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:
Diffstat (limited to 'source')
-rw-r--r--source/blender/blendthumb/CMakeLists.txt2
-rw-r--r--source/blender/blenfont/BLF_api.h26
-rw-r--r--source/blender/blenfont/CMakeLists.txt1
-rw-r--r--source/blender/blenfont/intern/blf.c71
-rw-r--r--source/blender/blenfont/intern/blf_default.c90
-rw-r--r--source/blender/blenfont/intern/blf_font.c6
-rw-r--r--source/blender/blenfont/intern/blf_internal.h2
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h1
-rw-r--r--source/blender/blenkernel/BKE_action.h11
-rw-r--r--source/blender/blenkernel/BKE_anim_visualization.h5
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h6
-rw-r--r--source/blender/blenkernel/BKE_collection.h22
-rw-r--r--source/blender/blenkernel/BKE_colortools.h5
-rw-r--r--source/blender/blenkernel/BKE_constraint.h13
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h3
-rw-r--r--source/blender/blenkernel/BKE_gpencil.h11
-rw-r--r--source/blender/blenkernel/BKE_gpencil_curve.h21
-rw-r--r--source/blender/blenkernel/BKE_gpencil_geom.h31
-rw-r--r--source/blender/blenkernel/BKE_gpencil_modifier.h8
-rw-r--r--source/blender/blenkernel/BKE_idprop.h2
-rw-r--r--source/blender/blenkernel/BKE_idtype.h11
-rw-r--r--source/blender/blenkernel/BKE_layer.h14
-rw-r--r--source/blender/blenkernel/BKE_mesh.h2
-rw-r--r--source/blender/blenkernel/BKE_modifier.h14
-rw-r--r--source/blender/blenkernel/BKE_multires.h18
-rw-r--r--source/blender/blenkernel/BKE_node.h7
-rw-r--r--source/blender/blenkernel/BKE_object.h10
-rw-r--r--source/blender/blenkernel/BKE_paint.h16
-rw-r--r--source/blender/blenkernel/BKE_particle.h19
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h12
-rw-r--r--source/blender/blenkernel/BKE_screen.h37
-rw-r--r--source/blender/blenkernel/BKE_sequencer_offscreen.h2
-rw-r--r--source/blender/blenkernel/BKE_shader_fx.h8
-rw-r--r--source/blender/blenkernel/CMakeLists.txt7
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c2
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c17
-rw-r--r--source/blender/blenkernel/intern/action.c174
-rw-r--r--source/blender/blenkernel/intern/anim_visualization.c31
-rw-r--r--source/blender/blenkernel/intern/armature.c69
-rw-r--r--source/blender/blenkernel/intern/armature_test.cc67
-rw-r--r--source/blender/blenkernel/intern/blender.c7
-rw-r--r--source/blender/blenkernel/intern/boids.c2
-rw-r--r--source/blender/blenkernel/intern/bpath.c3
-rw-r--r--source/blender/blenkernel/intern/brush.c35
-rw-r--r--source/blender/blenkernel/intern/cachefile.c2
-rw-r--r--source/blender/blenkernel/intern/camera.c2
-rw-r--r--source/blender/blenkernel/intern/cloth.c22
-rw-r--r--source/blender/blenkernel/intern/collection.c183
-rw-r--r--source/blender/blenkernel/intern/colortools.c24
-rw-r--r--source/blender/blenkernel/intern/constraint.c186
-rw-r--r--source/blender/blenkernel/intern/crazyspace.c4
-rw-r--r--source/blender/blenkernel/intern/curve.c798
-rw-r--r--source/blender/blenkernel/intern/curve_decimate.c4
-rw-r--r--source/blender/blenkernel/intern/curve_deform.c8
-rw-r--r--source/blender/blenkernel/intern/customdata.c4
-rw-r--r--source/blender/blenkernel/intern/displist.c423
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c19
-rw-r--r--source/blender/blenkernel/intern/editmesh_tangent.c1
-rw-r--r--source/blender/blenkernel/intern/effect.c16
-rw-r--r--source/blender/blenkernel/intern/fcurve.c88
-rw-r--r--source/blender/blenkernel/intern/fcurve_test.cc28
-rw-r--r--source/blender/blenkernel/intern/fluid.c65
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c3
-rw-r--r--source/blender/blenkernel/intern/font.c4
-rw-r--r--source/blender/blenkernel/intern/gpencil.c138
-rw-r--r--source/blender/blenkernel/intern/gpencil_curve.c874
-rw-r--r--source/blender/blenkernel/intern/gpencil_geom.c94
-rw-r--r--source/blender/blenkernel/intern/gpencil_modifier.c174
-rw-r--r--source/blender/blenkernel/intern/hair.c2
-rw-r--r--source/blender/blenkernel/intern/icons.c2
-rw-r--r--source/blender/blenkernel/intern/idprop.c60
-rw-r--r--source/blender/blenkernel/intern/image.c19
-rw-r--r--source/blender/blenkernel/intern/image_gen.c12
-rw-r--r--source/blender/blenkernel/intern/ipo.c77
-rw-r--r--source/blender/blenkernel/intern/key.c12
-rw-r--r--source/blender/blenkernel/intern/lattice.c2
-rw-r--r--source/blender/blenkernel/intern/lattice_deform.c2
-rw-r--r--source/blender/blenkernel/intern/lattice_deform_test.cc12
-rw-r--r--source/blender/blenkernel/intern/layer.c132
-rw-r--r--source/blender/blenkernel/intern/layer_utils.c28
-rw-r--r--source/blender/blenkernel/intern/lib_id.c13
-rw-r--r--source/blender/blenkernel/intern/lib_override.c148
-rw-r--r--source/blender/blenkernel/intern/library.c2
-rw-r--r--source/blender/blenkernel/intern/light.c2
-rw-r--r--source/blender/blenkernel/intern/lightprobe.c2
-rw-r--r--source/blender/blenkernel/intern/linestyle.c2
-rw-r--r--source/blender/blenkernel/intern/main_idmap.c1
-rw-r--r--source/blender/blenkernel/intern/mask.c2
-rw-r--r--source/blender/blenkernel/intern/material.c2
-rw-r--r--source/blender/blenkernel/intern/mball.c2
-rw-r--r--source/blender/blenkernel/intern/mball_tessellate.c12
-rw-r--r--source/blender/blenkernel/intern/mesh.c51
-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.c1
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c1
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c1
-rw-r--r--source/blender/blenkernel/intern/modifier.c451
-rw-r--r--source/blender/blenkernel/intern/movieclip.c4
-rw-r--r--source/blender/blenkernel/intern/multires.c886
-rw-r--r--source/blender/blenkernel/intern/multires_reshape.c2
-rw-r--r--source/blender/blenkernel/intern/multires_reshape.h14
-rw-r--r--source/blender/blenkernel/intern/multires_reshape_apply_base.c5
-rw-r--r--source/blender/blenkernel/intern/multires_reshape_subdivide.c2
-rw-r--r--source/blender/blenkernel/intern/multires_reshape_util.c28
-rw-r--r--source/blender/blenkernel/intern/multires_subdiv.c2
-rw-r--r--source/blender/blenkernel/intern/multires_versioning.c106
-rw-r--r--source/blender/blenkernel/intern/node.c11
-rw-r--r--source/blender/blenkernel/intern/object.c646
-rw-r--r--source/blender/blenkernel/intern/object_deform.c4
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c2
-rw-r--r--source/blender/blenkernel/intern/ocean.c2
-rw-r--r--source/blender/blenkernel/intern/packedFile.c22
-rw-r--r--source/blender/blenkernel/intern/paint.c75
-rw-r--r--source/blender/blenkernel/intern/particle.c548
-rw-r--r--source/blender/blenkernel/intern/particle_child.c70
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c18
-rw-r--r--source/blender/blenkernel/intern/particle_system.c191
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c1
-rw-r--r--source/blender/blenkernel/intern/pointcache.c255
-rw-r--r--source/blender/blenkernel/intern/pointcloud.cc (renamed from source/blender/blenkernel/intern/pointcloud.c)88
-rw-r--r--source/blender/blenkernel/intern/scene.c1122
-rw-r--r--source/blender/blenkernel/intern/screen.c877
-rw-r--r--source/blender/blenkernel/intern/shader_fx.c50
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c4
-rw-r--r--source/blender/blenkernel/intern/simulation.cc4
-rw-r--r--source/blender/blenkernel/intern/softbody.c10
-rw-r--r--source/blender/blenkernel/intern/sound.c10
-rw-r--r--source/blender/blenkernel/intern/speaker.c2
-rw-r--r--source/blender/blenkernel/intern/subdiv_displacement_multires.c2
-rw-r--r--source/blender/blenkernel/intern/text.c6
-rw-r--r--source/blender/blenkernel/intern/texture.c4
-rw-r--r--source/blender/blenkernel/intern/tracking.c1
-rw-r--r--source/blender/blenkernel/intern/tracking_solver.c8
-rw-r--r--source/blender/blenkernel/intern/tracking_util.c4
-rw-r--r--source/blender/blenkernel/intern/undo_system.c8
-rw-r--r--source/blender/blenkernel/intern/unit.c10
-rw-r--r--source/blender/blenkernel/intern/volume.cc51
-rw-r--r--source/blender/blenkernel/intern/volume_render.cc10
-rw-r--r--source/blender/blenkernel/intern/workspace.c105
-rw-r--r--source/blender/blenkernel/intern/world.c2
-rw-r--r--source/blender/blenlib/BLI_args.h46
-rw-r--r--source/blender/blenlib/BLI_bitmap.h2
-rw-r--r--source/blender/blenlib/BLI_ghash.h7
-rw-r--r--source/blender/blenlib/BLI_linklist_stack.h14
-rw-r--r--source/blender/blenlib/BLI_listbase_wrapper.hh3
-rw-r--r--source/blender/blenlib/BLI_map.hh16
-rw-r--r--source/blender/blenlib/BLI_math_base.h3
-rw-r--r--source/blender/blenlib/BLI_math_geom.h8
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h8
-rw-r--r--source/blender/blenlib/BLI_noise.h85
-rw-r--r--source/blender/blenlib/BLI_set.hh2
-rw-r--r--source/blender/blenlib/BLI_string.h1
-rw-r--r--source/blender/blenlib/BLI_string_utf8.h1
-rw-r--r--source/blender/blenlib/BLI_task.hh12
-rw-r--r--source/blender/blenlib/intern/BLI_args.c76
-rw-r--r--source/blender/blenlib/intern/BLI_heap.c3
-rw-r--r--source/blender/blenlib/intern/array_store.c16
-rw-r--r--source/blender/blenlib/intern/boxpack_2d.c4
-rw-r--r--source/blender/blenlib/intern/convexhull_2d.c3
-rw-r--r--source/blender/blenlib/intern/delaunay_2d.cc44
-rw-r--r--source/blender/blenlib/intern/math_base.c36
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c2
-rw-r--r--source/blender/blenlib/intern/math_boolean.cc2
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c1
-rw-r--r--source/blender/blenlib/intern/math_geom.c80
-rw-r--r--source/blender/blenlib/intern/math_interp.c6
-rw-r--r--source/blender/blenlib/intern/math_matrix.c67
-rw-r--r--source/blender/blenlib/intern/math_vector.c2
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c2
-rw-r--r--source/blender/blenlib/intern/mesh_boolean.cc2
-rw-r--r--source/blender/blenlib/intern/mesh_intersect.cc14
-rw-r--r--source/blender/blenlib/intern/noise.c301
-rw-r--r--source/blender/blenlib/intern/rct.c2
-rw-r--r--source/blender/blenlib/intern/scanfill_utils.c4
-rw-r--r--source/blender/blenlib/intern/smallhash.c1
-rw-r--r--source/blender/blenlib/intern/sort.c4
-rw-r--r--source/blender/blenlib/intern/storage_apple.mm2
-rw-r--r--source/blender/blenlib/intern/task_pool.cc10
-rw-r--r--source/blender/blenlib/intern/task_range.cc6
-rw-r--r--source/blender/blenlib/intern/voxel.c44
-rw-r--r--source/blender/blenlib/tests/BLI_array_store_test.cc18
-rw-r--r--source/blender/blenlib/tests/BLI_array_utils_test.cc2
-rw-r--r--source/blender/blenlib/tests/BLI_delaunay_2d_test.cc4
-rw-r--r--source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc12
-rw-r--r--source/blender/blenlib/tests/BLI_ghash_test.cc18
-rw-r--r--source/blender/blenlib/tests/BLI_heap_simple_test.cc14
-rw-r--r--source/blender/blenlib/tests/BLI_heap_test.cc22
-rw-r--r--source/blender/blenlib/tests/BLI_kdopbvh_test.cc4
-rw-r--r--source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc12
-rw-r--r--source/blender/blenlib/tests/BLI_listbase_test.cc22
-rw-r--r--source/blender/blenlib/tests/BLI_map_test.cc37
-rw-r--r--source/blender/blenlib/tests/BLI_math_base_test.cc18
-rw-r--r--source/blender/blenlib/tests/BLI_path_util_test.cc86
-rw-r--r--source/blender/blenlib/tests/BLI_polyfill_2d_test.cc4
-rw-r--r--source/blender/blenlib/tests/BLI_set_test.cc6
-rw-r--r--source/blender/blenlib/tests/BLI_stack_cxx_test.cc4
-rw-r--r--source/blender/blenlib/tests/BLI_string_test.cc42
-rw-r--r--source/blender/blenlib/tests/BLI_string_utf8_test.cc4
-rw-r--r--source/blender/blenlib/tests/BLI_task_graph_test.cc48
-rw-r--r--source/blender/blenlib/tests/BLI_task_test.cc16
-rw-r--r--source/blender/blenlib/tests/BLI_vector_set_test.cc6
-rw-r--r--source/blender/blenlib/tests/BLI_vector_test.cc16
-rw-r--r--source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc12
-rw-r--r--source/blender/blenlib/tests/performance/BLI_task_performance_test.cc4
-rw-r--r--source/blender/blenloader/BLO_read_write.h26
-rw-r--r--source/blender/blenloader/CMakeLists.txt4
-rw-r--r--source/blender/blenloader/intern/readfile.c3815
-rw-r--r--source/blender/blenloader/intern/readfile.h5
-rw-r--r--source/blender/blenloader/intern/versioning_250.c37
-rw-r--r--source/blender/blenloader/intern/versioning_260.c10
-rw-r--r--source/blender/blenloader/intern/versioning_270.c3
-rw-r--r--source/blender/blenloader/intern/versioning_280.c18
-rw-r--r--source/blender/blenloader/intern/versioning_290.c242
-rw-r--r--source/blender/blenloader/intern/versioning_cycles.c5
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c44
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c16
-rw-r--r--source/blender/blenloader/intern/writefile.c1383
-rw-r--r--source/blender/blenloader/tests/blendfile_loading_base_test.cc6
-rw-r--r--source/blender/blentranslation/intern/blt_lang.c6
-rw-r--r--source/blender/blentranslation/msgfmt/CMakeLists.txt2
-rw-r--r--source/blender/bmesh/CMakeLists.txt2
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c1
-rw-r--r--source/blender/bmesh/intern/bmesh_delete.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.c1
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_duplicate.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c6
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon_edgenet.c12
-rw-r--r--source/blender/bmesh/intern/bmesh_query.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_structure.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c51
-rw-r--r--source/blender/bmesh/operators/bmo_fill_grid.c4
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c6
-rw-r--r--source/blender/bmesh/tests/bmesh_core_test.cc10
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c42
-rw-r--r--source/blender/bmesh/tools/bmesh_boolean.cc39
-rw-r--r--source/blender/bmesh/tools/bmesh_edgenet.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_path_region.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_path_region_uv.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_region_match.c6
-rw-r--r--source/blender/compositor/CMakeLists.txt6
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.cpp4
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.cpp8
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp29
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp20
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cpp4
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.cpp6
-rw-r--r--source/blender/compositor/intern/COM_Node.cpp20
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.cpp6
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cpp8
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.cpp22
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.cpp8
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedOperation.cpp8
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp38
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_CombineColorNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.cpp12
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.cpp9
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.cpp12
-rw-r--r--source/blender/compositor/nodes/COM_SeparateColorNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.cpp2
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp41
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp22
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_CryptomatteOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_DenoiseOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.cpp30
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.cpp20
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp20
-rw-r--r--source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cpp60
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.cpp24
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_KeyingBlurOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_KeyingClipOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_KeyingDespillOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_KeyingOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.cpp26
-rw-r--r--source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp55
-rw-r--r--source/blender/compositor/operations/COM_KeyingSetAlphaOperation.h39
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.cpp52
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.cpp22
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp44
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp78
-rw-r--r--source/blender/compositor/operations/COM_PixelateOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.cpp31
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SplitOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_SunBeamsOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp41
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.cpp16
-rw-r--r--source/blender/compositor/operations/COM_TrackPositionOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp48
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp36
-rw-r--r--source/blender/compositor/operations/COM_WrapOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.cpp32
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cache.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cycle.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_map.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc11
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc12
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc20
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc10
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_remove_noop.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.cc11
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna_test.cc8
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_transitive.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline.cc9
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_all_objects.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_compositor.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_from_ids.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_render.cc6
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_view_layer.cc6
-rw-r--r--source/blender/depsgraph/intern/debug/deg_debug.cc10
-rw-r--r--source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc6
-rw-r--r--source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc6
-rw-r--r--source/blender/depsgraph/intern/depsgraph.cc8
-rw-r--r--source/blender/depsgraph/intern/depsgraph_physics.cc6
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_foreach.cc6
-rw-r--r--source/blender/depsgraph/intern/depsgraph_registry.cc6
-rw-r--r--source/blender/depsgraph/intern/depsgraph_relation.cc6
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc10
-rw-r--r--source/blender/depsgraph/intern/depsgraph_update.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc8
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc13
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_flush.cc9
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc9
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_stats.cc6
-rw-r--r--source/blender/depsgraph/intern/node/deg_node.cc6
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_component.cc6
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_factory.cc6
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_id.cc8
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.cc6
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_time.cc6
-rw-r--r--source/blender/draw/CMakeLists.txt11
-rw-r--r--source/blender/draw/DRW_engine.h2
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c79
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.h5
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_lookdev.c16
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c1
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c3
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h1
-rw-r--r--source/blender/draw/engines/eevee/eevee_shadows.c1
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c3
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_cache_utils.c2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_data.c6
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h2
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl8
-rw-r--r--source/blender/draw/engines/overlay/overlay_engine.c1
-rw-r--r--source/blender/draw/engines/overlay/overlay_extra.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_gpencil.c61
-rw-r--r--source/blender/draw/engines/overlay/overlay_image.c4
-rw-r--r--source/blender/draw/engines/overlay/overlay_private.h4
-rw-r--r--source/blender/draw/engines/overlay/overlay_wireframe.c2
-rw-r--r--source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl6
-rw-r--r--source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl5
-rw-r--r--source/blender/draw/engines/overlay/shaders/wireframe_frag.glsl5
-rw-r--r--source/blender/draw/engines/overlay/shaders/wireframe_vert.glsl9
-rw-r--r--source/blender/draw/intern/DRW_render.h1
-rw-r--r--source/blender/draw/intern/draw_cache.c67
-rw-r--r--source/blender/draw/intern/draw_cache.h14
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_gpencil.c180
-rw-r--r--source/blender/draw/intern/draw_cache_impl_lattice.c6
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c8
-rw-r--r--source/blender/draw/intern/draw_instance_data.c370
-rw-r--r--source/blender/draw/intern/draw_instance_data.h22
-rw-r--r--source/blender/draw/intern/draw_manager.c7
-rw-r--r--source/blender/draw/intern/draw_manager.h16
-rw-r--r--source/blender/draw/intern/draw_manager_data.c22
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c18
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c1
-rw-r--r--source/blender/draw/intern/draw_view.c1
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c32
-rw-r--r--source/blender/editors/animation/anim_deps.c3
-rw-r--r--source/blender/editors/animation/anim_filter.c3
-rw-r--r--source/blender/editors/animation/anim_ops.c3
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c20
-rw-r--r--source/blender/editors/armature/armature_naming.c2
-rw-r--r--source/blender/editors/armature/armature_select.c8
-rw-r--r--source/blender/editors/armature/meshlaplacian.c3
-rw-r--r--source/blender/editors/armature/pose_edit.c2
-rw-r--r--source/blender/editors/armature/pose_slide.c6
-rw-r--r--source/blender/editors/curve/editcurve.c588
-rw-r--r--source/blender/editors/curve/editcurve_add.c10
-rw-r--r--source/blender/editors/curve/editcurve_query.c8
-rw-r--r--source/blender/editors/curve/editcurve_select.c41
-rw-r--r--source/blender/editors/curve/editfont.c21
-rw-r--r--source/blender/editors/curve/editfont_undo.c1
-rw-r--r--source/blender/editors/gpencil/CMakeLists.txt1
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c46
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_add_monkey.c56
-rw-r--r--source/blender/editors/gpencil/gpencil_add_stroke.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c16
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c57
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c1839
-rw-r--r--source/blender/editors/gpencil/gpencil_edit_curve.c214
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h59
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c20
-rw-r--r--source/blender/editors/gpencil/gpencil_merge.c9
-rw-r--r--source/blender/editors/gpencil/gpencil_mesh.c165
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c22
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c14
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_sculpt_paint.c7
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c1574
-rw-r--r--source/blender/editors/gpencil/gpencil_trace.h4
-rw-r--r--source/blender/editors/gpencil/gpencil_trace_ops.c335
-rw-r--r--source/blender/editors/gpencil/gpencil_trace_utils.c5
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c111
-rw-r--r--source/blender/editors/gpencil/gpencil_uv.c14
-rw-r--r--source/blender/editors/gpencil/gpencil_vertex_paint.c25
-rw-r--r--source/blender/editors/include/ED_buttons.h3
-rw-r--r--source/blender/editors/include/ED_curve.h2
-rw-r--r--source/blender/editors/include/ED_fileselect.h4
-rw-r--r--source/blender/editors/include/ED_gizmo_library.h2
-rw-r--r--source/blender/editors/include/ED_gpencil.h10
-rw-r--r--source/blender/editors/include/ED_image.h7
-rw-r--r--source/blender/editors/include/ED_numinput.h1
-rw-r--r--source/blender/editors/include/ED_object.h1
-rw-r--r--source/blender/editors/include/ED_screen.h1
-rw-r--r--source/blender/editors/include/ED_undo.h1
-rw-r--r--source/blender/editors/include/ED_view3d.h4
-rw-r--r--source/blender/editors/include/UI_interface.h15
-rw-r--r--source/blender/editors/interface/interface.c226
-rw-r--r--source/blender/editors/interface/interface_button_group.c1
-rw-r--r--source/blender/editors/interface/interface_draw.c6
-rw-r--r--source/blender/editors/interface/interface_eyedropper.c2
-rw-r--r--source/blender/editors/interface/interface_handlers.c75
-rw-r--r--source/blender/editors/interface/interface_intern.h7
-rw-r--r--source/blender/editors/interface/interface_layout.c18
-rw-r--r--source/blender/editors/interface/interface_panel.c398
-rw-r--r--source/blender/editors/interface/interface_region_hud.c2
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c2
-rw-r--r--source/blender/editors/interface/interface_template_search_menu.c4
-rw-r--r--source/blender/editors/interface/interface_templates.c14
-rw-r--r--source/blender/editors/interface/interface_utils.c6
-rw-r--r--source/blender/editors/interface/interface_widgets.c43
-rw-r--r--source/blender/editors/interface/view2d_ops.c6
-rw-r--r--source/blender/editors/io/io_alembic.c4
-rw-r--r--source/blender/editors/io/io_cache.c2
-rw-r--r--source/blender/editors/io/io_collada.c4
-rw-r--r--source/blender/editors/io/io_usd.c2
-rw-r--r--source/blender/editors/lattice/CMakeLists.txt2
-rw-r--r--source/blender/editors/mask/mask_add.c2
-rw-r--r--source/blender/editors/mask/mask_draw.c2
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt2
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c128
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin.c3
-rw-r--r--source/blender/editors/mesh/editmesh_intersect.c17
-rw-r--r--source/blender/editors/mesh/editmesh_preselect_edgering.c2
-rw-r--r--source/blender/editors/mesh/editmesh_select_similar.c2
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c6
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c1
-rw-r--r--source/blender/editors/mesh/meshtools.c2
-rw-r--r--source/blender/editors/metaball/CMakeLists.txt2
-rw-r--r--source/blender/editors/object/CMakeLists.txt2
-rw-r--r--source/blender/editors/object/object_add.c2
-rw-r--r--source/blender/editors/object/object_bake.c11
-rw-r--r--source/blender/editors/object/object_constraint.c2
-rw-r--r--source/blender/editors/object/object_data_transfer.c52
-rw-r--r--source/blender/editors/object/object_edit.c2
-rw-r--r--source/blender/editors/object/object_hook.c8
-rw-r--r--source/blender/editors/object/object_modifier.c49
-rw-r--r--source/blender/editors/object/object_relations.c18
-rw-r--r--source/blender/editors/object/object_transform.c4
-rw-r--r--source/blender/editors/object/object_vgroup.c74
-rw-r--r--source/blender/editors/object/object_volume.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c2
-rw-r--r--source/blender/editors/physics/particle_object.c4
-rw-r--r--source/blender/editors/physics/physics_pointcache.c40
-rw-r--r--source/blender/editors/physics/rigidbody_world.c2
-rw-r--r--source/blender/editors/render/CMakeLists.txt2
-rw-r--r--source/blender/editors/render/render_internal.c17
-rw-r--r--source/blender/editors/render/render_opengl.c7
-rw-r--r--source/blender/editors/render/render_preview.c2
-rw-r--r--source/blender/editors/screen/area.c55
-rw-r--r--source/blender/editors/screen/screen_context.c3
-rw-r--r--source/blender/editors/screen/screen_draw.c2
-rw-r--r--source/blender/editors/screen/screen_edit.c6
-rw-r--r--source/blender/editors/screen/screen_geometry.c4
-rw-r--r--source/blender/editors/screen/screen_ops.c16
-rw-r--r--source/blender/editors/screen/screendump.c2
-rw-r--r--source/blender/editors/screen/workspace_edit.c2
-rw-r--r--source/blender/editors/sculpt_paint/CMakeLists.txt2
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c5
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c256
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c402
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_cloth.c87
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_detail.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_dyntopo.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_face_set.c223
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_color.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_mask.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_mesh.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_mask_expand.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_transform.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c21
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c4
-rw-r--r--source/blender/editors/sound/sound_ops.c12
-rw-r--r--source/blender/editors/space_action/action_draw.c2
-rw-r--r--source/blender/editors/space_action/action_edit.c2
-rw-r--r--source/blender/editors/space_api/spacetypes.c9
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c46
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c4
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c2
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c2
-rw-r--r--source/blender/editors/space_clip/clip_editor.c2
-rw-r--r--source/blender/editors/space_clip/clip_ops.c4
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c6
-rw-r--r--source/blender/editors/space_clip/tracking_select.c12
-rw-r--r--source/blender/editors/space_file/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_file/file_ops.c24
-rw-r--r--source/blender/editors/space_file/file_panels.c4
-rw-r--r--source/blender/editors/space_file/filelist.c16
-rw-r--r--source/blender/editors/space_file/filelist.h1
-rw-r--r--source/blender/editors/space_file/filesel.c81
-rw-r--r--source/blender/editors/space_file/fsmenu.c48
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c4
-rw-r--r--source/blender/editors/space_graph/graph_edit.c75
-rw-r--r--source/blender/editors/space_graph/graph_intern.h1
-rw-r--r--source/blender/editors/space_graph/graph_ops.c1
-rw-r--r--source/blender/editors/space_image/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_image/image_buttons.c2
-rw-r--r--source/blender/editors/space_image/image_ops.c80
-rw-r--r--source/blender/editors/space_info/info_ops.c2
-rw-r--r--source/blender/editors/space_info/info_stats.c6
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c10
-rw-r--r--source/blender/editors/space_node/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_node/drawnode.c1
-rw-r--r--source/blender/editors/space_node/node_add.c2
-rw-r--r--source/blender/editors/space_node/node_buttons.c2
-rw-r--r--source/blender/editors/space_node/node_edit.c2
-rw-r--r--source/blender/editors/space_node/node_group.c56
-rw-r--r--source/blender/editors/space_node/node_intern.h2
-rw-r--r--source/blender/editors/space_node/node_view.c36
-rw-r--r--source/blender/editors/space_outliner/CMakeLists.txt6
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h19
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c228
-rw-r--r--source/blender/editors/space_outliner/outliner_sync.c9
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c3
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c412
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c19
-rw-r--r--source/blender/editors/space_outliner/tree/common.cc41
-rw-r--r--source/blender/editors/space_outliner/tree/tree_display.cc60
-rw-r--r--source/blender/editors/space_outliner/tree/tree_display.h64
-rw-r--r--source/blender/editors/space_outliner/tree/tree_display.hh113
-rw-r--r--source/blender/editors/space_outliner/tree/tree_display_libraries.cc213
-rw-r--r--source/blender/editors/space_outliner/tree/tree_display_view_layer.cc284
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c30
-rw-r--r--source/blender/editors/space_sequencer/sequencer_buttons.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c58
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c78
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_modifier.c3
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c15
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c3
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c3
-rw-r--r--source/blender/editors/space_text/text_draw.c8
-rw-r--r--source/blender/editors/space_text/text_format_lua.c2
-rw-r--r--source/blender/editors/space_text/text_format_osl.c2
-rw-r--r--source/blender/editors/space_text/text_format_pov.c2
-rw-r--r--source/blender/editors/space_text/text_format_pov_ini.c2
-rw-r--r--source/blender/editors/space_text/text_format_py.c4
-rw-r--r--source/blender/editors/space_text/text_ops.c86
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c13
-rw-r--r--source/blender/editors/space_view3d/view3d_camera_control.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c18
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h3
-rw-r--r--source/blender/editors/space_view3d/view3d_placement.c595
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c80
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c15
-rw-r--r--source/blender/editors/transform/CMakeLists.txt2
-rw-r--r--source/blender/editors/transform/transform.c26
-rw-r--r--source/blender/editors/transform/transform.h94
-rw-r--r--source/blender/editors/transform/transform_constraints.c7
-rw-r--r--source/blender/editors/transform/transform_convert_armature.c2
-rw-r--r--source/blender/editors/transform/transform_convert_curve.c2
-rw-r--r--source/blender/editors/transform/transform_convert_gpencil.c436
-rw-r--r--source/blender/editors/transform/transform_convert_sequencer.c3
-rw-r--r--source/blender/editors/transform/transform_generics.c2
-rw-r--r--source/blender/editors/transform/transform_gizmo_2d.c2
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c45
-rw-r--r--source/blender/editors/transform/transform_mode.c22
-rw-r--r--source/blender/editors/transform/transform_mode_align.c4
-rw-r--r--source/blender/editors/transform/transform_mode_baketime.c4
-rw-r--r--source/blender/editors/transform/transform_mode_bbone_resize.c4
-rw-r--r--source/blender/editors/transform/transform_mode_bend.c4
-rw-r--r--source/blender/editors/transform/transform_mode_boneenvelope.c4
-rw-r--r--source/blender/editors/transform/transform_mode_boneroll.c4
-rw-r--r--source/blender/editors/transform/transform_mode_curveshrinkfatten.c4
-rw-r--r--source/blender/editors/transform/transform_mode_edge_bevelweight.c4
-rw-r--r--source/blender/editors/transform/transform_mode_edge_crease.c4
-rw-r--r--source/blender/editors/transform/transform_mode_edge_rotate_normal.c4
-rw-r--r--source/blender/editors/transform/transform_mode_edge_seq_slide.c4
-rw-r--r--source/blender/editors/transform/transform_mode_edge_slide.c4
-rw-r--r--source/blender/editors/transform/transform_mode_gpopacity.c18
-rw-r--r--source/blender/editors/transform/transform_mode_gpshrinkfatten.c18
-rw-r--r--source/blender/editors/transform/transform_mode_maskshrinkfatten.c4
-rw-r--r--source/blender/editors/transform/transform_mode_mirror.c4
-rw-r--r--source/blender/editors/transform/transform_mode_push_pull.c4
-rw-r--r--source/blender/editors/transform/transform_mode_resize.c4
-rw-r--r--source/blender/editors/transform/transform_mode_rotate.c4
-rw-r--r--source/blender/editors/transform/transform_mode_shear.c4
-rw-r--r--source/blender/editors/transform/transform_mode_shrink_fatten.c4
-rw-r--r--source/blender/editors/transform/transform_mode_skin_resize.c4
-rw-r--r--source/blender/editors/transform/transform_mode_tilt.c4
-rw-r--r--source/blender/editors/transform/transform_mode_timescale.c4
-rw-r--r--source/blender/editors/transform/transform_mode_timeslide.c4
-rw-r--r--source/blender/editors/transform/transform_mode_timetranslate.c4
-rw-r--r--source/blender/editors/transform/transform_mode_trackball.c4
-rw-r--r--source/blender/editors/transform/transform_mode_translate.c4
-rw-r--r--source/blender/editors/transform/transform_mode_vert_slide.c4
-rw-r--r--source/blender/editors/transform/transform_ops.c16
-rw-r--r--source/blender/editors/transform/transform_snap.c3
-rw-r--r--source/blender/editors/undo/memfile_undo.c35
-rw-r--r--source/blender/editors/util/ed_util_imbuf.c5
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c5
-rw-r--r--source/blender/freestyle/CMakeLists.txt4
-rw-r--r--source/blender/freestyle/intern/application/AppCanvas.cpp8
-rw-r--r--source/blender/freestyle/intern/application/AppConfig.cpp14
-rw-r--r--source/blender/freestyle/intern/application/Controller.cpp65
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp30
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp54
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp40
-rw-r--r--source/blender/freestyle/intern/geometry/Bezier.cpp4
-rw-r--r--source/blender/freestyle/intern/geometry/FastGrid.cpp2
-rw-r--r--source/blender/freestyle/intern/geometry/FitCurve.cpp2
-rw-r--r--source/blender/freestyle/intern/geometry/GeomCleaner.cpp7
-rw-r--r--source/blender/freestyle/intern/geometry/GeomUtils.cpp8
-rw-r--r--source/blender/freestyle/intern/geometry/Grid.cpp6
-rw-r--r--source/blender/freestyle/intern/geometry/matrix_util.cpp14
-rw-r--r--source/blender/freestyle/intern/geometry/matrix_util.h14
-rw-r--r--source/blender/freestyle/intern/geometry/normal_cycle.cpp8
-rw-r--r--source/blender/freestyle/intern/image/GaussianFilter.cpp2
-rw-r--r--source/blender/freestyle/intern/image/ImagePyramid.cpp2
-rw-r--r--source/blender/freestyle/intern/image/ImagePyramid.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_BBox.cpp62
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp98
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp98
-rw-r--r--source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp22
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.cpp105
-rw-r--r--source/blender/freestyle/intern/python/BPy_Freestyle.cpp32
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp108
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsNoise.cpp112
-rw-r--r--source/blender/freestyle/intern/python/BPy_Id.cpp72
-rw-r--r--source/blender/freestyle/intern/python/BPy_IntegrationType.cpp92
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface0D.cpp136
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface1D.cpp112
-rw-r--r--source/blender/freestyle/intern/python/BPy_Iterator.cpp96
-rw-r--r--source/blender/freestyle/intern/python/BPy_MediumType.cpp80
-rw-r--r--source/blender/freestyle/intern/python/BPy_Nature.cpp150
-rw-r--r--source/blender/freestyle/intern/python/BPy_Operators.cpp210
-rw-r--r--source/blender/freestyle/intern/python/BPy_SShape.cpp92
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp146
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeShader.cpp98
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp88
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp88
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp100
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp100
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewMap.cpp78
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewShape.cpp126
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/Director.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp100
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp106
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp92
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp108
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp86
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp82
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp110
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp94
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp126
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp112
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp84
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp106
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp98
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp104
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp91
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp90
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp116
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp96
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp106
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp98
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp120
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp106
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp96
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp83
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp83
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp90
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp90
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp90
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp90
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp90
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp90
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp90
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp90
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp90
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp90
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp68
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp68
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp68
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp81
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp98
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp98
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp98
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp98
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp98
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp98
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp98
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp98
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp70
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp70
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp70
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp82
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp80
-rw-r--r--source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp89
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeGroup.cpp2
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeLight.cpp2
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp8
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp11
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp3
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp22
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.h34
-rw-r--r--source/blender/freestyle/intern/stroke/Canvas.cpp18
-rw-r--r--source/blender/freestyle/intern/stroke/Chain.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/ChainingIterators.cpp22
-rw-r--r--source/blender/freestyle/intern/stroke/ContextFunctions.cpp8
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.cpp78
-rw-r--r--source/blender/freestyle/intern/stroke/Operators.cpp22
-rw-r--r--source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp2
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.cpp56
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRenderer.cpp6
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.cpp14
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeTesselator.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/TextStrokeRenderer.cpp2
-rw-r--r--source/blender/freestyle/intern/system/StringUtils.cpp10
-rw-r--r--source/blender/freestyle/intern/view_map/AutoPtrHelper.h4
-rw-r--r--source/blender/freestyle/intern/view_map/BoxGrid.cpp6
-rw-r--r--source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp12
-rw-r--r--source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp6
-rw-r--r--source/blender/freestyle/intern/view_map/Functions0D.cpp34
-rw-r--r--source/blender/freestyle/intern/view_map/Functions1D.cpp12
-rw-r--r--source/blender/freestyle/intern/view_map/Interface0D.cpp10
-rw-r--r--source/blender/freestyle/intern/view_map/OccluderSource.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/Silhouette.cpp12
-rw-r--r--source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/SphericalGrid.cpp6
-rw-r--r--source/blender/freestyle/intern/view_map/SteerableViewMap.cpp8
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp93
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.cpp48
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp128
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIO.cpp24
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapTesselator.cpp4
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.cpp44
-rw-r--r--source/blender/freestyle/intern/winged_edge/WFillGrid.cpp2
-rw-r--r--source/blender/freestyle/intern/winged_edge/WSFillGrid.cpp2
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.cpp16
-rw-r--r--source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp93
-rw-r--r--source/blender/gpencil_modifiers/CMakeLists.txt2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c4
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c5
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c4
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c51
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c3
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c3
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c5
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c3
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c10
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c8
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c9
-rw-r--r--source/blender/gpu/GPU_material.h27
-rw-r--r--source/blender/gpu/GPU_shader.h3
-rw-r--r--source/blender/gpu/GPU_uniform_buffer.h1
-rw-r--r--source/blender/gpu/GPU_viewport.h2
-rw-r--r--source/blender/gpu/intern/gpu_batch.cc20
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c21
-rw-r--r--source/blender/gpu/intern/gpu_context.cc16
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.cc33
-rw-r--r--source/blender/gpu/intern/gpu_immediate.cc34
-rw-r--r--source/blender/gpu/intern/gpu_immediate_util.c12
-rw-r--r--source/blender/gpu/intern/gpu_index_buffer.cc6
-rw-r--r--source/blender/gpu/intern/gpu_material.c10
-rw-r--r--source/blender/gpu/intern/gpu_matrix.cc17
-rw-r--r--source/blender/gpu/intern/gpu_node_graph.c154
-rw-r--r--source/blender/gpu/intern/gpu_node_graph.h10
-rw-r--r--source/blender/gpu/intern/gpu_platform.cc6
-rw-r--r--source/blender/gpu/intern/gpu_select_sample_query.cc2
-rw-r--r--source/blender/gpu/intern/gpu_shader.cc33
-rw-r--r--source/blender/gpu/intern/gpu_shader_interface.cc8
-rw-r--r--source/blender/gpu/intern/gpu_state.cc20
-rw-r--r--source/blender/gpu/intern/gpu_texture.cc16
-rw-r--r--source/blender/gpu/intern/gpu_uniform_buffer.cc16
-rw-r--r--source/blender/gpu/intern/gpu_vertex_buffer.cc20
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c3
-rw-r--r--source/blender/gpu/opengl/gl_backend.cc10
-rw-r--r--source/blender/gpu/opengl/gl_batch.cc28
-rw-r--r--source/blender/gpu/opengl/gl_context.cc12
-rw-r--r--source/blender/gpu/opengl/gl_debug.cc22
-rw-r--r--source/blender/gpu/opengl/gl_debug_layer.cc2
-rw-r--r--source/blender/gpu/opengl/gl_drawlist.cc22
-rw-r--r--source/blender/gpu/opengl/gl_framebuffer.cc16
-rw-r--r--source/blender/gpu/opengl/gl_framebuffer.hh10
-rw-r--r--source/blender/gpu/opengl/gl_immediate.cc10
-rw-r--r--source/blender/gpu/opengl/gl_index_buffer.cc2
-rw-r--r--source/blender/gpu/opengl/gl_query.cc4
-rw-r--r--source/blender/gpu/opengl/gl_shader.cc20
-rw-r--r--source/blender/gpu/opengl/gl_shader_interface.cc4
-rw-r--r--source/blender/gpu/opengl/gl_state.cc18
-rw-r--r--source/blender/gpu/opengl/gl_texture.cc50
-rw-r--r--source/blender/gpu/opengl/gl_uniform_buffer.cc8
-rw-r--r--source/blender/gpu/opengl/gl_vertex_array.cc4
-rw-r--r--source/blender/gpu/opengl/gl_vertex_buffer.cc18
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl10
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp89
-rw-r--r--source/blender/imbuf/IMB_imbuf.h14
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h7
-rw-r--r--source/blender/imbuf/intern/IMB_filetype.h63
-rw-r--r--source/blender/imbuf/intern/bmp.c52
-rw-r--r--source/blender/imbuf/intern/cineon/cineon_dpx.c16
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c7
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.c37
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.h4
-rw-r--r--source/blender/imbuf/intern/colormanagement.c28
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp2
-rw-r--r--source/blender/imbuf/intern/dds/Image.cpp4
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.cpp49
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.h4
-rw-r--r--source/blender/imbuf/intern/filetype.c339
-rw-r--r--source/blender/imbuf/intern/indexer.c3
-rw-r--r--source/blender/imbuf/intern/iris.c18
-rw-r--r--source/blender/imbuf/intern/jp2.c39
-rw-r--r--source/blender/imbuf/intern/jpeg.c19
-rw-r--r--source/blender/imbuf/intern/oiio/openimageio_api.cpp39
-rw-r--r--source/blender/imbuf/intern/oiio/openimageio_api.h2
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp114
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.h4
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_stub.cpp6
-rw-r--r--source/blender/imbuf/intern/png.c24
-rw-r--r--source/blender/imbuf/intern/radiance_hdr.c33
-rw-r--r--source/blender/imbuf/intern/readimage.c6
-rw-r--r--source/blender/imbuf/intern/rectop.c77
-rw-r--r--source/blender/imbuf/intern/targa.c50
-rw-r--r--source/blender/imbuf/intern/tiff.c12
-rw-r--r--source/blender/imbuf/intern/util.c146
-rw-r--r--source/blender/imbuf/intern/writeimage.c16
-rw-r--r--source/blender/io/alembic/exporter/abc_export_capi.cc6
-rw-r--r--source/blender/io/alembic/exporter/abc_subdiv_disabler.cc2
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_curves.cc4
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_hair.cc20
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_nurbs.cc4
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_points.cc6
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_transform.cc2
-rw-r--r--source/blender/io/alembic/intern/abc_reader_curves.cc6
-rw-r--r--source/blender/io/alembic/intern/abc_reader_mesh.cc77
-rw-r--r--source/blender/io/alembic/intern/abc_reader_nurbs.cc4
-rw-r--r--source/blender/io/alembic/intern/abc_reader_object.cc6
-rw-r--r--source/blender/io/alembic/intern/abc_reader_points.cc4
-rw-r--r--source/blender/io/alembic/intern/abc_reader_transform.cc2
-rw-r--r--source/blender/io/alembic/intern/abc_util.cc4
-rw-r--r--source/blender/io/alembic/intern/alembic_capi.cc34
-rw-r--r--source/blender/io/alembic/tests/abc_matrix_test.cc70
-rw-r--r--source/blender/io/avi/intern/avi.c2
-rw-r--r--source/blender/io/collada/AnimationExporter.cpp6
-rw-r--r--source/blender/io/collada/AnimationImporter.cpp46
-rw-r--r--source/blender/io/collada/ArmatureExporter.cpp4
-rw-r--r--source/blender/io/collada/ArmatureImporter.cpp55
-rw-r--r--source/blender/io/collada/BCAnimationCurve.cpp22
-rw-r--r--source/blender/io/collada/BCAnimationSampler.cpp14
-rw-r--r--source/blender/io/collada/BCSampleData.cpp2
-rw-r--r--source/blender/io/collada/CMakeLists.txt2
-rw-r--r--source/blender/io/collada/ControllerExporter.cpp14
-rw-r--r--source/blender/io/collada/DocumentExporter.cpp8
-rw-r--r--source/blender/io/collada/DocumentImporter.cpp70
-rw-r--r--source/blender/io/collada/ExtraHandler.cpp7
-rw-r--r--source/blender/io/collada/GeometryExporter.cpp6
-rw-r--r--source/blender/io/collada/ImageExporter.cpp6
-rw-r--r--source/blender/io/collada/Materials.cpp10
-rw-r--r--source/blender/io/collada/MeshImporter.cpp34
-rw-r--r--source/blender/io/collada/SceneExporter.cpp6
-rw-r--r--source/blender/io/collada/SkinInfo.cpp9
-rw-r--r--source/blender/io/collada/TransformReader.cpp2
-rw-r--r--source/blender/io/collada/TransformWriter.cpp4
-rw-r--r--source/blender/io/collada/collada.cpp2
-rw-r--r--source/blender/io/collada/collada_internal.cpp2
-rw-r--r--source/blender/io/collada/collada_utils.cpp47
-rw-r--r--source/blender/io/common/intern/abstract_hierarchy_iterator.cc2
-rw-r--r--source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc6
-rw-r--r--source/blender/io/common/intern/hierarchy_context_order_test.cc20
-rw-r--r--source/blender/io/usd/intern/usd_capi.cc4
-rw-r--r--source/blender/io/usd/intern/usd_writer_abstract.cc5
-rw-r--r--source/blender/io/usd/intern/usd_writer_light.cc2
-rw-r--r--source/blender/makesdna/DNA_ID.h1
-rw-r--r--source/blender/makesdna/DNA_action_types.h2
-rw-r--r--source/blender/makesdna/DNA_brush_types.h3
-rw-r--r--source/blender/makesdna/DNA_camera_defaults.h2
-rw-r--r--source/blender/makesdna/DNA_color_types.h4
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h4
-rw-r--r--source/blender/makesdna/DNA_curve_types.h47
-rw-r--r--source/blender/makesdna/DNA_gpencil_modifier_defaults.h3
-rw-r--r--source/blender/makesdna/DNA_gpencil_modifier_types.h13
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h84
-rw-r--r--source/blender/makesdna/DNA_material_types.h3
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h4
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h50
-rw-r--r--source/blender/makesdna/DNA_modifier_defaults.h1
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h9
-rw-r--r--source/blender/makesdna/DNA_node_types.h9
-rw-r--r--source/blender/makesdna/DNA_object_force_types.h2
-rw-r--r--source/blender/makesdna/DNA_object_types.h2
-rw-r--r--source/blender/makesdna/DNA_scene_types.h6
-rw-r--r--source/blender/makesdna/DNA_screen_types.h59
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h13
-rw-r--r--source/blender/makesdna/DNA_shader_fx_types.h4
-rw-r--r--source/blender/makesdna/DNA_space_types.h46
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h9
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h21
-rw-r--r--source/blender/makesdna/DNA_view3d_defaults.h1
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h2
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c2
-rw-r--r--source/blender/makesdna/intern/dna_rename_defs.h3
-rw-r--r--source/blender/makesdna/intern/makesdna.c4
-rw-r--r--source/blender/makesrna/RNA_define.h4
-rw-r--r--source/blender/makesrna/RNA_enum_types.h3
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt6
-rw-r--r--source/blender/makesrna/intern/makesrna.c17
-rw-r--r--source/blender/makesrna/intern/rna_ID.c2
-rw-r--r--source/blender/makesrna/intern/rna_access.c106
-rw-r--r--source/blender/makesrna/intern/rna_access_compare_override.c25
-rw-r--r--source/blender/makesrna/intern/rna_action.c2
-rw-r--r--source/blender/makesrna/intern/rna_armature.c2
-rw-r--r--source/blender/makesrna/intern/rna_brush.c78
-rw-r--r--source/blender/makesrna/intern/rna_camera.c9
-rw-r--r--source/blender/makesrna/intern/rna_collection.c2
-rw-r--r--source/blender/makesrna/intern/rna_color.c5
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c46
-rw-r--r--source/blender/makesrna/intern/rna_curve.c8
-rw-r--r--source/blender/makesrna/intern/rna_curveprofile.c3
-rw-r--r--source/blender/makesrna/intern/rna_define.c61
-rw-r--r--source/blender/makesrna/intern/rna_fcurve_api.c47
-rw-r--r--source/blender/makesrna/intern/rna_fluid.c13
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c398
-rw-r--r--source/blender/makesrna/intern/rna_gpencil_modifier.c21
-rw-r--r--source/blender/makesrna/intern/rna_image.c5
-rw-r--r--source/blender/makesrna/intern/rna_linestyle.c4
-rw-r--r--source/blender/makesrna/intern/rna_material.c12
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c54
-rw-r--r--source/blender/makesrna/intern/rna_movieclip.c4
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c46
-rw-r--r--source/blender/makesrna/intern/rna_object.c9
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c10
-rw-r--r--source/blender/makesrna/intern/rna_particle.c4
-rw-r--r--source/blender/makesrna/intern/rna_pose.c20
-rw-r--r--source/blender/makesrna/intern/rna_scene.c36
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c2
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c114
-rw-r--r--source/blender/makesrna/intern/rna_sequencer_api.c7
-rw-r--r--source/blender/makesrna/intern/rna_sound.c3
-rw-r--r--source/blender/makesrna/intern/rna_space.c81
-rw-r--r--source/blender/makesrna/intern/rna_texture.c4
-rw-r--r--source/blender/makesrna/intern/rna_texture_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c66
-rw-r--r--source/blender/makesrna/intern/rna_ui.c13
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c73
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c4
-rw-r--r--source/blender/makesrna/intern/rna_wm_gizmo.c1
-rw-r--r--source/blender/modifiers/CMakeLists.txt2
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c2
-rw-r--r--source/blender/modifiers/intern/MOD_array.c8
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c2
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c16
-rw-r--r--source/blender/modifiers/intern/MOD_correctivesmooth.c10
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c9
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c2
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c2
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c18
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c2
-rw-r--r--source/blender/modifiers/intern/MOD_mask.cc36
-rw-r--r--source/blender/modifiers/intern/MOD_mesh_to_volume.cc60
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache.c8
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c10
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c4
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c7
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c15
-rw-r--r--source/blender/modifiers/intern/MOD_simulation.cc24
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c48
-rw-r--r--source/blender/modifiers/intern/MOD_solidify_nonmanifold.c21
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c4
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c110
-rw-r--r--source/blender/modifiers/intern/MOD_ui_common.c8
-rw-r--r--source/blender/modifiers/intern/MOD_volume_displace.cc50
-rw-r--r--source/blender/modifiers/intern/MOD_volume_to_mesh.cc60
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c2
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weighted_normal.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.c2
-rw-r--r--source/blender/nodes/CMakeLists.txt2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_cryptomatte.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_defocus.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_directionalblur.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_lensdist.c4
-rw-r--r--source/blender/nodes/intern/node_common.c24
-rw-r--r--source/blender/nodes/intern/node_socket.cc14
-rw-r--r--source/blender/nodes/intern/node_util.c43
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c2
-rw-r--r--source/blender/nodes/shader/node_shader_util.h2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_attribute.c18
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_particle_info.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_valToRgb.cc4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_value.cc2
-rw-r--r--source/blender/nodes/simulation/nodes/node_sim_common.cc4
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c2
-rw-r--r--source/blender/nodes/texture/node_texture_util.h2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_proc.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_texture.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops.c12
-rw-r--r--source/blender/python/generic/blf_py_api.c2
-rw-r--r--source/blender/python/generic/idprop_py_api.c24
-rw-r--r--source/blender/python/generic/imbuf_py_api.c14
-rw-r--r--source/blender/python/generic/py_capi_utils.c29
-rw-r--r--source/blender/python/gpu/gpu_py_shader.c1
-rw-r--r--source/blender/python/intern/bpy.h1
-rw-r--r--source/blender/python/intern/bpy_app.c3
-rw-r--r--source/blender/python/intern/bpy_app_translations.c20
-rw-r--r--source/blender/python/intern/bpy_interface.c32
-rw-r--r--source/blender/python/intern/bpy_library_load.c10
-rw-r--r--source/blender/python/intern/bpy_operator.c4
-rw-r--r--source/blender/python/intern/bpy_rna.c90
-rw-r--r--source/blender/python/intern/bpy_utils_units.c12
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c8
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c16
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c93
-rw-r--r--source/blender/python/mathutils/mathutils_noise.c41
-rw-r--r--source/blender/render/CMakeLists.txt56
-rw-r--r--source/blender/render/RE_bake.h (renamed from source/blender/render/extern/include/RE_bake.h)0
-rw-r--r--source/blender/render/RE_engine.h (renamed from source/blender/render/extern/include/RE_engine.h)0
-rw-r--r--source/blender/render/RE_multires_bake.h (renamed from source/blender/render/extern/include/RE_multires_bake.h)1
-rw-r--r--source/blender/render/RE_pipeline.h (renamed from source/blender/render/extern/include/RE_pipeline.h)1
-rw-r--r--source/blender/render/RE_texture.h (renamed from source/blender/render/extern/include/RE_render_ext.h)47
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h83
-rw-r--r--source/blender/render/intern/bake.c (renamed from source/blender/render/intern/source/bake_api.c)0
-rw-r--r--source/blender/render/intern/engine.c (renamed from source/blender/render/intern/source/external_engine.c)8
-rw-r--r--source/blender/render/intern/initrender.c (renamed from source/blender/render/intern/source/initrender.c)6
-rw-r--r--source/blender/render/intern/initrender.h (renamed from source/blender/render/intern/include/initrender.h)0
-rw-r--r--source/blender/render/intern/multires_bake.c (renamed from source/blender/render/intern/source/multires_bake.c)11
-rw-r--r--source/blender/render/intern/pipeline.c (renamed from source/blender/render/intern/source/pipeline.c)47
-rw-r--r--source/blender/render/intern/pipeline.h (renamed from source/blender/render/intern/include/renderpipeline.h)0
-rw-r--r--source/blender/render/intern/render_result.c (renamed from source/blender/render/intern/source/render_result.c)10
-rw-r--r--source/blender/render/intern/render_result.h (renamed from source/blender/render/intern/include/render_result.h)0
-rw-r--r--source/blender/render/intern/render_types.h (renamed from source/blender/render/intern/include/render_types.h)0
-rw-r--r--source/blender/render/intern/texture_common.h (renamed from source/blender/render/intern/include/texture.h)2
-rw-r--r--source/blender/render/intern/texture_image.c (renamed from source/blender/render/intern/source/imagetexture.c)137
-rw-r--r--source/blender/render/intern/texture_pointdensity.c (renamed from source/blender/render/intern/source/pointdensity.c)19
-rw-r--r--source/blender/render/intern/texture_procedural.c (renamed from source/blender/render/intern/source/render_texture.c)285
-rw-r--r--source/blender/render/intern/zbuf.c (renamed from source/blender/render/intern/source/zbuf.c)0
-rw-r--r--source/blender/render/intern/zbuf.h (renamed from source/blender/render/intern/include/zbuf.h)0
-rw-r--r--source/blender/sequencer/CMakeLists.txt38
-rw-r--r--source/blender/sequencer/SEQ_sequencer.h (renamed from source/blender/sequencer/BKE_sequencer.h)554
-rw-r--r--source/blender/sequencer/intern/clipboard.c179
-rw-r--r--source/blender/sequencer/intern/effects.c172
-rw-r--r--source/blender/sequencer/intern/effects.h50
-rw-r--r--source/blender/sequencer/intern/image_cache.c133
-rw-r--r--source/blender/sequencer/intern/image_cache.h72
-rw-r--r--source/blender/sequencer/intern/iterator.c168
-rw-r--r--source/blender/sequencer/intern/modifier.c454
-rw-r--r--source/blender/sequencer/intern/multiview.c67
-rw-r--r--source/blender/sequencer/intern/multiview.h57
-rw-r--r--source/blender/sequencer/intern/prefetch.c47
-rw-r--r--source/blender/sequencer/intern/prefetch.h53
-rw-r--r--source/blender/sequencer/intern/proxy.c593
-rw-r--r--source/blender/sequencer/intern/proxy.h45
-rw-r--r--source/blender/sequencer/intern/render.c2093
-rw-r--r--source/blender/sequencer/intern/render.h79
-rw-r--r--source/blender/sequencer/intern/sequencer.c5865
-rw-r--r--source/blender/sequencer/intern/sequencer.h37
-rw-r--r--source/blender/sequencer/intern/sound.c163
-rw-r--r--source/blender/sequencer/intern/strip_add.c551
-rw-r--r--source/blender/sequencer/intern/strip_edit.c196
-rw-r--r--source/blender/sequencer/intern/strip_relations.c468
-rw-r--r--source/blender/sequencer/intern/strip_select.c81
-rw-r--r--source/blender/sequencer/intern/strip_time.c353
-rw-r--r--source/blender/sequencer/intern/strip_time.h38
-rw-r--r--source/blender/sequencer/intern/strip_transform.c397
-rw-r--r--source/blender/sequencer/intern/utils.c549
-rw-r--r--source/blender/sequencer/intern/utils.h41
-rw-r--r--source/blender/shader_fx/CMakeLists.txt2
-rw-r--r--source/blender/shader_fx/intern/FX_ui_common.c4
-rw-r--r--source/blender/simulation/SIM_mass_spring.h2
-rw-r--r--source/blender/simulation/intern/ConstrainedConjugateGradient.h4
-rw-r--r--source/blender/simulation/intern/SIM_mass_spring.cpp49
-rw-r--r--source/blender/simulation/intern/eigen_utils.h2
-rw-r--r--source/blender/simulation/intern/hair_volume.cpp4
-rw-r--r--source/blender/simulation/intern/implicit.h2
-rw-r--r--source/blender/simulation/intern/implicit_blender.c2
-rw-r--r--source/blender/simulation/intern/implicit_eigen.cpp2
-rw-r--r--source/blender/windowmanager/CMakeLists.txt8
-rw-r--r--source/blender/windowmanager/WM_api.h4
-rw-r--r--source/blender/windowmanager/WM_types.h4
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo.c2
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c1
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c1
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c1
-rw-r--r--source/blender/windowmanager/intern/wm.c165
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c2
-rw-r--r--source/blender/windowmanager/intern/wm_event_query.c32
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c70
-rw-r--r--source/blender/windowmanager/intern/wm_files.c56
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c8
-rw-r--r--source/blender/windowmanager/intern/wm_gesture_ops.c2
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c7
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c9
-rw-r--r--source/blender/windowmanager/intern/wm_operator_props.c32
-rw-r--r--source/blender/windowmanager/intern/wm_operator_type.c5
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c111
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c4
-rw-r--r--source/blender/windowmanager/intern/wm_window.c2
-rw-r--r--source/creator/CMakeLists.txt55
-rw-r--r--source/creator/creator.c51
-rw-r--r--source/creator/creator_args.c755
-rw-r--r--source/creator/creator_intern.h22
m---------source/tools0
1325 files changed, 39308 insertions, 29601 deletions
diff --git a/source/blender/blendthumb/CMakeLists.txt b/source/blender/blendthumb/CMakeLists.txt
index 0b1ce5149da..cb121cb9c8d 100644
--- a/source/blender/blendthumb/CMakeLists.txt
+++ b/source/blender/blendthumb/CMakeLists.txt
@@ -28,7 +28,7 @@ set(SRC
src/Dll.cpp
)
-set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /nodefaultlib:MSVCRT.lib")
+string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG " /nodefaultlib:MSVCRT.lib")
add_library(BlendThumb SHARED ${SRC})
target_link_libraries(BlendThumb ${ZLIB_LIBRARIES})
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index bf84f5c57b3..1f39257a4c2 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -40,9 +40,6 @@ struct rcti;
int BLF_init(void);
void BLF_exit(void);
-void BLF_default_dpi(int dpi);
-void BLF_default_set(int fontid);
-int BLF_default(void); /* get default font ID so we can pass it to other functions */
void BLF_cache_clear(void);
@@ -77,7 +74,7 @@ void BLF_color4f(int fontid, float r, float g, float b, float a);
void BLF_color4fv(int fontid, const float rgba[4]);
void BLF_color3f(int fontid, float r, float g, float b);
void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha);
-/* also available: UI_FontThemeColor(fontid, colorid) */
+/* Also available: `UI_FontThemeColor(fontid, colorid)`. */
/* Set a 4x4 matrix to be multiplied before draw the text.
* Remember that you need call BLF_enable(BLF_MATRIX)
@@ -92,19 +89,12 @@ void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha);
*/
void BLF_matrix(int fontid, const float m[16]);
-/* Batch drawcalls together as long as
- * the modelview matrix and the font remain unchanged. */
+/* Batch draw-calls together as long as
+ * the model-view matrix and the font remain unchanged. */
void BLF_batch_draw_begin(void);
void BLF_batch_draw_flush(void);
void BLF_batch_draw_end(void);
-/* Draw the string using the default font, size and dpi. */
-void BLF_draw_default(float x, float y, float z, const char *str, size_t len) ATTR_NONNULL();
-void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len) ATTR_NONNULL();
-
-/* Set size and DPI, and return default font ID. */
-int BLF_set_default(void);
-
/* Draw the string using the current font. */
void BLF_draw_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info)
ATTR_NONNULL(2);
@@ -257,6 +247,16 @@ void BLF_thumb_preview(const char *filename,
int h,
int channels) ATTR_NONNULL();
+/* blf_default.c */
+void BLF_default_dpi(int dpi);
+void BLF_default_set(int fontid);
+int BLF_default(void); /* get default font ID so we can pass it to other functions */
+/* Draw the string using the default font, size and dpi. */
+void BLF_draw_default(float x, float y, float z, const char *str, size_t len) ATTR_NONNULL();
+void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len) ATTR_NONNULL();
+/* Set size and DPI, and return default font ID. */
+int BLF_set_default(void);
+
/* blf_font_default.c */
int BLF_load_default(const bool unique);
int BLF_load_mono_default(const bool unique);
diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt
index 3fd0dd95ef8..59a9072de57 100644
--- a/source/blender/blenfont/CMakeLists.txt
+++ b/source/blender/blenfont/CMakeLists.txt
@@ -38,6 +38,7 @@ set(INC_SYS
set(SRC
intern/blf.c
+ intern/blf_default.c
intern/blf_dir.c
intern/blf_font.c
intern/blf_font_default.c
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index c8940add738..48f283e67b9 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -37,10 +37,6 @@
#include "MEM_guardedalloc.h"
-#include "DNA_listBase.h"
-#include "DNA_userdef_types.h"
-#include "DNA_vec_types.h"
-
#include "BLI_math.h"
#include "BLI_threads.h"
@@ -48,9 +44,6 @@
#include "IMB_colormanagement.h"
-#include "UI_interface.h"
-
-#include "GPU_immediate.h"
#include "GPU_matrix.h"
#include "GPU_shader.h"
@@ -64,9 +57,6 @@
*/
#define BLF_MAX_FONT 16
-/* call BLF_default_set first! */
-#define ASSERT_DEFAULT_SET BLI_assert(global_font_default != -1)
-
#define BLF_RESULT_CHECK_INIT(r_info) \
if (r_info) { \
memset(r_info, 0, sizeof(*(r_info))); \
@@ -76,10 +66,6 @@
/* Font array. */
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_dpi = 72;
-
/* XXX, should these be made into global_font_'s too? */
int blf_mono_font = -1;
int blf_mono_font_render = -1;
@@ -98,16 +84,11 @@ int BLF_init(void)
global_font[i] = NULL;
}
- global_font_dpi = 72;
+ BLF_default_dpi(72);
return blf_font_init();
}
-void BLF_default_dpi(int dpi)
-{
- global_font_dpi = dpi;
-}
-
void BLF_exit(void)
{
for (int i = 0; i < BLF_MAX_FONT; i++) {
@@ -132,6 +113,11 @@ void BLF_cache_clear(void)
}
}
+bool blf_font_id_is_valid(int fontid)
+{
+ return blf_get(fontid) != NULL;
+}
+
static int blf_search(const char *name)
{
for (int i = 0; i < BLF_MAX_FONT; i++) {
@@ -155,20 +141,6 @@ static int blf_search_available(void)
return -1;
}
-void BLF_default_set(int fontid)
-{
- FontBLF *font = blf_get(fontid);
- if (font || fontid == -1) {
- global_font_default = fontid;
- }
-}
-
-int BLF_default(void)
-{
- ASSERT_DEFAULT_SET;
- return global_font_default;
-}
-
bool BLF_has_glyph(int fontid, unsigned int unicode)
{
FontBLF *font = blf_get(fontid);
@@ -515,37 +487,6 @@ void BLF_batch_draw_end(void)
g_batch.enabled = false;
}
-void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
-{
- ASSERT_DEFAULT_SET;
-
- 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);
-}
-
-/* same as above but call 'BLF_draw_ascii' */
-void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
-{
- ASSERT_DEFAULT_SET;
-
- 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 */
-}
-
-int BLF_set_default(void)
-{
- ASSERT_DEFAULT_SET;
-
- const uiStyle *style = UI_style_get();
- BLF_size(global_font_default, style->widgetlabel.points, global_font_dpi);
-
- return global_font_default;
-}
-
static void blf_draw_gl__start(FontBLF *font)
{
/*
diff --git a/source/blender/blenfont/intern/blf_default.c b/source/blender/blenfont/intern/blf_default.c
new file mode 100644
index 00000000000..7bbc865128d
--- /dev/null
+++ b/source/blender/blenfont/intern/blf_default.c
@@ -0,0 +1,90 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup blf
+ *
+ * Default API, that uses Blender's user preferences for the default size.
+ */
+
+#include "DNA_userdef_types.h"
+
+#include "BLI_assert.h"
+
+#include "BLF_api.h"
+
+#include "UI_interface.h"
+
+#include "blf_internal.h"
+
+/* call BLF_default_set first! */
+#define ASSERT_DEFAULT_SET BLI_assert(global_font_default != -1)
+
+/* Default size and dpi, for BLF_draw_default. */
+static int global_font_default = -1;
+static int global_font_dpi = 72;
+
+void BLF_default_dpi(int dpi)
+{
+ global_font_dpi = dpi;
+}
+
+void BLF_default_set(int fontid)
+{
+ if ((fontid == -1) || blf_font_id_is_valid(fontid)) {
+ global_font_default = fontid;
+ }
+}
+
+int BLF_default(void)
+{
+ ASSERT_DEFAULT_SET;
+ return global_font_default;
+}
+
+int BLF_set_default(void)
+{
+ ASSERT_DEFAULT_SET;
+
+ const uiStyle *style = UI_style_get();
+ BLF_size(global_font_default, style->widgetlabel.points, global_font_dpi);
+
+ return global_font_default;
+}
+
+void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
+{
+ ASSERT_DEFAULT_SET;
+
+ 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);
+}
+
+/* same as above but call 'BLF_draw_ascii' */
+void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
+{
+ ASSERT_DEFAULT_SET;
+
+ 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 */
+}
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 1501ee07b66..189cbaf152d 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -75,9 +75,9 @@ static SpinLock blf_glyph_cache_mutex;
* \{ */
/**
- * Drawcalls are precious! make them count!
- * Since most of the Text elems are not covered by other UI elements, we can
- * group some strings together and render them in one drawcall. This behavior
+ * Draw-calls are precious! make them count!
+ * Since most of the Text elements are not covered by other UI elements, we can
+ * group some strings together and render them in one draw-call. This behavior
* is on demand only, between #BLF_batch_draw_begin() and #BLF_batch_draw_end().
*/
static void blf_batch_draw_init(void)
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h
index b616f47a897..ada772c53d2 100644
--- a/source/blender/blenfont/intern/blf_internal.h
+++ b/source/blender/blenfont/intern/blf_internal.h
@@ -43,6 +43,8 @@ char *blf_dir_metrics_search(const char *filename);
int blf_font_init(void);
void blf_font_exit(void);
+bool blf_font_id_is_valid(int fontid);
+
void blf_draw_buffer__start(struct FontBLF *font);
void blf_draw_buffer__end(void);
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index b517ecfa599..092eec578c9 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -364,6 +364,7 @@ struct Mesh *editbmesh_get_eval_cage_and_final(struct Depsgraph *depsgraph,
float (*editbmesh_vert_coords_alloc(struct BMEditMesh *em, int *r_vert_len))[3];
bool editbmesh_modifier_is_enabled(struct Scene *scene,
+ const struct Object *ob,
struct ModifierData *md,
bool has_prev_mesh);
void makeDerivedMesh(struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 699387a18c7..d8605941974 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -30,6 +30,12 @@
extern "C" {
#endif
+struct BlendWriter;
+struct BlendDataReader;
+struct BlendLibReader;
+struct BlendExpander;
+struct bArmature;
+
/* The following structures are defined in DNA_action_types.h, and DNA_anim_types.h */
struct AnimationEvalContext;
struct FCurve;
@@ -216,6 +222,11 @@ void BKE_pose_rest(struct bPose *pose, bool selected_bones_only);
/* Tag pose for recalc. Also tag all related data to be recalc. */
void BKE_pose_tag_recalc(struct Main *bmain, struct bPose *pose);
+void BKE_pose_blend_write(struct BlendWriter *writer, struct bPose *pose, struct bArmature *arm);
+void BKE_pose_blend_read_data(struct BlendDataReader *reader, struct bPose *pose);
+void BKE_pose_blend_read_lib(struct BlendLibReader *reader, struct Object *ob, struct bPose *pose);
+void BKE_pose_blend_read_expand(struct BlendExpander *expander, struct bPose *pose);
+
#ifdef __cplusplus
};
#endif
diff --git a/source/blender/blenkernel/BKE_anim_visualization.h b/source/blender/blenkernel/BKE_anim_visualization.h
index fb7875a112e..decb2e0b210 100644
--- a/source/blender/blenkernel/BKE_anim_visualization.h
+++ b/source/blender/blenkernel/BKE_anim_visualization.h
@@ -32,6 +32,8 @@ struct Scene;
struct bAnimVizSettings;
struct bMotionPath;
struct bPoseChannel;
+struct BlendWriter;
+struct BlendDataReader;
/* ---------------------------------------------------- */
/* Animation Visualization */
@@ -48,6 +50,9 @@ struct bMotionPath *animviz_verify_motionpaths(struct ReportList *reports,
struct Object *ob,
struct bPoseChannel *pchan);
+void animviz_motionpath_blend_write(struct BlendWriter *writer, struct bMotionPath *mpath);
+void animviz_motionpath_blend_read_data(struct BlendDataReader *reader, struct bMotionPath *mpath);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 741abb50453..9fa32013ba6 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -31,15 +31,15 @@ extern "C" {
*/
/* Blender major and minor version. */
-#define BLENDER_VERSION 291
+#define BLENDER_VERSION 292
/* Blender patch version for bugfix releases. */
#define BLENDER_VERSION_PATCH 0
/** Blender release cycle stage: alpha/beta/rc/release. */
-#define BLENDER_VERSION_CYCLE beta
+#define BLENDER_VERSION_CYCLE alpha
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 9
+#define BLENDER_FILE_SUBVERSION 4
/* 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_collection.h b/source/blender/blenkernel/BKE_collection.h
index f4393742dff..f35dafa15a8 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -35,10 +35,16 @@ extern "C" {
struct BLI_Iterator;
struct Base;
+struct BlendDataReader;
+struct BlendExpander;
+struct BlendLibReader;
+struct BlendWriter;
struct Collection;
+struct Library;
struct Main;
struct Object;
struct Scene;
+struct SceneCollection;
struct ViewLayer;
typedef struct CollectionParent {
@@ -160,6 +166,22 @@ bool BKE_collection_has_collection(struct Collection *parent, struct Collection
void BKE_collection_parent_relations_rebuild(struct Collection *collection);
void BKE_main_collections_parent_relations_rebuild(struct Main *bmain);
+/* .blend file I/O */
+
+void BKE_collection_blend_write_nolib(struct BlendWriter *writer, struct Collection *collection);
+void BKE_collection_blend_read_data(struct BlendDataReader *reader, struct Collection *collection);
+void BKE_collection_blend_read_lib(struct BlendLibReader *reader, struct Collection *collection);
+void BKE_collection_blend_read_expand(struct BlendExpander *expander,
+ struct Collection *collection);
+
+void BKE_collection_compat_blend_read_data(struct BlendDataReader *reader,
+ struct SceneCollection *sc);
+void BKE_collection_compat_blend_read_lib(struct BlendLibReader *reader,
+ struct Library *lib,
+ struct SceneCollection *sc);
+void BKE_collection_compat_blend_read_expand(struct BlendExpander *expander,
+ struct SceneCollection *sc);
+
/* Iteration callbacks. */
typedef void (*BKE_scene_objects_Cb)(struct Object *ob, void *data);
diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h
index e56a1ac9ce3..3631feb5071 100644
--- a/source/blender/blenkernel/BKE_colortools.h
+++ b/source/blender/blenkernel/BKE_colortools.h
@@ -139,6 +139,11 @@ void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_s
const struct ColorManagedViewSettings *settings);
void BKE_color_managed_view_settings_free(struct ColorManagedViewSettings *settings);
+void BKE_color_managed_view_settings_blend_write(struct BlendWriter *writer,
+ struct ColorManagedViewSettings *settings);
+void BKE_color_managed_view_settings_blend_read_data(struct BlendDataReader *reader,
+ struct ColorManagedViewSettings *settings);
+
void BKE_color_managed_colorspace_settings_init(
struct ColorManagedColorspaceSettings *colorspace_settings);
void BKE_color_managed_colorspace_settings_copy(
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index ecb891760b7..e5c4535560d 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -31,6 +31,10 @@ struct Scene;
struct bConstraint;
struct bConstraintTarget;
struct bPoseChannel;
+struct BlendWriter;
+struct BlendDataReader;
+struct BlendLibReader;
+struct BlendExpander;
/* ---------------------------------------------------------------------------- */
#ifdef __cplusplus
@@ -183,6 +187,8 @@ bool BKE_constraint_remove_ex(ListBase *list,
bool clear_dep);
bool BKE_constraint_remove(ListBase *list, struct bConstraint *con);
+void BKE_constraint_panel_expand(struct bConstraint *con);
+
/* Constraints + Proxies function prototypes */
void BKE_constraints_proxylocal_extract(struct ListBase *dst, struct ListBase *src);
bool BKE_constraints_proxylocked_owner(struct Object *ob, struct bPoseChannel *pchan);
@@ -220,6 +226,13 @@ void BKE_constraints_solve(struct Depsgraph *depsgraph,
struct bConstraintOb *cob,
float ctime);
+void BKE_constraint_blend_write(struct BlendWriter *writer, struct ListBase *conlist);
+void BKE_constraint_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb);
+void BKE_constraint_blend_read_lib(struct BlendLibReader *reader,
+ struct ID *id,
+ struct ListBase *conlist);
+void BKE_constraint_blend_read_expand(struct BlendExpander *expander, struct ListBase *lb);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index c9bc5e83a1f..f527f40d0d7 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -325,6 +325,9 @@ float fcurve_samplingcb_evalcurve(struct FCurve *fcu, void *data, float evaltime
void fcurve_store_samples(
struct FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb);
+/* Convert baked/sampled fcurves into bezt/regular fcurves. */
+void fcurve_samples_to_keyframes(struct FCurve *fcu, const int start, const int end);
+
/* ************* F-Curve .blend file API ******************** */
void BKE_fmodifiers_blend_write(struct BlendWriter *writer, struct ListBase *fmodifiers);
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 7d50599a8f0..6dc8d1ef06e 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -48,6 +48,7 @@ struct bGPDlayer;
struct bGPDlayer_Mask;
struct bGPDspoint;
struct bGPDstroke;
+struct bGPDcurve;
struct bGPdata;
#define GPENCIL_SIMPLIFY(scene) ((scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_ENABLE))
@@ -89,6 +90,7 @@ struct bGPdata;
void BKE_gpencil_free_point_weights(struct MDeformVert *dvert);
void BKE_gpencil_free_stroke_weights(struct bGPDstroke *gps);
+void BKE_gpencil_free_stroke_editcurve(struct bGPDstroke *gps);
void BKE_gpencil_free_stroke(struct bGPDstroke *gps);
bool BKE_gpencil_free_strokes(struct bGPDframe *gpf);
void BKE_gpencil_free_frames(struct bGPDlayer *gpl);
@@ -102,6 +104,7 @@ void BKE_gpencil_batch_cache_dirty_tag(struct bGPdata *gpd);
void BKE_gpencil_batch_cache_free(struct bGPdata *gpd);
void BKE_gpencil_stroke_sync_selection(struct bGPDstroke *gps);
+void BKE_gpencil_curve_sync_selection(struct bGPDstroke *gps);
struct bGPDframe *BKE_gpencil_frame_addnew(struct bGPDlayer *gpl, int cframe);
struct bGPDframe *BKE_gpencil_frame_addcopy(struct bGPDlayer *gpl, int cframe);
@@ -111,7 +114,10 @@ struct bGPdata *BKE_gpencil_data_addnew(struct Main *bmain, const char name[]);
struct bGPDframe *BKE_gpencil_frame_duplicate(const struct bGPDframe *gpf_src);
struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src);
void BKE_gpencil_frame_copy_strokes(struct bGPDframe *gpf_src, struct bGPDframe *gpf_dst);
-struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src, const bool dup_points);
+struct bGPDcurve *BKE_gpencil_stroke_curve_duplicate(struct bGPDcurve *gpc_src);
+struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src,
+ const bool dup_points,
+ const bool dup_curve);
struct bGPdata *BKE_gpencil_data_duplicate(struct Main *bmain,
const struct bGPdata *gpd,
@@ -160,6 +166,8 @@ struct bGPDstroke *BKE_gpencil_stroke_add_existing_style(struct bGPDframe *gpf,
int totpoints,
short thickness);
+struct bGPDcurve *BKE_gpencil_stroke_editcurve_new(const int tot_curve_points);
+
/* Stroke and Fill - Alpha Visibility Threshold */
#define GPENCIL_ALPHA_OPACITY_THRESH 0.001f
#define GPENCIL_STRENGTH_MIN 0.003f
@@ -247,6 +255,7 @@ float BKE_gpencil_multiframe_falloff_calc(
void BKE_gpencil_palette_ensure(struct Main *bmain, struct Scene *scene);
bool BKE_gpencil_from_image(struct SpaceImage *sima,
+ struct bGPdata *gpd,
struct bGPDframe *gpf,
const float size,
const bool mask);
diff --git a/source/blender/blenkernel/BKE_gpencil_curve.h b/source/blender/blenkernel/BKE_gpencil_curve.h
index c61427c6c4a..1821972469c 100644
--- a/source/blender/blenkernel/BKE_gpencil_curve.h
+++ b/source/blender/blenkernel/BKE_gpencil_curve.h
@@ -30,6 +30,10 @@ extern "C" {
struct Main;
struct Object;
struct Scene;
+struct bGPdata;
+struct bGPDlayer;
+struct bGPDstroke;
+struct bGPDcurve;
void BKE_gpencil_convert_curve(struct Main *bmain,
struct Scene *scene,
@@ -39,6 +43,23 @@ void BKE_gpencil_convert_curve(struct Main *bmain,
const float scale_thickness,
const float sample);
+struct bGPDcurve *BKE_gpencil_stroke_editcurve_generate(struct bGPDstroke *gps,
+ const float error_threshold,
+ const float corner_angle,
+ const float stroke_radius);
+void BKE_gpencil_stroke_editcurve_update(struct bGPdata *gpd,
+ struct bGPDlayer *gpl,
+ struct bGPDstroke *gps);
+void BKE_gpencil_editcurve_stroke_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc);
+void BKE_gpencil_stroke_editcurve_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc);
+void BKE_gpencil_strokes_selected_update_editcurve(struct bGPdata *gpd);
+void BKE_gpencil_strokes_selected_sync_selection_editcurve(struct bGPdata *gpd);
+void BKE_gpencil_stroke_update_geometry_from_editcurve(struct bGPDstroke *gps,
+ const uint resolution,
+ const bool is_adaptive);
+void BKE_gpencil_editcurve_recalculate_handles(struct bGPDstroke *gps);
+void BKE_gpencil_editcurve_subdivide(struct bGPDstroke *gps, const int cuts);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h b/source/blender/blenkernel/BKE_gpencil_geom.h
index 404cbbe1741..6917a62053c 100644
--- a/source/blender/blenkernel/BKE_gpencil_geom.h
+++ b/source/blender/blenkernel/BKE_gpencil_geom.h
@@ -51,11 +51,17 @@ void BKE_gpencil_stroke_boundingbox_calc(struct bGPDstroke *gps);
/* stroke geometry utilities */
void BKE_gpencil_stroke_normal(const struct bGPDstroke *gps, float r_normal[3]);
-void BKE_gpencil_stroke_simplify_adaptive(struct bGPDstroke *gps, float epsilon);
-void BKE_gpencil_stroke_simplify_fixed(struct bGPDstroke *gps);
-void BKE_gpencil_stroke_subdivide(struct bGPDstroke *gps, int level, int type);
-bool BKE_gpencil_stroke_trim(struct bGPDstroke *gps);
-void BKE_gpencil_stroke_merge_distance(struct bGPDframe *gpf,
+void BKE_gpencil_stroke_simplify_adaptive(struct bGPdata *gpd,
+ struct bGPDstroke *gps,
+ float epsilon);
+void BKE_gpencil_stroke_simplify_fixed(struct bGPdata *gpd, struct bGPDstroke *gps);
+void BKE_gpencil_stroke_subdivide(struct bGPdata *gpd,
+ struct bGPDstroke *gps,
+ int level,
+ int type);
+bool BKE_gpencil_stroke_trim(struct bGPdata *gpd, struct bGPDstroke *gps);
+void BKE_gpencil_stroke_merge_distance(struct bGPdata *gpd,
+ struct bGPDframe *gpf,
struct bGPDstroke *gps,
const float threshold,
const bool use_unselected);
@@ -72,7 +78,7 @@ void BKE_gpencil_stroke_2d_flat_ref(const struct bGPDspoint *ref_points,
const float scale,
int *r_direction);
void BKE_gpencil_stroke_fill_triangulate(struct bGPDstroke *gps);
-void BKE_gpencil_stroke_geometry_update(struct bGPDstroke *gps);
+void BKE_gpencil_stroke_geometry_update(struct bGPdata *gpd, struct bGPDstroke *gps);
void BKE_gpencil_stroke_uv_update(struct bGPDstroke *gps);
void BKE_gpencil_transform(struct bGPdata *gpd, const float mat[4][4]);
@@ -91,19 +97,26 @@ void BKE_gpencil_point_coords_apply_with_mat4(struct bGPdata *gpd,
const GPencilPointCoordinates *elem_data,
const float mat[4][4]);
-bool BKE_gpencil_stroke_sample(struct bGPDstroke *gps, const float dist, const bool select);
+bool BKE_gpencil_stroke_sample(struct bGPdata *gpd,
+ struct bGPDstroke *gps,
+ const float dist,
+ const bool select);
bool BKE_gpencil_stroke_smooth(struct bGPDstroke *gps, int i, float inf);
bool BKE_gpencil_stroke_smooth_strength(struct bGPDstroke *gps, int point_index, float influence);
bool BKE_gpencil_stroke_smooth_thickness(struct bGPDstroke *gps, int point_index, float influence);
bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, int point_index, float influence);
bool BKE_gpencil_stroke_close(struct bGPDstroke *gps);
-void BKE_gpencil_dissolve_points(struct bGPDframe *gpf, struct bGPDstroke *gps, const short tag);
+void BKE_gpencil_dissolve_points(struct bGPdata *gpd,
+ struct bGPDframe *gpf,
+ struct bGPDstroke *gps,
+ const short tag);
bool BKE_gpencil_stroke_stretch(struct bGPDstroke *gps, const float dist, const float tip_length);
bool BKE_gpencil_stroke_trim_points(struct bGPDstroke *gps,
const int index_from,
const int index_to);
-bool BKE_gpencil_stroke_split(struct bGPDframe *gpf,
+bool BKE_gpencil_stroke_split(struct bGPdata *gpd,
+ struct bGPDframe *gpf,
struct bGPDstroke *gps,
const int before_index,
struct bGPDstroke **remaining_gps);
diff --git a/source/blender/blenkernel/BKE_gpencil_modifier.h b/source/blender/blenkernel/BKE_gpencil_modifier.h
index e003144047b..7729d2c53ab 100644
--- a/source/blender/blenkernel/BKE_gpencil_modifier.h
+++ b/source/blender/blenkernel/BKE_gpencil_modifier.h
@@ -35,6 +35,9 @@ struct Main;
struct ModifierUpdateDepsgraphContext;
struct Object;
struct Scene;
+struct BlendWriter;
+struct BlendDataReader;
+struct BlendLibReader;
/* NOTE: bakeModifier() called from UI:
* needs to create new data-blocks, hence the need for this. */
struct bGPDframe;
@@ -249,6 +252,7 @@ typedef struct GpencilModifierTypeInfo {
void BKE_gpencil_modifier_init(void);
void BKE_gpencil_modifierType_panel_id(GpencilModifierType type, char *r_idname);
+void BKE_gpencil_modifier_panel_expand(struct GpencilModifierData *md);
const GpencilModifierTypeInfo *BKE_gpencil_modifier_get_info(GpencilModifierType type);
struct GpencilModifierData *BKE_gpencil_modifier_new(int type);
void BKE_gpencil_modifier_free_ex(struct GpencilModifierData *md, const int flag);
@@ -302,6 +306,10 @@ struct bGPDframe *BKE_gpencil_frame_retime_get(struct Depsgraph *depsgraph,
struct Object *ob,
struct bGPDlayer *gpl);
+void BKE_gpencil_modifier_blend_write(struct BlendWriter *writer, struct ListBase *modbase);
+void BKE_gpencil_modifier_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb);
+void BKE_gpencil_modifier_blend_read_lib(struct BlendLibReader *reader, struct Object *ob);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index 37a83a94079..9c250240e5e 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -147,8 +147,6 @@ void IDP_FreeProperty(struct IDProperty *prop);
void IDP_ClearProperty(IDProperty *prop);
-void IDP_RelinkProperty(struct IDProperty *prop);
-
void IDP_Reset(IDProperty *prop, const IDProperty *reference);
#define IDP_Int(prop) ((prop)->data.val)
diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index 3caf15d1b50..1298e3c2bbf 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -102,6 +102,10 @@ typedef void (*IDTypeBlendReadDataFunction)(struct BlendDataReader *reader, stru
typedef void (*IDTypeBlendReadLibFunction)(struct BlendLibReader *reader, struct ID *id);
typedef void (*IDTypeBlendReadExpandFunction)(struct BlendExpander *expander, struct ID *id);
+typedef void (*IDTypeBlendReadUndoPreserve)(struct BlendLibReader *reader,
+ struct ID *id_new,
+ struct ID *id_old);
+
typedef struct IDTypeInfo {
/* ********** General IDType data. ********** */
@@ -196,6 +200,13 @@ typedef struct IDTypeInfo {
* Specify which other id data blocks should be loaded when the current one is loaded.
*/
IDTypeBlendReadExpandFunction blend_read_expand;
+
+ /**
+ * Allow an ID type to preserve some of its data across (memfile) undo steps.
+ *
+ * \note Called from #setup_app_data when undoing or redoing a memfile step.
+ */
+ IDTypeBlendReadUndoPreserve blend_read_undo_preserve;
} IDTypeInfo;
/* ********** Declaration of each IDTypeInfo. ********** */
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 024d58174e8..7091a060243 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -34,6 +34,9 @@ extern "C" {
#define TODO_LAYER /* generic todo */
struct Base;
+struct BlendDataReader;
+struct BlendLibReader;
+struct BlendWriter;
struct Collection;
struct Depsgraph;
struct LayerCollection;
@@ -147,6 +150,14 @@ void BKE_layer_eval_view_layer_indexed(struct Depsgraph *depsgraph,
struct Scene *scene,
int view_layer_index);
+/* .blend file I/O */
+
+void BKE_view_layer_blend_write(struct BlendWriter *writer, struct ViewLayer *view_layer);
+void BKE_view_layer_blend_read_data(struct BlendDataReader *reader, struct ViewLayer *view_layer);
+void BKE_view_layer_blend_read_lib(struct BlendLibReader *reader,
+ struct Library *lib,
+ struct ViewLayer *view_layer);
+
/* iterators */
typedef struct ObjectsVisibleIteratorData {
@@ -366,6 +377,9 @@ struct Object **BKE_view_layer_array_selected_objects_params(
uint *r_len,
const struct ObjectsInViewLayerParams *params);
+struct Object *BKE_view_layer_non_active_selected_object(struct ViewLayer *view_layer,
+ const struct View3D *v3d);
+
#define BKE_view_layer_array_selected_objects(view_layer, v3d, r_len, ...) \
BKE_view_layer_array_selected_objects_params( \
view_layer, v3d, r_len, &(const struct ObjectsInViewLayerParams)__VA_ARGS__)
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 789f78826e0..807f13efe14 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -177,7 +177,7 @@ void BKE_mesh_to_pointcloud(struct Main *bmain,
struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
-void BKE_mesh_from_pointcloud(struct PointCloud *pointcloud, struct Mesh *me);
+void BKE_mesh_from_pointcloud(const struct PointCloud *pointcloud, struct Mesh *me);
void BKE_pointcloud_to_mesh(struct Main *bmain,
struct Depsgraph *depsgraph,
struct Scene *scene,
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index b2015c4e6d7..a2c3787bcd2 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -30,6 +30,7 @@ extern "C" {
struct ARegionType;
struct BMEditMesh;
struct BlendDataReader;
+struct BlendLibReader;
struct BlendWriter;
struct CustomData_MeshMasks;
struct DepsNodeHandle;
@@ -396,6 +397,7 @@ const ModifierTypeInfo *BKE_modifier_get_info(ModifierType type);
/* For modifier UI panels. */
void BKE_modifier_type_panel_id(ModifierType type, char *r_idname);
+void BKE_modifier_panel_expand(struct ModifierData *md);
/* Modifier utility calls, do call through type pointer and return
* default values if pointer is optional.
@@ -427,8 +429,10 @@ bool BKE_modifier_is_non_geometrical(ModifierData *md);
bool BKE_modifier_is_enabled(const struct Scene *scene,
struct ModifierData *md,
int required_mode);
-void BKE_modifier_set_error(struct ModifierData *md, const char *format, ...)
- ATTR_PRINTF_FORMAT(2, 3);
+void BKE_modifier_set_error(const struct Object *ob,
+ struct ModifierData *md,
+ const char *format,
+ ...) ATTR_PRINTF_FORMAT(3, 4);
bool BKE_modifier_is_preview(struct ModifierData *md);
void BKE_modifiers_foreach_ID_link(struct Object *ob, IDWalkFunc walk, void *userData);
@@ -532,6 +536,12 @@ struct Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(struct Object
void BKE_modifier_check_uuids_unique_and_report(const struct Object *object);
+void BKE_modifier_blend_write(struct BlendWriter *writer, struct ListBase *modbase);
+void BKE_modifier_blend_read_data(struct BlendDataReader *reader,
+ struct ListBase *lb,
+ struct Object *ob);
+void BKE_modifier_blend_read_lib(struct BlendLibReader *reader, struct Object *ob);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index fbdfc5b76a7..5a668532033 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -36,7 +36,6 @@ struct DerivedMesh;
struct MDisps;
struct Mesh;
struct ModifierData;
-struct Multires;
struct MultiresModifierData;
struct Object;
struct Scene;
@@ -114,22 +113,12 @@ int multiresModifier_rebuild_subdiv(struct Depsgraph *depsgraph,
struct MultiresModifierData *mmd,
int rebuild_limit,
bool switch_view_to_lower_level);
-void multiresModifier_subdivide_legacy(struct MultiresModifierData *mmd,
- struct Scene *scene,
- struct Object *ob,
- int updateblock,
- int simple);
void multiresModifier_sync_levels_ex(struct Object *ob_dst,
struct MultiresModifierData *mmd_src,
struct MultiresModifierData *mmd_dst);
void multires_stitch_grids(struct Object *);
-/* Related to the old multires */
-void multires_free(struct Multires *mr);
-void multires_load_old(struct Object *ob, struct Mesh *me);
-void multires_load_old_250(struct Mesh *);
-
void multiresModifier_scale_disp(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
@@ -229,6 +218,13 @@ BLI_INLINE void BKE_multires_construct_tangent_matrix(float tangent_matrix[3][3]
const float dPdv[3],
const int corner);
+/* Versioning. */
+
+/* Convert displacement which is stored for simply-subdivided mesh to a Catmull-Clark
+ * subdivided mesh. */
+void multires_do_versions_simple_to_catmull_clark(struct Object *object,
+ struct MultiresModifierData *mmd);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 38045e22def..e3591b8fcd1 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -880,8 +880,7 @@ void BKE_node_tree_unlink_id(ID *id, struct bNodeTree *ntree);
* } FOREACH_NODETREE_END;
* \endcode
*
- * \{
- */
+ * \{ */
/* should be an opaque type, only for internal use by BKE_node_tree_iter_*** */
struct NodeTreeIterStore {
@@ -1337,8 +1336,8 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
/** \} */
-void init_nodesystem(void);
-void free_nodesystem(void);
+void BKE_node_system_init(void);
+void BKE_node_system_exit(void);
/* -------------------------------------------------------------------- */
/* evaluation support, */
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 0a992f2cb58..28c912a4c9a 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -191,6 +191,8 @@ struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer,
unsigned int *r_bases_len);
void BKE_object_get_parent_matrix(struct Object *ob, struct Object *par, float r_parentmat[4][4]);
+
+/* Compute object world transform and store it in ob->obmat. */
void BKE_object_where_is_calc(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
void BKE_object_where_is_calc_ex(struct Depsgraph *depsgraph,
struct Scene *scene,
@@ -414,6 +416,14 @@ void BKE_object_to_mesh_clear(struct Object *object);
void BKE_object_check_uuids_unique_and_report(const struct Object *object);
+void BKE_object_modifiers_lib_link_common(void *userData,
+ struct Object *ob,
+ struct ID **idpoin,
+ int cb_flag);
+
+struct PartEff;
+struct PartEff *BKE_object_do_version_give_parteff_245(struct Object *ob);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 150d0d9b011..a58bf760ad5 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -66,6 +66,9 @@ struct ViewLayer;
struct bContext;
struct bToolRef;
struct tPaletteColorHSV;
+struct BlendWriter;
+struct BlendDataReader;
+struct BlendLibReader;
enum eOverlayFlags;
@@ -217,6 +220,15 @@ void BKE_paint_toolslots_brush_update(struct Paint *paint);
void BKE_paint_toolslots_brush_validate(struct Main *bmain, struct Paint *paint);
struct Brush *BKE_paint_toolslots_brush_get(struct Paint *paint, int slot_index);
+/* .blend I/O */
+void BKE_paint_blend_write(struct BlendWriter *writer, struct Paint *paint);
+void BKE_paint_blend_read_data(struct BlendDataReader *reader,
+ const struct Scene *scene,
+ struct Paint *paint);
+void BKE_paint_blend_read_lib(struct BlendLibReader *reader,
+ struct Scene *scene,
+ struct Paint *paint);
+
#define SCULPT_FACE_SET_NONE 0
/* Used for both vertex color and weight paint */
@@ -505,6 +517,9 @@ typedef struct SculptSession {
int active_face_index;
int active_grid_index;
+ /* When active, the cursor draws with faded colors, indicating that there is an action enabled.
+ */
+ bool draw_faded_cursor;
float cursor_radius;
float cursor_location[3];
float cursor_normal[3];
@@ -514,6 +529,7 @@ typedef struct SculptSession {
/* 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];
+ float gesture_initial_normal[3];
bool gesture_initial_hit;
/* TODO(jbakker): Replace rv3d adn v3d with ViewContext */
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 6ed3b94b8e5..73815325594 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -45,6 +45,9 @@ struct ParticleSystemModifierData;
struct BVHTreeRay;
struct BVHTreeRayHit;
+struct BlendWriter;
+struct BlendDataReader;
+struct BlendLibReader;
struct CustomData_MeshMasks;
struct Depsgraph;
struct EdgeHash;
@@ -261,7 +264,7 @@ extern unsigned int PSYS_FRAND_SEED_OFFSET[PSYS_FRAND_COUNT];
extern unsigned int PSYS_FRAND_SEED_MULTIPLIER[PSYS_FRAND_COUNT];
extern float PSYS_FRAND_BASE[PSYS_FRAND_COUNT];
-void psys_init_rng(void);
+void BKE_particle_init_rng(void);
BLI_INLINE float psys_frand(ParticleSystem *psys, unsigned int seed)
{
@@ -625,6 +628,20 @@ void BKE_particle_batch_cache_free(struct ParticleSystem *psys);
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);
+/* .blend file I/O */
+void BKE_particle_partdeflect_blend_read_data(struct BlendDataReader *reader,
+ struct PartDeflect *pd);
+void BKE_particle_partdeflect_blend_read_lib(struct BlendLibReader *reader,
+ struct ID *id,
+ struct PartDeflect *pd);
+void BKE_particle_system_blend_write(struct BlendWriter *writer, struct ListBase *particles);
+void BKE_particle_system_blend_read_data(struct BlendDataReader *reader,
+ struct ListBase *particles);
+void BKE_particle_system_blend_read_lib(struct BlendLibReader *reader,
+ struct Object *ob,
+ struct ID *id,
+ struct ListBase *particles);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index f8e04b75b3d..470d53f6655 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -91,6 +91,8 @@ struct RigidBodyWorld;
struct Scene;
struct SoftBody;
struct ViewLayer;
+struct BlendWriter;
+struct BlendDataReader;
/* temp structure for read/write */
typedef struct PTCacheData {
@@ -167,7 +169,7 @@ typedef struct PTCacheID {
* (the cfra parameter is just for using same function pointer with totwrite). */
int (*totpoint)(void *calldata, int cfra);
/* report error if number of points does not match */
- void (*error)(void *calldata, const char *message);
+ void (*error)(const struct ID *owner_id, void *calldata, const char *message);
/* number of points written for current cache frame */
int (*totwrite)(void *calldata, int cfra);
@@ -374,6 +376,14 @@ void BKE_ptcache_validate(struct PointCache *cache, int framenr);
/* Set correct flags after unsuccessful simulation step */
void BKE_ptcache_invalidate(struct PointCache *cache);
+/********************** .blend File I/O *********************/
+
+void BKE_ptcache_blend_write(struct BlendWriter *writer, struct ListBase *ptcaches);
+void BKE_ptcache_blend_read_data(struct BlendDataReader *reader,
+ struct ListBase *ptcaches,
+ struct PointCache **ocache,
+ int force_disk);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 35a3d0415a8..8e370ed27c5 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -33,6 +33,9 @@ extern "C" {
#endif
struct ARegion;
+struct BlendDataReader;
+struct BlendLibReader;
+struct BlendWriter;
struct Header;
struct ID;
struct LibraryForeachIDData;
@@ -275,6 +278,19 @@ typedef struct PanelType {
ExtensionRNA rna_ext;
} PanelType;
+/* #PanelType.flag */
+enum {
+ PANEL_TYPE_DEFAULT_CLOSED = (1 << 0),
+ PANEL_TYPE_NO_HEADER = (1 << 1),
+ /** Makes buttons in the header shrink/stretch to fill full layout width. */
+ PANEL_TYPE_HEADER_EXPAND = (1 << 2),
+ PANEL_TYPE_LAYOUT_VERT_BAR = (1 << 3),
+ /** This panel type represents data external to the UI. */
+ PANEL_TYPE_INSTANCED = (1 << 4),
+ /** Draw panel like a box widget. */
+ PANEL_TYPE_DRAW_BOX = (1 << 6),
+};
+
/* uilist types */
/* Draw an item in the uiList */
@@ -362,8 +378,8 @@ typedef struct Menu {
/* spacetypes */
struct SpaceType *BKE_spacetype_from_id(int spaceid);
-struct ARegionType *BKE_regiontype_from_id_or_first(struct SpaceType *st, int regionid);
-struct ARegionType *BKE_regiontype_from_id(struct SpaceType *st, int regionid);
+struct ARegionType *BKE_regiontype_from_id_or_first(const struct SpaceType *st, int regionid);
+struct ARegionType *BKE_regiontype_from_id(const struct SpaceType *st, int regionid);
const struct ListBase *BKE_spacetypes_list(void);
void BKE_spacetype_register(struct SpaceType *st);
bool BKE_spacetype_exists(int spaceid);
@@ -384,7 +400,7 @@ void BKE_spacedata_callback_id_remap_set(void (*func)(
void BKE_spacedata_id_unref(struct ScrArea *area, struct SpaceLink *sl, struct ID *id);
/* area/regions */
-struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *region);
+struct ARegion *BKE_area_region_copy(const struct SpaceType *st, const struct ARegion *region);
void BKE_area_region_free(struct SpaceType *st, struct ARegion *region);
void BKE_area_region_panels_free(struct ListBase *panels);
void BKE_screen_area_free(struct ScrArea *area);
@@ -449,6 +465,21 @@ void BKE_screen_remove_unused_scrverts(struct bScreen *screen);
void BKE_screen_header_alignment_reset(struct bScreen *screen);
+/* .blend file I/O */
+void BKE_screen_view3d_shading_blend_write(struct BlendWriter *writer,
+ struct View3DShading *shading);
+void BKE_screen_view3d_shading_blend_read_data(struct BlendDataReader *reader,
+ struct View3DShading *shading);
+
+void BKE_screen_area_map_blend_write(struct BlendWriter *writer, struct ScrAreaMap *area_map);
+bool BKE_screen_area_map_blend_read_data(struct BlendDataReader *reader,
+ struct ScrAreaMap *area_map);
+void BKE_screen_view3d_do_versions_250(struct View3D *v3d, ListBase *regions);
+void BKE_screen_area_blend_read_lib(struct BlendLibReader *reader,
+ struct ID *parent_id,
+ struct ScrArea *area);
+bool BKE_screen_blend_read_data(struct BlendDataReader *reader, struct bScreen *screen);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_sequencer_offscreen.h b/source/blender/blenkernel/BKE_sequencer_offscreen.h
index 90d3f80320a..f5f6067b06e 100644
--- a/source/blender/blenkernel/BKE_sequencer_offscreen.h
+++ b/source/blender/blenkernel/BKE_sequencer_offscreen.h
@@ -33,6 +33,8 @@
extern "C" {
#endif
+struct GPUOffScreen;
+
typedef struct ImBuf *(*SequencerDrawView)(struct Depsgraph *depsgraph,
struct Scene *scene,
struct View3DShading *shading_override,
diff --git a/source/blender/blenkernel/BKE_shader_fx.h b/source/blender/blenkernel/BKE_shader_fx.h
index da14487c1f4..7c2d363be5c 100644
--- a/source/blender/blenkernel/BKE_shader_fx.h
+++ b/source/blender/blenkernel/BKE_shader_fx.h
@@ -33,6 +33,9 @@ struct ListBase;
struct ModifierUpdateDepsgraphContext;
struct Object;
struct ShaderFxData;
+struct BlendWriter;
+struct BlendDataReader;
+struct BlendLibReader;
#define SHADER_FX_ACTIVE(_fx, _is_render) \
((((_fx)->mode & eShaderFxMode_Realtime) && (_is_render == false)) || \
@@ -151,6 +154,7 @@ typedef struct ShaderFxTypeInfo {
void BKE_shaderfx_init(void);
void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname);
+void BKE_shaderfx_panel_expand(struct ShaderFxData *fx);
const ShaderFxTypeInfo *BKE_shaderfx_get_info(ShaderFxType type);
struct ShaderFxData *BKE_shaderfx_new(int type);
void BKE_shaderfx_free_ex(struct ShaderFxData *fx, const int flag);
@@ -169,6 +173,10 @@ void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, vo
bool BKE_shaderfx_has_gpencil(struct Object *ob);
+void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbase);
+void BKE_shaderfx_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb);
+void BKE_shaderfx_blend_read_lib(struct BlendLibReader *reader, struct Object *ob);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index f6df3f1bb62..40b2d62baac 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -39,7 +39,7 @@ set(INC
../sequencer
../shader_fx
../simulation
- ../render/extern/include
+ ../render
../../../intern/ghost
../../../intern/glew-mx
../../../intern/guardedalloc
@@ -189,6 +189,7 @@ set(SRC
intern/multires_reshape_vertcos.c
intern/multires_subdiv.c
intern/multires_unsubdivide.c
+ intern/multires_versioning.c
intern/nla.c
intern/node.c
intern/object.c
@@ -209,7 +210,7 @@ set(SRC
intern/pbvh.c
intern/pbvh_bmesh.c
intern/pointcache.c
- intern/pointcloud.c
+ intern/pointcloud.cc
intern/report.c
intern/rigidbody.c
intern/scene.c
@@ -705,7 +706,7 @@ endif()
# # Warnings as errors, this is too strict!
# if(MSVC)
-# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
+# string(APPEND CMAKE_C_FLAGS " /WX")
# endif()
blender_add_lib(bf_blenkernel "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index d63c5fe12ab..67e7b890548 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -736,7 +736,7 @@ CCGError ccgSubSurf_syncFace(
}
}
else {
- if (ss->syncState == eSyncState_Vert || ss->syncState == eSyncState_Edge) {
+ if (ELEM(ss->syncState, eSyncState_Vert, eSyncState_Edge)) {
ss->syncState = eSyncState_Face;
}
else if (ss->syncState != eSyncState_Face) {
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index d551eaf04e4..eeff04788f9 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1021,7 +1021,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) &&
have_non_onlydeform_modifiers_appled) {
- BKE_modifier_set_error(md, "Modifier requires original data, bad stack position");
+ BKE_modifier_set_error(ob, md, "Modifier requires original data, bad stack position");
continue;
}
@@ -1047,10 +1047,10 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
if (unsupported) {
if (sculpt_dyntopo) {
- BKE_modifier_set_error(md, "Not supported in dyntopo");
+ BKE_modifier_set_error(ob, md, "Not supported in dyntopo");
}
else {
- BKE_modifier_set_error(md, "Not supported in sculpt mode");
+ BKE_modifier_set_error(ob, md, "Not supported in sculpt mode");
}
continue;
}
@@ -1378,7 +1378,10 @@ float (*editbmesh_vert_coords_alloc(BMEditMesh *em, int *r_vert_len))[3]
return cos;
}
-bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, bool has_prev_mesh)
+bool editbmesh_modifier_is_enabled(Scene *scene,
+ const Object *ob,
+ ModifierData *md,
+ bool has_prev_mesh)
{
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
@@ -1388,7 +1391,7 @@ bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, bool has_prev
}
if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && has_prev_mesh) {
- BKE_modifier_set_error(md, "Modifier requires original data, bad stack position");
+ BKE_modifier_set_error(ob, md, "Modifier requires original data, bad stack position");
return false;
}
@@ -1522,7 +1525,7 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
for (int i = 0; md; i++, md = md->next, md_datamask = md_datamask->next) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
- if (!editbmesh_modifier_is_enabled(scene, md, mesh_final != NULL)) {
+ if (!editbmesh_modifier_is_enabled(scene, ob, md, mesh_final != NULL)) {
continue;
}
@@ -2187,7 +2190,7 @@ static void mesh_init_origspace(Mesh *mesh)
for (i = 0; i < numpoly; i++, mp++) {
OrigSpaceLoop *lof = lof_array + mp->loopstart;
- if (mp->totloop == 3 || mp->totloop == 4) {
+ if (ELEM(mp->totloop, 3, 4)) {
for (j = 0; j < mp->totloop; j++, lof++) {
copy_v2_v2(lof->uv, default_osf[j]);
}
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index cbecc91b4ec..126063288d8 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -61,6 +61,7 @@
#include "BKE_main.h"
#include "BKE_object.h"
+#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "BIK_api.h"
@@ -295,6 +296,8 @@ IDTypeInfo IDType_ID_AC = {
.blend_read_data = action_blend_read_data,
.blend_read_lib = action_blend_read_lib,
.blend_read_expand = action_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
/* ***************** Library data level operations on action ************** */
@@ -1844,3 +1847,174 @@ void BKE_pose_check_uuids_unique_and_report(const bPose *pose)
BLI_gset_free(used_uuids, NULL);
}
+
+void BKE_pose_blend_write(BlendWriter *writer, bPose *pose, bArmature *arm)
+{
+ /* Write each channel */
+ if (pose == NULL) {
+ return;
+ }
+
+ BLI_assert(arm != NULL);
+
+ /* Write channels */
+ LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
+ /* Write ID Properties -- and copy this comment EXACTLY for easy finding
+ * of library blocks that implement this.*/
+ if (chan->prop) {
+ IDP_BlendWrite(writer, chan->prop);
+ }
+
+ BKE_constraint_blend_write(writer, &chan->constraints);
+
+ animviz_motionpath_blend_write(writer, chan->mpath);
+
+ /* Prevent crashes with autosave,
+ * when a bone duplicated in edit-mode has not yet been assigned to its pose-channel.
+ * Also needed with memundo, in some cases we can store a step before pose has been
+ * properly rebuilt from previous undo step. */
+ Bone *bone = (pose->flag & POSE_RECALC) ? BKE_armature_find_bone_name(arm, chan->name) :
+ chan->bone;
+ if (bone != NULL) {
+ /* gets restored on read, for library armatures */
+ chan->selectflag = bone->flag & BONE_SELECTED;
+ }
+
+ BLO_write_struct(writer, bPoseChannel, chan);
+ }
+
+ /* Write groups */
+ LISTBASE_FOREACH (bActionGroup *, grp, &pose->agroups) {
+ BLO_write_struct(writer, bActionGroup, grp);
+ }
+
+ /* write IK param */
+ if (pose->ikparam) {
+ const char *structname = BKE_pose_ikparam_get_name(pose);
+ if (structname) {
+ BLO_write_struct_by_name(writer, structname, pose->ikparam);
+ }
+ }
+
+ /* Write this pose */
+ BLO_write_struct(writer, bPose, pose);
+}
+
+void BKE_pose_blend_read_data(BlendDataReader *reader, bPose *pose)
+{
+ if (!pose) {
+ return;
+ }
+
+ BLO_read_list(reader, &pose->chanbase);
+ BLO_read_list(reader, &pose->agroups);
+
+ pose->chanhash = NULL;
+ pose->chan_array = NULL;
+
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
+ BKE_pose_channel_runtime_reset(&pchan->runtime);
+ BKE_pose_channel_session_uuid_generate(pchan);
+
+ pchan->bone = NULL;
+ BLO_read_data_address(reader, &pchan->parent);
+ BLO_read_data_address(reader, &pchan->child);
+ BLO_read_data_address(reader, &pchan->custom_tx);
+
+ BLO_read_data_address(reader, &pchan->bbone_prev);
+ BLO_read_data_address(reader, &pchan->bbone_next);
+
+ BKE_constraint_blend_read_data(reader, &pchan->constraints);
+
+ BLO_read_data_address(reader, &pchan->prop);
+ IDP_BlendDataRead(reader, &pchan->prop);
+
+ BLO_read_data_address(reader, &pchan->mpath);
+ if (pchan->mpath) {
+ animviz_motionpath_blend_read_data(reader, pchan->mpath);
+ }
+
+ BLI_listbase_clear(&pchan->iktree);
+ BLI_listbase_clear(&pchan->siktree);
+
+ /* in case this value changes in future, clamp else we get undefined behavior */
+ CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
+
+ pchan->draw_data = NULL;
+ }
+ pose->ikdata = NULL;
+ if (pose->ikparam != NULL) {
+ BLO_read_data_address(reader, &pose->ikparam);
+ }
+}
+
+void BKE_pose_blend_read_lib(BlendLibReader *reader, Object *ob, bPose *pose)
+{
+ bArmature *arm = ob->data;
+
+ if (!pose || !arm) {
+ return;
+ }
+
+ /* always rebuild to match proxy or lib changes, but on Undo */
+ bool rebuild = false;
+
+ if (!BLO_read_lib_is_undo(reader)) {
+ if (ob->proxy || ob->id.lib != arm->id.lib) {
+ rebuild = true;
+ }
+ }
+
+ if (ob->proxy) {
+ /* sync proxy layer */
+ if (pose->proxy_layer) {
+ arm->layer = pose->proxy_layer;
+ }
+
+ /* sync proxy active bone */
+ if (pose->proxy_act_bone[0]) {
+ Bone *bone = BKE_armature_find_bone_name(arm, pose->proxy_act_bone);
+ if (bone) {
+ arm->act_bone = bone;
+ }
+ }
+ }
+
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
+ BKE_constraint_blend_read_lib(reader, (ID *)ob, &pchan->constraints);
+
+ pchan->bone = BKE_armature_find_bone_name(arm, pchan->name);
+
+ IDP_BlendReadLib(reader, pchan->prop);
+
+ BLO_read_id_address(reader, arm->id.lib, &pchan->custom);
+ if (UNLIKELY(pchan->bone == NULL)) {
+ rebuild = true;
+ }
+ else if ((ob->id.lib == NULL) && arm->id.lib) {
+ /* local pose selection copied to armature, bit hackish */
+ pchan->bone->flag &= ~BONE_SELECTED;
+ pchan->bone->flag |= pchan->selectflag;
+ }
+ }
+
+ if (rebuild) {
+ Main *bmain = BLO_read_lib_get_main(reader);
+ DEG_id_tag_update_ex(
+ bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
+ BKE_pose_tag_recalc(bmain, pose);
+ }
+}
+
+void BKE_pose_blend_read_expand(BlendExpander *expander, bPose *pose)
+{
+ if (!pose) {
+ return;
+ }
+
+ LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
+ BKE_constraint_blend_read_expand(expander, &chan->constraints);
+ IDP_BlendReadExpand(expander, chan->prop);
+ BLO_expand(expander, chan->custom);
+ }
+}
diff --git a/source/blender/blenkernel/intern/anim_visualization.c b/source/blender/blenkernel/intern/anim_visualization.c
index 5452e2513fb..ecd71ec08fe 100644
--- a/source/blender/blenkernel/intern/anim_visualization.c
+++ b/source/blender/blenkernel/intern/anim_visualization.c
@@ -34,6 +34,8 @@
#include "GPU_batch.h"
+#include "BLO_read_write.h"
+
/* ******************************************************************** */
/* Animation Visualization */
@@ -224,3 +226,32 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports,
/* return it */
return mpath;
}
+
+void animviz_motionpath_blend_write(BlendWriter *writer, bMotionPath *mpath)
+{
+ /* sanity checks */
+ if (mpath == NULL) {
+ return;
+ }
+
+ /* firstly, just write the motionpath struct */
+ BLO_write_struct(writer, bMotionPath, mpath);
+
+ /* now write the array of data */
+ BLO_write_struct_array(writer, bMotionPathVert, mpath->length, mpath->points);
+}
+
+void animviz_motionpath_blend_read_data(BlendDataReader *reader, bMotionPath *mpath)
+{
+ /* sanity check */
+ if (mpath == NULL) {
+ return;
+ }
+
+ /* relink points cache */
+ BLO_read_data_address(reader, &mpath->points);
+
+ mpath->points_vbo = NULL;
+ mpath->batch_line = NULL;
+ mpath->batch_points = NULL;
+}
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index bad2ed53436..b5d3a04acb8 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -329,6 +329,8 @@ IDTypeInfo IDType_ID_AR = {
.blend_read_data = armature_blend_read_data,
.blend_read_lib = armature_blend_read_lib,
.blend_read_expand = armature_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
/** \} */
@@ -576,7 +578,7 @@ void BKE_armature_transform(bArmature *arm, const float mat[4][4], const bool do
/* -------------------------------------------------------------------- */
/** \name Armature Bone Find by Name
*
- * Using fast #GHash look-ups when available.
+ * Using fast #GHash lookups when available.
* \{ */
static Bone *get_named_bone_bonechildren(ListBase *lb, const char *name)
@@ -799,7 +801,7 @@ bool bone_autoside_name(
while (changed) { /* remove extensions */
changed = false;
if (len > 2 && basename[len - 2] == '.') {
- if (basename[len - 1] == 'L' || basename[len - 1] == 'R') { /* L R */
+ if (ELEM(basename[len - 1], 'L', 'R')) { /* L R */
basename[len - 2] = '\0';
len -= 2;
changed = true;
@@ -2154,50 +2156,50 @@ void mat3_vec_to_roll(const float mat[3][3], const float vec[3], float *r_roll)
*/
void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float r_mat[3][3])
{
-#define THETA_THRESHOLD_NEGY 1.0e-9f
-#define THETA_THRESHOLD_NEGY_CLOSE 1.0e-5f
+ const float THETA_SAFE = 1.0e-5f; /* theta above this value are always safe to use. */
+ const float THETA_CRITICAL = 1.0e-9f; /* above this is safe under certain conditions. */
+
+ const float x = nor[0];
+ const float y = nor[1];
+ const float z = nor[2];
- float theta;
+ const float theta = 1.0f + y;
+ const float theta_alt = x * x + z * z;
float rMatrix[3][3], bMatrix[3][3];
BLI_ASSERT_UNIT_V3(nor);
- theta = 1.0f + nor[1];
-
- /* With old algo, 1.0e-13f caused T23954 and T31333, 1.0e-6f caused T27675 and T30438,
- * so using 1.0e-9f as best compromise.
- *
- * New algo is supposed much more precise, since less complex computations are performed,
- * but it uses two different threshold values...
- *
- * Note: When theta is close to zero, we have to check we do have non-null X/Z components as well
- * (due to float precision errors, we can have nor = (0.0, 0.99999994, 0.0)...).
+ /* When theta is close to zero (nor is aligned close to negative Y Axis),
+ * we have to check we do have non-null X/Z components as well.
+ * Also, due to float precision errors, nor can be (0.0, -0.99999994, 0.0) which results
+ * in theta being close to zero. This will cause problems when theta is used as divisor.
*/
- if (theta > THETA_THRESHOLD_NEGY_CLOSE || ((nor[0] || nor[2]) && theta > THETA_THRESHOLD_NEGY)) {
- /* nor is *not* -Y.
+ if (theta > THETA_SAFE || ((x || z) && theta > THETA_CRITICAL)) {
+ /* nor is *not* aligned to negative Y-axis (0,-1,0).
* We got these values for free... so be happy with it... ;)
*/
- bMatrix[0][1] = -nor[0];
- bMatrix[1][0] = nor[0];
- bMatrix[1][1] = nor[1];
- bMatrix[1][2] = nor[2];
- bMatrix[2][1] = -nor[2];
- if (theta > THETA_THRESHOLD_NEGY_CLOSE) {
- /* If nor is far enough from -Y, apply the general case. */
- bMatrix[0][0] = 1 - nor[0] * nor[0] / theta;
- bMatrix[2][2] = 1 - nor[2] * nor[2] / theta;
- bMatrix[2][0] = bMatrix[0][2] = -nor[0] * nor[2] / theta;
+
+ bMatrix[0][1] = -x;
+ bMatrix[1][0] = x;
+ bMatrix[1][1] = y;
+ bMatrix[1][2] = z;
+ bMatrix[2][1] = -z;
+
+ if (theta > THETA_SAFE) {
+ /* nor differs significantly from negative Y axis (0,-1,0): apply the general case. */
+ bMatrix[0][0] = 1 - x * x / theta;
+ bMatrix[2][2] = 1 - z * z / theta;
+ bMatrix[2][0] = bMatrix[0][2] = -x * z / theta;
}
else {
- /* If nor is too close to -Y, apply the special case. */
- theta = nor[0] * nor[0] + nor[2] * nor[2];
- bMatrix[0][0] = (nor[0] + nor[2]) * (nor[0] - nor[2]) / -theta;
+ /* nor is close to negative Y axis (0,-1,0): apply the special case. */
+ bMatrix[0][0] = (x + z) * (x - z) / -theta_alt;
bMatrix[2][2] = -bMatrix[0][0];
- bMatrix[2][0] = bMatrix[0][2] = 2.0f * nor[0] * nor[2] / theta;
+ bMatrix[2][0] = bMatrix[0][2] = 2.0f * x * z / theta_alt;
}
}
else {
- /* If nor is -Y, simple symmetry by Z axis. */
+ /* nor is very close to negative Y axis (0,-1,0): use simple symmetry by Z axis. */
unit_m3(bMatrix);
bMatrix[0][0] = bMatrix[1][1] = -1.0;
}
@@ -2207,9 +2209,6 @@ void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float r_m
/* Combine and output result */
mul_m3_m3m3(r_mat, rMatrix, bMatrix);
-
-#undef THETA_THRESHOLD_NEGY
-#undef THETA_THRESHOLD_NEGY_CLOSE
}
void vec_roll_to_mat3(const float vec[3], const float roll, float r_mat[3][3])
diff --git a/source/blender/blenkernel/intern/armature_test.cc b/source/blender/blenkernel/intern/armature_test.cc
index f3c0d2f407a..366bbe3e37c 100644
--- a/source/blender/blenkernel/intern/armature_test.cc
+++ b/source/blender/blenkernel/intern/armature_test.cc
@@ -90,4 +90,71 @@ TEST(mat3_vec_to_roll, Rotationmatrix)
}
}
+TEST(vec_roll_to_mat3_normalized, Rotationmatrix)
+{
+ float negative_y_axis[3][3];
+ unit_m3(negative_y_axis);
+ negative_y_axis[0][0] = negative_y_axis[1][1] = -1.0f;
+
+ const float roll = 0.0f;
+ float roll_mat[3][3];
+
+ /* If normalized_vector is -Y, simple symmetry by Z axis. */
+ {
+ const float normalized_vector[3] = {0.0f, -1.0f, 0.0f};
+ vec_roll_to_mat3_normalized(normalized_vector, roll, roll_mat);
+ EXPECT_M3_NEAR(roll_mat, negative_y_axis, FLT_EPSILON);
+ }
+
+ /* If normalized_vector is far enough from -Y, apply the general case. */
+ {
+ const float expected_roll_mat[3][3] = {{1.000000f, 0.000000f, 0.000000f},
+ {0.000000f, -0.999989986f, -0.000000f},
+ {0.000000f, 0.000000f, 1.000000f}};
+
+ const float normalized_vector[3] = {0.0f, -1.0f + 1e-5f, 0.0f};
+ vec_roll_to_mat3_normalized(normalized_vector, roll, roll_mat);
+ EXPECT_M3_NEAR(roll_mat, expected_roll_mat, FLT_EPSILON);
+ }
+
+#if 0
+ /* TODO: This test will pass after fixing T82455) */
+ /* If normalized_vector is close to -Y and
+ * it has X and Z values above a threshold,
+ * apply the special case. */
+ {
+ const float expected_roll_mat[3][3] = {{0.000000f, -9.99999975e-06f, 1.000000f},
+ {9.99999975e-06f, -0.999999881f, 9.99999975e-06f},
+ {1.000000f, -9.99999975e-06, 0.000000f}};
+ const float normalized_vector[3] = {1e-24, -0.999999881, 0};
+ vec_roll_to_mat3_normalized(normalized_vector, roll, roll_mat);
+ EXPECT_M3_NEAR(roll_mat, expected_roll_mat, FLT_EPSILON);
+ }
+#endif
+
+ /* If normalized_vector is in a critical range close to -Y, apply the special case. */
+ {
+ const float expected_roll_mat[3][3] = {{0.000000f, -9.99999975e-06f, 1.000000f},
+ {9.99999975e-06f, -0.999999881f, 9.99999975e-06f},
+ {1.000000f, -9.99999975e-06f, 0.000000f}};
+
+ const float normalized_vector[3] = {1e-5f, -0.999999881f, 1e-5f}; /* Corner Case. */
+ vec_roll_to_mat3_normalized(normalized_vector, roll, roll_mat);
+ EXPECT_M3_NEAR(roll_mat, expected_roll_mat, FLT_EPSILON);
+ }
+
+ /* If normalized_vector is far enough from -Y, apply the general case. */
+ {
+ const float expected_roll_mat[3][3] = {{0.788675129f, -0.577350259f, -0.211324856f},
+ {0.577350259f, 0.577350259f, 0.577350259f},
+ {-0.211324856f, -0.577350259f, 0.788675129f}};
+
+ const float vector[3] = {1.0f, 1.0f, 1.0f}; /* Arbitrary Value. */
+ float normalized_vector[3];
+ normalize_v3_v3(normalized_vector, vector);
+ vec_roll_to_mat3_normalized(normalized_vector, roll, roll_mat);
+ EXPECT_M3_NEAR(roll_mat, expected_roll_mat, FLT_EPSILON);
+ }
+}
+
} // namespace blender::bke::tests
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 1ad1a821129..f4f25c3a153 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -53,13 +53,14 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
-#include "BKE_sequencer.h"
#include "BKE_studiolight.h"
#include "DEG_depsgraph.h"
#include "RE_pipeline.h"
-#include "RE_render_ext.h"
+#include "RE_texture.h"
+
+#include "SEQ_sequencer.h"
#include "BLF_api.h"
@@ -99,7 +100,7 @@ void BKE_blender_free(void)
IMB_moviecache_destruct();
- free_nodesystem();
+ BKE_node_system_exit();
}
/** \} */
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 78ce70a8448..96bf9fbe8d2 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -899,7 +899,7 @@ static Object *boid_find_ground(BoidBrainData *bbd,
for (coll = bbd->sim->colliders->first; coll; coll = coll->next) {
col.current = coll->ob;
col.md = coll->collmd;
- col.fac1 = col.fac2 = 0.f;
+ col.fac1 = col.fac2 = 0.0f;
if (col.md && col.md->bvhtree) {
BLI_bvhtree_ray_cast_ex(col.md->bvhtree,
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index 4ea9a26f0f8..f624d0ae057 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -73,12 +73,13 @@
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_report.h"
-#include "BKE_sequencer.h"
#include "BKE_bpath.h" /* own include */
#include "CLG_log.h"
+#include "SEQ_sequencer.h"
+
#ifndef _MSC_VER
# include "BLI_strict_flags.h"
#endif
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 17243b328e8..1b77989c2b8 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -50,7 +50,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-#include "RE_render_ext.h" /* RE_texture_evaluate */
+#include "RE_texture.h" /* RE_texture_evaluate */
#include "BLO_read_write.h"
@@ -355,6 +355,37 @@ static void brush_blend_read_expand(BlendExpander *expander, ID *id)
}
}
+static int brush_undo_preserve_cb(LibraryIDLinkCallbackData *cb_data)
+{
+ BlendLibReader *reader = cb_data->user_data;
+ ID *id_old = *cb_data->id_pointer;
+ /* Old data has not been remapped to new values of the pointers, if we want to keep the old
+ * pointer here we need its new address. */
+ ID *id_old_new = id_old != NULL ? BLO_read_get_new_id_address(reader, id_old->lib, id_old) :
+ NULL;
+ BLI_assert(id_old_new == NULL || ELEM(id_old, id_old_new, id_old_new->orig_id));
+ if (cb_data->cb_flag & IDWALK_CB_USER) {
+ id_us_plus_no_lib(id_old_new);
+ id_us_min(id_old);
+ }
+ *cb_data->id_pointer = id_old_new;
+ return IDWALK_RET_NOP;
+}
+
+static void brush_undo_preserve(BlendLibReader *reader, ID *id_new, ID *id_old)
+{
+ /* Whole Brush is preserved accross undo's. */
+ BKE_lib_id_swap(NULL, id_new, id_old);
+
+ /* `id_new` now has content from `id_old`, we need to ensure those old ID pointers are valid.
+ * Note: Since we want to re-use all old pointers here, code is much simpler than for Scene. */
+ BKE_library_foreach_ID_link(NULL, id_new, brush_undo_preserve_cb, reader, IDWALK_NOP);
+
+ /* Note: We do not swap IDProperties, as dealing with potential ID pointers in those would be
+ * fairly delicate. */
+ SWAP(IDProperty *, id_new->properties, id_old->properties);
+}
+
IDTypeInfo IDType_ID_BR = {
.id_code = ID_BR,
.id_filter = FILTER_ID_BR,
@@ -376,6 +407,8 @@ IDTypeInfo IDType_ID_BR = {
.blend_read_data = brush_blend_read_data,
.blend_read_lib = brush_blend_read_lib,
.blend_read_expand = brush_blend_read_expand,
+
+ .blend_read_undo_preserve = brush_undo_preserve,
};
static RNG *brush_rng;
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index 0ee0242866f..d6c31809a2e 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -140,6 +140,8 @@ IDTypeInfo IDType_ID_CF = {
.blend_read_data = cache_file_blend_read_data,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
/* TODO: make this per cache file to avoid global locks. */
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 3980a552855..0ca22e34973 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -201,6 +201,8 @@ IDTypeInfo IDType_ID_CA = {
.blend_read_data = camera_blend_read_data,
.blend_read_lib = camera_blend_read_lib,
.blend_read_expand = camera_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
/** \} */
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 403722b80cf..e9df562a15f 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -55,7 +55,7 @@
/* Prototypes for internal functions.
*/
static void cloth_to_object(Object *ob, ClothModifierData *clmd, float (*vertexCos)[3]);
-static void cloth_from_mesh(ClothModifierData *clmd, Mesh *mesh);
+static void cloth_from_mesh(ClothModifierData *clmd, const Object *ob, Mesh *mesh);
static bool cloth_from_object(
Object *ob, ClothModifierData *clmd, Mesh *mesh, float framenr, int first);
static void cloth_update_springs(ClothModifierData *clmd);
@@ -234,13 +234,13 @@ static bool do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int
if (clmd->clothObject == NULL) {
if (!cloth_from_object(ob, clmd, result, framenr, 1)) {
BKE_ptcache_invalidate(cache);
- BKE_modifier_set_error(&(clmd->modifier), "Can't initialize cloth");
+ BKE_modifier_set_error(ob, &(clmd->modifier), "Can't initialize cloth");
return false;
}
if (clmd->clothObject == NULL) {
BKE_ptcache_invalidate(cache);
- BKE_modifier_set_error(&(clmd->modifier), "Null cloth object");
+ BKE_modifier_set_error(ob, &(clmd->modifier), "Null cloth object");
return false;
}
@@ -742,7 +742,7 @@ static bool cloth_from_object(
clmd->clothObject->edgeset = NULL;
}
else {
- BKE_modifier_set_error(&(clmd->modifier), "Out of memory on allocating clmd->clothObject");
+ BKE_modifier_set_error(ob, &(clmd->modifier), "Out of memory on allocating clmd->clothObject");
return false;
}
@@ -751,7 +751,7 @@ static bool cloth_from_object(
return false;
}
- cloth_from_mesh(clmd, mesh);
+ cloth_from_mesh(clmd, ob, mesh);
/* create springs */
clmd->clothObject->springs = NULL;
@@ -814,7 +814,7 @@ static bool cloth_from_object(
if (!cloth_build_springs(clmd, mesh)) {
cloth_free_modifier(clmd);
- BKE_modifier_set_error(&(clmd->modifier), "Cannot build springs");
+ BKE_modifier_set_error(ob, &(clmd->modifier), "Cannot build springs");
return false;
}
@@ -831,7 +831,7 @@ static bool cloth_from_object(
return true;
}
-static void cloth_from_mesh(ClothModifierData *clmd, Mesh *mesh)
+static void cloth_from_mesh(ClothModifierData *clmd, const Object *ob, Mesh *mesh)
{
const MLoop *mloop = mesh->mloop;
const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(mesh);
@@ -844,8 +844,8 @@ static void cloth_from_mesh(ClothModifierData *clmd, Mesh *mesh)
"clothVertex");
if (clmd->clothObject->verts == NULL) {
cloth_free_modifier(clmd);
- BKE_modifier_set_error(&(clmd->modifier),
- "Out of memory on allocating clmd->clothObject->verts");
+ BKE_modifier_set_error(
+ ob, &(clmd->modifier), "Out of memory on allocating clmd->clothObject->verts");
printf("cloth_free_modifier clmd->clothObject->verts\n");
return;
}
@@ -861,8 +861,8 @@ static void cloth_from_mesh(ClothModifierData *clmd, Mesh *mesh)
clmd->clothObject->tri = MEM_mallocN(sizeof(MVertTri) * looptri_num, "clothLoopTris");
if (clmd->clothObject->tri == NULL) {
cloth_free_modifier(clmd);
- BKE_modifier_set_error(&(clmd->modifier),
- "Out of memory on allocating clmd->clothObject->looptri");
+ BKE_modifier_set_error(
+ ob, &(clmd->modifier), "Out of memory on allocating clmd->clothObject->looptri");
printf("cloth_free_modifier clmd->clothObject->looptri\n");
return;
}
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index e6620ea10dc..ab92480cce2 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -18,6 +18,9 @@
* \ingroup bke
*/
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#include <string.h>
#include "BLI_blenlib.h"
@@ -55,6 +58,8 @@
#include "MEM_guardedalloc.h"
+#include "BLO_read_write.h"
+
/* -------------------------------------------------------------------- */
/** \name Prototypes
* \{ */
@@ -167,6 +172,173 @@ static void collection_foreach_id(ID *id, LibraryForeachIDData *data)
}
}
+void BKE_collection_blend_write_nolib(BlendWriter *writer, Collection *collection)
+{
+ BKE_id_blend_write(writer, &collection->id);
+
+ /* Shared function for collection data-blocks and scene master collection. */
+ BKE_previewimg_blend_write(writer, collection->preview);
+
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
+ BLO_write_struct(writer, CollectionObject, cob);
+ }
+
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
+ BLO_write_struct(writer, CollectionChild, child);
+ }
+}
+
+static void collection_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ Collection *collection = (Collection *)id;
+ if (collection->id.us > 0 || BLO_write_is_undo(writer)) {
+ /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
+ collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
+ collection->tag = 0;
+ BLI_listbase_clear(&collection->object_cache);
+ BLI_listbase_clear(&collection->parents);
+
+ /* write LibData */
+ BLO_write_id_struct(writer, Collection, id_address, &collection->id);
+
+ BKE_collection_blend_write_nolib(writer, collection);
+ }
+}
+
+#ifdef USE_COLLECTION_COMPAT_28
+void BKE_collection_compat_blend_read_data(BlendDataReader *reader, SceneCollection *sc)
+{
+ BLO_read_list(reader, &sc->objects);
+ BLO_read_list(reader, &sc->scene_collections);
+
+ LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) {
+ BKE_collection_compat_blend_read_data(reader, nsc);
+ }
+}
+#endif
+
+void BKE_collection_blend_read_data(BlendDataReader *reader, Collection *collection)
+{
+ BLO_read_list(reader, &collection->gobject);
+ BLO_read_list(reader, &collection->children);
+
+ BLO_read_data_address(reader, &collection->preview);
+ BKE_previewimg_blend_read(reader, collection->preview);
+
+ collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
+ collection->tag = 0;
+ BLI_listbase_clear(&collection->object_cache);
+ BLI_listbase_clear(&collection->parents);
+
+#ifdef USE_COLLECTION_COMPAT_28
+ /* This runs before the very first doversion. */
+ BLO_read_data_address(reader, &collection->collection);
+ if (collection->collection != NULL) {
+ BKE_collection_compat_blend_read_data(reader, collection->collection);
+ }
+
+ BLO_read_data_address(reader, &collection->view_layer);
+ if (collection->view_layer != NULL) {
+ BKE_view_layer_blend_read_data(reader, collection->view_layer);
+ }
+#endif
+}
+
+static void collection_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ Collection *collection = (Collection *)id;
+ BKE_collection_blend_read_data(reader, collection);
+}
+
+static void lib_link_collection_data(BlendLibReader *reader, Library *lib, Collection *collection)
+{
+ LISTBASE_FOREACH_MUTABLE (CollectionObject *, cob, &collection->gobject) {
+ BLO_read_id_address(reader, lib, &cob->ob);
+
+ if (cob->ob == NULL) {
+ BLI_freelinkN(&collection->gobject, cob);
+ }
+ }
+
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
+ BLO_read_id_address(reader, lib, &child->collection);
+ }
+}
+
+#ifdef USE_COLLECTION_COMPAT_28
+void BKE_collection_compat_blend_read_lib(BlendLibReader *reader,
+ Library *lib,
+ SceneCollection *sc)
+{
+ LISTBASE_FOREACH (LinkData *, link, &sc->objects) {
+ BLO_read_id_address(reader, lib, &link->data);
+ BLI_assert(link->data);
+ }
+
+ LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) {
+ BKE_collection_compat_blend_read_lib(reader, lib, nsc);
+ }
+}
+#endif
+
+void BKE_collection_blend_read_lib(BlendLibReader *reader, Collection *collection)
+{
+#ifdef USE_COLLECTION_COMPAT_28
+ if (collection->collection) {
+ BKE_collection_compat_blend_read_lib(reader, collection->id.lib, collection->collection);
+ }
+
+ if (collection->view_layer) {
+ BKE_view_layer_blend_read_lib(reader, collection->id.lib, collection->view_layer);
+ }
+#endif
+
+ lib_link_collection_data(reader, collection->id.lib, collection);
+}
+
+static void collection_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+ Collection *collection = (Collection *)id;
+ BKE_collection_blend_read_lib(reader, collection);
+}
+
+#ifdef USE_COLLECTION_COMPAT_28
+void BKE_collection_compat_blend_read_expand(struct BlendExpander *expander,
+ struct SceneCollection *sc)
+{
+ LISTBASE_FOREACH (LinkData *, link, &sc->objects) {
+ BLO_expand(expander, link->data);
+ }
+
+ LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) {
+ BKE_collection_compat_blend_read_expand(expander, nsc);
+ }
+}
+#endif
+
+void BKE_collection_blend_read_expand(BlendExpander *expander, Collection *collection)
+{
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
+ BLO_expand(expander, cob->ob);
+ }
+
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
+ BLO_expand(expander, child->collection);
+ }
+
+#ifdef USE_COLLECTION_COMPAT_28
+ if (collection->collection != NULL) {
+ BKE_collection_compat_blend_read_expand(expander, collection->collection);
+ }
+#endif
+}
+
+static void collection_blend_read_expand(BlendExpander *expander, ID *id)
+{
+ Collection *collection = (Collection *)id;
+ BKE_collection_blend_read_expand(expander, collection);
+}
+
IDTypeInfo IDType_ID_GR = {
.id_code = ID_GR,
.id_filter = FILTER_ID_GR,
@@ -184,10 +356,12 @@ IDTypeInfo IDType_ID_GR = {
.foreach_id = collection_foreach_id,
.foreach_cache = NULL,
- .blend_write = NULL,
- .blend_read_data = NULL,
- .blend_read_lib = NULL,
- .blend_read_expand = NULL,
+ .blend_write = collection_blend_write,
+ .blend_read_data = collection_blend_read_data,
+ .blend_read_lib = collection_blend_read_lib,
+ .blend_read_expand = collection_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
/** \} */
@@ -301,6 +475,7 @@ void BKE_collection_add_from_collection(Main *bmain,
/** Free (or release) any data used by this collection (does not free the collection itself). */
void BKE_collection_free(Collection *collection)
{
+ BKE_libblock_free_data(&collection->id, false);
collection_free_data(&collection->id);
}
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 34e8e8bc6fb..3eb9fb6161d 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -1257,7 +1257,7 @@ void BKE_curvemapping_blend_read(BlendDataReader *reader, CurveMapping *cumap)
/* ***************** Histogram **************** */
-#define INV_255 (1.f / 255.f)
+#define INV_255 (1.0f / 255.0f)
BLI_INLINE int get_bin_float(float f)
{
@@ -1570,8 +1570,8 @@ void BKE_scopes_update(Scopes *scopes,
return;
}
- if (scopes->hist.ymax == 0.f) {
- scopes->hist.ymax = 1.f;
+ if (scopes->hist.ymax == 0.0f) {
+ scopes->hist.ymax = 1.0f;
}
/* hmmmm */
@@ -1819,6 +1819,24 @@ void BKE_color_managed_view_settings_free(ColorManagedViewSettings *settings)
}
}
+void BKE_color_managed_view_settings_blend_write(BlendWriter *writer,
+ ColorManagedViewSettings *settings)
+{
+ if (settings->curve_mapping) {
+ BKE_curvemapping_blend_write(writer, settings->curve_mapping);
+ }
+}
+
+void BKE_color_managed_view_settings_blend_read_data(BlendDataReader *reader,
+ ColorManagedViewSettings *settings)
+{
+ BLO_read_data_address(reader, &settings->curve_mapping);
+
+ if (settings->curve_mapping) {
+ BKE_curvemapping_blend_read(reader, settings->curve_mapping);
+ }
+}
+
void BKE_color_managed_colorspace_settings_init(
ColorManagedColorspaceSettings *colorspace_settings)
{
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 274546132fb..a1b53b721d3 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -21,6 +21,9 @@
* \ingroup bke
*/
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#include <float.h>
#include <math.h>
#include <stddef.h>
@@ -45,6 +48,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
+#include "DNA_screen_types.h"
#include "DNA_lattice_types.h"
#include "DNA_movieclip_types.h"
@@ -79,6 +83,8 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
+#include "BLO_read_write.h"
+
#include "CLG_log.h"
#ifdef WITH_PYTHON
@@ -5406,6 +5412,11 @@ bool BKE_constraint_remove_ex(ListBase *list, Object *ob, bConstraint *con, bool
return false;
}
+void BKE_constraint_panel_expand(bConstraint *con)
+{
+ con->ui_expand_flag |= UI_PANEL_DATA_EXPAND_ROOT;
+}
+
/* ......... */
/* Creates a new constraint, initializes its data, and returns it */
@@ -5421,10 +5432,10 @@ static bConstraint *add_new_constraint_internal(const char *name, short type)
con->enforce = 1.0f;
/* Only open the main panel when constraints are created, not the sub-panels. */
- con->ui_expand_flag = (1 << 0);
+ con->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT;
if (ELEM(type, CONSTRAINT_TYPE_ACTION, CONSTRAINT_TYPE_SPLINEIK)) {
/* Expand the two sub-panels in the cases where the main panel barely has any properties. */
- con->ui_expand_flag |= (1 << 1) | (1 << 2);
+ con->ui_expand_flag |= UI_SUBPANEL_DATA_EXPAND_1 | UI_SUBPANEL_DATA_EXPAND_2;
}
/* Determine a basic name, and info */
@@ -6080,3 +6091,174 @@ void BKE_constraints_solve(struct Depsgraph *depsgraph,
}
}
}
+
+void BKE_constraint_blend_write(BlendWriter *writer, ListBase *conlist)
+{
+ LISTBASE_FOREACH (bConstraint *, con, conlist) {
+ const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
+
+ /* Write the specific data */
+ if (cti && con->data) {
+ /* firstly, just write the plain con->data struct */
+ BLO_write_struct_by_name(writer, cti->structName, con->data);
+
+ /* do any constraint specific stuff */
+ switch (con->type) {
+ case CONSTRAINT_TYPE_PYTHON: {
+ bPythonConstraint *data = con->data;
+
+ /* write targets */
+ LISTBASE_FOREACH (bConstraintTarget *, ct, &data->targets) {
+ BLO_write_struct(writer, bConstraintTarget, ct);
+ }
+
+ /* Write ID Properties -- and copy this comment EXACTLY for easy finding
+ * of library blocks that implement this.*/
+ IDP_BlendWrite(writer, data->prop);
+
+ break;
+ }
+ case CONSTRAINT_TYPE_ARMATURE: {
+ bArmatureConstraint *data = con->data;
+
+ /* write targets */
+ LISTBASE_FOREACH (bConstraintTarget *, ct, &data->targets) {
+ BLO_write_struct(writer, bConstraintTarget, ct);
+ }
+
+ break;
+ }
+ case CONSTRAINT_TYPE_SPLINEIK: {
+ bSplineIKConstraint *data = con->data;
+
+ /* write points array */
+ BLO_write_float_array(writer, data->numpoints, data->points);
+
+ break;
+ }
+ }
+ }
+
+ /* Write the constraint */
+ BLO_write_struct(writer, bConstraint, con);
+ }
+}
+
+void BKE_constraint_blend_read_data(BlendDataReader *reader, ListBase *lb)
+{
+ BLO_read_list(reader, lb);
+ LISTBASE_FOREACH (bConstraint *, con, lb) {
+ BLO_read_data_address(reader, &con->data);
+
+ switch (con->type) {
+ case CONSTRAINT_TYPE_PYTHON: {
+ bPythonConstraint *data = con->data;
+
+ BLO_read_list(reader, &data->targets);
+
+ BLO_read_data_address(reader, &data->prop);
+ IDP_BlendDataRead(reader, &data->prop);
+ break;
+ }
+ case CONSTRAINT_TYPE_ARMATURE: {
+ bArmatureConstraint *data = con->data;
+
+ BLO_read_list(reader, &data->targets);
+
+ break;
+ }
+ case CONSTRAINT_TYPE_SPLINEIK: {
+ bSplineIKConstraint *data = con->data;
+
+ BLO_read_data_address(reader, &data->points);
+ break;
+ }
+ case CONSTRAINT_TYPE_KINEMATIC: {
+ bKinematicConstraint *data = con->data;
+
+ con->lin_error = 0.0f;
+ con->rot_error = 0.0f;
+
+ /* version patch for runtime flag, was not cleared in some case */
+ data->flag &= ~CONSTRAINT_IK_AUTO;
+ break;
+ }
+ case CONSTRAINT_TYPE_CHILDOF: {
+ /* XXX version patch, in older code this flag wasn't always set, and is inherent to type */
+ if (con->ownspace == CONSTRAINT_SPACE_POSE) {
+ con->flag |= CONSTRAINT_SPACEONCE;
+ }
+ break;
+ }
+ case CONSTRAINT_TYPE_TRANSFORM_CACHE: {
+ bTransformCacheConstraint *data = con->data;
+ data->reader = NULL;
+ data->reader_object_path[0] = '\0';
+ }
+ }
+ }
+}
+
+/* temp struct used to transport needed info to lib_link_constraint_cb() */
+typedef struct tConstraintLinkData {
+ BlendLibReader *reader;
+ ID *id;
+} tConstraintLinkData;
+/* callback function used to relink constraint ID-links */
+static void lib_link_constraint_cb(bConstraint *UNUSED(con),
+ ID **idpoin,
+ bool UNUSED(is_reference),
+ void *userdata)
+{
+ tConstraintLinkData *cld = (tConstraintLinkData *)userdata;
+ BLO_read_id_address(cld->reader, cld->id->lib, idpoin);
+}
+
+void BKE_constraint_blend_read_lib(BlendLibReader *reader, ID *id, ListBase *conlist)
+{
+ tConstraintLinkData cld;
+
+ /* legacy fixes */
+ LISTBASE_FOREACH (bConstraint *, con, conlist) {
+ /* patch for error introduced by changing constraints (dunno how) */
+ /* if con->data type changes, dna cannot resolve the pointer! (ton) */
+ if (con->data == NULL) {
+ 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 */
+
+ /* If linking from a library, clear 'local' library override flag. */
+ if (id->lib != NULL) {
+ con->flag &= ~CONSTRAINT_OVERRIDE_LIBRARY_LOCAL;
+ }
+ }
+
+ /* relink all ID-blocks used by the constraints */
+ cld.reader = reader;
+ cld.id = id;
+
+ BKE_constraints_id_loop(conlist, lib_link_constraint_cb, &cld);
+}
+
+/* callback function used to expand constraint ID-links */
+static void expand_constraint_cb(bConstraint *UNUSED(con),
+ ID **idpoin,
+ bool UNUSED(is_reference),
+ void *userdata)
+{
+ BlendExpander *expander = userdata;
+ BLO_expand(expander, *idpoin);
+}
+
+void BKE_constraint_blend_read_expand(BlendExpander *expander, ListBase *lb)
+{
+ BKE_constraints_id_loop(lb, expand_constraint_cb, expander);
+
+ /* deprecated manual expansion stuff */
+ LISTBASE_FOREACH (bConstraint *, curcon, lb) {
+ if (curcon->ipo) {
+ BLO_expand(expander, curcon->ipo); /* XXX deprecated - old animation system */
+ }
+ }
+}
diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index 01c05c62b70..4e1ec9ba35e 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -273,7 +273,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgra
for (i = 0; md && i <= cageIndex; i++, md = md->next) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
- if (!editbmesh_modifier_is_enabled(scene, md, me != NULL)) {
+ if (!editbmesh_modifier_is_enabled(scene, ob, md, me != NULL)) {
continue;
}
@@ -302,7 +302,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgra
}
for (; md && i <= cageIndex; md = md->next, i++) {
- if (editbmesh_modifier_is_enabled(scene, md, me != NULL) &&
+ if (editbmesh_modifier_is_enabled(scene, ob, md, me != NULL) &&
BKE_modifier_is_correctable_deformed(md)) {
numleft++;
}
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index b2ebb56d828..091d542c43d 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -325,6 +325,8 @@ IDTypeInfo IDType_ID_CU = {
.blend_read_data = curve_blend_read_data,
.blend_read_lib = curve_blend_read_lib,
.blend_read_expand = curve_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
static int cu_isectLL(const float v1[3],
@@ -438,7 +440,6 @@ ListBase *BKE_curve_editNurbs_get(Curve *cu)
short BKE_curve_type_get(const Curve *cu)
{
- Nurb *nu;
int type = cu->type;
if (cu->vfont) {
@@ -448,7 +449,7 @@ short BKE_curve_type_get(const Curve *cu)
if (!cu->type) {
type = OB_CURVE;
- for (nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
if (nu->pntsv > 1) {
type = OB_SURF;
}
@@ -461,15 +462,14 @@ short BKE_curve_type_get(const Curve *cu)
void BKE_curve_curve_dimension_update(Curve *cu)
{
ListBase *nurbs = BKE_curve_nurbs_get(cu);
- Nurb *nu = nurbs->first;
if (cu->flag & CU_3D) {
- for (; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
nu->flag &= ~CU_2D;
}
}
else {
- for (; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
nu->flag |= CU_2D;
BKE_nurb_test_2d(nu);
@@ -569,10 +569,9 @@ void BKE_curve_texspace_get(Curve *cu, float r_loc[3], float r_size[3])
bool BKE_nurbList_index_get_co(ListBase *nurb, const int index, float r_co[3])
{
- Nurb *nu;
int tot = 0;
- for (nu = nurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nurb) {
int tot_nu;
if (nu->type == CU_BEZIER) {
tot_nu = nu->pntsu;
@@ -596,39 +595,33 @@ bool BKE_nurbList_index_get_co(ListBase *nurb, const int index, float r_co[3])
int BKE_nurbList_verts_count(ListBase *nurb)
{
- Nurb *nu;
int tot = 0;
- nu = nurb->first;
- while (nu) {
+ LISTBASE_FOREACH (Nurb *, nu, nurb) {
if (nu->bezt) {
tot += 3 * nu->pntsu;
}
else if (nu->bp) {
tot += nu->pntsu * nu->pntsv;
}
-
- nu = nu->next;
}
+
return tot;
}
int BKE_nurbList_verts_count_without_handles(ListBase *nurb)
{
- Nurb *nu;
int tot = 0;
- nu = nurb->first;
- while (nu) {
+ LISTBASE_FOREACH (Nurb *, nu, nurb) {
if (nu->bezt) {
tot += nu->pntsu;
}
else if (nu->bp) {
tot += nu->pntsu * nu->pntsv;
}
-
- nu = nu->next;
}
+
return tot;
}
@@ -636,7 +629,6 @@ int BKE_nurbList_verts_count_without_handles(ListBase *nurb)
void BKE_nurb_free(Nurb *nu)
{
-
if (nu == NULL) {
return;
}
@@ -664,17 +656,12 @@ void BKE_nurb_free(Nurb *nu)
void BKE_nurbList_free(ListBase *lb)
{
- Nurb *nu, *next;
-
if (lb == NULL) {
return;
}
- nu = lb->first;
- while (nu) {
- next = nu->next;
+ LISTBASE_FOREACH_MUTABLE (Nurb *, nu, lb) {
BKE_nurb_free(nu);
- nu = next;
}
BLI_listbase_clear(lb);
}
@@ -747,16 +734,11 @@ Nurb *BKE_nurb_copy(Nurb *src, int pntsu, int pntsv)
void BKE_nurbList_duplicate(ListBase *lb1, const ListBase *lb2)
{
- Nurb *nu, *nun;
-
BKE_nurbList_free(lb1);
- nu = lb2->first;
- while (nu) {
- nun = BKE_nurb_duplicate(nu);
- BLI_addtail(lb1, nun);
-
- nu = nu->next;
+ LISTBASE_FOREACH (const Nurb *, nu, lb2) {
+ Nurb *nurb_new = BKE_nurb_duplicate(nu);
+ BLI_addtail(lb1, nurb_new);
}
}
@@ -2202,6 +2184,22 @@ static void bevel_list_calc_bisect(BevList *bl)
bevp1 = bevp2;
bevp2++;
}
+
+ if (is_cyclic == false) {
+ bevp0 = &bl->bevpoints[0];
+ bevp1 = &bl->bevpoints[1];
+ sub_v3_v3v3(bevp0->dir, bevp1->vec, bevp0->vec);
+ if (normalize_v3(bevp0->dir) == 0.0f) {
+ copy_v3_v3(bevp0->dir, bevp1->dir);
+ }
+
+ bevp0 = &bl->bevpoints[bl->nr - 2];
+ bevp1 = &bl->bevpoints[bl->nr - 1];
+ sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp0->vec);
+ if (normalize_v3(bevp1->dir) == 0.0f) {
+ copy_v3_v3(bevp1->dir, bevp0->dir);
+ }
+ }
}
static void bevel_list_flip_tangents(BevList *bl)
{
@@ -2625,9 +2623,7 @@ static void bevlist_firstlast_direction_calc_from_bpoint(Nurb *nu, BevList *bl)
void BKE_curve_bevelList_free(ListBase *bev)
{
- BevList *bl, *blnext;
- for (bl = bev->first; bl != NULL; bl = blnext) {
- blnext = bl->next;
+ LISTBASE_FOREACH_MUTABLE (BevList *, bl, bev) {
if (bl->seglen != NULL) {
MEM_freeN(bl->seglen);
}
@@ -2654,12 +2650,11 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
/* this function needs an object, because of tflag and upflag */
Curve *cu = ob->data;
- Nurb *nu;
BezTriple *bezt, *prevbezt;
BPoint *bp;
- BevList *bl, *blnew, *blnext;
+ BevList *blnew;
BevPoint *bevp2, *bevp1 = NULL, *bevp0;
- const float treshold = 0.00001f;
+ const float threshold = 0.00001f;
float min, inp;
float *seglen = NULL;
struct BevelSort *sortdata, *sd, *sd1;
@@ -2685,16 +2680,26 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
/* STEP 1: MAKE POLYS */
BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
- nu = nurbs->first;
if (cu->editnurb && ob->type != OB_FONT) {
is_editmode = 1;
}
- for (; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
if (nu->hide && is_editmode) {
continue;
}
+ /* check we are a single point? also check we are not a surface and that the orderu is sane,
+ * enforced in the UI but can go wrong possibly */
+ if (!BKE_nurb_check_valid_u(nu)) {
+ BevList *bl = MEM_callocN(sizeof(BevList), "makeBevelList1");
+ bl->bevpoints = MEM_calloc_arrayN(1, sizeof(BevPoint), "makeBevelPoints1");
+ BLI_addtail(bev, bl);
+ bl->nr = 0;
+ bl->charidx = nu->charidx;
+ continue;
+ }
+
/* check if we will calculate tilt data */
do_tilt = CU_DO_TILT(cu, nu);
@@ -2703,89 +2708,231 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
do_weight = true;
- /* check we are a single point? also check we are not a surface and that the orderu is sane,
- * enforced in the UI but can go wrong possibly */
- if (!BKE_nurb_check_valid_u(nu)) {
- bl = MEM_callocN(sizeof(BevList), "makeBevelList1");
- bl->bevpoints = MEM_calloc_arrayN(1, sizeof(BevPoint), "makeBevelPoints1");
+ BevPoint *bevp;
+
+ if (for_render && cu->resolu_ren != 0) {
+ resolu = cu->resolu_ren;
+ }
+ else {
+ resolu = nu->resolu;
+ }
+
+ segcount = SEGMENTSU(nu);
+
+ if (nu->type == CU_POLY) {
+ len = nu->pntsu;
+ BevList *bl = MEM_callocN(sizeof(BevList), "makeBevelList2");
+ bl->bevpoints = MEM_calloc_arrayN(len, sizeof(BevPoint), "makeBevelPoints2");
+ if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) {
+ bl->seglen = MEM_malloc_arrayN(segcount, sizeof(float), "makeBevelList2_seglen");
+ bl->segbevcount = MEM_malloc_arrayN(segcount, sizeof(int), "makeBevelList2_segbevcount");
+ }
BLI_addtail(bev, bl);
- bl->nr = 0;
+
+ bl->poly = (nu->flagu & CU_NURB_CYCLIC) ? 0 : -1;
+ bl->nr = len;
+ bl->dupe_nr = 0;
bl->charidx = nu->charidx;
+ bevp = bl->bevpoints;
+ bevp->offset = 0;
+ bp = nu->bp;
+ seglen = bl->seglen;
+ segbevcount = bl->segbevcount;
+
+ while (len--) {
+ copy_v3_v3(bevp->vec, bp->vec);
+ bevp->tilt = bp->tilt;
+ bevp->radius = bp->radius;
+ bevp->weight = bp->weight;
+ bevp->split_tag = true;
+ bp++;
+ if (seglen != NULL && len != 0) {
+ *seglen = len_v3v3(bevp->vec, bp->vec);
+ bevp++;
+ bevp->offset = *seglen;
+ if (*seglen > threshold) {
+ *segbevcount = 1;
+ }
+ else {
+ *segbevcount = 0;
+ }
+ seglen++;
+ segbevcount++;
+ }
+ else {
+ bevp++;
+ }
+ }
+
+ if ((nu->flagu & CU_NURB_CYCLIC) == 0) {
+ bevlist_firstlast_direction_calc_from_bpoint(nu, bl);
+ }
}
- else {
- BevPoint *bevp;
+ else if (nu->type == CU_BEZIER) {
+ /* in case last point is not cyclic */
+ len = segcount * resolu + 1;
- if (for_render && cu->resolu_ren != 0) {
- resolu = cu->resolu_ren;
+ BevList *bl = MEM_callocN(sizeof(BevList), "makeBevelBPoints");
+ bl->bevpoints = MEM_calloc_arrayN(len, sizeof(BevPoint), "makeBevelBPointsPoints");
+ if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) {
+ bl->seglen = MEM_malloc_arrayN(segcount, sizeof(float), "makeBevelBPoints_seglen");
+ bl->segbevcount = MEM_malloc_arrayN(segcount, sizeof(int), "makeBevelBPoints_segbevcount");
+ }
+ BLI_addtail(bev, bl);
+
+ bl->poly = (nu->flagu & CU_NURB_CYCLIC) ? 0 : -1;
+ bl->charidx = nu->charidx;
+
+ bevp = bl->bevpoints;
+ seglen = bl->seglen;
+ segbevcount = bl->segbevcount;
+
+ bevp->offset = 0;
+ if (seglen != NULL) {
+ *seglen = 0;
+ *segbevcount = 0;
+ }
+
+ a = nu->pntsu - 1;
+ bezt = nu->bezt;
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ a++;
+ prevbezt = nu->bezt + (nu->pntsu - 1);
}
else {
- resolu = nu->resolu;
+ prevbezt = bezt;
+ bezt++;
}
- segcount = SEGMENTSU(nu);
+ sub_v3_v3v3(bevp->dir, prevbezt->vec[2], prevbezt->vec[1]);
+ normalize_v3(bevp->dir);
- if (nu->type == CU_POLY) {
- len = nu->pntsu;
- bl = MEM_callocN(sizeof(BevList), "makeBevelList2");
- bl->bevpoints = MEM_calloc_arrayN(len, sizeof(BevPoint), "makeBevelPoints2");
- if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) {
- bl->seglen = MEM_malloc_arrayN(segcount, sizeof(float), "makeBevelList2_seglen");
- bl->segbevcount = MEM_malloc_arrayN(segcount, sizeof(int), "makeBevelList2_segbevcount");
- }
- BLI_addtail(bev, bl);
+ BLI_assert(segcount >= a);
- bl->poly = (nu->flagu & CU_NURB_CYCLIC) ? 0 : -1;
- bl->nr = len;
- bl->dupe_nr = 0;
- bl->charidx = nu->charidx;
- bevp = bl->bevpoints;
- bevp->offset = 0;
- bp = nu->bp;
- seglen = bl->seglen;
- segbevcount = bl->segbevcount;
+ while (a--) {
+ if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
- while (len--) {
- copy_v3_v3(bevp->vec, bp->vec);
- bevp->tilt = bp->tilt;
- bevp->radius = bp->radius;
- bevp->weight = bp->weight;
+ copy_v3_v3(bevp->vec, prevbezt->vec[1]);
+ bevp->tilt = prevbezt->tilt;
+ bevp->radius = prevbezt->radius;
+ bevp->weight = prevbezt->weight;
bevp->split_tag = true;
- bp++;
- if (seglen != NULL && len != 0) {
- *seglen = len_v3v3(bevp->vec, bp->vec);
- bevp++;
+ bevp->dupe_tag = false;
+ bevp++;
+ bl->nr++;
+ bl->dupe_nr = 1;
+ if (seglen != NULL) {
+ *seglen = len_v3v3(prevbezt->vec[1], bezt->vec[1]);
bevp->offset = *seglen;
- if (*seglen > treshold) {
+ seglen++;
+ /* match segbevcount to the cleaned up bevel lists (see STEP 2) */
+ if (bevp->offset > threshold) {
*segbevcount = 1;
}
- else {
- *segbevcount = 0;
+ segbevcount++;
+ }
+ }
+ else {
+ /* always do all three, to prevent data hanging around */
+ int j;
+
+ /* BevPoint must stay aligned to 4 so sizeof(BevPoint)/sizeof(float) works */
+ for (j = 0; j < 3; j++) {
+ BKE_curve_forward_diff_bezier(prevbezt->vec[1][j],
+ prevbezt->vec[2][j],
+ bezt->vec[0][j],
+ bezt->vec[1][j],
+ &(bevp->vec[j]),
+ resolu,
+ sizeof(BevPoint));
+ }
+
+ /* if both arrays are NULL do nothiong */
+ tilt_bezpart(prevbezt,
+ bezt,
+ nu,
+ do_tilt ? &bevp->tilt : NULL,
+ do_radius ? &bevp->radius : NULL,
+ do_weight ? &bevp->weight : NULL,
+ resolu,
+ sizeof(BevPoint));
+
+ if (cu->twist_mode == CU_TWIST_TANGENT) {
+ forward_diff_bezier_cotangent(prevbezt->vec[1],
+ prevbezt->vec[2],
+ bezt->vec[0],
+ bezt->vec[1],
+ bevp->tan,
+ resolu,
+ sizeof(BevPoint));
+ }
+
+ /* indicate with handlecodes double points */
+ if (prevbezt->h1 == prevbezt->h2) {
+ if (ELEM(prevbezt->h1, 0, HD_VECT)) {
+ bevp->split_tag = true;
+ }
+ }
+ else {
+ if (ELEM(prevbezt->h1, 0, HD_VECT)) {
+ bevp->split_tag = true;
+ }
+ else if (ELEM(prevbezt->h2, 0, HD_VECT)) {
+ bevp->split_tag = true;
+ }
+ }
+
+ /* seglen */
+ if (seglen != NULL) {
+ *seglen = 0;
+ *segbevcount = 0;
+ for (j = 0; j < resolu; j++) {
+ bevp0 = bevp;
+ bevp++;
+ bevp->offset = len_v3v3(bevp0->vec, bevp->vec);
+ /* match seglen and segbevcount to the cleaned up bevel lists (see STEP 2) */
+ if (bevp->offset > threshold) {
+ *seglen += bevp->offset;
+ *segbevcount += 1;
+ }
}
seglen++;
segbevcount++;
}
else {
- bevp++;
+ bevp += resolu;
}
+ bl->nr += resolu;
}
+ prevbezt = bezt;
+ bezt++;
+ }
- if ((nu->flagu & CU_NURB_CYCLIC) == 0) {
- bevlist_firstlast_direction_calc_from_bpoint(nu, bl);
- }
+ if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* not cyclic: endpoint */
+ copy_v3_v3(bevp->vec, prevbezt->vec[1]);
+ bevp->tilt = prevbezt->tilt;
+ bevp->radius = prevbezt->radius;
+ bevp->weight = prevbezt->weight;
+
+ sub_v3_v3v3(bevp->dir, prevbezt->vec[1], prevbezt->vec[0]);
+ normalize_v3(bevp->dir);
+
+ bl->nr++;
}
- else if (nu->type == CU_BEZIER) {
- /* in case last point is not cyclic */
- len = segcount * resolu + 1;
+ }
+ else if (nu->type == CU_NURBS) {
+ if (nu->pntsv == 1) {
+ len = (resolu * segcount);
- bl = MEM_callocN(sizeof(BevList), "makeBevelBPoints");
- bl->bevpoints = MEM_calloc_arrayN(len, sizeof(BevPoint), "makeBevelBPointsPoints");
+ BevList *bl = MEM_callocN(sizeof(BevList), "makeBevelList3");
+ bl->bevpoints = MEM_calloc_arrayN(len, sizeof(BevPoint), "makeBevelPoints3");
if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) {
- bl->seglen = MEM_malloc_arrayN(segcount, sizeof(float), "makeBevelBPoints_seglen");
- bl->segbevcount = MEM_malloc_arrayN(
- segcount, sizeof(int), "makeBevelBPoints_segbevcount");
+ bl->seglen = MEM_malloc_arrayN(segcount, sizeof(float), "makeBevelList3_seglen");
+ bl->segbevcount = MEM_malloc_arrayN(segcount, sizeof(int), "makeBevelList3_segbevcount");
}
BLI_addtail(bev, bl);
-
+ bl->nr = len;
+ bl->dupe_nr = 0;
bl->poly = (nu->flagu & CU_NURB_CYCLIC) ? 0 : -1;
bl->charidx = nu->charidx;
@@ -2793,292 +2940,134 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
seglen = bl->seglen;
segbevcount = bl->segbevcount;
- bevp->offset = 0;
- if (seglen != NULL) {
- *seglen = 0;
- *segbevcount = 0;
- }
-
- a = nu->pntsu - 1;
- bezt = nu->bezt;
- if (nu->flagu & CU_NURB_CYCLIC) {
- a++;
- prevbezt = nu->bezt + (nu->pntsu - 1);
- }
- else {
- prevbezt = bezt;
- bezt++;
- }
-
- sub_v3_v3v3(bevp->dir, prevbezt->vec[2], prevbezt->vec[1]);
- normalize_v3(bevp->dir);
-
- BLI_assert(segcount >= a);
+ BKE_nurb_makeCurve(nu,
+ &bevp->vec[0],
+ do_tilt ? &bevp->tilt : NULL,
+ do_radius ? &bevp->radius : NULL,
+ do_weight ? &bevp->weight : NULL,
+ resolu,
+ sizeof(BevPoint));
- while (a--) {
- if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
-
- copy_v3_v3(bevp->vec, prevbezt->vec[1]);
- bevp->tilt = prevbezt->tilt;
- bevp->radius = prevbezt->radius;
- bevp->weight = prevbezt->weight;
- bevp->split_tag = true;
- bevp->dupe_tag = false;
- bevp++;
- bl->nr++;
- bl->dupe_nr = 1;
- if (seglen != NULL) {
- *seglen = len_v3v3(prevbezt->vec[1], bezt->vec[1]);
- bevp->offset = *seglen;
- seglen++;
- /* match segbevcount to the cleaned up bevel lists (see STEP 2) */
- if (bevp->offset > treshold) {
- *segbevcount = 1;
- }
- segbevcount++;
- }
- }
- else {
- /* always do all three, to prevent data hanging around */
+ /* match seglen and segbevcount to the cleaned up bevel lists (see STEP 2) */
+ if (seglen != NULL) {
+ nr = segcount;
+ bevp0 = bevp;
+ bevp++;
+ while (nr) {
int j;
-
- /* BevPoint must stay aligned to 4 so sizeof(BevPoint)/sizeof(float) works */
- for (j = 0; j < 3; j++) {
- BKE_curve_forward_diff_bezier(prevbezt->vec[1][j],
- prevbezt->vec[2][j],
- bezt->vec[0][j],
- bezt->vec[1][j],
- &(bevp->vec[j]),
- resolu,
- sizeof(BevPoint));
- }
-
- /* if both arrays are NULL do nothiong */
- tilt_bezpart(prevbezt,
- bezt,
- nu,
- do_tilt ? &bevp->tilt : NULL,
- do_radius ? &bevp->radius : NULL,
- do_weight ? &bevp->weight : NULL,
- resolu,
- sizeof(BevPoint));
-
- if (cu->twist_mode == CU_TWIST_TANGENT) {
- forward_diff_bezier_cotangent(prevbezt->vec[1],
- prevbezt->vec[2],
- bezt->vec[0],
- bezt->vec[1],
- bevp->tan,
- resolu,
- sizeof(BevPoint));
- }
-
- /* indicate with handlecodes double points */
- if (prevbezt->h1 == prevbezt->h2) {
- if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) {
- bevp->split_tag = true;
- }
- }
- else {
- if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) {
- bevp->split_tag = true;
- }
- else if (prevbezt->h2 == 0 || prevbezt->h2 == HD_VECT) {
- bevp->split_tag = true;
- }
- }
-
- /* seglen */
- if (seglen != NULL) {
- *seglen = 0;
- *segbevcount = 0;
- for (j = 0; j < resolu; j++) {
- bevp0 = bevp;
- bevp++;
- bevp->offset = len_v3v3(bevp0->vec, bevp->vec);
- /* match seglen and segbevcount to the cleaned up bevel lists (see STEP 2) */
- if (bevp->offset > treshold) {
- *seglen += bevp->offset;
- *segbevcount += 1;
- }
+ *seglen = 0;
+ *segbevcount = 0;
+ /* We keep last bevel segment zero-length. */
+ for (j = 0; j < ((nr == 1) ? (resolu - 1) : resolu); j++) {
+ bevp->offset = len_v3v3(bevp0->vec, bevp->vec);
+ if (bevp->offset > threshold) {
+ *seglen += bevp->offset;
+ *segbevcount += 1;
}
- seglen++;
- segbevcount++;
- }
- else {
- bevp += resolu;
+ bevp0 = bevp;
+ bevp++;
}
- bl->nr += resolu;
+ seglen++;
+ segbevcount++;
+ nr--;
}
- prevbezt = bezt;
- bezt++;
}
- if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* not cyclic: endpoint */
- copy_v3_v3(bevp->vec, prevbezt->vec[1]);
- bevp->tilt = prevbezt->tilt;
- bevp->radius = prevbezt->radius;
- bevp->weight = prevbezt->weight;
-
- sub_v3_v3v3(bevp->dir, prevbezt->vec[1], prevbezt->vec[0]);
- normalize_v3(bevp->dir);
-
- bl->nr++;
- }
- }
- else if (nu->type == CU_NURBS) {
- if (nu->pntsv == 1) {
- len = (resolu * segcount);
-
- bl = MEM_callocN(sizeof(BevList), "makeBevelList3");
- bl->bevpoints = MEM_calloc_arrayN(len, sizeof(BevPoint), "makeBevelPoints3");
- if (need_seglen && (nu->flagu & CU_NURB_CYCLIC) == 0) {
- bl->seglen = MEM_malloc_arrayN(segcount, sizeof(float), "makeBevelList3_seglen");
- bl->segbevcount = MEM_malloc_arrayN(
- segcount, sizeof(int), "makeBevelList3_segbevcount");
- }
- BLI_addtail(bev, bl);
- bl->nr = len;
- bl->dupe_nr = 0;
- bl->poly = (nu->flagu & CU_NURB_CYCLIC) ? 0 : -1;
- bl->charidx = nu->charidx;
-
- bevp = bl->bevpoints;
- seglen = bl->seglen;
- segbevcount = bl->segbevcount;
-
- BKE_nurb_makeCurve(nu,
- &bevp->vec[0],
- do_tilt ? &bevp->tilt : NULL,
- do_radius ? &bevp->radius : NULL,
- do_weight ? &bevp->weight : NULL,
- resolu,
- sizeof(BevPoint));
-
- /* match seglen and segbevcount to the cleaned up bevel lists (see STEP 2) */
- if (seglen != NULL) {
- nr = segcount;
- bevp0 = bevp;
- bevp++;
- while (nr) {
- int j;
- *seglen = 0;
- *segbevcount = 0;
- /* We keep last bevel segment zero-length. */
- for (j = 0; j < ((nr == 1) ? (resolu - 1) : resolu); j++) {
- bevp->offset = len_v3v3(bevp0->vec, bevp->vec);
- if (bevp->offset > treshold) {
- *seglen += bevp->offset;
- *segbevcount += 1;
- }
- bevp0 = bevp;
- bevp++;
- }
- seglen++;
- segbevcount++;
- nr--;
- }
- }
-
- if ((nu->flagu & CU_NURB_CYCLIC) == 0) {
- bevlist_firstlast_direction_calc_from_bpoint(nu, bl);
- }
+ if ((nu->flagu & CU_NURB_CYCLIC) == 0) {
+ bevlist_firstlast_direction_calc_from_bpoint(nu, bl);
}
}
}
}
/* STEP 2: DOUBLE POINTS AND AUTOMATIC RESOLUTION, REDUCE DATABLOCKS */
- bl = bev->first;
- while (bl) {
- if (bl->nr) { /* null bevel items come from single points */
- /* Scale the threshold so high resolution shapes don't get over reduced, see: T49850. */
- const float threshold_resolu = 0.00001f / resolu;
- bool is_cyclic = bl->poly != -1;
- nr = bl->nr;
- if (is_cyclic) {
- bevp1 = bl->bevpoints;
- bevp0 = bevp1 + (nr - 1);
+ LISTBASE_FOREACH (BevList *, bl, bev) {
+ if (bl->nr == 0) { /* null bevel items come from single points */
+ continue;
+ }
+
+ /* Scale the threshold so high resolution shapes don't get over reduced, see: T49850. */
+ const float threshold_resolu = 0.00001f / resolu;
+ bool is_cyclic = bl->poly != -1;
+ nr = bl->nr;
+ if (is_cyclic) {
+ bevp1 = bl->bevpoints;
+ bevp0 = bevp1 + (nr - 1);
+ }
+ else {
+ bevp0 = bl->bevpoints;
+ bevp0->offset = 0;
+ bevp1 = bevp0 + 1;
+ }
+ nr--;
+ while (nr--) {
+ if (seglen != NULL) {
+ if (fabsf(bevp1->offset) < threshold) {
+ bevp0->dupe_tag = true;
+ bl->dupe_nr++;
+ }
}
else {
- bevp0 = bl->bevpoints;
- bevp0->offset = 0;
- bevp1 = bevp0 + 1;
- }
- nr--;
- while (nr--) {
- if (seglen != NULL) {
- if (fabsf(bevp1->offset) < treshold) {
- bevp0->dupe_tag = true;
- bl->dupe_nr++;
- }
- }
- else {
- if (compare_v3v3(bevp0->vec, bevp1->vec, threshold_resolu)) {
- bevp0->dupe_tag = true;
- bl->dupe_nr++;
- }
+ if (compare_v3v3(bevp0->vec, bevp1->vec, threshold_resolu)) {
+ bevp0->dupe_tag = true;
+ bl->dupe_nr++;
}
- bevp0 = bevp1;
- bevp1++;
}
+ bevp0 = bevp1;
+ bevp1++;
}
- bl = bl->next;
}
- bl = bev->first;
- while (bl) {
- blnext = bl->next;
- if (bl->nr && bl->dupe_nr) {
- nr = bl->nr - bl->dupe_nr + 1; /* +1 because vectorbezier sets flag too */
- blnew = MEM_mallocN(sizeof(BevList), "makeBevelList4");
- memcpy(blnew, bl, sizeof(BevList));
- blnew->bevpoints = MEM_calloc_arrayN(nr, sizeof(BevPoint), "makeBevelPoints4");
- if (!blnew->bevpoints) {
- MEM_freeN(blnew);
- break;
- }
- blnew->segbevcount = bl->segbevcount;
- blnew->seglen = bl->seglen;
- blnew->nr = 0;
- BLI_remlink(bev, bl);
- BLI_insertlinkbefore(bev, blnext, blnew); /* to make sure bevlijst is tuned with nurblist */
- bevp0 = bl->bevpoints;
- bevp1 = blnew->bevpoints;
- nr = bl->nr;
- while (nr--) {
- if (bevp0->dupe_tag == 0) {
- memcpy(bevp1, bevp0, sizeof(BevPoint));
- bevp1++;
- blnew->nr++;
- }
- bevp0++;
- }
- if (bl->bevpoints != NULL) {
- MEM_freeN(bl->bevpoints);
+
+ LISTBASE_FOREACH_MUTABLE (BevList *, bl, bev) {
+ if (bl->nr == 0 || bl->dupe_nr == 0) {
+ continue;
+ }
+
+ nr = bl->nr - bl->dupe_nr + 1; /* +1 because vectorbezier sets flag too */
+ blnew = MEM_mallocN(sizeof(BevList), "makeBevelList4");
+ memcpy(blnew, bl, sizeof(BevList));
+ blnew->bevpoints = MEM_calloc_arrayN(nr, sizeof(BevPoint), "makeBevelPoints4");
+ if (!blnew->bevpoints) {
+ MEM_freeN(blnew);
+ break;
+ }
+ blnew->segbevcount = bl->segbevcount;
+ blnew->seglen = bl->seglen;
+ blnew->nr = 0;
+ BLI_remlink(bev, bl);
+ BLI_insertlinkbefore(bev, bl->next, blnew); /* to make sure bevlist is tuned with nurblist */
+ bevp0 = bl->bevpoints;
+ bevp1 = blnew->bevpoints;
+ nr = bl->nr;
+ while (nr--) {
+ if (bevp0->dupe_tag == 0) {
+ memcpy(bevp1, bevp0, sizeof(BevPoint));
+ bevp1++;
+ blnew->nr++;
}
- MEM_freeN(bl);
- blnew->dupe_nr = 0;
+ bevp0++;
+ }
+ if (bl->bevpoints != NULL) {
+ MEM_freeN(bl->bevpoints);
}
- bl = blnext;
+ MEM_freeN(bl);
+ blnew->dupe_nr = 0;
}
/* STEP 3: POLYS COUNT AND AUTOHOLE */
- bl = bev->first;
poly = 0;
- while (bl) {
+ LISTBASE_FOREACH (BevList *, bl, bev) {
if (bl->nr && bl->poly >= 0) {
poly++;
bl->poly = poly;
bl->hole = 0;
}
- bl = bl->next;
}
/* find extreme left points, also test (turning) direction */
if (poly > 0) {
sd = sortdata = MEM_malloc_arrayN(poly, sizeof(struct BevelSort), "makeBevelList5");
- bl = bev->first;
- while (bl) {
+ LISTBASE_FOREACH (BevList *, bl, bev) {
if (bl->poly > 0) {
BevPoint *bevp;
@@ -3123,14 +3112,12 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
sd++;
}
-
- bl = bl->next;
}
qsort(sortdata, poly, sizeof(struct BevelSort), vergxcobev);
sd = sortdata + 1;
for (a = 1; a < poly; a++, sd++) {
- bl = sd->bl; /* is bl a hole? */
+ BevList *bl = sd->bl; /* is bl a hole? */
sd1 = sortdata + (a - 1);
for (b = a - 1; b >= 0; b--, sd1--) { /* all polys to the left */
if (sd1->bl->charidx == bl->charidx) { /* for text, only check matching char */
@@ -3147,7 +3134,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
sd = sortdata;
for (a = 0; a < poly; a++, sd++) {
if (sd->bl->hole == sd->dir) {
- bl = sd->bl;
+ BevList *bl = sd->bl;
bevp1 = bl->bevpoints;
bevp2 = bevp1 + (bl->nr - 1);
nr = bl->nr / 2;
@@ -3165,7 +3152,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
/* STEP 4: 2D-COSINES or 3D ORIENTATION */
if ((cu->flag & CU_3D) == 0) {
/* 2D Curves */
- for (bl = bev->first; bl; bl = bl->next) {
+ LISTBASE_FOREACH (BevList *, bl, bev) {
if (bl->nr < 2) {
BevPoint *bevp = bl->bevpoints;
unit_qt(bevp->quat);
@@ -3180,7 +3167,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
}
else {
/* 3D Curves */
- for (bl = bev->first; bl; bl = bl->next) {
+ LISTBASE_FOREACH (BevList *, bl, bev) {
if (bl->nr < 2) {
BevPoint *bevp = bl->bevpoints;
unit_qt(bevp->quat);
@@ -3674,7 +3661,7 @@ static bool tridiagonal_solve_with_limits(float *a,
* is affected by all other points of the curve segment, in practice the influence
* decreases exponentially with distance.
*
- * Note: this algorithm assumes that the handle horizontal size if always 1/3 of the
+ * Note: this algorithm assumes that the handle horizontal size is always 1/3 of the
* of the interval to the next point. This rule ensures linear interpolation of time.
*
* ^ height (co 1)
@@ -4314,12 +4301,8 @@ void BKE_nurb_handles_autocalc(Nurb *nu, uint8_t flag)
void BKE_nurbList_handles_autocalc(ListBase *editnurb, uint8_t flag)
{
- Nurb *nu;
-
- nu = editnurb->first;
- while (nu) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
BKE_nurb_handles_autocalc(nu, flag);
- nu = nu->next;
}
}
@@ -4331,13 +4314,11 @@ void BKE_nurbList_handles_set(ListBase *editnurb, const char code)
/* code==4: sets icu flag to become IPO_AUTO_HORIZ, horizontal extremes on auto-handles */
/* code==5: Set align, like 3 but no toggle */
/* code==6: Clear align, like 3 but no toggle */
- Nurb *nu;
BezTriple *bezt;
int a;
if (ELEM(code, HD_AUTO, HD_VECT)) {
- nu = editnurb->first;
- while (nu) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
a = nu->pntsu;
@@ -4364,7 +4345,6 @@ void BKE_nurbList_handles_set(ListBase *editnurb, const char code)
/* like BKE_nurb_handles_calc but moves selected */
nurb_handles_calc__align_selected(nu);
}
- nu = nu->next;
}
}
else {
@@ -4379,7 +4359,7 @@ void BKE_nurbList_handles_set(ListBase *editnurb, const char code)
}
else {
/* Toggle */
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
a = nu->pntsu;
@@ -4395,7 +4375,7 @@ void BKE_nurbList_handles_set(ListBase *editnurb, const char code)
}
h_new = (h_new == HD_FREE) ? HD_ALIGN : HD_FREE;
}
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
a = nu->pntsu;
@@ -4421,66 +4401,66 @@ void BKE_nurbList_handles_recalculate(ListBase *editnurb,
const bool calc_length,
const uint8_t flag)
{
- Nurb *nu;
BezTriple *bezt;
int a;
- for (nu = editnurb->first; nu; nu = nu->next) {
- if (nu->type == CU_BEZIER) {
- bool changed = false;
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
+ if (nu->type != CU_BEZIER) {
+ continue;
+ }
- for (a = nu->pntsu, bezt = nu->bezt; a--; bezt++) {
+ bool changed = false;
- const bool h1_select = (bezt->f1 & flag) == flag;
- const bool h2_select = (bezt->f3 & flag) == flag;
+ for (a = nu->pntsu, bezt = nu->bezt; a--; bezt++) {
- if (h1_select || h2_select) {
+ const bool h1_select = (bezt->f1 & flag) == flag;
+ const bool h2_select = (bezt->f3 & flag) == flag;
- float co1_back[3], co2_back[3];
+ if (h1_select || h2_select) {
- copy_v3_v3(co1_back, bezt->vec[0]);
- copy_v3_v3(co2_back, bezt->vec[2]);
+ float co1_back[3], co2_back[3];
- BKE_nurb_handle_calc_simple_auto(nu, bezt);
+ copy_v3_v3(co1_back, bezt->vec[0]);
+ copy_v3_v3(co2_back, bezt->vec[2]);
- if (h1_select) {
- if (!calc_length) {
- dist_ensure_v3_v3fl(bezt->vec[0], bezt->vec[1], len_v3v3(co1_back, bezt->vec[1]));
- }
- }
- else {
- copy_v3_v3(bezt->vec[0], co1_back);
- }
+ BKE_nurb_handle_calc_simple_auto(nu, bezt);
- if (h2_select) {
- if (!calc_length) {
- dist_ensure_v3_v3fl(bezt->vec[2], bezt->vec[1], len_v3v3(co2_back, bezt->vec[1]));
- }
- }
- else {
- copy_v3_v3(bezt->vec[2], co2_back);
+ if (h1_select) {
+ if (!calc_length) {
+ dist_ensure_v3_v3fl(bezt->vec[0], bezt->vec[1], len_v3v3(co1_back, bezt->vec[1]));
}
+ }
+ else {
+ copy_v3_v3(bezt->vec[0], co1_back);
+ }
- changed = true;
+ if (h2_select) {
+ if (!calc_length) {
+ dist_ensure_v3_v3fl(bezt->vec[2], bezt->vec[1], len_v3v3(co2_back, bezt->vec[1]));
+ }
+ }
+ else {
+ copy_v3_v3(bezt->vec[2], co2_back);
}
- }
- if (changed) {
- /* Recalculate the whole curve */
- BKE_nurb_handles_calc(nu);
+ changed = true;
}
}
+
+ if (changed) {
+ /* Recalculate the whole curve */
+ BKE_nurb_handles_calc(nu);
+ }
}
}
void BKE_nurbList_flag_set(ListBase *editnurb, uint8_t flag, bool set)
{
- Nurb *nu;
BezTriple *bezt;
BPoint *bp;
int a;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
a = nu->pntsu;
bezt = nu->bezt;
@@ -4516,7 +4496,7 @@ bool BKE_nurbList_flag_set_from_flag(ListBase *editnurb, uint8_t from_flag, uint
{
bool changed = false;
- for (Nurb *nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
for (int i = 0; i < nu->pntsu; i++) {
BezTriple *bezt = &nu->bezt[i];
@@ -4981,7 +4961,7 @@ bool BKE_nurb_type_convert(Nurb *nu,
}
}
else if (nu->type == CU_BEZIER) { /* Bezier */
- if (type == CU_POLY || type == CU_NURBS) {
+ if (ELEM(type, CU_POLY, CU_NURBS)) {
nr = use_handles ? (3 * nu->pntsu) : nu->pntsu;
nu->bp = MEM_calloc_arrayN(nr, sizeof(BPoint), "setsplinetype");
a = nu->pntsu;
@@ -5230,12 +5210,11 @@ bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3])
bool BKE_curve_center_median(Curve *cu, float cent[3])
{
ListBase *nurb_lb = BKE_curve_nurbs_get(cu);
- Nurb *nu;
int total = 0;
zero_v3(cent);
- for (nu = nurb_lb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nurb_lb) {
int i;
if (nu->type == CU_BEZIER) {
@@ -5283,12 +5262,11 @@ void BKE_curve_transform_ex(Curve *cu,
const bool do_props,
const float unit_scale)
{
- Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int i;
- for (nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
if (nu->type == CU_BEZIER) {
i = nu->pntsu;
for (bezt = nu->bezt; i--; bezt++) {
@@ -5313,12 +5291,11 @@ void BKE_curve_transform_ex(Curve *cu,
}
if (do_keys && cu->key) {
- KeyBlock *kb;
- for (kb = cu->key->block.first; kb; kb = kb->next) {
+ LISTBASE_FOREACH (KeyBlock *, kb, &cu->key->block) {
float *fp = kb->data;
int n = kb->totelem;
- for (nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
if (nu->type == CU_BEZIER) {
for (i = nu->pntsu; i && (n -= KEYELEM_ELEM_LEN_BEZTRIPLE) >= 0; i--) {
mul_m4_v3(mat, &fp[0]);
@@ -5474,9 +5451,8 @@ bool BKE_curve_material_index_validate(Curve *cu)
}
}
else {
- Nurb *nu;
const int max_idx = max_ii(0, cu->totcol - 1);
- for (nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
if (nu->mat_nr > max_idx) {
nu->mat_nr = 0;
is_valid = false;
@@ -5542,12 +5518,12 @@ void BKE_curve_material_remap(Curve *cu, const unsigned int *remap, unsigned int
void BKE_curve_smooth_flag_set(Curve *cu, const bool use_smooth)
{
if (use_smooth) {
- for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
nu->flag |= CU_SMOOTH;
}
}
else {
- for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
nu->flag &= ~CU_SMOOTH;
}
}
diff --git a/source/blender/blenkernel/intern/curve_decimate.c b/source/blender/blenkernel/intern/curve_decimate.c
index 68c0d2a3cec..e4647908b58 100644
--- a/source/blender/blenkernel/intern/curve_decimate.c
+++ b/source/blender/blenkernel/intern/curve_decimate.c
@@ -269,11 +269,11 @@ uint BKE_curve_decimate_bezt_array(BezTriple *bezt_array,
if (a == HD_VECT) { \
a = HD_FREE; \
} \
- else if (a == HD_AUTO || a == HD_AUTO_ANIM) { \
+ else if (ELEM(a, HD_AUTO, HD_AUTO_ANIM)) { \
a = HD_ALIGN; \
} \
/* opposite handle */ \
- if (b == HD_AUTO || b == HD_AUTO_ANIM) { \
+ if (ELEM(b, HD_AUTO, HD_AUTO_ANIM)) { \
b = HD_ALIGN; \
} \
} \
diff --git a/source/blender/blenkernel/intern/curve_deform.c b/source/blender/blenkernel/intern/curve_deform.c
index d4f197521a1..049bd46c434 100644
--- a/source/blender/blenkernel/intern/curve_deform.c
+++ b/source/blender/blenkernel/intern/curve_deform.c
@@ -222,10 +222,10 @@ static bool calc_curve_deform(
/* zero the axis which is not used,
* the big block of text above now applies to these 3 lines */
- quat_apply_track(
- quat,
- axis,
- (axis == 0 || axis == 2) ? 1 : 0); /* up flag is a dummy, set so no rotation is done */
+ quat_apply_track(quat,
+ axis,
+ (ELEM(axis, 0, 2)) ? 1 :
+ 0); /* up flag is a dummy, set so no rotation is done */
vec_apply_track(cent, axis);
cent[index] = 0.0f;
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index d762b1b0604..fdb3e246382 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -2509,7 +2509,7 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
return &data->layers[CustomData_get_layer_index(data, type)];
}
- if ((alloctype == CD_ASSIGN) || (alloctype == CD_REFERENCE)) {
+ if (ELEM(alloctype, CD_ASSIGN, CD_REFERENCE)) {
newlayerdata = layerdata;
}
else if (totelem > 0 && typeInfo->size > 0) {
@@ -2997,7 +2997,7 @@ void CustomData_free_elem(CustomData *data, int index, int count)
/**
* 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 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
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index bcb467e1230..f5257eb12ab 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -92,17 +92,13 @@ void BKE_displist_free(ListBase *lb)
DispList *BKE_displist_find_or_create(ListBase *lb, int type)
{
- DispList *dl;
-
- dl = lb->first;
- while (dl) {
+ LISTBASE_FOREACH (DispList *, dl, lb) {
if (dl->type == type) {
return dl;
}
- dl = dl->next;
}
- dl = MEM_callocN(sizeof(DispList), "find_disp");
+ DispList *dl = MEM_callocN(sizeof(DispList), "find_disp");
dl->type = type;
BLI_addtail(lb, dl);
@@ -111,14 +107,10 @@ DispList *BKE_displist_find_or_create(ListBase *lb, int type)
DispList *BKE_displist_find(ListBase *lb, int type)
{
- DispList *dl;
-
- dl = lb->first;
- while (dl) {
+ LISTBASE_FOREACH (DispList *, dl, lb) {
if (dl->type == type) {
return dl;
}
- dl = dl->next;
}
return NULL;
@@ -126,9 +118,7 @@ DispList *BKE_displist_find(ListBase *lb, int type)
bool BKE_displist_has_faces(ListBase *lb)
{
- DispList *dl;
-
- for (dl = lb->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (DispList *, dl, lb) {
if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) {
return true;
}
@@ -139,13 +129,10 @@ bool BKE_displist_has_faces(ListBase *lb)
void BKE_displist_copy(ListBase *lbn, ListBase *lb)
{
- DispList *dln, *dl;
-
BKE_displist_free(lbn);
- dl = lb->first;
- while (dl) {
- dln = MEM_dupallocN(dl);
+ LISTBASE_FOREACH (const DispList *, dl, lb) {
+ DispList *dln = MEM_dupallocN(dl);
BLI_addtail(lbn, dln);
dln->verts = MEM_dupallocN(dl->verts);
dln->nors = MEM_dupallocN(dl->nors);
@@ -154,22 +141,17 @@ void BKE_displist_copy(ListBase *lbn, ListBase *lb)
if (dl->bevel_split) {
dln->bevel_split = MEM_dupallocN(dl->bevel_split);
}
-
- dl = dl->next;
}
}
void BKE_displist_normals_add(ListBase *lb)
{
- DispList *dl = NULL;
float *vdata, *ndata, nor[3];
float *v1, *v2, *v3, *v4;
float *n1, *n2, *n3, *n4;
int a, b, p1, p2, p3, p4;
- dl = lb->first;
-
- while (dl) {
+ LISTBASE_FOREACH (DispList *, dl, lb) {
if (dl->type == DL_INDEX3) {
if (dl->nors == NULL) {
dl->nors = MEM_callocN(sizeof(float[3]), "dlnors");
@@ -230,15 +212,12 @@ void BKE_displist_normals_add(ListBase *lb)
}
}
}
- dl = dl->next;
}
}
void BKE_displist_count(ListBase *lb, int *totvert, int *totface, int *tottri)
{
- DispList *dl;
-
- for (dl = lb->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (DispList *, dl, lb) {
int vert_tot = 0;
int face_tot = 0;
int tri_tot = 0;
@@ -318,7 +297,6 @@ static void curve_to_displist(Curve *cu,
ListBase *dispbase,
const bool for_render)
{
- Nurb *nu;
DispList *dl;
BezTriple *bezt, *prevbezt;
BPoint *bp;
@@ -326,154 +304,154 @@ static void curve_to_displist(Curve *cu,
int a, len, resolu;
const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
- nu = nubase->first;
- while (nu) {
- if (nu->hide == 0 || editmode == false) {
- if (for_render && cu->resolu_ren != 0) {
- resolu = cu->resolu_ren;
- }
- else {
- resolu = nu->resolu;
- }
-
- if (!BKE_nurb_check_valid_u(nu)) {
- /* pass */
- }
- else if (nu->type == CU_BEZIER) {
- /* count */
- len = 0;
- a = nu->pntsu - 1;
- if (nu->flagu & CU_NURB_CYCLIC) {
- a++;
- }
-
- prevbezt = nu->bezt;
- bezt = prevbezt + 1;
- while (a--) {
- if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) {
- bezt = nu->bezt;
- }
+ LISTBASE_FOREACH (Nurb *, nu, nubase) {
+ if (nu->hide != 0 && editmode) {
+ continue;
+ }
- if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
- len++;
- }
- else {
- len += resolu;
- }
+ if (for_render && cu->resolu_ren != 0) {
+ resolu = cu->resolu_ren;
+ }
+ else {
+ resolu = nu->resolu;
+ }
- if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) {
- len++;
- }
+ if (!BKE_nurb_check_valid_u(nu)) {
+ /* pass */
+ }
+ else if (nu->type == CU_BEZIER) {
+ /* count */
+ len = 0;
+ a = nu->pntsu - 1;
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ a++;
+ }
- prevbezt = bezt;
- bezt++;
+ prevbezt = nu->bezt;
+ bezt = prevbezt + 1;
+ while (a--) {
+ if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) {
+ bezt = nu->bezt;
}
- dl = MEM_callocN(sizeof(DispList), "makeDispListbez");
- /* len+1 because of 'forward_diff_bezier' function */
- dl->verts = MEM_mallocN((len + 1) * sizeof(float[3]), "dlverts");
- BLI_addtail(dispbase, dl);
- dl->parts = 1;
- dl->nr = len;
- dl->col = nu->mat_nr;
- dl->charidx = nu->charidx;
-
- data = dl->verts;
-
- /* check that (len != 2) so we don't immediately loop back on ourselves */
- if (nu->flagu & CU_NURB_CYCLIC && (dl->nr != 2)) {
- dl->type = DL_POLY;
- a = nu->pntsu;
+ if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
+ len++;
}
else {
- dl->type = DL_SEGM;
- a = nu->pntsu - 1;
+ len += resolu;
}
- prevbezt = nu->bezt;
- bezt = prevbezt + 1;
+ if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) {
+ len++;
+ }
- while (a--) {
- if (a == 0 && dl->type == DL_POLY) {
- bezt = nu->bezt;
- }
+ prevbezt = bezt;
+ bezt++;
+ }
- if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
- copy_v3_v3(data, prevbezt->vec[1]);
- data += 3;
- }
- else {
- int j;
- for (j = 0; j < 3; j++) {
- BKE_curve_forward_diff_bezier(prevbezt->vec[1][j],
- prevbezt->vec[2][j],
- bezt->vec[0][j],
- bezt->vec[1][j],
- data + j,
- resolu,
- sizeof(float[3]));
- }
+ dl = MEM_callocN(sizeof(DispList), "makeDispListbez");
+ /* len+1 because of 'forward_diff_bezier' function */
+ dl->verts = MEM_mallocN((len + 1) * sizeof(float[3]), "dlverts");
+ BLI_addtail(dispbase, dl);
+ dl->parts = 1;
+ dl->nr = len;
+ dl->col = nu->mat_nr;
+ dl->charidx = nu->charidx;
+
+ data = dl->verts;
+
+ /* check that (len != 2) so we don't immediately loop back on ourselves */
+ if (nu->flagu & CU_NURB_CYCLIC && (dl->nr != 2)) {
+ dl->type = DL_POLY;
+ a = nu->pntsu;
+ }
+ else {
+ dl->type = DL_SEGM;
+ a = nu->pntsu - 1;
+ }
- data += 3 * resolu;
- }
+ prevbezt = nu->bezt;
+ bezt = prevbezt + 1;
+
+ while (a--) {
+ if (a == 0 && dl->type == DL_POLY) {
+ bezt = nu->bezt;
+ }
- if (a == 0 && dl->type == DL_SEGM) {
- copy_v3_v3(data, bezt->vec[1]);
+ if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
+ copy_v3_v3(data, prevbezt->vec[1]);
+ data += 3;
+ }
+ else {
+ int j;
+ for (j = 0; j < 3; j++) {
+ BKE_curve_forward_diff_bezier(prevbezt->vec[1][j],
+ prevbezt->vec[2][j],
+ bezt->vec[0][j],
+ bezt->vec[1][j],
+ data + j,
+ resolu,
+ sizeof(float[3]));
}
- prevbezt = bezt;
- bezt++;
+ data += 3 * resolu;
}
+
+ if (a == 0 && dl->type == DL_SEGM) {
+ copy_v3_v3(data, bezt->vec[1]);
+ }
+
+ prevbezt = bezt;
+ bezt++;
}
- else if (nu->type == CU_NURBS) {
- len = (resolu * SEGMENTSU(nu));
+ }
+ else if (nu->type == CU_NURBS) {
+ len = (resolu * SEGMENTSU(nu));
- dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
- dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
- BLI_addtail(dispbase, dl);
- dl->parts = 1;
+ dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
+ dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
+ BLI_addtail(dispbase, dl);
+ dl->parts = 1;
- dl->nr = len;
- dl->col = nu->mat_nr;
- dl->charidx = nu->charidx;
+ dl->nr = len;
+ dl->col = nu->mat_nr;
+ dl->charidx = nu->charidx;
- data = dl->verts;
- if (nu->flagu & CU_NURB_CYCLIC) {
- dl->type = DL_POLY;
- }
- else {
- dl->type = DL_SEGM;
- }
- BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, sizeof(float[3]));
+ data = dl->verts;
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ dl->type = DL_POLY;
+ }
+ else {
+ dl->type = DL_SEGM;
+ }
+ BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, sizeof(float[3]));
+ }
+ else if (nu->type == CU_POLY) {
+ len = nu->pntsu;
+ dl = MEM_callocN(sizeof(DispList), "makeDispListpoly");
+ dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
+ BLI_addtail(dispbase, dl);
+ dl->parts = 1;
+ dl->nr = len;
+ dl->col = nu->mat_nr;
+ dl->charidx = nu->charidx;
+
+ data = dl->verts;
+ if ((nu->flagu & CU_NURB_CYCLIC) && (dl->nr != 2)) {
+ dl->type = DL_POLY;
+ }
+ else {
+ dl->type = DL_SEGM;
}
- else if (nu->type == CU_POLY) {
- len = nu->pntsu;
- dl = MEM_callocN(sizeof(DispList), "makeDispListpoly");
- dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
- BLI_addtail(dispbase, dl);
- dl->parts = 1;
- dl->nr = len;
- dl->col = nu->mat_nr;
- dl->charidx = nu->charidx;
-
- data = dl->verts;
- if ((nu->flagu & CU_NURB_CYCLIC) && (dl->nr != 2)) {
- dl->type = DL_POLY;
- }
- else {
- dl->type = DL_SEGM;
- }
- a = len;
- bp = nu->bp;
- while (a--) {
- copy_v3_v3(data, bp->vec);
- bp++;
- data += 3;
- }
+ a = len;
+ bp = nu->bp;
+ while (a--) {
+ copy_v3_v3(data, bp->vec);
+ bp++;
+ data += 3;
}
}
- nu = nu->next;
}
}
@@ -491,7 +469,7 @@ void BKE_displist_fill(ListBase *dispbase,
ScanFillVert *sf_vert, *sf_vert_new, *sf_vert_last;
ScanFillFace *sf_tri;
MemArena *sf_arena;
- DispList *dlnew = NULL, *dl;
+ DispList *dlnew = NULL;
float *f1;
int colnr = 0, charidx = 0, cont = 1, tot, a, *index, nextcol = 0;
int totvert;
@@ -515,8 +493,7 @@ void BKE_displist_fill(ListBase *dispbase,
BLI_scanfill_begin_arena(&sf_ctx, sf_arena);
- dl = dispbase->first;
- while (dl) {
+ LISTBASE_FOREACH (DispList *, dl, dispbase) {
if (dl->type == DL_POLY) {
if (charidx < dl->charidx) {
cont = 1;
@@ -558,7 +535,6 @@ void BKE_displist_fill(ListBase *dispbase,
}
dl_flag_accum |= dl->flag;
}
- dl = dl->next;
}
/* XXX (obedit && obedit->actcol) ? (obedit->actcol - 1) : 0)) { */
@@ -627,19 +603,17 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
{
const float z_up[3] = {0.0f, 0.0f, -1.0f};
ListBase front, back;
- DispList *dl, *dlnew;
float *fp, *fp1;
int a, dpoly;
BLI_listbase_clear(&front);
BLI_listbase_clear(&back);
- dl = dispbase->first;
- while (dl) {
+ LISTBASE_FOREACH (DispList *, dl, dispbase) {
if (dl->type == DL_SURF) {
if ((dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) {
if ((cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE)) {
- dlnew = MEM_callocN(sizeof(DispList), "filldisp");
+ DispList *dlnew = MEM_callocN(sizeof(DispList), "filldisp");
BLI_addtail(&front, dlnew);
dlnew->verts = fp1 = MEM_mallocN(sizeof(float[3]) * dl->parts, "filldisp1");
dlnew->nr = dl->parts;
@@ -660,7 +634,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
}
}
if ((cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE)) {
- dlnew = MEM_callocN(sizeof(DispList), "filldisp");
+ DispList *dlnew = MEM_callocN(sizeof(DispList), "filldisp");
BLI_addtail(&back, dlnew);
dlnew->verts = fp1 = MEM_mallocN(sizeof(float[3]) * dl->parts, "filldisp1");
dlnew->nr = dl->parts;
@@ -682,7 +656,6 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
}
}
}
- dl = dl->next;
}
BKE_displist_fill(&front, dispbase, z_up, true);
@@ -939,18 +912,17 @@ static bool curve_calc_modifiers_pre(
static float (*displist_vert_coords_alloc(ListBase *dispbase, int *r_vert_len))[3]
{
- DispList *dl;
float(*allverts)[3], *fp;
*r_vert_len = 0;
- for (dl = dispbase->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (DispList *, dl, dispbase) {
*r_vert_len += (dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr;
}
allverts = MEM_mallocN(sizeof(float[3]) * (*r_vert_len), "displist_vert_coords_alloc allverts");
fp = (float *)allverts;
- for (dl = dispbase->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (DispList *, dl, dispbase) {
int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr);
memcpy(fp, dl->verts, sizeof(float) * offs);
fp += offs;
@@ -961,11 +933,10 @@ static float (*displist_vert_coords_alloc(ListBase *dispbase, int *r_vert_len))[
static void displist_vert_coords_apply(ListBase *dispbase, float (*allverts)[3])
{
- DispList *dl;
const float *fp;
fp = (float *)allverts;
- for (dl = dispbase->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (DispList *, dl, dispbase) {
int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr);
memcpy(dl->verts, fp, sizeof(float) * offs);
fp += offs;
@@ -1218,7 +1189,6 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
const bool for_orco)
{
ListBase nubase = {NULL, NULL};
- Nurb *nu;
Curve *cu = ob->data;
DispList *dl;
float *data;
@@ -1236,76 +1206,78 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
force_mesh_conversion = curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render);
}
- for (nu = nubase.first; nu; nu = nu->next) {
- if ((for_render || nu->hide == 0) && BKE_nurb_check_valid_uv(nu)) {
- int resolu = nu->resolu, resolv = nu->resolv;
+ LISTBASE_FOREACH (Nurb *, nu, &nubase) {
+ if (!(for_render || nu->hide == 0) || !BKE_nurb_check_valid_uv(nu)) {
+ continue;
+ }
+
+ int resolu = nu->resolu, resolv = nu->resolv;
- if (for_render) {
- if (cu->resolu_ren) {
- resolu = cu->resolu_ren;
- }
- if (cu->resolv_ren) {
- resolv = cu->resolv_ren;
- }
+ if (for_render) {
+ if (cu->resolu_ren) {
+ resolu = cu->resolu_ren;
+ }
+ if (cu->resolv_ren) {
+ resolv = cu->resolv_ren;
}
+ }
- if (nu->pntsv == 1) {
- len = SEGMENTSU(nu) * resolu;
+ if (nu->pntsv == 1) {
+ len = SEGMENTSU(nu) * resolu;
- dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
- dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
+ dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
+ dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
- BLI_addtail(dispbase, dl);
- dl->parts = 1;
- dl->nr = len;
- dl->col = nu->mat_nr;
- dl->charidx = nu->charidx;
+ BLI_addtail(dispbase, dl);
+ dl->parts = 1;
+ dl->nr = len;
+ dl->col = nu->mat_nr;
+ dl->charidx = nu->charidx;
- /* dl->rt will be used as flag for render face and */
- /* CU_2D conflicts with R_NOPUNOFLIP */
- dl->rt = nu->flag & ~CU_2D;
+ /* dl->rt will be used as flag for render face and */
+ /* CU_2D conflicts with R_NOPUNOFLIP */
+ dl->rt = nu->flag & ~CU_2D;
- data = dl->verts;
- if (nu->flagu & CU_NURB_CYCLIC) {
- dl->type = DL_POLY;
- }
- else {
- dl->type = DL_SEGM;
- }
-
- BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, sizeof(float[3]));
+ data = dl->verts;
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ dl->type = DL_POLY;
}
else {
- len = (nu->pntsu * resolu) * (nu->pntsv * resolv);
+ dl->type = DL_SEGM;
+ }
- dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
- dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
- BLI_addtail(dispbase, dl);
+ BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, sizeof(float[3]));
+ }
+ else {
+ len = (nu->pntsu * resolu) * (nu->pntsv * resolv);
- dl->col = nu->mat_nr;
- dl->charidx = nu->charidx;
+ dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
+ dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
+ BLI_addtail(dispbase, dl);
- /* dl->rt will be used as flag for render face and */
- /* CU_2D conflicts with R_NOPUNOFLIP */
- dl->rt = nu->flag & ~CU_2D;
+ dl->col = nu->mat_nr;
+ dl->charidx = nu->charidx;
- data = dl->verts;
- dl->type = DL_SURF;
+ /* dl->rt will be used as flag for render face and */
+ /* CU_2D conflicts with R_NOPUNOFLIP */
+ dl->rt = nu->flag & ~CU_2D;
- dl->parts = (nu->pntsu * resolu); /* in reverse, because makeNurbfaces works that way */
- dl->nr = (nu->pntsv * resolv);
- if (nu->flagv & CU_NURB_CYCLIC) {
- dl->flag |= DL_CYCL_U; /* reverse too! */
- }
- if (nu->flagu & CU_NURB_CYCLIC) {
- dl->flag |= DL_CYCL_V;
- }
+ data = dl->verts;
+ dl->type = DL_SURF;
- BKE_nurb_makeFaces(nu, data, 0, resolu, resolv);
-
- /* gl array drawing: using indices */
- displist_surf_indices(dl);
+ dl->parts = (nu->pntsu * resolu); /* in reverse, because makeNurbfaces works that way */
+ dl->nr = (nu->pntsv * resolv);
+ if (nu->flagv & CU_NURB_CYCLIC) {
+ dl->flag |= DL_CYCL_U; /* reverse too! */
+ }
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ dl->flag |= DL_CYCL_V;
}
+
+ BKE_nurb_makeFaces(nu, data, 0, resolu, resolv);
+
+ /* gl array drawing: using indices */
+ displist_surf_indices(dl);
}
}
@@ -1851,12 +1823,11 @@ void BKE_displist_make_curveTypes_forRender(Depsgraph *depsgraph,
void BKE_displist_minmax(ListBase *dispbase, float min[3], float max[3])
{
- DispList *dl;
const float *vert;
int a, tot = 0;
int doit = 0;
- for (dl = dispbase->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (DispList *, dl, dispbase) {
tot = (dl->type == DL_INDEX3) ? dl->nr : dl->nr * dl->parts;
vert = dl->verts;
for (a = 0; a < tot; a++, vert += 3) {
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index fef4b49de7e..b56a15b3d45 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -76,9 +76,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-/* to read material/texture color */
-#include "RE_render_ext.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#include "atomic_ops.h"
@@ -123,7 +121,7 @@ static int neighStraightY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
/* paint effect default movement per frame in global units */
#define EFF_MOVEMENT_PER_FRAME 0.05f
/* initial wave time factor */
-#define WAVE_TIME_FAC (1.0f / 24.f)
+#define WAVE_TIME_FAC (1.0f / 24.0f)
#define CANVAS_REL_SIZE 5.0f
/* drying limits */
#define MIN_WETNESS 0.001f
@@ -762,7 +760,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
sub_v3_v3v3(dim, grid->grid_bounds.max, grid->grid_bounds.min);
copy_v3_v3(td, dim);
copy_v3_v3(bData->dim, dim);
- min_dim = max_fff(td[0], td[1], td[2]) / 1000.f;
+ min_dim = max_fff(td[0], td[1], td[2]) / 1000.0f;
/* deactivate zero axises */
for (i = 0; i < 3; i++) {
@@ -2700,7 +2698,7 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
const int final_tri_index = tempPoints[final_index].tri_index;
/* If found pixel still lies on wrong face ( mesh has smaller than pixel sized faces) */
- if (final_tri_index != target_tri && final_tri_index != -1) {
+ if (!ELEM(final_tri_index, target_tri, -1)) {
/* Check if it's close enough to likely touch the intended triangle. Any triangle
* becomes thinner than a pixel at its vertices, so robustness requires some margin. */
const float final_pt[2] = {((final_index % w) + 0.5f) / w, ((final_index / w) + 0.5f) / h};
@@ -3034,7 +3032,7 @@ int dynamicPaint_createUVSurface(Scene *scene,
n_pos++;
}
}
- else if (n_target == ON_MESH_EDGE || n_target == OUT_OF_TEXTURE) {
+ else if (ELEM(n_target, ON_MESH_EDGE, OUT_OF_TEXTURE)) {
ed->flags[final_index[index]] |= ADJ_ON_MESH_EDGE;
}
}
@@ -3736,7 +3734,7 @@ static bool meshBrush_boundsIntersect(Bounds3D *b1,
if (brush->collision == MOD_DPAINT_COL_VOLUME) {
return boundsIntersect(b1, b2);
}
- if (brush->collision == MOD_DPAINT_COL_DIST || brush->collision == MOD_DPAINT_COL_VOLDIST) {
+ if (ELEM(brush->collision, MOD_DPAINT_COL_DIST, MOD_DPAINT_COL_VOLDIST)) {
return boundsIntersectDist(b1, b2, brush_radius);
}
return true;
@@ -4710,8 +4708,7 @@ static void dynamic_paint_paint_single_point_cb_ex(void *__restrict userdata,
}
/* Smooth range or color ramp */
- if (brush->proximity_falloff == MOD_DPAINT_PRFALL_SMOOTH ||
- brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP) {
+ if (ELEM(brush->proximity_falloff, MOD_DPAINT_PRFALL_SMOOTH, MOD_DPAINT_PRFALL_RAMP)) {
strength = 1.0f - distance / brush_radius;
CLAMP(strength, 0.0f, 1.0f);
}
@@ -5116,7 +5113,7 @@ static void dynamic_paint_prepare_effect_cb(void *__restrict userdata,
madd_v3_v3fl(forc,
scene->physics_settings.gravity,
surface->effector_weights->global_gravity * surface->effector_weights->weight[0] /
- 10.f);
+ 10.0f);
}
/* add surface point velocity and acceleration if enabled */
diff --git a/source/blender/blenkernel/intern/editmesh_tangent.c b/source/blender/blenkernel/intern/editmesh_tangent.c
index b3f6b543daf..9656c20f0be 100644
--- a/source/blender/blenkernel/intern/editmesh_tangent.c
+++ b/source/blender/blenkernel/intern/editmesh_tangent.c
@@ -35,6 +35,7 @@
/* interface */
#include "mikktspace.h"
+/* -------------------------------------------------------------------- */
/** \name Tangent Space Calculation
* \{ */
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 967b961dbea..13e9bb1bf24 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -68,8 +68,7 @@
#include "DEG_depsgraph_physics.h"
#include "DEG_depsgraph_query.h"
-#include "RE_render_ext.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
EffectorWeights *BKE_effector_add_weights(Collection *collection)
{
@@ -699,8 +698,8 @@ int get_effector_data(EffectorCache *eff,
copy_v3_v3(efd->loc, state.co);
/* rather than use the velocity use rotated x-axis (defaults to velocity) */
- efd->nor[0] = 1.f;
- efd->nor[1] = efd->nor[2] = 0.f;
+ efd->nor[0] = 1.0f;
+ efd->nor[1] = efd->nor[2] = 0.0f;
mul_qt_v3(state.rot, efd->nor);
if (real_velocity) {
@@ -1009,9 +1008,12 @@ static void do_physical_effector(EffectorCache *eff,
else {
add_v3_v3v3(temp, efd->vec_to_point2, efd->nor2);
}
- force[0] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[0], temp[1], temp[2], 2, 0, 2);
- force[1] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[1], temp[2], temp[0], 2, 0, 2);
- force[2] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[2], temp[0], temp[1], 2, 0, 2);
+ force[0] = -1.0f + 2.0f * BLI_noise_generic_turbulence(
+ pd->f_size, temp[0], temp[1], temp[2], 2, 0, 2);
+ force[1] = -1.0f + 2.0f * BLI_noise_generic_turbulence(
+ pd->f_size, temp[1], temp[2], temp[0], 2, 0, 2);
+ force[2] = -1.0f + 2.0f * BLI_noise_generic_turbulence(
+ pd->f_size, temp[2], temp[0], temp[1], 2, 0, 2);
mul_v3_fl(force, strength * efd->falloff);
break;
case PFIELD_DRAG:
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 003e926e0ae..e6d3696b198 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -855,7 +855,7 @@ void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
}
/* The active keyframe should always be selected. */
- BLI_assert(BEZT_ISSEL_ANY(active_bezt));
+ BLI_assert(BEZT_ISSEL_ANY(active_bezt) || !"active keyframe must be selected");
fcu->active_keyframe_index = (int)offset;
}
@@ -1076,6 +1076,84 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample
fcu->totvert = end - start + 1;
}
+static void init_unbaked_bezt_data(BezTriple *bezt)
+{
+ bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
+ /* Baked FCurve points always use linear interpolation. */
+ bezt->ipo = BEZT_IPO_LIN;
+ bezt->h1 = bezt->h2 = HD_AUTO_ANIM;
+}
+
+/* Convert baked/sampled fcurves into bezt/regular fcurves. */
+void fcurve_samples_to_keyframes(FCurve *fcu, const int start, const int end)
+{
+
+ /* Sanity checks. */
+ /* TODO: make these tests report errors using reports not CLOG's (Joshua Leung 2009). */
+ if (fcu == NULL) {
+ CLOG_ERROR(&LOG, "No F-Curve with F-Curve Modifiers to Un-Bake");
+ return;
+ }
+
+ if (start > end) {
+ CLOG_ERROR(&LOG, "Error: Frame range to unbake F-Curve is inappropriate");
+ return;
+ }
+
+ if (fcu->fpt == NULL) {
+ /* No data to unbake. */
+ CLOG_ERROR(&LOG, "Error: Curve containts no baked keyframes");
+ return;
+ }
+
+ /* Free any existing sample/keyframe data on the curve. */
+ if (fcu->bezt) {
+ MEM_freeN(fcu->bezt);
+ }
+
+ BezTriple *bezt;
+ FPoint *fpt = fcu->fpt;
+ int keyframes_to_insert = end - start;
+ int sample_points = fcu->totvert;
+
+ bezt = fcu->bezt = MEM_callocN(sizeof(*fcu->bezt) * (size_t)keyframes_to_insert, __func__);
+ fcu->totvert = keyframes_to_insert;
+
+ /* Get first sample point to 'copy' as keyframe. */
+ for (; sample_points && (fpt->vec[0] < start); fpt++, sample_points--) {
+ /* pass */
+ }
+
+ /* Current position in the timeline. */
+ int cur_pos = start;
+
+ /* Add leading dummy flat points if needed. */
+ for (; keyframes_to_insert && (fpt->vec[0] > start); cur_pos++, bezt++, keyframes_to_insert--) {
+ init_unbaked_bezt_data(bezt);
+ bezt->vec[1][0] = (float)cur_pos;
+ bezt->vec[1][1] = fpt->vec[1];
+ }
+
+ /* Copy actual sample points. */
+ for (; keyframes_to_insert && sample_points;
+ cur_pos++, bezt++, keyframes_to_insert--, fpt++, sample_points--) {
+ init_unbaked_bezt_data(bezt);
+ copy_v2_v2(bezt->vec[1], fpt->vec);
+ }
+
+ /* Add trailing dummy flat points if needed. */
+ for (fpt--; keyframes_to_insert; cur_pos++, bezt++, keyframes_to_insert--) {
+ init_unbaked_bezt_data(bezt);
+ bezt->vec[1][0] = (float)cur_pos;
+ bezt->vec[1][1] = fpt->vec[1];
+ }
+
+ MEM_SAFE_FREE(fcu->fpt);
+
+ /* Not strictly needed since we use linear interpolation, but better be consistent here. */
+ calchandles_fcurve(fcu);
+}
+
/* ***************************** F-Curve Sanity ********************************* */
/* The functions here are used in various parts of Blender, usually after some editing
* of keyframe data has occurred. They ensure that keyframe data is properly ordered and
@@ -1194,7 +1272,7 @@ void calchandles_fcurve_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
/* For automatic ease in and out. */
if (BEZT_IS_AUTOH(bezt) && !cycle) {
/* Only do this on first or last beztriple. */
- if ((a == 0) || (a == fcu->totvert - 1)) {
+ if (ELEM(a, 0, fcu->totvert - 1)) {
/* Set both handles to have same horizontal value as keyframe. */
if (fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) {
bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1];
@@ -1658,7 +1736,7 @@ static float fcurve_eval_keyframes_extrapolate(
return endpoint_bezt->vec[1][1] - (fac * dx);
}
- /* Use the gradient of the second handle (later) of neighbour to calculate the gradient and thus
+ /* Use the gradient of the second handle (later) of neighbor to calculate the gradient and thus
* the value of the curve at evaluation time. */
int handle = direction_to_neighbor > 0 ? 0 : 2;
float dx = endpoint_bezt->vec[1][0] - evaltime;
@@ -1934,7 +2012,7 @@ static float fcurve_eval_keyframes_interpolate(FCurve *fcu, BezTriple *bezts, fl
return 0.0f;
}
-/* Calculate F-Curve value for 'evaltime' using BezTriple keyframes. */
+/* Calculate F-Curve value for 'evaltime' using #BezTriple keyframes. */
static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime)
{
if (evaltime <= bezts->vec[1][0]) {
@@ -1949,7 +2027,7 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
return fcurve_eval_keyframes_interpolate(fcu, bezts, evaltime);
}
-/* Calculate F-Curve value for 'evaltime' using FPoint samples. */
+/* Calculate F-Curve value for 'evaltime' using #FPoint samples. */
static float fcurve_eval_samples(FCurve *fcu, FPoint *fpts, float evaltime)
{
FPoint *prevfpt, *lastfpt, *fpt;
diff --git a/source/blender/blenkernel/intern/fcurve_test.cc b/source/blender/blenkernel/intern/fcurve_test.cc
index a230c8f2e96..fb6ce02d146 100644
--- a/source/blender/blenkernel/intern/fcurve_test.cc
+++ b/source/blender/blenkernel/intern/fcurve_test.cc
@@ -22,6 +22,7 @@
#include "BKE_fcurve.h"
#include "ED_keyframing.h"
+#include "ED_types.h" /* For SELECT. */
#include "DNA_anim_types.h"
@@ -290,22 +291,43 @@ TEST(fcurve_active_keyframe, ActiveKeyframe)
EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), 2);
/* Check clearing the index. */
- BKE_fcurve_active_keyframe_set(fcu, NULL);
+ BKE_fcurve_active_keyframe_set(fcu, nullptr);
EXPECT_EQ(fcu->active_keyframe_index, FCURVE_ACTIVE_KEYFRAME_NONE);
EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), FCURVE_ACTIVE_KEYFRAME_NONE);
/* Check a "normal" action. */
+ fcu->bezt[2].f2 |= SELECT;
BKE_fcurve_active_keyframe_set(fcu, &fcu->bezt[2]);
EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), 2);
- /* Check out of bounds. */
+ /* Check setting an unselected keyframe as active. */
+ fcu->bezt[2].f1 = fcu->bezt[2].f2 = fcu->bezt[2].f3 = 0;
+ EXPECT_BLI_ASSERT(BKE_fcurve_active_keyframe_set(fcu, &fcu->bezt[2]),
+ "active keyframe must be selected");
+ EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), FCURVE_ACTIVE_KEYFRAME_NONE);
+
+ /* Check out of bounds (lower). */
BKE_fcurve_active_keyframe_set(fcu, fcu->bezt - 20);
+ EXPECT_EQ(fcu->active_keyframe_index, FCURVE_ACTIVE_KEYFRAME_NONE)
+ << "Setting out-of-bounds value via the API should result in valid active_keyframe_index";
EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), FCURVE_ACTIVE_KEYFRAME_NONE);
- /* Check out of bounds again. */
+ fcu->active_keyframe_index = -20;
+ EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), FCURVE_ACTIVE_KEYFRAME_NONE)
+ << "Even with active_keyframe_index out of bounds, getting it via the API should produce a "
+ "valid value";
+
+ /* Check out of bounds (higher). */
BKE_fcurve_active_keyframe_set(fcu, fcu->bezt + 4);
+ EXPECT_EQ(fcu->active_keyframe_index, FCURVE_ACTIVE_KEYFRAME_NONE)
+ << "Setting out-of-bounds value via the API should result in valid active_keyframe_index";
EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), FCURVE_ACTIVE_KEYFRAME_NONE);
+ fcu->active_keyframe_index = fcu->totvert;
+ EXPECT_EQ(BKE_fcurve_active_keyframe_index(fcu), FCURVE_ACTIVE_KEYFRAME_NONE)
+ << "Even with active_keyframe_index out of bounds, getting it via the API should produce a "
+ "valid value";
+
BKE_fcurve_free(fcu);
}
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index b9f201d8ada..30bf84ae6e1 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -80,7 +80,7 @@
# include "DEG_depsgraph.h"
# include "DEG_depsgraph_query.h"
-# include "RE_shader_ext.h"
+# include "RE_texture.h"
# include "CLG_log.h"
@@ -343,32 +343,37 @@ void BKE_fluid_cache_free(FluidDomainSettings *fds, Object *ob, int cache_map)
flags &= ~(FLUID_DOMAIN_BAKING_DATA | FLUID_DOMAIN_BAKED_DATA | FLUID_DOMAIN_OUTDATED_DATA);
BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_CONFIG, NULL);
BLI_path_abs(temp_dir, relbase);
- BLI_delete(temp_dir, true, true); /* BLI_exists(filepath) is implicit */
-
+ if (BLI_exists(temp_dir)) {
+ BLI_delete(temp_dir, true, true);
+ }
BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_DATA, NULL);
BLI_path_abs(temp_dir, relbase);
- BLI_delete(temp_dir, true, true); /* BLI_exists(filepath) is implicit */
-
+ if (BLI_exists(temp_dir)) {
+ BLI_delete(temp_dir, true, true);
+ }
BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_SCRIPT, NULL);
BLI_path_abs(temp_dir, relbase);
- BLI_delete(temp_dir, true, true); /* BLI_exists(filepath) is implicit */
-
+ if (BLI_exists(temp_dir)) {
+ BLI_delete(temp_dir, true, true);
+ }
fds->cache_frame_pause_data = 0;
}
if (cache_map & FLUID_DOMAIN_OUTDATED_NOISE) {
flags &= ~(FLUID_DOMAIN_BAKING_NOISE | FLUID_DOMAIN_BAKED_NOISE | FLUID_DOMAIN_OUTDATED_NOISE);
BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_NOISE, NULL);
BLI_path_abs(temp_dir, relbase);
- BLI_delete(temp_dir, true, true); /* BLI_exists(filepath) is implicit */
-
+ if (BLI_exists(temp_dir)) {
+ BLI_delete(temp_dir, true, true);
+ }
fds->cache_frame_pause_noise = 0;
}
if (cache_map & FLUID_DOMAIN_OUTDATED_MESH) {
flags &= ~(FLUID_DOMAIN_BAKING_MESH | FLUID_DOMAIN_BAKED_MESH | FLUID_DOMAIN_OUTDATED_MESH);
BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_MESH, NULL);
BLI_path_abs(temp_dir, relbase);
- BLI_delete(temp_dir, true, true); /* BLI_exists(filepath) is implicit */
-
+ if (BLI_exists(temp_dir)) {
+ BLI_delete(temp_dir, true, true);
+ }
fds->cache_frame_pause_mesh = 0;
}
if (cache_map & FLUID_DOMAIN_OUTDATED_PARTICLES) {
@@ -377,17 +382,18 @@ void BKE_fluid_cache_free(FluidDomainSettings *fds, Object *ob, int cache_map)
BLI_path_join(
temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_PARTICLES, NULL);
BLI_path_abs(temp_dir, relbase);
- BLI_delete(temp_dir, true, true); /* BLI_exists(filepath) is implicit */
-
+ if (BLI_exists(temp_dir)) {
+ BLI_delete(temp_dir, true, true);
+ }
fds->cache_frame_pause_particles = 0;
}
-
if (cache_map & FLUID_DOMAIN_OUTDATED_GUIDE) {
flags &= ~(FLUID_DOMAIN_BAKING_GUIDE | FLUID_DOMAIN_BAKED_GUIDE | FLUID_DOMAIN_OUTDATED_GUIDE);
BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_GUIDE, NULL);
BLI_path_abs(temp_dir, relbase);
- BLI_delete(temp_dir, true, true); /* BLI_exists(filepath) is implicit */
-
+ if (BLI_exists(temp_dir)) {
+ BLI_delete(temp_dir, true, true);
+ }
fds->cache_frame_pause_guide = 0;
}
fds->cache_flag = flags;
@@ -1987,7 +1993,7 @@ static void sample_mesh(FluidFlowSettings *ffs,
/* 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 time_mult = 1.0 / (25.0f * 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);
@@ -3295,7 +3301,7 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds, Mesh *orgmesh, Obj
/* If needed, vertex velocities will be read too. */
bool use_speedvectors = fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS;
FluidDomainVertexVelocity *velarray = NULL;
- float time_mult = 25.f * DT_DEFAULT;
+ float time_mult = 25.0f * DT_DEFAULT;
if (use_speedvectors) {
if (fds->mesh_velocities) {
@@ -4432,7 +4438,7 @@ float BKE_fluid_get_velocity_at(struct Object *ob, float position[3], float velo
if (fmd && (fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain && fmd->domain->fluid) {
FluidDomainSettings *fds = fmd->domain;
- float time_mult = 25.f * DT_DEFAULT;
+ float time_mult = 25.0f * DT_DEFAULT;
float size_mult = MAX3(fds->global_size[0], fds->global_size[1], fds->global_size[2]) /
MAX3(fds->base_res[0], fds->base_res[1], fds->base_res[2]);
float vel_mag;
@@ -4699,9 +4705,11 @@ void BKE_fluid_fields_sanitize(FluidDomainSettings *settings)
const char data_depth = settings->openvdb_data_depth;
if (settings->type == FLUID_DOMAIN_TYPE_GAS) {
- if (coba_field == FLUID_DOMAIN_FIELD_PHI || coba_field == FLUID_DOMAIN_FIELD_PHI_IN ||
- coba_field == FLUID_DOMAIN_FIELD_PHI_OUT ||
- coba_field == FLUID_DOMAIN_FIELD_PHI_OBSTACLE) {
+ if (ELEM(coba_field,
+ FLUID_DOMAIN_FIELD_PHI,
+ FLUID_DOMAIN_FIELD_PHI_IN,
+ FLUID_DOMAIN_FIELD_PHI_OUT,
+ FLUID_DOMAIN_FIELD_PHI_OBSTACLE)) {
/* Defaulted to density for gas domain. */
settings->coba_field = FLUID_DOMAIN_FIELD_DENSITY;
}
@@ -4712,10 +4720,14 @@ void BKE_fluid_fields_sanitize(FluidDomainSettings *settings)
}
}
else if (settings->type == FLUID_DOMAIN_TYPE_LIQUID) {
- if (coba_field == FLUID_DOMAIN_FIELD_COLOR_R || coba_field == FLUID_DOMAIN_FIELD_COLOR_G ||
- coba_field == FLUID_DOMAIN_FIELD_COLOR_B || coba_field == FLUID_DOMAIN_FIELD_DENSITY ||
- coba_field == FLUID_DOMAIN_FIELD_FLAME || coba_field == FLUID_DOMAIN_FIELD_FUEL ||
- coba_field == FLUID_DOMAIN_FIELD_HEAT) {
+ if (ELEM(coba_field,
+ FLUID_DOMAIN_FIELD_COLOR_R,
+ FLUID_DOMAIN_FIELD_COLOR_G,
+ FLUID_DOMAIN_FIELD_COLOR_B,
+ FLUID_DOMAIN_FIELD_DENSITY,
+ FLUID_DOMAIN_FIELD_FLAME,
+ FLUID_DOMAIN_FIELD_FUEL,
+ FLUID_DOMAIN_FIELD_HEAT)) {
/* Defaulted to phi for liquid domain. */
settings->coba_field = FLUID_DOMAIN_FIELD_PHI;
}
@@ -4995,6 +5007,7 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *fmd,
tfds->fractions_threshold = fds->fractions_threshold;
tfds->fractions_distance = fds->fractions_distance;
tfds->sys_particle_maximum = fds->sys_particle_maximum;
+ tfds->simulation_method = fds->simulation_method;
/* diffusion options*/
tfds->surface_tension = fds->surface_tension;
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index d13425f5ec9..6ebcef5caef 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -824,7 +824,8 @@ static void fcm_noise_evaluate(
* - 0.1 is passed as the 'z' value, otherwise evaluation fails for size = phase = 1
* with evaltime being an integer (which happens when evaluating on frame by frame basis)
*/
- noise = BLI_turbulence(data->size, evaltime - data->offset, data->phase, 0.1f, data->depth);
+ noise = BLI_noise_turbulence(
+ data->size, evaltime - data->offset, data->phase, 0.1f, data->depth);
/* combine the noise with existing motion data */
switch (data->modification) {
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index e0bbdfaeed6..9431915b4e4 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -168,6 +168,8 @@ IDTypeInfo IDType_ID_VF = {
.blend_read_data = vfont_blend_read_data,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
/***************************** VFont *******************************/
@@ -947,7 +949,7 @@ static bool vfont_to_curve(Object *ob,
// CLOG_WARN(&LOG, "linewidth exceeded: %c%c%c...", mem[i], mem[i+1], mem[i+2]);
for (j = i; j && (mem[j] != '\n') && (chartransdata[j].dobreak == 0); j--) {
bool dobreak = false;
- if (mem[j] == ' ' || mem[j] == '-') {
+ if (ELEM(mem[j], ' ', '-')) {
ct -= (i - (j - 1));
cnr -= (i - (j - 1));
if (mem[j] == ' ') {
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 6c6ca996caa..98e83bfb789 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -155,6 +155,12 @@ static void greasepencil_blend_write(BlendWriter *writer, ID *id, const void *id
BLO_write_struct_array(writer, bGPDspoint, gps->totpoints, gps->points);
BLO_write_struct_array(writer, bGPDtriangle, gps->tot_triangles, gps->triangles);
BKE_defvert_blend_write(writer, gps->totpoints, gps->dvert);
+ if (gps->editcurve != NULL) {
+ bGPDcurve *gpc = gps->editcurve;
+ BLO_write_struct(writer, bGPDcurve, gpc);
+ BLO_write_struct_array(
+ writer, bGPDcurve_point, gpc->tot_curve_points, gpc->curve_points);
+ }
}
}
}
@@ -222,6 +228,13 @@ void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd)
/* Relink geometry*/
BLO_read_data_address(reader, &gps->triangles);
+ /* relink stroke edit curve. */
+ BLO_read_data_address(reader, &gps->editcurve);
+ if (gps->editcurve != NULL) {
+ /* relink curve point array */
+ BLO_read_data_address(reader, &gps->editcurve->curve_points);
+ }
+
/* relink weight data */
if (gps->dvert) {
BLO_read_data_address(reader, &gps->dvert);
@@ -288,6 +301,8 @@ IDTypeInfo IDType_ID_GD = {
.blend_read_data = greasepencil_blend_read_data,
.blend_read_lib = greasepencil_blend_read_lib,
.blend_read_expand = greasepencil_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
/* ************************************************** */
@@ -339,6 +354,20 @@ void BKE_gpencil_free_stroke_weights(bGPDstroke *gps)
}
}
+void BKE_gpencil_free_stroke_editcurve(bGPDstroke *gps)
+{
+ if (gps == NULL) {
+ return;
+ }
+ bGPDcurve *editcurve = gps->editcurve;
+ if (editcurve == NULL) {
+ return;
+ }
+ MEM_freeN(editcurve->curve_points);
+ MEM_freeN(editcurve);
+ gps->editcurve = NULL;
+}
+
/* free stroke, doesn't unlink from any listbase */
void BKE_gpencil_free_stroke(bGPDstroke *gps)
{
@@ -356,6 +385,9 @@ void BKE_gpencil_free_stroke(bGPDstroke *gps)
if (gps->triangles) {
MEM_freeN(gps->triangles);
}
+ if (gps->editcurve != NULL) {
+ BKE_gpencil_free_stroke_editcurve(gps);
+ }
MEM_freeN(gps);
}
@@ -686,6 +718,13 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
+ gpd->curve_edit_resolution = GP_DEFAULT_CURVE_RESOLUTION;
+ gpd->curve_edit_threshold = GP_DEFAULT_CURVE_ERROR;
+ gpd->curve_edit_corner_angle = GP_DEFAULT_CURVE_EDIT_CORNER_ANGLE;
+
+ /* use adaptive curve resolution by default */
+ gpd->flag |= GP_DATA_CURVE_ADAPTIVE_RESOLUTION;
+
gpd->zdepth_offset = 0.150f;
/* grid settings */
@@ -774,6 +813,8 @@ bGPDstroke *BKE_gpencil_stroke_new(int mat_idx, int totpoints, short thickness)
gps->mat_nr = mat_idx;
+ gps->editcurve = NULL;
+
return gps;
}
@@ -825,6 +866,16 @@ bGPDstroke *BKE_gpencil_stroke_add_existing_style(
return gps;
}
+bGPDcurve *BKE_gpencil_stroke_editcurve_new(const int tot_curve_points)
+{
+ bGPDcurve *new_gp_curve = (bGPDcurve *)MEM_callocN(sizeof(bGPDcurve), __func__);
+ new_gp_curve->tot_curve_points = tot_curve_points;
+ new_gp_curve->curve_points = (bGPDcurve_point *)MEM_callocN(
+ sizeof(bGPDcurve_point) * tot_curve_points, __func__);
+
+ return new_gp_curve;
+}
+
/* ************************************************** */
/* Data Duplication */
@@ -843,13 +894,28 @@ void BKE_gpencil_stroke_weights_duplicate(bGPDstroke *gps_src, bGPDstroke *gps_d
BKE_defvert_array_copy(gps_dst->dvert, gps_src->dvert, gps_src->totpoints);
}
+/* Make a copy of a given gpencil stroke editcurve */
+bGPDcurve *BKE_gpencil_stroke_curve_duplicate(bGPDcurve *gpc_src)
+{
+ bGPDcurve *gpc_dst = MEM_dupallocN(gpc_src);
+
+ if (gpc_src->curve_points != NULL) {
+ gpc_dst->curve_points = MEM_dupallocN(gpc_src->curve_points);
+ }
+
+ return gpc_dst;
+}
+
/**
* Make a copy of a given grease-pencil stroke.
* \param gps_src: Source grease pencil strokes.
* \param dup_points: Duplicate points data.
+ * \param dup_curve: Duplicate curve data.
* \return Pointer to new stroke.
*/
-bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src, const bool dup_points)
+bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src,
+ const bool dup_points,
+ const bool dup_curve)
{
bGPDstroke *gps_dst = NULL;
@@ -868,6 +934,17 @@ bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src, const bool dup_poi
gps_dst->dvert = NULL;
}
}
+ else {
+ gps_dst->points = NULL;
+ gps_dst->dvert = NULL;
+ }
+
+ if (dup_curve && gps_src->editcurve != NULL) {
+ gps_dst->editcurve = BKE_gpencil_stroke_curve_duplicate(gps_src->editcurve);
+ }
+ else {
+ gps_dst->editcurve = NULL;
+ }
/* return new stroke */
return gps_dst;
@@ -896,7 +973,7 @@ bGPDframe *BKE_gpencil_frame_duplicate(const bGPDframe *gpf_src)
BLI_listbase_clear(&gpf_dst->strokes);
LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) {
/* make copy of source stroke */
- gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true);
+ gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true, true);
BLI_addtail(&gpf_dst->strokes, gps_dst);
}
@@ -921,7 +998,7 @@ void BKE_gpencil_frame_copy_strokes(bGPDframe *gpf_src, struct bGPDframe *gpf_ds
BLI_listbase_clear(&gpf_dst->strokes);
LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) {
/* make copy of source stroke */
- gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true);
+ gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true, true);
BLI_addtail(&gpf_dst->strokes, gps_dst);
}
}
@@ -1035,6 +1112,39 @@ void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps)
}
}
+void BKE_gpencil_curve_sync_selection(bGPDstroke *gps)
+{
+ bGPDcurve *gpc = gps->editcurve;
+ if (gpc == NULL) {
+ return;
+ }
+
+ gps->flag &= ~GP_STROKE_SELECT;
+ gpc->flag &= ~GP_CURVE_SELECT;
+
+ bool is_selected = false;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+
+ if (BEZT_ISSEL_ANY(bezt)) {
+ gpc_pt->flag |= GP_SPOINT_SELECT;
+ }
+ else {
+ gpc_pt->flag &= ~GP_SPOINT_SELECT;
+ }
+
+ if (gpc_pt->flag & GP_SPOINT_SELECT) {
+ is_selected = true;
+ }
+ }
+
+ if (is_selected) {
+ gpc->flag |= GP_CURVE_SELECT;
+ gps->flag |= GP_STROKE_SELECT;
+ }
+}
+
/* ************************************************** */
/* GP Frame API */
@@ -2009,12 +2119,12 @@ void BKE_gpencil_material_remap(struct bGPdata *gpd,
/**
* Load a table with material conversion index for merged materials.
- * \param ob: Grease pencil object
- * \param hue_threshold: Threshold for Hue
- * \param sat_threshold: Threshold for Saturation
- * \param val_threshold: Threshold for Value
- * \param r_mat_table : return material table
- * \return True if done
+ * \param ob: Grease pencil object.
+ * \param hue_threshold: Threshold for Hue.
+ * \param sat_threshold: Threshold for Saturation.
+ * \param val_threshold: Threshold for Value.
+ * \param r_mat_table: return material table.
+ * \return True if done.
*/
bool BKE_gpencil_merge_materials_table_get(Object *ob,
const float hue_threshold,
@@ -2302,12 +2412,14 @@ void BKE_gpencil_palette_ensure(Main *bmain, Scene *scene)
/**
* Create grease pencil strokes from image
* \param sima: Image
+ * \param gpd: Grease pencil data-block
* \param gpf: Grease pencil frame
* \param size: Size
* \param mask: Mask
* \return True if done
*/
-bool BKE_gpencil_from_image(SpaceImage *sima, bGPDframe *gpf, const float size, const bool mask)
+bool BKE_gpencil_from_image(
+ SpaceImage *sima, bGPdata *gpd, bGPDframe *gpf, const float size, const bool mask)
{
Image *image = sima->image;
bool done = false;
@@ -2355,7 +2467,7 @@ bool BKE_gpencil_from_image(SpaceImage *sima, bGPDframe *gpf, const float size,
pt->flag |= GP_SPOINT_SELECT;
}
}
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
}
@@ -2668,7 +2780,7 @@ void BKE_gpencil_parent_matrix_get(const Depsgraph *depsgraph,
return;
}
- if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) {
+ if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) {
mul_m4_m4m4(diff_mat, obparent_eval->obmat, gpl->inverse);
add_v3_v3(diff_mat[3], ob_eval->obmat[3]);
return;
@@ -2710,7 +2822,7 @@ void BKE_gpencil_update_layer_parent(const Depsgraph *depsgraph, Object *ob)
if ((gpl->parent != NULL) && (gpl->actframe != NULL)) {
Object *ob_parent = DEG_get_evaluated_object(depsgraph, gpl->parent);
/* calculate new matrix */
- if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) {
+ if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) {
copy_m4_m4(cur_mat, ob_parent->obmat);
}
else if (gpl->partype == PARBONE) {
diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c
index 6b3f752120a..8cc11468771 100644
--- a/source/blender/blenkernel/intern/gpencil_curve.c
+++ b/source/blender/blenkernel/intern/gpencil_curve.c
@@ -37,8 +37,10 @@
#include "BLT_translation.h"
#include "DNA_gpencil_types.h"
+#include "DNA_meshdata_types.h"
#include "BKE_collection.h"
+#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_curve.h"
@@ -47,8 +49,16 @@
#include "BKE_material.h"
#include "BKE_object.h"
+#include "curve_fit_nd.h"
+
#include "DEG_depsgraph_query.h"
+#define COORD_FITTING_INFLUENCE 20.0f
+
+/* -------------------------------------------------------------------- */
+/** \name Convert to curve object
+ * \{ */
+
/* Helper: Check materials with same color. */
static int gpencil_check_same_material_color(Object *ob_gp,
const float color_stroke[4],
@@ -295,6 +305,7 @@ static void gpencil_convert_spline(Main *bmain,
bGPDframe *gpf,
Nurb *nu)
{
+ bGPdata *gpd = (bGPdata *)ob_gp->data;
bool cyclic = true;
/* Create Stroke. */
@@ -445,11 +456,22 @@ static void gpencil_convert_spline(Main *bmain,
}
if (sample > 0.0f) {
- BKE_gpencil_stroke_sample(gps, sample, false);
+ BKE_gpencil_stroke_sample(gpd, gps, sample, false);
}
/* Recalc fill geometry. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+}
+
+static void gpencil_editstroke_deselect_all(bGPDcurve *gpc)
+{
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ }
+ gpc->flag &= ~GP_CURVE_SELECT;
}
/**
@@ -536,3 +558,851 @@ void BKE_gpencil_convert_curve(Main *bmain,
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Edit-Curve Kernel Functions
+ * \{ */
+
+static bGPDcurve *gpencil_stroke_editcurve_generate_edgecases(bGPDstroke *gps,
+ const float stroke_radius)
+{
+ BLI_assert(gps->totpoints < 3);
+
+ if (gps->totpoints == 1) {
+ bGPDcurve *editcurve = BKE_gpencil_stroke_editcurve_new(1);
+ bGPDspoint *pt = &gps->points[0];
+ bGPDcurve_point *cpt = &editcurve->curve_points[0];
+ BezTriple *bezt = &cpt->bezt;
+
+ /* Handles are twice as long as the radius of the point. */
+ float offset = (pt->pressure * stroke_radius) * 2.0f;
+
+ float tmp_vec[3];
+ for (int j = 0; j < 3; j++) {
+ copy_v3_v3(tmp_vec, &pt->x);
+ /* Move handles along the x-axis away from the control point */
+ tmp_vec[0] += (float)(j - 1) * offset;
+ copy_v3_v3(bezt->vec[j], tmp_vec);
+ }
+
+ cpt->pressure = pt->pressure;
+ cpt->strength = pt->strength;
+ copy_v4_v4(cpt->vert_color, pt->vert_color);
+
+ /* default handle type */
+ bezt->h1 = HD_FREE;
+ bezt->h2 = HD_FREE;
+
+ cpt->point_index = 0;
+
+ return editcurve;
+ }
+ if (gps->totpoints == 2) {
+ bGPDcurve *editcurve = BKE_gpencil_stroke_editcurve_new(2);
+ bGPDspoint *first_pt = &gps->points[0];
+ bGPDspoint *last_pt = &gps->points[1];
+
+ float length = len_v3v3(&first_pt->x, &last_pt->x);
+ float offset = length / 3;
+ float dir[3];
+ sub_v3_v3v3(dir, &last_pt->x, &first_pt->x);
+
+ for (int i = 0; i < 2; i++) {
+ bGPDspoint *pt = &gps->points[i];
+ bGPDcurve_point *cpt = &editcurve->curve_points[i];
+ BezTriple *bezt = &cpt->bezt;
+
+ float tmp_vec[3];
+ for (int j = 0; j < 3; j++) {
+ copy_v3_v3(tmp_vec, dir);
+ normalize_v3_length(tmp_vec, (float)(j - 1) * offset);
+ add_v3_v3v3(bezt->vec[j], &pt->x, tmp_vec);
+ }
+
+ cpt->pressure = pt->pressure;
+ cpt->strength = pt->strength;
+ copy_v4_v4(cpt->vert_color, pt->vert_color);
+
+ /* default handle type */
+ bezt->h1 = HD_VECT;
+ bezt->h2 = HD_VECT;
+
+ cpt->point_index = 0;
+ }
+
+ return editcurve;
+ }
+
+ return NULL;
+}
+
+/**
+ * Creates a bGPDcurve by doing a cubic curve fitting on the grease pencil stroke points.
+ */
+bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps,
+ const float error_threshold,
+ const float corner_angle,
+ const float stroke_radius)
+{
+ if (gps->totpoints < 3) {
+ return gpencil_stroke_editcurve_generate_edgecases(gps, stroke_radius);
+ }
+#define POINT_DIM 9
+
+ float *points = MEM_callocN(sizeof(float) * gps->totpoints * POINT_DIM, __func__);
+ float diag_length = len_v3v3(gps->boundbox_min, gps->boundbox_max);
+ float tmp_vec[3];
+
+ for (int i = 0; i < gps->totpoints; i++) {
+ bGPDspoint *pt = &gps->points[i];
+ int row = i * POINT_DIM;
+
+ /* normalize coordinate to 0..1 */
+ sub_v3_v3v3(tmp_vec, &pt->x, gps->boundbox_min);
+ mul_v3_v3fl(&points[row], tmp_vec, COORD_FITTING_INFLUENCE / diag_length);
+ points[row + 3] = pt->pressure / diag_length;
+
+ /* strength and color are already normalized */
+ points[row + 4] = pt->strength / diag_length;
+ mul_v4_v4fl(&points[row + 5], pt->vert_color, 1.0f / diag_length);
+ }
+
+ uint calc_flag = CURVE_FIT_CALC_HIGH_QUALIY;
+ if (gps->totpoints > 2 && gps->flag & GP_STROKE_CYCLIC) {
+ calc_flag |= CURVE_FIT_CALC_CYCLIC;
+ }
+
+ float *r_cubic_array = NULL;
+ unsigned int r_cubic_array_len = 0;
+ unsigned int *r_cubic_orig_index = NULL;
+ unsigned int *r_corners_index_array = NULL;
+ unsigned int r_corners_index_len = 0;
+ int r = curve_fit_cubic_to_points_refit_fl(points,
+ gps->totpoints,
+ POINT_DIM,
+ error_threshold,
+ calc_flag,
+ NULL,
+ 0,
+ corner_angle,
+ &r_cubic_array,
+ &r_cubic_array_len,
+ &r_cubic_orig_index,
+ &r_corners_index_array,
+ &r_corners_index_len);
+
+ if (r != 0 || r_cubic_array_len < 1) {
+ return NULL;
+ }
+
+ uint curve_point_size = 3 * POINT_DIM;
+
+ bGPDcurve *editcurve = BKE_gpencil_stroke_editcurve_new(r_cubic_array_len);
+
+ for (int i = 0; i < r_cubic_array_len; i++) {
+ bGPDcurve_point *cpt = &editcurve->curve_points[i];
+ BezTriple *bezt = &cpt->bezt;
+ float *curve_point = &r_cubic_array[i * curve_point_size];
+
+ for (int j = 0; j < 3; j++) {
+ float *bez = &curve_point[j * POINT_DIM];
+ madd_v3_v3v3fl(bezt->vec[j], gps->boundbox_min, bez, diag_length / COORD_FITTING_INFLUENCE);
+ }
+
+ float *ctrl_point = &curve_point[1 * POINT_DIM];
+ cpt->pressure = ctrl_point[3] * diag_length;
+ cpt->strength = ctrl_point[4] * diag_length;
+ mul_v4_v4fl(cpt->vert_color, &ctrl_point[5], diag_length);
+
+ /* default handle type */
+ bezt->h1 = HD_ALIGN;
+ bezt->h2 = HD_ALIGN;
+
+ cpt->point_index = r_cubic_orig_index[i];
+ }
+
+ if (r_corners_index_len > 0 && r_corners_index_array != NULL) {
+ int start = 0, end = r_corners_index_len;
+ if ((r_corners_index_len > 1) && (calc_flag & CURVE_FIT_CALC_CYCLIC) == 0) {
+ start = 1;
+ end = r_corners_index_len - 1;
+ }
+ for (int i = start; i < end; i++) {
+ bGPDcurve_point *cpt = &editcurve->curve_points[r_corners_index_array[i]];
+ BezTriple *bezt = &cpt->bezt;
+ bezt->h1 = HD_FREE;
+ bezt->h2 = HD_FREE;
+ }
+ }
+
+ MEM_freeN(points);
+ if (r_cubic_array) {
+ free(r_cubic_array);
+ }
+ if (r_corners_index_array) {
+ free(r_corners_index_array);
+ }
+ if (r_cubic_orig_index) {
+ free(r_cubic_orig_index);
+ }
+
+#undef POINT_DIM
+ return editcurve;
+}
+
+/**
+ * Updates the editcurve for a stroke. Frees the old curve if one exists and generates a new one.
+ */
+void BKE_gpencil_stroke_editcurve_update(bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps)
+{
+ if (gps == NULL || gps->totpoints < 0) {
+ return;
+ }
+
+ if (gps->editcurve != NULL) {
+ BKE_gpencil_free_stroke_editcurve(gps);
+ }
+
+ float defaultpixsize = 1000.0f / gpd->pixfactor;
+ float stroke_radius = ((gps->thickness + gpl->line_change) / defaultpixsize) / 2.0f;
+
+ bGPDcurve *editcurve = BKE_gpencil_stroke_editcurve_generate(
+ gps, gpd->curve_edit_threshold, gpd->curve_edit_corner_angle, stroke_radius);
+ if (editcurve == NULL) {
+ return;
+ }
+
+ gps->editcurve = editcurve;
+}
+
+/**
+ * Sync the selection from stroke to editcurve
+ */
+void BKE_gpencil_editcurve_stroke_sync_selection(bGPDstroke *gps, bGPDcurve *gpc)
+{
+ if (gps->flag & GP_STROKE_SELECT) {
+ gpc->flag |= GP_CURVE_SELECT;
+
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ bGPDspoint *pt = &gps->points[gpc_pt->point_index];
+ if (pt->flag & GP_SPOINT_SELECT) {
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(&gpc_pt->bezt);
+ }
+ else {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(&gpc_pt->bezt);
+ }
+ }
+ }
+ else {
+ gpc->flag &= ~GP_CURVE_SELECT;
+ gpencil_editstroke_deselect_all(gpc);
+ }
+}
+
+/**
+ * Sync the selection from editcurve to stroke
+ */
+void BKE_gpencil_stroke_editcurve_sync_selection(bGPDstroke *gps, bGPDcurve *gpc)
+{
+ if (gpc->flag & GP_CURVE_SELECT) {
+ gps->flag |= GP_STROKE_SELECT;
+
+ for (int i = 0; i < gpc->tot_curve_points - 1; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ bGPDspoint *pt = &gps->points[gpc_pt->point_index];
+ bGPDcurve_point *gpc_pt_next = &gpc->curve_points[i + 1];
+
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ pt->flag |= GP_SPOINT_SELECT;
+ if (gpc_pt_next->flag & GP_CURVE_POINT_SELECT) {
+ /* select all the points after */
+ for (int j = gpc_pt->point_index + 1; j < gpc_pt_next->point_index; j++) {
+ bGPDspoint *pt_next = &gps->points[j];
+ pt_next->flag |= GP_SPOINT_SELECT;
+ }
+ }
+ }
+ else {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ /* deselect all points after */
+ for (int j = gpc_pt->point_index + 1; j < gpc_pt_next->point_index; j++) {
+ bGPDspoint *pt_next = &gps->points[j];
+ pt_next->flag &= ~GP_SPOINT_SELECT;
+ }
+ }
+ }
+
+ bGPDcurve_point *gpc_first = &gpc->curve_points[0];
+ bGPDcurve_point *gpc_last = &gpc->curve_points[gpc->tot_curve_points - 1];
+ bGPDspoint *last_pt = &gps->points[gpc_last->point_index];
+ if (gpc_last->flag & GP_CURVE_POINT_SELECT) {
+ last_pt->flag |= GP_SPOINT_SELECT;
+ }
+ else {
+ last_pt->flag &= ~GP_SPOINT_SELECT;
+ }
+
+ if (gps->flag & GP_STROKE_CYCLIC) {
+ if (gpc_first->flag & GP_CURVE_POINT_SELECT && gpc_last->flag & GP_CURVE_POINT_SELECT) {
+ for (int i = gpc_last->point_index + 1; i < gps->totpoints; i++) {
+ bGPDspoint *pt_next = &gps->points[i];
+ pt_next->flag |= GP_SPOINT_SELECT;
+ }
+ }
+ else {
+ for (int i = gpc_last->point_index + 1; i < gps->totpoints; i++) {
+ bGPDspoint *pt_next = &gps->points[i];
+ pt_next->flag &= ~GP_SPOINT_SELECT;
+ }
+ }
+ }
+ }
+ else {
+ gps->flag &= ~GP_STROKE_SELECT;
+ for (int i = 0; i < gps->totpoints; i++) {
+ bGPDspoint *pt = &gps->points[i];
+ pt->flag &= ~GP_SPOINT_SELECT;
+ }
+ }
+}
+
+static void gpencil_interpolate_fl_from_to(
+ float from, float to, float *point_offset, int it, int stride)
+{
+ /* smooth interpolation */
+ float *r = point_offset;
+ for (int i = 0; i <= it; i++) {
+ float fac = (float)i / (float)it;
+ fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth
+ *r = interpf(to, from, fac);
+ r = POINTER_OFFSET(r, stride);
+ }
+}
+
+static void gpencil_interpolate_v4_from_to(
+ float from[4], float to[4], float *point_offset, int it, int stride)
+{
+ /* smooth interpolation */
+ float *r = point_offset;
+ for (int i = 0; i <= it; i++) {
+ float fac = (float)i / (float)it;
+ fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth
+ interp_v4_v4v4(r, from, to, fac);
+ r = POINTER_OFFSET(r, stride);
+ }
+}
+
+static float gpencil_approximate_curve_segment_arclength(bGPDcurve_point *cpt_start,
+ bGPDcurve_point *cpt_end)
+{
+ BezTriple *bezt_start = &cpt_start->bezt;
+ BezTriple *bezt_end = &cpt_end->bezt;
+
+ float chord_len = len_v3v3(bezt_start->vec[1], bezt_end->vec[1]);
+ float net_len = len_v3v3(bezt_start->vec[1], bezt_start->vec[2]);
+ net_len += len_v3v3(bezt_start->vec[2], bezt_end->vec[0]);
+ net_len += len_v3v3(bezt_end->vec[0], bezt_end->vec[1]);
+
+ return (chord_len + net_len) / 2.0f;
+}
+
+static void gpencil_calculate_stroke_points_curve_segment(
+ bGPDcurve_point *cpt, bGPDcurve_point *cpt_next, float *points_offset, int resolu, int stride)
+{
+ /* sample points on all 3 axis between two curve points */
+ for (uint axis = 0; axis < 3; axis++) {
+ BKE_curve_forward_diff_bezier(cpt->bezt.vec[1][axis],
+ cpt->bezt.vec[2][axis],
+ cpt_next->bezt.vec[0][axis],
+ cpt_next->bezt.vec[1][axis],
+ POINTER_OFFSET(points_offset, sizeof(float) * axis),
+ (int)resolu,
+ stride);
+ }
+
+ /* interpolate other attributes */
+ gpencil_interpolate_fl_from_to(cpt->pressure,
+ cpt_next->pressure,
+ POINTER_OFFSET(points_offset, sizeof(float) * 3),
+ resolu,
+ stride);
+ gpencil_interpolate_fl_from_to(cpt->strength,
+ cpt_next->strength,
+ POINTER_OFFSET(points_offset, sizeof(float) * 4),
+ resolu,
+ stride);
+ gpencil_interpolate_v4_from_to(cpt->vert_color,
+ cpt_next->vert_color,
+ POINTER_OFFSET(points_offset, sizeof(float) * 5),
+ resolu,
+ stride);
+}
+
+static float *gpencil_stroke_points_from_editcurve_adaptive_resolu(
+ bGPDcurve_point *curve_point_array,
+ int curve_point_array_len,
+ int resolution,
+ bool is_cyclic,
+ int *r_points_len)
+{
+ /* One stride contains: x, y, z, pressure, strength, Vr, Vg, Vb, Vmix_factor */
+ const uint stride = sizeof(float[9]);
+ const uint cpt_last = curve_point_array_len - 1;
+ const uint num_segments = (is_cyclic) ? curve_point_array_len : curve_point_array_len - 1;
+ int *segment_point_lengths = MEM_callocN(sizeof(int) * num_segments, __func__);
+
+ uint points_len = 1;
+ for (int i = 0; i < cpt_last; i++) {
+ bGPDcurve_point *cpt = &curve_point_array[i];
+ bGPDcurve_point *cpt_next = &curve_point_array[i + 1];
+ float arclen = gpencil_approximate_curve_segment_arclength(cpt, cpt_next);
+ int segment_resolu = (int)floorf(arclen * resolution);
+ CLAMP_MIN(segment_resolu, 1);
+
+ segment_point_lengths[i] = segment_resolu;
+ points_len += segment_resolu;
+ }
+
+ if (is_cyclic) {
+ bGPDcurve_point *cpt = &curve_point_array[cpt_last];
+ bGPDcurve_point *cpt_next = &curve_point_array[0];
+ float arclen = gpencil_approximate_curve_segment_arclength(cpt, cpt_next);
+ int segment_resolu = (int)floorf(arclen * resolution);
+ CLAMP_MIN(segment_resolu, 1);
+
+ segment_point_lengths[cpt_last] = segment_resolu;
+ points_len += segment_resolu;
+ }
+
+ float(*r_points)[9] = MEM_callocN((stride * points_len * (is_cyclic ? 2 : 1)), __func__);
+ float *points_offset = &r_points[0][0];
+ int point_index = 0;
+ for (int i = 0; i < cpt_last; i++) {
+ bGPDcurve_point *cpt_curr = &curve_point_array[i];
+ bGPDcurve_point *cpt_next = &curve_point_array[i + 1];
+ int segment_resolu = segment_point_lengths[i];
+ gpencil_calculate_stroke_points_curve_segment(
+ cpt_curr, cpt_next, points_offset, segment_resolu, stride);
+ /* update the index */
+ cpt_curr->point_index = point_index;
+ point_index += segment_resolu;
+ points_offset = POINTER_OFFSET(points_offset, segment_resolu * stride);
+ }
+
+ bGPDcurve_point *cpt_curr = &curve_point_array[cpt_last];
+ cpt_curr->point_index = point_index;
+ if (is_cyclic) {
+ bGPDcurve_point *cpt_next = &curve_point_array[0];
+ int segment_resolu = segment_point_lengths[cpt_last];
+ gpencil_calculate_stroke_points_curve_segment(
+ cpt_curr, cpt_next, points_offset, segment_resolu, stride);
+ }
+
+ MEM_freeN(segment_point_lengths);
+
+ *r_points_len = points_len;
+ return (float(*))r_points;
+}
+
+/**
+ * Helper: calculate the points on a curve with a fixed resolution.
+ */
+static float *gpencil_stroke_points_from_editcurve_fixed_resolu(bGPDcurve_point *curve_point_array,
+ int curve_point_array_len,
+ int resolution,
+ bool is_cyclic,
+ int *r_points_len)
+{
+ /* One stride contains: x, y, z, pressure, strength, Vr, Vg, Vb, Vmix_factor */
+ const uint stride = sizeof(float[9]);
+ const uint array_last = curve_point_array_len - 1;
+ const uint resolu_stride = resolution * stride;
+ const uint points_len = BKE_curve_calc_coords_axis_len(
+ curve_point_array_len, resolution, is_cyclic, false);
+
+ float(*r_points)[9] = MEM_callocN((stride * points_len * (is_cyclic ? 2 : 1)), __func__);
+ float *points_offset = &r_points[0][0];
+ for (unsigned int i = 0; i < array_last; i++) {
+ bGPDcurve_point *cpt_curr = &curve_point_array[i];
+ bGPDcurve_point *cpt_next = &curve_point_array[i + 1];
+
+ gpencil_calculate_stroke_points_curve_segment(
+ cpt_curr, cpt_next, points_offset, resolution, stride);
+ /* update the index */
+ cpt_curr->point_index = i * resolution;
+ points_offset = POINTER_OFFSET(points_offset, resolu_stride);
+ }
+
+ bGPDcurve_point *cpt_curr = &curve_point_array[array_last];
+ cpt_curr->point_index = array_last * resolution;
+ if (is_cyclic) {
+ bGPDcurve_point *cpt_next = &curve_point_array[0];
+ gpencil_calculate_stroke_points_curve_segment(
+ cpt_curr, cpt_next, points_offset, resolution, stride);
+ }
+
+ *r_points_len = points_len;
+ return (float(*))r_points;
+}
+
+/**
+ * Recalculate stroke points with the editcurve of the stroke.
+ */
+void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps,
+ const uint resolution,
+ const bool adaptive)
+{
+ if (gps == NULL || gps->editcurve == NULL) {
+ return;
+ }
+
+ bGPDcurve *editcurve = gps->editcurve;
+ bGPDcurve_point *curve_point_array = editcurve->curve_points;
+ int curve_point_array_len = editcurve->tot_curve_points;
+ if (curve_point_array_len == 0) {
+ return;
+ }
+ /* Handle case for single curve point. */
+ if (curve_point_array_len == 1) {
+ bGPDcurve_point *cpt = &curve_point_array[0];
+ /* resize stroke point array */
+ gps->totpoints = 1;
+ gps->points = MEM_recallocN(gps->points, sizeof(bGPDspoint) * gps->totpoints);
+ if (gps->dvert != NULL) {
+ gps->dvert = MEM_recallocN(gps->dvert, sizeof(MDeformVert) * gps->totpoints);
+ }
+
+ bGPDspoint *pt = &gps->points[0];
+ copy_v3_v3(&pt->x, cpt->bezt.vec[1]);
+
+ pt->pressure = cpt->pressure;
+ pt->strength = cpt->strength;
+
+ copy_v4_v4(pt->vert_color, cpt->vert_color);
+
+ /* deselect */
+ pt->flag &= ~GP_SPOINT_SELECT;
+ gps->flag &= ~GP_STROKE_SELECT;
+
+ return;
+ }
+
+ bool is_cyclic = gps->flag & GP_STROKE_CYCLIC;
+
+ int points_len = 0;
+ float(*points)[9] = NULL;
+ if (adaptive) {
+ points = (float(*)[9])gpencil_stroke_points_from_editcurve_adaptive_resolu(
+ curve_point_array, curve_point_array_len, resolution, is_cyclic, &points_len);
+ }
+ else {
+ points = (float(*)[9])gpencil_stroke_points_from_editcurve_fixed_resolu(
+ curve_point_array, curve_point_array_len, resolution, is_cyclic, &points_len);
+ }
+
+ if (points == NULL || points_len == 0) {
+ return;
+ }
+
+ /* resize stroke point array */
+ gps->totpoints = points_len;
+ gps->points = MEM_recallocN(gps->points, sizeof(bGPDspoint) * gps->totpoints);
+ if (gps->dvert != NULL) {
+ gps->dvert = MEM_recallocN(gps->dvert, sizeof(MDeformVert) * gps->totpoints);
+ }
+
+ /* write new data to stroke point array */
+ for (int i = 0; i < points_len; i++) {
+ bGPDspoint *pt = &gps->points[i];
+ copy_v3_v3(&pt->x, &points[i][0]);
+
+ pt->pressure = points[i][3];
+ pt->strength = points[i][4];
+
+ copy_v4_v4(pt->vert_color, &points[i][5]);
+
+ /* deselect points */
+ pt->flag &= ~GP_SPOINT_SELECT;
+ }
+ gps->flag &= ~GP_STROKE_SELECT;
+
+ /* free temp data */
+ MEM_freeN(points);
+}
+
+/**
+ * Recalculate the handles of the edit curve of a grease pencil stroke
+ */
+void BKE_gpencil_editcurve_recalculate_handles(bGPDstroke *gps)
+{
+ if (gps == NULL || gps->editcurve == NULL) {
+ return;
+ }
+
+ bool changed = false;
+ bGPDcurve *gpc = gps->editcurve;
+ if (gpc->tot_curve_points < 2) {
+ return;
+ }
+
+ if (gpc->tot_curve_points == 1) {
+ BKE_nurb_handle_calc(
+ &(gpc->curve_points[0].bezt), NULL, &(gpc->curve_points[0].bezt), false, 0);
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ }
+
+ for (int i = 1; i < gpc->tot_curve_points - 1; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ bGPDcurve_point *gpc_pt_prev = &gpc->curve_points[i - 1];
+ bGPDcurve_point *gpc_pt_next = &gpc->curve_points[i + 1];
+ /* update handle if point or neighbour is selected */
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT || gpc_pt_prev->flag & GP_CURVE_POINT_SELECT ||
+ gpc_pt_next->flag & GP_CURVE_POINT_SELECT) {
+ BezTriple *bezt = &gpc_pt->bezt;
+ BezTriple *bezt_prev = &gpc_pt_prev->bezt;
+ BezTriple *bezt_next = &gpc_pt_next->bezt;
+
+ BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, false, 0);
+ changed = true;
+ }
+ }
+
+ bGPDcurve_point *gpc_first = &gpc->curve_points[0];
+ bGPDcurve_point *gpc_last = &gpc->curve_points[gpc->tot_curve_points - 1];
+ bGPDcurve_point *gpc_first_next = &gpc->curve_points[1];
+ bGPDcurve_point *gpc_last_prev = &gpc->curve_points[gpc->tot_curve_points - 2];
+ if (gps->flag & GP_STROKE_CYCLIC) {
+ if (gpc_first->flag & GP_CURVE_POINT_SELECT || gpc_last->flag & GP_CURVE_POINT_SELECT) {
+ BezTriple *bezt_first = &gpc_first->bezt;
+ BezTriple *bezt_last = &gpc_last->bezt;
+ BezTriple *bezt_first_next = &gpc_first_next->bezt;
+ BezTriple *bezt_last_prev = &gpc_last_prev->bezt;
+
+ BKE_nurb_handle_calc(bezt_first, bezt_last, bezt_first_next, false, 0);
+ BKE_nurb_handle_calc(bezt_last, bezt_last_prev, bezt_first, false, 0);
+ changed = true;
+ }
+ }
+ else {
+ if (gpc_first->flag & GP_CURVE_POINT_SELECT || gpc_last->flag & GP_CURVE_POINT_SELECT) {
+ BezTriple *bezt_first = &gpc_first->bezt;
+ BezTriple *bezt_last = &gpc_last->bezt;
+ BezTriple *bezt_first_next = &gpc_first_next->bezt;
+ BezTriple *bezt_last_prev = &gpc_last_prev->bezt;
+
+ BKE_nurb_handle_calc(bezt_first, NULL, bezt_first_next, false, 0);
+ BKE_nurb_handle_calc(bezt_last, bezt_last_prev, NULL, false, 0);
+ changed = true;
+ }
+ }
+
+ if (changed) {
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ }
+}
+
+/* Helper: count how many new curve points must be generated. */
+static int gpencil_editcurve_subdivide_count(bGPDcurve *gpc, bool is_cyclic)
+{
+ int count = 0;
+ for (int i = 0; i < gpc->tot_curve_points - 1; i++) {
+ bGPDcurve_point *cpt = &gpc->curve_points[i];
+ bGPDcurve_point *cpt_next = &gpc->curve_points[i + 1];
+
+ if (cpt->flag & GP_CURVE_POINT_SELECT && cpt_next->flag & GP_CURVE_POINT_SELECT) {
+ count++;
+ }
+ }
+
+ if (is_cyclic) {
+ bGPDcurve_point *cpt = &gpc->curve_points[0];
+ bGPDcurve_point *cpt_next = &gpc->curve_points[gpc->tot_curve_points - 1];
+
+ if (cpt->flag & GP_CURVE_POINT_SELECT && cpt_next->flag & GP_CURVE_POINT_SELECT) {
+ count++;
+ }
+ }
+
+ return count;
+}
+
+static void gpencil_editcurve_subdivide_curve_segment(bGPDcurve_point *cpt_start,
+ bGPDcurve_point *cpt_end,
+ bGPDcurve_point *cpt_new)
+{
+ BezTriple *bezt_start = &cpt_start->bezt;
+ BezTriple *bezt_end = &cpt_end->bezt;
+ BezTriple *bezt_new = &cpt_new->bezt;
+ for (int axis = 0; axis < 3; axis++) {
+ float p0, p1, p2, p3, m0, m1, q0, q1, b;
+ p0 = bezt_start->vec[1][axis];
+ p1 = bezt_start->vec[2][axis];
+ p2 = bezt_end->vec[0][axis];
+ p3 = bezt_end->vec[1][axis];
+
+ m0 = (p0 + p1) / 2;
+ q0 = (p0 + 2 * p1 + p2) / 4;
+ b = (p0 + 3 * p1 + 3 * p2 + p3) / 8;
+ q1 = (p1 + 2 * p2 + p3) / 4;
+ m1 = (p2 + p3) / 2;
+
+ bezt_new->vec[0][axis] = q0;
+ bezt_new->vec[2][axis] = q1;
+ bezt_new->vec[1][axis] = b;
+
+ bezt_start->vec[2][axis] = m0;
+ bezt_end->vec[0][axis] = m1;
+ }
+
+ cpt_new->pressure = interpf(cpt_end->pressure, cpt_start->pressure, 0.5f);
+ cpt_new->strength = interpf(cpt_end->strength, cpt_start->strength, 0.5f);
+ interp_v4_v4v4(cpt_new->vert_color, cpt_start->vert_color, cpt_end->vert_color, 0.5f);
+}
+
+void BKE_gpencil_editcurve_subdivide(bGPDstroke *gps, const int cuts)
+{
+ bGPDcurve *gpc = gps->editcurve;
+ if (gpc == NULL || gpc->tot_curve_points < 2) {
+ return;
+ }
+ bool is_cyclic = gps->flag & GP_STROKE_CYCLIC;
+
+ /* repeat for number of cuts */
+ for (int s = 0; s < cuts; s++) {
+ int old_tot_curve_points = gpc->tot_curve_points;
+ int new_num_curve_points = gpencil_editcurve_subdivide_count(gpc, is_cyclic);
+ if (new_num_curve_points == 0) {
+ break;
+ }
+ int new_tot_curve_points = old_tot_curve_points + new_num_curve_points;
+
+ bGPDcurve_point *temp_curve_points = (bGPDcurve_point *)MEM_callocN(
+ sizeof(bGPDcurve_point) * new_tot_curve_points, __func__);
+
+ bool prev_subdivided = false;
+ int j = 0;
+ for (int i = 0; i < old_tot_curve_points - 1; i++, j++) {
+ bGPDcurve_point *cpt = &gpc->curve_points[i];
+ bGPDcurve_point *cpt_next = &gpc->curve_points[i + 1];
+
+ if (cpt->flag & GP_CURVE_POINT_SELECT && cpt_next->flag & GP_CURVE_POINT_SELECT) {
+ bGPDcurve_point *cpt_new = &temp_curve_points[j + 1];
+ gpencil_editcurve_subdivide_curve_segment(cpt, cpt_next, cpt_new);
+
+ memcpy(&temp_curve_points[j], cpt, sizeof(bGPDcurve_point));
+ memcpy(&temp_curve_points[j + 2], cpt_next, sizeof(bGPDcurve_point));
+
+ cpt_new->flag |= GP_CURVE_POINT_SELECT;
+ cpt_new->bezt.h1 = HD_ALIGN;
+ cpt_new->bezt.h2 = HD_ALIGN;
+ BEZT_SEL_ALL(&cpt_new->bezt);
+
+ prev_subdivided = true;
+ j++;
+ }
+ else if (!prev_subdivided) {
+ memcpy(&temp_curve_points[j], cpt, sizeof(bGPDcurve_point));
+ prev_subdivided = false;
+ }
+ else {
+ prev_subdivided = false;
+ }
+ }
+
+ if (is_cyclic) {
+ bGPDcurve_point *cpt = &gpc->curve_points[old_tot_curve_points - 1];
+ bGPDcurve_point *cpt_next = &gpc->curve_points[0];
+
+ if (cpt->flag & GP_CURVE_POINT_SELECT && cpt_next->flag & GP_CURVE_POINT_SELECT) {
+ bGPDcurve_point *cpt_new = &temp_curve_points[j + 1];
+ gpencil_editcurve_subdivide_curve_segment(cpt, cpt_next, cpt_new);
+
+ memcpy(&temp_curve_points[j], cpt, sizeof(bGPDcurve_point));
+ memcpy(&temp_curve_points[0], cpt_next, sizeof(bGPDcurve_point));
+
+ cpt_new->flag |= GP_CURVE_POINT_SELECT;
+ cpt_new->bezt.h1 = HD_ALIGN;
+ cpt_new->bezt.h2 = HD_ALIGN;
+ BEZT_SEL_ALL(&cpt_new->bezt);
+ }
+ else if (!prev_subdivided) {
+ memcpy(&temp_curve_points[j], cpt, sizeof(bGPDcurve_point));
+ }
+ }
+ else {
+ bGPDcurve_point *cpt = &gpc->curve_points[old_tot_curve_points - 1];
+ memcpy(&temp_curve_points[j], cpt, sizeof(bGPDcurve_point));
+ }
+
+ MEM_freeN(gpc->curve_points);
+ gpc->curve_points = temp_curve_points;
+ gpc->tot_curve_points = new_tot_curve_points;
+ }
+}
+
+void BKE_gpencil_strokes_selected_update_editcurve(bGPdata *gpd)
+{
+ const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+ /* For all selected strokes, update edit curve. */
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ if (!BKE_gpencil_layer_is_editable(gpl)) {
+ continue;
+ }
+ bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
+ for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
+ if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && is_multiedit)) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ /* skip deselected stroke */
+ if (!(gps->flag & GP_STROKE_SELECT)) {
+ continue;
+ }
+
+ /* Generate the curve if there is none or the stroke was changed */
+ if (gps->editcurve == NULL) {
+ BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps);
+ /* Continue if curve could not be generated. */
+ if (gps->editcurve == NULL) {
+ continue;
+ }
+ }
+ else if (gps->editcurve->flag & GP_CURVE_NEEDS_STROKE_UPDATE) {
+ BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps);
+ }
+ /* Update the selection from the stroke to the curve. */
+ BKE_gpencil_editcurve_stroke_sync_selection(gps, gps->editcurve);
+
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+ }
+ }
+ }
+}
+
+void BKE_gpencil_strokes_selected_sync_selection_editcurve(bGPdata *gpd)
+{
+ const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+ /* Sync selection for all strokes with editcurve. */
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ if (!BKE_gpencil_layer_is_editable(gpl)) {
+ continue;
+ }
+ bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
+ for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
+ if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && is_multiedit)) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ bGPDcurve *gpc = gps->editcurve;
+ if (gpc != NULL) {
+ /* Update the selection of every stroke that has an editcurve */
+ BKE_gpencil_stroke_editcurve_sync_selection(gps, gpc);
+ }
+ }
+ }
+ }
+ }
+}
+
+/** \} */
diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index 66a7ae757a2..d2cfb36cb15 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -45,8 +45,11 @@
#include "DNA_meshdata_types.h"
#include "DNA_scene_types.h"
+#include "BLT_translation.h"
+
#include "BKE_deform.h"
#include "BKE_gpencil.h"
+#include "BKE_gpencil_curve.h"
#include "BKE_gpencil_geom.h"
#include "BKE_main.h"
#include "BKE_material.h"
@@ -189,7 +192,7 @@ BoundBox *BKE_gpencil_boundbox_get(Object *ob)
/* Update orig object's boundbox with re-computed evaluated values. This function can be
* called with the evaluated object and need update the original object bound box data
* to keep both values synchronized. */
- if ((ob_orig != NULL) && (ob != ob_orig)) {
+ if (!ELEM(ob_orig, NULL, ob)) {
if (ob_orig->runtime.bb == NULL) {
ob_orig->runtime.bb = MEM_callocN(sizeof(BoundBox), "GPencil boundbox");
}
@@ -415,10 +418,11 @@ static void stroke_interpolate_deform_weights(
/**
* Resample a stroke
+ * \param gpd: Grease pencil data-block
* \param gps: Stroke to sample
* \param dist: Distance of one segment
*/
-bool BKE_gpencil_stroke_sample(bGPDstroke *gps, const float dist, const bool select)
+bool BKE_gpencil_stroke_sample(bGPdata *gpd, bGPDstroke *gps, const float dist, const bool select)
{
bGPDspoint *pt = gps->points;
bGPDspoint *pt1 = NULL;
@@ -515,7 +519,7 @@ bool BKE_gpencil_stroke_sample(bGPDstroke *gps, const float dist, const bool sel
gps->totpoints = i;
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
return true;
}
@@ -628,13 +632,15 @@ bool BKE_gpencil_stroke_trim_points(bGPDstroke *gps, const int index_from, const
/**
* Split stroke.
+ * \param gpd: Grease pencil data-block
* \param gpf: Grease pencil frame
* \param gps: Grease pencil original stroke
* \param before_index: Position of the point to split
* \param remaining_gps: Secondary stroke after split.
* \return True if the split was done
*/
-bool BKE_gpencil_stroke_split(bGPDframe *gpf,
+bool BKE_gpencil_stroke_split(bGPdata *gpd,
+ bGPDframe *gpf,
bGPDstroke *gps,
const int before_index,
bGPDstroke **remaining_gps)
@@ -684,7 +690,7 @@ bool BKE_gpencil_stroke_split(bGPDframe *gpf,
* Keep the end point. */
BKE_gpencil_stroke_trim_points(gps, 0, old_count);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
return true;
}
@@ -778,7 +784,7 @@ bool BKE_gpencil_stroke_smooth(bGPDstroke *gps, int i, float inf)
/* Only affect endpoints by a fraction of the normal strength,
* to prevent the stroke from shrinking too much
*/
- if ((i == 0) || (i == gps->totpoints - 1)) {
+ if (ELEM(i, 0, gps->totpoints - 1)) {
inf *= 0.1f;
}
@@ -838,7 +844,7 @@ bool BKE_gpencil_stroke_smooth_strength(bGPDstroke *gps, int point_index, float
}
/* Only affect endpoints by a fraction of the normal influence */
float inf = influence;
- if ((point_index == 0) || (point_index == gps->totpoints - 1)) {
+ if (ELEM(point_index, 0, gps->totpoints - 1)) {
inf *= 0.01f;
}
/* Limit max influence to reduce pop effect. */
@@ -902,7 +908,7 @@ bool BKE_gpencil_stroke_smooth_thickness(bGPDstroke *gps, int point_index, float
}
/* Only affect endpoints by a fraction of the normal influence */
float inf = influence;
- if ((point_index == 0) || (point_index == gps->totpoints - 1)) {
+ if (ELEM(point_index, 0, gps->totpoints - 1)) {
inf *= 0.01f;
}
/* Limit max influence to reduce pop effect. */
@@ -1273,14 +1279,31 @@ void BKE_gpencil_stroke_uv_update(bGPDstroke *gps)
/**
* Recalc all internal geometry data for the stroke
+ * \param gpd: Grease pencil data-block
* \param gps: Grease pencil stroke
*/
-void BKE_gpencil_stroke_geometry_update(bGPDstroke *gps)
+void BKE_gpencil_stroke_geometry_update(bGPdata *gpd, bGPDstroke *gps)
{
if (gps == NULL) {
return;
}
+ if (gps->editcurve != NULL) {
+ if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) {
+ /* curve geometry was updated: stroke needs recalculation */
+ if (gps->flag & GP_STROKE_NEEDS_CURVE_UPDATE) {
+ bool is_adaptive = gpd->flag & GP_DATA_CURVE_ADAPTIVE_RESOLUTION;
+ BKE_gpencil_stroke_update_geometry_from_editcurve(
+ gps, gpd->curve_edit_resolution, is_adaptive);
+ gps->flag &= ~GP_STROKE_NEEDS_CURVE_UPDATE;
+ }
+ }
+ else {
+ /* stroke geometry was updated: editcurve needs recalculation */
+ gps->editcurve->flag |= GP_CURVE_NEEDS_STROKE_UPDATE;
+ }
+ }
+
if (gps->totpoints > 2) {
BKE_gpencil_stroke_fill_triangulate(gps);
}
@@ -1326,7 +1349,7 @@ float BKE_gpencil_stroke_length(const bGPDstroke *gps, bool use_3d)
* Trim stroke to the first intersection or loop.
* \param gps: Stroke data
*/
-bool BKE_gpencil_stroke_trim(bGPDstroke *gps)
+bool BKE_gpencil_stroke_trim(bGPdata *gpd, bGPDstroke *gps)
{
if (gps->totpoints < 4) {
return false;
@@ -1402,7 +1425,7 @@ bool BKE_gpencil_stroke_trim(bGPDstroke *gps)
memcpy(dvert->dw, dvert_src->dw, sizeof(MDeformWeight));
}
}
- if (idx == start || idx == end) {
+ if (ELEM(idx, start, end)) {
copy_v3_v3(&pt_new->x, point);
}
}
@@ -1413,7 +1436,7 @@ bool BKE_gpencil_stroke_trim(bGPDstroke *gps)
MEM_SAFE_FREE(old_dvert);
}
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
return intersect;
}
@@ -1509,11 +1532,12 @@ bool BKE_gpencil_stroke_close(bGPDstroke *gps)
/**
* Dissolve points in stroke.
+ * \param gpd: Grease pencil data-block
* \param gpf: Grease pencil frame
* \param gps: Grease pencil stroke
* \param tag: Type of tag for point
*/
-void BKE_gpencil_dissolve_points(bGPDframe *gpf, bGPDstroke *gps, const short tag)
+void BKE_gpencil_dissolve_points(bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps, const short tag)
{
bGPDspoint *pt;
MDeformVert *dvert = NULL;
@@ -1589,7 +1613,7 @@ void BKE_gpencil_dissolve_points(bGPDframe *gpf, bGPDstroke *gps, const short ta
gps->totpoints = tot;
/* triangles cache needs to be recalculated */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
}
@@ -1635,10 +1659,11 @@ void BKE_gpencil_stroke_normal(const bGPDstroke *gps, float r_normal[3])
*
* Ramer - Douglas - Peucker algorithm
* by http ://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
+ * \param gpd: Grease pencil data-block
* \param gps: Grease pencil stroke
* \param epsilon: Epsilon value to define precision of the algorithm
*/
-void BKE_gpencil_stroke_simplify_adaptive(bGPDstroke *gps, float epsilon)
+void BKE_gpencil_stroke_simplify_adaptive(bGPdata *gpd, bGPDstroke *gps, float epsilon)
{
bGPDspoint *old_points = MEM_dupallocN(gps->points);
int totpoints = gps->totpoints;
@@ -1735,7 +1760,7 @@ void BKE_gpencil_stroke_simplify_adaptive(bGPDstroke *gps, float epsilon)
gps->totpoints = j;
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
MEM_SAFE_FREE(old_points);
MEM_SAFE_FREE(old_dvert);
@@ -1744,9 +1769,10 @@ void BKE_gpencil_stroke_simplify_adaptive(bGPDstroke *gps, float epsilon)
/**
* Simplify alternate vertex of stroke except extremes.
+ * \param gpd: Grease pencil data-block
* \param gps: Grease pencil stroke
*/
-void BKE_gpencil_stroke_simplify_fixed(bGPDstroke *gps)
+void BKE_gpencil_stroke_simplify_fixed(bGPdata *gpd, bGPDstroke *gps)
{
if (gps->totpoints < 5) {
return;
@@ -1800,19 +1826,20 @@ void BKE_gpencil_stroke_simplify_fixed(bGPDstroke *gps)
gps->totpoints = j;
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
MEM_SAFE_FREE(old_points);
MEM_SAFE_FREE(old_dvert);
}
/**
- * Subdivide grease pencil stroke.
- * \param gps: Grease pencil stroke
+ * Subdivide a stroke
+ * \param gpd: Grease pencil data-block
+ * \param gps: Stroke
* \param level: Level of subdivision
* \param type: Type of subdivision
*/
-void BKE_gpencil_stroke_subdivide(bGPDstroke *gps, int level, int type)
+void BKE_gpencil_stroke_subdivide(bGPdata *gpd, bGPDstroke *gps, int level, int type)
{
bGPDspoint *temp_points;
MDeformVert *temp_dverts = NULL;
@@ -1921,7 +1948,7 @@ void BKE_gpencil_stroke_subdivide(bGPDstroke *gps, int level, int type)
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
/* Merge by distance ------------------------------------- */
@@ -1930,12 +1957,14 @@ void BKE_gpencil_stroke_subdivide(bGPDstroke *gps, int level, int type)
* Reduce a series of points when the distance is below a threshold.
* Special case for first and last points (both are keeped) for other points,
* the merge point always is at first point.
+ * \param gpd: Grease pencil data-block
* \param gpf: Grease Pencil frame
* \param gps: Grease Pencil stroke
* \param threshold: Distance between points
* \param use_unselected: Set to true to analyze all stroke and not only selected points
*/
-void BKE_gpencil_stroke_merge_distance(bGPDframe *gpf,
+void BKE_gpencil_stroke_merge_distance(bGPdata *gpd,
+ bGPDframe *gpf,
bGPDstroke *gps,
const float threshold,
const bool use_unselected)
@@ -2000,11 +2029,11 @@ void BKE_gpencil_stroke_merge_distance(bGPDframe *gpf,
/* Dissolve tagged points */
if (tagged) {
- BKE_gpencil_dissolve_points(gpf, gps, GP_SPOINT_TAG);
+ BKE_gpencil_dissolve_points(gpd, gpf, gps, GP_SPOINT_TAG);
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
typedef struct GpEdge {
@@ -2093,6 +2122,7 @@ static int gpencil_walk_edge(GHash *v_table,
}
static void gpencil_generate_edgeloops(Object *ob,
+ bGPdata *gpd,
bGPDframe *gpf_stroke,
int stroke_mat_index,
const float angle,
@@ -2218,7 +2248,7 @@ static void gpencil_generate_edgeloops(Object *ob,
pt->strength = 1.0f;
}
- BKE_gpencil_stroke_geometry_update(gps_stroke);
+ BKE_gpencil_stroke_geometry_update(gpd, gps_stroke);
}
/* Free memory. */
@@ -2397,10 +2427,10 @@ bool BKE_gpencil_convert_mesh(Main *bmain,
}
/* If has only 3 points subdivide. */
if (mp->totloop == 3) {
- BKE_gpencil_stroke_subdivide(gps_fill, 1, GP_SUBDIV_SIMPLE);
+ BKE_gpencil_stroke_subdivide(gpd, gps_fill, 1, GP_SUBDIV_SIMPLE);
}
- BKE_gpencil_stroke_geometry_update(gps_fill);
+ BKE_gpencil_stroke_geometry_update(gpd, gps_fill);
}
}
}
@@ -2417,7 +2447,7 @@ bool BKE_gpencil_convert_mesh(Main *bmain,
gpl_stroke, CFRA + frame_offset, GP_GETFRAME_ADD_NEW);
gpencil_generate_edgeloops(
- ob_eval, gpf_stroke, stroke_mat_index, angle, thickness, offset, matrix, use_seams);
+ ob_eval, gpd, gpf_stroke, stroke_mat_index, angle, thickness, offset, matrix, use_seams);
/* Tag for recalculation */
DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
@@ -2457,7 +2487,7 @@ void BKE_gpencil_transform(bGPdata *gpd, const float mat[4][4])
}
/* Distortion may mean we need to re-triangulate. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
}
}
@@ -2549,7 +2579,7 @@ void BKE_gpencil_point_coords_apply(bGPdata *gpd, const GPencilPointCoordinates
}
/* Distortion may mean we need to re-triangulate. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
}
}
@@ -2586,7 +2616,7 @@ void BKE_gpencil_point_coords_apply_with_mat4(bGPdata *gpd,
}
/* Distortion may mean we need to re-triangulate. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
}
}
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index d12e445fe99..09f9e9e891c 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -37,9 +37,12 @@
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "BKE_colortools.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
@@ -54,6 +57,8 @@
#include "MOD_gpencil_modifiertypes.h"
+#include "BLO_read_write.h"
+
#include "CLG_log.h"
static CLG_LogRef LOG = {"bke.gpencil_modifier"};
@@ -411,6 +416,11 @@ void BKE_gpencil_modifierType_panel_id(GpencilModifierType type, char *r_idname)
strcat(r_idname, mti->name);
}
+void BKE_gpencil_modifier_panel_expand(GpencilModifierData *md)
+{
+ md->ui_expand_flag |= UI_PANEL_DATA_EXPAND_ROOT;
+}
+
/**
* Generic grease pencil modifier copy data.
* \param md_src: Source modifier data
@@ -688,7 +698,9 @@ void BKE_gpencil_prepare_eval_data(Depsgraph *depsgraph, Scene *scene, Object *o
}
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_eval);
- const bool do_modifiers = (bool)((!is_multiedit) && (ob->greasepencil_modifiers.first != NULL) &&
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd_eval);
+ const bool do_modifiers = (bool)((!is_multiedit) && (!is_curve_edit) &&
+ (ob->greasepencil_modifiers.first != NULL) &&
(!GPENCIL_SIMPLIFY_MODIF(scene)));
if ((!do_modifiers) && (!do_parent)) {
return;
@@ -724,8 +736,10 @@ void BKE_gpencil_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
bGPdata *gpd = (bGPdata *)ob->data;
const bool is_edit = GPENCIL_ANY_EDIT_MODE(gpd);
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
const bool is_render = (bool)(DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
- const bool do_modifiers = (bool)((!is_multiedit) && (ob->greasepencil_modifiers.first != NULL) &&
+ const bool do_modifiers = (bool)((!is_multiedit) && (!is_curve_edit) &&
+ (ob->greasepencil_modifiers.first != NULL) &&
(!GPENCIL_SIMPLIFY_MODIF(scene)));
if (!do_modifiers) {
return;
@@ -771,3 +785,159 @@ void BKE_gpencil_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
/* Clear any lattice data. */
BKE_gpencil_lattice_clear(ob);
}
+
+void BKE_gpencil_modifier_blend_write(BlendWriter *writer, ListBase *modbase)
+{
+ if (modbase == NULL) {
+ return;
+ }
+
+ LISTBASE_FOREACH (GpencilModifierData *, md, modbase) {
+ const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
+ if (mti == NULL) {
+ return;
+ }
+
+ BLO_write_struct_by_name(writer, mti->struct_name, md);
+
+ if (md->type == eGpencilModifierType_Thick) {
+ ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
+
+ if (gpmd->curve_thickness) {
+ BKE_curvemapping_blend_write(writer, gpmd->curve_thickness);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Noise) {
+ NoiseGpencilModifierData *gpmd = (NoiseGpencilModifierData *)md;
+
+ if (gpmd->curve_intensity) {
+ BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Hook) {
+ HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md;
+
+ if (gpmd->curfalloff) {
+ BKE_curvemapping_blend_write(writer, gpmd->curfalloff);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Tint) {
+ TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
+ if (gpmd->colorband) {
+ BLO_write_struct(writer, ColorBand, gpmd->colorband);
+ }
+ if (gpmd->curve_intensity) {
+ BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Smooth) {
+ SmoothGpencilModifierData *gpmd = (SmoothGpencilModifierData *)md;
+ if (gpmd->curve_intensity) {
+ BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Color) {
+ ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md;
+ if (gpmd->curve_intensity) {
+ BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Opacity) {
+ OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
+ if (gpmd->curve_intensity) {
+ BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
+ }
+ }
+ }
+}
+
+void BKE_gpencil_modifier_blend_read_data(BlendDataReader *reader, ListBase *lb)
+{
+ BLO_read_list(reader, lb);
+
+ LISTBASE_FOREACH (GpencilModifierData *, md, lb) {
+ md->error = NULL;
+
+ /* if modifiers disappear, or for upward compatibility */
+ if (NULL == BKE_gpencil_modifier_get_info(md->type)) {
+ md->type = eModifierType_None;
+ }
+
+ if (md->type == eGpencilModifierType_Lattice) {
+ LatticeGpencilModifierData *gpmd = (LatticeGpencilModifierData *)md;
+ gpmd->cache_data = NULL;
+ }
+ else if (md->type == eGpencilModifierType_Hook) {
+ HookGpencilModifierData *hmd = (HookGpencilModifierData *)md;
+
+ BLO_read_data_address(reader, &hmd->curfalloff);
+ if (hmd->curfalloff) {
+ BKE_curvemapping_blend_read(reader, hmd->curfalloff);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Noise) {
+ NoiseGpencilModifierData *gpmd = (NoiseGpencilModifierData *)md;
+
+ BLO_read_data_address(reader, &gpmd->curve_intensity);
+ if (gpmd->curve_intensity) {
+ BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
+ /* initialize the curve. Maybe this could be moved to modififer logic */
+ BKE_curvemapping_init(gpmd->curve_intensity);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Thick) {
+ ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
+
+ BLO_read_data_address(reader, &gpmd->curve_thickness);
+ if (gpmd->curve_thickness) {
+ BKE_curvemapping_blend_read(reader, gpmd->curve_thickness);
+ BKE_curvemapping_init(gpmd->curve_thickness);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Tint) {
+ TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
+ BLO_read_data_address(reader, &gpmd->colorband);
+ BLO_read_data_address(reader, &gpmd->curve_intensity);
+ if (gpmd->curve_intensity) {
+ BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Smooth) {
+ SmoothGpencilModifierData *gpmd = (SmoothGpencilModifierData *)md;
+ BLO_read_data_address(reader, &gpmd->curve_intensity);
+ if (gpmd->curve_intensity) {
+ BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Color) {
+ ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md;
+ BLO_read_data_address(reader, &gpmd->curve_intensity);
+ if (gpmd->curve_intensity) {
+ BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
+ }
+ }
+ else if (md->type == eGpencilModifierType_Opacity) {
+ OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
+ BLO_read_data_address(reader, &gpmd->curve_intensity);
+ if (gpmd->curve_intensity) {
+ BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
+ }
+ }
+ }
+}
+
+void BKE_gpencil_modifier_blend_read_lib(BlendLibReader *reader, Object *ob)
+{
+ BKE_gpencil_modifiers_foreach_ID_link(ob, BKE_object_modifiers_lib_link_common, reader);
+
+ /* If linking from a library, clear 'local' library override flag. */
+ if (ob->id.lib != NULL) {
+ LISTBASE_FOREACH (GpencilModifierData *, mod, &ob->greasepencil_modifiers) {
+ mod->flag &= ~eGpencilModifierFlag_OverrideLibrary_Local;
+ }
+ }
+}
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index 313b0d192dc..554919ad1a0 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -195,6 +195,8 @@ IDTypeInfo IDType_ID_HA = {
.blend_read_data = hair_blend_read_data,
.blend_read_lib = hair_blend_read_lib,
.blend_read_expand = hair_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
static void hair_random(Hair *hair)
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index bcec90cf0cf..eec9013d067 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -899,8 +899,10 @@ struct Icon_Geom *BKE_icon_geom_from_file(const char *filename)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Studio Light Icon
* \{ */
+
int BKE_icon_ensure_studio_light(struct StudioLight *sl, int id_type)
{
int icon_id = get_next_free_id();
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 113d4cf50d7..b0991f1d343 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -68,9 +68,7 @@ static size_t idp_size_table[] = {
};
/* -------------------------------------------------------------------- */
-/* Array Functions */
-
-/** \name IDP Array API
+/** \name Array Functions (IDP Array API)
* \{ */
#define GETPROP(prop, i) &(IDP_IDPArray(prop)[i])
@@ -323,9 +321,7 @@ static IDProperty *IDP_CopyArray(const IDProperty *prop, const int flag)
/** \} */
/* -------------------------------------------------------------------- */
-/* String Functions */
-
-/** \name IDProperty String API
+/** \name String Functions (IDProperty String API)
* \{ */
/**
@@ -439,9 +435,7 @@ void IDP_FreeString(IDProperty *prop)
/** \} */
/* -------------------------------------------------------------------- */
-/* ID Type */
-
-/** \name IDProperty ID API
+/** \name ID Type (IDProperty ID API)
* \{ */
static IDProperty *IDP_CopyID(const IDProperty *prop, const int flag)
@@ -477,9 +471,7 @@ void IDP_AssignID(IDProperty *prop, ID *id, const int flag)
/** \} */
/* -------------------------------------------------------------------- */
-/* Group Functions */
-
-/** \name IDProperty Group API
+/** \name Group Functions (IDProperty Group API)
* \{ */
/**
@@ -760,10 +752,9 @@ static void IDP_FreeGroup(IDProperty *prop, const bool do_id_user)
/** \} */
/* -------------------------------------------------------------------- */
-/* Main Functions */
-
-/** \name IDProperty Main API
+/** \name Main Functions (IDProperty Main API)
* \{ */
+
IDProperty *IDP_CopyProperty_ex(const IDProperty *prop, const int flag)
{
switch (prop->type) {
@@ -800,43 +791,6 @@ void IDP_CopyPropertyContent(IDProperty *dst, IDProperty *src)
IDP_FreeProperty(idprop_tmp);
}
-/* Updates ID pointers after an object has been copied */
-/* TODO Nuke this once its only user has been correctly converted
- * to use generic ID management from BKE_library! */
-void IDP_RelinkProperty(struct IDProperty *prop)
-{
- if (!prop) {
- return;
- }
-
- switch (prop->type) {
- case IDP_GROUP: {
- LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
- IDP_RelinkProperty(loop);
- }
- break;
- }
- case IDP_IDPARRAY: {
- IDProperty *idp_array = IDP_Array(prop);
- for (int i = 0; i < prop->len; i++) {
- IDP_RelinkProperty(&idp_array[i]);
- }
- break;
- }
- case IDP_ID: {
- ID *id = IDP_Id(prop);
- if (id && id->newid) {
- id_us_min(IDP_Id(prop));
- prop->data.pointer = id->newid;
- id_us_plus(IDP_Id(prop));
- }
- break;
- }
- default:
- break; /* Nothing to do for other IDProp types. */
- }
-}
-
/**
* Get the Group property that contains the id properties for ID id. Set create_if_needed
* to create the Group property and attach it to id if it doesn't exist; otherwise
@@ -961,7 +915,7 @@ bool IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
* This function takes three arguments: the ID property type, a union which defines
* its initial value, and a name.
*
- * The union is simple to use; see the top of this header file for its definition.
+ * The union is simple to use; see the top of BKE_idprop.h for its definition.
* An example of using this function:
*
* \code{.c}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 187908573dd..cd2ed32cd4f 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -84,7 +84,6 @@
#include "BKE_packedFile.h"
#include "BKE_report.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h" /* seq_foreground_frame_get() */
#include "BKE_workspace.h"
#include "BLF_api.h"
@@ -93,6 +92,8 @@
#include "RE_pipeline.h"
+#include "SEQ_sequencer.h" /* seq_foreground_frame_get() */
+
#include "GPU_texture.h"
#include "BLI_sys_types.h" /* for intptr_t support */
@@ -324,6 +325,8 @@ IDTypeInfo IDType_ID_IM = {
.blend_read_data = image_blend_read_data,
.blend_read_lib = image_blend_read_lib,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
/* prototypes */
@@ -665,7 +668,7 @@ ImageTile *BKE_image_get_tile(Image *ima, int tile_number)
/* Tile number 0 is a special case and refers to the first tile, typically
* coming from non-UDIM-aware code. */
- if (tile_number == 0 || tile_number == 1001) {
+ if (ELEM(tile_number, 0, 1001)) {
return ima->tiles.first;
}
@@ -802,7 +805,7 @@ Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exist
/* first search an identical filepath */
for (ima = bmain->images.first; ima; ima = ima->id.next) {
- if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) {
+ if (!ELEM(ima->source, IMA_SRC_VIEWER, IMA_SRC_GENERATED)) {
STRNCPY(strtest, ima->filepath);
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &ima->id));
@@ -1313,7 +1316,7 @@ int BKE_image_imtype_to_ftype(const char imtype, ImbFormatOptions *r_options)
return IMB_FTYPE_TIF;
}
#endif
- if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) {
+ if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
return IMB_FTYPE_OPENEXR;
}
#ifdef WITH_CINEON
@@ -1338,7 +1341,7 @@ int BKE_image_imtype_to_ftype(const char imtype, ImbFormatOptions *r_options)
char BKE_image_ftype_to_imtype(const int ftype, const ImbFormatOptions *options)
{
- if (ftype == 0) {
+ if (ftype == IMB_FTYPE_NONE) {
return R_IMF_IMTYPE_TARGA;
}
if (ftype == IMB_FTYPE_IMAGIC) {
@@ -1663,7 +1666,7 @@ static bool do_add_image_extension(char *string,
}
#endif
#ifdef WITH_OPENEXR
- else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) {
+ else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
if (!BLI_path_extension_check(string, extension_test = ".exr")) {
extension = extension_test;
}
@@ -2950,13 +2953,11 @@ void BKE_imbuf_write_prepare(ImBuf *ibuf, const ImageFormatData *imf)
int BKE_imbuf_write(ImBuf *ibuf, const char *name, const ImageFormatData *imf)
{
- int ok;
-
BKE_imbuf_write_prepare(ibuf, imf);
BLI_make_existing_file(name);
- ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
+ const bool ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
if (ok == 0) {
perror(name);
}
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index 877747a257e..ceb13c4955e 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -379,10 +379,16 @@ static void checker_board_text(
const float text_color[4] = {0.0, 0.0, 0.0, 1.0};
const float text_outline[4] = {1.0, 1.0, 1.0, 1.0};
+ const char char_array[36] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+ int first_char_index = 0;
for (y = 0; y < height; y += step) {
- text[1] = '1';
+ text[0] = char_array[first_char_index];
+ int second_char_index = 27;
for (x = 0; x < width; x += step) {
+ text[1] = char_array[second_char_index];
+
/* hard coded offset */
pen_x = x + 33;
pen_y = y + 44;
@@ -412,9 +418,9 @@ static void checker_board_text(
BLF_position(mono, pen_x, pen_y, 0.0);
BLF_draw_buffer(mono, text, 2);
- text[1]++;
+ second_char_index = (second_char_index + 1) % ARRAY_SIZE(char_array);
}
- text[0]++;
+ first_char_index = (first_char_index + 1) % ARRAY_SIZE(char_array);
}
/* cleanup the buffer. */
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 1a87b931689..9696d920640 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -52,6 +52,7 @@
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
+#include "BLI_endian_switch.h"
#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
@@ -68,12 +69,15 @@
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_nla.h"
-#include "BKE_sequencer.h"
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
+#include "SEQ_sequencer.h"
+
+#include "BLO_read_write.h"
+
#ifdef WIN32
# include "BLI_math_base.h" /* M_PI */
#endif
@@ -109,6 +113,69 @@ static void ipo_free_data(ID *id)
}
}
+static void ipo_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ Ipo *ipo = (Ipo *)id;
+
+ BLO_read_list(reader, &(ipo->curve));
+
+ LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
+ 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);
+ 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);
+ }
+}
+
+static void ipo_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+ Ipo *ipo = (Ipo *)id;
+
+ LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
+ if (icu->driver) {
+ BLO_read_id_address(reader, ipo->id.lib, &icu->driver->ob);
+ }
+ }
+}
+
+static void ipo_blend_read_expand(BlendExpander *expander, ID *id)
+{
+ Ipo *ipo = (Ipo *)id;
+
+ LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
+ if (icu->driver) {
+ BLO_expand(expander, icu->driver->ob);
+ }
+ }
+}
+
IDTypeInfo IDType_ID_IP = {
.id_code = ID_IP,
.id_filter = 0,
@@ -128,9 +195,11 @@ IDTypeInfo IDType_ID_IP = {
.foreach_cache = NULL,
.blend_write = NULL,
- .blend_read_data = NULL,
- .blend_read_lib = NULL,
- .blend_read_expand = NULL,
+ .blend_read_data = ipo_blend_read_data,
+ .blend_read_lib = ipo_blend_read_lib,
+ .blend_read_expand = ipo_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
/* *************************************************** */
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 95a8419b95d..7468112b40e 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -214,6 +214,8 @@ IDTypeInfo IDType_ID_KE = {
.blend_read_data = shapekey_blend_read_data,
.blend_read_lib = shapekey_blend_read_lib,
.blend_read_expand = shapekey_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
#define KEY_MODE_DUMMY 0 /* use where mode isn't checked for */
@@ -1614,7 +1616,7 @@ int BKE_keyblock_element_count_from_shape(const Key *key, const int shape_index)
int result = 0;
int index = 0;
for (const KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) {
- if ((shape_index == -1) || (index == shape_index)) {
+ if (ELEM(shape_index, -1, index)) {
result += kb->totelem;
}
}
@@ -1654,7 +1656,7 @@ void BKE_keyblock_data_get_from_shape(const Key *key, float (*arr)[3], const int
uint8_t *elements = (uint8_t *)arr;
int index = 0;
for (const KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) {
- if ((shape_index == -1) || (index == shape_index)) {
+ if (ELEM(shape_index, -1, index)) {
const int block_elem_len = kb->totelem * key->elemsize;
memcpy(elements, kb->data, block_elem_len);
elements += block_elem_len;
@@ -1684,7 +1686,7 @@ void BKE_keyblock_data_set_with_mat4(Key *key,
int index = 0;
for (KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) {
- if ((shape_index == -1) || (index == shape_index)) {
+ if (ELEM(shape_index, -1, index)) {
const int block_elem_len = kb->totelem;
float(*block_data)[3] = (float(*)[3])kb->data;
for (int data_offset = 0; data_offset < block_elem_len; ++data_offset) {
@@ -1708,7 +1710,7 @@ void BKE_keyblock_curve_data_set_with_mat4(
int index = 0;
for (KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) {
- if ((shape_index == -1) || (index == shape_index)) {
+ if (ELEM(shape_index, -1, index)) {
const int block_elem_size = kb->totelem * key->elemsize;
BKE_keyblock_curve_data_transform(nurb, mat, elements, kb->data);
elements += block_elem_size;
@@ -1724,7 +1726,7 @@ void BKE_keyblock_data_set(Key *key, const int shape_index, const void *data)
const uint8_t *elements = data;
int index = 0;
for (KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) {
- if ((shape_index == -1) || (index == shape_index)) {
+ if (ELEM(shape_index, -1, index)) {
const int block_elem_size = kb->totelem * key->elemsize;
memcpy(kb->data, elements, block_elem_size);
elements += block_elem_size;
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index c0eb6b4b134..74f78106be5 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -203,6 +203,8 @@ IDTypeInfo IDType_ID_LT = {
.blend_read_data = lattice_blend_read_data,
.blend_read_lib = lattice_blend_read_lib,
.blend_read_expand = lattice_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
int BKE_lattice_index_from_uvw(Lattice *lt, const int u, const int v, const int w)
diff --git a/source/blender/blenkernel/intern/lattice_deform.c b/source/blender/blenkernel/intern/lattice_deform.c
index 382661ff070..14c600caa46 100644
--- a/source/blender/blenkernel/intern/lattice_deform.c
+++ b/source/blender/blenkernel/intern/lattice_deform.c
@@ -169,7 +169,7 @@ void BKE_lattice_deform_data_eval_co(LatticeDeformData *lattice_deform_data,
int ui, vi, wi, uu, vv, ww;
/* vgroup influence */
- float co_prev[3], weight_blend = 0.0f;
+ float co_prev[4] = {0}, weight_blend = 0.0f;
copy_v3_v3(co_prev, co);
#ifdef __SSE2__
__m128 co_vec = _mm_loadu_ps(co_prev);
diff --git a/source/blender/blenkernel/intern/lattice_deform_test.cc b/source/blender/blenkernel/intern/lattice_deform_test.cc
index 7db9d941458..f08d0349598 100644
--- a/source/blender/blenkernel/intern/lattice_deform_test.cc
+++ b/source/blender/blenkernel/intern/lattice_deform_test.cc
@@ -83,7 +83,7 @@ static void test_lattice_deform_free(LatticeDeformTestContext *ctx)
TEST(lattice_deform_performance, performance_no_dvert_1)
{
const int32_t num_items = 1;
- LatticeDeformTestContext ctx = {{{0}}};
+ LatticeDeformTestContext ctx = {{{nullptr}}};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
@@ -92,7 +92,7 @@ TEST(lattice_deform_performance, performance_no_dvert_1)
TEST(lattice_deform_performance, performance_no_dvert_1000)
{
const int32_t num_items = 1000;
- LatticeDeformTestContext ctx = {{{0}}};
+ LatticeDeformTestContext ctx = {{{nullptr}}};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
@@ -101,7 +101,7 @@ TEST(lattice_deform_performance, performance_no_dvert_1000)
TEST(lattice_deform_performance, performance_no_dvert_10000)
{
const int32_t num_items = 10000;
- LatticeDeformTestContext ctx = {{{0}}};
+ LatticeDeformTestContext ctx = {{{nullptr}}};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
@@ -110,7 +110,7 @@ TEST(lattice_deform_performance, performance_no_dvert_10000)
TEST(lattice_deform_performance, performance_no_dvert_100000)
{
const int32_t num_items = 100000;
- LatticeDeformTestContext ctx = {{{0}}};
+ LatticeDeformTestContext ctx = {{{nullptr}}};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
@@ -119,7 +119,7 @@ TEST(lattice_deform_performance, performance_no_dvert_100000)
TEST(lattice_deform_performance, performance_no_dvert_1000000)
{
const int32_t num_items = 1000000;
- LatticeDeformTestContext ctx = {{{0}}};
+ LatticeDeformTestContext ctx = {{{nullptr}}};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
@@ -128,7 +128,7 @@ TEST(lattice_deform_performance, performance_no_dvert_1000000)
TEST(lattice_deform_performance, performance_no_dvert_10000000)
{
const int32_t num_items = 10000000;
- LatticeDeformTestContext ctx = {{{0}}};
+ LatticeDeformTestContext ctx = {{{nullptr}}};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 6efc9d0753e..0757cf791b7 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -18,6 +18,9 @@
* \ingroup bke
*/
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#include <string.h>
#include "BLI_listbase.h"
@@ -56,6 +59,8 @@
#include "MEM_guardedalloc.h"
+#include "BLO_read_write.h"
+
/* Set of flags which are dependent on a collection settings. */
static const short g_base_collection_flags = (BASE_VISIBLE_DEPSGRAPH | BASE_VISIBLE_VIEWLAYER |
BASE_SELECTABLE | BASE_ENABLED_VIEWPORT |
@@ -362,7 +367,13 @@ static void view_layer_bases_hash_create(ViewLayer *view_layer)
LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object) {
- BLI_ghash_insert(hash, base->object, base);
+ /* Some processes, like ID remapping, may lead to having several bases with the same
+ * object. So just take the first one here, and ignore all others
+ * (#BKE_layer_collection_sync will clean this up anyway). */
+ void **val_pp;
+ if (!BLI_ghash_ensure_p(hash, base->object, &val_pp)) {
+ *val_pp = base;
+ }
}
}
@@ -1445,12 +1456,9 @@ static LayerCollection *find_layer_collection_by_scene_collection(LayerCollectio
LayerCollection *BKE_layer_collection_first_from_scene_collection(ViewLayer *view_layer,
const Collection *collection)
{
- for (LayerCollection *layer_collection = view_layer->layer_collections.first;
- layer_collection != NULL;
- layer_collection = layer_collection->next) {
+ LISTBASE_FOREACH (LayerCollection *, layer_collection, &view_layer->layer_collections) {
LayerCollection *found = find_layer_collection_by_scene_collection(layer_collection,
collection);
-
if (found != NULL) {
return found;
}
@@ -1830,3 +1838,117 @@ void BKE_layer_eval_view_layer_indexed(struct Depsgraph *depsgraph,
BLI_assert(view_layer != NULL);
layer_eval_view_layer(depsgraph, scene, view_layer);
}
+
+static void write_layer_collections(BlendWriter *writer, ListBase *lb)
+{
+ LISTBASE_FOREACH (LayerCollection *, lc, lb) {
+ BLO_write_struct(writer, LayerCollection, lc);
+
+ write_layer_collections(writer, &lc->layer_collections);
+ }
+}
+
+void BKE_view_layer_blend_write(BlendWriter *writer, ViewLayer *view_layer)
+{
+ BLO_write_struct(writer, ViewLayer, view_layer);
+ BLO_write_struct_list(writer, Base, &view_layer->object_bases);
+
+ if (view_layer->id_properties) {
+ IDP_BlendWrite(writer, view_layer->id_properties);
+ }
+
+ LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
+ BLO_write_struct(writer, FreestyleModuleConfig, fmc);
+ }
+
+ LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
+ BLO_write_struct(writer, FreestyleLineSet, fls);
+ }
+ write_layer_collections(writer, &view_layer->layer_collections);
+}
+
+static void direct_link_layer_collections(BlendDataReader *reader, ListBase *lb, bool master)
+{
+ BLO_read_list(reader, lb);
+ LISTBASE_FOREACH (LayerCollection *, lc, lb) {
+#ifdef USE_COLLECTION_COMPAT_28
+ BLO_read_data_address(reader, &lc->scene_collection);
+#endif
+
+ /* Master collection is not a real data-lock. */
+ if (master) {
+ BLO_read_data_address(reader, &lc->collection);
+ }
+
+ direct_link_layer_collections(reader, &lc->layer_collections, false);
+ }
+}
+
+void BKE_view_layer_blend_read_data(BlendDataReader *reader, ViewLayer *view_layer)
+{
+ view_layer->stats = NULL;
+ BLO_read_list(reader, &view_layer->object_bases);
+ BLO_read_data_address(reader, &view_layer->basact);
+
+ direct_link_layer_collections(reader, &view_layer->layer_collections, true);
+ BLO_read_data_address(reader, &view_layer->active_collection);
+
+ BLO_read_data_address(reader, &view_layer->id_properties);
+ IDP_BlendDataRead(reader, &view_layer->id_properties);
+
+ BLO_read_list(reader, &(view_layer->freestyle_config.modules));
+ BLO_read_list(reader, &(view_layer->freestyle_config.linesets));
+
+ BLI_listbase_clear(&view_layer->drawdata);
+ view_layer->object_bases_array = NULL;
+ view_layer->object_bases_hash = NULL;
+}
+
+static void lib_link_layer_collection(BlendLibReader *reader,
+ Library *lib,
+ LayerCollection *layer_collection,
+ bool master)
+{
+ /* Master collection is not a real data-lock. */
+ if (!master) {
+ BLO_read_id_address(reader, lib, &layer_collection->collection);
+ }
+
+ LISTBASE_FOREACH (
+ LayerCollection *, layer_collection_nested, &layer_collection->layer_collections) {
+ lib_link_layer_collection(reader, lib, layer_collection_nested, false);
+ }
+}
+
+void BKE_view_layer_blend_read_lib(BlendLibReader *reader, Library *lib, ViewLayer *view_layer)
+{
+ LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
+ BLO_read_id_address(reader, lib, &fmc->script);
+ }
+
+ LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
+ BLO_read_id_address(reader, lib, &fls->linestyle);
+ BLO_read_id_address(reader, lib, &fls->group);
+ }
+
+ LISTBASE_FOREACH_MUTABLE (Base *, base, &view_layer->object_bases) {
+ /* we only bump the use count for the collection objects */
+ BLO_read_id_address(reader, lib, &base->object);
+
+ if (base->object == NULL) {
+ /* Free in case linked object got lost. */
+ BLI_freelinkN(&view_layer->object_bases, base);
+ if (view_layer->basact == base) {
+ view_layer->basact = NULL;
+ }
+ }
+ }
+
+ LISTBASE_FOREACH (LayerCollection *, layer_collection, &view_layer->layer_collections) {
+ lib_link_layer_collection(reader, lib, layer_collection, true);
+ }
+
+ BLO_read_id_address(reader, lib, &view_layer->mat_override);
+
+ IDP_BlendReadLib(reader, view_layer->id_properties);
+}
diff --git a/source/blender/blenkernel/intern/layer_utils.c b/source/blender/blenkernel/intern/layer_utils.c
index 513bc9e1420..974a5a24e8a 100644
--- a/source/blender/blenkernel/intern/layer_utils.c
+++ b/source/blender/blenkernel/intern/layer_utils.c
@@ -192,4 +192,32 @@ bool BKE_view_layer_filter_edit_mesh_has_edges(Object *ob, void *UNUSED(user_dat
return false;
}
+/**
+ * Use this in rare cases we need to detect a pair of objects (active, selected).
+ * This returns the other non-active selected object.
+ *
+ * Returns NULL with it finds multiple other selected objects
+ * as behavior in this case would be random from the user perspective.
+ */
+Object *BKE_view_layer_non_active_selected_object(struct ViewLayer *view_layer,
+ const struct View3D *v3d)
+{
+ Object *ob_active = OBACT(view_layer);
+ Object *ob_result = NULL;
+ FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob_iter) {
+ if (ob_iter == ob_active) {
+ continue;
+ }
+
+ if (ob_result == NULL) {
+ ob_result = ob_iter;
+ }
+ else {
+ ob_result = NULL;
+ break;
+ }
+ }
+ FOREACH_SELECTED_OBJECT_END;
+ return ob_result;
+}
/** \} */
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index b0f38001d01..21a77e2b45a 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -101,6 +101,15 @@ IDTypeInfo IDType_ID_LINK_PLACEHOLDER = {
.copy_data = NULL,
.free_data = NULL,
.make_local = NULL,
+ .foreach_id = NULL,
+ .foreach_cache = NULL,
+
+ .blend_write = NULL,
+ .blend_read_data = NULL,
+ .blend_read_lib = NULL,
+ .blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
/* GS reads the memory pointed at in a specific ordering.
@@ -1322,7 +1331,7 @@ void id_sort_by_name(ListBase *lb, ID *id, ID *id_sorting_hint)
BLI_remlink(lb, id);
/* Check if we can actually insert id before or after id_sorting_hint, if given. */
- if (id_sorting_hint != NULL && id_sorting_hint != id) {
+ if (!ELEM(id_sorting_hint, NULL, id)) {
BLI_assert(BLI_findindex(lb, id_sorting_hint) >= 0);
ID *id_sorting_hint_next = id_sorting_hint->next;
@@ -1560,7 +1569,7 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name, ID **r_id_sorting_
char base_name_test[MAX_ID_NAME - 2];
int number_test;
if ((id != id_test) && !ID_IS_LINKED(id_test) && (name[0] == id_test->name[2]) &&
- (id_test->name[base_name_len + 2] == '.' || id_test->name[base_name_len + 2] == '\0') &&
+ (ELEM(id_test->name[base_name_len + 2], '.', '\0')) &&
STREQLEN(name, id_test->name + 2, base_name_len) &&
(BLI_split_name_num(base_name_test, &number_test, id_test->name + 2, '.') ==
base_name_len)) {
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index f19ab96588e..e6f0e5e1199 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -129,8 +129,8 @@ void BKE_lib_override_library_copy(ID *dst_id, const ID *src_id, const bool do_f
BKE_lib_override_library_init(dst_id, NULL);
}
- /* Source is already overriding data, we copy it but reuse its reference for dest ID.
- * otherwise, source is only an override template, it then becomes reference of dest ID. */
+ /* If source is already overriding data, we copy it but reuse its reference for dest ID.
+ * Otherwise, source is only an override template, it then becomes reference of dest ID. */
dst_id->override_library->reference = src_id->override_library->reference ?
src_id->override_library->reference :
(ID *)src_id;
@@ -232,7 +232,7 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain,
FOREACH_MAIN_ID_BEGIN (bmain, other_id) {
if ((other_id->tag & LIB_TAG_DOIT) != 0 && other_id->lib == NULL) {
/* Note that using ID_REMAP_SKIP_INDIRECT_USAGE below is superfluous, as we only remap
- * local IDs usages anyway... */
+ * local IDs usages anyway. */
BKE_libblock_relink_ex(bmain,
other_id,
reference_id,
@@ -256,7 +256,7 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain,
/**
* Create overridden local copies of all tagged data-blocks in given Main.
*
- * \note Set id->newid of overridden libs with newly created overrides,
+ * \note Set `id->newid` of overridden libs with newly created overrides,
* caller is responsible to clean those pointers before/after usage as needed.
*
* \note By default, it will only remap newly created local overriding data-blocks between
@@ -289,13 +289,14 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain)
for (todo_id_iter = todo_ids.first; todo_id_iter != NULL; todo_id_iter = todo_id_iter->next) {
reference_id = todo_id_iter->data;
if (reference_id->newid == NULL) {
- /* If newid is already set, assume it has been handled by calling code.
+ /* If `newid` is already set, assume it has been handled by calling code.
* Only current use case: re-using proxy ID when converting to liboverride. */
if ((reference_id->newid = lib_override_library_create_from(bmain, reference_id)) == NULL) {
success = false;
break;
}
- } /* We also tag the new IDs so that in next step we can remap their pointers too. */
+ }
+ /* We also tag the new IDs so that in next step we can remap their pointers too. */
reference_id->newid->tag |= LIB_TAG_DOIT;
Key *reference_key;
@@ -333,7 +334,7 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain)
FOREACH_MAIN_ID_BEGIN (bmain, other_id) {
if ((other_id->tag & LIB_TAG_DOIT) != 0 && other_id->lib == NULL) {
/* Note that using ID_REMAP_SKIP_INDIRECT_USAGE below is superfluous, as we only remap
- * local IDs usages anyway... */
+ * local IDs usages anyway. */
BKE_libblock_relink_ex(bmain,
other_id,
reference_id,
@@ -381,7 +382,7 @@ static bool lib_override_hierarchy_recursive_tag(Main *bmain,
id->tag |= tag;
}
- /* This way we won't process again that ID should we encounter it again through another
+ /* This way we won't process again that ID, should we encounter it again through another
* relationship hierarchy.
* Note that this does not free any memory from relations, so we can still use the entries.
*/
@@ -436,7 +437,7 @@ void BKE_lib_override_library_dependencies_tag(Main *bmain,
/**
* Tag all IDs in given \a bmain that are part of the same \a id_root liboverride ID group.
- * That is, all other liboverrides IDs (in)directly used by \a is_root one, sharing the same
+ * That is, all other liboverride IDs (in)directly used by \a is_root one, and sharing the same
* library for their reference IDs.
*
* \param id_root: The root of the hierarchy of liboverride dependencies to be tagged.
@@ -481,8 +482,7 @@ static int lib_override_library_make_tag_ids_cb(LibraryIDLinkCallbackData *cb_da
BLI_assert(id_owner->lib == library_root);
if (id->tag & LIB_TAG_DOIT) {
- /* Already processed, but maybe not with the same chain of dependency, so we need to check that
- * one nonetheless. */
+ /* Already processed and tagged, nothing else to do here. */
return IDWALK_RET_STOP_RECURSION;
}
@@ -492,7 +492,7 @@ static int lib_override_library_make_tag_ids_cb(LibraryIDLinkCallbackData *cb_da
}
/* We tag all collections and objects for override. And we also tag all other data-blocks which
- * would user one of those. */
+ * would use one of those. */
if (ELEM(GS(id->name), ID_OB, ID_GR)) {
id->tag |= LIB_TAG_DOIT;
}
@@ -502,12 +502,12 @@ static int lib_override_library_make_tag_ids_cb(LibraryIDLinkCallbackData *cb_da
static bool lib_override_library_create_do(Main *bmain, ID *id_root)
{
- /* Tag all collections and objects, as well as other IDs using them. */
id_root->tag |= LIB_TAG_DOIT;
BKE_main_relations_create(bmain, 0);
if (ELEM(GS(id_root->name), ID_OB, ID_GR)) {
+ /* Tag all collections and objects. */
BKE_library_foreach_ID_link(bmain,
id_root,
lib_override_library_make_tag_ids_cb,
@@ -515,7 +515,7 @@ static bool lib_override_library_create_do(Main *bmain, ID *id_root)
IDWALK_READONLY | IDWALK_RECURSE);
/* Then, we remove (untag) bone shape objects, you shall never want to override those
- * (hopefully)... */
+ * (hopefully). */
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
if (ob->type == OB_ARMATURE && ob->pose != NULL && (ob->id.tag & LIB_TAG_DOIT)) {
for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan != NULL; pchan = pchan->next) {
@@ -527,6 +527,10 @@ static bool lib_override_library_create_do(Main *bmain, ID *id_root)
}
}
+ /* Now tag all non-object/collection IDs 'in-between' two tagged ones, as those are part of an
+ * override chain and therefore also need to be overridden.
+ * One very common cases are e.g. drivers on geometry or materials of an overridden object, that
+ * are using another overridden object as parameter. */
/* Note that this call will also free the main relations data we created above. */
BKE_lib_override_library_dependencies_tag(bmain, id_root, LIB_TAG_DOIT, false);
@@ -636,16 +640,13 @@ static void lib_override_library_create_post_process(
* \note Currently it only does special things if given \a id_root is an object of collection, more
* specific behaviors may be added in the future for other ID types.
*
- * \note It will overrides all IDs tagged with \a LIB_TAG_DOIT, and it does not clear that tag at
+ * \note It will override all IDs tagged with \a LIB_TAG_DOIT, and it does not clear that tag at
* its beginning, so caller code can add extra data-blocks to be overridden as well.
*
- * \note In the future that same function may be extended to support 'refresh' of overrides
- * (rebuilding overrides from linked data, trying to preserve local overrides already defined).
- *
* \param id_root: The root ID to create an override from.
* \param id_reference: Some reference ID used to do some post-processing after overrides have been
- * created, may be NULL. Typically, the Empty object instantiating the linked
- * collection we override, currently.
+ * created, may be NULL. Typically, the Empty object instantiating the linked collection we
+ * override, currently.
* \return true if override was successfully created.
*/
bool BKE_lib_override_library_create(
@@ -667,10 +668,10 @@ bool BKE_lib_override_library_create(
}
/**
- * Converts a given proxy object into a library override.
+ * Convert a given proxy object into a library override.
*
- * \note This is actually a thin wrapper around \a BKE_lib_override_library_create, only extra work
- * is to actually convert the proxy itself into an override first.
+ * \note This is a thin wrapper around \a BKE_lib_override_library_create, only extra work is to
+ * actually convert the proxy itself into an override first.
*
* \return true if override was successfully created.
*/
@@ -679,7 +680,7 @@ bool BKE_lib_override_library_proxy_convert(Main *bmain,
ViewLayer *view_layer,
Object *ob_proxy)
{
- /* proxy_group, if defined, is the empty instantiating the collection from which the proxy is
+ /* `proxy_group`, if defined, is the empty instantiating the collection from which the proxy is
* coming. */
Object *ob_proxy_group = ob_proxy->proxy_group;
const bool is_override_instancing_object = ob_proxy_group != NULL;
@@ -688,7 +689,8 @@ bool BKE_lib_override_library_proxy_convert(Main *bmain,
ID *id_reference = is_override_instancing_object ? &ob_proxy_group->id : &ob_proxy->id;
/* We manually convert the proxy object into a library override, further override handling will
- * then be handled by BKE_lib_override_library_create() just as for a regular override creation.
+ * then be handled by `BKE_lib_override_library_create()` just as for a regular override
+ * creation.
*/
ob_proxy->proxy->id.tag |= LIB_TAG_DOIT;
ob_proxy->proxy->id.newid = &ob_proxy->id;
@@ -728,7 +730,7 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_
if (id->tag & LIB_TAG_DOIT && ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
/* While this should not happen in typical cases (and won't be properly supported here), user
* is free to do all kind of very bad things, including having different local overrides of a
- * same linked ID in a same hierarchy... */
+ * same linked ID in a same hierarchy. */
if (!BLI_ghash_haskey(linkedref_to_old_override, id->override_library->reference)) {
BLI_ghash_insert(linkedref_to_old_override, id->override_library->reference, id);
id->override_library->reference->tag |= LIB_TAG_DOIT;
@@ -738,7 +740,7 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_
FOREACH_MAIN_ID_END;
/* Make new override from linked data. */
- /* Note that this call also remap all pointers of tagged IDs from old override IDs to new
+ /* Note that this call also remaps all pointers of tagged IDs from old override IDs to new
* override IDs (including within the old overrides themselves, since those are tagged too
* above). */
const bool success = lib_override_library_create_do(bmain, id_root_reference);
@@ -755,12 +757,12 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_
ID *id_override_old = BLI_ghash_lookup(linkedref_to_old_override, id);
if (id_override_old != NULL) {
- /* Swap the names between old override ID and new one. */
+ /* Swap the names between old override ID and new one. */
char id_name_buf[MAX_ID_NAME];
memcpy(id_name_buf, id_override_old->name, sizeof(id_name_buf));
memcpy(id_override_old->name, id_override_new->name, sizeof(id_override_old->name));
memcpy(id_override_new->name, id_name_buf, sizeof(id_override_new->name));
- /* Note that this is very efficient way to keep BMain IDs ordered as expected after
+ /* Note that this is a very efficient way to keep BMain IDs ordered as expected after
* swapping their names.
* However, one has to be very careful with this when iterating over the listbase at the
* same time. Here it works because we only execute this code when we are in the linked
@@ -816,7 +818,7 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_
* This improves performances anyway, so everything is fine. */
FOREACH_MAIN_ID_BEGIN (bmain, id) {
if (id->tag & LIB_TAG_DOIT) {
- /* Note that this work because linked IDs are always after local ones (including overrides),
+ /* Note that this works because linked IDs are always after local ones (including overrides),
* so we will only ever tag an old override ID after we have already checked it in this loop,
* hence we cannot untag it later. */
if (id->newid != NULL && ID_IS_LINKED(id)) {
@@ -833,7 +835,8 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_
FOREACH_MAIN_ID_END;
BKE_id_multi_tagged_delete(bmain);
- /* At this point, id_root has very likely been deleted, we need to update it to its new version.
+ /* At this point, `id_root` has very likely been deleted, we need to update it to its new
+ * version.
*/
id_root = id_root_reference->newid;
@@ -855,7 +858,7 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_
*
* \note All IDs tagged with `LIB_TAG_DOIT` will be deleted.
*
- * \param id_root: The root liboverride ID to resync from.
+ * \param id_root: The root liboverride ID to delete.
*/
void BKE_lib_override_library_delete(Main *bmain, ID *id_root)
{
@@ -864,8 +867,7 @@ void BKE_lib_override_library_delete(Main *bmain, ID *id_root)
/* Tag all collections and objects, as well as other IDs using them. */
id_root->tag |= LIB_TAG_DOIT;
- /* Make a mapping 'linked reference IDs' -> 'Local override IDs' of existing overrides, and tag
- * linked reference ones to be overridden again. */
+ /* Tag all library overrides in the chains of dependencies from the given root one. */
BKE_lib_override_library_override_group_tag(bmain, id_root, LIB_TAG_DOIT, true);
ID *id;
@@ -882,14 +884,9 @@ void BKE_lib_override_library_delete(Main *bmain, ID *id_root)
FOREACH_MAIN_ID_END;
/* Delete the override IDs. */
- FOREACH_MAIN_ID_BEGIN (bmain, id) {
- if (id->tag & LIB_TAG_DOIT) {
- BKE_id_delete(bmain, id);
- }
- }
- FOREACH_MAIN_ID_END;
+ BKE_id_multi_tagged_delete(bmain);
- /* Should not actually be needed here... */
+ /* Should not actually be needed here. */
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
}
@@ -1069,7 +1066,7 @@ IDOverrideLibraryPropertyOperation *BKE_lib_override_library_property_operation_
return ELEM(subitem_locindex, -1, opop->subitem_local_index) ? opop : NULL;
}
- /* index == -1 means all indices, that is valid fallback in case we requested specific index.
+ /* `index == -1` means all indices, that is a valid fallback in case we requested specific index.
*/
if (!strict && (subitem_locindex != subitem_defindex) &&
(opop = BLI_listbase_bytes_find(
@@ -1230,7 +1227,7 @@ bool BKE_lib_override_library_status_check_local(Main *bmain, ID *local)
BLI_assert(GS(local->name) == GS(reference->name));
if (GS(local->name) == ID_OB) {
- /* Our beloved pose's bone cross-data pointers.. Usually, depsgraph evaluation would
+ /* Our beloved pose's bone cross-data pointers. Usually, depsgraph evaluation would
* ensure this is valid, but in some situations (like hidden collections etc.) this won't
* be the case, so we need to take care of this ourselves. */
Object *ob_local = (Object *)local;
@@ -1290,16 +1287,16 @@ bool BKE_lib_override_library_status_check_reference(Main *bmain, ID *local)
if (reference->override_library && (reference->tag & LIB_TAG_OVERRIDE_LIBRARY_REFOK) == 0) {
if (!BKE_lib_override_library_status_check_reference(bmain, reference)) {
- /* If reference is also override of another data-block, and its status is not OK,
+ /* If reference is also an override of another data-block, and its status is not OK,
* then this override is not OK either.
- * Note that this should only happen when reloading libraries... */
+ * Note that this should only happen when reloading libraries. */
local->tag &= ~LIB_TAG_OVERRIDE_LIBRARY_REFOK;
return false;
}
}
if (GS(local->name) == ID_OB) {
- /* Our beloved pose's bone cross-data pointers.. Usually, depsgraph evaluation would
+ /* Our beloved pose's bone cross-data pointers. Usually, depsgraph evaluation would
* ensure this is valid, but in some situations (like hidden collections etc.) this won't
* be the case, so we need to take care of this ourselves. */
Object *ob_local = (Object *)local;
@@ -1332,7 +1329,7 @@ bool BKE_lib_override_library_status_check_reference(Main *bmain, ID *local)
}
/**
- * Compares local and reference data-blocks and create new override operations as needed,
+ * Compare local and reference data-blocks and create new override operations as needed,
* or reset to reference values if overriding is not allowed.
*
* \note Defining override operations is only mandatory before saving a `.blend` file on disk
@@ -1341,9 +1338,9 @@ bool BKE_lib_override_library_status_check_reference(Main *bmain, ID *local)
*
* \note This is by far the biggest operation (the more time-consuming) of the three so far,
* since it has to go over all properties in depth (all overridable ones at least).
- * Generating diff values and applying overrides are much cheaper.
+ * Generating differential values and applying overrides are much cheaper.
*
- * \return true if new overriding op was created, or some local data was reset. */
+ * \return true if a new overriding op was created, or some local data was reset. */
bool BKE_lib_override_library_operations_create(Main *bmain, ID *local)
{
BLI_assert(local->override_library != NULL);
@@ -1352,14 +1349,14 @@ bool BKE_lib_override_library_operations_create(Main *bmain, ID *local)
if (!is_template) {
/* Do not attempt to generate overriding rules from an empty place-holder generated by link
- * code when it cannot find to actual library/ID. Much better to keep the local data-block as
+ * code when it cannot find the actual library/ID. Much better to keep the local data-block as
* is in the file in that case, until broken lib is fixed. */
if (ID_MISSING(local->override_library->reference)) {
return ret;
}
if (GS(local->name) == ID_OB) {
- /* Our beloved pose's bone cross-data pointers.. Usually, depsgraph evaluation would
+ /* Our beloved pose's bone cross-data pointers. Usually, depsgraph evaluation would
* ensure this is valid, but in some situations (like hidden collections etc.) this won't
* be the case, so we need to take care of this ourselves. */
Object *ob_local = (Object *)local;
@@ -1427,9 +1424,9 @@ void BKE_lib_override_library_main_operations_create(Main *bmain, const bool for
}
/* Usual pose bones issue, need to be done outside of the threaded process or we may run into
- * concurency issues here.
+ * concurrency issues here.
* Note that calling #BKE_pose_ensure again in thread in
- * #BKE_lib_override_library_operations_create is not a problem then.. */
+ * #BKE_lib_override_library_operations_create is not a problem then. */
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
if (ob->type == OB_ARMATURE) {
BLI_assert(ob->data != NULL);
@@ -1442,6 +1439,15 @@ void BKE_lib_override_library_main_operations_create(Main *bmain, const bool for
FOREACH_MAIN_ID_BEGIN (bmain, id) {
if (ID_IS_OVERRIDE_LIBRARY_REAL(id) &&
(force_auto || (id->tag & LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH))) {
+ /* Usual issue with pose, it's quiet rare but sometimes they may not be up to date when this
+ * function is called. */
+ if (GS(id->name) == ID_OB) {
+ Object *ob = (Object *)id;
+ if (ob->type == OB_ARMATURE) {
+ BLI_assert(ob->data != NULL);
+ BKE_pose_ensure(bmain, ob, ob->data, true);
+ }
+ }
/* Only check overrides if we do have the real reference data available, and not some empty
* 'placeholder' for missing data (broken links). */
if ((id->override_library->reference->tag & LIB_TAG_MISSING) == 0) {
@@ -1557,7 +1563,7 @@ static void lib_override_library_id_hierarchy_recursive_reset(Main *bmain, ID *i
lib_override_library_id_reset_do(bmain, id_root);
- /* This way we won't process again that ID should we encounter it again through another
+ /* This way we won't process again that ID, should we encounter it again through another
* relationship hierarchy.
* Note that this does not free any memory from relations, so we can still use the entries.
*/
@@ -1600,7 +1606,7 @@ void BKE_lib_override_library_id_hierarchy_reset(Main *bmain, ID *id_root)
FOREACH_MAIN_ID_END;
}
-/** Set or clear given tag in all operations as unused in that override property data. */
+/** Set or clear given tag in all operations in that override property data. */
void BKE_lib_override_library_operations_tag(struct IDOverrideLibraryProperty *override_property,
const short tag,
const bool do_set)
@@ -1690,13 +1696,13 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
}
/* Do not attempt to apply overriding rules over an empty place-holder generated by link code
- * when it cannot find to actual library/ID. Much better to keep the local data-block as loaded
+ * when it cannot find the actual library/ID. Much better to keep the local data-block as loaded
* from the file in that case, until broken lib is fixed. */
if (ID_MISSING(local->override_library->reference)) {
return;
}
- /* Recursively do 'ancestors' overrides first, if any. */
+ /* Recursively do 'ancestor' overrides first, if any. */
if (local->override_library->reference->override_library &&
(local->override_library->reference->tag & LIB_TAG_OVERRIDE_LIBRARY_REFOK) == 0) {
BKE_lib_override_library_update(bmain, local->override_library->reference);
@@ -1708,7 +1714,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
/* XXX We need a way to get off-Main copies of IDs (similar to localized mats/texts/ etc.)!
* However, this is whole bunch of code work in itself, so for now plain stupid ID copy
- * will do, as inn-efficient as it is. :/
+ * will do, as inefficient as it is. :/
* Actually, maybe not! Since we are swapping with original ID's local content, we want to
* keep user-count in correct state when freeing tmp_id
* (and that user-counts of IDs used by 'new' local data also remain correct). */
@@ -1729,7 +1735,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
* manual handling here. */
BLI_strncpy(tmp_id->name, local->name, sizeof(tmp_id->name));
- /* Those ugly loop-back pointers again... Luckily we only need to deal with the shape keys here,
+ /* Those ugly loop-back pointers again. Luckily we only need to deal with the shape keys here,
* collections' parents are fully runtime and reconstructed later. */
Key *local_key = BKE_key_from_id(local);
Key *tmp_key = BKE_key_from_id(tmp_id);
@@ -1753,7 +1759,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
BKE_lib_id_swap(bmain, local, tmp_id);
if (local_key != NULL && tmp_key != NULL) {
- /* This is some kind of hard-coded 'always enforced override'... */
+ /* This is some kind of hard-coded 'always enforced override'. */
BKE_lib_id_swap(bmain, &local_key->id, &tmp_key->id);
tmp_key->id.flag |= (local_key->id.flag & LIB_EMBEDDED_DATA_LIB_OVERRIDE);
/* The swap of local and tmp_id inverted those pointers, we need to redefine proper
@@ -1764,9 +1770,8 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
tmp_key->from = tmp_id;
}
- /* Again, horribly inn-efficient in our case, we need something off-Main
+ /* Again, horribly inefficient in our case, we need something off-Main
* (aka more generic nolib copy/free stuff)! */
- /* XXX And crashing in complex cases (e.g. because depsgraph uses same data...). */
BKE_id_free_ex(bmain, tmp_id, LIB_ID_FREE_NO_UI_USER, true);
if (GS(local->name) == ID_AR) {
@@ -1794,9 +1799,9 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
local->tag |= LIB_TAG_OVERRIDE_LIBRARY_REFOK;
/* Full rebuild of Depsgraph! */
- /* Note: this is really brute force, in theory updates from RNA should have handle this already,
+ /* Note: this is really brute force, in theory updates from RNA should have handled this already,
* but for now let's play it safe. */
- DEG_id_tag_update_ex(bmain, local, ID_RECALC_ALL);
+ DEG_id_tag_update_ex(bmain, local, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
}
@@ -1825,12 +1830,11 @@ void BKE_lib_override_library_main_update(Main *bmain)
* Storage (how to store overriding data into `.blend` files).
*
* Basically:
- * 1) Only 'differential' storage needs special handling here. All others (replacing values or
+ * 1) Only 'differential' overrides needs special handling here. All others (replacing values or
* inserting/removing items from a collection) can be handled with simply storing current
* content of local data-block.
- * 2) We store the differential value into a second 'ghost' data-block,
- * which is an empty ID of same type as local one,
- * where we only define values that need differential data.
+ * 2) We store the differential value into a second 'ghost' data-block, which is an empty ID of
+ * same type as the local one, where we only define values that need differential data.
*
* This avoids us having to modify 'real' data-block at write time (and restoring it afterwards),
* which is inefficient, and potentially dangerous (in case of concurrent access...), while not
@@ -1872,15 +1876,15 @@ ID *BKE_lib_override_library_operations_store_start(Main *bmain,
/* This is fully disabled for now, as it generated very hard to solve issues with Collections and
* how they reference each-other in their parents/children relations.
- * Core of the issue is creating and storing those copies in a separate BMain, while collection
- * copy code re-assign blindly parents/children, even if they do not belong to the same BMain.
+ * Core of the issue is creating and storing those copies in a separate Main, while collection
+ * copy code re-assign blindly parents/children, even if they do not belong to the same Main.
* One solution could be to implement special flag as discussed below, and prevent any
* other-ID-reference creation/update in that case (since no differential operation is expected
* to involve those anyway). */
#if 0
/* XXX TODO We may also want a specialized handling of things here too, to avoid copying heavy
* never-overridable data (like Mesh geometry etc.)? And also maybe avoid lib
- * reference-counting completely (shallow copy...). */
+ * reference-counting completely (shallow copy). */
/* This would imply change in handling of user-count all over RNA
* (and possibly all over Blender code).
* Not impossible to do, but would rather see first is extra useless usual user handling is
@@ -1919,7 +1923,7 @@ void BKE_lib_override_library_operations_store_end(
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(local));
/* Nothing else to do here really, we need to keep all temp override storage data-blocks in
- * memory until whole file is written anyway (otherwise we'd get mem pointers overlap...). */
+ * memory until whole file is written anyway (otherwise we'd get mem pointers overlap). */
local->override_library->storage = NULL;
}
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 949e10d4721..6a560d51362 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -82,6 +82,8 @@ IDTypeInfo IDType_ID_LI = {
.blend_read_data = NULL,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index 4780f0cf208..a47a0c043ff 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -207,6 +207,8 @@ IDTypeInfo IDType_ID_LA = {
.blend_read_data = light_blend_read_data,
.blend_read_lib = light_blend_read_lib,
.blend_read_expand = light_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
Light *BKE_light_add(Main *bmain, const char *name)
diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c
index 31653a9a0ac..0553c070fdf 100644
--- a/source/blender/blenkernel/intern/lightprobe.c
+++ b/source/blender/blenkernel/intern/lightprobe.c
@@ -105,6 +105,8 @@ IDTypeInfo IDType_ID_LP = {
.blend_read_data = lightprobe_blend_read_data,
.blend_read_lib = lightprobe_blend_read_lib,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
void BKE_lightprobe_type_set(LightProbe *probe, const short lightprobe_type)
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 733a2bcd1e1..69e6535a59f 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -765,6 +765,8 @@ IDTypeInfo IDType_ID_LS = {
.blend_read_data = linestyle_blend_read_data,
.blend_read_lib = linestyle_blend_read_lib,
.blend_read_expand = linestyle_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
static const char *modifier_name[LS_MODIFIER_NUM] = {
diff --git a/source/blender/blenkernel/intern/main_idmap.c b/source/blender/blenkernel/intern/main_idmap.c
index 9a6ead7eb2b..21f5e9c6fb2 100644
--- a/source/blender/blenkernel/intern/main_idmap.c
+++ b/source/blender/blenkernel/intern/main_idmap.c
@@ -36,6 +36,7 @@
* Utility functions for faster ID lookups.
*/
+/* -------------------------------------------------------------------- */
/** \name BKE_main_idmap API
*
* Cache ID (name, library lookups).
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 1f9f155ee55..04fec1e57c4 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -268,6 +268,8 @@ IDTypeInfo IDType_ID_MSK = {
.blend_read_data = mask_blend_read_data,
.blend_read_lib = mask_blend_read_lib,
.blend_read_expand = mask_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
static struct {
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 4a85fab4e18..e892a3f4d53 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -272,6 +272,8 @@ IDTypeInfo IDType_ID_MA = {
.blend_read_data = material_blend_read_data,
.blend_read_lib = material_blend_read_lib,
.blend_read_expand = material_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
void BKE_gpencil_material_attr_init(Material *ma)
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index d2bacb7d3bc..65ec91c57cf 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -202,6 +202,8 @@ IDTypeInfo IDType_ID_MB = {
.blend_read_data = metaball_blend_read_data,
.blend_read_lib = metaball_blend_read_lib,
.blend_read_expand = metaball_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
/* Functions */
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index 7273d2a920d..cb01927d992 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -807,22 +807,22 @@ static void makecubetable(void)
INTLIST *edges;
for (edges = polys->list; edges; edges = edges->next) {
- if (edges->i == LB || edges->i == LT || edges->i == LN || edges->i == LF) {
+ if (ELEM(edges->i, LB, LT, LN, LF)) {
faces[i] |= 1 << L;
}
- if (edges->i == RB || edges->i == RT || edges->i == RN || edges->i == RF) {
+ if (ELEM(edges->i, RB, RT, RN, RF)) {
faces[i] |= 1 << R;
}
- if (edges->i == LB || edges->i == RB || edges->i == BN || edges->i == BF) {
+ if (ELEM(edges->i, LB, RB, BN, BF)) {
faces[i] |= 1 << B;
}
- if (edges->i == LT || edges->i == RT || edges->i == TN || edges->i == TF) {
+ if (ELEM(edges->i, LT, RT, TN, TF)) {
faces[i] |= 1 << T;
}
- if (edges->i == LN || edges->i == RN || edges->i == BN || edges->i == TN) {
+ if (ELEM(edges->i, LN, RN, BN, TN)) {
faces[i] |= 1 << N;
}
- if (edges->i == LF || edges->i == RF || edges->i == BF || edges->i == TF) {
+ if (ELEM(edges->i, LF, RF, BF, TF)) {
faces[i] |= 1 << F;
}
}
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index ba47b8fc4af..9ccdf5189d1 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -275,50 +275,6 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
mesh->totselect = 0;
}
- /* Multires data */
- BLO_read_data_address(reader, &mesh->mr);
- if (mesh->mr) {
- BLO_read_list(reader, &mesh->mr->levels);
- MultiresLevel *lvl = mesh->mr->levels.first;
-
- CustomData_blend_read(reader, &mesh->mr->vdata, lvl->totvert);
- BKE_defvert_blend_read(
- reader, lvl->totvert, CustomData_get(&mesh->mr->vdata, 0, CD_MDEFORMVERT));
- CustomData_blend_read(reader, &mesh->mr->fdata, lvl->totface);
-
- BLO_read_data_address(reader, &mesh->mr->edge_flags);
- BLO_read_data_address(reader, &mesh->mr->edge_creases);
-
- BLO_read_data_address(reader, &mesh->mr->verts);
-
- /* If mesh has the same number of vertices as the
- * highest multires level, load the current mesh verts
- * into multires and discard the old data. Needed
- * because some saved files either do not have a verts
- * array, or the verts array contains out-of-date
- * data. */
- if (mesh->totvert == ((MultiresLevel *)mesh->mr->levels.last)->totvert) {
- if (mesh->mr->verts) {
- MEM_freeN(mesh->mr->verts);
- }
- mesh->mr->verts = MEM_dupallocN(mesh->mvert);
- }
-
- for (; lvl; lvl = lvl->next) {
- BLO_read_data_address(reader, &lvl->verts);
- BLO_read_data_address(reader, &lvl->faces);
- BLO_read_data_address(reader, &lvl->edges);
- BLO_read_data_address(reader, &lvl->colfaces);
- }
- }
-
- /* if multires is present but has no valid vertex data,
- * there's no way to recover it; silently remove multires */
- if (mesh->mr && !mesh->mr->verts) {
- multires_free(mesh->mr);
- mesh->mr = NULL;
- }
-
if ((BLO_read_requires_endian_switch(reader)) && mesh->tface) {
TFace *tf = mesh->tface;
for (int i = 0; i < mesh->totface; i++, tf++) {
@@ -377,6 +333,8 @@ IDTypeInfo IDType_ID_ME = {
.blend_read_data = mesh_blend_read_data,
.blend_read_lib = mesh_blend_read_lib,
.blend_read_expand = mesh_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
enum {
@@ -1540,8 +1498,11 @@ void BKE_mesh_transform(Mesh *me, const float mat[4][4], bool do_keys)
void BKE_mesh_translate(Mesh *me, const float offset[3], const bool do_keys)
{
+ MVert *mvert = CustomData_duplicate_referenced_layer(&me->vdata, CD_MVERT, me->totvert);
+ /* If the referenced layer has been re-allocated need to update pointers stored in the mesh. */
+ BKE_mesh_update_customdata_pointers(me, false);
+
int i = me->totvert;
- MVert *mvert;
for (mvert = me->mvert; i--; mvert++) {
add_v3_v3(mvert->co, offset);
}
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index ae301aca25a..8272bd07411 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -949,7 +949,7 @@ void BKE_mesh_to_pointcloud(Main *bmain, Depsgraph *depsgraph, Scene *UNUSED(sce
BKE_object_free_derived_caches(ob);
}
-void BKE_mesh_from_pointcloud(PointCloud *pointcloud, Mesh *me)
+void BKE_mesh_from_pointcloud(const PointCloud *pointcloud, Mesh *me)
{
BLI_assert(pointcloud != NULL);
diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c
index 868694931cb..e118c1b6f6e 100644
--- a/source/blender/blenkernel/intern/mesh_merge.c
+++ b/source/blender/blenkernel/intern/mesh_merge.c
@@ -61,7 +61,7 @@ static int cddm_poly_compare(MLoop *mloop_array,
MLoop *mloop_source, *mloop_target;
- BLI_assert(direct_reverse == 1 || direct_reverse == -1);
+ BLI_assert(ELEM(direct_reverse, 1, -1));
i_loop_source = 0;
mloop_source = mloop_array + mpoly_source->loopstart;
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index 1c48cf6f3cb..f3b29171762 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -327,6 +327,7 @@ void BKE_mesh_remap_find_best_match_from_mesh(const MVert *verts_dst,
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Mesh to mesh mapping
* \{ */
diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c
index 150f7f19edc..f35f4ae3501 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -267,6 +267,7 @@ void BKE_mesh_batch_cache_free(Mesh *me)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Mesh runtime debug helpers.
* \{ */
/* evaluated mesh info printing function,
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index 6fea2cc8bf5..b3c53df2d5f 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -52,6 +52,7 @@
static CLG_LogRef LOG = {"bke.mesh"};
+/* -------------------------------------------------------------------- */
/** \name Internal functions
* \{ */
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 0aa85f0ad50..3c8b685a0e0 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -24,6 +24,9 @@
* \ingroup bke
*/
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#include <float.h>
#include <math.h>
#include <stdarg.h>
@@ -34,10 +37,15 @@
#include "MEM_guardedalloc.h"
#include "DNA_armature_types.h"
+#include "DNA_cloth_types.h"
+#include "DNA_fluid_types.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_mesh_types.h"
+#include "DNA_object_fluidsim_types.h"
+#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
@@ -53,6 +61,8 @@
#include "BKE_appdir.h"
#include "BKE_editmesh.h"
#include "BKE_editmesh_cache.h"
+#include "BKE_effect.h"
+#include "BKE_fluid.h"
#include "BKE_global.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_idtype.h"
@@ -63,6 +73,7 @@
#include "BKE_mesh_wrapper.h"
#include "BKE_multires.h"
#include "BKE_object.h"
+#include "BKE_pointcache.h"
/* may move these, only for BKE_modifier_path_relbase */
#include "BKE_main.h"
@@ -73,6 +84,8 @@
#include "MOD_modifiertypes.h"
+#include "BLO_read_write.h"
+
#include "CLG_log.h"
static CLG_LogRef LOG = {"bke.modifier"};
@@ -130,6 +143,11 @@ void BKE_modifier_type_panel_id(ModifierType type, char *r_idname)
strcat(r_idname, mti->name);
}
+void BKE_modifier_panel_expand(ModifierData *md)
+{
+ md->ui_expand_flag |= UI_PANEL_DATA_EXPAND_ROOT;
+}
+
/***/
ModifierData *BKE_modifier_new(int type)
@@ -389,7 +407,7 @@ bool BKE_modifier_is_non_geometrical(ModifierData *md)
return (mti->type == eModifierTypeType_NonGeometrical);
}
-void BKE_modifier_set_error(ModifierData *md, const char *_format, ...)
+void BKE_modifier_set_error(const Object *ob, ModifierData *md, const char *_format, ...)
{
char buffer[512];
va_list ap;
@@ -406,7 +424,16 @@ void BKE_modifier_set_error(ModifierData *md, const char *_format, ...)
md->error = BLI_strdup(buffer);
- CLOG_STR_ERROR(&LOG, md->error);
+#ifndef NDEBUG
+ if ((md->mode & eModifierMode_Virtual) == 0) {
+ /* Ensure correct object is passed in. */
+ const Object *ob_orig = (Object *)DEG_get_original_id((ID *)&ob->id);
+ const ModifierData *md_orig = md->orig_modifier_data ? md->orig_modifier_data : md;
+ BLI_assert(BLI_findindex(&ob_orig->modifiers, md_orig) != -1);
+ }
+#endif
+
+ CLOG_ERROR(&LOG, "Object: \"%s\", Modifier: \"%s\", %s", ob->id.name + 2, md->name, md->error);
}
/* used for buttons, to find out if the 'draw deformed in editmode' option is
@@ -1101,3 +1128,423 @@ void BKE_modifier_check_uuids_unique_and_report(const Object *object)
BLI_gset_free(used_uuids, NULL);
}
+
+void BKE_modifier_blend_write(BlendWriter *writer, ListBase *modbase)
+{
+ if (modbase == NULL) {
+ return;
+ }
+
+ LISTBASE_FOREACH (ModifierData *, md, modbase) {
+ const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
+ if (mti == NULL) {
+ return;
+ }
+
+ BLO_write_struct_by_name(writer, mti->structName, md);
+
+ if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+
+ BLO_write_struct(writer, ClothSimSettings, clmd->sim_parms);
+ BLO_write_struct(writer, ClothCollSettings, clmd->coll_parms);
+ BLO_write_struct(writer, EffectorWeights, clmd->sim_parms->effector_weights);
+ BKE_ptcache_blend_write(writer, &clmd->ptcaches);
+ }
+ else if (md->type == eModifierType_Fluid) {
+ FluidModifierData *fmd = (FluidModifierData *)md;
+
+ if (fmd->type & MOD_FLUID_TYPE_DOMAIN) {
+ BLO_write_struct(writer, FluidDomainSettings, fmd->domain);
+
+ if (fmd->domain) {
+ BKE_ptcache_blend_write(writer, &(fmd->domain->ptcaches[0]));
+
+ /* create fake pointcache so that old blender versions can read it */
+ fmd->domain->point_cache[1] = BKE_ptcache_add(&fmd->domain->ptcaches[1]);
+ fmd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE | PTCACHE_FAKE_SMOKE;
+ fmd->domain->point_cache[1]->step = 1;
+
+ BKE_ptcache_blend_write(writer, &(fmd->domain->ptcaches[1]));
+
+ if (fmd->domain->coba) {
+ BLO_write_struct(writer, ColorBand, fmd->domain->coba);
+ }
+
+ /* cleanup the fake pointcache */
+ BKE_ptcache_free_list(&fmd->domain->ptcaches[1]);
+ fmd->domain->point_cache[1] = NULL;
+
+ BLO_write_struct(writer, EffectorWeights, fmd->domain->effector_weights);
+ }
+ }
+ else if (fmd->type & MOD_FLUID_TYPE_FLOW) {
+ BLO_write_struct(writer, FluidFlowSettings, fmd->flow);
+ }
+ else if (fmd->type & MOD_FLUID_TYPE_EFFEC) {
+ BLO_write_struct(writer, FluidEffectorSettings, fmd->effector);
+ }
+ }
+ else if (md->type == eModifierType_Fluidsim) {
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
+
+ BLO_write_struct(writer, FluidsimSettings, fluidmd->fss);
+ }
+ else if (md->type == eModifierType_DynamicPaint) {
+ DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
+
+ if (pmd->canvas) {
+ BLO_write_struct(writer, DynamicPaintCanvasSettings, pmd->canvas);
+
+ /* write surfaces */
+ LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
+ BLO_write_struct(writer, DynamicPaintSurface, surface);
+ }
+ /* write caches and effector weights */
+ LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
+ BKE_ptcache_blend_write(writer, &(surface->ptcaches));
+
+ BLO_write_struct(writer, EffectorWeights, surface->effector_weights);
+ }
+ }
+ if (pmd->brush) {
+ BLO_write_struct(writer, DynamicPaintBrushSettings, pmd->brush);
+ BLO_write_struct(writer, ColorBand, pmd->brush->paint_ramp);
+ BLO_write_struct(writer, ColorBand, pmd->brush->vel_ramp);
+ }
+ }
+ else if (md->type == eModifierType_Collision) {
+
+#if 0
+ CollisionModifierData *collmd = (CollisionModifierData *)md;
+ // TODO: CollisionModifier should use pointcache
+ // + have proper reset events before enabling this
+ writestruct(wd, DATA, MVert, collmd->numverts, collmd->x);
+ writestruct(wd, DATA, MVert, collmd->numverts, collmd->xnew);
+ writestruct(wd, DATA, MFace, collmd->numfaces, collmd->mfaces);
+#endif
+ }
+
+ if (mti->blendWrite != NULL) {
+ mti->blendWrite(writer, md);
+ }
+ }
+}
+
+/* TODO(sergey): Find a better place for this.
+ *
+ * Unfortunately, this can not be done as a regular do_versions() since the modifier type is
+ * set to NONE, so the do_versions code wouldn't know where the modifier came from.
+ *
+ * The best approach seems to have the functionality in versioning_280.c but still call the
+ * function from #BKE_modifier_blend_read_data().
+ */
+
+/* Domain, inflow, ... */
+static void modifier_ensure_type(FluidModifierData *fluid_modifier_data, int type)
+{
+ fluid_modifier_data->type = type;
+ BKE_fluid_modifier_free(fluid_modifier_data);
+ BKE_fluid_modifier_create_type_data(fluid_modifier_data);
+}
+
+/**
+ * \note The old_modifier_data is NOT linked.
+ * This means that in order to access sub-data pointers #BLO_read_get_new_data_address is to be
+ * used.
+ */
+static ModifierData *modifier_replace_with_fluid(BlendDataReader *reader,
+ Object *object,
+ ListBase *modifiers,
+ ModifierData *old_modifier_data)
+{
+ ModifierData *new_modifier_data = BKE_modifier_new(eModifierType_Fluid);
+ FluidModifierData *fluid_modifier_data = (FluidModifierData *)new_modifier_data;
+
+ if (old_modifier_data->type == eModifierType_Fluidsim) {
+ FluidsimModifierData *old_fluidsim_modifier_data = (FluidsimModifierData *)old_modifier_data;
+ FluidsimSettings *old_fluidsim_settings = BLO_read_get_new_data_address(
+ reader, old_fluidsim_modifier_data->fss);
+ switch (old_fluidsim_settings->type) {
+ case OB_FLUIDSIM_ENABLE:
+ modifier_ensure_type(fluid_modifier_data, 0);
+ break;
+ case OB_FLUIDSIM_DOMAIN:
+ modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_DOMAIN);
+ BKE_fluid_domain_type_set(object, fluid_modifier_data->domain, FLUID_DOMAIN_TYPE_LIQUID);
+ break;
+ case OB_FLUIDSIM_FLUID:
+ modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
+ BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
+ /* No need to emit liquid far away from surface. */
+ fluid_modifier_data->flow->surface_distance = 0.0f;
+ break;
+ case OB_FLUIDSIM_OBSTACLE:
+ modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_EFFEC);
+ BKE_fluid_effector_type_set(
+ object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_COLLISION);
+ break;
+ case OB_FLUIDSIM_INFLOW:
+ modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
+ BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
+ BKE_fluid_flow_behavior_set(object, fluid_modifier_data->flow, FLUID_FLOW_BEHAVIOR_INFLOW);
+ /* No need to emit liquid far away from surface. */
+ fluid_modifier_data->flow->surface_distance = 0.0f;
+ break;
+ case OB_FLUIDSIM_OUTFLOW:
+ modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
+ BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
+ BKE_fluid_flow_behavior_set(
+ object, fluid_modifier_data->flow, FLUID_FLOW_BEHAVIOR_OUTFLOW);
+ break;
+ case OB_FLUIDSIM_PARTICLE:
+ /* "Particle" type objects not being used by Mantaflow fluid simulations.
+ * Skip this object, secondary particles can only be enabled through the domain object. */
+ break;
+ case OB_FLUIDSIM_CONTROL:
+ /* "Control" type objects not being used by Mantaflow fluid simulations.
+ * Use guiding type instead which is similar. */
+ modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_EFFEC);
+ BKE_fluid_effector_type_set(
+ object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_GUIDE);
+ break;
+ }
+ }
+ else if (old_modifier_data->type == eModifierType_Smoke) {
+ SmokeModifierData *old_smoke_modifier_data = (SmokeModifierData *)old_modifier_data;
+ modifier_ensure_type(fluid_modifier_data, old_smoke_modifier_data->type);
+ if (fluid_modifier_data->type == MOD_FLUID_TYPE_DOMAIN) {
+ BKE_fluid_domain_type_set(object, fluid_modifier_data->domain, FLUID_DOMAIN_TYPE_GAS);
+ }
+ else if (fluid_modifier_data->type == MOD_FLUID_TYPE_FLOW) {
+ BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_SMOKE);
+ }
+ else if (fluid_modifier_data->type == MOD_FLUID_TYPE_EFFEC) {
+ BKE_fluid_effector_type_set(
+ object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_COLLISION);
+ }
+ }
+
+ /* Replace modifier data in the stack. */
+ new_modifier_data->next = old_modifier_data->next;
+ new_modifier_data->prev = old_modifier_data->prev;
+ if (new_modifier_data->prev != NULL) {
+ new_modifier_data->prev->next = new_modifier_data;
+ }
+ if (new_modifier_data->next != NULL) {
+ new_modifier_data->next->prev = new_modifier_data;
+ }
+ if (modifiers->first == old_modifier_data) {
+ modifiers->first = new_modifier_data;
+ }
+ if (modifiers->last == old_modifier_data) {
+ modifiers->last = new_modifier_data;
+ }
+
+ /* Free old modifier data. */
+ MEM_freeN(old_modifier_data);
+
+ return new_modifier_data;
+}
+
+void BKE_modifier_blend_read_data(BlendDataReader *reader, ListBase *lb, Object *ob)
+{
+ BLO_read_list(reader, lb);
+
+ LISTBASE_FOREACH (ModifierData *, md, lb) {
+ BKE_modifier_session_uuid_generate(md);
+
+ md->error = NULL;
+ md->runtime = NULL;
+
+ /* Modifier data has been allocated as a part of data migration process and
+ * no reading of nested fields from file is needed. */
+ bool is_allocated = false;
+
+ if (md->type == eModifierType_Fluidsim) {
+ BLO_reportf_wrap(
+ BLO_read_data_reports(reader),
+ RPT_WARNING,
+ TIP_("Possible data loss when saving this file! %s modifier is deprecated (Object: %s)"),
+ md->name,
+ ob->id.name + 2);
+ md = modifier_replace_with_fluid(reader, ob, lb, md);
+ is_allocated = true;
+ }
+ else if (md->type == eModifierType_Smoke) {
+ BLO_reportf_wrap(
+ BLO_read_data_reports(reader),
+ RPT_WARNING,
+ TIP_("Possible data loss when saving this file! %s modifier is deprecated (Object: %s)"),
+ md->name,
+ ob->id.name + 2);
+ md = modifier_replace_with_fluid(reader, ob, lb, md);
+ is_allocated = true;
+ }
+
+ const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
+
+ /* if modifiers disappear, or for upward compatibility */
+ if (mti == NULL) {
+ md->type = eModifierType_None;
+ }
+
+ if (is_allocated) {
+ /* All the fields has been properly allocated. */
+ }
+ else if (md->type == eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData *)md;
+
+ clmd->clothObject = NULL;
+ clmd->hairdata = NULL;
+
+ BLO_read_data_address(reader, &clmd->sim_parms);
+ BLO_read_data_address(reader, &clmd->coll_parms);
+
+ BKE_ptcache_blend_read_data(reader, &clmd->ptcaches, &clmd->point_cache, 0);
+
+ if (clmd->sim_parms) {
+ if (clmd->sim_parms->presets > 10) {
+ clmd->sim_parms->presets = 0;
+ }
+
+ clmd->sim_parms->reset = 0;
+
+ BLO_read_data_address(reader, &clmd->sim_parms->effector_weights);
+
+ if (!clmd->sim_parms->effector_weights) {
+ clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL);
+ }
+ }
+
+ clmd->solver_result = NULL;
+ }
+ else if (md->type == eModifierType_Fluid) {
+
+ FluidModifierData *fmd = (FluidModifierData *)md;
+
+ if (fmd->type == MOD_FLUID_TYPE_DOMAIN) {
+ fmd->flow = NULL;
+ fmd->effector = NULL;
+ BLO_read_data_address(reader, &fmd->domain);
+ fmd->domain->fmd = fmd;
+
+ fmd->domain->fluid = NULL;
+ fmd->domain->fluid_mutex = BLI_rw_mutex_alloc();
+ fmd->domain->tex_density = NULL;
+ fmd->domain->tex_color = NULL;
+ fmd->domain->tex_shadow = NULL;
+ fmd->domain->tex_flame = NULL;
+ fmd->domain->tex_flame_coba = NULL;
+ fmd->domain->tex_coba = NULL;
+ fmd->domain->tex_field = NULL;
+ fmd->domain->tex_velocity_x = NULL;
+ fmd->domain->tex_velocity_y = NULL;
+ fmd->domain->tex_velocity_z = NULL;
+ fmd->domain->tex_wt = NULL;
+ fmd->domain->mesh_velocities = NULL;
+ BLO_read_data_address(reader, &fmd->domain->coba);
+
+ BLO_read_data_address(reader, &fmd->domain->effector_weights);
+ if (!fmd->domain->effector_weights) {
+ fmd->domain->effector_weights = BKE_effector_add_weights(NULL);
+ }
+
+ BKE_ptcache_blend_read_data(
+ reader, &(fmd->domain->ptcaches[0]), &(fmd->domain->point_cache[0]), 1);
+
+ /* Manta sim uses only one cache from now on, so store pointer convert */
+ if (fmd->domain->ptcaches[1].first || fmd->domain->point_cache[1]) {
+ if (fmd->domain->point_cache[1]) {
+ PointCache *cache = BLO_read_get_new_data_address(reader, fmd->domain->point_cache[1]);
+ if (cache->flag & PTCACHE_FAKE_SMOKE) {
+ /* Manta-sim/smoke was already saved in "new format" and this cache is a fake one. */
+ }
+ else {
+ printf(
+ "High resolution manta cache not available due to pointcache update. Please "
+ "reset the simulation.\n");
+ }
+ BKE_ptcache_free(cache);
+ }
+ BLI_listbase_clear(&fmd->domain->ptcaches[1]);
+ fmd->domain->point_cache[1] = NULL;
+ }
+ }
+ else if (fmd->type == MOD_FLUID_TYPE_FLOW) {
+ fmd->domain = NULL;
+ fmd->effector = NULL;
+ BLO_read_data_address(reader, &fmd->flow);
+ fmd->flow->fmd = fmd;
+ fmd->flow->mesh = NULL;
+ fmd->flow->verts_old = NULL;
+ fmd->flow->numverts = 0;
+ BLO_read_data_address(reader, &fmd->flow->psys);
+ }
+ else if (fmd->type == MOD_FLUID_TYPE_EFFEC) {
+ fmd->flow = NULL;
+ fmd->domain = NULL;
+ BLO_read_data_address(reader, &fmd->effector);
+ if (fmd->effector) {
+ fmd->effector->fmd = fmd;
+ fmd->effector->verts_old = NULL;
+ fmd->effector->numverts = 0;
+ fmd->effector->mesh = NULL;
+ }
+ else {
+ fmd->type = 0;
+ fmd->flow = NULL;
+ fmd->domain = NULL;
+ fmd->effector = NULL;
+ }
+ }
+ }
+ else if (md->type == eModifierType_DynamicPaint) {
+ DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
+
+ if (pmd->canvas) {
+ BLO_read_data_address(reader, &pmd->canvas);
+ pmd->canvas->pmd = pmd;
+ pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
+
+ if (pmd->canvas->surfaces.first) {
+ BLO_read_list(reader, &pmd->canvas->surfaces);
+
+ LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
+ surface->canvas = pmd->canvas;
+ surface->data = NULL;
+ BKE_ptcache_blend_read_data(reader, &(surface->ptcaches), &(surface->pointcache), 1);
+
+ BLO_read_data_address(reader, &surface->effector_weights);
+ if (surface->effector_weights == NULL) {
+ surface->effector_weights = BKE_effector_add_weights(NULL);
+ }
+ }
+ }
+ }
+ if (pmd->brush) {
+ BLO_read_data_address(reader, &pmd->brush);
+ pmd->brush->pmd = pmd;
+ BLO_read_data_address(reader, &pmd->brush->psys);
+ BLO_read_data_address(reader, &pmd->brush->paint_ramp);
+ BLO_read_data_address(reader, &pmd->brush->vel_ramp);
+ }
+ }
+
+ if (mti->blendRead != NULL) {
+ mti->blendRead(reader, md);
+ }
+ }
+}
+
+void BKE_modifier_blend_read_lib(BlendLibReader *reader, Object *ob)
+{
+ BKE_modifiers_foreach_ID_link(ob, BKE_object_modifiers_lib_link_common, reader);
+
+ /* If linking from a library, clear 'local' library override flag. */
+ if (ob->id.lib != NULL) {
+ LISTBASE_FOREACH (ModifierData *, mod, &ob->modifiers) {
+ mod->flag &= ~eModifierFlag_OverrideLibrary_Local;
+ }
+ }
+}
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 54131342489..b872c91cc29 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -360,6 +360,8 @@ IDTypeInfo IDType_ID_MC = {
.blend_read_data = movieclip_blend_read_data,
.blend_read_lib = movieclip_blend_read_lib,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
/*********************** movieclip buffer loaders *************************/
@@ -520,7 +522,7 @@ static void movieclip_convert_multilayer_add_pass(void *UNUSED(layer),
MEM_freeN(rect);
return;
}
- if (STREQ(pass_name, RE_PASSNAME_COMBINED) || STREQ(chan_id, "RGBA") || STREQ(chan_id, "RGB")) {
+ if (STREQ(pass_name, RE_PASSNAME_COMBINED) || STR_ELEM(chan_id, "RGBA", "RGB")) {
ctx->combined_pass = rect;
ctx->num_combined_channels = num_channels;
}
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 6e1168d8a16..441da8b134a 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -63,7 +63,6 @@
#include <string.h>
/* MULTIRES MODIFIER */
-static const int multires_max_levels = 13;
static const int multires_grid_tot[] = {
0, 4, 9, 25, 81, 289, 1089, 4225, 16641, 66049, 263169, 1050625, 4198401, 16785409};
static const int multires_side_tot[] = {
@@ -76,7 +75,6 @@ typedef enum {
ADD_DISPLACEMENTS,
} DispOp;
-static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert);
static void multiresModifier_disp_run(
DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, CCGElem **oldGridData, int totlvl);
@@ -241,40 +239,6 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level)
md->hidden = subd;
}
-static MDisps *multires_mdisps_init_hidden(Mesh *me, int level)
-{
- MDisps *mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, CD_CALLOC, NULL, me->totloop);
- int gridsize = BKE_ccg_gridsize(level);
- int gridarea = square_i(gridsize);
- int i, j;
-
- for (i = 0; i < me->totpoly; i++) {
- bool hide = false;
-
- for (j = 0; j < me->mpoly[i].totloop; j++) {
- if (me->mvert[me->mloop[me->mpoly[i].loopstart + j].v].flag & ME_HIDE) {
- hide = true;
- break;
- }
- }
-
- if (!hide) {
- continue;
- }
-
- for (j = 0; j < me->mpoly[i].totloop; j++) {
- MDisps *md = &mdisps[me->mpoly[i].loopstart + j];
-
- BLI_assert(!md->hidden);
-
- md->hidden = BLI_BITMAP_NEW(gridarea, "MDisps.hidden initialize");
- BLI_bitmap_set_all(md->hidden, true, gridarea);
- }
- }
-
- return mdisps;
-}
-
Mesh *BKE_multires_create_mesh(struct Depsgraph *depsgraph,
Object *object,
MultiresModifierData *mmd)
@@ -429,12 +393,6 @@ void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl)
mmd->renderlvl = CLAMPIS(MAX2(mmd->renderlvl, lvl), 0, mmd->totlvl);
}
-static void multires_dm_mark_as_modified(DerivedMesh *dm, MultiresModifiedFlags flags)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
- ccgdm->multires.modified_flags |= flags;
-}
-
static void multires_ccg_mark_as_modified(SubdivCCG *subdiv_ccg, MultiresModifiedFlags flags)
{
if (flags & MULTIRES_COORDS_MODIFIED) {
@@ -789,7 +747,6 @@ static DerivedMesh *multires_dm_create_local(Scene *scene,
DerivedMesh *dm,
int lvl,
int totlvl,
- int simple,
bool alloc_paint_mask,
int flags)
{
@@ -799,7 +756,6 @@ static DerivedMesh *multires_dm_create_local(Scene *scene,
mmd.sculptlvl = lvl;
mmd.renderlvl = lvl;
mmd.totlvl = totlvl;
- mmd.simple = simple;
flags |= MULTIRES_USE_LOCAL_MMD;
if (alloc_paint_mask) {
@@ -850,110 +806,6 @@ static DerivedMesh *subsurf_dm_create_local(Scene *scene,
return subsurf_make_derived_from_derived(dm, &smd, scene, NULL, flags);
}
-static void multires_subdivide_legacy(
- MultiresModifierData *mmd, Scene *scene, Object *ob, int totlvl, int updateblock, int simple)
-{
- Mesh *me = ob->data;
- MDisps *mdisps;
- const int lvl = mmd->totlvl;
-
- if ((totlvl > multires_max_levels) || (me->totpoly == 0)) {
- return;
- }
-
- BLI_assert(totlvl > lvl);
-
- multires_force_sculpt_rebuild(ob);
-
- mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
- if (!mdisps) {
- mdisps = multires_mdisps_init_hidden(me, totlvl);
- }
-
- if (mdisps->disps && !updateblock && lvl != 0) {
- /* upsample */
- DerivedMesh *lowdm, *cddm, *highdm;
- CCGElem **highGridData, **lowGridData, **subGridData;
- CCGKey highGridKey, lowGridKey;
- CCGSubSurf *ss;
- int i, numGrids, highGridSize;
- const bool has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
-
- /* create subsurf DM from original mesh at high level */
- cddm = CDDM_from_mesh(me);
- DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
- highdm = subsurf_dm_create_local(NULL,
- ob,
- cddm,
- totlvl,
- simple,
- 0,
- mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE,
- has_mask,
- false,
- SUBSURF_IGNORE_SIMPLIFY);
- ss = ((CCGDerivedMesh *)highdm)->ss;
-
- /* create multires DM from original mesh at low level */
- lowdm = multires_dm_create_local(
- scene, ob, cddm, lvl, lvl, simple, has_mask, MULTIRES_IGNORE_SIMPLIFY);
- BLI_assert(lowdm != cddm);
- cddm->release(cddm);
-
- /* copy subsurf grids and replace them with low displaced grids */
- numGrids = highdm->getNumGrids(highdm);
- highGridSize = highdm->getGridSize(highdm);
- highGridData = highdm->getGridData(highdm);
- highdm->getGridKey(highdm, &highGridKey);
- lowGridData = lowdm->getGridData(lowdm);
- lowdm->getGridKey(lowdm, &lowGridKey);
-
- subGridData = MEM_calloc_arrayN(numGrids, sizeof(float *), "subGridData*");
-
- for (i = 0; i < numGrids; i++) {
- /* backup subsurf grids */
- subGridData[i] = MEM_calloc_arrayN(
- highGridKey.elem_size, highGridSize * highGridSize, "subGridData");
- memcpy(subGridData[i], highGridData[i], highGridKey.elem_size * highGridSize * highGridSize);
-
- /* overwrite with current displaced grids */
- multires_copy_dm_grid(highGridData[i], lowGridData[i], &highGridKey, &lowGridKey);
- }
-
- /* low lower level dm no longer needed at this point */
- lowdm->release(lowdm);
-
- /* subsurf higher levels again with displaced data */
- ccgSubSurf_updateFromFaces(ss, lvl, NULL, 0);
- ccgSubSurf_updateLevels(ss, lvl, NULL, 0);
-
- /* reallocate displacements */
- multires_reallocate_mdisps(me->totloop, mdisps, totlvl);
-
- /* compute displacements */
- multiresModifier_disp_run(highdm, me, NULL, CALC_DISPLACEMENTS, subGridData, totlvl);
-
- /* free */
- highdm->release(highdm);
- for (i = 0; i < numGrids; i++) {
- MEM_freeN(subGridData[i]);
- }
- MEM_freeN(subGridData);
- }
- else {
- /* only reallocate, nothing to upsample */
- multires_reallocate_mdisps(me->totloop, mdisps, totlvl);
- }
-
- multires_set_tot_level(ob, mmd, totlvl);
-}
-
-void multiresModifier_subdivide_legacy(
- MultiresModifierData *mmd, Scene *scene, Object *ob, int updateblock, int simple)
-{
- multires_subdivide_legacy(mmd, scene, ob, mmd->totlvl + 1, updateblock, simple);
-}
-
static void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *grid, float t[3])
{
if (axis == 0) {
@@ -1227,7 +1079,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene)
ob,
cddm,
totlvl,
- mmd->simple,
+ false,
0,
mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE,
has_mask,
@@ -1237,7 +1089,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene)
/* create multires DM from original mesh and displacements */
lowdm = multires_dm_create_local(
- scene, ob, cddm, lvl, totlvl, mmd->simple, has_mask, MULTIRES_IGNORE_SIMPLIFY);
+ scene, ob, cddm, lvl, totlvl, has_mask, MULTIRES_IGNORE_SIMPLIFY);
cddm->release(cddm);
/* gather grid data */
@@ -1302,7 +1154,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene)
ob,
cddm,
mmd->totlvl,
- mmd->simple,
+ false,
0,
mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE,
has_mask,
@@ -1400,7 +1252,7 @@ DerivedMesh *multires_make_derived_from_derived(
ob,
dm,
lvl,
- mmd->simple,
+ false,
mmd->flags & eMultiresModifierFlag_ControlEdges,
mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE,
flags & MULTIRES_ALLOC_PAINT_MASK,
@@ -1449,9 +1301,6 @@ DerivedMesh *multires_make_derived_from_derived(
return result;
}
-/**** Old Multires code ****
- ***************************/
-
/* Adapted from sculptmode.c */
void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, float v)
{
@@ -1506,723 +1355,6 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u,
add_v3_v3v3(out, d2[0], d2[1]);
}
-static void old_mdisps_rotate(
- int S, int UNUSED(newside), int oldside, int x, int y, float *u, float *v)
-{
- float offset = oldside * 0.5f - 0.5f;
-
- if (S == 1) {
- *u = offset + x;
- *v = offset - y;
- }
- if (S == 2) {
- *u = offset + y;
- *v = offset + x;
- }
- if (S == 3) {
- *u = offset - x;
- *v = offset + y;
- }
- if (S == 0) {
- *u = offset - y;
- *v = offset - x;
- }
-}
-
-static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
-{
- int newlvl = log(sqrt(mdisp->totdisp) - 1) / M_LN2;
- int oldlvl = newlvl + 1;
- int oldside = multires_side_tot[oldlvl];
- int newside = multires_side_tot[newlvl];
- int nvert = (mface->v4) ? 4 : 3;
- int newtotdisp = multires_grid_tot[newlvl] * nvert;
- int x, y, S;
- float(*disps)[3], (*out)[3], u = 0.0f, v = 0.0f; /* Quite gcc barking. */
-
- disps = MEM_calloc_arrayN(newtotdisp, sizeof(float[3]), "multires disps");
-
- out = disps;
- for (S = 0; S < nvert; S++) {
- for (y = 0; y < newside; y++) {
- for (x = 0; x < newside; x++, out++) {
- old_mdisps_rotate(S, newside, oldside, x, y, &u, &v);
- old_mdisps_bilinear(*out, mdisp->disps, oldside, u, v);
-
- if (S == 1) {
- (*out)[1] = -(*out)[1];
- }
- else if (S == 2) {
- SWAP(float, (*out)[0], (*out)[1]);
- }
- else if (S == 3) {
- (*out)[0] = -(*out)[0];
- }
- else if (S == 0) {
- SWAP(float, (*out)[0], (*out)[1]);
- (*out)[0] = -(*out)[0];
- (*out)[1] = -(*out)[1];
- }
- }
- }
- }
-
- MEM_freeN(mdisp->disps);
-
- mdisp->totdisp = newtotdisp;
- mdisp->level = newlvl;
- mdisp->disps = disps;
-}
-
-void multires_load_old_250(Mesh *me)
-{
- MDisps *mdisps, *mdisps2;
- MFace *mf;
- int i, j, k;
-
- mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS);
-
- if (mdisps) {
- for (i = 0; i < me->totface; i++) {
- if (mdisps[i].totdisp) {
- old_mdisps_convert(&me->mface[i], &mdisps[i]);
- }
- }
-
- CustomData_add_layer(&me->ldata, CD_MDISPS, CD_CALLOC, NULL, me->totloop);
- mdisps2 = CustomData_get_layer(&me->ldata, CD_MDISPS);
-
- k = 0;
- mf = me->mface;
- for (i = 0; i < me->totface; i++, mf++) {
- int nvert = mf->v4 ? 4 : 3;
- int totdisp = mdisps[i].totdisp / nvert;
-
- for (j = 0; j < nvert; j++, k++) {
- mdisps2[k].disps = MEM_calloc_arrayN(
- totdisp, sizeof(float[3]), "multires disp in conversion");
- mdisps2[k].totdisp = totdisp;
- mdisps2[k].level = mdisps[i].level;
- memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp * j, totdisp);
- }
- }
- }
-}
-
-/* Does not actually free lvl itself */
-static void multires_free_level(MultiresLevel *lvl)
-{
- if (lvl) {
- if (lvl->faces) {
- MEM_freeN(lvl->faces);
- }
- if (lvl->edges) {
- MEM_freeN(lvl->edges);
- }
- if (lvl->colfaces) {
- MEM_freeN(lvl->colfaces);
- }
- }
-}
-
-void multires_free(Multires *mr)
-{
- if (mr) {
- MultiresLevel *lvl = mr->levels.first;
-
- /* Free the first-level data */
- if (lvl) {
- CustomData_free(&mr->vdata, lvl->totvert);
- CustomData_free(&mr->fdata, lvl->totface);
- if (mr->edge_flags) {
- MEM_freeN(mr->edge_flags);
- }
- if (mr->edge_creases) {
- MEM_freeN(mr->edge_creases);
- }
- }
-
- while (lvl) {
- multires_free_level(lvl);
- lvl = lvl->next;
- }
-
- /* mr->verts may be NULL when loading old files,
- * see direct_link_mesh() in readfile.c, and T43560. */
- MEM_SAFE_FREE(mr->verts);
-
- BLI_freelistN(&mr->levels);
-
- MEM_freeN(mr);
- }
-}
-
-typedef struct IndexNode {
- struct IndexNode *next, *prev;
- int index;
-} IndexNode;
-
-static void create_old_vert_face_map(ListBase **map,
- IndexNode **mem,
- const MultiresFace *mface,
- const int totvert,
- const int totface)
-{
- int i, j;
- IndexNode *node = NULL;
-
- (*map) = MEM_calloc_arrayN(totvert, sizeof(ListBase), "vert face map");
- (*mem) = MEM_calloc_arrayN(totface, sizeof(IndexNode[4]), "vert face map mem");
- node = *mem;
-
- /* Find the users */
- for (i = 0; i < totface; i++) {
- for (j = 0; j < (mface[i].v[3] ? 4 : 3); j++, node++) {
- node->index = i;
- BLI_addtail(&(*map)[mface[i].v[j]], node);
- }
- }
-}
-
-static void create_old_vert_edge_map(ListBase **map,
- IndexNode **mem,
- const MultiresEdge *medge,
- const int totvert,
- const int totedge)
-{
- int i, j;
- IndexNode *node = NULL;
-
- (*map) = MEM_calloc_arrayN(totvert, sizeof(ListBase), "vert edge map");
- (*mem) = MEM_calloc_arrayN(totedge, sizeof(IndexNode[2]), "vert edge map mem");
- node = *mem;
-
- /* Find the users */
- for (i = 0; i < totedge; i++) {
- for (j = 0; j < 2; j++, node++) {
- node->index = i;
- BLI_addtail(&(*map)[medge[i].v[j]], node);
- }
- }
-}
-
-static MultiresFace *find_old_face(
- ListBase *map, MultiresFace *faces, int v1, int v2, int v3, int v4)
-{
- IndexNode *n1;
- int v[4], i, j;
-
- v[0] = v1;
- v[1] = v2;
- v[2] = v3;
- v[3] = v4;
-
- for (n1 = map[v1].first; n1; n1 = n1->next) {
- int fnd[4] = {0, 0, 0, 0};
-
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++) {
- if (v[i] == faces[n1->index].v[j]) {
- fnd[i] = 1;
- }
- }
- }
-
- if (fnd[0] && fnd[1] && fnd[2] && fnd[3]) {
- return &faces[n1->index];
- }
- }
-
- return NULL;
-}
-
-static MultiresEdge *find_old_edge(ListBase *map, MultiresEdge *edges, int v1, int v2)
-{
- IndexNode *n1, *n2;
-
- for (n1 = map[v1].first; n1; n1 = n1->next) {
- for (n2 = map[v2].first; n2; n2 = n2->next) {
- if (n1->index == n2->index) {
- return &edges[n1->index];
- }
- }
- }
-
- return NULL;
-}
-
-static void multires_load_old_edges(
- ListBase **emap, MultiresLevel *lvl, int *vvmap, int dst, int v1, int v2, int mov)
-{
- int emid = find_old_edge(emap[2], lvl->edges, v1, v2)->mid;
- vvmap[dst + mov] = emid;
-
- if (lvl->next->next) {
- multires_load_old_edges(emap + 1, lvl->next, vvmap, dst + mov, v1, emid, mov / 2);
- multires_load_old_edges(emap + 1, lvl->next, vvmap, dst + mov, v2, emid, -mov / 2);
- }
-}
-
-static void multires_load_old_faces(ListBase **fmap,
- ListBase **emap,
- MultiresLevel *lvl,
- int *vvmap,
- int dst,
- int v1,
- int v2,
- int v3,
- int v4,
- int st2,
- int st3)
-{
- int fmid;
- int emid13, emid14, emid23, emid24;
-
- if (lvl && lvl->next) {
- fmid = find_old_face(fmap[1], lvl->faces, v1, v2, v3, v4)->mid;
- vvmap[dst] = fmid;
-
- emid13 = find_old_edge(emap[1], lvl->edges, v1, v3)->mid;
- emid14 = find_old_edge(emap[1], lvl->edges, v1, v4)->mid;
- emid23 = find_old_edge(emap[1], lvl->edges, v2, v3)->mid;
- emid24 = find_old_edge(emap[1], lvl->edges, v2, v4)->mid;
-
- multires_load_old_faces(fmap + 1,
- emap + 1,
- lvl->next,
- vvmap,
- dst + st2 * st3 + st3,
- fmid,
- v2,
- emid23,
- emid24,
- st2,
- st3 / 2);
-
- multires_load_old_faces(fmap + 1,
- emap + 1,
- lvl->next,
- vvmap,
- dst - st2 * st3 + st3,
- emid14,
- emid24,
- fmid,
- v4,
- st2,
- st3 / 2);
-
- multires_load_old_faces(fmap + 1,
- emap + 1,
- lvl->next,
- vvmap,
- dst + st2 * st3 - st3,
- emid13,
- emid23,
- v3,
- fmid,
- st2,
- st3 / 2);
-
- multires_load_old_faces(fmap + 1,
- emap + 1,
- lvl->next,
- vvmap,
- dst - st2 * st3 - st3,
- v1,
- fmid,
- emid13,
- emid14,
- st2,
- st3 / 2);
-
- if (lvl->next->next) {
- multires_load_old_edges(emap, lvl->next, vvmap, dst, emid24, fmid, st3);
- multires_load_old_edges(emap, lvl->next, vvmap, dst, emid13, fmid, -st3);
- multires_load_old_edges(emap, lvl->next, vvmap, dst, emid14, fmid, -st2 * st3);
- multires_load_old_edges(emap, lvl->next, vvmap, dst, emid23, fmid, st2 * st3);
- }
- }
-}
-
-static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert)
-{
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
- CCGSubSurf *ss = ccgdm->ss;
- CCGElem *vd;
- CCGKey key;
- int index;
- int totvert, totedge, totface;
- int gridSize = ccgSubSurf_getGridSize(ss);
- int edgeSize = ccgSubSurf_getEdgeSize(ss);
- int i = 0;
-
- dm->getGridKey(dm, &key);
-
- totface = ccgSubSurf_getNumFaces(ss);
- for (index = 0; index < totface; index++) {
- CCGFace *f = ccgdm->faceMap[index].face;
- int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
-
- vd = ccgSubSurf_getFaceCenterData(f);
- copy_v3_v3(CCG_elem_co(&key, vd), mvert[i].co);
- i++;
-
- for (S = 0; S < numVerts; S++) {
- for (x = 1; x < gridSize - 1; x++, i++) {
- vd = ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
- copy_v3_v3(CCG_elem_co(&key, vd), mvert[i].co);
- }
- }
-
- for (S = 0; S < numVerts; S++) {
- for (y = 1; y < gridSize - 1; y++) {
- for (x = 1; x < gridSize - 1; x++, i++) {
- vd = ccgSubSurf_getFaceGridData(ss, f, S, x, y);
- copy_v3_v3(CCG_elem_co(&key, vd), mvert[i].co);
- }
- }
- }
- }
-
- totedge = ccgSubSurf_getNumEdges(ss);
- for (index = 0; index < totedge; index++) {
- CCGEdge *e = ccgdm->edgeMap[index].edge;
- int x;
-
- for (x = 1; x < edgeSize - 1; x++, i++) {
- vd = ccgSubSurf_getEdgeData(ss, e, x);
- copy_v3_v3(CCG_elem_co(&key, vd), mvert[i].co);
- }
- }
-
- totvert = ccgSubSurf_getNumVerts(ss);
- for (index = 0; index < totvert; index++) {
- CCGVert *v = ccgdm->vertMap[index].vert;
-
- vd = ccgSubSurf_getVertData(ss, v);
- copy_v3_v3(CCG_elem_co(&key, vd), mvert[i].co);
- i++;
- }
-
- ccgSubSurf_updateToFaces(ss, 0, NULL, 0);
-}
-
-/* Loads a multires object stored in the old Multires struct into the new format */
-static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
-{
- MultiresLevel *lvl, *lvl1;
- Multires *mr = me->mr;
- MVert *vsrc, *vdst;
- unsigned int src, dst;
- int st_last = multires_side_tot[totlvl - 1] - 1;
- int extedgelen = multires_side_tot[totlvl] - 2;
- int *vvmap; // inorder for dst, map to src
- int crossedgelen;
- int s, x, tottri, totquad;
- unsigned int i, j, totvert;
-
- src = 0;
- vsrc = mr->verts;
- vdst = dm->getVertArray(dm);
- totvert = (unsigned int)dm->getNumVerts(dm);
- vvmap = MEM_calloc_arrayN(totvert, sizeof(int), "multires vvmap");
-
- if (!vvmap) {
- return;
- }
-
- lvl1 = mr->levels.first;
- /* Load base verts */
- for (i = 0; i < lvl1->totvert; i++) {
- vvmap[totvert - lvl1->totvert + i] = src;
- src++;
- }
-
- /* Original edges */
- dst = totvert - lvl1->totvert - extedgelen * lvl1->totedge;
- for (i = 0; i < lvl1->totedge; i++) {
- int ldst = dst + extedgelen * i;
- int lsrc = src;
- lvl = lvl1->next;
-
- for (j = 2; j <= mr->level_count; j++) {
- int base = multires_side_tot[totlvl - j + 1] - 2;
- int skip = multires_side_tot[totlvl - j + 2] - 1;
- int st = multires_side_tot[j - 1] - 1;
-
- for (x = 0; x < st; x++) {
- vvmap[ldst + base + x * skip] = lsrc + st * i + x;
- }
-
- lsrc += lvl->totvert - lvl->prev->totvert;
- lvl = lvl->next;
- }
- }
-
- /* Center points */
- dst = 0;
- for (i = 0; i < lvl1->totface; i++) {
- int sides = lvl1->faces[i].v[3] ? 4 : 3;
-
- vvmap[dst] = src + lvl1->totedge + i;
- dst += 1 + sides * (st_last - 1) * st_last;
- }
-
- /* The rest is only for level 3 and up */
- if (lvl1->next && lvl1->next->next) {
- ListBase **fmap, **emap;
- IndexNode **fmem, **emem;
-
- /* Face edge cross */
- tottri = totquad = 0;
- crossedgelen = multires_side_tot[totlvl - 1] - 2;
- dst = 0;
- for (i = 0; i < lvl1->totface; i++) {
- int sides = lvl1->faces[i].v[3] ? 4 : 3;
-
- lvl = lvl1->next->next;
- dst++;
-
- for (j = 3; j <= mr->level_count; j++) {
- int base = multires_side_tot[totlvl - j + 1] - 2;
- int skip = multires_side_tot[totlvl - j + 2] - 1;
- int st = pow(2, j - 2);
- int st2 = pow(2, j - 3);
- int lsrc = lvl->prev->totvert;
-
- /* Skip exterior edge verts */
- lsrc += lvl1->totedge * st;
-
- /* Skip earlier face edge crosses */
- lsrc += st2 * (tottri * 3 + totquad * 4);
-
- for (s = 0; s < sides; s++) {
- for (x = 0; x < st2; x++) {
- vvmap[dst + crossedgelen * (s + 1) - base - x * skip - 1] = lsrc;
- lsrc++;
- }
- }
-
- lvl = lvl->next;
- }
-
- dst += sides * (st_last - 1) * st_last;
-
- if (sides == 4) {
- totquad++;
- }
- else {
- tottri++;
- }
- }
-
- /* calculate vert to edge/face maps for each level (except the last) */
- fmap = MEM_calloc_arrayN((mr->level_count - 1), sizeof(ListBase *), "multires fmap");
- emap = MEM_calloc_arrayN((mr->level_count - 1), sizeof(ListBase *), "multires emap");
- fmem = MEM_calloc_arrayN((mr->level_count - 1), sizeof(IndexNode *), "multires fmem");
- emem = MEM_calloc_arrayN((mr->level_count - 1), sizeof(IndexNode *), "multires emem");
- lvl = lvl1;
- for (i = 0; i < (unsigned int)mr->level_count - 1; i++) {
- create_old_vert_face_map(fmap + i, fmem + i, lvl->faces, lvl->totvert, lvl->totface);
- create_old_vert_edge_map(emap + i, emem + i, lvl->edges, lvl->totvert, lvl->totedge);
- lvl = lvl->next;
- }
-
- /* Interior face verts */
- /* lvl = lvl1->next->next; */ /* UNUSED */
- dst = 0;
- for (j = 0; j < lvl1->totface; j++) {
- int sides = lvl1->faces[j].v[3] ? 4 : 3;
- int ldst = dst + 1 + sides * (st_last - 1);
-
- for (s = 0; s < sides; s++) {
- int st2 = multires_side_tot[totlvl - 1] - 2;
- int st3 = multires_side_tot[totlvl - 2] - 2;
- int st4 = st3 == 0 ? 1 : (st3 + 1) / 2;
- int mid = ldst + st2 * st3 + st3;
- int cv = lvl1->faces[j].v[s];
- int nv = lvl1->faces[j].v[s == sides - 1 ? 0 : s + 1];
- int pv = lvl1->faces[j].v[s == 0 ? sides - 1 : s - 1];
-
- multires_load_old_faces(fmap,
- emap,
- lvl1->next,
- vvmap,
- mid,
- vvmap[dst],
- cv,
- find_old_edge(emap[0], lvl1->edges, pv, cv)->mid,
- find_old_edge(emap[0], lvl1->edges, cv, nv)->mid,
- st2,
- st4);
-
- ldst += (st_last - 1) * (st_last - 1);
- }
-
- dst = ldst;
- }
-
- /*lvl = lvl->next;*/ /*UNUSED*/
-
- for (i = 0; i < (unsigned int)(mr->level_count - 1); i++) {
- MEM_freeN(fmap[i]);
- MEM_freeN(fmem[i]);
- MEM_freeN(emap[i]);
- MEM_freeN(emem[i]);
- }
-
- MEM_freeN(fmap);
- MEM_freeN(emap);
- MEM_freeN(fmem);
- MEM_freeN(emem);
- }
-
- /* Transfer verts */
- for (i = 0; i < totvert; i++) {
- copy_v3_v3(vdst[i].co, vsrc[vvmap[i]].co);
- }
-
- MEM_freeN(vvmap);
-
- multires_mvert_to_ss(dm, vdst);
-}
-
-/* Copy the first-level vcol data to the mesh, if it exists */
-/* Warning: higher-level vcol data will be lost */
-static void multires_load_old_vcols(Mesh *me)
-{
- MultiresLevel *lvl;
- MultiresColFace *colface;
- MCol *mcol;
- int i, j;
-
- if (!(lvl = me->mr->levels.first)) {
- return;
- }
-
- if (!(colface = lvl->colfaces)) {
- return;
- }
-
- /* older multires format never supported multiple vcol layers,
- * so we can assume the active vcol layer is the correct one */
- if (!(mcol = CustomData_get_layer(&me->fdata, CD_MCOL))) {
- return;
- }
-
- for (i = 0; i < me->totface; i++) {
- for (j = 0; j < 4; j++) {
- mcol[i * 4 + j].a = colface[i].col[j].a;
- mcol[i * 4 + j].r = colface[i].col[j].r;
- mcol[i * 4 + j].g = colface[i].col[j].g;
- mcol[i * 4 + j].b = colface[i].col[j].b;
- }
- }
-}
-
-/* Copy the first-level face-flag data to the mesh */
-static void multires_load_old_face_flags(Mesh *me)
-{
- MultiresLevel *lvl;
- MultiresFace *faces;
- int i;
-
- if (!(lvl = me->mr->levels.first)) {
- return;
- }
-
- if (!(faces = lvl->faces)) {
- return;
- }
-
- for (i = 0; i < me->totface; i++) {
- me->mface[i].flag = faces[i].flag;
- }
-}
-
-void multires_load_old(Object *ob, Mesh *me)
-{
- MultiresLevel *lvl;
- ModifierData *md;
- MultiresModifierData *mmd;
- DerivedMesh *dm, *orig;
- CustomDataLayer *l;
- int i;
-
- /* Load original level into the mesh */
- lvl = me->mr->levels.first;
- CustomData_free_layers(&me->vdata, CD_MVERT, lvl->totvert);
- CustomData_free_layers(&me->edata, CD_MEDGE, lvl->totedge);
- CustomData_free_layers(&me->fdata, CD_MFACE, lvl->totface);
- me->totvert = lvl->totvert;
- me->totedge = lvl->totedge;
- me->totface = lvl->totface;
- me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
- me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, me->totedge);
- me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
- memcpy(me->mvert, me->mr->verts, sizeof(MVert) * me->totvert);
- for (i = 0; i < me->totedge; i++) {
- me->medge[i].v1 = lvl->edges[i].v[0];
- me->medge[i].v2 = lvl->edges[i].v[1];
- }
- for (i = 0; i < me->totface; i++) {
- me->mface[i].v1 = lvl->faces[i].v[0];
- me->mface[i].v2 = lvl->faces[i].v[1];
- me->mface[i].v3 = lvl->faces[i].v[2];
- me->mface[i].v4 = lvl->faces[i].v[3];
- me->mface[i].mat_nr = lvl->faces[i].mat_nr;
- }
-
- /* Copy the first-level data to the mesh */
- /* XXX We must do this before converting tessfaces to polys/lopps! */
- for (i = 0, l = me->mr->vdata.layers; i < me->mr->vdata.totlayer; i++, l++) {
- CustomData_add_layer(&me->vdata, l->type, CD_REFERENCE, l->data, me->totvert);
- }
- for (i = 0, l = me->mr->fdata.layers; i < me->mr->fdata.totlayer; i++, l++) {
- CustomData_add_layer(&me->fdata, l->type, CD_REFERENCE, l->data, me->totface);
- }
- CustomData_reset(&me->mr->vdata);
- CustomData_reset(&me->mr->fdata);
-
- multires_load_old_vcols(me);
- multires_load_old_face_flags(me);
-
- /* multiresModifier_subdivide_legacy (actually, multires_subdivide_legacy) expects polys, not
- * tessfaces! */
- BKE_mesh_convert_mfaces_to_mpolys(me);
-
- /* Add a multires modifier to the object */
- md = ob->modifiers.first;
- while (md && BKE_modifier_get_info(md->type)->type == eModifierTypeType_OnlyDeform) {
- md = md->next;
- }
- mmd = (MultiresModifierData *)BKE_modifier_new(eModifierType_Multires);
- BLI_insertlinkbefore(&ob->modifiers, md, mmd);
-
- for (i = 0; i < me->mr->level_count - 1; i++) {
- multiresModifier_subdivide_legacy(mmd, NULL, ob, 1, 0);
- }
-
- mmd->lvl = mmd->totlvl;
- orig = CDDM_from_mesh(me);
- /* XXX We *must* alloc paint mask here, else we have some kind of mismatch in
- * multires_modifier_update_mdisps() (called by dm->release(dm)), which always creates the
- * reference subsurfed dm with this option, before calling multiresModifier_disp_run(),
- * which implicitly expects both subsurfs from its first dm and oldGridData parameters to
- * be of the same "format"! */
- dm = multires_make_derived_from_derived(orig, mmd, NULL, ob, 0);
-
- multires_load_old_dm(dm, me, mmd->totlvl + 1);
-
- multires_dm_mark_as_modified(dm, MULTIRES_COORDS_MODIFIED);
- dm->release(dm);
- orig->release(orig);
-
- /* Remove the old multires */
- multires_free(me->mr);
- me->mr = NULL;
-}
-
/* If 'ob_src' and 'ob_dst' both have multires modifiers, synchronize them
* such that 'ob_dst' has the same total number of levels as 'ob_src'. */
void multiresModifier_sync_levels_ex(Object *ob_dst,
@@ -2234,14 +1366,8 @@ void multiresModifier_sync_levels_ex(Object *ob_dst,
}
if (mmd_src->totlvl > mmd_dst->totlvl) {
- if (mmd_dst->simple) {
- multiresModifier_subdivide_to_level(
- ob_dst, mmd_dst, mmd_src->totlvl, MULTIRES_SUBDIVIDE_SIMPLE);
- }
- else {
- multiresModifier_subdivide_to_level(
- ob_dst, mmd_dst, mmd_src->totlvl, MULTIRES_SUBDIVIDE_CATMULL_CLARK);
- }
+ multiresModifier_subdivide_to_level(
+ ob_dst, mmd_dst, mmd_src->totlvl, MULTIRES_SUBDIVIDE_CATMULL_CLARK);
}
else {
multires_del_higher(mmd_dst, ob_dst, mmd_src->totlvl);
diff --git a/source/blender/blenkernel/intern/multires_reshape.c b/source/blender/blenkernel/intern/multires_reshape.c
index 5bcf8f62f86..04ad78ec0de 100644
--- a/source/blender/blenkernel/intern/multires_reshape.c
+++ b/source/blender/blenkernel/intern/multires_reshape.c
@@ -225,7 +225,7 @@ void multiresModifier_subdivide_to_level(struct Object *object,
multires_flush_sculpt_updates(object);
- if (!multires_reshape_context_create_from_subdivide(&reshape_context, object, mmd, top_level)) {
+ if (!multires_reshape_context_create_from_modifier(&reshape_context, object, mmd, top_level)) {
return;
}
diff --git a/source/blender/blenkernel/intern/multires_reshape.h b/source/blender/blenkernel/intern/multires_reshape.h
index d6c1d79dfd7..36ecf1a6395 100644
--- a/source/blender/blenkernel/intern/multires_reshape.h
+++ b/source/blender/blenkernel/intern/multires_reshape.h
@@ -167,10 +167,16 @@ bool multires_reshape_context_create_from_ccg(MultiresReshapeContext *reshape_co
struct Mesh *base_mesh,
int top_level);
-bool multires_reshape_context_create_from_subdivide(MultiresReshapeContext *reshape_context,
- struct Object *object,
- struct MultiresModifierData *mmd,
- int top_level);
+bool multires_reshape_context_create_from_modifier(MultiresReshapeContext *reshape_context,
+ struct Object *object,
+ struct MultiresModifierData *mmd,
+ int top_level);
+
+bool multires_reshape_context_create_from_subdiv(MultiresReshapeContext *reshape_context,
+ struct Object *object,
+ struct MultiresModifierData *mmd,
+ struct Subdiv *subdiv,
+ int top_level);
void multires_reshape_free_original_grids(MultiresReshapeContext *reshape_context);
void multires_reshape_context_free(MultiresReshapeContext *reshape_context);
diff --git a/source/blender/blenkernel/intern/multires_reshape_apply_base.c b/source/blender/blenkernel/intern/multires_reshape_apply_base.c
index 6e7e2b90c05..b693b1114ba 100644
--- a/source/blender/blenkernel/intern/multires_reshape_apply_base.c
+++ b/source/blender/blenkernel/intern/multires_reshape_apply_base.c
@@ -81,11 +81,6 @@ static float v3_dist_from_plane(const float v[3], const float center[3], const f
void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape_context)
{
- if (reshape_context->mmd->simple) {
- /* Simple subdivisions does not move base mesh verticies, so no refitting is needed. */
- return;
- }
-
Mesh *base_mesh = reshape_context->base_mesh;
MeshElemMap *pmap;
diff --git a/source/blender/blenkernel/intern/multires_reshape_subdivide.c b/source/blender/blenkernel/intern/multires_reshape_subdivide.c
index 7b7c1efc533..d42a061084f 100644
--- a/source/blender/blenkernel/intern/multires_reshape_subdivide.c
+++ b/source/blender/blenkernel/intern/multires_reshape_subdivide.c
@@ -96,7 +96,7 @@ void multires_subdivide_create_tangent_displacement_linear_grids(Object *object,
/* Convert the new grids to tangent displacement. */
multires_set_tot_level(object, mmd, new_top_level);
- if (!multires_reshape_context_create_from_subdivide(
+ if (!multires_reshape_context_create_from_modifier(
&reshape_context, object, mmd, new_top_level)) {
return;
}
diff --git a/source/blender/blenkernel/intern/multires_reshape_util.c b/source/blender/blenkernel/intern/multires_reshape_util.c
index c8179dd8a2d..8fb406e54a5 100644
--- a/source/blender/blenkernel/intern/multires_reshape_util.c
+++ b/source/blender/blenkernel/intern/multires_reshape_util.c
@@ -242,10 +242,26 @@ bool multires_reshape_context_create_from_ccg(MultiresReshapeContext *reshape_co
return context_verify_or_free(reshape_context);
}
-bool multires_reshape_context_create_from_subdivide(MultiresReshapeContext *reshape_context,
- struct Object *object,
- struct MultiresModifierData *mmd,
- int top_level)
+bool multires_reshape_context_create_from_modifier(MultiresReshapeContext *reshape_context,
+ struct Object *object,
+ struct MultiresModifierData *mmd,
+ int top_level)
+{
+ Subdiv *subdiv = multires_reshape_create_subdiv(NULL, object, mmd);
+
+ const bool result = multires_reshape_context_create_from_subdiv(
+ reshape_context, object, mmd, subdiv, top_level);
+
+ reshape_context->need_free_subdiv = true;
+
+ return result;
+}
+
+bool multires_reshape_context_create_from_subdiv(MultiresReshapeContext *reshape_context,
+ struct Object *object,
+ struct MultiresModifierData *mmd,
+ struct Subdiv *subdiv,
+ int top_level)
{
context_zero(reshape_context);
@@ -254,8 +270,8 @@ bool multires_reshape_context_create_from_subdivide(MultiresReshapeContext *resh
reshape_context->mmd = mmd;
reshape_context->base_mesh = base_mesh;
- reshape_context->subdiv = multires_reshape_create_subdiv(NULL, object, mmd);
- reshape_context->need_free_subdiv = true;
+ reshape_context->subdiv = subdiv;
+ reshape_context->need_free_subdiv = false;
reshape_context->reshape.level = mmd->totlvl;
reshape_context->reshape.grid_size = BKE_subdiv_grid_size_from_level(
diff --git a/source/blender/blenkernel/intern/multires_subdiv.c b/source/blender/blenkernel/intern/multires_subdiv.c
index 73ef623fbfd..8156814d9f1 100644
--- a/source/blender/blenkernel/intern/multires_subdiv.c
+++ b/source/blender/blenkernel/intern/multires_subdiv.c
@@ -36,7 +36,7 @@
void BKE_multires_subdiv_settings_init(SubdivSettings *settings, const MultiresModifierData *mmd)
{
- settings->is_simple = (mmd->simple != 0);
+ settings->is_simple = false;
settings->is_adaptive = true;
settings->level = settings->is_simple ? 1 : mmd->quality;
settings->use_creases = (mmd->flags & eMultiresModifierFlag_UseCrease);
diff --git a/source/blender/blenkernel/intern/multires_versioning.c b/source/blender/blenkernel/intern/multires_versioning.c
new file mode 100644
index 00000000000..4c0d7165cd0
--- /dev/null
+++ b/source/blender/blenkernel/intern/multires_versioning.c
@@ -0,0 +1,106 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 by Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
+
+#include "BKE_subdiv.h"
+#include "BKE_subdiv_eval.h"
+
+#include "multires_reshape.h"
+#include "opensubdiv_converter_capi.h"
+#include "subdiv_converter.h"
+
+static float simple_to_catmull_clark_get_edge_sharpness(
+ const OpenSubdiv_Converter *UNUSED(converter), int UNUSED(manifold_edge_index))
+{
+ return 10.0f;
+}
+
+static bool simple_to_catmull_clark_is_infinite_sharp_vertex(
+ const OpenSubdiv_Converter *UNUSED(converter), int UNUSED(manifold_vertex_index))
+{
+ return true;
+}
+
+static Subdiv *subdiv_for_simple_to_catmull_clark(Object *object, MultiresModifierData *mmd)
+{
+ SubdivSettings subdiv_settings;
+ BKE_multires_subdiv_settings_init(&subdiv_settings, mmd);
+
+ Mesh *base_mesh = object->data;
+
+ OpenSubdiv_Converter converter;
+ BKE_subdiv_converter_init_for_mesh(&converter, &subdiv_settings, base_mesh);
+ converter.getEdgeSharpness = simple_to_catmull_clark_get_edge_sharpness;
+ converter.isInfiniteSharpVertex = simple_to_catmull_clark_is_infinite_sharp_vertex;
+
+ Subdiv *subdiv = BKE_subdiv_new_from_converter(&subdiv_settings, &converter);
+ BKE_subdiv_converter_free(&converter);
+
+ if (!BKE_subdiv_eval_begin_from_mesh(subdiv, base_mesh, NULL)) {
+ BKE_subdiv_free(subdiv);
+ return NULL;
+ }
+
+ return subdiv;
+}
+
+void multires_do_versions_simple_to_catmull_clark(Object *object, MultiresModifierData *mmd)
+{
+ const Mesh *base_mesh = object->data;
+ if (base_mesh->totloop == 0) {
+ return;
+ }
+
+ /* Store the grids displacement in object space against the simple limit surface. */
+ {
+ Subdiv *subdiv = subdiv_for_simple_to_catmull_clark(object, mmd);
+ MultiresReshapeContext reshape_context;
+ if (!multires_reshape_context_create_from_subdiv(
+ &reshape_context, object, mmd, subdiv, mmd->totlvl)) {
+ BKE_subdiv_free(subdiv);
+ return;
+ }
+
+ multires_reshape_store_original_grids(&reshape_context);
+ multires_reshape_assign_final_coords_from_mdisps(&reshape_context);
+ multires_reshape_context_free(&reshape_context);
+
+ BKE_subdiv_free(subdiv);
+ }
+
+ /* Calculate the new tangent displacement against the new Catmull-Clark limit surface. */
+ {
+ MultiresReshapeContext reshape_context;
+ if (!multires_reshape_context_create_from_modifier(
+ &reshape_context, object, mmd, mmd->totlvl)) {
+ return;
+ }
+ multires_reshape_object_grids_to_tangent_displacement(&reshape_context);
+ multires_reshape_context_free(&reshape_context);
+ }
+}
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 80a553ff525..e2e61284d2e 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -404,6 +404,8 @@ static void write_node_socket_interface(BlendWriter *writer, bNodeSocket *sock)
/* this is only direct data, tree itself should have been written */
void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
{
+ BKE_id_blend_write(writer, &ntree->id);
+
/* for link_list() speed, we write per list */
if (ntree->adt) {
@@ -525,9 +527,6 @@ static void ntree_blend_write(BlendWriter *writer, ID *id, const void *id_addres
ntree->execdata = NULL;
BLO_write_id_struct(writer, bNodeTree, id_address, &ntree->id);
- /* Note that trees directly used by other IDs (materials etc.) are not 'real' ID, they cannot
- * be linked, etc., so we write actual id data here only, for 'real' ID trees. */
- BKE_id_blend_write(writer, &ntree->id);
ntreeBlendWrite(writer, ntree);
}
@@ -853,6 +852,8 @@ IDTypeInfo IDType_ID_NT = {
.blend_read_data = ntree_blend_read_data,
.blend_read_lib = ntree_blend_read_lib,
.blend_read_expand = ntree_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType *ntype)
@@ -4662,7 +4663,7 @@ static void registerFunctionNodes(void)
register_node_type_fn_random_float();
}
-void init_nodesystem(void)
+void BKE_node_system_init(void)
{
nodetreetypes_hash = BLI_ghash_str_new("nodetreetypes_hash gh");
nodetypes_hash = BLI_ghash_str_new("nodetypes_hash gh");
@@ -4689,7 +4690,7 @@ void init_nodesystem(void)
registerFunctionNodes();
}
-void free_nodesystem(void)
+void BKE_node_system_exit(void)
{
if (nodetypes_hash) {
NODE_TYPES_BEGIN (nt) {
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 971f79e296f..5f8406e7d37 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -21,6 +21,9 @@
* \ingroup bke
*/
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#include <math.h>
#include <stdio.h>
#include <string.h>
@@ -35,6 +38,7 @@
#include "DNA_collection_types.h"
#include "DNA_constraint_types.h"
#include "DNA_defaults.h"
+#include "DNA_effect_types.h"
#include "DNA_fluid_types.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
@@ -47,6 +51,8 @@
#include "DNA_meshdata_types.h"
#include "DNA_meta_types.h"
#include "DNA_movieclip_types.h"
+#include "DNA_nla_types.h"
+#include "DNA_object_fluidsim_types.h"
#include "DNA_object_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_rigidbody_types.h"
@@ -123,7 +129,6 @@
#include "BKE_pointcloud.h"
#include "BKE_rigidbody.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
#include "BKE_shader_fx.h"
#include "BKE_softbody.h"
#include "BKE_speaker.h"
@@ -136,6 +141,10 @@
#include "DRW_engine.h"
+#include "BLO_read_write.h"
+
+#include "SEQ_sequencer.h"
+
#ifdef WITH_PYTHON
# include "BPY_extern.h"
#endif
@@ -516,6 +525,614 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data)
}
}
+static void write_defgroups(BlendWriter *writer, ListBase *defbase)
+{
+ LISTBASE_FOREACH (bDeformGroup *, defgroup, defbase) {
+ BLO_write_struct(writer, bDeformGroup, defgroup);
+ }
+}
+
+static void write_fmaps(BlendWriter *writer, ListBase *fbase)
+{
+ LISTBASE_FOREACH (bFaceMap *, fmap, fbase) {
+ BLO_write_struct(writer, bFaceMap, fmap);
+ }
+}
+
+static void object_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ Object *ob = (Object *)id;
+
+ const bool is_undo = BLO_write_is_undo(writer);
+ if (ob->id.us > 0 || is_undo) {
+ /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
+ BKE_object_runtime_reset(ob);
+
+ if (is_undo) {
+ /* For undo we stay in object mode during undo presses, so keep edit-mode disabled on save as
+ * well, can help reducing false detection of changed data-blocks. */
+ ob->mode &= ~OB_MODE_EDIT;
+ }
+
+ /* write LibData */
+ BLO_write_id_struct(writer, Object, id_address, &ob->id);
+ BKE_id_blend_write(writer, &ob->id);
+
+ if (ob->adt) {
+ BKE_animdata_blend_write(writer, ob->adt);
+ }
+
+ /* direct data */
+ BLO_write_pointer_array(writer, ob->totcol, ob->mat);
+ BLO_write_raw(writer, sizeof(char) * ob->totcol, ob->matbits);
+
+ bArmature *arm = NULL;
+ if (ob->type == OB_ARMATURE) {
+ arm = ob->data;
+ if (arm && ob->pose && arm->act_bone) {
+ BLI_strncpy(
+ ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
+ }
+ }
+
+ BKE_pose_blend_write(writer, ob->pose, arm);
+ write_defgroups(writer, &ob->defbase);
+ write_fmaps(writer, &ob->fmaps);
+ BKE_constraint_blend_write(writer, &ob->constraints);
+ animviz_motionpath_blend_write(writer, ob->mpath);
+
+ BLO_write_struct(writer, PartDeflect, ob->pd);
+ if (ob->soft) {
+ /* Set deprecated pointers to prevent crashes of older Blenders */
+ ob->soft->pointcache = ob->soft->shared->pointcache;
+ ob->soft->ptcaches = ob->soft->shared->ptcaches;
+ BLO_write_struct(writer, SoftBody, ob->soft);
+ BLO_write_struct(writer, SoftBody_Shared, ob->soft->shared);
+ BKE_ptcache_blend_write(writer, &(ob->soft->shared->ptcaches));
+ BLO_write_struct(writer, EffectorWeights, ob->soft->effector_weights);
+ }
+
+ if (ob->rigidbody_object) {
+ /* TODO: if any extra data is added to handle duplis, will need separate function then */
+ BLO_write_struct(writer, RigidBodyOb, ob->rigidbody_object);
+ }
+ if (ob->rigidbody_constraint) {
+ BLO_write_struct(writer, RigidBodyCon, ob->rigidbody_constraint);
+ }
+
+ if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
+ BLO_write_struct(writer, ImageUser, ob->iuser);
+ }
+
+ BKE_particle_system_blend_write(writer, &ob->particlesystem);
+ BKE_modifier_blend_write(writer, &ob->modifiers);
+ BKE_gpencil_modifier_blend_write(writer, &ob->greasepencil_modifiers);
+ BKE_shaderfx_blend_write(writer, &ob->shader_fx);
+
+ BLO_write_struct_list(writer, LinkData, &ob->pc_ids);
+
+ BKE_previewimg_blend_write(writer, ob->preview);
+ }
+}
+
+/* XXX deprecated - old animation system */
+static void direct_link_nlastrips(BlendDataReader *reader, ListBase *strips)
+{
+ BLO_read_list(reader, strips);
+
+ LISTBASE_FOREACH (bActionStrip *, strip, strips) {
+ BLO_read_list(reader, &strip->modifiers);
+ }
+}
+
+static void object_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ Object *ob = (Object *)id;
+
+ PartEff *paf;
+
+ /* XXX This should not be needed - but seems like it can happen in some cases,
+ * so for now play safe. */
+ ob->proxy_from = NULL;
+
+ const bool is_undo = BLO_read_data_is_undo(reader);
+ 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);
+ }
+
+ BLO_read_data_address(reader, &ob->adt);
+ BKE_animdata_blend_read_data(reader, ob->adt);
+
+ BLO_read_data_address(reader, &ob->pose);
+ BKE_pose_blend_read_data(reader, ob->pose);
+
+ BLO_read_data_address(reader, &ob->mpath);
+ if (ob->mpath) {
+ animviz_motionpath_blend_read_data(reader, ob->mpath);
+ }
+
+ BLO_read_list(reader, &ob->defbase);
+ BLO_read_list(reader, &ob->fmaps);
+ /* XXX deprecated - old animation system <<< */
+ direct_link_nlastrips(reader, &ob->nlastrips);
+ BLO_read_list(reader, &ob->constraintChannels);
+ /* >>> XXX deprecated - old animation system */
+
+ BLO_read_pointer_array(reader, (void **)&ob->mat);
+ BLO_read_data_address(reader, &ob->matbits);
+
+ /* do it here, below old data gets converted */
+ BKE_modifier_blend_read_data(reader, &ob->modifiers, ob);
+ BKE_gpencil_modifier_blend_read_data(reader, &ob->greasepencil_modifiers);
+ BKE_shaderfx_blend_read_data(reader, &ob->shader_fx);
+
+ BLO_read_list(reader, &ob->effect);
+ paf = ob->effect.first;
+ while (paf) {
+ if (paf->type == EFF_PARTICLE) {
+ paf->keys = NULL;
+ }
+ if (paf->type == EFF_WAVE) {
+ WaveEff *wav = (WaveEff *)paf;
+ PartEff *next = paf->next;
+ WaveModifierData *wmd = (WaveModifierData *)BKE_modifier_new(eModifierType_Wave);
+
+ wmd->damp = wav->damp;
+ wmd->flag = wav->flag;
+ wmd->height = wav->height;
+ wmd->lifetime = wav->lifetime;
+ wmd->narrow = wav->narrow;
+ wmd->speed = wav->speed;
+ wmd->startx = wav->startx;
+ wmd->starty = wav->startx;
+ wmd->timeoffs = wav->timeoffs;
+ wmd->width = wav->width;
+
+ BLI_addtail(&ob->modifiers, wmd);
+
+ BLI_remlink(&ob->effect, paf);
+ MEM_freeN(paf);
+
+ paf = next;
+ continue;
+ }
+ if (paf->type == EFF_BUILD) {
+ BuildEff *baf = (BuildEff *)paf;
+ PartEff *next = paf->next;
+ BuildModifierData *bmd = (BuildModifierData *)BKE_modifier_new(eModifierType_Build);
+
+ bmd->start = baf->sfra;
+ bmd->length = baf->len;
+ bmd->randomize = 0;
+ bmd->seed = 1;
+
+ BLI_addtail(&ob->modifiers, bmd);
+
+ BLI_remlink(&ob->effect, paf);
+ MEM_freeN(paf);
+
+ paf = next;
+ continue;
+ }
+ paf = paf->next;
+ }
+
+ BLO_read_data_address(reader, &ob->pd);
+ BKE_particle_partdeflect_blend_read_data(reader, ob->pd);
+ BLO_read_data_address(reader, &ob->soft);
+ if (ob->soft) {
+ SoftBody *sb = ob->soft;
+
+ sb->bpoint = NULL; /* init pointers so it gets rebuilt nicely */
+ sb->bspring = NULL;
+ sb->scratch = NULL;
+ /* although not used anymore */
+ /* still have to be loaded to be compatible with old files */
+ BLO_read_pointer_array(reader, (void **)&sb->keys);
+ if (sb->keys) {
+ for (int a = 0; a < sb->totkey; a++) {
+ BLO_read_data_address(reader, &sb->keys[a]);
+ }
+ }
+
+ BLO_read_data_address(reader, &sb->effector_weights);
+ if (!sb->effector_weights) {
+ sb->effector_weights = BKE_effector_add_weights(NULL);
+ }
+
+ BLO_read_data_address(reader, &sb->shared);
+ if (sb->shared == NULL) {
+ /* Link deprecated caches if they exist, so we can use them for versioning.
+ * We should only do this when sb->shared == NULL, because those pointers
+ * are always set (for compatibility with older Blenders). We mustn't link
+ * the same pointcache twice. */
+ BKE_ptcache_blend_read_data(reader, &sb->ptcaches, &sb->pointcache, false);
+ }
+ else {
+ /* link caches */
+ BKE_ptcache_blend_read_data(reader, &sb->shared->ptcaches, &sb->shared->pointcache, false);
+ }
+ }
+ BLO_read_data_address(reader, &ob->fluidsimSettings); /* NT */
+
+ BLO_read_data_address(reader, &ob->rigidbody_object);
+ if (ob->rigidbody_object) {
+ RigidBodyOb *rbo = ob->rigidbody_object;
+ /* Allocate runtime-only struct */
+ rbo->shared = MEM_callocN(sizeof(*rbo->shared), "RigidBodyObShared");
+ }
+ BLO_read_data_address(reader, &ob->rigidbody_constraint);
+ if (ob->rigidbody_constraint) {
+ ob->rigidbody_constraint->physics_constraint = NULL;
+ }
+
+ BLO_read_list(reader, &ob->particlesystem);
+ BKE_particle_system_blend_read_data(reader, &ob->particlesystem);
+
+ BKE_constraint_blend_read_data(reader, &ob->constraints);
+
+ BLO_read_list(reader, &ob->hooks);
+ while (ob->hooks.first) {
+ ObHook *hook = ob->hooks.first;
+ HookModifierData *hmd = (HookModifierData *)BKE_modifier_new(eModifierType_Hook);
+
+ BLO_read_int32_array(reader, hook->totindex, &hook->indexar);
+
+ /* Do conversion here because if we have loaded
+ * a hook we need to make sure it gets converted
+ * and freed, regardless of version.
+ */
+ copy_v3_v3(hmd->cent, hook->cent);
+ hmd->falloff = hook->falloff;
+ hmd->force = hook->force;
+ hmd->indexar = hook->indexar;
+ hmd->object = hook->parent;
+ memcpy(hmd->parentinv, hook->parentinv, sizeof(hmd->parentinv));
+ hmd->totindex = hook->totindex;
+
+ BLI_addhead(&ob->modifiers, hmd);
+ BLI_remlink(&ob->hooks, hook);
+
+ BKE_modifier_unique_name(&ob->modifiers, (ModifierData *)hmd);
+
+ MEM_freeN(hook);
+ }
+
+ BLO_read_data_address(reader, &ob->iuser);
+ if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE && !ob->iuser) {
+ BKE_object_empty_draw_type_set(ob, ob->empty_drawtype);
+ }
+
+ BKE_object_runtime_reset(ob);
+ BLO_read_list(reader, &ob->pc_ids);
+
+ /* in case this value changes in future, clamp else we get undefined behavior */
+ CLAMP(ob->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
+
+ if (ob->sculpt) {
+ ob->sculpt = NULL;
+ /* Only create data on undo, otherwise rely on editor mode switching. */
+ if (BLO_read_data_is_undo(reader) && (ob->mode & OB_MODE_ALL_SCULPT)) {
+ BKE_object_sculpt_data_create(ob);
+ }
+ }
+
+ BLO_read_data_address(reader, &ob->preview);
+ BKE_previewimg_blend_read(reader, ob->preview);
+}
+
+/* XXX deprecated - old animation system */
+static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *striplist)
+{
+ LISTBASE_FOREACH (bActionStrip *, strip, striplist) {
+ BLO_read_id_address(reader, id->lib, &strip->object);
+ BLO_read_id_address(reader, id->lib, &strip->act);
+ BLO_read_id_address(reader, id->lib, &strip->ipo);
+ LISTBASE_FOREACH (bActionModifier *, amod, &strip->modifiers) {
+ BLO_read_id_address(reader, id->lib, &amod->ob);
+ }
+ }
+}
+
+/* XXX deprecated - old animation system */
+static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
+{
+ LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
+ BLO_read_id_address(reader, id->lib, &chan->ipo);
+ }
+}
+
+static void object_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+ Object *ob = (Object *)id;
+
+ bool warn = false;
+
+ /* 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 */
+
+ BLO_read_id_address(reader, ob->id.lib, &ob->parent);
+ BLO_read_id_address(reader, ob->id.lib, &ob->track);
+ BLO_read_id_address(reader, ob->id.lib, &ob->poselib);
+
+ /* 2.8x drops support for non-empty dupli instances. */
+ if (ob->type == OB_EMPTY) {
+ BLO_read_id_address(reader, ob->id.lib, &ob->instance_collection);
+ }
+ else {
+ if (ob->instance_collection != NULL) {
+ ID *new_id = BLO_read_get_new_id_address(reader, ob->id.lib, &ob->instance_collection->id);
+ BLO_reportf_wrap(BLO_read_lib_reports(reader),
+ RPT_WARNING,
+ TIP_("Non-Empty object '%s' cannot duplicate collection '%s' "
+ "anymore in Blender 2.80, removed instancing"),
+ ob->id.name + 2,
+ new_id->name + 2);
+ }
+ ob->instance_collection = NULL;
+ ob->transflag &= ~OB_DUPLICOLLECTION;
+ }
+
+ BLO_read_id_address(reader, ob->id.lib, &ob->proxy);
+ if (ob->proxy) {
+ /* paranoia check, actually a proxy_from pointer should never be written... */
+ if (ob->proxy->id.lib == NULL) {
+ ob->proxy->proxy_from = NULL;
+ ob->proxy = NULL;
+
+ if (ob->id.lib) {
+ printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->filepath);
+ }
+ else {
+ printf("Proxy lost from object %s lib <NONE>\n", ob->id.name + 2);
+ }
+ }
+ else {
+ /* this triggers object_update to always use a copy */
+ ob->proxy->proxy_from = ob;
+ }
+ }
+ BLO_read_id_address(reader, ob->id.lib, &ob->proxy_group);
+
+ void *poin = ob->data;
+ BLO_read_id_address(reader, ob->id.lib, &ob->data);
+
+ if (ob->data == NULL && poin != NULL) {
+ if (ob->id.lib) {
+ printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->filepath);
+ }
+ else {
+ printf("Object %s lost data.\n", ob->id.name + 2);
+ }
+
+ ob->type = OB_EMPTY;
+ warn = true;
+
+ if (ob->pose) {
+ /* we can't call #BKE_pose_free() here because of library linking
+ * freeing will recurse down into every pose constraints ID pointers
+ * which are not always valid, so for now free directly and suffer
+ * some leaked memory rather than crashing immediately
+ * while bad this _is_ an exceptional case - campbell */
+#if 0
+ BKE_pose_free(ob->pose);
+#else
+ MEM_freeN(ob->pose);
+#endif
+ ob->pose = NULL;
+ ob->mode &= ~OB_MODE_POSE;
+ }
+ }
+ for (int a = 0; a < ob->totcol; a++) {
+ BLO_read_id_address(reader, ob->id.lib, &ob->mat[a]);
+ }
+
+ /* When the object is local and the data is library its possible
+ * the material list size gets out of sync. T22663. */
+ if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) {
+ const short *totcol_data = BKE_object_material_len_p(ob);
+ /* Only expand so as not to lose any object materials that might be set. */
+ if (totcol_data && (*totcol_data > ob->totcol)) {
+ /* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */
+ BKE_object_material_resize(BLO_read_lib_get_main(reader), ob, *totcol_data, false);
+ }
+ }
+
+ BLO_read_id_address(reader, ob->id.lib, &ob->gpd);
+
+ /* if id.us==0 a new base will be created later on */
+
+ /* WARNING! Also check expand_object(), should reflect the stuff below. */
+ BKE_pose_blend_read_lib(reader, ob, ob->pose);
+ BKE_constraint_blend_read_lib(reader, &ob->id, &ob->constraints);
+
+ /* 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 */
+
+ LISTBASE_FOREACH (PartEff *, paf, &ob->effect) {
+ if (paf->type == EFF_PARTICLE) {
+ BLO_read_id_address(reader, ob->id.lib, &paf->group);
+ }
+ }
+
+ {
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)BKE_modifiers_findby_type(
+ ob, eModifierType_Fluidsim);
+
+ if (fluidmd && fluidmd->fss) {
+ BLO_read_id_address(
+ reader, ob->id.lib, &fluidmd->fss->ipo); /* XXX deprecated - old animation system */
+ }
+ }
+
+ {
+ FluidModifierData *fmd = (FluidModifierData *)BKE_modifiers_findby_type(ob,
+ eModifierType_Fluid);
+
+ if (fmd && (fmd->type == MOD_FLUID_TYPE_DOMAIN) && fmd->domain) {
+ /* Flag for refreshing the simulation after loading */
+ fmd->domain->flags |= FLUID_DOMAIN_FILE_LOAD;
+ }
+ else if (fmd && (fmd->type == MOD_FLUID_TYPE_FLOW) && fmd->flow) {
+ fmd->flow->flags &= ~FLUID_FLOW_NEEDS_UPDATE;
+ }
+ else if (fmd && (fmd->type == MOD_FLUID_TYPE_EFFEC) && fmd->effector) {
+ fmd->effector->flags &= ~FLUID_EFFECTOR_NEEDS_UPDATE;
+ }
+ }
+
+ /* texture field */
+ if (ob->pd) {
+ BKE_particle_partdeflect_blend_read_lib(reader, &ob->id, ob->pd);
+ }
+
+ if (ob->soft) {
+ BLO_read_id_address(reader, ob->id.lib, &ob->soft->collision_group);
+
+ BLO_read_id_address(reader, ob->id.lib, &ob->soft->effector_weights->group);
+ }
+
+ BKE_particle_system_blend_read_lib(reader, ob, &ob->id, &ob->particlesystem);
+ BKE_modifier_blend_read_lib(reader, ob);
+ BKE_gpencil_modifier_blend_read_lib(reader, ob);
+ BKE_shaderfx_blend_read_lib(reader, ob);
+
+ if (ob->rigidbody_constraint) {
+ BLO_read_id_address(reader, ob->id.lib, &ob->rigidbody_constraint->ob1);
+ BLO_read_id_address(reader, ob->id.lib, &ob->rigidbody_constraint->ob2);
+ }
+
+ if (warn) {
+ BLO_reportf_wrap(BLO_read_lib_reports(reader), RPT_WARNING, "Warning in console");
+ }
+}
+
+/* XXX deprecated - old animation system */
+static void expand_constraint_channels(BlendExpander *expander, ListBase *chanbase)
+{
+ LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
+ BLO_expand(expander, chan->ipo);
+ }
+}
+
+static void expand_object_expandModifiers(void *userData,
+ Object *UNUSED(ob),
+ ID **idpoin,
+ int UNUSED(cb_flag))
+{
+ BlendExpander *expander = userData;
+ BLO_expand(expander, *idpoin);
+}
+
+PartEff *BKE_object_do_version_give_parteff_245(Object *ob)
+{
+ PartEff *paf;
+
+ paf = ob->effect.first;
+ while (paf) {
+ if (paf->type == EFF_PARTICLE) {
+ return paf;
+ }
+ paf = paf->next;
+ }
+ return NULL;
+}
+
+static void object_blend_read_expand(BlendExpander *expander, ID *id)
+{
+ Object *ob = (Object *)id;
+
+ BLO_expand(expander, ob->data);
+
+ /* expand_object_expandModifier() */
+ if (ob->modifiers.first) {
+ BKE_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, expander);
+ }
+
+ /* expand_object_expandModifier() */
+ if (ob->greasepencil_modifiers.first) {
+ BKE_gpencil_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, expander);
+ }
+
+ /* expand_object_expandShaderFx() */
+ if (ob->shader_fx.first) {
+ BKE_shaderfx_foreach_ID_link(ob, expand_object_expandModifiers, expander);
+ }
+
+ BKE_pose_blend_read_expand(expander, ob->pose);
+ BLO_expand(expander, ob->poselib);
+ BKE_constraint_blend_read_expand(expander, &ob->constraints);
+
+ BLO_expand(expander, ob->gpd);
+
+ /* XXX deprecated - old animation system (for version patching only) */
+ BLO_expand(expander, ob->ipo);
+ BLO_expand(expander, ob->action);
+
+ expand_constraint_channels(expander, &ob->constraintChannels);
+
+ LISTBASE_FOREACH (bActionStrip *, strip, &ob->nlastrips) {
+ BLO_expand(expander, strip->object);
+ BLO_expand(expander, strip->act);
+ BLO_expand(expander, strip->ipo);
+ }
+ /* XXX deprecated - old animation system (for version patching only) */
+
+ for (int a = 0; a < ob->totcol; a++) {
+ BLO_expand(expander, ob->mat[a]);
+ }
+
+ PartEff *paf = BKE_object_do_version_give_parteff_245(ob);
+ if (paf && paf->group) {
+ BLO_expand(expander, paf->group);
+ }
+
+ if (ob->instance_collection) {
+ BLO_expand(expander, ob->instance_collection);
+ }
+
+ if (ob->proxy) {
+ BLO_expand(expander, ob->proxy);
+ }
+ if (ob->proxy_group) {
+ BLO_expand(expander, ob->proxy_group);
+ }
+
+ LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
+ BLO_expand(expander, psys->part);
+ }
+
+ if (ob->pd) {
+ BLO_expand(expander, ob->pd->tex);
+ BLO_expand(expander, ob->pd->f_source);
+ }
+
+ if (ob->soft) {
+ BLO_expand(expander, ob->soft->collision_group);
+
+ if (ob->soft->effector_weights) {
+ BLO_expand(expander, ob->soft->effector_weights->group);
+ }
+ }
+
+ if (ob->rigidbody_constraint) {
+ BLO_expand(expander, ob->rigidbody_constraint->ob1);
+ BLO_expand(expander, ob->rigidbody_constraint->ob2);
+ }
+}
+
IDTypeInfo IDType_ID_OB = {
.id_code = ID_OB,
.id_filter = FILTER_ID_OB,
@@ -533,10 +1150,12 @@ IDTypeInfo IDType_ID_OB = {
.foreach_id = object_foreach_id,
.foreach_cache = NULL,
- .blend_write = NULL,
- .blend_read_data = NULL,
- .blend_read_lib = NULL,
- .blend_read_expand = NULL,
+ .blend_write = object_blend_write,
+ .blend_read_data = object_blend_read_data,
+ .blend_read_lib = object_blend_read_lib,
+ .blend_read_expand = object_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
void BKE_object_workob_clear(Object *workob)
@@ -3692,6 +4311,10 @@ static int pc_cmp(const void *a, const void *b)
return 0;
}
+/* TODO: Review the usages of this function, currently with COW it will be called for orig object
+ * and then again for COW copies of it, think this is bad since there is no guarantee that we get
+ * the same stack index in both cases? Order is important since this index is used for filenames on
+ * disk. */
int BKE_object_insert_ptcache(Object *ob)
{
LinkData *link = NULL;
@@ -4806,3 +5429,16 @@ void BKE_object_check_uuids_unique_and_report(const Object *object)
BKE_pose_check_uuids_unique_and_report(object->pose);
BKE_modifier_check_uuids_unique_and_report(object);
}
+
+void BKE_object_modifiers_lib_link_common(void *userData,
+ struct Object *ob,
+ struct ID **idpoin,
+ int cb_flag)
+{
+ BlendLibReader *reader = userData;
+
+ BLO_read_id_address(reader, ob->id.lib, idpoin);
+ if (*idpoin != NULL && (cb_flag & IDWALK_CB_USER) != 0) {
+ id_us_plus_no_lib(*idpoin);
+ }
+}
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index 04f7529c6cd..1e7624d0d7d 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -51,6 +51,7 @@
#include "BKE_object.h"
#include "BKE_object_deform.h" /* own include */
+/* -------------------------------------------------------------------- */
/** \name Misc helpers
* \{ */
@@ -106,6 +107,7 @@ void BKE_object_defgroup_remap_update_users(Object *ob, const int *map)
}
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Group creation
* \{ */
@@ -156,6 +158,7 @@ MDeformVert *BKE_object_defgroup_data_create(ID *id)
}
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Group clearing
* \{ */
@@ -256,6 +259,7 @@ bool BKE_object_defgroup_clear_all(Object *ob, const bool use_selection)
}
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Group removal
* \{ */
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 39d6ee2700c..a1b01bce6c9 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1392,7 +1392,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
mat4_to_size(original_size, obmat);
size_to_mat4(size_mat, original_size);
- xvec[0] = -1.f;
+ xvec[0] = -1.0f;
xvec[1] = xvec[2] = 0;
vec_to_quat(q, xvec, ob->trackflag, ob->upflag);
quat_to_mat4(obmat, q);
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 6c770e53000..1d62a1cce2a 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -47,7 +47,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-#include "RE_render_ext.h"
+#include "RE_texture.h"
#include "BLI_hash.h"
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index ac3686a021b..87239d160b4 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -51,6 +51,9 @@
#include "BKE_sound.h"
#include "BKE_volume.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
#include "BLO_read_write.h"
int BKE_packedfile_seek(PackedFile *pf, int offset, int whence)
@@ -517,15 +520,30 @@ static void unpack_generate_paths(const char *name,
size_t abspathlen,
size_t relpathlen)
{
+ const short id_type = GS(id->name);
char tempname[FILE_MAX];
char tempdir[FILE_MAXDIR];
BLI_split_dirfile(name, tempdir, tempname, sizeof(tempdir), sizeof(tempname));
if (tempname[0] == '\0') {
- /* Note: we do not have any real way to re-create extension out of data... */
+ /* Note: we generally do not have any real way to re-create extension out of data. */
BLI_strncpy(tempname, id->name + 2, sizeof(tempname));
printf("%s\n", tempname);
+
+ /* For images we can add the file extension based on the file magic. */
+ if (id_type == ID_IM) {
+ ImagePackedFile *imapf = ((Image *)id)->packedfiles.last;
+ if (imapf != NULL && imapf->packedfile != NULL) {
+ const PackedFile *pf = imapf->packedfile;
+ enum eImbFileType ftype = IMB_ispic_type_from_memory((const uchar *)pf->data, pf->size);
+ if (ftype != IMB_FTYPE_NONE) {
+ const int imtype = BKE_image_ftype_to_imtype(ftype, NULL);
+ BKE_image_path_ensure_ext_from_imtype(tempname, imtype);
+ }
+ }
+ }
+
BLI_filename_make_safe(tempname);
printf("%s\n", tempname);
}
@@ -535,7 +553,7 @@ static void unpack_generate_paths(const char *name,
BLI_strncpy(tempdir, "//", sizeof(tempdir));
}
- switch (GS(id->name)) {
+ switch (id_type) {
case ID_VF:
BLI_snprintf(r_relpath, relpathlen, "//fonts/%s", tempname);
break;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 42749a93988..d726a4b1e37 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -125,6 +125,16 @@ static void palette_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_list(reader, &palette->colors);
}
+static void palette_undo_preserve(BlendLibReader *UNUSED(reader), ID *id_new, ID *id_old)
+{
+ /* Whole Palette is preserved accross undo's, and it has no extra pointer, simple. */
+ /* Note: We do not care about potential internal references to self here, Palette has none. */
+ /* Note: We do not swap IDProperties, as dealing with potential ID pointers in those would be
+ * fairly delicate. */
+ BKE_lib_id_swap(NULL, id_new, id_old);
+ SWAP(IDProperty *, id_new->properties, id_old->properties);
+}
+
IDTypeInfo IDType_ID_PAL = {
.id_code = ID_PAL,
.id_filter = FILTER_ID_PAL,
@@ -146,6 +156,8 @@ IDTypeInfo IDType_ID_PAL = {
.blend_read_data = palette_blend_read_data,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = palette_undo_preserve,
};
static void paint_curve_copy_data(Main *UNUSED(bmain),
@@ -207,6 +219,8 @@ IDTypeInfo IDType_ID_PC = {
.blend_read_data = paint_curve_blend_read_data,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
const char PAINT_CURSOR_SCULPT[3] = {255, 100, 100};
@@ -1162,6 +1176,56 @@ void BKE_paint_stroke_get_average(Scene *scene, Object *ob, float stroke[3])
}
}
+void BKE_paint_blend_write(BlendWriter *writer, Paint *p)
+{
+ if (p->cavity_curve) {
+ BKE_curvemapping_blend_write(writer, p->cavity_curve);
+ }
+ BLO_write_struct_array(writer, PaintToolSlot, p->tool_slots_len, p->tool_slots);
+}
+
+void BKE_paint_blend_read_data(BlendDataReader *reader, const Scene *scene, Paint *p)
+{
+ if (p->num_input_samples < 1) {
+ p->num_input_samples = 1;
+ }
+
+ BLO_read_data_address(reader, &p->cavity_curve);
+ if (p->cavity_curve) {
+ BKE_curvemapping_blend_read(reader, p->cavity_curve);
+ }
+ else {
+ BKE_paint_cavity_curve_preset(p, CURVE_PRESET_LINE);
+ }
+
+ BLO_read_data_address(reader, &p->tool_slots);
+
+ /* Workaround for invalid data written in older versions. */
+ const size_t expected_size = sizeof(PaintToolSlot) * p->tool_slots_len;
+ if (p->tool_slots && MEM_allocN_len(p->tool_slots) < expected_size) {
+ MEM_freeN(p->tool_slots);
+ p->tool_slots = MEM_callocN(expected_size, "PaintToolSlot");
+ }
+
+ BKE_paint_runtime_init(scene->toolsettings, p);
+}
+
+void BKE_paint_blend_read_lib(BlendLibReader *reader, Scene *sce, Paint *p)
+{
+ if (p) {
+ BLO_read_id_address(reader, sce->id.lib, &p->brush);
+ for (int i = 0; i < p->tool_slots_len; i++) {
+ if (p->tool_slots[i].brush != NULL) {
+ BLO_read_id_address(reader, sce->id.lib, &p->tool_slots[i].brush);
+ }
+ }
+ BLO_read_id_address(reader, sce->id.lib, &p->palette);
+ p->paint_cursor = NULL;
+
+ BKE_paint_runtime_init(sce->toolsettings, p);
+ }
+}
+
/* returns non-zero if any of the face's vertices
* are hidden, zero otherwise */
bool paint_is_face_hidden(const MLoopTri *lt, const MVert *mvert, const MLoop *mloop)
@@ -1734,17 +1798,16 @@ void BKE_sculpt_color_layer_create_if_needed(struct Object *object)
DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY);
}
+/** \warning Expects a fully evaluated depsgraph. */
void BKE_sculpt_update_object_for_edit(
Depsgraph *depsgraph, Object *ob_orig, bool need_pmap, bool need_mask, bool need_colors)
{
- /* Update from sculpt operators and undo, to update sculpt session
- * and PBVH after edits. */
- Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_orig);
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
-
BLI_assert(ob_orig == DEG_get_original_object(ob_orig));
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_orig);
+ Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
+ BLI_assert(me_eval != NULL);
+
sculpt_update_object(depsgraph, ob_orig, me_eval, need_pmap, need_mask, need_colors);
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 7b8ee7343ee..0b331fb88d2 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -21,6 +21,9 @@
* \ingroup bke
*/
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#include <math.h>
#include <stdlib.h>
#include <string.h>
@@ -29,6 +32,7 @@
#include "DNA_defaults.h"
+#include "DNA_cloth_types.h"
#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
#include "DNA_dynamicpaint_types.h"
@@ -52,6 +56,7 @@
#include "BLT_translation.h"
+#include "BKE_anim_data.h"
#include "BKE_anim_path.h"
#include "BKE_boids.h"
#include "BKE_cloth.h"
@@ -78,7 +83,9 @@
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
-#include "RE_render_ext.h"
+#include "RE_texture.h"
+
+#include "BLO_read_write.h"
#include "particle_private.h"
@@ -206,6 +213,279 @@ static void particle_settings_foreach_id(ID *id, LibraryForeachIDData *data)
}
}
+static void write_boid_state(BlendWriter *writer, BoidState *state)
+{
+ BLO_write_struct(writer, BoidState, state);
+
+ LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
+ switch (rule->type) {
+ case eBoidRuleType_Goal:
+ case eBoidRuleType_Avoid:
+ BLO_write_struct(writer, BoidRuleGoalAvoid, rule);
+ break;
+ case eBoidRuleType_AvoidCollision:
+ BLO_write_struct(writer, BoidRuleAvoidCollision, rule);
+ break;
+ case eBoidRuleType_FollowLeader:
+ BLO_write_struct(writer, BoidRuleFollowLeader, rule);
+ break;
+ case eBoidRuleType_AverageSpeed:
+ BLO_write_struct(writer, BoidRuleAverageSpeed, rule);
+ break;
+ case eBoidRuleType_Fight:
+ BLO_write_struct(writer, BoidRuleFight, rule);
+ break;
+ default:
+ BLO_write_struct(writer, BoidRule, rule);
+ break;
+ }
+ }
+#if 0
+ BoidCondition *cond = state->conditions.first;
+ for (; cond; cond = cond->next) {
+ BLO_write_struct(writer, BoidCondition, cond);
+ }
+#endif
+}
+
+static void particle_settings_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ ParticleSettings *part = (ParticleSettings *)id;
+ if (part->id.us > 0 || BLO_write_is_undo(writer)) {
+ /* write LibData */
+ BLO_write_id_struct(writer, ParticleSettings, id_address, &part->id);
+ BKE_id_blend_write(writer, &part->id);
+
+ if (part->adt) {
+ BKE_animdata_blend_write(writer, part->adt);
+ }
+ BLO_write_struct(writer, PartDeflect, part->pd);
+ BLO_write_struct(writer, PartDeflect, part->pd2);
+ BLO_write_struct(writer, EffectorWeights, part->effector_weights);
+
+ if (part->clumpcurve) {
+ BKE_curvemapping_blend_write(writer, part->clumpcurve);
+ }
+ if (part->roughcurve) {
+ BKE_curvemapping_blend_write(writer, part->roughcurve);
+ }
+ if (part->twistcurve) {
+ BKE_curvemapping_blend_write(writer, part->twistcurve);
+ }
+
+ LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
+ /* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */
+ if (dw->ob != NULL) {
+ dw->index = 0;
+ if (part->instance_collection) { /* can be NULL if lining fails or set to None */
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object) {
+ if (object == dw->ob) {
+ break;
+ }
+ dw->index++;
+ }
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
+ }
+ }
+ BLO_write_struct(writer, ParticleDupliWeight, dw);
+ }
+
+ if (part->boids && part->phystype == PART_PHYS_BOIDS) {
+ BLO_write_struct(writer, BoidSettings, part->boids);
+
+ LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
+ write_boid_state(writer, state);
+ }
+ }
+ if (part->fluid && part->phystype == PART_PHYS_FLUID) {
+ BLO_write_struct(writer, SPHFluidSettings, part->fluid);
+ }
+
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (part->mtex[a]) {
+ BLO_write_struct(writer, MTex, part->mtex[a]);
+ }
+ }
+ }
+}
+
+void BKE_particle_partdeflect_blend_read_data(BlendDataReader *UNUSED(reader), PartDeflect *pd)
+{
+ if (pd) {
+ pd->rng = NULL;
+ }
+}
+
+static void particle_settings_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ ParticleSettings *part = (ParticleSettings *)id;
+ BLO_read_data_address(reader, &part->adt);
+ BLO_read_data_address(reader, &part->pd);
+ BLO_read_data_address(reader, &part->pd2);
+
+ BKE_animdata_blend_read_data(reader, part->adt);
+ BKE_particle_partdeflect_blend_read_data(reader, part->pd);
+ BKE_particle_partdeflect_blend_read_data(reader, part->pd2);
+
+ BLO_read_data_address(reader, &part->clumpcurve);
+ if (part->clumpcurve) {
+ BKE_curvemapping_blend_read(reader, part->clumpcurve);
+ }
+ BLO_read_data_address(reader, &part->roughcurve);
+ if (part->roughcurve) {
+ BKE_curvemapping_blend_read(reader, part->roughcurve);
+ }
+ BLO_read_data_address(reader, &part->twistcurve);
+ if (part->twistcurve) {
+ BKE_curvemapping_blend_read(reader, part->twistcurve);
+ }
+
+ BLO_read_data_address(reader, &part->effector_weights);
+ if (!part->effector_weights) {
+ part->effector_weights = BKE_effector_add_weights(part->force_group);
+ }
+
+ BLO_read_list(reader, &part->instance_weights);
+
+ BLO_read_data_address(reader, &part->boids);
+ BLO_read_data_address(reader, &part->fluid);
+
+ if (part->boids) {
+ BLO_read_list(reader, &part->boids->states);
+
+ LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
+ BLO_read_list(reader, &state->rules);
+ BLO_read_list(reader, &state->conditions);
+ BLO_read_list(reader, &state->actions);
+ }
+ }
+ for (int a = 0; a < MAX_MTEX; a++) {
+ BLO_read_data_address(reader, &part->mtex[a]);
+ }
+
+ /* Protect against integer overflow vulnerability. */
+ CLAMP(part->trail_count, 1, 100000);
+}
+
+void BKE_particle_partdeflect_blend_read_lib(BlendLibReader *reader, ID *id, PartDeflect *pd)
+{
+ if (pd && pd->tex) {
+ BLO_read_id_address(reader, id->lib, &pd->tex);
+ }
+ if (pd && pd->f_source) {
+ BLO_read_id_address(reader, id->lib, &pd->f_source);
+ }
+}
+
+static void particle_settings_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+ ParticleSettings *part = (ParticleSettings *)id;
+ 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);
+ BLO_read_id_address(reader, part->id.lib, &part->force_group);
+ BLO_read_id_address(reader, part->id.lib, &part->bb_ob);
+ BLO_read_id_address(reader, part->id.lib, &part->collision_group);
+
+ BKE_particle_partdeflect_blend_read_lib(reader, &part->id, part->pd);
+ BKE_particle_partdeflect_blend_read_lib(reader, &part->id, part->pd2);
+
+ if (part->effector_weights) {
+ BLO_read_id_address(reader, part->id.lib, &part->effector_weights->group);
+ }
+ else {
+ part->effector_weights = BKE_effector_add_weights(part->force_group);
+ }
+
+ if (part->instance_weights.first && part->instance_collection) {
+ LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
+ BLO_read_id_address(reader, part->id.lib, &dw->ob);
+ }
+ }
+ else {
+ BLI_listbase_clear(&part->instance_weights);
+ }
+
+ if (part->boids) {
+ LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
+ LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
+ switch (rule->type) {
+ case eBoidRuleType_Goal:
+ case eBoidRuleType_Avoid: {
+ BoidRuleGoalAvoid *brga = (BoidRuleGoalAvoid *)rule;
+ BLO_read_id_address(reader, part->id.lib, &brga->ob);
+ break;
+ }
+ case eBoidRuleType_FollowLeader: {
+ BoidRuleFollowLeader *brfl = (BoidRuleFollowLeader *)rule;
+ BLO_read_id_address(reader, part->id.lib, &brfl->ob);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ for (int a = 0; a < MAX_MTEX; a++) {
+ MTex *mtex = part->mtex[a];
+ if (mtex) {
+ BLO_read_id_address(reader, part->id.lib, &mtex->tex);
+ BLO_read_id_address(reader, part->id.lib, &mtex->object);
+ }
+ }
+}
+
+static void particle_settings_blend_read_expand(BlendExpander *expander, ID *id)
+{
+ ParticleSettings *part = (ParticleSettings *)id;
+ BLO_expand(expander, part->instance_object);
+ BLO_expand(expander, part->instance_collection);
+ BLO_expand(expander, part->force_group);
+ BLO_expand(expander, part->bb_ob);
+ BLO_expand(expander, part->collision_group);
+
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (part->mtex[a]) {
+ BLO_expand(expander, part->mtex[a]->tex);
+ BLO_expand(expander, part->mtex[a]->object);
+ }
+ }
+
+ if (part->effector_weights) {
+ BLO_expand(expander, part->effector_weights->group);
+ }
+
+ if (part->pd) {
+ BLO_expand(expander, part->pd->tex);
+ BLO_expand(expander, part->pd->f_source);
+ }
+ if (part->pd2) {
+ BLO_expand(expander, part->pd2->tex);
+ BLO_expand(expander, part->pd2->f_source);
+ }
+
+ if (part->boids) {
+ LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
+ LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
+ if (rule->type == eBoidRuleType_Avoid) {
+ BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule;
+ BLO_expand(expander, gabr->ob);
+ }
+ else if (rule->type == eBoidRuleType_FollowLeader) {
+ BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule;
+ BLO_expand(expander, flbr->ob);
+ }
+ }
+ }
+ }
+
+ LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
+ BLO_expand(expander, dw->ob);
+ }
+}
+
IDTypeInfo IDType_ID_PA = {
.id_code = ID_PA,
.id_filter = FILTER_ID_PA,
@@ -223,17 +503,19 @@ IDTypeInfo IDType_ID_PA = {
.foreach_id = particle_settings_foreach_id,
.foreach_cache = NULL,
- .blend_write = NULL,
- .blend_read_data = NULL,
- .blend_read_lib = NULL,
- .blend_read_expand = NULL,
+ .blend_write = particle_settings_blend_write,
+ .blend_read_data = particle_settings_blend_read_data,
+ .blend_read_lib = particle_settings_blend_read_lib,
+ .blend_read_expand = particle_settings_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
unsigned int PSYS_FRAND_SEED_OFFSET[PSYS_FRAND_COUNT];
unsigned int PSYS_FRAND_SEED_MULTIPLIER[PSYS_FRAND_COUNT];
float PSYS_FRAND_BASE[PSYS_FRAND_COUNT];
-void psys_init_rng(void)
+void BKE_particle_init_rng(void)
{
RNG *rng = BLI_rng_new_srandom(5831); /* arbitrary */
for (int i = 0; i < PSYS_FRAND_COUNT; i++) {
@@ -917,7 +1199,7 @@ static float interpolate_particle_value(
value += w[3] * v4;
}
- CLAMP(value, 0.f, 1.f);
+ CLAMP(value, 0.0f, 1.0f);
return value;
}
@@ -1146,7 +1428,7 @@ static void do_particle_interpolation(ParticleSystem *psys,
PTCacheEditPoint *point = pind->epoint;
ParticleKey keys[4];
int point_vel = (point && point->keys->vel);
- float real_t, dfra, keytime, invdt = 1.f;
+ float real_t, dfra, keytime, invdt = 1.0f;
/* billboards wont fill in all of these, so start cleared */
memset(keys, 0, sizeof(keys));
@@ -1316,7 +1598,7 @@ static void do_particle_interpolation(ParticleSystem *psys,
/* Convert velocity to time-step size. */
if (pind->keyed || pind->cache || point_vel) {
- invdt = dfra * 0.04f * (psys ? psys->part->timetweak : 1.f);
+ invdt = dfra * 0.04f * (psys ? psys->part->timetweak : 1.0f);
mul_v3_fl(keys[1].vel, invdt);
mul_v3_fl(keys[2].vel, invdt);
interp_qt_qtqt(result->rot, keys[1].rot, keys[2].rot, keytime);
@@ -1335,7 +1617,7 @@ static void do_particle_interpolation(ParticleSystem *psys,
/* the velocity needs to be converted back from cubic interpolation */
if (pind->keyed || pind->cache || point_vel) {
- mul_v3_fl(result->vel, 1.f / invdt);
+ mul_v3_fl(result->vel, 1.0f / invdt);
}
}
@@ -2200,7 +2482,7 @@ int do_guides(Depsgraph *depsgraph,
pd->kink_freq,
pd->kink_shape,
pd->kink_amp,
- 0.f,
+ 0.0f,
pd->kink,
pd->kink_axis,
0,
@@ -2550,12 +2832,12 @@ static void psys_thread_create_path(ParticleTask *task,
if (ctx->between) {
ParticleData *pa = psys->particles + cpa->pa[0];
int w, needupdate;
- float foffset, wsum = 0.f;
+ float foffset, wsum = 0.0f;
float co[3];
float p_min = part->parting_min;
float p_max = part->parting_max;
/* Virtual parents don't work nicely with parting. */
- float p_fac = part->parents > 0.f ? 0.f : part->parting_fac;
+ float p_fac = part->parents > 0.0f ? 0.0f : part->parting_fac;
if (ctx->editupdate) {
needupdate = 0;
@@ -2583,15 +2865,15 @@ static void psys_thread_create_path(ParticleTask *task,
}
else {
key[w] = pcache[0];
- weight[w] = 0.f;
+ weight[w] = 0.0f;
}
}
/* modify weights to create parting */
- if (p_fac > 0.f) {
+ if (p_fac > 0.0f) {
const ParticleCacheKey *key_0_last = pcache_key_segment_endpoint_safe(key[0]);
for (w = 0; w < 4; w++) {
- if (w && (weight[w] > 0.f)) {
+ if (w && (weight[w] > 0.0f)) {
const ParticleCacheKey *key_w_last = pcache_key_segment_endpoint_safe(key[w]);
float d;
if (part->flag & PART_CHILD_LONG_HAIR) {
@@ -2600,7 +2882,7 @@ static void psys_thread_create_path(ParticleTask *task,
float d1 = len_v3v3(key[0]->co, key[w]->co);
float d2 = len_v3v3(key_0_last->co, key_w_last->co);
- d = d1 > 0.f ? d2 / d1 - 1.f : 10000.f;
+ d = d1 > 0.0f ? d2 / d1 - 1.0f : 10000.0f;
}
else {
float v1[3], v2[3];
@@ -2616,13 +2898,13 @@ static void psys_thread_create_path(ParticleTask *task,
d = (d - p_min) / (p_max - p_min);
}
else {
- d = (d - p_min) <= 0.f ? 0.f : 1.f;
+ d = (d - p_min) <= 0.0f ? 0.0f : 1.0f;
}
- CLAMP(d, 0.f, 1.f);
+ CLAMP(d, 0.0f, 1.0f);
- if (d > 0.f) {
- weight[w] *= (1.f - d);
+ if (d > 0.0f) {
+ weight[w] *= (1.0f - d);
}
}
wsum += weight[w];
@@ -3059,7 +3341,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
LOOP_PARTICLES
{
if (!psys->totchild) {
- psys_get_texture(sim, pa, &ptex, PAMAP_LENGTH, 0.f);
+ psys_get_texture(sim, pa, &ptex, PAMAP_LENGTH, 0.0f);
pa_length = ptex.length * (1.0f - part->randlength * psys_frand(psys, psys->seed + p));
if (vg_length) {
pa_length *= psys_particle_value_from_verts(psmd->mesh_final, part->from, pa, vg_length);
@@ -3716,19 +3998,25 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob
if (psys->part->type == PART_FLUID_FLIP) {
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FLIP;
}
- if (psys->part->type == PART_FLUID_SPRAY || psys->part->type == PART_FLUID_SPRAYFOAM ||
- psys->part->type == PART_FLUID_SPRAYBUBBLE ||
- psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+ if (ELEM(psys->part->type,
+ PART_FLUID_SPRAY,
+ PART_FLUID_SPRAYFOAM,
+ PART_FLUID_SPRAYBUBBLE,
+ PART_FLUID_SPRAYFOAMBUBBLE)) {
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_SPRAY;
}
- if (psys->part->type == PART_FLUID_FOAM || psys->part->type == PART_FLUID_SPRAYFOAM ||
- psys->part->type == PART_FLUID_FOAMBUBBLE ||
- psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+ if (ELEM(psys->part->type,
+ PART_FLUID_FOAM,
+ PART_FLUID_SPRAYFOAM,
+ PART_FLUID_FOAMBUBBLE,
+ PART_FLUID_SPRAYFOAMBUBBLE)) {
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FOAM;
}
- if (psys->part->type == PART_FLUID_BUBBLE || psys->part->type == PART_FLUID_FOAMBUBBLE ||
- psys->part->type == PART_FLUID_SPRAYBUBBLE ||
- psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+ if (ELEM(psys->part->type,
+ PART_FLUID_BUBBLE,
+ PART_FLUID_FOAMBUBBLE,
+ PART_FLUID_SPRAYBUBBLE,
+ PART_FLUID_SPRAYFOAMBUBBLE)) {
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_BUBBLE;
}
if (psys->part->type == PART_FLUID_TRACER) {
@@ -3736,9 +4024,11 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob
}
/* Disable combined export if combined particle system was deleted. */
- if (psys->part->type == PART_FLUID_SPRAYFOAM || psys->part->type == PART_FLUID_SPRAYBUBBLE ||
- psys->part->type == PART_FLUID_FOAMBUBBLE ||
- psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+ if (ELEM(psys->part->type,
+ PART_FLUID_SPRAYFOAM,
+ PART_FLUID_SPRAYBUBBLE,
+ PART_FLUID_FOAMBUBBLE,
+ PART_FLUID_SPRAYFOAMBUBBLE)) {
fmd->domain->sndparticle_combined_export = SNDPARTICLE_COMBINED_EXPORT_OFF;
}
}
@@ -3992,9 +4282,9 @@ static void get_cpa_texture(Mesh *mesh,
break;
case TEXCO_PARTICLE:
/* texture coordinates in range [-1, 1] */
- texvec[0] = 2.f * (cfra - par->time) / (par->dietime - par->time) - 1.f;
- texvec[1] = 0.f;
- texvec[2] = 0.f;
+ texvec[0] = 2.0f * (cfra - par->time) / (par->dietime - par->time) - 1.0f;
+ texvec[1] = 0.0f;
+ texvec[2] = 0.0f;
break;
}
@@ -4102,14 +4392,15 @@ void psys_get_texture(
break;
case TEXCO_PARTICLE:
/* texture coordinates in range [-1, 1] */
- texvec[0] = 2.f * (cfra - pa->time) / (pa->dietime - pa->time) - 1.f;
+ texvec[0] = 2.0f * (cfra - pa->time) / (pa->dietime - pa->time) - 1.0f;
if (sim->psys->totpart > 0) {
- texvec[1] = 2.f * (float)(pa - sim->psys->particles) / (float)sim->psys->totpart - 1.f;
+ texvec[1] = 2.0f * (float)(pa - sim->psys->particles) / (float)sim->psys->totpart -
+ 1.0f;
}
else {
texvec[1] = 0.0f;
}
- texvec[2] = 0.f;
+ texvec[2] = 0.0f;
break;
}
@@ -4654,8 +4945,8 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
else {
float dfra, frs_sec = sim->scene->r.frs_sec;
/* let's interpolate to try to be as accurate as possible */
- if (pa->state.time + 2.f >= state->time && pa->prev_state.time - 2.f <= state->time) {
- if (pa->prev_state.time >= pa->state.time || pa->prev_state.time < 0.f) {
+ if (pa->state.time + 2.0f >= state->time && pa->prev_state.time - 2.0f <= state->time) {
+ if (pa->prev_state.time >= pa->state.time || pa->prev_state.time < 0.0f) {
/* prev_state is wrong so let's not use it,
* this can happen at frames 1, 0 or particle birth. */
dfra = state->time - pa->state.time;
@@ -4682,13 +4973,13 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
psys_interpolate_particle(-1, keys, keytime, state, 1);
/* convert back to real velocity */
- mul_v3_fl(state->vel, 1.f / (dfra * timestep));
+ mul_v3_fl(state->vel, 1.0f / (dfra * timestep));
interp_v3_v3v3(state->ave, keys[1].ave, keys[2].ave, keytime);
interp_qt_qtqt(state->rot, keys[1].rot, keys[2].rot, keytime);
}
}
- else if (pa->state.time + 1.f >= state->time && pa->state.time - 1.f <= state->time) {
+ else if (pa->state.time + 1.0f >= state->time && pa->state.time - 1.0f <= state->time) {
/* linear interpolation using only pa->state */
dfra = state->time - pa->state.time;
@@ -4949,3 +5240,172 @@ void BKE_particle_batch_cache_free(ParticleSystem *psys)
BKE_particle_batch_cache_free_cb(psys);
}
}
+
+void BKE_particle_system_blend_write(BlendWriter *writer, ListBase *particles)
+{
+ LISTBASE_FOREACH (ParticleSystem *, psys, particles) {
+ BLO_write_struct(writer, ParticleSystem, psys);
+
+ if (psys->particles) {
+ BLO_write_struct_array(writer, ParticleData, psys->totpart, psys->particles);
+
+ if (psys->particles->hair) {
+ ParticleData *pa = psys->particles;
+
+ for (int a = 0; a < psys->totpart; a++, pa++) {
+ BLO_write_struct_array(writer, HairKey, pa->totkey, pa->hair);
+ }
+ }
+
+ if (psys->particles->boid && (psys->part->phystype == PART_PHYS_BOIDS)) {
+ BLO_write_struct_array(writer, BoidParticle, psys->totpart, psys->particles->boid);
+ }
+
+ if (psys->part->fluid && (psys->part->phystype == PART_PHYS_FLUID) &&
+ (psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS)) {
+ BLO_write_struct_array(
+ writer, ParticleSpring, psys->tot_fluidsprings, psys->fluid_springs);
+ }
+ }
+ LISTBASE_FOREACH (ParticleTarget *, pt, &psys->targets) {
+ BLO_write_struct(writer, ParticleTarget, pt);
+ }
+
+ if (psys->child) {
+ BLO_write_struct_array(writer, ChildParticle, psys->totchild, psys->child);
+ }
+
+ if (psys->clmd) {
+ BLO_write_struct(writer, ClothModifierData, psys->clmd);
+ BLO_write_struct(writer, ClothSimSettings, psys->clmd->sim_parms);
+ BLO_write_struct(writer, ClothCollSettings, psys->clmd->coll_parms);
+ }
+
+ BKE_ptcache_blend_write(writer, &psys->ptcaches);
+ }
+}
+
+void BKE_particle_system_blend_read_data(BlendDataReader *reader, ListBase *particles)
+{
+ ParticleData *pa;
+ int a;
+
+ LISTBASE_FOREACH (ParticleSystem *, psys, particles) {
+ BLO_read_data_address(reader, &psys->particles);
+
+ if (psys->particles && psys->particles->hair) {
+ for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
+ BLO_read_data_address(reader, &pa->hair);
+ }
+ }
+
+ if (psys->particles && psys->particles->keys) {
+ for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
+ pa->keys = NULL;
+ pa->totkey = 0;
+ }
+
+ psys->flag &= ~PSYS_KEYED;
+ }
+
+ if (psys->particles && psys->particles->boid) {
+ pa = psys->particles;
+ BLO_read_data_address(reader, &pa->boid);
+
+ /* This is purely runtime data, but still can be an issue if left dangling. */
+ pa->boid->ground = NULL;
+
+ for (a = 1, pa++; a < psys->totpart; a++, pa++) {
+ pa->boid = (pa - 1)->boid + 1;
+ pa->boid->ground = NULL;
+ }
+ }
+ else if (psys->particles) {
+ for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
+ pa->boid = NULL;
+ }
+ }
+
+ BLO_read_data_address(reader, &psys->fluid_springs);
+
+ BLO_read_data_address(reader, &psys->child);
+ psys->effectors = NULL;
+
+ BLO_read_list(reader, &psys->targets);
+
+ psys->edit = NULL;
+ psys->free_edit = NULL;
+ psys->pathcache = NULL;
+ psys->childcache = NULL;
+ BLI_listbase_clear(&psys->pathcachebufs);
+ BLI_listbase_clear(&psys->childcachebufs);
+ psys->pdd = NULL;
+
+ if (psys->clmd) {
+ BLO_read_data_address(reader, &psys->clmd);
+ psys->clmd->clothObject = NULL;
+ psys->clmd->hairdata = NULL;
+
+ BLO_read_data_address(reader, &psys->clmd->sim_parms);
+ BLO_read_data_address(reader, &psys->clmd->coll_parms);
+
+ if (psys->clmd->sim_parms) {
+ psys->clmd->sim_parms->effector_weights = NULL;
+ if (psys->clmd->sim_parms->presets > 10) {
+ psys->clmd->sim_parms->presets = 0;
+ }
+ }
+
+ psys->hair_in_mesh = psys->hair_out_mesh = NULL;
+ psys->clmd->solver_result = NULL;
+ }
+
+ BKE_ptcache_blend_read_data(reader, &psys->ptcaches, &psys->pointcache, 0);
+ if (psys->clmd) {
+ psys->clmd->point_cache = psys->pointcache;
+ }
+
+ psys->tree = NULL;
+ psys->bvhtree = NULL;
+
+ psys->orig_psys = NULL;
+ psys->batch_cache = NULL;
+ }
+}
+
+void BKE_particle_system_blend_read_lib(BlendLibReader *reader,
+ Object *ob,
+ ID *id,
+ ListBase *particles)
+{
+ LISTBASE_FOREACH_MUTABLE (ParticleSystem *, psys, particles) {
+
+ BLO_read_id_address(reader, id->lib, &psys->part);
+ if (psys->part) {
+ LISTBASE_FOREACH (ParticleTarget *, pt, &psys->targets) {
+ BLO_read_id_address(reader, id->lib, &pt->ob);
+ }
+
+ BLO_read_id_address(reader, id->lib, &psys->parent);
+ BLO_read_id_address(reader, id->lib, &psys->target_ob);
+
+ if (psys->clmd) {
+ /* XXX - from reading existing code this seems correct but intended usage of
+ * pointcache /w cloth should be added in 'ParticleSystem' - campbell */
+ psys->clmd->point_cache = psys->pointcache;
+ psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL;
+ BLO_read_id_address(reader, id->lib, &psys->clmd->coll_parms->group);
+ psys->clmd->modifier.error = NULL;
+ }
+ }
+ else {
+ /* particle modifier must be removed before particle system */
+ ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
+ BLI_remlink(&ob->modifiers, psmd);
+ BKE_modifier_free((ModifierData *)psmd);
+
+ BLI_remlink(particles, psys);
+ MEM_freeN(psys);
+ }
+ }
+}
diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c
index da5fdc85561..98a55c3de95 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -88,7 +88,7 @@ static void do_kink_spiral_deform(ParticleKey *state,
{
float result[3];
- CLAMP(time, 0.f, 1.f);
+ CLAMP(time, 0.0f, 1.0f);
copy_v3_v3(result, state->co);
@@ -426,21 +426,21 @@ void do_kink(ParticleKey *state,
float obmat[4][4],
int smooth_start)
{
- float kink[3] = {1.f, 0.f, 0.f}, par_vec[3], q1[4] = {1.f, 0.f, 0.f, 0.f};
- float t, dt = 1.f, result[3];
+ float kink[3] = {1.0f, 0.0f, 0.0f}, par_vec[3], q1[4] = {1.0f, 0.0f, 0.0f, 0.0f};
+ float t, dt = 1.0f, result[3];
if (ELEM(type, PART_KINK_NO, PART_KINK_SPIRAL)) {
return;
}
- CLAMP(time, 0.f, 1.f);
+ CLAMP(time, 0.0f, 1.0f);
if (shape != 0.0f && !ELEM(type, PART_KINK_BRAID)) {
if (shape < 0.0f) {
- time = (float)pow(time, 1.f + shape);
+ time = (float)pow(time, 1.0f + shape);
}
else {
- time = (float)pow(time, 1.f / (1.f - shape));
+ time = (float)pow(time, 1.0f / (1.0f - shape));
}
}
@@ -449,14 +449,14 @@ void do_kink(ParticleKey *state,
if (smooth_start) {
dt = fabsf(t);
/* smooth the beginning of kink */
- CLAMP(dt, 0.f, (float)M_PI);
- dt = sinf(dt / 2.f);
+ CLAMP(dt, 0.0f, (float)M_PI);
+ dt = sinf(dt / 2.0f);
}
if (!ELEM(type, PART_KINK_RADIAL)) {
float temp[3];
- kink[axis] = 1.f;
+ kink[axis] = 1.0f;
if (obmat) {
mul_mat3_m4_v3(obmat, kink);
@@ -487,7 +487,7 @@ void do_kink(ParticleKey *state,
break;
}
case PART_KINK_RADIAL: {
- if (flat > 0.f) {
+ if (flat > 0.0f) {
float proj[3];
/* flatten along strand */
project_v3_v3v3(proj, par_vec, par_vel);
@@ -500,7 +500,7 @@ void do_kink(ParticleKey *state,
case PART_KINK_WAVE: {
madd_v3_v3fl(result, kink, amplitude * sinf(t));
- if (flat > 0.f) {
+ if (flat > 0.0f) {
float proj[3];
/* flatten along wave */
project_v3_v3v3(proj, par_vec, kink);
@@ -513,8 +513,8 @@ void do_kink(ParticleKey *state,
break;
}
case PART_KINK_BRAID: {
- float y_vec[3] = {0.f, 1.f, 0.f};
- float z_vec[3] = {0.f, 0.f, 1.f};
+ float y_vec[3] = {0.0f, 1.0f, 0.0f};
+ float z_vec[3] = {0.0f, 0.0f, 1.0f};
float vec_one[3], state_co[3];
float inp_y, inp_z, length;
@@ -533,21 +533,21 @@ void do_kink(ParticleKey *state,
copy_v3_v3(state_co, y_vec);
mul_v3_fl(y_vec, amplitude * cosf(t));
- mul_v3_fl(z_vec, amplitude / 2.f * sinf(2.f * t));
+ mul_v3_fl(z_vec, amplitude / 2.0f * sinf(2.0f * t));
}
else if (inp_z > 0.0f) {
- mul_v3_v3fl(state_co, z_vec, sinf((float)M_PI / 3.f));
+ mul_v3_v3fl(state_co, z_vec, sinf((float)M_PI / 3.0f));
madd_v3_v3fl(state_co, y_vec, -0.5f);
- mul_v3_fl(y_vec, -amplitude * cosf(t + (float)M_PI / 3.f));
- mul_v3_fl(z_vec, amplitude / 2.f * cosf(2.f * t + (float)M_PI / 6.f));
+ mul_v3_fl(y_vec, -amplitude * cosf(t + (float)M_PI / 3.0f));
+ mul_v3_fl(z_vec, amplitude / 2.0f * cosf(2.0f * t + (float)M_PI / 6.0f));
}
else {
- mul_v3_v3fl(state_co, z_vec, -sinf((float)M_PI / 3.f));
+ mul_v3_v3fl(state_co, z_vec, -sinf((float)M_PI / 3.0f));
madd_v3_v3fl(state_co, y_vec, -0.5f);
- mul_v3_fl(y_vec, amplitude * -sinf(t + (float)M_PI / 6.f));
- mul_v3_fl(z_vec, amplitude / 2.f * -sinf(2.f * t + (float)M_PI / 3.f));
+ mul_v3_fl(y_vec, amplitude * -sinf(t + (float)M_PI / 6.0f));
+ mul_v3_fl(z_vec, amplitude / 2.0f * -sinf(2.0f * t + (float)M_PI / 3.0f));
}
mul_v3_fl(state_co, amplitude);
@@ -555,13 +555,13 @@ void do_kink(ParticleKey *state,
sub_v3_v3v3(par_vec, state->co, state_co);
length = normalize_v3(par_vec);
- mul_v3_fl(par_vec, MIN2(length, amplitude / 2.f));
+ mul_v3_fl(par_vec, MIN2(length, amplitude / 2.0f));
add_v3_v3v3(state_co, par_co, y_vec);
add_v3_v3(state_co, z_vec);
add_v3_v3(state_co, par_vec);
- shape = 2.f * (float)M_PI * (1.f + shape);
+ shape = 2.0f * (float)M_PI * (1.0f + shape);
if (t < shape) {
shape = t / shape;
@@ -576,7 +576,7 @@ void do_kink(ParticleKey *state,
}
/* blend the start of the kink */
- if (dt < 1.f) {
+ if (dt < 1.0f) {
interp_v3_v3v3(state->co, state->co, result, dt);
}
else {
@@ -642,7 +642,7 @@ float do_clump(ParticleKey *state,
float da[4], pa[12];
mul_v3_v3fl(noisevec, orco_offset, 1.0f / clump_noise_size);
- voronoi(noisevec[0], noisevec[1], noisevec[2], da, pa, 1.0f, 0);
+ BLI_noise_voronoi(noisevec[0], noisevec[1], noisevec[2], da, pa, 1.0f, 0);
mul_v3_fl(&pa[0], clump_noise_size);
add_v3_v3v3(center, par_co, &pa[0]);
@@ -674,9 +674,9 @@ static void do_rough(const float loc[3],
copy_v3_v3(rco, loc);
mul_v3_fl(rco, t);
- rough[0] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2, 0, 2);
- rough[1] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2, 0, 2);
- rough[2] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2, 0, 2);
+ rough[0] = -1.0f + 2.0f * BLI_noise_generic_turbulence(size, rco[0], rco[1], rco[2], 2, 0, 2);
+ rough[1] = -1.0f + 2.0f * BLI_noise_generic_turbulence(size, rco[1], rco[2], rco[0], 2, 0, 2);
+ rough[2] = -1.0f + 2.0f * BLI_noise_generic_turbulence(size, rco[2], rco[0], rco[1], 2, 0, 2);
madd_v3_v3fl(state->co, mat[0], fac * rough[0]);
madd_v3_v3fl(state->co, mat[1], fac * rough[1]);
@@ -718,9 +718,9 @@ static void do_rough_curve(const float loc[3],
copy_v3_v3(rco, loc);
mul_v3_fl(rco, time);
- rough[0] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2, 0, 2);
- rough[1] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2, 0, 2);
- rough[2] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2, 0, 2);
+ rough[0] = -1.0f + 2.0f * BLI_noise_generic_turbulence(size, rco[0], rco[1], rco[2], 2, 0, 2);
+ rough[1] = -1.0f + 2.0f * BLI_noise_generic_turbulence(size, rco[1], rco[2], rco[0], 2, 0, 2);
+ rough[2] = -1.0f + 2.0f * BLI_noise_generic_turbulence(size, rco[2], rco[0], rco[1], 2, 0, 2);
madd_v3_v3fl(state->co, mat[0], fac * rough[0]);
madd_v3_v3fl(state->co, mat[1], fac * rough[1]);
@@ -881,8 +881,8 @@ void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx,
part->clump_noise_size,
clumpcurve);
- if (kink_freq != 0.f) {
- kink_amp *= (1.f - kink_amp_clump * clump);
+ if (kink_freq != 0.0f) {
+ kink_amp *= (1.0f - kink_amp_clump * clump);
do_kink(state,
modifier_ctx->par_co,
@@ -904,17 +904,17 @@ void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx,
do_rough_curve(modifier_ctx->orco, mat, t, rough1, part->rough1_size, roughcurve, state);
}
else {
- if (rough1 > 0.f) {
+ if (rough1 > 0.0f) {
do_rough(modifier_ctx->orco, mat, t, rough1, part->rough1_size, 0.0, state);
}
- if (rough2 > 0.f) {
+ if (rough2 > 0.0f) {
float vec[3];
psys_frand_vec(sim->psys, i + 27, vec);
do_rough(vec, mat, t, rough2, part->rough2_size, part->rough2_thres, state);
}
- if (rough_end > 0.f) {
+ if (rough_end > 0.0f) {
float vec[3];
psys_frand_vec(sim->psys, i + 27, vec);
do_rough_end(vec, mat, t, rough_end, part->rough_end_shape, state);
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index d5999196b60..194593be4ff 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -150,9 +150,9 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
size[2] = MAX2(size[2], 1);
/* no full offset for flat/thin objects */
- min[0] += d < delta[0] ? d / 2.f : delta[0] / 2.f;
- min[1] += d < delta[1] ? d / 2.f : delta[1] / 2.f;
- min[2] += d < delta[2] ? d / 2.f : delta[2] / 2.f;
+ min[0] += d < delta[0] ? d / 2.0f : delta[0] / 2.0f;
+ min[1] += d < delta[1] ? d / 2.0f : delta[1] / 2.0f;
+ min[2] += d < delta[2] ? d / 2.0f : delta[2] / 2.0f;
for (i = 0, p = 0, pa = psys->particles; i < res; i++) {
for (j = 0; j < res; j++) {
@@ -220,7 +220,7 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
pa = psys->particles + a1 * a1mul + a2 * a2mul;
copy_v3_v3(co1, pa->fuv);
- co1[a] -= d < delta[a] ? d / 2.f : delta[a] / 2.f;
+ co1[a] -= d < delta[a] ? d / 2.0f : delta[a] / 2.0f;
copy_v3_v3(co2, co1);
co2[a] += delta[a] + 0.001f * d;
co1[a] -= 0.001f * d;
@@ -295,12 +295,12 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
for (j = 0; j < res; j++) {
for (k = 0; k < res; k++, p++, pa++) {
if (j % 2) {
- pa->fuv[0] += d / 2.f;
+ pa->fuv[0] += d / 2.0f;
}
if (k % 2) {
- pa->fuv[0] += d / 2.f;
- pa->fuv[1] += d / 2.f;
+ pa->fuv[0] += d / 2.0f;
+ pa->fuv[1] += d / 2.0f;
}
}
}
@@ -318,7 +318,7 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
}
}
- if (psys->part->grid_rand > 0.f) {
+ if (psys->part->grid_rand > 0.0f) {
float rfac = d * psys->part->grid_rand;
for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++) {
if (pa->flag & PARS_UNEXIST) {
@@ -1052,7 +1052,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
/* Calculate weights from face areas */
if ((part->flag & PART_EDISTR || children) && from != PART_FROM_VERT) {
MVert *v1, *v2, *v3, *v4;
- float totarea = 0.f, co1[3], co2[3], co3[3], co4[3];
+ float totarea = 0.0f, co1[3], co2[3], co3[3], co4[3];
float(*orcodata)[3];
orcodata = CustomData_get_layer(&mesh->vdata, CD_ORCO);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 060a9b4d794..4117dfc0b23 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -83,7 +83,7 @@
#include "PIL_time.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
/* FLUID sim particle import */
#ifdef WITH_FLUID
@@ -574,7 +574,7 @@ static void init_particle_texture(ParticleSimulationData *sim, ParticleData *pa,
ParticleSettings *part = psys->part;
ParticleTexture ptex;
- psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f);
+ psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.0f);
switch (part->type) {
case PART_EMITTER:
@@ -587,7 +587,7 @@ static void init_particle_texture(ParticleSimulationData *sim, ParticleData *pa,
if (ptex.exist < psys_frand(psys, p + 125)) {
pa->flag |= PARS_UNEXIST;
}
- pa->time = 0.f;
+ pa->time = 0.0f;
break;
}
}
@@ -697,28 +697,28 @@ static void get_angular_velocity_vector(short avemode, ParticleKey *state, float
case PART_AVE_HORIZONTAL: {
float zvec[3];
zvec[0] = zvec[1] = 0;
- zvec[2] = 1.f;
+ zvec[2] = 1.0f;
cross_v3_v3v3(vec, state->vel, zvec);
break;
}
case PART_AVE_VERTICAL: {
float zvec[3], temp[3];
zvec[0] = zvec[1] = 0;
- zvec[2] = 1.f;
+ zvec[2] = 1.0f;
cross_v3_v3v3(temp, state->vel, zvec);
cross_v3_v3v3(vec, temp, state->vel);
break;
}
case PART_AVE_GLOBAL_X:
- vec[0] = 1.f;
+ vec[0] = 1.0f;
vec[1] = vec[2] = 0;
break;
case PART_AVE_GLOBAL_Y:
- vec[1] = 1.f;
+ vec[1] = 1.0f;
vec[0] = vec[2] = 0;
break;
case PART_AVE_GLOBAL_Z:
- vec[2] = 1.f;
+ vec[2] = 1.0f;
vec[0] = vec[1] = 0;
break;
}
@@ -864,36 +864,36 @@ void psys_get_birth_coords(
/* -velocity from: */
/* *reactions */
- if (dtime > 0.f) {
+ if (dtime > 0.0f) {
sub_v3_v3v3(vel, pa->state.vel, pa->prev_state.vel);
}
/* *emitter velocity */
- if (dtime != 0.f && part->obfac != 0.f) {
+ if (dtime != 0.0f && part->obfac != 0.0f) {
sub_v3_v3v3(vel, loc, state->co);
mul_v3_fl(vel, part->obfac / dtime);
}
/* *emitter normal */
- if (part->normfac != 0.f) {
+ if (part->normfac != 0.0f) {
madd_v3_v3fl(vel, nor, part->normfac);
}
/* *emitter tangent */
- if (sim->psmd && part->tanfac != 0.f) {
+ if (sim->psmd && part->tanfac != 0.0f) {
madd_v3_v3fl(vel, vtan, part->tanfac);
}
/* *emitter object orientation */
- if (part->ob_vel[0] != 0.f) {
+ if (part->ob_vel[0] != 0.0f) {
normalize_v3_v3(vec, ob->obmat[0]);
madd_v3_v3fl(vel, vec, part->ob_vel[0]);
}
- if (part->ob_vel[1] != 0.f) {
+ if (part->ob_vel[1] != 0.0f) {
normalize_v3_v3(vec, ob->obmat[1]);
madd_v3_v3fl(vel, vec, part->ob_vel[1]);
}
- if (part->ob_vel[2] != 0.f) {
+ if (part->ob_vel[2] != 0.0f) {
normalize_v3_v3(vec, ob->obmat[2]);
madd_v3_v3fl(vel, vec, part->ob_vel[2]);
}
@@ -902,12 +902,12 @@ void psys_get_birth_coords(
/* TODO */
/* *random */
- if (part->randfac != 0.f) {
+ if (part->randfac != 0.0f) {
madd_v3_v3fl(vel, r_vel, part->randfac);
}
/* *particle */
- if (part->partfac != 0.f) {
+ if (part->partfac != 0.0f) {
madd_v3_v3fl(vel, p_vel, part->partfac);
}
@@ -1077,7 +1077,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
part = psys->part;
/* get precise emitter matrix if particle is born */
- if (part->type != PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
+ if (part->type != PART_HAIR && dtime > 0.0f && pa->time < cfra && pa->time >= sim->psys->cfra) {
evaluate_emitter_anim(sim->depsgraph, sim->scene, sim->ob, pa->time);
psys->flag |= PSYS_OB_ANIM_RESTORE;
@@ -1165,7 +1165,7 @@ ParticleSystem *psys_get_target_system(Object *ob, ParticleTarget *pt)
{
ParticleSystem *psys = NULL;
- if (pt->ob == NULL || pt->ob == ob) {
+ if (ELEM(pt->ob, NULL, ob)) {
psys = BLI_findlink(&ob->particlesystem, pt->psys - 1);
}
else {
@@ -1427,7 +1427,7 @@ static void integrate_particle(
copy_v3_v3(oldpos, pa->state.co);
/* Verlet integration behaves strangely with moving emitters, so do first step with euler. */
- if (pa->prev_state.time < 0.f && integrator == PART_INT_VERLET) {
+ if (pa->prev_state.time < 0.0f && integrator == PART_INT_VERLET) {
integrator = PART_INT_EULER;
}
@@ -1450,7 +1450,7 @@ static void integrate_particle(
copy_particle_key(states + i, &pa->state, 1);
}
- states->time = 0.f;
+ states->time = 0.0f;
for (i = 0; i < steps; i++) {
zero_v3(force);
@@ -1611,9 +1611,9 @@ static void sph_springs_modify(ParticleSystem *psys, float dtime)
float yield_ratio = fluid->yield_ratio;
float plasticity = fluid->plasticity_constant;
/* scale things according to dtime */
- float timefix = 25.f * dtime;
+ float timefix = 25.0f * dtime;
- if ((fluid->flag & SPH_VISCOELASTIC_SPRINGS) == 0 || fluid->spring_k == 0.f) {
+ if ((fluid->flag & SPH_VISCOELASTIC_SPRINGS) == 0 || fluid->spring_k == 0.0f) {
return;
}
@@ -1636,7 +1636,7 @@ static void sph_springs_modify(ParticleSystem *psys, float dtime)
spring->rest_length -= plasticity * (Lij - d - rij) * timefix;
}
- h = 4.f * pa1->size;
+ h = 4.0f * pa1->size;
if (spring->rest_length > h) {
spring->delete_flag = 1;
@@ -1743,7 +1743,7 @@ static void sph_density_accum_cb(void *userdata, int index, const float co[3], f
pfr->tot_neighbors++;
dist = sqrtf(squared_dist);
- q = (1.f - dist / pfr->h) * pfr->massfac;
+ q = (1.0f - dist / pfr->h) * pfr->massfac;
if (pfr->use_size) {
q *= npa->size;
@@ -1799,7 +1799,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
float visc = fluid->viscosity_omega;
float stiff_visc = fluid->viscosity_beta *
- (fluid->flag & SPH_FAC_VISCOSITY ? fluid->viscosity_omega : 1.f);
+ (fluid->flag & SPH_FAC_VISCOSITY ? fluid->viscosity_omega : 1.0f);
float inv_mass = 1.0f / sphdata->mass;
float spring_constant = fluid->spring_k;
@@ -1809,13 +1809,13 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
(fluid->flag & SPH_FAC_RADIUS ? 4.0f * pa->size : 1.0f);
float h = interaction_radius * sphdata->hfac;
/* 4.77 is an experimentally determined density factor */
- float rest_density = fluid->rest_density * (fluid->flag & SPH_FAC_DENSITY ? 4.77f : 1.f);
+ float rest_density = fluid->rest_density * (fluid->flag & SPH_FAC_DENSITY ? 4.77f : 1.0f);
float rest_length = fluid->rest_length *
- (fluid->flag & SPH_FAC_REST_LENGTH ? 2.588f * pa->size : 1.f);
+ (fluid->flag & SPH_FAC_REST_LENGTH ? 2.588f * pa->size : 1.0f);
float stiffness = fluid->stiffness_k;
float stiffness_near_fac = fluid->stiffness_knear *
- (fluid->flag & SPH_FAC_REPULSION ? fluid->stiffness_k : 1.f);
+ (fluid->flag & SPH_FAC_REPULSION ? fluid->stiffness_k : 1.0f);
ParticleData *npa;
float vec[3];
@@ -1849,7 +1849,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
sub_v3_v3v3(vec, co, state->co);
rij = normalize_v3(vec);
- q = (1.f - rij / h) * pfn->psys->part->mass * inv_mass;
+ q = (1.0f - rij / h) * pfn->psys->part->mass * inv_mass;
if (pfn->psys->part->flag & PART_SIZEMASS) {
q *= npa->size;
@@ -1861,20 +1861,20 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
madd_v3_v3fl(force, vec, -(pressure + near_pressure * q) * q);
/* Viscosity */
- if (visc > 0.f || stiff_visc > 0.f) {
+ if (visc > 0.0f || stiff_visc > 0.0f) {
sub_v3_v3v3(dv, vel, state->vel);
u = dot_v3v3(vec, dv);
- if (u < 0.f && visc > 0.f) {
+ if (u < 0.0f && visc > 0.0f) {
madd_v3_v3fl(force, vec, 0.5f * q * visc * u);
}
- if (u > 0.f && stiff_visc > 0.f) {
+ if (u > 0.0f && stiff_visc > 0.0f) {
madd_v3_v3fl(force, vec, 0.5f * q * stiff_visc * u);
}
}
- if (spring_constant > 0.f) {
+ if (spring_constant > 0.0f) {
/* Viscoelastic spring force */
if (pfn->psys == psys[0] && fluid->flag & SPH_VISCOELASTIC_SPRINGS && springhash) {
/* BLI_edgehash_lookup appears to be thread-safe. - z0r */
@@ -1883,8 +1883,9 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
if (spring_index) {
spring = psys[0]->fluid_springs + spring_index - 1;
- madd_v3_v3fl(
- force, vec, -10.f * spring_constant * (1.f - rij / h) * (spring->rest_length - rij));
+ madd_v3_v3fl(force,
+ vec,
+ -10.0f * spring_constant * (1.0f - rij / h) * (spring->rest_length - rij));
}
else if (fluid->spring_frames == 0 ||
(pa->prev_state.time - pa->time) <= fluid->spring_frames) {
@@ -1898,13 +1899,14 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
}
}
else { /* PART_SPRING_HOOKES - Hooke's spring force */
- madd_v3_v3fl(force, vec, -10.f * spring_constant * (1.f - rij / h) * (rest_length - rij));
+ madd_v3_v3fl(
+ force, vec, -10.0f * spring_constant * (1.0f - rij / h) * (rest_length - rij));
}
}
}
/* Artificial buoyancy force in negative gravity direction */
- if (fluid->buoyancy > 0.f && gravity) {
+ if (fluid->buoyancy > 0.0f && gravity) {
madd_v3_v3fl(force, gravity, fluid->buoyancy * (density - rest_density));
}
@@ -1922,7 +1924,7 @@ static void sphclassical_density_accum_cb(void *userdata,
SPHRangeData *pfr = (SPHRangeData *)userdata;
ParticleData *npa = pfr->npsys->particles + index;
float q;
- float qfac = 21.0f / (256.f * (float)M_PI);
+ float qfac = 21.0f / (256.0f * (float)M_PI);
float rij, rij_h;
float vec[3];
@@ -2079,7 +2081,7 @@ static void sphclassical_force_cb(void *sphdata_v,
}
/* Artificial buoyancy force in negative gravity direction */
- if (fluid->buoyancy > 0.f && gravity) {
+ if (fluid->buoyancy > 0.0f && gravity) {
madd_v3_v3fl(force, gravity, fluid->buoyancy * (pa->sphdensity - rest_density));
}
@@ -2199,7 +2201,7 @@ static void sph_integrate(ParticleSimulationData *sim,
{
ParticleSettings *part = sim->psys->part;
// float timestep = psys_get_timestep(sim); // UNUSED
- float pa_mass = part->mass * (part->flag & PART_SIZEMASS ? pa->size : 1.f);
+ float pa_mass = part->mass * (part->flag & PART_SIZEMASS ? pa->size : 1.0f);
float dtime = dfra * psys_get_timestep(sim);
// int steps = 1; // UNUSED
float effector_acceleration[3];
@@ -2211,7 +2213,7 @@ static void sph_integrate(ParticleSimulationData *sim,
/* restore previous state and treat gravity & effectors as external acceleration*/
sub_v3_v3v3(effector_acceleration, pa->state.vel, pa->prev_state.vel);
- mul_v3_fl(effector_acceleration, 1.f / dtime);
+ mul_v3_fl(effector_acceleration, 1.0f / dtime);
copy_particle_key(&pa->state, &pa->prev_state, 0);
@@ -2300,8 +2302,8 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
integrate_particle(part, pa, dtime, gravity, basic_force_cb, &efdata);
/* damp affects final velocity */
- if (part->dampfac != 0.f) {
- mul_v3_fl(pa->state.vel, 1.f - part->dampfac * efdata.ptex.damp * 25.f * dtime);
+ if (part->dampfac != 0.0f) {
+ mul_v3_fl(pa->state.vel, 1.0f - part->dampfac * efdata.ptex.damp * 25.0f * dtime);
}
// copy_v3_v3(pa->state.ave, states->ave);
@@ -2406,7 +2408,7 @@ static float nr_signed_distance_to_plane(float *p,
d = dot_v3v3(p0, nor);
if (pce->inv_nor == -1) {
- if (d < 0.f) {
+ if (d < 0.0f) {
pce->inv_nor = 1;
}
else {
@@ -2452,7 +2454,7 @@ static void collision_interpolate_element(ParticleCollisionElement *pce,
/* fac is the starting factor for current collision iteration */
/* The col->fac's are factors for the particle subframe step start
* and end during collision modifier step. */
- float f = fac + t * (1.f - fac);
+ float f = fac + t * (1.0f - fac);
float mul = col->fac1 + f * (col->fac2 - col->fac1);
if (pce->tot > 0) {
madd_v3_v3v3fl(pce->x0, pce->x[0], pce->v[0], mul);
@@ -2485,8 +2487,8 @@ static void collision_point_velocity(ParticleCollisionElement *pce)
static float collision_point_distance_with_normal(
float p[3], ParticleCollisionElement *pce, float fac, ParticleCollision *col, float *nor)
{
- if (fac >= 0.f) {
- collision_interpolate_element(pce, 0.f, fac, col);
+ if (fac >= 0.0f) {
+ collision_interpolate_element(pce, 0.0f, fac, col);
}
switch (pce->tot) {
@@ -2504,14 +2506,14 @@ static float collision_point_distance_with_normal(
return normalize_v3(nor);
}
case 3:
- return nr_signed_distance_to_plane(p, 0.f, pce, nor);
+ return nr_signed_distance_to_plane(p, 0.0f, pce, nor);
}
return 0;
}
static void collision_point_on_surface(
const float p[3], ParticleCollisionElement *pce, float fac, ParticleCollision *col, float *co)
{
- collision_interpolate_element(pce, 0.f, fac, col);
+ collision_interpolate_element(pce, 0.0f, fac, col);
switch (pce->tot) {
case 1: {
@@ -2575,11 +2577,11 @@ static float collision_newton_rhapson(ParticleCollision *col,
}
/* start from the beginning */
- t0 = 0.f;
+ t0 = 0.0f;
collision_interpolate_element(pce, t0, col->f, col);
d0 = distance_func(col->co1, radius, pce, n);
t1 = dt_init;
- d1 = 0.f;
+ d1 = 0.0f;
for (iter = 0; iter < 10; iter++) { //, itersum++) {
/* get current location */
@@ -2589,11 +2591,11 @@ static float collision_newton_rhapson(ParticleCollision *col,
d1 = distance_func(pce->p, radius, pce, n);
/* particle already inside face, so report collision */
- if (iter == 0 && d0 < 0.f && d0 > -radius) {
+ if (iter == 0 && d0 < 0.0f && d0 > -radius) {
copy_v3_v3(pce->p, col->co1);
copy_v3_v3(pce->nor, n);
pce->inside = 1;
- return 0.f;
+ return 0.0f;
}
/* Zero gradient (no movement relative to element). Can't step from
@@ -2602,15 +2604,15 @@ static float collision_newton_rhapson(ParticleCollision *col,
/* If first iteration, try from other end where the gradient may be
* greater. Note: code duplicated below. */
if (iter == 0) {
- t0 = 1.f;
+ t0 = 1.0f;
collision_interpolate_element(pce, t0, col->f, col);
d0 = distance_func(col->co2, radius, pce, n);
t1 = 1.0f - dt_init;
- d1 = 0.f;
+ d1 = 0.0f;
continue;
}
- return -1.f;
+ return -1.0f;
}
dd = (t1 - t0) / (d1 - d0);
@@ -2622,30 +2624,30 @@ static float collision_newton_rhapson(ParticleCollision *col,
/* Particle moving away from plane could also mean a strangely rotating
* face, so check from end. Note: code duplicated above. */
- if (iter == 0 && t1 < 0.f) {
- t0 = 1.f;
+ if (iter == 0 && t1 < 0.0f) {
+ t0 = 1.0f;
collision_interpolate_element(pce, t0, col->f, col);
d0 = distance_func(col->co2, radius, pce, n);
t1 = 1.0f - dt_init;
- d1 = 0.f;
+ d1 = 0.0f;
continue;
}
- if (iter == 1 && (t1 < -COLLISION_ZERO || t1 > 1.f)) {
- return -1.f;
+ if (iter == 1 && (t1 < -COLLISION_ZERO || t1 > 1.0f)) {
+ return -1.0f;
}
if (d1 <= COLLISION_ZERO && d1 >= -COLLISION_ZERO) {
- if (t1 >= -COLLISION_ZERO && t1 <= 1.f) {
+ if (t1 >= -COLLISION_ZERO && t1 <= 1.0f) {
if (distance_func == nr_signed_distance_to_plane) {
copy_v3_v3(pce->nor, n);
}
- CLAMP(t1, 0.f, 1.f);
+ CLAMP(t1, 0.0f, 1.0f);
return t1;
}
- return -1.f;
+ return -1.0f;
}
}
return -1.0;
@@ -2663,7 +2665,7 @@ static int collision_sphere_to_tri(ParticleCollision *col,
ct = collision_newton_rhapson(col, radius, pce, nr_signed_distance_to_plane);
- if (ct >= 0.f && ct < *t && (result->inside == 0 || pce->inside == 1)) {
+ if (ct >= 0.0f && ct < *t && (result->inside == 0 || pce->inside == 1)) {
float e1[3], e2[3], p0[3];
float e1e1, e1e2, e1p0, e2e2, e2p0, inv;
@@ -2678,11 +2680,11 @@ static int collision_sphere_to_tri(ParticleCollision *col,
e2e2 = dot_v3v3(e2, e2);
e2p0 = dot_v3v3(e2, p0);
- inv = 1.f / (e1e1 * e2e2 - e1e2 * e1e2);
+ inv = 1.0f / (e1e1 * e2e2 - e1e2 * e1e2);
u = (e2e2 * e1p0 - e1e2 * e2p0) * inv;
v = (e1e1 * e2p0 - e1e2 * e1p0) * inv;
- if (u >= 0.f && u <= 1.f && v >= 0.f && u + v <= 1.f) {
+ if (u >= 0.0f && u <= 1.0f && v >= 0.0f && u + v <= 1.0f) {
*result = *pce;
/* normal already calculated in pce */
@@ -2718,14 +2720,14 @@ static int collision_sphere_to_edges(ParticleCollision *col,
ct = collision_newton_rhapson(col, radius, cur, nr_distance_to_edge);
- if (ct >= 0.f && ct < *t) {
+ if (ct >= 0.0f && ct < *t) {
float u, e[3], vec[3];
sub_v3_v3v3(e, cur->x1, cur->x0);
sub_v3_v3v3(vec, cur->p, cur->x0);
u = dot_v3v3(vec, e) / dot_v3v3(e, e);
- if (u < 0.f || u > 1.f) {
+ if (u < 0.0f || u > 1.0f) {
break;
}
@@ -2763,7 +2765,7 @@ static int collision_sphere_to_verts(ParticleCollision *col,
ct = collision_newton_rhapson(col, radius, cur, nr_distance_to_vert);
- if (ct >= 0.f && ct < *t) {
+ if (ct >= 0.0f && ct < *t) {
*result = *cur;
sub_v3_v3v3(result->nor, cur->p, cur->x0);
@@ -3019,7 +3021,7 @@ static int collision_response(ParticleSimulationData *sim,
(vc_dot < 0.0f && v0_dot < 0.0f && vc_dot < v0_dot))) {
mul_v3_v3fl(v0_nor, pce->nor, vc_dot);
}
- else if (v0_dot > 0.f) {
+ else if (v0_dot > 0.0f) {
mul_v3_v3fl(v0_nor, pce->nor, vc_dot + v0_dot);
}
else {
@@ -3045,25 +3047,25 @@ static int collision_response(ParticleSimulationData *sim,
/* make sure particle stays on the right side of the surface */
if (!through) {
- distance = collision_point_distance_with_normal(co, pce, -1.f, col, nor);
+ distance = collision_point_distance_with_normal(co, pce, -1.0f, col, nor);
if (distance < col->radius + COLLISION_MIN_DISTANCE) {
madd_v3_v3fl(co, nor, col->radius + COLLISION_MIN_DISTANCE - distance);
}
dot = dot_v3v3(nor, v0);
- if (dot < 0.f) {
+ if (dot < 0.0f) {
madd_v3_v3fl(v0, nor, -dot);
}
- distance = collision_point_distance_with_normal(pa->state.co, pce, 1.f, col, nor);
+ distance = collision_point_distance_with_normal(pa->state.co, pce, 1.0f, col, nor);
if (distance < col->radius + COLLISION_MIN_DISTANCE) {
madd_v3_v3fl(pa->state.co, nor, col->radius + COLLISION_MIN_DISTANCE - distance);
}
dot = dot_v3v3(nor, pa->state.vel);
- if (dot < 0.f) {
+ if (dot < 0.0f) {
madd_v3_v3fl(pa->state.vel, nor, -dot);
}
}
@@ -3090,7 +3092,7 @@ static int collision_response(ParticleSimulationData *sim,
static void collision_fail(ParticleData *pa, ParticleCollision *col)
{
/* final chance to prevent total failure, so stick to the surface and hope for the best */
- collision_point_on_surface(col->co1, &col->pce, 1.f, col, pa->state.co);
+ collision_point_on_surface(col->co1, &col->pce, 1.0f, col, pa->state.co);
copy_v3_v3(pa->state.vel, col->pce.vel);
mul_v3_fl(pa->state.vel, col->inv_timestep);
@@ -3128,7 +3130,7 @@ static void collision_check(ParticleSimulationData *sim, int p, float dfra, floa
/* get acceleration (from gravity, forcefields etc. to be re-applied in collision response) */
sub_v3_v3v3(col.acc, pa->state.vel, pa->prev_state.vel);
- mul_v3_fl(col.acc, 1.f / col.total_time);
+ mul_v3_fl(col.acc, 1.0f / col.total_time);
/* set values for first iteration */
copy_v3_v3(col.co1, pa->prev_state.co);
@@ -3925,7 +3927,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
if (ELEM(pa->alive, PARS_ALIVE, PARS_DYING) == 0 ||
(pa->flag & (PARS_UNEXIST | PARS_NO_DISP))) {
- pa->state.time = -1.f;
+ pa->state.time = -1.0f;
}
}
@@ -4149,20 +4151,17 @@ static bool particles_has_tracer(short parttype)
static bool particles_has_spray(short parttype)
{
- return ((parttype == PART_FLUID_SPRAY) || (parttype == PART_FLUID_SPRAYFOAM) ||
- (parttype == PART_FLUID_SPRAYFOAMBUBBLE));
+ return (ELEM(parttype, PART_FLUID_SPRAY, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYFOAMBUBBLE));
}
static bool particles_has_bubble(short parttype)
{
- return ((parttype == PART_FLUID_BUBBLE) || (parttype == PART_FLUID_FOAMBUBBLE) ||
- (parttype == PART_FLUID_SPRAYFOAMBUBBLE));
+ return (ELEM(parttype, PART_FLUID_BUBBLE, PART_FLUID_FOAMBUBBLE, PART_FLUID_SPRAYFOAMBUBBLE));
}
static bool particles_has_foam(short parttype)
{
- return ((parttype == PART_FLUID_FOAM) || (parttype == PART_FLUID_SPRAYFOAM) ||
- (parttype == PART_FLUID_SPRAYFOAMBUBBLE));
+ return (ELEM(parttype, PART_FLUID_FOAM, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYFOAMBUBBLE));
}
static void particles_fluid_step(ParticleSimulationData *sim,
@@ -4410,7 +4409,7 @@ static void particles_fluid_step(ParticleSimulationData *sim,
zero_v3(pa->state.ave);
unit_qt(pa->state.rot);
- pa->time = 1.f;
+ pa->time = 1.0f;
pa->dietime = sim->scene->r.efra + 1;
pa->lifetime = sim->scene->r.efra;
pa->alive = PARS_ALIVE;
@@ -4590,8 +4589,8 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
dt_frac = psys->dt_frac;
for (t_frac = dt_frac; t_frac <= 1.0f; t_frac += dt_frac) {
sim->courant_num = 0.0f;
- dynamics_step(sim, cfra + dframe + t_frac - 1.f);
- psys->cfra = cfra + dframe + t_frac - 1.f;
+ dynamics_step(sim, cfra + dframe + t_frac - 1.0f);
+ psys->cfra = cfra + dframe + t_frac - 1.0f;
if (part->time_flag & PART_TIME_AUTOSF) {
update_timestep(psys, sim);
@@ -4692,17 +4691,17 @@ void BKE_particlesettings_fluid_default_settings(ParticleSettings *part)
{
SPHFluidSettings *fluid = part->fluid;
- fluid->spring_k = 0.f;
+ fluid->spring_k = 0.0f;
fluid->plasticity_constant = 0.1f;
fluid->yield_ratio = 0.1f;
- fluid->rest_length = 1.f;
- fluid->viscosity_omega = 2.f;
+ fluid->rest_length = 1.0f;
+ fluid->viscosity_omega = 2.0f;
fluid->viscosity_beta = 0.1f;
- fluid->stiffness_k = 1.f;
- fluid->stiffness_knear = 1.f;
- fluid->rest_density = 1.f;
- fluid->buoyancy = 0.f;
- fluid->radius = 1.f;
+ fluid->stiffness_k = 1.0f;
+ fluid->stiffness_knear = 1.0f;
+ fluid->rest_density = 1.0f;
+ fluid->buoyancy = 0.0f;
+ fluid->radius = 1.0f;
fluid->flag |= SPH_FAC_REPULSION | SPH_FAC_DENSITY | SPH_FAC_RADIUS | SPH_FAC_VISCOSITY |
SPH_FAC_REST_LENGTH;
}
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index d31b0d54784..09e4ad93baa 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -63,6 +63,7 @@
static void pbvh_bmesh_verify(PBVH *pbvh);
#endif
+/* -------------------------------------------------------------------- */
/** \name BMesh Utility API
*
* Use some local functions which assume triangles.
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 7c8527a8702..be06d4c7348 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -44,6 +44,7 @@
#include "DNA_simulation_types.h"
#include "BLI_blenlib.h"
+#include "BLI_endian_switch.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
@@ -67,6 +68,8 @@
#include "BKE_scene.h"
#include "BKE_softbody.h"
+#include "BLO_read_write.h"
+
#include "BIK_api.h"
#ifdef WITH_BULLET
@@ -256,7 +259,9 @@ static int ptcache_softbody_totpoint(void *soft_v, int UNUSED(cfra))
SoftBody *soft = soft_v;
return soft->totpoint;
}
-static void ptcache_softbody_error(void *UNUSED(soft_v), const char *UNUSED(message))
+static void ptcache_softbody_error(const ID *UNUSED(owner_id),
+ void *UNUSED(soft_v),
+ const char *UNUSED(message))
{
/* ignored for now */
}
@@ -460,7 +465,7 @@ static void ptcache_particle_interpolate(int index,
psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1);
interp_qt_qtqt(pa->state.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra);
- mul_v3_fl(pa->state.vel, 1.f / (dfra * timestep));
+ mul_v3_fl(pa->state.vel, 1.0f / (dfra * timestep));
pa->state.time = cfra;
}
@@ -471,7 +476,9 @@ static int ptcache_particle_totpoint(void *psys_v, int UNUSED(cfra))
return psys->totpart;
}
-static void ptcache_particle_error(void *UNUSED(psys_v), const char *UNUSED(message))
+static void ptcache_particle_error(const ID *UNUSED(owner_id),
+ void *UNUSED(psys_v),
+ const char *UNUSED(message))
{
/* ignored for now */
}
@@ -642,10 +649,11 @@ static int ptcache_cloth_totpoint(void *cloth_v, int UNUSED(cfra))
return clmd->clothObject ? clmd->clothObject->mvert_num : 0;
}
-static void ptcache_cloth_error(void *cloth_v, const char *message)
+static void ptcache_cloth_error(const ID *owner_id, void *cloth_v, const char *message)
{
ClothModifierData *clmd = cloth_v;
- BKE_modifier_set_error(&clmd->modifier, "%s", message);
+ BLI_assert(GS(owner_id->name) == ID_OB);
+ BKE_modifier_set_error((Object *)owner_id, &clmd->modifier, "%s", message);
}
static int ptcache_dynamicpaint_totpoint(void *sd, int UNUSED(cfra))
@@ -659,7 +667,9 @@ static int ptcache_dynamicpaint_totpoint(void *sd, int UNUSED(cfra))
return surface->data->total_points;
}
-static void ptcache_dynamicpaint_error(void *UNUSED(sd), const char *UNUSED(message))
+static void ptcache_dynamicpaint_error(const ID *UNUSED(owner_id),
+ void *UNUSED(sd),
+ const char *UNUSED(message))
{
/* ignored for now */
}
@@ -731,8 +741,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
data_len = sizeof(PaintPoint);
}
- else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
- surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
+ else if (ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WEIGHT)) {
data_len = sizeof(float);
}
else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
@@ -853,7 +862,9 @@ static int ptcache_rigidbody_totpoint(void *rb_v, int UNUSED(cfra))
return rbw->numbodies;
}
-static void ptcache_rigidbody_error(void *UNUSED(rb_v), const char *UNUSED(message))
+static void ptcache_rigidbody_error(const struct ID *UNUSED(owner_id),
+ void *UNUSED(rb_v),
+ const char *UNUSED(message))
{
/* ignored for now */
}
@@ -1355,6 +1366,58 @@ static int ptcache_path(PTCacheID *pid, char *filename)
return BLI_path_slash_ensure(filename); /* new strlen() */
}
+static size_t ptcache_filename_ext_append(PTCacheID *pid,
+ char *filename,
+ const size_t filename_len,
+ const bool use_frame_number,
+ const int cfra)
+{
+ size_t len = filename_len;
+ char *filename_ext;
+ filename_ext = filename + filename_len;
+ *filename_ext = '\0';
+
+ /* PointCaches are inserted in object's list on demand, we need a valid index now. */
+ if (pid->cache->index < 0) {
+ BLI_assert(GS(pid->owner_id->name) == ID_OB);
+ pid->cache->index = pid->stack_index = BKE_object_insert_ptcache((Object *)pid->owner_id);
+ }
+
+ const char *ext = ptcache_file_extension(pid);
+ if (use_frame_number) {
+ if (pid->cache->flag & PTCACHE_EXTERNAL) {
+ if (pid->cache->index >= 0) {
+ len += BLI_snprintf_rlen(
+ filename_ext, MAX_PTCACHE_FILE - len, "_%06d_%02u%s", cfra, pid->stack_index, ext);
+ }
+ else {
+ len += BLI_snprintf_rlen(filename_ext, MAX_PTCACHE_FILE - len, "_%06d%s", cfra, ext);
+ }
+ }
+ else {
+ len += BLI_snprintf_rlen(
+ filename_ext, MAX_PTCACHE_FILE - len, "_%06d_%02u%s", cfra, pid->stack_index, ext);
+ }
+ }
+ else {
+ if (pid->cache->flag & PTCACHE_EXTERNAL) {
+ if (pid->cache->index >= 0) {
+ len += BLI_snprintf_rlen(
+ filename_ext, MAX_PTCACHE_FILE - len, "_%02u%s", pid->stack_index, ext);
+ }
+ else {
+ len += BLI_snprintf_rlen(filename_ext, MAX_PTCACHE_FILE - len, "%s", ext);
+ }
+ }
+ else {
+ len += BLI_snprintf_rlen(
+ filename_ext, MAX_PTCACHE_FILE - len, "_%02u%s", pid->stack_index, ext);
+ }
+ }
+
+ return len;
+}
+
static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_path, short do_ext)
{
int len = 0;
@@ -1376,7 +1439,7 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
idname = (pid->owner_id->name + 2);
/* convert chars to hex so they are always a valid filename */
while ('\0' != *idname) {
- BLI_snprintf(newname, MAX_PTCACHE_FILE, "%02X", (unsigned int)(*idname++));
+ BLI_snprintf(newname, MAX_PTCACHE_FILE - len, "%02X", (unsigned int)(*idname++));
newname += 2;
len += 2;
}
@@ -1389,28 +1452,7 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
}
if (do_ext) {
- if (pid->cache->index < 0) {
- BLI_assert(GS(pid->owner_id->name) == ID_OB);
- pid->cache->index = pid->stack_index = BKE_object_insert_ptcache((Object *)pid->owner_id);
- }
-
- const char *ext = ptcache_file_extension(pid);
-
- if (pid->cache->flag & PTCACHE_EXTERNAL) {
- if (pid->cache->index >= 0) {
- /* Always 6 chars. */
- BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u%s", cfra, pid->stack_index, ext);
- }
- else {
- /* Always 6 chars. */
- BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d%s", cfra, ext);
- }
- }
- else {
- /* Always 6 chars. */
- BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u%s", cfra, pid->stack_index, ext);
- }
- len += 16;
+ len += ptcache_filename_ext_append(pid, filename, (size_t)len, true, cfra);
}
return len; /* make sure the above string is always 16 chars */
@@ -1423,7 +1465,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
{
PTCacheFile *pf;
FILE *fp = NULL;
- char filename[FILE_MAX * 2];
+ char filename[MAX_PTCACHE_FILE];
#ifndef DURIAN_POINTCACHE_LIB_OK
/* don't allow writing for linked objects */
@@ -2098,19 +2140,19 @@ static int ptcache_read_stream(PTCacheID *pid, int cfra)
}
if (!ptcache_file_header_begin_read(pf)) {
- pid->error(pid->calldata, "Failed to read point cache file");
+ pid->error(pid->owner_id, pid->calldata, "Failed to read point cache file");
error = 1;
}
else if (pf->type != pid->type) {
- pid->error(pid->calldata, "Point cache file has wrong type");
+ pid->error(pid->owner_id, pid->calldata, "Point cache file has wrong type");
error = 1;
}
else if (!pid->read_header(pf)) {
- pid->error(pid->calldata, "Failed to read point cache file header");
+ pid->error(pid->owner_id, pid->calldata, "Failed to read point cache file header");
error = 1;
}
else if (pf->totpoint != pid->totpoint(pid->calldata, cfra)) {
- pid->error(pid->calldata, "Number of points in cache does not match mesh");
+ pid->error(pid->owner_id, pid->calldata, "Number of points in cache does not match mesh");
error = 1;
}
@@ -2119,7 +2161,7 @@ static int ptcache_read_stream(PTCacheID *pid, int cfra)
/* We have stream reading here. */
if (!pid->read_stream(pf, pid->calldata)) {
- pid->error(pid->calldata, "Failed to read point cache file data");
+ pid->error(pid->owner_id, pid->calldata, "Failed to read point cache file data");
error = 1;
}
}
@@ -2155,7 +2197,7 @@ static int ptcache_read(PTCacheID *pid, int cfra)
int pid_totpoint = pid->totpoint(pid->calldata, cfra);
if (totpoint != pid_totpoint) {
- pid->error(pid->calldata, "Number of points in cache does not match mesh");
+ pid->error(pid->owner_id, pid->calldata, "Number of points in cache does not match mesh");
totpoint = MIN2(totpoint, pid_totpoint);
}
}
@@ -2211,7 +2253,7 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
int pid_totpoint = pid->totpoint(pid->calldata, (int)cfra);
if (totpoint != pid_totpoint) {
- pid->error(pid->calldata, "Number of points in cache does not match mesh");
+ pid->error(pid->owner_id, pid->calldata, "Number of points in cache does not match mesh");
totpoint = MIN2(totpoint, pid_totpoint);
}
}
@@ -2580,8 +2622,6 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
/*if (!G.relbase_valid) return; */ /* save blend file before using pointcache */
- const char *fext = ptcache_file_extension(pid);
-
/* clear all files in the temp dir with the prefix of the ID and the ".bphys" suffix */
switch (mode) {
case PTCACHE_CLEAR_ALL:
@@ -2604,7 +2644,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
len += 1;
}
- BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext);
+ ptcache_filename_ext_append(pid, ext, 0, false, 0);
while ((de = readdir(dir)) != NULL) {
if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
@@ -2801,9 +2841,7 @@ void BKE_ptcache_id_time(
return;
}
- const char *fext = ptcache_file_extension(pid);
-
- BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext);
+ ptcache_filename_ext_append(pid, ext, 0, false, 0);
while ((de = readdir(dir)) != NULL) {
if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
@@ -3515,9 +3553,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
return;
}
- const char *fext = ptcache_file_extension(pid);
-
- BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext);
+ ptcache_filename_ext_append(pid, ext, 0, false, 0);
/* put new name into cache */
BLI_strncpy(pid->cache->name, name_dst, sizeof(pid->cache->name));
@@ -3771,3 +3807,124 @@ void BKE_ptcache_invalidate(PointCache *cache)
cache->last_exact = MIN2(cache->startframe, 0);
}
}
+
+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:
+};
+static const char *ptcache_extra_struct[] = {
+ "",
+ "ParticleSpring",
+ "vec3f",
+};
+void BKE_ptcache_blend_write(BlendWriter *writer, ListBase *ptcaches)
+{
+ LISTBASE_FOREACH (PointCache *, cache, ptcaches) {
+ BLO_write_struct(writer, PointCache, cache);
+
+ if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
+ LISTBASE_FOREACH (PTCacheMem *, pm, &cache->mem_cache) {
+ BLO_write_struct(writer, PTCacheMem, pm);
+
+ for (int i = 0; i < BPHYS_TOT_DATA; i++) {
+ if (pm->data[i] && pm->data_types & (1 << i)) {
+ if (ptcache_data_struct[i][0] == '\0') {
+ BLO_write_raw(writer, MEM_allocN_len(pm->data[i]), pm->data[i]);
+ }
+ else {
+ BLO_write_struct_array_by_name(
+ writer, ptcache_data_struct[i], pm->totpoint, pm->data[i]);
+ }
+ }
+ }
+
+ LISTBASE_FOREACH (PTCacheExtra *, extra, &pm->extradata) {
+ if (ptcache_extra_struct[extra->type][0] == '\0') {
+ continue;
+ }
+ BLO_write_struct(writer, PTCacheExtra, extra);
+ BLO_write_struct_array_by_name(
+ writer, ptcache_extra_struct[extra->type], extra->totdata, extra->data);
+ }
+ }
+ }
+ }
+}
+
+static void direct_link_pointcache_cb(BlendDataReader *reader, void *data)
+{
+ PTCacheMem *pm = data;
+ for (int i = 0; i < BPHYS_TOT_DATA; i++) {
+ BLO_read_data_address(reader, &pm->data[i]);
+
+ /* the cache saves non-struct data without DNA */
+ if (pm->data[i] && ptcache_data_struct[i][0] == '\0' &&
+ BLO_read_requires_endian_switch(reader)) {
+ /* data_size returns bytes. */
+ int tot = (BKE_ptcache_data_size(i) * pm->totpoint) / sizeof(int);
+
+ int *poin = pm->data[i];
+
+ BLI_endian_switch_int32_array(poin, tot);
+ }
+ }
+
+ BLO_read_list(reader, &pm->extradata);
+
+ LISTBASE_FOREACH (PTCacheExtra *, extra, &pm->extradata) {
+ BLO_read_data_address(reader, &extra->data);
+ }
+}
+
+static void direct_link_pointcache(BlendDataReader *reader, PointCache *cache)
+{
+ if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
+ BLO_read_list_cb(reader, &cache->mem_cache, direct_link_pointcache_cb);
+ }
+ else {
+ BLI_listbase_clear(&cache->mem_cache);
+ }
+
+ cache->flag &= ~PTCACHE_SIMULATION_VALID;
+ cache->simframe = 0;
+ cache->edit = NULL;
+ cache->free_edit = NULL;
+ cache->cached_frames = NULL;
+ cache->cached_frames_len = 0;
+}
+
+void BKE_ptcache_blend_read_data(BlendDataReader *reader,
+ ListBase *ptcaches,
+ PointCache **ocache,
+ int force_disk)
+{
+ if (ptcaches->first) {
+ BLO_read_list(reader, ptcaches);
+ LISTBASE_FOREACH (PointCache *, cache, ptcaches) {
+ direct_link_pointcache(reader, cache);
+ if (force_disk) {
+ cache->flag |= PTCACHE_DISK_CACHE;
+ cache->step = 1;
+ }
+ }
+
+ BLO_read_data_address(reader, ocache);
+ }
+ else if (*ocache) {
+ /* old "single" caches need to be linked too */
+ BLO_read_data_address(reader, ocache);
+ direct_link_pointcache(reader, *ocache);
+ if (force_disk) {
+ (*ocache)->flag |= PTCACHE_DISK_CACHE;
+ (*ocache)->step = 1;
+ }
+
+ ptcaches->first = ptcaches->last = *ocache;
+ }
+}
diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.cc
index 78acf7251fa..cbfb1086e8d 100644
--- a/source/blender/blenkernel/intern/pointcloud.c
+++ b/source/blender/blenkernel/intern/pointcloud.cc
@@ -67,7 +67,7 @@ static void pointcloud_init_data(ID *id)
CustomData_add_layer_named(&pointcloud->pdata,
CD_PROP_FLOAT3,
CD_CALLOC,
- NULL,
+ nullptr,
pointcloud->totpoint,
POINTCLOUD_ATTR_POSITION);
BKE_pointcloud_update_customdata_pointers(pointcloud);
@@ -77,7 +77,7 @@ static void pointcloud_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_s
{
PointCloud *pointcloud_dst = (PointCloud *)id_dst;
const PointCloud *pointcloud_src = (const PointCloud *)id_src;
- pointcloud_dst->mat = MEM_dupallocN(pointcloud_dst->mat);
+ pointcloud_dst->mat = static_cast<Material **>(MEM_dupallocN(pointcloud_dst->mat));
const eCDAllocType alloc_type = (flag & LIB_ID_COPY_CD_REFERENCE) ? CD_REFERENCE : CD_DUPLICATE;
CustomData_copy(&pointcloud_src->pdata,
@@ -109,7 +109,7 @@ static void pointcloud_blend_write(BlendWriter *writer, ID *id, const void *id_a
{
PointCloud *pointcloud = (PointCloud *)id;
if (pointcloud->id.us > 0 || BLO_write_is_undo(writer)) {
- CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
+ CustomDataLayer *players = nullptr, players_buff[CD_TEMP_CHUNK_SIZE];
CustomData_blend_write_prepare(
&pointcloud->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
@@ -164,26 +164,28 @@ static void pointcloud_blend_read_expand(BlendExpander *expander, ID *id)
}
IDTypeInfo IDType_ID_PT = {
- .id_code = ID_PT,
- .id_filter = FILTER_ID_PT,
- .main_listbase_index = INDEX_ID_PT,
- .struct_size = sizeof(PointCloud),
- .name = "PointCloud",
- .name_plural = "pointclouds",
- .translation_context = BLT_I18NCONTEXT_ID_POINTCLOUD,
- .flags = 0,
-
- .init_data = pointcloud_init_data,
- .copy_data = pointcloud_copy_data,
- .free_data = pointcloud_free_data,
- .make_local = NULL,
- .foreach_id = pointcloud_foreach_id,
- .foreach_cache = NULL,
-
- .blend_write = pointcloud_blend_write,
- .blend_read_data = pointcloud_blend_read_data,
- .blend_read_lib = pointcloud_blend_read_lib,
- .blend_read_expand = pointcloud_blend_read_expand,
+ /* id_code */ ID_PT,
+ /* id_filter */ FILTER_ID_PT,
+ /* main_listbase_index */ INDEX_ID_PT,
+ /* struct_size */ sizeof(PointCloud),
+ /* name */ "PointCloud",
+ /* name_plural */ "pointclouds",
+ /* translation_context */ BLT_I18NCONTEXT_ID_POINTCLOUD,
+ /* flags */ 0,
+
+ /* init_data */ pointcloud_init_data,
+ /* copy_data */ pointcloud_copy_data,
+ /* free_data */ pointcloud_free_data,
+ /* make_local */ nullptr,
+ /* foreach_id */ pointcloud_foreach_id,
+ /* foreach_cache */ nullptr,
+
+ /* blend_write */ pointcloud_blend_write,
+ /* blend_read_data */ pointcloud_blend_read_data,
+ /* blend_read_lib */ pointcloud_blend_read_lib,
+ /* blend_read_expand */ pointcloud_blend_read_expand,
+
+ /* blend_read_undo_preserve */ nullptr,
};
static void pointcloud_random(PointCloud *pointcloud)
@@ -206,21 +208,21 @@ static void pointcloud_random(PointCloud *pointcloud)
void *BKE_pointcloud_add(Main *bmain, const char *name)
{
- PointCloud *pointcloud = BKE_id_new(bmain, ID_PT, name);
+ PointCloud *pointcloud = static_cast<PointCloud *>(BKE_id_new(bmain, ID_PT, name));
return pointcloud;
}
void *BKE_pointcloud_add_default(Main *bmain, const char *name)
{
- PointCloud *pointcloud = BKE_libblock_alloc(bmain, ID_PT, name, 0);
+ PointCloud *pointcloud = static_cast<PointCloud *>(BKE_libblock_alloc(bmain, ID_PT, name, 0));
pointcloud_init_data(&pointcloud->id);
CustomData_add_layer_named(&pointcloud->pdata,
CD_PROP_FLOAT,
CD_CALLOC,
- NULL,
+ nullptr,
pointcloud->totpoint,
POINTCLOUD_ATTR_RADIUS);
pointcloud_random(pointcloud);
@@ -231,14 +233,14 @@ void *BKE_pointcloud_add_default(Main *bmain, const char *name)
BoundBox *BKE_pointcloud_boundbox_get(Object *ob)
{
BLI_assert(ob->type == OB_POINTCLOUD);
- PointCloud *pointcloud = ob->data;
+ PointCloud *pointcloud = static_cast<PointCloud *>(ob->data);
- if (ob->runtime.bb != NULL && (ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) {
+ if (ob->runtime.bb != nullptr && (ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) {
return ob->runtime.bb;
}
- if (ob->runtime.bb == NULL) {
- ob->runtime.bb = MEM_callocN(sizeof(BoundBox), "pointcloud boundbox");
+ if (ob->runtime.bb == nullptr) {
+ ob->runtime.bb = static_cast<BoundBox *>(MEM_callocN(sizeof(BoundBox), "pointcloud boundbox"));
float min[3], max[3];
INIT_MINMAX(min, max);
@@ -262,10 +264,10 @@ BoundBox *BKE_pointcloud_boundbox_get(Object *ob)
void BKE_pointcloud_update_customdata_pointers(PointCloud *pointcloud)
{
- pointcloud->co = CustomData_get_layer_named(
- &pointcloud->pdata, CD_PROP_FLOAT3, POINTCLOUD_ATTR_POSITION);
- pointcloud->radius = CustomData_get_layer_named(
- &pointcloud->pdata, CD_PROP_FLOAT, POINTCLOUD_ATTR_RADIUS);
+ pointcloud->co = static_cast<float(*)[3]>(
+ CustomData_get_layer_named(&pointcloud->pdata, CD_PROP_FLOAT3, POINTCLOUD_ATTR_POSITION));
+ pointcloud->radius = static_cast<float *>(
+ CustomData_get_layer_named(&pointcloud->pdata, CD_PROP_FLOAT, POINTCLOUD_ATTR_RADIUS));
}
bool BKE_pointcloud_customdata_required(PointCloud *UNUSED(pointcloud), CustomDataLayer *layer)
@@ -277,11 +279,11 @@ bool BKE_pointcloud_customdata_required(PointCloud *UNUSED(pointcloud), CustomDa
PointCloud *BKE_pointcloud_new_for_eval(const PointCloud *pointcloud_src, int totpoint)
{
- PointCloud *pointcloud_dst = BKE_id_new_nomain(ID_PT, NULL);
+ PointCloud *pointcloud_dst = static_cast<PointCloud *>(BKE_id_new_nomain(ID_PT, nullptr));
CustomData_free(&pointcloud_dst->pdata, pointcloud_dst->totpoint);
STRNCPY(pointcloud_dst->id.name, pointcloud_src->id.name);
- pointcloud_dst->mat = MEM_dupallocN(pointcloud_src->mat);
+ pointcloud_dst->mat = static_cast<Material **>(MEM_dupallocN(pointcloud_src->mat));
pointcloud_dst->totcol = pointcloud_src->totcol;
pointcloud_dst->totpoint = totpoint;
@@ -300,7 +302,7 @@ PointCloud *BKE_pointcloud_copy_for_eval(struct PointCloud *pointcloud_src, bool
flags |= LIB_ID_COPY_CD_REFERENCE;
}
- PointCloud *result = (PointCloud *)BKE_id_copy_ex(NULL, &pointcloud_src->id, NULL, flags);
+ PointCloud *result = (PointCloud *)BKE_id_copy_ex(nullptr, &pointcloud_src->id, nullptr, flags);
return result;
}
@@ -324,7 +326,7 @@ static PointCloud *pointcloud_evaluate_modifiers(struct Depsgraph *depsgraph,
/* Evaluate modifiers. */
for (; md; md = md->next) {
- const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
+ const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type);
if (!BKE_modifier_is_enabled(scene, md, required_mode)) {
continue;
@@ -343,7 +345,7 @@ static PointCloud *pointcloud_evaluate_modifiers(struct Depsgraph *depsgraph,
BKE_pointcloud_update_customdata_pointers(pointcloud);
/* Created deformed coordinates array on demand. */
- mti->deformVerts(md, &mectx, NULL, pointcloud->co, pointcloud->totpoint);
+ mti->deformVerts(md, &mectx, nullptr, pointcloud->co, pointcloud->totpoint);
}
else if (mti->modifyPointCloud) {
/* Ensure we are not modifying the input. */
@@ -356,7 +358,7 @@ static PointCloud *pointcloud_evaluate_modifiers(struct Depsgraph *depsgraph,
if (pointcloud_next && pointcloud_next != pointcloud) {
/* If the modifier returned a new pointcloud, release the old one. */
if (pointcloud != pointcloud_input) {
- BKE_id_free(NULL, pointcloud);
+ BKE_id_free(nullptr, pointcloud);
}
pointcloud = pointcloud_next;
}
@@ -372,7 +374,7 @@ void BKE_pointcloud_data_update(struct Depsgraph *depsgraph, struct Scene *scene
BKE_object_free_derived_caches(object);
/* Evaluate modifiers. */
- PointCloud *pointcloud = object->data;
+ PointCloud *pointcloud = static_cast<PointCloud *>(object->data);
PointCloud *pointcloud_eval = pointcloud_evaluate_modifiers(
depsgraph, scene, object, pointcloud);
@@ -382,8 +384,8 @@ void BKE_pointcloud_data_update(struct Depsgraph *depsgraph, struct Scene *scene
}
/* Draw Cache */
-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_cb)(PointCloud *pointcloud, int mode) = nullptr;
+void (*BKE_pointcloud_batch_cache_free_cb)(PointCloud *pointcloud) = nullptr;
void BKE_pointcloud_batch_cache_dirty_tag(PointCloud *pointcloud, int mode)
{
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 416f5aa7edd..bed10df5ace 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -21,6 +21,9 @@
* \ingroup bke
*/
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#include <stddef.h>
#include <stdio.h>
#include <string.h>
@@ -70,6 +73,7 @@
#include "BKE_curveprofile.h"
#include "BKE_duplilist.h"
#include "BKE_editmesh.h"
+#include "BKE_effect.h"
#include "BKE_fcurve.h"
#include "BKE_freestyle.h"
#include "BKE_gpencil.h"
@@ -87,10 +91,10 @@
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_paint.h"
+#include "BKE_pointcache.h"
#include "BKE_rigidbody.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
-#include "BKE_sequencer.h"
#include "BKE_sound.h"
#include "BKE_unit.h"
#include "BKE_workspace.h"
@@ -103,6 +107,10 @@
#include "RE_engine.h"
+#include "SEQ_sequencer.h"
+
+#include "BLO_read_write.h"
+
#include "engines/eevee/eevee_lightcache.h"
#include "PIL_time.h"
@@ -454,53 +462,216 @@ static void scene_foreach_rigidbodyworldSceneLooper(struct RigidBodyWorld *UNUSE
BKE_lib_query_foreachid_process(data, id_pointer, cb_flag);
}
-static void scene_foreach_paint(LibraryForeachIDData *data, Paint *paint)
-{
- BKE_LIB_FOREACHID_PROCESS(data, paint->brush, IDWALK_CB_USER);
- for (int i = 0; i < paint->tool_slots_len; i++) {
- BKE_LIB_FOREACHID_PROCESS(data, paint->tool_slots[i].brush, IDWALK_CB_USER);
+/**
+ * This code is shared by both the regular `foreach_id` looper, and the code trying to restore or
+ * preserve ID pointers like brushes across undoes.
+ */
+typedef enum eSceneForeachUndoPreserveProcess {
+ /* Undo when preserving tool-settings from old scene, we also want to try to preserve that ID
+ * pointer from its old scene's value. */
+ SCENE_FOREACH_UNDO_RESTORE,
+ /* Undo when preserving tool-settings from old scene, we want to keep the new value of that ID
+ * pointer. */
+ SCENE_FOREACH_UNDO_NO_RESTORE,
+} eSceneForeachUndoPreserveProcess;
+
+static void scene_foreach_toolsettings_id_pointer_process(
+ ID **id_p,
+ const eSceneForeachUndoPreserveProcess action,
+ BlendLibReader *reader,
+ ID **id_old_p,
+ const uint cb_flag)
+{
+ switch (action) {
+ case SCENE_FOREACH_UNDO_RESTORE: {
+ ID *id_old = *id_old_p;
+ /* Old data has not been remapped to new values of the pointers, if we want to keep the old
+ * pointer here we need its new address. */
+ ID *id_old_new = id_old != NULL ? BLO_read_get_new_id_address(reader, id_old->lib, id_old) :
+ NULL;
+ if (id_old_new != NULL) {
+ BLI_assert(ELEM(id_old, id_old_new, id_old_new->orig_id));
+ *id_old_p = id_old_new;
+ if (cb_flag & IDWALK_CB_USER) {
+ id_us_plus_no_lib(id_old_new);
+ id_us_min(id_old);
+ }
+ break;
+ }
+ /* We failed to find a new valid pointer for the previous ID, just keep the current one as
+ * if we had been under SCENE_FOREACH_UNDO_NO_RESTORE case. */
+ SWAP(ID *, *id_p, *id_old_p);
+ break;
+ }
+ case SCENE_FOREACH_UNDO_NO_RESTORE:
+ /* Counteract the swap of the whole ToolSettings container struct. */
+ SWAP(ID *, *id_p, *id_old_p);
+ break;
}
- BKE_LIB_FOREACHID_PROCESS(data, paint->palette, IDWALK_CB_USER);
}
-static void scene_foreach_toolsettings(LibraryForeachIDData *data, ToolSettings *toolsett)
-{
- BKE_LIB_FOREACHID_PROCESS(data, toolsett->particle.scene, IDWALK_CB_NOP);
- BKE_LIB_FOREACHID_PROCESS(data, toolsett->particle.object, IDWALK_CB_NOP);
- BKE_LIB_FOREACHID_PROCESS(data, toolsett->particle.shape_object, IDWALK_CB_NOP);
-
- scene_foreach_paint(data, &toolsett->imapaint.paint);
- BKE_LIB_FOREACHID_PROCESS(data, toolsett->imapaint.stencil, IDWALK_CB_USER);
- BKE_LIB_FOREACHID_PROCESS(data, toolsett->imapaint.clone, IDWALK_CB_USER);
- BKE_LIB_FOREACHID_PROCESS(data, toolsett->imapaint.canvas, IDWALK_CB_USER);
+#define BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS( \
+ __data, __id, __do_undo_restore, __action, __reader, __id_old, __cb_flag) \
+ { \
+ if (__do_undo_restore) { \
+ scene_foreach_toolsettings_id_pointer_process( \
+ (ID **)&(__id), __action, __reader, (ID **)&(__id_old), __cb_flag); \
+ } \
+ else { \
+ BKE_LIB_FOREACHID_PROCESS(__data, __id, __cb_flag); \
+ } \
+ } \
+ (void)0
+
+static void scene_foreach_paint(LibraryForeachIDData *data,
+ Paint *paint,
+ const bool do_undo_restore,
+ BlendLibReader *reader,
+ Paint *paint_old)
+{
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS(data,
+ paint->brush,
+ do_undo_restore,
+ SCENE_FOREACH_UNDO_RESTORE,
+ reader,
+ paint_old->brush,
+ IDWALK_CB_USER);
+ for (int i = 0; i < paint_old->tool_slots_len; i++) {
+ /* This is a bit tricky.
+ * - In case we do not do `undo_restore`, `paint` and `paint_old` pointers are the same, so
+ * this is equivalent to simply looping over slots from `paint`.
+ * - In case we do `undo_restore`, we only want to consider the slots from the old one, since
+ * those are the one we keep in the end.
+ * + In case the new data has less valid slots, we feed in a dummy NULL pointer.
+ * + In case the new data has more valid slots, the extra ones are ignored.
+ */
+ Brush *brush_tmp = NULL;
+ Brush **brush_p = i < paint->tool_slots_len ? &paint->tool_slots[i].brush : &brush_tmp;
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS(data,
+ *brush_p,
+ do_undo_restore,
+ SCENE_FOREACH_UNDO_RESTORE,
+ reader,
+ paint_old->brush,
+ IDWALK_CB_USER);
+ }
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS(data,
+ paint->palette,
+ do_undo_restore,
+ SCENE_FOREACH_UNDO_RESTORE,
+ reader,
+ paint_old->palette,
+ IDWALK_CB_USER);
+}
+
+static void scene_foreach_toolsettings(LibraryForeachIDData *data,
+ ToolSettings *toolsett,
+ const bool do_undo_restore,
+ BlendLibReader *reader,
+ ToolSettings *toolsett_old)
+{
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS(data,
+ toolsett->particle.scene,
+ do_undo_restore,
+ SCENE_FOREACH_UNDO_NO_RESTORE,
+ reader,
+ toolsett_old->particle.scene,
+ IDWALK_CB_NOP);
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS(data,
+ toolsett->particle.object,
+ do_undo_restore,
+ SCENE_FOREACH_UNDO_NO_RESTORE,
+ reader,
+ toolsett_old->particle.object,
+ IDWALK_CB_NOP);
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS(data,
+ toolsett->particle.shape_object,
+ do_undo_restore,
+ SCENE_FOREACH_UNDO_NO_RESTORE,
+ reader,
+ toolsett_old->particle.shape_object,
+ IDWALK_CB_NOP);
+
+ scene_foreach_paint(
+ data, &toolsett->imapaint.paint, do_undo_restore, reader, &toolsett_old->imapaint.paint);
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS(data,
+ toolsett->imapaint.stencil,
+ do_undo_restore,
+ SCENE_FOREACH_UNDO_RESTORE,
+ reader,
+ toolsett_old->imapaint.stencil,
+ IDWALK_CB_USER);
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS(data,
+ toolsett->imapaint.clone,
+ do_undo_restore,
+ SCENE_FOREACH_UNDO_RESTORE,
+ reader,
+ toolsett_old->imapaint.clone,
+ IDWALK_CB_USER);
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS(data,
+ toolsett->imapaint.canvas,
+ do_undo_restore,
+ SCENE_FOREACH_UNDO_RESTORE,
+ reader,
+ toolsett_old->imapaint.canvas,
+ IDWALK_CB_USER);
if (toolsett->vpaint) {
- scene_foreach_paint(data, &toolsett->vpaint->paint);
+ scene_foreach_paint(
+ data, &toolsett->vpaint->paint, do_undo_restore, reader, &toolsett_old->vpaint->paint);
}
if (toolsett->wpaint) {
- scene_foreach_paint(data, &toolsett->wpaint->paint);
+ scene_foreach_paint(
+ data, &toolsett->wpaint->paint, do_undo_restore, reader, &toolsett_old->wpaint->paint);
}
if (toolsett->sculpt) {
- scene_foreach_paint(data, &toolsett->sculpt->paint);
- BKE_LIB_FOREACHID_PROCESS(data, toolsett->sculpt->gravity_object, IDWALK_CB_NOP);
+ scene_foreach_paint(
+ data, &toolsett->sculpt->paint, do_undo_restore, reader, &toolsett_old->sculpt->paint);
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS(data,
+ toolsett->sculpt->gravity_object,
+ do_undo_restore,
+ SCENE_FOREACH_UNDO_NO_RESTORE,
+ reader,
+ toolsett_old->sculpt->gravity_object,
+ IDWALK_CB_NOP);
}
if (toolsett->uvsculpt) {
- scene_foreach_paint(data, &toolsett->uvsculpt->paint);
+ scene_foreach_paint(
+ data, &toolsett->uvsculpt->paint, do_undo_restore, reader, &toolsett_old->uvsculpt->paint);
}
if (toolsett->gp_paint) {
- scene_foreach_paint(data, &toolsett->gp_paint->paint);
+ scene_foreach_paint(
+ data, &toolsett->gp_paint->paint, do_undo_restore, reader, &toolsett_old->gp_paint->paint);
}
if (toolsett->gp_vertexpaint) {
- scene_foreach_paint(data, &toolsett->gp_vertexpaint->paint);
+ scene_foreach_paint(data,
+ &toolsett->gp_vertexpaint->paint,
+ do_undo_restore,
+ reader,
+ &toolsett_old->gp_vertexpaint->paint);
}
if (toolsett->gp_sculptpaint) {
- scene_foreach_paint(data, &toolsett->gp_sculptpaint->paint);
+ scene_foreach_paint(data,
+ &toolsett->gp_sculptpaint->paint,
+ do_undo_restore,
+ reader,
+ &toolsett_old->gp_sculptpaint->paint);
}
if (toolsett->gp_weightpaint) {
- scene_foreach_paint(data, &toolsett->gp_weightpaint->paint);
+ scene_foreach_paint(data,
+ &toolsett->gp_weightpaint->paint,
+ do_undo_restore,
+ reader,
+ &toolsett_old->gp_weightpaint->paint);
}
- BKE_LIB_FOREACHID_PROCESS(data, toolsett->gp_sculpt.guide.reference_object, IDWALK_CB_NOP);
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS(data,
+ toolsett->gp_sculpt.guide.reference_object,
+ do_undo_restore,
+ SCENE_FOREACH_UNDO_NO_RESTORE,
+ reader,
+ toolsett_old->gp_sculpt.guide.reference_object,
+ IDWALK_CB_NOP);
}
static void scene_foreach_layer_collection(LibraryForeachIDData *data, ListBase *lb)
@@ -592,7 +763,7 @@ static void scene_foreach_id(ID *id, LibraryForeachIDData *data)
ToolSettings *toolsett = scene->toolsettings;
if (toolsett) {
- scene_foreach_toolsettings(data, toolsett);
+ scene_foreach_toolsettings(data, toolsett, false, NULL, toolsett);
}
if (scene->rigidbody_world) {
@@ -619,6 +790,889 @@ static void scene_foreach_cache(ID *id,
user_data);
}
+static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ Scene *sce = (Scene *)id;
+
+ if (BLO_write_is_undo(writer)) {
+ /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
+ /* XXX This UI data should not be stored in Scene at all... */
+ memset(&sce->cursor, 0, sizeof(sce->cursor));
+ }
+
+ /* write LibData */
+ BLO_write_id_struct(writer, Scene, id_address, &sce->id);
+ BKE_id_blend_write(writer, &sce->id);
+
+ if (sce->adt) {
+ BKE_animdata_blend_write(writer, sce->adt);
+ }
+ BKE_keyingsets_blend_write(writer, &sce->keyingsets);
+
+ /* direct data */
+ ToolSettings *tos = sce->toolsettings;
+ BLO_write_struct(writer, ToolSettings, tos);
+ if (tos->vpaint) {
+ BLO_write_struct(writer, VPaint, tos->vpaint);
+ BKE_paint_blend_write(writer, &tos->vpaint->paint);
+ }
+ if (tos->wpaint) {
+ BLO_write_struct(writer, VPaint, tos->wpaint);
+ BKE_paint_blend_write(writer, &tos->wpaint->paint);
+ }
+ if (tos->sculpt) {
+ BLO_write_struct(writer, Sculpt, tos->sculpt);
+ BKE_paint_blend_write(writer, &tos->sculpt->paint);
+ }
+ if (tos->uvsculpt) {
+ BLO_write_struct(writer, UvSculpt, tos->uvsculpt);
+ BKE_paint_blend_write(writer, &tos->uvsculpt->paint);
+ }
+ if (tos->gp_paint) {
+ BLO_write_struct(writer, GpPaint, tos->gp_paint);
+ BKE_paint_blend_write(writer, &tos->gp_paint->paint);
+ }
+ if (tos->gp_vertexpaint) {
+ BLO_write_struct(writer, GpVertexPaint, tos->gp_vertexpaint);
+ BKE_paint_blend_write(writer, &tos->gp_vertexpaint->paint);
+ }
+ if (tos->gp_sculptpaint) {
+ BLO_write_struct(writer, GpSculptPaint, tos->gp_sculptpaint);
+ BKE_paint_blend_write(writer, &tos->gp_sculptpaint->paint);
+ }
+ if (tos->gp_weightpaint) {
+ BLO_write_struct(writer, GpWeightPaint, tos->gp_weightpaint);
+ BKE_paint_blend_write(writer, &tos->gp_weightpaint->paint);
+ }
+ /* write grease-pencil custom ipo curve to file */
+ if (tos->gp_interpolate.custom_ipo) {
+ BKE_curvemapping_blend_write(writer, tos->gp_interpolate.custom_ipo);
+ }
+ /* write grease-pencil multiframe falloff curve to file */
+ if (tos->gp_sculpt.cur_falloff) {
+ BKE_curvemapping_blend_write(writer, tos->gp_sculpt.cur_falloff);
+ }
+ /* write grease-pencil primitive curve to file */
+ if (tos->gp_sculpt.cur_primitive) {
+ BKE_curvemapping_blend_write(writer, tos->gp_sculpt.cur_primitive);
+ }
+ /* Write the curve profile to the file. */
+ if (tos->custom_bevel_profile_preset) {
+ BKE_curveprofile_blend_write(writer, tos->custom_bevel_profile_preset);
+ }
+
+ BKE_paint_blend_write(writer, &tos->imapaint.paint);
+
+ Editing *ed = sce->ed;
+ if (ed) {
+ Sequence *seq;
+
+ BLO_write_struct(writer, Editing, ed);
+
+ /* reset write flags too */
+
+ SEQ_ALL_BEGIN (ed, seq) {
+ if (seq->strip) {
+ seq->strip->done = false;
+ }
+ BLO_write_struct(writer, Sequence, seq);
+ }
+ SEQ_ALL_END;
+
+ SEQ_ALL_BEGIN (ed, seq) {
+ if (seq->strip && seq->strip->done == 0) {
+ /* write strip with 'done' at 0 because readfile */
+
+ if (seq->effectdata) {
+ switch (seq->type) {
+ case SEQ_TYPE_COLOR:
+ BLO_write_struct(writer, SolidColorVars, seq->effectdata);
+ break;
+ case SEQ_TYPE_SPEED:
+ BLO_write_struct(writer, SpeedControlVars, seq->effectdata);
+ break;
+ case SEQ_TYPE_WIPE:
+ BLO_write_struct(writer, WipeVars, seq->effectdata);
+ break;
+ case SEQ_TYPE_GLOW:
+ BLO_write_struct(writer, GlowVars, seq->effectdata);
+ break;
+ case SEQ_TYPE_TRANSFORM:
+ BLO_write_struct(writer, TransformVars, seq->effectdata);
+ break;
+ case SEQ_TYPE_GAUSSIAN_BLUR:
+ BLO_write_struct(writer, GaussianBlurVars, seq->effectdata);
+ break;
+ case SEQ_TYPE_TEXT:
+ BLO_write_struct(writer, TextVars, seq->effectdata);
+ break;
+ case SEQ_TYPE_COLORMIX:
+ BLO_write_struct(writer, ColorMixVars, seq->effectdata);
+ break;
+ }
+ }
+
+ BLO_write_struct(writer, Stereo3dFormat, seq->stereo3d_format);
+
+ Strip *strip = seq->strip;
+ BLO_write_struct(writer, Strip, strip);
+ if (strip->crop) {
+ BLO_write_struct(writer, StripCrop, strip->crop);
+ }
+ if (strip->transform) {
+ BLO_write_struct(writer, StripTransform, strip->transform);
+ }
+ if (strip->proxy) {
+ BLO_write_struct(writer, StripProxy, strip->proxy);
+ }
+ if (seq->type == SEQ_TYPE_IMAGE) {
+ BLO_write_struct_array(writer,
+ StripElem,
+ MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem),
+ strip->stripdata);
+ }
+ else if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
+ BLO_write_struct(writer, StripElem, strip->stripdata);
+ }
+
+ strip->done = true;
+ }
+
+ if (seq->prop) {
+ IDP_BlendWrite(writer, seq->prop);
+ }
+
+ BKE_sequence_modifier_blend_write(writer, &seq->modifiers);
+ }
+ SEQ_ALL_END;
+
+ /* new; meta stack too, even when its nasty restore code */
+ LISTBASE_FOREACH (MetaStack *, ms, &ed->metastack) {
+ BLO_write_struct(writer, MetaStack, ms);
+ }
+ }
+
+ if (sce->r.avicodecdata) {
+ BLO_write_struct(writer, AviCodecData, sce->r.avicodecdata);
+ if (sce->r.avicodecdata->lpFormat) {
+ BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat);
+ }
+ if (sce->r.avicodecdata->lpParms) {
+ BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms);
+ }
+ }
+ if (sce->r.ffcodecdata.properties) {
+ IDP_BlendWrite(writer, sce->r.ffcodecdata.properties);
+ }
+
+ /* writing dynamic list of TimeMarkers to the blend file */
+ LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
+ BLO_write_struct(writer, TimeMarker, marker);
+
+ if (marker->prop != NULL) {
+ IDP_BlendWrite(writer, marker->prop);
+ }
+ }
+
+ /* writing dynamic list of TransformOrientations to the blend file */
+ LISTBASE_FOREACH (TransformOrientation *, ts, &sce->transform_spaces) {
+ BLO_write_struct(writer, TransformOrientation, ts);
+ }
+
+ /* writing MultiView to the blend file */
+ LISTBASE_FOREACH (SceneRenderView *, srv, &sce->r.views) {
+ BLO_write_struct(writer, SceneRenderView, srv);
+ }
+
+ if (sce->nodetree) {
+ BLO_write_struct(writer, bNodeTree, sce->nodetree);
+ ntreeBlendWrite(writer, sce->nodetree);
+ }
+
+ BKE_color_managed_view_settings_blend_write(writer, &sce->view_settings);
+
+ /* writing RigidBodyWorld data to the blend file */
+ if (sce->rigidbody_world) {
+ /* Set deprecated pointers to prevent crashes of older Blenders */
+ sce->rigidbody_world->pointcache = sce->rigidbody_world->shared->pointcache;
+ sce->rigidbody_world->ptcaches = sce->rigidbody_world->shared->ptcaches;
+ BLO_write_struct(writer, RigidBodyWorld, sce->rigidbody_world);
+
+ BLO_write_struct(writer, RigidBodyWorld_Shared, sce->rigidbody_world->shared);
+ BLO_write_struct(writer, EffectorWeights, sce->rigidbody_world->effector_weights);
+ BKE_ptcache_blend_write(writer, &(sce->rigidbody_world->shared->ptcaches));
+ }
+
+ BKE_previewimg_blend_write(writer, sce->preview);
+ BKE_curvemapping_curves_blend_write(writer, &sce->r.mblur_shutter_curve);
+
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
+ BKE_view_layer_blend_write(writer, view_layer);
+ }
+
+ if (sce->master_collection) {
+ BLO_write_struct(writer, Collection, sce->master_collection);
+ BKE_collection_blend_write_nolib(writer, sce->master_collection);
+ }
+
+ /* Eevee Lightcache */
+ if (sce->eevee.light_cache_data && !BLO_write_is_undo(writer)) {
+ BLO_write_struct(writer, LightCache, sce->eevee.light_cache_data);
+ EEVEE_lightcache_blend_write(writer, sce->eevee.light_cache_data);
+ }
+
+ BKE_screen_view3d_shading_blend_write(writer, &sce->display.shading);
+
+ /* Freed on doversion. */
+ BLI_assert(sce->layer_properties == NULL);
+}
+
+static void direct_link_paint_helper(BlendDataReader *reader, const Scene *scene, Paint **paint)
+{
+ /* TODO. is this needed */
+ BLO_read_data_address(reader, paint);
+
+ if (*paint) {
+ BKE_paint_blend_read_data(reader, scene, *paint);
+ }
+}
+
+static void link_recurs_seq(BlendDataReader *reader, ListBase *lb)
+{
+ BLO_read_list(reader, lb);
+
+ LISTBASE_FOREACH (Sequence *, seq, lb) {
+ if (seq->seqbase.first) {
+ link_recurs_seq(reader, &seq->seqbase);
+ }
+ }
+}
+
+static void scene_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ Scene *sce = (Scene *)id;
+
+ sce->depsgraph_hash = NULL;
+ sce->fps_info = NULL;
+
+ memset(&sce->customdata_mask, 0, sizeof(sce->customdata_mask));
+ memset(&sce->customdata_mask_modal, 0, sizeof(sce->customdata_mask_modal));
+
+ BKE_sound_reset_scene_runtime(sce);
+
+ /* set users to one by default, not in lib-link, this will increase it for compo nodes */
+ id_us_ensure_real(&sce->id);
+
+ BLO_read_list(reader, &(sce->base));
+
+ BLO_read_data_address(reader, &sce->adt);
+ BKE_animdata_blend_read_data(reader, sce->adt);
+
+ BLO_read_list(reader, &sce->keyingsets);
+ BKE_keyingsets_blend_read_data(reader, &sce->keyingsets);
+
+ BLO_read_data_address(reader, &sce->basact);
+
+ BLO_read_data_address(reader, &sce->toolsettings);
+ if (sce->toolsettings) {
+
+ /* Reset last_location and last_hit, so they are not remembered across sessions. In some files
+ * these are also NaN, which could lead to crashes in painting. */
+ struct UnifiedPaintSettings *ups = &sce->toolsettings->unified_paint_settings;
+ zero_v3(ups->last_location);
+ ups->last_hit = 0;
+
+ direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->sculpt);
+ direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->vpaint);
+ direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->wpaint);
+ direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->uvsculpt);
+ direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_paint);
+ direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_vertexpaint);
+ direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_sculptpaint);
+ direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_weightpaint);
+
+ BKE_paint_blend_read_data(reader, sce, &sce->toolsettings->imapaint.paint);
+
+ sce->toolsettings->particle.paintcursor = NULL;
+ sce->toolsettings->particle.scene = NULL;
+ sce->toolsettings->particle.object = NULL;
+ sce->toolsettings->gp_sculpt.paintcursor = NULL;
+
+ /* relink grease pencil interpolation curves */
+ BLO_read_data_address(reader, &sce->toolsettings->gp_interpolate.custom_ipo);
+ if (sce->toolsettings->gp_interpolate.custom_ipo) {
+ BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_interpolate.custom_ipo);
+ }
+ /* relink grease pencil multiframe falloff curve */
+ BLO_read_data_address(reader, &sce->toolsettings->gp_sculpt.cur_falloff);
+ if (sce->toolsettings->gp_sculpt.cur_falloff) {
+ BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_sculpt.cur_falloff);
+ }
+ /* relink grease pencil primitive curve */
+ BLO_read_data_address(reader, &sce->toolsettings->gp_sculpt.cur_primitive);
+ if (sce->toolsettings->gp_sculpt.cur_primitive) {
+ BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_sculpt.cur_primitive);
+ }
+
+ /* Relink toolsettings curve profile */
+ BLO_read_data_address(reader, &sce->toolsettings->custom_bevel_profile_preset);
+ if (sce->toolsettings->custom_bevel_profile_preset) {
+ BKE_curveprofile_blend_read(reader, sce->toolsettings->custom_bevel_profile_preset);
+ }
+ }
+
+ if (sce->ed) {
+ ListBase *old_seqbasep = &sce->ed->seqbase;
+
+ BLO_read_data_address(reader, &sce->ed);
+ Editing *ed = sce->ed;
+
+ BLO_read_data_address(reader, &ed->act_seq);
+ ed->cache = NULL;
+ ed->prefetch_job = NULL;
+
+ /* recursive link sequences, lb will be correctly initialized */
+ link_recurs_seq(reader, &ed->seqbase);
+
+ Sequence *seq;
+ SEQ_ALL_BEGIN (ed, seq) {
+ /* Do as early as possible, so that other parts of reading can rely on valid session UUID. */
+ BKE_sequence_session_uuid_generate(seq);
+
+ BLO_read_data_address(reader, &seq->seq1);
+ BLO_read_data_address(reader, &seq->seq2);
+ BLO_read_data_address(reader, &seq->seq3);
+
+ /* a patch: after introduction of effects with 3 input strips */
+ if (seq->seq3 == NULL) {
+ seq->seq3 = seq->seq2;
+ }
+
+ BLO_read_data_address(reader, &seq->effectdata);
+ BLO_read_data_address(reader, &seq->stereo3d_format);
+
+ if (seq->type & SEQ_TYPE_EFFECT) {
+ seq->flag |= SEQ_EFFECT_NOT_LOADED;
+ }
+
+ if (seq->type == SEQ_TYPE_SPEED) {
+ SpeedControlVars *s = seq->effectdata;
+ s->frameMap = NULL;
+ }
+
+ if (seq->type == SEQ_TYPE_TEXT) {
+ TextVars *t = seq->effectdata;
+ t->text_blf_id = SEQ_FONT_NOT_LOADED;
+ }
+
+ BLO_read_data_address(reader, &seq->prop);
+ IDP_BlendDataRead(reader, &seq->prop);
+
+ BLO_read_data_address(reader, &seq->strip);
+ if (seq->strip && seq->strip->done == 0) {
+ seq->strip->done = true;
+
+ if (ELEM(seq->type,
+ SEQ_TYPE_IMAGE,
+ SEQ_TYPE_MOVIE,
+ SEQ_TYPE_SOUND_RAM,
+ SEQ_TYPE_SOUND_HD)) {
+ BLO_read_data_address(reader, &seq->strip->stripdata);
+ }
+ else {
+ seq->strip->stripdata = NULL;
+ }
+ BLO_read_data_address(reader, &seq->strip->crop);
+ BLO_read_data_address(reader, &seq->strip->transform);
+ BLO_read_data_address(reader, &seq->strip->proxy);
+ if (seq->strip->proxy) {
+ seq->strip->proxy->anim = NULL;
+ }
+ else if (seq->flag & SEQ_USE_PROXY) {
+ SEQ_proxy_set(seq, true);
+ }
+
+ /* need to load color balance to it could be converted to modifier */
+ BLO_read_data_address(reader, &seq->strip->color_balance);
+ }
+
+ BKE_sequence_modifier_blend_read_data(reader, &seq->modifiers);
+ }
+ SEQ_ALL_END;
+
+ /* link metastack, slight abuse of structs here,
+ * have to restore pointer to internal part in struct */
+ {
+ Sequence temp;
+ void *poin;
+ intptr_t offset;
+
+ offset = ((intptr_t) & (temp.seqbase)) - ((intptr_t)&temp);
+
+ /* root pointer */
+ if (ed->seqbasep == old_seqbasep) {
+ ed->seqbasep = &ed->seqbase;
+ }
+ else {
+ poin = POINTER_OFFSET(ed->seqbasep, -offset);
+
+ poin = BLO_read_get_new_data_address(reader, poin);
+
+ if (poin) {
+ ed->seqbasep = (ListBase *)POINTER_OFFSET(poin, offset);
+ }
+ else {
+ ed->seqbasep = &ed->seqbase;
+ }
+ }
+ /* stack */
+ BLO_read_list(reader, &(ed->metastack));
+
+ LISTBASE_FOREACH (MetaStack *, ms, &ed->metastack) {
+ BLO_read_data_address(reader, &ms->parseq);
+
+ if (ms->oldbasep == old_seqbasep) {
+ ms->oldbasep = &ed->seqbase;
+ }
+ else {
+ poin = POINTER_OFFSET(ms->oldbasep, -offset);
+ poin = BLO_read_get_new_data_address(reader, poin);
+ if (poin) {
+ ms->oldbasep = (ListBase *)POINTER_OFFSET(poin, offset);
+ }
+ else {
+ ms->oldbasep = &ed->seqbase;
+ }
+ }
+ }
+ }
+ }
+
+#ifdef DURIAN_CAMERA_SWITCH
+ /* Runtime */
+ sce->r.mode &= ~R_NO_CAMERA_SWITCH;
+#endif
+
+ BLO_read_data_address(reader, &sce->r.avicodecdata);
+ if (sce->r.avicodecdata) {
+ BLO_read_data_address(reader, &sce->r.avicodecdata->lpFormat);
+ BLO_read_data_address(reader, &sce->r.avicodecdata->lpParms);
+ }
+ if (sce->r.ffcodecdata.properties) {
+ BLO_read_data_address(reader, &sce->r.ffcodecdata.properties);
+ IDP_BlendDataRead(reader, &sce->r.ffcodecdata.properties);
+ }
+
+ BLO_read_list(reader, &(sce->markers));
+ LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
+ BLO_read_data_address(reader, &marker->prop);
+ IDP_BlendDataRead(reader, &marker->prop);
+ }
+
+ BLO_read_list(reader, &(sce->transform_spaces));
+ BLO_read_list(reader, &(sce->r.layers));
+ BLO_read_list(reader, &(sce->r.views));
+
+ LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
+ BLO_read_data_address(reader, &srl->prop);
+ IDP_BlendDataRead(reader, &srl->prop);
+ BLO_read_list(reader, &(srl->freestyleConfig.modules));
+ BLO_read_list(reader, &(srl->freestyleConfig.linesets));
+ }
+
+ BKE_color_managed_view_settings_blend_read_data(reader, &sce->view_settings);
+
+ BLO_read_data_address(reader, &sce->rigidbody_world);
+ RigidBodyWorld *rbw = sce->rigidbody_world;
+ if (rbw) {
+ BLO_read_data_address(reader, &rbw->shared);
+
+ if (rbw->shared == NULL) {
+ /* Link deprecated caches if they exist, so we can use them for versioning.
+ * We should only do this when rbw->shared == NULL, because those pointers
+ * are always set (for compatibility with older Blenders). We mustn't link
+ * the same pointcache twice. */
+ BKE_ptcache_blend_read_data(reader, &rbw->ptcaches, &rbw->pointcache, false);
+
+ /* make sure simulation starts from the beginning after loading file */
+ if (rbw->pointcache) {
+ rbw->ltime = (float)rbw->pointcache->startframe;
+ }
+ }
+ else {
+ /* must nullify the reference to physics sim object, since it no-longer exist
+ * (and will need to be recalculated)
+ */
+ rbw->shared->physics_world = NULL;
+
+ /* link caches */
+ BKE_ptcache_blend_read_data(reader, &rbw->shared->ptcaches, &rbw->shared->pointcache, false);
+
+ /* make sure simulation starts from the beginning after loading file */
+ if (rbw->shared->pointcache) {
+ rbw->ltime = (float)rbw->shared->pointcache->startframe;
+ }
+ }
+ rbw->objects = NULL;
+ rbw->numbodies = 0;
+
+ /* set effector weights */
+ BLO_read_data_address(reader, &rbw->effector_weights);
+ if (!rbw->effector_weights) {
+ rbw->effector_weights = BKE_effector_add_weights(NULL);
+ }
+ }
+
+ BLO_read_data_address(reader, &sce->preview);
+ BKE_previewimg_blend_read(reader, sce->preview);
+
+ BKE_curvemapping_blend_read(reader, &sce->r.mblur_shutter_curve);
+
+#ifdef USE_COLLECTION_COMPAT_28
+ /* this runs before the very first doversion */
+ if (sce->collection) {
+ BLO_read_data_address(reader, &sce->collection);
+ BKE_collection_compat_blend_read_data(reader, sce->collection);
+ }
+#endif
+
+ /* insert into global old-new map for reading without UI (link_global accesses it again) */
+ BLO_read_glob_list(reader, &sce->view_layers);
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
+ BKE_view_layer_blend_read_data(reader, view_layer);
+ }
+
+ if (BLO_read_data_is_undo(reader)) {
+ /* If it's undo do nothing here, caches are handled by higher-level generic calling code. */
+ }
+ else {
+ /* else try to read the cache from file. */
+ BLO_read_data_address(reader, &sce->eevee.light_cache_data);
+ if (sce->eevee.light_cache_data) {
+ EEVEE_lightcache_blend_read_data(reader, sce->eevee.light_cache_data);
+ }
+ }
+ EEVEE_lightcache_info_update(&sce->eevee);
+
+ BKE_screen_view3d_shading_blend_read_data(reader, &sce->display.shading);
+
+ BLO_read_data_address(reader, &sce->layer_properties);
+ IDP_BlendDataRead(reader, &sce->layer_properties);
+}
+
+/* patch for missing scene IDs, can't be in do-versions */
+static void composite_patch(bNodeTree *ntree, Scene *scene)
+{
+
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
+ if (node->id == NULL && node->type == CMP_NODE_R_LAYERS) {
+ node->id = &scene->id;
+ }
+ }
+}
+
+static void scene_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+ Scene *sce = (Scene *)id;
+
+ BKE_keyingsets_blend_read_lib(reader, &sce->id, &sce->keyingsets);
+
+ BLO_read_id_address(reader, sce->id.lib, &sce->camera);
+ BLO_read_id_address(reader, sce->id.lib, &sce->world);
+ BLO_read_id_address(reader, sce->id.lib, &sce->set);
+ BLO_read_id_address(reader, sce->id.lib, &sce->gpd);
+
+ BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->imapaint.paint);
+ if (sce->toolsettings->sculpt) {
+ BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->sculpt->paint);
+ }
+ if (sce->toolsettings->vpaint) {
+ BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->vpaint->paint);
+ }
+ if (sce->toolsettings->wpaint) {
+ BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->wpaint->paint);
+ }
+ if (sce->toolsettings->uvsculpt) {
+ BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->uvsculpt->paint);
+ }
+ if (sce->toolsettings->gp_paint) {
+ BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->gp_paint->paint);
+ }
+ if (sce->toolsettings->gp_vertexpaint) {
+ BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->gp_vertexpaint->paint);
+ }
+ if (sce->toolsettings->gp_sculptpaint) {
+ BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->gp_sculptpaint->paint);
+ }
+ if (sce->toolsettings->gp_weightpaint) {
+ BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->gp_weightpaint->paint);
+ }
+
+ if (sce->toolsettings->sculpt) {
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->sculpt->gravity_object);
+ }
+
+ if (sce->toolsettings->imapaint.stencil) {
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.stencil);
+ }
+
+ if (sce->toolsettings->imapaint.clone) {
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.clone);
+ }
+
+ if (sce->toolsettings->imapaint.canvas) {
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.canvas);
+ }
+
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->particle.shape_object);
+
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->gp_sculpt.guide.reference_object);
+
+ LISTBASE_FOREACH_MUTABLE (Base *, base_legacy, &sce->base) {
+ BLO_read_id_address(reader, sce->id.lib, &base_legacy->object);
+
+ if (base_legacy->object == NULL) {
+ BLO_reportf_wrap(BLO_read_lib_reports(reader),
+ RPT_WARNING,
+ TIP_("LIB: object lost from scene: '%s'"),
+ sce->id.name + 2);
+ BLI_remlink(&sce->base, base_legacy);
+ if (base_legacy == sce->basact) {
+ sce->basact = NULL;
+ }
+ MEM_freeN(base_legacy);
+ }
+ }
+
+ Sequence *seq;
+ SEQ_ALL_BEGIN (sce->ed, seq) {
+ IDP_BlendReadLib(reader, seq->prop);
+
+ if (seq->ipo) {
+ BLO_read_id_address(
+ reader, sce->id.lib, &seq->ipo); /* XXX deprecated - old animation system */
+ }
+ seq->scene_sound = NULL;
+ if (seq->scene) {
+ BLO_read_id_address(reader, sce->id.lib, &seq->scene);
+ seq->scene_sound = NULL;
+ }
+ if (seq->clip) {
+ BLO_read_id_address(reader, sce->id.lib, &seq->clip);
+ }
+ if (seq->mask) {
+ BLO_read_id_address(reader, sce->id.lib, &seq->mask);
+ }
+ if (seq->scene_camera) {
+ BLO_read_id_address(reader, sce->id.lib, &seq->scene_camera);
+ }
+ if (seq->sound) {
+ seq->scene_sound = NULL;
+ if (seq->type == SEQ_TYPE_SOUND_HD) {
+ seq->type = SEQ_TYPE_SOUND_RAM;
+ }
+ else {
+ BLO_read_id_address(reader, sce->id.lib, &seq->sound);
+ }
+ if (seq->sound) {
+ id_us_plus_no_lib((ID *)seq->sound);
+ seq->scene_sound = NULL;
+ }
+ }
+ if (seq->type == SEQ_TYPE_TEXT) {
+ TextVars *t = seq->effectdata;
+ BLO_read_id_address(reader, sce->id.lib, &t->text_font);
+ }
+ BLI_listbase_clear(&seq->anims);
+
+ BKE_sequence_modifier_blend_read_lib(reader, sce, &seq->modifiers);
+ }
+ SEQ_ALL_END;
+
+ LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
+ IDP_BlendReadLib(reader, marker->prop);
+
+ if (marker->camera) {
+ BLO_read_id_address(reader, sce->id.lib, &marker->camera);
+ }
+ }
+
+ /* rigidbody world relies on its linked collections */
+ if (sce->rigidbody_world) {
+ RigidBodyWorld *rbw = sce->rigidbody_world;
+ if (rbw->group) {
+ BLO_read_id_address(reader, sce->id.lib, &rbw->group);
+ }
+ if (rbw->constraints) {
+ BLO_read_id_address(reader, sce->id.lib, &rbw->constraints);
+ }
+ if (rbw->effector_weights) {
+ BLO_read_id_address(reader, sce->id.lib, &rbw->effector_weights->group);
+ }
+ }
+
+ if (sce->nodetree) {
+ composite_patch(sce->nodetree, sce);
+ }
+
+ LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
+ BLO_read_id_address(reader, sce->id.lib, &srl->mat_override);
+ LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &srl->freestyleConfig.modules) {
+ BLO_read_id_address(reader, sce->id.lib, &fmc->script);
+ }
+ LISTBASE_FOREACH (FreestyleLineSet *, fls, &srl->freestyleConfig.linesets) {
+ BLO_read_id_address(reader, sce->id.lib, &fls->linestyle);
+ BLO_read_id_address(reader, sce->id.lib, &fls->group);
+ }
+ }
+ /* Motion Tracking */
+ BLO_read_id_address(reader, sce->id.lib, &sce->clip);
+
+#ifdef USE_COLLECTION_COMPAT_28
+ if (sce->collection) {
+ BKE_collection_compat_blend_read_lib(reader, sce->id.lib, sce->collection);
+ }
+#endif
+
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
+ BKE_view_layer_blend_read_lib(reader, sce->id.lib, view_layer);
+ }
+
+ if (sce->r.bake.cage_object) {
+ BLO_read_id_address(reader, sce->id.lib, &sce->r.bake.cage_object);
+ }
+
+#ifdef USE_SETSCENE_CHECK
+ if (sce->set != NULL) {
+ sce->flag |= SCE_READFILE_LIBLINK_NEED_SETSCENE_CHECK;
+ }
+#endif
+}
+
+static void scene_blend_read_expand(BlendExpander *expander, ID *id)
+{
+ Scene *sce = (Scene *)id;
+
+ LISTBASE_FOREACH (Base *, base_legacy, &sce->base) {
+ BLO_expand(expander, base_legacy->object);
+ }
+ BLO_expand(expander, sce->camera);
+ BLO_expand(expander, sce->world);
+
+ BKE_keyingsets_blend_read_expand(expander, &sce->keyingsets);
+
+ if (sce->set) {
+ BLO_expand(expander, sce->set);
+ }
+
+ LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
+ BLO_expand(expander, srl->mat_override);
+ LISTBASE_FOREACH (FreestyleModuleConfig *, module, &srl->freestyleConfig.modules) {
+ if (module->script) {
+ BLO_expand(expander, module->script);
+ }
+ }
+ LISTBASE_FOREACH (FreestyleLineSet *, lineset, &srl->freestyleConfig.linesets) {
+ if (lineset->group) {
+ BLO_expand(expander, lineset->group);
+ }
+ BLO_expand(expander, lineset->linestyle);
+ }
+ }
+
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
+ IDP_BlendReadExpand(expander, view_layer->id_properties);
+
+ LISTBASE_FOREACH (FreestyleModuleConfig *, module, &view_layer->freestyle_config.modules) {
+ if (module->script) {
+ BLO_expand(expander, module->script);
+ }
+ }
+
+ LISTBASE_FOREACH (FreestyleLineSet *, lineset, &view_layer->freestyle_config.linesets) {
+ if (lineset->group) {
+ BLO_expand(expander, lineset->group);
+ }
+ BLO_expand(expander, lineset->linestyle);
+ }
+ }
+
+ if (sce->gpd) {
+ BLO_expand(expander, sce->gpd);
+ }
+
+ if (sce->ed) {
+ Sequence *seq;
+
+ SEQ_ALL_BEGIN (sce->ed, seq) {
+ IDP_BlendReadExpand(expander, seq->prop);
+
+ if (seq->scene) {
+ BLO_expand(expander, seq->scene);
+ }
+ if (seq->scene_camera) {
+ BLO_expand(expander, seq->scene_camera);
+ }
+ if (seq->clip) {
+ BLO_expand(expander, seq->clip);
+ }
+ if (seq->mask) {
+ BLO_expand(expander, seq->mask);
+ }
+ if (seq->sound) {
+ BLO_expand(expander, seq->sound);
+ }
+
+ if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
+ TextVars *data = seq->effectdata;
+ BLO_expand(expander, data->text_font);
+ }
+ }
+ SEQ_ALL_END;
+ }
+
+ if (sce->rigidbody_world) {
+ BLO_expand(expander, sce->rigidbody_world->group);
+ BLO_expand(expander, sce->rigidbody_world->constraints);
+ }
+
+ LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
+ IDP_BlendReadExpand(expander, marker->prop);
+
+ if (marker->camera) {
+ BLO_expand(expander, marker->camera);
+ }
+ }
+
+ BLO_expand(expander, sce->clip);
+
+#ifdef USE_COLLECTION_COMPAT_28
+ if (sce->collection) {
+ BKE_collection_compat_blend_read_expand(expander, sce->collection);
+ }
+#endif
+
+ if (sce->r.bake.cage_object) {
+ BLO_expand(expander, sce->r.bake.cage_object);
+ }
+}
+
+static void scene_undo_preserve(BlendLibReader *reader, ID *id_new, ID *id_old)
+{
+ Scene *scene_new = (Scene *)id_new;
+ Scene *scene_old = (Scene *)id_old;
+
+ SWAP(View3DCursor, scene_old->cursor, scene_new->cursor);
+ if (scene_new->toolsettings != NULL && scene_old->toolsettings != NULL) {
+ /* First try to restore ID pointers that can be and should be preserved (like brushes or
+ * palettes), and counteract the swap of the whole ToolSettings structs below for the others
+ * (like object ones). */
+ scene_foreach_toolsettings(
+ NULL, scene_new->toolsettings, true, reader, scene_old->toolsettings);
+ SWAP(ToolSettings, *scene_old->toolsettings, *scene_new->toolsettings);
+ }
+}
+
IDTypeInfo IDType_ID_SCE = {
.id_code = ID_SCE,
.id_filter = FILTER_ID_SCE,
@@ -638,10 +1692,12 @@ IDTypeInfo IDType_ID_SCE = {
.foreach_id = scene_foreach_id,
.foreach_cache = scene_foreach_cache,
- .blend_write = NULL,
- .blend_read_data = NULL,
- .blend_read_lib = NULL,
- .blend_read_expand = NULL,
+ .blend_write = scene_blend_write,
+ .blend_read_data = scene_blend_read_data,
+ .blend_read_lib = scene_blend_read_lib,
+ .blend_read_expand = scene_blend_read_expand,
+
+ .blend_read_undo_preserve = scene_undo_preserve,
};
const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE";
@@ -1971,7 +3027,7 @@ bool BKE_scene_multiview_is_render_view_active(const RenderData *rd, const Scene
}
/* SCE_VIEWS_SETUP_BASIC */
- if (STREQ(srv->name, STEREO_LEFT_NAME) || STREQ(srv->name, STEREO_RIGHT_NAME)) {
+ if (STR_ELEM(srv->name, STEREO_LEFT_NAME, STEREO_RIGHT_NAME)) {
return true;
}
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index d9686eba29a..8662fce3dcc 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -21,6 +21,9 @@
* \ingroup bke
*/
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#ifdef WIN32
# include "BLI_winstuff.h"
#endif
@@ -49,14 +52,18 @@
#include "BLT_translation.h"
+#include "BKE_gpencil.h"
#include "BKE_icons.h"
#include "BKE_idprop.h"
#include "BKE_idtype.h"
+#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_node.h"
#include "BKE_screen.h"
#include "BKE_workspace.h"
+#include "BLO_read_write.h"
+
static void screen_free_data(ID *id)
{
bScreen *screen = (bScreen *)id;
@@ -230,6 +237,60 @@ static void screen_foreach_id(ID *id, LibraryForeachIDData *data)
}
}
+static void screen_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ bScreen *screen = (bScreen *)id;
+ /* Screens are reference counted, only saved if used by a workspace. */
+ if (screen->id.us > 0 || BLO_write_is_undo(writer)) {
+ /* write LibData */
+ /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
+ BLO_write_struct_at_address_with_filecode(writer, ID_SCRN, bScreen, id_address, screen);
+ BKE_id_blend_write(writer, &screen->id);
+
+ BKE_previewimg_blend_write(writer, screen->preview);
+
+ /* direct data */
+ BKE_screen_area_map_blend_write(writer, AREAMAP_FROM_SCREEN(screen));
+ }
+}
+
+/* Cannot use IDTypeInfo callback yet, because of the return value. */
+bool BKE_screen_blend_read_data(BlendDataReader *reader, bScreen *screen)
+{
+ bool success = true;
+
+ screen->regionbase.first = screen->regionbase.last = NULL;
+ screen->context = NULL;
+ screen->active_region = NULL;
+
+ BLO_read_data_address(reader, &screen->preview);
+ BKE_previewimg_blend_read(reader, screen->preview);
+
+ if (!BKE_screen_area_map_blend_read_data(reader, AREAMAP_FROM_SCREEN(screen))) {
+ printf("Error reading Screen %s... removing it.\n", screen->id.name + 2);
+ success = false;
+ }
+
+ return success;
+}
+
+/* note: file read without screens option G_FILE_NO_UI;
+ * check lib pointers in call below */
+static void screen_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+ bScreen *screen = (bScreen *)id;
+ /* deprecated, but needed for versioning (will be NULL'ed then) */
+ BLO_read_id_address(reader, screen->id.lib, &screen->scene);
+
+ screen->animtimer = NULL; /* saved in rare cases */
+ screen->tool_tip = NULL;
+ screen->scrubbing = false;
+
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ BKE_screen_area_blend_read_lib(reader, &screen->id, area);
+ }
+}
+
IDTypeInfo IDType_ID_SCR = {
.id_code = ID_SCR,
.id_filter = 0,
@@ -247,10 +308,13 @@ IDTypeInfo IDType_ID_SCR = {
.foreach_id = screen_foreach_id,
.foreach_cache = NULL,
- .blend_write = NULL,
+ .blend_write = screen_blend_write,
+ /* Cannot be used yet, because #direct_link_screen has a return value. */
.blend_read_data = NULL,
- .blend_read_lib = NULL,
+ .blend_read_lib = screen_blend_read_lib,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
/* ************ Spacetype/regiontype handling ************** */
@@ -312,7 +376,7 @@ SpaceType *BKE_spacetype_from_id(int spaceid)
return NULL;
}
-ARegionType *BKE_regiontype_from_id_or_first(SpaceType *st, int regionid)
+ARegionType *BKE_regiontype_from_id_or_first(const SpaceType *st, int regionid)
{
ARegionType *art;
@@ -327,7 +391,7 @@ ARegionType *BKE_regiontype_from_id_or_first(SpaceType *st, int regionid)
return st->regiontypes.first;
}
-ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
+ARegionType *BKE_regiontype_from_id(const SpaceType *st, int regionid)
{
ARegionType *art;
@@ -404,7 +468,7 @@ static void panel_list_copy(ListBase *newlb, const ListBase *lb)
}
}
-ARegion *BKE_area_region_copy(SpaceType *st, ARegion *region)
+ARegion *BKE_area_region_copy(const SpaceType *st, const ARegion *region)
{
ARegion *newar = MEM_dupallocN(region);
@@ -918,7 +982,7 @@ ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, int x, int
if (area) {
ARegion *region;
for (region = area->regionbase.first; region; region = region->next) {
- if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) {
+ if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) {
if (BLI_rcti_isect_pt(&region->winrct, x, y)) {
region_found = region;
break;
@@ -936,7 +1000,7 @@ ARegion *BKE_screen_find_region_xy(bScreen *screen, const int regiontype, int x,
{
ARegion *region_found = NULL;
LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
- if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) {
+ if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) {
if (BLI_rcti_isect_pt(&region->winrct, x, y)) {
region_found = region;
break;
@@ -973,7 +1037,7 @@ ScrArea *BKE_screen_find_big_area(bScreen *screen, const int spacetype, const sh
int size, maxsize = 0;
for (area = screen->areabase.first; area; area = area->next) {
- if ((spacetype == SPACE_TYPE_ANY) || (area->spacetype == spacetype)) {
+ if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) {
if (min <= area->winx && min <= area->winy) {
size = area->winx * area->winy;
if (size > maxsize) {
@@ -994,7 +1058,7 @@ ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap,
{
LISTBASE_FOREACH (ScrArea *, area, &areamap->areabase) {
if (BLI_rcti_isect_pt(&area->totrct, x, y)) {
- if ((spacetype == SPACE_TYPE_ANY) || (area->spacetype == spacetype)) {
+ if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) {
return area;
}
break;
@@ -1111,3 +1175,798 @@ void BKE_screen_header_alignment_reset(bScreen *screen)
}
screen->do_refresh = true;
}
+
+void BKE_screen_view3d_shading_blend_write(BlendWriter *writer, View3DShading *shading)
+{
+ if (shading->prop) {
+ IDP_BlendWrite(writer, shading->prop);
+ }
+}
+
+void BKE_screen_view3d_shading_blend_read_data(BlendDataReader *reader, View3DShading *shading)
+{
+ if (shading->prop) {
+ BLO_read_data_address(reader, &shading->prop);
+ IDP_BlendDataRead(reader, &shading->prop);
+ }
+}
+
+static void write_region(BlendWriter *writer, ARegion *region, int spacetype)
+{
+ BLO_write_struct(writer, ARegion, region);
+
+ if (region->regiondata) {
+ if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
+ return;
+ }
+
+ switch (spacetype) {
+ case SPACE_VIEW3D:
+ if (region->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d = region->regiondata;
+ BLO_write_struct(writer, RegionView3D, rv3d);
+
+ if (rv3d->localvd) {
+ BLO_write_struct(writer, RegionView3D, rv3d->localvd);
+ }
+ if (rv3d->clipbb) {
+ BLO_write_struct(writer, BoundBox, rv3d->clipbb);
+ }
+ }
+ else {
+ printf("regiondata write missing!\n");
+ }
+ break;
+ default:
+ printf("regiondata write missing!\n");
+ }
+ }
+}
+
+static void write_uilist(BlendWriter *writer, uiList *ui_list)
+{
+ BLO_write_struct(writer, uiList, ui_list);
+
+ if (ui_list->properties) {
+ IDP_BlendWrite(writer, ui_list->properties);
+ }
+}
+
+static void write_space_outliner(BlendWriter *writer, SpaceOutliner *space_outliner)
+{
+ BLI_mempool *ts = space_outliner->treestore;
+
+ if (ts) {
+ SpaceOutliner space_outliner_flat = *space_outliner;
+
+ int elems = BLI_mempool_len(ts);
+ /* linearize mempool to array */
+ TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL;
+
+ if (data) {
+ /* In this block we use the memory location of the treestore
+ * but _not_ its data, the addresses in this case are UUID's,
+ * since we can't rely on malloc giving us different values each time.
+ */
+ TreeStore ts_flat = {0};
+
+ /* we know the treestore is at least as big as a pointer,
+ * so offsetting works to give us a UUID. */
+ void *data_addr = (void *)POINTER_OFFSET(ts, sizeof(void *));
+
+ ts_flat.usedelem = elems;
+ ts_flat.totelem = elems;
+ ts_flat.data = data_addr;
+
+ BLO_write_struct(writer, SpaceOutliner, space_outliner);
+
+ BLO_write_struct_at_address(writer, TreeStore, ts, &ts_flat);
+ BLO_write_struct_array_at_address(writer, TreeStoreElem, elems, data_addr, data);
+
+ MEM_freeN(data);
+ }
+ else {
+ space_outliner_flat.treestore = NULL;
+ BLO_write_struct_at_address(writer, SpaceOutliner, space_outliner, &space_outliner_flat);
+ }
+ }
+ else {
+ BLO_write_struct(writer, SpaceOutliner, space_outliner);
+ }
+}
+
+static void write_panel_list(BlendWriter *writer, ListBase *lb)
+{
+ LISTBASE_FOREACH (Panel *, panel, lb) {
+ BLO_write_struct(writer, Panel, panel);
+ write_panel_list(writer, &panel->children);
+ }
+}
+
+static void write_area_regions(BlendWriter *writer, ScrArea *area)
+{
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
+ write_region(writer, region, area->spacetype);
+ write_panel_list(writer, &region->panels);
+
+ LISTBASE_FOREACH (PanelCategoryStack *, pc_act, &region->panels_category_active) {
+ BLO_write_struct(writer, PanelCategoryStack, pc_act);
+ }
+
+ LISTBASE_FOREACH (uiList *, ui_list, &region->ui_lists) {
+ write_uilist(writer, ui_list);
+ }
+
+ LISTBASE_FOREACH (uiPreview *, ui_preview, &region->ui_previews) {
+ BLO_write_struct(writer, uiPreview, ui_preview);
+ }
+ }
+
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
+ write_region(writer, region, sl->spacetype);
+ }
+
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ BLO_write_struct(writer, View3D, v3d);
+
+ if (v3d->localvd) {
+ BLO_write_struct(writer, View3D, v3d->localvd);
+ }
+
+ BKE_screen_view3d_shading_blend_write(writer, &v3d->shading);
+ }
+ else if (sl->spacetype == SPACE_GRAPH) {
+ SpaceGraph *sipo = (SpaceGraph *)sl;
+ ListBase tmpGhosts = sipo->runtime.ghost_curves;
+
+ /* temporarily disable ghost curves when saving */
+ BLI_listbase_clear(&sipo->runtime.ghost_curves);
+
+ BLO_write_struct(writer, SpaceGraph, sl);
+ if (sipo->ads) {
+ BLO_write_struct(writer, bDopeSheet, sipo->ads);
+ }
+
+ /* reenable ghost curves */
+ sipo->runtime.ghost_curves = tmpGhosts;
+ }
+ else if (sl->spacetype == SPACE_PROPERTIES) {
+ BLO_write_struct(writer, SpaceProperties, sl);
+ }
+ else if (sl->spacetype == SPACE_FILE) {
+ SpaceFile *sfile = (SpaceFile *)sl;
+
+ BLO_write_struct(writer, SpaceFile, sl);
+ if (sfile->params) {
+ BLO_write_struct(writer, FileSelectParams, sfile->params);
+ }
+ }
+ else if (sl->spacetype == SPACE_SEQ) {
+ BLO_write_struct(writer, SpaceSeq, sl);
+ }
+ else if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ write_space_outliner(writer, space_outliner);
+ }
+ else if (sl->spacetype == SPACE_IMAGE) {
+ BLO_write_struct(writer, SpaceImage, sl);
+ }
+ else if (sl->spacetype == SPACE_TEXT) {
+ BLO_write_struct(writer, SpaceText, sl);
+ }
+ else if (sl->spacetype == SPACE_SCRIPT) {
+ SpaceScript *scr = (SpaceScript *)sl;
+ scr->but_refs = NULL;
+ BLO_write_struct(writer, SpaceScript, sl);
+ }
+ else if (sl->spacetype == SPACE_ACTION) {
+ BLO_write_struct(writer, SpaceAction, sl);
+ }
+ else if (sl->spacetype == SPACE_NLA) {
+ SpaceNla *snla = (SpaceNla *)sl;
+
+ BLO_write_struct(writer, SpaceNla, snla);
+ if (snla->ads) {
+ BLO_write_struct(writer, bDopeSheet, snla->ads);
+ }
+ }
+ else if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+ BLO_write_struct(writer, SpaceNode, snode);
+
+ LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
+ BLO_write_struct(writer, bNodeTreePath, path);
+ }
+ }
+ else if (sl->spacetype == SPACE_CONSOLE) {
+ SpaceConsole *con = (SpaceConsole *)sl;
+
+ LISTBASE_FOREACH (ConsoleLine *, cl, &con->history) {
+ /* 'len_alloc' is invalid on write, set from 'len' on read */
+ BLO_write_struct(writer, ConsoleLine, cl);
+ BLO_write_raw(writer, (size_t)cl->len + 1, cl->line);
+ }
+ BLO_write_struct(writer, SpaceConsole, sl);
+ }
+ else if (sl->spacetype == SPACE_TOPBAR) {
+ BLO_write_struct(writer, SpaceTopBar, sl);
+ }
+ else if (sl->spacetype == SPACE_STATUSBAR) {
+ BLO_write_struct(writer, SpaceStatusBar, sl);
+ }
+ else if (sl->spacetype == SPACE_USERPREF) {
+ BLO_write_struct(writer, SpaceUserPref, sl);
+ }
+ else if (sl->spacetype == SPACE_CLIP) {
+ BLO_write_struct(writer, SpaceClip, sl);
+ }
+ else if (sl->spacetype == SPACE_INFO) {
+ BLO_write_struct(writer, SpaceInfo, sl);
+ }
+ }
+}
+
+void BKE_screen_area_map_blend_write(BlendWriter *writer, ScrAreaMap *area_map)
+{
+ BLO_write_struct_list(writer, ScrVert, &area_map->vertbase);
+ BLO_write_struct_list(writer, ScrEdge, &area_map->edgebase);
+ LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
+ area->butspacetype = area->spacetype; /* Just for compatibility, will be reset below. */
+
+ BLO_write_struct(writer, ScrArea, area);
+
+ BLO_write_struct(writer, ScrGlobalAreaData, area->global);
+
+ write_area_regions(writer, area);
+
+ area->butspacetype = SPACE_EMPTY; /* Unset again, was changed above. */
+ }
+}
+
+static void direct_link_panel_list(BlendDataReader *reader, ListBase *lb)
+{
+ BLO_read_list(reader, lb);
+
+ LISTBASE_FOREACH (Panel *, panel, lb) {
+ panel->runtime_flag = 0;
+ panel->activedata = NULL;
+ panel->type = NULL;
+ panel->runtime.custom_data_ptr = NULL;
+ direct_link_panel_list(reader, &panel->children);
+ }
+}
+
+static void direct_link_region(BlendDataReader *reader, ARegion *region, int spacetype)
+{
+ direct_link_panel_list(reader, &region->panels);
+
+ BLO_read_list(reader, &region->panels_category_active);
+
+ BLO_read_list(reader, &region->ui_lists);
+
+ /* The area's search filter is runtime only, so we need to clear the active flag on read. */
+ region->flag &= ~RGN_FLAG_SEARCH_FILTER_ACTIVE;
+
+ LISTBASE_FOREACH (uiList *, ui_list, &region->ui_lists) {
+ ui_list->type = NULL;
+ ui_list->dyn_data = NULL;
+ BLO_read_data_address(reader, &ui_list->properties);
+ IDP_BlendDataRead(reader, &ui_list->properties);
+ }
+
+ BLO_read_list(reader, &region->ui_previews);
+
+ if (spacetype == SPACE_EMPTY) {
+ /* unknown space type, don't leak regiondata */
+ region->regiondata = NULL;
+ }
+ else if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
+ /* Runtime data, don't use. */
+ region->regiondata = NULL;
+ }
+ else {
+ BLO_read_data_address(reader, &region->regiondata);
+ if (region->regiondata) {
+ if (spacetype == SPACE_VIEW3D) {
+ RegionView3D *rv3d = region->regiondata;
+
+ BLO_read_data_address(reader, &rv3d->localvd);
+ BLO_read_data_address(reader, &rv3d->clipbb);
+
+ rv3d->depths = NULL;
+ rv3d->render_engine = NULL;
+ rv3d->sms = NULL;
+ rv3d->smooth_timer = NULL;
+
+ rv3d->rflag &= ~(RV3D_NAVIGATING | RV3D_PAINTING);
+ rv3d->runtime_viewlock = 0;
+ }
+ }
+ }
+
+ region->v2d.sms = NULL;
+ region->v2d.alpha_hor = region->v2d.alpha_vert = 255; /* visible by default */
+ BLI_listbase_clear(&region->panels_category);
+ BLI_listbase_clear(&region->handlers);
+ BLI_listbase_clear(&region->uiblocks);
+ region->headerstr = NULL;
+ region->visible = 0;
+ region->type = NULL;
+ region->do_draw = 0;
+ region->gizmo_map = NULL;
+ region->regiontimer = NULL;
+ region->draw_buffer = NULL;
+ memset(&region->drawrct, 0, sizeof(region->drawrct));
+}
+
+/* for the saved 2.50 files without regiondata */
+/* and as patch for 2.48 and older */
+void BKE_screen_view3d_do_versions_250(View3D *v3d, ListBase *regions)
+{
+ LISTBASE_FOREACH (ARegion *, region, regions) {
+ if (region->regiontype == RGN_TYPE_WINDOW && region->regiondata == NULL) {
+ RegionView3D *rv3d;
+
+ rv3d = region->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch");
+ rv3d->persp = (char)v3d->persp;
+ rv3d->view = (char)v3d->view;
+ rv3d->dist = v3d->dist;
+ copy_v3_v3(rv3d->ofs, v3d->ofs);
+ copy_qt_qt(rv3d->viewquat, v3d->viewquat);
+ }
+ }
+
+ /* this was not initialized correct always */
+ if (v3d->gridsubdiv == 0) {
+ v3d->gridsubdiv = 10;
+ }
+}
+
+static void direct_link_area(BlendDataReader *reader, ScrArea *area)
+{
+ BLO_read_list(reader, &(area->spacedata));
+ BLO_read_list(reader, &(area->regionbase));
+
+ BLI_listbase_clear(&area->handlers);
+ area->type = NULL; /* spacetype callbacks */
+
+ /* Should always be unset so that rna_Area_type_get works correctly. */
+ area->butspacetype = SPACE_EMPTY;
+
+ area->region_active_win = -1;
+
+ area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE;
+
+ BLO_read_data_address(reader, &area->global);
+
+ /* if we do not have the spacetype registered we cannot
+ * free it, so don't allocate any new memory for such spacetypes. */
+ if (!BKE_spacetype_exists(area->spacetype)) {
+ /* Hint for versioning code to replace deprecated space types. */
+ area->butspacetype = area->spacetype;
+
+ area->spacetype = SPACE_EMPTY;
+ }
+
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
+ direct_link_region(reader, region, area->spacetype);
+ }
+
+ /* accident can happen when read/save new file with older version */
+ /* 2.50: we now always add spacedata for info */
+ if (area->spacedata.first == NULL) {
+ SpaceInfo *sinfo = MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
+ area->spacetype = sinfo->spacetype = SPACE_INFO;
+ BLI_addtail(&area->spacedata, sinfo);
+ }
+ /* add local view3d too */
+ else if (area->spacetype == SPACE_VIEW3D) {
+ BKE_screen_view3d_do_versions_250(area->spacedata.first, &area->regionbase);
+ }
+
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ BLO_read_list(reader, &(sl->regionbase));
+
+ /* if we do not have the spacetype registered we cannot
+ * free it, so don't allocate any new memory for such spacetypes. */
+ if (!BKE_spacetype_exists(sl->spacetype)) {
+ sl->spacetype = SPACE_EMPTY;
+ }
+
+ LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
+ direct_link_region(reader, region, sl->spacetype);
+ }
+
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+
+ v3d->flag |= V3D_INVALID_BACKBUF;
+
+ if (v3d->gpd) {
+ BLO_read_data_address(reader, &v3d->gpd);
+ BKE_gpencil_blend_read_data(reader, v3d->gpd);
+ }
+ BLO_read_data_address(reader, &v3d->localvd);
+
+ /* Runtime data */
+ v3d->runtime.properties_storage = NULL;
+ v3d->runtime.flag = 0;
+
+ /* render can be quite heavy, set to solid on load */
+ if (v3d->shading.type == OB_RENDER) {
+ v3d->shading.type = OB_SOLID;
+ }
+ v3d->shading.prev_type = OB_SOLID;
+
+ BKE_screen_view3d_shading_blend_read_data(reader, &v3d->shading);
+
+ BKE_screen_view3d_do_versions_250(v3d, &sl->regionbase);
+ }
+ else if (sl->spacetype == SPACE_GRAPH) {
+ SpaceGraph *sipo = (SpaceGraph *)sl;
+
+ BLO_read_data_address(reader, &sipo->ads);
+ BLI_listbase_clear(&sipo->runtime.ghost_curves);
+ }
+ else if (sl->spacetype == SPACE_NLA) {
+ SpaceNla *snla = (SpaceNla *)sl;
+
+ BLO_read_data_address(reader, &snla->ads);
+ }
+ else if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+
+ /* use #BLO_read_get_new_data_address_no_us and do not free old memory avoiding double
+ * frees and use of freed memory. this could happen because of a
+ * bug fixed in revision 58959 where the treestore memory address
+ * was not unique */
+ TreeStore *ts = BLO_read_get_new_data_address_no_us(reader, space_outliner->treestore);
+ space_outliner->treestore = NULL;
+ if (ts) {
+ TreeStoreElem *elems = BLO_read_get_new_data_address_no_us(reader, ts->data);
+
+ space_outliner->treestore = BLI_mempool_create(
+ sizeof(TreeStoreElem), ts->usedelem, 512, BLI_MEMPOOL_ALLOW_ITER);
+ if (ts->usedelem && elems) {
+ for (int i = 0; i < ts->usedelem; i++) {
+ TreeStoreElem *new_elem = BLI_mempool_alloc(space_outliner->treestore);
+ *new_elem = elems[i];
+ }
+ }
+ /* we only saved what was used */
+ space_outliner->storeflag |= SO_TREESTORE_CLEANUP; /* at first draw */
+ }
+ space_outliner->treehash = NULL;
+ space_outliner->tree.first = space_outliner->tree.last = NULL;
+ space_outliner->runtime = NULL;
+ }
+ else if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+
+ sima->iuser.scene = NULL;
+ sima->iuser.ok = 1;
+ sima->scopes.waveform_1 = NULL;
+ sima->scopes.waveform_2 = NULL;
+ sima->scopes.waveform_3 = NULL;
+ sima->scopes.vecscope = NULL;
+ sima->scopes.ok = 0;
+
+ /* WARNING: gpencil data is no longer stored directly in sima after 2.5
+ * so sacrifice a few old files for now to avoid crashes with new files!
+ * committed: r28002 */
+#if 0
+ sima->gpd = newdataadr(fd, sima->gpd);
+ if (sima->gpd) {
+ BKE_gpencil_blend_read_data(fd, sima->gpd);
+ }
+#endif
+ }
+ else if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+
+ if (snode->gpd) {
+ BLO_read_data_address(reader, &snode->gpd);
+ BKE_gpencil_blend_read_data(reader, snode->gpd);
+ }
+
+ BLO_read_list(reader, &snode->treepath);
+ snode->edittree = NULL;
+ snode->iofsd = NULL;
+ BLI_listbase_clear(&snode->linkdrag);
+ }
+ else if (sl->spacetype == SPACE_TEXT) {
+ SpaceText *st = (SpaceText *)sl;
+ memset(&st->runtime, 0, sizeof(st->runtime));
+ }
+ else if (sl->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+
+ /* grease pencil data is not a direct data and can't be linked from direct_link*
+ * functions, it should be linked from lib_link* functions instead
+ *
+ * otherwise it'll lead to lost grease data on open because it'll likely be
+ * read from file after all other users of grease pencil and newdataadr would
+ * simple return NULL here (sergey)
+ */
+#if 0
+ if (sseq->gpd) {
+ sseq->gpd = newdataadr(fd, sseq->gpd);
+ BKE_gpencil_blend_read_data(fd, sseq->gpd);
+ }
+#endif
+ sseq->scopes.reference_ibuf = NULL;
+ sseq->scopes.zebra_ibuf = NULL;
+ sseq->scopes.waveform_ibuf = NULL;
+ sseq->scopes.sep_waveform_ibuf = NULL;
+ sseq->scopes.vector_ibuf = NULL;
+ sseq->scopes.histogram_ibuf = NULL;
+ }
+ else if (sl->spacetype == SPACE_PROPERTIES) {
+ SpaceProperties *sbuts = (SpaceProperties *)sl;
+
+ sbuts->path = NULL;
+ sbuts->texuser = NULL;
+ sbuts->mainbo = sbuts->mainb;
+ sbuts->mainbuser = sbuts->mainb;
+ sbuts->runtime = NULL;
+ }
+ else if (sl->spacetype == SPACE_CONSOLE) {
+ SpaceConsole *sconsole = (SpaceConsole *)sl;
+
+ BLO_read_list(reader, &sconsole->scrollback);
+ BLO_read_list(reader, &sconsole->history);
+
+ /* 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*/
+ LISTBASE_FOREACH_MUTABLE (ConsoleLine *, cl, &sconsole->history) {
+ BLO_read_data_address(reader, &cl->line);
+ if (cl->line) {
+ /* the allocted length is not written, so reset here */
+ cl->len_alloc = cl->len + 1;
+ }
+ else {
+ BLI_remlink(&sconsole->history, cl);
+ MEM_freeN(cl);
+ }
+ }
+ }
+ else if (sl->spacetype == SPACE_FILE) {
+ SpaceFile *sfile = (SpaceFile *)sl;
+
+ /* this sort of info is probably irrelevant for reloading...
+ * plus, it isn't saved to files yet!
+ */
+ sfile->folders_prev = sfile->folders_next = NULL;
+ sfile->files = NULL;
+ sfile->layout = NULL;
+ sfile->op = NULL;
+ sfile->previews_timer = NULL;
+ BLO_read_data_address(reader, &sfile->params);
+ }
+ else if (sl->spacetype == SPACE_CLIP) {
+ SpaceClip *sclip = (SpaceClip *)sl;
+
+ sclip->scopes.track_search = NULL;
+ sclip->scopes.track_preview = NULL;
+ sclip->scopes.ok = 0;
+ }
+ }
+
+ BLI_listbase_clear(&area->actionzones);
+
+ BLO_read_data_address(reader, &area->v1);
+ BLO_read_data_address(reader, &area->v2);
+ BLO_read_data_address(reader, &area->v3);
+ BLO_read_data_address(reader, &area->v4);
+}
+
+/**
+ * \return false on error.
+ */
+bool BKE_screen_area_map_blend_read_data(BlendDataReader *reader, ScrAreaMap *area_map)
+{
+ BLO_read_list(reader, &area_map->vertbase);
+ BLO_read_list(reader, &area_map->edgebase);
+ BLO_read_list(reader, &area_map->areabase);
+ LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
+ direct_link_area(reader, area);
+ }
+
+ /* edges */
+ LISTBASE_FOREACH (ScrEdge *, se, &area_map->edgebase) {
+ BLO_read_data_address(reader, &se->v1);
+ BLO_read_data_address(reader, &se->v2);
+ BKE_screen_sort_scrvert(&se->v1, &se->v2);
+
+ if (se->v1 == NULL) {
+ BLI_remlink(&area_map->edgebase, se);
+
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void BKE_screen_area_blend_read_lib(BlendLibReader *reader, ID *parent_id, ScrArea *area)
+{
+ BLO_read_id_address(reader, parent_id->lib, &area->full);
+
+ memset(&area->runtime, 0x0, sizeof(area->runtime));
+
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ switch (sl->spacetype) {
+ case SPACE_VIEW3D: {
+ View3D *v3d = (View3D *)sl;
+
+ BLO_read_id_address(reader, parent_id->lib, &v3d->camera);
+ BLO_read_id_address(reader, parent_id->lib, &v3d->ob_center);
+
+ if (v3d->localvd) {
+ BLO_read_id_address(reader, parent_id->lib, &v3d->localvd->camera);
+ }
+ break;
+ }
+ case SPACE_GRAPH: {
+ SpaceGraph *sipo = (SpaceGraph *)sl;
+ bDopeSheet *ads = sipo->ads;
+
+ if (ads) {
+ BLO_read_id_address(reader, parent_id->lib, &ads->source);
+ BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
+ }
+ break;
+ }
+ case SPACE_PROPERTIES: {
+ SpaceProperties *sbuts = (SpaceProperties *)sl;
+ BLO_read_id_address(reader, parent_id->lib, &sbuts->pinid);
+ if (sbuts->pinid == NULL) {
+ sbuts->flag &= ~SB_PIN_CONTEXT;
+ }
+ break;
+ }
+ case SPACE_FILE:
+ break;
+ case SPACE_ACTION: {
+ SpaceAction *saction = (SpaceAction *)sl;
+ bDopeSheet *ads = &saction->ads;
+
+ if (ads) {
+ BLO_read_id_address(reader, parent_id->lib, &ads->source);
+ BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
+ }
+
+ BLO_read_id_address(reader, parent_id->lib, &saction->action);
+ break;
+ }
+ case SPACE_IMAGE: {
+ SpaceImage *sima = (SpaceImage *)sl;
+
+ BLO_read_id_address(reader, parent_id->lib, &sima->image);
+ BLO_read_id_address(reader, parent_id->lib, &sima->mask_info.mask);
+
+ /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+ * so fingers crossed this works fine!
+ */
+ BLO_read_id_address(reader, parent_id->lib, &sima->gpd);
+ break;
+ }
+ case SPACE_SEQ: {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+
+ /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
+ * so fingers crossed this works fine!
+ */
+ BLO_read_id_address(reader, parent_id->lib, &sseq->gpd);
+ break;
+ }
+ case SPACE_NLA: {
+ SpaceNla *snla = (SpaceNla *)sl;
+ bDopeSheet *ads = snla->ads;
+
+ if (ads) {
+ BLO_read_id_address(reader, parent_id->lib, &ads->source);
+ BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
+ }
+ break;
+ }
+ case SPACE_TEXT: {
+ SpaceText *st = (SpaceText *)sl;
+
+ BLO_read_id_address(reader, parent_id->lib, &st->text);
+ break;
+ }
+ case SPACE_SCRIPT: {
+ SpaceScript *scpt = (SpaceScript *)sl;
+ /*scpt->script = NULL; - 2.45 set to null, better re-run the script */
+ if (scpt->script) {
+ BLO_read_id_address(reader, parent_id->lib, &scpt->script);
+ if (scpt->script) {
+ SCRIPT_SET_NULL(scpt->script);
+ }
+ }
+ break;
+ }
+ case SPACE_OUTLINER: {
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ BLO_read_id_address(reader, NULL, &space_outliner->search_tse.id);
+
+ if (space_outliner->treestore) {
+ TreeStoreElem *tselem;
+ BLI_mempool_iter iter;
+
+ BLI_mempool_iternew(space_outliner->treestore, &iter);
+ while ((tselem = BLI_mempool_iterstep(&iter))) {
+ BLO_read_id_address(reader, NULL, &tselem->id);
+ }
+ if (space_outliner->treehash) {
+ /* rebuild hash table, because it depends on ids too */
+ space_outliner->storeflag |= SO_TREESTORE_REBUILD;
+ }
+ }
+ break;
+ }
+ case SPACE_NODE: {
+ SpaceNode *snode = (SpaceNode *)sl;
+
+ /* node tree can be stored locally in id too, link this first */
+ BLO_read_id_address(reader, parent_id->lib, &snode->id);
+ BLO_read_id_address(reader, parent_id->lib, &snode->from);
+
+ bNodeTree *ntree = snode->id ? ntreeFromID(snode->id) : NULL;
+ if (ntree) {
+ snode->nodetree = ntree;
+ }
+ else {
+ BLO_read_id_address(reader, parent_id->lib, &snode->nodetree);
+ }
+
+ bNodeTreePath *path;
+ for (path = snode->treepath.first; path; path = path->next) {
+ if (path == snode->treepath.first) {
+ /* first nodetree in path is same as snode->nodetree */
+ path->nodetree = snode->nodetree;
+ }
+ else {
+ BLO_read_id_address(reader, parent_id->lib, &path->nodetree);
+ }
+
+ if (!path->nodetree) {
+ break;
+ }
+ }
+
+ /* remaining path entries are invalid, remove */
+ bNodeTreePath *path_next;
+ for (; path; path = path_next) {
+ path_next = path->next;
+
+ BLI_remlink(&snode->treepath, path);
+ MEM_freeN(path);
+ }
+
+ /* edittree is just the last in the path,
+ * set this directly since the path may have been shortened above */
+ if (snode->treepath.last) {
+ path = snode->treepath.last;
+ snode->edittree = path->nodetree;
+ }
+ else {
+ snode->edittree = NULL;
+ }
+ break;
+ }
+ case SPACE_CLIP: {
+ SpaceClip *sclip = (SpaceClip *)sl;
+ BLO_read_id_address(reader, parent_id->lib, &sclip->clip);
+ BLO_read_id_address(reader, parent_id->lib, &sclip->mask_info.mask);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+}
diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c
index f2cdf08b415..3727ec866ca 100644
--- a/source/blender/blenkernel/intern/shader_fx.c
+++ b/source/blender/blenkernel/intern/shader_fx.c
@@ -36,6 +36,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
#include "DNA_shader_fx_types.h"
#include "BKE_gpencil.h"
@@ -49,6 +50,8 @@
#include "FX_shader_types.h"
+#include "BLO_read_write.h"
+
static ShaderFxTypeInfo *shader_fx_types[NUM_SHADER_FX_TYPES] = {NULL};
/* *************************************************** */
@@ -175,6 +178,11 @@ void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname)
strcat(r_idname, fxi->name);
}
+void BKE_shaderfx_panel_expand(ShaderFxData *fx)
+{
+ fx->ui_expand_flag |= UI_PANEL_DATA_EXPAND_ROOT;
+}
+
void BKE_shaderfx_copydata_generic(const ShaderFxData *fx_src, ShaderFxData *fx_dst)
{
const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx_src->type);
@@ -270,3 +278,45 @@ ShaderFxData *BKE_shaderfx_findby_name(Object *ob, const char *name)
{
return BLI_findstring(&(ob->shader_fx), name, offsetof(ShaderFxData, name));
}
+
+void BKE_shaderfx_blend_write(BlendWriter *writer, ListBase *fxbase)
+{
+ if (fxbase == NULL) {
+ return;
+ }
+
+ LISTBASE_FOREACH (ShaderFxData *, fx, fxbase) {
+ const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx->type);
+ if (fxi == NULL) {
+ return;
+ }
+
+ BLO_write_struct_by_name(writer, fxi->struct_name, fx);
+ }
+}
+
+void BKE_shaderfx_blend_read_data(BlendDataReader *reader, ListBase *lb)
+{
+ BLO_read_list(reader, lb);
+
+ LISTBASE_FOREACH (ShaderFxData *, fx, lb) {
+ fx->error = NULL;
+
+ /* if shader disappear, or for upward compatibility */
+ if (NULL == BKE_shaderfx_get_info(fx->type)) {
+ fx->type = eShaderFxType_None;
+ }
+ }
+}
+
+void BKE_shaderfx_blend_read_lib(BlendLibReader *reader, Object *ob)
+{
+ BKE_shaderfx_foreach_ID_link(ob, BKE_object_modifiers_lib_link_common, reader);
+
+ /* If linking from a library, clear 'local' library override flag. */
+ if (ob->id.lib != NULL) {
+ LISTBASE_FOREACH (ShaderFxData *, fx, &ob->shader_fx) {
+ fx->flag &= ~eShaderFxFlag_OverrideLibrary_Local;
+ }
+ }
+}
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 0c9ee61ca19..ae39b200b56 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -1548,8 +1548,8 @@ 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;
-
- /* Tolerance value to prevent artifacts on sharp edges of a mesh.
+
+ /* 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;
diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc
index 2e1f8bd581e..861779ec700 100644
--- a/source/blender/blenkernel/intern/simulation.cc
+++ b/source/blender/blenkernel/intern/simulation.cc
@@ -165,12 +165,14 @@ IDTypeInfo IDType_ID_SIM = {
/* free_data */ simulation_free_data,
/* make_local */ nullptr,
/* foreach_id */ simulation_foreach_id,
- /* foreach_cache */ NULL,
+ /* foreach_cache */ nullptr,
/* blend_write */ simulation_blend_write,
/* blend_read_data */ simulation_blend_read_data,
/* blend_read_lib */ simulation_blend_read_lib,
/* blend_read_expand */ simulation_blend_read_expand,
+
+ /* blend_read_undo_preserve */ nullptr,
};
void *BKE_simulation_add(Main *bmain, const char *name)
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index bf61c27ee2f..25d812884bc 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -1063,7 +1063,7 @@ static int sb_detect_face_pointCached(const float face_v1[3],
GHash *hash;
GHashIterator *ihash;
float nv1[3], edge1[3], edge2[3], d_nvect[3], aabbmin[3], aabbmax[3];
- float facedist, outerfacethickness, tune = 10.f;
+ float facedist, outerfacethickness, tune = 10.0f;
int a, deflected = 0;
aabbmin[0] = min_fff(face_v1[0], face_v2[0], face_v3[0]);
@@ -2032,7 +2032,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene,
attached = 0;
for (b = obp->nofsprings; b > 0; b--) {
bs = sb->bspring + obp->springs[b - 1];
- if ((ilast - bb == bs->v2) || (ilast - bb == bs->v1)) {
+ if (ELEM(ilast - bb, bs->v2, bs->v1)) {
attached = 1;
continue;
}
@@ -2797,8 +2797,8 @@ static void reference_to_scratch(Object *ob)
SoftBody *sb = ob->soft;
ReferenceVert *rp;
BodyPoint *bp;
- float accu_pos[3] = {0.f, 0.f, 0.f};
- float accu_mass = 0.f;
+ float accu_pos[3] = {0.0f, 0.0f, 0.0f};
+ float accu_mass = 0.0f;
int a;
sb->scratch->Ref.ivert = MEM_mallocN(sizeof(ReferenceVert) * sb->totpoint, "SB_Reference");
@@ -3321,7 +3321,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
bp->vec[0] = bp->vec[1] = bp->vec[2] = 0.0f;
/* the bp->prev*'s are for rolling back from a canceled try to propagate in time
- * adaptive step size algo in a nutshell:
+ * adaptive step size algorithm in a nutshell:
* 1. set scheduled time step to new dtime
* 2. try to advance the scheduled time step, being optimistic execute it
* 3. check for success
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 8bec9f331c5..8b66b1fc628 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -60,7 +60,6 @@
#include "BKE_main.h"
#include "BKE_packedFile.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
#include "BKE_sound.h"
#include "DEG_depsgraph.h"
@@ -68,6 +67,8 @@
#include "BLO_read_write.h"
+#include "SEQ_sequencer.h"
+
static void sound_free_audio(bSound *sound);
static void sound_copy_data(Main *UNUSED(bmain),
@@ -211,6 +212,8 @@ IDTypeInfo IDType_ID_SO = {
.blend_read_data = sound_blend_read_data,
.blend_read_lib = sound_blend_read_lib,
.blend_read_expand = sound_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
#ifdef WITH_AUDASPACE
@@ -1320,7 +1323,10 @@ int BKE_sound_scene_playing(Scene *UNUSED(scene))
{
return -1;
}
-void BKE_sound_read_waveform(Main *bmain, bSound *sound, short *stop)
+void BKE_sound_read_waveform(Main *bmain,
+ bSound *sound,
+ /* NOLINTNEXTLINE: readability-non-const-parameter. */
+ short *stop)
{
UNUSED_VARS(sound, stop, bmain);
}
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c
index a98093d1893..fabf0bb8971 100644
--- a/source/blender/blenkernel/intern/speaker.c
+++ b/source/blender/blenkernel/intern/speaker.c
@@ -112,6 +112,8 @@ IDTypeInfo IDType_ID_SPK = {
.blend_read_data = speaker_blend_read_data,
.blend_read_lib = speaker_blend_read_lib,
.blend_read_expand = speaker_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
void *BKE_speaker_add(Main *bmain, const char *name)
diff --git a/source/blender/blenkernel/intern/subdiv_displacement_multires.c b/source/blender/blenkernel/intern/subdiv_displacement_multires.c
index 69cac840276..0fb08880dd5 100644
--- a/source/blender/blenkernel/intern/subdiv_displacement_multires.c
+++ b/source/blender/blenkernel/intern/subdiv_displacement_multires.c
@@ -442,7 +442,7 @@ void BKE_subdiv_displacement_attach_from_multires(Subdiv *subdiv,
{
/* Make sure we don't have previously assigned displacement. */
BKE_subdiv_displacement_detach(subdiv);
- /* It is possible to have mesh without MDISPS layer. Happens when using
+ /* It is possible to have mesh without CD_MDISPS layer. Happens when using
* dynamic topology. */
if (!CustomData_has_layer(&mesh->ldata, CD_MDISPS)) {
return;
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 93306703686..6f4ac4c44a0 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -256,6 +256,8 @@ IDTypeInfo IDType_ID_TXT = {
.blend_read_data = text_blend_read_data,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
/** \} */
@@ -2333,7 +2335,7 @@ int txt_setcurr_tab_spaces(Text *text, int space)
if (ch == ':') {
is_indent = 1;
}
- else if (ch != ' ' && ch != '\t') {
+ else if (!ELEM(ch, ' ', '\t')) {
is_indent = 0;
}
}
@@ -2459,7 +2461,7 @@ int text_check_identifier_nodigit_unicode(const unsigned int ch)
bool text_check_whitespace(const char ch)
{
- if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') {
+ if (ELEM(ch, ' ', '\t', '\r', '\n')) {
return true;
}
return false;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 90c4f71ce7a..4c2e4a82acb 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -67,7 +67,7 @@
#include "BKE_scene.h"
#include "BKE_texture.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#include "BLO_read_write.h"
@@ -224,6 +224,8 @@ IDTypeInfo IDType_ID_TE = {
.blend_read_data = texture_blend_read_data,
.blend_read_lib = texture_blend_read_lib,
.blend_read_expand = texture_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
/* Utils for all IDs using those texture slots. */
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index cb33610a93f..7f927a8838e 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -338,6 +338,7 @@ void BKE_tracking_settings_init(MovieTracking *tracking)
tracking->settings.default_weight = 1.0f;
tracking->settings.dist = 1;
tracking->settings.object_distance = 1;
+ tracking->settings.refine_camera_intrinsics = REFINE_NO_INTRINSICS;
tracking->stabilization.scaleinf = 1.0f;
tracking->stabilization.anchor_frame = 1;
diff --git a/source/blender/blenkernel/intern/tracking_solver.c b/source/blender/blenkernel/intern/tracking_solver.c
index 7df8bf62b16..d89d36f85ea 100644
--- a/source/blender/blenkernel/intern/tracking_solver.c
+++ b/source/blender/blenkernel/intern/tracking_solver.c
@@ -291,12 +291,12 @@ static int reconstruct_refine_intrinsics_get_flags(MovieTracking *tracking,
flags |= LIBMV_REFINE_PRINCIPAL_POINT;
}
- if (refine & REFINE_RADIAL_DISTORTION_K1) {
- flags |= LIBMV_REFINE_RADIAL_DISTORTION_K1;
+ if (refine & REFINE_RADIAL_DISTORTION) {
+ flags |= LIBMV_REFINE_RADIAL_DISTORTION;
}
- if (refine & REFINE_RADIAL_DISTORTION_K2) {
- flags |= LIBMV_REFINE_RADIAL_DISTORTION_K2;
+ if (refine & REFINE_TANGENTIAL_DISTORTION) {
+ flags |= LIBMV_REFINE_TANGENTIAL_DISTORTION;
}
return flags;
diff --git a/source/blender/blenkernel/intern/tracking_util.c b/source/blender/blenkernel/intern/tracking_util.c
index bc6c94343b5..c7e4e0d5c08 100644
--- a/source/blender/blenkernel/intern/tracking_util.c
+++ b/source/blender/blenkernel/intern/tracking_util.c
@@ -722,7 +722,7 @@ static ImBuf *make_grayscale_ibuf_copy(ImBuf *ibuf)
{
ImBuf *grayscale = IMB_allocImBuf(ibuf->x, ibuf->y, 32, 0);
- BLI_assert(ibuf->channels == 3 || ibuf->channels == 4);
+ BLI_assert(ELEM(ibuf->channels, 3, 4));
/* TODO(sergey): Bummer, currently IMB API only allows to create 4 channels
* float buffer, so we do it manually here.
@@ -880,7 +880,7 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
}
/* Transform number of channels. */
if (input_mode == LIBMV_IMAGE_MODE_RGBA) {
- BLI_assert(orig_ibuf->channels == 3 || orig_ibuf->channels == 4);
+ BLI_assert(ELEM(orig_ibuf->channels, 3, 4));
/* pass */
}
else /* if (input_mode == LIBMV_IMAGE_MODE_MONO) */ {
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index 93f70b606dc..b687254fd69 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -95,7 +95,7 @@ static bool g_undo_callback_running = false;
/** \name Public Undo Types
*
* Unfortunately we need this for a handful of places.
- */
+ * \{ */
const UndoType *BKE_UNDOSYS_TYPE_IMAGE = NULL;
const UndoType *BKE_UNDOSYS_TYPE_MEMFILE = NULL;
const UndoType *BKE_UNDOSYS_TYPE_PAINTCURVE = NULL;
@@ -357,7 +357,7 @@ void BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain)
void BKE_undosys_stack_init_from_context(UndoStack *ustack, bContext *C)
{
const UndoType *ut = BKE_undosys_type_from_context(C);
- if ((ut != NULL) && (ut != BKE_UNDOSYS_TYPE_MEMFILE)) {
+ if (!ELEM(ut, NULL, BKE_UNDOSYS_TYPE_MEMFILE)) {
BKE_undosys_step_push_with_type(ustack, C, IFACE_("Original Mode"), ut);
}
}
@@ -549,6 +549,8 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack,
BLI_strncpy(us->name, name, sizeof(us->name));
}
us->type = ut;
+ /* True by default, code needs to explicitely set it to false if necessary. */
+ us->use_old_bmain_data = true;
/* Initialized, not added yet. */
CLOG_INFO(&LOG, 1, "addr=%p, name='%s', type='%s'", us, us->name, us->type->name);
@@ -897,7 +899,7 @@ void BKE_undosys_stack_group_end(UndoStack *ustack)
/** \name ID Reference Utilities
*
* Unfortunately we need this for a handful of places.
- */
+ * \{ */
static void UNUSED_FUNCTION(BKE_undosys_foreach_ID_ref(UndoStack *ustack,
UndoTypeForEachIDRefFn foreach_ID_ref_fn,
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 73bf149bf2a..b55f80c6473 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -802,17 +802,12 @@ static char *find_next_negative(const char *str, const char *remaining_str)
static char *find_next_op(const char *str, char *remaining_str, int len_max)
{
int i;
- bool scientific_notation = false;
for (i = 0; i < len_max; i++) {
if (remaining_str[i] == '\0') {
return remaining_str + i;
}
if (ch_is_op(remaining_str[i])) {
- if (scientific_notation) {
- scientific_notation = false;
- }
-
/* Make sure we don't look backwards before the start of the string. */
if (remaining_str != str && i != 0) {
/* Check for velocity or acceleration (e.g. '/' in 'ft/s' is not an op). */
@@ -822,8 +817,7 @@ static char *find_next_op(const char *str, char *remaining_str, int len_max)
}
/* Check for scientific notation. */
- if (remaining_str[i - 1] == 'e' || remaining_str[i - 1] == 'E') {
- scientific_notation = true;
+ if (ELEM(remaining_str[i - 1], 'e', 'E')) {
continue;
}
@@ -1184,7 +1178,7 @@ bool BKE_unit_replace_string(
/* Any operators after this? */
for (ch = str_found + 1; *ch != '\0'; ch++) {
- if (*ch == ' ' || *ch == '\t') {
+ if (ELEM(*ch, ' ', '\t')) {
continue;
}
op_found = (ch_is_op(*ch) || ELEM(*ch, ',', ')'));
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index 87993695486..11aa9597740 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -265,12 +265,13 @@ static struct VolumeFileCache {
struct VolumeGrid {
VolumeGrid(const VolumeFileCache::Entry &template_entry, const int simplify_level)
- : entry(NULL), simplify_level(simplify_level), is_loaded(false)
+ : entry(nullptr), simplify_level(simplify_level), is_loaded(false)
{
entry = GLOBAL_CACHE.add_metadata_user(template_entry);
}
- VolumeGrid(const openvdb::GridBase::Ptr &grid) : entry(NULL), local_grid(grid), is_loaded(true)
+ VolumeGrid(const openvdb::GridBase::Ptr &grid)
+ : entry(nullptr), local_grid(grid), is_loaded(true)
{
}
@@ -295,7 +296,7 @@ struct VolumeGrid {
void load(const char *volume_name, const char *filepath)
{
/* If already loaded or not file-backed, nothing to do. */
- if (is_loaded || entry == NULL) {
+ if (is_loaded || entry == nullptr) {
return;
}
@@ -337,7 +338,7 @@ struct VolumeGrid {
void unload(const char *volume_name)
{
/* Not loaded or not file-backed, nothing to do. */
- if (!is_loaded || entry == NULL) {
+ if (!is_loaded || entry == nullptr) {
return;
}
@@ -364,7 +365,7 @@ struct VolumeGrid {
local_grid = grid()->copyGridWithNewTree();
if (entry) {
GLOBAL_CACHE.remove_user(*entry, is_loaded);
- entry = NULL;
+ entry = nullptr;
}
is_loaded = true;
}
@@ -378,7 +379,7 @@ struct VolumeGrid {
local_grid = grid()->deepCopyGrid();
if (entry) {
GLOBAL_CACHE.remove_user(*entry, is_loaded);
- entry = NULL;
+ entry = nullptr;
}
is_loaded = true;
}
@@ -398,7 +399,7 @@ struct VolumeGrid {
return entry->error_msg.c_str();
}
- return NULL;
+ return nullptr;
}
bool grid_is_loaded() const
@@ -562,7 +563,7 @@ static void volume_blend_write(BlendWriter *writer, ID *id, const void *id_addre
Volume *volume = (Volume *)id;
if (volume->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
- volume->runtime.grids = 0;
+ volume->runtime.grids = nullptr;
/* write LibData */
BLO_write_id_struct(writer, Volume, id_address, &volume->id);
@@ -633,12 +634,14 @@ IDTypeInfo IDType_ID_VO = {
/* blend_read_data */ volume_blend_read_data,
/* blend_read_lib */ volume_blend_read_lib,
/* blend_read_expand */ volume_blend_read_expand,
+
+ /* blend_read_undo_preserve */ nullptr,
};
void BKE_volume_init_grids(Volume *volume)
{
#ifdef WITH_OPENVDB
- if (volume->runtime.grids == NULL) {
+ if (volume->runtime.grids == nullptr) {
volume->runtime.grids = OBJECT_GUARDED_NEW(VolumeGridVector);
}
#else
@@ -869,11 +872,11 @@ BoundBox *BKE_volume_boundbox_get(Object *ob)
{
BLI_assert(ob->type == OB_VOLUME);
- if (ob->runtime.bb != NULL && (ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) {
+ if (ob->runtime.bb != nullptr && (ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) {
return ob->runtime.bb;
}
- if (ob->runtime.bb == NULL) {
+ if (ob->runtime.bb == nullptr) {
Volume *volume = (Volume *)ob->data;
ob->runtime.bb = (BoundBox *)MEM_callocN(sizeof(BoundBox), "volume boundbox");
@@ -1004,7 +1007,7 @@ static Volume *volume_evaluate_modifiers(struct Depsgraph *depsgraph,
if (volume_next && volume_next != volume) {
/* If the modifier returned a new volume, release the old one. */
if (volume != volume_input) {
- BKE_id_free(NULL, volume);
+ BKE_id_free(nullptr, volume);
}
volume = volume_next;
}
@@ -1055,7 +1058,7 @@ void BKE_volume_grids_backup_restore(Volume *volume, VolumeGridVector *grids, co
/* Restore grids after datablock was re-copied from original by depsgraph,
* we don't want to load them again if possible. */
BLI_assert(volume->id.tag & LIB_TAG_COPIED_ON_WRITE);
- BLI_assert(volume->runtime.grids != NULL && grids != NULL);
+ BLI_assert(volume->runtime.grids != nullptr && grids != nullptr);
if (!grids->is_loaded()) {
/* No grids loaded in CoW datablock, nothing lost by discarding. */
@@ -1078,8 +1081,8 @@ void BKE_volume_grids_backup_restore(Volume *volume, VolumeGridVector *grids, co
/* Draw Cache */
-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_cb)(Volume *volume, int mode) = nullptr;
+void (*BKE_volume_batch_cache_free_cb)(Volume *volume) = nullptr;
void BKE_volume_batch_cache_dirty_tag(Volume *volume, int mode)
{
@@ -1136,10 +1139,10 @@ VolumeGrid *BKE_volume_grid_get(const Volume *volume, int grid_index)
return &grid;
}
}
- return NULL;
+ return nullptr;
#else
UNUSED_VARS(volume, grid_index);
- return NULL;
+ return nullptr;
#endif
}
@@ -1147,7 +1150,7 @@ VolumeGrid *BKE_volume_grid_active_get(const Volume *volume)
{
const int num_grids = BKE_volume_num_grids(volume);
if (num_grids == 0) {
- return NULL;
+ return nullptr;
}
const int index = clamp_i(volume->active_grid, 0, num_grids - 1);
@@ -1165,7 +1168,7 @@ VolumeGrid *BKE_volume_grid_find(const Volume *volume, const char *name)
}
}
- return NULL;
+ return nullptr;
}
/* Grid Loading */
@@ -1350,7 +1353,7 @@ bool BKE_volume_grid_bounds(const VolumeGrid *volume_grid, float min[3], float m
Volume *BKE_volume_new_for_eval(const Volume *volume_src)
{
- Volume *volume_dst = (Volume *)BKE_id_new_nomain(ID_VO, NULL);
+ Volume *volume_dst = (Volume *)BKE_id_new_nomain(ID_VO, nullptr);
STRNCPY(volume_dst->id.name, volume_src->id.name);
volume_dst->mat = (Material **)MEM_dupallocN(volume_src->mat);
@@ -1370,7 +1373,7 @@ Volume *BKE_volume_copy_for_eval(Volume *volume_src, bool reference)
flags |= LIB_ID_COPY_CD_REFERENCE;
}
- Volume *result = (Volume *)BKE_id_copy_ex(NULL, &volume_src->id, NULL, flags);
+ Volume *result = (Volume *)BKE_id_copy_ex(nullptr, &volume_src->id, nullptr, flags);
return result;
}
@@ -1393,12 +1396,12 @@ VolumeGrid *BKE_volume_grid_add(Volume *volume, const char *name, VolumeGridType
{
#ifdef WITH_OPENVDB
VolumeGridVector &grids = *volume->runtime.grids;
- BLI_assert(BKE_volume_grid_find(volume, name) == NULL);
+ BLI_assert(BKE_volume_grid_find(volume, name) == nullptr);
BLI_assert(type != VOLUME_GRID_UNKNOWN);
openvdb::GridBase::Ptr vdb_grid = BKE_volume_grid_type_operation(type, CreateGridOp{});
if (!vdb_grid) {
- return NULL;
+ return nullptr;
}
vdb_grid->setName(name);
@@ -1406,7 +1409,7 @@ VolumeGrid *BKE_volume_grid_add(Volume *volume, const char *name, VolumeGridType
return &grids.back();
#else
UNUSED_VARS(volume, name, type);
- return NULL;
+ return nullptr;
#endif
}
diff --git a/source/blender/blenkernel/intern/volume_render.cc b/source/blender/blenkernel/intern/volume_render.cc
index 37b397a9c6d..5c71f1d7eca 100644
--- a/source/blender/blenkernel/intern/volume_render.cc
+++ b/source/blender/blenkernel/intern/volume_render.cc
@@ -123,7 +123,7 @@ bool BKE_volume_grid_dense_floats(const Volume *volume,
const int channels = BKE_volume_grid_channels(volume_grid);
const int elem_size = sizeof(float) * channels;
float *voxels = static_cast<float *>(MEM_malloc_arrayN(num_voxels, elem_size, __func__));
- if (voxels == NULL) {
+ if (voxels == nullptr) {
return false;
}
@@ -143,7 +143,7 @@ bool BKE_volume_grid_dense_floats(const Volume *volume,
void BKE_volume_dense_float_grid_clear(DenseFloatVolumeGrid *dense_grid)
{
- if (dense_grid->voxels != NULL) {
+ if (dense_grid->voxels != nullptr) {
MEM_freeN(dense_grid->voxels);
}
}
@@ -339,7 +339,7 @@ void BKE_volume_grid_wireframe(const Volume *volume,
void *cb_userdata)
{
if (volume->display.wireframe_type == VOLUME_WIREFRAME_NONE) {
- cb(cb_userdata, NULL, NULL, 0, 0);
+ cb(cb_userdata, nullptr, nullptr, 0, 0);
return;
}
@@ -386,7 +386,7 @@ void BKE_volume_grid_wireframe(const Volume *volume,
#else
UNUSED_VARS(volume, volume_grid);
- cb(cb_userdata, NULL, NULL, 0, 0);
+ cb(cb_userdata, nullptr, nullptr, 0, 0);
#endif
}
@@ -432,7 +432,7 @@ void BKE_volume_grid_selection_surface(const Volume *volume,
cb(cb_userdata, (float(*)[3])verts.data(), (int(*)[3])tris.data(), verts.size(), tris.size());
#else
UNUSED_VARS(volume, volume_grid);
- cb(cb_userdata, NULL, NULL, 0, 0);
+ cb(cb_userdata, nullptr, nullptr, 0, 0);
#endif
}
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index cd163b7c8bf..291116556c3 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -48,6 +48,8 @@
#include "MEM_guardedalloc.h"
+#include "BLO_read_write.h"
+
/* -------------------------------------------------------------------- */
static void workspace_free_data(ID *id)
@@ -75,6 +77,98 @@ static void workspace_foreach_id(ID *id, LibraryForeachIDData *data)
}
}
+static void workspace_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ WorkSpace *workspace = (WorkSpace *)id;
+
+ BLO_write_id_struct(writer, WorkSpace, id_address, &workspace->id);
+ BKE_id_blend_write(writer, &workspace->id);
+ BLO_write_struct_list(writer, WorkSpaceLayout, &workspace->layouts);
+ BLO_write_struct_list(writer, WorkSpaceDataRelation, &workspace->hook_layout_relations);
+ BLO_write_struct_list(writer, wmOwnerID, &workspace->owner_ids);
+ BLO_write_struct_list(writer, bToolRef, &workspace->tools);
+ LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
+ if (tref->properties) {
+ IDP_BlendWrite(writer, tref->properties);
+ }
+ }
+}
+
+static void workspace_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ WorkSpace *workspace = (WorkSpace *)id;
+
+ BLO_read_list(reader, &workspace->layouts);
+ BLO_read_list(reader, &workspace->hook_layout_relations);
+ BLO_read_list(reader, &workspace->owner_ids);
+ BLO_read_list(reader, &workspace->tools);
+
+ LISTBASE_FOREACH (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) {
+ /* parent pointer does not belong to workspace data and is therefore restored in lib_link step
+ * of window manager.*/
+ BLO_read_data_address(reader, &relation->value);
+ }
+
+ LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
+ tref->runtime = NULL;
+ BLO_read_data_address(reader, &tref->properties);
+ IDP_BlendDataRead(reader, &tref->properties);
+ }
+
+ workspace->status_text = NULL;
+
+ id_us_ensure_real(&workspace->id);
+}
+
+static void workspace_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+ WorkSpace *workspace = (WorkSpace *)id;
+ Main *bmain = BLO_read_lib_get_main(reader);
+
+ /* Restore proper 'parent' pointers to relevant data, and clean up unused/invalid entries. */
+ LISTBASE_FOREACH_MUTABLE (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) {
+ relation->parent = NULL;
+ LISTBASE_FOREACH (wmWindowManager *, wm, &bmain->wm) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
+ if (win->winid == relation->parentid) {
+ relation->parent = win->workspace_hook;
+ }
+ }
+ }
+ if (relation->parent == NULL) {
+ BLI_freelinkN(&workspace->hook_layout_relations, relation);
+ }
+ }
+
+ LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout, &workspace->layouts) {
+ BLO_read_id_address(reader, id->lib, &layout->screen);
+
+ if (layout->screen) {
+ if (ID_IS_LINKED(id)) {
+ layout->screen->winid = 0;
+ if (layout->screen->temp) {
+ /* delete temp layouts when appending */
+ BKE_workspace_layout_remove(bmain, workspace, layout);
+ }
+ }
+ }
+ else {
+ /* If we're reading a layout without screen stored, it's useless and we shouldn't keep it
+ * around. */
+ BKE_workspace_layout_remove(bmain, workspace, layout);
+ }
+ }
+}
+
+static void workspace_blend_read_expand(BlendExpander *expander, ID *id)
+{
+ WorkSpace *workspace = (WorkSpace *)id;
+
+ LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
+ BLO_expand(expander, BKE_workspace_layout_screen_get(layout));
+ }
+}
+
IDTypeInfo IDType_ID_WS = {
.id_code = ID_WS,
.id_filter = FILTER_ID_WS,
@@ -92,12 +186,15 @@ IDTypeInfo IDType_ID_WS = {
.foreach_id = workspace_foreach_id,
.foreach_cache = NULL,
- .blend_write = NULL,
- .blend_read_data = NULL,
- .blend_read_lib = NULL,
- .blend_read_expand = NULL,
+ .blend_write = workspace_blend_write,
+ .blend_read_data = workspace_blend_read_data,
+ .blend_read_lib = workspace_blend_read_lib,
+ .blend_read_expand = workspace_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
+/* -------------------------------------------------------------------- */
/** \name Internal Utils
* \{ */
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 094557502a3..8fe7653fc25 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -204,6 +204,8 @@ IDTypeInfo IDType_ID_WO = {
.blend_read_data = world_blend_read_data,
.blend_read_lib = world_blend_read_lib,
.blend_read_expand = world_blend_read_expand,
+
+ .blend_read_undo_preserve = NULL,
};
World *BKE_world_add(Main *bmain, const char *name)
diff --git a/source/blender/blenlib/BLI_args.h b/source/blender/blenlib/BLI_args.h
index 54b5161f15a..b12b7ff5d1e 100644
--- a/source/blender/blenlib/BLI_args.h
+++ b/source/blender/blenlib/BLI_args.h
@@ -38,41 +38,41 @@ typedef struct bArgs bArgs;
*/
typedef int (*BA_ArgCallback)(int argc, const char **argv, void *data);
-struct bArgs *BLI_argsInit(int argc, const char **argv);
-void BLI_argsFree(struct bArgs *ba);
+struct bArgs *BLI_args_create(int argc, const char **argv);
+void BLI_args_destroy(struct bArgs *ba);
+
+/** The pass to use for #BLI_args_add. */
+void BLI_args_pass_set(struct bArgs *ba, int current_pass);
/**
* Pass starts at 1, -1 means valid all the time
* short_arg or long_arg can be null to specify no short or long versions
*/
-void BLI_argsAdd(struct bArgs *ba,
- int pass,
- const char *short_arg,
- const char *long_arg,
- const char *doc,
- BA_ArgCallback cb,
- void *data);
+void BLI_args_add(struct bArgs *ba,
+ const char *short_arg,
+ const char *long_arg,
+ const char *doc,
+ BA_ArgCallback cb,
+ void *data);
/**
* Short_case and long_case specify if those arguments are case specific
*/
-void BLI_argsAddCase(struct bArgs *ba,
- int pass,
- const char *short_arg,
- int short_case,
- const char *long_arg,
- int long_case,
- const char *doc,
- BA_ArgCallback cb,
- void *data);
+void BLI_args_add_case(struct bArgs *ba,
+ const char *short_arg,
+ int short_case,
+ const char *long_arg,
+ int long_case,
+ const char *doc,
+ BA_ArgCallback cb,
+ void *data);
-void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *data);
+void BLI_args_parse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *data);
-void BLI_argsPrintArgDoc(struct bArgs *ba, const char *arg);
-void BLI_argsPrintOtherDoc(struct bArgs *ba);
+void BLI_args_print_arg_doc(struct bArgs *ba, const char *arg);
+void BLI_args_print_other_doc(struct bArgs *ba);
-void BLI_argsPrint(struct bArgs *ba);
-const char **BLI_argsArgv(struct bArgs *ba);
+void BLI_args_print(struct bArgs *ba);
#ifdef __cplusplus
}
diff --git a/source/blender/blenlib/BLI_bitmap.h b/source/blender/blenlib/BLI_bitmap.h
index 960ce44c58c..c97be6eed3c 100644
--- a/source/blender/blenlib/BLI_bitmap.h
+++ b/source/blender/blenlib/BLI_bitmap.h
@@ -106,7 +106,7 @@ typedef unsigned int BLI_bitmap;
#define BLI_BITMAP_RESIZE(_bitmap, _tot) \
{ \
CHECK_TYPE(_bitmap, BLI_bitmap *); \
- (_bitmap) = MEM_reallocN(_bitmap, BLI_BITMAP_SIZE(_tot)); \
+ (_bitmap) = MEM_recallocN(_bitmap, BLI_BITMAP_SIZE(_tot)); \
} \
(void)0
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index e38848e2967..bc517f81955 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -74,6 +74,7 @@ enum {
#endif
};
+/* -------------------------------------------------------------------- */
/** \name GHash API
*
* Defined in ``BLI_ghash.c``
@@ -124,6 +125,7 @@ void BLI_ghash_flag_clear(GHash *gh, unsigned int flag);
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GHash Iterator
* \{ */
@@ -175,6 +177,7 @@ BLI_INLINE bool BLI_ghashIterator_done(GHashIterator *ghi)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GSet API
* A 'set' implementation (unordered collection of unique elements).
*
@@ -222,6 +225,7 @@ void *BLI_gset_pop_key(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GSet Iterator
* \{ */
@@ -272,6 +276,7 @@ BLI_INLINE bool BLI_gsetIterator_done(GSetIterator *gsi)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GHash/GSet Debugging API's
* \{ */
@@ -297,6 +302,7 @@ double BLI_gset_calc_quality(GSet *gs);
#endif /* GHASH_INTERNAL_API */
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GHash/GSet Macros
* \{ */
@@ -324,6 +330,7 @@ double BLI_gset_calc_quality(GSet *gs);
/** \} */
+/* -------------------------------------------------------------------- */
/** \name GHash/GSet Utils
*
* Defined in ``BLI_ghash_utils.c``
diff --git a/source/blender/blenlib/BLI_linklist_stack.h b/source/blender/blenlib/BLI_linklist_stack.h
index 065ed12f353..be98304e6b5 100644
--- a/source/blender/blenlib/BLI_linklist_stack.h
+++ b/source/blender/blenlib/BLI_linklist_stack.h
@@ -32,12 +32,9 @@
*/
/* -------------------------------------------------------------------- */
-/* Linked Stack using BLI_mempool
- *
- * Uses mempool for storage.
- */
-
/** \name Linked Stack (mempool)
+ *
+ * Uses #BLI_mempool for storage.
* \{ */
#define BLI_LINKSTACK_DECLARE(var, type) \
@@ -94,13 +91,12 @@
/** \} */
/* -------------------------------------------------------------------- */
-/* Linked Stack, using stack memory (alloca)
+/** \name Linked Stack (alloca)
+ *
+ * Linked Stack, using stack memory (alloca).
*
* alloca never frees, pop'd items are stored in a free-list for reuse.
* only use for lists small enough to fit on the stack.
- */
-
-/** \name Linked Stack (alloca)
* \{ */
#ifdef __GNUC__
diff --git a/source/blender/blenlib/BLI_listbase_wrapper.hh b/source/blender/blenlib/BLI_listbase_wrapper.hh
index c31694d7d9e..ed2a2b5e5ec 100644
--- a/source/blender/blenlib/BLI_listbase_wrapper.hh
+++ b/source/blender/blenlib/BLI_listbase_wrapper.hh
@@ -56,7 +56,8 @@ template<typename T> class ListBaseWrapper {
Iterator &operator++()
{
- current_ = current_->next;
+ /* Some types store next/prev using `void *`, so cast is necessary. */
+ current_ = static_cast<T *>(current_->next);
return *this;
}
diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh
index 08fe1a3cdbc..9480af89107 100644
--- a/source/blender/blenlib/BLI_map.hh
+++ b/source/blender/blenlib/BLI_map.hh
@@ -230,19 +230,25 @@ class Map {
*/
void add_new(const Key &key, const Value &value)
{
- this->add_new__impl(key, value, hash_(key));
+ this->add_new_as(key, value);
}
void add_new(const Key &key, Value &&value)
{
- this->add_new__impl(key, std::move(value), hash_(key));
+ this->add_new_as(key, std::move(value));
}
void add_new(Key &&key, const Value &value)
{
- this->add_new__impl(std::move(key), value, hash_(key));
+ this->add_new_as(std::move(key), value);
}
void add_new(Key &&key, Value &&value)
{
- this->add_new__impl(std::move(key), std::move(value), hash_(key));
+ this->add_new_as(std::move(key), std::move(value));
+ }
+ template<typename ForwardKey, typename ForwardValue>
+ void add_new_as(ForwardKey &&key, ForwardValue &&value)
+ {
+ this->add_new__impl(
+ std::forward<ForwardKey>(key), std::forward<ForwardValue>(value), hash_(key));
}
/**
@@ -1010,7 +1016,7 @@ class Map {
return;
}
else {
- auto return_value = create_value(value_ptr);
+ auto &&return_value = create_value(value_ptr);
slot.occupy_no_value(std::forward<ForwardKey>(key), hash);
occupied_and_removed_slots_++;
return return_value;
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index d2bb60717ca..0ec65999006 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -219,6 +219,9 @@ MINLINE unsigned int round_db_to_uint_clamp(double a);
int pow_i(int base, int exp);
double double_round(double x, int ndigits);
+float floor_power_of_10(float f);
+float ceil_power_of_10(float f);
+
#ifdef BLI_MATH_GCC_WARN_PRAGMA
# pragma GCC diagnostic pop
#endif
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index a9a55b10a9e..c0a9ea91e75 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -358,6 +358,14 @@ bool isect_plane_plane_v3(const float plane_a[4],
float r_isect_co[3],
float r_isect_no[3]) ATTR_WARN_UNUSED_RESULT;
+bool isect_planes_v3_fn(
+ const float planes[][4],
+ const int planes_len,
+ const float eps_coplanar,
+ const float eps_isect,
+ void (*callback_fn)(const float co[3], int i, int j, int k, void *user_data),
+ void *user_data);
+
/* line/ray triangle */
bool isect_line_segment_tri_v3(const float p1[3],
const float p2[3],
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 9f6c56d698a..d971f48c4cf 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -322,9 +322,13 @@ void mat4_to_size(float size[3], const float M[4][4]);
void mat4_to_size_fix_shear(float size[3], const float M[4][4]);
+void translate_m3(float mat[3][3], float tx, float ty);
void translate_m4(float mat[4][4], float tx, float ty, float tz);
+void rotate_m3(float mat[3][3], const float angle);
void rotate_m4(float mat[4][4], const char axis, const float angle);
+void rescale_m3(float mat[3][3], const float scale[2]);
void rescale_m4(float mat[4][4], const float scale[3]);
+void transform_pivot_set_m3(float mat[3][3], const float pivot[2]);
void transform_pivot_set_m4(float mat[4][4], const float pivot[3]);
void mat3_to_rot_size(float rot[3][3], float size[3], const float mat3[3][3]);
@@ -334,6 +338,10 @@ void mat4_decompose(float loc[3], float quat[4], float size[3], const float wmat
void mat3_polar_decompose(const float mat3[3][3], float r_U[3][3], float r_P[3][3]);
+void loc_rot_size_to_mat3(float R[3][3],
+ const float loc[2],
+ const float angle,
+ const float size[2]);
void loc_rot_size_to_mat4(float R[4][4],
const float loc[3],
const float rot[3][3],
diff --git a/source/blender/blenlib/BLI_noise.h b/source/blender/blenlib/BLI_noise.h
index cb66b0552df..37afd8ee031 100644
--- a/source/blender/blenlib/BLI_noise.h
+++ b/source/blender/blenlib/BLI_noise.h
@@ -27,53 +27,54 @@
extern "C" {
#endif
-/* noise.h: */
-float BLI_hnoise(float noisesize, float x, float y, float z);
-float BLI_hnoisep(float noisesize, float x, float y, float z);
-float BLI_turbulence(float noisesize, float x, float y, float z, int nr);
-float BLI_turbulence1(float noisesize, float x, float y, float z, int nr);
+float BLI_noise_hnoise(float noisesize, float x, float y, float z);
+float BLI_noise_hnoisep(float noisesize, float x, float y, float z);
+float BLI_noise_turbulence(float noisesize, float x, float y, float z, int nr);
/* newnoise: generic noise & turbulence functions
- * to replace the above BLI_hnoise/p & BLI_turbulence/1.
+ * to replace the above BLI_noise_hnoise/p & BLI_noise_turbulence/1.
* This is done so different noise basis functions can be used */
-float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noisebasis);
-float BLI_gTurbulence(
- float noisesize, float x, float y, float z, int oct, int hard, int noisebasis);
+float BLI_noise_generic_noise(
+ float noisesize, float x, float y, float z, bool hard, int noisebasis);
+float BLI_noise_generic_turbulence(
+ float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis);
/* newnoise: musgrave functions */
-float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis);
-float mg_MultiFractal(
+float BLI_noise_mg_fbm(
float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis);
-float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nbas2);
-float mg_HeteroTerrain(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- int noisebasis);
-float mg_HybridMultiFractal(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- float gain,
- int noisebasis);
-float mg_RidgedMultiFractal(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- float gain,
- int noisebasis);
+float BLI_noise_mg_multi_fractal(
+ float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis);
+float BLI_noise_mg_variable_lacunarity(
+ float x, float y, float z, float distortion, int nbas1, int nbas2);
+float BLI_noise_mg_hetero_terrain(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ int noisebasis);
+float BLI_noise_mg_hybrid_multi_fractal(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ float gain,
+ int noisebasis);
+float BLI_noise_mg_ridged_multi_fractal(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ float gain,
+ int noisebasis);
/* newnoise: voronoi */
-void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype);
-/* newnoise: cellNoise & cellNoiseV (for vector/point/color) */
-float cellNoise(float x, float y, float z);
-void cellNoiseV(float x, float y, float z, float r_ca[3]);
+void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype);
+/* newnoise: BLI_noise_cell & BLI_noise_cell_v3 (for vector/point/color) */
+float BLI_noise_cell(float x, float y, float z);
+void BLI_noise_cell_v3(float x, float y, float z, float r_ca[3]);
#ifdef __cplusplus
}
diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh
index f1cf44018c9..06b56c3f8e5 100644
--- a/source/blender/blenlib/BLI_set.hh
+++ b/source/blender/blenlib/BLI_set.hh
@@ -48,7 +48,7 @@
* - Small buffer optimization is enabled by default, if the key is not too large.
* - The methods `add_new` and `remove_contained` should be used instead of `add` and `remove`
* whenever appropriate. Assumptions and intention are described better this way.
- * - Look-ups can be performed using types other than Key without conversion. For that use the
+ * - Lookups can be performed using types other than Key without conversion. For that use the
* methods ending with `_as`. The template parameters Hash and #IsEqual have to support the other
* key type. This can greatly improve performance when the set contains strings.
* - The default constructor is cheap, even when a large #InlineBufferCapacity is used. A large
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index 6434464a012..2d745e63764 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -147,6 +147,7 @@ int BLI_string_find_split_words(const char *str,
int r_words[][2],
int words_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+/* -------------------------------------------------------------------- */
/** \name String Copy/Format Macros
* Avoid repeating destination with `sizeof(..)`.
* \note `ARRAY_SIZE` allows pointers on some platforms.
diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h
index b633bbfa435..65d9d7863c3 100644
--- a/source/blender/blenlib/BLI_string_utf8.h
+++ b/source/blender/blenlib/BLI_string_utf8.h
@@ -103,6 +103,7 @@ int BLI_str_utf8_offset_from_column(const char *str, int column);
#define BLI_UTF8_WIDTH_MAX 2 /* columns */
#define BLI_UTF8_ERR ((unsigned int)-1)
+/* -------------------------------------------------------------------- */
/** \name String Copy/Format Macros
* Avoid repeating destination with `sizeof(..)`.
* \note `ARRAY_SIZE` allows pointers on some platforms.
diff --git a/source/blender/blenlib/BLI_task.hh b/source/blender/blenlib/BLI_task.hh
index 8a0d77745c8..0da03d84793 100644
--- a/source/blender/blenlib/BLI_task.hh
+++ b/source/blender/blenlib/BLI_task.hh
@@ -24,16 +24,20 @@
/* Quiet top level deprecation message, unrelated to API usage here. */
# define TBB_SUPPRESS_DEPRECATED_MESSAGES 1
-# ifdef WIN32
+# if defined(WIN32) && !defined(NOMINMAX)
/* 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
+# define TBB_MIN_MAX_CLEANUP
# 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
+/* 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, however we can only undefine this if we
+ * were the ones that made the definition earlier. */
+# ifdef TBB_MIN_MAX_CLEANUP
+# undef NOMINMAX
+# endif
# endif
#endif
diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c
index 91aabca7747..3d4521a3304 100644
--- a/source/blender/blenlib/intern/BLI_args.c
+++ b/source/blender/blenlib/intern/BLI_args.c
@@ -63,6 +63,9 @@ struct bArgs {
int argc;
const char **argv;
int *passes;
+
+ /* Only use when initializing arguments. */
+ int current_pass;
};
static uint case_strhash(const void *ptr)
@@ -108,7 +111,7 @@ static bArgument *lookUp(struct bArgs *ba, const char *arg, int pass, int case_s
return BLI_ghash_lookup(ba->items, &key);
}
-bArgs *BLI_argsInit(int argc, const char **argv)
+bArgs *BLI_args_create(int argc, const char **argv)
{
bArgs *ba = MEM_callocN(sizeof(bArgs), "bArgs");
ba->passes = MEM_callocN(sizeof(int) * argc, "bArgs passes");
@@ -117,10 +120,13 @@ bArgs *BLI_argsInit(int argc, const char **argv)
ba->argc = argc;
ba->argv = argv;
+ /* Must be initialized by #BLI_args_pass_set. */
+ ba->current_pass = 0;
+
return ba;
}
-void BLI_argsFree(struct bArgs *ba)
+void BLI_args_destroy(struct bArgs *ba)
{
BLI_ghash_free(ba->items, MEM_freeN, MEM_freeN);
MEM_freeN(ba->passes);
@@ -128,7 +134,13 @@ void BLI_argsFree(struct bArgs *ba)
MEM_freeN(ba);
}
-void BLI_argsPrint(struct bArgs *ba)
+void BLI_args_pass_set(struct bArgs *ba, int current_pass)
+{
+ BLI_assert((current_pass != 0) && (current_pass >= -1));
+ ba->current_pass = current_pass;
+}
+
+void BLI_args_print(struct bArgs *ba)
{
int i;
for (i = 0; i < ba->argc; i++) {
@@ -136,11 +148,6 @@ void BLI_argsPrint(struct bArgs *ba)
}
}
-const char **BLI_argsArgv(struct bArgs *ba)
-{
- return ba->argv;
-}
-
static bArgDoc *internalDocs(struct bArgs *ba,
const char *short_arg,
const char *long_arg,
@@ -163,14 +170,10 @@ static bArgDoc *internalDocs(struct bArgs *ba,
return d;
}
-static void internalAdd(struct bArgs *ba,
- const char *arg,
- int pass,
- int case_str,
- BA_ArgCallback cb,
- void *data,
- bArgDoc *d)
+static void internalAdd(
+ struct bArgs *ba, const char *arg, int case_str, BA_ArgCallback cb, void *data, bArgDoc *d)
{
+ const int pass = ba->current_pass;
bArgument *a;
bAKey *key;
@@ -203,36 +206,34 @@ static void internalAdd(struct bArgs *ba,
BLI_ghash_insert(ba->items, key, a);
}
-void BLI_argsAddCase(struct bArgs *ba,
- int pass,
- const char *short_arg,
- int short_case,
- const char *long_arg,
- int long_case,
- const char *doc,
- BA_ArgCallback cb,
- void *data)
+void BLI_args_add_case(struct bArgs *ba,
+ const char *short_arg,
+ int short_case,
+ const char *long_arg,
+ int long_case,
+ const char *doc,
+ BA_ArgCallback cb,
+ void *data)
{
bArgDoc *d = internalDocs(ba, short_arg, long_arg, doc);
if (short_arg) {
- internalAdd(ba, short_arg, pass, short_case, cb, data, d);
+ internalAdd(ba, short_arg, short_case, cb, data, d);
}
if (long_arg) {
- internalAdd(ba, long_arg, pass, long_case, cb, data, d);
+ internalAdd(ba, long_arg, long_case, cb, data, d);
}
}
-void BLI_argsAdd(struct bArgs *ba,
- int pass,
- const char *short_arg,
- const char *long_arg,
- const char *doc,
- BA_ArgCallback cb,
- void *data)
+void BLI_args_add(struct bArgs *ba,
+ const char *short_arg,
+ const char *long_arg,
+ const char *doc,
+ BA_ArgCallback cb,
+ void *data)
{
- BLI_argsAddCase(ba, pass, short_arg, 0, long_arg, 0, doc, cb, data);
+ BLI_args_add_case(ba, short_arg, 0, long_arg, 0, doc, cb, data);
}
static void internalDocPrint(bArgDoc *d)
@@ -250,7 +251,7 @@ static void internalDocPrint(bArgDoc *d)
printf(" %s\n\n", d->documentation);
}
-void BLI_argsPrintArgDoc(struct bArgs *ba, const char *arg)
+void BLI_args_print_arg_doc(struct bArgs *ba, const char *arg)
{
bArgument *a = lookUp(ba, arg, -1, -1);
@@ -263,7 +264,7 @@ void BLI_argsPrintArgDoc(struct bArgs *ba, const char *arg)
}
}
-void BLI_argsPrintOtherDoc(struct bArgs *ba)
+void BLI_args_print_other_doc(struct bArgs *ba)
{
bArgDoc *d;
@@ -274,8 +275,9 @@ void BLI_argsPrintOtherDoc(struct bArgs *ba)
}
}
-void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
+void BLI_args_parse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
{
+ BLI_assert((pass != 0) && (pass >= -1));
int i = 0;
for (i = 1; i < ba->argc; i++) { /* skip argv[0] */
diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c
index d20f0ce49d0..a221820d4c4 100644
--- a/source/blender/blenlib/intern/BLI_heap.c
+++ b/source/blender/blenlib/intern/BLI_heap.c
@@ -67,6 +67,7 @@ struct Heap {
} nodes;
};
+/* -------------------------------------------------------------------- */
/** \name Internal Functions
* \{ */
@@ -146,6 +147,7 @@ static void heap_up(Heap *heap, uint i)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Internal Memory Management
* \{ */
@@ -187,6 +189,7 @@ static void heap_node_free(Heap *heap, HeapNode *node)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Public Heap API
* \{ */
diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c
index a6a0c21b104..847cb42186a 100644
--- a/source/blender/blenlib/intern/array_store.c
+++ b/source/blender/blenlib/intern/array_store.c
@@ -112,6 +112,7 @@
/* only for BLI_array_store_is_valid */
#include "BLI_ghash.h"
+/* -------------------------------------------------------------------- */
/** \name Defines
*
* Some of the logic for merging is quite involved,
@@ -206,6 +207,7 @@
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Internal Structs
* \{ */
@@ -313,6 +315,7 @@ typedef struct BTableRef {
static size_t bchunk_list_size(const BChunkList *chunk_list);
+/* -------------------------------------------------------------------- */
/** \name Internal BChunk API
* \{ */
@@ -360,6 +363,7 @@ static bool bchunk_data_compare(const BChunk *chunk,
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Internal BChunkList API
* \{ */
@@ -732,10 +736,11 @@ static void bchunk_list_fill_from_array(const BArrayInfo *info,
/** \} */
-/* ---------------------------------------------------------------------------
+/*
* Internal Table Lookup Functions
*/
+/* -------------------------------------------------------------------- */
/** \name Internal Hashing/De-Duplication API
*
* Only used by #bchunk_list_from_data_merge
@@ -1005,6 +1010,7 @@ static const BChunkRef *table_lookup(const BArrayInfo *info,
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Main Data De-Duplication Function
*
* \{ */
@@ -1307,7 +1313,7 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info,
ASSERT_CHUNKLIST_DATA(chunk_list, data);
/* its likely that the next chunk in the list will be a match, so check it! */
- while ((cref_found->next != NULL) && (cref_found->next != chunk_list_reference_last)) {
+ while (!ELEM(cref_found->next, NULL, chunk_list_reference_last)) {
cref_found = cref_found->next;
BChunk *chunk_found = cref_found->link;
@@ -1390,6 +1396,7 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info,
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Main Array Storage API
* \{ */
@@ -1405,7 +1412,7 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info,
*
* \param chunk_count: Number of elements to split each chunk into.
* - A small value increases the ability to de-duplicate chunks,
- * but adds overhead by increasing the number of chunks to look-up when searching for duplicates,
+ * but adds overhead by increasing the number of chunks to look up when searching for duplicates,
* as well as some overhead constructing the original array again, with more calls to ``memcpy``.
* - Larger values reduce the *book keeping* overhead,
* but increase the chance a small,
@@ -1496,6 +1503,7 @@ void BLI_array_store_clear(BArrayStore *bs)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name BArrayStore Statistics
* \{ */
@@ -1530,6 +1538,7 @@ size_t BLI_array_store_calc_size_compacted_get(const BArrayStore *bs)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name BArrayState Access
* \{ */
@@ -1653,6 +1662,7 @@ void *BLI_array_store_state_data_get_alloc(BArrayState *state, size_t *r_data_le
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Debugging API (for testing).
* \{ */
diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c
index 250a3fdf21b..9840dc77148 100644
--- a/source/blender/blenlib/intern/boxpack_2d.c
+++ b/source/blender/blenlib/intern/boxpack_2d.c
@@ -97,6 +97,7 @@ BLI_INLINE int quad_flag(uint q)
#define TL 2
#define BR 3
+/* -------------------------------------------------------------------- */
/** \name Box Accessor Functions
* \{ */
@@ -121,6 +122,7 @@ static float box_ymax_get(const BoxPack *box)
}
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Box Placement
* \{ */
@@ -165,6 +167,7 @@ static void box_ymax_set(BoxPack *box, const float f)
}
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Box Utils
* \{ */
@@ -203,6 +206,7 @@ static void vert_bias_update(BoxVert *v)
printf("\tBox Debug i %i, w:%.3f h:%.3f x:%.3f y:%.3f\n", b->index, b->w, b->h, b->x, b->y)
#endif
+/* -------------------------------------------------------------------- */
/** \name Box/Vert Sorting
* \{ */
diff --git a/source/blender/blenlib/intern/convexhull_2d.c b/source/blender/blenlib/intern/convexhull_2d.c
index 6e4a8623077..a3d24787d27 100644
--- a/source/blender/blenlib/intern/convexhull_2d.c
+++ b/source/blender/blenlib/intern/convexhull_2d.c
@@ -37,6 +37,7 @@
* http://softsurfer.com/Archive/algorithm_0203/algorithm_0203.htm
*/
+/* -------------------------------------------------------------------- */
/** \name Main Convex-Hull Calculation
* \{ */
@@ -227,9 +228,9 @@ int BLI_convexhull_2d(const float (*points)[2], const int n, int r_points[])
/** \} */
-/* -------------------------------------------------------------------- */
/* Helper functions */
+/* -------------------------------------------------------------------- */
/** \name Utility Convex-Hull Functions
* \{ */
diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc
index ac3662284d0..daa006fd5cc 100644
--- a/source/blender/blenlib/intern/delaunay_2d.cc
+++ b/source/blender/blenlib/intern/delaunay_2d.cc
@@ -654,12 +654,12 @@ template<typename T> inline bool is_border_edge(const CDTEdge<T> *e, const CDT_s
template<typename T> inline bool is_constrained_edge(const CDTEdge<T> *e)
{
- return e->input_ids != NULL;
+ return e->input_ids != nullptr;
}
template<typename T> inline bool is_deleted_edge(const CDTEdge<T> *e)
{
- return e->symedges[0].next == NULL;
+ return e->symedges[0].next == nullptr;
}
template<typename T> inline bool is_original_vert(const CDTVert<T> *v, CDT_state<T> *cdt)
@@ -1308,8 +1308,8 @@ template<typename T> inline int tri_orient(const SymEdge<T> *t)
* For case (a), 'vert' will be the vertex, and lambda will be 0, and 'in' will be the #SymEdge
* from 'vert' that has as face the one that you go through to get to this vertex. If you go
* exactly along an edge then we set 'in' to NULL, since it won't be needed. The first crossing
- * will have 'in' = NULL. We set 'out' to the #SymEdge that has the face we go through to get to the
- * next crossing, or, if the next crossing is a case (a), then it is the edge that goes to that
+ * will have 'in' = NULL. We set 'out' to the #SymEdge that has the face we go through to get to
+ * the next crossing, or, if the next crossing is a case (a), then it is the edge that goes to that
* next vertex. 'out' will be NULL for the last one.
*
* For case (b), vert will be NULL at first, and later filled in with the created split vertex,
@@ -1386,8 +1386,8 @@ void fill_crossdata_for_through_vert(CDTVert<T> *v,
cd_next->lambda = T(0);
cd_next->vert = v;
- cd_next->in = NULL;
- cd_next->out = NULL;
+ cd_next->in = nullptr;
+ cd_next->out = nullptr;
if (cd->lambda == 0) {
cd->out = cd_out;
}
@@ -1630,10 +1630,10 @@ void add_edge_constraint(
if (dbg_level > 0) {
std::cout << "\nADD EDGE CONSTRAINT\n" << vertname(v1) << " " << vertname(v2) << "\n";
}
- LinkNodePair edge_list = {NULL, NULL};
+ LinkNodePair edge_list = {nullptr, nullptr};
if (r_edges) {
- *r_edges = NULL;
+ *r_edges = nullptr;
}
/*
@@ -1648,7 +1648,7 @@ void add_edge_constraint(
if (t != nullptr) {
/* Segment already there. */
add_to_input_ids(&t->edge->input_ids, input_id);
- if (r_edges != NULL) {
+ if (r_edges != nullptr) {
BLI_linklist_append(&edge_list, t->edge);
*r_edges = edge_list.list;
}
@@ -1736,15 +1736,15 @@ void add_edge_constraint(
SymEdge<T> *se;
if (cd_prev->lambda == 0.0) {
se = find_symedge_between_verts(cd_prev->vert, v);
- if (se == NULL) {
+ if (se == nullptr) {
return;
}
cd_prev->out = se;
- cd->in = NULL;
+ cd->in = nullptr;
}
else {
se = find_symedge_with_face(v, sym(cd_prev->in)->face);
- if (se == NULL) {
+ if (se == nullptr) {
return;
}
cd->in = se;
@@ -1783,7 +1783,7 @@ void add_edge_constraint(
if (cd->lambda == -1.0) {
continue; /* This crossing was deleted. */
}
- t = NULL;
+ t = nullptr;
SymEdge<T> *tnext = t;
CDTEdge<T> *edge;
if (cd->lambda != 0.0) {
@@ -1795,7 +1795,7 @@ void add_edge_constraint(
else if (cd->lambda == 0.0) {
t = cd->in;
tnext = cd->out;
- if (t == NULL) {
+ if (t == nullptr) {
/* Previous non-deleted crossing must also have been a vert, and segment should exist. */
int j;
CrossData<T> *cd_prev;
@@ -1809,12 +1809,12 @@ void add_edge_constraint(
BLI_assert(cd_prev->out->next->vert == cd->vert);
edge = cd_prev->out->edge;
add_to_input_ids(&edge->input_ids, input_id);
- if (r_edges != NULL) {
+ if (r_edges != nullptr) {
BLI_linklist_append(&edge_list, edge);
}
}
}
- if (t != NULL) {
+ if (t != nullptr) {
if (tstart->next->vert == t->vert) {
edge = tstart->edge;
}
@@ -1822,7 +1822,7 @@ void add_edge_constraint(
edge = cdt_state->cdt.add_diagonal(tstart, t);
}
add_to_input_ids(&edge->input_ids, input_id);
- if (r_edges != NULL) {
+ if (r_edges != nullptr) {
BLI_linklist_append(&edge_list, edge);
}
/* Now retriangulate upper and lower gaps. */
@@ -1830,7 +1830,7 @@ void add_edge_constraint(
re_delaunay_triangulate(&cdt_state->cdt, &edge->symedges[1]);
}
if (i < ncrossings - 1) {
- if (tnext != NULL) {
+ if (tnext != nullptr) {
tstart = tnext;
}
}
@@ -2008,10 +2008,10 @@ template<typename T> void dissolve_symedge(CDT_state<T> *cdt_state, SymEdge<T> *
se = sym(se);
symse = sym(se);
}
- if (cdt->outer_face->symedge == se || cdt->outer_face->symedge == symse) {
+ if (ELEM(cdt->outer_face->symedge, se, symse)) {
/* Advancing by 2 to get past possible 'sym(se)'. */
if (se->next->next == se) {
- cdt->outer_face->symedge = NULL;
+ cdt->outer_face->symedge = nullptr;
}
else {
cdt->outer_face->symedge = se->next->next;
@@ -2177,9 +2177,9 @@ template<typename T> void remove_outer_edges_until_constraints(CDT_state<T> *cdt
}
se = se->next;
} while (se != se_start);
- while (to_dissolve != NULL) {
+ while (to_dissolve != nullptr) {
se = static_cast<SymEdge<T> *>(BLI_linklist_pop(&to_dissolve));
- if (se->next != NULL) {
+ if (se->next != nullptr) {
dissolve_symedge(cdt_state, se);
}
}
diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c
index 30267661ae7..2bf06371740 100644
--- a/source/blender/blenlib/intern/math_base.c
+++ b/source/blender/blenlib/intern/math_base.c
@@ -79,3 +79,39 @@ double double_round(double x, int ndigits)
/* if computation resulted in overflow, raise OverflowError */
return z;
}
+
+/**
+ * Floor to the nearest power of 10, e.g.:
+ * - 15.0 -> 10.0
+ * - 0.015 -> 0.01
+ * - 1.0 -> 1.0
+ *
+ * \param f: Value to floor, must be over 0.0.
+ * \note If we wanted to support signed values we could if this becomes necessary.
+ */
+float floor_power_of_10(float f)
+{
+ BLI_assert(!(f < 0.0f));
+ if (f != 0.0f) {
+ return 1.0f / (powf(10.0f, ceilf(log10f(1.0f / f))));
+ }
+ return 0.0f;
+}
+
+/**
+ * Ceiling to the nearest power of 10, e.g.:
+ * - 15.0 -> 100.0
+ * - 0.015 -> 0.1
+ * - 1.0 -> 1.0
+ *
+ * \param f: Value to ceiling, must be over 0.0.
+ * \note If we wanted to support signed values we could if this becomes necessary.
+ */
+float ceil_power_of_10(float f)
+{
+ BLI_assert(!(f < 0.0f));
+ if (f != 0.0f) {
+ return 1.0f / (powf(10.0f, floorf(log10f(1.0f / f))));
+ }
+ return 0.0f;
+}
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 1b388dcf11f..8cc5c31a4c7 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -611,7 +611,7 @@ MINLINE int compare_ff_relative(float a, float b, const float max_diff, const in
MINLINE float signf(float f)
{
- return (f < 0.f) ? -1.f : 1.f;
+ return (f < 0.0f) ? -1.0f : 1.0f;
}
MINLINE float compatible_signf(float f)
diff --git a/source/blender/blenlib/intern/math_boolean.cc b/source/blender/blenlib/intern/math_boolean.cc
index f8bf8676f50..a345bc1d0af 100644
--- a/source/blender/blenlib/intern/math_boolean.cc
+++ b/source/blender/blenlib/intern/math_boolean.cc
@@ -470,7 +470,7 @@ void exactinit()
}
every_other = !every_other;
check = 1.0 + epsilon;
- } while ((check != 1.0) && (check != lastcheck));
+ } while (!ELEM(check, 1.0, lastcheck));
splitter += 1.0;
/* Error bounds for orientation and #incircle tests. */
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index 85aabbb672a..1264620cf36 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -261,6 +261,7 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack)
r_col[2] = ((pack) >> 16) & 0xFF;
}
+/* -------------------------------------------------------------------- */
/** \name RGB/Grayscale Functions
*
* \warning
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 2f913a294e0..2b0018e7662 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1418,7 +1418,7 @@ int isect_seg_seg_v2_lambda_mu_db(const double v1[2],
/**
* \param l1, l2: Coordinates (point of line).
- * \param sp, r: Coordinate and radius (sphere).
+ * \param sp, r: Coordinate and radius (sphere).
* \return r_p1, r_p2: Intersection coordinates.
*
* \note The order of assignment for intersection points (\a r_p1, \a r_p2) is predictable,
@@ -2298,6 +2298,81 @@ bool isect_plane_plane_v3(const float plane_a[4],
}
/**
+ * Intersect all planes, calling `callback_fn` for each point that intersects
+ * 3 of the planes that isn't outside any of the other planes.
+ *
+ * This can be thought of as calculating a convex-hull from an array of planes.
+ *
+ * \param eps_coplanar: Epsilon for testing if two planes are aligned (co-planar).
+ * \param eps_isect: Epsilon for testing of a point is behind any of the planes.
+ *
+ * \warning As complexity is a little under `O(N^3)`, this is only suitable for small arrays.
+ *
+ * \note This function could be optimized by some spatial structure.
+ */
+bool isect_planes_v3_fn(
+ const float planes[][4],
+ const int planes_len,
+ const float eps_coplanar,
+ const float eps_isect,
+ void (*callback_fn)(const float co[3], int i, int j, int k, void *user_data),
+ void *user_data)
+{
+ bool found = false;
+
+ float n1n2[3], n2n3[3], n3n1[3];
+
+ for (int i = 0; i < planes_len; i++) {
+ const float *n1 = planes[i];
+ for (int j = i + 1; j < planes_len; j++) {
+ const float *n2 = planes[j];
+ cross_v3_v3v3(n1n2, n1, n2);
+ if (len_squared_v3(n1n2) <= eps_coplanar) {
+ continue;
+ }
+ for (int k = j + 1; k < planes_len; k++) {
+ const float *n3 = planes[k];
+ cross_v3_v3v3(n2n3, n2, n3);
+ if (len_squared_v3(n2n3) <= eps_coplanar) {
+ continue;
+ }
+
+ cross_v3_v3v3(n3n1, n3, n1);
+ if (len_squared_v3(n3n1) <= eps_coplanar) {
+ continue;
+ }
+ const float quotient = -dot_v3v3(n1, n2n3);
+ if (fabsf(quotient) < eps_coplanar) {
+ continue;
+ }
+ const float co_test[3] = {
+ ((n2n3[0] * n1[3]) + (n3n1[0] * n2[3]) + (n1n2[0] * n3[3])) / quotient,
+ ((n2n3[1] * n1[3]) + (n3n1[1] * n2[3]) + (n1n2[1] * n3[3])) / quotient,
+ ((n2n3[2] * n1[3]) + (n3n1[2] * n2[3]) + (n1n2[2] * n3[3])) / quotient,
+ };
+ int i_test;
+ for (i_test = 0; i_test < planes_len; i_test++) {
+ const float *np_test = planes[i_test];
+ if (((dot_v3v3(np_test, co_test) + np_test[3]) > eps_isect)) {
+ /* For low epsilon values the point could intersect it's own plane. */
+ if (!ELEM(i_test, i, j, k)) {
+ break;
+ }
+ }
+ }
+
+ if (i_test == planes_len) { /* ok */
+ callback_fn(co_test, i, j, k, user_data);
+ found = true;
+ }
+ }
+ }
+ }
+
+ return found;
+}
+
+/**
* Intersect two triangles.
*
* \param r_i1, r_i2: Retrieve the overlapping edge between the 2 triangles.
@@ -4181,6 +4256,7 @@ int interp_sparse_array(float *array, const int list_size, const float skipval)
return 1;
}
+/* -------------------------------------------------------------------- */
/** \name interp_weights_poly_v2, v3
* \{ */
@@ -5496,7 +5572,7 @@ void vcloud_estimate_transform_v3(const int list_size,
stunt[1] = q[1][1];
stunt[2] = q[2][2];
/* renormalizing for numeric stability */
- mul_m3_fl(q, 1.f / len_v3(stunt));
+ mul_m3_fl(q, 1.0f / len_v3(stunt));
/* this is pretty much Polardecompose 'inline' the algo based on Higham's thesis */
/* without the far case ... but seems to work here pretty neat */
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c
index 13a1816f1bd..3cec3db9806 100644
--- a/source/blender/blenlib/intern/math_interp.c
+++ b/source/blender/blenlib/intern/math_interp.c
@@ -517,7 +517,7 @@ void BLI_bilinear_interpolation_wrap_char(const unsigned char *buffer,
* otherwise at high texture magnifications circular artifacts are visible. */
#define EWA_MAXIDX 255
const float EWA_WTS[EWA_MAXIDX + 1] = {
- 1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f,
+ 1.0f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f,
0.938216f, 0.929664f, 0.921178f, 0.912759f, 0.904405f, 0.896117f, 0.887893f,
0.879734f, 0.871638f, 0.863605f, 0.855636f, 0.847728f, 0.839883f, 0.832098f,
0.824375f, 0.816712f, 0.809108f, 0.801564f, 0.794079f, 0.786653f, 0.779284f,
@@ -553,7 +553,7 @@ const float EWA_WTS[EWA_MAXIDX + 1] = {
0.0324175f, 0.0309415f, 0.029477f, 0.0280239f, 0.0265822f, 0.0251517f, 0.0237324f,
0.0223242f, 0.020927f, 0.0195408f, 0.0181653f, 0.0168006f, 0.0154466f, 0.0141031f,
0.0127701f, 0.0114476f, 0.0101354f, 0.00883339f, 0.00754159f, 0.00625989f, 0.00498819f,
- 0.00372644f, 0.00247454f, 0.00123242f, 0.f,
+ 0.00372644f, 0.00247454f, 0.00123242f, 0.0f,
};
static void radangle2imp(float a2, float b2, float th, float *A, float *B, float *C, float *F)
@@ -625,7 +625,7 @@ void BLI_ewa_filter(const int width,
* Use a different radius based on interpolation switch,
* just enough to anti-alias when interpolation is off,
* and slightly larger to make result a bit smoother than bilinear interpolation when
- * interpolation is on (minimum values: const float rmin = intpol ? 1.f : 0.5f;) */
+ * interpolation is on (minimum values: const float rmin = intpol ? 1.0f : 0.5f;) */
const float rmin = (intpol ? 1.5625f : 0.765625f) / ff2;
BLI_ewa_imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
if ((b2 = b * b) < rmin) {
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 656f37c9f18..6b5efc3f8c4 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -274,7 +274,7 @@ void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4])
{
- BLI_assert(R != A && R != B);
+ BLI_assert(!ELEM(R, A, B));
/* matrix product: R[j][k] = A[j][i] . B[i][k] */
#ifdef __SSE2__
@@ -319,7 +319,7 @@ void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4])
void mul_m4_m4m4_db_uniq(double R[4][4], const double A[4][4], const double B[4][4])
{
- BLI_assert(R != A && R != B);
+ BLI_assert(!ELEM(R, A, B));
/* matrix product: R[j][k] = A[j][i] . B[i][k] */
@@ -347,7 +347,7 @@ void mul_m4_m4m4_db_uniq(double R[4][4], const double A[4][4], const double B[4]
void mul_m4db_m4db_m4fl_uniq(double R[4][4], const double A[4][4], const float B[4][4])
{
/* Remove second check since types don't match. */
- BLI_assert(R != A /* && R != B */);
+ BLI_assert(!ELEM(R, A /*, B */));
/* matrix product: R[j][k] = A[j][i] . B[i][k] */
@@ -419,7 +419,7 @@ void mul_m3_m3_post(float R[3][3], const float B[3][3])
void mul_m3_m3m3_uniq(float R[3][3], const float A[3][3], const float B[3][3])
{
- BLI_assert(R != A && R != B);
+ BLI_assert(!ELEM(R, A, B));
R[0][0] = B[0][0] * A[0][0] + B[0][1] * A[1][0] + B[0][2] * A[2][0];
R[0][1] = B[0][0] * A[0][1] + B[0][1] * A[1][1] + B[0][2] * A[2][1];
@@ -535,8 +535,10 @@ void mul_m3_m4m4(float R[3][3], const float A[4][4], const float B[4][4])
R[2][2] = B[2][0] * A[0][2] + B[2][1] * A[1][2] + B[2][2] * A[2][2];
}
+/* -------------------------------------------------------------------- */
/** \name Macro helpers for: mul_m3_series
* \{ */
+
void _va_mul_m3_series_3(float r[3][3], const float m1[3][3], const float m2[3][3])
{
mul_m3_m3m3(r, m1, m2);
@@ -621,8 +623,10 @@ void _va_mul_m3_series_9(float r[3][3],
}
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Macro helpers for: mul_m4_series
* \{ */
+
void _va_mul_m4_series_3(float r[4][4], const float m1[4][4], const float m2[4][4])
{
mul_m4_m4m4(r, m1, m2);
@@ -2219,6 +2223,12 @@ void scale_m4_fl(float R[4][4], float scale)
R[3][0] = R[3][1] = R[3][2] = 0.0;
}
+void translate_m3(float mat[3][3], float tx, float ty)
+{
+ mat[2][0] += (tx * mat[0][0] + ty * mat[1][0]);
+ mat[2][1] += (tx * mat[0][1] + ty * mat[1][1]);
+}
+
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
{
mat[3][0] += (Tx * mat[0][0] + Ty * mat[1][0] + Tz * mat[2][0]);
@@ -2226,6 +2236,18 @@ void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
mat[3][2] += (Tx * mat[0][2] + Ty * mat[1][2] + Tz * mat[2][2]);
}
+void rotate_m3(float mat[3][3], const float angle)
+{
+ const float angle_cos = cosf(angle);
+ const float angle_sin = sinf(angle);
+
+ for (int col = 0; col < 3; col++) {
+ float temp = angle_cos * mat[0][col] + angle_sin * mat[1][col];
+ mat[1][col] = -angle_sin * mat[0][col] + angle_cos * mat[1][col];
+ mat[0][col] = temp;
+ }
+}
+
/* TODO: enum for axis? */
/**
* Rotate a matrix in-place.
@@ -2271,6 +2293,12 @@ void rotate_m4(float mat[4][4], const char axis, const float angle)
}
}
+void rescale_m3(float mat[3][3], const float scale[2])
+{
+ mul_v3_fl(mat[0], scale[0]);
+ mul_v3_fl(mat[1], scale[1]);
+}
+
/** Scale a matrix in-place. */
void rescale_m4(float mat[4][4], const float scale[3])
{
@@ -2301,6 +2329,20 @@ void transform_pivot_set_m4(float mat[4][4], const float pivot[3])
mul_m4_m4m4(mat, mat, tmat);
}
+void transform_pivot_set_m3(float mat[3][3], const float pivot[2])
+{
+ float tmat[3][3];
+
+ unit_m3(tmat);
+
+ copy_v2_v2(tmat[2], pivot);
+ mul_m3_m3m3(mat, tmat, mat);
+
+ /* invert the matrix */
+ negate_v2(tmat[2]);
+ mul_m3_m3m3(mat, mat, tmat);
+}
+
void blend_m3_m3m3(float out[3][3],
const float dst[3][3],
const float src[3][3],
@@ -2481,6 +2523,21 @@ bool equals_m4m4(const float mat1[4][4], const float mat2[4][4])
}
/**
+ * Make a 3x3 matrix out of 3 transform components.
+ * Matrices are made in the order: `loc * rot * scale`
+ */
+void loc_rot_size_to_mat3(float R[3][3],
+ const float loc[2],
+ const float angle,
+ const float size[2])
+{
+ unit_m3(R);
+ translate_m3(R, loc[0], loc[1]);
+ rotate_m3(R, angle);
+ rescale_m3(R, size);
+}
+
+/**
* Make a 4x4 matrix out of 3 transform components.
* Matrices are made in the order: `scale * rot * loc`
*/
@@ -2863,7 +2920,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
if (ks == k) {
break;
}
- t = (ks != p ? fabsf(e[ks]) : 0.f) + (ks != k + 1 ? fabsf(e[ks - 1]) : 0.0f);
+ t = (ks != p ? fabsf(e[ks]) : 0.0f) + (ks != k + 1 ? fabsf(e[ks - 1]) : 0.0f);
if (fabsf(s[ks]) <= eps * t) {
s[ks] = 0.0f;
break;
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 4d7efa4b6f4..5f3297134c6 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -162,6 +162,7 @@ void interp_v2_v2v2_slerp_safe(float target[2], const float a[2], const float b[
}
}
+/* -------------------------------------------------------------------- */
/** \name Cubic curve interpolation (bezier spline).
* \{ */
@@ -1395,6 +1396,7 @@ void copy_vn_fl(float *array_tar, const int size, const float val)
}
}
+/* -------------------------------------------------------------------- */
/** \name Double precision versions 'db'.
* \{ */
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index f6841ef52b0..f17b7535258 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -1288,6 +1288,7 @@ MINLINE bool is_one_v3(const float v[3])
return (v[0] == 1.0f && v[1] == 1.0f && v[2] == 1.0f);
}
+/* -------------------------------------------------------------------- */
/** \name Vector Comparison
*
* \note use ``value <= limit``, so a limit of zero doesn't fail on an exact match.
@@ -1395,6 +1396,7 @@ MINLINE bool compare_size_v3v3(const float v1[3], const float v2[3], const float
return true;
}
+/* -------------------------------------------------------------------- */
/** \name Vector Clamping
* \{ */
diff --git a/source/blender/blenlib/intern/mesh_boolean.cc b/source/blender/blenlib/intern/mesh_boolean.cc
index 82ccbcc91b6..bac1b0665c8 100644
--- a/source/blender/blenlib/intern/mesh_boolean.cc
+++ b/source/blender/blenlib/intern/mesh_boolean.cc
@@ -2853,7 +2853,7 @@ static bool dissolve_leaves_valid_bmesh(FaceMergeState *fms,
* saying which faces a vertex touches. */
for (int a_v_index = 0; ok && a_v_index < alen; ++a_v_index) {
const Vert *a_v = mf_left.vert[a_v_index];
- if (a_v != me.v1 && a_v != me.v2) {
+ if (!ELEM(a_v, me.v1, me.v2)) {
for (int b_v_index = 0; b_v_index < blen; ++b_v_index) {
const Vert *b_v = mf_right.vert[b_v_index];
if (a_v == b_v) {
diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc
index 785e405b482..4eff3c52e63 100644
--- a/source/blender/blenlib/intern/mesh_intersect.cc
+++ b/source/blender/blenlib/intern/mesh_intersect.cc
@@ -24,6 +24,7 @@
# include <algorithm>
# include <fstream>
# include <iostream>
+# include <memory>
# include "BLI_allocator.hh"
# include "BLI_array.hh"
@@ -520,7 +521,7 @@ class IMeshArena::IMeshArenaImpl : NonCopyable, NonMovable {
IMeshArena::IMeshArena()
{
- pimpl_ = std::unique_ptr<IMeshArenaImpl>(new IMeshArenaImpl());
+ pimpl_ = std::make_unique<IMeshArenaImpl>();
}
IMeshArena::~IMeshArena()
@@ -695,7 +696,7 @@ void IMesh::remove_null_faces()
{
int64_t nullcount = 0;
for (Face *f : this->face_) {
- if (f == NULL) {
+ if (f == nullptr) {
++nullcount;
}
}
@@ -2054,12 +2055,12 @@ class TriOverlaps {
if (two_trees_no_self) {
BLI_bvhtree_balance(tree_b_);
/* Don't expect a lot of trivial intersects in this case. */
- overlap_ = BLI_bvhtree_overlap(tree_, tree_b_, &overlap_tot_, NULL, NULL);
+ overlap_ = BLI_bvhtree_overlap(tree_, tree_b_, &overlap_tot_, nullptr, nullptr);
}
else {
CBData cbdata{tm, shape_fn, nshapes, use_self};
if (nshapes == 1) {
- overlap_ = BLI_bvhtree_overlap(tree_, tree_, &overlap_tot_, NULL, NULL);
+ overlap_ = BLI_bvhtree_overlap(tree_, tree_, &overlap_tot_, nullptr, nullptr);
}
else {
overlap_ = BLI_bvhtree_overlap(
@@ -2231,8 +2232,7 @@ struct SubdivideTrisData {
tm(tm),
itt_map(itt_map),
overlap(overlap),
- arena(arena),
- overlap_tri_range{}
+ arena(arena)
{
}
};
@@ -2365,7 +2365,7 @@ static CDT_data calc_cluster_subdivided(const CoplanarClusterInfo &clinfo,
std::pair<int, int> key = canon_int_pair(t, t_other);
if (itt_map.contains(key)) {
ITT_value itt = itt_map.lookup(key);
- if (itt.kind != INONE && itt.kind != ICOPLANAR) {
+ if (!ELEM(itt.kind, INONE, ICOPLANAR)) {
itts.append(itt);
if (dbg_level > 0) {
std::cout << " itt = " << itt << "\n";
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index 1ae1c91a3bd..4ba533c72aa 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -24,7 +24,9 @@
#include <math.h>
#include "BLI_compiler_compat.h"
-#include "BLI_noise.h"
+#include "BLI_sys_types.h"
+
+#include "BLI_noise.h" /* Own include. */
/* local */
static float noise3_perlin(const float vec[3]);
@@ -319,7 +321,8 @@ static float newPerlin(float x, float y, float z)
lerp(u, grad(hash[AB + 1], x, y - 1, z - 1), grad(hash[BB + 1], x - 1, y - 1, z - 1))));
}
-/* for use with BLI_gNoise()/BLI_gTurbulence(), returns unsigned improved perlin noise */
+/* for use with BLI_noise_generic_noise()/BLI_noise_generic_turbulence(), returns unsigned improved
+ * perlin noise */
static float newPerlinU(float x, float y, float z)
{
return (0.5f + 0.5f * newPerlin(x, y, z));
@@ -329,7 +332,7 @@ static float newPerlinU(float x, float y, float z)
/* END OF IMPROVED PERLIN */
/**************************/
-/* Was BLI_hnoise(), removed noisesize, so other functions can call it without scaling. */
+/* Was BLI_noise_hnoise(), removed noisesize, so other functions can call it without scaling. */
static float orgBlenderNoise(float x, float y, float z)
{
float cn1, cn2, cn3, cn4, cn5, cn6, i;
@@ -425,7 +428,7 @@ static float orgBlenderNoiseS(float x, float y, float z)
}
/* separated from orgBlenderNoise above, with scaling */
-float BLI_hnoise(float noisesize, float x, float y, float z)
+float BLI_noise_hnoise(float noisesize, float x, float y, float z)
{
if (noisesize == 0.0f) {
return 0.0f;
@@ -437,32 +440,15 @@ float BLI_hnoise(float noisesize, float x, float y, float z)
}
/* original turbulence functions */
-float BLI_turbulence(float noisesize, float x, float y, float z, int nr)
-{
- float s, d = 0.5, div = 1.0;
-
- s = BLI_hnoise(noisesize, x, y, z);
-
- while (nr > 0) {
-
- s += d * BLI_hnoise(noisesize * d, x, y, z);
- div += d;
- d *= 0.5f;
-
- nr--;
- }
- return s / div;
-}
-
-float BLI_turbulence1(float noisesize, float x, float y, float z, int nr)
+float BLI_noise_turbulence(float noisesize, float x, float y, float z, int nr)
{
float s, d = 0.5, div = 1.0;
- s = fabsf((-1.0f + 2.0f * BLI_hnoise(noisesize, x, y, z)));
+ s = BLI_noise_hnoise(noisesize, x, y, z);
while (nr > 0) {
- s += fabsf(d * (-1.0f + 2.0f * BLI_hnoise(noisesize * d, x, y, z)));
+ s += d * BLI_noise_hnoise(noisesize * d, x, y, z);
div += d;
d *= 0.5f;
@@ -786,14 +772,13 @@ static float noise3_perlin(const float vec[3])
int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;
float rx0, rx1, ry0, ry1, rz0, rz1, sx, sy, sz, a, b, c, d, t, u, v;
const float *q;
- int i, j;
SETUP(vec[0], bx0, bx1, rx0, rx1);
SETUP(vec[1], by0, by1, ry0, ry1);
SETUP(vec[2], bz0, bz1, rz0, rz1);
- i = p[bx0];
- j = p[bx1];
+ int i = p[bx0];
+ int j = p[bx1];
b00 = p[i + by0];
b10 = p[j + by0];
@@ -843,31 +828,23 @@ static float noise3_perlin(const float vec[3])
#undef SURVE
}
-/* for use with BLI_gNoise/gTurbulence, returns signed noise */
+/* for use with BLI_noise_generic_noise/gTurbulence, returns signed noise */
static float orgPerlinNoise(float x, float y, float z)
{
- float v[3];
-
- v[0] = x;
- v[1] = y;
- v[2] = z;
+ float v[3] = {x, y, z};
return noise3_perlin(v);
}
-/* for use with BLI_gNoise/gTurbulence, returns unsigned noise */
+/* for use with BLI_noise_generic_noise/gTurbulence, returns unsigned noise */
static float orgPerlinNoiseU(float x, float y, float z)
{
- float v[3];
-
- v[0] = x;
- v[1] = y;
- v[2] = z;
+ float v[3] = {x, y, z};
return (0.5f + 0.5f * noise3_perlin(v));
}
/* *************** CALL AS: *************** */
-float BLI_hnoisep(float noisesize, float x, float y, float z)
+float BLI_noise_hnoisep(float noisesize, float x, float y, float z)
{
float vec[3];
@@ -906,13 +883,12 @@ static float dist_Manhattan(float x, float y, float z, float e)
/* Chebychev */
static float dist_Chebychev(float x, float y, float z, float e)
{
- float t;
(void)e;
x = fabsf(x);
y = fabsf(y);
z = fabsf(z);
- t = (x > y) ? x : y;
+ float t = (x > y) ? x : y;
return ((z > t) ? z : t);
}
@@ -942,11 +918,8 @@ static float dist_Minkovsky(float x, float y, float z, float e)
/* Not 'pure' Worley, but the results are virtually the same.
* Returns distances in da and point coords in pa */
-void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
+void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
{
- int xx, yy, zz, xi, yi, zi;
- float xd, yd, zd, d;
-
float (*distfunc)(float, float, float, float);
switch (dtype) {
case 1:
@@ -973,18 +946,18 @@ void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtyp
break;
}
- xi = (int)(floor(x));
- yi = (int)(floor(y));
- zi = (int)(floor(z));
+ int xi = (int)(floor(x));
+ int yi = (int)(floor(y));
+ int zi = (int)(floor(z));
da[0] = da[1] = da[2] = da[3] = 1e10f;
- for (xx = xi - 1; xx <= xi + 1; xx++) {
- for (yy = yi - 1; yy <= yi + 1; yy++) {
- for (zz = zi - 1; zz <= zi + 1; zz++) {
+ for (int xx = xi - 1; xx <= xi + 1; xx++) {
+ for (int yy = yi - 1; yy <= yi + 1; yy++) {
+ for (int zz = zi - 1; zz <= zi + 1; zz++) {
const float *p = HASHPNT(xx, yy, zz);
- xd = x - (p[0] + xx);
- yd = y - (p[1] + yy);
- zd = z - (p[2] + zz);
- d = distfunc(xd, yd, zd, me);
+ float xd = x - (p[0] + xx);
+ float yd = y - (p[1] + yy);
+ float zd = z - (p[2] + zz);
+ float d = distfunc(xd, yd, zd, me);
if (d < da[0]) {
da[3] = da[2];
da[2] = da[1];
@@ -1038,39 +1011,39 @@ void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtyp
}
}
-/* returns different feature points for use in BLI_gNoise() */
+/* returns different feature points for use in BLI_noise_generic_noise() */
static float voronoi_F1(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return da[0];
}
static float voronoi_F2(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return da[1];
}
static float voronoi_F3(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return da[2];
}
static float voronoi_F4(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return da[3];
}
static float voronoi_F1F2(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (da[1] - da[0]);
}
@@ -1078,8 +1051,8 @@ static float voronoi_F1F2(float x, float y, float z)
static float voronoi_Cr(float x, float y, float z)
{
float t = 10 * voronoi_F1F2(x, y, z);
- if (t > 1.f) {
- return 1.f;
+ if (t > 1.0f) {
+ return 1.0f;
}
return t;
}
@@ -1090,35 +1063,35 @@ static float voronoi_Cr(float x, float y, float z)
static float voronoi_F1S(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (2.0f * da[0] - 1.0f);
}
static float voronoi_F2S(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (2.0f * da[1] - 1.0f);
}
static float voronoi_F3S(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (2.0f * da[2] - 1.0f);
}
static float voronoi_F4S(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (2.0f * da[3] - 1.0f);
}
static float voronoi_F1F2S(float x, float y, float z)
{
float da[4], pa[12];
- voronoi(x, y, z, da, pa, 1, 0);
+ BLI_noise_voronoi(x, y, z, da, pa, 1, 0);
return (2.0f * (da[1] - da[0]) - 1.0f);
}
@@ -1126,8 +1099,8 @@ static float voronoi_F1F2S(float x, float y, float z)
static float voronoi_CrS(float x, float y, float z)
{
float t = 10 * voronoi_F1F2(x, y, z);
- if (t > 1.f) {
- return 1.f;
+ if (t > 1.0f) {
+ return 1.0f;
}
return (2.0f * t - 1.0f);
}
@@ -1141,7 +1114,7 @@ static float voronoi_CrS(float x, float y, float z)
/*************/
/* returns unsigned cellnoise */
-static float cellNoiseU(float x, float y, float z)
+static float BLI_cellNoiseU(float x, float y, float z)
{
/* avoid precision issues on unit coordinates */
x = (x + 0.000001f) * 1.00001f;
@@ -1157,13 +1130,13 @@ static float cellNoiseU(float x, float y, float z)
}
/* idem, signed */
-float cellNoise(float x, float y, float z)
+float BLI_noise_cell(float x, float y, float z)
{
- return (2.0f * cellNoiseU(x, y, z) - 1.0f);
+ return (2.0f * BLI_cellNoiseU(x, y, z) - 1.0f);
}
/* returns a vector/point/color in ca, using point hasharray directly */
-void cellNoiseV(float x, float y, float z, float ca[3])
+void BLI_noise_cell_v3(float x, float y, float z, float ca[3])
{
/* avoid precision issues on unit coordinates */
x = (x + 0.000001f) * 1.00001f;
@@ -1184,7 +1157,8 @@ void cellNoiseV(float x, float y, float z, float ca[3])
/*****************/
/* newnoise: generic noise function for use with different noisebases */
-float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noisebasis)
+float BLI_noise_generic_noise(
+ float noisesize, float x, float y, float z, bool hard, int noisebasis)
{
float (*noisefunc)(float, float, float);
@@ -1214,12 +1188,12 @@ float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noise
noisefunc = voronoi_Cr;
break;
case 14:
- noisefunc = cellNoiseU;
+ noisefunc = BLI_cellNoiseU;
break;
case 0:
default: {
noisefunc = orgBlenderNoise;
- /* add one to make return value same as BLI_hnoise */
+ /* add one to make return value same as BLI_noise_hnoise */
x += 1;
y += 1;
z += 1;
@@ -1241,13 +1215,10 @@ float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noise
}
/* newnoise: generic turbulence function for use with different noisebasis */
-float BLI_gTurbulence(
- float noisesize, float x, float y, float z, int oct, int hard, int noisebasis)
+float BLI_noise_generic_turbulence(
+ float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
{
float (*noisefunc)(float, float, float);
- float sum, t, amp = 1, fscale = 1;
- int i;
-
switch (noisebasis) {
case 1:
noisefunc = orgPerlinNoiseU;
@@ -1274,7 +1245,7 @@ float BLI_gTurbulence(
noisefunc = voronoi_Cr;
break;
case 14:
- noisefunc = cellNoiseU;
+ noisefunc = BLI_cellNoiseU;
break;
case 0:
default:
@@ -1292,9 +1263,9 @@ float BLI_gTurbulence(
z *= noisesize;
}
- sum = 0;
- for (i = 0; i <= oct; i++, amp *= 0.5f, fscale *= 2.0f) {
- t = noisefunc(fscale * x, fscale * y, fscale * z);
+ float sum = 0, amp = 1, fscale = 1;
+ for (int i = 0; i <= oct; i++, amp *= 0.5f, fscale *= 2.0f) {
+ float t = noisefunc(fscale * x, fscale * y, fscale * z);
if (hard) {
t = fabsf(2.0f * t - 1.0f);
}
@@ -1319,11 +1290,9 @@ float BLI_gTurbulence(
* ``lacunarity'' is the gap between successive frequencies
* ``octaves'' is the number of frequencies in the fBm
*/
-float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
+float BLI_noise_mg_fbm(
+ float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
{
- float rmd, value = 0.0, pwr = 1.0, pwHL = powf(lacunarity, -H);
- int i;
-
float (*noisefunc)(float, float, float);
switch (noisebasis) {
case 1:
@@ -1351,7 +1320,7 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
noisefunc = voronoi_CrS;
break;
case 14:
- noisefunc = cellNoise;
+ noisefunc = BLI_noise_cell;
break;
case 0:
default: {
@@ -1360,7 +1329,8 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
}
}
- for (i = 0; i < (int)octaves; i++) {
+ float value = 0.0, pwr = 1.0, pwHL = powf(lacunarity, -H);
+ for (int i = 0; i < (int)octaves; i++) {
value += noisefunc(x, y, z) * pwr;
pwr *= pwHL;
x *= lacunarity;
@@ -1368,7 +1338,7 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
z *= lacunarity;
}
- rmd = octaves - floorf(octaves);
+ float rmd = octaves - floorf(octaves);
if (rmd != 0.0f) {
value += rmd * noisefunc(x, y, z) * pwr;
}
@@ -1391,12 +1361,9 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
/* this one is in fact rather confusing,
* there seem to be errors in the original source code (in all three versions of proc.text&mod),
* I modified it to something that made sense to me, so it might be wrong... */
-float mg_MultiFractal(
+float BLI_noise_mg_multi_fractal(
float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
{
- float rmd, value = 1.0, pwr = 1.0, pwHL = powf(lacunarity, -H);
- int i;
-
float (*noisefunc)(float, float, float);
switch (noisebasis) {
case 1:
@@ -1424,7 +1391,7 @@ float mg_MultiFractal(
noisefunc = voronoi_CrS;
break;
case 14:
- noisefunc = cellNoise;
+ noisefunc = BLI_noise_cell;
break;
case 0:
default: {
@@ -1433,14 +1400,15 @@ float mg_MultiFractal(
}
}
- for (i = 0; i < (int)octaves; i++) {
+ float value = 1.0, pwr = 1.0, pwHL = powf(lacunarity, -H);
+ for (int i = 0; i < (int)octaves; i++) {
value *= (pwr * noisefunc(x, y, z) + 1.0f);
pwr *= pwHL;
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;
}
- rmd = octaves - floorf(octaves);
+ float rmd = octaves - floorf(octaves);
if (rmd != 0.0f) {
value *= (rmd * noisefunc(x, y, z) * pwr + 1.0f);
}
@@ -1459,20 +1427,15 @@ float mg_MultiFractal(
* ``octaves'' is the number of frequencies in the fBm
* ``offset'' raises the terrain from `sea level'
*/
-float mg_HeteroTerrain(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- int noisebasis)
+float BLI_noise_mg_hetero_terrain(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ int noisebasis)
{
- float value, increment, rmd;
- int i;
- float pwHL = powf(lacunarity, -H);
- float pwr = pwHL; /* starts with i=1 instead of 0 */
-
float (*noisefunc)(float, float, float);
switch (noisebasis) {
case 1:
@@ -1500,7 +1463,7 @@ float mg_HeteroTerrain(float x,
noisefunc = voronoi_CrS;
break;
case 14:
- noisefunc = cellNoise;
+ noisefunc = BLI_noise_cell;
break;
case 0:
default: {
@@ -1510,13 +1473,15 @@ float mg_HeteroTerrain(float x,
}
/* first unscaled octave of function; later octaves are scaled */
- value = offset + noisefunc(x, y, z);
+ float value = offset + noisefunc(x, y, z);
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;
- for (i = 1; i < (int)octaves; i++) {
- increment = (noisefunc(x, y, z) + offset) * pwr * value;
+ float pwHL = powf(lacunarity, -H);
+ float pwr = pwHL; /* starts with i=1 instead of 0 */
+ for (int i = 1; i < (int)octaves; i++) {
+ float increment = (noisefunc(x, y, z) + offset) * pwr * value;
value += increment;
pwr *= pwHL;
x *= lacunarity;
@@ -1524,9 +1489,9 @@ float mg_HeteroTerrain(float x,
z *= lacunarity;
}
- rmd = octaves - floorf(octaves);
+ float rmd = octaves - floorf(octaves);
if (rmd != 0.0f) {
- increment = (noisefunc(x, y, z) + offset) * pwr * value;
+ float increment = (noisefunc(x, y, z) + offset) * pwr * value;
value += rmd * increment;
}
return value;
@@ -1539,22 +1504,17 @@ float mg_HeteroTerrain(float x,
* H: 0.25
* offset: 0.7
*/
-float mg_HybridMultiFractal(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- float gain,
- int noisebasis)
+float BLI_noise_mg_hybrid_multi_fractal(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ float gain,
+ int noisebasis)
{
- float result, signal, weight, rmd;
- int i;
- float pwHL = powf(lacunarity, -H);
- float pwr = pwHL; /* starts with i=1 instead of 0 */
float (*noisefunc)(float, float, float);
-
switch (noisebasis) {
case 1:
noisefunc = orgPerlinNoise;
@@ -1581,7 +1541,7 @@ float mg_HybridMultiFractal(float x,
noisefunc = voronoi_CrS;
break;
case 14:
- noisefunc = cellNoise;
+ noisefunc = BLI_noise_cell;
break;
case 0:
default: {
@@ -1590,17 +1550,19 @@ float mg_HybridMultiFractal(float x,
}
}
- result = noisefunc(x, y, z) + offset;
- weight = gain * result;
+ float result = noisefunc(x, y, z) + offset;
+ float weight = gain * result;
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;
- for (i = 1; (weight > 0.001f) && (i < (int)octaves); i++) {
+ float pwHL = powf(lacunarity, -H);
+ float pwr = pwHL; /* starts with i=1 instead of 0 */
+ for (int i = 1; (weight > 0.001f) && (i < (int)octaves); i++) {
if (weight > 1.0f) {
weight = 1.0f;
}
- signal = (noisefunc(x, y, z) + offset) * pwr;
+ float signal = (noisefunc(x, y, z) + offset) * pwr;
pwr *= pwHL;
result += weight * signal;
weight *= gain * signal;
@@ -1609,8 +1571,8 @@ float mg_HybridMultiFractal(float x,
z *= lacunarity;
}
- rmd = octaves - floorf(octaves);
- if (rmd != 0.f) {
+ float rmd = octaves - floorf(octaves);
+ if (rmd != 0.0f) {
result += rmd * ((noisefunc(x, y, z) + offset) * pwr);
}
@@ -1626,21 +1588,16 @@ float mg_HybridMultiFractal(float x,
* offset: 1.0
* gain: 2.0
*/
-float mg_RidgedMultiFractal(float x,
- float y,
- float z,
- float H,
- float lacunarity,
- float octaves,
- float offset,
- float gain,
- int noisebasis)
+float BLI_noise_mg_ridged_multi_fractal(float x,
+ float y,
+ float z,
+ float H,
+ float lacunarity,
+ float octaves,
+ float offset,
+ float gain,
+ int noisebasis)
{
- float result, signal, weight;
- int i;
- float pwHL = powf(lacunarity, -H);
- float pwr = pwHL; /* starts with i=1 instead of 0 */
-
float (*noisefunc)(float, float, float);
switch (noisebasis) {
case 1:
@@ -1668,7 +1625,7 @@ float mg_RidgedMultiFractal(float x,
noisefunc = voronoi_CrS;
break;
case 14:
- noisefunc = cellNoise;
+ noisefunc = BLI_noise_cell;
break;
case 0:
default: {
@@ -1677,15 +1634,15 @@ float mg_RidgedMultiFractal(float x,
}
}
- signal = offset - fabsf(noisefunc(x, y, z));
- signal *= signal;
- result = signal;
-
- for (i = 1; i < (int)octaves; i++) {
+ float signal = powf(offset - fabsf(noisefunc(x, y, z)), 2);
+ float result = signal;
+ for (int i = 1; i < (int)octaves; i++) {
+ float pwHL = powf(lacunarity, -H);
+ float pwr = pwHL; /* starts with i=1 instead of 0 */
x *= lacunarity;
y *= lacunarity;
z *= lacunarity;
- weight = signal * gain;
+ float weight = signal * gain;
if (weight > 1.0f) {
weight = 1.0f;
}
@@ -1705,12 +1662,10 @@ float mg_RidgedMultiFractal(float x,
/* "Variable Lacunarity Noise"
* A distorted variety of Perlin noise.
*/
-float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nbas2)
+float BLI_noise_mg_variable_lacunarity(
+ float x, float y, float z, float distortion, int nbas1, int nbas2)
{
- float rv[3];
float (*noisefunc1)(float, float, float);
- float (*noisefunc2)(float, float, float);
-
switch (nbas1) {
case 1:
noisefunc1 = orgPerlinNoise;
@@ -1737,7 +1692,7 @@ float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nba
noisefunc1 = voronoi_CrS;
break;
case 14:
- noisefunc1 = cellNoise;
+ noisefunc1 = BLI_noise_cell;
break;
case 0:
default: {
@@ -1746,6 +1701,7 @@ float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nba
}
}
+ float (*noisefunc2)(float, float, float);
switch (nbas2) {
case 1:
noisefunc2 = orgPerlinNoise;
@@ -1772,7 +1728,7 @@ float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nba
noisefunc2 = voronoi_CrS;
break;
case 14:
- noisefunc2 = cellNoise;
+ noisefunc2 = BLI_noise_cell;
break;
case 0:
default: {
@@ -1782,9 +1738,12 @@ float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nba
}
/* get a random vector and scale the randomization */
- rv[0] = noisefunc1(x + 13.5f, y + 13.5f, z + 13.5f) * distortion;
- rv[1] = noisefunc1(x, y, z) * distortion;
- rv[2] = noisefunc1(x - 13.5f, y - 13.5f, z - 13.5f) * distortion;
+ float rv[3] = {
+ rv[0] = noisefunc1(x + 13.5f, y + 13.5f, z + 13.5f) * distortion,
+ rv[1] = noisefunc1(x, y, z) * distortion,
+ rv[2] = noisefunc1(x - 13.5f, y - 13.5f, z - 13.5f) * distortion,
+ };
+
return noisefunc2(x + rv[0], y + rv[1], z + rv[2]); /* distorted-domain noise */
}
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index bec5f0ab3ba..61e0ec393cb 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -1085,9 +1085,9 @@ void print_rcti(const char *str, const rcti *rect)
BLI_rcti_size_y(rect));
}
-/* -------------------------------------------------------------------- */
/* Comprehensive math (float only) */
+/* -------------------------------------------------------------------- */
/** \name Rect math functions
* \{ */
diff --git a/source/blender/blenlib/intern/scanfill_utils.c b/source/blender/blenlib/intern/scanfill_utils.c
index 660d3dca807..b49239547c2 100644
--- a/source/blender/blenlib/intern/scanfill_utils.c
+++ b/source/blender/blenlib/intern/scanfill_utils.c
@@ -157,14 +157,14 @@ static ScanFillEdge *edge_step(PolyInfo *poly_info,
eed = (e_curr->next && e_curr != poly_info[poly_nr].edge_last) ? e_curr->next :
poly_info[poly_nr].edge_first;
if ((v_curr == eed->v1 || v_curr == eed->v2) == true &&
- (v_prev == eed->v1 || v_prev == eed->v2) == false) {
+ (ELEM(v_prev, eed->v1, eed->v2)) == false) {
return eed;
}
eed = (e_curr->prev && e_curr != poly_info[poly_nr].edge_first) ? e_curr->prev :
poly_info[poly_nr].edge_last;
if ((v_curr == eed->v1 || v_curr == eed->v2) == true &&
- (v_prev == eed->v1 || v_prev == eed->v2) == false) {
+ (ELEM(v_prev, eed->v1, eed->v2)) == false) {
return eed;
}
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index a091b41af23..5961893cae3 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -349,6 +349,7 @@ void **BLI_smallhash_iternew_p(const SmallHash *sh, SmallHashIter *iter, uintptr
return BLI_smallhash_iternext_p(iter, key);
}
+/* -------------------------------------------------------------------- */
/** \name Debugging & Introspection
* \{ */
diff --git a/source/blender/blenlib/intern/sort.c b/source/blender/blenlib/intern/sort.c
index e65be760a2c..6a13c0aa6f0 100644
--- a/source/blender/blenlib/intern/sort.c
+++ b/source/blender/blenlib/intern/sort.c
@@ -45,8 +45,8 @@
*
* \note modified to use glibc arg order for callbacks.
*/
-BLI_INLINE char *med3(char */*a*/, char */*b*/, char */*c*/, BLI_sort_cmp_t /*cmp*/, void */*thunk*/);
-BLI_INLINE void swapfunc(char */*a*/, char */*b*/, int /*n*/, int /*swaptype*/);
+BLI_INLINE char *med3(char *a, char *b, char *c, BLI_sort_cmp_t cmp, void *thunk);
+BLI_INLINE void swapfunc(char *a, char *b, int n, int swaptype);
#define min(a, b) (a) < (b) ? (a) : (b)
#define swapcode(TYPE, parmi, parmj, n) \
diff --git a/source/blender/blenlib/intern/storage_apple.mm b/source/blender/blenlib/intern/storage_apple.mm
index 564ef5a199a..2a4bbffa60e 100644
--- a/source/blender/blenlib/intern/storage_apple.mm
+++ b/source/blender/blenlib/intern/storage_apple.mm
@@ -29,7 +29,7 @@
#include "BLI_path_util.h"
/**
- * \param r_targetpath Buffer for the target path an alias points to.
+ * \param r_targetpath: Buffer for the target path an alias points to.
* \return Whether the file at the input path is an alias.
*/
/* False alarm by clang-tidy: #getFileSystemRepresentation changes the return value argument. */
diff --git a/source/blender/blenlib/intern/task_pool.cc b/source/blender/blenlib/intern/task_pool.cc
index cf328ec407c..1a119e135d5 100644
--- a/source/blender/blenlib/intern/task_pool.cc
+++ b/source/blender/blenlib/intern/task_pool.cc
@@ -83,11 +83,11 @@ class Task {
free_taskdata(other.free_taskdata),
freedata(other.freedata)
{
- other.pool = NULL;
- other.run = NULL;
- other.taskdata = NULL;
+ other.pool = nullptr;
+ other.run = nullptr;
+ other.taskdata = nullptr;
other.free_taskdata = false;
- other.freedata = NULL;
+ other.freedata = nullptr;
}
#if defined(WITH_TBB) && TBB_INTERFACE_VERSION_MAJOR < 10
@@ -302,7 +302,7 @@ static void *background_task_run(void *userdata)
task->~Task();
MEM_freeN(task);
}
- return NULL;
+ return nullptr;
}
static void background_task_pool_create(TaskPool *pool)
diff --git a/source/blender/blenlib/intern/task_range.cc b/source/blender/blenlib/intern/task_range.cc
index 27e0fb0ed07..229129bd088 100644
--- a/source/blender/blenlib/intern/task_range.cc
+++ b/source/blender/blenlib/intern/task_range.cc
@@ -70,7 +70,7 @@ struct RangeTask {
~RangeTask()
{
- if (settings->func_free != NULL) {
+ if (settings->func_free != nullptr) {
settings->func_free(userdata, userdata_chunk);
}
MEM_SAFE_FREE(userdata_chunk);
@@ -83,7 +83,7 @@ struct RangeTask {
memcpy(userdata_chunk, from_chunk, settings->userdata_chunk_size);
}
else {
- userdata_chunk = NULL;
+ userdata_chunk = nullptr;
}
}
@@ -139,7 +139,7 @@ void BLI_task_parallel_range(const int start,
for (int i = start; i < stop; i++) {
func(userdata, i, &tls);
}
- if (settings->func_free != NULL) {
+ if (settings->func_free != nullptr) {
settings->func_free(userdata, settings->userdata_chunk);
}
}
diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c
index 2c8eb9f5a13..eac01a0e2aa 100644
--- a/source/blender/blenlib/intern/voxel.c
+++ b/source/blender/blenlib/intern/voxel.c
@@ -51,7 +51,7 @@ float BLI_voxel_sample_nearest(const float *data, const int res[3], const float
BLI_INLINE int FLOORI(float x)
{
const int r = (int)x;
- return ((x >= 0.f) || (float)r == x) ? r : (r - 1);
+ return ((x >= 0.0f) || (float)r == x) ? r : (r - 1);
}
/* clamp function, cannot use the CLAMPIS macro,
@@ -92,9 +92,9 @@ float BLI_voxel_sample_trilinear(const float *data, const int res[3], const floa
const float dy = yf - (float)y;
const float dz = zf - (float)z;
- const float u[2] = {1.f - dx, dx};
- const float v[2] = {1.f - dy, dy};
- const float w[2] = {1.f - dz, dz};
+ const float u[2] = {1.0f - dx, dx};
+ const float v[2] = {1.0f - dy, dy};
+ const float w[2] = {1.0f - dz, dz};
return w[0] *
(v[0] * (u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]]) +
@@ -103,7 +103,7 @@ float BLI_voxel_sample_trilinear(const float *data, const int res[3], const floa
(v[0] * (u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]]) +
v[1] * (u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]]));
}
- return 0.f;
+ return 0.0f;
}
float BLI_voxel_sample_triquadratic(const float *data, const int res[3], const float co[3])
@@ -132,9 +132,9 @@ float BLI_voxel_sample_triquadratic(const float *data, const int res[3], const f
};
const float dx = xf - (float)x, dy = yf - (float)y, dz = zf - (float)z;
- const float u[3] = {dx * (0.5f * dx - 1.f) + 0.5f, dx * (1.0f - dx) + 0.5f, 0.5f * dx * dx};
- const float v[3] = {dy * (0.5f * dy - 1.f) + 0.5f, dy * (1.0f - dy) + 0.5f, 0.5f * dy * dy};
- const float w[3] = {dz * (0.5f * dz - 1.f) + 0.5f, dz * (1.0f - dz) + 0.5f, 0.5f * dz * dz};
+ const float u[3] = {dx * (0.5f * dx - 1.0f) + 0.5f, dx * (1.0f - dx) + 0.5f, 0.5f * dx * dx};
+ const float v[3] = {dy * (0.5f * dy - 1.0f) + 0.5f, dy * (1.0f - dy) + 0.5f, 0.5f * dy * dy};
+ const float w[3] = {dz * (0.5f * dz - 1.0f) + 0.5f, dz * (1.0f - dz) + 0.5f, 0.5f * dz * dz};
return w[0] *
(v[0] * (u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]] +
@@ -158,7 +158,7 @@ float BLI_voxel_sample_triquadratic(const float *data, const int res[3], const f
v[2] * (u[0] * data[xc[0] + yc[2] + zc[2]] + u[1] * data[xc[1] + yc[2] + zc[2]] +
u[2] * data[xc[2] + yc[2] + zc[2]]));
}
- return 0.f;
+ return 0.0f;
}
float BLI_voxel_sample_tricubic(const float *data,
@@ -195,18 +195,18 @@ float BLI_voxel_sample_tricubic(const float *data,
float u[4], v[4], w[4];
if (bspline) { // B-Spline
- u[0] = (((-1.f / 6.f) * dx + 0.5f) * dx - 0.5f) * dx + (1.f / 6.f);
- u[1] = ((0.5f * dx - 1.f) * dx) * dx + (2.f / 3.f);
- u[2] = ((-0.5f * dx + 0.5f) * dx + 0.5f) * dx + (1.f / 6.f);
- u[3] = (1.f / 6.f) * dx * dx * dx;
- v[0] = (((-1.f / 6.f) * dy + 0.5f) * dy - 0.5f) * dy + (1.f / 6.f);
- v[1] = ((0.5f * dy - 1.f) * dy) * dy + (2.f / 3.f);
- v[2] = ((-0.5f * dy + 0.5f) * dy + 0.5f) * dy + (1.f / 6.f);
- v[3] = (1.f / 6.f) * dy * dy * dy;
- w[0] = (((-1.f / 6.f) * dz + 0.5f) * dz - 0.5f) * dz + (1.f / 6.f);
- w[1] = ((0.5f * dz - 1.f) * dz) * dz + (2.f / 3.f);
- w[2] = ((-0.5f * dz + 0.5f) * dz + 0.5f) * dz + (1.f / 6.f);
- w[3] = (1.f / 6.f) * dz * dz * dz;
+ u[0] = (((-1.0f / 6.0f) * dx + 0.5f) * dx - 0.5f) * dx + (1.0f / 6.0f);
+ u[1] = ((0.5f * dx - 1.0f) * dx) * dx + (2.0f / 3.0f);
+ u[2] = ((-0.5f * dx + 0.5f) * dx + 0.5f) * dx + (1.0f / 6.0f);
+ u[3] = (1.0f / 6.0f) * dx * dx * dx;
+ v[0] = (((-1.0f / 6.0f) * dy + 0.5f) * dy - 0.5f) * dy + (1.0f / 6.0f);
+ v[1] = ((0.5f * dy - 1.0f) * dy) * dy + (2.0f / 3.0f);
+ v[2] = ((-0.5f * dy + 0.5f) * dy + 0.5f) * dy + (1.0f / 6.0f);
+ v[3] = (1.0f / 6.0f) * dy * dy * dy;
+ w[0] = (((-1.0f / 6.0f) * dz + 0.5f) * dz - 0.5f) * dz + (1.0f / 6.0f);
+ w[1] = ((0.5f * dz - 1.0f) * dz) * dz + (2.0f / 3.0f);
+ w[2] = ((-0.5f * dz + 0.5f) * dz + 0.5f) * dz + (1.0f / 6.0f);
+ w[3] = (1.0f / 6.0f) * dz * dz * dz;
}
else { // Catmull-Rom
u[0] = ((-0.5f * dx + 1.0f) * dx - 0.5f) * dx;
@@ -260,5 +260,5 @@ float BLI_voxel_sample_tricubic(const float *data,
v[3] * (u[0] * data[xc[0] + yc[3] + zc[3]] + u[1] * data[xc[1] + yc[3] + zc[3]] +
u[2] * data[xc[2] + yc[3] + zc[3]] + u[3] * data[xc[3] + yc[3] + zc[3]]));
}
- return 0.f;
+ return 0.0f;
}
diff --git a/source/blender/blenlib/tests/BLI_array_store_test.cc b/source/blender/blenlib/tests/BLI_array_store_test.cc
index a1ec8ec7bb3..ff050ce24db 100644
--- a/source/blender/blenlib/tests/BLI_array_store_test.cc
+++ b/source/blender/blenlib/tests/BLI_array_store_test.cc
@@ -125,7 +125,7 @@ static TestBuffer *testbuffer_list_add(ListBase *lb, const void *data, size_t da
TestBuffer *tb = (TestBuffer *)MEM_mallocN(sizeof(*tb), __func__);
tb->data = data;
tb->data_len = data_len;
- tb->state = NULL;
+ tb->state = nullptr;
BLI_addtail(lb, tb);
return tb;
}
@@ -244,10 +244,10 @@ static void testbuffer_list_data_randomize(ListBase *lb, unsigned int random_see
static void testbuffer_list_store_populate(BArrayStore *bs, ListBase *lb)
{
- for (TestBuffer *tb = (TestBuffer *)lb->first, *tb_prev = NULL; tb;
+ for (TestBuffer *tb = (TestBuffer *)lb->first, *tb_prev = nullptr; tb;
tb_prev = tb, tb = tb->next) {
tb->state = BLI_array_store_state_add(
- bs, tb->data, tb->data_len, (tb_prev ? tb_prev->state : NULL));
+ bs, tb->data, tb->data_len, (tb_prev ? tb_prev->state : nullptr));
}
}
@@ -255,7 +255,7 @@ static void testbuffer_list_store_clear(BArrayStore *bs, ListBase *lb)
{
for (TestBuffer *tb = (TestBuffer *)lb->first; tb; tb = tb->next) {
BLI_array_store_state_remove(bs, tb->state);
- tb->state = NULL;
+ tb->state = nullptr;
}
}
@@ -313,7 +313,7 @@ TEST(array_store, NopState)
{
BArrayStore *bs = BLI_array_store_create(1, 32);
const unsigned char data[] = "test";
- BArrayState *state = BLI_array_store_state_add(bs, data, sizeof(data) - 1, NULL);
+ BArrayState *state = BLI_array_store_state_add(bs, data, sizeof(data) - 1, nullptr);
EXPECT_EQ(BLI_array_store_state_size_get(state), sizeof(data) - 1);
BLI_array_store_state_remove(bs, state);
BLI_array_store_destroy(bs);
@@ -324,7 +324,7 @@ TEST(array_store, Single)
BArrayStore *bs = BLI_array_store_create(1, 32);
const char data_src[] = "test";
const char *data_dst;
- BArrayState *state = BLI_array_store_state_add(bs, data_src, sizeof(data_src), NULL);
+ BArrayState *state = BLI_array_store_state_add(bs, data_src, sizeof(data_src), nullptr);
size_t data_dst_len;
data_dst = (char *)BLI_array_store_state_data_get_alloc(state, &data_dst_len);
EXPECT_STREQ(data_src, data_dst);
@@ -339,7 +339,7 @@ TEST(array_store, DoubleNop)
const char data_src[] = "test";
const char *data_dst;
- BArrayState *state_a = BLI_array_store_state_add(bs, data_src, sizeof(data_src), NULL);
+ BArrayState *state_a = BLI_array_store_state_add(bs, data_src, sizeof(data_src), nullptr);
BArrayState *state_b = BLI_array_store_state_add(bs, data_src, sizeof(data_src), state_a);
EXPECT_EQ(BLI_array_store_calc_size_compacted_get(bs), sizeof(data_src));
@@ -366,7 +366,7 @@ TEST(array_store, DoubleDiff)
const char data_src_b[] = "####";
const char *data_dst;
- BArrayState *state_a = BLI_array_store_state_add(bs, data_src_a, sizeof(data_src_a), NULL);
+ BArrayState *state_a = BLI_array_store_state_add(bs, data_src_a, sizeof(data_src_a), nullptr);
BArrayState *state_b = BLI_array_store_state_add(bs, data_src_b, sizeof(data_src_b), state_a);
size_t data_dst_len;
@@ -594,7 +594,7 @@ static void testbuffer_list_state_random_data(ListBase *lb,
size_t data_len = rand_range_i(rng, data_min_len, data_max_len + stride, stride);
char *data = (char *)MEM_mallocN(data_len, __func__);
- if (lb->last == NULL) {
+ if (lb->last == nullptr) {
BLI_rng_get_char_n(rng, data, data_len);
}
else {
diff --git a/source/blender/blenlib/tests/BLI_array_utils_test.cc b/source/blender/blenlib/tests/BLI_array_utils_test.cc
index 33b4cd35d52..5d12b8fbd4d 100644
--- a/source/blender/blenlib/tests/BLI_array_utils_test.cc
+++ b/source/blender/blenlib/tests/BLI_array_utils_test.cc
@@ -91,7 +91,7 @@ TEST(array_utils, FindIndexInt4_DupeMid)
TEST(array_utils, FindIndexPointer)
{
- const char *data[4] = {NULL};
+ const char *data[4] = {nullptr};
STACK_DECLARE(data);
STACK_INIT(data, ARRAY_SIZE(data));
diff --git a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
index 14db4254f70..338d6f96bef 100644
--- a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
+++ b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
@@ -667,7 +667,7 @@ template<typename T> void crosssegs_test()
if (out.vert.size() == 5) {
int v_intersect = -1;
for (int i = 0; i < 5; i++) {
- if (i != v0_out && i != v1_out && i != v2_out && i != v3_out) {
+ if (!ELEM(i, v0_out, v1_out, v2_out, v3_out)) {
EXPECT_EQ(v_intersect, -1);
v_intersect = i;
}
@@ -1513,7 +1513,7 @@ TEST(delaunay_d, CintTwoFace)
input.edges_len = 0;
input.faces_len = 2;
input.vert_coords = vert_coords;
- input.edges = NULL;
+ input.edges = nullptr;
input.faces = faces;
input.faces_len_table = faces_len;
input.faces_start_table = faces_start;
diff --git a/source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc b/source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc
index aad21ae4ad4..390f687dbd1 100644
--- a/source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc
+++ b/source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc
@@ -12,7 +12,7 @@
static void expr_pylike_parse_fail_test(const char *str)
{
- ExprPyLike_Parsed *expr = BLI_expr_pylike_parse(str, NULL, 0);
+ ExprPyLike_Parsed *expr = BLI_expr_pylike_parse(str, nullptr, 0);
EXPECT_FALSE(BLI_expr_pylike_is_valid(expr));
@@ -21,7 +21,7 @@ static void expr_pylike_parse_fail_test(const char *str)
static void expr_pylike_const_test(const char *str, double value, bool force_const)
{
- ExprPyLike_Parsed *expr = BLI_expr_pylike_parse(str, NULL, 0);
+ ExprPyLike_Parsed *expr = BLI_expr_pylike_parse(str, nullptr, 0);
if (force_const) {
EXPECT_TRUE(BLI_expr_pylike_is_constant(expr));
@@ -32,7 +32,7 @@ static void expr_pylike_const_test(const char *str, double value, bool force_con
}
double result;
- eExprPyLike_EvalStatus status = BLI_expr_pylike_eval(expr, NULL, 0, &result);
+ eExprPyLike_EvalStatus status = BLI_expr_pylike_eval(expr, nullptr, 0, &result);
EXPECT_EQ(status, EXPR_PYLIKE_SUCCESS);
EXPECT_EQ(result, value);
@@ -344,10 +344,10 @@ TEST_ERROR(Mixed3, "sqrt(x) + 1 / max(0, x)", 1.0, EXPR_PYLIKE_SUCCESS)
TEST(expr_pylike, Error_Invalid)
{
- ExprPyLike_Parsed *expr = BLI_expr_pylike_parse("", NULL, 0);
+ ExprPyLike_Parsed *expr = BLI_expr_pylike_parse("", nullptr, 0);
double result;
- EXPECT_EQ(BLI_expr_pylike_eval(expr, NULL, 0, &result), EXPR_PYLIKE_INVALID);
+ EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID);
BLI_expr_pylike_free(expr);
}
@@ -357,7 +357,7 @@ TEST(expr_pylike, Error_ArgumentCount)
ExprPyLike_Parsed *expr = parse_for_eval("x", false);
double result;
- EXPECT_EQ(BLI_expr_pylike_eval(expr, NULL, 0, &result), EXPR_PYLIKE_FATAL_ERROR);
+ EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_FATAL_ERROR);
BLI_expr_pylike_free(expr);
}
diff --git a/source/blender/blenlib/tests/BLI_ghash_test.cc b/source/blender/blenlib/tests/BLI_ghash_test.cc
index 484f158a85c..a0b24e96fcc 100644
--- a/source/blender/blenlib/tests/BLI_ghash_test.cc
+++ b/source/blender/blenlib/tests/BLI_ghash_test.cc
@@ -77,7 +77,7 @@ TEST(ghash, InsertLookup)
EXPECT_EQ(POINTER_AS_UINT(v), *k);
}
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
}
/* Here we simply insert and then remove all keys, ensuring we do get an empty,
@@ -98,14 +98,14 @@ TEST(ghash, InsertRemove)
bkt_size = BLI_ghash_buckets_len(ghash);
for (i = TESTCASE_SIZE, k = keys; i--; k++) {
- void *v = BLI_ghash_popkey(ghash, POINTER_FROM_UINT(*k), NULL);
+ void *v = BLI_ghash_popkey(ghash, POINTER_FROM_UINT(*k), nullptr);
EXPECT_EQ(POINTER_AS_UINT(v), *k);
}
EXPECT_EQ(BLI_ghash_len(ghash), 0);
EXPECT_EQ(BLI_ghash_buckets_len(ghash), bkt_size);
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
}
/* Same as above, but this time we allow ghash to shrink. */
@@ -126,14 +126,14 @@ TEST(ghash, InsertRemoveShrink)
bkt_size = BLI_ghash_buckets_len(ghash);
for (i = TESTCASE_SIZE, k = keys; i--; k++) {
- void *v = BLI_ghash_popkey(ghash, POINTER_FROM_UINT(*k), NULL);
+ void *v = BLI_ghash_popkey(ghash, POINTER_FROM_UINT(*k), nullptr);
EXPECT_EQ(POINTER_AS_UINT(v), *k);
}
EXPECT_EQ(BLI_ghash_len(ghash), 0);
EXPECT_LT(BLI_ghash_buckets_len(ghash), bkt_size);
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
}
/* Check copy. */
@@ -152,7 +152,7 @@ TEST(ghash, Copy)
EXPECT_EQ(BLI_ghash_len(ghash), TESTCASE_SIZE);
- ghash_copy = BLI_ghash_copy(ghash, NULL, NULL);
+ ghash_copy = BLI_ghash_copy(ghash, nullptr, nullptr);
EXPECT_EQ(BLI_ghash_len(ghash_copy), TESTCASE_SIZE);
EXPECT_EQ(BLI_ghash_buckets_len(ghash_copy), BLI_ghash_buckets_len(ghash));
@@ -162,8 +162,8 @@ TEST(ghash, Copy)
EXPECT_EQ(POINTER_AS_UINT(v), *k);
}
- BLI_ghash_free(ghash, NULL, NULL);
- BLI_ghash_free(ghash_copy, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
+ BLI_ghash_free(ghash_copy, nullptr, nullptr);
}
/* Check pop. */
@@ -205,5 +205,5 @@ TEST(ghash, Pop)
}
EXPECT_EQ(BLI_ghash_len(ghash), 0);
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
}
diff --git a/source/blender/blenlib/tests/BLI_heap_simple_test.cc b/source/blender/blenlib/tests/BLI_heap_simple_test.cc
index e717a6e2653..f3a65125eeb 100644
--- a/source/blender/blenlib/tests/BLI_heap_simple_test.cc
+++ b/source/blender/blenlib/tests/BLI_heap_simple_test.cc
@@ -29,7 +29,7 @@ TEST(heap, SimpleEmpty)
heap = BLI_heapsimple_new();
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
EXPECT_EQ(BLI_heapsimple_len(heap), 0);
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
}
TEST(heap, SimpleOne)
@@ -45,7 +45,7 @@ TEST(heap, SimpleOne)
EXPECT_EQ(in, BLI_heapsimple_pop_min(heap));
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
EXPECT_EQ(BLI_heapsimple_len(heap), 0);
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
}
TEST(heap, SimpleRange)
@@ -59,7 +59,7 @@ TEST(heap, SimpleRange)
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap)));
}
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
}
TEST(heap, SimpleRangeReverse)
@@ -73,7 +73,7 @@ TEST(heap, SimpleRangeReverse)
EXPECT_EQ(-out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap)));
}
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
}
TEST(heap, SimpleDuplicates)
@@ -81,13 +81,13 @@ TEST(heap, SimpleDuplicates)
const int items_total = SIZE;
HeapSimple *heap = BLI_heapsimple_new();
for (int in = 0; in < items_total; in++) {
- BLI_heapsimple_insert(heap, 1.0f, 0);
+ BLI_heapsimple_insert(heap, 1.0f, nullptr);
}
for (int out_test = 0; out_test < items_total; out_test++) {
EXPECT_EQ(0, POINTER_AS_INT(BLI_heapsimple_pop_min(heap)));
}
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
}
static void random_heapsimple_helper(const int items_total, const int random_seed)
@@ -103,7 +103,7 @@ static void random_heapsimple_helper(const int items_total, const int random_see
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heapsimple_pop_min(heap)));
}
EXPECT_TRUE(BLI_heapsimple_is_empty(heap));
- BLI_heapsimple_free(heap, NULL);
+ BLI_heapsimple_free(heap, nullptr);
MEM_freeN(values);
}
diff --git a/source/blender/blenlib/tests/BLI_heap_test.cc b/source/blender/blenlib/tests/BLI_heap_test.cc
index 87e68c175a2..8b207c17c84 100644
--- a/source/blender/blenlib/tests/BLI_heap_test.cc
+++ b/source/blender/blenlib/tests/BLI_heap_test.cc
@@ -28,7 +28,7 @@ TEST(heap, Empty)
heap = BLI_heap_new();
EXPECT_TRUE(BLI_heap_is_empty(heap));
EXPECT_EQ(BLI_heap_len(heap), 0);
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
}
TEST(heap, One)
@@ -44,7 +44,7 @@ TEST(heap, One)
EXPECT_EQ(in, BLI_heap_pop_min(heap));
EXPECT_TRUE(BLI_heap_is_empty(heap));
EXPECT_EQ(BLI_heap_len(heap), 0);
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
}
TEST(heap, Range)
@@ -58,7 +58,7 @@ TEST(heap, Range)
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
}
TEST(heap, RangeReverse)
@@ -72,7 +72,7 @@ TEST(heap, RangeReverse)
EXPECT_EQ(-out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
}
TEST(heap, RangeRemove)
@@ -85,13 +85,13 @@ TEST(heap, RangeRemove)
}
for (int i = 0; i < items_total; i += 2) {
BLI_heap_remove(heap, nodes[i]);
- nodes[i] = NULL;
+ nodes[i] = nullptr;
}
for (int out_test = 1; out_test < items_total; out_test += 2) {
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
MEM_freeN(nodes);
}
@@ -100,13 +100,13 @@ TEST(heap, Duplicates)
const int items_total = SIZE;
Heap *heap = BLI_heap_new();
for (int in = 0; in < items_total; in++) {
- BLI_heap_insert(heap, 1.0f, 0);
+ BLI_heap_insert(heap, 1.0f, nullptr);
}
for (int out_test = 0; out_test < items_total; out_test++) {
EXPECT_EQ(0, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
}
static void random_heap_helper(const int items_total, const int random_seed)
@@ -122,7 +122,7 @@ static void random_heap_helper(const int items_total, const int random_seed)
EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
MEM_freeN(values);
}
@@ -156,7 +156,7 @@ TEST(heap, ReInsertSimple)
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
MEM_freeN(nodes);
}
@@ -181,7 +181,7 @@ static void random_heap_reinsert_helper(const int items_total, const int random_
BLI_heap_pop_min(heap);
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
- BLI_heap_free(heap, NULL);
+ BLI_heap_free(heap, nullptr);
MEM_freeN(nodes);
}
diff --git a/source/blender/blenlib/tests/BLI_kdopbvh_test.cc b/source/blender/blenlib/tests/BLI_kdopbvh_test.cc
index 2e8032400e3..f921c3ae2a4 100644
--- a/source/blender/blenlib/tests/BLI_kdopbvh_test.cc
+++ b/source/blender/blenlib/tests/BLI_kdopbvh_test.cc
@@ -82,11 +82,11 @@ static void find_nearest_points_test(
BLI_bvhtree_balance(tree);
/* first find each point */
- BVHTree_NearestPointCallback callback = optimal ? optimal_check_callback : NULL;
+ BVHTree_NearestPointCallback callback = optimal ? optimal_check_callback : nullptr;
int flags = optimal ? BVH_NEAREST_OPTIMAL_ORDER : 0;
for (int i = 0; i < points_len; i++) {
- const int j = BLI_bvhtree_find_nearest_ex(tree, points[i], NULL, callback, points, flags);
+ const int j = BLI_bvhtree_find_nearest_ex(tree, points[i], nullptr, callback, points, flags);
if (j != i) {
#if 0
const float dist = len_v3v3(points[i], points[j]);
diff --git a/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc b/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc
index d1a527d57ac..f2ae121e8ae 100644
--- a/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc
+++ b/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc
@@ -15,7 +15,7 @@ TEST(LockfreeLinkList, Init)
BLI_linklist_lockfree_init(&list);
EXPECT_EQ(list.head, &list.dummy_node);
EXPECT_EQ(list.tail, &list.dummy_node);
- BLI_linklist_lockfree_free(&list, NULL);
+ BLI_linklist_lockfree_free(&list, nullptr);
}
TEST(LockfreeLinkList, InsertSingle)
@@ -27,7 +27,7 @@ TEST(LockfreeLinkList, InsertSingle)
EXPECT_EQ(list.head, &list.dummy_node);
EXPECT_EQ(list.head->next, &node);
EXPECT_EQ(list.tail, &node);
- BLI_linklist_lockfree_free(&list, NULL);
+ BLI_linklist_lockfree_free(&list, nullptr);
}
TEST(LockfreeLinkList, InsertMultiple)
@@ -45,7 +45,7 @@ TEST(LockfreeLinkList, InsertMultiple)
EXPECT_EQ(list.tail, &nodes[num_nodes - 1]);
/* Check rest of the nodes. */
int node_index = 0;
- for (LockfreeLinkNode *node = BLI_linklist_lockfree_begin(&list); node != NULL;
+ for (LockfreeLinkNode *node = BLI_linklist_lockfree_begin(&list); node != nullptr;
node = node->next, ++node_index) {
EXPECT_EQ(node, &nodes[node_index]);
if (node_index != num_nodes - 1) {
@@ -53,7 +53,7 @@ TEST(LockfreeLinkList, InsertMultiple)
}
}
/* Free list. */
- BLI_linklist_lockfree_free(&list, NULL);
+ BLI_linklist_lockfree_free(&list, nullptr);
}
namespace {
@@ -84,7 +84,7 @@ TEST(LockfreeLinkList, InsertMultipleConcurrent)
TaskPool *pool = BLI_task_pool_create_suspended(&list, TASK_PRIORITY_HIGH);
/* Push tasks to the pool. */
for (int i = 0; i < num_nodes; ++i) {
- BLI_task_pool_push(pool, concurrent_insert, POINTER_FROM_INT(i), false, NULL);
+ BLI_task_pool_push(pool, concurrent_insert, POINTER_FROM_INT(i), false, nullptr);
}
/* Run all the tasks. */
BLI_task_pool_work_and_wait(pool);
@@ -92,7 +92,7 @@ TEST(LockfreeLinkList, InsertMultipleConcurrent)
EXPECT_EQ(list.head, &list.dummy_node);
bool *visited_nodes = (bool *)MEM_callocN(sizeof(bool) * num_nodes, "visited nodes");
/* First, we make sure that none of the nodes are added twice. */
- for (LockfreeLinkNode *node_v = BLI_linklist_lockfree_begin(&list); node_v != NULL;
+ for (LockfreeLinkNode *node_v = BLI_linklist_lockfree_begin(&list); node_v != nullptr;
node_v = node_v->next) {
IndexedNode *node = (IndexedNode *)node_v;
EXPECT_GE(node->index, 0);
diff --git a/source/blender/blenlib/tests/BLI_listbase_test.cc b/source/blender/blenlib/tests/BLI_listbase_test.cc
index e5b504a0040..ff85cf79e87 100644
--- a/source/blender/blenlib/tests/BLI_listbase_test.cc
+++ b/source/blender/blenlib/tests/BLI_listbase_test.cc
@@ -22,19 +22,19 @@ static bool listbase_is_valid(const ListBase *listbase)
if (listbase->first) {
const Link *prev, *link;
link = (Link *)listbase->first;
- TESTFAIL(link->prev == NULL);
+ TESTFAIL(link->prev == nullptr);
link = (Link *)listbase->last;
- TESTFAIL(link->next == NULL);
+ TESTFAIL(link->next == nullptr);
- prev = NULL;
+ prev = nullptr;
link = (Link *)listbase->first;
do {
TESTFAIL(link->prev == prev);
} while ((void)(prev = link), (link = link->next));
TESTFAIL(prev == listbase->last);
- prev = NULL;
+ prev = nullptr;
link = (Link *)listbase->last;
do {
TESTFAIL(link->next == prev);
@@ -42,7 +42,7 @@ static bool listbase_is_valid(const ListBase *listbase)
TESTFAIL(prev == listbase->first);
}
else {
- TESTFAIL(listbase->last == NULL);
+ TESTFAIL(listbase->last == nullptr);
}
#undef TESTFAIL
@@ -73,12 +73,12 @@ TEST(listbase, FindLinkOrIndex)
/* Empty list */
BLI_listbase_clear(&lb);
- EXPECT_EQ(BLI_findlink(&lb, -1), (void *)NULL);
- EXPECT_EQ(BLI_findlink(&lb, 0), (void *)NULL);
- EXPECT_EQ(BLI_findlink(&lb, 1), (void *)NULL);
- EXPECT_EQ(BLI_rfindlink(&lb, -1), (void *)NULL);
- EXPECT_EQ(BLI_rfindlink(&lb, 0), (void *)NULL);
- EXPECT_EQ(BLI_rfindlink(&lb, 1), (void *)NULL);
+ EXPECT_EQ(BLI_findlink(&lb, -1), (void *)nullptr);
+ EXPECT_EQ(BLI_findlink(&lb, 0), (void *)nullptr);
+ EXPECT_EQ(BLI_findlink(&lb, 1), (void *)nullptr);
+ EXPECT_EQ(BLI_rfindlink(&lb, -1), (void *)nullptr);
+ EXPECT_EQ(BLI_rfindlink(&lb, 0), (void *)nullptr);
+ EXPECT_EQ(BLI_rfindlink(&lb, 1), (void *)nullptr);
EXPECT_EQ(BLI_findindex(&lb, link1), -1);
/* One link */
diff --git a/source/blender/blenlib/tests/BLI_map_test.cc b/source/blender/blenlib/tests/BLI_map_test.cc
index 91c6335b949..323ced87d9e 100644
--- a/source/blender/blenlib/tests/BLI_map_test.cc
+++ b/source/blender/blenlib/tests/BLI_map_test.cc
@@ -8,6 +8,7 @@
#include "BLI_timeit.hh"
#include "BLI_vector.hh"
#include "testing/testing.h"
+#include <memory>
namespace blender::tests {
@@ -295,6 +296,24 @@ TEST(map, AddOrModify)
EXPECT_EQ(map.lookup(1), 15.0f);
}
+TEST(map, AddOrModifyReference)
+{
+ Map<int, std::unique_ptr<int>> map;
+ auto create_func = [](std::unique_ptr<int> *value) -> int & {
+ new (value) std::unique_ptr<int>(new int{10});
+ return **value;
+ };
+ auto modify_func = [](std::unique_ptr<int> *value) -> int & {
+ **value += 5;
+ return **value;
+ };
+ EXPECT_EQ(map.add_or_modify(1, create_func, modify_func), 10);
+ int &a = map.add_or_modify(1, create_func, modify_func);
+ EXPECT_EQ(a, 15);
+ a = 100;
+ EXPECT_EQ(*map.lookup(1), 100);
+}
+
TEST(map, AddOverwrite)
{
Map<int, float> map;
@@ -401,9 +420,9 @@ TEST(map, Clear)
TEST(map, UniquePtrValue)
{
- auto value1 = std::unique_ptr<int>(new int());
- auto value2 = std::unique_ptr<int>(new int());
- auto value3 = std::unique_ptr<int>(new int());
+ auto value1 = std::make_unique<int>();
+ auto value2 = std::make_unique<int>();
+ auto value3 = std::make_unique<int>();
int *value1_ptr = value1.get();
@@ -411,12 +430,12 @@ TEST(map, UniquePtrValue)
map.add_new(1, std::move(value1));
map.add(2, std::move(value2));
map.add_overwrite(3, std::move(value3));
- map.lookup_or_add_cb(4, []() { return std::unique_ptr<int>(new int()); });
- map.add_new(5, std::unique_ptr<int>(new int()));
- map.add(6, std::unique_ptr<int>(new int()));
- map.add_overwrite(7, std::unique_ptr<int>(new int()));
- map.lookup_or_add(8, std::unique_ptr<int>(new int()));
- map.pop_default(9, std::unique_ptr<int>(new int()));
+ map.lookup_or_add_cb(4, []() { return std::make_unique<int>(); });
+ map.add_new(5, std::make_unique<int>());
+ map.add(6, std::make_unique<int>());
+ map.add_overwrite(7, std::make_unique<int>());
+ map.lookup_or_add(8, std::make_unique<int>());
+ map.pop_default(9, std::make_unique<int>());
EXPECT_EQ(map.lookup(1).get(), value1_ptr);
EXPECT_EQ(map.lookup_ptr(100), nullptr);
diff --git a/source/blender/blenlib/tests/BLI_math_base_test.cc b/source/blender/blenlib/tests/BLI_math_base_test.cc
index dc20c75576d..d006a2eb59a 100644
--- a/source/blender/blenlib/tests/BLI_math_base_test.cc
+++ b/source/blender/blenlib/tests/BLI_math_base_test.cc
@@ -113,3 +113,21 @@ TEST(math_base, Log2CeilU)
EXPECT_EQ(log2_ceil_u(9), 4);
EXPECT_EQ(log2_ceil_u(123456), 17);
}
+
+TEST(math_base, CeilPowerOf10)
+{
+ EXPECT_EQ(ceil_power_of_10(0), 0);
+ EXPECT_EQ(ceil_power_of_10(1), 1);
+ EXPECT_EQ(ceil_power_of_10(1e-6f), 1e-6f);
+ EXPECT_NEAR(ceil_power_of_10(100.1f), 1000.0f, 1e-4f);
+ EXPECT_NEAR(ceil_power_of_10(99.9f), 100.0f, 1e-4f);
+}
+
+TEST(math_base, FloorPowerOf10)
+{
+ EXPECT_EQ(floor_power_of_10(0), 0);
+ EXPECT_EQ(floor_power_of_10(1), 1);
+ EXPECT_EQ(floor_power_of_10(1e-6f), 1e-6f);
+ EXPECT_NEAR(floor_power_of_10(100.1f), 100.0f, 1e-4f);
+ EXPECT_NEAR(floor_power_of_10(99.9f), 10.0f, 1e-4f);
+}
diff --git a/source/blender/blenlib/tests/BLI_path_util_test.cc b/source/blender/blenlib/tests/BLI_path_util_test.cc
index 927d24d2c4c..cf5135731e2 100644
--- a/source/blender/blenlib/tests/BLI_path_util_test.cc
+++ b/source/blender/blenlib/tests/BLI_path_util_test.cc
@@ -18,46 +18,46 @@ TEST(path_util, Clean)
/* "/./" -> "/" */
{
char path[FILE_MAX] = "/a/./b/./c/./";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("/a/b/c/", path);
}
{
char path[FILE_MAX] = "/./././";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("/", path);
}
{
char path[FILE_MAX] = "/a/./././b/";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("/a/b/", path);
}
/* "//" -> "/" */
{
char path[FILE_MAX] = "a////";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("a/", path);
}
- if (0) /* FIXME */
+ if (false) /* FIXME */
{
char path[FILE_MAX] = "./a////";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("./a/", path);
}
/* "foo/bar/../" -> "foo/" */
{
char path[FILE_MAX] = "/a/b/c/../../../";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("/", path);
}
{
char path[FILE_MAX] = "/a/../a/b/../b/c/../c/";
- BLI_path_normalize(NULL, path);
+ BLI_path_normalize(nullptr, path);
EXPECT_STREQ("/a/b/c/", path);
}
@@ -96,10 +96,10 @@ TEST(path_util, NameAtIndex_Single)
AT_INDEX("//a//", 0, "a");
AT_INDEX("a/b", 0, "a");
- AT_INDEX("/a", 1, NULL);
- AT_INDEX("/a/", 1, NULL);
- AT_INDEX("a/", 1, NULL);
- AT_INDEX("//a//", 1, NULL);
+ AT_INDEX("/a", 1, nullptr);
+ AT_INDEX("/a/", 1, nullptr);
+ AT_INDEX("a/", 1, nullptr);
+ AT_INDEX("//a//", 1, nullptr);
}
TEST(path_util, NameAtIndex_SingleNeg)
{
@@ -109,10 +109,10 @@ TEST(path_util, NameAtIndex_SingleNeg)
AT_INDEX("//a//", -1, "a");
AT_INDEX("a/b", -1, "b");
- AT_INDEX("/a", -2, NULL);
- AT_INDEX("/a/", -2, NULL);
- AT_INDEX("a/", -2, NULL);
- AT_INDEX("//a//", -2, NULL);
+ AT_INDEX("/a", -2, nullptr);
+ AT_INDEX("/a/", -2, nullptr);
+ AT_INDEX("a/", -2, nullptr);
+ AT_INDEX("//a//", -2, nullptr);
}
TEST(path_util, NameAtIndex_Double)
@@ -123,10 +123,10 @@ TEST(path_util, NameAtIndex_Double)
AT_INDEX("//ab//", 0, "ab");
AT_INDEX("ab/c", 0, "ab");
- AT_INDEX("/ab", 1, NULL);
- AT_INDEX("/ab/", 1, NULL);
- AT_INDEX("ab/", 1, NULL);
- AT_INDEX("//ab//", 1, NULL);
+ AT_INDEX("/ab", 1, nullptr);
+ AT_INDEX("/ab/", 1, nullptr);
+ AT_INDEX("ab/", 1, nullptr);
+ AT_INDEX("//ab//", 1, nullptr);
}
TEST(path_util, NameAtIndex_DoublNeg)
@@ -137,10 +137,10 @@ TEST(path_util, NameAtIndex_DoublNeg)
AT_INDEX("//ab//", -1, "ab");
AT_INDEX("ab/c", -1, "c");
- AT_INDEX("/ab", -2, NULL);
- AT_INDEX("/ab/", -2, NULL);
- AT_INDEX("ab/", -2, NULL);
- AT_INDEX("//ab//", -2, NULL);
+ AT_INDEX("/ab", -2, nullptr);
+ AT_INDEX("/ab/", -2, nullptr);
+ AT_INDEX("ab/", -2, nullptr);
+ AT_INDEX("//ab//", -2, nullptr);
}
TEST(path_util, NameAtIndex_Misc)
@@ -149,8 +149,8 @@ TEST(path_util, NameAtIndex_Misc)
AT_INDEX("/how/now/brown/cow", 1, "now");
AT_INDEX("/how/now/brown/cow", 2, "brown");
AT_INDEX("/how/now/brown/cow", 3, "cow");
- AT_INDEX("/how/now/brown/cow", 4, NULL);
- AT_INDEX("/how/now/brown/cow/", 4, NULL);
+ AT_INDEX("/how/now/brown/cow", 4, nullptr);
+ AT_INDEX("/how/now/brown/cow/", 4, nullptr);
}
TEST(path_util, NameAtIndex_MiscNeg)
@@ -159,8 +159,8 @@ TEST(path_util, NameAtIndex_MiscNeg)
AT_INDEX("/how/now/brown/cow", 1, "now");
AT_INDEX("/how/now/brown/cow", 2, "brown");
AT_INDEX("/how/now/brown/cow", 3, "cow");
- AT_INDEX("/how/now/brown/cow", 4, NULL);
- AT_INDEX("/how/now/brown/cow/", 4, NULL);
+ AT_INDEX("/how/now/brown/cow", 4, nullptr);
+ AT_INDEX("/how/now/brown/cow/", 4, nullptr);
}
TEST(path_util, NameAtIndex_MiscComplex)
@@ -169,8 +169,8 @@ TEST(path_util, NameAtIndex_MiscComplex)
AT_INDEX("//how///now\\/brown/cow", 1, "now");
AT_INDEX("/how/now\\//brown\\/cow", 2, "brown");
AT_INDEX("/how/now/brown/cow//\\", 3, "cow");
- AT_INDEX("/how/now/brown/\\cow", 4, NULL);
- AT_INDEX("how/now/brown/\\cow\\", 4, NULL);
+ AT_INDEX("/how/now/brown/\\cow", 4, nullptr);
+ AT_INDEX("how/now/brown/\\cow\\", 4, nullptr);
}
TEST(path_util, NameAtIndex_MiscComplexNeg)
@@ -179,24 +179,24 @@ TEST(path_util, NameAtIndex_MiscComplexNeg)
AT_INDEX("//how///now\\/brown/cow", -3, "now");
AT_INDEX("/how/now\\//brown\\/cow", -2, "brown");
AT_INDEX("/how/now/brown/cow//\\", -1, "cow");
- AT_INDEX("/how/now/brown/\\cow", -5, NULL);
- AT_INDEX("how/now/brown/\\cow\\", -5, NULL);
+ AT_INDEX("/how/now/brown/\\cow", -5, nullptr);
+ AT_INDEX("how/now/brown/\\cow\\", -5, nullptr);
}
TEST(path_util, NameAtIndex_NoneComplex)
{
- AT_INDEX("", 0, NULL);
- AT_INDEX("/", 0, NULL);
- AT_INDEX("//", 0, NULL);
- AT_INDEX("///", 0, NULL);
+ AT_INDEX("", 0, nullptr);
+ AT_INDEX("/", 0, nullptr);
+ AT_INDEX("//", 0, nullptr);
+ AT_INDEX("///", 0, nullptr);
}
TEST(path_util, NameAtIndex_NoneComplexNeg)
{
- AT_INDEX("", -1, NULL);
- AT_INDEX("/", -1, NULL);
- AT_INDEX("//", -1, NULL);
- AT_INDEX("///", -1, NULL);
+ AT_INDEX("", -1, nullptr);
+ AT_INDEX("/", -1, nullptr);
+ AT_INDEX("//", -1, nullptr);
+ AT_INDEX("///", -1, nullptr);
}
#undef AT_INDEX
@@ -590,9 +590,9 @@ TEST(path_util, PathFrameGet)
/* BLI_path_extension */
TEST(path_util, PathExtension)
{
- EXPECT_EQ(NULL, BLI_path_extension("some.def/file"));
- EXPECT_EQ(NULL, BLI_path_extension("Text"));
- EXPECT_EQ(NULL, BLI_path_extension("Text…001"));
+ EXPECT_EQ(nullptr, BLI_path_extension("some.def/file"));
+ EXPECT_EQ(nullptr, BLI_path_extension("Text"));
+ EXPECT_EQ(nullptr, BLI_path_extension("Text…001"));
EXPECT_STREQ(".", BLI_path_extension("some/file."));
EXPECT_STREQ(".gz", BLI_path_extension("some/file.tar.gz"));
diff --git a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
index 624a296e758..3c9d12c7178 100644
--- a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
+++ b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
@@ -118,7 +118,7 @@ static void test_polyfill_topology(const float /*poly*/[][2],
}
BLI_edgehashIterator_free(ehi);
- BLI_edgehash_free(edgehash, NULL);
+ BLI_edgehash_free(edgehash, nullptr);
}
/**
@@ -205,7 +205,7 @@ static void test_polyfill_template(const char *id,
test_polyfill_template_check(id, is_degenerate, poly, poly_tot, tris, tris_tot);
BLI_memarena_free(pf_arena);
- BLI_heap_free(pf_heap, NULL);
+ BLI_heap_free(pf_heap, nullptr);
}
#endif
}
diff --git a/source/blender/blenlib/tests/BLI_set_test.cc b/source/blender/blenlib/tests/BLI_set_test.cc
index dbe820c9d15..ea4369d6b8f 100644
--- a/source/blender/blenlib/tests/BLI_set_test.cc
+++ b/source/blender/blenlib/tests/BLI_set_test.cc
@@ -221,10 +221,10 @@ TEST(set, OftenAddRemoveContained)
TEST(set, UniquePtrValues)
{
Set<std::unique_ptr<int>> set;
- set.add_new(std::unique_ptr<int>(new int()));
- auto value1 = std::unique_ptr<int>(new int());
+ set.add_new(std::make_unique<int>());
+ auto value1 = std::make_unique<int>();
set.add_new(std::move(value1));
- set.add(std::unique_ptr<int>(new int()));
+ set.add(std::make_unique<int>());
EXPECT_EQ(set.size(), 3);
}
diff --git a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc
index c03893c5596..f1fcdae3a52 100644
--- a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc
+++ b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc
@@ -170,8 +170,8 @@ TEST(stack, Peek)
TEST(stack, UniquePtrValues)
{
Stack<std::unique_ptr<int>> stack;
- stack.push(std::unique_ptr<int>(new int()));
- stack.push(std::unique_ptr<int>(new int()));
+ stack.push(std::make_unique<int>());
+ stack.push(std::make_unique<int>());
std::unique_ptr<int> a = stack.pop();
std::unique_ptr<int> &b = stack.peek();
UNUSED_VARS(a, b);
diff --git a/source/blender/blenlib/tests/BLI_string_test.cc b/source/blender/blenlib/tests/BLI_string_test.cc
index e8fe505a6c9..58135adbcca 100644
--- a/source/blender/blenlib/tests/BLI_string_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_test.cc
@@ -66,8 +66,8 @@ TEST(string, StrPartition)
/* "" -> "", NULL, NULL, 0 */
pre_ln = BLI_str_partition(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 0);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
{
@@ -76,8 +76,8 @@ TEST(string, StrPartition)
/* "material" -> "material", NULL, NULL, 8 */
pre_ln = BLI_str_partition(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 8);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -125,8 +125,8 @@ TEST(string, StrRPartition)
/* "" -> "", NULL, NULL, 0 */
pre_ln = BLI_str_rpartition(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 0);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
{
@@ -135,8 +135,8 @@ TEST(string, StrRPartition)
/* "material" -> "material", NULL, NULL, 8 */
pre_ln = BLI_str_rpartition(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 8);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -166,8 +166,8 @@ TEST(string, StrPartitionEx)
/* "mate.rial" over "mate" -> "mate.rial", NULL, NULL, 4 */
pre_ln = BLI_str_partition_ex(str, str + 4, delim, &sep, &suf, true);
EXPECT_EQ(pre_ln, 4);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -215,8 +215,8 @@ TEST(string, StrPartitionUtf8)
/* "" -> "", NULL, NULL, 0 */
pre_ln = BLI_str_partition_utf8(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 0);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
{
@@ -225,8 +225,8 @@ TEST(string, StrPartitionUtf8)
/* "material" -> "material", NULL, NULL, 8 */
pre_ln = BLI_str_partition_utf8(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 8);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -274,8 +274,8 @@ TEST(string, StrRPartitionUtf8)
/* "" -> "", NULL, NULL, 0 */
pre_ln = BLI_str_rpartition_utf8(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 0);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
{
@@ -284,8 +284,8 @@ TEST(string, StrRPartitionUtf8)
/* "material" -> "material", NULL, NULL, 8 */
pre_ln = BLI_str_rpartition_utf8(str, delim, &sep, &suf);
EXPECT_EQ(pre_ln, 8);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -316,8 +316,8 @@ TEST(string, StrPartitionExUtf8)
/* "mate\xe2\x98\xafrial" over "mate" -> "mate\xe2\x98\xafrial", NULL, NULL, 4 */
pre_ln = BLI_str_partition_ex_utf8(str, str + 4, delim, &sep, &suf, true);
EXPECT_EQ(pre_ln, 4);
- EXPECT_EQ(sep, (void *)NULL);
- EXPECT_EQ(suf, (void *)NULL);
+ EXPECT_EQ(sep, (void *)nullptr);
+ EXPECT_EQ(suf, (void *)nullptr);
}
}
@@ -567,7 +567,7 @@ TEST(string, StringStrncasestr)
EXPECT_EQ(res, str_test0 + 1);
res = BLI_strncasestr(str_test0, "not there", 9);
- EXPECT_EQ(res, (void *)NULL);
+ EXPECT_EQ(res, (void *)nullptr);
}
/* BLI_string_max_possible_word_count */
diff --git a/source/blender/blenlib/tests/BLI_string_utf8_test.cc b/source/blender/blenlib/tests/BLI_string_utf8_test.cc
index 9743c1387a0..1833945b3fd 100644
--- a/source/blender/blenlib/tests/BLI_string_utf8_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_utf8_test.cc
@@ -262,14 +262,14 @@ const char *utf8_invalid_tests[][3] = {
/* 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},
+ {nullptr, nullptr, nullptr},
};
/* clang-format on */
/* BLI_utf8_invalid_strip (and indirectly, BLI_utf8_invalid_byte). */
TEST(string, Utf8InvalidBytes)
{
- for (int i = 0; utf8_invalid_tests[i][0] != NULL; i++) {
+ for (int i = 0; utf8_invalid_tests[i][0] != nullptr; i++) {
const char *tst = utf8_invalid_tests[i][0];
const char *tst_stripped = utf8_invalid_tests[i][1];
const int num_errors = (int)utf8_invalid_tests[i][2][0];
diff --git a/source/blender/blenlib/tests/BLI_task_graph_test.cc b/source/blender/blenlib/tests/BLI_task_graph_test.cc
index efcbf923625..475e0270da2 100644
--- a/source/blender/blenlib/tests/BLI_task_graph_test.cc
+++ b/source/blender/blenlib/tests/BLI_task_graph_test.cc
@@ -52,16 +52,16 @@ TEST(task, GraphSequential)
TaskGraph *graph = BLI_task_graph_create();
/* 0 => 1 */
- TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
+ TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
/* 1 => 2 */
TaskNode *node_b = BLI_task_graph_node_create(
- graph, TaskData_multiply_by_two_value, &data, NULL);
+ graph, TaskData_multiply_by_two_value, &data, nullptr);
/* 2 => 1 */
- TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_decrease_value, &data, NULL);
+ TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_decrease_value, &data, nullptr);
/* 2 => 1 */
- TaskNode *node_d = BLI_task_graph_node_create(graph, TaskData_square_value, &data, NULL);
+ TaskNode *node_d = BLI_task_graph_node_create(graph, TaskData_square_value, &data, nullptr);
/* 1 => 1 */
- TaskNode *node_e = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
+ TaskNode *node_e = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
/* 1 => 2 */
const int expected_value = 2;
@@ -82,12 +82,12 @@ TEST(task, GraphStartAtAnyNode)
TaskData data = {4};
TaskGraph *graph = BLI_task_graph_create();
- TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
+ TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
TaskNode *node_b = BLI_task_graph_node_create(
- graph, TaskData_multiply_by_two_value, &data, NULL);
- TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_decrease_value, &data, NULL);
- TaskNode *node_d = BLI_task_graph_node_create(graph, TaskData_square_value, &data, NULL);
- TaskNode *node_e = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
+ graph, TaskData_multiply_by_two_value, &data, nullptr);
+ TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_decrease_value, &data, nullptr);
+ TaskNode *node_d = BLI_task_graph_node_create(graph, TaskData_square_value, &data, nullptr);
+ TaskNode *node_e = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
// ((4 - 1) * (4 - 1)) + 1
const int expected_value = 10;
@@ -109,11 +109,11 @@ TEST(task, GraphSplit)
TaskData data = {1};
TaskGraph *graph = BLI_task_graph_create();
- TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
- TaskNode *node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data, NULL);
- TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, NULL);
+ TaskNode *node_a = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
+ TaskNode *node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data, nullptr);
+ TaskNode *node_c = BLI_task_graph_node_create(graph, TaskData_increase_value, &data, nullptr);
TaskNode *node_d = BLI_task_graph_node_create(
- graph, TaskData_multiply_by_two_store, &data, NULL);
+ graph, TaskData_multiply_by_two_store, &data, nullptr);
BLI_task_graph_edge_create(node_a, node_b);
BLI_task_graph_edge_create(node_b, node_c);
BLI_task_graph_edge_create(node_b, node_d);
@@ -134,12 +134,13 @@ TEST(task, GraphForest)
{
TaskNode *tree1_node_a = BLI_task_graph_node_create(
- graph, TaskData_increase_value, &data1, NULL);
- TaskNode *tree1_node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data1, NULL);
+ graph, TaskData_increase_value, &data1, nullptr);
+ TaskNode *tree1_node_b = BLI_task_graph_node_create(
+ graph, TaskData_store_value, &data1, nullptr);
TaskNode *tree1_node_c = BLI_task_graph_node_create(
- graph, TaskData_increase_value, &data1, NULL);
+ graph, TaskData_increase_value, &data1, nullptr);
TaskNode *tree1_node_d = BLI_task_graph_node_create(
- graph, TaskData_multiply_by_two_store, &data1, NULL);
+ graph, TaskData_multiply_by_two_store, &data1, nullptr);
BLI_task_graph_edge_create(tree1_node_a, tree1_node_b);
BLI_task_graph_edge_create(tree1_node_b, tree1_node_c);
BLI_task_graph_edge_create(tree1_node_b, tree1_node_d);
@@ -148,12 +149,13 @@ TEST(task, GraphForest)
{
TaskNode *tree2_node_a = BLI_task_graph_node_create(
- graph, TaskData_increase_value, &data2, NULL);
- TaskNode *tree2_node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data2, NULL);
+ graph, TaskData_increase_value, &data2, nullptr);
+ TaskNode *tree2_node_b = BLI_task_graph_node_create(
+ graph, TaskData_store_value, &data2, nullptr);
TaskNode *tree2_node_c = BLI_task_graph_node_create(
- graph, TaskData_increase_value, &data2, NULL);
+ graph, TaskData_increase_value, &data2, nullptr);
TaskNode *tree2_node_d = BLI_task_graph_node_create(
- graph, TaskData_multiply_by_two_store, &data2, NULL);
+ graph, TaskData_multiply_by_two_store, &data2, nullptr);
BLI_task_graph_edge_create(tree2_node_a, tree2_node_b);
BLI_task_graph_edge_create(tree2_node_b, tree2_node_c);
BLI_task_graph_edge_create(tree2_node_b, tree2_node_d);
@@ -175,7 +177,7 @@ TEST(task, GraphTaskData)
TaskGraph *graph = BLI_task_graph_create();
TaskNode *node_a = BLI_task_graph_node_create(
graph, TaskData_store_value, &data, TaskData_increase_value);
- TaskNode *node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data, NULL);
+ TaskNode *node_b = BLI_task_graph_node_create(graph, TaskData_store_value, &data, nullptr);
BLI_task_graph_edge_create(node_a, node_b);
EXPECT_TRUE(BLI_task_graph_node_push_work(node_a));
BLI_task_graph_work_and_wait(graph);
diff --git a/source/blender/blenlib/tests/BLI_task_test.cc b/source/blender/blenlib/tests/BLI_task_test.cc
index 3abaf6a6c0b..2a3fddf5e3d 100644
--- a/source/blender/blenlib/tests/BLI_task_test.cc
+++ b/source/blender/blenlib/tests/BLI_task_test.cc
@@ -72,7 +72,7 @@ static void task_mempool_iter_func(void *userdata, MempoolIterData *item)
int *data = (int *)item;
int *count = (int *)userdata;
- EXPECT_TRUE(data != NULL);
+ EXPECT_TRUE(data != nullptr);
*data += 1;
atomic_sub_and_fetch_uint32((uint32_t *)count, 1);
@@ -97,12 +97,12 @@ TEST(task, MempoolIter)
for (i = 0; i < NUM_ITEMS; i += 3) {
BLI_mempool_free(mempool, data[i]);
- data[i] = NULL;
+ data[i] = nullptr;
num_items--;
}
for (i = 0; i < NUM_ITEMS; i += 7) {
- if (data[i] == NULL) {
+ if (data[i] == nullptr) {
data[i] = (int *)BLI_mempool_alloc(mempool);
*data[i] = i - 1;
num_items++;
@@ -111,9 +111,9 @@ TEST(task, MempoolIter)
for (i = 0; i < NUM_ITEMS - 5; i += 23) {
for (int j = 0; j < 5; j++) {
- if (data[i + j] != NULL) {
+ if (data[i + j] != nullptr) {
BLI_mempool_free(mempool, data[i + j]);
- data[i + j] = NULL;
+ data[i + j] = nullptr;
num_items--;
}
}
@@ -125,7 +125,7 @@ TEST(task, MempoolIter)
* expected. */
EXPECT_EQ(num_items, 0);
for (i = 0; i < NUM_ITEMS; i++) {
- if (data[i] != NULL) {
+ if (data[i] != nullptr) {
EXPECT_EQ(*data[i], i);
}
}
@@ -150,7 +150,7 @@ static void task_listbase_iter_func(void *userdata,
TEST(task, ListBaseIter)
{
- ListBase list = {NULL, NULL};
+ ListBase list = {nullptr, nullptr};
LinkData *items_buffer = (LinkData *)MEM_calloc_arrayN(
NUM_ITEMS, sizeof(*items_buffer), __func__);
BLI_threadapi_init();
@@ -172,7 +172,7 @@ TEST(task, ListBaseIter)
* as expected. */
EXPECT_EQ(num_items, 0);
LinkData *item;
- for (i = 0, item = (LinkData *)list.first; i < NUM_ITEMS && item != NULL;
+ for (i = 0, item = (LinkData *)list.first; i < NUM_ITEMS && item != nullptr;
i++, item = item->next) {
EXPECT_EQ(POINTER_AS_INT(item->data), i);
}
diff --git a/source/blender/blenlib/tests/BLI_vector_set_test.cc b/source/blender/blenlib/tests/BLI_vector_set_test.cc
index 320cb15f450..bbbe96f9b7e 100644
--- a/source/blender/blenlib/tests/BLI_vector_set_test.cc
+++ b/source/blender/blenlib/tests/BLI_vector_set_test.cc
@@ -142,9 +142,9 @@ TEST(vector_set, AddMultipleTimes)
TEST(vector_set, UniquePtrValue)
{
VectorSet<std::unique_ptr<int>> set;
- set.add_new(std::unique_ptr<int>(new int()));
- set.add(std::unique_ptr<int>(new int()));
- set.index_of_try(std::unique_ptr<int>(new int()));
+ set.add_new(std::make_unique<int>());
+ set.add(std::make_unique<int>());
+ set.index_of_try(std::make_unique<int>());
std::unique_ptr<int> value = set.pop();
UNUSED_VARS(value);
}
diff --git a/source/blender/blenlib/tests/BLI_vector_test.cc b/source/blender/blenlib/tests/BLI_vector_test.cc
index e6b2e7c6365..462f13c15ab 100644
--- a/source/blender/blenlib/tests/BLI_vector_test.cc
+++ b/source/blender/blenlib/tests/BLI_vector_test.cc
@@ -79,11 +79,11 @@ struct TestListValue {
TEST(vector, ListBaseConstructor)
{
- TestListValue *value1 = new TestListValue{0, 0, 4};
- TestListValue *value2 = new TestListValue{0, 0, 5};
- TestListValue *value3 = new TestListValue{0, 0, 6};
+ TestListValue *value1 = new TestListValue{nullptr, nullptr, 4};
+ TestListValue *value2 = new TestListValue{nullptr, nullptr, 5};
+ TestListValue *value3 = new TestListValue{nullptr, nullptr, 6};
- ListBase list = {NULL, NULL};
+ ListBase list = {nullptr, nullptr};
BLI_addtail(&list, value1);
BLI_addtail(&list, value2);
BLI_addtail(&list, value3);
@@ -456,10 +456,10 @@ TEST(vector, AppendNTimes)
TEST(vector, UniquePtrValue)
{
Vector<std::unique_ptr<int>> vec;
- vec.append(std::unique_ptr<int>(new int()));
- vec.append(std::unique_ptr<int>(new int()));
- vec.append(std::unique_ptr<int>(new int()));
- vec.append(std::unique_ptr<int>(new int()));
+ vec.append(std::make_unique<int>());
+ vec.append(std::make_unique<int>());
+ vec.append(std::make_unique<int>());
+ vec.append(std::make_unique<int>());
EXPECT_EQ(vec.size(), 4);
std::unique_ptr<int> &a = vec.last();
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 6400bec93f9..9a374cd0b1f 100644
--- a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
+++ b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
@@ -152,7 +152,7 @@ static void str_ghash_tests(GHash *ghash, const char *id)
TIMEIT_END(string_lookup);
}
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
MEM_freeN(data);
MEM_freeN(data_p);
MEM_freeN(data_w);
@@ -227,7 +227,7 @@ static void int_ghash_tests(GHash *ghash, const char *id, const unsigned int nbr
}
EXPECT_EQ(BLI_ghash_len(ghash), 0);
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
printf("========== ENDED %s ==========\n\n", id);
}
@@ -309,7 +309,7 @@ static void randint_ghash_tests(GHash *ghash, const char *id, const unsigned int
TIMEIT_END(int_lookup);
}
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
MEM_freeN(data);
printf("========== ENDED %s ==========\n\n", id);
@@ -421,7 +421,7 @@ static void int4_ghash_tests(GHash *ghash, const char *id, const unsigned int nb
TIMEIT_END(int_v4_lookup);
}
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
MEM_freeN(data);
printf("========== ENDED %s ==========\n\n", id);
@@ -506,7 +506,7 @@ static void multi_small_ghash_tests_one(GHash *ghash, RNG *rng, const unsigned i
EXPECT_EQ(POINTER_AS_UINT(v), *dt);
}
- BLI_ghash_clear(ghash, NULL, NULL);
+ BLI_ghash_clear(ghash, nullptr, nullptr);
MEM_freeN(data);
}
@@ -538,7 +538,7 @@ static void multi_small_ghash_tests(GHash *ghash, const char *id, const unsigned
TIMEIT_END(multi_small2_ghash);
- BLI_ghash_free(ghash, NULL, NULL);
+ BLI_ghash_free(ghash, nullptr, nullptr);
BLI_rng_free(rng);
printf("========== ENDED %s ==========\n\n", id);
diff --git a/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
index 208f168b599..c5b0f86e384 100644
--- a/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
+++ b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
@@ -119,7 +119,7 @@ static void task_listbase_test_do(ListBase *list,
}
LinkData *item;
int j;
- for (j = 0, item = (LinkData *)list->first; j < num_items && item != NULL;
+ for (j = 0, item = (LinkData *)list->first; j < num_items && item != nullptr;
j++, item = item->next) {
EXPECT_EQ(POINTER_AS_INT(item->data), j);
item->data = POINTER_FROM_INT(0);
@@ -139,7 +139,7 @@ static void task_listbase_test(const char *id, const int nbr, const bool use_thr
{
printf("\n========== STARTING %s ==========\n", id);
- ListBase list = {NULL, NULL};
+ ListBase list = {nullptr, nullptr};
LinkData *items_buffer = (LinkData *)MEM_calloc_arrayN(nbr, sizeof(*items_buffer), __func__);
BLI_threadapi_init();
diff --git a/source/blender/blenloader/BLO_read_write.h b/source/blender/blenloader/BLO_read_write.h
index 5d685cc6687..c4480e2c544 100644
--- a/source/blender/blenloader/BLO_read_write.h
+++ b/source/blender/blenloader/BLO_read_write.h
@@ -43,6 +43,8 @@
/* for SDNA_TYPE_FROM_STRUCT() macro */
#include "dna_type_offsets.h"
+#include "DNA_windowmanager_types.h" /* for ReportType */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -52,6 +54,9 @@ typedef struct BlendExpander BlendExpander;
typedef struct BlendLibReader BlendLibReader;
typedef struct BlendWriter BlendWriter;
+struct Main;
+struct ReportList;
+
/* Blend Write API
* ===============
*
@@ -106,6 +111,14 @@ void BLO_write_struct_at_address_by_id(BlendWriter *writer,
BLO_write_struct_at_address_by_id( \
writer, BLO_get_struct_id(writer, struct_name), address, data_ptr)
+/* Write single struct at address and specify a filecode. */
+void BLO_write_struct_at_address_by_id_with_filecode(
+ BlendWriter *writer, int filecode, int struct_id, const void *address, const void *data_ptr);
+#define BLO_write_struct_at_address_with_filecode( \
+ writer, filecode, struct_name, address, data_ptr) \
+ BLO_write_struct_at_address_by_id_with_filecode( \
+ writer, filecode, BLO_get_struct_id(writer, struct_name), address, data_ptr)
+
/* Write struct array. */
void BLO_write_struct_array_by_name(BlendWriter *writer,
const char *struct_name,
@@ -177,6 +190,7 @@ bool BLO_write_is_undo(BlendWriter *writer);
*/
void *BLO_read_get_new_data_address(BlendDataReader *reader, const void *old_address);
+void *BLO_read_get_new_data_address_no_us(BlendDataReader *reader, const void *old_address);
void *BLO_read_get_new_packed_address(BlendDataReader *reader, const void *old_address);
#define BLO_read_data_address(reader, ptr_p) \
@@ -199,6 +213,9 @@ void BLO_read_pointer_array(BlendDataReader *reader, void **ptr_p);
/* Misc. */
bool BLO_read_requires_endian_switch(BlendDataReader *reader);
bool BLO_read_data_is_undo(BlendDataReader *reader);
+void BLO_read_data_globmap_add(BlendDataReader *reader, void *oldaddr, void *newaddr);
+void BLO_read_glob_list(BlendDataReader *reader, struct ListBase *list);
+struct ReportList *BLO_read_data_reports(BlendDataReader *reader);
/* Blend Read Lib API
* ===================
@@ -214,6 +231,8 @@ ID *BLO_read_get_new_id_address(BlendLibReader *reader, struct Library *lib, str
/* Misc. */
bool BLO_read_lib_is_undo(BlendLibReader *reader);
+struct Main *BLO_read_lib_get_main(BlendLibReader *reader);
+struct ReportList *BLO_read_lib_reports(BlendLibReader *reader);
/* Blend Expand API
* ===================
@@ -226,6 +245,13 @@ void BLO_expand_id(BlendExpander *expander, struct ID *id);
#define BLO_expand(expander, id) BLO_expand_id(expander, (struct ID *)id)
+/* Report API
+ * ===================
+ */
+
+void BLO_reportf_wrap(struct ReportList *reports, ReportType type, const char *format, ...)
+ ATTR_PRINTF_FORMAT(3, 4);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index c44bd8d0039..b65a3c4d58e 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -30,11 +30,11 @@ set(INC
../makesdna
../makesrna
../nodes
- ../render/extern/include
+ ../render
../sequencer
../windowmanager
- ../../../intern/guardedalloc
../../../intern/clog
+ ../../../intern/guardedalloc
# for writefile.c: dna_type_offsets.h
${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 5a6324eb8e1..2c10dd446f1 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -44,59 +44,17 @@
#define DNA_DEPRECATED_ALLOW
#include "DNA_anim_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_brush_types.h"
#include "DNA_cachefile_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_cloth_types.h"
-#include "DNA_collection_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_curveprofile_types.h"
-#include "DNA_dynamicpaint_types.h"
-#include "DNA_effect_types.h"
#include "DNA_fileglobal_types.h"
-#include "DNA_fluid_types.h"
#include "DNA_genfile.h"
-#include "DNA_gpencil_modifier_types.h"
-#include "DNA_gpencil_types.h"
-#include "DNA_hair_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
-#include "DNA_lattice_types.h"
#include "DNA_layer_types.h"
-#include "DNA_light_types.h"
-#include "DNA_lightprobe_types.h"
-#include "DNA_linestyle_types.h"
-#include "DNA_mask_types.h"
-#include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_meta_types.h"
-#include "DNA_movieclip_types.h"
-#include "DNA_nla_types.h"
#include "DNA_node_types.h"
-#include "DNA_object_fluidsim_types.h"
-#include "DNA_object_types.h"
#include "DNA_packedFile_types.h"
-#include "DNA_particle_types.h"
-#include "DNA_pointcache_types.h"
-#include "DNA_pointcloud_types.h"
-#include "DNA_rigidbody_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
#include "DNA_sdna_types.h"
-#include "DNA_sequence_types.h"
-#include "DNA_shader_fx_types.h"
-#include "DNA_simulation_types.h"
#include "DNA_sound_types.h"
-#include "DNA_space_types.h"
-#include "DNA_speaker_types.h"
-#include "DNA_text_types.h"
-#include "DNA_vfont_types.h"
-#include "DNA_view3d_types.h"
#include "DNA_volume_types.h"
#include "DNA_workspace_types.h"
-#include "DNA_world_types.h"
#include "MEM_guardedalloc.h"
@@ -111,29 +69,12 @@
#include "BLT_translation.h"
-#include "BKE_action.h"
#include "BKE_anim_data.h"
#include "BKE_animsys.h"
-#include "BKE_armature.h"
-#include "BKE_brush.h"
#include "BKE_collection.h"
-#include "BKE_colortools.h"
-#include "BKE_constraint.h"
-#include "BKE_curve.h"
-#include "BKE_curveprofile.h"
-#include "BKE_deform.h"
-#include "BKE_effect.h"
-#include "BKE_fcurve.h"
-#include "BKE_fcurve_driver.h"
-#include "BKE_fluid.h"
#include "BKE_global.h" /* for G */
-#include "BKE_gpencil.h"
-#include "BKE_gpencil_modifier.h"
-#include "BKE_hair.h"
-#include "BKE_icons.h"
#include "BKE_idprop.h"
#include "BKE_idtype.h"
-#include "BKE_image.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_lib_override.h"
@@ -141,43 +82,26 @@
#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_runtime.h"
#include "BKE_modifier.h"
-#include "BKE_multires.h"
-#include "BKE_nla.h"
#include "BKE_node.h" /* for tree type defines */
#include "BKE_object.h"
#include "BKE_packedFile.h"
-#include "BKE_paint.h"
-#include "BKE_particle.h"
-#include "BKE_pointcache.h"
-#include "BKE_pointcloud.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
-#include "BKE_sequencer.h"
-#include "BKE_shader_fx.h"
-#include "BKE_simulation.h"
-#include "BKE_sound.h"
-#include "BKE_volume.h"
#include "BKE_workspace.h"
#include "DRW_engine.h"
#include "DEG_depsgraph.h"
-#include "NOD_socket.h"
-
#include "BLO_blend_defs.h"
#include "BLO_blend_validate.h"
#include "BLO_read_write.h"
#include "BLO_readfile.h"
#include "BLO_undofile.h"
-#include "RE_engine.h"
-
-#include "engines/eevee/eevee_lightcache.h"
+#include "SEQ_sequencer.h"
#include "readfile.h"
@@ -263,15 +187,10 @@
/* local prototypes */
static void read_libraries(FileData *basefd, ListBase *mainlist);
static void *read_struct(FileData *fd, BHead *bh, const char *blockname);
-static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object *ob);
static BHead *find_bhead_from_code_name(FileData *fd, const short idcode, const char *name);
static BHead *find_bhead_from_idname(FileData *fd, const char *idname);
static bool library_link_idcode_needs_tag_check(const short idcode, const int flag);
-#ifdef USE_COLLECTION_COMPAT_28
-static void expand_scene_collection(BlendExpander *expander, SceneCollection *sc);
-#endif
-
typedef struct BHeadN {
struct BHeadN *next, *prev;
#ifdef USE_BHEAD_READ_ON_DEMAND
@@ -297,7 +216,7 @@ typedef struct BHeadN {
* bit kludge but better than doubling up on prints,
* we could alternatively have a versions of a report function which forces printing - campbell
*/
-void blo_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...)
+void BLO_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...)
{
char fixed_buf[1024]; /* should be long enough */
@@ -2262,7 +2181,6 @@ static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
* \{ */
static void lib_link_id(BlendLibReader *reader, ID *id);
-static void lib_link_collection(BlendLibReader *reader, Collection *collection);
static void lib_link_id_embedded_id(BlendLibReader *reader, ID *id)
{
@@ -2278,7 +2196,7 @@ static void lib_link_id_embedded_id(BlendLibReader *reader, ID *id)
Scene *scene = (Scene *)id;
if (scene->master_collection != NULL) {
lib_link_id(reader, &scene->master_collection->id);
- lib_link_collection(reader, scene->master_collection);
+ BKE_collection_blend_read_lib(reader, scene->master_collection);
}
}
}
@@ -2325,7 +2243,6 @@ static void direct_link_id_override_property_cb(BlendDataReader *reader, void *d
static void direct_link_id_common(
BlendDataReader *reader, Library *current_library, ID *id, ID *id_old, const int tag);
-static void direct_link_collection(BlendDataReader *reader, Collection *collection);
static void direct_link_id_embedded_id(BlendDataReader *reader,
Library *current_library,
@@ -2353,7 +2270,7 @@ static void direct_link_id_embedded_id(BlendDataReader *reader,
&scene->master_collection->id,
id_old != NULL ? &((Scene *)id_old)->master_collection->id : NULL,
0);
- direct_link_collection(reader, scene->master_collection);
+ BKE_collection_blend_read_data(reader, scene->master_collection);
}
}
}
@@ -2490,325 +2407,6 @@ static void direct_link_id_common(
/** \name Read Animation (legacy for version patching)
* \{ */
-/* XXX deprecated - old animation system */
-static void lib_link_ipo(BlendLibReader *reader, Ipo *ipo)
-{
- LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
- if (icu->driver) {
- BLO_read_id_address(reader, ipo->id.lib, &icu->driver->ob);
- }
- }
-}
-
-/* XXX deprecated - old animation system */
-static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo)
-{
- BLO_read_list(reader, &(ipo->curve));
-
- LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
- 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);
- 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);
- }
-}
-
-/* XXX deprecated - old animation system */
-static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *striplist)
-{
- LISTBASE_FOREACH (bActionStrip *, strip, striplist) {
- BLO_read_id_address(reader, id->lib, &strip->object);
- BLO_read_id_address(reader, id->lib, &strip->act);
- BLO_read_id_address(reader, id->lib, &strip->ipo);
- LISTBASE_FOREACH (bActionModifier *, amod, &strip->modifiers) {
- BLO_read_id_address(reader, id->lib, &amod->ob);
- }
- }
-}
-
-/* XXX deprecated - old animation system */
-static void direct_link_nlastrips(BlendDataReader *reader, ListBase *strips)
-{
- BLO_read_list(reader, strips);
-
- LISTBASE_FOREACH (bActionStrip *, strip, strips) {
- BLO_read_list(reader, &strip->modifiers);
- }
-}
-
-/* XXX deprecated - old animation system */
-static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
-{
- LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
- BLO_read_id_address(reader, id->lib, &chan->ipo);
- }
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Read ID: WorkSpace
- * \{ */
-
-static void lib_link_workspaces(BlendLibReader *reader, WorkSpace *workspace)
-{
- ID *id = (ID *)workspace;
-
- /* Restore proper 'parent' pointers to relevant data, and clean up unused/invalid entries. */
- LISTBASE_FOREACH_MUTABLE (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) {
- relation->parent = NULL;
- LISTBASE_FOREACH (wmWindowManager *, wm, &reader->main->wm) {
- LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
- if (win->winid == relation->parentid) {
- relation->parent = win->workspace_hook;
- }
- }
- }
- if (relation->parent == NULL) {
- BLI_freelinkN(&workspace->hook_layout_relations, relation);
- }
- }
-
- LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout, &workspace->layouts) {
- BLO_read_id_address(reader, id->lib, &layout->screen);
-
- if (layout->screen) {
- if (ID_IS_LINKED(id)) {
- layout->screen->winid = 0;
- if (layout->screen->temp) {
- /* delete temp layouts when appending */
- BKE_workspace_layout_remove(reader->main, workspace, layout);
- }
- }
- }
- else {
- /* If we're reading a layout without screen stored, it's useless and we shouldn't keep it
- * around. */
- BKE_workspace_layout_remove(reader->main, workspace, layout);
- }
- }
-}
-
-static void direct_link_workspace(BlendDataReader *reader, WorkSpace *workspace)
-{
- BLO_read_list(reader, &workspace->layouts);
- BLO_read_list(reader, &workspace->hook_layout_relations);
- BLO_read_list(reader, &workspace->owner_ids);
- BLO_read_list(reader, &workspace->tools);
-
- LISTBASE_FOREACH (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) {
- /* parent pointer does not belong to workspace data and is therefore restored in lib_link step
- * of window manager.*/
- BLO_read_data_address(reader, &relation->value);
- }
-
- LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
- tref->runtime = NULL;
- BLO_read_data_address(reader, &tref->properties);
- IDP_BlendDataRead(reader, &tref->properties);
- }
-
- workspace->status_text = NULL;
-
- id_us_ensure_real(&workspace->id);
-}
-
-static void lib_link_workspace_instance_hook(BlendLibReader *reader,
- WorkSpaceInstanceHook *hook,
- ID *id)
-{
- WorkSpace *workspace = BKE_workspace_active_get(hook);
- BLO_read_id_address(reader, id->lib, &workspace);
- BKE_workspace_active_set(hook, workspace);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Read ID: Armature
- * \{ */
-
-/* temp struct used to transport needed info to lib_link_constraint_cb() */
-typedef struct tConstraintLinkData {
- BlendLibReader *reader;
- ID *id;
-} tConstraintLinkData;
-/* callback function used to relink constraint ID-links */
-static void lib_link_constraint_cb(bConstraint *UNUSED(con),
- ID **idpoin,
- bool UNUSED(is_reference),
- void *userdata)
-{
- tConstraintLinkData *cld = (tConstraintLinkData *)userdata;
- BLO_read_id_address(cld->reader, cld->id->lib, idpoin);
-}
-
-static void lib_link_constraints(BlendLibReader *reader, ID *id, ListBase *conlist)
-{
- tConstraintLinkData cld;
-
- /* legacy fixes */
- LISTBASE_FOREACH (bConstraint *, con, conlist) {
- /* patch for error introduced by changing constraints (dunno how) */
- /* if con->data type changes, dna cannot resolve the pointer! (ton) */
- if (con->data == NULL) {
- 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 */
-
- /* If linking from a library, clear 'local' library override flag. */
- if (id->lib != NULL) {
- con->flag &= ~CONSTRAINT_OVERRIDE_LIBRARY_LOCAL;
- }
- }
-
- /* relink all ID-blocks used by the constraints */
- cld.reader = reader;
- cld.id = id;
-
- BKE_constraints_id_loop(conlist, lib_link_constraint_cb, &cld);
-}
-
-static void direct_link_constraints(BlendDataReader *reader, ListBase *lb)
-{
- BLO_read_list(reader, lb);
- LISTBASE_FOREACH (bConstraint *, con, lb) {
- BLO_read_data_address(reader, &con->data);
-
- switch (con->type) {
- case CONSTRAINT_TYPE_PYTHON: {
- bPythonConstraint *data = con->data;
-
- BLO_read_list(reader, &data->targets);
-
- BLO_read_data_address(reader, &data->prop);
- IDP_BlendDataRead(reader, &data->prop);
- break;
- }
- case CONSTRAINT_TYPE_ARMATURE: {
- bArmatureConstraint *data = con->data;
-
- BLO_read_list(reader, &data->targets);
-
- break;
- }
- case CONSTRAINT_TYPE_SPLINEIK: {
- bSplineIKConstraint *data = con->data;
-
- BLO_read_data_address(reader, &data->points);
- break;
- }
- case CONSTRAINT_TYPE_KINEMATIC: {
- bKinematicConstraint *data = con->data;
-
- con->lin_error = 0.f;
- con->rot_error = 0.f;
-
- /* version patch for runtime flag, was not cleared in some case */
- data->flag &= ~CONSTRAINT_IK_AUTO;
- break;
- }
- case CONSTRAINT_TYPE_CHILDOF: {
- /* XXX version patch, in older code this flag wasn't always set, and is inherent to type */
- if (con->ownspace == CONSTRAINT_SPACE_POSE) {
- con->flag |= CONSTRAINT_SPACEONCE;
- }
- break;
- }
- case CONSTRAINT_TYPE_TRANSFORM_CACHE: {
- bTransformCacheConstraint *data = con->data;
- data->reader = NULL;
- data->reader_object_path[0] = '\0';
- }
- }
- }
-}
-
-static void lib_link_pose(BlendLibReader *reader, Object *ob, bPose *pose)
-{
- bArmature *arm = ob->data;
-
- if (!pose || !arm) {
- return;
- }
-
- /* always rebuild to match proxy or lib changes, but on Undo */
- bool rebuild = false;
-
- if (!BLO_read_lib_is_undo(reader)) {
- if (ob->proxy || ob->id.lib != arm->id.lib) {
- rebuild = true;
- }
- }
-
- if (ob->proxy) {
- /* sync proxy layer */
- if (pose->proxy_layer) {
- arm->layer = pose->proxy_layer;
- }
-
- /* sync proxy active bone */
- if (pose->proxy_act_bone[0]) {
- Bone *bone = BKE_armature_find_bone_name(arm, pose->proxy_act_bone);
- if (bone) {
- arm->act_bone = bone;
- }
- }
- }
-
- LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
- lib_link_constraints(reader, (ID *)ob, &pchan->constraints);
-
- pchan->bone = BKE_armature_find_bone_name(arm, pchan->name);
-
- IDP_BlendReadLib(reader, pchan->prop);
-
- BLO_read_id_address(reader, arm->id.lib, &pchan->custom);
- if (UNLIKELY(pchan->bone == NULL)) {
- rebuild = true;
- }
- else if ((ob->id.lib == NULL) && arm->id.lib) {
- /* local pose selection copied to armature, bit hackish */
- pchan->bone->flag &= ~BONE_SELECTED;
- pchan->bone->flag |= pchan->selectflag;
- }
- }
-
- if (rebuild) {
- DEG_id_tag_update_ex(
- reader->main, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
- BKE_pose_tag_recalc(reader->main, pose);
- }
-}
-
/** \} */
/* -------------------------------------------------------------------- */
@@ -2826,1517 +2424,9 @@ void blo_do_versions_key_uidgen(Key *key)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Read ID: Particle Settings
- * \{ */
-
-/* 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: */
-};
-
-static void direct_link_pointcache_cb(BlendDataReader *reader, void *data)
-{
- PTCacheMem *pm = data;
- for (int i = 0; i < BPHYS_TOT_DATA; i++) {
- BLO_read_data_address(reader, &pm->data[i]);
-
- /* the cache saves non-struct data without DNA */
- if (pm->data[i] && ptcache_data_struct[i][0] == '\0' &&
- BLO_read_requires_endian_switch(reader)) {
- /* data_size returns bytes. */
- int tot = (BKE_ptcache_data_size(i) * pm->totpoint) / sizeof(int);
-
- int *poin = pm->data[i];
-
- BLI_endian_switch_int32_array(poin, tot);
- }
- }
-
- BLO_read_list(reader, &pm->extradata);
-
- LISTBASE_FOREACH (PTCacheExtra *, extra, &pm->extradata) {
- BLO_read_data_address(reader, &extra->data);
- }
-}
-
-static void direct_link_pointcache(BlendDataReader *reader, PointCache *cache)
-{
- if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
- BLO_read_list_cb(reader, &cache->mem_cache, direct_link_pointcache_cb);
- }
- else {
- BLI_listbase_clear(&cache->mem_cache);
- }
-
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe = 0;
- cache->edit = NULL;
- cache->free_edit = NULL;
- cache->cached_frames = NULL;
- cache->cached_frames_len = 0;
-}
-
-static void direct_link_pointcache_list(BlendDataReader *reader,
- ListBase *ptcaches,
- PointCache **ocache,
- int force_disk)
-{
- if (ptcaches->first) {
- BLO_read_list(reader, ptcaches);
- LISTBASE_FOREACH (PointCache *, cache, ptcaches) {
- direct_link_pointcache(reader, cache);
- if (force_disk) {
- cache->flag |= PTCACHE_DISK_CACHE;
- cache->step = 1;
- }
- }
-
- BLO_read_data_address(reader, ocache);
- }
- else if (*ocache) {
- /* old "single" caches need to be linked too */
- BLO_read_data_address(reader, ocache);
- direct_link_pointcache(reader, *ocache);
- if (force_disk) {
- (*ocache)->flag |= PTCACHE_DISK_CACHE;
- (*ocache)->step = 1;
- }
-
- ptcaches->first = ptcaches->last = *ocache;
- }
-}
-
-static void lib_link_partdeflect(BlendLibReader *reader, ID *id, PartDeflect *pd)
-{
- if (pd && pd->tex) {
- BLO_read_id_address(reader, id->lib, &pd->tex);
- }
- if (pd && pd->f_source) {
- BLO_read_id_address(reader, id->lib, &pd->f_source);
- }
-}
-
-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->instance_object);
- BLO_read_id_address(reader, part->id.lib, &part->instance_collection);
- BLO_read_id_address(reader, part->id.lib, &part->force_group);
- BLO_read_id_address(reader, part->id.lib, &part->bb_ob);
- BLO_read_id_address(reader, part->id.lib, &part->collision_group);
-
- lib_link_partdeflect(reader, &part->id, part->pd);
- lib_link_partdeflect(reader, &part->id, part->pd2);
-
- if (part->effector_weights) {
- BLO_read_id_address(reader, part->id.lib, &part->effector_weights->group);
- }
- else {
- part->effector_weights = BKE_effector_add_weights(part->force_group);
- }
-
- if (part->instance_weights.first && part->instance_collection) {
- LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
- BLO_read_id_address(reader, part->id.lib, &dw->ob);
- }
- }
- else {
- BLI_listbase_clear(&part->instance_weights);
- }
-
- if (part->boids) {
- LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
- LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
- switch (rule->type) {
- case eBoidRuleType_Goal:
- case eBoidRuleType_Avoid: {
- BoidRuleGoalAvoid *brga = (BoidRuleGoalAvoid *)rule;
- BLO_read_id_address(reader, part->id.lib, &brga->ob);
- break;
- }
- case eBoidRuleType_FollowLeader: {
- BoidRuleFollowLeader *brfl = (BoidRuleFollowLeader *)rule;
- BLO_read_id_address(reader, part->id.lib, &brfl->ob);
- break;
- }
- }
- }
- }
- }
-
- for (int a = 0; a < MAX_MTEX; a++) {
- MTex *mtex = part->mtex[a];
- if (mtex) {
- BLO_read_id_address(reader, part->id.lib, &mtex->tex);
- BLO_read_id_address(reader, part->id.lib, &mtex->object);
- }
- }
-}
-
-static void direct_link_partdeflect(PartDeflect *pd)
-{
- if (pd) {
- pd->rng = NULL;
- }
-}
-
-static void direct_link_particlesettings(BlendDataReader *reader, ParticleSettings *part)
-{
- BLO_read_data_address(reader, &part->adt);
- BLO_read_data_address(reader, &part->pd);
- BLO_read_data_address(reader, &part->pd2);
-
- BKE_animdata_blend_read_data(reader, part->adt);
- direct_link_partdeflect(part->pd);
- direct_link_partdeflect(part->pd2);
-
- BLO_read_data_address(reader, &part->clumpcurve);
- if (part->clumpcurve) {
- BKE_curvemapping_blend_read(reader, part->clumpcurve);
- }
- BLO_read_data_address(reader, &part->roughcurve);
- if (part->roughcurve) {
- BKE_curvemapping_blend_read(reader, part->roughcurve);
- }
- BLO_read_data_address(reader, &part->twistcurve);
- if (part->twistcurve) {
- BKE_curvemapping_blend_read(reader, part->twistcurve);
- }
-
- BLO_read_data_address(reader, &part->effector_weights);
- if (!part->effector_weights) {
- part->effector_weights = BKE_effector_add_weights(part->force_group);
- }
-
- BLO_read_list(reader, &part->instance_weights);
-
- BLO_read_data_address(reader, &part->boids);
- BLO_read_data_address(reader, &part->fluid);
-
- if (part->boids) {
- BLO_read_list(reader, &part->boids->states);
-
- LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
- BLO_read_list(reader, &state->rules);
- BLO_read_list(reader, &state->conditions);
- BLO_read_list(reader, &state->actions);
- }
- }
- for (int a = 0; a < MAX_MTEX; a++) {
- BLO_read_data_address(reader, &part->mtex[a]);
- }
-
- /* Protect against integer overflow vulnerability. */
- CLAMP(part->trail_count, 1, 100000);
-}
-
-static void lib_link_particlesystems(BlendLibReader *reader,
- Object *ob,
- ID *id,
- ListBase *particles)
-{
- LISTBASE_FOREACH_MUTABLE (ParticleSystem *, psys, particles) {
-
- BLO_read_id_address(reader, id->lib, &psys->part);
- if (psys->part) {
- LISTBASE_FOREACH (ParticleTarget *, pt, &psys->targets) {
- BLO_read_id_address(reader, id->lib, &pt->ob);
- }
-
- BLO_read_id_address(reader, id->lib, &psys->parent);
- BLO_read_id_address(reader, id->lib, &psys->target_ob);
-
- if (psys->clmd) {
- /* XXX - from reading existing code this seems correct but intended usage of
- * pointcache /w cloth should be added in 'ParticleSystem' - campbell */
- psys->clmd->point_cache = psys->pointcache;
- psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL;
- BLO_read_id_address(reader, id->lib, &psys->clmd->coll_parms->group);
- psys->clmd->modifier.error = NULL;
- }
- }
- else {
- /* particle modifier must be removed before particle system */
- ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
- BLI_remlink(&ob->modifiers, psmd);
- BKE_modifier_free((ModifierData *)psmd);
-
- BLI_remlink(particles, psys);
- MEM_freeN(psys);
- }
- }
-}
-static void direct_link_particlesystems(BlendDataReader *reader, ListBase *particles)
-{
- ParticleData *pa;
- int a;
-
- LISTBASE_FOREACH (ParticleSystem *, psys, particles) {
- BLO_read_data_address(reader, &psys->particles);
-
- if (psys->particles && psys->particles->hair) {
- for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
- BLO_read_data_address(reader, &pa->hair);
- }
- }
-
- if (psys->particles && psys->particles->keys) {
- for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
- pa->keys = NULL;
- pa->totkey = 0;
- }
-
- psys->flag &= ~PSYS_KEYED;
- }
-
- if (psys->particles && psys->particles->boid) {
- pa = psys->particles;
- BLO_read_data_address(reader, &pa->boid);
-
- /* This is purely runtime data, but still can be an issue if left dangling. */
- pa->boid->ground = NULL;
-
- for (a = 1, pa++; a < psys->totpart; a++, pa++) {
- pa->boid = (pa - 1)->boid + 1;
- pa->boid->ground = NULL;
- }
- }
- else if (psys->particles) {
- for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
- pa->boid = NULL;
- }
- }
-
- BLO_read_data_address(reader, &psys->fluid_springs);
-
- BLO_read_data_address(reader, &psys->child);
- psys->effectors = NULL;
-
- BLO_read_list(reader, &psys->targets);
-
- psys->edit = NULL;
- psys->free_edit = NULL;
- psys->pathcache = NULL;
- psys->childcache = NULL;
- BLI_listbase_clear(&psys->pathcachebufs);
- BLI_listbase_clear(&psys->childcachebufs);
- psys->pdd = NULL;
-
- if (psys->clmd) {
- BLO_read_data_address(reader, &psys->clmd);
- psys->clmd->clothObject = NULL;
- psys->clmd->hairdata = NULL;
-
- BLO_read_data_address(reader, &psys->clmd->sim_parms);
- BLO_read_data_address(reader, &psys->clmd->coll_parms);
-
- if (psys->clmd->sim_parms) {
- psys->clmd->sim_parms->effector_weights = NULL;
- if (psys->clmd->sim_parms->presets > 10) {
- psys->clmd->sim_parms->presets = 0;
- }
- }
-
- psys->hair_in_mesh = psys->hair_out_mesh = NULL;
- psys->clmd->solver_result = NULL;
- }
-
- direct_link_pointcache_list(reader, &psys->ptcaches, &psys->pointcache, 0);
- if (psys->clmd) {
- psys->clmd->point_cache = psys->pointcache;
- }
-
- psys->tree = NULL;
- psys->bvhtree = NULL;
-
- psys->orig_psys = NULL;
- psys->batch_cache = NULL;
- }
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Read ID: Mesh
- * \{ */
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Read ID: Object
- * \{ */
-
-static void lib_link_modifiers_common(void *userData, Object *ob, ID **idpoin, int cb_flag)
-{
- BlendLibReader *reader = userData;
-
- BLO_read_id_address(reader, ob->id.lib, idpoin);
- if (*idpoin != NULL && (cb_flag & IDWALK_CB_USER) != 0) {
- id_us_plus_no_lib(*idpoin);
- }
-}
-
-static void lib_link_modifiers(BlendLibReader *reader, Object *ob)
-{
- BKE_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, reader);
-
- /* If linking from a library, clear 'local' library override flag. */
- if (ob->id.lib != NULL) {
- LISTBASE_FOREACH (ModifierData *, mod, &ob->modifiers) {
- mod->flag &= ~eModifierFlag_OverrideLibrary_Local;
- }
- }
-}
-
-static void lib_link_gpencil_modifiers(BlendLibReader *reader, Object *ob)
-{
- BKE_gpencil_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, reader);
-
- /* If linking from a library, clear 'local' library override flag. */
- if (ob->id.lib != NULL) {
- LISTBASE_FOREACH (GpencilModifierData *, mod, &ob->greasepencil_modifiers) {
- mod->flag &= ~eGpencilModifierFlag_OverrideLibrary_Local;
- }
- }
-}
-
-static void lib_link_shaderfxs(BlendLibReader *reader, Object *ob)
-{
- BKE_shaderfx_foreach_ID_link(ob, lib_link_modifiers_common, reader);
-
- /* If linking from a library, clear 'local' library override flag. */
- if (ob->id.lib != NULL) {
- LISTBASE_FOREACH (ShaderFxData *, fx, &ob->shader_fx) {
- fx->flag &= ~eShaderFxFlag_OverrideLibrary_Local;
- }
- }
-}
-
-static void lib_link_object(BlendLibReader *reader, Object *ob)
-{
- bool warn = false;
-
- /* 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 */
-
- BLO_read_id_address(reader, ob->id.lib, &ob->parent);
- BLO_read_id_address(reader, ob->id.lib, &ob->track);
- BLO_read_id_address(reader, ob->id.lib, &ob->poselib);
-
- /* 2.8x drops support for non-empty dupli instances. */
- if (ob->type == OB_EMPTY) {
- BLO_read_id_address(reader, ob->id.lib, &ob->instance_collection);
- }
- else {
- if (ob->instance_collection != NULL) {
- ID *id = BLO_read_get_new_id_address(reader, ob->id.lib, &ob->instance_collection->id);
- blo_reportf_wrap(reader->fd->reports,
- RPT_WARNING,
- TIP_("Non-Empty object '%s' cannot duplicate collection '%s' "
- "anymore in Blender 2.80, removed instancing"),
- ob->id.name + 2,
- id->name + 2);
- }
- ob->instance_collection = NULL;
- ob->transflag &= ~OB_DUPLICOLLECTION;
- }
-
- BLO_read_id_address(reader, ob->id.lib, &ob->proxy);
- if (ob->proxy) {
- /* paranoia check, actually a proxy_from pointer should never be written... */
- if (ob->proxy->id.lib == NULL) {
- ob->proxy->proxy_from = NULL;
- ob->proxy = NULL;
-
- if (ob->id.lib) {
- printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->filepath);
- }
- else {
- printf("Proxy lost from object %s lib <NONE>\n", ob->id.name + 2);
- }
- }
- else {
- /* this triggers object_update to always use a copy */
- ob->proxy->proxy_from = ob;
- }
- }
- BLO_read_id_address(reader, ob->id.lib, &ob->proxy_group);
-
- void *poin = ob->data;
- BLO_read_id_address(reader, ob->id.lib, &ob->data);
-
- if (ob->data == NULL && poin != NULL) {
- if (ob->id.lib) {
- printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->filepath);
- }
- else {
- printf("Object %s lost data.\n", ob->id.name + 2);
- }
-
- ob->type = OB_EMPTY;
- warn = true;
-
- if (ob->pose) {
- /* we can't call #BKE_pose_free() here because of library linking
- * freeing will recurse down into every pose constraints ID pointers
- * which are not always valid, so for now free directly and suffer
- * some leaked memory rather than crashing immediately
- * while bad this _is_ an exceptional case - campbell */
-#if 0
- BKE_pose_free(ob->pose);
-#else
- MEM_freeN(ob->pose);
-#endif
- ob->pose = NULL;
- ob->mode &= ~OB_MODE_POSE;
- }
- }
- for (int a = 0; a < ob->totcol; a++) {
- BLO_read_id_address(reader, ob->id.lib, &ob->mat[a]);
- }
-
- /* When the object is local and the data is library its possible
- * the material list size gets out of sync. T22663. */
- if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) {
- const short *totcol_data = BKE_object_material_len_p(ob);
- /* Only expand so as not to lose any object materials that might be set. */
- if (totcol_data && (*totcol_data > ob->totcol)) {
- /* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */
- BKE_object_material_resize(reader->main, ob, *totcol_data, false);
- }
- }
-
- BLO_read_id_address(reader, ob->id.lib, &ob->gpd);
-
- /* if id.us==0 a new base will be created later on */
-
- /* WARNING! Also check expand_object(), should reflect the stuff below. */
- lib_link_pose(reader, ob, ob->pose);
- lib_link_constraints(reader, &ob->id, &ob->constraints);
-
- /* 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 */
-
- LISTBASE_FOREACH (PartEff *, paf, &ob->effect) {
- if (paf->type == EFF_PARTICLE) {
- BLO_read_id_address(reader, ob->id.lib, &paf->group);
- }
- }
-
- {
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)BKE_modifiers_findby_type(
- ob, eModifierType_Fluidsim);
-
- if (fluidmd && fluidmd->fss) {
- BLO_read_id_address(
- reader, ob->id.lib, &fluidmd->fss->ipo); /* XXX deprecated - old animation system */
- }
- }
-
- {
- FluidModifierData *fmd = (FluidModifierData *)BKE_modifiers_findby_type(ob,
- eModifierType_Fluid);
-
- if (fmd && (fmd->type == MOD_FLUID_TYPE_DOMAIN) && fmd->domain) {
- /* Flag for refreshing the simulation after loading */
- fmd->domain->flags |= FLUID_DOMAIN_FILE_LOAD;
- }
- else if (fmd && (fmd->type == MOD_FLUID_TYPE_FLOW) && fmd->flow) {
- fmd->flow->flags &= ~FLUID_FLOW_NEEDS_UPDATE;
- }
- else if (fmd && (fmd->type == MOD_FLUID_TYPE_EFFEC) && fmd->effector) {
- fmd->effector->flags &= ~FLUID_EFFECTOR_NEEDS_UPDATE;
- }
- }
-
- /* texture field */
- if (ob->pd) {
- lib_link_partdeflect(reader, &ob->id, ob->pd);
- }
-
- if (ob->soft) {
- BLO_read_id_address(reader, ob->id.lib, &ob->soft->collision_group);
-
- BLO_read_id_address(reader, ob->id.lib, &ob->soft->effector_weights->group);
- }
-
- lib_link_particlesystems(reader, ob, &ob->id, &ob->particlesystem);
- lib_link_modifiers(reader, ob);
- lib_link_gpencil_modifiers(reader, ob);
- lib_link_shaderfxs(reader, ob);
-
- if (ob->rigidbody_constraint) {
- BLO_read_id_address(reader, ob->id.lib, &ob->rigidbody_constraint->ob1);
- BLO_read_id_address(reader, ob->id.lib, &ob->rigidbody_constraint->ob2);
- }
-
- if (warn) {
- BKE_report(reader->fd->reports, RPT_WARNING, "Warning in console");
- }
-}
-
-/* direct data for cache */
-static void direct_link_motionpath(BlendDataReader *reader, bMotionPath *mpath)
-{
- /* sanity check */
- if (mpath == NULL) {
- return;
- }
-
- /* relink points cache */
- BLO_read_data_address(reader, &mpath->points);
-
- mpath->points_vbo = NULL;
- mpath->batch_line = NULL;
- mpath->batch_points = NULL;
-}
-
-static void direct_link_pose(BlendDataReader *reader, bPose *pose)
-{
- if (!pose) {
- return;
- }
-
- BLO_read_list(reader, &pose->chanbase);
- BLO_read_list(reader, &pose->agroups);
-
- pose->chanhash = NULL;
- pose->chan_array = NULL;
-
- LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
- BKE_pose_channel_runtime_reset(&pchan->runtime);
- BKE_pose_channel_session_uuid_generate(pchan);
-
- pchan->bone = NULL;
- BLO_read_data_address(reader, &pchan->parent);
- BLO_read_data_address(reader, &pchan->child);
- BLO_read_data_address(reader, &pchan->custom_tx);
-
- BLO_read_data_address(reader, &pchan->bbone_prev);
- BLO_read_data_address(reader, &pchan->bbone_next);
-
- direct_link_constraints(reader, &pchan->constraints);
-
- BLO_read_data_address(reader, &pchan->prop);
- IDP_BlendDataRead(reader, &pchan->prop);
-
- BLO_read_data_address(reader, &pchan->mpath);
- if (pchan->mpath) {
- direct_link_motionpath(reader, pchan->mpath);
- }
-
- BLI_listbase_clear(&pchan->iktree);
- BLI_listbase_clear(&pchan->siktree);
-
- /* in case this value changes in future, clamp else we get undefined behavior */
- CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
-
- pchan->draw_data = NULL;
- }
- pose->ikdata = NULL;
- if (pose->ikparam != NULL) {
- BLO_read_data_address(reader, &pose->ikparam);
- }
-}
-
-/* TODO(sergey): Find a better place for this.
- *
- * Unfortunately, this can not be done as a regular do_versions() since the modifier type is
- * set to NONE, so the do_versions code wouldn't know where the modifier came from.
- *
- * The best approach seems to have the functionality in versioning_280.c but still call the
- * function from #direct_link_modifiers().
- */
-
-/* Domain, inflow, ... */
-static void modifier_ensure_type(FluidModifierData *fluid_modifier_data, int type)
-{
- fluid_modifier_data->type = type;
- BKE_fluid_modifier_free(fluid_modifier_data);
- BKE_fluid_modifier_create_type_data(fluid_modifier_data);
-}
-
-/**
- * \note The old_modifier_data is NOT linked.
- * This means that in order to access sub-data pointers #newdataadr is to be used.
- */
-static ModifierData *modifier_replace_with_fluid(FileData *fd,
- Object *object,
- ListBase *modifiers,
- ModifierData *old_modifier_data)
-{
- ModifierData *new_modifier_data = BKE_modifier_new(eModifierType_Fluid);
- FluidModifierData *fluid_modifier_data = (FluidModifierData *)new_modifier_data;
-
- if (old_modifier_data->type == eModifierType_Fluidsim) {
- FluidsimModifierData *old_fluidsim_modifier_data = (FluidsimModifierData *)old_modifier_data;
- FluidsimSettings *old_fluidsim_settings = newdataadr(fd, old_fluidsim_modifier_data->fss);
- switch (old_fluidsim_settings->type) {
- case OB_FLUIDSIM_ENABLE:
- modifier_ensure_type(fluid_modifier_data, 0);
- break;
- case OB_FLUIDSIM_DOMAIN:
- modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_DOMAIN);
- BKE_fluid_domain_type_set(object, fluid_modifier_data->domain, FLUID_DOMAIN_TYPE_LIQUID);
- break;
- case OB_FLUIDSIM_FLUID:
- modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
- BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
- /* No need to emit liquid far away from surface. */
- fluid_modifier_data->flow->surface_distance = 0.0f;
- break;
- case OB_FLUIDSIM_OBSTACLE:
- modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_EFFEC);
- BKE_fluid_effector_type_set(
- object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_COLLISION);
- break;
- case OB_FLUIDSIM_INFLOW:
- modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
- BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
- BKE_fluid_flow_behavior_set(object, fluid_modifier_data->flow, FLUID_FLOW_BEHAVIOR_INFLOW);
- /* No need to emit liquid far away from surface. */
- fluid_modifier_data->flow->surface_distance = 0.0f;
- break;
- case OB_FLUIDSIM_OUTFLOW:
- modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_FLOW);
- BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_LIQUID);
- BKE_fluid_flow_behavior_set(
- object, fluid_modifier_data->flow, FLUID_FLOW_BEHAVIOR_OUTFLOW);
- break;
- case OB_FLUIDSIM_PARTICLE:
- /* "Particle" type objects not being used by Mantaflow fluid simulations.
- * Skip this object, secondary particles can only be enabled through the domain object. */
- break;
- case OB_FLUIDSIM_CONTROL:
- /* "Control" type objects not being used by Mantaflow fluid simulations.
- * Use guiding type instead which is similar. */
- modifier_ensure_type(fluid_modifier_data, MOD_FLUID_TYPE_EFFEC);
- BKE_fluid_effector_type_set(
- object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_GUIDE);
- break;
- }
- }
- else if (old_modifier_data->type == eModifierType_Smoke) {
- SmokeModifierData *old_smoke_modifier_data = (SmokeModifierData *)old_modifier_data;
- modifier_ensure_type(fluid_modifier_data, old_smoke_modifier_data->type);
- if (fluid_modifier_data->type == MOD_FLUID_TYPE_DOMAIN) {
- BKE_fluid_domain_type_set(object, fluid_modifier_data->domain, FLUID_DOMAIN_TYPE_GAS);
- }
- else if (fluid_modifier_data->type == MOD_FLUID_TYPE_FLOW) {
- BKE_fluid_flow_type_set(object, fluid_modifier_data->flow, FLUID_FLOW_TYPE_SMOKE);
- }
- else if (fluid_modifier_data->type == MOD_FLUID_TYPE_EFFEC) {
- BKE_fluid_effector_type_set(
- object, fluid_modifier_data->effector, FLUID_EFFECTOR_TYPE_COLLISION);
- }
- }
-
- /* Replace modifier data in the stack. */
- new_modifier_data->next = old_modifier_data->next;
- new_modifier_data->prev = old_modifier_data->prev;
- if (new_modifier_data->prev != NULL) {
- new_modifier_data->prev->next = new_modifier_data;
- }
- if (new_modifier_data->next != NULL) {
- new_modifier_data->next->prev = new_modifier_data;
- }
- if (modifiers->first == old_modifier_data) {
- modifiers->first = new_modifier_data;
- }
- if (modifiers->last == old_modifier_data) {
- modifiers->last = new_modifier_data;
- }
-
- /* Free old modifier data. */
- MEM_freeN(old_modifier_data);
-
- return new_modifier_data;
-}
-
-static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object *ob)
-{
- BLO_read_list(reader, lb);
-
- LISTBASE_FOREACH (ModifierData *, md, lb) {
- BKE_modifier_session_uuid_generate(md);
-
- md->error = NULL;
- md->runtime = NULL;
-
- /* Modifier data has been allocated as a part of data migration process and
- * no reading of nested fields from file is needed. */
- bool is_allocated = false;
-
- if (md->type == eModifierType_Fluidsim) {
- blo_reportf_wrap(
- reader->fd->reports,
- RPT_WARNING,
- TIP_("Possible data loss when saving this file! %s modifier is deprecated (Object: %s)"),
- md->name,
- ob->id.name + 2);
- md = modifier_replace_with_fluid(reader->fd, ob, lb, md);
- is_allocated = true;
- }
- else if (md->type == eModifierType_Smoke) {
- blo_reportf_wrap(
- reader->fd->reports,
- RPT_WARNING,
- TIP_("Possible data loss when saving this file! %s modifier is deprecated (Object: %s)"),
- md->name,
- ob->id.name + 2);
- md = modifier_replace_with_fluid(reader->fd, ob, lb, md);
- is_allocated = true;
- }
-
- const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
-
- /* if modifiers disappear, or for upward compatibility */
- if (mti == NULL) {
- md->type = eModifierType_None;
- }
-
- if (is_allocated) {
- /* All the fields has been properly allocated. */
- }
- else if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
-
- clmd->clothObject = NULL;
- clmd->hairdata = NULL;
-
- BLO_read_data_address(reader, &clmd->sim_parms);
- BLO_read_data_address(reader, &clmd->coll_parms);
-
- direct_link_pointcache_list(reader, &clmd->ptcaches, &clmd->point_cache, 0);
-
- if (clmd->sim_parms) {
- if (clmd->sim_parms->presets > 10) {
- clmd->sim_parms->presets = 0;
- }
-
- clmd->sim_parms->reset = 0;
-
- BLO_read_data_address(reader, &clmd->sim_parms->effector_weights);
-
- if (!clmd->sim_parms->effector_weights) {
- clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL);
- }
- }
-
- clmd->solver_result = NULL;
- }
- else if (md->type == eModifierType_Fluid) {
-
- FluidModifierData *fmd = (FluidModifierData *)md;
-
- if (fmd->type == MOD_FLUID_TYPE_DOMAIN) {
- fmd->flow = NULL;
- fmd->effector = NULL;
- BLO_read_data_address(reader, &fmd->domain);
- fmd->domain->fmd = fmd;
-
- fmd->domain->fluid = NULL;
- fmd->domain->fluid_mutex = BLI_rw_mutex_alloc();
- fmd->domain->tex_density = NULL;
- fmd->domain->tex_color = NULL;
- fmd->domain->tex_shadow = NULL;
- fmd->domain->tex_flame = NULL;
- fmd->domain->tex_flame_coba = NULL;
- fmd->domain->tex_coba = NULL;
- fmd->domain->tex_field = NULL;
- fmd->domain->tex_velocity_x = NULL;
- fmd->domain->tex_velocity_y = NULL;
- fmd->domain->tex_velocity_z = NULL;
- fmd->domain->tex_wt = NULL;
- fmd->domain->mesh_velocities = NULL;
- BLO_read_data_address(reader, &fmd->domain->coba);
-
- BLO_read_data_address(reader, &fmd->domain->effector_weights);
- if (!fmd->domain->effector_weights) {
- fmd->domain->effector_weights = BKE_effector_add_weights(NULL);
- }
-
- direct_link_pointcache_list(
- reader, &(fmd->domain->ptcaches[0]), &(fmd->domain->point_cache[0]), 1);
-
- /* Manta sim uses only one cache from now on, so store pointer convert */
- if (fmd->domain->ptcaches[1].first || fmd->domain->point_cache[1]) {
- if (fmd->domain->point_cache[1]) {
- PointCache *cache = BLO_read_get_new_data_address(reader, fmd->domain->point_cache[1]);
- if (cache->flag & PTCACHE_FAKE_SMOKE) {
- /* Manta-sim/smoke was already saved in "new format" and this cache is a fake one. */
- }
- else {
- printf(
- "High resolution manta cache not available due to pointcache update. Please "
- "reset the simulation.\n");
- }
- BKE_ptcache_free(cache);
- }
- BLI_listbase_clear(&fmd->domain->ptcaches[1]);
- fmd->domain->point_cache[1] = NULL;
- }
- }
- else if (fmd->type == MOD_FLUID_TYPE_FLOW) {
- fmd->domain = NULL;
- fmd->effector = NULL;
- BLO_read_data_address(reader, &fmd->flow);
- fmd->flow->fmd = fmd;
- fmd->flow->mesh = NULL;
- fmd->flow->verts_old = NULL;
- fmd->flow->numverts = 0;
- BLO_read_data_address(reader, &fmd->flow->psys);
- }
- else if (fmd->type == MOD_FLUID_TYPE_EFFEC) {
- fmd->flow = NULL;
- fmd->domain = NULL;
- BLO_read_data_address(reader, &fmd->effector);
- if (fmd->effector) {
- fmd->effector->fmd = fmd;
- fmd->effector->verts_old = NULL;
- fmd->effector->numverts = 0;
- fmd->effector->mesh = NULL;
- }
- else {
- fmd->type = 0;
- fmd->flow = NULL;
- fmd->domain = NULL;
- fmd->effector = NULL;
- }
- }
- }
- else if (md->type == eModifierType_DynamicPaint) {
- DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
-
- if (pmd->canvas) {
- BLO_read_data_address(reader, &pmd->canvas);
- pmd->canvas->pmd = pmd;
- pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
-
- if (pmd->canvas->surfaces.first) {
- BLO_read_list(reader, &pmd->canvas->surfaces);
-
- LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
- surface->canvas = pmd->canvas;
- surface->data = NULL;
- direct_link_pointcache_list(reader, &(surface->ptcaches), &(surface->pointcache), 1);
-
- BLO_read_data_address(reader, &surface->effector_weights);
- if (surface->effector_weights == NULL) {
- surface->effector_weights = BKE_effector_add_weights(NULL);
- }
- }
- }
- }
- if (pmd->brush) {
- BLO_read_data_address(reader, &pmd->brush);
- pmd->brush->pmd = pmd;
- BLO_read_data_address(reader, &pmd->brush->psys);
- BLO_read_data_address(reader, &pmd->brush->paint_ramp);
- BLO_read_data_address(reader, &pmd->brush->vel_ramp);
- }
- }
-
- if (mti->blendRead != NULL) {
- mti->blendRead(reader, md);
- }
- }
-}
-
-static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
-{
- BLO_read_list(reader, lb);
-
- LISTBASE_FOREACH (GpencilModifierData *, md, lb) {
- md->error = NULL;
-
- /* if modifiers disappear, or for upward compatibility */
- if (NULL == BKE_gpencil_modifier_get_info(md->type)) {
- md->type = eModifierType_None;
- }
-
- if (md->type == eGpencilModifierType_Lattice) {
- LatticeGpencilModifierData *gpmd = (LatticeGpencilModifierData *)md;
- gpmd->cache_data = NULL;
- }
- else if (md->type == eGpencilModifierType_Hook) {
- HookGpencilModifierData *hmd = (HookGpencilModifierData *)md;
-
- BLO_read_data_address(reader, &hmd->curfalloff);
- if (hmd->curfalloff) {
- BKE_curvemapping_blend_read(reader, hmd->curfalloff);
- }
- }
- else if (md->type == eGpencilModifierType_Noise) {
- NoiseGpencilModifierData *gpmd = (NoiseGpencilModifierData *)md;
-
- BLO_read_data_address(reader, &gpmd->curve_intensity);
- if (gpmd->curve_intensity) {
- BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- /* initialize the curve. Maybe this could be moved to modififer logic */
- BKE_curvemapping_init(gpmd->curve_intensity);
- }
- }
- else if (md->type == eGpencilModifierType_Thick) {
- ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
-
- BLO_read_data_address(reader, &gpmd->curve_thickness);
- if (gpmd->curve_thickness) {
- BKE_curvemapping_blend_read(reader, gpmd->curve_thickness);
- BKE_curvemapping_init(gpmd->curve_thickness);
- }
- }
- else if (md->type == eGpencilModifierType_Tint) {
- TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
- BLO_read_data_address(reader, &gpmd->colorband);
- BLO_read_data_address(reader, &gpmd->curve_intensity);
- if (gpmd->curve_intensity) {
- BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_init(gpmd->curve_intensity);
- }
- }
- else if (md->type == eGpencilModifierType_Smooth) {
- SmoothGpencilModifierData *gpmd = (SmoothGpencilModifierData *)md;
- BLO_read_data_address(reader, &gpmd->curve_intensity);
- if (gpmd->curve_intensity) {
- BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_init(gpmd->curve_intensity);
- }
- }
- else if (md->type == eGpencilModifierType_Color) {
- ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md;
- BLO_read_data_address(reader, &gpmd->curve_intensity);
- if (gpmd->curve_intensity) {
- BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_init(gpmd->curve_intensity);
- }
- }
- else if (md->type == eGpencilModifierType_Opacity) {
- OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
- BLO_read_data_address(reader, &gpmd->curve_intensity);
- if (gpmd->curve_intensity) {
- BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_init(gpmd->curve_intensity);
- }
- }
- }
-}
-
-static void direct_link_shaderfxs(BlendDataReader *reader, ListBase *lb)
-{
- BLO_read_list(reader, lb);
-
- LISTBASE_FOREACH (ShaderFxData *, fx, lb) {
- fx->error = NULL;
-
- /* if shader disappear, or for upward compatibility */
- if (NULL == BKE_shaderfx_get_info(fx->type)) {
- fx->type = eShaderFxType_None;
- }
- }
-}
-
-static void direct_link_object(BlendDataReader *reader, Object *ob)
-{
- PartEff *paf;
-
- /* XXX This should not be needed - but seems like it can happen in some cases,
- * so for now play safe. */
- ob->proxy_from = NULL;
-
- const bool is_undo = BLO_read_data_is_undo(reader);
- 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);
- }
-
- BLO_read_data_address(reader, &ob->adt);
- BKE_animdata_blend_read_data(reader, ob->adt);
-
- BLO_read_data_address(reader, &ob->pose);
- direct_link_pose(reader, ob->pose);
-
- BLO_read_data_address(reader, &ob->mpath);
- if (ob->mpath) {
- direct_link_motionpath(reader, ob->mpath);
- }
-
- BLO_read_list(reader, &ob->defbase);
- BLO_read_list(reader, &ob->fmaps);
- /* XXX deprecated - old animation system <<< */
- direct_link_nlastrips(reader, &ob->nlastrips);
- BLO_read_list(reader, &ob->constraintChannels);
- /* >>> XXX deprecated - old animation system */
-
- BLO_read_pointer_array(reader, (void **)&ob->mat);
- BLO_read_data_address(reader, &ob->matbits);
-
- /* do it here, below old data gets converted */
- direct_link_modifiers(reader, &ob->modifiers, ob);
- direct_link_gpencil_modifiers(reader, &ob->greasepencil_modifiers);
- direct_link_shaderfxs(reader, &ob->shader_fx);
-
- BLO_read_list(reader, &ob->effect);
- paf = ob->effect.first;
- while (paf) {
- if (paf->type == EFF_PARTICLE) {
- paf->keys = NULL;
- }
- if (paf->type == EFF_WAVE) {
- WaveEff *wav = (WaveEff *)paf;
- PartEff *next = paf->next;
- WaveModifierData *wmd = (WaveModifierData *)BKE_modifier_new(eModifierType_Wave);
-
- wmd->damp = wav->damp;
- wmd->flag = wav->flag;
- wmd->height = wav->height;
- wmd->lifetime = wav->lifetime;
- wmd->narrow = wav->narrow;
- wmd->speed = wav->speed;
- wmd->startx = wav->startx;
- wmd->starty = wav->startx;
- wmd->timeoffs = wav->timeoffs;
- wmd->width = wav->width;
-
- BLI_addtail(&ob->modifiers, wmd);
-
- BLI_remlink(&ob->effect, paf);
- MEM_freeN(paf);
-
- paf = next;
- continue;
- }
- if (paf->type == EFF_BUILD) {
- BuildEff *baf = (BuildEff *)paf;
- PartEff *next = paf->next;
- BuildModifierData *bmd = (BuildModifierData *)BKE_modifier_new(eModifierType_Build);
-
- bmd->start = baf->sfra;
- bmd->length = baf->len;
- bmd->randomize = 0;
- bmd->seed = 1;
-
- BLI_addtail(&ob->modifiers, bmd);
-
- BLI_remlink(&ob->effect, paf);
- MEM_freeN(paf);
-
- paf = next;
- continue;
- }
- paf = paf->next;
- }
-
- BLO_read_data_address(reader, &ob->pd);
- direct_link_partdeflect(ob->pd);
- BLO_read_data_address(reader, &ob->soft);
- if (ob->soft) {
- SoftBody *sb = ob->soft;
-
- sb->bpoint = NULL; /* init pointers so it gets rebuilt nicely */
- sb->bspring = NULL;
- sb->scratch = NULL;
- /* although not used anymore */
- /* still have to be loaded to be compatible with old files */
- BLO_read_pointer_array(reader, (void **)&sb->keys);
- if (sb->keys) {
- for (int a = 0; a < sb->totkey; a++) {
- BLO_read_data_address(reader, &sb->keys[a]);
- }
- }
-
- BLO_read_data_address(reader, &sb->effector_weights);
- if (!sb->effector_weights) {
- sb->effector_weights = BKE_effector_add_weights(NULL);
- }
-
- BLO_read_data_address(reader, &sb->shared);
- if (sb->shared == NULL) {
- /* Link deprecated caches if they exist, so we can use them for versioning.
- * We should only do this when sb->shared == NULL, because those pointers
- * are always set (for compatibility with older Blenders). We mustn't link
- * the same pointcache twice. */
- direct_link_pointcache_list(reader, &sb->ptcaches, &sb->pointcache, false);
- }
- else {
- /* link caches */
- direct_link_pointcache_list(reader, &sb->shared->ptcaches, &sb->shared->pointcache, false);
- }
- }
- BLO_read_data_address(reader, &ob->fluidsimSettings); /* NT */
-
- BLO_read_data_address(reader, &ob->rigidbody_object);
- if (ob->rigidbody_object) {
- RigidBodyOb *rbo = ob->rigidbody_object;
- /* Allocate runtime-only struct */
- rbo->shared = MEM_callocN(sizeof(*rbo->shared), "RigidBodyObShared");
- }
- BLO_read_data_address(reader, &ob->rigidbody_constraint);
- if (ob->rigidbody_constraint) {
- ob->rigidbody_constraint->physics_constraint = NULL;
- }
-
- BLO_read_list(reader, &ob->particlesystem);
- direct_link_particlesystems(reader, &ob->particlesystem);
-
- direct_link_constraints(reader, &ob->constraints);
-
- BLO_read_list(reader, &ob->hooks);
- while (ob->hooks.first) {
- ObHook *hook = ob->hooks.first;
- HookModifierData *hmd = (HookModifierData *)BKE_modifier_new(eModifierType_Hook);
-
- BLO_read_int32_array(reader, hook->totindex, &hook->indexar);
-
- /* Do conversion here because if we have loaded
- * a hook we need to make sure it gets converted
- * and freed, regardless of version.
- */
- copy_v3_v3(hmd->cent, hook->cent);
- hmd->falloff = hook->falloff;
- hmd->force = hook->force;
- hmd->indexar = hook->indexar;
- hmd->object = hook->parent;
- memcpy(hmd->parentinv, hook->parentinv, sizeof(hmd->parentinv));
- hmd->totindex = hook->totindex;
-
- BLI_addhead(&ob->modifiers, hmd);
- BLI_remlink(&ob->hooks, hook);
-
- BKE_modifier_unique_name(&ob->modifiers, (ModifierData *)hmd);
-
- MEM_freeN(hook);
- }
-
- BLO_read_data_address(reader, &ob->iuser);
- if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE && !ob->iuser) {
- BKE_object_empty_draw_type_set(ob, ob->empty_drawtype);
- }
-
- BKE_object_runtime_reset(ob);
- BLO_read_list(reader, &ob->pc_ids);
-
- /* in case this value changes in future, clamp else we get undefined behavior */
- CLAMP(ob->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
-
- if (ob->sculpt) {
- ob->sculpt = NULL;
- /* Only create data on undo, otherwise rely on editor mode switching. */
- if (BLO_read_data_is_undo(reader) && (ob->mode & OB_MODE_ALL_SCULPT)) {
- BKE_object_sculpt_data_create(ob);
- }
- }
-
- BLO_read_data_address(reader, &ob->preview);
- BKE_previewimg_blend_read(reader, ob->preview);
-}
-
-static void direct_link_view_settings(BlendDataReader *reader,
- ColorManagedViewSettings *view_settings)
-{
- BLO_read_data_address(reader, &view_settings->curve_mapping);
-
- if (view_settings->curve_mapping) {
- BKE_curvemapping_blend_read(reader, view_settings->curve_mapping);
- }
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Read View Layer (Collection Data)
- * \{ */
-
-static void direct_link_layer_collections(BlendDataReader *reader, ListBase *lb, bool master)
-{
- BLO_read_list(reader, lb);
- LISTBASE_FOREACH (LayerCollection *, lc, lb) {
-#ifdef USE_COLLECTION_COMPAT_28
- BLO_read_data_address(reader, &lc->scene_collection);
-#endif
-
- /* Master collection is not a real data-lock. */
- if (master) {
- BLO_read_data_address(reader, &lc->collection);
- }
-
- direct_link_layer_collections(reader, &lc->layer_collections, false);
- }
-}
-
-static void direct_link_view_layer(BlendDataReader *reader, ViewLayer *view_layer)
-{
- view_layer->stats = NULL;
- BLO_read_list(reader, &view_layer->object_bases);
- BLO_read_data_address(reader, &view_layer->basact);
-
- direct_link_layer_collections(reader, &view_layer->layer_collections, true);
- BLO_read_data_address(reader, &view_layer->active_collection);
-
- BLO_read_data_address(reader, &view_layer->id_properties);
- IDP_BlendDataRead(reader, &view_layer->id_properties);
-
- BLO_read_list(reader, &(view_layer->freestyle_config.modules));
- BLO_read_list(reader, &(view_layer->freestyle_config.linesets));
-
- BLI_listbase_clear(&view_layer->drawdata);
- view_layer->object_bases_array = NULL;
- view_layer->object_bases_hash = NULL;
-}
-
-static void lib_link_layer_collection(BlendLibReader *reader,
- Library *lib,
- LayerCollection *layer_collection,
- bool master)
-{
- /* Master collection is not a real data-lock. */
- if (!master) {
- BLO_read_id_address(reader, lib, &layer_collection->collection);
- }
-
- LISTBASE_FOREACH (
- LayerCollection *, layer_collection_nested, &layer_collection->layer_collections) {
- lib_link_layer_collection(reader, lib, layer_collection_nested, false);
- }
-}
-
-static void lib_link_view_layer(BlendLibReader *reader, Library *lib, ViewLayer *view_layer)
-{
- LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
- BLO_read_id_address(reader, lib, &fmc->script);
- }
-
- LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
- BLO_read_id_address(reader, lib, &fls->linestyle);
- BLO_read_id_address(reader, lib, &fls->group);
- }
-
- for (Base *base = view_layer->object_bases.first, *base_next = NULL; base; base = base_next) {
- base_next = base->next;
-
- /* we only bump the use count for the collection objects */
- BLO_read_id_address(reader, lib, &base->object);
-
- if (base->object == NULL) {
- /* Free in case linked object got lost. */
- BLI_freelinkN(&view_layer->object_bases, base);
- if (view_layer->basact == base) {
- view_layer->basact = NULL;
- }
- }
- }
-
- LISTBASE_FOREACH (LayerCollection *, layer_collection, &view_layer->layer_collections) {
- lib_link_layer_collection(reader, lib, layer_collection, true);
- }
-
- BLO_read_id_address(reader, lib, &view_layer->mat_override);
-
- IDP_BlendReadLib(reader, view_layer->id_properties);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Read ID: Collection
- * \{ */
-
-#ifdef USE_COLLECTION_COMPAT_28
-static void direct_link_scene_collection(BlendDataReader *reader, SceneCollection *sc)
-{
- BLO_read_list(reader, &sc->objects);
- BLO_read_list(reader, &sc->scene_collections);
-
- LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) {
- direct_link_scene_collection(reader, nsc);
- }
-}
-
-static void lib_link_scene_collection(BlendLibReader *reader, Library *lib, SceneCollection *sc)
-{
- LISTBASE_FOREACH (LinkData *, link, &sc->objects) {
- BLO_read_id_address(reader, lib, &link->data);
- BLI_assert(link->data);
- }
-
- LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) {
- lib_link_scene_collection(reader, lib, nsc);
- }
-}
-#endif
-
-static void direct_link_collection(BlendDataReader *reader, Collection *collection)
-{
- BLO_read_list(reader, &collection->gobject);
- BLO_read_list(reader, &collection->children);
-
- BLO_read_data_address(reader, &collection->preview);
- BKE_previewimg_blend_read(reader, collection->preview);
-
- collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
- collection->tag = 0;
- BLI_listbase_clear(&collection->object_cache);
- BLI_listbase_clear(&collection->parents);
-
-#ifdef USE_COLLECTION_COMPAT_28
- /* This runs before the very first doversion. */
- BLO_read_data_address(reader, &collection->collection);
- if (collection->collection != NULL) {
- direct_link_scene_collection(reader, collection->collection);
- }
-
- BLO_read_data_address(reader, &collection->view_layer);
- if (collection->view_layer != NULL) {
- direct_link_view_layer(reader, collection->view_layer);
- }
-#endif
-}
-
-static void lib_link_collection_data(BlendLibReader *reader, Library *lib, Collection *collection)
-{
- LISTBASE_FOREACH_MUTABLE (CollectionObject *, cob, &collection->gobject) {
- BLO_read_id_address(reader, lib, &cob->ob);
-
- if (cob->ob == NULL) {
- BLI_freelinkN(&collection->gobject, cob);
- }
- }
-
- LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
- BLO_read_id_address(reader, lib, &child->collection);
- }
-}
-
-static void lib_link_collection(BlendLibReader *reader, Collection *collection)
-{
-#ifdef USE_COLLECTION_COMPAT_28
- if (collection->collection) {
- lib_link_scene_collection(reader, collection->id.lib, collection->collection);
- }
-
- if (collection->view_layer) {
- lib_link_view_layer(reader, collection->id.lib, collection->view_layer);
- }
-#endif
-
- lib_link_collection_data(reader, collection->id.lib, collection);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Read ID: Scene
* \{ */
-/* patch for missing scene IDs, can't be in do-versions */
-static void composite_patch(bNodeTree *ntree, Scene *scene)
-{
-
- LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
- if (node->id == NULL && node->type == CMP_NODE_R_LAYERS) {
- node->id = &scene->id;
- }
- }
-}
-
-static void link_paint(BlendLibReader *reader, Scene *sce, Paint *p)
-{
- if (p) {
- BLO_read_id_address(reader, sce->id.lib, &p->brush);
- for (int i = 0; i < p->tool_slots_len; i++) {
- if (p->tool_slots[i].brush != NULL) {
- BLO_read_id_address(reader, sce->id.lib, &p->tool_slots[i].brush);
- }
- }
- BLO_read_id_address(reader, sce->id.lib, &p->palette);
- p->paint_cursor = NULL;
-
- BKE_paint_runtime_init(sce->toolsettings, p);
- }
-}
-
-static void lib_link_sequence_modifiers(BlendLibReader *reader, Scene *scene, ListBase *lb)
-{
- LISTBASE_FOREACH (SequenceModifierData *, smd, lb) {
- if (smd->mask_id) {
- BLO_read_id_address(reader, scene->id.lib, &smd->mask_id);
- }
- }
-}
-
-static void direct_link_lightcache_texture(BlendDataReader *reader, LightCacheTexture *lctex)
-{
- lctex->tex = NULL;
-
- if (lctex->data) {
- BLO_read_data_address(reader, &lctex->data);
- if (lctex->data && BLO_read_requires_endian_switch(reader)) {
- int data_size = lctex->components * lctex->tex_size[0] * lctex->tex_size[1] *
- lctex->tex_size[2];
-
- if (lctex->data_type == LIGHTCACHETEX_FLOAT) {
- BLI_endian_switch_float_array((float *)lctex->data, data_size * sizeof(float));
- }
- else if (lctex->data_type == LIGHTCACHETEX_UINT) {
- BLI_endian_switch_uint32_array((uint *)lctex->data, data_size * sizeof(uint));
- }
- }
- }
-
- if (lctex->data == NULL) {
- zero_v3_int(lctex->tex_size);
- }
-}
-
-static void direct_link_lightcache(BlendDataReader *reader, LightCache *cache)
-{
- cache->flag &= ~LIGHTCACHE_NOT_USABLE;
- direct_link_lightcache_texture(reader, &cache->cube_tx);
- direct_link_lightcache_texture(reader, &cache->grid_tx);
-
- if (cache->cube_mips) {
- BLO_read_data_address(reader, &cache->cube_mips);
- for (int i = 0; i < cache->mips_len; i++) {
- direct_link_lightcache_texture(reader, &cache->cube_mips[i]);
- }
- }
-
- BLO_read_data_address(reader, &cache->cube_data);
- BLO_read_data_address(reader, &cache->grid_data);
-}
-
-static void direct_link_view3dshading(BlendDataReader *reader, View3DShading *shading)
-{
- if (shading->prop) {
- BLO_read_data_address(reader, &shading->prop);
- IDP_BlendDataRead(reader, &shading->prop);
- }
-}
-
-/* check for cyclic set-scene,
- * libs can cause this case which is normally prevented, see (T#####) */
-#define USE_SETSCENE_CHECK
-
#ifdef USE_SETSCENE_CHECK
/**
* A version of #BKE_scene_validate_setscene with special checks for linked libs.
@@ -4373,182 +2463,6 @@ static bool scene_validate_setscene__liblink(Scene *sce, const int totscene)
}
#endif
-static void lib_link_scene(BlendLibReader *reader, Scene *sce)
-{
- BKE_keyingsets_blend_read_lib(reader, &sce->id, &sce->keyingsets);
-
- BLO_read_id_address(reader, sce->id.lib, &sce->camera);
- BLO_read_id_address(reader, sce->id.lib, &sce->world);
- BLO_read_id_address(reader, sce->id.lib, &sce->set);
- BLO_read_id_address(reader, sce->id.lib, &sce->gpd);
-
- link_paint(reader, sce, &sce->toolsettings->imapaint.paint);
- if (sce->toolsettings->sculpt) {
- link_paint(reader, sce, &sce->toolsettings->sculpt->paint);
- }
- if (sce->toolsettings->vpaint) {
- link_paint(reader, sce, &sce->toolsettings->vpaint->paint);
- }
- if (sce->toolsettings->wpaint) {
- link_paint(reader, sce, &sce->toolsettings->wpaint->paint);
- }
- if (sce->toolsettings->uvsculpt) {
- link_paint(reader, sce, &sce->toolsettings->uvsculpt->paint);
- }
- if (sce->toolsettings->gp_paint) {
- link_paint(reader, sce, &sce->toolsettings->gp_paint->paint);
- }
- if (sce->toolsettings->gp_vertexpaint) {
- link_paint(reader, sce, &sce->toolsettings->gp_vertexpaint->paint);
- }
- if (sce->toolsettings->gp_sculptpaint) {
- link_paint(reader, sce, &sce->toolsettings->gp_sculptpaint->paint);
- }
- if (sce->toolsettings->gp_weightpaint) {
- link_paint(reader, sce, &sce->toolsettings->gp_weightpaint->paint);
- }
-
- if (sce->toolsettings->sculpt) {
- BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->sculpt->gravity_object);
- }
-
- if (sce->toolsettings->imapaint.stencil) {
- BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.stencil);
- }
-
- if (sce->toolsettings->imapaint.clone) {
- BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.clone);
- }
-
- if (sce->toolsettings->imapaint.canvas) {
- BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.canvas);
- }
-
- BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->particle.shape_object);
-
- BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->gp_sculpt.guide.reference_object);
-
- LISTBASE_FOREACH_MUTABLE (Base *, base_legacy, &sce->base) {
- BLO_read_id_address(reader, sce->id.lib, &base_legacy->object);
-
- if (base_legacy->object == NULL) {
- blo_reportf_wrap(reader->fd->reports,
- RPT_WARNING,
- TIP_("LIB: object lost from scene: '%s'"),
- sce->id.name + 2);
- BLI_remlink(&sce->base, base_legacy);
- if (base_legacy == sce->basact) {
- sce->basact = NULL;
- }
- MEM_freeN(base_legacy);
- }
- }
-
- Sequence *seq;
- SEQ_ALL_BEGIN (sce->ed, seq) {
- IDP_BlendReadLib(reader, seq->prop);
-
- if (seq->ipo) {
- BLO_read_id_address(
- reader, sce->id.lib, &seq->ipo); /* XXX deprecated - old animation system */
- }
- seq->scene_sound = NULL;
- if (seq->scene) {
- BLO_read_id_address(reader, sce->id.lib, &seq->scene);
- seq->scene_sound = NULL;
- }
- if (seq->clip) {
- BLO_read_id_address(reader, sce->id.lib, &seq->clip);
- }
- if (seq->mask) {
- BLO_read_id_address(reader, sce->id.lib, &seq->mask);
- }
- if (seq->scene_camera) {
- BLO_read_id_address(reader, sce->id.lib, &seq->scene_camera);
- }
- if (seq->sound) {
- seq->scene_sound = NULL;
- if (seq->type == SEQ_TYPE_SOUND_HD) {
- seq->type = SEQ_TYPE_SOUND_RAM;
- }
- else {
- BLO_read_id_address(reader, sce->id.lib, &seq->sound);
- }
- if (seq->sound) {
- id_us_plus_no_lib((ID *)seq->sound);
- seq->scene_sound = NULL;
- }
- }
- if (seq->type == SEQ_TYPE_TEXT) {
- TextVars *t = seq->effectdata;
- BLO_read_id_address(reader, sce->id.lib, &t->text_font);
- }
- BLI_listbase_clear(&seq->anims);
-
- lib_link_sequence_modifiers(reader, sce, &seq->modifiers);
- }
- SEQ_ALL_END;
-
- LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
- IDP_BlendReadLib(reader, marker->prop);
-
- if (marker->camera) {
- BLO_read_id_address(reader, sce->id.lib, &marker->camera);
- }
- }
-
- /* rigidbody world relies on its linked collections */
- if (sce->rigidbody_world) {
- RigidBodyWorld *rbw = sce->rigidbody_world;
- if (rbw->group) {
- BLO_read_id_address(reader, sce->id.lib, &rbw->group);
- }
- if (rbw->constraints) {
- BLO_read_id_address(reader, sce->id.lib, &rbw->constraints);
- }
- if (rbw->effector_weights) {
- BLO_read_id_address(reader, sce->id.lib, &rbw->effector_weights->group);
- }
- }
-
- if (sce->nodetree) {
- composite_patch(sce->nodetree, sce);
- }
-
- LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
- BLO_read_id_address(reader, sce->id.lib, &srl->mat_override);
- LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &srl->freestyleConfig.modules) {
- BLO_read_id_address(reader, sce->id.lib, &fmc->script);
- }
- LISTBASE_FOREACH (FreestyleLineSet *, fls, &srl->freestyleConfig.linesets) {
- BLO_read_id_address(reader, sce->id.lib, &fls->linestyle);
- BLO_read_id_address(reader, sce->id.lib, &fls->group);
- }
- }
- /* Motion Tracking */
- BLO_read_id_address(reader, sce->id.lib, &sce->clip);
-
-#ifdef USE_COLLECTION_COMPAT_28
- if (sce->collection) {
- lib_link_scene_collection(reader, sce->id.lib, sce->collection);
- }
-#endif
-
- LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
- lib_link_view_layer(reader, sce->id.lib, view_layer);
- }
-
- if (sce->r.bake.cage_object) {
- BLO_read_id_address(reader, sce->id.lib, &sce->r.bake.cage_object);
- }
-
-#ifdef USE_SETSCENE_CHECK
- if (sce->set != NULL) {
- sce->flag |= SCE_READFILE_LIBLINK_NEED_SETSCENE_CHECK;
- }
-#endif
-}
-
static void lib_link_scenes_check_set(Main *bmain)
{
#ifdef USE_SETSCENE_CHECK
@@ -4568,1058 +2482,12 @@ static void lib_link_scenes_check_set(Main *bmain)
#undef USE_SETSCENE_CHECK
-static void link_recurs_seq(BlendDataReader *reader, ListBase *lb)
-{
- BLO_read_list(reader, lb);
-
- LISTBASE_FOREACH (Sequence *, seq, lb) {
- if (seq->seqbase.first) {
- link_recurs_seq(reader, &seq->seqbase);
- }
- }
-}
-
-static void direct_link_paint(BlendDataReader *reader, const Scene *scene, Paint *p)
-{
- if (p->num_input_samples < 1) {
- p->num_input_samples = 1;
- }
-
- BLO_read_data_address(reader, &p->cavity_curve);
- if (p->cavity_curve) {
- BKE_curvemapping_blend_read(reader, p->cavity_curve);
- }
- else {
- BKE_paint_cavity_curve_preset(p, CURVE_PRESET_LINE);
- }
-
- BLO_read_data_address(reader, &p->tool_slots);
-
- /* Workaround for invalid data written in older versions. */
- const size_t expected_size = sizeof(PaintToolSlot) * p->tool_slots_len;
- if (p->tool_slots && MEM_allocN_len(p->tool_slots) < expected_size) {
- MEM_freeN(p->tool_slots);
- p->tool_slots = MEM_callocN(expected_size, "PaintToolSlot");
- }
-
- BKE_paint_runtime_init(scene->toolsettings, p);
-}
-
-static void direct_link_paint_helper(BlendDataReader *reader, const Scene *scene, Paint **paint)
-{
- /* TODO. is this needed */
- BLO_read_data_address(reader, paint);
-
- if (*paint) {
- direct_link_paint(reader, scene, *paint);
- }
-}
-
-static void direct_link_sequence_modifiers(BlendDataReader *reader, ListBase *lb)
-{
- BLO_read_list(reader, lb);
-
- LISTBASE_FOREACH (SequenceModifierData *, smd, lb) {
- if (smd->mask_sequence) {
- BLO_read_data_address(reader, &smd->mask_sequence);
- }
-
- if (smd->type == seqModifierType_Curves) {
- CurvesModifierData *cmd = (CurvesModifierData *)smd;
-
- BKE_curvemapping_blend_read(reader, &cmd->curve_mapping);
- }
- else if (smd->type == seqModifierType_HueCorrect) {
- HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
-
- BKE_curvemapping_blend_read(reader, &hcmd->curve_mapping);
- }
- }
-}
-
-static void direct_link_scene(BlendDataReader *reader, Scene *sce)
-{
- sce->depsgraph_hash = NULL;
- sce->fps_info = NULL;
-
- memset(&sce->customdata_mask, 0, sizeof(sce->customdata_mask));
- memset(&sce->customdata_mask_modal, 0, sizeof(sce->customdata_mask_modal));
-
- BKE_sound_reset_scene_runtime(sce);
-
- /* set users to one by default, not in lib-link, this will increase it for compo nodes */
- id_us_ensure_real(&sce->id);
-
- BLO_read_list(reader, &(sce->base));
-
- BLO_read_data_address(reader, &sce->adt);
- BKE_animdata_blend_read_data(reader, sce->adt);
-
- BLO_read_list(reader, &sce->keyingsets);
- BKE_keyingsets_blend_read_data(reader, &sce->keyingsets);
-
- BLO_read_data_address(reader, &sce->basact);
-
- BLO_read_data_address(reader, &sce->toolsettings);
- if (sce->toolsettings) {
-
- /* Reset last_location and last_hit, so they are not remembered across sessions. In some files
- * these are also NaN, which could lead to crashes in painting. */
- struct UnifiedPaintSettings *ups = &sce->toolsettings->unified_paint_settings;
- zero_v3(ups->last_location);
- ups->last_hit = 0;
-
- direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->sculpt);
- direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->vpaint);
- direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->wpaint);
- direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->uvsculpt);
- direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_paint);
- direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_vertexpaint);
- direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_sculptpaint);
- direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_weightpaint);
-
- direct_link_paint(reader, sce, &sce->toolsettings->imapaint.paint);
-
- sce->toolsettings->particle.paintcursor = NULL;
- sce->toolsettings->particle.scene = NULL;
- sce->toolsettings->particle.object = NULL;
- sce->toolsettings->gp_sculpt.paintcursor = NULL;
-
- /* relink grease pencil interpolation curves */
- BLO_read_data_address(reader, &sce->toolsettings->gp_interpolate.custom_ipo);
- if (sce->toolsettings->gp_interpolate.custom_ipo) {
- BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_interpolate.custom_ipo);
- }
- /* relink grease pencil multiframe falloff curve */
- BLO_read_data_address(reader, &sce->toolsettings->gp_sculpt.cur_falloff);
- if (sce->toolsettings->gp_sculpt.cur_falloff) {
- BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_sculpt.cur_falloff);
- }
- /* relink grease pencil primitive curve */
- BLO_read_data_address(reader, &sce->toolsettings->gp_sculpt.cur_primitive);
- if (sce->toolsettings->gp_sculpt.cur_primitive) {
- BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_sculpt.cur_primitive);
- }
-
- /* Relink toolsettings curve profile */
- BLO_read_data_address(reader, &sce->toolsettings->custom_bevel_profile_preset);
- if (sce->toolsettings->custom_bevel_profile_preset) {
- BKE_curveprofile_blend_read(reader, sce->toolsettings->custom_bevel_profile_preset);
- }
- }
-
- if (sce->ed) {
- ListBase *old_seqbasep = &sce->ed->seqbase;
-
- BLO_read_data_address(reader, &sce->ed);
- Editing *ed = sce->ed;
-
- BLO_read_data_address(reader, &ed->act_seq);
- ed->cache = NULL;
- ed->prefetch_job = NULL;
-
- /* recursive link sequences, lb will be correctly initialized */
- link_recurs_seq(reader, &ed->seqbase);
-
- Sequence *seq;
- SEQ_ALL_BEGIN (ed, seq) {
- /* Do as early as possible, so that other parts of reading can rely on valid session UUID. */
- BKE_sequence_session_uuid_generate(seq);
-
- BLO_read_data_address(reader, &seq->seq1);
- BLO_read_data_address(reader, &seq->seq2);
- BLO_read_data_address(reader, &seq->seq3);
-
- /* a patch: after introduction of effects with 3 input strips */
- if (seq->seq3 == NULL) {
- seq->seq3 = seq->seq2;
- }
-
- BLO_read_data_address(reader, &seq->effectdata);
- BLO_read_data_address(reader, &seq->stereo3d_format);
-
- if (seq->type & SEQ_TYPE_EFFECT) {
- seq->flag |= SEQ_EFFECT_NOT_LOADED;
- }
-
- if (seq->type == SEQ_TYPE_SPEED) {
- SpeedControlVars *s = seq->effectdata;
- s->frameMap = NULL;
- }
-
- if (seq->type == SEQ_TYPE_TEXT) {
- TextVars *t = seq->effectdata;
- t->text_blf_id = SEQ_FONT_NOT_LOADED;
- }
-
- BLO_read_data_address(reader, &seq->prop);
- IDP_BlendDataRead(reader, &seq->prop);
-
- BLO_read_data_address(reader, &seq->strip);
- if (seq->strip && seq->strip->done == 0) {
- seq->strip->done = true;
-
- if (ELEM(seq->type,
- SEQ_TYPE_IMAGE,
- SEQ_TYPE_MOVIE,
- SEQ_TYPE_SOUND_RAM,
- SEQ_TYPE_SOUND_HD)) {
- BLO_read_data_address(reader, &seq->strip->stripdata);
- }
- else {
- seq->strip->stripdata = NULL;
- }
- BLO_read_data_address(reader, &seq->strip->crop);
- BLO_read_data_address(reader, &seq->strip->transform);
- BLO_read_data_address(reader, &seq->strip->proxy);
- if (seq->strip->proxy) {
- seq->strip->proxy->anim = NULL;
- }
- else if (seq->flag & SEQ_USE_PROXY) {
- BKE_sequencer_proxy_set(seq, true);
- }
-
- /* need to load color balance to it could be converted to modifier */
- BLO_read_data_address(reader, &seq->strip->color_balance);
- }
-
- direct_link_sequence_modifiers(reader, &seq->modifiers);
- }
- SEQ_ALL_END;
-
- /* link metastack, slight abuse of structs here,
- * have to restore pointer to internal part in struct */
- {
- Sequence temp;
- void *poin;
- intptr_t offset;
-
- offset = ((intptr_t) & (temp.seqbase)) - ((intptr_t)&temp);
-
- /* root pointer */
- if (ed->seqbasep == old_seqbasep) {
- ed->seqbasep = &ed->seqbase;
- }
- else {
- poin = POINTER_OFFSET(ed->seqbasep, -offset);
-
- poin = BLO_read_get_new_data_address(reader, poin);
-
- if (poin) {
- ed->seqbasep = (ListBase *)POINTER_OFFSET(poin, offset);
- }
- else {
- ed->seqbasep = &ed->seqbase;
- }
- }
- /* stack */
- BLO_read_list(reader, &(ed->metastack));
-
- LISTBASE_FOREACH (MetaStack *, ms, &ed->metastack) {
- BLO_read_data_address(reader, &ms->parseq);
-
- if (ms->oldbasep == old_seqbasep) {
- ms->oldbasep = &ed->seqbase;
- }
- else {
- poin = POINTER_OFFSET(ms->oldbasep, -offset);
- poin = BLO_read_get_new_data_address(reader, poin);
- if (poin) {
- ms->oldbasep = (ListBase *)POINTER_OFFSET(poin, offset);
- }
- else {
- ms->oldbasep = &ed->seqbase;
- }
- }
- }
- }
- }
-
-#ifdef DURIAN_CAMERA_SWITCH
- /* Runtime */
- sce->r.mode &= ~R_NO_CAMERA_SWITCH;
-#endif
-
- BLO_read_data_address(reader, &sce->r.avicodecdata);
- if (sce->r.avicodecdata) {
- BLO_read_data_address(reader, &sce->r.avicodecdata->lpFormat);
- BLO_read_data_address(reader, &sce->r.avicodecdata->lpParms);
- }
- if (sce->r.ffcodecdata.properties) {
- BLO_read_data_address(reader, &sce->r.ffcodecdata.properties);
- IDP_BlendDataRead(reader, &sce->r.ffcodecdata.properties);
- }
-
- BLO_read_list(reader, &(sce->markers));
- LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
- BLO_read_data_address(reader, &marker->prop);
- IDP_BlendDataRead(reader, &marker->prop);
- }
-
- BLO_read_list(reader, &(sce->transform_spaces));
- BLO_read_list(reader, &(sce->r.layers));
- BLO_read_list(reader, &(sce->r.views));
-
- LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
- BLO_read_data_address(reader, &srl->prop);
- IDP_BlendDataRead(reader, &srl->prop);
- BLO_read_list(reader, &(srl->freestyleConfig.modules));
- BLO_read_list(reader, &(srl->freestyleConfig.linesets));
- }
-
- direct_link_view_settings(reader, &sce->view_settings);
-
- BLO_read_data_address(reader, &sce->rigidbody_world);
- RigidBodyWorld *rbw = sce->rigidbody_world;
- if (rbw) {
- BLO_read_data_address(reader, &rbw->shared);
-
- if (rbw->shared == NULL) {
- /* Link deprecated caches if they exist, so we can use them for versioning.
- * We should only do this when rbw->shared == NULL, because those pointers
- * are always set (for compatibility with older Blenders). We mustn't link
- * the same pointcache twice. */
- direct_link_pointcache_list(reader, &rbw->ptcaches, &rbw->pointcache, false);
-
- /* make sure simulation starts from the beginning after loading file */
- if (rbw->pointcache) {
- rbw->ltime = (float)rbw->pointcache->startframe;
- }
- }
- else {
- /* must nullify the reference to physics sim object, since it no-longer exist
- * (and will need to be recalculated)
- */
- rbw->shared->physics_world = NULL;
-
- /* link caches */
- direct_link_pointcache_list(reader, &rbw->shared->ptcaches, &rbw->shared->pointcache, false);
-
- /* make sure simulation starts from the beginning after loading file */
- if (rbw->shared->pointcache) {
- rbw->ltime = (float)rbw->shared->pointcache->startframe;
- }
- }
- rbw->objects = NULL;
- rbw->numbodies = 0;
-
- /* set effector weights */
- BLO_read_data_address(reader, &rbw->effector_weights);
- if (!rbw->effector_weights) {
- rbw->effector_weights = BKE_effector_add_weights(NULL);
- }
- }
-
- BLO_read_data_address(reader, &sce->preview);
- BKE_previewimg_blend_read(reader, sce->preview);
-
- BKE_curvemapping_blend_read(reader, &sce->r.mblur_shutter_curve);
-
-#ifdef USE_COLLECTION_COMPAT_28
- /* this runs before the very first doversion */
- if (sce->collection) {
- BLO_read_data_address(reader, &sce->collection);
- direct_link_scene_collection(reader, sce->collection);
- }
-#endif
-
- /* insert into global old-new map for reading without UI (link_global accesses it again) */
- link_glob_list(reader->fd, &sce->view_layers);
- LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
- direct_link_view_layer(reader, view_layer);
- }
-
- if (BLO_read_data_is_undo(reader)) {
- /* If it's undo do nothing here, caches are handled by higher-level generic calling code. */
- }
- else {
- /* else try to read the cache from file. */
- BLO_read_data_address(reader, &sce->eevee.light_cache_data);
- if (sce->eevee.light_cache_data) {
- direct_link_lightcache(reader, sce->eevee.light_cache_data);
- }
- }
- EEVEE_lightcache_info_update(&sce->eevee);
-
- direct_link_view3dshading(reader, &sce->display.shading);
-
- BLO_read_data_address(reader, &sce->layer_properties);
- IDP_BlendDataRead(reader, &sce->layer_properties);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Read Screen Area/Region (Screen Data)
- * \{ */
-
-static void direct_link_panel_list(BlendDataReader *reader, ListBase *lb)
-{
- BLO_read_list(reader, lb);
-
- LISTBASE_FOREACH (Panel *, panel, lb) {
- panel->runtime_flag = 0;
- panel->activedata = NULL;
- panel->type = NULL;
- panel->runtime.custom_data_ptr = NULL;
- direct_link_panel_list(reader, &panel->children);
- }
-}
-
-static void direct_link_region(BlendDataReader *reader, ARegion *region, int spacetype)
-{
- direct_link_panel_list(reader, &region->panels);
-
- BLO_read_list(reader, &region->panels_category_active);
-
- BLO_read_list(reader, &region->ui_lists);
-
- /* The area's search filter is runtime only, so we need to clear the active flag on read. */
- region->flag &= ~RGN_FLAG_SEARCH_FILTER_ACTIVE;
-
- LISTBASE_FOREACH (uiList *, ui_list, &region->ui_lists) {
- ui_list->type = NULL;
- ui_list->dyn_data = NULL;
- BLO_read_data_address(reader, &ui_list->properties);
- IDP_BlendDataRead(reader, &ui_list->properties);
- }
-
- BLO_read_list(reader, &region->ui_previews);
-
- if (spacetype == SPACE_EMPTY) {
- /* unknown space type, don't leak regiondata */
- region->regiondata = NULL;
- }
- else if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
- /* Runtime data, don't use. */
- region->regiondata = NULL;
- }
- else {
- BLO_read_data_address(reader, &region->regiondata);
- if (region->regiondata) {
- if (spacetype == SPACE_VIEW3D) {
- RegionView3D *rv3d = region->regiondata;
-
- BLO_read_data_address(reader, &rv3d->localvd);
- BLO_read_data_address(reader, &rv3d->clipbb);
-
- rv3d->depths = NULL;
- rv3d->render_engine = NULL;
- rv3d->sms = NULL;
- rv3d->smooth_timer = NULL;
-
- rv3d->rflag &= ~(RV3D_NAVIGATING | RV3D_PAINTING);
- rv3d->runtime_viewlock = 0;
- }
- }
- }
-
- region->v2d.sms = NULL;
- region->v2d.alpha_hor = region->v2d.alpha_vert = 255; /* visible by default */
- BLI_listbase_clear(&region->panels_category);
- BLI_listbase_clear(&region->handlers);
- BLI_listbase_clear(&region->uiblocks);
- region->headerstr = NULL;
- region->visible = 0;
- region->type = NULL;
- region->do_draw = 0;
- region->gizmo_map = NULL;
- region->regiontimer = NULL;
- region->draw_buffer = NULL;
- memset(&region->drawrct, 0, sizeof(region->drawrct));
-}
-
-static void direct_link_area(BlendDataReader *reader, ScrArea *area)
-{
- BLO_read_list(reader, &(area->spacedata));
- BLO_read_list(reader, &(area->regionbase));
-
- BLI_listbase_clear(&area->handlers);
- area->type = NULL; /* spacetype callbacks */
-
- /* Should always be unset so that rna_Area_type_get works correctly. */
- area->butspacetype = SPACE_EMPTY;
-
- area->region_active_win = -1;
-
- area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE;
-
- BLO_read_data_address(reader, &area->global);
-
- /* if we do not have the spacetype registered we cannot
- * free it, so don't allocate any new memory for such spacetypes. */
- if (!BKE_spacetype_exists(area->spacetype)) {
- /* Hint for versioning code to replace deprecated space types. */
- area->butspacetype = area->spacetype;
-
- area->spacetype = SPACE_EMPTY;
- }
-
- LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
- direct_link_region(reader, region, area->spacetype);
- }
-
- /* accident can happen when read/save new file with older version */
- /* 2.50: we now always add spacedata for info */
- if (area->spacedata.first == NULL) {
- SpaceInfo *sinfo = MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
- area->spacetype = sinfo->spacetype = SPACE_INFO;
- BLI_addtail(&area->spacedata, sinfo);
- }
- /* add local view3d too */
- else if (area->spacetype == SPACE_VIEW3D) {
- blo_do_versions_view3d_split_250(area->spacedata.first, &area->regionbase);
- }
-
- LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
- BLO_read_list(reader, &(sl->regionbase));
-
- /* if we do not have the spacetype registered we cannot
- * free it, so don't allocate any new memory for such spacetypes. */
- if (!BKE_spacetype_exists(sl->spacetype)) {
- sl->spacetype = SPACE_EMPTY;
- }
-
- LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
- direct_link_region(reader, region, sl->spacetype);
- }
-
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
-
- v3d->flag |= V3D_INVALID_BACKBUF;
-
- if (v3d->gpd) {
- BLO_read_data_address(reader, &v3d->gpd);
- BKE_gpencil_blend_read_data(reader, v3d->gpd);
- }
- BLO_read_data_address(reader, &v3d->localvd);
-
- /* Runtime data */
- v3d->runtime.properties_storage = NULL;
- v3d->runtime.flag = 0;
-
- /* render can be quite heavy, set to solid on load */
- if (v3d->shading.type == OB_RENDER) {
- v3d->shading.type = OB_SOLID;
- }
- v3d->shading.prev_type = OB_SOLID;
-
- direct_link_view3dshading(reader, &v3d->shading);
-
- blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
- }
- else if (sl->spacetype == SPACE_GRAPH) {
- SpaceGraph *sipo = (SpaceGraph *)sl;
-
- BLO_read_data_address(reader, &sipo->ads);
- BLI_listbase_clear(&sipo->runtime.ghost_curves);
- }
- else if (sl->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *)sl;
-
- BLO_read_data_address(reader, &snla->ads);
- }
- else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
-
- /* use newdataadr_no_us and do not free old memory avoiding double
- * frees and use of freed memory. this could happen because of a
- * bug fixed in revision 58959 where the treestore memory address
- * was not unique */
- TreeStore *ts = newdataadr_no_us(reader->fd, space_outliner->treestore);
- space_outliner->treestore = NULL;
- if (ts) {
- TreeStoreElem *elems = newdataadr_no_us(reader->fd, ts->data);
-
- space_outliner->treestore = BLI_mempool_create(
- sizeof(TreeStoreElem), ts->usedelem, 512, BLI_MEMPOOL_ALLOW_ITER);
- if (ts->usedelem && elems) {
- for (int i = 0; i < ts->usedelem; i++) {
- TreeStoreElem *new_elem = BLI_mempool_alloc(space_outliner->treestore);
- *new_elem = elems[i];
- }
- }
- /* we only saved what was used */
- space_outliner->storeflag |= SO_TREESTORE_CLEANUP; /* at first draw */
- }
- space_outliner->treehash = NULL;
- space_outliner->tree.first = space_outliner->tree.last = NULL;
- }
- else if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
-
- sima->iuser.scene = NULL;
- sima->iuser.ok = 1;
- sima->scopes.waveform_1 = NULL;
- sima->scopes.waveform_2 = NULL;
- sima->scopes.waveform_3 = NULL;
- sima->scopes.vecscope = NULL;
- sima->scopes.ok = 0;
-
- /* WARNING: gpencil data is no longer stored directly in sima after 2.5
- * so sacrifice a few old files for now to avoid crashes with new files!
- * committed: r28002 */
-#if 0
- sima->gpd = newdataadr(fd, sima->gpd);
- if (sima->gpd) {
- BKE_gpencil_blend_read_data(fd, sima->gpd);
- }
-#endif
- }
- else if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
-
- if (snode->gpd) {
- BLO_read_data_address(reader, &snode->gpd);
- BKE_gpencil_blend_read_data(reader, snode->gpd);
- }
-
- BLO_read_list(reader, &snode->treepath);
- snode->edittree = NULL;
- snode->iofsd = NULL;
- BLI_listbase_clear(&snode->linkdrag);
- }
- else if (sl->spacetype == SPACE_TEXT) {
- SpaceText *st = (SpaceText *)sl;
- memset(&st->runtime, 0, sizeof(st->runtime));
- }
- else if (sl->spacetype == SPACE_SEQ) {
- SpaceSeq *sseq = (SpaceSeq *)sl;
-
- /* grease pencil data is not a direct data and can't be linked from direct_link*
- * functions, it should be linked from lib_link* functions instead
- *
- * otherwise it'll lead to lost grease data on open because it'll likely be
- * read from file after all other users of grease pencil and newdataadr would
- * simple return NULL here (sergey)
- */
-#if 0
- if (sseq->gpd) {
- sseq->gpd = newdataadr(fd, sseq->gpd);
- BKE_gpencil_blend_read_data(fd, sseq->gpd);
- }
-#endif
- sseq->scopes.reference_ibuf = NULL;
- sseq->scopes.zebra_ibuf = NULL;
- sseq->scopes.waveform_ibuf = NULL;
- sseq->scopes.sep_waveform_ibuf = NULL;
- sseq->scopes.vector_ibuf = NULL;
- sseq->scopes.histogram_ibuf = NULL;
- }
- else if (sl->spacetype == SPACE_PROPERTIES) {
- SpaceProperties *sbuts = (SpaceProperties *)sl;
-
- sbuts->path = NULL;
- sbuts->texuser = NULL;
- sbuts->mainbo = sbuts->mainb;
- sbuts->mainbuser = sbuts->mainb;
- sbuts->runtime = NULL;
- }
- else if (sl->spacetype == SPACE_CONSOLE) {
- SpaceConsole *sconsole = (SpaceConsole *)sl;
-
- BLO_read_list(reader, &sconsole->scrollback);
- BLO_read_list(reader, &sconsole->history);
-
- /* 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*/
- LISTBASE_FOREACH_MUTABLE (ConsoleLine *, cl, &sconsole->history) {
- BLO_read_data_address(reader, &cl->line);
- if (cl->line) {
- /* the allocted length is not written, so reset here */
- cl->len_alloc = cl->len + 1;
- }
- else {
- BLI_remlink(&sconsole->history, cl);
- MEM_freeN(cl);
- }
- }
- }
- else if (sl->spacetype == SPACE_FILE) {
- SpaceFile *sfile = (SpaceFile *)sl;
-
- /* this sort of info is probably irrelevant for reloading...
- * plus, it isn't saved to files yet!
- */
- sfile->folders_prev = sfile->folders_next = NULL;
- sfile->files = NULL;
- sfile->layout = NULL;
- sfile->op = NULL;
- sfile->previews_timer = NULL;
- BLO_read_data_address(reader, &sfile->params);
- }
- else if (sl->spacetype == SPACE_CLIP) {
- SpaceClip *sclip = (SpaceClip *)sl;
-
- sclip->scopes.track_search = NULL;
- sclip->scopes.track_preview = NULL;
- sclip->scopes.ok = 0;
- }
- }
-
- BLI_listbase_clear(&area->actionzones);
-
- BLO_read_data_address(reader, &area->v1);
- BLO_read_data_address(reader, &area->v2);
- BLO_read_data_address(reader, &area->v3);
- BLO_read_data_address(reader, &area->v4);
-}
-
-static void lib_link_area(BlendLibReader *reader, ID *parent_id, ScrArea *area)
-{
- BLO_read_id_address(reader, parent_id->lib, &area->full);
-
- memset(&area->runtime, 0x0, sizeof(area->runtime));
-
- LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
- switch (sl->spacetype) {
- case SPACE_VIEW3D: {
- View3D *v3d = (View3D *)sl;
-
- BLO_read_id_address(reader, parent_id->lib, &v3d->camera);
- BLO_read_id_address(reader, parent_id->lib, &v3d->ob_center);
-
- if (v3d->localvd) {
- BLO_read_id_address(reader, parent_id->lib, &v3d->localvd->camera);
- }
- break;
- }
- case SPACE_GRAPH: {
- SpaceGraph *sipo = (SpaceGraph *)sl;
- bDopeSheet *ads = sipo->ads;
-
- if (ads) {
- BLO_read_id_address(reader, parent_id->lib, &ads->source);
- BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
- }
- break;
- }
- case SPACE_PROPERTIES: {
- SpaceProperties *sbuts = (SpaceProperties *)sl;
- BLO_read_id_address(reader, parent_id->lib, &sbuts->pinid);
- if (sbuts->pinid == NULL) {
- sbuts->flag &= ~SB_PIN_CONTEXT;
- }
- break;
- }
- case SPACE_FILE:
- break;
- case SPACE_ACTION: {
- SpaceAction *saction = (SpaceAction *)sl;
- bDopeSheet *ads = &saction->ads;
-
- if (ads) {
- BLO_read_id_address(reader, parent_id->lib, &ads->source);
- BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
- }
-
- BLO_read_id_address(reader, parent_id->lib, &saction->action);
- break;
- }
- case SPACE_IMAGE: {
- SpaceImage *sima = (SpaceImage *)sl;
-
- BLO_read_id_address(reader, parent_id->lib, &sima->image);
- BLO_read_id_address(reader, parent_id->lib, &sima->mask_info.mask);
-
- /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
- * so fingers crossed this works fine!
- */
- BLO_read_id_address(reader, parent_id->lib, &sima->gpd);
- break;
- }
- case SPACE_SEQ: {
- SpaceSeq *sseq = (SpaceSeq *)sl;
-
- /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
- * so fingers crossed this works fine!
- */
- BLO_read_id_address(reader, parent_id->lib, &sseq->gpd);
- break;
- }
- case SPACE_NLA: {
- SpaceNla *snla = (SpaceNla *)sl;
- bDopeSheet *ads = snla->ads;
-
- if (ads) {
- BLO_read_id_address(reader, parent_id->lib, &ads->source);
- BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
- }
- break;
- }
- case SPACE_TEXT: {
- SpaceText *st = (SpaceText *)sl;
-
- BLO_read_id_address(reader, parent_id->lib, &st->text);
- break;
- }
- case SPACE_SCRIPT: {
- SpaceScript *scpt = (SpaceScript *)sl;
- /*scpt->script = NULL; - 2.45 set to null, better re-run the script */
- if (scpt->script) {
- BLO_read_id_address(reader, parent_id->lib, &scpt->script);
- if (scpt->script) {
- SCRIPT_SET_NULL(scpt->script);
- }
- }
- break;
- }
- case SPACE_OUTLINER: {
- SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
- BLO_read_id_address(reader, NULL, &space_outliner->search_tse.id);
-
- if (space_outliner->treestore) {
- TreeStoreElem *tselem;
- BLI_mempool_iter iter;
-
- BLI_mempool_iternew(space_outliner->treestore, &iter);
- while ((tselem = BLI_mempool_iterstep(&iter))) {
- BLO_read_id_address(reader, NULL, &tselem->id);
- }
- if (space_outliner->treehash) {
- /* rebuild hash table, because it depends on ids too */
- space_outliner->storeflag |= SO_TREESTORE_REBUILD;
- }
- }
- break;
- }
- case SPACE_NODE: {
- SpaceNode *snode = (SpaceNode *)sl;
-
- /* node tree can be stored locally in id too, link this first */
- BLO_read_id_address(reader, parent_id->lib, &snode->id);
- BLO_read_id_address(reader, parent_id->lib, &snode->from);
-
- bNodeTree *ntree = snode->id ? ntreeFromID(snode->id) : NULL;
- if (ntree) {
- snode->nodetree = ntree;
- }
- else {
- BLO_read_id_address(reader, parent_id->lib, &snode->nodetree);
- }
-
- bNodeTreePath *path;
- for (path = snode->treepath.first; path; path = path->next) {
- if (path == snode->treepath.first) {
- /* first nodetree in path is same as snode->nodetree */
- path->nodetree = snode->nodetree;
- }
- else {
- BLO_read_id_address(reader, parent_id->lib, &path->nodetree);
- }
-
- if (!path->nodetree) {
- break;
- }
- }
-
- /* remaining path entries are invalid, remove */
- bNodeTreePath *path_next;
- for (; path; path = path_next) {
- path_next = path->next;
-
- BLI_remlink(&snode->treepath, path);
- MEM_freeN(path);
- }
-
- /* edittree is just the last in the path,
- * set this directly since the path may have been shortened above */
- if (snode->treepath.last) {
- path = snode->treepath.last;
- snode->edittree = path->nodetree;
- }
- else {
- snode->edittree = NULL;
- }
- break;
- }
- case SPACE_CLIP: {
- SpaceClip *sclip = (SpaceClip *)sl;
- BLO_read_id_address(reader, parent_id->lib, &sclip->clip);
- BLO_read_id_address(reader, parent_id->lib, &sclip->mask_info.mask);
- break;
- }
- default:
- break;
- }
- }
-}
-
-/**
- * \return false on error.
- */
-static bool direct_link_area_map(BlendDataReader *reader, ScrAreaMap *area_map)
-{
- BLO_read_list(reader, &area_map->vertbase);
- BLO_read_list(reader, &area_map->edgebase);
- BLO_read_list(reader, &area_map->areabase);
- LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
- direct_link_area(reader, area);
- }
-
- /* edges */
- LISTBASE_FOREACH (ScrEdge *, se, &area_map->edgebase) {
- BLO_read_data_address(reader, &se->v1);
- BLO_read_data_address(reader, &se->v2);
- BKE_screen_sort_scrvert(&se->v1, &se->v2);
-
- if (se->v1 == NULL) {
- BLI_remlink(&area_map->edgebase, se);
-
- return false;
- }
- }
-
- return true;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name XR-data
- * \{ */
-
-static void direct_link_wm_xr_data(BlendDataReader *reader, wmXrData *xr_data)
-{
- direct_link_view3dshading(reader, &xr_data->session_settings.shading);
-}
-
-static void lib_link_wm_xr_data(BlendLibReader *reader, ID *parent_id, wmXrData *xr_data)
-{
- BLO_read_id_address(reader, parent_id->lib, &xr_data->session_settings.base_pose_object);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Read ID: Window Manager
- * \{ */
-
-static void direct_link_windowmanager(BlendDataReader *reader, wmWindowManager *wm)
-{
- id_us_ensure_real(&wm->id);
- BLO_read_list(reader, &wm->windows);
-
- LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
- BLO_read_data_address(reader, &win->parent);
-
- WorkSpaceInstanceHook *hook = win->workspace_hook;
- BLO_read_data_address(reader, &win->workspace_hook);
-
- /* This will be NULL for any pre-2.80 blend file. */
- if (win->workspace_hook != NULL) {
- /* We need to restore a pointer to this later when reading workspaces,
- * so store in global oldnew-map.
- * Note that this is only needed for versioning of older .blend files now.. */
- oldnewmap_insert(reader->fd->globmap, hook, win->workspace_hook, 0);
- /* Cleanup pointers to data outside of this data-block scope. */
- win->workspace_hook->act_layout = NULL;
- win->workspace_hook->temp_workspace_store = NULL;
- win->workspace_hook->temp_layout_store = NULL;
- }
-
- direct_link_area_map(reader, &win->global_areas);
-
- win->ghostwin = NULL;
- win->gpuctx = NULL;
- win->eventstate = NULL;
- win->cursor_keymap_status = NULL;
- win->tweak = NULL;
-#ifdef WIN32
- win->ime_data = NULL;
-#endif
-
- BLI_listbase_clear(&win->queue);
- BLI_listbase_clear(&win->handlers);
- BLI_listbase_clear(&win->modalhandlers);
- BLI_listbase_clear(&win->gesture);
-
- win->active = 0;
-
- win->cursor = 0;
- win->lastcursor = 0;
- win->modalcursor = 0;
- win->grabcursor = 0;
- win->addmousemove = true;
- BLO_read_data_address(reader, &win->stereo3d_format);
-
- /* Multi-view always fallback to anaglyph at file opening
- * otherwise quad-buffer saved files can break Blender. */
- if (win->stereo3d_format) {
- win->stereo3d_format->display_mode = S3D_DISPLAY_ANAGLYPH;
- }
- }
-
- direct_link_wm_xr_data(reader, &wm->xr);
-
- BLI_listbase_clear(&wm->timers);
- BLI_listbase_clear(&wm->operators);
- BLI_listbase_clear(&wm->paintcursors);
- BLI_listbase_clear(&wm->queue);
- BKE_reports_init(&wm->reports, RPT_STORE);
-
- BLI_listbase_clear(&wm->keyconfigs);
- wm->defaultconf = NULL;
- wm->addonconf = NULL;
- wm->userconf = NULL;
- wm->undo_stack = NULL;
-
- wm->message_bus = NULL;
-
- wm->xr.runtime = NULL;
-
- BLI_listbase_clear(&wm->jobs);
- BLI_listbase_clear(&wm->drags);
-
- wm->windrawable = NULL;
- wm->winactive = NULL;
- wm->initialized = 0;
- wm->op_undo_depth = 0;
- wm->is_interface_locked = 0;
-}
-
-static void lib_link_windowmanager(BlendLibReader *reader, wmWindowManager *wm)
-{
- LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
- if (win->workspace_hook) { /* NULL for old files */
- lib_link_workspace_instance_hook(reader, win->workspace_hook, &wm->id);
- }
- BLO_read_id_address(reader, wm->id.lib, &win->scene);
- /* deprecated, but needed for versioning (will be NULL'ed then) */
- BLO_read_id_address(reader, NULL, &win->screen);
-
- LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
- lib_link_area(reader, &wm->id, area);
- }
-
- lib_link_wm_xr_data(reader, &wm->id, &wm->xr);
- }
-}
-
/** \} */
/* -------------------------------------------------------------------- */
/** \name Read ID: Screen
* \{ */
-/* note: file read without screens option G_FILE_NO_UI;
- * check lib pointers in call below */
-static void lib_link_screen(BlendLibReader *reader, bScreen *screen)
-{
- /* deprecated, but needed for versioning (will be NULL'ed then) */
- BLO_read_id_address(reader, screen->id.lib, &screen->scene);
-
- screen->animtimer = NULL; /* saved in rare cases */
- screen->tool_tip = NULL;
- screen->scrubbing = false;
-
- LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
- lib_link_area(reader, &screen->id, area);
- }
-}
-
/* how to handle user count on pointer restore */
typedef enum ePointerUserMode {
USER_IGNORE = 0, /* ignore user count */
@@ -6096,48 +2964,6 @@ void blo_lib_link_restore(Main *oldmain,
BKE_main_idmap_destroy(id_map);
}
-/* for the saved 2.50 files without regiondata */
-/* and as patch for 2.48 and older */
-void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions)
-{
- LISTBASE_FOREACH (ARegion *, region, regions) {
- if (region->regiontype == RGN_TYPE_WINDOW && region->regiondata == NULL) {
- RegionView3D *rv3d;
-
- rv3d = region->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch");
- rv3d->persp = (char)v3d->persp;
- rv3d->view = (char)v3d->view;
- rv3d->dist = v3d->dist;
- copy_v3_v3(rv3d->ofs, v3d->ofs);
- copy_qt_qt(rv3d->viewquat, v3d->viewquat);
- }
- }
-
- /* this was not initialized correct always */
- if (v3d->gridsubdiv == 0) {
- v3d->gridsubdiv = 10;
- }
-}
-
-static bool direct_link_screen(BlendDataReader *reader, bScreen *screen)
-{
- bool success = true;
-
- screen->regionbase.first = screen->regionbase.last = NULL;
- screen->context = NULL;
- screen->active_region = NULL;
-
- BLO_read_data_address(reader, &screen->preview);
- BKE_previewimg_blend_read(reader, screen->preview);
-
- if (!direct_link_area_map(reader, AREAMAP_FROM_SCREEN(screen))) {
- printf("Error reading Screen %s... removing it.\n", screen->id.name + 2);
- success = false;
- }
-
- return success;
-}
-
/** \} */
/* -------------------------------------------------------------------- */
@@ -6152,7 +2978,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
for (newmain = fd->mainlist->first; newmain; newmain = newmain->next) {
if (newmain->curlib) {
if (BLI_path_cmp(newmain->curlib->filepath_abs, lib->filepath_abs) == 0) {
- blo_reportf_wrap(fd->reports,
+ BLO_reportf_wrap(fd->reports,
RPT_WARNING,
TIP_("Library '%s', '%s' had multiple instances, save and reload!"),
lib->filepath,
@@ -6381,64 +3207,13 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
bool success = true;
switch (GS(id->name)) {
- case ID_WM:
- direct_link_windowmanager(&reader, (wmWindowManager *)id);
- break;
case ID_SCR:
- success = direct_link_screen(&reader, (bScreen *)id);
- break;
- case ID_SCE:
- direct_link_scene(&reader, (Scene *)id);
- break;
- case ID_OB:
- direct_link_object(&reader, (Object *)id);
- break;
- case ID_IP:
- direct_link_ipo(&reader, (Ipo *)id);
+ success = BKE_screen_blend_read_data(&reader, (bScreen *)id);
break;
case ID_LI:
direct_link_library(fd, (Library *)id, main);
break;
- case ID_GR:
- direct_link_collection(&reader, (Collection *)id);
- break;
- case ID_PA:
- direct_link_particlesettings(&reader, (ParticleSettings *)id);
- break;
- case ID_WS:
- direct_link_workspace(&reader, (WorkSpace *)id);
- break;
- case ID_ME:
- case ID_LT:
- case ID_AC:
- case ID_NT:
- case ID_LS:
- case ID_TXT:
- case ID_VF:
- case ID_MC:
- case ID_PAL:
- case ID_PC:
- case ID_BR:
- case ID_IM:
- case ID_LA:
- case ID_MA:
- case ID_MB:
- case ID_CU:
- case ID_CA:
- case ID_WO:
- case ID_MSK:
- case ID_SPK:
- case ID_AR:
- case ID_LP:
- case ID_KE:
- case ID_TE:
- case ID_GD:
- case ID_HA:
- case ID_PT:
- case ID_VO:
- case ID_SIM:
- case ID_SO:
- case ID_CF:
+ default:
/* Do nothing. Handled by IDTypeInfo callback. */
break;
}
@@ -6628,15 +3403,6 @@ static void read_libblock_undo_restore_at_old_address(FileData *fd, Main *main,
const short idcode = GS(id->name);
- /* XXX 3DCursor (witch is UI data and as such should not be affected by undo) is stored in
- * Scene... So this requires some special handling, previously done in `blo_lib_link_restore()`,
- * but this cannot work anymore when we overwrite existing memory... */
- if (idcode == ID_SCE) {
- Scene *scene_old = (Scene *)id_old;
- Scene *scene = (Scene *)id;
- SWAP(View3DCursor, scene_old->cursor, scene->cursor);
- }
-
Main *old_bmain = fd->old_mainlist->first;
ListBase *old_lb = which_libbase(old_bmain, idcode);
ListBase *new_lb = which_libbase(main, idcode);
@@ -6648,6 +3414,11 @@ static void read_libblock_undo_restore_at_old_address(FileData *fd, Main *main,
* process). So we can pass NULL for the Main pointer parameter. */
BKE_lib_id_swap_full(NULL, id, id_old);
+ /* Special temporary usage of this pointer, necessary for the `undo_preserve` call after
+ * lib-linking to restore some data that should never be affected by undo, e.g. the 3D cursor of
+ * #Scene. */
+ id_old->orig_id = id;
+
BLI_addtail(new_lb, id_old);
BLI_addtail(old_lb, id);
}
@@ -7018,78 +3789,23 @@ static void lib_link_all(FileData *fd, Main *bmain)
id_type->blend_read_lib(&reader, id);
}
- /* Note: ID types are processed in reverse order as defined by INDEX_ID_XXX enums in DNA_ID.h.
- * This ensures handling of most dependencies in proper order, as elsewhere in code.
- * Please keep order of entries in that switch matching that order, it's easier to quickly see
- * whether something is wrong then. */
- switch (GS(id->name)) {
- case ID_WM:
- lib_link_windowmanager(&reader, (wmWindowManager *)id);
- break;
- case ID_WS:
- /* Could we skip WS in undo case? */
- lib_link_workspaces(&reader, (WorkSpace *)id);
- break;
- case ID_SCE:
- lib_link_scene(&reader, (Scene *)id);
- break;
- case ID_OB:
- lib_link_object(&reader, (Object *)id);
- break;
- case ID_SCR:
- /* DO NOT skip screens here, 3D viewport may contains pointers
- * to other ID data (like #View3D.ob_center)! See T41411. */
- lib_link_screen(&reader, (bScreen *)id);
- break;
- case ID_PA:
- lib_link_particlesettings(&reader, (ParticleSettings *)id);
- break;
- case ID_GR:
- lib_link_collection(&reader, (Collection *)id);
- break;
- case ID_IP:
- /* XXX deprecated... still needs to be maintained for version patches still. */
- lib_link_ipo(&reader, (Ipo *)id);
- break;
- case ID_LI:
- lib_link_library(&reader, (Library *)id); /* Only init users. */
- break;
- case ID_ME:
- case ID_LT:
- case ID_AC:
- case ID_NT:
- case ID_LS:
- case ID_TXT:
- case ID_VF:
- case ID_MC:
- case ID_PAL:
- case ID_PC:
- case ID_BR:
- case ID_IM:
- case ID_LA:
- case ID_MA:
- case ID_MB:
- case ID_CU:
- case ID_CA:
- case ID_WO:
- case ID_MSK:
- case ID_SPK:
- case ID_AR:
- case ID_LP:
- case ID_KE:
- case ID_TE:
- case ID_GD:
- case ID_HA:
- case ID_PT:
- case ID_VO:
- case ID_SIM:
- case ID_SO:
- case ID_CF:
- /* Do nothing. Handled by IDTypeInfo callback. */
- break;
+ if (GS(id->name) == ID_LI) {
+ lib_link_library(&reader, (Library *)id); /* Only init users. */
}
id->tag &= ~LIB_TAG_NEED_LINK;
+
+ /* Some data that should be persistent, like the 3DCursor or the tool settings, are
+ * stored in IDs affected by undo, like Scene. So this requires some specific handling. */
+ if (id_type->blend_read_undo_preserve != NULL && id->orig_id != NULL) {
+ id_type->blend_read_undo_preserve(&reader, id, id->orig_id);
+ }
+ }
+ FOREACH_MAIN_ID_END;
+
+ /* Cleanup `ID.orig_id`, this is now reserved for depsgraph/COW usage only. */
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
+ id->orig_id = NULL;
}
FOREACH_MAIN_ID_END;
@@ -7560,7 +4276,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
if (libmain->curlib == NULL) {
const char *idname = blo_bhead_id_name(fd, bhead);
- blo_reportf_wrap(fd->reports,
+ BLO_reportf_wrap(fd->reports,
RPT_WARNING,
TIP_("LIB: Data refers to main .blend file: '%s' from %s"),
idname,
@@ -7649,26 +4365,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
static BLOExpandDoitCallback expand_doit;
-// XXX deprecated - old animation system
-static void expand_ipo(BlendExpander *expander, Ipo *ipo)
-{
- LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
- if (icu->driver) {
- BLO_expand(expander, icu->driver->ob);
- }
- }
-}
-
-/* XXX deprecated - old animation system */
-static void expand_constraint_channels(BlendExpander *expander, ListBase *chanbase)
-{
- LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
- BLO_expand(expander, chan->ipo);
- }
-}
-
static void expand_id(BlendExpander *expander, ID *id);
-static void expand_collection(BlendExpander *expander, Collection *collection);
static void expand_id_embedded_id(BlendExpander *expander, ID *id)
{
@@ -7683,7 +4380,7 @@ static void expand_id_embedded_id(BlendExpander *expander, ID *id)
Scene *scene = (Scene *)id;
if (scene->master_collection != NULL) {
expand_id(expander, &scene->master_collection->id);
- expand_collection(expander, scene->master_collection);
+ BKE_collection_blend_read_expand(expander, scene->master_collection);
}
}
}
@@ -7705,322 +4402,6 @@ static void expand_id(BlendExpander *expander, ID *id)
expand_id_embedded_id(expander, id);
}
-static void expand_particlesettings(BlendExpander *expander, ParticleSettings *part)
-{
- BLO_expand(expander, part->instance_object);
- BLO_expand(expander, part->instance_collection);
- BLO_expand(expander, part->force_group);
- BLO_expand(expander, part->bb_ob);
- BLO_expand(expander, part->collision_group);
-
- for (int a = 0; a < MAX_MTEX; a++) {
- if (part->mtex[a]) {
- BLO_expand(expander, part->mtex[a]->tex);
- BLO_expand(expander, part->mtex[a]->object);
- }
- }
-
- if (part->effector_weights) {
- BLO_expand(expander, part->effector_weights->group);
- }
-
- if (part->pd) {
- BLO_expand(expander, part->pd->tex);
- BLO_expand(expander, part->pd->f_source);
- }
- if (part->pd2) {
- BLO_expand(expander, part->pd2->tex);
- BLO_expand(expander, part->pd2->f_source);
- }
-
- if (part->boids) {
- LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
- LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
- if (rule->type == eBoidRuleType_Avoid) {
- BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule;
- BLO_expand(expander, gabr->ob);
- }
- else if (rule->type == eBoidRuleType_FollowLeader) {
- BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule;
- BLO_expand(expander, flbr->ob);
- }
- }
- }
- }
-
- LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
- BLO_expand(expander, dw->ob);
- }
-}
-
-static void expand_collection(BlendExpander *expander, Collection *collection)
-{
- LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
- BLO_expand(expander, cob->ob);
- }
-
- LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
- BLO_expand(expander, child->collection);
- }
-
-#ifdef USE_COLLECTION_COMPAT_28
- if (collection->collection != NULL) {
- expand_scene_collection(expander, collection->collection);
- }
-#endif
-}
-
-/* callback function used to expand constraint ID-links */
-static void expand_constraint_cb(bConstraint *UNUSED(con),
- ID **idpoin,
- bool UNUSED(is_reference),
- void *userdata)
-{
- BlendExpander *expander = userdata;
- BLO_expand(expander, *idpoin);
-}
-
-static void expand_constraints(BlendExpander *expander, ListBase *lb)
-{
- BKE_constraints_id_loop(lb, expand_constraint_cb, expander);
-
- /* deprecated manual expansion stuff */
- LISTBASE_FOREACH (bConstraint *, curcon, lb) {
- if (curcon->ipo) {
- BLO_expand(expander, curcon->ipo); /* XXX deprecated - old animation system */
- }
- }
-}
-
-static void expand_pose(BlendExpander *expander, bPose *pose)
-{
- if (!pose) {
- return;
- }
-
- LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
- expand_constraints(expander, &chan->constraints);
- IDP_BlendReadExpand(expander, chan->prop);
- BLO_expand(expander, chan->custom);
- }
-}
-
-static void expand_object_expandModifiers(void *userData,
- Object *UNUSED(ob),
- ID **idpoin,
- int UNUSED(cb_flag))
-{
- BlendExpander *expander = userData;
- BLO_expand(expander, *idpoin);
-}
-
-static void expand_object(BlendExpander *expander, Object *ob)
-{
- BLO_expand(expander, ob->data);
-
- /* expand_object_expandModifier() */
- if (ob->modifiers.first) {
- BKE_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, expander);
- }
-
- /* expand_object_expandModifier() */
- if (ob->greasepencil_modifiers.first) {
- BKE_gpencil_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, expander);
- }
-
- /* expand_object_expandShaderFx() */
- if (ob->shader_fx.first) {
- BKE_shaderfx_foreach_ID_link(ob, expand_object_expandModifiers, expander);
- }
-
- expand_pose(expander, ob->pose);
- BLO_expand(expander, ob->poselib);
- expand_constraints(expander, &ob->constraints);
-
- BLO_expand(expander, ob->gpd);
-
- /* XXX deprecated - old animation system (for version patching only) */
- BLO_expand(expander, ob->ipo);
- BLO_expand(expander, ob->action);
-
- expand_constraint_channels(expander, &ob->constraintChannels);
-
- LISTBASE_FOREACH (bActionStrip *, strip, &ob->nlastrips) {
- BLO_expand(expander, strip->object);
- BLO_expand(expander, strip->act);
- BLO_expand(expander, strip->ipo);
- }
- /* XXX deprecated - old animation system (for version patching only) */
-
- for (int a = 0; a < ob->totcol; a++) {
- BLO_expand(expander, ob->mat[a]);
- }
-
- PartEff *paf = blo_do_version_give_parteff_245(ob);
- if (paf && paf->group) {
- BLO_expand(expander, paf->group);
- }
-
- if (ob->instance_collection) {
- BLO_expand(expander, ob->instance_collection);
- }
-
- if (ob->proxy) {
- BLO_expand(expander, ob->proxy);
- }
- if (ob->proxy_group) {
- BLO_expand(expander, ob->proxy_group);
- }
-
- LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
- BLO_expand(expander, psys->part);
- }
-
- if (ob->pd) {
- BLO_expand(expander, ob->pd->tex);
- BLO_expand(expander, ob->pd->f_source);
- }
-
- if (ob->soft) {
- BLO_expand(expander, ob->soft->collision_group);
-
- if (ob->soft->effector_weights) {
- BLO_expand(expander, ob->soft->effector_weights->group);
- }
- }
-
- if (ob->rigidbody_constraint) {
- BLO_expand(expander, ob->rigidbody_constraint->ob1);
- BLO_expand(expander, ob->rigidbody_constraint->ob2);
- }
-}
-
-#ifdef USE_COLLECTION_COMPAT_28
-static void expand_scene_collection(BlendExpander *expander, SceneCollection *sc)
-{
- LISTBASE_FOREACH (LinkData *, link, &sc->objects) {
- BLO_expand(expander, link->data);
- }
-
- LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) {
- expand_scene_collection(expander, nsc);
- }
-}
-#endif
-
-static void expand_scene(BlendExpander *expander, Scene *sce)
-{
- LISTBASE_FOREACH (Base *, base_legacy, &sce->base) {
- BLO_expand(expander, base_legacy->object);
- }
- BLO_expand(expander, sce->camera);
- BLO_expand(expander, sce->world);
-
- BKE_keyingsets_blend_read_expand(expander, &sce->keyingsets);
-
- if (sce->set) {
- BLO_expand(expander, sce->set);
- }
-
- LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
- BLO_expand(expander, srl->mat_override);
- LISTBASE_FOREACH (FreestyleModuleConfig *, module, &srl->freestyleConfig.modules) {
- if (module->script) {
- BLO_expand(expander, module->script);
- }
- }
- LISTBASE_FOREACH (FreestyleLineSet *, lineset, &srl->freestyleConfig.linesets) {
- if (lineset->group) {
- BLO_expand(expander, lineset->group);
- }
- BLO_expand(expander, lineset->linestyle);
- }
- }
-
- LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
- IDP_BlendReadExpand(expander, view_layer->id_properties);
-
- LISTBASE_FOREACH (FreestyleModuleConfig *, module, &view_layer->freestyle_config.modules) {
- if (module->script) {
- BLO_expand(expander, module->script);
- }
- }
-
- LISTBASE_FOREACH (FreestyleLineSet *, lineset, &view_layer->freestyle_config.linesets) {
- if (lineset->group) {
- BLO_expand(expander, lineset->group);
- }
- BLO_expand(expander, lineset->linestyle);
- }
- }
-
- if (sce->gpd) {
- BLO_expand(expander, sce->gpd);
- }
-
- if (sce->ed) {
- Sequence *seq;
-
- SEQ_ALL_BEGIN (sce->ed, seq) {
- IDP_BlendReadExpand(expander, seq->prop);
-
- if (seq->scene) {
- BLO_expand(expander, seq->scene);
- }
- if (seq->scene_camera) {
- BLO_expand(expander, seq->scene_camera);
- }
- if (seq->clip) {
- BLO_expand(expander, seq->clip);
- }
- if (seq->mask) {
- BLO_expand(expander, seq->mask);
- }
- if (seq->sound) {
- BLO_expand(expander, seq->sound);
- }
-
- if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
- TextVars *data = seq->effectdata;
- BLO_expand(expander, data->text_font);
- }
- }
- SEQ_ALL_END;
- }
-
- if (sce->rigidbody_world) {
- BLO_expand(expander, sce->rigidbody_world->group);
- BLO_expand(expander, sce->rigidbody_world->constraints);
- }
-
- LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
- IDP_BlendReadExpand(expander, marker->prop);
-
- if (marker->camera) {
- BLO_expand(expander, marker->camera);
- }
- }
-
- BLO_expand(expander, sce->clip);
-
-#ifdef USE_COLLECTION_COMPAT_28
- if (sce->collection) {
- expand_scene_collection(expander, sce->collection);
- }
-#endif
-
- if (sce->r.bake.cage_object) {
- BLO_expand(expander, sce->r.bake.cage_object);
- }
-}
-
-static void expand_workspace(BlendExpander *expander, WorkSpace *workspace)
-{
- LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
- BLO_expand(expander, BKE_workspace_layout_screen_get(layout));
- }
-}
-
/**
* Set the callback func used over all ID data found by \a BLO_expand_main func.
*
@@ -8063,29 +4444,6 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
id_type->blend_read_expand(&expander, id);
}
- switch (GS(id->name)) {
- case ID_OB:
- expand_object(&expander, (Object *)id);
- break;
- case ID_SCE:
- expand_scene(&expander, (Scene *)id);
- break;
- case ID_GR:
- expand_collection(&expander, (Collection *)id);
- break;
- case ID_IP:
- expand_ipo(&expander, (Ipo *)id); /* XXX deprecated - old animation system */
- break;
- case ID_PA:
- expand_particlesettings(&expander, (ParticleSettings *)id);
- break;
- case ID_WS:
- expand_workspace(&expander, (WorkSpace *)id);
- break;
- default:
- break;
- }
-
do_it = true;
id->tag &= ~LIB_TAG_NEED_EXPAND;
}
@@ -8123,6 +4481,31 @@ static bool object_in_any_collection(Main *bmain, Object *ob)
return false;
}
+/**
+ * Shared operations to perform on the object's base after adding it to the scene.
+ */
+static void object_base_instance_init(
+ Object *ob, bool set_selected, bool set_active, ViewLayer *view_layer, const View3D *v3d)
+{
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+
+ if (v3d != NULL) {
+ base->local_view_bits |= v3d->local_view_uuid;
+ }
+
+ if (set_selected) {
+ if (base->flag & BASE_SELECTABLE) {
+ base->flag |= BASE_SELECTED;
+ }
+ }
+
+ if (set_active) {
+ view_layer->basact = base;
+ }
+
+ BKE_scene_object_base_flag_sync_from_base(base);
+}
+
static void add_loose_objects_to_scene(Main *mainvar,
Main *bmain,
Scene *scene,
@@ -8168,19 +4551,12 @@ static void add_loose_objects_to_scene(Main *mainvar,
ob->mode = OB_MODE_OBJECT;
BKE_collection_object_add(bmain, active_collection, ob);
- Base *base = BKE_view_layer_base_find(view_layer, ob);
-
- if (v3d != NULL) {
- base->local_view_bits |= v3d->local_view_uuid;
- }
-
- if ((flag & FILE_AUTOSELECT) && (base->flag & BASE_SELECTABLE)) {
- /* Do NOT make base active here! screws up GUI stuff,
- * if you want it do it at the editor level. */
- base->flag |= BASE_SELECTED;
- }
- BKE_scene_object_base_flag_sync_from_base(base);
+ const bool set_selected = (flag & FILE_AUTOSELECT) != 0;
+ /* Do NOT make base active here! screws up GUI stuff,
+ * if you want it do it at the editor level. */
+ const bool set_active = false;
+ object_base_instance_init(ob, set_selected, set_active, view_layer, v3d);
ob->id.tag &= ~LIB_TAG_INDIRECT;
ob->id.flag &= ~LIB_INDIRECT_WEAK_LINK;
@@ -8226,19 +4602,12 @@ static void add_loose_object_data_to_scene(Main *mainvar,
BKE_object_materials_test(bmain, ob, ob->data);
BKE_collection_object_add(bmain, active_collection, ob);
- Base *base = BKE_view_layer_base_find(view_layer, ob);
- if (v3d != NULL) {
- base->local_view_bits |= v3d->local_view_uuid;
- }
-
- if ((flag & FILE_AUTOSELECT) && (base->flag & BASE_SELECTABLE)) {
- /* Do NOT make base active here! screws up GUI stuff,
- * if you want it do it at the editor level. */
- base->flag |= BASE_SELECTED;
- }
-
- BKE_scene_object_base_flag_sync_from_base(base);
+ const bool set_selected = (flag & FILE_AUTOSELECT) != 0;
+ /* Do NOT make base active here! screws up GUI stuff,
+ * if you want it do it at the editor level. */
+ bool set_active = false;
+ object_base_instance_init(ob, set_selected, set_active, view_layer, v3d);
copy_v3_v3(ob->loc, scene->cursor.location);
}
@@ -8272,23 +4641,15 @@ static void add_collections_to_scene(Main *mainvar,
ob->empty_drawsize = U.collection_instance_empty_size;
BKE_collection_object_add(bmain, active_collection, ob);
- Base *base = BKE_view_layer_base_find(view_layer, ob);
- if (v3d != NULL) {
- base->local_view_bits |= v3d->local_view_uuid;
- }
+ const bool set_selected = (flag & FILE_AUTOSELECT) != 0;
+ /* TODO: why is it OK to make this active here but not in other situations?
+ * See other callers of #object_base_instance_init */
+ const bool set_active = set_selected;
+ object_base_instance_init(ob, set_selected, set_active, view_layer, v3d);
- if ((flag & FILE_AUTOSELECT) && (base->flag & BASE_SELECTABLE)) {
- base->flag |= BASE_SELECTED;
- }
-
- BKE_scene_object_base_flag_sync_from_base(base);
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
- if (flag & FILE_AUTOSELECT) {
- view_layer->basact = base;
- }
-
/* Assign the collection. */
ob->instance_collection = collection;
id_us_plus(&collection->id);
@@ -8762,7 +5123,7 @@ static void read_library_linked_id(
}
if (!is_valid) {
- blo_reportf_wrap(reports,
+ BLO_reportf_wrap(reports,
RPT_ERROR,
TIP_("LIB: %s: '%s' is directly linked from '%s' (parent '%s'), but is a "
"non-linkable data type"),
@@ -8781,7 +5142,7 @@ static void read_library_linked_id(
read_libblock(fd, mainvar, bhead, id->tag, false, r_id);
}
else {
- blo_reportf_wrap(reports,
+ BLO_reportf_wrap(reports,
RPT_WARNING,
TIP_("LIB: %s: '%s' missing from '%s', parent '%s'"),
BKE_idtype_idcode_to_name(GS(id->name)),
@@ -8886,7 +5247,7 @@ static FileData *read_library_file_data(FileData *basefd,
/* Read packed file. */
PackedFile *pf = mainptr->curlib->packedfile;
- blo_reportf_wrap(basefd->reports,
+ BLO_reportf_wrap(basefd->reports,
RPT_INFO,
TIP_("Read packed library: '%s', parent '%s'"),
mainptr->curlib->filepath,
@@ -8898,7 +5259,7 @@ static FileData *read_library_file_data(FileData *basefd,
}
else {
/* Read file on disk. */
- blo_reportf_wrap(basefd->reports,
+ BLO_reportf_wrap(basefd->reports,
RPT_INFO,
TIP_("Read library: '%s', '%s', parent '%s'"),
mainptr->curlib->filepath_abs,
@@ -8940,7 +5301,7 @@ static FileData *read_library_file_data(FileData *basefd,
}
if (fd == NULL) {
- blo_reportf_wrap(
+ BLO_reportf_wrap(
basefd->reports, RPT_WARNING, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath_abs);
}
@@ -9042,6 +5403,11 @@ void *BLO_read_get_new_data_address(BlendDataReader *reader, const void *old_add
return newdataadr(reader->fd, old_address);
}
+void *BLO_read_get_new_data_address_no_us(BlendDataReader *reader, const void *old_address)
+{
+ return newdataadr_no_us(reader->fd, old_address);
+}
+
void *BLO_read_get_new_packed_address(BlendDataReader *reader, const void *old_address)
{
return newpackedadr(reader->fd, old_address);
@@ -9207,11 +5573,36 @@ bool BLO_read_data_is_undo(BlendDataReader *reader)
return reader->fd->memfile != NULL;
}
+void BLO_read_data_globmap_add(BlendDataReader *reader, void *oldaddr, void *newaddr)
+{
+ oldnewmap_insert(reader->fd->globmap, oldaddr, newaddr, 0);
+}
+
+void BLO_read_glob_list(BlendDataReader *reader, ListBase *list)
+{
+ link_glob_list(reader->fd, list);
+}
+
+ReportList *BLO_read_data_reports(BlendDataReader *reader)
+{
+ return reader->fd->reports;
+}
+
bool BLO_read_lib_is_undo(BlendLibReader *reader)
{
return reader->fd->memfile != NULL;
}
+Main *BLO_read_lib_get_main(BlendLibReader *reader)
+{
+ return reader->main;
+}
+
+ReportList *BLO_read_lib_reports(BlendLibReader *reader)
+{
+ return reader->fd->reports;
+}
+
void BLO_expand_id(BlendExpander *expander, ID *id)
{
expand_doit(expander->fd, expander->main, id);
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 4fa41731454..fb950e37da8 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -173,9 +173,6 @@ const char *blo_bhead_id_name(const FileData *fd, const BHead *bhead);
/* do versions stuff */
-void blo_reportf_wrap(struct ReportList *reports, ReportType type, const char *format, ...)
- ATTR_PRINTF_FORMAT(3, 4);
-
void blo_do_versions_dna(struct SDNA *sdna, const int versionfile, const int subversionfile);
void blo_do_versions_oldnewmap_insert(struct OldNewMap *onm,
@@ -185,9 +182,7 @@ void blo_do_versions_oldnewmap_insert(struct OldNewMap *onm,
void *blo_do_versions_newlibadr(struct FileData *fd, const void *lib, const void *adr);
void *blo_do_versions_newlibadr_us(struct FileData *fd, const void *lib, const void *adr);
-struct PartEff *blo_do_version_give_parteff_245(struct Object *ob);
void blo_do_version_old_trackto_to_constraints(struct Object *ob);
-void blo_do_versions_view3d_split_250(struct View3D *v3d, struct ListBase *regions);
void blo_do_versions_key_uidgen(struct Key *key);
void blo_do_versions_userdef(struct UserDef *userdef);
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 5046ee6aab1..c86ad639216 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -73,10 +73,11 @@
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_screen.h"
-#include "BKE_sequencer.h"
#include "BKE_sound.h"
#include "BKE_texture.h"
+#include "SEQ_sequencer.h"
+
#include "NOD_socket.h"
#include "BLO_readfile.h"
@@ -266,7 +267,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb)
/* and we split view3d */
switch (sl->spacetype) {
case SPACE_VIEW3D:
- blo_do_versions_view3d_split_250((View3D *)sl, lb);
+ BKE_screen_view3d_do_versions_250((View3D *)sl, lb);
break;
case SPACE_OUTLINER: {
@@ -799,20 +800,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
// BLI_freelistN(&pidlist);
- if (ob->type == OB_MESH) {
- Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data);
- void *olddata = ob->data;
- ob->data = me;
-
- /* XXX - library meshes crash on loading most yoFrankie levels,
- * the multires pointer gets invalid - Campbell */
- if (me && me->id.lib == NULL && me->mr && me->mr->level_count > 1) {
- multires_load_old(ob, me);
- }
-
- ob->data = olddata;
- }
-
if (ob->totcol && ob->matbits == NULL) {
int a;
@@ -1152,7 +1139,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile == 250 && bmain->subversionfile > 1) {
for (me = bmain->meshes.first; me; me = me->id.next) {
- multires_load_old_250(me);
+ CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface);
}
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
@@ -1179,7 +1166,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
if (clmd->sim_parms->velocity_smooth < 0.01f) {
- clmd->sim_parms->velocity_smooth = 0.f;
+ clmd->sim_parms->velocity_smooth = 0.0f;
}
}
}
@@ -1514,9 +1501,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
while (node) {
if (node->type == CMP_NODE_COLORBALANCE) {
NodeColorBalance *n = (NodeColorBalance *)node->storage;
- n->lift[0] += 1.f;
- n->lift[1] += 1.f;
- n->lift[2] += 1.f;
+ n->lift[0] += 1.0f;
+ n->lift[1] += 1.0f;
+ n->lift[2] += 1.0f;
}
node = node->next;
}
@@ -1529,9 +1516,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
while (node) {
if (node->type == CMP_NODE_COLORBALANCE) {
NodeColorBalance *n = (NodeColorBalance *)node->storage;
- n->lift[0] += 1.f;
- n->lift[1] += 1.f;
- n->lift[2] += 1.f;
+ n->lift[0] += 1.0f;
+ n->lift[1] += 1.0f;
+ n->lift[2] += 1.0f;
}
node = node->next;
@@ -1849,7 +1836,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
part->flag &= ~PART_HAIR_REGROW; /* this was a deprecated flag before */
- part->kink_amp_clump = 1.f; /* keep old files looking similar */
+ part->kink_amp_clump = 1.0f; /* keep old files looking similar */
}
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index a7c5d7b933c..c33f2a8cad5 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -61,11 +61,12 @@
#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_texture.h"
#include "BKE_tracking.h"
+#include "SEQ_sequencer.h"
+
#ifdef WITH_FFMPEG
# include "BKE_writeffmpeg.h"
#endif
@@ -2065,10 +2066,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (srl->freestyleConfig.mode == 0) {
srl->freestyleConfig.mode = FREESTYLE_CONTROL_EDITOR_MODE;
}
- if (srl->freestyleConfig.raycasting_algorithm ==
- FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE ||
- srl->freestyleConfig.raycasting_algorithm ==
- FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL) {
+ if (ELEM(srl->freestyleConfig.raycasting_algorithm,
+ FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE,
+ FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL)) {
srl->freestyleConfig.raycasting_algorithm = 0; /* deprecated */
srl->freestyleConfig.flags |= FREESTYLE_CULLING;
}
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 2452ac43bd4..41e46f8f0a0 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -63,9 +63,10 @@
#include "BKE_node.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
-#include "BKE_sequencer.h"
#include "BKE_tracking.h"
+#include "SEQ_sequencer.h"
+
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 8e082f1c0f9..c2bedc54690 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -93,11 +93,12 @@
#include "BKE_report.h"
#include "BKE_rigidbody.h"
#include "BKE_screen.h"
-#include "BKE_sequencer.h"
#include "BKE_studiolight.h"
#include "BKE_unit.h"
#include "BKE_workspace.h"
+#include "SEQ_sequencer.h"
+
/* Only for IMB_BlendMode */
#include "IMB_imbuf.h"
@@ -2099,7 +2100,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 8)) {
/* Blender Internal removal */
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- if (STREQ(scene->r.engine, "BLENDER_RENDER") || STREQ(scene->r.engine, "BLENDER_GAME")) {
+ if (STR_ELEM(scene->r.engine, "BLENDER_RENDER", "BLENDER_GAME")) {
BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
}
@@ -3419,7 +3420,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
case SPACE_OUTLINER: {
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
space_outliner->filter &= ~(SO_FILTER_UNUSED_1 | SO_FILTER_UNUSED_5 |
- SO_FILTER_UNUSED_12);
+ SO_FILTER_OB_STATE_SELECTABLE);
space_outliner->storeflag &= ~(SO_TREESTORE_UNUSED_1);
break;
}
@@ -3493,7 +3494,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
ob->flag &= ~(OB_FLAG_UNUSED_11 | OB_FLAG_UNUSED_12);
- ob->transflag &= ~(OB_TRANSFLAG_UNUSED_0 | OB_TRANSFLAG_UNUSED_1);
+ ob->transflag &= ~(OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK | OB_TRANSFLAG_UNUSED_1);
ob->shapeflag &= ~OB_SHAPE_FLAG_UNUSED_1;
}
@@ -3662,8 +3663,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- ob->transflag &= ~(OB_TRANSFLAG_UNUSED_0 | OB_TRANSFLAG_UNUSED_1 | OB_TRANSFLAG_UNUSED_3 |
- OB_TRANSFLAG_UNUSED_6 | OB_TRANSFLAG_UNUSED_12);
+ ob->transflag &= ~(OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK | OB_TRANSFLAG_UNUSED_1 |
+ OB_TRANSFLAG_UNUSED_3 | OB_TRANSFLAG_UNUSED_6 | OB_TRANSFLAG_UNUSED_12);
ob->nlaflag &= ~(OB_ADS_UNUSED_1 | OB_ADS_UNUSED_2);
}
@@ -4078,8 +4079,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (STREQ(view_settings->view_transform, "Default")) {
STRNCPY(view_settings->view_transform, "Standard");
}
- else if (STREQ(view_settings->view_transform, "RRT") ||
- STREQ(view_settings->view_transform, "Film")) {
+ else if (STR_ELEM(view_settings->view_transform, "RRT", "Film")) {
STRNCPY(view_settings->view_transform, "Filmic");
}
else if (STREQ(view_settings->view_transform, "Log")) {
@@ -4871,7 +4871,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
gps->fill_opacity_fac = 1.0f;
/* Calc geometry data because in old versions this data was not saved. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
srgb_to_linearrgb_v4(gps->vert_color_fill, gps->vert_color_fill);
int i;
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index eeb0dd336a3..ec39113c4d0 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -44,25 +44,171 @@
#include "DNA_rigidbody_types.h"
#include "DNA_screen_types.h"
#include "DNA_shader_fx_types.h"
+#include "DNA_space_types.h"
+#include "DNA_tracking_types.h"
#include "DNA_workspace_types.h"
#include "BKE_animsys.h"
#include "BKE_collection.h"
#include "BKE_colortools.h"
+#include "BKE_fcurve.h"
#include "BKE_gpencil.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
+#include "BKE_multires.h"
#include "BKE_node.h"
#include "MEM_guardedalloc.h"
+#include "RNA_access.h"
+
+#include "SEQ_sequencer.h"
+
#include "BLO_readfile.h"
#include "readfile.h"
/* Make preferences read-only, use versioning_userdef.c. */
#define U (*((const UserDef *)&U))
+/* image_size is width or height depending what RNA property is converted - X or Y. */
+static void seq_convert_transform_animation(const Scene *scene,
+ const char *path,
+ const int image_size)
+{
+ if (scene->adt == NULL || scene->adt->action == NULL) {
+ return;
+ }
+
+ FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
+ if (fcu != NULL && !BKE_fcurve_is_empty(fcu)) {
+ BezTriple *bezt = fcu->bezt;
+ for (int i = 0; i < fcu->totvert; i++, bezt++) {
+ /* Same math as with old_image_center_*, but simplified. */
+ bezt->vec[1][1] = image_size / 2 + bezt->vec[1][1] - scene->r.xsch / 2;
+ }
+ }
+}
+
+static void seq_convert_transform_crop(const Scene *scene,
+ Sequence *seq,
+ const eSpaceSeq_Proxy_RenderSize render_size)
+{
+ StripCrop *c = seq->strip->crop;
+ StripTransform *t = seq->strip->transform;
+ int old_image_center_x = scene->r.xsch / 2;
+ int old_image_center_y = scene->r.ysch / 2;
+ int image_size_x = scene->r.xsch;
+ int image_size_y = scene->r.ysch;
+
+ /* Hardcoded legacy bit-flags which has been removed. */
+ const uint32_t use_transform_flag = (1 << 16);
+ const uint32_t use_crop_flag = (1 << 17);
+
+ const StripElem *s_elem = SEQ_render_give_stripelem(seq, seq->start);
+ if (s_elem != NULL) {
+ image_size_x = s_elem->orig_width;
+ image_size_y = s_elem->orig_height;
+
+ if (SEQ_can_use_proxy(seq, SEQ_rendersize_to_proxysize(render_size))) {
+ image_size_x /= SEQ_rendersize_to_scale_factor(render_size);
+ image_size_y /= SEQ_rendersize_to_scale_factor(render_size);
+ }
+ }
+
+ /* Default scale. */
+ if (t->scale_x == 0.0f && t->scale_y == 0.0f) {
+ t->scale_x = 1.0f;
+ t->scale_y = 1.0f;
+ }
+
+ /* Clear crop if it was unused. This must happen before converting values. */
+ if ((seq->flag & use_crop_flag) == 0) {
+ c->bottom = c->top = c->left = c->right = 0;
+ }
+
+ if ((seq->flag & use_transform_flag) == 0) {
+ t->xofs = t->yofs = 0;
+
+ /* Reverse scale to fit for strips not using offset. */
+ float project_aspect = (float)scene->r.xsch / (float)scene->r.ysch;
+ float image_aspect = (float)image_size_x / (float)image_size_y;
+ if (project_aspect > image_aspect) {
+ t->scale_x = project_aspect / image_aspect;
+ }
+ else {
+ t->scale_y = image_aspect / project_aspect;
+ }
+ }
+
+ if ((seq->flag & use_crop_flag) != 0 && (seq->flag & use_transform_flag) == 0) {
+ /* Calculate image offset. */
+ float s_x = scene->r.xsch / image_size_x;
+ float s_y = scene->r.ysch / image_size_y;
+ old_image_center_x += c->right * s_x - c->left * s_x;
+ old_image_center_y += c->top * s_y - c->bottom * s_y;
+
+ /* Convert crop to scale. */
+ int cropped_image_size_x = image_size_x - c->right - c->left;
+ int cropped_image_size_y = image_size_y - c->top - c->bottom;
+ c->bottom = c->top = c->left = c->right = 0;
+ t->scale_x *= (float)image_size_x / (float)cropped_image_size_x;
+ t->scale_y *= (float)image_size_y / (float)cropped_image_size_y;
+ }
+
+ if ((seq->flag & use_transform_flag) != 0) {
+ /* Convert image offset. */
+ old_image_center_x = image_size_x / 2 - c->left + t->xofs;
+ old_image_center_y = image_size_y / 2 - c->bottom + t->yofs;
+
+ /* Preserve original image size. */
+ t->scale_x = t->scale_y = MAX2((float)image_size_x / (float)scene->r.xsch,
+ (float)image_size_y / (float)scene->r.ysch);
+
+ /* Convert crop. */
+ if ((seq->flag & use_crop_flag) != 0) {
+ c->top /= t->scale_x;
+ c->bottom /= t->scale_x;
+ c->left /= t->scale_x;
+ c->right /= t->scale_x;
+ }
+ }
+
+ t->xofs = old_image_center_x - scene->r.xsch / 2;
+ t->yofs = old_image_center_y - scene->r.ysch / 2;
+
+ /* Convert offset animation, but only if crop is not used. */
+ if ((seq->flag & use_transform_flag) != 0 && (seq->flag & use_crop_flag) == 0) {
+ char name_esc[(sizeof(seq->name) - 2) * 2], *path;
+ BLI_strescape(name_esc, seq->name + 2, sizeof(name_esc));
+
+ path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_x", name_esc);
+ seq_convert_transform_animation(scene, path, image_size_x);
+ MEM_freeN(path);
+ path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_y", name_esc);
+ seq_convert_transform_animation(scene, path, image_size_y);
+ MEM_freeN(path);
+ }
+
+ seq->flag &= ~use_transform_flag;
+ seq->flag &= ~use_crop_flag;
+}
+
+static void seq_convert_transform_crop_lb(const Scene *scene,
+ const ListBase *lb,
+ const eSpaceSeq_Proxy_RenderSize render_size)
+{
+
+ LISTBASE_FOREACH (Sequence *, seq, lb) {
+ if (seq->type != SEQ_TYPE_SOUND_RAM) {
+ seq_convert_transform_crop(scene, seq, render_size);
+ }
+ if (seq->type == SEQ_TYPE_META) {
+ seq_convert_transform_crop_lb(scene, &seq->seqbase, render_size);
+ }
+ }
+}
+
void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
{
if (!MAIN_VERSION_ATLEAST(bmain, 290, 1)) {
@@ -275,6 +421,46 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
}
}
+ /* Convert all Multires displacement to Catmull-Clark subdivision limit surface. */
+ if (!MAIN_VERSION_ATLEAST(bmain, 292, 1)) {
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Multires) {
+ MultiresModifierData *mmd = (MultiresModifierData *)md;
+ if (mmd->simple) {
+ multires_do_versions_simple_to_catmull_clark(ob, mmd);
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 292, 2)) {
+
+ eSpaceSeq_Proxy_RenderSize render_size = 100;
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ switch (sl->spacetype) {
+ case SPACE_SEQ: {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ render_size = sseq->render_size;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ if (scene->ed != NULL) {
+ seq_convert_transform_crop_lb(scene, &scene->ed->seqbase, render_size);
+ }
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
@@ -881,6 +1067,20 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
part->phystype = PART_PHYS_NO;
}
}
+ /* Init grease pencil default curve resolution. */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "int", "curve_edit_resolution")) {
+ LISTBASE_FOREACH (bGPdata *, gpd, &bmain->gpencils) {
+ gpd->curve_edit_resolution = GP_DEFAULT_CURVE_RESOLUTION;
+ gpd->flag |= GP_DATA_CURVE_ADAPTIVE_RESOLUTION;
+ }
+ }
+ /* Init grease pencil curve editing error threshold. */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "curve_edit_threshold")) {
+ LISTBASE_FOREACH (bGPdata *, gpd, &bmain->gpencils) {
+ gpd->curve_edit_threshold = GP_DEFAULT_CURVE_ERROR;
+ gpd->curve_edit_corner_angle = GP_DEFAULT_CURVE_EDIT_CORNER_ANGLE;
+ }
+ }
}
if (!MAIN_VERSION_ATLEAST(bmain, 291, 9)) {
@@ -913,6 +1113,35 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 292, 1)) {
+ {
+ const int LEGACY_REFINE_RADIAL_DISTORTION_K1 = (1 << 2);
+
+ LISTBASE_FOREACH (MovieClip *, clip, &bmain->movieclips) {
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingSettings *settings = &tracking->settings;
+ int new_refine_camera_intrinsics = 0;
+
+ if (settings->refine_camera_intrinsics & REFINE_FOCAL_LENGTH) {
+ new_refine_camera_intrinsics |= REFINE_FOCAL_LENGTH;
+ }
+
+ if (settings->refine_camera_intrinsics & REFINE_PRINCIPAL_POINT) {
+ new_refine_camera_intrinsics |= REFINE_PRINCIPAL_POINT;
+ }
+
+ /* The end goal is to enable radial distortion refinement if either K1 or K2 were set for
+ * refinement. It is enough to only check for L1 it was not possible to refine K2 without
+ * K1. */
+ if (settings->refine_camera_intrinsics & LEGACY_REFINE_RADIAL_DISTORTION_K1) {
+ new_refine_camera_intrinsics |= REFINE_RADIAL_DISTORTION;
+ }
+
+ settings->refine_camera_intrinsics = new_refine_camera_intrinsics;
+ }
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
@@ -924,5 +1153,18 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
{
/* Keep this block, even when empty. */
+ /* Initialize the opacity of the overlay wireframe */
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "wireframe_opacity")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.wireframe_opacity = 1.0f;
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c
index 26329fca6fa..19e392734f0 100644
--- a/source/blender/blenloader/intern/versioning_cycles.c
+++ b/source/blender/blenloader/intern/versioning_cycles.c
@@ -1197,8 +1197,7 @@ static void update_voronoi_node_square_distance(bNodeTree *ntree)
NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage;
bNodeSocket *sockDistance = nodeFindSocket(node, SOCK_OUT, "Distance");
if (tex->distance == SHD_VORONOI_EUCLIDEAN &&
- (tex->feature == SHD_VORONOI_F1 || tex->feature == SHD_VORONOI_F2) &&
- socket_is_used(sockDistance)) {
+ (ELEM(tex->feature, SHD_VORONOI_F1, SHD_VORONOI_F2)) && socket_is_used(sockDistance)) {
bNode *multiplyNode = nodeAddStaticNode(NULL, ntree, SH_NODE_MATH);
multiplyNode->custom1 = NODE_MATH_MULTIPLY;
multiplyNode->locx = node->locx + node->width + 20.0f;
@@ -1237,7 +1236,7 @@ static void update_noise_and_wave_distortion(bNodeTree *ntree)
bool need_update = false;
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
- if (node->type == SH_NODE_TEX_NOISE || node->type == SH_NODE_TEX_WAVE) {
+ if (ELEM(node->type, SH_NODE_TEX_NOISE, SH_NODE_TEX_WAVE)) {
bNodeSocket *sockDistortion = nodeFindSocket(node, SOCK_IN, "Distortion");
float *distortion = cycles_node_socket_float_value(sockDistortion);
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 4acf98cc58b..d654a0e30bd 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -75,9 +75,11 @@
#include "BKE_main.h" /* for Main */
#include "BKE_mesh.h" /* for ME_ defines (patching) */
#include "BKE_modifier.h"
+#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
-#include "BKE_sequencer.h"
+
+#include "SEQ_sequencer.h"
#include "NOD_socket.h"
@@ -460,20 +462,6 @@ static void do_version_constraints_245(ListBase *lb)
}
}
-PartEff *blo_do_version_give_parteff_245(Object *ob)
-{
- PartEff *paf;
-
- paf = ob->effect.first;
- while (paf) {
- if (paf->type == EFF_PARTICLE) {
- return paf;
- }
- paf = paf->next;
- }
- return NULL;
-}
-
/* NOTE: this version patch is intended for versions < 2.52.2,
* but was initially introduced in 2.27 already. */
void blo_do_version_old_trackto_to_constraints(Object *ob)
@@ -717,7 +705,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Object *ob = bmain->objects.first;
PartEff *paf;
while (ob) {
- paf = blo_do_version_give_parteff_245(ob);
+ paf = BKE_object_do_version_give_parteff_245(ob);
if (paf) {
if (paf->staticstep == 0) {
paf->staticstep = 5;
@@ -1252,7 +1240,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
ed = sce->ed;
if (ed) {
SEQ_ALL_BEGIN (sce->ed, seq) {
- if (seq->type == SEQ_TYPE_IMAGE || seq->type == SEQ_TYPE_MOVIE) {
+ if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE)) {
seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
}
}
@@ -1475,7 +1463,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- paf = blo_do_version_give_parteff_245(ob);
+ paf = BKE_object_do_version_give_parteff_245(ob);
if (paf) {
if (paf->disp == 0) {
paf->disp = 100;
@@ -1959,7 +1947,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Light *la;
Material *ma;
ParticleSettings *part;
- Mesh *me;
bNodeTree *ntree;
Tex *tex;
ModifierData *md;
@@ -2074,23 +2061,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- /* Copy over old per-level multires vertex data
- * into a single vertex array in struct Multires */
- for (me = bmain->meshes.first; me; me = me->id.next) {
- if (me->mr && !me->mr->verts) {
- MultiresLevel *lvl = me->mr->levels.last;
- if (lvl) {
- me->mr->verts = lvl->verts;
- lvl->verts = NULL;
- /* Don't need the other vert arrays */
- for (lvl = lvl->prev; lvl; lvl = lvl->prev) {
- MEM_freeN(lvl->verts);
- lvl->verts = NULL;
- }
- }
- }
- }
-
if (bmain->versionfile != 245 || bmain->subversionfile < 1) {
for (la = bmain->lights.first; la; la = la->id.next) {
la->falloff_type = LA_FALLOFF_INVLINEAR;
@@ -2250,7 +2220,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
/* convert old particles to new system */
- if ((paf = blo_do_version_give_parteff_245(ob))) {
+ if ((paf = BKE_object_do_version_give_parteff_245(ob))) {
ParticleSystem *psys;
ModifierData *md;
ParticleSystemModifierData *psmd;
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index f76fac23e96..5aa0e46aa46 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -803,6 +803,18 @@ void blo_do_versions_userdef(UserDef *userdef)
}
}
+ if (!USER_VERSION_ATLEAST(292, 3)) {
+ if (userdef->pixelsize == 0.0f) {
+ userdef->pixelsize = 1.0f;
+ }
+ /* Clear old userdef flag for "Camera Parent Lock". */
+ userdef->uiflag &= ~USER_UIFLAG_UNUSED_3;
+ }
+
+ if (!USER_VERSION_ATLEAST(292, 4)) {
+ userdef->animation_flag = USER_ANIM_SHOW_CHANNEL_GROUP_COLORS;
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
@@ -816,10 +828,6 @@ void blo_do_versions_userdef(UserDef *userdef)
/* Keep this block, even when empty. */
}
- if (userdef->pixelsize == 0.0f) {
- userdef->pixelsize = 1.0f;
- }
-
LISTBASE_FOREACH (bTheme *, btheme, &userdef->themes) {
do_versions_theme(userdef, btheme);
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index a37ec2d9f0a..11fe240620a 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -93,71 +93,27 @@
/* allow writefile to use deprecated functionality (for forward compatibility code) */
#define DNA_DEPRECATED_ALLOW
-#include "DNA_anim_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_cachefile_types.h"
-#include "DNA_cloth_types.h"
-#include "DNA_collection_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_curveprofile_types.h"
-#include "DNA_dynamicpaint_types.h"
#include "DNA_fileglobal_types.h"
-#include "DNA_fluid_types.h"
#include "DNA_genfile.h"
-#include "DNA_lightprobe_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_movieclip_types.h"
-#include "DNA_object_force_types.h"
-#include "DNA_object_types.h"
-#include "DNA_particle_types.h"
-#include "DNA_pointcache_types.h"
-#include "DNA_rigidbody_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
#include "DNA_sdna_types.h"
-#include "DNA_sequence_types.h"
-#include "DNA_shader_fx_types.h"
-#include "DNA_space_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_windowmanager_types.h"
-#include "DNA_workspace_types.h"
#include "BLI_bitmap.h"
#include "BLI_blenlib.h"
#include "BLI_mempool.h"
#include "MEM_guardedalloc.h" /* MEM_freeN */
-#include "BKE_action.h"
-#include "BKE_anim_data.h"
-#include "BKE_animsys.h"
-#include "BKE_armature.h"
#include "BKE_blender_version.h"
#include "BKE_bpath.h"
-#include "BKE_collection.h"
-#include "BKE_colortools.h"
-#include "BKE_constraint.h"
-#include "BKE_curveprofile.h"
-#include "BKE_deform.h"
-#include "BKE_fcurve.h"
-#include "BKE_fcurve_driver.h"
#include "BKE_global.h" /* for G */
-#include "BKE_gpencil_modifier.h"
-#include "BKE_icons.h"
#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_lib_override.h"
#include "BKE_main.h"
-#include "BKE_modifier.h"
#include "BKE_node.h"
-#include "BKE_object.h"
#include "BKE_packedFile.h"
-#include "BKE_pointcache.h"
#include "BKE_report.h"
-#include "BKE_sequencer.h"
-#include "BKE_shader_fx.h"
-#include "BKE_subsurf.h"
#include "BKE_workspace.h"
#include "BLO_blend_defs.h"
@@ -804,1267 +760,6 @@ static void write_userdef(BlendWriter *writer, const UserDef *userdef)
}
}
-static void write_boid_state(BlendWriter *writer, BoidState *state)
-{
- BLO_write_struct(writer, BoidState, state);
-
- LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
- switch (rule->type) {
- case eBoidRuleType_Goal:
- case eBoidRuleType_Avoid:
- BLO_write_struct(writer, BoidRuleGoalAvoid, rule);
- break;
- case eBoidRuleType_AvoidCollision:
- BLO_write_struct(writer, BoidRuleAvoidCollision, rule);
- break;
- case eBoidRuleType_FollowLeader:
- BLO_write_struct(writer, BoidRuleFollowLeader, rule);
- break;
- case eBoidRuleType_AverageSpeed:
- BLO_write_struct(writer, BoidRuleAverageSpeed, rule);
- break;
- case eBoidRuleType_Fight:
- BLO_write_struct(writer, BoidRuleFight, rule);
- break;
- default:
- BLO_write_struct(writer, BoidRule, rule);
- break;
- }
- }
-#if 0
- BoidCondition *cond = state->conditions.first;
- for (; cond; cond = cond->next) {
- BLO_write_struct(writer, BoidCondition, cond);
- }
-#endif
-}
-
-/* update this also to readfile.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:
-};
-static const char *ptcache_extra_struct[] = {
- "",
- "ParticleSpring",
- "vec3f",
-};
-static void write_pointcaches(BlendWriter *writer, ListBase *ptcaches)
-{
- LISTBASE_FOREACH (PointCache *, cache, ptcaches) {
- BLO_write_struct(writer, PointCache, cache);
-
- if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
- LISTBASE_FOREACH (PTCacheMem *, pm, &cache->mem_cache) {
- BLO_write_struct(writer, PTCacheMem, pm);
-
- for (int i = 0; i < BPHYS_TOT_DATA; i++) {
- if (pm->data[i] && pm->data_types & (1 << i)) {
- if (ptcache_data_struct[i][0] == '\0') {
- BLO_write_raw(writer, MEM_allocN_len(pm->data[i]), pm->data[i]);
- }
- else {
- BLO_write_struct_array_by_name(
- writer, ptcache_data_struct[i], pm->totpoint, pm->data[i]);
- }
- }
- }
-
- LISTBASE_FOREACH (PTCacheExtra *, extra, &pm->extradata) {
- if (ptcache_extra_struct[extra->type][0] == '\0') {
- continue;
- }
- BLO_write_struct(writer, PTCacheExtra, extra);
- BLO_write_struct_array_by_name(
- writer, ptcache_extra_struct[extra->type], extra->totdata, extra->data);
- }
- }
- }
- }
-}
-
-static void write_particlesettings(BlendWriter *writer,
- ParticleSettings *part,
- const void *id_address)
-{
- if (part->id.us > 0 || BLO_write_is_undo(writer)) {
- /* write LibData */
- BLO_write_id_struct(writer, ParticleSettings, id_address, &part->id);
- BKE_id_blend_write(writer, &part->id);
-
- if (part->adt) {
- BKE_animdata_blend_write(writer, part->adt);
- }
- BLO_write_struct(writer, PartDeflect, part->pd);
- BLO_write_struct(writer, PartDeflect, part->pd2);
- BLO_write_struct(writer, EffectorWeights, part->effector_weights);
-
- if (part->clumpcurve) {
- BKE_curvemapping_blend_write(writer, part->clumpcurve);
- }
- if (part->roughcurve) {
- BKE_curvemapping_blend_write(writer, part->roughcurve);
- }
- if (part->twistcurve) {
- BKE_curvemapping_blend_write(writer, part->twistcurve);
- }
-
- LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
- /* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */
- if (dw->ob != NULL) {
- dw->index = 0;
- if (part->instance_collection) { /* can be NULL if lining fails or set to None */
- FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object) {
- if (object == dw->ob) {
- break;
- }
- dw->index++;
- }
- FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
- }
- }
- BLO_write_struct(writer, ParticleDupliWeight, dw);
- }
-
- if (part->boids && part->phystype == PART_PHYS_BOIDS) {
- BLO_write_struct(writer, BoidSettings, part->boids);
-
- LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
- write_boid_state(writer, state);
- }
- }
- if (part->fluid && part->phystype == PART_PHYS_FLUID) {
- BLO_write_struct(writer, SPHFluidSettings, part->fluid);
- }
-
- for (int a = 0; a < MAX_MTEX; a++) {
- if (part->mtex[a]) {
- BLO_write_struct(writer, MTex, part->mtex[a]);
- }
- }
- }
-}
-
-static void write_particlesystems(BlendWriter *writer, ListBase *particles)
-{
- LISTBASE_FOREACH (ParticleSystem *, psys, particles) {
- BLO_write_struct(writer, ParticleSystem, psys);
-
- if (psys->particles) {
- BLO_write_struct_array(writer, ParticleData, psys->totpart, psys->particles);
-
- if (psys->particles->hair) {
- ParticleData *pa = psys->particles;
-
- for (int a = 0; a < psys->totpart; a++, pa++) {
- BLO_write_struct_array(writer, HairKey, pa->totkey, pa->hair);
- }
- }
-
- if (psys->particles->boid && (psys->part->phystype == PART_PHYS_BOIDS)) {
- BLO_write_struct_array(writer, BoidParticle, psys->totpart, psys->particles->boid);
- }
-
- if (psys->part->fluid && (psys->part->phystype == PART_PHYS_FLUID) &&
- (psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS)) {
- BLO_write_struct_array(
- writer, ParticleSpring, psys->tot_fluidsprings, psys->fluid_springs);
- }
- }
- LISTBASE_FOREACH (ParticleTarget *, pt, &psys->targets) {
- BLO_write_struct(writer, ParticleTarget, pt);
- }
-
- if (psys->child) {
- BLO_write_struct_array(writer, ChildParticle, psys->totchild, psys->child);
- }
-
- if (psys->clmd) {
- BLO_write_struct(writer, ClothModifierData, psys->clmd);
- BLO_write_struct(writer, ClothSimSettings, psys->clmd->sim_parms);
- BLO_write_struct(writer, ClothCollSettings, psys->clmd->coll_parms);
- }
-
- write_pointcaches(writer, &psys->ptcaches);
- }
-}
-
-static void write_motionpath(BlendWriter *writer, bMotionPath *mpath)
-{
- /* sanity checks */
- if (mpath == NULL) {
- return;
- }
-
- /* firstly, just write the motionpath struct */
- BLO_write_struct(writer, bMotionPath, mpath);
-
- /* now write the array of data */
- BLO_write_struct_array(writer, bMotionPathVert, mpath->length, mpath->points);
-}
-
-static void write_constraints(BlendWriter *writer, ListBase *conlist)
-{
- LISTBASE_FOREACH (bConstraint *, con, conlist) {
- const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
-
- /* Write the specific data */
- if (cti && con->data) {
- /* firstly, just write the plain con->data struct */
- BLO_write_struct_by_name(writer, cti->structName, con->data);
-
- /* do any constraint specific stuff */
- switch (con->type) {
- case CONSTRAINT_TYPE_PYTHON: {
- bPythonConstraint *data = con->data;
-
- /* write targets */
- LISTBASE_FOREACH (bConstraintTarget *, ct, &data->targets) {
- BLO_write_struct(writer, bConstraintTarget, ct);
- }
-
- /* Write ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
- IDP_BlendWrite(writer, data->prop);
-
- break;
- }
- case CONSTRAINT_TYPE_ARMATURE: {
- bArmatureConstraint *data = con->data;
-
- /* write targets */
- LISTBASE_FOREACH (bConstraintTarget *, ct, &data->targets) {
- BLO_write_struct(writer, bConstraintTarget, ct);
- }
-
- break;
- }
- case CONSTRAINT_TYPE_SPLINEIK: {
- bSplineIKConstraint *data = con->data;
-
- /* write points array */
- BLO_write_float_array(writer, data->numpoints, data->points);
-
- break;
- }
- }
- }
-
- /* Write the constraint */
- BLO_write_struct(writer, bConstraint, con);
- }
-}
-
-static void write_pose(BlendWriter *writer, bPose *pose, bArmature *arm)
-{
- /* Write each channel */
- if (pose == NULL) {
- return;
- }
-
- BLI_assert(arm != NULL);
-
- /* Write channels */
- LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
- /* Write ID Properties -- and copy this comment EXACTLY for easy finding
- * of library blocks that implement this.*/
- if (chan->prop) {
- IDP_BlendWrite(writer, chan->prop);
- }
-
- write_constraints(writer, &chan->constraints);
-
- write_motionpath(writer, chan->mpath);
-
- /* Prevent crashes with autosave,
- * when a bone duplicated in edit-mode has not yet been assigned to its pose-channel.
- * Also needed with memundo, in some cases we can store a step before pose has been
- * properly rebuilt from previous undo step. */
- Bone *bone = (pose->flag & POSE_RECALC) ? BKE_armature_find_bone_name(arm, chan->name) :
- chan->bone;
- if (bone != NULL) {
- /* gets restored on read, for library armatures */
- chan->selectflag = bone->flag & BONE_SELECTED;
- }
-
- BLO_write_struct(writer, bPoseChannel, chan);
- }
-
- /* Write groups */
- LISTBASE_FOREACH (bActionGroup *, grp, &pose->agroups) {
- BLO_write_struct(writer, bActionGroup, grp);
- }
-
- /* write IK param */
- if (pose->ikparam) {
- const char *structname = BKE_pose_ikparam_get_name(pose);
- if (structname) {
- BLO_write_struct_by_name(writer, structname, pose->ikparam);
- }
- }
-
- /* Write this pose */
- BLO_write_struct(writer, bPose, pose);
-}
-
-static void write_defgroups(BlendWriter *writer, ListBase *defbase)
-{
- LISTBASE_FOREACH (bDeformGroup *, defgroup, defbase) {
- BLO_write_struct(writer, bDeformGroup, defgroup);
- }
-}
-
-static void write_fmaps(BlendWriter *writer, ListBase *fbase)
-{
- LISTBASE_FOREACH (bFaceMap *, fmap, fbase) {
- BLO_write_struct(writer, bFaceMap, fmap);
- }
-}
-
-static void write_modifiers(BlendWriter *writer, ListBase *modbase)
-{
- if (modbase == NULL) {
- return;
- }
-
- LISTBASE_FOREACH (ModifierData *, md, modbase) {
- const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
- if (mti == NULL) {
- return;
- }
-
- BLO_write_struct_by_name(writer, mti->structName, md);
-
- if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *)md;
-
- BLO_write_struct(writer, ClothSimSettings, clmd->sim_parms);
- BLO_write_struct(writer, ClothCollSettings, clmd->coll_parms);
- BLO_write_struct(writer, EffectorWeights, clmd->sim_parms->effector_weights);
- write_pointcaches(writer, &clmd->ptcaches);
- }
- else if (md->type == eModifierType_Fluid) {
- FluidModifierData *fmd = (FluidModifierData *)md;
-
- if (fmd->type & MOD_FLUID_TYPE_DOMAIN) {
- BLO_write_struct(writer, FluidDomainSettings, fmd->domain);
-
- if (fmd->domain) {
- write_pointcaches(writer, &(fmd->domain->ptcaches[0]));
-
- /* create fake pointcache so that old blender versions can read it */
- fmd->domain->point_cache[1] = BKE_ptcache_add(&fmd->domain->ptcaches[1]);
- fmd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE | PTCACHE_FAKE_SMOKE;
- fmd->domain->point_cache[1]->step = 1;
-
- write_pointcaches(writer, &(fmd->domain->ptcaches[1]));
-
- if (fmd->domain->coba) {
- BLO_write_struct(writer, ColorBand, fmd->domain->coba);
- }
-
- /* cleanup the fake pointcache */
- BKE_ptcache_free_list(&fmd->domain->ptcaches[1]);
- fmd->domain->point_cache[1] = NULL;
-
- BLO_write_struct(writer, EffectorWeights, fmd->domain->effector_weights);
- }
- }
- else if (fmd->type & MOD_FLUID_TYPE_FLOW) {
- BLO_write_struct(writer, FluidFlowSettings, fmd->flow);
- }
- else if (fmd->type & MOD_FLUID_TYPE_EFFEC) {
- BLO_write_struct(writer, FluidEffectorSettings, fmd->effector);
- }
- }
- else if (md->type == eModifierType_Fluidsim) {
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
-
- BLO_write_struct(writer, FluidsimSettings, fluidmd->fss);
- }
- else if (md->type == eModifierType_DynamicPaint) {
- DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
-
- if (pmd->canvas) {
- BLO_write_struct(writer, DynamicPaintCanvasSettings, pmd->canvas);
-
- /* write surfaces */
- LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
- BLO_write_struct(writer, DynamicPaintSurface, surface);
- }
- /* write caches and effector weights */
- LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
- write_pointcaches(writer, &(surface->ptcaches));
-
- BLO_write_struct(writer, EffectorWeights, surface->effector_weights);
- }
- }
- if (pmd->brush) {
- BLO_write_struct(writer, DynamicPaintBrushSettings, pmd->brush);
- BLO_write_struct(writer, ColorBand, pmd->brush->paint_ramp);
- BLO_write_struct(writer, ColorBand, pmd->brush->vel_ramp);
- }
- }
- else if (md->type == eModifierType_Collision) {
-
-#if 0
- CollisionModifierData *collmd = (CollisionModifierData *)md;
- // TODO: CollisionModifier should use pointcache
- // + have proper reset events before enabling this
- writestruct(wd, DATA, MVert, collmd->numverts, collmd->x);
- writestruct(wd, DATA, MVert, collmd->numverts, collmd->xnew);
- writestruct(wd, DATA, MFace, collmd->numfaces, collmd->mfaces);
-#endif
- }
-
- if (mti->blendWrite != NULL) {
- mti->blendWrite(writer, md);
- }
- }
-}
-
-static void write_gpencil_modifiers(BlendWriter *writer, ListBase *modbase)
-{
- if (modbase == NULL) {
- return;
- }
-
- LISTBASE_FOREACH (GpencilModifierData *, md, modbase) {
- const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
- if (mti == NULL) {
- return;
- }
-
- BLO_write_struct_by_name(writer, mti->struct_name, md);
-
- if (md->type == eGpencilModifierType_Thick) {
- ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
-
- if (gpmd->curve_thickness) {
- BKE_curvemapping_blend_write(writer, gpmd->curve_thickness);
- }
- }
- else if (md->type == eGpencilModifierType_Noise) {
- NoiseGpencilModifierData *gpmd = (NoiseGpencilModifierData *)md;
-
- if (gpmd->curve_intensity) {
- BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
- }
- }
- else if (md->type == eGpencilModifierType_Hook) {
- HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md;
-
- if (gpmd->curfalloff) {
- BKE_curvemapping_blend_write(writer, gpmd->curfalloff);
- }
- }
- else if (md->type == eGpencilModifierType_Tint) {
- TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
- if (gpmd->colorband) {
- BLO_write_struct(writer, ColorBand, gpmd->colorband);
- }
- if (gpmd->curve_intensity) {
- BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
- }
- }
- else if (md->type == eGpencilModifierType_Smooth) {
- SmoothGpencilModifierData *gpmd = (SmoothGpencilModifierData *)md;
- if (gpmd->curve_intensity) {
- BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
- }
- }
- else if (md->type == eGpencilModifierType_Color) {
- ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md;
- if (gpmd->curve_intensity) {
- BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
- }
- }
- else if (md->type == eGpencilModifierType_Opacity) {
- OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
- if (gpmd->curve_intensity) {
- BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
- }
- }
- }
-}
-
-static void write_shaderfxs(BlendWriter *writer, ListBase *fxbase)
-{
- if (fxbase == NULL) {
- return;
- }
-
- LISTBASE_FOREACH (ShaderFxData *, fx, fxbase) {
- const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx->type);
- if (fxi == NULL) {
- return;
- }
-
- BLO_write_struct_by_name(writer, fxi->struct_name, fx);
- }
-}
-
-static void write_object(BlendWriter *writer, Object *ob, const void *id_address)
-{
- const bool is_undo = BLO_write_is_undo(writer);
- if (ob->id.us > 0 || is_undo) {
- /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
- BKE_object_runtime_reset(ob);
-
- if (is_undo) {
- /* For undo we stay in object mode during undo presses, so keep edit-mode disabled on save as
- * well, can help reducing false detection of changed data-blocks. */
- ob->mode &= ~OB_MODE_EDIT;
- }
-
- /* write LibData */
- BLO_write_id_struct(writer, Object, id_address, &ob->id);
- BKE_id_blend_write(writer, &ob->id);
-
- if (ob->adt) {
- BKE_animdata_blend_write(writer, ob->adt);
- }
-
- /* direct data */
- BLO_write_pointer_array(writer, ob->totcol, ob->mat);
- BLO_write_raw(writer, sizeof(char) * ob->totcol, ob->matbits);
-
- bArmature *arm = NULL;
- if (ob->type == OB_ARMATURE) {
- arm = ob->data;
- if (arm && ob->pose && arm->act_bone) {
- BLI_strncpy(
- ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
- }
- }
-
- write_pose(writer, ob->pose, arm);
- write_defgroups(writer, &ob->defbase);
- write_fmaps(writer, &ob->fmaps);
- write_constraints(writer, &ob->constraints);
- write_motionpath(writer, ob->mpath);
-
- BLO_write_struct(writer, PartDeflect, ob->pd);
- if (ob->soft) {
- /* Set deprecated pointers to prevent crashes of older Blenders */
- ob->soft->pointcache = ob->soft->shared->pointcache;
- ob->soft->ptcaches = ob->soft->shared->ptcaches;
- BLO_write_struct(writer, SoftBody, ob->soft);
- BLO_write_struct(writer, SoftBody_Shared, ob->soft->shared);
- write_pointcaches(writer, &(ob->soft->shared->ptcaches));
- BLO_write_struct(writer, EffectorWeights, ob->soft->effector_weights);
- }
-
- if (ob->rigidbody_object) {
- /* TODO: if any extra data is added to handle duplis, will need separate function then */
- BLO_write_struct(writer, RigidBodyOb, ob->rigidbody_object);
- }
- if (ob->rigidbody_constraint) {
- BLO_write_struct(writer, RigidBodyCon, ob->rigidbody_constraint);
- }
-
- if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
- BLO_write_struct(writer, ImageUser, ob->iuser);
- }
-
- write_particlesystems(writer, &ob->particlesystem);
- write_modifiers(writer, &ob->modifiers);
- write_gpencil_modifiers(writer, &ob->greasepencil_modifiers);
- write_shaderfxs(writer, &ob->shader_fx);
-
- BLO_write_struct_list(writer, LinkData, &ob->pc_ids);
-
- BKE_previewimg_blend_write(writer, ob->preview);
- }
-}
-
-static void write_collection_nolib(BlendWriter *writer, Collection *collection)
-{
- /* Shared function for collection data-blocks and scene master collection. */
- BKE_previewimg_blend_write(writer, collection->preview);
-
- LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
- BLO_write_struct(writer, CollectionObject, cob);
- }
-
- LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
- BLO_write_struct(writer, CollectionChild, child);
- }
-}
-
-static void write_collection(BlendWriter *writer, Collection *collection, const void *id_address)
-{
- if (collection->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
- collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
- collection->tag = 0;
- BLI_listbase_clear(&collection->object_cache);
- BLI_listbase_clear(&collection->parents);
-
- /* write LibData */
- BLO_write_id_struct(writer, Collection, id_address, &collection->id);
- BKE_id_blend_write(writer, &collection->id);
-
- write_collection_nolib(writer, collection);
- }
-}
-
-static void write_sequence_modifiers(BlendWriter *writer, ListBase *modbase)
-{
- LISTBASE_FOREACH (SequenceModifierData *, smd, modbase) {
- const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type);
-
- if (smti) {
- BLO_write_struct_by_name(writer, smti->struct_name, smd);
-
- if (smd->type == seqModifierType_Curves) {
- CurvesModifierData *cmd = (CurvesModifierData *)smd;
-
- BKE_curvemapping_blend_write(writer, &cmd->curve_mapping);
- }
- else if (smd->type == seqModifierType_HueCorrect) {
- HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
-
- BKE_curvemapping_blend_write(writer, &hcmd->curve_mapping);
- }
- }
- else {
- BLO_write_struct(writer, SequenceModifierData, smd);
- }
- }
-}
-
-static void write_view_settings(BlendWriter *writer, ColorManagedViewSettings *view_settings)
-{
- if (view_settings->curve_mapping) {
- BKE_curvemapping_blend_write(writer, view_settings->curve_mapping);
- }
-}
-
-static void write_view3dshading(BlendWriter *writer, View3DShading *shading)
-{
- if (shading->prop) {
- IDP_BlendWrite(writer, shading->prop);
- }
-}
-
-static void write_paint(BlendWriter *writer, Paint *p)
-{
- if (p->cavity_curve) {
- BKE_curvemapping_blend_write(writer, p->cavity_curve);
- }
- BLO_write_struct_array(writer, PaintToolSlot, p->tool_slots_len, p->tool_slots);
-}
-
-static void write_layer_collections(BlendWriter *writer, ListBase *lb)
-{
- LISTBASE_FOREACH (LayerCollection *, lc, lb) {
- BLO_write_struct(writer, LayerCollection, lc);
-
- write_layer_collections(writer, &lc->layer_collections);
- }
-}
-
-static void write_view_layer(BlendWriter *writer, ViewLayer *view_layer)
-{
- BLO_write_struct(writer, ViewLayer, view_layer);
- BLO_write_struct_list(writer, Base, &view_layer->object_bases);
-
- if (view_layer->id_properties) {
- IDP_BlendWrite(writer, view_layer->id_properties);
- }
-
- LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
- BLO_write_struct(writer, FreestyleModuleConfig, fmc);
- }
-
- LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
- BLO_write_struct(writer, FreestyleLineSet, fls);
- }
- write_layer_collections(writer, &view_layer->layer_collections);
-}
-
-static void write_lightcache_texture(BlendWriter *writer, LightCacheTexture *tex)
-{
- if (tex->data) {
- size_t data_size = tex->components * tex->tex_size[0] * tex->tex_size[1] * tex->tex_size[2];
- if (tex->data_type == LIGHTCACHETEX_FLOAT) {
- data_size *= sizeof(float);
- }
- else if (tex->data_type == LIGHTCACHETEX_UINT) {
- data_size *= sizeof(uint);
- }
-
- /* FIXME: We can't save more than what 32bit systems can handle.
- * The solution would be to split the texture but it is too late for 2.90. (see T78529) */
- if (data_size < INT_MAX) {
- BLO_write_raw(writer, data_size, tex->data);
- }
- }
-}
-
-static void write_lightcache(BlendWriter *writer, LightCache *cache)
-{
- write_lightcache_texture(writer, &cache->grid_tx);
- write_lightcache_texture(writer, &cache->cube_tx);
-
- if (cache->cube_mips) {
- BLO_write_struct_array(writer, LightCacheTexture, cache->mips_len, cache->cube_mips);
- for (int i = 0; i < cache->mips_len; i++) {
- write_lightcache_texture(writer, &cache->cube_mips[i]);
- }
- }
-
- BLO_write_struct_array(writer, LightGridCache, cache->grid_len, cache->grid_data);
- BLO_write_struct_array(writer, LightProbeCache, cache->cube_len, cache->cube_data);
-}
-
-static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address)
-{
- if (BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
- /* XXX This UI data should not be stored in Scene at all... */
- memset(&sce->cursor, 0, sizeof(sce->cursor));
- }
-
- /* write LibData */
- BLO_write_id_struct(writer, Scene, id_address, &sce->id);
- BKE_id_blend_write(writer, &sce->id);
-
- if (sce->adt) {
- BKE_animdata_blend_write(writer, sce->adt);
- }
- BKE_keyingsets_blend_write(writer, &sce->keyingsets);
-
- /* direct data */
- ToolSettings *tos = sce->toolsettings;
- BLO_write_struct(writer, ToolSettings, tos);
- if (tos->vpaint) {
- BLO_write_struct(writer, VPaint, tos->vpaint);
- write_paint(writer, &tos->vpaint->paint);
- }
- if (tos->wpaint) {
- BLO_write_struct(writer, VPaint, tos->wpaint);
- write_paint(writer, &tos->wpaint->paint);
- }
- if (tos->sculpt) {
- BLO_write_struct(writer, Sculpt, tos->sculpt);
- write_paint(writer, &tos->sculpt->paint);
- }
- if (tos->uvsculpt) {
- BLO_write_struct(writer, UvSculpt, tos->uvsculpt);
- write_paint(writer, &tos->uvsculpt->paint);
- }
- if (tos->gp_paint) {
- BLO_write_struct(writer, GpPaint, tos->gp_paint);
- write_paint(writer, &tos->gp_paint->paint);
- }
- if (tos->gp_vertexpaint) {
- BLO_write_struct(writer, GpVertexPaint, tos->gp_vertexpaint);
- write_paint(writer, &tos->gp_vertexpaint->paint);
- }
- if (tos->gp_sculptpaint) {
- BLO_write_struct(writer, GpSculptPaint, tos->gp_sculptpaint);
- write_paint(writer, &tos->gp_sculptpaint->paint);
- }
- if (tos->gp_weightpaint) {
- BLO_write_struct(writer, GpWeightPaint, tos->gp_weightpaint);
- write_paint(writer, &tos->gp_weightpaint->paint);
- }
- /* write grease-pencil custom ipo curve to file */
- if (tos->gp_interpolate.custom_ipo) {
- BKE_curvemapping_blend_write(writer, tos->gp_interpolate.custom_ipo);
- }
- /* write grease-pencil multiframe falloff curve to file */
- if (tos->gp_sculpt.cur_falloff) {
- BKE_curvemapping_blend_write(writer, tos->gp_sculpt.cur_falloff);
- }
- /* write grease-pencil primitive curve to file */
- if (tos->gp_sculpt.cur_primitive) {
- BKE_curvemapping_blend_write(writer, tos->gp_sculpt.cur_primitive);
- }
- /* Write the curve profile to the file. */
- if (tos->custom_bevel_profile_preset) {
- BKE_curveprofile_blend_write(writer, tos->custom_bevel_profile_preset);
- }
-
- write_paint(writer, &tos->imapaint.paint);
-
- Editing *ed = sce->ed;
- if (ed) {
- Sequence *seq;
-
- BLO_write_struct(writer, Editing, ed);
-
- /* reset write flags too */
-
- SEQ_ALL_BEGIN (ed, seq) {
- if (seq->strip) {
- seq->strip->done = false;
- }
- BLO_write_struct(writer, Sequence, seq);
- }
- SEQ_ALL_END;
-
- SEQ_ALL_BEGIN (ed, seq) {
- if (seq->strip && seq->strip->done == 0) {
- /* write strip with 'done' at 0 because readfile */
-
- if (seq->effectdata) {
- switch (seq->type) {
- case SEQ_TYPE_COLOR:
- BLO_write_struct(writer, SolidColorVars, seq->effectdata);
- break;
- case SEQ_TYPE_SPEED:
- BLO_write_struct(writer, SpeedControlVars, seq->effectdata);
- break;
- case SEQ_TYPE_WIPE:
- BLO_write_struct(writer, WipeVars, seq->effectdata);
- break;
- case SEQ_TYPE_GLOW:
- BLO_write_struct(writer, GlowVars, seq->effectdata);
- break;
- case SEQ_TYPE_TRANSFORM:
- BLO_write_struct(writer, TransformVars, seq->effectdata);
- break;
- case SEQ_TYPE_GAUSSIAN_BLUR:
- BLO_write_struct(writer, GaussianBlurVars, seq->effectdata);
- break;
- case SEQ_TYPE_TEXT:
- BLO_write_struct(writer, TextVars, seq->effectdata);
- break;
- case SEQ_TYPE_COLORMIX:
- BLO_write_struct(writer, ColorMixVars, seq->effectdata);
- break;
- }
- }
-
- BLO_write_struct(writer, Stereo3dFormat, seq->stereo3d_format);
-
- Strip *strip = seq->strip;
- BLO_write_struct(writer, Strip, strip);
- if (strip->crop) {
- BLO_write_struct(writer, StripCrop, strip->crop);
- }
- if (strip->transform) {
- BLO_write_struct(writer, StripTransform, strip->transform);
- }
- if (strip->proxy) {
- BLO_write_struct(writer, StripProxy, strip->proxy);
- }
- if (seq->type == SEQ_TYPE_IMAGE) {
- BLO_write_struct_array(writer,
- StripElem,
- MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem),
- strip->stripdata);
- }
- else if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
- BLO_write_struct(writer, StripElem, strip->stripdata);
- }
-
- strip->done = true;
- }
-
- if (seq->prop) {
- IDP_BlendWrite(writer, seq->prop);
- }
-
- write_sequence_modifiers(writer, &seq->modifiers);
- }
- SEQ_ALL_END;
-
- /* new; meta stack too, even when its nasty restore code */
- LISTBASE_FOREACH (MetaStack *, ms, &ed->metastack) {
- BLO_write_struct(writer, MetaStack, ms);
- }
- }
-
- if (sce->r.avicodecdata) {
- BLO_write_struct(writer, AviCodecData, sce->r.avicodecdata);
- if (sce->r.avicodecdata->lpFormat) {
- BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat);
- }
- if (sce->r.avicodecdata->lpParms) {
- BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms);
- }
- }
- if (sce->r.ffcodecdata.properties) {
- IDP_BlendWrite(writer, sce->r.ffcodecdata.properties);
- }
-
- /* writing dynamic list of TimeMarkers to the blend file */
- LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
- BLO_write_struct(writer, TimeMarker, marker);
-
- if (marker->prop != NULL) {
- IDP_BlendWrite(writer, marker->prop);
- }
- }
-
- /* writing dynamic list of TransformOrientations to the blend file */
- LISTBASE_FOREACH (TransformOrientation *, ts, &sce->transform_spaces) {
- BLO_write_struct(writer, TransformOrientation, ts);
- }
-
- /* writing MultiView to the blend file */
- LISTBASE_FOREACH (SceneRenderView *, srv, &sce->r.views) {
- BLO_write_struct(writer, SceneRenderView, srv);
- }
-
- if (sce->nodetree) {
- BLO_write_struct(writer, bNodeTree, sce->nodetree);
- ntreeBlendWrite(writer, sce->nodetree);
- }
-
- write_view_settings(writer, &sce->view_settings);
-
- /* writing RigidBodyWorld data to the blend file */
- if (sce->rigidbody_world) {
- /* Set deprecated pointers to prevent crashes of older Blenders */
- sce->rigidbody_world->pointcache = sce->rigidbody_world->shared->pointcache;
- sce->rigidbody_world->ptcaches = sce->rigidbody_world->shared->ptcaches;
- BLO_write_struct(writer, RigidBodyWorld, sce->rigidbody_world);
-
- BLO_write_struct(writer, RigidBodyWorld_Shared, sce->rigidbody_world->shared);
- BLO_write_struct(writer, EffectorWeights, sce->rigidbody_world->effector_weights);
- write_pointcaches(writer, &(sce->rigidbody_world->shared->ptcaches));
- }
-
- BKE_previewimg_blend_write(writer, sce->preview);
- BKE_curvemapping_curves_blend_write(writer, &sce->r.mblur_shutter_curve);
-
- LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
- write_view_layer(writer, view_layer);
- }
-
- if (sce->master_collection) {
- BLO_write_struct(writer, Collection, sce->master_collection);
- write_collection_nolib(writer, sce->master_collection);
- }
-
- /* Eevee Lightcache */
- if (sce->eevee.light_cache_data && !BLO_write_is_undo(writer)) {
- BLO_write_struct(writer, LightCache, sce->eevee.light_cache_data);
- write_lightcache(writer, sce->eevee.light_cache_data);
- }
-
- write_view3dshading(writer, &sce->display.shading);
-
- /* Freed on doversion. */
- BLI_assert(sce->layer_properties == NULL);
-}
-
-static void write_wm_xr_data(BlendWriter *writer, wmXrData *xr_data)
-{
- write_view3dshading(writer, &xr_data->session_settings.shading);
-}
-
-static void write_region(BlendWriter *writer, ARegion *region, int spacetype)
-{
- BLO_write_struct(writer, ARegion, region);
-
- if (region->regiondata) {
- if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
- return;
- }
-
- switch (spacetype) {
- case SPACE_VIEW3D:
- if (region->regiontype == RGN_TYPE_WINDOW) {
- RegionView3D *rv3d = region->regiondata;
- BLO_write_struct(writer, RegionView3D, rv3d);
-
- if (rv3d->localvd) {
- BLO_write_struct(writer, RegionView3D, rv3d->localvd);
- }
- if (rv3d->clipbb) {
- BLO_write_struct(writer, BoundBox, rv3d->clipbb);
- }
- }
- else {
- printf("regiondata write missing!\n");
- }
- break;
- default:
- printf("regiondata write missing!\n");
- }
- }
-}
-
-static void write_uilist(BlendWriter *writer, uiList *ui_list)
-{
- BLO_write_struct(writer, uiList, ui_list);
-
- if (ui_list->properties) {
- IDP_BlendWrite(writer, ui_list->properties);
- }
-}
-
-static void write_space_outliner(BlendWriter *writer, SpaceOutliner *space_outliner)
-{
- BLI_mempool *ts = space_outliner->treestore;
-
- if (ts) {
- SpaceOutliner space_outliner_flat = *space_outliner;
-
- int elems = BLI_mempool_len(ts);
- /* linearize mempool to array */
- TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL;
-
- if (data) {
- /* In this block we use the memory location of the treestore
- * but _not_ its data, the addresses in this case are UUID's,
- * since we can't rely on malloc giving us different values each time.
- */
- TreeStore ts_flat = {0};
-
- /* we know the treestore is at least as big as a pointer,
- * so offsetting works to give us a UUID. */
- void *data_addr = (void *)POINTER_OFFSET(ts, sizeof(void *));
-
- ts_flat.usedelem = elems;
- ts_flat.totelem = elems;
- ts_flat.data = data_addr;
-
- BLO_write_struct(writer, SpaceOutliner, space_outliner);
-
- BLO_write_struct_at_address(writer, TreeStore, ts, &ts_flat);
- BLO_write_struct_array_at_address(writer, TreeStoreElem, elems, data_addr, data);
-
- MEM_freeN(data);
- }
- else {
- space_outliner_flat.treestore = NULL;
- BLO_write_struct_at_address(writer, SpaceOutliner, space_outliner, &space_outliner_flat);
- }
- }
- else {
- BLO_write_struct(writer, SpaceOutliner, space_outliner);
- }
-}
-
-static void write_panel_list(BlendWriter *writer, ListBase *lb)
-{
- LISTBASE_FOREACH (Panel *, panel, lb) {
- BLO_write_struct(writer, Panel, panel);
- write_panel_list(writer, &panel->children);
- }
-}
-
-static void write_area_regions(BlendWriter *writer, ScrArea *area)
-{
- LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
- write_region(writer, region, area->spacetype);
- write_panel_list(writer, &region->panels);
-
- LISTBASE_FOREACH (PanelCategoryStack *, pc_act, &region->panels_category_active) {
- BLO_write_struct(writer, PanelCategoryStack, pc_act);
- }
-
- LISTBASE_FOREACH (uiList *, ui_list, &region->ui_lists) {
- write_uilist(writer, ui_list);
- }
-
- LISTBASE_FOREACH (uiPreview *, ui_preview, &region->ui_previews) {
- BLO_write_struct(writer, uiPreview, ui_preview);
- }
- }
-
- LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
- LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
- write_region(writer, region, sl->spacetype);
- }
-
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- BLO_write_struct(writer, View3D, v3d);
-
- if (v3d->localvd) {
- BLO_write_struct(writer, View3D, v3d->localvd);
- }
-
- write_view3dshading(writer, &v3d->shading);
- }
- else if (sl->spacetype == SPACE_GRAPH) {
- SpaceGraph *sipo = (SpaceGraph *)sl;
- ListBase tmpGhosts = sipo->runtime.ghost_curves;
-
- /* temporarily disable ghost curves when saving */
- BLI_listbase_clear(&sipo->runtime.ghost_curves);
-
- BLO_write_struct(writer, SpaceGraph, sl);
- if (sipo->ads) {
- BLO_write_struct(writer, bDopeSheet, sipo->ads);
- }
-
- /* reenable ghost curves */
- sipo->runtime.ghost_curves = tmpGhosts;
- }
- else if (sl->spacetype == SPACE_PROPERTIES) {
- BLO_write_struct(writer, SpaceProperties, sl);
- }
- else if (sl->spacetype == SPACE_FILE) {
- SpaceFile *sfile = (SpaceFile *)sl;
-
- BLO_write_struct(writer, SpaceFile, sl);
- if (sfile->params) {
- BLO_write_struct(writer, FileSelectParams, sfile->params);
- }
- }
- else if (sl->spacetype == SPACE_SEQ) {
- BLO_write_struct(writer, SpaceSeq, sl);
- }
- else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
- write_space_outliner(writer, space_outliner);
- }
- else if (sl->spacetype == SPACE_IMAGE) {
- BLO_write_struct(writer, SpaceImage, sl);
- }
- else if (sl->spacetype == SPACE_TEXT) {
- BLO_write_struct(writer, SpaceText, sl);
- }
- else if (sl->spacetype == SPACE_SCRIPT) {
- SpaceScript *scr = (SpaceScript *)sl;
- scr->but_refs = NULL;
- BLO_write_struct(writer, SpaceScript, sl);
- }
- else if (sl->spacetype == SPACE_ACTION) {
- BLO_write_struct(writer, SpaceAction, sl);
- }
- else if (sl->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *)sl;
-
- BLO_write_struct(writer, SpaceNla, snla);
- if (snla->ads) {
- BLO_write_struct(writer, bDopeSheet, snla->ads);
- }
- }
- else if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *)sl;
- BLO_write_struct(writer, SpaceNode, snode);
-
- LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
- BLO_write_struct(writer, bNodeTreePath, path);
- }
- }
- else if (sl->spacetype == SPACE_CONSOLE) {
- SpaceConsole *con = (SpaceConsole *)sl;
-
- LISTBASE_FOREACH (ConsoleLine *, cl, &con->history) {
- /* 'len_alloc' is invalid on write, set from 'len' on read */
- BLO_write_struct(writer, ConsoleLine, cl);
- BLO_write_raw(writer, (size_t)cl->len + 1, cl->line);
- }
- BLO_write_struct(writer, SpaceConsole, sl);
- }
-#ifdef WITH_GLOBAL_AREA_WRITING
- else if (sl->spacetype == SPACE_TOPBAR) {
- BLO_write_struct(writer, SpaceTopBar, sl);
- }
- else if (sl->spacetype == SPACE_STATUSBAR) {
- BLO_write_struct(writer, SpaceStatusBar, sl);
- }
-#endif
- else if (sl->spacetype == SPACE_USERPREF) {
- BLO_write_struct(writer, SpaceUserPref, sl);
- }
- else if (sl->spacetype == SPACE_CLIP) {
- BLO_write_struct(writer, SpaceClip, sl);
- }
- else if (sl->spacetype == SPACE_INFO) {
- BLO_write_struct(writer, SpaceInfo, sl);
- }
- }
-}
-
-static void write_area_map(BlendWriter *writer, ScrAreaMap *area_map)
-{
- BLO_write_struct_list(writer, ScrVert, &area_map->vertbase);
- BLO_write_struct_list(writer, ScrEdge, &area_map->edgebase);
- LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
- area->butspacetype = area->spacetype; /* Just for compatibility, will be reset below. */
-
- BLO_write_struct(writer, ScrArea, area);
-
-#ifdef WITH_GLOBAL_AREA_WRITING
- BLO_write_struct(writer, ScrGlobalAreaData, area->global);
-#endif
-
- write_area_regions(writer, area);
-
- area->butspacetype = SPACE_EMPTY; /* Unset again, was changed above. */
- }
-}
-
-static void write_windowmanager(BlendWriter *writer, wmWindowManager *wm, const void *id_address)
-{
- BLO_write_id_struct(writer, wmWindowManager, id_address, &wm->id);
- BKE_id_blend_write(writer, &wm->id);
- write_wm_xr_data(writer, &wm->xr);
-
- LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
-#ifndef WITH_GLOBAL_AREA_WRITING
- /* Don't write global areas yet, while we make changes to them. */
- ScrAreaMap global_areas = win->global_areas;
- memset(&win->global_areas, 0, sizeof(win->global_areas));
-#endif
-
- /* update deprecated screen member (for so loading in 2.7x uses the correct screen) */
- win->screen = BKE_workspace_active_screen_get(win->workspace_hook);
-
- BLO_write_struct(writer, wmWindow, win);
- BLO_write_struct(writer, WorkSpaceInstanceHook, win->workspace_hook);
- BLO_write_struct(writer, Stereo3dFormat, win->stereo3d_format);
-
-#ifdef WITH_GLOBAL_AREA_WRITING
- write_area_map(writer, &win->global_areas);
-#else
- win->global_areas = global_areas;
-#endif
-
- /* data is written, clear deprecated data again */
- win->screen = NULL;
- }
-}
-
-static void write_screen(BlendWriter *writer, bScreen *screen, const void *id_address)
-{
- /* Screens are reference counted, only saved if used by a workspace. */
- if (screen->id.us > 0 || BLO_write_is_undo(writer)) {
- /* write LibData */
- /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
- writestruct_at_address(writer->wd, ID_SCRN, bScreen, 1, id_address, screen);
- BKE_id_blend_write(writer, &screen->id);
-
- BKE_previewimg_blend_write(writer, screen->preview);
-
- /* direct data */
- write_area_map(writer, AREAMAP_FROM_SCREEN(screen));
- }
-}
-
-static void write_workspace(BlendWriter *writer, WorkSpace *workspace, const void *id_address)
-{
- BLO_write_id_struct(writer, WorkSpace, id_address, &workspace->id);
- BKE_id_blend_write(writer, &workspace->id);
- BLO_write_struct_list(writer, WorkSpaceLayout, &workspace->layouts);
- BLO_write_struct_list(writer, WorkSpaceDataRelation, &workspace->hook_layout_relations);
- BLO_write_struct_list(writer, wmOwnerID, &workspace->owner_ids);
- BLO_write_struct_list(writer, bToolRef, &workspace->tools);
- LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
- if (tref->properties) {
- IDP_BlendWrite(writer, tref->properties);
- }
- }
-}
-
/* Keep it last of write_foodata functions. */
static void write_libraries(WriteData *wd, Main *main)
{
@@ -2240,7 +935,7 @@ static bool write_file_handle(Main *mainvar,
write_thumb(wd, thumb);
write_global(wd, write_flags, mainvar);
- /* The windowmanager and screen often change,
+ /* The window-manager and screen often change,
* avoid thumbnail detecting changes because of this. */
mywrite_flush(wd);
@@ -2322,74 +1017,6 @@ static bool write_file_handle(Main *mainvar,
id_type->blend_write(&writer, (ID *)id_buffer, id);
}
- switch ((ID_Type)GS(id->name)) {
- case ID_WM:
- write_windowmanager(&writer, (wmWindowManager *)id_buffer, id);
- break;
- case ID_WS:
- write_workspace(&writer, (WorkSpace *)id_buffer, id);
- break;
- case ID_SCR:
- write_screen(&writer, (bScreen *)id_buffer, id);
- break;
- case ID_SCE:
- write_scene(&writer, (Scene *)id_buffer, id);
- break;
- case ID_GR:
- write_collection(&writer, (Collection *)id_buffer, id);
- break;
- case ID_OB:
- write_object(&writer, (Object *)id_buffer, id);
- break;
- case ID_PA:
- write_particlesettings(&writer, (ParticleSettings *)id_buffer, id);
- break;
- case ID_ME:
- case ID_LT:
- case ID_AC:
- case ID_NT:
- case ID_LS:
- case ID_TXT:
- case ID_VF:
- case ID_MC:
- case ID_PC:
- case ID_PAL:
- case ID_BR:
- case ID_IM:
- case ID_LA:
- case ID_MA:
- case ID_MB:
- case ID_CU:
- case ID_CA:
- case ID_WO:
- case ID_MSK:
- case ID_SPK:
- case ID_AR:
- case ID_LP:
- case ID_KE:
- case ID_TE:
- case ID_GD:
- case ID_HA:
- case ID_PT:
- case ID_VO:
- case ID_SIM:
- case ID_SO:
- case ID_CF:
- /* Do nothing, handled in IDTypeInfo callback. */
- break;
- case ID_LI:
- /* Do nothing, handled below - and should never be reached. */
- BLI_assert(0);
- break;
- case ID_IP:
- /* Do nothing, deprecated. */
- break;
- default:
- /* Should never be reached. */
- BLI_assert(0);
- break;
- }
-
if (do_override) {
BKE_lib_override_library_operations_store_end(override_storage, id);
}
@@ -2678,7 +1305,13 @@ void BLO_write_struct_at_address_by_id(BlendWriter *writer,
const void *address,
const void *data_ptr)
{
- writestruct_at_address_nr(writer->wd, DATA, struct_id, 1, address, data_ptr);
+ BLO_write_struct_at_address_by_id_with_filecode(writer, DATA, struct_id, address, data_ptr);
+}
+
+void BLO_write_struct_at_address_by_id_with_filecode(
+ BlendWriter *writer, int filecode, int struct_id, const void *address, const void *data_ptr)
+{
+ writestruct_at_address_nr(writer->wd, filecode, struct_id, 1, address, data_ptr);
}
void BLO_write_struct_array_by_id(BlendWriter *writer,
diff --git a/source/blender/blenloader/tests/blendfile_loading_base_test.cc b/source/blender/blenloader/tests/blendfile_loading_base_test.cc
index e34be68abbf..a3aabf6ac10 100644
--- a/source/blender/blenloader/tests/blendfile_loading_base_test.cc
+++ b/source/blender/blenloader/tests/blendfile_loading_base_test.cc
@@ -73,7 +73,7 @@ void BlendfileLoadingBaseTest::SetUpTestCase()
BKE_modifier_init();
DEG_register_node_types();
RNA_init();
- init_nodesystem();
+ BKE_node_system_init();
G.background = true;
G.factory_startup = true;
@@ -127,7 +127,7 @@ bool BlendfileLoadingBaseTest::blendfile_load(const char *filepath)
char abspath[FILENAME_MAX];
BLI_path_join(abspath, sizeof(abspath), test_assets_dir.c_str(), filepath, NULL);
- bfile = BLO_read_from_file(abspath, BLO_READ_SKIP_NONE, NULL /* reports */);
+ bfile = BLO_read_from_file(abspath, BLO_READ_SKIP_NONE, nullptr /* reports */);
if (bfile == nullptr) {
ADD_FAILURE() << "Unable to load file '" << filepath << "' from test assets dir '"
<< test_assets_dir << "'";
@@ -144,7 +144,7 @@ void BlendfileLoadingBaseTest::blendfile_free()
wmWindowManager *wm = static_cast<wmWindowManager *>(bfile->main->wm.first);
if (wm != nullptr) {
- wm_close_and_free(NULL, wm);
+ wm_close_and_free(nullptr, wm);
}
BLO_blendfiledata_free(bfile);
bfile = nullptr;
diff --git a/source/blender/blentranslation/intern/blt_lang.c b/source/blender/blentranslation/intern/blt_lang.c
index 078ded7e5c2..bd0352d3e80 100644
--- a/source/blender/blentranslation/intern/blt_lang.c
+++ b/source/blender/blentranslation/intern/blt_lang.c
@@ -105,7 +105,7 @@ static void fill_locales(void)
while (line) {
int t;
str = (char *)line->link;
- if (str[0] == '#' || str[0] == '\0') {
+ if (ELEM(str[0], '#', '\0')) {
line = line->next;
continue; /* Comment or void... */
}
@@ -130,7 +130,7 @@ static void fill_locales(void)
char *loc, *sep1, *sep2, *sep3;
str = (char *)line->link;
- if (str[0] == '#' || str[0] == '\0') {
+ if (ELEM(str[0], '#', '\0')) {
line = line->next;
continue;
}
@@ -388,7 +388,7 @@ static void blt_lang_check_ime_supported(void)
{
#ifdef WITH_INPUT_IME
const char *uilng = BLT_lang_get();
- ime_is_lang_supported = STREQ(uilng, "zh_CN") || STREQ(uilng, "zh_TW") || STREQ(uilng, "ja_JP");
+ ime_is_lang_supported = STR_ELEM(uilng, "zh_CN", "zh_TW", "ja_JP");
#else
ime_is_lang_supported = false;
#endif
diff --git a/source/blender/blentranslation/msgfmt/CMakeLists.txt b/source/blender/blentranslation/msgfmt/CMakeLists.txt
index 20f5053bd29..4b8f0878c75 100644
--- a/source/blender/blentranslation/msgfmt/CMakeLists.txt
+++ b/source/blender/blentranslation/msgfmt/CMakeLists.txt
@@ -34,7 +34,7 @@ setup_libdirs()
add_cc_flags_custom_test(msgfmt)
if(WIN32)
- set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /nodefaultlib:MSVCRT.lib")
+ string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " /nodefaultlib:MSVCRT.lib")
endif()
add_executable(msgfmt ${SRC})
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index 92c52f5d8d0..c215cf69e3a 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -183,7 +183,7 @@ set(LIB
)
if(MSVC AND NOT MSVC_CLANG)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX /wd4101")
+ string(APPEND CMAKE_C_FLAGS " /WX /wd4101")
endif()
if(WITH_BULLET)
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index ca5693aa5ba..8631c224ce0 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -335,7 +335,7 @@ BMFace *BM_face_create_ngon_verts(BMesh *bm,
/* we want to use the reverse winding to the existing order */
BM_edge_ordered_verts(edge_arr[i], &test_v2, &test_v1);
winding[(vert_arr[i_prev] == test_v2)]++;
- BLI_assert(vert_arr[i_prev] == test_v2 || vert_arr[i_prev] == test_v1);
+ BLI_assert(ELEM(vert_arr[i_prev], test_v2, test_v1));
}
}
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index df5e7aadc64..b913bdd12e4 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -2289,6 +2289,7 @@ bool BM_vert_splice(BMesh *bm, BMVert *v_dst, BMVert *v_src)
return true;
}
+/* -------------------------------------------------------------------- */
/** \name BM_vert_separate, bmesh_kernel_vert_separate and friends
* \{ */
diff --git a/source/blender/bmesh/intern/bmesh_delete.c b/source/blender/bmesh/intern/bmesh_delete.c
index b5ff24f6d61..f470361e5fb 100644
--- a/source/blender/bmesh/intern/bmesh_delete.c
+++ b/source/blender/bmesh/intern/bmesh_delete.c
@@ -28,9 +28,9 @@
#include "bmesh.h"
#include "intern/bmesh_private.h"
-/* -------------------------------------------------------------------- */
/* BMO functions */
+/* -------------------------------------------------------------------- */
/** \name BMesh Operator Delete Functions
* \{ */
@@ -203,7 +203,6 @@ void BMO_mesh_delete_oflag_context(BMesh *bm, const short oflag, const int type)
/** \} */
-/* -------------------------------------------------------------------- */
/* BM functions
*
* note! this is just a duplicate of the code above (bad!)
@@ -211,6 +210,7 @@ void BMO_mesh_delete_oflag_context(BMesh *bm, const short oflag, const int type)
* each time we need to remove some geometry.
*/
+/* -------------------------------------------------------------------- */
/** \name BMesh Delete Functions (no oflags)
* \{ */
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index 0bbe86d2d2f..a15408d43be 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -1027,6 +1027,7 @@ void BM_elem_float_data_set(CustomData *cd, void *element, int type, const float
}
}
+/* -------------------------------------------------------------------- */
/** \name Loop interpolation functions: BM_vert_loop_groups_data_layer_***
*
* Handling loop custom-data such as UV's, while keeping contiguous fans is rather tedious.
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index a5d02cdc4e5..4fe6e6aee58 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -66,6 +66,7 @@ static void recount_totsels(BMesh *bm)
}
}
+/* -------------------------------------------------------------------- */
/** \name BMesh helper functions for selection & hide flushing.
* \{ */
@@ -540,7 +541,8 @@ void BM_face_select_set(BMesh *bm, BMFace *f, const bool select)
}
}
-/** \name Non flushing versions element selection.
+/* -------------------------------------------------------------------- */
+/** \name Non Flushing Versions Element Selection
* \{ */
void BM_edge_select_set_noflush(BMesh *bm, BMEdge *e, const bool select)
diff --git a/source/blender/bmesh/intern/bmesh_mesh_duplicate.c b/source/blender/bmesh/intern/bmesh_mesh_duplicate.c
index 51f9d2eab1d..1d393abcd56 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_duplicate.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_duplicate.c
@@ -50,9 +50,7 @@ static BMEdge *bm_edge_copy_with_arrays(BMesh *bm_src,
}
static BMFace *bm_face_copy_with_arrays(
- BMesh *bm_src, BMesh *bm_dst, BMFace *f_src, BMVert **verts_dst, BMEdge **edges_dst
-
-)
+ BMesh *bm_src, BMesh *bm_dst, BMFace *f_src, BMVert **verts_dst, BMEdge **edges_dst)
{
BMFace *f_dst;
BMVert **vtar = BLI_array_alloca(vtar, f_src->len);
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index c5e030c436a..c2421939aa8 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -963,7 +963,7 @@ void BMO_slot_buffer_from_single(BMOperator *op, BMOpSlot *slot, BMHeader *ele)
BMO_ASSERT_SLOT_IN_OP(slot, op);
BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
BLI_assert(slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE);
- BLI_assert(slot->len == 0 || slot->len == 1);
+ BLI_assert(ELEM(slot->len, 0, 1));
BLI_assert(slot->slot_subtype.elem & ele->htype);
@@ -979,7 +979,7 @@ void BMO_slot_buffer_from_array(BMOperator *op,
{
BMO_ASSERT_SLOT_IN_OP(slot, op);
BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
- BLI_assert(slot->len == 0 || slot->len == ele_buffer_len);
+ BLI_assert(ELEM(slot->len, 0, ele_buffer_len));
if (slot->data.buf == NULL) {
slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(*slot->data.buf) * ele_buffer_len);
@@ -993,7 +993,7 @@ void *BMO_slot_buffer_get_single(BMOpSlot *slot)
{
BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
BLI_assert(slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE);
- BLI_assert(slot->len == 0 || slot->len == 1);
+ BLI_assert(ELEM(slot->len, 0, 1));
return slot->len ? (BMHeader *)slot->data.buf[0] : NULL;
}
diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
index 09c0f48c2f6..1d000b3b232 100644
--- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
+++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
@@ -39,9 +39,9 @@
#include "intern/bmesh_private.h"
/* -------------------------------------------------------------------- */
-/* Face Split Edge-Net */
-
-/** \name BM_face_split_edgenet and helper functions.
+/** \name Face Split Edge-Net
+ *
+ * #BM_face_split_edgenet and helper functions.
*
* \note Don't use #BM_edge_is_wire or #BM_edge_is_boundary
* since we need to take flagged faces into account.
@@ -702,9 +702,9 @@ bool BM_face_split_edgenet(BMesh *bm,
/** \} */
/* -------------------------------------------------------------------- */
-/* Face Split Edge-Net Connect Islands */
-
-/** \name BM_face_split_edgenet_connect_islands and helper functions.
+/** \name Face Split Edge-Net Connect Islands
+ *
+ * #BM_face_split_edgenet_connect_islands and helper functions.
*
* Connect isolated mesh 'islands' so they form legal regions from which we can create faces.
*
diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c
index 791fa64ae7d..0d8b5cf4590 100644
--- a/source/blender/bmesh/intern/bmesh_query.c
+++ b/source/blender/bmesh/intern/bmesh_query.c
@@ -1605,7 +1605,7 @@ float BM_loop_calc_face_normal_safe_vcos_ex(const BMLoop *l,
}
/**
- * #BM_loop_calc_face_normal_safe_ex with pre-defined sane epsilon.
+ * #BM_loop_calc_face_normal_safe_ex with predefined sane epsilon.
*
* Since this doesn't scale based on triangle size, fixed value works well.
*/
diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c
index d9f68f8aa62..ef4a9c9de1c 100644
--- a/source/blender/bmesh/intern/bmesh_structure.c
+++ b/source/blender/bmesh/intern/bmesh_structure.c
@@ -402,7 +402,7 @@ bool bmesh_radial_validate(int radlen, BMLoop *l)
if (l_iter->e != l->e) {
return false;
}
- if (l_iter->v != l->e->v1 && l_iter->v != l->e->v2) {
+ if (!ELEM(l_iter->v, l->e->v1, l->e->v2)) {
return false;
}
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index dc9107a1616..7d56e560275 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -37,6 +37,7 @@
} \
(void)0
+/* -------------------------------------------------------------------- */
/** \name Mask Flag Checks
* \{ */
@@ -75,6 +76,7 @@ static bool bmw_mask_check_face(BMWalker *walker, BMFace *f)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name BMesh Queries (modified to check walker flags)
* \{ */
@@ -94,8 +96,8 @@ static bool bmw_edge_is_wire(const BMWalker *walker, const BMEdge *e)
}
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Shell Walker
- * \{
*
* Starts at a vertex on the mesh and walks over the 'shell' it belongs
* to via visiting connected edges.
@@ -104,7 +106,7 @@ static bool bmw_edge_is_wire(const BMWalker *walker, const BMEdge *e)
* restrict flag acts on the edges as well.
*
* \todo Add restriction flag/callback for wire edges.
- */
+ * \{ */
static void bmw_VertShellWalker_visitEdge(BMWalker *walker, BMEdge *e)
{
BMwShellWalker *shellWalk = NULL;
@@ -228,14 +230,14 @@ static void *bmw_VertShellWalker_step(BMWalker *walker)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name LoopShell Walker
- * \{
*
* Starts at any element on the mesh and walks over the 'shell' it belongs
* to via visiting connected loops.
*
* \note this is mainly useful to loop over a shell delimited by edges.
- */
+ * \{ */
static void bmw_LoopShellWalker_visitLoop(BMWalker *walker, BMLoop *l)
{
BMwLoopShellWalker *shellWalk = NULL;
@@ -352,10 +354,10 @@ static void *bmw_LoopShellWalker_step(BMWalker *walker)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name LoopShell & 'Wire' Walker
- * \{
*
- * Piggyback ontop of #BMwLoopShellWalker, but also walk over wire edges
+ * Piggyback on top of #BMwLoopShellWalker, but also walk over wire edges
* This isn't elegant but users expect it when selecting linked,
* so we can support delimiters _and_ walking over wire edges.
*
@@ -363,7 +365,7 @@ static void *bmw_LoopShellWalker_step(BMWalker *walker)
* - can yield edges (as well as loops)
* - only step over wire edges.
* - verts and edges are stored in `visit_set_alt`.
- */
+ * \{ */
static void bmw_LoopShellWalker_visitEdgeWire(BMWalker *walker, BMEdge *e)
{
@@ -504,12 +506,12 @@ static void *bmw_LoopShellWireWalker_step(BMWalker *walker)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name FaceShell Walker
- * \{
*
* Starts at an edge on the mesh and walks over the 'shell' it belongs
* to via visiting connected faces.
- */
+ * \{ */
static void bmw_FaceShellWalker_visitEdge(BMWalker *walker, BMEdge *e)
{
BMwShellWalker *shellWalk = NULL;
@@ -567,13 +569,13 @@ static void *bmw_FaceShellWalker_step(BMWalker *walker)
}
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Connected Vertex Walker
- * \{
*
* Similar to shell walker, but visits vertices instead of edges.
*
* Walk from a vertex to all connected vertices.
- */
+ * \{ */
static void bmw_ConnectedVertexWalker_visitVertex(BMWalker *walker, BMVert *v)
{
BMwConnectedVertexWalker *vwalk;
@@ -629,8 +631,8 @@ static void *bmw_ConnectedVertexWalker_step(BMWalker *walker)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Island Boundary Walker
- * \{
*
* Starts at a edge on the mesh and walks over the boundary of an island it belongs to.
*
@@ -640,7 +642,7 @@ static void *bmw_ConnectedVertexWalker_step(BMWalker *walker)
* over the boundary. raises an error if it encounters non-manifold geometry.
*
* \todo Add restriction flag/callback for wire edges.
- */
+ * \{ */
static void bmw_IslandboundWalker_begin(BMWalker *walker, void *data)
{
BMLoop *l = data;
@@ -723,13 +725,13 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
return owalk.curloop;
}
+/* -------------------------------------------------------------------- */
/** \name Island Walker
- * \{
*
* Starts at a tool flagged-face and walks over the face region
*
* \todo Add restriction flag/callback for wire edges.
- */
+ * \{ */
static void bmw_IslandWalker_begin(BMWalker *walker, void *data)
{
BMwIslandWalker *iwalk = NULL;
@@ -828,11 +830,11 @@ static void *bmw_IslandManifoldWalker_step(BMWalker *walker)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Edge Loop Walker
- * \{
*
* Starts at a tool-flagged edge and walks over the edge loop
- */
+ * \{ */
/* utility function to see if an edge is a part of an ngon boundary */
static bool bm_edge_is_single(BMEdge *e)
@@ -981,7 +983,7 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker)
/* Typical loopiong over edges in the middle of a mesh */
/* However, why use 2 here at all?
* I guess for internal ngon loops it can be useful. Antony R. */
- if (vert_edge_tot == 4 || vert_edge_tot == 2) {
+ if (ELEM(vert_edge_tot, 4, 2)) {
int i_opposite = vert_edge_tot / 2;
int i = 0;
do {
@@ -1070,13 +1072,13 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Face Loop Walker
- * \{
*
* Starts at a tool-flagged face and walks over the face loop
* Conditions for starting and stepping the face loop have been
* tuned in an attempt to match the face loops built by EditMesh
- */
+ * \{ */
/* Check whether the face loop should includes the face specified
* by the given BMLoop */
@@ -1216,13 +1218,13 @@ static void *bmw_FaceLoopWalker_step(BMWalker *walker)
// #define BMW_EDGERING_NGON
+/* -------------------------------------------------------------------- */
/** \name Edge Ring Walker
- * \{
*
* Starts at a tool-flagged edge and walks over the edge ring
* Conditions for starting and stepping the edge ring have been
* tuned to match behavior users expect (dating back to v2.4x).
- */
+ * \{ */
static void bmw_EdgeringWalker_begin(BMWalker *walker, void *data)
{
BMwEdgeringWalker *lwalk, owalk, *owalk_pt;
@@ -1349,6 +1351,7 @@ static void *bmw_EdgeringWalker_step(BMWalker *walker)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Boundary Edge Walker
* \{ */
@@ -1420,14 +1423,14 @@ static void *bmw_EdgeboundaryWalker_step(BMWalker *walker)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name UV Edge Walker
*
* walk over uv islands; takes a loop as input. restrict flag
* restricts the walking to loops whose vert has restrict flag set as a
* tool flag.
*
- * the flag parameter to BMW_init maps to a loop customdata layer index.
- *
+ * The flag parameter to BMW_init maps to a loop customdata layer index.
* \{ */
static void bmw_UVEdgeWalker_begin(BMWalker *walker, void *data)
diff --git a/source/blender/bmesh/operators/bmo_fill_grid.c b/source/blender/bmesh/operators/bmo_fill_grid.c
index c97e855aa67..3aad37b3b02 100644
--- a/source/blender/bmesh/operators/bmo_fill_grid.c
+++ b/source/blender/bmesh/operators/bmo_fill_grid.c
@@ -96,9 +96,7 @@ static void quad_verts_to_barycentric_tri(float tri[3][3],
#endif
/* -------------------------------------------------------------------- */
-/* Handle Loop Pairs */
-
-/** \name Loop Pairs
+/** \name Handle Loop Pairs
* \{ */
/**
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index 46dff99898c..8b2f9478aab 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -338,9 +338,9 @@ static void alter_co(BMVert *v,
add_v3_v3v3(co2, v->co, params->fractal_ofs);
mul_v3_fl(co2, 10.0f);
- tvec[0] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 2) - 0.5f);
- tvec[1] = fac * (BLI_gTurbulence(1.0, co2[1], co2[0], co2[2], 15, 0, 2) - 0.5f);
- tvec[2] = fac * (BLI_gTurbulence(1.0, co2[1], co2[2], co2[0], 15, 0, 2) - 0.5f);
+ tvec[0] = fac * (BLI_noise_generic_turbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 2) - 0.5f);
+ tvec[1] = fac * (BLI_noise_generic_turbulence(1.0, co2[1], co2[0], co2[2], 15, 0, 2) - 0.5f);
+ tvec[2] = fac * (BLI_noise_generic_turbulence(1.0, co2[1], co2[2], co2[0], 15, 0, 2) - 0.5f);
/* add displacement */
madd_v3_v3fl(co, normal, tvec[0]);
diff --git a/source/blender/bmesh/tests/bmesh_core_test.cc b/source/blender/bmesh/tests/bmesh_core_test.cc
index afbc11e0722..202d16b09e3 100644
--- a/source/blender/bmesh/tests/bmesh_core_test.cc
+++ b/source/blender/bmesh/tests/bmesh_core_test.cc
@@ -16,8 +16,8 @@ TEST(bmesh_core, BMVertCreate)
EXPECT_EQ(bm->totvert, 0);
/* make a custom layer so we can see if it is copied properly */
BM_data_layer_add(bm, &bm->vdata, CD_PROP_FLOAT);
- bv1 = BM_vert_create(bm, co1, NULL, BM_CREATE_NOP);
- ASSERT_TRUE(bv1 != NULL);
+ bv1 = BM_vert_create(bm, co1, nullptr, BM_CREATE_NOP);
+ ASSERT_TRUE(bv1 != nullptr);
EXPECT_EQ(bv1->co[0], 1.0f);
EXPECT_EQ(bv1->co[1], 2.0f);
EXPECT_EQ(bv1->co[2], 0.0f);
@@ -25,14 +25,14 @@ TEST(bmesh_core, BMVertCreate)
EXPECT_EQ(bv1->head.htype, (char)BM_VERT);
EXPECT_EQ(bv1->head.hflag, 0);
EXPECT_EQ(bv1->head.api_flag, 0);
- bv2 = BM_vert_create(bm, NULL, NULL, BM_CREATE_NOP);
- ASSERT_TRUE(bv2 != NULL);
+ bv2 = BM_vert_create(bm, nullptr, nullptr, BM_CREATE_NOP);
+ ASSERT_TRUE(bv2 != nullptr);
EXPECT_TRUE(is_zero_v3(bv2->co));
/* create with example should copy custom data but not select flag */
BM_vert_select_set(bm, bv2, true);
BM_elem_float_data_set(&bm->vdata, bv2, CD_PROP_FLOAT, 1.5f);
bv3 = BM_vert_create(bm, co1, bv2, BM_CREATE_NOP);
- ASSERT_TRUE(bv3 != NULL);
+ ASSERT_TRUE(bv3 != nullptr);
EXPECT_FALSE(BM_elem_flag_test((BMElem *)bv3, BM_ELEM_SELECT));
EXPECT_EQ(BM_elem_float_data_get(&bm->vdata, bv3, CD_PROP_FLOAT), 1.5f);
EXPECT_EQ(BM_mesh_elem_count(bm, BM_VERT), 3);
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 309b6547a39..9497466723a 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -303,14 +303,14 @@ typedef enum {
} FKind;
/** Helper for keeping track of angle kind. */
-enum {
+typedef enum AngleKind {
/** Angle less than 180 degrees. */
ANGLE_SMALLER = -1,
/** 180 degree angle. */
ANGLE_STRAIGHT = 0,
/** Angle greater than 180 degrees. */
ANGLE_LARGER = 1,
-};
+} AngleKind;
/** Bevel parameters and state. */
typedef struct BevelParams {
@@ -1101,7 +1101,7 @@ static bool is_outside_edge(EdgeHalf *e, const float co[3], BMVert **ret_closer_
}
/* Return whether the angle is less than, equal to, or larger than 180 degrees. */
-static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v)
+static AngleKind edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v)
{
BMVert *v1 = BM_edge_other_vert(e1->e, v);
BMVert *v2 = BM_edge_other_vert(e2->e, v);
@@ -1413,7 +1413,7 @@ static void offset_meet(BevelParams *bp,
normalize_v3(norm_perp2);
float off1a[3], off1b[3], off2a[3], off2b[3];
- if (bp->offset_type == BEVEL_AMT_PERCENT || bp->offset_type == BEVEL_AMT_ABSOLUTE) {
+ if (ELEM(bp->offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE)) {
offset_meet_lines_percent_or_absolute(bp, e1, e2, v, off1a, off1b, off2a, off2b);
}
else {
@@ -1570,7 +1570,7 @@ static bool offset_on_edge_between(BevelParams *bp,
float meet1[3], meet2[3];
bool ok1 = offset_meet_edge(e1, emid, v, meet1, &ang1);
bool ok2 = offset_meet_edge(emid, e2, v, meet2, &ang2);
- if (bp->offset_type == BEVEL_AMT_PERCENT || bp->offset_type == BEVEL_AMT_ABSOLUTE) {
+ if (ELEM(bp->offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE)) {
BMVert *v2 = BM_edge_other_vert(emid->e, v);
if (bp->offset_type == BEVEL_AMT_PERCENT) {
interp_v3_v3v3(meetco, v->co, v2->co, bp->offset / 100.0f);
@@ -2172,7 +2172,7 @@ static void snap_to_superellipsoid(float co[3], const float super_r, bool midlin
float x = a;
float y = b;
float z = c;
- if (r == PRO_SQUARE_R || r == PRO_SQUARE_IN_R) {
+ if (ELEM(r, PRO_SQUARE_R, PRO_SQUARE_IN_R)) {
/* Will only be called for 2d profile. */
BLI_assert(fabsf(z) < BEVEL_EPSILON);
z = 0.0f;
@@ -2455,7 +2455,7 @@ static void bevel_harden_normals(BevelParams *bp, BMesh *bm)
BMFace *f;
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
FKind fkind = get_face_kind(bp, f);
- if (fkind == F_ORIG || fkind == F_RECON) {
+ if (ELEM(fkind, F_ORIG, F_RECON)) {
continue;
}
BMIter liter;
@@ -3041,7 +3041,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
for (EdgeHalf *e3 = e->next; e3 != e2; e3 = e3->next) {
e3->leftv = e3->rightv = v;
}
- int ang_kind = edges_angle_kind(e, e2, bv->v);
+ AngleKind ang_kind = edges_angle_kind(e, e2, bv->v);
/* Are we doing special mitering?
* There can only be one outer reflex angle, so only one outer miter,
@@ -3119,7 +3119,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
}
}
else { /* construct == false. */
- int ang_kind = edges_angle_kind(e, e2, bv->v);
+ AngleKind ang_kind = edges_angle_kind(e, e2, bv->v);
if ((miter_outer != BEVEL_MITER_SHARP && !emiter && ang_kind == ANGLE_LARGER) ||
(miter_inner != BEVEL_MITER_SHARP && ang_kind == ANGLE_SMALLER)) {
if (ang_kind == ANGLE_LARGER) {
@@ -4582,13 +4582,13 @@ static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3])
sub_v3_v3v3(edir, e->e->v1->co, e->e->v2->co);
plane_from_point_normal_v3(plane, co, edir);
- float va0[3], vb0[3], vmid0[3];
- closest_to_plane_v3(va0, plane, pro->start);
- closest_to_plane_v3(vb0, plane, pro->end);
- closest_to_plane_v3(vmid0, plane, pro->middle);
+ float start_plane[3], end_plane[3], middle_plane[3];
+ closest_to_plane_v3(start_plane, plane, pro->start);
+ closest_to_plane_v3(end_plane, plane, pro->end);
+ closest_to_plane_v3(middle_plane, plane, pro->middle);
float m[4][4], minv[4][4];
- if (make_unit_square_map(va0, vmid0, vb0, m) && invert_m4_m4(minv, m)) {
+ if (make_unit_square_map(start_plane, middle_plane, end_plane, m) && invert_m4_m4(minv, m)) {
/* Transform co and project it onto superellipse. */
float p[3];
mul_v3_m4v3(p, minv, co);
@@ -4599,9 +4599,9 @@ static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3])
copy_v3_v3(co, snap);
}
else {
- /* Planar case: just snap to line va0--vb0. */
+ /* Planar case: just snap to line start_plane--end_plane. */
float p[3];
- closest_to_line_segment_v3(p, co, va0, vb0);
+ closest_to_line_segment_v3(p, co, start_plane, end_plane);
copy_v3_v3(co, p);
}
}
@@ -4633,7 +4633,7 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe)
if (bp->profile_type == BEVEL_PROFILE_CUSTOM) {
/* Find both profile vertices that correspond to this point. */
float *profile_point_pipe1, *profile_point_pipe2, f;
- if (i == ipipe1 || i == ipipe2) {
+ if (ELEM(i, ipipe1, ipipe2)) {
if (n_bndv == 3 && i == ipipe1) {
/* This part of the vmesh is the triangular corner between the two pipe profiles. */
int ring = max_ii(j, k);
@@ -4942,7 +4942,7 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
copy_v3_v3(bndco, bndv->nv.co);
EdgeHalf *e1 = bndv->efirst;
EdgeHalf *e2 = bndv->elast;
- int ang_kind = ANGLE_STRAIGHT;
+ AngleKind ang_kind = ANGLE_STRAIGHT;
if (e1 && e2) {
ang_kind = edges_angle_kind(e1, e2, bv->v);
}
@@ -6243,7 +6243,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
break;
}
}
- if (bp->offset_type != BEVEL_AMT_PERCENT && bp->offset_type != BEVEL_AMT_ABSOLUTE) {
+ if (!ELEM(bp->offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE)) {
e->offset_r_spec = e->offset_l_spec;
}
if (bp->use_weights) {
@@ -6785,7 +6785,7 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme)
BMIter iter;
BMLoop *l;
BM_ITER_ELEM (l, &iter, r_f, BM_LOOPS_OF_FACE) {
- if (l->v == verts[0] || l->v == verts[2]) {
+ if (ELEM(l->v, verts[0], verts[2])) {
BM_elem_flag_enable(l, BM_ELEM_LONG_TAG);
}
}
@@ -7246,7 +7246,7 @@ 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 (ELEM(bp->offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE)) {
if (ea->is_bev && ebother != NULL && ebother->prev->is_bev) {
if (bp->offset_type == BEVEL_AMT_PERCENT) {
return 50.0f;
diff --git a/source/blender/bmesh/tools/bmesh_boolean.cc b/source/blender/bmesh/tools/bmesh_boolean.cc
index 37010b6f438..39b425a41df 100644
--- a/source/blender/bmesh/tools/bmesh_boolean.cc
+++ b/source/blender/bmesh/tools/bmesh_boolean.cc
@@ -30,8 +30,7 @@
#include "bmesh_boolean.h"
#include "bmesh_edgesplit.h"
-namespace blender {
-namespace meshintersect {
+namespace blender::meshintersect {
#ifdef WITH_GMP
@@ -120,7 +119,8 @@ static bool bmvert_attached_to_wire(const BMVert *bmv)
static bool bmvert_attached_to_hidden_face(BMVert *bmv)
{
BMIter iter;
- for (BMFace *bmf = static_cast<BMFace *>(BM_iter_new(&iter, NULL, BM_FACES_OF_VERT, bmv)); bmf;
+ for (BMFace *bmf = static_cast<BMFace *>(BM_iter_new(&iter, nullptr, BM_FACES_OF_VERT, bmv));
+ bmf;
bmf = static_cast<BMFace *>(BM_iter_step(&iter))) {
if (BM_elem_flag_test(bmf, BM_ELEM_HIDDEN)) {
return true;
@@ -133,7 +133,7 @@ static bool face_has_verts_in_order(BMesh *bm, BMFace *bmf, const BMVert *v1, co
{
BMIter liter;
BMLoop *l = static_cast<BMLoop *>(BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, bmf));
- while (l != NULL) {
+ while (l != nullptr) {
if (l->v == v1 && l->next->v == v2) {
return true;
}
@@ -198,7 +198,7 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden
for (int i = 0; i < 3; ++i) {
co[i] = static_cast<float>(d_co[i]);
}
- BMVert *bmv = BM_vert_create(bm, co, NULL, BM_CREATE_NOP);
+ BMVert *bmv = BM_vert_create(bm, co, nullptr, BM_CREATE_NOP);
new_bmvs[v] = bmv;
BM_elem_flag_enable(bmv, KEEP_FLAG);
any_change = true;
@@ -245,7 +245,7 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden
BMFace *bmf = BM_face_exists(face_bmverts.data(), flen);
/* #BM_face_exists checks if the face exists with the vertices in either order.
* We can only reuse the face if the orientations are the same. */
- if (bmf != NULL && face_has_verts_in_order(bm, bmf, face_bmverts[0], face_bmverts[1])) {
+ if (bmf != nullptr && face_has_verts_in_order(bm, bmf, face_bmverts[0], face_bmverts[1])) {
BM_elem_flag_enable(bmf, KEEP_FLAG);
}
else {
@@ -256,20 +256,20 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden
orig_face = old_bmfs[orig];
}
else {
- orig_face = NULL;
+ orig_face = nullptr;
}
/* Make or find #BMEdge's. */
for (int i = 0; i < flen; ++i) {
BMVert *bmv1 = face_bmverts[i];
BMVert *bmv2 = face_bmverts[(i + 1) % flen];
BMEdge *bme = BM_edge_exists(bmv1, bmv2);
- if (bme == NULL) {
- BMEdge *orig_edge = NULL;
+ if (bme == nullptr) {
+ BMEdge *orig_edge = nullptr;
if (face.edge_orig[i] != NO_INDEX) {
orig_edge = old_edges[face.edge_orig[i]];
}
bme = BM_edge_create(bm, bmv1, bmv2, orig_edge, BM_CREATE_NOP);
- if (orig_edge != NULL) {
+ if (orig_edge != nullptr) {
BM_elem_select_copy(bm, bme, orig_edge);
}
}
@@ -283,15 +283,15 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden
}
BMFace *bmf = BM_face_create(
bm, face_bmverts.data(), face_bmedges.data(), flen, orig_face, BM_CREATE_NOP);
- if (orig_face != NULL) {
+ if (orig_face != nullptr) {
BM_elem_select_copy(bm, bmf, orig_face);
}
BM_elem_flag_enable(bmf, KEEP_FLAG);
/* Now do interpolation of loop data (e.g., UV's) using the example face. */
- if (orig_face != NULL) {
+ if (orig_face != nullptr) {
BMIter liter;
BMLoop *l = static_cast<BMLoop *>(BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, bmf));
- while (l != NULL) {
+ while (l != nullptr) {
BM_loop_interp_from_face(bm, l, orig_face, true, true);
l = static_cast<BMLoop *>(BM_iter_step(&liter));
}
@@ -304,8 +304,8 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden
/* #BM_ITER_MESH_MUTABLE macro needs type casts for C++, so expand here.
* TODO(howard): make some nice C++ iterators for #BMesh. */
BMIter iter;
- BMFace *bmf = static_cast<BMFace *>(BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL));
- while (bmf != NULL) {
+ BMFace *bmf = static_cast<BMFace *>(BM_iter_new(&iter, bm, BM_FACES_OF_MESH, nullptr));
+ while (bmf != nullptr) {
# ifdef DEBUG
iter.count = BM_iter_mesh_count(BM_FACES_OF_MESH, bm);
# endif
@@ -322,8 +322,8 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden
}
bmf = bmf_next;
}
- BMVert *bmv = static_cast<BMVert *>(BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL));
- while (bmv != NULL) {
+ BMVert *bmv = static_cast<BMVert *>(BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, nullptr));
+ while (bmv != nullptr) {
# ifdef DEBUG
iter.count = BM_iter_mesh_count(BM_VERTS_OF_MESH, bm);
# endif
@@ -389,8 +389,7 @@ static bool bmesh_boolean(BMesh *bm,
#endif // WITH_GMP
-} // namespace meshintersect
-} // namespace blender
+} // namespace blender::meshintersect
extern "C" {
/**
@@ -493,7 +492,7 @@ bool BM_mesh_boolean_knife(BMesh *UNUSED(bm),
const int UNUSED(nshapes),
const bool UNUSED(use_self),
const bool UNUSED(use_separate_all),
- const bool UNUSED(keep_boolean))
+ const bool UNUSED(keep_hidden))
{
UNUSED_VARS(looptris, test_fn);
return false;
diff --git a/source/blender/bmesh/tools/bmesh_edgenet.c b/source/blender/bmesh/tools/bmesh_edgenet.c
index 9f4327fd1e3..c332d88e83b 100644
--- a/source/blender/bmesh/tools/bmesh_edgenet.c
+++ b/source/blender/bmesh/tools/bmesh_edgenet.c
@@ -51,7 +51,7 @@ enum {
*/
static bool bm_edge_step_ok(BMEdge *e)
{
- return BM_elem_flag_test(e, BM_ELEM_TAG) && ((e->l == NULL) || (e->l->radial_next == e->l));
+ return BM_elem_flag_test(e, BM_ELEM_TAG) && (ELEM(e->l, NULL, e->l->radial_next));
}
static int bm_edge_face(BMEdge *e)
diff --git a/source/blender/bmesh/tools/bmesh_path_region.c b/source/blender/bmesh/tools/bmesh_path_region.c
index f8e981bbd58..23be3cdf117 100644
--- a/source/blender/bmesh/tools/bmesh_path_region.c
+++ b/source/blender/bmesh/tools/bmesh_path_region.c
@@ -74,6 +74,7 @@ static bool bm_vert_pair_ends(BMVert *v_pivot, BMVert *v_end_pair[2])
}
#endif /* USE_EDGE_CHAIN */
+/* -------------------------------------------------------------------- */
/** \name Vertex in Region Checks
* \{ */
@@ -386,6 +387,7 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm,
#undef USE_EDGE_CHAIN
+/* -------------------------------------------------------------------- */
/** \name Main Functions (exposed externally).
* \{ */
diff --git a/source/blender/bmesh/tools/bmesh_path_region_uv.c b/source/blender/bmesh/tools/bmesh_path_region_uv.c
index d036c20d0e4..517913b5b56 100644
--- a/source/blender/bmesh/tools/bmesh_path_region_uv.c
+++ b/source/blender/bmesh/tools/bmesh_path_region_uv.c
@@ -72,6 +72,7 @@ static bool bm_loop_pair_ends(BMLoop *l_pivot, BMLoop *l_end_pair[2])
}
#endif /* USE_EDGE_CHAIN */
+/* -------------------------------------------------------------------- */
/** \name Loop Vertex in Region Checks
* \{ */
@@ -403,6 +404,7 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm,
#undef USE_EDGE_CHAIN
+/* -------------------------------------------------------------------- */
/** \name Main Functions (exposed externally).
* \{ */
diff --git a/source/blender/bmesh/tools/bmesh_region_match.c b/source/blender/bmesh/tools/bmesh_region_match.c
index d222ea214c4..561b00544b5 100644
--- a/source/blender/bmesh/tools/bmesh_region_match.c
+++ b/source/blender/bmesh/tools/bmesh_region_match.c
@@ -67,8 +67,6 @@
#include "BLI_strict_flags.h"
/* -------------------------------------------------------------------- */
-/* UUID-Walk API */
-
/** \name Internal UUIDWalk API
* \{ */
@@ -615,6 +613,7 @@ static uint bm_uuidwalk_init_from_edge(UUIDWalk *uuidwalk, BMEdge *e)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Internal UUIDFaceStep API
* \{ */
@@ -907,6 +906,7 @@ static void bm_face_array_visit(BMFace **faces,
#ifdef USE_PIVOT_SEARCH
+/* -------------------------------------------------------------------- */
/** \name Internal UUIDWalk API
* \{ */
@@ -1226,11 +1226,11 @@ static BMEdge *bm_face_region_pivot_edge_find(BMFace **faces_region,
#endif /* USE_PIVOT_SEARCH */
-/* -------------------------------------------------------------------- */
/* Quick UUID pass - identify candidates */
#ifdef USE_PIVOT_FASTMATCH
+/* -------------------------------------------------------------------- */
/** \name Fast Match
* \{ */
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index d524f4a0e1e..fec98f58261 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -34,8 +34,8 @@ set(INC
../windowmanager
../nodes/composite
../nodes/intern
- ../render/extern/include
- ../render/intern/include
+ ../render
+ ../render/intern
../../../extern/clew/include
../../../intern/atomic
../../../intern/guardedalloc
@@ -353,6 +353,8 @@ set(SRC
operations/COM_KeyingDespillOperation.h
operations/COM_KeyingOperation.cpp
operations/COM_KeyingOperation.h
+ operations/COM_KeyingSetAlphaOperation.cpp
+ operations/COM_KeyingSetAlphaOperation.h
operations/COM_ColorSpillOperation.cpp
operations/COM_ColorSpillOperation.h
diff --git a/source/blender/compositor/intern/COM_CPUDevice.cpp b/source/blender/compositor/intern/COM_CPUDevice.cpp
index bcb14e4dbb2..7ea12866148 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.cpp
+++ b/source/blender/compositor/intern/COM_CPUDevice.cpp
@@ -18,7 +18,7 @@
#include "COM_CPUDevice.h"
-CPUDevice::CPUDevice(int thread_id) : Device(), m_thread_id(thread_id)
+CPUDevice::CPUDevice(int thread_id) : m_thread_id(thread_id)
{
}
@@ -32,5 +32,5 @@ void CPUDevice::execute(WorkPackage *work)
executionGroup->getOutputOperation()->executeRegion(&rect, chunkNumber);
- executionGroup->finalizeChunkExecution(chunkNumber, NULL);
+ executionGroup->finalizeChunkExecution(chunkNumber, nullptr);
}
diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp
index 3d55fcba086..52e705ffb79 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.cpp
+++ b/source/blender/compositor/intern/COM_CompositorContext.cpp
@@ -22,13 +22,13 @@
CompositorContext::CompositorContext()
{
- this->m_scene = NULL;
- this->m_rd = NULL;
+ this->m_scene = nullptr;
+ this->m_rd = nullptr;
this->m_quality = COM_QUALITY_HIGH;
this->m_hasActiveOpenCLDevices = false;
this->m_fastCalculation = false;
- this->m_viewSettings = NULL;
- this->m_displaySettings = NULL;
+ this->m_viewSettings = nullptr;
+ this->m_displaySettings = nullptr;
}
int CompositorContext::getFramenumber() const
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index 60676ee42b7..f7250de8566 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -116,21 +116,28 @@
bool Converter::is_fast_node(bNode *b_node)
{
- return !(b_node->type == CMP_NODE_BLUR || b_node->type == CMP_NODE_VECBLUR ||
- b_node->type == CMP_NODE_BILATERALBLUR || b_node->type == CMP_NODE_DEFOCUS ||
- b_node->type == CMP_NODE_BOKEHBLUR || b_node->type == CMP_NODE_GLARE ||
- b_node->type == CMP_NODE_DBLUR || b_node->type == CMP_NODE_MOVIEDISTORTION ||
- b_node->type == CMP_NODE_LENSDIST || b_node->type == CMP_NODE_DOUBLEEDGEMASK ||
- b_node->type == CMP_NODE_DILATEERODE || b_node->type == CMP_NODE_DENOISE);
+ return !ELEM(b_node->type,
+ CMP_NODE_BLUR,
+ CMP_NODE_VECBLUR,
+ CMP_NODE_BILATERALBLUR,
+ CMP_NODE_DEFOCUS,
+ CMP_NODE_BOKEHBLUR,
+ CMP_NODE_GLARE,
+ CMP_NODE_DBLUR,
+ CMP_NODE_MOVIEDISTORTION,
+ CMP_NODE_LENSDIST,
+ CMP_NODE_DOUBLEEDGEMASK,
+ CMP_NODE_DILATEERODE,
+ CMP_NODE_DENOISE);
}
Node *Converter::convert(bNode *b_node)
{
- Node *node = NULL;
+ Node *node = nullptr;
/* ignore undefined nodes with missing or invalid node data */
if (!nodeIsRegistered(b_node)) {
- return NULL;
+ return nullptr;
}
switch (b_node->type) {
@@ -432,7 +439,7 @@ NodeOperation *Converter::convertDataType(NodeOperationOutput *from, NodeOperati
return new ConvertVectorToColorOperation();
}
- return NULL;
+ return nullptr;
}
void Converter::convertResolution(NodeOperationBuilder &builder,
@@ -491,8 +498,8 @@ void Converter::convertResolution(NodeOperationBuilder &builder,
}
if (doCenter) {
- NodeOperation *first = NULL;
- ScaleOperation *scaleOperation = NULL;
+ NodeOperation *first = nullptr;
+ ScaleOperation *scaleOperation = nullptr;
if (doScale) {
scaleOperation = new ScaleOperation();
scaleOperation->getInputSocket(1)->setResizeMode(COM_SC_NO_RESIZE);
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index ad980177ae5..27cec28f5d5 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -45,8 +45,8 @@ ExecutionGroup::ExecutionGroup()
{
this->m_isOutput = false;
this->m_complex = false;
- this->m_chunkExecutionStates = NULL;
- this->m_bTree = NULL;
+ this->m_chunkExecutionStates = nullptr;
+ this->m_bTree = nullptr;
this->m_height = 0;
this->m_width = 0;
this->m_cachedMaxReadBufferOffset = 0;
@@ -121,13 +121,13 @@ NodeOperation *ExecutionGroup::getOutputOperation() const
void ExecutionGroup::initExecution()
{
- if (this->m_chunkExecutionStates != NULL) {
+ if (this->m_chunkExecutionStates != nullptr) {
MEM_freeN(this->m_chunkExecutionStates);
}
unsigned int index;
determineNumberOfChunks();
- this->m_chunkExecutionStates = NULL;
+ this->m_chunkExecutionStates = nullptr;
if (this->m_numberOfChunks != 0) {
this->m_chunkExecutionStates = (ChunkExecutionState *)MEM_mallocN(
sizeof(ChunkExecutionState) * this->m_numberOfChunks, __func__);
@@ -152,15 +152,15 @@ void ExecutionGroup::initExecution()
void ExecutionGroup::deinitExecution()
{
- if (this->m_chunkExecutionStates != NULL) {
+ if (this->m_chunkExecutionStates != nullptr) {
MEM_freeN(this->m_chunkExecutionStates);
- this->m_chunkExecutionStates = NULL;
+ this->m_chunkExecutionStates = nullptr;
}
this->m_numberOfChunks = 0;
this->m_numberOfXChunks = 0;
this->m_numberOfYChunks = 0;
this->m_cachedReadOperations.clear();
- this->m_bTree = NULL;
+ this->m_bTree = nullptr;
}
void ExecutionGroup::determineResolution(unsigned int resolution[2])
{
@@ -415,7 +415,7 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo
MemoryBuffer *buffer = memoryBuffers[index];
if (buffer) {
if (buffer->isTemporarily()) {
- memoryBuffers[index] = NULL;
+ memoryBuffers[index] = nullptr;
delete buffer;
}
}
@@ -478,7 +478,7 @@ MemoryBuffer *ExecutionGroup::allocateOutputBuffer(int /*chunkNumber*/, rcti *re
MemoryBuffer *buffer = new MemoryBuffer(writeOperation->getMemoryProxy(), rect);
return buffer;
}
- return NULL;
+ return nullptr;
}
bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area)
@@ -562,7 +562,7 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, int xChun
determineDependingAreaOfInterest(&rect, readOperation, &area);
ExecutionGroup *group = memoryProxy->getExecutor();
- if (group != NULL) {
+ if (group != nullptr) {
if (!group->scheduleAreaWhenPossible(graph, &area)) {
canBeExecuted = false;
}
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
index f58d7a768cc..a13db6bb09e 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -83,7 +83,7 @@ MemoryBuffer::MemoryBuffer(DataType dataType, rcti *rect)
this->m_width = BLI_rcti_size_x(&this->m_rect);
this->m_height = BLI_rcti_size_y(&this->m_rect);
this->m_height = this->m_rect.ymax - this->m_rect.ymin;
- this->m_memoryProxy = NULL;
+ this->m_memoryProxy = nullptr;
this->m_chunkNumber = -1;
this->m_num_channels = determine_num_channels(dataType);
this->m_buffer = (float *)MEM_mallocN_aligned(
@@ -145,7 +145,7 @@ MemoryBuffer::~MemoryBuffer()
{
if (this->m_buffer) {
MEM_freeN(this->m_buffer);
- this->m_buffer = NULL;
+ this->m_buffer = nullptr;
}
}
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.cpp b/source/blender/compositor/intern/COM_MemoryProxy.cpp
index b73bac469d0..7d590cd0ef6 100644
--- a/source/blender/compositor/intern/COM_MemoryProxy.cpp
+++ b/source/blender/compositor/intern/COM_MemoryProxy.cpp
@@ -20,8 +20,8 @@
MemoryProxy::MemoryProxy(DataType datatype)
{
- this->m_writeBufferOperation = NULL;
- this->m_executor = NULL;
+ this->m_writeBufferOperation = nullptr;
+ this->m_executor = nullptr;
this->m_datatype = datatype;
}
@@ -40,6 +40,6 @@ void MemoryProxy::free()
{
if (this->m_buffer) {
delete this->m_buffer;
- this->m_buffer = NULL;
+ this->m_buffer = nullptr;
}
}
diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp
index 30ebd7e0d4b..74aefaf0e6d 100644
--- a/source/blender/compositor/intern/COM_Node.cpp
+++ b/source/blender/compositor/intern/COM_Node.cpp
@@ -37,14 +37,14 @@
**************/
Node::Node(bNode *editorNode, bool create_sockets)
- : m_editorNodeTree(NULL),
+ : m_editorNodeTree(nullptr),
m_editorNode(editorNode),
m_inActiveGroup(false),
m_instanceKey(NODE_INSTANCE_KEY_NONE)
{
if (create_sockets) {
bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first;
- while (input != NULL) {
+ while (input != nullptr) {
DataType dt = COM_DT_VALUE;
if (input->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
@@ -57,7 +57,7 @@ Node::Node(bNode *editorNode, bool create_sockets)
input = input->next;
}
bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first;
- while (output != NULL) {
+ while (output != nullptr) {
DataType dt = COM_DT_VALUE;
if (output->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
@@ -86,7 +86,7 @@ Node::~Node()
void Node::addInputSocket(DataType datatype)
{
- this->addInputSocket(datatype, NULL);
+ this->addInputSocket(datatype, nullptr);
}
void Node::addInputSocket(DataType datatype, bNodeSocket *bSocket)
@@ -97,7 +97,7 @@ void Node::addInputSocket(DataType datatype, bNodeSocket *bSocket)
void Node::addOutputSocket(DataType datatype)
{
- this->addOutputSocket(datatype, NULL);
+ this->addOutputSocket(datatype, nullptr);
}
void Node::addOutputSocket(DataType datatype, bNodeSocket *bSocket)
{
@@ -121,27 +121,27 @@ bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex)
{
bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->inputs.first;
int index = 0;
- while (bSock != NULL) {
+ while (bSock != nullptr) {
if (index == editorNodeInputSocketIndex) {
return bSock;
}
index++;
bSock = bSock->next;
}
- return NULL;
+ return nullptr;
}
bNodeSocket *Node::getEditorOutputSocket(int editorNodeOutputSocketIndex)
{
bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->outputs.first;
int index = 0;
- while (bSock != NULL) {
+ while (bSock != nullptr) {
if (index == editorNodeOutputSocketIndex) {
return bSock;
}
index++;
bSock = bSock->next;
}
- return NULL;
+ return nullptr;
}
/*******************
@@ -149,7 +149,7 @@ bNodeSocket *Node::getEditorOutputSocket(int editorNodeOutputSocketIndex)
*******************/
NodeInput::NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype)
- : m_node(node), m_editorSocket(b_socket), m_datatype(datatype), m_link(NULL)
+ : m_node(node), m_editorSocket(b_socket), m_datatype(datatype), m_link(nullptr)
{
}
diff --git a/source/blender/compositor/intern/COM_NodeGraph.cpp b/source/blender/compositor/intern/COM_NodeGraph.cpp
index fe680f61a90..b604b8ced88 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.cpp
+++ b/source/blender/compositor/intern/COM_NodeGraph.cpp
@@ -61,7 +61,7 @@ bNodeSocket *NodeGraph::find_b_node_input(bNode *b_node, const char *identifier)
return b_sock;
}
}
- return NULL;
+ return nullptr;
}
bNodeSocket *NodeGraph::find_b_node_output(bNode *b_node, const char *identifier)
@@ -71,7 +71,7 @@ bNodeSocket *NodeGraph::find_b_node_output(bNode *b_node, const char *identifier
return b_sock;
}
}
- return NULL;
+ return nullptr;
}
void NodeGraph::add_node(Node *node,
@@ -179,7 +179,7 @@ NodeOutput *NodeGraph::find_output(const NodeRange &node_range, bNodeSocket *b_s
}
}
}
- return NULL;
+ return nullptr;
}
void NodeGraph::add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink)
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp
index 4e3c5d2df6c..0842721a9e5 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperation.cpp
@@ -36,7 +36,7 @@ NodeOperation::NodeOperation()
this->m_height = 0;
this->m_isResolutionSet = false;
this->m_openCL = false;
- this->m_btree = NULL;
+ this->m_btree = nullptr;
}
NodeOperation::~NodeOperation()
@@ -146,7 +146,7 @@ NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex)
return &input->getLink()->getOperation();
}
- return NULL;
+ return nullptr;
}
void NodeOperation::getConnectedInputSockets(Inputs *sockets)
@@ -199,7 +199,7 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input,
NodeOperationInput::NodeOperationInput(NodeOperation *op,
DataType datatype,
InputResizeMode resizeMode)
- : m_operation(op), m_datatype(datatype), m_resizeMode(resizeMode), m_link(NULL)
+ : m_operation(op), m_datatype(datatype), m_resizeMode(resizeMode), m_link(nullptr)
{
}
@@ -209,7 +209,7 @@ SocketReader *NodeOperationInput::getReader()
return &m_link->getOperation();
}
- return NULL;
+ return nullptr;
}
void NodeOperationInput::determineResolution(unsigned int resolution[2],
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
index 53a6d115e97..1237e728079 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
@@ -38,7 +38,7 @@
#include "COM_NodeOperationBuilder.h" /* own include */
NodeOperationBuilder::NodeOperationBuilder(const CompositorContext *context, bNodeTree *b_nodetree)
- : m_context(context), m_current_node(NULL), m_active_viewer(NULL)
+ : m_context(context), m_current_node(nullptr), m_active_viewer(nullptr)
{
m_graph.from_bNodeTree(*context, b_nodetree);
}
@@ -61,7 +61,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
node->convertToOperations(converter, *m_context);
}
- m_current_node = NULL;
+ m_current_node = nullptr;
/* The input map constructed by nodes maps operation inputs to node inputs.
* Inverting yields a map of node inputs to all connected operation inputs,
@@ -168,7 +168,7 @@ void NodeOperationBuilder::removeInputLink(NodeOperationInput *to)
Link &link = *it;
if (link.to() == to) {
/* unregister with the input */
- to->setLink(NULL);
+ to->setLink(nullptr);
m_links.erase(it);
return;
@@ -203,15 +203,15 @@ PreviewOperation *NodeOperationBuilder::make_preview_operation() const
BLI_assert(m_current_node);
if (!(m_current_node->getbNode()->flag & NODE_PREVIEW)) {
- return NULL;
+ return nullptr;
}
/* previews only in the active group */
if (!m_current_node->isInActiveGroup()) {
- return NULL;
+ return nullptr;
}
/* do not calculate previews of hidden nodes */
if (m_current_node->getbNode()->flag & NODE_HIDDEN) {
- return NULL;
+ return nullptr;
}
bNodeInstanceHash *previews = m_context->getPreviewHash();
@@ -223,7 +223,7 @@ PreviewOperation *NodeOperationBuilder::make_preview_operation() const
return operation;
}
- return NULL;
+ return nullptr;
}
void NodeOperationBuilder::addPreview(NodeOperationOutput *output)
@@ -476,7 +476,7 @@ WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation
}
}
}
- return NULL;
+ return nullptr;
}
void NodeOperationBuilder::add_input_buffers(NodeOperation * /*operation*/,
@@ -526,13 +526,13 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
return;
}
- WriteBufferOperation *writeOperation = NULL;
+ WriteBufferOperation *writeOperation = nullptr;
for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
NodeOperationInput *target = *it;
/* try to find existing write buffer operation */
if (target->getOperation().isWriteBufferOperation()) {
- BLI_assert(writeOperation == NULL); /* there should only be one write op connected */
+ BLI_assert(writeOperation == nullptr); /* there should only be one write op connected */
writeOperation = (WriteBufferOperation *)(&target->getOperation());
}
else {
@@ -728,7 +728,7 @@ void NodeOperationBuilder::group_operations()
ReadBufferOperation *read_op = (ReadBufferOperation *)op;
MemoryProxy *memproxy = read_op->getMemoryProxy();
- if (memproxy->getExecutor() == NULL) {
+ if (memproxy->getExecutor() == nullptr) {
ExecutionGroup *group = make_group(memproxy->getWriteBufferOperation());
memproxy->setExecutor(group);
}
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
index 2529637801d..51ae9d6652e 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
@@ -41,7 +41,7 @@ OpenCLDevice::OpenCLDevice(cl_context context,
this->m_device = device;
this->m_context = context;
this->m_program = program;
- this->m_queue = NULL;
+ this->m_queue = nullptr;
this->m_vendorID = vendorId;
}
@@ -196,7 +196,8 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemo
(size_t)outputMemoryBuffer->getHeight(),
};
- error = clEnqueueNDRangeKernel(this->m_queue, kernel, 2, NULL, size, 0, 0, 0, NULL);
+ error = clEnqueueNDRangeKernel(
+ this->m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
@@ -243,7 +244,8 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel,
if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
- error = clEnqueueNDRangeKernel(this->m_queue, kernel, 2, NULL, size, 0, 0, 0, NULL);
+ error = clEnqueueNDRangeKernel(
+ this->m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
index 029be6d44b1..5febf3802de 100644
--- a/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
+++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
@@ -18,9 +18,9 @@
#include "COM_SingleThreadedOperation.h"
-SingleThreadedOperation::SingleThreadedOperation() : NodeOperation()
+SingleThreadedOperation::SingleThreadedOperation()
{
- this->m_cachedInstance = NULL;
+ this->m_cachedInstance = nullptr;
setComplex(true);
}
@@ -39,7 +39,7 @@ void SingleThreadedOperation::deinitExecution()
deinitMutex();
if (this->m_cachedInstance) {
delete this->m_cachedInstance;
- this->m_cachedInstance = NULL;
+ this->m_cachedInstance = nullptr;
}
}
void *SingleThreadedOperation::initializeTileData(rcti *rect)
@@ -49,7 +49,7 @@ void *SingleThreadedOperation::initializeTileData(rcti *rect)
}
lockMutex();
- if (this->m_cachedInstance == NULL) {
+ if (this->m_cachedInstance == nullptr) {
//
this->m_cachedInstance = createMemoryBuffer(rect);
}
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index 570e1eeba20..450b64eec5a 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -80,7 +80,7 @@ void *WorkScheduler::thread_execute_cpu(void *data)
delete work;
}
- return NULL;
+ return nullptr;
}
void *WorkScheduler::thread_execute_gpu(void *data)
@@ -93,7 +93,7 @@ void *WorkScheduler::thread_execute_gpu(void *data)
delete work;
}
- return NULL;
+ return nullptr;
}
#endif
@@ -166,13 +166,13 @@ void WorkScheduler::stop()
BLI_thread_queue_nowait(g_cpuqueue);
BLI_threadpool_end(&g_cputhreads);
BLI_thread_queue_free(g_cpuqueue);
- g_cpuqueue = NULL;
+ g_cpuqueue = nullptr;
# ifdef COM_OPENCL_ENABLED
if (g_openclActive) {
BLI_thread_queue_nowait(g_gpuqueue);
BLI_threadpool_end(&g_gputhreads);
BLI_thread_queue_free(g_gpuqueue);
- g_gpuqueue = NULL;
+ g_gpuqueue = nullptr;
}
# endif
#endif
@@ -234,8 +234,8 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
# ifdef COM_OPENCL_ENABLED
/* deinitialize OpenCL GPU's */
if (use_opencl && !g_openclInitialized) {
- g_context = NULL;
- g_program = NULL;
+ g_context = nullptr;
+ g_program = nullptr;
/* This will check for errors and skip if already initialized. */
if (clewInit() != CLEW_SUCCESS) {
@@ -245,7 +245,7 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
if (clCreateContextFromType) {
cl_uint numberOfPlatforms = 0;
cl_int error;
- error = clGetPlatformIDs(0, 0, &numberOfPlatforms);
+ error = clGetPlatformIDs(0, nullptr, &numberOfPlatforms);
if (error == -1001) {
} /* GPU not supported */
else if (error != CL_SUCCESS) {
@@ -256,40 +256,40 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
}
cl_platform_id *platforms = (cl_platform_id *)MEM_mallocN(
sizeof(cl_platform_id) * numberOfPlatforms, __func__);
- error = clGetPlatformIDs(numberOfPlatforms, platforms, 0);
+ error = clGetPlatformIDs(numberOfPlatforms, platforms, nullptr);
unsigned int indexPlatform;
for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) {
cl_platform_id platform = platforms[indexPlatform];
cl_uint numberOfDevices = 0;
- clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices);
+ clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, nullptr, &numberOfDevices);
if (numberOfDevices <= 0) {
continue;
}
cl_device_id *cldevices = (cl_device_id *)MEM_mallocN(
sizeof(cl_device_id) * numberOfDevices, __func__);
- clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, 0);
+ clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, nullptr);
g_context = clCreateContext(
- NULL, numberOfDevices, cldevices, clContextError, NULL, &error);
+ nullptr, numberOfDevices, cldevices, clContextError, nullptr, &error);
if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
- const char *cl_str[2] = {datatoc_COM_OpenCLKernels_cl, NULL};
- g_program = clCreateProgramWithSource(g_context, 1, cl_str, 0, &error);
- error = clBuildProgram(g_program, numberOfDevices, cldevices, 0, 0, 0);
+ const char *cl_str[2] = {datatoc_COM_OpenCLKernels_cl, nullptr};
+ g_program = clCreateProgramWithSource(g_context, 1, cl_str, nullptr, &error);
+ error = clBuildProgram(g_program, numberOfDevices, cldevices, nullptr, nullptr, nullptr);
if (error != CL_SUCCESS) {
cl_int error2;
size_t ret_val_size = 0;
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
error2 = clGetProgramBuildInfo(
- g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
+ g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, nullptr, &ret_val_size);
if (error2 != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
char *build_log = (char *)MEM_mallocN(sizeof(char) * ret_val_size + 1, __func__);
error2 = clGetProgramBuildInfo(
- g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
+ g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, nullptr);
if (error2 != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
@@ -303,7 +303,7 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
cl_device_id device = cldevices[indexDevices];
cl_int vendorID = 0;
cl_int error2 = clGetDeviceInfo(
- device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, NULL);
+ device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, nullptr);
if (error2 != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error2, clewErrorString(error2));
}
@@ -351,11 +351,11 @@ void WorkScheduler::deinitialize()
}
if (g_program) {
clReleaseProgram(g_program);
- g_program = NULL;
+ g_program = nullptr;
}
if (g_context) {
clReleaseContext(g_context);
- g_context = NULL;
+ g_context = nullptr;
}
g_openclInitialized = false;
diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp
index 808c1b22bdb..b82bede8443 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BlurNode.cpp
@@ -46,7 +46,7 @@ void BlurNode::convertToOperations(NodeConverter &converter,
const bool extend_bounds = (editorNode->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0;
CompositorQuality quality = context.getQuality();
- NodeOperation *input_operation = NULL, *output_operation = NULL;
+ NodeOperation *input_operation = nullptr, *output_operation = nullptr;
if (data->filtertype == R_FILTER_FAST_GAUSS) {
FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation();
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
index d320a6645e1..c927865489b 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
@@ -36,7 +36,7 @@ void ChannelMatteNode::convertToOperations(NodeConverter &converter,
NodeOutput *outputSocketImage = this->getOutputSocket(0);
NodeOutput *outputSocketMatte = this->getOutputSocket(1);
- NodeOperation *convert = NULL, *inv_convert = NULL;
+ NodeOperation *convert = nullptr, *inv_convert = nullptr;
/* colorspace */
switch (node->custom1) {
case CMP_NODE_CHANNEL_MATTE_CS_RGB:
@@ -67,7 +67,7 @@ void ChannelMatteNode::convertToOperations(NodeConverter &converter,
SetAlphaOperation *operationAlpha = new SetAlphaOperation();
converter.addOperation(operationAlpha);
- if (convert != NULL) {
+ if (convert != nullptr) {
converter.addOperation(convert);
converter.mapInputSocket(inputSocketImage, convert->getInputSocket(0));
@@ -82,7 +82,7 @@ void ChannelMatteNode::convertToOperations(NodeConverter &converter,
converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0));
converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
- if (inv_convert != NULL) {
+ if (inv_convert != nullptr) {
converter.addOperation(inv_convert);
converter.addLink(operationAlpha->getOutputSocket(0), inv_convert->getInputSocket(0));
converter.mapOutputSocket(outputSocketImage, inv_convert->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_CombineColorNode.cpp b/source/blender/compositor/nodes/COM_CombineColorNode.cpp
index 2f9b14db6af..12968f06a10 100644
--- a/source/blender/compositor/nodes/COM_CombineColorNode.cpp
+++ b/source/blender/compositor/nodes/COM_CombineColorNode.cpp
@@ -67,7 +67,7 @@ void CombineColorNode::convertToOperations(NodeConverter &converter,
NodeOperation *CombineRGBANode::getColorConverter(const CompositorContext & /*context*/) const
{
- return NULL; /* no conversion needed */
+ return nullptr; /* no conversion needed */
}
NodeOperation *CombineHSVANode::getColorConverter(const CompositorContext & /*context*/) const
diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
index da8985de5ac..2921b44c95b 100644
--- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
+++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
@@ -23,7 +23,7 @@
void ConvertAlphaNode::convertToOperations(NodeConverter &converter,
const CompositorContext & /*context*/) const
{
- NodeOperation *operation = NULL;
+ NodeOperation *operation = nullptr;
bNode *node = this->getbNode();
/* value hardcoded in rna_nodetree.c */
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp
index 0f09e5bfc91..393b1f2dabb 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.cpp
+++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp
@@ -41,7 +41,7 @@ void DefocusNode::convertToOperations(NodeConverter &converter,
bNode *node = this->getbNode();
NodeDefocus *data = (NodeDefocus *)node->storage;
Scene *scene = node->id ? (Scene *)node->id : context.getScene();
- Object *camob = scene ? scene->camera : NULL;
+ Object *camob = scene ? scene->camera : nullptr;
NodeOperation *radiusOperation;
if (data->no_zbuf) {
diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp
index 8b8ff55d544..1147c11794f 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.cpp
+++ b/source/blender/compositor/nodes/COM_FilterNode.cpp
@@ -34,7 +34,7 @@ void FilterNode::convertToOperations(NodeConverter &converter,
NodeInput *inputSocket = this->getInputSocket(0);
NodeInput *inputImageSocket = this->getInputSocket(1);
NodeOutput *outputSocket = this->getOutputSocket(0);
- ConvolutionFilterOperation *operation = NULL;
+ ConvolutionFilterOperation *operation = nullptr;
switch (this->getbNode()->custom1) {
case CMP_FILT_SOFT:
diff --git a/source/blender/compositor/nodes/COM_GlareNode.cpp b/source/blender/compositor/nodes/COM_GlareNode.cpp
index 1ff058ce7d4..ef088e42205 100644
--- a/source/blender/compositor/nodes/COM_GlareNode.cpp
+++ b/source/blender/compositor/nodes/COM_GlareNode.cpp
@@ -38,7 +38,7 @@ void GlareNode::convertToOperations(NodeConverter &converter,
bNode *node = this->getbNode();
NodeGlare *glare = (NodeGlare *)node->storage;
- GlareBaseOperation *glareoperation = NULL;
+ GlareBaseOperation *glareoperation = nullptr;
switch (glare->type) {
default:
case 3:
diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp
index 1662b81c265..596a448e6a0 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_ImageNode.cpp
@@ -44,7 +44,7 @@ NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter,
DataType datatype) const
{
NodeOutput *outputSocket = this->getOutputSocket(outputsocketIndex);
- MultilayerBaseOperation *operation = NULL;
+ MultilayerBaseOperation *operation = nullptr;
switch (datatype) {
case COM_DT_VALUE:
operation = new MultilayerValueOperation(passindex, view);
@@ -84,7 +84,7 @@ void ImageNode::convertToOperations(NodeConverter &converter,
/* force a load, we assume iuser index will be set OK anyway */
if (image && image->type == IMA_TYPE_MULTILAYER) {
bool is_multilayer_ok = false;
- ImBuf *ibuf = BKE_image_acquire_ibuf(image, imageuser, NULL);
+ ImBuf *ibuf = BKE_image_acquire_ibuf(image, imageuser, nullptr);
if (image->rr) {
RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer);
if (rl) {
@@ -94,7 +94,7 @@ void ImageNode::convertToOperations(NodeConverter &converter,
is_multilayer_ok = true;
for (index = 0; index < numberOfOutputs; index++) {
- NodeOperation *operation = NULL;
+ NodeOperation *operation = nullptr;
socket = this->getOutputSocket(index);
bNodeSocket *bnodeSocket = socket->getbNodeSocket();
NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;
@@ -196,13 +196,13 @@ void ImageNode::convertToOperations(NodeConverter &converter,
}
/* In case we can't load the layer. */
- if (operation == NULL) {
+ if (operation == nullptr) {
converter.setInvalidOutput(getOutputSocket(index));
}
}
}
}
- BKE_image_release_ibuf(image, ibuf, NULL);
+ BKE_image_release_ibuf(image, ibuf, nullptr);
/* without this, multilayer that fail to load will crash blender T32490. */
if (is_multilayer_ok == false) {
@@ -263,7 +263,7 @@ void ImageNode::convertToOperations(NodeConverter &converter,
/* happens when unlinking image datablock from multilayer node */
for (int i = 3; i < numberOfOutputs; i++) {
NodeOutput *output = this->getOutputSocket(i);
- NodeOperation *operation = NULL;
+ NodeOperation *operation = nullptr;
switch (output->getDataType()) {
case COM_DT_VALUE: {
SetValueOperation *valueoperation = new SetValueOperation();
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp
index b75d06763b7..9f0cdcbd552 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.cpp
+++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp
@@ -32,7 +32,7 @@
#include "COM_DilateErodeOperation.h"
-#include "COM_SetAlphaOperation.h"
+#include "COM_KeyingSetAlphaOperation.h"
#include "COM_GaussianAlphaXBlurOperation.h"
#include "COM_GaussianAlphaYBlurOperation.h"
@@ -63,7 +63,7 @@ NodeOperationOutput *KeyingNode::setupPreBlur(NodeConverter &converter,
converter.addLink(convertRGBToYCCOperation->getOutputSocket(0),
separateOperation->getInputSocket(0));
- if (channel == 0 || channel == 3) {
+ if (ELEM(channel, 0, 3)) {
converter.addLink(separateOperation->getOutputSocket(0),
combineOperation->getInputSocket(channel));
}
@@ -228,7 +228,8 @@ void KeyingNode::convertToOperations(NodeConverter &converter,
NodeOutput *outputImage = this->getOutputSocket(0);
NodeOutput *outputMatte = this->getOutputSocket(1);
NodeOutput *outputEdges = this->getOutputSocket(2);
- NodeOperationOutput *postprocessedMatte = NULL, *postprocessedImage = NULL, *edgesMatte = NULL;
+ NodeOperationOutput *postprocessedMatte = nullptr, *postprocessedImage = nullptr,
+ *edgesMatte = nullptr;
/* keying operation */
KeyingOperation *keyingOperation = new KeyingOperation();
@@ -322,7 +323,7 @@ void KeyingNode::convertToOperations(NodeConverter &converter,
}
/* set alpha channel to output image */
- SetAlphaOperation *alphaOperation = new SetAlphaOperation();
+ KeyingSetAlphaOperation *alphaOperation = new KeyingSetAlphaOperation();
converter.addOperation(alphaOperation);
converter.mapInputSocket(inputImage, alphaOperation->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp
index 227e26af2b2..0edf880400f 100644
--- a/source/blender/compositor/nodes/COM_MathNode.cpp
+++ b/source/blender/compositor/nodes/COM_MathNode.cpp
@@ -23,7 +23,7 @@
void MathNode::convertToOperations(NodeConverter &converter,
const CompositorContext & /*context*/) const
{
- MathBaseOperation *operation = NULL;
+ MathBaseOperation *operation = nullptr;
switch (this->getbNode()->custom1) {
case NODE_MATH_ADD:
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
index 3366a8c20d6..7cc8f2ea19c 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.cpp
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
@@ -49,7 +49,7 @@ void MovieClipNode::convertToOperations(NodeConverter &converter,
MovieClipUser *movieClipUser = (MovieClipUser *)editorNode->storage;
bool cacheFrame = !context.isRendering();
- ImBuf *ibuf = NULL;
+ ImBuf *ibuf = nullptr;
if (movieClip) {
if (cacheFrame) {
ibuf = BKE_movieclip_get_ibuf(movieClip, movieClipUser);
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
index 1269e0b7f77..09528e09f1f 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
@@ -100,7 +100,7 @@ void OutputFileNode::convertToOperations(NodeConverter &converter,
/* combine file path for the input */
BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path);
- NodeOperation *outputOperation = NULL;
+ NodeOperation *outputOperation = nullptr;
if (is_multiview && format->views_format == R_IMF_VIEWS_MULTIVIEW) {
outputOperation = new OutputOpenExrSingleLayerMultiViewOperation(
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
index d66dd3fd434..6be86c04c4d 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
@@ -58,17 +58,17 @@ void RenderLayersNode::testRenderLink(NodeConverter &converter,
Scene *scene = (Scene *)this->getbNode()->id;
const short layerId = this->getbNode()->custom1;
RenderResult *rr = RE_AcquireResultRead(re);
- if (rr == NULL) {
+ if (rr == nullptr) {
missingRenderLink(converter);
return;
}
ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, layerId);
- if (view_layer == NULL) {
+ if (view_layer == nullptr) {
missingRenderLink(converter);
return;
}
RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
- if (rl == NULL) {
+ if (rl == nullptr) {
missingRenderLink(converter);
return;
}
@@ -78,7 +78,7 @@ void RenderLayersNode::testRenderLink(NodeConverter &converter,
NodeImageLayer *storage = (NodeImageLayer *)output->getbNodeSocket()->storage;
RenderPass *rpass = (RenderPass *)BLI_findstring(
&rl->passes, storage->pass_name, offsetof(RenderPass, name));
- if (rpass == NULL) {
+ if (rpass == nullptr) {
missingSocketLink(converter, output);
continue;
}
@@ -164,9 +164,9 @@ void RenderLayersNode::convertToOperations(NodeConverter &converter,
const CompositorContext &context) const
{
Scene *scene = (Scene *)this->getbNode()->id;
- Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
+ Render *re = (scene) ? RE_GetSceneRender(scene) : nullptr;
- if (re != NULL) {
+ if (re != nullptr) {
testRenderLink(converter, context, re);
RE_ReleaseResult(re);
}
diff --git a/source/blender/compositor/nodes/COM_SeparateColorNode.cpp b/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
index 712ba1e1f2d..203aa25c9e9 100644
--- a/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
+++ b/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
@@ -99,7 +99,7 @@ void SeparateColorNode::convertToOperations(NodeConverter &converter,
NodeOperation *SeparateRGBANode::getColorConverter(const CompositorContext & /*context*/) const
{
- return NULL; /* no conversion needed */
+ return nullptr; /* no conversion needed */
}
NodeOperation *SeparateHSVANode::getColorConverter(const CompositorContext & /*context*/) const
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.cpp b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
index df201289ca4..b61c018d029 100644
--- a/source/blender/compositor/nodes/COM_ZCombineNode.cpp
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
@@ -32,7 +32,7 @@ void ZCombineNode::convertToOperations(NodeConverter &converter,
const CompositorContext &context) const
{
if ((context.getRenderData()->scemode & R_FULL_SAMPLE) || this->getbNode()->custom2) {
- ZCombineOperation *operation = NULL;
+ ZCombineOperation *operation = nullptr;
if (this->getbNode()->custom1) {
operation = new ZCombineAlphaOperation();
}
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
index 1be5ef1f2df..668d07c7c3d 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_AlphaOverKeyOperation.h"
-AlphaOverKeyOperation::AlphaOverKeyOperation() : MixBaseOperation()
+AlphaOverKeyOperation::AlphaOverKeyOperation()
{
/* pass */
}
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
index 513158dcff6..b8465ab7ccf 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_AlphaOverMixedOperation.h"
-AlphaOverMixedOperation::AlphaOverMixedOperation() : MixBaseOperation()
+AlphaOverMixedOperation::AlphaOverMixedOperation()
{
this->m_x = 0.0f;
}
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
index 8e5bce7221f..4510c027d46 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_AlphaOverPremultiplyOperation.h"
-AlphaOverPremultiplyOperation::AlphaOverPremultiplyOperation() : MixBaseOperation()
+AlphaOverPremultiplyOperation::AlphaOverPremultiplyOperation()
{
/* pass */
}
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
index 3d5e53feb39..684485c40cb 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
@@ -22,7 +22,7 @@
#include "MEM_guardedalloc.h"
-#include "RE_render_ext.h"
+#include "RE_texture.h"
/* An implementation of the Scale3X edge-extrapolation algorithm.
*
@@ -112,11 +112,11 @@ static int extrapolate9(float *E0,
#undef PCPY
}
-AntiAliasOperation::AntiAliasOperation() : NodeOperation()
+AntiAliasOperation::AntiAliasOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
- this->m_valueReader = NULL;
+ this->m_valueReader = nullptr;
this->setComplex(true);
}
@@ -179,7 +179,7 @@ void AntiAliasOperation::executePixel(float output[4], int x, int y, void *data)
void AntiAliasOperation::deinitExecution()
{
- this->m_valueReader = NULL;
+ this->m_valueReader = nullptr;
}
bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input,
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
index 8168867a522..35b0092fa5f 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
@@ -21,15 +21,15 @@
#include "RE_pipeline.h"
-BilateralBlurOperation::BilateralBlurOperation() : NodeOperation()
+BilateralBlurOperation::BilateralBlurOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
- this->m_inputColorProgram = NULL;
- this->m_inputDeterminatorProgram = NULL;
+ this->m_inputColorProgram = nullptr;
+ this->m_inputDeterminatorProgram = nullptr;
}
void BilateralBlurOperation::initExecution()
@@ -94,8 +94,8 @@ void BilateralBlurOperation::executePixel(float output[4], int x, int y, void *d
void BilateralBlurOperation::deinitExecution()
{
- this->m_inputColorProgram = NULL;
- this->m_inputDeterminatorProgram = NULL;
+ this->m_inputColorProgram = nullptr;
+ this->m_inputDeterminatorProgram = nullptr;
}
bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input,
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index ef0f259c592..3fe154c397e 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -22,14 +22,14 @@
#include "RE_pipeline.h"
-BlurBaseOperation::BlurBaseOperation(DataType data_type) : NodeOperation()
+BlurBaseOperation::BlurBaseOperation(DataType data_type)
{
/* data_type is almost always COM_DT_COLOR except for alpha-blur */
this->addInputSocket(data_type);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(data_type);
this->setComplex(true);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
memset(&m_data, 0, sizeof(NodeBlurData));
this->m_size = 1.0f;
this->m_sizeavailable = false;
@@ -154,8 +154,8 @@ float *BlurBaseOperation::make_dist_fac_inverse(float rad, int size, int falloff
void BlurBaseOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
- this->m_inputSize = NULL;
+ this->m_inputProgram = nullptr;
+ this->m_inputSize = nullptr;
}
void BlurBaseOperation::setData(const NodeBlurData *data)
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
index c00ef2468c0..f7b7816e1a1 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
@@ -22,7 +22,7 @@
#include "RE_pipeline.h"
-BokehBlurOperation::BokehBlurOperation() : NodeOperation()
+BokehBlurOperation::BokehBlurOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
@@ -34,9 +34,9 @@ BokehBlurOperation::BokehBlurOperation() : NodeOperation()
this->m_size = 1.0f;
this->m_sizeavailable = false;
- this->m_inputProgram = NULL;
- this->m_inputBokehProgram = NULL;
- this->m_inputBoundingBoxReader = NULL;
+ this->m_inputProgram = nullptr;
+ this->m_inputBokehProgram = nullptr;
+ this->m_inputBoundingBoxReader = nullptr;
this->m_extend_bounds = false;
}
@@ -47,7 +47,7 @@ void *BokehBlurOperation::initializeTileData(rcti * /*rect*/)
if (!this->m_sizeavailable) {
updateSize();
}
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ void *buffer = getInputOperation(0)->initializeTileData(nullptr);
unlockMutex();
return buffer;
}
@@ -133,9 +133,9 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
void BokehBlurOperation::deinitExecution()
{
deinitMutex();
- this->m_inputProgram = NULL;
- this->m_inputBokehProgram = NULL;
- this->m_inputBoundingBoxReader = NULL;
+ this->m_inputProgram = nullptr;
+ this->m_inputBokehProgram = nullptr;
+ this->m_inputBoundingBoxReader = nullptr;
}
bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input,
@@ -196,7 +196,7 @@ void BokehBlurOperation::executeOpenCL(OpenCLDevice *device,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL);
+ cl_kernel kernel = device->COM_clCreateKernel("bokehBlurKernel", nullptr);
if (!this->m_sizeavailable) {
updateSize();
}
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
index 3fd9a77d879..473a43c1776 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_BokehImageOperation.h"
#include "BLI_math.h"
-BokehImageOperation::BokehImageOperation() : NodeOperation()
+BokehImageOperation::BokehImageOperation()
{
this->addOutputSocket(COM_DT_COLOR);
this->m_deleteData = false;
@@ -113,7 +113,7 @@ void BokehImageOperation::deinitExecution()
if (this->m_deleteData) {
if (this->m_data) {
delete this->m_data;
- this->m_data = NULL;
+ this->m_data = nullptr;
}
}
}
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
index c5f0108bf5a..662b08bdee9 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
@@ -20,13 +20,13 @@
#include "BLI_math.h"
#include "DNA_node_types.h"
-BoxMaskOperation::BoxMaskOperation() : NodeOperation()
+BoxMaskOperation::BoxMaskOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
- this->m_inputMask = NULL;
- this->m_inputValue = NULL;
+ this->m_inputMask = nullptr;
+ this->m_inputValue = nullptr;
this->m_cosine = 0.0f;
this->m_sine = 0.0f;
}
@@ -105,6 +105,6 @@ void BoxMaskOperation::executePixelSampled(float output[4], float x, float y, Pi
void BoxMaskOperation::deinitExecution()
{
- this->m_inputMask = NULL;
- this->m_inputValue = NULL;
+ this->m_inputMask = nullptr;
+ this->m_inputValue = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
index b6c22029899..3ae1b4aaef4 100644
--- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
@@ -18,13 +18,13 @@
#include "COM_BrightnessOperation.h"
-BrightnessOperation::BrightnessOperation() : NodeOperation()
+BrightnessOperation::BrightnessOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
this->m_use_premultiply = false;
}
@@ -85,7 +85,7 @@ void BrightnessOperation::executePixelSampled(float output[4],
void BrightnessOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
- this->m_inputBrightnessProgram = NULL;
- this->m_inputContrastProgram = NULL;
+ this->m_inputProgram = nullptr;
+ this->m_inputBrightnessProgram = nullptr;
+ this->m_inputContrastProgram = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
index ecd61e95f43..9ccf9d7f1ef 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
@@ -22,11 +22,11 @@
#include "IMB_colormanagement.h"
-CalculateMeanOperation::CalculateMeanOperation() : NodeOperation()
+CalculateMeanOperation::CalculateMeanOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(COM_DT_VALUE);
- this->m_imageReader = NULL;
+ this->m_imageReader = nullptr;
this->m_iscalculated = false;
this->m_setting = 1;
this->setComplex(true);
@@ -45,7 +45,7 @@ void CalculateMeanOperation::executePixel(float output[4], int /*x*/, int /*y*/,
void CalculateMeanOperation::deinitExecution()
{
- this->m_imageReader = NULL;
+ this->m_imageReader = nullptr;
NodeOperation::deinitMutex();
}
@@ -77,7 +77,7 @@ void *CalculateMeanOperation::initializeTileData(rcti *rect)
this->m_iscalculated = true;
}
unlockMutex();
- return NULL;
+ return nullptr;
}
void CalculateMeanOperation::calculateMean(MemoryBuffer *tile)
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
index 059040d6f05..9a1e48177ed 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
@@ -23,7 +23,6 @@
#include "IMB_colormanagement.h"
CalculateStandardDeviationOperation::CalculateStandardDeviationOperation()
- : CalculateMeanOperation()
{
/* pass */
}
@@ -62,21 +61,18 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
case 2: /* red */
{
float value = buffer[offset];
- sum += value;
sum += (value - mean) * (value - mean);
break;
}
case 3: /* green */
{
float value = buffer[offset + 1];
- sum += value;
sum += (value - mean) * (value - mean);
break;
}
case 4: /* blue */
{
float value = buffer[offset + 2];
- sum += value;
sum += (value - mean) * (value - mean);
break;
}
@@ -100,5 +96,5 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
this->m_iscalculated = true;
}
unlockMutex();
- return NULL;
+ return nullptr;
}
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
index ddbc400777f..6bc9fa53c31 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
@@ -18,14 +18,14 @@
#include "COM_ChangeHSVOperation.h"
-ChangeHSVOperation::ChangeHSVOperation() : NodeOperation()
+ChangeHSVOperation::ChangeHSVOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
void ChangeHSVOperation::initExecution()
@@ -38,10 +38,10 @@ void ChangeHSVOperation::initExecution()
void ChangeHSVOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_hueOperation = NULL;
- this->m_saturationOperation = NULL;
- this->m_valueOperation = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_hueOperation = nullptr;
+ this->m_saturationOperation = nullptr;
+ this->m_valueOperation = nullptr;
}
void ChangeHSVOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
index cbd46ea71f8..956a2cc86ee 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
@@ -19,12 +19,12 @@
#include "COM_ChannelMatteOperation.h"
#include "BLI_math.h"
-ChannelMatteOperation::ChannelMatteOperation() : NodeOperation()
+ChannelMatteOperation::ChannelMatteOperation()
{
addInputSocket(COM_DT_COLOR);
addOutputSocket(COM_DT_VALUE);
- this->m_inputImageProgram = NULL;
+ this->m_inputImageProgram = nullptr;
}
void ChannelMatteOperation::initExecution()
@@ -77,7 +77,7 @@ void ChannelMatteOperation::initExecution()
void ChannelMatteOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
+ this->m_inputImageProgram = nullptr;
}
void ChannelMatteOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
index 62dc74d2092..389aeaf6fed 100644
--- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
@@ -19,14 +19,14 @@
#include "COM_ChromaMatteOperation.h"
#include "BLI_math.h"
-ChromaMatteOperation::ChromaMatteOperation() : NodeOperation()
+ChromaMatteOperation::ChromaMatteOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_COLOR);
addOutputSocket(COM_DT_VALUE);
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = nullptr;
+ this->m_inputKeyProgram = nullptr;
}
void ChromaMatteOperation::initExecution()
@@ -37,8 +37,8 @@ void ChromaMatteOperation::initExecution()
void ChromaMatteOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = nullptr;
+ this->m_inputKeyProgram = nullptr;
}
void ChromaMatteOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
index a515b9a6a67..f9eaaf6f7a0 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
@@ -31,13 +31,13 @@ inline float colorbalance_cdl(float in, float offset, float power, float slope)
return powf(x, power);
}
-ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation() : NodeOperation()
+ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputValueOperation = NULL;
- this->m_inputColorOperation = NULL;
+ this->m_inputValueOperation = nullptr;
+ this->m_inputColorOperation = nullptr;
this->setResolutionInputSocketIndex(1);
}
@@ -76,6 +76,6 @@ void ColorBalanceASCCDLOperation::executePixelSampled(float output[4],
void ColorBalanceASCCDLOperation::deinitExecution()
{
- this->m_inputValueOperation = NULL;
- this->m_inputColorOperation = NULL;
+ this->m_inputValueOperation = nullptr;
+ this->m_inputColorOperation = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
index 1578a805d1e..df44e87a86a 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
@@ -36,13 +36,13 @@ inline float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float g
return powf(srgb_to_linearrgb(x), gamma_inv);
}
-ColorBalanceLGGOperation::ColorBalanceLGGOperation() : NodeOperation()
+ColorBalanceLGGOperation::ColorBalanceLGGOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputValueOperation = NULL;
- this->m_inputColorOperation = NULL;
+ this->m_inputValueOperation = nullptr;
+ this->m_inputColorOperation = nullptr;
this->setResolutionInputSocketIndex(1);
}
@@ -81,6 +81,6 @@ void ColorBalanceLGGOperation::executePixelSampled(float output[4],
void ColorBalanceLGGOperation::deinitExecution()
{
- this->m_inputValueOperation = NULL;
- this->m_inputColorOperation = NULL;
+ this->m_inputValueOperation = nullptr;
+ this->m_inputColorOperation = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
index 893c052831c..60343c28662 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
@@ -21,13 +21,13 @@
#include "IMB_colormanagement.h"
-ColorCorrectionOperation::ColorCorrectionOperation() : NodeOperation()
+ColorCorrectionOperation::ColorCorrectionOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputImage = NULL;
- this->m_inputMask = NULL;
+ this->m_inputImage = nullptr;
+ this->m_inputMask = nullptr;
this->m_redChannelEnabled = true;
this->m_greenChannelEnabled = true;
this->m_blueChannelEnabled = true;
@@ -157,6 +157,6 @@ void ColorCorrectionOperation::executePixelSampled(float output[4],
void ColorCorrectionOperation::deinitExecution()
{
- this->m_inputImage = NULL;
- this->m_inputMask = NULL;
+ this->m_inputImage = nullptr;
+ this->m_inputMask = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
index 9d514c872f7..ed107a88953 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
@@ -22,7 +22,7 @@
#include "MEM_guardedalloc.h"
-ColorCurveOperation::ColorCurveOperation() : CurveBaseOperation()
+ColorCurveOperation::ColorCurveOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
@@ -30,10 +30,10 @@ ColorCurveOperation::ColorCurveOperation() : CurveBaseOperation()
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputFacProgram = NULL;
- this->m_inputImageProgram = NULL;
- this->m_inputBlackProgram = NULL;
- this->m_inputWhiteProgram = NULL;
+ this->m_inputFacProgram = nullptr;
+ this->m_inputImageProgram = nullptr;
+ this->m_inputBlackProgram = nullptr;
+ this->m_inputWhiteProgram = nullptr;
this->setResolutionInputSocketIndex(1);
}
@@ -90,22 +90,22 @@ void ColorCurveOperation::executePixelSampled(float output[4],
void ColorCurveOperation::deinitExecution()
{
CurveBaseOperation::deinitExecution();
- this->m_inputFacProgram = NULL;
- this->m_inputImageProgram = NULL;
- this->m_inputBlackProgram = NULL;
- this->m_inputWhiteProgram = NULL;
+ this->m_inputFacProgram = nullptr;
+ this->m_inputImageProgram = nullptr;
+ this->m_inputBlackProgram = nullptr;
+ this->m_inputWhiteProgram = nullptr;
}
// Constant level curve mapping
-ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation() : CurveBaseOperation()
+ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputFacProgram = NULL;
- this->m_inputImageProgram = NULL;
+ this->m_inputFacProgram = nullptr;
+ this->m_inputImageProgram = nullptr;
this->setResolutionInputSocketIndex(1);
}
@@ -148,6 +148,6 @@ void ConstantLevelColorCurveOperation::executePixelSampled(float output[4],
void ConstantLevelColorCurveOperation::deinitExecution()
{
CurveBaseOperation::deinitExecution();
- this->m_inputFacProgram = NULL;
- this->m_inputImageProgram = NULL;
+ this->m_inputFacProgram = nullptr;
+ this->m_inputImageProgram = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
index 90b7f4a63b5..b8749bec4b8 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
@@ -19,14 +19,14 @@
#include "COM_ColorMatteOperation.h"
#include "BLI_math.h"
-ColorMatteOperation::ColorMatteOperation() : NodeOperation()
+ColorMatteOperation::ColorMatteOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_COLOR);
addOutputSocket(COM_DT_VALUE);
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = nullptr;
+ this->m_inputKeyProgram = nullptr;
}
void ColorMatteOperation::initExecution()
@@ -37,8 +37,8 @@ void ColorMatteOperation::initExecution()
void ColorMatteOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = nullptr;
+ this->m_inputKeyProgram = nullptr;
}
void ColorMatteOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
index 95e0bd2d82b..4d62a293b78 100644
--- a/source/blender/compositor/operations/COM_ColorRampOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
@@ -20,13 +20,13 @@
#include "BKE_colorband.h"
-ColorRampOperation::ColorRampOperation() : NodeOperation()
+ColorRampOperation::ColorRampOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
- this->m_colorBand = NULL;
+ this->m_inputProgram = nullptr;
+ this->m_colorBand = nullptr;
}
void ColorRampOperation::initExecution()
{
@@ -46,5 +46,5 @@ void ColorRampOperation::executePixelSampled(float output[4],
void ColorRampOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
index 99ab6105934..050792d8dab 100644
--- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
@@ -20,14 +20,14 @@
#include "BLI_math.h"
#define AVG(a, b) ((a + b) / 2)
-ColorSpillOperation::ColorSpillOperation() : NodeOperation()
+ColorSpillOperation::ColorSpillOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_VALUE);
addOutputSocket(COM_DT_COLOR);
- this->m_inputImageReader = NULL;
- this->m_inputFacReader = NULL;
+ this->m_inputImageReader = nullptr;
+ this->m_inputFacReader = nullptr;
this->m_spillChannel = 1; // GREEN
this->m_spillMethod = 0;
}
@@ -77,8 +77,8 @@ void ColorSpillOperation::initExecution()
void ColorSpillOperation::deinitExecution()
{
- this->m_inputImageReader = NULL;
- this->m_inputFacReader = NULL;
+ this->m_inputImageReader = nullptr;
+ this->m_inputFacReader = nullptr;
}
void ColorSpillOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index 8d55fe53aa7..6a16872cae2 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -25,32 +25,31 @@
#include "BLI_threads.h"
#include "RE_pipeline.h"
-#include "RE_render_ext.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#include "render_types.h"
#include "PIL_time.h"
-CompositorOperation::CompositorOperation() : NodeOperation()
+CompositorOperation::CompositorOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
- this->setRenderData(NULL);
- this->m_outputBuffer = NULL;
- this->m_depthBuffer = NULL;
- this->m_imageInput = NULL;
- this->m_alphaInput = NULL;
- this->m_depthInput = NULL;
+ this->setRenderData(nullptr);
+ this->m_outputBuffer = nullptr;
+ this->m_depthBuffer = nullptr;
+ this->m_imageInput = nullptr;
+ this->m_alphaInput = nullptr;
+ this->m_depthInput = nullptr;
this->m_useAlphaInput = false;
this->m_active = false;
- this->m_scene = NULL;
+ this->m_scene = nullptr;
this->m_sceneName[0] = '\0';
- this->m_viewName = NULL;
+ this->m_viewName = nullptr;
}
void CompositorOperation::initExecution()
@@ -67,7 +66,7 @@ void CompositorOperation::initExecution()
this->m_outputBuffer = (float *)MEM_callocN(
sizeof(float[4]) * this->getWidth() * this->getHeight(), "CompositorOperation");
}
- if (this->m_depthInput != NULL) {
+ if (this->m_depthInput != nullptr) {
this->m_depthBuffer = (float *)MEM_callocN(
sizeof(float) * this->getWidth() * this->getHeight(), "CompositorOperation");
}
@@ -86,11 +85,11 @@ void CompositorOperation::deinitExecution()
if (rr) {
RenderView *rv = RE_RenderViewGetByName(rr, this->m_viewName);
- if (rv->rectf != NULL) {
+ if (rv->rectf != nullptr) {
MEM_freeN(rv->rectf);
}
rv->rectf = this->m_outputBuffer;
- if (rv->rectz != NULL) {
+ if (rv->rectz != nullptr) {
MEM_freeN(rv->rectz);
}
rv->rectz = this->m_depthBuffer;
@@ -107,13 +106,13 @@ void CompositorOperation::deinitExecution()
if (re) {
RE_ReleaseResult(re);
- re = NULL;
+ re = nullptr;
}
BLI_thread_lock(LOCK_DRAW_IMAGE);
BKE_image_signal(G.main,
BKE_image_ensure_viewer(G.main, IMA_TYPE_R_RESULT, "Render Result"),
- NULL,
+ nullptr,
IMA_SIGNAL_FREE);
BLI_thread_unlock(LOCK_DRAW_IMAGE);
}
@@ -126,11 +125,11 @@ void CompositorOperation::deinitExecution()
}
}
- this->m_outputBuffer = NULL;
- this->m_depthBuffer = NULL;
- this->m_imageInput = NULL;
- this->m_alphaInput = NULL;
- this->m_depthInput = NULL;
+ this->m_outputBuffer = nullptr;
+ this->m_depthBuffer = nullptr;
+ this->m_imageInput = nullptr;
+ this->m_alphaInput = nullptr;
+ this->m_depthInput = nullptr;
}
void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
index 6a4c5db856c..44468e04ae9 100644
--- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
@@ -20,11 +20,11 @@
#include "IMB_imbuf.h"
-ConvertColorProfileOperation::ConvertColorProfileOperation() : NodeOperation()
+ConvertColorProfileOperation::ConvertColorProfileOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
this->m_predivided = false;
}
@@ -46,5 +46,5 @@ void ConvertColorProfileOperation::executePixelSampled(float output[4],
void ConvertColorProfileOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
index 1a1ea794d24..fe395ecae9e 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
@@ -21,15 +21,15 @@
#include "BLI_math.h"
#include "DNA_camera_types.h"
-ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation() : NodeOperation()
+ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
this->m_fStop = 128.0f;
- this->m_cameraObject = NULL;
+ this->m_cameraObject = nullptr;
this->m_maxRadius = 32.0f;
- this->m_blurPostOperation = NULL;
+ this->m_blurPostOperation = nullptr;
}
float ConvertDepthToRadiusOperation::determineFocalDistance()
@@ -46,7 +46,7 @@ float ConvertDepthToRadiusOperation::determineFocalDistance()
void ConvertDepthToRadiusOperation::initExecution()
{
float cam_sensor = DEFAULT_SENSOR_WIDTH;
- Camera *camera = NULL;
+ Camera *camera = nullptr;
if (this->m_cameraObject && this->m_cameraObject->type == OB_CAMERA) {
camera = (Camera *)this->m_cameraObject->data;
@@ -111,5 +111,5 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4],
void ConvertDepthToRadiusOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.cpp b/source/blender/compositor/operations/COM_ConvertOperation.cpp
index 0bd3f5b8796..cccfd407752 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertOperation.cpp
@@ -22,7 +22,7 @@
ConvertBaseOperation::ConvertBaseOperation()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
void ConvertBaseOperation::initExecution()
@@ -32,7 +32,7 @@ void ConvertBaseOperation::initExecution()
void ConvertBaseOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
/* ******** Value to Color ******** */
@@ -397,11 +397,11 @@ void ConvertStraightToPremulOperation::executePixelSampled(float output[4],
/* ******** Separate Channels ******** */
-SeparateChannelOperation::SeparateChannelOperation() : NodeOperation()
+SeparateChannelOperation::SeparateChannelOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VALUE);
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
void SeparateChannelOperation::initExecution()
{
@@ -410,7 +410,7 @@ void SeparateChannelOperation::initExecution()
void SeparateChannelOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
void SeparateChannelOperation::executePixelSampled(float output[4],
@@ -425,7 +425,7 @@ void SeparateChannelOperation::executePixelSampled(float output[4],
/* ******** Combine Channels ******** */
-CombineChannelsOperation::CombineChannelsOperation() : NodeOperation()
+CombineChannelsOperation::CombineChannelsOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
@@ -433,10 +433,10 @@ CombineChannelsOperation::CombineChannelsOperation() : NodeOperation()
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
- this->m_inputChannel1Operation = NULL;
- this->m_inputChannel2Operation = NULL;
- this->m_inputChannel3Operation = NULL;
- this->m_inputChannel4Operation = NULL;
+ this->m_inputChannel1Operation = nullptr;
+ this->m_inputChannel2Operation = nullptr;
+ this->m_inputChannel3Operation = nullptr;
+ this->m_inputChannel4Operation = nullptr;
}
void CombineChannelsOperation::initExecution()
@@ -449,10 +449,10 @@ void CombineChannelsOperation::initExecution()
void CombineChannelsOperation::deinitExecution()
{
- this->m_inputChannel1Operation = NULL;
- this->m_inputChannel2Operation = NULL;
- this->m_inputChannel3Operation = NULL;
- this->m_inputChannel4Operation = NULL;
+ this->m_inputChannel1Operation = nullptr;
+ this->m_inputChannel2Operation = nullptr;
+ this->m_inputChannel3Operation = nullptr;
+ this->m_inputChannel4Operation = nullptr;
}
void CombineChannelsOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
index 1439c7abb45..1c2570cd251 100644
--- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_ConvolutionEdgeFilterOperation.h"
#include "BLI_math.h"
-ConvolutionEdgeFilterOperation::ConvolutionEdgeFilterOperation() : ConvolutionFilterOperation()
+ConvolutionEdgeFilterOperation::ConvolutionEdgeFilterOperation()
{
/* pass */
}
@@ -42,42 +42,42 @@ void ConvolutionEdgeFilterOperation::executePixel(float output[4], int x, int y,
CLAMP(y3, 0, getHeight() - 1);
float value[4];
- this->m_inputValueOperation->read(value, x2, y2, NULL);
+ this->m_inputValueOperation->read(value, x2, y2, nullptr);
float mval = 1.0f - value[0];
- this->m_inputOperation->read(in1, x1, y1, NULL);
+ this->m_inputOperation->read(in1, x1, y1, nullptr);
madd_v3_v3fl(res1, in1, this->m_filter[0]);
madd_v3_v3fl(res2, in1, this->m_filter[0]);
- this->m_inputOperation->read(in1, x2, y1, NULL);
+ this->m_inputOperation->read(in1, x2, y1, nullptr);
madd_v3_v3fl(res1, in1, this->m_filter[1]);
madd_v3_v3fl(res2, in1, this->m_filter[3]);
- this->m_inputOperation->read(in1, x3, y1, NULL);
+ this->m_inputOperation->read(in1, x3, y1, nullptr);
madd_v3_v3fl(res1, in1, this->m_filter[2]);
madd_v3_v3fl(res2, in1, this->m_filter[6]);
- this->m_inputOperation->read(in1, x1, y2, NULL);
+ this->m_inputOperation->read(in1, x1, y2, nullptr);
madd_v3_v3fl(res1, in1, this->m_filter[3]);
madd_v3_v3fl(res2, in1, this->m_filter[1]);
- this->m_inputOperation->read(in2, x2, y2, NULL);
+ this->m_inputOperation->read(in2, x2, y2, nullptr);
madd_v3_v3fl(res1, in2, this->m_filter[4]);
madd_v3_v3fl(res2, in2, this->m_filter[4]);
- this->m_inputOperation->read(in1, x3, y2, NULL);
+ this->m_inputOperation->read(in1, x3, y2, nullptr);
madd_v3_v3fl(res1, in1, this->m_filter[5]);
madd_v3_v3fl(res2, in1, this->m_filter[7]);
- this->m_inputOperation->read(in1, x1, y3, NULL);
+ this->m_inputOperation->read(in1, x1, y3, nullptr);
madd_v3_v3fl(res1, in1, this->m_filter[6]);
madd_v3_v3fl(res2, in1, this->m_filter[2]);
- this->m_inputOperation->read(in1, x2, y3, NULL);
+ this->m_inputOperation->read(in1, x2, y3, nullptr);
madd_v3_v3fl(res1, in1, this->m_filter[7]);
madd_v3_v3fl(res2, in1, this->m_filter[5]);
- this->m_inputOperation->read(in1, x3, y3, NULL);
+ this->m_inputOperation->read(in1, x3, y3, nullptr);
madd_v3_v3fl(res1, in1, this->m_filter[8]);
madd_v3_v3fl(res2, in1, this->m_filter[8]);
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
index 3f47bfda618..7e35f6fb4f6 100644
--- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
@@ -22,13 +22,13 @@
#include "MEM_guardedalloc.h"
-ConvolutionFilterOperation::ConvolutionFilterOperation() : NodeOperation()
+ConvolutionFilterOperation::ConvolutionFilterOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
this->setComplex(true);
}
void ConvolutionFilterOperation::initExecution()
@@ -55,8 +55,8 @@ void ConvolutionFilterOperation::set3x3Filter(
void ConvolutionFilterOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_inputValueOperation = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_inputValueOperation = nullptr;
}
void ConvolutionFilterOperation::executePixel(float output[4], int x, int y, void * /*data*/)
@@ -76,27 +76,27 @@ void ConvolutionFilterOperation::executePixel(float output[4], int x, int y, voi
CLAMP(y2, 0, getHeight() - 1);
CLAMP(y3, 0, getHeight() - 1);
float value[4];
- this->m_inputValueOperation->read(value, x2, y2, NULL);
+ this->m_inputValueOperation->read(value, x2, y2, nullptr);
const float mval = 1.0f - value[0];
zero_v4(output);
- this->m_inputOperation->read(in1, x1, y1, NULL);
+ this->m_inputOperation->read(in1, x1, y1, nullptr);
madd_v4_v4fl(output, in1, this->m_filter[0]);
- this->m_inputOperation->read(in1, x2, y1, NULL);
+ this->m_inputOperation->read(in1, x2, y1, nullptr);
madd_v4_v4fl(output, in1, this->m_filter[1]);
- this->m_inputOperation->read(in1, x3, y1, NULL);
+ this->m_inputOperation->read(in1, x3, y1, nullptr);
madd_v4_v4fl(output, in1, this->m_filter[2]);
- this->m_inputOperation->read(in1, x1, y2, NULL);
+ this->m_inputOperation->read(in1, x1, y2, nullptr);
madd_v4_v4fl(output, in1, this->m_filter[3]);
- this->m_inputOperation->read(in2, x2, y2, NULL);
+ this->m_inputOperation->read(in2, x2, y2, nullptr);
madd_v4_v4fl(output, in2, this->m_filter[4]);
- this->m_inputOperation->read(in1, x3, y2, NULL);
+ this->m_inputOperation->read(in1, x3, y2, nullptr);
madd_v4_v4fl(output, in1, this->m_filter[5]);
- this->m_inputOperation->read(in1, x1, y3, NULL);
+ this->m_inputOperation->read(in1, x1, y3, nullptr);
madd_v4_v4fl(output, in1, this->m_filter[6]);
- this->m_inputOperation->read(in1, x2, y3, NULL);
+ this->m_inputOperation->read(in1, x2, y3, nullptr);
madd_v4_v4fl(output, in1, this->m_filter[7]);
- this->m_inputOperation->read(in1, x3, y3, NULL);
+ this->m_inputOperation->read(in1, x3, y3, nullptr);
madd_v4_v4fl(output, in1, this->m_filter[8]);
output[0] = output[0] * value[0] + in2[0] * mval;
diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp
index 625490dd3ab..408f588871e 100644
--- a/source/blender/compositor/operations/COM_CropOperation.cpp
+++ b/source/blender/compositor/operations/COM_CropOperation.cpp
@@ -19,12 +19,12 @@
#include "COM_CropOperation.h"
#include "BLI_math.h"
-CropBaseOperation::CropBaseOperation() : NodeOperation()
+CropBaseOperation::CropBaseOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputOperation = NULL;
- this->m_settings = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_settings = nullptr;
}
void CropBaseOperation::updateArea()
@@ -75,7 +75,7 @@ void CropBaseOperation::initExecution()
void CropBaseOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
CropOperation::CropOperation() : CropBaseOperation()
diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
index 085db6a9dea..07466cdeccd 100644
--- a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_CryptomatteOperation.h"
-CryptomatteOperation::CryptomatteOperation(size_t num_inputs) : NodeOperation()
+CryptomatteOperation::CryptomatteOperation(size_t num_inputs)
{
for (size_t i = 0; i < num_inputs; i++) {
this->addInputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
index da62928ce7f..b58efcf0cca 100644
--- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
@@ -20,16 +20,16 @@
#include "BKE_colortools.h"
-CurveBaseOperation::CurveBaseOperation() : NodeOperation()
+CurveBaseOperation::CurveBaseOperation()
{
- this->m_curveMapping = NULL;
+ this->m_curveMapping = nullptr;
}
CurveBaseOperation::~CurveBaseOperation()
{
if (this->m_curveMapping) {
BKE_curvemapping_free(this->m_curveMapping);
- this->m_curveMapping = NULL;
+ this->m_curveMapping = nullptr;
}
}
@@ -41,7 +41,7 @@ void CurveBaseOperation::deinitExecution()
{
if (this->m_curveMapping) {
BKE_curvemapping_free(this->m_curveMapping);
- this->m_curveMapping = NULL;
+ this->m_curveMapping = nullptr;
}
}
diff --git a/source/blender/compositor/operations/COM_DenoiseOperation.cpp b/source/blender/compositor/operations/COM_DenoiseOperation.cpp
index 4087056a79d..bc33e5f75c4 100644
--- a/source/blender/compositor/operations/COM_DenoiseOperation.cpp
+++ b/source/blender/compositor/operations/COM_DenoiseOperation.cpp
@@ -26,13 +26,13 @@ static pthread_mutex_t oidn_lock = BLI_MUTEX_INITIALIZER;
#endif
#include <iostream>
-DenoiseOperation::DenoiseOperation() : SingleThreadedOperation()
+DenoiseOperation::DenoiseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VECTOR);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_settings = NULL;
+ this->m_settings = nullptr;
}
void DenoiseOperation::initExecution()
{
@@ -44,9 +44,9 @@ void DenoiseOperation::initExecution()
void DenoiseOperation::deinitExecution()
{
- this->m_inputProgramColor = NULL;
- this->m_inputProgramNormal = NULL;
- this->m_inputProgramAlbedo = NULL;
+ this->m_inputProgramColor = nullptr;
+ this->m_inputProgramNormal = nullptr;
+ this->m_inputProgramAlbedo = nullptr;
SingleThreadedOperation::deinitExecution();
}
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
index 9b8d72da26d..901445c6875 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
@@ -22,13 +22,13 @@
#include "BLI_utildefines.h"
-DespeckleOperation::DespeckleOperation() : NodeOperation()
+DespeckleOperation::DespeckleOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
this->setComplex(true);
}
void DespeckleOperation::initExecution()
@@ -39,8 +39,8 @@ void DespeckleOperation::initExecution()
void DespeckleOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_inputValueOperation = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_inputValueOperation = nullptr;
}
BLI_INLINE int color_diff(const float a[3], const float b[3], const float threshold)
@@ -69,10 +69,10 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*da
CLAMP(y2, 0, getHeight() - 1);
CLAMP(y3, 0, getHeight() - 1);
float value[4];
- this->m_inputValueOperation->read(value, x2, y2, NULL);
+ this->m_inputValueOperation->read(value, x2, y2, nullptr);
// const float mval = 1.0f - value[0];
- this->m_inputOperation->read(color_org, x2, y2, NULL);
+ this->m_inputOperation->read(color_org, x2, y2, nullptr);
#define TOT_DIV_ONE 1.0f
#define TOT_DIV_CNR (float)M_SQRT1_2
@@ -91,13 +91,13 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*da
zero_v4(color_mid);
zero_v4(color_mid_ok);
- this->m_inputOperation->read(in1, x1, y1, NULL);
+ this->m_inputOperation->read(in1, x1, y1, nullptr);
COLOR_ADD(TOT_DIV_CNR)
- this->m_inputOperation->read(in1, x2, y1, NULL);
+ this->m_inputOperation->read(in1, x2, y1, nullptr);
COLOR_ADD(TOT_DIV_ONE)
- this->m_inputOperation->read(in1, x3, y1, NULL);
+ this->m_inputOperation->read(in1, x3, y1, nullptr);
COLOR_ADD(TOT_DIV_CNR)
- this->m_inputOperation->read(in1, x1, y2, NULL);
+ this->m_inputOperation->read(in1, x1, y2, nullptr);
COLOR_ADD(TOT_DIV_ONE)
#if 0
@@ -105,13 +105,13 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*da
madd_v4_v4fl(color_mid, in2, this->m_filter[4]);
#endif
- this->m_inputOperation->read(in1, x3, y2, NULL);
+ this->m_inputOperation->read(in1, x3, y2, nullptr);
COLOR_ADD(TOT_DIV_ONE)
- this->m_inputOperation->read(in1, x1, y3, NULL);
+ this->m_inputOperation->read(in1, x1, y3, nullptr);
COLOR_ADD(TOT_DIV_CNR)
- this->m_inputOperation->read(in1, x2, y3, NULL);
+ this->m_inputOperation->read(in1, x2, y3, nullptr);
COLOR_ADD(TOT_DIV_ONE)
- this->m_inputOperation->read(in1, x3, y3, NULL);
+ this->m_inputOperation->read(in1, x3, y3, nullptr);
COLOR_ADD(TOT_DIV_CNR)
mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2)));
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
index ea3526eb7e0..cca99a42c0c 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
@@ -19,14 +19,14 @@
#include "COM_DifferenceMatteOperation.h"
#include "BLI_math.h"
-DifferenceMatteOperation::DifferenceMatteOperation() : NodeOperation()
+DifferenceMatteOperation::DifferenceMatteOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_COLOR);
addOutputSocket(COM_DT_VALUE);
- this->m_inputImage1Program = NULL;
- this->m_inputImage2Program = NULL;
+ this->m_inputImage1Program = nullptr;
+ this->m_inputImage2Program = nullptr;
}
void DifferenceMatteOperation::initExecution()
@@ -36,8 +36,8 @@ void DifferenceMatteOperation::initExecution()
}
void DifferenceMatteOperation::deinitExecution()
{
- this->m_inputImage1Program = NULL;
- this->m_inputImage2Program = NULL;
+ this->m_inputImage1Program = nullptr;
+ this->m_inputImage2Program = nullptr;
}
void DifferenceMatteOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
index 52bc00e9b84..74f5fceacfb 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
@@ -23,12 +23,12 @@
#include "MEM_guardedalloc.h"
// DilateErode Distance Threshold
-DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation()
+DilateErodeThresholdOperation::DilateErodeThresholdOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
this->setComplex(true);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
this->m_inset = 0.0f;
this->m__switch = 0.5f;
this->m_distance = 0.0f;
@@ -54,7 +54,7 @@ void DilateErodeThresholdOperation::initExecution()
void *DilateErodeThresholdOperation::initializeTileData(rcti * /*rect*/)
{
- void *buffer = this->m_inputProgram->initializeTileData(NULL);
+ void *buffer = this->m_inputProgram->initializeTileData(nullptr);
return buffer;
}
@@ -142,7 +142,7 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
void DilateErodeThresholdOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(
@@ -159,12 +159,12 @@ bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(
}
// Dilate Distance
-DilateDistanceOperation::DilateDistanceOperation() : NodeOperation()
+DilateDistanceOperation::DilateDistanceOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
this->setComplex(true);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
this->m_distance = 0.0f;
this->setOpenCL(true);
}
@@ -179,7 +179,7 @@ void DilateDistanceOperation::initExecution()
void *DilateDistanceOperation::initializeTileData(rcti * /*rect*/)
{
- void *buffer = this->m_inputProgram->initializeTileData(NULL);
+ void *buffer = this->m_inputProgram->initializeTileData(nullptr);
return buffer;
}
@@ -217,7 +217,7 @@ void DilateDistanceOperation::executePixel(float output[4], int x, int y, void *
void DilateDistanceOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input,
@@ -241,7 +241,7 @@ void DilateDistanceOperation::executeOpenCL(OpenCLDevice *device,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel dilateKernel = device->COM_clCreateKernel("dilateKernel", NULL);
+ cl_kernel dilateKernel = device->COM_clCreateKernel("dilateKernel", nullptr);
cl_int distanceSquared = this->m_distance * this->m_distance;
cl_int scope = this->m_scope;
@@ -301,7 +301,7 @@ void ErodeDistanceOperation::executeOpenCL(OpenCLDevice *device,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel erodeKernel = device->COM_clCreateKernel("erodeKernel", NULL);
+ cl_kernel erodeKernel = device->COM_clCreateKernel("erodeKernel", nullptr);
cl_int distanceSquared = this->m_distance * this->m_distance;
cl_int scope = this->m_scope;
@@ -317,12 +317,12 @@ void ErodeDistanceOperation::executeOpenCL(OpenCLDevice *device,
}
// Dilate step
-DilateStepOperation::DilateStepOperation() : NodeOperation()
+DilateStepOperation::DilateStepOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
this->setComplex(true);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
void DilateStepOperation::initExecution()
{
@@ -351,7 +351,7 @@ static tile_info *create_cache(int xmin, int xmax, int ymin, int ymax)
void *DilateStepOperation::initializeTileData(rcti *rect)
{
- MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL);
+ MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(nullptr);
int x, y, i;
int width = tile->getWidth();
int height = tile->getHeight();
@@ -448,7 +448,7 @@ void DilateStepOperation::executePixel(float output[4], int x, int y, void *data
void DilateStepOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
void DilateStepOperation::deinitializeTileData(rcti * /*rect*/, void *data)
@@ -480,7 +480,7 @@ ErodeStepOperation::ErodeStepOperation() : DilateStepOperation()
void *ErodeStepOperation::initializeTileData(rcti *rect)
{
- MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL);
+ MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(nullptr);
int x, y, i;
int width = tile->getWidth();
int height = tile->getHeight();
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
index 31eb74fbc42..c0b9c9b6f1d 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
@@ -23,14 +23,14 @@
#include "RE_pipeline.h"
-DirectionalBlurOperation::DirectionalBlurOperation() : NodeOperation()
+DirectionalBlurOperation::DirectionalBlurOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
this->setOpenCL(true);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
void DirectionalBlurOperation::initExecution()
@@ -103,7 +103,7 @@ void DirectionalBlurOperation::executeOpenCL(OpenCLDevice *device,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel directionalBlurKernel = device->COM_clCreateKernel("directionalBlurKernel", NULL);
+ cl_kernel directionalBlurKernel = device->COM_clCreateKernel("directionalBlurKernel", nullptr);
cl_int iterations = pow(2.0f, this->m_data->iter);
cl_float2 ltxy = {{this->m_tx, this->m_ty}};
@@ -128,7 +128,7 @@ void DirectionalBlurOperation::executeOpenCL(OpenCLDevice *device,
void DirectionalBlurOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
bool DirectionalBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/,
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
index 73790447216..fcc8bc4670e 100644
--- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
@@ -20,7 +20,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-DisplaceOperation::DisplaceOperation() : NodeOperation()
+DisplaceOperation::DisplaceOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VECTOR);
@@ -29,10 +29,10 @@ DisplaceOperation::DisplaceOperation() : NodeOperation()
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
- this->m_inputColorProgram = NULL;
- this->m_inputVectorProgram = NULL;
- this->m_inputScaleXProgram = NULL;
- this->m_inputScaleYProgram = NULL;
+ this->m_inputColorProgram = nullptr;
+ this->m_inputVectorProgram = nullptr;
+ this->m_inputScaleXProgram = nullptr;
+ this->m_inputScaleYProgram = nullptr;
}
void DisplaceOperation::initExecution()
@@ -143,10 +143,10 @@ void DisplaceOperation::pixelTransform(const float xy[2], float r_uv[2], float r
void DisplaceOperation::deinitExecution()
{
- this->m_inputColorProgram = NULL;
- this->m_inputVectorProgram = NULL;
- this->m_inputScaleXProgram = NULL;
- this->m_inputScaleYProgram = NULL;
+ this->m_inputColorProgram = nullptr;
+ this->m_inputVectorProgram = nullptr;
+ this->m_inputScaleXProgram = nullptr;
+ this->m_inputScaleYProgram = nullptr;
}
bool DisplaceOperation::determineDependingAreaOfInterest(rcti *input,
@@ -155,7 +155,7 @@ bool DisplaceOperation::determineDependingAreaOfInterest(rcti *input,
{
rcti colorInput;
rcti vectorInput;
- NodeOperation *operation = NULL;
+ NodeOperation *operation = nullptr;
/* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */
/* image */
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
index 32eb5679d9d..bbc4d63305b 100644
--- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
@@ -20,7 +20,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-DisplaceSimpleOperation::DisplaceSimpleOperation() : NodeOperation()
+DisplaceSimpleOperation::DisplaceSimpleOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VECTOR);
@@ -28,10 +28,10 @@ DisplaceSimpleOperation::DisplaceSimpleOperation() : NodeOperation()
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputColorProgram = NULL;
- this->m_inputVectorProgram = NULL;
- this->m_inputScaleXProgram = NULL;
- this->m_inputScaleYProgram = NULL;
+ this->m_inputColorProgram = nullptr;
+ this->m_inputVectorProgram = nullptr;
+ this->m_inputScaleXProgram = nullptr;
+ this->m_inputScaleYProgram = nullptr;
}
void DisplaceSimpleOperation::initExecution()
@@ -86,10 +86,10 @@ void DisplaceSimpleOperation::executePixelSampled(float output[4],
void DisplaceSimpleOperation::deinitExecution()
{
- this->m_inputColorProgram = NULL;
- this->m_inputVectorProgram = NULL;
- this->m_inputScaleXProgram = NULL;
- this->m_inputScaleYProgram = NULL;
+ this->m_inputColorProgram = nullptr;
+ this->m_inputVectorProgram = nullptr;
+ this->m_inputScaleXProgram = nullptr;
+ this->m_inputScaleYProgram = nullptr;
}
bool DisplaceSimpleOperation::determineDependingAreaOfInterest(rcti *input,
@@ -97,7 +97,7 @@ bool DisplaceSimpleOperation::determineDependingAreaOfInterest(rcti *input,
rcti *output)
{
rcti colorInput;
- NodeOperation *operation = NULL;
+ NodeOperation *operation = nullptr;
/* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */
/* image */
diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
index ff337455658..7d79dcc657d 100644
--- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
@@ -19,14 +19,14 @@
#include "COM_DistanceRGBMatteOperation.h"
#include "BLI_math.h"
-DistanceRGBMatteOperation::DistanceRGBMatteOperation() : NodeOperation()
+DistanceRGBMatteOperation::DistanceRGBMatteOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VALUE);
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = nullptr;
+ this->m_inputKeyProgram = nullptr;
}
void DistanceRGBMatteOperation::initExecution()
@@ -37,8 +37,8 @@ void DistanceRGBMatteOperation::initExecution()
void DistanceRGBMatteOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = nullptr;
+ this->m_inputKeyProgram = nullptr;
}
float DistanceRGBMatteOperation::calculateDistance(float key[4], float image[4])
diff --git a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp
index 6ad1a7e440a..f333cc1ecd9 100644
--- a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_DistanceYCCMatteOperation.h"
#include "BLI_math.h"
-DistanceYCCMatteOperation::DistanceYCCMatteOperation() : DistanceRGBMatteOperation()
+DistanceYCCMatteOperation::DistanceYCCMatteOperation()
{
/* pass */
}
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.cpp b/source/blender/compositor/operations/COM_DotproductOperation.cpp
index da6ce510a25..750e4308d11 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.cpp
+++ b/source/blender/compositor/operations/COM_DotproductOperation.cpp
@@ -18,14 +18,14 @@
#include "COM_DotproductOperation.h"
-DotproductOperation::DotproductOperation() : NodeOperation()
+DotproductOperation::DotproductOperation()
{
this->addInputSocket(COM_DT_VECTOR);
this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(COM_DT_VALUE);
this->setResolutionInputSocketIndex(0);
- this->m_input1Operation = NULL;
- this->m_input2Operation = NULL;
+ this->m_input1Operation = nullptr;
+ this->m_input2Operation = nullptr;
}
void DotproductOperation::initExecution()
{
@@ -35,8 +35,8 @@ void DotproductOperation::initExecution()
void DotproductOperation::deinitExecution()
{
- this->m_input1Operation = NULL;
- this->m_input2Operation = NULL;
+ this->m_input1Operation = nullptr;
+ this->m_input2Operation = nullptr;
}
/** \todo: current implementation is the inverse of a dotproduct. not 'logically' correct
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
index 95ccb462ade..7ef0d7b7606 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
@@ -1306,13 +1306,13 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float
}
}
-DoubleEdgeMaskOperation::DoubleEdgeMaskOperation() : NodeOperation()
+DoubleEdgeMaskOperation::DoubleEdgeMaskOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
- this->m_inputInnerMask = NULL;
- this->m_inputOuterMask = NULL;
+ this->m_inputInnerMask = nullptr;
+ this->m_inputOuterMask = nullptr;
this->m_adjecentOnly = false;
this->m_keepInside = false;
this->setComplex(true);
@@ -1322,7 +1322,7 @@ bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti * /*input*/,
ReadBufferOperation *readOperation,
rcti *output)
{
- if (this->m_cachedInstance == NULL) {
+ if (this->m_cachedInstance == nullptr) {
rcti newInput;
newInput.xmax = this->getWidth();
newInput.xmin = 0;
@@ -1339,7 +1339,7 @@ void DoubleEdgeMaskOperation::initExecution()
this->m_inputInnerMask = this->getInputSocketReader(0);
this->m_inputOuterMask = this->getInputSocketReader(1);
initMutex();
- this->m_cachedInstance = NULL;
+ this->m_cachedInstance = nullptr;
}
void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect)
@@ -1349,7 +1349,7 @@ void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect)
}
lockMutex();
- if (this->m_cachedInstance == NULL) {
+ if (this->m_cachedInstance == nullptr) {
MemoryBuffer *innerMask = (MemoryBuffer *)this->m_inputInnerMask->initializeTileData(rect);
MemoryBuffer *outerMask = (MemoryBuffer *)this->m_inputOuterMask->initializeTileData(rect);
float *data = (float *)MEM_mallocN(sizeof(float) * this->getWidth() * this->getHeight(),
@@ -1371,11 +1371,11 @@ void DoubleEdgeMaskOperation::executePixel(float output[4], int x, int y, void *
void DoubleEdgeMaskOperation::deinitExecution()
{
- this->m_inputInnerMask = NULL;
- this->m_inputOuterMask = NULL;
+ this->m_inputInnerMask = nullptr;
+ this->m_inputOuterMask = nullptr;
deinitMutex();
if (this->m_cachedInstance) {
MEM_freeN(this->m_cachedInstance);
- this->m_cachedInstance = NULL;
+ this->m_cachedInstance = nullptr;
}
}
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
index 0dc42b3457f..38541f91fc8 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
@@ -20,13 +20,13 @@
#include "BLI_math.h"
#include "DNA_node_types.h"
-EllipseMaskOperation::EllipseMaskOperation() : NodeOperation()
+EllipseMaskOperation::EllipseMaskOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
- this->m_inputMask = NULL;
- this->m_inputValue = NULL;
+ this->m_inputMask = nullptr;
+ this->m_inputValue = nullptr;
this->m_cosine = 0.0f;
this->m_sine = 0.0f;
}
@@ -114,6 +114,6 @@ void EllipseMaskOperation::executePixelSampled(float output[4],
void EllipseMaskOperation::deinitExecution()
{
- this->m_inputMask = NULL;
- this->m_inputValue = NULL;
+ this->m_inputMask = nullptr;
+ this->m_inputValue = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index 0ccb959712f..e87d40b4c86 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -24,7 +24,7 @@
FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->m_iirgaus = NULL;
+ this->m_iirgaus = nullptr;
}
void FastGaussianBlurOperation::executePixel(float output[4], int x, int y, void *data)
@@ -70,7 +70,7 @@ void FastGaussianBlurOperation::deinitExecution()
{
if (this->m_iirgaus) {
delete this->m_iirgaus;
- this->m_iirgaus = NULL;
+ this->m_iirgaus = nullptr;
}
BlurBaseOperation::deinitMutex();
}
@@ -256,12 +256,12 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
}
///
-FastGaussianBlurValueOperation::FastGaussianBlurValueOperation() : NodeOperation()
+FastGaussianBlurValueOperation::FastGaussianBlurValueOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
- this->m_iirgaus = NULL;
- this->m_inputprogram = NULL;
+ this->m_iirgaus = nullptr;
+ this->m_inputprogram = nullptr;
this->m_sigma = 1.0f;
this->m_overlay = 0;
setComplex(true);
@@ -300,7 +300,7 @@ void FastGaussianBlurValueOperation::deinitExecution()
{
if (this->m_iirgaus) {
delete this->m_iirgaus;
- this->m_iirgaus = NULL;
+ this->m_iirgaus = nullptr;
}
deinitMutex();
}
diff --git a/source/blender/compositor/operations/COM_FlipOperation.cpp b/source/blender/compositor/operations/COM_FlipOperation.cpp
index 57b686986b7..37eaf4868d3 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.cpp
+++ b/source/blender/compositor/operations/COM_FlipOperation.cpp
@@ -18,12 +18,12 @@
#include "COM_FlipOperation.h"
-FlipOperation::FlipOperation() : NodeOperation()
+FlipOperation::FlipOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
this->m_flipX = true;
this->m_flipY = false;
}
@@ -34,7 +34,7 @@ void FlipOperation::initExecution()
void FlipOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
void FlipOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
index 36272c05774..d67d67f8e57 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
@@ -19,11 +19,11 @@
#include "COM_GammaCorrectOperation.h"
#include "BLI_math.h"
-GammaCorrectOperation::GammaCorrectOperation() : NodeOperation()
+GammaCorrectOperation::GammaCorrectOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
void GammaCorrectOperation::initExecution()
{
@@ -58,14 +58,14 @@ void GammaCorrectOperation::executePixelSampled(float output[4],
void GammaCorrectOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
-GammaUncorrectOperation::GammaUncorrectOperation() : NodeOperation()
+GammaUncorrectOperation::GammaUncorrectOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
void GammaUncorrectOperation::initExecution()
{
@@ -100,5 +100,5 @@ void GammaUncorrectOperation::executePixelSampled(float output[4],
void GammaUncorrectOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_GammaOperation.cpp b/source/blender/compositor/operations/COM_GammaOperation.cpp
index ee6b42c349f..6baa52a290c 100644
--- a/source/blender/compositor/operations/COM_GammaOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaOperation.cpp
@@ -19,13 +19,13 @@
#include "COM_GammaOperation.h"
#include "BLI_math.h"
-GammaOperation::GammaOperation() : NodeOperation()
+GammaOperation::GammaOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
- this->m_inputGammaProgram = NULL;
+ this->m_inputProgram = nullptr;
+ this->m_inputGammaProgram = nullptr;
}
void GammaOperation::initExecution()
{
@@ -51,6 +51,6 @@ void GammaOperation::executePixelSampled(float output[4], float x, float y, Pixe
void GammaOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
- this->m_inputGammaProgram = NULL;
+ this->m_inputProgram = nullptr;
+ this->m_inputGammaProgram = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
index c028a2c0e4c..a7d8f030269 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
@@ -24,7 +24,7 @@
GaussianAlphaXBlurOperation::GaussianAlphaXBlurOperation() : BlurBaseOperation(COM_DT_VALUE)
{
- this->m_gausstab = NULL;
+ this->m_gausstab = nullptr;
this->m_filtersize = 0;
this->m_falloff = -1; /* intentionally invalid, so we can detect uninitialized values */
}
@@ -35,7 +35,7 @@ void *GaussianAlphaXBlurOperation::initializeTileData(rcti * /*rect*/)
if (!this->m_sizeavailable) {
updateGauss();
}
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ void *buffer = getInputOperation(0)->initializeTileData(nullptr);
unlockMutex();
return buffer;
}
@@ -57,7 +57,7 @@ void GaussianAlphaXBlurOperation::initExecution()
void GaussianAlphaXBlurOperation::updateGauss()
{
- if (this->m_gausstab == NULL) {
+ if (this->m_gausstab == nullptr) {
updateSize();
float rad = max_ff(m_size * m_data.sizex, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
@@ -65,7 +65,7 @@ void GaussianAlphaXBlurOperation::updateGauss()
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
}
- if (this->m_distbuf_inv == NULL) {
+ if (this->m_distbuf_inv == nullptr) {
updateSize();
float rad = max_ff(m_size * m_data.sizex, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
@@ -143,12 +143,12 @@ void GaussianAlphaXBlurOperation::deinitExecution()
if (this->m_gausstab) {
MEM_freeN(this->m_gausstab);
- this->m_gausstab = NULL;
+ this->m_gausstab = nullptr;
}
if (this->m_distbuf_inv) {
MEM_freeN(this->m_distbuf_inv);
- this->m_distbuf_inv = NULL;
+ this->m_distbuf_inv = nullptr;
}
deinitMutex();
@@ -172,7 +172,7 @@ bool GaussianAlphaXBlurOperation::determineDependingAreaOfInterest(
else
#endif
{
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ if (this->m_sizeavailable && this->m_gausstab != nullptr) {
newInput.xmax = input->xmax + this->m_filtersize + 1;
newInput.xmin = input->xmin - this->m_filtersize - 1;
newInput.ymax = input->ymax;
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
index 35abe4cd47b..f1bc8751329 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
@@ -24,7 +24,7 @@
GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(COM_DT_VALUE)
{
- this->m_gausstab = NULL;
+ this->m_gausstab = nullptr;
this->m_filtersize = 0;
this->m_falloff = -1; /* intentionally invalid, so we can detect uninitialized values */
}
@@ -35,7 +35,7 @@ void *GaussianAlphaYBlurOperation::initializeTileData(rcti * /*rect*/)
if (!this->m_sizeavailable) {
updateGauss();
}
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ void *buffer = getInputOperation(0)->initializeTileData(nullptr);
unlockMutex();
return buffer;
}
@@ -57,7 +57,7 @@ void GaussianAlphaYBlurOperation::initExecution()
void GaussianAlphaYBlurOperation::updateGauss()
{
- if (this->m_gausstab == NULL) {
+ if (this->m_gausstab == nullptr) {
updateSize();
float rad = max_ff(m_size * m_data.sizey, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
@@ -65,7 +65,7 @@ void GaussianAlphaYBlurOperation::updateGauss()
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
}
- if (this->m_distbuf_inv == NULL) {
+ if (this->m_distbuf_inv == nullptr) {
updateSize();
float rad = max_ff(m_size * m_data.sizey, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
@@ -143,12 +143,12 @@ void GaussianAlphaYBlurOperation::deinitExecution()
if (this->m_gausstab) {
MEM_freeN(this->m_gausstab);
- this->m_gausstab = NULL;
+ this->m_gausstab = nullptr;
}
if (this->m_distbuf_inv) {
MEM_freeN(this->m_distbuf_inv);
- this->m_distbuf_inv = NULL;
+ this->m_distbuf_inv = nullptr;
}
deinitMutex();
@@ -172,7 +172,7 @@ bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(
else
#endif
{
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ if (this->m_sizeavailable && this->m_gausstab != nullptr) {
newInput.xmax = input->xmax;
newInput.xmin = input->xmin;
newInput.ymax = input->ymax + this->m_filtersize + 1;
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
index dd479da864c..d489c64953e 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -24,7 +24,7 @@
GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->m_gausstab = NULL;
+ this->m_gausstab = nullptr;
}
void *GaussianBokehBlurOperation::initializeTileData(rcti * /*rect*/)
@@ -33,7 +33,7 @@ void *GaussianBokehBlurOperation::initializeTileData(rcti * /*rect*/)
if (!this->m_sizeavailable) {
updateGauss();
}
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ void *buffer = getInputOperation(0)->initializeTileData(nullptr);
unlockMutex();
return buffer;
}
@@ -51,7 +51,7 @@ void GaussianBokehBlurOperation::initExecution()
void GaussianBokehBlurOperation::updateGauss()
{
- if (this->m_gausstab == NULL) {
+ if (this->m_gausstab == nullptr) {
float radxf;
float radyf;
int n;
@@ -156,7 +156,7 @@ void GaussianBokehBlurOperation::deinitExecution()
if (this->m_gausstab) {
MEM_freeN(this->m_gausstab);
- this->m_gausstab = NULL;
+ this->m_gausstab = nullptr;
}
deinitMutex();
@@ -177,7 +177,7 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(
return true;
}
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ if (this->m_sizeavailable && this->m_gausstab != nullptr) {
newInput.xmin = 0;
newInput.ymin = 0;
newInput.xmax = this->getWidth();
@@ -197,12 +197,12 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(
// reference image
GaussianBlurReferenceOperation::GaussianBlurReferenceOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->m_maintabs = NULL;
+ this->m_maintabs = nullptr;
}
void *GaussianBlurReferenceOperation::initializeTileData(rcti * /*rect*/)
{
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ void *buffer = getInputOperation(0)->initializeTileData(nullptr);
return buffer;
}
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
index 32ad0482791..e4401b2a91c 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
@@ -25,9 +25,9 @@
GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->m_gausstab = NULL;
+ this->m_gausstab = nullptr;
#ifdef __SSE2__
- this->m_gausstab_sse = NULL;
+ this->m_gausstab_sse = nullptr;
#endif
this->m_filtersize = 0;
}
@@ -38,7 +38,7 @@ void *GaussianXBlurOperation::initializeTileData(rcti * /*rect*/)
if (!this->m_sizeavailable) {
updateGauss();
}
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ void *buffer = getInputOperation(0)->initializeTileData(nullptr);
unlockMutex();
return buffer;
}
@@ -63,7 +63,7 @@ void GaussianXBlurOperation::initExecution()
void GaussianXBlurOperation::updateGauss()
{
- if (this->m_gausstab == NULL) {
+ if (this->m_gausstab == nullptr) {
updateSize();
float rad = max_ff(m_size * m_data.sizex, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
@@ -125,14 +125,14 @@ void GaussianXBlurOperation::executeOpenCL(OpenCLDevice *device,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
cl_kernel gaussianXBlurOperationKernel = device->COM_clCreateKernel(
- "gaussianXBlurOperationKernel", NULL);
+ "gaussianXBlurOperationKernel", nullptr);
cl_int filter_size = this->m_filtersize;
cl_mem gausstab = clCreateBuffer(device->getContext(),
CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
sizeof(float) * (this->m_filtersize * 2 + 1),
this->m_gausstab,
- NULL);
+ nullptr);
device->COM_clAttachMemoryBufferToKernelParameter(gaussianXBlurOperationKernel,
0,
@@ -159,12 +159,12 @@ void GaussianXBlurOperation::deinitExecution()
if (this->m_gausstab) {
MEM_freeN(this->m_gausstab);
- this->m_gausstab = NULL;
+ this->m_gausstab = nullptr;
}
#ifdef __SSE2__
if (this->m_gausstab_sse) {
MEM_freeN(this->m_gausstab_sse);
- this->m_gausstab_sse = NULL;
+ this->m_gausstab_sse = nullptr;
}
#endif
@@ -189,7 +189,7 @@ bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input,
}
}
{
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ if (this->m_sizeavailable && this->m_gausstab != nullptr) {
newInput.xmax = input->xmax + this->m_filtersize + 1;
newInput.xmin = input->xmin - this->m_filtersize - 1;
newInput.ymax = input->ymax;
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
index 3ffa797c0c1..230538ba5e6 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
@@ -25,9 +25,9 @@
GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->m_gausstab = NULL;
+ this->m_gausstab = nullptr;
#ifdef __SSE2__
- this->m_gausstab_sse = NULL;
+ this->m_gausstab_sse = nullptr;
#endif
this->m_filtersize = 0;
}
@@ -38,7 +38,7 @@ void *GaussianYBlurOperation::initializeTileData(rcti * /*rect*/)
if (!this->m_sizeavailable) {
updateGauss();
}
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ void *buffer = getInputOperation(0)->initializeTileData(nullptr);
unlockMutex();
return buffer;
}
@@ -62,7 +62,7 @@ void GaussianYBlurOperation::initExecution()
void GaussianYBlurOperation::updateGauss()
{
- if (this->m_gausstab == NULL) {
+ if (this->m_gausstab == nullptr) {
updateSize();
float rad = max_ff(m_size * m_data.sizey, 0.0f);
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
@@ -125,14 +125,14 @@ void GaussianYBlurOperation::executeOpenCL(OpenCLDevice *device,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
cl_kernel gaussianYBlurOperationKernel = device->COM_clCreateKernel(
- "gaussianYBlurOperationKernel", NULL);
+ "gaussianYBlurOperationKernel", nullptr);
cl_int filter_size = this->m_filtersize;
cl_mem gausstab = clCreateBuffer(device->getContext(),
CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
sizeof(float) * (this->m_filtersize * 2 + 1),
this->m_gausstab,
- NULL);
+ nullptr);
device->COM_clAttachMemoryBufferToKernelParameter(gaussianYBlurOperationKernel,
0,
@@ -159,12 +159,12 @@ void GaussianYBlurOperation::deinitExecution()
if (this->m_gausstab) {
MEM_freeN(this->m_gausstab);
- this->m_gausstab = NULL;
+ this->m_gausstab = nullptr;
}
#ifdef __SSE2__
if (this->m_gausstab_sse) {
MEM_freeN(this->m_gausstab_sse);
- this->m_gausstab_sse = NULL;
+ this->m_gausstab_sse = nullptr;
}
#endif
@@ -189,7 +189,7 @@ bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input,
}
}
{
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ if (this->m_sizeavailable && this->m_gausstab != nullptr) {
newInput.xmax = input->xmax;
newInput.xmin = input->xmin;
newInput.ymax = input->ymax + this->m_filtersize + 1;
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
index 278e65a7dfd..7b4d38fba3e 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
@@ -19,11 +19,11 @@
#include "COM_GlareBaseOperation.h"
#include "BLI_math.h"
-GlareBaseOperation::GlareBaseOperation() : SingleThreadedOperation()
+GlareBaseOperation::GlareBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_settings = NULL;
+ this->m_settings = nullptr;
}
void GlareBaseOperation::initExecution()
{
@@ -33,7 +33,7 @@ void GlareBaseOperation::initExecution()
void GlareBaseOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
SingleThreadedOperation::deinitExecution();
}
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
index d050d9b58a9..1a1922f828c 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
@@ -21,11 +21,11 @@
#include "IMB_colormanagement.h"
-GlareThresholdOperation::GlareThresholdOperation() : NodeOperation()
+GlareThresholdOperation::GlareThresholdOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_FIT);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
void GlareThresholdOperation::determineResolution(unsigned int resolution[2],
@@ -65,5 +65,5 @@ void GlareThresholdOperation::executePixelSampled(float output[4],
void GlareThresholdOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
index 8292413f6f1..df30e75cf27 100644
--- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
@@ -22,12 +22,12 @@
#include "BKE_colortools.h"
-HueSaturationValueCorrectOperation::HueSaturationValueCorrectOperation() : CurveBaseOperation()
+HueSaturationValueCorrectOperation::HueSaturationValueCorrectOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
void HueSaturationValueCorrectOperation::initExecution()
{
@@ -68,5 +68,5 @@ void HueSaturationValueCorrectOperation::executePixelSampled(float output[4],
void HueSaturationValueCorrectOperation::deinitExecution()
{
CurveBaseOperation::deinitExecution();
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
index ef321157320..8113adb9bbc 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_IDMaskOperation.h"
-IDMaskOperation::IDMaskOperation() : NodeOperation()
+IDMaskOperation::IDMaskOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp
index 38d2fbf9ed4..ae5b7293a8c 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_ImageOperation.cpp
@@ -27,24 +27,24 @@
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+
#include "RE_pipeline.h"
-#include "RE_render_ext.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
-BaseImageOperation::BaseImageOperation() : NodeOperation()
+BaseImageOperation::BaseImageOperation()
{
- this->m_image = NULL;
- this->m_buffer = NULL;
- this->m_imageFloatBuffer = NULL;
- this->m_imageByteBuffer = NULL;
- this->m_imageUser = NULL;
+ this->m_image = nullptr;
+ this->m_buffer = nullptr;
+ this->m_imageFloatBuffer = nullptr;
+ this->m_imageByteBuffer = nullptr;
+ this->m_imageUser = nullptr;
this->m_imagewidth = 0;
this->m_imageheight = 0;
this->m_framenumber = 0;
- this->m_depthBuffer = NULL;
+ this->m_depthBuffer = nullptr;
this->m_numberOfChannels = 0;
- this->m_rd = NULL;
- this->m_viewName = NULL;
+ this->m_rd = nullptr;
+ this->m_viewName = nullptr;
}
ImageOperation::ImageOperation() : BaseImageOperation()
{
@@ -64,8 +64,8 @@ ImBuf *BaseImageOperation::getImBuf()
ImBuf *ibuf;
ImageUser iuser = *this->m_imageUser;
- if (this->m_image == NULL) {
- return NULL;
+ if (this->m_image == nullptr) {
+ return nullptr;
}
/* local changes to the original ImageUser */
@@ -73,10 +73,10 @@ ImBuf *BaseImageOperation::getImBuf()
iuser.multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
}
- ibuf = BKE_image_acquire_ibuf(this->m_image, &iuser, NULL);
- if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
- BKE_image_release_ibuf(this->m_image, ibuf, NULL);
- return NULL;
+ ibuf = BKE_image_acquire_ibuf(this->m_image, &iuser, nullptr);
+ if (ibuf == nullptr || (ibuf->rect == nullptr && ibuf->rect_float == nullptr)) {
+ BKE_image_release_ibuf(this->m_image, ibuf, nullptr);
+ return nullptr;
}
return ibuf;
}
@@ -97,9 +97,9 @@ void BaseImageOperation::initExecution()
void BaseImageOperation::deinitExecution()
{
- this->m_imageFloatBuffer = NULL;
- this->m_imageByteBuffer = NULL;
- BKE_image_release_ibuf(this->m_image, this->m_buffer, NULL);
+ this->m_imageFloatBuffer = nullptr;
+ this->m_imageByteBuffer = nullptr;
+ BKE_image_release_ibuf(this->m_image, this->m_buffer, nullptr);
}
void BaseImageOperation::determineResolution(unsigned int resolution[2],
@@ -115,7 +115,7 @@ void BaseImageOperation::determineResolution(unsigned int resolution[2],
resolution[1] = stackbuf->y;
}
- BKE_image_release_ibuf(this->m_image, stackbuf, NULL);
+ BKE_image_release_ibuf(this->m_image, stackbuf, nullptr);
}
static void sampleImageAtLocation(
@@ -124,13 +124,13 @@ static void sampleImageAtLocation(
if (ibuf->rect_float) {
switch (sampler) {
case COM_PS_NEAREST:
- nearest_interpolation_color(ibuf, NULL, color, x, y);
+ nearest_interpolation_color(ibuf, nullptr, color, x, y);
break;
case COM_PS_BILINEAR:
- bilinear_interpolation_color(ibuf, NULL, color, x, y);
+ bilinear_interpolation_color(ibuf, nullptr, color, x, y);
break;
case COM_PS_BICUBIC:
- bicubic_interpolation_color(ibuf, NULL, color, x, y);
+ bicubic_interpolation_color(ibuf, nullptr, color, x, y);
break;
}
}
@@ -138,13 +138,13 @@ static void sampleImageAtLocation(
unsigned char byte_color[4];
switch (sampler) {
case COM_PS_NEAREST:
- nearest_interpolation_color(ibuf, byte_color, NULL, x, y);
+ nearest_interpolation_color(ibuf, byte_color, nullptr, x, y);
break;
case COM_PS_BILINEAR:
- bilinear_interpolation_color(ibuf, byte_color, NULL, x, y);
+ bilinear_interpolation_color(ibuf, byte_color, nullptr, x, y);
break;
case COM_PS_BICUBIC:
- bicubic_interpolation_color(ibuf, byte_color, NULL, x, y);
+ bicubic_interpolation_color(ibuf, byte_color, nullptr, x, y);
break;
}
rgba_uchar_to_float(color, byte_color);
@@ -157,7 +157,7 @@ static void sampleImageAtLocation(
void ImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
int ix = x, iy = y;
- if (this->m_imageFloatBuffer == NULL && this->m_imageByteBuffer == NULL) {
+ if (this->m_imageFloatBuffer == nullptr && this->m_imageByteBuffer == nullptr) {
zero_v4(output);
}
else if (ix < 0 || iy < 0 || ix >= this->m_buffer->x || iy >= this->m_buffer->y) {
@@ -175,7 +175,7 @@ void ImageAlphaOperation::executePixelSampled(float output[4],
{
float tempcolor[4];
- if (this->m_imageFloatBuffer == NULL && this->m_imageByteBuffer == NULL) {
+ if (this->m_imageFloatBuffer == nullptr && this->m_imageByteBuffer == nullptr) {
output[0] = 0.0f;
}
else {
@@ -190,7 +190,7 @@ void ImageDepthOperation::executePixelSampled(float output[4],
float y,
PixelSampler /*sampler*/)
{
- if (this->m_depthBuffer == NULL) {
+ if (this->m_depthBuffer == nullptr) {
output[0] = 0.0f;
}
else {
diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h
index fcffdc7aae9..bff8dcc1cea 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.h
+++ b/source/blender/compositor/operations/COM_ImageOperation.h
@@ -25,8 +25,7 @@
#include "MEM_guardedalloc.h"
#include "RE_pipeline.h"
-#include "RE_render_ext.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
/**
* \brief Base class for all image operations
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp
index 0555ee24b9b..502b33d7e14 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.cpp
+++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp
@@ -27,24 +27,24 @@
BLI_assert(x >= 0 && x < this->getWidth() && y >= 0 && y < this->getHeight())
// Inpaint (simple convolve using average of known pixels)
-InpaintSimpleOperation::InpaintSimpleOperation() : NodeOperation()
+InpaintSimpleOperation::InpaintSimpleOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
- this->m_inputImageProgram = NULL;
- this->m_pixelorder = NULL;
- this->m_manhattan_distance = NULL;
- this->m_cached_buffer = NULL;
+ this->m_inputImageProgram = nullptr;
+ this->m_pixelorder = nullptr;
+ this->m_manhattan_distance = nullptr;
+ this->m_cached_buffer = nullptr;
this->m_cached_buffer_ready = false;
}
void InpaintSimpleOperation::initExecution()
{
this->m_inputImageProgram = this->getInputSocketReader(0);
- this->m_pixelorder = NULL;
- this->m_manhattan_distance = NULL;
- this->m_cached_buffer = NULL;
+ this->m_pixelorder = nullptr;
+ this->m_manhattan_distance = nullptr;
+ this->m_cached_buffer = nullptr;
this->m_cached_buffer_ready = false;
this->initMutex();
@@ -246,21 +246,21 @@ void InpaintSimpleOperation::executePixel(float output[4], int x, int y, void *
void InpaintSimpleOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
+ this->m_inputImageProgram = nullptr;
this->deinitMutex();
if (this->m_cached_buffer) {
MEM_freeN(this->m_cached_buffer);
- this->m_cached_buffer = NULL;
+ this->m_cached_buffer = nullptr;
}
if (this->m_pixelorder) {
MEM_freeN(this->m_pixelorder);
- this->m_pixelorder = NULL;
+ this->m_pixelorder = nullptr;
}
if (this->m_manhattan_distance) {
MEM_freeN(this->m_manhattan_distance);
- this->m_manhattan_distance = NULL;
+ this->m_manhattan_distance = nullptr;
}
this->m_cached_buffer_ready = false;
}
diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp
index bfd9d14a1ef..d9f436a3e28 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_InvertOperation.cpp
@@ -18,13 +18,13 @@
#include "COM_InvertOperation.h"
-InvertOperation::InvertOperation() : NodeOperation()
+InvertOperation::InvertOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputValueProgram = NULL;
- this->m_inputColorProgram = NULL;
+ this->m_inputValueProgram = nullptr;
+ this->m_inputColorProgram = nullptr;
this->m_color = true;
this->m_alpha = false;
setResolutionInputSocketIndex(1);
@@ -64,6 +64,6 @@ void InvertOperation::executePixelSampled(float output[4], float x, float y, Pix
void InvertOperation::deinitExecution()
{
- this->m_inputValueProgram = NULL;
- this->m_inputColorProgram = NULL;
+ this->m_inputValueProgram = nullptr;
+ this->m_inputColorProgram = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
index 83dd90ef08b..72bf86facfb 100644
--- a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
@@ -23,7 +23,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
-KeyingBlurOperation::KeyingBlurOperation() : NodeOperation()
+KeyingBlurOperation::KeyingBlurOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
index eafd1e671f8..592f116c451 100644
--- a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
@@ -23,7 +23,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
-KeyingClipOperation::KeyingClipOperation() : NodeOperation()
+KeyingClipOperation::KeyingClipOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
index a1ba49a69b2..b9bb316462d 100644
--- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
@@ -23,7 +23,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
-KeyingDespillOperation::KeyingDespillOperation() : NodeOperation()
+KeyingDespillOperation::KeyingDespillOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
@@ -32,8 +32,8 @@ KeyingDespillOperation::KeyingDespillOperation() : NodeOperation()
this->m_despillFactor = 0.5f;
this->m_colorBalance = 0.5f;
- this->m_pixelReader = NULL;
- this->m_screenReader = NULL;
+ this->m_pixelReader = nullptr;
+ this->m_screenReader = nullptr;
}
void KeyingDespillOperation::initExecution()
@@ -44,8 +44,8 @@ void KeyingDespillOperation::initExecution()
void KeyingDespillOperation::deinitExecution()
{
- this->m_pixelReader = NULL;
- this->m_screenReader = NULL;
+ this->m_pixelReader = nullptr;
+ this->m_screenReader = nullptr;
}
void KeyingDespillOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp
index 50562143ce6..9ef4217d300 100644
--- a/source/blender/compositor/operations/COM_KeyingOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp
@@ -39,7 +39,7 @@ static float get_pixel_saturation(const float pixelColor[4],
return (pixelColor[primary_channel] - val) * fabsf(1.0f - val);
}
-KeyingOperation::KeyingOperation() : NodeOperation()
+KeyingOperation::KeyingOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
@@ -47,8 +47,8 @@ KeyingOperation::KeyingOperation() : NodeOperation()
this->m_screenBalance = 0.5f;
- this->m_pixelReader = NULL;
- this->m_screenReader = NULL;
+ this->m_pixelReader = nullptr;
+ this->m_screenReader = nullptr;
}
void KeyingOperation::initExecution()
@@ -59,8 +59,8 @@ void KeyingOperation::initExecution()
void KeyingOperation::deinitExecution()
{
- this->m_pixelReader = NULL;
- this->m_screenReader = NULL;
+ this->m_pixelReader = nullptr;
+ this->m_screenReader = nullptr;
}
void KeyingOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
index 082091411fb..463a6fe49c0 100644
--- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
@@ -30,10 +30,10 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-KeyingScreenOperation::KeyingScreenOperation() : NodeOperation()
+KeyingScreenOperation::KeyingScreenOperation()
{
this->addOutputSocket(COM_DT_COLOR);
- this->m_movieClip = NULL;
+ this->m_movieClip = nullptr;
this->m_framenumber = 0;
this->m_trackingObject[0] = 0;
setComplex(true);
@@ -42,7 +42,7 @@ KeyingScreenOperation::KeyingScreenOperation() : NodeOperation()
void KeyingScreenOperation::initExecution()
{
initMutex();
- this->m_cachedTriangulation = NULL;
+ this->m_cachedTriangulation = nullptr;
}
void KeyingScreenOperation::deinitExecution()
@@ -64,7 +64,7 @@ void KeyingScreenOperation::deinitExecution()
MEM_freeN(this->m_cachedTriangulation);
- this->m_cachedTriangulation = NULL;
+ this->m_cachedTriangulation = nullptr;
}
}
@@ -77,7 +77,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
VoronoiSite *sites, *site;
ImBuf *ibuf;
ListBase *tracksbase;
- ListBase edges = {NULL, NULL};
+ ListBase edges = {nullptr, nullptr};
int sites_total;
int i;
int width = this->getWidth();
@@ -88,7 +88,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->m_trackingObject);
if (!object) {
- return NULL;
+ return nullptr;
}
tracksbase = BKE_tracking_object_get_tracks(tracking, object);
@@ -117,14 +117,14 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
}
if (!sites_total) {
- return NULL;
+ return nullptr;
}
BKE_movieclip_user_set_frame(&user, clip_frame);
ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, &user);
if (!ibuf) {
- return NULL;
+ return nullptr;
}
triangulation = (TriangulationData *)MEM_callocN(sizeof(TriangulationData),
@@ -232,13 +232,13 @@ void *KeyingScreenOperation::initializeTileData(rcti *rect)
int chunk_size = 20;
int i;
- if (this->m_movieClip == NULL) {
- return NULL;
+ if (this->m_movieClip == nullptr) {
+ return nullptr;
}
if (!this->m_cachedTriangulation) {
lockMutex();
- if (this->m_cachedTriangulation == NULL) {
+ if (this->m_cachedTriangulation == nullptr) {
this->m_cachedTriangulation = buildVoronoiTriangulation();
}
unlockMutex();
@@ -247,13 +247,13 @@ void *KeyingScreenOperation::initializeTileData(rcti *rect)
triangulation = this->m_cachedTriangulation;
if (!triangulation) {
- return NULL;
+ return nullptr;
}
tile_data = (TileData *)MEM_callocN(sizeof(TileData), "keying screen tile data");
for (i = 0; i < triangulation->triangles_total; i++) {
- if (BLI_rcti_isect(rect, &triangulation->triangles_AABB[i], NULL)) {
+ if (BLI_rcti_isect(rect, &triangulation->triangles_AABB[i], nullptr)) {
tile_data->triangles_total++;
if (tile_data->triangles_total > triangles_allocated) {
diff --git a/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp b/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp
new file mode 100644
index 00000000000..47daef8d190
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ *
+ * Copyright 2020, Blender Foundation.
+ */
+
+#include "COM_KeyingSetAlphaOperation.h"
+
+KeyingSetAlphaOperation::KeyingSetAlphaOperation()
+{
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->m_inputColor = nullptr;
+ this->m_inputAlpha = nullptr;
+}
+
+void KeyingSetAlphaOperation::initExecution()
+{
+ this->m_inputColor = getInputSocketReader(0);
+ this->m_inputAlpha = getInputSocketReader(1);
+}
+
+void KeyingSetAlphaOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
+{
+ float color_input[4];
+ float alpha_input[4];
+
+ this->m_inputColor->readSampled(color_input, x, y, sampler);
+ this->m_inputAlpha->readSampled(alpha_input, x, y, sampler);
+
+ mul_v4_v4fl(output, color_input, alpha_input[0]);
+}
+
+void KeyingSetAlphaOperation::deinitExecution()
+{
+ this->m_inputColor = nullptr;
+ this->m_inputAlpha = nullptr;
+}
diff --git a/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.h b/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.h
new file mode 100644
index 00000000000..b786240f215
--- /dev/null
+++ b/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.h
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * Copyright 2020, Blender Foundation.
+ */
+
+#pragma once
+
+#include "COM_NodeOperation.h"
+
+/**
+ * Operation which is used by keying node to modify image's alpha channels.
+ * It keeps color properly pre-multiplied.
+ */
+class KeyingSetAlphaOperation : public NodeOperation {
+ private:
+ SocketReader *m_inputColor;
+ SocketReader *m_inputAlpha;
+
+ public:
+ KeyingSetAlphaOperation();
+
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ void initExecution();
+ void deinitExecution();
+};
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
index 936ac00a0e8..f7cc6e2d4de 100644
--- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
@@ -21,12 +21,12 @@
#include "IMB_colormanagement.h"
-LuminanceMatteOperation::LuminanceMatteOperation() : NodeOperation()
+LuminanceMatteOperation::LuminanceMatteOperation()
{
addInputSocket(COM_DT_COLOR);
addOutputSocket(COM_DT_VALUE);
- this->m_inputImageProgram = NULL;
+ this->m_inputImageProgram = nullptr;
}
void LuminanceMatteOperation::initExecution()
@@ -36,7 +36,7 @@ void LuminanceMatteOperation::initExecution()
void LuminanceMatteOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
+ this->m_inputImageProgram = nullptr;
}
void LuminanceMatteOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
index ff5804a63a4..95b3c27ac2f 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_MapRangeOperation.h"
-MapRangeOperation::MapRangeOperation() : NodeOperation()
+MapRangeOperation::MapRangeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
@@ -26,7 +26,7 @@ MapRangeOperation::MapRangeOperation() : NodeOperation()
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
this->m_useClamp = false;
}
@@ -95,9 +95,9 @@ void MapRangeOperation::executePixelSampled(float output[4],
void MapRangeOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_sourceMinOperation = NULL;
- this->m_sourceMaxOperation = NULL;
- this->m_destMinOperation = NULL;
- this->m_destMaxOperation = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_sourceMinOperation = nullptr;
+ this->m_sourceMaxOperation = nullptr;
+ this->m_destMinOperation = nullptr;
+ this->m_destMaxOperation = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp
index 9101b82202a..32ab63ae028 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_MapUVOperation.h"
#include "BLI_math.h"
-MapUVOperation::MapUVOperation() : NodeOperation()
+MapUVOperation::MapUVOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addInputSocket(COM_DT_VECTOR);
@@ -28,8 +28,8 @@ MapUVOperation::MapUVOperation() : NodeOperation()
this->setComplex(true);
setResolutionInputSocketIndex(1);
- this->m_inputUVProgram = NULL;
- this->m_inputColorProgram = NULL;
+ this->m_inputUVProgram = nullptr;
+ this->m_inputColorProgram = nullptr;
}
void MapUVOperation::initExecution()
@@ -149,8 +149,8 @@ void MapUVOperation::pixelTransform(const float xy[2],
void MapUVOperation::deinitExecution()
{
- this->m_inputUVProgram = NULL;
- this->m_inputColorProgram = NULL;
+ this->m_inputUVProgram = nullptr;
+ this->m_inputColorProgram = nullptr;
}
bool MapUVOperation::determineDependingAreaOfInterest(rcti *input,
@@ -159,7 +159,7 @@ bool MapUVOperation::determineDependingAreaOfInterest(rcti *input,
{
rcti colorInput;
rcti uvInput;
- NodeOperation *operation = NULL;
+ NodeOperation *operation = nullptr;
/* the uv buffer only needs a 3x3 buffer. The image needs whole buffer */
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp
index 45104d11210..7f2044b9139 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp
@@ -18,11 +18,11 @@
#include "COM_MapValueOperation.h"
-MapValueOperation::MapValueOperation() : NodeOperation()
+MapValueOperation::MapValueOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
void MapValueOperation::initExecution()
@@ -55,5 +55,5 @@ void MapValueOperation::executePixelSampled(float output[4],
void MapValueOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp
index 9fc7448ce42..ab908590c55 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_MaskOperation.cpp
@@ -26,10 +26,10 @@
#include "BKE_lib_id.h"
#include "BKE_mask.h"
-MaskOperation::MaskOperation() : NodeOperation()
+MaskOperation::MaskOperation()
{
this->addOutputSocket(COM_DT_VALUE);
- this->m_mask = NULL;
+ this->m_mask = nullptr;
this->m_maskWidth = 0;
this->m_maskHeight = 0;
this->m_maskWidthInv = 0.0f;
@@ -42,7 +42,7 @@ MaskOperation::MaskOperation() : NodeOperation()
void MaskOperation::initExecution()
{
- if (this->m_mask && this->m_rasterMaskHandles[0] == NULL) {
+ if (this->m_mask && this->m_rasterMaskHandles[0] == nullptr) {
if (this->m_rasterMaskHandleTot == 1) {
this->m_rasterMaskHandles[0] = BKE_maskrasterize_handle_new();
@@ -61,7 +61,7 @@ void MaskOperation::initExecution()
float frame_iter = frame;
Mask *mask_temp = (Mask *)BKE_id_copy_ex(
- NULL, &this->m_mask->id, NULL, LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA);
+ nullptr, &this->m_mask->id, nullptr, LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA);
/* trick so we can get unkeyed edits to display */
{
@@ -92,7 +92,7 @@ void MaskOperation::initExecution()
frame_iter += frame_step;
}
- BKE_id_free(NULL, &mask_temp->id);
+ BKE_id_free(nullptr, &mask_temp->id);
}
}
}
@@ -102,7 +102,7 @@ void MaskOperation::deinitExecution()
for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
if (this->m_rasterMaskHandles[i]) {
BKE_maskrasterize_handle_free(this->m_rasterMaskHandles[i]);
- this->m_rasterMaskHandles[i] = NULL;
+ this->m_rasterMaskHandles[i] = nullptr;
}
}
}
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index 1363b75433a..edd5bb6d139 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -20,15 +20,15 @@
#include "BLI_math.h"
-MathBaseOperation::MathBaseOperation() : NodeOperation()
+MathBaseOperation::MathBaseOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
- this->m_inputValue1Operation = NULL;
- this->m_inputValue2Operation = NULL;
- this->m_inputValue3Operation = NULL;
+ this->m_inputValue1Operation = nullptr;
+ this->m_inputValue2Operation = nullptr;
+ this->m_inputValue3Operation = nullptr;
this->m_useClamp = false;
}
@@ -41,9 +41,9 @@ void MathBaseOperation::initExecution()
void MathBaseOperation::deinitExecution()
{
- this->m_inputValue1Operation = NULL;
- this->m_inputValue2Operation = NULL;
- this->m_inputValue3Operation = NULL;
+ this->m_inputValue1Operation = nullptr;
+ this->m_inputValue2Operation = nullptr;
+ this->m_inputValue3Operation = nullptr;
}
void MathBaseOperation::determineResolution(unsigned int resolution[2],
diff --git a/source/blender/compositor/operations/COM_MixOperation.cpp b/source/blender/compositor/operations/COM_MixOperation.cpp
index 371da20044f..948e69bf8eb 100644
--- a/source/blender/compositor/operations/COM_MixOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixOperation.cpp
@@ -22,15 +22,15 @@
/* ******** Mix Base Operation ******** */
-MixBaseOperation::MixBaseOperation() : NodeOperation()
+MixBaseOperation::MixBaseOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputValueOperation = NULL;
- this->m_inputColor1Operation = NULL;
- this->m_inputColor2Operation = NULL;
+ this->m_inputValueOperation = nullptr;
+ this->m_inputColor1Operation = nullptr;
+ this->m_inputColor2Operation = nullptr;
this->setUseValueAlphaMultiply(false);
this->setUseClamp(false);
}
@@ -90,14 +90,14 @@ void MixBaseOperation::determineResolution(unsigned int resolution[2],
void MixBaseOperation::deinitExecution()
{
- this->m_inputValueOperation = NULL;
- this->m_inputColor1Operation = NULL;
- this->m_inputColor2Operation = NULL;
+ this->m_inputValueOperation = nullptr;
+ this->m_inputColor1Operation = nullptr;
+ this->m_inputColor2Operation = nullptr;
}
/* ******** Mix Add Operation ******** */
-MixAddOperation::MixAddOperation() : MixBaseOperation()
+MixAddOperation::MixAddOperation()
{
/* pass */
}
@@ -126,7 +126,7 @@ void MixAddOperation::executePixelSampled(float output[4], float x, float y, Pix
/* ******** Mix Blend Operation ******** */
-MixBlendOperation::MixBlendOperation() : MixBaseOperation()
+MixBlendOperation::MixBlendOperation()
{
/* pass */
}
@@ -160,7 +160,7 @@ void MixBlendOperation::executePixelSampled(float output[4],
/* ******** Mix Burn Operation ******** */
-MixColorBurnOperation::MixColorBurnOperation() : MixBaseOperation()
+MixColorBurnOperation::MixColorBurnOperation()
{
/* pass */
}
@@ -243,7 +243,7 @@ void MixColorBurnOperation::executePixelSampled(float output[4],
/* ******** Mix Color Operation ******** */
-MixColorOperation::MixColorOperation() : MixBaseOperation()
+MixColorOperation::MixColorOperation()
{
/* pass */
}
@@ -288,7 +288,7 @@ void MixColorOperation::executePixelSampled(float output[4],
/* ******** Mix Darken Operation ******** */
-MixDarkenOperation::MixDarkenOperation() : MixBaseOperation()
+MixDarkenOperation::MixDarkenOperation()
{
/* pass */
}
@@ -321,7 +321,7 @@ void MixDarkenOperation::executePixelSampled(float output[4],
/* ******** Mix Difference Operation ******** */
-MixDifferenceOperation::MixDifferenceOperation() : MixBaseOperation()
+MixDifferenceOperation::MixDifferenceOperation()
{
/* pass */
}
@@ -354,7 +354,7 @@ void MixDifferenceOperation::executePixelSampled(float output[4],
/* ******** Mix Difference Operation ******** */
-MixDivideOperation::MixDivideOperation() : MixBaseOperation()
+MixDivideOperation::MixDivideOperation()
{
/* pass */
}
@@ -404,7 +404,7 @@ void MixDivideOperation::executePixelSampled(float output[4],
/* ******** Mix Dodge Operation ******** */
-MixDodgeOperation::MixDodgeOperation() : MixBaseOperation()
+MixDodgeOperation::MixDodgeOperation()
{
/* pass */
}
@@ -492,7 +492,7 @@ void MixDodgeOperation::executePixelSampled(float output[4],
/* ******** Mix Glare Operation ******** */
-MixGlareOperation::MixGlareOperation() : MixBaseOperation()
+MixGlareOperation::MixGlareOperation()
{
/* pass */
}
@@ -533,7 +533,7 @@ void MixGlareOperation::executePixelSampled(float output[4],
/* ******** Mix Hue Operation ******** */
-MixHueOperation::MixHueOperation() : MixBaseOperation()
+MixHueOperation::MixHueOperation()
{
/* pass */
}
@@ -575,7 +575,7 @@ void MixHueOperation::executePixelSampled(float output[4], float x, float y, Pix
/* ******** Mix Lighten Operation ******** */
-MixLightenOperation::MixLightenOperation() : MixBaseOperation()
+MixLightenOperation::MixLightenOperation()
{
/* pass */
}
@@ -626,7 +626,7 @@ void MixLightenOperation::executePixelSampled(float output[4],
/* ******** Mix Linear Light Operation ******** */
-MixLinearLightOperation::MixLinearLightOperation() : MixBaseOperation()
+MixLinearLightOperation::MixLinearLightOperation()
{
/* pass */
}
@@ -674,7 +674,7 @@ void MixLinearLightOperation::executePixelSampled(float output[4],
/* ******** Mix Multiply Operation ******** */
-MixMultiplyOperation::MixMultiplyOperation() : MixBaseOperation()
+MixMultiplyOperation::MixMultiplyOperation()
{
/* pass */
}
@@ -707,7 +707,7 @@ void MixMultiplyOperation::executePixelSampled(float output[4],
/* ******** Mix Ovelray Operation ******** */
-MixOverlayOperation::MixOverlayOperation() : MixBaseOperation()
+MixOverlayOperation::MixOverlayOperation()
{
/* pass */
}
@@ -757,7 +757,7 @@ void MixOverlayOperation::executePixelSampled(float output[4],
/* ******** Mix Saturation Operation ******** */
-MixSaturationOperation::MixSaturationOperation() : MixBaseOperation()
+MixSaturationOperation::MixSaturationOperation()
{
/* pass */
}
@@ -799,7 +799,7 @@ void MixSaturationOperation::executePixelSampled(float output[4],
/* ******** Mix Screen Operation ******** */
-MixScreenOperation::MixScreenOperation() : MixBaseOperation()
+MixScreenOperation::MixScreenOperation()
{
/* pass */
}
@@ -833,7 +833,7 @@ void MixScreenOperation::executePixelSampled(float output[4],
/* ******** Mix Soft Light Operation ******** */
-MixSoftLightOperation::MixSoftLightOperation() : MixBaseOperation()
+MixSoftLightOperation::MixSoftLightOperation()
{
/* pass */
}
@@ -879,7 +879,7 @@ void MixSoftLightOperation::executePixelSampled(float output[4],
/* ******** Mix Subtract Operation ******** */
-MixSubtractOperation::MixSubtractOperation() : MixBaseOperation()
+MixSubtractOperation::MixSubtractOperation()
{
/* pass */
}
@@ -911,7 +911,7 @@ void MixSubtractOperation::executePixelSampled(float output[4],
/* ******** Mix Value Operation ******** */
-MixValueOperation::MixValueOperation() : MixBaseOperation()
+MixValueOperation::MixValueOperation()
{
/* pass */
}
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
index 34773a1e4f8..725aacc7d34 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
@@ -21,7 +21,7 @@
#include "BKE_movieclip.h"
#include "BKE_tracking.h"
-MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation()
+MovieClipAttributeOperation::MovieClipAttributeOperation()
{
this->addOutputSocket(COM_DT_VALUE);
this->m_framenumber = 0;
@@ -31,7 +31,7 @@ MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation()
void MovieClipAttributeOperation::initExecution()
{
- if (this->m_clip == NULL) {
+ if (this->m_clip == nullptr) {
return;
}
float loc[2], scale, angle;
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
index 17794ae879e..4f819bf27af 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
@@ -26,11 +26,11 @@
#include "IMB_imbuf.h"
-MovieClipBaseOperation::MovieClipBaseOperation() : NodeOperation()
+MovieClipBaseOperation::MovieClipBaseOperation()
{
- this->m_movieClip = NULL;
- this->m_movieClipBuffer = NULL;
- this->m_movieClipUser = NULL;
+ this->m_movieClip = nullptr;
+ this->m_movieClipBuffer = nullptr;
+ this->m_movieClipUser = nullptr;
this->m_movieClipwidth = 0;
this->m_movieClipheight = 0;
this->m_framenumber = 0;
@@ -52,7 +52,7 @@ void MovieClipBaseOperation::initExecution()
if (ibuf) {
this->m_movieClipBuffer = ibuf;
- if (ibuf->rect_float == NULL || ibuf->userflags & IB_RECT_INVALID) {
+ if (ibuf->rect_float == nullptr || ibuf->userflags & IB_RECT_INVALID) {
IMB_float_from_rect(ibuf);
ibuf->userflags &= ~IB_RECT_INVALID;
}
@@ -65,7 +65,7 @@ void MovieClipBaseOperation::deinitExecution()
if (this->m_movieClipBuffer) {
IMB_freeImBuf(this->m_movieClipBuffer);
- this->m_movieClipBuffer = NULL;
+ this->m_movieClipBuffer = nullptr;
}
}
@@ -92,23 +92,23 @@ void MovieClipBaseOperation::executePixelSampled(float output[4],
{
ImBuf *ibuf = this->m_movieClipBuffer;
- if (ibuf == NULL) {
+ if (ibuf == nullptr) {
zero_v4(output);
}
- else if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
+ else if (ibuf->rect == nullptr && ibuf->rect_float == nullptr) {
/* Happens for multilayer exr, i.e. */
zero_v4(output);
}
else {
switch (sampler) {
case COM_PS_NEAREST:
- nearest_interpolation_color(ibuf, NULL, output, x, y);
+ nearest_interpolation_color(ibuf, nullptr, output, x, y);
break;
case COM_PS_BILINEAR:
- bilinear_interpolation_color(ibuf, NULL, output, x, y);
+ bilinear_interpolation_color(ibuf, nullptr, output, x, y);
break;
case COM_PS_BICUBIC:
- bicubic_interpolation_color(ibuf, NULL, output, x, y);
+ bicubic_interpolation_color(ibuf, nullptr, output, x, y);
break;
}
}
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
index 67491d51547..5031d590720 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
@@ -23,13 +23,13 @@
#include "BLI_linklist.h"
-MovieDistortionOperation::MovieDistortionOperation(bool distortion) : NodeOperation()
+MovieDistortionOperation::MovieDistortionOperation(bool distortion)
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->m_movieClip = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_movieClip = nullptr;
this->m_apply = distortion;
}
@@ -66,15 +66,15 @@ void MovieDistortionOperation::initExecution()
}
else {
m_margin[0] = m_margin[1] = 0;
- this->m_distortion = NULL;
+ this->m_distortion = nullptr;
}
}
void MovieDistortionOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_movieClip = NULL;
- if (this->m_distortion != NULL) {
+ this->m_inputOperation = nullptr;
+ this->m_movieClip = nullptr;
+ if (this->m_distortion != nullptr) {
BKE_tracking_distortion_free(this->m_distortion);
}
}
@@ -84,7 +84,7 @@ void MovieDistortionOperation::executePixelSampled(float output[4],
float y,
PixelSampler /*sampler*/)
{
- if (this->m_distortion != NULL) {
+ if (this->m_distortion != nullptr) {
/* float overscan = 0.0f; */
const float pixel_aspect = this->m_pixel_aspect;
const float w = (float)this->m_width /* / (1 + overscan) */;
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
index 8878b05ade7..023538ee5b1 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
@@ -21,7 +21,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-MultilayerBaseOperation::MultilayerBaseOperation(int passindex, int view) : BaseImageOperation()
+MultilayerBaseOperation::MultilayerBaseOperation(int passindex, int view)
{
this->m_passId = passindex;
this->m_view = view;
@@ -42,7 +42,7 @@ ImBuf *MultilayerBaseOperation::getImBuf()
}
this->m_imageUser->view = view;
- return NULL;
+ return nullptr;
}
void MultilayerColorOperation::executePixelSampled(float output[4],
@@ -50,20 +50,20 @@ void MultilayerColorOperation::executePixelSampled(float output[4],
float y,
PixelSampler sampler)
{
- if (this->m_imageFloatBuffer == NULL) {
+ if (this->m_imageFloatBuffer == nullptr) {
zero_v4(output);
}
else {
if (this->m_numberOfChannels == 4) {
switch (sampler) {
case COM_PS_NEAREST:
- nearest_interpolation_color(this->m_buffer, NULL, output, x, y);
+ nearest_interpolation_color(this->m_buffer, nullptr, output, x, y);
break;
case COM_PS_BILINEAR:
- bilinear_interpolation_color(this->m_buffer, NULL, output, x, y);
+ bilinear_interpolation_color(this->m_buffer, nullptr, output, x, y);
break;
case COM_PS_BICUBIC:
- bicubic_interpolation_color(this->m_buffer, NULL, output, x, y);
+ bicubic_interpolation_color(this->m_buffer, nullptr, output, x, y);
break;
}
}
@@ -87,7 +87,7 @@ void MultilayerValueOperation::executePixelSampled(float output[4],
float y,
PixelSampler /*sampler*/)
{
- if (this->m_imageFloatBuffer == NULL) {
+ if (this->m_imageFloatBuffer == nullptr) {
output[0] = 0.0f;
}
else {
@@ -109,7 +109,7 @@ void MultilayerVectorOperation::executePixelSampled(float output[4],
float y,
PixelSampler /*sampler*/)
{
- if (this->m_imageFloatBuffer == NULL) {
+ if (this->m_imageFloatBuffer == nullptr) {
output[0] = 0.0f;
}
else {
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.cpp b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
index 55faa480b83..a8448685332 100644
--- a/source/blender/compositor/operations/COM_NormalizeOperation.cpp
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
@@ -18,12 +18,12 @@
#include "COM_NormalizeOperation.h"
-NormalizeOperation::NormalizeOperation() : NodeOperation()
+NormalizeOperation::NormalizeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
- this->m_imageReader = NULL;
- this->m_cachedInstance = NULL;
+ this->m_imageReader = nullptr;
+ this->m_cachedInstance = nullptr;
this->setComplex(true);
}
void NormalizeOperation::initExecution()
@@ -37,7 +37,7 @@ void NormalizeOperation::executePixel(float output[4], int x, int y, void *data)
/* using generic two floats struct to store x: min y: mult */
NodeTwoFloats *minmult = (NodeTwoFloats *)data;
- this->m_imageReader->read(output, x, y, NULL);
+ this->m_imageReader->read(output, x, y, nullptr);
output[0] = (output[0] - minmult->x) * minmult->y;
@@ -52,7 +52,7 @@ void NormalizeOperation::executePixel(float output[4], int x, int y, void *data)
void NormalizeOperation::deinitExecution()
{
- this->m_imageReader = NULL;
+ this->m_imageReader = nullptr;
delete this->m_cachedInstance;
NodeOperation::deinitMutex();
}
@@ -85,7 +85,7 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti * /*input*/,
void *NormalizeOperation::initializeTileData(rcti *rect)
{
lockMutex();
- if (this->m_cachedInstance == NULL) {
+ if (this->m_cachedInstance == nullptr) {
MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
/* using generic two floats struct to store x: min y: mult */
NodeTwoFloats *minmult = new NodeTwoFloats();
diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
index c0fe7237687..f7fabfb9572 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
@@ -76,15 +76,15 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filenam
}
IMB_exr_add_view(exrhandle, srv->name);
- add_exr_channels(exrhandle, NULL, this->m_datatype, srv->name, width, false, NULL);
+ add_exr_channels(exrhandle, nullptr, this->m_datatype, srv->name, width, false, nullptr);
}
BLI_make_existing_file(filename);
/* prepare the file with all the channels */
- if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_format->exr_codec, NULL) ==
- 0) {
+ if (IMB_exr_begin_write(
+ exrhandle, filename, width, height, this->m_format->exr_codec, nullptr) == 0) {
printf("Error Writing Singlelayer Multiview Openexr\n");
IMB_exr_close(exrhandle);
}
@@ -93,7 +93,7 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filenam
return exrhandle;
}
}
- return NULL;
+ return nullptr;
}
void OutputOpenExrSingleLayerMultiViewOperation::deinitExecution()
@@ -112,11 +112,11 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinitExecution()
R_IMF_IMTYPE_OPENEXR,
(this->m_rd->scemode & R_EXTENSION) != 0,
true,
- NULL);
+ nullptr);
exrhandle = this->get_handle(filename);
add_exr_channels(exrhandle,
- NULL,
+ nullptr,
this->m_datatype,
this->m_viewName,
width,
@@ -124,15 +124,15 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinitExecution()
this->m_outputBuffer);
/* memory can only be freed after we write all views to the file */
- this->m_outputBuffer = NULL;
- this->m_imageInput = NULL;
+ this->m_outputBuffer = nullptr;
+ this->m_imageInput = nullptr;
/* ready to close the file */
if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
IMB_exr_write_channels(exrhandle);
/* free buffer memory for all the views */
- free_exr_channels(exrhandle, this->m_rd, NULL, this->m_datatype);
+ free_exr_channels(exrhandle, this->m_rd, nullptr, this->m_datatype);
/* remove exr handle and data */
IMB_exr_close(exrhandle);
@@ -188,14 +188,14 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename
srv->name,
width,
this->m_exr_half_float,
- NULL);
+ nullptr);
}
}
BLI_make_existing_file(filename);
/* prepare the file with all the channels for the header */
- if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, NULL) == 0) {
+ if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, nullptr) == 0) {
printf("Error Writing Multilayer Multiview Openexr\n");
IMB_exr_close(exrhandle);
}
@@ -204,7 +204,7 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename
return exrhandle;
}
}
- return NULL;
+ return nullptr;
}
void OutputOpenExrMultiLayerMultiViewOperation::deinitExecution()
@@ -223,7 +223,7 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinitExecution()
R_IMF_IMTYPE_MULTILAYER,
(this->m_rd->scemode & R_EXTENSION) != 0,
true,
- NULL);
+ nullptr);
exrhandle = this->get_handle(filename);
@@ -239,8 +239,8 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinitExecution()
for (unsigned int i = 0; i < this->m_layers.size(); i++) {
/* memory can only be freed after we write all views to the file */
- this->m_layers[i].outputBuffer = NULL;
- this->m_layers[i].imageInput = NULL;
+ this->m_layers[i].outputBuffer = nullptr;
+ this->m_layers[i].imageInput = nullptr;
}
/* ready to close the file */
@@ -300,7 +300,7 @@ void *OutputStereoOperation::get_handle(const char *filename)
return exrhandle;
}
- return NULL;
+ return nullptr;
}
void OutputStereoOperation::deinitExecution()
@@ -316,7 +316,7 @@ void OutputStereoOperation::deinitExecution()
/* populate single EXR channel with view data */
IMB_exr_add_channel(exrhandle,
- NULL,
+ nullptr,
this->m_name,
this->m_viewName,
1,
@@ -324,19 +324,19 @@ void OutputStereoOperation::deinitExecution()
buf,
this->m_format->depth == R_IMF_CHAN_DEPTH_16);
- this->m_imageInput = NULL;
- this->m_outputBuffer = NULL;
+ this->m_imageInput = nullptr;
+ this->m_outputBuffer = nullptr;
/* create stereo ibuf */
if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
- ImBuf *ibuf[3] = {NULL};
+ ImBuf *ibuf[3] = {nullptr};
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
char filename[FILE_MAX];
int i;
/* get rectf from EXR */
for (i = 0; i < 2; i++) {
- float *rectf = IMB_exr_channel_rect(exrhandle, NULL, this->m_name, names[i]);
+ float *rectf = IMB_exr_channel_rect(exrhandle, nullptr, this->m_name, names[i]);
ibuf[i] = IMB_allocImBuf(width, height, this->m_format->planes, 0);
ibuf[i]->channels = this->m_channels;
@@ -360,7 +360,7 @@ void OutputStereoOperation::deinitExecution()
this->m_format,
(this->m_rd->scemode & R_EXTENSION) != 0,
true,
- NULL);
+ nullptr);
BKE_imbuf_write(ibuf[2], filename, this->m_format);
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index 374189a5c50..c5623fdbd37 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -48,25 +48,55 @@ void add_exr_channels(void *exrhandle,
switch (datatype) {
case COM_DT_VALUE:
IMB_exr_add_channel(
- exrhandle, layerName, "V", viewName, 1, width, buf ? buf : NULL, use_half_float);
+ exrhandle, layerName, "V", viewName, 1, width, buf ? buf : nullptr, use_half_float);
break;
case COM_DT_VECTOR:
IMB_exr_add_channel(
- exrhandle, layerName, "X", viewName, 3, 3 * width, buf ? buf : NULL, use_half_float);
- IMB_exr_add_channel(
- exrhandle, layerName, "Y", viewName, 3, 3 * width, buf ? buf + 1 : NULL, use_half_float);
- IMB_exr_add_channel(
- exrhandle, layerName, "Z", viewName, 3, 3 * width, buf ? buf + 2 : NULL, use_half_float);
+ exrhandle, layerName, "X", viewName, 3, 3 * width, buf ? buf : nullptr, use_half_float);
+ IMB_exr_add_channel(exrhandle,
+ layerName,
+ "Y",
+ viewName,
+ 3,
+ 3 * width,
+ buf ? buf + 1 : nullptr,
+ use_half_float);
+ IMB_exr_add_channel(exrhandle,
+ layerName,
+ "Z",
+ viewName,
+ 3,
+ 3 * width,
+ buf ? buf + 2 : nullptr,
+ use_half_float);
break;
case COM_DT_COLOR:
IMB_exr_add_channel(
- exrhandle, layerName, "R", viewName, 4, 4 * width, buf ? buf : NULL, use_half_float);
- IMB_exr_add_channel(
- exrhandle, layerName, "G", viewName, 4, 4 * width, buf ? buf + 1 : NULL, use_half_float);
- IMB_exr_add_channel(
- exrhandle, layerName, "B", viewName, 4, 4 * width, buf ? buf + 2 : NULL, use_half_float);
- IMB_exr_add_channel(
- exrhandle, layerName, "A", viewName, 4, 4 * width, buf ? buf + 3 : NULL, use_half_float);
+ exrhandle, layerName, "R", viewName, 4, 4 * width, buf ? buf : nullptr, use_half_float);
+ IMB_exr_add_channel(exrhandle,
+ layerName,
+ "G",
+ viewName,
+ 4,
+ 4 * width,
+ buf ? buf + 1 : nullptr,
+ use_half_float);
+ IMB_exr_add_channel(exrhandle,
+ layerName,
+ "B",
+ viewName,
+ 4,
+ 4 * width,
+ buf ? buf + 2 : nullptr,
+ use_half_float);
+ IMB_exr_add_channel(exrhandle,
+ layerName,
+ "A",
+ viewName,
+ 4,
+ 4 * width,
+ buf ? buf + 3 : nullptr,
+ use_half_float);
break;
default:
break;
@@ -82,7 +112,7 @@ void free_exr_channels(void *exrhandle,
/* check renderdata for amount of views */
for (srv = (SceneRenderView *)rd->views.first; srv; srv = srv->next) {
- float *rect = NULL;
+ float *rect = nullptr;
if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {
continue;
@@ -130,7 +160,7 @@ static float *init_buffer(unsigned int width, unsigned int height, DataType data
return (float *)MEM_callocN(width * height * size * sizeof(float), "OutputFile buffer");
}
- return NULL;
+ return nullptr;
}
static void write_buffer_rect(rcti *rect,
@@ -187,9 +217,9 @@ OutputSingleLayerOperation::OutputSingleLayerOperation(
this->addInputSocket(datatype);
- this->m_outputBuffer = NULL;
+ this->m_outputBuffer = nullptr;
this->m_datatype = datatype;
- this->m_imageInput = NULL;
+ this->m_imageInput = nullptr;
this->m_format = format;
BLI_strncpy(this->m_path, path, sizeof(this->m_path));
@@ -252,8 +282,8 @@ void OutputSingleLayerOperation::deinitExecution()
IMB_freeImBuf(ibuf);
}
- this->m_outputBuffer = NULL;
- this->m_imageInput = NULL;
+ this->m_outputBuffer = nullptr;
+ this->m_imageInput = nullptr;
}
/******************************* MultiLayer *******************************/
@@ -265,8 +295,8 @@ OutputOpenExrLayer::OutputOpenExrLayer(const char *name_, DataType datatype_, bo
this->use_layer = use_layer_;
/* these are created in initExecution */
- this->outputBuffer = 0;
- this->imageInput = 0;
+ this->outputBuffer = nullptr;
+ this->imageInput = nullptr;
}
OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(const RenderData *rd,
@@ -356,7 +386,7 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
}
/* when the filename has no permissions, this can fail */
- if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, NULL)) {
+ if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, nullptr)) {
IMB_exr_write_channels(exrhandle);
}
else {
@@ -369,10 +399,10 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
for (unsigned int i = 0; i < this->m_layers.size(); i++) {
if (this->m_layers[i].outputBuffer) {
MEM_freeN(this->m_layers[i].outputBuffer);
- this->m_layers[i].outputBuffer = NULL;
+ this->m_layers[i].outputBuffer = nullptr;
}
- this->m_layers[i].imageInput = NULL;
+ this->m_layers[i].imageInput = nullptr;
}
}
}
diff --git a/source/blender/compositor/operations/COM_PixelateOperation.cpp b/source/blender/compositor/operations/COM_PixelateOperation.cpp
index 18e691d3c34..0d810c80ab4 100644
--- a/source/blender/compositor/operations/COM_PixelateOperation.cpp
+++ b/source/blender/compositor/operations/COM_PixelateOperation.cpp
@@ -18,12 +18,12 @@
#include "COM_PixelateOperation.h"
-PixelateOperation::PixelateOperation(DataType datatype) : NodeOperation()
+PixelateOperation::PixelateOperation(DataType datatype)
{
this->addInputSocket(datatype);
this->addOutputSocket(datatype);
this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
void PixelateOperation::initExecution()
@@ -33,7 +33,7 @@ void PixelateOperation::initExecution()
void PixelateOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
void PixelateOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
index eae576ceb56..d4f2ca7bbe8 100644
--- a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
@@ -87,8 +87,7 @@ static void readCornersFromSockets(rcti *rect, SocketReader *readers[4], float c
/* ******** PlaneCornerPinMaskOperation ******** */
-PlaneCornerPinMaskOperation::PlaneCornerPinMaskOperation()
- : PlaneDistortMaskOperation(), m_corners_ready(false)
+PlaneCornerPinMaskOperation::PlaneCornerPinMaskOperation() : m_corners_ready(false)
{
addInputSocket(COM_DT_VECTOR);
addInputSocket(COM_DT_VECTOR);
@@ -152,8 +151,7 @@ void PlaneCornerPinMaskOperation::determineResolution(unsigned int resolution[2]
/* ******** PlaneCornerPinWarpImageOperation ******** */
-PlaneCornerPinWarpImageOperation::PlaneCornerPinWarpImageOperation()
- : PlaneDistortWarpImageOperation(), m_corners_ready(false)
+PlaneCornerPinWarpImageOperation::PlaneCornerPinWarpImageOperation() : m_corners_ready(false)
{
addInputSocket(COM_DT_VECTOR);
addInputSocket(COM_DT_VECTOR);
diff --git a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp
index e7574e80c2f..c395f795a22 100644
--- a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp
@@ -44,11 +44,11 @@ BLI_INLINE void warpCoord(float x, float y, float matrix[3][3], float uv[2], flo
deriv[1][1] = (matrix[1][1] - matrix[1][2] * uv[1]) / vec[2];
}
-PlaneDistortWarpImageOperation::PlaneDistortWarpImageOperation() : NodeOperation()
+PlaneDistortWarpImageOperation::PlaneDistortWarpImageOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(COM_DT_COLOR);
- this->m_pixelReader = NULL;
+ this->m_pixelReader = nullptr;
this->m_motion_blur_samples = 1;
this->m_motion_blur_shutter = 0.5f;
this->setComplex(true);
@@ -87,7 +87,7 @@ void PlaneDistortWarpImageOperation::initExecution()
void PlaneDistortWarpImageOperation::deinitExecution()
{
- this->m_pixelReader = NULL;
+ this->m_pixelReader = nullptr;
}
void PlaneDistortWarpImageOperation::executePixelSampled(float output[4],
@@ -145,7 +145,7 @@ bool PlaneDistortWarpImageOperation::determineDependingAreaOfInterest(
/* ******** PlaneDistort Mask ******** */
-PlaneDistortMaskOperation::PlaneDistortMaskOperation() : NodeOperation()
+PlaneDistortMaskOperation::PlaneDistortMaskOperation()
{
addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp b/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp
index ed9a776d0a3..81a598e937b 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp
@@ -33,7 +33,7 @@
PlaneTrackCommon::PlaneTrackCommon()
{
- this->m_movieClip = NULL;
+ this->m_movieClip = nullptr;
this->m_framenumber = 0;
this->m_trackingObjectName[0] = '\0';
this->m_planeTrackName[0] = '\0';
diff --git a/source/blender/compositor/operations/COM_PlaneTrackOperation.h b/source/blender/compositor/operations/COM_PlaneTrackOperation.h
index fc0a0873d5f..fc325c7db7d 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneTrackOperation.h
@@ -64,7 +64,7 @@ class PlaneTrackCommon {
class PlaneTrackMaskOperation : public PlaneDistortMaskOperation, public PlaneTrackCommon {
public:
- PlaneTrackMaskOperation() : PlaneDistortMaskOperation(), PlaneTrackCommon()
+ PlaneTrackMaskOperation()
{
}
@@ -82,7 +82,7 @@ class PlaneTrackMaskOperation : public PlaneDistortMaskOperation, public PlaneTr
class PlaneTrackWarpImageOperation : public PlaneDistortWarpImageOperation,
public PlaneTrackCommon {
public:
- PlaneTrackWarpImageOperation() : PlaneDistortWarpImageOperation(), PlaneTrackCommon()
+ PlaneTrackWarpImageOperation() : PlaneTrackCommon()
{
}
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp
index 43d20271141..063421f6525 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cpp
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -35,12 +35,12 @@
PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings,
const ColorManagedDisplaySettings *displaySettings)
- : NodeOperation()
+
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
- this->m_preview = NULL;
- this->m_outputBuffer = NULL;
- this->m_input = NULL;
+ this->m_preview = nullptr;
+ this->m_outputBuffer = nullptr;
+ this->m_input = nullptr;
this->m_divider = 1.0f;
this->m_viewSettings = viewSettings;
this->m_displaySettings = displaySettings;
@@ -63,7 +63,7 @@ void PreviewOperation::initExecution()
this->m_outputBuffer = this->m_preview->rect;
}
- if (this->m_outputBuffer == NULL) {
+ if (this->m_outputBuffer == nullptr) {
this->m_outputBuffer = (unsigned char *)MEM_callocN(
sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation");
if (this->m_preview->rect) {
@@ -77,8 +77,8 @@ void PreviewOperation::initExecution()
void PreviewOperation::deinitExecution()
{
- this->m_outputBuffer = NULL;
- this->m_input = NULL;
+ this->m_outputBuffer = nullptr;
+ this->m_input = nullptr;
}
void PreviewOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
index 32933f1b966..7d459b76cb9 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
@@ -20,13 +20,13 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOperation()
+ProjectorLensDistortionOperation::ProjectorLensDistortionOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
this->m_dispersionAvailable = false;
this->m_dispersion = 0.0f;
}
@@ -39,7 +39,7 @@ void ProjectorLensDistortionOperation::initExecution()
void *ProjectorLensDistortionOperation::initializeTileData(rcti * /*rect*/)
{
updateDispersion();
- void *buffer = this->m_inputProgram->initializeTileData(NULL);
+ void *buffer = this->m_inputProgram->initializeTileData(nullptr);
return buffer;
}
@@ -63,7 +63,7 @@ void ProjectorLensDistortionOperation::executePixel(float output[4], int x, int
void ProjectorLensDistortionOperation::deinitExecution()
{
this->deinitMutex();
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
index 99cc9f5dd01..2977e6685d2 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
@@ -20,12 +20,12 @@
#include "COM_WriteBufferOperation.h"
#include "COM_defines.h"
-ReadBufferOperation::ReadBufferOperation(DataType datatype) : NodeOperation()
+ReadBufferOperation::ReadBufferOperation(DataType datatype)
{
this->addOutputSocket(datatype);
this->m_single_value = false;
this->m_offset = 0;
- this->m_buffer = NULL;
+ this->m_buffer = nullptr;
}
void *ReadBufferOperation::initializeTileData(rcti * /*rect*/)
@@ -36,7 +36,7 @@ void *ReadBufferOperation::initializeTileData(rcti * /*rect*/)
void ReadBufferOperation::determineResolution(unsigned int resolution[2],
unsigned int preferredResolution[2])
{
- if (this->m_memoryProxy != NULL) {
+ if (this->m_memoryProxy != nullptr) {
WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation();
operation->determineResolution(resolution, preferredResolution);
operation->setResolution(resolution);
@@ -120,7 +120,7 @@ bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input,
void ReadBufferOperation::readResolutionFromWriteBuffer()
{
- if (this->m_memoryProxy != NULL) {
+ if (this->m_memoryProxy != nullptr) {
WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation();
this->setWidth(operation->getWidth());
this->setHeight(operation->getHeight());
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
index c8a68c70c4d..11f64aa4d6a 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@ -23,18 +23,17 @@
#include "DNA_scene_types.h"
#include "RE_pipeline.h"
-#include "RE_render_ext.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
/* ******** Render Layers Base Prog ******** */
RenderLayersProg::RenderLayersProg(const char *passName, DataType type, int elementsize)
- : NodeOperation(), m_passName(passName)
+ : m_passName(passName)
{
- this->setScene(NULL);
- this->m_inputBuffer = NULL;
+ this->setScene(nullptr);
+ this->m_inputBuffer = nullptr;
this->m_elementsize = elementsize;
- this->m_rd = NULL;
+ this->m_rd = nullptr;
this->addOutputSocket(type);
}
@@ -42,8 +41,8 @@ RenderLayersProg::RenderLayersProg(const char *passName, DataType type, int elem
void RenderLayersProg::initExecution()
{
Scene *scene = this->getScene();
- Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
- RenderResult *rr = NULL;
+ Render *re = (scene) ? RE_GetSceneRender(scene) : nullptr;
+ RenderResult *rr = nullptr;
if (re) {
rr = RE_AcquireResultRead(re);
@@ -62,7 +61,7 @@ void RenderLayersProg::initExecution()
}
if (re) {
RE_ReleaseResult(re);
- re = NULL;
+ re = nullptr;
}
}
@@ -157,7 +156,7 @@ void RenderLayersProg::executePixelSampled(float output[4], float x, float y, Pi
}
#endif
- if (this->m_inputBuffer == NULL) {
+ if (this->m_inputBuffer == nullptr) {
int elemsize = this->m_elementsize;
if (elemsize == 1) {
output[0] = 0.0f;
@@ -177,15 +176,15 @@ void RenderLayersProg::executePixelSampled(float output[4], float x, float y, Pi
void RenderLayersProg::deinitExecution()
{
- this->m_inputBuffer = NULL;
+ this->m_inputBuffer = nullptr;
}
void RenderLayersProg::determineResolution(unsigned int resolution[2],
unsigned int /*preferredResolution*/[2])
{
Scene *sce = this->getScene();
- Render *re = (sce) ? RE_GetSceneRender(sce) : NULL;
- RenderResult *rr = NULL;
+ Render *re = (sce) ? RE_GetSceneRender(sce) : nullptr;
+ RenderResult *rr = nullptr;
resolution[0] = 0;
resolution[1] = 0;
@@ -217,7 +216,7 @@ void RenderLayersAOOperation::executePixelSampled(float output[4],
PixelSampler sampler)
{
float *inputBuffer = this->getInputBuffer();
- if (inputBuffer == NULL) {
+ if (inputBuffer == nullptr) {
zero_v3(output);
}
else {
@@ -234,7 +233,7 @@ void RenderLayersAlphaProg::executePixelSampled(float output[4],
{
float *inputBuffer = this->getInputBuffer();
- if (inputBuffer == NULL) {
+ if (inputBuffer == nullptr) {
output[0] = 0.0f;
}
else {
@@ -254,7 +253,7 @@ void RenderLayersDepthProg::executePixelSampled(float output[4],
int iy = y;
float *inputBuffer = this->getInputBuffer();
- if (inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() ||
+ if (inputBuffer == nullptr || ix < 0 || iy < 0 || ix >= (int)this->getWidth() ||
iy >= (int)this->getHeight()) {
output[0] = 10e10f;
}
diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp
index 3ccf36cec2c..7a21e960c13 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.cpp
+++ b/source/blender/compositor/operations/COM_RotateOperation.cpp
@@ -19,14 +19,14 @@
#include "COM_RotateOperation.h"
#include "BLI_math.h"
-RotateOperation::RotateOperation() : NodeOperation()
+RotateOperation::RotateOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
- this->m_imageSocket = NULL;
- this->m_degreeSocket = NULL;
+ this->m_imageSocket = nullptr;
+ this->m_degreeSocket = nullptr;
this->m_doDegree2RadConversion = false;
this->m_isDegreeSet = false;
}
@@ -40,8 +40,8 @@ void RotateOperation::initExecution()
void RotateOperation::deinitExecution()
{
- this->m_imageSocket = NULL;
- this->m_degreeSocket = NULL;
+ this->m_imageSocket = nullptr;
+ this->m_degreeSocket = nullptr;
}
inline void RotateOperation::ensureDegree()
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp
index 37ce832209c..9ec4e474ccd 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp
@@ -42,9 +42,9 @@ ScaleOperation::ScaleOperation() : BaseScaleOperation()
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_inputXOperation = nullptr;
+ this->m_inputYOperation = nullptr;
}
void ScaleOperation::initExecution()
{
@@ -57,9 +57,9 @@ void ScaleOperation::initExecution()
void ScaleOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_inputXOperation = nullptr;
+ this->m_inputYOperation = nullptr;
}
void ScaleOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
@@ -117,9 +117,9 @@ ScaleAbsoluteOperation::ScaleAbsoluteOperation() : BaseScaleOperation()
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_inputXOperation = nullptr;
+ this->m_inputYOperation = nullptr;
}
void ScaleAbsoluteOperation::initExecution()
{
@@ -132,9 +132,9 @@ void ScaleAbsoluteOperation::initExecution()
void ScaleAbsoluteOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_inputXOperation = nullptr;
+ this->m_inputYOperation = nullptr;
}
void ScaleAbsoluteOperation::executePixelSampled(float output[4],
@@ -206,7 +206,7 @@ ScaleFixedSizeOperation::ScaleFixedSizeOperation() : BaseScaleOperation()
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
this->m_is_offset = false;
}
void ScaleFixedSizeOperation::initExecution()
@@ -263,7 +263,7 @@ void ScaleFixedSizeOperation::initExecution()
void ScaleFixedSizeOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = nullptr;
}
void ScaleFixedSizeOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
index b7731a34c91..158ffd4a8c0 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -24,14 +24,14 @@
#include "PIL_time.h"
-ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation()
+ScreenLensDistortionOperation::ScreenLensDistortionOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
this->m_distortion = 0.0f;
this->m_dispersion = 0.0f;
this->m_distortion_const = false;
@@ -72,7 +72,7 @@ void ScreenLensDistortionOperation::initExecution()
void *ScreenLensDistortionOperation::initializeTileData(rcti * /*rect*/)
{
- void *buffer = this->m_inputProgram->initializeTileData(NULL);
+ void *buffer = this->m_inputProgram->initializeTileData(nullptr);
/* get distortion/dispersion values once, by reading inputs at (0,0)
* XXX this assumes invariable values (no image inputs),
@@ -202,7 +202,7 @@ void ScreenLensDistortionOperation::executePixel(float output[4], int x, int y,
void ScreenLensDistortionOperation::deinitExecution()
{
this->deinitMutex();
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
BLI_rng_free(this->m_rng);
}
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
index 68c165411b2..bf8fbacbfe1 100644
--- a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
@@ -18,14 +18,14 @@
#include "COM_SetAlphaOperation.h"
-SetAlphaOperation::SetAlphaOperation() : NodeOperation()
+SetAlphaOperation::SetAlphaOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
- this->m_inputColor = NULL;
- this->m_inputAlpha = NULL;
+ this->m_inputColor = nullptr;
+ this->m_inputAlpha = nullptr;
}
void SetAlphaOperation::initExecution()
@@ -49,6 +49,6 @@ void SetAlphaOperation::executePixelSampled(float output[4],
void SetAlphaOperation::deinitExecution()
{
- this->m_inputColor = NULL;
- this->m_inputAlpha = NULL;
+ this->m_inputColor = nullptr;
+ this->m_inputAlpha = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.cpp b/source/blender/compositor/operations/COM_SetColorOperation.cpp
index 58bfcb44afd..ffbc20fde9c 100644
--- a/source/blender/compositor/operations/COM_SetColorOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetColorOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_SetColorOperation.h"
-SetColorOperation::SetColorOperation() : NodeOperation()
+SetColorOperation::SetColorOperation()
{
this->addOutputSocket(COM_DT_COLOR);
}
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
index f3b3ed217f9..942d717d19c 100644
--- a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_SetSamplerOperation.h"
-SetSamplerOperation::SetSamplerOperation() : NodeOperation()
+SetSamplerOperation::SetSamplerOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -30,7 +30,7 @@ void SetSamplerOperation::initExecution()
}
void SetSamplerOperation::deinitExecution()
{
- this->m_reader = NULL;
+ this->m_reader = nullptr;
}
void SetSamplerOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.cpp b/source/blender/compositor/operations/COM_SetValueOperation.cpp
index e49b6941f49..d72a2dfe23d 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetValueOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_SetValueOperation.h"
-SetValueOperation::SetValueOperation() : NodeOperation()
+SetValueOperation::SetValueOperation()
{
this->addOutputSocket(COM_DT_VALUE);
}
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cpp b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
index d3a0329c9b9..a0341dbc4df 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_SetVectorOperation.h"
#include "COM_defines.h"
-SetVectorOperation::SetVectorOperation() : NodeOperation()
+SetVectorOperation::SetVectorOperation()
{
this->addOutputSocket(COM_DT_VECTOR);
}
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
index 2d54d6ae45d..baeb2f44303 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_SocketProxyOperation.h"
SocketProxyOperation::SocketProxyOperation(DataType type, bool use_conversion)
- : NodeOperation(), m_use_conversion(use_conversion)
+ : m_use_conversion(use_conversion)
{
this->addInputSocket(type);
this->addOutputSocket(type);
diff --git a/source/blender/compositor/operations/COM_SplitOperation.cpp b/source/blender/compositor/operations/COM_SplitOperation.cpp
index 3eddf033cf4..fb6214c7522 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.cpp
+++ b/source/blender/compositor/operations/COM_SplitOperation.cpp
@@ -27,13 +27,13 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-SplitOperation::SplitOperation() : NodeOperation()
+SplitOperation::SplitOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_image1Input = NULL;
- this->m_image2Input = NULL;
+ this->m_image1Input = nullptr;
+ this->m_image2Input = nullptr;
}
void SplitOperation::initExecution()
@@ -45,8 +45,8 @@ void SplitOperation::initExecution()
void SplitOperation::deinitExecution()
{
- this->m_image1Input = NULL;
- this->m_image2Input = NULL;
+ this->m_image1Input = nullptr;
+ this->m_image2Input = nullptr;
}
void SplitOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
index 4a7139537c1..7cfa4de7a61 100644
--- a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
+++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_SunBeamsOperation.h"
-SunBeamsOperation::SunBeamsOperation() : NodeOperation()
+SunBeamsOperation::SunBeamsOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -310,7 +310,7 @@ static void accumulate_line(MemoryBuffer *input,
void *SunBeamsOperation::initializeTileData(rcti * /*rect*/)
{
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ void *buffer = getInputOperation(0)->initializeTileData(nullptr);
return buffer;
}
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index 07316280bbc..e66cd57cb3f 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -25,15 +25,15 @@
#include "BLI_listbase.h"
#include "BLI_threads.h"
-TextureBaseOperation::TextureBaseOperation() : NodeOperation()
+TextureBaseOperation::TextureBaseOperation()
{
this->addInputSocket(COM_DT_VECTOR); // offset
this->addInputSocket(COM_DT_VECTOR); // size
- this->m_texture = NULL;
- this->m_inputSize = NULL;
- this->m_inputOffset = NULL;
- this->m_rd = NULL;
- this->m_pool = NULL;
+ this->m_texture = nullptr;
+ this->m_inputSize = nullptr;
+ this->m_inputOffset = nullptr;
+ this->m_rd = nullptr;
+ this->m_pool = nullptr;
this->m_sceneColorManage = false;
setComplex(true);
}
@@ -51,19 +51,20 @@ void TextureBaseOperation::initExecution()
this->m_inputOffset = getInputSocketReader(0);
this->m_inputSize = getInputSocketReader(1);
this->m_pool = BKE_image_pool_new();
- if (this->m_texture != NULL && this->m_texture->nodetree != NULL && this->m_texture->use_nodes) {
+ if (this->m_texture != nullptr && this->m_texture->nodetree != nullptr &&
+ this->m_texture->use_nodes) {
ntreeTexBeginExecTree(this->m_texture->nodetree);
}
NodeOperation::initExecution();
}
void TextureBaseOperation::deinitExecution()
{
- this->m_inputSize = NULL;
- this->m_inputOffset = NULL;
+ this->m_inputSize = nullptr;
+ this->m_inputOffset = nullptr;
BKE_image_pool_free(this->m_pool);
- this->m_pool = NULL;
- if (this->m_texture != NULL && this->m_texture->use_nodes && this->m_texture->nodetree != NULL &&
- this->m_texture->nodetree->execdata != NULL) {
+ this->m_pool = nullptr;
+ if (this->m_texture != nullptr && this->m_texture->use_nodes &&
+ this->m_texture->nodetree != nullptr && this->m_texture->nodetree->execdata != nullptr) {
ntreeTexEndExecTree(this->m_texture->nodetree->execdata);
}
NodeOperation::deinitExecution();
@@ -99,7 +100,7 @@ void TextureBaseOperation::executePixelSampled(float output[4],
float y,
PixelSampler sampler)
{
- TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
+ TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, nullptr};
float textureSize[4];
float textureOffset[4];
float vec[3];
@@ -114,7 +115,7 @@ void TextureBaseOperation::executePixelSampled(float output[4],
* interpolation and (b) in such configuration multitex() simply floor's the value
* which often produces artifacts.
*/
- if (m_texture != NULL && (m_texture->imaflag & TEX_INTERPOL) == 0) {
+ if (m_texture != nullptr && (m_texture->imaflag & TEX_INTERPOL) == 0) {
u += 0.5f / cx;
v += 0.5f / cy;
}
@@ -127,8 +128,16 @@ void TextureBaseOperation::executePixelSampled(float output[4],
vec[2] = textureSize[2] * textureOffset[2];
const int thread_id = WorkScheduler::current_thread_id();
- retval = multitex_ext(
- this->m_texture, vec, NULL, NULL, 0, &texres, thread_id, m_pool, m_sceneColorManage, false);
+ retval = multitex_ext(this->m_texture,
+ vec,
+ nullptr,
+ nullptr,
+ 0,
+ &texres,
+ thread_id,
+ m_pool,
+ m_sceneColorManage,
+ false);
if (texres.talpha) {
output[3] = texres.ta;
diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h
index 7fa85922b0b..a40dafd14cf 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.h
+++ b/source/blender/compositor/operations/COM_TextureOperation.h
@@ -24,8 +24,7 @@
#include "MEM_guardedalloc.h"
#include "RE_pipeline.h"
-#include "RE_render_ext.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
/**
* Base class for all renderlayeroperations
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp
index 59354ff7581..cb0fc747dcb 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.cpp
+++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp
@@ -22,13 +22,13 @@
#include "IMB_colormanagement.h"
-TonemapOperation::TonemapOperation() : NodeOperation()
+TonemapOperation::TonemapOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(COM_DT_COLOR);
- this->m_imageReader = NULL;
- this->m_data = NULL;
- this->m_cachedInstance = NULL;
+ this->m_imageReader = nullptr;
+ this->m_data = nullptr;
+ this->m_cachedInstance = nullptr;
this->setComplex(true);
}
void TonemapOperation::initExecution()
@@ -41,7 +41,7 @@ void TonemapOperation::executePixel(float output[4], int x, int y, void *data)
{
AvgLogLum *avg = (AvgLogLum *)data;
- this->m_imageReader->read(output, x, y, NULL);
+ this->m_imageReader->read(output, x, y, nullptr);
mul_v3_fl(output, avg->al);
float dr = output[0] + this->m_data->offset;
float dg = output[1] + this->m_data->offset;
@@ -65,7 +65,7 @@ void PhotoreceptorTonemapOperation::executePixel(float output[4], int x, int y,
const float m = (ntm->m > 0.0f) ? ntm->m : (0.3f + 0.7f * powf(avg->auto_key, 1.4f));
const float ic = 1.0f - ntm->c, ia = 1.0f - ntm->a;
- this->m_imageReader->read(output, x, y, NULL);
+ this->m_imageReader->read(output, x, y, nullptr);
const float L = IMB_colormanagement_get_luminance(output);
float I_l = output[0] + ic * (L - output[0]);
@@ -84,7 +84,7 @@ void PhotoreceptorTonemapOperation::executePixel(float output[4], int x, int y,
void TonemapOperation::deinitExecution()
{
- this->m_imageReader = NULL;
+ this->m_imageReader = nullptr;
delete this->m_cachedInstance;
NodeOperation::deinitMutex();
}
@@ -109,7 +109,7 @@ bool TonemapOperation::determineDependingAreaOfInterest(rcti * /*input*/,
void *TonemapOperation::initializeTileData(rcti *rect)
{
lockMutex();
- if (this->m_cachedInstance == NULL) {
+ if (this->m_cachedInstance == nullptr) {
MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
AvgLogLum *data = new AvgLogLum();
diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
index 5c4f3b99f58..ddabfb7cf6c 100644
--- a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
+++ b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
@@ -28,10 +28,10 @@
#include "BKE_node.h"
#include "BKE_tracking.h"
-TrackPositionOperation::TrackPositionOperation() : NodeOperation()
+TrackPositionOperation::TrackPositionOperation()
{
this->addOutputSocket(COM_DT_VALUE);
- this->m_movieClip = NULL;
+ this->m_movieClip = nullptr;
this->m_framenumber = 0;
this->m_trackingObjectName[0] = 0;
this->m_trackName[0] = 0;
@@ -43,7 +43,7 @@ TrackPositionOperation::TrackPositionOperation() : NodeOperation()
void TrackPositionOperation::initExecution()
{
- MovieTracking *tracking = NULL;
+ MovieTracking *tracking = nullptr;
MovieClipUser user = {0};
MovieTrackingObject *object;
@@ -79,7 +79,7 @@ void TrackPositionOperation::initExecution()
this->m_relativeFrame);
marker = BKE_tracking_marker_get_exact(track, relative_clip_framenr);
- if (marker != NULL && (marker->flag & MARKER_DISABLED) == 0) {
+ if (marker != nullptr && (marker->flag & MARKER_DISABLED) == 0) {
copy_v2_v2(this->m_relativePos, marker->pos);
}
else {
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp
index b45e6a2b6a1..286004cd49b 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.cpp
+++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp
@@ -18,16 +18,16 @@
#include "COM_TranslateOperation.h"
-TranslateOperation::TranslateOperation() : NodeOperation()
+TranslateOperation::TranslateOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_inputXOperation = nullptr;
+ this->m_inputYOperation = nullptr;
this->m_isDeltaSet = false;
this->m_factorX = 1.0f;
this->m_factorY = 1.0f;
@@ -41,9 +41,9 @@ void TranslateOperation::initExecution()
void TranslateOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
+ this->m_inputOperation = nullptr;
+ this->m_inputXOperation = nullptr;
+ this->m_inputYOperation = nullptr;
}
void TranslateOperation::executePixelSampled(float output[4],
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 057dc553f7f..414b5bd980a 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -22,7 +22,7 @@
#include "RE_pipeline.h"
-VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation()
+VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image.
@@ -35,9 +35,9 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation
this->setComplex(true);
this->setOpenCL(true);
- this->m_inputProgram = NULL;
- this->m_inputBokehProgram = NULL;
- this->m_inputSizeProgram = NULL;
+ this->m_inputProgram = nullptr;
+ this->m_inputBokehProgram = nullptr;
+ this->m_inputSizeProgram = nullptr;
this->m_maxBlur = 32.0f;
this->m_threshold = 1.0f;
this->m_do_size_scale = false;
@@ -188,7 +188,7 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice *device,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel defocusKernel = device->COM_clCreateKernel("defocusKernel", NULL);
+ cl_kernel defocusKernel = device->COM_clCreateKernel("defocusKernel", nullptr);
cl_int step = this->getStep();
cl_int maxBlur;
@@ -221,9 +221,9 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice *device,
void VariableSizeBokehBlurOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
- this->m_inputBokehProgram = NULL;
- this->m_inputSizeProgram = NULL;
+ this->m_inputProgram = nullptr;
+ this->m_inputBokehProgram = nullptr;
+ this->m_inputSizeProgram = nullptr;
#ifdef COM_DEFOCUS_SEARCH
this->m_inputSearchProgram = NULL;
#endif
@@ -276,7 +276,7 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(
#ifdef COM_DEFOCUS_SEARCH
// InverseSearchRadiusOperation
-InverseSearchRadiusOperation::InverseSearchRadiusOperation() : NodeOperation()
+InverseSearchRadiusOperation::InverseSearchRadiusOperation()
{
this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // radius
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
index 1e392b1f991..0776c97563e 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -43,17 +43,17 @@ void zbuf_free_span(ZSpan *zspan);
void antialias_tagbuf(int xsize, int ysize, char *rectmove);
/* VectorBlurOperation */
-VectorBlurOperation::VectorBlurOperation() : NodeOperation()
+VectorBlurOperation::VectorBlurOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE); // ZBUF
this->addInputSocket(COM_DT_COLOR); // SPEED
this->addOutputSocket(COM_DT_COLOR);
- this->m_settings = NULL;
- this->m_cachedInstance = NULL;
- this->m_inputImageProgram = NULL;
- this->m_inputSpeedProgram = NULL;
- this->m_inputZProgram = NULL;
+ this->m_settings = nullptr;
+ this->m_cachedInstance = nullptr;
+ this->m_inputImageProgram = nullptr;
+ this->m_inputSpeedProgram = nullptr;
+ this->m_inputZProgram = nullptr;
setComplex(true);
}
void VectorBlurOperation::initExecution()
@@ -62,7 +62,7 @@ void VectorBlurOperation::initExecution()
this->m_inputImageProgram = getInputSocketReader(0);
this->m_inputZProgram = getInputSocketReader(1);
this->m_inputSpeedProgram = getInputSocketReader(2);
- this->m_cachedInstance = NULL;
+ this->m_cachedInstance = nullptr;
QualityStepHelper::initExecution(COM_QH_INCREASE);
}
@@ -76,12 +76,12 @@ void VectorBlurOperation::executePixel(float output[4], int x, int y, void *data
void VectorBlurOperation::deinitExecution()
{
deinitMutex();
- this->m_inputImageProgram = NULL;
- this->m_inputSpeedProgram = NULL;
- this->m_inputZProgram = NULL;
+ this->m_inputImageProgram = nullptr;
+ this->m_inputSpeedProgram = nullptr;
+ this->m_inputZProgram = nullptr;
if (this->m_cachedInstance) {
MEM_freeN(this->m_cachedInstance);
- this->m_cachedInstance = NULL;
+ this->m_cachedInstance = nullptr;
}
}
void *VectorBlurOperation::initializeTileData(rcti *rect)
@@ -91,7 +91,7 @@ void *VectorBlurOperation::initializeTileData(rcti *rect)
}
lockMutex();
- if (this->m_cachedInstance == NULL) {
+ if (this->m_cachedInstance == nullptr) {
MemoryBuffer *tile = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect);
MemoryBuffer *speed = (MemoryBuffer *)this->m_inputSpeedProgram->initializeTileData(rect);
MemoryBuffer *z = (MemoryBuffer *)this->m_inputZProgram->initializeTileData(rect);
@@ -107,7 +107,7 @@ bool VectorBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/,
ReadBufferOperation *readOperation,
rcti *output)
{
- if (this->m_cachedInstance == NULL) {
+ if (this->m_cachedInstance == nullptr) {
rcti newInput;
newInput.xmax = this->getWidth();
newInput.xmin = 0;
@@ -183,7 +183,7 @@ void zbuf_free_span(ZSpan *zspan)
if (zspan->span2) {
MEM_freeN(zspan->span2);
}
- zspan->span1 = zspan->span2 = NULL;
+ zspan->span1 = zspan->span2 = nullptr;
}
}
@@ -192,7 +192,7 @@ static void zbuf_init_span(ZSpan *zspan)
{
zspan->miny1 = zspan->miny2 = zspan->recty + 1;
zspan->maxy1 = zspan->maxy2 = -1;
- zspan->minp1 = zspan->maxp1 = zspan->minp2 = zspan->maxp2 = NULL;
+ zspan->minp1 = zspan->maxp1 = zspan->minp2 = zspan->maxp2 = nullptr;
}
static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
@@ -243,7 +243,7 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
}
/* empty span */
- if (zspan->maxp1 == NULL) {
+ if (zspan->maxp1 == nullptr) {
span = zspan->span1;
}
else { /* does it complete left span? */
@@ -257,10 +257,10 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
if (span == zspan->span1) {
// printf("left span my0 %d my2 %d\n", my0, my2);
- if (zspan->minp1 == NULL || zspan->minp1[1] > minv[1]) {
+ if (zspan->minp1 == nullptr || zspan->minp1[1] > minv[1]) {
zspan->minp1 = minv;
}
- if (zspan->maxp1 == NULL || zspan->maxp1[1] < maxv[1]) {
+ if (zspan->maxp1 == nullptr || zspan->maxp1[1] < maxv[1]) {
zspan->maxp1 = maxv;
}
if (my0 < zspan->miny1) {
@@ -272,10 +272,10 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
}
else {
// printf("right span my0 %d my2 %d\n", my0, my2);
- if (zspan->minp2 == NULL || zspan->minp2[1] > minv[1]) {
+ if (zspan->minp2 == nullptr || zspan->minp2[1] > minv[1]) {
zspan->minp2 = minv;
}
- if (zspan->maxp2 == NULL || zspan->maxp2[1] < maxv[1]) {
+ if (zspan->maxp2 == nullptr || zspan->maxp2[1] < maxv[1]) {
zspan->maxp2 = maxv;
}
if (my0 < zspan->miny2) {
@@ -321,7 +321,7 @@ static void zbuf_fill_in_rgba(
zbuf_add_to_span(zspan, v4, v1);
/* clipped */
- if (zspan->minp2 == NULL || zspan->maxp2 == NULL) {
+ if (zspan->minp2 == nullptr || zspan->maxp2 == nullptr) {
return;
}
@@ -554,7 +554,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
float v1[3], v2[3], v3[3], v4[3], fx, fy;
const float *dimg, *dz, *ro;
float *rectvz, *dvz, *dvec1, *dvec2, *dz1, *dz2, *rectz;
- float *minvecbufrect = NULL, *rectweight, *rw, *rectmax, *rm;
+ float *minvecbufrect = nullptr, *rectweight, *rw, *rectmax, *rm;
float maxspeedsq = (float)nbd->maxspeed * nbd->maxspeed;
int y, x, step, maxspeed = nbd->maxspeed, samples = nbd->samples;
int tsktsk = 0;
@@ -747,7 +747,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
float blendfac, ipodata[4];
/* clear zbuf, if we draw future we fill in not moving pixels */
- if (0) {
+ if (false) {
for (x = xsize * ysize - 1; x >= 0; x--) {
rectz[x] = 10e16;
}
@@ -765,7 +765,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
/* clear drawing buffer */
for (x = xsize * ysize - 1; x >= 0; x--) {
- rectdraw[x].colpoin = NULL;
+ rectdraw[x].colpoin = nullptr;
}
dimg = imgrect;
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
index 61312355a39..a883237f870 100644
--- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
@@ -20,12 +20,12 @@
#include "BKE_colortools.h"
-VectorCurveOperation::VectorCurveOperation() : CurveBaseOperation()
+VectorCurveOperation::VectorCurveOperation()
{
this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(COM_DT_VECTOR);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
void VectorCurveOperation::initExecution()
{
@@ -48,5 +48,5 @@ void VectorCurveOperation::executePixelSampled(float output[4],
void VectorCurveOperation::deinitExecution()
{
CurveBaseOperation::deinitExecution();
- this->m_inputProgram = NULL;
+ this->m_inputProgram = nullptr;
}
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index e1d891559a7..025dde8e866 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -32,27 +32,27 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-ViewerOperation::ViewerOperation() : NodeOperation()
+ViewerOperation::ViewerOperation()
{
- this->setImage(NULL);
- this->setImageUser(NULL);
- this->m_outputBuffer = NULL;
- this->m_depthBuffer = NULL;
+ this->setImage(nullptr);
+ this->setImageUser(nullptr);
+ this->m_outputBuffer = nullptr;
+ this->m_depthBuffer = nullptr;
this->m_active = false;
this->m_doDepthBuffer = false;
- this->m_viewSettings = NULL;
- this->m_displaySettings = NULL;
+ this->m_viewSettings = nullptr;
+ this->m_displaySettings = nullptr;
this->m_useAlphaInput = false;
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
- this->m_imageInput = NULL;
- this->m_alphaInput = NULL;
- this->m_depthInput = NULL;
- this->m_rd = NULL;
- this->m_viewName = NULL;
+ this->m_imageInput = nullptr;
+ this->m_alphaInput = nullptr;
+ this->m_depthInput = nullptr;
+ this->m_rd = nullptr;
+ this->m_viewName = nullptr;
}
void ViewerOperation::initExecution()
@@ -61,7 +61,7 @@ void ViewerOperation::initExecution()
this->m_imageInput = getInputSocketReader(0);
this->m_alphaInput = getInputSocketReader(1);
this->m_depthInput = getInputSocketReader(2);
- this->m_doDepthBuffer = (this->m_depthInput != NULL);
+ this->m_doDepthBuffer = (this->m_depthInput != nullptr);
if (isActiveViewerOutput()) {
initImage();
@@ -70,10 +70,10 @@ void ViewerOperation::initExecution()
void ViewerOperation::deinitExecution()
{
- this->m_imageInput = NULL;
- this->m_alphaInput = NULL;
- this->m_depthInput = NULL;
- this->m_outputBuffer = NULL;
+ this->m_imageInput = nullptr;
+ this->m_alphaInput = nullptr;
+ this->m_depthInput = nullptr;
+ this->m_outputBuffer = nullptr;
}
void ViewerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
@@ -180,7 +180,7 @@ void ViewerOperation::updateImage(rcti *rect)
{
IMB_partial_display_buffer_update(this->m_ibuf,
this->m_outputBuffer,
- NULL,
+ nullptr,
getWidth(),
0,
0,
diff --git a/source/blender/compositor/operations/COM_WrapOperation.cpp b/source/blender/compositor/operations/COM_WrapOperation.cpp
index 952f69c3787..7f7c1b7b639 100644
--- a/source/blender/compositor/operations/COM_WrapOperation.cpp
+++ b/source/blender/compositor/operations/COM_WrapOperation.cpp
@@ -89,7 +89,7 @@ bool WrapOperation::determineDependingAreaOfInterest(rcti *input,
newInput.ymin = input->ymin;
newInput.ymax = input->ymax;
- if (m_wrappingType == CMP_NODE_WRAP_X || m_wrappingType == CMP_NODE_WRAP_XY) {
+ if (ELEM(m_wrappingType, CMP_NODE_WRAP_X, CMP_NODE_WRAP_XY)) {
// wrap only on the x-axis if tile is wrapping
newInput.xmin = getWrappedOriginalXPos(input->xmin);
newInput.xmax = roundf(getWrappedOriginalXPos(input->xmax));
@@ -98,7 +98,7 @@ bool WrapOperation::determineDependingAreaOfInterest(rcti *input,
newInput.xmax = this->getWidth();
}
}
- if (m_wrappingType == CMP_NODE_WRAP_Y || m_wrappingType == CMP_NODE_WRAP_XY) {
+ if (ELEM(m_wrappingType, CMP_NODE_WRAP_Y, CMP_NODE_WRAP_XY)) {
// wrap only on the y-axis if tile is wrapping
newInput.ymin = getWrappedOriginalYPos(input->ymin);
newInput.ymax = roundf(getWrappedOriginalYPos(input->ymax));
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
index 640e3e3d381..574978e5a5f 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
@@ -21,18 +21,18 @@
#include "COM_defines.h"
#include <stdio.h>
-WriteBufferOperation::WriteBufferOperation(DataType datatype) : NodeOperation()
+WriteBufferOperation::WriteBufferOperation(DataType datatype)
{
this->addInputSocket(datatype);
this->m_memoryProxy = new MemoryProxy(datatype);
this->m_memoryProxy->setWriteBufferOperation(this);
- this->m_memoryProxy->setExecutor(NULL);
+ this->m_memoryProxy->setExecutor(nullptr);
}
WriteBufferOperation::~WriteBufferOperation()
{
if (this->m_memoryProxy) {
delete this->m_memoryProxy;
- this->m_memoryProxy = NULL;
+ this->m_memoryProxy = nullptr;
}
}
@@ -52,7 +52,7 @@ void WriteBufferOperation::initExecution()
void WriteBufferOperation::deinitExecution()
{
- this->m_input = NULL;
+ this->m_input = nullptr;
this->m_memoryProxy->free();
}
@@ -82,7 +82,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/
}
if (data) {
this->m_input->deinitializeTileData(rect, data);
- data = NULL;
+ data = nullptr;
}
}
else {
@@ -175,8 +175,8 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice *device,
0,
outputFloatBuffer,
0,
- NULL,
- NULL);
+ nullptr,
+ nullptr);
if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
index 767280e2cd2..22a37a4583e 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_ZCombineOperation.h"
#include "BLI_utildefines.h"
-ZCombineOperation::ZCombineOperation() : NodeOperation()
+ZCombineOperation::ZCombineOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
@@ -27,10 +27,10 @@ ZCombineOperation::ZCombineOperation() : NodeOperation()
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
- this->m_image1Reader = NULL;
- this->m_depth1Reader = NULL;
- this->m_image2Reader = NULL;
- this->m_depth2Reader = NULL;
+ this->m_image1Reader = nullptr;
+ this->m_depth1Reader = nullptr;
+ this->m_image2Reader = nullptr;
+ this->m_depth2Reader = nullptr;
}
void ZCombineOperation::initExecution()
@@ -88,23 +88,23 @@ void ZCombineAlphaOperation::executePixelSampled(float output[4],
void ZCombineOperation::deinitExecution()
{
- this->m_image1Reader = NULL;
- this->m_depth1Reader = NULL;
- this->m_image2Reader = NULL;
- this->m_depth2Reader = NULL;
+ this->m_image1Reader = nullptr;
+ this->m_depth1Reader = nullptr;
+ this->m_image2Reader = nullptr;
+ this->m_depth2Reader = nullptr;
}
// MASK combine
-ZCombineMaskOperation::ZCombineMaskOperation() : NodeOperation()
+ZCombineMaskOperation::ZCombineMaskOperation()
{
this->addInputSocket(COM_DT_VALUE); // mask
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
- this->m_maskReader = NULL;
- this->m_image1Reader = NULL;
- this->m_image2Reader = NULL;
+ this->m_maskReader = nullptr;
+ this->m_image1Reader = nullptr;
+ this->m_image2Reader = nullptr;
}
void ZCombineMaskOperation::initExecution()
@@ -154,7 +154,7 @@ void ZCombineMaskAlphaOperation::executePixelSampled(float output[4],
void ZCombineMaskOperation::deinitExecution()
{
- this->m_image1Reader = NULL;
- this->m_maskReader = NULL;
- this->m_image2Reader = NULL;
+ this->m_image1Reader = nullptr;
+ this->m_maskReader = nullptr;
+ this->m_image2Reader = nullptr;
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index 39de6054615..e4660c34762 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -50,8 +50,7 @@
#include "DEG_depsgraph.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
bool deg_check_id_in_depsgraph(const Depsgraph *graph, ID *id_orig)
{
@@ -241,5 +240,4 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
index 717239d7c64..df108072142 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
@@ -31,8 +31,7 @@
#include "BKE_animsys.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
/* Animated property storage. */
@@ -178,5 +177,4 @@ AnimatedPropertyStorage *DepsgraphBuilderCache::ensureInitializedAnimatedPropert
return animated_property_storage;
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
index 6fb11c5b91e..dbc8bbd31fa 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
@@ -37,8 +37,7 @@
#include "intern/depsgraph.h"
#include "intern/depsgraph_relation.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
namespace {
@@ -235,5 +234,4 @@ void deg_graph_detect_cycles(Depsgraph *graph)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_map.cc b/source/blender/depsgraph/intern/builder/deg_builder_map.cc
index e605e83a862..5da54350cfc 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_map.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_map.cc
@@ -25,8 +25,7 @@
#include "DNA_ID.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
BuilderMap::BuilderMap()
{
@@ -59,5 +58,4 @@ int BuilderMap::getIDTag(ID *id) const
return id_tags_.lookup_default(id, 0);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 7f9a745c1a4..9cae343dcde 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -96,7 +96,6 @@
#include "BKE_pointcache.h"
#include "BKE_rigidbody.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
#include "BKE_shader_fx.h"
#include "BKE_simulation.h"
#include "BKE_sound.h"
@@ -110,6 +109,8 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "SEQ_sequencer.h"
+
#include "intern/builder/deg_builder.h"
#include "intern/depsgraph.h"
#include "intern/depsgraph_type.h"
@@ -119,8 +120,7 @@
#include "intern/node/deg_node_id.h"
#include "intern/node/deg_node_operation.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
/* ************ */
/* Node Builder */
@@ -1199,7 +1199,7 @@ void DepsgraphNodeBuilder::build_particle_systems(Object *object, bool is_object
/* Keyed particle targets. */
if (ELEM(part->phystype, PART_PHYS_KEYED, PART_PHYS_BOIDS)) {
LISTBASE_FOREACH (ParticleTarget *, particle_target, &psys->targets) {
- if (particle_target->ob == nullptr || particle_target->ob == object) {
+ if (ELEM(particle_target->ob, nullptr, object)) {
continue;
}
build_object(-1, particle_target->ob, DEG_ID_LINKED_INDIRECTLY, is_object_visible);
@@ -1929,5 +1929,4 @@ void DepsgraphNodeBuilder::constraint_walk(bConstraint * /*con*/,
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
index 6143b4472d7..3c55d832568 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
@@ -54,8 +54,7 @@
#include "intern/node/deg_node_component.h"
#include "intern/node/deg_node_operation.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
void DepsgraphNodeBuilder::build_pose_constraints(Object *object,
bPoseChannel *pchan,
@@ -119,8 +118,10 @@ void DepsgraphNodeBuilder::build_splineik_pose(Object *object,
/* Find the chain's root. */
bPoseChannel *rootchan = BKE_armature_splineik_solver_find_root(pchan, data);
- if (has_operation_node(
- &object->id, NodeType::EVAL_POSE, rootchan->name, OperationCode::POSE_SPLINE_IK_SOLVER)) {
+ if (has_operation_node(&object->id,
+ NodeType::EVAL_POSE,
+ rootchan->name,
+ OperationCode::POSE_SPLINE_IK_SOLVER)) {
return;
}
@@ -350,5 +351,4 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *object, bool is_object_visibl
op_node->set_as_exit();
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
index fd457e0b2bf..21a32b0d005 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
@@ -25,8 +25,7 @@
#include "DNA_scene_types.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
void DepsgraphNodeBuilder::build_scene_render(Scene *scene, ViewLayer *view_layer)
{
@@ -88,5 +87,4 @@ void DepsgraphNodeBuilder::build_scene_compositor(Scene *scene)
build_nodetree(scene->nodetree);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
index 1d6712d16ef..7a6dc6e2315 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
@@ -55,8 +55,7 @@
#include "intern/node/deg_node_component.h"
#include "intern/node/deg_node_operation.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
void DepsgraphNodeBuilder::build_layer_collections(ListBase *lb)
{
@@ -175,5 +174,4 @@ void DepsgraphNodeBuilder::build_view_layer(Scene *scene,
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
index 924088cbc13..4406cc83a0d 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
@@ -28,8 +28,7 @@
#include "BLI_utildefines.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
RootPChanMap::RootPChanMap()
{
@@ -78,5 +77,4 @@ bool RootPChanMap::has_common_root(const char *bone1, const char *bone2) const
return Set<StringRefNull>::Intersects(*bone1_roots, *bone2_roots);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index bac36885dfc..a55966632d8 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -89,7 +89,6 @@
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_rigidbody.h"
-#include "BKE_sequencer.h"
#include "BKE_shader_fx.h"
#include "BKE_shrinkwrap.h"
#include "BKE_sound.h"
@@ -99,6 +98,8 @@
#include "RNA_access.h"
#include "RNA_types.h"
+#include "SEQ_sequencer.h"
+
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -119,8 +120,7 @@
#include "intern/depsgraph_relation.h"
#include "intern/depsgraph_type.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
/* ***************** */
/* Relations Builder */
@@ -742,7 +742,7 @@ void DepsgraphRelationBuilder::build_object_proxy_from(Object *object)
void DepsgraphRelationBuilder::build_object_proxy_group(Object *object)
{
- if (object->proxy_group == nullptr || object->proxy_group == object->proxy) {
+ if (ELEM(object->proxy_group, nullptr, object->proxy)) {
return;
}
/* Object is local here (local in .blend file, users interacts with it). */
@@ -1233,7 +1233,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
}
}
if (cti->flush_constraint_targets) {
- cti->flush_constraint_targets(con, &targets, 1);
+ cti->flush_constraint_targets(con, &targets, true);
}
}
}
@@ -1853,7 +1853,7 @@ void DepsgraphRelationBuilder::build_particle_systems(Object *object)
/* Keyed particle targets. */
if (ELEM(part->phystype, PART_PHYS_KEYED, PART_PHYS_BOIDS)) {
LISTBASE_FOREACH (ParticleTarget *, particle_target, &psys->targets) {
- if (particle_target->ob == nullptr || particle_target->ob == object) {
+ if (ELEM(particle_target->ob, nullptr, object)) {
continue;
}
/* Make sure target object is pulled into the graph. */
@@ -2203,7 +2203,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
/* Layer parenting need react to the parent object transformation. */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
- if (gpl->parent != NULL) {
+ if (gpl->parent != nullptr) {
ComponentKey gpd_geom_key(&gpd->id, NodeType::GEOMETRY);
if (gpl->partype == PARBONE) {
@@ -2813,8 +2813,7 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node)
* to preserve that cache in copy-on-write, but for the time being
* we allow flush to layer collections component which will ensure
* that cached array of bases exists and is up-to-date. */
- if (comp_node->type == NodeType::PARAMETERS ||
- comp_node->type == NodeType::LAYER_COLLECTIONS) {
+ if (ELEM(comp_node->type, NodeType::PARAMETERS, NodeType::LAYER_COLLECTIONS)) {
rel_flag &= ~RELATION_FLAG_NO_FLUSH;
}
/* All entry operations of each component should wait for a proper
@@ -2926,5 +2925,4 @@ void DepsgraphRelationBuilder::constraint_walk(bConstraint * /*con*/,
data->builder->build_id(id);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc
index 717c8300f9b..b9ce29ce8d2 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc
@@ -35,13 +35,10 @@
#include "intern/depsgraph_relation.h"
#include "intern/node/deg_node.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
DriverDescriptor::DriverDescriptor(PointerRNA *id_ptr, FCurve *fcu)
- : rna_prefix(),
- rna_suffix(),
- id_ptr_(id_ptr),
+ : id_ptr_(id_ptr),
fcu_(fcu),
driver_relations_needed_(false),
pointer_rna_(),
@@ -254,5 +251,4 @@ void DepsgraphRelationBuilder::build_driver_relations(IDNode *id_node)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
index 2220ba6ee13..e0a7a42ea4a 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
@@ -25,8 +25,7 @@
#include "intern/builder/deg_builder_relations.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
////////////////////////////////////////////////////////////////////////////////
// Time source.
@@ -193,5 +192,4 @@ string RNAPathKey::identifier() const
return string("RnaPathKey(") + "id: " + id_name + ", prop: '" + prop_name + "')";
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
index 4c765152a2b..39a60c9029c 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -58,8 +58,7 @@
#include "intern/depsgraph_relation.h"
#include "intern/depsgraph_type.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
/* IK Solver Eval Steps */
void DepsgraphRelationBuilder::build_ik_pose(Object *object,
@@ -510,5 +509,4 @@ void DepsgraphRelationBuilder::build_proxy_rig(Object *object)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
index 703c6c7cd68..74948a336e9 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
@@ -25,8 +25,7 @@
#include "DNA_scene_types.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
void DepsgraphRelationBuilder::build_scene_render(Scene *scene, ViewLayer *view_layer)
{
@@ -76,5 +75,4 @@ void DepsgraphRelationBuilder::build_scene_compositor(Scene *scene)
build_nodetree(scene->nodetree);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
index 6e64eba60dc..b58d4a22712 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
@@ -56,8 +56,7 @@
#include "intern/depsgraph_type.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
void DepsgraphRelationBuilder::build_layer_collections(ListBase *lb)
{
@@ -154,5 +153,4 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene,
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.cc b/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.cc
index 8d51fa1422a..77d1a89c256 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.cc
@@ -33,8 +33,7 @@
#include "intern/depsgraph_relation.h"
#include "intern/depsgraph_type.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
static inline bool is_unused_noop(OperationNode *op_node)
{
@@ -85,5 +84,4 @@ void deg_graph_remove_unused_noops(Depsgraph *graph)
(::Depsgraph *)graph, BUILD, "Removed %d relations to no-op nodes\n", num_removed_relations);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index 18b24179edf..4064058f231 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -48,8 +48,7 @@
#include "intern/node/deg_node_id.h"
#include "intern/node/deg_node_operation.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
/* ********************************* ID Data ******************************** */
@@ -209,8 +208,7 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
}
}
/* Final transform properties go to the Done node for the exit. */
- else if (STREQ(prop_name, "head") || STREQ(prop_name, "tail") ||
- STREQ(prop_name, "length") || STRPREFIX(prop_name, "matrix")) {
+ else if (STR_ELEM(prop_name, "head", "tail", "length") || STRPREFIX(prop_name, "matrix")) {
if (source == RNAPointerSource::EXIT) {
node_identifier.operation_code = OperationCode::BONE_DONE;
}
@@ -325,7 +323,7 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
node_identifier.type = NodeType::GEOMETRY;
return node_identifier;
}
- if (STREQ(prop_identifier, "hide_viewport") || STREQ(prop_identifier, "hide_render")) {
+ if (STR_ELEM(prop_identifier, "hide_viewport", "hide_render")) {
node_identifier.type = NodeType::OBJECT_FROM_LAYER;
return node_identifier;
}
@@ -401,5 +399,4 @@ RNANodeQueryIDData *RNANodeQuery::ensure_id_data(const ID *id)
return id_data.get();
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna_test.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna_test.cc
index c91dda87190..b7a5aa7c171 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna_test.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna_test.cc
@@ -25,9 +25,7 @@
#include "testing/testing.h"
-namespace blender {
-namespace deg {
-namespace tests {
+namespace blender::deg::tests {
class TestableRNANodeQuery : public RNANodeQuery {
public:
@@ -55,6 +53,4 @@ TEST(deg_builder_rna, contains)
EXPECT_FALSE(TestableRNANodeQuery::contains("pose.bone[\"location\"].scale[0]", "location"));
}
-} // namespace tests
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg::tests
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
index c5e020b3242..c30778e7a91 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
@@ -33,8 +33,7 @@
#include "intern/depsgraph.h"
#include "intern/depsgraph_relation.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
/* -------------------------------------------------- */
@@ -110,5 +109,4 @@ void deg_graph_transitive_reduction(Depsgraph *graph)
DEG_DEBUG_PRINTF((::Depsgraph *)graph, BUILD, "Removed %d relations\n", num_removed_relations);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/pipeline.cc b/source/blender/depsgraph/intern/builder/pipeline.cc
index b13077e4792..f7feeea9593 100644
--- a/source/blender/depsgraph/intern/builder/pipeline.cc
+++ b/source/blender/depsgraph/intern/builder/pipeline.cc
@@ -30,15 +30,13 @@
#include "deg_builder_relations.h"
#include "deg_builder_transitive.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
AbstractBuilderPipeline::AbstractBuilderPipeline(::Depsgraph *graph)
: deg_graph_(reinterpret_cast<Depsgraph *>(graph)),
bmain_(deg_graph_->bmain),
scene_(deg_graph_->scene),
- view_layer_(deg_graph_->view_layer),
- builder_cache_()
+ view_layer_(deg_graph_->view_layer)
{
}
@@ -125,5 +123,4 @@ unique_ptr<DepsgraphRelationBuilder> AbstractBuilderPipeline::construct_relation
return std::make_unique<DepsgraphRelationBuilder>(bmain_, deg_graph_, &builder_cache_);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/pipeline_all_objects.cc b/source/blender/depsgraph/intern/builder/pipeline_all_objects.cc
index 81d239239be..d02aa16f26b 100644
--- a/source/blender/depsgraph/intern/builder/pipeline_all_objects.cc
+++ b/source/blender/depsgraph/intern/builder/pipeline_all_objects.cc
@@ -25,8 +25,7 @@
#include "DNA_layer_types.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
namespace {
@@ -73,5 +72,4 @@ unique_ptr<DepsgraphRelationBuilder> AllObjectsBuilderPipeline::construct_relati
return std::make_unique<AllObjectsRelationBuilder>(bmain_, deg_graph_, &builder_cache_);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/pipeline_compositor.cc b/source/blender/depsgraph/intern/builder/pipeline_compositor.cc
index 2b9922851c1..5fa9788cf72 100644
--- a/source/blender/depsgraph/intern/builder/pipeline_compositor.cc
+++ b/source/blender/depsgraph/intern/builder/pipeline_compositor.cc
@@ -23,8 +23,7 @@
#include "intern/builder/deg_builder_relations.h"
#include "intern/depsgraph.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
CompositorBuilderPipeline::CompositorBuilderPipeline(::Depsgraph *graph, bNodeTree *nodetree)
: AbstractBuilderPipeline(graph), nodetree_(nodetree)
@@ -44,5 +43,4 @@ void CompositorBuilderPipeline::build_relations(DepsgraphRelationBuilder &relati
relation_builder.build_nodetree(nodetree_);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc
index 87cfeb46693..5fd4a0fc3dd 100644
--- a/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc
+++ b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc
@@ -25,8 +25,7 @@
#include "intern/builder/deg_builder_relations.h"
#include "intern/depsgraph.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
namespace {
@@ -146,5 +145,4 @@ void FromIDsBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/pipeline_render.cc b/source/blender/depsgraph/intern/builder/pipeline_render.cc
index 3b065f7f1bc..9b40e4644a2 100644
--- a/source/blender/depsgraph/intern/builder/pipeline_render.cc
+++ b/source/blender/depsgraph/intern/builder/pipeline_render.cc
@@ -23,8 +23,7 @@
#include "intern/builder/deg_builder_relations.h"
#include "intern/depsgraph.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
RenderBuilderPipeline::RenderBuilderPipeline(::Depsgraph *graph) : AbstractBuilderPipeline(graph)
{
@@ -41,5 +40,4 @@ void RenderBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_b
relation_builder.build_scene_render(scene_, view_layer_);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc b/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc
index f1852a40a10..5ae577ab031 100644
--- a/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc
+++ b/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc
@@ -23,8 +23,7 @@
#include "intern/builder/deg_builder_relations.h"
#include "intern/depsgraph.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
ViewLayerBuilderPipeline::ViewLayerBuilderPipeline(::Depsgraph *graph)
: AbstractBuilderPipeline(graph)
@@ -41,5 +40,4 @@ void ViewLayerBuilderPipeline::build_relations(DepsgraphRelationBuilder &relatio
relation_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/debug/deg_debug.cc b/source/blender/depsgraph/intern/debug/deg_debug.cc
index ab6adea6416..47c97211886 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug.cc
@@ -32,8 +32,7 @@
#include "BKE_global.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
DepsgraphDebug::DepsgraphDebug()
: flags(G.debug), is_ever_evaluated(false), graph_evaluation_start_time_(0)
@@ -73,7 +72,7 @@ void DepsgraphDebug::end_graph_evaluation()
is_ever_evaluated = true;
}
-bool terminal_do_color(void)
+bool terminal_do_color()
{
return (G.debug & G_DEBUG_DEPSGRAPH_PRETTY) != 0;
}
@@ -90,7 +89,7 @@ string color_for_pointer(const void *pointer)
return string(buffer);
}
-string color_end(void)
+string color_end()
{
if (!terminal_do_color()) {
return "";
@@ -98,5 +97,4 @@ string color_end(void)
return string(TRUECOLOR_ANSI_COLOR_FINISH);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
index 04b25a36d6d..a0cbbbc163d 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
@@ -47,8 +47,7 @@ namespace dot = blender::dot;
/* ****************** */
/* Graphviz Debugging */
-namespace blender {
-namespace deg {
+namespace blender::deg {
/* Only one should be enabled, defines whether graphviz nodes
* get colored by individual types or classes.
@@ -510,8 +509,7 @@ static void deg_debug_graphviz_graph_relations(DotExportContext &ctx, const Deps
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
void DEG_debug_relations_graphviz(const Depsgraph *graph, FILE *fp, const char *label)
{
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 42c1fcba1bb..0cdd627dd44 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc
@@ -38,8 +38,7 @@
namespace deg = blender::deg;
-namespace blender {
-namespace deg {
+namespace blender::deg {
namespace {
struct DebugContext {
@@ -149,8 +148,7 @@ void deg_debug_stats_gnuplot(const DebugContext &ctx)
}
} // namespace
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
void DEG_debug_stats_gnuplot(const Depsgraph *depsgraph,
FILE *fp,
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index 99804a7cd7d..870a6d3fce8 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -57,8 +57,7 @@
namespace deg = blender::deg;
-namespace blender {
-namespace deg {
+namespace blender::deg {
Depsgraph::Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
: time_source(nullptr),
@@ -263,8 +262,7 @@ ID *Depsgraph::get_cow_id(const ID *id_orig) const
return id_node->id_cow;
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
/* **************** */
/* Public Graph API */
@@ -287,7 +285,7 @@ void DEG_graph_replace_owners(struct Depsgraph *depsgraph,
deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph);
const bool do_update_register = deg_graph->bmain != bmain;
- if (do_update_register && deg_graph->bmain != NULL) {
+ if (do_update_register && deg_graph->bmain != nullptr) {
deg::unregister_graph(deg_graph);
}
diff --git a/source/blender/depsgraph/intern/depsgraph_physics.cc b/source/blender/depsgraph/intern/depsgraph_physics.cc
index 0b8203ab05f..8f3aab19e37 100644
--- a/source/blender/depsgraph/intern/depsgraph_physics.cc
+++ b/source/blender/depsgraph/intern/depsgraph_physics.cc
@@ -174,8 +174,7 @@ void DEG_add_forcefield_relations(DepsNodeHandle *handle,
/******************************** Internal API ********************************/
-namespace blender {
-namespace deg {
+namespace blender::deg {
ListBase *build_effector_relations(Depsgraph *graph, Collection *collection)
{
@@ -245,5 +244,4 @@ void clear_physics_relations(Depsgraph *graph)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
index ebdd08ce519..ed7011ba306 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
@@ -44,8 +44,7 @@ namespace deg = blender::deg;
/* ************************ DEG TRAVERSAL ********************* */
-namespace blender {
-namespace deg {
+namespace blender::deg {
namespace {
typedef deque<OperationNode *> TraversalQueue;
@@ -265,8 +264,7 @@ void deg_foreach_id(const Depsgraph *depsgraph, DEGForeachIDCallback callback, v
}
} // namespace
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
void DEG_foreach_dependent_ID(const Depsgraph *depsgraph,
const ID *id,
diff --git a/source/blender/depsgraph/intern/depsgraph_registry.cc b/source/blender/depsgraph/intern/depsgraph_registry.cc
index 623702ee3ae..f348ef6e6e9 100644
--- a/source/blender/depsgraph/intern/depsgraph_registry.cc
+++ b/source/blender/depsgraph/intern/depsgraph_registry.cc
@@ -27,8 +27,7 @@
#include "intern/depsgraph.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
using GraphRegistry = Map<Main *, VectorSet<Depsgraph *>>;
static GraphRegistry &get_graph_registry()
@@ -65,5 +64,4 @@ Span<Depsgraph *> get_all_registered_graphs(Main *bmain)
return {};
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/depsgraph_relation.cc b/source/blender/depsgraph/intern/depsgraph_relation.cc
index d09247b03d9..904a6b56ae9 100644
--- a/source/blender/depsgraph/intern/depsgraph_relation.cc
+++ b/source/blender/depsgraph/intern/depsgraph_relation.cc
@@ -28,8 +28,7 @@
#include "intern/depsgraph_type.h"
#include "intern/node/deg_node.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
Relation::Relation(Node *from, Node *to, const char *description)
: from(from), to(to), name(description), flag(0)
@@ -65,5 +64,4 @@ void Relation::unlink()
to->inlinks.remove_first_occurrence_and_reorder(this);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 868f88d8fcd..aec3dd4b9ea 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -73,8 +73,7 @@ namespace deg = blender::deg;
/* *********************** */
/* Update Tagging/Flushing */
-namespace blender {
-namespace deg {
+namespace blender::deg {
namespace {
@@ -308,7 +307,7 @@ void depsgraph_tag_component(Depsgraph *graph,
void deg_graph_id_tag_legacy_compat(
Main *bmain, Depsgraph *depsgraph, ID *id, IDRecalcFlag tag, eUpdateSource update_source)
{
- if (tag == ID_RECALC_GEOMETRY || tag == 0) {
+ if (ELEM(tag, ID_RECALC_GEOMETRY, 0)) {
switch (GS(id->name)) {
case ID_OB: {
Object *object = (Object *)id;
@@ -617,7 +616,7 @@ void id_tag_update(Main *bmain, ID *id, int flag, eUpdateSource update_source)
/* Accumulate all tags for an ID between two undo steps, so they can be
* replayed for undo. */
- id->recalc_after_undo_push |= deg_recalc_flags_effective(NULL, flag);
+ id->recalc_after_undo_push |= deg_recalc_flags_effective(nullptr, flag);
}
void graph_id_tag_update(
@@ -676,8 +675,7 @@ void graph_id_tag_update(
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
const char *DEG_update_tag_as_string(IDRecalcFlag flag)
{
diff --git a/source/blender/depsgraph/intern/depsgraph_update.cc b/source/blender/depsgraph/intern/depsgraph_update.cc
index 98ff136f7bc..bb72320ca67 100644
--- a/source/blender/depsgraph/intern/depsgraph_update.cc
+++ b/source/blender/depsgraph/intern/depsgraph_update.cc
@@ -29,8 +29,7 @@
namespace deg = blender::deg;
-namespace blender {
-namespace deg {
+namespace blender::deg {
static DEG_EditorUpdateIDCb deg_editor_update_id_cb = nullptr;
static DEG_EditorUpdateSceneCb deg_editor_update_scene_cb = nullptr;
@@ -49,8 +48,7 @@ void deg_editors_scene_update(const DEGEditorUpdateContext *update_ctx, bool upd
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
/* Set callbacks which are being called when depsgraph changes. */
void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func, DEG_EditorUpdateSceneCb scene_func)
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index 2c4b7f03db5..620e86550cc 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -54,8 +54,7 @@
#include "intern/node/deg_node_operation.h"
#include "intern/node/deg_node_time.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
namespace {
@@ -71,7 +70,7 @@ void schedule_children(DepsgraphEvalState *state,
void schedule_node_to_pool(OperationNode *node, const int UNUSED(thread_id), TaskPool *pool)
{
- BLI_task_pool_push(pool, deg_task_run_func, node, false, NULL);
+ BLI_task_pool_push(pool, deg_task_run_func, node, false, nullptr);
}
/* Denotes which part of dependency graph is being evaluated. */
@@ -416,5 +415,4 @@ void deg_evaluate_on_refresh(Depsgraph *graph)
graph->debug.end_graph_evaluation();
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 477dd316768..cff7292abd4 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -90,9 +90,10 @@
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_pointcache.h"
-#include "BKE_sequencer.h"
#include "BKE_sound.h"
+#include "SEQ_sequencer.h"
+
#include "intern/builder/deg_builder.h"
#include "intern/builder/deg_builder_nodes.h"
#include "intern/depsgraph.h"
@@ -100,8 +101,7 @@
#include "intern/node/deg_node.h"
#include "intern/node/deg_node_id.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
#define DEBUG_PRINT \
if (G.debug & G_DEBUG_DEPSGRAPH_EVAL) \
@@ -304,7 +304,7 @@ bool id_copy_inplace_no_main(const ID *id, ID *newid)
bool result = (BKE_id_copy_ex(nullptr,
(ID *)id_for_copy,
&newid,
- LIB_ID_COPY_LOCALIZE | LIB_ID_CREATE_NO_ALLOCATE) != NULL);
+ LIB_ID_COPY_LOCALIZE | LIB_ID_CREATE_NO_ALLOCATE) != nullptr);
#ifdef NESTED_ID_NASTY_WORKAROUND
if (result) {
@@ -333,7 +333,7 @@ bool scene_copy_inplace_no_main(const Scene *scene, Scene *new_scene)
bool result = (BKE_id_copy_ex(nullptr,
id_for_copy,
(ID **)&new_scene,
- LIB_ID_COPY_LOCALIZE | LIB_ID_CREATE_NO_ALLOCATE) != NULL);
+ LIB_ID_COPY_LOCALIZE | LIB_ID_CREATE_NO_ALLOCATE) != nullptr);
#ifdef NESTED_ID_NASTY_WORKAROUND
if (result) {
@@ -1126,5 +1126,4 @@ bool deg_copy_on_write_is_needed(const ID_Type id_type)
return ID_TYPE_IS_COW(id_type);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index 5ccdcbec858..fa7cfb305ee 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -69,8 +69,7 @@
// catch usage of invalid state.
#undef INVALIDATE_ON_FLUSH
-namespace blender {
-namespace deg {
+namespace blender::deg {
enum {
ID_STATE_NONE = 0,
@@ -145,8 +144,7 @@ inline void flush_handle_component_node(IDNode *id_node,
* special component where we don't want all operations to be tagged.
*
* TODO(sergey): Make this a more generic solution. */
- if (comp_node->type != NodeType::PARTICLE_SETTINGS &&
- comp_node->type != NodeType::PARTICLE_SYSTEM) {
+ if (!ELEM(comp_node->type, NodeType::PARTICLE_SETTINGS, NodeType::PARTICLE_SYSTEM)) {
for (OperationNode *op : comp_node->operations) {
op->flag |= DEPSOP_FLAG_NEEDS_UPDATE;
}
@@ -411,5 +409,4 @@ void deg_graph_clear_tags(Depsgraph *graph)
graph->time_source->tagged_for_update = false;
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc
index f3d9422a88b..7a0c1b5b693 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc
@@ -29,8 +29,7 @@
#include "DRW_engine.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
RuntimeBackup::RuntimeBackup(const Depsgraph *depsgraph)
: have_backup(false),
@@ -117,5 +116,4 @@ void RuntimeBackup::restore_to_id(ID *id)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc
index 6c4eb8a91ee..3c0df93f4b9 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc
@@ -32,8 +32,7 @@
#include "intern/depsgraph.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
namespace {
@@ -142,5 +141,4 @@ void AnimationBackup::restore_to_id(ID *id)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc
index 25bcf2bfe72..0594b8a11b6 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc
@@ -25,13 +25,11 @@
#include "DNA_modifier_types.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
ModifierDataBackup::ModifierDataBackup(ModifierData *modifier_data)
: type(static_cast<ModifierType>(modifier_data->type)), runtime(modifier_data->runtime)
{
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.cc
index 9d3740258cc..3ee0d018782 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.cc
@@ -27,8 +27,7 @@
#include "BLI_utildefines.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
MovieClipBackup::MovieClipBackup(const Depsgraph * /*depsgraph*/)
{
@@ -59,5 +58,4 @@ void MovieClipBackup::restore_to_movieclip(MovieClip *movieclip)
reset();
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc
index addee3dc539..61299a2d49c 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc
@@ -32,8 +32,7 @@
#include "BKE_action.h"
#include "BKE_object.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
ObjectRuntimeBackup::ObjectRuntimeBackup(const Depsgraph * /*depsgraph*/)
: base_flag(0), base_local_view_bits(0)
@@ -180,5 +179,4 @@ void ObjectRuntimeBackup::restore_pose_channel_runtime_data(Object *object)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.cc
index 45663378f67..e99d18b442d 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.cc
@@ -22,9 +22,3 @@
*/
#include "intern/eval/deg_eval_runtime_backup_pose.h"
-
-namespace blender {
-namespace deg {
-
-}
-} // namespace blender
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.cc
index f000c8b5d4d..96a82c24778 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.cc
@@ -28,8 +28,7 @@
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
SceneBackup::SceneBackup(const Depsgraph *depsgraph) : sequencer_backup(depsgraph)
{
@@ -86,5 +85,4 @@ void SceneBackup::restore_to_scene(Scene *scene)
reset();
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.cc
index 3866a89cc17..35720140f97 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.cc
@@ -25,8 +25,7 @@
#include "DNA_sequence_types.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
SequenceBackup::SequenceBackup(const Depsgraph * /*depsgraph*/)
{
@@ -56,5 +55,4 @@ bool SequenceBackup::isEmpty() const
return (scene_sound == nullptr);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc
index 4d79480a5ad..c0e284a930e 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc
@@ -28,11 +28,11 @@
#include "BLI_assert.h"
-#include "BKE_sequencer.h"
#include "BKE_sound.h"
-namespace blender {
-namespace deg {
+#include "SEQ_sequencer.h"
+
+namespace blender::deg {
SequencerBackup::SequencerBackup(const Depsgraph *depsgraph) : depsgraph(depsgraph)
{
@@ -73,5 +73,4 @@ void SequencerBackup::restore_to_scene(Scene *scene)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.cc
index 4b63ada8bde..d05245a1c28 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.cc
@@ -27,8 +27,7 @@
#include "DNA_sound_types.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
SoundBackup::SoundBackup(const Depsgraph * /*depsgraph*/)
{
@@ -62,5 +61,4 @@ void SoundBackup::restore_to_sound(bSound *sound)
reset();
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc
index 8808673ce6a..8e9fff56023 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc
@@ -33,8 +33,7 @@
#include <stdio.h>
-namespace blender {
-namespace deg {
+namespace blender::deg {
VolumeBackup::VolumeBackup(const Depsgraph * /*depsgraph*/) : grids(nullptr)
{
@@ -58,5 +57,4 @@ void VolumeBackup::restore_to_volume(Volume *volume)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_stats.cc b/source/blender/depsgraph/intern/eval/deg_eval_stats.cc
index 3c84c781cbb..fb627fa69c5 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_stats.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_stats.cc
@@ -32,8 +32,7 @@
#include "intern/node/deg_node_id.h"
#include "intern/node/deg_node_operation.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
void deg_eval_stats_aggregate(Depsgraph *graph)
{
@@ -55,5 +54,4 @@ void deg_eval_stats_aggregate(Depsgraph *graph)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/node/deg_node.cc b/source/blender/depsgraph/intern/node/deg_node.cc
index 87843006347..6266acae651 100644
--- a/source/blender/depsgraph/intern/node/deg_node.cc
+++ b/source/blender/depsgraph/intern/node/deg_node.cc
@@ -36,8 +36,7 @@
#include "intern/node/deg_node_operation.h"
#include "intern/node/deg_node_time.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
const char *nodeClassAsString(NodeClass node_class)
{
@@ -340,5 +339,4 @@ void deg_register_base_depsnodes()
register_node_typeinfo(&DNTI_ID_REF);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc
index 2767513d6df..6ffe5db3fec 100644
--- a/source/blender/depsgraph/intern/node/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_component.cc
@@ -38,8 +38,7 @@
#include "intern/node/deg_node_id.h"
#include "intern/node/deg_node_operation.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
/* *********** */
/* Outer Nodes */
@@ -376,5 +375,4 @@ void deg_register_component_depsnodes()
register_node_typeinfo(&DNTI_SIMULATION);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/node/deg_node_factory.cc b/source/blender/depsgraph/intern/node/deg_node_factory.cc
index 9bb093139a1..209178f4b73 100644
--- a/source/blender/depsgraph/intern/node/deg_node_factory.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_factory.cc
@@ -23,8 +23,7 @@
#include "intern/node/deg_node_factory.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
/* Global type registry */
static DepsNodeFactory *node_typeinfo_registry[static_cast<int>(NodeType::NUM_TYPES)] = {nullptr};
@@ -43,5 +42,4 @@ DepsNodeFactory *type_get_factory(const NodeType type)
return node_typeinfo_registry[type_as_int];
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc
index 8d19949adc8..345da466960 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_id.cc
@@ -41,8 +41,7 @@
#include "intern/node/deg_node_factory.h"
#include "intern/node/deg_node_time.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
const char *linkedStateAsString(eDepsNode_LinkedState_Type linked_state)
{
@@ -137,7 +136,7 @@ void IDNode::destroy()
}
/* Free memory used by this CoW ID. */
- if (id_cow != id_orig && id_cow != nullptr) {
+ if (!ELEM(id_cow, id_orig, nullptr)) {
deg_free_copy_on_write_datablock(id_cow);
MEM_freeN(id_cow);
id_cow = nullptr;
@@ -213,5 +212,4 @@ IDComponentsMask IDNode::get_visible_components_mask() const
return result;
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.cc b/source/blender/depsgraph/intern/node/deg_node_operation.cc
index a32a43e2905..97aca6280be 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.cc
@@ -32,8 +32,7 @@
#include "intern/node/deg_node_factory.h"
#include "intern/node/deg_node_id.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
const char *operationCodeAsString(OperationCode opcode)
{
@@ -273,5 +272,4 @@ void deg_register_operation_depsnodes()
register_node_typeinfo(&DNTI_OPERATION);
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/depsgraph/intern/node/deg_node_time.cc b/source/blender/depsgraph/intern/node/deg_node_time.cc
index 4f7f70fef33..59ac4bd3d08 100644
--- a/source/blender/depsgraph/intern/node/deg_node_time.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_time.cc
@@ -28,8 +28,7 @@
#include "intern/depsgraph.h"
#include "intern/depsgraph_relation.h"
-namespace blender {
-namespace deg {
+namespace blender::deg {
void TimeSourceNode::tag_update(Depsgraph * /*graph*/, eUpdateSource /*source*/)
{
@@ -47,5 +46,4 @@ void TimeSourceNode::flush_update_tag(Depsgraph *graph)
}
}
-} // namespace deg
-} // namespace blender
+} // namespace blender::deg
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 4e72e89ae99..cefd52db66c 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -25,6 +25,7 @@ set(INC
../blenfont
../blenkernel
../blenlib
+ ../blenloader
../blentranslation
../bmesh
../depsgraph
@@ -35,13 +36,16 @@ set(INC
../makesdna
../makesrna
../nodes
- ../render/extern/include
- ../render/intern/include
+ ../render
+ ../render/intern
../windowmanager
../../../intern/atomic
../../../intern/glew-mx
../../../intern/guardedalloc
+
+ # dna_type_offsets.h
+ ${CMAKE_CURRENT_BINARY_DIR}/../makesdna/intern
)
set(SRC
@@ -446,6 +450,9 @@ endif()
blender_add_lib(bf_draw "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+# Needed so we can use dna_type_offsets.h for defaults initialization.
+add_dependencies(bf_draw bf_dna)
+
if(WITH_GTESTS)
if(WITH_OPENGL_DRAW_TESTS)
set(TEST_SRC
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index ca5c2c94b40..2d5b93f4272 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -36,6 +36,7 @@ struct ARegion;
struct DRWInstanceDataList;
struct Depsgraph;
struct DrawEngineType;
+struct GHash;
struct GPUMaterial;
struct GPUOffScreen;
struct GPUViewport;
@@ -140,6 +141,7 @@ void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph
/* This is here because GPUViewport needs it */
struct DRWInstanceDataList *DRW_instance_data_list_create(void);
void DRW_instance_data_list_free(struct DRWInstanceDataList *idatalist);
+void DRW_uniform_attrs_pool_free(struct GHash *table);
void DRW_render_context_enable(struct Render *render);
void DRW_render_context_disable(struct Render *render);
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 355d156a083..7d1f40ba5d8 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -401,7 +401,7 @@ static void eevee_id_world_update(void *vedata, World *wo)
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
LightCache *lcache = stl->g_data->light_cache;
- if (lcache == NULL || lcache == stl->lookdev_lightcache) {
+ if (ELEM(lcache, NULL, stl->lookdev_lightcache)) {
/* Avoid Lookdev viewport clearing the update flag (see T67741). */
return;
}
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index b515ea9c625..040aa8c8d9c 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -26,6 +26,7 @@
#include "BKE_global.h"
+#include "BLI_endian_switch.h"
#include "BLI_threads.h"
#include "DEG_depsgraph_build.h"
@@ -47,6 +48,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "BLO_read_write.h"
+
#include "wm_window.h"
/* Rounded to nearest PowerOfTwo */
@@ -509,6 +512,82 @@ void EEVEE_lightcache_free(LightCache *lcache)
MEM_freeN(lcache);
}
+static void write_lightcache_texture(BlendWriter *writer, LightCacheTexture *tex)
+{
+ if (tex->data) {
+ size_t data_size = tex->components * tex->tex_size[0] * tex->tex_size[1] * tex->tex_size[2];
+ if (tex->data_type == LIGHTCACHETEX_FLOAT) {
+ data_size *= sizeof(float);
+ }
+ else if (tex->data_type == LIGHTCACHETEX_UINT) {
+ data_size *= sizeof(uint);
+ }
+
+ /* FIXME: We can't save more than what 32bit systems can handle.
+ * The solution would be to split the texture but it is too late for 2.90. (see T78529) */
+ if (data_size < INT_MAX) {
+ BLO_write_raw(writer, data_size, tex->data);
+ }
+ }
+}
+
+void EEVEE_lightcache_blend_write(BlendWriter *writer, LightCache *cache)
+{
+ write_lightcache_texture(writer, &cache->grid_tx);
+ write_lightcache_texture(writer, &cache->cube_tx);
+
+ if (cache->cube_mips) {
+ BLO_write_struct_array(writer, LightCacheTexture, cache->mips_len, cache->cube_mips);
+ for (int i = 0; i < cache->mips_len; i++) {
+ write_lightcache_texture(writer, &cache->cube_mips[i]);
+ }
+ }
+
+ BLO_write_struct_array(writer, LightGridCache, cache->grid_len, cache->grid_data);
+ BLO_write_struct_array(writer, LightProbeCache, cache->cube_len, cache->cube_data);
+}
+
+static void direct_link_lightcache_texture(BlendDataReader *reader, LightCacheTexture *lctex)
+{
+ lctex->tex = NULL;
+
+ if (lctex->data) {
+ BLO_read_data_address(reader, &lctex->data);
+ if (lctex->data && BLO_read_requires_endian_switch(reader)) {
+ int data_size = lctex->components * lctex->tex_size[0] * lctex->tex_size[1] *
+ lctex->tex_size[2];
+
+ if (lctex->data_type == LIGHTCACHETEX_FLOAT) {
+ BLI_endian_switch_float_array((float *)lctex->data, data_size * sizeof(float));
+ }
+ else if (lctex->data_type == LIGHTCACHETEX_UINT) {
+ BLI_endian_switch_uint32_array((uint *)lctex->data, data_size * sizeof(uint));
+ }
+ }
+ }
+
+ if (lctex->data == NULL) {
+ zero_v3_int(lctex->tex_size);
+ }
+}
+
+void EEVEE_lightcache_blend_read_data(BlendDataReader *reader, LightCache *cache)
+{
+ cache->flag &= ~LIGHTCACHE_NOT_USABLE;
+ direct_link_lightcache_texture(reader, &cache->cube_tx);
+ direct_link_lightcache_texture(reader, &cache->grid_tx);
+
+ if (cache->cube_mips) {
+ BLO_read_data_address(reader, &cache->cube_mips);
+ for (int i = 0; i < cache->mips_len; i++) {
+ direct_link_lightcache_texture(reader, &cache->cube_mips[i]);
+ }
+ }
+
+ BLO_read_data_address(reader, &cache->cube_data);
+ BLO_read_data_address(reader, &cache->grid_data);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.h b/source/blender/draw/engines/eevee/eevee_lightcache.h
index 489c9ac22f4..17392c0de0b 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.h
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.h
@@ -30,6 +30,8 @@ struct LightCache;
struct Scene;
struct SceneEEVEE;
struct ViewLayer;
+struct BlendWriter;
+struct BlendDataReader;
/* Light Bake */
struct wmJob *EEVEE_lightbake_job_create(struct wmWindowManager *wm,
@@ -61,3 +63,6 @@ struct LightCache *EEVEE_lightcache_create(const int grid_len,
void EEVEE_lightcache_free(struct LightCache *lcache);
bool EEVEE_lightcache_load(struct LightCache *lcache);
void EEVEE_lightcache_info_update(struct SceneEEVEE *eevee);
+
+void EEVEE_lightcache_blend_write(struct BlendWriter *writer, struct LightCache *cache);
+void EEVEE_lightcache_blend_read_data(struct BlendDataReader *reader, struct LightCache *cache);
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index b7112c07cab..b773049f6f7 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -97,7 +97,7 @@ static float light_shape_power_get(const Light *la, const EEVEE_Light *evli)
power *= 4.0f / M_PI;
}
}
- else if (la->type == LA_SPOT || la->type == LA_LOCAL) {
+ else if (ELEM(la->type, LA_SPOT, LA_LOCAL)) {
power = 1.0f / (4.0f * evli->radius * evli->radius * M_PI * M_PI); /* 1/(4*r²*Pi²) */
/* for point lights (a.k.a radius == 0.0) */
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index 710d2c70479..628941f68a2 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -65,7 +65,8 @@ static void eevee_lookdev_hdri_preview_init(EEVEE_Data *vedata, EEVEE_ViewLayerD
Scene *scene = draw_ctx->scene;
DRWShadingGroup *grp;
- struct GPUBatch *sphere = DRW_cache_sphere_get();
+ const EEVEE_EffectsInfo *effects = vedata->stl->effects;
+ struct GPUBatch *sphere = DRW_cache_sphere_get(effects->sphere_lod);
int mat_options = VAR_MAT_MESH | VAR_MAT_LOOKDEV;
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS |
@@ -126,6 +127,19 @@ void EEVEE_lookdev_init(EEVEE_Data *vedata)
if (sphere_size != effects->sphere_size || rect->xmax != effects->anchor[0] ||
rect->ymin != effects->anchor[1]) {
+ /* Make sphere resolution adaptive to viewport_scale, dpi and lookdev_sphere_size */
+ float res_scale = clamp_f(
+ (U.lookdev_sphere_size / 400.0f) * viewport_scale * U.dpi_fac, 0.1f, 1.0f);
+
+ if (res_scale > 0.7f) {
+ effects->sphere_lod = DRW_LOD_HIGH;
+ }
+ else if (res_scale > 0.25f) {
+ effects->sphere_lod = DRW_LOD_MEDIUM;
+ }
+ else {
+ effects->sphere_lod = DRW_LOD_LOW;
+ }
/* If sphere size or anchor point moves, reset TAA to avoid ghosting issue.
* This needs to happen early because we are changing taa_current_sample. */
effects->sphere_size = sphere_size;
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 3b525ba0742..58f182ecf8d 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -881,7 +881,6 @@ void EEVEE_materials_free(void)
}
/* -------------------------------------------------------------------- */
-
/** \name Render Passes
* \{ */
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index fe3705f1fbb..530becfe771 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -521,8 +521,7 @@ void EEVEE_motion_blur_swap_data(EEVEE_Data *vedata)
case EEVEE_MOTION_DATA_MESH:
if (mb_geom->batch != NULL) {
for (int i = 0; i < GPU_BATCH_VBO_MAX_LEN; i++) {
- if (mb_geom->batch->verts[i] == mb_geom->vbo[MB_PREV] ||
- mb_geom->batch->verts[i] == mb_geom->vbo[MB_NEXT]) {
+ if (ELEM(mb_geom->batch->verts[i], mb_geom->vbo[MB_PREV], mb_geom->vbo[MB_NEXT])) {
/* Avoid double reference of the VBOs. */
mb_geom->batch->verts[i] = NULL;
}
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 7d41028195d..f5cef8f3c25 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -734,6 +734,7 @@ typedef struct EEVEE_EffectsInfo {
float prev_persmat[4][4];
/* Lookdev */
int sphere_size;
+ eDRWLevelOfDetail sphere_lod;
int anchor[2];
struct DRWView *lookdev_view;
/* Bloom */
diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c b/source/blender/draw/engines/eevee/eevee_shadows.c
index 2f8eb482882..fa5afd60235 100644
--- a/source/blender/draw/engines/eevee/eevee_shadows.c
+++ b/source/blender/draw/engines/eevee/eevee_shadows.c
@@ -349,7 +349,6 @@ void EEVEE_shadows_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView
}
/* -------------------------------------------------------------------- */
-
/** \name Render Passes
* \{ */
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index 9527c0f47b0..1e75968f1de 100644
--- a/source/blender/draw/engines/eevee/eevee_volumes.c
+++ b/source/blender/draw/engines/eevee/eevee_volumes.c
@@ -453,7 +453,7 @@ static bool eevee_volume_object_mesh_init(Scene *scene,
DRW_shgroup_uniform_texture_ref(
grp, gpu_grid->sampler_name, fds->tex_color ? &fds->tex_color : &e_data.dummy_one);
}
- else if (STREQ(gpu_grid->name, "flame") || STREQ(gpu_grid->name, "temperature")) {
+ else if (STR_ELEM(gpu_grid->name, "flame", "temperature")) {
DRW_shgroup_uniform_texture_ref(
grp, gpu_grid->sampler_name, fds->tex_flame ? &fds->tex_flame : &e_data.dummy_flame);
}
@@ -788,7 +788,6 @@ void EEVEE_volumes_free(void)
}
/* -------------------------------------------------------------------- */
-
/** \name Render Passes
* \{ */
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 948255b3852..f2472699300 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -62,7 +62,7 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob)
tgp_ob->do_mat_holdout = false;
for (int i = 0; i < ob->totcol; i++) {
MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, i + 1);
- if ((gp_style->flag & GP_MATERIAL_IS_STROKE_HOLDOUT) ||
+ if (((gp_style != NULL) && (gp_style->flag & GP_MATERIAL_IS_STROKE_HOLDOUT)) ||
((gp_style->flag & GP_MATERIAL_IS_FILL_HOLDOUT))) {
tgp_ob->do_mat_holdout = true;
break;
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.c b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
index 52b41726276..18ca2e4ccc9 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_data.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
@@ -247,6 +247,10 @@ GPENCIL_MaterialPool *gpencil_material_pool_create(GPENCIL_PrivateData *pd, Obje
gp_style = gpencil_viewport_material_overrides(pd, ob, color_type, gp_style);
+ /* Dots or Squares rotation. */
+ mat_data->alignment_rot_cos = cosf(gp_style->alignment_rotation);
+ mat_data->alignment_rot_sin = sinf(gp_style->alignment_rotation);
+
/* Stroke Style */
if ((gp_style->stroke_style == GP_MATERIAL_STROKE_STYLE_TEXTURE) && (gp_style->sima)) {
bool premul;
@@ -367,7 +371,7 @@ static float light_power_get(const Light *la)
if (la->type == LA_AREA) {
return 1.0f / (4.0f * M_PI);
}
- if (la->type == LA_SPOT || la->type == LA_LOCAL) {
+ if (ELEM(la->type, LA_SPOT, LA_LOCAL)) {
return 1.0f / (4.0f * M_PI * M_PI);
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 0922ab6552c..04128dc157e 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -62,7 +62,7 @@ typedef struct gpMaterial {
float stroke_color[4];
float fill_color[4];
float fill_mix_color[4];
- float fill_uv_transform[3][2], _pad0[2];
+ float fill_uv_transform[3][2], alignment_rot_cos, alignment_rot_sin;
float stroke_texture_mix;
float stroke_u_scale;
float fill_texture_mix;
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
index 5e930af7bd7..94b066c12e5 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
@@ -461,6 +461,14 @@ void stroke_vertex()
float rot_cos = abs(uv_rot);
x_axis = mat2(rot_cos, -rot_sin, rot_sin, rot_cos) * x_axis;
+# ifdef GP_MATERIAL_BUFFER_LEN
+ if (is_dot) {
+ float alignment_cos = MATERIAL(m).fill_uv_offset.z;
+ float alignment_sin = MATERIAL(m).fill_uv_offset.w;
+ x_axis = mat2(alignment_cos, -alignment_sin, alignment_sin, alignment_cos) * x_axis;
+ }
+# endif
+
vec2 y_axis = rotate_90deg(x_axis);
strokeAspect = decode_aspect(aspect1);
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c
index e49b2e45580..5188d338183 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -90,6 +90,7 @@ static void OVERLAY_engine_init(void *vedata)
V3D_OVERLAY_HIDE_BONES | V3D_OVERLAY_HIDE_OBJECT_XTRAS |
V3D_OVERLAY_HIDE_OBJECT_ORIGINS;
pd->overlay.wireframe_threshold = v3d->overlay.wireframe_threshold;
+ pd->overlay.wireframe_opacity = v3d->overlay.wireframe_opacity;
}
if (v3d->shading.type == OB_WIRE) {
diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c
index adb0dc22e16..4ca7ee42f8d 100644
--- a/source/blender/draw/engines/overlay/overlay_extra.c
+++ b/source/blender/draw/engines/overlay/overlay_extra.c
@@ -128,7 +128,7 @@ void OVERLAY_extra_cache_init(OVERLAY_Data *vedata)
cb->empty_plain_axes = BUF_INSTANCE(grp_sub, format, DRW_cache_plain_axes_get());
cb->empty_single_arrow = BUF_INSTANCE(grp_sub, format, DRW_cache_single_arrow_get());
cb->empty_sphere = BUF_INSTANCE(grp_sub, format, DRW_cache_empty_sphere_get());
- cb->empty_sphere_solid = BUF_INSTANCE(grp_sub, format, DRW_cache_sphere_get());
+ cb->empty_sphere_solid = BUF_INSTANCE(grp_sub, format, DRW_cache_sphere_get(DRW_LOD_LOW));
cb->field_cone_limit = BUF_INSTANCE(grp_sub, format, DRW_cache_field_cone_limit_get());
cb->field_curve = BUF_INSTANCE(grp_sub, format, DRW_cache_field_curve_get());
cb->field_force = BUF_INSTANCE(grp_sub, format, DRW_cache_field_force_get());
diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c b/source/blender/draw/engines/overlay/overlay_gpencil.c
index ccc914e0422..7f9290a6c3a 100644
--- a/source/blender/draw/engines/overlay/overlay_gpencil.c
+++ b/source/blender/draw/engines/overlay/overlay_gpencil.c
@@ -49,6 +49,10 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
pd->edit_gpencil_wires_grp = NULL;
psl->edit_gpencil_ps = NULL;
+ pd->edit_gpencil_curve_handle_grp = NULL;
+ pd->edit_gpencil_curve_points_grp = NULL;
+ psl->edit_gpencil_curve_ps = NULL;
+
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
Object *ob = draw_ctx->obact;
@@ -105,7 +109,8 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
(GPENCIL_EDIT_MODE(gpd) &&
(ts->gpencil_selectmode_edit != GP_SELECTMODE_STROKE));
- if ((!GPENCIL_VERTEX_MODE(gpd) && !GPENCIL_PAINT_MODE(gpd)) || use_vertex_mask) {
+ if ((!GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) &&
+ ((!GPENCIL_VERTEX_MODE(gpd) && !GPENCIL_PAINT_MODE(gpd)) || use_vertex_mask)) {
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_BLEND_ALPHA;
DRW_PASS_CREATE(psl->edit_gpencil_ps, state | pd->clipping_state);
@@ -132,6 +137,37 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
}
}
+ /* Handles and curve point for Curve Edit submode. */
+ if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) {
+ DRWState state = DRW_STATE_WRITE_COLOR;
+ DRW_PASS_CREATE(psl->edit_gpencil_curve_ps, state | pd->clipping_state);
+
+ /* Edit lines. */
+ if (show_lines) {
+ sh = OVERLAY_shader_edit_gpencil_wire();
+ pd->edit_gpencil_wires_grp = grp = DRW_shgroup_create(sh, psl->edit_gpencil_curve_ps);
+ DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
+ DRW_shgroup_uniform_bool_copy(grp, "doMultiframe", show_multi_edit_lines);
+ DRW_shgroup_uniform_bool_copy(grp, "doWeightColor", is_weight_paint);
+ DRW_shgroup_uniform_bool_copy(grp, "hideSelect", hide_select);
+ DRW_shgroup_uniform_float_copy(grp, "gpEditOpacity", v3d->vertex_opacity);
+ DRW_shgroup_uniform_texture(grp, "weightTex", G_draw.weight_ramp);
+ }
+
+ sh = OVERLAY_shader_edit_curve_handle();
+ pd->edit_gpencil_curve_handle_grp = grp = DRW_shgroup_create(sh, psl->edit_gpencil_curve_ps);
+ DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
+ DRW_shgroup_uniform_bool_copy(grp, "showCurveHandles", pd->edit_curve.show_handles);
+ DRW_shgroup_uniform_int_copy(grp, "curveHandleDisplay", pd->edit_curve.handle_display);
+ DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ALPHA);
+
+ sh = OVERLAY_shader_edit_curve_point();
+ pd->edit_gpencil_curve_points_grp = grp = DRW_shgroup_create(sh, psl->edit_gpencil_curve_ps);
+ DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
+ DRW_shgroup_uniform_bool_copy(grp, "showCurveHandles", pd->edit_curve.show_handles);
+ DRW_shgroup_uniform_int_copy(grp, "curveHandleDisplay", pd->edit_curve.handle_display);
+ }
+
/* control points for primitives and speed guide */
const bool is_cppoint = (gpd->runtime.tot_cp_points > 0);
const bool is_speed_guide = (ts->gp_sculpt.guide.use_guide &&
@@ -182,6 +218,7 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata)
{
OVERLAY_PassList *psl = vedata->psl;
+ OVERLAY_PrivateData *pd = vedata->stl->pd;
struct GPUShader *sh;
DRWShadingGroup *grp;
@@ -196,6 +233,9 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata)
ToolSettings *ts = scene->toolsettings;
const View3DCursor *cursor = &scene->cursor;
+ pd->edit_curve.show_handles = v3d->overlay.handle_display != CURVE_HANDLE_NONE;
+ pd->edit_curve.handle_display = v3d->overlay.handle_display;
+
if (gpd == NULL || ob->type != OB_GPENCIL) {
return;
}
@@ -303,6 +343,20 @@ static void OVERLAY_edit_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob
struct GPUBatch *geom = DRW_cache_gpencil_edit_points_get(ob, pd->cfra);
DRW_shgroup_call_no_cull(grp, geom, ob);
}
+
+ if (pd->edit_gpencil_curve_handle_grp) {
+ struct GPUBatch *geom = DRW_cache_gpencil_edit_curve_handles_get(ob, pd->cfra);
+ if (geom) {
+ DRW_shgroup_call_no_cull(pd->edit_gpencil_curve_handle_grp, geom, ob);
+ }
+ }
+
+ if (pd->edit_gpencil_curve_points_grp) {
+ struct GPUBatch *geom = DRW_cache_gpencil_edit_curve_points_get(ob, pd->cfra);
+ if (geom) {
+ DRW_shgroup_call_no_cull(pd->edit_gpencil_curve_points_grp, geom, ob);
+ }
+ }
}
static void overlay_gpencil_draw_stroke_color_name(bGPDlayer *UNUSED(gpl),
@@ -407,4 +461,9 @@ void OVERLAY_edit_gpencil_draw(OVERLAY_Data *vedata)
if (psl->edit_gpencil_ps) {
DRW_draw_pass(psl->edit_gpencil_ps);
}
+
+ /* Curve edit handles. */
+ if (psl->edit_gpencil_curve_ps) {
+ DRW_draw_pass(psl->edit_gpencil_curve_ps);
+ }
}
diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.c
index 9695f8616a5..844a0eb8351 100644
--- a/source/blender/draw/engines/overlay/overlay_image.c
+++ b/source/blender/draw/engines/overlay/overlay_image.c
@@ -346,9 +346,9 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob)
mul_m4_m4m4(mat, modelmat, mat);
const bool is_foreground = (bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != 0;
- /* Alpha is clamped just below 1.0 to fix background images to intefere with foreground
+ /* Alpha is clamped just below 1.0 to fix background images to interfere with foreground
* images. Without this a background image with 1.0 will be rendered on top of a transparent
- * foreground image due to the differnet blending modes they use. */
+ * foreground image due to the different blending modes they use. */
const float color_premult_alpha[4] = {1.0f, 1.0f, 1.0f, MIN2(bgpic->alpha, 0.999999)};
DRWPass *pass = is_foreground ? (use_view_transform ? psl->image_foreground_scene_ps :
diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h
index d5ba0a5423f..b9d591a5642 100644
--- a/source/blender/draw/engines/overlay/overlay_private.h
+++ b/source/blender/draw/engines/overlay/overlay_private.h
@@ -77,6 +77,7 @@ typedef struct OVERLAY_PassList {
DRWPass *edit_curve_handle_ps;
DRWPass *edit_gpencil_ps;
DRWPass *edit_gpencil_gizmos_ps;
+ DRWPass *edit_gpencil_curve_ps;
DRWPass *edit_lattice_ps;
DRWPass *edit_mesh_depth_ps[2];
DRWPass *edit_mesh_verts_ps[2];
@@ -140,6 +141,7 @@ typedef struct OVERLAY_ShadingData {
int zneg_flag;
/** Wireframe */
float wire_step_param;
+ float wire_opacity;
/** Edit Curve */
float edit_curve_normal_length;
/** Edit Mesh */
@@ -251,6 +253,8 @@ typedef struct OVERLAY_PrivateData {
DRWShadingGroup *edit_lattice_wires_grp;
DRWShadingGroup *edit_gpencil_points_grp;
DRWShadingGroup *edit_gpencil_wires_grp;
+ DRWShadingGroup *edit_gpencil_curve_handle_grp;
+ DRWShadingGroup *edit_gpencil_curve_points_grp;
DRWShadingGroup *edit_mesh_depth_grp[2];
DRWShadingGroup *edit_mesh_faces_grp[2];
DRWShadingGroup *edit_mesh_faces_cage_grp[2];
diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.c b/source/blender/draw/engines/overlay/overlay_wireframe.c
index 7d2939d101e..617dda56421 100644
--- a/source/blender/draw/engines/overlay/overlay_wireframe.c
+++ b/source/blender/draw/engines/overlay/overlay_wireframe.c
@@ -62,6 +62,7 @@ void OVERLAY_wireframe_cache_init(OVERLAY_Data *vedata)
View3DShading *shading = &draw_ctx->v3d->shading;
pd->shdata.wire_step_param = pd->overlay.wireframe_threshold - 254.0f / 255.0f;
+ pd->shdata.wire_opacity = pd->overlay.wireframe_opacity;
bool is_wire_shmode = (shading->type == OB_WIRE);
bool is_material_shmode = (shading->type > OB_SOLID);
@@ -95,6 +96,7 @@ void OVERLAY_wireframe_cache_init(OVERLAY_Data *vedata)
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_texture_ref(grp, "depthTex", depth_tx);
DRW_shgroup_uniform_float_copy(grp, "wireStepParam", pd->shdata.wire_step_param);
+ DRW_shgroup_uniform_float_copy(grp, "wireOpacity", pd->shdata.wire_opacity);
DRW_shgroup_uniform_bool_copy(grp, "useColoring", use_coloring);
DRW_shgroup_uniform_bool_copy(grp, "isTransform", (G.moving & G_TRANSFORM_OBJ) != 0);
DRW_shgroup_uniform_bool_copy(grp, "isObjectColor", is_object_color);
diff --git a/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl b/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl
index 9311542a79e..442f69aec7e 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl
@@ -53,6 +53,9 @@ void main()
bool edge_selected = (((vertFlag[1] | vertFlag[0]) & VERT_SELECTED) != 0);
bool handle_selected = (showCurveHandles &&
(((vertFlag[1] | vertFlag[0]) & VERT_SELECTED_BEZT_HANDLE) != 0));
+ /* It reuses freestyle flag because the flag is 8 bits and all are already used and this
+ * flag is not used in this context. */
+ bool is_gpencil = ((vertFlag[1] & EDGE_FREESTYLE) != 0);
/* If handle type is only selected and the edge is not selected, don't show. */
if ((curveHandleDisplay != CURVE_HANDLE_ALL) && (!handle_selected)) {
@@ -61,6 +64,9 @@ void main()
if ((!is_u_segment) && (color_id <= 4)) {
return;
}
+ if (is_gpencil) {
+ return;
+ }
}
vec4 inner_color;
diff --git a/source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl
index a811fcca0d4..6b4edbfe578 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl
@@ -17,16 +17,17 @@ void main()
{
GPU_INTEL_VERTEX_SHADER_WORKAROUND
+ /* Reuse the FREESTYLE flag to determine is GPencil. */
if ((data & VERT_SELECTED) != 0) {
if ((data & VERT_ACTIVE) != 0) {
finalColor = colorEditMeshActive;
}
else {
- finalColor = colorVertexSelect;
+ finalColor = ((data & EDGE_FREESTYLE) == 0) ? colorVertexSelect : colorGpencilVertexSelect;
}
}
else {
- finalColor = colorVertex;
+ finalColor = ((data & EDGE_FREESTYLE) == 0) ? colorVertex : colorGpencilVertex;
}
vec3 world_pos = point_object_to_world(pos);
diff --git a/source/blender/draw/engines/overlay/shaders/wireframe_frag.glsl b/source/blender/draw/engines/overlay/shaders/wireframe_frag.glsl
index b5442dc1b0b..5c8c22c57d9 100644
--- a/source/blender/draw/engines/overlay/shaders/wireframe_frag.glsl
+++ b/source/blender/draw/engines/overlay/shaders/wireframe_frag.glsl
@@ -5,7 +5,7 @@ uniform sampler2D depthTex;
flat in vec2 edgeStart;
#ifndef SELECT_EDGES
-in vec3 finalColor;
+in vec4 finalColor;
noperspective in vec2 edgePos;
layout(location = 0) out vec4 fragColor;
@@ -22,8 +22,7 @@ void main()
#ifndef SELECT_EDGES
lineOutput = pack_line_data(gl_FragCoord.xy, edgeStart, edgePos);
- fragColor.rgb = finalColor;
- fragColor.a = 1.0;
+ fragColor = finalColor;
# ifdef CUSTOM_DEPTH_BIAS
vec2 dir = lineOutput.xy * 2.0 - 1.0;
diff --git a/source/blender/draw/engines/overlay/shaders/wireframe_vert.glsl b/source/blender/draw/engines/overlay/shaders/wireframe_vert.glsl
index f7467aa3bf4..c80d8f99628 100644
--- a/source/blender/draw/engines/overlay/shaders/wireframe_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/wireframe_vert.glsl
@@ -1,5 +1,6 @@
uniform float wireStepParam;
+uniform float wireOpacity;
uniform bool useColoring;
uniform bool isTransform;
uniform bool isObjectColor;
@@ -14,7 +15,7 @@ in float wd; /* wiredata */
flat out vec2 edgeStart;
#ifndef SELECT_EDGES
-out vec3 finalColor;
+out vec4 finalColor;
noperspective out vec2 edgePos;
#endif
@@ -156,8 +157,10 @@ void main()
rim_col = pow(rim_col, vec3(1.0 / 2.2));
wire_col = pow(wire_col, vec3(1.0 / 2.2));
vec3 final_front_col = mix(rim_col, wire_col, 0.35);
- finalColor = mix(rim_col, final_front_col, facing);
- finalColor = pow(finalColor, vec3(2.2));
+ finalColor.rgb = mix(rim_col, final_front_col, facing);
+ finalColor.rgb = pow(finalColor.rgb, vec3(2.2));
+ finalColor.a = wireOpacity;
+ finalColor.rgb *= wireOpacity;
#endif
/* Cull flat edges below threshold. */
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 336e6e75659..fbe71900915 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -349,7 +349,6 @@ typedef enum {
DRW_STATE_LOGIC_INVERT = (10 << 11),
DRW_STATE_BLEND_ALPHA_UNDER_PREMUL = (11 << 11),
-
DRW_STATE_IN_FRONT_SELECT = (1 << 27),
DRW_STATE_SHADOW_OFFSET = (1 << 28),
DRW_STATE_CLIP_PLANES = (1 << 29),
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 52e7e91a995..921164c73a7 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -66,6 +66,17 @@
#define VCLASS_EMPTY_AXES_SHADOW (1 << 13)
#define VCLASS_EMPTY_SIZE (1 << 14)
+/* Sphere shape resolution */
+/* Low */
+#define DRW_SPHERE_SHAPE_LATITUDE_LOW 32
+#define DRW_SPHERE_SHAPE_LONGITUDE_LOW 24
+/* Medium */
+#define DRW_SPHERE_SHAPE_LATITUDE_MEDIUM 64
+#define DRW_SPHERE_SHAPE_LONGITUDE_MEDIUM 48
+/* High */
+#define DRW_SPHERE_SHAPE_LATITUDE_HIGH 80
+#define DRW_SPHERE_SHAPE_LONGITUDE_HIGH 60
+
typedef struct Vert {
float pos[3];
int class;
@@ -88,7 +99,6 @@ static struct DRWShapeCache {
GPUBatch *drw_quad;
GPUBatch *drw_quad_wires;
GPUBatch *drw_grid;
- GPUBatch *drw_sphere;
GPUBatch *drw_plain_axes;
GPUBatch *drw_single_arrow;
GPUBatch *drw_cube;
@@ -140,6 +150,7 @@ static struct DRWShapeCache {
GPUBatch *drw_particle_circle;
GPUBatch *drw_particle_axis;
GPUBatch *drw_gpencil_dummy_quad;
+ GPUBatch *drw_sphere_lod[DRW_LOD_MAX];
} SHC = {NULL};
void DRW_shape_cache_free(void)
@@ -473,11 +484,30 @@ static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lo
(*v_ofs)++;
}
-GPUBatch *DRW_cache_sphere_get(void)
+GPUBatch *DRW_cache_sphere_get(const eDRWLevelOfDetail level_of_detail)
{
- if (!SHC.drw_sphere) {
- const int lat_res = 32;
- const int lon_res = 24;
+ BLI_assert(level_of_detail >= DRW_LOD_LOW && level_of_detail < DRW_LOD_MAX);
+
+ if (!SHC.drw_sphere_lod[level_of_detail]) {
+ int lat_res;
+ int lon_res;
+
+ switch (level_of_detail) {
+ case DRW_LOD_LOW:
+ lat_res = DRW_SPHERE_SHAPE_LATITUDE_LOW;
+ lon_res = DRW_SPHERE_SHAPE_LONGITUDE_LOW;
+ break;
+ case DRW_LOD_MEDIUM:
+ lat_res = DRW_SPHERE_SHAPE_LATITUDE_MEDIUM;
+ lon_res = DRW_SPHERE_SHAPE_LONGITUDE_MEDIUM;
+ break;
+ case DRW_LOD_HIGH:
+ lat_res = DRW_SPHERE_SHAPE_LATITUDE_HIGH;
+ lon_res = DRW_SPHERE_SHAPE_LONGITUDE_HIGH;
+ break;
+ default:
+ return NULL;
+ }
GPUVertFormat format = extra_vert_format();
GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
@@ -508,9 +538,10 @@ GPUBatch *DRW_cache_sphere_get(void)
}
}
- SHC.drw_sphere = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO);
+ SHC.drw_sphere_lod[level_of_detail] = GPU_batch_create_ex(
+ GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
- return SHC.drw_sphere;
+ return SHC.drw_sphere_lod[level_of_detail];
}
/** \} */
@@ -1694,8 +1725,8 @@ GPUBatch *DRW_cache_speaker_get(void)
copy_v3_fl3(v, r, 0.0f, z);
GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
for (int i = 1; i < segments; i++) {
- float x = cosf(2.f * (float)M_PI * i / segments) * r;
- float y = sinf(2.f * (float)M_PI * i / segments) * r;
+ float x = cosf(2.0f * (float)M_PI * i / segments) * r;
+ float y = sinf(2.0f * (float)M_PI * i / segments) * r;
copy_v3_fl3(v, x, y, z);
GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
@@ -2389,7 +2420,7 @@ GPUBatch *DRW_cache_bone_stick_get(void)
/* Bone rectangle */
pos[0] = 0.0f;
for (int i = 0; i < 6; i++) {
- pos[1] = (i == 0 || i == 3) ? 0.0f : ((i < 3) ? 1.0f : -1.0f);
+ pos[1] = (ELEM(i, 0, 3)) ? 0.0f : ((i < 3) ? 1.0f : -1.0f);
flag = ((i < 2 || i > 4) ? POS_HEAD : POS_TAIL) | ((i == 0 || i == 3) ? 0 : COL_WIRE) |
COL_BONE | POS_BONE;
GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
@@ -2463,14 +2494,14 @@ static float axis_marker[8][2] = {
{-1.0f * S_X, -1.0f * S_Y},
{-1.0f * S_X, 1.0f * S_Y}
#else /* diamond */
- {-S_X, 0.f},
- {0.f, S_Y},
- {0.f, S_Y},
- {S_X, 0.f},
- {S_X, 0.f},
- {0.f, -S_Y},
- {0.f, -S_Y},
- {-S_X, 0.f}
+ {-S_X, 0.0f},
+ {0.0f, S_Y},
+ {0.0f, S_Y},
+ {S_X, 0.0f},
+ {S_X, 0.0f},
+ {0.0f, -S_Y},
+ {0.0f, -S_Y},
+ {-S_X, 0.0f}
#endif
};
#define MARKER_LEN (sizeof(axis_marker) / (sizeof(float[2])))
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index 5da9f4b7964..9fd7ffd4692 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -32,6 +32,15 @@ struct Volume;
struct VolumeGrid;
struct bGPDstroke;
+/* Shape resolution level of detail */
+typedef enum eDRWLevelOfDetail {
+ DRW_LOD_LOW = 0,
+ DRW_LOD_MEDIUM = 1,
+ DRW_LOD_HIGH = 2,
+
+ DRW_LOD_MAX, /* Max number of level of detail */
+} eDRWLevelOfDetail;
+
void DRW_shape_cache_free(void);
/* 3D cursor */
@@ -44,9 +53,10 @@ struct GPUBatch *DRW_cache_fullscreen_quad_get(void);
struct GPUBatch *DRW_cache_quad_get(void);
struct GPUBatch *DRW_cache_quad_wires_get(void);
struct GPUBatch *DRW_cache_cube_get(void);
-struct GPUBatch *DRW_cache_sphere_get(void);
struct GPUBatch *DRW_cache_normal_arrow_get(void);
+struct GPUBatch *DRW_cache_sphere_get(const eDRWLevelOfDetail level_of_detail);
+
/* Dummy VBOs */
struct GPUBatch *DRW_gpencil_dummy_buffer_get(void);
@@ -243,6 +253,8 @@ struct GPUBatch *DRW_cache_gpencil_strokes_get(struct Object *ob, int cfra);
struct GPUBatch *DRW_cache_gpencil_fills_get(struct Object *ob, int cfra);
struct GPUBatch *DRW_cache_gpencil_edit_lines_get(struct Object *ob, int cfra);
struct GPUBatch *DRW_cache_gpencil_edit_points_get(struct Object *ob, int cfra);
+struct GPUBatch *DRW_cache_gpencil_edit_curve_handles_get(struct Object *ob, int cfra);
+struct GPUBatch *DRW_cache_gpencil_edit_curve_points_get(struct Object *ob, int cfra);
struct GPUBatch *DRW_cache_gpencil_sbuffer_stroke_get(struct Object *ob);
struct GPUBatch *DRW_cache_gpencil_sbuffer_fill_get(struct Object *ob);
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c
index ce3a89ae45c..7766ce906b8 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -2804,8 +2804,6 @@ static void *extract_vcol_init(const MeshRenderData *mr, struct MeshBatchCache *
vcol_data->a = unit_float_to_ushort_clamp(vcol[loops[ml_index].v].color[3]);
}
}
-
- vcol_data += mr->loop_len;
}
}
return NULL;
diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c b/source/blender/draw/intern/draw_cache_impl_gpencil.c
index 220c7041c7f..4e809ad45fe 100644
--- a/source/blender/draw/intern/draw_cache_impl_gpencil.c
+++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c
@@ -21,6 +21,7 @@
* \ingroup draw
*/
+#include "DNA_curve_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_screen_types.h"
@@ -43,6 +44,9 @@
#include "draw_cache.h"
#include "draw_cache_impl.h"
+#define BEZIER_HANDLE 1 << 3
+#define COLOR_SHIFT 5
+
/* ---------------------------------------------------------------------- */
typedef struct GpencilBatchCache {
/** Instancing Data */
@@ -59,6 +63,10 @@ typedef struct GpencilBatchCache {
GPUVertBuf *edit_vbo;
GPUBatch *edit_lines_batch;
GPUBatch *edit_points_batch;
+ /** Edit Curve Mode */
+ GPUVertBuf *edit_curve_vbo;
+ GPUBatch *edit_curve_handles_batch;
+ GPUBatch *edit_curve_points_batch;
/** Cache is dirty */
bool is_dirty;
@@ -123,6 +131,10 @@ static void gpencil_batch_cache_clear(GpencilBatchCache *cache)
GPU_BATCH_DISCARD_SAFE(cache->edit_points_batch);
GPU_VERTBUF_DISCARD_SAFE(cache->edit_vbo);
+ GPU_BATCH_DISCARD_SAFE(cache->edit_curve_handles_batch);
+ GPU_BATCH_DISCARD_SAFE(cache->edit_curve_points_batch);
+ GPU_VERTBUF_DISCARD_SAFE(cache->edit_curve_vbo);
+
cache->is_dirty = true;
}
@@ -197,6 +209,23 @@ static GPUVertFormat *gpencil_edit_stroke_format(void)
}
/* MUST match the format below. */
+typedef struct gpEditCurveVert {
+ float pos[3];
+ int data;
+} gpEditCurveVert;
+
+static GPUVertFormat *gpencil_edit_curve_format(void)
+{
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ /* initialize vertex formats */
+ GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT);
+ }
+ return &format;
+}
+
+/* MUST match the format below. */
typedef struct gpColorVert {
float vcol[4]; /* Vertex color */
float fcol[4]; /* Fill color */
@@ -228,6 +257,7 @@ typedef struct gpIterData {
GPUIndexBufBuilder ibo;
int vert_len;
int tri_len;
+ int curve_len;
} gpIterData;
static GPUVertBuf *gpencil_dummy_buffer_get(void)
@@ -383,6 +413,7 @@ static void gpencil_batches_ensure(Object *ob, GpencilBatchCache *cache, int cfr
.ibo = {0},
.vert_len = 1, /* Start at 1 for the gl_InstanceID trick to work (see vert shader). */
.tri_len = 0,
+ .curve_len = 0,
};
BKE_gpencil_visible_stroke_iter(
NULL, ob, NULL, gpencil_object_verts_count_cb, &iter, do_onion, cfra);
@@ -653,6 +684,11 @@ typedef struct gpEditIterData {
int vgindex;
} gpEditIterData;
+typedef struct gpEditCurveIterData {
+ gpEditCurveVert *verts;
+ int vgindex;
+} gpEditCurveIterData;
+
static uint32_t gpencil_point_edit_flag(const bool layer_lock,
const bGPDspoint *pt,
int v,
@@ -698,6 +734,92 @@ static void gpencil_edit_stroke_iter_cb(bGPDlayer *gpl,
vert_ptr->weight = gpencil_point_edit_weight(dvert, 0, iter->vgindex);
}
+static void gpencil_edit_curve_stroke_count_cb(bGPDlayer *gpl,
+ bGPDframe *UNUSED(gpf),
+ bGPDstroke *gps,
+ void *thunk)
+{
+ if (gpl->flag & GP_LAYER_LOCKED) {
+ return;
+ }
+
+ gpIterData *iter = (gpIterData *)thunk;
+
+ if (gps->editcurve == NULL) {
+ return;
+ }
+
+ /* Store first index offset */
+ gps->runtime.curve_start = iter->curve_len;
+ iter->curve_len += gps->editcurve->tot_curve_points * 4;
+}
+
+static char gpencil_beztriple_vflag_get(char flag,
+ char col_id,
+ bool handle_point,
+ const bool handle_selected)
+{
+ char vflag = 0;
+ SET_FLAG_FROM_TEST(vflag, (flag & SELECT), VFLAG_VERT_SELECTED);
+ SET_FLAG_FROM_TEST(vflag, handle_point, BEZIER_HANDLE);
+ SET_FLAG_FROM_TEST(vflag, handle_selected, VFLAG_VERT_SELECTED_BEZT_HANDLE);
+ /* Reuse flag of Freestyle to indicate is GPencil data. */
+ vflag |= VFLAG_EDGE_FREESTYLE;
+
+ /* Handle color id. */
+ vflag |= col_id << COLOR_SHIFT;
+ return vflag;
+}
+
+static void gpencil_edit_curve_stroke_iter_cb(bGPDlayer *gpl,
+ bGPDframe *UNUSED(gpf),
+ bGPDstroke *gps,
+ void *thunk)
+{
+ if (gpl->flag & GP_LAYER_LOCKED) {
+ return;
+ }
+
+ if (gps->editcurve == NULL) {
+ return;
+ }
+ bGPDcurve *editcurve = gps->editcurve;
+ gpEditCurveIterData *iter = (gpEditCurveIterData *)thunk;
+ const int v = gps->runtime.curve_start;
+ gpEditCurveVert *vert_ptr = iter->verts + v;
+ /* Hide points when the curve is unselected. Passing the control point
+ * as handle produces the point shader skip it if you are not in ALL mode. */
+ const bool hide = !(editcurve->flag & GP_CURVE_SELECT);
+
+ for (int i = 0; i < editcurve->tot_curve_points; i++) {
+ BezTriple *bezt = &editcurve->curve_points[i].bezt;
+ const bool handle_selected = BEZT_ISSEL_ANY(bezt);
+ const char vflag[3] = {
+ gpencil_beztriple_vflag_get(bezt->f1, bezt->h1, true, handle_selected),
+ gpencil_beztriple_vflag_get(bezt->f2, bezt->h1, hide, handle_selected),
+ gpencil_beztriple_vflag_get(bezt->f3, bezt->h2, true, handle_selected),
+ };
+
+ /* First segment. */
+ copy_v3_v3(vert_ptr->pos, bezt->vec[0]);
+ vert_ptr->data = vflag[0];
+ vert_ptr++;
+
+ copy_v3_v3(vert_ptr->pos, bezt->vec[1]);
+ vert_ptr->data = vflag[1];
+ vert_ptr++;
+
+ /* Second segment. */
+ copy_v3_v3(vert_ptr->pos, bezt->vec[1]);
+ vert_ptr->data = vflag[1];
+ vert_ptr++;
+
+ copy_v3_v3(vert_ptr->pos, bezt->vec[2]);
+ vert_ptr->data = vflag[2];
+ vert_ptr++;
+ }
+}
+
static void gpencil_edit_batches_ensure(Object *ob, GpencilBatchCache *cache, int cfra)
{
bGPdata *gpd = (bGPdata *)ob->data;
@@ -737,6 +859,46 @@ static void gpencil_edit_batches_ensure(Object *ob, GpencilBatchCache *cache, in
cache->edit_lines_batch = GPU_batch_create(GPU_PRIM_LINE_STRIP, cache->vbo, NULL);
GPU_batch_vertbuf_add(cache->edit_lines_batch, cache->edit_vbo);
+ }
+
+ /* Curve Handles and Points for Editing. */
+ if (cache->edit_curve_vbo == NULL) {
+ gpIterData iterdata = {
+ .gpd = gpd,
+ .verts = NULL,
+ .ibo = {0},
+ .vert_len = 0,
+ .tri_len = 0,
+ .curve_len = 0,
+ };
+
+ /* Create VBO. */
+ GPUVertFormat *format = gpencil_edit_curve_format();
+ cache->edit_curve_vbo = GPU_vertbuf_create_with_format(format);
+
+ /* Count data. */
+ BKE_gpencil_visible_stroke_iter(
+ NULL, ob, NULL, gpencil_edit_curve_stroke_count_cb, &iterdata, false, cfra);
+
+ gpEditCurveIterData iter;
+ int vert_len = iterdata.curve_len;
+ if (vert_len > 0) {
+
+ GPU_vertbuf_data_alloc(cache->edit_curve_vbo, vert_len);
+ iter.verts = (gpEditCurveVert *)GPU_vertbuf_get_data(cache->edit_curve_vbo);
+
+ /* Fill buffers with data. */
+ BKE_gpencil_visible_stroke_iter(
+ NULL, ob, NULL, gpencil_edit_curve_stroke_iter_cb, &iter, false, cfra);
+
+ cache->edit_curve_handles_batch = GPU_batch_create(
+ GPU_PRIM_LINES, cache->edit_curve_vbo, NULL);
+ GPU_batch_vertbuf_add(cache->edit_curve_handles_batch, cache->edit_curve_vbo);
+
+ cache->edit_curve_points_batch = GPU_batch_create(
+ GPU_PRIM_POINTS, cache->edit_curve_vbo, NULL);
+ GPU_batch_vertbuf_add(cache->edit_curve_points_batch, cache->edit_curve_vbo);
+ }
gpd->flag &= ~GP_DATA_CACHE_IS_DIRTY;
cache->is_dirty = false;
@@ -761,4 +923,22 @@ GPUBatch *DRW_cache_gpencil_edit_points_get(Object *ob, int cfra)
return cache->edit_points_batch;
}
+GPUBatch *DRW_cache_gpencil_edit_curve_handles_get(Object *ob, int cfra)
+{
+ GpencilBatchCache *cache = gpencil_batch_cache_get(ob, cfra);
+ gpencil_batches_ensure(ob, cache, cfra);
+ gpencil_edit_batches_ensure(ob, cache, cfra);
+
+ return cache->edit_curve_handles_batch;
+}
+
+GPUBatch *DRW_cache_gpencil_edit_curve_points_get(Object *ob, int cfra)
+{
+ GpencilBatchCache *cache = gpencil_batch_cache_get(ob, cfra);
+ gpencil_batches_ensure(ob, cache, cfra);
+ gpencil_edit_batches_ensure(ob, cache, cfra);
+
+ return cache->edit_curve_points_batch;
+}
+
/** \} */
diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c
index 0f80b5159a7..e6c7341759b 100644
--- a/source/blender/draw/intern/draw_cache_impl_lattice.c
+++ b/source/blender/draw/intern/draw_cache_impl_lattice.c
@@ -389,11 +389,11 @@ static GPUIndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata,
#define LATT_INDEX(u, v, w) ((((w)*rdata->dims.v_len + (v)) * rdata->dims.u_len) + (u))
for (int w = 0; w < rdata->dims.w_len; w++) {
- int wxt = (w == 0 || w == rdata->dims.w_len - 1);
+ int wxt = (ELEM(w, 0, rdata->dims.w_len - 1));
for (int v = 0; v < rdata->dims.v_len; v++) {
- int vxt = (v == 0 || v == rdata->dims.v_len - 1);
+ int vxt = (ELEM(v, 0, rdata->dims.v_len - 1));
for (int u = 0; u < rdata->dims.u_len; u++) {
- int uxt = (u == 0 || u == rdata->dims.u_len - 1);
+ int uxt = (ELEM(u, 0, rdata->dims.u_len - 1));
if (w && ((uxt || vxt) || !rdata->show_only_outside)) {
GPU_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v, w - 1), LATT_INDEX(u, v, w));
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 52d1fcfdb80..75685c7e2f0 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -301,12 +301,12 @@ static void particle_calculate_parent_uvs(ParticleSystem *psys,
}
ParticleData *particle = &psys->particles[parent_index];
int num = particle->num_dmcache;
- if (num == DMCACHE_NOTFOUND || num == DMCACHE_ISCHILD) {
+ if (ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
if (particle->num < psmd->mesh_final->totface) {
num = particle->num;
}
}
- if (num != DMCACHE_NOTFOUND && num != DMCACHE_ISCHILD) {
+ if (!ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
MFace *mface = &psmd->mesh_final->mface[num];
for (int j = 0; j < num_uv_layers; j++) {
psys_interpolate_uvs(mtfaces[j] + num, mface->v4, particle->fuv, r_uv[j]);
@@ -330,12 +330,12 @@ static void particle_calculate_parent_mcol(ParticleSystem *psys,
}
ParticleData *particle = &psys->particles[parent_index];
int num = particle->num_dmcache;
- if (num == DMCACHE_NOTFOUND || num == DMCACHE_ISCHILD) {
+ if (ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
if (particle->num < psmd->mesh_final->totface) {
num = particle->num;
}
}
- if (num != DMCACHE_NOTFOUND && num != DMCACHE_ISCHILD) {
+ if (!ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
MFace *mface = &psmd->mesh_final->mface[num];
for (int j = 0; j < num_col_layers; j++) {
/* CustomDataLayer CD_MCOL has 4 structs per face. */
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index 4050a5f8b69..f1598ea2fff 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -30,9 +30,20 @@
*/
#include "draw_instance_data.h"
+#include "draw_manager.h"
+
#include "DRW_engine.h"
#include "DRW_render.h" /* For DRW_shgroup_get_instance_count() */
+#include "GPU_material.h"
+
+#include "DNA_particle_types.h"
+
+#include "BKE_duplilist.h"
+
+#include "RNA_access.h"
+
+#include "BLI_bitmap.h"
#include "BLI_memblock.h"
#include "BLI_mempool.h"
#include "BLI_utildefines.h"
@@ -408,3 +419,362 @@ void DRW_instance_data_list_resize(DRWInstanceDataList *idatalist)
}
/** \} */
+/* -------------------------------------------------------------------- */
+/** \name Sparse Uniform Buffer
+ * \{ */
+
+#define CHUNK_LIST_STEP (1 << 4)
+
+/** A chunked UBO manager that doesn't actually allocate unneeded chunks. */
+typedef struct DRWSparseUniformBuf {
+ /* Memory buffers used to stage chunk data before transfer to UBOs. */
+ char **chunk_buffers;
+ /* Uniform buffer objects with flushed data. */
+ struct GPUUniformBuf **chunk_ubos;
+ /* True if the relevant chunk contains data (distinct from simply being allocated). */
+ BLI_bitmap *chunk_used;
+
+ int num_chunks;
+ unsigned int item_size, chunk_size, chunk_bytes;
+} DRWSparseUniformBuf;
+
+static void drw_sparse_uniform_buffer_init(DRWSparseUniformBuf *buffer,
+ unsigned int item_size,
+ unsigned int chunk_size)
+{
+ buffer->chunk_buffers = NULL;
+ buffer->chunk_used = NULL;
+ buffer->chunk_ubos = NULL;
+ buffer->num_chunks = 0;
+ buffer->item_size = item_size;
+ buffer->chunk_size = chunk_size;
+ buffer->chunk_bytes = item_size * chunk_size;
+}
+
+/** Allocate a chunked UBO with the specified item and chunk size. */
+DRWSparseUniformBuf *DRW_sparse_uniform_buffer_new(unsigned int item_size, unsigned int chunk_size)
+{
+ DRWSparseUniformBuf *buf = MEM_mallocN(sizeof(DRWSparseUniformBuf), __func__);
+ drw_sparse_uniform_buffer_init(buf, item_size, chunk_size);
+ return buf;
+}
+
+/** Flush data from ordinary memory to UBOs. */
+void DRW_sparse_uniform_buffer_flush(DRWSparseUniformBuf *buffer)
+{
+ for (int i = 0; i < buffer->num_chunks; i++) {
+ if (BLI_BITMAP_TEST(buffer->chunk_used, i)) {
+ if (buffer->chunk_ubos[i] == NULL) {
+ buffer->chunk_ubos[i] = GPU_uniformbuf_create(buffer->chunk_bytes);
+ }
+ GPU_uniformbuf_update(buffer->chunk_ubos[i], buffer->chunk_buffers[i]);
+ }
+ }
+}
+
+/** Clean all buffers and free unused ones. */
+void DRW_sparse_uniform_buffer_clear(DRWSparseUniformBuf *buffer, bool free_all)
+{
+ int max_used_chunk = 0;
+
+ for (int i = 0; i < buffer->num_chunks; i++) {
+ /* Delete buffers that were not used since the last clear call. */
+ if (free_all || !BLI_BITMAP_TEST(buffer->chunk_used, i)) {
+ MEM_SAFE_FREE(buffer->chunk_buffers[i]);
+
+ if (buffer->chunk_ubos[i]) {
+ GPU_uniformbuf_free(buffer->chunk_ubos[i]);
+ buffer->chunk_ubos[i] = NULL;
+ }
+ }
+ else {
+ max_used_chunk = i + 1;
+ }
+ }
+
+ /* Shrink the chunk array if appropriate. */
+ const int old_num_chunks = buffer->num_chunks;
+
+ buffer->num_chunks = (max_used_chunk + CHUNK_LIST_STEP - 1) & ~(CHUNK_LIST_STEP - 1);
+
+ if (buffer->num_chunks == 0) {
+ /* Ensure that an empty pool holds no memory allocations. */
+ MEM_SAFE_FREE(buffer->chunk_buffers);
+ MEM_SAFE_FREE(buffer->chunk_used);
+ MEM_SAFE_FREE(buffer->chunk_ubos);
+ return;
+ }
+
+ if (buffer->num_chunks != old_num_chunks) {
+ buffer->chunk_buffers = MEM_recallocN(buffer->chunk_buffers,
+ buffer->num_chunks * sizeof(void *));
+ buffer->chunk_ubos = MEM_recallocN(buffer->chunk_ubos, buffer->num_chunks * sizeof(void *));
+ BLI_BITMAP_RESIZE(buffer->chunk_used, buffer->num_chunks);
+ }
+
+ BLI_bitmap_set_all(buffer->chunk_used, false, buffer->num_chunks);
+}
+
+/** Frees the buffer. */
+void DRW_sparse_uniform_buffer_free(DRWSparseUniformBuf *buffer)
+{
+ DRW_sparse_uniform_buffer_clear(buffer, true);
+ MEM_freeN(buffer);
+}
+
+/** Checks if the buffer contains any allocated chunks. */
+bool DRW_sparse_uniform_buffer_is_empty(DRWSparseUniformBuf *buffer)
+{
+ return buffer->num_chunks == 0;
+}
+
+static GPUUniformBuf *drw_sparse_uniform_buffer_get_ubo(DRWSparseUniformBuf *buffer, int chunk)
+{
+ if (buffer && chunk < buffer->num_chunks && BLI_BITMAP_TEST(buffer->chunk_used, chunk)) {
+ return buffer->chunk_ubos[chunk];
+ }
+ return NULL;
+}
+
+/** Bind the UBO for the given chunk, if present. A NULL buffer pointer is handled as empty. */
+void DRW_sparse_uniform_buffer_bind(DRWSparseUniformBuf *buffer, int chunk, int location)
+{
+ GPUUniformBuf *ubo = drw_sparse_uniform_buffer_get_ubo(buffer, chunk);
+ if (ubo) {
+ GPU_uniformbuf_bind(ubo, location);
+ }
+}
+
+/** Unbind the UBO for the given chunk, if present. A NULL buffer pointer is handled as empty. */
+void DRW_sparse_uniform_buffer_unbind(DRWSparseUniformBuf *buffer, int chunk)
+{
+ GPUUniformBuf *ubo = drw_sparse_uniform_buffer_get_ubo(buffer, chunk);
+ if (ubo) {
+ GPU_uniformbuf_unbind(ubo);
+ }
+}
+
+/** Returns a pointer to the given item of the given chunk, allocating memory if necessary. */
+void *DRW_sparse_uniform_buffer_ensure_item(DRWSparseUniformBuf *buffer, int chunk, int item)
+{
+ if (chunk >= buffer->num_chunks) {
+ buffer->num_chunks = (chunk + CHUNK_LIST_STEP) & ~(CHUNK_LIST_STEP - 1);
+ buffer->chunk_buffers = MEM_recallocN(buffer->chunk_buffers,
+ buffer->num_chunks * sizeof(void *));
+ buffer->chunk_ubos = MEM_recallocN(buffer->chunk_ubos, buffer->num_chunks * sizeof(void *));
+ BLI_BITMAP_RESIZE(buffer->chunk_used, buffer->num_chunks);
+ }
+
+ char *chunk_buffer = buffer->chunk_buffers[chunk];
+
+ if (chunk_buffer == NULL) {
+ buffer->chunk_buffers[chunk] = chunk_buffer = MEM_callocN(buffer->chunk_bytes, __func__);
+ }
+ else if (!BLI_BITMAP_TEST(buffer->chunk_used, chunk)) {
+ memset(chunk_buffer, 0, buffer->chunk_bytes);
+ }
+
+ BLI_BITMAP_ENABLE(buffer->chunk_used, chunk);
+
+ return chunk_buffer + buffer->item_size * item;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Uniform Attribute Buffers
+ * \{ */
+
+/** Sparse UBO buffer for a specific uniform attribute list. */
+typedef struct DRWUniformAttrBuf {
+ /* Attribute list (also used as hash table key) handled by this buffer. */
+ GPUUniformAttrList key;
+ /* Sparse UBO buffer containing the attribute values. */
+ DRWSparseUniformBuf ubos;
+ /* Last handle used to update the buffer, checked for avoiding redundant updates. */
+ DRWResourceHandle last_handle;
+ /* Linked list pointer used for freeing the empty unneeded buffers. */
+ struct DRWUniformAttrBuf *next_empty;
+} DRWUniformAttrBuf;
+
+static DRWUniformAttrBuf *drw_uniform_attrs_pool_ensure(GHash *table, GPUUniformAttrList *key)
+{
+ void **pkey, **pval;
+
+ if (!BLI_ghash_ensure_p_ex(table, key, &pkey, &pval)) {
+ DRWUniformAttrBuf *buffer = MEM_callocN(sizeof(*buffer), __func__);
+
+ *pkey = &buffer->key;
+ *pval = buffer;
+
+ GPU_uniform_attr_list_copy(&buffer->key, key);
+ drw_sparse_uniform_buffer_init(
+ &buffer->ubos, key->count * sizeof(float[4]), DRW_RESOURCE_CHUNK_LEN);
+
+ buffer->last_handle = (DRWResourceHandle)-1;
+ }
+
+ return (DRWUniformAttrBuf *)*pval;
+}
+
+/* This function mirrors lookup_property in cycles/blender/blender_object.cpp */
+static bool drw_uniform_property_lookup(ID *id, const char *name, float r_data[4])
+{
+ PointerRNA ptr, id_ptr;
+ PropertyRNA *prop;
+
+ if (!id) {
+ return false;
+ }
+
+ RNA_id_pointer_create(id, &id_ptr);
+
+ if (!RNA_path_resolve(&id_ptr, name, &ptr, &prop)) {
+ return false;
+ }
+
+ PropertyType type = RNA_property_type(prop);
+ int arraylen = RNA_property_array_length(&ptr, prop);
+
+ if (arraylen == 0) {
+ float value;
+
+ if (type == PROP_FLOAT) {
+ value = RNA_property_float_get(&ptr, prop);
+ }
+ else if (type == PROP_INT) {
+ value = RNA_property_int_get(&ptr, prop);
+ }
+ else {
+ return false;
+ }
+
+ copy_v4_fl4(r_data, value, value, value, 1);
+ return true;
+ }
+
+ if (type == PROP_FLOAT && arraylen <= 4) {
+ copy_v4_fl4(r_data, 0, 0, 0, 1);
+ RNA_property_float_get_array(&ptr, prop, r_data);
+ return true;
+ }
+
+ return false;
+}
+
+/* This function mirrors lookup_instance_property in cycles/blender/blender_object.cpp */
+static void drw_uniform_attribute_lookup(GPUUniformAttr *attr,
+ Object *ob,
+ Object *dupli_parent,
+ DupliObject *dupli_source,
+ float r_data[4])
+{
+ char idprop_name[sizeof(attr->name) + 4];
+
+ copy_v4_fl(r_data, 0);
+ sprintf(idprop_name, "[\"%s\"]", attr->name);
+
+ /* If requesting instance data, check the parent particle system and object. */
+ if (attr->use_dupli) {
+ if (dupli_source && dupli_source->particle_system) {
+ ParticleSettings *settings = dupli_source->particle_system->part;
+ if (drw_uniform_property_lookup((ID *)settings, idprop_name, r_data) ||
+ drw_uniform_property_lookup((ID *)settings, attr->name, r_data)) {
+ return;
+ }
+ }
+ if (drw_uniform_property_lookup((ID *)dupli_parent, idprop_name, r_data) ||
+ drw_uniform_property_lookup((ID *)dupli_parent, attr->name, r_data)) {
+ return;
+ }
+ }
+
+ /* Check the object and mesh. */
+ if (ob) {
+ if (drw_uniform_property_lookup((ID *)ob, idprop_name, r_data) ||
+ drw_uniform_property_lookup((ID *)ob, attr->name, r_data) ||
+ drw_uniform_property_lookup((ID *)ob->data, idprop_name, r_data) ||
+ drw_uniform_property_lookup((ID *)ob->data, attr->name, r_data)) {
+ return;
+ }
+ }
+}
+
+void drw_uniform_attrs_pool_update(GHash *table,
+ GPUUniformAttrList *key,
+ DRWResourceHandle *handle,
+ Object *ob,
+ Object *dupli_parent,
+ DupliObject *dupli_source)
+{
+ DRWUniformAttrBuf *buffer = drw_uniform_attrs_pool_ensure(table, key);
+
+ if (buffer->last_handle != *handle) {
+ buffer->last_handle = *handle;
+
+ int chunk = DRW_handle_chunk_get(handle);
+ int item = DRW_handle_id_get(handle);
+ float(*values)[4] = DRW_sparse_uniform_buffer_ensure_item(&buffer->ubos, chunk, item);
+
+ LISTBASE_FOREACH (GPUUniformAttr *, attr, &buffer->key.list) {
+ drw_uniform_attribute_lookup(attr, ob, dupli_parent, dupli_source, *values++);
+ }
+ }
+}
+
+DRWSparseUniformBuf *DRW_uniform_attrs_pool_find_ubo(GHash *table, struct GPUUniformAttrList *key)
+{
+ DRWUniformAttrBuf *buffer = BLI_ghash_lookup(table, key);
+ return buffer ? &buffer->ubos : NULL;
+}
+
+GHash *DRW_uniform_attrs_pool_new()
+{
+ return GPU_uniform_attr_list_hash_new("obattr_hash");
+}
+
+void DRW_uniform_attrs_pool_flush_all(GHash *table)
+{
+ GHASH_FOREACH_BEGIN (DRWUniformAttrBuf *, buffer, table) {
+ DRW_sparse_uniform_buffer_flush(&buffer->ubos);
+ }
+ GHASH_FOREACH_END();
+}
+
+static void drw_uniform_attrs_pool_free_cb(void *ptr)
+{
+ DRWUniformAttrBuf *buffer = ptr;
+
+ GPU_uniform_attr_list_free(&buffer->key);
+ DRW_sparse_uniform_buffer_clear(&buffer->ubos, true);
+ MEM_freeN(buffer);
+}
+
+void DRW_uniform_attrs_pool_clear_all(GHash *table)
+{
+ DRWUniformAttrBuf *remove_list = NULL;
+
+ GHASH_FOREACH_BEGIN (DRWUniformAttrBuf *, buffer, table) {
+ buffer->last_handle = (DRWResourceHandle)-1;
+ DRW_sparse_uniform_buffer_clear(&buffer->ubos, false);
+
+ if (DRW_sparse_uniform_buffer_is_empty(&buffer->ubos)) {
+ buffer->next_empty = remove_list;
+ remove_list = buffer;
+ }
+ }
+ GHASH_FOREACH_END();
+
+ while (remove_list) {
+ DRWUniformAttrBuf *buffer = remove_list;
+ remove_list = buffer->next_empty;
+ BLI_ghash_remove(table, &buffer->key, NULL, drw_uniform_attrs_pool_free_cb);
+ }
+}
+
+void DRW_uniform_attrs_pool_free(GHash *table)
+{
+ BLI_ghash_free(table, NULL, drw_uniform_attrs_pool_free_cb);
+}
+
+/** \} */
diff --git a/source/blender/draw/intern/draw_instance_data.h b/source/blender/draw/intern/draw_instance_data.h
index e562d99097e..c959a9e19d6 100644
--- a/source/blender/draw/intern/draw_instance_data.h
+++ b/source/blender/draw/intern/draw_instance_data.h
@@ -31,8 +31,12 @@
#define DRW_BUFFER_VERTS_CHUNK 128
+struct GHash;
+struct GPUUniformAttrList;
+
typedef struct DRWInstanceData DRWInstanceData;
typedef struct DRWInstanceDataList DRWInstanceDataList;
+typedef struct DRWSparseUniformBuf DRWSparseUniformBuf;
void *DRW_instance_data_next(DRWInstanceData *idata);
DRWInstanceData *DRW_instance_data_request(DRWInstanceDataList *idatalist, uint attr_size);
@@ -54,3 +58,21 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist);
void DRW_instance_data_list_reset(DRWInstanceDataList *idatalist);
void DRW_instance_data_list_free_unused(DRWInstanceDataList *idatalist);
void DRW_instance_data_list_resize(DRWInstanceDataList *idatalist);
+
+/* Sparse chunked UBO manager. */
+DRWSparseUniformBuf *DRW_sparse_uniform_buffer_new(unsigned int item_size,
+ unsigned int chunk_size);
+void DRW_sparse_uniform_buffer_flush(DRWSparseUniformBuf *buffer);
+void DRW_sparse_uniform_buffer_clear(DRWSparseUniformBuf *buffer, bool free_all);
+void DRW_sparse_uniform_buffer_free(DRWSparseUniformBuf *buffer);
+bool DRW_sparse_uniform_buffer_is_empty(DRWSparseUniformBuf *buffer);
+void DRW_sparse_uniform_buffer_bind(DRWSparseUniformBuf *buffer, int chunk, int location);
+void DRW_sparse_uniform_buffer_unbind(DRWSparseUniformBuf *buffer, int chunk);
+void *DRW_sparse_uniform_buffer_ensure_item(DRWSparseUniformBuf *buffer, int chunk, int item);
+
+/* Uniform attribute UBO management. */
+struct GHash *DRW_uniform_attrs_pool_new(void);
+void DRW_uniform_attrs_pool_flush_all(struct GHash *table);
+void DRW_uniform_attrs_pool_clear_all(struct GHash *table);
+struct DRWSparseUniformBuf *DRW_uniform_attrs_pool_find_ubo(struct GHash *table,
+ struct GPUUniformAttrList *key);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index a3c8a4a669f..5a25de1a3ca 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -467,6 +467,8 @@ static void drw_viewport_cache_resize(void)
BLI_memblock_clear(DST.vmempool->passes, NULL);
BLI_memblock_clear(DST.vmempool->views, NULL);
BLI_memblock_clear(DST.vmempool->images, NULL);
+
+ DRW_uniform_attrs_pool_clear_all(DST.vmempool->obattrs_ubo_pool);
}
DRW_instance_data_list_free_unused(DST.idatalist);
@@ -593,6 +595,9 @@ static void drw_viewport_var_init(void)
if (DST.vmempool->images == NULL) {
DST.vmempool->images = BLI_memblock_create(sizeof(GPUTexture *));
}
+ if (DST.vmempool->obattrs_ubo_pool == NULL) {
+ DST.vmempool->obattrs_ubo_pool = DRW_uniform_attrs_pool_new();
+ }
DST.resource_handle = 0;
DST.pass_handle = 0;
@@ -3025,6 +3030,7 @@ void DRW_render_context_disable(Render *render)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Init/Exit (DRW_opengl_ctx)
* \{ */
@@ -3171,6 +3177,7 @@ void DRW_xr_drawing_end(void)
#endif
+/* -------------------------------------------------------------------- */
/** \name Internal testing API for gtests
* \{ */
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index 8e505d5df71..4f4e03938c0 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -43,6 +43,9 @@
#include "draw_instance_data.h"
+struct DupliObject;
+struct Object;
+
/* Use draw manager to call GPU_select, see: DRW_draw_select_loop */
#define USE_GPU_SELECT
@@ -286,6 +289,7 @@ typedef enum {
/** Per drawcall uniforms/UBO */
DRW_UNIFORM_BLOCK_OBMATS,
DRW_UNIFORM_BLOCK_OBINFOS,
+ DRW_UNIFORM_BLOCK_OBATTRS,
DRW_UNIFORM_RESOURCE_CHUNK,
DRW_UNIFORM_RESOURCE_ID,
/** Legacy / Fallback */
@@ -317,6 +321,8 @@ struct DRWUniform {
float fvalue[4];
/* DRW_UNIFORM_INT_COPY */
int ivalue[4];
+ /* DRW_UNIFORM_BLOCK_OBATTRS */
+ struct GPUUniformAttrList *uniform_attrs;
};
int location; /* Uniform location or binding point for textures and ubos. */
uint8_t type; /* DRWUniformType */
@@ -340,6 +346,9 @@ struct DRWShadingGroup {
struct {
int objectinfo; /* Equal to 1 if the shader needs obinfos. */
DRWResourceHandle pass_handle; /* Memblock key to parent pass. */
+
+ /* Set of uniform attributes used by this shader. */
+ struct GPUUniformAttrList *uniform_attrs;
};
/* This struct is used after cache populate if using the Z sorting.
* It will not conflict with the above struct. */
@@ -598,3 +607,10 @@ void drw_resource_buffer_finish(ViewportMemoryPool *vmempool);
GPUBatch *drw_cache_procedural_points_get(void);
GPUBatch *drw_cache_procedural_lines_get(void);
GPUBatch *drw_cache_procedural_triangles_get(void);
+
+void drw_uniform_attrs_pool_update(struct GHash *table,
+ struct GPUUniformAttrList *key,
+ DRWResourceHandle *handle,
+ struct Object *ob,
+ struct Object *dupli_parent,
+ struct DupliObject *dupli_source);
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 5f394804bcf..f1d3f8c8d5a 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -128,6 +128,8 @@ void drw_resource_buffer_finish(ViewportMemoryPool *vmempool)
GPU_uniformbuf_update(vmempool->obinfos_ubo[i], data_infos);
}
+ DRW_uniform_attrs_pool_flush_all(vmempool->obattrs_ubo_pool);
+
/* Aligned alloc to avoid unaligned memcpy. */
DRWCommandChunk *chunk_tmp = MEM_mallocN_aligned(sizeof(DRWCommandChunk), 16, "tmp call chunk");
DRWCommandChunk *chunk;
@@ -209,6 +211,9 @@ static void drw_shgroup_uniform_create_ex(DRWShadingGroup *shgroup,
uni->texture_ref = (GPUTexture **)value;
uni->sampler_state = sampler_state;
break;
+ case DRW_UNIFORM_BLOCK_OBATTRS:
+ uni->uniform_attrs = (GPUUniformAttrList *)value;
+ break;
default:
uni->pvalue = (const float *)value;
break;
@@ -611,6 +616,15 @@ static DRWResourceHandle drw_resource_handle(DRWShadingGroup *shgroup,
}
}
+ if (shgroup->uniform_attrs) {
+ drw_uniform_attrs_pool_update(DST.vmempool->obattrs_ubo_pool,
+ shgroup->uniform_attrs,
+ &DST.ob_handle,
+ ob,
+ DST.dupli_parent,
+ DST.dupli_source);
+ }
+
return DST.ob_handle;
}
@@ -1184,6 +1198,7 @@ void DRW_buffer_add_entry_array(DRWCallBuffer *callbuf, const void *attr[], uint
static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
{
shgroup->uniforms = NULL;
+ shgroup->uniform_attrs = NULL;
int view_ubo_location = GPU_shader_get_builtin_block(shader, GPU_UNIFORM_BLOCK_VIEW);
int model_ubo_location = GPU_shader_get_builtin_block(shader, GPU_UNIFORM_BLOCK_MODEL);
@@ -1329,6 +1344,13 @@ void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, struct GPUMaterial
if (ubo != NULL) {
DRW_shgroup_uniform_block(grp, GPU_UBO_BLOCK_NAME, ubo);
}
+
+ GPUUniformAttrList *uattrs = GPU_material_uniform_attributes(material);
+ if (uattrs != NULL) {
+ int loc = GPU_shader_get_uniform_block_binding(grp->shader, GPU_ATTRIBUTE_UBO_BLOCK_NAME);
+ drw_shgroup_uniform_create_ex(grp, loc, DRW_UNIFORM_BLOCK_OBATTRS, uattrs, 0, 0, 1);
+ grp->uniform_attrs = uattrs;
+ }
}
GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttrFormat attrs[],
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 8cf96251e84..749e9e6bafb 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -57,12 +57,15 @@ typedef struct DRWCommandsState {
/* Resource location. */
int obmats_loc;
int obinfos_loc;
+ int obattrs_loc;
int baseinst_loc;
int chunkid_loc;
int resourceid_loc;
/* Legacy matrix support. */
int obmat_loc;
int obinv_loc;
+ /* Uniform Attributes. */
+ DRWSparseUniformBuf *obattrs_ubo;
/* Selection ID state. */
GPUVertBuf *select_buf;
uint select_id;
@@ -651,6 +654,12 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup,
state->obinfos_loc = uni->location;
GPU_uniformbuf_bind(DST.vmempool->obinfos_ubo[0], uni->location);
break;
+ case DRW_UNIFORM_BLOCK_OBATTRS:
+ state->obattrs_loc = uni->location;
+ state->obattrs_ubo = DRW_uniform_attrs_pool_find_ubo(DST.vmempool->obattrs_ubo_pool,
+ uni->uniform_attrs);
+ DRW_sparse_uniform_buffer_bind(state->obattrs_ubo, 0, uni->location);
+ break;
case DRW_UNIFORM_RESOURCE_CHUNK:
state->chunkid_loc = uni->location;
GPU_shader_uniform_int(shgroup->shader, uni->location, 0);
@@ -765,6 +774,10 @@ static void draw_call_resource_bind(DRWCommandsState *state, const DRWResourceHa
GPU_uniformbuf_unbind(DST.vmempool->obinfos_ubo[state->resource_chunk]);
GPU_uniformbuf_bind(DST.vmempool->obinfos_ubo[chunk], state->obinfos_loc);
}
+ if (state->obattrs_loc != -1) {
+ DRW_sparse_uniform_buffer_unbind(state->obattrs_ubo, state->resource_chunk);
+ DRW_sparse_uniform_buffer_bind(state->obattrs_ubo, chunk, state->obattrs_loc);
+ }
state->resource_chunk = chunk;
}
@@ -887,6 +900,9 @@ static void draw_call_batching_finish(DRWShadingGroup *shgroup, DRWCommandsState
if (state->obinfos_loc != -1) {
GPU_uniformbuf_unbind(DST.vmempool->obinfos_ubo[state->resource_chunk]);
}
+ if (state->obattrs_loc != -1) {
+ DRW_sparse_uniform_buffer_unbind(state->obattrs_ubo, state->resource_chunk);
+ }
}
static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
@@ -896,11 +912,13 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
DRWCommandsState state = {
.obmats_loc = -1,
.obinfos_loc = -1,
+ .obattrs_loc = -1,
.baseinst_loc = -1,
.chunkid_loc = -1,
.resourceid_loc = -1,
.obmat_loc = -1,
.obinv_loc = -1,
+ .obattrs_ubo = NULL,
.drw_state_enabled = 0,
.drw_state_disabled = 0,
};
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 85c04b73529..c93cbf16a30 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -549,7 +549,6 @@ void DRW_shader_free(GPUShader *shader)
/** \} */
/* -------------------------------------------------------------------- */
-
/** \name Shader Library
*
* Simple include system for glsl files.
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 1f1b52e9577..8ba3ee097df 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -198,7 +198,6 @@ void DRW_draw_cursor(void)
}
/* -------------------------------------------------------------------- */
-
/** \name 2D Cursor
* \{ */
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 338cbf2cded..c70a86eab1d 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -54,6 +54,7 @@
#include "DNA_simulation_types.h"
#include "DNA_space_types.h"
#include "DNA_speaker_types.h"
+#include "DNA_userdef_types.h"
#include "DNA_volume_types.h"
#include "DNA_world_types.h"
@@ -170,28 +171,9 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac,
}
/* helper method to test if group colors should be drawn */
-static bool acf_show_channel_colors(bAnimContext *ac)
+static bool acf_show_channel_colors(void)
{
- bool showGroupColors = false;
-
- if (ac->sl) {
- switch (ac->spacetype) {
- case SPACE_ACTION: {
- SpaceAction *saction = (SpaceAction *)ac->sl;
- showGroupColors = !(saction->flag & SACTION_NODRAWGCOLORS);
-
- break;
- }
- case SPACE_GRAPH: {
- SpaceGraph *sipo = (SpaceGraph *)ac->sl;
- showGroupColors = !(sipo->flag & SIPO_NODRAWGCOLORS);
-
- break;
- }
- }
- }
-
- return showGroupColors;
+ return (U.animation_flag & USER_ANIM_SHOW_CHANNEL_GROUP_COLORS) != 0;
}
/* get backdrop color for generic channels */
@@ -200,7 +182,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
bActionGroup *grp = NULL;
short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
- bool showGroupColors = acf_show_channel_colors(ac);
+ bool showGroupColors = acf_show_channel_colors();
if (ale->type == ANIMTYPE_FCURVE) {
FCurve *fcu = (FCurve *)ale->data;
@@ -240,7 +222,7 @@ static void acf_gpencil_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
- bool showGroupColors = acf_show_channel_colors(ac);
+ bool showGroupColors = acf_show_channel_colors();
if ((showGroupColors) && (ale->type == ANIMTYPE_GPLAYER)) {
bGPDlayer *gpl = (bGPDlayer *)ale->data;
@@ -848,10 +830,10 @@ static bAnimChannelType ACF_OBJECT = {
/* Group ------------------------------------------- */
/* get backdrop color for group widget */
-static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3])
+static void acf_group_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float r_color[3])
{
bActionGroup *agrp = (bActionGroup *)ale->data;
- bool showGroupColors = acf_show_channel_colors(ac);
+ bool showGroupColors = acf_show_channel_colors();
if (showGroupColors && agrp->customCol) {
uchar cp[3];
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index b2225ec138f..e552a321bca 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -44,12 +44,13 @@
#include "BKE_gpencil.h"
#include "BKE_main.h"
#include "BKE_node.h"
-#include "BKE_sequencer.h"
#include "DEG_depsgraph.h"
#include "RNA_access.h"
+#include "SEQ_sequencer.h"
+
#include "ED_anim_api.h"
/* **************************** depsgraph tagging ******************************** */
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 5dff62459ac..2e65fff69f1 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -96,11 +96,12 @@
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_node.h"
-#include "BKE_sequencer.h"
#include "ED_anim_api.h"
#include "ED_markers.h"
+#include "SEQ_sequencer.h"
+
#include "UI_resources.h" /* for TH_KEYFRAME_SCALE lookup */
/* ************************************************************ */
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index b52ff131b43..9e622aea6ab 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -37,7 +37,6 @@
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
#include "UI_view2d.h"
@@ -56,6 +55,8 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
+#include "SEQ_sequencer.h"
+
#include "anim_intern.h"
/* ********************** frame change operator ***************************/
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index fc622c7a52e..deebf1d1efc 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -21,13 +21,11 @@
* \ingroup edanimation
*/
-/* User-Interface Stuff for F-Modifiers:
- * This file defines the (C-Coded) templates + editing callbacks needed
- * by the interface stuff or F-Modifiers, as used by F-Curves in the Graph Editor,
- * and NLA-Strips in the NLA Editor.
+/**
+ * User Interface for F-Modifiers
*
- * Copy/Paste Buffer for F-Modifiers:
- * For now, this is also defined in this file so that it can be shared between the
+ * This file defines templates and some editing callbacks needed by the interface for
+ * F-Modifiers, as used by F-Curves in the Graph Editor and NLA-Strips in the NLA Editor.
*/
#include <string.h>
@@ -1047,8 +1045,12 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout,
}
}
-/* ********************************************** */
-/* COPY/PASTE BUFFER STUFF */
+/* -------------------------------------------------------------------- */
+/** \name Copy / Paste Buffer Code
+ *
+ * For now, this is also defined in this file so that it can be shared between the graph editor
+ * and the NLA editor.
+ * \{ */
/* Copy/Paste Buffer itself (list of FModifier 's) */
static ListBase fmodifier_copypaste_buf = {NULL, NULL};
@@ -1139,4 +1141,4 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *c
return ok;
}
-/* ********************************************** */
+/** \} */
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index 60a1434ed42..8bcaf72f678 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -606,7 +606,7 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot)
};
/* identifiers */
- ot->name = "AutoName by Axis";
+ ot->name = "Auto-Name by Axis";
ot->idname = "ARMATURE_OT_autoside_names";
ot->description =
"Automatically renames the selected bones according to which side of the target axis they "
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 27718b61d70..60fe8ee7dee 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -1550,10 +1550,10 @@ enum {
static const EnumPropertyItem prop_similar_types[] = {
{SIMEDBONE_CHILDREN, "CHILDREN", 0, "Children", ""},
- {SIMEDBONE_CHILDREN_IMMEDIATE, "CHILDREN_IMMEDIATE", 0, "Immediate children", ""},
+ {SIMEDBONE_CHILDREN_IMMEDIATE, "CHILDREN_IMMEDIATE", 0, "Immediate Children", ""},
{SIMEDBONE_SIBLINGS, "SIBLINGS", 0, "Siblings", ""},
{SIMEDBONE_LENGTH, "LENGTH", 0, "Length", ""},
- {SIMEDBONE_DIRECTION, "DIRECTION", 0, "Direction (Y axis)", ""},
+ {SIMEDBONE_DIRECTION, "DIRECTION", 0, "Direction (Y Axis)", ""},
{SIMEDBONE_PREFIX, "PREFIX", 0, "Prefix", ""},
{SIMEDBONE_SUFFIX, "SUFFIX", 0, "Suffix", ""},
{SIMEDBONE_LAYER, "LAYER", 0, "Layer", ""},
@@ -1806,11 +1806,11 @@ static void select_similar_data_pchan(bContext *C, const size_t bytes_size, cons
static void is_ancestor(EditBone *bone, EditBone *ancestor)
{
- if (bone->temp.ebone == ancestor || bone->temp.ebone == NULL) {
+ if (ELEM(bone->temp.ebone, ancestor, NULL)) {
return;
}
- if (bone->temp.ebone->temp.ebone != NULL && bone->temp.ebone->temp.ebone != ancestor) {
+ if (!ELEM(bone->temp.ebone->temp.ebone, NULL, ancestor)) {
is_ancestor(bone->temp.ebone, ancestor);
}
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index e51e5ec5cef..3c0b6dacbf6 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -1547,7 +1547,8 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
}
}
else {
- BKE_modifier_set_error(&mmd->modifier, "Failed to find bind solution (increase precision?)");
+ BKE_modifier_set_error(
+ mmd->object, &mmd->modifier, "Failed to find bind solution (increase precision?)");
error("Mesh Deform: failed to find bind solution.");
break;
}
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 8a1c2a4afa8..91893af003f 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -638,7 +638,7 @@ void POSE_OT_autoside_names(wmOperatorType *ot)
};
/* identifiers */
- ot->name = "AutoName by Axis";
+ ot->name = "Auto-Name by Axis";
ot->idname = "POSE_OT_autoside_names";
ot->description =
"Automatically renames the selected bones according to which side of the target axis they "
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index eb2a0d7a073..3781b2e318b 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -961,7 +961,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
/* initial apply for operator... */
/* TODO: need to calculate percentage for initial round too... */
- if (pso->mode != POSESLIDE_PUSH_REST && pso->mode != POSESLIDE_RELAX_REST) {
+ if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) {
pose_slide_apply(C, pso);
}
else {
@@ -1200,7 +1200,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
pose_slide_reset(pso);
/* apply... */
- if (pso->mode != POSESLIDE_PUSH_REST && pso->mode != POSESLIDE_RELAX_REST) {
+ if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) {
pose_slide_apply(C, pso);
}
else {
@@ -1223,7 +1223,7 @@ static void pose_slide_cancel(bContext *UNUSED(C), wmOperator *op)
static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso)
{
/* settings should have been set up ok for applying, so just apply! */
- if (pso->mode != POSESLIDE_PUSH_REST && pso->mode != POSESLIDE_RELAX_REST) {
+ if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) {
pose_slide_apply(C, pso);
}
else {
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 85d86849140..db472c9ffa7 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -307,12 +307,8 @@ static void keyIndex_delNurb(EditNurb *editnurb, Nurb *nu)
static void keyIndex_delNurbList(EditNurb *editnurb, ListBase *nubase)
{
- Nurb *nu = nubase->first;
-
- while (nu) {
+ LISTBASE_FOREACH (Nurb *, nu, nubase) {
keyIndex_delNurb(editnurb, nu);
-
- nu = nu->next;
}
}
@@ -476,19 +472,15 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
static void switch_keys_direction(Curve *cu, Nurb *actnu)
{
- KeyBlock *currkey;
EditNurb *editnurb = cu->editnurb;
ListBase *nubase = &editnurb->nurbs;
- Nurb *nu;
float *fp;
int a;
- currkey = cu->key->block.first;
- while (currkey) {
+ LISTBASE_FOREACH (KeyBlock *, currkey, &cu->key->block) {
fp = currkey->data;
- nu = nubase->first;
- while (nu) {
+ LISTBASE_FOREACH (Nurb *, nu, nubase) {
if (nu->bezt) {
BezTriple *bezt = nu->bezt;
a = nu->pntsu;
@@ -522,11 +514,7 @@ static void switch_keys_direction(Curve *cu, Nurb *actnu)
fp += a * KEYELEM_FLOAT_LEN_BPOINT;
}
}
-
- nu = nu->next;
}
-
- currkey = currkey->next;
}
}
@@ -583,13 +571,11 @@ static void bezt_to_key(BezTriple *bezt, float *key)
static void calc_keyHandles(ListBase *nurb, float *key)
{
- Nurb *nu;
int a;
float *fp = key;
BezTriple *bezt;
- nu = nurb->first;
- while (nu) {
+ LISTBASE_FOREACH (Nurb *, nu, nurb) {
if (nu->bezt) {
BezTriple *prevp, *nextp;
BezTriple cur, prev, next;
@@ -649,8 +635,6 @@ static void calc_keyHandles(ListBase *nurb, float *key)
a = nu->pntsu * nu->pntsv;
fp += a * KEYELEM_FLOAT_LEN_BPOINT;
}
-
- nu = nu->next;
}
}
@@ -658,255 +642,247 @@ static void calc_shapeKeys(Object *obedit, ListBase *newnurbs)
{
Curve *cu = (Curve *)obedit->data;
- /* are there keys? */
- if (cu->key) {
- int a, i;
- EditNurb *editnurb = cu->editnurb;
- KeyBlock *currkey;
- KeyBlock *actkey = BLI_findlink(&cu->key->block, editnurb->shapenr - 1);
- BezTriple *bezt, *oldbezt;
- BPoint *bp, *oldbp;
- Nurb *nu, *newnu;
- int totvert = BKE_keyblock_curve_element_count(&editnurb->nurbs);
-
- float(*ofs)[3] = NULL;
- float *oldkey, *newkey, *ofp;
-
- /* editing the base key should update others */
- if (cu->key->type == KEY_RELATIVE) {
- if (BKE_keyblock_is_basis(cu->key, editnurb->shapenr - 1)) { /* active key is a base */
- int totvec = 0;
-
- /* Calculate needed memory to store offset */
- nu = editnurb->nurbs.first;
- while (nu) {
- if (nu->bezt) {
- /* Three vects to store handles and one for tilt. */
- totvec += nu->pntsu * 4;
- }
- else {
- totvec += 2 * nu->pntsu * nu->pntsv;
- }
+ if (cu->key == NULL) {
+ return;
+ }
- nu = nu->next;
+ int a, i;
+ EditNurb *editnurb = cu->editnurb;
+ KeyBlock *actkey = BLI_findlink(&cu->key->block, editnurb->shapenr - 1);
+ BezTriple *bezt, *oldbezt;
+ BPoint *bp, *oldbp;
+ Nurb *newnu;
+ int totvert = BKE_keyblock_curve_element_count(&editnurb->nurbs);
+
+ float(*ofs)[3] = NULL;
+ float *oldkey, *newkey, *ofp;
+
+ /* editing the base key should update others */
+ if (cu->key->type == KEY_RELATIVE) {
+ if (BKE_keyblock_is_basis(cu->key, editnurb->shapenr - 1)) { /* active key is a base */
+ int totvec = 0;
+
+ /* Calculate needed memory to store offset */
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
+
+ if (nu->bezt) {
+ /* Three vects to store handles and one for tilt. */
+ totvec += nu->pntsu * 4;
}
+ else {
+ totvec += 2 * nu->pntsu * nu->pntsv;
+ }
+ }
- ofs = MEM_callocN(sizeof(float[3]) * totvec, "currkey->data");
- nu = editnurb->nurbs.first;
- i = 0;
- while (nu) {
- if (nu->bezt) {
- bezt = nu->bezt;
- a = nu->pntsu;
- while (a--) {
- oldbezt = getKeyIndexOrig_bezt(editnurb, bezt);
+ ofs = MEM_callocN(sizeof(float[3]) * totvec, "currkey->data");
+ i = 0;
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
+ if (nu->bezt) {
+ bezt = nu->bezt;
+ a = nu->pntsu;
+ while (a--) {
+ oldbezt = getKeyIndexOrig_bezt(editnurb, bezt);
- if (oldbezt) {
- int j;
- for (j = 0; j < 3; j++) {
- sub_v3_v3v3(ofs[i], bezt->vec[j], oldbezt->vec[j]);
- i++;
- }
- ofs[i][0] = bezt->tilt - oldbezt->tilt;
- ofs[i][1] = bezt->radius - oldbezt->radius;
+ if (oldbezt) {
+ int j;
+ for (j = 0; j < 3; j++) {
+ sub_v3_v3v3(ofs[i], bezt->vec[j], oldbezt->vec[j]);
i++;
}
- else {
- i += 4;
- }
- bezt++;
+ ofs[i][0] = bezt->tilt - oldbezt->tilt;
+ ofs[i][1] = bezt->radius - oldbezt->radius;
+ i++;
}
+ else {
+ i += 4;
+ }
+ bezt++;
}
- else {
- bp = nu->bp;
- a = nu->pntsu * nu->pntsv;
- while (a--) {
- oldbp = getKeyIndexOrig_bp(editnurb, bp);
- if (oldbp) {
- sub_v3_v3v3(ofs[i], bp->vec, oldbp->vec);
- ofs[i + 1][0] = bp->tilt - oldbp->tilt;
- ofs[i + 1][1] = bp->radius - oldbp->radius;
- }
- i += 2;
- bp++;
+ }
+ else {
+ bp = nu->bp;
+ a = nu->pntsu * nu->pntsv;
+ while (a--) {
+ oldbp = getKeyIndexOrig_bp(editnurb, bp);
+ if (oldbp) {
+ sub_v3_v3v3(ofs[i], bp->vec, oldbp->vec);
+ ofs[i + 1][0] = bp->tilt - oldbp->tilt;
+ ofs[i + 1][1] = bp->radius - oldbp->radius;
}
+ i += 2;
+ bp++;
}
-
- nu = nu->next;
}
}
}
+ }
- currkey = cu->key->block.first;
- while (currkey) {
- const bool apply_offset = (ofs && (currkey != actkey) &&
- (editnurb->shapenr - 1 == currkey->relative));
-
- float *fp = newkey = MEM_callocN(cu->key->elemsize * totvert, "currkey->data");
- ofp = oldkey = currkey->data;
+ LISTBASE_FOREACH (KeyBlock *, currkey, &cu->key->block) {
+ const bool apply_offset = (ofs && (currkey != actkey) &&
+ (editnurb->shapenr - 1 == currkey->relative));
- nu = editnurb->nurbs.first;
- /* We need to restore to original curve into newnurb, *not* editcurve's nurbs.
- * Otherwise, in case we update obdata *without* leaving editmode (e.g. viewport render),
- * we would invalidate editcurve. */
- newnu = newnurbs->first;
- i = 0;
- while (nu) {
- if (currkey == actkey) {
- const bool restore = actkey != cu->key->refkey;
+ float *fp = newkey = MEM_callocN(cu->key->elemsize * totvert, "currkey->data");
+ ofp = oldkey = currkey->data;
- if (nu->bezt) {
- bezt = nu->bezt;
- a = nu->pntsu;
- BezTriple *newbezt = newnu->bezt;
- while (a--) {
- int j;
- oldbezt = getKeyIndexOrig_bezt(editnurb, bezt);
+ Nurb *nu = editnurb->nurbs.first;
+ /* We need to restore to original curve into newnurb, *not* editcurve's nurbs.
+ * Otherwise, in case we update obdata *without* leaving editmode (e.g. viewport render),
+ * we would invalidate editcurve. */
+ newnu = newnurbs->first;
+ i = 0;
+ while (nu) {
+ if (currkey == actkey) {
+ const bool restore = actkey != cu->key->refkey;
- for (j = 0; j < 3; j++, i++) {
- copy_v3_v3(&fp[j * 3], bezt->vec[j]);
+ if (nu->bezt) {
+ bezt = nu->bezt;
+ a = nu->pntsu;
+ BezTriple *newbezt = newnu->bezt;
+ while (a--) {
+ int j;
+ oldbezt = getKeyIndexOrig_bezt(editnurb, bezt);
- if (restore && oldbezt) {
- copy_v3_v3(newbezt->vec[j], oldbezt->vec[j]);
- }
- }
- fp[9] = bezt->tilt;
- fp[10] = bezt->radius;
+ for (j = 0; j < 3; j++, i++) {
+ copy_v3_v3(&fp[j * 3], bezt->vec[j]);
if (restore && oldbezt) {
- newbezt->tilt = oldbezt->tilt;
- newbezt->radius = oldbezt->radius;
+ copy_v3_v3(newbezt->vec[j], oldbezt->vec[j]);
}
+ }
+ fp[9] = bezt->tilt;
+ fp[10] = bezt->radius;
- fp += KEYELEM_FLOAT_LEN_BEZTRIPLE;
- i++;
- bezt++;
- newbezt++;
+ if (restore && oldbezt) {
+ newbezt->tilt = oldbezt->tilt;
+ newbezt->radius = oldbezt->radius;
}
- }
- else {
- bp = nu->bp;
- a = nu->pntsu * nu->pntsv;
- BPoint *newbp = newnu->bp;
- while (a--) {
- oldbp = getKeyIndexOrig_bp(editnurb, bp);
- copy_v3_v3(fp, bp->vec);
+ fp += KEYELEM_FLOAT_LEN_BEZTRIPLE;
+ i++;
+ bezt++;
+ newbezt++;
+ }
+ }
+ else {
+ bp = nu->bp;
+ a = nu->pntsu * nu->pntsv;
+ BPoint *newbp = newnu->bp;
+ while (a--) {
+ oldbp = getKeyIndexOrig_bp(editnurb, bp);
- fp[3] = bp->tilt;
- fp[4] = bp->radius;
+ copy_v3_v3(fp, bp->vec);
- if (restore && oldbp) {
- copy_v3_v3(newbp->vec, oldbp->vec);
- newbp->tilt = oldbp->tilt;
- newbp->radius = oldbp->radius;
- }
+ fp[3] = bp->tilt;
+ fp[4] = bp->radius;
- fp += KEYELEM_FLOAT_LEN_BPOINT;
- bp++;
- newbp++;
- i += 2;
+ if (restore && oldbp) {
+ copy_v3_v3(newbp->vec, oldbp->vec);
+ newbp->tilt = oldbp->tilt;
+ newbp->radius = oldbp->radius;
}
+
+ fp += KEYELEM_FLOAT_LEN_BPOINT;
+ bp++;
+ newbp++;
+ i += 2;
}
}
- else {
- int index;
- const float *curofp;
-
- if (oldkey) {
- if (nu->bezt) {
- bezt = nu->bezt;
- a = nu->pntsu;
+ }
+ else {
+ int index;
+ const float *curofp;
- while (a--) {
- index = getKeyIndexOrig_keyIndex(editnurb, bezt);
- if (index >= 0) {
- int j;
- curofp = ofp + index;
+ if (oldkey) {
+ if (nu->bezt) {
+ bezt = nu->bezt;
+ a = nu->pntsu;
- for (j = 0; j < 3; j++, i++) {
- copy_v3_v3(&fp[j * 3], &curofp[j * 3]);
+ while (a--) {
+ index = getKeyIndexOrig_keyIndex(editnurb, bezt);
+ if (index >= 0) {
+ int j;
+ curofp = ofp + index;
- if (apply_offset) {
- add_v3_v3(&fp[j * 3], ofs[i]);
- }
- }
- fp[9] = curofp[9];
- fp[10] = curofp[10];
+ for (j = 0; j < 3; j++, i++) {
+ copy_v3_v3(&fp[j * 3], &curofp[j * 3]);
if (apply_offset) {
- /* Apply tilt offsets. */
- add_v3_v3(fp + 9, ofs[i]);
- i++;
+ add_v3_v3(&fp[j * 3], ofs[i]);
}
+ }
+ fp[9] = curofp[9];
+ fp[10] = curofp[10];
- fp += KEYELEM_FLOAT_LEN_BEZTRIPLE;
+ if (apply_offset) {
+ /* Apply tilt offsets. */
+ add_v3_v3(fp + 9, ofs[i]);
+ i++;
}
- else {
- int j;
- for (j = 0; j < 3; j++, i++) {
- copy_v3_v3(&fp[j * 3], bezt->vec[j]);
- }
- fp[9] = bezt->tilt;
- fp[10] = bezt->radius;
- fp += KEYELEM_FLOAT_LEN_BEZTRIPLE;
+ fp += KEYELEM_FLOAT_LEN_BEZTRIPLE;
+ }
+ else {
+ int j;
+ for (j = 0; j < 3; j++, i++) {
+ copy_v3_v3(&fp[j * 3], bezt->vec[j]);
}
- bezt++;
+ fp[9] = bezt->tilt;
+ fp[10] = bezt->radius;
+
+ fp += KEYELEM_FLOAT_LEN_BEZTRIPLE;
}
+ bezt++;
}
- else {
- bp = nu->bp;
- a = nu->pntsu * nu->pntsv;
- while (a--) {
- index = getKeyIndexOrig_keyIndex(editnurb, bp);
+ }
+ else {
+ bp = nu->bp;
+ a = nu->pntsu * nu->pntsv;
+ while (a--) {
+ index = getKeyIndexOrig_keyIndex(editnurb, bp);
- if (index >= 0) {
- curofp = ofp + index;
- copy_v3_v3(fp, curofp);
- fp[3] = curofp[3];
- fp[4] = curofp[4];
+ if (index >= 0) {
+ curofp = ofp + index;
+ copy_v3_v3(fp, curofp);
+ fp[3] = curofp[3];
+ fp[4] = curofp[4];
- if (apply_offset) {
- add_v3_v3(fp, ofs[i]);
- add_v3_v3(&fp[3], ofs[i + 1]);
- }
- }
- else {
- copy_v3_v3(fp, bp->vec);
- fp[3] = bp->tilt;
- fp[4] = bp->radius;
+ if (apply_offset) {
+ add_v3_v3(fp, ofs[i]);
+ add_v3_v3(&fp[3], ofs[i + 1]);
}
-
- fp += KEYELEM_FLOAT_LEN_BPOINT;
- bp++;
- i += 2;
}
+ else {
+ copy_v3_v3(fp, bp->vec);
+ fp[3] = bp->tilt;
+ fp[4] = bp->radius;
+ }
+
+ fp += KEYELEM_FLOAT_LEN_BPOINT;
+ bp++;
+ i += 2;
}
}
}
-
- nu = nu->next;
- newnu = newnu->next;
}
- if (apply_offset) {
- /* handles could become malicious after offsets applying */
- calc_keyHandles(&editnurb->nurbs, newkey);
- }
-
- currkey->totelem = totvert;
- if (currkey->data) {
- MEM_freeN(currkey->data);
- }
- currkey->data = newkey;
+ nu = nu->next;
+ newnu = newnu->next;
+ }
- currkey = currkey->next;
+ if (apply_offset) {
+ /* handles could become malicious after offsets applying */
+ calc_keyHandles(&editnurb->nurbs, newkey);
}
- if (ofs) {
- MEM_freeN(ofs);
+ currkey->totelem = totvert;
+ if (currkey->data) {
+ MEM_freeN(currkey->data);
}
+ currkey->data = newkey;
+ }
+
+ if (ofs) {
+ MEM_freeN(ofs);
}
}
@@ -929,11 +905,10 @@ static void fcurve_path_rename(AnimData *adt,
ListBase *orig_curves,
ListBase *curves)
{
- FCurve *fcu, *nfcu, *nextfcu;
+ FCurve *nfcu;
int len = strlen(orig_rna_path);
- for (fcu = orig_curves->first; fcu; fcu = nextfcu) {
- nextfcu = fcu->next;
+ LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, orig_curves) {
if (STREQLEN(fcu->rna_path, orig_rna_path, len)) {
char *spath, *suffix = fcu->rna_path + len;
nfcu = BKE_fcurve_copy(fcu);
@@ -977,16 +952,15 @@ static void fcurve_remove(AnimData *adt, ListBase *orig_curves, FCurve *fcu)
static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
{
- int nu_index = 0, a, pt_index;
+ int a, pt_index;
EditNurb *editnurb = cu->editnurb;
- Nurb *nu;
CVKeyIndex *keyIndex;
char rna_path[64], orig_rna_path[64];
AnimData *adt = BKE_animdata_from_id(&cu->id);
ListBase curves = {NULL, NULL};
- FCurve *fcu, *next;
- for (nu = editnurb->nurbs.first, nu_index = 0; nu != NULL; nu = nu->next, nu_index++) {
+ int nu_index = 0;
+ LISTBASE_FOREACH_INDEX (Nurb *, nu, &editnurb->nurbs, nu_index) {
if (nu->bezt) {
BezTriple *bezt = nu->bezt;
a = nu->pntsu;
@@ -1054,19 +1028,18 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
/* remove paths for removed control points
* need this to make further step with copying non-cv related curves copying
* not touching cv's f-curves */
- for (fcu = orig_curves->first; fcu; fcu = next) {
- next = fcu->next;
-
- if (STREQLEN(fcu->rna_path, "splines", 7)) {
+ LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, orig_curves) {
+ if (STRPREFIX(fcu->rna_path, "splines")) {
const char *ch = strchr(fcu->rna_path, '.');
- if (ch && (STREQLEN(ch, ".bezier_points", 14) || STREQLEN(ch, ".points", 7))) {
+ if (ch && (STRPREFIX(ch, ".bezier_points") || STRPREFIX(ch, ".points"))) {
fcurve_remove(adt, orig_curves, fcu);
}
}
}
- for (nu = editnurb->nurbs.first, nu_index = 0; nu != NULL; nu = nu->next, nu_index++) {
+ nu_index = 0;
+ LISTBASE_FOREACH_INDEX (Nurb *, nu, &editnurb->nurbs, nu_index) {
keyIndex = NULL;
if (nu->pntsu) {
if (nu->bezt) {
@@ -1086,10 +1059,8 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
/* the remainders in orig_curves can be copied back (like follow path) */
/* (if it's not path to spline) */
- for (fcu = orig_curves->first; fcu; fcu = next) {
- next = fcu->next;
-
- if (STREQLEN(fcu->rna_path, "splines", 7)) {
+ LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, orig_curves) {
+ if (STRPREFIX(fcu->rna_path, "splines")) {
fcurve_remove(adt, orig_curves, fcu);
}
else {
@@ -1141,13 +1112,11 @@ static int *init_index_map(Object *obedit, int *r_old_totvert)
{
Curve *curve = (Curve *)obedit->data;
EditNurb *editnurb = curve->editnurb;
- Nurb *nu;
CVKeyIndex *keyIndex;
int *old_to_new_map;
- int old_totvert;
- int vertex_index;
- for (nu = curve->nurb.first, old_totvert = 0; nu != NULL; nu = nu->next) {
+ int old_totvert = 0;
+ LISTBASE_FOREACH (Nurb *, nu, &curve->nurb) {
if (nu->bezt) {
old_totvert += nu->pntsu * 3;
}
@@ -1161,7 +1130,8 @@ static int *init_index_map(Object *obedit, int *r_old_totvert)
old_to_new_map[i] = -1;
}
- for (nu = editnurb->nurbs.first, vertex_index = 0; nu != NULL; nu = nu->next) {
+ int vertex_index = 0;
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
if (nu->bezt) {
BezTriple *bezt = nu->bezt;
int a = nu->pntsu;
@@ -1205,7 +1175,6 @@ static int *init_index_map(Object *obedit, int *r_old_totvert)
static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
{
- Object *object;
Curve *curve = (Curve *)obedit->data;
EditNurb *editnurb = curve->editnurb;
int *old_to_new_map = NULL;
@@ -1219,8 +1188,7 @@ static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
return;
}
- for (object = bmain->objects.first; object; object = object->id.next) {
- ModifierData *md;
+ LISTBASE_FOREACH (Object *, object, &bmain->objects) {
int index;
if ((object->parent) && (object->parent->data == curve) &&
ELEM(object->partype, PARVERT1, PARVERT3)) {
@@ -1248,7 +1216,7 @@ static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
}
}
if (object->data == curve) {
- for (md = object->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
if (md->type == eModifierType_Hook) {
HookModifierData *hmd = (HookModifierData *)md;
int i, j;
@@ -1290,13 +1258,12 @@ void ED_curve_editnurb_load(Main *bmain, Object *obedit)
if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
Curve *cu = obedit->data;
- Nurb *nu, *newnu;
ListBase newnurb = {NULL, NULL}, oldnurb = cu->nurb;
remap_hooks_and_vertex_parents(bmain, obedit);
- for (nu = editnurb->first; nu; nu = nu->next) {
- newnu = BKE_nurb_duplicate(nu);
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
+ Nurb *newnu = BKE_nurb_duplicate(nu);
BLI_addtail(&newnurb, newnu);
if (nu->type == CU_NURBS) {
@@ -1323,7 +1290,6 @@ void ED_curve_editnurb_make(Object *obedit)
{
Curve *cu = (Curve *)obedit->data;
EditNurb *editnurb = cu->editnurb;
- Nurb *nu, *newnu;
KeyBlock *actkey;
if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
@@ -1346,12 +1312,10 @@ void ED_curve_editnurb_make(Object *obedit)
cu->editnurb = editnurb;
}
- nu = cu->nurb.first;
- while (nu) {
- newnu = BKE_nurb_duplicate(nu);
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
+ Nurb *newnu = BKE_nurb_duplicate(nu);
BKE_nurb_test_2d(newnu); /* after join, or any other creation of curve */
BLI_addtail(&editnurb->nurbs, newnu);
- nu = nu->next;
}
/* animation could be added in editmode even if there was no animdata in
@@ -1722,11 +1686,10 @@ static void rotateflagNurb(ListBase *editnurb,
const float rotmat[3][3])
{
/* all verts with (flag & 'flag') rotate */
- Nurb *nu;
BPoint *bp;
int a;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_NURBS) {
bp = nu->bp;
a = nu->pntsu * nu->pntsv;
@@ -1746,12 +1709,11 @@ static void rotateflagNurb(ListBase *editnurb,
void ed_editnurb_translate_flag(ListBase *editnurb, uint8_t flag, const float vec[3])
{
/* all verts with ('flag' & flag) translate */
- Nurb *nu;
BezTriple *bezt;
BPoint *bp;
int a;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
a = nu->pntsu;
bezt = nu->bezt;
@@ -1785,11 +1747,10 @@ void ed_editnurb_translate_flag(ListBase *editnurb, uint8_t flag, const float ve
static void weightflagNurb(ListBase *editnurb, short flag, float w)
{
- Nurb *nu;
BPoint *bp;
int a;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_NURBS) {
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
@@ -1808,16 +1769,12 @@ static void ed_surf_delete_selected(Object *obedit)
{
Curve *cu = obedit->data;
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu, *next;
BPoint *bp, *bpn, *newbp;
int a, b, newu, newv;
BLI_assert(obedit->type == OB_SURF);
- nu = editnurb->first;
- while (nu) {
- next = nu->next;
-
+ LISTBASE_FOREACH_MUTABLE (Nurb *, nu, editnurb) {
/* is entire nurb selected */
bp = nu->bp;
a = nu->pntsu * nu->pntsv;
@@ -1903,7 +1860,6 @@ static void ed_surf_delete_selected(Object *obedit)
}
}
}
- nu = next;
}
}
@@ -1912,15 +1868,12 @@ static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
Curve *cu = obedit->data;
EditNurb *editnurb = cu->editnurb;
ListBase *nubase = &editnurb->nurbs;
- Nurb *nu, *next;
BezTriple *bezt, *bezt1;
BPoint *bp, *bp1;
int a, type, nuindex = 0;
/* first loop, can we remove entire pieces? */
- nu = nubase->first;
- while (nu) {
- next = nu->next;
+ LISTBASE_FOREACH_MUTABLE (Nurb *, nu, nubase) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
a = nu->pntsu;
@@ -1981,13 +1934,10 @@ static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
clamp_nurb_order_u(nu);
}
#endif
- nu = next;
nuindex++;
}
/* 2nd loop, delete small pieces: just for curves */
- nu = nubase->first;
- while (nu) {
- next = nu->next;
+ LISTBASE_FOREACH_MUTABLE (Nurb *, nu, nubase) {
type = 0;
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
@@ -2047,21 +1997,17 @@ static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
BKE_nurb_order_clamp_u(nu);
BKE_nurb_knot_calc_u(nu);
}
- nu = next;
}
}
/* only for OB_SURF */
bool ed_editnurb_extrude_flag(EditNurb *editnurb, const uint8_t flag)
{
- Nurb *nu;
BPoint *bp, *bpn, *newbp;
int a, u, v, len;
bool ok = false;
- nu = editnurb->nurbs.first;
- while (nu) {
-
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
if (nu->pntsv == 1) {
bp = nu->bp;
a = nu->pntsu;
@@ -2109,7 +2055,7 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const uint8_t flag)
bp++;
}
- if (u == 0 || u == nu->pntsv - 1) { /* row in u-direction selected */
+ if (ELEM(u, 0, nu->pntsv - 1)) { /* row in u-direction selected */
ok = true;
newbp = (BPoint *)MEM_mallocN(nu->pntsu * (nu->pntsv + 1) * sizeof(BPoint),
"extrudeNurb1");
@@ -2137,7 +2083,7 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const uint8_t flag)
nu->pntsv++;
BKE_nurb_knot_calc_v(nu);
}
- else if (v == 0 || v == nu->pntsu - 1) { /* column in v-direction selected */
+ else if (ELEM(v, 0, nu->pntsu - 1)) { /* column in v-direction selected */
ok = true;
bpn = newbp = (BPoint *)MEM_mallocN((nu->pntsu + 1) * nu->pntsv * sizeof(BPoint),
"extrudeNurb1");
@@ -2166,7 +2112,6 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const uint8_t flag)
}
}
}
- nu = nu->next;
}
return ok;
@@ -2197,14 +2142,15 @@ static void adduplicateflagNurb(
Object *obedit, View3D *v3d, ListBase *newnurb, const uint8_t flag, const bool split)
{
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu, *newnu;
+ Nurb *newnu;
BezTriple *bezt, *bezt1;
BPoint *bp, *bp1, *bp2, *bp3;
Curve *cu = (Curve *)obedit->data;
- int a, b, c, starta, enda, diffa, cyclicu, cyclicv, newu, newv, i;
+ int a, b, c, starta, enda, diffa, cyclicu, cyclicv, newu, newv;
char *usel;
- for (i = 0, nu = editnurb->first; nu; i++, nu = nu->next) {
+ int i = 0;
+ LISTBASE_FOREACH_INDEX (Nurb *, nu, editnurb, i) {
cyclicu = cyclicv = 0;
if (nu->type == CU_BEZIER) {
for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
@@ -2363,7 +2309,7 @@ static void adduplicateflagNurb(
newv = 0;
for (a = 0; a < nu->pntsu; a++) {
if (usel[a]) {
- if (newv == 0 || usel[a] == newv) {
+ if (ELEM(newv, 0, usel[a])) {
newv = usel[a];
newu++;
}
@@ -2569,7 +2515,7 @@ static void adduplicateflagNurb(
}
if (BLI_listbase_is_empty(newnurb) == false) {
- for (nu = newnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, newnurb) {
if (nu->type == CU_BEZIER) {
if (split) {
/* recalc first and last */
@@ -2619,10 +2565,9 @@ static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
}
EditNurb *editnurb = cu->editnurb;
- Nurb *nu;
- int i;
- for (nu = editnurb->nurbs.first, i = 0; nu; nu = nu->next, i++) {
+ int i = 0;
+ LISTBASE_FOREACH_INDEX (Nurb *, nu, &editnurb->nurbs, i) {
if (ED_curve_nurb_select_check(v3d, nu)) {
BKE_nurb_direction_switch(nu);
keyData_switchDirectionNurb(cu, nu);
@@ -2674,13 +2619,12 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
BezTriple *bezt;
BPoint *bp;
float weight = RNA_float_get(op->ptr, "weight");
int a;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->bezt) {
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
if (bezt->f2 & SELECT) {
@@ -2741,13 +2685,12 @@ static int set_radius_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
BezTriple *bezt;
BPoint *bp;
float radius = RNA_float_get(op->ptr, "radius");
int a;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->bezt) {
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
if (bezt->f2 & SELECT) {
@@ -2853,12 +2796,11 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op))
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
int a, a_end;
bool changed = false;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->bezt) {
/* duplicate the curve to use in weight calculation */
const BezTriple *bezt_orig = MEM_dupallocN(nu->bezt);
@@ -2960,7 +2902,6 @@ void CURVE_OT_smooth(wmOperatorType *ot)
static void curve_smooth_value(ListBase *editnurb, const int bezt_offsetof, const int bp_offset)
{
- Nurb *nu;
BezTriple *bezt;
BPoint *bp;
int a;
@@ -2970,7 +2911,7 @@ static void curve_smooth_value(ListBase *editnurb, const int bezt_offsetof, cons
int start_sel, end_sel; /* selection indices, inclusive */
float start_rad, end_rad, fac, range;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->bezt) {
#define BEZT_VALUE(bezt) (*((float *)((char *)(bezt) + bezt_offsetof)))
@@ -3289,12 +3230,11 @@ static int hide_exec(bContext *C, wmOperator *op)
}
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int a, sel;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
a = nu->pntsu;
@@ -3385,13 +3325,12 @@ static int reveal_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int a;
bool changed = false;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
nu->hide = 0;
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
@@ -3462,7 +3401,6 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
{
Curve *cu = obedit->data;
EditNurb *editnurb = cu->editnurb;
- Nurb *nu;
BezTriple *bezt, *beztnew, *beztn;
BPoint *bp, *prevbp, *bpnew, *bpn;
float vec[15];
@@ -3471,7 +3409,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
// printf("*** subdivideNurb: entering subdivide\n");
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
amount = 0;
if (nu->type == CU_BEZIER) {
BezTriple *nextbezt;
@@ -3925,18 +3863,17 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
View3D *v3d = CTX_wm_view3d(C);
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
bool changed = false;
bool changed_size = false;
const bool use_handles = RNA_boolean_get(op->ptr, "use_handles");
const int type = RNA_enum_get(op->ptr, "type");
- if (type == CU_CARDINAL || type == CU_BSPLINE) {
+ if (ELEM(type, CU_CARDINAL, CU_BSPLINE)) {
BKE_report(op->reports, RPT_ERROR, "Not yet implemented");
continue;
}
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (ED_curve_nurb_select_check(v3d, nu)) {
const int pntsu_prev = nu->pntsu;
const char *err_msg = NULL;
@@ -4225,12 +4162,11 @@ static void make_selection_list_nurb(View3D *v3d, ListBase *editnurb, ListBase *
{
ListBase nbase = {NULL, NULL};
NurbSort *nus, *nustest, *headdo, *taildo;
- Nurb *nu;
BPoint *bp;
float dist, headdist, taildist;
int a;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (ED_curve_nurb_select_check(v3d, nu)) {
nus = (NurbSort *)MEM_callocN(sizeof(NurbSort), "sort");
@@ -4472,7 +4408,7 @@ static int merge_nurb(View3D *v3d, Object *obedit)
/* resolution match, to avoid uv rotations */
if (nus1->nu->pntsv == 1) {
- if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsu == nus2->nu->pntsv) {
+ if (ELEM(nus1->nu->pntsu, nus2->nu->pntsu, nus2->nu->pntsv)) {
/* pass */
}
else {
@@ -4480,7 +4416,7 @@ static int merge_nurb(View3D *v3d, Object *obedit)
}
}
else if (nus2->nu->pntsv == 1) {
- if (nus2->nu->pntsu == nus1->nu->pntsu || nus2->nu->pntsu == nus1->nu->pntsv) {
+ if (ELEM(nus2->nu->pntsu, nus1->nu->pntsu, nus1->nu->pntsv)) {
/* pass */
}
else {
@@ -4996,7 +4932,6 @@ bool ed_editnurb_spin(
{
Curve *cu = (Curve *)obedit->data;
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
float cmat[3][3], tmat[3][3], imat[3][3];
float bmat[3][3], rotmat[3][3], scalemat1[3][3], scalemat2[3][3];
float persmat[3][3], persinv[3][3];
@@ -5056,7 +4991,7 @@ bool ed_editnurb_spin(
}
if (ok) {
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (ED_curve_nurb_select_check(v3d, nu)) {
nu->orderv = 4;
nu->flagv |= CU_NURB_CYCLIC;
@@ -5427,8 +5362,6 @@ static int ed_editcurve_addvert(Curve *cu,
View3D *v3d,
const float location_init[3])
{
- Nurb *nu;
-
float center[3];
float temp[3];
uint verts_len;
@@ -5437,7 +5370,7 @@ static int ed_editcurve_addvert(Curve *cu,
zero_v3(center);
verts_len = 0;
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
int i;
if (nu->type == CU_BEZIER) {
BezTriple *bezt;
@@ -5472,7 +5405,7 @@ static int ed_editcurve_addvert(Curve *cu,
ofs[2] = 0.0f;
}
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
if (nu->type == CU_BEZIER) {
BezTriple *bezt;
for (i = 0, bezt = nu->bezt; i < nu->pntsu; i++, bezt++) {
@@ -5511,7 +5444,7 @@ static int ed_editcurve_addvert(Curve *cu,
}
/* nothing selected: create a new curve */
- nu = BKE_curve_nurb_active_get(cu);
+ Nurb *nu = BKE_curve_nurb_active_get(cu);
if (!nu || nu->type == CU_BEZIER) {
Nurb *nurb_new;
@@ -5764,8 +5697,7 @@ static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op))
/* First test: curve? */
if (obedit->type != OB_CURVE) {
- Nurb *nu;
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
if ((nu->pntsv == 1) && (ED_curve_nurb_select_count(v3d, nu) == 1)) {
as_curve = true;
break;
@@ -5819,13 +5751,12 @@ void CURVE_OT_extrude(wmOperatorType *ot)
static bool curve_toggle_cyclic(View3D *v3d, ListBase *editnurb, int direction)
{
- Nurb *nu;
BezTriple *bezt;
BPoint *bp;
int a;
bool changed = false;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->pntsu > 1 || nu->pntsv > 1) {
if (nu->type == CU_POLY) {
a = nu->pntsu;
@@ -5932,10 +5863,9 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
ListBase *editnurb = object_editcurve_get(obedit);
uiPopupMenu *pup;
uiLayout *layout;
- Nurb *nu;
if (obedit->type == OB_SURF) {
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->pntsu > 1 || nu->pntsv > 1) {
if (nu->type == CU_NURBS) {
pup = UI_popup_menu_begin(C, IFACE_("Direction"), ICON_NONE);
@@ -6064,12 +5994,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
Curve *cu = obedit->data;
EditNurb *editnurb = cu->editnurb;
ListBase *nubase = &editnurb->nurbs, newnurb = {NULL, NULL};
- Nurb *nu, *nu1;
+ Nurb *nu1;
BezTriple *bezt, *bezt1, *bezt2;
BPoint *bp, *bp1, *bp2;
int a, b, starta, enda, cut, cyclicut;
- for (nu = nubase->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nubase) {
nu1 = NULL;
starta = enda = cut = -1;
cyclicut = 0;
@@ -6452,7 +6382,7 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
}
}
- for (nu = newnurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &newnurb) {
if (nu->type == CU_BEZIER) {
if (split) {
/* deselect for split operator */
@@ -6620,9 +6550,8 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op))
}
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if ((nu->type == CU_BEZIER) && (nu->pntsu > 2)) {
uint span_step[2] = {nu->pntsu, nu->pntsu};
uint span_len;
@@ -6766,9 +6695,8 @@ static int curve_decimate_exec(bContext *C, wmOperator *op)
{
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
if ((nu->pntsu > 2) && nurb_bezt_flag_any(nu, SELECT)) {
const int error_target_len = max_ii(2, nu->pntsu * ratio);
@@ -6917,7 +6845,6 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob_active = CTX_data_active_object(C);
Curve *cu;
- Nurb *nu, *newnu;
BezTriple *bezt;
BPoint *bp;
ListBase tempbase;
@@ -6955,9 +6882,8 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
/* watch it: switch order here really goes wrong */
mul_m4_m4m4(cmat, imat, ob_iter->obmat);
- nu = cu->nurb.first;
- while (nu) {
- newnu = BKE_nurb_duplicate(nu);
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
+ Nurb *newnu = BKE_nurb_duplicate(nu);
if (ob_active->totcol) { /* TODO, merge material lists */
CLAMP(newnu->mat_nr, 0, ob_active->totcol - 1);
}
@@ -6983,7 +6909,6 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op)
bp++;
}
}
- nu = nu->next;
}
}
@@ -7035,12 +6960,11 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
}
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
BezTriple *bezt;
BPoint *bp;
int a;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->bezt) {
bezt = nu->bezt;
a = nu->pntsu;
diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c
index 684666aba13..5b66d473466 100644
--- a/source/blender/editors/curve/editcurve_add.c
+++ b/source/blender/editors/curve/editcurve_add.c
@@ -141,7 +141,7 @@ Nurb *ED_curve_add_nurbs_primitive(
BKE_nurbList_flag_set(editnurb, SELECT, false);
/* these types call this function to return a Nurb */
- if (stype != CU_PRIM_TUBE && stype != CU_PRIM_DONUT) {
+ if (!ELEM(stype, CU_PRIM_TUBE, CU_PRIM_DONUT)) {
nu = (Nurb *)MEM_callocN(sizeof(Nurb), "addNurbprim");
nu->type = cutype;
nu->resolu = cu->resolu;
@@ -397,8 +397,8 @@ Nurb *ED_curve_add_nurbs_primitive(
break;
case CU_PRIM_SPHERE: /* sphere */
if (cutype == CU_NURBS) {
- const float tmp_cent[3] = {0.f, 0.f, 0.f};
- const float tmp_vec[3] = {0.f, 0.f, 1.f};
+ const float tmp_cent[3] = {0.0f, 0.0f, 0.0f};
+ const float tmp_vec[3] = {0.0f, 0.0f, 1.0f};
nu->pntsu = 5;
nu->pntsv = 1;
@@ -451,8 +451,8 @@ Nurb *ED_curve_add_nurbs_primitive(
break;
case CU_PRIM_DONUT: /* torus */
if (cutype == CU_NURBS) {
- const float tmp_cent[3] = {0.f, 0.f, 0.f};
- const float tmp_vec[3] = {0.f, 0.f, 1.f};
+ const float tmp_cent[3] = {0.0f, 0.0f, 0.0f};
+ const float tmp_vec[3] = {0.0f, 0.0f, 1.0f};
xzproj = 1;
nu = ED_curve_add_nurbs_primitive(C, obedit, mat, CU_NURBS | CU_PRIM_CIRCLE, 0);
diff --git a/source/blender/editors/curve/editcurve_query.c b/source/blender/editors/curve/editcurve_query.c
index 48571ab2a9b..56392aab5bf 100644
--- a/source/blender/editors/curve/editcurve_query.c
+++ b/source/blender/editors/curve/editcurve_query.c
@@ -26,6 +26,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BKE_curve.h"
@@ -170,7 +171,6 @@ void ED_curve_nurb_vert_selected_find(
/* in nu and (bezt or bp) selected are written if there's 1 sel. */
/* if more points selected in 1 spline: return only nu, bezt and bp are 0 */
ListBase *editnurb = &cu->editnurb->nurbs;
- Nurb *nu1;
BezTriple *bezt1;
BPoint *bp1;
int a;
@@ -179,13 +179,13 @@ void ED_curve_nurb_vert_selected_find(
*r_bezt = NULL;
*r_bp = NULL;
- for (nu1 = editnurb->first; nu1; nu1 = nu1->next) {
+ LISTBASE_FOREACH (Nurb *, nu1, editnurb) {
if (nu1->type == CU_BEZIER) {
bezt1 = nu1->bezt;
a = nu1->pntsu;
while (a--) {
if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt1)) {
- if (*r_nu != NULL && *r_nu != nu1) {
+ if (!ELEM(*r_nu, NULL, nu1)) {
*r_nu = NULL;
*r_bp = NULL;
*r_bezt = NULL;
@@ -209,7 +209,7 @@ void ED_curve_nurb_vert_selected_find(
a = nu1->pntsu * nu1->pntsv;
while (a--) {
if (bp1->f1 & SELECT) {
- if (*r_nu != NULL && *r_nu != nu1) {
+ if (!ELEM(*r_nu, NULL, nu1)) {
*r_bp = NULL;
*r_bezt = NULL;
*r_nu = NULL;
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c
index aa4ba332b66..4097275a2b9 100644
--- a/source/blender/editors/curve/editcurve_select.c
+++ b/source/blender/editors/curve/editcurve_select.c
@@ -237,9 +237,7 @@ int ED_curve_select_count(View3D *v3d, struct EditNurb *editnurb)
bool ED_curve_select_check(View3D *v3d, struct EditNurb *editnurb)
{
- Nurb *nu;
-
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
if (ED_curve_nurb_select_check(v3d, nu)) {
return true;
}
@@ -284,13 +282,12 @@ bool ED_curve_deselect_all_multi(struct bContext *C)
bool ED_curve_select_swap(EditNurb *editnurb, bool hide_handles)
{
- Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int a;
bool changed = false;
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
a = nu->pntsu;
@@ -331,7 +328,6 @@ static void select_adjacent_cp(ListBase *editnurb,
const bool cont,
const bool selstatus)
{
- Nurb *nu;
BezTriple *bezt;
BPoint *bp;
int a;
@@ -341,7 +337,7 @@ static void select_adjacent_cp(ListBase *editnurb,
return;
}
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
lastsel = false;
if (nu->type == CU_BEZIER) {
a = nu->pntsu;
@@ -412,7 +408,6 @@ static void select_adjacent_cp(ListBase *editnurb,
static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap, bool selstatus)
{
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
BPoint *bp;
BezTriple *bezt;
Curve *cu;
@@ -425,7 +420,7 @@ static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap
cu = (Curve *)obedit->data;
cu->actvert = CU_ACT_NONE;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
a = nu->pntsu;
@@ -632,10 +627,9 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
Curve *cu = obedit->data;
EditNurb *editnurb = cu->editnurb;
ListBase *nurbs = &editnurb->nurbs;
- Nurb *nu;
bool changed = false;
- for (nu = nurbs->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
if (ED_curve_nurb_select_check(v3d, nu)) {
changed |= ED_curve_nurb_select_all(nu);
}
@@ -887,7 +881,6 @@ void CURVE_OT_select_previous(wmOperatorType *ot)
static void curve_select_more(Object *obedit)
{
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
BPoint *bp, *tempbp;
int a;
short sel = 0;
@@ -897,7 +890,7 @@ static void curve_select_more(Object *obedit)
/* The algorithm is designed to work in planar cases so it */
/* may not be optimal always (example: end of NURBS sphere) */
if (obedit->type == OB_SURF) {
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
BLI_bitmap *selbpoints;
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
@@ -997,7 +990,6 @@ void CURVE_OT_select_more(wmOperatorType *ot)
static void curve_select_less(Object *obedit)
{
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int a;
@@ -1005,7 +997,7 @@ static void curve_select_less(Object *obedit)
bool lastsel = false;
if (obedit->type == OB_SURF) {
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
BLI_bitmap *selbpoints;
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
@@ -1077,7 +1069,7 @@ static void curve_select_less(Object *obedit)
}
}
else {
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
lastsel = false;
/* check what type of curve/nurb it is */
if (nu->type == CU_BEZIER) {
@@ -1210,14 +1202,13 @@ void CURVE_OT_select_less(wmOperatorType *ot)
static void curve_select_random(ListBase *editnurb, float randfac, int seed, bool select)
{
- Nurb *nu;
BezTriple *bezt;
BPoint *bp;
int a;
RNG *rng = BLI_rng_new_srandom(seed);
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
a = nu->pntsu;
@@ -1431,9 +1422,7 @@ void CURVE_OT_select_nth(wmOperatorType *ot)
}
/* -------------------------------------------------------------------- */
-/* Select Similar */
-
-/** \name Select Similar
+/** \name Select Similar Operator
* \{ */
static const EnumPropertyItem curve_prop_similar_compare_types[] = {
@@ -1702,8 +1691,7 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
Curve *cu = obedit->data;
EditNurb *editnurb = cu->editnurb;
- Nurb *nu;
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
if (!ED_curve_nurb_select_check(v3d, nu)) {
continue;
}
@@ -1736,9 +1724,8 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
Curve *cu = obedit->data;
EditNurb *editnurb = cu->editnurb;
bool changed = false;
- Nurb *nu;
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
switch (optype) {
case SIMCURHAND_TYPE: {
if (nu->type & type_ref) {
@@ -1797,9 +1784,7 @@ void CURVE_OT_select_similar(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/* Select Shortest Path */
-
-/** \name Select Path
+/** \name Select Shortest Path Operator
* \{ */
static float curve_calc_dist_pair(const Nurb *nu, int a, int b)
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index 2a880c11afb..d6744472c0e 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -626,7 +626,7 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/** \} */
@@ -635,7 +635,10 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot)
/** \name Text To Object
* \{ */
-static void txt_add_object(bContext *C, TextLine *firstline, int totline, const float offset[3])
+static void txt_add_object(bContext *C,
+ const TextLine *firstline,
+ int totline,
+ const float offset[3])
{
Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
@@ -644,11 +647,11 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
Curve *cu;
Object *obedit;
Base *base;
- struct TextLine *tmp;
+ const struct TextLine *tmp;
int nchars = 0, nbytes = 0;
char *s;
int a;
- const float rot[3] = {0.f, 0.f, 0.f};
+ const float rot[3] = {0.0f, 0.0f, 0.0f};
obedit = BKE_object_add(bmain, view_layer, OB_FONT, NULL);
base = view_layer->basact;
@@ -709,10 +712,10 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, obedit);
}
-void ED_text_to_object(bContext *C, Text *text, const bool split_lines)
+void ED_text_to_object(bContext *C, const Text *text, const bool split_lines)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
- TextLine *line;
+ const TextLine *line;
float offset[3];
int linenum = 0;
@@ -1692,8 +1695,8 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (event_val && (ascii || event->utf8_buf[0])) {
/* handle case like TAB (== 9) */
- if ((ascii > 31 && ascii < 254 && ascii != 127) || (ascii == 13) || (ascii == 10) ||
- (ascii == 8) || (event->utf8_buf[0])) {
+ if ((ascii > 31 && ascii < 254 && ascii != 127) || (ELEM(ascii, 13, 10)) || (ascii == 8) ||
+ (event->utf8_buf[0])) {
if (accentcode) {
if (ef->pos > 0) {
@@ -2157,7 +2160,7 @@ void FONT_OT_open(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/** \} */
diff --git a/source/blender/editors/curve/editfont_undo.c b/source/blender/editors/curve/editfont_undo.c
index ef9bb7e0c88..61c05f62af7 100644
--- a/source/blender/editors/curve/editfont_undo.c
+++ b/source/blender/editors/curve/editfont_undo.c
@@ -74,6 +74,7 @@ typedef struct UndoFont {
#ifdef USE_ARRAY_STORE
+/* -------------------------------------------------------------------- */
/** \name Array Store
* \{ */
diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt
index b2c618073f4..1e91edbb3c0 100644
--- a/source/blender/editors/gpencil/CMakeLists.txt
+++ b/source/blender/editors/gpencil/CMakeLists.txt
@@ -42,6 +42,7 @@ set(SRC
gpencil_convert.c
gpencil_data.c
gpencil_edit.c
+ gpencil_edit_curve.c
gpencil_fill.c
gpencil_interpolate.c
gpencil_merge.c
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index c06a2f06a98..a73bf8154d9 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -910,7 +910,7 @@ static void annotation_stroke_newfrombuffer(tGPsdata *p)
int totarrowpoints = runtime.arrow_end_style;
/* Setting up arrow stroke. */
- bGPDstroke *e_arrow_gps = BKE_gpencil_stroke_duplicate(gps, false);
+ bGPDstroke *e_arrow_gps = BKE_gpencil_stroke_duplicate(gps, false, false);
annotation_stroke_arrow_allocate(e_arrow_gps, totarrowpoints);
/* Set pointer to first non-initialized point. */
@@ -931,7 +931,7 @@ static void annotation_stroke_newfrombuffer(tGPsdata *p)
int totarrowpoints = runtime.arrow_start_style;
/* Setting up arrow stroke. */
- bGPDstroke *s_arrow_gps = BKE_gpencil_stroke_duplicate(gps, false);
+ bGPDstroke *s_arrow_gps = BKE_gpencil_stroke_duplicate(gps, false, false);
annotation_stroke_arrow_allocate(s_arrow_gps, totarrowpoints);
/* Set pointer to first non-initialized point. */
@@ -1198,7 +1198,7 @@ static void annotation_stroke_eraser_dostroke(tGPsdata *p,
/* Second Pass: Remove any points that are tagged */
if (do_cull) {
- gpencil_stroke_delete_tagged_points(gpf, gps, gps->next, GP_SPOINT_TAG, false, 0);
+ gpencil_stroke_delete_tagged_points(p->gpd, gpf, gps, gps->next, GP_SPOINT_TAG, false, 0);
}
}
}
@@ -1432,6 +1432,41 @@ static bool annotation_session_initdata(bContext *C, tGPsdata *p)
return 1;
}
+/* Enable the annotations in the current space. */
+static void annotation_visible_on_space(tGPsdata *p)
+{
+ ScrArea *area = p->area;
+ switch (area->spacetype) {
+ case SPACE_VIEW3D: {
+ View3D *v3d = (View3D *)area->spacedata.first;
+ v3d->flag2 |= V3D_SHOW_ANNOTATION;
+ break;
+ }
+ case SPACE_SEQ: {
+ SpaceSeq *sseq = (SpaceSeq *)area->spacedata.first;
+ sseq->flag |= SEQ_SHOW_GPENCIL;
+ break;
+ }
+ case SPACE_IMAGE: {
+ SpaceImage *sima = (SpaceImage *)area->spacedata.first;
+ sima->flag |= SI_SHOW_GPENCIL;
+ break;
+ }
+ case SPACE_NODE: {
+ SpaceNode *snode = (SpaceNode *)area->spacedata.first;
+ snode->flag |= SNODE_SHOW_GPENCIL;
+ break;
+ }
+ case SPACE_CLIP: {
+ SpaceClip *sclip = (SpaceClip *)area->spacedata.first;
+ sclip->flag |= SC_SHOW_ANNOTATION;
+ break;
+ }
+ default:
+ break;
+ }
+}
+
/* init new painting session */
static tGPsdata *annotation_session_initpaint(bContext *C)
{
@@ -1458,6 +1493,9 @@ static tGPsdata *annotation_session_initpaint(bContext *C)
*/
p->radius = U.gp_eraser;
+ /* Annotations must be always visible when use it. */
+ annotation_visible_on_space(p);
+
/* return context data for running paint operator */
return p;
}
@@ -2003,7 +2041,7 @@ static void annotation_draw_apply(wmOperator *op, tGPsdata *p, Depsgraph *depsgr
short ok = annotation_stroke_addpoint(p, p->mval, p->pressure, p->curtime);
/* handle errors while adding point */
- if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) {
+ if (ELEM(ok, GP_STROKEADD_FULL, GP_STROKEADD_OVERFLOW)) {
/* finish off old stroke */
annotation_paint_strokeend(p);
/* And start a new one!!! Else, projection errors! */
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index d4f3c4d7f5e..aae31b11025 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -486,7 +486,7 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
*/
for (gps = gpfs->strokes.first; gps; gps = gps->next) {
/* make a copy of stroke, then of its points array */
- gpsn = BKE_gpencil_stroke_duplicate(gps, true);
+ gpsn = BKE_gpencil_stroke_duplicate(gps, true, true);
/* append stroke to frame */
BLI_addtail(&gpf->strokes, gpsn);
diff --git a/source/blender/editors/gpencil/gpencil_add_monkey.c b/source/blender/editors/gpencil/gpencil_add_monkey.c
index 23ca5241866..315b3c281da 100644
--- a/source/blender/editors/gpencil/gpencil_add_monkey.c
+++ b/source/blender/editors/gpencil/gpencil_add_monkey.c
@@ -861,115 +861,115 @@ void ED_gpencil_create_monkey(bContext *C, Object *ob, float mat[4][4])
/* generate strokes */
gps = BKE_gpencil_stroke_add(frameFills, color_Skin, 270, 75, false);
BKE_gpencil_stroke_add_points(gps, data0, 270, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Skin_Shadow, 33, 60, false);
BKE_gpencil_stroke_add_points(gps, data1, 33, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Skin_Shadow, 18, 60, false);
BKE_gpencil_stroke_add_points(gps, data2, 18, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Skin_Light, 64, 60, false);
BKE_gpencil_stroke_add_points(gps, data3, 64, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Skin_Light, 33, 60, false);
BKE_gpencil_stroke_add_points(gps, data4, 33, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Skin_Light, 64, 60, false);
BKE_gpencil_stroke_add_points(gps, data5, 64, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Skin_Light, 33, 60, false);
BKE_gpencil_stroke_add_points(gps, data6, 33, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Skin_Light, 18, 40, false);
BKE_gpencil_stroke_add_points(gps, data7, 18, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Eyes, 49, 60, false);
BKE_gpencil_stroke_add_points(gps, data8, 49, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Skin_Shadow, 33, 60, false);
BKE_gpencil_stroke_add_points(gps, data9, 33, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Eyes, 49, 60, false);
BKE_gpencil_stroke_add_points(gps, data10, 49, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Skin_Shadow, 18, 40, false);
BKE_gpencil_stroke_add_points(gps, data11, 18, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameFills, color_Skin_Shadow, 18, 40, false);
BKE_gpencil_stroke_add_points(gps, data12, 18, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 33, 60, false);
BKE_gpencil_stroke_add_points(gps, data13, 33, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 33, 60, false);
BKE_gpencil_stroke_add_points(gps, data14, 33, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 65, 60, false);
BKE_gpencil_stroke_add_points(gps, data15, 65, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 34, 60, false);
BKE_gpencil_stroke_add_points(gps, data16, 34, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 33, 60, false);
BKE_gpencil_stroke_add_points(gps, data17, 33, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 33, 40, false);
BKE_gpencil_stroke_add_points(gps, data18, 33, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 34, 40, false);
BKE_gpencil_stroke_add_points(gps, data19, 34, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 33, 60, false);
BKE_gpencil_stroke_add_points(gps, data20, 33, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 64, 60, false);
BKE_gpencil_stroke_add_points(gps, data21, 64, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Pupils, 26, 60, false);
BKE_gpencil_stroke_add_points(gps, data22, 26, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Pupils, 26, 60, false);
BKE_gpencil_stroke_add_points(gps, data23, 26, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 33, 60, false);
BKE_gpencil_stroke_add_points(gps, data24, 33, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 18, 40, false);
BKE_gpencil_stroke_add_points(gps, data25, 18, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 18, 40, false);
BKE_gpencil_stroke_add_points(gps, data26, 18, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps = BKE_gpencil_stroke_add(frameLines, color_Black, 33, 60, false);
BKE_gpencil_stroke_add_points(gps, data27, 33, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
/* update depsgraph */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
diff --git a/source/blender/editors/gpencil/gpencil_add_stroke.c b/source/blender/editors/gpencil/gpencil_add_stroke.c
index 39a2d594c13..f26fd936d40 100644
--- a/source/blender/editors/gpencil/gpencil_add_stroke.c
+++ b/source/blender/editors/gpencil/gpencil_add_stroke.c
@@ -249,7 +249,7 @@ void ED_gpencil_create_stroke(bContext *C, Object *ob, float mat[4][4])
/* generate stroke */
gps = BKE_gpencil_stroke_add(frame_lines, color_black, 175, 75, false);
BKE_gpencil_stroke_add_points(gps, data0, 175, mat);
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
/* update depsgraph */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 2d9f49fa1ed..293ce370a0b 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -1616,9 +1616,13 @@ static bool gpencil_convert_poll_property(const bContext *UNUSED(C),
const bool valid_timing = RNA_boolean_get(ptr, "use_timing_data");
/* Always show those props */
- if (STREQ(prop_id, "type") || STREQ(prop_id, "use_normalize_weights") ||
- STREQ(prop_id, "radius_multiplier") || STREQ(prop_id, "use_link_strokes") ||
- STREQ(prop_id, "bevel_depth") || STREQ(prop_id, "bevel_resolution")) {
+ if (STR_ELEM(prop_id,
+ "type",
+ "use_normalize_weights",
+ "radius_multiplier",
+ "use_link_strokes",
+ "bevel_depth",
+ "bevel_resolution")) {
return true;
}
@@ -1635,7 +1639,7 @@ static bool gpencil_convert_poll_property(const bContext *UNUSED(C),
if (timing_mode != GP_STROKECONVERT_TIMING_NONE) {
/* Only show when link_stroke is true and stroke timing is enabled */
- if (STREQ(prop_id, "frame_range") || STREQ(prop_id, "start_frame")) {
+ if (STR_ELEM(prop_id, "frame_range", "start_frame")) {
return true;
}
@@ -1851,12 +1855,12 @@ static int image_to_gpencil_exec(bContext *C, wmOperator *op)
bGPdata *gpd = (bGPdata *)ob->data;
bGPDlayer *gpl = BKE_gpencil_layer_addnew(gpd, "Image Layer", true);
bGPDframe *gpf = BKE_gpencil_frame_addnew(gpl, CFRA);
- done = BKE_gpencil_from_image(sima, gpf, size, is_mask);
+ done = BKE_gpencil_from_image(sima, gpd, gpf, size, is_mask);
if (done) {
/* Delete any selected point. */
LISTBASE_FOREACH_MUTABLE (bGPDstroke *, gps, &gpf->strokes) {
- gpencil_stroke_delete_tagged_points(gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
+ gpencil_stroke_delete_tagged_points(gpd, gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
}
BKE_reportf(op->reports, RPT_INFO, "Object created");
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 07a1b34fa84..a963632a01b 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -580,7 +580,7 @@ static int gpencil_layer_duplicate_object_exec(bContext *C, wmOperator *op)
LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) {
/* Make copy of source stroke. */
- bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true);
+ bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true, true);
/* Check if material is in destination object,
* otherwise add the slot with the material. */
@@ -1531,6 +1531,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
const int direction = RNA_enum_get(op->ptr, "direction");
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+ bool changed = false;
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
/* temp listbase to store selected strokes */
ListBase selected = {NULL};
@@ -1557,14 +1558,14 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
continue;
}
/* some stroke is already at front*/
- if ((direction == GP_STROKE_MOVE_TOP) || (direction == GP_STROKE_MOVE_UP)) {
+ if (ELEM(direction, GP_STROKE_MOVE_TOP, GP_STROKE_MOVE_UP)) {
if (gps == gpf->strokes.last) {
gpf_lock = true;
continue;
}
}
/* some stroke is already at botom */
- if ((direction == GP_STROKE_MOVE_BOTTOM) || (direction == GP_STROKE_MOVE_DOWN)) {
+ if (ELEM(direction, GP_STROKE_MOVE_BOTTOM, GP_STROKE_MOVE_DOWN)) {
if (gps == gpf->strokes.first) {
gpf_lock = true;
continue;
@@ -1589,7 +1590,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
break;
/* Bring Forward */
case GP_STROKE_MOVE_UP:
- for (LinkData *link = selected.last; link; link = link->prev) {
+ LISTBASE_FOREACH_BACKWARD (LinkData *, link, &selected) {
gps = link->data;
BLI_listbase_link_move(&gpf->strokes, gps, 1);
}
@@ -1603,7 +1604,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
break;
/* Send to Back */
case GP_STROKE_MOVE_BOTTOM:
- for (LinkData *link = selected.last; link; link = link->prev) {
+ LISTBASE_FOREACH_BACKWARD (LinkData *, link, &selected) {
gps = link->data;
BLI_remlink(&gpf->strokes, gps);
BLI_addhead(&gpf->strokes, gps);
@@ -1612,6 +1613,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
default:
BLI_assert(0);
break;
+ changed = true;
}
}
BLI_freelistN(&selected);
@@ -1625,9 +1627,11 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- /* notifiers */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ /* notifiers */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -1693,6 +1697,7 @@ static int gpencil_stroke_change_color_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ bool changed = false;
/* loop all strokes */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
@@ -1717,6 +1722,8 @@ static int gpencil_stroke_change_color_exec(bContext *C, wmOperator *op)
/* assign new color */
gps->mat_nr = idx;
+
+ changed = true;
}
}
}
@@ -1728,9 +1735,11 @@ static int gpencil_stroke_change_color_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- /* notifiers */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ /* notifiers */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -1757,9 +1766,7 @@ void GPENCIL_OT_stroke_change_color(wmOperatorType *ot)
static int gpencil_material_lock_unsused_exec(bContext *C, wmOperator *UNUSED(op))
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
-
Object *ob = CTX_data_active_object(C);
-
short *totcol = BKE_object_material_len_p(ob);
/* sanity checks */
@@ -1776,6 +1783,7 @@ static int gpencil_material_lock_unsused_exec(bContext *C, wmOperator *UNUSED(op
}
}
+ bool changed = false;
/* loop all selected strokes and unlock any color */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* only editable and visible layers are considered */
@@ -1793,19 +1801,24 @@ static int gpencil_material_lock_unsused_exec(bContext *C, wmOperator *UNUSED(op
tmp_ma->gp_style->flag &= ~GP_MATERIAL_LOCKED;
DEG_id_tag_update(&tmp_ma->id, ID_RECALC_COPY_ON_WRITE);
}
+
+ changed = true;
}
}
}
}
- /* updates */
- DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
- /* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+ if (changed) {
+ /* updates */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
- /* notifiers */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ /* copy on write tag is needed, or else no refresh happens */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+
+ /* notifiers */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -3035,7 +3048,7 @@ static int gpencil_material_isolate_exec(bContext *C, wmOperator *op)
for (short i = 0; i < *totcol; i++) {
ma = BKE_gpencil_material(ob, i + 1);
/* Skip if this is the active one */
- if ((ma == NULL) || (ma == active_ma)) {
+ if (ELEM(ma, NULL, active_ma)) {
continue;
}
@@ -3476,7 +3489,6 @@ static int gpencil_set_active_material_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
- bool changed = false;
/* Sanity checks. */
if (gpd == NULL) {
@@ -3484,6 +3496,7 @@ static int gpencil_set_active_material_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ bool changed = false;
/* Loop all selected strokes. */
GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
if (gps->flag & GP_STROKE_SELECT) {
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index d54bdf552eb..f2c3804a067 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -52,6 +52,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_gpencil.h"
+#include "BKE_gpencil_curve.h"
#include "BKE_gpencil_geom.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
@@ -145,6 +146,18 @@ static bool gpencil_editmode_toggle_poll(bContext *C)
return ED_gpencil_data_get_active(C) != NULL;
}
+static bool gpencil_stroke_not_in_curve_edit_mode(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ if ((ob == NULL) || (ob->type != OB_GPENCIL)) {
+ return false;
+ }
+ bGPdata *gpd = (bGPdata *)ob->data;
+ bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
+
+ return (gpl != NULL && !GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd));
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -195,6 +208,22 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op)
ob->mode = mode;
}
+ /* Recalculate editcurves for strokes where the geometry/vertex colors have changed */
+ if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) {
+ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
+ {
+ if (gpc->flag & GP_CURVE_NEEDS_STROKE_UPDATE) {
+ BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps);
+ /* Update the selection from the stroke to the curve. */
+ BKE_gpencil_editcurve_stroke_sync_selection(gps, gps->editcurve);
+
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+ }
+ GP_EDITABLE_CURVES_END(gps_iter);
+ }
+
/* setup other modes */
ED_gpencil_setup_modes(C, gpd, mode);
/* set cache as dirty */
@@ -813,7 +842,8 @@ void GPENCIL_OT_selection_opacity_toggle(wmOperatorType *ot)
* \{ */
/* Make copies of selected point segments in a selected stroke */
-static void gpencil_duplicate_points(const bGPDstroke *gps,
+static void gpencil_duplicate_points(bGPdata *gpd,
+ const bGPDstroke *gps,
ListBase *new_strokes,
const char *layername)
{
@@ -853,7 +883,7 @@ static void gpencil_duplicate_points(const bGPDstroke *gps,
bGPDstroke *gpsd;
/* make a stupid copy first of the entire stroke (to get the flags too) */
- gpsd = BKE_gpencil_stroke_duplicate((bGPDstroke *)gps, false);
+ gpsd = BKE_gpencil_stroke_duplicate((bGPDstroke *)gps, false, true);
/* saves original layer name */
BLI_strncpy(gpsd->runtime.tmp_layerinfo, layername, sizeof(gpsd->runtime.tmp_layerinfo));
@@ -877,7 +907,7 @@ static void gpencil_duplicate_points(const bGPDstroke *gps,
}
}
- BKE_gpencil_stroke_geometry_update(gpsd);
+ BKE_gpencil_stroke_geometry_update(gpd, gpsd);
/* add to temp buffer */
gpsd->next = gpsd->prev = NULL;
@@ -894,6 +924,7 @@ static void gpencil_duplicate_points(const bGPDstroke *gps,
static int gpencil_duplicate_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
@@ -905,69 +936,80 @@ static int gpencil_duplicate_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* for each visible (and editable) layer's selected strokes,
- * copy the strokes into a temporary buffer, then append
- * once all done
- */
- CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
- ListBase new_strokes = {NULL, NULL};
- bGPDframe *gpf = gpl->actframe;
- bGPDstroke *gps;
-
- if (gpf == NULL) {
- continue;
- }
+ bool changed = false;
+ if (is_curve_edit) {
+ BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+ }
+ else {
+ /* for each visible (and editable) layer's selected strokes,
+ * copy the strokes into a temporary buffer, then append
+ * once all done
+ */
+ CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
+ ListBase new_strokes = {NULL, NULL};
+ bGPDframe *gpf = gpl->actframe;
+ bGPDstroke *gps;
- /* make copies of selected strokes, and deselect these once we're done */
- for (gps = gpf->strokes.first; gps; gps = gps->next) {
- /* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false) {
+ if (gpf == NULL) {
continue;
}
- if (gps->flag & GP_STROKE_SELECT) {
- if (gps->totpoints == 1) {
- /* Special Case: If there's just a single point in this stroke... */
- bGPDstroke *gpsd;
+ /* make copies of selected strokes, and deselect these once we're done */
+ for (gps = gpf->strokes.first; gps; gps = gps->next) {
+ /* skip strokes that are invalid for current view */
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
+ continue;
+ }
- /* make direct copies of the stroke and its points */
- gpsd = BKE_gpencil_stroke_duplicate(gps, true);
+ if (gps->flag & GP_STROKE_SELECT) {
+ if (gps->totpoints == 1) {
+ /* Special Case: If there's just a single point in this stroke... */
+ bGPDstroke *gpsd;
- BLI_strncpy(gpsd->runtime.tmp_layerinfo, gpl->info, sizeof(gpsd->runtime.tmp_layerinfo));
+ /* make direct copies of the stroke and its points */
+ gpsd = BKE_gpencil_stroke_duplicate(gps, true, true);
- /* Initialize triangle information. */
- BKE_gpencil_stroke_geometry_update(gpsd);
+ BLI_strncpy(
+ gpsd->runtime.tmp_layerinfo, gpl->info, sizeof(gpsd->runtime.tmp_layerinfo));
- /* add to temp buffer */
- gpsd->next = gpsd->prev = NULL;
- BLI_addtail(&new_strokes, gpsd);
- }
- else {
- /* delegate to a helper, as there's too much to fit in here (for copying subsets)... */
- gpencil_duplicate_points(gps, &new_strokes, gpl->info);
- }
+ /* Initialize triangle information. */
+ BKE_gpencil_stroke_geometry_update(gpd, gpsd);
- /* deselect original stroke, or else the originals get moved too
- * (when using the copy + move macro)
- */
- bGPDspoint *pt;
- int i;
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- pt->flag &= ~GP_SPOINT_SELECT;
+ /* add to temp buffer */
+ gpsd->next = gpsd->prev = NULL;
+ BLI_addtail(&new_strokes, gpsd);
+ }
+ else {
+ /* delegate to a helper, as there's too much to fit in here (for copying subsets)... */
+ gpencil_duplicate_points(gpd, gps, &new_strokes, gpl->info);
+ }
+
+ /* deselect original stroke, or else the originals get moved too
+ * (when using the copy + move macro)
+ */
+ bGPDspoint *pt;
+ int i;
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ }
+ gps->flag &= ~GP_STROKE_SELECT;
+
+ changed = true;
}
- gps->flag &= ~GP_STROKE_SELECT;
}
- }
- /* add all new strokes in temp buffer to the frame (preventing double-copies) */
- BLI_movelisttolist(&gpf->strokes, &new_strokes);
- BLI_assert(new_strokes.first == NULL);
+ /* add all new strokes in temp buffer to the frame (preventing double-copies) */
+ BLI_movelisttolist(&gpf->strokes, &new_strokes);
+ BLI_assert(new_strokes.first == NULL);
+ }
+ CTX_DATA_END;
}
- CTX_DATA_END;
- /* updates */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ /* updates */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -1028,7 +1070,7 @@ static void gpencil_copy_move_point(bGPDstroke *gps,
}
}
-static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
+static void gpencil_add_move_points(bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps)
{
bGPDspoint *temp_points = NULL;
MDeformVert *temp_dverts = NULL;
@@ -1042,14 +1084,14 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
/* review points in the middle of stroke to create new strokes */
for (int i = 0; i < gps->totpoints; i++) {
/* skip first and last point */
- if ((i == 0) || (i == gps->totpoints - 1)) {
+ if (ELEM(i, 0, gps->totpoints - 1)) {
continue;
}
pt = &gps->points[i];
if (pt->flag == GP_SPOINT_SELECT) {
/* duplicate original stroke data */
- bGPDstroke *gps_new = BKE_gpencil_stroke_duplicate(gps, false);
+ bGPDstroke *gps_new = BKE_gpencil_stroke_duplicate(gps, false, true);
gps_new->prev = gps_new->next = NULL;
/* add new points array */
@@ -1067,8 +1109,8 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
gpencil_copy_move_point(gps_new, gps->points, gps->dvert, i, 0, true);
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
- BKE_gpencil_stroke_geometry_update(gps_new);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps_new);
/* deselect orinal point */
pt->flag &= ~GP_SPOINT_SELECT;
@@ -1143,7 +1185,7 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
MEM_SAFE_FREE(temp_points);
MEM_SAFE_FREE(temp_dverts);
@@ -1155,10 +1197,100 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
}
}
+static void gpencil_curve_extrude_points(bGPdata *gpd,
+ bGPDframe *gpf,
+ bGPDstroke *gps,
+ bGPDcurve *gpc)
+{
+ const int old_num_points = gpc->tot_curve_points;
+ const bool first_select = gpc->curve_points[0].flag & GP_CURVE_POINT_SELECT;
+ bool last_select = gpc->curve_points[old_num_points - 1].flag & GP_CURVE_POINT_SELECT;
+
+ /* iterate over middle points */
+ for (int i = 1; i < gpc->tot_curve_points - 1; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+
+ /* Create new stroke if selected point */
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ bGPDstroke *gps_new = BKE_gpencil_stroke_duplicate(gps, false, false);
+ gps_new->points = NULL;
+ gps_new->flag &= ~GP_STROKE_CYCLIC;
+ gps_new->prev = gps_new->next = NULL;
+
+ gps_new->editcurve = BKE_gpencil_stroke_editcurve_new(2);
+ bGPDcurve *new_gpc = gps_new->editcurve;
+ for (int j = 0; j < new_gpc->tot_curve_points; j++) {
+ bGPDcurve_point *gpc_pt_new = &new_gpc->curve_points[j];
+ memcpy(gpc_pt_new, gpc_pt, sizeof(bGPDcurve_point));
+ gpc_pt_new->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(&gpc_pt_new->bezt);
+ }
+
+ /* select last point */
+ bGPDcurve_point *gpc_pt_last = &new_gpc->curve_points[1];
+ gpc_pt_last->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_IDX(&gpc_pt_last->bezt, 1);
+ gps_new->editcurve->flag |= GP_CURVE_SELECT;
+
+ BLI_insertlinkafter(&gpf->strokes, gps, gps_new);
+
+ gps_new->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps_new);
+
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(&gpc_pt->bezt);
+ }
+ }
+
+ /* Edgcase for single curve point. */
+ if (gpc->tot_curve_points == 1) {
+ last_select = false;
+ }
+
+ if (first_select || last_select) {
+ int new_num_points = old_num_points;
+
+ if (first_select) {
+ new_num_points++;
+ }
+ if (last_select) {
+ new_num_points++;
+ }
+
+ /* Grow the array */
+ gpc->tot_curve_points = new_num_points;
+ gpc->curve_points = MEM_recallocN(gpc->curve_points, sizeof(bGPDcurve_point) * new_num_points);
+
+ if (first_select) {
+ /* shift points by one */
+ memmove(
+ &gpc->curve_points[1], &gpc->curve_points[0], sizeof(bGPDcurve_point) * old_num_points);
+
+ bGPDcurve_point *old_first = &gpc->curve_points[1];
+
+ old_first->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(&old_first->bezt);
+ }
+
+ if (last_select) {
+ bGPDcurve_point *old_last = &gpc->curve_points[gpc->tot_curve_points - 2];
+ bGPDcurve_point *new_last = &gpc->curve_points[gpc->tot_curve_points - 1];
+ memcpy(new_last, old_last, sizeof(bGPDcurve_point));
+
+ old_last->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(&old_last->bezt);
+ }
+
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+}
+
static int gpencil_extrude_exec(bContext *C, wmOperator *op)
{
Object *obact = CTX_data_active_object(C);
bGPdata *gpd = (bGPdata *)obact->data;
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
bGPDstroke *gps = NULL;
@@ -1167,6 +1299,7 @@ static int gpencil_extrude_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ bool changed = false;
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
@@ -1182,9 +1315,22 @@ static int gpencil_extrude_exec(bContext *C, wmOperator *op)
continue;
}
- if (gps->flag & GP_STROKE_SELECT) {
- gpencil_add_move_points(gpf, gps);
+ if (is_curve_edit) {
+ if (gps->editcurve == NULL) {
+ continue;
+ }
+ bGPDcurve *gpc = gps->editcurve;
+ if (gpc->flag & GP_CURVE_SELECT) {
+ gpencil_curve_extrude_points(gpd, gpf, gps, gpc);
+ }
+ }
+ else {
+ if (gps->flag & GP_STROKE_SELECT) {
+ gpencil_add_move_points(gpd, gpf, gps);
+ }
}
+
+ changed = true;
}
/* if not multiedit, exit loop*/
if (!is_multiedit) {
@@ -1195,10 +1341,13 @@ static int gpencil_extrude_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- /* updates */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
- DEG_id_tag_update(&obact->id, ID_RECALC_COPY_ON_WRITE);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ /* updates */
+ DEG_id_tag_update(&gpd->id,
+ ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&obact->id, ID_RECALC_COPY_ON_WRITE);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -1352,6 +1501,7 @@ static int gpencil_strokes_copy_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
@@ -1366,56 +1516,62 @@ static int gpencil_strokes_copy_exec(bContext *C, wmOperator *op)
/* clear the buffer first */
ED_gpencil_strokes_copybuf_free();
- /* for each visible (and editable) layer's selected strokes,
- * copy the strokes into a temporary buffer, then append
- * once all done
- */
- CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
- bGPDframe *gpf = gpl->actframe;
- bGPDstroke *gps;
-
- if (gpf == NULL) {
- continue;
- }
+ if (is_curve_edit) {
+ BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+ }
+ else {
+ /* for each visible (and editable) layer's selected strokes,
+ * copy the strokes into a temporary buffer, then append
+ * once all done
+ */
+ CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
+ bGPDframe *gpf = gpl->actframe;
+ bGPDstroke *gps;
- /* make copies of selected strokes, and deselect these once we're done */
- for (gps = gpf->strokes.first; gps; gps = gps->next) {
- /* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false) {
+ if (gpf == NULL) {
continue;
}
- if (gps->flag & GP_STROKE_SELECT) {
- if (gps->totpoints == 1) {
- /* Special Case: If there's just a single point in this stroke... */
- bGPDstroke *gpsd;
-
- /* make direct copies of the stroke and its points */
- gpsd = BKE_gpencil_stroke_duplicate(gps, false);
-
- /* saves original layer name */
- BLI_strncpy(gpsd->runtime.tmp_layerinfo, gpl->info, sizeof(gpsd->runtime.tmp_layerinfo));
- gpsd->points = MEM_dupallocN(gps->points);
- if (gps->dvert != NULL) {
- gpsd->dvert = MEM_dupallocN(gps->dvert);
- BKE_gpencil_stroke_weights_duplicate(gps, gpsd);
- }
+ /* make copies of selected strokes, and deselect these once we're done */
+ for (gps = gpf->strokes.first; gps; gps = gps->next) {
+ /* skip strokes that are invalid for current view */
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
+ continue;
+ }
- /* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gpsd);
+ if (gps->flag & GP_STROKE_SELECT) {
+ if (gps->totpoints == 1) {
+ /* Special Case: If there's just a single point in this stroke... */
+ bGPDstroke *gpsd;
+
+ /* make direct copies of the stroke and its points */
+ gpsd = BKE_gpencil_stroke_duplicate(gps, false, true);
+
+ /* saves original layer name */
+ BLI_strncpy(
+ gpsd->runtime.tmp_layerinfo, gpl->info, sizeof(gpsd->runtime.tmp_layerinfo));
+ gpsd->points = MEM_dupallocN(gps->points);
+ if (gps->dvert != NULL) {
+ gpsd->dvert = MEM_dupallocN(gps->dvert);
+ BKE_gpencil_stroke_weights_duplicate(gps, gpsd);
+ }
- /* add to temp buffer */
- gpsd->next = gpsd->prev = NULL;
- BLI_addtail(&gpencil_strokes_copypastebuf, gpsd);
- }
- else {
- /* delegate to a helper, as there's too much to fit in here (for copying subsets)... */
- gpencil_duplicate_points(gps, &gpencil_strokes_copypastebuf, gpl->info);
+ /* Calc geometry data. */
+ BKE_gpencil_stroke_geometry_update(gpd, gpsd);
+
+ /* add to temp buffer */
+ gpsd->next = gpsd->prev = NULL;
+ BLI_addtail(&gpencil_strokes_copypastebuf, gpsd);
+ }
+ else {
+ /* delegate to a helper, as there's too much to fit in here (for copying subsets)... */
+ gpencil_duplicate_points(gpd, gps, &gpencil_strokes_copypastebuf, gpl->info);
+ }
}
}
}
+ CTX_DATA_END;
}
- CTX_DATA_END;
/* Build up hash of material colors used in these strokes */
if (gpencil_strokes_copypastebuf.first) {
@@ -1493,6 +1649,7 @@ static int gpencil_strokes_paste_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = (bGPdata *)ob->data;
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); /* only use active for copy merge */
Scene *scene = CTX_data_scene(C);
bGPDframe *gpf;
@@ -1556,46 +1713,52 @@ static int gpencil_strokes_paste_exec(bContext *C, wmOperator *op)
/* Ensure that all the necessary colors exist */
new_colors = gpencil_copybuf_validate_colormap(C);
- /* Copy over the strokes from the buffer (and adjust the colors) */
- bGPDstroke *gps_init = (!on_back) ? gpencil_strokes_copypastebuf.first :
- gpencil_strokes_copypastebuf.last;
- for (bGPDstroke *gps = gps_init; gps; gps = (!on_back) ? gps->next : gps->prev) {
- if (ED_gpencil_stroke_can_use(C, gps)) {
- /* Need to verify if layer exists */
- if (type != GP_COPY_TO_ACTIVE) {
- gpl = BLI_findstring(&gpd->layers, gps->runtime.tmp_layerinfo, offsetof(bGPDlayer, info));
- if (gpl == NULL) {
- /* no layer - use active (only if layer deleted before paste) */
- gpl = BKE_gpencil_layer_active_get(gpd);
+ if (is_curve_edit) {
+ BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+ }
+ else {
+ /* Copy over the strokes from the buffer (and adjust the colors) */
+ bGPDstroke *gps_init = (!on_back) ? gpencil_strokes_copypastebuf.first :
+ gpencil_strokes_copypastebuf.last;
+ for (bGPDstroke *gps = gps_init; gps; gps = (!on_back) ? gps->next : gps->prev) {
+ if (ED_gpencil_stroke_can_use(C, gps)) {
+ /* Need to verify if layer exists */
+ if (type != GP_COPY_TO_ACTIVE) {
+ gpl = BLI_findstring(
+ &gpd->layers, gps->runtime.tmp_layerinfo, offsetof(bGPDlayer, info));
+ if (gpl == NULL) {
+ /* no layer - use active (only if layer deleted before paste) */
+ gpl = BKE_gpencil_layer_active_get(gpd);
+ }
}
- }
- /* Ensure we have a frame to draw into
- * NOTE: Since this is an op which creates strokes,
- * we are obliged to add a new frame if one
- * doesn't exist already
- */
- gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_NEW);
- if (gpf) {
- /* Create new stroke */
- bGPDstroke *new_stroke = BKE_gpencil_stroke_duplicate(gps, true);
- new_stroke->runtime.tmp_layerinfo[0] = '\0';
- new_stroke->next = new_stroke->prev = NULL;
+ /* Ensure we have a frame to draw into
+ * NOTE: Since this is an op which creates strokes,
+ * we are obliged to add a new frame if one
+ * doesn't exist already
+ */
+ gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_NEW);
+ if (gpf) {
+ /* Create new stroke */
+ bGPDstroke *new_stroke = BKE_gpencil_stroke_duplicate(gps, true, true);
+ new_stroke->runtime.tmp_layerinfo[0] = '\0';
+ new_stroke->next = new_stroke->prev = NULL;
- /* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(new_stroke);
+ /* Calc geometry data. */
+ BKE_gpencil_stroke_geometry_update(gpd, new_stroke);
- if (on_back) {
- BLI_addhead(&gpf->strokes, new_stroke);
- }
- else {
- BLI_addtail(&gpf->strokes, new_stroke);
- }
+ if (on_back) {
+ BLI_addhead(&gpf->strokes, new_stroke);
+ }
+ else {
+ BLI_addtail(&gpf->strokes, new_stroke);
+ }
- /* Remap material */
- Material *ma = BLI_ghash_lookup(new_colors, POINTER_FROM_INT(new_stroke->mat_nr));
- new_stroke->mat_nr = BKE_gpencil_object_material_index_get(ob, ma);
- CLAMP_MIN(new_stroke->mat_nr, 0);
+ /* Remap material */
+ Material *ma = BLI_ghash_lookup(new_colors, POINTER_FROM_INT(new_stroke->mat_nr));
+ new_stroke->mat_nr = BKE_gpencil_object_material_index_get(ob, ma);
+ CLAMP_MIN(new_stroke->mat_nr, 0);
+ }
}
}
}
@@ -2018,10 +2181,10 @@ typedef enum eGP_DissolveMode {
/* Delete selected strokes */
static int gpencil_delete_selected_strokes(bContext *C)
{
- bool changed = false;
bGPdata *gpd = ED_gpencil_data_get_active(C);
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+ bool changed = false;
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
@@ -2042,16 +2205,9 @@ static int gpencil_delete_selected_strokes(bContext *C)
/* free stroke if selected */
if (gps->flag & GP_STROKE_SELECT) {
+ BLI_remlink(&gpf->strokes, gps);
/* free stroke memory arrays, then stroke itself */
- if (gps->points) {
- MEM_freeN(gps->points);
- }
- if (gps->dvert) {
- BKE_gpencil_free_stroke_weights(gps);
- MEM_freeN(gps->dvert);
- }
- MEM_SAFE_FREE(gps->triangles);
- BLI_freelinkN(&gpf->strokes, gps);
+ BKE_gpencil_free_stroke(gps);
changed = true;
}
@@ -2071,11 +2227,144 @@ static int gpencil_delete_selected_strokes(bContext *C)
/* ----------------------------------- */
-/* Delete selected points but keep the stroke */
-static int gpencil_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
+static bool gpencil_dissolve_selected_curve_points(bContext *C,
+ bGPdata *gpd,
+ eGP_DissolveMode mode)
+{
+ bool changed = false;
+ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
+ {
+ if (gpc->flag & GP_CURVE_SELECT) {
+ int first = 0, last = 0;
+ int num_points_remaining = gpc->tot_curve_points;
+
+ switch (mode) {
+ case GP_DISSOLVE_POINTS:
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *cpt = &gpc->curve_points[i];
+ if (cpt->flag & GP_CURVE_POINT_SELECT) {
+ num_points_remaining--;
+ }
+ }
+ break;
+ case GP_DISSOLVE_BETWEEN:
+ first = -1;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *cpt = &gpc->curve_points[i];
+ if (cpt->flag & GP_CURVE_POINT_SELECT) {
+ if (first < 0) {
+ first = i;
+ }
+ last = i;
+ }
+ }
+
+ for (int i = first + 1; i < last; i++) {
+ bGPDcurve_point *cpt = &gpc->curve_points[i];
+ if ((cpt->flag & GP_CURVE_POINT_SELECT) == 0) {
+ num_points_remaining--;
+ }
+ }
+ break;
+ case GP_DISSOLVE_UNSELECT:
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *cpt = &gpc->curve_points[i];
+ if ((cpt->flag & GP_CURVE_POINT_SELECT) == 0) {
+ num_points_remaining--;
+ }
+ }
+ break;
+ default:
+ return false;
+ break;
+ }
+
+ if (num_points_remaining < 1) {
+ /* Delete stroke */
+ BLI_remlink(&gpf_->strokes, gps);
+ BKE_gpencil_free_stroke(gps);
+ }
+ else {
+ bGPDcurve_point *new_points = MEM_callocN(sizeof(bGPDcurve_point) * num_points_remaining,
+ __func__);
+
+ int idx = 0;
+ switch (mode) {
+ case GP_DISSOLVE_POINTS:
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *cpt = &gpc->curve_points[i];
+ bGPDcurve_point *new_cpt = &new_points[idx];
+ if ((cpt->flag & GP_CURVE_POINT_SELECT) == 0) {
+ *new_cpt = *cpt;
+ idx++;
+ }
+ }
+ break;
+ case GP_DISSOLVE_BETWEEN:
+ for (int i = 0; i < first; i++) {
+ bGPDcurve_point *cpt = &gpc->curve_points[i];
+ bGPDcurve_point *new_cpt = &new_points[idx];
+
+ *new_cpt = *cpt;
+ idx++;
+ }
+
+ for (int i = first; i < last; i++) {
+ bGPDcurve_point *cpt = &gpc->curve_points[i];
+ bGPDcurve_point *new_cpt = &new_points[idx];
+ if (cpt->flag & GP_CURVE_POINT_SELECT) {
+ *new_cpt = *cpt;
+ idx++;
+ }
+ }
+
+ for (int i = last; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *cpt = &gpc->curve_points[i];
+ bGPDcurve_point *new_cpt = &new_points[idx];
+
+ *new_cpt = *cpt;
+ idx++;
+ }
+ break;
+ case GP_DISSOLVE_UNSELECT:
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *cpt = &gpc->curve_points[i];
+ bGPDcurve_point *new_cpt = &new_points[idx];
+ if (cpt->flag & GP_CURVE_POINT_SELECT) {
+ *new_cpt = *cpt;
+ idx++;
+ }
+ }
+ break;
+ default:
+ return false;
+ break;
+ }
+
+ if (gpc->curve_points != NULL) {
+ MEM_freeN(gpc->curve_points);
+ }
+
+ gpc->curve_points = new_points;
+ gpc->tot_curve_points = num_points_remaining;
+
+ BKE_gpencil_editcurve_recalculate_handles(gps);
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+
+ changed = true;
+ }
+ }
+ GP_EDITABLE_CURVES_END(gps_iter);
+
+ return changed;
+}
+
+static bool gpencil_dissolve_selected_stroke_points(bContext *C,
+ bGPdata *gpd,
+ eGP_DissolveMode mode)
{
- Object *ob = CTX_data_active_object(C);
- bGPdata *gpd = (bGPdata *)ob->data;
bool changed = false;
int first = 0;
int last = 0;
@@ -2135,18 +2424,8 @@ static int gpencil_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
/* if no points are left, we simply delete the entire stroke */
if (tot <= 0) {
/* remove the entire stroke */
- if (gps->points) {
- MEM_freeN(gps->points);
- }
- if (gps->dvert) {
- BKE_gpencil_free_stroke_weights(gps);
- MEM_freeN(gps->dvert);
- }
- if (gps->triangles) {
- MEM_freeN(gps->triangles);
- }
- BLI_freelinkN(&gpf_->strokes, gps);
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ BLI_remlink(&gpf_->strokes, gps);
+ BKE_gpencil_free_stroke(gps);
}
else {
/* just copy all points to keep into a smaller buffer */
@@ -2263,7 +2542,7 @@ static int gpencil_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
gps->totpoints = tot;
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
/* deselect the stroke, since none of its selected points will still be selected */
gps->flag &= ~GP_STROKE_SELECT;
@@ -2277,6 +2556,24 @@ static int gpencil_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
}
GP_EDITABLE_STROKES_END(gpstroke_iter);
+ return changed;
+}
+
+/* Delete selected points but keep the stroke */
+static int gpencil_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
+{
+ Object *ob = CTX_data_active_object(C);
+ bGPdata *gpd = (bGPdata *)ob->data;
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+ bool changed = false;
+
+ if (is_curve_edit) {
+ changed = gpencil_dissolve_selected_curve_points(C, gpd, mode);
+ }
+ else {
+ changed = gpencil_dissolve_selected_stroke_points(C, gpd, mode);
+ }
+
if (changed) {
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -2289,14 +2586,15 @@ static int gpencil_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
/* Temp data for storing information about an "island" of points
* that should be kept when splitting up a stroke. Used in:
- * gp_stroke_delete_tagged_points()
+ * gpencil_stroke_delete_tagged_points()
*/
typedef struct tGPDeleteIsland {
int start_idx;
int end_idx;
} tGPDeleteIsland;
-static void gpencil_stroke_join_islands(bGPDframe *gpf,
+static void gpencil_stroke_join_islands(bGPdata *gpd,
+ bGPDframe *gpf,
bGPDstroke *gps_first,
bGPDstroke *gps_last)
{
@@ -2305,7 +2603,7 @@ static void gpencil_stroke_join_islands(bGPDframe *gpf,
const int totpoints = gps_first->totpoints + gps_last->totpoints;
/* create new stroke */
- bGPDstroke *join_stroke = BKE_gpencil_stroke_duplicate(gps_first, false);
+ bGPDstroke *join_stroke = BKE_gpencil_stroke_duplicate(gps_first, false, true);
join_stroke->points = MEM_callocN(sizeof(bGPDspoint) * totpoints, __func__);
join_stroke->totpoints = totpoints;
@@ -2373,7 +2671,7 @@ static void gpencil_stroke_join_islands(bGPDframe *gpf,
/* add new stroke at head */
BLI_addhead(&gpf->strokes, join_stroke);
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(join_stroke);
+ BKE_gpencil_stroke_geometry_update(gpd, join_stroke);
/* remove first stroke */
BLI_remlink(&gpf->strokes, gps_first);
@@ -2398,7 +2696,8 @@ static void gpencil_stroke_join_islands(bGPDframe *gpf,
* 2) Each island gets converted to a new stroke
* If the number of points is <= limit, the stroke is deleted
*/
-void gpencil_stroke_delete_tagged_points(bGPDframe *gpf,
+void gpencil_stroke_delete_tagged_points(bGPdata *gpd,
+ bGPDframe *gpf,
bGPDstroke *gps,
bGPDstroke *next_stroke,
int tag_flags,
@@ -2450,7 +2749,7 @@ void gpencil_stroke_delete_tagged_points(bGPDframe *gpf,
/* Create each new stroke... */
for (idx = 0; idx < num_islands; idx++) {
tGPDeleteIsland *island = &islands[idx];
- new_stroke = BKE_gpencil_stroke_duplicate(gps, false);
+ new_stroke = BKE_gpencil_stroke_duplicate(gps, false, true);
/* if cyclic and first stroke, save to join later */
if ((is_cyclic) && (gps_first == NULL)) {
@@ -2521,7 +2820,7 @@ void gpencil_stroke_delete_tagged_points(bGPDframe *gpf,
}
else {
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(new_stroke);
+ BKE_gpencil_stroke_geometry_update(gpd, new_stroke);
if (next_stroke) {
BLI_insertlinkbefore(&gpf->strokes, next_stroke, new_stroke);
@@ -2533,7 +2832,7 @@ void gpencil_stroke_delete_tagged_points(bGPDframe *gpf,
}
/* if cyclic, need to join last stroke with first stroke */
if ((is_cyclic) && (gps_first != NULL) && (gps_first != new_stroke)) {
- gpencil_stroke_join_islands(gpf, gps_first, new_stroke);
+ gpencil_stroke_join_islands(gpd, gpf, gps_first, new_stroke);
}
}
@@ -2545,11 +2844,118 @@ void gpencil_stroke_delete_tagged_points(bGPDframe *gpf,
BKE_gpencil_free_stroke(gps);
}
+static void gpencil_curve_delete_tagged_points(bGPdata *gpd,
+ bGPDframe *gpf,
+ bGPDstroke *gps,
+ bGPDstroke *next_stroke,
+ bGPDcurve *gpc,
+ int tag_flags)
+{
+ if (gpc == NULL) {
+ return;
+ }
+ const bool is_cyclic = gps->flag & GP_STROKE_CYCLIC;
+ const int idx_last = gpc->tot_curve_points - 1;
+ bGPDstroke *gps_first = NULL;
+ bGPDstroke *gps_last = NULL;
+
+ int idx_start = 0;
+ int idx_end = 0;
+ bool prev_selected = gpc->curve_points[0].flag & tag_flags;
+ for (int i = 1; i < gpc->tot_curve_points; i++) {
+ bool selected = gpc->curve_points[i].flag & tag_flags;
+ if (prev_selected == true && selected == false) {
+ idx_start = i;
+ }
+ /* Island ends if the current point is selected or if we reached the end of the stroke */
+ if ((prev_selected == false && selected == true) || (selected == false && i == idx_last)) {
+
+ idx_end = selected ? i - 1 : i;
+ int island_length = idx_end - idx_start + 1;
+
+ /* If an island has only a single curve point, there is no curve segment, so skip island */
+ if (island_length == 1) {
+ if (is_cyclic) {
+ if (idx_start > 0 && idx_end < idx_last) {
+ prev_selected = selected;
+ continue;
+ }
+ }
+ else {
+ prev_selected = selected;
+ continue;
+ }
+ }
+
+ bGPDstroke *new_stroke = BKE_gpencil_stroke_duplicate(gps, false, false);
+ new_stroke->points = NULL;
+ new_stroke->flag &= ~GP_STROKE_CYCLIC;
+ new_stroke->editcurve = BKE_gpencil_stroke_editcurve_new(island_length);
+
+ if (gps_first == NULL) {
+ gps_first = new_stroke;
+ }
+
+ bGPDcurve *new_gpc = new_stroke->editcurve;
+ memcpy(new_gpc->curve_points,
+ gpc->curve_points + idx_start,
+ sizeof(bGPDcurve_point) * island_length);
+
+ BKE_gpencil_editcurve_recalculate_handles(new_stroke);
+ new_stroke->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+
+ /* Calc geometry data. */
+ BKE_gpencil_stroke_geometry_update(gpd, new_stroke);
+
+ if (next_stroke) {
+ BLI_insertlinkbefore(&gpf->strokes, next_stroke, new_stroke);
+ }
+ else {
+ BLI_addtail(&gpf->strokes, new_stroke);
+ }
+
+ gps_last = new_stroke;
+ }
+ prev_selected = selected;
+ }
+
+ /* join first and last stroke if cyclic */
+ if (is_cyclic && gps_first != NULL && gps_last != NULL && gps_first != gps_last) {
+ bGPDcurve *gpc_first = gps_first->editcurve;
+ bGPDcurve *gpc_last = gps_last->editcurve;
+ int first_tot_points = gpc_first->tot_curve_points;
+ int old_tot_points = gpc_last->tot_curve_points;
+
+ gpc_last->tot_curve_points = first_tot_points + old_tot_points;
+ gpc_last->curve_points = MEM_recallocN(gpc_last->curve_points,
+ sizeof(bGPDcurve_point) * gpc_last->tot_curve_points);
+ /* copy data from first to last */
+ memcpy(gpc_last->curve_points + old_tot_points,
+ gpc_first->curve_points,
+ sizeof(bGPDcurve_point) * first_tot_points);
+
+ BKE_gpencil_editcurve_recalculate_handles(gps_last);
+ gps_last->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+
+ /* Calc geometry data. */
+ BKE_gpencil_stroke_geometry_update(gpd, gps_last);
+
+ /* remove first one */
+ BLI_remlink(&gpf->strokes, gps_first);
+ BKE_gpencil_free_stroke(gps_first);
+ }
+
+ /* Delete the old stroke */
+ BLI_remlink(&gpf->strokes, gps);
+ BKE_gpencil_free_stroke(gps);
+}
+
/* Split selected strokes into segments, splitting on selected points */
static int gpencil_delete_selected_points(bContext *C)
{
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
bool changed = false;
@@ -2579,8 +2985,16 @@ static int gpencil_delete_selected_points(bContext *C)
/* deselect old stroke, since it will be used as template for the new strokes */
gps->flag &= ~GP_STROKE_SELECT;
- /* delete unwanted points by splitting stroke into several smaller ones */
- gpencil_stroke_delete_tagged_points(gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
+ if (is_curve_edit) {
+ bGPDcurve *gpc = gps->editcurve;
+ gpencil_curve_delete_tagged_points(
+ gpd, gpf, gps, gps->next, gpc, GP_CURVE_POINT_SELECT);
+ }
+ else {
+ /* delete unwanted points by splitting stroke into several smaller ones */
+ gpencil_stroke_delete_tagged_points(
+ gpd, gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
+ }
changed = true;
}
@@ -2737,13 +3151,15 @@ static bool gpencil_snap_poll(bContext *C)
static int gpencil_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
- RegionView3D *rv3d = CTX_wm_region_data(C);
+ ARegion *region = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obact = CTX_data_active_object(C);
- const float gridf = ED_view3d_grid_view_scale(scene, v3d, rv3d, NULL);
+ const float gridf = ED_view3d_grid_view_scale(scene, v3d, region, NULL);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+ bool changed = false;
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* only editable and visible layers are considered */
if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
@@ -2754,9 +3170,6 @@ static int gpencil_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
BKE_gpencil_parent_matrix_get(depsgraph, obact, gpl, diff_mat);
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- bGPDspoint *pt;
- int i;
-
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
@@ -2766,30 +3179,82 @@ static int gpencil_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
continue;
}
- /* 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) {
- /* apply parent transformations */
- float fpt[3];
- mul_v3_m4v3(fpt, diff_mat, &pt->x);
+ if (is_curve_edit) {
+ if (gps->editcurve == NULL) {
+ continue;
+ }
+ float inv_diff_mat[4][4];
+ invert_m4_m4_safe(inv_diff_mat, diff_mat);
+
+ bGPDcurve *gpc = gps->editcurve;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ float tmp0[3], tmp1[3], tmp2[3], offset[3];
+ mul_v3_m4v3(tmp0, diff_mat, bezt->vec[0]);
+ mul_v3_m4v3(tmp1, diff_mat, bezt->vec[1]);
+ mul_v3_m4v3(tmp2, diff_mat, bezt->vec[2]);
+
+ /* calculate the offset vector */
+ offset[0] = gridf * floorf(0.5f + tmp1[0] / gridf) - tmp1[0];
+ offset[1] = gridf * floorf(0.5f + tmp1[1] / gridf) - tmp1[1];
+ offset[2] = gridf * floorf(0.5f + tmp1[2] / gridf) - tmp1[2];
+
+ /* shift bezTriple */
+ add_v3_v3(bezt->vec[0], offset);
+ add_v3_v3(bezt->vec[1], offset);
+ add_v3_v3(bezt->vec[2], offset);
+
+ mul_v3_m4v3(tmp0, inv_diff_mat, bezt->vec[0]);
+ mul_v3_m4v3(tmp1, inv_diff_mat, bezt->vec[1]);
+ mul_v3_m4v3(tmp2, inv_diff_mat, bezt->vec[2]);
+ copy_v3_v3(bezt->vec[0], tmp0);
+ copy_v3_v3(bezt->vec[1], tmp1);
+ copy_v3_v3(bezt->vec[2], tmp2);
+
+ changed = true;
+ }
+ }
- fpt[0] = gridf * floorf(0.5f + fpt[0] / gridf);
- fpt[1] = gridf * floorf(0.5f + fpt[1] / gridf);
- fpt[2] = gridf * floorf(0.5f + fpt[2] / gridf);
+ if (changed) {
+ BKE_gpencil_editcurve_recalculate_handles(gps);
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+ }
+ else {
+ /* TODO: if entire stroke is selected, offset entire stroke by same amount? */
+ for (int i = 0; i < gps->totpoints; i++) {
+ bGPDspoint *pt = &gps->points[i];
+ /* only if point is selected */
+ if (pt->flag & GP_SPOINT_SELECT) {
+ /* apply parent transformations */
+ float fpt[3];
+ mul_v3_m4v3(fpt, diff_mat, &pt->x);
+
+ fpt[0] = gridf * floorf(0.5f + fpt[0] / gridf);
+ fpt[1] = gridf * floorf(0.5f + fpt[1] / gridf);
+ fpt[2] = gridf * floorf(0.5f + fpt[2] / gridf);
+
+ /* return data */
+ copy_v3_v3(&pt->x, fpt);
+ gpencil_apply_parent_point(depsgraph, obact, gpl, pt);
- /* return data */
- copy_v3_v3(&pt->x, fpt);
- gpencil_apply_parent_point(depsgraph, obact, gpl, pt);
+ changed = true;
+ }
}
}
}
}
}
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- DEG_id_tag_update(&obact->id, ID_RECALC_COPY_ON_WRITE);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&obact->id, ID_RECALC_COPY_ON_WRITE);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
+
return OPERATOR_FINISHED;
}
@@ -2817,7 +3282,7 @@ void GPENCIL_OT_snap_to_grid(wmOperatorType *ot)
static int gpencil_snap_to_cursor(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
-
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
Scene *scene = CTX_data_scene(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obact = CTX_data_active_object(C);
@@ -2825,50 +3290,60 @@ static int gpencil_snap_to_cursor(bContext *C, wmOperator *op)
const bool use_offset = RNA_boolean_get(op->ptr, "use_offset");
const float *cursor_global = scene->cursor.location;
- LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
- /* only editable and visible layers are considered */
- if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
- bGPDframe *gpf = gpl->actframe;
- float diff_mat[4][4];
+ bool changed = false;
+ if (is_curve_edit) {
+ BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+ }
+ else {
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ /* only editable and visible layers are considered */
+ if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
+ bGPDframe *gpf = gpl->actframe;
+ float diff_mat[4][4];
- /* calculate difference matrix */
- BKE_gpencil_parent_matrix_get(depsgraph, obact, gpl, diff_mat);
+ /* calculate difference matrix */
+ BKE_gpencil_parent_matrix_get(depsgraph, obact, gpl, diff_mat);
- LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- bGPDspoint *pt;
- int i;
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ bGPDspoint *pt;
+ int i;
- /* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false) {
- continue;
- }
- /* check if the color is editable */
- if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
- continue;
- }
- /* only continue if this stroke is selected (editable doesn't guarantee this)... */
- if ((gps->flag & GP_STROKE_SELECT) == 0) {
- continue;
- }
+ /* skip strokes that are invalid for current view */
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
+ continue;
+ }
+ /* check if the color is editable */
+ if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
+ continue;
+ }
+ /* only continue if this stroke is selected (editable doesn't guarantee this)... */
+ if ((gps->flag & GP_STROKE_SELECT) == 0) {
+ continue;
+ }
- if (use_offset) {
- float offset[3];
+ if (use_offset) {
+ float offset[3];
- /* compute offset from first point of stroke to cursor */
- /* TODO: Allow using midpoint instead? */
- sub_v3_v3v3(offset, cursor_global, &gps->points->x);
+ /* compute offset from first point of stroke to cursor */
+ /* TODO: Allow using midpoint instead? */
+ sub_v3_v3v3(offset, cursor_global, &gps->points->x);
- /* apply offset to all points in the stroke */
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- add_v3_v3(&pt->x, offset);
+ /* apply offset to all points in the stroke */
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ add_v3_v3(&pt->x, offset);
+ }
+
+ changed = true;
}
- }
- else {
- /* affect each selected point */
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- if (pt->flag & GP_SPOINT_SELECT) {
- copy_v3_v3(&pt->x, cursor_global);
- gpencil_apply_parent_point(depsgraph, obact, gpl, pt);
+ else {
+ /* affect each selected point */
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ if (pt->flag & GP_SPOINT_SELECT) {
+ copy_v3_v3(&pt->x, cursor_global);
+ gpencil_apply_parent_point(depsgraph, obact, gpl, pt);
+
+ changed = true;
+ }
}
}
}
@@ -2876,9 +3351,12 @@ static int gpencil_snap_to_cursor(bContext *C, wmOperator *op)
}
}
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- DEG_id_tag_update(&obact->id, ID_RECALC_COPY_ON_WRITE);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&obact->id, ID_RECALC_COPY_ON_WRITE);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
+
return OPERATOR_FINISHED;
}
@@ -2910,23 +3388,16 @@ void GPENCIL_OT_snap_to_cursor(wmOperatorType *ot)
/** \name Snapping Cursor to Selection Operator
* \{ */
-static int gpencil_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
+static bool gpencil_stroke_points_centroid(Depsgraph *depsgraph,
+ bContext *C,
+ Object *obact,
+ bGPdata *gpd,
+ float r_centroid[3],
+ float r_min[3],
+ float r_max[3],
+ size_t *count)
{
- Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- Object *obact = CTX_data_active_object(C);
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, obact);
- bGPdata *gpd = (bGPdata *)ob_eval->data;
-
- Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
-
- float *cursor = scene->cursor.location;
- float centroid[3] = {0.0f};
- float min[3], max[3];
- size_t count = 0;
-
- INIT_MINMAX(min, max);
-
+ bool changed = false;
/* calculate midpoints from selected points */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* only editable and visible layers are considered */
@@ -2960,29 +3431,61 @@ static int gpencil_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
float fpt[3];
mul_v3_m4v3(fpt, diff_mat, &pt->x);
- add_v3_v3(centroid, fpt);
- minmax_v3v3_v3(min, max, fpt);
+ add_v3_v3(r_centroid, fpt);
+ minmax_v3v3_v3(r_min, r_max, fpt);
- count++;
+ (*count)++;
}
}
+
+ changed = true;
}
}
}
- if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CENTER_BOUNDS) {
- mid_v3_v3v3(cursor, min, max);
+ return changed;
+}
+
+static int gpencil_snap_cursor_to_sel(bContext *C, wmOperator *op)
+{
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ Object *obact = CTX_data_active_object(C);
+ bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+
+ float *cursor = scene->cursor.location;
+ float centroid[3] = {0.0f};
+ float min[3], max[3];
+ size_t count = 0;
+
+ INIT_MINMAX(min, max);
+
+ bool changed = false;
+ if (is_curve_edit) {
+ BKE_report(op->reports, RPT_ERROR, "Not implemented!");
}
- else { /* #V3D_AROUND_CENTER_MEDIAN. */
- zero_v3(cursor);
- if (count) {
- mul_v3_fl(centroid, 1.0f / (float)count);
- copy_v3_v3(cursor, centroid);
- }
+ else {
+ changed = gpencil_stroke_points_centroid(depsgraph, C, obact, gpd, centroid, min, max, &count);
}
- DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+ if (changed) {
+ if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CENTER_BOUNDS) {
+ mid_v3_v3v3(cursor, min, max);
+ }
+ else { /* #V3D_AROUND_CENTER_MEDIAN. */
+ zero_v3(cursor);
+ if (count) {
+ mul_v3_fl(centroid, 1.0f / (float)count);
+ copy_v3_v3(cursor, centroid);
+ }
+ }
+
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+ }
return OPERATOR_FINISHED;
}
@@ -3030,6 +3533,7 @@ static int gpencil_stroke_apply_thickness_exec(bContext *C, wmOperator *UNUSED(o
}
}
}
+
/* clear value */
gpl->thickness = 0.0f;
gpl->line_change = 0;
@@ -3073,6 +3577,7 @@ static int gpencil_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
const int type = RNA_enum_get(op->ptr, "type");
const bool geometry = RNA_boolean_get(op->ptr, "geometry");
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
bGPDstroke *gps = NULL;
/* sanity checks */
@@ -3080,6 +3585,7 @@ static int gpencil_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ bool changed = false;
/* loop all selected strokes */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
@@ -3103,6 +3609,7 @@ static int gpencil_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
continue;
}
+ bool before = (bool)(gps->flag & GP_STROKE_CYCLIC);
switch (type) {
case GP_STROKE_CYCLIC_CLOSE:
/* Close all (enable) */
@@ -3121,9 +3628,19 @@ static int gpencil_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
break;
}
- /* Create new geometry. */
- if ((gps->flag & GP_STROKE_CYCLIC) && (geometry)) {
- BKE_gpencil_stroke_close(gps);
+ if (before != (gps->flag & GP_STROKE_CYCLIC)) {
+ /* Create new geometry. */
+ if (is_curve_edit) {
+ BKE_gpencil_editcurve_recalculate_handles(gps);
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+ else if ((gps->flag & GP_STROKE_CYCLIC) && geometry) {
+ BKE_gpencil_stroke_close(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+
+ changed = true;
}
}
@@ -3136,13 +3653,31 @@ static int gpencil_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- /* notifiers */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ /* notifiers */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
+static bool gpencil_cyclical_set_curve_edit_poll_property(const bContext *C,
+ wmOperator *UNUSED(op),
+ const PropertyRNA *prop)
+{
+ bGPdata *gpd = ED_gpencil_data_get_active(C);
+ if (gpd != NULL && GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) {
+ const char *prop_id = RNA_property_identifier(prop);
+ /* Only show type in curve edit mode */
+ if (!STREQ(prop_id, "type")) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
/**
* Similar to #CURVE_OT_cyclic_toggle or #MASK_OT_cyclic_toggle, but with
* option to force opened/closed strokes instead of just toggle behavior.
@@ -3152,8 +3687,8 @@ void GPENCIL_OT_stroke_cyclical_set(wmOperatorType *ot)
PropertyRNA *prop;
static const EnumPropertyItem cyclic_type[] = {
- {GP_STROKE_CYCLIC_CLOSE, "CLOSE", 0, "Close all", ""},
- {GP_STROKE_CYCLIC_OPEN, "OPEN", 0, "Open all", ""},
+ {GP_STROKE_CYCLIC_CLOSE, "CLOSE", 0, "Close All", ""},
+ {GP_STROKE_CYCLIC_OPEN, "OPEN", 0, "Open All", ""},
{GP_STROKE_CYCLIC_TOGGLE, "TOGGLE", 0, "Toggle", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -3166,6 +3701,7 @@ void GPENCIL_OT_stroke_cyclical_set(wmOperatorType *ot)
/* api callbacks */
ot->exec = gpencil_stroke_cyclical_set_exec;
ot->poll = gpencil_active_layer_poll;
+ ot->poll_property = gpencil_cyclical_set_curve_edit_poll_property;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3194,7 +3730,6 @@ static int gpencil_stroke_caps_set_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
Object *ob = CTX_data_active_object(C);
-
const int type = RNA_enum_get(op->ptr, "type");
/* sanity checks */
@@ -3202,6 +3737,7 @@ static int gpencil_stroke_caps_set_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ bool changed = false;
/* loop all selected strokes */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
if (gpl->actframe == NULL) {
@@ -3221,13 +3757,16 @@ static int gpencil_stroke_caps_set_exec(bContext *C, wmOperator *op)
continue;
}
- if ((type == GP_STROKE_CAPS_TOGGLE_BOTH) || (type == GP_STROKE_CAPS_TOGGLE_START)) {
+ short prev_first = gps->caps[0];
+ short prev_last = gps->caps[1];
+
+ if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_START)) {
++gps->caps[0];
if (gps->caps[0] >= GP_STROKE_CAP_MAX) {
gps->caps[0] = GP_STROKE_CAP_ROUND;
}
}
- if ((type == GP_STROKE_CAPS_TOGGLE_BOTH) || (type == GP_STROKE_CAPS_TOGGLE_END)) {
+ if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_END)) {
++gps->caps[1];
if (gps->caps[1] >= GP_STROKE_CAP_MAX) {
gps->caps[1] = GP_STROKE_CAP_ROUND;
@@ -3237,13 +3776,19 @@ static int gpencil_stroke_caps_set_exec(bContext *C, wmOperator *op)
gps->caps[0] = GP_STROKE_CAP_ROUND;
gps->caps[1] = GP_STROKE_CAP_ROUND;
}
+
+ if (prev_first != gps->caps[0] || prev_last != gps->caps[1]) {
+ changed = true;
+ }
}
}
CTX_DATA_END;
- /* notifiers */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ /* notifiers */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -3398,24 +3943,50 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a,
}
/* define start and end points of each stroke */
- float area[3], sb[3], ea[3], eb[3];
+ float start_a[3], start_b[3], end_a[3], end_b[3];
pt = &gps_a->points[0];
- copy_v3_v3(area, &pt->x);
+ copy_v3_v3(start_a, &pt->x);
pt = &gps_a->points[gps_a->totpoints - 1];
- copy_v3_v3(ea, &pt->x);
+ copy_v3_v3(end_a, &pt->x);
pt = &gps_b->points[0];
- copy_v3_v3(sb, &pt->x);
+ copy_v3_v3(start_b, &pt->x);
pt = &gps_b->points[gps_b->totpoints - 1];
- copy_v3_v3(eb, &pt->x);
+ copy_v3_v3(end_b, &pt->x);
+
+ /* Check if need flip strokes. */
+ float dist = len_squared_v3v3(end_a, start_b);
+ bool flip_a = false;
+ bool flip_b = false;
+ float lowest = dist;
+
+ dist = len_squared_v3v3(end_a, end_b);
+ if (dist < lowest) {
+ lowest = dist;
+ flip_a = false;
+ flip_b = true;
+ }
- /* review if need flip stroke B */
- float ea_sb = len_squared_v3v3(ea, sb);
- float ea_eb = len_squared_v3v3(ea, eb);
- /* flip if distance to end point is shorter */
- if (ea_eb < ea_sb) {
+ dist = len_squared_v3v3(start_a, start_b);
+ if (dist < lowest) {
+ lowest = dist;
+ flip_a = true;
+ flip_b = false;
+ }
+
+ dist = len_squared_v3v3(start_a, end_b);
+ if (dist < lowest) {
+ lowest = dist;
+ flip_a = true;
+ flip_b = true;
+ }
+
+ if (flip_a) {
+ gpencil_flip_stroke(gps_a);
+ }
+ if (flip_b) {
gpencil_flip_stroke(gps_b);
}
@@ -3439,16 +4010,71 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a,
}
}
+typedef struct tJoinStrokes {
+ bGPDframe *gpf;
+ bGPDstroke *gps;
+ bool used;
+} tJoinStrokes;
+
+static int gpencil_get_nearest_stroke_index(tJoinStrokes *strokes_list,
+ const bGPDstroke *gps,
+ const int totstrokes)
+{
+ int index = -1;
+ float min_dist = FLT_MAX;
+ float dist, start_a[3], end_a[3], start_b[3], end_b[3];
+
+ bGPDspoint *pt = &gps->points[0];
+ copy_v3_v3(start_a, &pt->x);
+
+ pt = &gps->points[gps->totpoints - 1];
+ copy_v3_v3(end_a, &pt->x);
+
+ for (int i = 0; i < totstrokes; i++) {
+ tJoinStrokes *elem = &strokes_list[i];
+ if (elem->used) {
+ continue;
+ }
+ pt = &elem->gps->points[0];
+ copy_v3_v3(start_b, &pt->x);
+
+ pt = &elem->gps->points[elem->gps->totpoints - 1];
+ copy_v3_v3(end_b, &pt->x);
+
+ dist = len_squared_v3v3(start_a, start_b);
+ if (dist < min_dist) {
+ min_dist = dist;
+ index = i;
+ }
+ dist = len_squared_v3v3(start_a, end_b);
+ if (dist < min_dist) {
+ min_dist = dist;
+ index = i;
+ }
+ dist = len_squared_v3v3(end_a, start_b);
+ if (dist < min_dist) {
+ min_dist = dist;
+ index = i;
+ }
+ dist = len_squared_v3v3(end_a, end_b);
+ if (dist < min_dist) {
+ min_dist = dist;
+ index = i;
+ }
+ }
+
+ return index;
+}
+
static int gpencil_stroke_join_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *activegpl = BKE_gpencil_layer_active_get(gpd);
Object *ob = CTX_data_active_object(C);
-
- bGPDframe *gpf_a = NULL;
- bGPDstroke *stroke_a = NULL;
- bGPDstroke *stroke_b = NULL;
- bGPDstroke *new_stroke = NULL;
+ /* Limit the number of strokes to join. It makes no sense to allow an very high number of strokes
+ * for CPU time and because to have a stroke with thousands of points is unpractical, so limit
+ * this number avoid to joining a full frame scene in one single stroke. */
+ const int max_join_strokes = 128;
const int type = RNA_enum_get(op->ptr, "type");
const bool leave_gaps = RNA_boolean_get(op->ptr, "leave_gaps");
@@ -3458,93 +4084,100 @@ static int gpencil_stroke_join_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+ if (is_curve_edit) {
+ return OPERATOR_CANCELLED;
+ }
+
if (activegpl->flag & GP_LAYER_LOCKED) {
return OPERATOR_CANCELLED;
}
BLI_assert(ELEM(type, GP_STROKE_JOIN, GP_STROKE_JOINCOPY));
- /* read all selected strokes */
- bool first = false;
+ int tot_strokes = 0;
+ /** Alloc memory */
+ tJoinStrokes *strokes_list = MEM_malloc_arrayN(sizeof(tJoinStrokes), max_join_strokes, __func__);
+ tJoinStrokes *elem = NULL;
+ /* Read all selected strokes to create a list. */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *gpf = gpl->actframe;
if (gpf == NULL) {
continue;
}
- LISTBASE_FOREACH_MUTABLE (bGPDstroke *, gps, &gpf->strokes) {
+ /* Add all stroke selected of the frame. */
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
if (gps->flag & GP_STROKE_SELECT) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
}
- /* check if the color is editable */
+ /* check if the color is editable. */
if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
continue;
}
-
- /* to join strokes, cyclic must be disabled */
- gps->flag &= ~GP_STROKE_CYCLIC;
-
- /* saves first frame and stroke */
- if (!first) {
- first = true;
- gpf_a = gpf;
- stroke_a = gps;
+ elem = &strokes_list[tot_strokes];
+ elem->gpf = gpf;
+ elem->gps = gps;
+ elem->used = false;
+
+ tot_strokes++;
+ /* Limit the number of strokes. */
+ if (tot_strokes == max_join_strokes) {
+ BKE_reportf(op->reports,
+ RPT_WARNING,
+ "Too many strokes selected. Only joined first %d strokes.",
+ max_join_strokes);
+ break;
}
- else {
- stroke_b = gps;
-
- /* create a new stroke if was not created before (only created if something to join) */
- if (new_stroke == NULL) {
- new_stroke = BKE_gpencil_stroke_duplicate(stroke_a, true);
+ }
+ }
+ }
+ CTX_DATA_END;
- /* if new, set current color */
- if (type == GP_STROKE_JOINCOPY) {
- new_stroke->mat_nr = stroke_a->mat_nr;
- }
- }
+ /* Nothing to join. */
+ if (tot_strokes < 2) {
+ MEM_SAFE_FREE(strokes_list);
+ return OPERATOR_CANCELLED;
+ }
- /* join new_stroke and stroke B. New stroke will contain all the previous data */
- gpencil_stroke_join_strokes(new_stroke, stroke_b, leave_gaps);
+ /* Take first stroke. */
+ elem = &strokes_list[0];
+ elem->used = true;
- /* if join only, delete old strokes */
- if (type == GP_STROKE_JOIN) {
- if (stroke_a) {
- /* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(new_stroke);
+ /* Create a new stroke. */
+ bGPDstroke *gps_new = BKE_gpencil_stroke_duplicate(elem->gps, true, true);
+ gps_new->flag &= ~GP_STROKE_CYCLIC;
+ BLI_insertlinkbefore(&elem->gpf->strokes, elem->gps, gps_new);
- BLI_insertlinkbefore(&gpf_a->strokes, stroke_a, new_stroke);
- BLI_remlink(&gpf->strokes, stroke_a);
- BKE_gpencil_free_stroke(stroke_a);
- stroke_a = NULL;
- }
- if (stroke_b) {
- BLI_remlink(&gpf->strokes, stroke_b);
- BKE_gpencil_free_stroke(stroke_b);
- stroke_b = NULL;
- }
- }
- }
- }
+ /* Join all strokes until the list is completed. */
+ while (true) {
+ int i = gpencil_get_nearest_stroke_index(strokes_list, gps_new, tot_strokes);
+ if (i < 0) {
+ break;
}
+ elem = &strokes_list[i];
+ /* Join new_stroke and stroke B. */
+ gpencil_stroke_join_strokes(gps_new, elem->gps, leave_gaps);
+ elem->used = true;
}
- CTX_DATA_END;
- /* add new stroke if was not added before */
- if (type == GP_STROKE_JOINCOPY) {
- if (new_stroke) {
- /* Add a new frame if needed */
- if (activegpl->actframe == NULL) {
- activegpl->actframe = BKE_gpencil_frame_addnew(activegpl, gpf_a->framenum);
- }
- /* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(new_stroke);
+ /* Calc geometry data for new stroke. */
+ BKE_gpencil_stroke_geometry_update(gpd, gps_new);
- BLI_addtail(&activegpl->actframe->strokes, new_stroke);
+ /* If join only, delete old strokes. */
+ if (type == GP_STROKE_JOIN) {
+ for (int i = 0; i < tot_strokes; i++) {
+ elem = &strokes_list[i];
+ BLI_remlink(&elem->gpf->strokes, elem->gps);
+ BKE_gpencil_free_stroke(elem->gps);
}
}
+ /* Free memory. */
+ MEM_SAFE_FREE(strokes_list);
+
/* notifiers */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -3587,7 +4220,7 @@ void GPENCIL_OT_stroke_join(wmOperatorType *ot)
/** \name Stroke Flip Operator
* \{ */
-static int gpencil_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op))
+static int gpencil_stroke_flip_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
Object *ob = CTX_data_active_object(C);
@@ -3597,6 +4230,8 @@ static int gpencil_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+ bool changed = false;
/* read all selected strokes */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *gpf = gpl->actframe;
@@ -3615,16 +4250,25 @@ static int gpencil_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op))
continue;
}
- /* flip stroke */
- gpencil_flip_stroke(gps);
+ if (is_curve_edit) {
+ BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+ }
+ else {
+ /* flip stroke */
+ gpencil_flip_stroke(gps);
+ }
+
+ changed = true;
}
}
}
CTX_DATA_END;
- /* notifiers */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ /* notifiers */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -3659,19 +4303,26 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
int oldframe = (int)DEG_get_ctime(depsgraph);
const eGP_ReprojectModes mode = RNA_enum_get(op->ptr, "type");
const bool keep_original = RNA_boolean_get(op->ptr, "keep_original");
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
- /* Init space conversion stuff. */
- GP_SpaceConversion gsc = {NULL};
- SnapObjectContext *sctx = NULL;
- gpencil_point_conversion_init(C, &gsc);
/* Init snap context for geometry projection. */
+ SnapObjectContext *sctx = NULL;
sctx = ED_transform_snap_object_context_create_view3d(scene, 0, region, CTX_wm_view3d(C));
+ bool changed = false;
+ /* Init space conversion stuff. */
+ GP_SpaceConversion gsc = {NULL};
+ gpencil_point_conversion_init(C, &gsc);
int cfra_prv = INT_MIN;
/* Go through each editable + selected stroke, adjusting each of its points one by one... */
GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
- if (gps->flag & GP_STROKE_SELECT) {
+ bool curve_select = false;
+ if (is_curve_edit && gps->editcurve != NULL) {
+ curve_select = gps->editcurve->flag & GP_CURVE_SELECT;
+ }
+
+ if (gps->flag & GP_STROKE_SELECT || curve_select) {
/* update frame to get the new location of objects */
if ((mode == GP_REPROJECT_SURFACE) && (cfra_prv != gpf_->framenum)) {
@@ -3681,6 +4332,17 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
}
ED_gpencil_stroke_reproject(depsgraph, &gsc, sctx, gpl, gpf_, gps, mode, keep_original);
+
+ if (is_curve_edit && gps->editcurve != NULL) {
+ BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps);
+ /* Update the selection from the stroke to the curve. */
+ BKE_gpencil_editcurve_stroke_sync_selection(gps, gps->editcurve);
+
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+
+ changed = true;
}
}
GP_EDITABLE_STROKES_END(gpstroke_iter);
@@ -3693,9 +4355,12 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
ED_transform_snap_object_context_destroy(sctx);
}
- /* update changed data */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ /* update changed data */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
+
return OPERATOR_FINISHED;
}
@@ -3763,10 +4428,11 @@ static int gpencil_recalc_geometry_exec(bContext *C, wmOperator *UNUSED(op))
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
}
}
+
/* update changed data */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -3860,134 +4526,176 @@ static int gpencil_count_subdivision_cuts(bGPDstroke *gps)
return totnewpoints;
}
-static int gpencil_stroke_subdivide_exec(bContext *C, wmOperator *op)
+static void gpencil_stroke_subdivide(bGPDstroke *gps, const int cuts)
{
- bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDspoint *temp_points;
- const int cuts = RNA_int_get(op->ptr, "number_cuts");
-
int totnewpoints, oldtotpoints;
int i2;
+ /* loop as many times as cuts */
+ for (int s = 0; s < cuts; s++) {
+ totnewpoints = gpencil_count_subdivision_cuts(gps);
+ if (totnewpoints == 0) {
+ continue;
+ }
+ /* duplicate points in a temp area */
+ temp_points = MEM_dupallocN(gps->points);
+ oldtotpoints = gps->totpoints;
- /* sanity checks */
- if (ELEM(NULL, gpd)) {
- return OPERATOR_CANCELLED;
- }
+ MDeformVert *temp_dverts = NULL;
+ MDeformVert *dvert_final = NULL;
+ MDeformVert *dvert = NULL;
+ MDeformVert *dvert_next = NULL;
+ if (gps->dvert != NULL) {
+ temp_dverts = MEM_dupallocN(gps->dvert);
+ }
- /* Go through each editable + selected stroke */
- GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
- if (gps->flag & GP_STROKE_SELECT) {
- /* loop as many times as cuts */
- for (int s = 0; s < cuts; s++) {
- totnewpoints = gpencil_count_subdivision_cuts(gps);
- if (totnewpoints == 0) {
- continue;
- }
- /* duplicate points in a temp area */
- temp_points = MEM_dupallocN(gps->points);
- oldtotpoints = gps->totpoints;
-
- MDeformVert *temp_dverts = NULL;
- MDeformVert *dvert_final = NULL;
- MDeformVert *dvert = NULL;
- MDeformVert *dvert_next = NULL;
- if (gps->dvert != NULL) {
- temp_dverts = MEM_dupallocN(gps->dvert);
- }
+ /* resize the points arrays */
+ gps->totpoints += totnewpoints;
+ gps->points = MEM_recallocN(gps->points, sizeof(*gps->points) * gps->totpoints);
+ if (gps->dvert != NULL) {
+ gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * gps->totpoints);
+ }
- /* resize the points arrays */
- gps->totpoints += totnewpoints;
- gps->points = MEM_recallocN(gps->points, sizeof(*gps->points) * gps->totpoints);
- if (gps->dvert != NULL) {
- gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * gps->totpoints);
- }
+ /* loop and interpolate */
+ i2 = 0;
+ for (int i = 0; i < oldtotpoints; i++) {
+ bGPDspoint *pt = &temp_points[i];
+ bGPDspoint *pt_final = &gps->points[i2];
- /* loop and interpolate */
- i2 = 0;
- for (int i = 0; i < oldtotpoints; i++) {
- bGPDspoint *pt = &temp_points[i];
- bGPDspoint *pt_final = &gps->points[i2];
-
- /* copy current point */
- copy_v3_v3(&pt_final->x, &pt->x);
- pt_final->pressure = pt->pressure;
- pt_final->strength = pt->strength;
- pt_final->time = pt->time;
- pt_final->flag = pt->flag;
- copy_v4_v4(pt_final->vert_color, pt->vert_color);
-
- if (gps->dvert != NULL) {
- dvert = &temp_dverts[i];
- dvert_final = &gps->dvert[i2];
- dvert_final->totweight = dvert->totweight;
- dvert_final->dw = dvert->dw;
- }
- i2++;
+ /* copy current point */
+ copy_v3_v3(&pt_final->x, &pt->x);
+ pt_final->pressure = pt->pressure;
+ pt_final->strength = pt->strength;
+ pt_final->time = pt->time;
+ pt_final->flag = pt->flag;
+ copy_v4_v4(pt_final->vert_color, pt->vert_color);
- /* if next point is selected add a half way point */
- if (pt->flag & GP_SPOINT_SELECT) {
- if (i + 1 < oldtotpoints) {
- if (temp_points[i + 1].flag & GP_SPOINT_SELECT) {
- pt_final = &gps->points[i2];
- if (gps->dvert != NULL) {
- dvert_final = &gps->dvert[i2];
- }
- /* Interpolate all values */
- bGPDspoint *next = &temp_points[i + 1];
- interp_v3_v3v3(&pt_final->x, &pt->x, &next->x, 0.5f);
- pt_final->pressure = interpf(pt->pressure, next->pressure, 0.5f);
- pt_final->strength = interpf(pt->strength, next->strength, 0.5f);
- CLAMP(pt_final->strength, GPENCIL_STRENGTH_MIN, 1.0f);
- interp_v4_v4v4(pt_final->vert_color, pt->vert_color, next->vert_color, 0.5f);
- pt_final->time = interpf(pt->time, next->time, 0.5f);
- pt_final->flag |= GP_SPOINT_SELECT;
-
- /* interpolate weights */
- if (gps->dvert != NULL) {
- dvert = &temp_dverts[i];
- dvert_next = &temp_dverts[i + 1];
- dvert_final = &gps->dvert[i2];
-
- dvert_final->totweight = dvert->totweight;
- dvert_final->dw = MEM_dupallocN(dvert->dw);
-
- /* interpolate weight values */
- for (int d = 0; d < dvert->totweight; d++) {
- MDeformWeight *dw_a = &dvert->dw[d];
- if (dvert_next->totweight > d) {
- MDeformWeight *dw_b = &dvert_next->dw[d];
- MDeformWeight *dw_final = &dvert_final->dw[d];
- dw_final->weight = interpf(dw_a->weight, dw_b->weight, 0.5f);
- }
- }
- }
+ if (gps->dvert != NULL) {
+ dvert = &temp_dverts[i];
+ dvert_final = &gps->dvert[i2];
+ dvert_final->totweight = dvert->totweight;
+ dvert_final->dw = dvert->dw;
+ }
+ i2++;
- i2++;
+ /* if next point is selected add a half way point */
+ if (pt->flag & GP_SPOINT_SELECT) {
+ if (i + 1 < oldtotpoints) {
+ if (temp_points[i + 1].flag & GP_SPOINT_SELECT) {
+ pt_final = &gps->points[i2];
+ if (gps->dvert != NULL) {
+ dvert_final = &gps->dvert[i2];
+ }
+ /* Interpolate all values */
+ bGPDspoint *next = &temp_points[i + 1];
+ interp_v3_v3v3(&pt_final->x, &pt->x, &next->x, 0.5f);
+ pt_final->pressure = interpf(pt->pressure, next->pressure, 0.5f);
+ pt_final->strength = interpf(pt->strength, next->strength, 0.5f);
+ CLAMP(pt_final->strength, GPENCIL_STRENGTH_MIN, 1.0f);
+ interp_v4_v4v4(pt_final->vert_color, pt->vert_color, next->vert_color, 0.5f);
+ pt_final->time = interpf(pt->time, next->time, 0.5f);
+ pt_final->flag |= GP_SPOINT_SELECT;
+
+ /* interpolate weights */
+ if (gps->dvert != NULL) {
+ dvert = &temp_dverts[i];
+ dvert_next = &temp_dverts[i + 1];
+ dvert_final = &gps->dvert[i2];
+
+ dvert_final->totweight = dvert->totweight;
+ dvert_final->dw = MEM_dupallocN(dvert->dw);
+
+ /* interpolate weight values */
+ for (int d = 0; d < dvert->totweight; d++) {
+ MDeformWeight *dw_a = &dvert->dw[d];
+ if (dvert_next->totweight > d) {
+ MDeformWeight *dw_b = &dvert_next->dw[d];
+ MDeformWeight *dw_final = &dvert_final->dw[d];
+ dw_final->weight = interpf(dw_a->weight, dw_b->weight, 0.5f);
+ }
}
}
+
+ i2++;
}
}
- /* free temp memory */
- MEM_SAFE_FREE(temp_points);
- MEM_SAFE_FREE(temp_dverts);
}
+ }
+ /* free temp memory */
+ MEM_SAFE_FREE(temp_points);
+ MEM_SAFE_FREE(temp_dverts);
+ }
+}
- /* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+static int gpencil_stroke_subdivide_exec(bContext *C, wmOperator *op)
+{
+ bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const int cuts = RNA_int_get(op->ptr, "number_cuts");
+
+ /* sanity checks */
+ if (ELEM(NULL, gpd)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+
+ bool changed = false;
+ if (is_curve_edit) {
+ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
+ {
+ if (gpc->flag & GP_CURVE_SELECT) {
+ BKE_gpencil_editcurve_subdivide(gps, cuts);
+ BKE_gpencil_editcurve_recalculate_handles(gps);
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ changed = true;
+ }
}
+ GP_EDITABLE_CURVES_END(gps_iter);
}
- GP_EDITABLE_STROKES_END(gpstroke_iter);
+ else {
+ /* Go through each editable + selected stroke */
+ GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
+ if (gps->flag & GP_STROKE_SELECT) {
+ gpencil_stroke_subdivide(gps, cuts);
+ /* Calc geometry data. */
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ changed = true;
+ }
+ }
+ GP_EDITABLE_STROKES_END(gpstroke_iter);
- /* smooth stroke */
- gpencil_smooth_stroke(C, op);
+ if (changed) {
+ /* smooth stroke */
+ gpencil_smooth_stroke(C, op);
+ }
+ }
- /* notifiers */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ /* notifiers */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
+static bool gpencil_subdivide_curve_edit_poll_property(const bContext *C,
+ wmOperator *UNUSED(op),
+ const PropertyRNA *prop)
+{
+ bGPdata *gpd = ED_gpencil_data_get_active(C);
+ if (gpd != NULL && GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) {
+ const char *prop_id = RNA_property_identifier(prop);
+ /* Only show number_cuts in curve edit mode */
+ if (!STREQ(prop_id, "number_cuts")) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
void GPENCIL_OT_stroke_subdivide(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -4002,6 +4710,7 @@ void GPENCIL_OT_stroke_subdivide(wmOperatorType *ot)
/* api callbacks */
ot->exec = gpencil_stroke_subdivide_exec;
ot->poll = gpencil_active_layer_poll;
+ ot->poll_property = gpencil_subdivide_curve_edit_poll_property;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -4037,18 +4746,29 @@ static int gpencil_stroke_simplify_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* Go through each editable + selected stroke */
- GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
- if (gps->flag & GP_STROKE_SELECT) {
- /* simplify stroke using Ramer-Douglas-Peucker algorithm */
- BKE_gpencil_stroke_simplify_adaptive(gps, factor);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+
+ bool changed = false;
+ if (is_curve_edit) {
+ BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+ }
+ else {
+ /* Go through each editable + selected stroke */
+ GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
+ if (gps->flag & GP_STROKE_SELECT) {
+ /* simplify stroke using Ramer-Douglas-Peucker algorithm */
+ BKE_gpencil_stroke_simplify_adaptive(gpd, gps, factor);
+ changed = true;
+ }
}
+ GP_EDITABLE_STROKES_END(gpstroke_iter);
}
- GP_EDITABLE_STROKES_END(gpstroke_iter);
- /* notifiers */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ /* notifiers */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -4086,19 +4806,30 @@ static int gpencil_stroke_simplify_fixed_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* Go through each editable + selected stroke */
- GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
- if (gps->flag & GP_STROKE_SELECT) {
- for (int i = 0; i < steps; i++) {
- BKE_gpencil_stroke_simplify_fixed(gps);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+
+ bool changed = false;
+ if (is_curve_edit) {
+ BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+ }
+ else {
+ /* Go through each editable + selected stroke */
+ GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
+ if (gps->flag & GP_STROKE_SELECT) {
+ changed |= true;
+ for (int i = 0; i < steps; i++) {
+ BKE_gpencil_stroke_simplify_fixed(gpd, gps);
+ }
}
}
+ GP_EDITABLE_STROKES_END(gpstroke_iter);
}
- GP_EDITABLE_STROKES_END(gpstroke_iter);
- /* notifiers */
- DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ if (changed) {
+ /* notifiers */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -4140,7 +4871,7 @@ static int gpencil_stroke_sample_exec(bContext *C, wmOperator *op)
/* Go through each editable + selected stroke */
GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
if (gps->flag & GP_STROKE_SELECT) {
- BKE_gpencil_stroke_sample(gps, length, true);
+ BKE_gpencil_stroke_sample(gpd, gps, length, true);
}
}
GP_EDITABLE_STROKES_END(gpstroke_iter);
@@ -4163,7 +4894,7 @@ void GPENCIL_OT_stroke_sample(wmOperatorType *ot)
/* api callbacks */
ot->exec = gpencil_stroke_sample_exec;
- ot->poll = gpencil_active_layer_poll;
+ ot->poll = gpencil_stroke_not_in_curve_edit_mode;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -4180,7 +4911,7 @@ void GPENCIL_OT_stroke_sample(wmOperatorType *ot)
/** \name Stroke Trim Operator
* \{ */
-static int gpencil_stroke_trim_exec(bContext *C, wmOperator *UNUSED(op))
+static int gpencil_stroke_trim_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
@@ -4191,6 +4922,7 @@ static int gpencil_stroke_trim_exec(bContext *C, wmOperator *UNUSED(op))
/* Go through each editable + selected stroke */
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
@@ -4210,7 +4942,12 @@ static int gpencil_stroke_trim_exec(bContext *C, wmOperator *UNUSED(op))
}
if (gps->flag & GP_STROKE_SELECT) {
- BKE_gpencil_stroke_trim(gps);
+ if (is_curve_edit) {
+ BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+ }
+ else {
+ BKE_gpencil_stroke_trim(gpd, gps);
+ }
}
}
/* if not multiedit, exit loop*/
@@ -4290,6 +5027,7 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
}
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_src);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd_src);
/* Create a new object. */
/* Take into account user preferences for duplicating actions. */
@@ -4306,7 +5044,7 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
ob_dst->data = (bGPdata *)gpd_dst;
/* Loop old data-block and separate parts. */
- if ((mode == GP_SEPARATE_POINT) || (mode == GP_SEPARATE_STROKE)) {
+ if (ELEM(mode, GP_SEPARATE_POINT, GP_SEPARATE_STROKE)) {
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
gpl_dst = NULL;
bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
@@ -4351,27 +5089,32 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
/* selected points mode */
if (mode == GP_SEPARATE_POINT) {
- /* make copy of source stroke */
- bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps, true);
+ if (is_curve_edit) {
+ BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+ }
+ else {
+ /* make copy of source stroke */
+ bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps, true, true);
- /* Reassign material. */
- gps_dst->mat_nr = idx;
+ /* Reassign material. */
+ gps_dst->mat_nr = idx;
- /* link to destination frame */
- BLI_addtail(&gpf_dst->strokes, gps_dst);
+ /* link to destination frame */
+ BLI_addtail(&gpf_dst->strokes, gps_dst);
- /* Invert selection status of all points in destination stroke */
- for (i = 0, pt = gps_dst->points; i < gps_dst->totpoints; i++, pt++) {
- pt->flag ^= GP_SPOINT_SELECT;
- }
+ /* Invert selection status of all points in destination stroke */
+ for (i = 0, pt = gps_dst->points; i < gps_dst->totpoints; i++, pt++) {
+ pt->flag ^= GP_SPOINT_SELECT;
+ }
- /* delete selected points from destination stroke */
- gpencil_stroke_delete_tagged_points(
- gpf_dst, gps_dst, NULL, GP_SPOINT_SELECT, false, 0);
+ /* delete selected points from destination stroke */
+ gpencil_stroke_delete_tagged_points(
+ gpd_dst, gpf_dst, gps_dst, NULL, GP_SPOINT_SELECT, false, 0);
- /* delete selected points from origin stroke */
- gpencil_stroke_delete_tagged_points(
- gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
+ /* delete selected points from origin stroke */
+ gpencil_stroke_delete_tagged_points(
+ gpd_src, gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
+ }
}
/* selected strokes mode */
else if (mode == GP_SEPARATE_STROKE) {
@@ -4491,7 +5234,7 @@ void GPENCIL_OT_stroke_separate(wmOperatorType *ot)
/** \name Stroke Split Operator
* \{ */
-static int gpencil_stroke_split_exec(bContext *C, wmOperator *UNUSED(op))
+static int gpencil_stroke_split_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
@@ -4503,6 +5246,7 @@ static int gpencil_stroke_split_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
/* loop strokes and split parts */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
@@ -4527,22 +5271,29 @@ static int gpencil_stroke_split_exec(bContext *C, wmOperator *UNUSED(op))
}
/* Split selected strokes. */
if (gps->flag & GP_STROKE_SELECT) {
- /* make copy of source stroke */
- bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps, true);
+ if (is_curve_edit) {
+ BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+ }
+ else {
+ /* make copy of source stroke */
+ bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps, true, true);
- /* link to same frame */
- BLI_addtail(&gpf->strokes, gps_dst);
+ /* link to same frame */
+ BLI_addtail(&gpf->strokes, gps_dst);
- /* invert selection status of all points in destination stroke */
- for (i = 0, pt = gps_dst->points; i < gps_dst->totpoints; i++, pt++) {
- pt->flag ^= GP_SPOINT_SELECT;
- }
+ /* invert selection status of all points in destination stroke */
+ for (i = 0, pt = gps_dst->points; i < gps_dst->totpoints; i++, pt++) {
+ pt->flag ^= GP_SPOINT_SELECT;
+ }
- /* delete selected points from destination stroke */
- gpencil_stroke_delete_tagged_points(gpf, gps_dst, NULL, GP_SPOINT_SELECT, true, 0);
+ /* delete selected points from destination stroke */
+ gpencil_stroke_delete_tagged_points(
+ gpd, gpf, gps_dst, NULL, GP_SPOINT_SELECT, true, 0);
- /* delete selected points from origin stroke */
- gpencil_stroke_delete_tagged_points(gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
+ /* delete selected points from origin stroke */
+ gpencil_stroke_delete_tagged_points(
+ gpd, gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
+ }
}
}
/* select again tagged points */
@@ -4622,7 +5373,7 @@ void GPENCIL_OT_stroke_smooth(wmOperatorType *ot)
/* api callbacks */
ot->exec = gpencil_stroke_smooth_exec;
- ot->poll = gpencil_active_layer_poll;
+ ot->poll = gpencil_stroke_not_in_curve_edit_mode;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -4678,7 +5429,10 @@ typedef bool (*GPencilTestFn)(bGPDstroke *gps,
const float diff_mat[4][4],
void *user_data);
-static void gpencil_cutter_dissolve(bGPDlayer *hit_layer, bGPDstroke *hit_stroke)
+static void gpencil_cutter_dissolve(bGPdata *gpd,
+ bGPDlayer *hit_layer,
+ bGPDstroke *hit_stroke,
+ const bool flat_caps)
{
bGPDspoint *pt = NULL;
bGPDspoint *pt1 = NULL;
@@ -4722,8 +5476,19 @@ static void gpencil_cutter_dissolve(bGPDlayer *hit_layer, bGPDstroke *hit_stroke
pt->flag &= ~GP_SPOINT_TAG;
}
}
+ /* If flat caps mode check extremes. */
+ if (flat_caps) {
+ if (hit_stroke->points[0].flag & GP_SPOINT_TAG) {
+ hit_stroke->caps[0] = GP_STROKE_CAP_FLAT;
+ }
+
+ if (hit_stroke->points[hit_stroke->totpoints - 1].flag & GP_SPOINT_TAG) {
+ hit_stroke->caps[1] = GP_STROKE_CAP_FLAT;
+ }
+ }
+
gpencil_stroke_delete_tagged_points(
- hit_layer->actframe, hit_stroke, gpsn, GP_SPOINT_TAG, false, 1);
+ gpd, hit_layer->actframe, hit_stroke, gpsn, GP_SPOINT_TAG, false, 1);
}
}
@@ -4736,6 +5501,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
ScrArea *area = CTX_wm_area(C);
ToolSettings *ts = CTX_data_tool_settings(C);
const float scale = ts->gp_sculpt.isect_threshold;
+ const bool flat_caps = RNA_boolean_get(op->ptr, "flat_caps");
bGPDspoint *pt;
GP_SpaceConversion gsc = {NULL};
@@ -4780,7 +5546,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
gps->flag |= GP_STROKE_SELECT;
float r_hita[3], r_hitb[3];
if (gps->totpoints > 1) {
- ED_gpencil_select_stroke_segment(gpl, gps, pt, true, true, scale, r_hita, r_hitb);
+ ED_gpencil_select_stroke_segment(gpd, gpl, gps, pt, true, true, scale, r_hita, r_hitb);
}
/* avoid infinite loops */
if (gps->totpoints > oldtot) {
@@ -4810,7 +5576,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
}
LISTBASE_FOREACH_MUTABLE (bGPDstroke *, gps, &gpf->strokes) {
if (gps->flag & GP_STROKE_SELECT) {
- gpencil_cutter_dissolve(gpl, gps);
+ gpencil_cutter_dissolve(gpd, gpl, gps, flat_caps);
}
}
}
@@ -4884,6 +5650,8 @@ void GPENCIL_OT_stroke_cutter(wmOperatorType *ot)
/* properties */
WM_operator_properties_gesture_lasso(ot);
+
+ RNA_def_boolean(ot->srna, "flat_caps", 0, "Flat Caps", "");
}
bool ED_object_gpencil_exit(struct Main *bmain, Object *ob)
@@ -4940,13 +5708,20 @@ static int gpencil_merge_by_distance_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* Go through each editable selected stroke */
- GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
- if (gps->flag & GP_STROKE_SELECT) {
- BKE_gpencil_stroke_merge_distance(gpf_, gps, threshold, unselected);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+
+ if (is_curve_edit) {
+ /* TODO: merge curve points by distance */
+ }
+ else {
+ /* Go through each editable selected stroke */
+ GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
+ if (gps->flag & GP_STROKE_SELECT) {
+ BKE_gpencil_stroke_merge_distance(gpd, gpf_, gps, threshold, unselected);
+ }
}
+ GP_EDITABLE_STROKES_END(gpstroke_iter);
}
- GP_EDITABLE_STROKES_END(gpstroke_iter);
/* notifiers */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
diff --git a/source/blender/editors/gpencil/gpencil_edit_curve.c b/source/blender/editors/gpencil/gpencil_edit_curve.c
new file mode 100644
index 00000000000..60d1d2169b4
--- /dev/null
+++ b/source/blender/editors/gpencil/gpencil_edit_curve.c
@@ -0,0 +1,214 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2008, Blender Foundation
+ * This is a new part of Blender
+ * Operators for editing Grease Pencil strokes
+ */
+
+/** \file
+ * \ingroup edgpencil
+ */
+
+#include <math.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_gpencil_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BKE_context.h"
+#include "BKE_curve.h"
+#include "BKE_gpencil.h"
+#include "BKE_gpencil_curve.h"
+#include "BKE_gpencil_geom.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_gpencil.h"
+
+#include "DEG_depsgraph.h"
+
+#include "gpencil_intern.h"
+
+/* Poll callback for checking if there is an active layer and we are in curve edit mode. */
+static bool gpencil_curve_edit_mode_poll(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ if ((ob == NULL) || (ob->type != OB_GPENCIL)) {
+ return false;
+ }
+ bGPdata *gpd = (bGPdata *)ob->data;
+ if (!GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) {
+ return false;
+ }
+
+ bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
+ return (gpl != NULL);
+}
+
+static int gpencil_stroke_enter_editcurve_mode_exec(bContext *C, wmOperator *op)
+{
+ Object *ob = CTX_data_active_object(C);
+ bGPdata *gpd = ob->data;
+
+ float error_threshold = RNA_float_get(op->ptr, "error_threshold");
+ gpd->curve_edit_threshold = error_threshold;
+
+ if (ELEM(NULL, gpd)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
+ if (gpf == gpl->actframe) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ /* only allow selected and non-converted strokes to be transformed */
+ if ((gps->flag & GP_STROKE_SELECT && gps->editcurve == NULL) ||
+ (gps->editcurve != NULL && gps->editcurve->flag & GP_CURVE_NEEDS_STROKE_UPDATE)) {
+ BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps);
+ /* Update the selection from the stroke to the curve. */
+ BKE_gpencil_editcurve_stroke_sync_selection(gps, gps->editcurve);
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+ }
+ }
+ }
+ }
+
+ gpd->flag |= GP_DATA_CURVE_EDIT_MODE;
+
+ /* notifiers */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void GPENCIL_OT_stroke_enter_editcurve_mode(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Enter curve edit mode";
+ ot->idname = "GPENCIL_OT_stroke_enter_editcurve_mode";
+ ot->description = "Called to transform a stroke into a curve";
+
+ /* api callbacks */
+ ot->exec = gpencil_stroke_enter_editcurve_mode_exec;
+ ot->poll = gpencil_active_layer_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ prop = RNA_def_float(ot->srna,
+ "error_threshold",
+ 0.1f,
+ FLT_MIN,
+ 100.0f,
+ "Error Threshold",
+ "Threshold on the maximum deviation from the actual stroke",
+ FLT_MIN,
+ 10.f);
+ RNA_def_property_ui_range(prop, FLT_MIN, 10.0f, 0.1f, 5);
+}
+
+static int gpencil_editcurve_set_handle_type_exec(bContext *C, wmOperator *op)
+{
+ Object *ob = CTX_data_active_object(C);
+ bGPdata *gpd = ob->data;
+ const int handle_type = RNA_enum_get(op->ptr, "type");
+
+ if (ELEM(NULL, gpd)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
+ {
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ BezTriple *bezt = &gpc_pt->bezt;
+
+ if (bezt->f2 & SELECT) {
+ bezt->h1 = handle_type;
+ bezt->h2 = handle_type;
+ }
+ else {
+ if (bezt->f1 & SELECT) {
+ bezt->h1 = handle_type;
+ }
+ if (bezt->f3 & SELECT) {
+ bezt->h2 = handle_type;
+ }
+ }
+ }
+ }
+
+ BKE_gpencil_editcurve_recalculate_handles(gps);
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+ GP_EDITABLE_CURVES_END(gps_iter);
+
+ /* notifiers */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void GPENCIL_OT_stroke_editcurve_set_handle_type(wmOperatorType *ot)
+{
+ static const EnumPropertyItem editcurve_handle_type_items[] = {
+ {HD_FREE, "FREE", 0, "Free", ""},
+ {HD_AUTO, "AUTOMATIC", 0, "Automatic", ""},
+ {HD_VECT, "VECTOR", 0, "Vector", ""},
+ {HD_ALIGN, "ALIGNED", 0, "Aligned", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ /* identifiers */
+ ot->name = "Set handle type";
+ ot->idname = "GPENCIL_OT_stroke_editcurve_set_handle_type";
+ ot->description = "Set the type of a edit curve handle";
+
+ /* api callbacks */
+ ot->invoke = WM_menu_invoke;
+ ot->exec = gpencil_editcurve_set_handle_type_exec;
+ ot->poll = gpencil_curve_edit_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop = RNA_def_enum(ot->srna, "type", editcurve_handle_type_items, 1, "Type", "Spline type");
+}
+
+/** \} */
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 3c1f538cb99..93941ea3766 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -359,14 +359,12 @@ static void gpencil_draw_datablock(tGPDfill *tgpf, const float ink[4])
tgpw.custonion = true;
/* normal strokes */
- if ((tgpf->fill_draw_mode == GP_FILL_DMODE_STROKE) ||
- (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH)) {
+ if (ELEM(tgpf->fill_draw_mode, GP_FILL_DMODE_STROKE, GP_FILL_DMODE_BOTH)) {
ED_gpencil_draw_fill(&tgpw);
}
/* 3D Lines with basic shapes and invisible lines */
- if ((tgpf->fill_draw_mode == GP_FILL_DMODE_CONTROL) ||
- (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH)) {
+ if (ELEM(tgpf->fill_draw_mode, GP_FILL_DMODE_CONTROL, GP_FILL_DMODE_BOTH)) {
gpencil_draw_basic_stroke(tgpf,
gps,
tgpw.diff_mat,
@@ -1301,11 +1299,11 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
/* simplify stroke */
for (int b = 0; b < tgpf->fill_simplylvl; b++) {
- BKE_gpencil_stroke_simplify_fixed(gps);
+ BKE_gpencil_stroke_simplify_fixed(tgpf->gpd, gps);
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(tgpf->gpd, gps);
}
/* ----------------------- */
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index e3e2199f8a3..e4e9a3ae0ab 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -343,7 +343,8 @@ struct GHash *gpencil_copybuf_validate_colormap(struct bContext *C);
/* Stroke Editing ------------------------------------ */
-void gpencil_stroke_delete_tagged_points(bGPDframe *gpf,
+void gpencil_stroke_delete_tagged_points(bGPdata *gpd,
+ bGPDframe *gpf,
bGPDstroke *gps,
bGPDstroke *next_stroke,
int tag_flags,
@@ -351,7 +352,7 @@ void gpencil_stroke_delete_tagged_points(bGPDframe *gpf,
int limit);
int gpencil_delete_selected_point_wrap(bContext *C);
-void gpencil_subdivide_stroke(bGPDstroke *gps, const int subdivide);
+void gpencil_subdivide_stroke(bGPdata *gpd, bGPDstroke *gps, const int subdivide);
/* Layers Enums -------------------------------------- */
@@ -447,6 +448,11 @@ void GPENCIL_OT_snap_cursor_to_selected(struct wmOperatorType *ot);
void GPENCIL_OT_reproject(struct wmOperatorType *ot);
void GPENCIL_OT_recalc_geometry(struct wmOperatorType *ot);
+/* stroke editcurve */
+
+void GPENCIL_OT_stroke_enter_editcurve_mode(struct wmOperatorType *ot);
+void GPENCIL_OT_stroke_editcurve_set_handle_type(struct wmOperatorType *ot);
+
/* stroke sculpting -- */
void GPENCIL_OT_sculpt_paint(struct wmOperatorType *ot);
@@ -693,6 +699,55 @@ struct GP_EditableStrokes_Iter {
(void)0
/**
+ * Iterate over all editable editcurves in the current context,
+ * stopping on each usable layer + stroke + curve pair (i.e. gpl, gps and gpc)
+ * to perform some operations on the curve.
+ *
+ * \param gpl: The identifier to use for the layer of the stroke being processed.
+ * Choose a suitable value to avoid name clashes.
+ * \param gps: The identifier to use for current stroke being processed.
+ * Choose a suitable value to avoid name clashes.
+ * \param gpc: The identifier to use for current editcurve being processed.
+ * Choose a suitable value to avoid name clashes.
+ */
+#define GP_EDITABLE_CURVES_BEGIN(gpstroke_iter, C, gpl, gps, gpc) \
+ { \
+ struct GP_EditableStrokes_Iter gpstroke_iter = {{{0}}}; \
+ Depsgraph *depsgraph_ = CTX_data_ensure_evaluated_depsgraph(C); \
+ Object *obact_ = CTX_data_active_object(C); \
+ bGPdata *gpd_ = CTX_data_gpencil_data(C); \
+ const bool is_multiedit_ = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_); \
+ CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { \
+ bGPDframe *init_gpf_ = (is_multiedit_) ? gpl->frames.first : gpl->actframe; \
+ for (bGPDframe *gpf_ = init_gpf_; gpf_; gpf_ = gpf_->next) { \
+ if ((gpf_ == gpl->actframe) || ((gpf_->flag & GP_FRAME_SELECT) && is_multiedit_)) { \
+ BKE_gpencil_parent_matrix_get(depsgraph_, obact_, gpl, gpstroke_iter.diff_mat); \
+ invert_m4_m4(gpstroke_iter.inverse_diff_mat, gpstroke_iter.diff_mat); \
+ /* loop over strokes */ \
+ bGPDstroke *gpsn_; \
+ for (bGPDstroke *gps = gpf_->strokes.first; gps; gps = gpsn_) { \
+ gpsn_ = gps->next; \
+ /* skip strokes that are invalid for current view */ \
+ if (ED_gpencil_stroke_can_use(C, gps) == false) \
+ continue; \
+ if (gps->editcurve == NULL) \
+ continue; \
+ bGPDcurve *gpc = gps->editcurve; \
+ /* ... Do Stuff With Strokes ... */
+
+#define GP_EDITABLE_CURVES_END(gpstroke_iter) \
+ } \
+ } \
+ if (!is_multiedit_) { \
+ break; \
+ } \
+ } \
+ } \
+ CTX_DATA_END; \
+ } \
+ (void)0
+
+/**
* Iterate over all editable strokes using evaluated data in the current context,
* stopping on each usable layer + stroke pair (i.e. gpl and gps)
* to perform some operations on the stroke.
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 2e13566402b..3617f20763e 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -184,7 +184,7 @@ static void gpencil_interpolate_update_strokes(bContext *C, tGPDinterpolate *tgp
/* Add temp strokes. */
if (gpf) {
- bGPDstroke *gps_eval = BKE_gpencil_stroke_duplicate(new_stroke, true);
+ bGPDstroke *gps_eval = BKE_gpencil_stroke_duplicate(new_stroke, true, true);
gps_eval->flag |= GP_STROKE_TAG;
BLI_addtail(&gpf->strokes, gps_eval);
}
@@ -220,7 +220,7 @@ static bool gpencil_interpolate_check_todo(bContext *C, bGPdata *gpd)
int fFrame;
/* only selected */
- if ((flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) &&
+ if ((GPENCIL_EDIT_MODE(gpd)) && (flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) &&
((gps_from->flag & GP_STROKE_SELECT) == 0)) {
continue;
}
@@ -305,7 +305,7 @@ static void gpencil_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
bool valid = true;
/* only selected */
- if ((tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) &&
+ if ((GPENCIL_EDIT_MODE(gpd)) && (tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) &&
((gps_from->flag & GP_STROKE_SELECT) == 0)) {
valid = false;
}
@@ -327,7 +327,7 @@ static void gpencil_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
}
/* create new stroke */
- new_stroke = BKE_gpencil_stroke_duplicate(gps_from, true);
+ new_stroke = BKE_gpencil_stroke_duplicate(gps_from, true, true);
if (valid) {
/* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */
@@ -353,7 +353,7 @@ static void gpencil_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(new_stroke);
+ BKE_gpencil_stroke_geometry_update(gpd, new_stroke);
/* add to strokes */
BLI_addtail(&tgpil->interFrame->strokes, new_stroke);
}
@@ -608,11 +608,11 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
}
/* make copy of source stroke, then adjust pointer to points too */
- gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true);
+ gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true, true);
gps_dst->flag &= ~GP_STROKE_TAG;
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps_dst);
+ BKE_gpencil_stroke_geometry_update(tgpi->gpd, gps_dst);
BLI_addtail(&gpf_dst->strokes, gps_dst);
}
@@ -1023,7 +1023,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
for (gps_from = prevFrame->strokes.first; gps_from; gps_from = gps_from->next) {
/* only selected */
- if ((flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) &&
+ if ((GPENCIL_EDIT_MODE(gpd)) && (flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) &&
((gps_from->flag & GP_STROKE_SELECT) == 0)) {
continue;
}
@@ -1050,7 +1050,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
}
/* create new stroke */
- bGPDstroke *new_stroke = BKE_gpencil_stroke_duplicate(gps_from, true);
+ bGPDstroke *new_stroke = BKE_gpencil_stroke_duplicate(gps_from, true, true);
/* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */
if (gps_from->totpoints > gps_to->totpoints) {
@@ -1075,7 +1075,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
gpencil_interpolate_update_points(gps_from, gps_to, new_stroke, factor);
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(new_stroke);
+ BKE_gpencil_stroke_geometry_update(gpd, new_stroke);
/* add to strokes */
BLI_addtail(&interFrame->strokes, new_stroke);
diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c
index 3e63d644760..f795ed01bb8 100644
--- a/source/blender/editors/gpencil/gpencil_merge.c
+++ b/source/blender/editors/gpencil/gpencil_merge.c
@@ -172,6 +172,9 @@ static void gpencil_get_elements_len(bContext *C, int *totstrokes, int *totpoint
static void gpencil_dissolve_points(bContext *C)
{
+ Object *ob = CTX_data_active_object(C);
+ bGPdata *gpd = ob->data;
+
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *gpf = gpl->actframe;
if (gpf == NULL) {
@@ -179,7 +182,7 @@ static void gpencil_dissolve_points(bContext *C)
}
LISTBASE_FOREACH_MUTABLE (bGPDstroke *, gps, &gpf->strokes) {
- gpencil_stroke_delete_tagged_points(gpf, gps, gps->next, GP_SPOINT_TAG, false, 0);
+ gpencil_stroke_delete_tagged_points(gpd, gpf, gps, gps->next, GP_SPOINT_TAG, false, 0);
}
}
CTX_DATA_END;
@@ -314,7 +317,7 @@ static int gpencil_insert_to_array(tGPencilPointCache *src_array,
}
src_elem = &src_array[idx];
/* check if all points or only a stroke */
- if ((gps_filter != NULL) && (gps_filter != src_elem->gps)) {
+ if (!ELEM(gps_filter, NULL, src_elem->gps)) {
continue;
}
@@ -519,7 +522,7 @@ static int gpencil_stroke_merge_exec(bContext *C, wmOperator *op)
gpencil_dissolve_points(C);
}
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
/* free memory */
MEM_SAFE_FREE(original_array);
diff --git a/source/blender/editors/gpencil/gpencil_mesh.c b/source/blender/editors/gpencil/gpencil_mesh.c
index e4862617d12..84314202dfc 100644
--- a/source/blender/editors/gpencil/gpencil_mesh.c
+++ b/source/blender/editors/gpencil/gpencil_mesh.c
@@ -25,17 +25,21 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_ghash.h"
#include "BLI_math.h"
+#include "DNA_anim_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
+#include "BKE_anim_data.h"
#include "BKE_context.h"
#include "BKE_duplilist.h"
#include "BKE_global.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_geom.h"
+#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_object.h"
@@ -86,6 +90,35 @@ typedef struct GpBakeOb {
Object *ob;
} GpBakeOb;
+/* Get list of keyframes used by selected objects. */
+static void animdata_keyframe_list_get(ListBase *ob_list,
+ const bool only_selected,
+ GHash *r_keyframes)
+{
+ /* Loop all objects to get the list of keyframes used. */
+ LISTBASE_FOREACH (GpBakeOb *, elem, ob_list) {
+ Object *ob = elem->ob;
+ AnimData *adt = BKE_animdata_from_id(&ob->id);
+ if ((adt == NULL) || (adt->action == NULL)) {
+ continue;
+ }
+ LISTBASE_FOREACH (FCurve *, fcurve, &adt->action->curves) {
+ int i;
+ BezTriple *bezt;
+ for (i = 0, bezt = fcurve->bezt; i < fcurve->totvert; i++, bezt++) {
+ /* Keyframe number is x value of point. */
+ if ((bezt->f2 & SELECT) || (!only_selected)) {
+ /* Insert only one key for each keyframe number. */
+ int key = (int)bezt->vec[1][0];
+ if (!BLI_ghash_haskey(r_keyframes, POINTER_FROM_INT(key))) {
+ BLI_ghash_insert(r_keyframes, POINTER_FROM_INT(key), POINTER_FROM_INT(key));
+ }
+ }
+ }
+ }
+ }
+}
+
static void gpencil_bake_duplilist(Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *list)
{
GpBakeOb *elem = NULL;
@@ -159,15 +192,14 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
ARegion *region = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
- Object *ob_gpencil = NULL;
- ListBase list = {NULL, NULL};
- gpencil_bake_ob_list(C, depsgraph, scene, &list);
+ ListBase ob_selected_list = {NULL, NULL};
+ gpencil_bake_ob_list(C, depsgraph, scene, &ob_selected_list);
/* Cannot check this in poll because the active object changes. */
- if (list.first == NULL) {
+ if (ob_selected_list.first == NULL) {
BKE_report(op->reports, RPT_INFO, "No valid object selected");
- gpencil_bake_free_ob_list(&list);
+ gpencil_bake_free_ob_list(&ob_selected_list);
return OPERATOR_CANCELLED;
}
@@ -186,29 +218,36 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
const int thickness = RNA_int_get(op->ptr, "thickness");
const bool use_seams = RNA_boolean_get(op->ptr, "seams");
const bool use_faces = RNA_boolean_get(op->ptr, "faces");
+ const bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
const float offset = RNA_float_get(op->ptr, "offset");
const int frame_offset = RNA_int_get(op->ptr, "frame_target") - frame_start;
- char target[64];
- RNA_string_get(op->ptr, "target", target);
const int project_type = RNA_enum_get(op->ptr, "project_type");
+ eGP_TargetObjectMode target = RNA_enum_get(op->ptr, "target");
- /* Create a new grease pencil object in origin. */
+ /* Create a new grease pencil object in origin or reuse selected. */
+ Object *ob_gpencil = NULL;
bool newob = false;
- if (STREQ(target, "*NEW")) {
+
+ if (target == GP_TARGET_OB_SELECTED) {
+ ob_gpencil = BKE_view_layer_non_active_selected_object(CTX_data_view_layer(C), v3d);
+ if (ob_gpencil != NULL) {
+ if (ob_gpencil->type != OB_GPENCIL) {
+ BKE_report(op->reports, RPT_WARNING, "Target object not a grease pencil, ignoring!");
+ ob_gpencil = NULL;
+ }
+ else if (BKE_object_obdata_is_libdata(ob_gpencil)) {
+ BKE_report(op->reports, RPT_WARNING, "Target object library-data, ignoring!");
+ ob_gpencil = NULL;
+ }
+ }
+ }
+
+ if (ob_gpencil == NULL) {
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
const float loc[3] = {0.0f, 0.0f, 0.0f};
ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits);
newob = true;
}
- else {
- ob_gpencil = BLI_findstring(&bmain->objects, target, offsetof(ID, name) + 2);
- }
-
- if ((ob_gpencil == NULL) || (ob_gpencil->type != OB_GPENCIL)) {
- BKE_report(op->reports, RPT_ERROR, "Target grease pencil object not valid");
- gpencil_bake_free_ob_list(&list);
- return OPERATOR_CANCELLED;
- }
bGPdata *gpd = (bGPdata *)ob_gpencil->data;
gpd->draw_mode = (project_type == GP_REPROJECT_KEEP) ? GP_DRAWMODE_3D : GP_DRAWMODE_2D;
@@ -221,6 +260,9 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
if (project_type != GP_REPROJECT_KEEP) {
/* Init space conversion stuff. */
gpencil_point_conversion_init(C, &gsc);
+ /* Move the grease pencil object to conversion data. */
+ gsc.ob = ob_gpencil;
+
/* Init snap context for geometry projection. */
sctx = ED_transform_snap_object_context_create_view3d(scene, 0, region, CTX_wm_view3d(C));
@@ -237,6 +279,13 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
/* Loop all frame range. */
int oldframe = (int)DEG_get_ctime(depsgraph);
int key = -1;
+
+ /* Get list of keyframes. */
+ GHash *keyframe_list = BLI_ghash_int_new(__func__);
+ if (only_selected) {
+ animdata_keyframe_list_get(&ob_selected_list, only_selected, keyframe_list);
+ }
+
for (int i = frame_start; i < frame_end + 1; i++) {
key++;
/* Jump if not step limit but include last frame always. */
@@ -244,12 +293,17 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
continue;
}
+ /* Check if frame is in the list of frames to be exported. */
+ if ((only_selected) && (!BLI_ghash_haskey(keyframe_list, POINTER_FROM_INT(i)))) {
+ continue;
+ }
+
/* Move scene to new frame. */
CFRA = i;
BKE_scene_graph_update_for_newframe(depsgraph);
/* Loop all objects in the list. */
- LISTBASE_FOREACH (GpBakeOb *, elem, &list) {
+ LISTBASE_FOREACH (GpBakeOb *, elem, &ob_selected_list) {
Object *ob_eval = (Object *)DEG_get_evaluated_object(depsgraph, elem->ob);
/* Generate strokes. */
@@ -270,13 +324,14 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
if (project_type != GP_REPROJECT_KEEP) {
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
bGPDframe *gpf = gpl->actframe;
- if (gpf != NULL) {
- LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- if ((gps->flag & GP_STROKE_TAG) == 0) {
- ED_gpencil_stroke_reproject(
- depsgraph, &gsc, sctx, gpl, gpf, gps, project_type, false);
- gps->flag |= GP_STROKE_TAG;
- }
+ if (gpf == NULL) {
+ continue;
+ }
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ if ((gps->flag & GP_STROKE_TAG) == 0) {
+ ED_gpencil_stroke_reproject(
+ depsgraph, &gsc, sctx, gpl, gpf, gps, project_type, false);
+ gps->flag |= GP_STROKE_TAG;
}
}
}
@@ -314,10 +369,14 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
}
/* Free memory. */
- gpencil_bake_free_ob_list(&list);
+ gpencil_bake_free_ob_list(&ob_selected_list);
if (sctx != NULL) {
ED_transform_snap_object_context_destroy(sctx);
}
+ /* Free temp hash table. */
+ if (keyframe_list != NULL) {
+ BLI_ghash_free(keyframe_list, NULL, NULL);
+ }
/* notifiers */
if (newob) {
@@ -334,6 +393,15 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int gpencil_bake_mesh_animation_invoke(bContext *C,
+ wmOperator *op,
+ const wmEvent *UNUSED(event))
+{
+ /* Show popup dialog to allow editing. */
+ /* FIXME: hard-coded dimensions here are just arbitrary. */
+ return WM_operator_props_dialog_popup(C, op, 250);
+}
+
void GPENCIL_OT_bake_mesh_animation(wmOperatorType *ot)
{
static const EnumPropertyItem reproject_type[] = {
@@ -355,6 +423,12 @@ void GPENCIL_OT_bake_mesh_animation(wmOperatorType *ot)
{0, NULL, 0, NULL, NULL},
};
+ static const EnumPropertyItem target_object_modes[] = {
+ {GP_TARGET_OB_NEW, "NEW", 0, "New Object", ""},
+ {GP_TARGET_OB_SELECTED, "SELECTED", 0, "Selected Object", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
PropertyRNA *prop;
/* identifiers */
@@ -363,6 +437,7 @@ void GPENCIL_OT_bake_mesh_animation(wmOperatorType *ot)
ot->description = "Bake Mesh Animation to Grease Pencil strokes";
/* callbacks */
+ ot->invoke = gpencil_bake_mesh_animation_invoke;
ot->exec = gpencil_bake_mesh_animation_exec;
ot->poll = gpencil_bake_mesh_animation_poll;
@@ -370,7 +445,15 @@ void GPENCIL_OT_bake_mesh_animation(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- ot->prop = RNA_def_int(
+ ot->prop = RNA_def_enum(ot->srna,
+ "target",
+ target_object_modes,
+ GP_TARGET_OB_NEW,
+ "Target Object",
+ "Target grease pencil");
+ RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
+
+ prop = RNA_def_int(
ot->srna, "frame_start", 1, 1, 100000, "Start Frame", "The start frame", 1, 100000);
prop = RNA_def_int(
@@ -379,6 +462,8 @@ void GPENCIL_OT_bake_mesh_animation(wmOperatorType *ot)
prop = RNA_def_int(ot->srna, "step", 1, 1, 100, "Step", "Step between generated frames", 1, 100);
+ RNA_def_int(ot->srna, "thickness", 1, 1, 100, "Thickness", "", 1, 100);
+
prop = RNA_def_float_rotation(ot->srna,
"angle",
0,
@@ -391,18 +476,22 @@ void GPENCIL_OT_bake_mesh_animation(wmOperatorType *ot)
DEG2RADF(180.0f));
RNA_def_property_float_default(prop, DEG2RADF(70.0f));
- RNA_def_int(ot->srna, "thickness", 1, 1, 100, "Thickness", "", 1, 100);
+ RNA_def_float_distance(ot->srna,
+ "offset",
+ 0.001f,
+ 0.0,
+ 100.0,
+ "Stroke Offset",
+ "Offset strokes from fill",
+ 0.0,
+ 100.00);
+
RNA_def_boolean(ot->srna, "seams", 0, "Only Seam Edges", "Convert only seam edges");
RNA_def_boolean(ot->srna, "faces", 1, "Export Faces", "Export faces as filled strokes");
- RNA_def_float_distance(
- ot->srna, "offset", 0.001f, 0.0, 100.0, "Offset", "Offset strokes from fill", 0.0, 100.00);
- RNA_def_int(ot->srna, "frame_target", 1, 1, 100000, "Frame Target", "", 1, 100000);
- RNA_def_string(ot->srna,
- "target",
- "*NEW",
- 64,
- "Target Object",
- "Target grease pencil object name. Leave empty for new object");
+ RNA_def_boolean(
+ ot->srna, "only_selected", 0, "Only Selected Keyframes", "Convert only selected keyframes");
+ RNA_def_int(
+ ot->srna, "frame_target", 1, 1, 100000, "Target Frame", "Destination frame", 1, 100000);
RNA_def_enum(ot->srna, "project_type", reproject_type, GP_REPROJECT_VIEW, "Projection Type", "");
}
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index 9f7725e01f5..33ac0c5bbbf 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -69,6 +69,13 @@ static bool gpencil_stroke_editmode_poll(bContext *C)
return (gpd && (gpd->flag & GP_DATA_STROKE_EDITMODE));
}
+/* Poll callback for stroke curve editing mode */
+static bool gpencil_stroke_editmode_curve_poll(bContext *C)
+{
+ bGPdata *gpd = CTX_data_gpencil_data(C);
+ return (GPENCIL_EDIT_MODE(gpd) && GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd));
+}
+
/* Poll callback for stroke painting mode */
static bool gpencil_stroke_paintmode_poll(bContext *C)
{
@@ -315,6 +322,15 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
keymap->poll = gpencil_stroke_editmode_poll;
}
+/* Stroke Curve Editing Keymap - Only when editmode is enabled and in curve edit mode */
+static void ed_keymap_gpencil_curve_editing(wmKeyConfig *keyconf)
+{
+ wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Curve Edit Mode", 0, 0);
+
+ /* set poll callback - so that this keymap only gets enabled when curve editmode is enabled */
+ keymap->poll = gpencil_stroke_editmode_curve_poll;
+}
+
/* keys for draw with a drawing brush (no fill) */
static void ed_keymap_gpencil_painting_draw(wmKeyConfig *keyconf)
{
@@ -471,6 +487,7 @@ static void ed_keymap_gpencil_weightpainting_draw(wmKeyConfig *keyconf)
void ED_keymap_gpencil(wmKeyConfig *keyconf)
{
ed_keymap_gpencil_general(keyconf);
+ ed_keymap_gpencil_curve_editing(keyconf);
ed_keymap_gpencil_editing(keyconf);
ed_keymap_gpencil_painting(keyconf);
ed_keymap_gpencil_painting_draw(keyconf);
@@ -568,6 +585,11 @@ void ED_operatortypes_gpencil(void)
WM_operatortype_append(GPENCIL_OT_sculpt_paint);
WM_operatortype_append(GPENCIL_OT_weight_paint);
+ /* Edit stroke editcurve */
+
+ WM_operatortype_append(GPENCIL_OT_stroke_enter_editcurve_mode);
+ WM_operatortype_append(GPENCIL_OT_stroke_editcurve_set_handle_type);
+
/* Editing (Buttons) ------------ */
WM_operatortype_append(GPENCIL_OT_annotation_add);
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 543ff8e7e9a..e544093cd1d 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1152,7 +1152,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
/* invalidate any other point, to interpolate between
* first and last contact in an imaginary line between them */
for (i = 0; i < gpd->runtime.sbuffer_used; i++) {
- if ((i != first_valid) && (i != last_valid)) {
+ if (!ELEM(i, first_valid, last_valid)) {
depth_arr[i] = FLT_MAX;
}
}
@@ -1195,7 +1195,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
/* subdivide and smooth the stroke */
if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) && (subdivide > 0)) {
- gpencil_subdivide_stroke(gps, subdivide);
+ gpencil_subdivide_stroke(gpd, gps, subdivide);
}
/* Smooth stroke after subdiv - only if there's something to do for each iteration,
@@ -1226,7 +1226,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
/* Simplify adaptive */
if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) &&
(brush->gpencil_settings->simplify_f > 0.0f)) {
- BKE_gpencil_stroke_simplify_adaptive(gps, brush->gpencil_settings->simplify_f);
+ BKE_gpencil_stroke_simplify_adaptive(gpd, gps, brush->gpencil_settings->simplify_f);
}
/* reproject to plane (only in 3d space) */
@@ -1279,11 +1279,11 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
/* post process stroke */
if ((p->brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) &&
p->brush->gpencil_settings->flag & GP_BRUSH_TRIM_STROKE) {
- BKE_gpencil_stroke_trim(gps);
+ BKE_gpencil_stroke_trim(gpd, gps);
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gpencil_stroke_added_enable(p);
}
@@ -1652,7 +1652,7 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p,
gpencil_stroke_soft_refine(gps);
}
- gpencil_stroke_delete_tagged_points(gpf, gps, gps->next, GP_SPOINT_TAG, false, 0);
+ gpencil_stroke_delete_tagged_points(p->gpd, gpf, gps, gps->next, GP_SPOINT_TAG, false, 0);
}
gpencil_update_cache(p->gpd);
}
@@ -2719,7 +2719,7 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra
short ok = gpencil_stroke_addpoint(p, p->mval, p->pressure, p->curtime);
/* handle errors while adding point */
- if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) {
+ if (ELEM(ok, GP_STROKEADD_FULL, GP_STROKEADD_OVERFLOW)) {
/* finish off old stroke */
gpencil_paint_strokeend(p);
/* And start a new one!!! Else, projection errors! */
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index c03ff05ac73..801dacb3e6b 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -849,7 +849,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
/* invalidate any other point, to interpolate between
* first and last contact in an imaginary line between them */
for (i = 0; i < gps->totpoints; i++) {
- if ((i != first_valid) && (i != last_valid)) {
+ if (!ELEM(i, first_valid, last_valid)) {
depth_arr[i] = FLT_MAX;
}
}
@@ -1082,7 +1082,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
/* Update evaluated data. */
ED_gpencil_sbuffer_update_eval(tgpi->gpd, tgpi->ob_eval);
@@ -1323,7 +1323,7 @@ static void gpencil_primitive_interaction_end(bContext *C,
copy_v2_v2(gps->aspect_ratio, brush_settings->aspect_ratio);
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(tgpi->gpd, gps);
}
/* transfer stroke from temporary buffer to the actual frame */
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 1d500223ab8..ed18c2eed5d 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -303,7 +303,7 @@ static void gpencil_update_geometry(bGPdata *gpd)
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
if (gps->flag & GP_STROKE_TAG) {
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
gps->flag &= ~GP_STROKE_TAG;
}
}
@@ -1021,7 +1021,7 @@ static void gpencil_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_NEW);
/* Make a new stroke */
- new_stroke = BKE_gpencil_stroke_duplicate(gps, true);
+ new_stroke = BKE_gpencil_stroke_duplicate(gps, true, true);
new_stroke->next = new_stroke->prev = NULL;
BLI_addtail(&gpf->strokes, new_stroke);
@@ -1574,6 +1574,7 @@ static bool gpencil_sculpt_brush_do_frame(bContext *C,
bool changed = false;
bool redo_geom = false;
Object *ob = gso->object;
+ bGPdata *gpd = ob->data;
char tool = gso->brush->gpencil_sculpt_tool;
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
@@ -1672,7 +1673,7 @@ static bool gpencil_sculpt_brush_do_frame(bContext *C,
MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
/* Update active frame now, only if material has fill. */
if (gp_style->flag & GP_MATERIAL_FILL_SHOW) {
- BKE_gpencil_stroke_geometry_update(gps_active);
+ BKE_gpencil_stroke_geometry_update(gpd, gps_active);
}
else {
gpencil_recalc_geometry_tag(gps_active);
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 82d5eedf576..2c0b9534141 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -43,10 +43,13 @@
#include "BKE_context.h"
#include "BKE_gpencil.h"
+#include "BKE_gpencil_curve.h"
+#include "BKE_gpencil_geom.h"
#include "BKE_material.h"
#include "BKE_report.h"
#include "UI_interface.h"
+#include "UI_resources.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -58,6 +61,7 @@
#include "ED_gpencil.h"
#include "ED_select_utils.h"
+#include "ED_view3d.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -126,6 +130,86 @@ static bool gpencil_select_poll(bContext *C)
return false;
}
+static bool gpencil_3d_point_to_screen_space(ARegion *region,
+ const float diff_mat[4][4],
+ const float co[3],
+ int r_co[2])
+{
+ float parent_co[3];
+ mul_v3_m4v3(parent_co, diff_mat, co);
+ int screen_co[2];
+ if (ED_view3d_project_int_global(
+ region, parent_co, screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) ==
+ V3D_PROJ_RET_OK) {
+ if (!ELEM(V2D_IS_CLIPPED, screen_co[0], screen_co[1])) {
+ copy_v2_v2_int(r_co, screen_co);
+ return true;
+ }
+ }
+ r_co[0] = V2D_IS_CLIPPED;
+ r_co[1] = V2D_IS_CLIPPED;
+ return false;
+}
+
+/* helper to deselect all selected strokes/points */
+static void deselect_all_selected(bContext *C)
+{
+ CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
+ /* deselect stroke and its points if selected */
+ if (gps->flag & GP_STROKE_SELECT) {
+ bGPDspoint *pt;
+ int i;
+
+ /* deselect points */
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ }
+
+ /* deselect stroke itself too */
+ gps->flag &= ~GP_STROKE_SELECT;
+ }
+
+ /* deselect curve and curve points */
+ if (gps->editcurve != NULL) {
+ bGPDcurve *gpc = gps->editcurve;
+ for (int j = 0; j < gpc->tot_curve_points; j++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[j];
+ BezTriple *bezt = &gpc_pt->bezt;
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ }
+
+ gpc->flag &= ~GP_CURVE_SELECT;
+ }
+ }
+ CTX_DATA_END;
+}
+
+static void select_all_curve_points(bGPDstroke *gps, bGPDcurve *gpc, bool deselect)
+{
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (deselect == false) {
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(bezt);
+ }
+ else {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ }
+ }
+
+ if (deselect == false) {
+ gpc->flag |= GP_CURVE_SELECT;
+ gps->flag |= GP_STROKE_SELECT;
+ }
+ else {
+ gpc->flag &= ~GP_CURVE_SELECT;
+ gps->flag &= ~GP_STROKE_SELECT;
+ }
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -149,6 +233,7 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
int action = RNA_enum_get(op->ptr, "action");
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
@@ -168,7 +253,12 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op)
}
}
- ED_gpencil_select_toggle_all(C, action);
+ if (is_curve_edit) {
+ ED_gpencil_select_curve_toggle_all(C, action);
+ }
+ else {
+ ED_gpencil_select_toggle_all(C, action);
+ }
/* updates */
DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
@@ -207,6 +297,7 @@ void GPENCIL_OT_select_all(wmOperatorType *ot)
static int gpencil_select_linked_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
@@ -218,18 +309,34 @@ static int gpencil_select_linked_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* select all points in selected strokes */
- CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
- if (gps->flag & GP_STROKE_SELECT) {
- bGPDspoint *pt;
- int i;
+ if (is_curve_edit) {
+ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
+ {
+ if (gpc->flag & GP_CURVE_SELECT) {
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(bezt);
+ }
+ }
+ }
+ GP_EDITABLE_CURVES_END(gps_iter);
+ }
+ else {
+ /* select all points in selected strokes */
+ CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
+ if (gps->flag & GP_STROKE_SELECT) {
+ bGPDspoint *pt;
+ int i;
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- pt->flag |= GP_SPOINT_SELECT;
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ pt->flag |= GP_SPOINT_SELECT;
+ }
}
}
+ CTX_DATA_END;
}
- CTX_DATA_END;
/* updates */
DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
@@ -265,8 +372,9 @@ void GPENCIL_OT_select_linked(wmOperatorType *ot)
static int gpencil_select_alternate_exec(bContext *C, wmOperator *op)
{
- const bool unselect_ends = RNA_boolean_get(op->ptr, "unselect_ends");
bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool unselect_ends = RNA_boolean_get(op->ptr, "unselect_ends");
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
if (gpd == NULL) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
@@ -278,47 +386,94 @@ static int gpencil_select_alternate_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* select all points in selected strokes */
- CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
- if ((gps->flag & GP_STROKE_SELECT) && (gps->totpoints > 1)) {
- bGPDspoint *pt;
- int row = 0;
- int start = 0;
- if (unselect_ends) {
- start = 1;
- }
+ bool changed = false;
+ if (is_curve_edit) {
+ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
+ {
+ if ((gps->flag & GP_STROKE_SELECT) && (gps->totpoints > 1)) {
+ int idx = 0;
+ int start = 0;
+ if (unselect_ends) {
+ start = 1;
+ }
- for (int i = start; i < gps->totpoints; i++) {
- pt = &gps->points[i];
- if ((row % 2) == 0) {
- pt->flag |= GP_SPOINT_SELECT;
+ for (int i = start; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ if ((idx % 2) == 0) {
+ gpc_pt->flag |= GP_SPOINT_SELECT;
+ BEZT_SEL_ALL(&gpc_pt->bezt);
+ }
+ else {
+ gpc_pt->flag &= ~GP_SPOINT_SELECT;
+ BEZT_DESEL_ALL(&gpc_pt->bezt);
+ }
+ idx++;
}
- else {
- pt->flag &= ~GP_SPOINT_SELECT;
+
+ if (unselect_ends) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[0];
+ gpc_pt->flag &= ~GP_SPOINT_SELECT;
+ BEZT_DESEL_ALL(&gpc_pt->bezt);
+
+ gpc_pt = &gpc->curve_points[gpc->tot_curve_points - 1];
+ gpc_pt->flag &= ~GP_SPOINT_SELECT;
+ BEZT_DESEL_ALL(&gpc_pt->bezt);
}
- row++;
+
+ BKE_gpencil_curve_sync_selection(gps);
+ changed = true;
}
+ }
+ GP_EDITABLE_CURVES_END(gps_iter);
+ }
+ else {
+ /* select all points in selected strokes */
+ CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
+ if ((gps->flag & GP_STROKE_SELECT) && (gps->totpoints > 1)) {
+ bGPDspoint *pt;
+ int row = 0;
+ int start = 0;
+ if (unselect_ends) {
+ start = 1;
+ }
- /* unselect start and end points */
- if (unselect_ends) {
- pt = &gps->points[0];
- pt->flag &= ~GP_SPOINT_SELECT;
+ for (int i = start; i < gps->totpoints; i++) {
+ pt = &gps->points[i];
+ if ((row % 2) == 0) {
+ pt->flag |= GP_SPOINT_SELECT;
+ }
+ else {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ }
+ row++;
+ }
- pt = &gps->points[gps->totpoints - 1];
- pt->flag &= ~GP_SPOINT_SELECT;
+ /* unselect start and end points */
+ if (unselect_ends) {
+ pt = &gps->points[0];
+ pt->flag &= ~GP_SPOINT_SELECT;
+
+ pt = &gps->points[gps->totpoints - 1];
+ pt->flag &= ~GP_SPOINT_SELECT;
+ }
+
+ changed = true;
}
}
+ CTX_DATA_END;
}
- CTX_DATA_END;
- /* updates */
- DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
+ if (changed) {
+ /* updates */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
- /* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+ /* copy on write tag is needed, or else no refresh happens */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+
+ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ }
- WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
return OPERATOR_FINISHED;
}
@@ -365,10 +520,13 @@ typedef enum eGP_SelectGrouped {
/* ----------------------------------- */
/* On each visible layer, check for selected strokes - if found, select all others */
-static void gpencil_select_same_layer(bContext *C)
+static bool gpencil_select_same_layer(bContext *C)
{
Scene *scene = CTX_data_scene(C);
+ bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+ bool changed = false;
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_USE_PREV);
bGPDstroke *gps;
@@ -390,29 +548,55 @@ static void gpencil_select_same_layer(bContext *C)
/* Select all if found */
if (found) {
- for (gps = gpf->strokes.first; gps; gps = gps->next) {
- if (ED_gpencil_stroke_can_use(C, gps)) {
- bGPDspoint *pt;
- int i;
-
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- pt->flag |= GP_SPOINT_SELECT;
+ if (is_curve_edit) {
+ for (gps = gpf->strokes.first; gps; gps = gps->next) {
+ if (gps->editcurve != NULL && ED_gpencil_stroke_can_use(C, gps)) {
+ bGPDcurve *gpc = gps->editcurve;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(&gpc_pt->bezt);
+ }
+ gpc->flag |= GP_CURVE_SELECT;
+ gps->flag |= GP_STROKE_SELECT;
+
+ changed = true;
}
+ }
+ }
+ else {
+ for (gps = gpf->strokes.first; gps; gps = gps->next) {
+ if (ED_gpencil_stroke_can_use(C, gps)) {
+ bGPDspoint *pt;
+ int i;
+
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ pt->flag |= GP_SPOINT_SELECT;
+ }
+
+ gps->flag |= GP_STROKE_SELECT;
- gps->flag |= GP_STROKE_SELECT;
+ changed = true;
+ }
}
}
}
}
CTX_DATA_END;
+
+ return changed;
}
/* Select all strokes with same colors as selected ones */
-static void gpencil_select_same_material(bContext *C)
+static bool gpencil_select_same_material(bContext *C)
{
+ bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
/* First, build set containing all the colors of selected strokes */
GSet *selected_colors = BLI_gset_str_new("GP Selected Colors");
+ bool changed = false;
+
CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
if (gps->flag & GP_STROKE_SELECT) {
/* add instead of insert here, otherwise the uniqueness check gets skipped,
@@ -424,25 +608,48 @@ static void gpencil_select_same_material(bContext *C)
CTX_DATA_END;
/* Second, select any visible stroke that uses these colors */
- CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
- if (BLI_gset_haskey(selected_colors, &gps->mat_nr)) {
- /* select this stroke */
- bGPDspoint *pt;
- int i;
+ if (is_curve_edit) {
+ CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
+ if (gps->editcurve != NULL && BLI_gset_haskey(selected_colors, &gps->mat_nr)) {
+ bGPDcurve *gpc = gps->editcurve;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(&gpc_pt->bezt);
+ }
+ gpc->flag |= GP_CURVE_SELECT;
+ gps->flag |= GP_STROKE_SELECT;
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- pt->flag |= GP_SPOINT_SELECT;
+ changed = true;
}
+ }
+ CTX_DATA_END;
+ }
+ else {
+ CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
+ if (BLI_gset_haskey(selected_colors, &gps->mat_nr)) {
+ /* select this stroke */
+ bGPDspoint *pt;
+ int i;
- gps->flag |= GP_STROKE_SELECT;
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ pt->flag |= GP_SPOINT_SELECT;
+ }
+
+ gps->flag |= GP_STROKE_SELECT;
+
+ changed = true;
+ }
}
+ CTX_DATA_END;
}
- CTX_DATA_END;
/* free memomy */
if (selected_colors != NULL) {
BLI_gset_free(selected_colors, NULL);
}
+
+ return changed;
}
/* ----------------------------------- */
@@ -456,12 +663,14 @@ static int gpencil_select_grouped_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ bool changed = false;
+
switch (mode) {
case GP_SEL_SAME_LAYER:
- gpencil_select_same_layer(C);
+ changed = gpencil_select_same_layer(C);
break;
case GP_SEL_SAME_MATERIAL:
- gpencil_select_same_material(C);
+ changed = gpencil_select_same_material(C);
break;
default:
@@ -469,14 +678,16 @@ static int gpencil_select_grouped_exec(bContext *C, wmOperator *op)
break;
}
- /* updates */
- DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
+ if (changed) {
+ /* updates */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
- /* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+ /* copy on write tag is needed, or else no refresh happens */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
- WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -515,6 +726,8 @@ void GPENCIL_OT_select_grouped(wmOperatorType *ot)
static int gpencil_select_first_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+
/* if not edit/sculpt mode, the event is catched but not processed */
if (GPENCIL_NONE_EDIT_MODE(gpd)) {
return OPERATOR_CANCELLED;
@@ -523,6 +736,7 @@ static int gpencil_select_first_exec(bContext *C, wmOperator *op)
const bool only_selected = RNA_boolean_get(op->ptr, "only_selected_strokes");
const bool extend = RNA_boolean_get(op->ptr, "extend");
+ bool changed = false;
CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
/* skip stroke if we're only manipulating selected strokes */
if (only_selected && !(gps->flag & GP_STROKE_SELECT)) {
@@ -532,30 +746,53 @@ static int gpencil_select_first_exec(bContext *C, wmOperator *op)
/* select first point */
BLI_assert(gps->totpoints >= 1);
- gps->points->flag |= GP_SPOINT_SELECT;
- gps->flag |= GP_STROKE_SELECT;
+ if (is_curve_edit) {
+ if (gps->editcurve != NULL) {
+ bGPDcurve *gpc = gps->editcurve;
+ gpc->curve_points[0].flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(&gpc->curve_points[0].bezt);
+ gpc->flag |= GP_CURVE_SELECT;
+ gps->flag |= GP_STROKE_SELECT;
+ if ((extend == false) && (gps->totpoints > 1)) {
+ for (int i = 1; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(&gpc_pt->bezt);
+ }
+ }
+ changed = true;
+ }
+ }
+ else {
+ gps->points->flag |= GP_SPOINT_SELECT;
+ gps->flag |= GP_STROKE_SELECT;
- /* deselect rest? */
- if ((extend == false) && (gps->totpoints > 1)) {
- /* start from index 1, to skip the first point that we'd just selected... */
- bGPDspoint *pt = &gps->points[1];
- int i = 1;
+ /* deselect rest? */
+ if ((extend == false) && (gps->totpoints > 1)) {
+ /* start from index 1, to skip the first point that we'd just selected... */
+ bGPDspoint *pt = &gps->points[1];
+ int i = 1;
- for (; i < gps->totpoints; i++, pt++) {
- pt->flag &= ~GP_SPOINT_SELECT;
+ for (; i < gps->totpoints; i++, pt++) {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ }
}
+ changed = true;
}
}
CTX_DATA_END;
- /* updates */
- DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
+ if (changed) {
+ /* updates */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
- /* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+ /* copy on write tag is needed, or else no refresh happens */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+
+ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ }
- WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
return OPERATOR_FINISHED;
}
@@ -590,12 +827,14 @@ void GPENCIL_OT_select_first(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Select First
+/** \name Select Last
* \{ */
static int gpencil_select_last_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+
/* if not edit/sculpt mode, the event is catched but not processed */
if (GPENCIL_NONE_EDIT_MODE(gpd)) {
return OPERATOR_CANCELLED;
@@ -604,6 +843,7 @@ static int gpencil_select_last_exec(bContext *C, wmOperator *op)
const bool only_selected = RNA_boolean_get(op->ptr, "only_selected_strokes");
const bool extend = RNA_boolean_get(op->ptr, "extend");
+ bool changed = false;
CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
/* skip stroke if we're only manipulating selected strokes */
if (only_selected && !(gps->flag & GP_STROKE_SELECT)) {
@@ -613,30 +853,54 @@ static int gpencil_select_last_exec(bContext *C, wmOperator *op)
/* select last point */
BLI_assert(gps->totpoints >= 1);
- gps->points[gps->totpoints - 1].flag |= GP_SPOINT_SELECT;
- gps->flag |= GP_STROKE_SELECT;
+ if (is_curve_edit) {
+ if (gps->editcurve != NULL) {
+ bGPDcurve *gpc = gps->editcurve;
+ gpc->curve_points[gpc->tot_curve_points - 1].flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(&gpc->curve_points[gpc->tot_curve_points - 1].bezt);
+ gpc->flag |= GP_CURVE_SELECT;
+ gps->flag |= GP_STROKE_SELECT;
+ if ((extend == false) && (gps->totpoints > 1)) {
+ for (int i = 0; i < gpc->tot_curve_points - 1; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(&gpc_pt->bezt);
+ }
+ }
+ changed = true;
+ }
+ }
+ else {
+ gps->points[gps->totpoints - 1].flag |= GP_SPOINT_SELECT;
+ gps->flag |= GP_STROKE_SELECT;
- /* deselect rest? */
- if ((extend == false) && (gps->totpoints > 1)) {
- /* don't include the last point... */
- bGPDspoint *pt = gps->points;
- int i = 1;
+ /* deselect rest? */
+ if ((extend == false) && (gps->totpoints > 1)) {
+ /* don't include the last point... */
+ bGPDspoint *pt = gps->points;
+ int i = 0;
- for (; i < gps->totpoints - 1; i++, pt++) {
- pt->flag &= ~GP_SPOINT_SELECT;
+ for (; i < gps->totpoints - 1; i++, pt++) {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ }
}
+
+ changed = true;
}
}
CTX_DATA_END;
- /* updates */
- DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
+ if (changed) {
+ /* updates */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
- /* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+ /* copy on write tag is needed, or else no refresh happens */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+
+ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ }
- WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
return OPERATOR_FINISHED;
}
@@ -677,64 +941,118 @@ void GPENCIL_OT_select_last(wmOperatorType *ot)
static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op))
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
/* if not edit/sculpt mode, the event is catched but not processed */
if (GPENCIL_NONE_EDIT_MODE(gpd)) {
return OPERATOR_CANCELLED;
}
- CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
- if (gps->flag & GP_STROKE_SELECT) {
- bGPDspoint *pt;
- int i;
- bool prev_sel;
-
- /* First Pass: Go in forward order,
- * expanding selection if previous was selected (pre changes).
- * - This pass covers the "after" edges of selection islands
- */
- prev_sel = false;
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- if (pt->flag & GP_SPOINT_SELECT) {
- /* selected point - just set flag for next point */
- prev_sel = true;
+ bool changed = false;
+ if (is_curve_edit) {
+ GP_EDITABLE_STROKES_BEGIN (gp_iter, C, gpl, gps) {
+ if (gps->editcurve != NULL && gps->flag & GP_STROKE_SELECT) {
+ bGPDcurve *editcurve = gps->editcurve;
+
+ bool prev_sel = false;
+ for (int i = 0; i < editcurve->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &editcurve->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ /* selected point - just set flag for next point */
+ prev_sel = true;
+ }
+ else {
+ /* unselected point - expand selection if previous was selected... */
+ if (prev_sel) {
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(bezt);
+ changed = true;
+ }
+ prev_sel = false;
+ }
}
- else {
- /* unselected point - expand selection if previous was selected... */
- if (prev_sel) {
- pt->flag |= GP_SPOINT_SELECT;
+
+ prev_sel = false;
+ for (int i = editcurve->tot_curve_points - 1; i >= 0; i--) {
+ bGPDcurve_point *gpc_pt = &editcurve->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ prev_sel = true;
+ }
+ else {
+ /* unselected point - expand selection if previous was selected... */
+ if (prev_sel) {
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(bezt);
+ changed = true;
+ }
+ prev_sel = false;
}
- prev_sel = false;
}
}
+ }
+ GP_EDITABLE_STROKES_END(gp_iter);
+ }
+ else {
+ CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
+ if (gps->flag & GP_STROKE_SELECT) {
+ bGPDspoint *pt;
+ int i;
+ bool prev_sel;
- /* Second Pass: Go in reverse order, doing the same as before (except in opposite order)
- * - This pass covers the "before" edges of selection islands
- */
- prev_sel = false;
- for (pt -= 1; i > 0; i--, pt--) {
- if (pt->flag & GP_SPOINT_SELECT) {
- prev_sel = true;
+ /* First Pass: Go in forward order,
+ * expanding selection if previous was selected (pre changes).
+ * - This pass covers the "after" edges of selection islands
+ */
+ prev_sel = false;
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ if (pt->flag & GP_SPOINT_SELECT) {
+ /* selected point - just set flag for next point */
+ prev_sel = true;
+ }
+ else {
+ /* unselected point - expand selection if previous was selected... */
+ if (prev_sel) {
+ pt->flag |= GP_SPOINT_SELECT;
+ changed = true;
+ }
+ prev_sel = false;
+ }
}
- else {
- /* unselected point - expand selection if previous was selected... */
- if (prev_sel) {
- pt->flag |= GP_SPOINT_SELECT;
+
+ /* Second Pass: Go in reverse order, doing the same as before (except in opposite order)
+ * - This pass covers the "before" edges of selection islands
+ */
+ prev_sel = false;
+ for (pt -= 1; i > 0; i--, pt--) {
+ if (pt->flag & GP_SPOINT_SELECT) {
+ prev_sel = true;
+ }
+ else {
+ /* unselected point - expand selection if previous was selected... */
+ if (prev_sel) {
+ pt->flag |= GP_SPOINT_SELECT;
+ changed = true;
+ }
+ prev_sel = false;
}
- prev_sel = false;
}
}
}
+ CTX_DATA_END;
}
- CTX_DATA_END;
- /* updates */
- DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
+ if (changed) {
+ /* updates */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
- /* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+ /* copy on write tag is needed, or else no refresh happens */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+
+ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ }
- WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
return OPERATOR_FINISHED;
}
@@ -762,65 +1080,125 @@ void GPENCIL_OT_select_more(wmOperatorType *ot)
static int gpencil_select_less_exec(bContext *C, wmOperator *UNUSED(op))
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+
/* if not edit/sculpt mode, the event is catched but not processed */
if (GPENCIL_NONE_EDIT_MODE(gpd)) {
return OPERATOR_CANCELLED;
}
- CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
- if (gps->flag & GP_STROKE_SELECT) {
- bGPDspoint *pt;
- int i;
- bool prev_sel;
+ bool changed = false;
+ if (is_curve_edit) {
+ GP_EDITABLE_STROKES_BEGIN (gp_iter, C, gpl, gps) {
+ if (gps->editcurve != NULL && gps->flag & GP_STROKE_SELECT) {
+ bGPDcurve *editcurve = gps->editcurve;
+ int i;
- /* First Pass: Go in forward order, shrinking selection
- * if previous was not selected (pre changes).
- * - This pass covers the "after" edges of selection islands
- */
- prev_sel = false;
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- if (pt->flag & GP_SPOINT_SELECT) {
- /* shrink if previous wasn't selected */
- if (prev_sel == false) {
- pt->flag &= ~GP_SPOINT_SELECT;
+ bool prev_sel = false;
+ for (i = 0; i < editcurve->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &editcurve->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ /* shrink if previous wasn't selected */
+ if (prev_sel == false) {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ changed = true;
+ }
+ prev_sel = true;
+ }
+ else {
+ /* mark previous as being unselected - and hence, is trigger for shrinking */
+ prev_sel = false;
}
- prev_sel = true;
}
- else {
- /* mark previous as being unselected - and hence, is trigger for shrinking */
- prev_sel = false;
+
+ /* Second Pass: Go in reverse order, doing the same as before (except in opposite order)
+ * - This pass covers the "before" edges of selection islands
+ */
+ prev_sel = false;
+ for (i = editcurve->tot_curve_points - 1; i > 0; i--) {
+ bGPDcurve_point *gpc_pt = &editcurve->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ /* shrink if previous wasn't selected */
+ if (prev_sel == false) {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ changed = true;
+ }
+ prev_sel = true;
+ }
+ else {
+ /* mark previous as being unselected - and hence, is trigger for shrinking */
+ prev_sel = false;
+ }
}
}
+ }
+ GP_EDITABLE_STROKES_END(gp_iter);
+ }
+ else {
+ CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
+ if (gps->flag & GP_STROKE_SELECT) {
+ bGPDspoint *pt;
+ int i;
+ bool prev_sel;
- /* Second Pass: Go in reverse order, doing the same as before (except in opposite order)
- * - This pass covers the "before" edges of selection islands
- */
- prev_sel = false;
- for (pt -= 1; i > 0; i--, pt--) {
- if (pt->flag & GP_SPOINT_SELECT) {
- /* shrink if previous wasn't selected */
- if (prev_sel == false) {
- pt->flag &= ~GP_SPOINT_SELECT;
+ /* First Pass: Go in forward order, shrinking selection
+ * if previous was not selected (pre changes).
+ * - This pass covers the "after" edges of selection islands
+ */
+ prev_sel = false;
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ if (pt->flag & GP_SPOINT_SELECT) {
+ /* shrink if previous wasn't selected */
+ if (prev_sel == false) {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ changed = true;
+ }
+ prev_sel = true;
+ }
+ else {
+ /* mark previous as being unselected - and hence, is trigger for shrinking */
+ prev_sel = false;
}
- prev_sel = true;
}
- else {
- /* mark previous as being unselected - and hence, is trigger for shrinking */
- prev_sel = false;
+
+ /* Second Pass: Go in reverse order, doing the same as before (except in opposite order)
+ * - This pass covers the "before" edges of selection islands
+ */
+ prev_sel = false;
+ for (pt -= 1; i > 0; i--, pt--) {
+ if (pt->flag & GP_SPOINT_SELECT) {
+ /* shrink if previous wasn't selected */
+ if (prev_sel == false) {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ changed = true;
+ }
+ prev_sel = true;
+ }
+ else {
+ /* mark previous as being unselected - and hence, is trigger for shrinking */
+ prev_sel = false;
+ }
}
}
}
+ CTX_DATA_END;
}
- CTX_DATA_END;
- /* updates */
- DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
+ if (changed) {
+ /* updates */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
- /* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+ /* copy on write tag is needed, or else no refresh happens */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+
+ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ }
- WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
return OPERATOR_FINISHED;
}
@@ -852,7 +1230,7 @@ void GPENCIL_OT_select_less(wmOperatorType *ot)
* from gpencil_paint.c #gpencil_stroke_eraser_dostroke().
* It would be great to de-duplicate the logic here sometime, but that can wait.
*/
-static bool gpencil_stroke_do_circle_sel(bGPdata *UNUSED(gpd),
+static bool gpencil_stroke_do_circle_sel(bGPdata *gpd,
bGPDlayer *gpl,
bGPDstroke *gps,
GP_SpaceConversion *gsc,
@@ -863,7 +1241,8 @@ static bool gpencil_stroke_do_circle_sel(bGPdata *UNUSED(gpd),
rcti *rect,
const float diff_mat[4][4],
const int selectmode,
- const float scale)
+ const float scale,
+ const bool is_curve_edit)
{
bGPDspoint *pt = NULL;
int x0 = 0, y0 = 0;
@@ -906,7 +1285,7 @@ static bool gpencil_stroke_do_circle_sel(bGPdata *UNUSED(gpd),
float r_hita[3], r_hitb[3];
bool hit_select = (bool)(pt_active->flag & GP_SPOINT_SELECT);
ED_gpencil_select_stroke_segment(
- gpl, gps_active, pt_active, hit_select, false, scale, r_hita, r_hitb);
+ gpd, gpl, gps_active, pt_active, hit_select, false, scale, r_hita, r_hitb);
}
}
}
@@ -927,17 +1306,119 @@ static bool gpencil_stroke_do_circle_sel(bGPdata *UNUSED(gpd),
}
}
+ /* If curve edit mode, generate the curve. */
+ if (is_curve_edit && hit && gps_active->editcurve == NULL) {
+ BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps_active);
+ gps_active->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ /* Select all curve points. */
+ select_all_curve_points(gps_active, gps_active->editcurve, false);
+ BKE_gpencil_stroke_geometry_update(gpd, gps_active);
+ changed = true;
+ }
+
/* Ensure that stroke selection is in sync with its points. */
BKE_gpencil_stroke_sync_selection(gps_active);
return changed;
}
+static bool gpencil_do_curve_circle_sel(bContext *C,
+ bGPDstroke *gps,
+ bGPDcurve *gpc,
+ const int mx,
+ const int my,
+ const int radius,
+ const bool select,
+ rcti *rect,
+ const float diff_mat[4][4],
+ const int selectmode)
+{
+ ARegion *region = CTX_wm_region(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ const bool only_selected = (v3d->overlay.handle_display == CURVE_HANDLE_SELECTED);
+
+ bool hit = false;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+
+ if (bezt->hide == 1) {
+ continue;
+ }
+
+ const bool handles_visible = (v3d->overlay.handle_display != CURVE_HANDLE_NONE) &&
+ (!only_selected || BEZT_ISSEL_ANY(bezt));
+
+ /* if the handles are not visible only check ctrl point (vec[1])*/
+ int from = (!handles_visible) ? 1 : 0;
+ int to = (!handles_visible) ? 2 : 3;
+
+ for (int j = from; j < to; j++) {
+ float parent_co[3];
+ mul_v3_m4v3(parent_co, diff_mat, bezt->vec[j]);
+ int screen_co[2];
+ /* do 2d projection */
+ if (ED_view3d_project_int_global(
+ region, parent_co, screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) !=
+ V3D_PROJ_RET_OK) {
+ continue;
+ }
+
+ /* view and bounding box test */
+ if (ELEM(V2D_IS_CLIPPED, screen_co[0], screen_co[1]) &&
+ !BLI_rcti_isect_pt(rect, screen_co[0], screen_co[1])) {
+ continue;
+ }
+
+ /* test inside circle */
+ int dist_x = screen_co[0] - mx;
+ int dist_y = screen_co[1] - my;
+ int dist = dist_x * dist_x + dist_y * dist_y;
+ if (dist <= radius * radius) {
+ hit = true;
+ /* change selection */
+ if (select) {
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_IDX(bezt, j);
+ }
+ else {
+ BEZT_DESEL_IDX(bezt, j);
+ if (!BEZT_ISSEL_ANY(bezt)) {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ }
+ }
+ }
+ }
+ }
+
+ /* select the entire curve */
+ if (hit && (selectmode == GP_SELECTMODE_STROKE)) {
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+
+ if (select) {
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(bezt);
+ }
+ else {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ }
+ }
+ }
+
+ BKE_gpencil_curve_sync_selection(gps);
+
+ return hit;
+}
+
static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
ToolSettings *ts = CTX_data_tool_settings(C);
Object *ob = CTX_data_active_object(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
int selectmode;
if (ob && ob->mode == OB_MODE_SCULPT_GPENCIL) {
@@ -963,12 +1444,6 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
const int my = RNA_int_get(op->ptr, "y");
const int radius = RNA_int_get(op->ptr, "radius");
- GP_SpaceConversion gsc = {NULL};
- /* for bounding rect around circle (for quicky intersection testing) */
- rcti rect = {0};
-
- bool changed = false;
-
/* sanity checks */
if (area == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
@@ -978,36 +1453,57 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
WM_gesture_is_modal_first(op->customdata));
const bool select = (sel_op != SEL_OP_SUB);
- if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- ED_gpencil_select_toggle_all(C, SEL_DESELECT);
- changed = true;
- }
- /* init space conversion stuff */
- gpencil_point_conversion_init(C, &gsc);
-
- /* rect is rectangle of selection circle */
+ bool changed = false;
+ /* for bounding rect around circle (for quicky intersection testing) */
+ rcti rect = {0};
rect.xmin = mx - radius;
rect.ymin = my - radius;
rect.xmax = mx + radius;
rect.ymax = my + radius;
- /* find visible strokes, and select if hit */
- GP_EVALUATED_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
- changed |= gpencil_stroke_do_circle_sel(gpd,
- gpl,
- gps,
- &gsc,
- mx,
- my,
- radius,
- select,
- &rect,
- gpstroke_iter.diff_mat,
- selectmode,
- scale);
+ if (is_curve_edit) {
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ ED_gpencil_select_curve_toggle_all(C, SEL_DESELECT);
+ changed = true;
+ }
+
+ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
+ {
+ changed |= gpencil_do_curve_circle_sel(
+ C, gps, gpc, mx, my, radius, select, &rect, gps_iter.diff_mat, selectmode);
+ }
+ GP_EDITABLE_CURVES_END(gps_iter);
+ }
+
+ if (changed == false) {
+ GP_SpaceConversion gsc = {NULL};
+ /* init space conversion stuff */
+ gpencil_point_conversion_init(C, &gsc);
+
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ ED_gpencil_select_toggle_all(C, SEL_DESELECT);
+ changed = true;
+ }
+
+ /* find visible strokes, and select if hit */
+ GP_EVALUATED_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
+ changed |= gpencil_stroke_do_circle_sel(gpd,
+ gpl,
+ gps,
+ &gsc,
+ mx,
+ my,
+ radius,
+ select,
+ &rect,
+ gpstroke_iter.diff_mat,
+ selectmode,
+ scale,
+ is_curve_edit);
+ }
+ GP_EVALUATED_STROKES_END(gpstroke_iter);
}
- GP_EVALUATED_STROKES_END(gpstroke_iter);
/* updates */
if (changed) {
@@ -1054,49 +1550,245 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot)
*
* \{ */
-typedef bool (*GPencilTestFn)(bGPDstroke *gps,
- bGPDspoint *pt,
- const GP_SpaceConversion *gsc,
- const float diff_mat[4][4],
- void *user_data);
+typedef struct GP_SelectUserData {
+ int mx, my, radius;
+ /* Bounding box rect */
+ rcti rect;
+ const int (*lasso_coords)[2];
+ int lasso_coords_len;
+} GP_SelectUserData;
-static int gpencil_generic_select_exec(
- bContext *C, wmOperator *op, GPencilTestFn is_inside_fn, rcti box, void *user_data)
+typedef bool (*GPencilTestFn)(ARegion *region,
+ const float diff_mat[4][4],
+ const float pt[3],
+ GP_SelectUserData *user_data);
+
+#if 0
+static bool gpencil_stroke_fill_isect_rect(ARegion *region,
+ bGPDstroke *gps,
+ const float diff_mat[4][4],
+ rcti rect)
{
- Object *ob = CTX_data_active_object(C);
- bGPdata *gpd = ED_gpencil_data_get_active(C);
- ToolSettings *ts = CTX_data_tool_settings(C);
- ScrArea *area = CTX_wm_area(C);
+ int min[2] = {-INT_MAX, -INT_MAX};
+ int max[2] = {INT_MAX, INT_MAX};
- int selectmode;
- if (ob && ob->mode == OB_MODE_SCULPT_GPENCIL) {
- selectmode = gpencil_select_mode_from_sculpt(ts->gpencil_selectmode_sculpt);
- }
- else if (ob && ob->mode == OB_MODE_VERTEX_GPENCIL) {
- selectmode = gpencil_select_mode_from_vertex(ts->gpencil_selectmode_vertex);
- }
- else {
- selectmode = ts->gpencil_selectmode_edit;
+ int(*points2d)[2] = MEM_callocN(sizeof(int[2]) * gps->totpoints, __func__);
+
+ for (int i = 0; i < gps->totpoints; i++) {
+ bGPDspoint *pt = &gps->points[i];
+ int *pt2d = points2d[i];
+
+ int screen_co[2];
+ gpencil_3d_point_to_screen_space(region, diff_mat, &pt->x, screen_co);
+ DO_MINMAX2(screen_co, min, max);
+
+ copy_v2_v2_int(pt2d, screen_co);
}
- const bool strokemode = ((selectmode == GP_SELECTMODE_STROKE) &&
- ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0));
- const bool segmentmode = ((selectmode == GP_SELECTMODE_SEGMENT) &&
- ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0));
+ bool hit = false;
+ /* check bounding box */
+ rcti bb = {min[0], max[0], min[1], max[1]};
+ if (BLI_rcti_isect(&rect, &bb, NULL)) {
+ for (int i = 0; i < gps->tot_triangles; i++) {
+ bGPDtriangle *tri = &gps->triangles[i];
+ int pt1[2], pt2[2], pt3[2];
+ int tri_min[2] = {-INT_MAX, -INT_MAX};
+ int tri_max[2] = {INT_MAX, INT_MAX};
+
+ copy_v2_v2_int(pt1, points2d[tri->verts[0]]);
+ copy_v2_v2_int(pt2, points2d[tri->verts[1]]);
+ copy_v2_v2_int(pt3, points2d[tri->verts[2]]);
+
+ DO_MINMAX2(pt1, tri_min, tri_max);
+ DO_MINMAX2(pt2, tri_min, tri_max);
+ DO_MINMAX2(pt3, tri_min, tri_max);
+
+ rcti tri_bb = {tri_min[0], tri_max[0], tri_min[1], tri_max[1]};
+ /* Case 1: triangle is entirely inside box selection */
+ /* (XXX: Can this even happen with no point inside the box?) */
+ if (BLI_rcti_inside_rcti(&tri_bb, &rect)) {
+ hit = true;
+ break;
+ }
- const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
- const float scale = ts->gp_sculpt.isect_threshold;
+ /* Case 2: rectangle intersects sides of triangle */
+ if (BLI_rcti_isect_segment(&rect, pt1, pt2) || BLI_rcti_isect_segment(&rect, pt2, pt3) ||
+ BLI_rcti_isect_segment(&rect, pt3, pt1)) {
+ hit = true;
+ break;
+ }
- GP_SpaceConversion gsc = {NULL};
+ /* TODO: Case 3: rectangle is inside the triangle */
+ }
+ }
+
+ MEM_freeN(points2d);
+ return hit;
+}
+#endif
+
+static bool gpencil_generic_curve_select(bContext *C,
+ Object *UNUSED(ob),
+ GPencilTestFn is_inside_fn,
+ rcti UNUSED(box),
+ GP_SelectUserData *user_data,
+ const bool strokemode,
+ const eSelectOp sel_op)
+{
+ ARegion *region = CTX_wm_region(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ const bool handle_only_selected = (v3d->overlay.handle_display == CURVE_HANDLE_SELECTED);
+ const bool handle_all = (v3d->overlay.handle_display == CURVE_HANDLE_ALL);
+ bool hit = false;
bool changed = false;
+ bool whole = false;
- /* sanity checks */
- if (area == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No active area");
- return OPERATOR_CANCELLED;
+ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
+ {
+ bool any_select = false;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+
+ if (bezt->hide == 1) {
+ continue;
+ }
+
+ const bool handles_visible = (handle_all || (handle_only_selected &&
+ (gpc_pt->flag & GP_CURVE_POINT_SELECT)));
+
+ if (handles_visible) {
+ for (int j = 0; j < 3; j++) {
+ const bool is_select = BEZT_ISSEL_IDX(bezt, j);
+ bool is_inside = is_inside_fn(region, gps_iter.diff_mat, bezt->vec[j], user_data);
+ if (strokemode) {
+ if (is_inside) {
+ hit = true;
+ any_select = true;
+ break;
+ }
+ }
+ else {
+ const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
+ if (sel_op_result != -1) {
+ if (sel_op_result) {
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_IDX(bezt, j);
+ any_select = true;
+ }
+ else {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_IDX(bezt, j);
+ }
+ changed = true;
+ hit = true;
+ }
+ else {
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_IDX(bezt, j);
+ }
+ }
+ }
+ }
+ }
+ /* if the handles are not visible only check ctrl point (vec[1])*/
+ else {
+ const bool is_select = bezt->f2;
+ bool is_inside = is_inside_fn(region, gps_iter.diff_mat, bezt->vec[1], user_data);
+ if (strokemode) {
+ if (is_inside) {
+ hit = true;
+ any_select = true;
+ }
+ }
+ else {
+ const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
+ if (sel_op_result != -1) {
+ if (sel_op_result) {
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ bezt->f2 |= SELECT;
+ any_select = true;
+ }
+ else {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ bezt->f2 &= ~SELECT;
+ }
+ changed = true;
+ hit = true;
+ }
+ else {
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ bezt->f2 &= ~SELECT;
+ }
+ }
+ }
+ }
+ }
+
+ /* TODO: Fix selection for filled in curves. */
+#if 0
+ if (!hit) {
+ /* check if we selected the inside of a filled curve */
+ MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
+ if ((gp_style->flag & GP_MATERIAL_FILL_SHOW) == 0) {
+ continue;
+ }
+
+ whole = gpencil_stroke_fill_isect_rect(region, gps, gps_iter.diff_mat, box);
+ }
+#endif
+ /* select the entire curve */
+ if (strokemode || whole) {
+ const int sel_op_result = ED_select_op_action_deselected(sel_op, any_select, hit || whole);
+ if (sel_op_result != -1) {
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+
+ if (sel_op_result) {
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(bezt);
+ }
+ else {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ }
+ }
+
+ if (sel_op_result) {
+ gpc->flag |= GP_CURVE_SELECT;
+ }
+ else {
+ gpc->flag &= ~GP_CURVE_SELECT;
+ }
+ changed = true;
+ }
+ }
+
+ BKE_gpencil_curve_sync_selection(gps);
}
+ GP_EDITABLE_CURVES_END(gps_iter);
+
+ return changed;
+}
+static bool gpencil_generic_stroke_select(bContext *C,
+ Object *ob,
+ bGPdata *gpd,
+ GPencilTestFn is_inside_fn,
+ rcti box,
+ GP_SelectUserData *user_data,
+ const bool strokemode,
+ const bool segmentmode,
+ const eSelectOp sel_op,
+ const float scale,
+ const bool is_curve_edit)
+{
+ GP_SpaceConversion gsc = {NULL};
+ bool changed = false;
/* init space conversion stuff */
gpencil_point_conversion_init(C, &gsc);
@@ -1130,7 +1822,7 @@ static int gpencil_generic_select_exec(
bGPDspoint *pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
/* convert point coords to screenspace */
- const bool is_inside = is_inside_fn(gps, pt, &gsc, gpstroke_iter.diff_mat, user_data);
+ const bool is_inside = is_inside_fn(gsc.region, gpstroke_iter.diff_mat, &pt->x, user_data);
if (strokemode == false) {
const bool is_select = (pt_active->flag & GP_SPOINT_SELECT) != 0;
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
@@ -1144,7 +1836,7 @@ static int gpencil_generic_select_exec(
bool hit_select = (bool)(pt_active->flag & GP_SPOINT_SELECT);
float r_hita[3], r_hitb[3];
ED_gpencil_select_stroke_segment(
- gpl, gps_active, pt_active, hit_select, false, scale, r_hita, r_hitb);
+ gpd, gpl, gps_active, pt_active, hit_select, false, scale, r_hita, r_hitb);
}
}
}
@@ -1191,11 +1883,82 @@ static int gpencil_generic_select_exec(
}
}
+ /* If curve edit mode, generate the curve. */
+ if (is_curve_edit && (hit || whole) && gps_active->editcurve == NULL) {
+ BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps_active);
+ gps_active->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ /* Select all curve points. */
+ select_all_curve_points(gps_active, gps_active->editcurve, false);
+ BKE_gpencil_stroke_geometry_update(gpd, gps_active);
+ changed = true;
+ }
+
/* Ensure that stroke selection is in sync with its points */
BKE_gpencil_stroke_sync_selection(gps_active);
}
GP_EVALUATED_STROKES_END(gpstroke_iter);
+ return changed;
+}
+
+static int gpencil_generic_select_exec(bContext *C,
+ wmOperator *op,
+ GPencilTestFn is_inside_fn,
+ rcti box,
+ GP_SelectUserData *user_data)
+{
+ Object *ob = CTX_data_active_object(C);
+ bGPdata *gpd = ED_gpencil_data_get_active(C);
+ ToolSettings *ts = CTX_data_tool_settings(C);
+ ScrArea *area = CTX_wm_area(C);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+
+ int selectmode;
+ if (ob && ob->mode == OB_MODE_SCULPT_GPENCIL) {
+ selectmode = gpencil_select_mode_from_sculpt(ts->gpencil_selectmode_sculpt);
+ }
+ else if (ob && ob->mode == OB_MODE_VERTEX_GPENCIL) {
+ selectmode = gpencil_select_mode_from_vertex(ts->gpencil_selectmode_vertex);
+ }
+ else {
+ selectmode = ts->gpencil_selectmode_edit;
+ }
+
+ const bool strokemode = ((selectmode == GP_SELECTMODE_STROKE) &&
+ ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0));
+ const bool segmentmode = ((selectmode == GP_SELECTMODE_SEGMENT) &&
+ ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0));
+
+ const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
+ const float scale = ts->gp_sculpt.isect_threshold;
+
+ bool changed = false;
+
+ /* sanity checks */
+ if (area == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "No active area");
+ return OPERATOR_CANCELLED;
+ }
+
+ if (is_curve_edit) {
+ changed = gpencil_generic_curve_select(
+ C, ob, is_inside_fn, box, user_data, strokemode, sel_op);
+ }
+
+ if (changed == false) {
+ changed = gpencil_generic_stroke_select(C,
+ ob,
+ gpd,
+ is_inside_fn,
+ box,
+ user_data,
+ strokemode,
+ segmentmode,
+ sel_op,
+ scale,
+ is_curve_edit);
+ }
+
/* if paint mode,delete selected points */
if (GPENCIL_PAINT_MODE(gpd)) {
gpencil_delete_selected_point_wrap(C);
@@ -1222,27 +1985,21 @@ static int gpencil_generic_select_exec(
/** \name Box Select Operator
* \{ */
-struct GP_SelectBoxUserData {
- rcti rect;
-};
-
-static bool gpencil_test_box(bGPDstroke *gps,
- bGPDspoint *pt,
- const GP_SpaceConversion *gsc,
+static bool gpencil_test_box(ARegion *region,
const float diff_mat[4][4],
- void *user_data)
+ const float pt[3],
+ GP_SelectUserData *user_data)
{
- const struct GP_SelectBoxUserData *data = user_data;
- bGPDspoint pt2;
- int x0, y0;
- gpencil_point_to_parent_space(pt, diff_mat, &pt2);
- gpencil_point_to_xy(gsc, gps, &pt2, &x0, &y0);
- return ((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(&data->rect, x0, y0));
+ int co[2] = {0};
+ if (gpencil_3d_point_to_screen_space(region, diff_mat, pt, co)) {
+ return BLI_rcti_isect_pt(&user_data->rect, co[0], co[1]);
+ }
+ return false;
}
static int gpencil_box_select_exec(bContext *C, wmOperator *op)
{
- struct GP_SelectBoxUserData data = {0};
+ GP_SelectUserData data = {0};
WM_operator_properties_border_to_rcti(op, &data.rect);
rcti rect = data.rect;
return gpencil_generic_select_exec(C, op, gpencil_test_box, rect, &data);
@@ -1277,45 +2034,38 @@ void GPENCIL_OT_select_box(wmOperatorType *ot)
/** \name Lasso Select Operator
* \{ */
-struct GP_SelectLassoUserData {
- rcti rect;
- const int (*mcoords)[2];
- int mcoords_len;
-};
-
-static bool gpencil_test_lasso(bGPDstroke *gps,
- bGPDspoint *pt,
- const GP_SpaceConversion *gsc,
+static bool gpencil_test_lasso(ARegion *region,
const float diff_mat[4][4],
- void *user_data)
+ const float pt[3],
+ GP_SelectUserData *user_data)
{
- const struct GP_SelectLassoUserData *data = user_data;
- bGPDspoint pt2;
- int x0, y0;
- gpencil_point_to_parent_space(pt, diff_mat, &pt2);
- gpencil_point_to_xy(gsc, gps, &pt2, &x0, &y0);
- /* test if in lasso boundbox + within the lasso noose */
- return ((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(&data->rect, x0, y0) &&
- BLI_lasso_is_point_inside(data->mcoords, data->mcoords_len, x0, y0, INT_MAX));
+ int co[2] = {0};
+ if (gpencil_3d_point_to_screen_space(region, diff_mat, pt, co)) {
+ /* test if in lasso boundbox + within the lasso noose */
+ return (BLI_rcti_isect_pt(&user_data->rect, co[0], co[1]) &&
+ BLI_lasso_is_point_inside(
+ user_data->lasso_coords, user_data->lasso_coords_len, co[0], co[1], INT_MAX));
+ }
+ return false;
}
static int gpencil_lasso_select_exec(bContext *C, wmOperator *op)
{
- struct GP_SelectLassoUserData data = {0};
- data.mcoords = WM_gesture_lasso_path_to_array(C, op, &data.mcoords_len);
+ struct GP_SelectUserData data = {0};
+ data.lasso_coords = WM_gesture_lasso_path_to_array(C, op, &data.lasso_coords_len);
/* Sanity check. */
- if (data.mcoords == NULL) {
+ if (data.lasso_coords == NULL) {
return OPERATOR_PASS_THROUGH;
}
/* Compute boundbox of lasso (for faster testing later). */
- BLI_lasso_boundbox(&data.rect, data.mcoords, data.mcoords_len);
+ BLI_lasso_boundbox(&data.rect, data.lasso_coords, data.lasso_coords_len);
rcti rect = data.rect;
int ret = gpencil_generic_select_exec(C, op, gpencil_test_lasso, rect, &data);
- MEM_freeN((void *)data.mcoords);
+ MEM_freeN((void *)data.lasso_coords);
return ret;
}
@@ -1346,25 +2096,56 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot)
/** \name Mouse Pick Select Operator
* \{ */
-/* helper to deselect all selected strokes/points */
-static void deselect_all_selected(bContext *C)
+static void gpencil_select_curve_point(bContext *C,
+ const int mval[2],
+ const int radius_squared,
+ bGPDlayer **r_gpl,
+ bGPDstroke **r_gps,
+ bGPDcurve **r_gpc,
+ bGPDcurve_point **r_pt,
+ char *handle)
{
- CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
- /* deselect stroke and its points if selected */
- if (gps->flag & GP_STROKE_SELECT) {
- bGPDspoint *pt;
- int i;
+ ARegion *region = CTX_wm_region(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ const bool only_selected = (v3d->overlay.handle_display == CURVE_HANDLE_SELECTED);
- /* deselect points */
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- pt->flag &= ~GP_SPOINT_SELECT;
+ int hit_distance = radius_squared;
+
+ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
+ {
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+
+ if (bezt->hide == 1) {
+ continue;
}
- /* deselect stroke itself too */
- gps->flag &= ~GP_STROKE_SELECT;
+ const bool handles_visible = (v3d->overlay.handle_display != CURVE_HANDLE_NONE) &&
+ (!only_selected || BEZT_ISSEL_ANY(bezt));
+
+ /* if the handles are not visible only check ctrl point (vec[1])*/
+ int from = (!handles_visible) ? 1 : 0;
+ int to = (!handles_visible) ? 2 : 3;
+
+ for (int j = from; j < to; j++) {
+ int screen_co[2];
+ if (gpencil_3d_point_to_screen_space(region, gps_iter.diff_mat, bezt->vec[j], screen_co)) {
+ const int pt_distance = len_manhattan_v2v2_int(mval, screen_co);
+
+ if (pt_distance <= radius_squared && pt_distance < hit_distance) {
+ *r_gpl = gpl;
+ *r_gps = gps;
+ *r_gpc = gpc;
+ *r_pt = gpc_pt;
+ *handle = j;
+ hit_distance = pt_distance;
+ }
+ }
+ }
}
}
- CTX_DATA_END;
+ GP_EDITABLE_CURVES_END(gps_iter);
}
static int gpencil_select_exec(bContext *C, wmOperator *op)
@@ -1374,6 +2155,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
bGPdata *gpd = ED_gpencil_data_get_active(C);
ToolSettings *ts = CTX_data_tool_settings(C);
const float scale = ts->gp_sculpt.isect_threshold;
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
/* "radius" is simply a threshold (screen space) to make it easier to test with a tolerance */
const float radius = 0.4f * U.widget_unit;
@@ -1387,12 +2169,17 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all") && !use_shift_extend;
int mval[2] = {0};
+ /* get mouse location */
+ RNA_int_get_array(op->ptr, "location", mval);
GP_SpaceConversion gsc = {NULL};
bGPDlayer *hit_layer = NULL;
bGPDstroke *hit_stroke = NULL;
bGPDspoint *hit_point = NULL;
+ bGPDcurve *hit_curve = NULL;
+ bGPDcurve_point *hit_curve_point = NULL;
+ char hit_curve_handle = 0;
int hit_distance = radius_squared;
/* sanity checks */
@@ -1414,47 +2201,57 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
whole = (bool)(ts->gpencil_selectmode_edit == GP_SELECTMODE_STROKE);
}
- /* init space conversion stuff */
- gpencil_point_conversion_init(C, &gsc);
+ if (is_curve_edit) {
+ gpencil_select_curve_point(C,
+ mval,
+ radius_squared,
+ &hit_layer,
+ &hit_stroke,
+ &hit_curve,
+ &hit_curve_point,
+ &hit_curve_handle);
+ }
- /* get mouse location */
- RNA_int_get_array(op->ptr, "location", mval);
+ if (hit_curve == NULL) {
+ /* init space conversion stuff */
+ gpencil_point_conversion_init(C, &gsc);
- /* First Pass: Find stroke point which gets hit */
- GP_EVALUATED_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
- bGPDstroke *gps_active = (gps->runtime.gps_orig) ? gps->runtime.gps_orig : gps;
- bGPDspoint *pt;
- int i;
+ /* First Pass: Find stroke point which gets hit */
+ GP_EVALUATED_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
+ bGPDstroke *gps_active = (gps->runtime.gps_orig) ? gps->runtime.gps_orig : gps;
+ bGPDspoint *pt;
+ int i;
- /* firstly, check for hit-point */
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- int xy[2];
-
- bGPDspoint pt2;
- gpencil_point_to_parent_space(pt, gpstroke_iter.diff_mat, &pt2);
- gpencil_point_to_xy(&gsc, gps, &pt2, &xy[0], &xy[1]);
-
- /* do boundbox check first */
- if (!ELEM(V2D_IS_CLIPPED, xy[0], xy[1])) {
- const int pt_distance = len_manhattan_v2v2_int(mval, xy);
-
- /* check if point is inside */
- if (pt_distance <= radius_squared) {
- /* only use this point if it is a better match than the current hit - T44685 */
- if (pt_distance < hit_distance) {
- hit_layer = gpl;
- hit_stroke = gps_active;
- hit_point = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
- hit_distance = pt_distance;
+ /* firstly, check for hit-point */
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ int xy[2];
+
+ bGPDspoint pt2;
+ gpencil_point_to_parent_space(pt, gpstroke_iter.diff_mat, &pt2);
+ gpencil_point_to_xy(&gsc, gps, &pt2, &xy[0], &xy[1]);
+
+ /* do boundbox check first */
+ if (!ELEM(V2D_IS_CLIPPED, xy[0], xy[1])) {
+ const int pt_distance = len_manhattan_v2v2_int(mval, xy);
+
+ /* check if point is inside */
+ if (pt_distance <= radius_squared) {
+ /* only use this point if it is a better match than the current hit - T44685 */
+ if (pt_distance < hit_distance) {
+ hit_layer = gpl;
+ hit_stroke = gps_active;
+ hit_point = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
+ hit_distance = pt_distance;
+ }
}
}
}
}
+ GP_EVALUATED_STROKES_END(gpstroke_iter);
}
- GP_EVALUATED_STROKES_END(gpstroke_iter);
/* Abort if nothing hit... */
- if (ELEM(NULL, hit_stroke, hit_point)) {
+ if (!hit_curve && !hit_curve_point && !hit_point && !hit_stroke) {
if (deselect_all) {
/* since left mouse select change, deselect all if click outside any hit */
@@ -1472,9 +2269,29 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ /* select all handles if the click was on the curve but not on a handle */
+ if (is_curve_edit && hit_point != NULL) {
+ whole = true;
+ hit_curve = hit_stroke->editcurve;
+ }
+
/* adjust selection behavior - for toggle option */
if (toggle) {
- deselect = (hit_point->flag & GP_SPOINT_SELECT) != 0;
+ if (hit_curve_point != NULL) {
+ BezTriple *bezt = &hit_curve_point->bezt;
+ if ((bezt->f1 & SELECT) && (hit_curve_handle == 0)) {
+ deselect = true;
+ }
+ if ((bezt->f2 & SELECT) && (hit_curve_handle == 1)) {
+ deselect = true;
+ }
+ if ((bezt->f3 & SELECT) && (hit_curve_handle == 2)) {
+ deselect = true;
+ }
+ }
+ else {
+ deselect = (hit_point->flag & GP_SPOINT_SELECT) != 0;
+ }
}
/* If not extending selection, deselect everything else */
@@ -1484,64 +2301,94 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* Perform selection operations... */
if (whole) {
- bGPDspoint *pt;
- int i;
+ /* Generate editcurve if it does not exist */
+ if (is_curve_edit && hit_curve == NULL) {
+ BKE_gpencil_stroke_editcurve_update(gpd, hit_layer, hit_stroke);
+ hit_stroke->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, hit_stroke);
+ hit_curve = hit_stroke->editcurve;
+ }
+ /* select all curve points */
+ if (hit_curve != NULL) {
+ select_all_curve_points(hit_stroke, hit_curve, deselect);
+ }
+ else {
+ bGPDspoint *pt;
+ int i;
+
+ /* entire stroke's points */
+ for (i = 0, pt = hit_stroke->points; i < hit_stroke->totpoints; i++, pt++) {
+ if (deselect == false) {
+ pt->flag |= GP_SPOINT_SELECT;
+ }
+ else {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ }
+ }
- /* entire stroke's points */
- for (i = 0, pt = hit_stroke->points; i < hit_stroke->totpoints; i++, pt++) {
+ /* stroke too... */
if (deselect == false) {
- pt->flag |= GP_SPOINT_SELECT;
+ hit_stroke->flag |= GP_STROKE_SELECT;
}
else {
- pt->flag &= ~GP_SPOINT_SELECT;
+ hit_stroke->flag &= ~GP_STROKE_SELECT;
}
}
-
- /* stroke too... */
- if (deselect == false) {
- hit_stroke->flag |= GP_STROKE_SELECT;
- }
- else {
- hit_stroke->flag &= ~GP_STROKE_SELECT;
- }
}
else {
/* just the point (and the stroke) */
if (deselect == false) {
- /* we're adding selection, so selection must be true */
- hit_point->flag |= GP_SPOINT_SELECT;
- hit_stroke->flag |= GP_STROKE_SELECT;
-
- /* expand selection to segment */
- int selectmode;
- if (ob && ob->mode == OB_MODE_SCULPT_GPENCIL) {
- selectmode = gpencil_select_mode_from_sculpt(ts->gpencil_selectmode_sculpt);
- }
- else if (ob && ob->mode == OB_MODE_VERTEX_GPENCIL) {
- selectmode = gpencil_select_mode_from_vertex(ts->gpencil_selectmode_vertex);
+ if (hit_curve_point != NULL) {
+ hit_curve_point->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_IDX(&hit_curve_point->bezt, hit_curve_handle);
+ hit_curve->flag |= GP_CURVE_SELECT;
+ hit_stroke->flag |= GP_STROKE_SELECT;
}
else {
- selectmode = ts->gpencil_selectmode_edit;
- }
+ /* we're adding selection, so selection must be true */
+ hit_point->flag |= GP_SPOINT_SELECT;
+ hit_stroke->flag |= GP_STROKE_SELECT;
+
+ /* expand selection to segment */
+ int selectmode;
+ if (ob && ob->mode == OB_MODE_SCULPT_GPENCIL) {
+ selectmode = gpencil_select_mode_from_sculpt(ts->gpencil_selectmode_sculpt);
+ }
+ else if (ob && ob->mode == OB_MODE_VERTEX_GPENCIL) {
+ selectmode = gpencil_select_mode_from_vertex(ts->gpencil_selectmode_vertex);
+ }
+ else {
+ selectmode = ts->gpencil_selectmode_edit;
+ }
- if (selectmode == GP_SELECTMODE_SEGMENT) {
- float r_hita[3], r_hitb[3];
- bool hit_select = (bool)(hit_point->flag & GP_SPOINT_SELECT);
- ED_gpencil_select_stroke_segment(
- hit_layer, hit_stroke, hit_point, hit_select, false, scale, r_hita, r_hitb);
+ if (selectmode == GP_SELECTMODE_SEGMENT) {
+ float r_hita[3], r_hitb[3];
+ bool hit_select = (bool)(hit_point->flag & GP_SPOINT_SELECT);
+ ED_gpencil_select_stroke_segment(
+ gpd, hit_layer, hit_stroke, hit_point, hit_select, false, scale, r_hita, r_hitb);
+ }
}
}
else {
- /* deselect point */
- hit_point->flag &= ~GP_SPOINT_SELECT;
+ if (hit_curve_point != NULL) {
+ BEZT_DESEL_IDX(&hit_curve_point->bezt, hit_curve_handle);
+ if (!BEZT_ISSEL_ANY(&hit_curve_point->bezt)) {
+ hit_curve_point->flag &= ~GP_CURVE_POINT_SELECT;
+ }
+ BKE_gpencil_curve_sync_selection(hit_stroke);
+ }
+ else {
+ /* deselect point */
+ hit_point->flag &= ~GP_SPOINT_SELECT;
- /* ensure that stroke is selected correctly */
- BKE_gpencil_stroke_sync_selection(hit_stroke);
+ /* ensure that stroke is selected correctly */
+ BKE_gpencil_stroke_sync_selection(hit_stroke);
+ }
}
}
/* updates */
- if (hit_point != NULL) {
+ if (hit_curve_point != NULL || hit_point != NULL) {
DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
@@ -1679,13 +2526,13 @@ static int gpencil_select_vertex_color_exec(bContext *C, wmOperator *op)
{
ToolSettings *ts = CTX_data_tool_settings(C);
Object *ob = CTX_data_active_object(C);
+ bGPdata *gpd = ED_gpencil_data_get_active(C);
const float threshold = RNA_int_get(op->ptr, "threshold");
const int selectmode = gpencil_select_mode_from_vertex(ts->gpencil_selectmode_vertex);
- bGPdata *gpd = (bGPdata *)ob->data;
const float range = pow(10, 5 - threshold);
- bool done = false;
+ bool changed = false;
/* Create a hash table with all selected colors. */
GHash *hue_table = BLI_ghash_int_new(__func__);
@@ -1722,7 +2569,6 @@ static int gpencil_select_vertex_color_exec(bContext *C, wmOperator *op)
if (gps_selected) {
gps->flag |= GP_STROKE_SELECT;
- done = true;
/* Extend stroke selection. */
if (selectmode == GP_SELECTMODE_STROKE) {
@@ -1736,7 +2582,7 @@ static int gpencil_select_vertex_color_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- if (done) {
+ if (changed) {
/* updates */
DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
diff --git a/source/blender/editors/gpencil/gpencil_trace.h b/source/blender/editors/gpencil/gpencil_trace.h
index 3adde7651cd..85eb4e0609f 100644
--- a/source/blender/editors/gpencil/gpencil_trace.h
+++ b/source/blender/editors/gpencil/gpencil_trace.h
@@ -56,6 +56,10 @@ struct bGPDframe;
#define BM_INV(bm, x, y) (bm_safe(bm, x, y) ? BM_UINV(bm, x, y) : 0)
#define BM_PUT(bm, x, y, b) (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0)
+/* Trace modes */
+#define GPENCIL_TRACE_MODE_SINGLE 0
+#define GPENCIL_TRACE_MODE_SEQUENCE 1
+
void ED_gpencil_trace_bitmap_print(FILE *f, const potrace_bitmap_t *bm);
potrace_bitmap_t *ED_gpencil_trace_bitmap_new(int32_t w, int32_t h);
diff --git a/source/blender/editors/gpencil/gpencil_trace_ops.c b/source/blender/editors/gpencil/gpencil_trace_ops.c
index 4391abee5a1..0be9d74278e 100644
--- a/source/blender/editors/gpencil/gpencil_trace_ops.c
+++ b/source/blender/editors/gpencil/gpencil_trace_ops.c
@@ -35,8 +35,11 @@
#include "BKE_context.h"
#include "BKE_duplilist.h"
+#include "BKE_global.h"
#include "BKE_gpencil.h"
#include "BKE_image.h"
+#include "BKE_layer.h"
+#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_object.h"
@@ -45,11 +48,15 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
+#include "UI_interface.h"
+#include "UI_resources.h"
+
#include "WM_api.h"
#include "WM_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
+#include "RNA_enum_types.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -61,34 +68,50 @@
#include "gpencil_trace.h"
#include "potracelib.h"
+typedef struct TraceJob {
+ /* from wmJob */
+ struct Object *owner;
+ short *stop, *do_update;
+ float *progress;
+
+ bContext *C;
+ wmWindowManager *wm;
+ Main *bmain;
+ Scene *scene;
+ View3D *v3d;
+ Base *base_active;
+ Object *ob_active;
+ Image *image;
+ Object *ob_gpencil;
+ bGPdata *gpd;
+ bGPDlayer *gpl;
+
+ bool was_ob_created;
+
+ int32_t frame_target;
+ float threshold;
+ float scale;
+ float sample;
+ int32_t resolution;
+ int32_t thickness;
+ int32_t turnpolicy;
+ int32_t mode;
+
+ bool success;
+ bool was_canceled;
+} TraceJob;
+
/**
* Trace a image.
- * \param C: Context
- * \param op: Operator
- * \param ob: Grease pencil object, can be NULL
- * \param ima: Image
- * \param gpf: Destination frame
+ * \param ibuf: Image buffer.
+ * \param gpf: Destination frame.
*/
-static bool gpencil_trace_image(
- bContext *C, wmOperator *op, Object *ob, Image *ima, bGPDframe *gpf)
+static bool gpencil_trace_image(TraceJob *trace_job, ImBuf *ibuf, bGPDframe *gpf)
{
- Main *bmain = CTX_data_main(C);
-
potrace_bitmap_t *bm = NULL;
potrace_param_t *param = NULL;
potrace_state_t *st = NULL;
- const float threshold = RNA_float_get(op->ptr, "threshold");
- const float scale = RNA_float_get(op->ptr, "scale");
- const float sample = RNA_float_get(op->ptr, "sample");
- const int32_t resolution = RNA_int_get(op->ptr, "resolution");
- const int32_t thickness = RNA_int_get(op->ptr, "thickness");
- const int32_t turnpolicy = RNA_enum_get(op->ptr, "turnpolicy");
-
- ImBuf *ibuf;
- void *lock;
- ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
-
/* Create an empty BW bitmap. */
bm = ED_gpencil_trace_bitmap_new(ibuf->x, ibuf->y);
if (!bm) {
@@ -101,10 +124,10 @@ static bool gpencil_trace_image(
return false;
}
param->turdsize = 0;
- param->turnpolicy = turnpolicy;
+ param->turnpolicy = trace_job->turnpolicy;
/* Load BW bitmap with image. */
- ED_gpencil_trace_image_to_bitmap(ibuf, bm, threshold);
+ ED_gpencil_trace_image_to_bitmap(ibuf, bm, trace_job->threshold);
/* Trace the bitmap. */
st = potrace_trace(param, bm);
@@ -128,23 +151,26 @@ static bool gpencil_trace_image(
* Really, there isn't documented in Potrace about how the scale is calculated,
* but after doing a lot of tests, it looks is using a VGA resolution (640) as a base.
* Maybe there are others ways to get the right scale conversion, but this solution works. */
- float scale_potrace = scale * (640.0f / (float)ibuf->x) * ((float)ibuf->x / (float)ibuf->y);
+ float scale_potrace = trace_job->scale * (640.0f / (float)ibuf->x) *
+ ((float)ibuf->x / (float)ibuf->y);
if (ibuf->x > ibuf->y) {
scale_potrace *= (float)ibuf->y / (float)ibuf->x;
}
- ED_gpencil_trace_data_to_strokes(
- bmain, st, ob, gpf, offset, scale_potrace, sample, resolution, thickness);
+ ED_gpencil_trace_data_to_strokes(trace_job->bmain,
+ st,
+ trace_job->ob_gpencil,
+ gpf,
+ offset,
+ scale_potrace,
+ trace_job->sample,
+ trace_job->resolution,
+ trace_job->thickness);
/* Free memory. */
potrace_state_free(st);
potrace_param_free(param);
- /* Release ibuf. */
- if (ibuf) {
- BKE_image_release_ibuf(ima, ibuf, lock);
- }
-
return true;
}
@@ -157,77 +183,210 @@ static bool gpencil_trace_image_poll(bContext *C)
return false;
}
+ Image *image = (Image *)ob->data;
+ if (!ELEM(image->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
+ CTX_wm_operator_poll_msg_set(C, "No valid image format selected");
+ return false;
+ }
+
return true;
}
-static int gpencil_trace_image_exec(bContext *C, wmOperator *op)
+static void trace_initialize_job_data(TraceJob *trace_job)
{
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- Base *base_active = CTX_data_active_base(C);
- Object *ob_active = base_active->object;
- Image *image = (Image *)ob_active->data;
- bool ob_created = false;
-
- const int32_t frame_target = CFRA;
- Object *ob_gpencil = (Object *)RNA_pointer_get(op->ptr, "target").data;
-
/* Create a new grease pencil object. */
- if (ob_gpencil == NULL) {
- ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
- ob_gpencil = ED_gpencil_add_object(C, ob_active->loc, local_view_bits);
+ if (trace_job->ob_gpencil == NULL) {
+ ushort local_view_bits = (trace_job->v3d && trace_job->v3d->localvd) ?
+ trace_job->v3d->local_view_uuid :
+ 0;
+ trace_job->ob_gpencil = ED_gpencil_add_object(
+ trace_job->C, trace_job->ob_active->loc, local_view_bits);
/* Apply image rotation. */
- copy_v3_v3(ob_gpencil->rot, ob_active->rot);
+ copy_v3_v3(trace_job->ob_gpencil->rot, trace_job->ob_active->rot);
/* Grease pencil is rotated 90 degrees in X axis by default. */
- ob_gpencil->rot[0] -= DEG2RADF(90.0f);
- ob_created = true;
+ trace_job->ob_gpencil->rot[0] -= DEG2RADF(90.0f);
+ trace_job->was_ob_created = true;
/* Apply image Scale. */
- copy_v3_v3(ob_gpencil->scale, ob_active->scale);
+ copy_v3_v3(trace_job->ob_gpencil->scale, trace_job->ob_active->scale);
+ /* The default display size of the image is 5.0 and this is used as scale = 1.0. */
+ mul_v3_fl(trace_job->ob_gpencil->scale, trace_job->ob_active->empty_drawsize / 5.0f);
}
- if ((ob_gpencil == NULL) || (ob_gpencil->type != OB_GPENCIL)) {
- BKE_report(op->reports, RPT_ERROR, "Target grease pencil object not valid");
- return OPERATOR_CANCELLED;
+ /* Create Layer. */
+ trace_job->gpd = (bGPdata *)trace_job->ob_gpencil->data;
+ trace_job->gpl = BKE_gpencil_layer_active_get(trace_job->gpd);
+ if (trace_job->gpl == NULL) {
+ trace_job->gpl = BKE_gpencil_layer_addnew(trace_job->gpd, DATA_("Trace"), true);
}
+}
- /* Create Layer. */
- bGPdata *gpd = (bGPdata *)ob_gpencil->data;
- bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
- if (gpl == NULL) {
- gpl = BKE_gpencil_layer_addnew(gpd, DATA_("Trace"), true);
+static void trace_start_job(void *customdata, short *stop, short *do_update, float *progress)
+{
+ TraceJob *trace_job = customdata;
+
+ trace_job->stop = stop;
+ trace_job->do_update = do_update;
+ trace_job->progress = progress;
+ trace_job->was_canceled = false;
+
+ G.is_break = false;
+
+ /* Single Image. */
+
+ if ((trace_job->image->source == IMA_SRC_FILE) ||
+ (trace_job->mode == GPENCIL_TRACE_MODE_SINGLE)) {
+ void *lock;
+ ImBuf *ibuf = BKE_image_acquire_ibuf(trace_job->image, NULL, &lock);
+ if (ibuf) {
+ /* Create frame. */
+ bGPDframe *gpf = BKE_gpencil_layer_frame_get(
+ trace_job->gpl, trace_job->frame_target, GP_GETFRAME_ADD_NEW);
+ gpencil_trace_image(trace_job, ibuf, gpf);
+ BKE_image_release_ibuf(trace_job->image, ibuf, lock);
+ *(trace_job->progress) = 1.0f;
+ }
+ }
+ /* Image sequence. */
+ else if (trace_job->image->type == IMA_TYPE_IMAGE) {
+ ImageUser *iuser = trace_job->ob_active->iuser;
+ for (int i = 0; i < iuser->frames; i++) {
+ if (G.is_break) {
+ trace_job->was_canceled = true;
+ break;
+ }
+
+ *(trace_job->progress) = (float)i / (float)iuser->frames;
+ *do_update = true;
+
+ iuser->framenr = i + 1;
+
+ void *lock;
+ ImBuf *ibuf = BKE_image_acquire_ibuf(trace_job->image, iuser, &lock);
+ if (ibuf) {
+ /* Create frame. */
+ bGPDframe *gpf = BKE_gpencil_layer_frame_get(
+ trace_job->gpl, trace_job->frame_target + i, GP_GETFRAME_ADD_NEW);
+ gpencil_trace_image(trace_job, ibuf, gpf);
+
+ BKE_image_release_ibuf(trace_job->image, ibuf, lock);
+ }
+ }
}
- /* Create frame. */
- bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, frame_target, GP_GETFRAME_ADD_NEW);
- gpencil_trace_image(C, op, ob_gpencil, image, gpf);
+ trace_job->success = !trace_job->was_canceled;
+ *do_update = true;
+ *stop = 0;
+}
- /* Back to active base. */
- ED_object_base_activate(C, base_active);
+static void trace_end_job(void *customdata)
+{
+ TraceJob *trace_job = customdata;
+
+ /* If canceled, delete all previously created object and data-block. */
+ if ((trace_job->was_canceled) && (trace_job->was_ob_created) && (trace_job->ob_gpencil)) {
+ bGPdata *gpd = trace_job->ob_gpencil->data;
+ BKE_id_delete(trace_job->bmain, &trace_job->ob_gpencil->id);
+ BKE_id_delete(trace_job->bmain, &gpd->id);
+ }
- /* notifiers */
- if (ob_created) {
- DEG_relations_tag_update(bmain);
+ if (trace_job->success) {
+ DEG_relations_tag_update(trace_job->bmain);
+
+ DEG_id_tag_update(&trace_job->scene->id, ID_RECALC_SELECT);
+ DEG_id_tag_update(&trace_job->gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
+
+ WM_main_add_notifier(NC_OBJECT | NA_ADDED, NULL);
+ WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, trace_job->scene);
+ }
+}
+
+static void trace_free_job(void *customdata)
+{
+ TraceJob *tj = customdata;
+ MEM_freeN(tj);
+}
+
+static int gpencil_trace_image_exec(bContext *C, wmOperator *op)
+{
+ TraceJob *job = MEM_mallocN(sizeof(TraceJob), "TraceJob");
+ job->C = C;
+ job->owner = CTX_data_active_object(C);
+ job->wm = CTX_wm_manager(C);
+ job->bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ job->scene = scene;
+ job->v3d = CTX_wm_view3d(C);
+ job->base_active = CTX_data_active_base(C);
+ job->ob_active = job->base_active->object;
+ job->image = (Image *)job->ob_active->data;
+ job->frame_target = CFRA;
+
+ /* Create a new grease pencil object or reuse selected. */
+ eGP_TargetObjectMode target = RNA_enum_get(op->ptr, "target");
+ job->ob_gpencil = (target == GP_TARGET_OB_SELECTED) ? BKE_view_layer_non_active_selected_object(
+ CTX_data_view_layer(C), job->v3d) :
+ NULL;
+
+ if (job->ob_gpencil != NULL) {
+ if (job->ob_gpencil->type != OB_GPENCIL) {
+ BKE_report(op->reports, RPT_WARNING, "Target object not a grease pencil, ignoring!");
+ job->ob_gpencil = NULL;
+ }
+ else if (BKE_object_obdata_is_libdata(job->ob_gpencil)) {
+ BKE_report(op->reports, RPT_WARNING, "Target object library-data, ignoring!");
+ job->ob_gpencil = NULL;
+ }
}
- DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
- DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
+ job->was_ob_created = false;
- WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, NULL);
- WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
+ job->threshold = RNA_float_get(op->ptr, "threshold");
+ job->scale = RNA_float_get(op->ptr, "scale");
+ job->sample = RNA_float_get(op->ptr, "sample");
+ job->resolution = RNA_int_get(op->ptr, "resolution");
+ job->thickness = RNA_int_get(op->ptr, "thickness");
+ job->turnpolicy = RNA_enum_get(op->ptr, "turnpolicy");
+ job->mode = RNA_enum_get(op->ptr, "mode");
+
+ trace_initialize_job_data(job);
+
+ /* Back to active base. */
+ ED_object_base_activate(job->C, job->base_active);
+
+ if (job->image->source == IMA_SRC_FILE) {
+ short stop = 0, do_update = true;
+ float progress;
+ trace_start_job(job, &stop, &do_update, &progress);
+ trace_end_job(job);
+ trace_free_job(job);
+ }
+ else {
+ wmJob *wm_job = WM_jobs_get(job->wm,
+ CTX_wm_window(C),
+ job->scene,
+ "Trace Image",
+ WM_JOB_PROGRESS,
+ WM_JOB_TYPE_TRACE_IMAGE);
+
+ WM_jobs_customdata_set(wm_job, job, trace_free_job);
+ WM_jobs_timer(wm_job, 0.1, NC_GEOM | ND_DATA, NC_GEOM | ND_DATA);
+ WM_jobs_callbacks(wm_job, trace_start_job, NULL, NULL, trace_end_job);
+
+ WM_jobs_start(CTX_wm_manager(C), wm_job);
+ }
return OPERATOR_FINISHED;
}
-static bool rna_GPencil_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
+static int gpencil_trace_image_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- return ((Object *)value.owner_id)->type == OB_GPENCIL;
+ /* Show popup dialog to allow editing. */
+ /* FIXME: hard-coded dimensions here are just arbitrary. */
+ return WM_operator_props_dialog_popup(C, op, 250);
}
void GPENCIL_OT_trace_image(wmOperatorType *ot)
{
- PropertyRNA *prop;
-
static const EnumPropertyItem turnpolicy_type[] = {
{POTRACE_TURNPOLICY_BLACK,
"BLACK",
@@ -257,12 +416,25 @@ void GPENCIL_OT_trace_image(wmOperatorType *ot)
{0, NULL, 0, NULL, NULL},
};
+ static const EnumPropertyItem trace_modes[] = {
+ {GPENCIL_TRACE_MODE_SINGLE, "SINGLE", 0, "Single", "Trace the current frame of the image"},
+ {GPENCIL_TRACE_MODE_SEQUENCE, "SEQUENCE", 0, "Sequence", "Trace full sequence"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ static const EnumPropertyItem target_object_modes[] = {
+ {GP_TARGET_OB_NEW, "NEW", 0, "New Object", ""},
+ {GP_TARGET_OB_SELECTED, "SELECTED", 0, "Selected Object", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
/* identifiers */
ot->name = "Trace Image to Grease Pencil";
ot->idname = "GPENCIL_OT_trace_image";
ot->description = "Extract Grease Pencil strokes from image";
/* callbacks */
+ ot->invoke = gpencil_trace_image_invoke;
ot->exec = gpencil_trace_image_exec;
ot->poll = gpencil_trace_image_poll;
@@ -270,8 +442,13 @@ void GPENCIL_OT_trace_image(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- prop = RNA_def_pointer_runtime(ot->srna, "target", &RNA_Object, "Target", "");
- RNA_def_property_poll_runtime(prop, rna_GPencil_object_poll);
+ ot->prop = RNA_def_enum(ot->srna,
+ "target",
+ target_object_modes,
+ GP_TARGET_OB_NEW,
+ "Target Object",
+ "Target grease pencil");
+ RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
RNA_def_int(ot->srna, "thickness", 10, 1, 1000, "Thickness", "", 1, 1000);
RNA_def_int(
@@ -301,7 +478,7 @@ void GPENCIL_OT_trace_image(wmOperatorType *ot)
0.0f,
1.0f,
"Color Threshold",
- "Determine what is considered white and what black",
+ "Determine the lightness threshold above which strokes are generated",
0.0f,
1.0f);
RNA_def_enum(ot->srna,
@@ -310,4 +487,10 @@ void GPENCIL_OT_trace_image(wmOperatorType *ot)
POTRACE_TURNPOLICY_MINORITY,
"Turn Policy",
"Determines how to resolve ambiguities during decomposition of bitmaps into paths");
+ RNA_def_enum(ot->srna,
+ "mode",
+ trace_modes,
+ GPENCIL_TRACE_MODE_SINGLE,
+ "Mode",
+ "Determines if trace simple image or full sequence");
}
diff --git a/source/blender/editors/gpencil/gpencil_trace_utils.c b/source/blender/editors/gpencil/gpencil_trace_utils.c
index 544cb4fef1e..ada777d43f3 100644
--- a/source/blender/editors/gpencil/gpencil_trace_utils.c
+++ b/source/blender/editors/gpencil/gpencil_trace_utils.c
@@ -352,13 +352,14 @@ void ED_gpencil_trace_data_to_strokes(Main *bmain,
* long stroke. Here the length is checked and removed if the length is too big. */
float length = BKE_gpencil_stroke_length(gps, true);
if (length <= MAX_LENGTH) {
+ bGPdata *gpd = ob->data;
if (sample > 0.0f) {
/* Resample stroke. Don't need to call to BKE_gpencil_stroke_geometry_update() because
* the sample function already call that. */
- BKE_gpencil_stroke_sample(gps, sample, false);
+ BKE_gpencil_stroke_sample(gpd, gps, sample, false);
}
else {
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
}
else {
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 28a90a26a9d..76a584fcac1 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -55,6 +55,7 @@
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil.h"
+#include "BKE_gpencil_curve.h"
#include "BKE_gpencil_geom.h"
#include "BKE_main.h"
#include "BKE_material.h"
@@ -555,7 +556,7 @@ bool ED_gpencil_stroke_can_use_direct(const ScrArea *area, const bGPDstroke *gps
/* filter stroke types by flags + spacetype */
if (gps->flag & GP_STROKE_3DSPACE) {
/* 3D strokes - only in 3D view */
- return ((area->spacetype == SPACE_VIEW3D) || (area->spacetype == SPACE_PROPERTIES));
+ return (ELEM(area->spacetype, SPACE_VIEW3D, SPACE_PROPERTIES));
}
if (gps->flag & GP_STROKE_2DIMAGE) {
/* Special "image" strokes - only in Image Editor */
@@ -1144,7 +1145,7 @@ void ED_gpencil_stroke_reproject(Depsgraph *depsgraph,
bGPDstroke *gps_active = gps;
/* if duplicate, deselect all points. */
if (keep_original) {
- gps_active = BKE_gpencil_stroke_duplicate(gps, true);
+ gps_active = BKE_gpencil_stroke_duplicate(gps, true, true);
gps_active->flag &= ~GP_STROKE_SELECT;
for (i = 0, pt = gps_active->points; i < gps_active->totpoints; i++, pt++) {
pt->flag &= ~GP_SPOINT_SELECT;
@@ -1320,10 +1321,11 @@ void ED_gpencil_project_point_to_plane(const Scene *scene,
/**
* Subdivide a stroke once, by adding a point half way between each pair of existing points
+ * \param gpd: Datablock
* \param gps: Stroke data
* \param subdivide: Number of times to subdivide
*/
-void gpencil_subdivide_stroke(bGPDstroke *gps, const int subdivide)
+void gpencil_subdivide_stroke(bGPdata *gpd, bGPDstroke *gps, const int subdivide)
{
bGPDspoint *temp_points;
int totnewpoints, oldtotpoints;
@@ -1413,7 +1415,7 @@ void gpencil_subdivide_stroke(bGPDstroke *gps, const int subdivide)
MEM_SAFE_FREE(temp_points);
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
/* Reset parent matrix for all layers. */
@@ -1429,7 +1431,7 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
if (gpl->parent != NULL) {
/* calculate new matrix */
- if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) {
+ if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) {
invert_m4_m4(cur_mat, gpl->parent->obmat);
copy_v3_v3(gpl_loc, obact->obmat[3]);
}
@@ -2243,8 +2245,12 @@ static void gpencil_copy_points(
}
}
-static void gpencil_insert_point(
- bGPDstroke *gps, bGPDspoint *a_pt, bGPDspoint *b_pt, const float co_a[3], const float co_b[3])
+static void gpencil_insert_point(bGPdata *gpd,
+ bGPDstroke *gps,
+ bGPDspoint *a_pt,
+ bGPDspoint *b_pt,
+ const float co_a[3],
+ const float co_b[3])
{
bGPDspoint *temp_points;
int totnewpoints, oldtotpoints;
@@ -2289,7 +2295,7 @@ static void gpencil_insert_point(
gpencil_copy_points(gps, pt, pt_final, i, i2);
/* create new point duplicating point and copy location */
- if ((i == a_idx) || (i == b_idx)) {
+ if (ELEM(i, a_idx, b_idx)) {
i2++;
pt_final = &gps->points[i2];
gpencil_copy_points(gps, pt, pt_final, i, i2);
@@ -2303,8 +2309,8 @@ static void gpencil_insert_point(
i2++;
}
- /* Calculate geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ /* Calc geometry data. */
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
MEM_SAFE_FREE(temp_points);
}
@@ -2328,7 +2334,8 @@ static float gpencil_calc_factor(const float p2d_a1[2],
}
/* extend selection to stroke intersections */
-int ED_gpencil_select_stroke_segment(bGPDlayer *gpl,
+int ED_gpencil_select_stroke_segment(bGPdata *gpd,
+ bGPDlayer *gpl,
bGPDstroke *gps,
bGPDspoint *pt,
bool select,
@@ -2483,7 +2490,7 @@ int ED_gpencil_select_stroke_segment(bGPDlayer *gpl,
/* insert new point in the collision points */
if (insert) {
- gpencil_insert_point(gps, hit_pointa, hit_pointb, r_hita, r_hitb);
+ gpencil_insert_point(gpd, gps, hit_pointa, hit_pointb, r_hita, r_hitb);
}
/* free memory */
@@ -2611,6 +2618,82 @@ void ED_gpencil_select_toggle_all(bContext *C, int action)
}
}
+void ED_gpencil_select_curve_toggle_all(bContext *C, int action)
+{
+ /* if toggle, check if we need to select or deselect */
+ if (action == SEL_TOGGLE) {
+ action = SEL_SELECT;
+ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
+ {
+ if (gpc->flag & GP_CURVE_SELECT) {
+ action = SEL_DESELECT;
+ }
+ }
+ GP_EDITABLE_CURVES_END(gps_iter);
+ }
+
+ if (action == SEL_DESELECT) {
+ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc)
+ {
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ }
+ gpc->flag &= ~GP_CURVE_SELECT;
+ gps->flag &= ~GP_STROKE_SELECT;
+ }
+ GP_EDITABLE_CURVES_END(gps_iter);
+ }
+ else {
+ GP_EDITABLE_STROKES_BEGIN (gps_iter, C, gpl, gps) {
+ Object *ob = CTX_data_active_object(C);
+ bGPdata *gpd = ob->data;
+ bool selected = false;
+
+ /* Make sure stroke has an editcurve */
+ if (gps->editcurve == NULL) {
+ BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps);
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+
+ bGPDcurve *gpc = gps->editcurve;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ switch (action) {
+ case SEL_SELECT:
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(bezt);
+ break;
+ case SEL_INVERT:
+ gpc_pt->flag ^= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_INVERT(bezt);
+ break;
+ default:
+ break;
+ }
+
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ selected = true;
+ }
+ }
+
+ if (selected) {
+ gpc->flag |= GP_CURVE_SELECT;
+ gps->flag |= GP_STROKE_SELECT;
+ }
+ else {
+ gpc->flag &= ~GP_CURVE_SELECT;
+ gps->flag &= ~GP_STROKE_SELECT;
+ }
+ }
+ GP_EDITABLE_STROKES_END(gps_iter);
+ }
+}
+
/**
* Ensure the #tGPspoint buffer (while drawing stroke)
* size is enough to save all points of the stroke.
@@ -2982,8 +3065,8 @@ bool ED_gpencil_stroke_check_collision(GP_SpaceConversion *gsc,
*
* \param gps: Stroke to check.
* \param gsc: Space conversion data.
- * \param mouse: Mouse position.
- * \param diff_mat: View matrix.
+ * \param mouse: Mouse position.
+ * \param diff_mat: View matrix.
* \return True if the point is inside.
*/
bool ED_gpencil_stroke_point_is_inside(bGPDstroke *gps,
diff --git a/source/blender/editors/gpencil/gpencil_uv.c b/source/blender/editors/gpencil/gpencil_uv.c
index 8304641611e..1d1bc72aaec 100644
--- a/source/blender/editors/gpencil/gpencil_uv.c
+++ b/source/blender/editors/gpencil/gpencil_uv.c
@@ -273,7 +273,7 @@ static bool gpencil_uv_transform_calc(bContext *C, wmOperator *op)
changed = true;
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
i++;
}
}
@@ -291,7 +291,7 @@ static bool gpencil_uv_transform_calc(bContext *C, wmOperator *op)
gps->uv_rotation = opdata->array_rot[i] - uv_rotation;
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
i++;
}
}
@@ -316,7 +316,7 @@ static bool gpencil_uv_transform_calc(bContext *C, wmOperator *op)
if (gps->flag & GP_STROKE_SELECT) {
gps->uv_scale = opdata->array_scale[i] + scale;
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
i++;
}
}
@@ -502,17 +502,17 @@ static int gpencil_reset_transform_fill_exec(bContext *C, wmOperator *op)
/* Loop all selected strokes and reset. */
GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
if (gps->flag & GP_STROKE_SELECT) {
- if ((mode == GP_UV_TRANSLATE) || (mode == GP_UV_ALL)) {
+ if (ELEM(mode, GP_UV_TRANSLATE, GP_UV_ALL)) {
zero_v2(gps->uv_translation);
}
- if ((mode == GP_UV_ROTATE) || (mode == GP_UV_ALL)) {
+ if (ELEM(mode, GP_UV_ROTATE, GP_UV_ALL)) {
gps->uv_rotation = 0.0f;
}
- if ((mode == GP_UV_SCALE) || (mode == GP_UV_ALL)) {
+ if (ELEM(mode, GP_UV_SCALE, GP_UV_ALL)) {
gps->uv_scale = 1.0f;
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
changed = true;
}
}
diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil/gpencil_vertex_paint.c
index c6ee30ad6e3..a4dc677f0dc 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_paint.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c
@@ -819,8 +819,9 @@ static void gpencil_save_selected_point(tGP_BrushVertexpaintData *gso,
gso->pbuffer_used++;
}
-/* Select points in this stroke and add to an array to be used later. */
-static void gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso,
+/* Select points in this stroke and add to an array to be used later.
+ * Returns true if any point was hit and got saved */
+static bool gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso,
bGPDstroke *gps,
const char tool,
const float diff_mat[4][4])
@@ -841,9 +842,11 @@ static void gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso,
int index;
bool include_last = false;
+ bool saved = false;
+
/* Check if the stroke collide with brush. */
if (!ED_gpencil_stroke_check_collision(gsc, gps, gso->mval, radius, diff_mat)) {
- return;
+ return false;
}
if (gps->totpoints == 1) {
@@ -862,6 +865,7 @@ static void gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso,
/* apply operation to this point */
if (pt_active != NULL) {
gpencil_save_selected_point(gso, gps_active, 0, pc1);
+ saved = true;
}
}
}
@@ -913,6 +917,7 @@ static void gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso,
}
hit = true;
gpencil_save_selected_point(gso, gps_active, index, pc1);
+ saved = true;
}
/* Only do the second point if this is the last segment,
@@ -931,6 +936,7 @@ static void gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso,
hit = true;
gpencil_save_selected_point(gso, gps_active, index, pc2);
include_last = false;
+ saved = true;
}
}
else {
@@ -949,8 +955,8 @@ static void gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso,
if (pt_active != NULL) {
hit = true;
gpencil_save_selected_point(gso, gps_active, index, pc1);
-
include_last = false;
+ saved = true;
}
}
}
@@ -970,10 +976,13 @@ static void gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso,
for (int repeat = 0; repeat < 50; repeat++) {
gpencil_save_selected_point(gso, gps_active, -1, NULL);
}
+ saved = true;
}
}
}
}
+
+ return saved;
}
/* Apply vertex paint brushes to strokes in the given frame. */
@@ -1008,7 +1017,13 @@ static bool gpencil_vertexpaint_brush_do_frame(bContext *C,
}
/* Check points below the brush. */
- gpencil_vertexpaint_select_stroke(gso, gps, tool, diff_mat);
+ bool hit = gpencil_vertexpaint_select_stroke(gso, gps, tool, diff_mat);
+
+ /* If stroke was hit and has an editcurve the curve needs an update. */
+ bGPDstroke *gps_active = (gps->runtime.gps_orig) ? gps->runtime.gps_orig : gps;
+ if (gps_active->editcurve != NULL && hit) {
+ gps_active->editcurve->flag |= GP_CURVE_NEEDS_STROKE_UPDATE;
+ }
}
/* For Average tool, need calculate the average resulting color from all colors
diff --git a/source/blender/editors/include/ED_buttons.h b/source/blender/editors/include/ED_buttons.h
index 5d153757900..1ff160b2ca8 100644
--- a/source/blender/editors/include/ED_buttons.h
+++ b/source/blender/editors/include/ED_buttons.h
@@ -27,6 +27,7 @@ extern "C" {
#endif
struct SpaceProperties;
+struct bContext;
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);
@@ -35,6 +36,8 @@ void ED_buttons_search_string_set(struct SpaceProperties *sbuts, const char *val
int ED_buttons_search_string_length(struct SpaceProperties *sbuts);
const char *ED_buttons_search_string_get(struct SpaceProperties *sbuts);
+void ED_buttons_set_context(const struct bContext *C, PointerRNA *ptr, const int context);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h
index f9b1d9cdc64..8015a665970 100644
--- a/source/blender/editors/include/ED_curve.h
+++ b/source/blender/editors/include/ED_curve.h
@@ -84,7 +84,7 @@ void ED_curve_editfont_load(struct Object *obedit);
void ED_curve_editfont_make(struct Object *obedit);
void ED_curve_editfont_free(struct Object *obedit);
-void ED_text_to_object(struct bContext *C, struct Text *text, const bool split_lines);
+void ED_text_to_object(struct bContext *C, const struct Text *text, const bool split_lines);
void ED_curve_beztcpy(struct EditNurb *editnurb,
struct BezTriple *dst,
diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h
index 341f97943a5..84808416074 100644
--- a/source/blender/editors/include/ED_fileselect.h
+++ b/source/blender/editors/include/ED_fileselect.h
@@ -35,6 +35,7 @@ struct SpaceFile;
struct bContext;
struct bScreen;
struct uiBlock;
+struct wmOperator;
struct wmWindow;
struct wmWindowManager;
@@ -145,6 +146,9 @@ void ED_fileselect_window_params_get(const struct wmWindow *win,
int win_size[2],
bool *is_maximized);
+struct ScrArea *ED_fileselect_handler_area_find(const struct wmWindow *win,
+ const struct wmOperator *file_operator);
+
int ED_path_extension_type(const char *path);
int ED_file_extension_icon(const char *path);
diff --git a/source/blender/editors/include/ED_gizmo_library.h b/source/blender/editors/include/ED_gizmo_library.h
index 861b563521f..434ab743d18 100644
--- a/source/blender/editors/include/ED_gizmo_library.h
+++ b/source/blender/editors/include/ED_gizmo_library.h
@@ -19,7 +19,7 @@
*
* \name Generic Gizmos.
*
- * This is exposes pre-defined gizmos for re-use.
+ * This is exposes predefined gizmos for re-use.
*/
#pragma once
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 398a1630cf6..17aa407bd76 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -79,6 +79,12 @@ typedef enum eGP_ReprojectModes {
GP_REPROJECT_KEEP,
} eGP_ReprojectModes;
+/* Target object modes. */
+typedef enum eGP_TargetObjectMode {
+ GP_TARGET_OB_NEW = 0,
+ GP_TARGET_OB_SELECTED = 1,
+} eGP_TargetObjectMode;
+
/* ------------- Grease-Pencil Runtime Data ---------------- */
/* Temporary 'Stroke Point' data (2D / screen-space)
@@ -308,7 +314,8 @@ void ED_gpencil_update_color_uv(struct Main *bmain, struct Material *mat);
* 2 - Hit in point B
* 3 - Hit in point A and B
*/
-int ED_gpencil_select_stroke_segment(struct bGPDlayer *gpl,
+int ED_gpencil_select_stroke_segment(struct bGPdata *gpd,
+ struct bGPDlayer *gpl,
struct bGPDstroke *gps,
struct bGPDspoint *pt,
bool select,
@@ -318,6 +325,7 @@ int ED_gpencil_select_stroke_segment(struct bGPDlayer *gpl,
float r_hitb[3]);
void ED_gpencil_select_toggle_all(struct bContext *C, int action);
+void ED_gpencil_select_curve_toggle_all(struct bContext *C, int action);
/* Ensure stroke sbuffer size is enough */
struct tGPspoint *ED_gpencil_sbuffer_ensure(struct tGPspoint *buffer_array,
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index 4835d2118d9..c1d3a17b9b6 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -55,11 +55,8 @@ void ED_space_image_auto_set(const struct bContext *C, struct SpaceImage *sima);
struct Mask *ED_space_image_get_mask(struct SpaceImage *sima);
void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask);
-bool ED_space_image_color_sample(struct SpaceImage *sima,
- struct ARegion *region,
- int mval[2],
- float r_col[3],
- bool *r_is_data);
+bool ED_space_image_color_sample(
+ struct SpaceImage *sima, struct ARegion *region, int mval[2], float r_col[3], bool *r_is_data);
struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **r_lock, int tile);
int ED_space_image_get_display_channel_mask(struct ImBuf *ibuf);
void ED_space_image_release_buffer(struct SpaceImage *sima, struct ImBuf *ibuf, void *lock);
diff --git a/source/blender/editors/include/ED_numinput.h b/source/blender/editors/include/ED_numinput.h
index 6c5aacafc7a..50f1ce1efe2 100644
--- a/source/blender/editors/include/ED_numinput.h
+++ b/source/blender/editors/include/ED_numinput.h
@@ -99,6 +99,7 @@ bool hasNumInput(const NumInput *n);
bool applyNumInput(NumInput *n, float *vec);
bool handleNumInput(struct bContext *C, NumInput *n, const struct wmEvent *event);
+/** Share with `TFM_MODAL_CANCEL` in `transform.h`. */
#define NUM_MODAL_INCREMENT_UP 18
#define NUM_MODAL_INCREMENT_DOWN 19
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 6fdd65fdcc9..2e9b711c99a 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -160,6 +160,7 @@ extern struct EnumPropertyItem prop_clear_parent_types[];
extern struct EnumPropertyItem prop_make_parent_types[];
#endif
+/* Set the object's parent, return true iff successful. */
bool ED_object_parent_set(struct ReportList *reports,
const struct bContext *C,
struct Scene *scene,
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index b8500ba0c37..dc1c43c0337 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -199,6 +199,7 @@ int ED_region_global_size_y(void);
void ED_area_update_region_sizes(struct wmWindowManager *wm,
struct wmWindow *win,
struct ScrArea *area);
+bool ED_area_has_shared_border(struct ScrArea *a, struct ScrArea *b);
ScrArea *ED_screen_areas_iter_first(const struct wmWindow *win, const bScreen *screen);
ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area);
diff --git a/source/blender/editors/include/ED_undo.h b/source/blender/editors/include/ED_undo.h
index 989854872f3..7b643e7c764 100644
--- a/source/blender/editors/include/ED_undo.h
+++ b/source/blender/editors/include/ED_undo.h
@@ -87,6 +87,7 @@ void ED_undosys_type_free(void);
/* memfile_undo.c */
struct MemFile *ED_undosys_stack_memfile_get_active(struct UndoStack *ustack);
+void ED_undosys_stack_memfile_id_changed_tag(struct UndoStack *ustack, struct ID *id);
#ifdef __cplusplus
}
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index d3eb6c00f57..a0246174970 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -459,6 +459,8 @@ void ED_view3d_clipping_calc(struct BoundBox *bb,
const struct ARegion *region,
const struct Object *ob,
const struct rcti *rect);
+bool ED_view3d_clipping_clamp_minmax(const struct RegionView3D *rv3d, float min[3], float max[3]);
+
void ED_view3d_clipping_local(struct RegionView3D *rv3d, const float mat[4][4]);
bool ED_view3d_clipping_test(const struct RegionView3D *rv3d,
const float co[3],
@@ -693,7 +695,7 @@ void ED_view3d_grid_steps(const struct Scene *scene,
float *r_grid_steps);
float ED_view3d_grid_view_scale(struct Scene *scene,
struct View3D *v3d,
- struct RegionView3D *rv3d,
+ struct ARegion *region,
const char **r_grid_unit);
void ED_scene_draw_fps(const struct Scene *scene, int xoffset, int *yoffset);
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index c987a8ac13b..f9dc23502c7 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1682,7 +1682,7 @@ void UI_panels_begin(const struct bContext *C, struct ARegion *region);
void UI_panels_end(const struct bContext *C, struct ARegion *region, int *r_x, int *r_y);
void UI_panels_draw(const struct bContext *C, struct ARegion *region);
-struct Panel *UI_panel_find_by_type(struct ListBase *lb, struct PanelType *pt);
+struct Panel *UI_panel_find_by_type(struct ListBase *lb, const struct PanelType *pt);
struct Panel *UI_panel_begin(struct ARegion *region,
struct ListBase *lb,
uiBlock *block,
@@ -1695,29 +1695,22 @@ 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);
+void UI_panel_label_offset(const struct uiBlock *block, int *r_x, int *r_y);
int UI_panel_size_y(const struct Panel *panel);
bool UI_panel_is_dragging(const struct Panel *panel);
bool UI_panel_matches_search_filter(const struct Panel *panel);
bool UI_panel_category_is_visible(const struct ARegion *region);
void UI_panel_category_add(struct ARegion *region, const char *name);
-struct PanelCategoryDyn *UI_panel_category_find(struct ARegion *region, const char *idname);
+struct PanelCategoryDyn *UI_panel_category_find(const struct ARegion *region, const char *idname);
struct PanelCategoryStack *UI_panel_category_active_find(struct ARegion *region,
const char *idname);
const char *UI_panel_category_active_get(struct ARegion *region, bool set_fallback);
void UI_panel_category_active_set(struct ARegion *region, const char *idname);
void UI_panel_category_active_set_default(struct ARegion *region, const char *idname);
-struct PanelCategoryDyn *UI_panel_category_find_mouse_over_ex(struct ARegion *region,
- const int x,
- const int y);
-struct PanelCategoryDyn *UI_panel_category_find_mouse_over(struct ARegion *region,
- const struct wmEvent *event);
void UI_panel_category_clear_all(struct ARegion *region);
void UI_panel_category_draw_all(struct ARegion *region, const char *category_id_active);
-struct PanelType *UI_paneltype_find(int space_id, int region_id, const char *idname);
-
/* Panel custom data. */
struct PointerRNA *UI_panel_custom_data_get(const struct Panel *panel);
struct PointerRNA *UI_region_panel_custom_data_under_cursor(const struct bContext *C,
@@ -1728,7 +1721,7 @@ void UI_panel_custom_data_set(struct Panel *panel, struct PointerRNA *custom_dat
struct Panel *UI_panel_add_instanced(const struct bContext *C,
struct ARegion *region,
struct ListBase *panels,
- char *panel_idname,
+ const char *panel_idname,
struct PointerRNA *custom_data);
void UI_panels_free_instanced(const struct bContext *C, struct ARegion *region);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index dc20e6f1813..02e083076f0 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -463,7 +463,7 @@ void ui_block_bounds_calc(uiBlock *block)
/* hardcoded exception... but that one is annoying with larger safety */
uiBut *bt = block->buttons.first;
- int xof = (bt && STREQLEN(bt->str, "ERROR", 5)) ? 10 : 40;
+ int xof = (bt && STRPREFIX(bt->str, "ERROR")) ? 10 : 40;
block->safety.xmin = block->rect.xmin - xof;
block->safety.ymin = block->rect.ymin - xof;
@@ -702,10 +702,10 @@ static bool ui_but_equals_old(const uiBut *but, const uiBut *oldbut)
if (but->funcN != oldbut->funcN) {
return false;
}
- if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) {
+ if (!ELEM(oldbut->func_arg1, oldbut, but->func_arg1)) {
return false;
}
- if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) {
+ if (!ELEM(oldbut->func_arg2, oldbut, but->func_arg2)) {
return false;
}
if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) ||
@@ -772,6 +772,95 @@ static void ui_but_extra_icons_update_from_old_but(const uiBut *new_but, const u
}
/**
+ * Update pointers and other information in the old active button based on new information in the
+ * corresponding new button from the current layout pass.
+ *
+ * \param oldbut: The button from the last layout pass that will be moved to the new block.
+ * \param but: The newly added button with much of the up to date information, to be feed later.
+ *
+ * \note #uiBut has ownership of many of its pointers. When the button is freed all these
+ * pointers are freed as well, so ownership has to be moved out of \a but in order to free it.
+ */
+static void ui_but_update_old_active_from_new(uiBut *oldbut, uiBut *but)
+{
+ BLI_assert(oldbut->active);
+
+ /* flags from the buttons we want to refresh, may want to add more here... */
+ const int flag_copy = UI_BUT_REDALERT | UI_HAS_ICON;
+ const int drawflag_copy = 0; /* None currently. */
+
+ /* still stuff needs to be copied */
+ oldbut->rect = but->rect;
+ oldbut->context = but->context; /* set by Layout */
+
+ /* drawing */
+ oldbut->icon = but->icon;
+ oldbut->iconadd = but->iconadd;
+ oldbut->alignnr = but->alignnr;
+
+ /* typically the same pointers, but not on undo/redo */
+ /* XXX some menu buttons store button itself in but->poin. Ugly */
+ if (oldbut->poin != (char *)oldbut) {
+ SWAP(char *, oldbut->poin, but->poin);
+ SWAP(void *, oldbut->func_argN, but->func_argN);
+ }
+
+ /* Move tooltip from new to old. */
+ SWAP(uiButToolTipFunc, oldbut->tip_func, but->tip_func);
+ SWAP(void *, oldbut->tip_argN, but->tip_argN);
+
+ oldbut->flag = (oldbut->flag & ~flag_copy) | (but->flag & flag_copy);
+ oldbut->drawflag = (oldbut->drawflag & ~drawflag_copy) | (but->drawflag & drawflag_copy);
+
+ ui_but_extra_icons_update_from_old_but(but, oldbut);
+ SWAP(ListBase, but->extra_op_icons, oldbut->extra_op_icons);
+
+ if (oldbut->type == UI_BTYPE_SEARCH_MENU) {
+ uiButSearch *search_oldbut = (uiButSearch *)oldbut, *search_but = (uiButSearch *)but;
+
+ SWAP(uiButSearchArgFreeFn, search_oldbut->arg_free_fn, search_but->arg_free_fn);
+ SWAP(void *, search_oldbut->arg, search_but->arg);
+ }
+
+ /* copy hardmin for list rows to prevent 'sticking' highlight to mouse position
+ * when scrolling without moving mouse (see T28432) */
+ if (ELEM(oldbut->type, UI_BTYPE_ROW, UI_BTYPE_LISTROW)) {
+ oldbut->hardmax = but->hardmax;
+ }
+
+ if (oldbut->type == UI_BTYPE_PROGRESS_BAR) {
+ uiButProgressbar *progress_oldbut = (uiButProgressbar *)oldbut;
+ uiButProgressbar *progress_but = (uiButProgressbar *)but;
+ progress_oldbut->progress = progress_but->progress;
+ }
+
+ /* move/copy string from the new button to the old */
+ /* needed for alt+mouse wheel over enums */
+ if (but->str != but->strdata) {
+ if (oldbut->str != oldbut->strdata) {
+ SWAP(char *, but->str, oldbut->str);
+ }
+ else {
+ oldbut->str = but->str;
+ but->str = but->strdata;
+ }
+ }
+ else {
+ if (oldbut->str != oldbut->strdata) {
+ MEM_freeN(oldbut->str);
+ oldbut->str = oldbut->strdata;
+ }
+ BLI_strncpy(oldbut->strdata, but->strdata, sizeof(oldbut->strdata));
+ }
+
+ if (but->dragpoin && (but->dragflag & UI_BUT_DRAGPOIN_FREE)) {
+ SWAP(void *, but->dragpoin, oldbut->dragpoin);
+ }
+
+ /* note: if layout hasn't been applied yet, it uses old button pointers... */
+}
+
+/**
* \return true when \a but_p is set (only done for active buttons).
*/
static bool ui_but_update_from_old_block(const bContext *C,
@@ -779,57 +868,36 @@ static bool ui_but_update_from_old_block(const bContext *C,
uiBut **but_p,
uiBut **but_old_p)
{
- const int drawflag_copy = 0; /* None currently. */
-
uiBlock *oldblock = block->oldblock;
- uiBut *oldbut = NULL, *but = *but_p;
- bool found_active = false;
+ uiBut *but = *but_p;
#if 0
- /* simple/stupid - search every time */
- oldbut = ui_but_find_old(oldblock, but);
- (void)but_old_p;
+ /* Simple method - search every time. Keep this for easy testing of the "fast path." */
+ uiBut *oldbut = ui_but_find_old(oldblock, but);
+ UNUSED_VARS(but_old_p);
#else
BLI_assert(*but_old_p == NULL || BLI_findindex(&oldblock->buttons, *but_old_p) != -1);
- /* Fast-path - avoid loop-in-loop, calling #ui_but_find_old
- * as long as old/new buttons are aligned. */
+ /* As long as old and new buttons are aligned, avoid loop-in-loop (calling #ui_but_find_old). */
+ uiBut *oldbut;
if (LIKELY(*but_old_p && ui_but_equals_old(but, *but_old_p))) {
oldbut = *but_old_p;
}
else {
- /* fallback to block search */
+ /* Fallback to block search. */
oldbut = ui_but_find_old(oldblock, but);
}
(*but_old_p) = oldbut ? oldbut->next : NULL;
#endif
+ bool found_active = false;
+
if (!oldbut) {
- return found_active;
+ return false;
}
if (oldbut->active) {
- /* flags from the buttons we want to refresh, may want to add more here... */
- const int flag_copy = UI_BUT_REDALERT | UI_HAS_ICON;
-
- found_active = true;
-
-#if 0
- but->flag = oldbut->flag;
- but->active = oldbut->active;
- but->pos = oldbut->pos;
- but->ofs = oldbut->ofs;
- but->editstr = oldbut->editstr;
- but->editval = oldbut->editval;
- but->editvec = oldbut->editvec;
- but->selsta = oldbut->selsta;
- but->selend = oldbut->selend;
- but->softmin = oldbut->softmin;
- but->softmax = oldbut->softmax;
- oldbut->active = NULL;
-#endif
-
- /* move button over from oldblock to new block */
+ /* Move button over from oldblock to new block. */
BLI_remlink(&oldblock->buttons, oldbut);
BLI_insertlinkafter(&block->buttons, but, oldbut);
/* Add the old button to the button groups in the new block. */
@@ -837,82 +905,16 @@ static bool ui_but_update_from_old_block(const bContext *C,
oldbut->block = block;
*but_p = oldbut;
- /* still stuff needs to be copied */
- oldbut->rect = but->rect;
- oldbut->context = but->context; /* set by Layout */
-
- /* drawing */
- oldbut->icon = but->icon;
- oldbut->iconadd = but->iconadd;
- oldbut->alignnr = but->alignnr;
-
- /* typically the same pointers, but not on undo/redo */
- /* XXX some menu buttons store button itself in but->poin. Ugly */
- if (oldbut->poin != (char *)oldbut) {
- SWAP(char *, oldbut->poin, but->poin);
- SWAP(void *, oldbut->func_argN, but->func_argN);
- }
-
- /* Move tooltip from new to old. */
- SWAP(uiButToolTipFunc, oldbut->tip_func, but->tip_func);
- SWAP(void *, oldbut->tip_argN, but->tip_argN);
-
- oldbut->flag = (oldbut->flag & ~flag_copy) | (but->flag & flag_copy);
- oldbut->drawflag = (oldbut->drawflag & ~drawflag_copy) | (but->drawflag & drawflag_copy);
-
- ui_but_extra_icons_update_from_old_but(but, oldbut);
- SWAP(ListBase, but->extra_op_icons, oldbut->extra_op_icons);
-
- if (oldbut->type == UI_BTYPE_SEARCH_MENU) {
- uiButSearch *search_oldbut = (uiButSearch *)oldbut, *search_but = (uiButSearch *)but;
-
- SWAP(uiButSearchArgFreeFn, search_oldbut->arg_free_fn, search_but->arg_free_fn);
- SWAP(void *, search_oldbut->arg, search_but->arg);
- }
-
- /* copy hardmin for list rows to prevent 'sticking' highlight to mouse position
- * when scrolling without moving mouse (see T28432) */
- if (ELEM(oldbut->type, UI_BTYPE_ROW, UI_BTYPE_LISTROW)) {
- oldbut->hardmax = but->hardmax;
- }
-
- if (oldbut->type == UI_BTYPE_PROGRESS_BAR) {
- uiButProgressbar *progress_oldbut = (uiButProgressbar *)oldbut;
- uiButProgressbar *progress_but = (uiButProgressbar *)but;
- progress_oldbut->progress = progress_but->progress;
- }
+ ui_but_update_old_active_from_new(oldbut, but);
if (!BLI_listbase_is_empty(&block->butstore)) {
UI_butstore_register_update(block, oldbut, but);
}
- /* move/copy string from the new button to the old */
- /* needed for alt+mouse wheel over enums */
- if (but->str != but->strdata) {
- if (oldbut->str != oldbut->strdata) {
- SWAP(char *, but->str, oldbut->str);
- }
- else {
- oldbut->str = but->str;
- but->str = but->strdata;
- }
- }
- else {
- if (oldbut->str != oldbut->strdata) {
- MEM_freeN(oldbut->str);
- oldbut->str = oldbut->strdata;
- }
- BLI_strncpy(oldbut->strdata, but->strdata, sizeof(oldbut->strdata));
- }
-
- if (but->dragpoin && (but->dragflag & UI_BUT_DRAGPOIN_FREE)) {
- SWAP(void *, but->dragpoin, oldbut->dragpoin);
- }
-
BLI_remlink(&block->buttons, but);
ui_but_free(C, but);
- /* note: if layout hasn't been applied yet, it uses old button pointers... */
+ found_active = true;
}
else {
const int flag_copy = UI_BUT_DRAG_MULTI;
@@ -928,9 +930,11 @@ static bool ui_but_update_from_old_block(const bContext *C,
return found_active;
}
-/* needed for temporarily rename buttons, such as in outliner or file-select,
- * they should keep calling uiDefButs to keep them alive */
-/* returns 0 when button removed */
+/**
+ * Needed for temporarily rename buttons, such as in outliner or file-select,
+ * they should keep calling #uiDefBut to keep them alive.
+ * \return false when button removed.
+ */
bool UI_but_active_only_ex(
const bContext *C, ARegion *region, uiBlock *block, uiBut *but, const bool remove_on_failure)
{
@@ -1581,6 +1585,7 @@ void ui_but_override_flag(Main *bmain, uiBut *but)
}
}
+/* -------------------------------------------------------------------- */
/** \name Button Extra Operator Icons
*
* Extra icons are shown on the right hand side of buttons. They can be clicked to invoke custom
@@ -1992,7 +1997,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
else if (block->panel) {
bool show_background = region->alignment != RGN_ALIGN_FLOAT;
if (show_background) {
- if (block->panel->type && (block->panel->type->flag & PNL_NO_HEADER)) {
+ if (block->panel->type && (block->panel->type->flag & PANEL_TYPE_NO_HEADER)) {
if (region->regiontype == RGN_TYPE_TOOLS) {
/* We never want a background around active tools. */
show_background = false;
@@ -4064,6 +4069,11 @@ static uiBut *ui_def_but(uiBlock *block,
}
#endif
+ /* Always keep text in radio-buttons (expanded enums) center aligned. */
+ if (ELEM(but->type, UI_BTYPE_ROW)) {
+ but->drawflag &= ~UI_BUT_TEXT_LEFT;
+ }
+
but->drawflag |= (block->flag & UI_BUT_ALIGN);
if (block->lock == true) {
@@ -4251,8 +4261,8 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
0,
"");
}
- uiItemS(column);
}
+ uiItemS(column);
}
else {
if (item->icon) {
diff --git a/source/blender/editors/interface/interface_button_group.c b/source/blender/editors/interface/interface_button_group.c
index 2d2da9a4d14..90479eaee94 100644
--- a/source/blender/editors/interface/interface_button_group.c
+++ b/source/blender/editors/interface/interface_button_group.c
@@ -75,7 +75,6 @@ void ui_block_free_button_groups(uiBlock *block)
}
}
-/* This function should be removed whenever #ui_layout_replace_but_ptr is removed. */
void ui_button_group_replace_but_ptr(uiBlock *block, const void *old_but_ptr, uiBut *new_but)
{
LISTBASE_FOREACH (uiButtonGroup *, button_group, &block->button_groups) {
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index dec1710ac69..d9571dc98bd 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -973,15 +973,15 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region),
1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_a, res, is_line, pos);
}
else {
- if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_R) {
+ if (ELEM(hist->mode, HISTO_MODE_RGB, HISTO_MODE_R)) {
histogram_draw_one(
1.0, 0.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_r, res, is_line, pos);
}
- if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_G) {
+ if (ELEM(hist->mode, HISTO_MODE_RGB, HISTO_MODE_G)) {
histogram_draw_one(
0.0, 1.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_g, res, is_line, pos);
}
- if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_B) {
+ if (ELEM(hist->mode, HISTO_MODE_RGB, HISTO_MODE_B)) {
histogram_draw_one(
0.0, 0.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_b, res, is_line, pos);
}
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index a740a152f1c..4d0e1584156 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -78,7 +78,7 @@ wmKeyMap *eyedropper_colorband_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items_point[] = {
{EYE_MODAL_POINT_CANCEL, "CANCEL", 0, "Cancel", ""},
- {EYE_MODAL_POINT_SAMPLE, "SAMPLE_SAMPLE", 0, "Sample a point", ""},
+ {EYE_MODAL_POINT_SAMPLE, "SAMPLE_SAMPLE", 0, "Sample a Point", ""},
{EYE_MODAL_POINT_CONFIRM, "SAMPLE_CONFIRM", 0, "Confirm Sampling", ""},
{EYE_MODAL_POINT_RESET, "SAMPLE_RESET", 0, "Reset Sampling", ""},
{0, NULL, 0, NULL, NULL},
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index b77f8bf3b63..af71306cc3b 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -504,7 +504,7 @@ bool ui_but_is_editing(const uiBut *but)
void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
{
static int lastdy = 0;
- int dy = event->prevy - event->y;
+ int dy = WM_event_absolute_delta_y(event);
/* This event should be originally from event->type,
* converting wrong event into wheel is bad, see T33803. */
@@ -518,10 +518,6 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
lastdy += dy;
if (abs(lastdy) > (int)UI_UNIT_Y) {
- if (U.uiflag2 & USER_TRACKPAD_NATURAL) {
- dy = -dy;
- }
-
*val = KM_PRESS;
if (dy > 0) {
@@ -1024,7 +1020,7 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data)
}
ui_but_value_set(but, (double)value_toggle);
- if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) {
+ if (ELEM(but->type, UI_BTYPE_ICON_TOGGLE, UI_BTYPE_ICON_TOGGLE_N)) {
ui_but_update_edited(but);
}
@@ -3564,7 +3560,7 @@ static void ui_do_but_textedit(
/* for double click: we do a press again for when you first click on button
* (selects all text, no cursor pos) */
- if (event->val == KM_PRESS || event->val == KM_DBL_CLICK) {
+ if (ELEM(event->val, KM_PRESS, KM_DBL_CLICK)) {
float mx = event->x;
float my = event->y;
ui_window_to_block_fl(data->region, block, &mx, &my);
@@ -4550,10 +4546,22 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, cons
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
- if (ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
- /* Support alt+wheel on expanded enum rows */
+ if (ELEM(event->type, MOUSEPAN, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
+ /* Support ctrl-wheel to cycle values on expanded enum rows. */
if (but->type == UI_BTYPE_ROW) {
- const int direction = (event->type == WHEELDOWNMOUSE) ? -1 : 1;
+ int type = event->type;
+ int val = event->val;
+
+ /* Convert pan to scroll-wheel. */
+ if (type == MOUSEPAN) {
+ ui_pan_to_scroll(event, &type, &val);
+
+ if (type == MOUSEPAN) {
+ return WM_UI_HANDLER_BREAK;
+ }
+ }
+
+ const int direction = (type == WHEELDOWNMOUSE) ? -1 : 1;
uiBut *but_select = ui_but_find_select_in_enum(but, direction);
if (but_select) {
uiBut *but_other = (direction == -1) ? but_select->next : but_select->prev;
@@ -4728,7 +4736,7 @@ static float ui_numedit_apply_snap(int temp,
float softmax,
const enum eSnapType snap)
{
- if (temp == softmin || temp == softmax) {
+ if (ELEM(temp, softmin, softmax)) {
return temp;
}
@@ -5040,7 +5048,7 @@ static int ui_do_but_NUM(
}
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
- if (event->type == EVT_ESCKEY || event->type == RIGHTMOUSE) {
+ if (ELEM(event->type, EVT_ESCKEY, RIGHTMOUSE)) {
if (event->val == KM_PRESS) {
data->cancel = true;
data->escapecancel = true;
@@ -5232,13 +5240,13 @@ static bool ui_numedit_but_SLI(uiBut *but,
temp = round_fl_to_int(tempf);
if (snap) {
- if (tempf == softmin || tempf == softmax) {
+ if (ELEM(tempf, softmin, softmax)) {
/* pass */
}
else if (ui_but_is_float(but)) {
if (shift) {
- if (tempf == softmin || tempf == softmax) {
+ if (ELEM(tempf, softmin, softmax)) {
}
else if (softrange < 2.10f) {
tempf = roundf(tempf * 100.0f) * 0.01f;
@@ -5362,7 +5370,7 @@ static int ui_do_but_SLI(
#endif
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
- if (event->type == EVT_ESCKEY || event->type == RIGHTMOUSE) {
+ if (ELEM(event->type, EVT_ESCKEY, RIGHTMOUSE)) {
if (event->val == KM_PRESS) {
data->cancel = true;
data->escapecancel = true;
@@ -5648,8 +5656,20 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
return WM_UI_HANDLER_BREAK;
}
if (ui_but_supports_cycling(but)) {
- if (ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
- const int direction = (event->type == WHEELDOWNMOUSE) ? 1 : -1;
+ if (ELEM(event->type, MOUSEPAN, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
+ int type = event->type;
+ int val = event->val;
+
+ /* Convert pan to scroll-wheel. */
+ if (type == MOUSEPAN) {
+ ui_pan_to_scroll(event, &type, &val);
+
+ if (type == MOUSEPAN) {
+ return WM_UI_HANDLER_BREAK;
+ }
+ }
+
+ const int direction = (type == WHEELDOWNMOUSE) ? 1 : -1;
data->value = ui_but_menu_step(but, direction);
@@ -5973,7 +5993,7 @@ static int ui_do_but_UNITVEC(
}
}
}
- else if (event->type == EVT_ESCKEY || event->type == RIGHTMOUSE) {
+ else if (ELEM(event->type, EVT_ESCKEY, RIGHTMOUSE)) {
if (event->val == KM_PRESS) {
data->cancel = true;
data->escapecancel = true;
@@ -6304,7 +6324,7 @@ static int ui_do_but_HSVCUBE(
}
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
- if (event->type == EVT_ESCKEY || event->type == RIGHTMOUSE) {
+ if (ELEM(event->type, EVT_ESCKEY, RIGHTMOUSE)) {
if (event->val == KM_PRESS) {
data->cancel = true;
data->escapecancel = true;
@@ -6372,7 +6392,7 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but,
* 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 (hsv[2] == 0.f) {
+ if (hsv[2] == 0.0f) {
hsv[2] = 0.0001f;
}
}
@@ -6475,15 +6495,15 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but,
* 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 (hsv[2] == 0.f) {
+ if (hsv[2] == 0.0f) {
hsv[2] = 0.0001f;
}
}
else {
- if (hsv[2] == 0.f) {
+ if (hsv[2] == 0.0f) {
hsv[2] = 0.0001f;
}
- if (hsv[2] == 1.f) {
+ if (hsv[2] == 1.0f) {
hsv[2] = 0.9999f;
}
}
@@ -6578,7 +6598,7 @@ static int ui_do_but_HSVCIRCLE(
}
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
- if (event->type == EVT_ESCKEY || event->type == RIGHTMOUSE) {
+ if (ELEM(event->type, EVT_ESCKEY, RIGHTMOUSE)) {
if (event->val == KM_PRESS) {
data->cancel = true;
data->escapecancel = true;
@@ -7291,7 +7311,7 @@ static bool ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int m
hist->ymax += (dy * 0.1f) * yfac;
/* 0.1 allows us to see HDR colors up to 10 */
- CLAMP(hist->ymax, 0.1f, 100.f);
+ CLAMP(hist->ymax, 0.1f, 100.0f);
data->draglastx = mx;
data->draglasty = my;
@@ -7324,7 +7344,7 @@ static int ui_do_but_HISTOGRAM(
/* XXX hardcoded keymap check.... */
if (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS) {
Histogram *hist = (Histogram *)but->poin;
- hist->ymax = 1.f;
+ hist->ymax = 1.0f;
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
@@ -7397,7 +7417,7 @@ static int ui_do_but_WAVEFORM(
/* XXX hardcoded keymap check.... */
if (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS) {
Scopes *scopes = (Scopes *)but->poin;
- scopes->wavefrm_yfac = 1.f;
+ scopes->wavefrm_yfac = 1.0f;
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
@@ -7693,6 +7713,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
}
#ifdef USE_DRAG_MULTINUM
+ data = but->active;
if (data) {
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) ||
/* if we started dragging, progress on any event */
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 01eb8f95d18..c4b54af1396 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -943,7 +943,7 @@ typedef struct uiWidgetBaseParameters {
/* We pack alpha check and discard factor in alpha_discard.
* If the value is negative then we do alpha check.
* The absolute value itself is the discard factor.
- * Initialize value to 1.0.f if you don't want discard */
+ * Initialize value to 1.0f if you don't want discard. */
float alpha_discard;
float tria_type;
float _pad[3];
@@ -995,8 +995,9 @@ void ui_draw_preview_item(
#define UI_TEXT_MARGIN_X 0.4f
#define UI_POPUP_MARGIN (UI_DPI_FAC * 12)
-/* margin at top of screen for popups */
-#define UI_POPUP_MENU_TOP (int)(8 * UI_DPI_FAC)
+/* Margin at top of screen for popups. Note this value must be sufficient
+ to draw a popover arrow to avoid cropping it. */
+#define UI_POPUP_MENU_TOP (int)(10 * UI_DPI_FAC)
#define UI_PIXEL_AA_JITTER 8
extern const float ui_pixel_jitter[UI_PIXEL_AA_JITTER][2];
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index ad260274e78..df7fd3dee0e 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -964,7 +964,11 @@ static uiBut *ui_item_with_label(uiLayout *layout,
UI_block_layout_set_current(block, layout);
/* Only add new row if more than 1 item will be added. */
- if (name[0] || use_prop_decorate) {
+ if (name[0]
+#ifdef UI_PROP_DECORATE
+ || use_prop_decorate
+#endif
+ ) {
/* Also avoid setting 'align' if possible. Set the space to zero instead as aligning a large
* number of labels can end up aligning thousands of buttons when displaying key-map search (a
* heavy operation), see: T78636. */
@@ -972,8 +976,8 @@ static uiBut *ui_item_with_label(uiLayout *layout,
sub->space = 0;
}
-#ifdef UI_PROP_DECORATE
if (name[0]) {
+#ifdef UI_PROP_DECORATE
if (use_prop_sep) {
layout_prop_decorate = uiItemL_respect_property_split(layout, name, 0);
}
@@ -998,7 +1002,7 @@ static uiBut *ui_item_with_label(uiLayout *layout,
const PropertySubType subtype = RNA_property_subtype(prop);
uiBut *but;
- if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) {
+ if (ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)) {
UI_block_layout_set_current(block, uiLayoutRow(sub, true));
but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, prop_but_width - UI_UNIT_X, h);
@@ -1882,7 +1886,7 @@ static void ui_item_rna_size(uiLayout *layout,
else if (type == PROP_ENUM && !icon_only) {
w += UI_UNIT_X / 4;
}
- else if (type == PROP_FLOAT || type == PROP_INT) {
+ else if (ELEM(type, PROP_FLOAT, PROP_INT)) {
w += UI_UNIT_X * 3;
}
}
@@ -2148,7 +2152,6 @@ void uiItemFullR(uiLayout *layout,
uiLayout *layout_split = uiLayoutSplit(
layout_row ? layout_row : layout, UI_ITEM_PROP_SEP_DIVIDE, true);
bool label_added = false;
- layout_split->space = 0;
uiLayout *layout_sub = uiLayoutColumn(layout_split, true);
layout_sub->space = 0;
@@ -2292,7 +2295,7 @@ void uiItemFullR(uiLayout *layout,
ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only);
}
/* property with separate label */
- else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) {
+ else if (ELEM(type, PROP_ENUM, PROP_STRING, PROP_POINTER)) {
but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
but = ui_but_add_search(but, ptr, prop, NULL, NULL);
@@ -3186,7 +3189,6 @@ uiPropertySplitWrapper uiItemPropertySplitWrapperCreate(uiLayout *parent_layout)
uiLayout *layout_row = uiLayoutRow(parent_layout, true);
uiLayout *layout_split = uiLayoutSplit(layout_row, UI_ITEM_PROP_SEP_DIVIDE, true);
- layout_split->space = 0;
split_wrapper.label_column = uiLayoutColumn(layout_split, true);
split_wrapper.label_column->alignment = UI_LAYOUT_ALIGN_RIGHT;
split_wrapper.property_row = ui_item_prop_split_layout_hack(parent_layout, layout_split);
@@ -5478,7 +5480,7 @@ uiLayout *UI_block_layout(uiBlock *block,
layout->context = NULL;
layout->emboss = UI_EMBOSS_UNDEFINED;
- if (type == UI_LAYOUT_MENU || type == UI_LAYOUT_PIEMENU) {
+ if (ELEM(type, UI_LAYOUT_MENU, UI_LAYOUT_PIEMENU)) {
layout->space = 0;
}
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index bfe5dc223c8..aafc1c53a3b 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -85,6 +85,11 @@ typedef enum uiPanelRuntimeFlag {
PANEL_USE_CLOSED_FROM_SEARCH = (1 << 8),
/** The Panel was before the start of the current / latest layout pass. */
PANEL_WAS_CLOSED = (1 << 9),
+ /**
+ * Set when the panel is being dragged and while it animates back to its aligned
+ * position. Unlike #PANEL_STATE_ANIMATION, this is applied to sub-panels as well.
+ */
+ PANEL_IS_DRAG_DROP = (1 << 10),
} uiPanelRuntimeFlag;
/* The state of the mouse position relative to the panel. */
@@ -96,8 +101,6 @@ typedef enum uiPanelMouseState {
typedef enum uiHandlePanelState {
PANEL_STATE_DRAG,
- PANEL_STATE_DRAG_SCALE,
- PANEL_STATE_WAIT_UNTAB,
PANEL_STATE_ANIMATION,
PANEL_STATE_EXIT,
} uiHandlePanelState;
@@ -110,10 +113,8 @@ typedef struct uiHandlePanelData {
double starttime;
/* Dragging. */
- bool is_drag_drop;
int startx, starty;
int startofsx, startofsy;
- int startsizex, startsizey;
float start_cur_xmin, start_cur_ymin;
} uiHandlePanelData;
@@ -209,7 +210,7 @@ static bool panel_active_animation_changed(ListBase *lb,
/**
* \return True if the properties editor switch tabs since the last layout pass.
*/
-static bool properties_space_needs_realign(ScrArea *area, ARegion *region)
+static bool properties_space_needs_realign(const ScrArea *area, const ARegion *region)
{
if (area->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) {
SpaceProperties *sbuts = area->spacedata.first;
@@ -222,7 +223,7 @@ static bool properties_space_needs_realign(ScrArea *area, ARegion *region)
return false;
}
-static bool panels_need_realign(ScrArea *area, ARegion *region, Panel **r_panel_animation)
+static bool panels_need_realign(const ScrArea *area, ARegion *region, Panel **r_panel_animation)
{
*r_panel_animation = NULL;
@@ -259,7 +260,7 @@ static Panel *panel_add_instanced(ARegion *region,
PanelType *panel_type,
PointerRNA *custom_data)
{
- Panel *panel = MEM_callocN(sizeof(Panel), "instanced panel");
+ Panel *panel = MEM_callocN(sizeof(Panel), __func__);
panel->type = panel_type;
BLI_strncpy(panel->panelname, panel_type->idname, sizeof(panel->panelname));
@@ -298,7 +299,7 @@ static Panel *panel_add_instanced(ARegion *region,
Panel *UI_panel_add_instanced(const bContext *C,
ARegion *region,
ListBase *panels,
- char *panel_idname,
+ const char *panel_idname,
PointerRNA *custom_data)
{
ARegionType *region_type = region->type;
@@ -313,19 +314,19 @@ Panel *UI_panel_add_instanced(const bContext *C,
Panel *new_panel = panel_add_instanced(region, panels, panel_type, custom_data);
- /* Do this after #panel_add_instatnced so all subpanels are added. */
+ /* Do this after #panel_add_instatnced so all sub-panels are added. */
panel_set_expansion_from_list_data(C, new_panel);
return new_panel;
}
/**
- * Find a unique key to append to the #PanelTyype.idname for the lookup to the panel's #uiBlock.
+ * Find a unique key to append to the #PanelType.idname for the lookup to the panel's #uiBlock.
* Needed for instanced panels, where there can be multiple with the same type and identifier.
*/
void UI_list_panel_unique_str(Panel *panel, char *r_name)
{
- /* The panel sortorder will be unique for a specific panel type because the instanced
+ /* The panel sort-order will be unique for a specific panel type because the instanced
* panel list is regenerated for every change in the data order / length. */
snprintf(r_name, INSTANCED_PANEL_UNIQUE_STR_LEN, "%d", panel->sortorder);
}
@@ -335,7 +336,7 @@ void UI_list_panel_unique_str(Panel *panel, char *r_name)
* and is freed by #UI_panels_free_instanced.
*
* \note The only panels that should need to be deleted at runtime are panels with the
- * #PNL_INSTANCED flag set.
+ * #PANEL_TYPE_INSTANCED flag set.
*/
static void panel_delete(const bContext *C, ARegion *region, ListBase *panels, Panel *panel)
{
@@ -362,7 +363,7 @@ void UI_panels_free_instanced(const bContext *C, ARegion *region)
{
/* Delete panels with the instanced flag. */
LISTBASE_FOREACH_MUTABLE (Panel *, panel, &region->panels) {
- if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) {
+ if ((panel->type != NULL) && (panel->type->flag & PANEL_TYPE_INSTANCED)) {
/* Make sure the panel's handler is removed before deleting it. */
if (C != NULL && panel->activedata != NULL) {
panel_activate_state(C, panel, PANEL_STATE_EXIT);
@@ -406,7 +407,7 @@ bool UI_panel_list_matches_data(ARegion *region,
int i = 0;
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
- if (panel->type != NULL && panel->type->flag & PNL_INSTANCED) {
+ if (panel->type != NULL && panel->type->flag & PANEL_TYPE_INSTANCED) {
/* The panels were reordered by drag and drop. */
if (panel->flag & PNL_INSTANCED_LIST_ORDER_CHANGED) {
return false;
@@ -455,9 +456,9 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
/* Find how many instanced panels with this context string. */
int list_panels_len = 0;
- LISTBASE_FOREACH (Panel *, panel, &region->panels) {
+ LISTBASE_FOREACH (const Panel *, panel, &region->panels) {
if (panel->type) {
- if (panel->type->flag & PNL_INSTANCED) {
+ if (panel->type->flag & PANEL_TYPE_INSTANCED) {
if (panel_type_context_poll(region, panel->type, context)) {
list_panels_len++;
}
@@ -466,11 +467,11 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
}
/* Sort the matching instanced panels by their display order. */
- PanelSort *panel_sort = MEM_callocN(list_panels_len * sizeof(*panel_sort), "instancedpanelsort");
+ PanelSort *panel_sort = MEM_callocN(list_panels_len * sizeof(*panel_sort), __func__);
PanelSort *sort_index = panel_sort;
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
if (panel->type) {
- if (panel->type->flag & PNL_INSTANCED) {
+ if (panel->type->flag & PANEL_TYPE_INSTANCED) {
if (panel_type_context_poll(region, panel->type, context)) {
sort_index->panel = panel;
sort_index++;
@@ -523,7 +524,7 @@ static bool panel_set_expand_from_list_data_recursive(Panel *panel, short flag,
static void panel_set_expansion_from_list_data(const bContext *C, Panel *panel)
{
BLI_assert(panel->type != NULL);
- BLI_assert(panel->type->flag & PNL_INSTANCED);
+ BLI_assert(panel->type->flag & PANEL_TYPE_INSTANCED);
if (panel->type->get_list_data_expand_flag == NULL) {
/* Instanced panel doesn't support loading expansion. */
return;
@@ -546,7 +547,7 @@ static void region_panels_set_expansion_from_list_data(const bContext *C, ARegio
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
if (panel->runtime_flag & PANEL_ACTIVE) {
PanelType *panel_type = panel->type;
- if (panel_type != NULL && panel->type->flag & PNL_INSTANCED) {
+ if (panel_type != NULL && panel->type->flag & PANEL_TYPE_INSTANCED) {
panel_set_expansion_from_list_data(C, panel);
}
}
@@ -556,12 +557,12 @@ static void region_panels_set_expansion_from_list_data(const bContext *C, ARegio
/**
* Recursive implementation for #set_panels_list_data_expand_flag.
*/
-static void get_panel_expand_flag(Panel *panel, short *flag, short *flag_index)
+static void get_panel_expand_flag(const Panel *panel, short *flag, short *flag_index)
{
const bool open = !(panel->flag & PNL_CLOSED);
SET_FLAG_FROM_TEST(*flag, open, (1 << *flag_index));
- LISTBASE_FOREACH (Panel *, child, &panel->children) {
+ LISTBASE_FOREACH (const Panel *, child, &panel->children) {
*flag_index = *flag_index + 1;
get_panel_expand_flag(child, flag, flag_index);
}
@@ -571,8 +572,8 @@ static void get_panel_expand_flag(Panel *panel, short *flag, short *flag_index)
* Call the callback to store the panel and sub-panel expansion settings in the list item that
* corresponds to each instanced panel.
*
- * \note This needs to iterate through all of the regions panels because the panel with changed
- * expansion could have been the sub-panel of a instanced panel, meaning it might not know
+ * \note This needs to iterate through all of the region's panels because the panel with changed
+ * expansion might have been the sub-panel of an instanced panel, meaning it might not know
* which list item it corresponds to.
*/
static void set_panels_list_data_expand_flag(const bContext *C, const ARegion *region)
@@ -584,7 +585,7 @@ static void set_panels_list_data_expand_flag(const bContext *C, const ARegion *r
}
/* Check for #PANEL_ACTIVE so we only set the expand flag for active panels. */
- if (panel_type->flag & PNL_INSTANCED && panel->runtime_flag & PANEL_ACTIVE) {
+ if (panel_type->flag & PANEL_TYPE_INSTANCED && panel->runtime_flag & PANEL_ACTIVE) {
short expand_flag;
short flag_index = 0;
get_panel_expand_flag(panel, &expand_flag, &flag_index);
@@ -603,22 +604,26 @@ static void set_panels_list_data_expand_flag(const bContext *C, const ARegion *r
/**
* Set flag state for a panel and its sub-panels.
- *
- * \return True if this function changed any of the flags, false if it didn't.
*/
-static bool panel_set_flag_recursive(Panel *panel, int flag, bool value)
+static void panel_set_flag_recursive(Panel *panel, short flag, bool value)
{
- const short flag_original = panel->flag;
-
SET_FLAG_FROM_TEST(panel->flag, value, flag);
- bool changed = (flag_original != panel->flag);
-
LISTBASE_FOREACH (Panel *, child, &panel->children) {
- changed |= panel_set_flag_recursive(child, flag, value);
+ panel_set_flag_recursive(child, flag, value);
}
+}
- return changed;
+/**
+ * Set runtime flag state for a panel and its sub-panels.
+ */
+static void panel_set_runtime_flag_recursive(Panel *panel, short flag, bool value)
+{
+ SET_FLAG_FROM_TEST(panel->runtime_flag, value, flag);
+
+ LISTBASE_FOREACH (Panel *, sub_panel, &panel->children) {
+ panel_set_runtime_flag_recursive(sub_panel, flag, value);
+ }
}
static void panels_collapse_all(ARegion *region, const Panel *from_panel)
@@ -631,7 +636,7 @@ static void panels_collapse_all(ARegion *region, const Panel *from_panel)
PanelType *pt = panel->type;
/* Close panels with headers in the same context. */
- if (pt && from_pt && !(pt->flag & PNL_NO_HEADER)) {
+ if (pt && from_pt && !(pt->flag & PANEL_TYPE_NO_HEADER)) {
if (!pt->context[0] || !from_pt->context[0] || STREQ(pt->context, from_pt->context)) {
if ((panel->flag & PNL_PIN) || !category || !pt->category[0] ||
STREQ(pt->category, category)) {
@@ -657,7 +662,7 @@ static bool panel_type_context_poll(ARegion *region,
return false;
}
-Panel *UI_panel_find_by_type(ListBase *lb, PanelType *pt)
+Panel *UI_panel_find_by_type(ListBase *lb, const PanelType *pt)
{
const char *idname = pt->idname;
@@ -681,11 +686,11 @@ Panel *UI_panel_begin(
const bool newpanel = (panel == NULL);
if (newpanel) {
- panel = MEM_callocN(sizeof(Panel), "new panel");
+ panel = MEM_callocN(sizeof(Panel), __func__);
panel->type = pt;
BLI_strncpy(panel->panelname, idname, sizeof(panel->panelname));
- if (pt->flag & PNL_DEFAULT_CLOSED) {
+ if (pt->flag & PANEL_TYPE_DEFAULT_CLOSED) {
panel->flag |= PNL_CLOSED;
panel->runtime_flag |= PANEL_WAS_CLOSED;
}
@@ -753,8 +758,8 @@ Panel *UI_panel_begin(
/**
* Create the panel header button group, used to mark which buttons are part of
- * panel headers for later panel search handling. Should be called before adding
- * buttons for the panel's header layout.
+ * panel headers for the panel search process that happens later. This Should be
+ * called before adding buttons for the panel's header layout.
*/
void UI_panel_header_buttons_begin(Panel *panel)
{
@@ -764,20 +769,20 @@ void UI_panel_header_buttons_begin(Panel *panel)
}
/**
- * Allow new button groups to be created after the header group.
+ * Finish the button group for the panel header to avoid putting panel body buttons in it.
*/
void UI_panel_header_buttons_end(Panel *panel)
{
uiBlock *block = panel->runtime.block;
- /* There should always be the button group created in #UI_panel_header_buttons_begin. */
+ /* A button group should always be created in #UI_panel_header_buttons_begin. */
BLI_assert(!BLI_listbase_is_empty(&block->button_groups));
uiButtonGroup *button_group = block->button_groups.last;
button_group->flag &= ~UI_BUTTON_GROUP_LOCK;
- /* Repurpose the first "header" button group if it is empty, in case the first button added to
+ /* Repurpose the first header button group if it is empty, in case the first button added to
* the panel doesn't add a new group (if the button is created directly rather than through an
* interface layout call). */
if (BLI_listbase_is_single(&block->button_groups) &&
@@ -785,9 +790,9 @@ void UI_panel_header_buttons_end(Panel *panel)
button_group->flag &= ~UI_BUTTON_GROUP_PANEL_HEADER;
}
else {
- /* We should still always add a new button group. Although this results in many empty groups,
- * without it, new buttons not protected with a #ui_block_new_button_group call would end up
- * in the panel header group. */
+ /* Always add a new button group. Although this may result in many empty groups, without it,
+ * new buttons in the panel body not protected with a #ui_block_new_button_group call would
+ * end up in the panel header group. */
ui_block_new_button_group(block, 0);
}
}
@@ -805,7 +810,7 @@ static float panel_region_offset_x_get(const ARegion *region)
/**
* Starting from the "block size" set in #UI_panel_end, calculate the full size
- * of the panel including the subpanel headers and buttons.
+ * of the panel including the sub-panel headers and buttons.
*/
static void panel_calculate_size_recursive(ARegion *region, Panel *panel)
{
@@ -854,7 +859,7 @@ static void panel_calculate_size_recursive(ARegion *region, Panel *panel)
void UI_panel_end(Panel *panel, int width, int height)
{
/* Store the size of the buttons layout in the panel. The actual panel size
- * (including subpanels) is calculated in #UI_panels_end. */
+ * (including sub-panels) is calculated in #UI_panels_end. */
panel->blocksizex = width;
panel->blocksizey = height;
}
@@ -878,7 +883,7 @@ static void ui_offset_panel_block(uiBlock *block)
block->rect.xmin = block->rect.ymin = 0.0;
}
-void ui_panel_tag_search_filter_match(struct Panel *panel)
+void ui_panel_tag_search_filter_match(Panel *panel)
{
panel->runtime_flag |= PANEL_SEARCH_FILTER_MATCH;
}
@@ -907,25 +912,22 @@ bool UI_panel_matches_search_filter(const Panel *panel)
}
/**
- * Set the flag telling the panel to use its search result status for
- * its expansion. Also activate animation if that changes the expansion.
+ * Set the flag telling the panel to use its search result status for its expansion.
*/
static void panel_set_expansion_from_seach_filter_recursive(const bContext *C,
Panel *panel,
- const bool use_search_closed,
- const bool use_animation)
+ const bool use_search_closed)
{
/* 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)) {
+ * but we can prevent running on header-less panels in some cases. */
+ if (panel->type == NULL || !(panel->type->flag & PANEL_TYPE_NO_HEADER)) {
SET_FLAG_FROM_TEST(panel->runtime_flag, use_search_closed, PANEL_USE_CLOSED_FROM_SEARCH);
}
LISTBASE_FOREACH (Panel *, child_panel, &panel->children) {
- /* Don't check if the subpanel is active, otherwise the
+ /* Don't check if the sub-panel 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);
+ panel_set_expansion_from_seach_filter_recursive(C, child_panel, use_search_closed);
}
}
@@ -934,18 +936,19 @@ static void panel_set_expansion_from_seach_filter_recursive(const bContext *C,
*/
static void region_panels_set_expansion_from_seach_filter(const bContext *C,
ARegion *region,
- const bool use_search_closed,
- const bool use_animation)
+ const bool use_search_closed)
{
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
- panel_set_expansion_from_seach_filter_recursive(C, panel, use_search_closed, use_animation);
+ /* Don't check if the panel is active, otherwise the expansion won't
+ * be correct when switching back to tab after exiting search. */
+ panel_set_expansion_from_seach_filter_recursive(C, panel, use_search_closed);
}
set_panels_list_data_expand_flag(C, region);
}
/**
- * Hide buttons in invisible layouts, which are created because in order to search,
- * buttons must be added for all panels, even panels that will end up closed.
+ * Hide buttons in invisible layouts, which are created because buttons must be
+ * added for all panels in order to search, even panels that will end up closed.
*/
static void panel_remove_invisible_layouts_recursive(Panel *panel, const Panel *parent_panel)
{
@@ -960,8 +963,8 @@ static void panel_remove_invisible_layouts_recursive(Panel *panel, const Panel *
}
}
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
+ /* If sub-panels have no search results but the parent panel does, then the parent panel open
+ * and the sub-panels will close. In that case there must be a way to hide the buttons in the
* panel but keep the header buttons. */
LISTBASE_FOREACH (uiButtonGroup *, button_group, &block->button_groups) {
if (button_group->flag & UI_BUTTON_GROUP_PANEL_HEADER) {
@@ -999,7 +1002,7 @@ static void region_panels_remove_invisible_layouts(ARegion *region)
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) {
+ if (panel->type && panel->type->flag & PANEL_TYPE_NO_HEADER) {
return false;
}
@@ -1029,42 +1032,24 @@ void UI_panels_draw(const bContext *C, ARegion *region)
/* Draw in reverse order, because #uiBlocks are added in reverse order
* and we need child panels to draw on top. */
LISTBASE_FOREACH_BACKWARD (uiBlock *, block, &region->uiblocks) {
- if (block->active && block->panel && !(block->panel->flag & PNL_SELECT) &&
+ if (block->active && block->panel && !UI_panel_is_dragging(block->panel) &&
!UI_block_is_search_only(block)) {
UI_block_draw(C, block);
}
}
LISTBASE_FOREACH_BACKWARD (uiBlock *, block, &region->uiblocks) {
- if (block->active && block->panel && (block->panel->flag & PNL_SELECT) &&
+ if (block->active && block->panel && UI_panel_is_dragging(block->panel) &&
!UI_block_is_search_only(block)) {
UI_block_draw(C, block);
}
}
}
-/* Triangle 'icon' for panel header. */
-void UI_draw_icon_tri(float x, float y, char dir, const float color[4])
-{
- const float f3 = 0.05 * U.widget_unit;
- const float f5 = 0.15 * U.widget_unit;
- const float f7 = 0.25 * U.widget_unit;
-
- if (dir == 'h') {
- UI_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y, color);
- }
- else if (dir == 't') {
- UI_draw_anti_tria(x - f5, y - f7, x + f5, y - f7, x, y + f3, color);
- }
- else { /* 'v' = vertical, down. */
- UI_draw_anti_tria(x - f5, y + f3, x + f5, y + f3, x, y - f7, color);
- }
-}
-
#define PNL_ICON UI_UNIT_X /* Could be UI_UNIT_Y too. */
/* For button layout next to label. */
-void UI_panel_label_offset(uiBlock *block, int *r_x, int *r_y)
+void UI_panel_label_offset(const uiBlock *block, int *r_x, int *r_y)
{
Panel *panel = block->panel;
const bool is_subpanel = (panel->type && panel->type->parent);
@@ -1125,7 +1110,7 @@ void ui_draw_aligned_panel(const uiStyle *style,
* can't be dragged. This may be changed in future. */
show_background);
const int panel_col = is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK;
- const bool draw_box_style = (panel->type && panel->type->flag & PNL_DRAW_BOX);
+ const bool draw_box_style = (panel->type && panel->type->flag & PANEL_TYPE_DRAW_BOX);
/* Use the theme for box widgets for box-style panels. */
uiWidgetColors *box_wcol = NULL;
@@ -1137,7 +1122,7 @@ void ui_draw_aligned_panel(const uiStyle *style,
const uint pos = GPU_vertformat_attr_add(
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
+ if (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER)) {
if (show_background) {
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(panel_col);
@@ -1593,7 +1578,7 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
static int get_panel_size_y(const Panel *panel)
{
- if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
+ if (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER)) {
return panel->sizey;
}
@@ -1604,7 +1589,7 @@ static int get_panel_real_size_y(const Panel *panel)
{
const int sizey = UI_panel_is_closed(panel) ? 0 : panel->sizey;
- if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
+ if (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER)) {
return sizey;
}
@@ -1628,14 +1613,9 @@ static int get_panel_real_ofsy(Panel *panel)
return panel->ofsy;
}
-bool UI_panel_is_dragging(const struct Panel *panel)
+bool UI_panel_is_dragging(const Panel *panel)
{
- uiHandlePanelData *data = panel->activedata;
- if (!data) {
- return false;
- }
-
- return data->is_drag_drop;
+ return panel->runtime_flag & PANEL_IS_DRAG_DROP;
}
/**
@@ -1653,13 +1633,13 @@ static int find_highest_panel(const void *a, const void *b)
/* Stick uppermost header-less panels to the top of the region -
* prevent them from being sorted (multiple header-less panels have to be sorted though). */
- if (panel_a->type->flag & PNL_NO_HEADER && panel_b->type->flag & PNL_NO_HEADER) {
+ if (panel_a->type->flag & PANEL_TYPE_NO_HEADER && panel_b->type->flag & PANEL_TYPE_NO_HEADER) {
/* Skip and check for `ofsy` and #Panel.sortorder below. */
}
- if (panel_a->type->flag & PNL_NO_HEADER) {
+ if (panel_a->type->flag & PANEL_TYPE_NO_HEADER) {
return -1;
}
- if (panel_b->type->flag & PNL_NO_HEADER) {
+ if (panel_b->type->flag & PANEL_TYPE_NO_HEADER) {
return 1;
}
@@ -1758,7 +1738,7 @@ static bool uiAlignPanelStep(ARegion *region, const float factor, const bool dra
const int region_offset_x = panel_region_offset_x_get(region);
for (int i = 0; i < active_panels_len; i++) {
PanelSort *ps = &panel_sort[i];
- const bool use_box = ps->panel->type->flag & PNL_DRAW_BOX;
+ const bool use_box = ps->panel->type->flag & PANEL_TYPE_DRAW_BOX;
ps->panel->runtime.region_ofsx = region_offset_x;
ps->new_offset_x = region_offset_x + ((use_box) ? UI_PANEL_BOX_STYLE_MARGIN : 0);
}
@@ -1768,7 +1748,7 @@ static bool uiAlignPanelStep(ARegion *region, const float factor, const bool dra
PanelSort *ps = &panel_sort[i];
y -= get_panel_real_size_y(ps->panel);
- const bool use_box = ps->panel->type->flag & PNL_DRAW_BOX;
+ const bool use_box = ps->panel->type->flag & PANEL_TYPE_DRAW_BOX;
if (use_box) {
y -= UI_PANEL_BOX_STYLE_MARGIN;
}
@@ -1848,25 +1828,17 @@ static void ui_do_animate(bContext *C, Panel *panel)
float fac = (PIL_check_seconds_timer() - data->starttime) / ANIMATION_TIME;
fac = min_ff(sqrtf(fac), 1.0f);
- /* For max 1 second, interpolate positions. */
if (uiAlignPanelStep(region, fac, false)) {
ED_region_tag_redraw(region);
}
else {
- fac = 1.0f;
- }
-
- if (fac >= 1.0f) {
- /* Store before data is freed. */
- const bool is_drag_drop = data->is_drag_drop;
-
- panel_activate_state(C, panel, PANEL_STATE_EXIT);
- if (is_drag_drop) {
- /* Note: doing this in #panel_activate_state would require removing `const` for context in
- * many other places. */
+ if (UI_panel_is_dragging(panel)) {
+ /* Note: doing this in #panel_activate_state would require
+ * removing `const` for context in many other places. */
reorder_instanced_panel_list(C, region, panel);
}
- return;
+
+ panel_activate_state(C, panel, PANEL_STATE_EXIT);
}
}
@@ -1874,7 +1846,7 @@ 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 = PANEL_USE_CLOSED_FROM_SEARCH;
+ const short flag_copy = PANEL_USE_CLOSED_FROM_SEARCH | PANEL_IS_DRAG_DROP;
const bool was_active = panel->runtime_flag & PANEL_ACTIVE;
const bool was_closed = UI_panel_is_closed(panel);
@@ -1902,10 +1874,10 @@ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y)
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);
+ region_panels_set_expansion_from_seach_filter(C, region, region_search_filter_active);
}
else if (region->flag & RGN_FLAG_SEARCH_FILTER_UPDATE) {
- region_panels_set_expansion_from_seach_filter(C, region, region_search_filter_active, true);
+ region_panels_set_expansion_from_seach_filter(C, region, region_search_filter_active);
}
if (region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE) {
@@ -1955,38 +1927,19 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
ARegion *region = CTX_wm_region(C);
/* Keep the drag position in the region with a small pad to keep the panel visible. */
- const int x = clamp_i(event->x, region->winrct.xmin, region->winrct.xmax + DRAG_REGION_PAD);
const int y = clamp_i(event->y, region->winrct.ymin, region->winrct.ymax + DRAG_REGION_PAD);
- float dx = (float)(x - data->startx);
float dy = (float)(y - data->starty);
/* Adjust for region zoom. */
- dx *= BLI_rctf_size_x(&region->v2d.cur) / (float)BLI_rcti_size_x(&region->winrct);
dy *= BLI_rctf_size_y(&region->v2d.cur) / (float)BLI_rcti_size_y(&region->winrct);
- if (data->state == PANEL_STATE_DRAG_SCALE) {
- panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX);
-
- if (data->startsizey - dy < UI_PANEL_MINY) {
- dy = -UI_PANEL_MINY + data->startsizey;
- }
-
- panel->sizey = data->startsizey - dy;
- panel->ofsy = data->startofsy + dy;
- }
- else {
- /* Reset the panel snapping, to allow dragging away from snapped edges. */
- panel->snap = PNL_SNAP_NONE;
+ /* Add the movement of the view due to edge scrolling while dragging. */
+ dy += ((float)region->v2d.cur.ymin - data->start_cur_ymin);
- /* Add the movement of the view due to edge scrolling while dragging. */
- dx += ((float)region->v2d.cur.xmin - data->start_cur_xmin);
- dy += ((float)region->v2d.cur.ymin - data->start_cur_ymin);
- panel->ofsx = data->startofsx + round_fl_to_int(dx);
- panel->ofsy = data->startofsy + round_fl_to_int(dy);
+ panel->ofsy = data->startofsy + round_fl_to_int(dy);
- uiAlignPanelStep(region, 0.2f, true);
- }
+ uiAlignPanelStep(region, 0.2f, true);
ED_region_tag_redraw(region);
}
@@ -2042,7 +1995,7 @@ static void ui_panel_drag_collapse(const bContext *C,
float xy_b_block[2] = {UNPACK2(xy_dst)};
Panel *panel = block->panel;
- if (panel == NULL || (panel->type && (panel->type->flag & PNL_NO_HEADER))) {
+ if (panel == NULL || (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER))) {
continue;
}
const int oldflag = panel->flag;
@@ -2135,9 +2088,9 @@ static void ui_panel_drag_collapse_handler_add(const bContext *C, const bool was
* \param mx: The mouse x coordinate, in panel space.
*/
static void ui_handle_panel_header(const bContext *C,
- uiBlock *block,
+ const uiBlock *block,
const int mx,
- short int event_type,
+ const int event_type,
const short ctrl,
const short shift)
{
@@ -2145,7 +2098,7 @@ static void ui_handle_panel_header(const bContext *C,
ARegion *region = CTX_wm_region(C);
BLI_assert(panel->type != NULL);
- BLI_assert(!(panel->type->flag & PNL_NO_HEADER));
+ BLI_assert(!(panel->type->flag & PANEL_TYPE_NO_HEADER));
const bool is_subpanel = (panel->type->parent != NULL);
const bool use_pin = UI_panel_category_is_visible(region) && !is_subpanel;
@@ -2187,27 +2140,10 @@ static void ui_handle_panel_header(const bContext *C,
}
}
- 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) {
- panel->ofsy = 0;
- }
+ SET_FLAG_FROM_TEST(panel->flag, !UI_panel_is_closed(panel), PNL_CLOSED);
- if (event_type == LEFTMOUSE) {
- ui_panel_drag_collapse_handler_add(C, false);
- }
- }
- else {
- /* Snap down to bottom screen edge. */
- panel->flag |= PNL_CLOSED;
- if (panel->snap & PNL_SNAP_BOTTOM) {
- panel->ofsy = -panel->sizey;
- }
-
- if (event_type == LEFTMOUSE) {
- ui_panel_drag_collapse_handler_add(C, true);
- }
+ if (event_type == LEFTMOUSE) {
+ ui_panel_drag_collapse_handler_add(C, UI_panel_is_closed(panel));
}
set_panels_list_data_expand_flag(C, region);
@@ -2244,7 +2180,7 @@ bool UI_panel_category_is_visible(const ARegion *region)
region->panels_category.first != region->panels_category.last;
}
-PanelCategoryDyn *UI_panel_category_find(ARegion *region, const char *idname)
+PanelCategoryDyn *UI_panel_category_find(const ARegion *region, const char *idname)
{
return BLI_findstring(&region->panels_category, idname, offsetof(PanelCategoryDyn, idname));
}
@@ -2325,10 +2261,10 @@ const char *UI_panel_category_active_get(ARegion *region, bool set_fallback)
return NULL;
}
-PanelCategoryDyn *UI_panel_category_find_mouse_over_ex(ARegion *region, const int x, const int y)
+static PanelCategoryDyn *panel_categories_find_mouse_over(ARegion *region, const wmEvent *event)
{
LISTBASE_FOREACH (PanelCategoryDyn *, ptd, &region->panels_category) {
- if (BLI_rcti_isect_pt(&ptd->rect, x, y)) {
+ if (BLI_rcti_isect_pt(&ptd->rect, event->mval[0], event->mval[1])) {
return ptd;
}
}
@@ -2336,11 +2272,6 @@ PanelCategoryDyn *UI_panel_category_find_mouse_over_ex(ARegion *region, const in
return NULL;
}
-PanelCategoryDyn *UI_panel_category_find_mouse_over(ARegion *region, const wmEvent *event)
-{
- return UI_panel_category_find_mouse_over_ex(region, event->mval[0], event->mval[1]);
-}
-
void UI_panel_category_add(ARegion *region, const char *name)
{
PanelCategoryDyn *pc_dyn = MEM_callocN(sizeof(*pc_dyn), __func__);
@@ -2436,7 +2367,7 @@ int ui_handler_panel_region(bContext *C,
/* Handle category tabs. */
if (UI_panel_category_is_visible(region)) {
if (event->type == LEFTMOUSE) {
- PanelCategoryDyn *pc_dyn = UI_panel_category_find_mouse_over(region, event);
+ PanelCategoryDyn *pc_dyn = panel_categories_find_mouse_over(region, event);
if (pc_dyn) {
UI_panel_category_active_set(region, pc_dyn->idname);
ED_region_tag_redraw(region);
@@ -2466,7 +2397,7 @@ int ui_handler_panel_region(bContext *C,
continue;
}
/* We can't expand or collapse panels without headers, they would disappear. */
- if (panel->type->flag & PNL_NO_HEADER) {
+ if (panel->type->flag & PANEL_TYPE_NO_HEADER) {
continue;
}
@@ -2617,89 +2548,80 @@ static void ui_handler_remove_panel(bContext *C, void *userdata)
panel_activate_state(C, panel, PANEL_STATE_EXIT);
}
-static void panel_activate_state(const bContext *C, Panel *panel, uiHandlePanelState state)
+static void panel_handle_data_ensure(const bContext *C,
+ wmWindow *win,
+ const ARegion *region,
+ Panel *panel,
+ const uiHandlePanelState state)
+{
+ if (panel->activedata == NULL) {
+ panel->activedata = MEM_callocN(sizeof(uiHandlePanelData), __func__);
+ WM_event_add_ui_handler(
+ C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, panel, 0);
+ }
+
+ uiHandlePanelData *data = panel->activedata;
+
+ data->animtimer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, ANIMATION_INTERVAL);
+
+ data->state = state;
+ data->startx = win->eventstate->x;
+ data->starty = win->eventstate->y;
+ data->startofsx = panel->ofsx;
+ data->startofsy = panel->ofsy;
+ data->start_cur_xmin = region->v2d.cur.xmin;
+ data->start_cur_ymin = region->v2d.cur.ymin;
+ data->starttime = PIL_check_seconds_timer();
+}
+
+/**
+ * \note "select" and "drag drop" flags: First, the panel is "picked up" and both flags are set.
+ * Then when the mouse releases and the panel starts animating to its aligned position, PNL_SELECT
+ * is unset. When the animation finishes, PANEL_IS_DRAG_DROP is cleared.
+ */
+static void panel_activate_state(const bContext *C, Panel *panel, const uiHandlePanelState state)
{
uiHandlePanelData *data = panel->activedata;
wmWindow *win = CTX_wm_window(C);
ARegion *region = CTX_wm_region(C);
- if (data && data->state == state) {
+ if (data != NULL && data->state == state) {
return;
}
- const bool was_drag_drop = (data && data->state == PANEL_STATE_DRAG);
-
- /* Set selection state for the panel and its sub-panels, which need to know they are selected
- * too so they can be drawn above their parent when it's dragged. */
- if (state == PANEL_STATE_EXIT || state == PANEL_STATE_ANIMATION) {
- panel_set_flag_recursive(panel, PNL_SELECT, false);
- }
- else {
+ if (state == PANEL_STATE_DRAG) {
panel_set_flag_recursive(panel, PNL_SELECT, true);
- }
+ panel_set_runtime_flag_recursive(panel, PANEL_IS_DRAG_DROP, true);
- if (data && data->animtimer) {
- WM_event_remove_timer(CTX_wm_manager(C), win, data->animtimer);
- data->animtimer = NULL;
- }
+ panel_handle_data_ensure(C, win, region, panel, state);
- if (state == PANEL_STATE_EXIT) {
- MEM_freeN(data);
- panel->activedata = NULL;
-
- WM_event_remove_ui_handler(
- &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, panel, false);
+ /* Initiate edge panning during drags for scrolling beyond the initial region view. */
+ wmOperatorType *ot = WM_operatortype_find("VIEW2D_OT_edge_pan", true);
+ ui_handle_afterfunc_add_operator(ot, WM_OP_INVOKE_DEFAULT, true);
}
- else {
- if (!data) {
- data = MEM_callocN(sizeof(uiHandlePanelData), "uiHandlePanelData");
- panel->activedata = data;
+ else if (state == PANEL_STATE_ANIMATION) {
+ panel_set_flag_recursive(panel, PNL_SELECT, false);
- WM_event_add_ui_handler(
- C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, panel, 0);
- }
+ panel_handle_data_ensure(C, win, region, panel, state);
+ }
+ else if (state == PANEL_STATE_EXIT) {
+ panel_set_runtime_flag_recursive(panel, PANEL_IS_DRAG_DROP, false);
- if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG)) {
- data->animtimer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, ANIMATION_INTERVAL);
- }
+ BLI_assert(data != NULL);
- /* Initiate edge panning during drags so we can move beyond the initial region view. */
- if (state == PANEL_STATE_DRAG) {
- wmOperatorType *ot = WM_operatortype_find("VIEW2D_OT_edge_pan", true);
- ui_handle_afterfunc_add_operator(ot, WM_OP_INVOKE_DEFAULT, true);
+ if (data->animtimer) {
+ WM_event_remove_timer(CTX_wm_manager(C), win, data->animtimer);
+ data->animtimer = NULL;
}
- data->state = state;
- data->startx = win->eventstate->x;
- data->starty = win->eventstate->y;
- data->startofsx = panel->ofsx;
- data->startofsy = panel->ofsy;
- data->startsizex = panel->sizex;
- data->startsizey = panel->sizey;
- data->start_cur_xmin = region->v2d.cur.xmin;
- data->start_cur_ymin = region->v2d.cur.ymin;
- data->starttime = PIL_check_seconds_timer();
+ MEM_freeN(data);
+ panel->activedata = NULL;
- /* Remember drag drop state even when animating to the aligned position after dragging. */
- data->is_drag_drop = was_drag_drop;
- if (state == PANEL_STATE_DRAG) {
- data->is_drag_drop = true;
- }
+ WM_event_remove_ui_handler(
+ &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, panel, false);
}
ED_region_tag_redraw(region);
}
-PanelType *UI_paneltype_find(int space_id, int region_id, const char *idname)
-{
- SpaceType *st = BKE_spacetype_from_id(space_id);
- if (st) {
- ARegionType *art = BKE_regiontype_from_id(st, region_id);
- if (art) {
- return BLI_findstring(&art->paneltypes, idname, offsetof(PanelType, idname));
- }
- }
- return NULL;
-}
-
/** \} */
diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c
index cecfe6941fc..b50daa0df21 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.c
@@ -146,7 +146,7 @@ static void hud_panels_register(ARegionType *art, int space_type, int region_typ
pt->poll = hud_panel_operator_redo_poll;
pt->space_type = space_type;
pt->region_type = region_type;
- pt->flag |= PNL_DEFAULT_CLOSED;
+ pt->flag |= PANEL_TYPE_DEFAULT_CLOSED;
BLI_addtail(&art->paneltypes, pt);
}
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index 5c3f00201a2..12f3ba609f0 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -800,7 +800,7 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but)
.style = UI_TIP_STYLE_HEADER,
.color_id = UI_TIP_LC_NORMAL,
});
- field->text = BLI_sprintfN("%s.", but_label.strinfo);
+ field->text = BLI_sprintfN("%s", but_label.strinfo);
}
/* Tip */
diff --git a/source/blender/editors/interface/interface_template_search_menu.c b/source/blender/editors/interface/interface_template_search_menu.c
index 14f97cb14a9..5c778043381 100644
--- a/source/blender/editors/interface/interface_template_search_menu.c
+++ b/source/blender/editors/interface/interface_template_search_menu.c
@@ -429,8 +429,8 @@ static void menu_items_from_all_operators(bContext *C, struct MenuSearch_Data *d
/**
* Create #MenuSearch_Data by inspecting the current context, this uses two methods:
*
- * - Look-up pre-defined editor-menus.
- * - Look-up key-map items which call menus.
+ * - Look up predefined editor-menus.
+ * - Look up key-map items which call menus.
*/
static struct MenuSearch_Data *menu_items_from_ui_create(
bContext *C, wmWindow *win, ScrArea *area_init, ARegion *region_init, bool include_all_areas)
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index d4d24b3e3c2..43ead511cfe 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1931,7 +1931,7 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C)
}
/* Move to the next instanced panel corresponding to the next modifier. */
- while ((panel->type == NULL) || !(panel->type->flag & PNL_INSTANCED)) {
+ while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
panel = panel->next;
BLI_assert(panel != NULL); /* There shouldn't be fewer panels than modifiers with UIs. */
}
@@ -2096,7 +2096,7 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
}
/* Move to the next instanced panel corresponding to the next constraint. */
- while ((panel->type == NULL) || !(panel->type->flag & PNL_INSTANCED)) {
+ while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
panel = panel->next;
BLI_assert(panel != NULL); /* There shouldn't be fewer panels than constraint panels. */
}
@@ -2166,7 +2166,7 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C)
}
/* Move to the next instanced panel corresponding to the next modifier. */
- while ((panel->type == NULL) || !(panel->type->flag & PNL_INSTANCED)) {
+ while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
panel = panel->next;
BLI_assert(panel != NULL); /* There shouldn't be fewer panels than modifiers with UIs. */
}
@@ -2237,7 +2237,7 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C)
}
/* Move to the next instanced panel corresponding to the next modifier. */
- while ((panel->type == NULL) || !(panel->type->flag & PNL_INSTANCED)) {
+ while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
panel = panel->next;
BLI_assert(panel != NULL); /* There shouldn't be fewer panels than modifiers with UIs. */
}
@@ -3304,7 +3304,6 @@ static void colorband_buttons_layout(uiLayout *layout,
row = uiLayoutRow(split, false);
uiItemR(row, &ptr, "position", 0, IFACE_("Pos"), ICON_NONE);
bt = block->buttons.last;
- bt->a1 = 1.0f; /* gives a bit more precision for modifying position */
UI_but_func_set(bt, colorband_update_cb, bt, coba);
row = uiLayoutRow(layout, false);
@@ -3336,7 +3335,6 @@ static void colorband_buttons_layout(uiLayout *layout,
row = uiLayoutRow(subsplit, false);
uiItemR(row, &ptr, "position", UI_ITEM_R_SLIDER, IFACE_("Pos"), ICON_NONE);
bt = block->buttons.last;
- bt->a1 = 1.0f; /* gives a bit more precision for modifying position */
UI_but_func_set(bt, colorband_update_cb, bt, coba);
row = uiLayoutRow(split, false);
@@ -4971,7 +4969,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
selection_y = &point->h2_loc[1];
}
}
- if (i == 0 || i == profile->path_len - 1) {
+ if (ELEM(i, 0, profile->path_len - 1)) {
point_last_or_first = true;
}
@@ -5330,7 +5328,7 @@ static void ui_template_palette_menu(bContext *UNUSED(C), uiLayout *layout, void
{
uiLayout *row;
- uiItemL(layout, IFACE_("Sort by:"), ICON_NONE);
+ uiItemL(layout, IFACE_("Sort By:"), ICON_NONE);
row = uiLayoutRow(layout, false);
uiItemEnumO_value(row, IFACE_("Hue"), ICON_NONE, "PALETTE_OT_sort", "type", 1);
row = uiLayoutRow(layout, false);
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 6bc644ce5b5..958a0bc03cd 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -645,10 +645,10 @@ bool UI_but_online_manual_id_from_active(const struct bContext *C, char *r_str,
}
/* -------------------------------------------------------------------- */
-/* Modal Button Store API */
-
/** \name Button Store
*
+ * Modal Button Store API.
+ *
* Store for modal operators & handlers to register button pointers
* which are maintained while drawing or NULL when removed.
*
@@ -792,7 +792,7 @@ void UI_butstore_update(uiBlock *block)
/* warning, loop-in-loop, in practice we only store <10 buttons at a time,
* so this isn't going to be a problem, if that changes old-new mapping can be cached first */
LISTBASE_FOREACH (uiButStore *, bs_handle, &block->butstore) {
- BLI_assert((bs_handle->block == NULL) || (bs_handle->block == block) ||
+ BLI_assert(ELEM(bs_handle->block, NULL, block) ||
(block->oldblock && block->oldblock == bs_handle->block));
if (bs_handle->block == block->oldblock) {
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 49760b99d2e..e2c835ac461 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -548,6 +548,24 @@ void UI_draw_anti_tria(
GPU_blend(GPU_BLEND_NONE);
}
+/* Triangle 'icon' for panel header and other cases. */
+void UI_draw_icon_tri(float x, float y, char dir, const float color[4])
+{
+ const float f3 = 0.05 * U.widget_unit;
+ const float f5 = 0.15 * U.widget_unit;
+ const float f7 = 0.25 * U.widget_unit;
+
+ if (dir == 'h') {
+ UI_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y, color);
+ }
+ else if (dir == 't') {
+ UI_draw_anti_tria(x - f5, y - f7, x + f5, y - f7, x, y + f3, color);
+ }
+ else { /* 'v' = vertical, down. */
+ UI_draw_anti_tria(x - f5, y + f3, x + f5, y + f3, x, y - f7, color);
+ }
+}
+
/* triangle 'icon' inside rect */
void ui_draw_anti_tria_rect(const rctf *rect, char dir, const float color[4])
{
@@ -899,7 +917,7 @@ static void shape_preset_init_trias_ex(uiWidgetTrias *tria,
float centx, centy, sizex, sizey, minsize;
int a, i1 = 0, i2 = 1;
- if (where == 'r' || where == 'l') {
+ if (ELEM(where, 'r', 'l')) {
minsize = BLI_rcti_size_y(rect);
}
else {
@@ -2426,19 +2444,23 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
}
}
else if (but->drawflag & UI_BUT_TEXT_LEFT) {
-
- /* Reduce the left padding for labels without an icon. */
- if ((but->type == UI_BTYPE_LABEL) && !(but->flag & UI_HAS_ICON) &&
- !ui_block_is_menu(but->block)) {
- text_padding /= 2;
- }
-
rect->xmin += text_padding;
}
else if (but->drawflag & UI_BUT_TEXT_RIGHT) {
rect->xmax -= text_padding;
}
}
+ else {
+ /* In case a separate text label and some other button are placed under each other,
+ and the outline of the button does not contrast with the background.
+ Add an offset (thickness of the outline) so that the text does not stick out visually. */
+ if (but->drawflag & UI_BUT_TEXT_LEFT) {
+ rect->xmin += U.pixelsize;
+ }
+ else if (but->drawflag & UI_BUT_TEXT_RIGHT) {
+ rect->xmax -= U.pixelsize;
+ }
+ }
/* Menu contains sub-menu items with triangle icon on their right. Shortcut
* strings should be drawn with some padding to the right then. */
@@ -4053,7 +4075,7 @@ static void widget_optionbut(uiWidgetColors *wcol,
}
/* smaller */
- delta = 1 + BLI_rcti_size_y(&recttemp) / 8;
+ delta = (BLI_rcti_size_y(&recttemp) - 2 * U.pixelsize) / 6;
BLI_rcti_resize(
&recttemp, BLI_rcti_size_x(&recttemp) - delta * 2, BLI_rcti_size_y(&recttemp) - delta * 2);
/* Keep one edge in place. */
@@ -4575,6 +4597,9 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
wt->wcol_theme = &tui->wcol_menu_back;
wt->state = widget_state;
}
+ if (!(but->flag & UI_HAS_ICON)) {
+ but->drawflag |= UI_BUT_NO_TEXT_PADDING;
+ }
break;
case UI_BTYPE_SEPR:
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 258516a1c61..a5999962e09 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -293,7 +293,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
#endif
default:
- if (event->type == vpd->invoke_event || event->type == EVT_ESCKEY) {
+ if (ELEM(event->type, vpd->invoke_event, EVT_ESCKEY)) {
if (event->val == KM_RELEASE) {
/* calculate overall delta mouse-movement for redo */
RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx));
@@ -1241,7 +1241,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
vzd->zoom_to_mouse_pos = true;
}
- if (event->type == MOUSEZOOM || event->type == MOUSEPAN) {
+ if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) {
float dx, dy, fac;
vzd->lastx = event->prevx;
@@ -1413,7 +1413,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
/* apply zooming */
view_zoomdrag_apply(C, op);
}
- else if (event->type == vzd->invoke_event || event->type == EVT_ESCKEY) {
+ else if (ELEM(event->type, vzd->invoke_event, EVT_ESCKEY)) {
if (event->val == KM_RELEASE) {
/* for redo, store the overall deltas - need to respect zoom-locks here... */
diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c
index 292d8e6066c..70125ff35fc 100644
--- a/source/blender/editors/io/io_alembic.c
+++ b/source/blender/editors/io/io_alembic.c
@@ -292,7 +292,7 @@ void WM_OT_alembic_export(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_int(ot->srna,
"start",
@@ -677,7 +677,7 @@ void WM_OT_alembic_import(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_SHOW_PROPS,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_float(
ot->srna,
diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c
index 045a293f71b..b73b8abccfe 100644
--- a/source/blender/editors/io/io_cache.c
+++ b/source/blender/editors/io/io_cache.c
@@ -134,7 +134,7 @@ void CACHEFILE_OT_open(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/* ***************************** Reload Operator **************************** */
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index 54ef5e6b8c5..af505043e6a 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -507,7 +507,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_enum(func,
"prop_bc_export_ui_section",
@@ -828,7 +828,7 @@ void WM_OT_collada_import(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_boolean(ot->srna,
"import_units",
diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c
index 45ea52bdebc..0eadb38abb5 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -185,7 +185,7 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_boolean(ot->srna,
"selected_objects_only",
diff --git a/source/blender/editors/lattice/CMakeLists.txt b/source/blender/editors/lattice/CMakeLists.txt
index f9c08727128..96f0dfcdb9f 100644
--- a/source/blender/editors/lattice/CMakeLists.txt
+++ b/source/blender/editors/lattice/CMakeLists.txt
@@ -22,7 +22,7 @@ set(INC
../../depsgraph
../../makesdna
../../makesrna
- ../../render/extern/include
+ ../../render
../../windowmanager
../../../../intern/clog
../../../../intern/guardedalloc
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 62f46c93bc7..d7b3d74bc7e 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -202,7 +202,7 @@ static void finSelectedSplinePoint(MaskLayer *mask_layer,
MaskSplinePoint *cur_point = &cur_spline->points[i];
if (MASKPOINT_ISSEL_ANY(cur_point)) {
- if (*spline != NULL && *spline != cur_spline) {
+ if (!ELEM(*spline, NULL, cur_spline)) {
*spline = NULL;
*point = NULL;
return;
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 8acbb328ab0..c757b6f0cc3 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -111,7 +111,7 @@ static void draw_single_handle(const MaskLayer *mask_layer,
const BezTriple *bezt = &point->bezt;
char handle_type;
- if (which_handle == MASK_WHICH_HANDLE_STICK || which_handle == MASK_WHICH_HANDLE_LEFT) {
+ if (ELEM(which_handle, MASK_WHICH_HANDLE_STICK, MASK_WHICH_HANDLE_LEFT)) {
handle_type = bezt->h1;
}
else {
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index 035af772a55..35bf295a678 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -28,7 +28,7 @@ set(INC
../../imbuf
../../makesdna
../../makesrna
- ../../render/extern/include
+ ../../render
../../windowmanager
../../../../intern/clog
../../../../intern/glew-mx
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index a90d6530453..b8badd207fe 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -127,15 +127,10 @@ enum {
static float get_bevel_offset(wmOperator *op)
{
- float val;
-
if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) {
- val = RNA_float_get(op->ptr, "offset_pct");
- }
- else {
- val = RNA_float_get(op->ptr, "offset");
+ return RNA_float_get(op->ptr, "offset_pct");
}
- return val;
+ return RNA_float_get(op->ptr, "offset");
}
static void edbm_bevel_update_status_text(bContext *C, wmOperator *op)
@@ -145,14 +140,12 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op)
char *p = buf;
int available_len = sizeof(buf);
Scene *sce = CTX_data_scene(C);
- char offset_str[NUM_STR_REP_LEN];
- const char *mode_str, *omiter_str, *imiter_str, *vmesh_str, *profile_type_str, *affect_str;
- PropertyRNA *prop;
#define WM_MODALKEY(_id) \
WM_modalkeymap_operator_items_to_string_buf( \
op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p)
+ char offset_str[NUM_STR_REP_LEN];
if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) {
BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%.1f%%", RNA_float_get(op->ptr, "offset_pct"));
}
@@ -167,6 +160,8 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op)
true);
}
+ PropertyRNA *prop;
+ const char *mode_str, *omiter_str, *imiter_str, *vmesh_str, *profile_type_str, *affect_str;
prop = RNA_struct_find_property(op->ptr, "offset_type");
RNA_property_enum_name_gettexted(
C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &mode_str);
@@ -240,18 +235,17 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op)
static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
{
Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- BevelData *opdata;
ViewLayer *view_layer = CTX_data_view_layer(C);
- float pixels_per_inch;
- int i, otype;
if (is_modal) {
RNA_float_set(op->ptr, "offset", 0.0f);
RNA_float_set(op->ptr, "offset_pct", 0.0f);
}
- op->customdata = opdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator");
+ op->customdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator");
+ BevelData *opdata = op->customdata;
uint objects_used_len = 0;
opdata->max_obj_scale = FLT_MIN;
@@ -261,7 +255,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
{
uint ob_store_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
- view_layer, CTX_wm_view3d(C), &ob_store_len);
+ view_layer, v3d, &ob_store_len);
opdata->ob_store = MEM_malloc_arrayN(ob_store_len, sizeof(*opdata->ob_store), __func__);
for (uint ob_index = 0; ob_index < ob_store_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -278,12 +272,12 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
}
opdata->is_modal = is_modal;
- otype = RNA_enum_get(op->ptr, "offset_type");
+ int otype = RNA_enum_get(op->ptr, "offset_type");
opdata->value_mode = (otype == BEVEL_AMT_PERCENT) ? OFFSET_VALUE_PERCENT : OFFSET_VALUE;
opdata->segments = (float)RNA_int_get(op->ptr, "segments");
- pixels_per_inch = U.dpi * U.pixelsize;
+ float pixels_per_inch = U.dpi * U.pixelsize;
- for (i = 0; i < NUM_VALUE_KINDS; i++) {
+ for (int i = 0; i < NUM_VALUE_KINDS; i++) {
opdata->shift_value[i] = -1.0f;
opdata->initial_length[i] = -1.0f;
/* note: scale for OFFSET_VALUE will get overwritten in edbm_bevel_invoke */
@@ -304,7 +298,6 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
/* avoid the cost of allocating a bm copy */
if (is_modal) {
- View3D *v3d = CTX_wm_view3d(C);
ARegion *region = CTX_wm_region(C);
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
@@ -491,23 +484,21 @@ static int edbm_bevel_exec(bContext *C, wmOperator *op)
static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event, bool mode_changed)
{
- BevelData *opdata;
- float mlen[2], len, value, sc, st;
- int vmode;
-
- opdata = op->customdata;
- mlen[0] = opdata->mcenter[0] - event->mval[0];
- mlen[1] = opdata->mcenter[1] - event->mval[1];
- len = len_v2(mlen);
- vmode = opdata->value_mode;
+ BevelData *opdata = op->customdata;
+ const float mlen[2] = {
+ opdata->mcenter[0] - event->mval[0],
+ opdata->mcenter[1] - event->mval[1],
+ };
+ float len = len_v2(mlen);
+ int vmode = opdata->value_mode;
if (mode_changed || opdata->initial_length[vmode] == -1.0f) {
/* If current value is not default start value, adjust len so that
* the scaling and offset in edbm_bevel_mouse_set_value will
* start at current value */
- value = (vmode == SEGMENTS_VALUE) ? opdata->segments :
- RNA_float_get(op->ptr, value_rna_name[vmode]);
- sc = opdata->scale[vmode];
- st = value_start[vmode];
+ float value = (vmode == SEGMENTS_VALUE) ? opdata->segments :
+ RNA_float_get(op->ptr, value_rna_name[vmode]);
+ float sc = opdata->scale[vmode];
+ float st = value_start[vmode];
if (value != value_start[vmode]) {
len = (st + sc * (len - MVAL_PIXEL_MARGIN) - value) / sc;
}
@@ -518,18 +509,17 @@ static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event,
static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
- BevelData *opdata;
- float center_3d[3];
if (!edbm_bevel_init(C, op, true)) {
return OPERATOR_CANCELLED;
}
- opdata = op->customdata;
+ BevelData *opdata = op->customdata;
opdata->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
/* initialize mouse values */
+ float center_3d[3];
if (!calculateTransformCenter(C, V3D_AROUND_CENTER_MEDIAN, center_3d, opdata->mcenter)) {
/* in this case the tool will likely do nothing,
* ideally this will never happen and should be checked for above */
@@ -561,13 +551,13 @@ static void edbm_bevel_mouse_set_value(wmOperator *op, const wmEvent *event)
{
BevelData *opdata = op->customdata;
int vmode = opdata->value_mode;
- float mdiff[2];
- float value;
- mdiff[0] = opdata->mcenter[0] - event->mval[0];
- mdiff[1] = opdata->mcenter[1] - event->mval[1];
+ const float mdiff[2] = {
+ opdata->mcenter[0] - event->mval[0],
+ opdata->mcenter[1] - event->mval[1],
+ };
- value = ((len_v2(mdiff) - MVAL_PIXEL_MARGIN) - opdata->initial_length[vmode]);
+ float value = ((len_v2(mdiff) - MVAL_PIXEL_MARGIN) - opdata->initial_length[vmode]);
/* Scale according to value mode */
value = value_start[vmode] + value * opdata->scale[vmode];
@@ -599,12 +589,10 @@ static void edbm_bevel_mouse_set_value(wmOperator *op, const wmEvent *event)
static void edbm_bevel_numinput_set_value(wmOperator *op)
{
BevelData *opdata = op->customdata;
- float value;
- int vmode;
- vmode = opdata->value_mode;
- value = (vmode == SEGMENTS_VALUE) ? opdata->segments :
- RNA_float_get(op->ptr, value_rna_name[vmode]);
+ int vmode = opdata->value_mode;
+ float value = (vmode == SEGMENTS_VALUE) ? opdata->segments :
+ RNA_float_get(op->ptr, value_rna_name[vmode]);
applyNumInput(&opdata->num_input[vmode], &value);
CLAMP(value, value_clamp_min[vmode], value_clamp_max[vmode]);
if (vmode == SEGMENTS_VALUE) {
@@ -616,82 +604,61 @@ static void edbm_bevel_numinput_set_value(wmOperator *op)
}
}
-/* Hide one of offset or offset_pct, depending on offset_type */
-static bool edbm_bevel_poll_property(const bContext *UNUSED(C),
- wmOperator *op,
- const PropertyRNA *prop)
-{
- const char *prop_id = RNA_property_identifier(prop);
-
- if (STRPREFIX(prop_id, "offset")) {
- int offset_type = RNA_enum_get(op->ptr, "offset_type");
-
- if (STREQ(prop_id, "offset") && offset_type == BEVEL_AMT_PERCENT) {
- return false;
- }
- if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT) {
- return false;
- }
- }
-
- return true;
-}
-
wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
{BEV_MODAL_CANCEL, "CANCEL", 0, "Cancel", "Cancel bevel"},
{BEV_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", "Confirm bevel"},
- {BEV_MODAL_VALUE_OFFSET, "VALUE_OFFSET", 0, "Change offset", "Value changes offset"},
- {BEV_MODAL_VALUE_PROFILE, "VALUE_PROFILE", 0, "Change profile", "Value changes profile"},
- {BEV_MODAL_VALUE_SEGMENTS, "VALUE_SEGMENTS", 0, "Change segments", "Value changes segments"},
- {BEV_MODAL_SEGMENTS_UP, "SEGMENTS_UP", 0, "Increase segments", "Increase segments"},
- {BEV_MODAL_SEGMENTS_DOWN, "SEGMENTS_DOWN", 0, "Decrease segments", "Decrease segments"},
+ {BEV_MODAL_VALUE_OFFSET, "VALUE_OFFSET", 0, "Change Offset", "Value changes offset"},
+ {BEV_MODAL_VALUE_PROFILE, "VALUE_PROFILE", 0, "Change Profile", "Value changes profile"},
+ {BEV_MODAL_VALUE_SEGMENTS, "VALUE_SEGMENTS", 0, "Change Segments", "Value changes segments"},
+ {BEV_MODAL_SEGMENTS_UP, "SEGMENTS_UP", 0, "Increase Segments", "Increase segments"},
+ {BEV_MODAL_SEGMENTS_DOWN, "SEGMENTS_DOWN", 0, "Decrease Segments", "Decrease segments"},
{BEV_MODAL_OFFSET_MODE_CHANGE,
"OFFSET_MODE_CHANGE",
0,
- "Change offset mode",
+ "Change Offset Mode",
"Cycle through offset modes"},
{BEV_MODAL_CLAMP_OVERLAP_TOGGLE,
"CLAMP_OVERLAP_TOGGLE",
0,
- "Toggle clamp overlap",
+ "Toggle Clamp Overlap",
"Toggle clamp overlap flag"},
{BEV_MODAL_AFFECT_CHANGE,
"AFFECT_CHANGE",
0,
- "Change affect type",
+ "Change Affect Type",
"Change which geometry type the operation affects, edges or vertices"},
{BEV_MODAL_HARDEN_NORMALS_TOGGLE,
"HARDEN_NORMALS_TOGGLE",
0,
- "Toggle harden normals",
+ "Toggle Harden Normals",
"Toggle harden normals flag"},
{BEV_MODAL_MARK_SEAM_TOGGLE,
"MARK_SEAM_TOGGLE",
0,
- "Toggle mark seam",
+ "Toggle Mark Seam",
"Toggle mark seam flag"},
{BEV_MODAL_MARK_SHARP_TOGGLE,
"MARK_SHARP_TOGGLE",
0,
- "Toggle mark sharp",
+ "Toggle Mark Sharp",
"Toggle mark sharp flag"},
{BEV_MODAL_OUTER_MITER_CHANGE,
"OUTER_MITER_CHANGE",
0,
- "Change outer miter",
+ "Change Outer Miter",
"Cycle through outer miter kinds"},
{BEV_MODAL_INNER_MITER_CHANGE,
"INNER_MITER_CHANGE",
0,
- "Change inner miter",
+ "Change Inner Miter",
"Cycle through inner miter kinds"},
{BEV_MODAL_PROFILE_TYPE_CHANGE, "PROFILE_TYPE_CHANGE", 0, "Cycle through profile types", ""},
{BEV_MODAL_VERTEX_MESH_CHANGE,
"VERTEX_MESH_CHANGE",
0,
- "Change intersection method",
+ "Change Intersection Method",
"Cycle through intersection methods"},
{0, NULL, 0, NULL, NULL},
};
@@ -1109,7 +1076,6 @@ void MESH_OT_bevel(wmOperatorType *ot)
ot->modal = edbm_bevel_modal;
ot->cancel = edbm_bevel_cancel;
ot->poll = ED_operator_editmesh;
- ot->poll_property = edbm_bevel_poll_property;
ot->ui = edbm_bevel_ui;
/* flags */
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c
index 6dde45a4f5f..7b3fabf07fc 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin.c
@@ -24,6 +24,7 @@
#include "DNA_object_types.h"
#include "BLI_math.h"
+#include "BLI_string.h"
#include "BKE_context.h"
#include "BKE_editmesh.h"
@@ -172,7 +173,7 @@ static bool edbm_spin_poll_property(const bContext *UNUSED(C),
const bool dupli = RNA_boolean_get(op->ptr, "dupli");
if (dupli) {
- if (STREQ(prop_id, "use_auto_merge") || STREQ(prop_id, "use_normal_flip")) {
+ if (STR_ELEM(prop_id, "use_auto_merge", "use_normal_flip")) {
return false;
}
}
diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c
index 2083c52b885..ff4867454d6 100644
--- a/source/blender/editors/mesh/editmesh_intersect.c
+++ b/source/blender/editors/mesh/editmesh_intersect.c
@@ -121,11 +121,10 @@ static void edbm_intersect_select(BMEditMesh *em, struct Mesh *me, bool do_selec
}
/* -------------------------------------------------------------------- */
-/* Cut intersections into geometry */
-
/** \name Simple Intersect (self-intersect)
- * \{
- */
+ *
+ * Cut intersections into geometry.
+ * \{ */
enum {
ISECT_SEL = 0,
@@ -338,15 +337,11 @@ void MESH_OT_intersect(struct wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/* Boolean (a kind of intersect) */
-
/** \name Boolean Intersect
*
* \note internally this is nearly exactly the same as 'MESH_OT_intersect',
* however from a user perspective they are quite different, so expose as different tools.
- *
- * \{
- */
+ * \{ */
static int edbm_intersect_boolean_exec(bContext *C, wmOperator *op)
{
@@ -495,9 +490,7 @@ void MESH_OT_intersect_boolean(struct wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/* Face Split by Edges */
-
-/** \name Face/Edge Split
+/** \name Face Split by Edges
* \{ */
static void bm_face_split_by_edges(BMesh *bm,
diff --git a/source/blender/editors/mesh/editmesh_preselect_edgering.c b/source/blender/editors/mesh/editmesh_preselect_edgering.c
index aa1df3d76fc..43e36957dc9 100644
--- a/source/blender/editors/mesh/editmesh_preselect_edgering.c
+++ b/source/blender/editors/mesh/editmesh_preselect_edgering.c
@@ -110,7 +110,7 @@ static void edgering_find_order(BMEdge *eed_last, BMEdge *eed, BMVert *eve_last,
BMLoop *l_other = BM_loop_other_edge_loop(l, eed->v1);
const bool rev = (l_other == l->prev);
- while (l_other->v != eed_last->v1 && l_other->v != eed_last->v2) {
+ while (!ELEM(l_other->v, eed_last->v1, eed_last->v2)) {
l_other = rev ? l_other->prev : l_other->next;
}
diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c
index f94d3ba5a70..00349983c57 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -83,7 +83,7 @@ static const EnumPropertyItem prop_similar_types[] = {
{SIMFACE_SIDES, "SIDES", 0, "Polygon Sides", ""},
{SIMFACE_PERIMETER, "PERIMETER", 0, "Perimeter", ""},
{SIMFACE_NORMAL, "NORMAL", 0, "Normal", ""},
- {SIMFACE_COPLANAR, "COPLANAR", 0, "Co-planar", ""},
+ {SIMFACE_COPLANAR, "COPLANAR", 0, "Coplanar", ""},
{SIMFACE_SMOOTH, "SMOOTH", 0, "Flat/Smooth", ""},
{SIMFACE_FACEMAP, "FACE_MAP", 0, "Face-Map", ""},
#ifdef WITH_FREESTYLE
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 85cc19e7471..b961f81e16a 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -75,7 +75,7 @@
#include "ED_uvedit.h"
#include "ED_view3d.h"
-#include "RE_render_ext.h"
+#include "RE_texture.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -875,7 +875,7 @@ static void edbm_add_edge_face_exec__tricky_finalize_sel(BMesh *bm, BMElem *ele_
}
else {
BMLoop *l = BM_face_edge_share_loop(f, (BMEdge *)ele_desel);
- BLI_assert(f->len == 4 || f->len == 3);
+ BLI_assert(ELEM(f->len, 4, 3));
BM_edge_select_set(bm, (BMEdge *)ele_desel, false);
if (f->len == 4) {
@@ -4082,7 +4082,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
isect = bm_edge_seg_isect(sco_a, sco_b, mouse_path, len, mode, &isected);
if (isect != 0.0f) {
- if (mode != KNIFE_MULTICUT && mode != KNIFE_MIDPOINT) {
+ if (!ELEM(mode, KNIFE_MULTICUT, KNIFE_MIDPOINT)) {
BMO_slot_map_float_insert(&bmop, slot_edge_percents, be, isect);
}
}
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index 41d840c4a2d..43cad2db185 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -118,6 +118,7 @@ typedef struct UndoMesh {
#ifdef USE_ARRAY_STORE
+/* -------------------------------------------------------------------- */
/** \name Array Store
* \{ */
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 62dd4a22654..3b5897de0b0 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -407,7 +407,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
me = (Mesh *)ob->data;
key = me->key;
- if (totvert == 0 || totvert == me->totvert) {
+ if (ELEM(totvert, 0, me->totvert)) {
BKE_report(op->reports, RPT_WARNING, "No mesh data to join");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/metaball/CMakeLists.txt b/source/blender/editors/metaball/CMakeLists.txt
index 72105ddb00a..4e600dc0277 100644
--- a/source/blender/editors/metaball/CMakeLists.txt
+++ b/source/blender/editors/metaball/CMakeLists.txt
@@ -22,7 +22,7 @@ set(INC
../../depsgraph
../../makesdna
../../makesrna
- ../../render/extern/include
+ ../../render
../../windowmanager
../../../../intern/clog
../../../../intern/guardedalloc
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index 2f72f563e68..e4991f31649 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -32,7 +32,7 @@ set(INC
../../modifiers
../../python
../../shader_fx
- ../../render/extern/include
+ ../../render
../../windowmanager
../../../../intern/clog
../../../../intern/glew-mx
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index d70e02cf3da..e15e64a5e45 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2932,7 +2932,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
/* Remove curves and meshes converted to Grease Pencil object. */
if (gpencilConverted) {
FOREACH_SCENE_OBJECT_BEGIN (scene, ob_delete) {
- if ((ob_delete->type == OB_CURVE) || (ob_delete->type == OB_MESH)) {
+ if (ELEM(ob_delete->type, OB_CURVE, OB_MESH)) {
if (ob_delete->flag & OB_DONE) {
ED_object_base_free_and_unlink(bmain, scene, ob_delete);
}
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index ae1aae27b7f..008498a1735 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -53,7 +53,7 @@
#include "RE_multires_bake.h"
#include "RE_pipeline.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#include "PIL_time.h"
@@ -97,7 +97,6 @@ typedef struct MultiresBakerJobData {
int len;
} ob_image;
DerivedMesh *lores_dm, *hires_dm;
- bool simple;
int lvl, tot_lvl;
ListBase images;
} MultiresBakerJobData;
@@ -247,7 +246,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
return dm;
}
-static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *lvl, bool *simple)
+static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *lvl)
{
Mesh *me = (Mesh *)ob->data;
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
@@ -264,7 +263,6 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l
CustomData_set_only_copy(&cddm->polyData, CD_MASK_BAREMESH.pmask);
*lvl = mmd->totlvl;
- *simple = mmd->simple != 0;
tmp_mmd.lvl = mmd->totlvl;
tmp_mmd.sculptlvl = mmd->totlvl;
@@ -386,7 +384,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
bkr.ob_image.array = bake_object_image_get_array(ob);
bkr.ob_image.len = ob->totcol;
- bkr.hires_dm = multiresbake_create_hiresdm(scene, ob, &bkr.tot_lvl, &bkr.simple);
+ bkr.hires_dm = multiresbake_create_hiresdm(scene, ob, &bkr.tot_lvl);
bkr.lores_dm = multiresbake_create_loresdm(scene, ob, &bkr.lvl);
RE_multires_bake_images(&bkr);
@@ -441,7 +439,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj)
data->ob_image.len = ob->totcol;
/* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */
- data->hires_dm = multiresbake_create_hiresdm(scene, ob, &data->tot_lvl, &data->simple);
+ data->hires_dm = multiresbake_create_hiresdm(scene, ob, &data->tot_lvl);
data->lores_dm = multiresbake_create_loresdm(scene, ob, &lvl);
data->lvl = lvl;
@@ -491,7 +489,6 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa
bkr.hires_dm = data->hires_dm;
bkr.tot_lvl = data->tot_lvl;
bkr.lvl = data->lvl;
- bkr.simple = data->simple;
/* needed for proper progress bar */
bkr.tot_obj = tot_obj;
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 0073aa830de..fa8531dfb48 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -2219,7 +2219,7 @@ static const EnumPropertyItem *object_constraint_add_itemf(bContext *UNUSED(C),
int totitem = 0;
while (item->identifier) {
- if ((item->value != CONSTRAINT_TYPE_KINEMATIC) && (item->value != CONSTRAINT_TYPE_SPLINEIK)) {
+ if (!ELEM(item->value, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK)) {
RNA_enum_item_add(&object_constraint_items, &totitem, item);
}
item++;
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 4884df1edb6..99989f86381 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -28,6 +28,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
+#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
@@ -562,32 +563,45 @@ static bool data_transfer_poll_property(const bContext *UNUSED(C),
return false;
}
- if (STREQ(prop_id, "use_object_transform") && use_auto_transform) {
- return false;
+ if (STREQ(prop_id, "use_object_transform")) {
+ if (use_auto_transform) {
+ return false;
+ }
}
- if (STREQ(prop_id, "max_distance") && !use_max_distance) {
- return false;
+ else if (STREQ(prop_id, "max_distance")) {
+ if (!use_max_distance) {
+ return false;
+ }
}
- if (STREQ(prop_id, "islands_precision") && !DT_DATATYPE_IS_LOOP(data_type)) {
- return false;
+ else if (STREQ(prop_id, "islands_precision")) {
+ if (!DT_DATATYPE_IS_LOOP(data_type)) {
+ return false;
+ }
}
-
- if (STREQ(prop_id, "vert_mapping") && !DT_DATATYPE_IS_VERT(data_type)) {
- return false;
+ else if (STREQ(prop_id, "vert_mapping")) {
+ if (!DT_DATATYPE_IS_VERT(data_type)) {
+ return false;
+ }
}
- if (STREQ(prop_id, "edge_mapping") && !DT_DATATYPE_IS_EDGE(data_type)) {
- return false;
+ else if (STREQ(prop_id, "edge_mapping")) {
+ if (!DT_DATATYPE_IS_EDGE(data_type)) {
+ return false;
+ }
}
- if (STREQ(prop_id, "loop_mapping") && !DT_DATATYPE_IS_LOOP(data_type)) {
- return false;
+ else if (STREQ(prop_id, "loop_mapping")) {
+ if (!DT_DATATYPE_IS_LOOP(data_type)) {
+ return false;
+ }
}
- if (STREQ(prop_id, "poly_mapping") && !DT_DATATYPE_IS_POLY(data_type)) {
- return false;
+ else if (STREQ(prop_id, "poly_mapping")) {
+ if (!DT_DATATYPE_IS_POLY(data_type)) {
+ return false;
+ }
}
-
- if ((STREQ(prop_id, "layers_select_src") || STREQ(prop_id, "layers_select_dst")) &&
- !DT_DATATYPE_IS_MULTILAYERS(data_type)) {
- return false;
+ else if (STR_ELEM(prop_id, "layers_select_src", "layers_select_dst")) {
+ if (!DT_DATATYPE_IS_MULTILAYERS(data_type)) {
+ return false;
+ }
}
/* Else, show it! */
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index ff38bddd040..ee08f29017a 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -761,7 +761,7 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_LATTICE, scene);
}
- else if (ob->type == OB_SURF || ob->type == OB_CURVE) {
+ else if (ELEM(ob->type, OB_SURF, OB_CURVE)) {
ok = 1;
ED_curve_editnurb_make(ob);
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 5cfe02dbc59..91c9916d227 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -238,12 +238,11 @@ static void select_editlattice_hook(Object *obedit, HookModifierData *hmd)
static int return_editcurve_indexar(Object *obedit, int *r_tot, int **r_indexar, float r_cent[3])
{
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int *index, a, nr, totvert = 0;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
a = nu->pntsu;
@@ -280,7 +279,7 @@ static int return_editcurve_indexar(Object *obedit, int *r_tot, int **r_indexar,
nr = 0;
zero_v3(r_cent);
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
a = nu->pntsu;
@@ -377,12 +376,11 @@ static bool object_hook_index_array(Main *bmain,
static void select_editcurve_hook(Object *obedit, HookModifierData *hmd)
{
ListBase *editnurb = object_editcurve_get(obedit);
- Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int index = 0, a, nr = 0;
- for (nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
a = nu->pntsu;
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 7f87577b630..0b22afb7e66 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -31,6 +31,7 @@
#include "DNA_armature_types.h"
#include "DNA_curve_types.h"
#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_force_types.h"
@@ -679,16 +680,15 @@ static int modifier_apply_shape(Main *bmain,
return 0;
}
- /*
- * It should be ridiculously easy to extract the original verts that we want
- * and form the shape data. We can probably use the CD KEYINDEX layer (or
- * whatever I ended up calling it, too tired to check now), though this would
- * by necessity have to make some potentially ugly assumptions about the order
- * of the mesh data :-/ you can probably assume in 99% of cases that the first
- * element of a given index is the original, and any subsequent duplicates are
- * copies/interpolates, but that's an assumption that would need to be tested
- * and then predominantly stated in comments in a half dozen headers.
- */
+ /* We could investigate using the #CD_ORIGINDEX layer
+ * to support other kinds of modifiers besides deforming modifiers.
+ * as this is done in many other places, see: #BKE_mesh_foreach_mapped_vert_coords_get.
+ *
+ * This isn't high priority in practice since most modifiers users
+ * want to apply as a shape are deforming modifiers.
+ *
+ * If a compelling use-case comes up where we want to support other kinds of modifiers
+ * we can look into supporting them. */
if (ob->type == OB_MESH) {
Mesh *mesh_applied;
@@ -721,7 +721,7 @@ static int modifier_apply_shape(Main *bmain,
BKE_id_free(NULL, mesh_applied);
}
else {
- /* TODO: implement for hair, pointclouds and volumes. */
+ /* TODO: implement for hair, point-clouds and volumes. */
BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type");
return 0;
}
@@ -798,8 +798,27 @@ static int modifier_apply_obdata(
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
+ else if (ob->type == OB_LATTICE) {
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
+ Lattice *lattice = ob->data;
+ ModifierEvalContext mectx = {depsgraph, object_eval, 0};
+
+ if (ELEM(mti->type, eModifierTypeType_Constructive, eModifierTypeType_Nonconstructive)) {
+ BKE_report(reports, RPT_ERROR, "Constructive modifiers cannot be applied");
+ return 0;
+ }
+
+ int numVerts;
+ float(*vertexCos)[3] = BKE_lattice_vert_coords_alloc(lattice, &numVerts);
+ mti->deformVerts(md_eval, &mectx, NULL, vertexCos, numVerts);
+ BKE_lattice_vert_coords_apply(lattice, vertexCos);
+
+ MEM_freeN(vertexCos);
+
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
else {
- /* TODO: implement for hair, pointclouds and volumes. */
+ /* TODO: implement for hair, point-clouds and volumes. */
BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type");
return 0;
}
@@ -1478,8 +1497,8 @@ static char *modifier_apply_as_shapekey_get_description(struct bContext *UNUSED(
void OBJECT_OT_modifier_apply_as_shapekey(wmOperatorType *ot)
{
- ot->name = "Apply Modifier As Shapekey";
- ot->description = "Apply modifier as a new shapekey and remove from the stack";
+ ot->name = "Apply Modifier as Shape Key";
+ ot->description = "Apply modifier as a new shape key and remove from the stack";
ot->idname = "OBJECT_OT_modifier_apply_as_shapekey";
ot->invoke = modifier_apply_as_shapekey_invoke;
@@ -1887,7 +1906,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
edit_modifier_properties(ot);
}
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index de3e5f3d5f9..29393e8a8d1 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -696,7 +696,7 @@ bool ED_object_parent_set(ReportList *reports,
/* Preconditions. */
if (ob == par) {
/* Parenting an object to itself is impossible. */
- return true;
+ return false;
}
if (BKE_object_parent_loop_check(par, ob)) {
@@ -911,7 +911,7 @@ bool ED_object_parent_set(ReportList *reports,
else if (partype == PAR_ARMATURE_NAME) {
ED_gpencil_add_armature_weights(C, reports, ob, par, GP_PAR_ARMATURE_NAME);
}
- else if ((partype == PAR_ARMATURE_AUTO) || (partype == PAR_ARMATURE_ENVELOPE)) {
+ else if (ELEM(partype, PAR_ARMATURE_AUTO, PAR_ARMATURE_ENVELOPE)) {
WM_cursor_wait(1);
ED_gpencil_add_armature_weights(C, reports, ob, par, GP_PAR_ARMATURE_AUTO);
WM_cursor_wait(0);
@@ -981,6 +981,12 @@ struct ParentingContext {
static bool parent_set_nonvertex_parent(bContext *C, struct ParentingContext *parenting_context)
{
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
+ if (ob == parenting_context->par) {
+ /* ED_object_parent_set() will fail (and thus return false), but this case shouldn't break
+ * this loop. It's expected that the active object is also selected. */
+ continue;
+ }
+
if (!ED_object_parent_set(parenting_context->reports,
C,
parenting_context->scene,
@@ -1005,6 +1011,12 @@ static bool parent_set_vertex_parent_with_kdtree(bContext *C,
int vert_par[3] = {0, 0, 0};
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
+ if (ob == parenting_context->par) {
+ /* ED_object_parent_set() will fail (and thus return false), but this case shouldn't break
+ * this loop. It's expected that the active object is also selected. */
+ continue;
+ }
+
parent_set_vert_find(tree, ob, vert_par, parenting_context->is_vertex_tri);
if (!ED_object_parent_set(parenting_context->reports,
C,
@@ -1359,7 +1371,7 @@ enum {
static const EnumPropertyItem prop_make_track_types[] = {
{CREATE_TRACK_DAMPTRACK, "DAMPTRACK", 0, "Damped Track Constraint", ""},
- {CREATE_TRACK_TRACKTO, "TRACKTO", 0, "Track To Constraint", ""},
+ {CREATE_TRACK_TRACKTO, "TRACKTO", 0, "Track to Constraint", ""},
{CREATE_TRACK_LOCKTRACK, "LOCKTRACK", 0, "Lock Track Constraint", ""},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 7d853745ad6..76d0c162f29 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -565,7 +565,7 @@ static void append_sorted_object_parent_hierarchy(Object *root_object,
Object **sorted_objects,
int *object_index)
{
- if (object->parent != NULL && object->parent != root_object) {
+ if (!ELEM(object->parent, NULL, root_object)) {
append_sorted_object_parent_hierarchy(
root_object, object->parent, sorted_objects, object_index);
}
@@ -1374,7 +1374,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
if (centermode == ORIGIN_TO_CURSOR) {
copy_v3_v3(gpcenter, cursor);
}
- if ((centermode == ORIGIN_TO_GEOMETRY) || (centermode == ORIGIN_TO_CURSOR)) {
+ if (ELEM(centermode, ORIGIN_TO_GEOMETRY, ORIGIN_TO_CURSOR)) {
bGPDspoint *pt;
float imat[3][3], bmat[3][3];
float offset_global[3];
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index e92b3323441..3d6a6abfe0d 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -2664,12 +2664,23 @@ static void vgroup_assign_verts(Object *ob, const float weight)
static bool vertex_group_supported_poll_ex(bContext *C, const Object *ob)
{
if (!ED_operator_object_active_local_editable_ex(C, ob)) {
+ CTX_wm_operator_poll_msg_set(C, "No active editable object");
return false;
}
+
+ if (!OB_TYPE_SUPPORT_VGROUP(ob->type)) {
+ CTX_wm_operator_poll_msg_set(C, "Object type does not support vertex groups");
+ return false;
+ }
+
+ /* Data checks. */
const ID *data = ob->data;
- return (OB_TYPE_SUPPORT_VGROUP(ob->type) &&
- /* Data checks. */
- (data != NULL) && !ID_IS_LINKED(data) && !ID_IS_OVERRIDE_LIBRARY(data));
+ if (data == NULL || ID_IS_LINKED(data) || ID_IS_OVERRIDE_LIBRARY(data)) {
+ CTX_wm_operator_poll_msg_set(C, "Object type \"%s\" does not have editable data");
+ return false;
+ }
+
+ return true;
}
static bool vertex_group_supported_poll(bContext *C)
@@ -2678,48 +2689,61 @@ static bool vertex_group_supported_poll(bContext *C)
return vertex_group_supported_poll_ex(C, ob);
}
-static bool vertex_group_poll(bContext *C)
+static bool vertex_group_poll_ex(bContext *C, Object *ob)
{
- Object *ob = ED_object_context(C);
+ if (!vertex_group_supported_poll_ex(C, ob)) {
+ return false;
+ }
+
+ if (BLI_listbase_is_empty(&ob->defbase)) {
+ CTX_wm_operator_poll_msg_set(C, "Object has no vertex groups");
+ return false;
+ }
- return (vertex_group_supported_poll(C) && ob->defbase.first);
+ return true;
}
-static bool vertex_group_mesh_poll(bContext *C)
+static bool vertex_group_poll(bContext *C)
{
Object *ob = ED_object_context(C);
-
- return (vertex_group_poll(C) && ob->type == OB_MESH);
+ return vertex_group_poll_ex(C, ob);
}
-static bool vertex_group_mesh_with_dvert_poll(bContext *C)
+static bool vertex_group_mesh_poll_ex(bContext *C, Object *ob)
{
- Object *ob = ED_object_context(C);
-
- if (!vertex_group_mesh_poll(C)) {
+ if (!vertex_group_poll_ex(C, ob)) {
return false;
}
- Mesh *me = ob->data;
- if (me->dvert == NULL) {
+ if (ob->type != OB_MESH) {
+ CTX_wm_operator_poll_msg_set(C, "Only mesh objects are supported");
return false;
}
return true;
}
-static bool UNUSED_FUNCTION(vertex_group_mesh_supported_poll)(bContext *C)
+static bool vertex_group_mesh_with_dvert_poll(bContext *C)
{
Object *ob = ED_object_context(C);
+ if (!vertex_group_mesh_poll_ex(C, ob)) {
+ return false;
+ }
+
+ Mesh *me = ob->data;
+ if (me->dvert == NULL) {
+ CTX_wm_operator_poll_msg_set(C, "The active mesh object has no vertex group data");
+ return false;
+ }
- return (vertex_group_supported_poll(C) && ob->type == OB_MESH);
+ return true;
}
static bool UNUSED_FUNCTION(vertex_group_poll_edit)(bContext *C)
{
Object *ob = ED_object_context(C);
- if (!vertex_group_supported_poll(C)) {
+ if (!vertex_group_supported_poll_ex(C, ob)) {
return false;
}
@@ -2733,7 +2757,7 @@ static bool vertex_group_vert_poll_ex(bContext *C,
{
Object *ob = ED_object_context(C);
- if (!vertex_group_supported_poll(C)) {
+ if (!vertex_group_supported_poll_ex(C, ob)) {
return false;
}
@@ -2786,7 +2810,7 @@ static bool vertex_group_vert_select_unlocked_poll(bContext *C)
{
Object *ob = ED_object_context(C);
- if (!vertex_group_supported_poll(C)) {
+ if (!vertex_group_supported_poll_ex(C, ob)) {
return false;
}
@@ -2807,7 +2831,7 @@ static bool vertex_group_vert_select_mesh_poll(bContext *C)
{
Object *ob = ED_object_context(C);
- if (!vertex_group_supported_poll(C)) {
+ if (!vertex_group_supported_poll_ex(C, ob)) {
return false;
}
@@ -3181,9 +3205,9 @@ void OBJECT_OT_vertex_group_levels(wmOperatorType *ot)
vgroup_operator_subset_select_props(ot, true);
RNA_def_float(
- ot->srna, "offset", 0.f, -1.0, 1.0, "Offset", "Value to add to weights", -1.0f, 1.f);
+ ot->srna, "offset", 0.0f, -1.0, 1.0, "Offset", "Value to add to weights", -1.0f, 1.0f);
RNA_def_float(
- ot->srna, "gain", 1.f, 0.f, FLT_MAX, "Gain", "Value to multiply weights by", 0.0f, 10.f);
+ ot->srna, "gain", 1.0f, 0.0f, FLT_MAX, "Gain", "Value to multiply weights by", 0.0f, 10.0f);
}
/** \} */
@@ -3345,7 +3369,7 @@ void OBJECT_OT_vertex_group_fix(wmOperatorType *ot)
10.0f);
RNA_def_float(ot->srna,
"strength",
- 1.f,
+ 1.0f,
-2.0f,
FLT_MAX,
"Strength",
@@ -3361,7 +3385,7 @@ void OBJECT_OT_vertex_group_fix(wmOperatorType *ot)
"Change Sensitivity",
"Change the amount weights are altered with each iteration: lower values are slower",
0.05f,
- 1.f);
+ 1.0f);
}
/** \} */
diff --git a/source/blender/editors/object/object_volume.c b/source/blender/editors/object/object_volume.c
index c5dc7f9f24d..5aa61139468 100644
--- a/source/blender/editors/object/object_volume.c
+++ b/source/blender/editors/object/object_volume.c
@@ -184,7 +184,7 @@ void OBJECT_OT_volume_import(wmOperatorType *ot)
WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILES |
WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_boolean(
ot->srna,
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index e6d11398279..63f12e339b9 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -4438,7 +4438,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
for (k = 0, hkey = pa->hair; k < pset->totaddkey; k++, hkey++) {
madd_v3_v3v3fl(hkey->co, pa->state.co, pa->state.vel, k * framestep * timestep);
hkey->time += k * framestep;
- hkey->weight = 1.f - (float)k / (float)(pset->totaddkey - 1);
+ hkey->weight = 1.0f - (float)k / (float)(pset->totaddkey - 1);
}
}
for (k = 0, hkey = pa->hair; k < pset->totaddkey; k++, hkey++) {
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 56bdc5c21f4..017cd63d9d5 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -691,7 +691,7 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
RNA_def_boolean(
- ot->srna, "all", 0, "All hair", "Disconnect all hair systems from the emitter mesh");
+ ot->srna, "all", 0, "All Hair", "Disconnect all hair systems from the emitter mesh");
}
/* from/to_world_space : whether from/to particles are in world or hair space
@@ -981,7 +981,7 @@ void PARTICLE_OT_connect_hair(wmOperatorType *ot)
/* No REGISTER, redo does not work due to missing update, see T47750. */
ot->flag = OPTYPE_UNDO;
- RNA_def_boolean(ot->srna, "all", 0, "All hair", "Connect all hair systems to the emitter mesh");
+ RNA_def_boolean(ot->srna, "all", 0, "All Hair", "Connect all hair systems to the emitter mesh");
}
/************************ particle system copy operator *********************/
diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
index 4934a3d10cd..e827a3fbb2d 100644
--- a/source/blender/editors/physics/physics_pointcache.c
+++ b/source/blender/editors/physics/physics_pointcache.c
@@ -57,7 +57,41 @@ static bool ptcache_bake_all_poll(bContext *C)
static bool ptcache_poll(bContext *C)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
- return (ptr.data && ptr.owner_id);
+
+ ID *id = ptr.owner_id;
+ PointCache *point_cache = ptr.data;
+
+ if (id == NULL || point_cache == NULL) {
+ return false;
+ }
+
+ if (ID_IS_OVERRIDE_LIBRARY_REAL(id) && (point_cache->flag & PTCACHE_DISK_CACHE) == false) {
+ return false;
+ }
+
+ if (ID_IS_LINKED(id) && (point_cache->flag & PTCACHE_DISK_CACHE) == false) {
+ return false;
+ }
+
+ return true;
+}
+
+static bool ptcache_add_remove_poll(bContext *C)
+{
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
+
+ ID *id = ptr.owner_id;
+ PointCache *point_cache = ptr.data;
+
+ if (id == NULL || point_cache == NULL) {
+ return false;
+ }
+
+ if (ID_IS_OVERRIDE_LIBRARY_REAL(id) || ID_IS_LINKED(id)) {
+ return false;
+ }
+
+ return true;
}
typedef struct PointCacheJob {
@@ -417,7 +451,7 @@ void PTCACHE_OT_add(wmOperatorType *ot)
/* api callbacks */
ot->exec = ptcache_add_new_exec;
- ot->poll = ptcache_poll;
+ ot->poll = ptcache_add_remove_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -431,7 +465,7 @@ void PTCACHE_OT_remove(wmOperatorType *ot)
/* api callbacks */
ot->exec = ptcache_remove_exec;
- ot->poll = ptcache_poll;
+ ot->poll = ptcache_add_remove_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c
index 42f270874e3..f2e2d7589df 100644
--- a/source/blender/editors/physics/rigidbody_world.c
+++ b/source/blender/editors/physics/rigidbody_world.c
@@ -210,5 +210,5 @@ void RIGIDBODY_OT_world_export(wmOperatorType *ot)
FILE_SAVE,
FILE_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt
index b39dbf74375..46afa390997 100644
--- a/source/blender/editors/render/CMakeLists.txt
+++ b/source/blender/editors/render/CMakeLists.txt
@@ -28,7 +28,7 @@ set(INC
../../imbuf
../../makesdna
../../makesrna
- ../../render/extern/include
+ ../../render
../../sequencer
../../windowmanager
../../../../intern/glew-mx
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 7ca711cd2b8..3dbf70aa4bc 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -57,7 +57,6 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
-#include "BKE_sequencer.h"
#include "BKE_undo_system.h"
#include "DEG_depsgraph.h"
@@ -83,6 +82,8 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "SEQ_sequencer.h"
+
#include "BLO_undofile.h"
#include "render_intern.h"
@@ -435,20 +436,6 @@ static void make_renderinfo_string(const RenderStats *rs,
}
}
else {
- if (rs->totvert || rs->totface || rs->totlamp) {
- spos += sprintf(spos, "| ");
- }
-
- if (rs->totvert) {
- spos += sprintf(spos, TIP_("Ve:%d "), rs->totvert);
- }
- if (rs->totface) {
- spos += sprintf(spos, TIP_("Fa:%d "), rs->totface);
- }
- if (rs->totlamp) {
- spos += sprintf(spos, TIP_("Li:%d "), rs->totlamp);
- }
-
if (rs->mem_peak == 0.0f) {
spos += sprintf(spos, TIP_("| Mem:%.2fM (Peak %.2fM) "), megs_used_memory, megs_peak_memory);
}
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 8cad3b94fe9..696c18d17c5 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -54,7 +54,6 @@
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
#include "BKE_writeavi.h"
#include "DEG_depsgraph.h"
@@ -78,6 +77,8 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "SEQ_sequencer.h"
+
#include "GPU_framebuffer.h"
#include "GPU_matrix.h"
@@ -488,7 +489,7 @@ static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender)
SpaceSeq *sseq = oglrender->sseq;
int chanshown = sseq ? sseq->chanshown : 0;
- BKE_sequencer_new_render_data(oglrender->bmain,
+ SEQ_render_new_render_data(oglrender->bmain,
oglrender->depsgraph,
scene,
oglrender->sizex,
@@ -500,7 +501,7 @@ static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender)
for (view_id = 0; view_id < oglrender->views_len; view_id++) {
context.view_id = view_id;
context.gpu_offscreen = oglrender->ofs;
- oglrender->seq_data.ibufs_arr[view_id] = BKE_sequencer_give_ibuf(&context, CFRA, chanshown);
+ oglrender->seq_data.ibufs_arr[view_id] = SEQ_render_give_ibuf(&context, CFRA, chanshown);
}
}
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 4afa45893f9..095deccada0 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -86,7 +86,7 @@
#include "RE_engine.h"
#include "RE_pipeline.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index f5962f36412..690d6c8055a 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1385,7 +1385,7 @@ static void region_rect_recursive(
region->winrct = *remainder;
BLI_rcti_init(remainder, 0, 0, 0, 0);
}
- else if (alignment == RGN_ALIGN_TOP || alignment == RGN_ALIGN_BOTTOM) {
+ else if (ELEM(alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
rcti *winrct = (region->overlap) ? overlap_remainder : remainder;
if ((prefsizey == 0) || (rct_fits(winrct, 'v', prefsizey) < 0)) {
@@ -1437,7 +1437,7 @@ static void region_rect_recursive(
BLI_rcti_sanitize(winrct);
}
}
- else if (alignment == RGN_ALIGN_VSPLIT || alignment == RGN_ALIGN_HSPLIT) {
+ else if (ELEM(alignment, RGN_ALIGN_VSPLIT, RGN_ALIGN_HSPLIT)) {
/* percentage subdiv*/
region->winrct = *remainder;
@@ -1738,6 +1738,10 @@ static void ed_default_handlers(
wmKeyMap *keymap_general = WM_keymap_ensure(wm->defaultconf, "Grease Pencil", 0, 0);
WM_event_add_keymap_handler(handlers, keymap_general);
+ wmKeyMap *keymap_curve_edit = WM_keymap_ensure(
+ wm->defaultconf, "Grease Pencil Stroke Curve Edit Mode", 0, 0);
+ WM_event_add_keymap_handler(handlers, keymap_curve_edit);
+
wmKeyMap *keymap_edit = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Stroke Edit Mode", 0, 0);
WM_event_add_keymap_handler(handlers, keymap_edit);
@@ -1871,6 +1875,11 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar
area->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
}
+bool ED_area_has_shared_border(struct ScrArea *a, struct ScrArea *b)
+{
+ return area_getorientation(a, b) != -1;
+}
+
/* called in screen_refresh, or screens_init, also area size changes */
void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area)
{
@@ -2626,7 +2635,7 @@ static void ed_panel_draw(const bContext *C,
int headerend = w - UI_UNIT_X;
UI_panel_header_buttons_begin(panel);
- if (pt->draw_header_preset && !(pt->flag & PNL_NO_HEADER)) {
+ if (pt->draw_header_preset && !(pt->flag & PANEL_TYPE_NO_HEADER)) {
/* for preset menu */
panel->layout = UI_block_layout(block,
UI_LAYOUT_HORIZONTAL,
@@ -2646,12 +2655,12 @@ static void ed_panel_draw(const bContext *C,
panel->layout = NULL;
}
- if (pt->draw_header && !(pt->flag & PNL_NO_HEADER)) {
+ if (pt->draw_header && !(pt->flag & PANEL_TYPE_NO_HEADER)) {
int labelx, labely;
UI_panel_label_offset(block, &labelx, &labely);
/* Unusual case: Use expanding layout (buttons stretch to available width). */
- if (pt->flag & PNL_LAYOUT_HEADER_EXPAND) {
+ if (pt->flag & PANEL_TYPE_HEADER_EXPAND) {
uiLayout *layout = UI_block_layout(block,
UI_LAYOUT_VERTICAL,
UI_LAYOUT_PANEL,
@@ -2685,7 +2694,7 @@ static void ed_panel_draw(const bContext *C,
short panelContext;
/* panel context can either be toolbar region or normal panels region */
- if (pt->flag & PNL_LAYOUT_VERT_BAR) {
+ if (pt->flag & PANEL_TYPE_LAYOUT_VERT_BAR) {
panelContext = UI_LAYOUT_VERT_BAR;
}
else if (region->regiontype == RGN_TYPE_TOOLS) {
@@ -2695,16 +2704,16 @@ static void ed_panel_draw(const bContext *C,
panelContext = UI_LAYOUT_PANEL;
}
- panel->layout = UI_block_layout(block,
- UI_LAYOUT_VERTICAL,
- panelContext,
- (pt->flag & PNL_LAYOUT_VERT_BAR) ? 0 : style->panelspace,
- 0,
- (pt->flag & PNL_LAYOUT_VERT_BAR) ? 0 :
- w - 2 * style->panelspace,
- em,
- 0,
- style);
+ panel->layout = UI_block_layout(
+ block,
+ UI_LAYOUT_VERTICAL,
+ panelContext,
+ (pt->flag & PANEL_TYPE_LAYOUT_VERT_BAR) ? 0 : style->panelspace,
+ 0,
+ (pt->flag & PANEL_TYPE_LAYOUT_VERT_BAR) ? 0 : w - 2 * style->panelspace,
+ em,
+ 0,
+ style);
pt->draw(C, panel);
@@ -2883,7 +2892,7 @@ void ED_region_panels_layout_ex(const bContext *C,
for (LinkNode *pt_link = panel_types_stack; pt_link; pt_link = pt_link->next) {
PanelType *pt = pt_link->link;
- if (pt->flag & PNL_INSTANCED) {
+ if (pt->flag & PANEL_TYPE_INSTANCED) {
has_instanced_panel = true;
continue;
}
@@ -2905,7 +2914,7 @@ void ED_region_panels_layout_ex(const bContext *C,
&region->panels,
pt,
panel,
- (pt->flag & PNL_DRAW_BOX) ? w_box_panel : w,
+ (pt->flag & PANEL_TYPE_DRAW_BOX) ? w_box_panel : w,
em,
NULL,
search_filter);
@@ -2917,7 +2926,7 @@ void ED_region_panels_layout_ex(const bContext *C,
if (panel->type == NULL) {
continue; /* Some panels don't have a type. */
}
- if (!(panel->type->flag & PNL_INSTANCED)) {
+ if (!(panel->type->flag & PANEL_TYPE_INSTANCED)) {
continue;
}
if (use_category_tabs && panel->type->category[0] &&
@@ -2939,7 +2948,7 @@ void ED_region_panels_layout_ex(const bContext *C,
&region->panels,
panel->type,
panel,
- (panel->type->flag & PNL_DRAW_BOX) ? w_box_panel : w,
+ (panel->type->flag & PANEL_TYPE_DRAW_BOX) ? w_box_panel : w,
em,
unique_panel_str,
search_filter);
@@ -3160,7 +3169,7 @@ bool ED_region_property_search(const bContext *C,
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) {
+ if (panel_type->flag & PANEL_TYPE_INSTANCED) {
has_instanced_panel = true;
continue;
}
@@ -3183,7 +3192,7 @@ bool ED_region_property_search(const bContext *C,
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)) {
+ if (panel->type == NULL || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
continue;
}
if (use_category_tabs) {
@@ -3577,7 +3586,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
ofs_y += vertical_offset;
}
} /* Strip */
- else if (i == 1 || i == 2) {
+ else if (ELEM(i, 1, 2)) {
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);
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 3924c334541..af09100b8e6 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -48,7 +48,6 @@
#include "BKE_gpencil.h"
#include "BKE_layer.h"
#include "BKE_object.h"
-#include "BKE_sequencer.h"
#include "RNA_access.h"
@@ -56,6 +55,8 @@
#include "ED_armature.h"
#include "ED_gpencil.h"
+#include "SEQ_sequencer.h"
+
#include "UI_interface.h"
#include "WM_api.h"
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index ddb1f5c87ba..6432bdac1b1 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -203,7 +203,7 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos)
*/
static void draw_join_shape(ScrArea *area, char dir, uint pos)
{
- if (dir == 'u' || dir == 'd') {
+ if (ELEM(dir, 'u', 'd')) {
draw_vertical_join_shape(area, dir, pos);
}
else {
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 5f56bbaef9d..5e67d6855c0 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -362,7 +362,7 @@ static void screen_areas_align(
{
wmWindow *win = CTX_wm_window(C);
- if (dir == 0 || dir == 2) {
+ if (ELEM(dir, 0, 2)) {
/* horizontal join, use average for new top and bottom. */
int top = (sa1->v2->vec.y + sa2->v2->vec.y) / 2;
int bottom = (sa1->v4->vec.y + sa2->v4->vec.y) / 2;
@@ -687,7 +687,7 @@ static void screen_cursor_set(wmWindow *win, const int xy[2])
WM_cursor_set(win, WM_CURSOR_EDIT);
}
else if (az->type == AZONE_REGION) {
- if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) {
+ if (ELEM(az->edge, AE_LEFT_TO_TOPRIGHT, AE_RIGHT_TO_TOPLEFT)) {
WM_cursor_set(win, WM_CURSOR_X_MOVE);
}
else {
@@ -772,7 +772,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
}
}
- if (region == region_prev || region == screen->active_region) {
+ if (ELEM(region, region_prev, screen->active_region)) {
do_draw = true;
}
}
diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c
index 4acf3dd7ba5..ac159f4d633 100644
--- a/source/blender/editors/screen/screen_geometry.c
+++ b/source/blender/editors/screen/screen_geometry.c
@@ -202,7 +202,7 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win,
/* all selected vertices get the right offset */
LISTBASE_FOREACH (ScrVert *, sv, &screen->vertbase) {
/* if is a collapsed area */
- if (sv != area->v1 && sv != area->v4) {
+ if (!ELEM(sv, area->v1, area->v4)) {
if (sv->flag) {
sv->vec.y = yval;
/* Changed size of a area. Run another pass to ensure everything still fits. */
@@ -228,7 +228,7 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win,
/* all selected vertices get the right offset */
LISTBASE_FOREACH (ScrVert *, sv, &screen->vertbase) {
/* if is not a collapsed area */
- if (sv != area->v2 && sv != area->v3) {
+ if (!ELEM(sv, area->v2, area->v3)) {
if (sv->flag) {
sv->vec.y = yval;
/* Changed size of a area. Run another pass to ensure everything still fits. */
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 27a1d4e4a50..72b3b344813 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1617,7 +1617,7 @@ static int area_snap_calc_location(const bScreen *screen,
switch (snap_type) {
case SNAP_AREAGRID:
m_cursor_final = m_cursor;
- if (delta != bigger && delta != -smaller) {
+ if (!ELEM(delta, bigger, -smaller)) {
m_cursor_final -= (m_cursor % AREAGRID);
CLAMP(m_cursor_final, origval - smaller, origval + bigger);
}
@@ -2477,7 +2477,7 @@ static int area_max_regionsize(ScrArea *area, ARegion *scalear, AZEdge edge)
}
}
else {
- if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) {
+ if (ELEM(edge, AE_RIGHT_TO_TOPLEFT, AE_LEFT_TO_TOPRIGHT)) {
dist = BLI_rcti_size_x(&area->totrct);
}
else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
@@ -2574,7 +2574,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
/* now copy to regionmovedata */
- if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
+ if (ELEM(rmd->edge, AE_LEFT_TO_TOPRIGHT, AE_RIGHT_TO_TOPLEFT)) {
rmd->origval = rmd->region->sizex;
}
else {
@@ -2598,7 +2598,7 @@ static void region_scale_validate_size(RegionMoveData *rmd)
if ((rmd->region->flag & RGN_FLAG_HIDDEN) == 0) {
short *size, maxsize = -1;
- if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
+ if (ELEM(rmd->edge, AE_LEFT_TO_TOPRIGHT, AE_RIGHT_TO_TOPLEFT)) {
size = &rmd->region->sizex;
}
else {
@@ -2648,7 +2648,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
const float aspect = BLI_rctf_size_x(&rmd->region->v2d.cur) /
(BLI_rcti_size_x(&rmd->region->v2d.mask) + 1);
const int snap_size_threshold = (U.widget_unit * 2) / aspect;
- if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
+ if (ELEM(rmd->edge, AE_LEFT_TO_TOPRIGHT, AE_RIGHT_TO_TOPLEFT)) {
delta = event->x - rmd->origx;
if (rmd->edge == AE_LEFT_TO_TOPRIGHT) {
delta = -delta;
@@ -2827,7 +2827,7 @@ static int frame_offset_exec(bContext *C, wmOperator *op)
CFRA += delta;
FRAMENUMBER_MIN_CLAMP(CFRA);
- SUBFRA = 0.f;
+ SUBFRA = 0.0f;
areas_do_frame_follow(C, false);
@@ -5523,8 +5523,8 @@ static void keymap_modal_set(wmKeyConfig *keyconf)
static const EnumPropertyItem modal_items[] = {
{KM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
{KM_MODAL_APPLY, "APPLY", 0, "Apply", ""},
- {KM_MODAL_SNAP_ON, "SNAP", 0, "Snap on", ""},
- {KM_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Snap off", ""},
+ {KM_MODAL_SNAP_ON, "SNAP", 0, "Snap On", ""},
+ {KM_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Snap Off", ""},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 5d0ae292ffa..7d7a3340dc3 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -249,7 +249,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_boolean(ot->srna,
"full",
1,
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index cab2d32bdcf..5430137f5ca 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -57,6 +57,7 @@
#include "screen_intern.h"
+/* -------------------------------------------------------------------- */
/** \name Workspace API
*
* \brief API for managing workspaces and their data.
@@ -231,6 +232,7 @@ void ED_workspace_scene_data_sync(WorkSpaceInstanceHook *hook, Scene *scene)
/** \} Workspace API */
+/* -------------------------------------------------------------------- */
/** \name Workspace Operators
*
* \{ */
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index 930f9890dd9..9bf3d2610d8 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -28,7 +28,7 @@ set(INC
../../imbuf
../../makesdna
../../makesrna
- ../../render/extern/include
+ ../../render
../../windowmanager
../../../../intern/atomic
../../../../intern/clog
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index f0285c8faf3..550913fc8af 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -1310,6 +1310,11 @@ static bool paint_cursor_context_init(bContext *C,
Object *active_object = pcontext->vc.obact;
pcontext->ss = active_object ? active_object->sculpt : NULL;
+ if (pcontext->ss && pcontext->ss->draw_faded_cursor) {
+ pcontext->outline_alpha = 0.3f;
+ copy_v3_fl(pcontext->outline_col, 0.8f);
+ }
+
pcontext->is_stroke_active = pcontext->ups->stroke_active;
return true;
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index e5d682c27d9..da627c6b7db 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -366,10 +366,10 @@ static int hide_show_exec(bContext *C, wmOperator *op)
/* Start undo. */
switch (action) {
case PARTIALVIS_HIDE:
- SCULPT_undo_push_begin("Hide area");
+ SCULPT_undo_push_begin(ob, "Hide area");
break;
case PARTIALVIS_SHOW:
- SCULPT_undo_push_begin("Show area");
+ SCULPT_undo_push_begin(ob, "Show area");
break;
}
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index fe16611a6eb..3a6b91443a0 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -349,8 +349,8 @@ typedef struct PaintOperation {
bool paint_use_opacity_masking(Brush *brush)
{
return ((brush->flag & BRUSH_AIRBRUSH) || (brush->flag & BRUSH_DRAG_DOT) ||
- (brush->flag & BRUSH_ANCHORED) || (brush->imagepaint_tool == PAINT_TOOL_SMEAR) ||
- (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) ||
+ (brush->flag & BRUSH_ANCHORED) ||
+ (ELEM(brush->imagepaint_tool, PAINT_TOOL_SMEAR, PAINT_TOOL_SOFTEN)) ||
(brush->imagepaint_tool == PAINT_TOOL_FILL) ||
(brush->flag & BRUSH_USE_GRADIENT) ||
(brush->mtex.tex && !ELEM(brush->mtex.brush_map_mode,
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 37af1fb6cda..8c16300a047 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -1789,7 +1789,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
static int project_paint_pixel_sizeof(const short tool)
{
- if ((tool == PAINT_TOOL_CLONE) || (tool == PAINT_TOOL_SMEAR)) {
+ if (ELEM(tool, PAINT_TOOL_CLONE, PAINT_TOOL_SMEAR)) {
return sizeof(ProjPixelClone);
}
return sizeof(ProjPixel);
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index cde24cd2c25..4dd7ecb09ca 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -169,7 +169,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
- SCULPT_undo_push_begin("Mask flood fill");
+ SCULPT_undo_push_begin(ob, "Mask flood fill");
MaskTaskData data = {
.ob = ob,
@@ -247,8 +247,16 @@ typedef struct LassoGestureData {
} LassoGestureData;
typedef struct LineGestureData {
+ /* Plane aligned to the gesture line. */
float true_plane[4];
float plane[4];
+
+ /* Planes to limit the action to the length of the gesture segment at both sides of the affected
+ * area. */
+ float side_plane[2][4];
+ float true_side_plane[2][4];
+ bool use_side_planes;
+
bool flip;
} LineGestureData;
@@ -321,6 +329,13 @@ static void sculpt_gesture_operator_properties(wmOperatorType *ot)
false,
"Front Faces Only",
"Affect only faces facing towards the view");
+
+ RNA_def_boolean(ot->srna,
+ "use_limit_to_segment",
+ false,
+ "Limit to Segment",
+ "Apply the gesture action only to the area that is contained within the "
+ "segement without extending its effect to the entire line");
}
static void sculpt_gesture_context_init_common(bContext *C,
@@ -333,6 +348,7 @@ static void sculpt_gesture_context_init_common(bContext *C,
/* Operator properties. */
sgcontext->front_faces_only = RNA_boolean_get(op->ptr, "use_front_faces_only");
+ sgcontext->line.use_side_planes = RNA_boolean_get(op->ptr, "use_limit_to_segment");
/* SculptSession */
sgcontext->ss = ob->sculpt;
@@ -449,6 +465,50 @@ static SculptGestureContext *sculpt_gesture_init_from_box(bContext *C, wmOperato
return sgcontext;
}
+static void sculpt_gesture_line_plane_from_tri(float *r_plane,
+ SculptGestureContext *sgcontext,
+ const bool flip,
+ const float p1[3],
+ const float p2[3],
+ const float p3[3])
+{
+ float normal[3];
+ normal_tri_v3(normal, p1, p2, p3);
+ mul_v3_mat3_m4v3(normal, sgcontext->vc.obact->imat, normal);
+ if (flip) {
+ mul_v3_fl(normal, -1.0f);
+ }
+ float plane_point_object_space[3];
+ mul_v3_m4v3(plane_point_object_space, sgcontext->vc.obact->imat, p1);
+ plane_from_point_normal_v3(r_plane, plane_point_object_space, normal);
+}
+
+/* Creates 4 points in the plane defined by the line and 2 extra points with an offset relative to
+ * this plane. */
+static void sculpt_gesture_line_calculate_plane_points(SculptGestureContext *sgcontext,
+ float line_points[2][2],
+ float r_plane_points[4][3],
+ float r_offset_plane_points[2][3])
+{
+ float depth_point[3];
+ add_v3_v3v3(depth_point, sgcontext->true_view_origin, sgcontext->true_view_normal);
+ ED_view3d_win_to_3d(
+ sgcontext->vc.v3d, sgcontext->vc.region, depth_point, line_points[0], r_plane_points[0]);
+ ED_view3d_win_to_3d(
+ sgcontext->vc.v3d, sgcontext->vc.region, depth_point, line_points[1], r_plane_points[3]);
+
+ madd_v3_v3v3fl(depth_point, sgcontext->true_view_origin, sgcontext->true_view_normal, 10.0f);
+ ED_view3d_win_to_3d(
+ sgcontext->vc.v3d, sgcontext->vc.region, depth_point, line_points[0], r_plane_points[1]);
+ ED_view3d_win_to_3d(
+ sgcontext->vc.v3d, sgcontext->vc.region, depth_point, line_points[1], r_plane_points[2]);
+
+ float normal[3];
+ normal_tri_v3(normal, r_plane_points[0], r_plane_points[1], r_plane_points[2]);
+ add_v3_v3v3(r_offset_plane_points[0], r_plane_points[0], normal);
+ add_v3_v3v3(r_offset_plane_points[1], r_plane_points[3], normal);
+}
+
static SculptGestureContext *sculpt_gesture_init_from_line(bContext *C, wmOperator *op)
{
SculptGestureContext *sgcontext = MEM_callocN(sizeof(SculptGestureContext),
@@ -465,36 +525,33 @@ static SculptGestureContext *sculpt_gesture_init_from_line(bContext *C, wmOperat
sgcontext->line.flip = RNA_boolean_get(op->ptr, "flip");
- float depth_point[3];
- float plane_points[3][3];
-
- /* Calculate a triangle in the line's plane. */
- add_v3_v3v3(depth_point, sgcontext->true_view_origin, sgcontext->true_view_normal);
- ED_view3d_win_to_3d(
- sgcontext->vc.v3d, sgcontext->vc.region, depth_point, line_points[0], plane_points[0]);
-
- madd_v3_v3v3fl(depth_point, sgcontext->true_view_origin, sgcontext->true_view_normal, 10.0f);
- ED_view3d_win_to_3d(
- sgcontext->vc.v3d, sgcontext->vc.region, depth_point, line_points[0], plane_points[1]);
- ED_view3d_win_to_3d(
- sgcontext->vc.v3d, sgcontext->vc.region, depth_point, line_points[1], plane_points[2]);
-
- /* Calculate final line plane and normal using the triangle. */
- float normal[3];
- normal_tri_v3(normal, plane_points[0], plane_points[1], plane_points[2]);
- if (!sgcontext->vc.rv3d->is_persp) {
- mul_v3_fl(normal, -1.0f);
- }
-
- /* Apply flip. */
- if (sgcontext->line.flip) {
- mul_v3_fl(normal, -1.0f);
- }
-
- mul_v3_mat3_m4v3(normal, sgcontext->vc.obact->imat, normal);
- float plane_point_object_space[3];
- mul_v3_m4v3(plane_point_object_space, sgcontext->vc.obact->imat, plane_points[0]);
- plane_from_point_normal_v3(sgcontext->line.true_plane, plane_point_object_space, normal);
+ float plane_points[4][3];
+ float offset_plane_points[2][3];
+ sculpt_gesture_line_calculate_plane_points(
+ sgcontext, line_points, plane_points, offset_plane_points);
+
+ /* Calculate line plane and normal. */
+ const bool flip = sgcontext->line.flip ^ !sgcontext->vc.rv3d->is_persp;
+ sculpt_gesture_line_plane_from_tri(sgcontext->line.true_plane,
+ sgcontext,
+ flip,
+ plane_points[0],
+ plane_points[1],
+ plane_points[2]);
+
+ /* Calculate the side planes. */
+ sculpt_gesture_line_plane_from_tri(sgcontext->line.true_side_plane[0],
+ sgcontext,
+ false,
+ plane_points[1],
+ plane_points[0],
+ offset_plane_points[0]);
+ sculpt_gesture_line_plane_from_tri(sgcontext->line.true_side_plane[1],
+ sgcontext,
+ false,
+ plane_points[3],
+ plane_points[2],
+ offset_plane_points[1]);
return sgcontext;
}
@@ -545,14 +602,20 @@ static void sculpt_gesture_flip_for_symmetry_pass(SculptGestureContext *sgcontex
flip_v3_v3(sgcontext->view_normal, sgcontext->true_view_normal, symmpass);
flip_v3_v3(sgcontext->view_origin, sgcontext->true_view_origin, symmpass);
flip_plane(sgcontext->line.plane, sgcontext->line.true_plane, symmpass);
+ flip_plane(sgcontext->line.side_plane[0], sgcontext->line.true_side_plane[0], symmpass);
+ flip_plane(sgcontext->line.side_plane[1], sgcontext->line.true_side_plane[1], symmpass);
}
static void sculpt_gesture_update_effected_nodes_by_line_plane(SculptGestureContext *sgcontext)
{
SculptSession *ss = sgcontext->ss;
- float clip_planes[1][4];
+ float clip_planes[3][4];
copy_v4_v4(clip_planes[0], sgcontext->line.plane);
- PBVHFrustumPlanes frustum = {.planes = clip_planes, .num_planes = 1};
+ copy_v4_v4(clip_planes[1], sgcontext->line.side_plane[0]);
+ copy_v4_v4(clip_planes[2], sgcontext->line.side_plane[1]);
+
+ const int num_planes = sgcontext->line.use_side_planes ? 3 : 1;
+ PBVHFrustumPlanes frustum = {.planes = clip_planes, .num_planes = num_planes};
BKE_pbvh_search_gather(ss->pbvh,
BKE_pbvh_node_frustum_contain_AABB,
&frustum,
@@ -631,6 +694,11 @@ static bool sculpt_gesture_is_vertex_effected(SculptGestureContext *sgcontext, P
case SCULPT_GESTURE_SHAPE_LASSO:
return sculpt_gesture_is_effected_lasso(sgcontext, vd->co);
case SCULPT_GESTURE_SHAPE_LINE:
+ if (sgcontext->line.use_side_planes) {
+ return plane_point_side_v3(sgcontext->line.plane, vd->co) > 0.0f &&
+ plane_point_side_v3(sgcontext->line.side_plane[0], vd->co) > 0.0f &&
+ plane_point_side_v3(sgcontext->line.side_plane[1], vd->co) > 0.0f;
+ }
return plane_point_side_v3(sgcontext->line.plane, vd->co) > 0.0f;
}
return false;
@@ -639,7 +707,7 @@ static bool sculpt_gesture_is_vertex_effected(SculptGestureContext *sgcontext, P
static void sculpt_gesture_apply(bContext *C, SculptGestureContext *sgcontext)
{
SculptGestureOperation *operation = sgcontext->operation;
- SCULPT_undo_push_begin("Sculpt Gesture Apply");
+ SCULPT_undo_push_begin(CTX_data_active_object(C), "Sculpt Gesture Apply");
operation->sculpt_gesture_begin(C, sgcontext);
@@ -863,6 +931,24 @@ static EnumPropertyItem prop_trim_operation_types[] = {
{0, NULL, 0, NULL, NULL},
};
+typedef enum eSculptTrimOrientationType {
+ SCULPT_GESTURE_TRIM_ORIENTATION_VIEW,
+ SCULPT_GESTURE_TRIM_ORIENTATION_SURFACE,
+} eSculptTrimOrientationType;
+static EnumPropertyItem prop_trim_orientation_types[] = {
+ {SCULPT_GESTURE_TRIM_ORIENTATION_VIEW,
+ "VIEW",
+ 0,
+ "View",
+ "Use the view to orientate the trimming shape"},
+ {SCULPT_GESTURE_TRIM_ORIENTATION_SURFACE,
+ "SURFACE",
+ 0,
+ "Surface",
+ "Use the surface normal to orientate the trimming shape"},
+ {0, NULL, 0, NULL, NULL},
+};
+
typedef struct SculptGestureTrimOperation {
SculptGestureOperation op;
@@ -875,6 +961,7 @@ typedef struct SculptGestureTrimOperation {
bool use_cursor_depth;
eSculptTrimOperationType mode;
+ eSculptTrimOrientationType orientation;
} SculptGestureTrimOperation;
static void sculpt_gesture_trim_normals_update(SculptGestureContext *sgcontext)
@@ -911,6 +998,29 @@ static void sculpt_gesture_trim_normals_update(SculptGestureContext *sgcontext)
trim_operation->mesh = result;
}
+/* Get the origin and normal that are going to be used for calculating the depth and position the
+ * trimming geometry. */
+static void sculpt_gesture_trim_shape_origin_normal_get(SculptGestureContext *sgcontext,
+ float *r_origin,
+ float *r_normal)
+{
+ SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)sgcontext->operation;
+ /* 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.
+ */
+ switch (trim_operation->orientation) {
+ case SCULPT_GESTURE_TRIM_ORIENTATION_VIEW:
+ copy_v3_v3(r_origin, sgcontext->world_space_view_origin);
+ copy_v3_v3(r_normal, sgcontext->world_space_view_normal);
+ break;
+ case SCULPT_GESTURE_TRIM_ORIENTATION_SURFACE:
+ mul_v3_m4v3(r_origin, sgcontext->vc.obact->obmat, sgcontext->ss->gesture_initial_location);
+ mul_v3_m4v3(r_normal, sgcontext->vc.obact->obmat, sgcontext->ss->gesture_initial_normal);
+ break;
+ }
+}
+
static void sculpt_gesture_trim_calculate_depth(bContext *C, SculptGestureContext *sgcontext)
{
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)sgcontext->operation;
@@ -920,11 +1030,11 @@ static void sculpt_gesture_trim_calculate_depth(bContext *C, SculptGestureContex
const int totvert = SCULPT_vertex_count_get(ss);
- float view_plane[4];
- 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);
+ float shape_plane[4];
+ float shape_origin[3];
+ float shape_normal[3];
+ sculpt_gesture_trim_shape_origin_normal_get(sgcontext, shape_origin, shape_normal);
+ plane_from_point_normal_v3(shape_plane, shape_origin, shape_normal);
trim_operation->depth_front = FLT_MAX;
trim_operation->depth_back = -FLT_MAX;
@@ -936,7 +1046,7 @@ static void sculpt_gesture_trim_calculate_depth(bContext *C, SculptGestureContex
* 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);
+ const float dist = dist_signed_to_plane_v3(world_space_vco, shape_plane);
trim_operation->depth_front = min_ff(dist, trim_operation->depth_front);
trim_operation->depth_back = max_ff(dist, trim_operation->depth_back);
}
@@ -945,11 +1055,22 @@ static void sculpt_gesture_trim_calculate_depth(bContext *C, SculptGestureContex
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;
+
+ float mid_point_depth;
+ if (trim_operation->orientation == SCULPT_GESTURE_TRIM_ORIENTATION_VIEW) {
+ mid_point_depth = ss->gesture_initial_hit ?
+ dist_signed_to_plane_v3(world_space_gesture_initial_location,
+ shape_plane) :
+ (trim_operation->depth_back + trim_operation->depth_front) * 0.5f;
+ }
+ else {
+ /* When using normal orientation, if the stroke started over the mesh, position the mid point
+ * at 0 distance from the shape plane. This positions the trimming shape half inside of the
+ * surface. */
+ mid_point_depth = ss->gesture_initial_hit ?
+ 0.0f :
+ (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);
@@ -987,30 +1108,41 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
depth_back += 0.1f;
}
- /* 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;
+ float shape_origin[3];
+ float shape_normal[3];
+ float shape_plane[4];
+ sculpt_gesture_trim_shape_origin_normal_get(sgcontext, shape_origin, shape_normal);
+ plane_from_point_normal_v3(shape_plane, shape_origin, shape_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);
+ madd_v3_v3v3fl(depth_point, shape_origin, shape_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);
+ if (trim_operation->orientation == SCULPT_GESTURE_TRIM_ORIENTATION_VIEW) {
+ ED_view3d_win_to_3d(vc->v3d, region, depth_point, screen_points[i], new_point);
+ }
+ else {
+ ED_view3d_win_to_3d_on_plane(region, shape_plane, screen_points[i], false, new_point);
+ madd_v3_v3fl(new_point, shape_normal, depth_front);
+ }
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. */
- madd_v3_v3v3fl(depth_point, view_origin, view_normal, depth_back);
+ madd_v3_v3v3fl(depth_point, shape_origin, shape_normal, depth_back);
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);
+ if (trim_operation->orientation == SCULPT_GESTURE_TRIM_ORIENTATION_VIEW) {
+ ED_view3d_win_to_3d(vc->v3d, region, depth_point, screen_points[i], new_point);
+ }
+ else {
+ ED_view3d_win_to_3d_on_plane(region, shape_plane, screen_points[i], false, new_point);
+ madd_v3_v3fl(new_point, shape_normal, depth_back);
+ }
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);
}
@@ -1229,6 +1361,12 @@ static void sculpt_gesture_init_trim_properties(SculptGestureContext *sgcontext,
trim_operation->mode = RNA_enum_get(op->ptr, "trim_mode");
trim_operation->use_cursor_depth = RNA_boolean_get(op->ptr, "use_cursor_depth");
+ trim_operation->orientation = RNA_enum_get(op->ptr, "trim_orientation");
+
+ /* If the cursor was not over the mesh, force the orientation to view. */
+ if (!sgcontext->ss->gesture_initial_hit) {
+ trim_operation->orientation = SCULPT_GESTURE_TRIM_ORIENTATION_VIEW;
+ }
}
static void sculpt_trim_gesture_operator_properties(wmOperatorType *ot)
@@ -1245,6 +1383,12 @@ static void sculpt_trim_gesture_operator_properties(wmOperatorType *ot)
false,
"Use Cursor for Depth",
"Use cursor location and radius for the dimensions and position of the trimming shape");
+ RNA_def_enum(ot->srna,
+ "trim_orientation",
+ prop_trim_orientation_types,
+ SCULPT_GESTURE_TRIM_ORIENTATION_VIEW,
+ "Shape Orientation",
+ NULL);
}
/* Project Gesture Operation. */
@@ -1430,6 +1574,7 @@ static int sculpt_trim_gesture_box_invoke(bContext *C, wmOperator *op, const wmE
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);
+ copy_v3_v3(ss->gesture_initial_normal, sgi.normal);
}
return WM_gesture_box_invoke(C, op, event);
@@ -1465,6 +1610,7 @@ static int sculpt_trim_gesture_lasso_invoke(bContext *C, wmOperator *op, const w
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);
+ copy_v3_v3(ss->gesture_initial_normal, sgi.normal);
}
return WM_gesture_lasso_invoke(C, op, event);
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 75357214936..57b1102219e 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -717,7 +717,7 @@ static float paint_space_stroke_spacing(bContext *C,
spacing *= stroke->zoom_2d;
if (paint_stroke_use_scene_spacing(brush, mode)) {
- return max_ff(0.001f, size_clamp * spacing / 50.f);
+ return max_ff(0.001f, size_clamp * spacing / 50.0f);
}
return max_ff(stroke->zoom_2d, size_clamp * spacing / 50.0f);
}
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 7be84a5e191..2484f382ed4 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -64,7 +64,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-#include "RE_render_ext.h"
+#include "RE_texture.h"
#include "ED_image.h"
#include "ED_screen.h"
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 25b1764e562..9e9e0f441f7 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -372,7 +372,7 @@ static float wpaint_blend(const VPaint *wp,
if (do_flip) {
switch (blend) {
case IMB_BLEND_MIX:
- paintval = 1.f - paintval;
+ paintval = 1.0f - paintval;
break;
case IMB_BLEND_ADD:
blend = IMB_BLEND_SUB;
@@ -964,7 +964,7 @@ static void do_weight_paint_vertex_multi(
if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
index_mirr = mesh_get_x_mirror_vert(ob, NULL, index, topology);
- if (index_mirr != -1 && index_mirr != index) {
+ if (!ELEM(index_mirr, -1, index)) {
dv_mirr = &me->dvert[index_mirr];
}
else {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 8c03d147768..c33dfecd52c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -76,6 +76,11 @@
#include "IMB_colormanagement.h"
+#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
+#include "GPU_matrix.h"
+#include "GPU_state.h"
+
#include "WM_api.h"
#include "WM_message.h"
#include "WM_toolsystem.h"
@@ -84,6 +89,7 @@
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_sculpt.h"
+#include "ED_space_api.h"
#include "ED_view3d.h"
#include "paint_intern.h"
#include "sculpt_intern.h"
@@ -1174,6 +1180,7 @@ void SCULPT_floodfill_free(SculptFloodFill *flood)
flood->queue = NULL;
}
+/* -------------------------------------------------------------------- */
/** \name Tool Capabilities
*
* Avoid duplicate checks, internal logic only,
@@ -1395,6 +1402,7 @@ static void sculpt_project_v3_normal_align(SculptSession *ss,
grab_delta, ss->cache->sculpt_normal_symm, (len_signed * normal_weight) * len_view_scale);
}
+/* -------------------------------------------------------------------- */
/** \name SculptProjectVector
*
* Fast-path for #project_plane_v3_v3v3
@@ -1902,6 +1910,7 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache *cache)
return 1.0f;
}
+/* -------------------------------------------------------------------- */
/** \name Calculate Normal and Center
*
* Calculate geometry surrounding the brush center.
@@ -2353,7 +2362,7 @@ static float brush_strength(const Sculpt *sd,
final_pressure = pressure * pressure;
return final_pressure * overlap * feather;
case SCULPT_TOOL_SMEAR:
- return pressure * overlap * feather;
+ return alpha * pressure * overlap * feather;
case SCULPT_TOOL_CLAY_STRIPS:
/* Clay Strips needs less strength to compensate the curve. */
final_pressure = powf(pressure, 1.5f);
@@ -3025,6 +3034,7 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
}
}
+/* -------------------------------------------------------------------- */
/** \name Sculpt Multires Displacement Eraser Brush
* \{ */
@@ -3247,7 +3257,6 @@ static void do_draw_sharp_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
}
/* -------------------------------------------------------------------- */
-
/** \name Sculpt Topology Brush
* \{ */
@@ -3823,20 +3832,33 @@ static void do_grab_brush_task_cb_ex(void *__restrict userdata,
ss, &test, data->brush->falloff_shape);
const int thread_id = BLI_task_parallel_thread_id(tls);
+ const bool grab_silhouette = brush->flag2 & BRUSH_GRAB_SILHOUETTE;
+
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
SCULPT_orig_vert_data_update(&orig_data, &vd);
if (sculpt_brush_test_sq_fn(&test, orig_data.co)) {
- const float fade = bstrength * SCULPT_brush_strength_factor(ss,
- brush,
- orig_data.co,
- sqrtf(test.dist),
- orig_data.no,
- NULL,
- vd.mask ? *vd.mask : 0.0f,
- vd.index,
- thread_id);
+ float fade = bstrength * SCULPT_brush_strength_factor(ss,
+ brush,
+ orig_data.co,
+ sqrtf(test.dist),
+ orig_data.no,
+ NULL,
+ vd.mask ? *vd.mask : 0.0f,
+ vd.index,
+ thread_id);
+
+ if (grab_silhouette) {
+ float silhouette_test_dir[3];
+ normalize_v3_v3(silhouette_test_dir, grab_delta);
+ if (dot_v3v3(ss->cache->initial_normal, ss->cache->grab_delta_symmetry) < 0.0f) {
+ mul_v3_fl(silhouette_test_dir, -1.0f);
+ }
+ float vno[3];
+ normal_short_to_float_v3(vno, orig_data.no);
+ fade *= max_ff(dot_v3v3(vno, silhouette_test_dir), 0.0f);
+ }
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
@@ -3903,7 +3925,7 @@ static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata,
if (brush->elastic_deform_type == BRUSH_ELASTIC_DEFORM_TWIST) {
int symm = ss->cache->mirror_symmetry_pass;
- if (symm == 1 || symm == 2 || symm == 4 || symm == 7) {
+ if (ELEM(symm, 1, 2, 4, 7)) {
dir = -dir;
}
}
@@ -4770,7 +4792,6 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
}
/* -------------------------------------------------------------------- */
-
/** \name Sculpt Clay Brush
* \{ */
@@ -5295,7 +5316,6 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
}
/* -------------------------------------------------------------------- */
-
/** \name Sculpt Clay Thumb Brush
* \{ */
@@ -5684,15 +5704,11 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
/* Check for unsupported features. */
PBVHType type = BKE_pbvh_type(ss->pbvh);
if (brush->sculpt_tool == SCULPT_TOOL_PAINT && type != PBVH_FACES) {
- if (!U.experimental.use_sculpt_vertex_colors) {
- return;
- }
+ return;
}
if (brush->sculpt_tool == SCULPT_TOOL_SMEAR && type != PBVH_FACES) {
- if (!U.experimental.use_sculpt_vertex_colors) {
- return;
- }
+ return;
}
/* Build a list of all nodes that are potentially within the brush's area of influence */
@@ -7682,7 +7698,7 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
sculpt_update_cache_invariants(C, sd, ss, op, mouse);
- SCULPT_undo_push_begin(sculpt_tool_name(sd));
+ SCULPT_undo_push_begin(ob, sculpt_tool_name(sd));
return true;
}
@@ -8041,7 +8057,7 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *op)
* as deleted, then after symmetrize operation all BMesh elements
* are logged as added (as opposed to attempting to store just the
* parts that symmetrize modifies). */
- SCULPT_undo_push_begin("Dynamic topology symmetrize");
+ SCULPT_undo_push_begin(ob, "Dynamic topology symmetrize");
SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_SYMMETRIZE);
BM_log_before_all_removed(ss->bm, ss->bm_log);
@@ -8144,6 +8160,7 @@ static void SCULPT_OT_symmetrize(wmOperatorType *ot)
/**** Toggle operator for turning sculpt mode on or off ****/
+/** \warning Expects a fully evaluated depsgraph. */
static void sculpt_init_session(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
/* Create persistent sculpt mode data. */
@@ -8208,6 +8225,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
if (flush_recalc) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ BKE_scene_graph_evaluated_ensure(depsgraph, bmain);
}
/* Create sculpt mode session data. */
@@ -8215,10 +8233,6 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
BKE_sculptsession_free(ob);
}
- /* Make sure derived final from original object does not reference possibly
- * 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);
@@ -8283,7 +8297,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
bool has_undo = wm->undo_stack != NULL;
/* Undo push is needed to prevent memory leak. */
if (has_undo) {
- SCULPT_undo_push_begin("Dynamic topology enable");
+ SCULPT_undo_push_begin(ob, "Dynamic topology enable");
}
SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob);
if (has_undo) {
@@ -8399,7 +8413,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
* while it works it causes lag when undoing the first undo step, see T71564. */
wmWindowManager *wm = CTX_wm_manager(C);
if (wm->op_undo_depth <= 1) {
- SCULPT_undo_push_begin(op->type->name);
+ SCULPT_undo_push_begin(ob, op->type->name);
}
}
}
@@ -9192,7 +9206,7 @@ static int sculpt_mask_by_color_invoke(bContext *C, wmOperator *op, const wmEven
mouse[1] = event->mval[1];
SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
- SCULPT_undo_push_begin("Mask by color");
+ SCULPT_undo_push_begin(ob, "Mask by color");
const int active_vertex = SCULPT_active_vertex_get(ss);
const float threshold = RNA_float_get(op->ptr, "threshold");
@@ -9249,6 +9263,335 @@ static void SCULPT_OT_mask_by_color(wmOperatorType *ot)
1.0f);
}
+/* -------------------------------------------------------------------- */
+/** \name Dyntopo Detail Size Edit Operator
+ * \{ */
+
+/* Defines how much the mouse movement will modify the detail size value. */
+#define DETAIL_SIZE_DELTA_SPEED 0.08f
+#define DETAIL_SIZE_DELTA_ACCURATE_SPEED 0.004f
+
+typedef struct DyntopoDetailSizeEditCustomData {
+ void *draw_handle;
+ Object *active_object;
+
+ float init_mval[2];
+ float accurate_mval[2];
+
+ float outline_col[4];
+
+ bool accurate_mode;
+ bool sample_mode;
+
+ float init_detail_size;
+ float accurate_detail_size;
+ float detail_size;
+ float radius;
+
+ float preview_tri[3][3];
+ float gizmo_mat[4][4];
+} DyntopoDetailSizeEditCustomData;
+
+static void dyntopo_detail_size_parallel_lines_draw(uint pos3d,
+ DyntopoDetailSizeEditCustomData *cd,
+ const float start_co[3],
+ const float end_co[3],
+ bool flip,
+ const float angle)
+{
+ float object_space_constant_detail = 1.0f /
+ (cd->detail_size * mat4_to_scale(cd->active_object->obmat));
+
+ /* The constant detail represents the maximum edge length allowed before subdividing it. If the
+ * triangle grid preview is created with this value it will represent an ideal mesh density where
+ * all edges have the exact maximum length, which never happens in practice. As the minimum edge
+ * length for dyntopo is 0.4 * max_edge_length, this adjust the detail size to the average
+ * between max and min edge length so the preview is more accurate. */
+ object_space_constant_detail *= 0.7f;
+
+ const float total_len = len_v3v3(cd->preview_tri[0], cd->preview_tri[1]);
+ const int tot_lines = (int)(total_len / object_space_constant_detail) + 1;
+ const float tot_lines_fl = total_len / object_space_constant_detail;
+ float spacing_disp[3];
+ sub_v3_v3v3(spacing_disp, end_co, start_co);
+ normalize_v3(spacing_disp);
+
+ float line_disp[3];
+ rotate_v2_v2fl(line_disp, spacing_disp, DEG2RAD(angle));
+ mul_v3_fl(spacing_disp, total_len / tot_lines_fl);
+
+ immBegin(GPU_PRIM_LINES, (uint)tot_lines * 2);
+ for (int i = 0; i < tot_lines; i++) {
+ float line_length;
+ if (flip) {
+ line_length = total_len * ((float)i / (float)tot_lines_fl);
+ }
+ else {
+ line_length = total_len * (1.0f - ((float)i / (float)tot_lines_fl));
+ }
+ float line_start[3];
+ copy_v3_v3(line_start, start_co);
+ madd_v3_v3v3fl(line_start, line_start, spacing_disp, i);
+ float line_end[3];
+ madd_v3_v3v3fl(line_end, line_start, line_disp, line_length);
+ immVertex3fv(pos3d, line_start);
+ immVertex3fv(pos3d, line_end);
+ }
+ immEnd();
+}
+
+static void dyntopo_detail_size_edit_draw(const bContext *UNUSED(C),
+ ARegion *UNUSED(ar),
+ void *arg)
+{
+ DyntopoDetailSizeEditCustomData *cd = arg;
+ GPU_blend(GPU_BLEND_ALPHA);
+ GPU_line_smooth(true);
+
+ uint pos3d = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+ GPU_matrix_push();
+ GPU_matrix_mul(cd->gizmo_mat);
+
+ /* Draw Cursor */
+ immUniformColor4fv(cd->outline_col);
+ GPU_line_width(3.0f);
+
+ imm_draw_circle_wire_3d(pos3d, 0, 0, cd->radius, 80);
+
+ /* Draw Triangle. */
+ immUniformColor4f(0.9f, 0.9f, 0.9f, 0.8f);
+ immBegin(GPU_PRIM_LINES, 6);
+ immVertex3fv(pos3d, cd->preview_tri[0]);
+ immVertex3fv(pos3d, cd->preview_tri[1]);
+
+ immVertex3fv(pos3d, cd->preview_tri[1]);
+ immVertex3fv(pos3d, cd->preview_tri[2]);
+
+ immVertex3fv(pos3d, cd->preview_tri[2]);
+ immVertex3fv(pos3d, cd->preview_tri[0]);
+ immEnd();
+
+ /* Draw Grid */
+ GPU_line_width(1.0f);
+ dyntopo_detail_size_parallel_lines_draw(
+ pos3d, cd, cd->preview_tri[0], cd->preview_tri[1], false, 60.0f);
+ dyntopo_detail_size_parallel_lines_draw(
+ pos3d, cd, cd->preview_tri[0], cd->preview_tri[1], true, 120.0f);
+ dyntopo_detail_size_parallel_lines_draw(
+ pos3d, cd, cd->preview_tri[0], cd->preview_tri[2], false, -60.0f);
+
+ immUnbindProgram();
+ GPU_matrix_pop();
+ GPU_blend(GPU_BLEND_NONE);
+ GPU_line_smooth(false);
+}
+
+static void dyntopo_detail_size_edit_cancel(bContext *C, wmOperator *op)
+{
+ Object *active_object = CTX_data_active_object(C);
+ SculptSession *ss = active_object->sculpt;
+ ARegion *ar = CTX_wm_region(C);
+ DyntopoDetailSizeEditCustomData *cd = op->customdata;
+ ED_region_draw_cb_exit(ar->type, cd->draw_handle);
+ ss->draw_faded_cursor = false;
+ MEM_freeN(op->customdata);
+ ED_workspace_status_text(C, NULL);
+}
+
+static void dyntopo_detail_size_sample_from_surface(Object *ob,
+ DyntopoDetailSizeEditCustomData *cd)
+{
+ SculptSession *ss = ob->sculpt;
+ const int active_vertex = SCULPT_active_vertex_get(ss);
+
+ float len_accum = 0;
+ int num_neighbors = 0;
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, active_vertex, ni) {
+ len_accum += len_v3v3(SCULPT_vertex_co_get(ss, active_vertex),
+ SCULPT_vertex_co_get(ss, ni.index));
+ num_neighbors++;
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+
+ if (num_neighbors > 0) {
+ const float avg_edge_len = len_accum / num_neighbors;
+ /* Use 0.7 as the average of min and max dyntopo edge length. */
+ const float detail_size = 0.7f / (avg_edge_len * mat4_to_scale(cd->active_object->obmat));
+ cd->detail_size = clamp_f(detail_size, 1.0f, 500.0f);
+ }
+}
+
+static void dyntopo_detail_size_update_from_mouse_delta(DyntopoDetailSizeEditCustomData *cd,
+ const wmEvent *event)
+{
+ const float mval[2] = {event->mval[0], event->mval[1]};
+
+ float detail_size_delta;
+ if (cd->accurate_mode) {
+ detail_size_delta = mval[0] - cd->accurate_mval[0];
+ cd->detail_size = cd->accurate_detail_size +
+ detail_size_delta * DETAIL_SIZE_DELTA_ACCURATE_SPEED;
+ }
+ else {
+ detail_size_delta = mval[0] - cd->init_mval[0];
+ cd->detail_size = cd->init_detail_size + detail_size_delta * DETAIL_SIZE_DELTA_SPEED;
+ }
+
+ if (event->type == EVT_LEFTSHIFTKEY && event->val == KM_PRESS) {
+ cd->accurate_mode = true;
+ copy_v2_v2(cd->accurate_mval, mval);
+ cd->accurate_detail_size = cd->detail_size;
+ }
+ if (event->type == EVT_LEFTSHIFTKEY && event->val == KM_RELEASE) {
+ cd->accurate_mode = false;
+ cd->accurate_detail_size = 0.0f;
+ }
+
+ cd->detail_size = clamp_f(cd->detail_size, 1.0f, 500.0f);
+}
+
+static int dyntopo_detail_size_edit_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Object *active_object = CTX_data_active_object(C);
+ SculptSession *ss = active_object->sculpt;
+ ARegion *ar = CTX_wm_region(C);
+ DyntopoDetailSizeEditCustomData *cd = op->customdata;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+
+ /* Cancel modal operator */
+ if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) ||
+ (event->type == RIGHTMOUSE && event->val == KM_PRESS)) {
+ dyntopo_detail_size_edit_cancel(C, op);
+ ED_region_tag_redraw(ar);
+ return OPERATOR_FINISHED;
+ }
+
+ /* Finish modal operator */
+ if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) ||
+ (event->type == EVT_RETKEY && event->val == KM_PRESS) ||
+ (event->type == EVT_PADENTER && event->val == KM_PRESS)) {
+ ED_region_draw_cb_exit(ar->type, cd->draw_handle);
+ sd->constant_detail = cd->detail_size;
+ ss->draw_faded_cursor = false;
+ MEM_freeN(op->customdata);
+ ED_region_tag_redraw(ar);
+ ED_workspace_status_text(C, NULL);
+ return OPERATOR_FINISHED;
+ }
+
+ ED_region_tag_redraw(ar);
+
+ if (event->type == EVT_LEFTCTRLKEY && event->val == KM_PRESS) {
+ cd->sample_mode = true;
+ }
+ if (event->type == EVT_LEFTCTRLKEY && event->val == KM_RELEASE) {
+ cd->sample_mode = false;
+ }
+
+ /* Sample mode sets the detail size sampling the average edge length under the surface. */
+ if (cd->sample_mode) {
+ dyntopo_detail_size_sample_from_surface(active_object, cd);
+ return OPERATOR_RUNNING_MODAL;
+ }
+ /* Regular mode, changes the detail size by moving the cursor. */
+ dyntopo_detail_size_update_from_mouse_delta(cd, event);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int dyntopo_detail_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ ARegion *ar = CTX_wm_region(C);
+ Object *active_object = CTX_data_active_object(C);
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Brush *brush = BKE_paint_brush(&sd->paint);
+
+ DyntopoDetailSizeEditCustomData *cd = MEM_callocN(sizeof(DyntopoDetailSizeEditCustomData),
+ "Dyntopo Detail Size Edit OP Custom Data");
+
+ /* Initial operator Custom Data setup. */
+ cd->draw_handle = ED_region_draw_cb_activate(
+ ar->type, dyntopo_detail_size_edit_draw, cd, REGION_DRAW_POST_VIEW);
+ cd->active_object = active_object;
+ cd->init_mval[0] = event->mval[0];
+ cd->init_mval[1] = event->mval[1];
+ cd->detail_size = sd->constant_detail;
+ cd->init_detail_size = sd->constant_detail;
+ copy_v4_v4(cd->outline_col, brush->add_col);
+ op->customdata = cd;
+
+ SculptSession *ss = active_object->sculpt;
+ cd->radius = ss->cursor_radius;
+
+ /* Generates the matrix to position the gizmo in the surface of the mesh using the same location
+ * and orientation as the brush cursor. */
+ float cursor_trans[4][4], cursor_rot[4][4];
+ const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f};
+ float quat[4];
+ copy_m4_m4(cursor_trans, active_object->obmat);
+ translate_m4(
+ cursor_trans, ss->cursor_location[0], ss->cursor_location[1], ss->cursor_location[2]);
+
+ float cursor_normal[3];
+ if (!is_zero_v3(ss->cursor_sampled_normal)) {
+ copy_v3_v3(cursor_normal, ss->cursor_sampled_normal);
+ }
+ else {
+ copy_v3_v3(cursor_normal, ss->cursor_normal);
+ }
+
+ rotation_between_vecs_to_quat(quat, z_axis, cursor_normal);
+ quat_to_mat4(cursor_rot, quat);
+ copy_m4_m4(cd->gizmo_mat, cursor_trans);
+ mul_m4_m4_post(cd->gizmo_mat, cursor_rot);
+
+ /* Initize the position of the triangle vertices. */
+ const float y_axis[3] = {0.0f, cd->radius, 0.0f};
+ for (int i = 0; i < 3; i++) {
+ zero_v3(cd->preview_tri[i]);
+ rotate_v2_v2fl(cd->preview_tri[i], y_axis, DEG2RAD(120.0f * i));
+ }
+
+ SCULPT_vertex_random_access_ensure(ss);
+
+ WM_event_add_modal_handler(C, op);
+ ED_region_tag_redraw(ar);
+
+ ss->draw_faded_cursor = true;
+
+ const char *status_str = TIP_(
+ "Move the mouse to change the dyntopo detail size. LMB: confirm size, ESC/RMB: cancel");
+ ED_workspace_status_text(C, status_str);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static bool dyntopo_detail_size_edit_poll(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+
+ return SCULPT_mode_poll(C) && ob->sculpt->bm && (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT);
+}
+
+static void SCULPT_OT_dyntopo_detail_size_edit(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Edit Dyntopo Detail Size";
+ ot->description = "Modify the constant detail size of dyntopo interactively";
+ ot->idname = "SCULPT_OT_dyntopo_detail_size_edit";
+
+ /* api callbacks */
+ ot->poll = dyntopo_detail_size_edit_poll;
+ ot->invoke = dyntopo_detail_size_edit_invoke;
+ ot->modal = dyntopo_detail_size_edit_modal;
+ ot->cancel = dyntopo_detail_size_edit_cancel;
+
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
void ED_operatortypes_sculpt(void)
{
WM_operatortype_append(SCULPT_OT_brush_stroke);
@@ -9282,4 +9625,5 @@ void ED_operatortypes_sculpt(void)
WM_operatortype_append(SCULPT_OT_vertex_to_loop_colors);
WM_operatortype_append(SCULPT_OT_color_filter);
WM_operatortype_append(SCULPT_OT_mask_by_color);
+ WM_operatortype_append(SCULPT_OT_dyntopo_detail_size_edit);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index 67129d5da50..f8165890cc4 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -139,14 +139,14 @@ static float cloth_brush_simulation_falloff_get(const Brush *brush,
const float falloff = radius + (radius * brush->cloth_sim_limit * brush->cloth_sim_falloff);
if (distance > limit) {
- /* Outiside the limits. */
+ /* Outside the limits. */
return 0.0f;
}
if (distance < falloff) {
/* Before the falloff area. */
return 1.0f;
}
- /* Do a smoothstep transition inside the falloff area. */
+ /* Do a smooth-step transition inside the falloff area. */
float p = 1.0f - ((distance - falloff) / (limit - falloff));
return 3.0f * p * p - 2.0f * p * p * p;
}
@@ -214,7 +214,7 @@ static void cloth_brush_add_length_constraint(SculptSession *ss,
/* Reallocation if the array capacity is exceeded. */
cloth_brush_reallocate_constraints(cloth_sim);
- /* Add the constraint to the GSet to avoid creating it again. */
+ /* Add the constraint to the #GSet to avoid creating it again. */
BLI_edgeset_add(cloth_sim->created_length_constraints, v1, v2);
}
@@ -326,12 +326,15 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
* positions. */
const bool cloth_is_deform_brush = ss->cache != NULL && brush != NULL &&
SCULPT_is_cloth_deform_brush(brush);
+
+ const bool use_falloff_plane = brush->cloth_force_falloff_type ==
+ BRUSH_CLOTH_FORCE_FALLOFF_PLANE;
float radius_squared = 0.0f;
if (cloth_is_deform_brush) {
radius_squared = ss->cache->initial_radius * ss->cache->initial_radius;
}
- /* Only limit the contraint creation to a radius when the simulation is local. */
+ /* Only limit the constraint creation to a radius when the simulation is local. */
const float cloth_sim_radius_squared = brush->cloth_simulation_area_type ==
BRUSH_CLOTH_SIMULATION_AREA_LOCAL ?
data->cloth_sim_radius * data->cloth_sim_radius :
@@ -380,12 +383,21 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
if (brush && brush->sculpt_tool == SCULPT_TOOL_CLOTH) {
/* The cloth brush works by applying forces in most of its modes, but some of them require
* deformation coordinates to make the simulation stable. */
- if (brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_GRAB && len_squared < radius_squared) {
- /* 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_DEFORMATION_GRAB_STRENGTH);
+ if (brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_GRAB) {
+ if (use_falloff_plane) {
+ /* With plane falloff the strength of the constraints is set when applying the
+ * deformation forces. */
+ cloth_brush_add_deformation_constraint(
+ data->cloth_sim, node_index, vd.index, CLOTH_DEFORMATION_GRAB_STRENGTH);
+ }
+ else if (len_squared < radius_squared) {
+ /* With radial falloff 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_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
@@ -436,9 +448,8 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
const float *grab_delta = data->grab_delta;
float(*imat)[4] = data->mat;
- const bool use_falloff_plane = !SCULPT_is_cloth_deform_brush(brush) &&
- brush->cloth_force_falloff_type ==
- BRUSH_CLOTH_FORCE_FALLOFF_PLANE;
+ const bool use_falloff_plane = brush->cloth_force_falloff_type ==
+ BRUSH_CLOTH_FORCE_FALLOFF_PLANE;
PBVHVertexIter vd;
const float bstrength = ss->cache->bstrength;
@@ -448,7 +459,7 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
ss, &test, data->brush->falloff_shape);
const int thread_id = BLI_task_parallel_thread_id(tls);
- /* For Pich Perpendicular Deform Type. */
+ /* For Pinch Perpendicular Deform Type. */
float x_object_space[3];
float z_object_space[3];
if (brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_PINCH_PERPENDICULAR) {
@@ -470,12 +481,6 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
madd_v3_v3fl(gravity, ss->cache->gravity_direction, -data->sd->gravity_factor);
}
- /* Original data for deform brushes. */
- SculptOrigVertData orig_data;
- if (SCULPT_is_cloth_deform_brush(brush)) {
- SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]);
- }
-
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
float force[3];
@@ -486,8 +491,7 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
float current_vertex_location[3];
if (brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_GRAB) {
- SCULPT_orig_vert_data_update(&orig_data, &vd);
- copy_v3_v3(current_vertex_location, orig_data.co);
+ copy_v3_v3(current_vertex_location, ss->cache->cloth_sim->init_pos[vd.index]);
}
else {
copy_v3_v3(current_vertex_location, vd.co);
@@ -504,7 +508,7 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
float dist = sqrtf(test.dist);
if (use_falloff_plane) {
- dist = dist_to_plane_v3(vd.co, deform_plane);
+ dist = dist_to_plane_v3(current_vertex_location, deform_plane);
}
const float fade = sim_factor * bstrength *
@@ -539,9 +543,15 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
break;
case BRUSH_CLOTH_DEFORM_GRAB:
madd_v3_v3v3fl(cloth_sim->deformation_pos[vd.index],
- orig_data.co,
+ cloth_sim->init_pos[vd.index],
ss->cache->grab_delta_symmetry,
fade);
+ if (use_falloff_plane) {
+ cloth_sim->deformation_strength[vd.index] = clamp_f(fade, 0.0f, 1.0f);
+ }
+ else {
+ cloth_sim->deformation_strength[vd.index] = 1.0f;
+ }
zero_v3(force);
break;
case BRUSH_CLOTH_DEFORM_SNAKE_HOOK:
@@ -920,7 +930,7 @@ static void cloth_brush_apply_brush_foces(Sculpt *sd, Object *ob, PBVHNode **nod
BKE_curvemapping_init(brush->curve);
- /* Init the grab delta. */
+ /* Initialize the grab delta. */
copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
normalize_v3(grab_delta);
@@ -930,7 +940,7 @@ static void cloth_brush_apply_brush_foces(Sculpt *sd, Object *ob, PBVHNode **nod
return;
}
- /* Calcuate push offset. */
+ /* Calculate push offset. */
if (brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_PUSH) {
mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
@@ -944,7 +954,7 @@ static void cloth_brush_apply_brush_foces(Sculpt *sd, Object *ob, PBVHNode **nod
brush->cloth_force_falloff_type == BRUSH_CLOTH_FORCE_FALLOFF_PLANE) {
SCULPT_calc_brush_plane(sd, ob, nodes, totnode, area_no, area_co);
- /* Init stroke local space matrix. */
+ /* Initialize stroke local space matrix. */
cross_v3_v3v3(mat[0], area_no, ss->cache->grab_delta_symmetry);
mat[0][3] = 0.0f;
cross_v3_v3v3(mat[1], area_no, mat[0]);
@@ -965,8 +975,8 @@ static void cloth_brush_apply_brush_foces(Sculpt *sd, Object *ob, PBVHNode **nod
}
}
- if (brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_SNAKE_HOOK) {
- /* Set the deformation strength to 0. Snake hook will initialize the strength in the required
+ if (ELEM(brush->cloth_deform_type, BRUSH_CLOTH_DEFORM_SNAKE_HOOK, BRUSH_CLOTH_DEFORM_GRAB)) {
+ /* Set the deformation strength to 0. Brushes will initialize the strength in the required
* area. */
const int totverts = SCULPT_vertex_count_get(ss);
for (int i = 0; i < totverts; i++) {
@@ -1058,7 +1068,7 @@ void SCULPT_cloth_brush_ensure_nodes_constraints(
PBVHNode **nodes,
int totnode,
SculptClothSimulation *cloth_sim,
- /* Cannot be const, because it is assigned to a non-const variable.
+ /* Cannot be `const`, because it is assigned to a `non-const` variable.
* NOLINTNEXTLINE: readability-non-const-parameter. */
float initial_location[3],
const float radius)
@@ -1178,7 +1188,7 @@ void SCULPT_do_cloth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
sculpt_cloth_ensure_constraints_in_simulation_area(sd, ob, nodes, totnode);
}
/* The first step of a symmetry pass is never simulated as deformation modes need valid delta
- * for brush tip alignement. */
+ * for brush tip alignment. */
return;
}
@@ -1253,9 +1263,14 @@ void SCULPT_cloth_plane_falloff_preview_draw(const uint gpuattr,
const float outline_col[3],
float outline_alpha)
{
- float local_mat_inv[4][4];
- invert_m4_m4(local_mat_inv, ss->cache->stroke_local_mat);
- GPU_matrix_mul(ss->cache->stroke_local_mat);
+ float local_mat[4][4];
+ copy_m4_m4(local_mat, ss->cache->stroke_local_mat);
+
+ if (ss->cache->brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_GRAB) {
+ add_v3_v3v3(local_mat[3], ss->cache->true_location, ss->cache->grab_delta);
+ }
+
+ GPU_matrix_mul(local_mat);
const float dist = ss->cache->radius;
const float arrow_x = ss->cache->radius * 0.2f;
@@ -1299,7 +1314,7 @@ static EnumPropertyItem prop_cloth_filter_type[] = {
"SCALE",
0,
"Scale",
- "Scales the mesh as a softbody using the origin of the object as scale"},
+ "Scales the mesh as a soft-body using the origin of the object as scale"},
{0, NULL, 0, NULL, NULL},
};
@@ -1533,7 +1548,7 @@ static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent
/* Needs mask data to be available as it is used when solving the constraints. */
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, false);
- SCULPT_undo_push_begin("Cloth filter");
+ SCULPT_undo_push_begin(ob, "Cloth filter");
SCULPT_filter_cache_init(C, ob, sd, SCULPT_UNDO_COORDS);
ss->filter_cache->automasking = SCULPT_automasking_cache_init(sd, NULL, ob);
diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.c b/source/blender/editors/sculpt_paint/sculpt_detail.c
index 8bbd90daaf8..ddf5b39f080 100644
--- a/source/blender/editors/sculpt_paint/sculpt_detail.c
+++ b/source/blender/editors/sculpt_paint/sculpt_detail.c
@@ -122,7 +122,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
float object_space_constant_detail = 1.0f / (sd->constant_detail * mat4_to_scale(ob->obmat));
BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail);
- SCULPT_undo_push_begin("Dynamic topology flood fill");
+ SCULPT_undo_push_begin(ob, "Dynamic topology flood fill");
SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_COORDS);
while (BKE_pbvh_bmesh_update_topology(
diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
index 22bcbcc3bf1..87e0ea7f6a9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
@@ -291,7 +291,7 @@ void sculpt_dynamic_topology_disable_with_undo(Main *bmain,
/* May be false in background mode. */
const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true;
if (use_undo) {
- SCULPT_undo_push_begin("Dynamic topology disable");
+ SCULPT_undo_push_begin(ob, "Dynamic topology disable");
SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END);
}
SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, NULL);
@@ -311,7 +311,7 @@ static void sculpt_dynamic_topology_enable_with_undo(Main *bmain,
/* May be false in background mode. */
const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true;
if (use_undo) {
- SCULPT_undo_push_begin("Dynamic topology enable");
+ SCULPT_undo_push_begin(ob, "Dynamic topology enable");
}
SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob);
if (use_undo) {
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c
index a9a2b1af2b1..c05dace380a 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -331,7 +331,7 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- SCULPT_undo_push_begin("face set change");
+ SCULPT_undo_push_begin(ob, "face set change");
SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
const int next_face_set = SCULPT_face_set_next_available_get(ss);
@@ -687,7 +687,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- SCULPT_undo_push_begin("face set change");
+ SCULPT_undo_push_begin(ob, "face set change");
SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
const float threshold = RNA_float_get(op->ptr, "threshold");
@@ -832,7 +832,7 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op)
const int mode = RNA_enum_get(op->ptr, "mode");
const int active_face_set = SCULPT_active_face_set_get(ss);
- SCULPT_undo_push_begin("Hide area");
+ SCULPT_undo_push_begin(ob, "Hide area");
PBVH *pbvh = ob->sculpt->pbvh;
PBVHNode **nodes;
@@ -1023,6 +1023,7 @@ void SCULPT_OT_face_sets_randomize_colors(wmOperatorType *ot)
typedef enum eSculptFaceSetEditMode {
SCULPT_FACE_SET_EDIT_GROW = 0,
SCULPT_FACE_SET_EDIT_SHRINK = 1,
+ SCULPT_FACE_SET_EDIT_DELETE_GEOMETRY = 2,
} eSculptFaceSetEditMode;
static EnumPropertyItem prop_sculpt_face_sets_edit_types[] = {
@@ -1040,6 +1041,13 @@ static EnumPropertyItem prop_sculpt_face_sets_edit_types[] = {
"Shrink Face Set",
"Shrinks the Face Sets boundary by one face based on mesh topology",
},
+ {
+ SCULPT_FACE_SET_EDIT_DELETE_GEOMETRY,
+ "DELETE_GEOMETRY",
+ 0,
+ "Delete Geometry",
+ "Deletes the faces that are assigned to the Face Set",
+ },
{0, NULL, 0, NULL, NULL},
};
@@ -1101,6 +1109,78 @@ static void sculpt_face_set_shrink(Object *ob,
}
}
+static bool check_single_face_set(SculptSession *ss, int *face_sets, const bool check_visible_only)
+{
+
+ int first_face_set = SCULPT_FACE_SET_NONE;
+ if (check_visible_only) {
+ for (int f = 0; f < ss->totfaces; f++) {
+ if (face_sets[f] > 0) {
+ first_face_set = face_sets[f];
+ break;
+ }
+ }
+ }
+ else {
+ first_face_set = abs(face_sets[0]);
+ }
+
+ if (first_face_set == SCULPT_FACE_SET_NONE) {
+ return true;
+ }
+
+ for (int f = 0; f < ss->totfaces; f++) {
+ const int face_set_id = check_visible_only ? face_sets[f] : abs(face_sets[f]);
+ if (face_set_id != first_face_set) {
+ return false;
+ }
+ }
+ return true;
+}
+
+static void sculpt_face_set_delete_geometry(Object *ob,
+ SculptSession *ss,
+ const int active_face_set_id,
+ const bool modify_hidden)
+{
+
+ Mesh *mesh = ob->data;
+ const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh);
+ BMesh *bm = BM_mesh_create(&allocsize,
+ &((struct BMeshCreateParams){
+ .use_toolflags = true,
+ }));
+
+ BM_mesh_bm_from_me(bm,
+ mesh,
+ (&(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ }));
+
+ BM_mesh_elem_table_init(bm, BM_FACE);
+ BM_mesh_elem_table_ensure(bm, BM_FACE);
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
+ BMIter iter;
+ BMFace *f;
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ const int face_index = BM_elem_index_get(f);
+ const int face_set_id = modify_hidden ? abs(ss->face_sets[face_index]) :
+ ss->face_sets[face_index];
+ BM_elem_flag_set(f, BM_ELEM_TAG, face_set_id == active_face_set_id);
+ }
+ BM_mesh_delete_hflag_context(bm, BM_ELEM_TAG, DEL_FACES);
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false);
+
+ BM_mesh_bm_to_me(NULL,
+ bm,
+ ob->data,
+ (&(struct BMeshToMeshParams){
+ .calc_object_remap = false,
+ }));
+
+ BM_mesh_free(bm);
+}
+
static void sculpt_face_set_apply_edit(Object *ob,
const int active_face_set_id,
const int mode,
@@ -1108,80 +1188,135 @@ static void sculpt_face_set_apply_edit(Object *ob,
{
SculptSession *ss = ob->sculpt;
- int *prev_face_sets = MEM_dupallocN(ss->face_sets);
-
switch (mode) {
- case SCULPT_FACE_SET_EDIT_GROW:
+ case SCULPT_FACE_SET_EDIT_GROW: {
+ int *prev_face_sets = MEM_dupallocN(ss->face_sets);
sculpt_face_set_grow(ob, ss, prev_face_sets, active_face_set_id, modify_hidden);
+ MEM_SAFE_FREE(prev_face_sets);
break;
- case SCULPT_FACE_SET_EDIT_SHRINK:
+ }
+ case SCULPT_FACE_SET_EDIT_SHRINK: {
+ int *prev_face_sets = MEM_dupallocN(ss->face_sets);
sculpt_face_set_shrink(ob, ss, prev_face_sets, active_face_set_id, modify_hidden);
+ MEM_SAFE_FREE(prev_face_sets);
+ break;
+ }
+ case SCULPT_FACE_SET_EDIT_DELETE_GEOMETRY:
+ sculpt_face_set_delete_geometry(ob, ss, active_face_set_id, modify_hidden);
break;
}
-
- MEM_SAFE_FREE(prev_face_sets);
}
-static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static bool sculpt_face_set_edit_is_operation_valid(SculptSession *ss,
+ const eSculptFaceSetEditMode mode,
+ const bool modify_hidden)
{
- Object *ob = CTX_data_active_object(C);
- SculptSession *ss = ob->sculpt;
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
-
- const int mode = RNA_enum_get(op->ptr, "mode");
-
- /* Dyntopo not supported. */
if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
+ /* Dyntopo is not supported. */
return OPERATOR_CANCELLED;
}
- /* Ignore other events to avoid repeated operations. */
- if (event->val != KM_PRESS) {
- return OPERATOR_CANCELLED;
+ if (mode == SCULPT_FACE_SET_EDIT_DELETE_GEOMETRY) {
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+ /* Modification of base mesh geometry requires special remapping of multires displacement,
+ * which does not happen here.
+ * Disable delete operation. It can be supported in the future by doing similar displacement
+ * data remapping as what happens in the mesh edit mode. */
+ return false;
+ }
+ if (check_single_face_set(ss, ss->face_sets, !modify_hidden)) {
+ /* Cancel the operator if the mesh only contains one Face Set to avoid deleting the
+ * entire object. */
+ return false;
+ }
}
+ return true;
+}
- BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, false);
+static void sculpt_face_set_edit_modify_geometry(bContext *C,
+ Object *ob,
+ const int active_face_set,
+ const eSculptFaceSetEditMode mode,
+ const bool modify_hidden)
+{
+ ED_sculpt_undo_geometry_begin(ob, "edit face set delete geometry");
+ sculpt_face_set_apply_edit(ob, abs(active_face_set), mode, modify_hidden);
+ ED_sculpt_undo_geometry_end(ob);
+ BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+}
- /* Update the current active Face Set and Vertex as the operator can be used directly from the
- * tool without brush cursor. */
- SculptCursorGeometryInfo sgi;
- float mouse[2];
- mouse[0] = event->mval[0];
- mouse[1] = event->mval[1];
- SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+static void face_set_edit_do_post_visibility_updates(Object *ob, PBVHNode **nodes, int totnode)
+{
+ SculptSession *ss = ob->sculpt;
+ PBVH *pbvh = ss->pbvh;
+
+ /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */
+ SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
+
+ for (int i = 0; i < totnode; i++) {
+ BKE_pbvh_node_mark_update_visibility(nodes[i]);
+ }
+
+ BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility);
+
+ if (BKE_pbvh_type(pbvh) == PBVH_FACES) {
+ BKE_mesh_flush_hidden_from_verts(ob->data);
+ }
+}
+static void sculpt_face_set_edit_modify_face_sets(Object *ob,
+ const int active_face_set,
+ const eSculptFaceSetEditMode mode,
+ const bool modify_hidden)
+{
PBVH *pbvh = ob->sculpt->pbvh;
PBVHNode **nodes;
int totnode;
BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
if (!nodes) {
- return OPERATOR_CANCELLED;
+ return;
}
-
- SCULPT_undo_push_begin("face set edit");
+ SCULPT_undo_push_begin(ob, "face set edit");
SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
-
- const int active_face_set = SCULPT_active_face_set_get(ss);
- const bool modify_hidden = RNA_boolean_get(op->ptr, "modify_hidden");
-
sculpt_face_set_apply_edit(ob, abs(active_face_set), mode, modify_hidden);
-
SCULPT_undo_push_end();
+ face_set_edit_do_post_visibility_updates(ob, nodes, totnode);
+ MEM_freeN(nodes);
+}
- /* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */
- SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
+static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- for (int i = 0; i < totnode; i++) {
- BKE_pbvh_node_mark_update_visibility(nodes[i]);
+ const int mode = RNA_enum_get(op->ptr, "mode");
+ const bool modify_hidden = RNA_boolean_get(op->ptr, "modify_hidden");
+
+ if (!sculpt_face_set_edit_is_operation_valid(ss, mode, modify_hidden)) {
+ return OPERATOR_CANCELLED;
}
- BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, false);
- MEM_SAFE_FREE(nodes);
+ /* Update the current active Face Set and Vertex as the operator can be used directly from the
+ * tool without brush cursor. */
+ SculptCursorGeometryInfo sgi;
+ const float mouse[2] = {event->mval[0], event->mval[1]};
+ SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
+ const int active_face_set = SCULPT_active_face_set_get(ss);
- if (BKE_pbvh_type(pbvh) == PBVH_FACES) {
- BKE_mesh_flush_hidden_from_verts(ob->data);
+ switch (mode) {
+ case SCULPT_FACE_SET_EDIT_DELETE_GEOMETRY:
+ sculpt_face_set_edit_modify_geometry(C, ob, active_face_set, mode, modify_hidden);
+ break;
+ case SCULPT_FACE_SET_EDIT_GROW:
+ case SCULPT_FACE_SET_EDIT_SHRINK:
+ sculpt_face_set_edit_modify_face_sets(ob, active_face_set, mode, modify_hidden);
+ break;
}
SCULPT_tag_update_overlays(C);
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.c b/source/blender/editors/sculpt_paint/sculpt_filter_color.c
index 07986bbb032..f3c07a86201 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_color.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.c
@@ -290,7 +290,7 @@ static int sculpt_color_filter_invoke(bContext *C, wmOperator *op, const wmEvent
return OPERATOR_CANCELLED;
}
- SCULPT_undo_push_begin("color filter");
+ SCULPT_undo_push_begin(ob, "color filter");
BKE_sculpt_color_layer_create_if_needed(ob);
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
index 8fa20aaae50..ddad6bef7fd 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
@@ -212,7 +212,7 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op)
int num_verts = SCULPT_vertex_count_get(ss);
BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
- SCULPT_undo_push_begin("Mask filter");
+ SCULPT_undo_push_begin(ob, "Mask filter");
for (int i = 0; i < totnode; i++) {
SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK);
@@ -440,7 +440,7 @@ static int sculpt_dirty_mask_exec(bContext *C, wmOperator *op)
}
BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
- SCULPT_undo_push_begin("Dirty Mask");
+ SCULPT_undo_push_begin(ob, "Dirty Mask");
for (int i = 0; i < totnode; i++) {
SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK);
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index 349e492a496..11af63c6e47 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -703,7 +703,7 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
SCULPT_boundary_info_ensure(ob);
}
- SCULPT_undo_push_begin("Mesh Filter");
+ SCULPT_undo_push_begin(ob, "Mesh Filter");
SCULPT_filter_cache_init(C, ob, sd, SCULPT_UNDO_COORDS);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 1a596909d8d..c5db078617f 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -1085,7 +1085,7 @@ void SCULPT_cache_free(StrokeCache *cache);
SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type);
SculptUndoNode *SCULPT_undo_get_node(PBVHNode *node);
SculptUndoNode *SCULPT_undo_get_first_node(void);
-void SCULPT_undo_push_begin(const char *name);
+void SCULPT_undo_push_begin(struct Object *ob, const char *name);
void SCULPT_undo_push_end(void);
void SCULPT_undo_push_end_ex(const bool use_nested_undo);
diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
index 5a921383ac3..39432dbbca4 100644
--- a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
@@ -378,7 +378,7 @@ static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent
BKE_pbvh_search_gather(pbvh, NULL, NULL, &ss->filter_cache->nodes, &ss->filter_cache->totnode);
- SCULPT_undo_push_begin("Mask Expand");
+ SCULPT_undo_push_begin(ob, "Mask Expand");
if (create_face_set) {
SCULPT_undo_push_node(ob, ss->filter_cache->nodes[0], SCULPT_UNDO_FACE_SETS);
diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.c b/source/blender/editors/sculpt_paint/sculpt_transform.c
index 479f70b5ff1..c1281c98deb 100644
--- a/source/blender/editors/sculpt_paint/sculpt_transform.c
+++ b/source/blender/editors/sculpt_paint/sculpt_transform.c
@@ -70,7 +70,7 @@ void ED_sculpt_init_transform(struct bContext *C)
copy_v3_v3(ss->init_pivot_pos, ss->pivot_pos);
copy_v4_v4(ss->init_pivot_rot, ss->pivot_rot);
- SCULPT_undo_push_begin("Transform");
+ SCULPT_undo_push_begin(ob, "Transform");
BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false, false);
ss->pivot_rot[3] = 1.0f;
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index f1410ffad1b..af2aad14008 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -1334,10 +1334,17 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
return unode;
}
-void SCULPT_undo_push_begin(const char *name)
+void SCULPT_undo_push_begin(Object *ob, const char *name)
{
UndoStack *ustack = ED_undo_stack_get();
+ if (ob != NULL) {
+ /* If possible, we need to tag the object and its geometry data as 'changed in the future' in
+ * the previous undo step if it's a memfile one. */
+ ED_undosys_stack_memfile_id_changed_tag(ustack, &ob->id);
+ ED_undosys_stack_memfile_id_changed_tag(ustack, ob->data);
+ }
+
/* Special case, we never read from this. */
bContext *C = NULL;
@@ -1477,8 +1484,6 @@ static void sculpt_undosys_step_decode(
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- /* Sculpt needs evaluated state. */
- BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer);
Object *ob = OBACT(view_layer);
if (ob && (ob->type == OB_MESH)) {
if (ob->mode & OB_MODE_SCULPT) {
@@ -1486,6 +1491,12 @@ static void sculpt_undosys_step_decode(
}
else {
ED_object_mode_generic_exit(bmain, depsgraph, scene, ob);
+
+ /* Sculpt needs evaluated state.
+ * Note: needs to be done here, as #ED_object_mode_generic_exit will usually invalidate
+ * (some) evaluated data. */
+ BKE_scene_graph_evaluated_ensure(depsgraph, bmain);
+
Mesh *me = ob->data;
/* Don't add sculpt topology undo steps when reading back undo state.
* The undo steps must enter/exit for us. */
@@ -1521,7 +1532,7 @@ static void sculpt_undosys_step_free(UndoStep *us_p)
void ED_sculpt_undo_geometry_begin(struct Object *ob, const char *name)
{
- SCULPT_undo_push_begin(name);
+ SCULPT_undo_push_begin(ob, name);
SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_GEOMETRY);
}
@@ -1634,7 +1645,7 @@ void ED_sculpt_undo_push_multires_mesh_begin(bContext *C, const char *str)
Object *object = CTX_data_active_object(C);
- SCULPT_undo_push_begin(str);
+ SCULPT_undo_push_begin(object, str);
SculptUndoNode *geometry_unode = SCULPT_undo_push_node(object, NULL, SCULPT_UNDO_GEOMETRY);
geometry_unode->geometry_clear_pbvh = false;
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 5be72ec87e7..f77d473ae57 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -172,7 +172,7 @@ static void HC_relaxation_iteration_uv(BMEditMesh *em,
for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
copy_v2_v2(diff, tmp_uvdata[i].sum_co);
- mul_v2_fl(diff, 1.f / tmp_uvdata[i].ncounter);
+ mul_v2_fl(diff, 1.0f / tmp_uvdata[i].ncounter);
copy_v2_v2(tmp_uvdata[i].p, diff);
tmp_uvdata[i].b[0] = diff[0] - sculptdata->uv[i].uv[0];
@@ -260,7 +260,7 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em,
* here it is not needed since we translate along the UV plane always. */
for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
copy_v2_v2(tmp_uvdata[i].p, tmp_uvdata[i].sum_co);
- mul_v2_fl(tmp_uvdata[i].p, 1.f / tmp_uvdata[i].ncounter);
+ mul_v2_fl(tmp_uvdata[i].p, 1.0f / tmp_uvdata[i].ncounter);
}
for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index e5f6b61a2ae..c6961cc9d4b 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -46,13 +46,14 @@
#include "BKE_packedFile.h"
#include "BKE_report.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
#include "BKE_sound.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
+#include "SEQ_sequencer.h"
+
#include "UI_interface.h"
#include "WM_api.h"
@@ -170,7 +171,7 @@ static void SOUND_OT_open(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_boolean(ot->srna, "cache", false, "Cache", "Cache the sound in memory");
RNA_def_boolean(ot->srna, "mono", false, "Mono", "Merge all the sound's channels into one");
}
@@ -197,7 +198,7 @@ static void SOUND_OT_open_mono(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_boolean(ot->srna, "cache", false, "Cache", "Cache the sound in memory");
RNA_def_boolean(ot->srna, "mono", true, "Mono", "Mixdown the sound to mono");
}
@@ -511,8 +512,7 @@ static bool sound_mixdown_draw_check_prop(PointerRNA *UNUSED(ptr),
void *UNUSED(user_data))
{
const char *prop_id = RNA_property_identifier(prop);
- return !(STREQ(prop_id, "filepath") || STREQ(prop_id, "directory") ||
- STREQ(prop_id, "filename"));
+ return !(STR_ELEM(prop_id, "filepath", "directory", "filename"));
}
static void sound_mixdown_draw(bContext *C, wmOperator *op)
@@ -721,7 +721,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_SHOW_PROPS,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
#ifdef WITH_AUDASPACE
RNA_def_int(
ot->srna,
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 8634e5a5f29..5036f22fd0e 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -145,7 +145,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
uchar col1a[4], col2a[4];
uchar col1b[4], col2b[4];
- const bool show_group_colors = !(saction->flag & SACTION_NODRAWGCOLORS);
+ const bool show_group_colors = U.animation_flag & USER_ANIM_SHOW_CHANNEL_GROUP_COLORS;
/* get theme colors */
UI_GetThemeColor4ubv(TH_SHADE2, col2);
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index f058ec5546a..167215b3813 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -1665,7 +1665,7 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
if (ked.i1) {
Scene *scene = ac.scene;
CFRA = round_fl_to_int(ked.f1 / ked.i1);
- SUBFRA = 0.f;
+ SUBFRA = 0.0f;
}
/* set notifier that things have changed */
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index b89c8cb2193..10ce7b81954 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -271,18 +271,15 @@ void ED_region_draw_cb_exit(ARegionType *art, void *handle)
void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
{
RegionDrawCB *rdc;
- bool has_drawn_something = false;
for (rdc = region->type->drawcalls.first; rdc; rdc = rdc->next) {
if (rdc->type == type) {
rdc->draw(C, region, rdc->customdata);
- has_drawn_something = true;
+
+ /* This is needed until we get rid of BGL which can change the states we are tracking. */
+ GPU_bgl_end();
}
}
- if (has_drawn_something) {
- /* This is needed until we get rid of BGL which can change the states we are tracking. */
- GPU_bgl_end();
- }
}
/* ********************* space template *********************** */
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 60ce86740cd..922ef8dde99 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -56,6 +56,7 @@
#include "RNA_access.h"
+#include "ED_buttons.h"
#include "ED_physics.h"
#include "ED_screen.h"
@@ -512,11 +513,11 @@ static bool buttons_context_linestyle_pinnable(const bContext *C, ViewLayer *vie
}
#endif
-static bool buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag)
+static bool buttons_context_path(
+ const bContext *C, SpaceProperties *sbuts, ButsContextPath *path, int mainb, int flag)
{
/* Note we don't use CTX_data here, instead we get it from the window.
* Otherwise there is a loop reading the context that we are setting. */
- SpaceProperties *sbuts = CTX_wm_space_properties(C);
wmWindow *window = CTX_wm_window(C);
Scene *scene = WM_window_get_active_scene(window);
ViewLayer *view_layer = WM_window_get_active_view_layer(window);
@@ -660,14 +661,14 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts)
int flag = 0;
/* Set scene path. */
- buttons_context_path(C, path, BCONTEXT_SCENE, pflag);
+ buttons_context_path(C, sbuts, path, BCONTEXT_SCENE, pflag);
buttons_texture_context_compute(C, sbuts);
/* for each context, see if we can compute a valid path to it, if
* this is the case, we know we have to display the button */
for (int i = 0; i < BCONTEXT_TOT; i++) {
- if (buttons_context_path(C, path, i, pflag)) {
+ if (buttons_context_path(C, sbuts, path, i, pflag)) {
flag |= (1 << i);
/* setting icon for data context */
@@ -713,7 +714,7 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts)
}
}
- buttons_context_path(C, path, sbuts->mainb, pflag);
+ buttons_context_path(C, sbuts, path, sbuts->mainb, pflag);
if (!(flag & (1 << sbuts->mainb))) {
if (flag & (1 << BCONTEXT_OBJECT)) {
@@ -734,6 +735,39 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts)
sbuts->pathflag = flag;
}
+static bool is_pointer_in_path(ButsContextPath *path, PointerRNA *ptr)
+{
+ for (int i = 0; i < path->len; ++i) {
+ if (ptr->owner_id == path->ptr[i].owner_id) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void ED_buttons_set_context(const bContext *C, PointerRNA *ptr, const int context)
+{
+ ScrArea *active_area = CTX_wm_area(C);
+ bScreen *screen = CTX_wm_screen(C);
+
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ /* Only update for properties editors that are visible and share a border. */
+ if (area->spacetype != SPACE_PROPERTIES) {
+ continue;
+ }
+ if (!ED_area_has_shared_border(active_area, area)) {
+ continue;
+ }
+
+ SpaceProperties *sbuts = (SpaceProperties *)area->spacedata.first;
+ ButsContextPath path;
+ if (buttons_context_path(C, sbuts, &path, context, 0) && is_pointer_in_path(&path, ptr)) {
+ sbuts->mainbuser = context;
+ sbuts->mainb = sbuts->mainbuser;
+ }
+ }
+}
+
/************************* Context Callback ************************/
const char *buttons_context_dir[] = {
@@ -1182,7 +1216,7 @@ void buttons_context_register(ARegionType *art)
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->poll = buttons_panel_context_poll;
pt->draw = buttons_panel_context_draw;
- pt->flag = PNL_NO_HEADER;
+ pt->flag = PANEL_TYPE_NO_HEADER;
BLI_addtail(&art->paneltypes, pt);
}
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index 87cf8507dd4..8bdc2ed993f 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -378,7 +378,7 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/* Second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY. */
@@ -405,7 +405,7 @@ void BUTTONS_OT_directory_browse(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/** \} */
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 3d470b19c1c..3c4a1fee69c 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -609,7 +609,7 @@ static void buttons_navigation_bar_region_init(wmWindowManager *wm, ARegion *reg
static void buttons_navigation_bar_region_draw(const bContext *C, ARegion *region)
{
LISTBASE_FOREACH (PanelType *, pt, &region->type->paneltypes) {
- pt->flag |= PNL_LAYOUT_VERT_BAR;
+ pt->flag |= PANEL_TYPE_LAYOUT_VERT_BAR;
}
ED_region_panels_layout(C, region);
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index f3bac697044..a95d0e3ea88 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -95,7 +95,7 @@ void ED_clip_buttons_register(ARegionType *art)
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->poll = metadata_panel_context_poll;
pt->draw = metadata_panel_context_draw;
- pt->flag |= PNL_DEFAULT_CLOSED;
+ pt->flag |= PANEL_TYPE_DEFAULT_CLOSED;
BLI_addtail(&art->paneltypes, pt);
}
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index ee9cc0e31df..bd11a746e11 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -675,7 +675,7 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
}
}
else {
- if (cur_sc->clip == old_clip || cur_sc->clip == NULL) {
+ if (ELEM(cur_sc->clip, old_clip, NULL)) {
cur_sc->clip = clip;
}
}
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 26fa5b8a06c..3f00e3114a5 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -329,7 +329,7 @@ void CLIP_OT_open(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_RELPATH | WM_FILESEL_FILES | WM_FILESEL_DIRECTORY,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/** \} */
@@ -616,7 +616,7 @@ static int view_zoom_exec(bContext *C, wmOperator *op)
static int view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (event->type == MOUSEZOOM || event->type == MOUSEPAN) {
+ if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) {
float delta, factor;
delta = event->prevx - event->x + event->prevy - event->y;
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 0631b6ea8a0..4d3e6cf4d6a 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -1043,13 +1043,13 @@ static int clear_track_path_exec(bContext *C, wmOperator *op)
void CLIP_OT_clear_track_path(wmOperatorType *ot)
{
static const EnumPropertyItem clear_path_actions[] = {
- {TRACK_CLEAR_UPTO, "UPTO", 0, "Clear up-to", "Clear path up to current frame"},
+ {TRACK_CLEAR_UPTO, "UPTO", 0, "Clear Up To", "Clear path up to current frame"},
{TRACK_CLEAR_REMAINED,
"REMAINED",
0,
- "Clear remained",
+ "Clear Remained",
"Clear path at remaining frames (after current)"},
- {TRACK_CLEAR_ALL, "ALL", 0, "Clear all", "Clear the whole path"},
+ {TRACK_CLEAR_ALL, "ALL", 0, "Clear All", "Clear the whole path"},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
index 478d22c7582..063ea9592aa 100644
--- a/source/blender/editors/space_clip/tracking_select.c
+++ b/source/blender/editors/space_clip/tracking_select.c
@@ -975,15 +975,15 @@ static int select_grouped_exec(bContext *C, wmOperator *op)
void CLIP_OT_select_grouped(wmOperatorType *ot)
{
static const EnumPropertyItem select_group_items[] = {
- {0, "KEYFRAMED", 0, "Keyframed tracks", "Select all keyframed tracks"},
- {1, "ESTIMATED", 0, "Estimated tracks", "Select all estimated tracks"},
- {2, "TRACKED", 0, "Tracked tracks", "Select all tracked tracks"},
- {3, "LOCKED", 0, "Locked tracks", "Select all locked tracks"},
- {4, "DISABLED", 0, "Disabled tracks", "Select all disabled tracks"},
+ {0, "KEYFRAMED", 0, "Keyframed Tracks", "Select all keyframed tracks"},
+ {1, "ESTIMATED", 0, "Estimated Tracks", "Select all estimated tracks"},
+ {2, "TRACKED", 0, "Tracked Tracks", "Select all tracked tracks"},
+ {3, "LOCKED", 0, "Locked Tracks", "Select all locked tracks"},
+ {4, "DISABLED", 0, "Disabled Tracks", "Select all disabled tracks"},
{5,
"COLOR",
0,
- "Tracks with same color",
+ "Tracks with Same Color",
"Select all tracks with same color as active track"},
{6, "FAILED", 0, "Failed Tracks", "Select all tracks which failed to be reconstructed"},
{0, NULL, 0, NULL, NULL},
diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt
index dcacf5e2504..993a52b9084 100644
--- a/source/blender/editors/space_file/CMakeLists.txt
+++ b/source/blender/editors/space_file/CMakeLists.txt
@@ -26,7 +26,7 @@ set(INC
../../imbuf
../../makesdna
../../makesrna
- ../../render/extern/include
+ ../../render
../../windowmanager
../../../../intern/atomic
../../../../intern/glew-mx
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 91653fb7785..93367ad3d3c 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1351,18 +1351,17 @@ static int file_column_sort_ui_context_invoke(bContext *C,
if (column_type != COLUMN_NONE) {
const FileAttributeColumn *column = &sfile->layout->attribute_columns[column_type];
- if (column->sort_type != FILE_SORT_NONE) {
- if (sfile->params->sort == column->sort_type) {
- /* Already sorting by selected column -> toggle sort invert (three state logic). */
- sfile->params->flag ^= FILE_SORT_INVERT;
- }
- else {
- sfile->params->sort = column->sort_type;
- sfile->params->flag &= ~FILE_SORT_INVERT;
- }
-
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+ BLI_assert(column->sort_type != FILE_SORT_DEFAULT);
+ if (sfile->params->sort == column->sort_type) {
+ /* Already sorting by selected column -> toggle sort invert (three state logic). */
+ sfile->params->flag ^= FILE_SORT_INVERT;
}
+ else {
+ sfile->params->sort = column->sort_type;
+ sfile->params->flag &= ~FILE_SORT_INVERT;
+ }
+
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
}
}
@@ -2415,7 +2414,8 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
WM_operator_properties_create_ptr(&ptr, ot);
RNA_string_set(&ptr, "directory", sfile->params->dir);
RNA_boolean_set(&ptr, "open", true);
- /* Enable confirmation prompt, else it's too easy to accidentally create new directories. */
+ /* Enable confirmation prompt, else it's too easy
+ * to accidentally create new directories. */
RNA_boolean_set(&ptr, "confirm", true);
if (lastdir) {
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index a71dec99e61..22d206c0a70 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -103,7 +103,7 @@ void file_tool_props_region_panels_register(ARegionType *art)
strcpy(pt->idname, "FILE_PT_operator");
strcpy(pt->label, N_("Operator"));
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
- pt->flag = PNL_NO_HEADER;
+ pt->flag = PANEL_TYPE_NO_HEADER;
pt->poll = file_panel_operator_poll;
pt->draw_header = file_panel_operator_header;
pt->draw = file_panel_operator;
@@ -217,7 +217,7 @@ void file_execute_region_panels_register(ARegionType *art)
strcpy(pt->idname, "FILE_PT_execution_buttons");
strcpy(pt->label, N_("Execute Buttons"));
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
- pt->flag = PNL_NO_HEADER;
+ pt->flag = PANEL_TYPE_NO_HEADER;
pt->poll = file_panel_operator_poll;
pt->draw = file_panel_execution_buttons_draw;
BLI_addtail(&art->paneltypes, pt);
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 3004aadb5dd..9e51b6ca4ba 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -294,9 +294,6 @@ enum {
typedef struct FileList {
FileDirEntryArr filelist;
- short prv_w;
- short prv_h;
-
short flags;
short sort;
@@ -586,7 +583,7 @@ static int compare_extension(void *user_data, const void *a1, const void *a2)
void filelist_sort(struct FileList *filelist)
{
- if ((filelist->flags & FL_NEED_SORTING) && (filelist->sort != FILE_SORT_NONE)) {
+ if (filelist->flags & FL_NEED_SORTING) {
void *sort_cb = NULL;
switch (filelist->sort) {
@@ -602,7 +599,7 @@ void filelist_sort(struct FileList *filelist)
case FILE_SORT_EXTENSION:
sort_cb = compare_extension;
break;
- case FILE_SORT_NONE: /* Should never reach this point! */
+ case FILE_SORT_DEFAULT:
default:
BLI_assert(0);
break;
@@ -951,12 +948,6 @@ void filelist_free_icons(void)
}
}
-void filelist_imgsize(struct FileList *filelist, short w, short h)
-{
- filelist->prv_w = w;
- filelist->prv_h = h;
-}
-
static FileDirEntry *filelist_geticon_get_file(struct FileList *filelist, const int index)
{
BLI_assert(G.background == false);
@@ -1303,6 +1294,8 @@ static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdat
}
IMB_thumb_path_lock(preview->path);
+ /* Always generate biggest preview size for now, it's simpler and avoids having to re-generate in
+ * case user switch to a bigger preview size. */
preview->img = IMB_thumb_manage(preview->path, THB_LARGE, source);
IMB_thumb_path_unlock(preview->path);
@@ -1569,7 +1562,6 @@ void filelist_free(struct FileList *filelist)
memset(&filelist->filter_data, 0, sizeof(filelist->filter_data));
filelist->flags &= ~(FL_NEED_SORTING | FL_NEED_FILTERING);
- filelist->sort = FILE_SORT_NONE;
}
void filelist_freelib(struct FileList *filelist)
diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h
index 051b811b001..4b8cc052382 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -69,7 +69,6 @@ void filelist_filter(struct FileList *filelist);
void filelist_init_icons(void);
void filelist_free_icons(void);
-void filelist_imgsize(struct FileList *filelist, short w, short h);
struct ImBuf *filelist_getimage(struct FileList *filelist, const int index);
struct ImBuf *filelist_geticon_image(struct FileList *filelist, const int index);
int filelist_geticon(struct FileList *filelist, const int index, const bool is_main);
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 42b2806814b..15c6972c5f5 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -61,6 +61,7 @@
#include "BLF_api.h"
#include "ED_fileselect.h"
+#include "ED_screen.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -266,15 +267,16 @@ short ED_fileselect_set_params(SpaceFile *sfile)
params->display = RNA_property_enum_get(op->ptr, prop);
}
+ if (params->display == FILE_DEFAULTDISPLAY) {
+ params->display = U_default.file_space_data.display_type;
+ }
+
if ((prop = RNA_struct_find_property(op->ptr, "sort_method"))) {
params->sort = RNA_property_enum_get(op->ptr, prop);
}
- else {
- params->sort = U_default.file_space_data.sort_type;
- }
- if (params->display == FILE_DEFAULTDISPLAY) {
- params->display = U_default.file_space_data.display_type;
+ if (params->sort == FILE_SORT_DEFAULT) {
+ params->sort = U_default.file_space_data.sort_type;
}
if (is_relative_path) {
@@ -326,8 +328,9 @@ short ED_fileselect_set_params(SpaceFile *sfile)
return 1;
}
-/* The subset of FileSelectParams.flag items we store into preferences. */
-#define PARAMS_FLAGS_REMEMBERED (FILE_HIDE_DOT | FILE_SORT_INVERT)
+/* The subset of FileSelectParams.flag items we store into preferences. Note that FILE_SORT_ALPHA
+ * may also be remembered, but only conditionally. */
+#define PARAMS_FLAGS_REMEMBERED (FILE_HIDE_DOT)
void ED_fileselect_window_params_get(const wmWindow *win, int win_size[2], bool *is_maximized)
{
@@ -340,6 +343,22 @@ void ED_fileselect_window_params_get(const wmWindow *win, int win_size[2], bool
*is_maximized = WM_window_is_maximized(win);
}
+static bool file_select_use_default_display_type(const SpaceFile *sfile)
+{
+ PropertyRNA *prop;
+ return (sfile->op == NULL) ||
+ !(prop = RNA_struct_find_property(sfile->op->ptr, "display_type")) ||
+ (RNA_property_enum_get(sfile->op->ptr, prop) == FILE_DEFAULTDISPLAY);
+}
+
+static bool file_select_use_default_sort_type(const SpaceFile *sfile)
+{
+ PropertyRNA *prop;
+ return (sfile->op == NULL) ||
+ !(prop = RNA_struct_find_property(sfile->op->ptr, "sort_method")) ||
+ (RNA_property_enum_get(sfile->op->ptr, prop) == FILE_SORT_DEFAULT);
+}
+
void ED_fileselect_set_params_from_userdef(SpaceFile *sfile)
{
wmOperator *op = sfile->op;
@@ -351,12 +370,6 @@ void ED_fileselect_set_params_from_userdef(SpaceFile *sfile)
return;
}
- if (!RNA_struct_property_is_set(op->ptr, "display_type")) {
- sfile->params->display = sfile_udata->display_type;
- }
- if (!RNA_struct_property_is_set(op->ptr, "sort_method")) {
- sfile->params->sort = sfile_udata->sort_type;
- }
sfile->params->thumbnail_size = sfile_udata->thumbnail_size;
sfile->params->details_flags = sfile_udata->details_flags;
sfile->params->filter_id = sfile_udata->filter_id;
@@ -364,6 +377,16 @@ void ED_fileselect_set_params_from_userdef(SpaceFile *sfile)
/* Combine flags we take from params with the flags we take from userdef. */
sfile->params->flag = (sfile->params->flag & ~PARAMS_FLAGS_REMEMBERED) |
(sfile_udata->flag & PARAMS_FLAGS_REMEMBERED);
+
+ if (file_select_use_default_display_type(sfile)) {
+ sfile->params->display = sfile_udata->display_type;
+ }
+ if (file_select_use_default_sort_type(sfile)) {
+ sfile->params->sort = sfile_udata->sort_type;
+ /* For the default sorting, also take invert flag from userdef. */
+ sfile->params->flag = (sfile->params->flag & ~FILE_SORT_INVERT) |
+ (sfile_udata->flag & FILE_SORT_INVERT);
+ }
}
/**
@@ -380,13 +403,24 @@ void ED_fileselect_params_to_userdef(SpaceFile *sfile,
UserDef_FileSpaceData *sfile_udata_new = &U.file_space_data;
UserDef_FileSpaceData sfile_udata_old = U.file_space_data;
- sfile_udata_new->display_type = sfile->params->display;
sfile_udata_new->thumbnail_size = sfile->params->thumbnail_size;
- sfile_udata_new->sort_type = sfile->params->sort;
sfile_udata_new->details_flags = sfile->params->details_flags;
sfile_udata_new->flag = sfile->params->flag & PARAMS_FLAGS_REMEMBERED;
sfile_udata_new->filter_id = sfile->params->filter_id;
+ /* In some rare cases, operators ask for a specific display or sort type (e.g. chronological
+ * sorting for "Recover Auto Save"). So the settings are optimized for a specific operation.
+ * Don't let that change the userdef memory for more general cases. */
+ if (file_select_use_default_display_type(sfile)) {
+ sfile_udata_new->display_type = sfile->params->display;
+ }
+ if (file_select_use_default_sort_type(sfile)) {
+ sfile_udata_new->sort_type = sfile->params->sort;
+ /* In this case also remember the invert flag. */
+ sfile_udata_new->flag = (sfile_udata_new->flag & ~FILE_SORT_INVERT) |
+ (sfile->params->flag & FILE_SORT_INVERT);
+ }
+
if (temp_win_size && !is_maximized) {
sfile_udata_new->temp_win_sizex = temp_win_size[0];
sfile_udata_new->temp_win_sizey = temp_win_size[1];
@@ -1050,3 +1084,20 @@ void file_params_renamefile_activate(SpaceFile *sfile, FileSelectParams *params)
params->rename_flag = 0;
}
}
+
+ScrArea *ED_fileselect_handler_area_find(const wmWindow *win, const wmOperator *file_operator)
+{
+ bScreen *screen = WM_window_get_active_screen(win);
+
+ ED_screen_areas_iter (win, screen, area) {
+ if (area->spacetype == SPACE_FILE) {
+ SpaceFile *sfile = area->spacedata.first;
+
+ if (sfile->op == file_operator) {
+ return area;
+ }
+ }
+ }
+
+ return NULL;
+}
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index 329b5fe67fd..d8556711c55 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -203,7 +203,7 @@ static void fsmenu_xdg_insert_entry(GHash *xdg_map,
xdg_path = xdg_path_buf;
}
fsmenu_insert_entry(
- fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, xdg_path, IFACE_(default_path), icon, FS_INSERT_LAST);
+ fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, xdg_path, N_(default_path), icon, FS_INSERT_LAST);
}
/** \} */
@@ -579,10 +579,10 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename)
name[0] = '\0';
while (fgets(line, sizeof(line), fp) != NULL) { /* read a line */
- if (STREQLEN(line, "[Bookmarks]", 11)) {
+ if (STRPREFIX(line, "[Bookmarks]")) {
category = FS_CATEGORY_BOOKMARKS;
}
- else if (STREQLEN(line, "[Recent]", 8)) {
+ else if (STRPREFIX(line, "[Recent]")) {
category = FS_CATEGORY_RECENT;
}
else if (line[0] == '!') {
@@ -698,49 +698,49 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
fsmenu_add_windows_folder(fsmenu,
FS_CATEGORY_SYSTEM_BOOKMARKS,
&FOLDERID_Profile,
- IFACE_("Home"),
+ N_("Home"),
ICON_HOME,
FS_INSERT_LAST);
fsmenu_add_windows_folder(fsmenu,
FS_CATEGORY_SYSTEM_BOOKMARKS,
&FOLDERID_Desktop,
- IFACE_("Desktop"),
+ N_("Desktop"),
ICON_DESKTOP,
FS_INSERT_LAST);
fsmenu_add_windows_folder(fsmenu,
FS_CATEGORY_SYSTEM_BOOKMARKS,
&FOLDERID_Documents,
- IFACE_("Documents"),
+ N_("Documents"),
ICON_DOCUMENTS,
FS_INSERT_LAST);
fsmenu_add_windows_folder(fsmenu,
FS_CATEGORY_SYSTEM_BOOKMARKS,
&FOLDERID_Downloads,
- IFACE_("Downloads"),
+ N_("Downloads"),
ICON_IMPORT,
FS_INSERT_LAST);
fsmenu_add_windows_folder(fsmenu,
FS_CATEGORY_SYSTEM_BOOKMARKS,
&FOLDERID_Music,
- IFACE_("Music"),
+ N_("Music"),
ICON_FILE_SOUND,
FS_INSERT_LAST);
fsmenu_add_windows_folder(fsmenu,
FS_CATEGORY_SYSTEM_BOOKMARKS,
&FOLDERID_Pictures,
- IFACE_("Pictures"),
+ N_("Pictures"),
ICON_FILE_IMAGE,
FS_INSERT_LAST);
fsmenu_add_windows_folder(fsmenu,
FS_CATEGORY_SYSTEM_BOOKMARKS,
&FOLDERID_Videos,
- IFACE_("Videos"),
+ N_("Videos"),
ICON_FILE_MOVIE,
FS_INSERT_LAST);
fsmenu_add_windows_folder(fsmenu,
FS_CATEGORY_SYSTEM_BOOKMARKS,
&FOLDERID_Fonts,
- IFACE_("Fonts"),
+ N_("Fonts"),
ICON_FILE_FONT,
FS_INSERT_LAST);
@@ -757,16 +757,12 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
{
/* We store some known macOS system paths and corresponding icons
* and names in the FS_CATEGORY_OTHER (not displayed directly) category. */
- fsmenu_insert_entry(fsmenu,
- FS_CATEGORY_OTHER,
- "/Library/Fonts/",
- IFACE_("Fonts"),
- ICON_FILE_FONT,
- FS_INSERT_LAST);
+ fsmenu_insert_entry(
+ fsmenu, FS_CATEGORY_OTHER, "/Library/Fonts/", N_("Fonts"), ICON_FILE_FONT, FS_INSERT_LAST);
fsmenu_insert_entry(fsmenu,
FS_CATEGORY_OTHER,
"/Applications/",
- IFACE_("Applications"),
+ N_("Applications"),
ICON_FILE_FOLDER,
FS_INSERT_LAST);
@@ -777,13 +773,13 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
fsmenu_insert_entry(fsmenu, FS_CATEGORY_OTHER, line, name, icon, FS_INSERT_LAST);
FS_MACOS_PATH("%s/", NULL, ICON_HOME)
- FS_MACOS_PATH("%s/Desktop/", IFACE_("Desktop"), ICON_DESKTOP)
- FS_MACOS_PATH("%s/Documents/", IFACE_("Documents"), ICON_DOCUMENTS)
- FS_MACOS_PATH("%s/Downloads/", IFACE_("Downloads"), ICON_IMPORT)
- FS_MACOS_PATH("%s/Movies/", IFACE_("Movies"), ICON_FILE_MOVIE)
- FS_MACOS_PATH("%s/Music/", IFACE_("Music"), ICON_FILE_SOUND)
- FS_MACOS_PATH("%s/Pictures/", IFACE_("Pictures"), ICON_FILE_IMAGE)
- FS_MACOS_PATH("%s/Library/Fonts/", IFACE_("Fonts"), ICON_FILE_FONT)
+ FS_MACOS_PATH("%s/Desktop/", N_("Desktop"), ICON_DESKTOP)
+ FS_MACOS_PATH("%s/Documents/", N_("Documents"), ICON_DOCUMENTS)
+ FS_MACOS_PATH("%s/Downloads/", N_("Downloads"), ICON_IMPORT)
+ FS_MACOS_PATH("%s/Movies/", N_("Movies"), ICON_FILE_MOVIE)
+ FS_MACOS_PATH("%s/Music/", N_("Music"), ICON_FILE_SOUND)
+ FS_MACOS_PATH("%s/Pictures/", N_("Pictures"), ICON_FILE_IMAGE)
+ FS_MACOS_PATH("%s/Library/Fonts/", N_("Fonts"), ICON_FILE_FONT)
# undef FS_MACOS_PATH
@@ -902,7 +898,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
if (read_bookmarks && home) {
fsmenu_insert_entry(
- fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, home, IFACE_("Home"), ICON_HOME, FS_INSERT_LAST);
+ fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, home, N_("Home"), ICON_HOME, FS_INSERT_LAST);
/* Follow the XDG spec, check if these are available. */
GHash *xdg_map = fsmenu_xdg_user_dirs_parse(home);
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 3a4e1883cee..920f1d346b9 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -309,7 +309,7 @@ static void graphedit_activekey_left_handle_coord_cb(bContext *C, void *fcu_ptr,
/* perform normal updates NOW */
graphedit_activekey_handles_cb(C, fcu_ptr, bezt_ptr);
- /* restore selection state so that no-one notices this hack */
+ /* restore selection state so that no one notices this hack */
bezt->f1 = f1;
bezt->f3 = f3;
}
@@ -331,7 +331,7 @@ static void graphedit_activekey_right_handle_coord_cb(bContext *C, void *fcu_ptr
/* perform normal updates NOW */
graphedit_activekey_handles_cb(C, fcu_ptr, bezt_ptr);
- /* restore selection state so that no-one notices this hack */
+ /* restore selection state so that no one notices this hack */
bezt->f1 = f1;
bezt->f3 = f3;
}
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 7fc1329df64..ae15b651059 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1863,6 +1863,75 @@ void GRAPH_OT_bake(wmOperatorType *ot)
/* TODO: add props for start/end frames (Joshua Leung 2009) */
}
+/* ******************** Un-Bake F-Curve Operator *********************** */
+/* This operator unbakes the data of the selected F-Points to F-Curves. */
+
+/* Un-Bake F-Points into F-Curves. */
+static void unbake_graph_curves(bAnimContext *ac, int start, int end)
+{
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+
+ /* Filter data. */
+ const int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL |
+ ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ /* Loop through filtered data and add keys between selected keyframes on every frame. */
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ FCurve *fcu = (FCurve *)ale->key_data;
+
+ fcurve_samples_to_keyframes(fcu, start, end);
+
+ ale->update |= ANIM_UPDATE_DEPS;
+ }
+
+ ANIM_animdata_update(ac, &anim_data);
+ ANIM_animdata_freelist(&anim_data);
+}
+
+/* ------------------- */
+
+static int graphkeys_unbake_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ bAnimContext ac;
+ Scene *scene = NULL;
+ int start, end;
+
+ /* Get editor data. */
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
+ scene = ac.scene;
+ start = PSFRA;
+ end = PEFRA;
+
+ /* Unbake keyframes. */
+ unbake_graph_curves(&ac, start, end);
+
+ /* Set notifier that keyframes have changed. */
+ /* 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;
+}
+
+void GRAPH_OT_unbake(wmOperatorType *ot)
+{
+ /* Identifiers */
+ ot->name = "Un-Bake Curve";
+ ot->idname = "GRAPH_OT_unbake";
+ ot->description = "Un-Bake selected F-Points to F-Curves";
+
+ /* API callbacks */
+ ot->exec = graphkeys_unbake_exec;
+ ot->poll = graphop_selected_fcurve_poll;
+
+ /* Flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
#ifdef WITH_AUDASPACE
/* ******************** Sound Bake F-Curve Operator *********************** */
@@ -2021,7 +2090,7 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_float(ot->srna,
"low",
0.0f,
@@ -2815,7 +2884,7 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
else {
/* Animation Mode - Affects current frame (int) */
CFRA = round_fl_to_int(sum_time / num_keyframes);
- SUBFRA = 0.f;
+ SUBFRA = 0.0f;
}
sipo->cursorVal = sum_value / (float)num_keyframes;
@@ -3507,7 +3576,7 @@ void GRAPH_OT_fmodifier_paste(wmOperatorType *ot)
/* Properties */
RNA_def_boolean(
- ot->srna, "only_active", true, "Only Active", "Only paste F-Modifiers on active F-Curve");
+ ot->srna, "only_active", false, "Only Active", "Only paste F-Modifiers on active F-Curve");
RNA_def_boolean(
ot->srna,
"replace",
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index eaa14fedb93..7add2f7cbb8 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -103,6 +103,7 @@ void GRAPH_OT_clean(struct wmOperatorType *ot);
void GRAPH_OT_decimate(struct wmOperatorType *ot);
void GRAPH_OT_sample(struct wmOperatorType *ot);
void GRAPH_OT_bake(struct wmOperatorType *ot);
+void GRAPH_OT_unbake(struct wmOperatorType *ot);
void GRAPH_OT_sound_bake(struct wmOperatorType *ot);
void GRAPH_OT_smooth(struct wmOperatorType *ot);
void GRAPH_OT_euler_filter(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index fd68303e759..63acc2a1774 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -459,6 +459,7 @@ void graphedit_operatortypes(void)
WM_operatortype_append(GRAPH_OT_easing_type);
WM_operatortype_append(GRAPH_OT_sample);
WM_operatortype_append(GRAPH_OT_bake);
+ WM_operatortype_append(GRAPH_OT_unbake);
WM_operatortype_append(GRAPH_OT_sound_bake);
WM_operatortype_append(GRAPH_OT_smooth);
WM_operatortype_append(GRAPH_OT_clean);
diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt
index 96aab8b5d1a..7a1bab0ef14 100644
--- a/source/blender/editors/space_image/CMakeLists.txt
+++ b/source/blender/editors/space_image/CMakeLists.txt
@@ -28,7 +28,7 @@ set(INC
../../imbuf
../../makesdna
../../makesrna
- ../../render/extern/include
+ ../../render
../../windowmanager
../../../../intern/clog
../../../../intern/glew-mx
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 15a4f910684..c0c0280959c 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -1320,6 +1320,6 @@ void image_buttons_register(ARegionType *art)
pt->order = 10;
pt->poll = metadata_panel_context_poll;
pt->draw = metadata_panel_context_draw;
- pt->flag |= PNL_DEFAULT_CLOSED;
+ pt->flag |= PANEL_TYPE_DEFAULT_CLOSED;
BLI_addtail(&art->paneltypes, pt);
}
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index d95f643d7f9..0fa48059cdc 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -519,7 +519,7 @@ enum {
static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (event->type == MOUSEZOOM || event->type == MOUSEPAN) {
+ if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) {
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *region = CTX_wm_region(C);
float delta, factor, location[2];
@@ -1436,8 +1436,7 @@ static bool image_open_draw_check_prop(PointerRNA *UNUSED(ptr),
{
const char *prop_id = RNA_property_identifier(prop);
- return !(STREQ(prop_id, "filepath") || STREQ(prop_id, "directory") ||
- STREQ(prop_id, "filename"));
+ return !(STR_ELEM(prop_id, "filepath", "directory", "filename"));
}
static void image_open_draw(bContext *UNUSED(C), wmOperator *op)
@@ -1486,7 +1485,7 @@ void IMAGE_OT_open(wmOperatorType *ot)
WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILES |
WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_boolean(
ot->srna,
@@ -1638,7 +1637,7 @@ void IMAGE_OT_replace(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/** \} */
@@ -2038,7 +2037,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_SHOW_PROPS,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/** \} */
@@ -2047,36 +2046,17 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
/** \name Save Image Operator
* \{ */
-static bool image_file_path_saveable(bContext *C, Image *ima, ImageUser *iuser)
+/**
+ * \param iuser: Image user or NULL when called outside the image space.
+ */
+static bool image_file_format_writable(Image *ima, ImageUser *iuser)
{
- /* Can always repack images. */
- if (BKE_image_has_packedfile(ima)) {
- return true;
- }
-
- /* Test for valid filepath. */
void *lock;
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
bool ret = false;
- if (ibuf) {
- Main *bmain = CTX_data_main(C);
- char name[FILE_MAX];
- BLI_strncpy(name, ibuf->name, FILE_MAX);
- BLI_path_abs(name, BKE_main_blendfile_path(bmain));
-
- if (BLI_exists(name) == false) {
- CTX_wm_operator_poll_msg_set(C, "image file not found");
- }
- else if (!BLI_file_is_writable(name)) {
- CTX_wm_operator_poll_msg_set(C, "image path can't be written to");
- }
- else if (!BKE_image_buffer_format_writable(ibuf)) {
- CTX_wm_operator_poll_msg_set(C, "image format is read-only");
- }
- else {
- ret = true;
- }
+ if (ibuf && BKE_image_buffer_format_writable(ibuf)) {
+ ret = true;
}
BKE_image_release_ibuf(ima, ibuf, lock);
@@ -2090,16 +2070,12 @@ static bool image_save_poll(bContext *C)
return false;
}
- Image *ima = image_from_context(C);
- ImageUser *iuser = image_user_from_context(C);
-
- /* Images without a filepath will go to save as. */
- if (!BKE_image_has_filepath(ima)) {
- return true;
- }
+ /* Check if there is a valid file path and image format we can write
+ * outside of the 'poll' so we can show a report with a pop-up. */
- /* Check if there is a valid file path and image format we can write. */
- return image_file_path_saveable(C, ima, iuser);
+ /* Can always repack images.
+ * Images without a filepath will go to "Save As". */
+ return true;
}
static int image_save_exec(bContext *C, wmOperator *op)
@@ -2114,6 +2090,8 @@ static int image_save_exec(bContext *C, wmOperator *op)
if (BKE_image_has_packedfile(image)) {
/* Save packed files to memory. */
BKE_image_memorypack(image);
+ /* Report since this can be called from key shortcuts. */
+ BKE_reportf(op->reports, RPT_INFO, "Packed to memory image \"%s\"", image->filepath);
return OPERATOR_FINISHED;
}
@@ -2123,16 +2101,15 @@ static int image_save_exec(bContext *C, wmOperator *op)
}
image_save_options_from_op(bmain, &opts, op, NULL);
- if (BLI_exists(opts.filepath) && BLI_file_is_writable(opts.filepath)) {
- if (save_image_op(bmain, image, iuser, op, &opts)) {
- /* report since this can be called from key-shortcuts */
- BKE_reportf(op->reports, RPT_INFO, "Saved Image '%s'", opts.filepath);
- ok = true;
- }
- }
- else {
+ /* Check if file write permission is ok. */
+ if (BLI_exists(opts.filepath) && !BLI_file_is_writable(opts.filepath)) {
BKE_reportf(
- op->reports, RPT_ERROR, "Cannot save image, path '%s' is not writable", opts.filepath);
+ op->reports, RPT_ERROR, "Cannot save image, path \"%s\" is not writable", opts.filepath);
+ }
+ else if (save_image_op(bmain, image, iuser, op, &opts)) {
+ /* Report since this can be called from key shortcuts. */
+ BKE_reportf(op->reports, RPT_INFO, "Saved image \"%s\"", opts.filepath);
+ ok = true;
}
BKE_color_managed_view_settings_free(&opts.im_format.view_settings);
@@ -2147,8 +2124,11 @@ static int image_save_exec(bContext *C, wmOperator *op)
static int image_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Image *ima = image_from_context(C);
+ ImageUser *iuser = image_user_from_context(C);
- if (!BKE_image_has_packedfile(ima) && !BKE_image_has_filepath(ima)) {
+ /* Not writable formats or images without a file-path will go to "Save As". */
+ if (!BKE_image_has_packedfile(ima) &&
+ (!BKE_image_has_filepath(ima) || !image_file_format_writable(ima, iuser))) {
WM_operator_name_call(C, "IMAGE_OT_save_as", WM_OP_INVOKE_DEFAULT, NULL);
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 0544a2cbefa..1435b95c9bf 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -516,7 +516,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_DIRECTORY,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/********************* report box operator *********************/
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index db8b6240558..bf21b383ba6 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -503,7 +503,7 @@ static void get_stats_string(
else if (obedit->type == OB_ARMATURE) {
*ofs += BLI_snprintf(info + *ofs,
len - *ofs,
- TIP_("Verts:%s/%s | Bones:%s/%s"),
+ TIP_("Joints:%s/%s | Bones:%s/%s"),
stats_fmt->totvertsel,
stats_fmt->totvert,
stats_fmt->totbonesel,
@@ -664,6 +664,7 @@ void ED_info_draw_stats(
EDGES,
FACES,
TRIS,
+ JOINTS,
BONES,
LAYERS,
FRAMES,
@@ -678,6 +679,7 @@ void ED_info_draw_stats(
STRNCPY(labels[EDGES], IFACE_("Edges"));
STRNCPY(labels[FACES], IFACE_("Faces"));
STRNCPY(labels[TRIS], IFACE_("Triangles"));
+ STRNCPY(labels[JOINTS], IFACE_("Joints"));
STRNCPY(labels[BONES], IFACE_("Bones"));
STRNCPY(labels[LAYERS], IFACE_("Layers"));
STRNCPY(labels[FRAMES], IFACE_("Frames"));
@@ -709,7 +711,7 @@ void ED_info_draw_stats(
stats_row(col1, labels[TRIS], col2, stats_fmt.tottri, NULL, y, height);
}
else if (obedit->type == OB_ARMATURE) {
- stats_row(col1, labels[VERTS], col2, stats_fmt.totvertsel, stats_fmt.totvert, y, height);
+ stats_row(col1, labels[JOINTS], col2, stats_fmt.totvertsel, stats_fmt.totvert, y, height);
stats_row(col1, labels[BONES], col2, stats_fmt.totbonesel, stats_fmt.totbone, y, height);
}
else {
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index db4e2dcdfba..083fd641dc1 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -588,7 +588,7 @@ void nla_buttons_register(ARegionType *art)
strcpy(pt->label, N_("Animation Data"));
strcpy(pt->category, "Edited Action");
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
- pt->flag = PNL_NO_HEADER;
+ pt->flag = PANEL_TYPE_NO_HEADER;
pt->draw = nla_panel_animdata;
pt->poll = nla_animdata_panel_poll;
BLI_addtail(&art->paneltypes, pt);
@@ -598,7 +598,7 @@ void nla_buttons_register(ARegionType *art)
strcpy(pt->label, N_("Active Strip Name"));
strcpy(pt->category, "Strip");
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
- pt->flag = PNL_NO_HEADER;
+ pt->flag = PANEL_TYPE_NO_HEADER;
pt->draw = nla_panel_stripname;
pt->poll = nla_strip_panel_poll;
BLI_addtail(&art->paneltypes, pt);
@@ -618,7 +618,7 @@ void nla_buttons_register(ARegionType *art)
strcpy(pt->category, "Strip");
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw = nla_panel_actclip;
- pt->flag = PNL_DEFAULT_CLOSED;
+ pt->flag = PANEL_TYPE_DEFAULT_CLOSED;
pt->poll = nla_strip_actclip_panel_poll;
BLI_addtail(&art->paneltypes, pt);
@@ -631,7 +631,7 @@ void nla_buttons_register(ARegionType *art)
pt->draw = nla_panel_evaluation;
pt->draw_header = nla_panel_animated_influence_header;
pt->parent = pt_properties;
- pt->flag = PNL_DEFAULT_CLOSED;
+ pt->flag = PANEL_TYPE_DEFAULT_CLOSED;
pt->poll = nla_strip_eval_panel_poll;
BLI_addtail(&pt_properties->children, BLI_genericNodeN(pt));
BLI_addtail(&art->paneltypes, pt);
@@ -645,7 +645,7 @@ void nla_buttons_register(ARegionType *art)
pt->draw = nla_panel_animated_strip_time;
pt->draw_header = nla_panel_animated_strip_time_header;
pt->parent = pt_properties;
- pt->flag = PNL_DEFAULT_CLOSED;
+ pt->flag = PANEL_TYPE_DEFAULT_CLOSED;
pt->poll = nla_strip_eval_panel_poll;
BLI_addtail(&pt_properties->children, BLI_genericNodeN(pt));
BLI_addtail(&art->paneltypes, pt);
diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt
index fc831bf8490..8836c43cd05 100644
--- a/source/blender/editors/space_node/CMakeLists.txt
+++ b/source/blender/editors/space_node/CMakeLists.txt
@@ -27,7 +27,7 @@ set(INC
../../makesdna
../../makesrna
../../nodes
- ../../render/extern/include
+ ../../render
../../compositor
../../windowmanager
../../../../intern/glew-mx
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 66da2887427..16bbca2a0c3 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -748,6 +748,7 @@ static void node_shader_buts_vect_transform(uiLayout *layout, bContext *UNUSED(C
static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
+ uiItemR(layout, ptr, "attribute_type", DEFAULT_FLAGS, IFACE_("Type"), ICON_NONE);
uiItemR(layout, ptr, "attribute_name", DEFAULT_FLAGS, IFACE_("Name"), ICON_NONE);
}
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c
index f8382a17c59..508c0a47e21 100644
--- a/source/blender/editors/space_node/node_add.c
+++ b/source/blender/editors/space_node/node_add.c
@@ -404,7 +404,7 @@ void NODE_OT_add_file(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Data-block name to assign");
}
diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c
index 8fc343a9ed4..6475e753409 100644
--- a/source/blender/editors/space_node/node_buttons.c
+++ b/source/blender/editors/space_node/node_buttons.c
@@ -214,7 +214,7 @@ void node_buttons_register(ARegionType *art)
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw = node_sockets_panel;
pt->poll = node_sockets_poll;
- pt->flag |= PNL_DEFAULT_CLOSED;
+ pt->flag |= PANEL_TYPE_DEFAULT_CLOSED;
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype node panel tree interface");
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index b1659bcd023..a39e84419d0 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -108,7 +108,7 @@ static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags)
node->flag |= NODE_DO_OUTPUT_RECALC;
}
}
- else if (node->type == CMP_NODE_VIEWER || node->type == CMP_NODE_SPLITVIEWER) {
+ else if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
if (recalc_flags & COM_RECALC_VIEWER) {
node->flag |= NODE_DO_OUTPUT_RECALC;
}
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index c6c14a9886e..654b95858bb 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -31,6 +31,7 @@
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "BLI_string.h"
#include "BLT_translation.h"
@@ -59,7 +60,11 @@
#include "NOD_socket.h"
#include "node_intern.h" /* own include */
-static bool node_group_operator_active(bContext *C)
+/* -------------------------------------------------------------------- */
+/** \name Local Utilities
+ * \{ */
+
+static bool node_group_operator_active_poll(bContext *C)
{
if (ED_operator_node_active(C)) {
SpaceNode *snode = CTX_wm_space_node(C);
@@ -68,10 +73,11 @@ static bool node_group_operator_active(bContext *C)
* Disabled otherwise to allow pynodes define their own operators
* with same keymap.
*/
- if (STREQ(snode->tree_idname, "ShaderNodeTree") ||
- STREQ(snode->tree_idname, "CompositorNodeTree") ||
- STREQ(snode->tree_idname, "TextureNodeTree") ||
- STREQ(snode->tree_idname, "SimulationNodeTree")) {
+ if (STR_ELEM(snode->tree_idname,
+ "ShaderNodeTree",
+ "CompositorNodeTree",
+ "TextureNodeTree",
+ "SimulationNodeTree")) {
return true;
}
}
@@ -132,7 +138,11 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname)
return NULL;
}
-/* ***************** Edit Group operator ************* */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Edit Group Operator
+ * \{ */
static int node_group_edit_exec(bContext *C, wmOperator *op)
{
@@ -169,7 +179,7 @@ void NODE_OT_group_edit(wmOperatorType *ot)
/* api callbacks */
ot->exec = node_group_edit_exec;
- ot->poll = node_group_operator_active;
+ ot->poll = node_group_operator_active_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -177,10 +187,16 @@ void NODE_OT_group_edit(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "exit", false, "Exit", "");
}
-/* ******************** Ungroup operator ********************** */
+/** \} */
-/* The given paths will be owned by the returned instance. Both pointers are allowed to point to
- * the same string. */
+/* -------------------------------------------------------------------- */
+/** \name Ungroup Operator
+ * \{ */
+
+/**
+ * The given paths will be owned by the returned instance.
+ * Both pointers are allowed to point to the same string.
+ */
static AnimationBasePathChange *animation_basepath_change_new(const char *src_basepath,
const char *dst_basepath)
{
@@ -422,7 +438,11 @@ void NODE_OT_group_ungroup(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* ******************** Separate operator ********************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Separate Operator
+ * \{ */
/* returns 1 if its OK */
static int node_group_separate_selected(
@@ -634,7 +654,11 @@ void NODE_OT_group_separate(wmOperatorType *ot)
RNA_def_enum(ot->srna, "type", node_group_separate_types, NODE_GS_COPY, "Type", "");
}
-/* ****************** Make Group operator ******************* */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Make Group Operator
+ * \{ */
static bool node_group_make_use_node(bNode *node, bNode *gnode)
{
@@ -1036,7 +1060,11 @@ void NODE_OT_group_make(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* ****************** Group Insert operator ******************* */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Group Insert Operator
+ * \{ */
static int node_group_insert_exec(bContext *C, wmOperator *op)
{
@@ -1086,3 +1114,5 @@ void NODE_OT_group_insert(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+
+/** \} */
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 04e452d5270..aa59b7293a3 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -266,7 +266,7 @@ extern const char *node_context_dir[];
#define NODE_SOCKDY (0.08f * U.widget_unit)
#define NODE_WIDTH(node) (node->width * UI_DPI_FAC)
#define NODE_HEIGHT(node) (node->height * UI_DPI_FAC)
-#define NODE_MARGIN_X (0.95f * U.widget_unit)
+#define NODE_MARGIN_X (1.10f * U.widget_unit)
#define NODE_SOCKSIZE (0.25f * U.widget_unit)
#define NODE_RESIZE_MARGIN (0.20f * U.widget_unit)
#define NODE_LINK_RESOL 12
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index ef7e7874c63..3c861896d37 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -55,7 +55,9 @@
#include "NOD_composite.h"
#include "node_intern.h" /* own include */
-/* **************** View All Operator ************** */
+/* -------------------------------------------------------------------- */
+/** \name View All Operator
+ * \{ */
int space_node_view_flag(
bContext *C, SpaceNode *snode, ARegion *region, const int node_flag, const int smooth_viewtx)
@@ -151,6 +153,12 @@ void NODE_OT_view_all(wmOperatorType *ot)
ot->flag = 0;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name View Selected Operator
+ * \{ */
+
static int node_view_selected_exec(bContext *C, wmOperator *op)
{
ARegion *region = CTX_wm_region(C);
@@ -178,7 +186,11 @@ void NODE_OT_view_selected(wmOperatorType *ot)
ot->flag = 0;
}
-/* **************** Background Image Operators ************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Background Image Operators
+ * \{ */
typedef struct NodeViewMove {
int mvalo[2];
@@ -284,6 +296,12 @@ void NODE_OT_backimage_move(wmOperatorType *ot)
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_XY;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Background Image Zoom
+ * \{ */
+
static int backimage_zoom_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
@@ -316,6 +334,12 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot)
RNA_def_float(ot->srna, "factor", 1.2f, 0.0f, 10.0f, "Factor", "", 0.0f, 10.0f);
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Background Image Fit
+ * \{ */
+
static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
@@ -372,7 +396,11 @@ void NODE_OT_backimage_fit(wmOperatorType *ot)
ot->flag = OPTYPE_BLOCKING;
}
-/******************** sample backdrop operator ********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Sample Backdrop Operator
+ * \{ */
typedef struct ImageSampleInfo {
ARegionType *art;
@@ -642,3 +670,5 @@ void NODE_OT_backimage_sample(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_BLOCKING;
}
+
+/** \} */
diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index 1aa25ba00b1..996570fae25 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -44,8 +44,14 @@ set(SRC
outliner_tree.c
outliner_utils.c
space_outliner.c
+ tree/common.cc
+ tree/tree_display.cc
+ tree/tree_display_libraries.cc
+ tree/tree_display_view_layer.cc
outliner_intern.h
+ tree/tree_display.h
+ tree/tree_display.hh
)
set(LIB
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index c1add28b1e4..8de7c233728 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -453,7 +453,7 @@ static void id_delete(bContext *C, ReportList *reports, TreeElement *te, TreeSto
ID *id = tselem->id;
BLI_assert(id != NULL);
- BLI_assert((tselem->type == 0 && te->idcode != 0) || tselem->type == TSE_LAYER_COLLECTION);
+ BLI_assert(ELEM(tselem->type, 0 && te->idcode != 0, TSE_LAYER_COLLECTION));
UNUSED_VARS_NDEBUG(te);
if (te->idcode == ID_LI && ((Library *)id)->parent != NULL) {
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index d65dec54a20..23a92903d66 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -25,6 +25,10 @@
#include "RNA_types.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* internal exports only */
struct ARegion;
@@ -42,6 +46,13 @@ struct bPoseChannel;
struct wmKeyConfig;
struct wmOperatorType;
+typedef struct SpaceOutliner_Runtime {
+ /**
+ * Internal C++ object to create and manage the tree for a specific display type (View Layers,
+ * Scenes, Blender File, etc.). */
+ struct TreeDisplay *tree_display;
+} SpaceOutliner_Runtime;
+
typedef enum TreeElementInsertType {
TE_INSERT_BEFORE,
TE_INSERT_AFTER,
@@ -527,10 +538,16 @@ bool outliner_tree_traverse(const SpaceOutliner *space_outliner,
float outliner_restrict_columns_width(const struct SpaceOutliner *space_outliner);
TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag);
bool outliner_is_element_visible(const TreeElement *te);
-void outliner_scroll_view(struct SpaceOutliner *space_outliner, struct ARegion *region, int delta_y);
+void outliner_scroll_view(struct SpaceOutliner *space_outliner,
+ struct ARegion *region,
+ int delta_y);
void outliner_tag_redraw_avoid_rebuild_on_open_change(const struct SpaceOutliner *space_outliner,
struct ARegion *region);
/* outliner_sync.c ---------------------------------------------- */
void outliner_sync_selection(const struct bContext *C, struct SpaceOutliner *space_outliner);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 0a0b099eb5b..064d6531bf4 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -27,12 +27,16 @@
#include "DNA_armature_types.h"
#include "DNA_collection_types.h"
+#include "DNA_constraint_types.h"
+#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_light_types.h"
#include "DNA_material_types.h"
+#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
+#include "DNA_shader_fx_types.h"
#include "DNA_world_types.h"
#include "BLI_listbase.h"
@@ -40,21 +44,26 @@
#include "BKE_armature.h"
#include "BKE_collection.h"
+#include "BKE_constraint.h"
#include "BKE_context.h"
#include "BKE_gpencil.h"
+#include "BKE_gpencil_modifier.h"
#include "BKE_layer.h"
#include "BKE_main.h"
+#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_paint.h"
+#include "BKE_particle.h"
#include "BKE_report.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
+#include "BKE_shader_fx.h"
#include "BKE_workspace.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "ED_armature.h"
+#include "ED_buttons.h"
#include "ED_gpencil.h"
#include "ED_object.h"
#include "ED_outliner.h"
@@ -63,6 +72,8 @@
#include "ED_sequencer.h"
#include "ED_undo.h"
+#include "SEQ_sequencer.h"
+
#include "WM_api.h"
#include "WM_toolsystem.h"
#include "WM_types.h"
@@ -801,15 +812,26 @@ static eOLDrawState tree_element_active_psys(bContext *C,
}
static int tree_element_active_constraint(bContext *C,
- Scene *UNUSED(scene),
- ViewLayer *UNUSED(sl),
- TreeElement *UNUSED(te),
+ Scene *scene,
+ ViewLayer *view_layer,
+ TreeElement *te,
TreeStoreElem *tselem,
const eOLSetState set)
{
if (set != OL_SETSEL_NONE) {
Object *ob = (Object *)tselem->id;
+ /* Activate the parent bone if this is a bone constraint. */
+ te = te->parent;
+ while (te) {
+ tselem = TREESTORE(te);
+ if (tselem->type == TSE_POSE_CHANNEL) {
+ tree_element_active_posechannel(C, scene, view_layer, ob, te, tselem, set, false);
+ return OL_DRAWSEL_NONE;
+ }
+ te = te->parent;
+ }
+
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
}
@@ -1041,6 +1063,7 @@ eOLDrawState tree_element_type_active(bContext *C,
case TSE_POSE_CHANNEL:
return tree_element_active_posechannel(
C, tvc->scene, tvc->view_layer, tvc->ob_pose, te, tselem, set, recursive);
+ case TSE_CONSTRAINT_BASE:
case TSE_CONSTRAINT:
return tree_element_active_constraint(C, tvc->scene, tvc->view_layer, te, tselem, set);
case TSE_R_LAYER:
@@ -1081,6 +1104,189 @@ bPoseChannel *outliner_find_parent_bone(TreeElement *te, TreeElement **r_bone_te
return NULL;
}
+static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreElem *tselem)
+{
+ PointerRNA ptr = {0};
+ int context = 0;
+
+ /* ID Types */
+ if (tselem->type == 0) {
+ RNA_id_pointer_create(tselem->id, &ptr);
+
+ switch (te->idcode) {
+ case ID_SCE:
+ context = BCONTEXT_SCENE;
+ break;
+ case ID_OB:
+ context = BCONTEXT_OBJECT;
+ break;
+ case ID_ME:
+ case ID_CU:
+ case ID_MB:
+ case ID_IM:
+ case ID_LT:
+ case ID_LA:
+ case ID_CA:
+ case ID_KE:
+ case ID_SPK:
+ case ID_AR:
+ case ID_GD:
+ case ID_LP:
+ case ID_HA:
+ case ID_PT:
+ case ID_VO:
+ context = BCONTEXT_DATA;
+ break;
+ case ID_MA:
+ context = BCONTEXT_MATERIAL;
+ break;
+ case ID_WO:
+ context = BCONTEXT_WORLD;
+ break;
+ }
+ }
+ else {
+ switch (tselem->type) {
+ case TSE_DEFGROUP_BASE:
+ case TSE_DEFGROUP:
+ RNA_id_pointer_create(tselem->id, &ptr);
+ context = BCONTEXT_DATA;
+ break;
+ case TSE_CONSTRAINT_BASE:
+ case TSE_CONSTRAINT: {
+ TreeElement *bone_te = NULL;
+ bPoseChannel *pchan = outliner_find_parent_bone(te, &bone_te);
+
+ if (pchan) {
+ RNA_pointer_create(TREESTORE(bone_te)->id, &RNA_PoseBone, pchan, &ptr);
+ context = BCONTEXT_BONE_CONSTRAINT;
+ }
+ else {
+ RNA_id_pointer_create(tselem->id, &ptr);
+ context = BCONTEXT_CONSTRAINT;
+ }
+
+ /* Expand the selected constraint in the properties editor. */
+ if (tselem->type != TSE_CONSTRAINT_BASE) {
+ BKE_constraint_panel_expand(te->directdata);
+ }
+ break;
+ }
+ case TSE_MODIFIER_BASE:
+ case TSE_MODIFIER:
+ RNA_id_pointer_create(tselem->id, &ptr);
+ context = BCONTEXT_MODIFIER;
+
+ if (tselem->type != TSE_MODIFIER_BASE) {
+ Object *ob = (Object *)tselem->id;
+
+ if (ob->type == OB_GPENCIL) {
+ BKE_gpencil_modifier_panel_expand(te->directdata);
+ }
+ else {
+ ModifierData *md = (ModifierData *)te->directdata;
+
+ switch ((ModifierType)md->type) {
+ case eModifierType_ParticleSystem:
+ context = BCONTEXT_PARTICLE;
+ break;
+ case eModifierType_Cloth:
+ case eModifierType_Softbody:
+ case eModifierType_Collision:
+ case eModifierType_Fluidsim:
+ case eModifierType_DynamicPaint:
+ case eModifierType_Fluid:
+ context = BCONTEXT_PHYSICS;
+ break;
+ default:
+ break;
+ }
+
+ if (context == BCONTEXT_MODIFIER) {
+ BKE_modifier_panel_expand(md);
+ }
+ }
+ }
+ break;
+ case TSE_GPENCIL_EFFECT_BASE:
+ case TSE_GPENCIL_EFFECT:
+ RNA_id_pointer_create(tselem->id, &ptr);
+ context = BCONTEXT_SHADERFX;
+
+ if (tselem->type != TSE_GPENCIL_EFFECT_BASE) {
+ BKE_shaderfx_panel_expand(te->directdata);
+ }
+ break;
+ case TSE_BONE: {
+ bArmature *arm = (bArmature *)tselem->id;
+ Bone *bone = te->directdata;
+
+ RNA_pointer_create(&arm->id, &RNA_Bone, bone, &ptr);
+ context = BCONTEXT_BONE;
+ break;
+ }
+ case TSE_EBONE: {
+ bArmature *arm = (bArmature *)tselem->id;
+ EditBone *ebone = te->directdata;
+
+ RNA_pointer_create(&arm->id, &RNA_EditBone, ebone, &ptr);
+ context = BCONTEXT_BONE;
+ break;
+ }
+ case TSE_POSE_CHANNEL: {
+ Object *ob = (Object *)tselem->id;
+ bArmature *arm = ob->data;
+ bPoseChannel *pchan = te->directdata;
+
+ RNA_pointer_create(&arm->id, &RNA_PoseBone, pchan, &ptr);
+ context = BCONTEXT_BONE;
+ break;
+ }
+ case TSE_POSE_BASE: {
+ Object *ob = (Object *)tselem->id;
+ bArmature *arm = ob->data;
+
+ RNA_pointer_create(&arm->id, &RNA_Armature, arm, &ptr);
+ context = BCONTEXT_DATA;
+ break;
+ }
+ case TSE_R_LAYER_BASE:
+ case TSE_R_LAYER: {
+ ViewLayer *view_layer = te->directdata;
+
+ RNA_pointer_create(tselem->id, &RNA_ViewLayer, view_layer, &ptr);
+ context = BCONTEXT_VIEW_LAYER;
+ break;
+ }
+ case TSE_POSEGRP_BASE:
+ case TSE_POSEGRP: {
+ Object *ob = (Object *)tselem->id;
+ bArmature *arm = ob->data;
+
+ RNA_pointer_create(&arm->id, &RNA_Armature, arm, &ptr);
+ context = BCONTEXT_DATA;
+ break;
+ }
+ case TSE_LINKED_PSYS: {
+ Object *ob = (Object *)tselem->id;
+ ParticleSystem *psys = psys_get_current(ob);
+
+ RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &ptr);
+ context = BCONTEXT_PARTICLE;
+ break;
+ }
+ case TSE_GP_LAYER:
+ RNA_id_pointer_create(tselem->id, &ptr);
+ context = BCONTEXT_DATA;
+ break;
+ }
+ }
+
+ if (ptr.data) {
+ ED_buttons_set_context(C, &ptr, context);
+ }
+}
+
/* ================================================ */
/**
@@ -1105,14 +1311,8 @@ static void do_outliner_item_activate_tree_element(bContext *C,
TSE_SEQUENCE_DUP,
TSE_EBONE,
TSE_LAYER_COLLECTION)) {
- /* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects,
- * we do not want to switch out of edit mode (see T48328 for details). */
- }
- else if (tselem->id && OB_DATA_SUPPORT_EDITMODE(te->idcode)) {
- /* Support edit-mode toggle, keeping the active object as is. */
- }
- else if (tselem->type == TSE_POSE_BASE) {
- /* Support pose mode toggle, keeping the active object as is. */
+ /* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several
+ * objects, we do not want to switch out of edit mode (see T48328 for details). */
}
else if (do_activate_data) {
tree_element_set_active_object(C,
@@ -1187,6 +1387,8 @@ static void do_outliner_item_activate_tree_element(bContext *C,
extend ? OL_SETSEL_EXTEND : OL_SETSEL_NORMAL,
recursive);
}
+
+ outliner_set_properties_tab(C, te, tselem);
}
/* Select the item using the set flags */
@@ -1242,7 +1444,7 @@ static bool do_outliner_range_select_recursive(ListBase *lb,
}
/* Set state for selection */
- if (te == active || te == cursor) {
+ if (ELEM(te, active, cursor)) {
selecting = !selecting;
}
diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c
index 24fa72fdabf..0f5c74a9168 100644
--- a/source/blender/editors/space_outliner/outliner_sync.c
+++ b/source/blender/editors/space_outliner/outliner_sync.c
@@ -39,7 +39,6 @@
#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_object.h"
-#include "BKE_sequencer.h"
#include "DEG_depsgraph.h"
@@ -47,6 +46,8 @@
#include "ED_object.h"
#include "ED_outliner.h"
+#include "SEQ_sequencer.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -256,9 +257,9 @@ static void outliner_select_sync_to_edit_bone(ViewLayer *view_layer,
add_selected_item(selected_ebones, ebone);
}
else if (!is_edit_bone_selected(selected_ebones, ebone)) {
- /* Dont flush to parent bone tip, synced selection is iterating the whole tree so deselecting
- * potential children with 'ED_armature_ebone_select_set(ebone, false)' would leave own tip
- * deselected. */
+ /* Don't flush to parent bone tip, synced selection is iterating the whole tree so
+ * deselecting potential children with `ED_armature_ebone_select_set(ebone, false)`
+ * would leave own tip deselected. */
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
}
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index cbdeb350ba4..159a4616ba7 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -65,7 +65,6 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
-#include "BKE_sequencer.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -89,6 +88,8 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
+#include "SEQ_sequencer.h"
+
#include "outliner_intern.h"
/* -------------------------------------------------------------------- */
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 4fbb394c38f..83be26793ee 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -69,7 +69,6 @@
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_outliner_treehash.h"
-#include "BKE_sequencer.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -81,9 +80,12 @@
#include "RNA_access.h"
+#include "SEQ_sequencer.h"
+
#include "UI_interface.h"
#include "outliner_intern.h"
+#include "tree/tree_display.h"
#ifdef WIN32
# include "BLI_math_base.h" /* M_PI */
@@ -93,7 +95,6 @@
static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
Collection *collection,
TreeElement *ten);
-static void outliner_make_object_parent_hierarchy(ListBase *lb);
static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner);
/* ********************************************************* */
@@ -236,14 +237,6 @@ void outliner_free_tree_element(TreeElement *element, ListBase *parent_subtree)
/* ********************************************************* */
-/* Prototype, see functions below */
-static TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
- ListBase *lb,
- void *idv,
- TreeElement *parent,
- short type,
- short index);
-
/* -------------------------------------------------------- */
bool outliner_requires_rebuild_on_select_or_active_change(const SpaceOutliner *space_outliner)
@@ -919,12 +912,12 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
* \note: If child items are only added to the tree if the item is open, the TSE_ type _must_ be
* added to #outliner_element_needs_rebuild_on_open_change().
*/
-static TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
- ListBase *lb,
- void *idv,
- TreeElement *parent,
- short type,
- short index)
+TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
+ ListBase *lb,
+ void *idv,
+ TreeElement *parent,
+ short type,
+ short index)
{
TreeElement *te;
TreeStoreElem *tselem;
@@ -1389,110 +1382,6 @@ static void outliner_add_seq_dup(SpaceOutliner *space_outliner,
/* ----------------------------------------------- */
-static const char *outliner_idcode_to_plural(short idcode)
-{
- const char *propname = BKE_idtype_idcode_to_name_plural(idcode);
- PropertyRNA *prop = RNA_struct_type_find_property(&RNA_BlendData, propname);
- return (prop) ? RNA_property_ui_name(prop) : "UNKNOWN";
-}
-
-static bool outliner_library_id_show(Library *lib, ID *id, short filter_id_type)
-{
- if (id->lib != lib) {
- return false;
- }
-
- if (filter_id_type == ID_GR) {
- /* Don't show child collections of non-scene master collection,
- * they are already shown as children. */
- Collection *collection = (Collection *)id;
- bool has_non_scene_parent = false;
-
- LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) {
- if (!(cparent->collection->flag & COLLECTION_IS_MASTER)) {
- has_non_scene_parent = true;
- }
- }
-
- if (has_non_scene_parent) {
- return false;
- }
- }
-
- return true;
-}
-
-static TreeElement *outliner_add_library_contents(Main *mainvar,
- SpaceOutliner *space_outliner,
- ListBase *lb,
- Library *lib)
-{
- TreeElement *ten, *tenlib = NULL;
- ListBase *lbarray[MAX_LIBARRAY];
- int a, tot;
- short filter_id_type = (space_outliner->filter & SO_FILTER_ID_TYPE) ?
- space_outliner->filter_id_type :
- 0;
-
- if (filter_id_type) {
- lbarray[0] = which_libbase(mainvar, space_outliner->filter_id_type);
- tot = 1;
- }
- else {
- tot = set_listbasepointers(mainvar, lbarray);
- }
-
- for (a = 0; a < tot; a++) {
- if (lbarray[a] && lbarray[a]->first) {
- ID *id = lbarray[a]->first;
- const bool is_library = (GS(id->name) == ID_LI) && (lib != NULL);
-
- /* check if there's data in current lib */
- for (; id; id = id->next) {
- if (id->lib == lib) {
- break;
- }
- }
-
- /* We always want to create an entry for libraries, even if/when we have no more IDs from
- * them. This invalid state is important to show to user as well.*/
- if (id != NULL || is_library) {
- if (!tenlib) {
- /* Create library tree element on demand, depending if there are any data-blocks. */
- if (lib) {
- tenlib = outliner_add_element(space_outliner, lb, lib, NULL, 0, 0);
- }
- else {
- tenlib = outliner_add_element(space_outliner, lb, mainvar, NULL, TSE_ID_BASE, 0);
- tenlib->name = IFACE_("Current File");
- }
- }
-
- /* Create data-block list parent element on demand. */
- if (id != NULL) {
- if (filter_id_type) {
- ten = tenlib;
- }
- else {
- ten = outliner_add_element(
- space_outliner, &tenlib->subtree, lbarray[a], NULL, TSE_ID_BASE, 0);
- ten->directdata = lbarray[a];
- ten->name = outliner_idcode_to_plural(GS(id->name));
- }
-
- for (id = lbarray[a]->first; id; id = id->next) {
- if (outliner_library_id_show(lib, id, filter_id_type)) {
- outliner_add_element(space_outliner, &ten->subtree, id, ten, 0, 0);
- }
- }
- }
- }
- }
- }
-
- return tenlib;
-}
-
static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *space_outliner)
{
TreeElement *ten;
@@ -1545,82 +1434,6 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *space
}
}
-static void outliner_add_layer_collection_objects(SpaceOutliner *space_outliner,
- ListBase *tree,
- ViewLayer *layer,
- LayerCollection *lc,
- TreeElement *ten)
-{
- LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) {
- Base *base = BKE_view_layer_base_find(layer, cob->ob);
- TreeElement *te_object = outliner_add_element(space_outliner, tree, base->object, ten, 0, 0);
- te_object->directdata = base;
-
- if (!(base->flag & BASE_VISIBLE_VIEWLAYER)) {
- te_object->flag |= TE_DISABLED;
- }
- }
-}
-
-static void outliner_add_layer_collections_recursive(SpaceOutliner *space_outliner,
- ListBase *tree,
- ViewLayer *layer,
- ListBase *layer_collections,
- TreeElement *parent_ten,
- const bool show_objects)
-{
- LISTBASE_FOREACH (LayerCollection *, lc, layer_collections) {
- const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0;
- TreeElement *ten;
-
- if (exclude && ((space_outliner->show_restrict_flags & SO_RESTRICT_ENABLE) == 0)) {
- ten = parent_ten;
- }
- else {
- ID *id = &lc->collection->id;
- ten = outliner_add_element(space_outliner, tree, id, parent_ten, TSE_LAYER_COLLECTION, 0);
-
- ten->name = id->name + 2;
- ten->directdata = lc;
-
- /* Open by default, except linked collections, which may contain many elements. */
- TreeStoreElem *tselem = TREESTORE(ten);
- if (!(tselem->used || ID_IS_LINKED(id) || ID_IS_OVERRIDE_LIBRARY(id))) {
- tselem->flag &= ~TSE_CLOSED;
- }
-
- if (exclude || (lc->runtime_flag & LAYER_COLLECTION_VISIBLE_VIEW_LAYER) == 0) {
- ten->flag |= TE_DISABLED;
- }
- }
-
- outliner_add_layer_collections_recursive(
- space_outliner, &ten->subtree, layer, &lc->layer_collections, ten, show_objects);
- if (!exclude && show_objects) {
- outliner_add_layer_collection_objects(space_outliner, &ten->subtree, layer, lc, ten);
- }
- }
-}
-
-static void outliner_add_view_layer(SpaceOutliner *space_outliner,
- ListBase *tree,
- TreeElement *parent,
- ViewLayer *layer,
- const bool show_objects)
-{
- /* First layer collection is for master collection, don't show it. */
- LayerCollection *lc = layer->layer_collections.first;
- if (lc == NULL) {
- return;
- }
-
- outliner_add_layer_collections_recursive(
- space_outliner, tree, layer, &lc->layer_collections, parent, show_objects);
- if (show_objects) {
- outliner_add_layer_collection_objects(space_outliner, tree, layer, lc, parent);
- }
-}
-
BLI_INLINE void outliner_add_collection_init(TreeElement *te, Collection *collection)
{
te->name = BKE_collection_ui_name_get(collection);
@@ -1660,7 +1473,7 @@ static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outli
/* Hierarchy --------------------------------------------- */
/* make sure elements are correctly nested */
-static void outliner_make_object_parent_hierarchy(ListBase *lb)
+void outliner_make_object_parent_hierarchy(ListBase *lb)
{
TreeElement *te, *ten, *tep;
TreeStoreElem *tselem;
@@ -1685,103 +1498,6 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb)
}
}
-/**
- * For all objects in the tree, lookup the parent in this map,
- * and move or add tree elements as needed.
- */
-static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *space_outliner,
- GHash *object_tree_elements_hash)
-{
- GHashIterator gh_iter;
- GHASH_ITER (gh_iter, object_tree_elements_hash) {
- Object *child = BLI_ghashIterator_getKey(&gh_iter);
-
- if (child->parent == NULL) {
- continue;
- }
-
- ListBase *child_ob_tree_elements = BLI_ghashIterator_getValue(&gh_iter);
- ListBase *parent_ob_tree_elements = BLI_ghash_lookup(object_tree_elements_hash, child->parent);
- if (parent_ob_tree_elements == NULL) {
- continue;
- }
-
- LISTBASE_FOREACH (LinkData *, link, parent_ob_tree_elements) {
- TreeElement *parent_ob_tree_element = link->data;
- TreeElement *parent_ob_collection_tree_element = NULL;
- bool found = false;
-
- /* We always want to remove the child from the direct collection its parent is nested under.
- * This is particularly important when dealing with multi-level nesting (grandchildren). */
- parent_ob_collection_tree_element = parent_ob_tree_element->parent;
- while (!ELEM(TREESTORE(parent_ob_collection_tree_element)->type,
- TSE_VIEW_COLLECTION_BASE,
- TSE_LAYER_COLLECTION)) {
- parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent;
- }
-
- LISTBASE_FOREACH (LinkData *, link_iter, child_ob_tree_elements) {
- TreeElement *child_ob_tree_element = link_iter->data;
-
- if (child_ob_tree_element->parent == parent_ob_collection_tree_element) {
- /* Move from the collection subtree into the parent object subtree. */
- BLI_remlink(&parent_ob_collection_tree_element->subtree, child_ob_tree_element);
- BLI_addtail(&parent_ob_tree_element->subtree, child_ob_tree_element);
- child_ob_tree_element->parent = parent_ob_tree_element;
- found = true;
- break;
- }
- }
-
- if (!found) {
- /* We add the child in the tree even if it is not in the collection.
- * We deliberately clear its sub-tree though, to make it less prominent. */
- TreeElement *child_ob_tree_element = outliner_add_element(
- space_outliner, &parent_ob_tree_element->subtree, child, parent_ob_tree_element, 0, 0);
- outliner_free_tree(&child_ob_tree_element->subtree);
- child_ob_tree_element->flag |= TE_CHILD_NOT_IN_COLLECTION;
- BLI_addtail(child_ob_tree_elements, BLI_genericNodeN(child_ob_tree_element));
- }
- }
- }
-}
-
-/**
- * Build a map from Object* to a list of TreeElement* matching the object.
- */
-static void outliner_object_tree_elements_lookup_create_recursive(GHash *object_tree_elements_hash,
- TreeElement *te_parent)
-{
- LISTBASE_FOREACH (TreeElement *, te, &te_parent->subtree) {
- TreeStoreElem *tselem = TREESTORE(te);
-
- if (tselem->type == TSE_LAYER_COLLECTION) {
- outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te);
- }
- else if (tselem->type == 0 && te->idcode == ID_OB) {
- Object *ob = (Object *)tselem->id;
- ListBase *tree_elements = BLI_ghash_lookup(object_tree_elements_hash, ob);
-
- if (tree_elements == NULL) {
- tree_elements = MEM_callocN(sizeof(ListBase), __func__);
- BLI_ghash_insert(object_tree_elements_hash, ob, tree_elements);
- }
-
- BLI_addtail(tree_elements, BLI_genericNodeN(te));
- outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te);
- }
- }
-}
-
-static void outliner_object_tree_elements_lookup_free(GHash *object_tree_elements_hash)
-{
- GHASH_FOREACH_BEGIN (ListBase *, tree_elements, object_tree_elements_hash) {
- BLI_freelistN(tree_elements);
- MEM_freeN(tree_elements);
- }
- GHASH_FOREACH_END();
-}
-
/* Sorting ------------------------------------------------------ */
typedef struct tTreeSort {
@@ -2206,6 +1922,9 @@ static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner)
case SO_FILTER_OB_ACTIVE:
exclude_filter |= SO_FILTER_OB_STATE_ACTIVE;
break;
+ case SO_FILTER_OB_SELECTABLE:
+ exclude_filter |= SO_FILTER_OB_STATE_SELECTABLE;
+ break;
}
return exclude_filter;
@@ -2288,6 +2007,11 @@ static bool outliner_element_visible_get(ViewLayer *view_layer,
return false;
}
}
+ else if (exclude_filter & SO_FILTER_OB_STATE_SELECTABLE) {
+ if ((base->flag & BASE_SELECTABLE) == 0) {
+ return false;
+ }
+ }
else {
BLI_assert(exclude_filter & SO_FILTER_OB_STATE_ACTIVE);
if (base != BASACT(view_layer)) {
@@ -2490,59 +2214,23 @@ void outliner_build_tree(Main *mainvar,
outliner_free_tree(&space_outliner->tree);
outliner_storage_cleanup(space_outliner);
+ outliner_tree_display_destroy(&space_outliner->runtime->tree_display);
- /* options */
- if (space_outliner->outlinevis == SO_LIBRARIES) {
- Library *lib;
-
- /* current file first - mainvar provides tselem with unique pointer - not used */
- ten = outliner_add_library_contents(mainvar, space_outliner, &space_outliner->tree, NULL);
- if (ten) {
- tselem = TREESTORE(ten);
- if (!tselem->used) {
- tselem->flag &= ~TSE_CLOSED;
- }
- }
+ space_outliner->runtime->tree_display = outliner_tree_display_create(space_outliner->outlinevis,
+ space_outliner);
+ if (space_outliner->runtime->tree_display) {
+ TreeSourceData source_data = {.bmain = mainvar, .scene = scene, .view_layer = view_layer};
+ space_outliner->tree = outliner_tree_display_build_tree(space_outliner->runtime->tree_display,
+ &source_data);
+ }
- for (lib = mainvar->libraries.first; lib; lib = lib->id.next) {
- ten = outliner_add_library_contents(mainvar, space_outliner, &space_outliner->tree, lib);
- /* NULL-check matters, due to filtering there may not be a new element. */
- if (ten) {
- lib->id.newid = (ID *)ten;
- }
- }
- /* make hierarchy */
- ten = space_outliner->tree.first;
- if (ten != NULL) {
- ten = ten->next; /* first one is main */
- while (ten) {
- TreeElement *nten = ten->next, *par;
- tselem = TREESTORE(ten);
- lib = (Library *)tselem->id;
- if (lib && lib->parent) {
- par = (TreeElement *)lib->parent->id.newid;
- if (tselem->id->tag & LIB_TAG_INDIRECT) {
- /* Only remove from 'first level' if lib is not also directly used. */
- BLI_remlink(&space_outliner->tree, ten);
- BLI_addtail(&par->subtree, ten);
- ten->parent = par;
- }
- else {
- /* Else, make a new copy of the libtree for our parent. */
- TreeElement *dupten = outliner_add_library_contents(
- mainvar, space_outliner, &par->subtree, lib);
- if (dupten) {
- dupten->parent = par;
- }
- }
- }
- ten = nten;
- }
- }
- /* restore newid pointers */
- for (lib = mainvar->libraries.first; lib; lib = lib->id.next) {
- lib->id.newid = NULL;
- }
+ if (space_outliner->runtime->tree_display) {
+ /* Skip if there's a tree-display that's responsible for adding all elements. */
+ }
+ /* options */
+ else if (space_outliner->outlinevis == SO_LIBRARIES) {
+ /* Ported to new tree-display, should be built there already. */
+ BLI_assert(false);
}
else if (space_outliner->outlinevis == SO_SCENES) {
Scene *sce;
@@ -2603,38 +2291,8 @@ void outliner_build_tree(Main *mainvar,
outliner_add_orphaned_datablocks(mainvar, space_outliner);
}
else if (space_outliner->outlinevis == SO_VIEW_LAYER) {
- if (space_outliner->filter & SO_FILTER_NO_COLLECTION) {
- /* Show objects in the view layer. */
- LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
- TreeElement *te_object = outliner_add_element(
- space_outliner, &space_outliner->tree, base->object, NULL, 0, 0);
- te_object->directdata = base;
- }
-
- if ((space_outliner->filter & SO_FILTER_NO_CHILDREN) == 0) {
- outliner_make_object_parent_hierarchy(&space_outliner->tree);
- }
- }
- else {
- /* Show collections in the view layer. */
- ten = outliner_add_element(
- space_outliner, &space_outliner->tree, scene, NULL, TSE_VIEW_COLLECTION_BASE, 0);
- ten->name = IFACE_("Scene Collection");
- TREESTORE(ten)->flag &= ~TSE_CLOSED;
-
- bool show_objects = !(space_outliner->filter & SO_FILTER_NO_OBJECT);
- outliner_add_view_layer(space_outliner, &ten->subtree, ten, view_layer, show_objects);
-
- if ((space_outliner->filter & SO_FILTER_NO_CHILDREN) == 0) {
- GHash *object_tree_elements_hash = BLI_ghash_new(
- BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
- outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, ten);
- outliner_make_object_parent_hierarchy_collections(space_outliner,
- object_tree_elements_hash);
- outliner_object_tree_elements_lookup_free(object_tree_elements_hash);
- BLI_ghash_free(object_tree_elements_hash, NULL, NULL);
- }
- }
+ /* Ported to new tree-display, should be built there already. */
+ BLI_assert(false);
}
if ((space_outliner->flag & SO_SKIP_SORT_ALPHA) == 0) {
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 8be7f4d1bad..5ec55eee7fb 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -53,6 +53,7 @@
#include "GPU_framebuffer.h"
#include "outliner_intern.h"
+#include "tree/tree_display.h"
static void outliner_main_region_init(wmWindowManager *wm, ARegion *region)
{
@@ -351,11 +352,22 @@ static void outliner_free(SpaceLink *sl)
if (space_outliner->treehash) {
BKE_outliner_treehash_free(space_outliner->treehash);
}
+
+ if (space_outliner->runtime) {
+ outliner_tree_display_destroy(&space_outliner->runtime->tree_display);
+ MEM_freeN(space_outliner->runtime);
+ }
}
/* spacetype; init callback */
-static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
+static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *area)
{
+ SpaceOutliner *space_outliner = area->spacedata.first;
+
+ if (space_outliner->runtime == NULL) {
+ space_outliner->runtime = MEM_callocN(sizeof(*space_outliner->runtime),
+ "SpaceOutliner_Runtime");
+ }
}
static SpaceLink *outliner_duplicate(SpaceLink *sl)
@@ -369,6 +381,11 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl)
space_outliner_new->sync_select_dirty = WM_OUTLINER_SYNC_SELECT_FROM_ALL;
+ if (space_outliner->runtime) {
+ space_outliner_new->runtime = MEM_dupallocN(space_outliner->runtime);
+ space_outliner_new->runtime->tree_display = NULL;
+ }
+
return (SpaceLink *)space_outliner_new;
}
diff --git a/source/blender/editors/space_outliner/tree/common.cc b/source/blender/editors/space_outliner/tree/common.cc
new file mode 100644
index 00000000000..65c9448634c
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/common.cc
@@ -0,0 +1,41 @@
+/*
+ * 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 spoutliner
+ *
+ * Functions and helpers shared between tree-display types or other tree related code.
+ */
+
+#include "BKE_idtype.h"
+
+#include "RNA_access.h"
+
+#include "tree_display.hh"
+
+/* -------------------------------------------------------------------- */
+/** \name ID Helpers.
+ *
+ * \{ */
+
+const char *outliner_idcode_to_plural(short idcode)
+{
+ const char *propname = BKE_idtype_idcode_to_name_plural(idcode);
+ PropertyRNA *prop = RNA_struct_type_find_property(&RNA_BlendData, propname);
+ return (prop) ? RNA_property_ui_name(prop) : "UNKNOWN";
+}
+
+/** \} */
diff --git a/source/blender/editors/space_outliner/tree/tree_display.cc b/source/blender/editors/space_outliner/tree/tree_display.cc
new file mode 100644
index 00000000000..12599733275
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_display.cc
@@ -0,0 +1,60 @@
+/*
+ * 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 spoutliner
+ */
+
+#include "BLI_listbase.h"
+
+#include "DNA_listBase.h"
+
+#include "tree_display.hh"
+
+using namespace blender::ed::outliner;
+
+TreeDisplay *outliner_tree_display_create(eSpaceOutliner_Mode mode, SpaceOutliner *space_outliner)
+{
+ AbstractTreeDisplay *tree_display = nullptr;
+
+ switch (mode) {
+ case SO_SCENES:
+ break;
+ case SO_LIBRARIES:
+ tree_display = new TreeDisplayLibraries(*space_outliner);
+ break;
+ case SO_SEQUENCE:
+ case SO_DATA_API:
+ case SO_ID_ORPHANS:
+ break;
+ case SO_VIEW_LAYER:
+ tree_display = new TreeDisplayViewLayer(*space_outliner);
+ break;
+ }
+
+ return reinterpret_cast<TreeDisplay *>(tree_display);
+}
+
+void outliner_tree_display_destroy(TreeDisplay **tree_display)
+{
+ delete reinterpret_cast<AbstractTreeDisplay *>(*tree_display);
+ *tree_display = nullptr;
+}
+
+ListBase outliner_tree_display_build_tree(TreeDisplay *tree_display, TreeSourceData *source_data)
+{
+ return reinterpret_cast<AbstractTreeDisplay *>(tree_display)->buildTree(*source_data);
+}
diff --git a/source/blender/editors/space_outliner/tree/tree_display.h b/source/blender/editors/space_outliner/tree/tree_display.h
new file mode 100644
index 00000000000..4ef71ded133
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_display.h
@@ -0,0 +1,64 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spoutliner
+ *
+ * C-API for the Tree-Display types.
+ */
+
+#pragma once
+
+#include "DNA_space_types.h"
+
+struct ListBase;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** C alias for an #AbstractTreeDisplay handle. */
+typedef struct TreeDisplay TreeDisplay;
+
+/**
+ * \brief The data to build the tree from.
+ */
+typedef struct TreeSourceData {
+ struct Main *bmain;
+ struct Scene *scene;
+ struct ViewLayer *view_layer;
+} TreeSourceData;
+
+TreeDisplay *outliner_tree_display_create(eSpaceOutliner_Mode mode, SpaceOutliner *space_outliner);
+void outliner_tree_display_destroy(TreeDisplay **tree_display);
+
+ListBase outliner_tree_display_build_tree(TreeDisplay *tree_display, TreeSourceData *source_data);
+
+/* The following functions are needed to build the tree. They are calls back into C; the way
+ * elements are created should be refactored and ported to C++ with a new design/API too. */
+struct TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
+ ListBase *lb,
+ void *idv,
+ struct TreeElement *parent,
+ short type,
+ short index);
+void outliner_make_object_parent_hierarchy(ListBase *lb);
+
+const char *outliner_idcode_to_plural(short idcode);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/editors/space_outliner/tree/tree_display.hh b/source/blender/editors/space_outliner/tree/tree_display.hh
new file mode 100644
index 00000000000..a3d9a626d1d
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_display.hh
@@ -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 spoutliner
+ *
+ * \brief Establish and manage Outliner trees for different display modes.
+ *
+ * Each Outliner display mode (e.g View Layer, Scenes, Blender File) is implemented as a
+ * tree-display class with the #AbstractTreeDisplay interface.
+ *
+ * Their main responsibility is building the Outliner tree for a display mode. For that, they
+ * implement the #buildTree() function, which based on Blender data (#TreeSourceData), builds a
+ * custom tree of whatever data it wants to visualize.
+ * Further, they can implement display mode dependent queries and general operations using the
+ * #AbstractTreeDisplay abstraction as common interface.
+ *
+ * Outliners keep the current tree-display object alive until the next full tree rebuild to keep
+ * access to it.
+ */
+
+#pragma once
+
+#include "tree_display.h"
+
+struct ListBase;
+struct Main;
+struct SpaceOutliner;
+struct TreeElement;
+struct TreeSourceData;
+
+namespace blender::ed::outliner {
+
+/* -------------------------------------------------------------------- */
+/* Tree-Display Interface */
+
+/**
+ * \brief Base Class For Tree-Displays
+ *
+ * Abstract base class defining the interface for tree-display variants.
+ */
+class AbstractTreeDisplay {
+ public:
+ AbstractTreeDisplay(SpaceOutliner &space_outliner) : space_outliner_(space_outliner)
+ {
+ }
+ virtual ~AbstractTreeDisplay() = default;
+
+ /**
+ * Build a tree for this display mode with the Blender context data given in \a source_data and
+ * the view settings in \a space_outliner.
+ */
+ virtual ListBase buildTree(const TreeSourceData &source_data) = 0;
+
+ protected:
+ /** All derived classes will need a handle to this, so storing it in the base for convenience. */
+ SpaceOutliner &space_outliner_;
+};
+
+/* -------------------------------------------------------------------- */
+/* View Layer Tree-Display */
+
+/**
+ * \brief Tree-Display for the View Layer display mode.
+ */
+class TreeDisplayViewLayer final : public AbstractTreeDisplay {
+ ViewLayer *view_layer_ = nullptr;
+ bool show_objects_ = true;
+
+ public:
+ TreeDisplayViewLayer(SpaceOutliner &space_outliner);
+
+ ListBase buildTree(const TreeSourceData &source_data) override;
+
+ private:
+ void add_view_layer(ListBase &, TreeElement &);
+ void add_layer_collections_recursive(ListBase &, ListBase &, TreeElement &);
+ void add_layer_collection_objects(ListBase &, LayerCollection &, TreeElement &);
+ void add_layer_collection_objects_children(TreeElement &);
+};
+
+/* -------------------------------------------------------------------- */
+/* Library Tree-Display */
+
+/**
+ * \brief Tree-Display for the Libraries display mode.
+ */
+class TreeDisplayLibraries final : public AbstractTreeDisplay {
+ public:
+ TreeDisplayLibraries(SpaceOutliner &space_outliner);
+
+ ListBase buildTree(const TreeSourceData &source_data) override;
+
+ private:
+ TreeElement *add_library_contents(Main &, ListBase &, Library *) const;
+ bool library_id_filter_poll(Library *lib, ID *id) const;
+ short id_filter_get() const;
+};
+
+} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_display_libraries.cc b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc
new file mode 100644
index 00000000000..bd0870c837c
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc
@@ -0,0 +1,213 @@
+/*
+ * 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 spoutliner
+ */
+
+#include "BLI_listbase.h"
+#include "BLI_listbase_wrapper.hh"
+
+#include "BKE_collection.h"
+#include "BKE_main.h"
+
+#include "BLT_translation.h"
+
+#include "../outliner_intern.h"
+#include "tree_display.hh"
+
+namespace blender::ed::outliner {
+
+/* Convenience/readability. */
+template<typename T> using List = ListBaseWrapper<T>;
+
+TreeDisplayLibraries::TreeDisplayLibraries(SpaceOutliner &space_outliner)
+ : AbstractTreeDisplay(space_outliner)
+{
+}
+
+ListBase TreeDisplayLibraries::buildTree(const TreeSourceData &source_data)
+{
+ ListBase tree = {nullptr};
+
+ {
+ /* current file first - mainvar provides tselem with unique pointer - not used */
+ TreeElement *ten = add_library_contents(*source_data.bmain, tree, nullptr);
+ TreeStoreElem *tselem;
+
+ if (ten) {
+ tselem = TREESTORE(ten);
+ if (!tselem->used) {
+ tselem->flag &= ~TSE_CLOSED;
+ }
+ }
+ }
+
+ for (ID *id : List<ID>(source_data.bmain->libraries)) {
+ Library *lib = reinterpret_cast<Library *>(id);
+ TreeElement *ten = add_library_contents(*source_data.bmain, tree, lib);
+ /* NULL-check matters, due to filtering there may not be a new element. */
+ if (ten) {
+ lib->id.newid = (ID *)ten;
+ }
+ }
+
+ /* make hierarchy */
+ for (TreeElement *ten : List<TreeElement>(tree)) {
+ if (ten == tree.first) {
+ /* First item is main, skip. */
+ continue;
+ }
+
+ TreeStoreElem *tselem = TREESTORE(ten);
+ Library *lib = (Library *)tselem->id;
+ BLI_assert(!lib || (GS(lib->id.name) == ID_LI));
+ if (!lib || !lib->parent) {
+ continue;
+ }
+
+ TreeElement *parent = (TreeElement *)lib->parent->id.newid;
+
+ if (tselem->id->tag & LIB_TAG_INDIRECT) {
+ /* Only remove from 'first level' if lib is not also directly used. */
+ BLI_remlink(&tree, ten);
+ BLI_addtail(&parent->subtree, ten);
+ ten->parent = parent;
+ }
+ else {
+ /* Else, make a new copy of the libtree for our parent. */
+ TreeElement *dupten = add_library_contents(*source_data.bmain, parent->subtree, lib);
+ if (dupten) {
+ dupten->parent = parent;
+ }
+ }
+ }
+ /* restore newid pointers */
+ for (ID *library_id : List<ID>(source_data.bmain->libraries)) {
+ library_id->newid = nullptr;
+ }
+
+ return tree;
+}
+
+TreeElement *TreeDisplayLibraries::add_library_contents(Main &mainvar,
+ ListBase &lb,
+ Library *lib) const
+{
+ const short filter_id_type = id_filter_get();
+
+ ListBase *lbarray[MAX_LIBARRAY];
+ int tot;
+ if (filter_id_type) {
+ lbarray[0] = which_libbase(&mainvar, space_outliner_.filter_id_type);
+ tot = 1;
+ }
+ else {
+ tot = set_listbasepointers(&mainvar, lbarray);
+ }
+
+ TreeElement *tenlib = nullptr;
+ for (int a = 0; a < tot; a++) {
+ if (!lbarray[a] || !lbarray[a]->first) {
+ continue;
+ }
+
+ ID *id = static_cast<ID *>(lbarray[a]->first);
+ const bool is_library = (GS(id->name) == ID_LI) && (lib != nullptr);
+
+ /* check if there's data in current lib */
+ for (ID *id_iter : List<ID>(lbarray[a])) {
+ if (id_iter->lib == lib) {
+ id = id_iter;
+ break;
+ }
+ }
+
+ /* We always want to create an entry for libraries, even if/when we have no more IDs from
+ * them. This invalid state is important to show to user as well.*/
+ if (id != nullptr || is_library) {
+ if (!tenlib) {
+ /* Create library tree element on demand, depending if there are any data-blocks. */
+ if (lib) {
+ tenlib = outliner_add_element(&space_outliner_, &lb, lib, nullptr, 0, 0);
+ }
+ else {
+ tenlib = outliner_add_element(&space_outliner_, &lb, &mainvar, nullptr, TSE_ID_BASE, 0);
+ tenlib->name = IFACE_("Current File");
+ }
+ }
+
+ /* Create data-block list parent element on demand. */
+ if (id != nullptr) {
+ TreeElement *ten;
+
+ if (filter_id_type) {
+ ten = tenlib;
+ }
+ else {
+ ten = outliner_add_element(
+ &space_outliner_, &tenlib->subtree, lbarray[a], nullptr, TSE_ID_BASE, 0);
+ ten->directdata = lbarray[a];
+ ten->name = outliner_idcode_to_plural(GS(id->name));
+ }
+
+ for (ID *id : List<ID>(lbarray[a])) {
+ if (library_id_filter_poll(lib, id)) {
+ outliner_add_element(&space_outliner_, &ten->subtree, id, ten, 0, 0);
+ }
+ }
+ }
+ }
+ }
+
+ return tenlib;
+}
+
+short TreeDisplayLibraries::id_filter_get() const
+{
+ if (space_outliner_.filter & SO_FILTER_ID_TYPE) {
+ return space_outliner_.filter_id_type;
+ }
+ return 0;
+}
+
+bool TreeDisplayLibraries::library_id_filter_poll(Library *lib, ID *id) const
+{
+ if (id->lib != lib) {
+ return false;
+ }
+
+ if (id_filter_get() == ID_GR) {
+ /* Don't show child collections of non-scene master collection,
+ * they are already shown as children. */
+ Collection *collection = (Collection *)id;
+ bool has_non_scene_parent = false;
+
+ for (CollectionParent *cparent : List<CollectionParent>(collection->parents)) {
+ if (!(cparent->collection->flag & COLLECTION_IS_MASTER)) {
+ has_non_scene_parent = true;
+ }
+ }
+
+ if (has_non_scene_parent) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
new file mode 100644
index 00000000000..c88eb957dd1
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
@@ -0,0 +1,284 @@
+/*
+ * 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 spoutliner
+ */
+
+#include <iostream>
+
+#include "DNA_scene_types.h"
+
+#include "BKE_layer.h"
+
+#include "BLI_listbase.h"
+#include "BLI_listbase_wrapper.hh"
+#include "BLI_map.hh"
+#include "BLI_vector.hh"
+
+#include "BLT_translation.h"
+
+#include "../outliner_intern.h"
+#include "tree_display.hh"
+
+namespace blender::ed::outliner {
+
+/* Convenience/readability. */
+template<typename T> using List = ListBaseWrapper<T>;
+
+class ObjectsChildrenBuilder {
+ using TreeChildren = Vector<TreeElement *>;
+ using ObjectTreeElementsMap = Map<Object *, TreeChildren>;
+
+ SpaceOutliner &outliner_;
+ ObjectTreeElementsMap object_tree_elements_map_;
+
+ public:
+ ObjectsChildrenBuilder(SpaceOutliner &soutliner);
+ ~ObjectsChildrenBuilder() = default;
+
+ void operator()(TreeElement &collection_tree_elem);
+
+ private:
+ void object_tree_elements_lookup_create_recursive(TreeElement *te_parent);
+ void make_object_parent_hierarchy_collections();
+};
+
+/* -------------------------------------------------------------------- */
+/** \name Tree-Display for a View Layer.
+ *
+ * \{ */
+
+TreeDisplayViewLayer::TreeDisplayViewLayer(SpaceOutliner &space_outliner)
+ : AbstractTreeDisplay(space_outliner)
+{
+}
+
+ListBase TreeDisplayViewLayer::buildTree(const TreeSourceData &source_data)
+{
+ ListBase tree = {nullptr};
+
+ view_layer_ = source_data.view_layer;
+ show_objects_ = !(space_outliner_.filter & SO_FILTER_NO_OBJECT);
+
+ const bool show_children = (space_outliner_.filter & SO_FILTER_NO_CHILDREN) == 0;
+
+ if (space_outliner_.filter & SO_FILTER_NO_COLLECTION) {
+ /* Show objects in the view layer. */
+ for (Base *base : List<Base>(view_layer_->object_bases)) {
+ TreeElement *te_object = outliner_add_element(
+ &space_outliner_, &tree, base->object, nullptr, 0, 0);
+ te_object->directdata = base;
+ }
+
+ if (show_children) {
+ outliner_make_object_parent_hierarchy(&tree);
+ }
+ }
+ else {
+ /* Show collections in the view layer. */
+ TreeElement &ten = *outliner_add_element(
+ &space_outliner_, &tree, source_data.scene, nullptr, TSE_VIEW_COLLECTION_BASE, 0);
+ ten.name = IFACE_("Scene Collection");
+ TREESTORE(&ten)->flag &= ~TSE_CLOSED;
+
+ add_view_layer(ten.subtree, ten);
+ if (show_children) {
+ add_layer_collection_objects_children(ten);
+ }
+ }
+
+ return tree;
+}
+
+void TreeDisplayViewLayer::add_view_layer(ListBase &tree, TreeElement &parent)
+{
+ /* First layer collection is for master collection, don't show it. */
+ LayerCollection *lc = static_cast<LayerCollection *>(view_layer_->layer_collections.first);
+ if (lc == nullptr) {
+ return;
+ }
+
+ add_layer_collections_recursive(tree, lc->layer_collections, parent);
+ if (show_objects_) {
+ add_layer_collection_objects(tree, *lc, parent);
+ }
+}
+
+void TreeDisplayViewLayer::add_layer_collections_recursive(ListBase &tree,
+ ListBase &layer_collections,
+ TreeElement &parent_ten)
+{
+ for (LayerCollection *lc : List<LayerCollection>(layer_collections)) {
+ const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0;
+ TreeElement *ten;
+
+ if (exclude && ((space_outliner_.show_restrict_flags & SO_RESTRICT_ENABLE) == 0)) {
+ ten = &parent_ten;
+ }
+ else {
+ ID *id = &lc->collection->id;
+ ten = outliner_add_element(
+ &space_outliner_, &tree, id, &parent_ten, TSE_LAYER_COLLECTION, 0);
+
+ ten->name = id->name + 2;
+ ten->directdata = lc;
+
+ /* Open by default, except linked collections, which may contain many elements. */
+ TreeStoreElem *tselem = TREESTORE(ten);
+ if (!(tselem->used || ID_IS_LINKED(id) || ID_IS_OVERRIDE_LIBRARY(id))) {
+ tselem->flag &= ~TSE_CLOSED;
+ }
+
+ if (exclude || (lc->runtime_flag & LAYER_COLLECTION_VISIBLE_VIEW_LAYER) == 0) {
+ ten->flag |= TE_DISABLED;
+ }
+ }
+
+ add_layer_collections_recursive(ten->subtree, lc->layer_collections, *ten);
+ if (!exclude && show_objects_) {
+ add_layer_collection_objects(ten->subtree, *lc, *ten);
+ }
+ }
+}
+
+void TreeDisplayViewLayer::add_layer_collection_objects(ListBase &tree,
+ LayerCollection &lc,
+ TreeElement &ten)
+{
+ for (CollectionObject *cob : List<CollectionObject>(lc.collection->gobject)) {
+ Base *base = BKE_view_layer_base_find(view_layer_, cob->ob);
+ TreeElement *te_object = outliner_add_element(
+ &space_outliner_, &tree, base->object, &ten, 0, 0);
+ te_object->directdata = base;
+
+ if (!(base->flag & BASE_VISIBLE_VIEWLAYER)) {
+ te_object->flag |= TE_DISABLED;
+ }
+ }
+}
+
+void TreeDisplayViewLayer::add_layer_collection_objects_children(TreeElement &collection_tree_elem)
+{
+ /* Call helper to add children. */
+ ObjectsChildrenBuilder child_builder{space_outliner_};
+ child_builder(collection_tree_elem);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Object Children helper.
+ *
+ * Helper to add child objects to the sub-tree of their parent, recursively covering all nested
+ * collections.
+ *
+ * \{ */
+
+ObjectsChildrenBuilder::ObjectsChildrenBuilder(SpaceOutliner &outliner) : outliner_(outliner)
+{
+}
+
+void ObjectsChildrenBuilder::operator()(TreeElement &collection_tree_elem)
+{
+ object_tree_elements_lookup_create_recursive(&collection_tree_elem);
+ make_object_parent_hierarchy_collections();
+}
+
+/**
+ * Build a map from Object* to a list of TreeElement* matching the object.
+ */
+void ObjectsChildrenBuilder::object_tree_elements_lookup_create_recursive(TreeElement *te_parent)
+{
+ for (TreeElement *te : List<TreeElement>(te_parent->subtree)) {
+ TreeStoreElem *tselem = TREESTORE(te);
+
+ if (tselem->type == TSE_LAYER_COLLECTION) {
+ object_tree_elements_lookup_create_recursive(te);
+ continue;
+ }
+
+ if (tselem->type == 0 && te->idcode == ID_OB) {
+ Object *ob = (Object *)tselem->id;
+ /* Lookup children or add new, empty children vector. */
+ Vector<TreeElement *> &tree_elements = object_tree_elements_map_.lookup_or_add(ob, {});
+
+ tree_elements.append(te);
+ object_tree_elements_lookup_create_recursive(te);
+ }
+ }
+}
+
+/**
+ * For all objects in the tree, lookup the parent in this map,
+ * and move or add tree elements as needed.
+ */
+void ObjectsChildrenBuilder::make_object_parent_hierarchy_collections()
+{
+ for (ObjectTreeElementsMap::MutableItem item : object_tree_elements_map_.items()) {
+ Object *child = item.key;
+
+ if (child->parent == nullptr) {
+ continue;
+ }
+
+ Vector<TreeElement *> &child_ob_tree_elements = item.value;
+ Vector<TreeElement *> *parent_ob_tree_elements = object_tree_elements_map_.lookup_ptr(
+ child->parent);
+ if (parent_ob_tree_elements == nullptr) {
+ continue;
+ }
+
+ for (TreeElement *parent_ob_tree_element : *parent_ob_tree_elements) {
+ TreeElement *parent_ob_collection_tree_element = nullptr;
+ bool found = false;
+
+ /* We always want to remove the child from the direct collection its parent is nested under.
+ * This is particularly important when dealing with multi-level nesting (grandchildren). */
+ parent_ob_collection_tree_element = parent_ob_tree_element->parent;
+ while (!ELEM(TREESTORE(parent_ob_collection_tree_element)->type,
+ TSE_VIEW_COLLECTION_BASE,
+ TSE_LAYER_COLLECTION)) {
+ parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent;
+ }
+
+ for (TreeElement *child_ob_tree_element : child_ob_tree_elements) {
+ if (child_ob_tree_element->parent == parent_ob_collection_tree_element) {
+ /* Move from the collection subtree into the parent object subtree. */
+ BLI_remlink(&parent_ob_collection_tree_element->subtree, child_ob_tree_element);
+ BLI_addtail(&parent_ob_tree_element->subtree, child_ob_tree_element);
+ child_ob_tree_element->parent = parent_ob_tree_element;
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ /* We add the child in the tree even if it is not in the collection.
+ * We deliberately clear its sub-tree though, to make it less prominent. */
+ TreeElement *child_ob_tree_element = outliner_add_element(
+ &outliner_, &parent_ob_tree_element->subtree, child, parent_ob_tree_element, 0, 0);
+ outliner_free_tree(&child_ob_tree_element->subtree);
+ child_ob_tree_element->flag |= TE_CHILD_NOT_IN_COLLECTION;
+ child_ob_tree_elements.append(child_ob_tree_element);
+ }
+ }
+ }
+}
+
+/** \} */
+
+} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 0725109944a..37dfcdbc765 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -43,7 +43,6 @@
#include "BKE_mask.h"
#include "BKE_movieclip.h"
#include "BKE_report.h"
-#include "BKE_sequencer.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -51,6 +50,8 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
+#include "SEQ_sequencer.h"
+
/* For menu, popup, icons, etc. */
#include "ED_screen.h"
#include "ED_sequencer.h"
@@ -147,7 +148,7 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type)
Sequence *seq;
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, true);
- int cfra = (int)CFRA;
+ int timeline_frame = (int)CFRA;
int proximity = INT_MAX;
if (!ed || !ed->seqbasep) {
@@ -155,10 +156,10 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type)
}
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if ((type == -1 || seq->type == type) && (seq->enddisp < cfra) &&
- (cfra - seq->enddisp < proximity)) {
+ if ((type == -1 || seq->type == type) && (seq->enddisp < timeline_frame) &&
+ (timeline_frame - seq->enddisp < proximity)) {
tgt = seq;
- proximity = cfra - seq->enddisp;
+ proximity = timeline_frame - seq->enddisp;
}
}
@@ -172,17 +173,17 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, i
{
Scene *scene = CTX_data_scene(C);
- int cfra = (int)CFRA;
+ int timeline_frame = (int)CFRA;
/* Effect strips don't need a channel initialized from the mouse. */
if (!(flag & SEQPROP_NOCHAN) && RNA_struct_property_is_set(op->ptr, "channel") == 0) {
RNA_int_set(op->ptr, "channel", sequencer_generic_invoke_xy_guess_channel(C, type));
}
- RNA_int_set(op->ptr, "frame_start", cfra);
+ RNA_int_set(op->ptr, "frame_start", timeline_frame);
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", timeline_frame + 25); /* XXX arbitrary but ok for now. */
}
if (!(flag & SEQPROP_NOPATHS)) {
@@ -314,7 +315,7 @@ static bool seq_effect_add_properties_poll(const bContext *UNUSED(C),
/* Hide start/end frames for effect strips that are locked to their parents' location. */
if (BKE_sequence_effect_get_num_inputs(type) != 0) {
- if ((STREQ(prop_id, "frame_start")) || (STREQ(prop_id, "frame_end"))) {
+ if (STR_ELEM(prop_id, "frame_start", "frame_end")) {
return false;
}
}
@@ -638,8 +639,7 @@ static bool sequencer_add_draw_check_fn(PointerRNA *UNUSED(ptr),
{
const char *prop_id = RNA_property_identifier(prop);
- return !(STREQ(prop_id, "filepath") || STREQ(prop_id, "directory") ||
- STREQ(prop_id, "filename"));
+ return !(STR_ELEM(prop_id, "filepath", "directory", "filename"));
}
static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op)
@@ -724,7 +724,7 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES |
WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
RNA_def_boolean(ot->srna, "sound", true, "Sound", "Load sound with the movie");
RNA_def_boolean(ot->srna,
@@ -779,7 +779,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES |
WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
RNA_def_boolean(ot->srna, "cache", false, "Cache", "Cache the sound in memory");
RNA_def_boolean(ot->srna, "mono", false, "Mono", "Merge all the sound's channels into one");
@@ -902,7 +902,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
}
}
- BKE_sequence_init_colorspace(seq);
+ SEQ_render_init_colorspace(seq);
BKE_sequence_calc_disp(scene, seq);
BKE_sequencer_sort(scene);
@@ -971,7 +971,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILES |
WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME);
RNA_def_boolean(ot->srna,
diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c
index 79f30423bf2..a8c13d63259 100644
--- a/source/blender/editors/space_sequencer/sequencer_buttons.c
+++ b/source/blender/editors/space_sequencer/sequencer_buttons.c
@@ -118,7 +118,7 @@ void sequencer_buttons_register(ARegionType *art)
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->poll = metadata_panel_context_poll;
pt->draw = metadata_panel_context_draw;
- pt->flag |= PNL_DEFAULT_CLOSED;
+ pt->flag |= PANEL_TYPE_DEFAULT_CLOSED;
pt->order = 10;
BLI_addtail(&art->paneltypes, pt);
}
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index e9c5b003420..8ac562f0ae0 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -44,7 +44,6 @@
#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
#include "BKE_sound.h"
#include "IMB_colormanagement.h"
@@ -69,6 +68,8 @@
#include "BIF_glutil.h"
+#include "SEQ_sequencer.h"
+
#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -625,7 +626,7 @@ static void draw_seq_text(View2D *v2d,
name = BKE_sequence_give_name(seq);
}
- if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) {
+ if (ELEM(seq->type, SEQ_TYPE_META, SEQ_TYPE_ADJUSTMENT)) {
str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
}
else if (seq->type == SEQ_TYPE_SCENE) {
@@ -969,14 +970,14 @@ static void fcurve_batch_add_verts(GPUVertBuf *vbo,
float y1,
float y2,
float y_height,
- int cfra,
+ int timeline_frame,
float curve_val,
unsigned int *vert_count)
{
float vert_pos[2][2];
- copy_v2_fl2(vert_pos[0], cfra, (curve_val * y_height) + y1);
- copy_v2_fl2(vert_pos[1], cfra, y2);
+ copy_v2_fl2(vert_pos[0], timeline_frame, (curve_val * y_height) + y1);
+ copy_v2_fl2(vert_pos[1], timeline_frame, y2);
GPU_vertbuf_vert_set(vbo, *vert_count, vert_pos[0]);
GPU_vertbuf_vert_set(vbo, *vert_count + 1, vert_pos[1]);
@@ -1025,23 +1026,25 @@ static void draw_seq_fcurve(
float prev_val = INT_MIN;
bool skip = false;
- for (int cfra = eval_start; cfra <= eval_end; cfra += eval_step) {
- curve_val = evaluate_fcurve(fcu, cfra);
+ for (int timeline_frame = eval_start; timeline_frame <= eval_end;
+ timeline_frame += eval_step) {
+ curve_val = evaluate_fcurve(fcu, timeline_frame);
CLAMP(curve_val, 0.0f, 1.0f);
/* Avoid adding adjacent verts that have the same value. */
- if (curve_val == prev_val && cfra < eval_end - eval_step) {
+ if (curve_val == prev_val && timeline_frame < eval_end - eval_step) {
skip = true;
continue;
}
/* If some frames were skipped above, we need to close the shape. */
if (skip) {
- fcurve_batch_add_verts(vbo, y1, y2, y_height, cfra - eval_step, prev_val, &vert_count);
+ fcurve_batch_add_verts(
+ vbo, y1, y2, y_height, timeline_frame - eval_step, prev_val, &vert_count);
skip = false;
}
- fcurve_batch_add_verts(vbo, y1, y2, y_height, cfra, curve_val, &vert_count);
+ fcurve_batch_add_verts(vbo, y1, y2, y_height, timeline_frame, curve_val, &vert_count);
prev_val = curve_val;
}
@@ -1240,7 +1243,7 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain,
struct Depsgraph *depsgraph,
Scene *scene,
SpaceSeq *sseq,
- int cfra,
+ int timeline_frame,
int frame_ofs,
const char *viewname)
{
@@ -1258,13 +1261,13 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain,
render_size = scene->r.size / 100.0;
}
else {
- render_size = BKE_sequencer_rendersize_to_scale_factor(sseq->render_size);
+ render_size = SEQ_rendersize_to_scale_factor(sseq->render_size);
}
rectx = roundf(render_size * scene->r.xsch);
recty = roundf(render_size * scene->r.ysch);
- BKE_sequencer_new_render_data(
+ SEQ_render_new_render_data(
bmain, depsgraph, scene, rectx, recty, sseq->render_size, false, &context);
context.view_id = BKE_scene_multiview_view_id_get(&scene->r, viewname);
@@ -1284,10 +1287,10 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain,
}
if (special_seq_update) {
- ibuf = BKE_sequencer_give_ibuf_direct(&context, cfra + frame_ofs, special_seq_update);
+ ibuf = SEQ_render_give_ibuf_direct(&context, timeline_frame + frame_ofs, special_seq_update);
}
else {
- ibuf = BKE_sequencer_give_ibuf(&context, cfra + frame_ofs, sseq->chanshown);
+ ibuf = SEQ_render_give_ibuf(&context, timeline_frame + frame_ofs, sseq->chanshown);
}
if (viewport) {
@@ -1765,7 +1768,7 @@ void sequencer_draw_preview(const bContext *C,
Scene *scene,
ARegion *region,
SpaceSeq *sseq,
- int cfra,
+ int timeline_frame,
int offset,
bool draw_overlay,
bool draw_backdrop)
@@ -1787,7 +1790,7 @@ void sequencer_draw_preview(const bContext *C,
/* Get image. */
ibuf = sequencer_ibuf_get(
- bmain, region, depsgraph, scene, sseq, cfra, offset, names[sseq->multiview_eye]);
+ bmain, region, depsgraph, scene, sseq, timeline_frame, offset, names[sseq->multiview_eye]);
/* Setup off-screen buffers. */
GPUViewport *viewport = WM_draw_region_get_viewport(region);
@@ -2085,7 +2088,7 @@ static bool draw_cache_view_init_fn(void *userdata, size_t item_count)
/* Called as a callback */
static bool draw_cache_view_iter_fn(
- void *userdata, struct Sequence *seq, int nfra, int cache_type, float UNUSED(cost))
+ void *userdata, struct Sequence *seq, int timeline_frame, int cache_type, float UNUSED(cost))
{
CacheDrawData *drawdata = userdata;
struct View2D *v2d = drawdata->v2d;
@@ -2131,14 +2134,13 @@ static bool draw_cache_view_iter_fn(
return false;
}
- int cfra = seq->start + nfra;
float vert_pos[6][2];
- copy_v2_fl2(vert_pos[0], cfra, stripe_bot);
- copy_v2_fl2(vert_pos[1], cfra, stripe_top);
- copy_v2_fl2(vert_pos[2], cfra + 1, stripe_top);
+ copy_v2_fl2(vert_pos[0], timeline_frame, stripe_bot);
+ copy_v2_fl2(vert_pos[1], timeline_frame, stripe_top);
+ copy_v2_fl2(vert_pos[2], timeline_frame + 1, stripe_top);
copy_v2_v2(vert_pos[3], vert_pos[2]);
copy_v2_v2(vert_pos[4], vert_pos[0]);
- copy_v2_fl2(vert_pos[5], cfra + 1, stripe_bot);
+ copy_v2_fl2(vert_pos[5], timeline_frame + 1, stripe_bot);
for (int i = 0; i < 6; i++) {
GPU_vertbuf_vert_set(vbo, *vert_count + i, vert_pos[i]);
@@ -2318,9 +2320,9 @@ void draw_timeline_seq(const bContext *C, ARegion *region)
/* Draw overlap frame frame indicator. */
if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
- int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ?
- scene->ed->over_cfra :
- scene->r.cfra + scene->ed->over_ofs;
+ int overlap_frame = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ?
+ scene->ed->over_cfra :
+ scene->r.cfra + scene->ed->over_ofs;
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -2334,8 +2336,8 @@ void draw_timeline_seq(const bContext *C, ARegion *region)
immUniformThemeColor(TH_CFRAME);
immBegin(GPU_PRIM_LINES, 2);
- immVertex2f(pos, cfra_over, v2d->cur.ymin);
- immVertex2f(pos, cfra_over, v2d->cur.ymax);
+ immVertex2f(pos, overlap_frame, v2d->cur.ymin);
+ immVertex2f(pos, overlap_frame, v2d->cur.ymax);
immEnd();
immUnbindProgram();
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 8a705ef49dd..eb4a1601187 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -43,9 +43,10 @@
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_report.h"
-#include "BKE_sequencer.h"
#include "BKE_sound.h"
+#include "SEQ_sequencer.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -97,11 +98,11 @@ EnumPropertyItem sequencer_prop_effect_types[] = {
#define SEQ_SIDE_MOUSE -1
EnumPropertyItem prop_side_types[] = {
- {SEQ_SIDE_MOUSE, "MOUSE", 0, "Mouse position", ""},
+ {SEQ_SIDE_MOUSE, "MOUSE", 0, "Mouse Position", ""},
{SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
{SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
{SEQ_SIDE_BOTH, "BOTH", 0, "Both", ""},
- {SEQ_SIDE_NO_CHANGE, "NO_CHANGE", 0, "No change", ""},
+ {SEQ_SIDE_NO_CHANGE, "NO_CHANGE", 0, "No Change", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -153,7 +154,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog
for (link = pj->queue.first; link; link = link->next) {
struct SeqIndexBuildContext *context = link->data;
- BKE_sequencer_proxy_rebuild(context, stop, do_update, progress);
+ SEQ_proxy_rebuild(context, stop, do_update, progress);
if (*stop) {
pj->stop = 1;
@@ -170,7 +171,7 @@ static void proxy_endjob(void *pjv)
LinkData *link;
for (link = pj->queue.first; link; link = link->next) {
- BKE_sequencer_proxy_rebuild_finish(link->data, pj->stop);
+ SEQ_proxy_rebuild_finish(link->data, pj->stop);
}
BKE_sequencer_free_imbuf(pj->scene, &ed->seqbase, false);
@@ -233,7 +234,7 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports)
continue;
}
- bool success = BKE_sequencer_proxy_rebuild_context(
+ bool success = SEQ_proxy_rebuild_context(
pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue);
if (!success && (seq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) != 0) {
@@ -588,7 +589,7 @@ int seq_effect_find_selected(Scene *scene,
*r_error_str = N_("Cannot apply effects to audio sequence strips");
return 0;
}
- if ((seq != activeseq) && (seq != seq2)) {
+ if (!ELEM(seq, activeseq, seq2)) {
if (seq2 == NULL) {
seq2 = seq;
}
@@ -984,21 +985,21 @@ static bool split_seq_list(
return (seq_first_new != NULL);
}
-static bool sequence_offset_after_frame(Scene *scene, const int delta, const int cfra)
+static bool sequence_offset_after_frame(Scene *scene, const int delta, const int timeline_frame)
{
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
bool done = false;
TimeMarker *marker;
- /* All strips >= cfra are shifted. */
+ /* All strips >= timeline_frame are shifted. */
if (ed == NULL) {
return 0;
}
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->startdisp >= cfra) {
+ if (seq->startdisp >= timeline_frame) {
BKE_sequence_translate(scene, seq, delta);
BKE_sequence_calc(scene, seq);
BKE_sequence_invalidate_cache_preprocessed(scene, seq);
@@ -1008,7 +1009,7 @@ static bool sequence_offset_after_frame(Scene *scene, const int delta, const int
if (!scene->toolsettings->lock_markers) {
for (marker = scene->markers.first; marker; marker = marker->next) {
- if (marker->frame >= cfra) {
+ if (marker->frame >= timeline_frame) {
marker->frame += delta;
}
}
@@ -1094,7 +1095,7 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
rctf rectf;
- int cfra, efra, sfra;
+ int timeline_frame, efra, sfra;
bool first = false, done;
bool do_all = RNA_boolean_get(op->ptr, "all");
@@ -1104,24 +1105,24 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
efra = (int)rectf.xmax;
/* Check if the current frame has a gap already. */
- for (cfra = CFRA; cfra >= sfra; cfra--) {
- if (BKE_sequencer_evaluate_frame(scene, cfra)) {
+ for (timeline_frame = CFRA; timeline_frame >= sfra; timeline_frame--) {
+ if (SEQ_render_evaluate_frame(scene, timeline_frame)) {
first = true;
break;
}
}
- for (; cfra < efra; cfra++) {
+ for (; timeline_frame < efra; timeline_frame++) {
/* There's still no strip to remove a gap for. */
if (first == false) {
- if (BKE_sequencer_evaluate_frame(scene, cfra)) {
+ if (SEQ_render_evaluate_frame(scene, timeline_frame)) {
first = true;
}
}
- else if (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
+ else if (SEQ_render_evaluate_frame(scene, timeline_frame) == 0) {
done = true;
- while (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
- done = sequence_offset_after_frame(scene, -1, cfra);
+ while (SEQ_render_evaluate_frame(scene, timeline_frame) == 0) {
+ done = sequence_offset_after_frame(scene, -1, timeline_frame);
if (done == false) {
break;
}
@@ -2658,7 +2659,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
Sequence *seq, *seq_new;
Strip *strip_new;
StripElem *se, *se_new;
- int start_ofs, cfra, frame_end;
+ int start_ofs, timeline_frame, frame_end;
int step = RNA_int_get(op->ptr, "length");
seq = ed->seqbasep->first; /* Poll checks this is valid. */
@@ -2675,12 +2676,12 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
/* if (seq->ipo) id_us_min(&seq->ipo->id); */
/* XXX, remove fcurve and assign to split image strips */
- start_ofs = cfra = BKE_sequence_tx_get_final_left(seq, false);
+ start_ofs = timeline_frame = BKE_sequence_tx_get_final_left(seq, false);
frame_end = BKE_sequence_tx_get_final_right(seq, false);
- while (cfra < frame_end) {
+ while (timeline_frame < frame_end) {
/* New seq. */
- se = BKE_sequencer_give_stripelem(seq, cfra);
+ se = SEQ_render_give_stripelem(seq, timeline_frame);
seq_new = BKE_sequence_dupli_recursive(
scene, scene, ed->seqbasep, seq, SEQ_DUPE_UNIQUE_NAME);
@@ -2712,7 +2713,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
/* XXX, COPY FCURVES */
- cfra++;
+ timeline_frame++;
start_ofs += step;
}
@@ -3018,11 +3019,12 @@ static bool strip_jump_internal(Scene *scene,
const bool do_center)
{
bool changed = false;
- int cfra = CFRA;
- int nfra = BKE_sequencer_find_next_prev_edit(scene, cfra, side, do_skip_mute, do_center, false);
+ int timeline_frame = CFRA;
+ int next_frame = BKE_sequencer_find_next_prev_edit(
+ scene, timeline_frame, side, do_skip_mute, do_center, false);
- if (nfra != cfra) {
- CFRA = nfra;
+ if (next_frame != timeline_frame) {
+ CFRA = next_frame;
changed = true;
}
@@ -3220,7 +3222,7 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op))
if (active_seq->strip) {
switch (active_seq->type) {
case SEQ_TYPE_IMAGE:
- se = BKE_sequencer_give_stripelem(active_seq, scene->r.cfra);
+ se = SEQ_render_give_stripelem(active_seq, scene->r.cfra);
break;
case SEQ_TYPE_MOVIE:
se = active_seq->strip->stripdata;
@@ -3504,12 +3506,12 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
short stop = 0, do_update;
float progress;
- BKE_sequencer_proxy_rebuild_context(bmain, depsgraph, scene, seq, file_list, &queue);
+ SEQ_proxy_rebuild_context(bmain, depsgraph, scene, seq, file_list, &queue);
for (link = queue.first; link; link = link->next) {
struct SeqIndexBuildContext *context = link->data;
- BKE_sequencer_proxy_rebuild(context, &stop, &do_update, &progress);
- BKE_sequencer_proxy_rebuild_finish(context, 0);
+ SEQ_proxy_rebuild(context, &stop, &do_update, &progress);
+ SEQ_proxy_rebuild_finish(context, 0);
}
BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
}
@@ -3568,7 +3570,7 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
SEQ_CURRENT_BEGIN (ed, seq) {
if ((seq->flag & SELECT)) {
if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE, SEQ_TYPE_META)) {
- BKE_sequencer_proxy_set(seq, turnon);
+ SEQ_proxy_set(seq, turnon);
if (seq->strip->proxy == NULL) {
continue;
}
@@ -3787,7 +3789,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
Sequence *seq = BKE_sequencer_active_get(scene);
const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
- int minframe, numdigits;
+ int minext_frameme, numdigits;
if (seq->type == SEQ_TYPE_IMAGE) {
char directory[FILE_MAX];
@@ -3796,7 +3798,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
/* Need to find min/max frame for placeholders. */
if (use_placeholders) {
- len = sequencer_image_seq_get_minmax_frame(op, seq->sfra, &minframe, &numdigits);
+ len = sequencer_image_seq_get_minmax_frame(op, seq->sfra, &minext_frameme, &numdigits);
}
else {
len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
@@ -3820,7 +3822,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
seq->strip->stripdata = se = MEM_callocN(len * sizeof(StripElem), "stripelem");
if (use_placeholders) {
- sequencer_image_seq_reserve_frames(op, se, len, minframe, numdigits);
+ sequencer_image_seq_reserve_frames(op, se, len, minext_frameme, numdigits);
}
else {
RNA_BEGIN (op->ptr, itemptr, "files") {
@@ -3918,7 +3920,7 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot)
WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILEPATH |
WM_FILESEL_FILES,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_boolean(ot->srna,
"use_placeholders",
false,
@@ -4063,7 +4065,7 @@ void SEQUENCER_OT_export_subtitles(struct wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/** \} */
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index df36453bd2e..1ea4fb05d53 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -47,7 +47,7 @@ void sequencer_draw_preview(const struct bContext *C,
struct Scene *scene,
struct ARegion *region,
struct SpaceSeq *sseq,
- int cfra,
+ int timeline_frame,
int offset,
bool draw_overlay,
bool draw_backdrop);
@@ -64,7 +64,7 @@ struct ImBuf *sequencer_ibuf_get(struct Main *bmain,
struct Depsgraph *depsgraph,
struct Scene *scene,
struct SpaceSeq *sseq,
- int cfra,
+ int timeline_frame,
int frame_ofs,
const char *viewname);
diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c
index 50f2a5084ef..fb09afc6ca5 100644
--- a/source/blender/editors/space_sequencer/sequencer_modifier.c
+++ b/source/blender/editors/space_sequencer/sequencer_modifier.c
@@ -27,7 +27,6 @@
#include "DNA_scene_types.h"
#include "BKE_context.h"
-#include "BKE_sequencer.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -35,6 +34,8 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
+#include "SEQ_sequencer.h"
+
/* Own include. */
#include "sequencer_intern.h"
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index 0a7aa1a6072..bdf6e4ece7f 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -34,7 +34,7 @@
#include "ED_sequencer.h"
#include "ED_transform.h" /* Transform keymap. */
-#include "BKE_sequencer.h"
+#include "SEQ_sequencer.h"
#include "sequencer_intern.h"
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 0a4a1ae92d9..a6b2d7feae3 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -33,13 +33,14 @@
#include "BKE_context.h"
#include "BKE_report.h"
-#include "BKE_sequencer.h"
#include "WM_api.h"
#include "WM_types.h"
#include "RNA_define.h"
+#include "SEQ_sequencer.h"
+
/* For menu, popup, icons, etc. */
#include "ED_outliner.h"
@@ -205,7 +206,7 @@ void ED_sequencer_select_sequence_single(Scene *scene, Sequence *seq, bool desel
BKE_sequencer_active_set(scene, seq);
- if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) {
+ if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE)) {
if (seq->strip) {
BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
}
@@ -465,7 +466,7 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
BKE_sequencer_active_set(scene, seq);
- if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) {
+ if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE)) {
if (seq->strip) {
BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
}
@@ -974,18 +975,18 @@ static int sequencer_select_side_of_frame_exec(bContext *C, wmOperator *op)
if (extend == false) {
ED_sequencer_deselect_all(scene);
}
- const int cfra = CFRA;
+ const int timeline_frame = CFRA;
SEQ_CURRENT_BEGIN (ed, seq) {
bool test = false;
switch (side) {
case -1:
- test = (cfra >= seq->enddisp);
+ test = (timeline_frame >= seq->enddisp);
break;
case 1:
- test = (cfra <= seq->startdisp);
+ test = (timeline_frame <= seq->startdisp);
break;
case 0:
- test = (cfra <= seq->enddisp) && (cfra >= seq->startdisp);
+ test = (timeline_frame <= seq->enddisp) && (timeline_frame >= seq->startdisp);
break;
}
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index 491c475b596..75d92d5f00d 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -28,7 +28,6 @@
#include "DNA_scene_types.h"
#include "BKE_context.h"
-#include "BKE_sequencer.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -39,6 +38,8 @@
#include "RNA_define.h"
+#include "SEQ_sequencer.h"
+
/* For menu, popup, icons, etc. */
#include "ED_anim_api.h"
#include "ED_screen.h"
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 289477c8353..45c7bac54f8 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -38,7 +38,6 @@
#include "BKE_global.h"
#include "BKE_lib_id.h"
#include "BKE_screen.h"
-#include "BKE_sequencer.h"
#include "BKE_sequencer_offscreen.h"
#include "ED_screen.h"
@@ -52,6 +51,8 @@
#include "RNA_access.h"
+#include "SEQ_sequencer.h"
+
#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index d3e6fd8f79c..2c9ea1d6afa 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -285,7 +285,7 @@ void wrap_offset(
end += max;
chop = 1;
}
- else if (ch == ' ' || ch == '-') {
+ else if (ELEM(ch, ' ', '-')) {
end = i + 1;
chop = 0;
if (linep == linein && i >= cursin) {
@@ -362,7 +362,7 @@ void wrap_offset_in_line(
end += max;
chop = 1;
}
- else if (ch == ' ' || ch == '-') {
+ else if (ELEM(ch, ' ', '-')) {
end = i + 1;
chop = 0;
if (i >= cursin) {
@@ -483,7 +483,7 @@ static int text_draw_wrapped(const SpaceText *st,
break;
}
}
- else if (str[mi] == ' ' || str[mi] == '-') {
+ else if (ELEM(str[mi], ' ', '-')) {
wrap = i + 1;
mend = mi + 1;
}
@@ -820,7 +820,7 @@ int text_get_visible_lines(const SpaceText *st, ARegion *region, const char *str
start = MIN2(end, i);
end += max;
}
- else if (ch == ' ' || ch == '-') {
+ else if (ELEM(ch, ' ', '-')) {
end = i + 1;
}
diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c
index 4f6d91451e0..16eb66624ce 100644
--- a/source/blender/editors/space_text/text_format_lua.c
+++ b/source/blender/editors/space_text/text_format_lua.c
@@ -271,7 +271,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
else if (*str == '-' && *(str + 1) == '-') {
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
}
- else if (*str == '"' || *str == '\'') {
+ else if (ELEM(*str, '"', '\'')) {
/* Strings */
find = *str;
cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE;
diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c
index b205996d1d2..1a024779a83 100644
--- a/source/blender/editors/space_text/text_format_osl.c
+++ b/source/blender/editors/space_text/text_format_osl.c
@@ -292,7 +292,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
str++;
*fmt = FMT_TYPE_COMMENT;
}
- else if (*str == '"' || *str == '\'') {
+ else if (ELEM(*str, '"', '\'')) {
/* Strings */
find = *str;
cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE;
diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c
index 96d9c234a40..a68632c0d56 100644
--- a/source/blender/editors/space_text/text_format_pov.c
+++ b/source/blender/editors/space_text/text_format_pov.c
@@ -864,7 +864,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
else if (*str == '/' && *(str + 1) == '/') {
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
}
- else if (*str == '"' || *str == '\'') {
+ else if (ELEM(*str, '"', '\'')) {
/* Strings */
find = *str;
cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE;
diff --git a/source/blender/editors/space_text/text_format_pov_ini.c b/source/blender/editors/space_text/text_format_pov_ini.c
index 8d6b877d3f7..1c6a93d2d7a 100644
--- a/source/blender/editors/space_text/text_format_pov_ini.c
+++ b/source/blender/editors/space_text/text_format_pov_ini.c
@@ -442,7 +442,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
if (*str == ';') {
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
}
- else if (*str == '"' || *str == '\'') {
+ else if (ELEM(*str, '"', '\'')) {
/* Strings */
find = *str;
cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE;
diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c
index 39985438462..31177c53d6a 100644
--- a/source/blender/editors/space_text/text_format_py.c
+++ b/source/blender/editors/space_text/text_format_py.c
@@ -224,7 +224,7 @@ static uint txtfmt_py_numeral_string_count_hexadecimal(const char *string)
/* Zeros. */
static bool txtfmt_py_numeral_char_is_zero(const char c)
{
- return (c == '0') || (c == '_');
+ return (ELEM(c, '0', '_'));
}
static uint txtfmt_py_numeral_string_count_zeros(const char *string)
{
@@ -408,7 +408,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
/* fill the remaining line */
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
}
- else if (*str == '"' || *str == '\'') {
+ else if (ELEM(*str, '"', '\'')) {
/* Strings */
find = *str;
cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE;
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 5c7f84ea386..52a5ff609d8 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -159,6 +159,15 @@ static bool text_new_poll(bContext *UNUSED(C))
return 1;
}
+static bool text_data_poll(bContext *C)
+{
+ Text *text = CTX_data_edit_text(C);
+ if (!text) {
+ return false;
+ }
+ return true;
+}
+
static bool text_edit_poll(bContext *C)
{
Text *text = CTX_data_edit_text(C);
@@ -407,9 +416,9 @@ void TEXT_OT_open(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA); /* TODO: relative_path. */
+ FILE_SORT_DEFAULT); /* TODO: relative_path. */
RNA_def_boolean(
- ot->srna, "internal", 0, "Make internal", "Make text file internal after loading");
+ ot->srna, "internal", 0, "Make Internal", "Make text file internal after loading");
}
/** \} */
@@ -573,17 +582,6 @@ void TEXT_OT_make_internal(wmOperatorType *ot)
/** \name Save Operator
* \{ */
-static bool text_save_poll(bContext *C)
-{
- Text *text = CTX_data_edit_text(C);
-
- if (!text_edit_poll(C)) {
- return 0;
- }
-
- return (text->filepath != NULL && !(text->flags & TXT_ISMEM));
-}
-
static void txt_write_file(Main *bmain, Text *text, ReportList *reports)
{
FILE *fp;
@@ -594,6 +592,13 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports)
BLI_strncpy(filepath, text->filepath, FILE_MAX);
BLI_path_abs(filepath, BKE_main_blendfile_path(bmain));
+ /* Check if file write permission is ok. */
+ if (BLI_exists(filepath) && !BLI_file_is_writable(filepath)) {
+ BKE_reportf(
+ reports, RPT_ERROR, "Cannot save text file, path \"%s\" is not writable", filepath);
+ return;
+ }
+
fp = BLI_fopen(filepath, "w");
if (fp == NULL) {
BKE_reportf(reports,
@@ -616,8 +621,8 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports)
if (BLI_stat(filepath, &st) == 0) {
text->mtime = st.st_mtime;
- /* report since this can be called from key-shortcuts */
- BKE_reportf(reports, RPT_INFO, "Saved Text '%s'", filepath);
+ /* Report since this can be called from key shortcuts. */
+ BKE_reportf(reports, RPT_INFO, "Saved text \"%s\"", filepath);
}
else {
text->mtime = 0;
@@ -644,6 +649,18 @@ static int text_save_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int text_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ Text *text = CTX_data_edit_text(C);
+
+ /* Internal and texts without a filepath will go to "Save As". */
+ if (text->filepath == NULL || (text->flags & TXT_ISMEM)) {
+ WM_operator_name_call(C, "TEXT_OT_save_as", WM_OP_INVOKE_DEFAULT, NULL);
+ return OPERATOR_CANCELLED;
+ }
+ return text_save_exec(C, op);
+}
+
void TEXT_OT_save(wmOperatorType *ot)
{
/* identifiers */
@@ -653,7 +670,8 @@ void TEXT_OT_save(wmOperatorType *ot)
/* api callbacks */
ot->exec = text_save_exec;
- ot->poll = text_save_poll;
+ ot->invoke = text_save_invoke;
+ ot->poll = text_edit_poll;
}
/** \} */
@@ -733,7 +751,7 @@ void TEXT_OT_save_as(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA); /* XXX TODO, relative_path. */
+ FILE_SORT_DEFAULT); /* XXX TODO, relative_path. */
}
/** \} */
@@ -742,11 +760,6 @@ void TEXT_OT_save_as(wmOperatorType *ot)
/** \name Run Script Operator
* \{ */
-static bool text_run_script_poll(bContext *C)
-{
- return (CTX_data_edit_text(C) != NULL);
-}
-
static int text_run_script(bContext *C, ReportList *reports)
{
#ifdef WITH_PYTHON
@@ -808,7 +821,7 @@ void TEXT_OT_run_script(wmOperatorType *ot)
ot->description = "Run active script";
/* api callbacks */
- ot->poll = text_run_script_poll;
+ ot->poll = text_data_poll;
ot->exec = text_run_script_exec;
/* flags */
@@ -1709,7 +1722,7 @@ static int text_get_cursor_rel(
loop = 0;
break;
}
- else if (ch == ' ' || ch == '-') {
+ else if (ELEM(ch, ' ', '-')) {
if (found) {
loop = 0;
break;
@@ -1884,7 +1897,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *region, const bool sel)
end += max;
chop = 1;
}
- else if (ch == ' ' || ch == '-' || ch == '\0') {
+ else if (ELEM(ch, ' ', '-', '\0')) {
if (j >= oldc) {
*charp = BLI_str_utf8_offset_from_column((*linep)->line, start);
loop = 0;
@@ -1974,7 +1987,7 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *region, const bool sel)
loop = 0;
break;
}
- else if (ch == ' ' || ch == '-') {
+ else if (ELEM(ch, ' ', '-')) {
end = i + 1;
endj = j;
chop = 0;
@@ -3052,7 +3065,7 @@ static void text_cursor_set_to_pos_wrapped(
break;
}
}
- else if (ch == ' ' || ch == '-' || ch == '\0') {
+ else if (ELEM(ch, ' ', '-', '\0')) {
if (found) {
break;
}
@@ -3693,7 +3706,7 @@ void TEXT_OT_replace(wmOperatorType *ot)
/* properties */
PropertyRNA *prop;
- prop = RNA_def_boolean(ot->srna, "all", false, "Replace all", "Replace all occurrences");
+ prop = RNA_def_boolean(ot->srna, "all", false, "Replace All", "Replace all occurrences");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
@@ -3781,6 +3794,17 @@ static const EnumPropertyItem resolution_items[] = {
{0, NULL, 0, NULL, NULL},
};
+static bool text_resolve_conflict_poll(bContext *C)
+{
+ Text *text = CTX_data_edit_text(C);
+
+ if (!text_edit_poll(C)) {
+ return false;
+ }
+
+ return ((text->filepath != NULL) && !(text->flags & TXT_ISMEM));
+}
+
static int text_resolve_conflict_exec(bContext *C, wmOperator *op)
{
Text *text = CTX_data_edit_text(C);
@@ -3872,7 +3896,7 @@ void TEXT_OT_resolve_conflict(wmOperatorType *ot)
/* api callbacks */
ot->exec = text_resolve_conflict_exec;
ot->invoke = text_resolve_conflict_invoke;
- ot->poll = text_save_poll;
+ ot->poll = text_resolve_conflict_poll;
/* properties */
RNA_def_enum(ot->srna,
@@ -3891,7 +3915,7 @@ void TEXT_OT_resolve_conflict(wmOperatorType *ot)
static int text_to_3d_object_exec(bContext *C, wmOperator *op)
{
- Text *text = CTX_data_edit_text(C);
+ const Text *text = CTX_data_edit_text(C);
const bool split_lines = RNA_boolean_get(op->ptr, "split_lines");
ED_text_to_object(C, text, split_lines);
@@ -3908,7 +3932,7 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot)
/* api callbacks */
ot->exec = text_to_3d_object_exec;
- ot->poll = text_edit_poll;
+ ot->poll = text_data_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index f4d6f7e322c..0371b4e271f 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -27,7 +27,7 @@ set(INC
../../imbuf
../../makesdna
../../makesrna
- ../../render/extern/include
+ ../../render
../../depsgraph
../../windowmanager
../../../../intern/glew-mx
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index d7ef03453f3..5ae012ce5dd 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -153,7 +153,7 @@ bool ED_view3d_area_user_region(const ScrArea *area, const View3D *v3d, ARegion
rv3d = region->regiondata;
if ((rv3d->viewlock & RV3D_LOCK_ROTATION) == 0) {
region_unlock = region;
- if (rv3d->persp == RV3D_PERSP || rv3d->persp == RV3D_CAMOB) {
+ if (ELEM(rv3d->persp, RV3D_PERSP, RV3D_CAMOB)) {
region_unlock_user = region;
break;
}
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index 8e03ed6e11d..36da0791c4f 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -280,10 +280,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
has_meshdata = (tot || totedgedata);
}
- else if (ob->type == OB_CURVE || ob->type == OB_SURF) {
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
TransformMedian_Curve *median = &median_basis.curve;
Curve *cu = ob->data;
- Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int a;
@@ -291,8 +290,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
StructRNA *seltype = NULL;
void *selp = NULL;
- nu = nurbs->first;
- while (nu) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
a = nu->pntsu;
@@ -343,7 +341,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
bp++;
}
}
- nu = nu->next;
}
if (totcurvedata == 1) {
@@ -973,15 +970,13 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
const TransformMedian_Curve *median = &median_basis.curve,
*ve_median = &ve_median_basis.curve;
Curve *cu = ob->data;
- Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int a;
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
const float scale_w = compute_scale_factor(ve_median->weight, median->weight);
- nu = nurbs->first;
- while (nu) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
if (nu->type == CU_BEZIER) {
for (a = nu->pntsu, bezt = nu->bezt; a--; bezt++) {
if (bezt->f2 & SELECT) {
@@ -1038,8 +1033,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
}
BKE_nurb_test_2d(nu);
BKE_nurb_handles_test(nu, true, false); /* test for bezier too */
-
- nu = nu->next;
}
}
else if ((ob->type == OB_LATTICE) && (apply_vcos || median_basis.lattice.weight)) {
diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c
index 1d5b33e7b90..11643960595 100644
--- a/source/blender/editors/space_view3d/view3d_camera_control.c
+++ b/source/blender/editors/space_view3d/view3d_camera_control.c
@@ -127,8 +127,7 @@ Object *ED_view3d_cameracontrol_object_get(View3DCameraControl *vctrl)
struct View3DCameraControl *ED_view3d_cameracontrol_acquire(Depsgraph *depsgraph,
Scene *scene,
View3D *v3d,
- RegionView3D *rv3d,
- const bool use_parent_root)
+ RegionView3D *rv3d)
{
View3DCameraControl *vctrl;
@@ -139,7 +138,8 @@ struct View3DCameraControl *ED_view3d_cameracontrol_acquire(Depsgraph *depsgraph
vctrl->ctx_v3d = v3d;
vctrl->ctx_rv3d = rv3d;
- vctrl->use_parent_root = use_parent_root;
+ vctrl->use_parent_root = v3d->camera != NULL &&
+ v3d->camera->transflag & OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK;
vctrl->persp_backup = rv3d->persp;
vctrl->dist_backup = rv3d->dist;
@@ -153,7 +153,7 @@ struct View3DCameraControl *ED_view3d_cameracontrol_acquire(Depsgraph *depsgraph
if (rv3d->persp == RV3D_CAMOB) {
Object *ob_back;
- if (use_parent_root && (vctrl->root_parent = v3d->camera->parent)) {
+ if (vctrl->use_parent_root && (vctrl->root_parent = v3d->camera->parent)) {
while (vctrl->root_parent->parent) {
vctrl->root_parent = vctrl->root_parent->parent;
}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 633344837a1..d4c85eeb3d2 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -949,15 +949,16 @@ void ED_view3d_grid_steps(const Scene *scene,
* Currently the simulation is only done when RV3D_VIEW_IS_AXIS. */
float ED_view3d_grid_view_scale(Scene *scene,
View3D *v3d,
- RegionView3D *rv3d,
+ ARegion *region,
const char **r_grid_unit)
{
float grid_scale;
+ RegionView3D *rv3d = region->regiondata;
if (!rv3d->is_persp && RV3D_VIEW_IS_AXIS(rv3d->view)) {
/* Decrease the distance between grid snap points depending on zoom. */
/* `0.38` was a value visually obtained in order to get a snap distance
* that matches previous versions Blender.*/
- float min_dist = 0.38f * (rv3d->dist / v3d->lens);
+ float min_dist = 16.0f / (region->sizex * rv3d->winmat[0][0]);
float grid_steps[STEPS_LEN];
ED_view3d_grid_steps(scene, v3d, rv3d, grid_steps);
/* Skip last item, in case the 'mid_dist' is greater than the largest unit. */
@@ -1468,12 +1469,13 @@ static void draw_selected_name(
}
static void draw_grid_unit_name(
- Scene *scene, RegionView3D *rv3d, View3D *v3d, int xoffset, int *yoffset)
+ Scene *scene, ARegion *region, View3D *v3d, int xoffset, int *yoffset)
{
+ RegionView3D *rv3d = region->regiondata;
if (!rv3d->is_persp && RV3D_VIEW_IS_AXIS(rv3d->view)) {
const char *grid_unit = NULL;
int font_id = BLF_default();
- ED_view3d_grid_view_scale(scene, v3d, rv3d, &grid_unit);
+ ED_view3d_grid_view_scale(scene, v3d, region, &grid_unit);
if (grid_unit) {
char numstr[32] = "";
@@ -1558,7 +1560,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *region)
if (v3d->gridflag & (V3D_SHOW_FLOOR | V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z)) {
/* draw below the viewport name */
- draw_grid_unit_name(scene, rv3d, v3d, xoffset, &yoffset);
+ draw_grid_unit_name(scene, region, v3d, xoffset, &yoffset);
}
DRW_draw_region_engine_info(xoffset, &yoffset, VIEW3D_OVERLAY_LINEHEIGHT);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 7ec6bddd6a3..f9de462813f 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -998,7 +998,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int event_xy[2];
if (event->type == MOUSEPAN) {
- if (U.uiflag2 & USER_TRACKPAD_NATURAL) {
+ if (event->is_direction_inverted) {
event_xy[0] = 2 * event->x - event->prevx;
event_xy[1] = 2 * event->y - event->prevy;
}
@@ -2138,7 +2138,7 @@ static void viewzoom_apply_camera(ViewOpsData *vod,
zoomfac_prev,
&vod->prev.time);
- if (zfac != 1.0f && zfac != 0.0f) {
+ if (!ELEM(zfac, 1.0f, 0.0f)) {
/* calculate inverted, then invert again (needed because of camera zoom scaling) */
zfac = 1.0f / zfac;
view_zoom_to_window_xy_camera(vod->scene,
@@ -2382,7 +2382,7 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
viewzoom_exec(C, op);
}
else {
- if (event->type == MOUSEZOOM || event->type == MOUSEPAN) {
+ if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) {
if (U.uiflag & USER_ZOOM_HORIZ) {
vod->init.event_xy[0] = vod->prev.event_xy[0] = event->x;
@@ -2978,6 +2978,11 @@ static int view3d_all_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+ if (RV3D_CLIPPING_ENABLED(v3d, rv3d)) {
+ /* This is an approximation, see function documentation for details. */
+ ED_view3d_clipping_clamp_minmax(rv3d, min, max);
+ }
+
if (use_all_regions) {
view3d_from_minmax_multi(C, v3d, min, max, true, smooth_viewtx);
}
@@ -3125,6 +3130,11 @@ static int viewselected_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+ if (RV3D_CLIPPING_ENABLED(v3d, rv3d)) {
+ /* This is an approximation, see function documentation for details. */
+ ED_view3d_clipping_clamp_minmax(rv3d, min, max);
+ }
+
if (use_all_regions) {
view3d_from_minmax_multi(C, v3d, min, max, ok_dist, smooth_viewtx);
}
@@ -4828,7 +4838,7 @@ void VIEW3D_OT_background_image_add(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 6ce76c478df..6824c526888 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -392,7 +392,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
}
fly->v3d_camera_control = ED_view3d_cameracontrol_acquire(
- fly->depsgraph, fly->scene, fly->v3d, fly->rv3d, (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);
+ fly->depsgraph, fly->scene, fly->v3d, fly->rv3d);
/* calculate center */
if (ED_view3d_cameracontrol_object_get(fly->v3d_camera_control)) {
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 aa8905721b4..9f35abf7fef 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
@@ -453,7 +453,7 @@ void ED_gizmotypes_preselect_3d(void)
/* -------------------------------------------------------------------- */
/** \name Gizmo Accessors
*
- * This avoids each user of the gizmo needing to write their own look-ups to access
+ * This avoids each user of the gizmo needing to write their own lookups to access
* the information from this gizmo.
* \{ */
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index b23b9db3211..0815850d694 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -228,8 +228,7 @@ void view3d_buttons_register(struct ARegionType *art);
struct View3DCameraControl *ED_view3d_cameracontrol_acquire(struct Depsgraph *depsgraph,
Scene *scene,
View3D *v3d,
- RegionView3D *rv3d,
- const bool use_parent_root);
+ RegionView3D *rv3d);
void ED_view3d_cameracontrol_update(struct View3DCameraControl *vctrl,
const bool use_autokey,
struct bContext *C,
diff --git a/source/blender/editors/space_view3d/view3d_placement.c b/source/blender/editors/space_view3d/view3d_placement.c
index 176fc641085..85388819f29 100644
--- a/source/blender/editors/space_view3d/view3d_placement.c
+++ b/source/blender/editors/space_view3d/view3d_placement.c
@@ -35,6 +35,7 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
+#include "BKE_global.h"
#include "BKE_main.h"
#include "RNA_access.h"
@@ -57,12 +58,16 @@
#include "GPU_batch.h"
#include "GPU_immediate.h"
+#include "GPU_matrix.h"
#include "GPU_state.h"
#include "view3d_intern.h"
static const char *view3d_gzgt_placement_id = "VIEW3D_GGT_placement";
+static void preview_plane_cursor_setup(wmGizmoGroup *gzgroup);
+static void preview_plane_cursor_visible_set(wmGizmoGroup *gzgroup, bool do_draw);
+
/* -------------------------------------------------------------------- */
/** \name Local Types
* \{ */
@@ -240,6 +245,12 @@ static bool idp_poject_surface_normal(SnapObjectContext *snap_context,
return success;
}
+static wmGizmoGroup *idp_gizmogroup_from_region(ARegion *region)
+{
+ wmGizmoMap *gzmap = region->gizmo_map;
+ return gzmap ? WM_gizmomap_group_find(gzmap, view3d_gzgt_placement_id) : NULL;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -610,135 +621,62 @@ static void draw_primitive_view(const struct bContext *C, ARegion *UNUSED(region
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Add Object Modal Operator
+/** \name Calculate The Initial Placement Plane
+ *
+ * Use by both the operator and placement cursor.
* \{ */
-/**
- *
- * */
-static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEvent *event)
+static void view3d_interactive_add_calc_plane(bContext *C,
+ Scene *scene,
+ View3D *v3d,
+ ARegion *region,
+ wmGizmo *snap_gizmo,
+ const float mval_fl[2],
+ const enum ePlace_Depth plane_depth,
+ const enum ePlace_Orient plane_orient,
+ const int plane_axis,
+ float r_co_src[3],
+ float r_matrix_orient[3][3])
{
+ const RegionView3D *rv3d = region->regiondata;
+ ED_transform_calc_orientation_from_type(C, r_matrix_orient);
- const int plane_axis = RNA_enum_get(op->ptr, "plane_axis");
- const enum ePlace_Depth plane_depth = RNA_enum_get(op->ptr, "plane_depth");
- const enum ePlace_Origin plane_origin = RNA_enum_get(op->ptr, "plane_origin");
- const enum ePlace_Orient plane_orient = RNA_enum_get(op->ptr, "plane_orientation");
-
- const float mval_fl[2] = {UNPACK2(event->mval)};
-
- struct InteractivePlaceData *ipd = op->customdata;
-
- RegionView3D *rv3d = ipd->region->regiondata;
-
- /* Assign snap gizmo which is may be used as part of the tool. */
- {
- wmGizmoMap *gzmap = ipd->region->gizmo_map;
- wmGizmoGroup *gzgroup = gzmap ? WM_gizmomap_group_find(gzmap, view3d_gzgt_placement_id) : NULL;
- if ((gzgroup != NULL) && gzgroup->gizmos.first) {
- ipd->snap_gizmo = gzgroup->gizmos.first;
- }
- }
-
- ipd->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
-
- ED_transform_calc_orientation_from_type(C, ipd->matrix_orient);
+ SnapObjectContext *snap_context = NULL;
+ bool snap_context_free = false;
/* Set the orientation. */
- if (plane_orient == PLACE_ORIENT_SURFACE) {
- bool snap_context_free = false;
- SnapObjectContext *snap_context =
- (ipd->snap_gizmo ? ED_gizmotypes_snap_3d_context_ensure(
- ipd->scene, ipd->region, ipd->v3d, ipd->snap_gizmo) :
- NULL);
+ if ((plane_orient == PLACE_ORIENT_SURFACE) || (plane_depth == PLACE_DEPTH_SURFACE)) {
+ snap_context = (snap_gizmo ?
+ ED_gizmotypes_snap_3d_context_ensure(scene, region, v3d, snap_gizmo) :
+ NULL);
if (snap_context == NULL) {
- snap_context = ED_transform_snap_object_context_create_view3d(
- ipd->scene, 0, ipd->region, ipd->v3d);
+ snap_context = ED_transform_snap_object_context_create_view3d(scene, 0, region, v3d);
snap_context_free = true;
}
+ }
+ if (plane_orient == PLACE_ORIENT_SURFACE) {
float matrix_orient_surface[3][3];
/* Use the snap normal as a fallback in case the cursor isn't over a surface
* but snapping is enabled. */
float normal_fallback[3];
- bool use_normal_fallback = ipd->snap_gizmo ?
- idp_snap_normal_from_gizmo(ipd->snap_gizmo, normal_fallback) :
+ bool use_normal_fallback = snap_gizmo ?
+ idp_snap_normal_from_gizmo(snap_gizmo, normal_fallback) :
false;
- if (idp_poject_surface_normal(snap_context,
+ if ((snap_context != NULL) &&
+ idp_poject_surface_normal(snap_context,
CTX_data_ensure_evaluated_depsgraph(C),
mval_fl,
- use_normal_fallback ? ipd->matrix_orient : NULL,
+ use_normal_fallback ? r_matrix_orient : NULL,
use_normal_fallback ? normal_fallback : NULL,
matrix_orient_surface)) {
- copy_m3_m3(ipd->matrix_orient, matrix_orient_surface);
- }
-
- if (snap_context_free) {
- ED_transform_snap_object_context_destroy(snap_context);
- }
- }
-
- ipd->orient_axis = plane_axis;
- ipd->is_centered_init = (plane_origin == PLACE_ORIGIN_CENTER);
- ipd->step[0].is_centered = ipd->is_centered_init;
- ipd->step[1].is_centered = ipd->is_centered_init;
- ipd->step_index = STEP_BASE;
-
- {
- PropertyRNA *prop = RNA_struct_find_property(op->ptr, "primitive_type");
- if (RNA_property_is_set(op->ptr, prop)) {
- ipd->primitive_type = RNA_property_enum_get(op->ptr, prop);
- ipd->use_tool = false;
- }
- else {
- ipd->use_tool = true;
-
- /* Get from the tool, a bit of a non-standard way of operating. */
- const bToolRef *tref = ipd->area->runtime.tool;
- if (tref && STREQ(tref->idname, "builtin.primitive_cube_add")) {
- ipd->primitive_type = PLACE_PRIMITIVE_TYPE_CUBE;
- }
- else if (tref && STREQ(tref->idname, "builtin.primitive_cylinder_add")) {
- ipd->primitive_type = PLACE_PRIMITIVE_TYPE_CYLINDER;
- }
- else if (tref && STREQ(tref->idname, "builtin.primitive_cone_add")) {
- ipd->primitive_type = PLACE_PRIMITIVE_TYPE_CONE;
- }
- else if (tref && STREQ(tref->idname, "builtin.primitive_uv_sphere_add")) {
- ipd->primitive_type = PLACE_PRIMITIVE_TYPE_SPHERE_UV;
- }
- else if (tref && STREQ(tref->idname, "builtin.primitive_ico_sphere_add")) {
- ipd->primitive_type = PLACE_PRIMITIVE_TYPE_SPHERE_ICO;
- }
- else {
- /* If the user runs this as an operator they should set the 'primitive_type',
- * however running from operator search will end up at this point. */
- ipd->primitive_type = PLACE_PRIMITIVE_TYPE_CUBE;
- ipd->use_tool = false;
- }
+ copy_m3_m3(r_matrix_orient, matrix_orient_surface);
}
}
- UNUSED_VARS(C, event);
-
- ipd->draw_handle_view = ED_region_draw_cb_activate(
- ipd->region->type, draw_primitive_view, ipd, REGION_DRAW_POST_VIEW);
-
- ED_region_tag_redraw(ipd->region);
-
- plane_from_point_normal_v3(
- ipd->step[0].plane, ipd->scene->cursor.location, ipd->matrix_orient[ipd->orient_axis]);
-
- const bool is_snap_found = ipd->snap_gizmo ?
- idp_snap_point_from_gizmo(ipd->snap_gizmo, ipd->co_src) :
- false;
- ipd->is_snap_invert = ipd->snap_gizmo ? ED_gizmotypes_snap_3d_invert_snap_get(ipd->snap_gizmo) :
- false;
- {
- const ToolSettings *ts = ipd->scene->toolsettings;
- ipd->use_snap = (ipd->is_snap_invert == !(ts->snap_flag & SCE_SNAP));
- }
+ const bool is_snap_found = snap_gizmo ? idp_snap_point_from_gizmo(snap_gizmo, r_co_src) : false;
if (is_snap_found) {
/* pass */
@@ -747,15 +685,10 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv
bool use_depth_fallback = true;
if (plane_depth == PLACE_DEPTH_CURSOR_VIEW) {
/* View plane. */
- ED_view3d_win_to_3d(
- ipd->v3d, ipd->region, ipd->scene->cursor.location, mval_fl, ipd->co_src);
+ ED_view3d_win_to_3d(v3d, region, scene->cursor.location, mval_fl, r_co_src);
use_depth_fallback = false;
}
else if (plane_depth == PLACE_DEPTH_SURFACE) {
- SnapObjectContext *snap_context =
- (ipd->snap_gizmo ? ED_gizmotypes_snap_3d_context_ensure(
- ipd->scene, ipd->region, ipd->v3d, ipd->snap_gizmo) :
- NULL);
if ((snap_context != NULL) &&
ED_transform_snap_object_project_view3d(snap_context,
CTX_data_ensure_evaluated_depsgraph(C),
@@ -767,7 +700,7 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv
mval_fl,
NULL,
NULL,
- ipd->co_src,
+ r_co_src,
NULL)) {
use_depth_fallback = false;
}
@@ -777,16 +710,15 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv
if (use_depth_fallback || (plane_depth == PLACE_DEPTH_CURSOR_PLANE)) {
/* Cursor plane. */
float plane[4];
- plane_from_point_normal_v3(
- plane, ipd->scene->cursor.location, ipd->matrix_orient[ipd->orient_axis]);
- if (ED_view3d_win_to_3d_on_plane(ipd->region, plane, mval_fl, false, ipd->co_src)) {
+ plane_from_point_normal_v3(plane, scene->cursor.location, r_matrix_orient[plane_axis]);
+ if (ED_view3d_win_to_3d_on_plane(region, plane, mval_fl, false, r_co_src)) {
use_depth_fallback = false;
}
/* Even if the calculation works, it's possible the point found is behind the view. */
if (rv3d->is_persp) {
float dir[3];
- sub_v3_v3v3(dir, rv3d->viewinv[3], ipd->co_src);
- if (dot_v3v3(dir, rv3d->viewinv[2]) < ipd->v3d->clip_start) {
+ sub_v3_v3v3(dir, rv3d->viewinv[3], r_co_src);
+ if (dot_v3v3(dir, rv3d->viewinv[2]) < v3d->clip_start) {
use_depth_fallback = true;
}
}
@@ -796,14 +728,119 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv
float co_depth[3];
/* Fallback to view center. */
negate_v3_v3(co_depth, rv3d->ofs);
- ED_view3d_win_to_3d(ipd->v3d, ipd->region, co_depth, mval_fl, ipd->co_src);
+ ED_view3d_win_to_3d(v3d, region, co_depth, mval_fl, r_co_src);
}
}
- plane_from_point_normal_v3(
- ipd->step[0].plane, ipd->co_src, ipd->matrix_orient[ipd->orient_axis]);
+ if (snap_context_free) {
+ ED_transform_snap_object_context_destroy(snap_context);
+ }
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Add Object Modal Operator
+ * \{ */
+
+static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEvent *event)
+{
+
+ const int plane_axis = RNA_enum_get(op->ptr, "plane_axis");
+ const enum ePlace_Depth plane_depth = RNA_enum_get(op->ptr, "plane_depth");
+ const enum ePlace_Origin plane_origin = RNA_enum_get(op->ptr, "plane_origin");
+ const enum ePlace_Orient plane_orient = RNA_enum_get(op->ptr, "plane_orientation");
+
+ const float mval_fl[2] = {UNPACK2(event->mval)};
+
+ struct InteractivePlaceData *ipd = op->customdata;
+
+ /* Assign snap gizmo which is may be used as part of the tool. */
+ {
+ wmGizmoGroup *gzgroup = idp_gizmogroup_from_region(ipd->region);
+ if (gzgroup != NULL) {
+ if (gzgroup->gizmos.first) {
+ ipd->snap_gizmo = gzgroup->gizmos.first;
+ }
+
+ /* Can be NULL when gizmos are disabled. */
+ if (gzgroup->customdata != NULL) {
+ preview_plane_cursor_visible_set(gzgroup, false);
+ }
+ }
+ }
+
+ ipd->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
+
+ view3d_interactive_add_calc_plane(C,
+ ipd->scene,
+ ipd->v3d,
+ ipd->region,
+ ipd->snap_gizmo,
+ mval_fl,
+ plane_depth,
+ plane_orient,
+ plane_axis,
+ ipd->co_src,
+ ipd->matrix_orient);
+
+ ipd->orient_axis = plane_axis;
+ ipd->is_centered_init = (plane_origin == PLACE_ORIGIN_CENTER);
+ ipd->step[0].is_centered = ipd->is_centered_init;
+ ipd->step[1].is_centered = ipd->is_centered_init;
+ ipd->step_index = STEP_BASE;
+
+ plane_from_point_normal_v3(ipd->step[0].plane, ipd->co_src, ipd->matrix_orient[plane_axis]);
copy_v3_v3(ipd->step[0].co_dst, ipd->co_src);
+
+ ipd->is_snap_invert = ipd->snap_gizmo ? ED_gizmotypes_snap_3d_invert_snap_get(ipd->snap_gizmo) :
+ false;
+ {
+ const ToolSettings *ts = ipd->scene->toolsettings;
+ ipd->use_snap = (ipd->is_snap_invert == !(ts->snap_flag & SCE_SNAP));
+ }
+
+ ipd->draw_handle_view = ED_region_draw_cb_activate(
+ ipd->region->type, draw_primitive_view, ipd, REGION_DRAW_POST_VIEW);
+
+ ED_region_tag_redraw(ipd->region);
+
+ /* Setup the primitive type. */
+ {
+ PropertyRNA *prop = RNA_struct_find_property(op->ptr, "primitive_type");
+ if (RNA_property_is_set(op->ptr, prop)) {
+ ipd->primitive_type = RNA_property_enum_get(op->ptr, prop);
+ ipd->use_tool = false;
+ }
+ else {
+ ipd->use_tool = true;
+
+ /* Get from the tool, a bit of a non-standard way of operating. */
+ const bToolRef *tref = ipd->area->runtime.tool;
+ if (tref && STREQ(tref->idname, "builtin.primitive_cube_add")) {
+ ipd->primitive_type = PLACE_PRIMITIVE_TYPE_CUBE;
+ }
+ else if (tref && STREQ(tref->idname, "builtin.primitive_cylinder_add")) {
+ ipd->primitive_type = PLACE_PRIMITIVE_TYPE_CYLINDER;
+ }
+ else if (tref && STREQ(tref->idname, "builtin.primitive_cone_add")) {
+ ipd->primitive_type = PLACE_PRIMITIVE_TYPE_CONE;
+ }
+ else if (tref && STREQ(tref->idname, "builtin.primitive_uv_sphere_add")) {
+ ipd->primitive_type = PLACE_PRIMITIVE_TYPE_SPHERE_UV;
+ }
+ else if (tref && STREQ(tref->idname, "builtin.primitive_ico_sphere_add")) {
+ ipd->primitive_type = PLACE_PRIMITIVE_TYPE_SPHERE_ICO;
+ }
+ else {
+ /* If the user runs this as an operator they should set the 'primitive_type',
+ * however running from operator search will end up at this point. */
+ ipd->primitive_type = PLACE_PRIMITIVE_TYPE_CUBE;
+ ipd->use_tool = false;
+ }
+ }
+ }
}
static int view3d_interactive_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -844,6 +881,15 @@ static void view3d_interactive_add_exit(bContext *C, wmOperator *op)
ED_region_tag_redraw(ipd->region);
+ {
+ wmGizmoGroup *gzgroup = idp_gizmogroup_from_region(ipd->region);
+ if (gzgroup != NULL) {
+ if (gzgroup->customdata != NULL) {
+ preview_plane_cursor_visible_set(gzgroup, true);
+ }
+ }
+ }
+
MEM_freeN(ipd);
}
@@ -1265,6 +1311,9 @@ static void WIDGETGROUP_placement_setup(const bContext *UNUSED(C), wmGizmoGroup
/* Don't handle any events, this is for display only. */
gizmo->flag |= WM_GIZMO_HIDDEN_KEYMAP;
}
+
+ /* Sets the gizmos custom-data which has it's own free callback. */
+ preview_plane_cursor_setup(gzgroup);
}
void VIEW3D_GGT_placement(wmGizmoGroupType *gzgt)
@@ -1282,3 +1331,309 @@ void VIEW3D_GGT_placement(wmGizmoGroupType *gzgt)
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Placement Preview Plane
+ *
+ * Preview the plane that will be used for placement.
+ *
+ * Note that we might want to split this into its own file,
+ * for now this is coupled with the 3D view placement gizmo.
+ * \{ */
+
+static void gizmo_plane_update_cursor(const bContext *C,
+ ARegion *region,
+ const int mval[2],
+ float r_co[3],
+ float r_matrix_orient[3][3],
+ int *r_plane_axis)
+{
+ wmOperatorType *ot = WM_operatortype_find("VIEW3D_OT_interactive_add", true);
+ BLI_assert(ot != NULL);
+ PointerRNA ptr;
+
+ ScrArea *area = CTX_wm_area(C);
+ BLI_assert(region == CTX_wm_region(C));
+ bToolRef *tref = area->runtime.tool;
+ WM_toolsystem_ref_properties_ensure_from_operator(tref, ot, &ptr);
+
+ const int plane_axis = RNA_enum_get(&ptr, "plane_axis");
+ const enum ePlace_Depth plane_depth = RNA_enum_get(&ptr, "plane_depth");
+ const enum ePlace_Orient plane_orient = RNA_enum_get(&ptr, "plane_orientation");
+
+ const float mval_fl[2] = {UNPACK2(mval)};
+
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+
+ /* Assign snap gizmo which is may be used as part of the tool. */
+ wmGizmo *snap_gizmo = NULL;
+ {
+ wmGizmoGroup *gzgroup = idp_gizmogroup_from_region(region);
+ if ((gzgroup != NULL) && gzgroup->gizmos.first) {
+ snap_gizmo = gzgroup->gizmos.first;
+ }
+ }
+
+ view3d_interactive_add_calc_plane((bContext *)C,
+ scene,
+ v3d,
+ region,
+ snap_gizmo,
+ mval_fl,
+ plane_depth,
+ plane_orient,
+ plane_axis,
+ r_co,
+ r_matrix_orient);
+ *r_plane_axis = plane_axis;
+}
+
+static void gizmo_plane_draw_grid(const int resolution,
+ const float scale,
+ const float scale_fade,
+ const float matrix[4][4],
+ const int plane_axis,
+ const float color[4])
+{
+ BLI_assert(scale_fade <= scale);
+ const int resolution_min = resolution - 1;
+ float color_fade[4] = {UNPACK4(color)};
+ const float *center = matrix[3];
+
+ GPU_blend(GPU_BLEND_ADDITIVE);
+ GPU_line_smooth(true);
+ GPU_line_width(1.0f);
+
+ GPUVertFormat *format = immVertexFormat();
+ const uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ const uint col_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+
+ immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR);
+
+ const size_t coords_len = resolution * resolution;
+ float(*coords)[3] = MEM_mallocN(sizeof(*coords) * coords_len, __func__);
+
+ const int axis_x = (plane_axis + 0) % 3;
+ const int axis_y = (plane_axis + 1) % 3;
+ const int axis_z = (plane_axis + 2) % 3;
+
+ int i;
+ const float resolution_div = (float)1.0f / (float)resolution;
+ i = 0;
+ for (int x = 0; x < resolution; x++) {
+ const float x_fl = (x * resolution_div) - 0.5f;
+ for (int y = 0; y < resolution; y++) {
+ const float y_fl = (y * resolution_div) - 0.5f;
+ coords[i][axis_x] = 0.0f;
+ coords[i][axis_y] = x_fl * scale;
+ coords[i][axis_z] = y_fl * scale;
+ mul_m4_v3(matrix, coords[i]);
+ i += 1;
+ }
+ }
+ BLI_assert(i == coords_len);
+ immBeginAtMost(GPU_PRIM_LINES, coords_len * 4);
+ i = 0;
+ for (int x = 0; x < resolution_min; x++) {
+ for (int y = 0; y < resolution_min; y++) {
+
+ /* Add #resolution_div to ensure we fade-out entirely. */
+#define FADE(v) \
+ max_ff(0.0f, (1.0f - square_f(((len_v3v3(v, center) / scale_fade) + resolution_div) * 2.0f)))
+
+ const float *v0 = coords[(resolution * x) + y];
+ const float *v1 = coords[(resolution * (x + 1)) + y];
+ const float *v2 = coords[(resolution * x) + (y + 1)];
+
+ const float f0 = FADE(v0);
+ const float f1 = FADE(v1);
+ const float f2 = FADE(v2);
+
+ if (f0 > 0.0f || f1 > 0.0f) {
+ color_fade[3] = color[3] * f0;
+ immAttr4fv(col_id, color_fade);
+ immVertex3fv(pos_id, v0);
+ color_fade[3] = color[3] * f1;
+ immAttr4fv(col_id, color_fade);
+ immVertex3fv(pos_id, v1);
+ }
+ if (f0 > 0.0f || f2 > 0.0f) {
+ color_fade[3] = color[3] * f0;
+ immAttr4fv(col_id, color_fade);
+ immVertex3fv(pos_id, v0);
+
+ color_fade[3] = color[3] * f2;
+ immAttr4fv(col_id, color_fade);
+ immVertex3fv(pos_id, v2);
+ }
+
+#undef FADE
+
+ i++;
+ }
+ }
+
+ MEM_freeN(coords);
+
+ immEnd();
+
+ immUnbindProgram();
+
+ GPU_line_smooth(false);
+ GPU_blend(GPU_BLEND_NONE);
+}
+
+/* -------------------------------------------------------------------- */
+/** \name Preview Plane Cursor
+ * \{ */
+
+struct PlacementCursor {
+ /**
+ * Back-pointer to the gizmo-group that uses this cursor.
+ * Needed so we know that the cursor belongs to the region.
+ */
+ wmGizmoGroup *gzgroup;
+
+ /**
+ * Enable this while the modal operator is running,
+ * so the preview-plane doesn't show at the same time time as add-object preview shape
+ * since it's distracting & not helpful.
+ */
+ bool do_draw;
+
+ void *paintcursor;
+
+ int plane_axis;
+ float matrix[4][4];
+
+ /* Check if we need to re-calculate the plane matrix. */
+ int mval_prev[2];
+ float viewmat_prev[4][4];
+};
+
+static void cursor_plane_draw(bContext *C, int x, int y, void *customdata)
+{
+ struct PlacementCursor *plc = (struct PlacementCursor *)customdata;
+ ARegion *region = CTX_wm_region(C);
+ const RegionView3D *rv3d = region->regiondata;
+
+ /* Early exit.
+ * Note that we can't do most of these checks in the poll function (besides global checks)
+ * so test them here instead.
+ *
+ * This cursor is only active while the gizmo is being used
+ * so it's not so important to have a poll function. */
+ if (plc->do_draw == false) {
+ return;
+ }
+ if (G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) {
+ return;
+ }
+ if (rv3d->rflag & RV3D_NAVIGATING) {
+ return;
+ }
+
+ /* Check this gizmo group is in the region. */
+ {
+ wmGizmoMap *gzmap = region->gizmo_map;
+ wmGizmoGroup *gzgroup_test = WM_gizmomap_group_find_ptr(gzmap, plc->gzgroup->type);
+ if (gzgroup_test != plc->gzgroup) {
+ /* Wrong viewport. */
+ return;
+ }
+ }
+
+ const int mval[2] = {x - region->winrct.xmin, y - region->winrct.ymin};
+
+ /* Update matrix? */
+ if ((plc->mval_prev[0] != mval[0]) || (plc->mval_prev[1] != mval[1]) ||
+ !equals_m4m4(plc->viewmat_prev, rv3d->viewmat)) {
+ plc->mval_prev[0] = mval[0];
+ plc->mval_prev[1] = mval[1];
+
+ float orient_matrix[3][3];
+ float co[3];
+ gizmo_plane_update_cursor(C, region, mval, co, orient_matrix, &plc->plane_axis);
+ copy_m4_m3(plc->matrix, orient_matrix);
+ copy_v3_v3(plc->matrix[3], co);
+
+ copy_m4_m4(plc->viewmat_prev, rv3d->viewmat);
+ }
+
+ /* Draw */
+ const float pixel_size = ED_view3d_pixel_size(rv3d, plc->matrix[3]);
+ if (pixel_size > FLT_EPSILON) {
+
+ /* Setup viewport & matrix. */
+ wmViewport(&region->winrct);
+ GPU_matrix_push_projection();
+ GPU_matrix_push();
+ GPU_matrix_projection_set(rv3d->winmat);
+ GPU_matrix_set(rv3d->viewmat);
+
+ const float scale_mod = U.gizmo_size * U.dpi_fac;
+
+ float final_scale = (scale_mod * pixel_size);
+
+ const int lines_subdiv = 10;
+ int lines = lines_subdiv;
+
+ float final_scale_fade = final_scale;
+ final_scale = ceil_power_of_10(final_scale);
+
+ float fac = final_scale_fade / final_scale;
+
+ float color[4] = {1, 1, 1, 1};
+ color[3] = square_f(1.0f - fac);
+ gizmo_plane_draw_grid(
+ lines * lines_subdiv, final_scale, final_scale_fade, plc->matrix, plc->plane_axis, color);
+
+ /* Arbitrary, 1.0 is a little too strong though. */
+ color[3] = 0.75f;
+ /* When the grid is large, we only need the 2x lines in the middle. */
+ if (fac < 0.2f) {
+ lines = 1;
+ final_scale = final_scale_fade;
+ }
+ gizmo_plane_draw_grid(
+ lines, final_scale, final_scale_fade, plc->matrix, plc->plane_axis, color);
+
+ /* Restore matrix. */
+ GPU_matrix_pop();
+ GPU_matrix_pop_projection();
+ }
+}
+
+static void preview_plane_cursor_free(void *customdata)
+{
+ struct PlacementCursor *plc = customdata;
+
+ /* The window manager is freed first on exit. */
+ wmWindowManager *wm = G_MAIN->wm.first;
+ if (UNLIKELY(wm != NULL)) {
+ WM_paint_cursor_end(plc->paintcursor);
+ }
+ MEM_freeN(plc);
+}
+
+static void preview_plane_cursor_setup(wmGizmoGroup *gzgroup)
+{
+ BLI_assert(gzgroup->customdata == NULL);
+ struct PlacementCursor *plc = MEM_callocN(sizeof(*plc), __func__);
+ plc->gzgroup = gzgroup;
+ plc->paintcursor = WM_paint_cursor_activate(
+ SPACE_VIEW3D, RGN_TYPE_WINDOW, NULL, cursor_plane_draw, plc);
+ gzgroup->customdata = plc;
+ gzgroup->customdata_free = preview_plane_cursor_free;
+
+ preview_plane_cursor_visible_set(gzgroup, true);
+}
+
+static void preview_plane_cursor_visible_set(wmGizmoGroup *gzgroup, bool do_draw)
+{
+ struct PlacementCursor *plc = gzgroup->customdata;
+ plc->do_draw = do_draw;
+}
+
+/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 265cb04c7b2..148a0986c5c 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -73,14 +73,14 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
Object *obact = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
- RegionView3D *rv3d = CTX_wm_region_data(C);
+ ARegion *region = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
TransVertStore tvs = {NULL};
TransVert *tv;
float gridf, imat[3][3], bmat[3][3], vec[3];
int a;
- gridf = ED_view3d_grid_view_scale(scene, v3d, rv3d, NULL);
+ gridf = ED_view3d_grid_view_scale(scene, v3d, region, NULL);
if (OBEDIT_FROM_OBACT(obact)) {
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -657,11 +657,11 @@ void VIEW3D_OT_snap_selected_to_active(wmOperatorType *ot)
static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
- RegionView3D *rv3d = CTX_wm_region_data(C);
+ ARegion *region = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
float gridf, *curs;
- gridf = ED_view3d_grid_view_scale(scene, v3d, rv3d, NULL);
+ gridf = ED_view3d_grid_view_scale(scene, v3d, region, NULL);
curs = scene->cursor.location;
curs[0] = gridf * floorf(0.5f + curs[0] / gridf);
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index 631994c9b85..c334b2ce541 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -303,8 +303,8 @@ void ED_view3d_clipping_calc(
/* four clipping planes and bounding volume */
/* first do the bounding volume */
for (int val = 0; val < 4; val++) {
- float xs = (val == 0 || val == 3) ? rect->xmin : rect->xmax;
- float ys = (val == 0 || val == 1) ? rect->ymin : rect->ymax;
+ float xs = (ELEM(val, 0, 3)) ? rect->xmin : rect->xmax;
+ float ys = (ELEM(val, 0, 1)) ? rect->ymin : rect->ymax;
ED_view3d_unproject(region, xs, ys, 0.0, bb->vec[val]);
ED_view3d_unproject(region, xs, ys, 1.0, bb->vec[4 + val]);
@@ -331,6 +331,76 @@ void ED_view3d_clipping_calc(
/** \} */
/* -------------------------------------------------------------------- */
+/** \name View Clipping Clamp Min/Max
+ * \{ */
+
+struct PointsInPlanesMinMax_UserData {
+ float min[3];
+ float max[3];
+};
+
+static void points_in_planes_minmax_fn(
+ const float co[3], int UNUSED(i), int UNUSED(j), int UNUSED(k), void *user_data_p)
+{
+ struct PointsInPlanesMinMax_UserData *user_data = user_data_p;
+ minmax_v3v3_v3(user_data->min, user_data->max, co);
+}
+
+/**
+ * Clamp min/max by the viewport clipping.
+ *
+ * \note This is an approximation, with the limitation that the bounding box from the (mix, max)
+ * calculation might not have any geometry inside the clipped region.
+ * Performing a clipping test on each vertex would work well enough for most cases,
+ * although it's not perfect either as edges/faces may intersect the clipping without having any
+ * of their vertices inside it.
+ * A more accurate result would be quite involved.
+ *
+ * \return True when the arguments were clamped.
+ */
+bool ED_view3d_clipping_clamp_minmax(const RegionView3D *rv3d, float min[3], float max[3])
+{
+ /* 6 planes for the cube, 4..6 for the current view clipping planes. */
+ float planes[6 + 6][4];
+
+ /* Convert the min/max to 6 planes. */
+ for (int i = 0; i < 3; i++) {
+ float *plane_min = planes[(i * 2) + 0];
+ float *plane_max = planes[(i * 2) + 1];
+ zero_v3(plane_min);
+ zero_v3(plane_max);
+ plane_min[i] = -1.0f;
+ plane_min[3] = +min[i];
+ plane_max[i] = +1.0f;
+ plane_max[3] = -max[i];
+ }
+
+ /* Copy planes from the viewport & flip. */
+ int planes_len = 6;
+ int clip_len = (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXCLIP) ? 4 : 6;
+ for (int i = 0; i < clip_len; i++) {
+ negate_v4_v4(planes[planes_len], rv3d->clip[i]);
+ planes_len += 1;
+ }
+
+ /* Calculate points intersecting all planes (effectively intersecting two bounding boxes). */
+ struct PointsInPlanesMinMax_UserData user_data;
+ INIT_MINMAX(user_data.min, user_data.max);
+
+ const float eps_coplanar = 1e-4f;
+ const float eps_isect = 1e-6f;
+ if (isect_planes_v3_fn(
+ planes, planes_len, eps_coplanar, eps_isect, points_in_planes_minmax_fn, &user_data)) {
+ copy_v3_v3(min, user_data.min);
+ copy_v3_v3(max, user_data.max);
+ return true;
+ }
+ return false;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name View Bound-Box Utilities
*
* \{ */
@@ -552,7 +622,8 @@ bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionV
ObjectTfmProtectedChannels obtfm;
Object *root_parent;
- if ((U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0 && (root_parent = v3d->camera->parent)) {
+ if (v3d->camera->transflag & OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK &&
+ (root_parent = v3d->camera->parent)) {
Object *ob_update;
float tmat[4][4];
float imat[4][4];
@@ -655,7 +726,8 @@ bool ED_view3d_camera_lock_autokey(View3D *v3d,
Scene *scene = CTX_data_scene(C);
ID *id_key;
Object *root_parent;
- if ((U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0 && (root_parent = v3d->camera->parent)) {
+ if (v3d->camera->transflag & OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK &&
+ (root_parent = v3d->camera->parent)) {
while (root_parent->parent) {
root_parent = root_parent->parent;
}
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 3c9e4fa49b9..665d704e6b2 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -473,8 +473,8 @@ enum {
};
/* keep the previous speed until user changes userpreferences */
-static float base_speed = -1.f;
-static float userdef_speed = -1.f;
+static float base_speed = -1.0f;
+static float userdef_speed = -1.0f;
static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
{
@@ -521,8 +521,9 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->speed = 0.0f;
walk->is_fast = false;
walk->is_slow = false;
- walk->grid = (walk->scene->unit.system == USER_UNIT_NONE) ? 1.f :
- 1.f / walk->scene->unit.scale_length;
+ walk->grid = (walk->scene->unit.system == USER_UNIT_NONE) ?
+ 1.0f :
+ 1.0f / walk->scene->unit.scale_length;
/* user preference settings */
walk->teleport.duration = U.walk_navigation.teleport_time;
@@ -585,11 +586,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->scene, 0, walk->region, walk->v3d);
walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(
- walk->depsgraph,
- walk->scene,
- walk->v3d,
- walk->rv3d,
- (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);
+ walk->depsgraph, walk->scene, walk->v3d, walk->rv3d);
/* center the mouse */
walk->center_mval[0] = walk->region->winx * 0.5f;
diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt
index 5bf8450246b..73d6a376da6 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -26,7 +26,7 @@ set(INC
../../ikplugin
../../makesdna
../../makesrna
- ../../render/extern/include
+ ../../render
../../depsgraph
../../sequencer
../../windowmanager
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 5aed4b9c6ef..77ce9c10c77 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -646,12 +646,12 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
static const EnumPropertyItem modal_items[] = {
{TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
{TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
- {TFM_MODAL_AXIS_X, "AXIS_X", 0, "X axis", ""},
- {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Y axis", ""},
- {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Z axis", ""},
- {TFM_MODAL_PLANE_X, "PLANE_X", 0, "X plane", ""},
- {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Y plane", ""},
- {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Z plane", ""},
+ {TFM_MODAL_AXIS_X, "AXIS_X", 0, "X Axis", ""},
+ {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Y Axis", ""},
+ {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Z Axis", ""},
+ {TFM_MODAL_PLANE_X, "PLANE_X", 0, "X Plane", ""},
+ {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Y Plane", ""},
+ {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Z Plane", ""},
{TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Clear Constraints", ""},
{TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Snap Invert", ""},
{TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Snap Invert (Off)", ""},
@@ -672,13 +672,13 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
0,
"Decrease Max AutoIK Chain Length",
""},
- {TFM_MODAL_EDGESLIDE_UP, "EDGESLIDE_EDGE_NEXT", 0, "Select next Edge Slide Edge", ""},
- {TFM_MODAL_EDGESLIDE_DOWN, "EDGESLIDE_PREV_NEXT", 0, "Select previous Edge Slide Edge", ""},
+ {TFM_MODAL_EDGESLIDE_UP, "EDGESLIDE_EDGE_NEXT", 0, "Select Next Edge Slide Edge", ""},
+ {TFM_MODAL_EDGESLIDE_DOWN, "EDGESLIDE_PREV_NEXT", 0, "Select Previous Edge Slide Edge", ""},
{TFM_MODAL_PROPSIZE, "PROPORTIONAL_SIZE", 0, "Adjust Proportional Influence", ""},
{TFM_MODAL_INSERTOFS_TOGGLE_DIR,
"INSERTOFS_TOGGLE_DIR",
0,
- "Toggle Direction for Node Auto-offset",
+ "Toggle Direction for Node Auto-Offset",
""},
{TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Move", ""},
{TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""},
@@ -1626,11 +1626,9 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
static void initSnapSpatial(TransInfo *t, float r_snap[2])
{
if (t->spacetype == SPACE_VIEW3D) {
- RegionView3D *rv3d = t->region->regiondata;
-
- if (rv3d) {
+ if (t->region->regiondata) {
View3D *v3d = t->area->spacedata.first;
- r_snap[0] = ED_view3d_grid_view_scale(t->scene, v3d, rv3d, NULL) * 1.0f;
+ r_snap[0] = ED_view3d_grid_view_scale(t->scene, v3d, t->region, NULL) * 1.0f;
r_snap[1] = r_snap[0] * 0.1f;
}
}
@@ -1949,7 +1947,7 @@ int transformEnd(bContext *C, TransInfo *t)
t->context = C;
- if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING) {
+ if (!ELEM(t->state, TRANS_STARTING, TRANS_RUNNING)) {
/* handle restoring objects */
if (t->state == TRANS_CANCEL) {
exit_code = OPERATOR_CANCELLED;
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 275ddb993b2..227330e8524 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -36,7 +36,9 @@
#include "transform_data.h"
-/* ************************** Types ***************************** */
+/* -------------------------------------------------------------------- */
+/** \name Types/
+ * \{ */
struct ARegion;
struct Depsgraph;
@@ -58,7 +60,7 @@ struct wmKeyConfig;
struct wmKeyMap;
struct wmTimer;
-/* transinfo->redraw */
+/** #TransInfo.redraw */
typedef enum {
TREDRAW_NOTHING = 0,
TREDRAW_HARD = 1,
@@ -264,8 +266,8 @@ typedef struct TransInfo {
TransDataContainer *data_container;
int data_container_len;
- /** eTransConvertType
- * TODO: It should be a member of TransDataContainer. */
+ /** #eTransConvertType
+ * TODO: It should be a member of #TransDataContainer. */
int data_type;
/** Combine length of all #TransDataContainer.data_len
@@ -329,16 +331,16 @@ typedef struct TransInfo {
float persinv[4][4];
short persp;
short around;
- /** spacetype where transforming is. */
+ /** space-type where transforming is. */
char spacetype;
/** Choice of custom cursor with or without a help line from the gizmo to the mouse position. */
char helpline;
- /** Avoid looking inside TransDataContainer obedit. */
+ /** Avoid looking inside #TransDataContainer.obedit. */
short obedit_type;
/** translation, to show for widget. */
float vec[3];
- /** rot/rescale, to show for widget. */
+ /** Rotate/re-scale, to show for widget. */
float mat[3][3];
/** orientation matrix of the current space. */
@@ -368,7 +370,7 @@ typedef struct TransInfo {
/** Value taken as input, either through mouse coordinates or entered as a parameter. */
float values[4];
- /** Offset applied ontop of modal input. */
+ /** Offset applied on top of modal input. */
float values_modal_offset[4];
/** Final value of the transformation (displayed in the redo panel).
@@ -397,7 +399,7 @@ typedef struct TransInfo {
struct ViewLayer *view_layer;
struct ToolSettings *settings;
struct wmTimer *animtimer;
- /** so we can do lookups for header text. */
+ /** Needed so we can perform a look up for header text. */
struct wmKeyMap *keymap;
/** assign from the operator, or can be NULL. */
struct ReportList *reports;
@@ -417,9 +419,13 @@ typedef struct TransInfo {
TransCustomDataContainer custom;
} TransInfo;
-/* ******************** Macros & Prototypes *********************** */
+/** \} */
-/* transinfo->state */
+/* -------------------------------------------------------------------- */
+/** \name Flags
+ * \{ */
+
+/** #TransInfo.state */
enum {
TRANS_STARTING = 0,
TRANS_RUNNING = 1,
@@ -427,7 +433,7 @@ enum {
TRANS_CANCEL = 3,
};
-/* transinfo->flag */
+/** #TransInfo.flag */
enum {
T_OBJECT = 1 << 0,
/** \note We could remove 'T_EDIT' and use 'obedit_type', for now ensure they're in sync. */
@@ -452,11 +458,11 @@ enum {
T_PROP_EDIT_ALL = T_PROP_EDIT | T_PROP_CONNECTED | T_PROP_PROJECTED,
T_V3D_ALIGN = 1 << 13,
- /** For 2d views like uv or fcurve. */
+ /** For 2D views such as UV or f-curve. */
T_2D_EDIT = 1 << 14,
T_CLIP_UV = 1 << 15,
- /** Auto-ik is on. */
+ /** Auto-IK is on. */
T_AUTOIK = 1 << 16,
/** Don't use mirror even if the data-block option is set. */
@@ -469,7 +475,7 @@ enum {
/** To specify if we save back settings at the end. */
T_MODAL = 1 << 19,
- /** No retopo. */
+ /** No re-topology (projection). */
T_NO_PROJECT = 1 << 20,
T_RELEASE_CONFIRM = 1 << 21,
@@ -484,8 +490,9 @@ enum {
T_CLNOR_REBUILD = 1 << 25,
- /* Special Aftertrans. */
+ /** Merges unselected into selected after transforming (runs after transforming). */
T_AUTOMERGE = 1 << 26,
+ /** Runs auto-merge & splits. */
T_AUTOSPLIT = 1 << 27,
};
@@ -503,8 +510,6 @@ enum {
*/
// #define USE_NODE_CENTER
-/* ******************************************************************************** */
-
/** #TransInfo.helpline */
enum {
HLP_NONE = 0,
@@ -538,8 +543,14 @@ enum {
MULTI_POINTS = 1 << 3,
};
-/** keymap modal items */
-/* NOTE: these values are saved in keymap files, do not change then but just add new ones. */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Keymap Modal Items
+ *
+ * \note these values are saved in key-map files, do not change then but just add new ones.
+ * \{ */
+
enum {
TFM_MODAL_CANCEL = 1,
TFM_MODAL_CONFIRM = 2,
@@ -559,7 +570,9 @@ enum {
TFM_MODAL_ADD_SNAP = 16,
TFM_MODAL_REMOVE_SNAP = 17,
- /* 18 and 19 used by numinput, defined in transform.h */
+ /* 18 and 19 used by number-input, defined in `ED_numinput.h`. */
+ // NUM_MODAL_INCREMENT_UP = 18,
+ // NUM_MODAL_INCREMENT_DOWN = 19,
TFM_MODAL_PROPSIZE_UP = 20,
TFM_MODAL_PROPSIZE_DOWN = 21,
@@ -569,15 +582,21 @@ enum {
TFM_MODAL_EDGESLIDE_UP = 24,
TFM_MODAL_EDGESLIDE_DOWN = 25,
- /* for analog input, like trackpad */
+ /** For analog input, like track-pad. */
TFM_MODAL_PROPSIZE = 26,
- /* node editor insert offset (aka auto-offset) direction toggle */
+ /** Node editor insert offset (also called auto-offset) direction toggle. */
TFM_MODAL_INSERTOFS_TOGGLE_DIR = 27,
TFM_MODAL_AUTOCONSTRAINT = 28,
TFM_MODAL_AUTOCONSTRAINTPLANE = 29,
};
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Public Transform API
+ * \{ */
+
bool initTransform(struct bContext *C,
struct TransInfo *t,
struct wmOperator *op,
@@ -601,18 +620,31 @@ void removeAspectRatio(TransInfo *t, float vec[2]);
struct wmKeyMap *transform_modal_keymap(struct wmKeyConfig *keyconf);
-/*********************** transform_gizmo.c ********** */
+/** \} */
+/* -------------------------------------------------------------------- */
+/** \name Gizmo
+ * \{ */
+
+/* transform_gizmo.c */
#define GIZMO_AXIS_LINE_WIDTH 2.0f
-/* return 0 when no gimbal for selection */
bool gimbal_axis(struct Object *ob, float gmat[3][3]);
void drawDial3d(const TransInfo *t);
-/*********************** TransData Creation and General Handling *********** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name TransData Creation and General Handling
+ * \{ */
+
bool transdata_check_local_islands(TransInfo *t, short around);
-/********************** Mouse Input ******************************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Mouse Input
+ * \{ */
typedef enum {
INPUT_NONE,
@@ -646,7 +678,11 @@ void setCustomPoints(TransInfo *t, MouseInput *mi, const int start[2], const int
void setCustomPointsFromDirection(TransInfo *t, MouseInput *mi, const float dir[2]);
void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *t, float values[3]));
-/*********************** Generics ********************************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Generics
+ * \{ */
void initTransDataContainers_FromObjectData(TransInfo *t,
struct Object *obact,
@@ -716,3 +752,5 @@ bool checkUseAxisMatrix(TransInfo *t);
*tc_end = (t)->data_container + (t)->data_container_len; \
th != tc_end; \
th++, i++)
+
+/** \} */
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index de1c875a7b0..5e2a8be8db0 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -284,7 +284,9 @@ static void constraint_snap_plane_to_edge(const TransInfo *t, const float plane[
* Snap to the nearest point between the snap point and the line that
* intersects the face plane with the constraint plane.
*/
-static void constraint_snap_plane_to_face(const TransInfo *t, const float plane[4], float r_out[3])
+static void UNUSED_FUNCTION(constraint_snap_plane_to_face(const TransInfo *t,
+ const float plane[4],
+ float r_out[3]))
{
float face_plane[4], isect_orig[3], isect_dir[3];
const float *face_snap_point = t->tsnap.snapPoint;
@@ -406,7 +408,8 @@ static void applyAxisConstraintVec(
constraint_snap_plane_to_edge(t, plane, out);
}
else if (is_snap_to_face) {
- constraint_snap_plane_to_face(t, plane, out);
+ /* Disabled, as it has not proven to be really useful. (See T82386). */
+ // constraint_snap_plane_to_face(t, plane, out);
}
else {
/* View alignment correction. */
diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c
index a14ff6c500d..a7301161570 100644
--- a/source/blender/editors/transform/transform_convert_armature.c
+++ b/source/blender/editors/transform/transform_convert_armature.c
@@ -1504,7 +1504,7 @@ static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
if ((bone->flag & BONE_HINGE) && (bone->flag & BONE_CONNECTED)) {
bone->flag |= BONE_HINGE_CHILD_TRANSFORM;
}
- else if ((bone->flag & BONE_TRANSFORM) && (mode == TFM_ROTATION || mode == TFM_TRACKBALL) &&
+ else if ((bone->flag & BONE_TRANSFORM) && (ELEM(mode, TFM_ROTATION, TFM_TRACKBALL)) &&
(around == V3D_AROUND_LOCAL_ORIGINS)) {
bone->flag |= BONE_TRANSFORM_CHILD;
}
diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c
index 90257b28f55..d2feb966657 100644
--- a/source/blender/editors/transform/transform_convert_curve.c
+++ b/source/blender/editors/transform/transform_convert_curve.c
@@ -406,7 +406,7 @@ void createTransCurveVerts(TransInfo *t)
}
td->ext = NULL;
- if (t->mode == TFM_CURVE_SHRINKFATTEN || t->mode == TFM_RESIZE) {
+ if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_RESIZE)) {
td->val = &(bp->radius);
td->ival = bp->radius;
}
diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil.c
index 84885dd8c49..0a742ec4470 100644
--- a/source/blender/editors/transform/transform_convert_gpencil.c
+++ b/source/blender/editors/transform/transform_convert_gpencil.c
@@ -31,7 +31,9 @@
#include "BKE_colortools.h"
#include "BKE_context.h"
+#include "BKE_curve.h"
#include "BKE_gpencil.h"
+#include "BKE_gpencil_curve.h"
#include "BKE_gpencil_geom.h"
#include "ED_gpencil.h"
@@ -63,33 +65,351 @@ static void createTransGPencil_center_get(bGPDstroke *gps, float r_center[3])
}
}
-void createTransGPencil(bContext *C, TransInfo *t)
+static short get_bezt_sel_triple_flag(BezTriple *bezt, const bool handles_visible)
{
- if (t->data_container_len == 0) {
+#define SEL_F1 (1 << 0)
+#define SEL_F2 (1 << 1)
+#define SEL_F3 (1 << 2)
+#define SEL_ALL ((1 << 0) | (1 << 1) | (1 << 2))
+
+ short flag = 0;
+
+ if (handles_visible) {
+ flag = ((bezt->f1 & SELECT) ? SEL_F1 : 0) | ((bezt->f2 & SELECT) ? SEL_F2 : 0) |
+ ((bezt->f3 & SELECT) ? SEL_F3 : 0);
+ }
+ else {
+ if (bezt->f2 & SELECT) {
+ flag = SEL_ALL;
+ }
+ }
+
+ /* Special case for auto & aligned handles */
+ if (flag != SEL_ALL && flag & SEL_F2) {
+ if (ELEM(bezt->h1, HD_AUTO, HD_ALIGN) && ELEM(bezt->h2, HD_AUTO, HD_ALIGN)) {
+ flag = SEL_ALL;
+ }
+ }
+
+#undef SEL_F1
+#undef SEL_F2
+#undef SEL_F3
+ return flag;
+}
+
+static void createTransGPencil_curves(bContext *C,
+ TransInfo *t,
+ Depsgraph *depsgraph,
+ ToolSettings *ts,
+ Object *obact,
+ bGPdata *gpd,
+ const int cfra_scene,
+ const bool is_multiedit,
+ const bool use_multiframe_falloff,
+ const bool is_prop_edit,
+ const bool is_prop_edit_connected,
+ const bool is_scale_thickness)
+{
+#define SEL_F1 (1 << 0)
+#define SEL_F2 (1 << 1)
+#define SEL_F3 (1 << 2)
+
+ View3D *v3d = t->view;
+ const bool handle_only_selected_visible = (v3d->overlay.handle_display == CURVE_HANDLE_SELECTED);
+ const bool handle_all_visible = (v3d->overlay.handle_display == CURVE_HANDLE_ALL);
+
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+ tc->data_len = 0;
+
+ /* Number of selected curve points */
+ uint32_t tot_curve_points = 0, tot_sel_curve_points = 0, tot_points = 0, tot_sel_points = 0;
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ /* Only editable and visible layers are considered. */
+ if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
+ bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
+ for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
+ if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ /* skip strokes that are invalid for current view */
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
+ continue;
+ }
+ /* Check if the color is editable. */
+ if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
+ continue;
+ }
+ /* Check if stroke has an editcurve */
+ if (gps->editcurve == NULL) {
+ continue;
+ }
+
+ bGPDcurve *gpc = gps->editcurve;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (bezt->hide) {
+ continue;
+ }
+
+ const bool handles_visible = (handle_all_visible ||
+ (handle_only_selected_visible &&
+ (gpc_pt->flag & GP_CURVE_POINT_SELECT)));
+
+ const short sel_flag = get_bezt_sel_triple_flag(bezt, handles_visible);
+ if (sel_flag & (SEL_F1 | SEL_F2 | SEL_F3)) {
+ if (sel_flag & SEL_F1) {
+ tot_sel_points++;
+ }
+ if (sel_flag & SEL_F2) {
+ tot_sel_points++;
+ }
+ if (sel_flag & SEL_F3) {
+ tot_sel_points++;
+ }
+ tot_sel_curve_points++;
+ }
+
+ if (is_prop_edit) {
+ tot_points += 3;
+ tot_curve_points++;
+ }
+ }
+ }
+ }
+
+ /* If not multiedit out of loop. */
+ if (!is_multiedit) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (((is_prop_edit && !is_prop_edit_connected) ? tot_curve_points : tot_sel_points) == 0) {
+ tc->data_len = 0;
return;
}
- Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- bGPdata *gpd = ED_gpencil_data_get_active(C);
- ToolSettings *ts = CTX_data_tool_settings(C);
+ int data_len_pt = 0;
- bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
- bool use_multiframe_falloff = (ts->gp_sculpt.flag & GP_SCULPT_SETT_FLAG_FRAME_FALLOFF) != 0;
+ if (is_prop_edit) {
+ tc->data_len = tot_points;
+ data_len_pt = tot_curve_points;
+ }
+ else {
+ tc->data_len = tot_sel_points;
+ data_len_pt = tot_sel_curve_points;
+ }
- Object *obact = CTX_data_active_object(C);
- TransData *td = NULL;
- float mtx[3][3], smtx[3][3];
+ if (tc->data_len == 0) {
+ return;
+ }
- const Scene *scene = CTX_data_scene(C);
- const int cfra_scene = CFRA;
+ transform_around_single_fallback_ex(t, data_len_pt);
- const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
- const bool is_prop_edit_connected = (t->flag & T_PROP_CONNECTED) != 0;
- const bool is_scale_thickness = ((t->mode == TFM_GPENCIL_SHRINKFATTEN) ||
- (ts->gp_sculpt.flag & GP_SCULPT_SETT_FLAG_SCALE_THICKNESS));
+ tc->data = MEM_callocN(tc->data_len * sizeof(TransData), __func__);
+ TransData *td = tc->data;
- TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
+ const bool use_around_origins_for_handles_test = ((t->around == V3D_AROUND_LOCAL_ORIGINS) &&
+ transform_mode_use_local_origins(t));
+
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ /* Only editable and visible layers are considered. */
+ if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
+ const int cfra = (gpl->flag & GP_LAYER_FRAMELOCK) ? gpl->actframe->framenum : cfra_scene;
+ bGPDframe *gpf = gpl->actframe;
+ bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
+ float diff_mat[4][4], mtx[3][3];
+ float smtx[3][3];
+
+ /* Init multiframe falloff options. */
+ int f_init = 0;
+ int f_end = 0;
+
+ if (use_multiframe_falloff) {
+ BKE_gpencil_frame_range_selected(gpl, &f_init, &f_end);
+ }
+
+ if ((gpf->framenum != cfra) && (!is_multiedit)) {
+ gpf = BKE_gpencil_frame_addcopy(gpl, cfra);
+ /* in some weird situations (framelock enabled) return NULL */
+ if (gpf == NULL) {
+ continue;
+ }
+ if (!is_multiedit) {
+ init_gpf = gpf;
+ }
+ }
+
+ /* Calculate difference matrix. */
+ BKE_gpencil_parent_matrix_get(depsgraph, obact, gpl, diff_mat);
+ copy_m3_m4(mtx, diff_mat);
+ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
+
+ for (gpf = init_gpf; gpf; gpf = gpf->next) {
+ if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
+ /* If multi-frame and falloff, recalculate and save value. */
+ float falloff = 1.0f; /* by default no falloff */
+ if ((is_multiedit) && (use_multiframe_falloff)) {
+ /* Falloff depends on distance to active frame
+ * (relative to the overall frame range). */
+ falloff = BKE_gpencil_multiframe_falloff_calc(
+ gpf, gpl->actframe->framenum, f_init, f_end, ts->gp_sculpt.cur_falloff);
+ }
+
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ /* skip strokes that are invalid for current view */
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
+ continue;
+ }
+ /* Check if the color is editable. */
+ if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
+ continue;
+ }
+ /* Check if stroke has an editcurve */
+ if (gps->editcurve == NULL) {
+ continue;
+ }
+ TransData *head, *tail;
+ head = tail = td;
+
+ gps->runtime.multi_frame_falloff = falloff;
+ bool need_handle_recalc = false;
+
+ bGPDcurve *gpc = gps->editcurve;
+ const bool is_cyclic = gps->flag & GP_STROKE_CYCLIC;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (bezt->hide) {
+ continue;
+ }
+
+ TransDataCurveHandleFlags *hdata = NULL;
+ bool bezt_use = false;
+ const bool handles_visible = (handle_all_visible ||
+ (handle_only_selected_visible &&
+ (gpc_pt->flag & GP_CURVE_POINT_SELECT)));
+ const short sel_flag = get_bezt_sel_triple_flag(bezt, handles_visible);
+ /* Iterate over bezier triple */
+ for (int j = 0; j < 3; j++) {
+ bool is_ctrl_point = (j == 1);
+ bool sel = sel_flag & (1 << j);
+
+ if (is_prop_edit || sel) {
+ copy_v3_v3(td->iloc, bezt->vec[j]);
+ td->loc = bezt->vec[j];
+ bool rotate_around_ctrl = !handles_visible ||
+ (t->around == V3D_AROUND_LOCAL_ORIGINS) ||
+ (bezt->f2 & SELECT);
+ copy_v3_v3(td->center, bezt->vec[rotate_around_ctrl ? 1 : j]);
+
+ if (!handles_visible || is_ctrl_point) {
+ if (bezt->f2 & SELECT) {
+ td->flag = TD_SELECTED;
+ }
+ else {
+ td->flag = 0;
+ }
+ }
+ else if (handles_visible) {
+ if (BEZT_ISSEL_IDX(bezt, j)) {
+ td->flag = TD_SELECTED;
+ }
+ else {
+ td->flag = 0;
+ }
+ }
+
+ td->ext = NULL;
+ if (is_ctrl_point) {
+ if (t->mode != TFM_MIRROR) {
+ if (t->mode != TFM_GPENCIL_OPACITY) {
+ if (is_scale_thickness) {
+ td->val = &(gpc_pt->pressure);
+ td->ival = gpc_pt->pressure;
+ }
+ }
+ else {
+ td->val = &(gpc_pt->strength);
+ td->ival = gpc_pt->strength;
+ }
+ }
+ }
+ else {
+ td->val = NULL;
+ }
+
+ if (hdata == NULL) {
+ if (is_ctrl_point && ((sel_flag & SEL_F1 & SEL_F3) == 0)) {
+ hdata = initTransDataCurveHandles(td, bezt);
+ }
+ else if (!is_ctrl_point) {
+ hdata = initTransDataCurveHandles(td, bezt);
+ }
+ }
+
+ td->extra = gps;
+ td->ob = obact;
+
+ copy_m3_m3(td->smtx, smtx);
+ copy_m3_m3(td->mtx, mtx);
+ copy_m3_m3(td->axismtx, mtx);
+
+ td++;
+ tail++;
+ }
+
+ bezt_use |= sel;
+ }
+
+ /* Update the handle types so transformation is possible */
+ if (bezt_use && !ELEM(t->mode, TFM_GPENCIL_OPACITY, TFM_GPENCIL_SHRINKFATTEN)) {
+ BKE_nurb_bezt_handle_test(
+ bezt, SELECT, handles_visible, use_around_origins_for_handles_test);
+ need_handle_recalc = true;
+ }
+ }
+ if (is_prop_edit && (head != tail)) {
+ calc_distanceCurveVerts(head, tail - 1, is_cyclic);
+ }
+
+ if (need_handle_recalc) {
+ BKE_gpencil_editcurve_recalculate_handles(gps);
+ }
+ }
+ }
+
+ /* If not multiedit out of loop. */
+ if (!is_multiedit) {
+ break;
+ }
+ }
+ }
+ }
+#undef SEL_F1
+#undef SEL_F2
+#undef SEL_F3
+}
+
+static void createTransGPencil_strokes(bContext *C,
+ TransInfo *t,
+ Depsgraph *depsgraph,
+ ToolSettings *ts,
+ Object *obact,
+ bGPdata *gpd,
+ const int cfra_scene,
+ const bool is_multiedit,
+ const bool use_multiframe_falloff,
+ const bool is_prop_edit,
+ const bool is_prop_edit_connected,
+ const bool is_scale_thickness)
+{
+ TransData *td = NULL;
+ float mtx[3][3], smtx[3][3];
+
+ TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
/* == Grease Pencil Strokes to Transform Data ==
* Grease Pencil stroke points can be a mixture of 2D (screen-space),
* or 3D coordinates. However, they're always saved as 3D points.
@@ -98,15 +418,6 @@ void createTransGPencil(bContext *C, TransInfo *t)
*/
tc->data_len = 0;
- if (gpd == NULL) {
- return;
- }
-
- /* initialize falloff curve */
- if (is_multiedit) {
- BKE_curvemapping_init(ts->gp_sculpt.cur_falloff);
- }
-
/* First Pass: Count the number of data-points required for the strokes,
* (and additional info about the configuration - e.g. 2D/3D?).
*/
@@ -368,6 +679,71 @@ void createTransGPencil(bContext *C, TransInfo *t)
}
}
+void createTransGPencil(bContext *C, TransInfo *t)
+{
+ if (t->data_container_len == 0) {
+ return;
+ }
+
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ const Scene *scene = CTX_data_scene(C);
+ ToolSettings *ts = scene->toolsettings;
+ Object *obact = CTX_data_active_object(C);
+ bGPdata *gpd = obact->data;
+ BLI_assert(gpd != NULL);
+
+ const int cfra_scene = CFRA;
+
+ const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+ const bool use_multiframe_falloff = (ts->gp_sculpt.flag & GP_SCULPT_SETT_FLAG_FRAME_FALLOFF) !=
+ 0;
+
+ const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
+ const bool is_prop_edit_connected = (t->flag & T_PROP_CONNECTED) != 0;
+ const bool is_scale_thickness = ((t->mode == TFM_GPENCIL_SHRINKFATTEN) ||
+ (ts->gp_sculpt.flag & GP_SCULPT_SETT_FLAG_SCALE_THICKNESS));
+
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+
+ /* initialize falloff curve */
+ if (is_multiedit) {
+ BKE_curvemapping_init(ts->gp_sculpt.cur_falloff);
+ }
+
+ if (gpd == NULL) {
+ return;
+ }
+
+ if (is_curve_edit) {
+ createTransGPencil_curves(C,
+ t,
+ depsgraph,
+ ts,
+ obact,
+ gpd,
+ cfra_scene,
+ is_multiedit,
+ use_multiframe_falloff,
+ is_prop_edit,
+ is_prop_edit_connected,
+ is_scale_thickness);
+ }
+ else {
+ createTransGPencil_strokes(C,
+ t,
+ depsgraph,
+ ts,
+ obact,
+ gpd,
+ cfra_scene,
+ is_multiedit,
+ use_multiframe_falloff,
+ is_prop_edit,
+ is_prop_edit_connected,
+ is_scale_thickness);
+ }
+}
+
/* force recalculation of triangles during transformation */
void recalcData_gpencil_strokes(TransInfo *t)
{
@@ -375,13 +751,19 @@ void recalcData_gpencil_strokes(TransInfo *t)
GHash *strokes = BLI_ghash_ptr_new(__func__);
TransData *td = tc->data;
+ bGPdata *gpd = td->ob->data;
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
for (int i = 0; i < tc->data_len; i++, td++) {
bGPDstroke *gps = td->extra;
if ((gps != NULL) && (!BLI_ghash_haskey(strokes, gps))) {
BLI_ghash_insert(strokes, gps, gps);
+ if (is_curve_edit && gps->editcurve != NULL) {
+ BKE_gpencil_editcurve_recalculate_handles(gps);
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ }
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
}
BLI_ghash_free(strokes, NULL, NULL);
diff --git a/source/blender/editors/transform/transform_convert_sequencer.c b/source/blender/editors/transform/transform_convert_sequencer.c
index 307fbbdf80b..3f86ef3e81b 100644
--- a/source/blender/editors/transform/transform_convert_sequencer.c
+++ b/source/blender/editors/transform/transform_convert_sequencer.c
@@ -29,10 +29,11 @@
#include "BKE_context.h"
#include "BKE_report.h"
-#include "BKE_sequencer.h"
#include "ED_markers.h"
+#include "SEQ_sequencer.h"
+
#include "UI_view2d.h"
#include "transform.h"
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 60848eb5678..8a7ec7a99e9 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -799,7 +799,7 @@ void postTrans(bContext *C, TransInfo *t)
if (t->data_len_all != 0) {
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
/* free data malloced per trans-data */
- if (ELEM(t->obedit_type, OB_CURVE, OB_SURF) || (t->spacetype == SPACE_GRAPH)) {
+ if (ELEM(t->obedit_type, OB_CURVE, OB_SURF, OB_GPENCIL) || (t->spacetype == SPACE_GRAPH)) {
TransData *td = tc->data;
for (int a = 0; a < tc->data_len; a++, td++) {
if (td->flag & TD_BEZTRIPLE) {
diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c
index c40f3d3f140..09100bb50cc 100644
--- a/source/blender/editors/transform/transform_gizmo_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -53,7 +53,7 @@
/* -------------------------------------------------------------------- */
/** \name Shared Callback's
- */
+ * \{ */
static bool gizmo2d_generic_poll(const bContext *C, wmGizmoGroupType *gzgt)
{
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index a22f6c35139..d5c6ea2dfdd 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -565,6 +565,9 @@ static bool test_rotmode_euler(short rotmode)
return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0 : 1;
}
+/**
+ * Return false when no gimbal for selection.
+ */
bool gimbal_axis(Object *ob, float gmat[3][3])
{
if (ob->mode & OB_MODE_POSE) {
@@ -650,6 +653,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
Object *ob = OBACT(view_layer);
bGPdata *gpd = CTX_data_gpencil_data(C);
const bool is_gp_edit = GPENCIL_ANY_MODE(gpd);
+ const bool is_curve_edit = GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
int a, totsel = 0;
const int pivot_point = scene->toolsettings->transform_pivot_point;
@@ -708,16 +712,39 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
continue;
}
- /* we're only interested in selected points here... */
- if (gps->flag & GP_STROKE_SELECT) {
- bGPDspoint *pt;
- int i;
+ if (is_curve_edit) {
+ if (gps->editcurve == NULL) {
+ continue;
+ }
- /* Change selection status of all points, then make the stroke match */
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- if (pt->flag & GP_SPOINT_SELECT) {
- calc_tw_center_with_matrix(tbounds, &pt->x, use_mat_local, diff_mat);
- totsel++;
+ bGPDcurve *gpc = gps->editcurve;
+ if (gpc->flag & GP_CURVE_SELECT) {
+ for (uint32_t i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ for (uint32_t j = 0; j < 3; j++) {
+ if (BEZT_ISSEL_IDX(bezt, j)) {
+ calc_tw_center_with_matrix(tbounds, bezt->vec[j], use_mat_local, diff_mat);
+ totsel++;
+ }
+ }
+ }
+ }
+ }
+ }
+ else {
+ /* we're only interested in selected points here... */
+ if (gps->flag & GP_STROKE_SELECT) {
+ bGPDspoint *pt;
+ int i;
+
+ /* Change selection status of all points, then make the stroke match */
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ if (pt->flag & GP_SPOINT_SELECT) {
+ calc_tw_center_with_matrix(tbounds, &pt->x, use_mat_local, diff_mat);
+ totsel++;
+ }
}
}
}
diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c
index c525bc0e6ea..af0a8e5e505 100644
--- a/source/blender/editors/transform/transform_mode.c
+++ b/source/blender/editors/transform/transform_mode.c
@@ -520,9 +520,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
}
/* -------------------------------------------------------------------- */
-/* Transform (Rotation Utils) */
-
-/** \name Transform Rotation Utils
+/** \name Transform (Rotation Utils)
* \{ */
/* Used by Transform Rotation and Transform Normal Rotation */
void headerRotation(TransInfo *t, char str[UI_MAX_DRAW_STR], float final)
@@ -534,13 +532,17 @@ void headerRotation(TransInfo *t, char str[UI_MAX_DRAW_STR], float final)
outputNumInput(&(t->num), c, &t->scene->unit);
- ofs += BLI_snprintf(
- str + ofs, UI_MAX_DRAW_STR - ofs, TIP_("Rot: %s %s %s"), &c[0], t->con.text, t->proptext);
+ ofs += BLI_snprintf(str + ofs,
+ UI_MAX_DRAW_STR - ofs,
+ TIP_("Rotation: %s %s %s"),
+ &c[0],
+ t->con.text,
+ t->proptext);
}
else {
ofs += BLI_snprintf(str + ofs,
UI_MAX_DRAW_STR - ofs,
- TIP_("Rot: %.2f%s %s"),
+ TIP_("Rotation: %.2f%s %s"),
RAD2DEGF(final),
t->con.text,
t->proptext);
@@ -815,9 +817,7 @@ void ElementRotation(
/** \} */
/* -------------------------------------------------------------------- */
-/* Transform (Resize Utils) */
-
-/** \name Transform Resize Utils
+/** \name Transform (Resize Utils)
* \{ */
void headerResize(TransInfo *t, const float vec[3], char str[UI_MAX_DRAW_STR])
{
@@ -1040,9 +1040,7 @@ void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float ma
/** \} */
/* -------------------------------------------------------------------- */
-/* Transform (Frame Utils) */
-
-/** \name Transform Frame Utils
+/** \name Transform (Frame Utils)
* \{ */
/**
diff --git a/source/blender/editors/transform/transform_mode_align.c b/source/blender/editors/transform/transform_mode_align.c
index 4fd4599b940..f16021914f1 100644
--- a/source/blender/editors/transform/transform_mode_align.c
+++ b/source/blender/editors/transform/transform_mode_align.c
@@ -35,9 +35,7 @@
#include "transform_mode.h"
/* -------------------------------------------------------------------- */
-/* Transform (Align) */
-
-/** \name Transform Align
+/** \name Transform (Align)
* \{ */
static void applyAlign(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform_mode_baketime.c b/source/blender/editors/transform/transform_mode_baketime.c
index 6470776e1a2..5efed6920dc 100644
--- a/source/blender/editors/transform/transform_mode_baketime.c
+++ b/source/blender/editors/transform/transform_mode_baketime.c
@@ -40,9 +40,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Bake-Time) */
-
-/** \name Transform Bake-Time
+/** \name Transform (Bake-Time)
* \{ */
static void applyBakeTime(TransInfo *t, const int mval[2])
diff --git a/source/blender/editors/transform/transform_mode_bbone_resize.c b/source/blender/editors/transform/transform_mode_bbone_resize.c
index 57e809a566a..e827e604327 100644
--- a/source/blender/editors/transform/transform_mode_bbone_resize.c
+++ b/source/blender/editors/transform/transform_mode_bbone_resize.c
@@ -41,9 +41,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (EditBone (B-bone) width scaling) */
-
-/** \name Transform B-bone width scaling
+/** \name Transform (EditBone B-Bone width scaling)
* \{ */
static void headerBoneSize(TransInfo *t, const float vec[3], char str[UI_MAX_DRAW_STR])
diff --git a/source/blender/editors/transform/transform_mode_bend.c b/source/blender/editors/transform/transform_mode_bend.c
index 2f83755b1fe..adf3a0346a0 100644
--- a/source/blender/editors/transform/transform_mode_bend.c
+++ b/source/blender/editors/transform/transform_mode_bend.c
@@ -47,9 +47,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Bend) */
-
-/** \name Transform Bend
+/** \name Transform (Bend)
* \{ */
struct BendCustomData {
diff --git a/source/blender/editors/transform/transform_mode_boneenvelope.c b/source/blender/editors/transform/transform_mode_boneenvelope.c
index 1a25ee50543..ced159a76c9 100644
--- a/source/blender/editors/transform/transform_mode_boneenvelope.c
+++ b/source/blender/editors/transform/transform_mode_boneenvelope.c
@@ -40,9 +40,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Bone Envelope) */
-
-/** \name Transform Bone Envelope
+/** \name Transform (Bone Envelope)
* \{ */
static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform_mode_boneroll.c b/source/blender/editors/transform/transform_mode_boneroll.c
index cd277517d6b..da6c0b44c3a 100644
--- a/source/blender/editors/transform/transform_mode_boneroll.c
+++ b/source/blender/editors/transform/transform_mode_boneroll.c
@@ -40,9 +40,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (EditBone Roll) */
-
-/** \name Transform EditBone Roll
+/** \name Transform (EditBone Roll)
* \{ */
static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
index 1935264d6d0..ee63bf4be6f 100644
--- a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
@@ -40,9 +40,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Curve Shrink/Fatten) */
-
-/** \name Transform Curve Shrink/Fatten
+/** \name Transform (Curve Shrink/Fatten)
* \{ */
static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform_mode_edge_bevelweight.c b/source/blender/editors/transform/transform_mode_edge_bevelweight.c
index 2f7707cdee4..3ce52ed3296 100644
--- a/source/blender/editors/transform/transform_mode_edge_bevelweight.c
+++ b/source/blender/editors/transform/transform_mode_edge_bevelweight.c
@@ -40,9 +40,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Bevel Weight) */
-
-/** \name Transform Bevel Weight
+/** \name Transform (Bevel Weight)
* \{ */
static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform_mode_edge_crease.c b/source/blender/editors/transform/transform_mode_edge_crease.c
index e2e0afc0a8f..23fa20b68ff 100644
--- a/source/blender/editors/transform/transform_mode_edge_crease.c
+++ b/source/blender/editors/transform/transform_mode_edge_crease.c
@@ -40,9 +40,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Crease) */
-
-/** \name Transform Crease
+/** \name Transform (Crease)
* \{ */
static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
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 4b083a0529f..32f0d4bd365 100644
--- a/source/blender/editors/transform/transform_mode_edge_rotate_normal.c
+++ b/source/blender/editors/transform/transform_mode_edge_rotate_normal.c
@@ -39,9 +39,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Normal Rotation) */
-
-/** \name Transform Normal Rotation
+/** \name Transform (Normal Rotation)
* \{ */
static void storeCustomLNorValue(TransDataContainer *tc, BMesh *bm)
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 5222d4d4e5a..dfa5c164acf 100644
--- a/source/blender/editors/transform/transform_mode_edge_seq_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_seq_slide.c
@@ -42,9 +42,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Sequencer Slide) */
-
-/** \name Transform Sequencer Slide
+/** \name Transform (Sequencer Slide)
* \{ */
static void headerSeqSlide(TransInfo *t, const float val[2], char str[UI_MAX_DRAW_STR])
diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c b/source/blender/editors/transform/transform_mode_edge_slide.c
index c887b69c792..dae3fe6f7b4 100644
--- a/source/blender/editors/transform/transform_mode_edge_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_slide.c
@@ -56,9 +56,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Edge Slide) */
-
-/** \name Transform Edge Slide
+/** \name Transform (Edge Slide)
* \{ */
typedef struct TransDataEdgeSlideVert {
diff --git a/source/blender/editors/transform/transform_mode_gpopacity.c b/source/blender/editors/transform/transform_mode_gpopacity.c
index 5eb390d7cbd..e67c6c03481 100644
--- a/source/blender/editors/transform/transform_mode_gpopacity.c
+++ b/source/blender/editors/transform/transform_mode_gpopacity.c
@@ -29,6 +29,8 @@
#include "BKE_context.h"
#include "BKE_unit.h"
+#include "DNA_gpencil_types.h"
+
#include "ED_screen.h"
#include "UI_interface.h"
@@ -40,9 +42,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (GPencil Opacity) */
-
-/** \name Transform GPencil Strokes Opacity
+/** \name Transform (GPencil Strokes Opacity)
* \{ */
static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2]))
@@ -70,8 +70,16 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), TIP_("Opacity: %3f"), ratio);
}
+ bool recalc = false;
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
+ bGPdata *gpd = td->ob->data;
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+ /* Only recalculate data when in curve edit mode. */
+ if (is_curve_edit) {
+ recalc = true;
+ }
+
for (i = 0; i < tc->data_len; i++, td++) {
if (td->flag & TD_SKIP) {
continue;
@@ -86,6 +94,10 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2]))
}
}
+ if (recalc) {
+ recalcData(t);
+ }
+
ED_area_status_text(t->area, str);
}
diff --git a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c
index 2d886b55a04..95e3d89d2b7 100644
--- a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c
@@ -29,6 +29,8 @@
#include "BKE_context.h"
#include "BKE_unit.h"
+#include "DNA_gpencil_types.h"
+
#include "ED_screen.h"
#include "UI_interface.h"
@@ -40,9 +42,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (GPencil Shrink/Fatten) */
-
-/** \name Transform GPencil Strokes Shrink/Fatten
+/** \name Transform (GPencil Strokes Shrink/Fatten)
* \{ */
static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
@@ -70,8 +70,16 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), TIP_("Shrink/Fatten: %3f"), ratio);
}
+ bool recalc = false;
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
+ bGPdata *gpd = td->ob->data;
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+ /* Only recalculate data when in curve edit mode. */
+ if (is_curve_edit) {
+ recalc = true;
+ }
+
for (i = 0; i < tc->data_len; i++, td++) {
if (td->flag & TD_SKIP) {
continue;
@@ -88,6 +96,10 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
}
}
+ if (recalc) {
+ recalcData(t);
+ }
+
ED_area_status_text(t->area, str);
}
diff --git a/source/blender/editors/transform/transform_mode_maskshrinkfatten.c b/source/blender/editors/transform/transform_mode_maskshrinkfatten.c
index 1c5b5000f5c..3019984d70b 100644
--- a/source/blender/editors/transform/transform_mode_maskshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_maskshrinkfatten.c
@@ -40,9 +40,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Mask Shrink/Fatten) */
-
-/** \name Transform Mask Shrink/Fatten
+/** \name Transform (Mask Shrink/Fatten)
* \{ */
static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform_mode_mirror.c b/source/blender/editors/transform/transform_mode_mirror.c
index 8d953610eb8..1440553de51 100644
--- a/source/blender/editors/transform/transform_mode_mirror.c
+++ b/source/blender/editors/transform/transform_mode_mirror.c
@@ -38,9 +38,7 @@
#include "transform_mode.h"
/* -------------------------------------------------------------------- */
-/* Transform (Mirror) */
-
-/** \name Transform Mirror
+/** \name Transform (Mirror)
* \{ */
static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform_mode_push_pull.c b/source/blender/editors/transform/transform_mode_push_pull.c
index 860dd51da94..8a92978f33f 100644
--- a/source/blender/editors/transform/transform_mode_push_pull.c
+++ b/source/blender/editors/transform/transform_mode_push_pull.c
@@ -41,9 +41,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Push/Pull) */
-
-/** \name Transform Push/Pull
+/** \name Transform (Push/Pull)
* \{ */
static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform_mode_resize.c b/source/blender/editors/transform/transform_mode_resize.c
index 33303b82567..62a4fbd6f04 100644
--- a/source/blender/editors/transform/transform_mode_resize.c
+++ b/source/blender/editors/transform/transform_mode_resize.c
@@ -39,9 +39,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Resize) */
-
-/** \name Transform Resize
+/** \name Transform (Resize)
* \{ */
static float ResizeBetween(TransInfo *t, const float p1[3], const float p2[3])
diff --git a/source/blender/editors/transform/transform_mode_rotate.c b/source/blender/editors/transform/transform_mode_rotate.c
index d8857dbc31e..856e71a0df6 100644
--- a/source/blender/editors/transform/transform_mode_rotate.c
+++ b/source/blender/editors/transform/transform_mode_rotate.c
@@ -37,9 +37,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Rotation) */
-
-/** \name Transform Rotation
+/** \name Transform (Rotation)
* \{ */
static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3])
diff --git a/source/blender/editors/transform/transform_mode_shear.c b/source/blender/editors/transform/transform_mode_shear.c
index dfc6f69b341..a41c49710b9 100644
--- a/source/blender/editors/transform/transform_mode_shear.c
+++ b/source/blender/editors/transform/transform_mode_shear.c
@@ -44,9 +44,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Shear) */
-
-/** \name Transform Shear
+/** \name Transform (Shear)
* \{ */
static void initShear_mouseInputMode(TransInfo *t)
diff --git a/source/blender/editors/transform/transform_mode_shrink_fatten.c b/source/blender/editors/transform/transform_mode_shrink_fatten.c
index af33c2bb090..cdea388529f 100644
--- a/source/blender/editors/transform/transform_mode_shrink_fatten.c
+++ b/source/blender/editors/transform/transform_mode_shrink_fatten.c
@@ -42,9 +42,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Shrink-Fatten) */
-
-/** \name Transform Shrink-Fatten
+/** \name Transform (Shrink-Fatten)
* \{ */
static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform_mode_skin_resize.c b/source/blender/editors/transform/transform_mode_skin_resize.c
index a1a6f0ce8f8..b4c919cbb86 100644
--- a/source/blender/editors/transform/transform_mode_skin_resize.c
+++ b/source/blender/editors/transform/transform_mode_skin_resize.c
@@ -38,9 +38,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Skin) */
-
-/** \name Transform Skin
+/** \name Transform (Skin)
* \{ */
static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform_mode_tilt.c b/source/blender/editors/transform/transform_mode_tilt.c
index 07e0e156803..d3b72fdf503 100644
--- a/source/blender/editors/transform/transform_mode_tilt.c
+++ b/source/blender/editors/transform/transform_mode_tilt.c
@@ -40,9 +40,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Tilt) */
-
-/** \name Transform Tilt
+/** \name Transform (Tilt)
* \{ */
static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
diff --git a/source/blender/editors/transform/transform_mode_timescale.c b/source/blender/editors/transform/transform_mode_timescale.c
index dbe06a6f1f6..7ae97c66660 100644
--- a/source/blender/editors/transform/transform_mode_timescale.c
+++ b/source/blender/editors/transform/transform_mode_timescale.c
@@ -42,9 +42,7 @@
#include "transform_mode.h"
/* -------------------------------------------------------------------- */
-/* Transform (Animation Time Scale) */
-
-/** \name Transform Animation Time Scale
+/** \name Transform (Animation Time Scale)
* \{ */
static void headerTimeScale(TransInfo *t, char str[UI_MAX_DRAW_STR])
diff --git a/source/blender/editors/transform/transform_mode_timeslide.c b/source/blender/editors/transform/transform_mode_timeslide.c
index 9636b4f6e42..34d3251f9cf 100644
--- a/source/blender/editors/transform/transform_mode_timeslide.c
+++ b/source/blender/editors/transform/transform_mode_timeslide.c
@@ -45,9 +45,7 @@
#include "transform_mode.h"
/* -------------------------------------------------------------------- */
-/* Transform (Animation Time Slide) */
-
-/** \name Transform Animation Time Slide
+/** \name Transform (Animation Time Slide)
* \{ */
static void headerTimeSlide(TransInfo *t, const float sval, char str[UI_MAX_DRAW_STR])
diff --git a/source/blender/editors/transform/transform_mode_timetranslate.c b/source/blender/editors/transform/transform_mode_timetranslate.c
index 226e8a377ea..adebc19c2b9 100644
--- a/source/blender/editors/transform/transform_mode_timetranslate.c
+++ b/source/blender/editors/transform/transform_mode_timetranslate.c
@@ -43,9 +43,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Animation Translation) */
-
-/** \name Transform Animation Translation
+/** \name Transform (Animation Translation)
* \{ */
static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR])
diff --git a/source/blender/editors/transform/transform_mode_trackball.c b/source/blender/editors/transform/transform_mode_trackball.c
index 32019e151a1..5a57a69f986 100644
--- a/source/blender/editors/transform/transform_mode_trackball.c
+++ b/source/blender/editors/transform/transform_mode_trackball.c
@@ -40,9 +40,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Rotation - Trackball) */
-
-/** \name Transform Rotation - Trackball
+/** \name Transform (Rotation - Trackball)
* \{ */
static void applyTrackballValue(TransInfo *t,
diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c
index d4748e7933b..183fc8f5dc3 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -49,9 +49,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Translation) */
-
-/** \name Transform Translation
+/** \name Transform (Translation)
* \{ */
static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_DRAW_STR])
diff --git a/source/blender/editors/transform/transform_mode_vert_slide.c b/source/blender/editors/transform/transform_mode_vert_slide.c
index 289ed76c731..1e5d027e253 100644
--- a/source/blender/editors/transform/transform_mode_vert_slide.c
+++ b/source/blender/editors/transform/transform_mode_vert_slide.c
@@ -53,9 +53,7 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
-/* Transform (Vert Slide) */
-
-/** \name Transform Vert Slide
+/** \name Transform (Vert Slide)
* \{ */
typedef struct TransDataVertSlideVert {
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index b164d0d443f..c455dd55b8a 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -541,7 +541,7 @@ static bool transform_poll_property(const bContext *UNUSED(C),
{
/* Hide orientation axis if no constraints are set, since it wont be used. */
PropertyRNA *prop_con = RNA_struct_find_property(op->ptr, "orient_type");
- if (prop_con != NULL && (prop_con != prop)) {
+ if (!ELEM(prop_con, NULL, prop)) {
if (STRPREFIX(prop_id, "constraint")) {
/* Special case: show constraint axis if we don't have values,
@@ -825,6 +825,17 @@ static void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
+/* Similar to #transform_shear_poll. */
+static bool transform_rotate_poll(bContext *C)
+{
+ if (!ED_operator_screenactive(C)) {
+ return false;
+ }
+
+ ScrArea *area = CTX_wm_area(C);
+ return area && !ELEM(area->spacetype, SPACE_ACTION);
+}
+
static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
{
/* identifiers */
@@ -838,7 +849,7 @@ static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
- ot->poll = ED_operator_screenactive;
+ ot->poll = transform_rotate_poll;
ot->poll_property = transform_poll_property;
RNA_def_float_rotation(
@@ -902,6 +913,7 @@ static void TRANSFORM_OT_bend(struct wmOperatorType *ot)
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
+/* Similar to #transform_rotate_poll. */
static bool transform_shear_poll(bContext *C)
{
if (!ED_operator_screenactive(C)) {
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index e461bcb88e9..f1c4c243780 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -38,10 +38,11 @@
#include "BKE_layer.h"
#include "BKE_object.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
#include "RNA_access.h"
+#include "SEQ_sequencer.h"
+
#include "WM_types.h"
#include "ED_gizmo_library.h"
diff --git a/source/blender/editors/undo/memfile_undo.c b/source/blender/editors/undo/memfile_undo.c
index 2df26abe8b3..49417a54472 100644
--- a/source/blender/editors/undo/memfile_undo.c
+++ b/source/blender/editors/undo/memfile_undo.c
@@ -24,7 +24,9 @@
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
+#include "BLI_listbase.h"
+#include "DNA_ID.h"
#include "DNA_node_types.h"
#include "DNA_object_enums.h"
#include "DNA_object_types.h"
@@ -52,6 +54,8 @@
#include "undo_intern.h"
+#include <stdio.h>
+
/* -------------------------------------------------------------------- */
/** \name Implements ED Undo System
* \{ */
@@ -307,4 +311,35 @@ struct MemFile *ED_undosys_stack_memfile_get_active(UndoStack *ustack)
return NULL;
}
+/**
+ * If the last undo step is a memfile one, find the first #MemFileChunk matching given ID
+ * (using its session UUID), and tag it as "changed in the future".
+ *
+ * Since non-memfile undos cannot automatically set this flag in the previous step as done with
+ * memfile ones, this has to be called manually by relevant undo code.
+ *
+ * \note Only current known case for this is undoing a switch from Object to Sculpt mode (see
+ * T82388).
+ *
+ * \note Calling this ID by ID is not optimal, as it will loop over all #MemFile.chunks until it
+ * finds the expected one. If this becomes an issue we'll have to add a mapping from session UUID
+ * to first #MemFileChunk in #MemFile itself
+ * (currently we only do that in #MemFileWriteData when writing a new step).
+ */
+void ED_undosys_stack_memfile_id_changed_tag(UndoStack *ustack, ID *id)
+{
+ UndoStep *us = ustack->step_active;
+ if (id == NULL || us == NULL || us->type != BKE_UNDOSYS_TYPE_MEMFILE) {
+ return;
+ }
+
+ MemFile *memfile = &((MemFileUndoStep *)us)->data->memfile;
+ LISTBASE_FOREACH (MemFileChunk *, mem_chunk, &memfile->chunks) {
+ if (mem_chunk->id_session_uuid == id->session_uuid) {
+ mem_chunk->is_identical_future = false;
+ break;
+ }
+ }
+}
+
/** \} */
diff --git a/source/blender/editors/util/ed_util_imbuf.c b/source/blender/editors/util/ed_util_imbuf.c
index 9a2b346132e..b832d9a1d86 100644
--- a/source/blender/editors/util/ed_util_imbuf.c
+++ b/source/blender/editors/util/ed_util_imbuf.c
@@ -30,7 +30,6 @@
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_screen.h"
-#include "BKE_sequencer.h"
#include "ED_image.h"
#include "ED_screen.h"
@@ -43,6 +42,8 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "SEQ_sequencer.h"
+
#include "UI_view2d.h"
#include "WM_api.h"
@@ -369,7 +370,7 @@ static void sequencer_sample_apply(bContext *C, wmOperator *op, const wmEvent *e
/* sequencer's image buffers are in non-linear space, need to make them linear */
copy_v4_v4(info->linearcol, info->colf);
- BKE_sequencer_pixel_from_sequencer_space_v4(scene, info->linearcol);
+ SEQ_render_pixel_from_sequencer_space_v4(scene, info->linearcol);
info->color_manage = true;
}
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 0ae167c117e..cc6eb49f984 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -4407,8 +4407,7 @@ void param_delete(ParamHandle *handle)
PHandle *phandle = (PHandle *)handle;
int i;
- param_assert((phandle->state == PHANDLE_STATE_ALLOCATED) ||
- (phandle->state == PHANDLE_STATE_CONSTRUCTED));
+ param_assert(ELEM(phandle->state, PHANDLE_STATE_ALLOCATED, PHANDLE_STATE_CONSTRUCTED));
for (i = 0; i < phandle->ncharts; i++) {
p_chart_delete(phandle->charts[i]);
@@ -4507,7 +4506,7 @@ void param_face_add(ParamHandle *handle,
param_assert(phash_lookup(phandle->hash_faces, key) == NULL);
param_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
- param_assert((nverts == 3) || (nverts == 4));
+ param_assert(ELEM(nverts, 3, 4));
if (nverts > 4) {
/* ngon */
diff --git a/source/blender/freestyle/CMakeLists.txt b/source/blender/freestyle/CMakeLists.txt
index 8270476e9dd..b7eaf018dba 100644
--- a/source/blender/freestyle/CMakeLists.txt
+++ b/source/blender/freestyle/CMakeLists.txt
@@ -565,8 +565,8 @@ set(INC
../makesrna
../python
../python/intern
- ../render/extern/include
- ../render/intern/include
+ ../render
+ ../render/intern
../../../extern/glew/include
../../../intern/guardedalloc
)
diff --git a/source/blender/freestyle/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp
index d34be79cd66..9187e0ebb05 100644
--- a/source/blender/freestyle/intern/application/AppCanvas.cpp
+++ b/source/blender/freestyle/intern/application/AppCanvas.cpp
@@ -31,13 +31,13 @@
#include "../system/StringUtils.h"
namespace Freestyle {
-AppCanvas::AppCanvas() : Canvas()
+AppCanvas::AppCanvas()
{
- _pViewer = 0;
+ _pViewer = nullptr;
_MapsPath = Config::Path::getInstance()->getMapsDir().c_str();
}
-AppCanvas::AppCanvas(AppView *iViewer) : Canvas()
+AppCanvas::AppCanvas(AppView *iViewer)
{
_pViewer = iViewer;
}
@@ -49,7 +49,7 @@ AppCanvas::AppCanvas(const AppCanvas &iBrother) : Canvas(iBrother)
AppCanvas::~AppCanvas()
{
- _pViewer = 0;
+ _pViewer = nullptr;
}
void AppCanvas::setViewer(AppView *iViewer)
diff --git a/source/blender/freestyle/intern/application/AppConfig.cpp b/source/blender/freestyle/intern/application/AppConfig.cpp
index 3aae4254b4b..90ded5045dc 100644
--- a/source/blender/freestyle/intern/application/AppConfig.cpp
+++ b/source/blender/freestyle/intern/application/AppConfig.cpp
@@ -28,16 +28,14 @@ using namespace std;
#include "BKE_appdir.h"
-namespace Freestyle {
+namespace Freestyle::Config {
-namespace Config {
-
-Path *Path::_pInstance = 0;
+Path *Path::_pInstance = nullptr;
Path::Path()
{
// get the root directory
// soc
- setRootDir(BKE_appdir_folder_id(BLENDER_SYSTEM_SCRIPTS, NULL));
+ setRootDir(BKE_appdir_folder_id(BLENDER_SYSTEM_SCRIPTS, nullptr));
_pInstance = this;
}
@@ -62,7 +60,7 @@ void Path::setHomeDir(const string &iHomeDir)
Path::~Path()
{
- _pInstance = 0;
+ _pInstance = nullptr;
}
Path *Path::getInstance()
@@ -85,6 +83,4 @@ string Path::getEnvVar(const string &iEnvVarName)
return value;
}
-} // namespace Config
-
-} /* namespace Freestyle */
+} // namespace Freestyle::Config
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index 4628c76ca7f..63612694e65 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -93,10 +93,10 @@ Controller::Controller()
_DebugNode->addRef();
#endif
- _winged_edge = NULL;
+ _winged_edge = nullptr;
- _pView = NULL;
- _pRenderMonitor = NULL;
+ _pView = nullptr;
+ _pRenderMonitor = nullptr;
_edgeTesselationNature = (Nature::SILHOUETTE | Nature::BORDER | Nature::CREASE);
@@ -108,9 +108,9 @@ Controller::Controller()
_EPSILON = 1.0e-6;
_bboxDiag = 0;
- _ViewMap = 0;
+ _ViewMap = nullptr;
- _Canvas = 0;
+ _Canvas = nullptr;
_VisibilityAlgo = ViewMapBuilder::ray_casting_adaptive_traditional;
//_VisibilityAlgo = ViewMapBuilder::ray_casting;
@@ -134,7 +134,7 @@ Controller::Controller()
Controller::~Controller()
{
- if (NULL != _RootNode) {
+ if (nullptr != _RootNode) {
int ref = _RootNode->destroy();
if (0 == ref) {
delete _RootNode;
@@ -159,27 +159,27 @@ Controller::~Controller()
if (_winged_edge) {
delete _winged_edge;
- _winged_edge = NULL;
+ _winged_edge = nullptr;
}
- if (0 != _ViewMap) {
+ if (nullptr != _ViewMap) {
delete _ViewMap;
- _ViewMap = 0;
+ _ViewMap = nullptr;
}
- if (0 != _Canvas) {
+ if (nullptr != _Canvas) {
delete _Canvas;
- _Canvas = 0;
+ _Canvas = nullptr;
}
if (_inter) {
delete _inter;
- _inter = NULL;
+ _inter = nullptr;
}
if (_ProgressBar) {
delete _ProgressBar;
- _ProgressBar = NULL;
+ _ProgressBar = nullptr;
}
// delete _current_dirs;
@@ -187,7 +187,7 @@ Controller::~Controller()
void Controller::setView(AppView *iView)
{
- if (NULL == iView) {
+ if (nullptr == iView) {
return;
}
@@ -203,14 +203,14 @@ void Controller::setRenderMonitor(RenderMonitor *iRenderMonitor)
void Controller::setPassDiffuse(float *buf, int width, int height)
{
AppCanvas *app_canvas = dynamic_cast<AppCanvas *>(_Canvas);
- BLI_assert(app_canvas != 0);
+ BLI_assert(app_canvas != nullptr);
app_canvas->setPassDiffuse(buf, width, height);
}
void Controller::setPassZ(float *buf, int width, int height)
{
AppCanvas *app_canvas = dynamic_cast<AppCanvas *>(_Canvas);
- BLI_assert(app_canvas != 0);
+ BLI_assert(app_canvas != nullptr);
app_canvas->setPassZ(buf, width, height);
}
@@ -226,7 +226,7 @@ bool Controller::hitViewMapCache()
return false;
}
if (sceneHashFunc.match()) {
- return (NULL != _ViewMap);
+ return (nullptr != _ViewMap);
}
sceneHashFunc.store();
return false;
@@ -242,7 +242,7 @@ int Controller::LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph
NodeGroup *blenderScene = loader.Load();
- if (blenderScene == NULL) {
+ if (blenderScene == nullptr) {
if (G.debug & G_DEBUG_FREESTYLE) {
cout << "Cannot load scene" << endl;
}
@@ -318,7 +318,7 @@ int Controller::LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph
}
delete _ViewMap;
- _ViewMap = NULL;
+ _ViewMap = nullptr;
}
_Chrono.start();
@@ -350,7 +350,7 @@ int Controller::LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph
string basename = string(cleaned);
#endif
- _ListOfModels.push_back("Blender_models");
+ _ListOfModels.emplace_back("Blender_models");
_Scene3dBBox = _RootNode->bbox();
@@ -386,14 +386,14 @@ void Controller::CloseFile()
_Canvas->Clear();
// soc: reset passes
- setPassDiffuse(NULL, 0, 0);
- setPassZ(NULL, 0, 0);
+ setPassDiffuse(nullptr, 0, 0);
+ setPassZ(nullptr, 0, 0);
}
void Controller::ClearRootNode()
{
_pView->DetachModel();
- if (NULL != _RootNode) {
+ if (nullptr != _RootNode) {
int ref = _RootNode->destroy();
if (0 == ref) {
_RootNode->addRef();
@@ -406,7 +406,7 @@ void Controller::DeleteWingedEdge()
{
if (_winged_edge) {
delete _winged_edge;
- _winged_edge = NULL;
+ _winged_edge = nullptr;
}
// clears the grid
@@ -454,10 +454,10 @@ void Controller::DeleteViewMap(bool freeCache)
}
#endif
- if (NULL != _ViewMap) {
+ if (nullptr != _ViewMap) {
if (freeCache || !_EnableViewMapCache) {
delete _ViewMap;
- _ViewMap = NULL;
+ _ViewMap = nullptr;
prevSceneHash = -1.0;
}
else {
@@ -877,7 +877,7 @@ bool Controller::getComputeSteerableViewMapFlag() const
int Controller::DrawStrokes()
{
- if (_ViewMap == 0) {
+ if (_ViewMap == nullptr) {
return 0;
}
@@ -927,12 +927,7 @@ Render *Controller::RenderStrokes(Render *re, bool render)
float megs_used_memory = (mem_in_use) / (1024.0 * 1024.0);
float megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
- printf("%d objs, %d verts, %d faces, mem %.2fM (peak %.2fM)\n",
- totmesh,
- freestyle_render->i.totvert,
- freestyle_render->i.totface,
- megs_used_memory,
- megs_peak_memory);
+ printf("%d objs, mem %.2fM (peak %.2fM)\n", totmesh, megs_used_memory, megs_peak_memory);
}
delete blenderRenderer;
@@ -1134,8 +1129,8 @@ void Controller::init_options()
_Canvas->init();
// soc: initialize passes
- setPassDiffuse(NULL, 0, 0);
- setPassZ(NULL, 0, 0);
+ setPassDiffuse(nullptr, 0, 0);
+ setPassZ(nullptr, 0, 0);
}
} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
index ee584f8953c..930da3ef471 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
@@ -33,18 +33,18 @@ BlenderFileLoader::BlenderFileLoader(Render *re, ViewLayer *view_layer, Depsgrap
{
_re = re;
_depsgraph = depsgraph;
- _Scene = NULL;
+ _Scene = nullptr;
_numFacesRead = 0;
#if 0
_minEdgeSize = DBL_MAX;
#endif
_smooth = (view_layer->freestyle_config.flags & FREESTYLE_FACE_SMOOTHNESS_FLAG) != 0;
- _pRenderMonitor = NULL;
+ _pRenderMonitor = nullptr;
}
BlenderFileLoader::~BlenderFileLoader()
{
- _Scene = NULL;
+ _Scene = nullptr;
}
NodeGroup *BlenderFileLoader::Load()
@@ -61,7 +61,7 @@ NodeGroup *BlenderFileLoader::Load()
_viewplane_bottom = _re->viewplane.ymin;
_viewplane_top = _re->viewplane.ymax;
- if (_re->clip_start < 0.f) {
+ if (_re->clip_start < 0.0f) {
// Adjust clipping start/end and set up a Z offset when the viewport preview
// is used with the orthographic view. In this case, _re->clip_start is negative,
// while Freestyle assumes that imported mesh data are in the camera coordinate
@@ -73,7 +73,7 @@ NodeGroup *BlenderFileLoader::Load()
else {
_z_near = -_re->clip_start;
_z_far = -_re->clip_end;
- _z_offset = 0.f;
+ _z_offset = 0.0f;
}
#if 0
@@ -104,7 +104,7 @@ NodeGroup *BlenderFileLoader::Load()
continue;
}
- Mesh *mesh = BKE_object_to_mesh(NULL, ob, false);
+ Mesh *mesh = BKE_object_to_mesh(nullptr, ob, false);
if (mesh) {
insertShapeNode(ob, mesh, ++id);
@@ -169,7 +169,7 @@ int BlenderFileLoader::countClippedFaces(float v1[3], float v2[3], float v3[3],
}
break;
case 3:
- if (sum == 3 || sum == -3) {
+ if (ELEM(sum, 3, -3)) {
numTris = 0;
}
else {
@@ -422,7 +422,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
// Compute loop normals
BKE_mesh_calc_normals_split(me);
- float(*lnors)[3] = NULL;
+ float(*lnors)[3] = nullptr;
if (CustomData_has_layer(&me->ldata, CD_NORMAL)) {
lnors = (float(*)[3])CustomData_get_layer(&me->ldata, CD_NORMAL);
@@ -577,7 +577,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
tmpMat.setLine(mat->line_col[0], mat->line_col[1], mat->line_col[2], mat->line_col[3]);
tmpMat.setDiffuse(mat->r, mat->g, mat->b, 1.0f);
tmpMat.setSpecular(mat->specr, mat->specg, mat->specb, 1.0f);
- tmpMat.setShininess(128.f);
+ tmpMat.setShininess(128.0f);
tmpMat.setPriority(mat->line_priority);
}
@@ -633,16 +633,16 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
// We might have several times the same vertex. We want a clean
// shape with no real-vertex. Here, we are making a cleaning pass.
- float *cleanVertices = NULL;
+ float *cleanVertices = nullptr;
unsigned int cvSize;
- unsigned int *cleanVIndices = NULL;
+ unsigned int *cleanVIndices = nullptr;
GeomCleaner::CleanIndexedVertexArray(
vertices, vSize, VIndices, viSize, &cleanVertices, &cvSize, &cleanVIndices);
- float *cleanNormals = NULL;
+ float *cleanNormals = nullptr;
unsigned int cnSize;
- unsigned int *cleanNIndices = NULL;
+ unsigned int *cleanNIndices = nullptr;
GeomCleaner::CleanIndexedVertexArray(
normals, nSize, NIndices, niSize, &cleanNormals, &cnSize, &cleanNIndices);
@@ -777,7 +777,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
cnSize,
marray,
meshFrsMaterials.size(),
- 0,
+ nullptr,
0,
numFaces,
numVertexPerFaces,
@@ -789,7 +789,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
niSize,
MIndices,
viSize,
- 0,
+ nullptr,
0,
0);
// sets the id of the rep
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index f31d7c95997..8aaffd4dde8 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -70,7 +70,7 @@ namespace Freestyle {
const char *BlenderStrokeRenderer::uvNames[] = {"along_stroke", "along_stroke_tips"};
-BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : StrokeRenderer()
+BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count)
{
freestyle_bmain = BKE_main_new();
@@ -141,7 +141,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
view_layer->layflag = SCE_LAY_SOLID | SCE_LAY_ZTRA;
// Camera
- Object *object_camera = BKE_object_add(freestyle_bmain, view_layer, OB_CAMERA, NULL);
+ Object *object_camera = BKE_object_add(freestyle_bmain, view_layer, OB_CAMERA, nullptr);
Camera *camera = (Camera *)object_camera->data;
camera->type = CAM_ORTHO;
@@ -174,7 +174,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
BlenderStrokeRenderer::~BlenderStrokeRenderer()
{
- BLI_ghash_free(_nodetree_hash, NULL, NULL);
+ BLI_ghash_free(_nodetree_hash, nullptr, nullptr);
DEG_graph_free(freestyle_depsgraph);
@@ -188,7 +188,7 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer()
BKE_main_free(freestyle_bmain);
}
-float BlenderStrokeRenderer::get_stroke_vertex_z(void) const
+float BlenderStrokeRenderer::get_stroke_vertex_z() const
{
float z = _z;
BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this);
@@ -199,7 +199,7 @@ float BlenderStrokeRenderer::get_stroke_vertex_z(void) const
return -z;
}
-unsigned int BlenderStrokeRenderer::get_stroke_mesh_id(void) const
+unsigned int BlenderStrokeRenderer::get_stroke_mesh_id() const
{
unsigned mesh_id = _mesh_id;
BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this);
@@ -213,7 +213,7 @@ Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain,
{
Material *ma = BKE_material_add(bmain, "stroke_shader");
bNodeTree *ntree;
- bNode *output_linestyle = NULL;
+ bNode *output_linestyle = nullptr;
bNodeSocket *fromsock, *tosock;
PointerRNA fromptr, toptr;
NodeShaderAttribute *storage;
@@ -233,19 +233,19 @@ Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain,
}
}
else {
- ntree = ntreeAddTree(NULL, "stroke_shader", "ShaderNodeTree");
+ ntree = ntreeAddTree(nullptr, "stroke_shader", "ShaderNodeTree");
}
ma->nodetree = ntree;
ma->use_nodes = 1;
ma->blend_method = MA_BM_HASHED;
- bNode *input_attr_color = nodeAddStaticNode(NULL, ntree, SH_NODE_ATTRIBUTE);
+ bNode *input_attr_color = nodeAddStaticNode(nullptr, ntree, SH_NODE_ATTRIBUTE);
input_attr_color->locx = 0.0f;
input_attr_color->locy = -200.0f;
storage = (NodeShaderAttribute *)input_attr_color->storage;
BLI_strncpy(storage->name, "Color", sizeof(storage->name));
- bNode *mix_rgb_color = nodeAddStaticNode(NULL, ntree, SH_NODE_MIX_RGB);
+ bNode *mix_rgb_color = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_RGB);
mix_rgb_color->custom1 = MA_RAMP_BLEND; // Mix
mix_rgb_color->locx = 200.0f;
mix_rgb_color->locy = -200.0f;
@@ -253,13 +253,13 @@ Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain,
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
RNA_float_set(&toptr, "default_value", 0.0f);
- bNode *input_attr_alpha = nodeAddStaticNode(NULL, ntree, SH_NODE_ATTRIBUTE);
+ bNode *input_attr_alpha = nodeAddStaticNode(nullptr, ntree, SH_NODE_ATTRIBUTE);
input_attr_alpha->locx = 400.0f;
input_attr_alpha->locy = 300.0f;
storage = (NodeShaderAttribute *)input_attr_alpha->storage;
BLI_strncpy(storage->name, "Alpha", sizeof(storage->name));
- bNode *mix_rgb_alpha = nodeAddStaticNode(NULL, ntree, SH_NODE_MIX_RGB);
+ bNode *mix_rgb_alpha = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_RGB);
mix_rgb_alpha->custom1 = MA_RAMP_BLEND; // Mix
mix_rgb_alpha->locx = 600.0f;
mix_rgb_alpha->locy = 300.0f;
@@ -267,27 +267,27 @@ Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain,
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
RNA_float_set(&toptr, "default_value", 0.0f);
- bNode *shader_emission = nodeAddStaticNode(NULL, ntree, SH_NODE_EMISSION);
+ bNode *shader_emission = nodeAddStaticNode(nullptr, ntree, SH_NODE_EMISSION);
shader_emission->locx = 400.0f;
shader_emission->locy = -200.0f;
- bNode *input_light_path = nodeAddStaticNode(NULL, ntree, SH_NODE_LIGHT_PATH);
+ bNode *input_light_path = nodeAddStaticNode(nullptr, ntree, SH_NODE_LIGHT_PATH);
input_light_path->locx = 400.0f;
input_light_path->locy = 100.0f;
- bNode *mix_shader_color = nodeAddStaticNode(NULL, ntree, SH_NODE_MIX_SHADER);
+ bNode *mix_shader_color = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_SHADER);
mix_shader_color->locx = 600.0f;
mix_shader_color->locy = -100.0f;
- bNode *shader_transparent = nodeAddStaticNode(NULL, ntree, SH_NODE_BSDF_TRANSPARENT);
+ bNode *shader_transparent = nodeAddStaticNode(nullptr, ntree, SH_NODE_BSDF_TRANSPARENT);
shader_transparent->locx = 600.0f;
shader_transparent->locy = 100.0f;
- bNode *mix_shader_alpha = nodeAddStaticNode(NULL, ntree, SH_NODE_MIX_SHADER);
+ bNode *mix_shader_alpha = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_SHADER);
mix_shader_alpha->locx = 800.0f;
mix_shader_alpha->locy = 100.0f;
- bNode *output_material = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_MATERIAL);
+ bNode *output_material = nodeAddStaticNode(nullptr, ntree, SH_NODE_OUTPUT_MATERIAL);
output_material->locx = 1000.0f;
output_material->locy = 100.0f;
@@ -393,7 +393,7 @@ Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain,
bNodeSocket *sock = (bNodeSocket *)BLI_findlink(&node->outputs, 0);
// add new UV Map node
- bNode *input_uvmap = nodeAddStaticNode(NULL, ntree, SH_NODE_UVMAP);
+ bNode *input_uvmap = nodeAddStaticNode(nullptr, ntree, SH_NODE_UVMAP);
input_uvmap->locx = node->locx - 200.0f;
input_uvmap->locy = node->locy;
NodeShaderUVMap *storage = (NodeShaderUVMap *)input_uvmap->storage;
@@ -590,31 +590,31 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
mesh->totcol = group->materials.size();
mesh->mvert = (MVert *)CustomData_add_layer(
- &mesh->vdata, CD_MVERT, CD_CALLOC, NULL, mesh->totvert);
+ &mesh->vdata, CD_MVERT, CD_CALLOC, nullptr, mesh->totvert);
mesh->medge = (MEdge *)CustomData_add_layer(
- &mesh->edata, CD_MEDGE, CD_CALLOC, NULL, mesh->totedge);
+ &mesh->edata, CD_MEDGE, CD_CALLOC, nullptr, mesh->totedge);
mesh->mpoly = (MPoly *)CustomData_add_layer(
- &mesh->pdata, CD_MPOLY, CD_CALLOC, NULL, mesh->totpoly);
+ &mesh->pdata, CD_MPOLY, CD_CALLOC, nullptr, mesh->totpoly);
mesh->mloop = (MLoop *)CustomData_add_layer(
- &mesh->ldata, CD_MLOOP, CD_CALLOC, NULL, mesh->totloop);
+ &mesh->ldata, CD_MLOOP, CD_CALLOC, nullptr, mesh->totloop);
MVert *vertices = mesh->mvert;
MEdge *edges = mesh->medge;
MPoly *polys = mesh->mpoly;
MLoop *loops = mesh->mloop;
- MLoopUV *loopsuv[2] = {NULL};
+ MLoopUV *loopsuv[2] = {nullptr};
if (hasTex) {
// First UV layer
CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPUV, CD_CALLOC, NULL, mesh->totloop, uvNames[0]);
+ &mesh->ldata, CD_MLOOPUV, CD_CALLOC, nullptr, mesh->totloop, uvNames[0]);
CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 0);
BKE_mesh_update_customdata_pointers(mesh, true);
loopsuv[0] = mesh->mloopuv;
// Second UV layer
CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPUV, CD_CALLOC, NULL, mesh->totloop, uvNames[1]);
+ &mesh->ldata, CD_MLOOPUV, CD_CALLOC, nullptr, mesh->totloop, uvNames[1]);
CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 1);
BKE_mesh_update_customdata_pointers(mesh, true);
loopsuv[1] = mesh->mloopuv;
@@ -622,9 +622,9 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
// colors and transparency (the latter represented by grayscale colors)
MLoopCol *colors = (MLoopCol *)CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, mesh->totloop, "Color");
+ &mesh->ldata, CD_MLOOPCOL, CD_CALLOC, nullptr, mesh->totloop, "Color");
MLoopCol *transp = (MLoopCol *)CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, mesh->totloop, "Alpha");
+ &mesh->ldata, CD_MLOOPCOL, CD_CALLOC, nullptr, mesh->totloop, "Alpha");
mesh->mloopcol = colors;
mesh->mat = (Material **)MEM_mallocN(sizeof(Material *) * mesh->totcol, "MaterialList");
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index 2446bfc13dc..65fa193f92f 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -59,7 +59,7 @@ using namespace Freestyle;
#include "DEG_depsgraph_query.h"
-#include "renderpipeline.h"
+#include "pipeline.h"
#include "FRS_freestyle.h"
@@ -72,9 +72,9 @@ struct FreestyleGlobals g_freestyle;
// Freestyle configuration
static bool freestyle_is_initialized = false;
-static Config::Path *pathconfig = NULL;
-static Controller *controller = NULL;
-static AppView *view = NULL;
+static Config::Path *pathconfig = nullptr;
+static Controller *controller = nullptr;
+static AppView *view = nullptr;
// line set buffer for copy & paste
static FreestyleLineSet lineset_buffer;
@@ -89,10 +89,10 @@ static void load_post_callback(struct Main * /*main*/,
}
static bCallbackFuncStore load_post_callback_funcstore = {
- NULL,
- NULL, /* next, prev */
+ nullptr,
+ nullptr, /* next, prev */
load_post_callback, /* func */
- NULL, /* arg */
+ nullptr, /* arg */
0 /* alloc */
};
@@ -111,12 +111,12 @@ void FRS_init()
view = new AppView;
controller->setView(view);
controller->Clear();
- g_freestyle.scene = NULL;
+ g_freestyle.scene = nullptr;
lineset_copied = false;
BKE_callback_add(&load_post_callback_funcstore, BKE_CB_EVT_LOAD_POST);
- freestyle_is_initialized = 1;
+ freestyle_is_initialized = true;
}
void FRS_set_context(bContext *C)
@@ -150,10 +150,10 @@ static void init_view(Render *re)
float thickness = 1.0f;
switch (re->r.line_thickness_mode) {
case R_LINE_THICKNESS_ABSOLUTE:
- thickness = re->r.unit_line_thickness * (re->r.size / 100.f);
+ thickness = re->r.unit_line_thickness * (re->r.size / 100.0f);
break;
case R_LINE_THICKNESS_RELATIVE:
- thickness = height / 480.f;
+ thickness = height / 480.0f;
break;
}
@@ -312,7 +312,7 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
// load mesh
re->i.infostr = TIP_("Freestyle: Mesh loading");
re->stats_draw(re->sdh, &re->i);
- re->i.infostr = NULL;
+ re->i.infostr = nullptr;
if (controller->LoadMesh(
re, view_layer, depsgraph)) { // returns if scene cannot be loaded or if empty
return;
@@ -507,7 +507,7 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
// compute view map
re->i.infostr = TIP_("Freestyle: View map creation");
re->stats_draw(re->sdh, &re->i);
- re->i.infostr = NULL;
+ re->i.infostr = nullptr;
controller->ComputeViewMap();
}
@@ -517,7 +517,7 @@ void FRS_composite_result(Render *re, ViewLayer *view_layer, Render *freestyle_r
float *src, *dest, *pixSrc, *pixDest;
int x, y, rectx, recty;
- if (freestyle_render == NULL || freestyle_render->result == NULL) {
+ if (freestyle_render == nullptr || freestyle_render->result == nullptr) {
return;
}
@@ -676,15 +676,15 @@ void FRS_do_stroke_rendering(Render *re, ViewLayer *view_layer)
// render strokes
re->i.infostr = TIP_("Freestyle: Stroke rendering");
re->stats_draw(re->sdh, &re->i);
- re->i.infostr = NULL;
+ re->i.infostr = nullptr;
g_freestyle.scene = DEG_get_evaluated_scene(depsgraph);
int strokeCount = controller->DrawStrokes();
- Render *freestyle_render = NULL;
+ Render *freestyle_render = nullptr;
if (strokeCount > 0) {
freestyle_render = controller->RenderStrokes(re, true);
}
controller->CloseFile();
- g_freestyle.scene = NULL;
+ g_freestyle.scene = nullptr;
// composite result
if (freestyle_render) {
@@ -762,7 +762,7 @@ void FRS_paste_active_lineset(FreestyleConfig *config)
lineset->exclude_edge_types = lineset_buffer.exclude_edge_types;
if (lineset->group) {
id_us_min(&lineset->group->id);
- lineset->group = NULL;
+ lineset->group = nullptr;
}
if (lineset_buffer.group) {
lineset->group = lineset_buffer.group;
@@ -790,14 +790,14 @@ void FRS_delete_active_lineset(FreestyleConfig *config)
bool FRS_move_active_lineset(FreestyleConfig *config, int direction)
{
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(config);
- return (lineset != NULL) && BLI_listbase_link_move(&config->linesets, lineset, direction);
+ return (lineset != nullptr) && BLI_listbase_link_move(&config->linesets, lineset, direction);
}
// Testing
Material *FRS_create_stroke_material(Main *bmain, struct FreestyleLineStyle *linestyle)
{
- bNodeTree *nt = (linestyle->use_nodes) ? linestyle->nodetree : NULL;
+ bNodeTree *nt = (linestyle->use_nodes) ? linestyle->nodetree : nullptr;
Material *ma = BlenderStrokeRenderer::GetStrokeShader(bmain, nt, true);
ma->id.us = 0;
return ma;
diff --git a/source/blender/freestyle/intern/geometry/Bezier.cpp b/source/blender/freestyle/intern/geometry/Bezier.cpp
index 4ae30ff893c..4eec3d72db9 100644
--- a/source/blender/freestyle/intern/geometry/Bezier.cpp
+++ b/source/blender/freestyle/intern/geometry/Bezier.cpp
@@ -73,8 +73,8 @@ void BezierCurveSegment::Build()
float increment = 1.0 / (float)nvertices;
float t = 0.0f;
for (int i = 0; i <= nvertices; ++i) {
- _Vertices.push_back(Vec2d((x[3] + t * (x[2] + t * (x[1] + t * x[0]))),
- (y[3] + t * (y[2] + t * (y[1] + t * y[0])))));
+ _Vertices.emplace_back((x[3] + t * (x[2] + t * (x[1] + t * x[0]))),
+ (y[3] + t * (y[2] + t * (y[1] + t * y[0]))));
t += increment;
}
}
diff --git a/source/blender/freestyle/intern/geometry/FastGrid.cpp b/source/blender/freestyle/intern/geometry/FastGrid.cpp
index 1e5707690a0..1e0ae06da19 100644
--- a/source/blender/freestyle/intern/geometry/FastGrid.cpp
+++ b/source/blender/freestyle/intern/geometry/FastGrid.cpp
@@ -40,7 +40,7 @@ void FastGrid::clear()
}
}
delete[] _cells;
- _cells = NULL;
+ _cells = nullptr;
_cells_size = 0;
Grid::clear();
diff --git a/source/blender/freestyle/intern/geometry/FitCurve.cpp b/source/blender/freestyle/intern/geometry/FitCurve.cpp
index aeb4902e5b0..5682ccc9298 100644
--- a/source/blender/freestyle/intern/geometry/FitCurve.cpp
+++ b/source/blender/freestyle/intern/geometry/FitCurve.cpp
@@ -493,7 +493,7 @@ void FitCurveWrapper::FitCurve(vector<Vec2d> &data, vector<Vec2d> &oCurve, doubl
// copy results
for (vector<Vector2>::iterator v = _vertices.begin(), vend = _vertices.end(); v != vend; ++v) {
- oCurve.push_back(Vec2d(v->x(), v->y()));
+ oCurve.emplace_back(v->x(), v->y());
}
}
diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp
index 76e63764e4d..b1d0a6c7e2a 100644
--- a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp
+++ b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp
@@ -54,8 +54,7 @@ void GeomCleaner::SortIndexedVertexArray(const float *iVertices,
list<IndexedVertex> indexedVertices;
unsigned i;
for (i = 0; i < iVSize; i += 3) {
- indexedVertices.push_back(
- IndexedVertex(Vec3f(iVertices[i], iVertices[i + 1], iVertices[i + 2]), i / 3));
+ indexedVertices.emplace_back(Vec3f(iVertices[i], iVertices[i + 1], iVertices[i + 2]), i / 3);
}
// q-sort
@@ -99,7 +98,7 @@ void GeomCleaner::CompressIndexedVertexArray(const float *iVertices,
vector<Vec3f> vertices;
unsigned i;
for (i = 0; i < iVSize; i += 3) {
- vertices.push_back(Vec3f(iVertices[i], iVertices[i + 1], iVertices[i + 2]));
+ vertices.emplace_back(iVertices[i], iVertices[i + 1], iVertices[i + 2]);
}
unsigned *mapVertex = new unsigned[iVSize];
@@ -207,7 +206,7 @@ void GeomCleaner::CleanIndexedVertexArray(const float *iVertices,
vector<Vec3f> vertices;
unsigned i;
for (i = 0; i < iVSize; i += 3) {
- vertices.push_back(Vec3f(iVertices[i], iVertices[i + 1], iVertices[i + 2]));
+ vertices.emplace_back(iVertices[i], iVertices[i + 1], iVertices[i + 2]);
}
cleanHashTable ht;
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp
index 925bc3c9f94..51727fd2288 100644
--- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp
+++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp
@@ -21,9 +21,7 @@
#include "GeomUtils.h"
-namespace Freestyle {
-
-namespace GeomUtils {
+namespace Freestyle::GeomUtils {
// This internal procedure is defined below.
bool intersect2dSegPoly(Vec2r *seg, Vec2r *poly, unsigned n);
@@ -846,6 +844,4 @@ inline void fromCoordAToCoordB(const Vec3r &p, Vec3r &q, const real transform[4]
}
}
-} // end of namespace GeomUtils
-
-} /* namespace Freestyle */
+} // namespace Freestyle::GeomUtils
diff --git a/source/blender/freestyle/intern/geometry/Grid.cpp b/source/blender/freestyle/intern/geometry/Grid.cpp
index 46e91197764..fad5a63ea4f 100644
--- a/source/blender/freestyle/intern/geometry/Grid.cpp
+++ b/source/blender/freestyle/intern/geometry/Grid.cpp
@@ -75,7 +75,7 @@ void firstIntersectionGridVisitor::examineOccluder(Polygon3r *occ)
}
}
else {
- occ->userdata2 = 0;
+ occ->userdata2 = nullptr;
}
}
}
@@ -321,11 +321,11 @@ void Grid::castInfiniteRay(const Vec3r &orig,
Polygon3r *Grid::castRayToFindFirstIntersection(
const Vec3r &orig, const Vec3r &dir, double &t, double &u, double &v, unsigned timestamp)
{
- Polygon3r *occluder = 0;
+ Polygon3r *occluder = nullptr;
Vec3r end = Vec3r(orig + FLT_MAX * dir / dir.norm());
bool inter = initInfiniteRay(orig, dir, timestamp);
if (!inter) {
- return 0;
+ return nullptr;
}
firstIntersectionGridVisitor visitor(orig, dir, _cell_size);
castRayInternal(visitor);
diff --git a/source/blender/freestyle/intern/geometry/matrix_util.cpp b/source/blender/freestyle/intern/geometry/matrix_util.cpp
index 9d25a240a63..5b5d9582e8f 100644
--- a/source/blender/freestyle/intern/geometry/matrix_util.cpp
+++ b/source/blender/freestyle/intern/geometry/matrix_util.cpp
@@ -33,11 +33,7 @@
#include "BLI_math.h"
-namespace Freestyle {
-
-namespace OGF {
-
-namespace MatrixUtil {
+namespace Freestyle::OGF::MatrixUtil {
static const double EPS = 0.00001;
static int MAX_ITER = 100;
@@ -149,7 +145,7 @@ void semi_definite_symmetric_eigen(const double *mat, int n, double *eigen_vec,
imv = n * (m - 1);
for (i = 1; i <= n; i++) {
- if ((i != l) && (i != m)) {
+ if (!ELEM(i, l, m)) {
iq = (i * i - i) / 2;
if (i < m) {
@@ -252,8 +248,4 @@ void semi_definite_symmetric_eigen(const double *mat, int n, double *eigen_vec,
//_________________________________________________________
-} // namespace MatrixUtil
-
-} // namespace OGF
-
-} /* namespace Freestyle */
+} // namespace Freestyle::OGF::MatrixUtil
diff --git a/source/blender/freestyle/intern/geometry/matrix_util.h b/source/blender/freestyle/intern/geometry/matrix_util.h
index 996ebc928a1..8a20cb31300 100644
--- a/source/blender/freestyle/intern/geometry/matrix_util.h
+++ b/source/blender/freestyle/intern/geometry/matrix_util.h
@@ -42,16 +42,18 @@ namespace MatrixUtil {
/**
* computes the eigen values and eigen vectors of a semi definite symmetric matrix
*
- * \param mat: The matrix stored in column symmetric storage, i.e.
- * matrix = { m11, m12, m22, m13, m23, m33, m14, m24, m34, m44 ... }
- * size = n(n+1)/2
+ * \param mat: The matrix stored in column symmetric storage, i.e.
+ * <pre>
+ * matrix = { m11, m12, m22, m13, m23, m33, m14, m24, m34, m44 ... }
+ * size = n(n+1)/2
+ * </pre>
*
* \param eigen_vec: (return) = { v1, v2, v3, ..., vn }
- * where vk = vk0, vk1, ..., vkn
- * size = n^2, must be allocated by caller
+ * where `vk = vk0, vk1, ..., vkn`
+ * `size = n^2`, must be allocated by caller.
*
* \param eigen_val: (return) are in decreasing order
- * size = n, must be allocated by caller
+ * `size = n`, must be allocated by caller.
*/
void semi_definite_symmetric_eigen(const double *mat, int n, double *eigen_vec, double *eigen_val);
diff --git a/source/blender/freestyle/intern/geometry/normal_cycle.cpp b/source/blender/freestyle/intern/geometry/normal_cycle.cpp
index d02b5cc2d5b..01d52646eb0 100644
--- a/source/blender/freestyle/intern/geometry/normal_cycle.cpp
+++ b/source/blender/freestyle/intern/geometry/normal_cycle.cpp
@@ -32,9 +32,7 @@
#include "normal_cycle.h"
#include "matrix_util.h"
-namespace Freestyle {
-
-namespace OGF {
+namespace Freestyle::OGF {
//_________________________________________________________
@@ -88,6 +86,4 @@ void NormalCycle::end()
//_________________________________________________________
-} // namespace OGF
-
-} /* namespace Freestyle */
+} // namespace Freestyle::OGF
diff --git a/source/blender/freestyle/intern/image/GaussianFilter.cpp b/source/blender/freestyle/intern/image/GaussianFilter.cpp
index ca476bee0d3..3bbe86ee986 100644
--- a/source/blender/freestyle/intern/image/GaussianFilter.cpp
+++ b/source/blender/freestyle/intern/image/GaussianFilter.cpp
@@ -28,7 +28,7 @@ namespace Freestyle {
GaussianFilter::GaussianFilter(float iSigma)
{
_sigma = iSigma;
- _mask = 0;
+ _mask = nullptr;
computeMask();
}
diff --git a/source/blender/freestyle/intern/image/ImagePyramid.cpp b/source/blender/freestyle/intern/image/ImagePyramid.cpp
index 2f12081eb76..b6779669a15 100644
--- a/source/blender/freestyle/intern/image/ImagePyramid.cpp
+++ b/source/blender/freestyle/intern/image/ImagePyramid.cpp
@@ -124,14 +124,12 @@ int ImagePyramid::height(int level)
}
GaussianPyramid::GaussianPyramid(const GrayImage &level0, unsigned nbLevels, float iSigma)
- : ImagePyramid()
{
_sigma = iSigma;
BuildPyramid(level0, nbLevels);
}
GaussianPyramid::GaussianPyramid(GrayImage *level0, unsigned nbLevels, float iSigma)
- : ImagePyramid()
{
_sigma = iSigma;
BuildPyramid(level0, nbLevels);
diff --git a/source/blender/freestyle/intern/image/ImagePyramid.h b/source/blender/freestyle/intern/image/ImagePyramid.h
index ee8bf69aa10..3b4e5eda52a 100644
--- a/source/blender/freestyle/intern/image/ImagePyramid.h
+++ b/source/blender/freestyle/intern/image/ImagePyramid.h
@@ -87,7 +87,7 @@ class GaussianPyramid : public ImagePyramid {
float _sigma;
public:
- GaussianPyramid(float iSigma = 1.f) : ImagePyramid()
+ GaussianPyramid(float iSigma = 1.0f) : ImagePyramid()
{
_sigma = iSigma;
}
diff --git a/source/blender/freestyle/intern/python/BPy_BBox.cpp b/source/blender/freestyle/intern/python/BPy_BBox.cpp
index 17a0e53876e..d66a74bc83f 100644
--- a/source/blender/freestyle/intern/python/BPy_BBox.cpp
+++ b/source/blender/freestyle/intern/python/BPy_BBox.cpp
@@ -29,7 +29,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int BBox_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -53,7 +53,7 @@ PyDoc_STRVAR(BBox_doc,
static int BBox_init(BPy_BBox *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -76,42 +76,46 @@ static PyObject *BBox_repr(BPy_BBox *self)
/*-----------------------BPy_BBox type definition ------------------------------*/
PyTypeObject BBox_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "BBox", /* tp_name */
+ PyVarObject_HEAD_INIT(nullptr, 0) "BBox", /* tp_name */
sizeof(BPy_BBox), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)BBox_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
(reprfunc)BBox_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
BBox_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)BBox_init, /* tp_init */
- 0, /* tp_alloc */
+ nullptr, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
index 42b13bf4920..2359d79f7d0 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
@@ -32,7 +32,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int BinaryPredicate0D_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -72,7 +72,7 @@ static char BinaryPredicate0D___doc__[] =
static int BinaryPredicate0D___init__(BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -98,7 +98,7 @@ static PyObject *BinaryPredicate0D___call__(BPy_BinaryPredicate0D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"inter1", "inter2", NULL};
+ static const char *kwlist[] = {"inter1", "inter2", nullptr};
BPy_Interface0D *obj1, *obj2;
if (!PyArg_ParseTupleAndKeywords(args,
@@ -109,18 +109,18 @@ static PyObject *BinaryPredicate0D___call__(BPy_BinaryPredicate0D *self,
&obj1,
&Interface0D_Type,
&obj2)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->bp0D)) == typeid(BinaryPredicate0D)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->bp0D->operator()(*(obj1->if0D), *(obj2->if0D)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return PyBool_from_bool(self->bp0D->result);
}
@@ -138,50 +138,58 @@ static PyObject *BinaryPredicate0D_name_get(BPy_BinaryPredicate0D *self, void *U
}
static PyGetSetDef BPy_BinaryPredicate0D_getseters[] = {
- {"name", (getter)BinaryPredicate0D_name_get, (setter)NULL, BinaryPredicate0D_name_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ {"name",
+ (getter)BinaryPredicate0D_name_get,
+ (setter) nullptr,
+ BinaryPredicate0D_name_doc,
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_BinaryPredicate0D type definition ------------------------------*/
PyTypeObject BinaryPredicate0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "BinaryPredicate0D", /* tp_name */
- sizeof(BPy_BinaryPredicate0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)BinaryPredicate0D___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)BinaryPredicate0D___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)BinaryPredicate0D___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- BinaryPredicate0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_BinaryPredicate0D_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)BinaryPredicate0D___init__, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "BinaryPredicate0D", /* tp_name */
+ sizeof(BPy_BinaryPredicate0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)BinaryPredicate0D___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)BinaryPredicate0D___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)BinaryPredicate0D___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ BinaryPredicate0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_BinaryPredicate0D_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)BinaryPredicate0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
index ed991695739..7d554e0abe1 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
@@ -38,7 +38,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int BinaryPredicate1D_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -108,7 +108,7 @@ static char BinaryPredicate1D___doc__[] =
static int BinaryPredicate1D___init__(BPy_BinaryPredicate1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -133,7 +133,7 @@ static PyObject *BinaryPredicate1D___call__(BPy_BinaryPredicate1D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"inter1", "inter2", NULL};
+ static const char *kwlist[] = {"inter1", "inter2", nullptr};
BPy_Interface1D *obj1, *obj2;
if (!PyArg_ParseTupleAndKeywords(args,
@@ -144,18 +144,18 @@ static PyObject *BinaryPredicate1D___call__(BPy_BinaryPredicate1D *self,
&obj1,
&Interface1D_Type,
&obj2)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->bp1D)) == typeid(BinaryPredicate1D)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->bp1D->operator()(*(obj1->if1D), *(obj2->if1D)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return PyBool_from_bool(self->bp1D->result);
}
@@ -173,49 +173,57 @@ static PyObject *BinaryPredicate1D_name_get(BPy_BinaryPredicate1D *self, void *U
}
static PyGetSetDef BPy_BinaryPredicate1D_getseters[] = {
- {"name", (getter)BinaryPredicate1D_name_get, (setter)NULL, BinaryPredicate1D_name_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ {"name",
+ (getter)BinaryPredicate1D_name_get,
+ (setter) nullptr,
+ BinaryPredicate1D_name_doc,
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_BinaryPredicate1D type definition ------------------------------*/
PyTypeObject BinaryPredicate1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "BinaryPredicate1D", /* tp_name */
- sizeof(BPy_BinaryPredicate1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)BinaryPredicate1D___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)BinaryPredicate1D___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)BinaryPredicate1D___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- BinaryPredicate1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_BinaryPredicate1D_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)BinaryPredicate1D___init__, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "BinaryPredicate1D", /* tp_name */
+ sizeof(BPy_BinaryPredicate1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)BinaryPredicate1D___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)BinaryPredicate1D___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)BinaryPredicate1D___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ BinaryPredicate1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_BinaryPredicate1D_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)BinaryPredicate1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
index e838bade64a..e01d09bfe21 100644
--- a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
@@ -110,14 +110,14 @@ static char ContextFunctions_load_map___doc__[] =
static PyObject *ContextFunctions_load_map(PyObject * /*self*/, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"file_name", "map_name", "num_levels", "sigma", NULL};
+ static const char *kwlist[] = {"file_name", "map_name", "num_levels", "sigma", nullptr};
char *fileName, *mapName;
unsigned nbLevels = 4;
float sigma = 1.0;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "ss|If", (char **)kwlist, &fileName, &mapName, &nbLevels, &sigma)) {
- return NULL;
+ return nullptr;
}
ContextFunctions::LoadMapCF(fileName, mapName, nbLevels, sigma);
Py_RETURN_NONE;
@@ -146,14 +146,14 @@ static PyObject *ContextFunctions_read_map_pixel(PyObject * /*self*/,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"map_name", "level", "x", "y", NULL};
+ static const char *kwlist[] = {"map_name", "level", "x", "y", nullptr};
char *mapName;
int level;
unsigned x, y;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "siII", (char **)kwlist, &mapName, &level, &x, &y)) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(ContextFunctions::ReadMapPixelCF(mapName, level, x, y));
}
@@ -179,12 +179,12 @@ static PyObject *ContextFunctions_read_complete_view_map_pixel(PyObject * /*self
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"level", "x", "y", NULL};
+ static const char *kwlist[] = {"level", "x", "y", nullptr};
int level;
unsigned x, y;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "iII", (char **)kwlist, &level, &x, &y)) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(ContextFunctions::ReadCompleteViewMapPixelCF(level, x, y));
}
@@ -213,13 +213,13 @@ static PyObject *ContextFunctions_read_directional_view_map_pixel(PyObject * /*s
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"orientation", "level", "x", "y", NULL};
+ static const char *kwlist[] = {"orientation", "level", "x", "y", nullptr};
int orientation, level;
unsigned x, y;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "iiII", (char **)kwlist, &orientation, &level, &x, &y)) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(
ContextFunctions::ReadDirectionalViewMapPixelCF(orientation, level, x, y));
@@ -285,7 +285,7 @@ static PyMethodDef module_functions[] = {
(PyCFunction)ContextFunctions_get_selected_fedge,
METH_NOARGS,
ContextFunctions_get_selected_fedge___doc__},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*-----------------------ContextFunctions module definition--------------------------------*/
@@ -304,12 +304,12 @@ int ContextFunctions_Init(PyObject *module)
{
PyObject *m;
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
m = PyModule_Create(&module_definition);
- if (m == NULL) {
+ if (m == nullptr) {
return -1;
}
Py_INCREF(m);
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp
index 03f9760344b..f1d7a242a93 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp
@@ -77,7 +77,7 @@ PyObject *Vector_from_Vec2f(Vec2f &vec)
float vec_data[2]; // because vec->_coord is protected
vec_data[0] = vec.x();
vec_data[1] = vec.y();
- return Vector_CreatePyObject(vec_data, 2, NULL);
+ return Vector_CreatePyObject(vec_data, 2, nullptr);
}
PyObject *Vector_from_Vec3f(Vec3f &vec)
@@ -86,7 +86,7 @@ PyObject *Vector_from_Vec3f(Vec3f &vec)
vec_data[0] = vec.x();
vec_data[1] = vec.y();
vec_data[2] = vec.z();
- return Vector_CreatePyObject(vec_data, 3, NULL);
+ return Vector_CreatePyObject(vec_data, 3, nullptr);
}
PyObject *Vector_from_Vec3r(Vec3r &vec)
@@ -95,12 +95,12 @@ PyObject *Vector_from_Vec3r(Vec3r &vec)
vec_data[0] = vec.x();
vec_data[1] = vec.y();
vec_data[2] = vec.z();
- return Vector_CreatePyObject(vec_data, 3, NULL);
+ return Vector_CreatePyObject(vec_data, 3, nullptr);
}
PyObject *BPy_Id_from_Id(Id &id)
{
- PyObject *py_id = Id_Type.tp_new(&Id_Type, 0, 0);
+ PyObject *py_id = Id_Type.tp_new(&Id_Type, nullptr, nullptr);
((BPy_Id *)py_id)->id = new Id(id.getFirst(), id.getSecond());
return py_id;
}
@@ -130,7 +130,7 @@ PyObject *Any_BPy_Interface0D_from_Interface0D(Interface0D &if0D)
}
string msg("unexpected type: " + if0D.getExactTypeName());
PyErr_SetString(PyExc_TypeError, msg.c_str());
- return NULL;
+ return nullptr;
}
PyObject *Any_BPy_Interface1D_from_Interface1D(Interface1D &if1D)
@@ -158,7 +158,7 @@ PyObject *Any_BPy_Interface1D_from_Interface1D(Interface1D &if1D)
}
string msg("unexpected type: " + if1D.getExactTypeName());
PyErr_SetString(PyExc_TypeError, msg.c_str());
- return NULL;
+ return nullptr;
}
PyObject *Any_BPy_FEdge_from_FEdge(FEdge &fe)
@@ -174,7 +174,7 @@ PyObject *Any_BPy_FEdge_from_FEdge(FEdge &fe)
}
string msg("unexpected type: " + fe.getExactTypeName());
PyErr_SetString(PyExc_TypeError, msg.c_str());
- return NULL;
+ return nullptr;
}
PyObject *Any_BPy_ViewVertex_from_ViewVertex(ViewVertex &vv)
@@ -190,12 +190,12 @@ PyObject *Any_BPy_ViewVertex_from_ViewVertex(ViewVertex &vv)
}
string msg("unexpected type: " + vv.getExactTypeName());
PyErr_SetString(PyExc_TypeError, msg.c_str());
- return NULL;
+ return nullptr;
}
PyObject *BPy_Interface0D_from_Interface0D(Interface0D &if0D)
{
- PyObject *py_if0D = Interface0D_Type.tp_new(&Interface0D_Type, 0, 0);
+ PyObject *py_if0D = Interface0D_Type.tp_new(&Interface0D_Type, nullptr, nullptr);
((BPy_Interface0D *)py_if0D)->if0D = &if0D;
((BPy_Interface0D *)py_if0D)->borrowed = true;
return py_if0D;
@@ -203,7 +203,7 @@ PyObject *BPy_Interface0D_from_Interface0D(Interface0D &if0D)
PyObject *BPy_Interface1D_from_Interface1D(Interface1D &if1D)
{
- PyObject *py_if1D = Interface1D_Type.tp_new(&Interface1D_Type, 0, 0);
+ PyObject *py_if1D = Interface1D_Type.tp_new(&Interface1D_Type, nullptr, nullptr);
((BPy_Interface1D *)py_if1D)->if1D = &if1D;
((BPy_Interface1D *)py_if1D)->borrowed = true;
return py_if1D;
@@ -211,7 +211,7 @@ PyObject *BPy_Interface1D_from_Interface1D(Interface1D &if1D)
PyObject *BPy_SVertex_from_SVertex(SVertex &sv)
{
- PyObject *py_sv = SVertex_Type.tp_new(&SVertex_Type, 0, 0);
+ PyObject *py_sv = SVertex_Type.tp_new(&SVertex_Type, nullptr, nullptr);
((BPy_SVertex *)py_sv)->sv = &sv;
((BPy_SVertex *)py_sv)->py_if0D.if0D = ((BPy_SVertex *)py_sv)->sv;
((BPy_SVertex *)py_sv)->py_if0D.borrowed = true;
@@ -220,7 +220,7 @@ PyObject *BPy_SVertex_from_SVertex(SVertex &sv)
PyObject *BPy_FEdgeSharp_from_FEdgeSharp(FEdgeSharp &fes)
{
- PyObject *py_fe = FEdgeSharp_Type.tp_new(&FEdgeSharp_Type, 0, 0);
+ PyObject *py_fe = FEdgeSharp_Type.tp_new(&FEdgeSharp_Type, nullptr, nullptr);
((BPy_FEdgeSharp *)py_fe)->fes = &fes;
((BPy_FEdgeSharp *)py_fe)->py_fe.fe = ((BPy_FEdgeSharp *)py_fe)->fes;
((BPy_FEdgeSharp *)py_fe)->py_fe.py_if1D.if1D = ((BPy_FEdgeSharp *)py_fe)->fes;
@@ -230,7 +230,7 @@ PyObject *BPy_FEdgeSharp_from_FEdgeSharp(FEdgeSharp &fes)
PyObject *BPy_FEdgeSmooth_from_FEdgeSmooth(FEdgeSmooth &fes)
{
- PyObject *py_fe = FEdgeSmooth_Type.tp_new(&FEdgeSmooth_Type, 0, 0);
+ PyObject *py_fe = FEdgeSmooth_Type.tp_new(&FEdgeSmooth_Type, nullptr, nullptr);
((BPy_FEdgeSmooth *)py_fe)->fes = &fes;
((BPy_FEdgeSmooth *)py_fe)->py_fe.fe = ((BPy_FEdgeSmooth *)py_fe)->fes;
((BPy_FEdgeSmooth *)py_fe)->py_fe.py_if1D.if1D = ((BPy_FEdgeSmooth *)py_fe)->fes;
@@ -240,7 +240,7 @@ PyObject *BPy_FEdgeSmooth_from_FEdgeSmooth(FEdgeSmooth &fes)
PyObject *BPy_FEdge_from_FEdge(FEdge &fe)
{
- PyObject *py_fe = FEdge_Type.tp_new(&FEdge_Type, 0, 0);
+ PyObject *py_fe = FEdge_Type.tp_new(&FEdge_Type, nullptr, nullptr);
((BPy_FEdge *)py_fe)->fe = &fe;
((BPy_FEdge *)py_fe)->py_if1D.if1D = ((BPy_FEdge *)py_fe)->fe;
((BPy_FEdge *)py_fe)->py_if1D.borrowed = true;
@@ -251,14 +251,14 @@ PyObject *BPy_Nature_from_Nature(unsigned short n)
{
PyObject *args = PyTuple_New(1);
PyTuple_SET_ITEM(args, 0, PyLong_FromLong(n));
- PyObject *py_n = Nature_Type.tp_new(&Nature_Type, args, NULL);
+ PyObject *py_n = Nature_Type.tp_new(&Nature_Type, args, nullptr);
Py_DECREF(args);
return py_n;
}
PyObject *BPy_Stroke_from_Stroke(Stroke &s)
{
- PyObject *py_s = Stroke_Type.tp_new(&Stroke_Type, 0, 0);
+ PyObject *py_s = Stroke_Type.tp_new(&Stroke_Type, nullptr, nullptr);
((BPy_Stroke *)py_s)->s = &s;
((BPy_Stroke *)py_s)->py_if1D.if1D = ((BPy_Stroke *)py_s)->s;
((BPy_Stroke *)py_s)->py_if1D.borrowed = true;
@@ -267,7 +267,7 @@ PyObject *BPy_Stroke_from_Stroke(Stroke &s)
PyObject *BPy_StrokeAttribute_from_StrokeAttribute(StrokeAttribute &sa)
{
- PyObject *py_sa = StrokeAttribute_Type.tp_new(&StrokeAttribute_Type, 0, 0);
+ PyObject *py_sa = StrokeAttribute_Type.tp_new(&StrokeAttribute_Type, nullptr, nullptr);
((BPy_StrokeAttribute *)py_sa)->sa = &sa;
((BPy_StrokeAttribute *)py_sa)->borrowed = true;
return py_sa;
@@ -277,14 +277,14 @@ PyObject *BPy_MediumType_from_MediumType(Stroke::MediumType n)
{
PyObject *args = PyTuple_New(1);
PyTuple_SET_ITEM(args, 0, PyLong_FromLong(n));
- PyObject *py_mt = MediumType_Type.tp_new(&MediumType_Type, args, NULL);
+ PyObject *py_mt = MediumType_Type.tp_new(&MediumType_Type, args, nullptr);
Py_DECREF(args);
return py_mt;
}
PyObject *BPy_StrokeVertex_from_StrokeVertex(StrokeVertex &sv)
{
- PyObject *py_sv = StrokeVertex_Type.tp_new(&StrokeVertex_Type, 0, 0);
+ PyObject *py_sv = StrokeVertex_Type.tp_new(&StrokeVertex_Type, nullptr, nullptr);
((BPy_StrokeVertex *)py_sv)->sv = &sv;
((BPy_StrokeVertex *)py_sv)->py_cp.cp = ((BPy_StrokeVertex *)py_sv)->sv;
((BPy_StrokeVertex *)py_sv)->py_cp.py_if0D.if0D = ((BPy_StrokeVertex *)py_sv)->sv;
@@ -294,7 +294,7 @@ PyObject *BPy_StrokeVertex_from_StrokeVertex(StrokeVertex &sv)
PyObject *BPy_ViewVertex_from_ViewVertex(ViewVertex &vv)
{
- PyObject *py_vv = ViewVertex_Type.tp_new(&ViewVertex_Type, 0, 0);
+ PyObject *py_vv = ViewVertex_Type.tp_new(&ViewVertex_Type, nullptr, nullptr);
((BPy_ViewVertex *)py_vv)->vv = &vv;
((BPy_ViewVertex *)py_vv)->py_if0D.if0D = ((BPy_ViewVertex *)py_vv)->vv;
((BPy_ViewVertex *)py_vv)->py_if0D.borrowed = true;
@@ -303,7 +303,7 @@ PyObject *BPy_ViewVertex_from_ViewVertex(ViewVertex &vv)
PyObject *BPy_NonTVertex_from_NonTVertex(NonTVertex &ntv)
{
- PyObject *py_ntv = NonTVertex_Type.tp_new(&NonTVertex_Type, 0, 0);
+ PyObject *py_ntv = NonTVertex_Type.tp_new(&NonTVertex_Type, nullptr, nullptr);
((BPy_NonTVertex *)py_ntv)->ntv = &ntv;
((BPy_NonTVertex *)py_ntv)->py_vv.vv = ((BPy_NonTVertex *)py_ntv)->ntv;
((BPy_NonTVertex *)py_ntv)->py_vv.py_if0D.if0D = ((BPy_NonTVertex *)py_ntv)->ntv;
@@ -313,7 +313,7 @@ PyObject *BPy_NonTVertex_from_NonTVertex(NonTVertex &ntv)
PyObject *BPy_TVertex_from_TVertex(TVertex &tv)
{
- PyObject *py_tv = TVertex_Type.tp_new(&TVertex_Type, 0, 0);
+ PyObject *py_tv = TVertex_Type.tp_new(&TVertex_Type, nullptr, nullptr);
((BPy_TVertex *)py_tv)->tv = &tv;
((BPy_TVertex *)py_tv)->py_vv.vv = ((BPy_TVertex *)py_tv)->tv;
((BPy_TVertex *)py_tv)->py_vv.py_if0D.if0D = ((BPy_TVertex *)py_tv)->tv;
@@ -323,14 +323,14 @@ PyObject *BPy_TVertex_from_TVertex(TVertex &tv)
PyObject *BPy_BBox_from_BBox(const BBox<Vec3r> &bb)
{
- PyObject *py_bb = BBox_Type.tp_new(&BBox_Type, 0, 0);
+ PyObject *py_bb = BBox_Type.tp_new(&BBox_Type, nullptr, nullptr);
((BPy_BBox *)py_bb)->bb = new BBox<Vec3r>(bb);
return py_bb;
}
PyObject *BPy_ViewEdge_from_ViewEdge(ViewEdge &ve)
{
- PyObject *py_ve = ViewEdge_Type.tp_new(&ViewEdge_Type, 0, 0);
+ PyObject *py_ve = ViewEdge_Type.tp_new(&ViewEdge_Type, nullptr, nullptr);
((BPy_ViewEdge *)py_ve)->ve = &ve;
((BPy_ViewEdge *)py_ve)->py_if1D.if1D = ((BPy_ViewEdge *)py_ve)->ve;
((BPy_ViewEdge *)py_ve)->py_if1D.borrowed = true;
@@ -339,7 +339,7 @@ PyObject *BPy_ViewEdge_from_ViewEdge(ViewEdge &ve)
PyObject *BPy_Chain_from_Chain(Chain &c)
{
- PyObject *py_c = Chain_Type.tp_new(&Chain_Type, 0, 0);
+ PyObject *py_c = Chain_Type.tp_new(&Chain_Type, nullptr, nullptr);
((BPy_Chain *)py_c)->c = &c;
((BPy_Chain *)py_c)->py_c.c = ((BPy_Chain *)py_c)->c;
((BPy_Chain *)py_c)->py_c.py_if1D.if1D = ((BPy_Chain *)py_c)->c;
@@ -349,7 +349,7 @@ PyObject *BPy_Chain_from_Chain(Chain &c)
PyObject *BPy_SShape_from_SShape(SShape &ss)
{
- PyObject *py_ss = SShape_Type.tp_new(&SShape_Type, 0, 0);
+ PyObject *py_ss = SShape_Type.tp_new(&SShape_Type, nullptr, nullptr);
((BPy_SShape *)py_ss)->ss = &ss;
((BPy_SShape *)py_ss)->borrowed = true;
return py_ss;
@@ -357,16 +357,16 @@ PyObject *BPy_SShape_from_SShape(SShape &ss)
PyObject *BPy_ViewShape_from_ViewShape(ViewShape &vs)
{
- PyObject *py_vs = ViewShape_Type.tp_new(&ViewShape_Type, 0, 0);
+ PyObject *py_vs = ViewShape_Type.tp_new(&ViewShape_Type, nullptr, nullptr);
((BPy_ViewShape *)py_vs)->vs = &vs;
((BPy_ViewShape *)py_vs)->borrowed = true;
- ((BPy_ViewShape *)py_vs)->py_ss = NULL;
+ ((BPy_ViewShape *)py_vs)->py_ss = nullptr;
return py_vs;
}
PyObject *BPy_FrsMaterial_from_FrsMaterial(const FrsMaterial &m)
{
- PyObject *py_m = FrsMaterial_Type.tp_new(&FrsMaterial_Type, 0, 0);
+ PyObject *py_m = FrsMaterial_Type.tp_new(&FrsMaterial_Type, nullptr, nullptr);
((BPy_FrsMaterial *)py_m)->m = new FrsMaterial(m);
return py_m;
}
@@ -375,14 +375,14 @@ PyObject *BPy_IntegrationType_from_IntegrationType(IntegrationType i)
{
PyObject *args = PyTuple_New(1);
PyTuple_SET_ITEM(args, 0, PyLong_FromLong(i));
- PyObject *py_it = IntegrationType_Type.tp_new(&IntegrationType_Type, args, NULL);
+ PyObject *py_it = IntegrationType_Type.tp_new(&IntegrationType_Type, args, nullptr);
Py_DECREF(args);
return py_it;
}
PyObject *BPy_CurvePoint_from_CurvePoint(CurvePoint &cp)
{
- PyObject *py_cp = CurvePoint_Type.tp_new(&CurvePoint_Type, 0, 0);
+ PyObject *py_cp = CurvePoint_Type.tp_new(&CurvePoint_Type, nullptr, nullptr);
// CurvePointIterator::operator*() returns a reference of a class data
// member whose value is mutable upon iteration over different CurvePoints.
// It is likely that such a mutable reference is passed to this function,
@@ -408,7 +408,7 @@ PyObject *BPy_directedViewEdge_from_directedViewEdge(ViewVertex::directedViewEdg
PyObject *BPy_AdjacencyIterator_from_AdjacencyIterator(AdjacencyIterator &a_it)
{
- PyObject *py_a_it = AdjacencyIterator_Type.tp_new(&AdjacencyIterator_Type, 0, 0);
+ PyObject *py_a_it = AdjacencyIterator_Type.tp_new(&AdjacencyIterator_Type, nullptr, nullptr);
((BPy_AdjacencyIterator *)py_a_it)->a_it = new AdjacencyIterator(a_it);
((BPy_AdjacencyIterator *)py_a_it)->py_it.it = ((BPy_AdjacencyIterator *)py_a_it)->a_it;
((BPy_AdjacencyIterator *)py_a_it)->at_start = true;
@@ -418,7 +418,8 @@ PyObject *BPy_AdjacencyIterator_from_AdjacencyIterator(AdjacencyIterator &a_it)
PyObject *BPy_Interface0DIterator_from_Interface0DIterator(Interface0DIterator &if0D_it,
bool reversed)
{
- PyObject *py_if0D_it = Interface0DIterator_Type.tp_new(&Interface0DIterator_Type, 0, 0);
+ PyObject *py_if0D_it = Interface0DIterator_Type.tp_new(
+ &Interface0DIterator_Type, nullptr, nullptr);
((BPy_Interface0DIterator *)py_if0D_it)->if0D_it = new Interface0DIterator(if0D_it);
((BPy_Interface0DIterator *)py_if0D_it)->py_it.it =
((BPy_Interface0DIterator *)py_if0D_it)->if0D_it;
@@ -429,7 +430,7 @@ PyObject *BPy_Interface0DIterator_from_Interface0DIterator(Interface0DIterator &
PyObject *BPy_CurvePointIterator_from_CurvePointIterator(CurveInternal::CurvePointIterator &cp_it)
{
- PyObject *py_cp_it = CurvePointIterator_Type.tp_new(&CurvePointIterator_Type, 0, 0);
+ PyObject *py_cp_it = CurvePointIterator_Type.tp_new(&CurvePointIterator_Type, nullptr, nullptr);
((BPy_CurvePointIterator *)py_cp_it)->cp_it = new CurveInternal::CurvePointIterator(cp_it);
((BPy_CurvePointIterator *)py_cp_it)->py_it.it = ((BPy_CurvePointIterator *)py_cp_it)->cp_it;
return py_cp_it;
@@ -438,7 +439,8 @@ PyObject *BPy_CurvePointIterator_from_CurvePointIterator(CurveInternal::CurvePoi
PyObject *BPy_StrokeVertexIterator_from_StrokeVertexIterator(
StrokeInternal::StrokeVertexIterator &sv_it, bool reversed)
{
- PyObject *py_sv_it = StrokeVertexIterator_Type.tp_new(&StrokeVertexIterator_Type, 0, 0);
+ PyObject *py_sv_it = StrokeVertexIterator_Type.tp_new(
+ &StrokeVertexIterator_Type, nullptr, nullptr);
((BPy_StrokeVertexIterator *)py_sv_it)->sv_it = new StrokeInternal::StrokeVertexIterator(sv_it);
((BPy_StrokeVertexIterator *)py_sv_it)->py_it.it = ((BPy_StrokeVertexIterator *)py_sv_it)->sv_it;
((BPy_StrokeVertexIterator *)py_sv_it)->at_start = true;
@@ -448,7 +450,7 @@ PyObject *BPy_StrokeVertexIterator_from_StrokeVertexIterator(
PyObject *BPy_SVertexIterator_from_SVertexIterator(ViewEdgeInternal::SVertexIterator &sv_it)
{
- PyObject *py_sv_it = SVertexIterator_Type.tp_new(&SVertexIterator_Type, 0, 0);
+ PyObject *py_sv_it = SVertexIterator_Type.tp_new(&SVertexIterator_Type, nullptr, nullptr);
((BPy_SVertexIterator *)py_sv_it)->sv_it = new ViewEdgeInternal::SVertexIterator(sv_it);
((BPy_SVertexIterator *)py_sv_it)->py_it.it = ((BPy_SVertexIterator *)py_sv_it)->sv_it;
return py_sv_it;
@@ -457,7 +459,8 @@ PyObject *BPy_SVertexIterator_from_SVertexIterator(ViewEdgeInternal::SVertexIter
PyObject *BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator(
ViewVertexInternal::orientedViewEdgeIterator &ove_it, bool reversed)
{
- PyObject *py_ove_it = orientedViewEdgeIterator_Type.tp_new(&orientedViewEdgeIterator_Type, 0, 0);
+ PyObject *py_ove_it = orientedViewEdgeIterator_Type.tp_new(
+ &orientedViewEdgeIterator_Type, nullptr, nullptr);
((BPy_orientedViewEdgeIterator *)py_ove_it)->ove_it =
new ViewVertexInternal::orientedViewEdgeIterator(ove_it);
((BPy_orientedViewEdgeIterator *)py_ove_it)->py_it.it =
@@ -469,7 +472,7 @@ PyObject *BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator(
PyObject *BPy_ViewEdgeIterator_from_ViewEdgeIterator(ViewEdgeInternal::ViewEdgeIterator &ve_it)
{
- PyObject *py_ve_it = ViewEdgeIterator_Type.tp_new(&ViewEdgeIterator_Type, 0, 0);
+ PyObject *py_ve_it = ViewEdgeIterator_Type.tp_new(&ViewEdgeIterator_Type, nullptr, nullptr);
((BPy_ViewEdgeIterator *)py_ve_it)->ve_it = new ViewEdgeInternal::ViewEdgeIterator(ve_it);
((BPy_ViewEdgeIterator *)py_ve_it)->py_it.it = ((BPy_ViewEdgeIterator *)py_ve_it)->ve_it;
return py_ve_it;
@@ -477,7 +480,7 @@ PyObject *BPy_ViewEdgeIterator_from_ViewEdgeIterator(ViewEdgeInternal::ViewEdgeI
PyObject *BPy_ChainingIterator_from_ChainingIterator(ChainingIterator &c_it)
{
- PyObject *py_c_it = ChainingIterator_Type.tp_new(&ChainingIterator_Type, 0, 0);
+ PyObject *py_c_it = ChainingIterator_Type.tp_new(&ChainingIterator_Type, nullptr, nullptr);
((BPy_ChainingIterator *)py_c_it)->c_it = new ChainingIterator(c_it);
((BPy_ChainingIterator *)py_c_it)->py_ve_it.py_it.it = ((BPy_ChainingIterator *)py_c_it)->c_it;
return py_c_it;
@@ -485,7 +488,8 @@ PyObject *BPy_ChainingIterator_from_ChainingIterator(ChainingIterator &c_it)
PyObject *BPy_ChainPredicateIterator_from_ChainPredicateIterator(ChainPredicateIterator &cp_it)
{
- PyObject *py_cp_it = ChainPredicateIterator_Type.tp_new(&ChainPredicateIterator_Type, 0, 0);
+ PyObject *py_cp_it = ChainPredicateIterator_Type.tp_new(
+ &ChainPredicateIterator_Type, nullptr, nullptr);
((BPy_ChainPredicateIterator *)py_cp_it)->cp_it = new ChainPredicateIterator(cp_it);
((BPy_ChainPredicateIterator *)py_cp_it)->py_c_it.py_ve_it.py_it.it =
((BPy_ChainPredicateIterator *)py_cp_it)->cp_it;
@@ -494,7 +498,8 @@ PyObject *BPy_ChainPredicateIterator_from_ChainPredicateIterator(ChainPredicateI
PyObject *BPy_ChainSilhouetteIterator_from_ChainSilhouetteIterator(ChainSilhouetteIterator &cs_it)
{
- PyObject *py_cs_it = ChainSilhouetteIterator_Type.tp_new(&ChainSilhouetteIterator_Type, 0, 0);
+ PyObject *py_cs_it = ChainSilhouetteIterator_Type.tp_new(
+ &ChainSilhouetteIterator_Type, nullptr, nullptr);
((BPy_ChainSilhouetteIterator *)py_cs_it)->cs_it = new ChainSilhouetteIterator(cs_it);
((BPy_ChainSilhouetteIterator *)py_cs_it)->py_c_it.py_ve_it.py_it.it =
((BPy_ChainSilhouetteIterator *)py_cs_it)->cs_it;
@@ -648,10 +653,10 @@ static bool float_array_from_PyList(PyObject *obj, float *v, int n)
v[i] = PyFloat_AsDouble(PyList_GET_ITEM(obj, i));
if (v[i] == -1.0f && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "list elements must be a number");
- return 0;
+ return false;
}
}
- return 1;
+ return true;
}
bool Vec2f_ptr_from_PyList(PyObject *obj, Vec2f &vec)
@@ -707,10 +712,10 @@ static bool float_array_from_PyTuple(PyObject *obj, float *v, int n)
v[i] = PyFloat_AsDouble(PyTuple_GET_ITEM(obj, i));
if (v[i] == -1.0f && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "tuple elements must be a number");
- return 0;
+ return false;
}
}
- return 1;
+ return true;
}
bool Vec2f_ptr_from_PyTuple(PyObject *obj, Vec2f &vec)
@@ -766,21 +771,21 @@ bool float_array_from_PyObject(PyObject *obj, float *v, int n)
{
if (VectorObject_Check(obj) && ((VectorObject *)obj)->size == n) {
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
- return 0;
+ return false;
}
for (int i = 0; i < n; i++) {
v[i] = ((VectorObject *)obj)->vec[i];
}
- return 1;
+ return true;
}
if (ColorObject_Check(obj) && n == 3) {
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
- return 0;
+ return false;
}
for (int i = 0; i < n; i++) {
v[i] = ((ColorObject *)obj)->col[i];
}
- return 1;
+ return true;
}
if (PyList_Check(obj) && PyList_GET_SIZE(obj) == n) {
return float_array_from_PyList(obj, v, n);
@@ -788,7 +793,7 @@ bool float_array_from_PyObject(PyObject *obj, float *v, int n)
if (PyTuple_Check(obj) && PyTuple_GET_SIZE(obj) == n) {
return float_array_from_PyTuple(obj, v, n);
}
- return 0;
+ return false;
}
int convert_v4(PyObject *obj, void *v)
diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
index 9796dcda964..db85292c6c0 100644
--- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
@@ -72,7 +72,7 @@ static PyObject *Freestyle_getCurrentScene(PyObject * /*self*/)
Scene *scene = g_freestyle.scene;
if (!scene) {
PyErr_SetString(PyExc_TypeError, "current scene not available");
- return NULL;
+ return nullptr;
}
PointerRNA ptr_scene;
RNA_pointer_create(&scene->id, &RNA_Scene, scene, &ptr_scene);
@@ -166,12 +166,12 @@ static PyObject *Freestyle_blendRamp(PyObject * /*self*/, PyObject *args)
float a[3], fac, b[3];
if (!PyArg_ParseTuple(args, "sOfO", &s, &obj1, &fac, &obj2)) {
- return NULL;
+ return nullptr;
}
type = ramp_blend_type(s);
if (type < 0) {
PyErr_SetString(PyExc_TypeError, "argument 1 is an unknown ramp blend type");
- return NULL;
+ return nullptr;
}
if (mathutils_array_parse(a,
3,
@@ -179,7 +179,7 @@ static PyObject *Freestyle_blendRamp(PyObject * /*self*/, PyObject *args)
obj1,
"argument 2 must be a 3D vector "
"(either a tuple/list of 3 elements or Vector)") == -1) {
- return NULL;
+ return nullptr;
}
if (mathutils_array_parse(b,
3,
@@ -187,10 +187,10 @@ static PyObject *Freestyle_blendRamp(PyObject * /*self*/, PyObject *args)
obj2,
"argument 4 must be a 3D vector "
"(either a tuple/list of 3 elements or Vector)") == -1) {
- return NULL;
+ return nullptr;
}
ramp_blend(type, a, fac, b);
- return Vector_CreatePyObject(a, 3, NULL);
+ return Vector_CreatePyObject(a, 3, nullptr);
}
#include "BKE_colorband.h" /* BKE_colorband_evaluate() */
@@ -214,18 +214,18 @@ static PyObject *Freestyle_evaluateColorRamp(PyObject * /*self*/, PyObject *args
float in, out[4];
if (!(PyArg_ParseTuple(args, "O!f", &pyrna_struct_Type, &py_srna, &in))) {
- return NULL;
+ return nullptr;
}
if (!RNA_struct_is_a(py_srna->ptr.type, &RNA_ColorRamp)) {
PyErr_SetString(PyExc_TypeError, "1st argument is not a ColorRamp object");
- return NULL;
+ return nullptr;
}
coba = (ColorBand *)py_srna->ptr.data;
if (!BKE_colorband_evaluate(coba, in, out)) {
PyErr_SetString(PyExc_ValueError, "failed to evaluate the color ramp");
- return NULL;
+ return nullptr;
}
- return Vector_CreatePyObject(out, 4, NULL);
+ return Vector_CreatePyObject(out, 4, nullptr);
}
#include "BKE_colortools.h" /* BKE_curvemapping_evaluateF() */
@@ -253,22 +253,22 @@ static PyObject *Freestyle_evaluateCurveMappingF(PyObject * /*self*/, PyObject *
float value;
if (!(PyArg_ParseTuple(args, "O!if", &pyrna_struct_Type, &py_srna, &cur, &value))) {
- return NULL;
+ return nullptr;
}
if (!RNA_struct_is_a(py_srna->ptr.type, &RNA_CurveMapping)) {
PyErr_SetString(PyExc_TypeError, "1st argument is not a CurveMapping object");
- return NULL;
+ return nullptr;
}
if (cur < 0 || cur > 3) {
PyErr_SetString(PyExc_ValueError, "2nd argument is out of range");
- return NULL;
+ return nullptr;
}
cumap = (CurveMapping *)py_srna->ptr.data;
BKE_curvemapping_init(cumap);
/* disable extrapolation if enabled */
if ((cumap->flag & CUMA_EXTEND_EXTRAPOLATE)) {
cumap->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
- BKE_curvemapping_changed(cumap, 0);
+ BKE_curvemapping_changed(cumap, false);
}
return PyFloat_FromDouble(BKE_curvemapping_evaluateF(cumap, cur, value));
}
@@ -515,7 +515,7 @@ static PyMethodDef module_functions[] = {
(PyCFunction)Freestyle_evaluateCurveMappingF,
METH_VARARGS,
Freestyle_evaluateCurveMappingF___doc__},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*-----------------------Freestyle module definition---------------------------*/
@@ -536,7 +536,7 @@ PyObject *Freestyle_Init(void)
// initialize modules
module = PyModule_Create(&module_definition);
if (!module) {
- return NULL;
+ return nullptr;
}
PyDict_SetItemString(PySys_GetObject("modules"), module_definition.m_name, module);
diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
index 3efabbfbdf5..2aa08ec3ab5 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
+++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
@@ -33,7 +33,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int FrsMaterial_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -80,10 +80,10 @@ PyDoc_STRVAR(
static int FrsMaterial_init(BPy_FrsMaterial *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
+ static const char *kwlist_1[] = {"brother", nullptr};
static const char *kwlist_2[] = {
- "line", "diffuse", "ambient", "specular", "emission", "shininess", "priority", NULL};
- PyObject *brother = 0;
+ "line", "diffuse", "ambient", "specular", "emission", "shininess", "priority", nullptr};
+ PyObject *brother = nullptr;
float line[4], diffuse[4], ambient[4], specular[4], emission[4], shininess;
int priority;
@@ -456,46 +456,46 @@ static PyGetSetDef BPy_FrsMaterial_getseters[] = {
(getter)FrsMaterial_line_get,
(setter)FrsMaterial_line_set,
FrsMaterial_line_doc,
- NULL},
+ nullptr},
{"diffuse",
(getter)FrsMaterial_diffuse_get,
(setter)FrsMaterial_diffuse_set,
FrsMaterial_diffuse_doc,
- NULL},
+ nullptr},
{"specular",
(getter)FrsMaterial_specular_get,
(setter)FrsMaterial_specular_set,
FrsMaterial_specular_doc,
- NULL},
+ nullptr},
{"ambient",
(getter)FrsMaterial_ambient_get,
(setter)FrsMaterial_ambient_set,
FrsMaterial_ambient_doc,
- NULL},
+ nullptr},
{"emission",
(getter)FrsMaterial_emission_get,
(setter)FrsMaterial_emission_set,
FrsMaterial_emission_doc,
- NULL},
+ nullptr},
{"shininess",
(getter)FrsMaterial_shininess_get,
(setter)FrsMaterial_shininess_set,
FrsMaterial_shininess_doc,
- NULL},
+ nullptr},
{"priority",
(getter)FrsMaterial_priority_get,
(setter)FrsMaterial_priority_set,
FrsMaterial_priority_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
static PyObject *BPy_FrsMaterial_richcmpr(PyObject *objectA,
PyObject *objectB,
int comparison_type)
{
- const BPy_FrsMaterial *matA = NULL, *matB = NULL;
- bool result = 0;
+ const BPy_FrsMaterial *matA = nullptr, *matB = nullptr;
+ bool result = false;
if (!BPy_FrsMaterial_Check(objectA) || !BPy_FrsMaterial_Check(objectB)) {
if (comparison_type == Py_NE) {
@@ -517,7 +517,7 @@ static PyObject *BPy_FrsMaterial_richcmpr(PyObject *objectA,
break;
default:
PyErr_SetString(PyExc_TypeError, "Material does not support this comparison type");
- return NULL;
+ return nullptr;
}
if (result == true) {
@@ -534,43 +534,47 @@ static Py_hash_t FrsMaterial_hash(PyObject *self)
/*-----------------------BPy_FrsMaterial type definition ------------------------------*/
PyTypeObject FrsMaterial_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Material", /* tp_name */
- sizeof(BPy_FrsMaterial), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)FrsMaterial_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)FrsMaterial_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)FrsMaterial_hash, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- FrsMaterial_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- (richcmpfunc)BPy_FrsMaterial_richcmpr, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_FrsMaterial_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)FrsMaterial_init, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Material", /* tp_name */
+ sizeof(BPy_FrsMaterial), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)FrsMaterial_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)FrsMaterial_repr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ (hashfunc)FrsMaterial_hash, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ FrsMaterial_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ (richcmpfunc)BPy_FrsMaterial_richcmpr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_FrsMaterial_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)FrsMaterial_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
index 6bd4ae6b5fe..943a9ca0e64 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
+++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
@@ -34,7 +34,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int FrsNoise_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -63,7 +63,7 @@ PyDoc_STRVAR(FrsNoise_doc,
static int FrsNoise_init(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"seed", NULL};
+ static const char *kwlist[] = {"seed", nullptr};
long seed = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|l", (char **)kwlist, &seed)) {
@@ -104,11 +104,11 @@ PyDoc_STRVAR(FrsNoise_turbulence1_doc,
static PyObject *FrsNoise_drand(BPy_FrsNoise * /*self*/, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"seed", NULL};
+ static const char *kwlist[] = {"seed", nullptr};
long seed = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|I", (char **)kwlist, &seed)) {
PyErr_SetString(PyExc_TypeError, "optional argument 1 must be of type int");
- return NULL;
+ return nullptr;
}
if (seed) {
RandGen::srand48(seed);
@@ -118,25 +118,25 @@ static PyObject *FrsNoise_drand(BPy_FrsNoise * /*self*/, PyObject *args, PyObjec
static PyObject *FrsNoise_turbulence_smooth(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"v", "oct", NULL};
+ static const char *kwlist[] = {"v", "oct", nullptr};
double x; // note: this has to be a double (not float)
unsigned nbOctaves = 8;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "d|I", (char **)kwlist, &x, &nbOctaves)) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(self->pn->turbulenceSmooth(x, nbOctaves));
}
static PyObject *FrsNoise_turbulence1(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"v", "freq", "amp", "oct", NULL};
+ static const char *kwlist[] = {"v", "freq", "amp", "oct", nullptr};
float f1, f2, f3;
unsigned int i = 4;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "fff|I", (char **)kwlist, &f1, &f2, &f3, &i)) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(self->n->turbulence1(f1, f2, f3, i));
}
@@ -159,19 +159,19 @@ PyDoc_STRVAR(FrsNoise_turbulence2_doc,
static PyObject *FrsNoise_turbulence2(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"v", "freq", "amp", "oct", NULL};
+ static const char *kwlist[] = {"v", "freq", "amp", "oct", nullptr};
PyObject *obj1;
float f2, f3;
unsigned int i = 4;
Vec2f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Off|I", (char **)kwlist, &obj1, &f2, &f3, &i)) {
- return NULL;
+ return nullptr;
}
if (!Vec2f_ptr_from_PyObject(obj1, vec)) {
PyErr_SetString(PyExc_TypeError,
"argument 1 must be a 2D vector (either a list of 2 elements or Vector)");
- return NULL;
+ return nullptr;
}
float t = self->n->turbulence2(vec, f2, f3, i);
return PyFloat_FromDouble(t);
@@ -195,19 +195,19 @@ PyDoc_STRVAR(FrsNoise_turbulence3_doc,
static PyObject *FrsNoise_turbulence3(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"v", "freq", "amp", "oct", NULL};
+ static const char *kwlist[] = {"v", "freq", "amp", "oct", nullptr};
PyObject *obj1;
float f2, f3;
unsigned int i = 4;
Vec3f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Off|I", (char **)kwlist, &obj1, &f2, &f3, &i)) {
- return NULL;
+ return nullptr;
}
if (!Vec3f_ptr_from_PyObject(obj1, vec)) {
PyErr_SetString(PyExc_TypeError,
"argument 1 must be a 3D vector (either a list of 3 elements or Vector)");
- return NULL;
+ return nullptr;
}
float t = self->n->turbulence3(vec, f2, f3, i);
return PyFloat_FromDouble(t);
@@ -225,11 +225,11 @@ PyDoc_STRVAR(FrsNoise_smoothNoise1_doc,
static PyObject *FrsNoise_smoothNoise1(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"v", NULL};
+ static const char *kwlist[] = {"v", nullptr};
float f;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &f)) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(self->n->smoothNoise1(f));
}
@@ -246,17 +246,17 @@ PyDoc_STRVAR(FrsNoise_smoothNoise2_doc,
static PyObject *FrsNoise_smoothNoise2(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"v", NULL};
+ static const char *kwlist[] = {"v", nullptr};
PyObject *obj;
Vec2f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) {
- return NULL;
+ return nullptr;
}
if (!Vec2f_ptr_from_PyObject(obj, vec)) {
PyErr_SetString(PyExc_TypeError,
"argument 1 must be a 2D vector (either a list of 2 elements or Vector)");
- return NULL;
+ return nullptr;
}
float t = self->n->smoothNoise2(vec);
return PyFloat_FromDouble(t);
@@ -274,17 +274,17 @@ PyDoc_STRVAR(FrsNoise_smoothNoise3_doc,
static PyObject *FrsNoise_smoothNoise3(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"v", NULL};
+ static const char *kwlist[] = {"v", nullptr};
PyObject *obj;
Vec3f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) {
- return NULL;
+ return nullptr;
}
if (!Vec3f_ptr_from_PyObject(obj, vec)) {
PyErr_SetString(PyExc_TypeError,
"argument 1 must be a 3D vector (either a list of 3 elements or Vector)");
- return NULL;
+ return nullptr;
}
float t = self->n->smoothNoise3(vec);
return PyFloat_FromDouble(t);
@@ -315,53 +315,57 @@ static PyMethodDef BPy_FrsNoise_methods[] = {
(PyCFunction)FrsNoise_smoothNoise3,
METH_VARARGS | METH_KEYWORDS,
FrsNoise_smoothNoise3_doc},
- {"rand", (PyCFunction)FrsNoise_drand, METH_VARARGS | METH_KEYWORDS, NULL},
+ {"rand", (PyCFunction)FrsNoise_drand, METH_VARARGS | METH_KEYWORDS, nullptr},
{"turbulence_smooth",
(PyCFunction)FrsNoise_turbulence_smooth,
METH_VARARGS | METH_KEYWORDS,
- NULL},
- {NULL, NULL, 0, NULL},
+ nullptr},
+ {nullptr, nullptr, 0, nullptr},
};
/*-----------------------BPy_FrsNoise type definition ------------------------------*/
PyTypeObject FrsNoise_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Noise", /* tp_name */
- sizeof(BPy_FrsNoise), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)FrsNoise_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Noise", /* tp_name */
+ sizeof(BPy_FrsNoise), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)FrsNoise_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
(reprfunc)FrsNoise_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
FrsNoise_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
BPy_FrsNoise_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)FrsNoise_init, /* tp_init */
- 0, /* tp_alloc */
+ nullptr, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
diff --git a/source/blender/freestyle/intern/python/BPy_Id.cpp b/source/blender/freestyle/intern/python/BPy_Id.cpp
index 8f61f7f3e14..323e76fe249 100644
--- a/source/blender/freestyle/intern/python/BPy_Id.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Id.cpp
@@ -31,7 +31,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int Id_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -64,8 +64,8 @@ PyDoc_STRVAR(
static int Id_init(BPy_Id *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"first", "second", NULL};
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"first", "second", nullptr};
PyObject *brother;
int first = 0, second = 0;
@@ -159,50 +159,54 @@ static int Id_second_set(BPy_Id *self, PyObject *value, void *UNUSED(closure))
}
static PyGetSetDef BPy_Id_getseters[] = {
- {"first", (getter)Id_first_get, (setter)Id_first_set, Id_first_doc, NULL},
- {"second", (getter)Id_second_get, (setter)Id_second_set, Id_second_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ {"first", (getter)Id_first_get, (setter)Id_first_set, Id_first_doc, nullptr},
+ {"second", (getter)Id_second_get, (setter)Id_second_set, Id_second_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_Id type definition ------------------------------*/
PyTypeObject Id_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Id", /* tp_name */
- sizeof(BPy_Id), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)Id_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Id", /* tp_name */
+ sizeof(BPy_Id), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Id_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
(reprfunc)Id_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Id_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
(richcmpfunc)Id_RichCompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
BPy_Id_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)Id_init, /* tp_init */
- 0, /* tp_alloc */
+ nullptr, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
diff --git a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
index 9c155db913c..25f3c54ea7d 100644
--- a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
+++ b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
@@ -61,8 +61,8 @@ PyDoc_STRVAR(Integrator_integrate_doc,
static PyObject *Integrator_integrate(PyObject * /*self*/, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"func", "it", "it_end", "integration_type", NULL};
- PyObject *obj1, *obj4 = 0;
+ static const char *kwlist[] = {"func", "it", "it_end", "integration_type", nullptr};
+ PyObject *obj1, *obj4 = nullptr;
BPy_Interface0DIterator *obj2, *obj3;
if (!PyArg_ParseTupleAndKeywords(args,
@@ -77,7 +77,7 @@ static PyObject *Integrator_integrate(PyObject * /*self*/, PyObject *args, PyObj
&obj3,
&IntegrationType_Type,
&obj4)) {
- return NULL;
+ return nullptr;
}
Interface0DIterator it(*(obj2->if0D_it)), it_end(*(obj3->if0D_it));
@@ -101,7 +101,7 @@ static PyObject *Integrator_integrate(PyObject * /*self*/, PyObject *args, PyObj
string class_name(Py_TYPE(obj1)->tp_name);
PyErr_SetString(PyExc_TypeError, ("unsupported function type: " + class_name).c_str());
- return NULL;
+ return nullptr;
}
/*-----------------------Integrator module docstring---------------------------------------*/
@@ -115,7 +115,7 @@ static PyMethodDef module_functions[] = {
(PyCFunction)Integrator_integrate,
METH_VARARGS | METH_KEYWORDS,
Integrator_integrate_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*-----------------------Integrator module definition--------------------------------------*/
@@ -149,43 +149,47 @@ PyDoc_STRVAR(IntegrationType_doc,
" last of the values obtained for the 0D elements.");
PyTypeObject IntegrationType_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "IntegrationType", /* tp_name */
- sizeof(PyLongObject), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- IntegrationType_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &PyLong_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "IntegrationType", /* tp_name */
+ sizeof(PyLongObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ IntegrationType_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &PyLong_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ nullptr, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
/*-----------------------BPy_IntegrationType instance definitions -------------------------*/
@@ -210,7 +214,7 @@ int IntegrationType_Init(PyObject *module)
{
PyObject *m, *d, *f;
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -227,7 +231,7 @@ int IntegrationType_Init(PyObject *module)
PyDict_SetItemString(IntegrationType_Type.tp_dict, "LAST", BPy_IntegrationType_LAST);
m = PyModule_Create(&module_definition);
- if (m == NULL) {
+ if (m == nullptr) {
return -1;
}
Py_INCREF(m);
diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
index 18e11c55bc4..3d0c57d5509 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
@@ -39,7 +39,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int Interface0D_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -102,7 +102,7 @@ PyDoc_STRVAR(Interface0D_doc,
static int Interface0D_init(BPy_Interface0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -139,16 +139,16 @@ PyDoc_STRVAR(Interface0D_get_fedge_doc,
static PyObject *Interface0D_get_fedge(BPy_Interface0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"inter", NULL};
+ static const char *kwlist[] = {"inter", nullptr};
PyObject *py_if0D;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0D_Type, &py_if0D)) {
- return NULL;
+ return nullptr;
}
FEdge *fe = self->if0D->getFEdge(*(((BPy_Interface0D *)py_if0D)->if0D));
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
if (fe) {
return Any_BPy_FEdge_from_FEdge(*fe);
@@ -161,7 +161,7 @@ static PyMethodDef BPy_Interface0D_methods[] = {
(PyCFunction)Interface0D_get_fedge,
METH_VARARGS | METH_KEYWORDS,
Interface0D_get_fedge_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------Interface1D get/setters ----------------------------*/
@@ -185,7 +185,7 @@ static PyObject *Interface0D_point_3d_get(BPy_Interface0D *self, void *UNUSED(cl
{
Vec3f p(self->if0D->getPoint3D());
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
return Vector_from_Vec3f(p);
}
@@ -199,7 +199,7 @@ static PyObject *Interface0D_projected_x_get(BPy_Interface0D *self, void *UNUSED
{
real x = self->if0D->getProjectedX();
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(x);
}
@@ -213,7 +213,7 @@ static PyObject *Interface0D_projected_y_get(BPy_Interface0D *self, void *UNUSED
{
real y = self->if0D->getProjectedY();
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(y);
}
@@ -227,7 +227,7 @@ static PyObject *Interface0D_projected_z_get(BPy_Interface0D *self, void *UNUSED
{
real z = self->if0D->getProjectedZ();
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(z);
}
@@ -241,7 +241,7 @@ static PyObject *Interface0D_point_2d_get(BPy_Interface0D *self, void *UNUSED(cl
{
Vec2f p(self->if0D->getPoint2D());
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
return Vector_from_Vec2f(p);
}
@@ -255,7 +255,7 @@ static PyObject *Interface0D_id_get(BPy_Interface0D *self, void *UNUSED(closure)
{
Id id(self->if0D->getId());
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
return BPy_Id_from_Id(id); // return a copy
}
@@ -269,75 +269,87 @@ static PyObject *Interface0D_nature_get(BPy_Interface0D *self, void *UNUSED(clos
{
Nature::VertexNature nature = self->if0D->getNature();
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
return BPy_Nature_from_Nature(nature);
}
static PyGetSetDef BPy_Interface0D_getseters[] = {
- {"name", (getter)Interface0D_name_get, (setter)NULL, Interface0D_name_doc, NULL},
- {"point_3d", (getter)Interface0D_point_3d_get, (setter)NULL, Interface0D_point_3d_doc, NULL},
+ {"name", (getter)Interface0D_name_get, (setter) nullptr, Interface0D_name_doc, nullptr},
+ {"point_3d",
+ (getter)Interface0D_point_3d_get,
+ (setter) nullptr,
+ Interface0D_point_3d_doc,
+ nullptr},
{"projected_x",
(getter)Interface0D_projected_x_get,
- (setter)NULL,
+ (setter) nullptr,
Interface0D_projected_x_doc,
- NULL},
+ nullptr},
{"projected_y",
(getter)Interface0D_projected_y_get,
- (setter)NULL,
+ (setter) nullptr,
Interface0D_projected_y_doc,
- NULL},
+ nullptr},
{"projected_z",
(getter)Interface0D_projected_z_get,
- (setter)NULL,
+ (setter) nullptr,
Interface0D_projected_z_doc,
- NULL},
- {"point_2d", (getter)Interface0D_point_2d_get, (setter)NULL, Interface0D_point_2d_doc, NULL},
- {"id", (getter)Interface0D_id_get, (setter)NULL, Interface0D_id_doc, NULL},
- {"nature", (getter)Interface0D_nature_get, (setter)NULL, Interface0D_nature_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {"point_2d",
+ (getter)Interface0D_point_2d_get,
+ (setter) nullptr,
+ Interface0D_point_2d_doc,
+ nullptr},
+ {"id", (getter)Interface0D_id_get, (setter) nullptr, Interface0D_id_doc, nullptr},
+ {"nature", (getter)Interface0D_nature_get, (setter) nullptr, Interface0D_nature_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_Interface0D type definition ------------------------------*/
PyTypeObject Interface0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Interface0D", /* tp_name */
- sizeof(BPy_Interface0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)Interface0D_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)Interface0D_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Interface0D_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_Interface0D_methods, /* tp_methods */
- 0, /* tp_members */
- BPy_Interface0D_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Interface0D_init, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Interface0D", /* tp_name */
+ sizeof(BPy_Interface0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Interface0D_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)Interface0D_repr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Interface0D_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ BPy_Interface0D_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_Interface0D_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Interface0D_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
index 423b97fe3cd..8a4a6eb61db 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
@@ -40,7 +40,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int Interface1D_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -113,7 +113,7 @@ PyDoc_STRVAR(Interface1D_doc,
static int Interface1D_init(BPy_Interface1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -183,11 +183,11 @@ PyDoc_STRVAR(Interface1D_points_begin_doc,
static PyObject *Interface1D_points_begin(BPy_Interface1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"t", NULL};
+ static const char *kwlist[] = {"t", nullptr};
float f = 0.0f;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f)) {
- return NULL;
+ return nullptr;
}
Interface0DIterator if0D_it(self->if1D->pointsBegin(f));
return BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, false);
@@ -209,11 +209,11 @@ PyDoc_STRVAR(Interface1D_points_end_doc,
static PyObject *Interface1D_points_end(BPy_Interface1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"t", NULL};
+ static const char *kwlist[] = {"t", nullptr};
float f = 0.0f;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f)) {
- return NULL;
+ return nullptr;
}
Interface0DIterator if0D_it(self->if1D->pointsEnd(f));
return BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, true);
@@ -236,7 +236,7 @@ static PyMethodDef BPy_Interface1D_methods[] = {
(PyCFunction)Interface1D_points_end,
METH_VARARGS | METH_KEYWORDS,
Interface1D_points_end_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------Interface1D get/setters ----------------------------*/
@@ -260,7 +260,7 @@ static PyObject *Interface1D_id_get(BPy_Interface1D *self, void *UNUSED(closure)
{
Id id(self->if1D->getId());
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
return BPy_Id_from_Id(id); // return a copy
}
@@ -274,7 +274,7 @@ static PyObject *Interface1D_nature_get(BPy_Interface1D *self, void *UNUSED(clos
{
Nature::VertexNature nature = self->if1D->getNature();
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
return BPy_Nature_from_Nature(nature);
}
@@ -288,7 +288,7 @@ static PyObject *Interface1D_length_2d_get(BPy_Interface1D *self, void *UNUSED(c
{
real length = self->if1D->getLength2D();
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble((double)length);
}
@@ -318,62 +318,66 @@ static int Interface1D_time_stamp_set(BPy_Interface1D *self,
}
static PyGetSetDef BPy_Interface1D_getseters[] = {
- {"name", (getter)Interface1D_name_get, (setter)NULL, Interface1D_name_doc, NULL},
- {"id", (getter)Interface1D_id_get, (setter)NULL, Interface1D_id_doc, NULL},
- {"nature", (getter)Interface1D_nature_get, (setter)NULL, Interface1D_nature_doc, NULL},
+ {"name", (getter)Interface1D_name_get, (setter) nullptr, Interface1D_name_doc, nullptr},
+ {"id", (getter)Interface1D_id_get, (setter) nullptr, Interface1D_id_doc, nullptr},
+ {"nature", (getter)Interface1D_nature_get, (setter) nullptr, Interface1D_nature_doc, nullptr},
{"length_2d",
(getter)Interface1D_length_2d_get,
- (setter)NULL,
+ (setter) nullptr,
Interface1D_length_2d_doc,
- NULL},
+ nullptr},
{"time_stamp",
(getter)Interface1D_time_stamp_get,
(setter)Interface1D_time_stamp_set,
Interface1D_time_stamp_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_Interface1D type definition ------------------------------*/
PyTypeObject Interface1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Interface1D", /* tp_name */
- sizeof(BPy_Interface1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)Interface1D_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)Interface1D_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Interface1D_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_Interface1D_methods, /* tp_methods */
- 0, /* tp_members */
- BPy_Interface1D_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Interface1D_init, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Interface1D", /* tp_name */
+ sizeof(BPy_Interface1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Interface1D_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)Interface1D_repr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Interface1D_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ BPy_Interface1D_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_Interface1D_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Interface1D_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_Iterator.cpp b/source/blender/freestyle/intern/python/BPy_Iterator.cpp
index b8dedb6497a..bee30aa9e8c 100644
--- a/source/blender/freestyle/intern/python/BPy_Iterator.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Iterator.cpp
@@ -41,7 +41,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int Iterator_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -126,7 +126,7 @@ PyDoc_STRVAR(Iterator_doc,
static int Iterator_init(BPy_Iterator *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -155,7 +155,7 @@ static PyObject *Iterator_increment(BPy_Iterator *self)
{
if (self->it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError, "cannot increment any more");
- return NULL;
+ return nullptr;
}
self->it->increment();
Py_RETURN_NONE;
@@ -170,7 +170,7 @@ static PyObject *Iterator_decrement(BPy_Iterator *self)
{
if (self->it->isBegin()) {
PyErr_SetString(PyExc_RuntimeError, "cannot decrement any more");
- return NULL;
+ return nullptr;
}
self->it->decrement();
Py_RETURN_NONE;
@@ -179,7 +179,7 @@ static PyObject *Iterator_decrement(BPy_Iterator *self)
static PyMethodDef BPy_Iterator_methods[] = {
{"increment", (PyCFunction)Iterator_increment, METH_NOARGS, Iterator_increment_doc},
{"decrement", (PyCFunction)Iterator_decrement, METH_NOARGS, Iterator_decrement_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------Iterator get/setters ----------------------------*/
@@ -215,52 +215,56 @@ static PyObject *Iterator_is_end_get(BPy_Iterator *self, void *UNUSED(closure))
}
static PyGetSetDef BPy_Iterator_getseters[] = {
- {"name", (getter)Iterator_name_get, (setter)NULL, Iterator_name_doc, NULL},
- {"is_begin", (getter)Iterator_is_begin_get, (setter)NULL, Iterator_is_begin_doc, NULL},
- {"is_end", (getter)Iterator_is_end_get, (setter)NULL, Iterator_is_end_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ {"name", (getter)Iterator_name_get, (setter) nullptr, Iterator_name_doc, nullptr},
+ {"is_begin", (getter)Iterator_is_begin_get, (setter) nullptr, Iterator_is_begin_doc, nullptr},
+ {"is_end", (getter)Iterator_is_end_get, (setter) nullptr, Iterator_is_end_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_Iterator type definition ------------------------------*/
PyTypeObject Iterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Iterator", /* tp_name */
- sizeof(BPy_Iterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)Iterator_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)Iterator_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Iterator_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_Iterator_methods, /* tp_methods */
- 0, /* tp_members */
- BPy_Iterator_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Iterator_init, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Iterator", /* tp_name */
+ sizeof(BPy_Iterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Iterator_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)Iterator_repr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Iterator_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ BPy_Iterator_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_Iterator_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Iterator_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_MediumType.cpp b/source/blender/freestyle/intern/python/BPy_MediumType.cpp
index 915f0c41a56..547f46839b8 100644
--- a/source/blender/freestyle/intern/python/BPy_MediumType.cpp
+++ b/source/blender/freestyle/intern/python/BPy_MediumType.cpp
@@ -41,43 +41,47 @@ PyDoc_STRVAR(MediumType_doc,
"* Stroke.OPAQUE_MEDIUM: To simulate an opaque medium (oil, spray...).");
PyTypeObject MediumType_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "MediumType", /* tp_name */
- sizeof(PyLongObject), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- MediumType_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &PyLong_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "MediumType", /* tp_name */
+ sizeof(PyLongObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ MediumType_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &PyLong_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ nullptr, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
/*-----------------------BPy_IntegrationType instance definitions -------------------------*/
@@ -96,7 +100,7 @@ PyLongObject _BPy_MediumType_OPAQUE_MEDIUM = {
int MediumType_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
diff --git a/source/blender/freestyle/intern/python/BPy_Nature.cpp b/source/blender/freestyle/intern/python/BPy_Nature.cpp
index 79fb154233e..b0a620803d1 100644
--- a/source/blender/freestyle/intern/python/BPy_Nature.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Nature.cpp
@@ -35,40 +35,40 @@ static PyObject *BPy_Nature_or(PyObject *a, PyObject *b);
/*-----------------------BPy_Nature number method definitions --------------------*/
static PyNumberMethods nature_as_number = {
- 0, /* binaryfunc nb_add */
- 0, /* binaryfunc nb_subtract */
- 0, /* binaryfunc nb_multiply */
- 0, /* binaryfunc nb_remainder */
- 0, /* binaryfunc nb_divmod */
- 0, /* ternaryfunc nb_power */
- 0, /* unaryfunc nb_negative */
- 0, /* unaryfunc nb_positive */
- 0, /* unaryfunc nb_absolute */
- 0, /* inquiry nb_bool */
- 0, /* unaryfunc nb_invert */
- 0, /* binaryfunc nb_lshift */
- 0, /* binaryfunc nb_rshift */
+ nullptr, /* binaryfunc nb_add */
+ nullptr, /* binaryfunc nb_subtract */
+ nullptr, /* binaryfunc nb_multiply */
+ nullptr, /* binaryfunc nb_remainder */
+ nullptr, /* binaryfunc nb_divmod */
+ nullptr, /* ternaryfunc nb_power */
+ nullptr, /* unaryfunc nb_negative */
+ nullptr, /* unaryfunc nb_positive */
+ nullptr, /* unaryfunc nb_absolute */
+ nullptr, /* inquiry nb_bool */
+ nullptr, /* unaryfunc nb_invert */
+ nullptr, /* binaryfunc nb_lshift */
+ nullptr, /* binaryfunc nb_rshift */
(binaryfunc)BPy_Nature_and, /* binaryfunc nb_and */
(binaryfunc)BPy_Nature_xor, /* binaryfunc nb_xor */
(binaryfunc)BPy_Nature_or, /* binaryfunc nb_or */
- 0, /* unaryfunc nb_int */
- 0, /* void *nb_reserved */
- 0, /* unaryfunc nb_float */
- 0, /* binaryfunc nb_inplace_add */
- 0, /* binaryfunc nb_inplace_subtract */
- 0, /* binaryfunc nb_inplace_multiply */
- 0, /* binaryfunc nb_inplace_remainder */
- 0, /* ternaryfunc nb_inplace_power */
- 0, /* binaryfunc nb_inplace_lshift */
- 0, /* binaryfunc nb_inplace_rshift */
- 0, /* binaryfunc nb_inplace_and */
- 0, /* binaryfunc nb_inplace_xor */
- 0, /* binaryfunc nb_inplace_or */
- 0, /* binaryfunc nb_floor_divide */
- 0, /* binaryfunc nb_true_divide */
- 0, /* binaryfunc nb_inplace_floor_divide */
- 0, /* binaryfunc nb_inplace_true_divide */
- 0, /* unaryfunc nb_index */
+ nullptr, /* unaryfunc nb_int */
+ nullptr, /* void *nb_reserved */
+ nullptr, /* unaryfunc nb_float */
+ nullptr, /* binaryfunc nb_inplace_add */
+ nullptr, /* binaryfunc nb_inplace_subtract */
+ nullptr, /* binaryfunc nb_inplace_multiply */
+ nullptr, /* binaryfunc nb_inplace_remainder */
+ nullptr, /* ternaryfunc nb_inplace_power */
+ nullptr, /* binaryfunc nb_inplace_lshift */
+ nullptr, /* binaryfunc nb_inplace_rshift */
+ nullptr, /* binaryfunc nb_inplace_and */
+ nullptr, /* binaryfunc nb_inplace_xor */
+ nullptr, /* binaryfunc nb_inplace_or */
+ nullptr, /* binaryfunc nb_floor_divide */
+ nullptr, /* binaryfunc nb_true_divide */
+ nullptr, /* binaryfunc nb_inplace_floor_divide */
+ nullptr, /* binaryfunc nb_inplace_true_divide */
+ nullptr, /* unaryfunc nb_index */
};
/*-----------------------BPy_Nature docstring ------------------------------------*/
@@ -103,43 +103,47 @@ PyDoc_STRVAR(Nature_doc,
/*-----------------------BPy_Nature type definition ------------------------------*/
PyTypeObject Nature_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Nature", /* tp_name */
- sizeof(PyLongObject), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- &nature_as_number, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- Nature_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &PyLong_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Nature", /* tp_name */
+ sizeof(PyLongObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ &nature_as_number, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Nature_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &PyLong_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ nullptr, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
/*-----------------------BPy_Nature instance definitions ----------------------------------*/
@@ -186,7 +190,7 @@ static PyLongObject _Nature_EDGE_MARK = {
//-------------------MODULE INITIALIZATION--------------------------------
int Nature_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -225,16 +229,16 @@ static PyObject *BPy_Nature_bitwise(PyObject *a, int op, PyObject *b)
if (!BPy_Nature_Check(a) || !BPy_Nature_Check(b)) {
PyErr_SetString(PyExc_TypeError, "operands must be a Nature object");
- return NULL;
+ return nullptr;
}
if ((op1 = PyLong_AsLong(a)) == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError, "operand 1: unexpected Nature value");
- return NULL;
+ return nullptr;
}
if ((op2 = PyLong_AsLong(b)) == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError, "operand 2: unexpected Nature value");
- return NULL;
+ return nullptr;
}
switch (op) {
case '&':
@@ -248,7 +252,7 @@ static PyObject *BPy_Nature_bitwise(PyObject *a, int op, PyObject *b)
break;
default:
PyErr_BadArgument();
- return NULL;
+ return nullptr;
}
if (v == 0) {
result = PyObject_NewVar(BPy_Nature, &Nature_Type, 0);
diff --git a/source/blender/freestyle/intern/python/BPy_Operators.cpp b/source/blender/freestyle/intern/python/BPy_Operators.cpp
index 1235786d5d3..5fd02e4a9dd 100644
--- a/source/blender/freestyle/intern/python/BPy_Operators.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Operators.cpp
@@ -41,7 +41,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int Operators_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -78,23 +78,23 @@ PyDoc_STRVAR(Operators_select_doc,
static PyObject *Operators_select(BPy_Operators * /*self*/, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"pred", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"pred", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &UnaryPredicate1D_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (!((BPy_UnaryPredicate1D *)obj)->up1D) {
PyErr_SetString(PyExc_TypeError,
"Operators.select(): 1st argument: invalid UnaryPredicate1D object");
- return NULL;
+ return nullptr;
}
if (Operators::select(*(((BPy_UnaryPredicate1D *)obj)->up1D)) < 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError, "Operators.select() failed");
}
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -123,8 +123,8 @@ PyDoc_STRVAR(Operators_chain_doc,
static PyObject *Operators_chain(BPy_Operators * /*self*/, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"it", "pred", "modifier", NULL};
- PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0;
+ static const char *kwlist[] = {"it", "pred", "modifier", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr;
if (!PyArg_ParseTupleAndKeywords(args,
kwds,
@@ -136,17 +136,17 @@ static PyObject *Operators_chain(BPy_Operators * /*self*/, PyObject *args, PyObj
&obj2,
&UnaryFunction1DVoid_Type,
&obj3)) {
- return NULL;
+ return nullptr;
}
if (!((BPy_ChainingIterator *)obj1)->c_it) {
PyErr_SetString(PyExc_TypeError,
"Operators.chain(): 1st argument: invalid ChainingIterator object");
- return NULL;
+ return nullptr;
}
if (!((BPy_UnaryPredicate1D *)obj2)->up1D) {
PyErr_SetString(PyExc_TypeError,
"Operators.chain(): 2nd argument: invalid UnaryPredicate1D object");
- return NULL;
+ return nullptr;
}
if (!obj3) {
if (Operators::chain(*(((BPy_ChainingIterator *)obj1)->c_it),
@@ -154,14 +154,14 @@ static PyObject *Operators_chain(BPy_Operators * /*self*/, PyObject *args, PyObj
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError, "Operators.chain() failed");
}
- return NULL;
+ return nullptr;
}
}
else {
if (!((BPy_UnaryFunction1DVoid *)obj3)->uf1D_void) {
PyErr_SetString(PyExc_TypeError,
"Operators.chain(): 3rd argument: invalid UnaryFunction1DVoid object");
- return NULL;
+ return nullptr;
}
if (Operators::chain(*(((BPy_ChainingIterator *)obj1)->c_it),
*(((BPy_UnaryPredicate1D *)obj2)->up1D),
@@ -169,7 +169,7 @@ static PyObject *Operators_chain(BPy_Operators * /*self*/, PyObject *args, PyObj
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError, "Operators.chain() failed");
}
- return NULL;
+ return nullptr;
}
}
Py_RETURN_NONE;
@@ -203,8 +203,8 @@ static PyObject *Operators_bidirectional_chain(BPy_Operators * /*self*/,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", "pred", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ static const char *kwlist[] = {"it", "pred", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
if (!PyArg_ParseTupleAndKeywords(args,
kwds,
@@ -214,20 +214,20 @@ static PyObject *Operators_bidirectional_chain(BPy_Operators * /*self*/,
&obj1,
&UnaryPredicate1D_Type,
&obj2)) {
- return NULL;
+ return nullptr;
}
if (!((BPy_ChainingIterator *)obj1)->c_it) {
PyErr_SetString(
PyExc_TypeError,
"Operators.bidirectional_chain(): 1st argument: invalid ChainingIterator object");
- return NULL;
+ return nullptr;
}
if (!obj2) {
if (Operators::bidirectionalChain(*(((BPy_ChainingIterator *)obj1)->c_it)) < 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError, "Operators.bidirectional_chain() failed");
}
- return NULL;
+ return nullptr;
}
}
else {
@@ -235,14 +235,14 @@ static PyObject *Operators_bidirectional_chain(BPy_Operators * /*self*/,
PyErr_SetString(
PyExc_TypeError,
"Operators.bidirectional_chain(): 2nd argument: invalid UnaryPredicate1D object");
- return NULL;
+ return nullptr;
}
if (Operators::bidirectionalChain(*(((BPy_ChainingIterator *)obj1)->c_it),
*(((BPy_UnaryPredicate1D *)obj2)->up1D)) < 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError, "Operators.bidirectional_chain() failed");
}
- return NULL;
+ return nullptr;
}
}
Py_RETURN_NONE;
@@ -283,9 +283,9 @@ static PyObject *Operators_sequential_split(BPy_Operators * /*self*/,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist_1[] = {"starting_pred", "stopping_pred", "sampling", NULL};
- static const char *kwlist_2[] = {"pred", "sampling", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ static const char *kwlist_1[] = {"starting_pred", "stopping_pred", "sampling", nullptr};
+ static const char *kwlist_2[] = {"pred", "sampling", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
float f = 0.0f;
if (PyArg_ParseTupleAndKeywords(args,
@@ -301,13 +301,13 @@ static PyObject *Operators_sequential_split(BPy_Operators * /*self*/,
PyErr_SetString(
PyExc_TypeError,
"Operators.sequential_split(): 1st argument: invalid UnaryPredicate0D object");
- return NULL;
+ return nullptr;
}
if (!((BPy_UnaryPredicate0D *)obj2)->up0D) {
PyErr_SetString(
PyExc_TypeError,
"Operators.sequential_split(): 2nd argument: invalid UnaryPredicate0D object");
- return NULL;
+ return nullptr;
}
if (Operators::sequentialSplit(*(((BPy_UnaryPredicate0D *)obj1)->up0D),
*(((BPy_UnaryPredicate0D *)obj2)->up0D),
@@ -315,7 +315,7 @@ static PyObject *Operators_sequential_split(BPy_Operators * /*self*/,
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError, "Operators.sequential_split() failed");
}
- return NULL;
+ return nullptr;
}
}
else if ((void)PyErr_Clear(),
@@ -326,18 +326,18 @@ static PyObject *Operators_sequential_split(BPy_Operators * /*self*/,
PyErr_SetString(
PyExc_TypeError,
"Operators.sequential_split(): 1st argument: invalid UnaryPredicate0D object");
- return NULL;
+ return nullptr;
}
if (Operators::sequentialSplit(*(((BPy_UnaryPredicate0D *)obj1)->up0D), f) < 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError, "Operators.sequential_split() failed");
}
- return NULL;
+ return nullptr;
}
}
else {
PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -382,9 +382,9 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist_1[] = {"func", "pred_1d", "sampling", NULL};
- static const char *kwlist_2[] = {"func", "pred_0d", "pred_1d", "sampling", NULL};
- PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0;
+ static const char *kwlist_1[] = {"func", "pred_1d", "sampling", nullptr};
+ static const char *kwlist_2[] = {"func", "pred_0d", "pred_1d", "sampling", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr;
float f = 0.0f;
if (PyArg_ParseTupleAndKeywords(args,
@@ -400,13 +400,13 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/,
PyErr_SetString(
PyExc_TypeError,
"Operators.recursive_split(): 1st argument: invalid UnaryFunction0DDouble object");
- return NULL;
+ return nullptr;
}
if (!((BPy_UnaryPredicate1D *)obj2)->up1D) {
PyErr_SetString(
PyExc_TypeError,
"Operators.recursive_split(): 2nd argument: invalid UnaryPredicate1D object");
- return NULL;
+ return nullptr;
}
if (Operators::recursiveSplit(*(((BPy_UnaryFunction0DDouble *)obj1)->uf0D_double),
*(((BPy_UnaryPredicate1D *)obj2)->up1D),
@@ -414,7 +414,7 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/,
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError, "Operators.recursive_split() failed");
}
- return NULL;
+ return nullptr;
}
}
else if ((void)PyErr_Clear(),
@@ -434,19 +434,19 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/,
PyErr_SetString(
PyExc_TypeError,
"Operators.recursive_split(): 1st argument: invalid UnaryFunction0DDouble object");
- return NULL;
+ return nullptr;
}
if (!((BPy_UnaryPredicate0D *)obj2)->up0D) {
PyErr_SetString(
PyExc_TypeError,
"Operators.recursive_split(): 2nd argument: invalid UnaryPredicate0D object");
- return NULL;
+ return nullptr;
}
if (!((BPy_UnaryPredicate1D *)obj3)->up1D) {
PyErr_SetString(
PyExc_TypeError,
"Operators.recursive_split(): 3rd argument: invalid UnaryPredicate1D object");
- return NULL;
+ return nullptr;
}
if (Operators::recursiveSplit(*(((BPy_UnaryFunction0DDouble *)obj1)->uf0D_double),
*(((BPy_UnaryPredicate0D *)obj2)->up0D),
@@ -455,12 +455,12 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/,
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError, "Operators.recursive_split() failed");
}
- return NULL;
+ return nullptr;
}
}
else {
PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -476,23 +476,23 @@ PyDoc_STRVAR(Operators_sort_doc,
static PyObject *Operators_sort(BPy_Operators * /*self*/, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"pred", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"pred", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &BinaryPredicate1D_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (!((BPy_BinaryPredicate1D *)obj)->bp1D) {
PyErr_SetString(PyExc_TypeError,
"Operators.sort(): 1st argument: invalid BinaryPredicate1D object");
- return NULL;
+ return nullptr;
}
if (Operators::sort(*(((BPy_BinaryPredicate1D *)obj)->bp1D)) < 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError, "Operators.sort() failed");
}
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -511,8 +511,8 @@ PyDoc_STRVAR(Operators_create_doc,
static PyObject *Operators_create(BPy_Operators * /*self*/, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"pred", "shaders", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ static const char *kwlist[] = {"pred", "shaders", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
if (!PyArg_ParseTupleAndKeywords(args,
kwds,
@@ -522,12 +522,12 @@ static PyObject *Operators_create(BPy_Operators * /*self*/, PyObject *args, PyOb
&obj1,
&PyList_Type,
&obj2)) {
- return NULL;
+ return nullptr;
}
if (!((BPy_UnaryPredicate1D *)obj1)->up1D) {
PyErr_SetString(PyExc_TypeError,
"Operators.create(): 1st argument: invalid UnaryPredicate1D object");
- return NULL;
+ return nullptr;
}
vector<StrokeShader *> shaders;
shaders.reserve(PyList_Size(obj2));
@@ -536,7 +536,7 @@ static PyObject *Operators_create(BPy_Operators * /*self*/, PyObject *args, PyOb
if (!BPy_StrokeShader_Check(py_ss)) {
PyErr_SetString(PyExc_TypeError,
"Operators.create(): 2nd argument must be a list of StrokeShader objects");
- return NULL;
+ return nullptr;
}
StrokeShader *shader = ((BPy_StrokeShader *)py_ss)->ss;
if (!shader) {
@@ -545,7 +545,7 @@ static PyObject *Operators_create(BPy_Operators * /*self*/, PyObject *args, PyOb
<< " of the shaders list is invalid likely due to missing call of "
"StrokeShader.__init__()";
PyErr_SetString(PyExc_TypeError, ss.str().c_str());
- return NULL;
+ return nullptr;
}
shaders.push_back(shader);
}
@@ -553,7 +553,7 @@ static PyObject *Operators_create(BPy_Operators * /*self*/, PyObject *args, PyOb
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError, "Operators.create() failed");
}
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -569,15 +569,15 @@ PyDoc_STRVAR(Operators_reset_doc,
static PyObject *Operators_reset(BPy_Operators * /*self*/, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"delete_strokes", NULL};
- PyObject *obj1 = 0;
+ static const char *kwlist[] = {"delete_strokes", nullptr};
+ PyObject *obj1 = nullptr;
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &PyBool_Type, &obj1)) {
// true is the default
Operators::reset(obj1 ? bool_from_PyBool(obj1) : true);
}
else {
PyErr_SetString(PyExc_RuntimeError, "Operators.reset() failed");
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -596,15 +596,15 @@ static PyObject *Operators_get_viewedge_from_index(BPy_Operators * /*self*/,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"i", NULL};
+ static const char *kwlist[] = {"i", nullptr};
unsigned int i;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &i)) {
- return NULL;
+ return nullptr;
}
if (i >= Operators::getViewEdgesSize()) {
PyErr_SetString(PyExc_IndexError, "index out of range");
- return NULL;
+ return nullptr;
}
return BPy_ViewEdge_from_ViewEdge(*(Operators::getViewEdgeFromIndex(i)));
}
@@ -623,15 +623,15 @@ static PyObject *Operators_get_chain_from_index(BPy_Operators * /*self*/,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"i", NULL};
+ static const char *kwlist[] = {"i", nullptr};
unsigned int i;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &i)) {
- return NULL;
+ return nullptr;
}
if (i >= Operators::getChainsSize()) {
PyErr_SetString(PyExc_IndexError, "index out of range");
- return NULL;
+ return nullptr;
}
return BPy_Chain_from_Chain(*(Operators::getChainFromIndex(i)));
}
@@ -650,15 +650,15 @@ static PyObject *Operators_get_stroke_from_index(BPy_Operators * /*self*/,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"i", NULL};
+ static const char *kwlist[] = {"i", nullptr};
unsigned int i;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &i)) {
- return NULL;
+ return nullptr;
}
if (i >= Operators::getStrokesSize()) {
PyErr_SetString(PyExc_IndexError, "index out of range");
- return NULL;
+ return nullptr;
}
return BPy_Stroke_from_Stroke(*(Operators::getStrokeFromIndex(i)));
}
@@ -760,49 +760,53 @@ static PyMethodDef BPy_Operators_methods[] = {
(PyCFunction)Operators_get_strokes_size,
METH_NOARGS | METH_STATIC,
Operators_get_strokes_size_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*-----------------------BPy_Operators type definition ------------------------------*/
PyTypeObject Operators_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Operators", /* tp_name */
- sizeof(BPy_Operators), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)Operators_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- Operators_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_Operators_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Operators", /* tp_name */
+ sizeof(BPy_Operators), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)Operators_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Operators_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ BPy_Operators_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ nullptr, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp
index b1d5f8f4aac..ed83e76559f 100644
--- a/source/blender/freestyle/intern/python/BPy_SShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp
@@ -35,7 +35,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int SShape_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -65,8 +65,8 @@ PyDoc_STRVAR(
static int SShape_init(BPy_SShape *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"brother", NULL};
- PyObject *brother = 0;
+ static const char *kwlist[] = {"brother", nullptr};
+ PyObject *brother = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &SShape_Type, &brother)) {
return -1;
@@ -104,11 +104,11 @@ static char SShape_add_edge_doc[] =
static PyObject *SShape_add_edge(BPy_SShape *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"edge", NULL};
- PyObject *py_fe = 0;
+ static const char *kwlist[] = {"edge", nullptr};
+ PyObject *py_fe = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe)) {
- return NULL;
+ return nullptr;
}
self->ss->AddEdge(((BPy_FEdge *)py_fe)->fe);
Py_RETURN_NONE;
@@ -125,11 +125,11 @@ PyDoc_STRVAR(SShape_add_vertex_doc,
static PyObject *SShape_add_vertex(BPy_SShape *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"edge", NULL};
- PyObject *py_sv = 0;
+ static const char *kwlist[] = {"edge", nullptr};
+ PyObject *py_sv = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &SVertex_Type, &py_sv)) {
- return NULL;
+ return nullptr;
}
self->ss->AddNewVertex(((BPy_SVertex *)py_sv)->sv);
Py_RETURN_NONE;
@@ -157,7 +157,7 @@ static PyMethodDef BPy_SShape_methods[] = {
METH_VARARGS | METH_KEYWORDS,
SShape_add_vertex_doc},
{"compute_bbox", (PyCFunction)SShape_compute_bbox, METH_NOARGS, SShape_compute_bbox_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------SShape get/setters ----------------------------*/
@@ -266,53 +266,57 @@ static PyObject *SShape_edges_get(BPy_SShape *self, void *UNUSED(closure))
}
static PyGetSetDef BPy_SShape_getseters[] = {
- {"id", (getter)SShape_id_get, (setter)SShape_id_set, SShape_id_doc, NULL},
- {"name", (getter)SShape_name_get, (setter)SShape_name_set, SShape_name_doc, NULL},
- {"bbox", (getter)SShape_bbox_get, (setter)SShape_bbox_set, SShape_bbox_doc, NULL},
- {"edges", (getter)SShape_edges_get, (setter)NULL, SShape_edges_doc, NULL},
- {"vertices", (getter)SShape_vertices_get, (setter)NULL, SShape_vertices_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ {"id", (getter)SShape_id_get, (setter)SShape_id_set, SShape_id_doc, nullptr},
+ {"name", (getter)SShape_name_get, (setter)SShape_name_set, SShape_name_doc, nullptr},
+ {"bbox", (getter)SShape_bbox_get, (setter)SShape_bbox_set, SShape_bbox_doc, nullptr},
+ {"edges", (getter)SShape_edges_get, (setter) nullptr, SShape_edges_doc, nullptr},
+ {"vertices", (getter)SShape_vertices_get, (setter) nullptr, SShape_vertices_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_SShape type definition ------------------------------*/
PyTypeObject SShape_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "SShape", /* tp_name */
- sizeof(BPy_SShape), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)SShape_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
+ PyVarObject_HEAD_INIT(nullptr, 0) "SShape", /* tp_name */
+ sizeof(BPy_SShape), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)SShape_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
(reprfunc)SShape_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
SShape_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
BPy_SShape_methods, /* tp_methods */
- 0, /* tp_members */
+ nullptr, /* tp_members */
BPy_SShape_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)SShape_init, /* tp_init */
- 0, /* tp_alloc */
+ nullptr, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
index 3718fddcf20..8f706f56f7d 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
@@ -31,7 +31,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int StrokeAttribute_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -84,11 +84,11 @@ PyDoc_STRVAR(StrokeAttribute_doc,
static int StrokeAttribute_init(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"attribute1", "attribute2", "t", NULL};
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"attribute1", "attribute2", "t", nullptr};
static const char *kwlist_3[] = {
- "red", "green", "blue", "alpha", "thickness_right", "thickness_left", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ "red", "green", "blue", "alpha", "thickness_right", "thickness_left", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
float red, green, blue, alpha, thickness_right, thickness_left, t;
if (PyArg_ParseTupleAndKeywords(
@@ -166,11 +166,11 @@ static PyObject *StrokeAttribute_get_attribute_real(BPy_StrokeAttribute *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"name", NULL};
+ static const char *kwlist[] = {"name", nullptr};
char *attr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
- return NULL;
+ return nullptr;
}
double a = self->sa->getAttributeReal(attr);
return PyFloat_FromDouble(a);
@@ -190,11 +190,11 @@ static PyObject *StrokeAttribute_get_attribute_vec2(BPy_StrokeAttribute *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"name", NULL};
+ static const char *kwlist[] = {"name", nullptr};
char *attr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
- return NULL;
+ return nullptr;
}
Vec2f a = self->sa->getAttributeVec2f(attr);
return Vector_from_Vec2f(a);
@@ -214,11 +214,11 @@ static PyObject *StrokeAttribute_get_attribute_vec3(BPy_StrokeAttribute *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"name", NULL};
+ static const char *kwlist[] = {"name", nullptr};
char *attr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
- return NULL;
+ return nullptr;
}
Vec3f a = self->sa->getAttributeVec3f(attr);
return Vector_from_Vec3f(a);
@@ -238,11 +238,11 @@ static PyObject *StrokeAttribute_has_attribute_real(BPy_StrokeAttribute *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"name", NULL};
+ static const char *kwlist[] = {"name", nullptr};
char *attr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
- return NULL;
+ return nullptr;
}
return PyBool_from_bool(self->sa->isAttributeAvailableReal(attr));
}
@@ -262,11 +262,11 @@ static PyObject *StrokeAttribute_has_attribute_vec2(BPy_StrokeAttribute *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"name", NULL};
+ static const char *kwlist[] = {"name", nullptr};
char *attr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
- return NULL;
+ return nullptr;
}
return PyBool_from_bool(self->sa->isAttributeAvailableVec2f(attr));
}
@@ -286,11 +286,11 @@ static PyObject *StrokeAttribute_has_attribute_vec3(BPy_StrokeAttribute *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"name", NULL};
+ static const char *kwlist[] = {"name", nullptr};
char *attr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
- return NULL;
+ return nullptr;
}
return PyBool_from_bool(self->sa->isAttributeAvailableVec3f(attr));
}
@@ -311,12 +311,12 @@ static PyObject *StrokeAttribute_set_attribute_real(BPy_StrokeAttribute *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"name", "value", NULL};
- char *s = 0;
+ static const char *kwlist[] = {"name", "value", nullptr};
+ char *s = nullptr;
double d = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sd", (char **)kwlist, &s, &d)) {
- return NULL;
+ return nullptr;
}
self->sa->setAttributeReal(s, d);
Py_RETURN_NONE;
@@ -338,18 +338,18 @@ static PyObject *StrokeAttribute_set_attribute_vec2(BPy_StrokeAttribute *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"name", "value", NULL};
+ static const char *kwlist[] = {"name", "value", nullptr};
char *s;
- PyObject *obj = 0;
+ PyObject *obj = nullptr;
Vec2f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO", (char **)kwlist, &s, &obj)) {
- return NULL;
+ return nullptr;
}
if (!Vec2f_ptr_from_PyObject(obj, vec)) {
PyErr_SetString(PyExc_TypeError,
"argument 2 must be a 2D vector (either a list of 2 elements or Vector)");
- return NULL;
+ return nullptr;
}
self->sa->setAttributeVec2f(s, vec);
Py_RETURN_NONE;
@@ -371,18 +371,18 @@ static PyObject *StrokeAttribute_set_attribute_vec3(BPy_StrokeAttribute *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"name", "value", NULL};
+ static const char *kwlist[] = {"name", "value", nullptr};
char *s;
- PyObject *obj = 0;
+ PyObject *obj = nullptr;
Vec3f vec;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO", (char **)kwlist, &s, &obj)) {
- return NULL;
+ return nullptr;
}
if (!Vec3f_ptr_from_PyObject(obj, vec)) {
PyErr_SetString(PyExc_TypeError,
"argument 2 must be a 3D vector (either a list of 3 elements or Vector)");
- return NULL;
+ return nullptr;
}
self->sa->setAttributeVec3f(s, vec);
Py_RETURN_NONE;
@@ -425,7 +425,7 @@ static PyMethodDef BPy_StrokeAttribute_methods[] = {
(PyCFunction)StrokeAttribute_set_attribute_vec3,
METH_VARARGS | METH_KEYWORDS,
StrokeAttribute_set_attribute_vec3_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------mathutils callbacks ----------------------------*/
@@ -651,65 +651,69 @@ static PyGetSetDef BPy_StrokeAttribute_getseters[] = {
(getter)StrokeAttribute_alpha_get,
(setter)StrokeAttribute_alpha_set,
StrokeAttribute_alpha_doc,
- NULL},
+ nullptr},
{"color",
(getter)StrokeAttribute_color_get,
(setter)StrokeAttribute_color_set,
StrokeAttribute_color_doc,
- NULL},
+ nullptr},
{"thickness",
(getter)StrokeAttribute_thickness_get,
(setter)StrokeAttribute_thickness_set,
StrokeAttribute_thickness_doc,
- NULL},
+ nullptr},
{"visible",
(getter)StrokeAttribute_visible_get,
(setter)StrokeAttribute_visible_set,
StrokeAttribute_visible_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_StrokeAttribute type definition ------------------------------*/
PyTypeObject StrokeAttribute_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "StrokeAttribute", /* tp_name */
- sizeof(BPy_StrokeAttribute), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)StrokeAttribute_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)StrokeAttribute_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- StrokeAttribute_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_StrokeAttribute_methods, /* tp_methods */
- 0, /* tp_members */
- BPy_StrokeAttribute_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)StrokeAttribute_init, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "StrokeAttribute", /* tp_name */
+ sizeof(BPy_StrokeAttribute), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)StrokeAttribute_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)StrokeAttribute_repr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ StrokeAttribute_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ BPy_StrokeAttribute_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_StrokeAttribute_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)StrokeAttribute_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
index 5e5685153af..b55da256c22 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
@@ -51,7 +51,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int StrokeShader_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -198,7 +198,7 @@ static char StrokeShader___doc__[] =
static int StrokeShader___init__(BPy_StrokeShader *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -229,23 +229,23 @@ static char StrokeShader_shade___doc__[] =
static PyObject *StrokeShader_shade(BPy_StrokeShader *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"stroke", NULL};
- PyObject *py_s = 0;
+ static const char *kwlist[] = {"stroke", nullptr};
+ PyObject *py_s = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Stroke_Type, &py_s)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->ss)) == typeid(StrokeShader)) {
PyErr_SetString(PyExc_TypeError, "shade method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->ss->shade(*(((BPy_Stroke *)py_s)->s)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " shade method failed").c_str());
}
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -255,7 +255,7 @@ static PyMethodDef BPy_StrokeShader_methods[] = {
(PyCFunction)StrokeShader_shade,
METH_VARARGS | METH_KEYWORDS,
StrokeShader_shade___doc__},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------StrokeShader get/setters ----------------------------*/
@@ -271,50 +271,54 @@ static PyObject *StrokeShader_name_get(BPy_StrokeShader *self, void *UNUSED(clos
}
static PyGetSetDef BPy_StrokeShader_getseters[] = {
- {"name", (getter)StrokeShader_name_get, (setter)NULL, StrokeShader_name_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ {"name", (getter)StrokeShader_name_get, (setter) nullptr, StrokeShader_name_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_StrokeShader type definition ------------------------------*/
PyTypeObject StrokeShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "StrokeShader", /* tp_name */
- sizeof(BPy_StrokeShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)StrokeShader___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)StrokeShader___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- StrokeShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_StrokeShader_methods, /* tp_methods */
- 0, /* tp_members */
- BPy_StrokeShader_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)StrokeShader___init__, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "StrokeShader", /* tp_name */
+ sizeof(BPy_StrokeShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)StrokeShader___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)StrokeShader___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ StrokeShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ BPy_StrokeShader_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_StrokeShader_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)StrokeShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp
index 6214ea94f41..78c93ddce31 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp
@@ -40,7 +40,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int UnaryFunction0D_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -109,50 +109,58 @@ static PyObject *UnaryFunction0D_name_get(BPy_UnaryFunction0D *self, void *UNUSE
}
static PyGetSetDef BPy_UnaryFunction0D_getseters[] = {
- {"name", (getter)UnaryFunction0D_name_get, (setter)NULL, UnaryFunction0D_name_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ {"name",
+ (getter)UnaryFunction0D_name_get,
+ (setter) nullptr,
+ UnaryFunction0D_name_doc,
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryFunction0D type definition ------------------------------*/
PyTypeObject UnaryFunction0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0D", /* tp_name */
- sizeof(BPy_UnaryFunction0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction0D___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction0D___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryFunction0D_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0D", /* tp_name */
+ sizeof(BPy_UnaryFunction0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction0D___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction0D___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryFunction0D_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ nullptr, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp
index 18d6479a498..365850b748c 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp
@@ -38,7 +38,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int UnaryFunction1D_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -103,50 +103,58 @@ static PyObject *UnaryFunction1D_name_get(BPy_UnaryFunction1D *self, void *UNUSE
}
static PyGetSetDef BPy_UnaryFunction1D_getseters[] = {
- {"name", (getter)UnaryFunction1D_name_get, (setter)NULL, UnaryFunction1D_name_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ {"name",
+ (getter)UnaryFunction1D_name_get,
+ (setter) nullptr,
+ UnaryFunction1D_name_doc,
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryFunction1D type definition ------------------------------*/
PyTypeObject UnaryFunction1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1D", /* tp_name */
- sizeof(BPy_UnaryFunction1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction1D___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction1D___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryFunction1D_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction1D", /* tp_name */
+ sizeof(BPy_UnaryFunction1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction1D___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction1D___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryFunction1D_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ nullptr, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
index ddbb55fdb4d..e3076d4615f 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
@@ -34,7 +34,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int UnaryPredicate0D_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -85,7 +85,7 @@ static char UnaryPredicate0D___doc__[] =
static int UnaryPredicate0D___init__(BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -110,12 +110,12 @@ static PyObject *UnaryPredicate0D___call__(BPy_UnaryPredicate0D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *py_if0D_it;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &py_if0D_it)) {
- return NULL;
+ return nullptr;
}
Interface0DIterator *if0D_it = ((BPy_Interface0DIterator *)py_if0D_it)->if0D_it;
@@ -123,18 +123,18 @@ static PyObject *UnaryPredicate0D___call__(BPy_UnaryPredicate0D *self,
if (!if0D_it) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " has no Interface0DIterator").c_str());
- return NULL;
+ return nullptr;
}
if (typeid(*(self->up0D)) == typeid(UnaryPredicate0D)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->up0D->operator()(*if0D_it) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return PyBool_from_bool(self->up0D->result);
}
@@ -152,50 +152,58 @@ static PyObject *UnaryPredicate0D_name_get(BPy_UnaryPredicate0D *self, void *UNU
}
static PyGetSetDef BPy_UnaryPredicate0D_getseters[] = {
- {"name", (getter)UnaryPredicate0D_name_get, (setter)NULL, UnaryPredicate0D_name_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ {"name",
+ (getter)UnaryPredicate0D_name_get,
+ (setter) nullptr,
+ UnaryPredicate0D_name_doc,
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryPredicate0D type definition ------------------------------*/
PyTypeObject UnaryPredicate0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryPredicate0D", /* tp_name */
- sizeof(BPy_UnaryPredicate0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryPredicate0D___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryPredicate0D___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryPredicate0D___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryPredicate0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryPredicate0D_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryPredicate0D___init__, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryPredicate0D", /* tp_name */
+ sizeof(BPy_UnaryPredicate0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryPredicate0D___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryPredicate0D___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryPredicate0D___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryPredicate0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryPredicate0D_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryPredicate0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
index 11e77fa365a..4b5269a1434 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
@@ -43,7 +43,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int UnaryPredicate1D_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -143,7 +143,7 @@ static char UnaryPredicate1D___doc__[] =
static int UnaryPredicate1D___init__(BPy_UnaryPredicate1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -168,12 +168,12 @@ static PyObject *UnaryPredicate1D___call__(BPy_UnaryPredicate1D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"inter", NULL};
+ static const char *kwlist[] = {"inter", nullptr};
PyObject *py_if1D;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &py_if1D)) {
- return NULL;
+ return nullptr;
}
Interface1D *if1D = ((BPy_Interface1D *)py_if1D)->if1D;
@@ -181,18 +181,18 @@ static PyObject *UnaryPredicate1D___call__(BPy_UnaryPredicate1D *self,
if (!if1D) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " has no Interface1D").c_str());
- return NULL;
+ return nullptr;
}
if (typeid(*(self->up1D)) == typeid(UnaryPredicate1D)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->up1D->operator()(*if1D) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return PyBool_from_bool(self->up1D->result);
}
@@ -210,50 +210,58 @@ static PyObject *UnaryPredicate1D_name_get(BPy_UnaryPredicate1D *self, void *UNU
}
static PyGetSetDef BPy_UnaryPredicate1D_getseters[] = {
- {"name", (getter)UnaryPredicate1D_name_get, (setter)NULL, UnaryPredicate1D_name_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ {"name",
+ (getter)UnaryPredicate1D_name_get,
+ (setter) nullptr,
+ UnaryPredicate1D_name_doc,
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryPredicate1D type definition ------------------------------*/
PyTypeObject UnaryPredicate1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryPredicate1D", /* tp_name */
- sizeof(BPy_UnaryPredicate1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryPredicate1D___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryPredicate1D___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryPredicate1D___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryPredicate1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryPredicate1D_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryPredicate1D___init__, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryPredicate1D", /* tp_name */
+ sizeof(BPy_UnaryPredicate1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryPredicate1D___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryPredicate1D___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryPredicate1D___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryPredicate1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryPredicate1D_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryPredicate1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
index 67a4249ade8..8565a95fc1a 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
@@ -34,7 +34,7 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
int ViewMap_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -58,7 +58,7 @@ PyDoc_STRVAR(ViewMap_doc,
static int ViewMap_init(BPy_ViewMap *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -92,11 +92,11 @@ PyDoc_STRVAR(ViewMap_get_closest_viewedge_doc,
static PyObject *ViewMap_get_closest_viewedge(BPy_ViewMap *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"x", "y", NULL};
+ static const char *kwlist[] = {"x", "y", nullptr};
double x, y;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "dd", (char **)kwlist, &x, &y)) {
- return NULL;
+ return nullptr;
}
ViewEdge *ve = const_cast<ViewEdge *>(self->vm->getClosestViewEdge(x, y));
if (ve) {
@@ -119,11 +119,11 @@ PyDoc_STRVAR(ViewMap_get_closest_fedge_doc,
static PyObject *ViewMap_get_closest_fedge(BPy_ViewMap *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"x", "y", NULL};
+ static const char *kwlist[] = {"x", "y", nullptr};
double x, y;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "dd", (char **)kwlist, &x, &y)) {
- return NULL;
+ return nullptr;
}
FEdge *fe = const_cast<FEdge *>(self->vm->getClosestFEdge(x, y));
if (fe) {
@@ -143,7 +143,7 @@ static PyMethodDef BPy_ViewMap_methods[] = {
(PyCFunction)ViewMap_get_closest_fedge,
METH_VARARGS | METH_KEYWORDS,
ViewMap_get_closest_fedge_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------ViewMap get/setters ----------------------------*/
@@ -173,49 +173,53 @@ static PyGetSetDef BPy_ViewMap_getseters[] = {
(getter)ViewMap_scene_bbox_get,
(setter)ViewMap_scene_bbox_set,
ViewMap_scene_bbox_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_ViewMap type definition ------------------------------*/
PyTypeObject ViewMap_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ViewMap", /* tp_name */
- sizeof(BPy_ViewMap), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)ViewMap_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ViewMap", /* tp_name */
+ sizeof(BPy_ViewMap), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)ViewMap_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
(reprfunc)ViewMap_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
ViewMap_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
BPy_ViewMap_methods, /* tp_methods */
- 0, /* tp_members */
+ nullptr, /* tp_members */
BPy_ViewMap_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)ViewMap_init, /* tp_init */
- 0, /* tp_alloc */
+ nullptr, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
index 7d8b5ef6fa9..6c8551867fd 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
@@ -35,7 +35,7 @@ extern "C" {
int ViewShape_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -68,14 +68,14 @@ PyDoc_STRVAR(ViewShape_doc,
static int ViewShape_init(BPy_ViewShape *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"sshape", NULL};
- PyObject *obj = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"sshape", nullptr};
+ PyObject *obj = nullptr;
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &ViewShape_Type, &obj)) {
if (!obj) {
self->vs = new ViewShape();
- self->py_ss = NULL;
+ self->py_ss = nullptr;
}
else {
self->vs = new ViewShape(*(((BPy_ViewShape *)obj)->vs));
@@ -86,7 +86,7 @@ static int ViewShape_init(BPy_ViewShape *self, PyObject *args, PyObject *kwds)
PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &SShape_Type, &obj)) {
BPy_SShape *py_ss = (BPy_SShape *)obj;
self->vs = new ViewShape(py_ss->ss);
- self->py_ss = (!py_ss->borrowed) ? py_ss : NULL;
+ self->py_ss = (!py_ss->borrowed) ? py_ss : nullptr;
}
else {
PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
@@ -100,7 +100,7 @@ static int ViewShape_init(BPy_ViewShape *self, PyObject *args, PyObject *kwds)
static void ViewShape_dealloc(BPy_ViewShape *self)
{
if (self->py_ss) {
- self->vs->setSShape((SShape *)NULL);
+ self->vs->setSShape((SShape *)nullptr);
Py_DECREF(self->py_ss);
}
if (self->vs && !self->borrowed) {
@@ -124,11 +124,11 @@ PyDoc_STRVAR(ViewShape_add_edge_doc,
static PyObject *ViewShape_add_edge(BPy_ViewShape *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"edge", NULL};
- PyObject *py_ve = 0;
+ static const char *kwlist[] = {"edge", nullptr};
+ PyObject *py_ve = nullptr;
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) {
- return NULL;
+ return nullptr;
}
self->vs->AddEdge(((BPy_ViewEdge *)py_ve)->ve);
Py_RETURN_NONE;
@@ -144,11 +144,11 @@ PyDoc_STRVAR(ViewShape_add_vertex_doc,
static PyObject *ViewShape_add_vertex(BPy_ViewShape *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"vertex", NULL};
- PyObject *py_vv = 0;
+ static const char *kwlist[] = {"vertex", nullptr};
+ PyObject *py_vv = nullptr;
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewVertex_Type, &py_vv)) {
- return NULL;
+ return nullptr;
}
self->vs->AddVertex(((BPy_ViewVertex *)py_vv)->vv);
Py_RETURN_NONE;
@@ -165,7 +165,7 @@ static PyMethodDef BPy_ViewShape_methods[] = {
(PyCFunction)ViewShape_add_vertex,
METH_VARARGS | METH_KEYWORDS,
ViewShape_add_vertex_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------ViewShape get/setters ----------------------------*/
@@ -324,63 +324,71 @@ static PyGetSetDef BPy_ViewShape_getseters[] = {
(getter)ViewShape_sshape_get,
(setter)ViewShape_sshape_set,
ViewShape_sshape_doc,
- NULL},
+ nullptr},
{"vertices",
(getter)ViewShape_vertices_get,
(setter)ViewShape_vertices_set,
ViewShape_vertices_doc,
- NULL},
- {"edges", (getter)ViewShape_edges_get, (setter)ViewShape_edges_set, ViewShape_edges_doc, NULL},
- {"name", (getter)ViewShape_name_get, (setter)NULL, ViewShape_name_doc, NULL},
+ nullptr},
+ {"edges",
+ (getter)ViewShape_edges_get,
+ (setter)ViewShape_edges_set,
+ ViewShape_edges_doc,
+ nullptr},
+ {"name", (getter)ViewShape_name_get, (setter) nullptr, ViewShape_name_doc, nullptr},
{"library_path",
(getter)ViewShape_library_path_get,
- (setter)NULL,
+ (setter) nullptr,
ViewShape_library_path_doc,
- NULL},
- {"id", (getter)ViewShape_id_get, (setter)NULL, ViewShape_id_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {"id", (getter)ViewShape_id_get, (setter) nullptr, ViewShape_id_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_ViewShape type definition ------------------------------*/
PyTypeObject ViewShape_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ViewShape", /* tp_name */
- sizeof(BPy_ViewShape), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)ViewShape_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)ViewShape_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ViewShape_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_ViewShape_methods, /* tp_methods */
- 0, /* tp_members */
- BPy_ViewShape_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ViewShape_init, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ViewShape", /* tp_name */
+ sizeof(BPy_ViewShape), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)ViewShape_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)ViewShape_repr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ViewShape_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ BPy_ViewShape_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_ViewShape_getseters, /* tp_getset */
+ nullptr, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ViewShape_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp
index 65c7f063dcf..e284f28cd0b 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp
@@ -44,7 +44,7 @@ static char FalseBP1D___doc__[] =
static int FalseBP1D___init__(BPy_FalseBP1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -55,43 +55,47 @@ static int FalseBP1D___init__(BPy_FalseBP1D *self, PyObject *args, PyObject *kwd
/*-----------------------BPy_FalseBP1D type definition ------------------------------*/
PyTypeObject FalseBP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "FalseBP1D", /* tp_name */
- sizeof(BPy_FalseBP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- FalseBP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &BinaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)FalseBP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "FalseBP1D", /* tp_name */
+ sizeof(BPy_FalseBP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ FalseBP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &BinaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)FalseBP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp
index 59c3283ed35..2c84f69dd6e 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp
@@ -45,7 +45,7 @@ static char Length2DBP1D___doc__[] =
static int Length2DBP1D___init__(BPy_Length2DBP1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -57,43 +57,47 @@ static int Length2DBP1D___init__(BPy_Length2DBP1D *self, PyObject *args, PyObjec
/*-----------------------BPy_Length2DBP1D type definition ------------------------------*/
PyTypeObject Length2DBP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Length2DBP1D", /* tp_name */
- sizeof(BPy_Length2DBP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Length2DBP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &BinaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Length2DBP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Length2DBP1D", /* tp_name */
+ sizeof(BPy_Length2DBP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Length2DBP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &BinaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Length2DBP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp
index 62bfbbcfad0..ab79ae4e209 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp
@@ -44,7 +44,7 @@ static char SameShapeIdBP1D___doc__[] =
static int SameShapeIdBP1D___init__(BPy_SameShapeIdBP1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -56,43 +56,47 @@ static int SameShapeIdBP1D___init__(BPy_SameShapeIdBP1D *self, PyObject *args, P
/*-----------------------BPy_SameShapeIdBP1D type definition ------------------------------*/
PyTypeObject SameShapeIdBP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "SameShapeIdBP1D", /* tp_name */
- sizeof(BPy_SameShapeIdBP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- SameShapeIdBP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &BinaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)SameShapeIdBP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "SameShapeIdBP1D", /* tp_name */
+ sizeof(BPy_SameShapeIdBP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ SameShapeIdBP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &BinaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)SameShapeIdBP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp
index e169ffe7c75..47c3c6b53aa 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp
@@ -44,7 +44,7 @@ static char TrueBP1D___doc__[] =
static int TrueBP1D___init__(BPy_TrueBP1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -56,43 +56,47 @@ static int TrueBP1D___init__(BPy_TrueBP1D *self, PyObject *args, PyObject *kwds)
/*-----------------------BPy_TrueBP1D type definition ------------------------------*/
PyTypeObject TrueBP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "TrueBP1D", /* tp_name */
- sizeof(BPy_TrueBP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- TrueBP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &BinaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)TrueBP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "TrueBP1D", /* tp_name */
+ sizeof(BPy_TrueBP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ TrueBP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &BinaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)TrueBP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
index ec660b7a7fe..9d69b1c902c 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
@@ -69,8 +69,8 @@ static int ViewMapGradientNormBP1D___init__(BPy_ViewMapGradientNormBP1D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"level", "integration_type", "sampling", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"level", "integration_type", "sampling", nullptr};
+ PyObject *obj = nullptr;
int i;
float f = 2.0;
@@ -86,43 +86,47 @@ static int ViewMapGradientNormBP1D___init__(BPy_ViewMapGradientNormBP1D *self,
/*-----------------------BPy_ViewMapGradientNormBP1D type definition ----------------------------*/
PyTypeObject ViewMapGradientNormBP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ViewMapGradientNormBP1D", /* tp_name */
- sizeof(BPy_ViewMapGradientNormBP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ViewMapGradientNormBP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &BinaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ViewMapGradientNormBP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ViewMapGradientNormBP1D", /* tp_name */
+ sizeof(BPy_ViewMapGradientNormBP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ViewMapGradientNormBP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &BinaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ViewMapGradientNormBP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp
index 0769b30ebb7..ff1d63f5f58 100644
--- a/source/blender/freestyle/intern/python/Director.cpp
+++ b/source/blender/freestyle/intern/python/Director.cpp
@@ -195,7 +195,7 @@ int Director_BPy_ChainingIterator_init(ChainingIterator *c_it)
PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_c_it) not initialized");
return -1;
}
- PyObject *result = PyObject_CallMethod((PyObject *)c_it->py_c_it, "init", NULL);
+ PyObject *result = PyObject_CallMethod((PyObject *)c_it->py_c_it, "init", nullptr);
if (!result) {
return -1;
}
@@ -222,7 +222,7 @@ int Director_BPy_ChainingIterator_traverse(ChainingIterator *c_it, AdjacencyIter
c_it->result = ((BPy_ViewEdge *)result)->ve;
}
else if (result == Py_None) {
- c_it->result = NULL;
+ c_it->result = nullptr;
}
else {
PyErr_SetString(PyExc_RuntimeError, "traverse method returned a wrong value");
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
index 7b3571c479f..f70f70275df 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
@@ -69,10 +69,10 @@ PyDoc_STRVAR(CurvePoint_doc,
static int CurvePoint_init(BPy_CurvePoint *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"first_vertex", "second_vertex", "t2d", NULL};
- static const char *kwlist_3[] = {"first_point", "second_point", "t2d", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"first_vertex", "second_vertex", "t2d", nullptr};
+ static const char *kwlist_3[] = {"first_point", "second_point", "t2d", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
float t2d;
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &CurvePoint_Type, &obj1)) {
@@ -107,11 +107,11 @@ static int CurvePoint_init(BPy_CurvePoint *self, PyObject *args, PyObject *kwds)
&t2d)) {
CurvePoint *cp1 = ((BPy_CurvePoint *)obj1)->cp;
CurvePoint *cp2 = ((BPy_CurvePoint *)obj2)->cp;
- if (!cp1 || cp1->A() == 0 || cp1->B() == 0) {
+ if (!cp1 || cp1->A() == nullptr || cp1->B() == nullptr) {
PyErr_SetString(PyExc_TypeError, "argument 1 is an invalid CurvePoint object");
return -1;
}
- if (!cp2 || cp2->A() == 0 || cp2->B() == 0) {
+ if (!cp2 || cp2->A() == nullptr || cp2->B() == nullptr) {
PyErr_SetString(PyExc_TypeError, "argument 2 is an invalid CurvePoint object");
return -1;
}
@@ -225,56 +225,60 @@ static PyGetSetDef BPy_CurvePoint_getseters[] = {
(getter)CurvePoint_first_svertex_get,
(setter)CurvePoint_first_svertex_set,
CurvePoint_first_svertex_doc,
- NULL},
+ nullptr},
{"second_svertex",
(getter)CurvePoint_second_svertex_get,
(setter)CurvePoint_second_svertex_set,
CurvePoint_second_svertex_doc,
- NULL},
- {"fedge", (getter)CurvePoint_fedge_get, NULL, CurvePoint_fedge_doc, NULL},
- {"t2d", (getter)CurvePoint_t2d_get, (setter)CurvePoint_t2d_set, CurvePoint_t2d_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {"fedge", (getter)CurvePoint_fedge_get, nullptr, CurvePoint_fedge_doc, nullptr},
+ {"t2d", (getter)CurvePoint_t2d_get, (setter)CurvePoint_t2d_set, CurvePoint_t2d_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_CurvePoint type definition ------------------------------*/
PyTypeObject CurvePoint_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "CurvePoint", /* tp_name */
- sizeof(BPy_CurvePoint), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- CurvePoint_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_CurvePoint_getseters, /* tp_getset */
- &Interface0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)CurvePoint_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "CurvePoint", /* tp_name */
+ sizeof(BPy_CurvePoint), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ CurvePoint_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_CurvePoint_getseters, /* tp_getset */
+ &Interface0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)CurvePoint_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
index 63725c6b0e8..b245ecd81f1 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
@@ -54,9 +54,9 @@ PyDoc_STRVAR(SVertex_doc,
static int SVertex_init(BPy_SVertex *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"point_3d", "id", NULL};
- PyObject *obj = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"point_3d", "id", nullptr};
+ PyObject *obj = nullptr;
float v[3];
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &SVertex_Type, &obj)) {
@@ -93,17 +93,17 @@ PyDoc_STRVAR(SVertex_add_normal_doc,
static PyObject *SVertex_add_normal(BPy_SVertex *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"normal", NULL};
+ static const char *kwlist[] = {"normal", nullptr};
PyObject *py_normal;
Vec3r n;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &py_normal)) {
- return NULL;
+ return nullptr;
}
if (!Vec3r_ptr_from_PyObject(py_normal, n)) {
PyErr_SetString(PyExc_TypeError,
"argument 1 must be a 3D vector (either a list of 3 elements or Vector)");
- return NULL;
+ return nullptr;
}
self->sv->AddNormal(n);
Py_RETURN_NONE;
@@ -119,11 +119,11 @@ PyDoc_STRVAR(SVertex_add_fedge_doc,
static PyObject *SVertex_add_fedge(BPy_SVertex *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"fedge", NULL};
+ static const char *kwlist[] = {"fedge", nullptr};
PyObject *py_fe;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe)) {
- return NULL;
+ return nullptr;
}
self->sv->AddFEdge(((BPy_FEdge *)py_fe)->fe);
Py_RETURN_NONE;
@@ -140,7 +140,7 @@ static PyMethodDef BPy_SVertex_methods[] = {
(PyCFunction)SVertex_add_fedge,
METH_VARARGS | METH_KEYWORDS,
SVertex_add_fedge_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------mathutils callbacks ----------------------------*/
@@ -423,63 +423,75 @@ static PyGetSetDef BPy_SVertex_getseters[] = {
(getter)SVertex_point_3d_get,
(setter)SVertex_point_3d_set,
SVertex_point_3d_doc,
- NULL},
+ nullptr},
{"point_2d",
(getter)SVertex_point_2d_get,
(setter)SVertex_point_2d_set,
SVertex_point_2d_doc,
- NULL},
- {"id", (getter)SVertex_id_get, (setter)SVertex_id_set, SVertex_id_doc, NULL},
- {"normals", (getter)SVertex_normals_get, (setter)NULL, SVertex_normals_doc, NULL},
+ nullptr},
+ {"id", (getter)SVertex_id_get, (setter)SVertex_id_set, SVertex_id_doc, nullptr},
+ {"normals", (getter)SVertex_normals_get, (setter) nullptr, SVertex_normals_doc, nullptr},
{"normals_size",
(getter)SVertex_normals_size_get,
- (setter)NULL,
+ (setter) nullptr,
SVertex_normals_size_doc,
- NULL},
- {"viewvertex", (getter)SVertex_viewvertex_get, (setter)NULL, SVertex_viewvertex_doc, NULL},
- {"curvatures", (getter)SVertex_curvatures_get, (setter)NULL, SVertex_curvatures_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {"viewvertex",
+ (getter)SVertex_viewvertex_get,
+ (setter) nullptr,
+ SVertex_viewvertex_doc,
+ nullptr},
+ {"curvatures",
+ (getter)SVertex_curvatures_get,
+ (setter) nullptr,
+ SVertex_curvatures_doc,
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_SVertex type definition ------------------------------*/
PyTypeObject SVertex_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "SVertex", /* tp_name */
- sizeof(BPy_SVertex), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ PyVarObject_HEAD_INIT(nullptr, 0) "SVertex", /* tp_name */
+ sizeof(BPy_SVertex), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
SVertex_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
BPy_SVertex_methods, /* tp_methods */
- 0, /* tp_members */
+ nullptr, /* tp_members */
BPy_SVertex_getseters, /* tp_getset */
&Interface0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)SVertex_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
index c947f37397b..696b3022e85 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
@@ -85,7 +85,7 @@ static PyObject *ViewVertex_edges_end(BPy_ViewVertex * /*self*/)
return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator(ove_it, 1);
#else
PyErr_SetString(PyExc_NotImplementedError, "edges_end method currently disabled");
- return NULL;
+ return nullptr;
#endif
}
@@ -102,11 +102,11 @@ PyDoc_STRVAR(ViewVertex_edges_iterator_doc,
static PyObject *ViewVertex_edges_iterator(BPy_ViewVertex *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"edge", NULL};
+ static const char *kwlist[] = {"edge", nullptr};
PyObject *py_ve;
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) {
- return NULL;
+ return nullptr;
}
ViewEdge *ve = ((BPy_ViewEdge *)py_ve)->ve;
ViewVertexInternal::orientedViewEdgeIterator ove_it(self->vv->edgesIterator(ve));
@@ -120,7 +120,7 @@ static PyMethodDef BPy_ViewVertex_methods[] = {
(PyCFunction)ViewVertex_edges_iterator,
METH_VARARGS | METH_KEYWORDS,
ViewVertex_edges_iterator_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------ViewVertex get/setters ----------------------------*/
@@ -134,7 +134,7 @@ static PyObject *ViewVertex_nature_get(BPy_ViewVertex *self, void *UNUSED(closur
{
Nature::VertexNature nature = self->vv->getNature();
if (PyErr_Occurred()) {
- return NULL;
+ return nullptr;
}
return BPy_Nature_from_Nature(nature); // return a copy
}
@@ -154,49 +154,53 @@ static PyGetSetDef BPy_ViewVertex_getseters[] = {
(getter)ViewVertex_nature_get,
(setter)ViewVertex_nature_set,
ViewVertex_nature_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_ViewVertex type definition ------------------------------*/
PyTypeObject ViewVertex_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ViewVertex", /* tp_name */
- sizeof(BPy_ViewVertex), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ViewVertex_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_ViewVertex_methods, /* tp_methods */
- 0, /* tp_members */
- BPy_ViewVertex_getseters, /* tp_getset */
- &Interface0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ViewVertex_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ViewVertex", /* tp_name */
+ sizeof(BPy_ViewVertex), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ViewVertex_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ BPy_ViewVertex_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_ViewVertex_getseters, /* tp_getset */
+ &Interface0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ViewVertex_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
index 5c1a8f8482f..5e63e190356 100644
--- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
@@ -70,11 +70,11 @@ PyDoc_STRVAR(
static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"first_vertex", "second_vertex", "t3d", NULL};
- static const char *kwlist_3[] = {"point", NULL};
- static const char *kwlist_4[] = {"svertex", "attribute", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"first_vertex", "second_vertex", "t3d", nullptr};
+ static const char *kwlist_3[] = {"point", nullptr};
+ static const char *kwlist_4[] = {"svertex", "attribute", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
float t3d;
if (PyArg_ParseTupleAndKeywords(
@@ -102,11 +102,11 @@ static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *k
&t3d)) {
StrokeVertex *sv1 = ((BPy_StrokeVertex *)obj1)->sv;
StrokeVertex *sv2 = ((BPy_StrokeVertex *)obj2)->sv;
- if (!sv1 || (sv1->A() == 0 && sv1->B() == 0)) {
+ if (!sv1 || (sv1->A() == nullptr && sv1->B() == nullptr)) {
PyErr_SetString(PyExc_TypeError, "argument 1 is an invalid StrokeVertex object");
return -1;
}
- if (!sv2 || (sv2->A() == 0 && sv2->B() == 0)) {
+ if (!sv2 || (sv2->A() == nullptr && sv2->B() == nullptr)) {
PyErr_SetString(PyExc_TypeError, "argument 2 is an invalid StrokeVertex object");
return -1;
}
@@ -116,14 +116,14 @@ static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *k
PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist_3, &CurvePoint_Type, &obj1)) {
CurvePoint *cp = ((BPy_CurvePoint *)obj1)->cp;
- if (!cp || cp->A() == 0 || cp->B() == 0) {
+ if (!cp || cp->A() == nullptr || cp->B() == nullptr) {
PyErr_SetString(PyExc_TypeError, "argument 1 is an invalid CurvePoint object");
return -1;
}
self->sv = new StrokeVertex(cp);
}
else if ((void)PyErr_Clear(),
- (void)(obj2 = 0),
+ (void)(obj2 = nullptr),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!|O!",
@@ -335,65 +335,69 @@ static PyGetSetDef BPy_StrokeVertex_getseters[] = {
(getter)StrokeVertex_attribute_get,
(setter)StrokeVertex_attribute_set,
StrokeVertex_attribute_doc,
- NULL},
+ nullptr},
{"curvilinear_abscissa",
(getter)StrokeVertex_curvilinear_abscissa_get,
(setter)StrokeVertex_curvilinear_abscissa_set,
StrokeVertex_curvilinear_abscissa_doc,
- NULL},
+ nullptr},
{"point",
(getter)StrokeVertex_point_get,
(setter)StrokeVertex_point_set,
StrokeVertex_point_doc,
- NULL},
+ nullptr},
{"stroke_length",
(getter)StrokeVertex_stroke_length_get,
(setter)StrokeVertex_stroke_length_set,
StrokeVertex_stroke_length_doc,
- NULL},
- {"u", (getter)StrokeVertex_u_get, (setter)NULL, StrokeVertex_u_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {"u", (getter)StrokeVertex_u_get, (setter) nullptr, StrokeVertex_u_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_StrokeVertex type definition ------------------------------*/
PyTypeObject StrokeVertex_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "StrokeVertex", /* tp_name */
- sizeof(BPy_StrokeVertex), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- StrokeVertex_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_StrokeVertex_getseters, /* tp_getset */
- &CurvePoint_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)StrokeVertex_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "StrokeVertex", /* tp_name */
+ sizeof(BPy_StrokeVertex), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ StrokeVertex_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_StrokeVertex_getseters, /* tp_getset */
+ &CurvePoint_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)StrokeVertex_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
index ff53f5bfcbe..ed10f3e0af5 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
@@ -50,8 +50,8 @@ PyDoc_STRVAR(
static int NonTVertex_init(BPy_NonTVertex *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"svertex", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"svertex", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &SVertex_Type, &obj)) {
return -1;
@@ -99,49 +99,53 @@ static PyGetSetDef BPy_NonTVertex_getseters[] = {
(getter)NonTVertex_svertex_get,
(setter)NonTVertex_svertex_set,
NonTVertex_svertex_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_NonTVertex type definition ------------------------------*/
PyTypeObject NonTVertex_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "NonTVertex", /* tp_name */
- sizeof(BPy_NonTVertex), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- NonTVertex_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_NonTVertex_getseters, /* tp_getset */
- &ViewVertex_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)NonTVertex_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "NonTVertex", /* tp_name */
+ sizeof(BPy_NonTVertex), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NonTVertex_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_NonTVertex_getseters, /* tp_getset */
+ &ViewVertex_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)NonTVertex_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp
index 61755b4bbd8..596eec7a4e5 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp
@@ -51,7 +51,7 @@ PyDoc_STRVAR(TVertex_doc,
static int TVertex_init(BPy_TVertex *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -75,11 +75,11 @@ PyDoc_STRVAR(TVertex_get_svertex_doc,
static PyObject *TVertex_get_svertex(BPy_TVertex *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"fedge", NULL};
+ static const char *kwlist[] = {"fedge", nullptr};
PyObject *py_fe;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe)) {
- return NULL;
+ return nullptr;
}
SVertex *sv = self->tv->getSVertex(((BPy_FEdge *)py_fe)->fe);
if (sv) {
@@ -102,11 +102,11 @@ PyDoc_STRVAR(TVertex_get_mate_doc,
static PyObject *TVertex_get_mate(BPy_TVertex *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"viewedge", NULL};
+ static const char *kwlist[] = {"viewedge", nullptr};
PyObject *py_ve;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) {
- return NULL;
+ return nullptr;
}
ViewEdge *ve = self->tv->mate(((BPy_ViewEdge *)py_ve)->ve);
if (ve) {
@@ -124,7 +124,7 @@ static PyMethodDef BPy_TVertex_methods[] = {
(PyCFunction)TVertex_get_mate,
METH_VARARGS | METH_KEYWORDS,
TVertex_get_mate_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------TVertex get/setters ----------------------------*/
@@ -203,55 +203,59 @@ static PyGetSetDef BPy_TVertex_getseters[] = {
(getter)TVertex_front_svertex_get,
(setter)TVertex_front_svertex_set,
TVertex_front_svertex_doc,
- NULL},
+ nullptr},
{"back_svertex",
(getter)TVertex_back_svertex_get,
(setter)TVertex_back_svertex_set,
TVertex_back_svertex_doc,
- NULL},
- {"id", (getter)TVertex_id_get, (setter)TVertex_id_set, TVertex_id_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {"id", (getter)TVertex_id_get, (setter)TVertex_id_set, TVertex_id_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_TVertex type definition ------------------------------*/
PyTypeObject TVertex_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "TVertex", /* tp_name */
- sizeof(BPy_TVertex), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ PyVarObject_HEAD_INIT(nullptr, 0) "TVertex", /* tp_name */
+ sizeof(BPy_TVertex), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
TVertex_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
BPy_TVertex_methods, /* tp_methods */
- 0, /* tp_members */
+ nullptr, /* tp_members */
BPy_TVertex_getseters, /* tp_getset */
&ViewVertex_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)TVertex_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
index e04a89bad3b..0438abfd38c 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
@@ -62,9 +62,9 @@ PyDoc_STRVAR(FEdge_doc,
static int FEdge_init(BPy_FEdge *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"first_vertex", "second_vertex", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"first_vertex", "second_vertex", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &FEdge_Type, &obj1)) {
if (!obj1) {
@@ -106,7 +106,7 @@ static PyObject *FEdge_sq_item(BPy_FEdge *self, int keynum)
if (keynum < 0) {
keynum += FEdge_sq_length(self);
}
- if (keynum == 0 || keynum == 1) {
+ if (ELEM(keynum, 0, 1)) {
SVertex *v = self->fe->operator[](keynum);
if (v) {
return BPy_SVertex_from_SVertex(*v);
@@ -114,20 +114,20 @@ static PyObject *FEdge_sq_item(BPy_FEdge *self, int keynum)
Py_RETURN_NONE;
}
PyErr_Format(PyExc_IndexError, "FEdge[index]: index %d out of range", keynum);
- return NULL;
+ return nullptr;
}
static PySequenceMethods BPy_FEdge_as_sequence = {
(lenfunc)FEdge_sq_length, /* sq_length */
- NULL, /* sq_concat */
- NULL, /* sq_repeat */
+ nullptr, /* sq_concat */
+ nullptr, /* sq_repeat */
(ssizeargfunc)FEdge_sq_item, /* sq_item */
- NULL, /* sq_slice */
- NULL, /* sq_ass_item */
- NULL, /* *was* sq_ass_slice */
- NULL, /* sq_contains */
- NULL, /* sq_inplace_concat */
- NULL, /* sq_inplace_repeat */
+ nullptr, /* sq_slice */
+ nullptr, /* sq_ass_item */
+ nullptr, /* *was* sq_ass_slice */
+ nullptr, /* sq_contains */
+ nullptr, /* sq_inplace_concat */
+ nullptr, /* sq_inplace_repeat */
};
/*----------------------FEdge get/setters ----------------------------*/
@@ -320,73 +320,81 @@ static PyGetSetDef BPy_FEdge_getseters[] = {
(getter)FEdge_first_svertex_get,
(setter)FEdge_first_svertex_set,
FEdge_first_svertex_doc,
- NULL},
+ nullptr},
{"second_svertex",
(getter)FEdge_second_svertex_get,
(setter)FEdge_second_svertex_set,
FEdge_second_svertex_doc,
- NULL},
+ nullptr},
{"next_fedge",
(getter)FEdge_next_fedge_get,
(setter)FEdge_next_fedge_set,
FEdge_next_fedge_doc,
- NULL},
+ nullptr},
{"previous_fedge",
(getter)FEdge_previous_fedge_get,
(setter)FEdge_previous_fedge_set,
FEdge_previous_fedge_doc,
- NULL},
- {"viewedge", (getter)FEdge_viewedge_get, (setter)FEdge_viewedge_set, FEdge_viewedge_doc, NULL},
+ nullptr},
+ {"viewedge",
+ (getter)FEdge_viewedge_get,
+ (setter)FEdge_viewedge_set,
+ FEdge_viewedge_doc,
+ nullptr},
{"is_smooth",
(getter)FEdge_is_smooth_get,
(setter)FEdge_is_smooth_set,
FEdge_is_smooth_doc,
- NULL},
- {"id", (getter)FEdge_id_get, (setter)FEdge_id_set, FEdge_id_doc, NULL},
- {"nature", (getter)FEdge_nature_get, (setter)FEdge_nature_set, FEdge_nature_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {"id", (getter)FEdge_id_get, (setter)FEdge_id_set, FEdge_id_doc, nullptr},
+ {"nature", (getter)FEdge_nature_get, (setter)FEdge_nature_set, FEdge_nature_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_FEdge type definition ------------------------------*/
PyTypeObject FEdge_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "FEdge", /* tp_name */
- sizeof(BPy_FEdge), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
+ PyVarObject_HEAD_INIT(nullptr, 0) "FEdge", /* tp_name */
+ sizeof(BPy_FEdge), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
&BPy_FEdge_as_sequence, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
FEdge_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
BPy_FEdge_getseters, /* tp_getset */
&Interface1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)FEdge_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
index 78c0ee051d6..d77a8007b1a 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
@@ -54,9 +54,9 @@ PyDoc_STRVAR(FrsCurve_doc,
static int FrsCurve_init(BPy_FrsCurve *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"id", NULL};
- PyObject *obj = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"id", nullptr};
+ PyObject *obj = nullptr;
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &FrsCurve_Type, &obj)) {
if (!obj) {
@@ -89,11 +89,11 @@ PyDoc_STRVAR(FrsCurve_push_vertex_back_doc,
static PyObject *FrsCurve_push_vertex_back(BPy_FrsCurve *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"vertex", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"vertex", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) {
- return NULL;
+ return nullptr;
}
if (BPy_CurvePoint_Check(obj)) {
@@ -104,7 +104,7 @@ static PyObject *FrsCurve_push_vertex_back(BPy_FrsCurve *self, PyObject *args, P
}
else {
PyErr_SetString(PyExc_TypeError, "invalid argument");
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -119,11 +119,11 @@ PyDoc_STRVAR(FrsCurve_push_vertex_front_doc,
static PyObject *FrsCurve_push_vertex_front(BPy_FrsCurve *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"vertex", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"vertex", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) {
- return NULL;
+ return nullptr;
}
if (BPy_CurvePoint_Check(obj)) {
@@ -134,7 +134,7 @@ static PyObject *FrsCurve_push_vertex_front(BPy_FrsCurve *self, PyObject *args,
}
else {
PyErr_SetString(PyExc_TypeError, "invalid argument");
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -148,7 +148,7 @@ static PyMethodDef BPy_FrsCurve_methods[] = {
(PyCFunction)FrsCurve_push_vertex_front,
METH_VARARGS | METH_KEYWORDS,
FrsCurve_push_vertex_front_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------CurvePoint get/setters ----------------------------*/
@@ -174,55 +174,59 @@ static PyObject *FrsCurve_segments_size_get(BPy_FrsCurve *self, void *UNUSED(clo
}
static PyGetSetDef BPy_FrsCurve_getseters[] = {
- {"is_empty", (getter)FrsCurve_is_empty_get, (setter)NULL, FrsCurve_is_empty_doc, NULL},
+ {"is_empty", (getter)FrsCurve_is_empty_get, (setter) nullptr, FrsCurve_is_empty_doc, nullptr},
{"segments_size",
(getter)FrsCurve_segments_size_get,
- (setter)NULL,
+ (setter) nullptr,
FrsCurve_segments_size_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_FrsCurve type definition ------------------------------*/
PyTypeObject FrsCurve_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Curve", /* tp_name */
- sizeof(BPy_FrsCurve), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Curve", /* tp_name */
+ sizeof(BPy_FrsCurve), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
FrsCurve_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
BPy_FrsCurve_methods, /* tp_methods */
- 0, /* tp_members */
+ nullptr, /* tp_members */
BPy_FrsCurve_getseters, /* tp_getset */
&Interface1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)FrsCurve_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
index 910f9cdfa07..90cc3e4f1ab 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
@@ -56,8 +56,8 @@ PyDoc_STRVAR(Stroke_doc,
static int Stroke_init(BPy_Stroke *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"brother", NULL};
- PyObject *brother = 0;
+ static const char *kwlist[] = {"brother", nullptr};
+ PyObject *brother = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &Stroke_Type, &brother)) {
return -1;
@@ -91,7 +91,7 @@ static PyObject *Stroke_sq_item(BPy_Stroke *self, int keynum)
}
if (keynum < 0 || keynum >= Stroke_sq_length(self)) {
PyErr_Format(PyExc_IndexError, "Stroke[index]: index %d out of range", keynum);
- return NULL;
+ return nullptr;
}
return BPy_StrokeVertex_from_StrokeVertex(self->s->strokeVerticeAt(keynum));
}
@@ -113,11 +113,11 @@ PyDoc_STRVAR(Stroke_compute_sampling_doc,
static PyObject *Stroke_compute_sampling(BPy_Stroke *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"n", NULL};
+ static const char *kwlist[] = {"n", nullptr};
int i;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", (char **)kwlist, &i)) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(self->s->ComputeSampling(i));
}
@@ -140,27 +140,27 @@ PyDoc_STRVAR(Stroke_resample_doc,
static PyObject *Stroke_resample(BPy_Stroke *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"n", NULL};
- static const char *kwlist_2[] = {"sampling", NULL};
+ static const char *kwlist_1[] = {"n", nullptr};
+ static const char *kwlist_2[] = {"sampling", nullptr};
int i;
float f;
if (PyArg_ParseTupleAndKeywords(args, kwds, "i", (char **)kwlist_1, &i)) {
if (self->s->Resample(i) < 0) {
PyErr_SetString(PyExc_RuntimeError, "Stroke resampling (by vertex count) failed");
- return NULL;
+ return nullptr;
}
}
else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist_2, &f)) {
if (self->s->Resample(f) < 0) {
PyErr_SetString(PyExc_RuntimeError, "Stroke resampling (by vertex interval) failed");
- return NULL;
+ return nullptr;
}
}
else {
PyErr_SetString(PyExc_TypeError, "invalid argument");
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -180,8 +180,8 @@ PyDoc_STRVAR(Stroke_insert_vertex_doc,
static PyObject *Stroke_insert_vertex(BPy_Stroke *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"vertex", "next", NULL};
- PyObject *py_sv = 0, *py_sv_it = 0;
+ static const char *kwlist[] = {"vertex", "next", nullptr};
+ PyObject *py_sv = nullptr, *py_sv_it = nullptr;
if (!PyArg_ParseTupleAndKeywords(args,
kwds,
@@ -191,7 +191,7 @@ static PyObject *Stroke_insert_vertex(BPy_Stroke *self, PyObject *args, PyObject
&py_sv,
&StrokeVertexIterator_Type,
&py_sv_it)) {
- return NULL;
+ return nullptr;
}
/* Make the wrapped StrokeVertex internal. */
@@ -214,19 +214,19 @@ PyDoc_STRVAR(Stroke_remove_vertex_doc,
static PyObject *Stroke_remove_vertex(BPy_Stroke *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"vertex", NULL};
- PyObject *py_sv = 0;
+ static const char *kwlist[] = {"vertex", nullptr};
+ PyObject *py_sv = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &StrokeVertex_Type, &py_sv)) {
- return NULL;
+ return nullptr;
}
if (((BPy_StrokeVertex *)py_sv)->sv) {
self->s->RemoveVertex(((BPy_StrokeVertex *)py_sv)->sv);
}
else {
PyErr_SetString(PyExc_TypeError, "invalid argument");
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -268,11 +268,11 @@ PyDoc_STRVAR(Stroke_stroke_vertices_begin_doc,
static PyObject *Stroke_stroke_vertices_begin(BPy_Stroke *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"t", NULL};
+ static const char *kwlist[] = {"t", nullptr};
float f = 0.0f;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f)) {
- return NULL;
+ return nullptr;
}
StrokeInternal::StrokeVertexIterator sv_it(self->s->strokeVerticesBegin(f));
return BPy_StrokeVertexIterator_from_StrokeVertexIterator(sv_it, false);
@@ -353,7 +353,7 @@ static PyMethodDef BPy_Stroke_methods[] = {
(PyCFunction)Stroke_stroke_vertices_size,
METH_NOARGS,
Stroke_stroke_vertices_size_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------Stroke get/setters ----------------------------*/
@@ -465,75 +465,79 @@ static PyGetSetDef BPy_Stroke_getseters[] = {
(getter)Stroke_medium_type_get,
(setter)Stroke_medium_type_set,
Stroke_medium_type_doc,
- NULL},
+ nullptr},
{"texture_id",
(getter)Stroke_texture_id_get,
(setter)Stroke_texture_id_set,
Stroke_texture_id_doc,
- NULL},
- {"tips", (getter)Stroke_tips_get, (setter)Stroke_tips_set, Stroke_tips_doc, NULL},
+ nullptr},
+ {"tips", (getter)Stroke_tips_get, (setter)Stroke_tips_set, Stroke_tips_doc, nullptr},
{"length_2d",
(getter)Stroke_length_2d_get,
(setter)Stroke_length_2d_set,
Stroke_length_2d_doc,
- NULL},
- {"id", (getter)Stroke_id_get, (setter)Stroke_id_set, Stroke_id_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {"id", (getter)Stroke_id_get, (setter)Stroke_id_set, Stroke_id_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_Stroke type definition ------------------------------*/
static PySequenceMethods BPy_Stroke_as_sequence = {
(lenfunc)Stroke_sq_length, /* sq_length */
- NULL, /* sq_concat */
- NULL, /* sq_repeat */
+ nullptr, /* sq_concat */
+ nullptr, /* sq_repeat */
(ssizeargfunc)Stroke_sq_item, /* sq_item */
- NULL, /* sq_slice */
- NULL, /* sq_ass_item */
- NULL, /* *was* sq_ass_slice */
- NULL, /* sq_contains */
- NULL, /* sq_inplace_concat */
- NULL, /* sq_inplace_repeat */
+ nullptr, /* sq_slice */
+ nullptr, /* sq_ass_item */
+ nullptr, /* *was* sq_ass_slice */
+ nullptr, /* sq_contains */
+ nullptr, /* sq_inplace_concat */
+ nullptr, /* sq_inplace_repeat */
};
PyTypeObject Stroke_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Stroke", /* tp_name */
- sizeof(BPy_Stroke), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Stroke", /* tp_name */
+ sizeof(BPy_Stroke), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
&BPy_Stroke_as_sequence, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Stroke_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)Stroke_iter, /* tp_iter */
- 0, /* tp_iternext */
+ nullptr, /* tp_iternext */
BPy_Stroke_methods, /* tp_methods */
- 0, /* tp_members */
+ nullptr, /* tp_members */
BPy_Stroke_getseters, /* tp_getset */
&Interface1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)Stroke_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
index e9160d7a5c7..c416d860c77 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
@@ -54,8 +54,8 @@ PyDoc_STRVAR(
static int ViewEdge_init(BPy_ViewEdge *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"brother", NULL};
- PyObject *brother = 0;
+ static const char *kwlist[] = {"brother", nullptr};
+ PyObject *brother = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &ViewEdge_Type, &brother)) {
return -1;
@@ -87,7 +87,7 @@ static PyMethodDef BPy_ViewEdge_methods[] = {
(PyCFunction)ViewEdge_update_fedges,
METH_NOARGS,
ViewEdge_update_fedges_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------ViewEdge get/setters ----------------------------*/
@@ -333,88 +333,96 @@ static PyGetSetDef BPy_ViewEdge_getseters[] = {
(getter)ViewEdge_first_viewvertex_get,
(setter)ViewEdge_first_viewvertex_set,
ViewEdge_first_viewvertex_doc,
- NULL},
+ nullptr},
{"last_viewvertex",
(getter)ViewEdge_last_viewvertex_get,
(setter)ViewEdge_last_viewvertex_set,
ViewEdge_last_viewvertex_doc,
- NULL},
+ nullptr},
{"first_fedge",
(getter)ViewEdge_first_fedge_get,
(setter)ViewEdge_first_fedge_set,
ViewEdge_first_fedge_doc,
- NULL},
+ nullptr},
{"last_fedge",
(getter)ViewEdge_last_fedge_get,
(setter)ViewEdge_last_fedge_set,
ViewEdge_last_fedge_doc,
- NULL},
+ nullptr},
{"viewshape",
(getter)ViewEdge_viewshape_get,
(setter)ViewEdge_viewshape_set,
ViewEdge_viewshape_doc,
- NULL},
+ nullptr},
{"occludee",
(getter)ViewEdge_occludee_get,
(setter)ViewEdge_occludee_set,
ViewEdge_occludee_doc,
- NULL},
- {"is_closed", (getter)ViewEdge_is_closed_get, (setter)NULL, ViewEdge_is_closed_doc, NULL},
- {"id", (getter)ViewEdge_id_get, (setter)ViewEdge_id_set, ViewEdge_id_doc, NULL},
+ nullptr},
+ {"is_closed",
+ (getter)ViewEdge_is_closed_get,
+ (setter) nullptr,
+ ViewEdge_is_closed_doc,
+ nullptr},
+ {"id", (getter)ViewEdge_id_get, (setter)ViewEdge_id_set, ViewEdge_id_doc, nullptr},
{"nature",
(getter)ViewEdge_nature_get,
(setter)ViewEdge_nature_set,
ViewEdge_nature_doc,
- NULL},
- {"qi", (getter)ViewEdge_qi_get, (setter)ViewEdge_qi_set, ViewEdge_qi_doc, NULL},
+ nullptr},
+ {"qi", (getter)ViewEdge_qi_get, (setter)ViewEdge_qi_set, ViewEdge_qi_doc, nullptr},
{"chaining_time_stamp",
(getter)ViewEdge_chaining_time_stamp_get,
(setter)ViewEdge_chaining_time_stamp_set,
ViewEdge_chaining_time_stamp_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_ViewEdge type definition ------------------------------*/
PyTypeObject ViewEdge_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ViewEdge", /* tp_name */
- sizeof(BPy_ViewEdge), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ViewEdge_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_ViewEdge_methods, /* tp_methods */
- 0, /* tp_members */
- BPy_ViewEdge_getseters, /* tp_getset */
- &Interface1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ViewEdge_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ViewEdge", /* tp_name */
+ sizeof(BPy_ViewEdge), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ViewEdge_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ BPy_ViewEdge_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_ViewEdge_getseters, /* tp_getset */
+ &Interface1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ViewEdge_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
index 028e36145b9..dcf6c149b7d 100644
--- a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
@@ -53,9 +53,9 @@ PyDoc_STRVAR(Chain_doc,
static int Chain_init(BPy_Chain *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"id", NULL};
- PyObject *obj = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"id", nullptr};
+ PyObject *obj = nullptr;
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &Chain_Type, &obj)) {
if (!obj) {
@@ -92,12 +92,12 @@ PyDoc_STRVAR(Chain_push_viewedge_back_doc,
static PyObject *Chain_push_viewedge_back(BPy_Chain *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"viewedge", "orientation", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ static const char *kwlist[] = {"viewedge", "orientation", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!O!", (char **)kwlist, &ViewEdge_Type, &obj1, &PyBool_Type, &obj2)) {
- return NULL;
+ return nullptr;
}
ViewEdge *ve = ((BPy_ViewEdge *)obj1)->ve;
bool orientation = bool_from_PyBool(obj2);
@@ -118,12 +118,12 @@ PyDoc_STRVAR(Chain_push_viewedge_front_doc,
static PyObject *Chain_push_viewedge_front(BPy_Chain *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"viewedge", "orientation", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ static const char *kwlist[] = {"viewedge", "orientation", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!O!", (char **)kwlist, &ViewEdge_Type, &obj1, &PyBool_Type, &obj2)) {
- return NULL;
+ return nullptr;
}
ViewEdge *ve = ((BPy_ViewEdge *)obj1)->ve;
bool orientation = bool_from_PyBool(obj2);
@@ -140,49 +140,53 @@ static PyMethodDef BPy_Chain_methods[] = {
(PyCFunction)Chain_push_viewedge_front,
METH_VARARGS | METH_KEYWORDS,
Chain_push_viewedge_front_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*-----------------------BPy_Chain type definition ------------------------------*/
PyTypeObject Chain_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Chain", /* tp_name */
- sizeof(BPy_Chain), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Chain", /* tp_name */
+ sizeof(BPy_Chain), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Chain_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
BPy_Chain_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
&FrsCurve_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)Chain_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
index 018e0449552..454a2bb1c0f 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
@@ -57,9 +57,9 @@ PyDoc_STRVAR(FEdgeSharp_doc,
static int FEdgeSharp_init(BPy_FEdgeSharp *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"first_vertex", "second_vertex", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"first_vertex", "second_vertex", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &FEdgeSharp_Type, &obj1)) {
if (!obj1) {
@@ -362,85 +362,89 @@ static PyGetSetDef BPy_FEdgeSharp_getseters[] = {
(getter)FEdgeSharp_normal_right_get,
(setter)FEdgeSharp_normal_right_set,
FEdgeSharp_normal_right_doc,
- NULL},
+ nullptr},
{"normal_left",
(getter)FEdgeSharp_normal_left_get,
(setter)FEdgeSharp_normal_left_set,
FEdgeSharp_normal_left_doc,
- NULL},
+ nullptr},
{"material_index_right",
(getter)FEdgeSharp_material_index_right_get,
(setter)FEdgeSharp_material_index_right_set,
FEdgeSharp_material_index_right_doc,
- NULL},
+ nullptr},
{"material_index_left",
(getter)FEdgeSharp_material_index_left_get,
(setter)FEdgeSharp_material_index_left_set,
FEdgeSharp_material_index_left_doc,
- NULL},
+ nullptr},
{"material_right",
(getter)FEdgeSharp_material_right_get,
- (setter)NULL,
+ (setter) nullptr,
FEdgeSharp_material_right_doc,
- NULL},
+ nullptr},
{"material_left",
(getter)FEdgeSharp_material_left_get,
- (setter)NULL,
+ (setter) nullptr,
FEdgeSharp_material_left_doc,
- NULL},
+ nullptr},
{"face_mark_right",
(getter)FEdgeSharp_face_mark_right_get,
(setter)FEdgeSharp_face_mark_right_set,
FEdgeSharp_face_mark_right_doc,
- NULL},
+ nullptr},
{"face_mark_left",
(getter)FEdgeSharp_face_mark_left_get,
(setter)FEdgeSharp_face_mark_left_set,
FEdgeSharp_face_mark_left_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_FEdgeSharp type definition ------------------------------*/
PyTypeObject FEdgeSharp_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "FEdgeSharp", /* tp_name */
- sizeof(BPy_FEdgeSharp), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- FEdgeSharp_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_FEdgeSharp_getseters, /* tp_getset */
- &FEdge_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)FEdgeSharp_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "FEdgeSharp", /* tp_name */
+ sizeof(BPy_FEdgeSharp), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ FEdgeSharp_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_FEdgeSharp_getseters, /* tp_getset */
+ &FEdge_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)FEdgeSharp_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
index 014f0411356..c0d56ec949c 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
@@ -54,9 +54,9 @@ PyDoc_STRVAR(FEdgeSmooth_doc,
static int FEdgeSmooth_init(BPy_FEdgeSmooth *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"first_vertex", "second_vertex", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"first_vertex", "second_vertex", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
if (PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist_1, &FEdgeSmooth_Type, &obj1)) {
@@ -227,61 +227,69 @@ static PyGetSetDef BPy_FEdgeSmooth_getseters[] = {
(getter)FEdgeSmooth_normal_get,
(setter)FEdgeSmooth_normal_set,
FEdgeSmooth_normal_doc,
- NULL},
+ nullptr},
{"material_index",
(getter)FEdgeSmooth_material_index_get,
(setter)FEdgeSmooth_material_index_set,
FEdgeSmooth_material_index_doc,
- NULL},
- {"material", (getter)FEdgeSmooth_material_get, (setter)NULL, FEdgeSmooth_material_doc, NULL},
+ nullptr},
+ {"material",
+ (getter)FEdgeSmooth_material_get,
+ (setter) nullptr,
+ FEdgeSmooth_material_doc,
+ nullptr},
{"face_mark",
(getter)FEdgeSmooth_face_mark_get,
(setter)FEdgeSmooth_face_mark_set,
FEdgeSmooth_face_mark_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_FEdgeSmooth type definition ------------------------------*/
PyTypeObject FEdgeSmooth_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "FEdgeSmooth", /* tp_name */
- sizeof(BPy_FEdgeSmooth), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- FEdgeSmooth_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_FEdgeSmooth_getseters, /* tp_getset */
- &FEdge_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)FEdgeSmooth_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "FEdgeSmooth", /* tp_name */
+ sizeof(BPy_FEdgeSmooth), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ FEdgeSmooth_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_FEdgeSmooth_getseters, /* tp_getset */
+ &FEdge_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)FEdgeSmooth_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
index dc32b73fda1..9f5f8d07e26 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
@@ -60,10 +60,10 @@ PyDoc_STRVAR(
static int AdjacencyIterator_init(BPy_AdjacencyIterator *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
+ static const char *kwlist_1[] = {"brother", nullptr};
static const char *kwlist_2[] = {
- "vertex", "restrict_to_selection", "restrict_to_unvisited", NULL};
- PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0;
+ "vertex", "restrict_to_selection", "restrict_to_unvisited", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr;
if (PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist_1, &AdjacencyIterator_Type, &obj1)) {
@@ -77,7 +77,7 @@ static int AdjacencyIterator_init(BPy_AdjacencyIterator *self, PyObject *args, P
}
}
else if ((void)PyErr_Clear(),
- (void)(obj2 = obj3 = 0),
+ (void)(obj2 = obj3 = nullptr),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!|O!O!",
@@ -113,7 +113,7 @@ static PyObject *AdjacencyIterator_iternext(BPy_AdjacencyIterator *self)
{
if (self->a_it->isEnd()) {
PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+ return nullptr;
}
if (self->at_start) {
self->at_start = false;
@@ -122,7 +122,7 @@ static PyObject *AdjacencyIterator_iternext(BPy_AdjacencyIterator *self)
self->a_it->increment();
if (self->a_it->isEnd()) {
PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+ return nullptr;
}
}
ViewEdge *ve = self->a_it->operator->();
@@ -140,7 +140,7 @@ static PyObject *AdjacencyIterator_object_get(BPy_AdjacencyIterator *self, void
{
if (self->a_it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
- return NULL;
+ return nullptr;
}
ViewEdge *ve = self->a_it->operator*();
if (ve) {
@@ -160,7 +160,7 @@ static PyObject *AdjacencyIterator_is_incoming_get(BPy_AdjacencyIterator *self,
{
if (self->a_it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
- return NULL;
+ return nullptr;
}
return PyBool_from_bool(self->a_it->isIncoming());
}
@@ -168,57 +168,61 @@ static PyObject *AdjacencyIterator_is_incoming_get(BPy_AdjacencyIterator *self,
static PyGetSetDef BPy_AdjacencyIterator_getseters[] = {
{"is_incoming",
(getter)AdjacencyIterator_is_incoming_get,
- (setter)NULL,
+ (setter) nullptr,
AdjacencyIterator_is_incoming_doc,
- NULL},
+ nullptr},
{"object",
(getter)AdjacencyIterator_object_get,
- (setter)NULL,
+ (setter) nullptr,
AdjacencyIterator_object_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_AdjacencyIterator type definition ------------------------------*/
PyTypeObject AdjacencyIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "AdjacencyIterator", /* tp_name */
- sizeof(BPy_AdjacencyIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- AdjacencyIterator_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- (getiterfunc)AdjacencyIterator_iter, /* tp_iter */
- (iternextfunc)AdjacencyIterator_iternext, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_AdjacencyIterator_getseters, /* tp_getset */
- &Iterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)AdjacencyIterator_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "AdjacencyIterator", /* tp_name */
+ sizeof(BPy_AdjacencyIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ AdjacencyIterator_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)AdjacencyIterator_iter, /* tp_iter */
+ (iternextfunc)AdjacencyIterator_iternext, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_AdjacencyIterator_getseters, /* tp_getset */
+ &Iterator_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)AdjacencyIterator_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
index 9c534a3463c..e4cd1cd073b 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
@@ -82,7 +82,7 @@ PyDoc_STRVAR(
static int check_begin(PyObject *obj, void *v)
{
- if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
+ if (obj != nullptr && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
return 0;
}
*((PyObject **)v) = obj;
@@ -93,15 +93,16 @@ static int ChainPredicateIterator_init(BPy_ChainPredicateIterator *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
+ static const char *kwlist_1[] = {"brother", nullptr};
static const char *kwlist_2[] = {"upred",
"bpred",
"restrict_to_selection",
"restrict_to_unvisited",
"begin",
"orientation",
- NULL};
- PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0, *obj4 = 0, *obj5 = 0, *obj6 = 0;
+ nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr, *obj4 = nullptr, *obj5 = nullptr,
+ *obj6 = nullptr;
if (PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist_1, &ChainPredicateIterator_Type, &obj1)) {
@@ -112,7 +113,7 @@ static int ChainPredicateIterator_init(BPy_ChainPredicateIterator *self,
Py_INCREF(self->bpred);
}
else if ((void)PyErr_Clear(),
- (void)(obj3 = obj4 = obj5 = obj6 = 0),
+ (void)(obj3 = obj4 = obj5 = obj6 = nullptr),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!O!|O!O!O&O!",
@@ -133,7 +134,7 @@ static int ChainPredicateIterator_init(BPy_ChainPredicateIterator *self,
BinaryPredicate1D *bp1D = ((BPy_BinaryPredicate1D *)obj2)->bp1D;
bool restrict_to_selection = (!obj3) ? true : bool_from_PyBool(obj3);
bool restrict_to_unvisited = (!obj4) ? true : bool_from_PyBool(obj4);
- ViewEdge *begin = (!obj5 || obj5 == Py_None) ? NULL : ((BPy_ViewEdge *)obj5)->ve;
+ ViewEdge *begin = (!obj5 || obj5 == Py_None) ? nullptr : ((BPy_ViewEdge *)obj5)->ve;
bool orientation = (!obj6) ? true : bool_from_PyBool(obj6);
self->cp_it = new ChainPredicateIterator(
*up1D, *bp1D, restrict_to_selection, restrict_to_unvisited, begin, orientation);
@@ -162,43 +163,47 @@ static void ChainPredicateIterator_dealloc(BPy_ChainPredicateIterator *self)
/*-----------------------BPy_ChainPredicateIterator type definition ----------------------------*/
PyTypeObject ChainPredicateIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ChainPredicateIterator", /* tp_name */
- sizeof(BPy_ChainPredicateIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)ChainPredicateIterator_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ChainPredicateIterator_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &ChainingIterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ChainPredicateIterator_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ChainPredicateIterator", /* tp_name */
+ sizeof(BPy_ChainPredicateIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)ChainPredicateIterator_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ChainPredicateIterator_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &ChainingIterator_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ChainPredicateIterator_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
index 9fa84d5f6b8..9aa8984f4af 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
@@ -68,7 +68,7 @@ PyDoc_STRVAR(ChainSilhouetteIterator_doc,
static int check_begin(PyObject *obj, void *v)
{
- if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
+ if (obj != nullptr && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
return 0;
}
*((PyObject **)v) = obj;
@@ -79,16 +79,16 @@ static int ChainSilhouetteIterator_init(BPy_ChainSilhouetteIterator *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"restrict_to_selection", "begin", "orientation", NULL};
- PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"restrict_to_selection", "begin", "orientation", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr;
if (PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist_1, &ChainSilhouetteIterator_Type, &obj1)) {
self->cs_it = new ChainSilhouetteIterator(*(((BPy_ChainSilhouetteIterator *)obj1)->cs_it));
}
else if ((void)PyErr_Clear(),
- (void)(obj1 = obj2 = obj3 = 0),
+ (void)(obj1 = obj2 = obj3 = nullptr),
PyArg_ParseTupleAndKeywords(args,
kwds,
"|O!O&O!",
@@ -100,7 +100,7 @@ static int ChainSilhouetteIterator_init(BPy_ChainSilhouetteIterator *self,
&PyBool_Type,
&obj3)) {
bool restrict_to_selection = (!obj1) ? true : bool_from_PyBool(obj1);
- ViewEdge *begin = (!obj2 || obj2 == Py_None) ? NULL : ((BPy_ViewEdge *)obj2)->ve;
+ ViewEdge *begin = (!obj2 || obj2 == Py_None) ? nullptr : ((BPy_ViewEdge *)obj2)->ve;
bool orientation = (!obj3) ? true : bool_from_PyBool(obj3);
self->cs_it = new ChainSilhouetteIterator(restrict_to_selection, begin, orientation);
}
@@ -117,43 +117,47 @@ static int ChainSilhouetteIterator_init(BPy_ChainSilhouetteIterator *self,
/*-----------------------BPy_ChainSilhouetteIterator type definition ----------------------------*/
PyTypeObject ChainSilhouetteIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ChainSilhouetteIterator", /* tp_name */
- sizeof(BPy_ChainSilhouetteIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ChainSilhouetteIterator_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &ChainingIterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ChainSilhouetteIterator_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ChainSilhouetteIterator", /* tp_name */
+ sizeof(BPy_ChainSilhouetteIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ChainSilhouetteIterator_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &ChainingIterator_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ChainSilhouetteIterator_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
index d24e1dc527d..f2441fa9d18 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
@@ -69,7 +69,7 @@ PyDoc_STRVAR(
static int check_begin(PyObject *obj, void *v)
{
- if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
+ if (obj != nullptr && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
return 0;
}
*((PyObject **)v) = obj;
@@ -78,17 +78,17 @@ static int check_begin(PyObject *obj, void *v)
static int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
+ static const char *kwlist_1[] = {"brother", nullptr};
static const char *kwlist_2[] = {
- "restrict_to_selection", "restrict_to_unvisited", "begin", "orientation", NULL};
- PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0, *obj4 = 0;
+ "restrict_to_selection", "restrict_to_unvisited", "begin", "orientation", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr, *obj4 = nullptr;
if (PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist_1, &ChainingIterator_Type, &obj1)) {
self->c_it = new ChainingIterator(*(((BPy_ChainingIterator *)obj1)->c_it));
}
else if ((void)PyErr_Clear(),
- (void)(obj1 = obj2 = obj3 = obj4 = 0),
+ (void)(obj1 = obj2 = obj3 = obj4 = nullptr),
PyArg_ParseTupleAndKeywords(args,
kwds,
"|O!O!O&O!",
@@ -103,7 +103,7 @@ static int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args,
&obj4)) {
bool restrict_to_selection = (!obj1) ? true : bool_from_PyBool(obj1);
bool restrict_to_unvisited = (!obj2) ? true : bool_from_PyBool(obj2);
- ViewEdge *begin = (!obj3 || obj3 == Py_None) ? NULL : ((BPy_ViewEdge *)obj3)->ve;
+ ViewEdge *begin = (!obj3 || obj3 == Py_None) ? nullptr : ((BPy_ViewEdge *)obj3)->ve;
bool orientation = (!obj4) ? true : bool_from_PyBool(obj4);
self->c_it = new ChainingIterator(
restrict_to_selection, restrict_to_unvisited, begin, orientation);
@@ -131,7 +131,7 @@ static PyObject *ChainingIterator_init(BPy_ChainingIterator *self)
{
if (typeid(*(self->c_it)) == typeid(ChainingIterator)) {
PyErr_SetString(PyExc_TypeError, "init() method not properly overridden");
- return NULL;
+ return nullptr;
}
self->c_it->init();
Py_RETURN_NONE;
@@ -155,16 +155,16 @@ static PyObject *ChainingIterator_traverse(BPy_ChainingIterator *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *py_a_it;
if (typeid(*(self->c_it)) == typeid(ChainingIterator)) {
PyErr_SetString(PyExc_TypeError, "traverse() method not properly overridden");
- return NULL;
+ return nullptr;
}
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &AdjacencyIterator_Type, &py_a_it)) {
- return NULL;
+ return nullptr;
}
if (((BPy_AdjacencyIterator *)py_a_it)->a_it) {
self->c_it->traverse(*(((BPy_AdjacencyIterator *)py_a_it)->a_it));
@@ -178,7 +178,7 @@ static PyMethodDef BPy_ChainingIterator_methods[] = {
(PyCFunction)ChainingIterator_traverse,
METH_VARARGS | METH_KEYWORDS,
ChainingIterator_traverse_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------ChainingIterator get/setters ----------------------------*/
@@ -192,7 +192,7 @@ static PyObject *ChainingIterator_object_get(BPy_ChainingIterator *self, void *U
{
if (self->c_it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
- return NULL;
+ return nullptr;
}
ViewEdge *ve = self->c_it->operator*();
if (ve) {
@@ -232,62 +232,66 @@ static PyObject *ChainingIterator_is_incrementing_get(BPy_ChainingIterator *self
static PyGetSetDef BPy_ChainingIterator_getseters[] = {
{"object",
(getter)ChainingIterator_object_get,
- (setter)NULL,
+ (setter) nullptr,
ChainingIterator_object_doc,
- NULL},
+ nullptr},
{"next_vertex",
(getter)ChainingIterator_next_vertex_get,
- (setter)NULL,
+ (setter) nullptr,
ChainingIterator_next_vertex_doc,
- NULL},
+ nullptr},
{"is_incrementing",
(getter)ChainingIterator_is_incrementing_get,
- (setter)NULL,
+ (setter) nullptr,
ChainingIterator_is_incrementing_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_ChainingIterator type definition ------------------------------*/
PyTypeObject ChainingIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ChainingIterator", /* tp_name */
- sizeof(BPy_ChainingIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ChainingIterator_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_ChainingIterator_methods, /* tp_methods */
- 0, /* tp_members */
- BPy_ChainingIterator_getseters, /* tp_getset */
- &ViewEdgeIterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ChainingIterator___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ChainingIterator", /* tp_name */
+ sizeof(BPy_ChainingIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ChainingIterator_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ BPy_ChainingIterator_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_ChainingIterator_getseters, /* tp_getset */
+ &ViewEdgeIterator_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ChainingIterator___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
index 8eac657316e..ff710e931d4 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
@@ -54,9 +54,9 @@ PyDoc_STRVAR(CurvePointIterator_doc,
static int CurvePointIterator_init(BPy_CurvePointIterator *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"step", NULL};
- PyObject *brother = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"step", nullptr};
+ PyObject *brother = nullptr;
float step;
if (PyArg_ParseTupleAndKeywords(
@@ -92,7 +92,7 @@ static PyObject *CurvePointIterator_object_get(BPy_CurvePointIterator *self, voi
{
if (self->cp_it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
- return NULL;
+ return nullptr;
}
return BPy_CurvePoint_from_CurvePoint(self->cp_it->operator*());
}
@@ -120,54 +120,58 @@ static PyObject *CurvePointIterator_u_get(BPy_CurvePointIterator *self, void *UN
static PyGetSetDef BPy_CurvePointIterator_getseters[] = {
{"object",
(getter)CurvePointIterator_object_get,
- (setter)NULL,
+ (setter) nullptr,
CurvePointIterator_object_doc,
- NULL},
- {"t", (getter)CurvePointIterator_t_get, (setter)NULL, CurvePointIterator_t_doc, NULL},
- {"u", (getter)CurvePointIterator_u_get, (setter)NULL, CurvePointIterator_u_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {"t", (getter)CurvePointIterator_t_get, (setter) nullptr, CurvePointIterator_t_doc, nullptr},
+ {"u", (getter)CurvePointIterator_u_get, (setter) nullptr, CurvePointIterator_u_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_CurvePointIterator type definition ------------------------------*/
PyTypeObject CurvePointIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "CurvePointIterator", /* tp_name */
- sizeof(BPy_CurvePointIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- CurvePointIterator_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_CurvePointIterator_getseters, /* tp_getset */
- &Iterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)CurvePointIterator_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "CurvePointIterator", /* tp_name */
+ sizeof(BPy_CurvePointIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ CurvePointIterator_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_CurvePointIterator_getseters, /* tp_getset */
+ &Iterator_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)CurvePointIterator_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
index f7afc7695ae..d0de53fa424 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
@@ -65,9 +65,9 @@ static int convert_nested_it(PyObject *obj, void *v)
static int Interface0DIterator_init(BPy_Interface0DIterator *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"it", NULL};
- static const char *kwlist_2[] = {"inter", NULL};
- static const char *kwlist_3[] = {"brother", NULL};
+ static const char *kwlist_1[] = {"it", nullptr};
+ static const char *kwlist_2[] = {"inter", nullptr};
+ static const char *kwlist_3[] = {"brother", nullptr};
Interface0DIteratorNested *nested_it;
PyObject *brother, *inter;
@@ -111,21 +111,21 @@ static PyObject *Interface0DIterator_iternext(BPy_Interface0DIterator *self)
if (self->reversed) {
if (self->if0D_it->isBegin()) {
PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+ return nullptr;
}
self->if0D_it->decrement();
}
else {
if (self->if0D_it->isEnd()) {
PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+ return nullptr;
}
if (self->at_start) {
self->at_start = false;
}
else if (self->if0D_it->atLast()) {
PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+ return nullptr;
}
else {
self->if0D_it->increment();
@@ -150,7 +150,7 @@ static PyObject *Interface0DIterator_object_get(BPy_Interface0DIterator *self,
{
if (self->if0D_it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
- return NULL;
+ return nullptr;
}
return Any_BPy_Interface0D_from_Interface0D(self->if0D_it->operator*());
}
@@ -190,59 +190,63 @@ static PyObject *Interface0DIterator_at_last_get(BPy_Interface0DIterator *self,
static PyGetSetDef BPy_Interface0DIterator_getseters[] = {
{"object",
(getter)Interface0DIterator_object_get,
- (setter)NULL,
+ (setter) nullptr,
Interface0DIterator_object_doc,
- NULL},
- {"t", (getter)Interface0DIterator_t_get, (setter)NULL, Interface0DIterator_t_doc, NULL},
- {"u", (getter)Interface0DIterator_u_get, (setter)NULL, Interface0DIterator_u_doc, NULL},
+ nullptr},
+ {"t", (getter)Interface0DIterator_t_get, (setter) nullptr, Interface0DIterator_t_doc, nullptr},
+ {"u", (getter)Interface0DIterator_u_get, (setter) nullptr, Interface0DIterator_u_doc, nullptr},
{"at_last",
(getter)Interface0DIterator_at_last_get,
- (setter)NULL,
+ (setter) nullptr,
Interface0DIterator_at_last_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_Interface0DIterator type definition ------------------------------*/
PyTypeObject Interface0DIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Interface0DIterator", /* tp_name */
- sizeof(BPy_Interface0DIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Interface0DIterator_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- (getiterfunc)Interface0DIterator_iter, /* tp_iter */
- (iternextfunc)Interface0DIterator_iternext, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_Interface0DIterator_getseters, /* tp_getset */
- &Iterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Interface0DIterator_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Interface0DIterator", /* tp_name */
+ sizeof(BPy_Interface0DIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Interface0DIterator_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)Interface0DIterator_iter, /* tp_iter */
+ (iternextfunc)Interface0DIterator_iternext, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_Interface0DIterator_getseters, /* tp_getset */
+ &Iterator_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Interface0DIterator_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
index 83c504081c1..c0db79858b7 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
@@ -62,9 +62,9 @@ PyDoc_STRVAR(
static int SVertexIterator_init(BPy_SVertexIterator *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"vertex", "begin", "previous_edge", "next_edge", "t", NULL};
- PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0, *obj4 = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"vertex", "begin", "previous_edge", "next_edge", "t", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr, *obj4 = nullptr;
float t;
if (PyArg_ParseTupleAndKeywords(
@@ -115,7 +115,7 @@ static PyObject *SVertexIterator_object_get(BPy_SVertexIterator *self, void *UNU
{
if (self->sv_it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
- return NULL;
+ return nullptr;
}
SVertex *sv = self->sv_it->operator->();
if (sv) {
@@ -145,52 +145,60 @@ static PyObject *SVertexIterator_u_get(BPy_SVertexIterator *self, void *UNUSED(c
}
static PyGetSetDef BPy_SVertexIterator_getseters[] = {
- {"object", (getter)SVertexIterator_object_get, (setter)NULL, SVertexIterator_object_doc, NULL},
- {"t", (getter)SVertexIterator_t_get, (setter)NULL, SVertexIterator_t_doc, NULL},
- {"u", (getter)SVertexIterator_u_get, (setter)NULL, SVertexIterator_u_doc, NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ {"object",
+ (getter)SVertexIterator_object_get,
+ (setter) nullptr,
+ SVertexIterator_object_doc,
+ nullptr},
+ {"t", (getter)SVertexIterator_t_get, (setter) nullptr, SVertexIterator_t_doc, nullptr},
+ {"u", (getter)SVertexIterator_u_get, (setter) nullptr, SVertexIterator_u_doc, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_SVertexIterator type definition ------------------------------*/
PyTypeObject SVertexIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "SVertexIterator", /* tp_name */
- sizeof(BPy_SVertexIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- SVertexIterator_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_SVertexIterator_getseters, /* tp_getset */
- &Iterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)SVertexIterator_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "SVertexIterator", /* tp_name */
+ sizeof(BPy_SVertexIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ SVertexIterator_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_SVertexIterator_getseters, /* tp_getset */
+ &Iterator_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)SVertexIterator_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
index e1b24e768e3..ceb0d2a7546 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
@@ -60,9 +60,9 @@ static int StrokeVertexIterator_init(BPy_StrokeVertexIterator *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"stroke", NULL};
- PyObject *brother = 0, *stroke = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"stroke", nullptr};
+ PyObject *brother = nullptr, *stroke = nullptr;
if (PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist_1, &StrokeVertexIterator_Type, &brother)) {
@@ -111,7 +111,7 @@ static PyObject *StrokeVertexIterator_iternext(BPy_StrokeVertexIterator *self)
if (self->reversed) {
if (self->sv_it->isBegin()) {
PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+ return nullptr;
}
self->sv_it->decrement();
}
@@ -119,7 +119,7 @@ static PyObject *StrokeVertexIterator_iternext(BPy_StrokeVertexIterator *self)
/* If sv_it.isEnd() is true, the iterator can't be incremented. */
if (self->sv_it->isEnd()) {
PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+ return nullptr;
}
/* If at the start of the iterator, only return the object
* and don't increment, to keep for-loops in sync */
@@ -130,7 +130,7 @@ static PyObject *StrokeVertexIterator_iternext(BPy_StrokeVertexIterator *self)
* Incrementing it further would lead to a state that the iterator can't be dereferenced. */
else if (self->sv_it->atLast()) {
PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+ return nullptr;
}
else {
self->sv_it->increment();
@@ -154,7 +154,7 @@ static PyObject *StrokeVertexIterator_incremented(BPy_StrokeVertexIterator *self
{
if (self->sv_it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError, "cannot increment any more");
- return NULL;
+ return nullptr;
}
StrokeInternal::StrokeVertexIterator copy(*self->sv_it);
copy.increment();
@@ -173,7 +173,7 @@ static PyObject *StrokeVertexIterator_decremented(BPy_StrokeVertexIterator *self
{
if (self->sv_it->isBegin()) {
PyErr_SetString(PyExc_RuntimeError, "cannot decrement any more");
- return NULL;
+ return nullptr;
}
StrokeInternal::StrokeVertexIterator copy(*self->sv_it);
copy.decrement();
@@ -207,7 +207,7 @@ static PyMethodDef BPy_StrokeVertexIterator_methods[] = {
(PyCFunction)StrokeVertexIterator_reversed,
METH_NOARGS,
StrokeVertexIterator_reversed_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------StrokeVertexIterator get/setters ----------------------------*/
@@ -222,7 +222,7 @@ static PyObject *StrokeVertexIterator_object_get(BPy_StrokeVertexIterator *self,
{
if (self->sv_it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
- return NULL;
+ return nullptr;
}
StrokeVertex *sv = self->sv_it->operator->();
if (sv) {
@@ -265,59 +265,71 @@ static PyObject *StrokeVertexIterator_at_last_get(BPy_StrokeVertexIterator *self
static PyGetSetDef BPy_StrokeVertexIterator_getseters[] = {
{"object",
(getter)StrokeVertexIterator_object_get,
- (setter)NULL,
+ (setter) nullptr,
StrokeVertexIterator_object_doc,
- NULL},
- {"t", (getter)StrokeVertexIterator_t_get, (setter)NULL, StrokeVertexIterator_t_doc, NULL},
- {"u", (getter)StrokeVertexIterator_u_get, (setter)NULL, StrokeVertexIterator_u_doc, NULL},
+ nullptr},
+ {"t",
+ (getter)StrokeVertexIterator_t_get,
+ (setter) nullptr,
+ StrokeVertexIterator_t_doc,
+ nullptr},
+ {"u",
+ (getter)StrokeVertexIterator_u_get,
+ (setter) nullptr,
+ StrokeVertexIterator_u_doc,
+ nullptr},
{"at_last",
(getter)StrokeVertexIterator_at_last_get,
- (setter)NULL,
+ (setter) nullptr,
StrokeVertexIterator_at_last_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_StrokeVertexIterator type definition ------------------------------*/
PyTypeObject StrokeVertexIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "StrokeVertexIterator", /* tp_name */
- sizeof(BPy_StrokeVertexIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- StrokeVertexIterator_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- (getiterfunc)StrokeVertexIterator_iter, /* tp_iter */
- (iternextfunc)StrokeVertexIterator_iternext, /* tp_iternext */
- BPy_StrokeVertexIterator_methods, /* tp_methods */
- 0, /* tp_members */
- BPy_StrokeVertexIterator_getseters, /* tp_getset */
- &Iterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)StrokeVertexIterator_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "StrokeVertexIterator", /* tp_name */
+ sizeof(BPy_StrokeVertexIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ StrokeVertexIterator_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)StrokeVertexIterator_iter, /* tp_iter */
+ (iternextfunc)StrokeVertexIterator_iternext, /* tp_iternext */
+ BPy_StrokeVertexIterator_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_StrokeVertexIterator_getseters, /* tp_getset */
+ &Iterator_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)StrokeVertexIterator_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
index 20134057864..e01bbe928ce 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
@@ -57,7 +57,7 @@ PyDoc_STRVAR(ViewEdgeIterator_doc,
static int check_begin(PyObject *obj, void *v)
{
- if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
+ if (obj != nullptr && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
return 0;
}
*((PyObject **)v) = obj;
@@ -66,19 +66,19 @@ static int check_begin(PyObject *obj, void *v)
static int ViewEdgeIterator_init(BPy_ViewEdgeIterator *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist_1[] = {"brother", NULL};
- static const char *kwlist_2[] = {"begin", "orientation", NULL};
- PyObject *obj1 = 0, *obj2 = 0;
+ static const char *kwlist_1[] = {"brother", nullptr};
+ static const char *kwlist_2[] = {"begin", "orientation", nullptr};
+ PyObject *obj1 = nullptr, *obj2 = nullptr;
if (PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist_1, &ViewEdgeIterator_Type, &obj1)) {
self->ve_it = new ViewEdgeInternal::ViewEdgeIterator(*(((BPy_ViewEdgeIterator *)obj1)->ve_it));
}
else if ((void)PyErr_Clear(),
- (void)(obj1 = obj2 = 0),
+ (void)(obj1 = obj2 = nullptr),
PyArg_ParseTupleAndKeywords(
args, kwds, "|O&O!", (char **)kwlist_2, check_begin, &obj1, &PyBool_Type, &obj2)) {
- ViewEdge *begin = (!obj1 || obj1 == Py_None) ? NULL : ((BPy_ViewEdge *)obj1)->ve;
+ ViewEdge *begin = (!obj1 || obj1 == Py_None) ? nullptr : ((BPy_ViewEdge *)obj1)->ve;
bool orientation = (!obj2) ? true : bool_from_PyBool(obj2);
self->ve_it = new ViewEdgeInternal::ViewEdgeIterator(begin, orientation);
}
@@ -106,7 +106,7 @@ static PyMethodDef BPy_ViewEdgeIterator_methods[] = {
(PyCFunction)ViewEdgeIterator_change_orientation,
METH_NOARGS,
ViewEdgeIterator_change_orientation_doc},
- {NULL, NULL, 0, NULL},
+ {nullptr, nullptr, 0, nullptr},
};
/*----------------------ViewEdgeIterator get/setters ----------------------------*/
@@ -120,7 +120,7 @@ static PyObject *ViewEdgeIterator_object_get(BPy_ViewEdgeIterator *self, void *U
{
if (!self->ve_it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
- return NULL;
+ return nullptr;
}
ViewEdge *ve = self->ve_it->operator*();
if (ve) {
@@ -212,67 +212,71 @@ static int ViewEdgeIterator_begin_set(BPy_ViewEdgeIterator *self,
static PyGetSetDef BPy_ViewEdgeIterator_getseters[] = {
{"object",
(getter)ViewEdgeIterator_object_get,
- (setter)NULL,
+ (setter) nullptr,
ViewEdgeIterator_object_doc,
- NULL},
+ nullptr},
{"current_edge",
(getter)ViewEdgeIterator_current_edge_get,
(setter)ViewEdgeIterator_current_edge_set,
ViewEdgeIterator_current_edge_doc,
- NULL},
+ nullptr},
{"orientation",
(getter)ViewEdgeIterator_orientation_get,
(setter)ViewEdgeIterator_orientation_set,
ViewEdgeIterator_orientation_doc,
- NULL},
+ nullptr},
{"begin",
(getter)ViewEdgeIterator_begin_get,
(setter)ViewEdgeIterator_begin_set,
ViewEdgeIterator_begin_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_ViewEdgeIterator type definition ------------------------------*/
PyTypeObject ViewEdgeIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ViewEdgeIterator", /* tp_name */
- sizeof(BPy_ViewEdgeIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ViewEdgeIterator_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_ViewEdgeIterator_methods, /* tp_methods */
- 0, /* tp_members */
- BPy_ViewEdgeIterator_getseters, /* tp_getset */
- &Iterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ViewEdgeIterator_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ViewEdgeIterator", /* tp_name */
+ sizeof(BPy_ViewEdgeIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ViewEdgeIterator_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ BPy_ViewEdgeIterator_methods, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_ViewEdgeIterator_getseters, /* tp_getset */
+ &Iterator_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ViewEdgeIterator_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
index 30b7b3ccde5..735746e33be 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
@@ -51,8 +51,8 @@ static int orientedViewEdgeIterator_init(BPy_orientedViewEdgeIterator *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"brother", NULL};
- PyObject *brother = 0;
+ static const char *kwlist[] = {"brother", nullptr};
+ PyObject *brother = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &orientedViewEdgeIterator_Type, &brother)) {
@@ -85,14 +85,14 @@ static PyObject *orientedViewEdgeIterator_iternext(BPy_orientedViewEdgeIterator
if (self->reversed) {
if (self->ove_it->isBegin()) {
PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+ return nullptr;
}
self->ove_it->decrement();
}
else {
if (self->ove_it->isEnd()) {
PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+ return nullptr;
}
if (self->at_start) {
self->at_start = false;
@@ -101,7 +101,7 @@ static PyObject *orientedViewEdgeIterator_iternext(BPy_orientedViewEdgeIterator
self->ove_it->increment();
if (self->ove_it->isEnd()) {
PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+ return nullptr;
}
}
}
@@ -123,7 +123,7 @@ static PyObject *orientedViewEdgeIterator_object_get(BPy_orientedViewEdgeIterato
{
if (self->ove_it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
- return NULL;
+ return nullptr;
}
return BPy_directedViewEdge_from_directedViewEdge(self->ove_it->operator*());
}
@@ -131,52 +131,56 @@ static PyObject *orientedViewEdgeIterator_object_get(BPy_orientedViewEdgeIterato
static PyGetSetDef BPy_orientedViewEdgeIterator_getseters[] = {
{"object",
(getter)orientedViewEdgeIterator_object_get,
- (setter)NULL,
+ (setter) nullptr,
orientedViewEdgeIterator_object_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_orientedViewEdgeIterator type definition ---------------------------*/
PyTypeObject orientedViewEdgeIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "orientedViewEdgeIterator", /* tp_name */
- sizeof(BPy_orientedViewEdgeIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- orientedViewEdgeIterator_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- (getiterfunc)orientedViewEdgeIterator_iter, /* tp_iter */
- (iternextfunc)orientedViewEdgeIterator_iternext, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_orientedViewEdgeIterator_getseters, /* tp_getset */
- &Iterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)orientedViewEdgeIterator_init, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "orientedViewEdgeIterator", /* tp_name */
+ sizeof(BPy_orientedViewEdgeIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ orientedViewEdgeIterator_doc, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)orientedViewEdgeIterator_iter, /* tp_iter */
+ (iternextfunc)orientedViewEdgeIterator_iternext, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_orientedViewEdgeIterator_getseters, /* tp_getset */
+ &Iterator_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)orientedViewEdgeIterator_init, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
index efe96b72061..c3b98d12918 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
@@ -54,7 +54,7 @@ static int BackboneStretcherShader___init__(BPy_BackboneStretcherShader *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"amount", NULL};
+ static const char *kwlist[] = {"amount", nullptr};
float f = 2.0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f)) {
@@ -67,43 +67,47 @@ static int BackboneStretcherShader___init__(BPy_BackboneStretcherShader *self,
/*-----------------------BPy_BackboneStretcherShader type definition ----------------------------*/
PyTypeObject BackboneStretcherShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "BackboneStretcherShader", /* tp_name */
- sizeof(BPy_BackboneStretcherShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- BackboneStretcherShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)BackboneStretcherShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "BackboneStretcherShader", /* tp_name */
+ sizeof(BPy_BackboneStretcherShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ BackboneStretcherShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)BackboneStretcherShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp
index 2336b1ce902..50fc9938a87 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp
@@ -54,7 +54,7 @@ static char BezierCurveShader___doc__[] =
static int BezierCurveShader___init__(BPy_BezierCurveShader *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"error", NULL};
+ static const char *kwlist[] = {"error", nullptr};
float f = 4.0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f)) {
@@ -67,43 +67,47 @@ static int BezierCurveShader___init__(BPy_BezierCurveShader *self, PyObject *arg
/*-----------------------BPy_BezierCurveShader type definition ------------------------------*/
PyTypeObject BezierCurveShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "BezierCurveShader", /* tp_name */
- sizeof(BPy_BezierCurveShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- BezierCurveShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)BezierCurveShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "BezierCurveShader", /* tp_name */
+ sizeof(BPy_BezierCurveShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ BezierCurveShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)BezierCurveShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
index eaed138f61a..e1198266a98 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
@@ -58,7 +58,7 @@ static int BlenderTextureShader___init__(BPy_BlenderTextureShader *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"texture", NULL};
+ static const char *kwlist[] = {"texture", nullptr};
PyObject *obj;
MTex *_mtex;
bNodeTree *_nodetree;
@@ -87,43 +87,47 @@ static int BlenderTextureShader___init__(BPy_BlenderTextureShader *self,
/*-----------------------BPy_BlenderTextureShader type definition ------------------------------*/
PyTypeObject BlenderTextureShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "BlenderTextureShader", /* tp_name */
- sizeof(BPy_BlenderTextureShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- BlenderTextureShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)BlenderTextureShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "BlenderTextureShader", /* tp_name */
+ sizeof(BPy_BlenderTextureShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ BlenderTextureShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)BlenderTextureShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp
index 27af7207b97..e8790df2dd0 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp
@@ -67,10 +67,11 @@ static int CalligraphicShader___init__(BPy_CalligraphicShader *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"thickness_min", "thickness_max", "orientation", "clamp", NULL};
+ static const char *kwlist[] = {
+ "thickness_min", "thickness_max", "orientation", "clamp", nullptr};
double d1, d2;
float f3[2];
- PyObject *obj4 = 0;
+ PyObject *obj4 = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "ddO&O!", (char **)kwlist, &d1, &d2, convert_v2, f3, &PyBool_Type, &obj4)) {
@@ -84,43 +85,47 @@ static int CalligraphicShader___init__(BPy_CalligraphicShader *self,
/*-----------------------BPy_CalligraphicShader type definition ------------------------------*/
PyTypeObject CalligraphicShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "CalligraphicShader", /* tp_name */
- sizeof(BPy_CalligraphicShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- CalligraphicShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)CalligraphicShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "CalligraphicShader", /* tp_name */
+ sizeof(BPy_CalligraphicShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ CalligraphicShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)CalligraphicShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp
index 81320e9b5a1..8fb6e26d8d7 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp
@@ -53,7 +53,7 @@ static char ColorNoiseShader___doc__[] =
static int ColorNoiseShader___init__(BPy_ColorNoiseShader *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"amplitude", "period", NULL};
+ static const char *kwlist[] = {"amplitude", "period", nullptr};
float f1, f2;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "ff", (char **)kwlist, &f1, &f2)) {
@@ -66,43 +66,47 @@ static int ColorNoiseShader___init__(BPy_ColorNoiseShader *self, PyObject *args,
/*-----------------------BPy_ColorNoiseShader type definition ------------------------------*/
PyTypeObject ColorNoiseShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ColorNoiseShader", /* tp_name */
- sizeof(BPy_ColorNoiseShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ColorNoiseShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ColorNoiseShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ColorNoiseShader", /* tp_name */
+ sizeof(BPy_ColorNoiseShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ColorNoiseShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ColorNoiseShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp
index c5d65734aa5..2b108226e90 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp
@@ -59,7 +59,7 @@ static int ConstantColorShader___init__(BPy_ConstantColorShader *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"red", "green", "blue", "alpha", NULL};
+ static const char *kwlist[] = {"red", "green", "blue", "alpha", nullptr};
float f1, f2, f3, f4 = 1.0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "fff|f", (char **)kwlist, &f1, &f2, &f3, &f4)) {
@@ -72,43 +72,47 @@ static int ConstantColorShader___init__(BPy_ConstantColorShader *self,
/*-----------------------BPy_ConstantColorShader type definition ------------------------------*/
PyTypeObject ConstantColorShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ConstantColorShader", /* tp_name */
- sizeof(BPy_ConstantColorShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ConstantColorShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ConstantColorShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ConstantColorShader", /* tp_name */
+ sizeof(BPy_ConstantColorShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ConstantColorShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ConstantColorShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
index 00fbfe525c3..0174107f27f 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
@@ -53,7 +53,7 @@ static int ConstantThicknessShader___init__(BPy_ConstantThicknessShader *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"thickness", NULL};
+ static const char *kwlist[] = {"thickness", nullptr};
float f;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &f)) {
@@ -66,43 +66,47 @@ static int ConstantThicknessShader___init__(BPy_ConstantThicknessShader *self,
/*-----------------------BPy_ConstantThicknessShader type definition ----------------------------*/
PyTypeObject ConstantThicknessShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ConstantThicknessShader", /* tp_name */
- sizeof(BPy_ConstantThicknessShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ConstantThicknessShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ConstantThicknessShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ConstantThicknessShader", /* tp_name */
+ sizeof(BPy_ConstantThicknessShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ConstantThicknessShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ConstantThicknessShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
index ebafe84fee0..b5c200c17b1 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
@@ -59,7 +59,7 @@ static char ConstrainedIncreasingThicknessShader___doc__[] =
static int ConstrainedIncreasingThicknessShader___init__(
BPy_ConstrainedIncreasingThicknessShader *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"thickness_min", "thickness_max", "ratio", NULL};
+ static const char *kwlist[] = {"thickness_min", "thickness_max", "ratio", nullptr};
float f1, f2, f3;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "fff", (char **)kwlist, &f1, &f2, &f3)) {
@@ -72,43 +72,47 @@ static int ConstrainedIncreasingThicknessShader___init__(
/*-----------------------BPy_ConstrainedIncreasingThicknessShader type definition ---------------*/
PyTypeObject ConstrainedIncreasingThicknessShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ConstrainedIncreasingThicknessShader", /* tp_name */
- sizeof(BPy_ConstrainedIncreasingThicknessShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ConstrainedIncreasingThicknessShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ConstrainedIncreasingThicknessShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ConstrainedIncreasingThicknessShader", /* tp_name */
+ sizeof(BPy_ConstrainedIncreasingThicknessShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ConstrainedIncreasingThicknessShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ConstrainedIncreasingThicknessShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp
index ff875fa98d3..d1c3219b079 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp
@@ -61,7 +61,7 @@ static int GuidingLinesShader___init__(BPy_GuidingLinesShader *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"offset", NULL};
+ static const char *kwlist[] = {"offset", nullptr};
float f;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &f)) {
@@ -74,43 +74,47 @@ static int GuidingLinesShader___init__(BPy_GuidingLinesShader *self,
/*-----------------------BPy_GuidingLinesShader type definition ------------------------------*/
PyTypeObject GuidingLinesShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GuidingLinesShader", /* tp_name */
- sizeof(BPy_GuidingLinesShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GuidingLinesShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GuidingLinesShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GuidingLinesShader", /* tp_name */
+ sizeof(BPy_GuidingLinesShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GuidingLinesShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GuidingLinesShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp
index 3c7ba689b28..7d1efebe71f 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp
@@ -79,7 +79,7 @@ static int IncreasingColorShader___init__(BPy_IncreasingColorShader *self,
"green_max",
"blue_max",
"alpha_max",
- NULL,
+ nullptr,
};
float f1, f2, f3, f4, f5, f6, f7, f8;
@@ -94,43 +94,47 @@ static int IncreasingColorShader___init__(BPy_IncreasingColorShader *self,
/*-----------------------BPy_IncreasingColorShader type definition ------------------------------*/
PyTypeObject IncreasingColorShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "IncreasingColorShader", /* tp_name */
- sizeof(BPy_IncreasingColorShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- IncreasingColorShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)IncreasingColorShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "IncreasingColorShader", /* tp_name */
+ sizeof(BPy_IncreasingColorShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ IncreasingColorShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)IncreasingColorShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
index e04fa45be36..f13930bd4b3 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
@@ -59,7 +59,7 @@ static int IncreasingThicknessShader___init__(BPy_IncreasingThicknessShader *sel
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"thickness_A", "thickness_B", NULL};
+ static const char *kwlist[] = {"thickness_A", "thickness_B", nullptr};
float f1, f2;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "ff", (char **)kwlist, &f1, &f2)) {
@@ -72,43 +72,47 @@ static int IncreasingThicknessShader___init__(BPy_IncreasingThicknessShader *sel
/*-----------------------BPy_IncreasingThicknessShader type definition --------------------------*/
PyTypeObject IncreasingThicknessShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "IncreasingThicknessShader", /* tp_name */
- sizeof(BPy_IncreasingThicknessShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- IncreasingThicknessShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)IncreasingThicknessShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "IncreasingThicknessShader", /* tp_name */
+ sizeof(BPy_IncreasingThicknessShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ IncreasingThicknessShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)IncreasingThicknessShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
index 8128a6dd8ad..48c63554f06 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
@@ -60,7 +60,7 @@ static int PolygonalizationShader___init__(BPy_PolygonalizationShader *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"error", NULL};
+ static const char *kwlist[] = {"error", nullptr};
float f;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &f)) {
@@ -73,43 +73,47 @@ static int PolygonalizationShader___init__(BPy_PolygonalizationShader *self,
/*-----------------------BPy_PolygonalizationShader type definition -----------------------------*/
PyTypeObject PolygonalizationShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "PolygonalizationShader", /* tp_name */
- sizeof(BPy_PolygonalizationShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- PolygonalizationShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)PolygonalizationShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "PolygonalizationShader", /* tp_name */
+ sizeof(BPy_PolygonalizationShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ PolygonalizationShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)PolygonalizationShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp
index ad8b8ef786b..5f0a0bfb305 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp
@@ -51,7 +51,7 @@ static char SamplingShader___doc__[] =
static int SamplingShader___init__(BPy_SamplingShader *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"sampling", NULL};
+ static const char *kwlist[] = {"sampling", nullptr};
float f;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &f)) {
@@ -64,43 +64,47 @@ static int SamplingShader___init__(BPy_SamplingShader *self, PyObject *args, PyO
/*-----------------------BPy_SamplingShader type definition ------------------------------*/
PyTypeObject SamplingShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "SamplingShader", /* tp_name */
- sizeof(BPy_SamplingShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- SamplingShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)SamplingShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "SamplingShader", /* tp_name */
+ sizeof(BPy_SamplingShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ SamplingShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)SamplingShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
index 9e2726061c3..3d30fb4e11b 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
@@ -80,7 +80,7 @@ static int SmoothingShader___init__(BPy_SmoothingShader *self, PyObject *args, P
"aniso_normal",
"aniso_curvature",
"carricature_factor",
- NULL,
+ nullptr,
};
int i1 = 100;
double d2 = 0.1, d3 = 0.0, d4 = 0.2, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 1.0;
@@ -96,43 +96,47 @@ static int SmoothingShader___init__(BPy_SmoothingShader *self, PyObject *args, P
/*-----------------------BPy_SmoothingShader type definition ------------------------------*/
PyTypeObject SmoothingShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "SmoothingShader", /* tp_name */
- sizeof(BPy_SmoothingShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- SmoothingShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)SmoothingShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "SmoothingShader", /* tp_name */
+ sizeof(BPy_SmoothingShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ SmoothingShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)SmoothingShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp
index f45d97047eb..876dd5f2f63 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp
@@ -63,10 +63,11 @@ static int SpatialNoiseShader___init__(BPy_SpatialNoiseShader *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"amount", "scale", "num_octaves", "smooth", "pure_random", NULL};
+ static const char *kwlist[] = {
+ "amount", "scale", "num_octaves", "smooth", "pure_random", nullptr};
float f1, f2;
int i3;
- PyObject *obj4 = 0, *obj5 = 0;
+ PyObject *obj4 = nullptr, *obj5 = nullptr;
if (!PyArg_ParseTupleAndKeywords(args,
kwds,
@@ -89,43 +90,47 @@ static int SpatialNoiseShader___init__(BPy_SpatialNoiseShader *self,
/*-----------------------BPy_SpatialNoiseShader type definition ------------------------------*/
PyTypeObject SpatialNoiseShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "SpatialNoiseShader", /* tp_name */
- sizeof(BPy_SpatialNoiseShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- SpatialNoiseShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)SpatialNoiseShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "SpatialNoiseShader", /* tp_name */
+ sizeof(BPy_SpatialNoiseShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ SpatialNoiseShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)SpatialNoiseShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
index 93a14edd964..bd70d41717b 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
@@ -53,7 +53,7 @@ static int StrokeTextureStepShader___init__(BPy_StrokeTextureStepShader *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"step", NULL};
+ static const char *kwlist[] = {"step", nullptr};
float step = 0.1;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &step)) {
@@ -66,43 +66,47 @@ static int StrokeTextureStepShader___init__(BPy_StrokeTextureStepShader *self,
/*-----------------------BPy_StrokeTextureStepShader type definition ----------------------------*/
PyTypeObject StrokeTextureStepShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "StrokeTextureStepShader", /* tp_name */
- sizeof(BPy_StrokeTextureStepShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- StrokeTextureStepShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)StrokeTextureStepShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "StrokeTextureStepShader", /* tp_name */
+ sizeof(BPy_StrokeTextureStepShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ StrokeTextureStepShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)StrokeTextureStepShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp
index 966dc050985..fd7f5fabe77 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp
@@ -55,7 +55,7 @@ static int ThicknessNoiseShader___init__(BPy_ThicknessNoiseShader *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"amplitude", "period", NULL};
+ static const char *kwlist[] = {"amplitude", "period", nullptr};
float f1, f2;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "ff", (char **)kwlist, &f1, &f2)) {
@@ -68,43 +68,47 @@ static int ThicknessNoiseShader___init__(BPy_ThicknessNoiseShader *self,
/*-----------------------BPy_ThicknessNoiseShader type definition ------------------------------*/
PyTypeObject ThicknessNoiseShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ThicknessNoiseShader", /* tp_name */
- sizeof(BPy_ThicknessNoiseShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ThicknessNoiseShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ThicknessNoiseShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ThicknessNoiseShader", /* tp_name */
+ sizeof(BPy_ThicknessNoiseShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ThicknessNoiseShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ThicknessNoiseShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp
index 001e6ce23ba..ed575b12b8d 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp
@@ -52,7 +52,7 @@ static char TipRemoverShader___doc__[] =
static int TipRemoverShader___init__(BPy_TipRemoverShader *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"tip_length", NULL};
+ static const char *kwlist[] = {"tip_length", nullptr};
double d;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "d", (char **)kwlist, &d)) {
@@ -65,43 +65,47 @@ static int TipRemoverShader___init__(BPy_TipRemoverShader *self, PyObject *args,
/*-----------------------BPy_TipRemoverShader type definition ------------------------------*/
PyTypeObject TipRemoverShader_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "TipRemoverShader", /* tp_name */
- sizeof(BPy_TipRemoverShader), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- TipRemoverShader___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &StrokeShader_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)TipRemoverShader___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "TipRemoverShader", /* tp_name */
+ sizeof(BPy_TipRemoverShader), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ TipRemoverShader___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &StrokeShader_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)TipRemoverShader___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
index 9ced91f6867..5ce96212031 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
@@ -44,7 +44,7 @@ extern "C" {
int UnaryFunction0DDouble_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -133,7 +133,7 @@ static int UnaryFunction0DDouble___init__(BPy_UnaryFunction0DDouble *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -158,24 +158,24 @@ static PyObject *UnaryFunction0DDouble___call__(BPy_UnaryFunction0DDouble *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *obj;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf0D_double)) == typeid(UnaryFunction0D<double>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf0D_double->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(self->uf0D_double->result);
}
@@ -183,43 +183,47 @@ static PyObject *UnaryFunction0DDouble___call__(BPy_UnaryFunction0DDouble *self,
/*-----------------------BPy_UnaryFunction0DDouble type definition ------------------------------*/
PyTypeObject UnaryFunction0DDouble_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DDouble", /* tp_name */
- sizeof(BPy_UnaryFunction0DDouble), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction0DDouble___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction0DDouble___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction0DDouble___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction0DDouble___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction0DDouble___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DDouble", /* tp_name */
+ sizeof(BPy_UnaryFunction0DDouble), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction0DDouble___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction0DDouble___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction0DDouble___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction0DDouble___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction0DDouble___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
index 7520f647276..8c988d55c91 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
@@ -35,7 +35,7 @@ extern "C" {
int UnaryFunction0DEdgeNature_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -71,7 +71,7 @@ static int UnaryFunction0DEdgeNature___init__(BPy_UnaryFunction0DEdgeNature *sel
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -97,24 +97,24 @@ static PyObject *UnaryFunction0DEdgeNature___call__(BPy_UnaryFunction0DEdgeNatur
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *obj;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf0D_edgenature)) == typeid(UnaryFunction0D<Nature::EdgeNature>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf0D_edgenature->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return BPy_Nature_from_Nature(self->uf0D_edgenature->result);
}
@@ -122,43 +122,47 @@ static PyObject *UnaryFunction0DEdgeNature___call__(BPy_UnaryFunction0DEdgeNatur
/*-----------------------BPy_UnaryFunction0DEdgeNature type definition --------------------------*/
PyTypeObject UnaryFunction0DEdgeNature_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DEdgeNature", /* tp_name */
- sizeof(BPy_UnaryFunction0DEdgeNature), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction0DEdgeNature___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction0DEdgeNature___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction0DEdgeNature___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction0DEdgeNature___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction0DEdgeNature___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DEdgeNature", /* tp_name */
+ sizeof(BPy_UnaryFunction0DEdgeNature), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction0DEdgeNature___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction0DEdgeNature___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction0DEdgeNature___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction0DEdgeNature___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction0DEdgeNature___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp
index 7ee0d9bd71d..25b19e84b60 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp
@@ -40,7 +40,7 @@ extern "C" {
int UnaryFunction0DFloat_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -109,7 +109,7 @@ static int UnaryFunction0DFloat___init__(BPy_UnaryFunction0DFloat *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -134,24 +134,24 @@ static PyObject *UnaryFunction0DFloat___call__(BPy_UnaryFunction0DFloat *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *obj;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf0D_float)) == typeid(UnaryFunction0D<float>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf0D_float->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(self->uf0D_float->result);
}
@@ -159,43 +159,47 @@ static PyObject *UnaryFunction0DFloat___call__(BPy_UnaryFunction0DFloat *self,
/*-----------------------BPy_UnaryFunction0DFloat type definition ------------------------------*/
PyTypeObject UnaryFunction0DFloat_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DFloat", /* tp_name */
- sizeof(BPy_UnaryFunction0DFloat), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction0DFloat___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction0DFloat___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction0DFloat___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction0DFloat___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction0DFloat___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DFloat", /* tp_name */
+ sizeof(BPy_UnaryFunction0DFloat), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction0DFloat___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction0DFloat___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction0DFloat___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction0DFloat___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction0DFloat___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp
index 9c0f833d8fa..b2426cab572 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp
@@ -35,7 +35,7 @@ extern "C" {
int UnaryFunction0DId_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -68,7 +68,7 @@ static char UnaryFunction0DId___doc__[] =
static int UnaryFunction0DId___init__(BPy_UnaryFunction0DId *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -93,24 +93,24 @@ static PyObject *UnaryFunction0DId___call__(BPy_UnaryFunction0DId *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *obj;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf0D_id)) == typeid(UnaryFunction0D<Id>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf0D_id->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return BPy_Id_from_Id(self->uf0D_id->result);
}
@@ -118,43 +118,47 @@ static PyObject *UnaryFunction0DId___call__(BPy_UnaryFunction0DId *self,
/*-----------------------BPy_UnaryFunction0DId type definition ------------------------------*/
PyTypeObject UnaryFunction0DId_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DId", /* tp_name */
- sizeof(BPy_UnaryFunction0DId), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction0DId___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction0DId___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction0DId___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction0DId___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction0DId___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DId", /* tp_name */
+ sizeof(BPy_UnaryFunction0DId), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction0DId___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction0DId___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction0DId___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction0DId___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction0DId___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
index 95cdc1522ac..77f89265ba4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
@@ -35,7 +35,7 @@ extern "C" {
int UnaryFunction0DMaterial_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -70,7 +70,7 @@ static int UnaryFunction0DMaterial___init__(BPy_UnaryFunction0DMaterial *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -96,24 +96,24 @@ static PyObject *UnaryFunction0DMaterial___call__(BPy_UnaryFunction0DMaterial *s
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *obj;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf0D_material)) == typeid(UnaryFunction0D<FrsMaterial>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf0D_material->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return BPy_FrsMaterial_from_FrsMaterial(self->uf0D_material->result);
}
@@ -121,43 +121,47 @@ static PyObject *UnaryFunction0DMaterial___call__(BPy_UnaryFunction0DMaterial *s
/*-----------------------BPy_UnaryFunction0DMaterial type definition ----------------------------*/
PyTypeObject UnaryFunction0DMaterial_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DMaterial", /* tp_name */
- sizeof(BPy_UnaryFunction0DMaterial), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction0DMaterial___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction0DMaterial___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction0DMaterial___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction0DMaterial___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction0DMaterial___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DMaterial", /* tp_name */
+ sizeof(BPy_UnaryFunction0DMaterial), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction0DMaterial___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction0DMaterial___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction0DMaterial___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction0DMaterial___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction0DMaterial___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
index 17ddd9773d2..52f990502ef 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
@@ -35,7 +35,7 @@ extern "C" {
int UnaryFunction0DUnsigned_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -71,7 +71,7 @@ static int UnaryFunction0DUnsigned___init__(BPy_UnaryFunction0DUnsigned *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -97,24 +97,24 @@ static PyObject *UnaryFunction0DUnsigned___call__(BPy_UnaryFunction0DUnsigned *s
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *obj;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf0D_unsigned)) == typeid(UnaryFunction0D<unsigned int>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf0D_unsigned->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return PyLong_FromLong(self->uf0D_unsigned->result);
}
@@ -122,43 +122,47 @@ static PyObject *UnaryFunction0DUnsigned___call__(BPy_UnaryFunction0DUnsigned *s
/*-----------------------BPy_UnaryFunction0DUnsigned type definition ----------------------------*/
PyTypeObject UnaryFunction0DUnsigned_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DUnsigned", /* tp_name */
- sizeof(BPy_UnaryFunction0DUnsigned), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction0DUnsigned___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction0DUnsigned___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction0DUnsigned___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction0DUnsigned___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction0DUnsigned___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DUnsigned", /* tp_name */
+ sizeof(BPy_UnaryFunction0DUnsigned), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction0DUnsigned___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction0DUnsigned___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction0DUnsigned___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction0DUnsigned___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction0DUnsigned___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp
index 3ff73dca832..45e1144cd32 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp
@@ -36,7 +36,7 @@ extern "C" {
int UnaryFunction0DVec2f_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -77,7 +77,7 @@ static int UnaryFunction0DVec2f___init__(BPy_UnaryFunction0DVec2f *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -102,24 +102,24 @@ static PyObject *UnaryFunction0DVec2f___call__(BPy_UnaryFunction0DVec2f *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *obj;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf0D_vec2f)) == typeid(UnaryFunction0D<Vec2f>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf0D_vec2f->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return Vector_from_Vec2f(self->uf0D_vec2f->result);
}
@@ -127,43 +127,47 @@ static PyObject *UnaryFunction0DVec2f___call__(BPy_UnaryFunction0DVec2f *self,
/*-----------------------BPy_UnaryFunction0DVec2f type definition ------------------------------*/
PyTypeObject UnaryFunction0DVec2f_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DVec2f", /* tp_name */
- sizeof(BPy_UnaryFunction0DVec2f), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction0DVec2f___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction0DVec2f___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction0DVec2f___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction0DVec2f___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction0DVec2f___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DVec2f", /* tp_name */
+ sizeof(BPy_UnaryFunction0DVec2f), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction0DVec2f___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction0DVec2f___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction0DVec2f___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction0DVec2f___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction0DVec2f___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
index afbd25df122..18eeae86dd7 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
@@ -35,7 +35,7 @@ extern "C" {
int UnaryFunction0DVec3f_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -70,7 +70,7 @@ static int UnaryFunction0DVec3f___init__(BPy_UnaryFunction0DVec3f *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -95,24 +95,24 @@ static PyObject *UnaryFunction0DVec3f___call__(BPy_UnaryFunction0DVec3f *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *obj;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf0D_vec3f)) == typeid(UnaryFunction0D<Vec3f>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf0D_vec3f->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return Vector_from_Vec3f(self->uf0D_vec3f->result);
}
@@ -120,43 +120,47 @@ static PyObject *UnaryFunction0DVec3f___call__(BPy_UnaryFunction0DVec3f *self,
/*-----------------------BPy_UnaryFunction0DVec3f type definition ------------------------------*/
PyTypeObject UnaryFunction0DVec3f_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DVec3f", /* tp_name */
- sizeof(BPy_UnaryFunction0DVec3f), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction0DVec3f___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction0DVec3f___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction0DVec3f___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction0DVec3f___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction0DVec3f___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DVec3f", /* tp_name */
+ sizeof(BPy_UnaryFunction0DVec3f), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction0DVec3f___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction0DVec3f___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction0DVec3f___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction0DVec3f___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction0DVec3f___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
index 4fd6d949974..28c4425b2a4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
@@ -35,7 +35,7 @@ extern "C" {
int UnaryFunction0DVectorViewShape_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -72,7 +72,7 @@ static int UnaryFunction0DVectorViewShape___init__(BPy_UnaryFunction0DVectorView
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -98,24 +98,24 @@ static PyObject *UnaryFunction0DVectorViewShape___call__(BPy_UnaryFunction0DVect
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *obj;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf0D_vectorviewshape)) == typeid(UnaryFunction0D<std::vector<ViewShape *>>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf0D_vectorviewshape->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
const unsigned int list_len = self->uf0D_vectorviewshape->result.size();
@@ -131,43 +131,47 @@ static PyObject *UnaryFunction0DVectorViewShape___call__(BPy_UnaryFunction0DVect
/*-----------------------BPy_UnaryFunction0DVectorViewShape type definition ---------------------*/
PyTypeObject UnaryFunction0DVectorViewShape_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DVectorViewShape", /* tp_name */
- sizeof(BPy_UnaryFunction0DVectorViewShape), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction0DVectorViewShape___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction0DVectorViewShape___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction0DVectorViewShape___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction0DVectorViewShape___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction0DVectorViewShape___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DVectorViewShape", /* tp_name */
+ sizeof(BPy_UnaryFunction0DVectorViewShape), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction0DVectorViewShape___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction0DVectorViewShape___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction0DVectorViewShape___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction0DVectorViewShape___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction0DVectorViewShape___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
index 0f623b0e765..75773aaa8d0 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
@@ -36,7 +36,7 @@ extern "C" {
int UnaryFunction0DViewShape_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -78,7 +78,7 @@ static int UnaryFunction0DViewShape___init__(BPy_UnaryFunction0DViewShape *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -104,24 +104,24 @@ static PyObject *UnaryFunction0DViewShape___call__(BPy_UnaryFunction0DViewShape
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"it", NULL};
+ static const char *kwlist[] = {"it", nullptr};
PyObject *obj;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf0D_viewshape)) == typeid(UnaryFunction0D<ViewShape *>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf0D_viewshape->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return BPy_ViewShape_from_ViewShape(*(self->uf0D_viewshape->result));
}
@@ -129,43 +129,47 @@ static PyObject *UnaryFunction0DViewShape___call__(BPy_UnaryFunction0DViewShape
/*-----------------------BPy_UnaryFunction0DViewShape type definition ---------------------------*/
PyTypeObject UnaryFunction0DViewShape_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DViewShape", /* tp_name */
- sizeof(BPy_UnaryFunction0DViewShape), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction0DViewShape___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction0DViewShape___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction0DViewShape___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction0DViewShape___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction0DViewShape___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DViewShape", /* tp_name */
+ sizeof(BPy_UnaryFunction0DViewShape), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction0DViewShape___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction0DViewShape___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction0DViewShape___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction0DViewShape___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction0DViewShape___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp
index 6d4406b17a7..b59e72e23d2 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp
@@ -57,7 +57,7 @@ static char ShapeIdF0D___doc__[] =
static int ShapeIdF0D___init__(BPy_ShapeIdF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -70,43 +70,47 @@ static int ShapeIdF0D___init__(BPy_ShapeIdF0D *self, PyObject *args, PyObject *k
/*-----------------------BPy_ShapeIdF0D type definition ------------------------------*/
PyTypeObject ShapeIdF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ShapeIdF0D", /* tp_name */
- sizeof(BPy_ShapeIdF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ShapeIdF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DId_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ShapeIdF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ShapeIdF0D", /* tp_name */
+ sizeof(BPy_ShapeIdF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ShapeIdF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DId_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ShapeIdF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp
index a9050c4594e..9f7f2b234f7 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp
@@ -60,7 +60,7 @@ static char MaterialF0D___doc__[] =
static int MaterialF0D___init__(BPy_MaterialF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -73,43 +73,47 @@ static int MaterialF0D___init__(BPy_MaterialF0D *self, PyObject *args, PyObject
/*-----------------------BPy_MaterialF0D type definition ------------------------------*/
PyTypeObject MaterialF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "MaterialF0D", /* tp_name */
- sizeof(BPy_MaterialF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- MaterialF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DMaterial_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)MaterialF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "MaterialF0D", /* tp_name */
+ sizeof(BPy_MaterialF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ MaterialF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DMaterial_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)MaterialF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp
index 1173b2434d6..1cd1a4ab8ac 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp
@@ -51,7 +51,7 @@ static char CurveNatureF0D___doc__[] =
static int CurveNatureF0D___init__(BPy_CurveNatureF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -64,43 +64,47 @@ static int CurveNatureF0D___init__(BPy_CurveNatureF0D *self, PyObject *args, PyO
/*-----------------------BPy_CurveNatureF0D type definition ------------------------------*/
PyTypeObject CurveNatureF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "CurveNatureF0D", /* tp_name */
- sizeof(BPy_CurveNatureF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- CurveNatureF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DEdgeNature_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)CurveNatureF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "CurveNatureF0D", /* tp_name */
+ sizeof(BPy_CurveNatureF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ CurveNatureF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DEdgeNature_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)CurveNatureF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp
index 673522a055e..60cfed83713 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp
@@ -53,7 +53,7 @@ static char Normal2DF0D___doc__[] =
static int Normal2DF0D___init__(BPy_Normal2DF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -66,43 +66,47 @@ static int Normal2DF0D___init__(BPy_Normal2DF0D *self, PyObject *args, PyObject
/*-----------------------BPy_Normal2DF0D type definition ------------------------------*/
PyTypeObject Normal2DF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Normal2DF0D", /* tp_name */
- sizeof(BPy_Normal2DF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Normal2DF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DVec2f_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Normal2DF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Normal2DF0D", /* tp_name */
+ sizeof(BPy_Normal2DF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Normal2DF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DVec2f_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Normal2DF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
index 5ec616c90c1..063f1651486 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
@@ -55,7 +55,7 @@ static int VertexOrientation2DF0D___init__(BPy_VertexOrientation2DF0D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -68,43 +68,47 @@ static int VertexOrientation2DF0D___init__(BPy_VertexOrientation2DF0D *self,
/*-----------------------BPy_VertexOrientation2DF0D type definition -----------------------------*/
PyTypeObject VertexOrientation2DF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "VertexOrientation2DF0D", /* tp_name */
- sizeof(BPy_VertexOrientation2DF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- VertexOrientation2DF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DVec2f_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)VertexOrientation2DF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "VertexOrientation2DF0D", /* tp_name */
+ sizeof(BPy_VertexOrientation2DF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ VertexOrientation2DF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DVec2f_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)VertexOrientation2DF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp
index 6db4c9317e2..b0188cd0244 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp
@@ -55,7 +55,7 @@ static int VertexOrientation3DF0D___init__(BPy_VertexOrientation3DF0D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -68,43 +68,47 @@ static int VertexOrientation3DF0D___init__(BPy_VertexOrientation3DF0D *self,
/*-----------------------BPy_VertexOrientation3DF0D type definition -----------------------------*/
PyTypeObject VertexOrientation3DF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "VertexOrientation3DF0D", /* tp_name */
- sizeof(BPy_VertexOrientation3DF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- VertexOrientation3DF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DVec3f_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)VertexOrientation3DF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "VertexOrientation3DF0D", /* tp_name */
+ sizeof(BPy_VertexOrientation3DF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ VertexOrientation3DF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DVec3f_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)VertexOrientation3DF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp
index 827c089aa1a..ba890477782 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp
@@ -50,7 +50,7 @@ static char GetOccludeeF0D___doc__[] =
static int GetOccludeeF0D___init__(BPy_GetOccludeeF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int GetOccludeeF0D___init__(BPy_GetOccludeeF0D *self, PyObject *args, PyO
/*-----------------------BPy_GetOccludeeF0D type definition ------------------------------*/
PyTypeObject GetOccludeeF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetOccludeeF0D", /* tp_name */
- sizeof(BPy_GetOccludeeF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetOccludeeF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DViewShape_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetOccludeeF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetOccludeeF0D", /* tp_name */
+ sizeof(BPy_GetOccludeeF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetOccludeeF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DViewShape_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetOccludeeF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp
index 31b36dbf855..531020dc32a 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp
@@ -50,7 +50,7 @@ static char GetShapeF0D___doc__[] =
static int GetShapeF0D___init__(BPy_GetShapeF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int GetShapeF0D___init__(BPy_GetShapeF0D *self, PyObject *args, PyObject
/*-----------------------BPy_GetShapeF0D type definition ------------------------------*/
PyTypeObject GetShapeF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetShapeF0D", /* tp_name */
- sizeof(BPy_GetShapeF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetShapeF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DViewShape_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetShapeF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetShapeF0D", /* tp_name */
+ sizeof(BPy_GetShapeF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetShapeF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DViewShape_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetShapeF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp
index 5f1d123c8d3..cb36e388306 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp
@@ -55,7 +55,7 @@ static int Curvature2DAngleF0D___init__(BPy_Curvature2DAngleF0D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -68,43 +68,47 @@ static int Curvature2DAngleF0D___init__(BPy_Curvature2DAngleF0D *self,
/*-----------------------BPy_Curvature2DAngleF0D type definition ------------------------------*/
PyTypeObject Curvature2DAngleF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Curvature2DAngleF0D", /* tp_name */
- sizeof(BPy_Curvature2DAngleF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Curvature2DAngleF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Curvature2DAngleF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Curvature2DAngleF0D", /* tp_name */
+ sizeof(BPy_Curvature2DAngleF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Curvature2DAngleF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Curvature2DAngleF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp
index 736afca7fae..ca306a55d1e 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp
@@ -59,7 +59,7 @@ static char DensityF0D___doc__[] =
static int DensityF0D___init__(BPy_DensityF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"sigma", NULL};
+ static const char *kwlist[] = {"sigma", nullptr};
double d = 2;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|d", (char **)kwlist, &d)) {
@@ -73,43 +73,47 @@ static int DensityF0D___init__(BPy_DensityF0D *self, PyObject *args, PyObject *k
/*-----------------------BPy_DensityF0D type definition ------------------------------*/
PyTypeObject DensityF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "DensityF0D", /* tp_name */
- sizeof(BPy_DensityF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- DensityF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)DensityF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "DensityF0D", /* tp_name */
+ sizeof(BPy_DensityF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ DensityF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)DensityF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp
index d3cd14a1aba..6a688212239 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp
@@ -50,7 +50,7 @@ static char GetProjectedXF0D___doc__[] =
static int GetProjectedXF0D___init__(BPy_GetProjectedXF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int GetProjectedXF0D___init__(BPy_GetProjectedXF0D *self, PyObject *args,
/*-----------------------BPy_GetProjectedXF0D type definition ------------------------------*/
PyTypeObject GetProjectedXF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetProjectedXF0D", /* tp_name */
- sizeof(BPy_GetProjectedXF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetProjectedXF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetProjectedXF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetProjectedXF0D", /* tp_name */
+ sizeof(BPy_GetProjectedXF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetProjectedXF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetProjectedXF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp
index 92d5a1e4216..8efaaf1b699 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp
@@ -50,7 +50,7 @@ static char GetProjectedYF0D___doc__[] =
static int GetProjectedYF0D___init__(BPy_GetProjectedYF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int GetProjectedYF0D___init__(BPy_GetProjectedYF0D *self, PyObject *args,
/*-----------------------BPy_GetProjectedYF0D type definition ------------------------------*/
PyTypeObject GetProjectedYF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetProjectedYF0D", /* tp_name */
- sizeof(BPy_GetProjectedYF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetProjectedYF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetProjectedYF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetProjectedYF0D", /* tp_name */
+ sizeof(BPy_GetProjectedYF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetProjectedYF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetProjectedYF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp
index cb2a5e3a102..e13c990685f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp
@@ -50,7 +50,7 @@ static char GetProjectedZF0D___doc__[] =
static int GetProjectedZF0D___init__(BPy_GetProjectedZF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int GetProjectedZF0D___init__(BPy_GetProjectedZF0D *self, PyObject *args,
/*-----------------------BPy_GetProjectedZF0D type definition ------------------------------*/
PyTypeObject GetProjectedZF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetProjectedZF0D", /* tp_name */
- sizeof(BPy_GetProjectedZF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetProjectedZF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetProjectedZF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetProjectedZF0D", /* tp_name */
+ sizeof(BPy_GetProjectedZF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetProjectedZF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetProjectedZF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp
index dd75001f3bd..43cbb433bdd 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp
@@ -50,7 +50,7 @@ static char GetXF0D___doc__[] =
static int GetXF0D___init__(BPy_GetXF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int GetXF0D___init__(BPy_GetXF0D *self, PyObject *args, PyObject *kwds)
/*-----------------------BPy_GetXF0D type definition ------------------------------*/
PyTypeObject GetXF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetXF0D", /* tp_name */
- sizeof(BPy_GetXF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetXF0D", /* tp_name */
+ sizeof(BPy_GetXF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
GetXF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
&UnaryFunction0DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)GetXF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp
index 09e2a84e29f..24bfe3be985 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp
@@ -50,7 +50,7 @@ static char GetYF0D___doc__[] =
static int GetYF0D___init__(BPy_GetYF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int GetYF0D___init__(BPy_GetYF0D *self, PyObject *args, PyObject *kwds)
/*-----------------------BPy_GetYF0D type definition ------------------------------*/
PyTypeObject GetYF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetYF0D", /* tp_name */
- sizeof(BPy_GetYF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetYF0D", /* tp_name */
+ sizeof(BPy_GetYF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
GetYF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
&UnaryFunction0DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)GetYF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp
index 920432530ed..84a985a134d 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp
@@ -50,7 +50,7 @@ static char GetZF0D___doc__[] =
static int GetZF0D___init__(BPy_GetZF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int GetZF0D___init__(BPy_GetZF0D *self, PyObject *args, PyObject *kwds)
/*-----------------------BPy_GetZF0D type definition ------------------------------*/
PyTypeObject GetZF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetZF0D", /* tp_name */
- sizeof(BPy_GetZF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetZF0D", /* tp_name */
+ sizeof(BPy_GetZF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
GetZF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
&UnaryFunction0DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)GetZF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp
index 58e5a1a498a..247473dcb41 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp
@@ -57,7 +57,7 @@ static int LocalAverageDepthF0D___init__(BPy_LocalAverageDepthF0D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"mask_size", NULL};
+ static const char *kwlist[] = {"mask_size", nullptr};
double d = 5.0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|d", (char **)kwlist, &d)) {
@@ -71,43 +71,47 @@ static int LocalAverageDepthF0D___init__(BPy_LocalAverageDepthF0D *self,
/*-----------------------BPy_LocalAverageDepthF0D type definition ------------------------------*/
PyTypeObject LocalAverageDepthF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "LocalAverageDepthF0D", /* tp_name */
- sizeof(BPy_LocalAverageDepthF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- LocalAverageDepthF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)LocalAverageDepthF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "LocalAverageDepthF0D", /* tp_name */
+ sizeof(BPy_LocalAverageDepthF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ LocalAverageDepthF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)LocalAverageDepthF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp
index 0d1b55f0a00..e82b5f1c557 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp
@@ -55,7 +55,7 @@ static char ZDiscontinuityF0D___doc__[] =
static int ZDiscontinuityF0D___init__(BPy_ZDiscontinuityF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -68,43 +68,47 @@ static int ZDiscontinuityF0D___init__(BPy_ZDiscontinuityF0D *self, PyObject *arg
/*-----------------------BPy_ZDiscontinuityF0D type definition ------------------------------*/
PyTypeObject ZDiscontinuityF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ZDiscontinuityF0D", /* tp_name */
- sizeof(BPy_ZDiscontinuityF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ZDiscontinuityF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ZDiscontinuityF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ZDiscontinuityF0D", /* tp_name */
+ sizeof(BPy_ZDiscontinuityF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ZDiscontinuityF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ZDiscontinuityF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp
index a00d4204d69..b4760d10b2c 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp
@@ -53,7 +53,7 @@ static int GetCurvilinearAbscissaF0D___init__(BPy_GetCurvilinearAbscissaF0D *sel
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -66,43 +66,47 @@ static int GetCurvilinearAbscissaF0D___init__(BPy_GetCurvilinearAbscissaF0D *sel
/*-----------------------BPy_GetCurvilinearAbscissaF0D type definition --------------------------*/
PyTypeObject GetCurvilinearAbscissaF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetCurvilinearAbscissaF0D", /* tp_name */
- sizeof(BPy_GetCurvilinearAbscissaF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetCurvilinearAbscissaF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DFloat_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetCurvilinearAbscissaF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetCurvilinearAbscissaF0D", /* tp_name */
+ sizeof(BPy_GetCurvilinearAbscissaF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetCurvilinearAbscissaF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DFloat_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetCurvilinearAbscissaF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp
index b4310685969..d4c735e3572 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp
@@ -50,7 +50,7 @@ static char GetParameterF0D___doc__[] =
static int GetParameterF0D___init__(BPy_GetParameterF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -61,45 +61,48 @@ static int GetParameterF0D___init__(BPy_GetParameterF0D *self, PyObject *args, P
}
/*-----------------------BPy_GetParameterF0D type definition ------------------------------*/
-
PyTypeObject GetParameterF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetParameterF0D", /* tp_name */
- sizeof(BPy_GetParameterF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetParameterF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DFloat_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetParameterF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetParameterF0D", /* tp_name */
+ sizeof(BPy_GetParameterF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetParameterF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DFloat_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetParameterF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp
index ad744918e00..6d5f1ed80c3 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp
@@ -57,7 +57,7 @@ static int GetViewMapGradientNormF0D___init__(BPy_GetViewMapGradientNormF0D *sel
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"level", NULL};
+ static const char *kwlist[] = {"level", nullptr};
int i;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", (char **)kwlist, &i)) {
@@ -71,43 +71,47 @@ static int GetViewMapGradientNormF0D___init__(BPy_GetViewMapGradientNormF0D *sel
/*-----------------------BPy_GetViewMapGradientNormF0D type definition --------------------------*/
PyTypeObject GetViewMapGradientNormF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetViewMapGradientNormF0D", /* tp_name */
- sizeof(BPy_GetViewMapGradientNormF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetViewMapGradientNormF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DFloat_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetViewMapGradientNormF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetViewMapGradientNormF0D", /* tp_name */
+ sizeof(BPy_GetViewMapGradientNormF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetViewMapGradientNormF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DFloat_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetViewMapGradientNormF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp
index 685701152f4..bbf2aee5204 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp
@@ -55,7 +55,7 @@ static int ReadCompleteViewMapPixelF0D___init__(BPy_ReadCompleteViewMapPixelF0D
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"level", NULL};
+ static const char *kwlist[] = {"level", nullptr};
int i;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", (char **)kwlist, &i)) {
@@ -69,43 +69,47 @@ static int ReadCompleteViewMapPixelF0D___init__(BPy_ReadCompleteViewMapPixelF0D
/*-----------------------BPy_ReadCompleteViewMapPixelF0D type definition ------------------------*/
PyTypeObject ReadCompleteViewMapPixelF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ReadCompleteViewMapPixelF0D", /* tp_name */
- sizeof(BPy_ReadCompleteViewMapPixelF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ReadCompleteViewMapPixelF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DFloat_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ReadCompleteViewMapPixelF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ReadCompleteViewMapPixelF0D", /* tp_name */
+ sizeof(BPy_ReadCompleteViewMapPixelF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ReadCompleteViewMapPixelF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DFloat_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ReadCompleteViewMapPixelF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp
index b74ee3b33c6..54401153d37 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp
@@ -55,7 +55,7 @@ static char ReadMapPixelF0D___doc__[] =
static int ReadMapPixelF0D___init__(BPy_ReadMapPixelF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"map_name", "level", NULL};
+ static const char *kwlist[] = {"map_name", "level", nullptr};
const char *s;
int i;
@@ -70,43 +70,47 @@ static int ReadMapPixelF0D___init__(BPy_ReadMapPixelF0D *self, PyObject *args, P
/*-----------------------BPy_ReadMapPixelF0D type definition ------------------------------*/
PyTypeObject ReadMapPixelF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ReadMapPixelF0D", /* tp_name */
- sizeof(BPy_ReadMapPixelF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ReadMapPixelF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DFloat_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ReadMapPixelF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ReadMapPixelF0D", /* tp_name */
+ sizeof(BPy_ReadMapPixelF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ReadMapPixelF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DFloat_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ReadMapPixelF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp
index a878db99e06..88ca0579870 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp
@@ -58,7 +58,7 @@ static int ReadSteerableViewMapPixelF0D___init__(BPy_ReadSteerableViewMapPixelF0
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"orientation", "level", NULL};
+ static const char *kwlist[] = {"orientation", "level", nullptr};
unsigned int u;
int i;
@@ -73,43 +73,47 @@ static int ReadSteerableViewMapPixelF0D___init__(BPy_ReadSteerableViewMapPixelF0
/*-----------------------BPy_ReadSteerableViewMapPixelF0D type definition -----------------------*/
PyTypeObject ReadSteerableViewMapPixelF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ReadSteerableViewMapPixelF0D", /* tp_name */
- sizeof(BPy_ReadSteerableViewMapPixelF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ReadSteerableViewMapPixelF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DFloat_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ReadSteerableViewMapPixelF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ReadSteerableViewMapPixelF0D", /* tp_name */
+ sizeof(BPy_ReadSteerableViewMapPixelF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ReadSteerableViewMapPixelF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DFloat_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ReadSteerableViewMapPixelF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp
index 57605e42186..d6e00988e68 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp
@@ -58,7 +58,7 @@ static int QuantitativeInvisibilityF0D___init__(BPy_QuantitativeInvisibilityF0D
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -71,43 +71,47 @@ static int QuantitativeInvisibilityF0D___init__(BPy_QuantitativeInvisibilityF0D
/*-----------------------BPy_QuantitativeInvisibilityF0D type definition ------------------------*/
PyTypeObject QuantitativeInvisibilityF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "QuantitativeInvisibilityF0D", /* tp_name */
- sizeof(BPy_QuantitativeInvisibilityF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- QuantitativeInvisibilityF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DUnsigned_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)QuantitativeInvisibilityF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "QuantitativeInvisibilityF0D", /* tp_name */
+ sizeof(BPy_QuantitativeInvisibilityF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ QuantitativeInvisibilityF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DUnsigned_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)QuantitativeInvisibilityF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp
index e56460601e5..ddff11d7916 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp
@@ -51,7 +51,7 @@ static char GetOccludersF0D___doc__[] =
static int GetOccludersF0D___init__(BPy_GetOccludersF0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -64,43 +64,47 @@ static int GetOccludersF0D___init__(BPy_GetOccludersF0D *self, PyObject *args, P
/*-----------------------BPy_GetOccludersF0D type definition ------------------------------*/
PyTypeObject GetOccludersF0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetOccludersF0D", /* tp_name */
- sizeof(BPy_GetOccludersF0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetOccludersF0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction0DVectorViewShape_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetOccludersF0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetOccludersF0D", /* tp_name */
+ sizeof(BPy_GetOccludersF0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetOccludersF0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction0DVectorViewShape_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetOccludersF0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp
index b59e27dcea9..57b2d61d5c1 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp
@@ -49,7 +49,7 @@ extern "C" {
int UnaryFunction1DDouble_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -172,8 +172,8 @@ static int UnaryFunction1DDouble___init__(BPy_UnaryFunction1DDouble *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"integration", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -207,23 +207,23 @@ static PyObject *UnaryFunction1DDouble___call__(BPy_UnaryFunction1DDouble *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"inter", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"inter", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf1D_double)) == typeid(UnaryFunction1D<double>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf1D_double->operator()(*(((BPy_Interface1D *)obj)->if1D)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(self->uf1D_double->result);
}
@@ -257,50 +257,54 @@ static PyGetSetDef BPy_UnaryFunction1DDouble_getseters[] = {
(getter)integration_type_get,
(setter)integration_type_set,
integration_type_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryFunction1DDouble type definition ------------------------------*/
PyTypeObject UnaryFunction1DDouble_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DDouble", /* tp_name */
- sizeof(BPy_UnaryFunction1DDouble), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction1DDouble___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction1DDouble___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction1DDouble___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction1DDouble___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryFunction1DDouble_getseters, /* tp_getset */
- &UnaryFunction1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction1DDouble___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction1DDouble", /* tp_name */
+ sizeof(BPy_UnaryFunction1DDouble), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction1DDouble___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction1DDouble___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction1DDouble___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction1DDouble___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryFunction1DDouble_getseters, /* tp_getset */
+ &UnaryFunction1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction1DDouble___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
index 2f5a59f9c7a..a987dbb67f5 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
@@ -36,7 +36,7 @@ extern "C" {
int UnaryFunction1DEdgeNature_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -77,8 +77,8 @@ static int UnaryFunction1DEdgeNature___init__(BPy_UnaryFunction1DEdgeNature *sel
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"integration", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -114,23 +114,23 @@ static PyObject *UnaryFunction1DEdgeNature___call__(BPy_UnaryFunction1DEdgeNatur
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"inter", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"inter", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf1D_edgenature)) == typeid(UnaryFunction1D<Nature::EdgeNature>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf1D_edgenature->operator()(*(((BPy_Interface1D *)obj)->if1D)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return BPy_Nature_from_Nature(self->uf1D_edgenature->result);
}
@@ -164,50 +164,54 @@ static PyGetSetDef BPy_UnaryFunction1DEdgeNature_getseters[] = {
(getter)integration_type_get,
(setter)integration_type_set,
integration_type_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryFunction1DEdgeNature type definition --------------------------*/
PyTypeObject UnaryFunction1DEdgeNature_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DEdgeNature", /* tp_name */
- sizeof(BPy_UnaryFunction1DEdgeNature), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction1DEdgeNature___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction1DEdgeNature___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction1DEdgeNature___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction1DEdgeNature___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryFunction1DEdgeNature_getseters, /* tp_getset */
- &UnaryFunction1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction1DEdgeNature___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction1DEdgeNature", /* tp_name */
+ sizeof(BPy_UnaryFunction1DEdgeNature), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction1DEdgeNature___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction1DEdgeNature___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction1DEdgeNature___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction1DEdgeNature___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryFunction1DEdgeNature_getseters, /* tp_getset */
+ &UnaryFunction1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction1DEdgeNature___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp
index e11d21b6c8e..66499c68c65 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp
@@ -34,7 +34,7 @@ extern "C" {
int UnaryFunction1DFloat_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -68,8 +68,8 @@ static int UnaryFunction1DFloat___init__(BPy_UnaryFunction1DFloat *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"integration", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -103,23 +103,23 @@ static PyObject *UnaryFunction1DFloat___call__(BPy_UnaryFunction1DFloat *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"inter", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"inter", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf1D_float)) == typeid(UnaryFunction1D<float>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf1D_float->operator()(*(((BPy_Interface1D *)obj)->if1D)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(self->uf1D_float->result);
}
@@ -153,50 +153,54 @@ static PyGetSetDef BPy_UnaryFunction1DFloat_getseters[] = {
(getter)integration_type_get,
(setter)integration_type_set,
integration_type_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryFunction1DFloat type definition ------------------------------*/
PyTypeObject UnaryFunction1DFloat_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DFloat", /* tp_name */
- sizeof(BPy_UnaryFunction1DFloat), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction1DFloat___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction1DFloat___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction1DFloat___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction1DFloat___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryFunction1DFloat_getseters, /* tp_getset */
- &UnaryFunction1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction1DFloat___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction1DFloat", /* tp_name */
+ sizeof(BPy_UnaryFunction1DFloat), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction1DFloat___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction1DFloat___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction1DFloat___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction1DFloat___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryFunction1DFloat_getseters, /* tp_getset */
+ &UnaryFunction1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction1DFloat___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
index e04a5b9d7f4..54c5c786367 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
@@ -36,7 +36,7 @@ extern "C" {
int UnaryFunction1DUnsigned_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -77,8 +77,8 @@ static int UnaryFunction1DUnsigned___init__(BPy_UnaryFunction1DUnsigned *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"integration", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -114,23 +114,23 @@ static PyObject *UnaryFunction1DUnsigned___call__(BPy_UnaryFunction1DUnsigned *s
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"inter", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"inter", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf1D_unsigned)) == typeid(UnaryFunction1D<unsigned int>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf1D_unsigned->operator()(*(((BPy_Interface1D *)obj)->if1D)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return PyLong_FromLong(self->uf1D_unsigned->result);
}
@@ -164,50 +164,54 @@ static PyGetSetDef BPy_UnaryFunction1DUnsigned_getseters[] = {
(getter)integration_type_get,
(setter)integration_type_set,
integration_type_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryFunction1DUnsigned type definition ----------------------------*/
PyTypeObject UnaryFunction1DUnsigned_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DUnsigned", /* tp_name */
- sizeof(BPy_UnaryFunction1DUnsigned), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction1DUnsigned___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction1DUnsigned___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction1DUnsigned___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction1DUnsigned___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryFunction1DUnsigned_getseters, /* tp_getset */
- &UnaryFunction1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction1DUnsigned___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction1DUnsigned", /* tp_name */
+ sizeof(BPy_UnaryFunction1DUnsigned), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction1DUnsigned___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction1DUnsigned___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction1DUnsigned___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction1DUnsigned___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryFunction1DUnsigned_getseters, /* tp_getset */
+ &UnaryFunction1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction1DUnsigned___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp
index f8d75640811..8b23163fc95 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp
@@ -37,7 +37,7 @@ extern "C" {
int UnaryFunction1DVec2f_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -83,8 +83,8 @@ static int UnaryFunction1DVec2f___init__(BPy_UnaryFunction1DVec2f *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"integration", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -118,23 +118,23 @@ static PyObject *UnaryFunction1DVec2f___call__(BPy_UnaryFunction1DVec2f *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"inter", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"inter", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf1D_vec2f)) == typeid(UnaryFunction1D<Vec2f>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf1D_vec2f->operator()(*(((BPy_Interface1D *)obj)->if1D)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return Vector_from_Vec2f(self->uf1D_vec2f->result);
}
@@ -168,50 +168,54 @@ static PyGetSetDef BPy_UnaryFunction1DVec2f_getseters[] = {
(getter)integration_type_get,
(setter)integration_type_set,
integration_type_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryFunction1DVec2f type definition ------------------------------*/
PyTypeObject UnaryFunction1DVec2f_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DVec2f", /* tp_name */
- sizeof(BPy_UnaryFunction1DVec2f), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction1DVec2f___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction1DVec2f___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction1DVec2f___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction1DVec2f___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryFunction1DVec2f_getseters, /* tp_getset */
- &UnaryFunction1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction1DVec2f___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction1DVec2f", /* tp_name */
+ sizeof(BPy_UnaryFunction1DVec2f), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction1DVec2f___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction1DVec2f___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction1DVec2f___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction1DVec2f___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryFunction1DVec2f_getseters, /* tp_getset */
+ &UnaryFunction1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction1DVec2f___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp
index 9f71fb3840b..9b6a2445588 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp
@@ -36,7 +36,7 @@ extern "C" {
int UnaryFunction1DVec3f_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -76,8 +76,8 @@ static int UnaryFunction1DVec3f___init__(BPy_UnaryFunction1DVec3f *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"integration", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -111,23 +111,23 @@ static PyObject *UnaryFunction1DVec3f___call__(BPy_UnaryFunction1DVec3f *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"inter", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"inter", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf1D_vec3f)) == typeid(UnaryFunction1D<Vec3f>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf1D_vec3f->operator()(*(((BPy_Interface1D *)obj)->if1D)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
return Vector_from_Vec3f(self->uf1D_vec3f->result);
}
@@ -161,50 +161,54 @@ static PyGetSetDef BPy_UnaryFunction1DVec3f_getseters[] = {
(getter)integration_type_get,
(setter)integration_type_set,
integration_type_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryFunction1DVec3f type definition ------------------------------*/
PyTypeObject UnaryFunction1DVec3f_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DVec3f", /* tp_name */
- sizeof(BPy_UnaryFunction1DVec3f), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction1DVec3f___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction1DVec3f___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction1DVec3f___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction1DVec3f___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryFunction1DVec3f_getseters, /* tp_getset */
- &UnaryFunction1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction1DVec3f___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction1DVec3f", /* tp_name */
+ sizeof(BPy_UnaryFunction1DVec3f), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction1DVec3f___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction1DVec3f___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction1DVec3f___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction1DVec3f___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryFunction1DVec3f_getseters, /* tp_getset */
+ &UnaryFunction1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction1DVec3f___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
index cb4982f4532..c95595dc953 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
@@ -38,7 +38,7 @@ extern "C" {
int UnaryFunction1DVectorViewShape_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -92,8 +92,8 @@ static int UnaryFunction1DVectorViewShape___init__(BPy_UnaryFunction1DVectorView
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"integration", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -129,23 +129,23 @@ static PyObject *UnaryFunction1DVectorViewShape___call__(BPy_UnaryFunction1DVect
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"inter", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"inter", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf1D_vectorviewshape)) == typeid(UnaryFunction1D<std::vector<ViewShape *>>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf1D_vectorviewshape->operator()(*(((BPy_Interface1D *)obj)->if1D)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
const unsigned int list_len = self->uf1D_vectorviewshape->result.size();
@@ -189,50 +189,54 @@ static PyGetSetDef BPy_UnaryFunction1DVectorViewShape_getseters[] = {
(getter)integration_type_get,
(setter)integration_type_set,
integration_type_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryFunction1DVectorViewShape type definition ---------------------*/
PyTypeObject UnaryFunction1DVectorViewShape_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DVectorViewShape", /* tp_name */
- sizeof(BPy_UnaryFunction1DVectorViewShape), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction1DVectorViewShape___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction1DVectorViewShape___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction1DVectorViewShape___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction1DVectorViewShape___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryFunction1DVectorViewShape_getseters, /* tp_getset */
- &UnaryFunction1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction1DVectorViewShape___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction1DVectorViewShape", /* tp_name */
+ sizeof(BPy_UnaryFunction1DVectorViewShape), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction1DVectorViewShape___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction1DVectorViewShape___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction1DVectorViewShape___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction1DVectorViewShape___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryFunction1DVectorViewShape_getseters, /* tp_getset */
+ &UnaryFunction1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction1DVectorViewShape___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp
index 46564cdaeca..b258b0b27f7 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp
@@ -38,7 +38,7 @@ extern "C" {
int UnaryFunction1DVoid_Init(PyObject *module)
{
- if (module == NULL) {
+ if (module == nullptr) {
return -1;
}
@@ -91,8 +91,8 @@ static int UnaryFunction1DVoid___init__(BPy_UnaryFunction1DVoid *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"integration", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -126,23 +126,23 @@ static PyObject *UnaryFunction1DVoid___call__(BPy_UnaryFunction1DVoid *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"inter", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"inter", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) {
- return NULL;
+ return nullptr;
}
if (typeid(*(self->uf1D_void)) == typeid(UnaryFunction1D_void)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
- return NULL;
+ return nullptr;
}
if (self->uf1D_void->operator()(*(((BPy_Interface1D *)obj)->if1D)) < 0) {
if (!PyErr_Occurred()) {
string class_name(Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -176,50 +176,54 @@ static PyGetSetDef BPy_UnaryFunction1DVoid_getseters[] = {
(getter)integration_type_get,
(setter)integration_type_set,
integration_type_doc,
- NULL},
- {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+ nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
};
/*-----------------------BPy_UnaryFunction1DVoid type definition ------------------------------*/
PyTypeObject UnaryFunction1DVoid_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DVoid", /* tp_name */
- sizeof(BPy_UnaryFunction1DVoid), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)UnaryFunction1DVoid___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- (reprfunc)UnaryFunction1DVoid___repr__, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- (ternaryfunc)UnaryFunction1DVoid___call__, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- UnaryFunction1DVoid___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- BPy_UnaryFunction1DVoid_getseters, /* tp_getset */
- &UnaryFunction1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)UnaryFunction1DVoid___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction1DVoid", /* tp_name */
+ sizeof(BPy_UnaryFunction1DVoid), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)UnaryFunction1DVoid___dealloc__, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ (reprfunc)UnaryFunction1DVoid___repr__, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ (ternaryfunc)UnaryFunction1DVoid___call__, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ UnaryFunction1DVoid___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ BPy_UnaryFunction1DVoid_getseters, /* tp_getset */
+ &UnaryFunction1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)UnaryFunction1DVoid___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp
index 2504a09016c..205820d9a92 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp
@@ -61,8 +61,8 @@ static char CurveNatureF1D___doc__[] =
static int CurveNatureF1D___init__(BPy_CurveNatureF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -76,43 +76,47 @@ static int CurveNatureF1D___init__(BPy_CurveNatureF1D *self, PyObject *args, PyO
/*-----------------------BPy_CurveNatureF1D type definition ------------------------------*/
PyTypeObject CurveNatureF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "CurveNatureF1D", /* tp_name */
- sizeof(BPy_CurveNatureF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- CurveNatureF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DEdgeNature_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)CurveNatureF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "CurveNatureF1D", /* tp_name */
+ sizeof(BPy_CurveNatureF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ CurveNatureF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DEdgeNature_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)CurveNatureF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp
index f1cdd6a0cb8..d22a1ec99ef 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp
@@ -55,8 +55,8 @@ static char Normal2DF1D___doc__[] =
static int Normal2DF1D___init__(BPy_Normal2DF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -70,43 +70,47 @@ static int Normal2DF1D___init__(BPy_Normal2DF1D *self, PyObject *args, PyObject
/*-----------------------BPy_Normal2DF1D type definition ------------------------------*/
PyTypeObject Normal2DF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Normal2DF1D", /* tp_name */
- sizeof(BPy_Normal2DF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Normal2DF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DVec2f_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Normal2DF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Normal2DF1D", /* tp_name */
+ sizeof(BPy_Normal2DF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Normal2DF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DVec2f_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Normal2DF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp
index 27d6c509348..f66bd4c668f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp
@@ -55,8 +55,8 @@ static char Orientation2DF1D___doc__[] =
static int Orientation2DF1D___init__(BPy_Orientation2DF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -70,43 +70,47 @@ static int Orientation2DF1D___init__(BPy_Orientation2DF1D *self, PyObject *args,
/*-----------------------BPy_Orientation2DF1D type definition ------------------------------*/
PyTypeObject Orientation2DF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Orientation2DF1D", /* tp_name */
- sizeof(BPy_Orientation2DF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Orientation2DF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DVec2f_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Orientation2DF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Orientation2DF1D", /* tp_name */
+ sizeof(BPy_Orientation2DF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Orientation2DF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DVec2f_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Orientation2DF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp
index 1a2d9c5e745..2f408d45b74 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp
@@ -55,8 +55,8 @@ static char Orientation3DF1D___doc__[] =
static int Orientation3DF1D___init__(BPy_Orientation3DF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -70,43 +70,47 @@ static int Orientation3DF1D___init__(BPy_Orientation3DF1D *self, PyObject *args,
/*-----------------------BPy_Orientation3DF1D type definition ------------------------------*/
PyTypeObject Orientation3DF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Orientation3DF1D", /* tp_name */
- sizeof(BPy_Orientation3DF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Orientation3DF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DVec3f_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Orientation3DF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Orientation3DF1D", /* tp_name */
+ sizeof(BPy_Orientation3DF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Orientation3DF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DVec3f_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Orientation3DF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp
index 4d0e1a66f56..13455eb3a4c 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp
@@ -57,8 +57,8 @@ static int Curvature2DAngleF1D___init__(BPy_Curvature2DAngleF1D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -71,43 +71,47 @@ static int Curvature2DAngleF1D___init__(BPy_Curvature2DAngleF1D *self,
/*-----------------------BPy_Curvature2DAngleF1D type definition ------------------------------*/
PyTypeObject Curvature2DAngleF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "Curvature2DAngleF1D", /* tp_name */
- sizeof(BPy_Curvature2DAngleF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- Curvature2DAngleF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Curvature2DAngleF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "Curvature2DAngleF1D", /* tp_name */
+ sizeof(BPy_Curvature2DAngleF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Curvature2DAngleF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Curvature2DAngleF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp
index b96406de066..fcf2bebc161 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp
@@ -67,8 +67,8 @@ static char DensityF1D___doc__[] =
static int DensityF1D___init__(BPy_DensityF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"sigma", "integration_type", "sampling", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"sigma", "integration_type", "sampling", nullptr};
+ PyObject *obj = nullptr;
double d = 2.0;
float f = 2.0;
@@ -84,43 +84,47 @@ static int DensityF1D___init__(BPy_DensityF1D *self, PyObject *args, PyObject *k
/*-----------------------BPy_DensityF1D type definition ------------------------------*/
PyTypeObject DensityF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "DensityF1D", /* tp_name */
- sizeof(BPy_DensityF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- DensityF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)DensityF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "DensityF1D", /* tp_name */
+ sizeof(BPy_DensityF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ DensityF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)DensityF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp
index 9f16f53e833..5c352c670c1 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp
@@ -71,8 +71,8 @@ static int GetCompleteViewMapDensityF1D___init__(BPy_GetCompleteViewMapDensityF1
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"level", "integration_type", "sampling", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"level", "integration_type", "sampling", nullptr};
+ PyObject *obj = nullptr;
int i;
float f = 2.0;
@@ -88,43 +88,47 @@ static int GetCompleteViewMapDensityF1D___init__(BPy_GetCompleteViewMapDensityF1
/*-----------------------BPy_GetCompleteViewMapDensityF1D type definition -----------------------*/
PyTypeObject GetCompleteViewMapDensityF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetCompleteViewMapDensityF1D", /* tp_name */
- sizeof(BPy_GetCompleteViewMapDensityF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetCompleteViewMapDensityF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetCompleteViewMapDensityF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetCompleteViewMapDensityF1D", /* tp_name */
+ sizeof(BPy_GetCompleteViewMapDensityF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetCompleteViewMapDensityF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetCompleteViewMapDensityF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp
index 8cea26338df..45c6a1b0fb7 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp
@@ -77,8 +77,8 @@ static int GetDirectionalViewMapDensityF1D___init__(BPy_GetDirectionalViewMapDen
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"orientation", "level", "integration_type", "sampling", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"orientation", "level", "integration_type", "sampling", nullptr};
+ PyObject *obj = nullptr;
unsigned int u1, u2;
float f = 2.0;
@@ -95,43 +95,47 @@ static int GetDirectionalViewMapDensityF1D___init__(BPy_GetDirectionalViewMapDen
/*-----------------------BPy_GetDirectionalViewMapDensityF1D type definition --------------------*/
PyTypeObject GetDirectionalViewMapDensityF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetDirectionalViewMapDensityF1D", /* tp_name */
- sizeof(BPy_GetDirectionalViewMapDensityF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetDirectionalViewMapDensityF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetDirectionalViewMapDensityF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetDirectionalViewMapDensityF1D", /* tp_name */
+ sizeof(BPy_GetDirectionalViewMapDensityF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetDirectionalViewMapDensityF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetDirectionalViewMapDensityF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp
index 5f47fb03f8b..0c7276a13ec 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp
@@ -55,8 +55,8 @@ static char GetProjectedXF1D___doc__[] =
static int GetProjectedXF1D___init__(BPy_GetProjectedXF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -70,43 +70,47 @@ static int GetProjectedXF1D___init__(BPy_GetProjectedXF1D *self, PyObject *args,
/*-----------------------BPy_GetProjectedXF1D type definition ------------------------------*/
PyTypeObject GetProjectedXF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetProjectedXF1D", /* tp_name */
- sizeof(BPy_GetProjectedXF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetProjectedXF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetProjectedXF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetProjectedXF1D", /* tp_name */
+ sizeof(BPy_GetProjectedXF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetProjectedXF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetProjectedXF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp
index b6e1c2d336e..1f1c01a5344 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp
@@ -55,8 +55,8 @@ static char GetProjectedYF1D___doc__[] =
static int GetProjectedYF1D___init__(BPy_GetProjectedYF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -70,43 +70,47 @@ static int GetProjectedYF1D___init__(BPy_GetProjectedYF1D *self, PyObject *args,
/*-----------------------BPy_GetProjectedYF1D type definition ------------------------------*/
PyTypeObject GetProjectedYF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetProjectedYF1D", /* tp_name */
- sizeof(BPy_GetProjectedYF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetProjectedYF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetProjectedYF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetProjectedYF1D", /* tp_name */
+ sizeof(BPy_GetProjectedYF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetProjectedYF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetProjectedYF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp
index dfe7cd82710..cfa06f9d8fd 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp
@@ -55,8 +55,8 @@ static char GetProjectedZF1D___doc__[] =
static int GetProjectedZF1D___init__(BPy_GetProjectedZF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -70,43 +70,47 @@ static int GetProjectedZF1D___init__(BPy_GetProjectedZF1D *self, PyObject *args,
/*-----------------------BPy_GetProjectedZF1D type definition ------------------------------*/
PyTypeObject GetProjectedZF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetProjectedZF1D", /* tp_name */
- sizeof(BPy_GetProjectedZF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetProjectedZF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetProjectedZF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetProjectedZF1D", /* tp_name */
+ sizeof(BPy_GetProjectedZF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetProjectedZF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetProjectedZF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp
index a1ed9d15d5e..985e10f2b83 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp
@@ -68,8 +68,8 @@ static int GetSteerableViewMapDensityF1D___init__(BPy_GetSteerableViewMapDensity
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"level", "integration_type", "sampling", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"level", "integration_type", "sampling", nullptr};
+ PyObject *obj = nullptr;
int i;
float f = 2.0;
@@ -85,43 +85,47 @@ static int GetSteerableViewMapDensityF1D___init__(BPy_GetSteerableViewMapDensity
/*-----------------------BPy_GetSteerableViewMapDensityF1D type definition ----------------------*/
PyTypeObject GetSteerableViewMapDensityF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetSteerableViewMapDensityF1D", /* tp_name */
- sizeof(BPy_GetSteerableViewMapDensityF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetSteerableViewMapDensityF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetSteerableViewMapDensityF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetSteerableViewMapDensityF1D", /* tp_name */
+ sizeof(BPy_GetSteerableViewMapDensityF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetSteerableViewMapDensityF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetSteerableViewMapDensityF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp
index 268d140749d..441ea2f5833 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp
@@ -68,8 +68,8 @@ static int GetViewMapGradientNormF1D___init__(BPy_GetViewMapGradientNormF1D *sel
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"level", "integration_type", "sampling", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"level", "integration_type", "sampling", nullptr};
+ PyObject *obj = nullptr;
int i;
float f = 2.0;
@@ -85,43 +85,47 @@ static int GetViewMapGradientNormF1D___init__(BPy_GetViewMapGradientNormF1D *sel
/*-----------------------BPy_GetViewMapGradientNormF1D type definition --------------------------*/
PyTypeObject GetViewMapGradientNormF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetViewMapGradientNormF1D", /* tp_name */
- sizeof(BPy_GetViewMapGradientNormF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetViewMapGradientNormF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetViewMapGradientNormF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetViewMapGradientNormF1D", /* tp_name */
+ sizeof(BPy_GetViewMapGradientNormF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetViewMapGradientNormF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetViewMapGradientNormF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp
index 5a0b7d6aa55..716cfbfe37a 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp
@@ -55,8 +55,8 @@ static char GetXF1D___doc__[] =
static int GetXF1D___init__(BPy_GetXF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -70,43 +70,47 @@ static int GetXF1D___init__(BPy_GetXF1D *self, PyObject *args, PyObject *kwds)
/*-----------------------BPy_GetXF1D type definition ------------------------------*/
PyTypeObject GetXF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetXF1D", /* tp_name */
- sizeof(BPy_GetXF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetXF1D", /* tp_name */
+ sizeof(BPy_GetXF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
GetXF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
&UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)GetXF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp
index 9b523126841..693c2453db2 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp
@@ -55,8 +55,8 @@ static char GetYF1D___doc__[] =
static int GetYF1D___init__(BPy_GetYF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -69,43 +69,47 @@ static int GetYF1D___init__(BPy_GetYF1D *self, PyObject *args, PyObject *kwds)
/*-----------------------BPy_GetYF1D type definition ------------------------------*/
PyTypeObject GetYF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetYF1D", /* tp_name */
- sizeof(BPy_GetYF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetYF1D", /* tp_name */
+ sizeof(BPy_GetYF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
GetYF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
&UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)GetYF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp
index 73407affd8d..e9030625b10 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp
@@ -55,8 +55,8 @@ static char GetZF1D___doc__[] =
static int GetZF1D___init__(BPy_GetZF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -70,43 +70,47 @@ static int GetZF1D___init__(BPy_GetZF1D *self, PyObject *args, PyObject *kwds)
/*-----------------------BPy_GetZF1D type definition ------------------------------*/
PyTypeObject GetZF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetZF1D", /* tp_name */
- sizeof(BPy_GetZF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetZF1D", /* tp_name */
+ sizeof(BPy_GetZF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
GetZF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
&UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)GetZF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp
index aef67aab928..4ae2cd054e2 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp
@@ -64,8 +64,8 @@ static int LocalAverageDepthF1D___init__(BPy_LocalAverageDepthF1D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"sigma", "integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"sigma", "integration_type", nullptr};
+ PyObject *obj = nullptr;
double d;
if (!PyArg_ParseTupleAndKeywords(
@@ -80,43 +80,47 @@ static int LocalAverageDepthF1D___init__(BPy_LocalAverageDepthF1D *self,
/*-----------------------BPy_LocalAverageDepthF1D type definition ------------------------------*/
PyTypeObject LocalAverageDepthF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "LocalAverageDepthF1D", /* tp_name */
- sizeof(BPy_LocalAverageDepthF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- LocalAverageDepthF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)LocalAverageDepthF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "LocalAverageDepthF1D", /* tp_name */
+ sizeof(BPy_LocalAverageDepthF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ LocalAverageDepthF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)LocalAverageDepthF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp
index cf2162c30ad..9feb07552ca 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp
@@ -59,8 +59,8 @@ static char ZDiscontinuityF1D___doc__[] =
static int ZDiscontinuityF1D___init__(BPy_ZDiscontinuityF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -74,43 +74,47 @@ static int ZDiscontinuityF1D___init__(BPy_ZDiscontinuityF1D *self, PyObject *arg
/*-----------------------BPy_ZDiscontinuityF1D type definition ------------------------------*/
PyTypeObject ZDiscontinuityF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ZDiscontinuityF1D", /* tp_name */
- sizeof(BPy_ZDiscontinuityF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ZDiscontinuityF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DDouble_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ZDiscontinuityF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ZDiscontinuityF1D", /* tp_name */
+ sizeof(BPy_ZDiscontinuityF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ZDiscontinuityF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DDouble_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ZDiscontinuityF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp
index f843ff52d06..400b5a95fcf 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp
@@ -61,8 +61,8 @@ static int QuantitativeInvisibilityF1D___init__(BPy_QuantitativeInvisibilityF1D
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"integration_type", NULL};
- PyObject *obj = 0;
+ static const char *kwlist[] = {"integration_type", nullptr};
+ PyObject *obj = nullptr;
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) {
@@ -76,43 +76,47 @@ static int QuantitativeInvisibilityF1D___init__(BPy_QuantitativeInvisibilityF1D
/*-----------------------BPy_QuantitativeInvisibilityF1D type definition ------------------------*/
PyTypeObject QuantitativeInvisibilityF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "QuantitativeInvisibilityF1D", /* tp_name */
- sizeof(BPy_QuantitativeInvisibilityF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- QuantitativeInvisibilityF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DUnsigned_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)QuantitativeInvisibilityF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "QuantitativeInvisibilityF1D", /* tp_name */
+ sizeof(BPy_QuantitativeInvisibilityF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ QuantitativeInvisibilityF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DUnsigned_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)QuantitativeInvisibilityF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp
index f56d89c469a..7637153017f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp
@@ -51,7 +51,7 @@ static char GetOccludeeF1D___doc__[] =
static int GetOccludeeF1D___init__(BPy_GetOccludeeF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int GetOccludeeF1D___init__(BPy_GetOccludeeF1D *self, PyObject *args, PyO
/*-----------------------BPy_GetOccludeeF1D type definition ------------------------------*/
PyTypeObject GetOccludeeF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetOccludeeF1D", /* tp_name */
- sizeof(BPy_GetOccludeeF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetOccludeeF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DVectorViewShape_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetOccludeeF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetOccludeeF1D", /* tp_name */
+ sizeof(BPy_GetOccludeeF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetOccludeeF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DVectorViewShape_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetOccludeeF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp
index 3ff4d36bc19..d532268b294 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp
@@ -51,7 +51,7 @@ static char GetOccludersF1D___doc__[] =
static int GetOccludersF1D___init__(BPy_GetOccludersF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int GetOccludersF1D___init__(BPy_GetOccludersF1D *self, PyObject *args, P
/*-----------------------BPy_GetOccludersF1D type definition ------------------------------*/
PyTypeObject GetOccludersF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetOccludersF1D", /* tp_name */
- sizeof(BPy_GetOccludersF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetOccludersF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DVectorViewShape_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetOccludersF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetOccludersF1D", /* tp_name */
+ sizeof(BPy_GetOccludersF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetOccludersF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DVectorViewShape_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetOccludersF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp
index 08122b76385..dd1492e940e 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp
@@ -51,7 +51,7 @@ static char GetShapeF1D___doc__[] =
static int GetShapeF1D___init__(BPy_GetShapeF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int GetShapeF1D___init__(BPy_GetShapeF1D *self, PyObject *args, PyObject
/*-----------------------BPy_GetShapeF1D type definition ------------------------------*/
PyTypeObject GetShapeF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "GetShapeF1D", /* tp_name */
- sizeof(BPy_GetShapeF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- GetShapeF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DVectorViewShape_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)GetShapeF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "GetShapeF1D", /* tp_name */
+ sizeof(BPy_GetShapeF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ GetShapeF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DVectorViewShape_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)GetShapeF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp
index 4be8f239fd6..c3750734efc 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp
@@ -51,7 +51,7 @@ static int ChainingTimeStampF1D___init__(BPy_ChainingTimeStampF1D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int ChainingTimeStampF1D___init__(BPy_ChainingTimeStampF1D *self,
/*-----------------------BPy_ChainingTimeStampF1D type definition ------------------------------*/
PyTypeObject ChainingTimeStampF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ChainingTimeStampF1D", /* tp_name */
- sizeof(BPy_ChainingTimeStampF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ChainingTimeStampF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DVoid_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ChainingTimeStampF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ChainingTimeStampF1D", /* tp_name */
+ sizeof(BPy_ChainingTimeStampF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ChainingTimeStampF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DVoid_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ChainingTimeStampF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp
index bca4ebb4236..85738684e44 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp
@@ -51,7 +51,7 @@ static int IncrementChainingTimeStampF1D___init__(BPy_IncrementChainingTimeStamp
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -63,43 +63,47 @@ static int IncrementChainingTimeStampF1D___init__(BPy_IncrementChainingTimeStamp
/*-----------------------BPy_IncrementChainingTimeStampF1D type definition ----------------------*/
PyTypeObject IncrementChainingTimeStampF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "IncrementChainingTimeStampF1D", /* tp_name */
- sizeof(BPy_IncrementChainingTimeStampF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- IncrementChainingTimeStampF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DVoid_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)IncrementChainingTimeStampF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "IncrementChainingTimeStampF1D", /* tp_name */
+ sizeof(BPy_IncrementChainingTimeStampF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ IncrementChainingTimeStampF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DVoid_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)IncrementChainingTimeStampF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp
index e2d0c7d1308..1f577820da4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp
@@ -49,7 +49,7 @@ static char TimeStampF1D___doc__[] =
static int TimeStampF1D___init__(BPy_TimeStampF1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -61,43 +61,47 @@ static int TimeStampF1D___init__(BPy_TimeStampF1D *self, PyObject *args, PyObjec
/*-----------------------BPy_TimeStampF1D type definition ------------------------------*/
PyTypeObject TimeStampF1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "TimeStampF1D", /* tp_name */
- sizeof(BPy_TimeStampF1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- TimeStampF1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryFunction1DVoid_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)TimeStampF1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "TimeStampF1D", /* tp_name */
+ sizeof(BPy_TimeStampF1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ TimeStampF1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryFunction1DVoid_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)TimeStampF1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp
index 1e8aab3b086..227aca2b5c6 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp
@@ -42,7 +42,7 @@ static char FalseUP0D___doc__[] =
static int FalseUP0D___init__(BPy_FalseUP0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -54,43 +54,47 @@ static int FalseUP0D___init__(BPy_FalseUP0D *self, PyObject *args, PyObject *kwd
/*-----------------------BPy_FalseUP0D type definition ------------------------------*/
PyTypeObject FalseUP0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "FalseUP0D", /* tp_name */
- sizeof(BPy_FalseUP0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- FalseUP0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)FalseUP0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "FalseUP0D", /* tp_name */
+ sizeof(BPy_FalseUP0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ FalseUP0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)FalseUP0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp
index ca6c7a5b344..5f5c756b28d 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp
@@ -42,7 +42,7 @@ static char TrueUP0D___doc__[] =
static int TrueUP0D___init__(BPy_TrueUP0D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -54,43 +54,47 @@ static int TrueUP0D___init__(BPy_TrueUP0D *self, PyObject *args, PyObject *kwds)
/*-----------------------BPy_TrueUP0D type definition ------------------------------*/
PyTypeObject TrueUP0D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "TrueUP0D", /* tp_name */
- sizeof(BPy_TrueUP0D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- TrueUP0D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate0D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)TrueUP0D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "TrueUP0D", /* tp_name */
+ sizeof(BPy_TrueUP0D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ TrueUP0D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate0D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)TrueUP0D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp
index 734aa5a0e84..b3f9c225931 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp
@@ -43,7 +43,7 @@ static char ContourUP1D___doc__[] =
static int ContourUP1D___init__(BPy_ContourUP1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -55,43 +55,47 @@ static int ContourUP1D___init__(BPy_ContourUP1D *self, PyObject *args, PyObject
/*-----------------------BPy_ContourUP1D type definition ------------------------------*/
PyTypeObject ContourUP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ContourUP1D", /* tp_name */
- sizeof(BPy_ContourUP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ContourUP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ContourUP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ContourUP1D", /* tp_name */
+ sizeof(BPy_ContourUP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ContourUP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ContourUP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp
index 2044d663e77..f865fe5013d 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp
@@ -58,7 +58,7 @@ static int DensityLowerThanUP1D___init__(BPy_DensityLowerThanUP1D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"threshold", "sigma", NULL};
+ static const char *kwlist[] = {"threshold", "sigma", nullptr};
double d1, d2 = 2.0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "d|d", (char **)kwlist, &d1, &d2)) {
@@ -71,43 +71,47 @@ static int DensityLowerThanUP1D___init__(BPy_DensityLowerThanUP1D *self,
/*-----------------------BPy_DensityLowerThanUP1D type definition ------------------------------*/
PyTypeObject DensityLowerThanUP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "DensityLowerThanUP1D", /* tp_name */
- sizeof(BPy_DensityLowerThanUP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- DensityLowerThanUP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)DensityLowerThanUP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "DensityLowerThanUP1D", /* tp_name */
+ sizeof(BPy_DensityLowerThanUP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ DensityLowerThanUP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)DensityLowerThanUP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
index c5feec45844..154b44ff81a 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
@@ -53,7 +53,7 @@ static int EqualToChainingTimeStampUP1D___init__(BPy_EqualToChainingTimeStampUP1
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"ts", NULL};
+ static const char *kwlist[] = {"ts", nullptr};
unsigned u;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &u)) {
@@ -66,43 +66,47 @@ static int EqualToChainingTimeStampUP1D___init__(BPy_EqualToChainingTimeStampUP1
/*-----------------------BPy_EqualToChainingTimeStampUP1D type definition -----------------------*/
PyTypeObject EqualToChainingTimeStampUP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "EqualToChainingTimeStampUP1D", /* tp_name */
- sizeof(BPy_EqualToChainingTimeStampUP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- EqualToChainingTimeStampUP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)EqualToChainingTimeStampUP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "EqualToChainingTimeStampUP1D", /* tp_name */
+ sizeof(BPy_EqualToChainingTimeStampUP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ EqualToChainingTimeStampUP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)EqualToChainingTimeStampUP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp
index fd68878dc45..2bb9dbaf484 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp
@@ -52,7 +52,7 @@ static int EqualToTimeStampUP1D___init__(BPy_EqualToTimeStampUP1D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"ts", NULL};
+ static const char *kwlist[] = {"ts", nullptr};
unsigned u;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &u)) {
@@ -65,43 +65,47 @@ static int EqualToTimeStampUP1D___init__(BPy_EqualToTimeStampUP1D *self,
/*-----------------------BPy_EqualToTimeStampUP1D type definition ------------------------------*/
PyTypeObject EqualToTimeStampUP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "EqualToTimeStampUP1D", /* tp_name */
- sizeof(BPy_EqualToTimeStampUP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- EqualToTimeStampUP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)EqualToTimeStampUP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "EqualToTimeStampUP1D", /* tp_name */
+ sizeof(BPy_EqualToTimeStampUP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ EqualToTimeStampUP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)EqualToTimeStampUP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp
index 3ddadcf2d4f..7b9923d7b6c 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp
@@ -47,7 +47,7 @@ static int ExternalContourUP1D___init__(BPy_ExternalContourUP1D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -59,43 +59,47 @@ static int ExternalContourUP1D___init__(BPy_ExternalContourUP1D *self,
/*-----------------------BPy_ExternalContourUP1D type definition ------------------------------*/
PyTypeObject ExternalContourUP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ExternalContourUP1D", /* tp_name */
- sizeof(BPy_ExternalContourUP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ExternalContourUP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ExternalContourUP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ExternalContourUP1D", /* tp_name */
+ sizeof(BPy_ExternalContourUP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ExternalContourUP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ExternalContourUP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp
index a93ce638f33..ec1a02e13aa 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp
@@ -42,7 +42,7 @@ static char FalseUP1D___doc__[] =
static int FalseUP1D___init__(BPy_FalseUP1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -54,43 +54,47 @@ static int FalseUP1D___init__(BPy_FalseUP1D *self, PyObject *args, PyObject *kwd
/*-----------------------BPy_FalseUP1D type definition ------------------------------*/
PyTypeObject FalseUP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "FalseUP1D", /* tp_name */
- sizeof(BPy_FalseUP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- FalseUP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)FalseUP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "FalseUP1D", /* tp_name */
+ sizeof(BPy_FalseUP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ FalseUP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)FalseUP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
index 153fbf56ba8..b9a76f91c21 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
@@ -57,7 +57,7 @@ static int QuantitativeInvisibilityUP1D___init__(BPy_QuantitativeInvisibilityUP1
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"qi", NULL};
+ static const char *kwlist[] = {"qi", nullptr};
int i = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", (char **)kwlist, &i)) {
@@ -70,43 +70,47 @@ static int QuantitativeInvisibilityUP1D___init__(BPy_QuantitativeInvisibilityUP1
/*-----------------------BPy_QuantitativeInvisibilityUP1D type definition -----------------------*/
PyTypeObject QuantitativeInvisibilityUP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "QuantitativeInvisibilityUP1D", /* tp_name */
- sizeof(BPy_QuantitativeInvisibilityUP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- QuantitativeInvisibilityUP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)QuantitativeInvisibilityUP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "QuantitativeInvisibilityUP1D", /* tp_name */
+ sizeof(BPy_QuantitativeInvisibilityUP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ QuantitativeInvisibilityUP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)QuantitativeInvisibilityUP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp
index 8a57b3173e5..68f0ea7a913 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp
@@ -53,7 +53,7 @@ static char ShapeUP1D___doc__[] =
static int ShapeUP1D___init__(BPy_ShapeUP1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"first", "second", NULL};
+ static const char *kwlist[] = {"first", "second", nullptr};
unsigned u1, u2 = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I|I", (char **)kwlist, &u1, &u2)) {
@@ -66,43 +66,47 @@ static int ShapeUP1D___init__(BPy_ShapeUP1D *self, PyObject *args, PyObject *kwd
/*-----------------------BPy_ShapeUP1D type definition ------------------------------*/
PyTypeObject ShapeUP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "ShapeUP1D", /* tp_name */
- sizeof(BPy_ShapeUP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- ShapeUP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ShapeUP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "ShapeUP1D", /* tp_name */
+ sizeof(BPy_ShapeUP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ShapeUP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ShapeUP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp
index 9c1bf4ecd18..362bcc4cea8 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp
@@ -42,7 +42,7 @@ static char TrueUP1D___doc__[] =
static int TrueUP1D___init__(BPy_TrueUP1D *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {NULL};
+ static const char *kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
return -1;
@@ -54,43 +54,47 @@ static int TrueUP1D___init__(BPy_TrueUP1D *self, PyObject *args, PyObject *kwds)
/*-----------------------BPy_TrueUP1D type definition ------------------------------*/
PyTypeObject TrueUP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "TrueUP1D", /* tp_name */
- sizeof(BPy_TrueUP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- TrueUP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)TrueUP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "TrueUP1D", /* tp_name */
+ sizeof(BPy_TrueUP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ TrueUP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)TrueUP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp
index 4fb486f1366..9329e3a7628 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp
@@ -53,7 +53,7 @@ static int WithinImageBoundaryUP1D___init__(BPy_WithinImageBoundaryUP1D *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"xmin", "ymin", "xmax", "ymax", NULL};
+ static const char *kwlist[] = {"xmin", "ymin", "xmax", "ymax", nullptr};
double xmin, ymin, xmax, ymax;
if (!PyArg_ParseTupleAndKeywords(
@@ -67,43 +67,47 @@ static int WithinImageBoundaryUP1D___init__(BPy_WithinImageBoundaryUP1D *self,
/*-----------------------BPy_TrueUP1D type definition ------------------------------*/
PyTypeObject WithinImageBoundaryUP1D_Type = {
- PyVarObject_HEAD_INIT(NULL, 0) "WithinImageBoundaryUP1D", /* tp_name */
- sizeof(BPy_WithinImageBoundaryUP1D), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- WithinImageBoundaryUP1D___doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &UnaryPredicate1D_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)WithinImageBoundaryUP1D___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+ PyVarObject_HEAD_INIT(nullptr, 0) "WithinImageBoundaryUP1D", /* tp_name */
+ sizeof(BPy_WithinImageBoundaryUP1D), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ nullptr, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ nullptr, /* tp_print */
+#endif
+ nullptr, /* tp_getattr */
+ nullptr, /* tp_setattr */
+ nullptr, /* tp_reserved */
+ nullptr, /* tp_repr */
+ nullptr, /* tp_as_number */
+ nullptr, /* tp_as_sequence */
+ nullptr, /* tp_as_mapping */
+ nullptr, /* tp_hash */
+ nullptr, /* tp_call */
+ nullptr, /* tp_str */
+ nullptr, /* tp_getattro */
+ nullptr, /* tp_setattro */
+ nullptr, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ WithinImageBoundaryUP1D___doc__, /* tp_doc */
+ nullptr, /* tp_traverse */
+ nullptr, /* tp_clear */
+ nullptr, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ nullptr, /* tp_iter */
+ nullptr, /* tp_iternext */
+ nullptr, /* tp_methods */
+ nullptr, /* tp_members */
+ nullptr, /* tp_getset */
+ &UnaryPredicate1D_Type, /* tp_base */
+ nullptr, /* tp_dict */
+ nullptr, /* tp_descr_get */
+ nullptr, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)WithinImageBoundaryUP1D___init__, /* tp_init */
+ nullptr, /* tp_alloc */
+ nullptr, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
index fe0fc715e34..cc29bc77595 100644
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
@@ -23,27 +23,27 @@
namespace Freestyle {
-IndexedFaceSet::IndexedFaceSet() : Rep()
+IndexedFaceSet::IndexedFaceSet()
{
- _Vertices = NULL;
- _Normals = NULL;
- _FrsMaterials = 0;
- _TexCoords = NULL;
- _FaceEdgeMarks = 0;
+ _Vertices = nullptr;
+ _Normals = nullptr;
+ _FrsMaterials = nullptr;
+ _TexCoords = nullptr;
+ _FaceEdgeMarks = nullptr;
_VSize = 0;
_NSize = 0;
_MSize = 0;
_TSize = 0;
_NumFaces = 0;
- _NumVertexPerFace = NULL;
- _FaceStyle = NULL;
- _VIndices = NULL;
+ _NumVertexPerFace = nullptr;
+ _FaceStyle = nullptr;
+ _VIndices = nullptr;
_VISize = 0;
- _NIndices = NULL;
+ _NIndices = nullptr;
_NISize = 0;
- _MIndices = NULL;
+ _MIndices = nullptr;
_MISize = 0;
- _TIndices = NULL;
+ _TIndices = nullptr;
_TISize = 0;
}
@@ -68,7 +68,6 @@ IndexedFaceSet::IndexedFaceSet(float *iVertices,
unsigned *iTIndices,
unsigned iTISize,
unsigned iCopy)
- : Rep()
{
if (1 == iCopy) {
_VSize = iVSize;
@@ -80,7 +79,7 @@ IndexedFaceSet::IndexedFaceSet(float *iVertices,
memcpy(_Normals, iNormals, iNSize * sizeof(float));
_MSize = iMSize;
- _FrsMaterials = 0;
+ _FrsMaterials = nullptr;
if (iMaterials) {
_FrsMaterials = new FrsMaterial *[_MSize];
for (unsigned int i = 0; i < _MSize; ++i) {
@@ -88,7 +87,7 @@ IndexedFaceSet::IndexedFaceSet(float *iVertices,
}
}
_TSize = iTSize;
- _TexCoords = 0;
+ _TexCoords = nullptr;
if (_TSize) {
_TexCoords = new float[_TSize];
memcpy(_TexCoords, iTexCoords, iTSize * sizeof(float));
@@ -113,13 +112,13 @@ IndexedFaceSet::IndexedFaceSet(float *iVertices,
memcpy(_NIndices, iNIndices, _NISize * sizeof(unsigned));
_MISize = iMISize;
- _MIndices = 0;
+ _MIndices = nullptr;
if (iMIndices) {
_MIndices = new unsigned[_MISize];
memcpy(_MIndices, iMIndices, _MISize * sizeof(unsigned));
}
_TISize = iTISize;
- _TIndices = 0;
+ _TIndices = nullptr;
if (_TISize) {
_TIndices = new unsigned[_TISize];
memcpy(_TIndices, iTIndices, _TISize * sizeof(unsigned));
@@ -133,7 +132,7 @@ IndexedFaceSet::IndexedFaceSet(float *iVertices,
_Normals = iNormals;
_MSize = iMSize;
- _FrsMaterials = 0;
+ _FrsMaterials = nullptr;
if (iMaterials) {
_FrsMaterials = iMaterials;
}
@@ -153,7 +152,7 @@ IndexedFaceSet::IndexedFaceSet(float *iVertices,
_NIndices = iNIndices;
_MISize = iMISize;
- _MIndices = 0;
+ _MIndices = nullptr;
if (iMISize) {
_MIndices = iMIndices;
}
@@ -181,11 +180,11 @@ IndexedFaceSet::IndexedFaceSet(const IndexedFaceSet &iBrother) : Rep(iBrother)
}
}
else {
- _FrsMaterials = 0;
+ _FrsMaterials = nullptr;
}
_TSize = iBrother.tsize();
- _TexCoords = 0;
+ _TexCoords = nullptr;
if (_TSize) {
_TexCoords = new float[_TSize];
memcpy(_TexCoords, iBrother.texCoords(), _TSize * sizeof(float));
@@ -215,11 +214,11 @@ IndexedFaceSet::IndexedFaceSet(const IndexedFaceSet &iBrother) : Rep(iBrother)
memcpy(_MIndices, iBrother.mindices(), _MISize * sizeof(unsigned));
}
else {
- _MIndices = 0;
+ _MIndices = nullptr;
}
_TISize = iBrother.tisize();
- _TIndices = 0;
+ _TIndices = nullptr;
if (_TISize) {
_TIndices = new unsigned[_TISize];
memcpy(_TIndices, iBrother.tindices(), _TISize * sizeof(unsigned));
@@ -228,61 +227,61 @@ IndexedFaceSet::IndexedFaceSet(const IndexedFaceSet &iBrother) : Rep(iBrother)
IndexedFaceSet::~IndexedFaceSet()
{
- if (NULL != _Vertices) {
+ if (nullptr != _Vertices) {
delete[] _Vertices;
- _Vertices = NULL;
+ _Vertices = nullptr;
}
- if (NULL != _Normals) {
+ if (nullptr != _Normals) {
delete[] _Normals;
- _Normals = NULL;
+ _Normals = nullptr;
}
- if (NULL != _FrsMaterials) {
+ if (nullptr != _FrsMaterials) {
for (unsigned int i = 0; i < _MSize; ++i) {
delete _FrsMaterials[i];
}
delete[] _FrsMaterials;
- _FrsMaterials = NULL;
+ _FrsMaterials = nullptr;
}
- if (NULL != _TexCoords) {
+ if (nullptr != _TexCoords) {
delete[] _TexCoords;
- _TexCoords = NULL;
+ _TexCoords = nullptr;
}
- if (NULL != _NumVertexPerFace) {
+ if (nullptr != _NumVertexPerFace) {
delete[] _NumVertexPerFace;
- _NumVertexPerFace = NULL;
+ _NumVertexPerFace = nullptr;
}
- if (NULL != _FaceStyle) {
+ if (nullptr != _FaceStyle) {
delete[] _FaceStyle;
- _FaceStyle = NULL;
+ _FaceStyle = nullptr;
}
- if (NULL != _FaceEdgeMarks) {
+ if (nullptr != _FaceEdgeMarks) {
delete[] _FaceEdgeMarks;
- _FaceEdgeMarks = NULL;
+ _FaceEdgeMarks = nullptr;
}
- if (NULL != _VIndices) {
+ if (nullptr != _VIndices) {
delete[] _VIndices;
- _VIndices = NULL;
+ _VIndices = nullptr;
}
- if (NULL != _NIndices) {
+ if (nullptr != _NIndices) {
delete[] _NIndices;
- _NIndices = NULL;
+ _NIndices = nullptr;
}
- if (NULL != _MIndices) {
+ if (nullptr != _MIndices) {
delete[] _MIndices;
- _MIndices = NULL;
+ _MIndices = nullptr;
}
- if (NULL != _TIndices) {
+ if (nullptr != _TIndices) {
delete[] _TIndices;
- _TIndices = NULL;
+ _TIndices = nullptr;
}
}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp b/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
index 4bbb4a6c58a..69c33ea02a1 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
@@ -27,7 +27,7 @@ namespace Freestyle {
void NodeGroup::AddChild(Node *iChild)
{
- if (NULL == iChild) {
+ if (nullptr == iChild) {
return;
}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeLight.cpp b/source/blender/freestyle/intern/scene_graph/NodeLight.cpp
index f6585d9f932..7200ae5e83c 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeLight.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeLight.cpp
@@ -25,7 +25,7 @@ namespace Freestyle {
int NodeLight::numberOfLights = 0;
-NodeLight::NodeLight() : Node()
+NodeLight::NodeLight()
{
if (numberOfLights > 7) {
_number = 7;
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp
index 95d4735ddc4..4e0253c88e9 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp
@@ -25,9 +25,7 @@
#include "../view_map/Functions0D.h"
#include "../view_map/SteerableViewMap.h"
-namespace Freestyle {
-
-namespace Functions0D {
+namespace Freestyle::Functions0D {
int DensityF0D::operator()(Interface0DIterator &iter)
{
@@ -114,6 +112,4 @@ int GetViewMapGradientNormF0D::operator()(Interface0DIterator &iter)
return 0;
}
-} // end of namespace Functions0D
-
-} /* namespace Freestyle */
+} // namespace Freestyle::Functions0D
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
index ef151365fa0..7a516470e6b 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
@@ -24,10 +24,7 @@
#include "../view_map/SteerableViewMap.h"
-namespace Freestyle {
-
-// FIXME
-namespace Functions1D {
+namespace Freestyle::Functions1D {
int GetSteerableViewMapDensityF1D::operator()(Interface1D &inter)
{
@@ -43,7 +40,7 @@ int GetSteerableViewMapDensityF1D::operator()(Interface1D &inter)
Interface0D &i0D = (*it);
Interface0D &i0Dnext = (*itnext);
fe = i0D.getFEdge(i0Dnext);
- if (fe == 0) {
+ if (fe == nullptr) {
cerr << "GetSteerableViewMapDensityF1D warning: no FEdge between " << i0D.getId() << " and "
<< i0Dnext.getId() << endl;
// compute the direction between these two ???
@@ -127,6 +124,4 @@ int GetViewMapGradientNormF1D::operator()(Interface1D &inter)
return 0;
}
-} // namespace Functions1D
-
-} /* namespace Freestyle */
+} // namespace Freestyle::Functions1D
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
index abe3871c395..7e2dcb8f99f 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
@@ -37,7 +37,6 @@ CalligraphicShader::CalligraphicShader(real iMinThickness,
real iMaxThickness,
const Vec2f &iOrientation,
bool clamp)
- : StrokeShader()
{
_minThickness = iMinThickness;
_maxThickness = iMaxThickness;
@@ -90,7 +89,6 @@ static const unsigned NB_VALUE_NOISE = 512;
SpatialNoiseShader::SpatialNoiseShader(
float iAmount, float ixScale, int nbOctave, bool smooth, bool pureRandom)
- : StrokeShader()
{
_amount = iAmount;
if (ixScale == 0) {
@@ -169,7 +167,6 @@ SmoothingShader::SmoothingShader(int iNbIteration,
real iAnisoNormal,
real iAnisoCurvature,
real iCarricatureFactor)
- : StrokeShader()
{
_nbIterations = iNbIteration;
_factorCurvature = ifactorCurvature;
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
index 36234ad619c..335bfdffe90 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
@@ -40,9 +40,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-namespace Freestyle {
-
-namespace StrokeShaders {
+namespace Freestyle::StrokeShaders {
//
// Thickness modifiers
@@ -170,13 +168,13 @@ int LengthDependingThicknessShader::shade(Stroke &stroke) const
static const unsigned NB_VALUE_NOISE = 512;
-ThicknessNoiseShader::ThicknessNoiseShader() : StrokeShader()
+ThicknessNoiseShader::ThicknessNoiseShader()
{
_amplitude = 1.0f;
_scale = 1.0f / 2.0f / (float)NB_VALUE_NOISE;
}
-ThicknessNoiseShader::ThicknessNoiseShader(float iAmplitude, float iPeriod) : StrokeShader()
+ThicknessNoiseShader::ThicknessNoiseShader(float iAmplitude, float iPeriod)
{
_amplitude = iAmplitude;
_scale = 1.0f / iPeriod / (float)NB_VALUE_NOISE;
@@ -256,13 +254,13 @@ int MaterialColorShader::shade(Stroke &stroke) const
return 0;
}
-ColorNoiseShader::ColorNoiseShader() : StrokeShader()
+ColorNoiseShader::ColorNoiseShader()
{
_amplitude = 1.0f;
_scale = 1.0f / 2.0f / (float)NB_VALUE_NOISE;
}
-ColorNoiseShader::ColorNoiseShader(float iAmplitude, float iPeriod) : StrokeShader()
+ColorNoiseShader::ColorNoiseShader(float iAmplitude, float iPeriod)
{
_amplitude = iAmplitude;
_scale = 1.0f / iPeriod / (float)NB_VALUE_NOISE;
@@ -384,13 +382,13 @@ int BezierCurveShader::shade(Stroke &stroke) const
// Build the Bezier curve from this set of data points:
vector<Vec2d> data;
StrokeInternal::StrokeVertexIterator v = stroke.strokeVerticesBegin(), vend;
- data.push_back(Vec2d(v->x(), v->y())); // first one
+ data.emplace_back(v->x(), v->y()); // first one
StrokeInternal::StrokeVertexIterator previous = v;
++v;
for (vend = stroke.strokeVerticesEnd(); v != vend; ++v) {
if (!((fabs(v->x() - (previous)->x()) < M_EPSILON) &&
((fabs(v->y() - (previous)->y()) < M_EPSILON)))) {
- data.push_back(Vec2d(v->x(), v->y()));
+ data.emplace_back(v->x(), v->y());
}
previous = v;
}
@@ -646,7 +644,7 @@ int GuidingLinesShader::shade(Stroke &stroke) const
//
/////////////////////////////////////////
-TipRemoverShader::TipRemoverShader(real tipLength) : StrokeShader()
+TipRemoverShader::TipRemoverShader(real tipLength)
{
_tipLength = tipLength;
}
@@ -697,6 +695,4 @@ int TipRemoverShader::shade(Stroke &stroke) const
return 0;
}
-} // end of namespace StrokeShaders
-
-} /* namespace Freestyle */
+} // namespace Freestyle::StrokeShaders
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
index 8663cfd42bf..0ac0aa09cf9 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
@@ -56,7 +56,7 @@ class ConstantThicknessShader : public StrokeShader {
* \param thickness:
* The thickness that must be assigned to the stroke.
*/
- ConstantThicknessShader(float thickness) : StrokeShader()
+ ConstantThicknessShader(float thickness)
{
_thickness = thickness;
}
@@ -86,7 +86,7 @@ class ConstantThicknessShader : public StrokeShader {
*/
class ConstantExternThicknessShader : public StrokeShader {
public:
- ConstantExternThicknessShader(float thickness) : StrokeShader()
+ ConstantExternThicknessShader(float thickness)
{
_thickness = thickness;
}
@@ -120,7 +120,7 @@ class IncreasingThicknessShader : public StrokeShader {
* \param iThicknessMax:
* The second thickness value.
*/
- IncreasingThicknessShader(float iThicknessMin, float iThicknessMax) : StrokeShader()
+ IncreasingThicknessShader(float iThicknessMin, float iThicknessMax)
{
_ThicknessMin = iThicknessMin;
_ThicknessMax = iThicknessMax;
@@ -164,7 +164,7 @@ class ConstrainedIncreasingThicknessShader : public StrokeShader {
* The ration thickness/length we don't want to exceed.
*/
ConstrainedIncreasingThicknessShader(float iThicknessMin, float iThicknessMax, float iRatio)
- : StrokeShader()
+
{
_ThicknessMin = iThicknessMin;
_ThicknessMax = iThicknessMax;
@@ -199,7 +199,7 @@ class LengthDependingThicknessShader : public StrokeShader {
// l < 50
public:
- LengthDependingThicknessShader(float iMinThickness, float iMaxThickness) : StrokeShader()
+ LengthDependingThicknessShader(float iMinThickness, float iMaxThickness)
{
_minThickness = iMinThickness;
_maxThickness = iMaxThickness;
@@ -265,7 +265,7 @@ class ConstantColorShader : public StrokeShader {
* \param iAlpha:
* The alpha value
*/
- ConstantColorShader(float iR, float iG, float iB, float iAlpha = 1.0f) : StrokeShader()
+ ConstantColorShader(float iR, float iG, float iB, float iAlpha = 1.0f)
{
_color[0] = iR;
_color[1] = iG;
@@ -322,7 +322,7 @@ class IncreasingColorShader : public StrokeShader {
float iGM,
float iBM,
float iAlphaM)
- : StrokeShader()
+
{
_colorMin[0] = iRm;
_colorMin[1] = iGm;
@@ -353,7 +353,7 @@ class MaterialColorShader : public StrokeShader {
float _coefficient;
public:
- MaterialColorShader(float coeff = 1.0f) : StrokeShader()
+ MaterialColorShader(float coeff = 1.0f)
{
_coefficient = coeff;
}
@@ -411,7 +411,7 @@ class BackboneStretcherShader : public StrokeShader {
* \param iAmount:
* The stretching amount value.
*/
- BackboneStretcherShader(float iAmount = 2.0f) : StrokeShader()
+ BackboneStretcherShader(float iAmount = 2.0f)
{
_amount = iAmount;
}
@@ -438,7 +438,7 @@ class SamplingShader : public StrokeShader {
* \param sampling:
* The sampling to use for the stroke resampling
*/
- SamplingShader(float sampling) : StrokeShader()
+ SamplingShader(float sampling)
{
_sampling = sampling;
}
@@ -457,7 +457,7 @@ class ExternalContourStretcherShader : public StrokeShader {
float _amount;
public:
- ExternalContourStretcherShader(float iAmount = 2.0f) : StrokeShader()
+ ExternalContourStretcherShader(float iAmount = 2.0f)
{
_amount = iAmount;
}
@@ -486,7 +486,7 @@ class BezierCurveShader : public StrokeShader {
* The error we're allowing for the approximation.
* This error is the max distance allowed between the new curve and the original geometry.
*/
- BezierCurveShader(float error = 4.0) : StrokeShader()
+ BezierCurveShader(float error = 4.0)
{
_error = error;
}
@@ -517,7 +517,7 @@ class PolygonalizationShader : public StrokeShader {
* geometry. The smaller, the closer the new stroke to the original one.
* This error corresponds * to the maximum distance between the new stroke and the old one.
*/
- PolygonalizationShader(float iError) : StrokeShader()
+ PolygonalizationShader(float iError)
{
_error = iError;
}
@@ -548,7 +548,7 @@ class GuidingLinesShader : public StrokeShader {
* "bbox". iOffset is the value of the displacement which is applied to this line along its
* normal.
*/
- GuidingLinesShader(float iOffset) : StrokeShader()
+ GuidingLinesShader(float iOffset)
{
_offset = iOffset;
}
@@ -604,7 +604,7 @@ class BlenderTextureShader : public StrokeShader {
* \param mtex:
* The blender texture to use.
*/
- BlenderTextureShader(MTex *mtex) : StrokeShader()
+ BlenderTextureShader(MTex *mtex)
{
_mtex = mtex;
_nodeTree = NULL;
@@ -614,7 +614,7 @@ class BlenderTextureShader : public StrokeShader {
* \param nodetree:
* A node tree (of new shading nodes) to define textures.
*/
- BlenderTextureShader(bNodeTree *nodetree) : StrokeShader()
+ BlenderTextureShader(bNodeTree *nodetree)
{
_nodeTree = nodetree;
_mtex = NULL;
@@ -642,7 +642,7 @@ class StrokeTextureStepShader : public StrokeShader {
* \param id:
* The number of the preset to use.
*/
- StrokeTextureStepShader(float step) : StrokeShader()
+ StrokeTextureStepShader(float step)
{
_step = step;
}
diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp
index 14c74c0f127..dc1a6fac4a9 100644
--- a/source/blender/freestyle/intern/stroke/Canvas.cpp
+++ b/source/blender/freestyle/intern/stroke/Canvas.cpp
@@ -48,17 +48,17 @@ using namespace std;
namespace Freestyle {
-Canvas *Canvas::_pInstance = 0;
+Canvas *Canvas::_pInstance = nullptr;
-const char *Canvas::_MapsPath = 0;
+const char *Canvas::_MapsPath = nullptr;
Canvas::Canvas()
{
- _SelectedFEdge = 0;
+ _SelectedFEdge = nullptr;
_pInstance = this;
PseudoNoise::init(42);
- _Renderer = 0;
- _current_sm = NULL;
+ _Renderer = nullptr;
+ _current_sm = nullptr;
_steerableViewMap = new SteerableViewMap(NB_STEERABLE_VIEWMAP - 1);
_basic = false;
}
@@ -76,12 +76,12 @@ Canvas::Canvas(const Canvas &iBrother)
Canvas::~Canvas()
{
- _pInstance = 0;
+ _pInstance = nullptr;
Clear();
if (_Renderer) {
delete _Renderer;
- _Renderer = 0;
+ _Renderer = nullptr;
}
// FIXME: think about an easy control for the maps memory management...
if (!_maps.empty()) {
@@ -347,8 +347,8 @@ void Canvas::loadMap(const char *iFileName,
qimg = &newMap;
#endif
/* OCIO_TODO: support different input color space */
- ImBuf *qimg = IMB_loadiffname(filePath.c_str(), 0, NULL);
- if (qimg == 0) {
+ ImBuf *qimg = IMB_loadiffname(filePath.c_str(), 0, nullptr);
+ if (qimg == nullptr) {
cerr << "Could not load image file " << filePath << endl;
return;
}
diff --git a/source/blender/freestyle/intern/stroke/Chain.cpp b/source/blender/freestyle/intern/stroke/Chain.cpp
index 562ca32be78..4a0f31bc910 100644
--- a/source/blender/freestyle/intern/stroke/Chain.cpp
+++ b/source/blender/freestyle/intern/stroke/Chain.cpp
@@ -53,7 +53,7 @@ void Chain::push_viewedge_back(ViewEdge *iViewEdge, bool orientation)
}
// Ensure the continuity of underlying FEdges
CurvePoint *cp =
- _Vertices.back(); // assumed to be instantiated as new CurvePoint(iSVertex, 0, 0.f);
+ _Vertices.back(); // assumed to be instantiated as new CurvePoint(iSVertex, 0, 0.0f);
SVertex *sv_first = (*vfirst);
FEdge *fe = _fedgeB->duplicate();
fe->setTemporary(true);
@@ -117,7 +117,7 @@ void Chain::push_viewedge_front(ViewEdge *iViewEdge, bool orientation)
}
// Ensure the continuity of underlying FEdges
CurvePoint *cp =
- _Vertices.front(); // assumed to be instantiated as new CurvePoint(iSVertex, 0, 0.f);
+ _Vertices.front(); // assumed to be instantiated as new CurvePoint(iSVertex, 0, 0.0f);
SVertex *sv_last = cp->A();
SVertex *sv_curr = (*v);
FEdge *fe = (orientation) ? iViewEdge->fedgeA() : iViewEdge->fedgeB();
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
index 2b2ab0dc14a..51c04c8346e 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
@@ -76,19 +76,19 @@ int ChainingIterator::increment()
_increment = true;
ViewVertex *vertex = getVertex();
if (!vertex) {
- _edge = 0;
+ _edge = nullptr;
return 0;
}
AdjacencyIterator it = AdjacencyIterator(vertex, _restrictToSelection, _restrictToUnvisited);
if (it.isEnd()) {
- _edge = 0;
+ _edge = nullptr;
return 0;
}
if (traverse(it) < 0) {
return -1;
}
_edge = result;
- if (_edge == 0) {
+ if (_edge == nullptr) {
return 0;
}
if (_edge->A() == vertex) {
@@ -105,19 +105,19 @@ int ChainingIterator::decrement()
_increment = false;
ViewVertex *vertex = getVertex();
if (!vertex) {
- _edge = 0;
+ _edge = nullptr;
return 0;
}
AdjacencyIterator it = AdjacencyIterator(vertex, _restrictToSelection, _restrictToUnvisited);
if (it.isEnd()) {
- _edge = 0;
+ _edge = nullptr;
return 0;
}
if (traverse(it) < 0) {
return -1;
}
_edge = result;
- if (_edge == 0) {
+ if (_edge == nullptr) {
return 0;
}
if (_edge->B() == vertex) {
@@ -150,12 +150,12 @@ int ChainSilhouetteIterator::traverse(const AdjacencyIterator &ait)
}
++it;
}
- result = 0;
+ result = nullptr;
return 0;
}
if (nextVertex->getNature() & Nature::NON_T_VERTEX) {
// soc NonTVertex *nontvertex = (NonTVertex*)nextVertex;
- ViewEdge *newEdge(0);
+ ViewEdge *newEdge(nullptr);
// we'll try to chain the edges by keeping the same nature...
// the preseance order is : SILHOUETTE, BORDER, CREASE, MATERIAL_BOUNDARY, EDGE_MARK,
// SUGGESTIVE, VALLEY, RIDGE
@@ -185,13 +185,13 @@ int ChainSilhouetteIterator::traverse(const AdjacencyIterator &ait)
result = newEdge;
}
else {
- result = 0;
+ result = nullptr;
}
return 0;
}
}
}
- result = 0;
+ result = nullptr;
return 0;
}
@@ -218,7 +218,7 @@ int ChainPredicateIterator::traverse(const AdjacencyIterator &ait)
}
++it;
}
- result = 0;
+ result = nullptr;
return 0;
}
diff --git a/source/blender/freestyle/intern/stroke/ContextFunctions.cpp b/source/blender/freestyle/intern/stroke/ContextFunctions.cpp
index 5609013a417..c6140f463ab 100644
--- a/source/blender/freestyle/intern/stroke/ContextFunctions.cpp
+++ b/source/blender/freestyle/intern/stroke/ContextFunctions.cpp
@@ -26,9 +26,7 @@
#include "../system/TimeStamp.h"
-namespace Freestyle {
-
-namespace ContextFunctions {
+namespace Freestyle::ContextFunctions {
unsigned GetTimeStampCF()
{
@@ -78,6 +76,4 @@ FEdge *GetSelectedFEdgeCF()
return Canvas::getInstance()->selectedFEdge();
}
-} // namespace ContextFunctions
-
-} /* namespace Freestyle */
+} // namespace Freestyle::ContextFunctions
diff --git a/source/blender/freestyle/intern/stroke/Curve.cpp b/source/blender/freestyle/intern/stroke/Curve.cpp
index 7129a35ffdb..c3dac81477d 100644
--- a/source/blender/freestyle/intern/stroke/Curve.cpp
+++ b/source/blender/freestyle/intern/stroke/Curve.cpp
@@ -40,8 +40,8 @@ namespace Freestyle {
CurvePoint::CurvePoint()
{
- __A = 0;
- __B = 0;
+ __A = nullptr;
+ __B = nullptr;
_t2d = 0;
}
@@ -50,11 +50,11 @@ CurvePoint::CurvePoint(SVertex *iA, SVertex *iB, float t)
__A = iA;
__B = iB;
_t2d = t;
- if ((iA == 0) && (t == 1.0f)) {
+ if ((iA == nullptr) && (t == 1.0f)) {
_Point2d = __B->point2d();
_Point3d = __B->point3d();
}
- else if ((iB == 0) && (t == 0.0f)) {
+ else if ((iB == nullptr) && (t == 0.0f)) {
_Point2d = __A->point2d();
_Point3d = __A->point3d();
}
@@ -66,17 +66,17 @@ CurvePoint::CurvePoint(SVertex *iA, SVertex *iB, float t)
CurvePoint::CurvePoint(CurvePoint *iA, CurvePoint *iB, float t3)
{
- __A = 0;
- __B = 0;
+ __A = nullptr;
+ __B = nullptr;
float t1 = iA->t2d();
float t2 = iB->t2d();
- if ((iA->A() == iB->A()) && (iA->B() == iB->B()) && (iA->A() != 0) && (iA->B() != 0) &&
- (iB->A() != 0) && (iB->B() != 0)) {
+ if ((iA->A() == iB->A()) && (iA->B() == iB->B()) && (iA->A() != nullptr) &&
+ (iA->B() != nullptr) && (iB->A() != nullptr) && (iB->B() != nullptr)) {
__A = iA->A();
__B = iB->B();
_t2d = t1 + t2 * t3 - t1 * t3;
}
- else if ((iA->B() == 0) && (iB->B() == 0)) {
+ else if ((iA->B() == nullptr) && (iB->B() == nullptr)) {
__A = iA->A();
__B = iB->A();
_t2d = t3;
@@ -133,15 +133,15 @@ CurvePoint::CurvePoint(CurvePoint *iA, CurvePoint *iB, float t3)
_t2d = t2 * t3;
}
}
- else if (iA->A() != 0 && iB->A() != 0 &&
+ else if (iA->A() != nullptr && iB->A() != nullptr &&
(iA->A()->point3d() - iB->A()->point3d()).norm() < 1.0e-6) {
goto iA_A_eq_iB_A;
}
- else if (iA->B() != 0 && iB->B() != 0 &&
+ else if (iA->B() != nullptr && iB->B() != nullptr &&
(iA->B()->point3d() - iB->B()->point3d()).norm() < 1.0e-6) {
goto iA_B_eq_iB_B;
}
- else if (iA->B() != 0 && iB->A() != 0 &&
+ else if (iA->B() != nullptr && iB->A() != nullptr &&
(iA->B()->point3d() - iB->A()->point3d()).norm() < 1.0e-6) {
goto iA_B_eq_iB_A;
}
@@ -162,7 +162,7 @@ CurvePoint::CurvePoint(CurvePoint *iA, CurvePoint *iB, float t3)
cerr << "Fatal error in CurvePoint::CurvePoint(CurvePoint *iA, CurvePoint *iB, float t3)"
<< endl;
}
- BLI_assert(__A != 0 && __B != 0);
+ BLI_assert(__A != nullptr && __B != nullptr);
#if 0
_Point2d = __A->point2d() + _t2d * (__B->point2d() - __A->point2d());
@@ -195,7 +195,7 @@ CurvePoint &CurvePoint::operator=(const CurvePoint &iBrother)
FEdge *CurvePoint::fedge()
{
if (getNature() & Nature::T_VERTEX) {
- return 0;
+ return nullptr;
}
return __A->fedge();
}
@@ -206,14 +206,14 @@ FEdge *CurvePoint::getFEdge(Interface0D &inter)
if (!iVertexB) {
cerr << "Warning: CurvePoint::getFEdge() failed to cast the given 0D element to CurvePoint."
<< endl;
- return 0;
+ return nullptr;
}
if (((__A == iVertexB->__A) && (__B == iVertexB->__B)) ||
((__A == iVertexB->__B) && (__B == iVertexB->__A))) {
return __A->getFEdge(*__B);
}
- if (__B == 0) {
- if (iVertexB->__B == 0) {
+ if (__B == nullptr) {
+ if (iVertexB->__B == nullptr) {
return __A->getFEdge(*(iVertexB->__A));
}
if (iVertexB->__A == __A) {
@@ -223,7 +223,7 @@ FEdge *CurvePoint::getFEdge(Interface0D &inter)
return __A->getFEdge(*(iVertexB->__A));
}
}
- if (iVertexB->__B == 0) {
+ if (iVertexB->__B == nullptr) {
if (iVertexB->__A == __A) {
return __B->getFEdge(*(iVertexB->__A));
}
@@ -284,15 +284,15 @@ FEdge *CurvePoint::getFEdge(Interface0D &inter)
#endif
cerr << "Warning: CurvePoint::getFEdge() failed." << endl;
- return NULL;
+ return nullptr;
}
Vec3r CurvePoint::normal() const
{
- if (__B == 0) {
+ if (__B == nullptr) {
return __A->normal();
}
- if (__A == 0) {
+ if (__A == nullptr) {
return __B->normal();
}
Vec3r Na = __A->normal();
@@ -328,7 +328,7 @@ Id CurvePoint::shape_id() const
const SShape *CurvePoint::shape() const
{
- if (__A == 0) {
+ if (__A == nullptr) {
return __B->shape();
}
return __A->shape();
@@ -357,10 +357,10 @@ const unsigned CurvePoint::qi() const
occluder_container::const_iterator CurvePoint::occluders_begin() const
{
- if (__A == 0) {
+ if (__A == nullptr) {
return __B->occluders_begin();
}
- if (__B == 0) {
+ if (__B == nullptr) {
return __A->occluders_begin();
}
return __A->getFEdge(*__B)->occluders_begin();
@@ -368,10 +368,10 @@ occluder_container::const_iterator CurvePoint::occluders_begin() const
occluder_container::const_iterator CurvePoint::occluders_end() const
{
- if (__A == 0) {
+ if (__A == nullptr) {
return __B->occluders_end();
}
- if (__B == 0) {
+ if (__B == nullptr) {
return __A->occluders_end();
}
return __A->getFEdge(*__B)->occluders_end();
@@ -379,10 +379,10 @@ occluder_container::const_iterator CurvePoint::occluders_end() const
bool CurvePoint::occluders_empty() const
{
- if (__A == 0) {
+ if (__A == nullptr) {
return __B->occluders_empty();
}
- if (__B == 0) {
+ if (__B == nullptr) {
return __A->occluders_empty();
}
return __A->getFEdge(*__B)->occluders_empty();
@@ -390,10 +390,10 @@ bool CurvePoint::occluders_empty() const
int CurvePoint::occluders_size() const
{
- if (__A == 0) {
+ if (__A == nullptr) {
return __B->occluders_size();
}
- if (__B == 0) {
+ if (__B == nullptr) {
return __A->occluders_size();
}
return __A->getFEdge(*__B)->occluders_size();
@@ -401,10 +401,10 @@ int CurvePoint::occluders_size() const
const SShape *CurvePoint::occluded_shape() const
{
- if (__A == 0) {
+ if (__A == nullptr) {
return __B->occluded_shape();
}
- if (__B == 0) {
+ if (__B == nullptr) {
return __A->occluded_shape();
}
return __A->getFEdge(*__B)->occluded_shape();
@@ -412,10 +412,10 @@ const SShape *CurvePoint::occluded_shape() const
const Polygon3r &CurvePoint::occludee() const
{
- if (__A == 0) {
+ if (__A == nullptr) {
return __B->occludee();
}
- if (__B == 0) {
+ if (__B == nullptr) {
return __A->occludee();
}
return __A->getFEdge(*__B)->occludee();
@@ -423,10 +423,10 @@ const Polygon3r &CurvePoint::occludee() const
bool CurvePoint::occludee_empty() const
{
- if (__A == 0) {
+ if (__A == nullptr) {
return __B->occludee_empty();
}
- if (__B == 0) {
+ if (__B == nullptr) {
return __A->occludee_empty();
}
return __A->getFEdge(*__B)->occludee_empty();
@@ -434,13 +434,13 @@ bool CurvePoint::occludee_empty() const
real CurvePoint::z_discontinuity() const
{
- if (__A == 0) {
+ if (__A == nullptr) {
return __B->z_discontinuity();
}
- if (__B == 0) {
+ if (__B == nullptr) {
return __A->z_discontinuity();
}
- if (__A->getFEdge(*__B) == 0) {
+ if (__A->getFEdge(*__B) == nullptr) {
return 0.0;
}
diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp
index 25954c7ecbf..c73bb739e47 100644
--- a/source/blender/freestyle/intern/stroke/Operators.cpp
+++ b/source/blender/freestyle/intern/stroke/Operators.cpp
@@ -34,7 +34,7 @@ namespace Freestyle {
Operators::I1DContainer Operators::_current_view_edges_set;
Operators::I1DContainer Operators::_current_chains_set;
-Operators::I1DContainer *Operators::_current_set = NULL;
+Operators::I1DContainer *Operators::_current_set = nullptr;
Operators::StrokesContainer Operators::_current_strokes_set;
int Operators::select(UnaryPredicate1D &pred)
@@ -656,7 +656,7 @@ int Operators::sequentialSplit(UnaryPredicate0D &startingPred,
goto error;
}
} while (!startingPred.result);
- } while ((itStart != end) && (itStart != last));
+ } while (!ELEM(itStart, end, last));
}
// Update the current set of chains:
@@ -738,7 +738,7 @@ static int __recursiveSplit(Chain *_curve,
// retrieves the current splitting id
Id *newId = _curve->getSplittingId();
- if (newId == 0) {
+ if (newId == nullptr) {
newId = new Id(_curve->getId());
_curve->setSplittingId(newId);
}
@@ -810,7 +810,7 @@ int Operators::recursiveSplit(UnaryFunction0D<double> &func,
return 0;
}
- Chain *currentChain = 0;
+ Chain *currentChain = nullptr;
I1DContainer splitted_chains;
I1DContainer newChains;
I1DContainer::iterator cit = _current_chains_set.begin(), citend = _current_chains_set.end();
@@ -885,7 +885,7 @@ static int __recursiveSplit(Chain *_curve,
#endif
real _min = FLT_MAX;
++it;
- real mean = 0.f;
+ real mean = 0.0f;
// soc unused - real variance = 0.0f;
unsigned count = 0;
CurveInternal::CurvePointIterator next = it;
@@ -921,7 +921,7 @@ static int __recursiveSplit(Chain *_curve,
// retrieves the current splitting id
Id *newId = _curve->getSplittingId();
- if (newId == NULL) {
+ if (newId == nullptr) {
newId = new Id(_curve->getId());
_curve->setSplittingId(newId);
}
@@ -994,7 +994,7 @@ int Operators::recursiveSplit(UnaryFunction0D<double> &func,
return 0;
}
- Chain *currentChain = 0;
+ Chain *currentChain = nullptr;
I1DContainer splitted_chains;
I1DContainer newChains;
I1DContainer::iterator cit = _current_chains_set.begin(), citend = _current_chains_set.end();
@@ -1095,7 +1095,7 @@ static Stroke *createStroke(Interface1D &inter)
Vec2r previous = current;
SVertex *sv;
CurvePoint *cp;
- StrokeVertex *stroke_vertex = NULL;
+ StrokeVertex *stroke_vertex = nullptr;
bool hasSingularity = false;
do {
@@ -1122,7 +1122,7 @@ static Stroke *createStroke(Interface1D &inter)
stroke->push_back(stroke_vertex);
previous = current;
++it;
- } while ((it != itend) && (it != itfirst));
+ } while (!ELEM(it, itend, itfirst));
if (it == itfirst) {
// Add last vertex:
@@ -1152,7 +1152,7 @@ static Stroke *createStroke(Interface1D &inter)
// Discard the stroke if the number of stroke vertices is less than two
if (stroke->strokeVerticesSize() < 2) {
delete stroke;
- return NULL;
+ return nullptr;
}
stroke->setLength(currentCurvilignAbscissa);
if (hasSingularity) {
@@ -1198,7 +1198,7 @@ static Stroke *createStroke(Interface1D &inter)
else {
// Discard the stroke because all stroke vertices are overlapping
delete stroke;
- return NULL;
+ return nullptr;
}
current = overlapping_vertices.front()->getPoint();
Vec2r dir(target - current);
diff --git a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp
index c2c263696bc..0e3fea3ddf8 100644
--- a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp
@@ -24,7 +24,7 @@
namespace Freestyle {
-PSStrokeRenderer::PSStrokeRenderer(const char *iFileName) : StrokeRenderer()
+PSStrokeRenderer::PSStrokeRenderer(const char *iFileName)
{
if (!iFileName) {
iFileName = "freestyle.ps";
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp
index aa87dc473e2..79eb37ae870 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -47,9 +47,9 @@ StrokeAttribute::StrokeAttribute()
_color[i] = 0.2f;
}
_color[0] = 0.8f;
- _userAttributesReal = NULL;
- _userAttributesVec2f = NULL;
- _userAttributesVec3f = NULL;
+ _userAttributesReal = nullptr;
+ _userAttributesVec2f = nullptr;
+ _userAttributesVec3f = nullptr;
_visible = true;
}
@@ -66,19 +66,19 @@ StrokeAttribute::StrokeAttribute(const StrokeAttribute &iBrother)
_userAttributesReal = new realMap(*iBrother._userAttributesReal);
}
else {
- _userAttributesReal = NULL;
+ _userAttributesReal = nullptr;
}
if (iBrother._userAttributesVec2f) {
_userAttributesVec2f = new Vec2fMap(*iBrother._userAttributesVec2f);
}
else {
- _userAttributesVec2f = NULL;
+ _userAttributesVec2f = nullptr;
}
if (iBrother._userAttributesVec3f) {
_userAttributesVec3f = new Vec3fMap(*iBrother._userAttributesVec3f);
}
else {
- _userAttributesVec3f = NULL;
+ _userAttributesVec3f = nullptr;
}
}
@@ -100,9 +100,9 @@ StrokeAttribute::StrokeAttribute(float iRColor,
_visible = true;
- _userAttributesReal = NULL;
- _userAttributesVec2f = NULL;
- _userAttributesVec3f = NULL;
+ _userAttributesReal = nullptr;
+ _userAttributesVec2f = nullptr;
+ _userAttributesVec3f = nullptr;
}
StrokeAttribute::StrokeAttribute(const StrokeAttribute &a1, const StrokeAttribute &a2, float t)
@@ -129,7 +129,7 @@ StrokeAttribute::StrokeAttribute(const StrokeAttribute &a1, const StrokeAttribut
}
}
else {
- _userAttributesReal = NULL;
+ _userAttributesReal = nullptr;
}
if ((a1._userAttributesVec2f) && (a2._userAttributesVec2f)) {
if (a1._userAttributesVec2f->size() == a2._userAttributesVec2f->size()) {
@@ -143,7 +143,7 @@ StrokeAttribute::StrokeAttribute(const StrokeAttribute &a1, const StrokeAttribut
}
}
else {
- _userAttributesVec2f = NULL;
+ _userAttributesVec2f = nullptr;
}
if ((a1._userAttributesVec3f) && (a2._userAttributesVec3f)) {
if (a1._userAttributesVec3f->size() == a2._userAttributesVec3f->size()) {
@@ -157,7 +157,7 @@ StrokeAttribute::StrokeAttribute(const StrokeAttribute &a1, const StrokeAttribut
}
}
else {
- _userAttributesVec3f = NULL;
+ _userAttributesVec3f = nullptr;
}
}
@@ -194,7 +194,7 @@ StrokeAttribute &StrokeAttribute::operator=(const StrokeAttribute &iBrother)
_userAttributesReal = new realMap(*(iBrother._userAttributesReal));
}
else {
- _userAttributesReal = NULL;
+ _userAttributesReal = nullptr;
}
if (iBrother._userAttributesVec2f) {
if (!_userAttributesVec2f) {
@@ -203,7 +203,7 @@ StrokeAttribute &StrokeAttribute::operator=(const StrokeAttribute &iBrother)
_userAttributesVec2f = new Vec2fMap(*(iBrother._userAttributesVec2f));
}
else {
- _userAttributesVec2f = NULL;
+ _userAttributesVec2f = nullptr;
}
if (iBrother._userAttributesVec3f) {
if (!_userAttributesVec3f) {
@@ -212,7 +212,7 @@ StrokeAttribute &StrokeAttribute::operator=(const StrokeAttribute &iBrother)
_userAttributesVec3f = new Vec3fMap(*(iBrother._userAttributesVec3f));
}
else {
- _userAttributesVec3f = NULL;
+ _userAttributesVec3f = nullptr;
}
return *this;
}
@@ -342,7 +342,7 @@ void StrokeAttribute::setAttributeVec3f(const char *iName, const Vec3f &att)
/* */
/**********************************/
-StrokeVertex::StrokeVertex() : CurvePoint()
+StrokeVertex::StrokeVertex()
{
_CurvilignAbscissa = 0.0f;
_StrokeLength = 0.0f;
@@ -355,7 +355,7 @@ StrokeVertex::StrokeVertex(const StrokeVertex &iBrother) : CurvePoint(iBrother)
_StrokeLength = 0.0f;
}
-StrokeVertex::StrokeVertex(SVertex *iSVertex) : CurvePoint(iSVertex, 0, 0.0f)
+StrokeVertex::StrokeVertex(SVertex *iSVertex) : CurvePoint(iSVertex, nullptr, 0.0f)
{
_CurvilignAbscissa = 0.0f;
_StrokeLength = 0.0f;
@@ -376,7 +376,7 @@ StrokeVertex::StrokeVertex(StrokeVertex *iA, StrokeVertex *iB, float t3) : Curve
}
StrokeVertex::StrokeVertex(SVertex *iSVertex, const StrokeAttribute &iAttribute)
- : CurvePoint(iSVertex, 0, 0.0f)
+ : CurvePoint(iSVertex, nullptr, 0.0f)
{
_Attribute = iAttribute;
_CurvilignAbscissa = 0.0f;
@@ -416,11 +416,11 @@ Stroke::Stroke()
_textureId = 0;
_textureStep = 1.0;
for (int a = 0; a < MAX_MTEX; a++) {
- _mtex[a] = NULL;
+ _mtex[a] = nullptr;
}
- _nodeTree = NULL;
+ _nodeTree = nullptr;
_tips = false;
- _rep = NULL;
+ _rep = nullptr;
}
Stroke::Stroke(const Stroke &iBrother) : Interface1D(iBrother)
@@ -447,7 +447,7 @@ Stroke::Stroke(const Stroke &iBrother) : Interface1D(iBrother)
_rep = new StrokeRep(*(iBrother._rep));
}
else {
- _rep = NULL;
+ _rep = nullptr;
}
}
@@ -464,7 +464,7 @@ Stroke::~Stroke()
_ViewEdges.clear();
if (_rep) {
delete _rep;
- _rep = NULL;
+ _rep = nullptr;
}
}
@@ -489,7 +489,7 @@ Stroke &Stroke::operator=(const Stroke &iBrother)
_rep = new StrokeRep(*(iBrother._rep));
}
else {
- _rep = NULL;
+ _rep = nullptr;
}
return *this;
}
@@ -550,7 +550,7 @@ int Stroke::Resample(int iNPoints)
vertex_container newVertices;
real t = 0.0f;
- StrokeVertex *newVertex = NULL;
+ StrokeVertex *newVertex = nullptr;
vector<StrokeSegment> strokeSegments;
int N = 0;
float meanlength = 0;
@@ -562,7 +562,7 @@ int Stroke::Resample(int iNPoints)
real norm_var = vec_tmp.norm();
int numberOfPointsToAdd = (int)floor(NPointsToAdd * norm_var / _Length);
float csampling = norm_var / (float)(numberOfPointsToAdd + 1);
- strokeSegments.push_back(StrokeSegment(it, next, norm_var, numberOfPointsToAdd, csampling));
+ strokeSegments.emplace_back(it, next, norm_var, numberOfPointsToAdd, csampling);
N += numberOfPointsToAdd;
meanlength += norm_var;
++nsegments;
@@ -661,7 +661,7 @@ int Stroke::Resample(float iSampling)
vertex_container newVertices;
real t = 0.0f;
const real limit = 0.99;
- StrokeVertex *newVertex = NULL;
+ StrokeVertex *newVertex = nullptr;
StrokeInternal::StrokeVertexIterator it = strokeVerticesBegin();
StrokeInternal::StrokeVertexIterator next = it;
++next;
@@ -691,7 +691,7 @@ int Stroke::Resample(float iSampling)
++next;
}
// add last:
- if ((it != itend) && (next == itend) /* && (t == 0.f)*/) {
+ if ((it != itend) && (next == itend) /* && (t == 0.0f)*/) {
newVertices.push_back(&(*it));
}
diff --git a/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp b/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
index 5b2beb8f068..a4268e43a56 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
@@ -35,7 +35,7 @@ namespace Freestyle {
/* */
/**********************************/
-TextureManager *StrokeRenderer::_textureManager = 0;
+TextureManager *StrokeRenderer::_textureManager = nullptr;
StrokeRenderer::StrokeRenderer()
{
@@ -59,7 +59,7 @@ bool StrokeRenderer::loadTextures()
/* */
/**********************************/
-TextureManager *TextureManager::_pInstance = 0;
+TextureManager *TextureManager::_pInstance = nullptr;
string TextureManager::_patterns_path;
@@ -77,7 +77,7 @@ TextureManager::~TextureManager()
if (!_brushesMap.empty()) {
_brushesMap.clear();
}
- _pInstance = 0;
+ _pInstance = nullptr;
}
void TextureManager::load()
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
index 3678461253c..aadc42beb4b 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
@@ -563,8 +563,8 @@ void Strip::computeTexCoordWithTips(const vector<StrokeVertex *> &iStrokeVertice
float texStep)
{
vector<StrokeVertex *>::const_iterator v, vend;
- StrokeVertex *sv = NULL;
- StrokeVertexRep *tvRep[2] = {NULL};
+ StrokeVertex *sv = nullptr;
+ StrokeVertexRep *tvRep[2] = {nullptr};
float l, fact, t;
float u = 0, uPrev = 0;
@@ -750,13 +750,13 @@ void Strip::computeTexCoordWithTips(const vector<StrokeVertex *> &iStrokeVertice
StrokeRep::StrokeRep()
{
- _stroke = 0;
+ _stroke = nullptr;
_strokeType = Stroke::OPAQUE_MEDIUM;
- _nodeTree = NULL;
+ _nodeTree = nullptr;
_hasTex = false;
_textureStep = 1.0;
for (int a = 0; a < MAX_MTEX; a++) {
- _mtex[a] = NULL;
+ _mtex[a] = nullptr;
}
TextureManager *ptm = TextureManager::getInstance();
if (ptm) {
@@ -786,7 +786,7 @@ StrokeRep::StrokeRep(Stroke *iStroke)
_mtex[a] = iStroke->getMTex(a);
}
else {
- _mtex[a] = NULL;
+ _mtex[a] = nullptr;
}
}
if (_textureId == 0) {
@@ -822,7 +822,7 @@ StrokeRep::StrokeRep(const StrokeRep &iBrother)
_mtex[a] = iBrother._mtex[a];
}
else {
- _mtex[a] = NULL;
+ _mtex[a] = nullptr;
}
}
for (vector<Strip *>::const_iterator s = iBrother._strips.begin(), send = iBrother._strips.end();
diff --git a/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp b/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
index e9a50067d4d..d4ebaac2459 100644
--- a/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
@@ -30,8 +30,8 @@ namespace Freestyle {
LineRep *StrokeTesselator::Tesselate(Stroke *iStroke)
{
- if (0 == iStroke) {
- return 0;
+ if (nullptr == iStroke) {
+ return nullptr;
}
LineRep *line;
diff --git a/source/blender/freestyle/intern/stroke/TextStrokeRenderer.cpp b/source/blender/freestyle/intern/stroke/TextStrokeRenderer.cpp
index f579bd72038..fa131743afc 100644
--- a/source/blender/freestyle/intern/stroke/TextStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/stroke/TextStrokeRenderer.cpp
@@ -20,7 +20,7 @@
namespace Freestyle {
-TextStrokeRenderer::TextStrokeRenderer(const char *iFileName) : StrokeRenderer()
+TextStrokeRenderer::TextStrokeRenderer(const char *iFileName)
{
if (!iFileName) {
iFileName = "freestyle.txt";
diff --git a/source/blender/freestyle/intern/system/StringUtils.cpp b/source/blender/freestyle/intern/system/StringUtils.cpp
index 90210f33a25..b488987dd41 100644
--- a/source/blender/freestyle/intern/system/StringUtils.cpp
+++ b/source/blender/freestyle/intern/system/StringUtils.cpp
@@ -24,9 +24,7 @@
#include "StringUtils.h"
#include "FreestyleConfig.h"
-namespace Freestyle {
-
-namespace StringUtils {
+namespace Freestyle::StringUtils {
void getPathName(const string &path, const string &base, vector<string> &pathnames)
{
@@ -46,7 +44,7 @@ void getPathName(const string &path, const string &base, vector<string> &pathnam
dir = path.substr(pos, sep - pos);
BLI_strncpy(cleaned, dir.c_str(), FILE_MAX);
- BLI_path_normalize(NULL, cleaned);
+ BLI_path_normalize(nullptr, cleaned);
res = string(cleaned);
if (!base.empty()) {
@@ -57,6 +55,4 @@ void getPathName(const string &path, const string &base, vector<string> &pathnam
}
}
-} // end of namespace StringUtils
-
-} /* namespace Freestyle */
+} // namespace Freestyle::StringUtils
diff --git a/source/blender/freestyle/intern/view_map/AutoPtrHelper.h b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
index 94fd80bc0fb..cfcfa5e651b 100644
--- a/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
+++ b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
@@ -27,6 +27,8 @@ namespace Freestyle {
template<typename T> class AutoPtr : public std::unique_ptr<T> {
public:
+ using std::unique_ptr<T>::unique_ptr;
+
AutoPtr() : std::unique_ptr<T>()
{
}
@@ -42,6 +44,8 @@ template<typename T> class AutoPtr : public std::unique_ptr<T> {
other.release();
}
+ using std::unique_ptr<T>::operator=;
+
template<typename X> AutoPtr &operator=(AutoPtr<X> &other) = delete;
};
diff --git a/source/blender/freestyle/intern/view_map/BoxGrid.cpp b/source/blender/freestyle/intern/view_map/BoxGrid.cpp
index 5a490e3c7cc..e81291c94bc 100644
--- a/source/blender/freestyle/intern/view_map/BoxGrid.cpp
+++ b/source/blender/freestyle/intern/view_map/BoxGrid.cpp
@@ -157,7 +157,7 @@ void BoxGrid::assignCells(OccluderSource & /*source*/,
Vec3r point = transform((*f)->center3d());
unsigned int i, j;
getCellCoordinates(point, i, j);
- if (_cells[i * _cellsY + j] == NULL) {
+ if (_cells[i * _cellsY + j] == nullptr) {
// This is an uninitialized cell
real x, y, width, height;
@@ -181,7 +181,7 @@ void BoxGrid::distributePolygons(OccluderSource &source)
unsigned long nKeptFaces = 0;
for (source.begin(); source.isValid(); source.next()) {
- OccluderData *occluder = NULL;
+ OccluderData *occluder = nullptr;
try {
if (insertOccluder(source, occluder)) {
@@ -242,7 +242,7 @@ bool BoxGrid::enableQI() const
return _enableQI;
}
-BoxGrid::Transform::Transform() : GridHelpers::Transform()
+BoxGrid::Transform::Transform()
{
}
diff --git a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
index cb3a297076a..a6781bfc8d1 100644
--- a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
+++ b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
@@ -146,7 +146,7 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
// For each feature edge, while bestOccluderTarget not found and view edge not visible
bool bestOccluderTargetFound = false;
- FEdge *bestOccluderTarget = NULL;
+ FEdge *bestOccluderTarget = nullptr;
real bestOccluderDistance = 0.0;
FEdge *festart = (*ve)->fedgeA();
FEdge *fe = festart;
@@ -173,7 +173,7 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
else {
real d = distance2D(fe->center2d(), prosceniumOrigin);
// If center point is closer to viewport origin than current target
- if (bestOccluderTarget == NULL || d < bestOccluderDistance) {
+ if (bestOccluderTarget == nullptr || d < bestOccluderDistance) {
// Then store as bestOccluderTarget
bestOccluderDistance = d;
bestOccluderTarget = fe;
@@ -187,18 +187,18 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
(*ve)->setIsInImage(true);
}
fe = fe->nextEdge();
- } while (fe != NULL && fe != festart && !(bestOccluderTargetFound && (*ve)->isInImage()));
+ } while (fe != nullptr && fe != festart && !(bestOccluderTargetFound && (*ve)->isInImage()));
// Either we have run out of FEdges, or we already have the one edge we need to determine
// visibility Cull all remaining edges.
- while (fe != NULL && fe != festart) {
+ while (!ELEM(fe, NULL, festart)) {
fe->setIsInImage(false);
fe = fe->nextEdge();
}
// If bestOccluderTarget was not found inside the occluder proscenium,
// we need to expand the occluder proscenium to include it.
- if ((*ve)->isInImage() && bestOccluderTarget != NULL && !bestOccluderTargetFound) {
+ if ((*ve)->isInImage() && bestOccluderTarget != nullptr && !bestOccluderTargetFound) {
// Expand occluder proscenium to enclose bestOccluderTarget
Vec3r point = bestOccluderTarget->center2d();
if (point[0] < occluderProscenium[0]) {
@@ -253,7 +253,7 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
expandGridSpaceOccluderProscenium(fe);
}
fe = fe->nextEdge();
- } while (fe != NULL && fe != festart);
+ } while (!ELEM(fe, NULL, festart));
}
}
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
index 3788b5e3545..7e8937bfe80 100644
--- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
+++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
@@ -39,7 +39,7 @@ void FEdgeXDetector::processShapes(WingedEdge &we)
vector<WShape *> wshapes = we.getWShapes();
WXShape *wxs;
- if (_pProgressBar != NULL) {
+ if (_pProgressBar != nullptr) {
_pProgressBar->reset();
_pProgressBar->setLabelText("Detecting feature lines");
_pProgressBar->setTotalSteps(wshapes.size() * 3);
@@ -228,7 +228,7 @@ void FEdgeXDetector::computeCurvatures(WXVertex *vertex)
}
// view dependent
C = vertex->curvatures();
- if (C == 0) {
+ if (C == nullptr) {
return;
}
@@ -370,7 +370,7 @@ void FEdgeXDetector::ProcessBorderEdge(WXEdge *iEdge)
{
// first check whether it is a border edge: BORDER ?
//---------
- if (iEdge->GetaFace() == 0) {
+ if (iEdge->GetaFace() == nullptr) {
// it is a border edge
iEdge->AddNature(Nature::BORDER);
}
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.cpp b/source/blender/freestyle/intern/view_map/Functions0D.cpp
index 892b9b33b4b..4ea163c47cf 100644
--- a/source/blender/freestyle/intern/view_map/Functions0D.cpp
+++ b/source/blender/freestyle/intern/view_map/Functions0D.cpp
@@ -26,9 +26,7 @@
using namespace std;
-namespace Freestyle {
-
-namespace Functions0D {
+namespace Freestyle::Functions0D {
// Internal function
FEdge *getFEdge(Interface0D &it1, Interface0D &it2)
@@ -47,7 +45,7 @@ void getFEdges(Interface0DIterator &it, FEdge *&fe1, FEdge *&fe2)
}
if (count < 3) {
// if we only have 2 vertices
- FEdge *fe = 0;
+ FEdge *fe = nullptr;
Interface0DIterator tmp = it;
if (it.isBegin()) {
++tmp;
@@ -58,7 +56,7 @@ void getFEdges(Interface0DIterator &it, FEdge *&fe1, FEdge *&fe2)
fe = it->getFEdge(*tmp);
}
fe1 = fe;
- fe2 = NULL;
+ fe2 = nullptr;
}
else {
// we have more than 2 vertices
@@ -77,11 +75,11 @@ void getFEdges(Interface0DIterator &it, FEdge *&fe1, FEdge *&fe2)
}
if (begin) {
fe1 = it->getFEdge(*next);
- fe2 = NULL;
+ fe2 = nullptr;
}
else if (last) {
fe1 = previous->getFEdge(*it);
- fe2 = NULL;
+ fe2 = nullptr;
}
else {
fe1 = previous->getFEdge(*it);
@@ -95,14 +93,14 @@ void getViewEdges(Interface0DIterator &it, ViewEdge *&ve1, ViewEdge *&ve2)
FEdge *fe1, *fe2;
getFEdges(it, fe1, fe2);
ve1 = fe1->viewedge();
- if (fe2 != NULL) {
+ if (fe2 != nullptr) {
ve2 = fe2->viewedge();
if (ve2 == ve1) {
- ve2 = NULL;
+ ve2 = nullptr;
}
}
else {
- ve2 = NULL;
+ ve2 = nullptr;
}
}
@@ -124,7 +122,7 @@ void getOccludersF0D(Interface0DIterator &it, set<ViewShape *> &oOccluders)
oOccluders.insert((*oit));
}
- if (ve2 != NULL) {
+ if (ve2 != nullptr) {
oit = ve2->occluders_begin();
oitend = ve2->occluders_end();
for (; oit != oitend; ++oit) {
@@ -280,7 +278,7 @@ int ZDiscontinuityF0D::operator()(Interface0DIterator &iter)
FEdge *fe1, *fe2;
getFEdges(iter, fe1, fe2);
result = fe1->z_discontinuity();
- if (fe2 != NULL) {
+ if (fe2 != nullptr) {
result += fe2->z_discontinuity();
result /= 2.0f;
}
@@ -294,7 +292,7 @@ int Normal2DF0D::operator()(Interface0DIterator &iter)
Vec3f e1(fe1->orientation2d());
Vec2f n1(e1[1], -e1[0]);
Vec2f n(n1);
- if (fe2 != NULL) {
+ if (fe2 != nullptr) {
Vec3f e2(fe2->orientation2d());
Vec2f n2(e2[1], -e2[0]);
n += n2;
@@ -308,7 +306,7 @@ int MaterialF0D::operator()(Interface0DIterator &iter)
{
FEdge *fe1, *fe2;
getFEdges(iter, fe1, fe2);
- if (fe1 == NULL) {
+ if (fe1 == nullptr) {
return -1;
}
if (fe1->isSmooth()) {
@@ -337,7 +335,7 @@ int QuantitativeInvisibilityF0D::operator()(Interface0DIterator &iter)
getViewEdges(iter, ve1, ve2);
unsigned int qi1, qi2;
qi1 = ve1->qi();
- if (ve2 != NULL) {
+ if (ve2 != nullptr) {
qi2 = ve2->qi();
if (qi2 != qi1) {
if (G.debug & G_DEBUG_FREESTYLE) {
@@ -356,7 +354,7 @@ int CurveNatureF0D::operator()(Interface0DIterator &iter)
ViewEdge *ve1, *ve2;
getViewEdges(iter, ve1, ve2);
nat |= ve1->getNature();
- if (ve2 != NULL) {
+ if (ve2 != nullptr) {
nat |= ve2->getNature();
}
result = nat;
@@ -388,6 +386,4 @@ int GetOccludeeF0D::operator()(Interface0DIterator &iter)
return 0;
}
-} // end of namespace Functions0D
-
-} /* namespace Freestyle */
+} // namespace Freestyle::Functions0D
diff --git a/source/blender/freestyle/intern/view_map/Functions1D.cpp b/source/blender/freestyle/intern/view_map/Functions1D.cpp
index a0a320a6e6d..999d7f6e753 100644
--- a/source/blender/freestyle/intern/view_map/Functions1D.cpp
+++ b/source/blender/freestyle/intern/view_map/Functions1D.cpp
@@ -23,9 +23,7 @@
using namespace std;
-namespace Freestyle {
-
-namespace Functions1D {
+namespace Freestyle::Functions1D {
int GetXF1D::operator()(Interface1D &inter)
{
@@ -219,8 +217,8 @@ void getOccludeeF1D(Interface1D &inter, set<ViewShape *> &oShapes)
ViewEdge *ve = dynamic_cast<ViewEdge *>(&inter);
if (ve) {
ViewShape *aShape = ve->aShape();
- if (aShape == 0) {
- oShapes.insert((ViewShape *)0);
+ if (aShape == nullptr) {
+ oShapes.insert((ViewShape *)nullptr);
return;
}
oShapes.insert(aShape);
@@ -266,6 +264,4 @@ void getShapeF1D(Interface1D &inter, set<ViewShape *> &oShapes)
}
}
-} // end of namespace Functions1D
-
-} /* namespace Freestyle */
+} // namespace Freestyle::Functions1D
diff --git a/source/blender/freestyle/intern/view_map/Interface0D.cpp b/source/blender/freestyle/intern/view_map/Interface0D.cpp
index 2961b0f58e5..907b21ad5cf 100644
--- a/source/blender/freestyle/intern/view_map/Interface0D.cpp
+++ b/source/blender/freestyle/intern/view_map/Interface0D.cpp
@@ -79,7 +79,7 @@ Geometry::Vec2r Interface0D::getPoint2D() const
FEdge *Interface0D::getFEdge(Interface0D &UNUSED(element))
{
PyErr_SetString(PyExc_TypeError, "method getFEdge() not properly overridden");
- return 0;
+ return nullptr;
}
Id Interface0D::getId() const
@@ -97,25 +97,25 @@ Nature::VertexNature Interface0D::getNature() const
SVertex *Interface0D::castToSVertex()
{
PyErr_SetString(PyExc_TypeError, "method castToSVertex() not properly overridden");
- return 0;
+ return nullptr;
}
ViewVertex *Interface0D::castToViewVertex()
{
PyErr_SetString(PyExc_TypeError, "method castToViewVertex() not properly overridden");
- return 0;
+ return nullptr;
}
NonTVertex *Interface0D::castToNonTVertex()
{
PyErr_SetString(PyExc_TypeError, "method castToNonTVertex() not properly overridden");
- return 0;
+ return nullptr;
}
TVertex *Interface0D::castToTVertex()
{
PyErr_SetString(PyExc_TypeError, "method castToTVertex() not properly overridden");
- return 0;
+ return nullptr;
}
} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/view_map/OccluderSource.cpp b/source/blender/freestyle/intern/view_map/OccluderSource.cpp
index e75856edc35..618fa781fa7 100644
--- a/source/blender/freestyle/intern/view_map/OccluderSource.cpp
+++ b/source/blender/freestyle/intern/view_map/OccluderSource.cpp
@@ -97,7 +97,7 @@ bool OccluderSource::isValid()
WFace *OccluderSource::getWFace()
{
- return valid ? *currentFace : NULL;
+ return valid ? *currentFace : nullptr;
}
Polygon3r OccluderSource::getCameraSpacePolygon()
diff --git a/source/blender/freestyle/intern/view_map/Silhouette.cpp b/source/blender/freestyle/intern/view_map/Silhouette.cpp
index 3280e56ea7e..0f9d1f166b2 100644
--- a/source/blender/freestyle/intern/view_map/Silhouette.cpp
+++ b/source/blender/freestyle/intern/view_map/Silhouette.cpp
@@ -158,14 +158,14 @@ real SVertex::z_discontinuity() const
FEdge *SVertex::fedge()
{
if (getNature() & Nature::T_VERTEX) {
- return NULL;
+ return nullptr;
}
return _FEdges[0];
}
FEdge *SVertex::getFEdge(Interface0D &inter)
{
- FEdge *result = NULL;
+ FEdge *result = nullptr;
SVertex *iVertexB = dynamic_cast<SVertex *>(&inter);
if (!iVertexB) {
return result;
@@ -177,7 +177,7 @@ FEdge *SVertex::getFEdge(Interface0D &inter)
result = (*fe);
}
}
- if ((result == 0) && (getNature() & Nature::T_VERTEX)) {
+ if ((result == nullptr) && (getNature() & Nature::T_VERTEX)) {
SVertex *brother;
ViewVertex *vvertex = viewvertex();
TVertex *tvertex = dynamic_cast<TVertex *>(vvertex);
@@ -195,7 +195,7 @@ FEdge *SVertex::getFEdge(Interface0D &inter)
}
}
}
- if ((result == 0) && (iVertexB->getNature() & Nature::T_VERTEX)) {
+ if ((result == nullptr) && (iVertexB->getNature() & Nature::T_VERTEX)) {
SVertex *brother;
ViewVertex *vvertex = iVertexB->viewvertex();
TVertex *tvertex = dynamic_cast<TVertex *>(vvertex);
@@ -239,8 +239,8 @@ float FEdge::viewedge_length() const
const SShape *FEdge::occluded_shape() const
{
ViewShape *aShape = _ViewEdge->aShape();
- if (aShape == 0) {
- return 0;
+ if (aShape == nullptr) {
+ return nullptr;
}
return aShape->sshape();
}
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
index 2624c70c988..21b0827a660 100644
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
@@ -73,7 +73,7 @@ real SilhouetteGeomEngine::_znear = 0.0;
real SilhouetteGeomEngine::_zfar = 100.0;
bool SilhouetteGeomEngine::_isOrthographicProjection = false;
-SilhouetteGeomEngine *SilhouetteGeomEngine::_pInstance = NULL;
+SilhouetteGeomEngine *SilhouetteGeomEngine::_pInstance = nullptr;
void SilhouetteGeomEngine::setTransform(const real iModelViewMatrix[4][4],
const real iProjectionMatrix[4][4],
diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
index 0c6e9741fbd..db567d6b5ef 100644
--- a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
+++ b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
@@ -154,7 +154,7 @@ void SphericalGrid::assignCells(OccluderSource & /*source*/,
Vec3r point = SphericalGrid::Transform::sphericalProjection((*f)->center3d());
unsigned i, j;
getCellCoordinates(point, i, j);
- if (_cells[i * _cellsY + j] == NULL) {
+ if (_cells[i * _cellsY + j] == nullptr) {
// This is an uninitialized cell
real x, y, width, height;
@@ -178,7 +178,7 @@ void SphericalGrid::distributePolygons(OccluderSource &source)
unsigned long nKeptFaces = 0;
for (source.begin(); source.isValid(); source.next()) {
- OccluderData *occluder = NULL;
+ OccluderData *occluder = nullptr;
try {
if (insertOccluder(source, occluder)) {
@@ -238,7 +238,7 @@ bool SphericalGrid::enableQI() const
return _enableQI;
}
-SphericalGrid::Transform::Transform() : GridHelpers::Transform()
+SphericalGrid::Transform::Transform()
{
}
diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
index 7790dd64cf5..d8a1e597a1d 100644
--- a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
@@ -45,8 +45,8 @@ SteerableViewMap::SteerableViewMap(unsigned int nbOrientations)
_nbOrientations = nbOrientations;
_bound = cos(M_PI / (float)_nbOrientations);
for (unsigned int i = 0; i < _nbOrientations; ++i) {
- _directions.push_back(Vec2d(cos((float)i * M_PI / (float)_nbOrientations),
- sin((float)i * M_PI / (float)_nbOrientations)));
+ _directions.emplace_back(cos((float)i * M_PI / (float)_nbOrientations),
+ sin((float)i * M_PI / (float)_nbOrientations));
}
Build();
}
@@ -88,7 +88,7 @@ void SteerableViewMap::Clear()
}
}
delete[] _imagesPyramids;
- _imagesPyramids = 0;
+ _imagesPyramids = nullptr;
}
if (!_mapping.empty()) {
for (map<unsigned int, double *>::iterator m = _mapping.begin(), mend = _mapping.end();
@@ -240,7 +240,7 @@ unsigned int SteerableViewMap::getNumberOfPyramidLevels() const
void SteerableViewMap::saveSteerableViewMap() const
{
for (unsigned int i = 0; i <= _nbOrientations; ++i) {
- if (_imagesPyramids[i] == 0) {
+ if (_imagesPyramids[i] == nullptr) {
cerr << "SteerableViewMap warning: orientation " << i
<< " of steerable View Map whas not been computed yet" << endl;
continue;
diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
index aecd37fa0de..8d5955fc0ae 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
@@ -33,13 +33,13 @@ namespace Freestyle {
void ViewEdgeXBuilder::Init(ViewShape *oVShape)
{
- if (NULL == oVShape) {
+ if (nullptr == oVShape) {
return;
}
// for design convenience, we store the current SShape.
_pCurrentSShape = oVShape->sshape();
- if (0 == _pCurrentSShape) {
+ if (nullptr == _pCurrentSShape) {
return;
}
@@ -164,7 +164,7 @@ ViewEdge *ViewEdgeXBuilder::BuildSmoothViewEdge(const OWXFaceLayer &iFaceLayer)
if (iFaceLayer.fl->nature() & Nature::RIDGE) {
if (size < 4) {
- return 0;
+ return nullptr;
}
}
@@ -176,9 +176,9 @@ ViewEdge *ViewEdgeXBuilder::BuildSmoothViewEdge(const OWXFaceLayer &iFaceLayer)
_pCurrentVShape->AddEdge(newVEdge);
// build FEdges
- FEdge *feprevious = NULL;
- FEdge *fefirst = NULL;
- FEdge *fe = NULL;
+ FEdge *feprevious = nullptr;
+ FEdge *fefirst = nullptr;
+ FEdge *fe = nullptr;
for (list<OWXFaceLayer>::iterator fl = facesChain.begin(), flend = facesChain.end(); fl != flend;
++fl) {
fe = BuildSmoothFEdge(feprevious, (*fl));
@@ -201,8 +201,8 @@ ViewEdge *ViewEdgeXBuilder::BuildSmoothViewEdge(const OWXFaceLayer &iFaceLayer)
if ((first == end) && (size != 1)) {
fefirst->setPreviousEdge(fe);
fe->setNextEdge(fefirst);
- newVEdge->setA(0);
- newVEdge->setB(0);
+ newVEdge->setA(nullptr);
+ newVEdge->setB(nullptr);
}
else {
ViewVertex *vva = MakeViewVertex(fefirst->vertexA());
@@ -262,9 +262,9 @@ ViewEdge *ViewEdgeXBuilder::BuildSharpViewEdge(const OWXEdge &iWEdge)
firstWEdge = edgesChain.front();
// build FEdges
- FEdge *feprevious = NULL;
- FEdge *fefirst = NULL;
- FEdge *fe = NULL;
+ FEdge *feprevious = nullptr;
+ FEdge *fefirst = nullptr;
+ FEdge *fe = nullptr;
for (list<OWXEdge>::iterator we = edgesChain.begin(), weend = edgesChain.end(); we != weend;
++we) {
fe = BuildSharpFEdge(feprevious, (*we));
@@ -284,8 +284,8 @@ ViewEdge *ViewEdgeXBuilder::BuildSharpViewEdge(const OWXEdge &iWEdge)
if ((firstWEdge == endWEdge) && (size != 1)) {
fefirst->setPreviousEdge(fe);
fe->setNextEdge(fefirst);
- newVEdge->setA(0);
- newVEdge->setB(0);
+ newVEdge->setA(nullptr);
+ newVEdge->setB(nullptr);
}
else {
ViewVertex *vva = MakeViewVertex(fefirst->vertexA());
@@ -303,7 +303,7 @@ ViewEdge *ViewEdgeXBuilder::BuildSharpViewEdge(const OWXEdge &iWEdge)
OWXFaceLayer ViewEdgeXBuilder::FindNextFaceLayer(const OWXFaceLayer &iFaceLayer)
{
- WXFace *nextFace = NULL;
+ WXFace *nextFace = nullptr;
WOEdge *woeend;
real tend;
if (iFaceLayer.order) {
@@ -315,7 +315,7 @@ OWXFaceLayer ViewEdgeXBuilder::FindNextFaceLayer(const OWXFaceLayer &iFaceLayer)
tend = iFaceLayer.fl->getSmoothEdge()->ta();
}
// special case of EDGE_VERTEX config:
- if ((tend == 0.0) || (tend == 1.0)) {
+ if (ELEM(tend, 0.0, 1.0)) {
WVertex *nextVertex;
if (tend == 0.0) {
nextVertex = woeend->GetaVertex();
@@ -324,14 +324,14 @@ OWXFaceLayer ViewEdgeXBuilder::FindNextFaceLayer(const OWXFaceLayer &iFaceLayer)
nextVertex = woeend->GetbVertex();
}
if (nextVertex->isBoundary()) { // if it's a non-manifold vertex -> ignore
- return OWXFaceLayer(0, true);
+ return OWXFaceLayer(nullptr, true);
}
bool found = false;
WVertex::face_iterator f = nextVertex->faces_begin();
WVertex::face_iterator fend = nextVertex->faces_end();
while ((!found) && (f != fend)) {
nextFace = dynamic_cast<WXFace *>(*f);
- if ((0 != nextFace) && (nextFace != iFaceLayer.fl->getFace())) {
+ if ((nullptr != nextFace) && (nextFace != iFaceLayer.fl->getFace())) {
vector<WXFaceLayer *> sameNatureLayers;
nextFace->retrieveSmoothEdgesLayers(iFaceLayer.fl->nature(), sameNatureLayers);
// don't know... Maybe should test whether this face has also a vertex_edge configuration.
@@ -339,7 +339,7 @@ OWXFaceLayer ViewEdgeXBuilder::FindNextFaceLayer(const OWXFaceLayer &iFaceLayer)
WXFaceLayer *winner = sameNatureLayers[0];
// check face mark continuity
if (winner->getFace()->GetMark() != iFaceLayer.fl->getFace()->GetMark()) {
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
if (woeend == winner->getSmoothEdge()->woea()->twin()) {
return OWXFaceLayer(winner, true);
@@ -354,24 +354,24 @@ OWXFaceLayer ViewEdgeXBuilder::FindNextFaceLayer(const OWXFaceLayer &iFaceLayer)
else {
nextFace = dynamic_cast<WXFace *>(iFaceLayer.fl->getFace()->GetBordingFace(woeend));
if (!nextFace) {
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
// if the next face layer has either no smooth edge or no smooth edge of same nature, no next
// face
if (!nextFace->hasSmoothEdges()) {
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
vector<WXFaceLayer *> sameNatureLayers;
nextFace->retrieveSmoothEdgesLayers(iFaceLayer.fl->nature(), sameNatureLayers);
// don't know how to deal with several edges of same nature on a single face
if ((sameNatureLayers.empty()) || (sameNatureLayers.size() != 1)) {
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
WXFaceLayer *winner = sameNatureLayers[0];
// check face mark continuity
if (winner->getFace()->GetMark() != iFaceLayer.fl->getFace()->GetMark()) {
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
if (woeend == winner->getSmoothEdge()->woea()->twin()) {
return OWXFaceLayer(winner, true);
@@ -379,12 +379,12 @@ OWXFaceLayer ViewEdgeXBuilder::FindNextFaceLayer(const OWXFaceLayer &iFaceLayer)
return OWXFaceLayer(winner, false);
}
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
OWXFaceLayer ViewEdgeXBuilder::FindPreviousFaceLayer(const OWXFaceLayer &iFaceLayer)
{
- WXFace *previousFace = NULL;
+ WXFace *previousFace = nullptr;
WOEdge *woebegin;
real tend;
if (iFaceLayer.order) {
@@ -397,7 +397,7 @@ OWXFaceLayer ViewEdgeXBuilder::FindPreviousFaceLayer(const OWXFaceLayer &iFaceLa
}
// special case of EDGE_VERTEX config:
- if ((tend == 0.0) || (tend == 1.0)) {
+ if (ELEM(tend, 0.0, 1.0)) {
WVertex *previousVertex;
if (tend == 0.0) {
previousVertex = woebegin->GetaVertex();
@@ -406,14 +406,14 @@ OWXFaceLayer ViewEdgeXBuilder::FindPreviousFaceLayer(const OWXFaceLayer &iFaceLa
previousVertex = woebegin->GetbVertex();
}
if (previousVertex->isBoundary()) { // if it's a non-manifold vertex -> ignore
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
bool found = false;
WVertex::face_iterator f = previousVertex->faces_begin();
WVertex::face_iterator fend = previousVertex->faces_end();
for (; (!found) && (f != fend); ++f) {
previousFace = dynamic_cast<WXFace *>(*f);
- if ((0 != previousFace) && (previousFace != iFaceLayer.fl->getFace())) {
+ if ((nullptr != previousFace) && (previousFace != iFaceLayer.fl->getFace())) {
vector<WXFaceLayer *> sameNatureLayers;
previousFace->retrieveSmoothEdgesLayers(iFaceLayer.fl->nature(), sameNatureLayers);
// don't know... Maybe should test whether this face has also a vertex_edge configuration
@@ -421,7 +421,7 @@ OWXFaceLayer ViewEdgeXBuilder::FindPreviousFaceLayer(const OWXFaceLayer &iFaceLa
WXFaceLayer *winner = sameNatureLayers[0];
// check face mark continuity
if (winner->getFace()->GetMark() != iFaceLayer.fl->getFace()->GetMark()) {
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
if (woebegin == winner->getSmoothEdge()->woeb()->twin()) {
return OWXFaceLayer(winner, true);
@@ -434,25 +434,25 @@ OWXFaceLayer ViewEdgeXBuilder::FindPreviousFaceLayer(const OWXFaceLayer &iFaceLa
}
else {
previousFace = dynamic_cast<WXFace *>(iFaceLayer.fl->getFace()->GetBordingFace(woebegin));
- if (0 == previousFace) {
- return OWXFaceLayer(NULL, true);
+ if (nullptr == previousFace) {
+ return OWXFaceLayer(nullptr, true);
}
// if the next face layer has either no smooth edge or no smooth edge of same nature, no next
// face
if (!previousFace->hasSmoothEdges()) {
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
vector<WXFaceLayer *> sameNatureLayers;
previousFace->retrieveSmoothEdgesLayers(iFaceLayer.fl->nature(), sameNatureLayers);
// don't know how to deal with several edges of same nature on a single face
if ((sameNatureLayers.empty()) || (sameNatureLayers.size() != 1)) {
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
WXFaceLayer *winner = sameNatureLayers[0];
// check face mark continuity
if (winner->getFace()->GetMark() != iFaceLayer.fl->getFace()->GetMark()) {
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
if (woebegin == winner->getSmoothEdge()->woeb()->twin()) {
return OWXFaceLayer(winner, true);
@@ -460,7 +460,7 @@ OWXFaceLayer ViewEdgeXBuilder::FindPreviousFaceLayer(const OWXFaceLayer &iFaceLa
return OWXFaceLayer(winner, false);
}
- return OWXFaceLayer(NULL, true);
+ return OWXFaceLayer(nullptr, true);
}
FEdge *ViewEdgeXBuilder::BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer &ifl)
@@ -487,7 +487,8 @@ FEdge *ViewEdgeXBuilder::BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer
Vec3r normal;
// Make the 2 Svertices
- if (feprevious == 0) { // that means that we don't have any vertex already built for that face
+ if (feprevious ==
+ nullptr) { // that means that we don't have any vertex already built for that face
Vec3r A1(woea->GetaVertex()->GetVertex());
Vec3r A2(woea->GetbVertex()->GetVertex());
Vec3r A(A1 + ta * (A2 - A1));
@@ -543,7 +544,7 @@ FEdge *ViewEdgeXBuilder::BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer
fe->setFrsMaterialIndex(ifl.fl->getFace()->frs_materialIndex());
fe->setFace(ifl.fl->getFace());
fe->setFaceMark(ifl.fl->getFace()->GetMark());
- if (feprevious == 0) {
+ if (feprevious == nullptr) {
normal.normalize();
}
fe->setNormal(normal);
@@ -562,10 +563,10 @@ FEdge *ViewEdgeXBuilder::BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer
bool ViewEdgeXBuilder::stopSmoothViewEdge(WXFaceLayer *iFaceLayer)
{
- if (NULL == iFaceLayer) {
+ if (nullptr == iFaceLayer) {
return true;
}
- if (iFaceLayer->userdata == 0) {
+ if (iFaceLayer->userdata == nullptr) {
return false;
}
return true;
@@ -588,7 +589,7 @@ int ViewEdgeXBuilder::retrieveFaceMarks(WXEdge *iEdge)
OWXEdge ViewEdgeXBuilder::FindNextWEdge(const OWXEdge &iEdge)
{
if (Nature::NO_FEATURE == iEdge.e->nature()) {
- return OWXEdge(NULL, true);
+ return OWXEdge(nullptr, true);
}
WVertex *v;
@@ -600,7 +601,7 @@ OWXEdge ViewEdgeXBuilder::FindNextWEdge(const OWXEdge &iEdge)
}
if (((WXVertex *)v)->isFeature()) {
- return 0; /* XXX eeek? NULL? OWXEdge(NULL, true/false)?*/
+ return nullptr; /* XXX eeek? NULL? OWXEdge(NULL, true/false)?*/
}
int faceMarks = retrieveFaceMarks(iEdge.e);
@@ -631,13 +632,13 @@ OWXEdge ViewEdgeXBuilder::FindNextWEdge(const OWXEdge &iEdge)
return OWXEdge(wxe, false);
}
// we did not find:
- return OWXEdge(NULL, true);
+ return OWXEdge(nullptr, true);
}
OWXEdge ViewEdgeXBuilder::FindPreviousWEdge(const OWXEdge &iEdge)
{
if (Nature::NO_FEATURE == iEdge.e->nature()) {
- return OWXEdge(NULL, true);
+ return OWXEdge(nullptr, true);
}
WVertex *v;
@@ -649,7 +650,7 @@ OWXEdge ViewEdgeXBuilder::FindPreviousWEdge(const OWXEdge &iEdge)
}
if (((WXVertex *)v)->isFeature()) {
- return 0;
+ return nullptr;
}
int faceMarks = retrieveFaceMarks(iEdge.e);
@@ -676,7 +677,7 @@ OWXEdge ViewEdgeXBuilder::FindPreviousWEdge(const OWXEdge &iEdge)
return OWXEdge(wxe, false);
}
// we did not find:
- return OWXEdge(NULL, true);
+ return OWXEdge(nullptr, true);
}
FEdge *ViewEdgeXBuilder::BuildSharpFEdge(FEdge *feprevious, const OWXEdge &iwe)
@@ -750,10 +751,10 @@ FEdge *ViewEdgeXBuilder::BuildSharpFEdge(FEdge *feprevious, const OWXEdge &iwe)
bool ViewEdgeXBuilder::stopSharpViewEdge(WXEdge *iEdge)
{
- if (NULL == iEdge) {
+ if (nullptr == iEdge) {
return true;
}
- if (iEdge->userdata == 0) {
+ if (iEdge->userdata == nullptr) {
return false;
}
return true;
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.cpp b/source/blender/freestyle/intern/view_map/ViewMap.cpp
index fa2f95dac72..60d0e45b9fb 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMap.cpp
@@ -37,7 +37,7 @@ namespace Freestyle {
/* */
/**********************************/
-ViewMap *ViewMap::_pInstance = NULL;
+ViewMap *ViewMap::_pInstance = nullptr;
ViewMap::~ViewMap()
{
@@ -103,7 +103,7 @@ const FEdge *ViewMap::getClosestFEdge(real x, real y) const
{
// find the closest of this candidates:
real minDist = DBL_MAX;
- FEdge *winner = NULL;
+ FEdge *winner = nullptr;
for (fedges_container::const_iterator fe = _FEdges.begin(), feend = _FEdges.end(); fe != feend;
fe++) {
Vec2d A((*fe)->vertexA()->point2D()[0], (*fe)->vertexA()->point2D()[1]);
@@ -122,7 +122,7 @@ const ViewEdge *ViewMap::getClosestViewEdge(real x, real y) const
{
// find the closest of this candidates:
real minDist = DBL_MAX;
- FEdge *winner = NULL;
+ FEdge *winner = nullptr;
for (fedges_container::const_iterator fe = _FEdges.begin(), feend = _FEdges.end(); fe != feend;
fe++) {
Vec2d A((*fe)->vertexA()->point2D()[0], (*fe)->vertexA()->point2D()[1]);
@@ -134,7 +134,7 @@ const ViewEdge *ViewMap::getClosestViewEdge(real x, real y) const
}
}
if (!winner) {
- return NULL;
+ return nullptr;
}
return winner->viewedge();
@@ -194,9 +194,9 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
const vector<FEdge *> &fedges = iVertex->fedges();
if (fedges.size() != 2) {
cerr << "ViewMap warning: Can't split the ViewEdge" << endl;
- return NULL;
+ return nullptr;
}
- FEdge *fend(NULL), *fbegin(NULL);
+ FEdge *fend(nullptr), *fbegin(nullptr);
for (vector<FEdge *>::const_iterator fe = fedges.begin(), feend = fedges.end(); fe != feend;
++fe) {
if ((*fe)->vertexB() == iVertex) {
@@ -205,7 +205,7 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
if ((*fe)->vertexA() == iVertex) {
fbegin = (*fe);
}
- if ((fbegin != NULL) && (fend != NULL)) {
+ if ((fbegin != nullptr) && (fend != nullptr)) {
break;
}
}
@@ -213,7 +213,7 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
ViewShape *vshape = ioEdge->viewShape();
vva = new NonTVertex(iVertex);
// if the ViewEdge is a closed loop, we don't create a new VEdge
- if (ioEdge->A() == 0) {
+ if (ioEdge->A() == nullptr) {
// closed loop
ioEdge->setA(vva);
ioEdge->setB(vva);
@@ -225,8 +225,8 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
ioEdge->setFEdgeB(fend);
// Update FEdges
- fend->setNextEdge(NULL);
- fbegin->setPreviousEdge(NULL);
+ fend->setNextEdge(nullptr);
+ fbegin->setPreviousEdge(nullptr);
// update new View Vertex:
vva->AddOutgoingViewEdge(ioEdge);
@@ -246,8 +246,8 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
ioEdge->setFEdgeB(fend);
// Update FEdges
- fend->setNextEdge(NULL);
- fbegin->setPreviousEdge(NULL);
+ fend->setNextEdge(nullptr);
+ fbegin->setPreviousEdge(nullptr);
// update new View Vertex:
vva->AddOutgoingViewEdge(newVEdge);
@@ -711,56 +711,56 @@ ViewEdge::const_fedge_iterator ViewEdge::fedge_iterator_last() const
ViewEdge::fedge_iterator ViewEdge::fedge_iterator_end()
{
- return fedge_iterator(0, this->_FEdgeB);
+ return fedge_iterator(nullptr, this->_FEdgeB);
}
ViewEdge::const_fedge_iterator ViewEdge::fedge_iterator_end() const
{
- return const_fedge_iterator(0, this->_FEdgeB);
+ return const_fedge_iterator(nullptr, this->_FEdgeB);
}
//! embedding vertex iterator
ViewEdge::const_vertex_iterator ViewEdge::vertices_begin() const
{
- return const_vertex_iterator(this->_FEdgeA->vertexA(), 0, _FEdgeA);
+ return const_vertex_iterator(this->_FEdgeA->vertexA(), nullptr, _FEdgeA);
}
ViewEdge::vertex_iterator ViewEdge::vertices_begin()
{
- return vertex_iterator(this->_FEdgeA->vertexA(), 0, _FEdgeA);
+ return vertex_iterator(this->_FEdgeA->vertexA(), nullptr, _FEdgeA);
}
ViewEdge::const_vertex_iterator ViewEdge::vertices_last() const
{
- return const_vertex_iterator(this->_FEdgeB->vertexB(), _FEdgeB, 0);
+ return const_vertex_iterator(this->_FEdgeB->vertexB(), _FEdgeB, nullptr);
}
ViewEdge::vertex_iterator ViewEdge::vertices_last()
{
- return vertex_iterator(this->_FEdgeB->vertexB(), _FEdgeB, 0);
+ return vertex_iterator(this->_FEdgeB->vertexB(), _FEdgeB, nullptr);
}
ViewEdge::const_vertex_iterator ViewEdge::vertices_end() const
{
- return const_vertex_iterator(0, _FEdgeB, 0);
+ return const_vertex_iterator(nullptr, _FEdgeB, nullptr);
}
ViewEdge::vertex_iterator ViewEdge::vertices_end()
{
- return vertex_iterator(0, _FEdgeB, 0);
+ return vertex_iterator(nullptr, _FEdgeB, nullptr);
}
Interface0DIterator ViewEdge::verticesBegin()
{
Interface0DIterator ret(new ViewEdgeInternal::SVertexIterator(
- this->_FEdgeA->vertexA(), this->_FEdgeA->vertexA(), NULL, _FEdgeA, 0.0f));
+ this->_FEdgeA->vertexA(), this->_FEdgeA->vertexA(), nullptr, _FEdgeA, 0.0f));
return ret;
}
Interface0DIterator ViewEdge::verticesEnd()
{
Interface0DIterator ret(new ViewEdgeInternal::SVertexIterator(
- NULL, this->_FEdgeA->vertexA(), _FEdgeB, NULL, getLength2D()));
+ nullptr, this->_FEdgeA->vertexA(), _FEdgeB, nullptr, getLength2D()));
return ret;
}
@@ -795,7 +795,7 @@ ViewShape::~ViewShape()
if (_SShape) {
delete _SShape;
- _SShape = NULL;
+ _SShape = nullptr;
}
}
@@ -836,7 +836,7 @@ void ViewEdge::UpdateFEdges()
do {
currentEdge->setViewEdge(this);
currentEdge = currentEdge->nextEdge();
- } while ((currentEdge != NULL) && (currentEdge != _FEdgeB));
+ } while (!ELEM(currentEdge, NULL, _FEdgeB));
// last one
_FEdgeB->setViewEdge(this);
}
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
index a0989c52e4e..de30ee0460a 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
@@ -61,7 +61,7 @@ static void findOccludee(FEdge *fe,
Vec3r &edgeDir,
vector<WVertex *> &faceVertices)
{
- WFace *face = NULL;
+ WFace *face = nullptr;
if (fe->isSmooth()) {
FEdgeSmooth *fes = dynamic_cast<FEdgeSmooth *>(fe);
face = (WFace *)fes->face();
@@ -71,7 +71,7 @@ static void findOccludee(FEdge *fe,
WVertex::incoming_edge_iterator ie;
- *oaWFace = NULL;
+ *oaWFace = nullptr;
if (((fe)->getNature() & Nature::SILHOUETTE) || ((fe)->getNature() & Nature::BORDER)) {
// we cast a ray from A in the same direction but looking behind
Vec3r v(-u[0], -u[1], -u[2]);
@@ -90,7 +90,7 @@ static void findOccludee(FEdge *fe,
real d = -((p->getVertices())[0] * p->getNormal());
real t, t_u, t_v;
- if (0 != face) {
+ if (nullptr != face) {
skipFace = false;
if (face == oface) {
@@ -110,7 +110,7 @@ static void findOccludee(FEdge *fe,
WVertex::incoming_edge_iterator iebegin = (*fv)->incoming_edges_begin();
WVertex::incoming_edge_iterator ieend = (*fv)->incoming_edges_end();
for (ie = iebegin; ie != ieend; ++ie) {
- if ((*ie) == 0) {
+ if ((*ie) == nullptr) {
continue;
}
@@ -172,7 +172,7 @@ static void findOccludee(FEdge *fe,
}
if (noIntersection) {
- *oaWFace = NULL;
+ *oaWFace = nullptr;
}
}
}
@@ -198,7 +198,7 @@ static void findOccludee(FEdge *fe, G &grid, real epsilon, ViewEdge * /*ve*/, WF
vector<WVertex *> faceVertices;
- WFace *face = NULL;
+ WFace *face = nullptr;
if (fe->isSmooth()) {
FEdgeSmooth *fes = dynamic_cast<FEdgeSmooth *>(fe);
face = (WFace *)fes->face();
@@ -245,7 +245,7 @@ static int computeVisibility(ViewMap *viewMap,
real raylength = u.norm();
u.normalize();
- WFace *face = NULL;
+ WFace *face = nullptr;
if (fe->isSmooth()) {
FEdgeSmooth *fes = dynamic_cast<FEdgeSmooth *>(fe);
face = (WFace *)fes->face();
@@ -330,7 +330,7 @@ static int computeVisibility(ViewMap *viewMap,
WVertex::incoming_edge_iterator iebegin = (*fv)->incoming_edges_begin();
WVertex::incoming_edge_iterator ieend = (*fv)->incoming_edges_end();
for (ie = iebegin; ie != ieend; ++ie) {
- if ((*ie) == 0) {
+ if ((*ie) == nullptr) {
continue;
}
@@ -400,7 +400,7 @@ static int computeVisibility(ViewMap *viewMap,
cout << "\t\tIs occluder" << endl;
}
#endif
- if (foundOccluders != NULL) {
+ if (foundOccluders != nullptr) {
ViewShape *vshape = viewMap->viewShape(oface->GetVertex(0)->shape()->GetId());
foundOccluders->insert(vshape);
}
@@ -443,7 +443,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
FEdge *fe, *festart;
int nSamples = 0;
vector<WFace *> wFaces;
- WFace *wFace = NULL;
+ WFace *wFace = nullptr;
unsigned cnt = 0;
unsigned cntStep = (unsigned)ceil(0.01f * vedges.size());
unsigned tmpQI = 0;
@@ -472,7 +472,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
if (!(*ve)->isInImage()) {
// This view edge has been proscenium culled
(*ve)->setQI(255);
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
#if LOGGING
if (_global.debug & G_DEBUG_FREESTYLE) {
cout << "\tCulled." << endl;
@@ -486,7 +486,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
fe = (*ve)->fedgeA();
qiMajority = 0;
do {
- if (fe != NULL && fe->isInImage()) {
+ if (fe != nullptr && fe->isInImage()) {
qiMajority++;
}
fe = fe->nextEdge();
@@ -501,7 +501,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
// We can recover from this error:
// Treat this edge as fully visible with no occludee
(*ve)->setQI(0);
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
continue;
}
@@ -566,7 +566,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
if (wFace) {
vector<Vec3r> vertices;
for (int i = 0, numEdges = wFace->numberOfEdges(); i < numEdges; ++i) {
- vertices.push_back(Vec3r(wFace->GetVertex(i)->GetVertex()));
+ vertices.emplace_back(wFace->GetVertex(i)->GetVertex());
}
Polygon3r poly(vertices, wFace->GetNormal());
poly.userdata = (void *)wFace;
@@ -622,7 +622,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
// occludee --
if (!wFaces.empty()) {
if (wFaces.size() <= (float)nSamples / 2.0f) {
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
}
else {
ViewShape *vshape = ioViewMap->viewShape(
@@ -652,7 +652,7 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
FEdge *fe, *festart;
int nSamples = 0;
vector<WFace *> wFaces;
- WFace *wFace = NULL;
+ WFace *wFace = nullptr;
unsigned tmpQI = 0;
unsigned qiClasses[256];
unsigned maxIndex, maxCard;
@@ -670,7 +670,7 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
if (!(*ve)->isInImage()) {
// This view edge has been proscenium culled
(*ve)->setQI(255);
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
#if LOGGING
if (_global.debug & G_DEBUG_FREESTYLE) {
cout << "\tCulled." << endl;
@@ -684,7 +684,7 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
fe = (*ve)->fedgeA();
qiMajority = 0;
do {
- if (fe != NULL && fe->isInImage()) {
+ if (fe != nullptr && fe->isInImage()) {
qiMajority++;
}
fe = fe->nextEdge();
@@ -699,7 +699,7 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
// We can recover from this error:
// Treat this edge as fully visible with no occludee
(*ve)->setQI(0);
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
continue;
}
@@ -721,7 +721,7 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
fe = (*ve)->fedgeA();
do {
- if (fe == NULL || !fe->isInImage()) {
+ if (fe == nullptr || !fe->isInImage()) {
fe = fe->nextEdge();
continue;
}
@@ -764,7 +764,7 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
if (wFace) {
vector<Vec3r> vertices;
for (int i = 0, numEdges = wFace->numberOfEdges(); i < numEdges; ++i) {
- vertices.push_back(Vec3r(wFace->GetVertex(i)->GetVertex()));
+ vertices.emplace_back(wFace->GetVertex(i)->GetVertex());
}
Polygon3r poly(vertices, wFace->GetNormal());
poly.userdata = (void *)wFace;
@@ -811,7 +811,7 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
// occludee --
if (!wFaces.empty()) {
if (wFaces.size() <= (float)nSamples / 2.0f) {
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
}
else {
ViewShape *vshape = ioViewMap->viewShape(
@@ -832,7 +832,7 @@ static void computeFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
FEdge *fe, *festart;
unsigned nSamples = 0;
vector<WFace *> wFaces;
- WFace *wFace = NULL;
+ WFace *wFace = nullptr;
unsigned tmpQI = 0;
unsigned qiClasses[256];
unsigned maxIndex, maxCard;
@@ -843,7 +843,7 @@ static void computeFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
if (!(*ve)->isInImage()) {
// This view edge has been proscenium culled
(*ve)->setQI(255);
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
continue;
}
@@ -870,7 +870,7 @@ static void computeFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
// We can recover from this error:
// Treat this edge as fully visible with no occludee
(*ve)->setQI(0);
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
continue;
}
@@ -918,7 +918,7 @@ static void computeFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
if (wFace) {
vector<Vec3r> vertices;
for (int i = 0, numEdges = wFace->numberOfEdges(); i < numEdges; ++i) {
- vertices.push_back(Vec3r(wFace->GetVertex(i)->GetVertex()));
+ vertices.emplace_back(wFace->GetVertex(i)->GetVertex());
}
Polygon3r poly(vertices, wFace->GetNormal());
poly.userdata = (void *)wFace;
@@ -945,7 +945,7 @@ static void computeFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
// occludee --
if (!wFaces.empty()) {
if (wFaces.size() < nSamples / 2) {
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
}
else {
ViewShape *vshape = ioViewMap->viewShape(
@@ -965,14 +965,14 @@ static void computeVeryFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
FEdge *fe;
unsigned qi = 0;
- WFace *wFace = 0;
+ WFace *wFace = nullptr;
for (vector<ViewEdge *>::iterator ve = vedges.begin(), veend = vedges.end(); ve != veend; ve++) {
// Find an edge to test
if (!(*ve)->isInImage()) {
// This view edge has been proscenium culled
(*ve)->setQI(255);
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
continue;
}
fe = (*ve)->fedgeA();
@@ -992,7 +992,7 @@ static void computeVeryFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
// We can recover from this error:
// Treat this edge as fully visible with no occludee
qi = 0;
- wFace = NULL;
+ wFace = nullptr;
}
else {
qi = computeVisibility<G, I>(ioViewMap, fe, grid, epsilon, *ve, &wFace, NULL);
@@ -1002,7 +1002,7 @@ static void computeVeryFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
if (wFace) {
vector<Vec3r> vertices;
for (int i = 0, numEdges = wFace->numberOfEdges(); i < numEdges; ++i) {
- vertices.push_back(Vec3r(wFace->GetVertex(i)->GetVertex()));
+ vertices.emplace_back(wFace->GetVertex(i)->GetVertex());
}
Polygon3r poly(vertices, wFace->GetNormal());
poly.userdata = (void *)wFace;
@@ -1011,7 +1011,7 @@ static void computeVeryFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
(*ve)->setaShape(vshape);
}
else {
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
}
(*ve)->setQI(qi);
}
@@ -1138,7 +1138,7 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
// For each feature edge, while bestOccluderTarget not found and view edge not visible
bool bestOccluderTargetFound = false;
- FEdge *bestOccluderTarget = NULL;
+ FEdge *bestOccluderTarget = nullptr;
real bestOccluderDistance = 0.0;
FEdge *festart = (*ve)->fedgeA();
FEdge *fe = festart;
@@ -1164,7 +1164,7 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
else {
real d = distance2D(fe->center2d(), prosceniumOrigin);
// If center point is closer to viewport origin than current target
- if (bestOccluderTarget == NULL || d < bestOccluderDistance) {
+ if (bestOccluderTarget == nullptr || d < bestOccluderDistance) {
// Then store as bestOccluderTarget
bestOccluderDistance = d;
bestOccluderTarget = fe;
@@ -1189,7 +1189,7 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
// If bestOccluderTarget was not found inside the occluder proscenium, we need to expand the
// occluder proscenium to include it.
- if ((*ve)->isInImage() && bestOccluderTarget != NULL && !bestOccluderTargetFound) {
+ if ((*ve)->isInImage() && bestOccluderTarget != nullptr && !bestOccluderTargetFound) {
// Expand occluder proscenium to enclose bestOccluderTarget
Vec3r point = bestOccluderTarget->center2d();
if (point[0] < occluderProscenium[0]) {
@@ -1337,7 +1337,7 @@ void ViewMapBuilder::computeCusps(ViewMap *ioViewMap)
first = false;
}
// If we're in a positive part, we need a stronger negative value to change
- NonTVertex *cusp = NULL;
+ NonTVertex *cusp = nullptr;
if (positive) {
if (((crossP) * (viewvector)) < -0.1) {
// state changes
@@ -1381,17 +1381,17 @@ void ViewMapBuilder::ComputeCumulativeVisibility(ViewMap *ioViewMap,
AutoPtr<OccluderSource> source;
if (_orthographicProjection) {
- transform.reset(new BoxGrid::Transform);
+ transform = std::make_unique<BoxGrid::Transform>();
}
else {
- transform.reset(new SphericalGrid::Transform);
+ transform = std::make_unique<SphericalGrid::Transform>();
}
if (cull) {
- source.reset(new CulledOccluderSource(*transform, we, *ioViewMap, true));
+ source = std::make_unique<CulledOccluderSource>(*transform, we, *ioViewMap, true);
}
else {
- source.reset(new OccluderSource(*transform, we));
+ source = std::make_unique<OccluderSource>(*transform, we);
}
AutoPtr<GridDensityProvider> density(factory.newGridDensityProvider(*source, bbox, *transform));
@@ -1419,17 +1419,17 @@ void ViewMapBuilder::ComputeDetailedVisibility(ViewMap *ioViewMap,
AutoPtr<OccluderSource> source;
if (_orthographicProjection) {
- transform.reset(new BoxGrid::Transform);
+ transform = std::make_unique<BoxGrid::Transform>();
}
else {
- transform.reset(new SphericalGrid::Transform);
+ transform = std::make_unique<SphericalGrid::Transform>();
}
if (cull) {
- source.reset(new CulledOccluderSource(*transform, we, *ioViewMap, true));
+ source = std::make_unique<CulledOccluderSource>(*transform, we, *ioViewMap, true);
}
else {
- source.reset(new OccluderSource(*transform, we));
+ source = std::make_unique<OccluderSource>(*transform, we);
}
AutoPtr<GridDensityProvider> density(factory.newGridDensityProvider(*source, bbox, *transform));
@@ -1556,7 +1556,7 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
unsigned vEdgesSize = vedges.size();
unsigned fEdgesSize = ioViewMap->FEdges().size();
- if (_pProgressBar != NULL && fEdgesSize > gProgressBarMinSize) {
+ if (_pProgressBar != nullptr && fEdgesSize > gProgressBarMinSize) {
unsigned progressBarSteps = min(gProgressBarMaxSteps, vEdgesSize);
progressBarStep = vEdgesSize / progressBarSteps;
_pProgressBar->reset();
@@ -1570,7 +1570,7 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
FEdge *fe, *festart;
int nSamples = 0;
vector<Polygon3r *> aFaces;
- Polygon3r *aFace = NULL;
+ Polygon3r *aFace = nullptr;
unsigned tmpQI = 0;
unsigned qiClasses[256];
unsigned maxIndex, maxCard;
@@ -1683,7 +1683,7 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
// occludee --
if (!aFaces.empty()) {
if (aFaces.size() <= (float)nSamples / 2.0f) {
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
}
else {
vector<Polygon3r *>::iterator p = aFaces.begin();
@@ -1713,7 +1713,7 @@ void ViewMapBuilder::ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real ep
unsigned vEdgesSize = vedges.size();
unsigned fEdgesSize = ioViewMap->FEdges().size();
- if (_pProgressBar != NULL && fEdgesSize > gProgressBarMinSize) {
+ if (_pProgressBar != nullptr && fEdgesSize > gProgressBarMinSize) {
unsigned progressBarSteps = min(gProgressBarMaxSteps, vEdgesSize);
progressBarStep = vEdgesSize / progressBarSteps;
_pProgressBar->reset();
@@ -1727,7 +1727,7 @@ void ViewMapBuilder::ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real ep
FEdge *fe, *festart;
unsigned nSamples = 0;
vector<Polygon3r *> aFaces;
- Polygon3r *aFace = NULL;
+ Polygon3r *aFace = nullptr;
unsigned tmpQI = 0;
unsigned qiClasses[256];
unsigned maxIndex, maxCard;
@@ -1801,7 +1801,7 @@ void ViewMapBuilder::ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real ep
if (!aFaces.empty()) {
if (aFaces.size() < nSamples / 2) {
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
}
else {
vector<Polygon3r *>::iterator p = aFaces.begin();
@@ -1846,7 +1846,7 @@ void ViewMapBuilder::ComputeVeryFastRayCastingVisibility(ViewMap *ioViewMap, rea
unsigned vEdgesSize = vedges.size();
unsigned fEdgesSize = ioViewMap->FEdges().size();
- if (_pProgressBar != NULL && fEdgesSize > gProgressBarMinSize) {
+ if (_pProgressBar != nullptr && fEdgesSize > gProgressBarMinSize) {
unsigned progressBarSteps = min(gProgressBarMaxSteps, vEdgesSize);
progressBarStep = vEdgesSize / progressBarSteps;
_pProgressBar->reset();
@@ -1859,7 +1859,7 @@ void ViewMapBuilder::ComputeVeryFastRayCastingVisibility(ViewMap *ioViewMap, rea
unsigned counter = progressBarStep;
FEdge *fe;
unsigned qi = 0;
- Polygon3r *aFace = NULL;
+ Polygon3r *aFace = nullptr;
static unsigned timestamp = 1;
for (vector<ViewEdge *>::iterator ve = vedges.begin(), veend = vedges.end(); ve != veend; ve++) {
if (_pRenderMonitor && _pRenderMonitor->testBreak()) {
@@ -1877,7 +1877,7 @@ void ViewMapBuilder::ComputeVeryFastRayCastingVisibility(ViewMap *ioViewMap, rea
(*ve)->setaShape(vshape);
}
else {
- (*ve)->setaShape(0);
+ (*ve)->setaShape(nullptr);
}
(*ve)->setQI(qi);
@@ -1903,7 +1903,7 @@ void ViewMapBuilder::FindOccludee(FEdge *fe,
Vec3r &edgeDir,
vector<WVertex *> &faceVertices)
{
- WFace *face = NULL;
+ WFace *face = nullptr;
if (fe->isSmooth()) {
FEdgeSmooth *fes = dynamic_cast<FEdgeSmooth *>(fe);
face = (WFace *)fes->face();
@@ -1915,7 +1915,7 @@ void ViewMapBuilder::FindOccludee(FEdge *fe,
WVertex::incoming_edge_iterator ie;
OccludersSet::iterator p, pend;
- *oaPolygon = NULL;
+ *oaPolygon = nullptr;
if (((fe)->getNature() & Nature::SILHOUETTE) || ((fe)->getNature() & Nature::BORDER)) {
occluders.clear();
// we cast a ray from A in the same direction but looking behind
@@ -1955,7 +1955,7 @@ void ViewMapBuilder::FindOccludee(FEdge *fe,
WVertex::incoming_edge_iterator iebegin = (*fv)->incoming_edges_begin();
WVertex::incoming_edge_iterator ieend = (*fv)->incoming_edges_end();
for (ie = iebegin; ie != ieend; ++ie) {
- if ((*ie) == 0) {
+ if ((*ie) == nullptr) {
continue;
}
@@ -1994,7 +1994,7 @@ void ViewMapBuilder::FindOccludee(FEdge *fe,
}
if (noIntersection) {
- *oaPolygon = NULL;
+ *oaPolygon = nullptr;
}
}
}
@@ -2026,7 +2026,7 @@ void ViewMapBuilder::FindOccludee(
vector<WVertex *> faceVertices;
- WFace *face = NULL;
+ WFace *face = nullptr;
if (fe->isSmooth()) {
FEdgeSmooth *fes = dynamic_cast<FEdgeSmooth *>(fe);
face = (WFace *)fes->face();
@@ -2101,7 +2101,7 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe,
iGrid->castRay(center, vp, occluders, timestamp);
- WFace *face = NULL;
+ WFace *face = nullptr;
if (fe->isSmooth()) {
FEdgeSmooth *fes = dynamic_cast<FEdgeSmooth *>(fe);
face = (WFace *)fes->face();
@@ -2168,7 +2168,7 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe,
WVertex::incoming_edge_iterator iebegin = (*fv)->incoming_edges_begin();
WVertex::incoming_edge_iterator ieend = (*fv)->incoming_edges_end();
for (ie = iebegin; ie != ieend; ++ie) {
- if ((*ie) == 0) {
+ if ((*ie) == nullptr) {
continue;
}
@@ -2322,7 +2322,7 @@ struct less_Intersection {
};
struct silhouette_binary_rule : public binary_rule<segment, segment> {
- silhouette_binary_rule() : binary_rule<segment, segment>()
+ silhouette_binary_rule()
{
}
@@ -2358,7 +2358,7 @@ void ViewMapBuilder::ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsi
#endif
unsigned progressBarStep = 0;
- if (_pProgressBar != NULL && fEdgesSize > gProgressBarMinSize) {
+ if (_pProgressBar != nullptr && fEdgesSize > gProgressBarMinSize) {
unsigned progressBarSteps = min(gProgressBarMaxSteps, sVerticesSize);
progressBarStep = sVerticesSize / progressBarSteps;
_pProgressBar->reset();
@@ -2428,7 +2428,7 @@ void ViewMapBuilder::ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsi
// reset userdata:
for (fe = ioEdges.begin(), fend = ioEdges.end(); fe != fend; fe++) {
- (*fe)->userdata = NULL;
+ (*fe)->userdata = nullptr;
}
// list containing the new edges resulting from splitting operations.
@@ -2561,7 +2561,7 @@ void ViewMapBuilder::ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsi
// reset userdata:
for (fe = ioEdges.begin(), fend = ioEdges.end(); fe != fend; fe++) {
- (*fe)->userdata = NULL;
+ (*fe)->userdata = nullptr;
}
// delete segments
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
index 3cbf42ed388..aed5d6b5adc 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
@@ -50,9 +50,7 @@
} \
(void)0
-namespace Freestyle {
-
-namespace ViewMapIO {
+namespace Freestyle::ViewMapIO {
namespace Internal {
@@ -228,8 +226,8 @@ static int load(istream &in, FEdge *fe)
bool b;
- FEdgeSmooth *fesmooth = NULL;
- FEdgeSharp *fesharp = NULL;
+ FEdgeSmooth *fesmooth = nullptr;
+ FEdgeSharp *fesharp = nullptr;
if (fe->isSmooth()) {
fesmooth = dynamic_cast<FEdgeSmooth *>(fe);
}
@@ -1239,25 +1237,25 @@ int save(ostream &out, ViewMap *vm, ProgressBar *pb)
for (vector<ViewShape *>::const_iterator j0 = vm->ViewShapes().begin();
j0 != vm->ViewShapes().end();
j0++) {
- (*j0)->userdata = NULL;
- (*j0)->sshape()->userdata = NULL;
+ (*j0)->userdata = nullptr;
+ (*j0)->sshape()->userdata = nullptr;
}
for (vector<FEdge *>::const_iterator j1 = vm->FEdges().begin(); j1 != vm->FEdges().end(); j1++) {
- (*j1)->userdata = NULL;
+ (*j1)->userdata = nullptr;
}
for (vector<SVertex *>::const_iterator j2 = vm->SVertices().begin(); j2 != vm->SVertices().end();
j2++) {
- (*j2)->userdata = NULL;
+ (*j2)->userdata = nullptr;
}
for (vector<ViewEdge *>::const_iterator j3 = vm->ViewEdges().begin();
j3 != vm->ViewEdges().end();
j3++) {
- (*j3)->userdata = NULL;
+ (*j3)->userdata = nullptr;
}
for (vector<ViewVertex *>::const_iterator j4 = vm->ViewVertices().begin();
j4 != vm->ViewVertices().end();
j4++) {
- (*j4)->userdata = NULL;
+ (*j4)->userdata = nullptr;
}
SET_PROGRESS(6);
@@ -1307,6 +1305,4 @@ string getModelsPath()
} // namespace Options
-} // End of namespace ViewMapIO
-
-} /* namespace Freestyle */
+} // namespace Freestyle::ViewMapIO
diff --git a/source/blender/freestyle/intern/view_map/ViewMapTesselator.cpp b/source/blender/freestyle/intern/view_map/ViewMapTesselator.cpp
index a1f76c120fb..9b87bf762fa 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapTesselator.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapTesselator.cpp
@@ -26,7 +26,7 @@ namespace Freestyle {
NodeGroup *ViewMapTesselator::Tesselate(ViewMap *iViewMap)
{
if (iViewMap->ViewEdges().empty()) {
- return NULL;
+ return nullptr;
}
const vector<ViewEdge *> &viewedges = iViewMap->ViewEdges();
@@ -35,7 +35,7 @@ NodeGroup *ViewMapTesselator::Tesselate(ViewMap *iViewMap)
NodeGroup *ViewMapTesselator::Tesselate(WShape *UNUSED(iWShape))
{
- return NULL;
+ return nullptr;
}
} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.cpp b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
index c8805c144e3..0811fe336b7 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
@@ -63,7 +63,7 @@ WVertex::WVertex(WVertex &iBrother)
_Shape = iBrother._Shape;
_Smooth = iBrother._Smooth;
_Border = iBrother._Border;
- userdata = NULL;
+ userdata = nullptr;
iBrother.userdata = new vertexdata;
((vertexdata *)(iBrother.userdata))->_copy = this;
}
@@ -84,12 +84,12 @@ void WVertex::incoming_edge_iterator::increment()
WOEdge *twin = _current->twin();
if (!twin) {
// we reached a hole
- _current = 0;
+ _current = nullptr;
return;
}
WOEdge *next = twin->getPrevOnFace();
if (next == _begin) {
- next = NULL;
+ next = nullptr;
}
_current = next;
}
@@ -98,7 +98,7 @@ WFace *WVertex::face_iterator::operator*()
{
WOEdge *woedge = *_edge_it;
if (!woedge) {
- return NULL;
+ return nullptr;
}
return (woedge)->GetbFace();
}
@@ -163,7 +163,7 @@ WVertex::incoming_edge_iterator WVertex::incoming_edges_end()
else {
begin = _EdgeList.front()->GetbOEdge();
}
- return incoming_edge_iterator(this, begin, 0);
+ return incoming_edge_iterator(this, begin, nullptr);
}
#if 0
WOEdge **WVertex::incoming_edge_iterator::operator->()
@@ -194,7 +194,7 @@ WOEdge::WOEdge(WOEdge &iBrother)
_paFace = iBrother.GetaFace();
_pbFace = iBrother.GetbFace();
_pOwner = iBrother.GetOwner();
- userdata = NULL;
+ userdata = nullptr;
iBrother.userdata = new oedgedata;
((oedgedata *)(iBrother.userdata))->_copy = this;
@@ -228,11 +228,11 @@ WOEdge *WOEdge::getPrevOnFace()
WEdge::WEdge(WEdge &iBrother)
{
- _paOEdge = NULL;
- _pbOEdge = NULL;
+ _paOEdge = nullptr;
+ _pbOEdge = nullptr;
WOEdge *aoedge = iBrother.GetaOEdge();
WOEdge *boedge = iBrother.GetbOEdge();
- userdata = NULL;
+ userdata = nullptr;
if (aoedge) {
//_paOEdge = new WOEdge(*aoedge);
@@ -272,7 +272,7 @@ WFace::WFace(WFace &iBrother)
_Id = iBrother.GetId();
_FrsMaterialIndex = iBrother._FrsMaterialIndex;
_Mark = iBrother._Mark;
- userdata = NULL;
+ userdata = nullptr;
iBrother.userdata = new facedata;
((facedata *)(iBrother.userdata))->_copy = this;
}
@@ -332,7 +332,7 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
// checks whether this edge already exists or not
// If it exists, it points outward v2
bool exist = false;
- WOEdge *pInvertEdge = NULL; // The inverted edge if it exists
+ WOEdge *pInvertEdge = nullptr; // The inverted edge if it exists
vector<WEdge *> &v2Edges = v2->GetEdges();
vector<WEdge *>::iterator it;
for (it = v2Edges.begin(); it != v2Edges.end(); it++) {
@@ -394,7 +394,7 @@ bool WFace::getOppositeEdge(const WVertex *v, WOEdge *&e)
}
vector<WOEdge *>::iterator it;
- e = NULL;
+ e = nullptr;
for (it = _OEdgeList.begin(); it != _OEdgeList.end(); it++) {
if ((*it)->GetaVertex() == v) {
e = *it;
@@ -403,7 +403,7 @@ bool WFace::getOppositeEdge(const WVertex *v, WOEdge *&e)
if (!e) {
return false;
}
- e = NULL;
+ e = nullptr;
for (it = _OEdgeList.begin(); it != _OEdgeList.end(); it++) {
if (((*it)->GetaVertex() != v) && ((*it)->GetbVertex() != v)) {
e = *it;
@@ -449,7 +449,7 @@ WOEdge *WFace::GetPrevOEdge(WOEdge *iOEdge)
return prev;
}
- return NULL;
+ return nullptr;
}
WShape *WFace::getShape()
@@ -570,22 +570,22 @@ WShape::WShape(WShape &iBrother)
vend = iBrother.getVertexList().end();
for (v = iBrother.getVertexList().begin(); v != vend; ++v) {
delete (vertexdata *)((*v)->userdata);
- (*v)->userdata = NULL;
+ (*v)->userdata = nullptr;
}
// Edges and OEdges:
eend = iBrother.getEdgeList().end();
for (e = iBrother.getEdgeList().begin(); e != eend; ++e) {
delete (edgedata *)((*e)->userdata);
- (*e)->userdata = NULL;
+ (*e)->userdata = nullptr;
// OEdge a:
delete (oedgedata *)((*e)->GetaOEdge()->userdata);
- (*e)->GetaOEdge()->userdata = NULL;
+ (*e)->GetaOEdge()->userdata = nullptr;
// OEdge b:
WOEdge *oedgeb = (*e)->GetbOEdge();
if (oedgeb) {
delete (oedgedata *)(oedgeb->userdata);
- oedgeb->userdata = NULL;
+ oedgeb->userdata = nullptr;
}
}
@@ -593,7 +593,7 @@ WShape::WShape(WShape &iBrother)
fend = iBrother.GetFaceList().end();
for (f = iBrother.GetFaceList().begin(); f != fend; ++f) {
delete (facedata *)((*f)->userdata);
- (*f)->userdata = NULL;
+ (*f)->userdata = nullptr;
}
}
@@ -621,7 +621,7 @@ WFace *WShape::MakeFace(vector<WVertex *> &iVertexList,
WFace *face = MakeFace(iVertexList, iFaceEdgeMarksList, iMaterial);
if (!face) {
- return NULL;
+ return nullptr;
}
// set the list of per-vertex normals
@@ -649,7 +649,7 @@ WFace *WShape::MakeFace(vector<WVertex *> &iVertexList,
if ((iVertexList[0] == iVertexList[1]) || (iVertexList[0] == iVertexList[2]) ||
(iVertexList[2] == iVertexList[1])) {
cerr << "Warning: degenerated triangle detected, correcting" << endl;
- return NULL;
+ return nullptr;
}
}
@@ -695,7 +695,7 @@ WFace *WShape::MakeFace(vector<WVertex *> &iVertexList,
}
if (!oedge) {
- return NULL;
+ return nullptr;
}
WEdge *edge = oedge->GetOwner();
diff --git a/source/blender/freestyle/intern/winged_edge/WFillGrid.cpp b/source/blender/freestyle/intern/winged_edge/WFillGrid.cpp
index f54b54f5a3a..9898255aaa7 100644
--- a/source/blender/freestyle/intern/winged_edge/WFillGrid.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WFillGrid.cpp
@@ -42,7 +42,7 @@ void WFillGrid::fillGrid()
(*f)->RetrieveVertexList(fvertices);
for (vector<WVertex *>::const_iterator wv = fvertices.begin(); wv != fvertices.end(); ++wv) {
- vectors.push_back(Vec3r((*wv)->GetVertex()));
+ vectors.emplace_back((*wv)->GetVertex());
}
// occluder will be deleted by the grid
diff --git a/source/blender/freestyle/intern/winged_edge/WSFillGrid.cpp b/source/blender/freestyle/intern/winged_edge/WSFillGrid.cpp
index e1cb1c29f63..3ca021ec2c6 100644
--- a/source/blender/freestyle/intern/winged_edge/WSFillGrid.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WSFillGrid.cpp
@@ -42,7 +42,7 @@ void WSFillGrid::fillGrid()
(*f)->RetrieveVertexList(fvertices);
for (vector<WVertex *>::const_iterator wv = fvertices.begin(); wv != fvertices.end(); ++wv) {
- vectors.push_back(Vec3r((*wv)->GetVertex()));
+ vectors.emplace_back((*wv)->GetVertex());
}
// occluder will be deleted by the grid
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
index f11f30130c8..bedf4192d64 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
@@ -74,13 +74,13 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
return _pSmoothEdge;
}
float ta, tb;
- WOEdge *woea(0), *woeb(0);
+ WOEdge *woea(nullptr), *woeb(nullptr);
bool ok = false;
vector<int> cuspEdgesIndices;
int indexStart, indexEnd;
unsigned nedges = _pWXFace->numberOfEdges();
if (_nNullDotP == nedges) {
- _pSmoothEdge = NULL;
+ _pSmoothEdge = nullptr;
return _pSmoothEdge;
}
if ((_nPosDotP != 0) && (_nPosDotP != _DotP.size()) && (_nNullDotP == 0)) {
@@ -89,7 +89,7 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
// We retrieve the 2 edges for which we have opposite signs for each extremity
RetrieveCuspEdgesIndices(cuspEdgesIndices);
if (cuspEdgesIndices.size() != 2) { // we necessarly have 2 cusp edges
- return 0;
+ return nullptr;
}
// let us determine which cusp edge corresponds to the starting:
@@ -119,8 +119,8 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
else if (_nNullDotP == 1) {
// that means that we have exactly one of the 2 extremities of our silhouette edge is a vertex
// of the mesh
- if ((_nPosDotP == 2) || (_nPosDotP == 0)) {
- _pSmoothEdge = NULL;
+ if (ELEM(_nPosDotP, 2, 0)) {
+ _pSmoothEdge = nullptr;
return _pSmoothEdge;
}
RetrieveCuspEdgesIndices(cuspEdgesIndices);
@@ -129,8 +129,8 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
if (G.debug & G_DEBUG_FREESTYLE) {
cout << "Warning in BuildSmoothEdge: weird WXFace configuration" << endl;
}
- _pSmoothEdge = NULL;
- return NULL;
+ _pSmoothEdge = nullptr;
+ return nullptr;
}
unsigned index0 = Get0VertexIndex(); // retrieve the 0 vertex index
unsigned nedges = _pWXFace->numberOfEdges();
@@ -275,7 +275,7 @@ WFace *WXShape::MakeFace(vector<WVertex *> &iVertexList,
{
WFace *face = WShape::MakeFace(iVertexList, iFaceEdgeMarksList, iMaterialIndex);
if (!face) {
- return NULL;
+ return nullptr;
}
Vec3f center;
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
index c989d77a730..d9d6a6675c2 100644
--- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
@@ -69,7 +69,7 @@ void WingedEdgeBuilder::visitNodeTransformAfter(NodeTransform &UNUSED(transform)
delete _current_matrix;
if (_matrices_stack.empty()) {
- _current_matrix = NULL;
+ _current_matrix = nullptr;
return;
}
@@ -133,12 +133,12 @@ bool WingedEdgeBuilder::buildWShape(WShape &shape, IndexedFaceSet &ifs)
const unsigned int *vindices = ifs.vindices();
const unsigned int *nindices = ifs.nindices();
- const unsigned int *tindices = NULL;
+ const unsigned int *tindices = nullptr;
if (ifs.tsize()) {
tindices = ifs.tindices();
}
- const unsigned int *mindices = NULL;
+ const unsigned int *mindices = nullptr;
if (ifs.msize()) {
mindices = ifs.mindices();
}
@@ -282,23 +282,23 @@ void WingedEdgeBuilder::buildTriangleStrip(const float * /*vertices*/,
triangleVertices.push_back(currentShape->getVertexList()[vindices[nTriangle + 1] / 3]);
triangleVertices.push_back(currentShape->getVertexList()[vindices[nTriangle + 2] / 3]);
- triangleNormals.push_back(Vec3f(normals[nindices[nTriangle]],
- normals[nindices[nTriangle] + 1],
- normals[nindices[nTriangle] + 2]));
- triangleNormals.push_back(Vec3f(normals[nindices[nTriangle + 1]],
- normals[nindices[nTriangle + 1] + 1],
- normals[nindices[nTriangle + 1] + 2]));
- triangleNormals.push_back(Vec3f(normals[nindices[nTriangle + 2]],
- normals[nindices[nTriangle + 2] + 1],
- normals[nindices[nTriangle + 2] + 2]));
+ triangleNormals.emplace_back(normals[nindices[nTriangle]],
+ normals[nindices[nTriangle] + 1],
+ normals[nindices[nTriangle] + 2]);
+ triangleNormals.emplace_back(normals[nindices[nTriangle + 1]],
+ normals[nindices[nTriangle + 1] + 1],
+ normals[nindices[nTriangle + 1] + 2]);
+ triangleNormals.emplace_back(normals[nindices[nTriangle + 2]],
+ normals[nindices[nTriangle + 2] + 1],
+ normals[nindices[nTriangle + 2] + 2]);
if (texCoords) {
- triangleTexCoords.push_back(
- Vec2f(texCoords[tindices[nTriangle]], texCoords[tindices[nTriangle] + 1]));
- triangleTexCoords.push_back(
- Vec2f(texCoords[tindices[nTriangle + 1]], texCoords[tindices[nTriangle + 1] + 1]));
- triangleTexCoords.push_back(
- Vec2f(texCoords[tindices[nTriangle + 2]], texCoords[tindices[nTriangle + 2] + 1]));
+ triangleTexCoords.emplace_back(texCoords[tindices[nTriangle]],
+ texCoords[tindices[nTriangle] + 1]);
+ triangleTexCoords.emplace_back(texCoords[tindices[nTriangle + 1]],
+ texCoords[tindices[nTriangle + 1] + 1]);
+ triangleTexCoords.emplace_back(texCoords[tindices[nTriangle + 2]],
+ texCoords[tindices[nTriangle + 2] + 1]);
}
}
else { // if nTriangle is odd
@@ -306,23 +306,23 @@ void WingedEdgeBuilder::buildTriangleStrip(const float * /*vertices*/,
triangleVertices.push_back(currentShape->getVertexList()[vindices[nTriangle + 2] / 3]);
triangleVertices.push_back(currentShape->getVertexList()[vindices[nTriangle + 1] / 3]);
- triangleNormals.push_back(Vec3f(normals[nindices[nTriangle]],
- normals[nindices[nTriangle] + 1],
- normals[nindices[nTriangle] + 2]));
- triangleNormals.push_back(Vec3f(normals[nindices[nTriangle + 2]],
- normals[nindices[nTriangle + 2] + 1],
- normals[nindices[nTriangle + 2] + 2]));
- triangleNormals.push_back(Vec3f(normals[nindices[nTriangle + 1]],
- normals[nindices[nTriangle + 1] + 1],
- normals[nindices[nTriangle + 1] + 2]));
+ triangleNormals.emplace_back(normals[nindices[nTriangle]],
+ normals[nindices[nTriangle] + 1],
+ normals[nindices[nTriangle] + 2]);
+ triangleNormals.emplace_back(normals[nindices[nTriangle + 2]],
+ normals[nindices[nTriangle + 2] + 1],
+ normals[nindices[nTriangle + 2] + 2]);
+ triangleNormals.emplace_back(normals[nindices[nTriangle + 1]],
+ normals[nindices[nTriangle + 1] + 1],
+ normals[nindices[nTriangle + 1] + 2]);
if (texCoords) {
- triangleTexCoords.push_back(
- Vec2f(texCoords[tindices[nTriangle]], texCoords[tindices[nTriangle] + 1]));
- triangleTexCoords.push_back(
- Vec2f(texCoords[tindices[nTriangle + 2]], texCoords[tindices[nTriangle + 2] + 1]));
- triangleTexCoords.push_back(
- Vec2f(texCoords[tindices[nTriangle + 1]], texCoords[tindices[nTriangle + 1] + 1]));
+ triangleTexCoords.emplace_back(texCoords[tindices[nTriangle]],
+ texCoords[tindices[nTriangle] + 1]);
+ triangleTexCoords.emplace_back(texCoords[tindices[nTriangle + 2]],
+ texCoords[tindices[nTriangle + 2] + 1]);
+ triangleTexCoords.emplace_back(texCoords[tindices[nTriangle + 1]],
+ texCoords[tindices[nTriangle + 1] + 1]);
}
}
triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[nTriangle / 3] & IndexedFaceSet::FACE_MARK) !=
@@ -386,22 +386,21 @@ void WingedEdgeBuilder::buildTriangles(const float * /*vertices*/,
triangleVertices.push_back(currentShape->getVertexList()[vindices[3 * i + 1] / 3]);
triangleVertices.push_back(currentShape->getVertexList()[vindices[3 * i + 2] / 3]);
- triangleNormals.push_back(Vec3f(
- normals[nindices[3 * i]], normals[nindices[3 * i] + 1], normals[nindices[3 * i] + 2]));
- triangleNormals.push_back(Vec3f(normals[nindices[3 * i + 1]],
- normals[nindices[3 * i + 1] + 1],
- normals[nindices[3 * i + 1] + 2]));
- triangleNormals.push_back(Vec3f(normals[nindices[3 * i + 2]],
- normals[nindices[3 * i + 2] + 1],
- normals[nindices[3 * i + 2] + 2]));
+ triangleNormals.emplace_back(
+ normals[nindices[3 * i]], normals[nindices[3 * i] + 1], normals[nindices[3 * i] + 2]);
+ triangleNormals.emplace_back(normals[nindices[3 * i + 1]],
+ normals[nindices[3 * i + 1] + 1],
+ normals[nindices[3 * i + 1] + 2]);
+ triangleNormals.emplace_back(normals[nindices[3 * i + 2]],
+ normals[nindices[3 * i + 2] + 1],
+ normals[nindices[3 * i + 2] + 2]);
if (texCoords) {
- triangleTexCoords.push_back(
- Vec2f(texCoords[tindices[3 * i]], texCoords[tindices[3 * i] + 1]));
- triangleTexCoords.push_back(
- Vec2f(texCoords[tindices[3 * i + 1]], texCoords[tindices[3 * i + 1] + 1]));
- triangleTexCoords.push_back(
- Vec2f(texCoords[tindices[3 * i + 2]], texCoords[tindices[3 * i + 2] + 1]));
+ triangleTexCoords.emplace_back(texCoords[tindices[3 * i]], texCoords[tindices[3 * i] + 1]);
+ triangleTexCoords.emplace_back(texCoords[tindices[3 * i + 1]],
+ texCoords[tindices[3 * i + 1] + 1]);
+ triangleTexCoords.emplace_back(texCoords[tindices[3 * i + 2]],
+ texCoords[tindices[3 * i + 2] + 1]);
}
triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[i] & IndexedFaceSet::FACE_MARK) != 0);
diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt
index cb4d74559a4..9f1484b47c0 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -31,7 +31,7 @@ set(INC
../editors/include
../makesdna
../makesrna
- ../render/extern/include
+ ../render
../windowmanager
../../../intern/eigen
../../../intern/guardedalloc
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
index 1985ec5caf5..37cde3162a0 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
@@ -383,7 +383,7 @@ PanelType *gpencil_modifier_panel_register(ARegionType *region_type,
/* Give the panel the special flag that says it was built here and corresponds to a
* modifier rather than a #PanelType. */
- panel_type->flag = PNL_LAYOUT_HEADER_EXPAND | PNL_DRAW_BOX | PNL_INSTANCED;
+ panel_type->flag = PANEL_TYPE_HEADER_EXPAND | PANEL_TYPE_DRAW_BOX | PANEL_TYPE_INSTANCED;
panel_type->reorder = gpencil_modifier_reorder;
panel_type->get_list_data_expand_flag = get_gpencil_modifier_expand_flag;
panel_type->set_list_data_expand_flag = set_gpencil_modifier_expand_flag;
@@ -420,7 +420,7 @@ PanelType *gpencil_modifier_subpanel_register(ARegionType *region_type,
panel_type->draw_header = draw_header;
panel_type->draw = draw;
panel_type->poll = gpencil_modifier_ui_poll;
- panel_type->flag = (PNL_DEFAULT_CLOSED | PNL_DRAW_BOX);
+ panel_type->flag = (PANEL_TYPE_DEFAULT_CLOSED | PANEL_TYPE_DRAW_BOX);
BLI_assert(parent != NULL);
BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
index aee345757c6..cc8eae64300 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
@@ -125,10 +125,11 @@ static void deformStroke(GpencilModifierData *md,
if (!mmd->object) {
return;
}
+ bGPdata *gpd = ob->data;
gpencil_deform_verts(mmd, ob, gps);
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
static void bakeModifier(Main *UNUSED(bmain),
@@ -215,7 +216,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, ptr, "invert_vertex_group", 0, "", ICON_ARROW_LEFTRIGHT);
- col = uiLayoutColumnWithHeading(layout, true, IFACE_("Bind to"));
+ col = uiLayoutColumnWithHeading(layout, true, IFACE_("Bind To"));
uiItemR(col, ptr, "use_vertex_groups", 0, IFACE_("Vertex Groups"), ICON_NONE);
uiItemR(col, ptr, "use_bone_envelopes", 0, IFACE_("Bone Envelopes"), ICON_NONE);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
index dec6ef63ffb..aa21bf192c4 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
@@ -86,7 +86,7 @@ static void initData(GpencilModifierData *md)
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);
+ md->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT | UI_SUBPANEL_DATA_EXPAND_1;
}
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
@@ -255,7 +255,7 @@ static void generate_geometry(GpencilModifierData *md,
/* Duplicate original strokes to create this instance. */
LISTBASE_FOREACH_BACKWARD (tmpStrokes *, iter, &stroke_cache) {
/* Duplicate stroke */
- bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(iter->gps, true);
+ bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(iter->gps, true, true);
/* Move points */
for (int i = 0; i < iter->gps->totpoints; i++) {
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
index 5b5cc61bedc..8221c9288d4 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
@@ -115,7 +115,8 @@ static void gpf_clear_all_strokes(bGPDframe *gpf)
*
* Note: This won't be called if all points are present/removed
*/
-static void reduce_stroke_points(bGPDstroke *gps,
+static void reduce_stroke_points(bGPdata *gpd,
+ bGPDstroke *gps,
const int num_points,
const eBuildGpencil_Transition transition)
{
@@ -180,7 +181,7 @@ static void reduce_stroke_points(bGPDstroke *gps,
gps->totpoints = num_points;
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
/* --------------------------------------------- */
@@ -197,7 +198,10 @@ typedef struct tStrokeBuildDetails {
} tStrokeBuildDetails;
/* Sequential - Show strokes one after the other */
-static void build_sequential(BuildGpencilModifierData *mmd, bGPDframe *gpf, float fac)
+static void build_sequential(BuildGpencilModifierData *mmd,
+ bGPdata *gpd,
+ bGPDframe *gpf,
+ float fac)
{
const size_t tot_strokes = BLI_listbase_count(&gpf->strokes);
bGPDstroke *gps;
@@ -236,25 +240,25 @@ static void build_sequential(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa
size_t last_visible = 0;
switch (mmd->transition) {
- /* Show in forward order
- * - As fac increases, the number of visible points increases
- */
+ /* Show in forward order
+ * - As fac increases, the number of visible points increases
+ */
case GP_BUILD_TRANSITION_GROW:
first_visible = 0; /* always visible */
last_visible = (size_t)roundf(totpoints * fac);
break;
- /* Hide in reverse order
- * - As fac increases, the number of points visible at the end decreases
- */
+ /* Hide in reverse order
+ * - As fac increases, the number of points visible at the end decreases
+ */
case GP_BUILD_TRANSITION_SHRINK:
first_visible = 0; /* always visible (until last point removed) */
last_visible = (size_t)(totpoints * (1.0f - fac));
break;
- /* Hide in forward order
- * - As fac increases, the early points start getting hidden
- */
+ /* Hide in forward order
+ * - As fac increases, the early points start getting hidden
+ */
case GP_BUILD_TRANSITION_FADE:
first_visible = (size_t)(totpoints * fac);
last_visible = totpoints; /* i.e. visible until the end, unless first overlaps this */
@@ -278,12 +282,12 @@ static void build_sequential(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa
else if (first_visible > cell->start_idx) {
/* Starts partway through this stroke */
int num_points = cell->end_idx - first_visible;
- reduce_stroke_points(cell->gps, num_points, mmd->transition);
+ reduce_stroke_points(gpd, cell->gps, num_points, mmd->transition);
}
else {
/* Ends partway through this stroke */
int num_points = last_visible - cell->start_idx;
- reduce_stroke_points(cell->gps, num_points, mmd->transition);
+ reduce_stroke_points(gpd, cell->gps, num_points, mmd->transition);
}
}
}
@@ -295,7 +299,10 @@ static void build_sequential(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa
/* --------------------------------------------- */
/* Concurrent - Show multiple strokes at once */
-static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, float fac)
+static void build_concurrent(BuildGpencilModifierData *mmd,
+ bGPdata *gpd,
+ bGPDframe *gpf,
+ float fac)
{
bGPDstroke *gps, *gps_next;
int max_points = 0;
@@ -390,16 +397,14 @@ static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa
}
else if (num_points < gps->totpoints) {
/* Remove some points */
- reduce_stroke_points(gps, num_points, mmd->transition);
+ reduce_stroke_points(gpd, gps, num_points, mmd->transition);
}
}
}
/* --------------------------------------------- */
-static void generate_geometry(GpencilModifierData *md,
- Depsgraph *depsgraph,
- bGPDlayer *gpl,
- bGPDframe *gpf)
+static void generate_geometry(
+ GpencilModifierData *md, Depsgraph *depsgraph, bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf)
{
BuildGpencilModifierData *mmd = (BuildGpencilModifierData *)md;
const bool reverse = (mmd->transition != GP_BUILD_TRANSITION_GROW);
@@ -504,11 +509,11 @@ static void generate_geometry(GpencilModifierData *md,
/* Time management mode */
switch (mmd->mode) {
case GP_BUILD_MODE_SEQUENTIAL:
- build_sequential(mmd, gpf, fac);
+ build_sequential(mmd, gpd, gpf, fac);
break;
case GP_BUILD_MODE_CONCURRENT:
- build_concurrent(mmd, gpf, fac);
+ build_concurrent(mmd, gpd, gpf, fac);
break;
default:
@@ -530,7 +535,7 @@ static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Objec
if (gpf == NULL) {
continue;
}
- generate_geometry(md, depsgraph, gpl, gpf);
+ generate_geometry(md, depsgraph, gpd, gpl, gpf);
}
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
index f0838e4522d..09cce3f1ab4 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
@@ -228,6 +228,7 @@ static void deformStroke(GpencilModifierData *md,
mmd->flag & GP_HOOK_INVERT_MATERIAL)) {
return;
}
+ bGPdata *gpd = ob->data;
/* init struct */
tData.curfalloff = mmd->curfalloff;
@@ -273,7 +274,7 @@ static void deformStroke(GpencilModifierData *md,
gpencil_hook_co_apply(&tData, weight, pt);
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
/* FIXME: Ideally we be doing this on a copy of the main depsgraph
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
index 098a2edf04a..b2a83e83c9e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
@@ -85,6 +85,7 @@ static void deformStroke(GpencilModifierData *md,
bGPDframe *UNUSED(gpf),
bGPDstroke *gps)
{
+ bGPdata *gpd = ob->data;
LatticeGpencilModifierData *mmd = (LatticeGpencilModifierData *)md;
const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname);
@@ -121,7 +122,7 @@ static void deformStroke(GpencilModifierData *md,
(struct LatticeDeformData *)mmd->cache_data, &pt->x, mmd->strength * weight);
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
/* FIXME: Ideally we be doing this on a copy of the main depsgraph
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
index a5457c86ec0..111c60436bf 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
@@ -151,7 +151,7 @@ static void generate_geometry(GpencilModifierData *md, Object *ob, bGPDlayer *gp
mmd->flag & GP_MIRROR_INVERT_PASS,
mmd->flag & GP_MIRROR_INVERT_LAYERPASS,
mmd->flag & GP_MIRROR_INVERT_MATERIAL)) {
- gps_new = BKE_gpencil_stroke_duplicate(gps, true);
+ gps_new = BKE_gpencil_stroke_duplicate(gps, true, true);
update_position(ob, mmd, gps_new, xi);
BLI_addtail(&gpf->strokes, gps_new);
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
index 7d0e3ce53fe..445f677e616 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
@@ -129,6 +129,7 @@ static void duplicateStroke(Object *ob,
float fading_thickness,
float fading_opacity)
{
+ bGPdata *gpd = ob->data;
int i;
bGPDstroke *new_gps = NULL;
float stroke_normal[3];
@@ -172,7 +173,7 @@ static void duplicateStroke(Object *ob,
* to be processed, since we duplicate its data. */
for (i = count - 1; i >= 0; i--) {
if (i != 0) {
- new_gps = BKE_gpencil_stroke_duplicate(gps, true);
+ new_gps = BKE_gpencil_stroke_duplicate(gps, true, true);
BLI_addtail(results, new_gps);
}
else {
@@ -199,7 +200,7 @@ static void duplicateStroke(Object *ob,
}
/* Calc geometry data. */
if (new_gps != NULL) {
- BKE_gpencil_stroke_geometry_update(new_gps);
+ BKE_gpencil_stroke_geometry_update(gpd, new_gps);
}
MEM_freeN(t1_array);
MEM_freeN(t2_array);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
index 634aac00777..4e009e25ce3 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
@@ -100,6 +100,7 @@ static void deformStroke(GpencilModifierData *md,
mmd->flag & GP_OFFSET_INVERT_MATERIAL)) {
return;
}
+ bGPdata *gpd = ob->data;
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
@@ -125,7 +126,7 @@ static void deformStroke(GpencilModifierData *md,
mul_m4_v3(mat, &pt->x);
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
static void bakeModifier(struct Main *UNUSED(bmain),
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
index 7052c59ae40..8093be2f560 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
@@ -92,26 +92,26 @@ static void deformStroke(GpencilModifierData *md,
mmd->flag & GP_SIMPLIFY_INVERT_MATERIAL)) {
return;
}
-
+ bGPdata *gpd = ob->data;
/* Select simplification mode. */
switch (mmd->mode) {
case GP_SIMPLIFY_FIXED: {
for (int i = 0; i < mmd->step; i++) {
- BKE_gpencil_stroke_simplify_fixed(gps);
+ BKE_gpencil_stroke_simplify_fixed(gpd, gps);
}
break;
}
case GP_SIMPLIFY_ADAPTIVE: {
/* simplify stroke using Ramer-Douglas-Peucker algorithm */
- BKE_gpencil_stroke_simplify_adaptive(gps, mmd->factor);
+ BKE_gpencil_stroke_simplify_adaptive(gpd, gps, mmd->factor);
break;
}
case GP_SIMPLIFY_SAMPLE: {
- BKE_gpencil_stroke_sample(gps, mmd->length, false);
+ BKE_gpencil_stroke_sample(gpd, gps, mmd->length, false);
break;
}
case GP_SIMPLIFY_MERGE: {
- BKE_gpencil_stroke_merge_distance(gpf, gps, mmd->distance, true);
+ BKE_gpencil_stroke_merge_distance(gpd, gpf, gps, mmd->distance, true);
break;
}
default:
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
index 6eb12974408..c91bb1cef92 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
@@ -80,6 +80,7 @@ static void deformStroke(GpencilModifierData *md,
bGPDstroke *gps)
{
SubdivGpencilModifierData *mmd = (SubdivGpencilModifierData *)md;
+ bGPdata *gpd = ob->data;
/* It makes sense when adding points to a straight line */
/* e.g. for creating thickness variation in later modifiers. */
@@ -100,7 +101,12 @@ static void deformStroke(GpencilModifierData *md,
return;
}
- BKE_gpencil_stroke_subdivide(gps, mmd->level, mmd->type);
+ BKE_gpencil_stroke_subdivide(gpd, gps, mmd->level, mmd->type);
+
+ /* If the stroke is cyclic, must generate the closing geometry. */
+ if (gps->flag & GP_STROKE_CYCLIC) {
+ BKE_gpencil_stroke_close(gps);
+ }
}
static void bakeModifier(struct Main *UNUSED(bmain),
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c
index d29351646b9..c396dffad27 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c
@@ -82,6 +82,7 @@ static void deformStroke(GpencilModifierData *md,
{
TextureGpencilModifierData *mmd = (TextureGpencilModifierData *)md;
const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname);
+ bGPdata *gpd = ob->data;
if (!is_stroke_affected_by_modifier(ob,
mmd->layername,
@@ -97,15 +98,15 @@ static void deformStroke(GpencilModifierData *md,
mmd->flag & GP_TEX_INVERT_MATERIAL)) {
return;
}
- if ((mmd->mode == FILL) || (mmd->mode == STROKE_AND_FILL)) {
+ if (ELEM(mmd->mode, FILL, STROKE_AND_FILL)) {
gps->uv_rotation += mmd->fill_rotation;
gps->uv_translation[0] += mmd->fill_offset[0];
gps->uv_translation[1] += mmd->fill_offset[1];
gps->uv_scale *= mmd->fill_scale;
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
- if ((mmd->mode == STROKE) || (mmd->mode == STROKE_AND_FILL)) {
+ if (ELEM(mmd->mode, STROKE, STROKE_AND_FILL)) {
float totlen = 1.0f;
if (mmd->fit_method == GP_TEX_FIT_STROKE) {
totlen = 0.0f;
@@ -127,6 +128,7 @@ static void deformStroke(GpencilModifierData *md,
pt->uv_fac /= totlen;
pt->uv_fac *= mmd->uv_scale;
pt->uv_fac += mmd->uv_offset;
+ pt->uv_rot += mmd->alignment_rotation;
}
}
}
@@ -171,6 +173,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
col = uiLayoutColumn(layout, false);
uiItemR(col, ptr, "fit_method", 0, IFACE_("Stroke Fit Method"), ICON_NONE);
uiItemR(col, ptr, "uv_offset", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "alignment_rotation", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "uv_scale", 0, IFACE_("Scale"), ICON_NONE);
}
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 2f12625acac..67cd1a61aed 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -34,6 +34,7 @@
extern "C" {
#endif
+struct GHash;
struct GPUMaterial;
struct GPUNode;
struct GPUNodeLink;
@@ -143,6 +144,7 @@ typedef void (*GPUMaterialEvalCallbackFn)(GPUMaterial *mat,
GPUNodeLink *GPU_constant(const float *num);
GPUNodeLink *GPU_uniform(const float *num);
GPUNodeLink *GPU_attribute(GPUMaterial *mat, CustomDataType type, const char *name);
+GPUNodeLink *GPU_uniform_attribute(GPUMaterial *mat, const char *name, bool use_dupli);
GPUNodeLink *GPU_image(GPUMaterial *mat,
struct Image *ima,
struct ImageUser *iuser,
@@ -259,6 +261,31 @@ ListBase GPU_material_attributes(GPUMaterial *material);
ListBase GPU_material_textures(GPUMaterial *material);
ListBase GPU_material_volume_grids(GPUMaterial *material);
+typedef struct GPUUniformAttr {
+ struct GPUUniformAttr *next, *prev;
+
+ /* Meaningful part of the attribute set key. */
+ char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
+ bool use_dupli;
+
+ /* Helper fields used by code generation. */
+ short id;
+ int users;
+} GPUUniformAttr;
+
+typedef struct GPUUniformAttrList {
+ ListBase list; /* GPUUniformAttr */
+
+ /* List length and hash code precomputed for fast lookup and comparison. */
+ unsigned int count, hash_code;
+} GPUUniformAttrList;
+
+GPUUniformAttrList *GPU_material_uniform_attributes(GPUMaterial *material);
+
+struct GHash *GPU_uniform_attr_list_hash_new(const char *info);
+void GPU_uniform_attr_list_copy(GPUUniformAttrList *dest, GPUUniformAttrList *src);
+void GPU_uniform_attr_list_free(GPUUniformAttrList *set);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index 9aaa5d4cae8..27a7ea1e6a5 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -413,6 +413,9 @@ void GPU_shader_free_builtin_shaders(void);
* This makes sure the GPUVertexFormat name buffer does not overflow. */
#define GPU_MAX_ATTR 15
+/* Determined by the maximum uniform buffer size divided by chunk size. */
+#define GPU_MAX_UNIFORM_ATTR 8
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/gpu/GPU_uniform_buffer.h b/source/blender/gpu/GPU_uniform_buffer.h
index ebcaa80e6f6..4efac0a8c00 100644
--- a/source/blender/gpu/GPU_uniform_buffer.h
+++ b/source/blender/gpu/GPU_uniform_buffer.h
@@ -53,6 +53,7 @@ void GPU_uniformbuf_unbind(GPUUniformBuf *ubo);
void GPU_uniformbuf_unbind_all(void);
#define GPU_UBO_BLOCK_NAME "nodeTree"
+#define GPU_ATTRIBUTE_UBO_BLOCK_NAME "uniformAttrs"
#ifdef __cplusplus
}
diff --git a/source/blender/gpu/GPU_viewport.h b/source/blender/gpu/GPU_viewport.h
index 7b0d8c274d3..d8e4c5377b0 100644
--- a/source/blender/gpu/GPU_viewport.h
+++ b/source/blender/gpu/GPU_viewport.h
@@ -38,6 +38,7 @@ extern "C" {
#define GPU_INFO_SIZE 512 /* IMA_MAX_RENDER_TEXT */
#define GLA_PIXEL_OFS 0.375f
+typedef struct GHash GHash;
typedef struct GPUViewport GPUViewport;
struct GPUFrameBuffer;
@@ -57,6 +58,7 @@ typedef struct ViewportMemoryPool {
struct BLI_memblock *images;
struct GPUUniformBuf **matrices_ubo;
struct GPUUniformBuf **obinfos_ubo;
+ struct GHash *obattrs_ubo_pool;
uint ubo_len;
} ViewportMemoryPool;
diff --git a/source/blender/gpu/intern/gpu_batch.cc b/source/blender/gpu/intern/gpu_batch.cc
index 511ddd210af..3bf1233c000 100644
--- a/source/blender/gpu/intern/gpu_batch.cc
+++ b/source/blender/gpu/intern/gpu_batch.cc
@@ -73,21 +73,21 @@ void GPU_batch_init_ex(GPUBatch *batch,
GPUIndexBuf *elem,
eGPUBatchFlag owns_flag)
{
- BLI_assert(verts != NULL);
+ BLI_assert(verts != nullptr);
/* Do not pass any other flag */
BLI_assert((owns_flag & ~(GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX)) == 0);
batch->verts[0] = verts;
for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; v++) {
- batch->verts[v] = NULL;
+ batch->verts[v] = nullptr;
}
for (int v = 0; v < GPU_BATCH_INST_VBO_MAX_LEN; v++) {
- batch->inst[v] = NULL;
+ batch->inst[v] = nullptr;
}
batch->elem = elem;
batch->prim_type = prim_type;
batch->flag = owns_flag | GPU_BATCH_INIT | GPU_BATCH_DIRTY;
- batch->shader = NULL;
+ batch->shader = nullptr;
}
/* This will share the VBOs with the new batch. */
@@ -171,7 +171,7 @@ int GPU_batch_instbuf_add_ex(GPUBatch *batch, GPUVertBuf *insts, bool own_vbo)
batch->flag |= GPU_BATCH_DIRTY;
for (uint v = 0; v < GPU_BATCH_INST_VBO_MAX_LEN; v++) {
- if (batch->inst[v] == NULL) {
+ if (batch->inst[v] == nullptr) {
/* for now all VertexBuffers must have same vertex_len */
if (batch->inst[0]) {
/* Allow for different size of vertex buffer (will choose the smallest number of verts). */
@@ -195,9 +195,9 @@ int GPU_batch_vertbuf_add_ex(GPUBatch *batch, GPUVertBuf *verts, bool own_vbo)
batch->flag |= GPU_BATCH_DIRTY;
for (uint v = 0; v < GPU_BATCH_VBO_MAX_LEN; v++) {
- if (batch->verts[v] == NULL) {
+ if (batch->verts[v] == nullptr) {
/* for now all VertexBuffers must have same vertex_len */
- if (batch->verts[0] != NULL) {
+ if (batch->verts[0] != nullptr) {
/* This is an issue for the HACK inside DRW_vbo_request(). */
// BLI_assert(verts->vertex_len == batch->verts[0]->vertex_len);
}
@@ -246,7 +246,7 @@ void GPU_batch_draw_range(GPUBatch *batch, int v_first, int v_count)
/* Draw multiple instance of a batch without having any instance attributes. */
void GPU_batch_draw_instanced(GPUBatch *batch, int i_count)
{
- BLI_assert(batch->inst[0] == NULL);
+ BLI_assert(batch->inst[0] == nullptr);
GPU_shader_bind(batch->shader);
GPU_batch_draw_advanced(batch, 0, 0, 0, i_count);
@@ -255,7 +255,7 @@ void GPU_batch_draw_instanced(GPUBatch *batch, int i_count)
void GPU_batch_draw_advanced(
GPUBatch *gpu_batch, int v_first, int v_count, int i_first, int i_count)
{
- BLI_assert(Context::get()->shader != NULL);
+ BLI_assert(Context::get()->shader != nullptr);
Batch *batch = static_cast<Batch *>(gpu_batch);
if (v_count == 0) {
@@ -269,7 +269,7 @@ void GPU_batch_draw_advanced(
if (i_count == 0) {
i_count = (batch->inst[0]) ? batch->inst_(0)->vertex_len : 1;
/* Meh. This is to be able to use different numbers of verts in instance vbos. */
- if (batch->inst[1] != NULL) {
+ if (batch->inst[1] != nullptr) {
i_count = min_ii(i_count, batch->inst_(1)->vertex_len);
}
}
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 2d76e793fc0..3ebe2edc89e 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -377,6 +377,19 @@ static int codegen_process_uniforms_functions(GPUMaterial *material,
BLI_freelistN(&ubo_inputs);
}
+ /* Generate the uniform attribute UBO if necessary. */
+ if (!BLI_listbase_is_empty(&graph->uniform_attrs.list)) {
+ BLI_dynstr_append(ds, "\nstruct UniformAttributes {\n");
+ LISTBASE_FOREACH (GPUUniformAttr *, attr, &graph->uniform_attrs.list) {
+ BLI_dynstr_appendf(ds, " vec4 attr%d;\n", attr->id);
+ }
+ BLI_dynstr_append(ds, "};\n");
+ BLI_dynstr_appendf(ds, "layout (std140) uniform %s {\n", GPU_ATTRIBUTE_UBO_BLOCK_NAME);
+ BLI_dynstr_append(ds, " UniformAttributes uniform_attrs[DRW_RESOURCE_CHUNK_LEN];\n");
+ BLI_dynstr_append(ds, "};\n");
+ BLI_dynstr_append(ds, "#define GET_UNIFORM_ATTR(name) (uniform_attrs[resource_id].name)\n");
+ }
+
BLI_dynstr_append(ds, "\n");
return builtins;
@@ -478,7 +491,10 @@ static void codegen_call_functions(DynStr *ds, GPUNodeGraph *graph, GPUOutput *f
BLI_dynstr_appendf(ds, "cons%d", input->id);
}
else if (input->source == GPU_SOURCE_ATTR) {
- BLI_dynstr_appendf(ds, "var%d", input->attr->id);
+ codegen_convert_datatype(ds, input->attr->gputype, input->type, "var", input->attr->id);
+ }
+ else if (input->source == GPU_SOURCE_UNIFORM_ATTR) {
+ BLI_dynstr_appendf(ds, "GET_UNIFORM_ATTR(attr%d)", input->uniform_attr->id);
}
BLI_dynstr_append(ds, ", ");
@@ -799,6 +815,7 @@ GPUPass *GPU_generate_pass(GPUMaterial *material,
/* Prune the unused nodes and extract attributes before compiling so the
* generated VBOs are ready to accept the future shader. */
gpu_node_graph_prune_unused(graph);
+ gpu_node_graph_finalize_uniform_attrs(graph);
int builtins = 0;
LISTBASE_FOREACH (GPUNode *, node, &graph->nodes) {
@@ -914,7 +931,7 @@ static int count_active_texture_sampler(GPUShader *shader, char *source)
/* Move past "uniform". */
code += 7;
/* Skip sampler type suffix. */
- while (*code != ' ' && *code != '\0') {
+ while (!ELEM(*code, ' ', '\0')) {
code++;
}
/* Skip following spaces. */
diff --git a/source/blender/gpu/intern/gpu_context.cc b/source/blender/gpu/intern/gpu_context.cc
index 119c1ef9c55..a9d32dcf297 100644
--- a/source/blender/gpu/intern/gpu_context.cc
+++ b/source/blender/gpu/intern/gpu_context.cc
@@ -54,7 +54,7 @@
using namespace blender::gpu;
-static thread_local Context *active_ctx = NULL;
+static thread_local Context *active_ctx = nullptr;
/* -------------------------------------------------------------------- */
/** \name gpu::Context methods
@@ -80,12 +80,12 @@ Context::~Context()
delete imm;
}
-bool Context::is_active_on_thread(void)
+bool Context::is_active_on_thread()
{
return (this == active_ctx) && pthread_equal(pthread_self(), thread_);
}
-Context *Context::get(void)
+Context *Context::get()
{
return active_ctx;
}
@@ -98,7 +98,7 @@ Context *Context::get(void)
GPUContext *GPU_context_create(void *ghost_window)
{
- if (GPUBackend::get() == NULL) {
+ if (GPUBackend::get() == nullptr) {
/* TODO move where it make sense. */
GPU_backend_init(GPU_BACKEND_OPENGL);
}
@@ -114,7 +114,7 @@ void GPU_context_discard(GPUContext *ctx_)
{
Context *ctx = unwrap(ctx_);
delete ctx;
- active_ctx = NULL;
+ active_ctx = nullptr;
}
/* ctx can be NULL */
@@ -166,7 +166,7 @@ static GPUBackend *g_backend;
void GPU_backend_init(eGPUBackendType backend_type)
{
- BLI_assert(g_backend == NULL);
+ BLI_assert(g_backend == nullptr);
switch (backend_type) {
#if WITH_OPENGL_BACKEND
@@ -185,10 +185,10 @@ void GPU_backend_exit(void)
/* TODO assert no resource left. Currently UI textures are still not freed in their context
* correctly. */
delete g_backend;
- g_backend = NULL;
+ g_backend = nullptr;
}
-GPUBackend *GPUBackend::get(void)
+GPUBackend *GPUBackend::get()
{
return g_backend;
}
diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc
index 8d9a1301be0..f11f1cea753 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.cc
+++ b/source/blender/gpu/intern/gpu_framebuffer.cc
@@ -58,7 +58,7 @@ FrameBuffer::FrameBuffer(const char *name)
dirty_state_ = true;
for (int i = 0; i < ARRAY_SIZE(attachments_); i++) {
- attachments_[i].tex = NULL;
+ attachments_[i].tex = nullptr;
attachments_[i].mip = -1;
attachments_[i].layer = -1;
}
@@ -67,7 +67,7 @@ FrameBuffer::FrameBuffer(const char *name)
FrameBuffer::~FrameBuffer()
{
for (int i = 0; i < ARRAY_SIZE(attachments_); i++) {
- if (attachments_[i].tex != NULL) {
+ if (attachments_[i].tex != nullptr) {
reinterpret_cast<Texture *>(attachments_[i].tex)->detach_from(this);
}
}
@@ -150,7 +150,7 @@ void FrameBuffer::recursive_downsample(int max_lvl,
/* Replace attached mip-level for each attachment. */
for (int att = 0; att < ARRAY_SIZE(attachments_); att++) {
Texture *tex = reinterpret_cast<Texture *>(attachments_[att].tex);
- if (tex != NULL) {
+ if (tex != nullptr) {
/* Some Intel HDXXX have issue with rendering to a mipmap that is below
* the texture GL_TEXTURE_MAX_LEVEL. So even if it not correct, in this case
* we allow GL_TEXTURE_MAX_LEVEL to be one level lower. In practice it does work! */
@@ -169,7 +169,7 @@ void FrameBuffer::recursive_downsample(int max_lvl,
}
for (int att = 0; att < ARRAY_SIZE(attachments_); att++) {
- if (attachments_[att].tex != NULL) {
+ if (attachments_[att].tex != nullptr) {
/* Reset mipmap level range. */
reinterpret_cast<Texture *>(attachments_[att].tex)->mip_range_set(0, max_lvl);
/* Reset base level. NOTE: might not be the one bound at the start of this function. */
@@ -242,14 +242,14 @@ void GPU_framebuffer_restore(void)
GPUFrameBuffer *GPU_framebuffer_active_get(void)
{
Context *ctx = Context::get();
- return wrap(ctx ? ctx->active_fb : NULL);
+ return wrap(ctx ? ctx->active_fb : nullptr);
}
/* Returns the default frame-buffer. Will always exists even if it's just a dummy. */
GPUFrameBuffer *GPU_framebuffer_back_get(void)
{
Context *ctx = Context::get();
- return wrap(ctx ? ctx->back_left : NULL);
+ return wrap(ctx ? ctx->back_left : nullptr);
}
bool GPU_framebuffer_bound(GPUFrameBuffer *gpu_fb)
@@ -314,7 +314,7 @@ void GPU_framebuffer_config_array(GPUFrameBuffer *gpu_fb,
if (depth_attachment.mip == -1) {
/* GPU_ATTACHMENT_LEAVE */
}
- else if (depth_attachment.tex == NULL) {
+ else if (depth_attachment.tex == nullptr) {
/* GPU_ATTACHMENT_NONE: Need to clear both targets. */
fb->attachment_set(GPU_FB_DEPTH_STENCIL_ATTACHMENT, depth_attachment);
fb->attachment_set(GPU_FB_DEPTH_ATTACHMENT, depth_attachment);
@@ -487,7 +487,7 @@ void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *gpu_fb,
static struct {
GPUFrameBuffer *framebuffers[FRAMEBUFFER_STACK_DEPTH];
uint top;
-} FrameBufferStack = {{0}};
+} FrameBufferStack = {{nullptr}};
static void gpuPushFrameBuffer(GPUFrameBuffer *fb)
{
@@ -496,7 +496,7 @@ static void gpuPushFrameBuffer(GPUFrameBuffer *fb)
FrameBufferStack.top++;
}
-static GPUFrameBuffer *gpuPopFrameBuffer(void)
+static GPUFrameBuffer *gpuPopFrameBuffer()
{
BLI_assert(FrameBufferStack.top > 0);
FrameBufferStack.top--;
@@ -526,7 +526,7 @@ static GPUFrameBuffer *gpu_offscreen_fb_get(GPUOffScreen *ofs)
BLI_assert(ctx);
for (int i = 0; i < MAX_CTX_FB_LEN; i++) {
- if (ofs->framebuffers[i].fb == NULL) {
+ if (ofs->framebuffers[i].fb == nullptr) {
ofs->framebuffers[i].ctx = ctx;
GPU_framebuffer_ensure_config(&ofs->framebuffers[i].fb,
{
@@ -552,7 +552,7 @@ static GPUFrameBuffer *gpu_offscreen_fb_get(GPUOffScreen *ofs)
for (int i = 0; i < MAX_CTX_FB_LEN; i++) {
GPU_framebuffer_free(ofs->framebuffers[i].fb);
- ofs->framebuffers[i].fb = NULL;
+ ofs->framebuffers[i].fb = nullptr;
}
return gpu_offscreen_fb_get(ofs);
@@ -569,16 +569,17 @@ GPUOffScreen *GPU_offscreen_create(
width = max_ii(1, width);
ofs->color = GPU_texture_create_2d(
- "ofs_color", width, height, 1, (high_bitdepth) ? GPU_RGBA16F : GPU_RGBA8, NULL);
+ "ofs_color", width, height, 1, (high_bitdepth) ? GPU_RGBA16F : GPU_RGBA8, nullptr);
if (depth) {
- ofs->depth = GPU_texture_create_2d("ofs_depth", width, height, 1, GPU_DEPTH24_STENCIL8, NULL);
+ ofs->depth = GPU_texture_create_2d(
+ "ofs_depth", width, height, 1, GPU_DEPTH24_STENCIL8, nullptr);
}
if ((depth && !ofs->depth) || !ofs->color) {
BLI_snprintf(err_out, 256, "GPUTexture: Texture allocation failed.");
GPU_offscreen_free(ofs);
- return NULL;
+ return nullptr;
}
GPUFrameBuffer *fb = gpu_offscreen_fb_get(ofs);
@@ -586,7 +587,7 @@ GPUOffScreen *GPU_offscreen_create(
/* check validity at the very end! */
if (!GPU_framebuffer_check_valid(fb, err_out)) {
GPU_offscreen_free(ofs);
- return NULL;
+ return nullptr;
}
GPU_framebuffer_restore();
return ofs;
@@ -620,7 +621,7 @@ void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
void GPU_offscreen_unbind(GPUOffScreen *UNUSED(ofs), bool restore)
{
- GPUFrameBuffer *fb = NULL;
+ GPUFrameBuffer *fb = nullptr;
if (restore) {
fb = gpuPopFrameBuffer();
}
diff --git a/source/blender/gpu/intern/gpu_immediate.cc b/source/blender/gpu/intern/gpu_immediate.cc
index 979b3cbb557..95718391165 100644
--- a/source/blender/gpu/intern/gpu_immediate.cc
+++ b/source/blender/gpu/intern/gpu_immediate.cc
@@ -39,19 +39,19 @@
using namespace blender::gpu;
-static thread_local Immediate *imm = NULL;
+static thread_local Immediate *imm = nullptr;
-void immActivate(void)
+void immActivate()
{
imm = Context::get()->imm;
}
-void immDeactivate(void)
+void immDeactivate()
{
- imm = NULL;
+ imm = nullptr;
}
-GPUVertFormat *immVertexFormat(void)
+GPUVertFormat *immVertexFormat()
{
GPU_vertformat_clear(&imm->vertex_format);
return &imm->vertex_format;
@@ -59,7 +59,7 @@ GPUVertFormat *immVertexFormat(void)
void immBindShader(GPUShader *shader)
{
- BLI_assert(imm->shader == NULL);
+ BLI_assert(imm->shader == nullptr);
imm->shader = shader;
imm->builtin_shader_bound = GPU_SHADER_TEXT; /* Default value. */
@@ -81,16 +81,16 @@ void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
imm->builtin_shader_bound = shader_id;
}
-void immUnbindProgram(void)
+void immUnbindProgram()
{
- BLI_assert(imm->shader != NULL);
+ BLI_assert(imm->shader != nullptr);
GPU_shader_unbind();
- imm->shader = NULL;
+ imm->shader = nullptr;
}
/* XXX do not use it. Special hack to use OCIO with batch API. */
-GPUShader *immGetShader(void)
+GPUShader *immGetShader()
{
return imm->shader;
}
@@ -192,7 +192,7 @@ static void wide_line_workaround_start(GPUPrimType prim_type)
}
}
-static void wide_line_workaround_end(void)
+static void wide_line_workaround_end()
{
if (imm->prev_shader) {
if (GPU_blend_get() == GPU_BLEND_NONE) {
@@ -202,7 +202,7 @@ static void wide_line_workaround_end(void)
immUnbindProgram();
immBindShader(imm->prev_shader);
- imm->prev_shader = NULL;
+ imm->prev_shader = nullptr;
}
}
@@ -245,7 +245,7 @@ GPUBatch *immBeginBatch(GPUPrimType prim_type, uint vertex_len)
imm->vertex_data = (uchar *)GPU_vertbuf_get_data(verts);
- imm->batch = GPU_batch_create_ex(prim_type, verts, NULL, GPU_BATCH_OWNS_VBO);
+ imm->batch = GPU_batch_create_ex(prim_type, verts, nullptr, GPU_BATCH_OWNS_VBO);
imm->batch->flag |= GPU_BATCH_BUILDING;
return imm->batch;
@@ -258,7 +258,7 @@ GPUBatch *immBeginBatchAtMost(GPUPrimType prim_type, uint vertex_len)
return immBeginBatch(prim_type, vertex_len);
}
-void immEnd(void)
+void immEnd()
{
BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* Make sure we're between a Begin/End pair. */
BLI_assert(imm->vertex_data || imm->batch);
@@ -279,7 +279,7 @@ void immEnd(void)
}
GPU_batch_set_shader(imm->batch, imm->shader);
imm->batch->flag &= ~GPU_BATCH_BUILDING;
- imm->batch = NULL; /* don't free, batch belongs to caller */
+ imm->batch = nullptr; /* don't free, batch belongs to caller */
}
else {
imm->end();
@@ -288,7 +288,7 @@ void immEnd(void)
/* Prepare for next immBegin. */
imm->prim_type = GPU_PRIM_NONE;
imm->strict_vertex_len = true;
- imm->vertex_data = NULL;
+ imm->vertex_data = nullptr;
wide_line_workaround_end();
}
@@ -489,7 +489,7 @@ void immAttrSkip(uint attr_id)
setAttrValueBit(attr_id);
}
-static void immEndVertex(void) /* and move on to the next vertex */
+static void immEndVertex() /* and move on to the next vertex */
{
BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
BLI_assert(imm->vertex_idx < imm->vertex_len);
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index b8cd9fe356d..d18dc862ce7 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -455,8 +455,8 @@ void imm_draw_cylinder_fill_normal_3d(
for (int j = 0; j < stacks; j++) {
float fac1 = (float)j / (float)stacks;
float fac2 = (float)(j + 1) / (float)stacks;
- float r1 = base * (1.f - fac1) + top * fac1;
- float r2 = base * (1.f - fac2) + top * fac2;
+ float r1 = base * (1.0f - fac1) + top * fac1;
+ float r2 = base * (1.0f - fac2) + top * fac2;
float h1 = height * ((float)j / (float)stacks);
float h2 = height * ((float)(j + 1) / (float)stacks);
@@ -511,8 +511,8 @@ void imm_draw_cylinder_wire_3d(
for (int j = 0; j < stacks; j++) {
float fac1 = (float)j / (float)stacks;
float fac2 = (float)(j + 1) / (float)stacks;
- float r1 = base * (1.f - fac1) + top * fac1;
- float r2 = base * (1.f - fac2) + top * fac2;
+ float r1 = base * (1.0f - fac1) + top * fac1;
+ float r2 = base * (1.0f - fac2) + top * fac2;
float h1 = height * ((float)j / (float)stacks);
float h2 = height * ((float)(j + 1) / (float)stacks);
@@ -549,8 +549,8 @@ void imm_draw_cylinder_fill_3d(
for (int j = 0; j < stacks; j++) {
float fac1 = (float)j / (float)stacks;
float fac2 = (float)(j + 1) / (float)stacks;
- float r1 = base * (1.f - fac1) + top * fac1;
- float r2 = base * (1.f - fac2) + top * fac2;
+ float r1 = base * (1.0f - fac1) + top * fac1;
+ float r2 = base * (1.0f - fac2) + top * fac2;
float h1 = height * ((float)j / (float)stacks);
float h2 = height * ((float)(j + 1) / (float)stacks);
diff --git a/source/blender/gpu/intern/gpu_index_buffer.cc b/source/blender/gpu/intern/gpu_index_buffer.cc
index 36f18f2da49..65932d2dbf4 100644
--- a/source/blender/gpu/intern/gpu_index_buffer.cc
+++ b/source/blender/gpu/intern/gpu_index_buffer.cc
@@ -69,7 +69,7 @@ void GPU_indexbuf_init(GPUIndexBufBuilder *builder,
void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *builder, uint v)
{
#if TRUST_NO_ONE
- assert(builder->data != NULL);
+ assert(builder->data != nullptr);
assert(builder->index_len < builder->max_index_len);
assert(v <= builder->max_allowed_index);
#endif
@@ -79,7 +79,7 @@ void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *builder, uint v)
void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder *builder)
{
#if TRUST_NO_ONE
- assert(builder->data != NULL);
+ assert(builder->data != nullptr);
assert(builder->index_len < builder->max_index_len);
#endif
builder->data[builder->index_len++] = RESTART_INDEX;
@@ -336,7 +336,7 @@ GPUIndexBuf *GPU_indexbuf_create_subrange(GPUIndexBuf *elem_src, uint start, uin
void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *builder, GPUIndexBuf *elem)
{
- BLI_assert(builder->data != NULL);
+ BLI_assert(builder->data != nullptr);
/* Transfer data ownership to GPUIndexBuf.
* It will be uploaded upon first use. */
unwrap(elem)->init(builder->index_len, builder->data);
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 011d14673b4..a0fe77598f2 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -313,7 +313,7 @@ static float eval_profile(float r, short falloff_type, float sharpness, float pa
{
r = fabsf(r);
- if (falloff_type == SHD_SUBSURFACE_BURLEY || falloff_type == SHD_SUBSURFACE_RANDOM_WALK) {
+ if (ELEM(falloff_type, SHD_SUBSURFACE_BURLEY, SHD_SUBSURFACE_RANDOM_WALK)) {
return burley_profile(r, param) / BURLEY_TRUNCATE_CDF;
}
if (falloff_type == SHD_SUBSURFACE_CUBIC) {
@@ -353,7 +353,7 @@ static void compute_sss_kernel(
/* Christensen-Burley fitting */
float l[3], d[3];
- if (falloff_type == SHD_SUBSURFACE_BURLEY || falloff_type == SHD_SUBSURFACE_RANDOM_WALK) {
+ if (ELEM(falloff_type, SHD_SUBSURFACE_BURLEY, SHD_SUBSURFACE_RANDOM_WALK)) {
mul_v3_v3fl(l, rad, 0.25f * M_1_PI);
const float A = 1.0f;
const float s = 1.9f - A + 3.5f * (A - 0.8f) * (A - 0.8f);
@@ -584,6 +584,12 @@ ListBase GPU_material_volume_grids(GPUMaterial *material)
return material->graph.volume_grids;
}
+GPUUniformAttrList *GPU_material_uniform_attributes(GPUMaterial *material)
+{
+ GPUUniformAttrList *attrs = &material->graph.uniform_attrs;
+ return attrs->count > 0 ? attrs : NULL;
+}
+
void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link)
{
if (!material->graph.outlink) {
diff --git a/source/blender/gpu/intern/gpu_matrix.cc b/source/blender/gpu/intern/gpu_matrix.cc
index 0274966d4b9..dae56e39db6 100644
--- a/source/blender/gpu/intern/gpu_matrix.cc
+++ b/source/blender/gpu/intern/gpu_matrix.cc
@@ -606,7 +606,7 @@ const float (*GPU_matrix_projection_get(float m[4][4]))[4]
const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4]
{
- if (m == NULL) {
+ if (m == nullptr) {
static Mat4 temp;
m = temp;
}
@@ -617,12 +617,12 @@ const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4]
const float (*GPU_matrix_normal_get(float m[3][3]))[3]
{
- if (m == NULL) {
+ if (m == nullptr) {
static Mat3 temp3;
m = temp3;
}
- copy_m3_m4(m, (const float(*)[4])GPU_matrix_model_view_get(NULL));
+ copy_m3_m4(m, (const float(*)[4])GPU_matrix_model_view_get(nullptr));
invert_m3(m);
transpose_m3(m);
@@ -632,7 +632,7 @@ const float (*GPU_matrix_normal_get(float m[3][3]))[3]
const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3]
{
- if (m == NULL) {
+ if (m == nullptr) {
static Mat3 temp3;
m = temp3;
}
@@ -658,17 +658,18 @@ void GPU_matrix_bind(GPUShader *shader)
int32_t P_inv = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_PROJECTION_INV);
if (MV != -1) {
- GPU_shader_uniform_vector(shader, MV, 16, 1, (const float *)GPU_matrix_model_view_get(NULL));
+ GPU_shader_uniform_vector(
+ shader, MV, 16, 1, (const float *)GPU_matrix_model_view_get(nullptr));
}
if (P != -1) {
- GPU_shader_uniform_vector(shader, P, 16, 1, (const float *)GPU_matrix_projection_get(NULL));
+ GPU_shader_uniform_vector(shader, P, 16, 1, (const float *)GPU_matrix_projection_get(nullptr));
}
if (MVP != -1) {
GPU_shader_uniform_vector(
- shader, MVP, 16, 1, (const float *)GPU_matrix_model_view_projection_get(NULL));
+ shader, MVP, 16, 1, (const float *)GPU_matrix_model_view_projection_get(nullptr));
}
if (N != -1) {
- GPU_shader_uniform_vector(shader, N, 9, 1, (const float *)GPU_matrix_normal_get(NULL));
+ GPU_shader_uniform_vector(shader, N, 9, 1, (const float *)GPU_matrix_normal_get(nullptr));
}
if (MV_inv != -1) {
Mat4 m;
diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c
index c890d56994f..2a2a51e32b3 100644
--- a/source/blender/gpu/intern/gpu_node_graph.c
+++ b/source/blender/gpu/intern/gpu_node_graph.c
@@ -132,7 +132,14 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType
case GPU_NODE_LINK_ATTR:
input->source = GPU_SOURCE_ATTR;
input->attr = link->attr;
- input->attr->gputype = type;
+ /* Failsafe handling if the same attribute is used with different datatypes for
+ * some reason (only really makes sense with float/vec2/vec3/vec4 though). This
+ * can happen if mixing the generic Attribute node with specialized ones. */
+ CLAMP_MIN(input->attr->gputype, type);
+ break;
+ case GPU_NODE_LINK_UNIFORM_ATTR:
+ input->source = GPU_SOURCE_UNIFORM_ATTR;
+ input->uniform_attr = link->uniform_attr;
break;
case GPU_NODE_LINK_CONSTANT:
input->source = (type == GPU_CLOSURE) ? GPU_SOURCE_STRUCT : GPU_SOURCE_CONSTANT;
@@ -259,8 +266,90 @@ static void gpu_node_output(GPUNode *node, const eGPUType type, GPUNodeLink **li
BLI_addtail(&node->outputs, output);
}
+/* Uniform Attribute Functions */
+
+static int uniform_attr_sort_cmp(const void *a, const void *b)
+{
+ const GPUUniformAttr *attr_a = a, *attr_b = b;
+
+ int cmps = strcmp(attr_a->name, attr_b->name);
+ if (cmps != 0) {
+ return cmps > 0 ? 1 : 0;
+ }
+
+ return (attr_a->use_dupli && !attr_b->use_dupli);
+}
+
+static unsigned int uniform_attr_list_hash(const void *key)
+{
+ const GPUUniformAttrList *attrs = key;
+ return attrs->hash_code;
+}
+
+static bool uniform_attr_list_cmp(const void *a, const void *b)
+{
+ const GPUUniformAttrList *set_a = a, *set_b = b;
+
+ if (set_a->hash_code != set_b->hash_code || set_a->count != set_b->count) {
+ return true;
+ }
+
+ GPUUniformAttr *attr_a = set_a->list.first, *attr_b = set_b->list.first;
+
+ for (; attr_a && attr_b; attr_a = attr_a->next, attr_b = attr_b->next) {
+ if (!STREQ(attr_a->name, attr_b->name) || attr_a->use_dupli != attr_b->use_dupli) {
+ return true;
+ }
+ }
+
+ return attr_a || attr_b;
+}
+
+struct GHash *GPU_uniform_attr_list_hash_new(const char *info)
+{
+ return BLI_ghash_new(uniform_attr_list_hash, uniform_attr_list_cmp, info);
+}
+
+void GPU_uniform_attr_list_copy(GPUUniformAttrList *dest, GPUUniformAttrList *src)
+{
+ dest->count = src->count;
+ dest->hash_code = src->hash_code;
+ BLI_duplicatelist(&dest->list, &src->list);
+}
+
+void GPU_uniform_attr_list_free(GPUUniformAttrList *set)
+{
+ set->count = 0;
+ set->hash_code = 0;
+ BLI_freelistN(&set->list);
+}
+
+void gpu_node_graph_finalize_uniform_attrs(GPUNodeGraph *graph)
+{
+ GPUUniformAttrList *attrs = &graph->uniform_attrs;
+ BLI_assert(attrs->count == BLI_listbase_count(&attrs->list));
+
+ /* Sort the attributes by name to ensure a stable order. */
+ BLI_listbase_sort(&attrs->list, uniform_attr_sort_cmp);
+
+ /* Compute the indices and the hash code. */
+ int next_id = 0;
+ attrs->hash_code = 0;
+
+ LISTBASE_FOREACH (GPUUniformAttr *, attr, &attrs->list) {
+ attr->id = next_id++;
+
+ attrs->hash_code ^= BLI_ghashutil_strhash_p(attr->name);
+
+ if (attr->use_dupli) {
+ attrs->hash_code ^= BLI_ghashutil_uinthash(attr->id);
+ }
+ }
+}
+
/* Attributes and Textures */
+/** Add a new varying attribute of given type and name. Returns NULL if out of slots. */
static GPUMaterialAttribute *gpu_node_graph_add_attribute(GPUNodeGraph *graph,
CustomDataType type,
const char *name)
@@ -296,6 +385,38 @@ static GPUMaterialAttribute *gpu_node_graph_add_attribute(GPUNodeGraph *graph,
return attr;
}
+/** Add a new uniform attribute of given type and name. Returns NULL if out of slots. */
+static GPUUniformAttr *gpu_node_graph_add_uniform_attribute(GPUNodeGraph *graph,
+ const char *name,
+ bool use_dupli)
+{
+ /* Find existing attribute. */
+ GPUUniformAttrList *attrs = &graph->uniform_attrs;
+ GPUUniformAttr *attr = attrs->list.first;
+
+ for (; attr; attr = attr->next) {
+ if (STREQ(attr->name, name) && attr->use_dupli == use_dupli) {
+ break;
+ }
+ }
+
+ /* Add new requested attribute if it's within GPU limits. */
+ if (attr == NULL && attrs->count < GPU_MAX_UNIFORM_ATTR) {
+ attr = MEM_callocN(sizeof(*attr), __func__);
+ STRNCPY(attr->name, name);
+ attr->use_dupli = use_dupli;
+ attr->id = -1;
+ BLI_addtail(&attrs->list, attr);
+ attrs->count++;
+ }
+
+ if (attr != NULL) {
+ attr->users++;
+ }
+
+ return attr;
+}
+
static GPUMaterialTexture *gpu_node_graph_add_texture(GPUNodeGraph *graph,
Image *ima,
ImageUser *iuser,
@@ -369,6 +490,7 @@ GPUNodeLink *GPU_attribute(GPUMaterial *mat, const CustomDataType type, const ch
GPUNodeGraph *graph = gpu_material_node_graph(mat);
GPUMaterialAttribute *attr = gpu_node_graph_add_attribute(graph, type, name);
+ /* Dummy fallback if out of slots. */
if (attr == NULL) {
static const float zero_data[GPU_MAX_CONSTANT_DATA] = {0.0f};
return GPU_constant(zero_data);
@@ -380,6 +502,23 @@ GPUNodeLink *GPU_attribute(GPUMaterial *mat, const CustomDataType type, const ch
return link;
}
+GPUNodeLink *GPU_uniform_attribute(GPUMaterial *mat, const char *name, bool use_dupli)
+{
+ GPUNodeGraph *graph = gpu_material_node_graph(mat);
+ GPUUniformAttr *attr = gpu_node_graph_add_uniform_attribute(graph, name, use_dupli);
+
+ /* Dummy fallback if out of slots. */
+ if (attr == NULL) {
+ static const float zero_data[GPU_MAX_CONSTANT_DATA] = {0.0f};
+ return GPU_constant(zero_data);
+ }
+
+ GPUNodeLink *link = gpu_node_link_create();
+ link->link_type = GPU_NODE_LINK_UNIFORM_ATTR;
+ link->uniform_attr = attr;
+ return link;
+}
+
GPUNodeLink *GPU_constant(const float *num)
{
GPUNodeLink *link = gpu_node_link_create();
@@ -616,6 +755,9 @@ static void gpu_inputs_free(ListBase *inputs)
if (input->source == GPU_SOURCE_ATTR) {
input->attr->users--;
}
+ else if (input->source == GPU_SOURCE_UNIFORM_ATTR) {
+ input->uniform_attr->users--;
+ }
else if (ELEM(input->source, GPU_SOURCE_TEX, GPU_SOURCE_TEX_TILED_MAPPING)) {
input->texture->users--;
}
@@ -671,6 +813,7 @@ void gpu_node_graph_free(GPUNodeGraph *graph)
BLI_freelistN(&graph->volume_grids);
BLI_freelistN(&graph->textures);
BLI_freelistN(&graph->attributes);
+ GPU_uniform_attr_list_free(&graph->uniform_attrs);
}
/* Prune Unused Nodes */
@@ -735,4 +878,13 @@ void gpu_node_graph_prune_unused(GPUNodeGraph *graph)
BLI_freelinkN(&graph->volume_grids, grid);
}
}
+
+ GPUUniformAttrList *uattrs = &graph->uniform_attrs;
+
+ LISTBASE_FOREACH_MUTABLE (GPUUniformAttr *, attr, &uattrs->list) {
+ if (attr->users == 0) {
+ BLI_freelinkN(&uattrs->list, attr);
+ uattrs->count--;
+ }
+ }
}
diff --git a/source/blender/gpu/intern/gpu_node_graph.h b/source/blender/gpu/intern/gpu_node_graph.h
index 7265abf4d65..a0e6298cd92 100644
--- a/source/blender/gpu/intern/gpu_node_graph.h
+++ b/source/blender/gpu/intern/gpu_node_graph.h
@@ -42,6 +42,7 @@ typedef enum eGPUDataSource {
GPU_SOURCE_CONSTANT,
GPU_SOURCE_UNIFORM,
GPU_SOURCE_ATTR,
+ GPU_SOURCE_UNIFORM_ATTR,
GPU_SOURCE_BUILTIN,
GPU_SOURCE_STRUCT,
GPU_SOURCE_TEX,
@@ -53,6 +54,7 @@ typedef enum eGPUDataSource {
typedef enum {
GPU_NODE_LINK_NONE = 0,
GPU_NODE_LINK_ATTR,
+ GPU_NODE_LINK_UNIFORM_ATTR,
GPU_NODE_LINK_BUILTIN,
GPU_NODE_LINK_COLORBAND,
GPU_NODE_LINK_CONSTANT,
@@ -96,6 +98,8 @@ struct GPUNodeLink {
struct GPUOutput *output;
/* GPU_NODE_LINK_ATTR */
struct GPUMaterialAttribute *attr;
+ /* GPU_NODE_LINK_UNIFORM_ATTR */
+ struct GPUUniformAttr *uniform_attr;
/* GPU_NODE_LINK_IMAGE_BLENDER */
struct GPUMaterialTexture *texture;
};
@@ -130,6 +134,8 @@ typedef struct GPUInput {
struct GPUMaterialTexture *texture;
/* GPU_SOURCE_ATTR */
struct GPUMaterialAttribute *attr;
+ /* GPU_SOURCE_UNIFORM_ATTR */
+ struct GPUUniformAttr *uniform_attr;
/* GPU_SOURCE_VOLUME_GRID | GPU_SOURCE_VOLUME_GRID_TRANSFORM */
struct GPUMaterialVolumeGrid *volume_grid;
};
@@ -146,11 +152,15 @@ typedef struct GPUNodeGraph {
ListBase attributes;
ListBase textures;
ListBase volume_grids;
+
+ /* The list of uniform attributes. */
+ GPUUniformAttrList uniform_attrs;
} GPUNodeGraph;
/* Node Graph */
void gpu_node_graph_prune_unused(GPUNodeGraph *graph);
+void gpu_node_graph_finalize_uniform_attrs(GPUNodeGraph *graph);
void gpu_node_graph_free_nodes(GPUNodeGraph *graph);
void gpu_node_graph_free(GPUNodeGraph *graph);
diff --git a/source/blender/gpu/intern/gpu_platform.cc b/source/blender/gpu/intern/gpu_platform.cc
index ad7142878e7..6b9878f2ba4 100644
--- a/source/blender/gpu/intern/gpu_platform.cc
+++ b/source/blender/gpu/intern/gpu_platform.cc
@@ -77,7 +77,7 @@ void GPUPlatformGlobal::create_gpu_name(const char *vendor,
BLI_str_replace_char(gpu_name, '\r', ' ');
}
-void GPUPlatformGlobal::clear(void)
+void GPUPlatformGlobal::clear()
{
MEM_SAFE_FREE(GPG.support_key);
MEM_SAFE_FREE(GPG.gpu_name);
@@ -94,12 +94,12 @@ void GPUPlatformGlobal::clear(void)
using namespace blender::gpu;
-eGPUSupportLevel GPU_platform_support_level(void)
+eGPUSupportLevel GPU_platform_support_level()
{
return GPG.support_level;
}
-const char *GPU_platform_support_level_key(void)
+const char *GPU_platform_support_level_key()
{
return GPG.support_key;
}
diff --git a/source/blender/gpu/intern/gpu_select_sample_query.cc b/source/blender/gpu/intern/gpu_select_sample_query.cc
index 5bbf3bd05d3..6ca811895a5 100644
--- a/source/blender/gpu/intern/gpu_select_sample_query.cc
+++ b/source/blender/gpu/intern/gpu_select_sample_query.cc
@@ -70,7 +70,7 @@ typedef struct GPUSelectQueryState {
eGPUDepthTest depth_test;
} GPUSelectQueryState;
-static GPUSelectQueryState g_query_state = {0};
+static GPUSelectQueryState g_query_state = {false};
void gpu_select_query_begin(
uint (*buffer)[4], uint bufsize, const rcti *input, char mode, int oldhits)
diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc
index c13321ed205..49f96cb652c 100644
--- a/source/blender/gpu/intern/gpu_shader.cc
+++ b/source/blender/gpu/intern/gpu_shader.cc
@@ -291,7 +291,7 @@ GPUShader *GPU_shader_create_ex(const char *vertcode,
const char *shname)
{
/* At least a vertex shader and a fragment shader are required. */
- BLI_assert((fragcode != NULL) && (vertcode != NULL));
+ BLI_assert((fragcode != nullptr) && (vertcode != nullptr));
Shader *shader = GPUBackend::get()->shader_alloc(shname);
@@ -342,14 +342,14 @@ GPUShader *GPU_shader_create_ex(const char *vertcode,
shader->geometry_shader_from_glsl(sources);
}
- if (tf_names != NULL && tf_count > 0) {
+ if (tf_names != nullptr && tf_count > 0) {
BLI_assert(tf_type != GPU_SHADER_TFB_NONE);
shader->transform_feedback_names_set(Span<const char *>(tf_names, tf_count), tf_type);
}
if (!shader->finalize()) {
delete shader;
- return NULL;
+ return nullptr;
};
return wrap(shader);
@@ -374,7 +374,7 @@ GPUShader *GPU_shader_create(const char *vertcode,
const char *shname)
{
return GPU_shader_create_ex(
- vertcode, fragcode, geomcode, libcode, defines, GPU_SHADER_TFB_NONE, NULL, 0, shname);
+ vertcode, fragcode, geomcode, libcode, defines, GPU_SHADER_TFB_NONE, nullptr, 0, shname);
}
GPUShader *GPU_shader_create_from_python(const char *vertcode,
@@ -383,17 +383,24 @@ GPUShader *GPU_shader_create_from_python(const char *vertcode,
const char *libcode,
const char *defines)
{
- char *libcodecat = NULL;
+ char *libcodecat = nullptr;
- if (libcode == NULL) {
+ if (libcode == nullptr) {
libcode = datatoc_gpu_shader_colorspace_lib_glsl;
}
else {
libcode = libcodecat = BLI_strdupcat(libcode, datatoc_gpu_shader_colorspace_lib_glsl);
}
- GPUShader *sh = GPU_shader_create_ex(
- vertcode, fragcode, geomcode, libcode, defines, GPU_SHADER_TFB_NONE, NULL, 0, "pyGPUShader");
+ GPUShader *sh = GPU_shader_create_ex(vertcode,
+ fragcode,
+ geomcode,
+ libcode,
+ defines,
+ GPU_SHADER_TFB_NONE,
+ nullptr,
+ 0,
+ "pyGPUShader");
MEM_SAFE_FREE(libcodecat);
return sh;
@@ -402,9 +409,9 @@ GPUShader *GPU_shader_create_from_python(const char *vertcode,
static const char *string_join_array_maybe_alloc(const char **str_arr, bool *r_is_alloc)
{
bool is_alloc = false;
- if (str_arr == NULL) {
+ if (str_arr == nullptr) {
*r_is_alloc = false;
- return NULL;
+ return nullptr;
}
/* Skip empty strings (avoid alloc if we can). */
while (str_arr[0] && str_arr[0][0] == '\0') {
@@ -450,7 +457,7 @@ struct GPUShader *GPU_shader_create_from_arrays_impl(
struct {
const char *str;
bool is_alloc;
- } str_dst[4] = {{0}};
+ } str_dst[4] = {{nullptr}};
const char **str_src[4] = {params->vert, params->frag, params->geom, params->defs};
for (int i = 0; i < ARRAY_SIZE(str_src); i++) {
@@ -461,7 +468,7 @@ struct GPUShader *GPU_shader_create_from_arrays_impl(
BLI_snprintf(name, sizeof(name), "%s_%d", func, line);
GPUShader *sh = GPU_shader_create(
- str_dst[0].str, str_dst[1].str, str_dst[2].str, NULL, str_dst[3].str, name);
+ str_dst[0].str, str_dst[1].str, str_dst[2].str, nullptr, str_dst[3].str, name);
for (int i = 0; i < ARRAY_SIZE(str_dst); i++) {
if (str_dst[i].is_alloc) {
@@ -502,7 +509,7 @@ void GPU_shader_unbind(void)
if (ctx->shader) {
ctx->shader->unbind();
}
- ctx->shader = NULL;
+ ctx->shader = nullptr;
#endif
}
diff --git a/source/blender/gpu/intern/gpu_shader_interface.cc b/source/blender/gpu/intern/gpu_shader_interface.cc
index e5fb8025e7f..81c1e013877 100644
--- a/source/blender/gpu/intern/gpu_shader_interface.cc
+++ b/source/blender/gpu/intern/gpu_shader_interface.cc
@@ -32,12 +32,12 @@
namespace blender::gpu {
-ShaderInterface::ShaderInterface(void)
+ShaderInterface::ShaderInterface()
{
/* TODO(fclem): add unique ID for debugging. */
}
-ShaderInterface::~ShaderInterface(void)
+ShaderInterface::~ShaderInterface()
{
/* Free memory used by name_buffer. */
MEM_freeN(name_buffer_);
@@ -70,14 +70,14 @@ static void sort_input_list(MutableSpan<ShaderInput> dst)
/* Sorts all inputs inside their respective array.
* This is to allow fast hash collision detection.
* See ShaderInterface::input_lookup for more details. */
-void ShaderInterface::sort_inputs(void)
+void ShaderInterface::sort_inputs()
{
sort_input_list(MutableSpan<ShaderInput>(inputs_, attr_len_));
sort_input_list(MutableSpan<ShaderInput>(inputs_ + attr_len_, ubo_len_));
sort_input_list(MutableSpan<ShaderInput>(inputs_ + attr_len_ + ubo_len_, uniform_len_));
}
-void ShaderInterface::debug_print(void)
+void ShaderInterface::debug_print()
{
Span<ShaderInput> attrs = Span<ShaderInput>(inputs_, attr_len_);
Span<ShaderInput> ubos = Span<ShaderInput>(inputs_ + attr_len_, ubo_len_);
diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc
index 0b2e4989a33..407a8dd6e2b 100644
--- a/source/blender/gpu/intern/gpu_state.cc
+++ b/source/blender/gpu/intern/gpu_state.cc
@@ -260,7 +260,7 @@ eGPUStencilTest GPU_stencil_test_get()
}
/* NOTE: Already premultiplied by U.pixelsize. */
-float GPU_line_width_get(void)
+float GPU_line_width_get()
{
GPUStateMutable &state = Context::get()->state_manager->mutable_state;
return state.line_width;
@@ -285,13 +285,13 @@ void GPU_viewport_size_get_i(int coords[4])
Context::get()->active_fb->viewport_get(coords);
}
-bool GPU_depth_mask_get(void)
+bool GPU_depth_mask_get()
{
GPUState &state = Context::get()->state_manager->state;
return (state.write_mask & GPU_WRITE_DEPTH) != 0;
}
-bool GPU_mipmap_enabled(void)
+bool GPU_mipmap_enabled()
{
/* TODO(fclem): this used to be a userdef option. */
return true;
@@ -303,17 +303,17 @@ bool GPU_mipmap_enabled(void)
/** \name Context Utils
* \{ */
-void GPU_flush(void)
+void GPU_flush()
{
Context::get()->flush();
}
-void GPU_finish(void)
+void GPU_finish()
{
Context::get()->finish();
}
-void GPU_apply_state(void)
+void GPU_apply_state()
{
Context::get()->state_manager->apply_state();
}
@@ -328,7 +328,7 @@ void GPU_apply_state(void)
* bgl functions.
* \{ */
-void GPU_bgl_start(void)
+void GPU_bgl_start()
{
Context *ctx = Context::get();
if (!(ctx && ctx->state_manager)) {
@@ -345,7 +345,7 @@ void GPU_bgl_start(void)
}
/* Just turn off the bgl safeguard system. Can be called even without GPU_bgl_start. */
-void GPU_bgl_end(void)
+void GPU_bgl_end()
{
Context *ctx = Context::get();
if (!(ctx && ctx->state_manager)) {
@@ -359,7 +359,7 @@ void GPU_bgl_end(void)
}
}
-bool GPU_bgl_get(void)
+bool GPU_bgl_get()
{
return Context::get()->state_manager->use_bgl;
}
@@ -381,7 +381,7 @@ void GPU_memory_barrier(eGPUBarrier barrier)
/** \name Default State
* \{ */
-StateManager::StateManager(void)
+StateManager::StateManager()
{
/* Set default state. */
state.write_mask = GPU_WRITE_COLOR;
diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc
index 99d286c3abd..d134d718cbe 100644
--- a/source/blender/gpu/intern/gpu_texture.cc
+++ b/source/blender/gpu/intern/gpu_texture.cc
@@ -49,14 +49,14 @@ Texture::Texture(const char *name)
}
for (int i = 0; i < ARRAY_SIZE(fb_); i++) {
- fb_[i] = NULL;
+ fb_[i] = nullptr;
}
}
Texture::~Texture()
{
for (int i = 0; i < ARRAY_SIZE(fb_); i++) {
- if (fb_[i] != NULL) {
+ if (fb_[i] != nullptr) {
fb_[i]->attachment_remove(fb_attachment_[i]);
}
}
@@ -142,7 +142,7 @@ bool Texture::init_buffer(GPUVertBuf *vbo, eGPUTextureFormat format)
void Texture::attach_to(FrameBuffer *fb, GPUAttachmentType type)
{
for (int i = 0; i < ARRAY_SIZE(fb_); i++) {
- if (fb_[i] == NULL) {
+ if (fb_[i] == nullptr) {
fb_attachment_[i] = type;
fb_[i] = fb;
return;
@@ -156,7 +156,7 @@ void Texture::detach_from(FrameBuffer *fb)
for (int i = 0; i < ARRAY_SIZE(fb_); i++) {
if (fb_[i] == fb) {
fb_[i]->attachment_remove(fb_attachment_[i]);
- fb_[i] = NULL;
+ fb_[i] = nullptr;
return;
}
}
@@ -226,7 +226,7 @@ static inline GPUTexture *gpu_texture_create(const char *name,
if (!success) {
delete tex;
- return NULL;
+ return nullptr;
}
if (pixels) {
tex->update(data_format, pixels);
@@ -295,7 +295,7 @@ GPUTexture *GPU_texture_create_compressed_2d(
if (!success) {
delete tex;
- return NULL;
+ return nullptr;
}
if (data) {
size_t ofs = 0;
@@ -320,7 +320,7 @@ GPUTexture *GPU_texture_create_from_vertbuf(const char *name, GPUVertBuf *vert)
bool success = tex->init_buffer(vert, tex_format);
if (!success) {
delete tex;
- return NULL;
+ return nullptr;
}
return reinterpret_cast<GPUTexture *>(tex);
}
@@ -383,7 +383,7 @@ void *GPU_texture_read(GPUTexture *tex_, eGPUDataFormat data_format, int miplvl)
*/
void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
{
- BLI_assert(data != NULL); /* Do not accept NULL as parameter. */
+ BLI_assert(data != nullptr); /* Do not accept NULL as parameter. */
reinterpret_cast<Texture *>(tex)->clear(data_format, data);
}
diff --git a/source/blender/gpu/intern/gpu_uniform_buffer.cc b/source/blender/gpu/intern/gpu_uniform_buffer.cc
index 2dea98f03ca..89c70c47e4a 100644
--- a/source/blender/gpu/intern/gpu_uniform_buffer.cc
+++ b/source/blender/gpu/intern/gpu_uniform_buffer.cc
@@ -73,7 +73,7 @@ static eGPUType get_padded_gpu_type(LinkData *link)
GPUInput *input = (GPUInput *)link->data;
eGPUType gputype = input->type;
/* Unless the vec3 is followed by a float we need to treat it as a vec4. */
- if (gputype == GPU_VEC3 && (link->next != NULL) &&
+ if (gputype == GPU_VEC3 && (link->next != nullptr) &&
(((GPUInput *)link->next->data)->type != GPU_FLOAT)) {
gputype = GPU_VEC4;
}
@@ -106,7 +106,7 @@ static void buffer_from_list_inputs_sort(ListBase *inputs)
BLI_listbase_sort(inputs, inputs_cmp);
/* Creates a lookup table for the different types; */
- LinkData *inputs_lookup[MAX_UBO_GPU_TYPE + 1] = {NULL};
+ LinkData *inputs_lookup[MAX_UBO_GPU_TYPE + 1] = {nullptr};
eGPUType cur_type = static_cast<eGPUType>(MAX_UBO_GPU_TYPE + 1);
LISTBASE_FOREACH (LinkData *, link, inputs) {
@@ -131,21 +131,21 @@ static void buffer_from_list_inputs_sort(ListBase *inputs)
}
/* If there is no GPU_VEC3 there is no need for alignment. */
- if (inputs_lookup[GPU_VEC3] == NULL) {
+ if (inputs_lookup[GPU_VEC3] == nullptr) {
return;
}
LinkData *link = inputs_lookup[GPU_VEC3];
- while (link != NULL && ((GPUInput *)link->data)->type == GPU_VEC3) {
+ while (link != nullptr && ((GPUInput *)link->data)->type == GPU_VEC3) {
LinkData *link_next = link->next;
/* If GPU_VEC3 is followed by nothing or a GPU_FLOAT, no need for alignment. */
- if ((link_next == NULL) || ((GPUInput *)link_next->data)->type == GPU_FLOAT) {
+ if ((link_next == nullptr) || ((GPUInput *)link_next->data)->type == GPU_FLOAT) {
break;
}
/* If there is a float, move it next to current vec3. */
- if (inputs_lookup[GPU_FLOAT] != NULL) {
+ if (inputs_lookup[GPU_FLOAT] != nullptr) {
LinkData *float_input = inputs_lookup[GPU_FLOAT];
inputs_lookup[GPU_FLOAT] = float_input->next;
@@ -195,7 +195,7 @@ GPUUniformBuf *GPU_uniformbuf_create_ex(size_t size, const void *data, const cha
{
UniformBuf *ubo = GPUBackend::get()->uniformbuf_alloc(size, name);
/* Direct init. */
- if (data != NULL) {
+ if (data != nullptr) {
ubo->update(data);
}
return wrap(ubo);
@@ -211,7 +211,7 @@ GPUUniformBuf *GPU_uniformbuf_create_from_list(ListBase *inputs, const char *nam
{
/* There is no point on creating an UBO if there is no arguments. */
if (BLI_listbase_is_empty(inputs)) {
- return NULL;
+ return nullptr;
}
buffer_from_list_inputs_sort(inputs);
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.cc b/source/blender/gpu/intern/gpu_vertex_buffer.cc
index 29fa8a89d27..09b9eba9f95 100644
--- a/source/blender/gpu/intern/gpu_vertex_buffer.cc
+++ b/source/blender/gpu/intern/gpu_vertex_buffer.cc
@@ -66,13 +66,13 @@ void VertBuf::init(const GPUVertFormat *format, GPUUsageType usage)
flag |= GPU_VERTBUF_INIT;
}
-void VertBuf::clear(void)
+void VertBuf::clear()
{
this->release_data();
flag = GPU_VERTBUF_INVALID;
}
-VertBuf *VertBuf::duplicate(void)
+VertBuf *VertBuf::duplicate()
{
VertBuf *dst = GPUBackend::get()->vertbuf_alloc();
/* Full copy. */
@@ -107,7 +107,7 @@ void VertBuf::resize(uint vert_len)
flag |= GPU_VERTBUF_DATA_DIRTY;
}
-void VertBuf::upload(void)
+void VertBuf::upload()
{
this->upload_data();
}
@@ -125,7 +125,7 @@ using namespace blender::gpu;
/* -------- Creation & deletion -------- */
-GPUVertBuf *GPU_vertbuf_calloc(void)
+GPUVertBuf *GPU_vertbuf_calloc()
{
return wrap(GPUBackend::get()->vertbuf_alloc());
}
@@ -191,7 +191,7 @@ void GPU_vertbuf_data_resize(GPUVertBuf *verts, uint v_len)
void GPU_vertbuf_data_len_set(GPUVertBuf *verts_, uint v_len)
{
VertBuf *verts = unwrap(verts_);
- BLI_assert(verts->data != NULL); /* Only for dynamic data. */
+ BLI_assert(verts->data != nullptr); /* Only for dynamic data. */
BLI_assert(v_len <= verts->vertex_alloc);
verts->vertex_len = v_len;
}
@@ -203,7 +203,7 @@ void GPU_vertbuf_attr_set(GPUVertBuf *verts_, uint a_idx, uint v_idx, const void
const GPUVertAttr *a = &format->attrs[a_idx];
BLI_assert(v_idx < verts->vertex_alloc);
BLI_assert(a_idx < format->attr_len);
- BLI_assert(verts->data != NULL);
+ BLI_assert(verts->data != nullptr);
verts->flag |= GPU_VERTBUF_DATA_DIRTY;
memcpy(verts->data + a->offset + v_idx * format->stride, data, a->sz);
}
@@ -225,7 +225,7 @@ void GPU_vertbuf_vert_set(GPUVertBuf *verts_, uint v_idx, const void *data)
VertBuf *verts = unwrap(verts_);
const GPUVertFormat *format = &verts->format;
BLI_assert(v_idx < verts->vertex_alloc);
- BLI_assert(verts->data != NULL);
+ BLI_assert(verts->data != nullptr);
verts->flag |= GPU_VERTBUF_DATA_DIRTY;
memcpy(verts->data + v_idx * format->stride, data, format->stride);
}
@@ -236,7 +236,7 @@ void GPU_vertbuf_attr_fill_stride(GPUVertBuf *verts_, uint a_idx, uint stride, c
const GPUVertFormat *format = &verts->format;
const GPUVertAttr *a = &format->attrs[a_idx];
BLI_assert(a_idx < format->attr_len);
- BLI_assert(verts->data != NULL);
+ BLI_assert(verts->data != nullptr);
verts->flag |= GPU_VERTBUF_DATA_DIRTY;
const uint vertex_len = verts->vertex_len;
@@ -259,7 +259,7 @@ void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *verts_, uint a_idx, GPUVertBufRaw
const GPUVertFormat *format = &verts->format;
const GPUVertAttr *a = &format->attrs[a_idx];
BLI_assert(a_idx < format->attr_len);
- BLI_assert(verts->data != NULL);
+ BLI_assert(verts->data != nullptr);
verts->flag |= GPU_VERTBUF_DATA_DIRTY;
verts->flag &= ~GPU_VERTBUF_DATA_UPLOADED;
@@ -313,7 +313,7 @@ GPUVertBufStatus GPU_vertbuf_get_status(const GPUVertBuf *verts)
return unwrap(verts)->flag;
}
-uint GPU_vertbuf_get_memory_usage(void)
+uint GPU_vertbuf_get_memory_usage()
{
return VertBuf::memory_usage;
}
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index 9063c8bdbce..188c8786665 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -1023,6 +1023,9 @@ void GPU_viewport_free(GPUViewport *viewport)
}
BLI_memblock_destroy(viewport->vmempool.images, NULL);
}
+ if (viewport->vmempool.obattrs_ubo_pool != NULL) {
+ DRW_uniform_attrs_pool_free(viewport->vmempool.obattrs_ubo_pool);
+ }
for (int i = 0; i < viewport->vmempool.ubo_len; i++) {
GPU_uniformbuf_free(viewport->vmempool.matrices_ubo[i]);
diff --git a/source/blender/gpu/opengl/gl_backend.cc b/source/blender/gpu/opengl/gl_backend.cc
index 46e048d7f7c..b444bd1859d 100644
--- a/source/blender/gpu/opengl/gl_backend.cc
+++ b/source/blender/gpu/opengl/gl_backend.cc
@@ -38,7 +38,7 @@ namespace blender::gpu {
/** \name Platform
* \{ */
-void GLBackend::platform_init(void)
+void GLBackend::platform_init()
{
BLI_assert(!GPG.initialized);
GPG.initialized = true;
@@ -135,7 +135,7 @@ void GLBackend::platform_init(void)
GPG.create_gpu_name(vendor, renderer, version);
}
-void GLBackend::platform_exit(void)
+void GLBackend::platform_exit()
{
BLI_assert(GPG.initialized);
GPG.clear();
@@ -147,7 +147,7 @@ void GLBackend::platform_exit(void)
/** \name Capabilities
* \{ */
-static bool detect_mip_render_workaround(void)
+static bool detect_mip_render_workaround()
{
int cube_size = 2;
float clear_color[4] = {1.0f, 0.5f, 0.0f, 0.0f};
@@ -192,7 +192,7 @@ static bool detect_mip_render_workaround(void)
return enable_workaround;
}
-static void detect_workarounds(void)
+static void detect_workarounds()
{
const char *vendor = (const char *)glGetString(GL_VENDOR);
const char *renderer = (const char *)glGetString(GL_RENDERER);
@@ -376,7 +376,7 @@ bool GLContext::debug_layer_workaround = false;
bool GLContext::unused_fb_slot_workaround = false;
float GLContext::derivative_signs[2] = {1.0f, 1.0f};
-void GLBackend::capabilities_init(void)
+void GLBackend::capabilities_init()
{
BLI_assert(GLEW_VERSION_3_3);
/* Common Capabilities. */
diff --git a/source/blender/gpu/opengl/gl_batch.cc b/source/blender/gpu/opengl/gl_batch.cc
index 6f36f128d18..89486b73b05 100644
--- a/source/blender/gpu/opengl/gl_batch.cc
+++ b/source/blender/gpu/opengl/gl_batch.cc
@@ -50,7 +50,7 @@ using namespace blender::gpu;
* TODO(fclem): Could be revisited to avoid so much cross references.
* \{ */
-GLVaoCache::GLVaoCache(void)
+GLVaoCache::GLVaoCache()
{
init();
}
@@ -60,13 +60,13 @@ GLVaoCache::~GLVaoCache()
this->clear();
}
-void GLVaoCache::init(void)
+void GLVaoCache::init()
{
- context_ = NULL;
- interface_ = NULL;
+ context_ = nullptr;
+ interface_ = nullptr;
is_dynamic_vao_count = false;
for (int i = 0; i < GPU_VAO_STATIC_LEN; i++) {
- static_vaos.interfaces[i] = NULL;
+ static_vaos.interfaces[i] = nullptr;
static_vaos.vao_ids[i] = 0;
}
vao_base_instance_ = 0;
@@ -93,7 +93,7 @@ void GLVaoCache::insert(const GLShaderInterface *interface, GLuint vao)
else {
/* Erase previous entries, they will be added back if drawn again. */
for (int i = 0; i < GPU_VAO_STATIC_LEN; i++) {
- if (static_vaos.interfaces[i] != NULL) {
+ if (static_vaos.interfaces[i] != nullptr) {
const_cast<GLShaderInterface *>(static_vaos.interfaces[i])->ref_remove(this);
context_->vao_free(static_vaos.vao_ids[i]);
}
@@ -143,13 +143,13 @@ void GLVaoCache::remove(const GLShaderInterface *interface)
if (interfaces[i] == interface) {
context_->vao_free(vaos[i]);
vaos[i] = 0;
- interfaces[i] = NULL;
+ interfaces[i] = nullptr;
break; /* cannot have duplicates */
}
}
}
-void GLVaoCache::clear(void)
+void GLVaoCache::clear()
{
GLContext *ctx = GLContext::get();
const int count = (is_dynamic_vao_count) ? dynamic_vaos.count : GPU_VAO_STATIC_LEN;
@@ -157,7 +157,7 @@ void GLVaoCache::clear(void)
const GLShaderInterface **interfaces = (is_dynamic_vao_count) ? dynamic_vaos.interfaces :
static_vaos.interfaces;
/* Early out, nothing to free. */
- if (context_ == NULL) {
+ if (context_ == nullptr) {
return;
}
@@ -174,7 +174,7 @@ void GLVaoCache::clear(void)
}
for (int i = 0; i < count; i++) {
- if (interfaces[i] != NULL) {
+ if (interfaces[i] != nullptr) {
const_cast<GLShaderInterface *>(interfaces[i])->ref_remove(this);
}
}
@@ -207,13 +207,13 @@ GLuint GLVaoCache::lookup(const GLShaderInterface *interface)
/* The GLVaoCache object is only valid for one GLContext.
* Reset the cache if trying to draw in another context; */
-void GLVaoCache::context_check(void)
+void GLVaoCache::context_check()
{
GLContext *ctx = GLContext::get();
BLI_assert(ctx);
if (context_ != ctx) {
- if (context_ != NULL) {
+ if (context_ != nullptr) {
/* IMPORTANT: Trying to draw a batch in multiple different context will trash the VAO cache.
* This has major performance impact and should be avoided in most cases. */
context_->vao_cache_unregister(this);
@@ -282,7 +282,7 @@ GLuint GLVaoCache::vao_get(GPUBatch *batch)
/** \name Creation & Deletion
* \{ */
-GLBatch::GLBatch(void)
+GLBatch::GLBatch()
{
}
@@ -307,7 +307,7 @@ void GLBatch::bind(int i_first)
#if GPU_TRACK_INDEX_RANGE
/* Can be removed if GL 4.3 is required. */
- if (!GLContext::fixed_restart_index_support && (elem != NULL)) {
+ if (!GLContext::fixed_restart_index_support && (elem != nullptr)) {
glPrimitiveRestartIndex(this->elem_()->restart_index());
}
#endif
diff --git a/source/blender/gpu/opengl/gl_context.cc b/source/blender/gpu/opengl/gl_context.cc
index 9c98953f469..d766e6f0828 100644
--- a/source/blender/gpu/opengl/gl_context.cc
+++ b/source/blender/gpu/opengl/gl_context.cc
@@ -121,7 +121,7 @@ GLContext::~GLContext()
/** \name Activate / Deactivate context
* \{ */
-void GLContext::activate(void)
+void GLContext::activate()
{
/* Make sure no other context is already bound to this thread. */
BLI_assert(is_active_ == false);
@@ -160,7 +160,7 @@ void GLContext::activate(void)
immActivate();
}
-void GLContext::deactivate(void)
+void GLContext::deactivate()
{
immDeactivate();
is_active_ = false;
@@ -172,12 +172,12 @@ void GLContext::deactivate(void)
/** \name Flush, Finish & sync
* \{ */
-void GLContext::flush(void)
+void GLContext::flush()
{
glFlush();
}
-void GLContext::finish(void)
+void GLContext::finish()
{
glFinish();
}
@@ -191,7 +191,7 @@ void GLContext::finish(void)
* In this case we delay the deletion until the context is bound again.
* \{ */
-void GLSharedOrphanLists::orphans_clear(void)
+void GLSharedOrphanLists::orphans_clear()
{
/* Check if any context is active on this thread! */
BLI_assert(GLContext::get());
@@ -208,7 +208,7 @@ void GLSharedOrphanLists::orphans_clear(void)
lists_mutex.unlock();
};
-void GLContext::orphans_clear(void)
+void GLContext::orphans_clear()
{
/* Check if context has been activated by another thread! */
BLI_assert(this->is_active_on_thread());
diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc
index 5564cbbabae..4e45ff11fc7 100644
--- a/source/blender/gpu/opengl/gl_debug.cc
+++ b/source/blender/gpu/opengl/gl_debug.cc
@@ -141,7 +141,7 @@ static void APIENTRY debug_callback(GLenum UNUSED(source),
#undef APIENTRY
/* This function needs to be called once per context. */
-void init_gl_callbacks(void)
+void init_gl_callbacks()
{
CLOG_ENSURE(&LOG);
@@ -152,8 +152,8 @@ void init_gl_callbacks(void)
SNPRINTF(msg, format, GLEW_VERSION_4_3 ? "OpenGL 4.3" : "KHR_debug extension");
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
- glDebugMessageCallback((GLDEBUGPROC)debug_callback, NULL);
- glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
+ glDebugMessageCallback((GLDEBUGPROC)debug_callback, nullptr);
+ glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION,
GL_DEBUG_TYPE_MARKER,
0,
@@ -164,8 +164,8 @@ void init_gl_callbacks(void)
else if (GLEW_ARB_debug_output) {
SNPRINTF(msg, format, "ARB_debug_output");
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
- glDebugMessageCallbackARB((GLDEBUGPROCARB)debug_callback, NULL);
- glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
+ glDebugMessageCallbackARB((GLDEBUGPROCARB)debug_callback, nullptr);
+ glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
glDebugMessageInsertARB(GL_DEBUG_SOURCE_APPLICATION_ARB,
GL_DEBUG_TYPE_OTHER_ARB,
0,
@@ -213,7 +213,7 @@ void check_gl_error(const char *info)
default:
char msg[256];
SNPRINTF(msg, "Unknown GL error: %x : %s", error, info);
- debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, nullptr);
break;
}
}
@@ -250,7 +250,7 @@ void check_gl_resources(const char *info)
const char *sh_name = ctx->shader->name_get();
char msg[256];
SNPRINTF(msg, "Missing UBO bind at slot %d : %s > %s : %s", i, sh_name, ubo_name, info);
- debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, nullptr);
}
}
@@ -262,7 +262,7 @@ void check_gl_resources(const char *info)
const char *sh_name = ctx->shader->name_get();
char msg[256];
SNPRINTF(msg, "Missing Texture bind at slot %d : %s > %s : %s", i, sh_name, tex_name, info);
- debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, nullptr);
}
}
@@ -274,14 +274,14 @@ void check_gl_resources(const char *info)
const char *sh_name = ctx->shader->name_get();
char msg[256];
SNPRINTF(msg, "Missing Image bind at slot %d : %s > %s : %s", i, sh_name, tex_name, info);
- debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, nullptr);
}
}
}
void raise_gl_error(const char *info)
{
- debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, info, NULL);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, info, nullptr);
}
/** \} */
@@ -369,7 +369,7 @@ void GLContext::debug_group_begin(const char *name, int index)
}
}
-void GLContext::debug_group_end(void)
+void GLContext::debug_group_end()
{
if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
glPopDebugGroup();
diff --git a/source/blender/gpu/opengl/gl_debug_layer.cc b/source/blender/gpu/opengl/gl_debug_layer.cc
index a4dc4679b7e..188083b0f50 100644
--- a/source/blender/gpu/opengl/gl_debug_layer.cc
+++ b/source/blender/gpu/opengl/gl_debug_layer.cc
@@ -108,7 +108,7 @@ DEBUG_FUNC_DECLARE(PFNGLUSEPROGRAMPROC, void, glUseProgram, GLuint, program);
/* Init a fallback layer (to KHR_debug) that covers only some functions.
* We override the functions pointers by our own implementation that just checks glGetError.
* Some additional functions (not overridable) are covered inside the header using wrappers. */
-void init_debug_layer(void)
+void init_debug_layer()
{
#define DEBUG_WRAP(function) \
do { \
diff --git a/source/blender/gpu/opengl/gl_drawlist.cc b/source/blender/gpu/opengl/gl_drawlist.cc
index 990e1a8014b..aecadc4d14a 100644
--- a/source/blender/gpu/opengl/gl_drawlist.cc
+++ b/source/blender/gpu/opengl/gl_drawlist.cc
@@ -65,13 +65,13 @@ typedef struct GLDrawCommandIndexed {
GLDrawList::GLDrawList(int length)
{
BLI_assert(length > 0);
- batch_ = NULL;
+ batch_ = nullptr;
buffer_id_ = 0;
command_len_ = 0;
command_offset_ = 0;
data_offset_ = 0;
data_size_ = 0;
- data_ = NULL;
+ data_ = nullptr;
if (GLContext::multi_draw_indirect_support) {
/* Alloc the biggest possible command list, which is indexed. */
@@ -88,12 +88,12 @@ GLDrawList::~GLDrawList()
GLContext::buf_free(buffer_id_);
}
-void GLDrawList::init(void)
+void GLDrawList::init()
{
BLI_assert(GLContext::get());
BLI_assert(MDI_ENABLED);
- BLI_assert(data_ == NULL);
- batch_ = NULL;
+ BLI_assert(data_ == nullptr);
+ batch_ = nullptr;
command_len_ = 0;
if (buffer_id_ == 0) {
@@ -105,7 +105,7 @@ void GLDrawList::init(void)
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer_id_);
/* If buffer is full, orphan buffer data and start fresh. */
// if (command_offset_ >= data_size_) {
- glBufferData(GL_DRAW_INDIRECT_BUFFER, buffer_size_, NULL, GL_DYNAMIC_DRAW);
+ glBufferData(GL_DRAW_INDIRECT_BUFFER, buffer_size_, nullptr, GL_DYNAMIC_DRAW);
data_offset_ = 0;
// }
/* Map the remaining range. */
@@ -123,7 +123,7 @@ void GLDrawList::append(GPUBatch *gpu_batch, int i_first, int i_count)
return;
}
- if (data_ == NULL) {
+ if (data_ == nullptr) {
this->init();
}
@@ -169,7 +169,7 @@ void GLDrawList::append(GPUBatch *gpu_batch, int i_first, int i_count)
}
}
-void GLDrawList::submit(void)
+void GLDrawList::submit()
{
if (command_len_ == 0) {
return;
@@ -177,7 +177,7 @@ void GLDrawList::submit(void)
/* Something's wrong if we get here without MDI support. */
BLI_assert(MDI_ENABLED);
BLI_assert(data_);
- BLI_assert(GLContext::get()->shader != NULL);
+ BLI_assert(GLContext::get()->shader != nullptr);
/* Only do multi-draw indirect if doing more than 2 drawcall. This avoids the overhead of
* buffer mapping if scene is not very instance friendly. BUT we also need to take into
@@ -190,7 +190,7 @@ void GLDrawList::submit(void)
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer_id_);
glFlushMappedBufferRange(GL_DRAW_INDIRECT_BUFFER, 0, command_offset_);
glUnmapBuffer(GL_DRAW_INDIRECT_BUFFER);
- data_ = NULL; /* Unmapped */
+ data_ = nullptr; /* Unmapped */
data_offset_ += command_offset_;
batch_->bind(0);
@@ -227,7 +227,7 @@ void GLDrawList::submit(void)
/* Do not submit this buffer again. */
command_len_ = 0;
/* Avoid keeping reference to the batch. */
- batch_ = NULL;
+ batch_ = nullptr;
}
/** \} */
diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc
index a180aa270b0..cbb332388dc 100644
--- a/source/blender/gpu/opengl/gl_framebuffer.cc
+++ b/source/blender/gpu/opengl/gl_framebuffer.cc
@@ -72,7 +72,7 @@ GLFrameBuffer::GLFrameBuffer(
GLFrameBuffer::~GLFrameBuffer()
{
- if (context_ == NULL) {
+ if (context_ == nullptr) {
return;
}
@@ -92,7 +92,7 @@ GLFrameBuffer::~GLFrameBuffer()
}
}
-void GLFrameBuffer::init(void)
+void GLFrameBuffer::init()
{
context_ = GLContext::get();
state_manager_ = static_cast<GLStateManager *>(context_->state_manager);
@@ -154,7 +154,7 @@ bool GLFrameBuffer::check(char err_out[256])
return false;
}
-void GLFrameBuffer::update_attachments(void)
+void GLFrameBuffer::update_attachments()
{
/* Default frame-buffers cannot have attachments. */
BLI_assert(immutable_ == false);
@@ -176,7 +176,7 @@ void GLFrameBuffer::update_attachments(void)
first_attachment = (attach.tex) ? type : first_attachment;
}
- if (attach.tex == NULL) {
+ if (attach.tex == nullptr) {
glFramebufferTexture(GL_FRAMEBUFFER, gl_attachment, 0, 0);
continue;
}
@@ -208,7 +208,7 @@ void GLFrameBuffer::update_attachments(void)
for (int i = ARRAY_SIZE(gl_attachments_) - 1; i >= 0; --i) {
GPUAttachmentType type = GPU_FB_COLOR_ATTACHMENT0 + i;
GPUAttachment &attach = attachments_[type];
- if (attach.tex != NULL) {
+ if (attach.tex != nullptr) {
gl_tex = static_cast<GLTexture *>(unwrap(attach.tex))->tex_id_;
}
else if (gl_tex != 0) {
@@ -232,11 +232,11 @@ void GLFrameBuffer::update_attachments(void)
glDrawBuffers(ARRAY_SIZE(gl_attachments_), gl_attachments_);
if (G.debug & G_DEBUG_GPU) {
- BLI_assert(this->check(NULL));
+ BLI_assert(this->check(nullptr));
}
}
-void GLFrameBuffer::apply_state(void)
+void GLFrameBuffer::apply_state()
{
if (dirty_state_ == false) {
return;
@@ -410,7 +410,7 @@ void GLFrameBuffer::clear_multi(const float (*clear_cols)[4])
* TODO(fclem): fix this insecurity? */
int type = GPU_FB_COLOR_ATTACHMENT0;
for (int i = 0; type < GPU_FB_MAX_ATTACHMENT; i++, type++) {
- if (attachments_[type].tex != NULL) {
+ if (attachments_[type].tex != nullptr) {
this->clear_attachment(GPU_FB_COLOR_ATTACHMENT0 + i, GPU_DATA_FLOAT, clear_cols[i]);
}
}
diff --git a/source/blender/gpu/opengl/gl_framebuffer.hh b/source/blender/gpu/opengl/gl_framebuffer.hh
index cf159a60b01..1de366fc844 100644
--- a/source/blender/gpu/opengl/gl_framebuffer.hh
+++ b/source/blender/gpu/opengl/gl_framebuffer.hh
@@ -67,11 +67,11 @@ class GLFrameBuffer : public FrameBuffer {
/**
* Special frame-buffer encapsulating internal window frame-buffer.
* (i.e.: #GL_FRONT_LEFT, #GL_BACK_RIGHT, ...)
- * \param ctx: context the handle is from.
- * \param target: the internal GL name (i.e: #GL_BACK_LEFT).
- * \param fbo: the (optional) already created object for some implementation. Default is 0.
- * \param w: buffer width.
- * \param h: buffer height.
+ * \param ctx: Context the handle is from.
+ * \param target: The internal GL name (i.e: #GL_BACK_LEFT).
+ * \param fbo: The (optional) already created object for some implementation. Default is 0.
+ * \param w: Buffer width.
+ * \param h: Buffer height.
**/
GLFrameBuffer(const char *name, GLContext *ctx, GLenum target, GLuint fbo, int w, int h);
diff --git a/source/blender/gpu/opengl/gl_immediate.cc b/source/blender/gpu/opengl/gl_immediate.cc
index b71f8766dbb..63e3162944d 100644
--- a/source/blender/gpu/opengl/gl_immediate.cc
+++ b/source/blender/gpu/opengl/gl_immediate.cc
@@ -50,12 +50,12 @@ GLImmediate::GLImmediate()
buffer.buffer_size = DEFAULT_INTERNAL_BUFFER_SIZE;
glGenBuffers(1, &buffer.vbo_id);
glBindBuffer(GL_ARRAY_BUFFER, buffer.vbo_id);
- glBufferData(GL_ARRAY_BUFFER, buffer.buffer_size, NULL, GL_DYNAMIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, buffer.buffer_size, nullptr, GL_DYNAMIC_DRAW);
buffer_strict.buffer_size = DEFAULT_INTERNAL_BUFFER_SIZE;
glGenBuffers(1, &buffer_strict.vbo_id);
glBindBuffer(GL_ARRAY_BUFFER, buffer_strict.vbo_id);
- glBufferData(GL_ARRAY_BUFFER, buffer_strict.buffer_size, NULL, GL_DYNAMIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, buffer_strict.buffer_size, nullptr, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
@@ -112,7 +112,7 @@ uchar *GLImmediate::begin()
}
else {
/* orphan this buffer & start with a fresh one */
- glBufferData(GL_ARRAY_BUFFER, buffer_size(), NULL, GL_DYNAMIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, buffer_size(), nullptr, GL_DYNAMIC_DRAW);
buffer_offset() = 0;
}
@@ -129,13 +129,13 @@ uchar *GLImmediate::begin()
access |= GL_MAP_FLUSH_EXPLICIT_BIT;
}
void *data = glMapBufferRange(GL_ARRAY_BUFFER, buffer_offset(), bytes_needed, access);
- BLI_assert(data != NULL);
+ BLI_assert(data != nullptr);
bytes_mapped_ = bytes_needed;
return (uchar *)data;
}
-void GLImmediate::end(void)
+void GLImmediate::end()
{
BLI_assert(prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
diff --git a/source/blender/gpu/opengl/gl_index_buffer.cc b/source/blender/gpu/opengl/gl_index_buffer.cc
index 0096a9a500f..e2c18c5d0b9 100644
--- a/source/blender/gpu/opengl/gl_index_buffer.cc
+++ b/source/blender/gpu/opengl/gl_index_buffer.cc
@@ -33,7 +33,7 @@ GLIndexBuf::~GLIndexBuf()
GLContext::buf_free(ibo_id_);
}
-void GLIndexBuf::bind(void)
+void GLIndexBuf::bind()
{
if (is_subrange_) {
static_cast<GLIndexBuf *>(src_)->bind();
diff --git a/source/blender/gpu/opengl/gl_query.cc b/source/blender/gpu/opengl/gl_query.cc
index 6da5cacfcb2..8a42719c665 100644
--- a/source/blender/gpu/opengl/gl_query.cc
+++ b/source/blender/gpu/opengl/gl_query.cc
@@ -48,7 +48,7 @@ void GLQueryPool::reset(GPUQueryType type)
}
#endif
-void GLQueryPool::begin_query(void)
+void GLQueryPool::begin_query()
{
/* TODO add assert about expected usage. */
while (query_issued_ >= query_ids_.size()) {
@@ -59,7 +59,7 @@ void GLQueryPool::begin_query(void)
glBeginQuery(gl_type_, query_ids_[query_issued_++]);
}
-void GLQueryPool::end_query(void)
+void GLQueryPool::end_query()
{
/* TODO add assert about expected usage. */
glEndQuery(gl_type_);
diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc
index 193e4ee8a70..cc5f83228d6 100644
--- a/source/blender/gpu/opengl/gl_shader.cc
+++ b/source/blender/gpu/opengl/gl_shader.cc
@@ -53,7 +53,7 @@ GLShader::GLShader(const char *name) : Shader(name)
debug::object_label(GL_PROGRAM, shader_program_, name);
}
-GLShader::~GLShader(void)
+GLShader::~GLShader()
{
#if 0 /* Would be nice to have, but for now the Deferred compilation \
* does not have a GPUContext. */
@@ -72,7 +72,7 @@ GLShader::~GLShader(void)
/** \name Shader stage creation
* \{ */
-char *GLShader::glsl_patch_get(void)
+char *GLShader::glsl_patch_get()
{
/** Used for shader patching. Init once. */
static char patch[512] = "\0";
@@ -123,14 +123,14 @@ GLuint GLShader::create_shader_stage(GLenum gl_stage, MutableSpan<const char *>
/* Patch the shader code using the first source slot. */
sources[0] = glsl_patch_get();
- glShaderSource(shader, sources.size(), sources.data(), NULL);
+ glShaderSource(shader, sources.size(), sources.data(), nullptr);
glCompileShader(shader);
GLint status;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
if (!status || (G.debug & G_DEBUG_GPU)) {
char log[5000] = "";
- glGetShaderInfoLog(shader, sizeof(log), NULL, log);
+ glGetShaderInfoLog(shader, sizeof(log), nullptr, log);
if (log[0] != '\0') {
switch (gl_stage) {
case GL_VERTEX_SHADER:
@@ -172,7 +172,7 @@ void GLShader::fragment_shader_from_glsl(MutableSpan<const char *> sources)
frag_shader_ = this->create_shader_stage(GL_FRAGMENT_SHADER, sources);
}
-bool GLShader::finalize(void)
+bool GLShader::finalize()
{
if (compilation_failed_) {
return false;
@@ -184,7 +184,7 @@ bool GLShader::finalize(void)
glGetProgramiv(shader_program_, GL_LINK_STATUS, &status);
if (!status) {
char log[5000];
- glGetProgramInfoLog(shader_program_, sizeof(log), NULL, log);
+ glGetProgramInfoLog(shader_program_, sizeof(log), nullptr, log);
Span<const char *> sources;
this->print_log(sources, log, "Linking", true);
return false;
@@ -201,13 +201,13 @@ bool GLShader::finalize(void)
/** \name Binding
* \{ */
-void GLShader::bind(void)
+void GLShader::bind()
{
BLI_assert(shader_program_ != 0);
glUseProgram(shader_program_);
}
-void GLShader::unbind(void)
+void GLShader::unbind()
{
#ifndef NDEBUG
glUseProgram(0);
@@ -259,7 +259,7 @@ bool GLShader::transform_feedback_enable(GPUVertBuf *buf_)
return true;
}
-void GLShader::transform_feedback_disable(void)
+void GLShader::transform_feedback_disable()
{
glEndTransformFeedback();
}
@@ -409,7 +409,7 @@ void GLShader::vertformat_from_shader(GPUVertFormat *format) const
char name[256];
GLenum gl_type;
GLint size;
- glGetActiveAttrib(shader_program_, i, sizeof(name), NULL, &size, &gl_type, name);
+ glGetActiveAttrib(shader_program_, i, sizeof(name), nullptr, &size, &gl_type, name);
/* Ignore OpenGL names like `gl_BaseInstanceARB`, `gl_InstanceID` and `gl_VertexID`. */
if (glGetAttribLocation(shader_program_, name) == -1) {
diff --git a/source/blender/gpu/opengl/gl_shader_interface.cc b/source/blender/gpu/opengl/gl_shader_interface.cc
index 2d55c222e9c..9533639b133 100644
--- a/source/blender/gpu/opengl/gl_shader_interface.cc
+++ b/source/blender/gpu/opengl/gl_shader_interface.cc
@@ -267,7 +267,7 @@ GLShaderInterface::GLShaderInterface(GLuint program)
for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORM_BLOCKS; u_int++) {
GPUUniformBlockBuiltin u = static_cast<GPUUniformBlockBuiltin>(u_int);
const ShaderInput *block = this->ubo_get(builtin_uniform_block_name(u));
- builtin_blocks_[u] = (block != NULL) ? block->binding : -1;
+ builtin_blocks_[u] = (block != nullptr) ? block->binding : -1;
}
MEM_freeN(uniforms_from_blocks);
@@ -285,7 +285,7 @@ GLShaderInterface::GLShaderInterface(GLuint program)
GLShaderInterface::~GLShaderInterface()
{
for (auto *ref : refs_) {
- if (ref != NULL) {
+ if (ref != nullptr) {
ref->remove(this);
}
}
diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc
index 5483f889a8a..c5b5dd3efd2 100644
--- a/source/blender/gpu/opengl/gl_state.cc
+++ b/source/blender/gpu/opengl/gl_state.cc
@@ -42,7 +42,7 @@ namespace blender::gpu {
/** \name GLStateManager
* \{ */
-GLStateManager::GLStateManager(void) : StateManager()
+GLStateManager::GLStateManager()
{
/* Set other states that never change. */
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
@@ -71,7 +71,7 @@ GLStateManager::GLStateManager(void) : StateManager()
set_mutable_state(mutable_state);
}
-void GLStateManager::apply_state(void)
+void GLStateManager::apply_state()
{
if (!this->use_bgl) {
this->set_state(this->state);
@@ -84,7 +84,7 @@ void GLStateManager::apply_state(void)
};
/* Will set all the states regardless of the current ones. */
-void GLStateManager::force_state(void)
+void GLStateManager::force_state()
{
/* Little exception for clip distances since they need to keep the old count correct. */
uint32_t clip_distances = current_.clip_distances;
@@ -511,7 +511,7 @@ void GLStateManager::texture_unbind(Texture *tex_)
tex->is_bound_ = false;
}
-void GLStateManager::texture_unbind_all(void)
+void GLStateManager::texture_unbind_all()
{
for (int i = 0; i < ARRAY_SIZE(textures_); i++) {
if (textures_[i] != 0) {
@@ -523,7 +523,7 @@ void GLStateManager::texture_unbind_all(void)
this->texture_bind_apply();
}
-void GLStateManager::texture_bind_apply(void)
+void GLStateManager::texture_bind_apply()
{
if (dirty_texture_binds_ == 0) {
return;
@@ -555,7 +555,7 @@ void GLStateManager::texture_unpack_row_length_set(uint len)
glPixelStorei(GL_UNPACK_ROW_LENGTH, len);
}
-uint64_t GLStateManager::bound_texture_slots(void)
+uint64_t GLStateManager::bound_texture_slots()
{
uint64_t bound_slots = 0;
for (int i = 0; i < ARRAY_SIZE(textures_); i++) {
@@ -603,7 +603,7 @@ void GLStateManager::image_unbind(Texture *tex_)
tex->is_bound_ = false;
}
-void GLStateManager::image_unbind_all(void)
+void GLStateManager::image_unbind_all()
{
for (int i = 0; i < ARRAY_SIZE(images_); i++) {
if (images_[i] != 0) {
@@ -614,7 +614,7 @@ void GLStateManager::image_unbind_all(void)
this->image_bind_apply();
}
-void GLStateManager::image_bind_apply(void)
+void GLStateManager::image_bind_apply()
{
if (dirty_image_binds_ == 0) {
return;
@@ -638,7 +638,7 @@ void GLStateManager::image_bind_apply(void)
}
}
-uint8_t GLStateManager::bound_image_slots(void)
+uint8_t GLStateManager::bound_image_slots()
{
uint8_t bound_slots = 0;
for (int i = 0; i < ARRAY_SIZE(images_); i++) {
diff --git a/source/blender/gpu/opengl/gl_texture.cc b/source/blender/gpu/opengl/gl_texture.cc
index 070a86509ff..4f990b77bd0 100644
--- a/source/blender/gpu/opengl/gl_texture.cc
+++ b/source/blender/gpu/opengl/gl_texture.cc
@@ -44,7 +44,7 @@ namespace blender::gpu {
GLTexture::GLTexture(const char *name) : Texture(name)
{
- BLI_assert(GLContext::get() != NULL);
+ BLI_assert(GLContext::get() != nullptr);
glGenTextures(1, &tex_id_);
}
@@ -55,7 +55,7 @@ GLTexture::~GLTexture()
GPU_framebuffer_free(framebuffer_);
}
GLContext *ctx = GLContext::get();
- if (ctx != NULL && is_bound_) {
+ if (ctx != nullptr && is_bound_) {
/* This avoid errors when the texture is still inside the bound texture array. */
ctx->state_manager->texture_unbind(this);
}
@@ -63,7 +63,7 @@ GLTexture::~GLTexture()
}
/* Return true on success. */
-bool GLTexture::init_internal(void)
+bool GLTexture::init_internal()
{
if ((format_ == GPU_DEPTH24_STENCIL8) && GPU_depth_blitting_workaround()) {
/* MacOS + Radeon Pro fails to blit depth on GPU_DEPTH24_STENCIL8
@@ -148,7 +148,7 @@ void GLTexture::ensure_mipmaps(int miplvl)
if (type_ == GPU_TEXTURE_CUBE) {
for (int i = 0; i < d; i++) {
GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
- glTexImage2D(target, mip, internal_format, w, h, 0, gl_format, gl_type, NULL);
+ glTexImage2D(target, mip, internal_format, w, h, 0, gl_format, gl_type, nullptr);
}
}
else if (format_flag_ & GPU_FORMAT_COMPRESSED) {
@@ -156,13 +156,13 @@ void GLTexture::ensure_mipmaps(int miplvl)
switch (dimensions) {
default:
case 1:
- glCompressedTexImage1D(target_, mip, internal_format, w, 0, size, NULL);
+ glCompressedTexImage1D(target_, mip, internal_format, w, 0, size, nullptr);
break;
case 2:
- glCompressedTexImage2D(target_, mip, internal_format, w, h, 0, size, NULL);
+ glCompressedTexImage2D(target_, mip, internal_format, w, h, 0, size, nullptr);
break;
case 3:
- glCompressedTexImage3D(target_, mip, internal_format, w, h, d, 0, size, NULL);
+ glCompressedTexImage3D(target_, mip, internal_format, w, h, d, 0, size, nullptr);
break;
}
}
@@ -170,13 +170,13 @@ void GLTexture::ensure_mipmaps(int miplvl)
switch (dimensions) {
default:
case 1:
- glTexImage1D(target_, mip, internal_format, w, 0, gl_format, gl_type, NULL);
+ glTexImage1D(target_, mip, internal_format, w, 0, gl_format, gl_type, nullptr);
break;
case 2:
- glTexImage2D(target_, mip, internal_format, w, h, 0, gl_format, gl_type, NULL);
+ glTexImage2D(target_, mip, internal_format, w, h, 0, gl_format, gl_type, nullptr);
break;
case 3:
- glTexImage3D(target_, mip, internal_format, w, h, d, 0, gl_format, gl_type, NULL);
+ glTexImage3D(target_, mip, internal_format, w, h, d, 0, gl_format, gl_type, nullptr);
break;
}
}
@@ -231,7 +231,7 @@ void GLTexture::update_sub(
int mip, int offset[3], int extent[3], eGPUDataFormat type, const void *data)
{
BLI_assert(validate_data_format(format_, type));
- BLI_assert(data != NULL);
+ BLI_assert(data != nullptr);
this->ensure_mipmaps(mip);
@@ -294,7 +294,7 @@ void GLTexture::update_sub(
* WARNING: Depth textures are not populated but they have their mips correctly defined.
* WARNING: This resets the mipmap range.
*/
-void GLTexture::generate_mipmap(void)
+void GLTexture::generate_mipmap()
{
this->ensure_mipmaps(9999);
/* Some drivers have bugs when using glGenerateMipmap with depth textures (see T56789).
@@ -440,7 +440,7 @@ void GLTexture::mip_range_set(int min, int max)
}
}
-struct GPUFrameBuffer *GLTexture::framebuffer_get(void)
+struct GPUFrameBuffer *GLTexture::framebuffer_get()
{
if (framebuffer_) {
return framebuffer_;
@@ -461,7 +461,7 @@ struct GPUFrameBuffer *GLTexture::framebuffer_get(void)
GLuint GLTexture::samplers_[GPU_SAMPLER_MAX] = {0};
-void GLTexture::samplers_init(void)
+void GLTexture::samplers_init()
{
glGenSamplers(GPU_SAMPLER_MAX, samplers_);
for (int i = 0; i <= GPU_SAMPLER_ICON - 1; i++) {
@@ -517,7 +517,7 @@ void GLTexture::samplers_init(void)
debug::object_label(GL_SAMPLER, icon_sampler, "icons");
}
-void GLTexture::samplers_update(void)
+void GLTexture::samplers_update()
{
if (!GLContext::texture_filter_anisotropic_support) {
return;
@@ -536,7 +536,7 @@ void GLTexture::samplers_update(void)
}
}
-void GLTexture::samplers_free(void)
+void GLTexture::samplers_free()
{
glDeleteSamplers(GPU_SAMPLER_MAX, samplers_);
}
@@ -617,13 +617,13 @@ bool GLTexture::proxy_check(int mip)
switch (dimensions) {
default:
case 1:
- glCompressedTexImage1D(gl_proxy, mip, size[0], 0, gl_format, img_size, NULL);
+ glCompressedTexImage1D(gl_proxy, mip, size[0], 0, gl_format, img_size, nullptr);
break;
case 2:
- glCompressedTexImage2D(gl_proxy, mip, UNPACK2(size), 0, gl_format, img_size, NULL);
+ glCompressedTexImage2D(gl_proxy, mip, UNPACK2(size), 0, gl_format, img_size, nullptr);
break;
case 3:
- glCompressedTexImage3D(gl_proxy, mip, UNPACK3(size), 0, gl_format, img_size, NULL);
+ glCompressedTexImage3D(gl_proxy, mip, UNPACK3(size), 0, gl_format, img_size, nullptr);
break;
}
}
@@ -631,13 +631,15 @@ bool GLTexture::proxy_check(int mip)
switch (dimensions) {
default:
case 1:
- glTexImage1D(gl_proxy, mip, internal_format, size[0], 0, gl_format, gl_type, NULL);
+ glTexImage1D(gl_proxy, mip, internal_format, size[0], 0, gl_format, gl_type, nullptr);
break;
case 2:
- glTexImage2D(gl_proxy, mip, internal_format, UNPACK2(size), 0, gl_format, gl_type, NULL);
+ glTexImage2D(
+ gl_proxy, mip, internal_format, UNPACK2(size), 0, gl_format, gl_type, nullptr);
break;
case 3:
- glTexImage3D(gl_proxy, mip, internal_format, UNPACK3(size), 0, gl_format, gl_type, NULL);
+ glTexImage3D(
+ gl_proxy, mip, internal_format, UNPACK3(size), 0, gl_format, gl_type, nullptr);
break;
}
}
@@ -649,7 +651,7 @@ bool GLTexture::proxy_check(int mip)
/** \} */
-void GLTexture::check_feedback_loop(void)
+void GLTexture::check_feedback_loop()
{
/* Recursive down sample workaround break this check.
* See #recursive_downsample() for more information. */
@@ -679,7 +681,7 @@ void GLTexture::check_feedback_loop(void)
}
/* TODO(fclem): Legacy. Should be removed at some point. */
-uint GLTexture::gl_bindcode_get(void) const
+uint GLTexture::gl_bindcode_get() const
{
return tex_id_;
}
diff --git a/source/blender/gpu/opengl/gl_uniform_buffer.cc b/source/blender/gpu/opengl/gl_uniform_buffer.cc
index e6aaddf75d3..ecb233f2e5a 100644
--- a/source/blender/gpu/opengl/gl_uniform_buffer.cc
+++ b/source/blender/gpu/opengl/gl_uniform_buffer.cc
@@ -55,13 +55,13 @@ GLUniformBuf::~GLUniformBuf()
/** \name Data upload / update
* \{ */
-void GLUniformBuf::init(void)
+void GLUniformBuf::init()
{
BLI_assert(GLContext::get());
glGenBuffers(1, &ubo_id_);
glBindBuffer(GL_UNIFORM_BUFFER, ubo_id_);
- glBufferData(GL_UNIFORM_BUFFER, size_in_bytes_, NULL, GL_DYNAMIC_DRAW);
+ glBufferData(GL_UNIFORM_BUFFER, size_in_bytes_, nullptr, GL_DYNAMIC_DRAW);
debug::object_label(GL_UNIFORM_BUFFER, ubo_id_, name_);
}
@@ -97,7 +97,7 @@ void GLUniformBuf::bind(int slot)
this->init();
}
- if (data_ != NULL) {
+ if (data_ != nullptr) {
this->update(data_);
MEM_SAFE_FREE(data_);
}
@@ -111,7 +111,7 @@ void GLUniformBuf::bind(int slot)
#endif
}
-void GLUniformBuf::unbind(void)
+void GLUniformBuf::unbind()
{
#ifdef DEBUG
/* NOTE: This only unbinds the last bound slot. */
diff --git a/source/blender/gpu/opengl/gl_vertex_array.cc b/source/blender/gpu/opengl/gl_vertex_array.cc
index ed6699e51f3..ea2770f099d 100644
--- a/source/blender/gpu/opengl/gl_vertex_array.cc
+++ b/source/blender/gpu/opengl/gl_vertex_array.cc
@@ -70,13 +70,13 @@ static uint16_t vbo_bind(const ShaderInterface *interface,
const char *name = GPU_vertformat_attr_name_get(format, a, n_idx);
const ShaderInput *input = interface->attr_get(name);
- if (input == NULL) {
+ if (input == nullptr) {
continue;
}
enabled_attrib |= (1 << input->location);
- if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) {
+ if (ELEM(a->comp_len, 16, 12, 8)) {
BLI_assert(a->fetch_mode == GPU_FETCH_FLOAT);
BLI_assert(a->comp_type == GPU_COMP_F32);
for (int i = 0; i < a->comp_len / 4; i++) {
diff --git a/source/blender/gpu/opengl/gl_vertex_buffer.cc b/source/blender/gpu/opengl/gl_vertex_buffer.cc
index c6efe577e15..a56d5269fde 100644
--- a/source/blender/gpu/opengl/gl_vertex_buffer.cc
+++ b/source/blender/gpu/opengl/gl_vertex_buffer.cc
@@ -27,19 +27,19 @@
namespace blender::gpu {
-void GLVertBuf::acquire_data(void)
+void GLVertBuf::acquire_data()
{
/* Discard previous data if any. */
MEM_SAFE_FREE(data);
data = (uchar *)MEM_mallocN(sizeof(uchar) * this->size_alloc_get(), __func__);
}
-void GLVertBuf::resize_data(void)
+void GLVertBuf::resize_data()
{
data = (uchar *)MEM_reallocN(data, sizeof(uchar) * this->size_alloc_get());
}
-void GLVertBuf::release_data(void)
+void GLVertBuf::release_data()
{
if (vbo_id_ != 0) {
GLContext::buf_free(vbo_id_);
@@ -52,7 +52,7 @@ void GLVertBuf::release_data(void)
void GLVertBuf::duplicate_data(VertBuf *dst_)
{
- BLI_assert(GLContext::get() != NULL);
+ BLI_assert(GLContext::get() != nullptr);
GLVertBuf *src = this;
GLVertBuf *dst = static_cast<GLVertBuf *>(dst_);
@@ -61,7 +61,7 @@ void GLVertBuf::duplicate_data(VertBuf *dst_)
glGenBuffers(1, &dst->vbo_id_);
glBindBuffer(GL_COPY_WRITE_BUFFER, dst->vbo_id_);
- glBufferData(GL_COPY_WRITE_BUFFER, dst->vbo_size_, NULL, to_gl(dst->usage_));
+ glBufferData(GL_COPY_WRITE_BUFFER, dst->vbo_size_, nullptr, to_gl(dst->usage_));
glBindBuffer(GL_COPY_READ_BUFFER, src->vbo_id_);
@@ -75,14 +75,14 @@ void GLVertBuf::duplicate_data(VertBuf *dst_)
}
}
-void GLVertBuf::upload_data(void)
+void GLVertBuf::upload_data()
{
this->bind();
}
-void GLVertBuf::bind(void)
+void GLVertBuf::bind()
{
- BLI_assert(GLContext::get() != NULL);
+ BLI_assert(GLContext::get() != nullptr);
if (vbo_id_ == 0) {
glGenBuffers(1, &vbo_id_);
@@ -93,7 +93,7 @@ void GLVertBuf::bind(void)
if (flag & GPU_VERTBUF_DATA_DIRTY) {
vbo_size_ = this->size_used_get();
/* Orphan the vbo to avoid sync then upload data. */
- glBufferData(GL_ARRAY_BUFFER, vbo_size_, NULL, to_gl(usage_));
+ glBufferData(GL_ARRAY_BUFFER, vbo_size_, nullptr, to_gl(usage_));
glBufferSubData(GL_ARRAY_BUFFER, 0, vbo_size_, data);
memory_usage += vbo_size_;
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl
index 10e1b4563bc..faf37db3ea6 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl
@@ -1,6 +1,8 @@
-void node_attribute(vec3 attr, out vec4 outcol, out vec3 outvec, out float outf)
+void node_attribute(
+ vec4 attr, out vec4 outcol, out vec3 outvec, out float outf, out float outalpha)
{
- outcol = vec4(attr, 1.0);
- outvec = attr;
- outf = avg(attr);
+ outcol = vec4(attr.xyz, 1.0);
+ outvec = attr.xyz;
+ outf = avg(attr.xyz);
+ outalpha = attr.w;
}
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index e127e377858..61f2153cf6c 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -101,13 +101,13 @@ struct IK_Target {
IK_Target()
{
- bldepsgraph = NULL;
- blscene = NULL;
- target = NULL;
- constraint = NULL;
- blenderConstraint = NULL;
- rootChannel = NULL;
- owner = NULL;
+ bldepsgraph = nullptr;
+ blscene = nullptr;
+ target = nullptr;
+ constraint = nullptr;
+ blenderConstraint = nullptr;
+ rootChannel = nullptr;
+ owner = nullptr;
controlType = 0;
channel = 0;
ee = 0;
@@ -138,12 +138,12 @@ struct IK_Channel {
IK_Channel()
{
- pchan = NULL;
+ pchan = nullptr;
parent = -1;
jointType = 0;
ndof = 0;
jointValid = 0;
- owner = NULL;
+ owner = nullptr;
jointValue[0] = 0.0;
jointValue[1] = 0.0;
jointValue[2] = 0.0;
@@ -174,20 +174,20 @@ struct IK_Scene {
IK_Scene()
{
- bldepsgraph = NULL;
- blscene = NULL;
- next = NULL;
- channels = NULL;
- armature = NULL;
- cache = NULL;
- scene = NULL;
- base = NULL;
- solver = NULL;
+ bldepsgraph = nullptr;
+ blscene = nullptr;
+ next = nullptr;
+ channels = nullptr;
+ armature = nullptr;
+ cache = nullptr;
+ scene = nullptr;
+ base = nullptr;
+ solver = nullptr;
blScale = blInvScale = 1.0f;
- blArmature = NULL;
+ blArmature = nullptr;
numchan = 0;
numjoint = 0;
- polarConstraint = NULL;
+ polarConstraint = nullptr;
}
~IK_Scene()
@@ -228,7 +228,7 @@ enum IK_SegmentAxis {
static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *con)
{
- bPoseChannel *curchan, *pchan_root = NULL, *chanlist[256], **oldchan;
+ bPoseChannel *curchan, *pchan_root = nullptr, *chanlist[256], **oldchan;
PoseTree *tree;
PoseTarget *target;
bKinematicConstraint *data;
@@ -290,7 +290,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
* and each channel can be part of at most one tree. */
tree = (PoseTree *)pchan_root->iktree.first;
- if (tree == NULL) {
+ if (tree == nullptr) {
/* make new tree */
tree = (PoseTree *)MEM_callocN(sizeof(PoseTree), "posetree");
@@ -398,7 +398,7 @@ static bool constraint_valid(bConstraint *con)
}
if (is_cartesian_constraint(con)) {
/* cartesian space constraint */
- if (data->tar == NULL) {
+ if (data->tar == nullptr) {
return false;
}
if (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0) {
@@ -956,7 +956,7 @@ static int convert_channels(struct Depsgraph *depsgraph,
* 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);
+ BKE_pose_where_is_bone(depsgraph, ikscene->blscene, ikscene->blArmature, pchan, ctime, true);
}
/* tell blender that this channel was controlled by IK,
* it's cleared on each BKE_pose_where_is() */
@@ -965,18 +965,18 @@ static int convert_channels(struct Depsgraph *depsgraph,
/* set DoF flag */
flag = 0;
if (!(pchan->ikflag & BONE_IK_NO_XDOF) && !(pchan->ikflag & BONE_IK_NO_XDOF_TEMP) &&
- (!(pchan->ikflag & BONE_IK_XLIMIT) || pchan->limitmin[0] < 0.f ||
- pchan->limitmax[0] > 0.f)) {
+ (!(pchan->ikflag & BONE_IK_XLIMIT) || pchan->limitmin[0] < 0.0f ||
+ pchan->limitmax[0] > 0.0f)) {
flag |= IK_XDOF;
}
if (!(pchan->ikflag & BONE_IK_NO_YDOF) && !(pchan->ikflag & BONE_IK_NO_YDOF_TEMP) &&
- (!(pchan->ikflag & BONE_IK_YLIMIT) || pchan->limitmin[1] < 0.f ||
- pchan->limitmax[1] > 0.f)) {
+ (!(pchan->ikflag & BONE_IK_YLIMIT) || pchan->limitmin[1] < 0.0f ||
+ pchan->limitmax[1] > 0.0f)) {
flag |= IK_YDOF;
}
if (!(pchan->ikflag & BONE_IK_NO_ZDOF) && !(pchan->ikflag & BONE_IK_NO_ZDOF_TEMP) &&
- (!(pchan->ikflag & BONE_IK_ZLIMIT) || pchan->limitmin[2] < 0.f ||
- pchan->limitmax[2] > 0.f)) {
+ (!(pchan->ikflag & BONE_IK_ZLIMIT) || pchan->limitmin[2] < 0.0f ||
+ pchan->limitmax[2] > 0.0f)) {
flag |= IK_ZDOF;
}
@@ -1163,7 +1163,7 @@ static IK_Scene *convert_tree(
float start[3];
if (tree->totchannel == 0) {
- return NULL;
+ return nullptr;
}
ikscene = new IK_Scene;
@@ -1196,7 +1196,7 @@ static IK_Scene *convert_tree(
break;
default:
delete ikscene;
- return NULL;
+ return nullptr;
}
ikscene->blArmature = ob;
/* assume uniform scaling and take Y scale as general scale for the armature */
@@ -1438,10 +1438,10 @@ static IK_Scene *convert_tree(
}
if (!ret) {
delete ikscene;
- return NULL;
+ return nullptr;
}
/* 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;
+ for (numtarget = 0, polarcon = nullptr, ret = true, target = (PoseTarget *)tree->targets.first;
target;
target = (PoseTarget *)target->next) {
condata = (bKinematicConstraint *)target->con->data;
@@ -1496,7 +1496,7 @@ static IK_Scene *convert_tree(
}
if (!ret) {
delete ikscene;
- return NULL;
+ return nullptr;
}
/* set the weight */
e_matrix &Wq = arm->getWq();
@@ -1535,7 +1535,7 @@ static IK_Scene *convert_tree(
/* 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;
+ for (bonecnt = 0, bonelen = 0.0f, a = iktarget->channel; a >= 0;
a = tree->parent[a], bonecnt++) {
bonelen += ikscene->blScale * tree->pchan[a]->bone->length;
}
@@ -1638,7 +1638,7 @@ static IK_Scene *convert_tree(
if (!ret || !scene->addCache(ikscene->cache) || !scene->addSolver(ikscene->solver) ||
!scene->initialize()) {
delete ikscene;
- ikscene = NULL;
+ ikscene = nullptr;
}
return ikscene;
}
@@ -1688,7 +1688,7 @@ static int init_scene(Object *ob)
IK_Scene *scene;
if (ob->pose->ikdata) {
- for (scene = ((IK_Data *)ob->pose->ikdata)->first; scene != NULL; scene = scene->next) {
+ for (scene = ((IK_Data *)ob->pose->ikdata)->first; scene != nullptr; scene = scene->next) {
if (fabs(scene->blScale - scale) > KDL::epsilon) {
return 1;
}
@@ -1720,7 +1720,8 @@ static void execute_scene(struct Depsgraph *depsgraph,
/* 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);
+ BKE_pose_where_is_bone(
+ depsgraph, blscene, ikscene->blArmature, ikchan->pchan, ctime, true);
}
/* tell blender that this channel was controlled by IK,
* it's cleared on each BKE_pose_where_is() */
@@ -1767,7 +1768,7 @@ static void execute_scene(struct Depsgraph *depsgraph,
if (ikscene->cache && !reiterate && simulation) {
iTaSC::CacheTS sts, cts;
sts = cts = (iTaSC::CacheTS)std::round(timestamp * 1000.0);
- if (ikscene->cache->getPreviousCacheItem(ikscene->armature, 0, &cts) == NULL || cts == 0) {
+ if (ikscene->cache->getPreviousCacheItem(ikscene->armature, 0, &cts) == nullptr || cts == 0) {
/* the cache is empty before this time, reiterate */
if (ikparam->flag & ITASC_INITIAL_REITERATION) {
reiterate = true;
@@ -1886,7 +1887,7 @@ void itasc_initialize_tree(struct Depsgraph *depsgraph,
bPoseChannel *pchan;
int count = 0;
- if (ob->pose->ikdata != NULL && !(ob->pose->flag & POSE_WAS_REBUILT)) {
+ if (ob->pose->ikdata != nullptr && !(ob->pose->flag & POSE_WAS_REBUILT)) {
if (!init_scene(ob)) {
return;
}
@@ -1949,7 +1950,7 @@ void itasc_clear_data(struct bPose *pose)
delete scene;
}
MEM_freeN(ikdata);
- pose->ikdata = NULL;
+ pose->ikdata = nullptr;
}
}
@@ -1960,7 +1961,7 @@ void itasc_clear_cache(struct bPose *pose)
for (IK_Scene *scene = ikdata->first; scene; scene = scene->next) {
if (scene->cache) {
/* clear all cache but leaving the timestamp 0 (=rest pose) */
- scene->cache->clearCacheFrom(NULL, 1);
+ scene->cache->clearCacheFrom(nullptr, 1);
}
}
}
@@ -2000,7 +2001,7 @@ void itasc_test_constraint(struct Object *ob, struct bConstraint *cons)
struct bKinematicConstraint *data = (struct bKinematicConstraint *)cons->data;
/* only for IK constraint */
- if (cons->type != CONSTRAINT_TYPE_KINEMATIC || data == NULL) {
+ if (cons->type != CONSTRAINT_TYPE_KINEMATIC || data == nullptr) {
return;
}
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 839b0b12b83..957352595ed 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -466,27 +466,29 @@ void IMB_scaleImBuf_threaded(struct ImBuf *ibuf, unsigned int newx, unsigned int
*
* \attention Defined in writeimage.c
*/
-short IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags);
+bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags);
bool IMB_prepare_write_ImBuf(const bool isfloat, struct ImBuf *ibuf);
/**
*
* \attention Defined in util.c
*/
-bool IMB_ispic(const char *name);
-int IMB_ispic_type(const char *name);
+bool IMB_ispic(const char *filepath);
+bool IMB_ispic_type_matches(const char *filepath, int filetype);
+int IMB_ispic_type_from_memory(const unsigned char *buf, const size_t buf_size);
+int IMB_ispic_type(const char *filepath);
/**
*
* \attention Defined in util.c
*/
-bool IMB_isanim(const char *name);
+bool IMB_isanim(const char *filepath);
/**
*
* \attention Defined in util.c
*/
-int imb_get_anim_type(const char *name);
+int imb_get_anim_type(const char *filepath);
/**
*
@@ -684,6 +686,8 @@ void IMB_rectfill_area(struct ImBuf *ibuf,
int x2,
int y2,
struct ColorManagedDisplay *display);
+void IMB_rectfill_area_replace(
+ const struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2);
void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value);
/* This should not be here, really,
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index 98e9c34a4ff..4bb3ea500fa 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -69,7 +69,7 @@ typedef struct DDSData {
* See T46524. */
/** #ImBuf.ftype flag, main image types. */
-enum eImbTypes {
+enum eImbFileType {
IMB_FTYPE_PNG = 1,
IMB_FTYPE_TGA = 2,
IMB_FTYPE_JPG = 3,
@@ -98,6 +98,9 @@ enum eImbTypes {
#endif
};
+/* Only for readability. */
+#define IMB_FTYPE_NONE 0
+
/* ibuf->foptions flag, type specific options.
* Some formats include compression rations on some bits */
@@ -243,7 +246,7 @@ typedef struct ImBuf {
/* file information */
/** file type we are going to save as */
- enum eImbTypes ftype;
+ enum eImbFileType ftype;
/** file format specific flags */
ImbFormatOptions foptions;
/** filename associated with this image */
diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h
index 93a3a98c3d1..c8f6135f330 100644
--- a/source/blender/imbuf/intern/IMB_filetype.h
+++ b/source/blender/imbuf/intern/IMB_filetype.h
@@ -29,18 +29,27 @@ struct ImBuf;
#define IM_FTYPE_FLOAT 1
typedef struct ImFileType {
+ /** Optional, called once when initializing. */
void (*init)(void);
+ /** Optional, called once when exiting. */
void (*exit)(void);
- int (*is_a)(const unsigned char *buf);
- int (*is_a_filepath)(const char *filepath);
- int (*ftype)(const struct ImFileType *type, const struct ImBuf *ibuf);
+ /**
+ * Check if the data matches this file types 'magic',
+ * \note that this may only read in a small part of the files header,
+ * see: #IMB_ispic_type for details.
+ */
+ bool (*is_a)(const unsigned char *buf, const size_t size);
+
+ /** Load an image from memory. */
struct ImBuf *(*load)(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
+ /** Load an image from a file. */
struct ImBuf *(*load_filepath)(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]);
- int (*save)(struct ImBuf *ibuf, const char *filepath, int flags);
+ /** Save to a file (or memory if #IB_mem is set in `flags` and the format supports it). */
+ bool (*save)(struct ImBuf *ibuf, const char *filepath, int flags);
void (*load_tile)(struct ImBuf *ibuf,
const unsigned char *mem,
size_t size,
@@ -49,13 +58,19 @@ typedef struct ImFileType {
unsigned int *rect);
int flag;
+
+ /** #eImbFileType */
int filetype;
+
int default_save_role;
} ImFileType;
extern const ImFileType IMB_FILE_TYPES[];
extern const ImFileType *IMB_FILE_TYPES_LAST;
+const ImFileType *IMB_file_type_from_ftype(int ftype);
+const ImFileType *IMB_file_type_from_ibuf(const struct ImBuf *ibuf);
+
void imb_filetypes_init(void);
void imb_filetypes_exit(void);
@@ -68,31 +83,31 @@ void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty);
/* Type Specific Functions */
/* png */
-int imb_is_a_png(const unsigned char *mem);
+bool imb_is_a_png(const unsigned char *mem, const size_t size);
struct ImBuf *imb_loadpng(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags);
/* targa */
-int imb_is_a_targa(const unsigned char *buf);
+bool imb_is_a_targa(const unsigned char *buf, const size_t size);
struct ImBuf *imb_loadtarga(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags);
/* iris */
-int imb_is_a_iris(const unsigned char *mem);
+bool imb_is_a_iris(const unsigned char *mem, const size_t size);
struct ImBuf *imb_loadiris(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags);
/* jp2 */
-int imb_is_a_jp2(const unsigned char *buf);
+bool imb_is_a_jp2(const unsigned char *buf, const size_t size);
struct ImBuf *imb_load_jp2(const unsigned char *mem,
size_t size,
int flags,
@@ -100,55 +115,55 @@ struct ImBuf *imb_load_jp2(const unsigned char *mem,
struct ImBuf *imb_load_jp2_filepath(const char *filepath,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags);
/* jpeg */
-int imb_is_a_jpeg(const unsigned char *mem);
-int imb_savejpeg(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_is_a_jpeg(const unsigned char *mem, const size_t size);
+bool imb_savejpeg(struct ImBuf *ibuf, const char *filepath, int flags);
struct ImBuf *imb_load_jpeg(const unsigned char *buffer,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
/* bmp */
-int imb_is_a_bmp(const unsigned char *buf);
+bool imb_is_a_bmp(const unsigned char *buf, const size_t size);
struct ImBuf *imb_bmp_decode(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_savebmp(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_savebmp(struct ImBuf *ibuf, const char *filepath, int flags);
/* cineon */
-int imb_is_cineon(const unsigned char *buf);
-int imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags);
+bool imb_is_a_cineon(const unsigned char *buf, const size_t size);
+bool imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags);
struct ImBuf *imb_load_cineon(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
/* dpx */
-int imb_is_dpx(const unsigned char *buf);
-int imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags);
+bool imb_is_a_dpx(const unsigned char *buf, const size_t size);
+bool imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags);
struct ImBuf *imb_load_dpx(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
/* hdr */
-int imb_is_a_hdr(const unsigned char *buf);
+bool imb_is_a_hdr(const unsigned char *buf, const size_t size);
struct ImBuf *imb_loadhdr(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
-int imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags);
/* tiff */
void imb_inittiff(void);
-int imb_is_a_tiff(const unsigned char *buf);
+bool imb_is_a_tiff(const unsigned char *buf, const size_t size);
struct ImBuf *imb_loadtiff(const unsigned char *mem,
size_t size,
int flags,
char colorspace[IM_MAX_SPACE]);
void imb_loadtiletiff(
struct ImBuf *ibuf, const unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect);
-int imb_savetiff(struct ImBuf *ibuf, const char *filepath, int flags);
+bool imb_savetiff(struct ImBuf *ibuf, const char *filepath, int flags);
diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c
index ab818d451d6..58ce02f28ae 100644
--- a/source/blender/imbuf/intern/bmp.c
+++ b/source/blender/imbuf/intern/bmp.c
@@ -72,43 +72,43 @@ typedef struct BMPHEADER {
CHECK_HEADER_FIELD(_mem, "CI") || CHECK_HEADER_FIELD(_mem, "CP") || \
CHECK_HEADER_FIELD(_mem, "IC") || CHECK_HEADER_FIELD(_mem, "PT"))
-static int checkbmp(const uchar *mem)
+static bool checkbmp(const uchar *mem, const size_t size)
{
+ if (size < BMP_FILEHEADER_SIZE) {
+ return false;
+ }
+
+ if (!CHECK_HEADER_FIELD_BMP(mem)) {
+ return false;
+ }
- int ret_val = 0;
+ bool ok = false;
BMPINFOHEADER bmi;
uint u;
- if (mem) {
- if (CHECK_HEADER_FIELD_BMP(mem)) {
- /* skip fileheader */
- mem += BMP_FILEHEADER_SIZE;
- }
- else {
- return 0;
- }
+ /* skip fileheader */
+ mem += BMP_FILEHEADER_SIZE;
- /* for systems where an int needs to be 4 bytes aligned */
- memcpy(&bmi, mem, sizeof(bmi));
+ /* for systems where an int needs to be 4 bytes aligned */
+ memcpy(&bmi, mem, sizeof(bmi));
- u = LITTLE_LONG(bmi.biSize);
- /* we only support uncompressed images for now. */
- if (u >= sizeof(BMPINFOHEADER)) {
- if (bmi.biCompression == 0) {
- u = LITTLE_SHORT(bmi.biBitCount);
- if (u > 0 && u <= 32) {
- ret_val = 1;
- }
+ u = LITTLE_LONG(bmi.biSize);
+ /* we only support uncompressed images for now. */
+ if (u >= sizeof(BMPINFOHEADER)) {
+ if (bmi.biCompression == 0) {
+ u = LITTLE_SHORT(bmi.biBitCount);
+ if (u > 0 && u <= 32) {
+ ok = true;
}
}
}
- return ret_val;
+ return ok;
}
-int imb_is_a_bmp(const uchar *buf)
+bool imb_is_a_bmp(const uchar *buf, size_t size)
{
- return checkbmp(buf);
+ return checkbmp(buf, size);
}
ImBuf *imb_bmp_decode(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
@@ -124,7 +124,7 @@ ImBuf *imb_bmp_decode(const uchar *mem, size_t size, int flags, char colorspace[
(void)size; /* unused */
- if (checkbmp(mem) == 0) {
+ if (checkbmp(mem, size) == 0) {
return NULL;
}
@@ -296,12 +296,12 @@ static int putShortLSB(ushort us, FILE *ofile)
}
/* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */
-int imb_savebmp(ImBuf *ibuf, const char *filepath, int UNUSED(flags))
+bool imb_savebmp(ImBuf *ibuf, const char *filepath, int UNUSED(flags))
{
BMPINFOHEADER infoheader;
const size_t bytes_per_pixel = (ibuf->planes + 7) >> 3;
- BLI_assert(bytes_per_pixel == 1 || bytes_per_pixel == 3);
+ BLI_assert(ELEM(bytes_per_pixel, 1, 3));
const size_t pad_bytes_per_scanline = (4 - ibuf->x * bytes_per_pixel % 4) % 4;
const size_t bytesize = (ibuf->x * bytes_per_pixel + pad_bytes_per_scanline) * ibuf->y;
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c
index eeccadf56c1..de54e6dab9d 100644
--- a/source/blender/imbuf/intern/cineon/cineon_dpx.c
+++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c
@@ -183,14 +183,14 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
return rvalue;
}
-int imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags)
+bool imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags)
{
return imb_save_dpx_cineon(buf, filepath, 1, flags);
}
-int imb_is_cineon(const unsigned char *buf)
+bool imb_is_a_cineon(const unsigned char *buf, size_t size)
{
- return logImageIsCineon(buf);
+ return logImageIsCineon(buf, size);
}
ImBuf *imb_load_cineon(const unsigned char *mem,
@@ -198,20 +198,20 @@ ImBuf *imb_load_cineon(const unsigned char *mem,
int flags,
char colorspace[IM_MAX_SPACE])
{
- if (imb_is_cineon(mem)) {
+ if (imb_is_a_cineon(mem, size)) {
return imb_load_dpx_cineon(mem, size, 1, flags, colorspace);
}
return NULL;
}
-int imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags)
+bool imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags)
{
return imb_save_dpx_cineon(buf, filepath, 0, flags);
}
-int imb_is_dpx(const unsigned char *buf)
+bool imb_is_a_dpx(const unsigned char *buf, size_t size)
{
- return logImageIsDpx(buf);
+ return logImageIsDpx(buf, size);
}
ImBuf *imb_load_dpx(const unsigned char *mem,
@@ -219,7 +219,7 @@ ImBuf *imb_load_dpx(const unsigned char *mem,
int flags,
char colorspace[IM_MAX_SPACE])
{
- if (imb_is_dpx(mem)) {
+ if (imb_is_a_dpx(mem, size)) {
return imb_load_dpx_cineon(mem, size, 0, flags, colorspace);
}
return NULL;
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index 73003265d8d..b7a15812547 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -277,9 +277,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
}
dpx->element[i].bitsPerSample = header.imageHeader.element[i].bits_per_sample;
- if (dpx->element[i].bitsPerSample != 1 && dpx->element[i].bitsPerSample != 8 &&
- dpx->element[i].bitsPerSample != 10 && dpx->element[i].bitsPerSample != 12 &&
- dpx->element[i].bitsPerSample != 16) {
+ if (!ELEM(dpx->element[i].bitsPerSample, 1, 8, 10, 12, 16)) {
if (verbose) {
printf("DPX: Unsupported bitsPerSample for elements %d: %d\n",
i,
@@ -348,8 +346,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
if (dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 ||
isnan(dpx->element[i].refHighQuantity)) {
- if (dpx->element[i].transfer == transfer_PrintingDensity ||
- dpx->element[i].transfer == transfer_Logarithmic) {
+ if (ELEM(dpx->element[i].transfer, transfer_PrintingDensity, transfer_Logarithmic)) {
dpx->element[i].refHighQuantity = 2.048f;
}
else {
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c
index 446f360a3e7..2d42609fdf5 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.c
+++ b/source/blender/imbuf/intern/cineon/logImageCore.c
@@ -96,15 +96,23 @@ void logImageSetVerbose(int verbosity)
* IO stuff
*/
-int logImageIsDpx(const void *buffer)
+int logImageIsDpx(const void *buffer, const unsigned int size)
{
- unsigned int magicNum = *(unsigned int *)buffer;
+ unsigned int magicNum;
+ if (size < sizeof(magicNum)) {
+ return 0;
+ }
+ magicNum = *(unsigned int *)buffer;
return (magicNum == DPX_FILE_MAGIC || magicNum == swap_uint(DPX_FILE_MAGIC, 1));
}
-int logImageIsCineon(const void *buffer)
+int logImageIsCineon(const void *buffer, const unsigned int size)
{
- unsigned int magicNum = *(unsigned int *)buffer;
+ unsigned int magicNum;
+ if (size < sizeof(magicNum)) {
+ return 0;
+ }
+ magicNum = *(unsigned int *)buffer;
return (magicNum == CINEON_FILE_MAGIC || magicNum == swap_uint(CINEON_FILE_MAGIC, 1));
}
@@ -119,17 +127,17 @@ LogImageFile *logImageOpenFromFile(const char *filename, int cineon)
return NULL;
}
- if (fread(&magicNum, sizeof(unsigned int), 1, f) != 1) {
+ if (fread(&magicNum, sizeof(magicNum), 1, f) != 1) {
fclose(f);
return NULL;
}
fclose(f);
- if (logImageIsDpx(&magicNum)) {
+ if (logImageIsDpx(&magicNum, sizeof(magicNum))) {
return dpxOpen((const unsigned char *)filename, 0, 0);
}
- if (logImageIsCineon(&magicNum)) {
+ if (logImageIsCineon(&magicNum, sizeof(magicNum))) {
return cineonOpen((const unsigned char *)filename, 0, 0);
}
@@ -138,10 +146,10 @@ LogImageFile *logImageOpenFromFile(const char *filename, int cineon)
LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size)
{
- if (logImageIsDpx(buffer)) {
+ if (logImageIsDpx(buffer, size)) {
return dpxOpen(buffer, 1, size);
}
- if (logImageIsCineon(buffer)) {
+ if (logImageIsCineon(buffer, size)) {
return cineonOpen(buffer, 1, size);
}
@@ -215,7 +223,7 @@ size_t getRowLength(size_t width, LogImageElement logElement)
if (logElement.packing == 0) {
return ((width * logElement.depth * 10 - 1) / 32 + 1) * 4;
}
- else if (logElement.packing == 1 || logElement.packing == 2) {
+ else if (ELEM(logElement.packing, 1, 2)) {
return ((width * logElement.depth - 1) / 3 + 1) * 4;
}
break;
@@ -223,7 +231,7 @@ size_t getRowLength(size_t width, LogImageElement logElement)
if (logElement.packing == 0) {
return ((width * logElement.depth * 12 - 1) / 32 + 1) * 4;
}
- else if (logElement.packing == 1 || logElement.packing == 2) {
+ else if (ELEM(logElement.packing, 1, 2)) {
return width * logElement.depth * 2;
}
break;
@@ -442,8 +450,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
for (i = 0; i < logImage->numElements; i++) {
/* descriptor_Depth and descriptor_Composite are not supported */
- if (logImage->element[i].descriptor != descriptor_Depth &&
- logImage->element[i].descriptor != descriptor_Composite) {
+ if (!ELEM(logImage->element[i].descriptor, descriptor_Depth, descriptor_Composite)) {
/* Allocate memory */
elementData[i] = imb_alloc_pixels(
logImage->width, logImage->height, logImage->element[i].depth, sizeof(float), __func__);
@@ -680,7 +687,7 @@ static int logImageElementGetData(LogImageFile *logImage, LogImageElement logEle
if (logElement.packing == 0) {
return logImageElementGetData10Packed(logImage, logElement, data);
}
- else if (logElement.packing == 1 || logElement.packing == 2) {
+ else if (ELEM(logElement.packing, 1, 2)) {
return logImageElementGetData10(logImage, logElement, data);
}
break;
@@ -689,7 +696,7 @@ static int logImageElementGetData(LogImageFile *logImage, LogImageElement logEle
if (logElement.packing == 0) {
return logImageElementGetData12Packed(logImage, logElement, data);
}
- else if (logElement.packing == 1 || logElement.packing == 2) {
+ else if (ELEM(logElement.packing, 1, 2)) {
return logImageElementGetData12(logImage, logElement, data);
}
break;
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.h b/source/blender/imbuf/intern/cineon/logImageCore.h
index a2d50f21a98..c2704a086b6 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.h
+++ b/source/blender/imbuf/intern/cineon/logImageCore.h
@@ -181,8 +181,8 @@ enum descriptor {
/* int functions return 0 for OK */
void logImageSetVerbose(int verbosity);
-int logImageIsDpx(const void *buffer);
-int logImageIsCineon(const void *buffer);
+int logImageIsDpx(const void *buffer, unsigned int size);
+int logImageIsCineon(const void *buffer, unsigned int size);
LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size);
LogImageFile *logImageOpenFromFile(const char *filename, int cineon);
void logImageGetSize(LogImageFile *logImage, int *width, int *height, int *depth);
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index 7847ae83c19..2c95d49612f 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -54,10 +54,11 @@
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_main.h"
-#include "BKE_sequencer.h"
#include "RNA_define.h"
+#include "SEQ_sequencer.h"
+
#include <ocio_capi.h>
/* -------------------------------------------------------------------- */
@@ -2615,7 +2616,6 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
if (do_colormanagement) {
bool make_byte = false;
- const ImFileType *type;
/* for proper check whether byte buffer is required by a format or not
* should be pretty safe since this image buffer is supposed to be used for
@@ -2628,13 +2628,10 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
* we need to allocate byte buffer and store color managed
* image there
*/
- for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
- if (type->save && type->ftype(type, colormanaged_ibuf)) {
- if ((type->flag & IM_FTYPE_FLOAT) == 0) {
- make_byte = true;
- }
-
- break;
+ const ImFileType *type = IMB_file_type_from_ibuf(colormanaged_ibuf);
+ if (type != NULL) {
+ if ((type->save != NULL) && (type->flag & IM_FTYPE_FLOAT) == 0) {
+ make_byte = true;
}
}
@@ -3237,14 +3234,11 @@ void IMB_colormanagement_colorspace_from_ibuf_ftype(
}
/* Get color space from file type. */
- const ImFileType *type;
-
- for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
- if (type->save && type->ftype(type, ibuf)) {
- const char *role_colorspace;
-
- role_colorspace = IMB_colormanagement_role_colorspace_name_get(type->default_save_role);
-
+ const ImFileType *type = IMB_file_type_from_ibuf(ibuf);
+ if (type != NULL) {
+ if (type->save != NULL) {
+ const char *role_colorspace = IMB_colormanagement_role_colorspace_name_get(
+ type->default_save_role);
BLI_strncpy(colorspace_settings->name, role_colorspace, sizeof(colorspace_settings->name));
}
}
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index 3e459934db7..37e30d30e2c 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -1130,7 +1130,7 @@ void *DirectDrawSurface::readData(uint &rsize)
if (stream.failed) {
free(data);
- data = NULL;
+ data = nullptr;
rsize = 0;
}
diff --git a/source/blender/imbuf/intern/dds/Image.cpp b/source/blender/imbuf/intern/dds/Image.cpp
index 4cfd7178f29..7958a586c7d 100644
--- a/source/blender/imbuf/intern/dds/Image.cpp
+++ b/source/blender/imbuf/intern/dds/Image.cpp
@@ -32,7 +32,7 @@
#include <stdio.h> /* printf */
-Image::Image() : m_width(0), m_height(0), m_format(Format_RGB), m_data(NULL)
+Image::Image() : m_width(0), m_height(0), m_format(Format_RGB), m_data(nullptr)
{
}
@@ -52,7 +52,7 @@ void Image::allocate(uint w, uint h)
void Image::free()
{
delete[] m_data;
- m_data = NULL;
+ m_data = nullptr;
}
uint Image::width() const
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index 1d29dd4a26b..804d8130b4c 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -42,16 +42,16 @@
extern "C" {
-int imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
+bool imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
{
- return 0; /* todo: finish this function */
+ return false; /* todo: finish this function */
/* check image buffer */
- if (ibuf == 0) {
- return 0;
+ if (ibuf == nullptr) {
+ return false;
}
- if (ibuf->rect == 0) {
- return 0;
+ if (ibuf->rect == nullptr) {
+ return false;
}
/* open file for writing */
@@ -69,21 +69,24 @@ int imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
fildes << "DDS ";
fildes.close();
- return 1;
+ return true;
}
-int imb_is_a_dds(const unsigned char *mem) /* note: use at most first 32 bytes */
+bool imb_is_a_dds(const unsigned char *mem, const size_t size)
{
+ if (size < 8) {
+ return false;
+ }
/* heuristic check to see if mem contains a DDS file */
/* header.fourcc == FOURCC_DDS */
if ((mem[0] != 'D') || (mem[1] != 'D') || (mem[2] != 'S') || (mem[3] != ' ')) {
- return 0;
+ return false;
}
/* header.size == 124 */
if ((mem[4] != 124) || mem[5] || mem[6] || mem[7]) {
- return 0;
+ return false;
}
- return 1;
+ return true;
}
struct ImBuf *imb_load_dds(const unsigned char *mem,
@@ -91,7 +94,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
int flags,
char colorspace[IM_MAX_SPACE])
{
- struct ImBuf *ibuf = NULL;
+ struct ImBuf *ibuf = nullptr;
DirectDrawSurface dds((unsigned char *)mem, size); /* reads header */
unsigned char bits_per_pixel;
unsigned int *rect;
@@ -100,7 +103,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
int col;
unsigned char *cp = (unsigned char *)&col;
Color32 pixel;
- Color32 *pixels = 0;
+ Color32 *pixels = nullptr;
/* OCIO_TODO: never was able to save DDS, so can't test loading
* but profile used to be set to sRGB and can't see rect_float here, so
@@ -108,28 +111,28 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
*/
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
- if (!imb_is_a_dds(mem)) {
- return 0;
+ if (!imb_is_a_dds(mem, size)) {
+ return nullptr;
}
/* check if DDS is valid and supported */
if (!dds.isValid()) {
/* no need to print error here, just testing if it is a DDS */
if (flags & IB_test) {
- return 0;
+ return nullptr;
}
printf("DDS: not valid; header follows\n");
dds.printInfo();
- return 0;
+ return nullptr;
}
if (!dds.isSupported()) {
printf("DDS: format not supported\n");
- return 0;
+ return nullptr;
}
if ((dds.width() > 65535) || (dds.height() > 65535)) {
printf("DDS: dimensions too large\n");
- return 0;
+ return nullptr;
}
/* convert DDS into ImBuf */
@@ -148,8 +151,8 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
}
}
ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, 0);
- if (ibuf == 0) {
- return 0; /* memory allocation failed */
+ if (ibuf == nullptr) {
+ return nullptr; /* memory allocation failed */
}
ibuf->ftype = IMB_FTYPE_DDS;
@@ -160,7 +163,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
if (!imb_addrectImBuf(ibuf)) {
return ibuf;
}
- if (ibuf->rect == 0) {
+ if (ibuf->rect == nullptr) {
return ibuf;
}
@@ -188,7 +191,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
}
}
else {
- ibuf->dds_data.data = NULL;
+ ibuf->dds_data.data = nullptr;
ibuf->dds_data.size = 0;
}
diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h
index 930205c9efb..931c4f267f9 100644
--- a/source/blender/imbuf/intern/dds/dds_api.h
+++ b/source/blender/imbuf/intern/dds/dds_api.h
@@ -26,8 +26,8 @@
extern "C" {
#endif
-int imb_is_a_dds(const unsigned char *mem); /* use only first 32 bytes of mem */
-int imb_save_dds(struct ImBuf *ibuf, const char *name, int flags);
+bool imb_is_a_dds(const unsigned char *mem, const size_t size);
+bool imb_save_dds(struct ImBuf *ibuf, const char *name, int flags);
struct ImBuf *imb_load_dds(const unsigned char *mem,
size_t size,
int flags,
diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c
index 5aa588da36d..b1fe557a9bf 100644
--- a/source/blender/imbuf/intern/filetype.c
+++ b/source/blender/imbuf/intern/filetype.c
@@ -40,192 +40,197 @@
# include "dds/dds_api.h"
#endif
-static int imb_ftype_default(const ImFileType *type, const ImBuf *ibuf)
-{
- return (ibuf->ftype == type->filetype);
-}
-static int imb_ftype_iris(const ImFileType *type, const ImBuf *ibuf)
-{
- (void)type;
- return (ibuf->ftype == IMB_FTYPE_IMAGIC);
-}
-
const ImFileType IMB_FILE_TYPES[] = {
- {NULL,
- NULL,
- imb_is_a_jpeg,
- NULL,
- imb_ftype_default,
- imb_load_jpeg,
- NULL,
- imb_savejpeg,
- NULL,
- 0,
- IMB_FTYPE_JPG,
- COLOR_ROLE_DEFAULT_BYTE},
- {NULL,
- NULL,
- imb_is_a_png,
- NULL,
- imb_ftype_default,
- imb_loadpng,
- NULL,
- imb_savepng,
- NULL,
- 0,
- IMB_FTYPE_PNG,
- COLOR_ROLE_DEFAULT_BYTE},
- {NULL,
- NULL,
- imb_is_a_bmp,
- NULL,
- imb_ftype_default,
- imb_bmp_decode,
- NULL,
- imb_savebmp,
- NULL,
- 0,
- IMB_FTYPE_BMP,
- COLOR_ROLE_DEFAULT_BYTE},
- {NULL,
- NULL,
- imb_is_a_targa,
- NULL,
- imb_ftype_default,
- imb_loadtarga,
- NULL,
- imb_savetarga,
- NULL,
- 0,
- IMB_FTYPE_TGA,
- COLOR_ROLE_DEFAULT_BYTE},
- {NULL,
- NULL,
- imb_is_a_iris,
- NULL,
- imb_ftype_iris,
- imb_loadiris,
- NULL,
- imb_saveiris,
- NULL,
- 0,
- IMB_FTYPE_IMAGIC,
- COLOR_ROLE_DEFAULT_BYTE},
+ {
+ .init = NULL,
+ .exit = NULL,
+ .is_a = imb_is_a_jpeg,
+ .load = imb_load_jpeg,
+ .load_filepath = NULL,
+ .save = imb_savejpeg,
+ .load_tile = NULL,
+ .flag = 0,
+ .filetype = IMB_FTYPE_JPG,
+ .default_save_role = COLOR_ROLE_DEFAULT_BYTE,
+ },
+ {
+ .init = NULL,
+ .exit = NULL,
+ .is_a = imb_is_a_png,
+ .load = imb_loadpng,
+ .load_filepath = NULL,
+ .save = imb_savepng,
+ .load_tile = NULL,
+ .flag = 0,
+ .filetype = IMB_FTYPE_PNG,
+ .default_save_role = COLOR_ROLE_DEFAULT_BYTE,
+ },
+ {
+ .init = NULL,
+ .exit = NULL,
+ .is_a = imb_is_a_bmp,
+ .load = imb_bmp_decode,
+ .load_filepath = NULL,
+ .save = imb_savebmp,
+ .load_tile = NULL,
+ .flag = 0,
+ .filetype = IMB_FTYPE_BMP,
+ .default_save_role = COLOR_ROLE_DEFAULT_BYTE,
+ },
+ {
+ .init = NULL,
+ .exit = NULL,
+ .is_a = imb_is_a_targa,
+ .load = imb_loadtarga,
+ .load_filepath = NULL,
+ .save = imb_savetarga,
+ .load_tile = NULL,
+ .flag = 0,
+ .filetype = IMB_FTYPE_TGA,
+ .default_save_role = COLOR_ROLE_DEFAULT_BYTE,
+ },
+ {
+ .init = NULL,
+ .exit = NULL,
+ .is_a = imb_is_a_iris,
+ .load = imb_loadiris,
+ .load_filepath = NULL,
+ .save = imb_saveiris,
+ .load_tile = NULL,
+ .flag = 0,
+ .filetype = IMB_FTYPE_IMAGIC,
+ .default_save_role = COLOR_ROLE_DEFAULT_BYTE,
+ },
#ifdef WITH_CINEON
- {NULL,
- NULL,
- imb_is_dpx,
- NULL,
- imb_ftype_default,
- imb_load_dpx,
- NULL,
- imb_save_dpx,
- NULL,
- IM_FTYPE_FLOAT,
- IMB_FTYPE_DPX,
- COLOR_ROLE_DEFAULT_FLOAT},
- {NULL,
- NULL,
- imb_is_cineon,
- NULL,
- imb_ftype_default,
- imb_load_cineon,
- NULL,
- imb_save_cineon,
- NULL,
- IM_FTYPE_FLOAT,
- IMB_FTYPE_CINEON,
- COLOR_ROLE_DEFAULT_FLOAT},
+ {
+ .init = NULL,
+ .exit = NULL,
+ .is_a = imb_is_a_dpx,
+ .load = imb_load_dpx,
+ .load_filepath = NULL,
+ .save = imb_save_dpx,
+ .load_tile = NULL,
+ .flag = IM_FTYPE_FLOAT,
+ .filetype = IMB_FTYPE_DPX,
+ .default_save_role = COLOR_ROLE_DEFAULT_FLOAT,
+ },
+ {
+ .init = NULL,
+ .exit = NULL,
+ .is_a = imb_is_a_cineon,
+ .load = imb_load_cineon,
+ .load_filepath = NULL,
+ .save = imb_save_cineon,
+ .load_tile = NULL,
+ .flag = IM_FTYPE_FLOAT,
+ .filetype = IMB_FTYPE_CINEON,
+ .default_save_role = COLOR_ROLE_DEFAULT_FLOAT,
+ },
#endif
#ifdef WITH_TIFF
- {imb_inittiff,
- NULL,
- imb_is_a_tiff,
- NULL,
- imb_ftype_default,
- imb_loadtiff,
- NULL,
- imb_savetiff,
- imb_loadtiletiff,
- 0,
- IMB_FTYPE_TIF,
- COLOR_ROLE_DEFAULT_BYTE},
+ {
+ .init = imb_inittiff,
+ .exit = NULL,
+ .is_a = imb_is_a_tiff,
+ .load = imb_loadtiff,
+ .load_filepath = NULL,
+ .save = imb_savetiff,
+ .load_tile = imb_loadtiletiff,
+ .flag = 0,
+ .filetype = IMB_FTYPE_TIF,
+ .default_save_role = COLOR_ROLE_DEFAULT_BYTE,
+ },
#endif
#ifdef WITH_HDR
- {NULL,
- NULL,
- imb_is_a_hdr,
- NULL,
- imb_ftype_default,
- imb_loadhdr,
- NULL,
- imb_savehdr,
- NULL,
- IM_FTYPE_FLOAT,
- IMB_FTYPE_RADHDR,
- COLOR_ROLE_DEFAULT_FLOAT},
+ {
+ .init = NULL,
+ .exit = NULL,
+ .is_a = imb_is_a_hdr,
+ .load = imb_loadhdr,
+ .load_filepath = NULL,
+ .save = imb_savehdr,
+ .load_tile = NULL,
+ .flag = IM_FTYPE_FLOAT,
+ .filetype = IMB_FTYPE_RADHDR,
+ .default_save_role = COLOR_ROLE_DEFAULT_FLOAT,
+ },
#endif
#ifdef WITH_OPENEXR
- {imb_initopenexr,
- imb_exitopenexr,
- imb_is_a_openexr,
- NULL,
- imb_ftype_default,
- imb_load_openexr,
- NULL,
- imb_save_openexr,
- NULL,
- IM_FTYPE_FLOAT,
- IMB_FTYPE_OPENEXR,
- COLOR_ROLE_DEFAULT_FLOAT},
+ {
+ .init = imb_initopenexr,
+ .exit = imb_exitopenexr,
+ .is_a = imb_is_a_openexr,
+ .load = imb_load_openexr,
+ .load_filepath = NULL,
+ .save = imb_save_openexr,
+ .load_tile = NULL,
+ .flag = IM_FTYPE_FLOAT,
+ .filetype = IMB_FTYPE_OPENEXR,
+ .default_save_role = COLOR_ROLE_DEFAULT_FLOAT,
+ },
#endif
#ifdef WITH_OPENJPEG
- {NULL,
- NULL,
- imb_is_a_jp2,
- NULL,
- imb_ftype_default,
- imb_load_jp2,
- NULL,
- imb_save_jp2,
- NULL,
- IM_FTYPE_FLOAT,
- IMB_FTYPE_JP2,
- COLOR_ROLE_DEFAULT_BYTE},
+ {
+ .init = NULL,
+ .exit = NULL,
+ .is_a = imb_is_a_jp2,
+ .load = imb_load_jp2,
+ .load_filepath = NULL,
+ .save = imb_save_jp2,
+ .load_tile = NULL,
+ .flag = IM_FTYPE_FLOAT,
+ .filetype = IMB_FTYPE_JP2,
+ .default_save_role = COLOR_ROLE_DEFAULT_BYTE,
+ },
#endif
#ifdef WITH_DDS
- {NULL,
- NULL,
- imb_is_a_dds,
- NULL,
- imb_ftype_default,
- imb_load_dds,
- NULL,
- NULL,
- NULL,
- 0,
- IMB_FTYPE_DDS,
- COLOR_ROLE_DEFAULT_BYTE},
+ {
+ .init = NULL,
+ .exit = NULL,
+ .is_a = imb_is_a_dds,
+ .load = imb_load_dds,
+ .load_filepath = NULL,
+ .save = NULL,
+ .load_tile = NULL,
+ .flag = 0,
+ .filetype = IMB_FTYPE_DDS,
+ .default_save_role = COLOR_ROLE_DEFAULT_BYTE,
+ },
#endif
#ifdef WITH_OPENIMAGEIO
- {NULL,
- NULL,
- NULL,
- imb_is_a_photoshop,
- imb_ftype_default,
- NULL,
- imb_load_photoshop,
- NULL,
- NULL,
- IM_FTYPE_FLOAT,
- IMB_FTYPE_PSD,
- COLOR_ROLE_DEFAULT_FLOAT},
+ {
+ .init = NULL,
+ .exit = NULL,
+ .is_a = imb_is_a_photoshop,
+ .load = NULL,
+ .load_filepath = imb_load_photoshop,
+ .save = NULL,
+ .load_tile = NULL,
+ .flag = IM_FTYPE_FLOAT,
+ .filetype = IMB_FTYPE_PSD,
+ .default_save_role = COLOR_ROLE_DEFAULT_FLOAT,
+ },
#endif
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0},
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0},
};
const ImFileType *IMB_FILE_TYPES_LAST = &IMB_FILE_TYPES[ARRAY_SIZE(IMB_FILE_TYPES) - 1];
+const ImFileType *IMB_file_type_from_ftype(int ftype)
+{
+ for (const ImFileType *type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
+ if (ftype == type->filetype) {
+ return type;
+ }
+ }
+ return NULL;
+}
+
+const ImFileType *IMB_file_type_from_ibuf(const ImBuf *ibuf)
+{
+ return IMB_file_type_from_ftype(ibuf->ftype);
+}
+
void imb_filetypes_init(void)
{
const ImFileType *type;
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index 76717bef537..b5b8cd4a580 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -1218,8 +1218,11 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim,
}
void IMB_anim_index_rebuild(struct IndexBuildContext *context,
+ /* NOLINTNEXTLINE: readability-non-const-parameter. */
short *stop,
+ /* NOLINTNEXTLINE: readability-non-const-parameter. */
short *do_update,
+ /* NOLINTNEXTLINE: readability-non-const-parameter. */
float *progress)
{
switch (context->anim_type) {
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index 12c4c63849c..112b95bf1a1 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -243,8 +243,11 @@ static void test_endian_zbuf(struct ImBuf *ibuf)
/* this one is only def-ed once, strangely... */
#define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0])
-int imb_is_a_iris(const uchar *mem)
+bool imb_is_a_iris(const uchar *mem, size_t size)
{
+ if (size < 2) {
+ return false;
+ }
return ((GS(mem) == IMAGIC) || (GSS(mem) == IMAGIC));
}
@@ -271,7 +274,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors
return NULL;
}
- if (!imb_is_a_iris(mem)) {
+ if (!imb_is_a_iris(mem, size)) {
return NULL;
}
@@ -286,7 +289,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors
rle = ISRLE(image.type);
bpp = BPP(image.type);
- if (bpp != 1 && bpp != 2) {
+ if (!ELEM(bpp, 1, 2)) {
fprintf(stderr, "longimagedata: image must have 1 or 2 byte per pix chan\n");
return NULL;
}
@@ -807,7 +810,7 @@ fail:
* Added: zbuf write
*/
-static int output_iris(uint *lptr, int xsize, int ysize, int zsize, const char *name, int *zptr)
+static bool output_iris(uint *lptr, int xsize, int ysize, int zsize, const char *name, int *zptr)
{
FILE *outf;
IMAGE *image;
@@ -969,10 +972,9 @@ static int compressrow(uchar *lbuf, uchar *rlebuf, int z, int cnt)
return optr - (uchar *)rlebuf;
}
-int imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags)
+bool imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags)
{
short zsize;
- int ret;
zsize = (ibuf->planes + 7) >> 3;
if (flags & IB_zbuf && ibuf->zbuf != NULL) {
@@ -982,11 +984,11 @@ int imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags)
IMB_convert_rgba_to_abgr(ibuf);
test_endian_zbuf(ibuf);
- ret = output_iris(ibuf->rect, ibuf->x, ibuf->y, zsize, filepath, ibuf->zbuf);
+ const bool ok = output_iris(ibuf->rect, ibuf->x, ibuf->y, zsize, filepath, ibuf->zbuf);
/* restore! Quite clumsy, 2 times a switch... maybe better a malloc ? */
IMB_convert_rgba_to_abgr(ibuf);
test_endian_zbuf(ibuf);
- return ret;
+ return ok;
}
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index c7e4fe45a26..e19589317d7 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -58,31 +58,38 @@ enum {
DCP_CINEMA4K = 4,
};
-static bool check_jp2(const unsigned char *mem) /* J2K_CFMT */
+static bool check_jp2(const unsigned char *mem, const size_t size) /* J2K_CFMT */
{
+ if (size < sizeof(JP2_HEAD)) {
+ return false;
+ }
return memcmp(JP2_HEAD, mem, sizeof(JP2_HEAD)) ? 0 : 1;
}
-static bool check_j2k(const unsigned char *mem) /* J2K_CFMT */
+static bool check_j2k(const unsigned char *mem, const size_t size) /* J2K_CFMT */
{
+ if (size < sizeof(J2K_HEAD)) {
+ return false;
+ }
return memcmp(J2K_HEAD, mem, sizeof(J2K_HEAD)) ? 0 : 1;
}
-static OPJ_CODEC_FORMAT format_from_header(const unsigned char mem[JP2_FILEHEADER_SIZE])
+static OPJ_CODEC_FORMAT format_from_header(const unsigned char mem[JP2_FILEHEADER_SIZE],
+ const size_t size)
{
- if (check_jp2(mem)) {
+ if (check_jp2(mem, size)) {
return OPJ_CODEC_JP2;
}
- if (check_j2k(mem)) {
+ if (check_j2k(mem, size)) {
return OPJ_CODEC_J2K;
}
return OPJ_CODEC_UNKNOWN;
}
-int imb_is_a_jp2(const unsigned char *buf)
+bool imb_is_a_jp2(const unsigned char *buf, size_t size)
{
- return (check_jp2(buf) || check_j2k(buf));
+ return (check_jp2(buf, size) || check_j2k(buf, size));
}
/**
@@ -126,6 +133,7 @@ static void info_callback(const char *msg, void *client_data)
} \
(void)0
+/* -------------------------------------------------------------------- */
/** \name Buffer Stream
* \{ */
@@ -217,6 +225,7 @@ static opj_stream_t *opj_stream_create_from_buffer(struct BufInfo *p_file,
/** \} */
+/* -------------------------------------------------------------------- */
/** \name File Stream
* \{ */
@@ -315,7 +324,7 @@ ImBuf *imb_load_jp2(const unsigned char *mem,
int flags,
char colorspace[IM_MAX_SPACE])
{
- const OPJ_CODEC_FORMAT format = (size > JP2_FILEHEADER_SIZE) ? format_from_header(mem) :
+ const OPJ_CODEC_FORMAT format = (size > JP2_FILEHEADER_SIZE) ? format_from_header(mem, size) :
OPJ_CODEC_UNKNOWN;
struct BufInfo buf_wrapper = {
.buf = mem,
@@ -346,7 +355,7 @@ ImBuf *imb_load_jp2_filepath(const char *filepath, int flags, char colorspace[IM
fseek(p_file, 0, SEEK_SET);
- const OPJ_CODEC_FORMAT format = format_from_header(mem);
+ const OPJ_CODEC_FORMAT format = format_from_header(mem, sizeof(mem));
ImBuf *ibuf = imb_load_jp2_stream(stream, format, flags, colorspace);
opj_stream_destroy(stream);
return ibuf;
@@ -1192,22 +1201,22 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
return image;
}
-int imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int flags);
+bool imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int flags);
-int imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags)
+bool imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags)
{
opj_stream_t *stream = opj_stream_create_from_file(
filepath, OPJ_J2K_STREAM_CHUNK_SIZE, false, NULL);
if (stream == NULL) {
return 0;
}
- int ret = imb_save_jp2_stream(ibuf, stream, flags);
+ const bool ok = imb_save_jp2_stream(ibuf, stream, flags);
opj_stream_destroy(stream);
- return ret;
+ return ok;
}
/* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */
-int imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int UNUSED(flags))
+bool imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int UNUSED(flags))
{
int quality = ibuf->foptions.quality;
@@ -1228,7 +1237,7 @@ int imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int UNUSED(fla
image = ibuftoimage(ibuf, &parameters);
opj_codec_t *codec = NULL;
- int ok = false;
+ bool ok = false;
/* JP2 format output */
{
/* get a JP2 compressor handle */
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index 525284bd867..93cdbbb1407 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -57,12 +57,13 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla
static const uchar jpeg_default_quality = 75;
static uchar ibuf_quality;
-int imb_is_a_jpeg(const unsigned char *mem)
+bool imb_is_a_jpeg(const unsigned char *mem, const size_t size)
{
- if ((mem[0] == 0xFF) && (mem[1] == 0xD8)) {
- return 1;
+ const char magic[2] = {0xFF, 0xD8};
+ if (size < sizeof(magic)) {
+ return false;
}
- return 0;
+ return memcmp(mem, magic, sizeof(magic)) == 0;
}
/*----------------------------------------------------------
@@ -246,7 +247,7 @@ static boolean handle_app1(j_decompress_ptr cinfo)
INPUT_BYTE(cinfo, neogeo[i], return false);
}
length = 0;
- if (STREQLEN(neogeo, "NeoGeo", 6)) {
+ if (STRPREFIX(neogeo, "NeoGeo")) {
struct NeoGeo_Word *neogeo_word = (struct NeoGeo_Word *)(neogeo + 6);
ibuf_quality = neogeo_word->quality;
}
@@ -362,7 +363,7 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla
* That is why we need split it to the
* common key/value here.
*/
- if (!STREQLEN(str, "Blender", 7)) {
+ if (!STRPREFIX(str, "Blender")) {
/*
* Maybe the file have text that
* we don't know "what it's", in that
@@ -429,7 +430,7 @@ ImBuf *imb_load_jpeg(const unsigned char *buffer,
struct my_error_mgr jerr;
ImBuf *ibuf;
- if (!imb_is_a_jpeg(buffer)) {
+ if (!imb_is_a_jpeg(buffer, size)) {
return NULL;
}
@@ -608,7 +609,7 @@ static int init_jpeg(FILE *outfile, struct jpeg_compress_struct *cinfo, struct I
return 0;
}
-static int save_stdjpeg(const char *name, struct ImBuf *ibuf)
+static bool save_stdjpeg(const char *name, struct ImBuf *ibuf)
{
FILE *outfile;
struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
@@ -642,7 +643,7 @@ static int save_stdjpeg(const char *name, struct ImBuf *ibuf)
return 1;
}
-int imb_savejpeg(struct ImBuf *ibuf, const char *filepath, int flags)
+bool imb_savejpeg(struct ImBuf *ibuf, const char *filepath, int flags)
{
ibuf->flags = flags;
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
index 71774b335d7..1e8c3c25778 100644
--- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
@@ -101,7 +101,7 @@ static ImBuf *imb_oiio_load_image(
IMB_freeImBuf(ibuf);
}
- return NULL;
+ return nullptr;
}
}
catch (const std::exception &exc) {
@@ -110,7 +110,7 @@ static ImBuf *imb_oiio_load_image(
IMB_freeImBuf(ibuf);
}
- return NULL;
+ return nullptr;
}
/* ImBuf always needs 4 channels */
@@ -141,7 +141,7 @@ static ImBuf *imb_oiio_load_image_float(
IMB_freeImBuf(ibuf);
}
- return NULL;
+ return nullptr;
}
}
catch (const std::exception &exc) {
@@ -150,7 +150,7 @@ static ImBuf *imb_oiio_load_image_float(
IMB_freeImBuf(ibuf);
}
- return NULL;
+ return nullptr;
}
/* ImBuf always needs 4 channels */
@@ -163,16 +163,13 @@ static ImBuf *imb_oiio_load_image_float(
extern "C" {
-int imb_is_a_photoshop(const char *filename)
+bool imb_is_a_photoshop(const unsigned char *mem, size_t size)
{
- const char *photoshop_extension[] = {
- ".psd",
- ".pdd",
- ".psb",
- NULL,
- };
-
- return BLI_path_extension_check_array(filename, photoshop_extension);
+ const unsigned char magic[4] = {'8', 'B', 'P', 'S'};
+ if (size < sizeof(magic)) {
+ return false;
+ }
+ return memcmp(magic, mem, sizeof(magic)) == 0;
}
int imb_save_photoshop(struct ImBuf *ibuf, const char * /*name*/, int flags)
@@ -190,7 +187,7 @@ int imb_save_photoshop(struct ImBuf *ibuf, const char * /*name*/, int flags)
struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspace[IM_MAX_SPACE])
{
- struct ImBuf *ibuf = NULL;
+ struct ImBuf *ibuf = nullptr;
int width, height, components;
bool is_float, is_alpha, is_half;
int basesize;
@@ -198,8 +195,8 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
const bool is_colorspace_manually_set = (colorspace[0] != '\0');
/* load image from file through OIIO */
- if (imb_is_a_photoshop(filename) == 0) {
- return NULL;
+ if (IMB_ispic_type_matches(filename, IMB_FTYPE_PSD) == 0) {
+ return nullptr;
}
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
@@ -208,7 +205,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
if (!in) {
std::cerr << __func__ << ": ImageInput::create() failed:" << std::endl
<< OIIO_NAMESPACE::geterror() << std::endl;
- return NULL;
+ return nullptr;
}
ImageSpec spec, config;
@@ -217,7 +214,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
if (!in->open(filename, spec, config)) {
std::cerr << __func__ << ": ImageInput::open() failed:" << std::endl
<< in->geterror() << std::endl;
- return NULL;
+ return nullptr;
}
if (!is_colorspace_manually_set) {
@@ -248,7 +245,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
if (in) {
in->close();
}
- return NULL;
+ return nullptr;
}
if (is_float) {
@@ -263,7 +260,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
}
if (!ibuf) {
- return NULL;
+ return nullptr;
}
/* ImBuf always needs 4 channels */
@@ -281,7 +278,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
IMB_freeImBuf(ibuf);
}
- return NULL;
+ return nullptr;
}
}
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.h b/source/blender/imbuf/intern/oiio/openimageio_api.h
index 3f5f234099c..659050cdb00 100644
--- a/source/blender/imbuf/intern/oiio/openimageio_api.h
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.h
@@ -31,7 +31,7 @@ extern "C" {
struct ImBuf;
-int imb_is_a_photoshop(const char *name);
+bool imb_is_a_photoshop(const unsigned char *mem, const size_t size);
int imb_save_photoshop(struct ImBuf *ibuf, const char *name, int flags);
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index ca70ec633c1..56188fbe98a 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -330,8 +330,12 @@ extern "C" {
* Test presence of OpenEXR file.
* \param mem: pointer to loaded OpenEXR bitstream
*/
-int imb_is_a_openexr(const unsigned char *mem)
+bool imb_is_a_openexr(const unsigned char *mem, const size_t size)
{
+ /* No define is exposed for this size. */
+ if (size < 4) {
+ return false;
+ }
return Imf::isImfMagic((const char *)mem);
}
@@ -407,10 +411,10 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *name, const int flags
{
const int channels = ibuf->channels;
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
- const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */
+ const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != nullptr; /* summarize */
const int width = ibuf->x;
const int height = ibuf->y;
- OStream *file_stream = NULL;
+ OStream *file_stream = nullptr;
try {
Header header(width, height);
@@ -514,10 +518,10 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const int flag
{
const int channels = ibuf->channels;
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
- const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */
+ const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != nullptr; /* summarize */
const int width = ibuf->x;
const int height = ibuf->y;
- OStream *file_stream = NULL;
+ OStream *file_stream = nullptr;
try {
Header header(width, height);
@@ -551,7 +555,7 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const int flag
int ystride = -xstride * width;
/* last scanline, stride negative */
- float *rect[4] = {NULL, NULL, NULL, NULL};
+ float *rect[4] = {nullptr, nullptr, nullptr, nullptr};
rect[0] = ibuf->rect_float + channels * (height - 1) * width;
rect[1] = (channels >= 2) ? rect[0] + 1 : rect[0];
rect[2] = (channels >= 3) ? rect[0] + 2 : rect[0];
@@ -586,7 +590,7 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const int flag
return true;
}
-int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
+bool imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
{
if (flags & IB_mem) {
imb_addencodedbufferImBuf(ibuf);
@@ -594,15 +598,15 @@ int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
}
if (ibuf->foptions.flag & OPENEXR_HALF) {
- return (int)imb_save_openexr_half(ibuf, name, flags);
+ return imb_save_openexr_half(ibuf, name, flags);
}
/* when no float rect, we save as half (16 bits is sufficient) */
- if (ibuf->rect_float == NULL) {
- return (int)imb_save_openexr_half(ibuf, name, flags);
+ if (ibuf->rect_float == nullptr) {
+ return imb_save_openexr_half(ibuf, name, flags);
}
- return (int)imb_save_openexr_float(ibuf, name, flags);
+ return imb_save_openexr_float(ibuf, name, flags);
}
/* ******* Nicer API, MultiLayer and with Tile file support ************************************ */
@@ -614,7 +618,7 @@ int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
* - separated with a dot: the Layer name (like "Light1" or "Walls" or "Characters")
*/
-static ListBase exrhandles = {NULL, NULL};
+static ListBase exrhandles = {nullptr, nullptr};
typedef struct ExrHandle {
struct ExrHandle *next, *prev;
@@ -691,7 +695,7 @@ void *IMB_exr_get_handle_name(const char *name)
{
ExrHandle *data = (ExrHandle *)BLI_rfindstring(&exrhandles, name, offsetof(ExrHandle, name));
- if (data == NULL) {
+ if (data == nullptr) {
data = (ExrHandle *)IMB_exr_get_handle();
BLI_strncpy(data->name, name, strlen(name) + 1);
}
@@ -754,8 +758,8 @@ static void imb_exr_insert_view_name(char *name_full, const char *passname, cons
{
BLI_assert(!ELEM(name_full, passname, viewname));
- if (viewname == NULL || viewname[0] == '\0') {
- BLI_strncpy(name_full, passname, sizeof(((ExrChannel *)NULL)->name));
+ if (viewname == nullptr || viewname[0] == '\0') {
+ BLI_strncpy(name_full, passname, sizeof(((ExrChannel *)nullptr)->name));
return;
}
@@ -882,11 +886,11 @@ int IMB_exr_begin_write(void *handle,
delete data->ofile;
delete data->ofile_stream;
- data->ofile = NULL;
- data->ofile_stream = NULL;
+ data->ofile = nullptr;
+ data->ofile_stream = nullptr;
}
- return (data->ofile != NULL);
+ return (data->ofile != nullptr);
}
/* only used for writing temp. render results (not image files)
@@ -951,8 +955,8 @@ void IMB_exrtile_begin_write(
delete data->mpofile;
delete data->ofile_stream;
- data->mpofile = NULL;
- data->ofile_stream = NULL;
+ data->mpofile = nullptr;
+ data->ofile_stream = nullptr;
}
}
@@ -973,8 +977,8 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig
delete data->ifile;
delete data->ifile_stream;
- data->ifile = NULL;
- data->ifile_stream = NULL;
+ data->ifile = nullptr;
+ data->ifile_stream = nullptr;
}
if (data->ifile) {
@@ -988,8 +992,14 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig
GetChannelsInMultiPartFile(*data->ifile, channels);
for (size_t i = 0; i < channels.size(); i++) {
- IMB_exr_add_channel(
- data, NULL, channels[i].name.c_str(), channels[i].view.c_str(), 0, 0, NULL, false);
+ IMB_exr_add_channel(data,
+ nullptr,
+ channels[i].name.c_str(),
+ channels[i].view.c_str(),
+ 0,
+ 0,
+ nullptr,
+ false);
echan = (ExrChannel *)data->channels.last;
echan->m->name = channels[i].name;
@@ -1074,7 +1084,7 @@ float *IMB_exr_channel_rect(void *handle,
return echan->rect;
}
- return NULL;
+ return nullptr;
}
void IMB_exr_clear_channels(void *handle)
@@ -1097,7 +1107,7 @@ void IMB_exr_write_channels(void *handle)
if (data->channels.first) {
const size_t num_pixels = ((size_t)data->width) * data->height;
- half *rect_half = NULL, *current_rect_half = NULL;
+ half *rect_half = nullptr, *current_rect_half = nullptr;
/* We allocate teporary storage for half pixels for all the channels at once. */
if (data->num_half_channels != 0) {
@@ -1138,7 +1148,7 @@ void IMB_exr_write_channels(void *handle)
std::cerr << "OpenEXR-writePixels: ERROR: " << exc.what() << std::endl;
}
/* Free temporary buffers. */
- if (rect_half != NULL) {
+ if (rect_half != nullptr) {
MEM_freeN(rect_half);
}
}
@@ -1210,7 +1220,7 @@ void IMB_exr_read_channels(void *handle)
"BlenderMultiChannel");
/* 'previous multilayer attribute, flipped. */
- short flip = (ta && STREQLEN(ta->value().c_str(), "Blender V2.43", 13));
+ short flip = (ta && STRPREFIX(ta->value().c_str(), "Blender V2.43"));
exr_printf(
"\nIMB_exr_read_channels\n%s %-6s %-22s "
@@ -1323,7 +1333,7 @@ void IMB_exr_multilayer_convert(void *handle,
pass->totchan,
pass->chan_id,
pass->view);
- pass->rect = NULL;
+ pass->rect = nullptr;
}
}
}
@@ -1343,11 +1353,11 @@ void IMB_exr_close(void *handle)
delete data->ofile_stream;
delete data->multiView;
- data->ifile = NULL;
- data->ifile_stream = NULL;
- data->ofile = NULL;
- data->mpofile = NULL;
- data->ofile_stream = NULL;
+ data->ifile = nullptr;
+ data->ifile_stream = nullptr;
+ data->ofile = nullptr;
+ data->mpofile = nullptr;
+ data->ofile_stream = nullptr;
for (chan = (ExrChannel *)data->channels.first; chan; chan = chan->next) {
delete chan->m;
@@ -1491,7 +1501,7 @@ static ExrLayer *imb_exr_get_layer(ListBase *lb, char *layname)
{
ExrLayer *lay = (ExrLayer *)BLI_findstring(lb, layname, offsetof(ExrLayer, name));
- if (lay == NULL) {
+ if (lay == nullptr) {
lay = (ExrLayer *)MEM_callocN(sizeof(ExrLayer), "exr layer");
BLI_addtail(lb, lay);
BLI_strncpy(lay->name, layname, EXR_LAY_MAXNAME);
@@ -1504,7 +1514,7 @@ static ExrPass *imb_exr_get_pass(ListBase *lb, char *passname)
{
ExrPass *pass = (ExrPass *)BLI_findstring(lb, passname, offsetof(ExrPass, name));
- if (pass == NULL) {
+ if (pass == nullptr) {
pass = (ExrPass *)MEM_callocN(sizeof(ExrPass), "exr pass");
if (STREQ(passname, "Combined")) {
@@ -1546,7 +1556,7 @@ static ExrHandle *imb_exr_begin_read_mem(IStream &file_stream,
for (size_t i = 0; i < channels.size(); i++) {
IMB_exr_add_channel(
- data, NULL, channels[i].name.c_str(), channels[i].view.c_str(), 0, 0, NULL, false);
+ data, nullptr, channels[i].name.c_str(), channels[i].view.c_str(), 0, 0, nullptr, false);
echan = (ExrChannel *)data->channels.last;
echan->m->name = channels[i].name;
@@ -1588,7 +1598,7 @@ static ExrHandle *imb_exr_begin_read_mem(IStream &file_stream,
if (echan) {
printf("error, too many channels in one pass: %s\n", echan->m->name.c_str());
IMB_exr_close(data);
- return NULL;
+ return nullptr;
}
/* with some heuristics, try to merge the channels in buffers */
@@ -1610,7 +1620,7 @@ static ExrHandle *imb_exr_begin_read_mem(IStream &file_stream,
memset(lookup, 0, sizeof(lookup));
/* we can have RGB(A), XYZ(W), UVA */
- if (pass->totchan == 3 || pass->totchan == 4) {
+ if (ELEM(pass->totchan, 3, 4)) {
if (pass->chan[0]->chan_id == 'B' || pass->chan[1]->chan_id == 'B' ||
pass->chan[2]->chan_id == 'B') {
lookup[(unsigned int)'R'] = 0;
@@ -1723,7 +1733,7 @@ static int exr_has_rgb(MultiPartInputFile &file, const char *rgb_channels[3])
{
/* Common names for RGB-like channels in order. */
static const char *channel_names[] = {
- "R", "Red", "G", "Green", "B", "Blue", "AR", "RA", "AG", "GA", "AB", "BA", NULL};
+ "R", "Red", "G", "Green", "B", "Blue", "AR", "RA", "AG", "GA", "AB", "BA", nullptr};
const Header &header = file.header(0);
int num_channels = 0;
@@ -1746,26 +1756,26 @@ static bool exr_has_luma(MultiPartInputFile &file)
* optionally it could be also channels for chromas called BY and RY.
*/
const Header &header = file.header(0);
- return header.channels().findChannel("Y") != NULL;
+ return header.channels().findChannel("Y") != nullptr;
}
static bool exr_has_chroma(MultiPartInputFile &file)
{
const Header &header = file.header(0);
- return header.channels().findChannel("BY") != NULL &&
- header.channels().findChannel("RY") != NULL;
+ return header.channels().findChannel("BY") != nullptr &&
+ header.channels().findChannel("RY") != nullptr;
}
static bool exr_has_zbuffer(MultiPartInputFile &file)
{
const Header &header = file.header(0);
- return !(header.channels().findChannel("Z") == NULL);
+ return !(header.channels().findChannel("Z") == nullptr);
}
static bool exr_has_alpha(MultiPartInputFile &file)
{
const Header &header = file.header(0);
- return !(header.channels().findChannel("A") == NULL);
+ return !(header.channels().findChannel("A") == nullptr);
}
static bool exr_is_half_float(MultiPartInputFile &file)
@@ -1895,12 +1905,12 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
int flags,
char colorspace[IM_MAX_SPACE])
{
- struct ImBuf *ibuf = NULL;
- IMemStream *membuf = NULL;
- MultiPartInputFile *file = NULL;
+ struct ImBuf *ibuf = nullptr;
+ IMemStream *membuf = nullptr;
+ MultiPartInputFile *file = nullptr;
- if (imb_is_a_openexr(mem) == 0) {
- return NULL;
+ if (imb_is_a_openexr(mem, size) == 0) {
+ return nullptr;
}
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);
@@ -1918,7 +1928,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 (false) { /* debug */
exr_print_filecontents(*file);
}
@@ -2084,7 +2094,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
delete file;
delete membuf;
- return 0;
+ return nullptr;
}
}
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h
index 73db146849b..940715690a7 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.h
+++ b/source/blender/imbuf/intern/openexr/openexr_api.h
@@ -32,9 +32,9 @@ extern "C" {
void imb_initopenexr(void);
void imb_exitopenexr(void);
-int imb_is_a_openexr(const unsigned char *mem);
+bool imb_is_a_openexr(const unsigned char *mem, const size_t size);
-int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags);
+bool imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags);
struct ImBuf *imb_load_openexr(const unsigned char *mem, size_t size, int flags, char *colorspace);
diff --git a/source/blender/imbuf/intern/openexr/openexr_stub.cpp b/source/blender/imbuf/intern/openexr/openexr_stub.cpp
index bfc4291c7b1..51bc2094053 100644
--- a/source/blender/imbuf/intern/openexr/openexr_stub.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_stub.cpp
@@ -26,11 +26,11 @@
void *IMB_exr_get_handle(void)
{
- return NULL;
+ return nullptr;
}
void *IMB_exr_get_handle_name(const char * /*name*/)
{
- return NULL;
+ return nullptr;
}
void IMB_exr_add_channel(void * /*handle*/,
const char * /*layname*/,
@@ -82,7 +82,7 @@ float *IMB_exr_channel_rect(void * /*handle*/,
const char * /*passname*/,
const char * /*view*/)
{
- return NULL;
+ return nullptr;
}
void IMB_exr_read_channels(void * /*handle*/)
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 0104d7e2f17..60fc2ac0867 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -59,19 +59,21 @@ BLI_INLINE unsigned short UPSAMPLE_8_TO_16(const unsigned char _val)
return (_val << 8) + _val;
}
-int imb_is_a_png(const unsigned char *mem)
+bool imb_is_a_png(const unsigned char *mem, size_t size)
{
- int ret_val = 0;
+ const int num_to_check = 8;
+ if (size < num_to_check) {
+ return false;
+ }
+ bool ok = false;
- if (mem) {
#if (PNG_LIBPNG_VER_MAJOR == 1) && (PNG_LIBPNG_VER_MINOR == 2)
- /* Older version of libpng doesn't use const pointer to memory. */
- ret_val = !png_sig_cmp((png_bytep)mem, 0, 8);
+ /* Older version of libpng doesn't use const pointer to memory. */
+ ok = !png_sig_cmp((png_bytep)mem, 0, num_to_check);
#else
- ret_val = !png_sig_cmp(mem, 0, 8);
+ ok = !png_sig_cmp(mem, 0, num_to_check);
#endif
- }
- return ret_val;
+ return ok;
}
static void Flush(png_structp png_ptr)
@@ -119,7 +121,7 @@ BLI_INLINE unsigned short ftoshort(float val)
return unit_float_to_ushort_clamp(val);
}
-int imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags)
+bool imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags)
{
png_structp png_ptr;
png_infop info_ptr;
@@ -522,7 +524,7 @@ static void imb_png_warning(png_structp UNUSED(png_ptr), png_const_charp message
* and with new libpng it became too much picky, giving a warning on
* the splash screen even.
*/
- if ((G.debug & G_DEBUG) == 0 && STREQLEN(message, "iCCP", 4)) {
+ if ((G.debug & G_DEBUG) == 0 && STRPREFIX(message, "iCCP")) {
return;
}
fprintf(stderr, "libpng warning: %s\n", message);
@@ -550,7 +552,7 @@ ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colors
float *to_float;
unsigned int channels;
- if (imb_is_a_png(mem) == 0) {
+ if (imb_is_a_png(mem, size) == 0) {
return NULL;
}
diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c
index 21709fa8603..285b18595f7 100644
--- a/source/blender/imbuf/intern/radiance_hdr.c
+++ b/source/blender/imbuf/intern/radiance_hdr.c
@@ -197,17 +197,22 @@ static void FLOAT2RGBE(const fCOLOR fcol, RGBE rgbe)
/* ImBuf read */
-int imb_is_a_hdr(const unsigned char *buf)
+bool imb_is_a_hdr(const unsigned char *buf, const size_t size)
{
- /* For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead */
- /* update: actually, the 'RADIANCE' part is just an optional program name,
- * the magic word is really only the '#?' part */
- // if (strstr((char *)buf, "#?RADIANCE")) return 1;
- if (memcmp((char *)buf, "#?", 2) == 0) {
- return 1;
+ /* NOTE: `#?RADIANCE` is used by other programs such as `ImageMagik`,
+ * Although there are some files in the wild that only use `#?` (from looking online).
+ * If this is ever a problem we could check for the longer header since this is part of the spec.
+ *
+ * We could check `32-bit_rle_rgbe` or `32-bit_rle_xyze` too since this is part of the format.
+ * Currently this isn't needed.
+ *
+ * See: http://paulbourke.net/dataformats/pic/
+ */
+ const unsigned char magic[2] = {'#', '?'};
+ if (size < sizeof(magic)) {
+ return false;
}
- // if (strstr((char *)buf, "32-bit_rle_rgbe")) return 1;
- return 0;
+ return memcmp(buf, magic, sizeof(magic)) == 0;
}
struct ImBuf *imb_loadhdr(const unsigned char *mem,
@@ -224,7 +229,7 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem,
const unsigned char *ptr, *mem_eof = mem + size;
char oriY[80], oriX[80];
- if (imb_is_a_hdr((void *)mem)) {
+ if (imb_is_a_hdr(mem, size)) {
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);
/* find empty line, next line is resolution info */
@@ -329,9 +334,9 @@ static int fwritecolrs(
fcol[BLU] = (channels >= 3) ? fpscan[j + 2] : fpscan[j];
}
else {
- fcol[RED] = (float)ibufscan[j] / 255.f;
- fcol[GRN] = (float)((channels >= 2) ? ibufscan[j + 1] : ibufscan[j]) / 255.f;
- fcol[BLU] = (float)((channels >= 3) ? ibufscan[j + 2] : ibufscan[j]) / 255.f;
+ fcol[RED] = (float)ibufscan[j] / 255.0f;
+ fcol[GRN] = (float)((channels >= 2) ? ibufscan[j + 1] : ibufscan[j]) / 255.0f;
+ fcol[BLU] = (float)((channels >= 3) ? ibufscan[j + 2] : ibufscan[j]) / 255.0f;
}
FLOAT2RGBE(fcol, rgbe);
COPY_RGBE(rgbe, rgbe_scan[i]);
@@ -409,7 +414,7 @@ static void writeHeader(FILE *file, int width, int height)
fputc(10, file);
}
-int imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags)
+bool imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags)
{
FILE *file = BLI_fopen(filepath, "wb");
float *fp = NULL;
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index 8b322eaf052..f0daa4543e1 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -282,7 +282,6 @@ ImBuf *IMB_testiffname(const char *filepath, int flags)
static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int *rect)
{
- const ImFileType *type;
unsigned char *mem;
size_t size;
@@ -301,8 +300,9 @@ static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int
return;
}
- for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
- if (type->load_tile && type->ftype(type, ibuf)) {
+ const ImFileType *type = IMB_file_type_from_ibuf(ibuf);
+ if (type != NULL) {
+ if (type->load_tile != NULL) {
type->load_tile(ibuf, mem, size, tx, ty, rect);
}
}
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c
index 8b4f33bb306..6ae93def50f 100644
--- a/source/blender/imbuf/intern/rectop.c
+++ b/source/blender/imbuf/intern/rectop.c
@@ -1069,8 +1069,11 @@ void IMB_rectblend_threaded(ImBuf *dbuf,
}
}
-/* fill */
-
+/**
+ * Replace pixels of entire image with solid color.
+ * \param ibuf: An image to be filled with color. It must be 4 channel image.
+ * \param col: RGBA color, which is assigned directly to both byte (via scaling) and float buffers.
+ */
void IMB_rectfill(ImBuf *drect, const float col[4])
{
int num;
@@ -1103,6 +1106,61 @@ void IMB_rectfill(ImBuf *drect, const float col[4])
}
}
+/**
+ * Replace pixels of image area with solid color.
+ * \param ibuf: an image to be filled with color. It must be 4 channel image.
+ * \param col: RGBA color, which is assigned directly to both byte (via scaling) and float buffers.
+ * \param x1, y1, x2, y2: (x1, y1) defines starting point of the rectangular area to be filled,
+ * (x2, y2) is the end point. Note that values are allowed to be loosely ordered, which means that
+ * x2 is allowed to be lower than x1, as well as y2 is allowed to be lower than y1. No matter the
+ * order the area between x1 and x2, and y1 and y2 is filled.
+ */
+void IMB_rectfill_area_replace(
+ const ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2)
+{
+ /* Sanity checks. */
+ BLI_assert(ibuf->channels == 4);
+
+ if (ibuf->channels != 4) {
+ return;
+ }
+
+ int width = ibuf->x;
+ int height = ibuf->y;
+ CLAMP(x1, 0, width);
+ CLAMP(x2, 0, width);
+ CLAMP(y1, 0, height);
+ CLAMP(y2, 0, height);
+
+ if (x1 > x2) {
+ SWAP(int, x1, x2);
+ }
+ if (y1 > y2) {
+ SWAP(int, y1, y2);
+ }
+ if (x1 == x2 || y1 == y2) {
+ return;
+ }
+
+ unsigned char col_char[4] = {col[0] * 255, col[1] * 255, col[2] * 255, col[3] * 255};
+
+ for (int y = y1; y < y2; y++) {
+ for (int x = x1; x < x2; x++) {
+ size_t offset = ((size_t)ibuf->x) * y * 4 + 4 * x;
+
+ if (ibuf->rect) {
+ unsigned char *rrect = (unsigned char *)ibuf->rect + offset;
+ memcpy(rrect, &col_char, sizeof(unsigned char) * 4);
+ }
+
+ if (ibuf->rect_float) {
+ float *rrectf = ibuf->rect_float + offset;
+ memcpy(rrectf, &col, sizeof(float) * 4);
+ }
+ }
+ }
+}
+
void buf_rectfill_area(unsigned char *rect,
float *rectf,
int width,
@@ -1214,6 +1272,21 @@ void buf_rectfill_area(unsigned char *rect,
}
}
+/**
+ * Blend pixels of image area with solid color.
+ *
+ * For images with `uchar` buffer use color matching image color-space.
+ * For images with float buffer use color display color-space.
+ * If display color-space can not be referenced, use color in SRGB color-space.
+ *
+ * \param ibuf: an image to be filled with color. It must be 4 channel image.
+ * \param col: RGBA color.
+ * \param x1, y1, x2, y2: (x1, y1) defines starting point of the rectangular area to be filled,
+ * (x2, y2) is the end point. Note that values are allowed to be loosely ordered, which means that
+ * x2 is allowed to be lower than x1, as well as y2 is allowed to be lower than y1. No matter the
+ * order the area between x1 and x2, and y1 and y2 is filled.
+ * \param display: color-space reference for display space.
+ */
void IMB_rectfill_area(ImBuf *ibuf,
const float col[4],
int x1,
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index 5f373e4bd3a..a9833623250 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -60,6 +60,14 @@ typedef struct TARGA {
unsigned char imgdes;
} TARGA;
+/**
+ * On-disk header size.
+ *
+ * \note In theory it's possible padding would make the struct and on-disk size differ,
+ * so use a constant instead of `sizeof(TARGA)`.
+ */
+#define TARGA_HEADER_SIZE 18
+
/***/
static int tga_out1(unsigned int data, FILE *file)
@@ -286,14 +294,12 @@ static bool dumptarga(struct ImBuf *ibuf, FILE *file)
return 1;
}
-int imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags)
+bool imb_savetarga(struct ImBuf *ibuf, const char *filepath, int UNUSED(flags))
{
- char buf[20] = {0};
+ char buf[TARGA_HEADER_SIZE] = {0};
FILE *fildes;
bool ok = false;
- (void)flags; /* unused */
-
buf[16] = (ibuf->planes + 0x7) & ~0x7;
if (ibuf->planes > 8) {
buf[2] = 10;
@@ -326,7 +332,7 @@ int imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags)
return 0;
}
- if (fwrite(buf, 1, 18, fildes) != 18) {
+ if (fwrite(buf, 1, TARGA_HEADER_SIZE, fildes) != TARGA_HEADER_SIZE) {
fclose(fildes);
return 0;
}
@@ -355,8 +361,12 @@ int imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags)
return ok;
}
-static int checktarga(TARGA *tga, const unsigned char *mem)
+static bool checktarga(TARGA *tga, const unsigned char *mem, const size_t size)
{
+ if (size < TARGA_HEADER_SIZE) {
+ return false;
+ }
+
tga->numid = mem[0];
tga->maptyp = mem[1];
tga->imgtyp = mem[2];
@@ -372,7 +382,7 @@ static int checktarga(TARGA *tga, const unsigned char *mem)
tga->imgdes = mem[17];
if (tga->maptyp > 1) {
- return 0;
+ return false;
}
switch (tga->imgtyp) {
case 1: /* raw cmap */
@@ -383,31 +393,31 @@ static int checktarga(TARGA *tga, const unsigned char *mem)
case 11: /* b&w */
break;
default:
- return 0;
+ return false;
}
if (tga->mapsize && tga->mapbits > 32) {
- return 0;
+ return false;
}
if (tga->xsize <= 0) {
- return 0;
+ return false;
}
if (tga->ysize <= 0) {
- return 0;
+ return false;
}
if (tga->pixsize > 32) {
- return 0;
+ return false;
}
if (tga->pixsize == 0) {
- return 0;
+ return false;
}
- return 1;
+ return true;
}
-int imb_is_a_targa(const unsigned char *buf)
+bool imb_is_a_targa(const unsigned char *buf, size_t size)
{
TARGA tga;
- return checktarga(&tga, buf);
+ return checktarga(&tga, buf, size);
}
static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect)
@@ -627,7 +637,7 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
int32_t cp_data;
uchar *cp = (uchar *)&cp_data;
- if (checktarga(&tga, mem) == 0) {
+ if (checktarga(&tga, mem, mem_size) == 0) {
return NULL;
}
@@ -647,7 +657,7 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
if (tga.imgtyp < 4) {
ibuf->foptions.flag |= RAWTGA;
}
- mem = mem + 18 + tga.numid;
+ mem = mem + TARGA_HEADER_SIZE + tga.numid;
cp[0] = 0xff;
cp[1] = cp[2] = 0;
@@ -703,7 +713,7 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
return ibuf;
}
- if (tga.imgtyp != 1 && tga.imgtyp != 9) { /* happens sometimes (beuh) */
+ if (!ELEM(tga.imgtyp, 1, 9)) { /* happens sometimes (beuh) */
if (cmap) {
MEM_freeN(cmap);
cmap = NULL;
@@ -777,7 +787,7 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
ibuf->planes = 24;
}
- if (tga.imgtyp == 3 || tga.imgtyp == 11) {
+ if (ELEM(tga.imgtyp, 3, 11)) {
uchar *crect;
unsigned int *lrect, col;
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c
index cd0b012d809..587d6ad9e7e 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -316,10 +316,13 @@ static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, const unsigned char *
* hence my manual comparison. - Jonathan Merritt (lancelet) 4th Sept 2005.
*/
#define IMB_TIFF_NCB 4 /* number of comparison bytes used */
-int imb_is_a_tiff(const unsigned char *buf)
+bool imb_is_a_tiff(const unsigned char *buf, size_t size)
{
const char big_endian[IMB_TIFF_NCB] = {0x4d, 0x4d, 0x00, 0x2a};
const char lil_endian[IMB_TIFF_NCB] = {0x49, 0x49, 0x2a, 0x00};
+ if (size < IMB_TIFF_NCB) {
+ return false;
+ }
return ((memcmp(big_endian, buf, IMB_TIFF_NCB) == 0) ||
(memcmp(lil_endian, buf, IMB_TIFF_NCB) == 0));
@@ -578,7 +581,7 @@ ImBuf *imb_loadtiff(const unsigned char *mem,
fprintf(stderr, "imb_loadtiff: size < IMB_TIFF_NCB\n");
return NULL;
}
- if (imb_is_a_tiff(mem) == 0) {
+ if (imb_is_a_tiff(mem, size) == 0) {
return NULL;
}
@@ -759,8 +762,7 @@ void imb_loadtiletiff(
*
* \return 1 if the function is successful, 0 on failure.
*/
-
-int imb_savetiff(ImBuf *ibuf, const char *filepath, int flags)
+bool imb_savetiff(ImBuf *ibuf, const char *filepath, int flags)
{
TIFF *image = NULL;
uint16 samplesperpixel, bitspersample;
@@ -888,7 +890,7 @@ int imb_savetiff(ImBuf *ibuf, const char *filepath, int flags)
/* convert from float source */
float rgb[4];
- if (channels_in_float == 3 || channels_in_float == 4) {
+ if (ELEM(channels_in_float, 3, 4)) {
if (ibuf->float_colorspace || (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA)) {
/* Float buffer was managed already, no need in color
* space conversion.
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index 64b03f332a8..64dad5de902 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -117,75 +117,94 @@ const char *imb_ext_audio[] = {
NULL,
};
-int IMB_ispic_type(const char *name)
-{
- /* increased from 32 to 64 because of the bitmaps header size */
+/* Increased from 32 to 64 because of the bitmaps header size. */
#define HEADER_SIZE 64
- unsigned char buf[HEADER_SIZE];
- const ImFileType *type;
+static ssize_t imb_ispic_read_header_from_filepath(const char *filepath,
+ unsigned char buf[HEADER_SIZE])
+{
BLI_stat_t st;
int fp;
- BLI_assert(!BLI_path_is_rel(name));
+ BLI_assert(!BLI_path_is_rel(filepath));
if (UTIL_DEBUG) {
- printf("%s: loading %s\n", __func__, name);
+ printf("%s: loading %s\n", __func__, filepath);
}
- if (BLI_stat(name, &st) == -1) {
- return false;
+ if (BLI_stat(filepath, &st) == -1) {
+ return -1;
}
if (((st.st_mode) & S_IFMT) != S_IFREG) {
- return false;
+ return -1;
}
- if ((fp = BLI_open(name, O_BINARY | O_RDONLY, 0)) == -1) {
- return false;
+ if ((fp = BLI_open(filepath, O_BINARY | O_RDONLY, 0)) == -1) {
+ return -1;
}
- memset(buf, 0, sizeof(buf));
- if (read(fp, buf, HEADER_SIZE) <= 0) {
- close(fp);
- return false;
- }
+ const ssize_t size = read(fp, buf, HEADER_SIZE);
close(fp);
+ return size;
+}
- /* XXX move this exception */
- if ((BIG_LONG(((int *)buf)[0]) & 0xfffffff0) == 0xffd8ffe0) {
- return IMB_FTYPE_JPG;
- }
-
- for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
- if (type->is_a) {
- if (type->is_a(buf)) {
- return type->filetype;
- }
- }
- else if (type->is_a_filepath) {
- if (type->is_a_filepath(name)) {
+int IMB_ispic_type_from_memory(const unsigned char *buf, const size_t buf_size)
+{
+ for (const ImFileType *type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
+ if (type->is_a != NULL) {
+ if (type->is_a(buf, buf_size)) {
return type->filetype;
}
}
}
- return 0;
+ return IMB_FTYPE_NONE;
+}
-#undef HEADER_SIZE
+int IMB_ispic_type(const char *filepath)
+{
+ unsigned char buf[HEADER_SIZE];
+ const ssize_t buf_size = imb_ispic_read_header_from_filepath(filepath, buf);
+ if (buf_size <= 0) {
+ return IMB_FTYPE_NONE;
+ }
+ return IMB_ispic_type_from_memory(buf, (size_t)buf_size);
+}
+
+bool IMB_ispic_type_matches(const char *filepath, int filetype)
+{
+ unsigned char buf[HEADER_SIZE];
+ const ssize_t buf_size = imb_ispic_read_header_from_filepath(filepath, buf);
+ if (buf_size <= 0) {
+ return false;
+ }
+
+ const ImFileType *type = IMB_file_type_from_ftype(filetype);
+ if (type != NULL) {
+ /* Requesting to load a type that can't check it's own header doesn't make sense.
+ * Keep the check for developers. */
+ BLI_assert(type->is_a != NULL);
+ if (type->is_a != NULL) {
+ return type->is_a(buf, (size_t)buf_size);
+ }
+ }
+ return false;
}
-bool IMB_ispic(const char *name)
+#undef HEADER_SIZE
+
+bool IMB_ispic(const char *filepath)
{
- return (IMB_ispic_type(name) != 0);
+ return (IMB_ispic_type(filepath) != IMB_FTYPE_NONE);
}
-static int isavi(const char *name)
+static bool isavi(const char *filepath)
{
#ifdef WITH_AVI
- return AVI_is_avi(name);
+ return AVI_is_avi(filepath);
#else
- (void)name;
+ (void)filepath;
return false;
#endif
}
@@ -244,7 +263,7 @@ const char *IMB_ffmpeg_last_error(void)
return ffmpeg_last_error;
}
-static int isffmpeg(const char *filename)
+static int isffmpeg(const char *filepath)
{
AVFormatContext *pFormatCtx = NULL;
unsigned int i;
@@ -252,7 +271,7 @@ static int isffmpeg(const char *filename)
AVCodec *pCodec;
AVCodecContext *pCodecCtx;
- if (BLI_path_extension_check_n(filename,
+ if (BLI_path_extension_check_n(filepath,
".swf",
".jpg",
".jp2",
@@ -269,7 +288,7 @@ static int isffmpeg(const char *filename)
return 0;
}
- if (avformat_open_input(&pFormatCtx, filename, NULL, NULL) != 0) {
+ if (avformat_open_input(&pFormatCtx, filepath, NULL, NULL) != 0) {
if (UTIL_DEBUG) {
fprintf(stderr, "isffmpeg: av_open_input_file failed\n");
}
@@ -285,7 +304,7 @@ static int isffmpeg(const char *filename)
}
if (UTIL_DEBUG) {
- av_dump_format(pFormatCtx, 0, filename, 0);
+ av_dump_format(pFormatCtx, 0, filepath, 0);
}
/* Find the first video stream */
@@ -324,83 +343,82 @@ static int isffmpeg(const char *filename)
}
#endif
-int imb_get_anim_type(const char *name)
+int imb_get_anim_type(const char *filepath)
{
- int type;
BLI_stat_t st;
- BLI_assert(!BLI_path_is_rel(name));
+ BLI_assert(!BLI_path_is_rel(filepath));
if (UTIL_DEBUG) {
- printf("%s: %s\n", __func__, name);
+ printf("%s: %s\n", __func__, filepath);
}
#ifndef _WIN32
# ifdef WITH_FFMPEG
/* stat test below fails on large files > 4GB */
- if (isffmpeg(name)) {
+ if (isffmpeg(filepath)) {
return ANIM_FFMPEG;
}
# endif
- if (BLI_stat(name, &st) == -1) {
+ if (BLI_stat(filepath, &st) == -1) {
return 0;
}
if (((st.st_mode) & S_IFMT) != S_IFREG) {
return 0;
}
- if (isavi(name)) {
+ if (isavi(filepath)) {
return ANIM_AVI;
}
- if (ismovie(name)) {
+ if (ismovie(filepath)) {
return ANIM_MOVIE;
}
-#else
- if (BLI_stat(name, &st) == -1) {
+#else /* !_WIN32 */
+ if (BLI_stat(filepath, &st) == -1) {
return 0;
}
if (((st.st_mode) & S_IFMT) != S_IFREG) {
return 0;
}
- if (ismovie(name)) {
+ if (ismovie(filepath)) {
return ANIM_MOVIE;
}
# ifdef WITH_FFMPEG
- if (isffmpeg(name)) {
+ if (isffmpeg(filepath)) {
return ANIM_FFMPEG;
}
# endif
- if (isavi(name)) {
+ if (isavi(filepath)) {
return ANIM_AVI;
}
-#endif
- type = IMB_ispic(name);
- if (type) {
+#endif /* !_WIN32 */
+
+ /* Assume a single image is part of an image sequence. */
+ if (IMB_ispic(filepath)) {
return ANIM_SEQUENCE;
}
return ANIM_NONE;
}
-bool IMB_isanim(const char *filename)
+bool IMB_isanim(const char *filepath)
{
int type;
- type = imb_get_anim_type(filename);
+ type = imb_get_anim_type(filepath);
return (type && type != ANIM_SEQUENCE);
}
bool IMB_isfloat(const ImBuf *ibuf)
{
- const ImFileType *type;
-
- for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
- if (type->ftype(type, ibuf)) {
- return (type->flag & IM_FTYPE_FLOAT) != 0;
+ const ImFileType *type = IMB_file_type_from_ibuf(ibuf);
+ if (type != NULL) {
+ if (type->flag & IM_FTYPE_FLOAT) {
+ return true;
}
}
return false;
diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c
index e321470559a..f21d274f8fd 100644
--- a/source/blender/imbuf/intern/writeimage.c
+++ b/source/blender/imbuf/intern/writeimage.c
@@ -41,10 +41,8 @@ static bool prepare_write_imbuf(const ImFileType *type, ImBuf *ibuf)
return IMB_prepare_write_ImBuf((type->flag & IM_FTYPE_FLOAT), ibuf);
}
-short IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
+bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
{
- const ImFileType *type;
-
errno = 0;
BLI_assert(!BLI_path_is_rel(filepath));
@@ -54,15 +52,11 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
}
ibuf->flags = flags;
- for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
- if (type->save && type->ftype(type, ibuf)) {
- short result = false;
-
+ const ImFileType *type = IMB_file_type_from_ibuf(ibuf);
+ if (type != NULL) {
+ if (type->save != NULL) {
prepare_write_imbuf(type, ibuf);
-
- result = type->save(ibuf, filepath, flags);
-
- return result;
+ return type->save(ibuf, filepath, flags);
}
}
diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc
index 892109dc578..5b8998a0b1a 100644
--- a/source/blender/io/alembic/exporter/abc_export_capi.cc
+++ b/source/blender/io/alembic/exporter/abc_export_capi.cc
@@ -227,8 +227,8 @@ bool ABC_export(Scene *scene,
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_FRAME, NC_SCENE | ND_FRAME);
WM_jobs_callbacks(wm_job,
blender::io::alembic::export_startjob,
- NULL,
- NULL,
+ nullptr,
+ nullptr,
blender::io::alembic::export_endjob);
WM_jobs_start(CTX_wm_manager(C), wm_job);
@@ -236,7 +236,7 @@ bool ABC_export(Scene *scene,
else {
/* Fake a job context, so that we don't need NULL pointer checks while exporting. */
short stop = 0, do_update = 0;
- float progress = 0.f;
+ float progress = 0.0f;
blender::io::alembic::export_startjob(job, &stop, &do_update, &progress);
blender::io::alembic::export_endjob(job);
diff --git a/source/blender/io/alembic/exporter/abc_subdiv_disabler.cc b/source/blender/io/alembic/exporter/abc_subdiv_disabler.cc
index 255803a6bfb..334a26df784 100644
--- a/source/blender/io/alembic/exporter/abc_subdiv_disabler.cc
+++ b/source/blender/io/alembic/exporter/abc_subdiv_disabler.cc
@@ -92,7 +92,7 @@ ModifierData *SubdivModifierDisabler::get_subdiv_modifier(Scene *scene, Object *
}
/* mesh is not a subsurf. break */
- if ((md->type != eModifierType_Displace) && (md->type != eModifierType_ParticleSystem)) {
+ if (!ELEM(md->type, eModifierType_Displace, eModifierType_ParticleSystem)) {
return nullptr;
}
}
diff --git a/source/blender/io/alembic/exporter/abc_writer_curves.cc b/source/blender/io/alembic/exporter/abc_writer_curves.cc
index b57af345a3c..5e01609f930 100644
--- a/source/blender/io/alembic/exporter/abc_writer_curves.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_curves.cc
@@ -135,7 +135,7 @@ void ABCCurveWriter::do_write(HierarchyContext &context)
}
}
- if (nurbs->knotsu != NULL) {
+ if (nurbs->knotsu != nullptr) {
const size_t num_knots = KNOTSU(nurbs);
/* Add an extra knot at the beginning and end of the array since most apps
@@ -189,7 +189,7 @@ ABCCurveMeshWriter::ABCCurveMeshWriter(const ABCWriterConstructorArgs &args)
Mesh *ABCCurveMeshWriter::get_export_mesh(Object *object_eval, bool &r_needsfree)
{
Mesh *mesh_eval = BKE_object_get_evaluated_mesh(object_eval);
- if (mesh_eval != NULL) {
+ if (mesh_eval != nullptr) {
/* Mesh_eval only exists when generative modifiers are in use. */
r_needsfree = false;
return mesh_eval;
diff --git a/source/blender/io/alembic/exporter/abc_writer_hair.cc b/source/blender/io/alembic/exporter/abc_writer_hair.cc
index 072feb2a90a..f8d610a3659 100644
--- a/source/blender/io/alembic/exporter/abc_writer_hair.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_hair.cc
@@ -163,16 +163,17 @@ void ABCHairWriter::write_hair_sample(const HierarchyContext &context,
if (num < mesh->totface) {
/* TODO(Sybren): check whether the NULL check here and if(mface) are actually required */
- MFace *face = mface == NULL ? NULL : &mface[num];
+ MFace *face = mface == nullptr ? nullptr : &mface[num];
MTFace *tface = mtface + num;
if (mface) {
float r_uv[2], mapfw[4], vec[3];
psys_interpolate_uvs(tface, face->v4, pa->fuv, r_uv);
- uv_values.push_back(Imath::V2f(r_uv[0], r_uv[1]));
+ uv_values.emplace_back(r_uv[0], r_uv[1]);
- psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, normal, NULL, NULL, NULL);
+ psys_interpolate_face(
+ mverts, face, tface, nullptr, mapfw, vec, normal, nullptr, nullptr, nullptr);
copy_yup_from_zup(tmp_nor.getValue(), normal);
norm_values.push_back(tmp_nor);
@@ -203,7 +204,7 @@ void ABCHairWriter::write_hair_sample(const HierarchyContext &context,
}
if (vtx[o] == num) {
- uv_values.push_back(Imath::V2f(tface->uv[o][0], tface->uv[o][1]));
+ uv_values.emplace_back(tface->uv[o][0], tface->uv[o][1]);
MVert *mv = mverts + vtx[o];
@@ -230,7 +231,7 @@ void ABCHairWriter::write_hair_sample(const HierarchyContext &context,
mul_m4_v3(inv_mat, vert);
/* Convert Z-up to Y-up. */
- verts.push_back(Imath::V3f(vert[0], vert[2], -vert[1]));
+ verts.emplace_back(vert[0], vert[2], -vert[1]);
}
}
}
@@ -277,12 +278,13 @@ void ABCHairWriter::write_hair_child_sample(const HierarchyContext &context,
float r_uv[2], tmpnor[3], mapfw[4], vec[3];
psys_interpolate_uvs(tface, face->v4, pc->fuv, r_uv);
- uv_values.push_back(Imath::V2f(r_uv[0], r_uv[1]));
+ uv_values.emplace_back(r_uv[0], r_uv[1]);
- psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, tmpnor, NULL, NULL, NULL);
+ psys_interpolate_face(
+ mverts, face, tface, nullptr, mapfw, vec, tmpnor, nullptr, nullptr, nullptr);
/* Convert Z-up to Y-up. */
- norm_values.push_back(Imath::V3f(tmpnor[0], tmpnor[2], -tmpnor[1]));
+ norm_values.emplace_back(tmpnor[0], tmpnor[2], -tmpnor[1]);
}
else {
if (!uv_values.empty()) {
@@ -302,7 +304,7 @@ void ABCHairWriter::write_hair_child_sample(const HierarchyContext &context,
mul_m4_v3(inv_mat, vert);
/* Convert Z-up to Y-up. */
- verts.push_back(Imath::V3f(vert[0], vert[2], -vert[1]));
+ verts.emplace_back(vert[0], vert[2], -vert[1]);
path++;
}
diff --git a/source/blender/io/alembic/exporter/abc_writer_nurbs.cc b/source/blender/io/alembic/exporter/abc_writer_nurbs.cc
index 7595a0eba63..ce451eb1428 100644
--- a/source/blender/io/alembic/exporter/abc_writer_nurbs.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_nurbs.cc
@@ -93,7 +93,7 @@ bool ABCNurbsWriter::check_is_animated(const HierarchyContext &context) const
{
/* Check if object has shape keys. */
Curve *cu = static_cast<Curve *>(context.object->data);
- return (cu->key != NULL);
+ return (cu->key != nullptr);
}
bool ABCNurbsWriter::is_supported(const HierarchyContext *context) const
@@ -126,7 +126,7 @@ void ABCNurbsWriter::do_write(HierarchyContext &context)
Curve *curve = static_cast<Curve *>(context.object->data);
ListBase *nulb;
- if (context.object->runtime.curve_cache->deformed_nurbs.first != NULL) {
+ if (context.object->runtime.curve_cache->deformed_nurbs.first != nullptr) {
nulb = &context.object->runtime.curve_cache->deformed_nurbs;
}
else {
diff --git a/source/blender/io/alembic/exporter/abc_writer_points.cc b/source/blender/io/alembic/exporter/abc_writer_points.cc
index 557f580e8aa..70608fdbe92 100644
--- a/source/blender/io/alembic/exporter/abc_writer_points.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_points.cc
@@ -123,15 +123,15 @@ void ABCPointsWriter::do_write(HierarchyContext &context)
sub_v3_v3v3(vel, state.co, psys->particles[p].prev_state.co);
/* Convert Z-up to Y-up. */
- points.push_back(Imath::V3f(pos[0], pos[2], -pos[1]));
- velocities.push_back(Imath::V3f(vel[0], vel[2], -vel[1]));
+ points.emplace_back(pos[0], pos[2], -pos[1]);
+ velocities.emplace_back(vel[0], vel[2], -vel[1]);
widths.push_back(psys->particles[p].size);
ids.push_back(index++);
}
if (psys->lattice_deform_data) {
BKE_lattice_deform_data_destroy(psys->lattice_deform_data);
- psys->lattice_deform_data = NULL;
+ psys->lattice_deform_data = nullptr;
}
Alembic::Abc::P3fArraySample psample(points);
diff --git a/source/blender/io/alembic/exporter/abc_writer_transform.cc b/source/blender/io/alembic/exporter/abc_writer_transform.cc
index 7b1fa87de64..7fe9fd933c5 100644
--- a/source/blender/io/alembic/exporter/abc_writer_transform.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_transform.cc
@@ -112,7 +112,7 @@ OObject ABCTransformWriter::get_alembic_object() const
bool ABCTransformWriter::check_is_animated(const HierarchyContext &context) const
{
- if (context.duplicator != NULL) {
+ if (context.duplicator != nullptr) {
/* This object is being duplicated, so could be emitted by a particle system and thus
* influenced by forces. TODO(Sybren): Make this more strict. Probably better to get from the
* depsgraph whether this object instance has a time source. */
diff --git a/source/blender/io/alembic/intern/abc_reader_curves.cc b/source/blender/io/alembic/intern/abc_reader_curves.cc
index e29b6eda6fc..8d6605d6973 100644
--- a/source/blender/io/alembic/intern/abc_reader_curves.cc
+++ b/source/blender/io/alembic/intern/abc_reader_curves.cc
@@ -101,7 +101,7 @@ void AbcCurveReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele
ICompoundProperty user_props = m_curves_schema.getUserProperties();
if (user_props) {
const PropertyHeader *header = user_props.getPropertyHeader(ABC_CURVE_RESOLUTION_U_PROPNAME);
- if (header != NULL && header->isScalar() && IInt16Property::matches(*header)) {
+ if (header != nullptr && header->isScalar() && IInt16Property::matches(*header)) {
IInt16Property resolu(user_props, header->getName());
cu->resolu = resolu.getValue(sample_sel);
}
@@ -218,10 +218,10 @@ void AbcCurveReader::read_curve_sample(Curve *cu,
nu->pntsu -= overlap;
}
- const bool do_weights = (weights != NULL) && (weights->size() > 1);
+ const bool do_weights = (weights != nullptr) && (weights->size() > 1);
float weight = 1.0f;
- const bool do_radius = (radiuses != NULL) && (radiuses->size() > 1);
+ const bool do_radius = (radiuses != nullptr) && (radiuses->size() > 1);
float radius = (radiuses && radiuses->size() == 1) ? (*radiuses)[0] : 1.0f;
nu->type = CU_NURBS;
diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc
index 28e42b1f70f..14c3d756d56 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.cc
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc
@@ -33,6 +33,7 @@
#include "DNA_object_types.h"
#include "BLI_compiler_compat.h"
+#include "BLI_listbase.h"
#include "BLI_math_geom.h"
#include "BKE_main.h"
@@ -70,55 +71,44 @@ namespace blender::io::alembic {
/* Some helpers for mesh generation */
namespace utils {
-static void build_mat_map(const Main *bmain, std::map<std::string, Material *> &mat_map)
+static std::map<std::string, Material *> build_material_map(const Main *bmain)
{
- Material *material = static_cast<Material *>(bmain->materials.first);
-
- for (; material; material = static_cast<Material *>(material->id.next)) {
+ std::map<std::string, Material *> mat_map;
+ LISTBASE_FOREACH (Material *, material, &bmain->materials) {
mat_map[material->id.name + 2] = material;
}
+ return mat_map;
}
static void assign_materials(Main *bmain,
Object *ob,
const std::map<std::string, int> &mat_index_map)
{
- bool can_assign = true;
- std::map<std::string, int>::const_iterator it = mat_index_map.begin();
-
- int matcount = 0;
- for (; it != mat_index_map.end(); ++it, matcount++) {
+ std::map<std::string, int>::const_iterator it;
+ for (it = mat_index_map.begin(); it != mat_index_map.end(); ++it) {
if (!BKE_object_material_slot_add(bmain, ob)) {
- can_assign = false;
- break;
+ return;
}
}
- /* TODO(kevin): use global map? */
- std::map<std::string, Material *> mat_map;
- build_mat_map(bmain, mat_map);
-
+ std::map<std::string, Material *> matname_to_material = build_material_map(bmain);
std::map<std::string, Material *>::iterator mat_iter;
- if (can_assign) {
- it = mat_index_map.begin();
-
- for (; it != mat_index_map.end(); ++it) {
- std::string mat_name = it->first;
- mat_iter = mat_map.find(mat_name);
+ for (it = mat_index_map.begin(); it != mat_index_map.end(); ++it) {
+ const std::string mat_name = it->first;
+ const int mat_index = it->second;
- Material *assigned_mat;
-
- if (mat_iter == mat_map.end()) {
- assigned_mat = BKE_material_add(bmain, mat_name.c_str());
- mat_map[mat_name] = assigned_mat;
- }
- else {
- assigned_mat = mat_iter->second;
- }
-
- BKE_object_material_assign(bmain, ob, assigned_mat, it->second, BKE_MAT_ASSIGN_OBDATA);
+ Material *assigned_mat;
+ mat_iter = matname_to_material.find(mat_name);
+ if (mat_iter == matname_to_material.end()) {
+ assigned_mat = BKE_material_add(bmain, mat_name.c_str());
+ matname_to_material[mat_name] = assigned_mat;
+ }
+ else {
+ assigned_mat = mat_iter->second;
}
+
+ BKE_object_material_assign(bmain, ob, assigned_mat, mat_index, BKE_MAT_ASSIGN_OBDATA);
}
}
@@ -159,7 +149,8 @@ static void read_mverts(CDStreamConfig &config, const AbcMeshData &mesh_data)
const P3fArraySamplePtr &positions = mesh_data.positions;
if (config.use_vertex_interpolation && config.weight != 0.0f &&
- mesh_data.ceil_positions != NULL && mesh_data.ceil_positions->size() == positions->size()) {
+ mesh_data.ceil_positions != nullptr &&
+ mesh_data.ceil_positions->size() == positions->size()) {
read_mverts_interp(mverts, positions, mesh_data.ceil_positions, config.weight);
return;
}
@@ -393,19 +384,19 @@ static void *add_customdata_cb(Mesh *mesh, const char *name, int data_type)
/* unsupported custom data type -- don't do anything. */
if (!ELEM(cd_data_type, CD_MLOOPUV, CD_MLOOPCOL)) {
- return NULL;
+ return nullptr;
}
loopdata = &mesh->ldata;
cd_ptr = CustomData_get_layer_named(loopdata, cd_data_type, name);
- if (cd_ptr != NULL) {
+ if (cd_ptr != nullptr) {
/* layer already exists, so just return it. */
return cd_ptr;
}
/* Create a new layer. */
numloops = mesh->totloop;
- cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT, NULL, numloops, name);
+ cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT, nullptr, numloops, name);
return cd_ptr;
}
@@ -562,7 +553,7 @@ void AbcMeshReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str());
m_object->data = mesh;
- Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
+ Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, nullptr);
if (read_mesh != mesh) {
/* XXX fixme after 2.80; mesh->flag isn't copied by BKE_mesh_nomain_to_mesh() */
/* read_mesh can be freed by BKE_mesh_nomain_to_mesh(), so get the flag before that happens. */
@@ -667,7 +658,7 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
return existing_mesh;
}
- Mesh *new_mesh = NULL;
+ Mesh *new_mesh = nullptr;
/* Only read point data when streaming meshes, unless we need to create new ones. */
ImportSettings settings;
@@ -737,7 +728,7 @@ void AbcMeshReader::assign_facesets_to_mpoly(const ISampleSelector &sample_sel,
const std::string &grp_name = face_sets[i];
if (r_mat_map.find(grp_name) == r_mat_map.end()) {
- r_mat_map[grp_name] = 1 + current_mat++;
+ r_mat_map[grp_name] = ++current_mat;
}
const int assigned_mat = r_mat_map[grp_name];
@@ -787,7 +778,7 @@ BLI_INLINE MEdge *find_edge(MEdge *edges, int totedge, int v1, int v2)
}
}
- return NULL;
+ return nullptr;
}
static void read_subd_sample(const std::string &iobject_full_name,
@@ -877,7 +868,7 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str());
m_object->data = mesh;
- Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
+ Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, nullptr);
if (read_mesh != mesh) {
BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, &CD_MASK_MESH, true);
}
@@ -913,7 +904,7 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
}
MEdge *edge = find_edge(edges, totedge, v1, v2);
- if (edge == NULL) {
+ if (edge == nullptr) {
edge = find_edge(edges, totedge, v2, v1);
}
@@ -959,7 +950,7 @@ Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh,
const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices();
const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts();
- Mesh *new_mesh = NULL;
+ Mesh *new_mesh = nullptr;
ImportSettings settings;
settings.read_flag |= read_flag;
diff --git a/source/blender/io/alembic/intern/abc_reader_nurbs.cc b/source/blender/io/alembic/intern/abc_reader_nurbs.cc
index 27d4ec44a27..2a5f4ecb787 100644
--- a/source/blender/io/alembic/intern/abc_reader_nurbs.cc
+++ b/source/blender/io/alembic/intern/abc_reader_nurbs.cc
@@ -197,7 +197,7 @@ void AbcNurbsReader::getNurbsPatches(const IObject &obj)
if (num_children == 0) {
INuPatch abc_nurb(obj, kWrapExisting);
INuPatchSchema schem = abc_nurb.getSchema();
- m_schemas.push_back(std::pair<INuPatchSchema, IObject>(schem, obj));
+ m_schemas.emplace_back(schem, obj);
return;
}
@@ -218,7 +218,7 @@ void AbcNurbsReader::getNurbsPatches(const IObject &obj)
if (INuPatch::matches(md) && ok) {
INuPatch abc_nurb(child, kWrapExisting);
INuPatchSchema schem = abc_nurb.getSchema();
- m_schemas.push_back(std::pair<INuPatchSchema, IObject>(schem, child));
+ m_schemas.emplace_back(schem, child);
}
getNurbsPatches(child);
diff --git a/source/blender/io/alembic/intern/abc_reader_object.cc b/source/blender/io/alembic/intern/abc_reader_object.cc
index 707241ca17f..5ca7022bb36 100644
--- a/source/blender/io/alembic/intern/abc_reader_object.cc
+++ b/source/blender/io/alembic/intern/abc_reader_object.cc
@@ -44,13 +44,13 @@ using Alembic::AbcGeom::IXformSchema;
namespace blender::io::alembic {
AbcObjectReader::AbcObjectReader(const IObject &object, ImportSettings &settings)
- : m_object(NULL),
+ : m_object(nullptr),
m_iobject(object),
m_settings(&settings),
m_min_time(std::numeric_limits<chrono_t>::max()),
m_max_time(std::numeric_limits<chrono_t>::min()),
m_refcount(0),
- parent_reader(NULL)
+ parent_reader(nullptr)
{
m_name = object.getFullName();
std::vector<std::string> parts;
@@ -203,7 +203,7 @@ void AbcObjectReader::setupObjectTransform(const float time)
if (!is_constant) {
bConstraint *con = BKE_constraint_add_for_object(
- m_object, NULL, CONSTRAINT_TYPE_TRANSFORM_CACHE);
+ m_object, nullptr, CONSTRAINT_TYPE_TRANSFORM_CACHE);
bTransformCacheConstraint *data = static_cast<bTransformCacheConstraint *>(con->data);
BLI_strncpy(data->object_path, m_iobject.getFullName().c_str(), FILE_MAX);
diff --git a/source/blender/io/alembic/intern/abc_reader_points.cc b/source/blender/io/alembic/intern/abc_reader_points.cc
index 88b5088805f..f7dcba7a0de 100644
--- a/source/blender/io/alembic/intern/abc_reader_points.cc
+++ b/source/blender/io/alembic/intern/abc_reader_points.cc
@@ -82,7 +82,7 @@ bool AbcPointsReader::accepts_object_type(
void AbcPointsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
{
Mesh *mesh = BKE_mesh_add(bmain, m_data_name.c_str());
- Mesh *read_mesh = this->read_mesh(mesh, sample_sel, 0, NULL);
+ Mesh *read_mesh = this->read_mesh(mesh, sample_sel, 0, nullptr);
if (read_mesh != mesh) {
BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, &CD_MASK_MESH, true);
@@ -145,7 +145,7 @@ struct Mesh *AbcPointsReader::read_mesh(struct Mesh *existing_mesh,
const P3fArraySamplePtr &positions = sample.getPositions();
- Mesh *new_mesh = NULL;
+ Mesh *new_mesh = nullptr;
if (existing_mesh->totvert != positions->size()) {
new_mesh = BKE_mesh_new_nomain(positions->size(), 0, 0, 0, 0);
diff --git a/source/blender/io/alembic/intern/abc_reader_transform.cc b/source/blender/io/alembic/intern/abc_reader_transform.cc
index 3aab2f2d339..625cd255dba 100644
--- a/source/blender/io/alembic/intern/abc_reader_transform.cc
+++ b/source/blender/io/alembic/intern/abc_reader_transform.cc
@@ -72,7 +72,7 @@ bool AbcEmptyReader::accepts_object_type(
void AbcEmptyReader::readObjectData(Main *bmain, const ISampleSelector &UNUSED(sample_sel))
{
m_object = BKE_object_add_only_object(bmain, OB_EMPTY, m_object_name.c_str());
- m_object->data = NULL;
+ m_object->data = nullptr;
}
} // namespace blender::io::alembic
diff --git a/source/blender/io/alembic/intern/abc_util.cc b/source/blender/io/alembic/intern/abc_util.cc
index edb20da89a5..aa7beb37dc5 100644
--- a/source/blender/io/alembic/intern/abc_util.cc
+++ b/source/blender/io/alembic/intern/abc_util.cc
@@ -132,7 +132,7 @@ bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string
return false;
}
- return prop.getPropertyHeader(name) != NULL;
+ return prop.getPropertyHeader(name) != nullptr;
}
typedef std::pair<Alembic::AbcCoreAbstract::index_t, float> index_time_pair_t;
@@ -173,7 +173,7 @@ float get_weight_and_index(float time,
AbcObjectReader *create_reader(const Alembic::AbcGeom::IObject &object, ImportSettings &settings)
{
- AbcObjectReader *reader = NULL;
+ AbcObjectReader *reader = nullptr;
const Alembic::AbcGeom::MetaData &md = object.getMetaData();
diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc
index eba7f64db02..c9eefbf9039 100644
--- a/source/blender/io/alembic/intern/alembic_capi.cc
+++ b/source/blender/io/alembic/intern/alembic_capi.cc
@@ -167,7 +167,7 @@ AbcArchiveHandle *ABC_create_handle(struct Main *bmain,
if (!archive->valid()) {
delete archive;
- return NULL;
+ return nullptr;
}
if (object_paths) {
@@ -239,7 +239,7 @@ static std::pair<bool, AbcObjectReader *> visit_object(
if (!object.valid()) {
std::cerr << " - " << full_name << ": object is invalid, skipping it and all its children.\n";
- return std::make_pair(false, static_cast<AbcObjectReader *>(NULL));
+ return std::make_pair(false, static_cast<AbcObjectReader *>(nullptr));
}
/* The interpretation of data by the children determine the role of this
@@ -261,7 +261,7 @@ static std::pair<bool, AbcObjectReader *> visit_object(
bool child_claims_this_object = child_result.first;
AbcObjectReader *child_reader = child_result.second;
- if (child_reader == NULL) {
+ if (child_reader == nullptr) {
BLI_assert(!child_claims_this_object);
}
else {
@@ -277,7 +277,7 @@ static std::pair<bool, AbcObjectReader *> visit_object(
}
BLI_assert(children_claiming_this_object == claiming_child_readers.size());
- AbcObjectReader *reader = NULL;
+ AbcObjectReader *reader = nullptr;
const MetaData &md = object.getMetaData();
bool parent_is_part_of_this_object = false;
@@ -544,8 +544,8 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa
const AbcObjectReader *parent_reader = reader->parent_reader;
Object *ob = reader->object();
- if (parent_reader == NULL || !reader->inherits_xform()) {
- ob->parent = NULL;
+ if (parent_reader == nullptr || !reader->inherits_xform()) {
+ ob->parent = nullptr;
}
else {
ob->parent = parent_reader->object();
@@ -583,7 +583,7 @@ static void import_endjob(void *user_data)
/* It's possible that cancellation occurred between the creation of
* the reader and the creation of the Blender object. */
- if (ob == NULL) {
+ if (ob == nullptr) {
continue;
}
@@ -685,7 +685,7 @@ bool ABC_import(bContext *C,
job->settings.validate_meshes = validate_meshes;
job->error_code = ABC_NO_ERROR;
job->was_cancelled = false;
- job->archive = NULL;
+ job->archive = nullptr;
job->is_background_job = as_background_job;
G.is_break = false;
@@ -702,14 +702,14 @@ bool ABC_import(bContext *C,
/* setup job */
WM_jobs_customdata_set(wm_job, job, import_freejob);
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_FRAME, NC_SCENE | ND_FRAME);
- WM_jobs_callbacks(wm_job, import_startjob, NULL, NULL, import_endjob);
+ WM_jobs_callbacks(wm_job, import_startjob, nullptr, nullptr, import_endjob);
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
else {
/* Fake a job context, so that we don't need NULL pointer checks while importing. */
short stop = 0, do_update = 0;
- float progress = 0.f;
+ float progress = 0.0f;
import_startjob(job, &stop, &do_update, &progress);
import_endjob(job);
@@ -762,13 +762,13 @@ static AbcObjectReader *get_abc_reader(CacheReader *reader, Object *ob, const ch
if (!iobject.valid()) {
*err_str = "Invalid object: verify object path";
- return NULL;
+ return nullptr;
}
const ObjectHeader &header = iobject.getHeader();
if (!abc_reader->accepts_object_type(header, ob, err_str)) {
/* err_str is set by acceptsObjectType() */
- return NULL;
+ return nullptr;
}
return abc_reader;
@@ -789,8 +789,8 @@ Mesh *ABC_read_mesh(CacheReader *reader,
int read_flag)
{
AbcObjectReader *abc_reader = get_abc_reader(reader, ob, err_str);
- if (abc_reader == NULL) {
- return NULL;
+ if (abc_reader == nullptr) {
+ return nullptr;
}
ISampleSelector sample_sel = sample_selector_for_time(time);
@@ -801,7 +801,7 @@ bool ABC_mesh_topology_changed(
CacheReader *reader, Object *ob, Mesh *existing_mesh, const float time, const char **err_str)
{
AbcObjectReader *abc_reader = get_abc_reader(reader, ob, err_str);
- if (abc_reader == NULL) {
+ if (abc_reader == nullptr) {
return false;
}
@@ -851,9 +851,9 @@ CacheReader *CacheReader_open_alembic_object(AbcArchiveHandle *handle,
ImportSettings settings;
AbcObjectReader *abc_reader = create_reader(iobject, settings);
- if (abc_reader == NULL) {
+ if (abc_reader == nullptr) {
/* This object is not supported */
- return NULL;
+ return nullptr;
}
abc_reader->object(object);
abc_reader->incref();
diff --git a/source/blender/io/alembic/tests/abc_matrix_test.cc b/source/blender/io/alembic/tests/abc_matrix_test.cc
index fc5b645987e..c6d7245a52c 100644
--- a/source/blender/io/alembic/tests/abc_matrix_test.cc
+++ b/source/blender/io/alembic/tests/abc_matrix_test.cc
@@ -14,7 +14,7 @@ TEST(abc_matrix, CreateRotationMatrixY_YfromZ)
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};
+ float euler[3] = {0.0f, M_PI_4, 0.0f};
/* Construct expected matrices */
float unit[3][3];
@@ -41,7 +41,7 @@ TEST(abc_matrix, CreateRotationMatrixZ_YfromZ)
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};
+ float euler[3] = {0.0f, 0.0f, M_PI_4};
/* Construct expected matrices */
float unit[3][3];
@@ -150,25 +150,25 @@ TEST(abc_matrix, CopyM44AxisSwap_YfromZ)
* above. This matrix was created by rotating a cube in Blender over
* (X=10, Y=20, Z=30 degrees in XYZ order) and translating over (1, 2, 3) */
float input[4][4] = {
- {0.81379765272f, 0.4698463380336f, -0.342020124197f, 0.f},
- {-0.44096961617f, 0.8825641274452f, 0.163175910711f, 0.f},
- {0.37852230668f, 0.0180283170193f, 0.925416588783f, 0.f},
- {1.f, 2.f, 3.f, 1.f},
+ {0.81379765272f, 0.4698463380336f, -0.342020124197f, 0.0f},
+ {-0.44096961617f, 0.8825641274452f, 0.163175910711f, 0.0f},
+ {0.37852230668f, 0.0180283170193f, 0.925416588783f, 0.0f},
+ {1.0f, 2.0f, 3.0f, 1.0f},
};
copy_m44_axis_swap(result, input, ABC_YUP_FROM_ZUP);
/* Check the resulting rotation & translation. */
- float trans[4] = {1.f, 3.f, -2.f, 1.f};
+ float trans[4] = {1.0f, 3.0f, -2.0f, 1.0f};
EXPECT_V4_NEAR(trans, result[3], 1e-5f);
/* This matrix was created by rotating a cube in Blender over
* (X=10, Y=30, Z=-20 degrees in XZY order) and translating over (1, 3, -2) */
float expect[4][4] = {
- {0.813797652721f, -0.342020124197f, -0.469846338033f, 0.f},
- {0.378522306680f, 0.925416588783f, -0.018028317019f, 0.f},
- {0.440969616174f, -0.163175910711f, 0.882564127445f, 0.f},
- {1.f, 3.f, -2.f, 1.f},
+ {0.813797652721f, -0.342020124197f, -0.469846338033f, 0.0f},
+ {0.378522306680f, 0.925416588783f, -0.018028317019f, 0.0f},
+ {0.440969616174f, -0.163175910711f, 0.882564127445f, 0.0f},
+ {1.0f, 3.0f, -2.0f, 1.0f},
};
EXPECT_M4_NEAR(expect, result, 1e-5f);
}
@@ -182,10 +182,10 @@ TEST(abc_matrix, CopyM44AxisSwapWithScale_YfromZ)
* (X=10, Y=20, Z=30 degrees in XYZ order), translating over (1, 2, 3),
* and scaling by (4, 5, 6). */
float input[4][4] = {
- {3.25519061088f, 1.8793853521347f, -1.368080496788f, 0.f},
- {-2.20484805107f, 4.4128208160400f, 0.815879583358f, 0.f},
- {2.27113389968f, 0.1081698983907f, 5.552499771118f, 0.f},
- {1.f, 2.f, 3.f, 1.f},
+ {3.25519061088f, 1.8793853521347f, -1.368080496788f, 0.0f},
+ {-2.20484805107f, 4.4128208160400f, 0.815879583358f, 0.0f},
+ {2.27113389968f, 0.1081698983907f, 5.552499771118f, 0.0f},
+ {1.0f, 2.0f, 3.0f, 1.0f},
};
copy_m44_axis_swap(result, input, ABC_YUP_FROM_ZUP);
@@ -194,10 +194,10 @@ TEST(abc_matrix, CopyM44AxisSwapWithScale_YfromZ)
* (X=10, Y=30, Z=-20 degrees in XZY order), translating over (1, 3, -2)
* and scaling over (4, 6, 5). */
float expect[4][4] = {
- {3.255190610885f, -1.368080496788f, -1.879385352134f, 0.f},
- {2.271133899688f, 5.552499771118f, -0.108169898390f, 0.f},
- {2.204848051071f, -0.815879583358f, 4.412820816040f, 0.f},
- {1.f, 3.f, -2.f, 1.f},
+ {3.255190610885f, -1.368080496788f, -1.879385352134f, 0.0f},
+ {2.271133899688f, 5.552499771118f, -0.108169898390f, 0.0f},
+ {2.204848051071f, -0.815879583358f, 4.412820816040f, 0.0f},
+ {1.0f, 3.0f, -2.0f, 1.0f},
};
EXPECT_M4_NEAR(expect, result, 1e-5f);
}
@@ -209,10 +209,10 @@ TEST(abc_matrix, CopyM44AxisSwap_ZfromY)
/* This matrix was created by rotating a cube in Blender over
* (X=10, Y=30, Z=-20 degrees in XZY order) and translating over (1, 3, -2) */
float input[4][4] = {
- {0.813797652721f, -0.342020124197f, -0.469846338033f, 0.f},
- {0.378522306680f, 0.925416588783f, -0.018028317019f, 0.f},
- {0.440969616174f, -0.163175910711f, 0.882564127445f, 0.f},
- {1.f, 3.f, -2.f, 1.f},
+ {0.813797652721f, -0.342020124197f, -0.469846338033f, 0.0f},
+ {0.378522306680f, 0.925416588783f, -0.018028317019f, 0.0f},
+ {0.440969616174f, -0.163175910711f, 0.882564127445f, 0.0f},
+ {1.0f, 3.0f, -2.0f, 1.0f},
};
copy_m44_axis_swap(result, input, ABC_ZUP_FROM_YUP);
@@ -220,10 +220,10 @@ TEST(abc_matrix, CopyM44AxisSwap_ZfromY)
/* This matrix was created by rotating a cube in Blender over
* (X=10, Y=20, Z=30 degrees in XYZ order) and translating over (1, 2, 3) */
float expect[4][4] = {
- {0.813797652721f, 0.469846338033f, -0.342020124197f, 0.f},
- {-0.44096961617f, 0.882564127445f, 0.163175910711f, 0.f},
- {0.378522306680f, 0.018028317019f, 0.925416588783f, 0.f},
- {1.f, 2.f, 3.f, 1.f},
+ {0.813797652721f, 0.469846338033f, -0.342020124197f, 0.0f},
+ {-0.44096961617f, 0.882564127445f, 0.163175910711f, 0.0f},
+ {0.378522306680f, 0.018028317019f, 0.925416588783f, 0.0f},
+ {1.0f, 2.0f, 3.0f, 1.0f},
};
EXPECT_M4_NEAR(expect, result, 1e-5f);
@@ -237,10 +237,10 @@ TEST(abc_matrix, CopyM44AxisSwapWithScale_ZfromY)
* (X=10, Y=30, Z=-20 degrees in XZY order), translating over (1, 3, -2)
* and scaling over (4, 6, 5). */
float input[4][4] = {
- {3.2551906108f, -1.36808049678f, -1.879385352134f, 0.f},
- {2.2711338996f, 5.55249977111f, -0.108169898390f, 0.f},
- {2.2048480510f, -0.81587958335f, 4.412820816040f, 0.f},
- {1.f, 3.f, -2.f, 1.f},
+ {3.2551906108f, -1.36808049678f, -1.879385352134f, 0.0f},
+ {2.2711338996f, 5.55249977111f, -0.108169898390f, 0.0f},
+ {2.2048480510f, -0.81587958335f, 4.412820816040f, 0.0f},
+ {1.0f, 3.0f, -2.0f, 1.0f},
};
copy_m44_axis_swap(result, input, ABC_ZUP_FROM_YUP);
@@ -249,10 +249,10 @@ TEST(abc_matrix, CopyM44AxisSwapWithScale_ZfromY)
* (X=10, Y=20, Z=30 degrees in XYZ order), translating over (1, 2, 3),
* and scaling by (4, 5, 6). */
float expect[4][4] = {
- {3.25519061088f, 1.879385352134f, -1.36808049678f, 0.f},
- {-2.2048480510f, 4.412820816040f, 0.81587958335f, 0.f},
- {2.27113389968f, 0.108169898390f, 5.55249977111f, 0.f},
- {1.f, 2.f, 3.f, 1.f},
+ {3.25519061088f, 1.879385352134f, -1.36808049678f, 0.0f},
+ {-2.2048480510f, 4.412820816040f, 0.81587958335f, 0.0f},
+ {2.27113389968f, 0.108169898390f, 5.55249977111f, 0.0f},
+ {1.0f, 2.0f, 3.0f, 1.0f},
};
EXPECT_M4_NEAR(expect, result, 1e-5f);
diff --git a/source/blender/io/avi/intern/avi.c b/source/blender/io/avi/intern/avi.c
index 0ab51b7a084..88f2e1a259f 100644
--- a/source/blender/io/avi/intern/avi.c
+++ b/source/blender/io/avi/intern/avi.c
@@ -148,7 +148,7 @@ static bool fcc_is_data(int fcc)
if (!isdigit(fccs[0]) || !isdigit(fccs[1]) || (fccs[2] != 'd' && fccs[2] != 'w')) {
return 0;
}
- if (fccs[3] != 'b' && fccs[3] != 'c') {
+ if (!ELEM(fccs[3], 'b', 'c')) {
return 0;
}
diff --git a/source/blender/io/collada/AnimationExporter.cpp b/source/blender/io/collada/AnimationExporter.cpp
index 9ecb890b649..73952b06bc9 100644
--- a/source/blender/io/collada/AnimationExporter.cpp
+++ b/source/blender/io/collada/AnimationExporter.cpp
@@ -228,7 +228,7 @@ void AnimationExporter::export_matrix_animation(Object *ob, BCAnimationSampler &
if (keep_flat_curves || is_animated) {
bAction *action = bc_getSceneObjectAction(ob);
std::string name = encode_xml(id_name(ob));
- std::string action_name = (action == NULL) ? name + "-action" : id_name(action);
+ std::string action_name = (action == nullptr) ? name + "-action" : id_name(action);
std::string channel_type = "transform";
std::string axis;
std::string id = bc_get_action_id(action_name, name, channel_type, axis);
@@ -290,7 +290,7 @@ BCAnimationCurve *AnimationExporter::get_modified_export_curve(Object *ob,
BCAnimationCurveMap &curves)
{
std::string channel_type = curve.get_channel_type();
- BCAnimationCurve *mcurve = NULL;
+ BCAnimationCurve *mcurve = nullptr;
if (channel_type == "lens") {
/* Create an xfov curve */
@@ -302,7 +302,7 @@ BCAnimationCurve *AnimationExporter::get_modified_export_curve(Object *ob,
BCValueMap lens_values;
curve.get_value_map(lens_values);
- BCAnimationCurve *sensor_curve = NULL;
+ BCAnimationCurve *sensor_curve = nullptr;
BCCurveKey sensor_key(BC_ANIMATION_TYPE_CAMERA, "sensor_width", 0);
BCAnimationCurveMap::iterator cit = curves.find(sensor_key);
if (cit != curves.end()) {
diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp
index 645a821b463..2e7977d89bb 100644
--- a/source/blender/io/collada/AnimationImporter.cpp
+++ b/source/blender/io/collada/AnimationImporter.cpp
@@ -228,7 +228,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
}
if (ob->type == OB_ARMATURE) {
- bActionGroup *grp = NULL;
+ bActionGroup *grp = nullptr;
const char *bone_name = bc_get_joint_name(animated->node);
if (bone_name) {
@@ -236,7 +236,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
grp = BKE_action_group_find_name(act, bone_name);
/* no matching groups, so add one */
- if (grp == NULL) {
+ if (grp == nullptr) {
/* Add a new group, and make it active */
grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup");
@@ -355,7 +355,7 @@ void AnimationImporter::read_node_transform(COLLADAFW::Node *node, Object *ob)
TransformReader::get_node_mat(mat, node, &uid_animated_map, ob);
if (ob) {
copy_m4_m4(ob->obmat, mat);
- BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
+ BKE_object_apply_mat4(ob, ob->obmat, false, false);
}
}
@@ -662,7 +662,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi
BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
- if (animlist == NULL) {
+ if (animlist == nullptr) {
fprintf(stderr,
"Collada: No animlist found for ID: %s of type %s\n",
listid.toAscii().c_str(),
@@ -818,7 +818,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
COLLADAFW::Transformation *tm)
{
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
- const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
+ const char *bone_name = is_joint ? bc_get_joint_name(node) : nullptr;
char joint_path[200];
if (is_joint) {
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
@@ -847,7 +847,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
/* new curves to assign matrix transform animation */
FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale */
unsigned int totcu = 10;
- const char *tm_str = NULL;
+ const char *tm_str = nullptr;
char rna_path[200];
for (int i = 0; i < totcu; i++) {
@@ -910,7 +910,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
float temp[4][4], par[4][4];
/* calc M */
- calc_joint_parent_mat_rest(par, NULL, root, node);
+ calc_joint_parent_mat_rest(par, nullptr, root, node);
mul_m4_m4m4(temp, par, matfra);
#if 0
@@ -1218,7 +1218,7 @@ void AnimationImporter::translate_Animations(
for (unsigned int j = 0; j < matBinds.getCount(); j++) {
const COLLADAFW::UniqueId &matuid = matBinds[j].getReferencedMaterial();
const COLLADAFW::Effect *ef = (COLLADAFW::Effect *)(FW_object_map[matuid]);
- if (ef != NULL) { /* can be NULL T28909. */
+ if (ef != nullptr) { /* can be NULL T28909. */
Material *ma = uid_material_map[matuid];
if (!ma) {
fprintf(stderr,
@@ -1303,7 +1303,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
/* new curves to assign matrix transform animation */
FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale. */
unsigned int totcu = 10;
- const char *tm_str = NULL;
+ const char *tm_str = nullptr;
char rna_path[200];
for (int i = 0; i < totcu; i++) {
@@ -1358,7 +1358,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
Matrix temp, par;
/* calc M */
- calc_joint_parent_mat_rest(par, NULL, root, node);
+ calc_joint_parent_mat_rest(par, nullptr, root, node);
mul_m4_m4m4(temp, par, matfra);
/* evaluate_joint_world_transform_at_frame(temp, NULL, node, fra); */
@@ -1442,7 +1442,7 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
for (unsigned int i = 0; i < nodeCameras.getCount(); i++) {
const COLLADAFW::Camera *camera = (COLLADAFW::Camera *)
FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
- if (camera == NULL) {
+ if (camera == nullptr) {
/* Can happen if the node refers to an unknown camera. */
continue;
}
@@ -1476,7 +1476,7 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
for (unsigned int j = 0; j < matBinds.getCount(); j++) {
const COLLADAFW::UniqueId &matuid = matBinds[j].getReferencedMaterial();
const COLLADAFW::Effect *ef = (COLLADAFW::Effect *)(FW_object_map[matuid]);
- if (ef != NULL) { /* can be NULL T28909. */
+ if (ef != nullptr) { /* can be NULL T28909. */
const COLLADAFW::CommonEffectPointerArray &commonEffects = ef->getCommonEffects();
if (!commonEffects.empty()) {
COLLADAFW::EffectCommon *efc = commonEffects[0];
@@ -1597,10 +1597,10 @@ Object *AnimationImporter::translate_animation_OLD(
root_map[node->getUniqueId()];
Object *ob = is_joint ? armature_importer->get_armature_for_joint(node) :
object_map[node->getUniqueId()];
- const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
+ const char *bone_name = is_joint ? bc_get_joint_name(node) : nullptr;
if (!ob) {
fprintf(stderr, "cannot find Object for Node with id=\"%s\"\n", node->getOriginalId().c_str());
- return NULL;
+ return nullptr;
}
/* frames at which to sample */
@@ -1620,7 +1620,7 @@ Object *AnimationImporter::translate_animation_OLD(
Bone *bone = BKE_armature_find_bone_name((bArmature *)ob->data, bone_name);
if (!bone) {
fprintf(stderr, "cannot find bone \"%s\"\n", bone_name);
- return NULL;
+ return nullptr;
}
unit_m4(rest);
@@ -1628,7 +1628,7 @@ Object *AnimationImporter::translate_animation_OLD(
invert_m4_m4(irest, rest);
}
- Object *job = NULL;
+ Object *job = nullptr;
#ifdef ARMATURE_TEST
FCurve *job_curves[10];
@@ -1641,7 +1641,7 @@ Object *AnimationImporter::translate_animation_OLD(
std::sort(frames.begin(), frames.end());
- const char *tm_str = NULL;
+ const char *tm_str = nullptr;
switch (tm_type) {
case COLLADAFW::Transformation::ROTATE:
tm_str = "rotation_quaternion";
@@ -1726,7 +1726,7 @@ Object *AnimationImporter::translate_animation_OLD(
float temp[4][4], par[4][4];
/* calc M */
- calc_joint_parent_mat_rest(par, NULL, root, node);
+ calc_joint_parent_mat_rest(par, nullptr, root, node);
mul_m4_m4m4(temp, par, matfra);
/* evaluate_joint_world_transform_at_frame(temp, NULL, node, fra); */
@@ -2071,8 +2071,8 @@ void AnimationImporter::get_joint_rest_mat(float mat[4][4],
if (!armature_importer->get_joint_bind_mat(mat, node)) {
float par[4][4], m[4][4];
- calc_joint_parent_mat_rest(par, NULL, root, node);
- get_node_mat(m, node, NULL, NULL);
+ calc_joint_parent_mat_rest(par, nullptr, root, node);
+ get_node_mat(m, node, nullptr, nullptr);
mul_m4_m4m4(mat, par, m);
}
}
@@ -2094,11 +2094,11 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4],
if (!armature_importer->get_joint_bind_mat(m, node)) {
if (par) {
float temp[4][4];
- get_node_mat(temp, node, NULL, NULL);
+ get_node_mat(temp, node, nullptr, nullptr);
mul_m4_m4m4(m, par, temp);
}
else {
- get_node_mat(m, node, NULL, NULL);
+ get_node_mat(m, node, nullptr, nullptr);
}
}
@@ -2202,7 +2202,7 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv
bActionGroup *grp = BKE_action_group_find_name(act, bone_name);
/* no matching groups, so add one */
- if (grp == NULL) {
+ if (grp == nullptr) {
/* Add a new group, and make it active */
grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup");
diff --git a/source/blender/io/collada/ArmatureExporter.cpp b/source/blender/io/collada/ArmatureExporter.cpp
index 6aeffd22bbd..9bf1a4ae830 100644
--- a/source/blender/io/collada/ArmatureExporter.cpp
+++ b/source/blender/io/collada/ArmatureExporter.cpp
@@ -50,7 +50,7 @@ void ArmatureExporter::add_armature_bones(Object *ob_arm,
/* write bone nodes */
bArmature *armature = (bArmature *)ob_arm->data;
- bool is_edited = armature->edbo != NULL;
+ bool is_edited = armature->edbo != nullptr;
if (!is_edited) {
ED_armature_to_edit(armature);
@@ -315,7 +315,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW:
BCMatrix::sanitize(mat, LIMITTED_PRECISION);
}
- TransformWriter::add_joint_transform(node, mat, NULL, this->export_settings, has_restmat);
+ TransformWriter::add_joint_transform(node, mat, nullptr, this->export_settings, has_restmat);
}
std::string ArmatureExporter::get_controller_id(Object *ob_arm, Object *ob)
diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp
index af6558da3b4..9533ca322f9 100644
--- a/source/blender/io/collada/ArmatureImporter.cpp
+++ b/source/blender/io/collada/ArmatureImporter.cpp
@@ -56,7 +56,7 @@ ArmatureImporter::ArmatureImporter(UnitConverter *conv,
view_layer(view_layer),
unit_converter(conv),
import_settings(import_settings),
- empty(NULL),
+ empty(nullptr),
mesh_importer(mesh)
{
}
@@ -139,7 +139,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
/* create a bone even if there's no joint data for it (i.e. it has no influence) */
if (!bone_is_skinned) {
- get_node_mat(mat, node, NULL, NULL, parent_mat);
+ get_node_mat(mat, node, nullptr, nullptr, parent_mat);
}
if (parent) {
@@ -174,14 +174,14 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
else {
float angle;
mat4_to_loc_rot_size(loc, rot, size, mat);
- mat3_to_vec_roll(rot, NULL, &angle);
+ mat3_to_vec_roll(rot, nullptr, &angle);
bone->roll = angle;
}
copy_v3_v3(bone->head, mat[3]);
if (bone_is_skinned && this->import_settings->keep_bind_info) {
float rest_mat[4][4];
- get_node_mat(rest_mat, node, NULL, NULL, NULL);
+ get_node_mat(rest_mat, node, nullptr, nullptr, nullptr);
bc_set_IDPropertyMatrix(bone, "bind_mat", joint_bind_mat);
bc_set_IDPropertyMatrix(bone, "rest_mat", rest_mat);
}
@@ -230,7 +230,7 @@ void ArmatureImporter::fix_leaf_bone_hierarchy(bArmature *armature,
Bone *bone,
bool fix_orientation)
{
- if (bone == NULL) {
+ if (bone == nullptr) {
return;
}
@@ -251,14 +251,14 @@ void ArmatureImporter::fix_leaf_bone(bArmature *armature,
BoneExtended *be,
bool fix_orientation)
{
- if (be == NULL || !be->has_tail()) {
+ if (be == nullptr || !be->has_tail()) {
/* Collada only knows Joints, Here we guess a reasonable leaf bone length */
float leaf_length = (leaf_bone_length == FLT_MAX) ? 1.0 : leaf_bone_length;
float vec[3];
- if (fix_orientation && ebone->parent != NULL) {
+ if (fix_orientation && ebone->parent != nullptr) {
EditBone *parent = ebone->parent;
sub_v3_v3v3(vec, ebone->head, parent->head);
if (len_squared_v3(vec) < MINIMUM_BONE_LENGTH) {
@@ -279,7 +279,7 @@ void ArmatureImporter::fix_leaf_bone(bArmature *armature,
void ArmatureImporter::fix_parent_connect(bArmature *armature, Bone *bone)
{
/* armature has no bones */
- if (bone == NULL) {
+ if (bone == nullptr) {
return;
}
@@ -297,18 +297,18 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature,
int max_chain_length)
{
BoneExtensionMap &extended_bones = bone_extension_manager.getExtensionMap(armature);
- BoneExtended *dominant_child = NULL;
+ BoneExtended *dominant_child = nullptr;
int maxlen = 0;
- if (parentbone == NULL) {
+ if (parentbone == nullptr) {
return;
}
Bone *child = (Bone *)parentbone->childbase.first;
- if (child && (import_settings->find_chains || child->next == NULL)) {
+ if (child && (import_settings->find_chains || child->next == nullptr)) {
for (; child; child = child->next) {
BoneExtended *be = extended_bones[child->name];
- if (be != NULL) {
+ if (be != nullptr) {
int chain_len = be->get_chain_length();
if (chain_len <= max_chain_length) {
if (chain_len > maxlen) {
@@ -316,7 +316,7 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature,
maxlen = chain_len;
}
else if (chain_len == maxlen) {
- dominant_child = NULL;
+ dominant_child = nullptr;
}
}
}
@@ -324,7 +324,7 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature,
}
BoneExtended *pbe = extended_bones[parentbone->name];
- if (dominant_child != NULL) {
+ if (dominant_child != nullptr) {
/* Found a valid chain. Now connect current bone with that chain.*/
EditBone *pebone = bc_get_edit_bone(armature, parentbone->name);
EditBone *cebone = bc_get_edit_bone(armature, dominant_child->get_name());
@@ -429,7 +429,7 @@ Object *ArmatureImporter::get_empty_for_leaves()
return empty;
}
- empty = bc_add_object(m_bmain, scene, view_layer, OB_EMPTY, NULL);
+ empty = bc_add_object(m_bmain, scene, view_layer, OB_EMPTY, nullptr);
empty->empty_drawtype = OB_EMPTY_SPHERE;
return empty;
@@ -480,7 +480,7 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *>
/* if there is an armature created for root_joint next root_joint */
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
COLLADAFW::Node *node = *ri;
- if (get_armature_for_joint(node) != NULL) {
+ if (get_armature_for_joint(node) != nullptr) {
continue;
}
@@ -506,7 +506,8 @@ 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() */
- create_bone(NULL, node, NULL, node->getChildNodes().getCount(), NULL, armature, layer_labels);
+ create_bone(
+ nullptr, node, nullptr, node->getChildNodes().getCount(), nullptr, armature, layer_labels);
if (this->import_settings->find_chains) {
connect_bone_chains(armature, (Bone *)armature->bonebase.first, UNLIMITED_CHAIN_MAX);
}
@@ -543,7 +544,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
* - exit edit mode
* - set a sphere shape to leaf bones */
- Object *ob_arm = NULL;
+ Object *ob_arm = nullptr;
/*
* find if there's another skin sharing at least one bone with this skin
@@ -579,14 +580,14 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
*/
SkinInfo *a = &skin;
- Object *shared = NULL;
+ Object *shared = nullptr;
std::vector<COLLADAFW::Node *> skin_root_joints;
std::vector<std::string> layer_labels;
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;
for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) {
SkinInfo *b = &it->second;
- if (b == a || b->BKE_armature_from_object() == NULL) {
+ if (b == a || b->BKE_armature_from_object() == nullptr) {
continue;
}
@@ -603,7 +604,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
}
}
- if (shared != NULL) {
+ if (shared != nullptr) {
break;
}
}
@@ -651,7 +652,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
if (skin.uses_joint_or_descendant(node)) {
create_bone(
- &skin, node, NULL, node->getChildNodes().getCount(), NULL, armature, layer_labels);
+ &skin, node, nullptr, node->getChildNodes().getCount(), nullptr, armature, layer_labels);
if (joint_parent_map.find(node->getUniqueId()) != joint_parent_map.end() &&
!skin.get_parent()) {
@@ -707,7 +708,7 @@ void ArmatureImporter::set_pose(Object *ob_arm,
float obmat[4][4];
/* object-space */
- get_node_mat(obmat, root_node, NULL, NULL);
+ get_node_mat(obmat, root_node, nullptr, nullptr);
bool is_decomposed = node_is_decomposed(root_node);
// if (*edbone)
@@ -804,7 +805,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
/* link armature with a mesh object */
const COLLADAFW::UniqueId &uid = skin.get_controller_uid();
const COLLADAFW::UniqueId *guid = get_geometry_uid(uid);
- if (guid != NULL) {
+ if (guid != nullptr) {
Object *ob = mesh_importer->get_object_by_geom_uid(*guid);
if (ob) {
skin.link_armature(C, ob, joint_by_uid, this);
@@ -1001,7 +1002,7 @@ void ArmatureImporter::make_shape_keys(bContext *C)
COLLADAFW::UniqueId *ArmatureImporter::get_geometry_uid(const COLLADAFW::UniqueId &controller_uid)
{
if (geom_uid_by_controller_uid.find(controller_uid) == geom_uid_by_controller_uid.end()) {
- return NULL;
+ return nullptr;
}
return &geom_uid_by_controller_uid[controller_uid];
@@ -1024,7 +1025,7 @@ Object *ArmatureImporter::get_armature_for_joint(COLLADAFW::Node *node)
return arm->second;
}
}
- return NULL;
+ return nullptr;
}
void ArmatureImporter::set_tags_map(TagsMap &tags_map)
@@ -1065,7 +1066,7 @@ BoneExtended &ArmatureImporter::add_bone_extended(EditBone *bone,
extended_bones[bone->name] = be;
TagsMap::iterator etit;
- ExtraTags *et = 0;
+ ExtraTags *et = nullptr;
etit = uid_tags_map.find(node->getUniqueId().toAscii());
bool has_connect = false;
diff --git a/source/blender/io/collada/BCAnimationCurve.cpp b/source/blender/io/collada/BCAnimationCurve.cpp
index 46439bb3556..33eaf3376cd 100644
--- a/source/blender/io/collada/BCAnimationCurve.cpp
+++ b/source/blender/io/collada/BCAnimationCurve.cpp
@@ -22,7 +22,7 @@
BCAnimationCurve::BCAnimationCurve()
{
this->curve_key.set_object_type(BC_ANIMATION_TYPE_OBJECT);
- this->fcurve = NULL;
+ this->fcurve = nullptr;
this->curve_is_local_copy = false;
}
@@ -53,7 +53,7 @@ BCAnimationCurve::BCAnimationCurve(BCCurveKey key, Object *ob, FCurve *fcu)
BCAnimationCurve::BCAnimationCurve(const BCCurveKey &key, Object *ob)
{
this->curve_key = key;
- this->fcurve = NULL;
+ this->fcurve = nullptr;
this->curve_is_local_copy = false;
init_pointer_rna(ob);
}
@@ -120,7 +120,7 @@ BCAnimationCurve::~BCAnimationCurve()
if (curve_is_local_copy && fcurve) {
// fprintf(stderr, "removed fcurve %s\n", fcurve->rna_path);
delete_fcurve(fcurve);
- this->fcurve = NULL;
+ this->fcurve = nullptr;
}
}
@@ -169,7 +169,7 @@ std::string BCAnimationCurve::get_animation_name(Object *ob) const
} break;
case BC_ANIMATION_TYPE_BONE: {
- if (fcurve == NULL || fcurve->rna_path == NULL) {
+ if (fcurve == nullptr || fcurve->rna_path == nullptr) {
name = "";
}
else {
@@ -218,7 +218,7 @@ std::string BCAnimationCurve::get_rna_path() const
int BCAnimationCurve::sample_count() const
{
- if (fcurve == NULL) {
+ if (fcurve == nullptr) {
return 0;
}
return fcurve->totvert;
@@ -226,7 +226,7 @@ int BCAnimationCurve::sample_count() const
int BCAnimationCurve::closest_index_above(const float sample_frame, const int start_at) const
{
- if (fcurve == NULL) {
+ if (fcurve == nullptr) {
return -1;
}
@@ -240,7 +240,7 @@ int BCAnimationCurve::closest_index_above(const float sample_frame, const int st
int BCAnimationCurve::closest_index_below(const float sample_frame) const
{
- if (fcurve == NULL) {
+ if (fcurve == nullptr) {
return -1;
}
@@ -304,14 +304,14 @@ FCurve *BCAnimationCurve::get_edit_fcurve()
void BCAnimationCurve::clean_handles()
{
- if (fcurve == NULL) {
+ if (fcurve == nullptr) {
fcurve = get_edit_fcurve();
}
/* Keep old bezt data for copy)*/
BezTriple *old_bezts = fcurve->bezt;
int totvert = fcurve->totvert;
- fcurve->bezt = NULL;
+ fcurve->bezt = nullptr;
fcurve->totvert = 0;
for (int i = 0; i < totvert; i++) {
@@ -492,7 +492,7 @@ bool BCAnimationCurve::add_value_from_rna(const int frame_index)
void BCAnimationCurve::get_value_map(BCValueMap &value_map)
{
value_map.clear();
- if (fcurve == NULL) {
+ if (fcurve == nullptr) {
return;
}
@@ -533,7 +533,7 @@ bool BCAnimationCurve::is_animated()
bool BCAnimationCurve::is_keyframe(int frame)
{
- if (this->fcurve == NULL) {
+ if (this->fcurve == nullptr) {
return false;
}
diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp
index 6bada9950b9..abc770ceef5 100644
--- a/source/blender/io/collada/BCAnimationSampler.cpp
+++ b/source/blender/io/collada/BCAnimationSampler.cpp
@@ -116,7 +116,7 @@ static bool is_object_keyframe(Object *ob, int frame_index)
static void add_keyframes_from(bAction *action, BCFrameSet &frameset)
{
if (action) {
- FCurve *fcu = NULL;
+ FCurve *fcu = nullptr;
for (fcu = (FCurve *)action->curves.first; fcu; fcu = fcu->next) {
BezTriple *bezt = fcu->bezt;
for (int i = 0; i < fcu->totvert; bezt++, i++) {
@@ -237,7 +237,7 @@ bool BCAnimationSampler::is_animated_by_constraint(Object *ob,
{
bConstraint *con;
for (con = (bConstraint *)conlist->first; con; con = con->next) {
- ListBase targets = {NULL, NULL};
+ ListBase targets = {nullptr, nullptr};
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
@@ -468,7 +468,7 @@ void BCAnimationSampler::initialize_curves(BCAnimationCurveMap &curves, Object *
}
/* Add curves on Object->data actions */
- action = NULL;
+ action = nullptr;
if (ob->type == OB_CAMERA) {
action = bc_getSceneCameraAction(ob);
object_type = BC_ANIMATION_TYPE_CAMERA;
@@ -520,7 +520,7 @@ const BCSample *BCSampleFrame::get_sample(Object *ob) const
{
BCSampleMap::const_iterator it = sampleMap.find(ob);
if (it == sampleMap.end()) {
- return NULL;
+ return nullptr;
}
return it->second;
}
@@ -529,7 +529,7 @@ const BCMatrix *BCSampleFrame::get_sample_matrix(Object *ob) const
{
BCSampleMap::const_iterator it = sampleMap.find(ob);
if (it == sampleMap.end()) {
- return NULL;
+ return nullptr;
}
BCSample *sample = it->second;
return &sample->get_matrix();
@@ -540,7 +540,7 @@ const BCMatrix *BCSampleFrame::get_sample_matrix(Object *ob, Bone *bone) const
{
BCSampleMap::const_iterator it = sampleMap.find(ob);
if (it == sampleMap.end()) {
- return NULL;
+ return nullptr;
}
BCSample *sample = it->second;
@@ -577,7 +577,7 @@ BCSample &BCSampleFrameContainer::add(Object *ob, int frame_index)
BCSampleFrame *BCSampleFrameContainer::get_frame(int frame_index)
{
BCSampleFrameMap::iterator it = sample_frames.find(frame_index);
- BCSampleFrame *frame = (it == sample_frames.end()) ? NULL : &it->second;
+ BCSampleFrame *frame = (it == sample_frames.end()) ? nullptr : &it->second;
return frame;
}
diff --git a/source/blender/io/collada/BCSampleData.cpp b/source/blender/io/collada/BCSampleData.cpp
index f099e250565..339dc829742 100644
--- a/source/blender/io/collada/BCSampleData.cpp
+++ b/source/blender/io/collada/BCSampleData.cpp
@@ -86,7 +86,7 @@ const BCMatrix *BCSample::get_matrix(Bone *bone) const
{
BCBoneMatrixMap::const_iterator it = bonemats.find(bone);
if (it == bonemats.end()) {
- return NULL;
+ return nullptr;
}
return it->second;
}
diff --git a/source/blender/io/collada/CMakeLists.txt b/source/blender/io/collada/CMakeLists.txt
index 8ffce9e3e7e..e1645083116 100644
--- a/source/blender/io/collada/CMakeLists.txt
+++ b/source/blender/io/collada/CMakeLists.txt
@@ -141,7 +141,7 @@ endif()
if(CMAKE_COMPILER_IS_GNUCXX)
# COLLADAFWArray.h gives error with gcc 4.5
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
+ string(APPEND CMAKE_CXX_FLAGS " -fpermissive")
endif()
blender_add_lib(bf_collada "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/io/collada/ControllerExporter.cpp b/source/blender/io/collada/ControllerExporter.cpp
index 1d8d0f2b389..52d4bbf122e 100644
--- a/source/blender/io/collada/ControllerExporter.cpp
+++ b/source/blender/io/collada/ControllerExporter.cpp
@@ -47,7 +47,7 @@
bool ControllerExporter::is_skinned_mesh(Object *ob)
{
- return bc_get_assigned_armature(ob) != NULL;
+ return bc_get_assigned_armature(ob) != nullptr;
}
void ControllerExporter::write_bone_URLs(COLLADASW::InstanceController &ins,
@@ -175,7 +175,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
bool use_instantiation = this->export_settings.get_use_object_instantiation();
Mesh *me;
- if (((Mesh *)ob->data)->dvert == NULL) {
+ if (((Mesh *)ob->data)->dvert == nullptr) {
return;
}
@@ -272,7 +272,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
add_joints_element(&ob->defbase, joints_source_id, inv_bind_mat_source_id);
add_vertex_weights_element(weights_source_id, joints_source_id, vcounts, joints);
- BKE_id_free(NULL, me);
+ BKE_id_free(nullptr, me);
closeSkin();
closeController();
@@ -312,7 +312,7 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key)
COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, morph_weights_id)));
targets.add();
- BKE_id_free(NULL, me);
+ BKE_id_free(nullptr, me);
/* support for animations
* can also try the base element and param alternative */
@@ -530,7 +530,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
float loc[3];
float rot[3] = {0, 0, 0};
float scale[3];
- bc_decompose(bind_mat, loc, NULL, NULL, scale);
+ bc_decompose(bind_mat, loc, nullptr, nullptr, scale);
/* Only translations, no rotation vs armature */
loc_eulO_size_to_mat4(bind_mat, loc, rot, scale, 6);
@@ -571,12 +571,12 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
Bone *ControllerExporter::get_bone_from_defgroup(Object *ob_arm, bDeformGroup *def)
{
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, def->name);
- return pchan ? pchan->bone : NULL;
+ return pchan ? pchan->bone : nullptr;
}
bool ControllerExporter::is_bone_defgroup(Object *ob_arm, bDeformGroup *def)
{
- return get_bone_from_defgroup(ob_arm, def) != NULL;
+ return get_bone_from_defgroup(ob_arm, def) != nullptr;
}
std::string ControllerExporter::add_weights_source(Mesh *me,
diff --git a/source/blender/io/collada/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp
index 65c71b0edef..241afbd4034 100644
--- a/source/blender/io/collada/DocumentExporter.cpp
+++ b/source/blender/io/collada/DocumentExporter.cpp
@@ -127,7 +127,7 @@ char *bc_CustomData_get_layer_name(const struct CustomData *data, int type, int
{
int layer_index = CustomData_get_layer_index(data, type);
if (layer_index < 0) {
- return NULL;
+ return nullptr;
}
return data->layers[layer_index + n].name;
@@ -138,7 +138,7 @@ char *bc_CustomData_get_active_layer_name(const CustomData *data, int type)
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_active_layer_index(data, type);
if (layer_index < 0) {
- return NULL;
+ return nullptr;
}
return data->layers[layer_index].name;
@@ -155,7 +155,7 @@ static COLLADABU::NativeString make_temp_filepath(const char *name, const char *
{
char tempfile[FILE_MAX];
- if (name == NULL) {
+ if (name == nullptr) {
name = "untitled";
}
@@ -184,7 +184,7 @@ int DocumentExporter::exportCurrentScene()
clear_global_id_map();
- COLLADABU::NativeString native_filename = make_temp_filepath(NULL, ".dae");
+ COLLADABU::NativeString native_filename = make_temp_filepath(nullptr, ".dae");
COLLADASW::StreamWriter *writer = new COLLADASW::StreamWriter(native_filename);
/* open <collada> */
diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp
index b9f132d04dd..b85a96d89de 100644
--- a/source/blender/io/collada/DocumentImporter.cpp
+++ b/source/blender/io/collada/DocumentImporter.cpp
@@ -224,7 +224,7 @@ void DocumentImporter::finish()
fprintf(stderr, "+-- Import Scene --------\n");
const COLLADAFW::NodePointerArray &roots = (*sit)->getRootNodes();
for (unsigned int i = 0; i < roots.getCount(); i++) {
- std::vector<Object *> *objects_done = write_node(roots[i], NULL, sce, NULL, false);
+ std::vector<Object *> *objects_done = write_node(roots[i], nullptr, sce, nullptr, false);
objects_to_scale->insert(
objects_to_scale->end(), objects_done->begin(), objects_done->end());
delete objects_done;
@@ -247,7 +247,7 @@ void DocumentImporter::finish()
const COLLADAFW::NodePointerArray &roots = (*vsit)->getRootNodes();
for (unsigned int i = 0; i < roots.getCount(); i++) {
- translate_anim_recursive(roots[i], NULL, NULL);
+ translate_anim_recursive(roots[i], nullptr, nullptr);
}
}
@@ -270,12 +270,12 @@ void DocumentImporter::finish()
/* update scene */
DEG_id_tag_update(&sce->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
- WM_event_add_notifier(mContext, NC_OBJECT | ND_TRANSFORM, NULL);
+ WM_event_add_notifier(mContext, NC_OBJECT | ND_TRANSFORM, nullptr);
}
void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node,
- COLLADAFW::Node *par = NULL,
- Object *parob = NULL)
+ COLLADAFW::Node *par = nullptr,
+ Object *parob = nullptr)
{
/* The split in T29246, rootmap must point at actual root when
* calculating bones in apply_curves_as_matrix. - actual root is the root node.
@@ -306,7 +306,7 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node,
#endif
unsigned int i;
- if (node->getType() == COLLADAFW::Node::JOINT && par == NULL) {
+ if (node->getType() == COLLADAFW::Node::JOINT && par == nullptr) {
/* For Skeletons without root node we have to simulate the
* root node here and recursively enter the same function
* XXX: maybe this can be made more elegant. */
@@ -317,7 +317,7 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node,
node, root_map, object_map, FW_object_map, uid_material_map);
COLLADAFW::NodePointerArray &children = node->getChildNodes();
for (i = 0; i < children.getCount(); i++) {
- translate_anim_recursive(children[i], node, NULL);
+ translate_anim_recursive(children[i], node, nullptr);
}
}
}
@@ -375,11 +375,11 @@ Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera
const COLLADAFW::UniqueId &cam_uid = camera->getInstanciatedObjectId();
if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) {
// fprintf(stderr, "Couldn't find camera by UID.\n");
- return NULL;
+ return nullptr;
}
Main *bmain = CTX_data_main(mContext);
- Object *ob = bc_add_object(bmain, sce, view_layer, OB_CAMERA, NULL);
+ Object *ob = bc_add_object(bmain, sce, view_layer, OB_CAMERA, nullptr);
Camera *cam = uid_camera_map[cam_uid];
Camera *old_cam = (Camera *)ob->data;
ob->data = cam;
@@ -392,11 +392,11 @@ Object *DocumentImporter::create_light_object(COLLADAFW::InstanceLight *lamp, Sc
const COLLADAFW::UniqueId &lamp_uid = lamp->getInstanciatedObjectId();
if (uid_light_map.find(lamp_uid) == uid_light_map.end()) {
fprintf(stderr, "Couldn't find light by UID.\n");
- return NULL;
+ return nullptr;
}
Main *bmain = CTX_data_main(mContext);
- Object *ob = bc_add_object(bmain, sce, view_layer, OB_LAMP, NULL);
+ Object *ob = bc_add_object(bmain, sce, view_layer, OB_LAMP, nullptr);
Light *la = uid_light_map[lamp_uid];
Light *old_light = (Light *)ob->data;
ob->data = la;
@@ -438,7 +438,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
}
/* calc new matrix and apply */
mul_m4_m4m4(obn->obmat, obn->obmat, mat);
- BKE_object_apply_mat4(obn, obn->obmat, 0, 0);
+ BKE_object_apply_mat4(obn, obn->obmat, false, false);
}
}
else {
@@ -456,7 +456,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
continue;
}
COLLADAFW::InstanceNodePointerArray &inodes = child_node->getInstanceNodes();
- Object *new_child = NULL;
+ Object *new_child = nullptr;
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));
@@ -465,7 +465,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
}
else {
new_child = create_instance_node(
- object_map.find(child_id)->second, child_node, NULL, sce, is_library_node);
+ object_map.find(child_id)->second, child_node, nullptr, sce, is_library_node);
}
bc_set_parent(new_child, obn, mContext, true);
@@ -509,7 +509,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
bool is_library_node)
{
Main *bmain = CTX_data_main(mContext);
- Object *ob = NULL;
+ Object *ob = nullptr;
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
bool read_transform = true;
std::string id = node->getOriginalId();
@@ -525,7 +525,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
stderr, "| %s id='%s', name='%s'\n", is_joint ? "JOINT" : "NODE ", id.c_str(), name.c_str());
if (is_joint) {
- if (parent_node == NULL && !is_library_node) {
+ if (parent_node == nullptr && !is_library_node) {
/* A Joint on root level is a skeleton without root node.
* Here we add the armature "on the fly": */
par = bc_add_object(bmain, sce, view_layer, OB_ARMATURE, std::string("Armature").c_str());
@@ -534,11 +534,11 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
object_map.insert(std::pair<COLLADAFW::UniqueId, Object *>(node->getUniqueId(), par));
node_map[node->getUniqueId()] = node;
}
- if (parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT) {
+ if (parent_node == nullptr || parent_node->getType() != COLLADAFW::Node::JOINT) {
armature_importer.add_root_joint(node, par);
}
- if (parent_node == NULL) {
+ if (parent_node == nullptr) {
/* for skeletons without root node all has been done above.
* Skeletons with root node are handled further down. */
goto finally;
@@ -561,12 +561,12 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
* sure... <instance_geometry> */
while (geom_done < geom.getCount()) {
ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map);
- if (ob == NULL) {
+ if (ob == nullptr) {
report_unknown_reference(*node, "instance_mesh");
}
else {
objects_done->push_back(ob);
- if (parent_node == NULL) {
+ if (parent_node == nullptr) {
root_objects->push_back(ob);
}
}
@@ -574,12 +574,12 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
while (camera_done < camera.getCount()) {
ob = create_camera_object(camera[camera_done], sce);
- if (ob == NULL) {
+ if (ob == nullptr) {
report_unknown_reference(*node, "instance_camera");
}
else {
objects_done->push_back(ob);
- if (parent_node == NULL) {
+ if (parent_node == nullptr) {
root_objects->push_back(ob);
}
}
@@ -587,12 +587,12 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
while (lamp_done < lamp.getCount()) {
ob = create_light_object(lamp[lamp_done], sce);
- if (ob == NULL) {
+ if (ob == nullptr) {
report_unknown_reference(*node, "instance_light");
}
else {
objects_done->push_back(ob);
- if (parent_node == NULL) {
+ if (parent_node == nullptr) {
root_objects->push_back(ob);
}
}
@@ -602,12 +602,12 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
COLLADAFW::InstanceGeometry *geometry = (COLLADAFW::InstanceGeometry *)
controller[controller_done];
ob = mesh_importer.create_mesh_object(node, geometry, true, uid_material_map);
- if (ob == NULL) {
+ if (ob == nullptr) {
report_unknown_reference(*node, "instance_controller");
}
else {
objects_done->push_back(ob);
- if (parent_node == NULL) {
+ if (parent_node == nullptr) {
root_objects->push_back(ob);
}
}
@@ -620,7 +620,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
fprintf(stderr,
"Cannot find object for node referenced by <instance_node name=\"%s\">.\n",
inst_node[inst_done]->getName().c_str());
- ob = NULL;
+ ob = nullptr;
}
else {
std::pair<std::multimap<COLLADAFW::UniqueId, Object *>::iterator,
@@ -633,7 +633,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
COLLADAFW::Node *source_node = node_map[node_id];
ob = create_instance_node(source_ob, source_node, node, sce, is_library_node);
objects_done->push_back(ob);
- if (parent_node == NULL) {
+ if (parent_node == nullptr) {
root_objects->push_back(ob);
}
}
@@ -651,10 +651,10 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
ob = bc_add_object(bmain, sce, view_layer, OB_ARMATURE, name.c_str());
}
else {
- ob = bc_add_object(bmain, sce, view_layer, OB_EMPTY, NULL);
+ ob = bc_add_object(bmain, sce, view_layer, OB_EMPTY, nullptr);
}
objects_done->push_back(ob);
- if (parent_node == NULL) {
+ if (parent_node == nullptr) {
root_objects->push_back(ob);
}
}
@@ -701,7 +701,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
if (objects_done->empty()) {
- ob = NULL;
+ ob = nullptr;
}
else {
ob = *objects_done->begin();
@@ -763,7 +763,7 @@ bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryN
fprintf(stderr, "+-- Read Library nodes ----------\n");
for (unsigned int i = 0; i < nodes.getCount(); i++) {
std::vector<Object *> *child_objects;
- child_objects = write_node(nodes[i], NULL, sce, NULL, true);
+ child_objects = write_node(nodes[i], nullptr, sce, nullptr, true);
delete child_objects;
}
return true;
@@ -876,7 +876,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
}
Main *bmain = CTX_data_main(mContext);
- Camera *cam = NULL;
+ Camera *cam = nullptr;
std::string cam_id, cam_name;
ExtraTags *et = getExtraTags(camera->getUniqueId());
@@ -1029,7 +1029,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
}
Main *bmain = CTX_data_main(mContext);
- Light *lamp = NULL;
+ Light *lamp = nullptr;
std::string la_id, la_name;
ExtraTags *et = getExtraTags(light->getUniqueId());
@@ -1237,7 +1237,7 @@ bool DocumentImporter::writeKinematicsScene(const COLLADAFW::KinematicsScene *ki
ExtraTags *DocumentImporter::getExtraTags(const COLLADAFW::UniqueId &uid)
{
if (uid_tags_map.find(uid.toAscii()) == uid_tags_map.end()) {
- return NULL;
+ return nullptr;
}
return uid_tags_map[uid.toAscii()];
}
diff --git a/source/blender/io/collada/ExtraHandler.cpp b/source/blender/io/collada/ExtraHandler.cpp
index acfa74f34af..8aefb321dd6 100644
--- a/source/blender/io/collada/ExtraHandler.cpp
+++ b/source/blender/io/collada/ExtraHandler.cpp
@@ -23,7 +23,8 @@
#include "ExtraHandler.h"
-ExtraHandler::ExtraHandler(DocumentImporter *dimp, AnimationImporter *aimp) : currentExtraTags(0)
+ExtraHandler::ExtraHandler(DocumentImporter *dimp, AnimationImporter *aimp)
+ : currentExtraTags(nullptr)
{
this->dimp = dimp;
this->aimp = aimp;
@@ -50,7 +51,7 @@ bool ExtraHandler::textData(const char *text, size_t textLength)
{
char buf[1024];
- if (currentElement.length() == 0 || currentExtraTags == 0) {
+ if (currentElement.length() == 0 || currentExtraTags == nullptr) {
return false;
}
@@ -64,7 +65,7 @@ bool ExtraHandler::parseElement(const char *profileName,
const COLLADAFW::UniqueId &uniqueId)
{
/* implement for backwards compatibility, new version added object parameter */
- return parseElement(profileName, elementHash, uniqueId, NULL);
+ return parseElement(profileName, elementHash, uniqueId, nullptr);
}
bool ExtraHandler::parseElement(const char *profileName,
diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp
index 332390845c7..def7caabf32 100644
--- a/source/blender/io/collada/GeometryExporter.cpp
+++ b/source/blender/io/collada/GeometryExporter.cpp
@@ -140,7 +140,7 @@ void GeometryExporter::operator()(Object *ob)
}
}
- BKE_id_free(NULL, me);
+ BKE_id_free(nullptr, me);
}
void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
@@ -350,7 +350,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
return;
}
- Material *ma = ob->totcol ? BKE_object_material_get(ob, material_index + 1) : NULL;
+ Material *ma = ob->totcol ? BKE_object_material_get(ob, material_index + 1) : nullptr;
COLLADASW::PrimitivesBase *primitive_list = create_primitive_list(is_triangulated, mSW);
/* sets count attribute in <polylist> */
@@ -636,7 +636,7 @@ void GeometryExporter::create_normals(std::vector<Normal> &normals,
MVert *verts = me->mvert;
MLoop *mloops = me->mloop;
- float(*lnors)[3] = NULL;
+ float(*lnors)[3] = nullptr;
bool use_custom_normals = false;
BKE_mesh_calc_normals_split(me);
diff --git a/source/blender/io/collada/ImageExporter.cpp b/source/blender/io/collada/ImageExporter.cpp
index 51d753db03f..bb7b3bf0631 100644
--- a/source/blender/io/collada/ImageExporter.cpp
+++ b/source/blender/io/collada/ImageExporter.cpp
@@ -53,7 +53,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
std::string name(id_name(image));
std::string translated_name(translate_id(name));
- ImBuf *imbuf = BKE_image_acquire_ibuf(image, NULL, NULL);
+ ImBuf *imbuf = BKE_image_acquire_ibuf(image, nullptr, nullptr);
if (!imbuf) {
fprintf(stderr, "Collada export: image does not exist:\n%s\n", image->filepath);
return;
@@ -106,7 +106,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
/* make absolute source path */
BLI_strncpy(source_path, image->filepath, sizeof(source_path));
BLI_path_abs(source_path, ID_BLEND_PATH_FROM_GLOBAL(&image->id));
- BLI_path_normalize(NULL, source_path);
+ BLI_path_normalize(nullptr, source_path);
if (use_copies) {
@@ -145,7 +145,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
img.add(mSW);
fprintf(stdout, "Collada export: Added image: %s\n", export_file);
- BKE_image_release_ibuf(image, imbuf, NULL);
+ BKE_image_release_ibuf(image, imbuf, nullptr);
}
void ImagesExporter::exportImages(Scene *sce)
diff --git a/source/blender/io/collada/Materials.cpp b/source/blender/io/collada/Materials.cpp
index a97b7dfcfd6..644ecc18e9b 100644
--- a/source/blender/io/collada/Materials.cpp
+++ b/source/blender/io/collada/Materials.cpp
@@ -96,10 +96,10 @@ bNodeTree *MaterialNode::prepare_material_nodetree()
{
if (material->nodetree) {
ntree = material->nodetree;
- return NULL;
+ return nullptr;
}
- material->nodetree = ntreeAddTree(NULL, "Shader Nodetree", "ShaderNodeTree");
+ material->nodetree = ntreeAddTree(nullptr, "Shader Nodetree", "ShaderNodeTree");
material->use_nodes = true;
ntree = material->nodetree;
return ntree;
@@ -225,7 +225,7 @@ void MaterialNode::set_diffuse(COLLADAFW::ColorOrTexture &cot)
}
else if (cot.isTexture()) {
bNode *texture_node = add_texture_node(cot, -300, locy, "Base Color");
- if (texture_node != NULL) {
+ if (texture_node != nullptr) {
add_link(texture_node, 0, shader_node, 0);
}
}
@@ -320,7 +320,7 @@ void MaterialNode::set_emission(COLLADAFW::ColorOrTexture &cot)
// texture
else if (cot.isTexture()) {
bNode *texture_node = add_texture_node(cot, -300, locy, "Emission");
- if (texture_node != NULL) {
+ if (texture_node != nullptr) {
add_link(texture_node, 0, shader_node, 0);
}
}
@@ -392,7 +392,7 @@ bNode *MaterialNode::add_texture_node(COLLADAFW::ColorOrTexture &cot,
if (image_map.find(ima_uid) == image_map.end()) {
fprintf(stderr, "Couldn't find an image by UID.\n");
- return NULL;
+ return nullptr;
}
Image *ima = image_map[ima_uid];
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp
index 72a265db287..bb2aabb0598 100644
--- a/source/blender/io/collada/MeshImporter.cpp
+++ b/source/blender/io/collada/MeshImporter.cpp
@@ -346,7 +346,7 @@ void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
}
me->totvert = pos.getFloatValues()->getCount() / stride;
- me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
+ me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, nullptr, me->totvert);
MVert *mvert;
int i;
@@ -469,8 +469,10 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
if (total_poly_count > 0) {
me->totpoly = total_poly_count;
me->totloop = total_loop_count;
- me->mpoly = (MPoly *)CustomData_add_layer(&me->pdata, CD_MPOLY, CD_CALLOC, NULL, me->totpoly);
- me->mloop = (MLoop *)CustomData_add_layer(&me->ldata, CD_MLOOP, CD_CALLOC, NULL, me->totloop);
+ me->mpoly = (MPoly *)CustomData_add_layer(
+ &me->pdata, CD_MPOLY, CD_CALLOC, nullptr, me->totpoly);
+ me->mloop = (MLoop *)CustomData_add_layer(
+ &me->ldata, CD_MLOOP, CD_CALLOC, nullptr, me->totloop);
unsigned int totuvset = collada_mesh->getUVCoords().getInputInfosArray().getCount();
for (int i = 0; i < totuvset; i++) {
@@ -487,7 +489,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
COLLADAFW::String &uvname = info->mName;
/* Allocate space for UV_data */
CustomData_add_layer_named(
- &me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, uvname.c_str());
+ &me->ldata, CD_MLOOPUV, CD_DEFAULT, nullptr, me->totloop, uvname.c_str());
}
/* activate the first uv map */
me->mloopuv = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, 0);
@@ -500,7 +502,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
collada_mesh->getColors().getInputInfosArray()[i];
COLLADAFW::String colname = extract_vcolname(info->mName);
CustomData_add_layer_named(
- &me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop, colname.c_str());
+ &me->ldata, CD_MLOOPCOL, CD_DEFAULT, nullptr, me->totloop, colname.c_str());
}
me->mloopcol = (MLoopCol *)CustomData_get_layer_n(&me->ldata, CD_MLOOPCOL, 0);
}
@@ -576,7 +578,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
if (!CustomData_has_layer(&edata, CD_MEDGE)) {
- CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
+ CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, nullptr, totedge);
}
CustomData_free(&mesh->edata, mesh->totedge);
@@ -744,7 +746,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
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());
- if (mloopuv == NULL) {
+ if (mloopuv == nullptr) {
fprintf(stderr,
"Collada import: Mesh [%s] : Unknown reference to TEXCOORD [#%s].\n",
me->id.name,
@@ -774,7 +776,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
COLLADAFW::String colname = extract_vcolname(color_index_list.getName());
MLoopCol *mloopcol = (MLoopCol *)CustomData_get_layer_named(
&me->ldata, CD_MLOOPCOL, colname.c_str());
- if (mloopcol == NULL) {
+ if (mloopcol == nullptr) {
fprintf(stderr,
"Collada import: Mesh [%s] : Unknown reference to VCOLOR [#%s].\n",
me->id.name,
@@ -888,7 +890,7 @@ Object *MeshImporter::get_object_by_geom_uid(const COLLADAFW::UniqueId &geom_uid
if (uid_object_map.find(geom_uid) != uid_object_map.end()) {
return uid_object_map[geom_uid];
}
- return NULL;
+ return nullptr;
}
Mesh *MeshImporter::get_mesh_by_geom_uid(const COLLADAFW::UniqueId &geom_uid)
@@ -896,7 +898,7 @@ Mesh *MeshImporter::get_mesh_by_geom_uid(const COLLADAFW::UniqueId &geom_uid)
if (uid_mesh_map.find(geom_uid) != uid_mesh_map.end()) {
return uid_mesh_map[geom_uid];
}
- return NULL;
+ return nullptr;
}
std::string *MeshImporter::get_geometry_name(const std::string &mesh_name)
@@ -904,7 +906,7 @@ std::string *MeshImporter::get_geometry_name(const std::string &mesh_name)
if (this->mesh_geom_map.find(mesh_name) != this->mesh_geom_map.end()) {
return &this->mesh_geom_map[mesh_name];
}
- return NULL;
+ return nullptr;
}
/**
@@ -959,7 +961,7 @@ static void bc_remove_materials_from_object(Object *ob, Mesh *me)
{
for (int index = 0; index < ob->totcol; index++) {
ob->matbits[index] = 0;
- ob->mat[index] = NULL;
+ ob->mat[index] = nullptr;
}
}
@@ -1109,7 +1111,7 @@ Object *MeshImporter::create_mesh_object(
if (!geom_uid) {
fprintf(stderr, "Couldn't find a mesh UID by controller's UID.\n");
- return NULL;
+ return nullptr;
}
}
else {
@@ -1118,16 +1120,16 @@ Object *MeshImporter::create_mesh_object(
/* 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;
+ return nullptr;
}
}
if (!uid_mesh_map[*geom_uid]) {
- return NULL;
+ return nullptr;
}
/* name Object */
const std::string &id = node->getName().empty() ? node->getOriginalId() : node->getName();
- const char *name = (id.length()) ? id.c_str() : NULL;
+ const char *name = (id.length()) ? id.c_str() : nullptr;
/* add object */
Object *ob = bc_add_object(m_bmain, scene, view_layer, OB_MESH, name);
diff --git a/source/blender/io/collada/SceneExporter.cpp b/source/blender/io/collada/SceneExporter.cpp
index 1b3bc1b66ea..01c270518e9 100644
--- a/source/blender/io/collada/SceneExporter.cpp
+++ b/source/blender/io/collada/SceneExporter.cpp
@@ -107,7 +107,7 @@ void SceneExporter::writeNode(Object *ob)
bool armature_exported = false;
Object *ob_arm = bc_get_assigned_armature(ob);
- if (ob_arm != NULL) {
+ if (ob_arm != nullptr) {
armature_exported = bc_is_in_Export_set(
this->export_settings.get_export_set(), ob_arm, view_layer);
if (armature_exported && bc_is_marked(ob_arm)) {
@@ -207,7 +207,7 @@ void SceneExporter::writeNode(Object *ob)
* No real mapping in the .dae
* Need support for multiple target objects also. */
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
- ListBase targets = {NULL, NULL};
+ ListBase targets = {nullptr, nullptr};
if (cti && cti->get_constraint_targets) {
bConstraintTarget *ct;
@@ -222,7 +222,7 @@ void SceneExporter::writeNode(Object *ob)
}
if (cti->flush_constraint_targets) {
- cti->flush_constraint_targets(con, &targets, 1);
+ cti->flush_constraint_targets(con, &targets, true);
}
}
diff --git a/source/blender/io/collada/SkinInfo.cpp b/source/blender/io/collada/SkinInfo.cpp
index eef45a5be90..19a4a4f61c2 100644
--- a/source/blender/io/collada/SkinInfo.cpp
+++ b/source/blender/io/collada/SkinInfo.cpp
@@ -75,7 +75,7 @@ SkinInfo::SkinInfo(const SkinInfo &skin)
transfer_int_array_data_const(skin.joint_indices, joint_indices);
}
-SkinInfo::SkinInfo(UnitConverter *conv) : unit_converter(conv), ob_arm(NULL), parent(NULL)
+SkinInfo::SkinInfo(UnitConverter *conv) : unit_converter(conv), ob_arm(nullptr), parent(nullptr)
{
}
@@ -157,7 +157,7 @@ void SkinInfo::set_controller(const COLLADAFW::SkinController *co)
/* called from write_controller */
Object *SkinInfo::create_armature(Main *bmain, Scene *scene, ViewLayer *view_layer)
{
- ob_arm = bc_add_object(bmain, scene, view_layer, OB_ARMATURE, NULL);
+ ob_arm = bc_add_object(bmain, scene, view_layer, OB_ARMATURE, nullptr);
return ob_arm;
}
@@ -228,7 +228,8 @@ void SkinInfo::link_armature(bContext *C,
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- ModifierData *md = ED_object_modifier_add(NULL, bmain, scene, ob, NULL, eModifierType_Armature);
+ ModifierData *md = ED_object_modifier_add(
+ nullptr, bmain, scene, ob, nullptr, eModifierType_Armature);
ArmatureModifierData *amd = (ArmatureModifierData *)md;
amd->object = ob_arm;
@@ -248,7 +249,7 @@ void SkinInfo::link_armature(bContext *C,
DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
#endif
copy_m4_m4(ob->obmat, bind_shape_matrix);
- BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
+ BKE_object_apply_mat4(ob, ob->obmat, false, false);
amd->deformflag = ARM_DEF_VGROUP;
diff --git a/source/blender/io/collada/TransformReader.cpp b/source/blender/io/collada/TransformReader.cpp
index 393393be65b..81b0ffc340a 100644
--- a/source/blender/io/collada/TransformReader.cpp
+++ b/source/blender/io/collada/TransformReader.cpp
@@ -33,7 +33,7 @@ void TransformReader::get_node_mat(float mat[4][4],
std::map<COLLADAFW::UniqueId, Animation> *animation_map,
Object *ob)
{
- get_node_mat(mat, node, animation_map, ob, NULL);
+ get_node_mat(mat, node, animation_map, ob, nullptr);
}
void TransformReader::get_node_mat(float mat[4][4],
diff --git a/source/blender/io/collada/TransformWriter.cpp b/source/blender/io/collada/TransformWriter.cpp
index 7c9d26e4fde..c22631e7bd3 100644
--- a/source/blender/io/collada/TransformWriter.cpp
+++ b/source/blender/io/collada/TransformWriter.cpp
@@ -54,7 +54,7 @@ void TransformWriter::add_joint_transform(COLLADASW::Node &node,
}
else {
float loc[3], rot[3], scale[3];
- bc_decompose(local, loc, rot, NULL, scale);
+ bc_decompose(local, loc, rot, nullptr, scale);
add_transform(node, loc, rot, scale);
}
}
@@ -90,7 +90,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node &node,
}
case BC_TRANSFORMATION_TYPE_DECOMPOSED: {
float loc[3], rot[3], scale[3];
- bc_decompose(f_obmat, loc, rot, NULL, scale);
+ bc_decompose(f_obmat, loc, rot, nullptr, scale);
if (limit_precision) {
bc_sanitize_v3(loc, LIMITTED_PRECISION);
bc_sanitize_v3(rot, LIMITTED_PRECISION);
diff --git a/source/blender/io/collada/collada.cpp b/source/blender/io/collada/collada.cpp
index bf1ebbfa669..f3c69c7d3d0 100644
--- a/source/blender/io/collada/collada.cpp
+++ b/source/blender/io/collada/collada.cpp
@@ -109,7 +109,7 @@ int collada_export(bContext *C, ExportSettings *export_settings)
DocumentExporter exporter(blender_context, export_settings);
int status = exporter.exportCurrentScene();
- BLI_linklist_free(export_settings->export_set, NULL);
+ BLI_linklist_free(export_settings->export_set, nullptr);
return (status) ? -1 : export_count;
}
diff --git a/source/blender/io/collada/collada_internal.cpp b/source/blender/io/collada/collada_internal.cpp
index 091bd2cd7c2..096f6a678ac 100644
--- a/source/blender/io/collada/collada_internal.cpp
+++ b/source/blender/io/collada/collada_internal.cpp
@@ -26,7 +26,7 @@
#include "BKE_armature.h"
-UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP)
+UnitConverter::UnitConverter() : up_axis(COLLADAFW::FileInfo::Z_UP)
{
axis_angle_to_mat4_single(x_up_mat4, 'Y', -0.5 * M_PI);
axis_angle_to_mat4_single(y_up_mat4, 'X', 0.5 * M_PI);
diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp
index 30c77c0a7df..c57952afcc8 100644
--- a/source/blender/io/collada/collada_utils.cpp
+++ b/source/blender/io/collada/collada_utils.cpp
@@ -97,7 +97,7 @@ int bc_test_parent_loop(Object *par, Object *ob)
{
/* test if 'ob' is a parent somewhere in par's parents */
- if (par == NULL) {
+ if (par == nullptr) {
return 0;
}
if (ob == par) {
@@ -112,7 +112,7 @@ bool bc_validateConstraints(bConstraint *con)
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
/* these we can skip completely (invalid constraints...) */
- if (cti == NULL) {
+ if (cti == nullptr) {
return false;
}
if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) {
@@ -120,7 +120,7 @@ bool bc_validateConstraints(bConstraint *con)
}
/* these constraints can't be evaluated anyway */
- if (cti->evaluate_constraint == NULL) {
+ if (cti->evaluate_constraint == nullptr) {
return false;
}
@@ -144,7 +144,8 @@ bool bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
mul_m4_m4m4(ob->obmat, par->obmat, ob->obmat);
}
- bool ok = ED_object_parent_set(NULL, C, scene, ob, par, partype, xmirror, keep_transform, NULL);
+ bool ok = ED_object_parent_set(
+ nullptr, C, scene, ob, par, partype, xmirror, keep_transform, nullptr);
return ok;
}
@@ -222,7 +223,7 @@ Mesh *bc_get_mesh_copy(BlenderContext &blender_context,
bool triangulate)
{
CustomData_MeshMasks mask = CD_MASK_MESH;
- Mesh *tmpmesh = NULL;
+ Mesh *tmpmesh = nullptr;
if (apply_modifiers) {
#if 0 /* Not supported by new system currently... */
switch (export_mesh_type) {
@@ -246,7 +247,7 @@ Mesh *bc_get_mesh_copy(BlenderContext &blender_context,
tmpmesh = (Mesh *)ob->data;
}
- tmpmesh = (Mesh *)BKE_id_copy_ex(NULL, &tmpmesh->id, NULL, LIB_ID_COPY_LOCALIZE);
+ tmpmesh = (Mesh *)BKE_id_copy_ex(nullptr, &tmpmesh->id, nullptr, LIB_ID_COPY_LOCALIZE);
if (triangulate) {
bc_triangulate_mesh(tmpmesh);
@@ -257,7 +258,7 @@ Mesh *bc_get_mesh_copy(BlenderContext &blender_context,
Object *bc_get_assigned_armature(Object *ob)
{
- Object *ob_arm = NULL;
+ Object *ob_arm = nullptr;
if (ob->parent && ob->partype == PARSKEL && ob->parent->type == OB_ARMATURE) {
ob_arm = ob->parent;
@@ -319,7 +320,7 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set)
bool bc_is_root_bone(Bone *aBone, bool deform_bones_only)
{
if (deform_bones_only) {
- Bone *root = NULL;
+ Bone *root = nullptr;
Bone *bone = aBone;
while (bone) {
if (!(bone->flag & BONE_NO_DEFORM)) {
@@ -371,7 +372,7 @@ void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene)
mul_m4_m4m4(ob->obmat, bc_unit.get_scale(), ob->obmat);
}
mul_m4_m4m4(ob->obmat, bc_unit.get_rotation(), ob->obmat);
- BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
+ BKE_object_apply_mat4(ob, ob->obmat, false, false);
}
void bc_match_scale(std::vector<Object *> *objects_done,
@@ -381,7 +382,7 @@ void bc_match_scale(std::vector<Object *> *objects_done,
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end();
++it) {
Object *ob = *it;
- if (ob->parent == NULL) {
+ if (ob->parent == nullptr) {
bc_match_scale(*it, bc_unit, scale_to_scene);
}
}
@@ -450,11 +451,11 @@ void bc_triangulate_mesh(Mesh *me)
BMeshFromMeshParams bm_from_me_params = {0};
bm_from_me_params.calc_face_normal = true;
BM_mesh_bm_from_me(bm, me, &bm_from_me_params);
- BM_mesh_triangulate(bm, quad_method, use_beauty, 4, tag_only, NULL, NULL, NULL);
+ BM_mesh_triangulate(bm, quad_method, use_beauty, 4, tag_only, nullptr, nullptr, nullptr);
BMeshToMeshParams bm_to_me_params = {0};
bm_to_me_params.calc_object_remap = false;
- BM_mesh_bm_to_me(NULL, bm, me, &bm_to_me_params);
+ BM_mesh_bm_to_me(nullptr, bm, me, &bm_to_me_params);
BM_mesh_free(bm);
}
@@ -481,7 +482,7 @@ EditBone *bc_get_edit_bone(bArmature *armature, char *name)
}
}
- return NULL;
+ return nullptr;
}
int bc_set_layer(int bitfield, int layer)
{
@@ -511,7 +512,7 @@ BoneExtensionMap &BoneExtensionManager::getExtensionMap(bArmature *armature)
{
std::string key = armature->id.name;
BoneExtensionMap *result = extended_bone_maps[key];
- if (result == NULL) {
+ if (result == nullptr) {
result = new BoneExtensionMap();
extended_bone_maps[key] = result;
}
@@ -706,7 +707,7 @@ int BoneExtended::get_use_connect()
void bc_set_IDPropertyMatrix(EditBone *ebone, const char *key, float mat[4][4])
{
IDProperty *idgroup = (IDProperty *)ebone->prop;
- if (idgroup == NULL) {
+ if (idgroup == nullptr) {
IDPropertyTemplate val = {0};
idgroup = IDP_New(IDP_GROUP, &val, "RNA_EditBone ID properties");
ebone->prop = idgroup;
@@ -754,7 +755,7 @@ static void bc_set_IDProperty(EditBone *ebone, const char *key, float value)
*/
IDProperty *bc_get_IDProperty(Bone *bone, std::string key)
{
- return (bone->prop == NULL) ? NULL : IDP_GetPropertyFromGroup(bone->prop, key.c_str());
+ return (bone->prop == nullptr) ? nullptr : IDP_GetPropertyFromGroup(bone->prop, key.c_str());
}
/**
@@ -895,7 +896,7 @@ bool bc_bone_matrix_local_get(Object *ob, Bone *bone, Matrix &mat, bool for_open
mul_m4_m4m4(mat, temp, mat);
}
}
- bc_enable_fcurves(action, NULL);
+ bc_enable_fcurves(action, nullptr);
return true;
}
@@ -908,11 +909,11 @@ bool bc_is_animated(BCMatrixSampleMap &values)
}
BCMatrixSampleMap::iterator it;
- const BCMatrix *refmat = NULL;
+ const BCMatrix *refmat = nullptr;
for (it = values.begin(); it != values.end(); ++it) {
const BCMatrix *matrix = it->second;
- if (refmat == NULL) {
+ if (refmat == nullptr) {
refmat = matrix;
continue;
}
@@ -1040,7 +1041,7 @@ void bc_create_restpose_mat(BCExportSettings &export_settings,
return;
}
- bc_decompose(from_mat, loc, rot, NULL, scale);
+ bc_decompose(from_mat, loc, rot, nullptr, scale);
loc_eulO_size_to_mat4(to_mat, loc, rot, scale, 6);
if (export_settings.get_keep_bind_info()) {
@@ -1192,8 +1193,8 @@ std::string bc_find_bonename_in_path(std::string path, std::string probe)
static bNodeTree *prepare_material_nodetree(Material *ma)
{
- if (ma->nodetree == NULL) {
- ma->nodetree = ntreeAddTree(NULL, "Shader Nodetree", "ShaderNodeTree");
+ if (ma->nodetree == nullptr) {
+ ma->nodetree = ntreeAddTree(nullptr, "Shader Nodetree", "ShaderNodeTree");
ma->use_nodes = true;
}
return ma->nodetree;
@@ -1450,7 +1451,7 @@ bNode *bc_get_master_shader(Material *ma)
}
}
}
- return NULL;
+ return nullptr;
}
COLLADASW::ColorOrTexture bc_get_cot(float r, float g, float b, float a)
diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
index 6077fc89b91..fc47b024be1 100644
--- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
@@ -182,7 +182,7 @@ bool AbstractHierarchyWriter::check_has_deforming_physics(const HierarchyContext
}
AbstractHierarchyIterator::AbstractHierarchyIterator(Depsgraph *depsgraph)
- : depsgraph_(depsgraph), writers_(), export_subset_({true, true})
+ : depsgraph_(depsgraph), export_subset_({true, true})
{
}
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 6e4509afd30..ad0d6820e2b 100644
--- a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
+++ b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
@@ -272,7 +272,7 @@ TEST_F(AbstractHierarchyIteratorTest, ExportSubsetTest)
/* Even when only asking an export of transforms, on the first frame everything should be
* exported. */
{
- ExportSubset export_subset = {0};
+ ExportSubset export_subset = {false};
export_subset.transforms = true;
export_subset.shapes = false;
iterator->set_export_subset(export_subset);
@@ -296,7 +296,7 @@ TEST_F(AbstractHierarchyIteratorTest, ExportSubsetTest)
/* Third iteration, should only write data now. */
{
- ExportSubset export_subset = {0};
+ ExportSubset export_subset = {false};
export_subset.transforms = false;
export_subset.shapes = true;
iterator->set_export_subset(export_subset);
@@ -311,7 +311,7 @@ TEST_F(AbstractHierarchyIteratorTest, ExportSubsetTest)
/* Fourth iteration, should export everything now. */
{
- ExportSubset export_subset = {0};
+ ExportSubset export_subset = {false};
export_subset.transforms = true;
export_subset.shapes = true;
iterator->set_export_subset(export_subset);
diff --git a/source/blender/io/common/intern/hierarchy_context_order_test.cc b/source/blender/io/common/intern/hierarchy_context_order_test.cc
index f4e2b81b39b..3f2e348a8ee 100644
--- a/source/blender/io/common/intern/hierarchy_context_order_test.cc
+++ b/source/blender/io/common/intern/hierarchy_context_order_test.cc
@@ -38,11 +38,11 @@ class HierarchyContextOrderTest : public testing::Test {
TEST_F(HierarchyContextOrderTest, ObjectPointerTest)
{
- HierarchyContext ctx_a = {0};
+ HierarchyContext ctx_a = {nullptr};
ctx_a.object = fake_pointer(1);
ctx_a.duplicator = nullptr;
- HierarchyContext ctx_b = {0};
+ HierarchyContext ctx_b = {nullptr};
ctx_b.object = fake_pointer(2);
ctx_b.duplicator = nullptr;
@@ -53,12 +53,12 @@ TEST_F(HierarchyContextOrderTest, ObjectPointerTest)
TEST_F(HierarchyContextOrderTest, DuplicatorPointerTest)
{
- HierarchyContext ctx_a = {0};
+ HierarchyContext ctx_a = {nullptr};
ctx_a.object = fake_pointer(1);
ctx_a.duplicator = fake_pointer(1);
ctx_a.export_name = "A";
- HierarchyContext ctx_b = {0};
+ HierarchyContext ctx_b = {nullptr};
ctx_b.object = fake_pointer(1);
ctx_b.duplicator = fake_pointer(1);
ctx_b.export_name = "B";
@@ -70,11 +70,11 @@ TEST_F(HierarchyContextOrderTest, DuplicatorPointerTest)
TEST_F(HierarchyContextOrderTest, ExportParentTest)
{
- HierarchyContext ctx_a = {0};
+ HierarchyContext ctx_a = {nullptr};
ctx_a.object = fake_pointer(1);
ctx_a.export_parent = fake_pointer(1);
- HierarchyContext ctx_b = {0};
+ HierarchyContext ctx_b = {nullptr};
ctx_b.object = fake_pointer(1);
ctx_b.export_parent = fake_pointer(2);
@@ -85,25 +85,25 @@ TEST_F(HierarchyContextOrderTest, ExportParentTest)
TEST_F(HierarchyContextOrderTest, TransitiveTest)
{
- HierarchyContext ctx_a = {0};
+ HierarchyContext ctx_a = {nullptr};
ctx_a.object = fake_pointer(1);
ctx_a.export_parent = fake_pointer(1);
ctx_a.duplicator = nullptr;
ctx_a.export_name = "A";
- HierarchyContext ctx_b = {0};
+ HierarchyContext ctx_b = {nullptr};
ctx_b.object = fake_pointer(2);
ctx_b.export_parent = nullptr;
ctx_b.duplicator = fake_pointer(1);
ctx_b.export_name = "B";
- HierarchyContext ctx_c = {0};
+ HierarchyContext ctx_c = {nullptr};
ctx_c.object = fake_pointer(2);
ctx_c.export_parent = fake_pointer(2);
ctx_c.duplicator = fake_pointer(1);
ctx_c.export_name = "C";
- HierarchyContext ctx_d = {0};
+ HierarchyContext ctx_d = {nullptr};
ctx_d.object = fake_pointer(2);
ctx_d.export_parent = fake_pointer(3);
ctx_d.duplicator = nullptr;
diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc
index 7b375689543..dc2b46e5cea 100644
--- a/source/blender/io/usd/intern/usd_capi.cc
+++ b/source/blender/io/usd/intern/usd_capi.cc
@@ -59,7 +59,7 @@ struct ExportJobData {
bool export_ok;
};
-static void ensure_usd_plugin_path_registered(void)
+static void ensure_usd_plugin_path_registered()
{
static bool plugin_path_registered = false;
if (plugin_path_registered) {
@@ -225,7 +225,7 @@ bool USD_export(bContext *C,
else {
/* Fake a job context, so that we don't need NULL pointer checks while exporting. */
short stop = 0, do_update = 0;
- float progress = 0.f;
+ float progress = 0.0f;
blender::io::usd::export_startjob(job, &stop, &do_update, &progress);
blender::io::usd::export_endjob(job);
diff --git a/source/blender/io/usd/intern/usd_writer_abstract.cc b/source/blender/io/usd/intern/usd_writer_abstract.cc
index 17d51c9b7cc..694fc76a446 100644
--- a/source/blender/io/usd/intern/usd_writer_abstract.cc
+++ b/source/blender/io/usd/intern/usd_writer_abstract.cc
@@ -37,10 +37,7 @@ static const pxr::TfToken surface("surface", pxr::TfToken::Immortal);
namespace blender::io::usd {
USDAbstractWriter::USDAbstractWriter(const USDExporterContext &usd_export_context)
- : usd_export_context_(usd_export_context),
- usd_value_writer_(),
- frame_has_been_written_(false),
- is_animated_(false)
+ : usd_export_context_(usd_export_context), frame_has_been_written_(false), is_animated_(false)
{
}
diff --git a/source/blender/io/usd/intern/usd_writer_light.cc b/source/blender/io/usd/intern/usd_writer_light.cc
index b6a81c973d2..f77c51c22ec 100644
--- a/source/blender/io/usd/intern/usd_writer_light.cc
+++ b/source/blender/io/usd/intern/usd_writer_light.cc
@@ -99,7 +99,7 @@ void USDLightWriter::do_write(HierarchyContext &context)
usd_intensity = light->energy;
}
else {
- usd_intensity = light->energy / 100.f;
+ usd_intensity = light->energy / 100.0f;
}
usd_light.CreateIntensityAttr().Set(usd_intensity, timecode);
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 6aec3c39b29..f2d860a2851 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -305,6 +305,7 @@ typedef struct ID {
/**
* Only set for data-blocks which are coming from copy-on-write, points to
* the original version of it.
+ * Also used temporarily during memfile undo to keep a reference to old ID when found.
*/
struct ID *orig_id;
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index ac6160b28e4..790a7a36288 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -857,7 +857,7 @@ typedef enum eSAction_Flag {
/* show pose-markers (local to action) in Action Editor mode */
SACTION_POSEMARKERS_SHOW = (1 << 6),
/* don't draw action channels using group colors (where applicable) */
- SACTION_NODRAWGCOLORS = (1 << 7),
+ /* SACTION_NODRAWGCOLORS = (1 << 7), DEPRECATED */
/* SACTION_NODRAWCFRANUM = (1 << 8), DEPRECATED */
/* don't perform realtime updates */
SACTION_NOREALTIMEUPDATES = (1 << 10),
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 37b7947dbea..866c1c44e3f 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -183,7 +183,7 @@ typedef enum eGPBrush_Presets {
GP_BRUSH_PRESET_DRAW_WEIGHT = 300,
} eGPBrush_Presets;
-/* BrushGpencilSettings->gp_flag */
+/* BrushGpencilSettings->flag */
typedef enum eGPDbrush_Flag {
/* brush use pressure */
GP_BRUSH_USE_PRESSURE = (1 << 0),
@@ -775,6 +775,7 @@ typedef enum eBrushFlags2 {
BRUSH_POSE_USE_LOCK_ROTATION = (1 << 5),
BRUSH_CLOTH_USE_COLLISION = (1 << 6),
BRUSH_AREA_RADIUS_PRESSURE = (1 << 7),
+ BRUSH_GRAB_SILHOUETTE = (1 << 8),
} eBrushFlags2;
typedef enum {
diff --git a/source/blender/makesdna/DNA_camera_defaults.h b/source/blender/makesdna/DNA_camera_defaults.h
index 55fbb59a161..b0237caa544 100644
--- a/source/blender/makesdna/DNA_camera_defaults.h
+++ b/source/blender/makesdna/DNA_camera_defaults.h
@@ -37,7 +37,7 @@
#define _DNA_DEFAULT_CameraStereoSettings \
{ \
.interocular_distance = 0.065f, \
- .convergence_distance = 30.f * 0.065f, \
+ .convergence_distance = 30.0f * 0.065f, \
.pole_merge_angle_from = DEG2RADF(60.0f), \
.pole_merge_angle_to = DEG2RADF(75.0f), \
}
diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h
index 5577a17c0df..ff419e1794e 100644
--- a/source/blender/makesdna/DNA_color_types.h
+++ b/source/blender/makesdna/DNA_color_types.h
@@ -61,9 +61,9 @@ typedef struct CurveMap {
/** Display and evaluate table. */
CurveMapPoint *table;
- /** For RGB curves, premulled table. */
+ /** For RGB curves, pre-multiplied table. */
CurveMapPoint *premultable;
- /** For RGB curves, premulled extrapolation vector. */
+ /** For RGB curves, pre-multiplied extrapolation vector. */
float premul_ext_in[2];
float premul_ext_out[2];
} CurveMap;
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index 92ee3f062a6..93a67602047 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -60,7 +60,7 @@ typedef struct bConstraint {
/** Constraint name, MAX_NAME. */
char name[64];
- /* Flag for panel and subpanel closed / open state in the UI. */
+ /* An "expand" bit for each of the constraint's (sub)panels (uiPanelDataExpansion). */
short ui_expand_flag;
/** Amount of influence exherted by constraint (0.0-1.0). */
@@ -690,8 +690,10 @@ typedef enum eBConstraint_Types {
/* flag 0x20 (1 << 5) was used to indicate that a constraint was evaluated
* using a 'local' hack for posebones only. */
typedef enum eBConstraint_Flags {
+#ifdef DNA_DEPRECATED_ALLOW
/* Expansion for old box constraint layouts. Just for versioning. */
CONSTRAINT_EXPAND_DEPRECATED = (1 << 0),
+#endif
/* pre-check for illegal object name or bone name */
CONSTRAINT_DISABLE = (1 << 2),
/* to indicate which Ipo should be shown, maybe for 3d access later too */
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 2f362034b78..4eca81c27cc 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -519,6 +519,10 @@ typedef enum eBezTriple_KeyframeType {
(bezt)->f2 & SELECT : \
BEZT_ISSEL_ANY(bezt))
+#define BEZT_ISSEL_IDX(bezt, i) \
+ ((i == 0 && (bezt)->f1 & SELECT) || (i == 1 && (bezt)->f2 & SELECT) || \
+ (i == 2 && (bezt)->f3 & SELECT))
+
#define BEZT_SEL_ALL(bezt) \
{ \
(bezt)->f1 |= SELECT; \
@@ -533,6 +537,49 @@ typedef enum eBezTriple_KeyframeType {
(bezt)->f3 &= ~SELECT; \
} \
((void)0)
+#define BEZT_SEL_INVERT(bezt) \
+ { \
+ (bezt)->f1 ^= SELECT; \
+ (bezt)->f2 ^= SELECT; \
+ (bezt)->f3 ^= SELECT; \
+ } \
+ ((void)0)
+
+#define BEZT_SEL_IDX(bezt, i) \
+ { \
+ switch (i) { \
+ case 0: \
+ (bezt)->f1 |= SELECT; \
+ break; \
+ case 1: \
+ (bezt)->f2 |= SELECT; \
+ break; \
+ case 2: \
+ (bezt)->f3 |= SELECT; \
+ break; \
+ default: \
+ break; \
+ } \
+ } \
+ ((void)0)
+
+#define BEZT_DESEL_IDX(bezt, i) \
+ { \
+ switch (i) { \
+ case 0: \
+ (bezt)->f1 &= ~SELECT; \
+ break; \
+ case 1: \
+ (bezt)->f2 &= ~SELECT; \
+ break; \
+ case 2: \
+ (bezt)->f3 &= ~SELECT; \
+ break; \
+ default: \
+ break; \
+ } \
+ } \
+ ((void)0)
#define BEZT_IS_AUTOH(bezt) \
(ELEM((bezt)->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM((bezt)->h2, HD_AUTO, HD_AUTO_ANIM))
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
index 44239221df4..fdb77bfd196 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
@@ -52,7 +52,7 @@
.layer_pass = 0, \
}
-/* Deliberately set this range to the half the default frame-range
+/* Deliberately set this range to the half the default frame-range
* to have an immediate effect to suggest use-cases. */
#define _DNA_DEFAULT_BuildGpencilModifierData \
{ \
@@ -138,7 +138,6 @@
.fading_center = 0.5f, \
.fading_thickness = 0.5f, \
.fading_opacity = 0.5f, \
- .split_angle = DEG2RADF(1.0f), \
}
#define _DNA_DEFAULT_NoiseGpencilModifierData \
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index 7e2ec8b6c65..f84265eea1d 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -57,7 +57,9 @@ typedef enum GpencilModifierMode {
eGpencilModifierMode_Realtime = (1 << 0),
eGpencilModifierMode_Render = (1 << 1),
eGpencilModifierMode_Editmode = (1 << 2),
+#ifdef DNA_DEPRECATED_ALLOW
eGpencilModifierMode_Expanded_DEPRECATED = (1 << 3),
+#endif
eGpencilModifierMode_Virtual = (1 << 4),
} GpencilModifierMode;
@@ -72,6 +74,7 @@ typedef struct GpencilModifierData {
int type, mode;
char _pad0[4];
short flag;
+ /* An "expand" bit for each of the modifier's (sub)panels (uiPanelDataExpansion). */
short ui_expand_flag;
/** MAX_NAME. */
char name[64];
@@ -682,7 +685,6 @@ typedef struct MultiplyGpencilModifierData {
int flag;
/** Custom index for passes. */
int layer_pass;
- char _pad[4];
int flags;
@@ -695,14 +697,10 @@ typedef struct MultiplyGpencilModifierData {
float fading_thickness;
float fading_opacity;
- /* in rad not deg */
- float split_angle;
-
- /* char _pad[4]; */
} MultiplyGpencilModifierData;
typedef enum eMultiplyGpencil_Flag {
- GP_MULTIPLY_ENABLE_ANGLE_SPLITTING = (1 << 1),
+ /* GP_MULTIPLY_ENABLE_ANGLE_SPLITTING = (1 << 1), Deprecated. */
GP_MULTIPLY_ENABLE_FADING = (1 << 2),
} eMultiplyGpencil_Flag;
@@ -778,6 +776,9 @@ typedef struct TextureGpencilModifierData {
/** Texture fit options. */
short fit_method;
short mode;
+ /** Dot texture rotation */
+ float alignment_rotation;
+ char _pad[4];
} TextureGpencilModifierData;
typedef enum eTextureGpencil_Flag {
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 222b716a502..94b75642fd6 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -29,6 +29,7 @@
struct AnimData;
struct MDeformVert;
+struct Curve;
#define GP_DEFAULT_PIX_FACTOR 1.0f
#define GP_DEFAULT_GRID_LINES 4
@@ -36,6 +37,10 @@ struct MDeformVert;
#define GP_MATERIAL_BUFFER_LEN 256
+#define GP_DEFAULT_CURVE_RESOLUTION 32
+#define GP_DEFAULT_CURVE_ERROR 0.1f
+#define GP_DEFAULT_CURVE_EDIT_CORNER_ANGLE M_PI_2
+
/* ***************************************** */
/* GP Stroke Points */
@@ -166,6 +171,61 @@ typedef enum eGPDpalette_Flag {
} eGPDpalette_Flag;
/* ***************************************** */
+/* GP Curve Point */
+
+typedef struct bGPDcurve_point {
+ /** Bezier Triple for the handles and control points. */
+ BezTriple bezt;
+ /** Pressure of input device (from 0 to 1) at this point. */
+ float pressure;
+ /** Color strength (used for alpha factor). */
+ float strength;
+ /** Index of corresponding point in gps->points. */
+ int point_index;
+
+ /** Additional options. */
+ int flag;
+
+ /** Factor of uv along the stroke. */
+ float uv_fac;
+ /** Uv rotation for dot mode. */
+ float uv_rot;
+ /** Uv for fill mode. */
+ float uv_fill[2];
+
+ /** Vertex Color RGBA (A=mix factor). */
+ float vert_color[4];
+ char _pad[4];
+} bGPDcurve_point;
+
+/* bGPDcurve_point->flag */
+typedef enum eGPDcurve_point_Flag {
+ GP_CURVE_POINT_SELECT = (1 << 0),
+} eGPDcurve_point_Flag;
+
+/* ***************************************** */
+/* GP Curve */
+
+/* Curve for Bezier Editing. */
+typedef struct bGPDcurve {
+ /** Array of BezTriple. */
+ bGPDcurve_point *curve_points;
+ /** Total number of curve points. */
+ int tot_curve_points;
+ /** General flag. */
+ short flag;
+ char _pad[2];
+} bGPDcurve;
+
+/* bGPDcurve_Flag->flag */
+typedef enum bGPDcurve_Flag {
+ /* Flag to indicated that the stroke data has been changed and the curve needs to be refitted */
+ GP_CURVE_NEEDS_STROKE_UPDATE = (1 << 0),
+ /* Curve is selected */
+ GP_CURVE_SELECT = (1 << 1),
+} bGPDcurve_Flag;
+
+/* ***************************************** */
/* GP Strokes */
/* Runtime temp data for bGPDstroke */
@@ -180,7 +240,8 @@ typedef struct bGPDstroke_Runtime {
int stroke_start;
/** Triangle offset in the ibo where this fill starts. */
int fill_start;
- int _pad[1];
+ /** Curve Handles offset in the ibo where this handle starts. */
+ int curve_start;
/** Original stroke (used to dereference evaluated data) */
struct bGPDstroke *gps_orig;
@@ -245,6 +306,9 @@ typedef struct bGPDstroke {
/** Vertex Color for Fill (one for all stroke, A=mix factor). */
float vert_color_fill[4];
+ /** Curve used to edit the stroke using Bezier handlers. */
+ struct bGPDcurve *editcurve;
+
bGPDstroke_Runtime runtime;
} bGPDstroke;
@@ -263,6 +327,9 @@ typedef enum eGPDstroke_Flag {
/* Flag used to indicate that stroke is used for fill close and must use
* fill color for stroke and no fill area */
GP_STROKE_NOFILL = (1 << 8),
+ /* Flag to indicated that the editcurve has been changed and the stroke needs to be updated with
+ * the curve data */
+ GP_STROKE_NEEDS_CURVE_UPDATE = (1 << 9),
/* only for use with stroke-buffer (while drawing arrows) */
GP_STROKE_USE_ARROW_START = (1 << 12),
/* only for use with stroke-buffer (while drawing arrows) */
@@ -562,7 +629,12 @@ typedef struct bGPdata {
ListBase layers;
/** Settings for this data-block. */
int flag;
- char _pad1[4];
+ /** Default resolution for generated curves using curve editing method. */
+ int curve_edit_resolution;
+ /** Curve Editing error threshold. */
+ float curve_edit_threshold;
+ /** Curve Editing corner angle (less or equal is treated as corner). */
+ float curve_edit_corner_angle;
/* Palettes */
/** List of bGPDpalette's - Deprecated (2.78 - 2.79 only). */
@@ -680,6 +752,11 @@ typedef enum eGPdata_Flag {
/* Autolock not active layers */
GP_DATA_AUTOLOCK_LAYERS = (1 << 20),
+
+ /* Enable Bezier Editing Curve (a submode of Edit mode). */
+ GP_DATA_CURVE_EDIT_MODE = (1 << 21),
+ /* Use adaptive curve resolution */
+ GP_DATA_CURVE_ADAPTIVE_RESOLUTION = (1 << 22),
} eGPdata_Flag;
/* gpd->onion_flag */
@@ -725,6 +802,9 @@ typedef enum eGP_DrawMode {
GP_DATA_STROKE_WEIGHTMODE | GP_DATA_STROKE_VERTEXMODE)) && \
((gpd)->flag & GP_DATA_STROKE_MULTIEDIT))
+#define GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd) \
+ ((gpd) && ((gpd)->flag & (GP_DATA_STROKE_EDITMODE)) && ((gpd)->flag & GP_DATA_CURVE_EDIT_MODE))
+
/* Macros to check grease pencil modes */
#define GPENCIL_ANY_MODE(gpd) \
((gpd) && ((gpd)->flag & \
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 355d3d6439b..1d31b876068 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -99,7 +99,8 @@ typedef struct MaterialGPencilStyle {
float mix_stroke_factor;
/** Mode used to align Dots and Boxes with stroke drawing path and object rotation */
int alignment_mode;
- char _pad[4];
+ /** Rotation for texture for Dots and Squares. */
+ float alignment_rotation;
} MaterialGPencilStyle;
/* MaterialGPencilStyle->flag */
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index e2837ba85f8..a822a6723fa 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -48,7 +48,6 @@ struct MPropCol;
struct MVert;
struct Material;
struct Mesh;
-struct Multires;
struct SubdivCCG;
#
@@ -230,9 +229,6 @@ typedef struct Mesh {
* default and Face Sets can be used without affecting the color of the mesh. */
int face_sets_color_default;
- /** Deprecated multiresolution modeling data, only keep for loading old files. */
- struct Multires *mr DNA_DEPRECATED;
-
Mesh_Runtime runtime;
} Mesh;
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index 45bf6e8c282..7cc94a2ad0b 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -518,54 +518,4 @@ typedef struct MRecast {
int i;
} MRecast;
-/** Multires structs kept for compatibility with old files. */
-typedef struct MultiresCol {
- float a, r, g, b;
-} MultiresCol;
-
-typedef struct MultiresColFace {
- /* vertex colors */
- MultiresCol col[4];
-} MultiresColFace;
-
-typedef struct MultiresFace {
- unsigned int v[4];
- unsigned int mid;
- char flag, mat_nr, _pad[2];
-} MultiresFace;
-
-typedef struct MultiresEdge {
- unsigned int v[2];
- unsigned int mid;
-} MultiresEdge;
-
-typedef struct MultiresLevel {
- struct MultiresLevel *next, *prev;
-
- MultiresFace *faces;
- MultiresColFace *colfaces;
- MultiresEdge *edges;
-
- unsigned int totvert, totface, totedge;
- char _pad[4];
-
- /* Kept for compatibility with even older files */
- MVert *verts;
-} MultiresLevel;
-
-typedef struct Multires {
- ListBase levels;
- MVert *verts;
-
- unsigned char level_count, current, newlvl, edgelvl, pinlvl, renderlvl;
- unsigned char use_col, flag;
-
- /* Special level 1 data that cannot be modified from other levels */
- CustomData vdata;
- CustomData fdata;
- short *edge_flags;
- char *edge_creases;
-} Multires;
-/* End multi-res structs. */
-
/** \} */
diff --git a/source/blender/makesdna/DNA_modifier_defaults.h b/source/blender/makesdna/DNA_modifier_defaults.h
index 34a951ca988..b5bcfa4d157 100644
--- a/source/blender/makesdna/DNA_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_modifier_defaults.h
@@ -438,7 +438,6 @@
.sculptlvl = 0, \
.renderlvl = 0, \
.totlvl = 0, \
- .simple = 0, \
.flags = eMultiresModifierFlag_UseCrease | eMultiresModifierFlag_ControlEdges, \
.uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS, \
.quality = 4, \
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 29bcc5fe903..232fca062fa 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -106,8 +106,10 @@ typedef enum ModifierMode {
eModifierMode_Render = (1 << 1),
eModifierMode_Editmode = (1 << 2),
eModifierMode_OnCage = (1 << 3),
- /* Old modifier box expansion, just for versioning. */
+#ifdef DNA_DEPRECATED_ALLOW
+ /** Old modifier box expansion, just for versioning. */
eModifierMode_Expanded_DEPRECATED = (1 << 4),
+#endif
eModifierMode_Virtual = (1 << 5),
eModifierMode_ApplyOnSpline = (1 << 6),
eModifierMode_DisableTemporary = (1u << 31),
@@ -119,7 +121,7 @@ typedef struct ModifierData {
int type, mode;
char _pad0[4];
short flag;
- /* An "expand" bit for each of the modifier's (sub)panels. */
+ /* An "expand" bit for each of the modifier's (sub)panels (uiPanelDataExpansion). */
short ui_expand_flag;
/** MAX_NAME. */
char name[64];
@@ -1047,7 +1049,8 @@ typedef struct MultiresModifierData {
ModifierData modifier;
char lvl, sculptlvl, renderlvl, totlvl;
- char simple, flags, _pad[2];
+ char simple DNA_DEPRECATED;
+ char flags, _pad[2];
short quality;
short uv_smooth;
short boundary_smooth;
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index cba93bbadfc..6f6c9029d07 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -923,6 +923,8 @@ typedef struct NodeTexMagic {
typedef struct NodeShaderAttribute {
char name[64];
+ int type;
+ char _pad[4];
} NodeShaderAttribute;
typedef struct NodeShaderVectTransform {
@@ -1092,6 +1094,13 @@ typedef struct NodeDenoise {
#define SHD_VECT_TRANSFORM_SPACE_OBJECT 1
#define SHD_VECT_TRANSFORM_SPACE_CAMERA 2
+/* attribute */
+enum {
+ SHD_ATTRIBUTE_GEOMETRY = 0,
+ SHD_ATTRIBUTE_OBJECT = 1,
+ SHD_ATTRIBUTE_INSTANCER = 2,
+};
+
/* toon modes */
#define SHD_TOON_DIFFUSE 0
#define SHD_TOON_GLOSSY 1
diff --git a/source/blender/makesdna/DNA_object_force_types.h b/source/blender/makesdna/DNA_object_force_types.h
index 3b0640544ae..3bd11d02b7a 100644
--- a/source/blender/makesdna/DNA_object_force_types.h
+++ b/source/blender/makesdna/DNA_object_force_types.h
@@ -54,7 +54,7 @@ typedef enum ePFieldType {
PFIELD_LENNARDJ = 9,
/** Defines predator / goal for boids. */
PFIELD_BOID = 10,
- /** Force defined by BLI_gTurbulence. */
+ /** Force defined by BLI_noise_generic_turbulence. */
PFIELD_TURBULENCE = 11,
/** Linear & quadratic drag. */
PFIELD_DRAG = 12,
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 112c8210460..345d1287ab1 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -508,7 +508,7 @@ enum {
/* (short) transflag */
enum {
- OB_TRANSFLAG_UNUSED_0 = 1 << 0, /* cleared */
+ OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK = 1 << 0,
OB_TRANSFLAG_UNUSED_1 = 1 << 1, /* cleared */
OB_NEG_SCALE = 1 << 2,
OB_TRANSFLAG_UNUSED_3 = 1 << 3, /* cleared */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index af499b0684b..f65f8d32e97 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -28,6 +28,10 @@
/* XXX, temp feature - campbell */
#define DURIAN_CAMERA_SWITCH
+/* check for cyclic set-scene,
+ * libs can cause this case which is normally prevented, see (T#####) */
+#define USE_SETSCENE_CHECK
+
#include "DNA_ID.h"
#include "DNA_collection_types.h"
#include "DNA_color_types.h" /* color management */
@@ -1086,7 +1090,7 @@ typedef struct GP_Sculpt_Settings {
int lock_axis;
/** Threshold for intersections */
float isect_threshold;
- char _pad_[4];
+ char _pad[4];
/** Multiframe edit falloff effect by frame. */
struct CurveMapping *cur_falloff;
/** Curve used for primitive tools. */
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index f0ff02d3668..e42ff2a6e58 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -37,8 +37,8 @@ struct PointerRNA;
struct Scene;
struct SpaceLink;
struct SpaceType;
-struct uiLayout;
struct uiBlock;
+struct uiLayout;
struct wmDrawBuffer;
struct wmTimer;
struct wmTooltipState;
@@ -170,9 +170,8 @@ typedef struct Panel {
/** Panel size excluding children. */
int blocksizex, blocksizey;
short labelofs;
- char _pad[4];
short flag, runtime_flag;
- short snap;
+ char _pad[6];
/** Panels are aligned according to increasing sort-order. */
int sortorder;
/** Runtime for panel manipulation. */
@@ -184,6 +183,34 @@ typedef struct Panel {
} Panel;
/**
+ * Used for passing expansion between instanced panel data and the panels themselves.
+ * There are 16 defines because the expansion data is typically stored in a short.
+ *
+ * \note Expansion for instanced panels is stored in depth first order. For example, the value of
+ * UI_SUBPANEL_DATA_EXPAND_2 correspond to mean the expansion of the second subpanel or the first
+ * subpanel's first subpanel.
+ */
+typedef enum uiPanelDataExpansion {
+ UI_PANEL_DATA_EXPAND_ROOT = (1 << 0),
+ UI_SUBPANEL_DATA_EXPAND_1 = (1 << 1),
+ UI_SUBPANEL_DATA_EXPAND_2 = (1 << 2),
+ UI_SUBPANEL_DATA_EXPAND_3 = (1 << 3),
+ UI_SUBPANEL_DATA_EXPAND_4 = (1 << 4),
+ UI_SUBPANEL_DATA_EXPAND_5 = (1 << 5),
+ UI_SUBPANEL_DATA_EXPAND_6 = (1 << 6),
+ UI_SUBPANEL_DATA_EXPAND_7 = (1 << 7),
+ UI_SUBPANEL_DATA_EXPAND_8 = (1 << 8),
+ UI_SUBPANEL_DATA_EXPAND_9 = (1 << 9),
+ UI_SUBPANEL_DATA_EXPAND_10 = (1 << 10),
+ UI_SUBPANEL_DATA_EXPAND_11 = (1 << 11),
+ UI_SUBPANEL_DATA_EXPAND_12 = (1 << 12),
+ UI_SUBPANEL_DATA_EXPAND_13 = (1 << 13),
+ UI_SUBPANEL_DATA_EXPAND_14 = (1 << 14),
+ UI_SUBPANEL_DATA_EXPAND_15 = (1 << 15),
+ UI_SUBPANEL_DATA_EXPAND_16 = (1 << 16),
+} uiPanelDataExpansion;
+
+/**
* Notes on Panel Categories:
*
* - #ARegion.panels_category (#PanelCategoryDyn)
@@ -294,10 +321,6 @@ typedef struct uiPreview {
char _pad1[6];
} uiPreview;
-/* These two lines with # tell makesdna this struct can be excluded.
- * Should be: #ifndef WITH_GLOBAL_AREA_WRITING */
-#
-#
typedef struct ScrGlobalAreaData {
/* Global areas have a non-dynamic size. That means, changing the window
* size doesn't affect their size at all. However, they can still be
@@ -548,28 +571,6 @@ enum {
PNL_INSTANCED_LIST_ORDER_CHANGED = (1 << 7),
};
-/** #Panel.snap - for snapping to screen edges */
-#define PNL_SNAP_NONE 0
-/* #define PNL_SNAP_TOP 1 */
-/* #define PNL_SNAP_RIGHT 2 */
-#define PNL_SNAP_BOTTOM 4
-/* #define PNL_SNAP_LEFT 8 */
-
-/* #define PNL_SNAP_DIST 9.0 */
-
-/* paneltype flag */
-enum {
- PNL_DEFAULT_CLOSED = (1 << 0),
- PNL_NO_HEADER = (1 << 1),
- /** Makes buttons in the header shrink/stretch to fill full layout width. */
- PNL_LAYOUT_HEADER_EXPAND = (1 << 2),
- PNL_LAYOUT_VERT_BAR = (1 << 3),
- /** This panel type represents data external to the UI. */
- PNL_INSTANCED = (1 << 4),
- /** Draw panel like a box widget. */
- PNL_DRAW_BOX = (1 << 6),
-};
-
/* Fallback panel category (only for old scripts which need updating) */
#define PNL_CATEGORY_FALLBACK "Misc"
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 1d89657faf6..e21f3e1e706 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -68,6 +68,9 @@ typedef struct StripCrop {
typedef struct StripTransform {
int xofs;
int yofs;
+ float scale_x;
+ float scale_y;
+ float rotation;
} StripTransform;
typedef struct StripColorBalance {
@@ -338,17 +341,19 @@ typedef struct TextVars {
VFont *text_font;
int text_blf_id;
int text_size;
- float color[4], shadow_color[4];
+ float color[4], shadow_color[4], box_color[4];
float loc[2];
float wrap_width;
+ float box_margin;
char flag;
char align, align_y;
- char _pad[1];
+ char _pad[5];
} TextVars;
/* TextVars.flag */
enum {
SEQ_TEXT_SHADOW = (1 << 0),
+ SEQ_TEXT_BOX = (1 << 1),
};
/* TextVars.align */
@@ -494,8 +499,8 @@ enum {
SEQ_MAKE_FLOAT = (1 << 13),
SEQ_LOCK = (1 << 14),
SEQ_USE_PROXY = (1 << 15),
- SEQ_USE_TRANSFORM = (1 << 16),
- SEQ_USE_CROP = (1 << 17),
+ SEQ_FLAG_UNUSED_23 = (1 << 16), /* cleared */
+ SEQ_FLAG_UNUSED_22 = (1 << 17), /* cleared */
SEQ_FLAG_UNUSED_18 = (1 << 18), /* cleared */
SEQ_FLAG_UNUSED_19 = (1 << 19), /* cleared */
SEQ_FLAG_UNUSED_21 = (1 << 21), /* cleared */
diff --git a/source/blender/makesdna/DNA_shader_fx_types.h b/source/blender/makesdna/DNA_shader_fx_types.h
index 5bb78edb280..07ccac5ba29 100644
--- a/source/blender/makesdna/DNA_shader_fx_types.h
+++ b/source/blender/makesdna/DNA_shader_fx_types.h
@@ -49,7 +49,9 @@ typedef enum ShaderFxMode {
eShaderFxMode_Realtime = (1 << 0),
eShaderFxMode_Render = (1 << 1),
eShaderFxMode_Editmode = (1 << 2),
+#ifdef DNA_DEPRECATED_ALLOW
eShaderFxMode_Expanded_DEPRECATED = (1 << 3),
+#endif
} ShaderFxMode;
typedef enum {
@@ -63,7 +65,7 @@ typedef struct ShaderFxData {
int type, mode;
char _pad0[4];
short flag;
- /* Expansion for shader effect panels and sub-panels. */
+ /* An "expand" bit for each of the constraint's (sub)panels (uiPanelDataExpansion). */
short ui_expand_flag;
/** MAX_NAME. */
char name[64];
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 7785c700e1c..a3aa79d29e8 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -59,10 +59,6 @@ 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
-
/* -------------------------------------------------------------------- */
/** \name SpaceLink (Base)
* \{ */
@@ -238,6 +234,9 @@ typedef enum eSpaceButtons_Flag {
/** \name Outliner
* \{ */
+/* Defined in `outliner_intern.h`. */
+typedef struct SpaceOutliner_Runtime SpaceOutliner_Runtime;
+
/* Outliner */
typedef struct SpaceOutliner {
SpaceLink *next, *prev;
@@ -280,6 +279,8 @@ typedef struct SpaceOutliner {
* Pointers to treestore elements, grouped by (id, type, nr)
* in hashtable for faster searching */
void *treehash;
+
+ SpaceOutliner_Runtime *runtime;
} SpaceOutliner;
/* SpaceOutliner.flag */
@@ -309,11 +310,11 @@ typedef enum eSpaceOutliner_Filter {
SO_FILTER_NO_OB_CAMERA = (1 << 10),
SO_FILTER_NO_OB_OTHERS = (1 << 11),
- SO_FILTER_UNUSED_12 = (1 << 12), /* cleared */
- SO_FILTER_OB_STATE_VISIBLE = (1 << 13), /* Not set via DNA. */
- SO_FILTER_OB_STATE_HIDDEN = (1 << 14), /* Not set via DNA. */
- SO_FILTER_OB_STATE_SELECTED = (1 << 15), /* Not set via DNA. */
- SO_FILTER_OB_STATE_ACTIVE = (1 << 16), /* Not set via DNA. */
+ SO_FILTER_OB_STATE_SELECTABLE = (1 << 12), /* Not set via DNA. */
+ SO_FILTER_OB_STATE_VISIBLE = (1 << 13), /* Not set via DNA. */
+ SO_FILTER_OB_STATE_HIDDEN = (1 << 14), /* Not set via DNA. */
+ SO_FILTER_OB_STATE_SELECTED = (1 << 15), /* Not set via DNA. */
+ SO_FILTER_OB_STATE_ACTIVE = (1 << 16), /* Not set via DNA. */
SO_FILTER_NO_COLLECTION = (1 << 17),
SO_FILTER_ID_TYPE = (1 << 18),
@@ -325,7 +326,7 @@ typedef enum eSpaceOutliner_Filter {
#define SO_FILTER_OB_STATE \
(SO_FILTER_OB_STATE_VISIBLE | SO_FILTER_OB_STATE_HIDDEN | SO_FILTER_OB_STATE_SELECTED | \
- SO_FILTER_OB_STATE_ACTIVE)
+ SO_FILTER_OB_STATE_ACTIVE | SO_FILTER_OB_STATE_SELECTABLE)
#define SO_FILTER_ANY \
(SO_FILTER_NO_OB_CONTENT | SO_FILTER_NO_CHILDREN | SO_FILTER_OB_TYPE | SO_FILTER_OB_STATE | \
@@ -338,6 +339,7 @@ typedef enum eSpaceOutliner_StateFilter {
SO_FILTER_OB_HIDDEN = 2,
SO_FILTER_OB_SELECTED = 3,
SO_FILTER_OB_ACTIVE = 4,
+ SO_FILTER_OB_SELECTABLE = 5,
} eSpaceOutliner_StateFilter;
/* SpaceOutliner.show_restrict_flags */
@@ -468,7 +470,7 @@ typedef enum eGraphEdit_Flag {
/* don't draw curves with AA ("beauty-draw") for performance */
SIPO_BEAUTYDRAW_OFF = (1 << 12),
/* draw grouped channels with colors set in group */
- SIPO_NODRAWGCOLORS = (1 << 13),
+ /* SIPO_NODRAWGCOLORS = (1 << 13), DEPRECATED */
/* normalize curves on display */
SIPO_NORMALIZE = (1 << 14),
SIPO_NORMALIZE_FREEZE = (1 << 15),
@@ -764,7 +766,13 @@ typedef struct SpaceFile {
/* FileSelectParams.display */
enum eFileDisplayType {
+ /** Internal (not exposed to users): Keep whatever display type was used during the last File
+ * Browser use, or the default if no such record is found. Use this unless there's a good reason
+ * to set a specific display type. */
FILE_DEFAULTDISPLAY = 0,
+
+ /* User selectable choices. */
+
FILE_VERTICALDISPLAY = 1,
FILE_HORIZONTALDISPLAY = 2,
FILE_IMGDISPLAY = 3,
@@ -772,7 +780,13 @@ enum eFileDisplayType {
/* FileSelectParams.sort */
enum eFileSortType {
- FILE_SORT_NONE = 0,
+ /** Internal (not exposed to users): Sort by whatever was sorted by during the last File Browser
+ * use, or the default if no such record is found. Use this unless there's a good reason to set a
+ * specific sort order. */
+ FILE_SORT_DEFAULT = 0,
+
+ /* User selectable choices. */
+
FILE_SORT_ALPHA = 1,
FILE_SORT_EXTENSION = 2,
FILE_SORT_TIME = 3,
@@ -1672,10 +1686,6 @@ typedef enum eSpaceClip_GPencil_Source {
/** \name Top Bar
* \{ */
-/* These two lines with # tell makesdna this struct can be excluded.
- * Should be: #ifndef WITH_GLOBAL_AREA_WRITING */
-#
-#
typedef struct SpaceTopBar {
SpaceLink *next, *prev;
/** Storage of regions for inactive spaces. */
@@ -1692,10 +1702,6 @@ typedef struct SpaceTopBar {
/** \name Status Bar
* \{ */
-/* These two lines with # tell makesdna this struct can be excluded.
- * Should be: #ifndef WITH_GLOBAL_AREA_WRITING */
-#
-#
typedef struct SpaceStatusBar {
SpaceLink *next, *prev;
/** Storage of regions for inactive spaces. */
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index d0105cda1ea..0bbeabf130f 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -288,8 +288,7 @@ typedef struct MovieTrackingSettings {
int reconstruction_flag;
/* which camera intrinsics to refine. uses on the REFINE_* flags */
- short refine_camera_intrinsics;
- char _pad2[2];
+ int refine_camera_intrinsics;
/* ** tool settings ** */
@@ -551,10 +550,12 @@ enum {
/* MovieTrackingSettings->refine_camera_intrinsics */
enum {
+ REFINE_NO_INTRINSICS = (0),
+
REFINE_FOCAL_LENGTH = (1 << 0),
REFINE_PRINCIPAL_POINT = (1 << 1),
- REFINE_RADIAL_DISTORTION_K1 = (1 << 2),
- REFINE_RADIAL_DISTORTION_K2 = (1 << 4),
+ REFINE_RADIAL_DISTORTION = (1 << 2),
+ REFINE_TANGENTIAL_DISTORTION = (1 << 3),
};
/* MovieTrackingStrabilization->flag */
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 4a02ac8f429..464eed4779f 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -589,6 +589,7 @@ typedef struct WalkNavigation {
} WalkNavigation;
typedef struct UserDef_Runtime {
+ /** Mark as changed so the preferences are saved on exit. */
char is_dirty;
char _pad0[7];
} UserDef_Runtime;
@@ -635,7 +636,8 @@ typedef struct UserDef_Experimental {
char use_sculpt_vertex_colors;
char use_switch_object_operator;
char use_sculpt_tools_tilt;
- char _pad[7];
+ char use_object_add_tool;
+ char _pad[6];
/** `makesdna` does not allow empty structs. */
} UserDef_Experimental;
@@ -825,13 +827,13 @@ typedef struct UserDef {
short autokey_mode;
/** Flags for autokeying. */
short autokey_flag;
+ /** Flags for animation. */
+ short animation_flag;
/** Options for text rendering. */
char text_render;
char navigation_mode;
- char _pad9[2];
-
/** Turn-table rotation amount per-pixel in radians. Scaled with DPI. */
float view_rotate_sensitivity_turntable;
/** Track-ball rotation scale. */
@@ -1045,7 +1047,7 @@ typedef enum eUserpref_UI_Flag {
USER_HIDE_DOT = (1 << 16),
USER_SHOW_GIZMO_NAVIGATE = (1 << 17),
USER_SHOW_VIEWPORTNAME = (1 << 18),
- USER_CAM_LOCK_NO_PARENT = (1 << 19),
+ USER_UIFLAG_UNUSED_3 = (1 << 19), /* Cleared. */
USER_ZOOM_TO_MOUSEPOS = (1 << 20),
USER_SHOW_FPS = (1 << 21),
USER_UIFLAG_UNUSED_22 = (1 << 22), /* cleared */
@@ -1072,7 +1074,7 @@ typedef enum eUserpref_UI_Flag {
typedef enum eUserpref_UI_Flag2 {
USER_UIFLAG2_UNUSED_0 = (1 << 0), /* cleared */
USER_REGION_OVERLAP = (1 << 1),
- USER_TRACKPAD_NATURAL = (1 << 2),
+ USER_UIFLAG2_UNUSED_2 = (1 << 2),
USER_UIFLAG2_UNUSED_3 = (1 << 3), /* dirty */
} eUserpref_UI_Flag2;
@@ -1146,6 +1148,15 @@ typedef enum eAutokey_Flag {
ANIMRECORD_FLAG_WITHNLA = (1 << 10),
} eAutokey_Flag;
+/**
+ * Animation flags
+ * #UserDef.animation_flag, used for animation flags that aren't covered by more specific flags
+ * (like eAutokey_Flag).
+ */
+typedef enum eUserpref_Anim_Flags {
+ USER_ANIM_SHOW_CHANNEL_GROUP_COLORS = (1 << 0),
+} eUserpref_Anim_Flags;
+
/** #UserDef.transopts */
typedef enum eUserpref_Translation_Flags {
USER_TR_TOOLTIPS = (1 << 0),
diff --git a/source/blender/makesdna/DNA_view3d_defaults.h b/source/blender/makesdna/DNA_view3d_defaults.h
index 68f23b33d07..10d0bafec61 100644
--- a/source/blender/makesdna/DNA_view3d_defaults.h
+++ b/source/blender/makesdna/DNA_view3d_defaults.h
@@ -51,6 +51,7 @@
#define _DNA_DEFAULT_View3DOverlay \
{ \
.wireframe_threshold = 1.0f, \
+ .wireframe_opacity = 1.0f, \
.xray_alpha_bone = 0.5f, \
.fade_alpha = 0.40f, \
.texture_paint_mode_opacity = 1.0f, \
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 3fc8b05c8b4..7e80fc1bd6d 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -223,6 +223,7 @@ typedef struct View3DOverlay {
/** Other settings. */
float wireframe_threshold;
+ float wireframe_opacity;
/** Grease pencil settings. */
float gpencil_paper_opacity;
@@ -233,7 +234,6 @@ typedef struct View3DOverlay {
float gpencil_vertex_paint_opacity;
/** Handles display type for curves. */
int handle_display;
- char _pad[4];
} View3DOverlay;
/* View3DOverlay->handle_display */
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index df1626157b0..3690a1126d4 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -1699,7 +1699,7 @@ bool DNA_sdna_patch_struct(SDNA *sdna, const char *struct_name_old, const char *
return false;
}
-/* Make public if called often with same struct (avoid duplicate look-ups). */
+/* Make public if called often with same struct (avoid duplicate lookups). */
static bool DNA_sdna_patch_struct_member_nr(SDNA *sdna,
const int struct_name_nr,
const char *elem_old,
diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h
index 7067caa60d9..2a4160bdfb1 100644
--- a/source/blender/makesdna/intern/dna_rename_defs.h
+++ b/source/blender/makesdna/intern/dna_rename_defs.h
@@ -126,3 +126,6 @@ DNA_STRUCT_RENAME_ELEM(bTheme, ttopbar, space_topbar)
DNA_STRUCT_RENAME_ELEM(bTheme, tuserpref, space_preferences)
DNA_STRUCT_RENAME_ELEM(bTheme, tv3d, space_view3d)
DNA_STRUCT_RENAME_ELEM(RigidBodyWorld, steps_per_second, substeps_per_frame)
+/* Write with a different name, old Blender versions crash loading files with non-NULL
+ * global_areas. See D9442. */
+DNA_STRUCT_RENAME_ELEM(wmWindow, global_area_map, global_areas)
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 44b6e4dd3a1..81a7da7b4d8 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -742,7 +742,7 @@ static int convert_include(const char *filename)
break;
}
- if (*md1 == ',' || *md1 == ' ') {
+ if (ELEM(*md1, ',', ' ')) {
*md1 = 0;
}
md1++;
@@ -1439,7 +1439,7 @@ int main(int argc, char **argv)
{
int return_status = 0;
- if (argc != 4 && argc != 5) {
+ if (!ELEM(argc, 4, 5)) {
printf("Usage: %s dna.c dna_struct_offsets.h [base directory]\n", argv[0]);
return_status = 1;
}
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 272246d75d3..c12426ffcd0 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -372,7 +372,9 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item
void RNA_def_property_enum_native_type(PropertyRNA *prop, const char *native_enum_type);
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength);
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type);
-void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type);
+void RNA_def_property_struct_runtime(StructOrFunctionRNA *cont,
+ PropertyRNA *prop,
+ StructRNA *type);
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value);
void RNA_def_property_boolean_array_default(PropertyRNA *prop, const bool *array);
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 831e8dc424d..a94466e30c2 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -61,6 +61,7 @@ extern const EnumPropertyItem rna_enum_space_type_items[];
extern const EnumPropertyItem rna_enum_space_image_mode_items[];
extern const EnumPropertyItem rna_enum_space_image_mode_all_items[];
extern const EnumPropertyItem rna_enum_space_action_mode_items[];
+extern const EnumPropertyItem rna_enum_fileselect_params_sort_items[];
extern const EnumPropertyItem rna_enum_region_type_items[];
extern const EnumPropertyItem rna_enum_object_modifier_type_items[];
extern const EnumPropertyItem rna_enum_constraint_type_items[];
@@ -190,8 +191,6 @@ extern const EnumPropertyItem rna_enum_shading_type_items[];
extern const EnumPropertyItem rna_enum_navigation_mode_items[];
-extern const EnumPropertyItem rna_enum_file_sort_items[];
-
extern const EnumPropertyItem rna_enum_node_socket_in_out_items[];
extern const EnumPropertyItem rna_enum_node_math_items[];
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index d8029ff16a0..d638d6f66cc 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -20,7 +20,7 @@
if(CMAKE_COMPILER_IS_GNUCC)
# add here so we fail early.
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
+ string(APPEND CMAKE_C_FLAGS " -Werror=implicit-function-declaration")
endif()
# files rna_access.c rna_define.c makesrna.c intentionally excluded.
@@ -151,7 +151,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
set(GENSRC_CFLAGS "-Wno-missing-prototypes")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
- set(GENSRC_CFLAGS "${GENSRC_CFLAGS} -Wno-missing-variable-declarations")
+ string(APPEND GENSRC_CFLAGS " -Wno-missing-variable-declarations")
endif()
if(GENSRC_CFLAGS)
@@ -378,7 +378,7 @@ blender_include_dirs(
../../simulation
../../windowmanager
../../editors/include
- ../../render/extern/include
+ ../../render
../../../../intern/cycles/blender
../../../../intern/atomic
../../../../intern/glew-mx
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index e193aa78353..8b861d20e4e 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -29,6 +29,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_string.h"
#include "BLI_system.h" /* for 'BLI_system_backtrace' stub. */
#include "BLI_utildefines.h"
@@ -255,10 +256,10 @@ static const char *rna_safe_id(const char *id)
if (STREQ(id, "operator")) {
return "operator_value";
}
- else if (STREQ(id, "new")) {
+ if (STREQ(id, "new")) {
return "create";
}
- else if (STREQ(id, "co_return")) {
+ if (STREQ(id, "co_return")) {
/* MSVC2015, C++ uses for coroutines */
return "coord_return";
}
@@ -577,8 +578,7 @@ static int rna_enum_bitmask(PropertyRNA *prop)
static int rna_color_quantize(PropertyRNA *prop, PropertyDefRNA *dp)
{
- return ((prop->type == PROP_FLOAT) &&
- (prop->subtype == PROP_COLOR || prop->subtype == PROP_COLOR_GAMMA) &&
+ return ((prop->type == PROP_FLOAT) && (ELEM(prop->subtype, PROP_COLOR, PROP_COLOR_GAMMA)) &&
(IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0));
}
@@ -671,7 +671,7 @@ static char *rna_def_property_get_func(
return NULL;
}
}
- else if (prop->type == PROP_INT || prop->type == PROP_ENUM) {
+ else if (ELEM(prop->type, PROP_INT, PROP_ENUM)) {
if (IS_DNATYPE_INT_COMPAT(dp->dnatype) == 0) {
CLOG_ERROR(&LOG,
"%s.%s is a '%s' but wrapped as type '%s'.",
@@ -761,9 +761,10 @@ static char *rna_def_property_get_func(
fprintf(f, "static PointerRNA %s(CollectionPropertyIterator *iter)\n", func);
fprintf(f, "{\n");
if (manualfunc) {
- if (STREQ(manualfunc, "rna_iterator_listbase_get") ||
- STREQ(manualfunc, "rna_iterator_array_get") ||
- STREQ(manualfunc, "rna_iterator_array_dereference_get")) {
+ if (STR_ELEM(manualfunc,
+ "rna_iterator_listbase_get",
+ "rna_iterator_array_get",
+ "rna_iterator_array_dereference_get")) {
fprintf(f,
" return rna_pointer_inherit_refine(&iter->parent, &RNA_%s, %s(iter));\n",
(cprop->item_type) ? (const char *)cprop->item_type : "UnknownType",
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index f2c8b1d9e73..452c6754d10 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -1310,7 +1310,7 @@ static void rna_def_ID_override_library_property_operation(BlenderRNA *brna)
"MANDATORY",
0,
"Mandatory",
- "For templates, prevents the user from removing pre-defined operation (NOT USED)"},
+ "For templates, prevents the user from removing predefined operation (NOT USED)"},
{IDOVERRIDE_LIBRARY_FLAG_LOCKED,
"LOCKED",
0,
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index a631fe4fc26..70fafaf8111 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -425,9 +425,7 @@ static int rna_ensure_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
if (idprop->type == IDP_ARRAY) {
return idprop->len;
}
- else {
- return 0;
- }
+ return 0;
}
static bool rna_ensure_property_array_check(PropertyRNA *prop)
@@ -1268,7 +1266,7 @@ char RNA_property_array_item_char(PropertyRNA *prop, int index)
PROP_COORDS)) {
return vectoritem[index];
}
- else if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) {
+ if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) {
return coloritem[index];
}
@@ -1533,9 +1531,7 @@ int RNA_property_float_clamp(PointerRNA *ptr, PropertyRNA *prop, float *value)
*value = max;
return 1;
}
- else {
- return 0;
- }
+ return 0;
}
int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value)
@@ -1552,9 +1548,7 @@ int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value)
*value = max;
return 1;
}
- else {
- return 0;
- }
+ return 0;
}
/* this is the max length including \0 terminator.
@@ -1668,7 +1662,7 @@ void RNA_property_enum_items(bContext *C,
#ifdef WITH_INTERNATIONAL
static void property_enum_translate(PropertyRNA *prop,
EnumPropertyItem **r_item,
- int *r_totitem,
+ const int *totitem,
bool *r_free)
{
if (!(prop->flag & PROP_ENUM_NO_TRANSLATE)) {
@@ -1690,8 +1684,8 @@ static void property_enum_translate(PropertyRNA *prop,
const EnumPropertyItem *item = *r_item;
int tot;
- if (r_totitem) {
- tot = *r_totitem;
+ if (totitem) {
+ tot = *totitem;
}
else {
/* count */
@@ -2614,12 +2608,10 @@ int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
if (iprop->get) {
return iprop->get(ptr);
}
- else if (iprop->get_ex) {
+ if (iprop->get_ex) {
return iprop->get_ex(ptr, prop);
}
- else {
- return iprop->defaultvalue;
- }
+ return iprop->defaultvalue;
}
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
@@ -2950,15 +2942,13 @@ float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
}
return (float)IDP_Double(idprop);
}
- else if (fprop->get) {
+ if (fprop->get) {
return fprop->get(ptr);
}
- else if (fprop->get_ex) {
+ if (fprop->get_ex) {
return fprop->get_ex(ptr, prop);
}
- else {
- return fprop->defaultvalue;
- }
+ return fprop->defaultvalue;
}
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
@@ -3389,15 +3379,13 @@ int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop)
#endif
return idprop->len - 1;
}
- else if (sprop->length) {
+ if (sprop->length) {
return sprop->length(ptr);
}
- else if (sprop->length_ex) {
+ if (sprop->length_ex) {
return sprop->length_ex(ptr, prop);
}
- else {
- return strlen(sprop->defaultvalue);
- }
+ return strlen(sprop->defaultvalue);
}
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
@@ -3555,12 +3543,10 @@ int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
if (eprop->get) {
return eprop->get(ptr);
}
- else if (eprop->get_ex) {
+ if (eprop->get_ex) {
return eprop->get_ex(ptr, prop);
}
- else {
- return eprop->defaultvalue;
- }
+ return eprop->defaultvalue;
}
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
@@ -3671,18 +3657,16 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
}
return rna_pointer_inherit_refine(ptr, pprop->type, idprop);
}
- else if (pprop->get) {
+ if (pprop->get) {
return pprop->get(ptr);
}
- else if (prop->flag & PROP_IDPROPERTY) {
+ if (prop->flag & PROP_IDPROPERTY) {
/* XXX temporary hack to add it automatically, reading should
* never do any write ops, to ensure thread safety etc .. */
RNA_property_pointer_add(ptr, prop);
return RNA_property_pointer_get(ptr, prop);
}
- else {
- return PointerRNA_NULL;
- }
+ return PointerRNA_NULL;
}
void RNA_property_pointer_set(PointerRNA *ptr,
@@ -3924,18 +3908,16 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
if (cprop->length) {
return cprop->length(ptr);
}
- else {
- CollectionPropertyIterator iter;
- int length = 0;
-
- RNA_property_collection_begin(ptr, prop, &iter);
- for (; iter.valid; RNA_property_collection_next(&iter)) {
- length++;
- }
- RNA_property_collection_end(&iter);
+ CollectionPropertyIterator iter;
+ int length = 0;
- return length;
+ RNA_property_collection_begin(ptr, prop, &iter);
+ for (; iter.valid; RNA_property_collection_next(&iter)) {
+ length++;
}
+ RNA_property_collection_end(&iter);
+
+ return length;
}
/* This helper checks whether given collection property itself is editable (we only currently
@@ -5775,21 +5757,19 @@ static char *rna_idp_path(PointerRNA *ptr,
path = rna_idp_path_create(&link);
break;
}
- else {
- int j;
- link.name = iter->name;
- for (j = 0; j < iter->len; j++, array++) {
- PointerRNA child_ptr;
- if (RNA_property_collection_lookup_int(ptr, prop, j, &child_ptr)) {
- link.index = j;
- if ((path = rna_idp_path(&child_ptr, array, needle, &link))) {
- break;
- }
+ int j;
+ link.name = iter->name;
+ for (j = 0; j < iter->len; j++, array++) {
+ PointerRNA child_ptr;
+ if (RNA_property_collection_lookup_int(ptr, prop, j, &child_ptr)) {
+ link.index = j;
+ if ((path = rna_idp_path(&child_ptr, array, needle, &link))) {
+ break;
}
}
- if (path) {
- break;
- }
+ }
+ if (path) {
+ break;
}
}
}
@@ -6788,9 +6768,7 @@ static char *rna_pointer_as_string__bldata(Main *bmain, PointerRNA *ptr)
if (RNA_struct_is_ID(ptr->type)) {
return RNA_path_full_ID_py(bmain, ptr->owner_id);
}
- else {
- return RNA_path_full_struct_py(bmain, ptr);
- }
+ return RNA_path_full_struct_py(bmain, ptr);
}
char *RNA_pointer_as_string(bContext *C,
@@ -6805,9 +6783,7 @@ char *RNA_pointer_as_string(bContext *C,
if ((prop = rna_idproperty_check(&prop_ptr, ptr)) && prop->type != IDP_ID) {
return RNA_pointer_as_string_id(C, ptr_prop);
}
- else {
- return rna_pointer_as_string__bldata(CTX_data_main(C), ptr_prop);
- }
+ return rna_pointer_as_string__bldata(CTX_data_main(C), ptr_prop);
}
/* context can be NULL */
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index 562738efdaa..4bbbf5f01da 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -26,6 +26,7 @@
#include "DNA_constraint_types.h"
#include "DNA_key_types.h"
#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
@@ -37,6 +38,7 @@
# include "PIL_time_utildefines.h"
#endif
+#include "BKE_armature.h"
#include "BKE_idprop.h"
#include "BKE_lib_override.h"
#include "BKE_main.h"
@@ -209,7 +211,7 @@ bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACo
if (ptr_a == NULL || ptr_b == NULL) {
return false;
}
- else if (ptr_a->type != ptr_b->type) {
+ if (ptr_a->type != ptr_b->type) {
return false;
}
@@ -593,6 +595,27 @@ bool RNA_struct_override_matches(Main *bmain,
}
#endif
+ if (ptr_local->owner_id == ptr_local->data && GS(ptr_local->owner_id->name) == ID_OB) {
+ /* Our beloved pose's bone cross-data pointers. Usually, depsgraph evaluation would
+ * ensure this is valid, but in some situations (like hidden collections etc.) this won't
+ * be the case, so we need to take care of this ourselves.
+ *
+ * Note: Typically callers of this function (from BKE_lib_override area) will already have
+ * ensured this. However, studio is still reporting sporadic, unreproducible crashes due to
+ * invalid pose data, so think there are still some cases where some armatures are somehow
+ * missing updates (possibly due to dependencies?). Since calling this function on same ID
+ * several time is almost free, and safe even in a threaded context as long as it has been done
+ * at least once first outside of threaded processing, we do it another time here. */
+ Object *ob_local = (Object *)ptr_local->owner_id;
+ if (ob_local->type == OB_ARMATURE) {
+ Object *ob_reference = (Object *)ptr_local->owner_id->override_library->reference;
+ BLI_assert(ob_local->data != NULL);
+ BLI_assert(ob_reference->data != NULL);
+ BKE_pose_ensure(bmain, ob_local, ob_local->data, true);
+ BKE_pose_ensure(bmain, ob_reference, ob_reference->data, true);
+ }
+ }
+
iterprop = RNA_struct_iterator_property(ptr_local->type);
for (RNA_property_collection_begin(ptr_local, iterprop, &iter); iter.valid;
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index 89687c1234c..576431b7fd1 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -450,7 +450,7 @@ static void rna_def_dopesheet(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_shapekeys", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSHAPEKEYS);
RNA_def_property_ui_text(
- prop, "Display Shapekeys", "Include visualization of shape key related animation data");
+ prop, "Display Shape Keys", "Include visualization of shape key related animation data");
RNA_def_property_ui_icon(prop, ICON_SHAPEKEY_DATA, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index cc0c11fb089..d586f222203 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -1336,7 +1336,7 @@ static void rna_def_edit_bone(BlenderRNA *brna)
RNA_def_property_ui_text(
prop,
"Editbone Matrix",
- "Matrix combining loc/rot of the bone (head position, direction and roll), "
+ "Matrix combining location and rotation of the bone (head position, direction and roll), "
"in armature space (does not include/support bone's length/size)");
RNA_def_property_float_funcs(prop, "rna_EditBone_matrix_get", "rna_EditBone_matrix_set", NULL);
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index d119be66916..736edc61d74 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -79,6 +79,27 @@ static const EnumPropertyItem sculpt_stroke_method_items[] = {
{0, NULL, 0, NULL, NULL},
};
+static const EnumPropertyItem rna_enum_brush_texture_slot_map_all_mode_items[] = {
+ {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""},
+ {MTEX_MAP_MODE_AREA, "AREA_PLANE", 0, "Area Plane", ""},
+ {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
+ {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""},
+ {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""},
+ {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""},
+ {0, NULL, 0, NULL, NULL},
+};
+
+#ifdef RNA_RUNTIME
+static const EnumPropertyItem rna_enum_brush_texture_slot_map_texture_mode_items[] = {
+ {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""},
+ {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
+ {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""},
+ {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""},
+ {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""},
+ {0, NULL, 0, NULL, NULL},
+};
+#endif
+
/* clang-format off */
const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = {
{SCULPT_TOOL_DRAW, "DRAW", ICON_BRUSH_SCULPT_DRAW, "Draw", ""},
@@ -1015,6 +1036,28 @@ static void rna_GPencilBrush_pin_mode_update(bContext *C, PointerRNA *ptr)
}
}
+static const EnumPropertyItem *rna_BrushTextureSlot_map_mode_itemf(bContext *C,
+ PointerRNA *UNUSED(ptr),
+ PropertyRNA *UNUSED(prop),
+ bool *UNUSED(r_free))
+{
+
+ if (C == NULL) {
+ return rna_enum_brush_texture_slot_map_all_mode_items;
+ }
+
+# define rna_enum_brush_texture_slot_map_sculpt_mode_items \
+ rna_enum_brush_texture_slot_map_all_mode_items;
+
+ const ePaintMode mode = BKE_paintmode_get_active_from_context(C);
+ if (mode == PAINT_MODE_SCULPT) {
+ return rna_enum_brush_texture_slot_map_sculpt_mode_items;
+ }
+ return rna_enum_brush_texture_slot_map_texture_mode_items;
+
+# undef rna_enum_brush_texture_slot_map_sculpt_mode_items
+}
+
#else
static void rna_def_brush_texture_slot(BlenderRNA *brna)
@@ -1022,25 +1065,6 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static const EnumPropertyItem prop_map_mode_items[] = {
- {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""},
- {MTEX_MAP_MODE_AREA, "AREA_PLANE", 0, "Area Plane", ""},
- {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
- {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""},
- {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""},
- {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
- static const EnumPropertyItem prop_tex_paint_map_mode_items[] = {
- {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""},
- {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
- {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""},
- {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""},
- {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
static const EnumPropertyItem prop_mask_paint_map_mode_items[] = {
{MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""},
{MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
@@ -1069,14 +1093,8 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna)
prop = RNA_def_property(srna, "map_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
- RNA_def_property_enum_items(prop, prop_map_mode_items);
- RNA_def_property_ui_text(prop, "Mode", "");
- RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
- RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
-
- prop = RNA_def_property(srna, "tex_paint_map_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
- RNA_def_property_enum_items(prop, prop_tex_paint_map_mode_items);
+ RNA_def_property_enum_items(prop, rna_enum_brush_texture_slot_map_all_mode_items);
+ RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_BrushTextureSlot_map_mode_itemf");
RNA_def_property_ui_text(prop, "Mode", "");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
@@ -2968,6 +2986,12 @@ static void rna_def_brush(BlenderRNA *brna)
"Apply the maximum grab strength to the active vertex instead of the cursor location");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "use_grab_silhouette", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", BRUSH_GRAB_SILHOUETTE);
+ RNA_def_property_ui_text(
+ prop, "Grab Silhouette", "Grabs trying to automask the silhouette of the object");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "use_paint_antialiasing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "sampling_flag", BRUSH_PAINT_ANTIALIASING);
RNA_def_property_ui_text(prop, "Anti-Aliasing", "Smooths the edges of the strokes");
diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c
index 31a71a80bbc..1810cee5cee 100644
--- a/source/blender/makesrna/intern/rna_camera.c
+++ b/source/blender/makesrna/intern/rna_camera.c
@@ -36,11 +36,12 @@
# include "BKE_camera.h"
# include "BKE_object.h"
-# include "BKE_sequencer.h"
# include "DEG_depsgraph.h"
# include "DEG_depsgraph_build.h"
+# include "SEQ_sequencer.h"
+
static float rna_Camera_angle_get(PointerRNA *ptr)
{
Camera *cam = (Camera *)ptr->owner_id;
@@ -383,7 +384,7 @@ static void rna_def_camera_stereo_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "convergence_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_range(prop, 0.00001f, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.00001f, 15.f, 1, 3);
+ RNA_def_property_ui_range(prop, 0.00001f, 15.0f, 1, 3);
RNA_def_property_ui_text(prop,
"Convergence Plane Distance",
"The converge point for the stereo cameras "
@@ -583,7 +584,7 @@ void RNA_def_camera(BlenderRNA *brna)
prop = RNA_def_property(srna, "sensor_width", PROP_FLOAT, PROP_DISTANCE_CAMERA);
RNA_def_property_float_sdna(prop, NULL, "sensor_x");
RNA_def_property_range(prop, 1.0f, FLT_MAX);
- RNA_def_property_ui_range(prop, 1.0f, 100.f, 100, 4);
+ RNA_def_property_ui_range(prop, 1.0f, 100.0f, 100, 4);
RNA_def_property_ui_text(
prop, "Sensor Width", "Horizontal size of the image sensor area in millimeters");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
@@ -591,7 +592,7 @@ void RNA_def_camera(BlenderRNA *brna)
prop = RNA_def_property(srna, "sensor_height", PROP_FLOAT, PROP_DISTANCE_CAMERA);
RNA_def_property_float_sdna(prop, NULL, "sensor_y");
RNA_def_property_range(prop, 1.0f, FLT_MAX);
- RNA_def_property_ui_range(prop, 1.0f, 100.f, 100, 4);
+ RNA_def_property_ui_range(prop, 1.0f, 100.0f, 100, 4);
RNA_def_property_ui_text(
prop, "Sensor Height", "Vertical size of the image sensor area in millimeters");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c
index da364eda6ba..20a455f5312 100644
--- a/source/blender/makesrna/intern/rna_collection.c
+++ b/source/blender/makesrna/intern/rna_collection.c
@@ -275,7 +275,7 @@ static bool rna_Collection_children_override_apply(Main *bmain,
Collection *coll_dst = (Collection *)ptr_dst->owner_id;
if (ptr_item_dst->type == NULL || ptr_item_src->type == NULL) {
- BLI_assert(0 && "invalid source or destination sub-collection.");
+ /* This can happen when reference and overrides differ, just ignore then. */
return false;
}
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index b4f053a0d2b..ac47f434c3b 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -52,7 +52,6 @@
# include "BKE_linestyle.h"
# include "BKE_movieclip.h"
# include "BKE_node.h"
-# include "BKE_sequencer.h"
# include "DEG_depsgraph.h"
@@ -61,6 +60,8 @@
# include "IMB_colormanagement.h"
# include "IMB_imbuf.h"
+# include "SEQ_sequencer.h"
+
static int rna_CurveMapping_curves_length(PointerRNA *ptr)
{
CurveMapping *cumap = (CurveMapping *)ptr->data;
@@ -796,7 +797,7 @@ static void rna_def_curvemapping(BlenderRNA *brna)
static const EnumPropertyItem tone_items[] = {
{CURVE_TONE_STANDARD, "STANDARD", 0, "Standard", ""},
- {CURVE_TONE_FILMLIKE, "FILMLIKE", 0, "Film like", ""},
+ {CURVE_TONE_FILMLIKE, "FILMLIKE", 0, "Filmlike", ""},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index 76b419926a1..774187d18b7 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -673,8 +673,8 @@ static void rna_ActionConstraint_minmax_range(
*max = 180.0f;
}
else {
- *min = -1000.f;
- *max = 1000.f;
+ *min = -1000.0f;
+ *max = 1000.0f;
}
}
@@ -1183,13 +1183,13 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.01, 1.f);
+ RNA_def_property_range(prop, 0.01, 1.0f);
RNA_def_property_ui_text(
prop, "Weight", "For Tree-IK: Weight of position control for this target");
prop = RNA_def_property(srna, "orient_weight", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "orientweight");
- RNA_def_property_range(prop, 0.01, 1.f);
+ RNA_def_property_range(prop, 0.01, 1.0f);
RNA_def_property_ui_text(
prop, "Orientation Weight", "For Tree-IK: Weight of orientation control for this target");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
@@ -1274,7 +1274,7 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna)
prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "dist");
- RNA_def_property_range(prop, 0.0, 100.f);
+ RNA_def_property_range(prop, 0.0, 100.0f);
RNA_def_property_ui_text(prop, "Distance", "Radius of limiting sphere");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
@@ -1790,21 +1790,21 @@ static void rna_def_constraint_action(BlenderRNA *brna)
prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "max");
- RNA_def_property_range(prop, -1000.f, 1000.f);
+ RNA_def_property_range(prop, -1000.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Maximum", "Maximum value for target channel range");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_ActionConstraint_minmax_range");
prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "min");
- RNA_def_property_range(prop, -1000.f, 1000.f);
+ RNA_def_property_range(prop, -1000.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Minimum", "Minimum value for target channel range");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_ActionConstraint_minmax_range");
prop = RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "eval_time");
- RNA_def_property_range(prop, 0.f, 1.f);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(
prop, "Evaluation Time", "Interpolates between Action Start and End frames");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
@@ -2003,7 +2003,7 @@ static void rna_def_constraint_stretch_to(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "bulge", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.0, 100.f);
+ RNA_def_property_range(prop, 0.0, 100.0f);
RNA_def_property_ui_text(
prop, "Volume Variation", "Factor between volume variation and stretching");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
@@ -2546,37 +2546,37 @@ static void rna_def_constraint_rotation_limit(BlenderRNA *brna)
prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "xmin");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "ymin");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "min_z", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "zmin");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "xmax");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "ymax");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "max_z", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "zmax");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
@@ -2634,37 +2634,37 @@ static void rna_def_constraint_size_limit(BlenderRNA *brna)
prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "xmin");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ymin");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "min_z", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "zmin");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "xmax");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ymax");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "max_z", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "zmax");
- RNA_def_property_range(prop, -1000.0, 1000.f);
+ RNA_def_property_range(prop, -1000.0, 1000.0f);
RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
@@ -3017,7 +3017,7 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
/* volume presevation for "volumetric" scale mode */
prop = RNA_def_property(srna, "bulge", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.0, 100.f);
+ RNA_def_property_range(prop, 0.0, 100.0f);
RNA_def_property_ui_text(
prop, "Volume Variation", "Factor between volume variation and stretching");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
@@ -3453,7 +3453,7 @@ void RNA_def_constraint(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(
prop,
- "Rot error",
+ "Rotation error",
"Amount of residual error in radians for constraints that work on orientation");
RNA_define_lib_overridable(false);
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 2d6bf2897e0..2e73fabe103 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -543,11 +543,9 @@ static void rna_Curve_resolution_u_update_data(Main *bmain, Scene *scene, Pointe
{
Curve *cu = (Curve *)ptr->owner_id;
ListBase *nurbs = BKE_curve_nurbs_get(cu);
- Nurb *nu = nurbs->first;
- while (nu) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
nu->resolu = cu->resolu;
- nu = nu->next;
}
rna_Curve_update_data(bmain, scene, ptr);
@@ -557,11 +555,9 @@ static void rna_Curve_resolution_v_update_data(Main *bmain, Scene *scene, Pointe
{
Curve *cu = (Curve *)ptr->owner_id;
ListBase *nurbs = BKE_curve_nurbs_get(cu);
- Nurb *nu = nurbs->first;
- while (nu) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
nu->resolv = cu->resolv;
- nu = nu->next;
}
rna_Curve_update_data(bmain, scene, ptr);
diff --git a/source/blender/makesrna/intern/rna_curveprofile.c b/source/blender/makesrna/intern/rna_curveprofile.c
index ee1c659fcd5..25f0c5fb9b4 100644
--- a/source/blender/makesrna/intern/rna_curveprofile.c
+++ b/source/blender/makesrna/intern/rna_curveprofile.c
@@ -53,7 +53,6 @@
# include "BKE_linestyle.h"
# include "BKE_movieclip.h"
# include "BKE_node.h"
-# include "BKE_sequencer.h"
# include "DEG_depsgraph.h"
@@ -62,6 +61,8 @@
# include "IMB_colormanagement.h"
# include "IMB_imbuf.h"
+# include "SEQ_sequencer.h"
+
/**
* Set both handle types for all selected points in the profile-- faster than changing types
* for many points individually. Also set both handles for the points.
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 8eb964b8c17..8cc4f545ca9 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -513,7 +513,7 @@ static int rna_find_sdna_member(SDNA *sdna,
return 1;
}
- else if (cmp == 3) {
+ if (cmp == 3) {
smember->type = "";
smember->name = dnaname;
smember->offset = *offset;
@@ -1303,7 +1303,7 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_,
rna_addtail(&dcont->properties, dprop);
}
else {
-#ifdef DEBUG
+#ifndef NDEBUG
char error[512];
if (rna_validate_identifier(identifier, error, true) == 0) {
CLOG_ERROR(&LOG,
@@ -1407,7 +1407,7 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_,
/* a priori not raw editable */
prop->rawtype = -1;
- if (type != PROP_COLLECTION && type != PROP_POINTER) {
+ if (!ELEM(type, PROP_COLLECTION, PROP_POINTER)) {
prop->flag = PROP_EDITABLE;
if (type != PROP_STRING) {
@@ -1812,8 +1812,9 @@ void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
}
}
-void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type)
+void RNA_def_property_struct_runtime(StructOrFunctionRNA *cont, PropertyRNA *prop, StructRNA *type)
{
+ /* Never valid when defined from python. */
StructRNA *srna = DefRNA.laststruct;
if (DefRNA.preprocess) {
@@ -1821,11 +1822,26 @@ void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type)
return;
}
+ const bool is_id_type = (type->flag & STRUCT_ID) != 0;
+
switch (prop->type) {
case PROP_POINTER: {
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
pprop->type = type;
+ /* Check between `cont` and `srna` is mandatory, since when defined from python
+ * `DefRNA.laststruct` is not valid.
+ * This is not an issue as bpy code already checks for this case on its own. */
+ if (cont == srna && (srna->flag & STRUCT_NO_DATABLOCK_IDPROPERTIES) != 0 && is_id_type) {
+ CLOG_ERROR(&LOG,
+ "\"%s.%s\", this struct type (probably an Operator, Keymap or UserPreference) "
+ "does not accept ID pointer properties.",
+ CONTAINER_RNA_ID(cont),
+ prop->identifier);
+ DefRNA.error = true;
+ return;
+ }
+
if (type && (type->flag & STRUCT_ID_REFCOUNT)) {
prop->flag |= PROP_ID_REFCOUNT;
}
@@ -1838,10 +1854,16 @@ void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type)
break;
}
default:
- CLOG_ERROR(
- &LOG, "\"%s.%s\", invalid type for struct type.", srna->identifier, prop->identifier);
+ CLOG_ERROR(&LOG,
+ "\"%s.%s\", invalid type for struct type.",
+ CONTAINER_RNA_ID(cont),
+ prop->identifier);
DefRNA.error = true;
- break;
+ return;
+ }
+
+ if (is_id_type) {
+ prop->flag |= PROP_PTR_NO_OWNERSHIP;
}
}
@@ -2195,15 +2217,13 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop,
dp->dnaoffset = smember.offset;
return dp;
}
- else {
- CLOG_ERROR(&LOG,
- "\"%s.%s\" (identifier \"%s\") not found. Struct must be in DNA.",
- structname,
- propname,
- prop->identifier);
- DefRNA.error = true;
- return NULL;
- }
+ CLOG_ERROR(&LOG,
+ "\"%s.%s\" (identifier \"%s\") not found. Struct must be in DNA.",
+ structname,
+ propname,
+ prop->identifier);
+ DefRNA.error = true;
+ return NULL;
}
if (smember.arraylength > 1) {
@@ -4142,7 +4162,7 @@ PropertyRNA *RNA_def_pointer_runtime(StructOrFunctionRNA *cont_,
PropertyRNA *prop;
prop = RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_runtime(prop, type);
+ RNA_def_property_struct_runtime(cont, prop, type);
if ((type->flag & STRUCT_ID) != 0) {
prop->flag |= PROP_EDITABLE;
}
@@ -4177,7 +4197,7 @@ PropertyRNA *RNA_def_collection_runtime(StructOrFunctionRNA *cont_,
PropertyRNA *prop;
prop = RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE);
- RNA_def_property_struct_runtime(prop, type);
+ RNA_def_property_struct_runtime(cont, prop, type);
RNA_def_property_ui_text(prop, ui_name, ui_description);
return prop;
@@ -4359,9 +4379,8 @@ int rna_parameter_size(PropertyRNA *parm)
}
return sizeof(PointerRNA *);
}
- else {
- return sizeof(void *);
- }
+ return sizeof(void *);
+
#endif
}
case PROP_COLLECTION:
diff --git a/source/blender/makesrna/intern/rna_fcurve_api.c b/source/blender/makesrna/intern/rna_fcurve_api.c
index f7be65b4e75..5a720b91f87 100644
--- a/source/blender/makesrna/intern/rna_fcurve_api.c
+++ b/source/blender/makesrna/intern/rna_fcurve_api.c
@@ -76,52 +76,7 @@ static void rna_FCurve_convert_to_keyframes(FCurve *fcu, ReportList *reports, in
BKE_report(reports, RPT_WARNING, "FCurve has no sample points");
}
else {
- BezTriple *bezt;
- FPoint *fpt = fcu->fpt;
- int tot_kf = end - start;
- int tot_sp = fcu->totvert;
-
- bezt = fcu->bezt = MEM_callocN(sizeof(*fcu->bezt) * (size_t)tot_kf, __func__);
- fcu->totvert = tot_kf;
-
- /* Get first sample point to 'copy' as keyframe. */
- for (; tot_sp && (fpt->vec[0] < (float)start); fpt++, tot_sp--) {
- /* pass */
- }
-
- /* Add heading dummy flat points if needed. */
- for (; tot_kf && (fpt->vec[0] > (float)start); start++, bezt++, tot_kf--) {
- /* Linear interpolation, of course. */
- bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
- bezt->ipo = BEZT_IPO_LIN;
- bezt->h1 = bezt->h2 = HD_AUTO_ANIM;
- bezt->vec[1][0] = (float)start;
- bezt->vec[1][1] = fpt->vec[1];
- }
-
- /* Copy actual sample points. */
- for (; tot_kf && tot_sp; start++, bezt++, tot_kf--, fpt++, tot_sp--) {
- /* Linear interpolation, of course. */
- bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
- bezt->ipo = BEZT_IPO_LIN;
- bezt->h1 = bezt->h2 = HD_AUTO_ANIM;
- copy_v2_v2(bezt->vec[1], fpt->vec);
- }
-
- /* Add leading dummy flat points if needed. */
- for (fpt--; tot_kf; start++, bezt++, tot_kf--) {
- /* Linear interpolation, of course. */
- bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
- bezt->ipo = BEZT_IPO_LIN;
- bezt->h1 = bezt->h2 = HD_AUTO_ANIM;
- bezt->vec[1][0] = (float)start;
- bezt->vec[1][1] = fpt->vec[1];
- }
-
- MEM_SAFE_FREE(fcu->fpt);
-
- /* Not strictly needed since we use linear interpolation, but better be consistent here. */
- calchandles_fcurve(fcu);
+ fcurve_samples_to_keyframes(fcu, start, end);
WM_main_add_notifier(NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
}
}
diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c
index 60eed60ace1..02ae71e3b3d 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -1456,8 +1456,16 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem simulation_methods[] = {
- {FLUID_DOMAIN_METHOD_FLIP, "FLIP", 0, "FLIP", "Use FLIP as the simulation method"},
- /*{FLUID_DOMAIN_METHOD_APIC, "APIC", 0, "APIC", "Use APIC as the simulation method"},*/
+ {FLUID_DOMAIN_METHOD_FLIP,
+ "FLIP",
+ 0,
+ "FLIP",
+ "Use FLIP as the simulation method (more splashy behavior)"},
+ {FLUID_DOMAIN_METHOD_APIC,
+ "APIC",
+ 0,
+ "APIC",
+ "Use APIC as the simulation method (more energetic and stable behavior)"},
{0, NULL, 0, NULL, NULL},
};
@@ -1820,6 +1828,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "simulation_method");
RNA_def_property_enum_items(prop, simulation_methods);
RNA_def_property_ui_text(prop, "Simulation Method", "Change the underlying simulation method");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset");
prop = RNA_def_property(srna, "flip_ratio", PROP_FLOAT, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index f8bc5c06963..603bd51b2d9 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -23,6 +23,7 @@
#include "BLI_math.h"
#include "DNA_brush_types.h"
+#include "DNA_curve_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
@@ -160,6 +161,7 @@ static const EnumPropertyItem rna_enum_gpencil_caps_modes_items[] = {
#ifdef RNA_RUNTIME
# include "BLI_ghash.h"
+# include "BLI_listbase.h"
# include "BLI_string_utils.h"
# include "WM_api.h"
@@ -167,6 +169,7 @@ static const EnumPropertyItem rna_enum_gpencil_caps_modes_items[] = {
# include "BKE_action.h"
# include "BKE_animsys.h"
# include "BKE_gpencil.h"
+# include "BKE_gpencil_curve.h"
# include "BKE_gpencil_geom.h"
# include "BKE_icons.h"
@@ -179,6 +182,71 @@ static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
}
+static void rna_GPencil_curve_edit_mode_toggle(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ ToolSettings *ts = scene->toolsettings;
+ bGPdata *gpd = (bGPdata *)ptr->owner_id;
+
+ /* Curve edit mode is turned on. */
+ if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) {
+ /* If the current select mode is segment and the Bezier mode is on, change
+ * to Point because segment is not supported. */
+ if (ts->gpencil_selectmode_edit == GP_SELECTMODE_SEGMENT) {
+ ts->gpencil_selectmode_edit = GP_SELECTMODE_POINT;
+ }
+
+ BKE_gpencil_strokes_selected_update_editcurve(gpd);
+ }
+ /* Curve edit mode is turned off. */
+ else {
+ BKE_gpencil_strokes_selected_sync_selection_editcurve(gpd);
+ }
+
+ /* Standard update. */
+ rna_GPencil_update(bmain, scene, ptr);
+}
+
+static void rna_GPencil_stroke_curve_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ bGPdata *gpd = (bGPdata *)ptr->owner_id;
+
+ if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) {
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ if (gpl->actframe != NULL) {
+ bGPDframe *gpf = gpl->actframe;
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ if (gps->editcurve != NULL) {
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+ }
+ }
+ }
+ }
+
+ rna_GPencil_update(bmain, scene, ptr);
+}
+
+static void rna_GPencil_stroke_curve_resolution_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ bGPdata *gpd = (bGPdata *)ptr->owner_id;
+
+ if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) {
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ if (gpl->actframe != NULL) {
+ bGPDframe *gpf = gpl->actframe;
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ if (gps->editcurve != NULL) {
+ gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+ }
+ }
+ }
+ }
+ rna_GPencil_update(bmain, scene, ptr);
+}
+
static void rna_GPencil_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
DEG_id_tag_update(ptr->owner_id, ID_RECALC_TRANSFORM);
@@ -191,11 +259,12 @@ static void rna_GPencil_dependency_update(Main *bmain, Scene *UNUSED(scene), Poi
static void rna_GPencil_uv_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
+ bGPdata *gpd = (bGPdata *)ptr->owner_id;
/* Force to recalc the UVs. */
bGPDstroke *gps = (bGPDstroke *)ptr->data;
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
@@ -669,7 +738,7 @@ static void rna_GPencil_stroke_point_add(
stroke->totpoints += count;
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(stroke);
+ BKE_gpencil_stroke_geometry_update(gpd, stroke);
DEG_id_tag_update(&gpd->id,
ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
@@ -730,7 +799,7 @@ static void rna_GPencil_stroke_point_pop(ID *id,
}
/* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(stroke);
+ BKE_gpencil_stroke_geometry_update(gpd, stroke);
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
@@ -808,6 +877,32 @@ static void rna_GPencil_stroke_select_set(PointerRNA *ptr, const bool value)
}
}
+static void rna_GPencil_curve_select_set(PointerRNA *ptr, const bool value)
+{
+ bGPDcurve *gpc = ptr->data;
+
+ /* Set new value. */
+ if (value) {
+ gpc->flag |= GP_CURVE_SELECT;
+ }
+ else {
+ gpc->flag &= ~GP_CURVE_SELECT;
+ }
+ /* Ensure that the curves's points are selected in the same way. */
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (value) {
+ gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(bezt);
+ }
+ else {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ }
+ }
+}
+
static bGPDframe *rna_GPencil_frame_new(bGPDlayer *layer,
ReportList *reports,
int frame_number,
@@ -969,6 +1064,100 @@ static char *rna_GreasePencilGrid_path(PointerRNA *UNUSED(ptr))
return BLI_strdup("grid");
}
+static void rna_GpencilCurvePoint_BezTriple_handle1_get(PointerRNA *ptr, float *values)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ copy_v3_v3(values, cpt->bezt.vec[0]);
+}
+
+static void rna_GpencilCurvePoint_BezTriple_handle1_set(PointerRNA *ptr, const float *values)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ copy_v3_v3(cpt->bezt.vec[0], values);
+}
+
+static bool rna_GpencilCurvePoint_BezTriple_handle1_select_get(PointerRNA *ptr)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ return cpt->bezt.f1;
+}
+
+static void rna_GpencilCurvePoint_BezTriple_handle1_select_set(PointerRNA *ptr, const bool value)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ cpt->bezt.f1 = value;
+}
+
+static void rna_GpencilCurvePoint_BezTriple_handle2_get(PointerRNA *ptr, float *values)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ copy_v3_v3(values, cpt->bezt.vec[2]);
+}
+
+static void rna_GpencilCurvePoint_BezTriple_handle2_set(PointerRNA *ptr, const float *values)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ copy_v3_v3(cpt->bezt.vec[2], values);
+}
+
+static bool rna_GpencilCurvePoint_BezTriple_handle2_select_get(PointerRNA *ptr)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ return cpt->bezt.f3;
+}
+
+static void rna_GpencilCurvePoint_BezTriple_handle2_select_set(PointerRNA *ptr, const bool value)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ cpt->bezt.f3 = value;
+}
+
+static void rna_GpencilCurvePoint_BezTriple_ctrlpoint_get(PointerRNA *ptr, float *values)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ copy_v3_v3(values, cpt->bezt.vec[1]);
+}
+
+static void rna_GpencilCurvePoint_BezTriple_ctrlpoint_set(PointerRNA *ptr, const float *values)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ copy_v3_v3(cpt->bezt.vec[1], values);
+}
+
+static bool rna_GpencilCurvePoint_BezTriple_ctrlpoint_select_get(PointerRNA *ptr)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ return cpt->bezt.f2;
+}
+
+static void rna_GpencilCurvePoint_BezTriple_ctrlpoint_select_set(PointerRNA *ptr, const bool value)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ cpt->bezt.f2 = value;
+}
+
+static bool rna_GpencilCurvePoint_BezTriple_hide_get(PointerRNA *ptr)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ return (bool)cpt->bezt.hide;
+}
+
+static void rna_GpencilCurvePoint_BezTriple_hide_set(PointerRNA *ptr, const bool value)
+{
+ bGPDcurve_point *cpt = (bGPDcurve_point *)ptr->data;
+ cpt->bezt.hide = value;
+}
+
+static bool rna_stroke_has_edit_curve_get(PointerRNA *ptr)
+{
+ bGPDstroke *gps = (bGPDstroke *)ptr->data;
+ if (gps->editcurve != NULL) {
+ return true;
+ }
+
+ return false;
+}
+
#else
static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
@@ -1106,6 +1295,149 @@ static void rna_def_gpencil_triangle(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
}
+static void rna_def_gpencil_curve_point(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "GPencilEditCurvePoint", NULL);
+ RNA_def_struct_sdna(srna, "bGPDcurve_point");
+ RNA_def_struct_ui_text(srna, "Bezier Curve Point", "Bezier curve point with two handles");
+
+ /* Boolean values */
+ prop = RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop,
+ "rna_GpencilCurvePoint_BezTriple_handle1_select_get",
+ "rna_GpencilCurvePoint_BezTriple_handle1_select_set");
+ RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+ prop = RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop,
+ "rna_GpencilCurvePoint_BezTriple_handle2_select_get",
+ "rna_GpencilCurvePoint_BezTriple_handle2_select_set");
+ RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+ prop = RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop,
+ "rna_GpencilCurvePoint_BezTriple_ctrlpoint_select_get",
+ "rna_GpencilCurvePoint_BezTriple_ctrlpoint_select_set");
+ RNA_def_property_ui_text(prop, "Control Point selected", "Control point selection status");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop,
+ "rna_GpencilCurvePoint_BezTriple_hide_get",
+ "rna_GpencilCurvePoint_BezTriple_hide_set");
+ RNA_def_property_ui_text(prop, "Hide", "Visibility status");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+ /* Vector values */
+ prop = RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_TRANSLATION);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_float_funcs(prop,
+ "rna_GpencilCurvePoint_BezTriple_handle1_get",
+ "rna_GpencilCurvePoint_BezTriple_handle1_set",
+ NULL);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle");
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
+
+ prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_float_funcs(prop,
+ "rna_GpencilCurvePoint_BezTriple_ctrlpoint_get",
+ "rna_GpencilCurvePoint_BezTriple_ctrlpoint_set",
+ NULL);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
+
+ prop = RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_TRANSLATION);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_float_funcs(prop,
+ "rna_GpencilCurvePoint_BezTriple_handle2_get",
+ "rna_GpencilCurvePoint_BezTriple_handle2_set",
+ NULL);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle");
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
+
+ /* Pressure */
+ prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "pressure");
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, RNA_TRANSLATION_PREC_DEFAULT);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Pressure", "Pressure of the grease pencil stroke point");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
+
+ /* Strength */
+ prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "strength");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(
+ prop, "Strength", "Color intensity (alpha factor) of the grease pencil stroke point");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
+
+ /* read-only index */
+ prop = RNA_def_property(srna, "point_index", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "point_index");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(
+ prop, "Point Index", "Index of the corresponding grease pencil stroke point");
+
+ prop = RNA_def_property(srna, "uv_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "uv_fac");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "UV Factor", "Internal UV factor");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
+
+ prop = RNA_def_property(srna, "uv_rotation", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "uv_rot");
+ RNA_def_property_range(prop, -M_PI_2, M_PI_2);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "UV Rotation", "Internal UV factor for dot mode");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
+
+ prop = RNA_def_property(srna, "vertex_color", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_float_sdna(prop, NULL, "vert_color");
+ RNA_def_property_array(prop, 4);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Vertex Color", "Vertex color of the grease pencil stroke point");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
+}
+
+/* Editing Curve data. */
+static void rna_def_gpencil_curve(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "GPencilEditCurve", NULL);
+ RNA_def_struct_sdna(srna, "bGPDcurve");
+ RNA_def_struct_ui_text(srna, "Edit Curve", "Edition Curve");
+
+ prop = RNA_def_property(srna, "curve_points", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "curve_points", "tot_curve_points");
+ RNA_def_property_struct_type(prop, "GPencilEditCurvePoint");
+ RNA_def_property_ui_text(prop, "Curve Points", "Curve data points");
+
+ prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_CURVE_SELECT);
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_curve_select_set");
+ RNA_def_property_ui_text(prop, "Select", "Curve is selected for viewport editing");
+ RNA_def_property_update(prop, 0, "rna_GPencil_update");
+}
+
static void rna_def_gpencil_mvert_group(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1180,6 +1512,12 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "GPencilTriangle");
RNA_def_property_ui_text(prop, "Triangles", "Triangulation data for HQ fill");
+ /* Edit Curve. */
+ prop = RNA_def_property(srna, "edit_curve", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "editcurve");
+ RNA_def_property_struct_type(prop, "GPencilEditCurve");
+ RNA_def_property_ui_text(prop, "Edit Curve", "Temporary data for Edit Curve");
+
/* Material Index */
prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "mat_nr");
@@ -1205,6 +1543,12 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Cyclic", "Enable cyclic drawing, closing the stroke");
RNA_def_property_update(prop, 0, "rna_GPencil_update");
+ /* The stroke has Curve Edit data. */
+ prop = RNA_def_property(srna, "has_edit_curve", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_stroke_has_edit_curve_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Has Curve Data", "Stroke has Curve data to edit shape");
+
/* Caps mode */
prop = RNA_def_property(srna, "start_cap_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "caps[0]");
@@ -2017,6 +2361,47 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
"Scale conversion factor for pixel size (use larger values for thicker lines)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ prop = RNA_def_property(srna, "edit_curve_resolution", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "curve_edit_resolution");
+ RNA_def_property_range(prop, 1, 256);
+ RNA_def_property_ui_range(prop, 1, 64, 1, 1);
+ RNA_def_property_int_default(prop, GP_DEFAULT_CURVE_RESOLUTION);
+ RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop,
+ "Curve Resolution",
+ "Number of segments generated between control points when editing strokes in curve mode");
+ RNA_def_property_update(
+ prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_resolution_update");
+
+ prop = RNA_def_property(srna, "use_adaptive_curve_resolution", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_CURVE_ADAPTIVE_RESOLUTION);
+ RNA_def_property_boolean_default(prop, true);
+ RNA_def_property_ui_text(prop,
+ "Adaptive Resolution",
+ "Set the resolution of each editcurve segment dynamically depending on "
+ "the length of the segment. The resolution is the number of points "
+ "generated per unit distance");
+ RNA_def_property_update(
+ prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_resolution_update");
+
+ /* Curve editing error threshold. */
+ prop = RNA_def_property(srna, "curve_edit_threshold", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "curve_edit_threshold");
+ RNA_def_property_range(prop, FLT_MIN, 10.0);
+ RNA_def_property_float_default(prop, GP_DEFAULT_CURVE_ERROR);
+ RNA_def_property_ui_text(prop, "Threshold", "Curve conversion error threshold");
+ RNA_def_property_ui_range(prop, FLT_MIN, 10.0, 2, 5);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
+ /* Curve editing corner angle. */
+ prop = RNA_def_property(srna, "curve_edit_corner_angle", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "curve_edit_corner_angle");
+ RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
+ RNA_def_property_float_default(prop, DEG2RADF(90.0f));
+ RNA_def_property_ui_text(prop, "Corner Angle", "Angle threshold to be treated as corners");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
prop = RNA_def_property(srna, "use_multiedit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_MULTIEDIT);
RNA_def_property_ui_text(prop,
@@ -2025,6 +2410,11 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
"(keyframes must be selected to be included)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ prop = RNA_def_property(srna, "use_curve_edit", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_CURVE_EDIT_MODE);
+ RNA_def_property_ui_text(prop, "Curve Editing", "Edit strokes using curve handles");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_curve_edit_mode_toggle");
+
prop = RNA_def_property(srna, "use_autolock_layers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_AUTOLOCK_LAYERS);
RNA_def_property_ui_text(
@@ -2176,6 +2566,8 @@ void RNA_def_gpencil(BlenderRNA *brna)
rna_def_gpencil_stroke(brna);
rna_def_gpencil_stroke_point(brna);
rna_def_gpencil_triangle(brna);
+ rna_def_gpencil_curve(brna);
+ rna_def_gpencil_curve_point(brna);
rna_def_gpencil_mvert_group(brna);
}
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 5592474a348..19264aeebd7 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -2109,22 +2109,11 @@ static void rna_def_modifier_gpencilmultiply(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "enable_angle_splitting", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", GP_MULTIPLY_ENABLE_ANGLE_SPLITTING);
- RNA_def_property_ui_text(prop, "Angle Splitting", "Enable angle splitting");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
prop = RNA_def_property(srna, "use_fade", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", GP_MULTIPLY_ENABLE_FADING);
RNA_def_property_ui_text(prop, "Fade", "Fade the stroke thickness for each generated stroke");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "split_angle", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_range(prop, 0, M_PI);
- RNA_def_property_ui_range(prop, 0, M_PI, 10, 2);
- RNA_def_property_ui_text(prop, "Angle", "Split angle for segments");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
prop = RNA_def_property(srna, "duplicates", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "duplications");
RNA_def_property_range(prop, 0, 999);
@@ -2263,6 +2252,16 @@ static void rna_def_modifier_gpenciltexture(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "UV Scale", "Factor to scale the UVs");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+ /* Rotation of Dot Texture. */
+ prop = RNA_def_property(srna, "alignment_rotation", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "alignment_rotation");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -DEG2RADF(90.0f), DEG2RADF(90.0f));
+ RNA_def_property_ui_range(prop, -DEG2RADF(90.0f), DEG2RADF(90.0f), 10, 3);
+ RNA_def_property_ui_text(
+ prop, "Rotation", "Additional rotation applied to dots and square strokes");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
prop = RNA_def_property(srna, "fill_rotation", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "fill_rotation");
RNA_def_property_ui_text(prop, "Fill Rotation", "Additional rotation of the fill UV");
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 1c43815d3a2..504a4a6bdf3 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -235,7 +235,8 @@ static int rna_Image_file_format_get(PointerRNA *ptr)
{
Image *image = (Image *)ptr->data;
ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
- int imtype = BKE_image_ftype_to_imtype(ibuf ? ibuf->ftype : 0, ibuf ? &ibuf->foptions : NULL);
+ int imtype = BKE_image_ftype_to_imtype(ibuf ? ibuf->ftype : IMB_FTYPE_NONE,
+ ibuf ? &ibuf->foptions : NULL);
BKE_image_release_ibuf(image, ibuf, NULL);
@@ -1034,7 +1035,7 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "aspx");
RNA_def_property_array(prop, 2);
RNA_def_property_range(prop, 0.1f, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.1f, 5000.f, 1, 2);
+ RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
RNA_def_property_ui_text(
prop, "Display Aspect", "Display Aspect for this image, does not affect rendering");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c
index 64c50b82d1f..03442748854 100644
--- a/source/blender/makesrna/intern/rna_linestyle.c
+++ b/source/blender/makesrna/intern/rna_linestyle.c
@@ -1573,7 +1573,7 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna)
prop = RNA_def_property(srna, "pivot_u", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "pivot_u");
- RNA_def_property_range(prop, 0.f, 1.f);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop,
"Stroke Point Parameter",
"Pivot in terms of the stroke point parameter u (0 <= u <= 1)");
@@ -1920,7 +1920,7 @@ static void rna_def_linestyle(BlenderRNA *brna)
prop = RNA_def_property(srna, "thickness_ratio", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "thickness_ratio");
- RNA_def_property_range(prop, 0.f, 1.f);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(
prop,
"Thickness Ratio",
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 5e16f1187fb..086a182e085 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -24,6 +24,8 @@
#include "DNA_material_types.h"
#include "DNA_texture_types.h"
+#include "BLI_math.h"
+
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -594,6 +596,16 @@ static void rna_def_material_greasepencil(BlenderRNA *brna)
prop, "Alignment", "Defines how align Dots and Boxes with drawing path and object rotation");
RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
+ /* Rotation of texture for Dots or Strokes. */
+ prop = RNA_def_property(srna, "alignment_rotation", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "alignment_rotation");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -DEG2RADF(90.0f), DEG2RADF(90.0f));
+ RNA_def_property_ui_range(prop, -DEG2RADF(90.0f), DEG2RADF(90.0f), 10, 3);
+ RNA_def_property_ui_text(
+ prop, "Rotation", "Additional rotation applied to dots and square strokes");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
+
/* pass index for future compositing and editing tools */
prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "index");
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 7885e182787..2df42b87c07 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -197,7 +197,7 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = {
"WELD",
ICON_AUTOMERGE_OFF,
"Weld",
- "Find groups of vertices closer than dist and merges them together"},
+ "Find groups of vertices closer than dist and merge them together"},
{eModifierType_Wireframe,
"WIREFRAME",
ICON_MOD_WIREFRAME,
@@ -969,15 +969,6 @@ static void rna_fluid_set_type(Main *bmain, Scene *scene, PointerRNA *ptr)
rna_Modifier_dependency_update(bmain, scene, ptr);
}
-static void rna_MultiresModifier_type_set(PointerRNA *ptr, int value)
-{
- Object *ob = (Object *)ptr->owner_id;
- MultiresModifierData *mmd = (MultiresModifierData *)ptr->data;
-
- multires_force_sculpt_rebuild(ob);
- mmd->simple = value;
-}
-
static void rna_MultiresModifier_level_range(
PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
{
@@ -1538,12 +1529,7 @@ static void rna_ParticleInstanceModifier_particle_system_set(PointerRNA *ptr,
static void rna_Modifier_show_expanded_set(PointerRNA *ptr, bool value)
{
ModifierData *md = ptr->data;
- if (value) {
- md->ui_expand_flag |= (1 << 0);
- }
- else {
- md->ui_expand_flag &= ~(1 << 0);
- }
+ SET_FLAG_FROM_TEST(md->ui_expand_flag, value, UI_PANEL_DATA_EXPAND_ROOT);
}
/**
@@ -1554,7 +1540,7 @@ static void rna_Modifier_show_expanded_set(PointerRNA *ptr, bool value)
static bool rna_Modifier_show_expanded_get(PointerRNA *ptr)
{
ModifierData *md = ptr->data;
- return md->ui_expand_flag & (1 << 0);
+ return md->ui_expand_flag & UI_PANEL_DATA_EXPAND_ROOT;
}
static int rna_MeshSequenceCacheModifier_has_velocity_get(PointerRNA *ptr)
@@ -1604,15 +1590,8 @@ static int rna_MeshSequenceCacheModifier_read_velocity_get(PointerRNA *ptr)
#else
-/* NOTE: *MUST* return subdivision_type property. */
-static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const char type[])
+static void rna_def_property_subdivision_common(StructRNA *srna)
{
- static const EnumPropertyItem prop_subdivision_type_items[] = {
- {SUBSURF_TYPE_CATMULL_CLARK, "CATMULL_CLARK", 0, "Catmull-Clark", ""},
- {SUBSURF_TYPE_SIMPLE, "SIMPLE", 0, "Simple", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
static const EnumPropertyItem prop_uv_smooth_items[] = {
{SUBSURF_UV_SMOOTH_NONE, "NONE", 0, "None", "UVs are not smoothed, boundaries are kept sharp"},
{SUBSURF_UV_SMOOTH_PRESERVE_CORNERS,
@@ -1677,19 +1656,17 @@ static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const c
RNA_def_property_ui_text(prop, "Boundary Smooth", "Controls how open boundaries are smoothed");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
- prop = RNA_def_property(srna, "subdivision_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, type);
- RNA_def_property_enum_items(prop, prop_subdivision_type_items);
- RNA_def_property_ui_text(prop, "Subdivision Type", "Select type of subdivision algorithm");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
RNA_define_lib_overridable(false);
-
- return prop;
}
static void rna_def_modifier_subsurf(BlenderRNA *brna)
{
+ static const EnumPropertyItem prop_subdivision_type_items[] = {
+ {SUBSURF_TYPE_CATMULL_CLARK, "CATMULL_CLARK", 0, "Catmull-Clark", ""},
+ {SUBSURF_TYPE_SIMPLE, "SIMPLE", 0, "Simple", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
StructRNA *srna;
PropertyRNA *prop;
@@ -1698,10 +1675,16 @@ static void rna_def_modifier_subsurf(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SubsurfModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_SUBSURF);
- rna_def_property_subdivision_common(srna, "subdivType");
+ rna_def_property_subdivision_common(srna);
RNA_define_lib_overridable(true);
+ prop = RNA_def_property(srna, "subdivision_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "subdivType");
+ RNA_def_property_enum_items(prop, prop_subdivision_type_items);
+ RNA_def_property_ui_text(prop, "Subdivision Type", "Select type of subdivision algorithm");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
/* see CCGSUBSURF_LEVEL_MAX for max limit */
prop = RNA_def_property(srna, "levels", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "levels");
@@ -1893,8 +1876,7 @@ static void rna_def_modifier_multires(BlenderRNA *brna)
RNA_define_lib_overridable(true);
- prop = rna_def_property_subdivision_common(srna, "simple");
- RNA_def_property_enum_funcs(prop, NULL, "rna_MultiresModifier_type_set", NULL);
+ rna_def_property_subdivision_common(srna);
prop = RNA_def_property(srna, "levels", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "lvl");
diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c
index ff5445f1d71..d07a4b4fac7 100644
--- a/source/blender/makesrna/intern/rna_movieclip.c
+++ b/source/blender/makesrna/intern/rna_movieclip.c
@@ -46,11 +46,11 @@
# include "ED_clip.h"
-# include "BKE_sequencer.h"
-
# include "DNA_screen_types.h"
# include "DNA_space_types.h"
+# include "SEQ_sequencer.h"
+
static void rna_MovieClip_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
MovieClip *clip = (MovieClip *)ptr->owner_id;
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 0dea0e47978..e91b0d860c6 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -55,7 +55,7 @@
#include "MEM_guardedalloc.h"
-#include "RE_render_ext.h"
+#include "RE_texture.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -4362,10 +4362,38 @@ static void def_sh_vector_rotate(StructRNA *srna)
static void def_sh_attribute(StructRNA *srna)
{
+ static const EnumPropertyItem prop_attribute_type[] = {
+ {SHD_ATTRIBUTE_GEOMETRY,
+ "GEOMETRY",
+ 0,
+ "Geometry",
+ "The attribute is associated with the object geometry, and its value "
+ "varies from vertex to vertex, or within the object volume"},
+ {SHD_ATTRIBUTE_OBJECT,
+ "OBJECT",
+ 0,
+ "Object",
+ "The attribute is associated with the object or mesh datablock itself, "
+ "and its value is uniform"},
+ {SHD_ATTRIBUTE_INSTANCER,
+ "INSTANCER",
+ 0,
+ "Instancer",
+ "The attribute is associated with the instancer particle system or object, "
+ "falling back to the Object mode if the attribute isn't found, or the object "
+ "is not instanced"},
+ {0, NULL, 0, NULL, NULL},
+ };
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "NodeShaderAttribute", "storage");
+ prop = RNA_def_property(srna, "attribute_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type");
+ RNA_def_property_enum_items(prop, prop_attribute_type);
+ RNA_def_property_ui_text(prop, "Attribute Type", "General type of the attribute");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
prop = RNA_def_property(srna, "attribute_name", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "Attribute Name", "");
@@ -4788,7 +4816,7 @@ static void def_sh_tex_voronoi(StructRNA *srna)
{SHD_VORONOI_DISTANCE_TO_EDGE,
"DISTANCE_TO_EDGE",
0,
- "Distance To Edge",
+ "Distance to Edge",
"Computes the distance to the edge of the voronoi cell"},
{SHD_VORONOI_N_SPHERE_RADIUS,
"N_SPHERE_RADIUS",
@@ -7090,7 +7118,7 @@ static void def_cmp_lensdist(StructRNA *srna)
static void def_cmp_colorbalance(StructRNA *srna)
{
PropertyRNA *prop;
- static float default_1[3] = {1.f, 1.f, 1.f};
+ static float default_1[3] = {1.0f, 1.0f, 1.0f};
static const EnumPropertyItem type_items[] = {
{0, "LIFT_GAMMA_GAIN", 0, "Lift/Gamma/Gain", ""},
@@ -7145,7 +7173,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_float_sdna(prop, NULL, "power");
RNA_def_property_array(prop, 3);
RNA_def_property_float_array_default(prop, default_1);
- RNA_def_property_range(prop, 0.f, FLT_MAX);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Power", "Correction for Midtones");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl");
@@ -7154,7 +7182,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_float_sdna(prop, NULL, "slope");
RNA_def_property_array(prop, 3);
RNA_def_property_float_array_default(prop, default_1);
- RNA_def_property_range(prop, 0.f, FLT_MAX);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Slope", "Correction for Highlights");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl");
@@ -7725,15 +7753,15 @@ static void def_cmp_viewer(StructRNA *srna)
static const EnumPropertyItem tileorder_items[] = {
{0, "CENTEROUT", 0, "Center", "Expand from center"},
{1, "RANDOM", 0, "Random", "Random tiles"},
- {2, "BOTTOMUP", 0, "Bottom up", "Expand from bottom"},
- {3, "RULE_OF_THIRDS", 0, "Rule of thirds", "Expand from 9 places"},
+ {2, "BOTTOMUP", 0, "Bottom Up", "Expand from bottom"},
+ {3, "RULE_OF_THIRDS", 0, "Rule of Thirds", "Expand from 9 places"},
{0, NULL, 0, NULL, NULL},
};
prop = RNA_def_property(srna, "tile_order", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, tileorder_items);
- RNA_def_property_ui_text(prop, "Tile order", "Tile order");
+ RNA_def_property_ui_text(prop, "Tile Order", "Tile order");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "center_x", PROP_FLOAT, PROP_NONE);
@@ -8037,7 +8065,7 @@ static void def_cmp_sunbeams(StructRNA *srna)
static void def_cmp_cryptomatte(StructRNA *srna)
{
PropertyRNA *prop;
- static float default_1[3] = {1.f, 1.f, 1.f};
+ static float default_1[3] = {1.0f, 1.0f, 1.0f};
RNA_def_struct_sdna_from(srna, "NodeCryptomatte", "storage");
prop = RNA_def_property(srna, "matte_id", PROP_STRING, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 8b227774d66..6f7116bfe22 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -2699,6 +2699,15 @@ static void rna_def_object(BlenderRNA *brna)
prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
+ prop = RNA_def_property(srna, "use_camera_lock_parent", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(
+ prop, NULL, "transflag", OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK);
+ RNA_def_property_ui_text(prop,
+ "Camera Parent Lock",
+ "View Lock 3D viewport camera transformation affects the object's "
+ "parent instead");
+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
+
/* Track and Up flags */
/* XXX: these have been saved here for a bit longer (after old track was removed),
* since some other tools still refer to this */
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 2c740533dcd..ee87ad19cbb 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -944,6 +944,8 @@ static void rna_def_pointcache_common(StructRNA *srna)
RNA_def_struct_path_func(srna, "rna_PointCache_path");
+ RNA_define_lib_overridable(true);
+
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "startframe");
RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
@@ -1038,6 +1040,8 @@ static void rna_def_pointcache_common(StructRNA *srna)
"Use this file's path for the disk cache when library linked into another file "
"(for local bakes per scene file, disable this option)");
RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
+
+ RNA_define_lib_overridable(false);
}
static void rna_def_ptcache_point_caches(BlenderRNA *brna, PropertyRNA *cprop)
@@ -1099,6 +1103,7 @@ static void rna_def_pointcache_active(BlenderRNA *brna)
NULL);
RNA_def_property_struct_type(prop, "PointCacheItem");
RNA_def_property_ui_text(prop, "Point Cache List", "");
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
rna_def_ptcache_point_caches(brna, prop);
}
@@ -2031,7 +2036,8 @@ static void rna_def_softbody(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_estimate_matrix", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_ESTIMATEIPO);
- RNA_def_property_ui_text(prop, "Estimate Matrix", "Estimate matrix... split to COM, ROT, SCALE");
+ RNA_def_property_ui_text(
+ prop, "Estimate Transforms", "Store the estimated transforms in the soft body settings");
/***********************************************************************************/
/* these are not exactly settings, but reading calculated results*/
@@ -2047,7 +2053,7 @@ static void rna_def_softbody(BlenderRNA *brna)
prop = RNA_def_property(srna, "rotation_estimate", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "lrot");
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_3x3);
- RNA_def_property_ui_text(prop, "Rot Matrix", "Estimated rotation matrix");
+ RNA_def_property_ui_text(prop, "Rotation Matrix", "Estimated rotation matrix");
prop = RNA_def_property(srna, "scale_estimate", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "lscale");
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 543038eee8c..5987f52328d 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -1011,13 +1011,13 @@ static float rna_PartSettings_timestep_get(struct PointerRNA *ptr)
static void rna_PartSetting_hairlength_set(struct PointerRNA *ptr, float value)
{
ParticleSettings *settings = (ParticleSettings *)ptr->data;
- settings->normfac = value / 4.f;
+ settings->normfac = value / 4.0f;
}
static float rna_PartSetting_hairlength_get(struct PointerRNA *ptr)
{
ParticleSettings *settings = (ParticleSettings *)ptr->data;
- return settings->normfac * 4.f;
+ return settings->normfac * 4.0f;
}
static void rna_PartSetting_linelentail_set(struct PointerRNA *ptr, float value)
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 942cd3d1a20..bc9aabbefe6 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -375,14 +375,14 @@ static void rna_Itasc_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
if (itasc->feedback < 0.01f) {
itasc->feedback = 0.01f;
}
- if (itasc->feedback > 100.f) {
- itasc->feedback = 100.f;
+ if (itasc->feedback > 100.0f) {
+ itasc->feedback = 100.0f;
}
if (itasc->maxvel < 0.01f) {
itasc->maxvel = 0.01f;
}
- if (itasc->maxvel > 100.f) {
- itasc->maxvel = 100.f;
+ if (itasc->maxvel > 100.0f) {
+ itasc->maxvel = 100.0f;
}
BIK_update_param(ob->pose);
@@ -1241,14 +1241,14 @@ static void rna_def_pose_channel(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_ik_rotation_control", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_ROTCTL);
- RNA_def_property_ui_text(prop, "IK rot control", "Apply channel rotation as IK constraint");
+ RNA_def_property_ui_text(prop, "IK Rotation Control", "Apply channel rotation as IK constraint");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "use_ik_linear_control", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_LINCTL);
RNA_def_property_ui_text(
- prop, "IK rot control", "Apply channel size as IK constraint if stretching is enabled");
+ prop, "IK Linear Control", "Apply channel size as IK constraint if stretching is enabled");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
@@ -1325,7 +1325,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
prop = RNA_def_property(srna, "ik_rotation_weight", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "ikrotweight");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "IK Rot Weight", "Weight of rotation constraint for IK");
+ RNA_def_property_ui_text(prop, "IK Rotation Weight", "Weight of rotation constraint for IK");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
@@ -1504,7 +1504,7 @@ static void rna_def_pose_itasc(BlenderRNA *brna)
prop = RNA_def_property(srna, "step_count", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "numstep");
- RNA_def_property_range(prop, 1.f, 50.f);
+ RNA_def_property_range(prop, 1.0f, 50.0f);
RNA_def_property_ui_text(prop, "Num Steps", "Divide the frame interval into this many steps");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
@@ -1695,6 +1695,8 @@ static void rna_def_pose(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "IK Param", "Parameters for IK solver");
+ RNA_define_lib_overridable(true);
+
/* pose edit options */
prop = RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", POSE_MIRROR_EDIT);
@@ -1722,6 +1724,8 @@ static void rna_def_pose(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Pose_update");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
+ RNA_define_lib_overridable(false);
+
/* animviz */
rna_def_animviz_common(srna);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 24cff501b59..c132c434468 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -379,7 +379,7 @@ const EnumPropertyItem rna_enum_image_type_items[] = {
{R_IMF_IMTYPE_FFMPEG,
"FFMPEG",
ICON_FILE_MOVIE,
- "FFmpeg video",
+ "FFmpeg Video",
"The most versatile way to output video files"},
#endif
{0, NULL, 0, NULL, NULL},
@@ -680,7 +680,6 @@ const EnumPropertyItem rna_enum_transform_orientation_items[] = {
# include "BKE_pointcache.h"
# include "BKE_scene.h"
# include "BKE_screen.h"
-# include "BKE_sequencer.h"
# include "BKE_unit.h"
# include "ED_image.h"
@@ -694,6 +693,8 @@ const EnumPropertyItem rna_enum_transform_orientation_items[] = {
# include "DEG_depsgraph_build.h"
# include "DEG_depsgraph_query.h"
+# include "SEQ_sequencer.h"
+
# ifdef WITH_FREESTYLE
# include "FRS_freestyle.h"
# endif
@@ -1157,7 +1158,7 @@ static int rna_RenderSettings_stereoViews_skip(CollectionPropertyIterator *iter,
ListBaseIterator *internal = &iter->internal.listbase;
SceneRenderView *srv = (SceneRenderView *)internal->link;
- if ((STREQ(srv->name, STEREO_LEFT_NAME)) || (STREQ(srv->name, STEREO_RIGHT_NAME))) {
+ if (STR_ELEM(srv->name, STEREO_LEFT_NAME, STEREO_RIGHT_NAME)) {
return 0;
}
@@ -2793,7 +2794,8 @@ static void rna_def_view3d_cursor(BlenderRNA *brna)
prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
RNA_def_property_flag(prop, PROP_THICK_WRAP); /* no reference to original data */
- RNA_def_property_ui_text(prop, "Transform Matrix", "Matrix combining loc/rot of the cursor");
+ RNA_def_property_ui_text(
+ prop, "Transform Matrix", "Matrix combining location and rotation of the cursor");
RNA_def_property_float_funcs(
prop, "rna_View3DCursor_matrix_get", "rna_View3DCursor_matrix_set", NULL);
}
@@ -2864,13 +2866,13 @@ static void rna_def_tool_settings(BlenderRNA *brna)
};
static const EnumPropertyItem gpencil_stroke_snap_items[] = {
- {0, "NONE", 0, "All points", "Snap to all points"},
+ {0, "NONE", 0, "All Points", "Snap to all points"},
{GP_PROJECT_DEPTH_STROKE_ENDPOINTS,
"ENDS",
0,
- "End points",
+ "End Points",
"Snap to first and last points and interpolate"},
- {GP_PROJECT_DEPTH_STROKE_FIRST, "FIRST", 0, "First point", "Snap to first point"},
+ {GP_PROJECT_DEPTH_STROKE_FIRST, "FIRST", 0, "First Point", "Snap to first point"},
{0, NULL, 0, NULL, NULL},
};
@@ -5510,12 +5512,12 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna)
"Constant Bitrate",
"Configure constant bit rate, rather than constant output quality"},
{FFM_CRF_LOSSLESS, "LOSSLESS", 0, "Lossless", ""},
- {FFM_CRF_PERC_LOSSLESS, "PERC_LOSSLESS", 0, "Perceptually lossless", ""},
- {FFM_CRF_HIGH, "HIGH", 0, "High quality", ""},
- {FFM_CRF_MEDIUM, "MEDIUM", 0, "Medium quality", ""},
- {FFM_CRF_LOW, "LOW", 0, "Low quality", ""},
- {FFM_CRF_VERYLOW, "VERYLOW", 0, "Very low quality", ""},
- {FFM_CRF_LOWEST, "LOWEST", 0, "Lowest quality", ""},
+ {FFM_CRF_PERC_LOSSLESS, "PERC_LOSSLESS", 0, "Perceptually Lossless", ""},
+ {FFM_CRF_HIGH, "HIGH", 0, "High Quality", ""},
+ {FFM_CRF_MEDIUM, "MEDIUM", 0, "Medium Quality", ""},
+ {FFM_CRF_LOW, "LOW", 0, "Low Quality", ""},
+ {FFM_CRF_VERYLOW, "VERYLOW", 0, "Very Low Quality", ""},
+ {FFM_CRF_LOWEST, "LOWEST", 0, "Lowest Quality", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -5738,7 +5740,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
{0,
"AUTO",
0,
- "Auto-detect",
+ "Auto-Detect",
"Automatically determine the number of threads, based on CPUs"},
{R_FIXED_THREADS, "FIXED", 0, "Fixed", "Manually determine the number of threads"},
{0, NULL, 0, NULL, NULL},
@@ -6537,7 +6539,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "line_thickness", PROP_FLOAT, PROP_PIXEL);
RNA_def_property_float_sdna(prop, NULL, "unit_line_thickness");
- RNA_def_property_range(prop, 0.f, 10000.f);
+ RNA_def_property_range(prop, 0.0f, 10000.0f);
RNA_def_property_ui_text(prop, "Line Thickness", "Line thickness in pixels");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_freestyle_update");
@@ -7359,9 +7361,9 @@ void RNA_def_scene(BlenderRNA *brna)
};
static const EnumPropertyItem sync_mode_items[] = {
- {0, "NONE", 0, "No Sync", "Do not sync, play every frame"},
+ {0, "NONE", 0, "Play Every Frame", "Do not sync, play every frame"},
{SCE_FRAME_DROP, "FRAME_DROP", 0, "Frame Dropping", "Drop frames if playback is too slow"},
- {AUDIO_SYNC, "AUDIO_SYNC", 0, "AV-sync", "Sync to audio playback, dropping frames"},
+ {AUDIO_SYNC, "AUDIO_SYNC", 0, "Sync to Audio", "Sync to audio playback, dropping frames"},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index c7bdf7a2dd6..e477bf6d284 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -1151,7 +1151,7 @@ static void rna_def_particle_edit(BlenderRNA *brna)
static const EnumPropertyItem edit_type_items[] = {
{PE_TYPE_PARTICLES, "PARTICLES", 0, "Particles", ""},
- {PE_TYPE_SOFTBODY, "SOFT_BODY", 0, "Soft body", ""},
+ {PE_TYPE_SOFTBODY, "SOFT_BODY", 0, "Soft Body", ""},
{PE_TYPE_CLOTH, "CLOTH", 0, "Cloth", ""},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 9d322d0d09b..2ffb9612486 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -34,7 +34,6 @@
#include "BKE_anim_data.h"
#include "BKE_animsys.h"
-#include "BKE_sequencer.h"
#include "BKE_sound.h"
#include "IMB_metadata.h"
@@ -47,6 +46,8 @@
#include "rna_internal.h"
+#include "SEQ_sequencer.h"
+
#include "WM_types.h"
typedef struct EffectInfo {
@@ -469,35 +470,7 @@ static void rna_Sequence_channel_set(PointerRNA *ptr, int value)
static void rna_Sequence_use_proxy_set(PointerRNA *ptr, bool value)
{
Sequence *seq = (Sequence *)ptr->data;
- BKE_sequencer_proxy_set(seq, value != 0);
-}
-
-static void rna_Sequence_use_translation_set(PointerRNA *ptr, bool value)
-{
- Sequence *seq = (Sequence *)ptr->data;
- if (value) {
- seq->flag |= SEQ_USE_TRANSFORM;
- if (seq->strip->transform == NULL) {
- seq->strip->transform = MEM_callocN(sizeof(struct StripTransform), "StripTransform");
- }
- }
- else {
- seq->flag &= ~SEQ_USE_TRANSFORM;
- }
-}
-
-static void rna_Sequence_use_crop_set(PointerRNA *ptr, bool value)
-{
- Sequence *seq = (Sequence *)ptr->data;
- if (value) {
- seq->flag |= SEQ_USE_CROP;
- if (seq->strip->crop == NULL) {
- seq->strip->crop = MEM_callocN(sizeof(struct StripCrop), "StripCrop");
- }
- }
- else {
- seq->flag &= ~SEQ_USE_CROP;
- }
+ SEQ_proxy_set(seq, value != 0);
}
static int transform_seq_cmp_fn(Sequence *seq, void *arg_pt)
@@ -983,8 +956,7 @@ static void rna_SequenceProxy_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
Scene *scene = (Scene *)ptr->owner_id;
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq = sequence_get_by_proxy(ed, ptr->data);
-
- BKE_sequence_invalidate_cache_raw(scene, seq);
+ BKE_sequence_invalidate_cache_preprocessed(scene, seq);
}
/* do_versions? */
@@ -1408,18 +1380,35 @@ static void rna_def_strip_transform(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Sequence Transform", "Transform parameters for a sequence strip");
RNA_def_struct_sdna(srna, "StripTransform");
+ prop = RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_UNSIGNED);
+ RNA_def_property_float_sdna(prop, NULL, "scale_x");
+ RNA_def_property_ui_text(prop, "Scale X", "Scale along X axis");
+ RNA_def_property_ui_range(prop, 0, FLT_MAX, 3, 3);
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update");
+
+ prop = RNA_def_property(srna, "scale_y", PROP_FLOAT, PROP_UNSIGNED);
+ RNA_def_property_float_sdna(prop, NULL, "scale_y");
+ RNA_def_property_ui_text(prop, "Scale Y", "Scale along Y axis");
+ RNA_def_property_ui_range(prop, 0, FLT_MAX, 3, 3);
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update");
+
prop = RNA_def_property(srna, "offset_x", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "xofs");
- RNA_def_property_ui_text(
- prop, "Offset X", "Amount to move the input on the X axis within its boundaries");
- RNA_def_property_ui_range(prop, -4096, 4096, 1, -1);
+ RNA_def_property_ui_text(prop, "Translate X", "Move along X axis");
+ RNA_def_property_ui_range(prop, INT_MIN, INT_MAX, 1, 6);
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update");
prop = RNA_def_property(srna, "offset_y", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "yofs");
- RNA_def_property_ui_text(
- prop, "Offset Y", "Amount to move the input on the Y axis within its boundaries");
- RNA_def_property_ui_range(prop, -4096, 4096, 1, -1);
+ RNA_def_property_ui_text(prop, "Translate Y", "Move along Y axis");
+ RNA_def_property_ui_range(prop, INT_MIN, INT_MAX, 1, 6);
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update");
+
+ prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "rotation");
+ RNA_def_property_ui_text(prop, "Rotation", "Rotate around image centr");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update");
RNA_def_struct_path_func(srna, "rna_SequenceTransform_path");
@@ -1523,12 +1512,14 @@ static void rna_def_strip_proxy(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_proxy_custom_directory", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "storage", SEQ_STORAGE_PROXY_CUSTOM_DIR);
RNA_def_property_ui_text(prop, "Proxy Custom Directory", "Use a custom directory to store data");
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
+ RNA_def_property_update(
+ prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
prop = RNA_def_property(srna, "use_proxy_custom_file", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "storage", SEQ_STORAGE_PROXY_CUSTOM_FILE);
RNA_def_property_ui_text(prop, "Proxy Custom File", "Use a custom file to read proxy data from");
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
+ RNA_def_property_update(
+ prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
}
static void rna_def_color_balance(BlenderRNA *brna)
@@ -1936,7 +1927,7 @@ static void rna_def_sequence(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_PREPROCESSED);
RNA_def_property_ui_text(
prop,
- "Cache Pre-processed",
+ "Cache Pre-Processed",
"Cache pre-processed images, for faster tweaking of effects at the cost of memory usage");
prop = RNA_def_property(srna, "use_cache_composite", PROP_BOOLEAN, PROP_NONE);
@@ -2100,7 +2091,7 @@ static void rna_def_editor(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0f, SEQ_CACHE_COST_MAX, 0.1f, 1);
RNA_def_property_float_sdna(prop, NULL, "recycle_max_cost");
RNA_def_property_ui_text(
- prop, "Recycle Up To Cost", "Only frames with cost lower than this value will be recycled");
+ prop, "Recycle Up to Cost", "Only frames with cost lower than this value will be recycled");
}
static void rna_def_filter_video(StructRNA *srna)
@@ -2150,7 +2141,7 @@ static void rna_def_filter_video(StructRNA *srna)
prop = RNA_def_property(srna, "use_reverse_frames", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_REVERSE_FRAMES);
RNA_def_property_ui_text(prop, "Reverse Frames", "Reverse frame order");
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
prop = RNA_def_property(srna, "color_multiply", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_sdna(prop, NULL, "mul");
@@ -2172,24 +2163,12 @@ static void rna_def_filter_video(StructRNA *srna)
prop = RNA_def_property(srna, "strobe", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 1.0f, 30.0f);
RNA_def_property_ui_text(prop, "Strobe", "Only display every nth frame");
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
-
- prop = RNA_def_property(srna, "use_translation", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_TRANSFORM);
- RNA_def_property_ui_text(prop, "Use Translation", "Translate image before processing");
- RNA_def_property_boolean_funcs(prop, NULL, "rna_Sequence_use_translation_set");
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
prop = RNA_def_property(srna, "transform", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "strip->transform");
RNA_def_property_ui_text(prop, "Transform", "");
- prop = RNA_def_property(srna, "use_crop", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_CROP);
- RNA_def_property_ui_text(prop, "Use Crop", "Crop image before processing");
- RNA_def_property_boolean_funcs(prop, NULL, "rna_Sequence_use_crop_set");
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
-
prop = RNA_def_property(srna, "crop", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "strip->crop");
RNA_def_property_ui_text(prop, "Crop", "");
@@ -2204,7 +2183,8 @@ static void rna_def_proxy(StructRNA *srna)
RNA_def_property_ui_text(
prop, "Use Proxy / Timecode", "Use a preview proxy and/or time-code index for this strip");
RNA_def_property_boolean_funcs(prop, NULL, "rna_Sequence_use_proxy_set");
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
+ RNA_def_property_update(
+ prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "strip->proxy");
@@ -2822,7 +2802,7 @@ static void rna_def_speed_control(StructRNA *srna)
prop = RNA_def_property(srna, "use_frame_interpolate", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", SEQ_SPEED_USE_INTERPOLATION);
RNA_def_property_ui_text(
- prop, "Frame interpolation", "Do crossfade blending between current and next frame");
+ prop, "Frame Interpolation", "Do crossfade blending between current and next frame");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
}
@@ -2887,6 +2867,11 @@ static void rna_def_text(StructRNA *srna)
RNA_def_property_ui_text(prop, "Shadow Color", "");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
+ prop = RNA_def_property(srna, "box_color", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "box_color");
+ RNA_def_property_ui_text(prop, "Box Color", "");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
+
prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "loc");
RNA_def_property_ui_text(prop, "Location", "Location of the text");
@@ -2901,6 +2886,14 @@ static void rna_def_text(StructRNA *srna)
RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1);
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
+ prop = RNA_def_property(srna, "box_margin", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "box_margin");
+ RNA_def_property_ui_text(prop, "Box Margin", "Box margin as factor of image width");
+ RNA_def_property_range(prop, 0, 1.0);
+ RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1);
+ RNA_def_property_float_default(prop, 0.01f);
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
+
prop = RNA_def_property(srna, "align_x", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "align");
RNA_def_property_enum_items(prop, text_align_x_items);
@@ -2923,6 +2916,11 @@ static void rna_def_text(StructRNA *srna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_TEXT_SHADOW);
RNA_def_property_ui_text(prop, "Shadow", "Display shadow behind text");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
+
+ prop = RNA_def_property(srna, "use_box", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_TEXT_BOX);
+ RNA_def_property_ui_text(prop, "Shadow", "Display colored box behind text");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
}
static void rna_def_color_mix(StructRNA *srna)
diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c
index e93ca7bc019..9b8386dd1b1 100644
--- a/source/blender/makesrna/intern/rna_sequencer_api.c
+++ b/source/blender/makesrna/intern/rna_sequencer_api.c
@@ -46,12 +46,13 @@
# include "BKE_movieclip.h"
# include "BKE_report.h"
-# include "BKE_sequencer.h"
# include "BKE_sound.h"
# include "IMB_imbuf.h"
# include "IMB_imbuf_types.h"
+# include "SEQ_sequencer.h"
+
# include "WM_api.h"
static void rna_Sequence_update_rnafunc(ID *id, Sequence *self, bool do_data)
@@ -92,7 +93,7 @@ static Sequence *alloc_generic_sequence(
strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
BLI_split_dirfile(file, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
- BKE_sequence_init_colorspace(seq);
+ SEQ_render_init_colorspace(seq);
}
else {
strip->stripdata = NULL;
@@ -476,7 +477,7 @@ void RNA_api_sequence_strip(StructRNA *srna)
RNA_def_function_ui_description(func, "Update the strip dimensions");
parm = RNA_def_boolean(func, "data", false, "Data", "Update strip data");
- func = RNA_def_function(srna, "strip_elem_from_frame", "BKE_sequencer_give_stripelem");
+ func = RNA_def_function(srna, "strip_elem_from_frame", "SEQ_render_give_stripelem");
RNA_def_function_ui_description(func, "Return the strip element from a given frame or None");
parm = RNA_def_int(func,
"frame",
diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c
index 2fb50c2e89e..c5a53d4522d 100644
--- a/source/blender/makesrna/intern/rna_sound.c
+++ b/source/blender/makesrna/intern/rna_sound.c
@@ -29,11 +29,12 @@
#ifdef RNA_RUNTIME
# include "BKE_context.h"
-# include "BKE_sequencer.h"
# include "BKE_sound.h"
# include "DEG_depsgraph.h"
+# include "SEQ_sequencer.h"
+
static void rna_Sound_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
bSound *sound = (bSound *)ptr->data;
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 422252d0e95..dd7cb2bf643 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -29,7 +29,6 @@
#include "BKE_key.h"
#include "BKE_movieclip.h"
#include "BKE_node.h"
-#include "BKE_sequencer.h"
#include "BKE_studiolight.h"
#include "ED_text.h"
@@ -55,6 +54,8 @@
#include "rna_internal.h"
+#include "SEQ_sequencer.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -307,6 +308,22 @@ static const EnumPropertyItem multiview_camera_items[] = {
#undef V3D_S3D_CAMERA_S3D
#undef V3D_S3D_CAMERA_VIEWS
+const EnumPropertyItem rna_enum_fileselect_params_sort_items[] = {
+ {FILE_SORT_ALPHA, "FILE_SORT_ALPHA", ICON_NONE, "Name", "Sort the file list alphabetically"},
+ {FILE_SORT_EXTENSION,
+ "FILE_SORT_EXTENSION",
+ ICON_NONE,
+ "Extension",
+ "Sort the file list by extension/type"},
+ {FILE_SORT_TIME,
+ "FILE_SORT_TIME",
+ ICON_NONE,
+ "Modified Date",
+ "Sort files by modification time"},
+ {FILE_SORT_SIZE, "FILE_SORT_SIZE", ICON_NONE, "Size", "Sort files by size"},
+ {0, NULL, 0, NULL, NULL},
+};
+
#ifndef RNA_RUNTIME
static const EnumPropertyItem stereo3d_eye_items[] = {
{STEREO_LEFT_ID, "LEFT_EYE", ICON_NONE, "Left Eye"},
@@ -463,22 +480,6 @@ static const EnumPropertyItem fileselectparams_recursion_level_items[] = {
{0, NULL, 0, NULL, NULL},
};
-const EnumPropertyItem rna_enum_file_sort_items[] = {
- {FILE_SORT_ALPHA, "FILE_SORT_ALPHA", ICON_NONE, "Name", "Sort the file list alphabetically"},
- {FILE_SORT_EXTENSION,
- "FILE_SORT_EXTENSION",
- ICON_NONE,
- "Extension",
- "Sort the file list by extension/type"},
- {FILE_SORT_TIME,
- "FILE_SORT_TIME",
- ICON_NONE,
- "Modified Date",
- "Sort files by modification time"},
- {FILE_SORT_SIZE, "FILE_SORT_SIZE", ICON_NONE, "Size", "Sort files by size"},
- {0, NULL, 0, NULL, NULL},
-};
-
static const EnumPropertyItem rna_enum_curve_display_handle_items[] = {
{CURVE_HANDLE_NONE, "NONE", 0, "None", ""},
{CURVE_HANDLE_SELECTED, "SELECTED", 0, "Selected", ""},
@@ -2346,8 +2347,8 @@ static void rna_SpaceClipEditor_lock_selection_update(Main *UNUSED(bmain),
{
SpaceClip *sc = (SpaceClip *)(ptr->data);
- sc->xlockof = 0.f;
- sc->ylockof = 0.f;
+ sc->xlockof = 0.0f;
+ sc->ylockof = 0.0f;
}
static void rna_SpaceClipEditor_view_type_update(Main *UNUSED(bmain),
@@ -3049,6 +3050,7 @@ static void rna_def_space_outliner(BlenderRNA *brna)
{SO_FILTER_OB_HIDDEN, "HIDDEN", 0, "Hidden", "Show hidden objects"},
{SO_FILTER_OB_SELECTED, "SELECTED", 0, "Selected", "Show selected objects"},
{SO_FILTER_OB_ACTIVE, "ACTIVE", 0, "Active", "Show only the active object"},
+ {SO_FILTER_OB_SELECTABLE, "SELECTABLE", 0, "Selectable", "Show only selectable objects"},
{0, NULL, 0, NULL, NULL},
};
@@ -3210,7 +3212,7 @@ static void rna_def_space_outliner(BlenderRNA *brna)
prop = RNA_def_property(srna, "filter_id_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "filter_id_type");
RNA_def_property_enum_items(prop, rna_enum_id_type_items);
- RNA_def_property_ui_text(prop, "Filter ID Type", "Data-block type to show");
+ RNA_def_property_ui_text(prop, "Filter by Type", "Data-block type to show");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID);
}
@@ -3714,6 +3716,16 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "wireframe_opacity", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "overlay.wireframe_opacity");
+ RNA_def_property_ui_text(prop,
+ "Wireframe Opacity",
+ "Opacity of the displayed edges "
+ "(1.0 for opaque)");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "show_paint_wire", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay.paint_flag", V3D_OVERLAY_PAINT_WIRE);
RNA_def_property_ui_text(prop, "Show Wire", "Use wireframe display in painting modes");
@@ -5173,19 +5185,10 @@ static void rna_def_space_dopesheet(BlenderRNA *brna)
"(Action and Shape Key Editors only)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL);
- prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SACTION_NODRAWGCOLORS);
- RNA_def_property_ui_text(
- prop,
- "Show Group Colors",
- "Display groups and channels with colors matching their corresponding groups "
- "(pose bones only currently)");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL);
-
prop = RNA_def_property(srna, "show_interpolation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SACTION_SHOW_INTERPOLATION);
RNA_def_property_ui_text(prop,
- "Show Handles And Interpolation",
+ "Show Handles and Interpolation",
"Display keyframe handle types and non-bezier interpolation modes");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL);
@@ -5208,7 +5211,7 @@ static void rna_def_space_dopesheet(BlenderRNA *brna)
/* editing */
prop = RNA_def_property(srna, "use_auto_merge_keyframes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SACTION_NOTRANSKEYCULL);
- RNA_def_property_ui_text(prop, "AutoMerge Keyframes", "Automatically merge nearby keyframes");
+ RNA_def_property_ui_text(prop, "Auto-Merge Keyframes", "Automatically merge nearby keyframes");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL);
prop = RNA_def_property(srna, "use_realtime_update", PROP_BOOLEAN, PROP_NONE);
@@ -5349,14 +5352,6 @@ static void rna_def_space_graph(BlenderRNA *brna)
"(disable for better performance)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
- prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NODRAWGCOLORS);
- RNA_def_property_ui_text(
- prop,
- "Show Group Colors",
- "Display groups and channels with colors matching their corresponding groups");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL);
-
prop = RNA_def_property(srna, "show_markers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_SHOW_MARKERS);
RNA_def_property_ui_text(
@@ -5610,7 +5605,11 @@ static void rna_def_fileselect_idfilter(BlenderRNA *brna)
ICON_GREASEPENCIL,
"Grease Pencil",
"Show Grease pencil data-blocks"},
- {FILTER_ID_GR, "filter_group", ICON_OUTLINER_COLLECTION, "Collections", "Show Collection data-blocks"},
+ {FILTER_ID_GR,
+ "filter_group",
+ ICON_OUTLINER_COLLECTION,
+ "Collections",
+ "Show Collection data-blocks"},
{FILTER_ID_HA, "filter_hair", ICON_HAIR_DATA, "Hairs", "Show/hide Hair data-blocks"},
{FILTER_ID_IM, "filter_image", ICON_IMAGE_DATA, "Images", "Show Image data-blocks"},
{FILTER_ID_LA, "filter_light", ICON_LIGHT_DATA, "Lights", "Show Light data-blocks"},
@@ -5826,7 +5825,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
prop = RNA_def_property(srna, "sort_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "sort");
- RNA_def_property_enum_items(prop, rna_enum_file_sort_items);
+ RNA_def_property_enum_items(prop, rna_enum_fileselect_params_sort_items);
RNA_def_property_ui_text(prop, "Sort", "");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index 4d5f0f6c2fa..fb6d40b3a55 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -1074,8 +1074,8 @@ static void rna_def_texture_stucci(BlenderRNA *brna)
static const EnumPropertyItem prop_stucci_stype[] = {
{TEX_PLASTIC, "PLASTIC", 0, "Plastic", "Use standard stucci"},
- {TEX_WALLIN, "WALL_IN", 0, "Wall in", "Create Dimples"},
- {TEX_WALLOUT, "WALL_OUT", 0, "Wall out", "Create Ridges"},
+ {TEX_WALLIN, "WALL_IN", 0, "Wall In", "Create Dimples"},
+ {TEX_WALLOUT, "WALL_OUT", 0, "Wall Out", "Create Ridges"},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c
index b000565ed09..13b561f9dd6 100644
--- a/source/blender/makesrna/intern/rna_texture_api.c
+++ b/source/blender/makesrna/intern/rna_texture_api.c
@@ -36,7 +36,7 @@
# include "IMB_imbuf.h"
# include "IMB_imbuf_types.h"
# include "RE_pipeline.h"
-# include "RE_shader_ext.h"
+# include "RE_texture.h"
static void texture_evaluate(struct Tex *tex, float value[3], float r_color[4])
{
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 6d90a76a2c0..f9597fdd7af 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -889,38 +889,6 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
- static const EnumPropertyItem refine_items[] = {
- {0, "NONE", 0, "Nothing", "Do not refine camera intrinsics"},
- {REFINE_FOCAL_LENGTH, "FOCAL_LENGTH", 0, "Focal Length", "Refine focal length"},
- {REFINE_FOCAL_LENGTH | REFINE_RADIAL_DISTORTION_K1,
- "FOCAL_LENGTH_RADIAL_K1",
- 0,
- "Focal length, K1",
- "Refine focal length and radial distortion K1"},
- {REFINE_FOCAL_LENGTH | REFINE_RADIAL_DISTORTION_K1 | REFINE_RADIAL_DISTORTION_K2,
- "FOCAL_LENGTH_RADIAL_K1_K2",
- 0,
- "Focal length, K1, K2",
- "Refine focal length and radial distortion K1 and K2"},
- {REFINE_FOCAL_LENGTH | REFINE_PRINCIPAL_POINT | REFINE_RADIAL_DISTORTION_K1 |
- REFINE_RADIAL_DISTORTION_K2,
- "FOCAL_LENGTH_PRINCIPAL_POINT_RADIAL_K1_K2",
- 0,
- "Focal Length, Optical Center, K1, K2",
- "Refine focal length, optical center and radial distortion K1 and K2"},
- {REFINE_FOCAL_LENGTH | REFINE_PRINCIPAL_POINT,
- "FOCAL_LENGTH_PRINCIPAL_POINT",
- 0,
- "Focal Length, Optical Center",
- "Refine focal length and optical center"},
- {REFINE_RADIAL_DISTORTION_K1 | REFINE_RADIAL_DISTORTION_K2,
- "RADIAL_K1_K2",
- 0,
- "K1, K2",
- "Refine radial distortion K1 and K2"},
- {0, NULL, 0, NULL, NULL},
- };
-
srna = RNA_def_struct(brna, "MovieTrackingSettings", NULL);
RNA_def_struct_ui_text(srna, "Movie tracking settings", "Match moving settings");
@@ -943,11 +911,35 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
"Automatically select keyframes when solving camera/object motion");
/* intrinsics refinement during bundle adjustment */
- prop = RNA_def_property(srna, "refine_intrinsics", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "refine_camera_intrinsics");
+
+ prop = RNA_def_property(srna, "refine_intrinsics_focal_length", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "refine_camera_intrinsics", REFINE_FOCAL_LENGTH);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_enum_items(prop, refine_items);
- RNA_def_property_ui_text(prop, "Refine", "Refine intrinsics during camera solving");
+ RNA_def_property_ui_text(
+ prop, "Refine Focal Length", "Refine focal length during camera solving");
+
+ prop = RNA_def_property(srna, "refine_intrinsics_principal_point", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "refine_camera_intrinsics", REFINE_PRINCIPAL_POINT);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(
+ prop, "Refine Principal Point", "Refine principal point during camera solving");
+
+ prop = RNA_def_property(srna, "refine_intrinsics_radial_distortion", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "refine_camera_intrinsics", REFINE_RADIAL_DISTORTION);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop,
+ "Refine Radial",
+ "Refine radial coefficients of distortion model during camera solving");
+
+ prop = RNA_def_property(
+ srna, "refine_intrinsics_tangential_distortion", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(
+ prop, NULL, "refine_camera_intrinsics", REFINE_TANGENTIAL_DISTORTION);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(
+ prop,
+ "Refine Tangential",
+ "Refine tangential coefficients of distortion model during camera solving");
/* tool settings */
@@ -1194,7 +1186,7 @@ static void rna_def_trackingCamera(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "focal");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.0f, 5000.f, 1, 2);
+ RNA_def_property_ui_range(prop, 0.0f, 5000.0f, 1, 2);
RNA_def_property_ui_text(prop, "Focal Length", "Camera's focal length");
RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL);
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index d87b3a6386e..51cc178ab15 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -26,6 +26,7 @@
#include "BLT_translation.h"
#include "BKE_idprop.h"
+#include "BKE_screen.h"
#include "BLI_listbase.h"
@@ -375,7 +376,7 @@ static StructRNA *rna_Panel_register(Main *bmain,
for (; pt_iter; pt_iter = pt_iter->prev) {
/* No header has priority. */
- if ((pt->flag & PNL_NO_HEADER) && !(pt_iter->flag & PNL_NO_HEADER)) {
+ if ((pt->flag & PANEL_TYPE_NO_HEADER) && !(pt_iter->flag & PANEL_TYPE_NO_HEADER)) {
continue;
}
if (pt_iter->order <= pt->order) {
@@ -1299,29 +1300,29 @@ static void rna_def_panel(BlenderRNA *brna)
FunctionRNA *func;
static const EnumPropertyItem panel_flag_items[] = {
- {PNL_DEFAULT_CLOSED,
+ {PANEL_TYPE_DEFAULT_CLOSED,
"DEFAULT_CLOSED",
0,
"Default Closed",
"Defines if the panel has to be open or collapsed at the time of its creation"},
- {PNL_NO_HEADER,
+ {PANEL_TYPE_NO_HEADER,
"HIDE_HEADER",
0,
"Hide Header",
"If set to False, the panel shows a header, which contains a clickable "
"arrow to collapse the panel and the label (see bl_label)"},
- {PNL_INSTANCED,
+ {PANEL_TYPE_INSTANCED,
"INSTANCED",
0,
"Instanced Panel",
"Multiple panels with this type can be used as part of a list depending on data external "
"to the UI. Used to create panels for the modifiers and other stacks"},
- {PNL_LAYOUT_HEADER_EXPAND,
+ {PANEL_TYPE_HEADER_EXPAND,
"HEADER_LAYOUT_EXPAND",
0,
"Expand Header Layout",
"Allow buttons in the header to stretch and shrink to fill the entire layout width"},
- {PNL_DRAW_BOX, "DRAW_BOX", 0, "Box Style", "Draw panel with the box widget theme"},
+ {PANEL_TYPE_DRAW_BOX, "DRAW_BOX", 0, "Box Style", "Draw panel with the box widget theme"},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index c31766efe58..6ddc2e3ef57 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -217,9 +217,10 @@ static void rna_userdef_version_get(PointerRNA *ptr, int *value)
value[2] = userdef->subversionfile;
}
+/** Mark the preferences as being changed so they are saved on exit. */
# define USERDEF_TAG_DIRTY rna_userdef_is_dirty_update_impl()
-/* Use single function so we can more easily breakpoint it. */
+/** Use single function so we can more easily break-point it. */
void rna_userdef_is_dirty_update_impl(void)
{
/* We can't use 'ptr->data' because this update function
@@ -408,6 +409,15 @@ static void rna_userdef_autokeymode_set(PointerRNA *ptr, int value)
}
}
+static void rna_userdef_anim_update(Main *UNUSED(bmain),
+ Scene *UNUSED(scene),
+ PointerRNA *UNUSED(ptr))
+{
+ WM_main_add_notifier(NC_SPACE | ND_SPACE_GRAPH, NULL);
+ WM_main_add_notifier(NC_SPACE | ND_SPACE_DOPESHEET, NULL);
+ USERDEF_TAG_DIRTY;
+}
+
static void rna_userdef_tablet_api_update(Main *UNUSED(bmain),
Scene *UNUSED(scene),
PointerRNA *UNUSED(ptr))
@@ -4222,7 +4232,7 @@ static void rna_def_userdef_solidlight(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
- static float default_dir[3] = {0.f, 0.f, 1.f};
+ static float default_dir[3] = {0.0f, 0.0f, 1.0f};
static float default_col[3] = {0.8f, 0.8f, 0.8f};
srna = RNA_def_struct(brna, "UserSolidLight", NULL);
@@ -4283,26 +4293,26 @@ static void rna_def_userdef_walk_navigation(BlenderRNA *brna)
"Speed factor for when looking around, high values mean faster mouse movement");
prop = RNA_def_property(srna, "walk_speed", PROP_FLOAT, PROP_VELOCITY);
- RNA_def_property_range(prop, 0.01f, 100.f);
+ RNA_def_property_range(prop, 0.01f, 100.0f);
RNA_def_property_ui_text(prop, "Walk Speed", "Base speed for walking and flying");
prop = RNA_def_property(srna, "walk_speed_factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.01f, 10.f);
+ RNA_def_property_range(prop, 0.01f, 10.0f);
RNA_def_property_ui_text(
prop, "Speed Factor", "Multiplication factor when using the fast or slow modifiers");
prop = RNA_def_property(srna, "view_height", PROP_FLOAT, PROP_UNIT_LENGTH);
- RNA_def_property_ui_range(prop, 0.1f, 10.f, 0.1, 2);
- RNA_def_property_range(prop, 0.f, 1000.f);
+ RNA_def_property_ui_range(prop, 0.1f, 10.0f, 0.1, 2);
+ RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "View Height", "View distance from the floor when walking");
prop = RNA_def_property(srna, "jump_height", PROP_FLOAT, PROP_UNIT_LENGTH);
- RNA_def_property_ui_range(prop, 0.1f, 10.f, 0.1, 2);
- RNA_def_property_range(prop, 0.1f, 100.f);
+ RNA_def_property_ui_range(prop, 0.1f, 10.0f, 0.1, 2);
+ RNA_def_property_range(prop, 0.1f, 100.0f);
RNA_def_property_ui_text(prop, "Jump Height", "Maximum height of a jump");
prop = RNA_def_property(srna, "teleport_time", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.f, 10.f);
+ RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(
prop, "Teleport Duration", "Interval of time warp when teleporting in navigation mode");
@@ -4389,7 +4399,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
static const EnumPropertyItem line_width[] = {
{-1, "THIN", 0, "Thin", "Thinner lines than the default"},
- {0, "AUTO", 0, "Auto", "Automatic line width based on UI scale"},
+ {0, "AUTO", 0, "Default", "Automatic line width based on UI scale"},
{1, "THICK", 0, "Thick", "Thicker lines than the default"},
{0, NULL, 0, NULL, NULL},
};
@@ -4403,7 +4413,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
{USER_RENDER_DISPLAY_SCREEN,
"SCREEN",
0,
- "Full Screen",
+ "Maximized Area",
"Images are rendered in a maximized Image Editor"},
{USER_RENDER_DISPLAY_AREA,
"AREA",
@@ -4421,7 +4431,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
{USER_TEMP_SPACE_DISPLAY_FULLSCREEN,
"SCREEN", /* Could be FULLSCREEN, but keeping it consistent with render_display_types */
0,
- "Full Screen",
+ "Maximized Area",
"Open the temporary editor in a maximized screen"},
{USER_TEMP_SPACE_DISPLAY_WINDOW,
"WINDOW",
@@ -4453,8 +4463,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_ui_text(
prop,
"UI Line Width",
- "Changes the thickness of widget outlines, lines and points in the interface, "
- "for high DPI displays");
+ "Changes the thickness of widget outlines, lines and dots in the interface");
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
/* display */
@@ -4786,7 +4795,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
prop = RNA_def_property(srna, "font_path_ui_mono", PROP_STRING, PROP_FILEPATH);
RNA_def_property_string_sdna(prop, NULL, "font_path_ui_mono");
- RNA_def_property_ui_text(prop, "Mono-space Font", "Path to interface mono-space Font");
+ RNA_def_property_ui_text(prop, "Monospaced Font", "Path to interface monospaced Font");
RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_font_update");
/* Language. */
@@ -4994,6 +5003,15 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
"Color for newly added transformation F-Curves (Location, Rotation, Scale) "
"and also Color is based on the transform axis");
+ prop = RNA_def_property(srna, "use_anim_channel_group_colors", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "animation_flag", USER_ANIM_SHOW_CHANNEL_GROUP_COLORS);
+ RNA_def_property_ui_text(
+ prop,
+ "Channel Group Colors",
+ "Use animation channel group colors; generally this is used to show bone group colors");
+ RNA_def_property_boolean_default(prop, true);
+ RNA_def_property_update(prop, 0, "rna_userdef_anim_update");
+
prop = RNA_def_property(srna, "fcurve_new_auto_smoothing", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_fcurve_auto_smoothing_items);
RNA_def_property_enum_sdna(prop, NULL, "auto_smoothing_new");
@@ -5659,13 +5677,6 @@ static void rna_def_userdef_input(BlenderRNA *brna)
"Auto Depth",
"Use the depth under the mouse to improve view pan/rotate/zoom functionality");
- prop = RNA_def_property(srna, "use_camera_lock_parent", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "uiflag", USER_CAM_LOCK_NO_PARENT);
- RNA_def_property_ui_text(prop,
- "Camera Parent Lock",
- "When the camera is locked to the view and in fly mode, "
- "transform the parent rather than the camera");
-
/* view zoom */
prop = RNA_def_property(srna, "use_zoom_to_mouse", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_TO_MOUSEPOS);
@@ -5784,10 +5795,8 @@ static void rna_def_userdef_input(BlenderRNA *brna)
prop = RNA_def_property(srna, "tablet_api", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, tablet_api);
- RNA_def_property_ui_text(prop,
- "Tablet API",
- "Select the tablet API to use for pressure sensitivity (restart "
- "Blender for changes to take effect)");
+ RNA_def_property_ui_text(
+ prop, "Tablet API", "Select the tablet API to use for pressure sensitivity");
RNA_def_property_update(prop, 0, "rna_userdef_tablet_api_update");
# ifdef WITH_INPUT_NDOF
@@ -5927,13 +5936,6 @@ static void rna_def_userdef_input(BlenderRNA *brna)
RNA_def_property_range(prop, 0, 32);
RNA_def_property_ui_text(
prop, "Wheel Scroll Lines", "Number of lines scrolled at a time with the mouse wheel");
-
- prop = RNA_def_property(srna, "use_trackpad_natural", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_TRACKPAD_NATURAL);
- RNA_def_property_ui_text(prop,
- "Trackpad Natural",
- "If your system uses 'natural' scrolling, this option keeps consistent "
- "trackpad usage throughout the UI");
}
static void rna_def_userdef_keymap(BlenderRNA *brna)
@@ -6179,6 +6181,11 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
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");
+
+ prop = RNA_def_property(srna, "use_object_add_tool", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "use_object_add_tool", 1);
+ RNA_def_property_ui_text(
+ prop, "Add Object Tool", "Show add object tool in the toolbar in Object Mode and Edit Mode");
}
static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop)
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 2cabc89feee..2c373eb8d46 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -1135,7 +1135,7 @@ void RNA_api_keymapitems(StructRNA *srna)
RNA_def_boolean(func, "alt", 0, "Alt", "");
RNA_def_boolean(func, "oskey", 0, "OS Key", "");
RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
- RNA_def_boolean(func, "repeat", true, "Repeat", "When set, accept key-repeat events");
+ RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
RNA_def_boolean(func,
"head",
0,
@@ -1159,7 +1159,7 @@ void RNA_api_keymapitems(StructRNA *srna)
RNA_def_boolean(func, "alt", 0, "Alt", "");
RNA_def_boolean(func, "oskey", 0, "OS Key", "");
RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
- RNA_def_boolean(func, "repeat", true, "Repeat", "When set, accept key-repeat events");
+ RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
RNA_def_function_return(func, parm);
diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c
index 27d46e4d25b..bb2f57dc723 100644
--- a/source/blender/makesrna/intern/rna_wm_gizmo.c
+++ b/source/blender/makesrna/intern/rna_wm_gizmo.c
@@ -558,6 +558,7 @@ static StructRNA *rna_Gizmo_refine(PointerRNA *mnp_ptr)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Gizmo Group API
* \{ */
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 65024e46a2b..549751ce267 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -31,7 +31,7 @@ set(INC
../editors/include
../makesdna
../makesrna
- ../render/extern/include
+ ../render
../windowmanager
../../../intern/eigen
../../../intern/guardedalloc
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index 324cac3df8b..38fb19e3233 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -258,7 +258,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
uiItemR(col, ptr, "use_deform_preserve_volume", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "use_multi_modifier", 0, NULL, ICON_NONE);
- col = uiLayoutColumnWithHeading(layout, true, IFACE_("Bind to"));
+ col = uiLayoutColumnWithHeading(layout, true, IFACE_("Bind To"));
uiItemR(col, ptr, "use_vertex_groups", 0, IFACE_("Vertex Groups"), ICON_NONE);
uiItemR(col, ptr, "use_bone_envelopes", 0, IFACE_("Bone Envelopes"), ICON_NONE);
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 7e21300f3c2..da1754b8ebd 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -69,7 +69,7 @@ static void initData(ModifierData *md)
MEMCPY_STRUCT_AFTER(amd, DNA_struct_default_get(ArrayModifierData), modifier);
/* Open the first subpanel by default, it corresspnds to Relative offset which is enabled too. */
- md->ui_expand_flag = (1 << 0) | (1 << 1);
+ md->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT | UI_SUBPANEL_DATA_EXPAND_1;
}
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
@@ -481,7 +481,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
/* calculate the maximum number of copies which will fit within the
* prescribed length */
- if (amd->fit_type == MOD_ARR_FITLENGTH || amd->fit_type == MOD_ARR_FITCURVE) {
+ if (ELEM(amd->fit_type, MOD_ARR_FITLENGTH, MOD_ARR_FITCURVE)) {
const float float_epsilon = 1e-6f;
bool offset_is_too_small = false;
float dist = len_v3(offset[3]);
@@ -508,6 +508,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
if (offset_is_too_small) {
BKE_modifier_set_error(
+ ctx->object,
&amd->modifier,
"The offset is too small, we cannot generate the amount of geometry it would require");
}
@@ -518,7 +519,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
else if (((size_t)count * (size_t)chunk_nverts + (size_t)start_cap_nverts +
(size_t)end_cap_nverts) > max_num_vertices) {
count = 1;
- BKE_modifier_set_error(&amd->modifier,
+ BKE_modifier_set_error(ctx->object,
+ &amd->modifier,
"The amount of copies is too high, we cannot generate the amount of "
"geometry it would require");
}
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index b84c8a186b5..04ddac338e5 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -208,7 +208,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
Object *ob = ctx->object;
if (harden_normals && (ob->type == OB_MESH) && !(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH)) {
- BKE_modifier_set_error(md, "Enable 'Auto Smooth' in Object Data Properties");
+ BKE_modifier_set_error(ob, md, "Enable 'Auto Smooth' in Object Data Properties");
harden_normals = false;
}
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 8d0c7cd6d49..124ef950385 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -189,7 +189,7 @@ static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data))
return BM_elem_flag_test(f, BM_FACE_TAG) ? 1 : 0;
}
-static bool BMD_error_messages(ModifierData *md, Collection *col)
+static bool BMD_error_messages(const Object *ob, ModifierData *md, Collection *col)
{
BooleanModifierData *bmd = (BooleanModifierData *)md;
@@ -202,21 +202,21 @@ static bool BMD_error_messages(ModifierData *md, Collection *col)
#ifndef WITH_GMP
/* If compiled without GMP, return a error. */
if (use_exact) {
- BKE_modifier_set_error(md, "Compiled without GMP, using fast solver");
+ BKE_modifier_set_error(ob, md, "Compiled without GMP, using fast solver");
error_returns_result = false;
}
#endif
/* If intersect is selected using fast solver, return a error. */
if (operand_collection && operation_intersect && !use_exact) {
- BKE_modifier_set_error(md, "Cannot execute, intersect only available using exact solver");
+ BKE_modifier_set_error(ob, md, "Cannot execute, intersect only available using exact solver");
error_returns_result = true;
}
/* If the selected collection is empty and using fast solver, return a error. */
if (operand_collection) {
if (!use_exact && BKE_collection_is_empty(col)) {
- BKE_modifier_set_error(md, "Cannot execute, fast solver and empty collection");
+ BKE_modifier_set_error(ob, md, "Cannot execute, fast solver and empty collection");
error_returns_result = true;
}
@@ -225,7 +225,7 @@ static bool BMD_error_messages(ModifierData *md, Collection *col)
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (col, operand_ob) {
if (operand_ob->type != OB_MESH) {
BKE_modifier_set_error(
- md, "Cannot execute, the selected collection contains non mesh objects");
+ ob, md, "Cannot execute, the selected collection contains non mesh objects");
error_returns_result = true;
}
}
@@ -623,7 +623,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
return result;
}
- BMD_error_messages(md, NULL);
+ BMD_error_messages(ctx->object, md, NULL);
Object *operand_ob = bmd->object;
@@ -651,7 +651,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* if new mesh returned, return it; otherwise there was
* an error, so delete the modifier object */
if (result == NULL) {
- BKE_modifier_set_error(md, "Cannot execute boolean operation");
+ BKE_modifier_set_error(object, md, "Cannot execute boolean operation");
}
}
}
@@ -662,7 +662,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
/* Return result for certain errors. */
- if (BMD_error_messages(md, col) == confirm_return) {
+ if (BMD_error_messages(ctx->object, md, col) == confirm_return) {
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index eaf8c44a9be..5884ec0aa17 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -615,7 +615,7 @@ static void correctivesmooth_modifier_do(ModifierData *md,
csmd_orig->bind_coords_num = csmd->bind_coords_num;
}
else {
- BKE_modifier_set_error(md, "Attempt to bind from inactive dependency graph");
+ BKE_modifier_set_error(ob, md, "Attempt to bind from inactive dependency graph");
}
}
@@ -625,7 +625,7 @@ static void correctivesmooth_modifier_do(ModifierData *md,
}
if ((csmd->rest_source == MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND) && (csmd->bind_coords == NULL)) {
- BKE_modifier_set_error(md, "Bind data required");
+ BKE_modifier_set_error(ob, md, "Bind data required");
goto error;
}
@@ -633,14 +633,14 @@ static void correctivesmooth_modifier_do(ModifierData *md,
if (csmd->rest_source == MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND) {
if (csmd->bind_coords_num != numVerts) {
BKE_modifier_set_error(
- md, "Bind vertex count mismatch: %u to %u", csmd->bind_coords_num, numVerts);
+ ob, md, "Bind vertex count mismatch: %u to %u", csmd->bind_coords_num, numVerts);
goto error;
}
}
else {
/* MOD_CORRECTIVESMOOTH_RESTSOURCE_ORCO */
if (ob->type != OB_MESH) {
- BKE_modifier_set_error(md, "Object is not a mesh");
+ BKE_modifier_set_error(ob, md, "Object is not a mesh");
goto error;
}
else {
@@ -648,7 +648,7 @@ static void correctivesmooth_modifier_do(ModifierData *md,
if (me_numVerts != numVerts) {
BKE_modifier_set_error(
- md, "Original vertex count mismatch: %u to %u", me_numVerts, numVerts);
+ ob, md, "Original vertex count mismatch: %u to %u", me_numVerts, numVerts);
goto error;
}
}
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index d841ace2cce..d4c941d144d 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -232,16 +232,19 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
if (BKE_reports_contain(&reports, RPT_ERROR)) {
const char *report_str = BKE_reports_string(&reports, RPT_ERROR);
- BKE_modifier_set_error(md, "%s", report_str);
+ BKE_modifier_set_error(ctx->object, md, "%s", report_str);
MEM_freeN((void *)report_str);
}
else if ((dtmd->data_types & DT_TYPE_LNOR) && !(me->flag & ME_AUTOSMOOTH)) {
- BKE_modifier_set_error((ModifierData *)dtmd, "Enable 'Auto Smooth' in Object Data Properties");
+ BKE_modifier_set_error(
+ ctx->object, (ModifierData *)dtmd, "Enable 'Auto Smooth' in Object Data Properties");
}
else if (result->totvert > HIGH_POLY_WARNING ||
((Mesh *)(ob_source->data))->totvert > HIGH_POLY_WARNING) {
BKE_modifier_set_error(
- md, "Source or destination object has a high polygon count, computation might be slow");
+ ctx->object,
+ md,
+ "Source or destination object has a high polygon count, computation might be slow");
}
return result;
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index 2532afc933e..10ed4f8d80b 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -140,7 +140,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
if (dmd->face_count <= 3) {
- BKE_modifier_set_error(md, "Modifier requires more than 3 input faces");
+ BKE_modifier_set_error(ctx->object, md, "Modifier requires more than 3 input faces");
return mesh;
}
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index efd46f53eb6..d432559fcfa 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -61,7 +61,7 @@
#include "MOD_ui_common.h"
#include "MOD_util.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
/* Displace */
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 8eb9e97573d..a484b4d8147 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -666,8 +666,7 @@ static void LaplacianDeformModifier_do(
sysdif = isSystemDifferent(lmd, ob, mesh, numVerts);
sys = lmd->cache_system;
if (sysdif) {
- if (sysdif == LAPDEFORM_SYSTEM_ONLY_CHANGE_ANCHORS ||
- sysdif == LAPDEFORM_SYSTEM_ONLY_CHANGE_GROUP) {
+ if (ELEM(sysdif, LAPDEFORM_SYSTEM_ONLY_CHANGE_ANCHORS, LAPDEFORM_SYSTEM_ONLY_CHANGE_GROUP)) {
filevertexCos = MEM_malloc_arrayN(numVerts, sizeof(float[3]), "TempModDeformCoordinates");
memcpy(filevertexCos, lmd->vertexco, sizeof(float[3]) * numVerts);
MEM_SAFE_FREE(lmd->vertexco);
@@ -684,14 +683,15 @@ static void LaplacianDeformModifier_do(
else {
if (sysdif == LAPDEFORM_SYSTEM_CHANGE_VERTEXES) {
BKE_modifier_set_error(
- &lmd->modifier, "Vertices changed from %d to %d", lmd->total_verts, numVerts);
+ ob, &lmd->modifier, "Vertices changed from %d to %d", lmd->total_verts, numVerts);
}
else if (sysdif == LAPDEFORM_SYSTEM_CHANGE_EDGES) {
BKE_modifier_set_error(
- &lmd->modifier, "Edges changed from %d to %d", sys->total_edges, mesh->totedge);
+ ob, &lmd->modifier, "Edges changed from %d to %d", sys->total_edges, mesh->totedge);
}
else if (sysdif == LAPDEFORM_SYSTEM_CHANGE_NOT_VALID_GROUP) {
- BKE_modifier_set_error(&lmd->modifier,
+ BKE_modifier_set_error(ob,
+ &lmd->modifier,
"Vertex group '%s' is not valid, or maybe empty",
sys->anchor_grp_name);
}
@@ -704,8 +704,10 @@ static void LaplacianDeformModifier_do(
}
else {
if (!isValidVertexGroup(lmd, ob, mesh)) {
- BKE_modifier_set_error(
- &lmd->modifier, "Vertex group '%s' is not valid, or maybe empty", lmd->anchor_grp_name);
+ BKE_modifier_set_error(ob,
+ &lmd->modifier,
+ "Vertex group '%s' is not valid, or maybe empty",
+ lmd->anchor_grp_name);
lmd->flag &= ~MOD_LAPLACIANDEFORM_BIND;
}
else if (lmd->total_verts > 0 && lmd->total_verts == numVerts) {
@@ -725,7 +727,7 @@ static void LaplacianDeformModifier_do(
}
}
if (sys && sys->is_matrix_computed && !sys->has_solution) {
- BKE_modifier_set_error(&lmd->modifier, "The system did not find a solution");
+ BKE_modifier_set_error(ob, &lmd->modifier, "The system did not find a solution");
}
}
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index f7a8faf7a1c..d51f95bd18d 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -82,7 +82,7 @@ struct BLaplacianSystem {
typedef struct BLaplacianSystem LaplacianSystem;
static void required_data_mask(Object *ob, ModifierData *md, CustomData_MeshMasks *r_cddata_masks);
-static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, bool useRenderParams);
+static bool is_disabled(const struct Scene *scene, ModifierData *md, bool useRenderParams);
static float compute_volume(const float center[3],
float (*vertexCos)[3],
const MPoly *mpoly,
diff --git a/source/blender/modifiers/intern/MOD_mask.cc b/source/blender/modifiers/intern/MOD_mask.cc
index 78d44179ca1..92ee5a84df9 100644
--- a/source/blender/modifiers/intern/MOD_mask.cc
+++ b/source/blender/modifiers/intern/MOD_mask.cc
@@ -322,7 +322,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* Return empty or input mesh when there are no vertex groups. */
MDeformVert *dvert = (MDeformVert *)CustomData_get_layer(&mesh->vdata, CD_MDEFORMVERT);
- if (dvert == NULL) {
+ if (dvert == nullptr) {
return invert_mask ? mesh : BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0, 0);
}
@@ -418,13 +418,13 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
int mode = RNA_enum_get(ptr, "mode");
- uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
uiLayoutSetPropSep(layout, true);
if (mode == MOD_MASK_MODE_ARM) {
row = uiLayoutRow(layout, true);
- uiItemR(row, ptr, "armature", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "armature", 0, nullptr, ICON_NONE);
sub = uiLayoutRow(row, true);
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, ptr, "invert_vertex_group", 0, "", ICON_ARROW_LEFTRIGHT);
@@ -433,7 +433,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr);
}
- uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "threshold", 0, nullptr, ICON_NONE);
modifier_panel_end(layout, ptr);
}
@@ -456,26 +456,26 @@ ModifierTypeInfo modifierType_Mask = {
/* copyData */ BKE_modifier_copydata_generic,
- /* deformVerts */ NULL,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
- /* deformMatricesEM */ NULL,
+ /* deformVerts */ nullptr,
+ /* deformMatrices */ nullptr,
+ /* deformVertsEM */ nullptr,
+ /* deformMatricesEM */ nullptr,
/* modifyMesh */ modifyMesh,
- /* modifyHair */ NULL,
- /* modifyPointCloud */ NULL,
- /* modifyVolume */ NULL,
+ /* modifyHair */ nullptr,
+ /* modifyPointCloud */ nullptr,
+ /* modifyVolume */ nullptr,
/* initData */ initData,
/* requiredDataMask */ requiredDataMask,
- /* freeData */ NULL,
+ /* freeData */ nullptr,
/* isDisabled */ isDisabled,
/* updateDepsgraph */ updateDepsgraph,
- /* dependsOnTime */ NULL,
- /* dependsOnNormals */ NULL,
+ /* dependsOnTime */ nullptr,
+ /* dependsOnNormals */ nullptr,
/* foreachIDLink */ foreachIDLink,
- /* foreachTexLink */ NULL,
- /* freeRuntimeData */ NULL,
+ /* foreachTexLink */ nullptr,
+ /* freeRuntimeData */ nullptr,
/* panelRegister */ panelRegister,
- /* blendWrite */ NULL,
- /* blendRead */ NULL,
+ /* blendWrite */ nullptr,
+ /* blendRead */ nullptr,
};
diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
index cc16da0fa80..61d556a64af 100644
--- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
+++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
@@ -107,7 +107,7 @@ class OpenVDBMeshAdapter {
static void initData(ModifierData *md)
{
MeshToVolumeModifierData *mvmd = reinterpret_cast<MeshToVolumeModifierData *>(md);
- mvmd->object = NULL;
+ mvmd->object = nullptr;
mvmd->resolution_mode = MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT;
mvmd->voxel_size = 0.1f;
mvmd->voxel_amount = 32;
@@ -139,32 +139,32 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *layout = panel->layout;
- PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
MeshToVolumeModifierData *mvmd = static_cast<MeshToVolumeModifierData *>(ptr->data);
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
- uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "density", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "object", 0, nullptr, ICON_NONE);
+ uiItemR(layout, ptr, "density", 0, nullptr, ICON_NONE);
{
uiLayout *col = uiLayoutColumn(layout, false);
- uiItemR(col, ptr, "use_fill_volume", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "exterior_band_width", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "use_fill_volume", 0, nullptr, ICON_NONE);
+ uiItemR(col, ptr, "exterior_band_width", 0, nullptr, ICON_NONE);
uiLayout *subcol = uiLayoutColumn(col, false);
uiLayoutSetActive(subcol, !mvmd->fill_volume);
- uiItemR(subcol, ptr, "interior_band_width", 0, NULL, ICON_NONE);
+ uiItemR(subcol, ptr, "interior_band_width", 0, nullptr, ICON_NONE);
}
{
uiLayout *col = uiLayoutColumn(layout, false);
- uiItemR(col, ptr, "resolution_mode", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "resolution_mode", 0, nullptr, ICON_NONE);
if (mvmd->resolution_mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT) {
- uiItemR(col, ptr, "voxel_amount", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "voxel_amount", 0, nullptr, ICON_NONE);
}
else {
- uiItemR(col, ptr, "voxel_size", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "voxel_size", 0, nullptr, ICON_NONE);
}
}
@@ -213,11 +213,11 @@ static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, Vo
MeshToVolumeModifierData *mvmd = reinterpret_cast<MeshToVolumeModifierData *>(md);
Object *object_to_convert = mvmd->object;
- if (object_to_convert == NULL) {
+ if (object_to_convert == nullptr) {
return input_volume;
}
Mesh *mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(object_to_convert, false);
- if (mesh == NULL) {
+ if (mesh == nullptr) {
return input_volume;
}
BKE_mesh_wrapper_ensure_mdata(mesh);
@@ -273,8 +273,8 @@ static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, Vo
return volume;
#else
- UNUSED_VARS(md, ctx);
- BKE_modifier_set_error(md, "Compiled without OpenVDB");
+ UNUSED_VARS(md);
+ BKE_modifier_set_error(ctx->object, md, "Compiled without OpenVDB");
return input_volume;
#endif
}
@@ -290,26 +290,26 @@ ModifierTypeInfo modifierType_MeshToVolume = {
/* copyData */ BKE_modifier_copydata_generic,
- /* deformVerts */ NULL,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
- /* deformMatricesEM */ NULL,
- /* modifyMesh */ NULL,
- /* modifyHair */ NULL,
- /* modifyPointCloud */ NULL,
+ /* deformVerts */ nullptr,
+ /* deformMatrices */ nullptr,
+ /* deformVertsEM */ nullptr,
+ /* deformMatricesEM */ nullptr,
+ /* modifyMesh */ nullptr,
+ /* modifyHair */ nullptr,
+ /* modifyPointCloud */ nullptr,
/* modifyVolume */ modifyVolume,
/* initData */ initData,
- /* requiredDataMask */ NULL,
- /* freeData */ NULL,
- /* isDisabled */ NULL,
+ /* requiredDataMask */ nullptr,
+ /* freeData */ nullptr,
+ /* isDisabled */ nullptr,
/* updateDepsgraph */ updateDepsgraph,
- /* dependsOnTime */ NULL,
- /* dependsOnNormals */ NULL,
+ /* dependsOnTime */ nullptr,
+ /* dependsOnNormals */ nullptr,
/* foreachIDLink */ foreachIDLink,
- /* foreachTexLink */ NULL,
- /* freeRuntimeData */ NULL,
+ /* foreachTexLink */ nullptr,
+ /* freeRuntimeData */ nullptr,
/* panelRegister */ panelRegister,
- /* blendWrite */ NULL,
- /* blendRead */ NULL,
+ /* blendWrite */ nullptr,
+ /* blendRead */ nullptr,
};
diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c
index 5d5b8b847d5..b808d738fe8 100644
--- a/source/blender/modifiers/intern/MOD_meshcache.c
+++ b/source/blender/modifiers/intern/MOD_meshcache.c
@@ -171,13 +171,13 @@ static void meshcache_do(MeshCacheModifierData *mcmd,
/* we could support any object type */
if (UNLIKELY(ob->type != OB_MESH)) {
- BKE_modifier_set_error(&mcmd->modifier, "'Integrate' only valid for Mesh objects");
+ BKE_modifier_set_error(ob, &mcmd->modifier, "'Integrate' only valid for Mesh objects");
}
else if (UNLIKELY(me->totvert != numVerts)) {
- BKE_modifier_set_error(&mcmd->modifier, "'Integrate' original mesh vertex mismatch");
+ BKE_modifier_set_error(ob, &mcmd->modifier, "'Integrate' original mesh vertex mismatch");
}
else if (UNLIKELY(me->totpoly == 0)) {
- BKE_modifier_set_error(&mcmd->modifier, "'Integrate' requires faces");
+ BKE_modifier_set_error(ob, &mcmd->modifier, "'Integrate' requires faces");
}
else {
/* the moons align! */
@@ -216,7 +216,7 @@ static void meshcache_do(MeshCacheModifierData *mcmd,
/* -------------------------------------------------------------------- */
/* Apply the transformation matrix (if needed) */
if (UNLIKELY(err_str)) {
- BKE_modifier_set_error(&mcmd->modifier, "%s", err_str);
+ BKE_modifier_set_error(ob, &mcmd->modifier, "%s", err_str);
}
else if (ok) {
bool use_matrix = false;
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index e2c8db07623..0e530312238 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -373,7 +373,7 @@ static void meshdeformModifier_do(ModifierData *md,
Object *ob_target = mmd->object;
cagemesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false);
if (cagemesh == NULL) {
- BKE_modifier_set_error(md, "Cannot get mesh from cage object");
+ BKE_modifier_set_error(ctx->object, md, "Cannot get mesh from cage object");
return;
}
@@ -388,7 +388,7 @@ static void meshdeformModifier_do(ModifierData *md,
if (!mmd->bindcagecos) {
/* progress bar redraw can make this recursive .. */
if (!DEG_is_active(ctx->depsgraph)) {
- BKE_modifier_set_error(md, "Attempt to bind from inactive dependency graph");
+ BKE_modifier_set_error(ob, md, "Attempt to bind from inactive dependency graph");
goto finally;
}
if (!recursive_bind_sentinel) {
@@ -405,16 +405,16 @@ static void meshdeformModifier_do(ModifierData *md,
totcagevert = BKE_mesh_wrapper_vert_len(cagemesh);
if (mmd->totvert != totvert) {
- BKE_modifier_set_error(md, "Vertices changed from %d to %d", mmd->totvert, totvert);
+ BKE_modifier_set_error(ob, md, "Vertices changed from %d to %d", mmd->totvert, totvert);
goto finally;
}
else if (mmd->totcagevert != totcagevert) {
BKE_modifier_set_error(
- md, "Cage vertices changed from %d to %d", mmd->totcagevert, totcagevert);
+ ob, md, "Cage vertices changed from %d to %d", mmd->totcagevert, totcagevert);
goto finally;
}
else if (mmd->bindcagecos == NULL) {
- BKE_modifier_set_error(md, "Bind data missing");
+ BKE_modifier_set_error(ob, md, "Bind data missing");
goto finally;
}
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index 70732636d02..73106b2e816 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -127,7 +127,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
BKE_cachefile_reader_open(cache_file, &mcmd->reader, ctx->object, mcmd->object_path);
if (!mcmd->reader) {
BKE_modifier_set_error(
- md, "Could not create Alembic reader for file %s", cache_file->filepath);
+ ctx->object, md, "Could not create Alembic reader for file %s", cache_file->filepath);
return mesh;
}
}
@@ -170,7 +170,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
if (err_str) {
- BKE_modifier_set_error(md, "%s", err_str);
+ BKE_modifier_set_error(ctx->object, md, "%s", err_str);
}
if (!ELEM(result, NULL, mesh) && (mesh != org_mesh)) {
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index e3a8d651183..9f99e036601 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -74,7 +74,7 @@ static void initData(ModifierData *md)
MEMCPY_STRUCT_AFTER(mmd, DNA_struct_default_get(MultiresModifierData), modifier);
/* Open subdivision panels by default. */
- md->ui_expand_flag = (1 << 0) | (1 << 1);
+ md->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT | UI_SUBPANEL_DATA_EXPAND_1;
}
static void requiredDataMask(Object *UNUSED(ob),
@@ -216,7 +216,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
{
Mesh *result = mesh;
#if !defined(WITH_OPENSUBDIV)
- BKE_modifier_set_error(md, "Disabled, built without OpenSubdiv");
+ BKE_modifier_set_error(ctx->object, md, "Disabled, built without OpenSubdiv");
return result;
#endif
MultiresModifierData *mmd = (MultiresModifierData *)md;
@@ -300,7 +300,7 @@ static void deformMatrices(ModifierData *md,
{
#if !defined(WITH_OPENSUBDIV)
- BKE_modifier_set_error(md, "Disabled, built without OpenSubdiv");
+ BKE_modifier_set_error(ctx->object, md, "Disabled, built without OpenSubdiv");
return;
#endif
@@ -478,7 +478,6 @@ static void advanced_panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayoutSetActive(layout, !has_displacement);
- uiItemR(layout, ptr, "subdivision_type", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "quality", 0, NULL, ICON_NONE);
col = uiLayoutColumn(layout, false);
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 1be74a8fed2..0ec564d2e2d 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -476,7 +476,15 @@ static bool is_valid_target(NormalEditModifierData *enmd)
if ((enmd->mode == MOD_NORMALEDIT_MODE_DIRECTIONAL) && enmd->target) {
return true;
}
- BKE_modifier_set_error((ModifierData *)enmd, "Invalid target settings");
+ return false;
+}
+
+static bool is_valid_target_with_error(const Object *ob, NormalEditModifierData *enmd)
+{
+ if (is_valid_target(enmd)) {
+ return true;
+ }
+ BKE_modifier_set_error(ob, (ModifierData *)enmd, "Invalid target settings");
return false;
}
@@ -491,7 +499,7 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
(enmd->mix_limit == (float)M_PI));
/* Do not run that modifier at all if autosmooth is disabled! */
- if (!is_valid_target(enmd) || mesh->totloop == 0) {
+ if (!is_valid_target_with_error(ctx->object, enmd) || mesh->totloop == 0) {
return mesh;
}
@@ -506,7 +514,8 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH))
#endif
{
- BKE_modifier_set_error((ModifierData *)enmd, "Enable 'Auto Smooth' in Object Data Properties");
+ BKE_modifier_set_error(
+ ob, (ModifierData *)enmd, "Enable 'Auto Smooth' in Object Data Properties");
return mesh;
}
diff --git a/source/blender/modifiers/intern/MOD_simulation.cc b/source/blender/modifiers/intern/MOD_simulation.cc
index 10a4b3f7cf9..0766c59cda6 100644
--- a/source/blender/modifiers/intern/MOD_simulation.cc
+++ b/source/blender/modifiers/intern/MOD_simulation.cc
@@ -169,25 +169,25 @@ ModifierTypeInfo modifierType_Simulation = {
/* copyData */ copyData,
- /* deformVerts */ NULL,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
- /* deformMatricesEM */ NULL,
- /* modifyMesh */ NULL,
- /* modifyHair */ NULL,
+ /* deformVerts */ nullptr,
+ /* deformMatrices */ nullptr,
+ /* deformVertsEM */ nullptr,
+ /* deformMatricesEM */ nullptr,
+ /* modifyMesh */ nullptr,
+ /* modifyHair */ nullptr,
/* modifyPointCloud */ modifyPointCloud,
- /* modifyVolume */ NULL,
+ /* modifyVolume */ nullptr,
/* initData */ initData,
- /* requiredDataMask */ NULL,
+ /* requiredDataMask */ nullptr,
/* freeData */ freeData,
/* isDisabled */ isDisabled,
/* updateDepsgraph */ updateDepsgraph,
- /* dependsOnTime */ NULL,
- /* dependsOnNormals */ NULL,
+ /* dependsOnTime */ nullptr,
+ /* dependsOnNormals */ nullptr,
/* foreachIDLink */ foreachIDLink,
- /* foreachTexLink */ NULL,
- /* freeRuntimeData */ NULL,
+ /* foreachTexLink */ nullptr,
+ /* freeRuntimeData */ nullptr,
/* panelRegister */ panelRegister,
/* blendWrite */ blendWrite,
/* blendRead */ blendRead,
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 20445a7006a..6936f5a53f8 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -998,8 +998,8 @@ static void add_poly(SkinOutput *so, BMVert *v1, BMVert *v2, BMVert *v3, BMVert
BMVert *verts[4] = {v1, v2, v3, v4};
BMFace *f;
- BLI_assert(v1 != v2 && v1 != v3 && v1 != v4);
- BLI_assert(v2 != v3 && v2 != v4);
+ BLI_assert(!ELEM(v1, v2, v3, v4));
+ BLI_assert(!ELEM(v2, v3, v4));
BLI_assert(v3 != v4);
BLI_assert(v1 && v2 && v3);
@@ -1414,7 +1414,7 @@ static void quad_from_tris(BMEdge *e, BMFace *adj[2], BMVert *ndx[4])
/* Find what the second tri has that the first doesn't */
for (i = 0; i < 3; i++) {
- if (tri[1][i] != tri[0][0] && tri[1][i] != tri[0][1] && tri[1][i] != tri[0][2]) {
+ if (!ELEM(tri[1][i], tri[0][0], tri[0][1], tri[0][2])) {
opp = tri[1][i];
break;
}
@@ -1760,13 +1760,19 @@ static bool skin_output_branch_hulls(
return result;
}
+typedef enum eSkinErrorFlag {
+ SKIN_ERROR_NO_VALID_ROOT = (1 << 0),
+ SKIN_ERROR_HULL = (1 << 1),
+} eSkinErrorFlag;
+
static BMesh *build_skin(SkinNode *skin_nodes,
int totvert,
const MeshElemMap *emap,
const MEdge *medge,
int totedge,
const MDeformVert *input_dvert,
- SkinModifierData *smd)
+ SkinModifierData *smd,
+ eSkinErrorFlag *r_error)
{
SkinOutput so;
int v;
@@ -1802,7 +1808,7 @@ static BMesh *build_skin(SkinNode *skin_nodes,
skin_update_merged_vertices(skin_nodes, totvert);
if (!skin_output_branch_hulls(&so, skin_nodes, totvert, emap, medge)) {
- BKE_modifier_set_error(&smd->modifier, "Hull error");
+ *r_error |= SKIN_ERROR_HULL;
}
/* Merge triangles here in the hope of providing better target
@@ -1848,7 +1854,7 @@ static void skin_set_orig_indices(Mesh *mesh)
* 2) Generate node frames
* 3) Output vertices and polygons from frames, connections, and hulls
*/
-static Mesh *base_skin(Mesh *origmesh, SkinModifierData *smd)
+static Mesh *base_skin(Mesh *origmesh, SkinModifierData *smd, eSkinErrorFlag *r_error)
{
Mesh *result;
MVertSkin *nodes;
@@ -1878,16 +1884,14 @@ static Mesh *base_skin(Mesh *origmesh, SkinModifierData *smd)
MEM_freeN(emat);
emat = NULL;
- bm = build_skin(skin_nodes, totvert, emap, medge, totedge, dvert, smd);
+ bm = build_skin(skin_nodes, totvert, emap, medge, totedge, dvert, smd, r_error);
MEM_freeN(skin_nodes);
MEM_freeN(emap);
MEM_freeN(emapmem);
if (!has_valid_root) {
- BKE_modifier_set_error(
- &smd->modifier,
- "No valid root vertex found (you need one per mesh island you want to skin)");
+ *r_error |= SKIN_ERROR_NO_VALID_ROOT;
}
if (!bm) {
@@ -1904,7 +1908,7 @@ static Mesh *base_skin(Mesh *origmesh, SkinModifierData *smd)
return result;
}
-static Mesh *final_skin(SkinModifierData *smd, Mesh *mesh)
+static Mesh *final_skin(SkinModifierData *smd, Mesh *mesh, eSkinErrorFlag *r_error)
{
Mesh *result;
@@ -1914,7 +1918,7 @@ static Mesh *final_skin(SkinModifierData *smd, Mesh *mesh)
}
mesh = subdivide_base(mesh);
- result = base_skin(mesh, smd);
+ result = base_skin(mesh, smd, r_error);
BKE_id_free(NULL, mesh);
return result;
@@ -1934,11 +1938,25 @@ static void initData(ModifierData *md)
md->mode |= eModifierMode_Editmode;
}
-static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx), Mesh *mesh)
+static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
{
- Mesh *result;
+ eSkinErrorFlag error = 0;
+ Mesh *result = final_skin((SkinModifierData *)md, mesh, &error);
+
+ if (error & SKIN_ERROR_NO_VALID_ROOT) {
+ error &= ~SKIN_ERROR_NO_VALID_ROOT;
+ BKE_modifier_set_error(
+ ctx->object,
+ md,
+ "No valid root vertex found (you need one per mesh island you want to skin)");
+ }
+ if (error & SKIN_ERROR_HULL) {
+ error &= ~SKIN_ERROR_HULL;
+ BKE_modifier_set_error(ctx->object, md, "Hull error");
+ }
+ BLI_assert(error == 0);
- if (!(result = final_skin((SkinModifierData *)md, mesh))) {
+ if (result == NULL) {
return mesh;
}
return result;
diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 47adb7ba0bd..8acf07f9181 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -2501,16 +2501,25 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
MEM_freeN(face_edges);
}
if (edge_index != numNewEdges) {
- BKE_modifier_set_error(
- md, "Internal Error: edges array wrong size: %u instead of %u", numNewEdges, edge_index);
+ BKE_modifier_set_error(ctx->object,
+ md,
+ "Internal Error: edges array wrong size: %u instead of %u",
+ numNewEdges,
+ edge_index);
}
if (poly_index != numNewPolys) {
- BKE_modifier_set_error(
- md, "Internal Error: polys array wrong size: %u instead of %u", numNewPolys, poly_index);
+ BKE_modifier_set_error(ctx->object,
+ md,
+ "Internal Error: polys array wrong size: %u instead of %u",
+ numNewPolys,
+ poly_index);
}
if (loop_index != numNewLoops) {
- BKE_modifier_set_error(
- md, "Internal Error: loops array wrong size: %u instead of %u", numNewLoops, loop_index);
+ BKE_modifier_set_error(ctx->object,
+ md,
+ "Internal Error: loops array wrong size: %u instead of %u",
+ numNewLoops,
+ loop_index);
}
BLI_assert(edge_index == numNewEdges);
BLI_assert(poly_index == numNewPolys);
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index c30dd9f8765..1aa015682dd 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -254,7 +254,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
{
Mesh *result = mesh;
#if !defined(WITH_OPENSUBDIV)
- BKE_modifier_set_error(md, "Disabled, built without OpenSubdiv");
+ BKE_modifier_set_error(ctx->object, md, "Disabled, built without OpenSubdiv");
return result;
#endif
SubsurfModifierData *smd = (SubsurfModifierData *)md;
@@ -309,7 +309,7 @@ static void deformMatrices(ModifierData *md,
int num_verts)
{
#if !defined(WITH_OPENSUBDIV)
- BKE_modifier_set_error(md, "Disabled, built without OpenSubdiv");
+ BKE_modifier_set_error(ctx->object, md, "Disabled, built without OpenSubdiv");
return;
#endif
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index aa48eaa6a32..5407397e3bf 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -70,6 +70,9 @@ typedef struct SDefAdjacencyArray {
uint num; /* Careful, this is twice the number of polygons (avoids an extra loop) */
} SDefAdjacencyArray;
+/**
+ * Polygons per edge (only 2, any more will exit calculation).
+ */
typedef struct SDefEdgePolys {
uint polys[2], num;
} SDefEdgePolys;
@@ -83,37 +86,67 @@ typedef struct SDefBindCalcData {
const MPoly *const mpoly;
const MEdge *const medge;
const MLoop *const mloop;
+ /** Coordinates to bind to, transformed into local space (compatible with `vertexCos`). */
float (*const targetCos)[3];
+ /** Coordinates to bind (reference to the modifiers input argument). */
float (*const vertexCos)[3];
float imat[4][4];
const float falloff;
int success;
} SDefBindCalcData;
+/**
+ * This represents the relationship between a point (a source coordinate)
+ * and the face-corner it's being bound to (from the target mesh).
+ *
+ * \note Some of these values could be de-duplicated however these are only
+ * needed once when running bind, so optimizing this structure isn't a priority.
+ */
typedef struct SDefBindPoly {
+ /** Coordinates copied directly from the modifiers inptut. */
float (*coords)[3];
+ /** Coordinates projected into 2D space using `normal`. */
float (*coords_v2)[2];
+ /** The point being queried projected into 2D space using `normal`. */
float point_v2[2];
float weight_angular;
float weight_dist_proj;
float weight_dist;
float weight;
float scales[2];
+ /** Center of `coords` */
float centroid[3];
+ /** Center of `coords_v2` */
float centroid_v2[2];
+ /**
+ * The calculated normal of coords (could be shared between faces).
+ */
float normal[3];
float cent_edgemid_vecs_v2[2][2];
+ /**
+ * The unsigned angle of this face-corner in `[0.0 .. PI]` range,
+ * where a small value is a thin corner. PI is is a straight line.
+ * Take care dividing by this value as it can approach zero.
+ */
float edgemid_angle;
float point_edgemid_angles[2];
float corner_edgemid_angles[2];
float dominant_angle_weight;
+ /** Index of the input polygon. */
uint index;
+ /** Number of vertices in this face. */
uint numverts;
+ /**
+ * This polygons loop-start.
+ * \note that we could look this up from the polygon.
+ */
uint loopstart;
uint edge_inds[2];
uint edge_vert_inds[2];
+ /** The index of this corner in the face (starting at zero). */
uint corner_ind;
uint dominant_edge;
+ /** When true `point_v2` is inside `coords_v2`. */
bool inside;
} SDefBindPoly;
@@ -256,7 +289,7 @@ static int buildAdjacencyMap(const MPoly *poly,
{
const MLoop *loop;
- /* Fing polygons adjacent to edges */
+ /* Find polygons adjacent to edges. */
for (int i = 0; i < numpoly; i++, poly++) {
loop = &mloop[poly->loopstart];
@@ -466,7 +499,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
bwdata->bind_polys = bpoly;
/* Loop over all adjacent edges,
- * and build the SDefBindPoly data for each poly adjacent to those. */
+ * and build the #SDefBindPoly data for each poly adjacent to those. */
for (vedge = vert_edges; vedge; vedge = vedge->next) {
uint edge_ind = vedge->index;
@@ -475,7 +508,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
bpoly = bwdata->bind_polys;
for (int j = 0; j < bwdata->numpoly; bpoly++, j++) {
- /* If coords isn't allocated, we have reached the first uninitialized bpoly */
+ /* If coords isn't allocated, we have reached the first uninitialized `bpoly`. */
if ((bpoly->index == edge_polys[edge_ind].polys[i]) || (!bpoly->coords)) {
break;
}
@@ -530,7 +563,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
}
}
- /* Compute poly's parametric data */
+ /* Compute polygons parametric data. */
mid_v3_v3_array(bpoly->centroid, bpoly->coords, poly->totloop);
normal_poly_v3(bpoly->normal, bpoly->coords, poly->totloop);
@@ -540,7 +573,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
cross_v3_v3v3(axis, bpoly->normal, world);
normalize_v3(axis);
- /* Map coords onto 2d normal plane */
+ /* Map coords onto 2d normal plane. */
map_to_plane_axis_angle_v2_v3v3fl(bpoly->point_v2, point_co, axis, angle);
zero_v2(bpoly->centroid_v2);
@@ -595,7 +628,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
bpoly->corner_edgemid_angles[1] = angle_normalized_v2v2(tmp_vec_v2,
bpoly->cent_edgemid_vecs_v2[1]);
- /* Check for inifnite weights, and compute angular data otherwise */
+ /* Check for infinite weights, and compute angular data otherwise. */
if (bpoly->weight_dist < FLT_EPSILON) {
inf_weight_flags |= MOD_SDEF_INFINITE_WEIGHT_DIST_PROJ;
inf_weight_flags |= MOD_SDEF_INFINITE_WEIGHT_DIST;
@@ -665,10 +698,10 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
}
}
- /* Compute scalings and falloff.
- * Scale all weights if no infinite weight is found,
- * scale only unprojected weight if projected weight is infinite,
- * scale none if both are infinite. */
+ /* Compute scaling and falloff:
+ * - Scale all weights if no infinite weight is found.
+ * - Scale only un-projected weight if projected weight is infinite.
+ * - Scale none if both are infinite. */
if (!inf_weight_flags) {
bpoly = bwdata->bind_polys;
@@ -892,7 +925,7 @@ static void bindVert(void *__restrict userdata,
interp_weights_poly_v2(
sdbind->vert_weights, bpoly->coords_v2, bpoly->numverts, bpoly->point_v2);
- /* Reproject vert based on weights and original poly verts,
+ /* Re-project vert based on weights and original poly verts,
* to reintroduce poly non-planarity */
zero_v3(point_co_proj);
for (int j = 0; j < bpoly->numverts; j++, loop++) {
@@ -1010,7 +1043,8 @@ static void bindVert(void *__restrict userdata,
freeBindData(bwdata);
}
-static bool surfacedeformBind(SurfaceDeformModifierData *smd_orig,
+static bool surfacedeformBind(Object *ob,
+ SurfaceDeformModifierData *smd_orig,
SurfaceDeformModifierData *smd_eval,
float (*vertexCos)[3],
uint numverts,
@@ -1031,20 +1065,20 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd_orig,
vert_edges = MEM_calloc_arrayN(tnumverts, sizeof(*vert_edges), "SDefVertEdgeMap");
if (vert_edges == NULL) {
- BKE_modifier_set_error((ModifierData *)smd_eval, "Out of memory");
+ BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
return false;
}
adj_array = MEM_malloc_arrayN(tnumedges, 2 * sizeof(*adj_array), "SDefVertEdge");
if (adj_array == NULL) {
- BKE_modifier_set_error((ModifierData *)smd_eval, "Out of memory");
+ BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
MEM_freeN(vert_edges);
return false;
}
edge_polys = MEM_calloc_arrayN(tnumedges, sizeof(*edge_polys), "SDefEdgeFaceMap");
if (edge_polys == NULL) {
- BKE_modifier_set_error((ModifierData *)smd_eval, "Out of memory");
+ BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
MEM_freeN(vert_edges);
MEM_freeN(adj_array);
return false;
@@ -1052,14 +1086,14 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd_orig,
smd_orig->verts = MEM_malloc_arrayN(numverts, sizeof(*smd_orig->verts), "SDefBindVerts");
if (smd_orig->verts == NULL) {
- BKE_modifier_set_error((ModifierData *)smd_eval, "Out of memory");
+ BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
return false;
}
BKE_bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI, 2);
if (treeData.tree == NULL) {
- BKE_modifier_set_error((ModifierData *)smd_eval, "Out of memory");
+ BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
MEM_freeN(smd_orig->verts);
smd_orig->verts = NULL;
@@ -1070,8 +1104,8 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd_orig,
mpoly, medge, mloop, tnumpoly, tnumedges, vert_edges, adj_array, edge_polys);
if (adj_result == MOD_SDEF_BIND_RESULT_NONMANY_ERR) {
- BKE_modifier_set_error((ModifierData *)smd_eval,
- "Target has edges with more than two polygons");
+ BKE_modifier_set_error(
+ ob, (ModifierData *)smd_eval, "Target has edges with more than two polygons");
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
free_bvhtree_from_mesh(&treeData);
MEM_freeN(smd_orig->verts);
@@ -1098,7 +1132,7 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd_orig,
};
if (data.targetCos == NULL) {
- BKE_modifier_set_error((ModifierData *)smd_eval, "Out of memory");
+ BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
freeData((ModifierData *)smd_orig);
return false;
}
@@ -1117,20 +1151,20 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd_orig,
MEM_freeN(data.targetCos);
if (data.success == MOD_SDEF_BIND_RESULT_MEM_ERR) {
- BKE_modifier_set_error((ModifierData *)smd_eval, "Out of memory");
+ BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
freeData((ModifierData *)smd_orig);
}
else if (data.success == MOD_SDEF_BIND_RESULT_NONMANY_ERR) {
- BKE_modifier_set_error((ModifierData *)smd_eval,
- "Target has edges with more than two polygons");
+ BKE_modifier_set_error(
+ ob, (ModifierData *)smd_eval, "Target has edges with more than two polygons");
freeData((ModifierData *)smd_orig);
}
else if (data.success == MOD_SDEF_BIND_RESULT_CONCAVE_ERR) {
- BKE_modifier_set_error((ModifierData *)smd_eval, "Target contains concave polygons");
+ BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Target contains concave polygons");
freeData((ModifierData *)smd_orig);
}
else if (data.success == MOD_SDEF_BIND_RESULT_OVERLAP_ERR) {
- BKE_modifier_set_error((ModifierData *)smd_eval, "Target contains overlapping vertices");
+ BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Target contains overlapping vertices");
freeData((ModifierData *)smd_orig);
}
else if (data.success == MOD_SDEF_BIND_RESULT_GENERIC_ERR) {
@@ -1138,7 +1172,7 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd_orig,
* to explain this with a reasonably sized message.
* Though it shouldn't really matter all that much,
* because this is very unlikely to occur */
- BKE_modifier_set_error((ModifierData *)smd_eval, "Target contains invalid polygons");
+ BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Target contains invalid polygons");
freeData((ModifierData *)smd_orig);
}
@@ -1235,7 +1269,7 @@ static void surfacedeformModifier_do(ModifierData *md,
if (!(smd->flags & MOD_SDEF_BIND)) {
if (smd->verts != NULL) {
if (!DEG_is_active(ctx->depsgraph)) {
- BKE_modifier_set_error(md, "Attempt to bind from inactive dependency graph");
+ BKE_modifier_set_error(ob, md, "Attempt to bind from inactive dependency graph");
return;
}
ModifierData *md_orig = BKE_modifier_get_original(md);
@@ -1247,7 +1281,7 @@ static void surfacedeformModifier_do(ModifierData *md,
Object *ob_target = smd->target;
target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false);
if (!target) {
- BKE_modifier_set_error(md, "No valid target mesh");
+ BKE_modifier_set_error(ob, md, "No valid target mesh");
return;
}
@@ -1257,7 +1291,7 @@ static void surfacedeformModifier_do(ModifierData *md,
/* If not bound, execute bind. */
if (smd->verts == NULL) {
if (!DEG_is_active(ctx->depsgraph)) {
- BKE_modifier_set_error(md, "Attempt to unbind from inactive dependency graph");
+ BKE_modifier_set_error(ob, md, "Attempt to unbind from inactive dependency graph");
return;
}
@@ -1271,7 +1305,7 @@ static void surfacedeformModifier_do(ModifierData *md,
/* Avoid converting edit-mesh data, binding is an exception. */
BKE_mesh_wrapper_ensure_mdata(target);
- if (!surfacedeformBind(smd_orig, smd, vertexCos, numverts, tnumpoly, tnumverts, target)) {
+ if (!surfacedeformBind(ob, smd_orig, smd, vertexCos, numverts, tnumpoly, tnumverts, target)) {
smd->flags &= ~MOD_SDEF_BIND;
}
/* Early abort, this is binding 'call', no need to perform whole evaluation. */
@@ -1280,17 +1314,17 @@ static void surfacedeformModifier_do(ModifierData *md,
/* Poly count checks */
if (smd->numverts != numverts) {
- BKE_modifier_set_error(md, "Vertices changed from %u to %u", smd->numverts, numverts);
+ BKE_modifier_set_error(ob, md, "Vertices changed from %u to %u", smd->numverts, numverts);
return;
}
if (smd->numpoly != tnumpoly) {
- BKE_modifier_set_error(md, "Target polygons changed from %u to %u", smd->numpoly, tnumpoly);
+ BKE_modifier_set_error(
+ ob, md, "Target polygons changed from %u to %u", smd->numpoly, tnumpoly);
return;
}
- /* Early out if modifier would not affect input at all - still *after* the sanity checks (and
- * potential binding) above.
- */
+ /* Early out if modifier would not affect input at all - still *after* the sanity checks
+ * (and potential binding) above. */
if (smd->strength == 0.0f) {
return;
}
@@ -1454,8 +1488,7 @@ static void blendWrite(BlendWriter *writer, const ModifierData *md)
BLO_write_uint32_array(
writer, smd->verts[i].binds[j].numverts, smd->verts[i].binds[j].vert_inds);
- if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
- smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI) {
+ if (ELEM(smd->verts[i].binds[j].mode, MOD_SDEF_MODE_CENTROID, MOD_SDEF_MODE_LOOPTRI)) {
BLO_write_float3_array(writer, 1, smd->verts[i].binds[j].vert_weights);
}
else {
@@ -1483,8 +1516,7 @@ static void blendRead(BlendDataReader *reader, ModifierData *md)
BLO_read_uint32_array(
reader, smd->verts[i].binds[j].numverts, &smd->verts[i].binds[j].vert_inds);
- if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
- smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI) {
+ if (ELEM(smd->verts[i].binds[j].mode, MOD_SDEF_MODE_CENTROID, MOD_SDEF_MODE_LOOPTRI)) {
BLO_read_float3_array(reader, 1, &smd->verts[i].binds[j].vert_weights);
}
else {
diff --git a/source/blender/modifiers/intern/MOD_ui_common.c b/source/blender/modifiers/intern/MOD_ui_common.c
index bad76a0b559..6c92ceb6fc0 100644
--- a/source/blender/modifiers/intern/MOD_ui_common.c
+++ b/source/blender/modifiers/intern/MOD_ui_common.c
@@ -229,14 +229,14 @@ static void modifier_ops_extra_draw(bContext *C, uiLayout *layout, void *md_v)
/* Apply as shapekey. */
if (BKE_modifier_is_same_topology(md) && !BKE_modifier_is_non_geometrical(md)) {
uiItemBooleanO(layout,
- CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply As Shapekey"),
+ CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply as Shape Key"),
ICON_SHAPEKEY_DATA,
"OBJECT_OT_modifier_apply_as_shapekey",
"keep_modifier",
false);
uiItemBooleanO(layout,
- CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Save As Shapekey"),
+ CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Save as Shape Key"),
ICON_SHAPEKEY_DATA,
"OBJECT_OT_modifier_apply_as_shapekey",
"keep_modifier",
@@ -416,7 +416,7 @@ PanelType *modifier_panel_register(ARegionType *region_type, ModifierType type,
/* Give the panel the special flag that says it was built here and corresponds to a
* modifier rather than a #PanelType. */
- panel_type->flag = PNL_LAYOUT_HEADER_EXPAND | PNL_DRAW_BOX | PNL_INSTANCED;
+ panel_type->flag = PANEL_TYPE_HEADER_EXPAND | PANEL_TYPE_DRAW_BOX | PANEL_TYPE_INSTANCED;
panel_type->reorder = modifier_reorder;
panel_type->get_list_data_expand_flag = get_modifier_expand_flag;
panel_type->set_list_data_expand_flag = set_modifier_expand_flag;
@@ -453,7 +453,7 @@ PanelType *modifier_subpanel_register(ARegionType *region_type,
panel_type->draw_header = draw_header;
panel_type->draw = draw;
panel_type->poll = modifier_ui_poll;
- panel_type->flag = (PNL_DEFAULT_CLOSED | PNL_DRAW_BOX);
+ panel_type->flag = (PANEL_TYPE_DEFAULT_CLOSED | PANEL_TYPE_DRAW_BOX);
BLI_assert(parent != NULL);
BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME);
diff --git a/source/blender/modifiers/intern/MOD_volume_displace.cc b/source/blender/modifiers/intern/MOD_volume_displace.cc
index 22bf5cd4893..f4e1936713c 100644
--- a/source/blender/modifiers/intern/MOD_volume_displace.cc
+++ b/source/blender/modifiers/intern/MOD_volume_displace.cc
@@ -45,7 +45,7 @@
#include "MOD_modifiertypes.h"
#include "MOD_ui_common.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#include "RNA_access.h"
@@ -62,7 +62,7 @@
static void initData(ModifierData *md)
{
VolumeDisplaceModifierData *vdmd = reinterpret_cast<VolumeDisplaceModifierData *>(md);
- vdmd->texture = NULL;
+ vdmd->texture = nullptr;
vdmd->strength = 0.5f;
copy_v3_fl(vdmd->texture_mid_level, 0.5f);
vdmd->texture_sample_radius = 1.0f;
@@ -71,11 +71,11 @@ static void initData(ModifierData *md)
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
{
VolumeDisplaceModifierData *vdmd = reinterpret_cast<VolumeDisplaceModifierData *>(md);
- if (vdmd->texture != NULL) {
+ if (vdmd->texture != nullptr) {
DEG_add_generic_id_relation(ctx->node, &vdmd->texture->id, "Volume Displace Modifier");
}
if (vdmd->texture_map_mode == MOD_VOLUME_DISPLACE_MAP_OBJECT) {
- if (vdmd->texture_map_object != NULL) {
+ if (vdmd->texture_map_object != nullptr) {
DEG_add_object_relation(
ctx->node, vdmd->texture_map_object, DEG_OB_COMP_TRANSFORM, "Volume Displace Modifier");
}
@@ -114,14 +114,14 @@ static void panel_draw(const bContext *C, Panel *panel)
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
- uiTemplateID(layout, C, ptr, "texture", "texture.new", NULL, NULL, 0, ICON_NONE, NULL);
+ uiTemplateID(layout, C, ptr, "texture", "texture.new", nullptr, nullptr, 0, ICON_NONE, nullptr);
uiItemR(layout, ptr, "texture_map_mode", 0, "Texture Mapping", ICON_NONE);
if (vdmd->texture_map_mode == MOD_VOLUME_DISPLACE_MAP_OBJECT) {
uiItemR(layout, ptr, "texture_map_object", 0, "Object", ICON_NONE);
}
- uiItemR(layout, ptr, "strength", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "strength", 0, nullptr, ICON_NONE);
uiItemR(layout, ptr, "texture_sample_radius", 0, "Sample Radius", ICON_NONE);
uiItemR(layout, ptr, "texture_mid_level", 0, "Mid Level", ICON_NONE);
@@ -166,7 +166,7 @@ template<typename GridType> struct DisplaceOp {
openvdb::Vec3d compute_displace_vector(const openvdb::Coord &coord) const
{
- if (this->texture != NULL) {
+ if (this->texture != nullptr) {
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) *
@@ -180,7 +180,7 @@ template<typename GridType> struct DisplaceOp {
{
TexResult texture_result = {0};
BKE_texture_get_value(
- NULL, this->texture, const_cast<float *>(pos.asV()), &texture_result, false);
+ nullptr, this->texture, const_cast<float *>(pos.asV()), &texture_result, false);
return {texture_result.tr, texture_result.tg, texture_result.tb};
}
};
@@ -270,7 +270,7 @@ struct DisplaceGridOp {
return index_to_object * object_to_world;
}
case MOD_VOLUME_DISPLACE_MAP_OBJECT: {
- if (vdmd.texture_map_object == NULL) {
+ if (vdmd.texture_map_object == nullptr) {
return index_to_object;
}
const openvdb::Mat4s object_to_world = matrix_to_openvdb(ctx.object->obmat);
@@ -295,7 +295,7 @@ static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, Vo
const int grid_amount = BKE_volume_num_grids(volume);
for (int grid_index = 0; grid_index < grid_amount; grid_index++) {
VolumeGrid *volume_grid = BKE_volume_grid_get(volume, grid_index);
- BLI_assert(volume_grid != NULL);
+ BLI_assert(volume_grid != nullptr);
openvdb::GridBase::Ptr grid = BKE_volume_grid_openvdb_for_write(volume, volume_grid, false);
VolumeGridType grid_type = BKE_volume_grid_type(volume_grid);
@@ -307,7 +307,7 @@ static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, Vo
return volume;
#else
UNUSED_VARS(md, ctx);
- BKE_modifier_set_error(md, "Compiled without OpenVDB");
+ BKE_modifier_set_error(ctx->object, md, "Compiled without OpenVDB");
return volume;
#endif
}
@@ -323,26 +323,26 @@ ModifierTypeInfo modifierType_VolumeDisplace = {
/* copyData */ BKE_modifier_copydata_generic,
- /* deformVerts */ NULL,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
- /* deformMatricesEM */ NULL,
- /* modifyMesh */ NULL,
- /* modifyHair */ NULL,
- /* modifyPointCloud */ NULL,
+ /* deformVerts */ nullptr,
+ /* deformMatrices */ nullptr,
+ /* deformVertsEM */ nullptr,
+ /* deformMatricesEM */ nullptr,
+ /* modifyMesh */ nullptr,
+ /* modifyHair */ nullptr,
+ /* modifyPointCloud */ nullptr,
/* modifyVolume */ modifyVolume,
/* initData */ initData,
- /* requiredDataMask */ NULL,
- /* freeData */ NULL,
- /* isDisabled */ NULL,
+ /* requiredDataMask */ nullptr,
+ /* freeData */ nullptr,
+ /* isDisabled */ nullptr,
/* updateDepsgraph */ updateDepsgraph,
/* dependsOnTime */ dependsOnTime,
- /* dependsOnNormals */ NULL,
+ /* dependsOnNormals */ nullptr,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
- /* freeRuntimeData */ NULL,
+ /* freeRuntimeData */ nullptr,
/* panelRegister */ panelRegister,
- /* blendWrite */ NULL,
- /* blendRead */ NULL,
+ /* blendWrite */ nullptr,
+ /* blendRead */ nullptr,
};
diff --git a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
index 913a457c38d..e008dc3f140 100644
--- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
+++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
@@ -59,7 +59,7 @@ using blender::Span;
static void initData(ModifierData *md)
{
VolumeToMeshModifierData *vmmd = reinterpret_cast<VolumeToMeshModifierData *>(md);
- vmmd->object = NULL;
+ vmmd->object = nullptr;
vmmd->threshold = 0.1f;
strncpy(vmmd->grid_name, "density", MAX_NAME);
vmmd->adaptivity = 0.0f;
@@ -91,7 +91,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *layout = panel->layout;
- PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
VolumeToMeshModifierData *vmmd = static_cast<VolumeToMeshModifierData *>(ptr->data);
uiLayoutSetPropSep(layout, true);
@@ -99,26 +99,26 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *col = uiLayoutColumn(layout, false);
- uiItemR(col, ptr, "object", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "grid_name", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "object", 0, nullptr, ICON_NONE);
+ uiItemR(col, ptr, "grid_name", 0, nullptr, ICON_NONE);
}
{
uiLayout *col = uiLayoutColumn(layout, false);
- uiItemR(col, ptr, "resolution_mode", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "resolution_mode", 0, nullptr, ICON_NONE);
if (vmmd->resolution_mode == VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_AMOUNT) {
- uiItemR(col, ptr, "voxel_amount", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "voxel_amount", 0, nullptr, ICON_NONE);
}
else if (vmmd->resolution_mode == VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_SIZE) {
- uiItemR(col, ptr, "voxel_size", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "voxel_size", 0, nullptr, ICON_NONE);
}
}
{
uiLayout *col = uiLayoutColumn(layout, false);
- uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "adaptivity", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "use_smooth_shade", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "threshold", 0, nullptr, ICON_NONE);
+ uiItemR(col, ptr, "adaptivity", 0, nullptr, ICON_NONE);
+ uiItemR(col, ptr, "use_smooth_shade", 0, nullptr, ICON_NONE);
}
modifier_panel_end(layout, ptr);
@@ -293,7 +293,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
BKE_volume_load(volume, DEG_get_bmain(ctx->depsgraph));
VolumeGrid *volume_grid = BKE_volume_grid_find(volume, vmmd->grid_name);
if (volume_grid == nullptr) {
- BKE_modifier_set_error(md, "Cannot find '%s' grid", vmmd->grid_name);
+ BKE_modifier_set_error(ctx->object, md, "Cannot find '%s' grid", vmmd->grid_name);
return create_empty_mesh(input_mesh);
}
@@ -302,7 +302,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
const VolumeGridType grid_type = BKE_volume_grid_type(volume_grid);
VolumeToMeshOp to_mesh_op{*grid, *vmmd, *ctx};
if (!BKE_volume_grid_type_operation(grid_type, to_mesh_op)) {
- BKE_modifier_set_error(md, "Expected a scalar grid");
+ BKE_modifier_set_error(ctx->object, md, "Expected a scalar grid");
return create_empty_mesh(input_mesh);
}
@@ -313,8 +313,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
return mesh;
#else
- UNUSED_VARS(md, ctx);
- BKE_modifier_set_error(md, "Compiled without OpenVDB");
+ UNUSED_VARS(md);
+ BKE_modifier_set_error(ctx->object, md, "Compiled without OpenVDB");
return create_empty_mesh(input_mesh);
#endif
}
@@ -330,26 +330,26 @@ ModifierTypeInfo modifierType_VolumeToMesh = {
/* copyData */ BKE_modifier_copydata_generic,
- /* deformVerts */ NULL,
- /* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
- /* deformMatricesEM */ NULL,
+ /* deformVerts */ nullptr,
+ /* deformMatrices */ nullptr,
+ /* deformVertsEM */ nullptr,
+ /* deformMatricesEM */ nullptr,
/* modifyMesh */ modifyMesh,
- /* modifyHair */ NULL,
- /* modifyPointCloud */ NULL,
- /* modifyVolume */ NULL,
+ /* modifyHair */ nullptr,
+ /* modifyPointCloud */ nullptr,
+ /* modifyVolume */ nullptr,
/* initData */ initData,
- /* requiredDataMask */ NULL,
- /* freeData */ NULL,
- /* isDisabled */ NULL,
+ /* requiredDataMask */ nullptr,
+ /* freeData */ nullptr,
+ /* isDisabled */ nullptr,
/* updateDepsgraph */ updateDepsgraph,
- /* dependsOnTime */ NULL,
- /* dependsOnNormals */ NULL,
+ /* dependsOnTime */ nullptr,
+ /* dependsOnNormals */ nullptr,
/* foreachIDLink */ foreachIDLink,
- /* foreachTexLink */ NULL,
- /* freeRuntimeData */ NULL,
+ /* foreachTexLink */ nullptr,
+ /* freeRuntimeData */ nullptr,
/* panelRegister */ panelRegister,
- /* blendWrite */ NULL,
- /* blendRead */ NULL,
+ /* blendWrite */ nullptr,
+ /* blendRead */ nullptr,
};
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 4d1e2cea86f..53e41484606 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -57,7 +57,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#include "MOD_ui_common.h"
#include "MOD_util.h"
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 4c8b511f19a..45f06a7778c 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -51,7 +51,8 @@
#include "RNA_access.h"
#include "MEM_guardedalloc.h"
-#include "RE_shader_ext.h"
+
+#include "RE_texture.h"
#include "MOD_modifiertypes.h"
#include "MOD_ui_common.h"
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 65bb009fc58..bd15d909834 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -574,7 +574,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH))
#endif
{
- BKE_modifier_set_error((ModifierData *)wnmd, "Enable 'Auto Smooth' in Object Data Properties");
+ BKE_modifier_set_error(
+ ctx->object, (ModifierData *)wnmd, "Enable 'Auto Smooth' in Object Data Properties");
return mesh;
}
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index 1c1ca08183d..c5e2ecb9660 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -55,7 +55,7 @@
#include "MOD_ui_common.h"
#include "MOD_util.h"
#include "MOD_weightvg_util.h"
-#include "RE_shader_ext.h" /* Texture masking. */
+#include "RE_texture.h" /* Texture masking. */
/* Maps new_w weights in place, using either one of the predefined functions, or a custom curve.
* Return values are in new_w.
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 78b3e6236f0..f88d50167ac 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -35,7 +35,7 @@ set(INC
../imbuf
../makesdna
../makesrna
- ../render/extern/include
+ ../render
../../../intern/glew-mx
../../../intern/guardedalloc
../../../intern/sky/include
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
index ce0c1a91072..c8d2d993e75 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
@@ -65,7 +65,7 @@ static void cryptomatte_add(NodeCryptomatte *n, float f)
/* Find the next separator. */
char *token_end = strchr(n->matte_id + start, ',');
- if (token_end == NULL || token_end == n->matte_id + start) {
+ if (ELEM(token_end, NULL, n->matte_id + start)) {
token_end = n->matte_id + end;
}
/* Be aware that token_len still contains any trailing white space. */
@@ -144,7 +144,7 @@ static void cryptomatte_remove(NodeCryptomatte *n, float f)
/* Find the next separator. */
char *token_end = strchr(n->matte_id + start + 1, ',');
- if (token_end == NULL || token_end == n->matte_id + start) {
+ if (ELEM(token_end, NULL, n->matte_id + start)) {
token_end = n->matte_id + end;
}
/* Be aware that token_len still contains any trailing white space. */
diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c
index bd8aca3d2fd..3803f450f49 100644
--- a/source/blender/nodes/composite/nodes/node_composite_defocus.c
+++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c
@@ -45,10 +45,10 @@ static void node_composit_init_defocus(bNodeTree *UNUSED(ntree), bNode *node)
nbd->preview = 1;
nbd->gamco = 0;
nbd->samples = 16;
- nbd->fstop = 128.f;
+ nbd->fstop = 128.0f;
nbd->maxblur = 16;
- nbd->bthresh = 1.f;
- nbd->scale = 1.f;
+ nbd->bthresh = 1.0f;
+ nbd->scale = 1.0f;
nbd->no_zbuf = 1;
node->storage = nbd;
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
index 477bc43d084..6dd60526edf 100644
--- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
@@ -23,7 +23,7 @@
#include "node_composite_util.h"
-static bNodeSocketTemplate cmp_node_dblur_in[] = {{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.f},
+static bNodeSocketTemplate cmp_node_dblur_in[] = {{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, ""}};
static bNodeSocketTemplate cmp_node_dblur_out[] = {{SOCK_RGBA, N_("Image")}, {-1, ""}};
diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.c b/source/blender/nodes/composite/nodes/node_composite_lensdist.c
index 89f61b59171..ce8c8c00e24 100644
--- a/source/blender/nodes/composite/nodes/node_composite_lensdist.c
+++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.c
@@ -25,8 +25,8 @@
static bNodeSocketTemplate cmp_node_lensdist_in[] = {
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
- {SOCK_FLOAT, N_("Distort"), 0.f, 0.f, 0.f, 0.f, -0.999f, 1.f, PROP_NONE},
- {SOCK_FLOAT, N_("Dispersion"), 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, PROP_NONE},
+ {SOCK_FLOAT, N_("Distort"), 0.0f, 0.0f, 0.0f, 0.0f, -0.999f, 1.0f, PROP_NONE},
+ {SOCK_FLOAT, N_("Dispersion"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
{-1, ""},
};
static bNodeSocketTemplate cmp_node_lensdist_out[] = {
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index aa1f23163a0..36b9098d972 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -47,7 +47,9 @@ enum {
REFINE_BACKWARD = 1 << 1,
};
-/**** Group ****/
+/* -------------------------------------------------------------------- */
+/** \name Node Group
+ * \{ */
bNodeSocket *node_group_find_input_socket(bNode *groupnode, const char *identifier)
{
@@ -193,7 +195,11 @@ void node_group_update(struct bNodeTree *ntree, struct bNode *node)
}
}
-/**** FRAME ****/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Node Frame
+ * \{ */
static void node_frame_init(bNodeTree *UNUSED(ntree), bNode *node)
{
@@ -219,7 +225,11 @@ void register_node_type_frame(void)
nodeRegisterType(ntype);
}
-/* **************** REROUTE ******************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Node Re-Route
+ * \{ */
/* simple, only a single input and output here */
static void node_reroute_update_internal_links(bNodeTree *ntree, bNode *node)
@@ -403,7 +413,11 @@ void BKE_node_tree_unlink_id(ID *id, struct bNodeTree *ntree)
}
}
-/**** GROUP_INPUT / GROUP_OUTPUT ****/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Node #GROUP_INPUT / #GROUP_OUTPUT
+ * \{ */
static void node_group_input_init(bNodeTree *ntree, bNode *node)
{
@@ -599,3 +613,5 @@ void register_node_type_group_output(void)
nodeRegisterType(ntype);
}
+
+/** \} */
diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc
index 116177a54b7..2c4d7057b4e 100644
--- a/source/blender/nodes/intern/node_socket.cc
+++ b/source/blender/nodes/intern/node_socket.cc
@@ -135,7 +135,7 @@ static void verify_socket_template_list(bNodeTree *ntree,
bNodeSocketTemplate *stemp;
/* no inputs anymore? */
- if (stemp_first == NULL) {
+ if (stemp_first == nullptr) {
for (sock = (bNodeSocket *)socklist->first; sock; sock = nextsock) {
nextsock = sock->next;
nodeRemoveSocket(ntree, node, sock);
@@ -266,7 +266,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
case SOCK_OBJECT: {
bNodeSocketValueObject *dval = (bNodeSocketValueObject *)MEM_callocN(
sizeof(bNodeSocketValueObject), "node socket value object");
- dval->value = NULL;
+ dval->value = nullptr;
sock->default_value = dval;
break;
@@ -274,7 +274,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
case SOCK_IMAGE: {
bNodeSocketValueImage *dval = (bNodeSocketValueImage *)MEM_callocN(
sizeof(bNodeSocketValueImage), "node socket value image");
- dval->value = NULL;
+ dval->value = nullptr;
sock->default_value = dval;
break;
@@ -490,13 +490,13 @@ static bNodeSocketType *make_standard_socket_type(int type, int subtype)
/* set the RNA type
* uses the exact same identifier as the socket type idname */
srna = stype->ext_socket.srna = RNA_struct_find(socket_idname);
- BLI_assert(srna != NULL);
+ BLI_assert(srna != nullptr);
/* associate the RNA type with the socket type */
RNA_struct_blender_type_set(srna, stype);
/* set the interface RNA type */
srna = stype->ext_interface.srna = RNA_struct_find(interface_idname);
- BLI_assert(srna != NULL);
+ BLI_assert(srna != nullptr);
/* associate the RNA type with the socket type */
RNA_struct_blender_type_set(srna, stype);
@@ -520,7 +520,7 @@ static bNodeSocketType *make_standard_socket_type(int type, int subtype)
extern "C" void ED_init_node_socket_type_virtual(bNodeSocketType *);
-static bNodeSocketType *make_socket_type_virtual(void)
+static bNodeSocketType *make_socket_type_virtual()
{
const char *socket_idname = "NodeSocketVirtual";
bNodeSocketType *stype;
@@ -533,7 +533,7 @@ static bNodeSocketType *make_socket_type_virtual(void)
/* set the RNA type
* uses the exact same identifier as the socket type idname */
srna = stype->ext_socket.srna = RNA_struct_find(socket_idname);
- BLI_assert(srna != NULL);
+ BLI_assert(srna != nullptr);
/* associate the RNA type with the socket type */
RNA_struct_blender_type_set(srna, stype);
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index b2309abe32e..a5d61332a90 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -43,7 +43,9 @@
#include "node_util.h"
-/**** Storage Data ****/
+/* -------------------------------------------------------------------- */
+/** \name Storage Data
+ * \{ */
void node_free_curves(bNode *node)
{
@@ -77,7 +79,11 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context),
return NULL; /* unused return */
}
-/**** Updates ****/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Updates
+ * \{ */
void node_sock_label(bNodeSocket *sock, const char *name)
{
@@ -173,7 +179,11 @@ void node_math_update(bNodeTree *UNUSED(ntree), bNode *node)
}
}
-/**** Labels ****/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Labels
+ * \{ */
void node_blend_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
@@ -222,7 +232,11 @@ void node_filter_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int m
BLI_strncpy(label, IFACE_(name), maxlen);
}
-/*** Link Insertion ***/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Link Insertion
+ * \{ */
/* test if two sockets are interchangeable */
static bool node_link_socket_match(bNodeSocket *a, bNodeSocket *b)
@@ -321,12 +335,17 @@ void node_insert_link_default(bNodeTree *ntree, bNode *node, bNodeLink *link)
}
}
-/**** Internal Links (mute and disconnect) ****/
+/** \} */
-/* common datatype priorities, works for compositor, shader and texture nodes alike
+/* -------------------------------------------------------------------- */
+/** \name Internal Links (mute and disconnect)
+ * \{ */
+
+/**
+ * Common datatype priorities, works for compositor, shader and texture nodes alike
* defines priority of datatype connection based on output type (to):
- * < 0 : never connect these types
- * >= 0 : priority of connection (higher values chosen first)
+ * `< 0`: never connect these types.
+ * `>= 0`: priority of connection (higher values chosen first).
*/
static int node_datatype_priority(eNodeSocketDatatype from, eNodeSocketDatatype to)
{
@@ -507,7 +526,11 @@ void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
}
}
-/**** Default value RNA access ****/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Default value RNA access
+ * \{ */
float node_socket_get_float(bNodeTree *ntree, bNode *UNUSED(node), bNodeSocket *sock)
{
@@ -556,3 +579,5 @@ void node_socket_set_vector(bNodeTree *ntree,
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
RNA_float_set_array(&ptr, "default_value", value);
}
+
+/** \} */
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index ae5da4d2fd2..efd0e48f41a 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -50,7 +50,7 @@
#include "GPU_material.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#include "NOD_common.h"
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index c1687e1a349..91454c3c982 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -63,7 +63,7 @@
#include "IMB_colormanagement.h"
#include "RE_pipeline.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#include "GPU_material.h"
#include "GPU_texture.h"
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c
index 4fd0ce4f1ef..9b3122e38e0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_attribute.c
+++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c
@@ -25,6 +25,7 @@ static bNodeSocketTemplate sh_node_attribute_out[] = {
{SOCK_RGBA, N_("Color")},
{SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{SOCK_FLOAT, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_FACTOR},
+ {SOCK_FLOAT, N_("Alpha"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_FACTOR},
{-1, ""},
};
@@ -41,8 +42,9 @@ static int node_shader_gpu_attribute(GPUMaterial *mat,
GPUNodeStack *out)
{
NodeShaderAttribute *attr = node->storage;
+ bool is_varying = attr->type == SHD_ATTRIBUTE_GEOMETRY;
- if (GPU_material_is_volume_shader(mat)) {
+ if (GPU_material_is_volume_shader(mat) && is_varying) {
if (out[0].hasoutput) {
out[0].link = GPU_volume_grid(mat, attr->name, GPU_VOLUME_DEFAULT_0);
}
@@ -52,11 +54,23 @@ static int node_shader_gpu_attribute(GPUMaterial *mat,
if (out[2].hasoutput) {
out[2].link = GPU_volume_grid(mat, attr->name, GPU_VOLUME_DEFAULT_0);
}
+ if (out[3].hasoutput) {
+ static const float default_alpha = 1.0f;
+ out[3].link = GPU_constant(&default_alpha);
+ }
return 1;
}
- GPUNodeLink *cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name);
+ GPUNodeLink *cd_attr;
+
+ if (is_varying) {
+ cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name);
+ }
+ else {
+ cd_attr = GPU_uniform_attribute(mat, attr->name, attr->type == SHD_ATTRIBUTE_INSTANCER);
+ }
+
GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr);
/* for each output. */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
index 2f42b6429c7..e29b2ee1c5c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
@@ -34,7 +34,7 @@ static bNodeSocketTemplate sh_node_bsdf_hair_principled_in[] = {
{SOCK_FLOAT, N_("IOR"), 1.55f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{SOCK_FLOAT,
N_("Offset"),
- 2.0f * ((float)M_PI) / 180.f,
+ 2.0f * ((float)M_PI) / 180.0f,
0.0f,
0.0f,
0.0f,
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
index 7dd2ee9a4ac..493acb06963 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
@@ -82,7 +82,7 @@ static int gpu_shader_normal_map(GPUMaterial *mat,
}
const char *color_to_normal_fnc_name = "color_to_normal_new_shading";
- if (nm->space == SHD_SPACE_BLENDER_OBJECT || nm->space == SHD_SPACE_BLENDER_WORLD) {
+ if (ELEM(nm->space, SHD_SPACE_BLENDER_OBJECT, SHD_SPACE_BLENDER_WORLD)) {
color_to_normal_fnc_name = "color_to_blender_normal_new_shading";
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
index b646e806e6e..c6eabc3b2cb 100644
--- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
@@ -18,7 +18,7 @@
*/
#include "../node_shader_util.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
static bNodeSocketTemplate outputs[] = {
{SOCK_FLOAT, "Index"},
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc
index c1543f791f1..59b89c46fc7 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc
@@ -101,7 +101,7 @@ void register_node_type_sh_seprgb(void)
sh_fn_node_type_base(&ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_seprgb_in, sh_node_seprgb_out);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_seprgb);
+ node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_seprgb);
node_type_gpu(&ntype, gpu_shader_seprgb);
ntype.expand_in_mf_network = sh_node_seprgb_expand_in_mf_network;
@@ -159,7 +159,7 @@ void register_node_type_sh_combrgb(void)
sh_fn_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_combrgb);
+ node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_combrgb);
node_type_gpu(&ntype, gpu_shader_combrgb);
ntype.expand_in_mf_network = sh_node_combrgb_expand_in_mf_network;
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c
index fae1fb283ed..14cd1fd4c0c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c
@@ -19,7 +19,7 @@
#include "../node_shader_util.h"
-#include "RE_render_ext.h"
+#include "RE_texture.h"
/* **************** OUTPUT ******************** */
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
index becc4623e9a..a86a8bb8935 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
@@ -172,7 +172,7 @@ void register_node_type_sh_valtorgb(void)
node_type_init(&ntype, node_shader_init_valtorgb);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_valtorgb);
+ node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_valtorgb);
node_type_gpu(&ntype, gpu_shader_valtorgb);
ntype.expand_in_mf_network = sh_node_valtorgb_expand_in_mf_network;
@@ -215,7 +215,7 @@ void register_node_type_sh_rgbtobw(void)
sh_node_type_base(&ntype, SH_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_rgbtobw_in, sh_node_rgbtobw_out);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_rgbtobw);
+ node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_rgbtobw);
node_type_gpu(&ntype, gpu_shader_rgbtobw);
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/shader/nodes/node_shader_value.cc b/source/blender/nodes/shader/nodes/node_shader_value.cc
index 1a1382fa8af..5a8a1b847cc 100644
--- a/source/blender/nodes/shader/nodes/node_shader_value.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_value.cc
@@ -51,7 +51,7 @@ void register_node_type_sh_value(void)
static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_VALUE, "Value", NODE_CLASS_INPUT, 0);
- node_type_socket_templates(&ntype, NULL, sh_node_value_out);
+ node_type_socket_templates(&ntype, nullptr, sh_node_value_out);
node_type_gpu(&ntype, gpu_shader_value);
ntype.expand_in_mf_network = sh_node_value_expand_in_mf_network;
diff --git a/source/blender/nodes/simulation/nodes/node_sim_common.cc b/source/blender/nodes/simulation/nodes/node_sim_common.cc
index fbc03905d4f..fd26d450129 100644
--- a/source/blender/nodes/simulation/nodes/node_sim_common.cc
+++ b/source/blender/nodes/simulation/nodes/node_sim_common.cc
@@ -33,10 +33,10 @@ void register_node_type_sim_group(void)
ntype.insert_link = node_insert_link_default;
ntype.update_internal_links = node_update_internal_links_default;
ntype.rna_ext.srna = RNA_struct_find("SimulationNodeGroup");
- BLI_assert(ntype.rna_ext.srna != NULL);
+ BLI_assert(ntype.rna_ext.srna != nullptr);
RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype);
- node_type_socket_templates(&ntype, NULL, NULL);
+ node_type_socket_templates(&ntype, nullptr, nullptr);
node_type_size(&ntype, 140, 60, 400);
node_type_label(&ntype, node_group_label);
node_type_group_update(&ntype, node_group_update);
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 2d593c6218a..48027dc847b 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -48,7 +48,7 @@
#include "RNA_access.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
static void texture_get_from_context(const bContext *C,
bNodeTreeType *UNUSED(treetype),
diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h
index 01d1aa5cd62..74f27ef3974 100644
--- a/source/blender/nodes/texture/node_texture_util.h
+++ b/source/blender/nodes/texture/node_texture_util.h
@@ -61,7 +61,7 @@
#include "IMB_imbuf_types.h"
#include "RE_pipeline.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#ifdef __cplusplus
extern "C" {
diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c
index 2cd4e31feb3..a8a82153e58 100644
--- a/source/blender/nodes/texture/nodes/node_texture_proc.c
+++ b/source/blender/nodes/texture/nodes/node_texture_proc.c
@@ -24,7 +24,7 @@
#include "NOD_texture.h"
#include "node_texture_util.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
/*
* In this file: wrappers to use procedural textures as nodes
diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c
index 9551a10ee57..59e2e9be581 100644
--- a/source/blender/nodes/texture/nodes/node_texture_texture.c
+++ b/source/blender/nodes/texture/nodes/node_texture_texture.c
@@ -24,7 +24,7 @@
#include "NOD_texture.h"
#include "node_texture_util.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
static bNodeSocketTemplate inputs[] = {
{SOCK_RGBA, N_("Color1"), 1.0f, 1.0f, 1.0f, 1.0f},
diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c
index 2168e0d1730..03a890d315c 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.c
+++ b/source/blender/python/bmesh/bmesh_py_ops.c
@@ -166,10 +166,14 @@ static PyTypeObject bmesh_op_Type = {
sizeof(BPy_BMeshOpFunc), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- NULL, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
+ NULL, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
NULL,
/* tp_compare */ /* DEPRECATED in python 3.0! */
(reprfunc)bpy_bmesh_op_repr, /* tp_repr */
diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c
index 836f4f1a12c..0ec66e22fa9 100644
--- a/source/blender/python/generic/blf_py_api.c
+++ b/source/blender/python/generic/blf_py_api.c
@@ -373,7 +373,7 @@ static PyObject *py_blf_shadow(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
- if (level != 0 && level != 3 && level != 5) {
+ if (!ELEM(level, 0, 3, 5)) {
PyErr_SetString(PyExc_TypeError, "blf.shadow expected arg to be in (0, 3, 5)");
return NULL;
}
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index 6f5f36ec42f..a8b66f3f2fe 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -1197,8 +1197,12 @@ PyTypeObject BPy_IDGroup_Type = {
/* Methods to implement standard operations */
- NULL, /* destructor tp_dealloc; */
- (printfunc)NULL, /* printfunc tp_print; */
+ NULL, /* destructor tp_dealloc; */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* cmpfunc tp_compare; */
@@ -1606,8 +1610,12 @@ PyTypeObject BPy_IDArray_Type = {
/* Methods to implement standard operations */
- NULL, /* destructor tp_dealloc; */
- (printfunc)NULL, /* printfunc tp_print; */
+ NULL, /* destructor tp_dealloc; */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* cmpfunc tp_compare; */
@@ -1723,8 +1731,12 @@ PyTypeObject BPy_IDGroup_Iter_Type = {
/* Methods to implement standard operations */
- NULL, /* destructor tp_dealloc; */
- (printfunc)NULL, /* printfunc tp_print; */
+ NULL, /* destructor tp_dealloc; */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* cmpfunc tp_compare; */
diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c
index 5dc4aa6ce7c..3ea4550dd50 100644
--- a/source/blender/python/generic/imbuf_py_api.c
+++ b/source/blender/python/generic/imbuf_py_api.c
@@ -342,11 +342,15 @@ PyTypeObject Py_ImBuf_Type = {
/* Methods to implement standard operations */
(destructor)py_imbuf_dealloc, /* destructor tp_dealloc; */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- NULL, /* cmpfunc tp_compare; */
- (reprfunc)py_imbuf_repr, /* reprfunc tp_repr; */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
+ NULL, /* cmpfunc tp_compare; */
+ (reprfunc)py_imbuf_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 6c02e293789..d944cb435d0 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -893,18 +893,6 @@ void PyC_MainModule_Restore(PyObject *main_mod)
*/
void PyC_SetHomePath(const char *py_path_bundle)
{
- if (py_path_bundle == NULL) {
- /* Common enough to have bundled *nix python but complain on OSX/Win */
-# if defined(__APPLE__) || defined(_WIN32)
- fprintf(stderr,
- "Warning! bundled python not found and is expected on this platform. "
- "(if you built with CMake: 'install' target may have not been built)\n");
-# endif
- return;
- }
- /* set the environment path */
- printf("found bundled python: %s\n", py_path_bundle);
-
# ifdef __APPLE__
/* OSX allow file/directory names to contain : character (represented as / in the Finder)
* but current Python lib (release 3.1.1) doesn't handle these correctly */
@@ -915,19 +903,14 @@ void PyC_SetHomePath(const char *py_path_bundle)
}
# endif
- {
- wchar_t py_path_bundle_wchar[1024];
-
- /* Can't use this, on linux gives bug: T23018,
- * TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 2008 */
- /* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */
+ /* Set the environment path. */
+ wchar_t py_path_bundle_wchar[1024];
- BLI_strncpy_wchar_from_utf8(
- py_path_bundle_wchar, py_path_bundle, ARRAY_SIZE(py_path_bundle_wchar));
+ /* Can't use `mbstowcs` on linux gives bug: T23018. */
+ BLI_strncpy_wchar_from_utf8(
+ py_path_bundle_wchar, py_path_bundle, ARRAY_SIZE(py_path_bundle_wchar));
- Py_SetPythonHome(py_path_bundle_wchar);
- // printf("found python (wchar_t) '%ls'\n", py_path_bundle_wchar);
- }
+ Py_SetPythonHome(py_path_bundle_wchar);
}
bool PyC_IsInterpreterActive(void)
diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c
index 3748691c434..c90a4a7bc9d 100644
--- a/source/blender/python/gpu/gpu_py_shader.c
+++ b/source/blender/python/gpu/gpu_py_shader.c
@@ -64,6 +64,7 @@ static int bpygpu_ParseBultinShaderEnum(PyObject *o, void *p)
MATCH_ID(3D_UNIFORM_COLOR);
MATCH_ID(3D_FLAT_COLOR);
MATCH_ID(3D_SMOOTH_COLOR);
+ MATCH_ID(3D_POLYLINE_UNIFORM_COLOR);
#undef MATCH_ID
PyErr_Format(PyExc_ValueError, "unknown type literal: '%s'", mode_id);
diff --git a/source/blender/python/intern/bpy.h b/source/blender/python/intern/bpy.h
index e2fe84f71c7..25a047edfb5 100644
--- a/source/blender/python/intern/bpy.h
+++ b/source/blender/python/intern/bpy.h
@@ -35,6 +35,7 @@ void BPY_atexit_unregister(void);
extern struct CLG_LogRef *BPY_LOG_CONTEXT;
extern struct CLG_LogRef *BPY_LOG_RNA;
+extern struct CLG_LogRef *BPY_LOG_INTERFACE;
#ifdef __cplusplus
}
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index 8354e220b09..02ab001dbf6 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -82,6 +82,7 @@ static PyTypeObject BlenderAppType;
static PyStructSequence_Field app_info_fields[] = {
{"version", "The Blender version as a tuple of 3 numbers. eg. (2, 83, 1)"},
+ {"version_file", "The blend file version, compatible with ``bpy.data.version``"},
{"version_string", "The Blender version formatted as a string"},
{"version_cycle", "The release status of this build alpha/beta/rc/release"},
{"version_char", "Deprecated, always an empty string"},
@@ -151,6 +152,8 @@ static PyObject *make_app_info(void)
SetObjItem(
PyC_Tuple_Pack_I32(BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_VERSION_PATCH));
+ SetObjItem(PyC_Tuple_Pack_I32(
+ BLENDER_FILE_VERSION / 100, BLENDER_FILE_VERSION % 100, BLENDER_FILE_SUBVERSION));
SetStrItem(BKE_blender_version_string());
SetStrItem(STRINGIFY(BLENDER_VERSION_CYCLE));
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c
index 476ddf2019a..ee64d0a409c 100644
--- a/source/blender/python/intern/bpy_app_translations.c
+++ b/source/blender/python/intern/bpy_app_translations.c
@@ -420,9 +420,9 @@ static BLT_i18n_contexts_descriptor _contexts[] = BLT_I18NCONTEXTS_DESC;
static PyStructSequence_Field app_translations_contexts_fields[ARRAY_SIZE(_contexts)] = {{NULL}};
static PyStructSequence_Desc app_translations_contexts_desc = {
- "bpy.app.translations.contexts", /* name */
- "This named tuple contains all pre-defined translation contexts", /* doc */
- app_translations_contexts_fields, /* fields */
+ "bpy.app.translations.contexts", /* name */
+ "This named tuple contains all predefined translation contexts", /* doc */
+ app_translations_contexts_fields, /* fields */
ARRAY_SIZE(app_translations_contexts_fields) - 1,
};
@@ -464,7 +464,7 @@ static PyObject *app_translations_contexts_make(void)
* \{ */
PyDoc_STRVAR(app_translations_contexts_doc,
- "A named tuple containing all pre-defined translation contexts.\n"
+ "A named tuple containing all predefined translation contexts.\n"
"\n"
".. warning::\n"
" Never use a (new) context starting with \"" BLT_I18NCONTEXT_DEFAULT_BPYRNA
@@ -794,10 +794,14 @@ static PyTypeObject BlenderAppTranslationsType = {
0, /* tp_itemsize */
/* methods */
/* No destructor, this is a singleton! */
- NULL, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
+ NULL, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
NULL,
/* tp_compare */ /* DEPRECATED in python 3.0! */
NULL, /* tp_repr */
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index d72c2ccfcff..0b11ac639c7 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -80,6 +80,7 @@
/* Logging types to use anywhere in the Python modules. */
CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_CONTEXT, "bpy.context");
+CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_INTERFACE, "bpy.interface");
CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_RNA, "bpy.rna");
/* for internal use, when starting and ending python scripts */
@@ -304,7 +305,6 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
{
#ifndef WITH_PYTHON_MODULE
PyThreadState *py_tstate = NULL;
- const char *py_path_bundle = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, NULL);
/* Needed for Python's initialization for portable Python installations.
* We could use #Py_SetPath, but this overrides Python's internal logic
@@ -321,8 +321,21 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
/* must run before python initializes */
PyImport_ExtendInittab(bpy_internal_modules);
- /* allow to use our own included python */
- PyC_SetHomePath(py_path_bundle);
+ /* Allow to use our own included Python. `py_path_bundle` may be NULL. */
+ {
+ const char *py_path_bundle = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, NULL);
+ if (py_path_bundle != NULL) {
+ PyC_SetHomePath(py_path_bundle);
+ }
+ else {
+ /* Common enough to use the system Python on Linux/Unix, warn on other systems. */
+# if defined(__APPLE__) || defined(_WIN32)
+ fprintf(stderr,
+ "Bundled Python not found and is expected on this platform "
+ "(the 'install' target may have not been built)\n");
+# endif
+ }
+ }
/* Without this the `sys.stdout` may be set to 'ascii'
* (it is on my system at least), where printing unicode values will raise
@@ -343,17 +356,16 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
/* Initialize Python (also acquires lock). */
Py_Initialize();
- // PySys_SetArgv(argc, argv); /* broken in py3, not a huge deal */
- /* sigh, why do python guys not have a (char **) version anymore? */
+ /* We could convert to #wchar_t then pass to #PySys_SetArgv (or use #PyConfig in Python 3.8+).
+ * However this risks introducing subtle changes in encoding that are hard to track down.
+ *
+ * So rely on #PyC_UnicodeFromByte since it's a tried & true way of getting paths
+ * that include non `utf-8` compatible characters, see: T20021. */
{
- int i;
PyObject *py_argv = PyList_New(argc);
- for (i = 0; i < argc; i++) {
- /* should fix bug T20021 - utf path name problems, by replacing
- * PyUnicode_FromString, with this one */
+ for (int i = 0; i < argc; i++) {
PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i]));
}
-
PySys_SetObject("argv", py_argv);
Py_DECREF(py_argv);
}
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index 061595a6c5d..bc3d8b2c360 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -92,9 +92,13 @@ static PyTypeObject bpy_lib_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)bpy_lib_dealloc, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
NULL,
/* tp_compare */ /* DEPRECATED in python 3.0! */
NULL, /* tp_repr */
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 0c8728f70fc..5ac76ab9ac1 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -118,7 +118,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
}
}
- if (context_dict == NULL || context_dict == Py_None) {
+ if (ELEM(context_dict, NULL, Py_None)) {
context_dict = NULL;
}
else if (!PyDict_Check(context_dict)) {
@@ -220,7 +220,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
}
}
- if (context_dict == NULL || context_dict == Py_None) {
+ if (ELEM(context_dict, NULL, Py_None)) {
context_dict = NULL;
}
else if (!PyDict_Check(context_dict)) {
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 53c89f64bc1..6e41bc96eed 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -5431,7 +5431,7 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self,
/* Get/set both take the same args currently. */
PyObject *seq;
- if (prop_type != PROP_INT && prop_type != PROP_FLOAT) {
+ if (!ELEM(prop_type, PROP_INT, PROP_FLOAT)) {
PyErr_Format(PyExc_TypeError, "foreach_get/set available only for int and float");
return NULL;
}
@@ -6403,10 +6403,14 @@ PyTypeObject pyrna_struct_meta_idprop_Type = {
0, /* tp_itemsize */
/* methods */
- NULL, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
+ NULL, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
NULL,
/* tp_compare */ /* deprecated in Python 3.0! */
NULL, /* tp_repr */
@@ -6456,7 +6460,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type = {
#if defined(_MSC_VER)
NULL, /* defer assignment */
#else
- &PyType_Type, /* struct _typeobject *tp_base; */
+ &PyType_Type, /* struct _typeobject *tp_base; */
#endif
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
@@ -6485,9 +6489,13 @@ PyTypeObject pyrna_struct_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)pyrna_struct_dealloc, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
NULL,
/* tp_compare */ /* DEPRECATED in Python 3.0! */
(reprfunc)pyrna_struct_repr, /* tp_repr */
@@ -6521,7 +6529,7 @@ PyTypeObject pyrna_struct_Type = {
/* delete references to contained objects */
(inquiry)pyrna_struct_clear, /* inquiry tp_clear; */
#else
- NULL, /* traverseproc tp_traverse; */
+ NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
@@ -6574,9 +6582,13 @@ PyTypeObject pyrna_prop_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)pyrna_prop_dealloc, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
NULL,
/* tp_compare */ /* DEPRECATED in Python 3.0! */
(reprfunc)pyrna_prop_repr, /* tp_repr */
@@ -6658,9 +6670,13 @@ PyTypeObject pyrna_prop_array_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)pyrna_prop_array_dealloc, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
NULL,
/* tp_compare */ /* DEPRECATED in Python 3.0! */
(reprfunc)pyrna_prop_array_repr, /* tp_repr */
@@ -6741,9 +6757,13 @@ PyTypeObject pyrna_prop_collection_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)pyrna_prop_dealloc, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
NULL,
/* tp_compare */ /* DEPRECATED in Python 3.0! */
NULL,
@@ -6827,9 +6847,13 @@ static PyTypeObject pyrna_prop_collection_idprop_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)pyrna_prop_dealloc, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
NULL,
/* tp_compare */ /* DEPRECATED in Python 3.0! */
NULL,
@@ -6912,10 +6936,14 @@ PyTypeObject pyrna_func_Type = {
sizeof(BPy_FunctionRNA), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- NULL, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
+ NULL, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
NULL,
/* tp_compare */ /* DEPRECATED in Python 3.0! */
(reprfunc)pyrna_func_repr, /* tp_repr */
@@ -7009,9 +7037,13 @@ static PyTypeObject pyrna_prop_collection_iter_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)pyrna_prop_collection_iter_dealloc, /* tp_dealloc */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
+# if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+# else
+ (printfunc)NULL, /* printfunc tp_print */
+# endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
NULL,
/* tp_compare */ /* DEPRECATED in Python 3.0! */
NULL,
diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.c
index a58e2bcb975..b460ef5e0c0 100644
--- a/source/blender/python/intern/bpy_utils_units.c
+++ b/source/blender/python/intern/bpy_utils_units.c
@@ -73,15 +73,15 @@ static PyStructSequence_Field bpyunits_systems_fields[ARRAY_SIZE(bpyunits_usyste
static PyStructSequence_Field bpyunits_categories_fields[ARRAY_SIZE(bpyunits_ucategorie_items)];
static PyStructSequence_Desc bpyunits_systems_desc = {
- "bpy.utils.units.systems", /* name */
- "This named tuple contains all pre-defined unit systems", /* doc */
- bpyunits_systems_fields, /* fields */
+ "bpy.utils.units.systems", /* name */
+ "This named tuple contains all predefined unit systems", /* doc */
+ bpyunits_systems_fields, /* fields */
ARRAY_SIZE(bpyunits_systems_fields) - 1,
};
static PyStructSequence_Desc bpyunits_categories_desc = {
- "bpy.utils.units.categories", /* name */
- "This named tuple contains all pre-defined unit names", /* doc */
- bpyunits_categories_fields, /* fields */
+ "bpy.utils.units.categories", /* name */
+ "This named tuple contains all predefined unit names", /* doc */
+ bpyunits_categories_fields, /* fields */
ARRAY_SIZE(bpyunits_categories_fields) - 1,
};
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 0b9fa1841ec..87d16656d70 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -514,7 +514,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
angle = angle_wrap_rad(angle);
- if (matSize != 2 && matSize != 3 && matSize != 4) {
+ if (!ELEM(matSize, 2, 3, 4)) {
PyErr_SetString(PyExc_ValueError,
"Matrix.Rotation(): "
"can only return a 2x2 3x3 or 4x4 matrix");
@@ -653,7 +653,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
if (!PyArg_ParseTuple(args, "fi|O:Matrix.Scale", &factor, &matSize, &vec)) {
return NULL;
}
- if (matSize != 2 && matSize != 3 && matSize != 4) {
+ if (!ELEM(matSize, 2, 3, 4)) {
PyErr_SetString(PyExc_ValueError,
"Matrix.Scale(): "
"can only return a 2x2 3x3 or 4x4 matrix");
@@ -759,7 +759,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
if (!PyArg_ParseTuple(args, "Oi:Matrix.OrthoProjection", &axis, &matSize)) {
return NULL;
}
- if (matSize != 2 && matSize != 3 && matSize != 4) {
+ if (!ELEM(matSize, 2, 3, 4)) {
PyErr_SetString(PyExc_ValueError,
"Matrix.OrthoProjection(): "
"can only return a 2x2 3x3 or 4x4 matrix");
@@ -895,7 +895,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args)
if (!PyArg_ParseTuple(args, "siO:Matrix.Shear", &plane, &matSize, &fac)) {
return NULL;
}
- if (matSize != 2 && matSize != 3 && matSize != 4) {
+ if (!ELEM(matSize, 2, 3, 4)) {
PyErr_SetString(PyExc_ValueError,
"Matrix.Shear(): "
"can only return a 2x2 3x3 or 4x4 matrix");
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 80efbf6fbac..61487df1ab5 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -3042,11 +3042,15 @@ PyTypeObject vector_Type = {
/* Methods to implement standard operations */
(destructor)BaseMathObject_dealloc, /* destructor tp_dealloc; */
- (printfunc)NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
- NULL, /* setattrfunc tp_setattr; */
- NULL, /* cmpfunc tp_compare; */
- (reprfunc)Vector_repr, /* reprfunc tp_repr; */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
+ (printfunc)NULL, /* printfunc tp_print */
+#endif
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
+ NULL, /* cmpfunc tp_compare; */
+ (reprfunc)Vector_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */
@@ -3061,7 +3065,7 @@ PyTypeObject vector_Type = {
#ifndef MATH_STANDALONE
(reprfunc)Vector_str, /* reprfunc tp_str; */
#else
- NULL, /* reprfunc tp_str; */
+ NULL, /* reprfunc tp_str; */
#endif
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index ad5f1a486b4..77ced169dab 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -1062,6 +1062,20 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje
return Vector_CreatePyObject(pt_dst, 3, NULL);
}
+struct PointsInPlanes_UserData {
+ PyObject *py_verts;
+ char *planes_used;
+};
+
+static void points_in_planes_fn(const float co[3], int i, int j, int k, void *user_data_p)
+{
+ struct PointsInPlanes_UserData *user_data = user_data_p;
+ PyList_APPEND(user_data->py_verts, Vector_CreatePyObject(co, 3, NULL));
+ user_data->planes_used[i] = true;
+ user_data->planes_used[j] = true;
+ user_data->planes_used[k] = true;
+}
+
PyDoc_STRVAR(M_Geometry_points_in_planes_doc,
".. function:: points_in_planes(planes)\n"
"\n"
@@ -1073,7 +1087,6 @@ PyDoc_STRVAR(M_Geometry_points_in_planes_doc,
" :return: two lists, once containing the vertices inside the planes, another "
"containing the plane indices used\n"
" :rtype: pair of lists\n");
-/* note: this function could be optimized by some spatial structure */
static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *args)
{
PyObject *py_planes;
@@ -1090,81 +1103,37 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a
}
/* note, this could be refactored into plain C easy - py bits are noted */
- const float eps = 0.0001f;
- const uint len = (uint)planes_len;
- uint i, j, k, l;
- float n1n2[3], n2n3[3], n3n1[3];
- float potentialVertex[3];
- char *planes_used = PyMem_Malloc(sizeof(char) * len);
+ struct PointsInPlanes_UserData user_data = {
+ .py_verts = PyList_New(0),
+ .planes_used = PyMem_Malloc(sizeof(char) * planes_len),
+ };
/* python */
- PyObject *py_verts = PyList_New(0);
PyObject *py_plane_index = PyList_New(0);
- memset(planes_used, 0, sizeof(char) * len);
+ memset(user_data.planes_used, 0, sizeof(char) * planes_len);
- for (i = 0; i < len; i++) {
- const float *N1 = planes[i];
- for (j = i + 1; j < len; j++) {
- const float *N2 = planes[j];
- cross_v3_v3v3(n1n2, N1, N2);
- if (len_squared_v3(n1n2) > eps) {
- for (k = j + 1; k < len; k++) {
- const float *N3 = planes[k];
- cross_v3_v3v3(n2n3, N2, N3);
- if (len_squared_v3(n2n3) > eps) {
- cross_v3_v3v3(n3n1, N3, N1);
- if (len_squared_v3(n3n1) > eps) {
- const float quotient = dot_v3v3(N1, n2n3);
- if (fabsf(quotient) > eps) {
- /**
- * <pre>
- * potentialVertex = (
- * (n2n3 * N1[3] + n3n1 * N2[3] + n1n2 * N3[3]) *
- * (-1.0 / quotient));
- * </pre>
- */
- const float quotient_ninv = -1.0f / quotient;
- potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) + (n1n2[0] * N3[3])) *
- quotient_ninv;
- potentialVertex[1] = ((n2n3[1] * N1[3]) + (n3n1[1] * N2[3]) + (n1n2[1] * N3[3])) *
- quotient_ninv;
- potentialVertex[2] = ((n2n3[2] * N1[3]) + (n3n1[2] * N2[3]) + (n1n2[2] * N3[3])) *
- quotient_ninv;
- for (l = 0; l < len; l++) {
- const float *NP = planes[l];
- if ((dot_v3v3(NP, potentialVertex) + NP[3]) > 0.000001f) {
- break;
- }
- }
-
- if (l == len) { /* ok */
- /* python */
- PyList_APPEND(py_verts, Vector_CreatePyObject(potentialVertex, 3, NULL));
- planes_used[i] = planes_used[j] = planes_used[k] = true;
- }
- }
- }
- }
- }
- }
- }
- }
+ const float eps_coplanar = 1e-4f;
+ const float eps_isect = 1e-6f;
+ const bool has_isect = isect_planes_v3_fn(
+ planes, planes_len, eps_coplanar, eps_isect, points_in_planes_fn, &user_data);
PyMem_Free(planes);
- /* now make a list of used planes */
- for (i = 0; i < len; i++) {
- if (planes_used[i]) {
- PyList_APPEND(py_plane_index, PyLong_FromLong(i));
+ /* Now make user_data list of used planes. */
+ if (has_isect) {
+ for (int i = 0; i < planes_len; i++) {
+ if (user_data.planes_used[i]) {
+ PyList_APPEND(py_plane_index, PyLong_FromLong(i));
+ }
}
}
- PyMem_Free(planes_used);
+ PyMem_Free(user_data.planes_used);
{
PyObject *ret = PyTuple_New(2);
- PyTuple_SET_ITEMS(ret, py_verts, py_plane_index);
+ PyTuple_SET_ITEMS(ret, user_data.py_verts, py_plane_index);
return ret;
}
}
diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c
index 49a3f114ebb..c24960f2d04 100644
--- a/source/blender/python/mathutils/mathutils_noise.c
+++ b/source/blender/python/mathutils/mathutils_noise.c
@@ -179,7 +179,7 @@ static float frand(void)
y ^= (y << 15) & 0xefc60000UL;
y ^= (y >> 18);
- return (float)y / 4294967296.f;
+ return (float)y / 4294967296.0f;
}
/*------------------------------------------------------------*/
@@ -246,7 +246,8 @@ static void noise_vector(float x, float y, float z, int nb, float v[3])
/* Simply evaluate noise at 3 different positions */
const float *ofs = state_offset_vector;
for (int j = 0; j < 3; j++) {
- v[j] = (2.0f * BLI_gNoise(1.0f, x + ofs[0], y + ofs[1], z + ofs[2], 0, nb) - 1.0f);
+ v[j] = (2.0f * BLI_noise_generic_noise(1.0f, x + ofs[0], y + ofs[1], z + ofs[2], false, nb) -
+ 1.0f);
ofs += 3;
}
}
@@ -257,8 +258,8 @@ static float turb(
{
float amp, out, t;
int i;
- amp = 1.f;
- out = (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f);
+ amp = 1.0f;
+ out = (float)(2.0f * BLI_noise_generic_noise(1.0f, x, y, z, false, nb) - 1.0f);
if (hard) {
out = fabsf(out);
}
@@ -267,7 +268,7 @@ static float turb(
x *= freqscale;
y *= freqscale;
z *= freqscale;
- t = (float)(amp * (2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f));
+ t = (float)(amp * (2.0f * BLI_noise_generic_noise(1.0f, x, y, z, false, nb) - 1.0f));
if (hard) {
t = fabsf(t);
}
@@ -290,7 +291,7 @@ static void vTurb(float x,
{
float amp, t[3];
int i;
- amp = 1.f;
+ amp = 1.0f;
noise_vector(x, y, z, nb, v);
if (hard) {
v[0] = fabsf(v[0]);
@@ -450,7 +451,8 @@ static PyObject *M_Noise_noise(PyObject *UNUSED(self), PyObject *args, PyObject
}
return PyFloat_FromDouble(
- (2.0f * BLI_gNoise(1.0f, vec[0], vec[1], vec[2], 0, noise_basis_enum) - 1.0f));
+ (2.0f * BLI_noise_generic_noise(1.0f, vec[0], vec[1], vec[2], false, noise_basis_enum) -
+ 1.0f));
}
PyDoc_STRVAR(M_Noise_noise_vector_doc,
@@ -659,7 +661,8 @@ static PyObject *M_Noise_fractal(PyObject *UNUSED(self), PyObject *args, PyObjec
return NULL;
}
- return PyFloat_FromDouble(mg_fBm(vec[0], vec[1], vec[2], H, lac, oct, noise_basis_enum));
+ return PyFloat_FromDouble(
+ BLI_noise_mg_fbm(vec[0], vec[1], vec[2], H, lac, oct, noise_basis_enum));
}
PyDoc_STRVAR(
@@ -713,7 +716,7 @@ static PyObject *M_Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args, P
}
return PyFloat_FromDouble(
- mg_MultiFractal(vec[0], vec[1], vec[2], H, lac, oct, noise_basis_enum));
+ BLI_noise_mg_multi_fractal(vec[0], vec[1], vec[2], H, lac, oct, noise_basis_enum));
}
PyDoc_STRVAR(M_Noise_variable_lacunarity_doc,
@@ -780,8 +783,8 @@ static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *a
return NULL;
}
- return PyFloat_FromDouble(
- mg_VLNoise(vec[0], vec[1], vec[2], d, noise_type1_enum, noise_type2_enum));
+ return PyFloat_FromDouble(BLI_noise_mg_variable_lacunarity(
+ vec[0], vec[1], vec[2], d, noise_type1_enum, noise_type2_enum));
}
PyDoc_STRVAR(
@@ -838,7 +841,7 @@ static PyObject *M_Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args,
}
return PyFloat_FromDouble(
- mg_HeteroTerrain(vec[0], vec[1], vec[2], H, lac, oct, ofs, noise_basis_enum));
+ BLI_noise_mg_hetero_terrain(vec[0], vec[1], vec[2], H, lac, oct, ofs, noise_basis_enum));
}
PyDoc_STRVAR(
@@ -899,8 +902,8 @@ static PyObject *M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject *
return NULL;
}
- return PyFloat_FromDouble(
- mg_HybridMultiFractal(vec[0], vec[1], vec[2], H, lac, oct, ofs, gn, noise_basis_enum));
+ return PyFloat_FromDouble(BLI_noise_mg_hybrid_multi_fractal(
+ vec[0], vec[1], vec[2], H, lac, oct, ofs, gn, noise_basis_enum));
}
PyDoc_STRVAR(
@@ -961,8 +964,8 @@ static PyObject *M_Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject *
return NULL;
}
- return PyFloat_FromDouble(
- mg_RidgedMultiFractal(vec[0], vec[1], vec[2], H, lac, oct, ofs, gn, noise_basis_enum));
+ return PyFloat_FromDouble(BLI_noise_mg_ridged_multi_fractal(
+ vec[0], vec[1], vec[2], H, lac, oct, ofs, gn, noise_basis_enum));
}
PyDoc_STRVAR(M_Noise_voronoi_doc,
@@ -1008,7 +1011,7 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args, PyObjec
list = PyList_New(4);
- voronoi(vec[0], vec[1], vec[2], da, pa, me, metric_enum);
+ BLI_noise_voronoi(vec[0], vec[1], vec[2], da, pa, me, metric_enum);
for (i = 0; i < 4; i++) {
PyObject *v = Vector_CreatePyObject(pa + 3 * i, 3, NULL);
@@ -1042,7 +1045,7 @@ static PyObject *M_Noise_cell(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
- return PyFloat_FromDouble(cellNoise(vec[0], vec[1], vec[2]));
+ return PyFloat_FromDouble(BLI_noise_cell(vec[0], vec[1], vec[2]));
}
PyDoc_STRVAR(M_Noise_cell_vector_doc,
@@ -1067,7 +1070,7 @@ static PyObject *M_Noise_cell_vector(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
- cellNoiseV(vec[0], vec[1], vec[2], r_vec);
+ BLI_noise_cell_v3(vec[0], vec[1], vec[2], r_vec);
return Vector_CreatePyObject(r_vec, 3, NULL);
}
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt
index 598e6e019d4..d1f69ddfc02 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -20,8 +20,8 @@
set(INC
- extern/include
- intern/include
+ .
+ intern
../blenkernel
../blenlib
../blentranslation
@@ -42,29 +42,29 @@ set(INC
set(SRC
- intern/source/bake_api.c
- intern/source/external_engine.c
- intern/source/imagetexture.c
- intern/source/initrender.c
- intern/source/multires_bake.c
- intern/source/pipeline.c
- intern/source/pointdensity.c
- intern/source/render_result.c
- intern/source/render_texture.c
- intern/source/zbuf.c
+ intern/bake.c
+ intern/engine.c
+ intern/initrender.c
+ intern/multires_bake.c
+ intern/pipeline.c
+ intern/render_result.c
+ intern/texture_image.c
+ intern/texture_pointdensity.c
+ intern/texture_procedural.c
+ intern/zbuf.c
- extern/include/RE_bake.h
- extern/include/RE_engine.h
- extern/include/RE_multires_bake.h
- extern/include/RE_pipeline.h
- extern/include/RE_render_ext.h
- extern/include/RE_shader_ext.h
- intern/include/initrender.h
- intern/include/render_result.h
- intern/include/render_types.h
- intern/include/renderpipeline.h
- intern/include/texture.h
- intern/include/zbuf.h
+ RE_bake.h
+ RE_engine.h
+ RE_multires_bake.h
+ RE_pipeline.h
+ RE_texture.h
+
+ intern/initrender.h
+ intern/render_result.h
+ intern/render_types.h
+ intern/pipeline.h
+ intern/texture_common.h
+ intern/zbuf.h
)
set(LIB
@@ -98,13 +98,5 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
-if(APPLE)
- # SSE math is enabled by default on x86_64
- if(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfpmath=sse")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mfpmath=sse")
- endif()
-endif()
-
blender_add_lib_nolist(bf_render "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/render/extern/include/RE_bake.h b/source/blender/render/RE_bake.h
index 3ed41ede006..3ed41ede006 100644
--- a/source/blender/render/extern/include/RE_bake.h
+++ b/source/blender/render/RE_bake.h
diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/RE_engine.h
index a153c622af8..a153c622af8 100644
--- a/source/blender/render/extern/include/RE_engine.h
+++ b/source/blender/render/RE_engine.h
diff --git a/source/blender/render/extern/include/RE_multires_bake.h b/source/blender/render/RE_multires_bake.h
index c48ce7bfd6e..fd200e85719 100644
--- a/source/blender/render/extern/include/RE_multires_bake.h
+++ b/source/blender/render/RE_multires_bake.h
@@ -33,7 +33,6 @@ extern "C" {
typedef struct MultiresBakeRender {
Scene *scene;
DerivedMesh *lores_dm, *hires_dm;
- bool simple;
int bake_filter; /* Bake-filter, aka margin */
int lvl, tot_lvl;
short mode;
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/RE_pipeline.h
index 089c7eb044b..4dd2b300700 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/RE_pipeline.h
@@ -159,7 +159,6 @@ typedef struct RenderResult {
typedef struct RenderStats {
int cfra;
- int totface, totvert, totlamp, totpart;
bool localview;
double starttime, lastframetime;
const char *infostr, *statstr;
diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/RE_texture.h
index 76812840c91..b394cfeee75 100644
--- a/source/blender/render/extern/include/RE_render_ext.h
+++ b/source/blender/render/RE_texture.h
@@ -30,12 +30,13 @@
struct Depsgraph;
struct ImagePool;
struct MTex;
+struct Tex;
#ifdef __cplusplus
extern "C" {
#endif
-/* render_texture.c */
+/* texture_procedural.c */
bool RE_texture_evaluate(const struct MTex *mtex,
const float vec[3],
const int thread,
@@ -53,10 +54,10 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
void RE_texture_rng_init(void);
void RE_texture_rng_exit(void);
-/* imagetexture.c */
+/* texture_image.c */
void ibuf_sample(struct ImBuf *ibuf, float fx, float fy, float dx, float dy, float result[4]);
-/* pointdensity.c */
+/* texture_pointdensity.c */
struct PointDensity;
void RE_point_density_cache(struct Depsgraph *depsgraph, struct PointDensity *pd);
@@ -75,6 +76,46 @@ void RE_point_density_free(struct PointDensity *pd);
void RE_point_density_fix_linking(void);
+/* texture_procedural.c */
+
+/* Texture evaluation result.
+ * Note; tr tg tb ta has to remain in this order for array access. */
+typedef struct TexResult {
+ float tin, tr, tg, tb, ta;
+ int talpha;
+ float *nor;
+} TexResult;
+
+/* This one uses nodes. */
+int multitex_ext(struct Tex *tex,
+ float texvec[3],
+ float dxt[3],
+ float dyt[3],
+ int osatex,
+ struct TexResult *texres,
+ const short thread,
+ struct ImagePool *pool,
+ bool scene_color_manage,
+ const bool skip_load_image);
+/* Nodes disabled. */
+int multitex_ext_safe(struct Tex *tex,
+ const float texvec[3],
+ struct TexResult *texres,
+ struct ImagePool *pool,
+ bool scene_color_manage,
+ const bool skip_load_image);
+/* Only for internal node usage. */
+int multitex_nodes(struct Tex *tex,
+ const float texvec[3],
+ float dxt[3],
+ float dyt[3],
+ int osatex,
+ struct TexResult *texres,
+ const short thread,
+ short which_output,
+ struct MTex *mtex,
+ struct ImagePool *pool);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
deleted file mode 100644
index d9d5a924949..00000000000
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2006 by Blender Foundation
- * All rights reserved.
- */
-/** \file
- * \ingroup render
- */
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* this include is for texture exports */
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-
-/* localized texture result data */
-/* note; tr tg tb ta has to remain in this order */
-typedef struct TexResult {
- float tin, tr, tg, tb, ta;
- int talpha;
- float *nor;
-} TexResult;
-
-typedef struct BakeImBufuserData {
- float *displacement_buffer;
- char *mask_buffer;
-} BakeImBufuserData;
-
-/* node shaders... */
-struct ImagePool;
-struct MTex;
-struct Tex;
-
-/* this one uses nodes */
-int multitex_ext(struct Tex *tex,
- float texvec[3],
- float dxt[3],
- float dyt[3],
- int osatex,
- struct TexResult *texres,
- const short thread,
- struct ImagePool *pool,
- bool scene_color_manage,
- const bool skip_load_image);
-/* nodes disabled */
-int multitex_ext_safe(struct Tex *tex,
- const float texvec[3],
- struct TexResult *texres,
- struct ImagePool *pool,
- bool scene_color_manage,
- const bool skip_load_image);
-/* only for internal node usage */
-int multitex_nodes(struct Tex *tex,
- const float texvec[3],
- float dxt[3],
- float dyt[3],
- int osatex,
- struct TexResult *texres,
- const short thread,
- short which_output,
- struct MTex *mtex,
- struct ImagePool *pool);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/bake.c
index 6f5db4986f2..6f5db4986f2 100644
--- a/source/blender/render/intern/source/bake_api.c
+++ b/source/blender/render/intern/bake.c
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/engine.c
index 31b20008b52..769077c0e8c 100644
--- a/source/blender/render/intern/source/external_engine.c
+++ b/source/blender/render/intern/engine.c
@@ -63,9 +63,9 @@
#include "DRW_engine.h"
#include "initrender.h"
+#include "pipeline.h"
#include "render_result.h"
#include "render_types.h"
-#include "renderpipeline.h"
/* Render Engine Types */
@@ -376,8 +376,8 @@ void RE_engine_end_result(
pa->status = (!cancel && merge_results) ? PART_STATUS_MERGED : PART_STATUS_RENDERED;
}
else if (re->result->do_exr_tile) {
- /* if written result does not match any tile and we are using save
- * buffers, we are going to get openexr save errors */
+ /* If written result does not match any tile and we are using save
+ * buffers, we are going to get OpenEXR save errors. */
fprintf(stderr, "RenderEngine.end_result: dimensions do not match any OpenEXR tile.\n");
}
}
@@ -676,7 +676,6 @@ bool RE_bake_engine(Render *re,
/* set render info */
re->i.cfra = re->scene->r.cfra;
BLI_strncpy(re->i.scene_name, re->scene->id.name + 2, sizeof(re->i.scene_name) - 2);
- re->i.totface = re->i.totvert = re->i.totlamp = 0;
/* render */
engine = re->engine;
@@ -867,7 +866,6 @@ int RE_engine_render(Render *re, int do_all)
/* set render info */
re->i.cfra = re->scene->r.cfra;
BLI_strncpy(re->i.scene_name, re->scene->id.name + 2, sizeof(re->i.scene_name));
- re->i.totface = re->i.totvert = re->i.totlamp = 0;
/* render */
RenderEngine *engine = re->engine;
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/initrender.c
index d1632dfeacd..fb7f7270c13 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/initrender.c
@@ -40,8 +40,8 @@
#include "BKE_camera.h"
/* this module */
+#include "pipeline.h"
#include "render_types.h"
-#include "renderpipeline.h"
/* Own includes */
#include "initrender.h"
@@ -268,9 +268,6 @@ void RE_parts_init(Render *re)
re->parts = BLI_ghash_new(
BLI_ghashutil_inthash_v4_p, BLI_ghashutil_inthash_v4_cmp, "render parts");
- /* this is render info for caller, is not reset when parts are freed! */
- re->i.totpart = 0;
-
/* just for readable code.. */
xminb = re->disprect.xmin;
yminb = re->disprect.ymin;
@@ -328,7 +325,6 @@ void RE_parts_init(Render *re)
pa->recty = recty;
BLI_ghash_insert(re->parts, &pa->disprect, pa);
- re->i.totpart++;
}
}
}
diff --git a/source/blender/render/intern/include/initrender.h b/source/blender/render/intern/initrender.h
index f5ac352752f..f5ac352752f 100644
--- a/source/blender/render/intern/include/initrender.h
+++ b/source/blender/render/intern/initrender.h
diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/multires_bake.c
index f12b425ee8b..a4f68419c67 100644
--- a/source/blender/render/intern/source/multires_bake.c
+++ b/source/blender/render/intern/multires_bake.c
@@ -46,7 +46,7 @@
#include "RE_multires_bake.h"
#include "RE_pipeline.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -111,6 +111,11 @@ typedef struct {
const int *orig_index_mp_to_orig;
} MNormalBakeData;
+typedef struct BakeImBufuserData {
+ float *displacement_buffer;
+ char *mask_buffer;
+} BakeImBufuserData;
+
static void multiresbake_get_normal(const MResolvePixelData *data,
float norm[],
const int tri_num,
@@ -766,10 +771,6 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima)
smd.uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS;
smd.quality = 3;
- if (bkr->simple) {
- smd.subdivType = ME_SIMPLE_SUBSURF;
- }
-
height_data->ssdm = subsurf_make_derived_from_derived(
bkr->lores_dm, &smd, bkr->scene, NULL, 0);
init_ccgdm_arrays(height_data->ssdm);
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/pipeline.c
index 917193553dc..3d19e5e6c15 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/pipeline.c
@@ -70,7 +70,6 @@
#include "BKE_pointcache.h"
#include "BKE_report.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
#include "BKE_sound.h"
#include "BKE_writeavi.h" /* <------ should be replaced once with generic movie module */
@@ -87,10 +86,12 @@
#include "RE_engine.h"
#include "RE_pipeline.h"
-#include "RE_render_ext.h"
+#include "RE_texture.h"
-#include "../../../windowmanager/WM_api.h" /* XXX */
-#include "../../../windowmanager/wm_window.h" /* XXX */
+#include "SEQ_sequencer.h"
+
+#include "../../windowmanager/WM_api.h" /* XXX */
+#include "../../windowmanager/wm_window.h" /* XXX */
#include "GPU_context.h"
#ifdef WITH_FREESTYLE
@@ -101,9 +102,9 @@
/* internal */
#include "initrender.h"
+#include "pipeline.h"
#include "render_result.h"
#include "render_types.h"
-#include "renderpipeline.h"
/* render flow
*
@@ -188,6 +189,10 @@ static int default_break(void *UNUSED(arg))
static void stats_background(void *UNUSED(arg), RenderStats *rs)
{
+ if (rs->infostr == NULL) {
+ return;
+ }
+
uintptr_t mem_in_use, peak_memory;
float megs_used_memory, megs_peak_memory;
char info_time_str[32];
@@ -208,17 +213,7 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
info_time_str, sizeof(info_time_str), PIL_check_seconds_timer() - rs->starttime);
fprintf(stdout, TIP_("| Time:%s | "), info_time_str);
- if (rs->infostr) {
- fprintf(stdout, "%s", rs->infostr);
- }
- else {
- fprintf(stdout,
- TIP_("Sce: %s Ve:%d Fa:%d La:%d"),
- rs->scene_name,
- rs->totvert,
- rs->totface,
- rs->totlamp);
- }
+ fprintf(stdout, "%s", rs->infostr);
/* Flush stdout to be sure python callbacks are printing stuff after blender. */
fflush(stdout);
@@ -1503,27 +1498,27 @@ static void do_render_seq(Render *re)
tot_views = BKE_scene_multiview_num_views_get(&re->r);
ibuf_arr = MEM_mallocN(sizeof(ImBuf *) * tot_views, "Sequencer Views ImBufs");
- BKE_sequencer_new_render_data(re->main,
- re->pipeline_depsgraph,
- re->scene,
- re_x,
- re_y,
- SEQ_RENDER_SIZE_SCENE,
- true,
- &context);
+ SEQ_render_new_render_data(re->main,
+ re->pipeline_depsgraph,
+ re->scene,
+ re_x,
+ re_y,
+ SEQ_RENDER_SIZE_SCENE,
+ true,
+ &context);
/* the renderresult gets destroyed during the rendering, so we first collect all ibufs
* and then we populate the final renderesult */
for (view_id = 0; view_id < tot_views; view_id++) {
context.view_id = view_id;
- out = BKE_sequencer_give_ibuf(&context, cfra, 0);
+ out = SEQ_render_give_ibuf(&context, cfra, 0);
if (out) {
ibuf_arr[view_id] = IMB_dupImBuf(out);
IMB_metadata_copy(ibuf_arr[view_id], out);
IMB_freeImBuf(out);
- BKE_sequencer_imbuf_from_sequencer_space(re->pipeline_scene_eval, ibuf_arr[view_id]);
+ SEQ_render_imbuf_from_sequencer_space(re->pipeline_scene_eval, ibuf_arr[view_id]);
}
else {
ibuf_arr[view_id] = NULL;
diff --git a/source/blender/render/intern/include/renderpipeline.h b/source/blender/render/intern/pipeline.h
index 062df59bfd3..062df59bfd3 100644
--- a/source/blender/render/intern/include/renderpipeline.h
+++ b/source/blender/render/intern/pipeline.h
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/render_result.c
index db75cb5cfed..dfce51ec3ab 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/render_result.c
@@ -737,8 +737,10 @@ static int order_render_passes(const void *a, const void *b)
return (rpa->view_id < rpb->view_id);
}
-/* From imbuf, if a handle was returned and
- * it's not a singlelayer multiview we convert this to render result. */
+/**
+ * From imbuf, if a handle was returned and
+ * it's not a single-layer multi-view we convert this to render result.
+ */
RenderResult *render_result_new_from_exr(
void *exrhandle, const char *colorspace, bool predivide, int rectx, int recty)
{
@@ -992,9 +994,7 @@ bool RE_WriteRenderResult(ReportList *reports,
/* We only store RGBA passes as half float, for
* others precision loss can be problematic. */
bool pass_half_float = half_float &&
- (STREQ(rp->chan_id, "RGB") || STREQ(rp->chan_id, "RGBA") ||
- STREQ(rp->chan_id, "R") || STREQ(rp->chan_id, "G") ||
- STREQ(rp->chan_id, "B") || STREQ(rp->chan_id, "A"));
+ (STR_ELEM(rp->chan_id, "RGB", "RGBA", "R", "G", "B", "A"));
for (int a = 0; a < rp->channels; a++) {
/* Save Combined as RGBA if single layer save. */
diff --git a/source/blender/render/intern/include/render_result.h b/source/blender/render/intern/render_result.h
index 5c487223e94..5c487223e94 100644
--- a/source/blender/render/intern/include/render_result.h
+++ b/source/blender/render/intern/render_result.h
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/render_types.h
index 6be5fb4792c..6be5fb4792c 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/render_types.h
diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/texture_common.h
index 44ad508fe33..b3a976c3fe0 100644
--- a/source/blender/render/intern/include/texture.h
+++ b/source/blender/render/intern/texture_common.h
@@ -79,7 +79,7 @@ struct ImagePool;
struct Tex;
struct TexResult;
-/* imagetexture.h */
+/* texture_image.c */
int imagewraposa(struct Tex *tex,
struct Image *ima,
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/texture_image.c
index dd179f9461b..5614318afbb 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/texture_image.c
@@ -46,11 +46,10 @@
#include "BKE_image.h"
-#include "RE_render_ext.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
#include "render_types.h"
-#include "texture.h"
+#include "texture_common.h"
static void boxsample(ImBuf *ibuf,
float minx,
@@ -200,7 +199,7 @@ int imagewrap(Tex *tex,
return retval;
}
}
- else if (tex->extend == TEX_CLIP || tex->extend == TEX_CHECKER) {
+ else if (ELEM(tex->extend, TEX_CLIP, TEX_CHECKER)) {
if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y) {
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
@@ -282,9 +281,9 @@ int imagewrap(Tex *tex,
* the normal used in the renderer points inward. It is generated
* this way in calc_vertexnormals(). Should this ever change
* this negate must be removed. */
- texres->nor[0] = -2.f * (texres->tr - 0.5f);
- texres->nor[1] = 2.f * (texres->tg - 0.5f);
- texres->nor[2] = 2.f * (texres->tb - 0.5f);
+ texres->nor[0] = -2.0f * (texres->tr - 0.5f);
+ texres->nor[1] = 2.0f * (texres->tg - 0.5f);
+ texres->nor[2] = 2.0f * (texres->tb - 0.5f);
}
else {
/* bump: take three samples */
@@ -328,7 +327,7 @@ int imagewrap(Tex *tex,
texres->ta = 1.0f - texres->ta;
}
- /* de-premul, this is being premulled in shade_input_do_shade()
+ /* de-premul, this is being pre-multiplied in shade_input_do_shade()
* do not de-premul for generated alpha, it is already in straight */
if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
fx = 1.0f / texres->ta;
@@ -743,8 +742,10 @@ typedef struct afdata_t {
/* this only used here to make it easier to pass extend flags as single int */
enum { TXC_XMIR = 1, TXC_YMIR, TXC_REPT, TXC_EXTD };
-/* similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags
- * returns true if out of range in clipmode */
+/**
+ * Similar to `ibuf_get_color()` but clips/wraps coords according to repeat/extend flags
+ * returns true if out of range in clip-mode.
+ */
static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extflag)
{
int clip = 0;
@@ -798,7 +799,7 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf
col[0] = fp[0];
col[1] = fp[1];
col[2] = fp[2];
- col[3] = clip ? 0.f : (ibuf->channels == 4 ? fp[3] : 1.f);
+ col[3] = clip ? 0.0f : (ibuf->channels == 4 ? fp[3] : 1.0f);
}
}
else {
@@ -807,7 +808,7 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf
col[0] = rect[0] * inv_alpha_fac;
col[1] = rect[1] * inv_alpha_fac;
col[2] = rect[2] * inv_alpha_fac;
- col[3] = clip ? 0.f : rect[3] * (1.f / 255.f);
+ col[3] = clip ? 0.0f : rect[3] * (1.0f / 255.0f);
}
return clip;
}
@@ -820,7 +821,7 @@ static int ibuf_get_color_clip_bilerp(
float c00[4], c01[4], c10[4], c11[4];
const float ufl = floorf(u -= 0.5f), vfl = floorf(v -= 0.5f);
const float uf = u - ufl, vf = v - vfl;
- const float w00 = (1.f - uf) * (1.f - vf), w10 = uf * (1.f - vf), w01 = (1.f - uf) * vf,
+ const float w00 = (1.0f - uf) * (1.0f - vf), w10 = uf * (1.0f - vf), w01 = (1.0f - uf) * vf,
w11 = uf * vf;
const int x1 = (int)ufl, y1 = (int)vfl, x2 = x1 + 1, y2 = y1 + 1;
int clip = ibuf_get_color_clip(c00, ibuf, x1, y1, extflag);
@@ -830,7 +831,7 @@ static int ibuf_get_color_clip_bilerp(
col[0] = w00 * c00[0] + w10 * c10[0] + w01 * c01[0] + w11 * c11[0];
col[1] = w00 * c00[1] + w10 * c10[1] + w01 * c01[1] + w11 * c11[1];
col[2] = w00 * c00[2] + w10 * c10[2] + w01 * c01[2] + w11 * c11[2];
- col[3] = clip ? 0.f : w00 * c00[3] + w10 * c10[3] + w01 * c01[3] + w11 * c11[3];
+ col[3] = clip ? 0.0f : w00 * c00[3] + w10 * c10[3] + w01 * c01[3] + w11 * c11[3];
return clip;
}
return ibuf_get_color_clip(col, ibuf, (int)u, (int)v, extflag);
@@ -839,7 +840,7 @@ static int ibuf_get_color_clip_bilerp(
static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD)
{
int xs, ys, clip = 0;
- float tc[4], xsd, ysd, cw = 0.f;
+ float tc[4], xsd, ysd, cw = 0.0f;
const float ux = ibuf->x * AFD->dxt[0], uy = ibuf->y * AFD->dxt[1];
const float vx = ibuf->x * AFD->dyt[0], vy = ibuf->y * AFD->dyt[1];
int xsam = (int)(0.5f * sqrtf(ux * ux + uy * uy) + 0.5f);
@@ -847,9 +848,9 @@ static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata
const int minsam = AFD->intpol ? 2 : 4;
xsam = CLAMPIS(xsam, minsam, ibuf->x * 2);
ysam = CLAMPIS(ysam, minsam, ibuf->y * 2);
- xsd = 1.f / xsam;
- ysd = 1.f / ysam;
- texr->tr = texr->tg = texr->tb = texr->ta = 0.f;
+ xsd = 1.0f / xsam;
+ ysd = 1.0f / ysam;
+ texr->tr = texr->tg = texr->tb = texr->ta = 0.0f;
for (ys = 0; ys < ysam; ys++) {
for (xs = 0; xs < xsam; xs++) {
const float su = (xs + ((ys & 1) + 0.5f) * 0.5f) * xsd - 0.5f;
@@ -859,11 +860,11 @@ static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata
const int out = ibuf_get_color_clip_bilerp(
tc, ibuf, pu * ibuf->x, pv * ibuf->y, AFD->intpol, AFD->extflag);
clip |= out;
- cw += out ? 0.f : 1.f;
+ cw += out ? 0.0f : 1.0f;
texr->tr += tc[0];
texr->tg += tc[1];
texr->tb += tc[2];
- texr->ta += texr->talpha ? tc[3] : 0.f;
+ texr->ta += texr->talpha ? tc[3] : 0.0f;
}
}
xsd *= ysd;
@@ -871,7 +872,7 @@ static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata
texr->tg *= xsd;
texr->tb *= xsd;
/* clipping can be ignored if alpha used, texr->ta already includes filtered edge */
- texr->ta = texr->talpha ? texr->ta * xsd : (clip ? cw * xsd : 1.f);
+ texr->ta = texr->talpha ? texr->ta * xsd : (clip ? cw * xsd : 1.0f);
}
typedef struct ReadEWAData {
@@ -906,19 +907,19 @@ static void ewa_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t
static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD)
{
const int maxn = AFD->iProbes - 1;
- const float ll = ((AFD->majrad == AFD->minrad) ? 2.f * AFD->majrad :
- 2.f * (AFD->majrad - AFD->minrad)) /
- (maxn ? (float)maxn : 1.f);
- float du = maxn ? cosf(AFD->theta) * ll : 0.f;
- float dv = maxn ? sinf(AFD->theta) * ll : 0.f;
+ const float ll = ((AFD->majrad == AFD->minrad) ? 2.0f * AFD->majrad :
+ 2.0f * (AFD->majrad - AFD->minrad)) /
+ (maxn ? (float)maxn : 1.0f);
+ float du = maxn ? cosf(AFD->theta) * ll : 0.0f;
+ float dv = maxn ? sinf(AFD->theta) * ll : 0.0f;
/* const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); */
const float D = (EWA_MAXIDX + 1) * 0.25f * (du * du + dv * dv) / (AFD->majrad * AFD->majrad);
- float d; /* TXF alpha: cw = 0.f; */
+ float d; /* TXF alpha: cw = 0.0f; */
int n; /* TXF alpha: clip = 0; */
/* have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.) */
du *= AFD->dusc;
dv *= AFD->dvsc;
- d = texr->tr = texr->tb = texr->tg = texr->ta = 0.f;
+ d = texr->tr = texr->tb = texr->tg = texr->ta = 0.0f;
for (n = -maxn; n <= maxn; n += 2) {
float tc[4];
const float hn = n * 0.5f;
@@ -932,20 +933,20 @@ static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata
/*const int out =*/ibuf_get_color_clip_bilerp(
tc, ibuf, ibuf->x * u, ibuf->y * v, AFD->intpol, AFD->extflag);
/* TXF alpha: clip |= out;
- * TXF alpha: cw += out ? 0.f : wt; */
+ * TXF alpha: cw += out ? 0.0f : wt; */
texr->tr += tc[0] * wt;
texr->tg += tc[1] * wt;
texr->tb += tc[2] * wt;
- texr->ta += texr->talpha ? tc[3] * wt : 0.f;
+ texr->ta += texr->talpha ? tc[3] * wt : 0.0f;
d += wt;
}
- d = 1.f / d;
+ d = 1.0f / d;
texr->tr *= d;
texr->tg *= d;
texr->tb *= d;
/* clipping can be ignored if alpha used, texr->ta already includes filtered edge */
- texr->ta = texr->talpha ? texr->ta * d : 1.f; // TXF alpha: (clip ? cw*d : 1.f);
+ texr->ta = texr->talpha ? texr->ta * d : 1.0f; // TXF alpha: (clip ? cw*d : 1.0f);
}
#undef EWA_MAXIDX
@@ -1032,7 +1033,7 @@ static int imagewraposa_aniso(Tex *tex,
filterfunc = area_sample;
}
- texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.f;
+ texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.0f;
/* we need to set retval OK, otherwise texture code generates normals itself... */
retval = texres->nor ? (TEX_RGB | TEX_NOR) : TEX_RGB;
@@ -1102,7 +1103,7 @@ static int imagewraposa_aniso(Tex *tex,
miny = addval;
}
}
- else if (tex->filtersize != 1.f) {
+ else if (tex->filtersize != 1.0f) {
minx *= tex->filtersize;
miny *= tex->filtersize;
dxt[0] *= tex->filtersize;
@@ -1115,7 +1116,7 @@ static int imagewraposa_aniso(Tex *tex,
float t;
SWAP(float, minx, miny);
/* must rotate dxt/dyt 90 deg
- * yet another blender problem is that swapping X/Y axes (or any tex proj switches)
+ * yet another blender problem is that swapping X/Y axes (or any tex projection switches)
* should do something similar, but it doesn't, it only swaps coords,
* so filter area will be incorrect in those cases. */
t = dxt[0];
@@ -1196,8 +1197,8 @@ static int imagewraposa_aniso(Tex *tex,
}
}
/* scale around center, (0.5, 0.5) */
- if (tex->checkerdist < 1.f) {
- const float omcd = 1.f / (1.f - tex->checkerdist);
+ if (tex->checkerdist < 1.0f) {
+ const float omcd = 1.0f / (1.0f - tex->checkerdist);
fx = (fx - 0.5f) * omcd + 0.5f;
fy = (fy - 0.5f) * omcd + 0.5f;
minx *= omcd;
@@ -1206,16 +1207,16 @@ static int imagewraposa_aniso(Tex *tex,
}
if (tex->extend == TEX_CLIPCUBE) {
- if ((fx + minx) < 0.f || (fy + miny) < 0.f || (fx - minx) > 1.f || (fy - miny) > 1.f ||
- texvec[2] < -1.f || texvec[2] > 1.f) {
+ if ((fx + minx) < 0.0f || (fy + miny) < 0.0f || (fx - minx) > 1.0f || (fy - miny) > 1.0f ||
+ texvec[2] < -1.0f || texvec[2] > 1.0f) {
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
}
return retval;
}
}
- else if (tex->extend == TEX_CLIP || tex->extend == TEX_CHECKER) {
- if ((fx + minx) < 0.f || (fy + miny) < 0.f || (fx - minx) > 1.f || (fy - miny) > 1.f) {
+ else if (ELEM(tex->extend, TEX_CLIP, TEX_CHECKER)) {
+ if ((fx + minx) < 0.0f || (fy + miny) < 0.0f || (fx - minx) > 1.0f || (fy - miny) > 1.0f) {
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
}
@@ -1224,8 +1225,8 @@ static int imagewraposa_aniso(Tex *tex,
}
else {
if (tex->extend == TEX_EXTEND) {
- fx = (fx > 1.f) ? 1.f : ((fx < 0.f) ? 0.f : fx);
- fy = (fy > 1.f) ? 1.f : ((fy < 0.f) ? 0.f : fy);
+ fx = (fx > 1.0f) ? 1.0f : ((fx < 0.0f) ? 0.0f : fx);
+ fy = (fy > 1.0f) ? 1.0f : ((fy < 0.0f) ? 0.0f : fy);
}
else {
fx -= floorf(fx);
@@ -1258,13 +1259,13 @@ static int imagewraposa_aniso(Tex *tex,
int maxlev;
ImBuf *mipmaps[IMB_MIPMAP_LEVELS + 1];
- /* modify ellipse minor axis if too eccentric, use for area sampling as well
- * scaling dxt/dyt as done in pbrt is not the same
- * (as in ewa_eval(), scale by sqrt(ibuf->x) to maximize precision) */
+ /* Modify ellipse minor axis if too eccentric, use for area sampling as well
+ * scaling `dxt/dyt` as done in PBRT is not the same
+ * (as in `ewa_eval()`, scale by `sqrt(ibuf->x)` to maximize precision). */
const float ff = sqrtf(ibuf->x), q = ibuf->y / ff;
const float Ux = dxt[0] * ff, Vx = dxt[1] * q, Uy = dyt[0] * ff, Vy = dyt[1] * q;
const float A = Vx * Vx + Vy * Vy;
- const float B = -2.f * (Ux * Vx + Uy * Vy);
+ const float B = -2.0f * (Ux * Vx + Uy * Vy);
const float C = Ux * Ux + Uy * Uy;
const float F = A * C - B * B * 0.25f;
float a, b, th, ecc;
@@ -1275,16 +1276,16 @@ static int imagewraposa_aniso(Tex *tex,
b *= ff;
a = max_ff(a, 1.0f);
b = max_ff(b, 1.0f);
- fProbes = 2.f * (a / b) - 1.f;
+ fProbes = 2.0f * (a / b) - 1.0f;
AFD.iProbes = round_fl_to_int(fProbes);
AFD.iProbes = MIN2(AFD.iProbes, tex->afmax);
if (AFD.iProbes < fProbes) {
- b = 2.f * a / (float)(AFD.iProbes + 1);
+ b = 2.0f * a / (float)(AFD.iProbes + 1);
}
AFD.majrad = a / ff;
AFD.minrad = b / ff;
AFD.theta = th;
- AFD.dusc = 1.f / ff;
+ AFD.dusc = 1.0f / ff;
AFD.dvsc = ff / (float)ibuf->y;
}
else { /* EWA & area */
@@ -1308,13 +1309,13 @@ static int imagewraposa_aniso(Tex *tex,
}
/* mipmap level */
- if (levf < 0.f) { /* original image only */
+ if (levf < 0.0f) { /* original image only */
previbuf = curibuf = mipmaps[0];
- levf = 0.f;
+ levf = 0.0f;
}
else if (levf >= maxlev - 1) {
previbuf = curibuf = mipmaps[maxlev - 1];
- levf = 0.f;
+ levf = 0.0f;
if (tex->texfilter == TXF_FELINE) {
AFD.iProbes = 1;
}
@@ -1377,7 +1378,7 @@ static int imagewraposa_aniso(Tex *tex,
const float ff = sqrtf(ibuf->x), q = ibuf->y / ff;
const float Ux = dxt[0] * ff, Vx = dxt[1] * q, Uy = dyt[0] * ff, Vy = dyt[1] * q;
const float A = Vx * Vx + Vy * Vy;
- const float B = -2.f * (Ux * Vx + Uy * Vy);
+ const float B = -2.0f * (Ux * Vx + Uy * Vy);
const float C = Ux * Ux + Uy * Uy;
const float F = A * C - B * B * 0.25f;
float a, b, th, ecc, fProbes;
@@ -1386,16 +1387,16 @@ static int imagewraposa_aniso(Tex *tex,
b *= ff;
a = max_ff(a, 1.0f);
b = max_ff(b, 1.0f);
- fProbes = 2.f * (a / b) - 1.f;
+ fProbes = 2.0f * (a / b) - 1.0f;
/* no limit to number of Probes here */
AFD.iProbes = round_fl_to_int(fProbes);
if (AFD.iProbes < fProbes) {
- b = 2.f * a / (float)(AFD.iProbes + 1);
+ b = 2.0f * a / (float)(AFD.iProbes + 1);
}
AFD.majrad = a / ff;
AFD.minrad = b / ff;
AFD.theta = th;
- AFD.dusc = 1.f / ff;
+ AFD.dusc = 1.0f / ff;
AFD.dvsc = ff / (float)ibuf->y;
}
if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) {
@@ -1425,7 +1426,7 @@ static int imagewraposa_aniso(Tex *tex,
texres->tin = texres->ta;
}
if (tex->flag & TEX_NEGALPHA) {
- texres->ta = 1.f - texres->ta;
+ texres->ta = 1.0f - texres->ta;
}
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */
@@ -1435,12 +1436,12 @@ static int imagewraposa_aniso(Tex *tex,
* the normal used in the renderer points inward. It is generated
* this way in calc_vertexnormals(). Should this ever change
* this negate must be removed. */
- texres->nor[0] = -2.f * (texres->tr - 0.5f);
- texres->nor[1] = 2.f * (texres->tg - 0.5f);
- texres->nor[2] = 2.f * (texres->tb - 0.5f);
+ texres->nor[0] = -2.0f * (texres->tr - 0.5f);
+ texres->nor[1] = 2.0f * (texres->tg - 0.5f);
+ texres->nor[2] = 2.0f * (texres->tb - 0.5f);
}
- /* de-premul, this is being premulled in shade_input_do_shade()
+ /* de-premul, this is being pre-multiplied in shade_input_do_shade()
* TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode,
* so for now commented out also disabled in imagewraposa()
* to be able to compare results with blender's default texture filtering */
@@ -1449,7 +1450,7 @@ static int imagewraposa_aniso(Tex *tex,
/* do not de-premul for generated alpha, it is already in straight */
if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
- fx = 1.f / texres->ta;
+ fx = 1.0f / texres->ta;
texres->tr *= fx;
texres->tg *= fx;
texres->tb *= fx;
@@ -1699,7 +1700,7 @@ int imagewraposa(Tex *tex,
return retval;
}
}
- else if (tex->extend == TEX_CLIP || tex->extend == TEX_CHECKER) {
+ else if (ELEM(tex->extend, TEX_CLIP, TEX_CHECKER)) {
if (fx + minx < 0.0f || fy + miny < 0.0f || fx - minx > 1.0f || fy - miny > 1.0f) {
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
@@ -1964,12 +1965,12 @@ int imagewraposa(Tex *tex,
* the normal used in the renderer points inward. It is generated
* this way in calc_vertexnormals(). Should this ever change
* this negate must be removed. */
- texres->nor[0] = -2.f * (texres->tr - 0.5f);
- texres->nor[1] = 2.f * (texres->tg - 0.5f);
- texres->nor[2] = 2.f * (texres->tb - 0.5f);
+ texres->nor[0] = -2.0f * (texres->tr - 0.5f);
+ texres->nor[1] = 2.0f * (texres->tg - 0.5f);
+ texres->nor[2] = 2.0f * (texres->tb - 0.5f);
}
- /* de-premul, this is being premulled in shade_input_do_shade() */
+ /* de-premul, this is being pre-multiplied in shade_input_do_shade() */
/* do not de-premul for generated alpha, it is already in straight */
if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
mul_v3_fl(&texres->tr, 1.0f / texres->ta);
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/texture_pointdensity.c
index 12b80da9f59..e2568e0a013 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/texture_pointdensity.c
@@ -54,10 +54,9 @@
#include "DEG_depsgraph_query.h"
#include "render_types.h"
-#include "texture.h"
+#include "texture_common.h"
-#include "RE_render_ext.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
static ThreadMutex sample_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -656,13 +655,13 @@ static int pointdensity(PointDensity *pd,
}
if (pd->flag & TEX_PD_TURBULENCE) {
- turb = BLI_gTurbulence(pd->noise_size,
- texvec[0] + vec[0],
- texvec[1] + vec[1],
- texvec[2] + vec[2],
- pd->noise_depth,
- 0,
- pd->noise_basis);
+ turb = BLI_noise_generic_turbulence(pd->noise_size,
+ texvec[0] + vec[0],
+ texvec[1] + vec[1],
+ texvec[2] + vec[2],
+ pd->noise_depth,
+ 0,
+ pd->noise_basis);
turb -= 0.5f; /* re-center 0.0-1.0 range around 0 to prevent offsetting result */
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/texture_procedural.c
index 12abc0f9216..a98f29a705d 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/texture_procedural.c
@@ -55,10 +55,9 @@
#include "MEM_guardedalloc.h"
#include "render_types.h"
-#include "texture.h"
+#include "texture_common.h"
-#include "RE_render_ext.h"
-#include "RE_shader_ext.h"
+#include "RE_texture.h"
static RNG_THREAD_ARRAY *random_tex_array;
@@ -174,37 +173,37 @@ static int clouds(const Tex *tex, const float texvec[3], TexResult *texres)
{
int rv = TEX_INT;
- texres->tin = BLI_gTurbulence(tex->noisesize,
- texvec[0],
- texvec[1],
- texvec[2],
- tex->noisedepth,
- (tex->noisetype != TEX_NOISESOFT),
- tex->noisebasis);
+ texres->tin = BLI_noise_generic_turbulence(tex->noisesize,
+ texvec[0],
+ texvec[1],
+ texvec[2],
+ tex->noisedepth,
+ (tex->noisetype != TEX_NOISESOFT),
+ tex->noisebasis);
if (texres->nor != NULL) {
/* calculate bumpnormal */
- texres->nor[0] = BLI_gTurbulence(tex->noisesize,
- texvec[0] + tex->nabla,
- texvec[1],
- texvec[2],
- tex->noisedepth,
- (tex->noisetype != TEX_NOISESOFT),
- tex->noisebasis);
- texres->nor[1] = BLI_gTurbulence(tex->noisesize,
- texvec[0],
- texvec[1] + tex->nabla,
- texvec[2],
- tex->noisedepth,
- (tex->noisetype != TEX_NOISESOFT),
- tex->noisebasis);
- texres->nor[2] = BLI_gTurbulence(tex->noisesize,
- texvec[0],
- texvec[1],
- texvec[2] + tex->nabla,
- tex->noisedepth,
- (tex->noisetype != TEX_NOISESOFT),
- tex->noisebasis);
+ texres->nor[0] = BLI_noise_generic_turbulence(tex->noisesize,
+ texvec[0] + tex->nabla,
+ texvec[1],
+ texvec[2],
+ tex->noisedepth,
+ (tex->noisetype != TEX_NOISESOFT),
+ tex->noisebasis);
+ texres->nor[1] = BLI_noise_generic_turbulence(tex->noisesize,
+ texvec[0],
+ texvec[1] + tex->nabla,
+ texvec[2],
+ tex->noisedepth,
+ (tex->noisetype != TEX_NOISESOFT),
+ tex->noisebasis);
+ texres->nor[2] = BLI_noise_generic_turbulence(tex->noisesize,
+ texvec[0],
+ texvec[1],
+ texvec[2] + tex->nabla,
+ tex->noisedepth,
+ (tex->noisetype != TEX_NOISESOFT),
+ tex->noisebasis);
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
@@ -214,20 +213,20 @@ static int clouds(const Tex *tex, const float texvec[3], TexResult *texres)
/* in this case, int. value should really be computed from color,
* and bumpnormal from that, would be too slow, looks ok as is */
texres->tr = texres->tin;
- texres->tg = BLI_gTurbulence(tex->noisesize,
- texvec[1],
- texvec[0],
- texvec[2],
- tex->noisedepth,
- (tex->noisetype != TEX_NOISESOFT),
- tex->noisebasis);
- texres->tb = BLI_gTurbulence(tex->noisesize,
- texvec[1],
- texvec[2],
- texvec[0],
- tex->noisedepth,
- (tex->noisetype != TEX_NOISESOFT),
- tex->noisebasis);
+ texres->tg = BLI_noise_generic_turbulence(tex->noisesize,
+ texvec[1],
+ texvec[0],
+ texvec[2],
+ tex->noisedepth,
+ (tex->noisetype != TEX_NOISESOFT),
+ tex->noisebasis);
+ texres->tb = BLI_noise_generic_turbulence(tex->noisesize,
+ texvec[1],
+ texvec[2],
+ texvec[0],
+ tex->noisedepth,
+ (tex->noisetype != TEX_NOISESOFT),
+ tex->noisebasis);
BRICONTRGB;
texres->ta = 1.0;
return (rv | TEX_RGB);
@@ -296,12 +295,14 @@ static float wood_int(const Tex *tex, float x, float y, float z)
}
else if (wt == TEX_BANDNOISE) {
wi = tex->turbul *
- BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
+ BLI_noise_generic_noise(
+ tex->noisesize, x, y, z, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
wi = waveform[wf]((x + y + z) * 10.0f + wi);
}
else if (wt == TEX_RINGNOISE) {
wi = tex->turbul *
- BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
+ BLI_noise_generic_noise(
+ tex->noisesize, x, y, z, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
wi = waveform[wf](sqrtf(x * x + y * y + z * z) * 20.0f + wi);
}
@@ -346,13 +347,13 @@ static float marble_int(const Tex *tex, float x, float y, float z)
n = 5.0f * (x + y + z);
- mi = n + tex->turbul * BLI_gTurbulence(tex->noisesize,
- x,
- y,
- z,
- tex->noisedepth,
- (tex->noisetype != TEX_NOISESOFT),
- tex->noisebasis);
+ mi = n + tex->turbul * BLI_noise_generic_turbulence(tex->noisesize,
+ x,
+ y,
+ z,
+ tex->noisedepth,
+ (tex->noisetype != TEX_NOISESOFT),
+ tex->noisebasis);
if (mt >= TEX_SOFT) { /* TEX_SOFT always true */
mi = waveform[wf](mi);
@@ -472,36 +473,36 @@ static int stucci(const Tex *tex, const float texvec[3], TexResult *texres)
float nor[3], b2, ofs;
int retval = TEX_INT;
- b2 = BLI_gNoise(tex->noisesize,
- texvec[0],
- texvec[1],
- texvec[2],
- (tex->noisetype != TEX_NOISESOFT),
- tex->noisebasis);
+ b2 = BLI_noise_generic_noise(tex->noisesize,
+ texvec[0],
+ texvec[1],
+ texvec[2],
+ (tex->noisetype != TEX_NOISESOFT),
+ tex->noisebasis);
ofs = tex->turbul / 200.0f;
if (tex->stype) {
ofs *= (b2 * b2);
}
- nor[0] = BLI_gNoise(tex->noisesize,
- texvec[0] + ofs,
- texvec[1],
- texvec[2],
- (tex->noisetype != TEX_NOISESOFT),
- tex->noisebasis);
- nor[1] = BLI_gNoise(tex->noisesize,
- texvec[0],
- texvec[1] + ofs,
- texvec[2],
- (tex->noisetype != TEX_NOISESOFT),
- tex->noisebasis);
- nor[2] = BLI_gNoise(tex->noisesize,
- texvec[0],
- texvec[1],
- texvec[2] + ofs,
- (tex->noisetype != TEX_NOISESOFT),
- tex->noisebasis);
+ nor[0] = BLI_noise_generic_noise(tex->noisesize,
+ texvec[0] + ofs,
+ texvec[1],
+ texvec[2],
+ (tex->noisetype != TEX_NOISESOFT),
+ tex->noisebasis);
+ nor[1] = BLI_noise_generic_noise(tex->noisesize,
+ texvec[0],
+ texvec[1] + ofs,
+ texvec[2],
+ (tex->noisetype != TEX_NOISESOFT),
+ tex->noisebasis);
+ nor[2] = BLI_noise_generic_noise(tex->noisesize,
+ texvec[0],
+ texvec[1],
+ texvec[2] + ofs,
+ (tex->noisetype != TEX_NOISESOFT),
+ tex->noisebasis);
texres->tin = nor[2];
@@ -539,10 +540,10 @@ static int mg_mFractalOrfBmTex(const Tex *tex, const float texvec[3], TexResult
float (*mgravefunc)(float, float, float, float, float, float, int);
if (tex->stype == TEX_MFRACTAL) {
- mgravefunc = mg_MultiFractal;
+ mgravefunc = BLI_noise_mg_multi_fractal;
}
else {
- mgravefunc = mg_fBm;
+ mgravefunc = BLI_noise_mg_fbm;
}
texres->tin = tex->ns_outscale * mgravefunc(texvec[0],
@@ -594,10 +595,10 @@ static int mg_ridgedOrHybridMFTex(const Tex *tex, const float texvec[3], TexResu
float (*mgravefunc)(float, float, float, float, float, float, float, float, int);
if (tex->stype == TEX_RIDGEDMF) {
- mgravefunc = mg_RidgedMultiFractal;
+ mgravefunc = BLI_noise_mg_ridged_multi_fractal;
}
else {
- mgravefunc = mg_HybridMultiFractal;
+ mgravefunc = BLI_noise_mg_hybrid_multi_fractal;
}
texres->tin = tex->ns_outscale * mgravefunc(texvec[0],
@@ -655,43 +656,43 @@ static int mg_HTerrainTex(const Tex *tex, const float texvec[3], TexResult *texr
{
int rv = TEX_INT;
- texres->tin = tex->ns_outscale * mg_HeteroTerrain(texvec[0],
- texvec[1],
- texvec[2],
- tex->mg_H,
- tex->mg_lacunarity,
- tex->mg_octaves,
- tex->mg_offset,
- tex->noisebasis);
+ texres->tin = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0],
+ texvec[1],
+ texvec[2],
+ tex->mg_H,
+ tex->mg_lacunarity,
+ tex->mg_octaves,
+ tex->mg_offset,
+ tex->noisebasis);
if (texres->nor != NULL) {
float offs = tex->nabla / tex->noisesize; /* also scaling of texvec */
/* calculate bumpnormal */
- texres->nor[0] = tex->ns_outscale * mg_HeteroTerrain(texvec[0] + offs,
- texvec[1],
- texvec[2],
- tex->mg_H,
- tex->mg_lacunarity,
- tex->mg_octaves,
- tex->mg_offset,
- tex->noisebasis);
- texres->nor[1] = tex->ns_outscale * mg_HeteroTerrain(texvec[0],
- texvec[1] + offs,
- texvec[2],
- tex->mg_H,
- tex->mg_lacunarity,
- tex->mg_octaves,
- tex->mg_offset,
- tex->noisebasis);
- texres->nor[2] = tex->ns_outscale * mg_HeteroTerrain(texvec[0],
- texvec[1],
- texvec[2] + offs,
- tex->mg_H,
- tex->mg_lacunarity,
- tex->mg_octaves,
- tex->mg_offset,
- tex->noisebasis);
+ texres->nor[0] = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0] + offs,
+ texvec[1],
+ texvec[2],
+ tex->mg_H,
+ tex->mg_lacunarity,
+ tex->mg_octaves,
+ tex->mg_offset,
+ tex->noisebasis);
+ texres->nor[1] = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0],
+ texvec[1] + offs,
+ texvec[2],
+ tex->mg_H,
+ tex->mg_lacunarity,
+ tex->mg_octaves,
+ tex->mg_offset,
+ tex->noisebasis);
+ texres->nor[2] = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0],
+ texvec[1],
+ texvec[2] + offs,
+ tex->mg_H,
+ tex->mg_lacunarity,
+ tex->mg_octaves,
+ tex->mg_offset,
+ tex->noisebasis);
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
@@ -706,31 +707,31 @@ static int mg_distNoiseTex(const Tex *tex, const float texvec[3], TexResult *tex
{
int rv = TEX_INT;
- texres->tin = mg_VLNoise(
+ texres->tin = BLI_noise_mg_variable_lacunarity(
texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
if (texres->nor != NULL) {
float offs = tex->nabla / tex->noisesize; /* also scaling of texvec */
/* calculate bumpnormal */
- texres->nor[0] = mg_VLNoise(texvec[0] + offs,
- texvec[1],
- texvec[2],
- tex->dist_amount,
- tex->noisebasis,
- tex->noisebasis2);
- texres->nor[1] = mg_VLNoise(texvec[0],
- texvec[1] + offs,
- texvec[2],
- tex->dist_amount,
- tex->noisebasis,
- tex->noisebasis2);
- texres->nor[2] = mg_VLNoise(texvec[0],
- texvec[1],
- texvec[2] + offs,
- tex->dist_amount,
- tex->noisebasis,
- tex->noisebasis2);
+ texres->nor[0] = BLI_noise_mg_variable_lacunarity(texvec[0] + offs,
+ texvec[1],
+ texvec[2],
+ tex->dist_amount,
+ tex->noisebasis,
+ tex->noisebasis2);
+ texres->nor[1] = BLI_noise_mg_variable_lacunarity(texvec[0],
+ texvec[1] + offs,
+ texvec[2],
+ tex->dist_amount,
+ tex->noisebasis,
+ tex->noisebasis2);
+ texres->nor[2] = BLI_noise_mg_variable_lacunarity(texvec[0],
+ texvec[1],
+ texvec[2] + offs,
+ tex->dist_amount,
+ tex->noisebasis,
+ tex->noisebasis2);
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
@@ -756,28 +757,28 @@ static int voronoiTex(const Tex *tex, const float texvec[3], TexResult *texres)
float aw3 = fabsf(tex->vn_w3);
float aw4 = fabsf(tex->vn_w4);
float sc = (aw1 + aw2 + aw3 + aw4);
- if (sc != 0.f) {
+ if (sc != 0.0f) {
sc = tex->ns_outscale / sc;
}
- voronoi(texvec[0], texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
+ BLI_noise_voronoi(texvec[0], texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
texres->tin = sc * fabsf(dot_v4v4(&tex->vn_w1, da));
if (tex->vn_coltype) {
float ca[3]; /* cell color */
- cellNoiseV(pa[0], pa[1], pa[2], ca);
+ BLI_noise_cell_v3(pa[0], pa[1], pa[2], ca);
texres->tr = aw1 * ca[0];
texres->tg = aw1 * ca[1];
texres->tb = aw1 * ca[2];
- cellNoiseV(pa[3], pa[4], pa[5], ca);
+ BLI_noise_cell_v3(pa[3], pa[4], pa[5], ca);
texres->tr += aw2 * ca[0];
texres->tg += aw2 * ca[1];
texres->tb += aw2 * ca[2];
- cellNoiseV(pa[6], pa[7], pa[8], ca);
+ BLI_noise_cell_v3(pa[6], pa[7], pa[8], ca);
texres->tr += aw3 * ca[0];
texres->tg += aw3 * ca[1];
texres->tb += aw3 * ca[2];
- cellNoiseV(pa[9], pa[10], pa[11], ca);
+ BLI_noise_cell_v3(pa[9], pa[10], pa[11], ca);
texres->tr += aw4 * ca[0];
texres->tg += aw4 * ca[1];
texres->tb += aw4 * ca[2];
@@ -807,11 +808,11 @@ static int voronoiTex(const Tex *tex, const float texvec[3], TexResult *texres)
float offs = tex->nabla / tex->noisesize; /* also scaling of texvec */
/* calculate bumpnormal */
- voronoi(texvec[0] + offs, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
+ BLI_noise_voronoi(texvec[0] + offs, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
texres->nor[0] = sc * fabsf(dot_v4v4(&tex->vn_w1, da));
- voronoi(texvec[0], texvec[1] + offs, texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
+ BLI_noise_voronoi(texvec[0], texvec[1] + offs, texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
texres->nor[1] = sc * fabsf(dot_v4v4(&tex->vn_w1, da));
- voronoi(texvec[0], texvec[1], texvec[2] + offs, da, pa, tex->vn_mexp, tex->vn_distm);
+ BLI_noise_voronoi(texvec[0], texvec[1], texvec[2] + offs, da, pa, tex->vn_mexp, tex->vn_distm);
texres->nor[2] = sc * fabsf(dot_v4v4(&tex->vn_w1, da));
tex_normal_derivate(tex, texres);
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/zbuf.c
index d74ab330dc2..d74ab330dc2 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/zbuf.c
diff --git a/source/blender/render/intern/include/zbuf.h b/source/blender/render/intern/zbuf.h
index 41fa15c594f..41fa15c594f 100644
--- a/source/blender/render/intern/include/zbuf.h
+++ b/source/blender/render/intern/zbuf.h
diff --git a/source/blender/sequencer/CMakeLists.txt b/source/blender/sequencer/CMakeLists.txt
index 866eba9ca41..18755e7e6bc 100644
--- a/source/blender/sequencer/CMakeLists.txt
+++ b/source/blender/sequencer/CMakeLists.txt
@@ -20,18 +20,23 @@
set(INC
.
+ intern
../blenkernel
../blenlib
+ ../blenloader
../blentranslation
../depsgraph
../imbuf
../makesdna
../makesrna
- ../render/extern/include
+ ../render
../blenfont
../windowmanager
../../../intern/atomic
../../../intern/guardedalloc
+
+ # dna_type_offsets.h
+ ${CMAKE_CURRENT_BINARY_DIR}/../makesdna/intern
)
set(INC_SYS
@@ -39,13 +44,35 @@ set(INC_SYS
)
set(SRC
- BKE_sequencer.h
+ SEQ_sequencer.h
- intern/sequencer.c
- intern/image_cache.c
+ intern/clipboard.c
intern/effects.c
+ intern/effects.h
+ intern/image_cache.c
+ intern/image_cache.h
+ intern/iterator.c
intern/modifier.c
+ intern/multiview.c
+ intern/multiview.h
intern/prefetch.c
+ intern/prefetch.h
+ intern/proxy.c
+ intern/proxy.h
+ intern/render.c
+ intern/render.h
+ intern/sequencer.c
+ intern/sequencer.h
+ intern/sound.c
+ intern/strip_add.c
+ intern/strip_edit.c
+ intern/strip_relations.c
+ intern/strip_select.c
+ intern/strip_time.c
+ intern/strip_time.h
+ intern/strip_transform.c
+ intern/utils.c
+ intern/utils.h
)
set(LIB
@@ -66,3 +93,6 @@ if(WITH_AUDASPACE)
endif()
blender_add_lib(bf_sequencer "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+
+# Needed so we can use dna_type_offsets.h.
+add_dependencies(bf_sequencer bf_dna)
diff --git a/source/blender/sequencer/BKE_sequencer.h b/source/blender/sequencer/SEQ_sequencer.h
index 04be46f0ccf..d9e2d32db0b 100644
--- a/source/blender/sequencer/BKE_sequencer.h
+++ b/source/blender/sequencer/SEQ_sequencer.h
@@ -20,7 +20,7 @@
#pragma once
/** \file
- * \ingroup bke
+ * \ingroup sequencer
*/
#ifdef __cplusplus
@@ -36,23 +36,43 @@ struct Main;
struct Mask;
struct ReportList;
struct Scene;
+struct SeqIndexBuildContext;
struct Sequence;
struct SequenceModifierData;
struct Stereo3dFormat;
-struct StripColorBalance;
struct StripElem;
struct TextVars;
struct bContext;
struct bSound;
+struct BlendWriter;
+struct BlendDataReader;
+struct BlendLibReader;
-struct SeqIndexBuildContext;
+/* Wipe effect */
+enum {
+ DO_SINGLE_WIPE,
+ DO_DOUBLE_WIPE,
+ /* DO_BOX_WIPE, */ /* UNUSED */
+ /* DO_CROSS_WIPE, */ /* UNUSED */
+ DO_IRIS_WIPE,
+ DO_CLOCK_WIPE,
+};
-#define EARLY_NO_INPUT -1
-#define EARLY_DO_EFFECT 0
-#define EARLY_USE_INPUT_1 1
-#define EARLY_USE_INPUT_2 2
+/* RNA enums, just to be more readable */
+enum {
+ SEQ_SIDE_NONE = 0,
+ SEQ_SIDE_LEFT,
+ SEQ_SIDE_RIGHT,
+ SEQ_SIDE_BOTH,
+ SEQ_SIDE_NO_CHANGE,
+};
-/* sequence iterator */
+/* **********************************************************************
+ * sequencer.c
+ *
+ * Sequencer iterators
+ * **********************************************************************
+ */
typedef struct SeqIterator {
struct Sequence **array;
@@ -62,12 +82,6 @@ typedef struct SeqIterator {
int valid;
} SeqIterator;
-void BKE_sequence_iterator_begin(struct Editing *ed,
- SeqIterator *iter,
- const bool use_current_sequences);
-void BKE_sequence_iterator_next(SeqIterator *iter);
-void BKE_sequence_iterator_end(SeqIterator *iter);
-
#define SEQ_ALL_BEGIN(ed, _seq) \
{ \
SeqIterator iter_macro; \
@@ -90,6 +104,19 @@ void BKE_sequence_iterator_end(SeqIterator *iter);
#define SEQ_CURRENT_END SEQ_ALL_END
+void BKE_sequence_iterator_begin(struct Editing *ed,
+ SeqIterator *iter,
+ const bool use_current_sequences);
+void BKE_sequence_iterator_next(SeqIterator *iter);
+void BKE_sequence_iterator_end(SeqIterator *iter);
+
+/* **********************************************************************
+ * render.c
+ *
+ * Sequencer render functions
+ * **********************************************************************
+ */
+
typedef enum eSeqTaskId {
SEQ_TASK_MAIN_RENDER,
SEQ_TASK_PREFETCH_RENDER,
@@ -118,141 +145,43 @@ typedef struct SeqRenderData {
// bool gpu_full_samples;
} SeqRenderData;
-void BKE_sequencer_new_render_data(struct Main *bmain,
- struct Depsgraph *depsgraph,
- struct Scene *scene,
- int rectx,
- int recty,
- int preview_render_size,
- int for_render,
- SeqRenderData *r_context);
-
-int BKE_sequencer_cmp_time_startdisp(const void *a, const void *b);
-
-/* Wipe effect */
-enum {
- DO_SINGLE_WIPE,
- DO_DOUBLE_WIPE,
- /* DO_BOX_WIPE, */ /* UNUSED */
- /* DO_CROSS_WIPE, */ /* UNUSED */
- DO_IRIS_WIPE,
- DO_CLOCK_WIPE,
-};
-
-struct SeqEffectHandle {
- bool multithreaded;
- bool supports_mask;
-
- /* constructors & destructor */
- /* init is _only_ called on first creation */
- void (*init)(struct Sequence *seq);
-
- /* number of input strips needed
- * (called directly after construction) */
- int (*num_inputs)(void);
-
- /* load is called first time after readblenfile in
- * get_sequence_effect automatically */
- void (*load)(struct Sequence *seqconst);
-
- /* duplicate */
- void (*copy)(struct Sequence *dst, struct Sequence *src, const int flag);
-
- /* destruct */
- void (*free)(struct Sequence *seq, const bool do_id_user);
-
- /* returns: -1: no input needed,
- * 0: no early out,
- * 1: out = ibuf1,
- * 2: out = ibuf2 */
- int (*early_out)(struct Sequence *seq, float facf0, float facf1);
-
- /* stores the y-range of the effect IPO */
- void (*store_icu_yrange)(struct Sequence *seq, short adrcode, float *ymin, float *ymax);
-
- /* stores the default facf0 and facf1 if no IPO is present */
- void (*get_default_fac)(struct Sequence *seq, float cfra, float *facf0, float *facf1);
-
- /* execute the effect
- * sequence effects are only required to either support
- * float-rects or byte-rects
- * (mixed cases are handled one layer up...) */
-
- struct ImBuf *(*execute)(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra,
- float facf0,
- float facf1,
- struct ImBuf *ibuf1,
- struct ImBuf *ibuf2,
- struct ImBuf *ibuf3);
-
- struct ImBuf *(*init_execution)(const SeqRenderData *context,
- struct ImBuf *ibuf1,
- struct ImBuf *ibuf2,
- struct ImBuf *ibuf3);
-
- void (*execute_slice)(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra,
- float facf0,
- float facf1,
- struct ImBuf *ibuf1,
- struct ImBuf *ibuf2,
- struct ImBuf *ibuf3,
- int start_line,
- int total_lines,
- struct ImBuf *out);
-};
-
-/* ********************* prototypes *************** */
+struct ImBuf *SEQ_render_give_ibuf(const SeqRenderData *context,
+ float timeline_frame,
+ int chanshown);
+struct ImBuf *SEQ_render_give_ibuf_direct(const SeqRenderData *context,
+ float timeline_frame,
+ struct Sequence *seq);
+void SEQ_render_init_colorspace(struct Sequence *seq);
+void SEQ_render_new_render_data(struct Main *bmain,
+ struct Depsgraph *depsgraph,
+ struct Scene *scene,
+ int rectx,
+ int recty,
+ int preview_render_size,
+ int for_render,
+ SeqRenderData *r_context);
+int SEQ_render_evaluate_frame(struct Scene *scene, int timeline_frame);
+struct StripElem *SEQ_render_give_stripelem(struct Sequence *seq, int timeline_frame);
/* **********************************************************************
- * sequencer.c
+ * render.c
*
- * sequencer render functions
+ * Sequencer color space functions
* ********************************************************************** */
-double BKE_sequencer_rendersize_to_scale_factor(int size);
-
-struct ImBuf *BKE_sequencer_give_ibuf(const SeqRenderData *context, float cfra, int chanshown);
-struct ImBuf *BKE_sequencer_give_ibuf_direct(const SeqRenderData *context,
- float cfra,
- struct Sequence *seq);
-struct ImBuf *BKE_sequencer_give_ibuf_seqbase(const SeqRenderData *context,
- float cfra,
- int chan_shown,
- struct ListBase *seqbasep);
-struct ImBuf *BKE_sequencer_effect_execute_threaded(struct SeqEffectHandle *sh,
- const SeqRenderData *context,
- struct Sequence *seq,
- float cfra,
- float facf0,
- float facf1,
- struct ImBuf *ibuf1,
- struct ImBuf *ibuf2,
- struct ImBuf *ibuf3);
+
+void SEQ_render_imbuf_from_sequencer_space(struct Scene *scene, struct ImBuf *ibuf);
+void SEQ_render_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4]);
/* **********************************************************************
* sequencer.c
*
- * sequencer color space functions
+ * Sequencer scene functions
* ********************************************************************** */
-void BKE_sequencer_imbuf_to_sequencer_space(struct Scene *scene,
- struct ImBuf *ibuf,
- bool make_float);
-void BKE_sequencer_imbuf_from_sequencer_space(struct Scene *scene, struct ImBuf *ibuf);
-void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4]);
-
-/* **********************************************************************
- * sequencer scene functions
- * ********************************************************************** */
struct Editing *BKE_sequencer_editing_get(struct Scene *scene, bool alloc);
struct Editing *BKE_sequencer_editing_ensure(struct Scene *scene);
void BKE_sequencer_editing_free(struct Scene *scene, const bool do_id_user);
-
void BKE_sequencer_sort(struct Scene *scene);
-
struct Sequence *BKE_sequencer_from_elem(ListBase *seqbase, struct StripElem *se);
struct Sequence *BKE_sequencer_active_get(struct Scene *scene);
int BKE_sequencer_active_get_pair(struct Scene *scene,
@@ -260,7 +189,6 @@ int BKE_sequencer_active_get_pair(struct Scene *scene,
struct Sequence **seq_other);
void BKE_sequencer_active_set(struct Scene *scene, struct Sequence *seq);
struct Mask *BKE_sequencer_mask_get(struct Scene *scene);
-
/* apply functions recursively */
int BKE_sequencer_base_recursive_apply(struct ListBase *seqbase,
int (*apply_fn)(struct Sequence *seq, void *),
@@ -268,16 +196,14 @@ int BKE_sequencer_base_recursive_apply(struct ListBase *seqbase,
int BKE_sequencer_recursive_apply(struct Sequence *seq,
int (*apply_fn)(struct Sequence *, void *),
void *arg);
-
+float BKE_sequence_get_fps(struct Scene *scene, struct Sequence *seq);
+int BKE_sequencer_find_next_prev_edit(struct Scene *scene,
+ int timeline_frame,
+ const short side,
+ const bool do_skip_mute,
+ const bool do_center,
+ const bool do_unselected);
/* maintenance functions, mostly for RNA */
-/* extern */
-
-void BKE_sequencer_free_clipboard(void);
-
-void BKE_sequencer_base_clipboard_pointers_free(struct ListBase *seqbase);
-void BKE_sequencer_base_clipboard_pointers_store(struct Main *bmain, struct ListBase *seqbase);
-void BKE_sequencer_base_clipboard_pointers_restore(struct ListBase *seqbase, struct Main *bmain);
-
void BKE_sequence_free(struct Scene *scene, struct Sequence *seq, const bool do_clean_animdata);
void BKE_sequence_free_anim(struct Sequence *seq);
const char *BKE_sequence_give_name(struct Sequence *seq);
@@ -293,123 +219,67 @@ void BKE_sequence_movie_reload_if_needed(struct Main *bmain,
struct Sequence *seq,
bool *r_was_reloaded,
bool *r_can_produce_frames);
-int BKE_sequencer_evaluate_frame(struct Scene *scene, int cfra);
-int BKE_sequencer_get_shown_sequences(struct ListBase *seqbasep,
- int cfra,
- int chanshown,
- struct Sequence **seq_arr_out);
-
-struct StripElem *BKE_sequencer_give_stripelem(struct Sequence *seq, int cfra);
-
-/* intern */
+void BKE_sequence_alpha_mode_from_extension(struct Sequence *seq);
void BKE_sequencer_update_changed_seq_and_deps(struct Scene *scene,
struct Sequence *changed_seq,
int len_change,
int ibuf_change);
-bool BKE_sequencer_input_have_to_preprocess(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra);
+bool BKE_sequencer_check_scene_recursion(struct Scene *scene, struct ReportList *reports);
+bool BKE_sequencer_render_loop_check(struct Sequence *seq_main, struct Sequence *seq);
+int BKE_sequencer_cmp_time_startdisp(const void *a, const void *b);
-bool BKE_sequencer_proxy_rebuild_context(struct Main *bmain,
- struct Depsgraph *depsgraph,
- struct Scene *scene,
- struct Sequence *seq,
- struct GSet *file_list,
- ListBase *queue);
-void BKE_sequencer_proxy_rebuild(struct SeqIndexBuildContext *context,
- short *stop,
- short *do_update,
- float *progress);
-void BKE_sequencer_proxy_rebuild_finish(struct SeqIndexBuildContext *context, bool stop);
-
-void BKE_sequencer_proxy_set(struct Sequence *seq, bool value);
/* **********************************************************************
- * seqcache.c
+ * proxy.c
*
- * Sequencer memory cache management functions
+ * Proxy functions
* ********************************************************************** */
-#define SEQ_CACHE_COST_MAX 10.0f
+bool SEQ_proxy_rebuild_context(struct Main *bmain,
+ struct Depsgraph *depsgraph,
+ struct Scene *scene,
+ struct Sequence *seq,
+ struct GSet *file_list,
+ ListBase *queue);
+void SEQ_proxy_rebuild(struct SeqIndexBuildContext *context,
+ short *stop,
+ short *do_update,
+ float *progress);
+void SEQ_proxy_rebuild_finish(struct SeqIndexBuildContext *context, bool stop);
+void SEQ_proxy_set(struct Sequence *seq, bool value);
+bool SEQ_can_use_proxy(struct Sequence *seq, int psize);
+int SEQ_rendersize_to_proxysize(int render_size);
+double SEQ_rendersize_to_scale_factor(int size);
+
+/* **********************************************************************
+ * image_cache.c
+ *
+ * Sequencer memory cache management functions
+ * ********************************************************************** */
-struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra,
- int type,
- bool skip_disk_cache);
-void BKE_sequencer_cache_put(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra,
- int type,
- struct ImBuf *i,
- float cost,
- bool skip_disk_cache);
-bool BKE_sequencer_cache_put_if_possible(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra,
- int type,
- struct ImBuf *nval,
- float cost,
- bool skip_disk_cache);
-bool BKE_sequencer_cache_recycle_item(struct Scene *scene);
-void BKE_sequencer_cache_free_temp_cache(struct Scene *scene, short id, int cfra);
-void BKE_sequencer_cache_destruct(struct Scene *scene);
-void BKE_sequencer_cache_cleanup_all(struct Main *bmain);
void BKE_sequencer_cache_cleanup(struct Scene *scene);
-void BKE_sequencer_cache_cleanup_sequence(struct Scene *scene,
- struct Sequence *seq,
- struct Sequence *seq_changed,
- int invalidate_types,
- bool force_seq_changed_range);
void BKE_sequencer_cache_iterate(struct Scene *scene,
void *userdata,
bool callback_init(void *userdata, size_t item_count),
bool callback_iter(void *userdata,
struct Sequence *seq,
- int cfra,
+ int timeline_frame,
int cache_type,
float cost));
-bool BKE_sequencer_cache_is_full(struct Scene *scene);
/* **********************************************************************
- * seqprefetch.c
+ * prefetch.c
*
* Sequencer frame prefetching
* ********************************************************************** */
-void BKE_sequencer_prefetch_start(const SeqRenderData *context, float cfra, float cost);
+#define SEQ_CACHE_COST_MAX 10.0f
void BKE_sequencer_prefetch_stop_all(void);
void BKE_sequencer_prefetch_stop(struct Scene *scene);
-void BKE_sequencer_prefetch_free(struct Scene *scene);
bool BKE_sequencer_prefetch_need_redraw(struct Main *bmain, struct Scene *scene);
-bool BKE_sequencer_prefetch_job_is_running(struct Scene *scene);
-void BKE_sequencer_prefetch_get_time_range(struct Scene *scene, int *start, int *end);
-SeqRenderData *BKE_sequencer_prefetch_get_original_context(const SeqRenderData *context);
-struct Sequence *BKE_sequencer_prefetch_get_original_sequence(struct Sequence *seq,
- struct Scene *scene);
/* **********************************************************************
- * seqeffects.c
+ * sequencer.c
*
- * Sequencer effect strip management functions
- * **********************************************************************
- */
-
-/* intern */
-struct SeqEffectHandle BKE_sequence_get_blend(struct Sequence *seq);
-void BKE_sequence_effect_speed_rebuild_map(struct Scene *scene, struct Sequence *seq, bool force);
-float BKE_sequencer_speed_effect_target_frame_get(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra,
- int input);
-
-/* extern */
-struct SeqEffectHandle BKE_sequence_get_effect(struct Sequence *seq);
-int BKE_sequence_effect_get_num_inputs(int seq_type);
-int BKE_sequence_effect_get_supports_mask(int seq_type);
-void BKE_sequencer_text_font_unload(struct TextVars *data, const bool do_id_user);
-void BKE_sequencer_text_font_load(struct TextVars *data, const bool do_id_user);
-
-/* **********************************************************************
* Sequencer editing functions
* **********************************************************************
*/
@@ -426,13 +296,8 @@ bool BKE_sequence_single_check(struct Sequence *seq);
void BKE_sequence_single_fix(struct Sequence *seq);
bool BKE_sequence_test_overlap(struct ListBase *seqbasep, struct Sequence *test);
void BKE_sequence_translate(struct Scene *scene, struct Sequence *seq, int delta);
-void BKE_sequence_sound_init(struct Scene *scene, struct Sequence *seq);
const struct Sequence *BKE_sequencer_foreground_frame_get(const struct Scene *scene, int frame);
struct ListBase *BKE_sequence_seqbase(struct ListBase *seqbase, struct Sequence *seq);
-struct Sequence *BKE_sequence_metastrip(ListBase *seqbase /* = ed->seqbase */,
- struct Sequence *meta /* = NULL */,
- struct Sequence *seq);
-
void BKE_sequencer_offset_animdata(struct Scene *scene, struct Sequence *seq, int ofs);
void BKE_sequencer_dupe_animdata(struct Scene *scene, const char *name_src, const char *name_dst);
bool BKE_sequence_base_shuffle_ex(struct ListBase *seqbasep,
@@ -454,26 +319,11 @@ struct Sequence *BKE_sequence_dupli_recursive(const struct Scene *scene_src,
struct Sequence *seq,
int dupe_flag);
int BKE_sequence_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char **error_str);
-
-bool BKE_sequence_check_depend(struct Sequence *seq, struct Sequence *cur);
-void BKE_sequence_invalidate_cache_raw(struct Scene *scene, struct Sequence *seq);
-void BKE_sequence_invalidate_cache_preprocessed(struct Scene *scene, struct Sequence *seq);
-void BKE_sequence_invalidate_cache_composite(struct Scene *scene, struct Sequence *seq);
-void BKE_sequence_invalidate_dependent(struct Scene *scene, struct Sequence *seq);
-void BKE_sequence_invalidate_scene_strips(struct Main *bmain, struct Scene *scene_target);
-void BKE_sequence_invalidate_movieclip_strips(struct Main *bmain, struct MovieClip *clip_target);
-void BKE_sequence_invalidate_cache_in_range(struct Scene *scene,
- struct Sequence *seq,
- struct Sequence *range_mask,
- int invalidate_types);
-
void BKE_sequencer_update_sound_bounds_all(struct Scene *scene);
void BKE_sequencer_update_sound_bounds(struct Scene *scene, struct Sequence *seq);
void BKE_sequencer_update_muting(struct Editing *ed);
void BKE_sequencer_update_sound(struct Scene *scene, struct bSound *sound);
-
void BKE_sequencer_refresh_sound_length(struct Main *bmain, struct Scene *scene);
-
void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq);
void BKE_sequence_base_dupli_recursive(const struct Scene *scene_src,
struct Scene *scene_dst,
@@ -482,12 +332,39 @@ void BKE_sequence_base_dupli_recursive(const struct Scene *scene_src,
int dupe_flag,
const int flag);
bool BKE_sequence_is_valid_check(struct Sequence *seq);
-
-void BKE_sequencer_clear_scene_in_allseqs(struct Main *bmain, struct Scene *sce);
-
struct Sequence *BKE_sequence_get_by_name(struct ListBase *seqbase,
const char *name,
bool recursive);
+void BKE_sequencer_flag_for_removal(struct Scene *scene,
+ struct ListBase *seqbase,
+ struct Sequence *seq);
+void BKE_sequencer_remove_flagged_sequences(struct Scene *scene, struct ListBase *seqbase);
+
+/* **********************************************************************
+ * sequencer.c
+ *
+ * Cache invalidation
+ * **********************************************************************
+ */
+
+void BKE_sequence_invalidate_cache_raw(struct Scene *scene, struct Sequence *seq);
+void BKE_sequence_invalidate_cache_preprocessed(struct Scene *scene, struct Sequence *seq);
+void BKE_sequence_invalidate_cache_composite(struct Scene *scene, struct Sequence *seq);
+void BKE_sequence_invalidate_dependent(struct Scene *scene, struct Sequence *seq);
+void BKE_sequence_invalidate_scene_strips(struct Main *bmain, struct Scene *scene_target);
+void BKE_sequence_invalidate_movieclip_strips(struct Main *bmain, struct MovieClip *clip_target);
+void BKE_sequence_invalidate_cache_in_range(struct Scene *scene,
+ struct Sequence *seq,
+ struct Sequence *range_mask,
+ int invalidate_types);
+void BKE_sequencer_all_free_anim_ibufs(struct Scene *scene, int timeline_frame);
+
+/* **********************************************************************
+ * sequencer.c
+ *
+ * Add strips
+ * **********************************************************************
+ */
/* api for adding new sequence strips */
typedef struct SeqLoadInfo {
@@ -528,32 +405,7 @@ typedef struct SeqLoadInfo {
/* use as an api function */
typedef struct Sequence *(*SeqLoadFn)(struct bContext *, ListBase *, struct SeqLoadInfo *);
-struct Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine, int type);
-
-/* Generate new UUID for the given sequence. */
-void BKE_sequence_session_uuid_generate(struct Sequence *sequence);
-
-void BKE_sequence_alpha_mode_from_extension(struct Sequence *seq);
-void BKE_sequence_init_colorspace(struct Sequence *seq);
-
-float BKE_sequence_get_fps(struct Scene *scene, struct Sequence *seq);
-float BKE_sequencer_give_stripelem_index(struct Sequence *seq, float cfra);
-
-/* RNA enums, just to be more readable */
-enum {
- SEQ_SIDE_NONE = 0,
- SEQ_SIDE_LEFT,
- SEQ_SIDE_RIGHT,
- SEQ_SIDE_BOTH,
- SEQ_SIDE_NO_CHANGE,
-};
-int BKE_sequencer_find_next_prev_edit(struct Scene *scene,
- int cfra,
- const short side,
- const bool do_skip_mute,
- const bool do_center,
- const bool do_unselected);
-
+struct Sequence *BKE_sequence_alloc(ListBase *lb, int timeline_frame, int machine, int type);
struct Sequence *BKE_sequencer_add_image_strip(struct bContext *C,
ListBase *seqbasep,
struct SeqLoadInfo *seq_load);
@@ -564,11 +416,13 @@ struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C,
ListBase *seqbasep,
struct SeqLoadInfo *seq_load);
-/* copy/paste */
-extern ListBase seqbase_clipboard;
-extern int seqbase_clipboard_frame;
+/* **********************************************************************
+ * modifier.c
+ *
+ * Modifiers
+ * **********************************************************************
+ */
-/* modifiers */
typedef struct SequenceModifierTypeInfo {
/* default name for the modifier */
char name[64]; /* MAX_NAME */
@@ -596,7 +450,6 @@ typedef struct SequenceModifierTypeInfo {
} SequenceModifierTypeInfo;
const struct SequenceModifierTypeInfo *BKE_sequence_modifier_type_info_get(int type);
-
struct SequenceModifierData *BKE_sequence_modifier_new(struct Sequence *seq,
const char *name,
int type);
@@ -609,36 +462,119 @@ struct SequenceModifierData *BKE_sequence_modifier_find_by_name(struct Sequence
struct ImBuf *BKE_sequence_modifier_apply_stack(const SeqRenderData *context,
struct Sequence *seq,
struct ImBuf *ibuf,
- int cfra);
+ int timeline_frame);
void BKE_sequence_modifier_list_copy(struct Sequence *seqn, struct Sequence *seq);
-
int BKE_sequence_supports_modifiers(struct Sequence *seq);
-/* internal filters */
-struct ImBuf *BKE_sequencer_render_mask_input(const SeqRenderData *context,
- int mask_input_type,
- struct Sequence *mask_sequence,
- struct Mask *mask_id,
- int cfra,
- int fra_offset,
- bool make_float);
-void BKE_sequencer_color_balance_apply(struct StripColorBalance *cb,
- struct ImBuf *ibuf,
- float mul,
- bool make_float,
- struct ImBuf *mask_input);
-
-void BKE_sequencer_all_free_anim_ibufs(struct Scene *scene, int cfra);
-bool BKE_sequencer_check_scene_recursion(struct Scene *scene, struct ReportList *reports);
-bool BKE_sequencer_render_loop_check(struct Sequence *seq_main, struct Sequence *seq);
-void BKE_sequencer_flag_for_removal(struct Scene *scene,
- struct ListBase *seqbase,
- struct Sequence *seq);
-void BKE_sequencer_remove_flagged_sequences(struct Scene *scene, struct ListBase *seqbase);
+void BKE_sequence_modifier_blend_write(struct BlendWriter *writer, struct ListBase *modbase);
+void BKE_sequence_modifier_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb);
+void BKE_sequence_modifier_blend_read_lib(struct BlendLibReader *reader,
+ struct Scene *scene,
+ struct ListBase *lb);
+
+/* **********************************************************************
+ * seqeffects.c
+ *
+ * Sequencer effect strip management functions
+ * **********************************************************************
+ */
+
+struct SeqEffectHandle {
+ bool multithreaded;
+ bool supports_mask;
+
+ /* constructors & destructor */
+ /* init is _only_ called on first creation */
+ void (*init)(struct Sequence *seq);
+
+ /* number of input strips needed
+ * (called directly after construction) */
+ int (*num_inputs)(void);
+
+ /* load is called first time after readblenfile in
+ * get_sequence_effect automatically */
+ void (*load)(struct Sequence *seqconst);
+
+ /* duplicate */
+ void (*copy)(struct Sequence *dst, struct Sequence *src, const int flag);
+
+ /* destruct */
+ void (*free)(struct Sequence *seq, const bool do_id_user);
+
+ /* returns: -1: no input needed,
+ * 0: no early out,
+ * 1: out = ibuf1,
+ * 2: out = ibuf2 */
+ int (*early_out)(struct Sequence *seq, float facf0, float facf1);
+
+ /* stores the y-range of the effect IPO */
+ void (*store_icu_yrange)(struct Sequence *seq, short adrcode, float *ymin, float *ymax);
+
+ /* stores the default facf0 and facf1 if no IPO is present */
+ void (*get_default_fac)(struct Sequence *seq, float timeline_frame, float *facf0, float *facf1);
+
+ /* execute the effect
+ * sequence effects are only required to either support
+ * float-rects or byte-rects
+ * (mixed cases are handled one layer up...) */
+
+ struct ImBuf *(*execute)(const SeqRenderData *context,
+ struct Sequence *seq,
+ float timeline_frame,
+ float facf0,
+ float facf1,
+ struct ImBuf *ibuf1,
+ struct ImBuf *ibuf2,
+ struct ImBuf *ibuf3);
+
+ struct ImBuf *(*init_execution)(const SeqRenderData *context,
+ struct ImBuf *ibuf1,
+ struct ImBuf *ibuf2,
+ struct ImBuf *ibuf3);
+
+ void (*execute_slice)(const SeqRenderData *context,
+ struct Sequence *seq,
+ float timeline_frame,
+ float facf0,
+ float facf1,
+ struct ImBuf *ibuf1,
+ struct ImBuf *ibuf2,
+ struct ImBuf *ibuf3,
+ int start_line,
+ int total_lines,
+ struct ImBuf *out);
+};
+
+struct SeqEffectHandle BKE_sequence_get_effect(struct Sequence *seq);
+int BKE_sequence_effect_get_num_inputs(int seq_type);
+void BKE_sequencer_text_font_unload(struct TextVars *data, const bool do_id_user);
+void BKE_sequencer_text_font_load(struct TextVars *data, const bool do_id_user);
+
+/* **********************************************************************
+ * sequencer.c
+ *
+ * Clipboard
+ * **********************************************************************
+ */
+
+extern ListBase seqbase_clipboard;
+extern int seqbase_clipboard_frame;
+void BKE_sequencer_base_clipboard_pointers_store(struct Main *bmain, struct ListBase *seqbase);
+void BKE_sequencer_base_clipboard_pointers_restore(struct ListBase *seqbase, struct Main *bmain);
+void BKE_sequencer_free_clipboard(void);
+
+/* **********************************************************************
+ * sequencer.c
+ *
+ * Depsgraph
+ * **********************************************************************
+ */
/* A debug and development function which checks whether sequences have unique UUIDs.
* Errors will be reported to the console. */
void BKE_sequencer_check_uuids_unique_and_report(const struct Scene *scene);
+/* Generate new UUID for the given sequence. */
+void BKE_sequence_session_uuid_generate(struct Sequence *sequence);
#ifdef __cplusplus
}
diff --git a/source/blender/sequencer/intern/clipboard.c b/source/blender/sequencer/intern/clipboard.c
new file mode 100644
index 00000000000..7d37dab93dd
--- /dev/null
+++ b/source/blender/sequencer/intern/clipboard.c
@@ -0,0 +1,179 @@
+/*
+ * 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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_sound_types.h"
+
+#include "BLI_listbase.h"
+
+#include "BKE_main.h"
+#include "BKE_movieclip.h"
+#include "BKE_scene.h"
+#include "BKE_sound.h"
+
+#include "SEQ_sequencer.h"
+
+#include "sequencer.h"
+
+#ifdef WITH_AUDASPACE
+# include <AUD_Special.h>
+#endif
+
+/* -------------------------------------------------------------------- */
+/* Manage pointers in the clipboard.
+ * note that these pointers should _never_ be access in the sequencer,
+ * they are only for storage while in the clipboard
+ * notice 'newid' is used for temp pointer storage here, validate on access (this is safe usage,
+ * since those data-blocks are fully out of Main lists).
+ */
+
+ListBase seqbase_clipboard;
+int seqbase_clipboard_frame;
+
+void BKE_sequencer_base_clipboard_pointers_free(struct ListBase *seqbase);
+
+void BKE_sequencer_free_clipboard(void)
+{
+ Sequence *seq, *nseq;
+
+ BKE_sequencer_base_clipboard_pointers_free(&seqbase_clipboard);
+
+ for (seq = seqbase_clipboard.first; seq; seq = nseq) {
+ nseq = seq->next;
+ seq_free_sequence_recurse(NULL, seq, false);
+ }
+ BLI_listbase_clear(&seqbase_clipboard);
+}
+
+#define ID_PT (*id_pt)
+static void seqclipboard_ptr_free(Main *UNUSED(bmain), ID **id_pt)
+{
+ if (ID_PT) {
+ BLI_assert(ID_PT->newid != NULL);
+ MEM_freeN(ID_PT);
+ ID_PT = NULL;
+ }
+}
+static void seqclipboard_ptr_store(Main *UNUSED(bmain), ID **id_pt)
+{
+ if (ID_PT) {
+ ID *id_prev = ID_PT;
+ ID_PT = MEM_dupallocN(ID_PT);
+ ID_PT->newid = id_prev;
+ }
+}
+static void seqclipboard_ptr_restore(Main *bmain, ID **id_pt)
+{
+ if (ID_PT) {
+ const ListBase *lb = which_libbase(bmain, GS(ID_PT->name));
+ void *id_restore;
+
+ BLI_assert(ID_PT->newid != NULL);
+ if (BLI_findindex(lb, (ID_PT)->newid) != -1) {
+ /* the pointer is still valid */
+ id_restore = (ID_PT)->newid;
+ }
+ else {
+ /* the pointer of the same name still exists */
+ id_restore = BLI_findstring(lb, (ID_PT)->name + 2, offsetof(ID, name) + 2);
+ }
+
+ if (id_restore == NULL) {
+ /* check for a data with the same filename */
+ switch (GS(ID_PT->name)) {
+ case ID_SO: {
+ id_restore = BLI_findstring(lb, ((bSound *)ID_PT)->filepath, offsetof(bSound, filepath));
+ if (id_restore == NULL) {
+ id_restore = BKE_sound_new_file(bmain, ((bSound *)ID_PT)->filepath);
+ (ID_PT)->newid = id_restore; /* reuse next time */
+ }
+ break;
+ }
+ case ID_MC: {
+ id_restore = BLI_findstring(
+ lb, ((MovieClip *)ID_PT)->filepath, offsetof(MovieClip, filepath));
+ if (id_restore == NULL) {
+ id_restore = BKE_movieclip_file_add(bmain, ((MovieClip *)ID_PT)->filepath);
+ (ID_PT)->newid = id_restore; /* reuse next time */
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ /* Replace with pointer to actual data-block. */
+ seqclipboard_ptr_free(bmain, id_pt);
+ ID_PT = id_restore;
+ }
+}
+#undef ID_PT
+
+static void sequence_clipboard_pointers(Main *bmain,
+ Sequence *seq,
+ void (*callback)(Main *, ID **))
+{
+ callback(bmain, (ID **)&seq->scene);
+ callback(bmain, (ID **)&seq->scene_camera);
+ callback(bmain, (ID **)&seq->clip);
+ callback(bmain, (ID **)&seq->mask);
+ callback(bmain, (ID **)&seq->sound);
+
+ if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
+ TextVars *text_data = seq->effectdata;
+ callback(bmain, (ID **)&text_data->text_font);
+ }
+}
+
+/* recursive versions of functions above */
+void BKE_sequencer_base_clipboard_pointers_free(ListBase *seqbase)
+{
+ Sequence *seq;
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ sequence_clipboard_pointers(NULL, seq, seqclipboard_ptr_free);
+ BKE_sequencer_base_clipboard_pointers_free(&seq->seqbase);
+ }
+}
+void BKE_sequencer_base_clipboard_pointers_store(Main *bmain, ListBase *seqbase)
+{
+ Sequence *seq;
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ sequence_clipboard_pointers(bmain, seq, seqclipboard_ptr_store);
+ BKE_sequencer_base_clipboard_pointers_store(bmain, &seq->seqbase);
+ }
+}
+void BKE_sequencer_base_clipboard_pointers_restore(ListBase *seqbase, Main *bmain)
+{
+ Sequence *seq;
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ sequence_clipboard_pointers(bmain, seq, seqclipboard_ptr_restore);
+ BKE_sequencer_base_clipboard_pointers_restore(&seq->seqbase, bmain);
+ }
+}
diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c
index dd7634a10eb..ba16206ce97 100644
--- a/source/blender/sequencer/intern/effects.c
+++ b/source/blender/sequencer/intern/effects.c
@@ -46,7 +46,6 @@
#include "BKE_fcurve.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
-#include "BKE_sequencer.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
@@ -59,8 +58,15 @@
#include "RE_pipeline.h"
+#include "SEQ_sequencer.h"
+
#include "BLF_api.h"
+#include "effects.h"
+#include "render.h"
+#include "strip_time.h"
+#include "utils.h"
+
static struct SeqEffectHandle get_sequence_effect_impl(int seq_type);
static void slice_get_byte_buffers(const SeqRenderData *context,
@@ -148,15 +154,15 @@ static ImBuf *prepare_effect_imbufs(const SeqRenderData *context,
if (out->rect_float) {
if (ibuf1 && !ibuf1->rect_float) {
- BKE_sequencer_imbuf_to_sequencer_space(scene, ibuf1, true);
+ seq_imbuf_to_sequencer_space(scene, ibuf1, true);
}
if (ibuf2 && !ibuf2->rect_float) {
- BKE_sequencer_imbuf_to_sequencer_space(scene, ibuf2, true);
+ seq_imbuf_to_sequencer_space(scene, ibuf2, true);
}
if (ibuf3 && !ibuf3->rect_float) {
- BKE_sequencer_imbuf_to_sequencer_space(scene, ibuf3, true);
+ seq_imbuf_to_sequencer_space(scene, ibuf3, true);
}
IMB_colormanagement_assign_float_colorspace(out, scene->sequencer_colorspace_settings.name);
@@ -350,7 +356,7 @@ static void do_alphaover_effect_float(
static void do_alphaover_effect(const SeqRenderData *context,
Sequence *UNUSED(seq),
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -557,7 +563,7 @@ static void do_alphaunder_effect_float(
static void do_alphaunder_effect(const SeqRenderData *context,
Sequence *UNUSED(seq),
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -692,7 +698,7 @@ static void do_cross_effect_float(
static void do_cross_effect(const SeqRenderData *context,
Sequence *UNUSED(seq),
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -990,7 +996,7 @@ static struct ImBuf *gammacross_init_execution(const SeqRenderData *context,
static void do_gammacross_effect(const SeqRenderData *context,
Sequence *UNUSED(seq),
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -1125,7 +1131,7 @@ static void do_add_effect_float(
static void do_add_effect(const SeqRenderData *context,
Sequence *UNUSED(seq),
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -1260,7 +1266,7 @@ static void do_sub_effect_float(
static void do_sub_effect(const SeqRenderData *context,
Sequence *UNUSED(seq),
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -1511,7 +1517,7 @@ static void do_mul_effect_float(
static void do_mul_effect(const SeqRenderData *context,
Sequence *UNUSED(seq),
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -1801,7 +1807,7 @@ static void do_blend_effect_byte(float facf0,
static void do_blend_mode_effect(const SeqRenderData *context,
Sequence *seq,
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -1842,7 +1848,7 @@ static void init_colormix_effect(Sequence *seq)
static void do_colormix_effect(const SeqRenderData *context,
Sequence *seq,
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float UNUSED(facf0),
float UNUSED(facf1),
ImBuf *ibuf1,
@@ -2307,7 +2313,7 @@ static void do_wipe_effect_float(Sequence *seq,
static ImBuf *do_wipe_effect(const SeqRenderData *context,
Sequence *seq,
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -2438,7 +2444,7 @@ static void transform_image(int x,
static void do_transform_effect(const SeqRenderData *context,
Sequence *seq,
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float UNUSED(facf0),
float UNUSED(facf1),
ImBuf *ibuf1,
@@ -2785,7 +2791,7 @@ static void do_glow_effect_float(Sequence *seq,
static ImBuf *do_glow_effect(const SeqRenderData *context,
Sequence *seq,
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -2864,7 +2870,7 @@ static int early_out_color(Sequence *UNUSED(seq), float UNUSED(facf0), float UNU
static ImBuf *do_solid_color(const SeqRenderData *context,
Sequence *seq,
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -2962,7 +2968,7 @@ static int early_out_multicam(Sequence *UNUSED(seq), float UNUSED(facf0), float
static ImBuf *do_multicam(const SeqRenderData *context,
Sequence *seq,
- float cfra,
+ float timeline_frame,
float UNUSED(facf0),
float UNUSED(facf1),
ImBuf *UNUSED(ibuf1),
@@ -2986,7 +2992,7 @@ static ImBuf *do_multicam(const SeqRenderData *context,
return NULL;
}
- out = BKE_sequencer_give_ibuf_seqbase(context, cfra, seq->multicam_source, seqbasep);
+ out = seq_render_give_ibuf_seqbase(context, timeline_frame, seq->multicam_source, seqbasep);
return out;
}
@@ -3004,7 +3010,7 @@ static int early_out_adjustment(Sequence *UNUSED(seq), float UNUSED(facf0), floa
return EARLY_NO_INPUT;
}
-static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, float cfra)
+static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, float timeline_frame)
{
Editing *ed;
ListBase *seqbasep;
@@ -3015,7 +3021,7 @@ static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, fl
seqbasep = BKE_sequence_seqbase(&ed->seqbase, seq);
if (seq->machine > 1) {
- i = BKE_sequencer_give_ibuf_seqbase(context, cfra, seq->machine - 1, seqbasep);
+ i = seq_render_give_ibuf_seqbase(context, timeline_frame, seq->machine - 1, seqbasep);
}
/* found nothing? so let's work the way up the metastrip stack, so
@@ -3029,7 +3035,7 @@ static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, fl
meta = BKE_sequence_metastrip(&ed->seqbase, NULL, seq);
if (meta) {
- i = do_adjustment_impl(context, meta, cfra);
+ i = do_adjustment_impl(context, meta, timeline_frame);
}
}
@@ -3038,7 +3044,7 @@ static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, fl
static ImBuf *do_adjustment(const SeqRenderData *context,
Sequence *seq,
- float cfra,
+ float timeline_frame,
float UNUSED(facf0),
float UNUSED(facf1),
ImBuf *UNUSED(ibuf1),
@@ -3054,7 +3060,7 @@ static ImBuf *do_adjustment(const SeqRenderData *context,
return NULL;
}
- out = do_adjustment_impl(context, seq, cfra);
+ out = do_adjustment_impl(context, seq, timeline_frame);
return out;
}
@@ -3142,7 +3148,7 @@ static void store_icu_yrange_speed(Sequence *seq, short UNUSED(adrcode), float *
void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool force)
{
- int cfra;
+ int timeline_frame;
float fallback_fac = 1.0f;
SpeedControlVars *v = (SpeedControlVars *)seq->effectdata;
FCurve *fcu = NULL;
@@ -3195,9 +3201,9 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for
v->frameMap[0] = 0;
v->lastValidFrame = 0;
- for (cfra = 1; cfra < v->length; cfra++) {
+ for (timeline_frame = 1; timeline_frame < v->length; timeline_frame++) {
if (fcu) {
- facf = evaluate_fcurve(fcu, seq->startdisp + cfra);
+ facf = evaluate_fcurve(fcu, seq->startdisp + timeline_frame);
}
else {
facf = fallback_fac;
@@ -3207,11 +3213,11 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for
cursor += facf;
if (cursor >= seq->seq1->len) {
- v->frameMap[cfra] = seq->seq1->len - 1;
+ v->frameMap[timeline_frame] = seq->seq1->len - 1;
}
else {
- v->frameMap[cfra] = cursor;
- v->lastValidFrame = cfra;
+ v->frameMap[timeline_frame] = cursor;
+ v->lastValidFrame = timeline_frame;
}
}
}
@@ -3219,10 +3225,10 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for
float facf;
v->lastValidFrame = 0;
- for (cfra = 0; cfra < v->length; cfra++) {
+ for (timeline_frame = 0; timeline_frame < v->length; timeline_frame++) {
if (fcu) {
- facf = evaluate_fcurve(fcu, seq->startdisp + cfra);
+ facf = evaluate_fcurve(fcu, seq->startdisp + timeline_frame);
}
else {
facf = fallback_fac;
@@ -3237,45 +3243,47 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for
facf = seq->seq1->len - 1;
}
else {
- v->lastValidFrame = cfra;
+ v->lastValidFrame = timeline_frame;
}
- v->frameMap[cfra] = facf;
+ v->frameMap[timeline_frame] = facf;
}
}
}
-/* Override cfra when rendering speed effect input. */
+/* Override timeline_frame when rendering speed effect input. */
float BKE_sequencer_speed_effect_target_frame_get(const SeqRenderData *context,
Sequence *seq,
- float cfra,
+ float timeline_frame,
int input)
{
- int nr = BKE_sequencer_give_stripelem_index(seq, cfra);
+ int frame_index = seq_give_frame_index(seq, timeline_frame);
SpeedControlVars *s = (SpeedControlVars *)seq->effectdata;
BKE_sequence_effect_speed_rebuild_map(context->scene, seq, false);
/* No interpolation. */
if ((s->flags & SEQ_SPEED_USE_INTERPOLATION) == 0) {
- return seq->start + s->frameMap[nr];
+ return seq->start + s->frameMap[frame_index];
}
/* We need to provide current and next image for interpolation. */
if (input == 0) { /* Current frame. */
- return floor(seq->start + s->frameMap[nr]);
+ return floor(seq->start + s->frameMap[frame_index]);
}
/* Next frame. */
- return ceil(seq->start + s->frameMap[nr]);
+ return ceil(seq->start + s->frameMap[frame_index]);
}
-static float speed_effect_interpolation_ratio_get(SpeedControlVars *s, Sequence *seq, float cfra)
+static float speed_effect_interpolation_ratio_get(SpeedControlVars *s,
+ Sequence *seq,
+ float timeline_frame)
{
- int nr = BKE_sequencer_give_stripelem_index(seq, cfra);
- return s->frameMap[nr] - floor(s->frameMap[nr]);
+ int frame_index = seq_give_frame_index(seq, timeline_frame);
+ return s->frameMap[frame_index] - floor(s->frameMap[frame_index]);
}
static ImBuf *do_speed_effect(const SeqRenderData *context,
Sequence *seq,
- float cfra,
+ float timeline_frame,
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -3288,10 +3296,10 @@ static ImBuf *do_speed_effect(const SeqRenderData *context,
if (s->flags & SEQ_SPEED_USE_INTERPOLATION) {
out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
- facf0 = facf1 = speed_effect_interpolation_ratio_get(s, seq, cfra);
+ facf0 = facf1 = speed_effect_interpolation_ratio_get(s, seq, timeline_frame);
/* Current frame is ibuf1, next frame is ibuf2. */
- out = BKE_sequencer_effect_execute_threaded(
- &cross_effect, context, NULL, cfra, facf0, facf1, ibuf1, ibuf2, ibuf3);
+ out = seq_render_effect_execute_threaded(
+ &cross_effect, context, NULL, timeline_frame, facf0, facf1, ibuf1, ibuf2, ibuf3);
return out;
}
@@ -3303,7 +3311,7 @@ static ImBuf *do_speed_effect(const SeqRenderData *context,
static void do_overdrop_effect(const SeqRenderData *context,
Sequence *UNUSED(seq),
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float facf0,
float facf1,
ImBuf *ibuf1,
@@ -3727,7 +3735,7 @@ static void *render_effect_execute_do_y_thread(void *thread_data_v)
static ImBuf *do_gaussian_blur_effect(const SeqRenderData *context,
Sequence *seq,
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float UNUSED(facf0),
float UNUSED(facf1),
ImBuf *ibuf1,
@@ -3782,6 +3790,11 @@ static void init_text_effect(Sequence *seq)
copy_v4_fl(data->color, 1.0f);
data->shadow_color[3] = 1.0f;
+ data->box_color[0] = 0.5f;
+ data->box_color[1] = 0.5f;
+ data->box_color[2] = 0.5f;
+ data->box_color[3] = 1.0f;
+ data->box_margin = 0.01f;
BLI_strncpy(data->text, "Text", sizeof(data->text));
@@ -3866,7 +3879,7 @@ static int early_out_text(Sequence *seq, float UNUSED(facf0), float UNUSED(facf1
static ImBuf *do_text_effect(const SeqRenderData *context,
Sequence *seq,
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float UNUSED(facf0),
float UNUSED(facf1),
ImBuf *ibuf1,
@@ -3902,7 +3915,7 @@ static ImBuf *do_text_effect(const SeqRenderData *context,
/* Compensate text size for preview render size. */
proxy_size_comp = context->scene->r.size / 100.0;
if (context->preview_render_size != SEQ_RENDER_SIZE_SCENE) {
- proxy_size_comp = BKE_sequencer_rendersize_to_scale_factor(context->preview_render_size);
+ proxy_size_comp = SEQ_rendersize_to_scale_factor(context->preview_render_size);
}
/* set before return */
@@ -3923,18 +3936,18 @@ static ImBuf *do_text_effect(const SeqRenderData *context,
x = (data->loc[0] * width);
y = (data->loc[1] * height) + y_ofs;
+ /* vars for calculating wordwrap and optional box */
+ struct {
+ struct ResultBLF info;
+ rctf rect;
+ } wrap;
+
+ BLF_boundbox_ex(font, data->text, sizeof(data->text), &wrap.rect, &wrap.info);
+
if ((data->align == SEQ_TEXT_ALIGN_X_LEFT) && (data->align_y == SEQ_TEXT_ALIGN_Y_TOP)) {
y -= line_height;
}
else {
- /* vars for calculating wordwrap */
- struct {
- struct ResultBLF info;
- rctf rect;
- } wrap;
-
- BLF_boundbox_ex(font, data->text, sizeof(data->text), &wrap.rect, &wrap.info);
-
if (data->align == SEQ_TEXT_ALIGN_X_RIGHT) {
x -= BLI_rctf_size_x(&wrap.rect);
}
@@ -3953,8 +3966,34 @@ static ImBuf *do_text_effect(const SeqRenderData *context,
}
}
+ if (data->flag & SEQ_TEXT_BOX) {
+ if (out->rect) {
+ const int margin = data->box_margin * width;
+ const int minx = x + wrap.rect.xmin - margin;
+ const int maxx = x + wrap.rect.xmax + margin;
+ const int miny = y + wrap.rect.ymin - margin;
+ const int maxy = y + wrap.rect.ymax + margin;
+
+ if (data->flag & SEQ_TEXT_SHADOW) {
+ /* draw a shadow behind the box */
+ int shadow_offset = 0.005f * width;
+
+ if (shadow_offset == 0) {
+ shadow_offset = 1;
+ }
+
+ IMB_rectfill_area_replace(out,
+ data->shadow_color,
+ minx + shadow_offset,
+ miny - shadow_offset,
+ maxx + shadow_offset,
+ maxy - shadow_offset);
+ }
+ IMB_rectfill_area_replace(out, data->box_color, minx, miny, maxx, maxy);
+ }
+ }
/* BLF_SHADOW won't work with buffers, instead use cheap shadow trick */
- if (data->flag & SEQ_TEXT_SHADOW) {
+ else if (data->flag & SEQ_TEXT_SHADOW) {
int fontx, fonty;
fontx = BLF_width_max(font);
fonty = line_height;
@@ -4040,16 +4079,16 @@ static void store_icu_yrange_noop(Sequence *UNUSED(seq),
}
static void get_default_fac_noop(Sequence *UNUSED(seq),
- float UNUSED(cfra),
+ float UNUSED(timeline_frame),
float *facf0,
float *facf1)
{
*facf0 = *facf1 = 1.0;
}
-static void get_default_fac_fade(Sequence *seq, float cfra, float *facf0, float *facf1)
+static void get_default_fac_fade(Sequence *seq, float timeline_frame, float *facf0, float *facf1)
{
- *facf0 = (float)(cfra - seq->startdisp);
+ *facf0 = (float)(timeline_frame - seq->startdisp);
*facf1 = (float)(*facf0 + 0.5f);
*facf0 /= seq->len;
*facf1 /= seq->len;
@@ -4282,10 +4321,3 @@ int BKE_sequence_effect_get_num_inputs(int seq_type)
}
return 0;
}
-
-int BKE_sequence_effect_get_supports_mask(int seq_type)
-{
- struct SeqEffectHandle rval = get_sequence_effect_impl(seq_type);
-
- return rval.supports_mask;
-}
diff --git a/source/blender/sequencer/intern/effects.h b/source/blender/sequencer/intern/effects.h
new file mode 100644
index 00000000000..58e0a97d4c5
--- /dev/null
+++ b/source/blender/sequencer/intern/effects.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.
+ *
+ * The Original Code is Copyright (C) 2004 Blender Foundation.
+ * All rights reserved.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup sequencer
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct Scene;
+struct Sequence;
+struct SeqRenderData;
+
+/* **********************************************************************
+ * sequencer.c
+ *
+ * Sequencer editing functions
+ * **********************************************************************
+ */
+
+struct SeqEffectHandle BKE_sequence_get_blend(struct Sequence *seq);
+void BKE_sequence_effect_speed_rebuild_map(struct Scene *scene, struct Sequence *seq, bool force);
+float BKE_sequencer_speed_effect_target_frame_get(const struct SeqRenderData *context,
+ struct Sequence *seq,
+ float timeline_frame,
+ int input);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c
index 7d2858050be..d515a13cdee 100644
--- a/source/blender/sequencer/intern/image_cache.c
+++ b/source/blender/sequencer/intern/image_cache.c
@@ -47,7 +47,12 @@
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
+
+#include "SEQ_sequencer.h"
+
+#include "image_cache.h"
+#include "prefetch.h"
+#include "strip_time.h"
/**
* Sequencer Cache Design Notes
@@ -155,17 +160,20 @@ typedef struct SeqCacheKey {
struct SeqCacheKey *link_next; /* Used for linking intermediate items to final frame. */
struct Sequence *seq;
SeqRenderData context;
- float nfra;
- float cost; /* In short: render time(s) divided by playback frame duration(s) */
- bool is_temp_cache; /* this cache entry will be freed before rendering next frame */
+ float frame_index; /* Usually same as timeline_frame. Mapped to media for RAW entries. */
+ float timeline_frame; /* Only for reference - used for freeing when cache is full. */
+ float cost; /* In short: render time(s) divided by playback frame duration(s) */
+ bool is_temp_cache; /* this cache entry will be freed before rendering next frame */
/* ID of task for asigning temp cache entries to particular task(thread, etc.) */
eSeqTaskId task_id;
int type;
} SeqCacheKey;
static ThreadMutex cache_create_lock = BLI_MUTEX_INITIALIZER;
-static float seq_cache_cfra_to_frame_index(Sequence *seq, float cfra);
-static float seq_cache_frame_index_to_cfra(Sequence *seq, float nfra);
+static float seq_cache_timeline_frame_to_frame_index(Sequence *seq,
+ float timeline_frame,
+ int type);
+static float seq_cache_frame_index_to_timeline_frame(Sequence *seq, float frame_index);
static char *seq_disk_cache_base_dir(void)
{
@@ -376,7 +384,7 @@ static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache,
size_t path_len)
{
seq_disk_cache_get_dir(disk_cache, key->context.scene, key->seq, path, path_len);
- int frameno = (int)key->nfra / DCACHE_IMAGES_PER_FILE;
+ int frameno = (int)key->frame_index / DCACHE_IMAGES_PER_FILE;
char cache_filename[FILE_MAXFILE];
sprintf(cache_filename,
DCACHE_FNAME_FORMAT,
@@ -445,8 +453,9 @@ static void seq_disk_cache_delete_invalid_files(SeqDiskCache *disk_cache,
next_file = cache_file->next;
if (cache_file->cache_type & invalidate_types) {
if (STREQ(cache_dir, cache_file->dir)) {
- int cfra_start = seq_cache_frame_index_to_cfra(seq, cache_file->start_frame);
- if (cfra_start > range_start && cfra_start <= range_end) {
+ int timeline_frame_start = seq_cache_frame_index_to_timeline_frame(
+ seq, cache_file->start_frame);
+ if (timeline_frame_start > range_start && timeline_frame_start <= range_end) {
seq_disk_cache_delete_file(disk_cache, cache_file);
}
}
@@ -553,7 +562,7 @@ static int seq_disk_cache_add_header_entry(SeqCacheKey *key, ImBuf *ibuf, DiskCa
}
header->entry[i].offset = offset;
- header->entry[i].frameno = key->nfra;
+ header->entry[i].frameno = key->frame_index;
/* Store colorspace name of ibuf. */
const char *colorspace_name;
@@ -574,7 +583,7 @@ static int seq_disk_cache_add_header_entry(SeqCacheKey *key, ImBuf *ibuf, DiskCa
static int seq_disk_cache_get_header_entry(SeqCacheKey *key, DiskCacheHeader *header)
{
for (int i = 0; i < DCACHE_IMAGES_PER_FILE; i++) {
- if (header->entry[i].frameno == key->nfra) {
+ if (header->entry[i].frameno == key->frame_index) {
return i;
}
}
@@ -710,7 +719,7 @@ static unsigned int seq_cache_hashhash(const void *key_)
const SeqCacheKey *key = key_;
unsigned int rval = seq_hash_render_data(&key->context);
- rval ^= *(const unsigned int *)&key->nfra;
+ rval ^= *(const unsigned int *)&key->frame_index;
rval += key->type;
rval ^= ((intptr_t)key->seq) << 6;
@@ -722,18 +731,25 @@ static bool seq_cache_hashcmp(const void *a_, const void *b_)
const SeqCacheKey *a = a_;
const SeqCacheKey *b = b_;
- return ((a->seq != b->seq) || (a->nfra != b->nfra) || (a->type != b->type) ||
+ return ((a->seq != b->seq) || (a->frame_index != b->frame_index) || (a->type != b->type) ||
seq_cmp_render_data(&a->context, &b->context));
}
-static float seq_cache_cfra_to_frame_index(Sequence *seq, float cfra)
+static float seq_cache_timeline_frame_to_frame_index(Sequence *seq, float timeline_frame, int type)
{
- return cfra - seq->start;
+ /* With raw images, map timeline_frame to strip input media frame range. This means that static
+ * images or extended frame range of movies will only generate one cache entry. No special
+ * treatment in converting frame index to timeline_frame is needed. */
+ if (type == SEQ_CACHE_STORE_RAW) {
+ return seq_give_frame_index(seq, timeline_frame);
+ }
+
+ return timeline_frame - seq->start;
}
-static float seq_cache_frame_index_to_cfra(Sequence *seq, float nfra)
+static float seq_cache_frame_index_to_timeline_frame(Sequence *seq, float frame_index)
{
- return nfra + seq->start;
+ return frame_index + seq->start;
}
static SeqCache *seq_cache_get_from_scene(Scene *scene)
@@ -846,15 +862,13 @@ static SeqCacheKey *seq_cache_choose_key(Scene *scene, SeqCacheKey *lkey, SeqCac
BKE_sequencer_prefetch_get_time_range(scene, &pfjob_start, &pfjob_end);
if (lkey) {
- int lkey_cfra = seq_cache_frame_index_to_cfra(lkey->seq, lkey->nfra);
- if (lkey_cfra < pfjob_start || lkey_cfra > pfjob_end) {
+ if (lkey->timeline_frame < pfjob_start || lkey->timeline_frame > pfjob_end) {
return lkey;
}
}
if (rkey) {
- int rkey_cfra = seq_cache_frame_index_to_cfra(rkey->seq, rkey->nfra);
- if (rkey_cfra < pfjob_start || rkey_cfra > pfjob_end) {
+ if (rkey->timeline_frame < pfjob_start || rkey->timeline_frame > pfjob_end) {
return rkey;
}
}
@@ -863,17 +877,14 @@ static SeqCacheKey *seq_cache_choose_key(Scene *scene, SeqCacheKey *lkey, SeqCac
}
if (rkey && lkey) {
- int lkey_cfra = seq_cache_frame_index_to_cfra(lkey->seq, lkey->nfra);
- int rkey_cfra = seq_cache_frame_index_to_cfra(rkey->seq, rkey->nfra);
-
- if (lkey_cfra > rkey_cfra) {
+ if (lkey->timeline_frame > rkey->timeline_frame) {
SeqCacheKey *swapkey = lkey;
lkey = rkey;
rkey = swapkey;
}
- int l_diff = scene->r.cfra - lkey_cfra;
- int r_diff = rkey_cfra - scene->r.cfra;
+ int l_diff = scene->r.cfra - lkey->timeline_frame;
+ int r_diff = rkey->timeline_frame - scene->r.cfra;
if (l_diff > r_diff) {
finalkey = lkey;
@@ -953,8 +964,7 @@ static SeqCacheKey *seq_cache_get_item_for_removal(Scene *scene)
if (key->cost <= scene->ed->recycle_max_cost) {
cheap_count++;
if (lkey) {
- if (seq_cache_frame_index_to_cfra(key->seq, key->nfra) <
- seq_cache_frame_index_to_cfra(lkey->seq, lkey->nfra)) {
+ if (key->timeline_frame < lkey->timeline_frame) {
lkey = key;
}
}
@@ -962,8 +972,7 @@ static SeqCacheKey *seq_cache_get_item_for_removal(Scene *scene)
lkey = key;
}
if (rkey) {
- if (seq_cache_frame_index_to_cfra(key->seq, key->nfra) >
- seq_cache_frame_index_to_cfra(rkey->seq, rkey->nfra)) {
+ if (key->timeline_frame > rkey->timeline_frame) {
rkey = key;
}
}
@@ -1074,7 +1083,7 @@ static void seq_cache_create(Main *bmain, Scene *scene)
/* ***************************** API ****************************** */
-void BKE_sequencer_cache_free_temp_cache(Scene *scene, short id, int cfra)
+void BKE_sequencer_cache_free_temp_cache(Scene *scene, short id, int timeline_frame)
{
SeqCache *cache = seq_cache_get_from_scene(scene);
if (!cache) {
@@ -1089,9 +1098,14 @@ void BKE_sequencer_cache_free_temp_cache(Scene *scene, short id, int cfra)
SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
BLI_ghashIterator_step(&gh_iter);
- if (key->is_temp_cache && key->task_id == id &&
- seq_cache_frame_index_to_cfra(key->seq, key->nfra) != cfra) {
- BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree);
+ if (key->is_temp_cache && key->task_id == id) {
+ /* Use frame_index here to avoid freeing raw images if they are used for multiple frames. */
+ float frame_index = seq_cache_timeline_frame_to_frame_index(
+ key->seq, timeline_frame, key->type);
+ if (frame_index != key->frame_index || timeline_frame > key->seq->enddisp ||
+ timeline_frame < key->seq->startdisp) {
+ BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree);
+ }
}
}
seq_cache_unlock(scene);
@@ -1188,10 +1202,9 @@ void BKE_sequencer_cache_cleanup_sequence(Scene *scene,
SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
BLI_ghashIterator_step(&gh_iter);
- int key_cfra = seq_cache_frame_index_to_cfra(key->seq, key->nfra);
-
/* Clean all final and composite in intersection of seq and seq_changed. */
- if (key->type & invalidate_composite && key_cfra >= range_start && key_cfra <= range_end) {
+ if (key->type & invalidate_composite && key->timeline_frame >= range_start &&
+ key->timeline_frame <= range_end) {
if (key->link_next || key->link_prev) {
seq_cache_relink_keys(key->link_next, key->link_prev);
}
@@ -1199,8 +1212,9 @@ void BKE_sequencer_cache_cleanup_sequence(Scene *scene,
BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree);
}
- if (key->type & invalidate_source && key->seq == seq && key_cfra >= seq_changed->startdisp &&
- key_cfra <= seq_changed->enddisp) {
+ if (key->type & invalidate_source && key->seq == seq &&
+ key->timeline_frame >= seq_changed->startdisp &&
+ key->timeline_frame <= seq_changed->enddisp) {
if (key->link_next || key->link_prev) {
seq_cache_relink_keys(key->link_next, key->link_prev);
}
@@ -1212,8 +1226,11 @@ void BKE_sequencer_cache_cleanup_sequence(Scene *scene,
seq_cache_unlock(scene);
}
-struct ImBuf *BKE_sequencer_cache_get(
- const SeqRenderData *context, Sequence *seq, float cfra, int type, bool skip_disk_cache)
+struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context,
+ Sequence *seq,
+ float timeline_frame,
+ int type,
+ bool skip_disk_cache)
{
if (context->skip_cache || context->is_proxy_render || !seq) {
@@ -1245,7 +1262,7 @@ struct ImBuf *BKE_sequencer_cache_get(
if (cache && seq) {
key.seq = seq;
key.context = *context;
- key.nfra = seq_cache_cfra_to_frame_index(seq, cfra);
+ key.frame_index = seq_cache_timeline_frame_to_frame_index(seq, timeline_frame, type);
key.type = type;
ibuf = seq_cache_get(cache, &key);
@@ -1267,10 +1284,10 @@ struct ImBuf *BKE_sequencer_cache_get(
BLI_mutex_unlock(&cache->disk_cache->read_write_mutex);
if (ibuf) {
if (key.type == SEQ_CACHE_STORE_FINAL_OUT) {
- BKE_sequencer_cache_put_if_possible(context, seq, cfra, type, ibuf, 0.0f, true);
+ BKE_sequencer_cache_put_if_possible(context, seq, timeline_frame, type, ibuf, 0.0f, true);
}
else {
- BKE_sequencer_cache_put(context, seq, cfra, type, ibuf, 0.0f, true);
+ BKE_sequencer_cache_put(context, seq, timeline_frame, type, ibuf, 0.0f, true);
}
}
}
@@ -1280,7 +1297,7 @@ struct ImBuf *BKE_sequencer_cache_get(
bool BKE_sequencer_cache_put_if_possible(const SeqRenderData *context,
Sequence *seq,
- float cfra,
+ float timeline_frame,
int type,
ImBuf *ibuf,
float cost,
@@ -1299,7 +1316,7 @@ bool BKE_sequencer_cache_put_if_possible(const SeqRenderData *context,
}
if (BKE_sequencer_cache_recycle_item(scene)) {
- BKE_sequencer_cache_put(context, seq, cfra, type, ibuf, cost, skip_disk_cache);
+ BKE_sequencer_cache_put(context, seq, timeline_frame, type, ibuf, cost, skip_disk_cache);
return true;
}
@@ -1310,7 +1327,7 @@ bool BKE_sequencer_cache_put_if_possible(const SeqRenderData *context,
void BKE_sequencer_cache_put(const SeqRenderData *context,
Sequence *seq,
- float cfra,
+ float timeline_frame,
int type,
ImBuf *i,
float cost,
@@ -1330,7 +1347,7 @@ void BKE_sequencer_cache_put(const SeqRenderData *context,
}
/* Prevent reinserting, it breaks cache key linking. */
- ImBuf *test = BKE_sequencer_cache_get(context, seq, cfra, type, true);
+ ImBuf *test = BKE_sequencer_cache_get(context, seq, timeline_frame, type, true);
if (test) {
IMB_freeImBuf(test);
return;
@@ -1365,7 +1382,8 @@ void BKE_sequencer_cache_put(const SeqRenderData *context,
key->cache_owner = cache;
key->seq = seq;
key->context = *context;
- key->nfra = seq_cache_cfra_to_frame_index(seq, cfra);
+ key->frame_index = seq_cache_timeline_frame_to_frame_index(seq, timeline_frame, type);
+ key->timeline_frame = timeline_frame;
key->type = type;
key->cost = cost;
key->link_prev = NULL;
@@ -1415,11 +1433,14 @@ void BKE_sequencer_cache_put(const SeqRenderData *context,
}
}
-void BKE_sequencer_cache_iterate(
- struct Scene *scene,
- void *userdata,
- bool callback_init(void *userdata, size_t item_count),
- bool callback_iter(void *userdata, struct Sequence *seq, int nfra, int cache_type, float cost))
+void BKE_sequencer_cache_iterate(struct Scene *scene,
+ void *userdata,
+ bool callback_init(void *userdata, size_t item_count),
+ bool callback_iter(void *userdata,
+ struct Sequence *seq,
+ int timeline_frame,
+ int cache_type,
+ float cost))
{
SeqCache *cache = seq_cache_get_from_scene(scene);
if (!cache) {
@@ -1436,7 +1457,7 @@ void BKE_sequencer_cache_iterate(
SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
BLI_ghashIterator_step(&gh_iter);
- interrupt = callback_iter(userdata, key->seq, key->nfra, key->type, key->cost);
+ interrupt = callback_iter(userdata, key->seq, key->timeline_frame, key->type, key->cost);
}
cache->last_key = NULL;
diff --git a/source/blender/sequencer/intern/image_cache.h b/source/blender/sequencer/intern/image_cache.h
new file mode 100644
index 00000000000..0fcf0548628
--- /dev/null
+++ b/source/blender/sequencer/intern/image_cache.h
@@ -0,0 +1,72 @@
+/*
+ * 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) 2004 Blender Foundation.
+ * All rights reserved.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup sequencer
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ImBuf;
+struct Main;
+struct Scene;
+struct Sequence;
+struct SeqRenderData;
+
+#ifdef __cplusplus
+}
+#endif
+
+struct ImBuf *BKE_sequencer_cache_get(const struct SeqRenderData *context,
+ struct Sequence *seq,
+ float timeline_frame,
+ int type,
+ bool skip_disk_cache);
+void BKE_sequencer_cache_put(const struct SeqRenderData *context,
+ struct Sequence *seq,
+ float timeline_frame,
+ int type,
+ struct ImBuf *i,
+ float cost,
+ bool skip_disk_cache);
+bool BKE_sequencer_cache_put_if_possible(const struct SeqRenderData *context,
+ struct Sequence *seq,
+ float timeline_frame,
+ int type,
+ struct ImBuf *nval,
+ float cost,
+ bool skip_disk_cache);
+bool BKE_sequencer_cache_recycle_item(struct Scene *scene);
+void BKE_sequencer_cache_free_temp_cache(struct Scene *scene, short id, int timeline_frame);
+void BKE_sequencer_cache_destruct(struct Scene *scene);
+void BKE_sequencer_cache_cleanup_all(struct Main *bmain);
+void BKE_sequencer_cache_cleanup_sequence(struct Scene *scene,
+ struct Sequence *seq,
+ struct Sequence *seq_changed,
+ int invalidate_types,
+ bool force_seq_changed_range);
+bool BKE_sequencer_cache_is_full(struct Scene *scene);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/sequencer/intern/iterator.c b/source/blender/sequencer/intern/iterator.c
new file mode 100644
index 00000000000..fe6f4184ab1
--- /dev/null
+++ b/source/blender/sequencer/intern/iterator.c
@@ -0,0 +1,168 @@
+/*
+ * 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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+
+#include "BLI_listbase.h"
+
+#include "BKE_scene.h"
+
+#include "SEQ_sequencer.h"
+
+/* ************************* iterator ************************** */
+/* *************** (replaces old WHILE_SEQ) ********************* */
+/* **************** use now SEQ_ALL_BEGIN () SEQ_ALL_END ***************** */
+
+/* sequence strip iterator:
+ * - builds a full array, recursively into meta strips
+ */
+
+static void seq_count(ListBase *seqbase, int *tot)
+{
+ Sequence *seq;
+
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ (*tot)++;
+
+ if (seq->seqbase.first) {
+ seq_count(&seq->seqbase, tot);
+ }
+ }
+}
+
+static void seq_build_array(ListBase *seqbase, Sequence ***array, int depth)
+{
+ Sequence *seq;
+
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ seq->depth = depth;
+
+ if (seq->seqbase.first) {
+ seq_build_array(&seq->seqbase, array, depth + 1);
+ }
+
+ **array = seq;
+ (*array)++;
+ }
+}
+
+static void seq_array(Editing *ed,
+ Sequence ***seqarray,
+ int *tot,
+ const bool use_current_sequences)
+{
+ Sequence **array;
+
+ *seqarray = NULL;
+ *tot = 0;
+
+ if (ed == NULL) {
+ return;
+ }
+
+ if (use_current_sequences) {
+ seq_count(ed->seqbasep, tot);
+ }
+ else {
+ seq_count(&ed->seqbase, tot);
+ }
+
+ if (*tot == 0) {
+ return;
+ }
+
+ *seqarray = array = MEM_mallocN(sizeof(Sequence *) * (*tot), "SeqArray");
+ if (use_current_sequences) {
+ seq_build_array(ed->seqbasep, &array, 0);
+ }
+ else {
+ seq_build_array(&ed->seqbase, &array, 0);
+ }
+}
+
+void BKE_sequence_iterator_begin(Editing *ed, SeqIterator *iter, const bool use_current_sequences)
+{
+ memset(iter, 0, sizeof(*iter));
+ seq_array(ed, &iter->array, &iter->tot, use_current_sequences);
+
+ if (iter->tot) {
+ iter->cur = 0;
+ iter->seq = iter->array[iter->cur];
+ iter->valid = 1;
+ }
+}
+
+void BKE_sequence_iterator_next(SeqIterator *iter)
+{
+ if (++iter->cur < iter->tot) {
+ iter->seq = iter->array[iter->cur];
+ }
+ else {
+ iter->valid = 0;
+ }
+}
+
+void BKE_sequence_iterator_end(SeqIterator *iter)
+{
+ if (iter->array) {
+ MEM_freeN(iter->array);
+ }
+
+ iter->valid = 0;
+}
+
+int BKE_sequencer_base_recursive_apply(ListBase *seqbase,
+ int (*apply_fn)(Sequence *seq, void *),
+ void *arg)
+{
+ Sequence *iseq;
+ for (iseq = seqbase->first; iseq; iseq = iseq->next) {
+ if (BKE_sequencer_recursive_apply(iseq, apply_fn, arg) == -1) {
+ return -1; /* bail out */
+ }
+ }
+ return 1;
+}
+
+int BKE_sequencer_recursive_apply(Sequence *seq, int (*apply_fn)(Sequence *, void *), void *arg)
+{
+ int ret = apply_fn(seq, arg);
+
+ if (ret == -1) {
+ return -1; /* bail out */
+ }
+
+ if (ret && seq->seqbase.first) {
+ ret = BKE_sequencer_base_recursive_apply(&seq->seqbase, apply_fn, arg);
+ }
+
+ return ret;
+}
diff --git a/source/blender/sequencer/intern/modifier.c b/source/blender/sequencer/intern/modifier.c
index a38fe252731..2c37ecf1910 100644
--- a/source/blender/sequencer/intern/modifier.c
+++ b/source/blender/sequencer/intern/modifier.c
@@ -39,12 +39,17 @@
#include "DNA_sequence_types.h"
#include "BKE_colortools.h"
-#include "BKE_sequencer.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "SEQ_sequencer.h"
+
+#include "BLO_read_write.h"
+
+#include "render.h"
+
static SequenceModifierTypeInfo *modifiersTypes[NUM_SEQUENCE_MODIFIER_TYPES];
static bool modifierTypesInit = false;
@@ -79,19 +84,58 @@ typedef struct ModifierThread {
modifier_apply_threaded_cb apply_callback;
} ModifierThread;
+/**
+ * \a timeline_frame is offset by \a fra_offset only in case we are using a real mask.
+ */
+static ImBuf *modifier_render_mask_input(const SeqRenderData *context,
+ int mask_input_type,
+ Sequence *mask_sequence,
+ Mask *mask_id,
+ int timeline_frame,
+ int fra_offset,
+ bool make_float)
+{
+ ImBuf *mask_input = NULL;
+
+ if (mask_input_type == SEQUENCE_MASK_INPUT_STRIP) {
+ if (mask_sequence) {
+ SeqRenderState state;
+ seq_render_state_init(&state);
+
+ mask_input = seq_render_strip(context, &state, mask_sequence, timeline_frame);
+
+ if (make_float) {
+ if (!mask_input->rect_float) {
+ IMB_float_from_rect(mask_input);
+ }
+ }
+ else {
+ if (!mask_input->rect) {
+ IMB_rect_from_float(mask_input);
+ }
+ }
+ }
+ }
+ else if (mask_input_type == SEQUENCE_MASK_INPUT_ID) {
+ mask_input = seq_render_mask(context, mask_id, timeline_frame - fra_offset, make_float);
+ }
+
+ return mask_input;
+}
+
static ImBuf *modifier_mask_get(SequenceModifierData *smd,
const SeqRenderData *context,
- int cfra,
+ int timeline_frame,
int fra_offset,
bool make_float)
{
- return BKE_sequencer_render_mask_input(context,
- smd->mask_input_type,
- smd->mask_sequence,
- smd->mask_id,
- cfra,
- fra_offset,
- make_float);
+ return modifier_render_mask_input(context,
+ smd->mask_input_type,
+ smd->mask_sequence,
+ smd->mask_id,
+ timeline_frame,
+ fra_offset,
+ make_float);
}
static void modifier_init_handle(void *handle_v, int start_line, int tot_line, void *init_data_v)
@@ -171,6 +215,291 @@ static void modifier_apply_threaded(ImBuf *ibuf,
/** \name Color Balance Modifier
* \{ */
+static StripColorBalance calc_cb(StripColorBalance *cb_)
+{
+ StripColorBalance cb = *cb_;
+ int c;
+
+ for (c = 0; c < 3; c++) {
+ cb.lift[c] = 2.0f - cb.lift[c];
+ }
+
+ if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) {
+ for (c = 0; c < 3; c++) {
+ /* tweak to give more subtle results
+ * values above 1.0 are scaled */
+ if (cb.lift[c] > 1.0f) {
+ cb.lift[c] = pow(cb.lift[c] - 1.0f, 2.0) + 1.0;
+ }
+
+ cb.lift[c] = 2.0f - cb.lift[c];
+ }
+ }
+
+ if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAIN) {
+ for (c = 0; c < 3; c++) {
+ if (cb.gain[c] != 0.0f) {
+ cb.gain[c] = 1.0f / cb.gain[c];
+ }
+ else {
+ cb.gain[c] = 1000000; /* should be enough :) */
+ }
+ }
+ }
+
+ if (!(cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAMMA)) {
+ for (c = 0; c < 3; c++) {
+ if (cb.gamma[c] != 0.0f) {
+ cb.gamma[c] = 1.0f / cb.gamma[c];
+ }
+ else {
+ cb.gamma[c] = 1000000; /* should be enough :) */
+ }
+ }
+ }
+
+ return cb;
+}
+
+/* note: lift is actually 2-lift */
+MINLINE float color_balance_fl(
+ float in, const float lift, const float gain, const float gamma, const float mul)
+{
+ float x = (((in - 1.0f) * lift) + 1.0f) * gain;
+
+ /* prevent NaN */
+ if (x < 0.0f) {
+ x = 0.0f;
+ }
+
+ x = powf(x, gamma) * mul;
+ CLAMP(x, FLT_MIN, FLT_MAX);
+ return x;
+}
+
+static void make_cb_table_float(float lift, float gain, float gamma, float *table, float mul)
+{
+ int y;
+
+ for (y = 0; y < 256; y++) {
+ float v = color_balance_fl((float)y * (1.0f / 255.0f), lift, gain, gamma, mul);
+
+ table[y] = v;
+ }
+}
+
+static void color_balance_byte_byte(StripColorBalance *cb_,
+ unsigned char *rect,
+ unsigned char *mask_rect,
+ int width,
+ int height,
+ float mul)
+{
+ // unsigned char cb_tab[3][256];
+ unsigned char *cp = rect;
+ unsigned char *e = cp + width * 4 * height;
+ unsigned char *m = mask_rect;
+
+ StripColorBalance cb = calc_cb(cb_);
+
+ while (cp < e) {
+ float p[4];
+ int c;
+
+ straight_uchar_to_premul_float(p, cp);
+
+ for (c = 0; c < 3; c++) {
+ float t = color_balance_fl(p[c], cb.lift[c], cb.gain[c], cb.gamma[c], mul);
+
+ if (m) {
+ float m_normal = (float)m[c] / 255.0f;
+
+ p[c] = p[c] * (1.0f - m_normal) + t * m_normal;
+ }
+ else {
+ p[c] = t;
+ }
+ }
+
+ premul_float_to_straight_uchar(cp, p);
+
+ cp += 4;
+ if (m) {
+ m += 4;
+ }
+ }
+}
+
+static void color_balance_byte_float(StripColorBalance *cb_,
+ unsigned char *rect,
+ float *rect_float,
+ unsigned char *mask_rect,
+ int width,
+ int height,
+ float mul)
+{
+ float cb_tab[4][256];
+ int c, i;
+ unsigned char *p = rect;
+ unsigned char *e = p + width * 4 * height;
+ unsigned char *m = mask_rect;
+ float *o;
+ StripColorBalance cb;
+
+ o = rect_float;
+
+ cb = calc_cb(cb_);
+
+ for (c = 0; c < 3; c++) {
+ make_cb_table_float(cb.lift[c], cb.gain[c], cb.gamma[c], cb_tab[c], mul);
+ }
+
+ for (i = 0; i < 256; i++) {
+ cb_tab[3][i] = ((float)i) * (1.0f / 255.0f);
+ }
+
+ while (p < e) {
+ if (m) {
+ const float t[3] = {m[0] / 255.0f, m[1] / 255.0f, m[2] / 255.0f};
+
+ p[0] = p[0] * (1.0f - t[0]) + t[0] * cb_tab[0][p[0]];
+ p[1] = p[1] * (1.0f - t[1]) + t[1] * cb_tab[1][p[1]];
+ p[2] = p[2] * (1.0f - t[2]) + t[2] * cb_tab[2][p[2]];
+
+ m += 4;
+ }
+ else {
+ o[0] = cb_tab[0][p[0]];
+ o[1] = cb_tab[1][p[1]];
+ o[2] = cb_tab[2][p[2]];
+ }
+
+ o[3] = cb_tab[3][p[3]];
+
+ p += 4;
+ o += 4;
+ }
+}
+
+static void color_balance_float_float(StripColorBalance *cb_,
+ float *rect_float,
+ const float *mask_rect_float,
+ int width,
+ int height,
+ float mul)
+{
+ float *p = rect_float;
+ const float *e = rect_float + width * 4 * height;
+ const float *m = mask_rect_float;
+ StripColorBalance cb = calc_cb(cb_);
+
+ while (p < e) {
+ int c;
+ for (c = 0; c < 3; c++) {
+ float t = color_balance_fl(p[c], cb.lift[c], cb.gain[c], cb.gamma[c], mul);
+
+ if (m) {
+ p[c] = p[c] * (1.0f - m[c]) + t * m[c];
+ }
+ else {
+ p[c] = t;
+ }
+ }
+
+ p += 4;
+ if (m) {
+ m += 4;
+ }
+ }
+}
+
+typedef struct ColorBalanceInitData {
+ StripColorBalance *cb;
+ ImBuf *ibuf;
+ float mul;
+ ImBuf *mask;
+ bool make_float;
+} ColorBalanceInitData;
+
+typedef struct ColorBalanceThread {
+ StripColorBalance *cb;
+ float mul;
+
+ int width, height;
+
+ unsigned char *rect, *mask_rect;
+ float *rect_float, *mask_rect_float;
+
+ bool make_float;
+} ColorBalanceThread;
+
+static void color_balance_init_handle(void *handle_v,
+ int start_line,
+ int tot_line,
+ void *init_data_v)
+{
+ ColorBalanceThread *handle = (ColorBalanceThread *)handle_v;
+ ColorBalanceInitData *init_data = (ColorBalanceInitData *)init_data_v;
+ ImBuf *ibuf = init_data->ibuf;
+ ImBuf *mask = init_data->mask;
+
+ int offset = 4 * start_line * ibuf->x;
+
+ memset(handle, 0, sizeof(ColorBalanceThread));
+
+ handle->cb = init_data->cb;
+ handle->mul = init_data->mul;
+ handle->width = ibuf->x;
+ handle->height = tot_line;
+ handle->make_float = init_data->make_float;
+
+ if (ibuf->rect) {
+ handle->rect = (unsigned char *)ibuf->rect + offset;
+ }
+
+ if (ibuf->rect_float) {
+ handle->rect_float = ibuf->rect_float + offset;
+ }
+
+ if (mask) {
+ if (mask->rect) {
+ handle->mask_rect = (unsigned char *)mask->rect + offset;
+ }
+
+ if (mask->rect_float) {
+ handle->mask_rect_float = mask->rect_float + offset;
+ }
+ }
+ else {
+ handle->mask_rect = NULL;
+ handle->mask_rect_float = NULL;
+ }
+}
+
+static void *color_balance_do_thread(void *thread_data_v)
+{
+ ColorBalanceThread *thread_data = (ColorBalanceThread *)thread_data_v;
+ StripColorBalance *cb = thread_data->cb;
+ int width = thread_data->width, height = thread_data->height;
+ unsigned char *rect = thread_data->rect;
+ unsigned char *mask_rect = thread_data->mask_rect;
+ float *rect_float = thread_data->rect_float;
+ float *mask_rect_float = thread_data->mask_rect_float;
+ float mul = thread_data->mul;
+
+ if (rect_float) {
+ color_balance_float_float(cb, rect_float, mask_rect_float, width, height, mul);
+ }
+ else if (thread_data->make_float) {
+ color_balance_byte_float(cb, rect, rect_float, mask_rect, width, height, mul);
+ }
+ else {
+ color_balance_byte_byte(cb, rect, mask_rect, width, height, mul);
+ }
+
+ return NULL;
+}
+
static void colorBalance_init_data(SequenceModifierData *smd)
{
ColorBalanceModifierData *cbmd = (ColorBalanceModifierData *)smd;
@@ -185,11 +514,41 @@ static void colorBalance_init_data(SequenceModifierData *smd)
}
}
+static void modifier_color_balance_apply(
+ StripColorBalance *cb, ImBuf *ibuf, float mul, bool make_float, ImBuf *mask_input)
+{
+ ColorBalanceInitData init_data;
+
+ if (!ibuf->rect_float && make_float) {
+ imb_addrectfloatImBuf(ibuf);
+ }
+
+ init_data.cb = cb;
+ init_data.ibuf = ibuf;
+ init_data.mul = mul;
+ init_data.make_float = make_float;
+ init_data.mask = mask_input;
+
+ IMB_processor_apply_threaded(ibuf->y,
+ sizeof(ColorBalanceThread),
+ &init_data,
+ color_balance_init_handle,
+ color_balance_do_thread);
+
+ /* color balance either happens on float buffer or byte buffer, but never on both,
+ * free byte buffer if there's float buffer since float buffer would be used for
+ * color balance in favor of byte buffer
+ */
+ if (ibuf->rect_float && ibuf->rect) {
+ imb_freerectImBuf(ibuf);
+ }
+}
+
static void colorBalance_apply(SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask)
{
ColorBalanceModifierData *cbmd = (ColorBalanceModifierData *)smd;
- BKE_sequencer_color_balance_apply(&cbmd->color_balance, ibuf, cbmd->color_multiply, false, mask);
+ modifier_color_balance_apply(&cbmd->color_balance, ibuf, cbmd->color_multiply, false, mask);
}
static SequenceModifierTypeInfo seqModifier_ColorBalance = {
@@ -492,7 +851,7 @@ static void hue_correct_apply_threaded(int width,
/* adjust value, scaling returned default 0.5 up to 1 */
f = BKE_curvemapping_evaluateF(curve_mapping, 2, hsv[0]);
- hsv[2] *= (f * 2.f);
+ hsv[2] *= (f * 2.0f);
hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */
CLAMP(hsv[1], 0.0f, 1.0f);
@@ -884,7 +1243,7 @@ static void tonemapmodifier_apply(struct SequenceModifierData *smd, ImBuf *ibuf,
unsigned char *cp = (unsigned char *)ibuf->rect;
float avl, maxl = -FLT_MAX, minl = FLT_MAX;
const float sc = 1.0f / p;
- float Lav = 0.f;
+ float Lav = 0.0f;
float cav[4] = {0.0f, 0.0f, 0.0f, 0.0f};
while (p--) {
float pixel[4];
@@ -1050,14 +1409,14 @@ SequenceModifierData *BKE_sequence_modifier_find_by_name(Sequence *seq, const ch
ImBuf *BKE_sequence_modifier_apply_stack(const SeqRenderData *context,
Sequence *seq,
ImBuf *ibuf,
- int cfra)
+ int timeline_frame)
{
SequenceModifierData *smd;
ImBuf *processed_ibuf = ibuf;
if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) {
processed_ibuf = IMB_dupImBuf(ibuf);
- BKE_sequencer_imbuf_from_sequencer_space(context->scene, processed_ibuf);
+ SEQ_render_imbuf_from_sequencer_space(context->scene, processed_ibuf);
}
for (smd = seq->modifiers.first; smd; smd = smd->next) {
@@ -1082,7 +1441,8 @@ ImBuf *BKE_sequence_modifier_apply_stack(const SeqRenderData *context,
frame_offset = smd->mask_id ? ((Mask *)smd->mask_id)->sfra : 0;
}
- ImBuf *mask = modifier_mask_get(smd, context, cfra, frame_offset, ibuf->rect_float != NULL);
+ ImBuf *mask = modifier_mask_get(
+ smd, context, timeline_frame, frame_offset, ibuf->rect_float != NULL);
if (processed_ibuf == ibuf) {
processed_ibuf = IMB_dupImBuf(ibuf);
@@ -1097,7 +1457,7 @@ ImBuf *BKE_sequence_modifier_apply_stack(const SeqRenderData *context,
}
if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) {
- BKE_sequencer_imbuf_to_sequencer_space(context->scene, processed_ibuf, false);
+ seq_imbuf_to_sequencer_space(context->scene, processed_ibuf, false);
}
return processed_ibuf;
@@ -1128,3 +1488,65 @@ int BKE_sequence_supports_modifiers(Sequence *seq)
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name .blend File I/O
+ * \{ */
+
+void BKE_sequence_modifier_blend_write(BlendWriter *writer, ListBase *modbase)
+{
+ LISTBASE_FOREACH (SequenceModifierData *, smd, modbase) {
+ const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type);
+
+ if (smti) {
+ BLO_write_struct_by_name(writer, smti->struct_name, smd);
+
+ if (smd->type == seqModifierType_Curves) {
+ CurvesModifierData *cmd = (CurvesModifierData *)smd;
+
+ BKE_curvemapping_blend_write(writer, &cmd->curve_mapping);
+ }
+ else if (smd->type == seqModifierType_HueCorrect) {
+ HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
+
+ BKE_curvemapping_blend_write(writer, &hcmd->curve_mapping);
+ }
+ }
+ else {
+ BLO_write_struct(writer, SequenceModifierData, smd);
+ }
+ }
+}
+
+void BKE_sequence_modifier_blend_read_data(BlendDataReader *reader, ListBase *lb)
+{
+ BLO_read_list(reader, lb);
+
+ LISTBASE_FOREACH (SequenceModifierData *, smd, lb) {
+ if (smd->mask_sequence) {
+ BLO_read_data_address(reader, &smd->mask_sequence);
+ }
+
+ if (smd->type == seqModifierType_Curves) {
+ CurvesModifierData *cmd = (CurvesModifierData *)smd;
+
+ BKE_curvemapping_blend_read(reader, &cmd->curve_mapping);
+ }
+ else if (smd->type == seqModifierType_HueCorrect) {
+ HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
+
+ BKE_curvemapping_blend_read(reader, &hcmd->curve_mapping);
+ }
+ }
+}
+
+void BKE_sequence_modifier_blend_read_lib(BlendLibReader *reader, Scene *scene, ListBase *lb)
+{
+ LISTBASE_FOREACH (SequenceModifierData *, smd, lb) {
+ if (smd->mask_id) {
+ BLO_read_id_address(reader, scene->id.lib, &smd->mask_id);
+ }
+ }
+}
+
+/** \} */
diff --git a/source/blender/sequencer/intern/multiview.c b/source/blender/sequencer/intern/multiview.c
new file mode 100644
index 00000000000..e120234ed8b
--- /dev/null
+++ b/source/blender/sequencer/intern/multiview.c
@@ -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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "DNA_scene_types.h"
+
+#include "BLI_string.h"
+
+#include "BKE_scene.h"
+
+#include "IMB_imbuf.h"
+
+#include "multiview.h"
+
+void seq_anim_add_suffix(Scene *scene, struct anim *anim, const int view_id)
+{
+ const char *suffix = BKE_scene_multiview_view_id_suffix_get(&scene->r, view_id);
+ IMB_suffix_anim(anim, suffix);
+}
+
+/* the number of files will vary according to the stereo format */
+int seq_num_files(Scene *scene, char views_format, const bool is_multiview)
+{
+ if (!is_multiview) {
+ return 1;
+ }
+ if (views_format == R_IMF_VIEWS_STEREO_3D) {
+ return 1;
+ }
+ /* R_IMF_VIEWS_INDIVIDUAL */
+
+ return BKE_scene_multiview_num_views_get(&scene->r);
+}
+
+void seq_multiview_name(Scene *scene,
+ const int view_id,
+ const char *prefix,
+ const char *ext,
+ char *r_path,
+ size_t r_size)
+{
+ const char *suffix = BKE_scene_multiview_view_id_suffix_get(&scene->r, view_id);
+ BLI_assert(ext != NULL && suffix != NULL && prefix != NULL);
+ BLI_snprintf(r_path, r_size, "%s%s%s", prefix, suffix, ext);
+}
diff --git a/source/blender/sequencer/intern/multiview.h b/source/blender/sequencer/intern/multiview.h
new file mode 100644
index 00000000000..e1f998d18e2
--- /dev/null
+++ b/source/blender/sequencer/intern/multiview.h
@@ -0,0 +1,57 @@
+/*
+ * 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) 2004 Blender Foundation.
+ * All rights reserved.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup sequencer
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct Editing;
+struct ImBuf;
+struct Main;
+struct Mask;
+struct Scene;
+struct Sequence;
+struct StripColorBalance;
+struct StripElem;
+
+/* **********************************************************************
+ * sequencer.c
+ *
+ * Sequencer editing functions
+ * **********************************************************************
+ */
+
+void seq_anim_add_suffix(struct Scene *scene, struct anim *anim, const int view_id);
+void seq_multiview_name(struct Scene *scene,
+ const int view_id,
+ const char *prefix,
+ const char *ext,
+ char *r_path,
+ size_t r_size);
+int seq_num_files(struct Scene *scene, char views_format, const bool is_multiview);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/sequencer/intern/prefetch.c b/source/blender/sequencer/intern/prefetch.c
index ec0bdad28e9..98b83651ffc 100644
--- a/source/blender/sequencer/intern/prefetch.c
+++ b/source/blender/sequencer/intern/prefetch.c
@@ -47,13 +47,18 @@
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_scene.h"
-#include "BKE_sequencer.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_debug.h"
#include "DEG_depsgraph_query.h"
+#include "SEQ_sequencer.h"
+
+#include "image_cache.h"
+#include "prefetch.h"
+#include "render.h"
+
typedef struct PrefetchJob {
struct PrefetchJob *next, *prev;
@@ -283,25 +288,25 @@ static void seq_prefetch_update_context(const SeqRenderData *context)
PrefetchJob *pfjob;
pfjob = seq_prefetch_job_get(context->scene);
- BKE_sequencer_new_render_data(pfjob->bmain_eval,
- pfjob->depsgraph,
- pfjob->scene_eval,
- context->rectx,
- context->recty,
- context->preview_render_size,
- false,
- &pfjob->context_cpy);
+ SEQ_render_new_render_data(pfjob->bmain_eval,
+ pfjob->depsgraph,
+ pfjob->scene_eval,
+ context->rectx,
+ context->recty,
+ context->preview_render_size,
+ false,
+ &pfjob->context_cpy);
pfjob->context_cpy.is_prefetch_render = true;
pfjob->context_cpy.task_id = SEQ_TASK_PREFETCH_RENDER;
- BKE_sequencer_new_render_data(pfjob->bmain,
- pfjob->depsgraph,
- pfjob->scene,
- context->rectx,
- context->recty,
- context->preview_render_size,
- false,
- &pfjob->context);
+ SEQ_render_new_render_data(pfjob->bmain,
+ pfjob->depsgraph,
+ pfjob->scene,
+ context->rectx,
+ context->recty,
+ context->preview_render_size,
+ false,
+ &pfjob->context);
pfjob->context.is_prefetch_render = false;
/* Same ID as prefetch context, because context will be swapped, but we still
@@ -358,7 +363,7 @@ static bool seq_prefetch_do_skip_frame(Scene *scene)
PrefetchJob *pfjob = seq_prefetch_job_get(scene);
float cfra = seq_prefetch_cfra(pfjob);
Sequence *seq_arr[MAXSEQ + 1];
- int count = BKE_sequencer_get_shown_sequences(ed->seqbasep, cfra, 0, seq_arr);
+ int count = seq_get_shown_sequences(ed->seqbasep, cfra, 0, seq_arr);
SeqRenderData *ctx = &pfjob->context_cpy;
ImBuf *ibuf = NULL;
@@ -457,7 +462,7 @@ static void *seq_prefetch_frames(void *job)
continue;
}
- ImBuf *ibuf = BKE_sequencer_give_ibuf(&pfjob->context_cpy, seq_prefetch_cfra(pfjob), 0);
+ ImBuf *ibuf = SEQ_render_give_ibuf(&pfjob->context_cpy, seq_prefetch_cfra(pfjob), 0);
BKE_sequencer_cache_free_temp_cache(
pfjob->scene, pfjob->context.task_id, seq_prefetch_cfra(pfjob));
IMB_freeImBuf(ibuf);
@@ -524,7 +529,7 @@ static PrefetchJob *seq_prefetch_start(const SeqRenderData *context, float cfra)
}
/* Start or resume prefetching*/
-void BKE_sequencer_prefetch_start(const SeqRenderData *context, float cfra, float cost)
+void BKE_sequencer_prefetch_start(const SeqRenderData *context, float timeline_frame, float cost)
{
Scene *scene = context->scene;
Editing *ed = scene->ed;
@@ -544,7 +549,7 @@ void BKE_sequencer_prefetch_start(const SeqRenderData *context, float cfra, floa
!(playing && cost > 0.9) && ed->cache_flag & SEQ_CACHE_ALL_TYPES && has_strips &&
!G.is_rendering && !G.moving) {
- seq_prefetch_start(context, cfra);
+ seq_prefetch_start(context, timeline_frame);
}
}
}
diff --git a/source/blender/sequencer/intern/prefetch.h b/source/blender/sequencer/intern/prefetch.h
new file mode 100644
index 00000000000..aa47a9dbcfc
--- /dev/null
+++ b/source/blender/sequencer/intern/prefetch.h
@@ -0,0 +1,53 @@
+/*
+ * 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) 2004 Blender Foundation.
+ * All rights reserved.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup sequencer
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ImBuf;
+struct Main;
+struct Scene;
+struct Sequence;
+struct SeqRenderData;
+
+#ifdef __cplusplus
+}
+#endif
+
+void BKE_sequencer_prefetch_start(const struct SeqRenderData *context,
+ float timeline_frame,
+ float cost);
+void BKE_sequencer_prefetch_free(struct Scene *scene);
+bool BKE_sequencer_prefetch_job_is_running(struct Scene *scene);
+void BKE_sequencer_prefetch_get_time_range(struct Scene *scene, int *start, int *end);
+struct SeqRenderData *BKE_sequencer_prefetch_get_original_context(
+ const struct SeqRenderData *context);
+struct Sequence *BKE_sequencer_prefetch_get_original_sequence(struct Sequence *seq,
+ struct Scene *scene);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/sequencer/intern/proxy.c b/source/blender/sequencer/intern/proxy.c
new file mode 100644
index 00000000000..ff65216d987
--- /dev/null
+++ b/source/blender/sequencer/intern/proxy.c
@@ -0,0 +1,593 @@
+/*
+ * 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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_anim_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_space_types.h"
+
+#include "BLI_fileops.h"
+#include "BLI_listbase.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+
+#ifdef WIN32
+# include "BLI_winstuff.h"
+#else
+# include <unistd.h>
+#endif
+
+#include "BKE_global.h"
+#include "BKE_image.h"
+#include "BKE_main.h"
+#include "BKE_scene.h"
+
+#include "DEG_depsgraph.h"
+
+#include "IMB_colormanagement.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_metadata.h"
+
+#include "SEQ_sequencer.h"
+
+#include "multiview.h"
+#include "proxy.h"
+#include "render.h"
+#include "sequencer.h"
+#include "strip_time.h"
+#include "utils.h"
+
+typedef struct SeqIndexBuildContext {
+ struct IndexBuildContext *index_context;
+
+ int tc_flags;
+ int size_flags;
+ int quality;
+ bool overwrite;
+ int view_id;
+
+ Main *bmain;
+ Depsgraph *depsgraph;
+ Scene *scene;
+ Sequence *seq, *orig_seq;
+} SeqIndexBuildContext;
+
+int SEQ_rendersize_to_proxysize(int render_size)
+{
+ switch (render_size) {
+ case SEQ_RENDER_SIZE_PROXY_25:
+ return IMB_PROXY_25;
+ case SEQ_RENDER_SIZE_PROXY_50:
+ return IMB_PROXY_50;
+ case SEQ_RENDER_SIZE_PROXY_75:
+ return IMB_PROXY_75;
+ case SEQ_RENDER_SIZE_PROXY_100:
+ return IMB_PROXY_100;
+ }
+ return IMB_PROXY_NONE;
+}
+
+double SEQ_rendersize_to_scale_factor(int render_size)
+{
+ switch (render_size) {
+ case SEQ_RENDER_SIZE_PROXY_25:
+ return 0.25;
+ case SEQ_RENDER_SIZE_PROXY_50:
+ return 0.50;
+ case SEQ_RENDER_SIZE_PROXY_75:
+ return 0.75;
+ }
+ return 1.0;
+}
+
+bool seq_proxy_get_custom_file_fname(Sequence *seq, char *name, const int view_id)
+{
+ char fname[FILE_MAXFILE];
+ char suffix[24];
+ StripProxy *proxy = seq->strip->proxy;
+
+ if (proxy == NULL) {
+ return false;
+ }
+
+ BLI_join_dirfile(fname, PROXY_MAXFILE, proxy->dir, proxy->file);
+ BLI_path_abs(fname, BKE_main_blendfile_path_from_global());
+
+ if (view_id > 0) {
+ BLI_snprintf(suffix, sizeof(suffix), "_%d", view_id);
+ /* TODO(sergey): This will actually append suffix after extension
+ * which is weird but how was originally coded in multi-view branch.
+ */
+ BLI_snprintf(name, PROXY_MAXFILE, "%s_%s", fname, suffix);
+ }
+ else {
+ BLI_strncpy(name, fname, PROXY_MAXFILE);
+ }
+
+ return true;
+}
+
+static bool seq_proxy_get_fname(Editing *ed,
+ Sequence *seq,
+ int timeline_frame,
+ eSpaceSeq_Proxy_RenderSize render_size,
+ char *name,
+ const int view_id)
+{
+ char dir[PROXY_MAXFILE];
+ char suffix[24] = {'\0'};
+ StripProxy *proxy = seq->strip->proxy;
+
+ if (proxy == NULL) {
+ return false;
+ }
+
+ /* Multi-view suffix. */
+ if (view_id > 0) {
+ BLI_snprintf(suffix, sizeof(suffix), "_%d", view_id);
+ }
+
+ /* Per strip with Custom file situation is handled separately. */
+ if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE &&
+ ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE) {
+ if (seq_proxy_get_custom_file_fname(seq, name, view_id)) {
+ return true;
+ }
+ }
+
+ if (ed->proxy_storage == SEQ_EDIT_PROXY_DIR_STORAGE) {
+ /* Per project default. */
+ if (ed->proxy_dir[0] == 0) {
+ BLI_strncpy(dir, "//BL_proxy", sizeof(dir));
+ }
+ else { /* Per project with custom dir. */
+ BLI_strncpy(dir, ed->proxy_dir, sizeof(dir));
+ }
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
+ }
+ else {
+ /* Pre strip with custom dir. */
+ if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_DIR) {
+ BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir));
+ }
+ else { /* Per strip default. */
+ BLI_snprintf(dir, PROXY_MAXFILE, "%s/BL_proxy", seq->strip->dir);
+ }
+ }
+
+ /* Proxy size number to be used in path. */
+ int proxy_size_number = SEQ_rendersize_to_scale_factor(render_size) * 100;
+
+ BLI_snprintf(name,
+ PROXY_MAXFILE,
+ "%s/images/%d/%s_proxy%s",
+ dir,
+ proxy_size_number,
+ SEQ_render_give_stripelem(seq, timeline_frame)->name,
+ suffix);
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
+ strcat(name, ".jpg");
+
+ return true;
+}
+
+bool SEQ_can_use_proxy(Sequence *seq, int psize)
+{
+ if (seq->strip->proxy == NULL) {
+ return false;
+ }
+ short size_flags = seq->strip->proxy->build_size_flags;
+ return (seq->flag & SEQ_USE_PROXY) != 0 && psize != IMB_PROXY_NONE && (size_flags & psize) != 0;
+}
+
+ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline_frame)
+{
+ char name[PROXY_MAXFILE];
+ StripProxy *proxy = seq->strip->proxy;
+ const eSpaceSeq_Proxy_RenderSize psize = context->preview_render_size;
+ Editing *ed = context->scene->ed;
+ StripAnim *sanim;
+
+ /* only use proxies, if they are enabled (even if present!) */
+ if (!SEQ_can_use_proxy(seq, SEQ_rendersize_to_proxysize(psize))) {
+ return NULL;
+ }
+
+ if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) {
+ int frameno = (int)seq_give_frame_index(seq, timeline_frame) + seq->anim_startofs;
+ if (proxy->anim == NULL) {
+ if (seq_proxy_get_fname(ed, seq, timeline_frame, psize, name, context->view_id) == 0) {
+ return NULL;
+ }
+
+ proxy->anim = openanim(name, IB_rect, 0, seq->strip->colorspace_settings.name);
+ }
+ if (proxy->anim == NULL) {
+ return NULL;
+ }
+
+ seq_open_anim_file(context->scene, seq, true);
+ sanim = seq->anims.first;
+
+ frameno = IMB_anim_index_get_frame_index(
+ sanim ? sanim->anim : NULL, seq->strip->proxy->tc, frameno);
+
+ return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE);
+ }
+
+ if (seq_proxy_get_fname(ed, seq, timeline_frame, psize, name, context->view_id) == 0) {
+ return NULL;
+ }
+
+ if (BLI_exists(name)) {
+ ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL);
+
+ if (ibuf) {
+ seq_imbuf_assign_spaces(context->scene, ibuf);
+ }
+
+ return ibuf;
+ }
+
+ return NULL;
+}
+
+static void seq_proxy_build_frame(const SeqRenderData *context,
+ SeqRenderState *state,
+ Sequence *seq,
+ int timeline_frame,
+ int proxy_render_size,
+ const bool overwrite)
+{
+ char name[PROXY_MAXFILE];
+ int quality;
+ int rectx, recty;
+ ImBuf *ibuf_tmp, *ibuf;
+ Editing *ed = context->scene->ed;
+
+ if (!seq_proxy_get_fname(ed, seq, timeline_frame, proxy_render_size, name, context->view_id)) {
+ return;
+ }
+
+ if (!overwrite && BLI_exists(name)) {
+ return;
+ }
+
+ ibuf_tmp = seq_render_strip(context, state, seq, timeline_frame);
+
+ rectx = (proxy_render_size * ibuf_tmp->x) / 100;
+ recty = (proxy_render_size * ibuf_tmp->y) / 100;
+
+ if (ibuf_tmp->x != rectx || ibuf_tmp->y != recty) {
+ ibuf = IMB_dupImBuf(ibuf_tmp);
+ IMB_metadata_copy(ibuf, ibuf_tmp);
+ IMB_freeImBuf(ibuf_tmp);
+ IMB_scalefastImBuf(ibuf, (short)rectx, (short)recty);
+ }
+ else {
+ ibuf = ibuf_tmp;
+ }
+
+ /* depth = 32 is intentionally left in, otherwise ALPHA channels
+ * won't work... */
+ quality = seq->strip->proxy->quality;
+ ibuf->ftype = IMB_FTYPE_JPG;
+ ibuf->foptions.quality = quality;
+
+ /* unsupported feature only confuses other s/w */
+ if (ibuf->planes == 32) {
+ ibuf->planes = 24;
+ }
+
+ BLI_make_existing_file(name);
+
+ const bool ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
+ if (ok == false) {
+ perror(name);
+ }
+
+ IMB_freeImBuf(ibuf);
+}
+
+/**
+ * Returns whether the file this context would read from even exist,
+ * if not, don't create the context
+ */
+static bool seq_proxy_multiview_context_invalid(Sequence *seq, Scene *scene, const int view_id)
+{
+ if ((scene->r.scemode & R_MULTIVIEW) == 0) {
+ return false;
+ }
+
+ if ((seq->type == SEQ_TYPE_IMAGE) && (seq->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
+ static char prefix[FILE_MAX];
+ static const char *ext = NULL;
+ char str[FILE_MAX];
+
+ if (view_id == 0) {
+ char path[FILE_MAX];
+ BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name);
+ BLI_path_abs(path, BKE_main_blendfile_path_from_global());
+ BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext);
+ }
+ else {
+ prefix[0] = '\0';
+ }
+
+ if (prefix[0] == '\0') {
+ return view_id != 0;
+ }
+
+ seq_multiview_name(scene, view_id, prefix, ext, str, FILE_MAX);
+
+ if (BLI_access(str, R_OK) == 0) {
+ return false;
+ }
+
+ return view_id != 0;
+ }
+ return false;
+}
+
+/**
+ * This returns the maximum possible number of required contexts
+ */
+static int seq_proxy_context_count(Sequence *seq, Scene *scene)
+{
+ int num_views = 1;
+
+ if ((scene->r.scemode & R_MULTIVIEW) == 0) {
+ return 1;
+ }
+
+ switch (seq->type) {
+ case SEQ_TYPE_MOVIE: {
+ num_views = BLI_listbase_count(&seq->anims);
+ break;
+ }
+ case SEQ_TYPE_IMAGE: {
+ switch (seq->views_format) {
+ case R_IMF_VIEWS_INDIVIDUAL:
+ num_views = BKE_scene_multiview_num_views_get(&scene->r);
+ break;
+ case R_IMF_VIEWS_STEREO_3D:
+ num_views = 2;
+ break;
+ case R_IMF_VIEWS_MULTIVIEW:
+ /* not supported at the moment */
+ /* pass through */
+ default:
+ num_views = 1;
+ }
+ break;
+ }
+ }
+
+ return num_views;
+}
+
+bool SEQ_proxy_rebuild_context(Main *bmain,
+ Depsgraph *depsgraph,
+ Scene *scene,
+ Sequence *seq,
+ struct GSet *file_list,
+ ListBase *queue)
+{
+ SeqIndexBuildContext *context;
+ Sequence *nseq;
+ LinkData *link;
+ int num_files;
+ int i;
+
+ if (!seq->strip || !seq->strip->proxy) {
+ return true;
+ }
+
+ if (!(seq->flag & SEQ_USE_PROXY)) {
+ return true;
+ }
+
+ num_files = seq_proxy_context_count(seq, scene);
+
+ for (i = 0; i < num_files; i++) {
+ if (seq_proxy_multiview_context_invalid(seq, scene, i)) {
+ continue;
+ }
+
+ context = MEM_callocN(sizeof(SeqIndexBuildContext), "seq proxy rebuild context");
+
+ nseq = BKE_sequence_dupli_recursive(scene, scene, NULL, seq, 0);
+
+ context->tc_flags = nseq->strip->proxy->build_tc_flags;
+ context->size_flags = nseq->strip->proxy->build_size_flags;
+ context->quality = nseq->strip->proxy->quality;
+ context->overwrite = (nseq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) == 0;
+
+ context->bmain = bmain;
+ context->depsgraph = depsgraph;
+ context->scene = scene;
+ context->orig_seq = seq;
+ context->seq = nseq;
+
+ context->view_id = i; /* only for images */
+
+ if (nseq->type == SEQ_TYPE_MOVIE) {
+ StripAnim *sanim;
+
+ seq_open_anim_file(scene, nseq, true);
+ sanim = BLI_findlink(&nseq->anims, i);
+
+ if (sanim->anim) {
+ context->index_context = IMB_anim_index_rebuild_context(sanim->anim,
+ context->tc_flags,
+ context->size_flags,
+ context->quality,
+ context->overwrite,
+ file_list);
+ }
+ if (!context->index_context) {
+ MEM_freeN(context);
+ return false;
+ }
+ }
+
+ link = BLI_genericNodeN(context);
+ BLI_addtail(queue, link);
+ }
+ return true;
+}
+
+void SEQ_proxy_rebuild(SeqIndexBuildContext *context,
+ short *stop,
+ short *do_update,
+ float *progress)
+{
+ const bool overwrite = context->overwrite;
+ SeqRenderData render_context;
+ Sequence *seq = context->seq;
+ Scene *scene = context->scene;
+ Main *bmain = context->bmain;
+ int timeline_frame;
+
+ if (seq->type == SEQ_TYPE_MOVIE) {
+ if (context->index_context) {
+ IMB_anim_index_rebuild(context->index_context, stop, do_update, progress);
+ }
+
+ return;
+ }
+
+ if (!(seq->flag & SEQ_USE_PROXY)) {
+ return;
+ }
+
+ /* that's why it is called custom... */
+ if (seq->strip->proxy && seq->strip->proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) {
+ return;
+ }
+
+ /* fail safe code */
+
+ SEQ_render_new_render_data(bmain,
+ context->depsgraph,
+ context->scene,
+ roundf((scene->r.size * (float)scene->r.xsch) / 100.0f),
+ roundf((scene->r.size * (float)scene->r.ysch) / 100.0f),
+ 100,
+ false,
+ &render_context);
+
+ render_context.skip_cache = true;
+ render_context.is_proxy_render = true;
+ render_context.view_id = context->view_id;
+
+ SeqRenderState state;
+ seq_render_state_init(&state);
+
+ for (timeline_frame = seq->startdisp + seq->startstill;
+ timeline_frame < seq->enddisp - seq->endstill;
+ timeline_frame++) {
+ if (context->size_flags & IMB_PROXY_25) {
+ seq_proxy_build_frame(&render_context, &state, seq, timeline_frame, 25, overwrite);
+ }
+ if (context->size_flags & IMB_PROXY_50) {
+ seq_proxy_build_frame(&render_context, &state, seq, timeline_frame, 50, overwrite);
+ }
+ if (context->size_flags & IMB_PROXY_75) {
+ seq_proxy_build_frame(&render_context, &state, seq, timeline_frame, 75, overwrite);
+ }
+ if (context->size_flags & IMB_PROXY_100) {
+ seq_proxy_build_frame(&render_context, &state, seq, timeline_frame, 100, overwrite);
+ }
+
+ *progress = (float)(timeline_frame - seq->startdisp - seq->startstill) /
+ (seq->enddisp - seq->endstill - seq->startdisp - seq->startstill);
+ *do_update = true;
+
+ if (*stop || G.is_break) {
+ break;
+ }
+ }
+}
+
+void SEQ_proxy_rebuild_finish(SeqIndexBuildContext *context, bool stop)
+{
+ if (context->index_context) {
+ StripAnim *sanim;
+
+ for (sanim = context->seq->anims.first; sanim; sanim = sanim->next) {
+ IMB_close_anim_proxies(sanim->anim);
+ }
+
+ for (sanim = context->orig_seq->anims.first; sanim; sanim = sanim->next) {
+ IMB_close_anim_proxies(sanim->anim);
+ }
+
+ IMB_anim_index_rebuild_finish(context->index_context, stop);
+ }
+
+ seq_free_sequence_recurse(NULL, context->seq, true);
+
+ MEM_freeN(context);
+}
+
+void SEQ_proxy_set(struct Sequence *seq, bool value)
+{
+ if (value) {
+ seq->flag |= SEQ_USE_PROXY;
+ if (seq->strip->proxy == NULL) {
+ seq->strip->proxy = MEM_callocN(sizeof(struct StripProxy), "StripProxy");
+ seq->strip->proxy->quality = 90;
+ seq->strip->proxy->build_tc_flags = SEQ_PROXY_TC_ALL;
+ seq->strip->proxy->build_size_flags = SEQ_PROXY_IMAGE_SIZE_25;
+ }
+ }
+ else {
+ seq->flag &= ~SEQ_USE_PROXY;
+ }
+}
+
+void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir)
+{
+ char dir[FILE_MAX];
+ char fname[FILE_MAXFILE];
+
+ IMB_anim_get_fname(anim, fname, FILE_MAXFILE);
+ BLI_strncpy(dir, base_dir, sizeof(dir));
+ BLI_path_append(dir, sizeof(dir), fname);
+ IMB_anim_set_index_dir(anim, dir);
+}
+
+void free_proxy_seq(Sequence *seq)
+{
+ if (seq->strip && seq->strip->proxy && seq->strip->proxy->anim) {
+ IMB_free_anim(seq->strip->proxy->anim);
+ seq->strip->proxy->anim = NULL;
+ }
+}
diff --git a/source/blender/sequencer/intern/proxy.h b/source/blender/sequencer/intern/proxy.h
new file mode 100644
index 00000000000..a362a318a5a
--- /dev/null
+++ b/source/blender/sequencer/intern/proxy.h
@@ -0,0 +1,45 @@
+/*
+ * 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) 2004 Blender Foundation.
+ * All rights reserved.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup sequencer
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct anim;
+struct ImBuf;
+struct SeqRenderData;
+struct Sequence;
+
+#define PROXY_MAXFILE (2 * FILE_MAXDIR + FILE_MAXFILE)
+struct ImBuf *seq_proxy_fetch(const struct SeqRenderData *context,
+ struct Sequence *seq,
+ int timeline_frame);
+bool seq_proxy_get_custom_file_fname(struct Sequence *seq, char *name, const int view_id);
+void free_proxy_seq(Sequence *seq);
+void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c
new file mode 100644
index 00000000000..008ea1cd3a0
--- /dev/null
+++ b/source/blender/sequencer/intern/render.c
@@ -0,0 +1,2093 @@
+/*
+ * 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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include <time.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_anim_types.h"
+#include "DNA_mask_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_space_types.h"
+
+#include "BLI_linklist.h"
+#include "BLI_listbase.h"
+#include "BLI_path_util.h"
+
+#include "BKE_anim_data.h"
+#include "BKE_animsys.h"
+#include "BKE_fcurve.h"
+#include "BKE_global.h"
+#include "BKE_image.h"
+#include "BKE_layer.h"
+#include "BKE_lib_id.h"
+#include "BKE_main.h"
+#include "BKE_mask.h"
+#include "BKE_movieclip.h"
+#include "BKE_scene.h"
+#include "BKE_sequencer_offscreen.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
+
+#include "IMB_colormanagement.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_metadata.h"
+
+#include "RNA_access.h"
+
+#include "RE_engine.h"
+#include "RE_pipeline.h"
+
+#include "SEQ_sequencer.h"
+
+#include "effects.h"
+#include "image_cache.h"
+#include "multiview.h"
+#include "prefetch.h"
+#include "proxy.h"
+#include "render.h"
+#include "strip_time.h"
+#include "utils.h"
+
+static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
+ SeqRenderState *state,
+ ListBase *seqbasep,
+ float timeline_frame,
+ int chanshown);
+
+static ThreadMutex seq_render_mutex = BLI_MUTEX_INITIALIZER;
+SequencerDrawView sequencer_view3d_fn = NULL; /* NULL in background mode */
+
+/* -------------------------------------------------------------------- */
+/** \name Color-space utility functions
+ * \{ */
+void seq_imbuf_assign_spaces(Scene *scene, ImBuf *ibuf)
+{
+#if 0
+ /* Bute buffer is supposed to be in sequencer working space already. */
+ if (ibuf->rect != NULL) {
+ IMB_colormanagement_assign_rect_colorspace(ibuf, scene->sequencer_colorspace_settings.name);
+ }
+#endif
+ if (ibuf->rect_float != NULL) {
+ IMB_colormanagement_assign_float_colorspace(ibuf, scene->sequencer_colorspace_settings.name);
+ }
+}
+
+void seq_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, bool make_float)
+{
+ /* Early output check: if both buffers are NULL we have nothing to convert. */
+ if (ibuf->rect_float == NULL && ibuf->rect == NULL) {
+ return;
+ }
+ /* Get common conversion settings. */
+ const char *to_colorspace = scene->sequencer_colorspace_settings.name;
+ /* Perform actual conversion logic. */
+ if (ibuf->rect_float == NULL) {
+ /* We are not requested to give float buffer and byte buffer is already
+ * in thee required colorspace. Can skip doing anything here.
+ */
+ const char *from_colorspace = IMB_colormanagement_get_rect_colorspace(ibuf);
+ if (!make_float && STREQ(from_colorspace, to_colorspace)) {
+ return;
+ }
+ if (false) {
+ /* The idea here is to provide as fast playback as possible and
+ * enforcing float buffer here (a) uses more cache memory (b) might
+ * make some other effects slower to apply.
+ *
+ * However, this might also have negative effect by adding weird
+ * artifacts which will then not happen in final render.
+ */
+ IMB_colormanagement_transform_byte_threaded((unsigned char *)ibuf->rect,
+ ibuf->x,
+ ibuf->y,
+ ibuf->channels,
+ from_colorspace,
+ to_colorspace);
+ }
+ else {
+ /* We perform conversion to a float buffer so we don't worry about
+ * precision loss.
+ */
+ imb_addrectfloatImBuf(ibuf);
+ IMB_colormanagement_transform_from_byte_threaded(ibuf->rect_float,
+ (unsigned char *)ibuf->rect,
+ ibuf->x,
+ ibuf->y,
+ ibuf->channels,
+ from_colorspace,
+ to_colorspace);
+ /* We don't need byte buffer anymore. */
+ imb_freerectImBuf(ibuf);
+ }
+ }
+ else {
+ const char *from_colorspace = IMB_colormanagement_get_float_colorspace(ibuf);
+ /* Unknown input color space, can't perform conversion. */
+ if (from_colorspace == NULL || from_colorspace[0] == '\0') {
+ return;
+ }
+ /* We don't want both byte and float buffers around: they'll either run
+ * out of sync or conversion of byte buffer will lose precision in there.
+ */
+ if (ibuf->rect != NULL) {
+ imb_freerectImBuf(ibuf);
+ }
+ IMB_colormanagement_transform_threaded(
+ ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, true);
+ }
+ seq_imbuf_assign_spaces(scene, ibuf);
+}
+
+void SEQ_render_imbuf_from_sequencer_space(Scene *scene, ImBuf *ibuf)
+{
+ const char *from_colorspace = scene->sequencer_colorspace_settings.name;
+ const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(
+ COLOR_ROLE_SCENE_LINEAR);
+
+ if (!ibuf->rect_float) {
+ return;
+ }
+
+ if (to_colorspace && to_colorspace[0] != '\0') {
+ IMB_colormanagement_transform_threaded(
+ ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, true);
+ IMB_colormanagement_assign_float_colorspace(ibuf, to_colorspace);
+ }
+}
+
+void SEQ_render_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4])
+{
+ const char *from_colorspace = scene->sequencer_colorspace_settings.name;
+ const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(
+ COLOR_ROLE_SCENE_LINEAR);
+
+ if (to_colorspace && to_colorspace[0] != '\0') {
+ IMB_colormanagement_transform_v4(pixel, from_colorspace, to_colorspace);
+ }
+ else {
+ /* if no color management enables fallback to legacy conversion */
+ srgb_to_linearrgb_v4(pixel, pixel);
+ }
+}
+
+void SEQ_render_init_colorspace(Sequence *seq)
+{
+ if (seq->strip && seq->strip->stripdata) {
+ char name[FILE_MAX];
+ ImBuf *ibuf;
+
+ BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name);
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
+
+ /* initialize input color space */
+ if (seq->type == SEQ_TYPE_IMAGE) {
+ ibuf = IMB_loadiffname(
+ name, IB_test | IB_alphamode_detect, seq->strip->colorspace_settings.name);
+
+ /* byte images are default to straight alpha, however sequencer
+ * works in premul space, so mark strip to be premultiplied first
+ */
+ seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
+ if (ibuf) {
+ if (ibuf->flags & IB_alphamode_premul) {
+ seq->alpha_mode = IMA_ALPHA_PREMUL;
+ }
+
+ IMB_freeImBuf(ibuf);
+ }
+ }
+ }
+}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Rendering utility functions
+ * \{ */
+void SEQ_render_new_render_data(Main *bmain,
+ struct Depsgraph *depsgraph,
+ Scene *scene,
+ int rectx,
+ int recty,
+ int preview_render_size,
+ int for_render,
+ SeqRenderData *r_context)
+{
+ r_context->bmain = bmain;
+ r_context->depsgraph = depsgraph;
+ r_context->scene = scene;
+ r_context->rectx = rectx;
+ r_context->recty = recty;
+ r_context->preview_render_size = preview_render_size;
+ r_context->for_render = for_render;
+ r_context->motion_blur_samples = 0;
+ r_context->motion_blur_shutter = 0;
+ r_context->skip_cache = false;
+ r_context->is_proxy_render = false;
+ r_context->view_id = 0;
+ r_context->gpu_offscreen = NULL;
+ r_context->task_id = SEQ_TASK_MAIN_RENDER;
+ r_context->is_prefetch_render = false;
+}
+
+void seq_render_state_init(SeqRenderState *state)
+{
+ state->scene_parents = NULL;
+}
+
+StripElem *SEQ_render_give_stripelem(Sequence *seq, int timeline_frame)
+{
+ StripElem *se = seq->strip->stripdata;
+
+ if (seq->type == SEQ_TYPE_IMAGE) {
+ /* only IMAGE strips use the whole array, MOVIE strips use only the first element,
+ * all other strips don't use this...
+ */
+
+ int frame_index = (int)seq_give_frame_index(seq, timeline_frame);
+
+ if (frame_index == -1 || se == NULL) {
+ return NULL;
+ }
+
+ se += frame_index + seq->anim_startofs;
+ }
+ return se;
+}
+
+static int evaluate_seq_frame_gen(Sequence **seq_arr,
+ ListBase *seqbase,
+ int timeline_frame,
+ int chanshown)
+{
+ /* Use arbitrary sized linked list, the size could be over MAXSEQ. */
+ LinkNodePair effect_inputs = {NULL, NULL};
+ int totseq = 0;
+
+ memset(seq_arr, 0, sizeof(Sequence *) * (MAXSEQ + 1));
+
+ LISTBASE_FOREACH (Sequence *, seq, seqbase) {
+ if ((seq->startdisp <= timeline_frame) && (seq->enddisp > timeline_frame)) {
+ if ((seq->type & SEQ_TYPE_EFFECT) && !(seq->flag & SEQ_MUTE)) {
+
+ if (seq->seq1) {
+ BLI_linklist_append_alloca(&effect_inputs, seq->seq1);
+ }
+
+ if (seq->seq2) {
+ BLI_linklist_append_alloca(&effect_inputs, seq->seq2);
+ }
+
+ if (seq->seq3) {
+ BLI_linklist_append_alloca(&effect_inputs, seq->seq3);
+ }
+ }
+
+ seq_arr[seq->machine] = seq;
+ totseq++;
+ }
+ }
+
+ /* Drop strips which are used for effect inputs, we don't want
+ * them to blend into render stack in any other way than effect
+ * string rendering. */
+ for (LinkNode *seq_item = effect_inputs.list; seq_item; seq_item = seq_item->next) {
+ Sequence *seq = seq_item->link;
+ /* It's possible that effect strip would be placed to the same
+ * 'machine' as its inputs. We don't want to clear such strips
+ * from the stack. */
+ if (seq_arr[seq->machine] && seq_arr[seq->machine]->type & SEQ_TYPE_EFFECT) {
+ continue;
+ }
+ /* If we're shown a specified channel, then we want to see the strips
+ * which belongs to this machine. */
+ if (chanshown != 0 && chanshown <= seq->machine) {
+ continue;
+ }
+ seq_arr[seq->machine] = NULL;
+ }
+
+ return totseq;
+}
+
+int SEQ_render_evaluate_frame(Scene *scene, int timeline_frame)
+{
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq_arr[MAXSEQ + 1];
+
+ if (ed == NULL) {
+ return 0;
+ }
+
+ return evaluate_seq_frame_gen(seq_arr, ed->seqbasep, timeline_frame, 0);
+}
+
+static bool video_seq_is_rendered(Sequence *seq)
+{
+ return (seq && !(seq->flag & SEQ_MUTE) && seq->type != SEQ_TYPE_SOUND_RAM);
+}
+
+int seq_get_shown_sequences(ListBase *seqbasep,
+ int timeline_frame,
+ int chanshown,
+ Sequence **seq_arr_out)
+{
+ Sequence *seq_arr[MAXSEQ + 1];
+ int b = chanshown;
+ int cnt = 0;
+
+ if (b > MAXSEQ) {
+ return 0;
+ }
+
+ if (evaluate_seq_frame_gen(seq_arr, seqbasep, timeline_frame, chanshown)) {
+ if (b == 0) {
+ b = MAXSEQ;
+ }
+ for (; b > 0; b--) {
+ if (video_seq_is_rendered(seq_arr[b])) {
+ break;
+ }
+ }
+ }
+
+ chanshown = b;
+
+ for (; b > 0; b--) {
+ if (video_seq_is_rendered(seq_arr[b])) {
+ if (seq_arr[b]->blend_mode == SEQ_BLEND_REPLACE) {
+ break;
+ }
+ }
+ }
+
+ for (; b <= chanshown && b >= 0; b++) {
+ if (video_seq_is_rendered(seq_arr[b])) {
+ seq_arr_out[cnt++] = seq_arr[b];
+ }
+ }
+
+ return cnt;
+}
+
+/* Estimate time spent by the program rendering the strip */
+static clock_t seq_estimate_render_cost_begin(void)
+{
+ return clock();
+}
+
+static float seq_estimate_render_cost_end(Scene *scene, clock_t begin)
+{
+ clock_t end = clock();
+ float time_spent = (float)(end - begin);
+ float time_max = (1.0f / scene->r.frs_sec) * CLOCKS_PER_SEC;
+
+ if (time_max != 0) {
+ return time_spent / time_max;
+ }
+
+ return 1;
+}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Preprocessing and effects
+ * \{ */
+/*
+ * input preprocessing for SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP and SEQ_TYPE_SCENE
+ *
+ * Do all the things you can't really do afterwards using sequence effects
+ * (read: before rescaling to render resolution has been done)
+ *
+ * Order is important!
+ *
+ * - Deinterlace
+ * - Crop and transform in image source coordinate space
+ * - Flip X + Flip Y (could be done afterwards, backward compatibility)
+ * - Promote image to float data (affects pipeline operations afterwards)
+ * - Color balance (is most efficient in the byte -> float
+ * (future: half -> float should also work fine!)
+ * case, if done on load, since we can use lookup tables)
+ * - Premultiply
+ */
+
+static bool sequencer_use_transform(const Sequence *seq)
+{
+ const StripTransform *transform = seq->strip->transform;
+
+ if (transform->xofs != 0 || transform->yofs != 0 || transform->scale_x != 1 ||
+ transform->scale_y != 1 || transform->rotation != 0) {
+ return true;
+ }
+
+ return false;
+}
+
+static bool sequencer_use_crop(const Sequence *seq)
+{
+ const StripCrop *crop = seq->strip->crop;
+ if (crop->left > 0 || crop->right > 0 || crop->top > 0 || crop->bottom > 0) {
+ return true;
+ }
+
+ return false;
+}
+
+static bool BKE_sequencer_input_have_to_preprocess(const SeqRenderData *context,
+ Sequence *seq,
+ float UNUSED(timeline_frame))
+{
+ float mul;
+
+ if (context && context->is_proxy_render) {
+ return false;
+ }
+
+ if ((seq->flag & (SEQ_FILTERY | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_FLOAT)) ||
+ sequencer_use_crop(seq) || sequencer_use_transform(seq)) {
+ return true;
+ }
+
+ mul = seq->mul;
+
+ if (seq->blend_mode == SEQ_BLEND_REPLACE) {
+ mul *= seq->blend_opacity / 100.0f;
+ }
+
+ if (mul != 1.0f) {
+ return true;
+ }
+
+ if (seq->sat != 1.0f) {
+ return true;
+ }
+
+ if (seq->modifiers.first) {
+ return true;
+ }
+
+ return false;
+}
+
+typedef struct ImageTransformThreadInitData {
+ ImBuf *ibuf_source;
+ ImBuf *ibuf_out;
+ StripTransform *transform;
+ float scale_to_fit;
+ float image_scale_factor;
+ bool for_render;
+} ImageTransformThreadInitData;
+
+typedef struct ImageTransformThreadData {
+ ImBuf *ibuf_source;
+ ImBuf *ibuf_out;
+ StripTransform *transform;
+ float scale_to_fit;
+ float image_scale_factor;
+ bool for_render;
+ int start_line;
+ int tot_line;
+} ImageTransformThreadData;
+
+static void sequencer_image_transform_init(void *handle_v,
+ int start_line,
+ int tot_line,
+ void *init_data_v)
+{
+ ImageTransformThreadData *handle = (ImageTransformThreadData *)handle_v;
+ const ImageTransformThreadInitData *init_data = (ImageTransformThreadInitData *)init_data_v;
+
+ handle->ibuf_source = init_data->ibuf_source;
+ handle->ibuf_out = init_data->ibuf_out;
+ handle->transform = init_data->transform;
+ handle->scale_to_fit = init_data->scale_to_fit;
+ handle->image_scale_factor = init_data->image_scale_factor;
+ handle->for_render = init_data->for_render;
+
+ handle->start_line = start_line;
+ handle->tot_line = tot_line;
+}
+
+static void *sequencer_image_transform_do_thread(void *data_v)
+{
+ const ImageTransformThreadData *data = (ImageTransformThreadData *)data_v;
+ const StripTransform *transform = data->transform;
+ const float scale_x = transform->scale_x * data->scale_to_fit;
+ const float scale_y = transform->scale_y * data->scale_to_fit;
+ const float scale_to_fit_offs_x = (data->ibuf_out->x - data->ibuf_source->x) / 2;
+ const float scale_to_fit_offs_y = (data->ibuf_out->y - data->ibuf_source->y) / 2;
+ const float translate_x = transform->xofs * data->image_scale_factor + scale_to_fit_offs_x;
+ const float translate_y = transform->yofs * data->image_scale_factor + scale_to_fit_offs_y;
+ const int width = data->ibuf_out->x;
+ const int height = data->ibuf_out->y;
+ const float pivot[2] = {width / 2 - scale_to_fit_offs_x, height / 2 - scale_to_fit_offs_y};
+ float transform_matrix[3][3];
+ loc_rot_size_to_mat3(transform_matrix,
+ (const float[]){translate_x, translate_y},
+ transform->rotation,
+ (const float[]){scale_x, scale_y});
+ invert_m3(transform_matrix);
+ transform_pivot_set_m3(transform_matrix, pivot);
+
+ for (int yi = data->start_line; yi < data->start_line + data->tot_line; yi++) {
+ for (int xi = 0; xi < width; xi++) {
+ float uv[2] = {xi, yi};
+ mul_v2_m3v2(uv, transform_matrix, uv);
+
+ if (data->for_render) {
+ bilinear_interpolation(data->ibuf_source, data->ibuf_out, uv[0], uv[1], xi, yi);
+ }
+ else {
+ nearest_interpolation(data->ibuf_source, data->ibuf_out, uv[0], uv[1], xi, yi);
+ }
+ }
+ }
+
+ return NULL;
+}
+
+static void multibuf(ImBuf *ibuf, const float fmul)
+{
+ char *rt;
+ float *rt_float;
+
+ int a;
+
+ rt = (char *)ibuf->rect;
+ rt_float = ibuf->rect_float;
+
+ if (rt) {
+ const int imul = (int)(256.0f * fmul);
+ a = ibuf->x * ibuf->y;
+ while (a--) {
+ rt[0] = min_ii((imul * rt[0]) >> 8, 255);
+ rt[1] = min_ii((imul * rt[1]) >> 8, 255);
+ rt[2] = min_ii((imul * rt[2]) >> 8, 255);
+ rt[3] = min_ii((imul * rt[3]) >> 8, 255);
+
+ rt += 4;
+ }
+ }
+ if (rt_float) {
+ a = ibuf->x * ibuf->y;
+ while (a--) {
+ rt_float[0] *= fmul;
+ rt_float[1] *= fmul;
+ rt_float[2] *= fmul;
+ rt_float[3] *= fmul;
+
+ rt_float += 4;
+ }
+ }
+}
+
+static ImBuf *input_preprocess(const SeqRenderData *context,
+ Sequence *seq,
+ float timeline_frame,
+ ImBuf *ibuf)
+{
+ Scene *scene = context->scene;
+ ImBuf *preprocessed_ibuf = NULL;
+
+ /* Deinterlace. */
+ if ((seq->flag & SEQ_FILTERY) && !ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP)) {
+ /* Change original image pointer to avoid another duplication in SEQ_USE_TRANSFORM. */
+ preprocessed_ibuf = IMB_makeSingleUser(ibuf);
+ ibuf = preprocessed_ibuf;
+
+ IMB_filtery(preprocessed_ibuf);
+ }
+
+ /* Calculate scale factor, so image fits in preview area with original aspect ratio. */
+ const float scale_to_fit_factor = MIN2((float)context->rectx / (float)ibuf->x,
+ (float)context->recty / (float)ibuf->y);
+
+ /* Get scale factor if preview resolution doesn't match project resolution. */
+ float preview_scale_factor;
+ if (context->preview_render_size == SEQ_RENDER_SIZE_SCENE) {
+ preview_scale_factor = (float)scene->r.size / 100;
+ }
+ else {
+ preview_scale_factor = SEQ_rendersize_to_scale_factor(context->preview_render_size);
+ }
+
+ if (sequencer_use_crop(seq)) {
+ /* Change original image pointer to avoid another duplication in SEQ_USE_TRANSFORM. */
+ preprocessed_ibuf = IMB_makeSingleUser(ibuf);
+ ibuf = preprocessed_ibuf;
+
+ const int width = ibuf->x;
+ const int height = ibuf->y;
+ const StripCrop *c = seq->strip->crop;
+
+ const int left = c->left / scale_to_fit_factor * preview_scale_factor;
+ const int right = c->right / scale_to_fit_factor * preview_scale_factor;
+ const int top = c->top / scale_to_fit_factor * preview_scale_factor;
+ const int bottom = c->bottom / scale_to_fit_factor * preview_scale_factor;
+ const float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+
+ /* Left. */
+ IMB_rectfill_area_replace(preprocessed_ibuf, col, 0, 0, left, height);
+ /* Bottom. */
+ IMB_rectfill_area_replace(preprocessed_ibuf, col, left, 0, width, bottom);
+ /* Right. */
+ IMB_rectfill_area_replace(preprocessed_ibuf, col, width - right, bottom, width, height);
+ /* Top. */
+ IMB_rectfill_area_replace(preprocessed_ibuf, col, left, height - top, width - right, height);
+ }
+
+ if (sequencer_use_transform(seq) || context->rectx != ibuf->x || context->recty != ibuf->y) {
+ const int x = context->rectx;
+ const int y = context->recty;
+ preprocessed_ibuf = IMB_allocImBuf(x, y, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
+
+ ImageTransformThreadInitData init_data = {NULL};
+ init_data.ibuf_source = ibuf;
+ init_data.ibuf_out = preprocessed_ibuf;
+ init_data.transform = seq->strip->transform;
+ init_data.scale_to_fit = scale_to_fit_factor;
+ init_data.image_scale_factor = preview_scale_factor;
+ init_data.for_render = context->for_render;
+ IMB_processor_apply_threaded(context->recty,
+ sizeof(ImageTransformThreadData),
+ &init_data,
+ sequencer_image_transform_init,
+ sequencer_image_transform_do_thread);
+ seq_imbuf_assign_spaces(scene, preprocessed_ibuf);
+ IMB_metadata_copy(preprocessed_ibuf, ibuf);
+ IMB_freeImBuf(ibuf);
+ }
+
+ /* Duplicate ibuf if we still have original. */
+ if (preprocessed_ibuf == NULL) {
+ preprocessed_ibuf = IMB_makeSingleUser(ibuf);
+ }
+
+ if (seq->flag & SEQ_FLIPX) {
+ IMB_flipx(preprocessed_ibuf);
+ }
+
+ if (seq->flag & SEQ_FLIPY) {
+ IMB_flipy(preprocessed_ibuf);
+ }
+
+ if (seq->sat != 1.0f) {
+ IMB_saturation(preprocessed_ibuf, seq->sat);
+ }
+
+ if (seq->flag & SEQ_MAKE_FLOAT) {
+ if (!preprocessed_ibuf->rect_float) {
+ seq_imbuf_to_sequencer_space(scene, preprocessed_ibuf, true);
+ }
+
+ if (preprocessed_ibuf->rect) {
+ imb_freerectImBuf(preprocessed_ibuf);
+ }
+ }
+
+ float mul = seq->mul;
+ if (seq->blend_mode == SEQ_BLEND_REPLACE) {
+ mul *= seq->blend_opacity / 100.0f;
+ }
+
+ if (mul != 1.0f) {
+ multibuf(preprocessed_ibuf, mul);
+ }
+
+ if (seq->modifiers.first) {
+ ImBuf *ibuf_new = BKE_sequence_modifier_apply_stack(
+ context, seq, preprocessed_ibuf, timeline_frame);
+
+ if (ibuf_new != preprocessed_ibuf) {
+ IMB_metadata_copy(ibuf_new, preprocessed_ibuf);
+ IMB_freeImBuf(preprocessed_ibuf);
+ preprocessed_ibuf = ibuf_new;
+ }
+ }
+
+ return preprocessed_ibuf;
+}
+
+static ImBuf *seq_render_preprocess_ibuf(const SeqRenderData *context,
+ Sequence *seq,
+ ImBuf *ibuf,
+ float timeline_frame,
+ clock_t begin,
+ bool use_preprocess,
+ const bool is_proxy_image)
+{
+ if (context->is_proxy_render == false &&
+ (ibuf->x != context->rectx || ibuf->y != context->recty)) {
+ use_preprocess = true;
+ }
+
+ if (use_preprocess) {
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+
+ /* Proxies are not stored in cache. */
+ if (!is_proxy_image) {
+ BKE_sequencer_cache_put(
+ context, seq, timeline_frame, SEQ_CACHE_STORE_RAW, ibuf, cost, false);
+ }
+
+ /* Reset timer so we can get partial render time. */
+ begin = seq_estimate_render_cost_begin();
+ ibuf = input_preprocess(context, seq, timeline_frame, ibuf);
+ }
+
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put(
+ context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED, ibuf, cost, false);
+ return ibuf;
+}
+
+typedef struct RenderEffectInitData {
+ struct SeqEffectHandle *sh;
+ const SeqRenderData *context;
+ Sequence *seq;
+ float timeline_frame, facf0, facf1;
+ ImBuf *ibuf1, *ibuf2, *ibuf3;
+
+ ImBuf *out;
+} RenderEffectInitData;
+
+typedef struct RenderEffectThread {
+ struct SeqEffectHandle *sh;
+ const SeqRenderData *context;
+ Sequence *seq;
+ float timeline_frame, facf0, facf1;
+ ImBuf *ibuf1, *ibuf2, *ibuf3;
+
+ ImBuf *out;
+ int start_line, tot_line;
+} RenderEffectThread;
+
+static void render_effect_execute_init_handle(void *handle_v,
+ int start_line,
+ int tot_line,
+ void *init_data_v)
+{
+ RenderEffectThread *handle = (RenderEffectThread *)handle_v;
+ RenderEffectInitData *init_data = (RenderEffectInitData *)init_data_v;
+
+ handle->sh = init_data->sh;
+ handle->context = init_data->context;
+ handle->seq = init_data->seq;
+ handle->timeline_frame = init_data->timeline_frame;
+ handle->facf0 = init_data->facf0;
+ handle->facf1 = init_data->facf1;
+ handle->ibuf1 = init_data->ibuf1;
+ handle->ibuf2 = init_data->ibuf2;
+ handle->ibuf3 = init_data->ibuf3;
+ handle->out = init_data->out;
+
+ handle->start_line = start_line;
+ handle->tot_line = tot_line;
+}
+
+static void *render_effect_execute_do_thread(void *thread_data_v)
+{
+ RenderEffectThread *thread_data = (RenderEffectThread *)thread_data_v;
+
+ thread_data->sh->execute_slice(thread_data->context,
+ thread_data->seq,
+ thread_data->timeline_frame,
+ thread_data->facf0,
+ thread_data->facf1,
+ thread_data->ibuf1,
+ thread_data->ibuf2,
+ thread_data->ibuf3,
+ thread_data->start_line,
+ thread_data->tot_line,
+ thread_data->out);
+
+ return NULL;
+}
+
+ImBuf *seq_render_effect_execute_threaded(struct SeqEffectHandle *sh,
+ const SeqRenderData *context,
+ Sequence *seq,
+ float timeline_frame,
+ float facf0,
+ float facf1,
+ ImBuf *ibuf1,
+ ImBuf *ibuf2,
+ ImBuf *ibuf3)
+{
+ RenderEffectInitData init_data;
+ ImBuf *out = sh->init_execution(context, ibuf1, ibuf2, ibuf3);
+
+ init_data.sh = sh;
+ init_data.context = context;
+ init_data.seq = seq;
+ init_data.timeline_frame = timeline_frame;
+ init_data.facf0 = facf0;
+ init_data.facf1 = facf1;
+ init_data.ibuf1 = ibuf1;
+ init_data.ibuf2 = ibuf2;
+ init_data.ibuf3 = ibuf3;
+ init_data.out = out;
+
+ IMB_processor_apply_threaded(out->y,
+ sizeof(RenderEffectThread),
+ &init_data,
+ render_effect_execute_init_handle,
+ render_effect_execute_do_thread);
+
+ return out;
+}
+
+static ImBuf *seq_render_effect_strip_impl(const SeqRenderData *context,
+ SeqRenderState *state,
+ Sequence *seq,
+ float timeline_frame)
+{
+ Scene *scene = context->scene;
+ float fac, facf;
+ int early_out;
+ int i;
+ struct SeqEffectHandle sh = BKE_sequence_get_effect(seq);
+ FCurve *fcu = NULL;
+ ImBuf *ibuf[3];
+ Sequence *input[3];
+ ImBuf *out = NULL;
+
+ ibuf[0] = ibuf[1] = ibuf[2] = NULL;
+
+ input[0] = seq->seq1;
+ input[1] = seq->seq2;
+ input[2] = seq->seq3;
+
+ if (!sh.execute && !(sh.execute_slice && sh.init_execution)) {
+ /* effect not supported in this version... */
+ out = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
+ return out;
+ }
+
+ if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) {
+ sh.get_default_fac(seq, timeline_frame, &fac, &facf);
+ facf = fac;
+ }
+ else {
+ fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "effect_fader", 0, NULL);
+ if (fcu) {
+ fac = facf = evaluate_fcurve(fcu, timeline_frame);
+ }
+ else {
+ fac = facf = seq->effect_fader;
+ }
+ }
+
+ early_out = sh.early_out(seq, fac, facf);
+
+ switch (early_out) {
+ case EARLY_NO_INPUT:
+ out = sh.execute(context, seq, timeline_frame, fac, facf, NULL, NULL, NULL);
+ break;
+ case EARLY_DO_EFFECT:
+ for (i = 0; i < 3; i++) {
+ /* Speed effect requires time remapping of `timeline_frame` for input(s). */
+ if (input[0] && seq->type == SEQ_TYPE_SPEED) {
+ float target_frame = BKE_sequencer_speed_effect_target_frame_get(
+ context, seq, timeline_frame, i);
+ ibuf[i] = seq_render_strip(context, state, input[0], target_frame);
+ }
+ else { /* Other effects. */
+ if (input[i]) {
+ ibuf[i] = seq_render_strip(context, state, input[i], timeline_frame);
+ }
+ }
+ }
+
+ if (ibuf[0] && (ibuf[1] || BKE_sequence_effect_get_num_inputs(seq->type) == 1)) {
+ if (sh.multithreaded) {
+ out = seq_render_effect_execute_threaded(
+ &sh, context, seq, timeline_frame, fac, facf, ibuf[0], ibuf[1], ibuf[2]);
+ }
+ else {
+ out = sh.execute(context, seq, timeline_frame, fac, facf, ibuf[0], ibuf[1], ibuf[2]);
+ }
+ }
+ break;
+ case EARLY_USE_INPUT_1:
+ if (input[0]) {
+ out = seq_render_strip(context, state, input[0], timeline_frame);
+ }
+ break;
+ case EARLY_USE_INPUT_2:
+ if (input[1]) {
+ out = seq_render_strip(context, state, input[1], timeline_frame);
+ }
+ break;
+ }
+
+ for (i = 0; i < 3; i++) {
+ IMB_freeImBuf(ibuf[i]);
+ }
+
+ if (out == NULL) {
+ out = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
+ }
+
+ return out;
+}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Individual strip rendering functions
+ * \{ */
+/**
+ * Render individual view for multi-view or single (default view) for mono-view.
+ */
+static ImBuf *seq_render_image_strip_view(const SeqRenderData *context,
+ Sequence *seq,
+ char *name,
+ char *prefix,
+ const char *ext,
+ int view_id)
+{
+
+ ImBuf *ibuf = NULL;
+
+ int flag = IB_rect | IB_metadata;
+ if (seq->alpha_mode == SEQ_ALPHA_PREMUL) {
+ flag |= IB_alphamode_premul;
+ }
+
+ if (prefix[0] == '\0') {
+ ibuf = IMB_loadiffname(name, flag, seq->strip->colorspace_settings.name);
+ }
+ else {
+ char str[FILE_MAX];
+ BKE_scene_multiview_view_prefix_get(context->scene, name, prefix, &ext);
+ seq_multiview_name(context->scene, view_id, prefix, ext, str, FILE_MAX);
+ ibuf = IMB_loadiffname(str, flag, seq->strip->colorspace_settings.name);
+ }
+
+ if (ibuf == NULL) {
+ return NULL;
+ }
+
+ /* We don't need both (speed reasons)! */
+ if (ibuf->rect_float != NULL && ibuf->rect != NULL) {
+ imb_freerectImBuf(ibuf);
+ }
+
+ /* All sequencer color is done in SRGB space, linear gives odd cross-fades. */
+ seq_imbuf_to_sequencer_space(context->scene, ibuf, false);
+
+ return ibuf;
+}
+
+static bool seq_image_strip_is_multiview_render(
+ Scene *scene, Sequence *seq, int totfiles, char *name, char *r_prefix, const char *r_ext)
+{
+ if (totfiles > 1) {
+ BKE_scene_multiview_view_prefix_get(scene, name, r_prefix, &r_ext);
+ if (r_prefix[0] == '\0') {
+ return false;
+ }
+ }
+ else {
+ r_prefix[0] = '\0';
+ }
+
+ return (seq->flag & SEQ_USE_VIEWS) != 0 && (scene->r.scemode & R_MULTIVIEW) != 0;
+}
+
+static ImBuf *seq_render_image_strip(const SeqRenderData *context,
+ Sequence *seq,
+ float UNUSED(frame_index),
+ float timeline_frame,
+ bool *r_is_proxy_image)
+{
+ char name[FILE_MAX];
+ const char *ext = NULL;
+ char prefix[FILE_MAX];
+ ImBuf *ibuf = NULL;
+
+ StripElem *s_elem = SEQ_render_give_stripelem(seq, timeline_frame);
+ if (s_elem == NULL) {
+ return NULL;
+ }
+
+ BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name);
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
+
+ /* Try to get a proxy image. */
+ ibuf = seq_proxy_fetch(context, seq, timeline_frame);
+ if (ibuf != NULL) {
+ s_elem->orig_width = ibuf->x;
+ s_elem->orig_height = ibuf->y;
+ *r_is_proxy_image = true;
+ return ibuf;
+ }
+
+ /* Proxy not found, render original. */
+ const int totfiles = seq_num_files(context->scene, seq->views_format, true);
+ bool is_multiview_render = seq_image_strip_is_multiview_render(
+ context->scene, seq, totfiles, name, prefix, ext);
+
+ if (is_multiview_render) {
+ int totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
+ ImBuf **ibufs_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
+
+ for (int view_id = 0; view_id < totfiles; view_id++) {
+ ibufs_arr[view_id] = seq_render_image_strip_view(context, seq, name, prefix, ext, view_id);
+ }
+
+ if (ibufs_arr[0] == NULL) {
+ return NULL;
+ }
+
+ if (seq->views_format == R_IMF_VIEWS_STEREO_3D) {
+ IMB_ImBufFromStereo3d(seq->stereo3d_format, ibufs_arr[0], &ibufs_arr[0], &ibufs_arr[1]);
+ }
+
+ for (int view_id = 0; view_id < totviews; view_id++) {
+ SeqRenderData localcontext = *context;
+ localcontext.view_id = view_id;
+
+ if (view_id != context->view_id) {
+ ibufs_arr[view_id] = seq_render_preprocess_ibuf(
+ &localcontext, seq, ibufs_arr[view_id], timeline_frame, clock(), true, false);
+ }
+ }
+
+ /* Return the original requested ImBuf. */
+ ibuf = ibufs_arr[context->view_id];
+
+ /* Remove the others (decrease their refcount). */
+ for (int view_id = 0; view_id < totviews; view_id++) {
+ if (ibufs_arr[view_id] != ibuf) {
+ IMB_freeImBuf(ibufs_arr[view_id]);
+ }
+ }
+
+ MEM_freeN(ibufs_arr);
+ }
+ else {
+ ibuf = seq_render_image_strip_view(context, seq, name, prefix, ext, context->view_id);
+ }
+
+ if (ibuf == NULL) {
+ return NULL;
+ }
+
+ s_elem->orig_width = ibuf->x;
+ s_elem->orig_height = ibuf->y;
+
+ return ibuf;
+}
+
+static ImBuf *seq_render_movie_strip_custom_file_proxy(const SeqRenderData *context,
+ Sequence *seq,
+ int timeline_frame)
+{
+ char name[PROXY_MAXFILE];
+ StripProxy *proxy = seq->strip->proxy;
+
+ if (proxy->anim == NULL) {
+ if (seq_proxy_get_custom_file_fname(seq, name, context->view_id)) {
+ proxy->anim = openanim(name, IB_rect, 0, seq->strip->colorspace_settings.name);
+ }
+ if (proxy->anim == NULL) {
+ return NULL;
+ }
+ }
+
+ int frameno = (int)seq_give_frame_index(seq, timeline_frame) + seq->anim_startofs;
+ return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE);
+}
+
+/**
+ * Render individual view for multi-view or single (default view) for mono-view.
+ */
+static ImBuf *seq_render_movie_strip_view(const SeqRenderData *context,
+ Sequence *seq,
+ float frame_index,
+ float timeline_frame,
+ StripAnim *sanim,
+ bool *r_is_proxy_image)
+{
+ ImBuf *ibuf = NULL;
+ IMB_Proxy_Size psize = SEQ_rendersize_to_proxysize(context->preview_render_size);
+
+ IMB_anim_set_preseek(sanim->anim, seq->anim_preseek);
+
+ if (SEQ_can_use_proxy(seq, psize)) {
+ /* Try to get a proxy image.
+ * Movie proxies are handled by ImBuf module with exception of `custom file` setting. */
+ if (context->scene->ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE &&
+ seq->strip->proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) {
+ ibuf = seq_render_movie_strip_custom_file_proxy(context, seq, timeline_frame);
+ }
+ else {
+ ibuf = IMB_anim_absolute(sanim->anim,
+ frame_index + seq->anim_startofs,
+ seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN,
+ psize);
+ }
+
+ if (ibuf != NULL) {
+ *r_is_proxy_image = true;
+ }
+ }
+
+ /* Fetching for requested proxy size failed, try fetching the original instead. */
+ if (ibuf == NULL) {
+ ibuf = IMB_anim_absolute(sanim->anim,
+ frame_index + seq->anim_startofs,
+ seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN,
+ IMB_PROXY_NONE);
+ }
+ if (ibuf == NULL) {
+ return NULL;
+ }
+
+ seq_imbuf_to_sequencer_space(context->scene, ibuf, false);
+
+ /* We don't need both (speed reasons)! */
+ if (ibuf->rect_float != NULL && ibuf->rect != NULL) {
+ imb_freerectImBuf(ibuf);
+ }
+
+ return ibuf;
+}
+
+static ImBuf *seq_render_movie_strip(const SeqRenderData *context,
+ Sequence *seq,
+ float frame_index,
+ float timeline_frame,
+ bool *r_is_proxy_image)
+{
+ /* Load all the videos. */
+ seq_open_anim_file(context->scene, seq, false);
+
+ ImBuf *ibuf = NULL;
+ StripAnim *sanim = seq->anims.first;
+ const int totfiles = seq_num_files(context->scene, seq->views_format, true);
+ bool is_multiview_render = (seq->flag & SEQ_USE_VIEWS) != 0 &&
+ (context->scene->r.scemode & R_MULTIVIEW) != 0 &&
+ BLI_listbase_count_at_most(&seq->anims, totfiles + 1) == totfiles;
+
+ if (is_multiview_render) {
+ ImBuf **ibuf_arr;
+ int totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
+ ibuf_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
+ int ibuf_view_id;
+
+ for (ibuf_view_id = 0, sanim = seq->anims.first; sanim; sanim = sanim->next, ibuf_view_id++) {
+ if (sanim->anim) {
+ ibuf_arr[ibuf_view_id] = seq_render_movie_strip_view(
+ context, seq, frame_index, timeline_frame, sanim, r_is_proxy_image);
+ }
+ }
+
+ if (seq->views_format == R_IMF_VIEWS_STEREO_3D) {
+ if (ibuf_arr[0] == NULL) {
+ /* Probably proxy hasn't been created yet. */
+ MEM_freeN(ibuf_arr);
+ return NULL;
+ }
+
+ IMB_ImBufFromStereo3d(seq->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
+ }
+
+ for (int view_id = 0; view_id < totviews; view_id++) {
+ SeqRenderData localcontext = *context;
+ localcontext.view_id = view_id;
+
+ if (view_id != context->view_id) {
+ ibuf_arr[view_id] = seq_render_preprocess_ibuf(
+ &localcontext, seq, ibuf_arr[view_id], timeline_frame, clock(), true, false);
+ }
+ }
+
+ /* Return the original requested ImBuf. */
+ ibuf = ibuf_arr[context->view_id];
+
+ /* Remove the others (decrease their refcount). */
+ for (int view_id = 0; view_id < totviews; view_id++) {
+ if (ibuf_arr[view_id] != ibuf) {
+ IMB_freeImBuf(ibuf_arr[view_id]);
+ }
+ }
+
+ MEM_freeN(ibuf_arr);
+ }
+ else {
+ ibuf = seq_render_movie_strip_view(
+ context, seq, frame_index, timeline_frame, sanim, r_is_proxy_image);
+ }
+
+ if (ibuf == NULL) {
+ return NULL;
+ }
+
+ seq->strip->stripdata->orig_width = ibuf->x;
+ seq->strip->stripdata->orig_height = ibuf->y;
+
+ return ibuf;
+}
+
+static ImBuf *seq_get_movieclip_ibuf(Sequence *seq, MovieClipUser user)
+{
+ ImBuf *ibuf = NULL;
+ float tloc[2], tscale, tangle;
+ if (seq->clip_flag & SEQ_MOVIECLIP_RENDER_STABILIZED) {
+ ibuf = BKE_movieclip_get_stable_ibuf(seq->clip, &user, tloc, &tscale, &tangle, 0);
+ }
+ else {
+ ibuf = BKE_movieclip_get_ibuf_flag(seq->clip, &user, seq->clip->flag, MOVIECLIP_CACHE_SKIP);
+ }
+ return ibuf;
+}
+
+static ImBuf *seq_render_movieclip_strip(const SeqRenderData *context,
+ Sequence *seq,
+ float frame_index,
+ bool *r_is_proxy_image)
+{
+ ImBuf *ibuf = NULL;
+ MovieClipUser user;
+ IMB_Proxy_Size psize = SEQ_rendersize_to_proxysize(context->preview_render_size);
+
+ if (!seq->clip) {
+ return NULL;
+ }
+
+ memset(&user, 0, sizeof(MovieClipUser));
+
+ BKE_movieclip_user_set_frame(&user, frame_index + seq->anim_startofs + seq->clip->start_frame);
+
+ user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
+ switch (psize) {
+ case IMB_PROXY_NONE:
+ user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
+ break;
+ case IMB_PROXY_100:
+ user.render_size = MCLIP_PROXY_RENDER_SIZE_100;
+ break;
+ case IMB_PROXY_75:
+ user.render_size = MCLIP_PROXY_RENDER_SIZE_75;
+ break;
+ case IMB_PROXY_50:
+ user.render_size = MCLIP_PROXY_RENDER_SIZE_50;
+ break;
+ case IMB_PROXY_25:
+ user.render_size = MCLIP_PROXY_RENDER_SIZE_25;
+ break;
+ }
+
+ if (seq->clip_flag & SEQ_MOVIECLIP_RENDER_UNDISTORTED) {
+ user.render_flag |= MCLIP_PROXY_RENDER_UNDISTORT;
+ }
+
+ /* Try to get a proxy image. */
+ ibuf = seq_get_movieclip_ibuf(seq, user);
+
+ if (ibuf != NULL && psize != IMB_PROXY_NONE) {
+ *r_is_proxy_image = true;
+ }
+
+ /* If proxy is not found, grab full-size frame. */
+ if (ibuf == NULL) {
+ user.render_flag |= MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER;
+ ibuf = seq_get_movieclip_ibuf(seq, user);
+ }
+
+ return ibuf;
+}
+
+ImBuf *seq_render_mask(const SeqRenderData *context,
+ Mask *mask,
+ float frame_index,
+ bool make_float)
+{
+ /* TODO - add option to rasterize to alpha imbuf? */
+ ImBuf *ibuf = NULL;
+ float *maskbuf;
+ int i;
+
+ if (!mask) {
+ return NULL;
+ }
+
+ AnimData *adt;
+ Mask *mask_temp;
+ MaskRasterHandle *mr_handle;
+
+ 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 + frame_index, true);
+
+ /* anim-data */
+ adt = BKE_animdata_from_id(&mask->id);
+ const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
+ context->depsgraph, mask->sfra + frame_index);
+ BKE_animsys_evaluate_animdata(&mask_temp->id, adt, &anim_eval_context, ADT_RECALC_ANIM, false);
+
+ maskbuf = MEM_mallocN(sizeof(float) * context->rectx * context->recty, __func__);
+
+ mr_handle = BKE_maskrasterize_handle_new();
+
+ BKE_maskrasterize_handle_init(
+ mr_handle, mask_temp, context->rectx, context->recty, true, true, true);
+
+ BKE_id_free(NULL, &mask_temp->id);
+
+ BKE_maskrasterize_buffer(mr_handle, context->rectx, context->recty, maskbuf);
+
+ BKE_maskrasterize_handle_free(mr_handle);
+
+ if (make_float) {
+ /* pixels */
+ const float *fp_src;
+ float *fp_dst;
+
+ ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rectfloat);
+
+ fp_src = maskbuf;
+ fp_dst = ibuf->rect_float;
+ i = context->rectx * context->recty;
+ while (--i) {
+ fp_dst[0] = fp_dst[1] = fp_dst[2] = *fp_src;
+ fp_dst[3] = 1.0f;
+
+ fp_src += 1;
+ fp_dst += 4;
+ }
+ }
+ else {
+ /* pixels */
+ const float *fp_src;
+ unsigned char *ub_dst;
+
+ ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
+
+ fp_src = maskbuf;
+ ub_dst = (unsigned char *)ibuf->rect;
+ i = context->rectx * context->recty;
+ while (--i) {
+ ub_dst[0] = ub_dst[1] = ub_dst[2] = (unsigned char)(*fp_src * 255.0f); /* already clamped */
+ ub_dst[3] = 255;
+
+ fp_src += 1;
+ ub_dst += 4;
+ }
+ }
+
+ MEM_freeN(maskbuf);
+
+ return ibuf;
+}
+
+static ImBuf *seq_render_mask_strip(const SeqRenderData *context, Sequence *seq, float frame_index)
+{
+ bool make_float = (seq->flag & SEQ_MAKE_FLOAT) != 0;
+
+ return seq_render_mask(context, seq->mask, frame_index, make_float);
+}
+
+static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
+ Sequence *seq,
+ float frame_index,
+ float timeline_frame)
+{
+ ImBuf *ibuf = NULL;
+ double frame;
+ Object *camera;
+
+ struct {
+ int scemode;
+ int timeline_frame;
+ float subframe;
+
+#ifdef DURIAN_CAMERA_SWITCH
+ int mode;
+#endif
+ } orig_data;
+
+ /* Old info:
+ * Hack! This function can be called from do_render_seq(), in that case
+ * the seq->scene can already have a Render initialized with same name,
+ * so we have to use a default name. (compositor uses scene name to
+ * find render).
+ * However, when called from within the UI (image preview in sequencer)
+ * we do want to use scene Render, that way the render result is defined
+ * for display in render/imagewindow
+ *
+ * Hmm, don't see, why we can't do that all the time,
+ * and since G.is_rendering is uhm, gone... (Peter)
+ */
+
+ /* New info:
+ * Using the same name for the renders works just fine as the do_render_seq()
+ * render is not used while the scene strips are rendered.
+ *
+ * However rendering from UI (through sequencer_preview_area_draw) can crash in
+ * very many cases since other renders (material preview, an actual render etc.)
+ * can be started while this sequence preview render is running. The only proper
+ * solution is to make the sequencer preview render a proper job, which can be
+ * stopped when needed. This would also give a nice progress bar for the preview
+ * space so that users know there's something happening.
+ *
+ * As a result the active scene now only uses OpenGL rendering for the sequencer
+ * preview. This is far from nice, but is the only way to prevent crashes at this
+ * time.
+ *
+ * -jahka
+ */
+
+ const bool is_rendering = G.is_rendering;
+ const bool is_background = G.background;
+ const bool do_seq_gl = is_rendering ? 0 : (context->scene->r.seq_prev_type) != OB_RENDER;
+ bool have_comp = false;
+ bool use_gpencil = true;
+ /* do we need to re-evaluate the frame after rendering? */
+ bool is_frame_update = false;
+ Scene *scene;
+ int is_thread_main = BLI_thread_is_main();
+
+ /* don't refer to seq->scene above this point!, it can be NULL */
+ if (seq->scene == NULL) {
+ return NULL;
+ }
+
+ /* Prevent rendering scene recursively. */
+ if (seq->scene == context->scene) {
+ return NULL;
+ }
+
+ scene = seq->scene;
+ frame = (double)scene->r.sfra + (double)frame_index + (double)seq->anim_startofs;
+
+#if 0 /* UNUSED */
+ have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first);
+#endif
+ have_comp = (scene->r.scemode & R_DOCOMP) && scene->use_nodes && scene->nodetree;
+
+ /* Get view layer for the strip. */
+ ViewLayer *view_layer = BKE_view_layer_default_render(scene);
+ /* Depsgraph will be NULL when doing rendering. */
+ Depsgraph *depsgraph = NULL;
+
+ orig_data.scemode = scene->r.scemode;
+ orig_data.timeline_frame = scene->r.cfra;
+ orig_data.subframe = scene->r.subframe;
+#ifdef DURIAN_CAMERA_SWITCH
+ orig_data.mode = scene->r.mode;
+#endif
+
+ BKE_scene_frame_set(scene, frame);
+
+ if (seq->scene_camera) {
+ camera = seq->scene_camera;
+ }
+ else {
+ BKE_scene_camera_switch_update(scene);
+ camera = scene->camera;
+ }
+
+ if (have_comp == false && camera == NULL) {
+ goto finally;
+ }
+
+ if (seq->flag & SEQ_SCENE_NO_GPENCIL) {
+ use_gpencil = false;
+ }
+
+ /* prevent eternal loop */
+ scene->r.scemode &= ~R_DOSEQ;
+
+#ifdef DURIAN_CAMERA_SWITCH
+ /* stooping to new low's in hackyness :( */
+ scene->r.mode |= R_NO_CAMERA_SWITCH;
+#endif
+
+ is_frame_update = (orig_data.timeline_frame != scene->r.cfra) ||
+ (orig_data.subframe != scene->r.subframe);
+
+ if ((sequencer_view3d_fn && do_seq_gl && camera) && is_thread_main) {
+ char err_out[256] = "unknown";
+ const int width = (scene->r.xsch * scene->r.size) / 100;
+ const int height = (scene->r.ysch * scene->r.size) / 100;
+ const char *viewname = BKE_scene_multiview_render_view_name_get(&scene->r, context->view_id);
+
+ unsigned int draw_flags = V3D_OFSDRAW_NONE;
+ draw_flags |= (use_gpencil) ? V3D_OFSDRAW_SHOW_ANNOTATION : 0;
+ draw_flags |= (context->scene->r.seq_flag & R_SEQ_OVERRIDE_SCENE_SETTINGS) ?
+ V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS :
+ 0;
+
+ /* for old scene this can be uninitialized,
+ * should probably be added to do_versions at some point if the functionality stays */
+ if (context->scene->r.seq_prev_type == 0) {
+ context->scene->r.seq_prev_type = 3 /* == OB_SOLID */;
+ }
+
+ /* opengl offscreen render */
+ depsgraph = BKE_scene_ensure_depsgraph(context->bmain, scene, view_layer);
+ BKE_scene_graph_update_for_newframe(depsgraph);
+ ibuf = sequencer_view3d_fn(
+ /* set for OpenGL render (NULL when scrubbing) */
+ depsgraph,
+ scene,
+ &context->scene->display.shading,
+ context->scene->r.seq_prev_type,
+ camera,
+ width,
+ height,
+ IB_rect,
+ draw_flags,
+ scene->r.alphamode,
+ viewname,
+ context->gpu_offscreen,
+ err_out);
+ if (ibuf == NULL) {
+ fprintf(stderr, "seq_render_scene_strip failed to get opengl buffer: %s\n", err_out);
+ }
+ }
+ else {
+ Render *re = RE_GetSceneRender(scene);
+ const int totviews = BKE_scene_multiview_num_views_get(&scene->r);
+ ImBuf **ibufs_arr;
+
+ ibufs_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
+
+ /* XXX: this if can be removed when sequence preview rendering uses the job system
+ *
+ * disable rendered preview for sequencer while rendering -- it's very much possible
+ * that preview render will went into conflict with final render
+ *
+ * When rendering from command line renderer is called from main thread, in this
+ * case it's always safe to render scene here
+ */
+ if (!is_thread_main || is_rendering == false || is_background || context->for_render) {
+ if (re == NULL) {
+ re = RE_NewSceneRender(scene);
+ }
+
+ RE_RenderFrame(
+ re, context->bmain, scene, have_comp ? NULL : view_layer, camera, frame, false);
+
+ /* restore previous state after it was toggled on & off by RE_RenderFrame */
+ G.is_rendering = is_rendering;
+ }
+
+ for (int view_id = 0; view_id < totviews; view_id++) {
+ SeqRenderData localcontext = *context;
+ RenderResult rres;
+
+ localcontext.view_id = view_id;
+
+ RE_AcquireResultImage(re, &rres, view_id);
+
+ if (rres.rectf) {
+ ibufs_arr[view_id] = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat);
+ memcpy(ibufs_arr[view_id]->rect_float,
+ rres.rectf,
+ sizeof(float[4]) * rres.rectx * rres.recty);
+
+ if (rres.rectz) {
+ addzbuffloatImBuf(ibufs_arr[view_id]);
+ memcpy(
+ ibufs_arr[view_id]->zbuf_float, rres.rectz, sizeof(float) * rres.rectx * rres.recty);
+ }
+
+ /* float buffers in the sequencer are not linear */
+ seq_imbuf_to_sequencer_space(context->scene, ibufs_arr[view_id], false);
+ }
+ else if (rres.rect32) {
+ ibufs_arr[view_id] = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect);
+ memcpy(ibufs_arr[view_id]->rect, rres.rect32, 4 * rres.rectx * rres.recty);
+ }
+
+ if (view_id != context->view_id) {
+ BKE_sequencer_cache_put(
+ &localcontext, seq, timeline_frame, SEQ_CACHE_STORE_RAW, ibufs_arr[view_id], 0, false);
+ }
+
+ RE_ReleaseResultImage(re);
+ }
+
+ /* return the original requested ImBuf */
+ ibuf = ibufs_arr[context->view_id];
+
+ /* "remove" the others (decrease their refcount) */
+ for (int view_id = 0; view_id < totviews; view_id++) {
+ if (ibufs_arr[view_id] != ibuf) {
+ IMB_freeImBuf(ibufs_arr[view_id]);
+ }
+ }
+ MEM_freeN(ibufs_arr);
+ }
+
+finally:
+ /* restore */
+ scene->r.scemode = orig_data.scemode;
+ scene->r.cfra = orig_data.timeline_frame;
+ scene->r.subframe = orig_data.subframe;
+
+ if (is_frame_update && (depsgraph != NULL)) {
+ BKE_scene_graph_update_for_newframe(depsgraph);
+ }
+
+#ifdef DURIAN_CAMERA_SWITCH
+ /* stooping to new low's in hackyness :( */
+ scene->r.mode &= orig_data.mode | ~R_NO_CAMERA_SWITCH;
+#endif
+
+ return ibuf;
+}
+
+/**
+ * Used for meta-strips & scenes with #SEQ_SCENE_STRIPS flag set.
+ */
+static ImBuf *do_render_strip_seqbase(const SeqRenderData *context,
+ SeqRenderState *state,
+ Sequence *seq,
+ float frame_index)
+{
+ ImBuf *ibuf = NULL;
+ ListBase *seqbase = NULL;
+ int offset;
+
+ seqbase = BKE_sequence_seqbase_get(seq, &offset);
+
+ if (seqbase && !BLI_listbase_is_empty(seqbase)) {
+
+ if (seq->flag & SEQ_SCENE_STRIPS && seq->scene) {
+ BKE_animsys_evaluate_all_animation(context->bmain, context->depsgraph, frame_index + offset);
+ }
+
+ ibuf = seq_render_strip_stack(context,
+ state,
+ seqbase,
+ /* scene strips don't have their start taken into account */
+ frame_index + offset,
+ 0);
+ }
+
+ return ibuf;
+}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Strip stack rendering functions
+ * \{ */
+static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
+ SeqRenderState *state,
+ Sequence *seq,
+ float timeline_frame,
+ bool *r_is_proxy_image)
+{
+ ImBuf *ibuf = NULL;
+ float frame_index = seq_give_frame_index(seq, timeline_frame);
+ int type = (seq->type & SEQ_TYPE_EFFECT) ? SEQ_TYPE_EFFECT : seq->type;
+ switch (type) {
+ case SEQ_TYPE_META: {
+ ibuf = do_render_strip_seqbase(context, state, seq, frame_index);
+ break;
+ }
+
+ case SEQ_TYPE_SCENE: {
+ if (seq->flag & SEQ_SCENE_STRIPS) {
+ if (seq->scene && (context->scene != seq->scene)) {
+ /* recursive check */
+ if (BLI_linklist_index(state->scene_parents, seq->scene) != -1) {
+ break;
+ }
+ LinkNode scene_parent = {
+ .next = state->scene_parents,
+ .link = seq->scene,
+ };
+ state->scene_parents = &scene_parent;
+ /* end check */
+
+ /* Use the Scene sequence-strip's scene for the context when rendering the
+ * scene's sequences (necessary for multi-cam selector among others). */
+ SeqRenderData local_context = *context;
+ local_context.scene = seq->scene;
+ local_context.skip_cache = true;
+
+ ibuf = do_render_strip_seqbase(&local_context, state, seq, frame_index);
+
+ /* step back in the list */
+ state->scene_parents = state->scene_parents->next;
+ }
+ }
+ else {
+ /* scene can be NULL after deletions */
+ ibuf = seq_render_scene_strip(context, seq, frame_index, timeline_frame);
+ }
+
+ break;
+ }
+
+ case SEQ_TYPE_EFFECT: {
+ ibuf = seq_render_effect_strip_impl(context, state, seq, timeline_frame);
+ break;
+ }
+
+ case SEQ_TYPE_IMAGE: {
+ ibuf = seq_render_image_strip(context, seq, frame_index, timeline_frame, r_is_proxy_image);
+ break;
+ }
+
+ case SEQ_TYPE_MOVIE: {
+ ibuf = seq_render_movie_strip(context, seq, frame_index, timeline_frame, r_is_proxy_image);
+ break;
+ }
+
+ case SEQ_TYPE_MOVIECLIP: {
+ ibuf = seq_render_movieclip_strip(context, seq, frame_index, r_is_proxy_image);
+
+ if (ibuf) {
+ /* duplicate frame so movie cache wouldn't be confused by sequencer's stuff */
+ ImBuf *i = IMB_dupImBuf(ibuf);
+ IMB_freeImBuf(ibuf);
+ ibuf = i;
+
+ if (ibuf->rect_float) {
+ seq_imbuf_to_sequencer_space(context->scene, ibuf, false);
+ }
+ }
+
+ break;
+ }
+
+ case SEQ_TYPE_MASK: {
+ /* ibuf is always new */
+ ibuf = seq_render_mask_strip(context, seq, frame_index);
+ break;
+ }
+ }
+
+ if (ibuf) {
+ seq_imbuf_assign_spaces(context->scene, ibuf);
+ }
+
+ return ibuf;
+}
+
+ImBuf *seq_render_strip(const SeqRenderData *context,
+ SeqRenderState *state,
+ Sequence *seq,
+ float timeline_frame)
+{
+ ImBuf *ibuf = NULL;
+ bool use_preprocess = false;
+ bool is_proxy_image = false;
+
+ clock_t begin = seq_estimate_render_cost_begin();
+
+ ibuf = BKE_sequencer_cache_get(
+ context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED, false);
+ if (ibuf != NULL) {
+ return ibuf;
+ }
+
+ /* Proxies are not stored in cache. */
+ if (!SEQ_can_use_proxy(seq, SEQ_rendersize_to_proxysize(context->preview_render_size))) {
+ ibuf = BKE_sequencer_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_RAW, false);
+ }
+
+ if (ibuf == NULL) {
+ ibuf = do_render_strip_uncached(context, state, seq, timeline_frame, &is_proxy_image);
+ }
+
+ if (ibuf) {
+ use_preprocess = BKE_sequencer_input_have_to_preprocess(context, seq, timeline_frame);
+ ibuf = seq_render_preprocess_ibuf(
+ context, seq, ibuf, timeline_frame, begin, use_preprocess, is_proxy_image);
+ }
+
+ if (ibuf == NULL) {
+ ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
+ seq_imbuf_assign_spaces(context->scene, ibuf);
+ }
+
+ return ibuf;
+}
+
+static bool seq_must_swap_input_in_blend_mode(Sequence *seq)
+{
+ bool swap_input = false;
+
+ /* bad hack, to fix crazy input ordering of
+ * those two effects */
+
+ if (ELEM(seq->blend_mode, SEQ_TYPE_ALPHAOVER, SEQ_TYPE_ALPHAUNDER, SEQ_TYPE_OVERDROP)) {
+ swap_input = true;
+ }
+
+ return swap_input;
+}
+
+static int seq_get_early_out_for_blend_mode(Sequence *seq)
+{
+ struct SeqEffectHandle sh = BKE_sequence_get_blend(seq);
+ float facf = seq->blend_opacity / 100.0f;
+ int early_out = sh.early_out(seq, facf, facf);
+
+ if (ELEM(early_out, EARLY_DO_EFFECT, EARLY_NO_INPUT)) {
+ return early_out;
+ }
+
+ if (seq_must_swap_input_in_blend_mode(seq)) {
+ if (early_out == EARLY_USE_INPUT_2) {
+ return EARLY_USE_INPUT_1;
+ }
+ if (early_out == EARLY_USE_INPUT_1) {
+ return EARLY_USE_INPUT_2;
+ }
+ }
+ return early_out;
+}
+
+static ImBuf *seq_render_strip_stack_apply_effect(
+ const SeqRenderData *context, Sequence *seq, float timeline_frame, ImBuf *ibuf1, ImBuf *ibuf2)
+{
+ ImBuf *out;
+ struct SeqEffectHandle sh = BKE_sequence_get_blend(seq);
+ float facf = seq->blend_opacity / 100.0f;
+ int swap_input = seq_must_swap_input_in_blend_mode(seq);
+
+ if (swap_input) {
+ if (sh.multithreaded) {
+ out = seq_render_effect_execute_threaded(
+ &sh, context, seq, timeline_frame, facf, facf, ibuf2, ibuf1, NULL);
+ }
+ else {
+ out = sh.execute(context, seq, timeline_frame, facf, facf, ibuf2, ibuf1, NULL);
+ }
+ }
+ else {
+ if (sh.multithreaded) {
+ out = seq_render_effect_execute_threaded(
+ &sh, context, seq, timeline_frame, facf, facf, ibuf1, ibuf2, NULL);
+ }
+ else {
+ out = sh.execute(context, seq, timeline_frame, facf, facf, ibuf1, ibuf2, NULL);
+ }
+ }
+
+ return out;
+}
+
+static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
+ SeqRenderState *state,
+ ListBase *seqbasep,
+ float timeline_frame,
+ int chanshown)
+{
+ Sequence *seq_arr[MAXSEQ + 1];
+ int count;
+ int i;
+ ImBuf *out = NULL;
+ clock_t begin;
+
+ count = seq_get_shown_sequences(seqbasep, timeline_frame, chanshown, (Sequence **)&seq_arr);
+
+ if (count == 0) {
+ return NULL;
+ }
+
+ for (i = count - 1; i >= 0; i--) {
+ int early_out;
+ Sequence *seq = seq_arr[i];
+
+ out = BKE_sequencer_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_COMPOSITE, false);
+
+ if (out) {
+ break;
+ }
+ if (seq->blend_mode == SEQ_BLEND_REPLACE) {
+ out = seq_render_strip(context, state, seq, timeline_frame);
+ break;
+ }
+
+ early_out = seq_get_early_out_for_blend_mode(seq);
+
+ switch (early_out) {
+ case EARLY_NO_INPUT:
+ case EARLY_USE_INPUT_2:
+ out = seq_render_strip(context, state, seq, timeline_frame);
+ break;
+ case EARLY_USE_INPUT_1:
+ if (i == 0) {
+ out = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
+ }
+ break;
+ case EARLY_DO_EFFECT:
+ if (i == 0) {
+ begin = seq_estimate_render_cost_begin();
+
+ ImBuf *ibuf1 = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
+ ImBuf *ibuf2 = seq_render_strip(context, state, seq, timeline_frame);
+
+ out = seq_render_strip_stack_apply_effect(context, seq, timeline_frame, ibuf1, ibuf2);
+
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put(
+ context, seq_arr[i], timeline_frame, SEQ_CACHE_STORE_COMPOSITE, out, cost, false);
+
+ IMB_freeImBuf(ibuf1);
+ IMB_freeImBuf(ibuf2);
+ }
+ break;
+ }
+ if (out) {
+ break;
+ }
+ }
+
+ i++;
+ for (; i < count; i++) {
+ begin = seq_estimate_render_cost_begin();
+ Sequence *seq = seq_arr[i];
+
+ if (seq_get_early_out_for_blend_mode(seq) == EARLY_DO_EFFECT) {
+ ImBuf *ibuf1 = out;
+ ImBuf *ibuf2 = seq_render_strip(context, state, seq, timeline_frame);
+
+ out = seq_render_strip_stack_apply_effect(context, seq, timeline_frame, ibuf1, ibuf2);
+
+ IMB_freeImBuf(ibuf1);
+ IMB_freeImBuf(ibuf2);
+ }
+
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put(
+ context, seq_arr[i], timeline_frame, SEQ_CACHE_STORE_COMPOSITE, out, cost, false);
+ }
+
+ return out;
+}
+
+/**
+ * \return The image buffer or NULL.
+ *
+ * \note The returned #ImBuf is has it's reference increased, free after usage!
+ */
+ImBuf *SEQ_render_give_ibuf(const SeqRenderData *context, float timeline_frame, int chanshown)
+{
+ Scene *scene = context->scene;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ ListBase *seqbasep;
+
+ if (ed == NULL) {
+ return NULL;
+ }
+
+ if ((chanshown < 0) && !BLI_listbase_is_empty(&ed->metastack)) {
+ int count = BLI_listbase_count(&ed->metastack);
+ count = max_ii(count + chanshown, 0);
+ seqbasep = ((MetaStack *)BLI_findlink(&ed->metastack, count))->oldbasep;
+ }
+ else {
+ seqbasep = ed->seqbasep;
+ }
+
+ SeqRenderState state;
+ seq_render_state_init(&state);
+ ImBuf *out = NULL;
+ Sequence *seq_arr[MAXSEQ + 1];
+ int count;
+
+ count = seq_get_shown_sequences(seqbasep, timeline_frame, chanshown, seq_arr);
+
+ if (count) {
+ out = BKE_sequencer_cache_get(
+ context, seq_arr[count - 1], timeline_frame, SEQ_CACHE_STORE_FINAL_OUT, false);
+ }
+
+ BKE_sequencer_cache_free_temp_cache(context->scene, context->task_id, timeline_frame);
+
+ clock_t begin = seq_estimate_render_cost_begin();
+ float cost = 0;
+
+ if (count && !out) {
+ BLI_mutex_lock(&seq_render_mutex);
+ out = seq_render_strip_stack(context, &state, seqbasep, timeline_frame, chanshown);
+ cost = seq_estimate_render_cost_end(context->scene, begin);
+
+ if (context->is_prefetch_render) {
+ BKE_sequencer_cache_put(context,
+ seq_arr[count - 1],
+ timeline_frame,
+ SEQ_CACHE_STORE_FINAL_OUT,
+ out,
+ cost,
+ false);
+ }
+ else {
+ BKE_sequencer_cache_put_if_possible(context,
+ seq_arr[count - 1],
+ timeline_frame,
+ SEQ_CACHE_STORE_FINAL_OUT,
+ out,
+ cost,
+ false);
+ }
+ BLI_mutex_unlock(&seq_render_mutex);
+ }
+
+ BKE_sequencer_prefetch_start(context, timeline_frame, cost);
+
+ return out;
+}
+
+ImBuf *seq_render_give_ibuf_seqbase(const SeqRenderData *context,
+ float timeline_frame,
+ int chan_shown,
+ ListBase *seqbasep)
+{
+ SeqRenderState state;
+ seq_render_state_init(&state);
+
+ return seq_render_strip_stack(context, &state, seqbasep, timeline_frame, chan_shown);
+}
+
+ImBuf *SEQ_render_give_ibuf_direct(const SeqRenderData *context,
+ float timeline_frame,
+ Sequence *seq)
+{
+ SeqRenderState state;
+ seq_render_state_init(&state);
+
+ ImBuf *ibuf = seq_render_strip(context, &state, seq, timeline_frame);
+
+ return ibuf;
+}
+/** \} */
diff --git a/source/blender/sequencer/intern/render.h b/source/blender/sequencer/intern/render.h
new file mode 100644
index 00000000000..d5affeb547b
--- /dev/null
+++ b/source/blender/sequencer/intern/render.h
@@ -0,0 +1,79 @@
+/*
+ * 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) 2004 Blender Foundation.
+ * All rights reserved.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup sequencer
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct Editing;
+struct ImBuf;
+struct ListBase;
+struct Scene;
+struct SeqRenderData;
+struct Sequence;
+
+#define EARLY_NO_INPUT -1
+#define EARLY_DO_EFFECT 0
+#define EARLY_USE_INPUT_1 1
+#define EARLY_USE_INPUT_2 2
+
+/* mutable state for sequencer */
+typedef struct SeqRenderState {
+ struct LinkNode *scene_parents;
+} SeqRenderState;
+
+void seq_render_state_init(SeqRenderState *state);
+
+struct ImBuf *seq_render_give_ibuf_seqbase(const struct SeqRenderData *context,
+ float timeline_frame,
+ int chan_shown,
+ struct ListBase *seqbasep);
+struct ImBuf *seq_render_effect_execute_threaded(struct SeqEffectHandle *sh,
+ const SeqRenderData *context,
+ struct Sequence *seq,
+ float timeline_frame,
+ float facf0,
+ float facf1,
+ struct ImBuf *ibuf1,
+ struct ImBuf *ibuf2,
+ struct ImBuf *ibuf3);
+void seq_imbuf_to_sequencer_space(struct Scene *scene, struct ImBuf *ibuf, bool make_float);
+int seq_get_shown_sequences(struct ListBase *seqbasep,
+ int timeline_frame,
+ int chanshown,
+ struct Sequence **seq_arr_out);
+struct ImBuf *seq_render_strip(const struct SeqRenderData *context,
+ struct SeqRenderState *state,
+ struct Sequence *seq,
+ float timeline_frame);
+struct ImBuf *seq_render_mask(const struct SeqRenderData *context,
+ struct Mask *mask,
+ float frame_index,
+ bool make_float);
+void seq_imbuf_assign_spaces(struct Scene *scene, struct ImBuf *ibuf);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/sequencer/intern/sequencer.c b/source/blender/sequencer/intern/sequencer.c
index 068d836d1e6..0ebf8f3c8e7 100644
--- a/source/blender/sequencer/intern/sequencer.c
+++ b/source/blender/sequencer/intern/sequencer.c
@@ -24,184 +24,52 @@
* \ingroup bke
*/
-#include <math.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
-#include "DNA_mask_types.h"
-#include "DNA_movieclip_types.h"
-#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
-#include "DNA_sound_types.h"
-#include "DNA_space_types.h"
-#include "DNA_windowmanager_types.h"
-#include "BLI_fileops.h"
-#include "BLI_linklist.h"
#include "BLI_listbase.h"
-#include "BLI_math.h"
-#include "BLI_path_util.h"
-#include "BLI_session_uuid.h"
#include "BLI_string.h"
-#include "BLI_string_utf8.h"
-#include "BLI_threads.h"
-#include "BLI_utildefines.h"
-
-#ifdef WIN32
-# include "BLI_winstuff.h"
-#else
-# include <unistd.h>
-#endif
-
-#include "BLT_translation.h"
-#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_fcurve.h"
-#include "BKE_global.h"
#include "BKE_idprop.h"
-#include "BKE_image.h"
-#include "BKE_layer.h"
#include "BKE_lib_id.h"
-#include "BKE_main.h"
-#include "BKE_mask.h"
-#include "BKE_movieclip.h"
-#include "BKE_report.h"
-#include "BKE_scene.h"
-#include "BKE_sequencer.h"
-#include "BKE_sequencer_offscreen.h"
+#include "BKE_sound.h"
#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_query.h"
-
-#include "RNA_access.h"
-
-#include "RE_pipeline.h"
-
-#include <pthread.h>
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
-#include "IMB_metadata.h"
-
-#include "BKE_context.h"
-#include "BKE_sound.h"
-
-#include "RE_engine.h"
-#ifdef WITH_AUDASPACE
-# include <AUD_Special.h>
-#endif
+#include "SEQ_sequencer.h"
-/* mutable state for sequencer */
-typedef struct SeqRenderState {
- LinkNode *scene_parents;
-} SeqRenderState;
+#include "image_cache.h"
+#include "prefetch.h"
+#include "sequencer.h"
+#include "utils.h"
-static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
- SeqRenderState *state,
- ListBase *seqbasep,
- float cfra,
- int chanshown);
-static ImBuf *seq_render_preprocess_ibuf(const SeqRenderData *context,
- Sequence *seq,
- ImBuf *ibuf,
- float cfra,
- clock_t begin,
- bool use_preprocess,
- const bool is_proxy_image);
-static ImBuf *seq_render_strip(const SeqRenderData *context,
- SeqRenderState *state,
- Sequence *seq,
- float cfra);
static void seq_free_animdata(Scene *scene, Sequence *seq);
-static ImBuf *seq_render_mask(const SeqRenderData *context, Mask *mask, float nr, bool make_float);
-static int seq_num_files(Scene *scene, char views_format, const bool is_multiview);
-static void seq_anim_add_suffix(Scene *scene, struct anim *anim, const int view_id);
-
-static ThreadMutex seq_render_mutex = BLI_MUTEX_INITIALIZER;
-
-/* **** XXX ******** */
-#define SELECT 1
-ListBase seqbase_clipboard;
-int seqbase_clipboard_frame;
-
-SequencerDrawView sequencer_view3d_fn = NULL; /* NULL in background mode */
-
-#if 0 /* unused function */
-static void printf_strip(Sequence *seq)
-{
- fprintf(stderr,
- "name: '%s', len:%d, start:%d, (startofs:%d, endofs:%d), "
- "(startstill:%d, endstill:%d), machine:%d, (startdisp:%d, enddisp:%d)\n",
- seq->name,
- seq->len,
- seq->start,
- seq->startofs,
- seq->endofs,
- seq->startstill,
- seq->endstill,
- seq->machine,
- seq->startdisp,
- seq->enddisp);
-
- fprintf(stderr,
- "\tseq_tx_set_final_left: %d %d\n\n",
- seq_tx_get_final_left(seq, 0),
- seq_tx_get_final_right(seq, 0));
-}
-#endif
-
-static void sequencer_state_init(SeqRenderState *state)
-{
- state->scene_parents = NULL;
-}
-int BKE_sequencer_base_recursive_apply(ListBase *seqbase,
- int (*apply_fn)(Sequence *seq, void *),
- void *arg)
-{
- Sequence *iseq;
- for (iseq = seqbase->first; iseq; iseq = iseq->next) {
- if (BKE_sequencer_recursive_apply(iseq, apply_fn, arg) == -1) {
- return -1; /* bail out */
- }
- }
- return 1;
-}
+/* -------------------------------------------------------------------- */
+/** \name Allocate / Free Functions
+ * \{ */
-int BKE_sequencer_recursive_apply(Sequence *seq, int (*apply_fn)(Sequence *, void *), void *arg)
+static Strip *seq_strip_alloc(int type)
{
- int ret = apply_fn(seq, arg);
-
- if (ret == -1) {
- return -1; /* bail out */
- }
+ Strip *strip = MEM_callocN(sizeof(Strip), "strip");
- if (ret && seq->seqbase.first) {
- ret = BKE_sequencer_base_recursive_apply(&seq->seqbase, apply_fn, arg);
+ if (ELEM(type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD) == 0) {
+ strip->transform = MEM_callocN(sizeof(struct StripTransform), "StripTransform");
+ strip->transform->scale_x = 1;
+ strip->transform->scale_y = 1;
+ strip->crop = MEM_callocN(sizeof(struct StripCrop), "StripCrop");
}
- return ret;
-}
-
-/*********************** alloc / free functions *************************/
-
-/* free */
-
-static void free_proxy_seq(Sequence *seq)
-{
- if (seq->strip && seq->strip->proxy && seq->strip->proxy->anim) {
- IMB_free_anim(seq->strip->proxy->anim);
- seq->strip->proxy->anim = NULL;
- }
+ strip->us = 1;
+ return strip;
}
static void seq_free_strip(Strip *strip)
@@ -236,6 +104,36 @@ static void seq_free_strip(Strip *strip)
MEM_freeN(strip);
}
+Sequence *BKE_sequence_alloc(ListBase *lb, int timeline_frame, int machine, int type)
+{
+ Sequence *seq;
+
+ seq = MEM_callocN(sizeof(Sequence), "addseq");
+ BLI_addtail(lb, seq);
+
+ *((short *)seq->name) = ID_SEQ;
+ seq->name[2] = 0;
+
+ seq->flag = SELECT;
+ seq->start = timeline_frame;
+ seq->machine = machine;
+ seq->sat = 1.0;
+ seq->mul = 1.0;
+ seq->blend_opacity = 100.0;
+ seq->volume = 1.0f;
+ seq->pitch = 1.0f;
+ seq->scene_sound = NULL;
+ seq->type = type;
+
+ seq->strip = seq_strip_alloc(type);
+ seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Sequence Stereo Format");
+ seq->cache_flag = SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_PREPROCESSED | SEQ_CACHE_STORE_COMPOSITE;
+
+ BKE_sequence_session_uuid_generate(seq);
+
+ return seq;
+}
+
/* only give option to skip cache locally (static func) */
static void BKE_sequence_free_ex(Scene *scene,
Sequence *seq,
@@ -312,25 +210,9 @@ void BKE_sequence_free(Scene *scene, Sequence *seq, const bool do_clean_animdata
BKE_sequence_free_ex(scene, seq, true, true, do_clean_animdata);
}
-/* Function to free imbuf and anim data on changes */
-void BKE_sequence_free_anim(Sequence *seq)
-{
- while (seq->anims.last) {
- StripAnim *sanim = seq->anims.last;
-
- if (sanim->anim) {
- IMB_free_anim(sanim->anim);
- sanim->anim = NULL;
- }
-
- BLI_freelinkN(&seq->anims, sanim);
- }
- BLI_listbase_clear(&seq->anims);
-}
-
/* cache must be freed before calling this function
* since it leaves the seqbase in an invalid state */
-static void seq_free_sequence_recurse(Scene *scene, Sequence *seq, const bool do_id_user)
+void seq_free_sequence_recurse(Scene *scene, Sequence *seq, const bool do_id_user)
{
Sequence *iseq, *iseq_next;
@@ -350,135 +232,6 @@ Editing *BKE_sequencer_editing_get(Scene *scene, bool alloc)
return scene->ed;
}
-void BKE_sequencer_free_clipboard(void)
-{
- Sequence *seq, *nseq;
-
- BKE_sequencer_base_clipboard_pointers_free(&seqbase_clipboard);
-
- for (seq = seqbase_clipboard.first; seq; seq = nseq) {
- nseq = seq->next;
- seq_free_sequence_recurse(NULL, seq, false);
- }
- BLI_listbase_clear(&seqbase_clipboard);
-}
-
-/* -------------------------------------------------------------------- */
-/* Manage pointers in the clipboard.
- * note that these pointers should _never_ be access in the sequencer,
- * they are only for storage while in the clipboard
- * notice 'newid' is used for temp pointer storage here, validate on access (this is safe usage,
- * since those data-blocks are fully out of Main lists).
- */
-#define ID_PT (*id_pt)
-static void seqclipboard_ptr_free(Main *UNUSED(bmain), ID **id_pt)
-{
- if (ID_PT) {
- BLI_assert(ID_PT->newid != NULL);
- MEM_freeN(ID_PT);
- ID_PT = NULL;
- }
-}
-static void seqclipboard_ptr_store(Main *UNUSED(bmain), ID **id_pt)
-{
- if (ID_PT) {
- ID *id_prev = ID_PT;
- ID_PT = MEM_dupallocN(ID_PT);
- ID_PT->newid = id_prev;
- }
-}
-static void seqclipboard_ptr_restore(Main *bmain, ID **id_pt)
-{
- if (ID_PT) {
- const ListBase *lb = which_libbase(bmain, GS(ID_PT->name));
- void *id_restore;
-
- BLI_assert(ID_PT->newid != NULL);
- if (BLI_findindex(lb, (ID_PT)->newid) != -1) {
- /* the pointer is still valid */
- id_restore = (ID_PT)->newid;
- }
- else {
- /* the pointer of the same name still exists */
- id_restore = BLI_findstring(lb, (ID_PT)->name + 2, offsetof(ID, name) + 2);
- }
-
- if (id_restore == NULL) {
- /* check for a data with the same filename */
- switch (GS(ID_PT->name)) {
- case ID_SO: {
- id_restore = BLI_findstring(lb, ((bSound *)ID_PT)->filepath, offsetof(bSound, filepath));
- if (id_restore == NULL) {
- id_restore = BKE_sound_new_file(bmain, ((bSound *)ID_PT)->filepath);
- (ID_PT)->newid = id_restore; /* reuse next time */
- }
- break;
- }
- case ID_MC: {
- id_restore = BLI_findstring(
- lb, ((MovieClip *)ID_PT)->filepath, offsetof(MovieClip, filepath));
- if (id_restore == NULL) {
- id_restore = BKE_movieclip_file_add(bmain, ((MovieClip *)ID_PT)->filepath);
- (ID_PT)->newid = id_restore; /* reuse next time */
- }
- break;
- }
- default:
- break;
- }
- }
-
- /* Replace with pointer to actual data-block. */
- seqclipboard_ptr_free(bmain, id_pt);
- ID_PT = id_restore;
- }
-}
-#undef ID_PT
-
-static void sequence_clipboard_pointers(Main *bmain,
- Sequence *seq,
- void (*callback)(Main *, ID **))
-{
- callback(bmain, (ID **)&seq->scene);
- callback(bmain, (ID **)&seq->scene_camera);
- callback(bmain, (ID **)&seq->clip);
- callback(bmain, (ID **)&seq->mask);
- callback(bmain, (ID **)&seq->sound);
-
- if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
- TextVars *text_data = seq->effectdata;
- callback(bmain, (ID **)&text_data->text_font);
- }
-}
-
-/* recursive versions of functions above */
-void BKE_sequencer_base_clipboard_pointers_free(ListBase *seqbase)
-{
- Sequence *seq;
- for (seq = seqbase->first; seq; seq = seq->next) {
- sequence_clipboard_pointers(NULL, seq, seqclipboard_ptr_free);
- BKE_sequencer_base_clipboard_pointers_free(&seq->seqbase);
- }
-}
-void BKE_sequencer_base_clipboard_pointers_store(Main *bmain, ListBase *seqbase)
-{
- Sequence *seq;
- for (seq = seqbase->first; seq; seq = seq->next) {
- sequence_clipboard_pointers(bmain, seq, seqclipboard_ptr_store);
- BKE_sequencer_base_clipboard_pointers_store(bmain, &seq->seqbase);
- }
-}
-void BKE_sequencer_base_clipboard_pointers_restore(ListBase *seqbase, Main *bmain)
-{
- Sequence *seq;
- for (seq = seqbase->first; seq; seq = seq->next) {
- sequence_clipboard_pointers(bmain, seq, seqclipboard_ptr_restore);
- BKE_sequencer_base_clipboard_pointers_restore(&seq->seqbase, bmain);
- }
-}
-
-/* end clipboard pointer mess */
-
Editing *BKE_sequencer_editing_ensure(Scene *scene)
{
if (scene->ed == NULL) {
@@ -520,5172 +273,39 @@ void BKE_sequencer_editing_free(Scene *scene, const bool do_id_user)
scene->ed = NULL;
}
-/*********************** Sequencer color space functions *************************/
-
-static void sequencer_imbuf_assign_spaces(Scene *scene, ImBuf *ibuf)
-{
-#if 0
- /* Bute buffer is supposed to be in sequencer working space already. */
- if (ibuf->rect != NULL) {
- IMB_colormanagement_assign_rect_colorspace(ibuf, scene->sequencer_colorspace_settings.name);
- }
-#endif
- if (ibuf->rect_float != NULL) {
- IMB_colormanagement_assign_float_colorspace(ibuf, scene->sequencer_colorspace_settings.name);
- }
-}
-
-void BKE_sequencer_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, bool make_float)
-{
- /* Early output check: if both buffers are NULL we have nothing to convert. */
- if (ibuf->rect_float == NULL && ibuf->rect == NULL) {
- return;
- }
- /* Get common conversion settings. */
- const char *to_colorspace = scene->sequencer_colorspace_settings.name;
- /* Perform actual conversion logic. */
- if (ibuf->rect_float == NULL) {
- /* We are not requested to give float buffer and byte buffer is already
- * in thee required colorspace. Can skip doing anything here.
- */
- const char *from_colorspace = IMB_colormanagement_get_rect_colorspace(ibuf);
- if (!make_float && STREQ(from_colorspace, to_colorspace)) {
- return;
- }
- if (false) {
- /* The idea here is to provide as fast playback as possible and
- * enforcing float buffer here (a) uses more cache memory (b) might
- * make some other effects slower to apply.
- *
- * However, this might also have negative effect by adding weird
- * artifacts which will then not happen in final render.
- */
- IMB_colormanagement_transform_byte_threaded((unsigned char *)ibuf->rect,
- ibuf->x,
- ibuf->y,
- ibuf->channels,
- from_colorspace,
- to_colorspace);
- }
- else {
- /* We perform conversion to a float buffer so we don't worry about
- * precision loss.
- */
- imb_addrectfloatImBuf(ibuf);
- IMB_colormanagement_transform_from_byte_threaded(ibuf->rect_float,
- (unsigned char *)ibuf->rect,
- ibuf->x,
- ibuf->y,
- ibuf->channels,
- from_colorspace,
- to_colorspace);
- /* We don't need byte buffer anymore. */
- imb_freerectImBuf(ibuf);
- }
- }
- else {
- const char *from_colorspace = IMB_colormanagement_get_float_colorspace(ibuf);
- /* Unknown input color space, can't perform conversion. */
- if (from_colorspace == NULL || from_colorspace[0] == '\0') {
- return;
- }
- /* We don't want both byte and float buffers around: they'll either run
- * out of sync or conversion of byte buffer will lose precision in there.
- */
- if (ibuf->rect != NULL) {
- imb_freerectImBuf(ibuf);
- }
- IMB_colormanagement_transform_threaded(
- ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, true);
- }
- sequencer_imbuf_assign_spaces(scene, ibuf);
-}
-
-void BKE_sequencer_imbuf_from_sequencer_space(Scene *scene, ImBuf *ibuf)
-{
- const char *from_colorspace = scene->sequencer_colorspace_settings.name;
- const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(
- COLOR_ROLE_SCENE_LINEAR);
-
- if (!ibuf->rect_float) {
- return;
- }
-
- if (to_colorspace && to_colorspace[0] != '\0') {
- IMB_colormanagement_transform_threaded(
- ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, true);
- IMB_colormanagement_assign_float_colorspace(ibuf, to_colorspace);
- }
-}
-
-void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4])
-{
- const char *from_colorspace = scene->sequencer_colorspace_settings.name;
- const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(
- COLOR_ROLE_SCENE_LINEAR);
-
- if (to_colorspace && to_colorspace[0] != '\0') {
- IMB_colormanagement_transform_v4(pixel, from_colorspace, to_colorspace);
- }
- else {
- /* if no color management enables fallback to legacy conversion */
- srgb_to_linearrgb_v4(pixel, pixel);
- }
-}
-
-/*********************** sequencer pipeline functions *************************/
-
-void BKE_sequencer_new_render_data(Main *bmain,
- struct Depsgraph *depsgraph,
- Scene *scene,
- int rectx,
- int recty,
- int preview_render_size,
- int for_render,
- SeqRenderData *r_context)
-{
- r_context->bmain = bmain;
- r_context->depsgraph = depsgraph;
- r_context->scene = scene;
- r_context->rectx = rectx;
- r_context->recty = recty;
- r_context->preview_render_size = preview_render_size;
- r_context->for_render = for_render;
- r_context->motion_blur_samples = 0;
- r_context->motion_blur_shutter = 0;
- r_context->skip_cache = false;
- r_context->is_proxy_render = false;
- r_context->view_id = 0;
- r_context->gpu_offscreen = NULL;
- r_context->task_id = SEQ_TASK_MAIN_RENDER;
- r_context->is_prefetch_render = false;
-}
-
-/* ************************* iterator ************************** */
-/* *************** (replaces old WHILE_SEQ) ********************* */
-/* **************** use now SEQ_ALL_BEGIN () SEQ_ALL_END ***************** */
-
-/* sequence strip iterator:
- * - builds a full array, recursively into meta strips
- */
-
-static void seq_count(ListBase *seqbase, int *tot)
-{
- Sequence *seq;
-
- for (seq = seqbase->first; seq; seq = seq->next) {
- (*tot)++;
-
- if (seq->seqbase.first) {
- seq_count(&seq->seqbase, tot);
- }
- }
-}
-
-static void seq_build_array(ListBase *seqbase, Sequence ***array, int depth)
-{
- Sequence *seq;
-
- for (seq = seqbase->first; seq; seq = seq->next) {
- seq->depth = depth;
-
- if (seq->seqbase.first) {
- seq_build_array(&seq->seqbase, array, depth + 1);
- }
-
- **array = seq;
- (*array)++;
- }
-}
-
-static void seq_array(Editing *ed,
- Sequence ***seqarray,
- int *tot,
- const bool use_current_sequences)
-{
- Sequence **array;
-
- *seqarray = NULL;
- *tot = 0;
-
- if (ed == NULL) {
- return;
- }
-
- if (use_current_sequences) {
- seq_count(ed->seqbasep, tot);
- }
- else {
- seq_count(&ed->seqbase, tot);
- }
-
- if (*tot == 0) {
- return;
- }
-
- *seqarray = array = MEM_mallocN(sizeof(Sequence *) * (*tot), "SeqArray");
- if (use_current_sequences) {
- seq_build_array(ed->seqbasep, &array, 0);
- }
- else {
- seq_build_array(&ed->seqbase, &array, 0);
- }
-}
-
-void BKE_sequence_iterator_begin(Editing *ed, SeqIterator *iter, const bool use_current_sequences)
-{
- memset(iter, 0, sizeof(*iter));
- seq_array(ed, &iter->array, &iter->tot, use_current_sequences);
-
- if (iter->tot) {
- iter->cur = 0;
- iter->seq = iter->array[iter->cur];
- iter->valid = 1;
- }
-}
-
-void BKE_sequence_iterator_next(SeqIterator *iter)
-{
- if (++iter->cur < iter->tot) {
- iter->seq = iter->array[iter->cur];
- }
- else {
- iter->valid = 0;
- }
-}
-
-void BKE_sequence_iterator_end(SeqIterator *iter)
-{
- if (iter->array) {
- MEM_freeN(iter->array);
- }
-
- iter->valid = 0;
-}
-
-static int metaseq_start(Sequence *metaseq)
-{
- return metaseq->start + metaseq->startofs;
-}
-
-static int metaseq_end(Sequence *metaseq)
-{
- return metaseq->start + metaseq->len - metaseq->endofs;
-}
-
-static void seq_update_sound_bounds_recursive_impl(Scene *scene,
- Sequence *metaseq,
- int start,
- int end)
-{
- Sequence *seq;
-
- /* for sound we go over full meta tree to update bounds of the sound strips,
- * since sound is played outside of evaluating the imbufs, */
- for (seq = metaseq->seqbase.first; seq; seq = seq->next) {
- if (seq->type == SEQ_TYPE_META) {
- seq_update_sound_bounds_recursive_impl(
- scene, seq, max_ii(start, metaseq_start(seq)), min_ii(end, metaseq_end(seq)));
- }
- else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
- if (seq->scene_sound) {
- int startofs = seq->startofs;
- int endofs = seq->endofs;
- if (seq->startofs + seq->start < start) {
- startofs = start - seq->start;
- }
-
- if (seq->start + seq->len - seq->endofs > end) {
- endofs = seq->start + seq->len - end;
- }
-
- BKE_sound_move_scene_sound(scene,
- seq->scene_sound,
- seq->start + startofs,
- seq->start + seq->len - endofs,
- startofs + seq->anim_startofs);
- }
- }
- }
-}
-
-static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq)
-{
- seq_update_sound_bounds_recursive_impl(
- scene, metaseq, metaseq_start(metaseq), metaseq_end(metaseq));
-}
-
-void BKE_sequence_calc_disp(Scene *scene, Sequence *seq)
-{
- if (seq->startofs && seq->startstill) {
- seq->startstill = 0;
- }
- if (seq->endofs && seq->endstill) {
- seq->endstill = 0;
- }
-
- seq->startdisp = seq->start + seq->startofs - seq->startstill;
- seq->enddisp = seq->start + seq->len - seq->endofs + seq->endstill;
-
- if (seq->type == SEQ_TYPE_META) {
- seq_update_sound_bounds_recursive(scene, seq);
- }
-}
-
-void BKE_sequence_calc(Scene *scene, Sequence *seq)
-{
- Sequence *seqm;
- int min, max;
-
- /* check all metas recursively */
- seqm = seq->seqbase.first;
- while (seqm) {
- if (seqm->seqbase.first) {
- BKE_sequence_calc(scene, seqm);
- }
- seqm = seqm->next;
- }
-
- /* effects and meta: automatic start and end */
- if (seq->type & SEQ_TYPE_EFFECT) {
- if (seq->seq1) {
- seq->startofs = seq->endofs = seq->startstill = seq->endstill = 0;
- if (seq->seq3) {
- seq->start = seq->startdisp = max_iii(
- seq->seq1->startdisp, seq->seq2->startdisp, seq->seq3->startdisp);
- seq->enddisp = min_iii(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp);
- }
- else if (seq->seq2) {
- seq->start = seq->startdisp = max_ii(seq->seq1->startdisp, seq->seq2->startdisp);
- seq->enddisp = min_ii(seq->seq1->enddisp, seq->seq2->enddisp);
- }
- else {
- seq->start = seq->startdisp = seq->seq1->startdisp;
- seq->enddisp = seq->seq1->enddisp;
- }
- /* we cant help if strips don't overlap, it wont give useful results.
- * but at least ensure 'len' is never negative which causes bad bugs elsewhere. */
- if (seq->enddisp < seq->startdisp) {
- /* simple start/end swap */
- seq->start = seq->enddisp;
- seq->enddisp = seq->startdisp;
- seq->startdisp = seq->start;
- seq->flag |= SEQ_INVALID_EFFECT;
- }
- else {
- seq->flag &= ~SEQ_INVALID_EFFECT;
- }
-
- seq->len = seq->enddisp - seq->startdisp;
- }
- else {
- BKE_sequence_calc_disp(scene, seq);
- }
- }
- else {
- if (seq->type == SEQ_TYPE_META) {
- seqm = seq->seqbase.first;
- if (seqm) {
- min = MAXFRAME * 2;
- max = -MAXFRAME * 2;
- while (seqm) {
- if (seqm->startdisp < min) {
- min = seqm->startdisp;
- }
- if (seqm->enddisp > max) {
- max = seqm->enddisp;
- }
- seqm = seqm->next;
- }
- seq->start = min + seq->anim_startofs;
- seq->len = max - min;
- seq->len -= seq->anim_startofs;
- seq->len -= seq->anim_endofs;
- }
- seq_update_sound_bounds_recursive(scene, seq);
- }
- BKE_sequence_calc_disp(scene, seq);
- }
-}
-
-static void seq_multiview_name(Scene *scene,
- const int view_id,
- const char *prefix,
- const char *ext,
- char *r_path,
- size_t r_size)
-{
- const char *suffix = BKE_scene_multiview_view_id_suffix_get(&scene->r, view_id);
- BLI_assert(ext != NULL && suffix != NULL && prefix != NULL);
- BLI_snprintf(r_path, r_size, "%s%s%s", prefix, suffix, ext);
-}
-
-/* note: caller should run BKE_sequence_calc(scene, seq) after */
-void BKE_sequence_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const bool lock_range)
-{
- char path[FILE_MAX];
- int prev_startdisp = 0, prev_enddisp = 0;
- /* note: don't rename the strip, will break animation curves */
-
- if (ELEM(seq->type,
- SEQ_TYPE_MOVIE,
- SEQ_TYPE_IMAGE,
- SEQ_TYPE_SOUND_RAM,
- SEQ_TYPE_SCENE,
- SEQ_TYPE_META,
- SEQ_TYPE_MOVIECLIP,
- SEQ_TYPE_MASK) == 0) {
- return;
- }
-
- if (lock_range) {
- /* keep so we don't have to move the actual start and end points (only the data) */
- BKE_sequence_calc_disp(scene, seq);
- prev_startdisp = seq->startdisp;
- prev_enddisp = seq->enddisp;
- }
-
- switch (seq->type) {
- case SEQ_TYPE_IMAGE: {
- /* Hack? */
- size_t olen = MEM_allocN_len(seq->strip->stripdata) / sizeof(StripElem);
-
- seq->len = olen;
- seq->len -= seq->anim_startofs;
- seq->len -= seq->anim_endofs;
- if (seq->len < 0) {
- seq->len = 0;
- }
- break;
- }
- case SEQ_TYPE_MOVIE: {
- StripAnim *sanim;
- bool is_multiview_loaded = false;
- const bool is_multiview = (seq->flag & SEQ_USE_VIEWS) != 0 &&
- (scene->r.scemode & R_MULTIVIEW) != 0;
-
- BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name);
- BLI_path_abs(path, BKE_main_blendfile_path_from_global());
-
- BKE_sequence_free_anim(seq);
-
- if (is_multiview && (seq->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
- char prefix[FILE_MAX];
- const char *ext = NULL;
- const int totfiles = seq_num_files(scene, seq->views_format, true);
- int i = 0;
-
- BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext);
-
- if (prefix[0] != '\0') {
- for (i = 0; i < totfiles; i++) {
- struct anim *anim;
- char str[FILE_MAX];
-
- seq_multiview_name(scene, i, prefix, ext, str, FILE_MAX);
- anim = openanim(str,
- IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
- seq->streamindex,
- seq->strip->colorspace_settings.name);
-
- if (anim) {
- seq_anim_add_suffix(scene, anim, i);
- sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
- BLI_addtail(&seq->anims, sanim);
- sanim->anim = anim;
- }
- }
- is_multiview_loaded = true;
- }
- }
-
- if (is_multiview_loaded == false) {
- struct anim *anim;
- anim = openanim(path,
- IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
- seq->streamindex,
- seq->strip->colorspace_settings.name);
- if (anim) {
- sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
- BLI_addtail(&seq->anims, sanim);
- sanim->anim = anim;
- }
- }
-
- /* use the first video as reference for everything */
- sanim = seq->anims.first;
-
- if ((!sanim) || (!sanim->anim)) {
- return;
- }
-
- IMB_anim_load_metadata(sanim->anim);
-
- seq->len = IMB_anim_get_duration(
- sanim->anim, seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN);
-
- seq->anim_preseek = IMB_anim_get_preseek(sanim->anim);
-
- seq->len -= seq->anim_startofs;
- seq->len -= seq->anim_endofs;
- if (seq->len < 0) {
- seq->len = 0;
- }
- break;
- }
- case SEQ_TYPE_MOVIECLIP:
- if (seq->clip == NULL) {
- return;
- }
-
- seq->len = BKE_movieclip_get_duration(seq->clip);
-
- seq->len -= seq->anim_startofs;
- seq->len -= seq->anim_endofs;
- if (seq->len < 0) {
- seq->len = 0;
- }
- break;
- case SEQ_TYPE_MASK:
- if (seq->mask == NULL) {
- return;
- }
- seq->len = BKE_mask_get_duration(seq->mask);
- seq->len -= seq->anim_startofs;
- seq->len -= seq->anim_endofs;
- if (seq->len < 0) {
- seq->len = 0;
- }
- break;
- case SEQ_TYPE_SOUND_RAM:
-#ifdef WITH_AUDASPACE
- if (!seq->sound) {
- return;
- }
- seq->len = ceil((double)BKE_sound_get_length(bmain, seq->sound) * FPS);
- seq->len -= seq->anim_startofs;
- seq->len -= seq->anim_endofs;
- if (seq->len < 0) {
- seq->len = 0;
- }
-#else
- UNUSED_VARS(bmain);
- return;
-#endif
- break;
- case SEQ_TYPE_SCENE: {
- seq->len = (seq->scene) ? seq->scene->r.efra - seq->scene->r.sfra + 1 : 0;
- seq->len -= seq->anim_startofs;
- seq->len -= seq->anim_endofs;
- if (seq->len < 0) {
- seq->len = 0;
- }
- break;
- }
- }
-
- free_proxy_seq(seq);
-
- if (lock_range) {
- BKE_sequence_tx_set_final_left(seq, prev_startdisp);
- BKE_sequence_tx_set_final_right(seq, prev_enddisp);
- BKE_sequence_single_fix(seq);
- }
-
- BKE_sequence_calc(scene, seq);
-}
-
-void BKE_sequence_movie_reload_if_needed(struct Main *bmain,
- struct Scene *scene,
- struct Sequence *seq,
- bool *r_was_reloaded,
- bool *r_can_produce_frames)
-{
- BLI_assert(seq->type == SEQ_TYPE_MOVIE ||
- !"This function is only implemented for movie strips.");
-
- bool must_reload = false;
-
- /* The Sequence struct allows for multiple anim structs to be associated with one strip. This
- * function will return true only if there is at least one 'anim' AND all anims can produce
- * frames. */
-
- if (BLI_listbase_is_empty(&seq->anims)) {
- /* No anim present, so reloading is always necessary. */
- must_reload = true;
- }
- else {
- LISTBASE_FOREACH (StripAnim *, sanim, &seq->anims) {
- if (!IMB_anim_can_produce_frames(sanim->anim)) {
- /* Anim cannot produce frames, try reloading. */
- must_reload = true;
- break;
- }
- };
- }
-
- if (!must_reload) {
- /* There are one or more anims, and all can produce frames. */
- *r_was_reloaded = false;
- *r_can_produce_frames = true;
- return;
- }
-
- BKE_sequence_reload_new_file(bmain, scene, seq, true);
- *r_was_reloaded = true;
-
- if (BLI_listbase_is_empty(&seq->anims)) {
- /* No anims present after reloading => no frames can be produced. */
- *r_can_produce_frames = false;
- return;
- }
-
- /* Check if there are still anims that cannot produce frames. */
- LISTBASE_FOREACH (StripAnim *, sanim, &seq->anims) {
- if (!IMB_anim_can_produce_frames(sanim->anim)) {
- /* There still is an anim that cannot produce frames. */
- *r_can_produce_frames = false;
- return;
- }
- };
-
- /* There are one or more anims, and all can produce frames. */
- *r_can_produce_frames = true;
-}
-
-void BKE_sequencer_sort(Scene *scene)
-{
- /* all strips together per kind, and in order of y location ("machine") */
- ListBase seqbase, effbase;
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq, *seqt;
-
- if (ed == NULL) {
- return;
- }
-
- BLI_listbase_clear(&seqbase);
- BLI_listbase_clear(&effbase);
-
- while ((seq = BLI_pophead(ed->seqbasep))) {
-
- if (seq->type & SEQ_TYPE_EFFECT) {
- seqt = effbase.first;
- while (seqt) {
- if (seqt->machine >= seq->machine) {
- BLI_insertlinkbefore(&effbase, seqt, seq);
- break;
- }
- seqt = seqt->next;
- }
- if (seqt == NULL) {
- BLI_addtail(&effbase, seq);
- }
- }
- else {
- seqt = seqbase.first;
- while (seqt) {
- if (seqt->machine >= seq->machine) {
- BLI_insertlinkbefore(&seqbase, seqt, seq);
- break;
- }
- seqt = seqt->next;
- }
- if (seqt == NULL) {
- BLI_addtail(&seqbase, seq);
- }
- }
- }
-
- BLI_movelisttolist(&seqbase, &effbase);
- *(ed->seqbasep) = seqbase;
-}
-
-/** Comparison function suitable to be used with BLI_listbase_sort()... */
-int BKE_sequencer_cmp_time_startdisp(const void *a, const void *b)
-{
- const Sequence *seq_a = a;
- const Sequence *seq_b = b;
-
- return (seq_a->startdisp > seq_b->startdisp);
-}
-
-static int clear_scene_in_allseqs_fn(Sequence *seq, void *arg_pt)
-{
- if (seq->scene == (Scene *)arg_pt) {
- seq->scene = NULL;
- }
- return 1;
-}
-
-void BKE_sequencer_clear_scene_in_allseqs(Main *bmain, Scene *scene)
-{
- Scene *scene_iter;
-
- /* when a scene is deleted: test all seqs */
- for (scene_iter = bmain->scenes.first; scene_iter; scene_iter = scene_iter->id.next) {
- if (scene_iter != scene && scene_iter->ed) {
- BKE_sequencer_base_recursive_apply(
- &scene_iter->ed->seqbase, clear_scene_in_allseqs_fn, scene);
- }
- }
-}
-
-typedef struct SeqUniqueInfo {
- Sequence *seq;
- char name_src[SEQ_NAME_MAXSTR];
- char name_dest[SEQ_NAME_MAXSTR];
- int count;
- int match;
-} SeqUniqueInfo;
-
-static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui)
-{
- Sequence *seq;
- for (seq = seqbasep->first; seq; seq = seq->next) {
- if ((sui->seq != seq) && STREQ(sui->name_dest, seq->name + 2)) {
- /* SEQ_NAME_MAXSTR -4 for the number, -1 for \0, - 2 for r_prefix */
- BLI_snprintf(sui->name_dest,
- sizeof(sui->name_dest),
- "%.*s.%03d",
- SEQ_NAME_MAXSTR - 4 - 1 - 2,
- sui->name_src,
- sui->count++);
- sui->match = 1; /* be sure to re-scan */
- }
- }
-}
-
-static int seqbase_unique_name_recursive_fn(Sequence *seq, void *arg_pt)
-{
- if (seq->seqbase.first) {
- seqbase_unique_name(&seq->seqbase, (SeqUniqueInfo *)arg_pt);
- }
- return 1;
-}
-
-void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, Sequence *seq)
-{
- SeqUniqueInfo sui;
- char *dot;
- sui.seq = seq;
- BLI_strncpy(sui.name_src, seq->name + 2, sizeof(sui.name_src));
- BLI_strncpy(sui.name_dest, seq->name + 2, sizeof(sui.name_dest));
-
- sui.count = 1;
- sui.match = 1; /* assume the worst to start the loop */
-
- /* Strip off the suffix */
- if ((dot = strrchr(sui.name_src, '.'))) {
- *dot = '\0';
- dot++;
-
- if (*dot) {
- sui.count = atoi(dot) + 1;
- }
- }
-
- while (sui.match) {
- sui.match = 0;
- seqbase_unique_name(seqbasep, &sui);
- BKE_sequencer_base_recursive_apply(seqbasep, seqbase_unique_name_recursive_fn, &sui);
- }
-
- BLI_strncpy(seq->name + 2, sui.name_dest, sizeof(seq->name) - 2);
-}
-
-static const char *give_seqname_by_type(int type)
-{
- switch (type) {
- case SEQ_TYPE_META:
- return "Meta";
- case SEQ_TYPE_IMAGE:
- return "Image";
- case SEQ_TYPE_SCENE:
- return "Scene";
- case SEQ_TYPE_MOVIE:
- return "Movie";
- case SEQ_TYPE_MOVIECLIP:
- return "Clip";
- case SEQ_TYPE_MASK:
- return "Mask";
- case SEQ_TYPE_SOUND_RAM:
- return "Audio";
- case SEQ_TYPE_CROSS:
- return "Cross";
- case SEQ_TYPE_GAMCROSS:
- return "Gamma Cross";
- case SEQ_TYPE_ADD:
- return "Add";
- case SEQ_TYPE_SUB:
- return "Sub";
- case SEQ_TYPE_MUL:
- return "Mul";
- case SEQ_TYPE_ALPHAOVER:
- return "Alpha Over";
- case SEQ_TYPE_ALPHAUNDER:
- return "Alpha Under";
- case SEQ_TYPE_OVERDROP:
- return "Over Drop";
- case SEQ_TYPE_COLORMIX:
- return "Color Mix";
- case SEQ_TYPE_WIPE:
- return "Wipe";
- case SEQ_TYPE_GLOW:
- return "Glow";
- case SEQ_TYPE_TRANSFORM:
- return "Transform";
- case SEQ_TYPE_COLOR:
- return "Color";
- case SEQ_TYPE_MULTICAM:
- return "Multicam";
- case SEQ_TYPE_ADJUSTMENT:
- return "Adjustment";
- case SEQ_TYPE_SPEED:
- return "Speed";
- case SEQ_TYPE_GAUSSIAN_BLUR:
- return "Gaussian Blur";
- case SEQ_TYPE_TEXT:
- return "Text";
- default:
- return NULL;
- }
-}
-
-const char *BKE_sequence_give_name(Sequence *seq)
-{
- const char *name = give_seqname_by_type(seq->type);
-
- if (!name) {
- if (!(seq->type & SEQ_TYPE_EFFECT)) {
- return seq->strip->dir;
- }
-
- return "Effect";
- }
- return name;
-}
-
-ListBase *BKE_sequence_seqbase_get(Sequence *seq, int *r_offset)
-{
- ListBase *seqbase = NULL;
-
- switch (seq->type) {
- case SEQ_TYPE_META: {
- seqbase = &seq->seqbase;
- *r_offset = seq->start;
- break;
- }
- case SEQ_TYPE_SCENE: {
- if (seq->flag & SEQ_SCENE_STRIPS && seq->scene) {
- Editing *ed = BKE_sequencer_editing_get(seq->scene, false);
- if (ed) {
- seqbase = &ed->seqbase;
- *r_offset = seq->scene->r.sfra;
- }
- }
- break;
- }
- }
-
- return seqbase;
-}
-
-/*********************** DO THE SEQUENCE *************************/
-
-static void multibuf(ImBuf *ibuf, const float fmul)
-{
- char *rt;
- float *rt_float;
-
- int a;
-
- rt = (char *)ibuf->rect;
- rt_float = ibuf->rect_float;
-
- if (rt) {
- const int imul = (int)(256.0f * fmul);
- a = ibuf->x * ibuf->y;
- while (a--) {
- rt[0] = min_ii((imul * rt[0]) >> 8, 255);
- rt[1] = min_ii((imul * rt[1]) >> 8, 255);
- rt[2] = min_ii((imul * rt[2]) >> 8, 255);
- rt[3] = min_ii((imul * rt[3]) >> 8, 255);
-
- rt += 4;
- }
- }
- if (rt_float) {
- a = ibuf->x * ibuf->y;
- while (a--) {
- rt_float[0] *= fmul;
- rt_float[1] *= fmul;
- rt_float[2] *= fmul;
- rt_float[3] *= fmul;
-
- rt_float += 4;
- }
- }
-}
-
-float BKE_sequencer_give_stripelem_index(Sequence *seq, float cfra)
+static void seq_new_fix_links_recursive(Sequence *seq)
{
- float nr;
- int sta = seq->start;
- int end = seq->start + seq->len - 1;
+ SequenceModifierData *smd;
if (seq->type & SEQ_TYPE_EFFECT) {
- end = seq->enddisp;
- }
-
- if (end < sta) {
- return -1;
- }
-
- if (seq->flag & SEQ_REVERSE_FRAMES) {
- /*reverse frame in this sequence */
- if (cfra <= sta) {
- nr = end - sta;
- }
- else if (cfra >= end) {
- nr = 0;
- }
- else {
- nr = end - cfra;
- }
- }
- else {
- if (cfra <= sta) {
- nr = 0;
- }
- else if (cfra >= end) {
- nr = end - sta;
- }
- else {
- nr = cfra - sta;
- }
- }
-
- if (seq->strobe < 1.0f) {
- seq->strobe = 1.0f;
- }
-
- if (seq->strobe > 1.0f) {
- nr -= fmodf((double)nr, (double)seq->strobe);
- }
-
- return nr;
-}
-
-StripElem *BKE_sequencer_give_stripelem(Sequence *seq, int cfra)
-{
- StripElem *se = seq->strip->stripdata;
-
- if (seq->type == SEQ_TYPE_IMAGE) {
- /* only IMAGE strips use the whole array, MOVIE strips use only the first element,
- * all other strips don't use this...
- */
-
- int nr = (int)BKE_sequencer_give_stripelem_index(seq, cfra);
-
- if (nr == -1 || se == NULL) {
- return NULL;
- }
-
- se += nr + seq->anim_startofs;
- }
- return se;
-}
-
-static int evaluate_seq_frame_gen(Sequence **seq_arr, ListBase *seqbase, int cfra, int chanshown)
-{
- /* Use arbitrary sized linked list, the size could be over MAXSEQ. */
- LinkNodePair effect_inputs = {NULL, NULL};
- int totseq = 0;
-
- memset(seq_arr, 0, sizeof(Sequence *) * (MAXSEQ + 1));
-
- LISTBASE_FOREACH (Sequence *, seq, seqbase) {
- if ((seq->startdisp <= cfra) && (seq->enddisp > cfra)) {
- if ((seq->type & SEQ_TYPE_EFFECT) && !(seq->flag & SEQ_MUTE)) {
-
- if (seq->seq1) {
- BLI_linklist_append_alloca(&effect_inputs, seq->seq1);
- }
-
- if (seq->seq2) {
- BLI_linklist_append_alloca(&effect_inputs, seq->seq2);
- }
-
- if (seq->seq3) {
- BLI_linklist_append_alloca(&effect_inputs, seq->seq3);
- }
- }
-
- seq_arr[seq->machine] = seq;
- totseq++;
- }
- }
-
- /* Drop strips which are used for effect inputs, we don't want
- * them to blend into render stack in any other way than effect
- * string rendering. */
- for (LinkNode *seq_item = effect_inputs.list; seq_item; seq_item = seq_item->next) {
- Sequence *seq = seq_item->link;
- /* It's possible that effect strip would be placed to the same
- * 'machine' as its inputs. We don't want to clear such strips
- * from the stack. */
- if (seq_arr[seq->machine] && seq_arr[seq->machine]->type & SEQ_TYPE_EFFECT) {
- continue;
- }
- /* If we're shown a specified channel, then we want to see the strips
- * which belongs to this machine. */
- if (chanshown != 0 && chanshown <= seq->machine) {
- continue;
- }
- seq_arr[seq->machine] = NULL;
- }
-
- return totseq;
-}
-
-int BKE_sequencer_evaluate_frame(Scene *scene, int cfra)
-{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq_arr[MAXSEQ + 1];
-
- if (ed == NULL) {
- return 0;
- }
-
- return evaluate_seq_frame_gen(seq_arr, ed->seqbasep, cfra, 0);
-}
-
-static bool video_seq_is_rendered(Sequence *seq)
-{
- return (seq && !(seq->flag & SEQ_MUTE) && seq->type != SEQ_TYPE_SOUND_RAM);
-}
-
-int BKE_sequencer_get_shown_sequences(ListBase *seqbasep,
- int cfra,
- int chanshown,
- Sequence **seq_arr_out)
-{
- Sequence *seq_arr[MAXSEQ + 1];
- int b = chanshown;
- int cnt = 0;
-
- if (b > MAXSEQ) {
- return 0;
- }
-
- if (evaluate_seq_frame_gen(seq_arr, seqbasep, cfra, chanshown)) {
- if (b == 0) {
- b = MAXSEQ;
- }
- for (; b > 0; b--) {
- if (video_seq_is_rendered(seq_arr[b])) {
- break;
- }
- }
- }
-
- chanshown = b;
-
- for (; b > 0; b--) {
- if (video_seq_is_rendered(seq_arr[b])) {
- if (seq_arr[b]->blend_mode == SEQ_BLEND_REPLACE) {
- break;
- }
- }
- }
-
- for (; b <= chanshown && b >= 0; b++) {
- if (video_seq_is_rendered(seq_arr[b])) {
- seq_arr_out[cnt++] = seq_arr[b];
- }
- }
-
- return cnt;
-}
-
-/*********************** proxy management *************************/
-
-typedef struct SeqIndexBuildContext {
- struct IndexBuildContext *index_context;
-
- int tc_flags;
- int size_flags;
- int quality;
- bool overwrite;
- int view_id;
-
- Main *bmain;
- Depsgraph *depsgraph;
- Scene *scene;
- Sequence *seq, *orig_seq;
-} SeqIndexBuildContext;
-
-#define PROXY_MAXFILE (2 * FILE_MAXDIR + FILE_MAXFILE)
-
-static IMB_Proxy_Size seq_rendersize_to_proxysize(int render_size)
-{
- switch (render_size) {
- case SEQ_RENDER_SIZE_PROXY_25:
- return IMB_PROXY_25;
- case SEQ_RENDER_SIZE_PROXY_50:
- return IMB_PROXY_50;
- case SEQ_RENDER_SIZE_PROXY_75:
- return IMB_PROXY_75;
- case SEQ_RENDER_SIZE_PROXY_100:
- return IMB_PROXY_100;
- }
- return IMB_PROXY_NONE;
-}
-
-double BKE_sequencer_rendersize_to_scale_factor(int render_size)
-{
- switch (render_size) {
- case SEQ_RENDER_SIZE_PROXY_25:
- return 0.25;
- case SEQ_RENDER_SIZE_PROXY_50:
- return 0.50;
- case SEQ_RENDER_SIZE_PROXY_75:
- return 0.75;
- }
- return 1.0;
-}
-
-/* the number of files will vary according to the stereo format */
-static int seq_num_files(Scene *scene, char views_format, const bool is_multiview)
-{
- if (!is_multiview) {
- return 1;
- }
- if (views_format == R_IMF_VIEWS_STEREO_3D) {
- return 1;
- }
- /* R_IMF_VIEWS_INDIVIDUAL */
-
- return BKE_scene_multiview_num_views_get(&scene->r);
-}
-
-static void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir)
-{
- char dir[FILE_MAX];
- char fname[FILE_MAXFILE];
-
- IMB_anim_get_fname(anim, fname, FILE_MAXFILE);
- BLI_strncpy(dir, base_dir, sizeof(dir));
- BLI_path_append(dir, sizeof(dir), fname);
- IMB_anim_set_index_dir(anim, dir);
-}
-
-static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile)
-{
- char dir[FILE_MAX];
- char name[FILE_MAX];
- StripProxy *proxy;
- bool use_proxy;
- bool is_multiview_loaded = false;
- Editing *ed = scene->ed;
- const bool is_multiview = (seq->flag & SEQ_USE_VIEWS) != 0 &&
- (scene->r.scemode & R_MULTIVIEW) != 0;
-
- if ((seq->anims.first != NULL) && (((StripAnim *)seq->anims.first)->anim != NULL)) {
- return;
- }
-
- /* reset all the previously created anims */
- BKE_sequence_free_anim(seq);
-
- BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name);
- BLI_path_abs(name, BKE_main_blendfile_path_from_global());
-
- proxy = seq->strip->proxy;
-
- use_proxy = proxy && ((proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_DIR) != 0 ||
- (ed->proxy_storage == SEQ_EDIT_PROXY_DIR_STORAGE));
-
- if (use_proxy) {
- if (ed->proxy_storage == SEQ_EDIT_PROXY_DIR_STORAGE) {
- if (ed->proxy_dir[0] == 0) {
- BLI_strncpy(dir, "//BL_proxy", sizeof(dir));
- }
- else {
- BLI_strncpy(dir, ed->proxy_dir, sizeof(dir));
- }
- }
- else {
- BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir));
- }
- BLI_path_abs(dir, BKE_main_blendfile_path_from_global());
- }
-
- if (is_multiview && seq->views_format == R_IMF_VIEWS_INDIVIDUAL) {
- int totfiles = seq_num_files(scene, seq->views_format, true);
- char prefix[FILE_MAX];
- const char *ext = NULL;
- int i;
-
- BKE_scene_multiview_view_prefix_get(scene, name, prefix, &ext);
-
- if (prefix[0] != '\0') {
- for (i = 0; i < totfiles; i++) {
- const char *suffix = BKE_scene_multiview_view_id_suffix_get(&scene->r, i);
- char str[FILE_MAX];
- StripAnim *sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
-
- BLI_addtail(&seq->anims, sanim);
-
- BLI_snprintf(str, sizeof(str), "%s%s%s", prefix, suffix, ext);
-
- if (openfile) {
- sanim->anim = openanim(str,
- IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
- seq->streamindex,
- seq->strip->colorspace_settings.name);
- }
- else {
- sanim->anim = openanim_noload(str,
- IB_rect |
- ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
- seq->streamindex,
- seq->strip->colorspace_settings.name);
- }
-
- if (sanim->anim) {
- /* we already have the suffix */
- IMB_suffix_anim(sanim->anim, suffix);
- }
- else {
- if (openfile) {
- sanim->anim = openanim(name,
- IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
- seq->streamindex,
- seq->strip->colorspace_settings.name);
- }
- else {
- sanim->anim = openanim_noload(name,
- IB_rect |
- ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
- seq->streamindex,
- seq->strip->colorspace_settings.name);
- }
-
- /* No individual view files - monoscopic, stereo 3d or EXR multi-view. */
- totfiles = 1;
- }
-
- if (sanim->anim && use_proxy) {
- seq_proxy_index_dir_set(sanim->anim, dir);
- }
- }
- is_multiview_loaded = true;
- }
- }
-
- if (is_multiview_loaded == false) {
- StripAnim *sanim;
-
- sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
- BLI_addtail(&seq->anims, sanim);
-
- if (openfile) {
- sanim->anim = openanim(name,
- IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
- seq->streamindex,
- seq->strip->colorspace_settings.name);
- }
- else {
- sanim->anim = openanim_noload(name,
- IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
- seq->streamindex,
- seq->strip->colorspace_settings.name);
- }
-
- if (sanim->anim && use_proxy) {
- seq_proxy_index_dir_set(sanim->anim, dir);
- }
- }
-}
-
-static bool seq_proxy_get_custom_file_fname(Sequence *seq, char *name, const int view_id)
-{
- char fname[FILE_MAXFILE];
- char suffix[24];
- StripProxy *proxy = seq->strip->proxy;
-
- if (proxy == NULL) {
- return false;
- }
-
- BLI_join_dirfile(fname, PROXY_MAXFILE, proxy->dir, proxy->file);
- BLI_path_abs(fname, BKE_main_blendfile_path_from_global());
-
- if (view_id > 0) {
- BLI_snprintf(suffix, sizeof(suffix), "_%d", view_id);
- /* TODO(sergey): This will actually append suffix after extension
- * which is weird but how was originally coded in multi-view branch.
- */
- BLI_snprintf(name, PROXY_MAXFILE, "%s_%s", fname, suffix);
- }
- else {
- BLI_strncpy(name, fname, PROXY_MAXFILE);
- }
-
- return true;
-}
-
-static bool seq_proxy_get_fname(Editing *ed,
- Sequence *seq,
- int cfra,
- eSpaceSeq_Proxy_RenderSize render_size,
- char *name,
- const int view_id)
-{
- char dir[PROXY_MAXFILE];
- char suffix[24] = {'\0'};
- StripProxy *proxy = seq->strip->proxy;
-
- if (proxy == NULL) {
- return false;
- }
-
- /* Multi-view suffix. */
- if (view_id > 0) {
- BLI_snprintf(suffix, sizeof(suffix), "_%d", view_id);
- }
-
- /* Per strip with Custom file situation is handled separately. */
- if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE &&
- ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE) {
- if (seq_proxy_get_custom_file_fname(seq, name, view_id)) {
- return true;
- }
- }
-
- if (ed->proxy_storage == SEQ_EDIT_PROXY_DIR_STORAGE) {
- /* Per project default. */
- if (ed->proxy_dir[0] == 0) {
- BLI_strncpy(dir, "//BL_proxy", sizeof(dir));
- }
- else { /* Per project with custom dir. */
- BLI_strncpy(dir, ed->proxy_dir, sizeof(dir));
- }
- BLI_path_abs(name, BKE_main_blendfile_path_from_global());
- }
- else {
- /* Pre strip with custom dir. */
- if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_DIR) {
- BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir));
- }
- else { /* Per strip default. */
- BLI_snprintf(dir, PROXY_MAXFILE, "%s/BL_proxy", seq->strip->dir);
- }
- }
-
- /* Proxy size number to be used in path. */
- int proxy_size_number = BKE_sequencer_rendersize_to_scale_factor(render_size) * 100;
-
- BLI_snprintf(name,
- PROXY_MAXFILE,
- "%s/images/%d/%s_proxy%s",
- dir,
- proxy_size_number,
- BKE_sequencer_give_stripelem(seq, cfra)->name,
- suffix);
- BLI_path_abs(name, BKE_main_blendfile_path_from_global());
- strcat(name, ".jpg");
-
- return true;
-}
-
-static bool seq_can_use_proxy(Sequence *seq, IMB_Proxy_Size psize)
-{
- if (seq->strip->proxy == NULL) {
- return false;
- }
- short size_flags = seq->strip->proxy->build_size_flags;
- return (seq->flag & SEQ_USE_PROXY) != 0 && psize != IMB_PROXY_NONE && (size_flags & psize) != 0;
-}
-
-static ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int cfra)
-{
- char name[PROXY_MAXFILE];
- StripProxy *proxy = seq->strip->proxy;
- const eSpaceSeq_Proxy_RenderSize psize = context->preview_render_size;
- Editing *ed = context->scene->ed;
- StripAnim *sanim;
-
- /* only use proxies, if they are enabled (even if present!) */
- if (!seq_can_use_proxy(seq, seq_rendersize_to_proxysize(psize))) {
- return NULL;
- }
-
- if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) {
- int frameno = (int)BKE_sequencer_give_stripelem_index(seq, cfra) + seq->anim_startofs;
- if (proxy->anim == NULL) {
- if (seq_proxy_get_fname(ed, seq, cfra, psize, name, context->view_id) == 0) {
- return NULL;
- }
-
- proxy->anim = openanim(name, IB_rect, 0, seq->strip->colorspace_settings.name);
- }
- if (proxy->anim == NULL) {
- return NULL;
- }
-
- seq_open_anim_file(context->scene, seq, true);
- sanim = seq->anims.first;
-
- frameno = IMB_anim_index_get_frame_index(
- sanim ? sanim->anim : NULL, seq->strip->proxy->tc, frameno);
-
- return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE);
- }
-
- if (seq_proxy_get_fname(ed, seq, cfra, psize, name, context->view_id) == 0) {
- return NULL;
- }
-
- if (BLI_exists(name)) {
- ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL);
-
- if (ibuf) {
- sequencer_imbuf_assign_spaces(context->scene, ibuf);
- }
-
- return ibuf;
- }
-
- return NULL;
-}
-
-static void seq_proxy_build_frame(const SeqRenderData *context,
- SeqRenderState *state,
- Sequence *seq,
- int cfra,
- int proxy_render_size,
- const bool overwrite)
-{
- char name[PROXY_MAXFILE];
- int quality;
- int rectx, recty;
- int ok;
- ImBuf *ibuf_tmp, *ibuf;
- Editing *ed = context->scene->ed;
-
- if (!seq_proxy_get_fname(ed, seq, cfra, proxy_render_size, name, context->view_id)) {
- return;
- }
-
- if (!overwrite && BLI_exists(name)) {
- return;
- }
-
- ibuf_tmp = seq_render_strip(context, state, seq, cfra);
-
- rectx = (proxy_render_size * ibuf_tmp->x) / 100;
- recty = (proxy_render_size * ibuf_tmp->y) / 100;
-
- if (ibuf_tmp->x != rectx || ibuf_tmp->y != recty) {
- ibuf = IMB_dupImBuf(ibuf_tmp);
- IMB_metadata_copy(ibuf, ibuf_tmp);
- IMB_freeImBuf(ibuf_tmp);
- IMB_scalefastImBuf(ibuf, (short)rectx, (short)recty);
- }
- else {
- ibuf = ibuf_tmp;
- }
-
- /* depth = 32 is intentionally left in, otherwise ALPHA channels
- * won't work... */
- quality = seq->strip->proxy->quality;
- ibuf->ftype = IMB_FTYPE_JPG;
- ibuf->foptions.quality = quality;
-
- /* unsupported feature only confuses other s/w */
- if (ibuf->planes == 32) {
- ibuf->planes = 24;
- }
-
- BLI_make_existing_file(name);
-
- ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
- if (ok == 0) {
- perror(name);
- }
-
- IMB_freeImBuf(ibuf);
-}
-
-/**
- * Returns whether the file this context would read from even exist,
- * if not, don't create the context
- */
-static bool seq_proxy_multiview_context_invalid(Sequence *seq, Scene *scene, const int view_id)
-{
- if ((scene->r.scemode & R_MULTIVIEW) == 0) {
- return false;
- }
-
- if ((seq->type == SEQ_TYPE_IMAGE) && (seq->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
- static char prefix[FILE_MAX];
- static const char *ext = NULL;
- char str[FILE_MAX];
-
- if (view_id == 0) {
- char path[FILE_MAX];
- BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name);
- BLI_path_abs(path, BKE_main_blendfile_path_from_global());
- BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext);
- }
- else {
- prefix[0] = '\0';
- }
-
- if (prefix[0] == '\0') {
- return view_id != 0;
- }
-
- seq_multiview_name(scene, view_id, prefix, ext, str, FILE_MAX);
-
- if (BLI_access(str, R_OK) == 0) {
- return false;
- }
-
- return view_id != 0;
- }
- return false;
-}
-
-/**
- * This returns the maximum possible number of required contexts
- */
-static int seq_proxy_context_count(Sequence *seq, Scene *scene)
-{
- int num_views = 1;
-
- if ((scene->r.scemode & R_MULTIVIEW) == 0) {
- return 1;
- }
-
- switch (seq->type) {
- case SEQ_TYPE_MOVIE: {
- num_views = BLI_listbase_count(&seq->anims);
- break;
- }
- case SEQ_TYPE_IMAGE: {
- switch (seq->views_format) {
- case R_IMF_VIEWS_INDIVIDUAL:
- num_views = BKE_scene_multiview_num_views_get(&scene->r);
- break;
- case R_IMF_VIEWS_STEREO_3D:
- num_views = 2;
- break;
- case R_IMF_VIEWS_MULTIVIEW:
- /* not supported at the moment */
- /* pass through */
- default:
- num_views = 1;
- }
- break;
- }
- }
-
- return num_views;
-}
-
-bool BKE_sequencer_proxy_rebuild_context(Main *bmain,
- Depsgraph *depsgraph,
- Scene *scene,
- Sequence *seq,
- struct GSet *file_list,
- ListBase *queue)
-{
- SeqIndexBuildContext *context;
- Sequence *nseq;
- LinkData *link;
- int num_files;
- int i;
-
- if (!seq->strip || !seq->strip->proxy) {
- return true;
- }
-
- if (!(seq->flag & SEQ_USE_PROXY)) {
- return true;
- }
-
- num_files = seq_proxy_context_count(seq, scene);
-
- for (i = 0; i < num_files; i++) {
- if (seq_proxy_multiview_context_invalid(seq, scene, i)) {
- continue;
- }
-
- context = MEM_callocN(sizeof(SeqIndexBuildContext), "seq proxy rebuild context");
-
- nseq = BKE_sequence_dupli_recursive(scene, scene, NULL, seq, 0);
-
- context->tc_flags = nseq->strip->proxy->build_tc_flags;
- context->size_flags = nseq->strip->proxy->build_size_flags;
- context->quality = nseq->strip->proxy->quality;
- context->overwrite = (nseq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) == 0;
-
- context->bmain = bmain;
- context->depsgraph = depsgraph;
- context->scene = scene;
- context->orig_seq = seq;
- context->seq = nseq;
-
- context->view_id = i; /* only for images */
-
- if (nseq->type == SEQ_TYPE_MOVIE) {
- StripAnim *sanim;
-
- seq_open_anim_file(scene, nseq, true);
- sanim = BLI_findlink(&nseq->anims, i);
-
- if (sanim->anim) {
- context->index_context = IMB_anim_index_rebuild_context(sanim->anim,
- context->tc_flags,
- context->size_flags,
- context->quality,
- context->overwrite,
- file_list);
- }
- if (!context->index_context) {
- MEM_freeN(context);
- return false;
- }
- }
-
- link = BLI_genericNodeN(context);
- BLI_addtail(queue, link);
- }
- return true;
-}
-
-void BKE_sequencer_proxy_rebuild(SeqIndexBuildContext *context,
- short *stop,
- short *do_update,
- float *progress)
-{
- const bool overwrite = context->overwrite;
- SeqRenderData render_context;
- Sequence *seq = context->seq;
- Scene *scene = context->scene;
- Main *bmain = context->bmain;
- int cfra;
-
- if (seq->type == SEQ_TYPE_MOVIE) {
- if (context->index_context) {
- IMB_anim_index_rebuild(context->index_context, stop, do_update, progress);
- }
-
- return;
- }
-
- if (!(seq->flag & SEQ_USE_PROXY)) {
- return;
- }
-
- /* that's why it is called custom... */
- if (seq->strip->proxy && seq->strip->proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) {
- return;
- }
-
- /* fail safe code */
-
- BKE_sequencer_new_render_data(bmain,
- context->depsgraph,
- context->scene,
- roundf((scene->r.size * (float)scene->r.xsch) / 100.0f),
- roundf((scene->r.size * (float)scene->r.ysch) / 100.0f),
- 100,
- false,
- &render_context);
-
- render_context.skip_cache = true;
- render_context.is_proxy_render = true;
- render_context.view_id = context->view_id;
-
- SeqRenderState state;
- sequencer_state_init(&state);
-
- for (cfra = seq->startdisp + seq->startstill; cfra < seq->enddisp - seq->endstill; cfra++) {
- if (context->size_flags & IMB_PROXY_25) {
- seq_proxy_build_frame(&render_context, &state, seq, cfra, 25, overwrite);
- }
- if (context->size_flags & IMB_PROXY_50) {
- seq_proxy_build_frame(&render_context, &state, seq, cfra, 50, overwrite);
- }
- if (context->size_flags & IMB_PROXY_75) {
- seq_proxy_build_frame(&render_context, &state, seq, cfra, 75, overwrite);
- }
- if (context->size_flags & IMB_PROXY_100) {
- seq_proxy_build_frame(&render_context, &state, seq, cfra, 100, overwrite);
- }
-
- *progress = (float)(cfra - seq->startdisp - seq->startstill) /
- (seq->enddisp - seq->endstill - seq->startdisp - seq->startstill);
- *do_update = true;
-
- if (*stop || G.is_break) {
- break;
- }
- }
-}
-
-void BKE_sequencer_proxy_rebuild_finish(SeqIndexBuildContext *context, bool stop)
-{
- if (context->index_context) {
- StripAnim *sanim;
-
- for (sanim = context->seq->anims.first; sanim; sanim = sanim->next) {
- IMB_close_anim_proxies(sanim->anim);
- }
-
- for (sanim = context->orig_seq->anims.first; sanim; sanim = sanim->next) {
- IMB_close_anim_proxies(sanim->anim);
- }
-
- IMB_anim_index_rebuild_finish(context->index_context, stop);
- }
-
- seq_free_sequence_recurse(NULL, context->seq, true);
-
- MEM_freeN(context);
-}
-
-void BKE_sequencer_proxy_set(struct Sequence *seq, bool value)
-{
- if (value) {
- seq->flag |= SEQ_USE_PROXY;
- if (seq->strip->proxy == NULL) {
- seq->strip->proxy = MEM_callocN(sizeof(struct StripProxy), "StripProxy");
- seq->strip->proxy->quality = 90;
- seq->strip->proxy->build_tc_flags = SEQ_PROXY_TC_ALL;
- seq->strip->proxy->build_size_flags = SEQ_PROXY_IMAGE_SIZE_25;
- }
- }
- else {
- seq->flag &= ~SEQ_USE_PROXY;
- }
-}
-
-/*********************** color balance *************************/
-
-static StripColorBalance calc_cb(StripColorBalance *cb_)
-{
- StripColorBalance cb = *cb_;
- int c;
-
- for (c = 0; c < 3; c++) {
- cb.lift[c] = 2.0f - cb.lift[c];
- }
-
- if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) {
- for (c = 0; c < 3; c++) {
- /* tweak to give more subtle results
- * values above 1.0 are scaled */
- if (cb.lift[c] > 1.0f) {
- cb.lift[c] = pow(cb.lift[c] - 1.0f, 2.0) + 1.0;
- }
-
- cb.lift[c] = 2.0f - cb.lift[c];
- }
- }
-
- if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAIN) {
- for (c = 0; c < 3; c++) {
- if (cb.gain[c] != 0.0f) {
- cb.gain[c] = 1.0f / cb.gain[c];
- }
- else {
- cb.gain[c] = 1000000; /* should be enough :) */
- }
- }
- }
-
- if (!(cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAMMA)) {
- for (c = 0; c < 3; c++) {
- if (cb.gamma[c] != 0.0f) {
- cb.gamma[c] = 1.0f / cb.gamma[c];
- }
- else {
- cb.gamma[c] = 1000000; /* should be enough :) */
- }
- }
- }
-
- return cb;
-}
-
-/* note: lift is actually 2-lift */
-MINLINE float color_balance_fl(
- float in, const float lift, const float gain, const float gamma, const float mul)
-{
- float x = (((in - 1.0f) * lift) + 1.0f) * gain;
-
- /* prevent NaN */
- if (x < 0.f) {
- x = 0.f;
- }
-
- x = powf(x, gamma) * mul;
- CLAMP(x, FLT_MIN, FLT_MAX);
- return x;
-}
-
-static void make_cb_table_float(float lift, float gain, float gamma, float *table, float mul)
-{
- int y;
-
- for (y = 0; y < 256; y++) {
- float v = color_balance_fl((float)y * (1.0f / 255.0f), lift, gain, gamma, mul);
-
- table[y] = v;
- }
-}
-
-static void color_balance_byte_byte(StripColorBalance *cb_,
- unsigned char *rect,
- unsigned char *mask_rect,
- int width,
- int height,
- float mul)
-{
- // unsigned char cb_tab[3][256];
- unsigned char *cp = rect;
- unsigned char *e = cp + width * 4 * height;
- unsigned char *m = mask_rect;
-
- StripColorBalance cb = calc_cb(cb_);
-
- while (cp < e) {
- float p[4];
- int c;
-
- straight_uchar_to_premul_float(p, cp);
-
- for (c = 0; c < 3; c++) {
- float t = color_balance_fl(p[c], cb.lift[c], cb.gain[c], cb.gamma[c], mul);
-
- if (m) {
- float m_normal = (float)m[c] / 255.0f;
-
- p[c] = p[c] * (1.0f - m_normal) + t * m_normal;
- }
- else {
- p[c] = t;
- }
- }
-
- premul_float_to_straight_uchar(cp, p);
-
- cp += 4;
- if (m) {
- m += 4;
- }
- }
-}
-
-static void color_balance_byte_float(StripColorBalance *cb_,
- unsigned char *rect,
- float *rect_float,
- unsigned char *mask_rect,
- int width,
- int height,
- float mul)
-{
- float cb_tab[4][256];
- int c, i;
- unsigned char *p = rect;
- unsigned char *e = p + width * 4 * height;
- unsigned char *m = mask_rect;
- float *o;
- StripColorBalance cb;
-
- o = rect_float;
-
- cb = calc_cb(cb_);
-
- for (c = 0; c < 3; c++) {
- make_cb_table_float(cb.lift[c], cb.gain[c], cb.gamma[c], cb_tab[c], mul);
- }
-
- for (i = 0; i < 256; i++) {
- cb_tab[3][i] = ((float)i) * (1.0f / 255.0f);
- }
-
- while (p < e) {
- if (m) {
- const float t[3] = {m[0] / 255.0f, m[1] / 255.0f, m[2] / 255.0f};
-
- p[0] = p[0] * (1.0f - t[0]) + t[0] * cb_tab[0][p[0]];
- p[1] = p[1] * (1.0f - t[1]) + t[1] * cb_tab[1][p[1]];
- p[2] = p[2] * (1.0f - t[2]) + t[2] * cb_tab[2][p[2]];
-
- m += 4;
- }
- else {
- o[0] = cb_tab[0][p[0]];
- o[1] = cb_tab[1][p[1]];
- o[2] = cb_tab[2][p[2]];
- }
-
- o[3] = cb_tab[3][p[3]];
-
- p += 4;
- o += 4;
- }
-}
-
-static void color_balance_float_float(StripColorBalance *cb_,
- float *rect_float,
- const float *mask_rect_float,
- int width,
- int height,
- float mul)
-{
- float *p = rect_float;
- const float *e = rect_float + width * 4 * height;
- const float *m = mask_rect_float;
- StripColorBalance cb = calc_cb(cb_);
-
- while (p < e) {
- int c;
- for (c = 0; c < 3; c++) {
- float t = color_balance_fl(p[c], cb.lift[c], cb.gain[c], cb.gamma[c], mul);
-
- if (m) {
- p[c] = p[c] * (1.0f - m[c]) + t * m[c];
- }
- else {
- p[c] = t;
- }
- }
-
- p += 4;
- if (m) {
- m += 4;
- }
- }
-}
-
-typedef struct ColorBalanceInitData {
- StripColorBalance *cb;
- ImBuf *ibuf;
- float mul;
- ImBuf *mask;
- bool make_float;
-} ColorBalanceInitData;
-
-typedef struct ColorBalanceThread {
- StripColorBalance *cb;
- float mul;
-
- int width, height;
-
- unsigned char *rect, *mask_rect;
- float *rect_float, *mask_rect_float;
-
- bool make_float;
-} ColorBalanceThread;
-
-static void color_balance_init_handle(void *handle_v,
- int start_line,
- int tot_line,
- void *init_data_v)
-{
- ColorBalanceThread *handle = (ColorBalanceThread *)handle_v;
- ColorBalanceInitData *init_data = (ColorBalanceInitData *)init_data_v;
- ImBuf *ibuf = init_data->ibuf;
- ImBuf *mask = init_data->mask;
-
- int offset = 4 * start_line * ibuf->x;
-
- memset(handle, 0, sizeof(ColorBalanceThread));
-
- handle->cb = init_data->cb;
- handle->mul = init_data->mul;
- handle->width = ibuf->x;
- handle->height = tot_line;
- handle->make_float = init_data->make_float;
-
- if (ibuf->rect) {
- handle->rect = (unsigned char *)ibuf->rect + offset;
- }
-
- if (ibuf->rect_float) {
- handle->rect_float = ibuf->rect_float + offset;
- }
-
- if (mask) {
- if (mask->rect) {
- handle->mask_rect = (unsigned char *)mask->rect + offset;
- }
-
- if (mask->rect_float) {
- handle->mask_rect_float = mask->rect_float + offset;
- }
- }
- else {
- handle->mask_rect = NULL;
- handle->mask_rect_float = NULL;
- }
-}
-
-static void *color_balance_do_thread(void *thread_data_v)
-{
- ColorBalanceThread *thread_data = (ColorBalanceThread *)thread_data_v;
- StripColorBalance *cb = thread_data->cb;
- int width = thread_data->width, height = thread_data->height;
- unsigned char *rect = thread_data->rect;
- unsigned char *mask_rect = thread_data->mask_rect;
- float *rect_float = thread_data->rect_float;
- float *mask_rect_float = thread_data->mask_rect_float;
- float mul = thread_data->mul;
-
- if (rect_float) {
- color_balance_float_float(cb, rect_float, mask_rect_float, width, height, mul);
- }
- else if (thread_data->make_float) {
- color_balance_byte_float(cb, rect, rect_float, mask_rect, width, height, mul);
- }
- else {
- color_balance_byte_byte(cb, rect, mask_rect, width, height, mul);
- }
-
- return NULL;
-}
-
-/**
- * \a cfra is offset by \a fra_offset only in case we are using a real mask.
- */
-ImBuf *BKE_sequencer_render_mask_input(const SeqRenderData *context,
- int mask_input_type,
- Sequence *mask_sequence,
- Mask *mask_id,
- int cfra,
- int fra_offset,
- bool make_float)
-{
- ImBuf *mask_input = NULL;
-
- if (mask_input_type == SEQUENCE_MASK_INPUT_STRIP) {
- if (mask_sequence) {
- SeqRenderState state;
- sequencer_state_init(&state);
-
- mask_input = seq_render_strip(context, &state, mask_sequence, cfra);
-
- if (make_float) {
- if (!mask_input->rect_float) {
- IMB_float_from_rect(mask_input);
- }
- }
- else {
- if (!mask_input->rect) {
- IMB_rect_from_float(mask_input);
- }
- }
- }
- }
- else if (mask_input_type == SEQUENCE_MASK_INPUT_ID) {
- mask_input = seq_render_mask(context, mask_id, cfra - fra_offset, make_float);
- }
-
- return mask_input;
-}
-
-void BKE_sequencer_color_balance_apply(
- StripColorBalance *cb, ImBuf *ibuf, float mul, bool make_float, ImBuf *mask_input)
-{
- ColorBalanceInitData init_data;
-
- if (!ibuf->rect_float && make_float) {
- imb_addrectfloatImBuf(ibuf);
- }
-
- init_data.cb = cb;
- init_data.ibuf = ibuf;
- init_data.mul = mul;
- init_data.make_float = make_float;
- init_data.mask = mask_input;
-
- IMB_processor_apply_threaded(ibuf->y,
- sizeof(ColorBalanceThread),
- &init_data,
- color_balance_init_handle,
- color_balance_do_thread);
-
- /* color balance either happens on float buffer or byte buffer, but never on both,
- * free byte buffer if there's float buffer since float buffer would be used for
- * color balance in favor of byte buffer
- */
- if (ibuf->rect_float && ibuf->rect) {
- imb_freerectImBuf(ibuf);
- }
-}
-
-/*
- * input preprocessing for SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP and SEQ_TYPE_SCENE
- *
- * Do all the things you can't really do afterwards using sequence effects
- * (read: before rescaling to render resolution has been done)
- *
- * Order is important!
- *
- * - Deinterlace
- * - Crop and transform in image source coordinate space
- * - Flip X + Flip Y (could be done afterwards, backward compatibility)
- * - Promote image to float data (affects pipeline operations afterwards)
- * - Color balance (is most efficient in the byte -> float
- * (future: half -> float should also work fine!)
- * case, if done on load, since we can use lookup tables)
- * - Premultiply
- */
-
-bool BKE_sequencer_input_have_to_preprocess(const SeqRenderData *context,
- Sequence *seq,
- float UNUSED(cfra))
-{
- float mul;
-
- if (context && context->is_proxy_render) {
- return false;
- }
-
- if (seq->flag &
- (SEQ_FILTERY | SEQ_USE_CROP | SEQ_USE_TRANSFORM | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_FLOAT)) {
- return true;
- }
-
- mul = seq->mul;
-
- if (seq->blend_mode == SEQ_BLEND_REPLACE) {
- mul *= seq->blend_opacity / 100.0f;
- }
-
- if (mul != 1.0f) {
- return true;
- }
-
- if (seq->sat != 1.0f) {
- return true;
- }
-
- if (seq->modifiers.first) {
- return true;
- }
-
- return false;
-}
-
-static ImBuf *input_preprocess(const SeqRenderData *context,
- Sequence *seq,
- float cfra,
- ImBuf *ibuf,
- const bool is_proxy_image)
-{
- Scene *scene = context->scene;
- float mul;
-
- ibuf = IMB_makeSingleUser(ibuf);
-
- if ((seq->flag & SEQ_FILTERY) && !ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP)) {
- IMB_filtery(ibuf);
- }
-
- if (seq->flag & (SEQ_USE_CROP | SEQ_USE_TRANSFORM)) {
- StripCrop c = {0};
- StripTransform t = {0};
-
- if (seq->flag & SEQ_USE_CROP && seq->strip->crop) {
- c = *seq->strip->crop;
- }
- if (seq->flag & SEQ_USE_TRANSFORM && seq->strip->transform) {
- t = *seq->strip->transform;
- }
-
- /* Calculate scale factor for current image if needed. */
- double scale_factor, image_scale_factor = 1.0;
- if (context->preview_render_size == SEQ_RENDER_SIZE_SCENE) {
- scale_factor = image_scale_factor = (double)scene->r.size / 100;
- }
- else {
- scale_factor = BKE_sequencer_rendersize_to_scale_factor(context->preview_render_size);
- if (!is_proxy_image) {
- image_scale_factor = scale_factor;
- }
- }
-
- if (image_scale_factor != 1.0) {
- if (context->for_render) {
- IMB_scaleImBuf(ibuf, ibuf->x * image_scale_factor, ibuf->y * image_scale_factor);
- }
- else {
- IMB_scalefastImBuf(ibuf, ibuf->x * image_scale_factor, ibuf->y * image_scale_factor);
- }
- }
-
- t.xofs *= scale_factor;
- t.yofs *= scale_factor;
- c.left *= scale_factor;
- c.right *= scale_factor;
- c.top *= scale_factor;
- c.bottom *= scale_factor;
-
- int sx, sy, dx, dy;
- sx = ibuf->x - c.left - c.right;
- sy = ibuf->y - c.top - c.bottom;
-
- if (seq->flag & SEQ_USE_TRANSFORM) {
- dx = context->rectx;
- dy = context->recty;
- }
- else {
- dx = sx;
- dy = sy;
- }
-
- if (c.top + c.bottom >= ibuf->y || c.left + c.right >= ibuf->x || t.xofs >= dx ||
- t.yofs >= dy) {
- return NULL;
- }
-
- ImBuf *i = IMB_allocImBuf(dx, dy, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
- IMB_rectcpy(i, ibuf, t.xofs, t.yofs, c.left, c.bottom, sx, sy);
- sequencer_imbuf_assign_spaces(scene, i);
- IMB_metadata_copy(i, ibuf);
- IMB_freeImBuf(ibuf);
- ibuf = i;
- }
-
- if (seq->flag & SEQ_FLIPX) {
- IMB_flipx(ibuf);
- }
-
- if (seq->flag & SEQ_FLIPY) {
- IMB_flipy(ibuf);
- }
-
- if (seq->sat != 1.0f) {
- IMB_saturation(ibuf, seq->sat);
- }
-
- mul = seq->mul;
-
- if (seq->blend_mode == SEQ_BLEND_REPLACE) {
- mul *= seq->blend_opacity / 100.0f;
- }
-
- if (seq->flag & SEQ_MAKE_FLOAT) {
- if (!ibuf->rect_float) {
- BKE_sequencer_imbuf_to_sequencer_space(scene, ibuf, true);
- }
-
- if (ibuf->rect) {
- imb_freerectImBuf(ibuf);
- }
- }
-
- if (mul != 1.0f) {
- multibuf(ibuf, mul);
- }
-
- if (ibuf->x != context->rectx || ibuf->y != context->recty) {
- if (context->for_render) {
- IMB_scaleImBuf(ibuf, (short)context->rectx, (short)context->recty);
- }
- else {
- IMB_scalefastImBuf(ibuf, (short)context->rectx, (short)context->recty);
- }
- }
-
- if (seq->modifiers.first) {
- ImBuf *ibuf_new = BKE_sequence_modifier_apply_stack(context, seq, ibuf, cfra);
-
- if (ibuf_new != ibuf) {
- IMB_metadata_copy(ibuf_new, ibuf);
- IMB_freeImBuf(ibuf);
- ibuf = ibuf_new;
- }
- }
-
- return ibuf;
-}
-
-/*********************** strip rendering functions *************************/
-
-typedef struct RenderEffectInitData {
- struct SeqEffectHandle *sh;
- const SeqRenderData *context;
- Sequence *seq;
- float cfra, facf0, facf1;
- ImBuf *ibuf1, *ibuf2, *ibuf3;
-
- ImBuf *out;
-} RenderEffectInitData;
-
-typedef struct RenderEffectThread {
- struct SeqEffectHandle *sh;
- const SeqRenderData *context;
- Sequence *seq;
- float cfra, facf0, facf1;
- ImBuf *ibuf1, *ibuf2, *ibuf3;
-
- ImBuf *out;
- int start_line, tot_line;
-} RenderEffectThread;
-
-static void render_effect_execute_init_handle(void *handle_v,
- int start_line,
- int tot_line,
- void *init_data_v)
-{
- RenderEffectThread *handle = (RenderEffectThread *)handle_v;
- RenderEffectInitData *init_data = (RenderEffectInitData *)init_data_v;
-
- handle->sh = init_data->sh;
- handle->context = init_data->context;
- handle->seq = init_data->seq;
- handle->cfra = init_data->cfra;
- handle->facf0 = init_data->facf0;
- handle->facf1 = init_data->facf1;
- handle->ibuf1 = init_data->ibuf1;
- handle->ibuf2 = init_data->ibuf2;
- handle->ibuf3 = init_data->ibuf3;
- handle->out = init_data->out;
-
- handle->start_line = start_line;
- handle->tot_line = tot_line;
-}
-
-static void *render_effect_execute_do_thread(void *thread_data_v)
-{
- RenderEffectThread *thread_data = (RenderEffectThread *)thread_data_v;
-
- thread_data->sh->execute_slice(thread_data->context,
- thread_data->seq,
- thread_data->cfra,
- thread_data->facf0,
- thread_data->facf1,
- thread_data->ibuf1,
- thread_data->ibuf2,
- thread_data->ibuf3,
- thread_data->start_line,
- thread_data->tot_line,
- thread_data->out);
-
- return NULL;
-}
-
-ImBuf *BKE_sequencer_effect_execute_threaded(struct SeqEffectHandle *sh,
- const SeqRenderData *context,
- Sequence *seq,
- float cfra,
- float facf0,
- float facf1,
- ImBuf *ibuf1,
- ImBuf *ibuf2,
- ImBuf *ibuf3)
-{
- RenderEffectInitData init_data;
- ImBuf *out = sh->init_execution(context, ibuf1, ibuf2, ibuf3);
-
- init_data.sh = sh;
- init_data.context = context;
- init_data.seq = seq;
- init_data.cfra = cfra;
- init_data.facf0 = facf0;
- init_data.facf1 = facf1;
- init_data.ibuf1 = ibuf1;
- init_data.ibuf2 = ibuf2;
- init_data.ibuf3 = ibuf3;
- init_data.out = out;
-
- IMB_processor_apply_threaded(out->y,
- sizeof(RenderEffectThread),
- &init_data,
- render_effect_execute_init_handle,
- render_effect_execute_do_thread);
-
- return out;
-}
-
-static ImBuf *seq_render_effect_strip_impl(const SeqRenderData *context,
- SeqRenderState *state,
- Sequence *seq,
- float cfra)
-{
- Scene *scene = context->scene;
- float fac, facf;
- int early_out;
- int i;
- struct SeqEffectHandle sh = BKE_sequence_get_effect(seq);
- FCurve *fcu = NULL;
- ImBuf *ibuf[3];
- Sequence *input[3];
- ImBuf *out = NULL;
-
- ibuf[0] = ibuf[1] = ibuf[2] = NULL;
-
- input[0] = seq->seq1;
- input[1] = seq->seq2;
- input[2] = seq->seq3;
-
- if (!sh.execute && !(sh.execute_slice && sh.init_execution)) {
- /* effect not supported in this version... */
- out = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
- return out;
- }
-
- if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) {
- sh.get_default_fac(seq, cfra, &fac, &facf);
- facf = fac;
- }
- else {
- fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "effect_fader", 0, NULL);
- if (fcu) {
- fac = facf = evaluate_fcurve(fcu, cfra);
- }
- else {
- fac = facf = seq->effect_fader;
- }
- }
-
- early_out = sh.early_out(seq, fac, facf);
-
- switch (early_out) {
- case EARLY_NO_INPUT:
- out = sh.execute(context, seq, cfra, fac, facf, NULL, NULL, NULL);
- break;
- case EARLY_DO_EFFECT:
- for (i = 0; i < 3; i++) {
- /* Speed effect requires time remapping of `cfra` for input(s). */
- if (input[0] && seq->type == SEQ_TYPE_SPEED) {
- float target_frame = BKE_sequencer_speed_effect_target_frame_get(context, seq, cfra, i);
- ibuf[i] = seq_render_strip(context, state, input[0], target_frame);
- }
- else { /* Other effects. */
- if (input[i]) {
- ibuf[i] = seq_render_strip(context, state, input[i], cfra);
- }
- }
- }
-
- if (ibuf[0] && (ibuf[1] || BKE_sequence_effect_get_num_inputs(seq->type) == 1)) {
- if (sh.multithreaded) {
- out = BKE_sequencer_effect_execute_threaded(
- &sh, context, seq, cfra, fac, facf, ibuf[0], ibuf[1], ibuf[2]);
- }
- else {
- out = sh.execute(context, seq, cfra, fac, facf, ibuf[0], ibuf[1], ibuf[2]);
- }
- }
- break;
- case EARLY_USE_INPUT_1:
- if (input[0]) {
- out = seq_render_strip(context, state, input[0], cfra);
- }
- break;
- case EARLY_USE_INPUT_2:
- if (input[1]) {
- out = seq_render_strip(context, state, input[1], cfra);
- }
- break;
- }
-
- for (i = 0; i < 3; i++) {
- IMB_freeImBuf(ibuf[i]);
- }
-
- if (out == NULL) {
- out = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
- }
-
- return out;
-}
-
-/**
- * Render individual view for multi-view or single (default view) for mono-view.
- */
-static ImBuf *seq_render_image_strip_view(const SeqRenderData *context,
- Sequence *seq,
- char *name,
- char *prefix,
- const char *ext,
- int view_id)
-{
-
- ImBuf *ibuf = NULL;
-
- int flag = IB_rect | IB_metadata;
- if (seq->alpha_mode == SEQ_ALPHA_PREMUL) {
- flag |= IB_alphamode_premul;
- }
-
- if (prefix[0] == '\0') {
- ibuf = IMB_loadiffname(name, flag, seq->strip->colorspace_settings.name);
- }
- else {
- char str[FILE_MAX];
- BKE_scene_multiview_view_prefix_get(context->scene, name, prefix, &ext);
- seq_multiview_name(context->scene, view_id, prefix, ext, str, FILE_MAX);
- ibuf = IMB_loadiffname(str, flag, seq->strip->colorspace_settings.name);
- }
-
- if (ibuf == NULL) {
- return NULL;
- }
-
- /* We don't need both (speed reasons)! */
- if (ibuf->rect_float != NULL && ibuf->rect != NULL) {
- imb_freerectImBuf(ibuf);
- }
-
- /* All sequencer color is done in SRGB space, linear gives odd cross-fades. */
- BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibuf, false);
-
- return ibuf;
-}
-
-static bool seq_image_strip_is_multiview_render(
- Scene *scene, Sequence *seq, int totfiles, char *name, char *r_prefix, const char *r_ext)
-{
- if (totfiles > 1) {
- BKE_scene_multiview_view_prefix_get(scene, name, r_prefix, &r_ext);
- if (r_prefix[0] == '\0') {
- return false;
- }
- }
- else {
- r_prefix[0] = '\0';
- }
-
- return (seq->flag & SEQ_USE_VIEWS) != 0 && (scene->r.scemode & R_MULTIVIEW) != 0;
-}
-
-static ImBuf *seq_render_image_strip(const SeqRenderData *context,
- Sequence *seq,
- float UNUSED(nr),
- float cfra,
- bool *r_is_proxy_image)
-{
- char name[FILE_MAX];
- const char *ext = NULL;
- char prefix[FILE_MAX];
- ImBuf *ibuf = NULL;
-
- StripElem *s_elem = BKE_sequencer_give_stripelem(seq, cfra);
- if (s_elem == NULL) {
- return NULL;
- }
-
- BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name);
- BLI_path_abs(name, BKE_main_blendfile_path_from_global());
-
- /* Try to get a proxy image. */
- ibuf = seq_proxy_fetch(context, seq, cfra);
- if (ibuf != NULL) {
- s_elem->orig_width = ibuf->x;
- s_elem->orig_height = ibuf->y;
- *r_is_proxy_image = true;
- return ibuf;
- }
-
- /* Proxy not found, render original. */
- const int totfiles = seq_num_files(context->scene, seq->views_format, true);
- bool is_multiview_render = seq_image_strip_is_multiview_render(
- context->scene, seq, totfiles, name, prefix, ext);
-
- if (is_multiview_render) {
- int totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
- ImBuf **ibufs_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
-
- for (int view_id = 0; view_id < totfiles; view_id++) {
- ibufs_arr[view_id] = seq_render_image_strip_view(context, seq, name, prefix, ext, view_id);
- }
-
- if (ibufs_arr[0] == NULL) {
- return NULL;
- }
-
- if (seq->views_format == R_IMF_VIEWS_STEREO_3D) {
- IMB_ImBufFromStereo3d(seq->stereo3d_format, ibufs_arr[0], &ibufs_arr[0], &ibufs_arr[1]);
- }
-
- for (int view_id = 0; view_id < totviews; view_id++) {
- SeqRenderData localcontext = *context;
- localcontext.view_id = view_id;
-
- if (view_id != context->view_id) {
- ibufs_arr[view_id] = seq_render_preprocess_ibuf(
- &localcontext, seq, ibufs_arr[view_id], cfra, clock(), true, false);
- }
- }
-
- /* Return the original requested ImBuf. */
- ibuf = ibufs_arr[context->view_id];
-
- /* Remove the others (decrease their refcount). */
- for (int view_id = 0; view_id < totviews; view_id++) {
- if (ibufs_arr[view_id] != ibuf) {
- IMB_freeImBuf(ibufs_arr[view_id]);
- }
- }
-
- MEM_freeN(ibufs_arr);
- }
- else {
- ibuf = seq_render_image_strip_view(context, seq, name, prefix, ext, context->view_id);
- }
-
- if (ibuf == NULL) {
- return NULL;
- }
-
- s_elem->orig_width = ibuf->x;
- s_elem->orig_height = ibuf->y;
-
- return ibuf;
-}
-
-static ImBuf *seq_render_movie_strip_custom_file_proxy(const SeqRenderData *context,
- Sequence *seq,
- int cfra)
-{
- char name[PROXY_MAXFILE];
- StripProxy *proxy = seq->strip->proxy;
-
- if (proxy->anim == NULL) {
- if (seq_proxy_get_custom_file_fname(seq, name, context->view_id)) {
- proxy->anim = openanim(name, IB_rect, 0, seq->strip->colorspace_settings.name);
- }
- if (proxy->anim == NULL) {
- return NULL;
- }
- }
-
- int frameno = (int)BKE_sequencer_give_stripelem_index(seq, cfra) + seq->anim_startofs;
- return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE);
-}
-
-/**
- * Render individual view for multi-view or single (default view) for mono-view.
- */
-static ImBuf *seq_render_movie_strip_view(const SeqRenderData *context,
- Sequence *seq,
- float nr,
- float cfra,
- StripAnim *sanim,
- bool *r_is_proxy_image)
-{
- ImBuf *ibuf = NULL;
- IMB_Proxy_Size psize = seq_rendersize_to_proxysize(context->preview_render_size);
-
- IMB_anim_set_preseek(sanim->anim, seq->anim_preseek);
-
- if (seq_can_use_proxy(seq, psize)) {
- /* Try to get a proxy image.
- * Movie proxies are handled by ImBuf module with exception of `custom file` setting. */
- if (context->scene->ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE &&
- seq->strip->proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) {
- ibuf = seq_render_movie_strip_custom_file_proxy(context, seq, cfra);
- }
- else {
- ibuf = IMB_anim_absolute(sanim->anim,
- nr + seq->anim_startofs,
- seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN,
- psize);
- }
-
- if (ibuf != NULL) {
- *r_is_proxy_image = true;
- }
- }
-
- /* Fetching for requested proxy size failed, try fetching the original instead. */
- if (ibuf == NULL) {
- ibuf = IMB_anim_absolute(sanim->anim,
- nr + seq->anim_startofs,
- seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN,
- IMB_PROXY_NONE);
- }
- if (ibuf == NULL) {
- return NULL;
- }
-
- BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibuf, false);
-
- /* We don't need both (speed reasons)! */
- if (ibuf->rect_float != NULL && ibuf->rect != NULL) {
- imb_freerectImBuf(ibuf);
- }
-
- return ibuf;
-}
-
-static ImBuf *seq_render_movie_strip(
- const SeqRenderData *context, Sequence *seq, float nr, float cfra, bool *r_is_proxy_image)
-{
- /* Load all the videos. */
- seq_open_anim_file(context->scene, seq, false);
-
- ImBuf *ibuf = NULL;
- StripAnim *sanim = seq->anims.first;
- const int totfiles = seq_num_files(context->scene, seq->views_format, true);
- bool is_multiview_render = (seq->flag & SEQ_USE_VIEWS) != 0 &&
- (context->scene->r.scemode & R_MULTIVIEW) != 0 &&
- BLI_listbase_count_at_most(&seq->anims, totfiles + 1) == totfiles;
-
- if (is_multiview_render) {
- ImBuf **ibuf_arr;
- int totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
- ibuf_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
- int ibuf_view_id;
-
- for (ibuf_view_id = 0, sanim = seq->anims.first; sanim; sanim = sanim->next, ibuf_view_id++) {
- if (sanim->anim) {
- ibuf_arr[ibuf_view_id] = seq_render_movie_strip_view(
- context, seq, nr, cfra, sanim, r_is_proxy_image);
- }
- }
-
- if (seq->views_format == R_IMF_VIEWS_STEREO_3D) {
- if (ibuf_arr[0] == NULL) {
- /* Probably proxy hasn't been created yet. */
- MEM_freeN(ibuf_arr);
- return NULL;
- }
-
- IMB_ImBufFromStereo3d(seq->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
- }
-
- for (int view_id = 0; view_id < totviews; view_id++) {
- SeqRenderData localcontext = *context;
- localcontext.view_id = view_id;
-
- if (view_id != context->view_id) {
- ibuf_arr[view_id] = seq_render_preprocess_ibuf(
- &localcontext, seq, ibuf_arr[view_id], cfra, clock(), true, false);
- }
- }
-
- /* Return the original requested ImBuf. */
- ibuf = ibuf_arr[context->view_id];
-
- /* Remove the others (decrease their refcount). */
- for (int view_id = 0; view_id < totviews; view_id++) {
- if (ibuf_arr[view_id] != ibuf) {
- IMB_freeImBuf(ibuf_arr[view_id]);
- }
- }
-
- MEM_freeN(ibuf_arr);
- }
- else {
- ibuf = seq_render_movie_strip_view(context, seq, nr, cfra, sanim, r_is_proxy_image);
- }
-
- if (ibuf == NULL) {
- return NULL;
- }
-
- seq->strip->stripdata->orig_width = ibuf->x;
- seq->strip->stripdata->orig_height = ibuf->y;
-
- return ibuf;
-}
-
-static ImBuf *seq_get_movieclip_ibuf(Sequence *seq, MovieClipUser user)
-{
- ImBuf *ibuf = NULL;
- float tloc[2], tscale, tangle;
- if (seq->clip_flag & SEQ_MOVIECLIP_RENDER_STABILIZED) {
- ibuf = BKE_movieclip_get_stable_ibuf(seq->clip, &user, tloc, &tscale, &tangle, 0);
- }
- else {
- ibuf = BKE_movieclip_get_ibuf_flag(seq->clip, &user, seq->clip->flag, MOVIECLIP_CACHE_SKIP);
- }
- return ibuf;
-}
-
-static ImBuf *seq_render_movieclip_strip(const SeqRenderData *context,
- Sequence *seq,
- float nr,
- bool *r_is_proxy_image)
-{
- ImBuf *ibuf = NULL;
- MovieClipUser user;
- IMB_Proxy_Size psize = seq_rendersize_to_proxysize(context->preview_render_size);
-
- if (!seq->clip) {
- return NULL;
- }
-
- memset(&user, 0, sizeof(MovieClipUser));
-
- BKE_movieclip_user_set_frame(&user, nr + seq->anim_startofs + seq->clip->start_frame);
-
- user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
- switch (psize) {
- case IMB_PROXY_NONE:
- user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
- break;
- case IMB_PROXY_100:
- user.render_size = MCLIP_PROXY_RENDER_SIZE_100;
- break;
- case IMB_PROXY_75:
- user.render_size = MCLIP_PROXY_RENDER_SIZE_75;
- break;
- case IMB_PROXY_50:
- user.render_size = MCLIP_PROXY_RENDER_SIZE_50;
- break;
- case IMB_PROXY_25:
- user.render_size = MCLIP_PROXY_RENDER_SIZE_25;
- break;
- }
-
- if (seq->clip_flag & SEQ_MOVIECLIP_RENDER_UNDISTORTED) {
- user.render_flag |= MCLIP_PROXY_RENDER_UNDISTORT;
- }
-
- /* Try to get a proxy image. */
- ibuf = seq_get_movieclip_ibuf(seq, user);
-
- if (ibuf != NULL && psize != IMB_PROXY_NONE) {
- *r_is_proxy_image = true;
- }
-
- /* If proxy is not found, grab full-size frame. */
- if (ibuf == NULL) {
- user.render_flag |= MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER;
- ibuf = seq_get_movieclip_ibuf(seq, user);
- }
-
- return ibuf;
-}
-
-static ImBuf *seq_render_mask(const SeqRenderData *context, Mask *mask, float nr, bool make_float)
-{
- /* TODO - add option to rasterize to alpha imbuf? */
- ImBuf *ibuf = NULL;
- float *maskbuf;
- int i;
-
- if (!mask) {
- return NULL;
- }
-
- AnimData *adt;
- Mask *mask_temp;
- MaskRasterHandle *mr_handle;
-
- 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);
-
- /* anim-data */
- adt = BKE_animdata_from_id(&mask->id);
- const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
- context->depsgraph, mask->sfra + nr);
- BKE_animsys_evaluate_animdata(&mask_temp->id, adt, &anim_eval_context, ADT_RECALC_ANIM, false);
-
- maskbuf = MEM_mallocN(sizeof(float) * context->rectx * context->recty, __func__);
-
- mr_handle = BKE_maskrasterize_handle_new();
-
- BKE_maskrasterize_handle_init(
- mr_handle, mask_temp, context->rectx, context->recty, true, true, true);
-
- BKE_id_free(NULL, &mask_temp->id);
-
- BKE_maskrasterize_buffer(mr_handle, context->rectx, context->recty, maskbuf);
-
- BKE_maskrasterize_handle_free(mr_handle);
-
- if (make_float) {
- /* pixels */
- const float *fp_src;
- float *fp_dst;
-
- ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rectfloat);
-
- fp_src = maskbuf;
- fp_dst = ibuf->rect_float;
- i = context->rectx * context->recty;
- while (--i) {
- fp_dst[0] = fp_dst[1] = fp_dst[2] = *fp_src;
- fp_dst[3] = 1.0f;
-
- fp_src += 1;
- fp_dst += 4;
- }
- }
- else {
- /* pixels */
- const float *fp_src;
- unsigned char *ub_dst;
-
- ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
-
- fp_src = maskbuf;
- ub_dst = (unsigned char *)ibuf->rect;
- i = context->rectx * context->recty;
- while (--i) {
- ub_dst[0] = ub_dst[1] = ub_dst[2] = (unsigned char)(*fp_src * 255.0f); /* already clamped */
- ub_dst[3] = 255;
-
- fp_src += 1;
- ub_dst += 4;
- }
- }
-
- MEM_freeN(maskbuf);
-
- return ibuf;
-}
-
-static ImBuf *seq_render_mask_strip(const SeqRenderData *context, Sequence *seq, float nr)
-{
- bool make_float = (seq->flag & SEQ_MAKE_FLOAT) != 0;
-
- return seq_render_mask(context, seq->mask, nr, make_float);
-}
-
-static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
- Sequence *seq,
- float nr,
- float cfra)
-{
- ImBuf *ibuf = NULL;
- double frame;
- Object *camera;
-
- struct {
- int scemode;
- int cfra;
- float subframe;
-
-#ifdef DURIAN_CAMERA_SWITCH
- int mode;
-#endif
- } orig_data;
-
- /* Old info:
- * Hack! This function can be called from do_render_seq(), in that case
- * the seq->scene can already have a Render initialized with same name,
- * so we have to use a default name. (compositor uses scene name to
- * find render).
- * However, when called from within the UI (image preview in sequencer)
- * we do want to use scene Render, that way the render result is defined
- * for display in render/imagewindow
- *
- * Hmm, don't see, why we can't do that all the time,
- * and since G.is_rendering is uhm, gone... (Peter)
- */
-
- /* New info:
- * Using the same name for the renders works just fine as the do_render_seq()
- * render is not used while the scene strips are rendered.
- *
- * However rendering from UI (through sequencer_preview_area_draw) can crash in
- * very many cases since other renders (material preview, an actual render etc.)
- * can be started while this sequence preview render is running. The only proper
- * solution is to make the sequencer preview render a proper job, which can be
- * stopped when needed. This would also give a nice progress bar for the preview
- * space so that users know there's something happening.
- *
- * As a result the active scene now only uses OpenGL rendering for the sequencer
- * preview. This is far from nice, but is the only way to prevent crashes at this
- * time.
- *
- * -jahka
- */
-
- const bool is_rendering = G.is_rendering;
- const bool is_background = G.background;
- const bool do_seq_gl = is_rendering ? 0 : (context->scene->r.seq_prev_type) != OB_RENDER;
- bool have_comp = false;
- bool use_gpencil = true;
- /* do we need to re-evaluate the frame after rendering? */
- bool is_frame_update = false;
- Scene *scene;
- int is_thread_main = BLI_thread_is_main();
-
- /* don't refer to seq->scene above this point!, it can be NULL */
- if (seq->scene == NULL) {
- return NULL;
- }
-
- /* Prevent rendering scene recursively. */
- if (seq->scene == context->scene) {
- return NULL;
- }
-
- scene = seq->scene;
- frame = (double)scene->r.sfra + (double)nr + (double)seq->anim_startofs;
-
-#if 0 /* UNUSED */
- have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first);
-#endif
- have_comp = (scene->r.scemode & R_DOCOMP) && scene->use_nodes && scene->nodetree;
-
- /* Get view layer for the strip. */
- ViewLayer *view_layer = BKE_view_layer_default_render(scene);
- /* Depsgraph will be NULL when doing rendering. */
- Depsgraph *depsgraph = NULL;
-
- orig_data.scemode = scene->r.scemode;
- orig_data.cfra = scene->r.cfra;
- orig_data.subframe = scene->r.subframe;
-#ifdef DURIAN_CAMERA_SWITCH
- orig_data.mode = scene->r.mode;
-#endif
-
- BKE_scene_frame_set(scene, frame);
-
- if (seq->scene_camera) {
- camera = seq->scene_camera;
- }
- else {
- BKE_scene_camera_switch_update(scene);
- camera = scene->camera;
- }
-
- if (have_comp == false && camera == NULL) {
- goto finally;
- }
-
- if (seq->flag & SEQ_SCENE_NO_GPENCIL) {
- use_gpencil = false;
- }
-
- /* prevent eternal loop */
- scene->r.scemode &= ~R_DOSEQ;
-
-#ifdef DURIAN_CAMERA_SWITCH
- /* stooping to new low's in hackyness :( */
- scene->r.mode |= R_NO_CAMERA_SWITCH;
-#endif
-
- is_frame_update = (orig_data.cfra != scene->r.cfra) || (orig_data.subframe != scene->r.subframe);
-
- if ((sequencer_view3d_fn && do_seq_gl && camera) && is_thread_main) {
- char err_out[256] = "unknown";
- const int width = (scene->r.xsch * scene->r.size) / 100;
- const int height = (scene->r.ysch * scene->r.size) / 100;
- const char *viewname = BKE_scene_multiview_render_view_name_get(&scene->r, context->view_id);
-
- unsigned int draw_flags = V3D_OFSDRAW_NONE;
- draw_flags |= (use_gpencil) ? V3D_OFSDRAW_SHOW_ANNOTATION : 0;
- draw_flags |= (context->scene->r.seq_flag & R_SEQ_OVERRIDE_SCENE_SETTINGS) ?
- V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS :
- 0;
-
- /* for old scene this can be uninitialized,
- * should probably be added to do_versions at some point if the functionality stays */
- if (context->scene->r.seq_prev_type == 0) {
- context->scene->r.seq_prev_type = 3 /* == OB_SOLID */;
- }
-
- /* opengl offscreen render */
- depsgraph = BKE_scene_ensure_depsgraph(context->bmain, scene, view_layer);
- BKE_scene_graph_update_for_newframe(depsgraph);
- ibuf = sequencer_view3d_fn(
- /* set for OpenGL render (NULL when scrubbing) */
- depsgraph,
- scene,
- &context->scene->display.shading,
- context->scene->r.seq_prev_type,
- camera,
- width,
- height,
- IB_rect,
- draw_flags,
- scene->r.alphamode,
- viewname,
- context->gpu_offscreen,
- err_out);
- if (ibuf == NULL) {
- fprintf(stderr, "seq_render_scene_strip failed to get opengl buffer: %s\n", err_out);
- }
- }
- else {
- Render *re = RE_GetSceneRender(scene);
- const int totviews = BKE_scene_multiview_num_views_get(&scene->r);
- ImBuf **ibufs_arr;
-
- ibufs_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
-
- /* XXX: this if can be removed when sequence preview rendering uses the job system
- *
- * disable rendered preview for sequencer while rendering -- it's very much possible
- * that preview render will went into conflict with final render
- *
- * When rendering from command line renderer is called from main thread, in this
- * case it's always safe to render scene here
- */
- if (!is_thread_main || is_rendering == false || is_background || context->for_render) {
- if (re == NULL) {
- re = RE_NewSceneRender(scene);
- }
-
- RE_RenderFrame(
- re, context->bmain, scene, have_comp ? NULL : view_layer, camera, frame, false);
-
- /* restore previous state after it was toggled on & off by RE_RenderFrame */
- G.is_rendering = is_rendering;
- }
-
- for (int view_id = 0; view_id < totviews; view_id++) {
- SeqRenderData localcontext = *context;
- RenderResult rres;
-
- localcontext.view_id = view_id;
-
- RE_AcquireResultImage(re, &rres, view_id);
-
- if (rres.rectf) {
- ibufs_arr[view_id] = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat);
- memcpy(ibufs_arr[view_id]->rect_float,
- rres.rectf,
- sizeof(float[4]) * rres.rectx * rres.recty);
-
- if (rres.rectz) {
- addzbuffloatImBuf(ibufs_arr[view_id]);
- memcpy(
- ibufs_arr[view_id]->zbuf_float, rres.rectz, sizeof(float) * rres.rectx * rres.recty);
- }
-
- /* float buffers in the sequencer are not linear */
- BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibufs_arr[view_id], false);
- }
- else if (rres.rect32) {
- ibufs_arr[view_id] = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect);
- memcpy(ibufs_arr[view_id]->rect, rres.rect32, 4 * rres.rectx * rres.recty);
- }
-
- if (view_id != context->view_id) {
- BKE_sequencer_cache_put(
- &localcontext, seq, cfra, SEQ_CACHE_STORE_RAW, ibufs_arr[view_id], 0, false);
- }
-
- RE_ReleaseResultImage(re);
- }
-
- /* return the original requested ImBuf */
- ibuf = ibufs_arr[context->view_id];
-
- /* "remove" the others (decrease their refcount) */
- for (int view_id = 0; view_id < totviews; view_id++) {
- if (ibufs_arr[view_id] != ibuf) {
- IMB_freeImBuf(ibufs_arr[view_id]);
- }
- }
- MEM_freeN(ibufs_arr);
- }
-
-finally:
- /* restore */
- scene->r.scemode = orig_data.scemode;
- scene->r.cfra = orig_data.cfra;
- scene->r.subframe = orig_data.subframe;
-
- if (is_frame_update && (depsgraph != NULL)) {
- BKE_scene_graph_update_for_newframe(depsgraph);
- }
-
-#ifdef DURIAN_CAMERA_SWITCH
- /* stooping to new low's in hackyness :( */
- scene->r.mode &= orig_data.mode | ~R_NO_CAMERA_SWITCH;
-#endif
-
- return ibuf;
-}
-
-/**
- * Used for meta-strips & scenes with #SEQ_SCENE_STRIPS flag set.
- */
-static ImBuf *do_render_strip_seqbase(const SeqRenderData *context,
- SeqRenderState *state,
- Sequence *seq,
- float nr)
-{
- ImBuf *ibuf = NULL;
- ListBase *seqbase = NULL;
- int offset;
-
- seqbase = BKE_sequence_seqbase_get(seq, &offset);
-
- if (seqbase && !BLI_listbase_is_empty(seqbase)) {
-
- if (seq->flag & SEQ_SCENE_STRIPS && seq->scene) {
- BKE_animsys_evaluate_all_animation(context->bmain, context->depsgraph, nr + offset);
- }
-
- ibuf = seq_render_strip_stack(context,
- state,
- seqbase,
- /* scene strips don't have their start taken into account */
- nr + offset,
- 0);
- }
-
- return ibuf;
-}
-
-static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
- SeqRenderState *state,
- Sequence *seq,
- float cfra,
- bool *r_is_proxy_image)
-{
- ImBuf *ibuf = NULL;
- float nr = BKE_sequencer_give_stripelem_index(seq, cfra);
- int type = (seq->type & SEQ_TYPE_EFFECT) ? SEQ_TYPE_EFFECT : seq->type;
- switch (type) {
- case SEQ_TYPE_META: {
- ibuf = do_render_strip_seqbase(context, state, seq, nr);
- break;
- }
-
- case SEQ_TYPE_SCENE: {
- if (seq->flag & SEQ_SCENE_STRIPS) {
- if (seq->scene && (context->scene != seq->scene)) {
- /* recursive check */
- if (BLI_linklist_index(state->scene_parents, seq->scene) != -1) {
- break;
- }
- LinkNode scene_parent = {
- .next = state->scene_parents,
- .link = seq->scene,
- };
- state->scene_parents = &scene_parent;
- /* end check */
-
- /* Use the Scene Seq's scene for the context when rendering the scene's sequences
- * (necessary for Multicam Selector among others).
- */
- SeqRenderData local_context = *context;
- local_context.scene = seq->scene;
- local_context.skip_cache = true;
-
- ibuf = do_render_strip_seqbase(&local_context, state, seq, nr);
-
- /* step back in the list */
- state->scene_parents = state->scene_parents->next;
- }
- }
- else {
- /* scene can be NULL after deletions */
- ibuf = seq_render_scene_strip(context, seq, nr, cfra);
- }
-
- break;
- }
-
- case SEQ_TYPE_EFFECT: {
- ibuf = seq_render_effect_strip_impl(context, state, seq, cfra);
- break;
- }
-
- case SEQ_TYPE_IMAGE: {
- ibuf = seq_render_image_strip(context, seq, nr, cfra, r_is_proxy_image);
- break;
- }
-
- case SEQ_TYPE_MOVIE: {
- ibuf = seq_render_movie_strip(context, seq, nr, cfra, r_is_proxy_image);
- break;
- }
-
- case SEQ_TYPE_MOVIECLIP: {
- ibuf = seq_render_movieclip_strip(context, seq, nr, r_is_proxy_image);
-
- if (ibuf) {
- /* duplicate frame so movie cache wouldn't be confused by sequencer's stuff */
- ImBuf *i = IMB_dupImBuf(ibuf);
- IMB_freeImBuf(ibuf);
- ibuf = i;
-
- if (ibuf->rect_float) {
- BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibuf, false);
- }
- }
-
- break;
- }
-
- case SEQ_TYPE_MASK: {
- /* ibuf is always new */
- ibuf = seq_render_mask_strip(context, seq, nr);
- break;
- }
- }
-
- if (ibuf) {
- sequencer_imbuf_assign_spaces(context->scene, ibuf);
- }
-
- return ibuf;
-}
-
-/* Estimate time spent by the program rendering the strip */
-static clock_t seq_estimate_render_cost_begin(void)
-{
- return clock();
-}
-
-static float seq_estimate_render_cost_end(Scene *scene, clock_t begin)
-{
- clock_t end = clock();
- float time_spent = (float)(end - begin);
- float time_max = (1.0f / scene->r.frs_sec) * CLOCKS_PER_SEC;
-
- if (time_max != 0) {
- return time_spent / time_max;
- }
-
- return 1;
-}
-
-static ImBuf *seq_render_preprocess_ibuf(const SeqRenderData *context,
- Sequence *seq,
- ImBuf *ibuf,
- float cfra,
- clock_t begin,
- bool use_preprocess,
- const bool is_proxy_image)
-{
- if (context->is_proxy_render == false &&
- (ibuf->x != context->rectx || ibuf->y != context->recty)) {
- use_preprocess = true;
- }
-
- if (use_preprocess) {
- float cost = seq_estimate_render_cost_end(context->scene, begin);
-
- /* TODO(Richard): It should be possible to store in cache if image is proxy,
- * but it adds quite a bit of complexity. Since proxies are fast to read, I would
- * rather simplify existing code a bit. */
- if (!is_proxy_image) {
- BKE_sequencer_cache_put(context, seq, cfra, SEQ_CACHE_STORE_RAW, ibuf, cost, false);
- }
-
- /* Reset timer so we can get partial render time. */
- begin = seq_estimate_render_cost_begin();
- ibuf = input_preprocess(context, seq, cfra, ibuf, is_proxy_image);
- }
-
- float cost = seq_estimate_render_cost_end(context->scene, begin);
- BKE_sequencer_cache_put(context, seq, cfra, SEQ_CACHE_STORE_PREPROCESSED, ibuf, cost, false);
- return ibuf;
-}
-
-static ImBuf *seq_render_strip(const SeqRenderData *context,
- SeqRenderState *state,
- Sequence *seq,
- float cfra)
-{
- ImBuf *ibuf = NULL;
- bool use_preprocess = false;
- bool is_proxy_image = false;
-
- clock_t begin = seq_estimate_render_cost_begin();
-
- ibuf = BKE_sequencer_cache_get(context, seq, cfra, SEQ_CACHE_STORE_PREPROCESSED, false);
- if (ibuf != NULL) {
- return ibuf;
- }
-
- ibuf = BKE_sequencer_cache_get(context, seq, cfra, SEQ_CACHE_STORE_RAW, false);
- if (ibuf == NULL) {
- ibuf = do_render_strip_uncached(context, state, seq, cfra, &is_proxy_image);
- }
-
- if (ibuf) {
- use_preprocess = BKE_sequencer_input_have_to_preprocess(context, seq, cfra);
- ibuf = seq_render_preprocess_ibuf(
- context, seq, ibuf, cfra, begin, use_preprocess, is_proxy_image);
- }
-
- if (ibuf == NULL) {
- ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
- sequencer_imbuf_assign_spaces(context->scene, ibuf);
- }
-
- return ibuf;
-}
-
-/*********************** strip stack rendering functions *************************/
-
-static bool seq_must_swap_input_in_blend_mode(Sequence *seq)
-{
- bool swap_input = false;
-
- /* bad hack, to fix crazy input ordering of
- * those two effects */
-
- if (ELEM(seq->blend_mode, SEQ_TYPE_ALPHAOVER, SEQ_TYPE_ALPHAUNDER, SEQ_TYPE_OVERDROP)) {
- swap_input = true;
- }
-
- return swap_input;
-}
-
-static int seq_get_early_out_for_blend_mode(Sequence *seq)
-{
- struct SeqEffectHandle sh = BKE_sequence_get_blend(seq);
- float facf = seq->blend_opacity / 100.0f;
- int early_out = sh.early_out(seq, facf, facf);
-
- if (ELEM(early_out, EARLY_DO_EFFECT, EARLY_NO_INPUT)) {
- return early_out;
- }
-
- if (seq_must_swap_input_in_blend_mode(seq)) {
- if (early_out == EARLY_USE_INPUT_2) {
- return EARLY_USE_INPUT_1;
- }
- if (early_out == EARLY_USE_INPUT_1) {
- return EARLY_USE_INPUT_2;
- }
- }
- return early_out;
-}
-
-static ImBuf *seq_render_strip_stack_apply_effect(
- const SeqRenderData *context, Sequence *seq, float cfra, ImBuf *ibuf1, ImBuf *ibuf2)
-{
- ImBuf *out;
- struct SeqEffectHandle sh = BKE_sequence_get_blend(seq);
- float facf = seq->blend_opacity / 100.0f;
- int swap_input = seq_must_swap_input_in_blend_mode(seq);
-
- if (swap_input) {
- if (sh.multithreaded) {
- out = BKE_sequencer_effect_execute_threaded(
- &sh, context, seq, cfra, facf, facf, ibuf2, ibuf1, NULL);
- }
- else {
- out = sh.execute(context, seq, cfra, facf, facf, ibuf2, ibuf1, NULL);
- }
- }
- else {
- if (sh.multithreaded) {
- out = BKE_sequencer_effect_execute_threaded(
- &sh, context, seq, cfra, facf, facf, ibuf1, ibuf2, NULL);
- }
- else {
- out = sh.execute(context, seq, cfra, facf, facf, ibuf1, ibuf2, NULL);
- }
- }
-
- return out;
-}
-
-static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
- SeqRenderState *state,
- ListBase *seqbasep,
- float cfra,
- int chanshown)
-{
- Sequence *seq_arr[MAXSEQ + 1];
- int count;
- int i;
- ImBuf *out = NULL;
- clock_t begin;
-
- count = BKE_sequencer_get_shown_sequences(seqbasep, cfra, chanshown, (Sequence **)&seq_arr);
-
- if (count == 0) {
- return NULL;
- }
-
- for (i = count - 1; i >= 0; i--) {
- int early_out;
- Sequence *seq = seq_arr[i];
-
- out = BKE_sequencer_cache_get(context, seq, cfra, SEQ_CACHE_STORE_COMPOSITE, false);
-
- if (out) {
- break;
- }
- if (seq->blend_mode == SEQ_BLEND_REPLACE) {
- out = seq_render_strip(context, state, seq, cfra);
- break;
- }
-
- early_out = seq_get_early_out_for_blend_mode(seq);
-
- switch (early_out) {
- case EARLY_NO_INPUT:
- case EARLY_USE_INPUT_2:
- out = seq_render_strip(context, state, seq, cfra);
- break;
- case EARLY_USE_INPUT_1:
- if (i == 0) {
- out = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
- }
- break;
- case EARLY_DO_EFFECT:
- if (i == 0) {
- begin = seq_estimate_render_cost_begin();
-
- ImBuf *ibuf1 = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
- ImBuf *ibuf2 = seq_render_strip(context, state, seq, cfra);
-
- out = seq_render_strip_stack_apply_effect(context, seq, cfra, ibuf1, ibuf2);
-
- float cost = seq_estimate_render_cost_end(context->scene, begin);
- BKE_sequencer_cache_put(
- context, seq_arr[i], cfra, SEQ_CACHE_STORE_COMPOSITE, out, cost, false);
-
- IMB_freeImBuf(ibuf1);
- IMB_freeImBuf(ibuf2);
- }
- break;
- }
- if (out) {
- break;
- }
- }
-
- i++;
- for (; i < count; i++) {
- begin = seq_estimate_render_cost_begin();
- Sequence *seq = seq_arr[i];
-
- if (seq_get_early_out_for_blend_mode(seq) == EARLY_DO_EFFECT) {
- ImBuf *ibuf1 = out;
- ImBuf *ibuf2 = seq_render_strip(context, state, seq, cfra);
-
- out = seq_render_strip_stack_apply_effect(context, seq, cfra, ibuf1, ibuf2);
-
- IMB_freeImBuf(ibuf1);
- IMB_freeImBuf(ibuf2);
- }
-
- float cost = seq_estimate_render_cost_end(context->scene, begin);
- BKE_sequencer_cache_put(
- context, seq_arr[i], cfra, SEQ_CACHE_STORE_COMPOSITE, out, cost, false);
- }
-
- return out;
-}
-
-/*
- * returned ImBuf is refed!
- * you have to free after usage!
- */
-
-ImBuf *BKE_sequencer_give_ibuf(const SeqRenderData *context, float cfra, int chanshown)
-{
- Scene *scene = context->scene;
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- ListBase *seqbasep;
-
- if (ed == NULL) {
- return NULL;
- }
-
- if ((chanshown < 0) && !BLI_listbase_is_empty(&ed->metastack)) {
- int count = BLI_listbase_count(&ed->metastack);
- count = max_ii(count + chanshown, 0);
- seqbasep = ((MetaStack *)BLI_findlink(&ed->metastack, count))->oldbasep;
- }
- else {
- seqbasep = ed->seqbasep;
- }
-
- SeqRenderState state;
- sequencer_state_init(&state);
- ImBuf *out = NULL;
- Sequence *seq_arr[MAXSEQ + 1];
- int count;
-
- count = BKE_sequencer_get_shown_sequences(seqbasep, cfra, chanshown, seq_arr);
-
- if (count) {
- out = BKE_sequencer_cache_get(
- context, seq_arr[count - 1], cfra, SEQ_CACHE_STORE_FINAL_OUT, false);
- }
-
- BKE_sequencer_cache_free_temp_cache(context->scene, context->task_id, cfra);
-
- clock_t begin = seq_estimate_render_cost_begin();
- float cost = 0;
-
- if (count && !out) {
- BLI_mutex_lock(&seq_render_mutex);
- out = seq_render_strip_stack(context, &state, seqbasep, cfra, chanshown);
- cost = seq_estimate_render_cost_end(context->scene, begin);
-
- if (context->is_prefetch_render) {
- BKE_sequencer_cache_put(
- context, seq_arr[count - 1], cfra, SEQ_CACHE_STORE_FINAL_OUT, out, cost, false);
- }
- else {
- BKE_sequencer_cache_put_if_possible(
- context, seq_arr[count - 1], cfra, SEQ_CACHE_STORE_FINAL_OUT, out, cost, false);
- }
- BLI_mutex_unlock(&seq_render_mutex);
- }
-
- BKE_sequencer_prefetch_start(context, cfra, cost);
-
- return out;
-}
-
-ImBuf *BKE_sequencer_give_ibuf_seqbase(const SeqRenderData *context,
- float cfra,
- int chan_shown,
- ListBase *seqbasep)
-{
- SeqRenderState state;
- sequencer_state_init(&state);
-
- return seq_render_strip_stack(context, &state, seqbasep, cfra, chan_shown);
-}
-
-ImBuf *BKE_sequencer_give_ibuf_direct(const SeqRenderData *context, float cfra, Sequence *seq)
-{
- SeqRenderState state;
- sequencer_state_init(&state);
-
- ImBuf *ibuf = seq_render_strip(context, &state, seq, cfra);
-
- return ibuf;
-}
-
-/* check whether sequence cur depends on seq */
-bool BKE_sequence_check_depend(Sequence *seq, Sequence *cur)
-{
- if (cur->seq1 == seq || cur->seq2 == seq || cur->seq3 == seq) {
- return true;
- }
-
- /* sequences are not intersecting in time, assume no dependency exists between them */
- if (cur->enddisp < seq->startdisp || cur->startdisp > seq->enddisp) {
- return false;
- }
-
- /* checking sequence is below reference one, not dependent on it */
- if (cur->machine < seq->machine) {
- return false;
- }
-
- /* sequence is not blending with lower machines, no dependency here occurs
- * check for non-effects only since effect could use lower machines as input
- */
- if ((cur->type & SEQ_TYPE_EFFECT) == 0 &&
- ((cur->blend_mode == SEQ_BLEND_REPLACE) ||
- (cur->blend_mode == SEQ_TYPE_CROSS && cur->blend_opacity == 100.0f))) {
- return false;
- }
-
- return true;
-}
-
-static void sequence_do_invalidate_dependent(Scene *scene, Sequence *seq, ListBase *seqbase)
-{
- Sequence *cur;
-
- for (cur = seqbase->first; cur; cur = cur->next) {
- if (cur == seq) {
- continue;
- }
-
- if (BKE_sequence_check_depend(seq, cur)) {
- /* Effect must be invalidated completely if they depend on invalidated seq. */
- if ((cur->type & SEQ_TYPE_EFFECT) != 0) {
- BKE_sequencer_cache_cleanup_sequence(scene, cur, seq, SEQ_CACHE_ALL_TYPES, false);
- }
- else {
- /* In case of alpha over for example only invalidate composite image */
- BKE_sequencer_cache_cleanup_sequence(
- scene, cur, seq, SEQ_CACHE_STORE_COMPOSITE | SEQ_CACHE_STORE_FINAL_OUT, false);
- }
- }
-
- if (cur->seqbase.first) {
- sequence_do_invalidate_dependent(scene, seq, &cur->seqbase);
- }
- }
-}
-
-static void sequence_invalidate_cache(Scene *scene,
- Sequence *seq,
- bool invalidate_self,
- int invalidate_types)
-{
- Editing *ed = scene->ed;
-
- if (invalidate_self) {
- BKE_sequence_free_anim(seq);
- BKE_sequencer_cache_cleanup_sequence(scene, seq, seq, invalidate_types, false);
- }
-
- if (seq->effectdata && seq->type == SEQ_TYPE_SPEED) {
- BKE_sequence_effect_speed_rebuild_map(scene, seq, true);
- }
-
- sequence_do_invalidate_dependent(scene, seq, &ed->seqbase);
- DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
- BKE_sequencer_prefetch_stop(scene);
-}
-
-void BKE_sequence_invalidate_cache_in_range(Scene *scene,
- Sequence *seq,
- Sequence *range_mask,
- int invalidate_types)
-{
- BKE_sequencer_cache_cleanup_sequence(scene, seq, range_mask, invalidate_types, true);
-}
-
-void BKE_sequence_invalidate_cache_raw(Scene *scene, Sequence *seq)
-{
- sequence_invalidate_cache(scene, seq, true, SEQ_CACHE_ALL_TYPES);
-}
-
-void BKE_sequence_invalidate_cache_preprocessed(Scene *scene, Sequence *seq)
-{
- sequence_invalidate_cache(scene,
- seq,
- true,
- SEQ_CACHE_STORE_PREPROCESSED | SEQ_CACHE_STORE_COMPOSITE |
- SEQ_CACHE_STORE_FINAL_OUT);
-}
-
-void BKE_sequence_invalidate_cache_composite(Scene *scene, Sequence *seq)
-{
- if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
- return;
- }
-
- sequence_invalidate_cache(
- scene, seq, true, SEQ_CACHE_STORE_COMPOSITE | SEQ_CACHE_STORE_FINAL_OUT);
-}
-
-void BKE_sequence_invalidate_dependent(Scene *scene, Sequence *seq)
-{
- if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
- return;
- }
-
- sequence_invalidate_cache(
- scene, seq, false, SEQ_CACHE_STORE_COMPOSITE | SEQ_CACHE_STORE_FINAL_OUT);
-}
-
-static void invalidate_scene_strips(Scene *scene, Scene *scene_target, ListBase *seqbase)
-{
- for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
- if (seq->scene == scene_target) {
- BKE_sequence_invalidate_cache_raw(scene, seq);
- }
-
- if (seq->seqbase.first != NULL) {
- invalidate_scene_strips(scene, scene_target, &seq->seqbase);
- }
- }
-}
-
-void BKE_sequence_invalidate_scene_strips(Main *bmain, Scene *scene_target)
-{
- for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
- if (scene->ed != NULL) {
- invalidate_scene_strips(scene, scene_target, &scene->ed->seqbase);
- }
- }
-}
-
-static void invalidate_movieclip_strips(Scene *scene, MovieClip *clip_target, ListBase *seqbase)
-{
- for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
- if (seq->clip == clip_target) {
- BKE_sequence_invalidate_cache_raw(scene, seq);
- }
-
- if (seq->seqbase.first != NULL) {
- invalidate_movieclip_strips(scene, clip_target, &seq->seqbase);
- }
- }
-}
-
-void BKE_sequence_invalidate_movieclip_strips(Main *bmain, MovieClip *clip_target)
-{
- for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
- if (scene->ed != NULL) {
- invalidate_movieclip_strips(scene, clip_target, &scene->ed->seqbase);
- }
- }
-}
-
-void BKE_sequencer_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render)
-{
- if (scene->ed == NULL) {
- return;
- }
-
- Sequence *seq;
-
- BKE_sequencer_cache_cleanup(scene);
- BKE_sequencer_prefetch_stop(scene);
-
- for (seq = seqbase->first; seq; seq = seq->next) {
- if (for_render && CFRA >= seq->startdisp && CFRA <= seq->enddisp) {
- continue;
- }
-
- if (seq->strip) {
- if (seq->type == SEQ_TYPE_MOVIE) {
- BKE_sequence_free_anim(seq);
- }
- if (seq->type == SEQ_TYPE_SPEED) {
- BKE_sequence_effect_speed_rebuild_map(scene, seq, true);
- }
- }
- if (seq->type == SEQ_TYPE_META) {
- BKE_sequencer_free_imbuf(scene, &seq->seqbase, for_render);
- }
- if (seq->type == SEQ_TYPE_SCENE) {
- /* FIXME: recurse downwards,
- * but do recurse protection somehow! */
- }
- }
-}
-
-static bool update_changed_seq_recurs(
- Scene *scene, Sequence *seq, Sequence *changed_seq, int len_change, int ibuf_change)
-{
- Sequence *subseq;
- bool free_imbuf = false;
-
- /* recurse downwards to see if this seq depends on the changed seq */
-
- if (seq == NULL) {
- return false;
- }
-
- if (seq == changed_seq) {
- free_imbuf = true;
- }
-
- for (subseq = seq->seqbase.first; subseq; subseq = subseq->next) {
- if (update_changed_seq_recurs(scene, subseq, changed_seq, len_change, ibuf_change)) {
- free_imbuf = true;
- }
- }
-
- if (seq->seq1) {
- if (update_changed_seq_recurs(scene, seq->seq1, changed_seq, len_change, ibuf_change)) {
- free_imbuf = true;
- }
- }
- if (seq->seq2 && (seq->seq2 != seq->seq1)) {
- if (update_changed_seq_recurs(scene, seq->seq2, changed_seq, len_change, ibuf_change)) {
- free_imbuf = true;
- }
- }
- if (seq->seq3 && (seq->seq3 != seq->seq1) && (seq->seq3 != seq->seq2)) {
- if (update_changed_seq_recurs(scene, seq->seq3, changed_seq, len_change, ibuf_change)) {
- free_imbuf = true;
- }
- }
-
- if (free_imbuf) {
- if (ibuf_change) {
- if (seq->type == SEQ_TYPE_MOVIE) {
- BKE_sequence_free_anim(seq);
- }
- else if (seq->type == SEQ_TYPE_SPEED) {
- BKE_sequence_effect_speed_rebuild_map(scene, seq, true);
- }
- }
-
- if (len_change) {
- BKE_sequence_calc(scene, seq);
- }
- }
-
- return free_imbuf;
-}
-
-void BKE_sequencer_update_changed_seq_and_deps(Scene *scene,
- Sequence *changed_seq,
- int len_change,
- int ibuf_change)
-{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
-
- if (ed == NULL) {
- return;
- }
-
- for (seq = ed->seqbase.first; seq; seq = seq->next) {
- update_changed_seq_recurs(scene, seq, changed_seq, len_change, ibuf_change);
- }
-}
-
-/* seq funcs's for transforming internally
- * notice the difference between start/end and left/right.
- *
- * left and right are the bounds at which the sequence is rendered,
- * start and end are from the start and fixed length of the sequence.
- */
-static int seq_tx_get_start(Sequence *seq)
-{
- return seq->start;
-}
-static int seq_tx_get_end(Sequence *seq)
-{
- return seq->start + seq->len;
-}
-
-int BKE_sequence_tx_get_final_left(Sequence *seq, bool metaclip)
-{
- if (metaclip && seq->tmp) {
- /* return the range clipped by the parents range */
- return max_ii(BKE_sequence_tx_get_final_left(seq, false),
- BKE_sequence_tx_get_final_left((Sequence *)seq->tmp, true));
- }
-
- return (seq->start - seq->startstill) + seq->startofs;
-}
-int BKE_sequence_tx_get_final_right(Sequence *seq, bool metaclip)
-{
- if (metaclip && seq->tmp) {
- /* return the range clipped by the parents range */
- return min_ii(BKE_sequence_tx_get_final_right(seq, false),
- BKE_sequence_tx_get_final_right((Sequence *)seq->tmp, true));
- }
-
- return ((seq->start + seq->len) + seq->endstill) - seq->endofs;
-}
-
-void BKE_sequence_tx_set_final_left(Sequence *seq, int val)
-{
- if (val < (seq)->start) {
- seq->startstill = abs(val - (seq)->start);
- seq->startofs = 0;
- }
- else {
- seq->startofs = abs(val - (seq)->start);
- seq->startstill = 0;
- }
-}
-
-void BKE_sequence_tx_set_final_right(Sequence *seq, int val)
-{
- if (val > (seq)->start + (seq)->len) {
- seq->endstill = abs(val - (seq->start + (seq)->len));
- seq->endofs = 0;
- }
- else {
- seq->endofs = abs(val - ((seq)->start + (seq)->len));
- seq->endstill = 0;
- }
-}
-
-/* used so we can do a quick check for single image seq
- * since they work a bit differently to normal image seq's (during transform) */
-bool BKE_sequence_single_check(Sequence *seq)
-{
- return ((seq->len == 1) &&
- (seq->type == SEQ_TYPE_IMAGE ||
- ((seq->type & SEQ_TYPE_EFFECT) && BKE_sequence_effect_get_num_inputs(seq->type) == 0)));
-}
-
-/* check if the selected seq's reference unselected seq's */
-bool BKE_sequence_base_isolated_sel_check(ListBase *seqbase)
-{
- Sequence *seq;
- /* is there more than 1 select */
- bool ok = false;
-
- for (seq = seqbase->first; seq; seq = seq->next) {
- if (seq->flag & SELECT) {
- ok = true;
- break;
- }
- }
-
- if (ok == false) {
- return false;
- }
-
- /* test relationships */
- for (seq = seqbase->first; seq; seq = seq->next) {
- if ((seq->type & SEQ_TYPE_EFFECT) == 0) {
- continue;
- }
-
- if (seq->flag & SELECT) {
- if ((seq->seq1 && (seq->seq1->flag & SELECT) == 0) ||
- (seq->seq2 && (seq->seq2->flag & SELECT) == 0) ||
- (seq->seq3 && (seq->seq3->flag & SELECT) == 0)) {
- return false;
- }
- }
- else {
- if ((seq->seq1 && (seq->seq1->flag & SELECT)) || (seq->seq2 && (seq->seq2->flag & SELECT)) ||
- (seq->seq3 && (seq->seq3->flag & SELECT))) {
- return false;
- }
- }
- }
-
- return true;
-}
-
-/* use to impose limits when dragging/extending - so impossible situations don't happen
- * Cant use the SEQ_LEFTSEL and SEQ_LEFTSEL directly because the strip may be in a metastrip */
-void BKE_sequence_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag)
-{
- if (leftflag) {
- if (BKE_sequence_tx_get_final_left(seq, false) >=
- BKE_sequence_tx_get_final_right(seq, false)) {
- BKE_sequence_tx_set_final_left(seq, BKE_sequence_tx_get_final_right(seq, false) - 1);
- }
-
- if (BKE_sequence_single_check(seq) == 0) {
- if (BKE_sequence_tx_get_final_left(seq, false) >= seq_tx_get_end(seq)) {
- BKE_sequence_tx_set_final_left(seq, seq_tx_get_end(seq) - 1);
- }
-
- /* doesn't work now - TODO */
-#if 0
- if (seq_tx_get_start(seq) >= seq_tx_get_final_right(seq, 0)) {
- int ofs;
- ofs = seq_tx_get_start(seq) - seq_tx_get_final_right(seq, 0);
- seq->start -= ofs;
- seq_tx_set_final_left(seq, seq_tx_get_final_left(seq, 0) + ofs);
- }
-#endif
- }
- }
-
- if (rightflag) {
- if (BKE_sequence_tx_get_final_right(seq, false) <=
- BKE_sequence_tx_get_final_left(seq, false)) {
- BKE_sequence_tx_set_final_right(seq, BKE_sequence_tx_get_final_left(seq, false) + 1);
- }
-
- if (BKE_sequence_single_check(seq) == 0) {
- if (BKE_sequence_tx_get_final_right(seq, false) <= seq_tx_get_start(seq)) {
- BKE_sequence_tx_set_final_right(seq, seq_tx_get_start(seq) + 1);
- }
- }
- }
-
- /* sounds cannot be extended past their endpoints */
- if (seq->type == SEQ_TYPE_SOUND_RAM) {
- seq->startstill = 0;
- seq->endstill = 0;
- }
-}
-
-void BKE_sequence_single_fix(Sequence *seq)
-{
- int left, start, offset;
- if (!BKE_sequence_single_check(seq)) {
- return;
- }
-
- /* make sure the image is always at the start since there is only one,
- * adjusting its start should be ok */
- left = BKE_sequence_tx_get_final_left(seq, false);
- start = seq->start;
- if (start != left) {
- offset = left - start;
- BKE_sequence_tx_set_final_left(seq, BKE_sequence_tx_get_final_left(seq, false) - offset);
- BKE_sequence_tx_set_final_right(seq, BKE_sequence_tx_get_final_right(seq, false) - offset);
- seq->start += offset;
- }
-}
-
-bool BKE_sequence_tx_test(Sequence *seq)
-{
- return !(seq->type & SEQ_TYPE_EFFECT) || (BKE_sequence_effect_get_num_inputs(seq->type) == 0);
-}
-
-/**
- * Return \a true if given \a seq needs a complete cleanup of its cache when it is transformed.
- *
- * Some (effect) strip types need a complete recache of themselves when they are transformed,
- * because they do not 'contain' anything and do not have any explicit relations to other strips.
- */
-bool BKE_sequence_tx_fullupdate_test(Sequence *seq)
-{
- return BKE_sequence_tx_test(seq) && ELEM(seq->type, SEQ_TYPE_ADJUSTMENT, SEQ_TYPE_MULTICAM);
-}
-
-static bool seq_overlap(Sequence *seq1, Sequence *seq2)
-{
- return (seq1 != seq2 && seq1->machine == seq2->machine &&
- ((seq1->enddisp <= seq2->startdisp) || (seq1->startdisp >= seq2->enddisp)) == 0);
-}
-
-bool BKE_sequence_test_overlap(ListBase *seqbasep, Sequence *test)
-{
- Sequence *seq;
-
- seq = seqbasep->first;
- while (seq) {
- if (seq_overlap(test, seq)) {
- return true;
- }
-
- seq = seq->next;
- }
- return false;
-}
-
-void BKE_sequence_translate(Scene *evil_scene, Sequence *seq, int delta)
-{
- if (delta == 0) {
- return;
- }
-
- BKE_sequencer_offset_animdata(evil_scene, seq, delta);
- seq->start += delta;
-
- if (seq->type == SEQ_TYPE_META) {
- Sequence *seq_child;
- for (seq_child = seq->seqbase.first; seq_child; seq_child = seq_child->next) {
- BKE_sequence_translate(evil_scene, seq_child, delta);
- }
- }
-
- BKE_sequence_calc_disp(evil_scene, seq);
-}
-
-void BKE_sequence_sound_init(Scene *scene, Sequence *seq)
-{
- if (seq->type == SEQ_TYPE_META) {
- Sequence *seq_child;
- for (seq_child = seq->seqbase.first; seq_child; seq_child = seq_child->next) {
- BKE_sequence_sound_init(scene, seq_child);
- }
- }
- else {
- if (seq->sound) {
- seq->scene_sound = BKE_sound_add_scene_sound_defaults(scene, seq);
- }
- if (seq->scene) {
- seq->scene_sound = BKE_sound_scene_add_scene_sound_defaults(scene, seq);
- }
- }
-}
-
-const Sequence *BKE_sequencer_foreground_frame_get(const Scene *scene, int frame)
-{
- const Editing *ed = scene->ed;
- const Sequence *seq, *best_seq = NULL;
- int best_machine = -1;
-
- if (!ed) {
- return NULL;
- }
-
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) {
- continue;
- }
- /* Only use strips that generate an image, not ones that combine
- * other strips or apply some effect. */
- if (ELEM(seq->type,
- SEQ_TYPE_IMAGE,
- SEQ_TYPE_META,
- SEQ_TYPE_SCENE,
- SEQ_TYPE_MOVIE,
- SEQ_TYPE_COLOR,
- SEQ_TYPE_TEXT)) {
- if (seq->machine > best_machine) {
- best_seq = seq;
- best_machine = seq->machine;
- }
- }
- }
- return best_seq;
-}
-
-/* return 0 if there weren't enough space */
-bool BKE_sequence_base_shuffle_ex(ListBase *seqbasep,
- Sequence *test,
- Scene *evil_scene,
- int channel_delta)
-{
- const int orig_machine = test->machine;
- BLI_assert(ELEM(channel_delta, -1, 1));
-
- test->machine += channel_delta;
- BKE_sequence_calc(evil_scene, test);
- while (BKE_sequence_test_overlap(seqbasep, test)) {
- if ((channel_delta > 0) ? (test->machine >= MAXSEQ) : (test->machine < 1)) {
- break;
- }
-
- test->machine += channel_delta;
- BKE_sequence_calc(
- evil_scene,
- test); // XXX - I don't think this is needed since were only moving vertically, Campbell.
- }
-
- if ((test->machine < 1) || (test->machine > MAXSEQ)) {
- /* Blender 2.4x would remove the strip.
- * nicer to move it to the end */
-
- Sequence *seq;
- int new_frame = test->enddisp;
-
- for (seq = seqbasep->first; seq; seq = seq->next) {
- if (seq->machine == orig_machine) {
- new_frame = max_ii(new_frame, seq->enddisp);
- }
- }
-
- test->machine = orig_machine;
- new_frame = new_frame + (test->start - test->startdisp); /* adjust by the startdisp */
- BKE_sequence_translate(evil_scene, test, new_frame - test->start);
-
- BKE_sequence_calc(evil_scene, test);
- return false;
- }
-
- return true;
-}
-
-bool BKE_sequence_base_shuffle(ListBase *seqbasep, Sequence *test, Scene *evil_scene)
-{
- return BKE_sequence_base_shuffle_ex(seqbasep, test, evil_scene, 1);
-}
-
-static int shuffle_seq_time_offset_test(ListBase *seqbasep, char dir)
-{
- int offset = 0;
- Sequence *seq, *seq_other;
-
- for (seq = seqbasep->first; seq; seq = seq->next) {
- if (seq->tmp) {
- for (seq_other = seqbasep->first; seq_other; seq_other = seq_other->next) {
- if (!seq_other->tmp && seq_overlap(seq, seq_other)) {
- if (dir == 'L') {
- offset = min_ii(offset, seq_other->startdisp - seq->enddisp);
- }
- else {
- offset = max_ii(offset, seq_other->enddisp - seq->startdisp);
- }
- }
- }
- }
- }
- return offset;
-}
-
-static int shuffle_seq_time_offset(Scene *scene, ListBase *seqbasep, char dir)
-{
- int ofs = 0;
- int tot_ofs = 0;
- Sequence *seq;
- while ((ofs = shuffle_seq_time_offset_test(seqbasep, dir))) {
- for (seq = seqbasep->first; seq; seq = seq->next) {
- if (seq->tmp) {
- /* seq_test_overlap only tests display values */
- seq->startdisp += ofs;
- seq->enddisp += ofs;
- }
- }
-
- tot_ofs += ofs;
- }
-
- for (seq = seqbasep->first; seq; seq = seq->next) {
- if (seq->tmp) {
- BKE_sequence_calc_disp(scene, seq); /* corrects dummy startdisp/enddisp values */
- }
- }
-
- return tot_ofs;
-}
-
-bool BKE_sequence_base_shuffle_time(ListBase *seqbasep,
- Scene *evil_scene,
- ListBase *markers,
- const bool use_sync_markers)
-{
- /* note: seq->tmp is used to tag strips to move */
-
- Sequence *seq;
-
- int offset_l = shuffle_seq_time_offset(evil_scene, seqbasep, 'L');
- int offset_r = shuffle_seq_time_offset(evil_scene, seqbasep, 'R');
- int offset = (-offset_l < offset_r) ? offset_l : offset_r;
-
- if (offset) {
- for (seq = seqbasep->first; seq; seq = seq->next) {
- if (seq->tmp) {
- BKE_sequence_translate(evil_scene, seq, offset);
- seq->flag &= ~SEQ_OVERLAP;
- }
- }
-
- if (use_sync_markers && !(evil_scene->toolsettings->lock_markers) && (markers != NULL)) {
- TimeMarker *marker;
- /* affect selected markers - it's unlikely that we will want to affect all in this way? */
- for (marker = markers->first; marker; marker = marker->next) {
- if (marker->flag & SELECT) {
- marker->frame += offset;
- }
- }
- }
- }
-
- return offset ? false : true;
-}
-
-/* Unlike _update_sound_ funcs, these ones take info from audaspace to update sequence length! */
-#ifdef WITH_AUDASPACE
-static bool sequencer_refresh_sound_length_recursive(Main *bmain, Scene *scene, ListBase *seqbase)
-{
- Sequence *seq;
- bool changed = false;
-
- for (seq = seqbase->first; seq; seq = seq->next) {
- if (seq->type == SEQ_TYPE_META) {
- if (sequencer_refresh_sound_length_recursive(bmain, scene, &seq->seqbase)) {
- BKE_sequence_calc(scene, seq);
- changed = true;
- }
- }
- else if (seq->type == SEQ_TYPE_SOUND_RAM && seq->sound) {
- const float length = BKE_sound_get_length(bmain, seq->sound);
- int old = seq->len;
- float fac;
-
- seq->len = (int)ceil((double)length * FPS);
- fac = (float)seq->len / (float)old;
- old = seq->startofs;
- seq->startofs *= fac;
- seq->endofs *= fac;
- seq->start += (old - seq->startofs); /* So that visual/"real" start frame does not change! */
-
- BKE_sequence_calc(scene, seq);
- changed = true;
- }
- }
- return changed;
-}
-#endif
-
-void BKE_sequencer_refresh_sound_length(Main *bmain, Scene *scene)
-{
-#ifdef WITH_AUDASPACE
- if (scene->ed) {
- sequencer_refresh_sound_length_recursive(bmain, scene, &scene->ed->seqbase);
- }
-#else
- UNUSED_VARS(bmain, scene);
-#endif
-}
-
-void BKE_sequencer_update_sound_bounds_all(Scene *scene)
-{
- Editing *ed = scene->ed;
-
- if (ed) {
- Sequence *seq;
-
- for (seq = ed->seqbase.first; seq; seq = seq->next) {
- if (seq->type == SEQ_TYPE_META) {
- seq_update_sound_bounds_recursive(scene, seq);
- }
- else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
- BKE_sequencer_update_sound_bounds(scene, seq);
- }
- }
- }
-}
-
-void BKE_sequencer_update_sound_bounds(Scene *scene, Sequence *seq)
-{
- if (seq->type == SEQ_TYPE_SCENE) {
- if (seq->scene && seq->scene_sound) {
- /* We have to take into account start frame of the sequence's scene! */
- int startofs = seq->startofs + seq->anim_startofs + seq->scene->r.sfra;
-
- BKE_sound_move_scene_sound(scene, seq->scene_sound, seq->startdisp, seq->enddisp, startofs);
- }
- }
- else {
- BKE_sound_move_scene_sound_defaults(scene, seq);
- }
- /* mute is set in seq_update_muting_recursive */
-}
-
-static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, int mute)
-{
- Sequence *seq;
- int seqmute;
-
- /* for sound we go over full meta tree to update muted state,
- * since sound is played outside of evaluating the imbufs, */
- for (seq = seqbasep->first; seq; seq = seq->next) {
- seqmute = (mute || (seq->flag & SEQ_MUTE));
-
- if (seq->type == SEQ_TYPE_META) {
- /* if this is the current meta sequence, unmute because
- * all sequences above this were set to mute */
- if (seq == metaseq) {
- seqmute = 0;
- }
-
- seq_update_muting_recursive(&seq->seqbase, metaseq, seqmute);
- }
- else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
- if (seq->scene_sound) {
- BKE_sound_mute_scene_sound(seq->scene_sound, seqmute);
- }
- }
- }
-}
-
-void BKE_sequencer_update_muting(Editing *ed)
-{
- if (ed) {
- /* mute all sounds up to current metastack list */
- MetaStack *ms = ed->metastack.last;
-
- if (ms) {
- seq_update_muting_recursive(&ed->seqbase, ms->parseq, 1);
- }
- else {
- seq_update_muting_recursive(&ed->seqbase, NULL, 0);
- }
- }
-}
-
-static void seq_update_sound_recursive(Scene *scene, ListBase *seqbasep, bSound *sound)
-{
- Sequence *seq;
-
- for (seq = seqbasep->first; seq; seq = seq->next) {
- if (seq->type == SEQ_TYPE_META) {
- seq_update_sound_recursive(scene, &seq->seqbase, sound);
- }
- else if (seq->type == SEQ_TYPE_SOUND_RAM) {
- if (seq->scene_sound && sound == seq->sound) {
- BKE_sound_update_scene_sound(seq->scene_sound, sound);
- }
- }
- }
-}
-
-void BKE_sequencer_update_sound(Scene *scene, bSound *sound)
-{
- if (scene->ed) {
- seq_update_sound_recursive(scene, &scene->ed->seqbase, sound);
- }
-}
-
-/* in cases where we done know the sequence's listbase */
-ListBase *BKE_sequence_seqbase(ListBase *seqbase, Sequence *seq)
-{
- Sequence *iseq;
- ListBase *lb = NULL;
-
- for (iseq = seqbase->first; iseq; iseq = iseq->next) {
- if (seq == iseq) {
- return seqbase;
- }
- if (iseq->seqbase.first && (lb = BKE_sequence_seqbase(&iseq->seqbase, seq))) {
- return lb;
- }
- }
-
- return NULL;
-}
-
-Sequence *BKE_sequence_metastrip(ListBase *seqbase, Sequence *meta, Sequence *seq)
-{
- Sequence *iseq;
-
- for (iseq = seqbase->first; iseq; iseq = iseq->next) {
- Sequence *rval;
-
- if (seq == iseq) {
- return meta;
- }
- if (iseq->seqbase.first && (rval = BKE_sequence_metastrip(&iseq->seqbase, iseq, seq))) {
- return rval;
- }
- }
-
- return NULL;
-}
-
-int BKE_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
-{
- char name[sizeof(seq_a->name)];
-
- if (seq_a->len != seq_b->len) {
- *error_str = N_("Strips must be the same length");
- return 0;
- }
-
- /* type checking, could be more advanced but disallow sound vs non-sound copy */
- if (seq_a->type != seq_b->type) {
- if (seq_a->type == SEQ_TYPE_SOUND_RAM || seq_b->type == SEQ_TYPE_SOUND_RAM) {
- *error_str = N_("Strips were not compatible");
- return 0;
- }
-
- /* disallow effects to swap with non-effects strips */
- if ((seq_a->type & SEQ_TYPE_EFFECT) != (seq_b->type & SEQ_TYPE_EFFECT)) {
- *error_str = N_("Strips were not compatible");
- return 0;
- }
-
- if ((seq_a->type & SEQ_TYPE_EFFECT) && (seq_b->type & SEQ_TYPE_EFFECT)) {
- if (BKE_sequence_effect_get_num_inputs(seq_a->type) !=
- BKE_sequence_effect_get_num_inputs(seq_b->type)) {
- *error_str = N_("Strips must have the same number of inputs");
- return 0;
- }
- }
- }
-
- SWAP(Sequence, *seq_a, *seq_b);
-
- /* swap back names so animation fcurves don't get swapped */
- BLI_strncpy(name, seq_a->name + 2, sizeof(name));
- BLI_strncpy(seq_a->name + 2, seq_b->name + 2, sizeof(seq_b->name) - 2);
- BLI_strncpy(seq_b->name + 2, name, sizeof(seq_b->name) - 2);
-
- /* swap back opacity, and overlay mode */
- SWAP(int, seq_a->blend_mode, seq_b->blend_mode);
- SWAP(float, seq_a->blend_opacity, seq_b->blend_opacity);
-
- SWAP(Sequence *, seq_a->prev, seq_b->prev);
- SWAP(Sequence *, seq_a->next, seq_b->next);
- SWAP(int, seq_a->start, seq_b->start);
- SWAP(int, seq_a->startofs, seq_b->startofs);
- SWAP(int, seq_a->endofs, seq_b->endofs);
- SWAP(int, seq_a->startstill, seq_b->startstill);
- SWAP(int, seq_a->endstill, seq_b->endstill);
- SWAP(int, seq_a->machine, seq_b->machine);
- SWAP(int, seq_a->startdisp, seq_b->startdisp);
- SWAP(int, seq_a->enddisp, seq_b->enddisp);
-
- return 1;
-}
-
-/* r_prefix + [" + escaped_name + "] + \0 */
-#define SEQ_RNAPATH_MAXSTR ((30 + 2 + (SEQ_NAME_MAXSTR * 2) + 2) + 1)
-
-static size_t sequencer_rna_path_prefix(char str[SEQ_RNAPATH_MAXSTR], const char *name)
-{
- char name_esc[SEQ_NAME_MAXSTR * 2];
-
- BLI_strescape(name_esc, name, sizeof(name_esc));
- return BLI_snprintf_rlen(
- str, SEQ_RNAPATH_MAXSTR, "sequence_editor.sequences_all[\"%s\"]", name_esc);
-}
-
-/* XXX - hackish function needed for transforming strips! TODO - have some better solution */
-void BKE_sequencer_offset_animdata(Scene *scene, Sequence *seq, int ofs)
-{
- char str[SEQ_RNAPATH_MAXSTR];
- size_t str_len;
- FCurve *fcu;
-
- if (scene->adt == NULL || ofs == 0 || scene->adt->action == NULL) {
- return;
- }
-
- str_len = sequencer_rna_path_prefix(str, seq->name + 2);
-
- for (fcu = scene->adt->action->curves.first; fcu; fcu = fcu->next) {
- if (STREQLEN(fcu->rna_path, str, str_len)) {
- unsigned int i;
- if (fcu->bezt) {
- for (i = 0; i < fcu->totvert; i++) {
- BezTriple *bezt = &fcu->bezt[i];
- bezt->vec[0][0] += ofs;
- bezt->vec[1][0] += ofs;
- bezt->vec[2][0] += ofs;
- }
- }
- if (fcu->fpt) {
- for (i = 0; i < fcu->totvert; i++) {
- FPoint *fpt = &fcu->fpt[i];
- fpt->vec[0] += ofs;
- }
- }
- }
- }
-
- DEG_id_tag_update(&scene->adt->action->id, ID_RECALC_ANIMATION);
-}
-
-void BKE_sequencer_dupe_animdata(Scene *scene, const char *name_src, const char *name_dst)
-{
- char str_from[SEQ_RNAPATH_MAXSTR];
- size_t str_from_len;
- FCurve *fcu;
- FCurve *fcu_last;
- FCurve *fcu_cpy;
- ListBase lb = {NULL, NULL};
-
- if (scene->adt == NULL || scene->adt->action == NULL) {
- return;
- }
-
- str_from_len = sequencer_rna_path_prefix(str_from, name_src);
-
- fcu_last = scene->adt->action->curves.last;
-
- for (fcu = scene->adt->action->curves.first; fcu && fcu->prev != fcu_last; fcu = fcu->next) {
- if (STREQLEN(fcu->rna_path, str_from, str_from_len)) {
- fcu_cpy = BKE_fcurve_copy(fcu);
- BLI_addtail(&lb, fcu_cpy);
- }
- }
-
- /* notice validate is 0, keep this because the seq may not be added to the scene yet */
- BKE_animdata_fix_paths_rename(
- &scene->id, scene->adt, NULL, "sequence_editor.sequences_all", name_src, name_dst, 0, 0, 0);
-
- /* add the original fcurves back */
- BLI_movelisttolist(&scene->adt->action->curves, &lb);
-}
-
-/* XXX - hackish function needed to remove all fcurves belonging to a sequencer strip */
-static void seq_free_animdata(Scene *scene, Sequence *seq)
-{
- char str[SEQ_RNAPATH_MAXSTR];
- size_t str_len;
- FCurve *fcu;
-
- if (scene->adt == NULL || scene->adt->action == NULL) {
- return;
- }
-
- str_len = sequencer_rna_path_prefix(str, seq->name + 2);
-
- fcu = scene->adt->action->curves.first;
-
- while (fcu) {
- if (STREQLEN(fcu->rna_path, str, str_len)) {
- FCurve *next_fcu = fcu->next;
-
- BLI_remlink(&scene->adt->action->curves, fcu);
- BKE_fcurve_free(fcu);
-
- fcu = next_fcu;
- }
- else {
- fcu = fcu->next;
- }
- }
-}
-
-#undef SEQ_RNAPATH_MAXSTR
-
-Sequence *BKE_sequence_get_by_name(ListBase *seqbase, const char *name, bool recursive)
-{
- Sequence *iseq = NULL;
- Sequence *rseq = NULL;
-
- for (iseq = seqbase->first; iseq; iseq = iseq->next) {
- if (STREQ(name, iseq->name + 2)) {
- return iseq;
- }
- if (recursive && (iseq->seqbase.first) &&
- (rseq = BKE_sequence_get_by_name(&iseq->seqbase, name, 1))) {
- return rseq;
- }
- }
-
- return NULL;
-}
-
-/**
- * Only use as last resort when the StripElem is available but no the Sequence.
- * (needed for RNA)
- */
-Sequence *BKE_sequencer_from_elem(ListBase *seqbase, StripElem *se)
-{
- Sequence *iseq;
-
- for (iseq = seqbase->first; iseq; iseq = iseq->next) {
- Sequence *seq_found;
- if ((iseq->strip && iseq->strip->stripdata) &&
- (ARRAY_HAS_ITEM(se, iseq->strip->stripdata, iseq->len))) {
- break;
- }
- if ((seq_found = BKE_sequencer_from_elem(&iseq->seqbase, se))) {
- iseq = seq_found;
- break;
- }
- }
-
- return iseq;
-}
-
-Sequence *BKE_sequencer_active_get(Scene *scene)
-{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
-
- if (ed == NULL) {
- return NULL;
- }
-
- return ed->act_seq;
-}
-
-void BKE_sequencer_active_set(Scene *scene, Sequence *seq)
-{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
-
- if (ed == NULL) {
- return;
- }
-
- ed->act_seq = seq;
-}
-
-int BKE_sequencer_active_get_pair(Scene *scene, Sequence **seq_act, Sequence **seq_other)
-{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
-
- *seq_act = BKE_sequencer_active_get(scene);
-
- if (*seq_act == NULL) {
- return 0;
- }
-
- Sequence *seq;
-
- *seq_other = NULL;
-
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT && (seq != (*seq_act))) {
- if (*seq_other) {
- return 0;
- }
-
- *seq_other = seq;
- }
- }
-
- return (*seq_other != NULL);
-}
-
-Mask *BKE_sequencer_mask_get(Scene *scene)
-{
- Sequence *seq_act = BKE_sequencer_active_get(scene);
-
- if (seq_act && seq_act->type == SEQ_TYPE_MASK) {
- return seq_act->mask;
- }
-
- return NULL;
-}
-
-/* api like funcs for adding */
-
-static void seq_load_apply(Main *bmain, Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
-{
- if (seq) {
- BLI_strncpy_utf8(seq->name + 2, seq_load->name, sizeof(seq->name) - 2);
- BLI_utf8_invalid_strip(seq->name + 2, strlen(seq->name + 2));
- BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
-
- if (seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) {
- seq_load->start_frame += (seq->enddisp - seq->startdisp);
- }
-
- if (seq_load->flag & SEQ_LOAD_REPLACE_SEL) {
- seq_load->flag |= SELECT;
- BKE_sequencer_active_set(scene, seq);
- }
-
- if (seq_load->flag & SEQ_LOAD_SOUND_MONO) {
- seq->sound->flags |= SOUND_FLAGS_MONO;
- BKE_sound_load(bmain, seq->sound);
- }
-
- if (seq_load->flag & SEQ_LOAD_SOUND_CACHE) {
- if (seq->sound) {
- seq->sound->flags |= SOUND_FLAGS_CACHING;
- }
- }
-
- seq_load->tot_success++;
- }
- else {
- seq_load->tot_error++;
- }
-}
-
-static Strip *seq_strip_alloc(int type)
-{
- Strip *strip = MEM_callocN(sizeof(Strip), "strip");
-
- if (ELEM(type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD) == 0) {
- strip->transform = MEM_callocN(sizeof(struct StripTransform), "StripTransform");
- strip->crop = MEM_callocN(sizeof(struct StripCrop), "StripCrop");
- }
-
- strip->us = 1;
- return strip;
-}
-
-Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine, int type)
-{
- Sequence *seq;
-
- seq = MEM_callocN(sizeof(Sequence), "addseq");
- BLI_addtail(lb, seq);
-
- *((short *)seq->name) = ID_SEQ;
- seq->name[2] = 0;
-
- seq->flag = SELECT;
- seq->start = cfra;
- seq->machine = machine;
- seq->sat = 1.0;
- seq->mul = 1.0;
- seq->blend_opacity = 100.0;
- seq->volume = 1.0f;
- seq->pitch = 1.0f;
- seq->scene_sound = NULL;
- seq->type = type;
-
- seq->strip = seq_strip_alloc(type);
- seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Sequence Stereo Format");
- seq->cache_flag = SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_PREPROCESSED | SEQ_CACHE_STORE_COMPOSITE;
-
- BKE_sequence_session_uuid_generate(seq);
-
- return seq;
-}
-
-void BKE_sequence_session_uuid_generate(struct Sequence *sequence)
-{
- sequence->runtime.session_uuid = BLI_session_uuid_generate();
-}
-
-void BKE_sequence_alpha_mode_from_extension(Sequence *seq)
-{
- if (seq->strip && seq->strip->stripdata) {
- const char *filename = seq->strip->stripdata->name;
- seq->alpha_mode = BKE_image_alpha_mode_from_extension_ex(filename);
- }
-}
-
-void BKE_sequence_init_colorspace(Sequence *seq)
-{
- if (seq->strip && seq->strip->stripdata) {
- char name[FILE_MAX];
- ImBuf *ibuf;
-
- BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name);
- BLI_path_abs(name, BKE_main_blendfile_path_from_global());
-
- /* initialize input color space */
- if (seq->type == SEQ_TYPE_IMAGE) {
- ibuf = IMB_loadiffname(
- name, IB_test | IB_alphamode_detect, seq->strip->colorspace_settings.name);
-
- /* byte images are default to straight alpha, however sequencer
- * works in premul space, so mark strip to be premultiplied first
- */
- seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
- if (ibuf) {
- if (ibuf->flags & IB_alphamode_premul) {
- seq->alpha_mode = IMA_ALPHA_PREMUL;
- }
-
- IMB_freeImBuf(ibuf);
- }
+ if (seq->seq1 && seq->seq1->tmp) {
+ seq->seq1 = seq->seq1->tmp;
}
- }
-}
-
-float BKE_sequence_get_fps(Scene *scene, Sequence *seq)
-{
- switch (seq->type) {
- case SEQ_TYPE_MOVIE: {
- seq_open_anim_file(scene, seq, true);
- if (BLI_listbase_is_empty(&seq->anims)) {
- return 0.0f;
- }
- StripAnim *strip_anim = seq->anims.first;
- if (strip_anim->anim == NULL) {
- return 0.0f;
- }
- short frs_sec;
- float frs_sec_base;
- if (IMB_anim_get_fps(strip_anim->anim, &frs_sec, &frs_sec_base, true)) {
- return (float)frs_sec / frs_sec_base;
- }
- break;
+ if (seq->seq2 && seq->seq2->tmp) {
+ seq->seq2 = seq->seq2->tmp;
}
- case SEQ_TYPE_MOVIECLIP:
- if (seq->clip != NULL) {
- return BKE_movieclip_get_fps(seq->clip);
- }
- break;
- case SEQ_TYPE_SCENE:
- if (seq->scene != NULL) {
- return (float)seq->scene->r.frs_sec / seq->scene->r.frs_sec_base;
- }
- break;
- }
- return 0.0f;
-}
-
-/* NOTE: this function doesn't fill in image names */
-Sequence *BKE_sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
-{
- Scene *scene = CTX_data_scene(C); /* only for active seq */
- Sequence *seq;
- Strip *strip;
-
- seq = BKE_sequence_alloc(seqbasep, seq_load->start_frame, seq_load->channel, SEQ_TYPE_IMAGE);
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
-
- /* basic defaults */
- seq->len = seq_load->len ? seq_load->len : 1;
-
- strip = seq->strip;
- strip->stripdata = MEM_callocN(seq->len * sizeof(StripElem), "stripelem");
- BLI_strncpy(strip->dir, seq_load->path, sizeof(strip->dir));
-
- if (seq_load->stereo3d_format) {
- *seq->stereo3d_format = *seq_load->stereo3d_format;
- }
-
- seq->views_format = seq_load->views_format;
- seq->flag |= seq_load->flag & SEQ_USE_VIEWS;
-
- seq_load_apply(CTX_data_main(C), scene, seq, seq_load);
- BKE_sequence_invalidate_cache_composite(scene, seq);
-
- return seq;
-}
-
-#ifdef WITH_AUDASPACE
-Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
-{
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C); /* only for sound */
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- bSound *sound;
-
- Sequence *seq; /* generic strip vars */
- Strip *strip;
- StripElem *se;
-
- sound = BKE_sound_new_file(bmain, seq_load->path); /* handles relative paths */
-
- SoundInfo info;
- if (!BKE_sound_info_get(bmain, sound, &info)) {
- BKE_id_free(bmain, sound);
- return NULL;
- }
-
- if (info.specs.channels == SOUND_CHANNELS_INVALID) {
- BKE_id_free(bmain, sound);
- return NULL;
- }
-
- seq = BKE_sequence_alloc(seqbasep, seq_load->start_frame, seq_load->channel, SEQ_TYPE_SOUND_RAM);
- seq->sound = sound;
- BLI_strncpy(seq->name + 2, "Sound", SEQ_NAME_MAXSTR - 2);
- BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
-
- /* basic defaults */
- /* We add a very small negative offset here, because
- * ceil(132.0) == 133.0, not nice with videos, see T47135. */
- seq->len = (int)ceil((double)info.length * FPS - 1e-4);
- strip = seq->strip;
-
- /* we only need 1 element to store the filename */
- strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
-
- BLI_split_dirfile(seq_load->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
-
- seq->scene_sound = NULL;
-
- BKE_sequence_calc_disp(scene, seq);
-
- /* last active name */
- BLI_strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR);
-
- seq_load_apply(bmain, scene, seq, seq_load);
-
- /* TODO(sergey): Shall we tag here or in the operator? */
- DEG_relations_tag_update(bmain);
-
- return seq;
-}
-#else // WITH_AUDASPACE
-Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
-{
- (void)C;
- (void)seqbasep;
- (void)seq_load;
- return NULL;
-}
-#endif // WITH_AUDASPACE
-
-static void seq_anim_add_suffix(Scene *scene, struct anim *anim, const int view_id)
-{
- const char *suffix = BKE_scene_multiview_view_id_suffix_get(&scene->r, view_id);
- IMB_suffix_anim(anim, suffix);
-}
-
-Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
-{
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C); /* only for sound */
- char path[sizeof(seq_load->path)];
-
- Sequence *seq; /* generic strip vars */
- Strip *strip;
- StripElem *se;
- char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */
- bool is_multiview_loaded = false;
- const bool is_multiview = (seq_load->flag & SEQ_USE_VIEWS) != 0;
- const int totfiles = seq_num_files(scene, seq_load->views_format, is_multiview);
- struct anim **anim_arr;
- int i;
-
- BLI_strncpy(path, seq_load->path, sizeof(path));
- BLI_path_abs(path, BKE_main_blendfile_path(bmain));
-
- anim_arr = MEM_callocN(sizeof(struct anim *) * totfiles, "Video files");
-
- if (is_multiview && (seq_load->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
- char prefix[FILE_MAX];
- const char *ext = NULL;
- size_t j = 0;
-
- BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext);
-
- if (prefix[0] != '\0') {
- for (i = 0; i < totfiles; i++) {
- char str[FILE_MAX];
-
- seq_multiview_name(scene, i, prefix, ext, str, FILE_MAX);
- anim_arr[j] = openanim(str, IB_rect, 0, colorspace);
-
- if (anim_arr[j]) {
- seq_anim_add_suffix(scene, anim_arr[j], i);
- j++;
- }
- }
-
- if (j == 0) {
- MEM_freeN(anim_arr);
- return NULL;
- }
- is_multiview_loaded = true;
+ if (seq->seq3 && seq->seq3->tmp) {
+ seq->seq3 = seq->seq3->tmp;
}
}
-
- if (is_multiview_loaded == false) {
- anim_arr[0] = openanim(path, IB_rect, 0, colorspace);
-
- if (anim_arr[0] == NULL) {
- MEM_freeN(anim_arr);
- return NULL;
+ else if (seq->type == SEQ_TYPE_META) {
+ Sequence *seqn;
+ for (seqn = seq->seqbase.first; seqn; seqn = seqn->next) {
+ seq_new_fix_links_recursive(seqn);
}
}
- if (seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
- seq_load->channel++;
- }
- seq = BKE_sequence_alloc(seqbasep, seq_load->start_frame, seq_load->channel, SEQ_TYPE_MOVIE);
-
- /* multiview settings */
- if (seq_load->stereo3d_format) {
- *seq->stereo3d_format = *seq_load->stereo3d_format;
- seq->views_format = seq_load->views_format;
- }
- seq->flag |= seq_load->flag & SEQ_USE_VIEWS;
-
- seq->type = SEQ_TYPE_MOVIE;
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
-
- for (i = 0; i < totfiles; i++) {
- if (anim_arr[i]) {
- StripAnim *sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
- BLI_addtail(&seq->anims, sanim);
- sanim->anim = anim_arr[i];
- }
- else {
- break;
+ for (smd = seq->modifiers.first; smd; smd = smd->next) {
+ if (smd->mask_sequence && smd->mask_sequence->tmp) {
+ smd->mask_sequence = smd->mask_sequence->tmp;
}
}
-
- IMB_anim_load_metadata(anim_arr[0]);
-
- seq->anim_preseek = IMB_anim_get_preseek(anim_arr[0]);
- BLI_strncpy(seq->name + 2, "Movie", SEQ_NAME_MAXSTR - 2);
- BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
-
- /* adjust scene's frame rate settings to match */
- if (seq_load->flag & SEQ_LOAD_SYNC_FPS) {
- IMB_anim_get_fps(anim_arr[0], &scene->r.frs_sec, &scene->r.frs_sec_base, true);
- }
-
- /* basic defaults */
- seq->len = IMB_anim_get_duration(anim_arr[0], IMB_TC_RECORD_RUN);
- strip = seq->strip;
-
- BLI_strncpy(seq->strip->colorspace_settings.name,
- colorspace,
- sizeof(seq->strip->colorspace_settings.name));
-
- /* we only need 1 element for MOVIE strips */
- strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
-
- BLI_split_dirfile(seq_load->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
-
- BKE_sequence_calc_disp(scene, seq);
-
- if (seq_load->name[0] == '\0') {
- BLI_strncpy(seq_load->name, se->name, sizeof(seq_load->name));
- }
-
- if (seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
- int start_frame_back = seq_load->start_frame;
- seq_load->channel--;
- seq_load->seq_sound = BKE_sequencer_add_sound_strip(C, seqbasep, seq_load);
- seq_load->start_frame = start_frame_back;
- }
-
- /* can be NULL */
- seq_load_apply(CTX_data_main(C), scene, seq, seq_load);
- BKE_sequence_invalidate_cache_composite(scene, seq);
-
- MEM_freeN(anim_arr);
- return seq;
}
+/** \} */
+/* -------------------------------------------------------------------- */
+/** \name Duplicate Functions
+ * \{ */
static Sequence *seq_dupli(const Scene *scene_src,
Scene *scene_dst,
ListBase *new_seq_list,
@@ -5799,35 +419,6 @@ static Sequence *seq_dupli(const Scene *scene_src,
return seqn;
}
-static void seq_new_fix_links_recursive(Sequence *seq)
-{
- SequenceModifierData *smd;
-
- if (seq->type & SEQ_TYPE_EFFECT) {
- if (seq->seq1 && seq->seq1->tmp) {
- seq->seq1 = seq->seq1->tmp;
- }
- if (seq->seq2 && seq->seq2->tmp) {
- seq->seq2 = seq->seq2->tmp;
- }
- if (seq->seq3 && seq->seq3->tmp) {
- seq->seq3 = seq->seq3->tmp;
- }
- }
- else if (seq->type == SEQ_TYPE_META) {
- Sequence *seqn;
- for (seqn = seq->seqbase.first; seqn; seqn = seqn->next) {
- seq_new_fix_links_recursive(seqn);
- }
- }
-
- for (smd = seq->modifiers.first; smd; smd = smd->next) {
- if (smd->mask_sequence && smd->mask_sequence->tmp) {
- smd->mask_sequence = smd->mask_sequence->tmp;
- }
- }
-}
-
static Sequence *sequence_dupli_recursive_do(const Scene *scene_src,
Scene *scene_dst,
ListBase *new_seq_list,
@@ -5907,297 +498,115 @@ void BKE_sequence_base_dupli_recursive(const Scene *scene_src,
seq_new_fix_links_recursive(seq);
}
}
+/* r_prefix + [" + escaped_name + "] + \0 */
+#define SEQ_RNAPATH_MAXSTR ((30 + 2 + (SEQ_NAME_MAXSTR * 2) + 2) + 1)
-/* called on draw, needs to be fast,
- * we could cache and use a flag if we want to make checks for file paths resolving for eg. */
-bool BKE_sequence_is_valid_check(Sequence *seq)
+static size_t sequencer_rna_path_prefix(char str[SEQ_RNAPATH_MAXSTR], const char *name)
{
- switch (seq->type) {
- case SEQ_TYPE_MASK:
- return (seq->mask != NULL);
- case SEQ_TYPE_MOVIECLIP:
- return (seq->clip != NULL);
- case SEQ_TYPE_SCENE:
- return (seq->scene != NULL);
- case SEQ_TYPE_SOUND_RAM:
- return (seq->sound != NULL);
- }
+ char name_esc[SEQ_NAME_MAXSTR * 2];
- return true;
+ BLI_strescape(name_esc, name, sizeof(name_esc));
+ return BLI_snprintf_rlen(
+ str, SEQ_RNAPATH_MAXSTR, "sequence_editor.sequences_all[\"%s\"]", name_esc);
}
-int BKE_sequencer_find_next_prev_edit(Scene *scene,
- int cfra,
- const short side,
- const bool do_skip_mute,
- const bool do_center,
- const bool do_unselected)
+/* XXX - hackish function needed for transforming strips! TODO - have some better solution */
+void BKE_sequencer_offset_animdata(Scene *scene, Sequence *seq, int ofs)
{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
-
- int dist, best_dist, best_frame = cfra;
- int seq_frames[2], seq_frames_tot;
-
- /* In case where both is passed,
- * frame just finds the nearest end while frame_left the nearest start. */
-
- best_dist = MAXFRAME * 2;
+ char str[SEQ_RNAPATH_MAXSTR];
+ size_t str_len;
+ FCurve *fcu;
- if (ed == NULL) {
- return cfra;
+ if (scene->adt == NULL || ofs == 0 || scene->adt->action == NULL) {
+ return;
}
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- int i;
-
- if (do_skip_mute && (seq->flag & SEQ_MUTE)) {
- continue;
- }
-
- if (do_unselected && (seq->flag & SELECT)) {
- continue;
- }
-
- if (do_center) {
- seq_frames[0] = (seq->startdisp + seq->enddisp) / 2;
- seq_frames_tot = 1;
- }
- else {
- seq_frames[0] = seq->startdisp;
- seq_frames[1] = seq->enddisp;
-
- seq_frames_tot = 2;
- }
-
- for (i = 0; i < seq_frames_tot; i++) {
- const int seq_frame = seq_frames[i];
-
- dist = MAXFRAME * 2;
+ str_len = sequencer_rna_path_prefix(str, seq->name + 2);
- switch (side) {
- case SEQ_SIDE_LEFT:
- if (seq_frame < cfra) {
- dist = cfra - seq_frame;
- }
- break;
- case SEQ_SIDE_RIGHT:
- if (seq_frame > cfra) {
- dist = seq_frame - cfra;
- }
- break;
- case SEQ_SIDE_BOTH:
- dist = abs(seq_frame - cfra);
- break;
+ for (fcu = scene->adt->action->curves.first; fcu; fcu = fcu->next) {
+ if (STREQLEN(fcu->rna_path, str, str_len)) {
+ unsigned int i;
+ if (fcu->bezt) {
+ for (i = 0; i < fcu->totvert; i++) {
+ BezTriple *bezt = &fcu->bezt[i];
+ bezt->vec[0][0] += ofs;
+ bezt->vec[1][0] += ofs;
+ bezt->vec[2][0] += ofs;
+ }
}
-
- if (dist < best_dist) {
- best_frame = seq_frame;
- best_dist = dist;
+ if (fcu->fpt) {
+ for (i = 0; i < fcu->totvert; i++) {
+ FPoint *fpt = &fcu->fpt[i];
+ fpt->vec[0] += ofs;
+ }
}
}
}
- return best_frame;
+ DEG_id_tag_update(&scene->adt->action->id, ID_RECALC_ANIMATION);
}
-static void sequencer_all_free_anim_ibufs(ListBase *seqbase, int cfra)
+void BKE_sequencer_dupe_animdata(Scene *scene, const char *name_src, const char *name_dst)
{
- for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
- if (seq->enddisp < cfra || seq->startdisp > cfra) {
- BKE_sequence_free_anim(seq);
- }
- if (seq->type == SEQ_TYPE_META) {
- sequencer_all_free_anim_ibufs(&seq->seqbase, cfra);
- }
- }
-}
+ char str_from[SEQ_RNAPATH_MAXSTR];
+ size_t str_from_len;
+ FCurve *fcu;
+ FCurve *fcu_last;
+ FCurve *fcu_cpy;
+ ListBase lb = {NULL, NULL};
-void BKE_sequencer_all_free_anim_ibufs(Scene *scene, int cfra)
-{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed == NULL) {
+ if (scene->adt == NULL || scene->adt->action == NULL) {
return;
}
- sequencer_all_free_anim_ibufs(&ed->seqbase, cfra);
- BKE_sequencer_cache_cleanup(scene);
-}
-
-static bool sequencer_seq_generates_image(Sequence *seq)
-{
- switch (seq->type) {
- case SEQ_TYPE_IMAGE:
- case SEQ_TYPE_SCENE:
- case SEQ_TYPE_MOVIE:
- case SEQ_TYPE_MOVIECLIP:
- case SEQ_TYPE_MASK:
- case SEQ_TYPE_COLOR:
- case SEQ_TYPE_TEXT:
- return true;
- }
- return false;
-}
-
-static Sequence *sequencer_check_scene_recursion(Scene *scene, ListBase *seqbase)
-{
- LISTBASE_FOREACH (Sequence *, seq, seqbase) {
- if (seq->type == SEQ_TYPE_SCENE && seq->scene == scene) {
- return seq;
- }
-
- if (seq->type == SEQ_TYPE_SCENE && (seq->flag & SEQ_SCENE_STRIPS)) {
- if (sequencer_check_scene_recursion(scene, &seq->scene->ed->seqbase)) {
- return seq;
- }
- }
-
- if (seq->type == SEQ_TYPE_META && sequencer_check_scene_recursion(scene, &seq->seqbase)) {
- return seq;
- }
- }
- return NULL;
-}
-
-bool BKE_sequencer_check_scene_recursion(Scene *scene, ReportList *reports)
-{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed == NULL) {
- return false;
- }
-
- Sequence *recursive_seq = sequencer_check_scene_recursion(scene, &ed->seqbase);
+ str_from_len = sequencer_rna_path_prefix(str_from, name_src);
- if (recursive_seq != NULL) {
- BKE_reportf(reports,
- RPT_WARNING,
- "Recursion detected in video sequencer. Strip %s at frame %d will not be rendered",
- recursive_seq->name + 2,
- recursive_seq->startdisp);
+ fcu_last = scene->adt->action->curves.last;
- LISTBASE_FOREACH (Sequence *, seq, &ed->seqbase) {
- if (seq->type != SEQ_TYPE_SCENE && sequencer_seq_generates_image(seq)) {
- /* There are other strips to render, so render them. */
- return false;
- }
+ for (fcu = scene->adt->action->curves.first; fcu && fcu->prev != fcu_last; fcu = fcu->next) {
+ if (STREQLEN(fcu->rna_path, str_from, str_from_len)) {
+ fcu_cpy = BKE_fcurve_copy(fcu);
+ BLI_addtail(&lb, fcu_cpy);
}
- /* No other strips to render - cancel operator. */
- return true;
- }
-
- return false;
-}
-
-/* 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;
}
- if ((seq_main->seq1 && BKE_sequencer_render_loop_check(seq_main->seq1, seq)) ||
- (seq_main->seq2 && BKE_sequencer_render_loop_check(seq_main->seq2, seq)) ||
- (seq_main->seq3 && BKE_sequencer_render_loop_check(seq_main->seq3, seq))) {
- return true;
- }
-
- SequenceModifierData *smd;
- for (smd = seq_main->modifiers.first; smd; smd = smd->next) {
- if (smd->mask_sequence && BKE_sequencer_render_loop_check(smd->mask_sequence, seq)) {
- return true;
- }
- }
+ /* notice validate is 0, keep this because the seq may not be added to the scene yet */
+ BKE_animdata_fix_paths_rename(
+ &scene->id, scene->adt, NULL, "sequence_editor.sequences_all", name_src, name_dst, 0, 0, 0);
- return false;
+ /* add the original fcurves back */
+ BLI_movelisttolist(&scene->adt->action->curves, &lb);
}
-static void sequencer_flag_users_for_removal(Scene *scene, ListBase *seqbase, Sequence *seq)
+/* XXX - hackish function needed to remove all fcurves belonging to a sequencer strip */
+static void seq_free_animdata(Scene *scene, Sequence *seq)
{
- LISTBASE_FOREACH (Sequence *, user_seq, seqbase) {
- /* Look in metas for usage of seq. */
- if (user_seq->type == SEQ_TYPE_META) {
- sequencer_flag_users_for_removal(scene, &user_seq->seqbase, seq);
- }
-
- /* Clear seq from modifiers. */
- SequenceModifierData *smd;
- for (smd = user_seq->modifiers.first; smd; smd = smd->next) {
- if (smd->mask_sequence == seq) {
- smd->mask_sequence = NULL;
- }
- }
-
- /* Remove effects, that use seq. */
- if ((user_seq->seq1 && user_seq->seq1 == seq) || (user_seq->seq2 && user_seq->seq2 == seq) ||
- (user_seq->seq3 && user_seq->seq3 == seq)) {
- user_seq->flag |= SEQ_FLAG_DELETE;
- /* Strips can be used as mask even if not in same seqbase. */
- sequencer_flag_users_for_removal(scene, &scene->ed->seqbase, user_seq);
- }
- }
-}
+ char str[SEQ_RNAPATH_MAXSTR];
+ size_t str_len;
+ FCurve *fcu;
-/* Flag seq and its users (effects) for removal. */
-void BKE_sequencer_flag_for_removal(Scene *scene, ListBase *seqbase, Sequence *seq)
-{
- if (seq == NULL || (seq->flag & SEQ_FLAG_DELETE) != 0) {
+ if (scene->adt == NULL || scene->adt->action == NULL) {
return;
}
- /* Flag and remove meta children. */
- if (seq->type == SEQ_TYPE_META) {
- LISTBASE_FOREACH (Sequence *, meta_child, &seq->seqbase) {
- BKE_sequencer_flag_for_removal(scene, &seq->seqbase, meta_child);
- }
- }
-
- seq->flag |= SEQ_FLAG_DELETE;
- sequencer_flag_users_for_removal(scene, seqbase, seq);
-}
+ str_len = sequencer_rna_path_prefix(str, seq->name + 2);
-/* Remove all flagged sequences, return true if sequence is removed. */
-void BKE_sequencer_remove_flagged_sequences(Scene *scene, ListBase *seqbase)
-{
- LISTBASE_FOREACH_MUTABLE (Sequence *, seq, seqbase) {
- if (seq->flag & SEQ_FLAG_DELETE) {
- if (seq->type == SEQ_TYPE_META) {
- BKE_sequencer_remove_flagged_sequences(scene, &seq->seqbase);
- }
- BLI_remlink(seqbase, seq);
- BKE_sequence_free(scene, seq, true);
- }
- }
-}
+ fcu = scene->adt->action->curves.first;
-void BKE_sequencer_check_uuids_unique_and_report(const Scene *scene)
-{
- if (scene->ed == NULL) {
- return;
- }
+ while (fcu) {
+ if (STREQLEN(fcu->rna_path, str, str_len)) {
+ FCurve *next_fcu = fcu->next;
- struct GSet *used_uuids = BLI_gset_new(
- BLI_session_uuid_ghash_hash, BLI_session_uuid_ghash_compare, "sequencer used uuids");
+ BLI_remlink(&scene->adt->action->curves, fcu);
+ BKE_fcurve_free(fcu);
- const Sequence *sequence;
- SEQ_ALL_BEGIN (scene->ed, sequence) {
- const SessionUUID *session_uuid = &sequence->runtime.session_uuid;
- if (!BLI_session_uuid_is_generated(session_uuid)) {
- printf("Sequence %s does not have UUID generated.\n", sequence->name);
- continue;
+ fcu = next_fcu;
}
-
- if (BLI_gset_lookup(used_uuids, session_uuid) != NULL) {
- printf("Sequence %s has duplicate UUID generated.\n", sequence->name);
- continue;
+ else {
+ fcu = fcu->next;
}
-
- BLI_gset_insert(used_uuids, (void *)session_uuid);
}
- SEQ_ALL_END;
-
- BLI_gset_free(used_uuids, NULL);
}
+
+#undef SEQ_RNAPATH_MAXSTR
+/** \} */
diff --git a/source/blender/sequencer/intern/sequencer.h b/source/blender/sequencer/intern/sequencer.h
new file mode 100644
index 00000000000..928b3edd728
--- /dev/null
+++ b/source/blender/sequencer/intern/sequencer.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.
+ *
+ * The Original Code is Copyright (C) 2004 Blender Foundation.
+ * All rights reserved.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup sequencer
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct Scene;
+struct Sequence;
+
+void seq_free_sequence_recurse(struct Scene *scene, struct Sequence *seq, const bool do_id_user);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/sequencer/intern/sound.c b/source/blender/sequencer/intern/sound.c
new file mode 100644
index 00000000000..9549938abee
--- /dev/null
+++ b/source/blender/sequencer/intern/sound.c
@@ -0,0 +1,163 @@
+/*
+ * 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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include <math.h>
+
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_sound_types.h"
+
+#include "BLI_listbase.h"
+
+#include "BKE_main.h"
+#include "BKE_scene.h"
+#include "BKE_sound.h"
+
+#include "SEQ_sequencer.h"
+
+#include "strip_time.h"
+
+void BKE_sequence_sound_init(Scene *scene, Sequence *seq);
+
+void BKE_sequence_sound_init(Scene *scene, Sequence *seq)
+{
+ if (seq->type == SEQ_TYPE_META) {
+ Sequence *seq_child;
+ for (seq_child = seq->seqbase.first; seq_child; seq_child = seq_child->next) {
+ BKE_sequence_sound_init(scene, seq_child);
+ }
+ }
+ else {
+ if (seq->sound) {
+ seq->scene_sound = BKE_sound_add_scene_sound_defaults(scene, seq);
+ }
+ if (seq->scene) {
+ seq->scene_sound = BKE_sound_scene_add_scene_sound_defaults(scene, seq);
+ }
+ }
+}
+
+/* Unlike _update_sound_ funcs, these ones take info from audaspace to update sequence length! */
+#ifdef WITH_AUDASPACE
+static bool sequencer_refresh_sound_length_recursive(Main *bmain, Scene *scene, ListBase *seqbase)
+{
+ Sequence *seq;
+ bool changed = false;
+
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ if (seq->type == SEQ_TYPE_META) {
+ if (sequencer_refresh_sound_length_recursive(bmain, scene, &seq->seqbase)) {
+ BKE_sequence_calc(scene, seq);
+ changed = true;
+ }
+ }
+ else if (seq->type == SEQ_TYPE_SOUND_RAM && seq->sound) {
+ const float length = BKE_sound_get_length(bmain, seq->sound);
+ int old = seq->len;
+ float fac;
+
+ seq->len = (int)ceil((double)length * FPS);
+ fac = (float)seq->len / (float)old;
+ old = seq->startofs;
+ seq->startofs *= fac;
+ seq->endofs *= fac;
+ seq->start += (old - seq->startofs); /* So that visual/"real" start frame does not change! */
+
+ BKE_sequence_calc(scene, seq);
+ changed = true;
+ }
+ }
+ return changed;
+}
+#endif
+
+void BKE_sequencer_refresh_sound_length(Main *bmain, Scene *scene)
+{
+#ifdef WITH_AUDASPACE
+ if (scene->ed) {
+ sequencer_refresh_sound_length_recursive(bmain, scene, &scene->ed->seqbase);
+ }
+#else
+ UNUSED_VARS(bmain, scene);
+#endif
+}
+
+void BKE_sequencer_update_sound_bounds_all(Scene *scene)
+{
+ Editing *ed = scene->ed;
+
+ if (ed) {
+ Sequence *seq;
+
+ for (seq = ed->seqbase.first; seq; seq = seq->next) {
+ if (seq->type == SEQ_TYPE_META) {
+ seq_update_sound_bounds_recursive(scene, seq);
+ }
+ else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
+ BKE_sequencer_update_sound_bounds(scene, seq);
+ }
+ }
+ }
+}
+
+void BKE_sequencer_update_sound_bounds(Scene *scene, Sequence *seq)
+{
+ if (seq->type == SEQ_TYPE_SCENE) {
+ if (seq->scene && seq->scene_sound) {
+ /* We have to take into account start frame of the sequence's scene! */
+ int startofs = seq->startofs + seq->anim_startofs + seq->scene->r.sfra;
+
+ BKE_sound_move_scene_sound(scene, seq->scene_sound, seq->startdisp, seq->enddisp, startofs);
+ }
+ }
+ else {
+ BKE_sound_move_scene_sound_defaults(scene, seq);
+ }
+ /* mute is set in seq_update_muting_recursive */
+}
+
+static void seq_update_sound_recursive(Scene *scene, ListBase *seqbasep, bSound *sound)
+{
+ Sequence *seq;
+
+ for (seq = seqbasep->first; seq; seq = seq->next) {
+ if (seq->type == SEQ_TYPE_META) {
+ seq_update_sound_recursive(scene, &seq->seqbase, sound);
+ }
+ else if (seq->type == SEQ_TYPE_SOUND_RAM) {
+ if (seq->scene_sound && sound == seq->sound) {
+ BKE_sound_update_scene_sound(seq->scene_sound, sound);
+ }
+ }
+ }
+}
+
+void BKE_sequencer_update_sound(Scene *scene, bSound *sound)
+{
+ if (scene->ed) {
+ seq_update_sound_recursive(scene, &scene->ed->seqbase, sound);
+ }
+}
diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c
new file mode 100644
index 00000000000..d2e4025bdfc
--- /dev/null
+++ b/source/blender/sequencer/intern/strip_add.c
@@ -0,0 +1,551 @@
+/*
+ * 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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include <math.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_sound_types.h"
+
+#include "BLI_listbase.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+#include "BLI_string_utf8.h"
+
+#include "BKE_context.h"
+#include "BKE_image.h"
+#include "BKE_lib_id.h"
+#include "BKE_main.h"
+#include "BKE_mask.h"
+#include "BKE_movieclip.h"
+#include "BKE_scene.h"
+#include "BKE_sound.h"
+
+#include "DEG_depsgraph_query.h"
+
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_metadata.h"
+
+#include "SEQ_sequencer.h"
+
+#include "multiview.h"
+#include "proxy.h"
+#include "utils.h"
+
+static void seq_load_apply(Main *bmain, Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
+{
+ if (seq) {
+ BLI_strncpy_utf8(seq->name + 2, seq_load->name, sizeof(seq->name) - 2);
+ BLI_utf8_invalid_strip(seq->name + 2, strlen(seq->name + 2));
+ BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
+
+ if (seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) {
+ seq_load->start_frame += (seq->enddisp - seq->startdisp);
+ }
+
+ if (seq_load->flag & SEQ_LOAD_REPLACE_SEL) {
+ seq_load->flag |= SELECT;
+ BKE_sequencer_active_set(scene, seq);
+ }
+
+ if (seq_load->flag & SEQ_LOAD_SOUND_MONO) {
+ seq->sound->flags |= SOUND_FLAGS_MONO;
+ BKE_sound_load(bmain, seq->sound);
+ }
+
+ if (seq_load->flag & SEQ_LOAD_SOUND_CACHE) {
+ if (seq->sound) {
+ seq->sound->flags |= SOUND_FLAGS_CACHING;
+ }
+ }
+
+ seq_load->tot_success++;
+ }
+ else {
+ seq_load->tot_error++;
+ }
+}
+
+/* NOTE: this function doesn't fill in image names */
+Sequence *BKE_sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
+{
+ Scene *scene = CTX_data_scene(C); /* only for active seq */
+ Sequence *seq;
+ Strip *strip;
+
+ seq = BKE_sequence_alloc(seqbasep, seq_load->start_frame, seq_load->channel, SEQ_TYPE_IMAGE);
+ seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+
+ /* basic defaults */
+ seq->len = seq_load->len ? seq_load->len : 1;
+
+ strip = seq->strip;
+ strip->stripdata = MEM_callocN(seq->len * sizeof(StripElem), "stripelem");
+ BLI_strncpy(strip->dir, seq_load->path, sizeof(strip->dir));
+
+ if (seq_load->stereo3d_format) {
+ *seq->stereo3d_format = *seq_load->stereo3d_format;
+ }
+
+ seq->views_format = seq_load->views_format;
+ seq->flag |= seq_load->flag & SEQ_USE_VIEWS;
+
+ seq_load_apply(CTX_data_main(C), scene, seq, seq_load);
+ BKE_sequence_invalidate_cache_composite(scene, seq);
+
+ return seq;
+}
+
+#ifdef WITH_AUDASPACE
+Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
+{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C); /* only for sound */
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ bSound *sound;
+
+ Sequence *seq; /* generic strip vars */
+ Strip *strip;
+ StripElem *se;
+
+ sound = BKE_sound_new_file(bmain, seq_load->path); /* handles relative paths */
+
+ SoundInfo info;
+ if (!BKE_sound_info_get(bmain, sound, &info)) {
+ BKE_id_free(bmain, sound);
+ return NULL;
+ }
+
+ if (info.specs.channels == SOUND_CHANNELS_INVALID) {
+ BKE_id_free(bmain, sound);
+ return NULL;
+ }
+
+ seq = BKE_sequence_alloc(seqbasep, seq_load->start_frame, seq_load->channel, SEQ_TYPE_SOUND_RAM);
+ seq->sound = sound;
+ BLI_strncpy(seq->name + 2, "Sound", SEQ_NAME_MAXSTR - 2);
+ BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
+
+ /* basic defaults */
+ /* We add a very small negative offset here, because
+ * ceil(132.0) == 133.0, not nice with videos, see T47135. */
+ seq->len = (int)ceil((double)info.length * FPS - 1e-4);
+ strip = seq->strip;
+
+ /* we only need 1 element to store the filename */
+ strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
+
+ BLI_split_dirfile(seq_load->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
+
+ seq->scene_sound = NULL;
+
+ BKE_sequence_calc_disp(scene, seq);
+
+ /* last active name */
+ BLI_strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR);
+
+ seq_load_apply(bmain, scene, seq, seq_load);
+
+ /* TODO(sergey): Shall we tag here or in the operator? */
+ DEG_relations_tag_update(bmain);
+
+ return seq;
+}
+#else // WITH_AUDASPACE
+Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
+{
+ (void)C;
+ (void)seqbasep;
+ (void)seq_load;
+ return NULL;
+}
+#endif // WITH_AUDASPACE
+
+Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
+{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C); /* only for sound */
+ char path[sizeof(seq_load->path)];
+
+ Sequence *seq; /* generic strip vars */
+ Strip *strip;
+ StripElem *se;
+ char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */
+ bool is_multiview_loaded = false;
+ const bool is_multiview = (seq_load->flag & SEQ_USE_VIEWS) != 0;
+ const int totfiles = seq_num_files(scene, seq_load->views_format, is_multiview);
+ struct anim **anim_arr;
+ int i;
+
+ BLI_strncpy(path, seq_load->path, sizeof(path));
+ BLI_path_abs(path, BKE_main_blendfile_path(bmain));
+
+ anim_arr = MEM_callocN(sizeof(struct anim *) * totfiles, "Video files");
+
+ if (is_multiview && (seq_load->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
+ char prefix[FILE_MAX];
+ const char *ext = NULL;
+ size_t j = 0;
+
+ BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext);
+
+ if (prefix[0] != '\0') {
+ for (i = 0; i < totfiles; i++) {
+ char str[FILE_MAX];
+
+ seq_multiview_name(scene, i, prefix, ext, str, FILE_MAX);
+ anim_arr[j] = openanim(str, IB_rect, 0, colorspace);
+
+ if (anim_arr[j]) {
+ seq_anim_add_suffix(scene, anim_arr[j], i);
+ j++;
+ }
+ }
+
+ if (j == 0) {
+ MEM_freeN(anim_arr);
+ return NULL;
+ }
+ is_multiview_loaded = true;
+ }
+ }
+
+ if (is_multiview_loaded == false) {
+ anim_arr[0] = openanim(path, IB_rect, 0, colorspace);
+
+ if (anim_arr[0] == NULL) {
+ MEM_freeN(anim_arr);
+ return NULL;
+ }
+ }
+
+ if (seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
+ seq_load->channel++;
+ }
+ seq = BKE_sequence_alloc(seqbasep, seq_load->start_frame, seq_load->channel, SEQ_TYPE_MOVIE);
+
+ /* multiview settings */
+ if (seq_load->stereo3d_format) {
+ *seq->stereo3d_format = *seq_load->stereo3d_format;
+ seq->views_format = seq_load->views_format;
+ }
+ seq->flag |= seq_load->flag & SEQ_USE_VIEWS;
+
+ seq->type = SEQ_TYPE_MOVIE;
+ seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+
+ for (i = 0; i < totfiles; i++) {
+ if (anim_arr[i]) {
+ StripAnim *sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
+ BLI_addtail(&seq->anims, sanim);
+ sanim->anim = anim_arr[i];
+ }
+ else {
+ break;
+ }
+ }
+
+ IMB_anim_load_metadata(anim_arr[0]);
+
+ seq->anim_preseek = IMB_anim_get_preseek(anim_arr[0]);
+ BLI_strncpy(seq->name + 2, "Movie", SEQ_NAME_MAXSTR - 2);
+ BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
+
+ /* adjust scene's frame rate settings to match */
+ if (seq_load->flag & SEQ_LOAD_SYNC_FPS) {
+ IMB_anim_get_fps(anim_arr[0], &scene->r.frs_sec, &scene->r.frs_sec_base, true);
+ }
+
+ /* basic defaults */
+ seq->len = IMB_anim_get_duration(anim_arr[0], IMB_TC_RECORD_RUN);
+ strip = seq->strip;
+
+ BLI_strncpy(seq->strip->colorspace_settings.name,
+ colorspace,
+ sizeof(seq->strip->colorspace_settings.name));
+
+ /* we only need 1 element for MOVIE strips */
+ strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
+
+ BLI_split_dirfile(seq_load->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
+
+ BKE_sequence_calc_disp(scene, seq);
+
+ if (seq_load->name[0] == '\0') {
+ BLI_strncpy(seq_load->name, se->name, sizeof(seq_load->name));
+ }
+
+ if (seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
+ int start_frame_back = seq_load->start_frame;
+ seq_load->channel--;
+ seq_load->seq_sound = BKE_sequencer_add_sound_strip(C, seqbasep, seq_load);
+ seq_load->start_frame = start_frame_back;
+ }
+
+ /* can be NULL */
+ seq_load_apply(CTX_data_main(C), scene, seq, seq_load);
+ BKE_sequence_invalidate_cache_composite(scene, seq);
+
+ MEM_freeN(anim_arr);
+ return seq;
+}
+
+/* note: caller should run BKE_sequence_calc(scene, seq) after */
+void BKE_sequence_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const bool lock_range)
+{
+ char path[FILE_MAX];
+ int prev_startdisp = 0, prev_enddisp = 0;
+ /* note: don't rename the strip, will break animation curves */
+
+ if (ELEM(seq->type,
+ SEQ_TYPE_MOVIE,
+ SEQ_TYPE_IMAGE,
+ SEQ_TYPE_SOUND_RAM,
+ SEQ_TYPE_SCENE,
+ SEQ_TYPE_META,
+ SEQ_TYPE_MOVIECLIP,
+ SEQ_TYPE_MASK) == 0) {
+ return;
+ }
+
+ if (lock_range) {
+ /* keep so we don't have to move the actual start and end points (only the data) */
+ BKE_sequence_calc_disp(scene, seq);
+ prev_startdisp = seq->startdisp;
+ prev_enddisp = seq->enddisp;
+ }
+
+ switch (seq->type) {
+ case SEQ_TYPE_IMAGE: {
+ /* Hack? */
+ size_t olen = MEM_allocN_len(seq->strip->stripdata) / sizeof(StripElem);
+
+ seq->len = olen;
+ seq->len -= seq->anim_startofs;
+ seq->len -= seq->anim_endofs;
+ if (seq->len < 0) {
+ seq->len = 0;
+ }
+ break;
+ }
+ case SEQ_TYPE_MOVIE: {
+ StripAnim *sanim;
+ bool is_multiview_loaded = false;
+ const bool is_multiview = (seq->flag & SEQ_USE_VIEWS) != 0 &&
+ (scene->r.scemode & R_MULTIVIEW) != 0;
+
+ BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name);
+ BLI_path_abs(path, BKE_main_blendfile_path_from_global());
+
+ BKE_sequence_free_anim(seq);
+
+ if (is_multiview && (seq->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
+ char prefix[FILE_MAX];
+ const char *ext = NULL;
+ const int totfiles = seq_num_files(scene, seq->views_format, true);
+ int i = 0;
+
+ BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext);
+
+ if (prefix[0] != '\0') {
+ for (i = 0; i < totfiles; i++) {
+ struct anim *anim;
+ char str[FILE_MAX];
+
+ seq_multiview_name(scene, i, prefix, ext, str, FILE_MAX);
+ anim = openanim(str,
+ IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex,
+ seq->strip->colorspace_settings.name);
+
+ if (anim) {
+ seq_anim_add_suffix(scene, anim, i);
+ sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
+ BLI_addtail(&seq->anims, sanim);
+ sanim->anim = anim;
+ }
+ }
+ is_multiview_loaded = true;
+ }
+ }
+
+ if (is_multiview_loaded == false) {
+ struct anim *anim;
+ anim = openanim(path,
+ IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex,
+ seq->strip->colorspace_settings.name);
+ if (anim) {
+ sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
+ BLI_addtail(&seq->anims, sanim);
+ sanim->anim = anim;
+ }
+ }
+
+ /* use the first video as reference for everything */
+ sanim = seq->anims.first;
+
+ if ((!sanim) || (!sanim->anim)) {
+ return;
+ }
+
+ IMB_anim_load_metadata(sanim->anim);
+
+ seq->len = IMB_anim_get_duration(
+ sanim->anim, seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN);
+
+ seq->anim_preseek = IMB_anim_get_preseek(sanim->anim);
+
+ seq->len -= seq->anim_startofs;
+ seq->len -= seq->anim_endofs;
+ if (seq->len < 0) {
+ seq->len = 0;
+ }
+ break;
+ }
+ case SEQ_TYPE_MOVIECLIP:
+ if (seq->clip == NULL) {
+ return;
+ }
+
+ seq->len = BKE_movieclip_get_duration(seq->clip);
+
+ seq->len -= seq->anim_startofs;
+ seq->len -= seq->anim_endofs;
+ if (seq->len < 0) {
+ seq->len = 0;
+ }
+ break;
+ case SEQ_TYPE_MASK:
+ if (seq->mask == NULL) {
+ return;
+ }
+ seq->len = BKE_mask_get_duration(seq->mask);
+ seq->len -= seq->anim_startofs;
+ seq->len -= seq->anim_endofs;
+ if (seq->len < 0) {
+ seq->len = 0;
+ }
+ break;
+ case SEQ_TYPE_SOUND_RAM:
+#ifdef WITH_AUDASPACE
+ if (!seq->sound) {
+ return;
+ }
+ seq->len = ceil((double)BKE_sound_get_length(bmain, seq->sound) * FPS);
+ seq->len -= seq->anim_startofs;
+ seq->len -= seq->anim_endofs;
+ if (seq->len < 0) {
+ seq->len = 0;
+ }
+#else
+ UNUSED_VARS(bmain);
+ return;
+#endif
+ break;
+ case SEQ_TYPE_SCENE: {
+ seq->len = (seq->scene) ? seq->scene->r.efra - seq->scene->r.sfra + 1 : 0;
+ seq->len -= seq->anim_startofs;
+ seq->len -= seq->anim_endofs;
+ if (seq->len < 0) {
+ seq->len = 0;
+ }
+ break;
+ }
+ }
+
+ free_proxy_seq(seq);
+
+ if (lock_range) {
+ BKE_sequence_tx_set_final_left(seq, prev_startdisp);
+ BKE_sequence_tx_set_final_right(seq, prev_enddisp);
+ BKE_sequence_single_fix(seq);
+ }
+
+ BKE_sequence_calc(scene, seq);
+}
+
+void BKE_sequence_movie_reload_if_needed(struct Main *bmain,
+ struct Scene *scene,
+ struct Sequence *seq,
+ bool *r_was_reloaded,
+ bool *r_can_produce_frames)
+{
+ BLI_assert(seq->type == SEQ_TYPE_MOVIE ||
+ !"This function is only implemented for movie strips.");
+
+ bool must_reload = false;
+
+ /* The Sequence struct allows for multiple anim structs to be associated with one strip. This
+ * function will return true only if there is at least one 'anim' AND all anims can produce
+ * frames. */
+
+ if (BLI_listbase_is_empty(&seq->anims)) {
+ /* No anim present, so reloading is always necessary. */
+ must_reload = true;
+ }
+ else {
+ LISTBASE_FOREACH (StripAnim *, sanim, &seq->anims) {
+ if (!IMB_anim_can_produce_frames(sanim->anim)) {
+ /* Anim cannot produce frames, try reloading. */
+ must_reload = true;
+ break;
+ }
+ };
+ }
+
+ if (!must_reload) {
+ /* There are one or more anims, and all can produce frames. */
+ *r_was_reloaded = false;
+ *r_can_produce_frames = true;
+ return;
+ }
+
+ BKE_sequence_reload_new_file(bmain, scene, seq, true);
+ *r_was_reloaded = true;
+
+ if (BLI_listbase_is_empty(&seq->anims)) {
+ /* No anims present after reloading => no frames can be produced. */
+ *r_can_produce_frames = false;
+ return;
+ }
+
+ /* Check if there are still anims that cannot produce frames. */
+ LISTBASE_FOREACH (StripAnim *, sanim, &seq->anims) {
+ if (!IMB_anim_can_produce_frames(sanim->anim)) {
+ /* There still is an anim that cannot produce frames. */
+ *r_can_produce_frames = false;
+ return;
+ }
+ };
+
+ /* There are one or more anims, and all can produce frames. */
+ *r_can_produce_frames = true;
+}
diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c
new file mode 100644
index 00000000000..46a4ee0c03f
--- /dev/null
+++ b/source/blender/sequencer/intern/strip_edit.c
@@ -0,0 +1,196 @@
+/*
+ * 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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_string.h"
+
+#include "BLT_translation.h"
+
+#include "BKE_movieclip.h"
+#include "BKE_scene.h"
+#include "BKE_sound.h"
+
+#include "SEQ_sequencer.h"
+
+int BKE_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
+{
+ char name[sizeof(seq_a->name)];
+
+ if (seq_a->len != seq_b->len) {
+ *error_str = N_("Strips must be the same length");
+ return 0;
+ }
+
+ /* type checking, could be more advanced but disallow sound vs non-sound copy */
+ if (seq_a->type != seq_b->type) {
+ if (seq_a->type == SEQ_TYPE_SOUND_RAM || seq_b->type == SEQ_TYPE_SOUND_RAM) {
+ *error_str = N_("Strips were not compatible");
+ return 0;
+ }
+
+ /* disallow effects to swap with non-effects strips */
+ if ((seq_a->type & SEQ_TYPE_EFFECT) != (seq_b->type & SEQ_TYPE_EFFECT)) {
+ *error_str = N_("Strips were not compatible");
+ return 0;
+ }
+
+ if ((seq_a->type & SEQ_TYPE_EFFECT) && (seq_b->type & SEQ_TYPE_EFFECT)) {
+ if (BKE_sequence_effect_get_num_inputs(seq_a->type) !=
+ BKE_sequence_effect_get_num_inputs(seq_b->type)) {
+ *error_str = N_("Strips must have the same number of inputs");
+ return 0;
+ }
+ }
+ }
+
+ SWAP(Sequence, *seq_a, *seq_b);
+
+ /* swap back names so animation fcurves don't get swapped */
+ BLI_strncpy(name, seq_a->name + 2, sizeof(name));
+ BLI_strncpy(seq_a->name + 2, seq_b->name + 2, sizeof(seq_b->name) - 2);
+ BLI_strncpy(seq_b->name + 2, name, sizeof(seq_b->name) - 2);
+
+ /* swap back opacity, and overlay mode */
+ SWAP(int, seq_a->blend_mode, seq_b->blend_mode);
+ SWAP(float, seq_a->blend_opacity, seq_b->blend_opacity);
+
+ SWAP(Sequence *, seq_a->prev, seq_b->prev);
+ SWAP(Sequence *, seq_a->next, seq_b->next);
+ SWAP(int, seq_a->start, seq_b->start);
+ SWAP(int, seq_a->startofs, seq_b->startofs);
+ SWAP(int, seq_a->endofs, seq_b->endofs);
+ SWAP(int, seq_a->startstill, seq_b->startstill);
+ SWAP(int, seq_a->endstill, seq_b->endstill);
+ SWAP(int, seq_a->machine, seq_b->machine);
+ SWAP(int, seq_a->startdisp, seq_b->startdisp);
+ SWAP(int, seq_a->enddisp, seq_b->enddisp);
+
+ return 1;
+}
+
+static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, int mute)
+{
+ Sequence *seq;
+ int seqmute;
+
+ /* for sound we go over full meta tree to update muted state,
+ * since sound is played outside of evaluating the imbufs, */
+ for (seq = seqbasep->first; seq; seq = seq->next) {
+ seqmute = (mute || (seq->flag & SEQ_MUTE));
+
+ if (seq->type == SEQ_TYPE_META) {
+ /* if this is the current meta sequence, unmute because
+ * all sequences above this were set to mute */
+ if (seq == metaseq) {
+ seqmute = 0;
+ }
+
+ seq_update_muting_recursive(&seq->seqbase, metaseq, seqmute);
+ }
+ else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
+ if (seq->scene_sound) {
+ BKE_sound_mute_scene_sound(seq->scene_sound, seqmute);
+ }
+ }
+ }
+}
+
+void BKE_sequencer_update_muting(Editing *ed)
+{
+ if (ed) {
+ /* mute all sounds up to current metastack list */
+ MetaStack *ms = ed->metastack.last;
+
+ if (ms) {
+ seq_update_muting_recursive(&ed->seqbase, ms->parseq, 1);
+ }
+ else {
+ seq_update_muting_recursive(&ed->seqbase, NULL, 0);
+ }
+ }
+}
+
+static void sequencer_flag_users_for_removal(Scene *scene, ListBase *seqbase, Sequence *seq)
+{
+ LISTBASE_FOREACH (Sequence *, user_seq, seqbase) {
+ /* Look in metas for usage of seq. */
+ if (user_seq->type == SEQ_TYPE_META) {
+ sequencer_flag_users_for_removal(scene, &user_seq->seqbase, seq);
+ }
+
+ /* Clear seq from modifiers. */
+ SequenceModifierData *smd;
+ for (smd = user_seq->modifiers.first; smd; smd = smd->next) {
+ if (smd->mask_sequence == seq) {
+ smd->mask_sequence = NULL;
+ }
+ }
+
+ /* Remove effects, that use seq. */
+ if ((user_seq->seq1 && user_seq->seq1 == seq) || (user_seq->seq2 && user_seq->seq2 == seq) ||
+ (user_seq->seq3 && user_seq->seq3 == seq)) {
+ user_seq->flag |= SEQ_FLAG_DELETE;
+ /* Strips can be used as mask even if not in same seqbase. */
+ sequencer_flag_users_for_removal(scene, &scene->ed->seqbase, user_seq);
+ }
+ }
+}
+
+/* Flag seq and its users (effects) for removal. */
+void BKE_sequencer_flag_for_removal(Scene *scene, ListBase *seqbase, Sequence *seq)
+{
+ if (seq == NULL || (seq->flag & SEQ_FLAG_DELETE) != 0) {
+ return;
+ }
+
+ /* Flag and remove meta children. */
+ if (seq->type == SEQ_TYPE_META) {
+ LISTBASE_FOREACH (Sequence *, meta_child, &seq->seqbase) {
+ BKE_sequencer_flag_for_removal(scene, &seq->seqbase, meta_child);
+ }
+ }
+
+ seq->flag |= SEQ_FLAG_DELETE;
+ sequencer_flag_users_for_removal(scene, seqbase, seq);
+}
+
+/* Remove all flagged sequences, return true if sequence is removed. */
+void BKE_sequencer_remove_flagged_sequences(Scene *scene, ListBase *seqbase)
+{
+ LISTBASE_FOREACH_MUTABLE (Sequence *, seq, seqbase) {
+ if (seq->flag & SEQ_FLAG_DELETE) {
+ if (seq->type == SEQ_TYPE_META) {
+ BKE_sequencer_remove_flagged_sequences(scene, &seq->seqbase);
+ }
+ BLI_remlink(seqbase, seq);
+ BKE_sequence_free(scene, seq, true);
+ }
+ }
+}
diff --git a/source/blender/sequencer/intern/strip_relations.c b/source/blender/sequencer/intern/strip_relations.c
new file mode 100644
index 00000000000..d802ce22f21
--- /dev/null
+++ b/source/blender/sequencer/intern/strip_relations.c
@@ -0,0 +1,468 @@
+/*
+ * 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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+
+#include "BLI_ghash.h"
+#include "BLI_listbase.h"
+#include "BLI_session_uuid.h"
+
+#include "BKE_main.h"
+#include "BKE_report.h"
+#include "BKE_scene.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
+
+#include "IMB_imbuf.h"
+
+#include "SEQ_sequencer.h"
+
+#include "effects.h"
+#include "image_cache.h"
+#include "utils.h"
+
+/* check whether sequence cur depends on seq */
+static bool BKE_sequence_check_depend(Sequence *seq, Sequence *cur)
+{
+ if (cur->seq1 == seq || cur->seq2 == seq || cur->seq3 == seq) {
+ return true;
+ }
+
+ /* sequences are not intersecting in time, assume no dependency exists between them */
+ if (cur->enddisp < seq->startdisp || cur->startdisp > seq->enddisp) {
+ return false;
+ }
+
+ /* checking sequence is below reference one, not dependent on it */
+ if (cur->machine < seq->machine) {
+ return false;
+ }
+
+ /* sequence is not blending with lower machines, no dependency here occurs
+ * check for non-effects only since effect could use lower machines as input
+ */
+ if ((cur->type & SEQ_TYPE_EFFECT) == 0 &&
+ ((cur->blend_mode == SEQ_BLEND_REPLACE) ||
+ (cur->blend_mode == SEQ_TYPE_CROSS && cur->blend_opacity == 100.0f))) {
+ return false;
+ }
+
+ return true;
+}
+
+static void sequence_do_invalidate_dependent(Scene *scene, Sequence *seq, ListBase *seqbase)
+{
+ Sequence *cur;
+
+ for (cur = seqbase->first; cur; cur = cur->next) {
+ if (cur == seq) {
+ continue;
+ }
+
+ if (BKE_sequence_check_depend(seq, cur)) {
+ /* Effect must be invalidated completely if they depend on invalidated seq. */
+ if ((cur->type & SEQ_TYPE_EFFECT) != 0) {
+ BKE_sequencer_cache_cleanup_sequence(scene, cur, seq, SEQ_CACHE_ALL_TYPES, false);
+ }
+ else {
+ /* In case of alpha over for example only invalidate composite image */
+ BKE_sequencer_cache_cleanup_sequence(
+ scene, cur, seq, SEQ_CACHE_STORE_COMPOSITE | SEQ_CACHE_STORE_FINAL_OUT, false);
+ }
+ }
+
+ if (cur->seqbase.first) {
+ sequence_do_invalidate_dependent(scene, seq, &cur->seqbase);
+ }
+ }
+}
+
+static void sequence_invalidate_cache(Scene *scene,
+ Sequence *seq,
+ bool invalidate_self,
+ int invalidate_types)
+{
+ Editing *ed = scene->ed;
+
+ if (invalidate_self) {
+ BKE_sequence_free_anim(seq);
+ BKE_sequencer_cache_cleanup_sequence(scene, seq, seq, invalidate_types, false);
+ }
+
+ if (seq->effectdata && seq->type == SEQ_TYPE_SPEED) {
+ BKE_sequence_effect_speed_rebuild_map(scene, seq, true);
+ }
+
+ sequence_do_invalidate_dependent(scene, seq, &ed->seqbase);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
+ BKE_sequencer_prefetch_stop(scene);
+}
+
+void BKE_sequence_invalidate_cache_in_range(Scene *scene,
+ Sequence *seq,
+ Sequence *range_mask,
+ int invalidate_types)
+{
+ BKE_sequencer_cache_cleanup_sequence(scene, seq, range_mask, invalidate_types, true);
+}
+
+void BKE_sequence_invalidate_cache_raw(Scene *scene, Sequence *seq)
+{
+ sequence_invalidate_cache(scene, seq, true, SEQ_CACHE_ALL_TYPES);
+}
+
+void BKE_sequence_invalidate_cache_preprocessed(Scene *scene, Sequence *seq)
+{
+ sequence_invalidate_cache(scene,
+ seq,
+ true,
+ SEQ_CACHE_STORE_PREPROCESSED | SEQ_CACHE_STORE_COMPOSITE |
+ SEQ_CACHE_STORE_FINAL_OUT);
+}
+
+void BKE_sequence_invalidate_cache_composite(Scene *scene, Sequence *seq)
+{
+ if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
+ return;
+ }
+
+ sequence_invalidate_cache(
+ scene, seq, true, SEQ_CACHE_STORE_COMPOSITE | SEQ_CACHE_STORE_FINAL_OUT);
+}
+
+void BKE_sequence_invalidate_dependent(Scene *scene, Sequence *seq)
+{
+ if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
+ return;
+ }
+
+ sequence_invalidate_cache(
+ scene, seq, false, SEQ_CACHE_STORE_COMPOSITE | SEQ_CACHE_STORE_FINAL_OUT);
+}
+
+static void invalidate_scene_strips(Scene *scene, Scene *scene_target, ListBase *seqbase)
+{
+ for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
+ if (seq->scene == scene_target) {
+ BKE_sequence_invalidate_cache_raw(scene, seq);
+ }
+
+ if (seq->seqbase.first != NULL) {
+ invalidate_scene_strips(scene, scene_target, &seq->seqbase);
+ }
+ }
+}
+
+void BKE_sequence_invalidate_scene_strips(Main *bmain, Scene *scene_target)
+{
+ for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
+ if (scene->ed != NULL) {
+ invalidate_scene_strips(scene, scene_target, &scene->ed->seqbase);
+ }
+ }
+}
+
+static void invalidate_movieclip_strips(Scene *scene, MovieClip *clip_target, ListBase *seqbase)
+{
+ for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
+ if (seq->clip == clip_target) {
+ BKE_sequence_invalidate_cache_raw(scene, seq);
+ }
+
+ if (seq->seqbase.first != NULL) {
+ invalidate_movieclip_strips(scene, clip_target, &seq->seqbase);
+ }
+ }
+}
+
+void BKE_sequence_invalidate_movieclip_strips(Main *bmain, MovieClip *clip_target)
+{
+ for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
+ if (scene->ed != NULL) {
+ invalidate_movieclip_strips(scene, clip_target, &scene->ed->seqbase);
+ }
+ }
+}
+
+void BKE_sequencer_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render)
+{
+ if (scene->ed == NULL) {
+ return;
+ }
+
+ Sequence *seq;
+
+ BKE_sequencer_cache_cleanup(scene);
+ BKE_sequencer_prefetch_stop(scene);
+
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ if (for_render && CFRA >= seq->startdisp && CFRA <= seq->enddisp) {
+ continue;
+ }
+
+ if (seq->strip) {
+ if (seq->type == SEQ_TYPE_MOVIE) {
+ BKE_sequence_free_anim(seq);
+ }
+ if (seq->type == SEQ_TYPE_SPEED) {
+ BKE_sequence_effect_speed_rebuild_map(scene, seq, true);
+ }
+ }
+ if (seq->type == SEQ_TYPE_META) {
+ BKE_sequencer_free_imbuf(scene, &seq->seqbase, for_render);
+ }
+ if (seq->type == SEQ_TYPE_SCENE) {
+ /* FIXME: recurse downwards,
+ * but do recurse protection somehow! */
+ }
+ }
+}
+
+static bool update_changed_seq_recurs(
+ Scene *scene, Sequence *seq, Sequence *changed_seq, int len_change, int ibuf_change)
+{
+ Sequence *subseq;
+ bool free_imbuf = false;
+
+ /* recurse downwards to see if this seq depends on the changed seq */
+
+ if (seq == NULL) {
+ return false;
+ }
+
+ if (seq == changed_seq) {
+ free_imbuf = true;
+ }
+
+ for (subseq = seq->seqbase.first; subseq; subseq = subseq->next) {
+ if (update_changed_seq_recurs(scene, subseq, changed_seq, len_change, ibuf_change)) {
+ free_imbuf = true;
+ }
+ }
+
+ if (seq->seq1) {
+ if (update_changed_seq_recurs(scene, seq->seq1, changed_seq, len_change, ibuf_change)) {
+ free_imbuf = true;
+ }
+ }
+ if (seq->seq2 && (seq->seq2 != seq->seq1)) {
+ if (update_changed_seq_recurs(scene, seq->seq2, changed_seq, len_change, ibuf_change)) {
+ free_imbuf = true;
+ }
+ }
+ if (seq->seq3 && (seq->seq3 != seq->seq1) && (seq->seq3 != seq->seq2)) {
+ if (update_changed_seq_recurs(scene, seq->seq3, changed_seq, len_change, ibuf_change)) {
+ free_imbuf = true;
+ }
+ }
+
+ if (free_imbuf) {
+ if (ibuf_change) {
+ if (seq->type == SEQ_TYPE_MOVIE) {
+ BKE_sequence_free_anim(seq);
+ }
+ else if (seq->type == SEQ_TYPE_SPEED) {
+ BKE_sequence_effect_speed_rebuild_map(scene, seq, true);
+ }
+ }
+
+ if (len_change) {
+ BKE_sequence_calc(scene, seq);
+ }
+ }
+
+ return free_imbuf;
+}
+
+void BKE_sequencer_update_changed_seq_and_deps(Scene *scene,
+ Sequence *changed_seq,
+ int len_change,
+ int ibuf_change)
+{
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+
+ if (ed == NULL) {
+ return;
+ }
+
+ for (seq = ed->seqbase.first; seq; seq = seq->next) {
+ update_changed_seq_recurs(scene, seq, changed_seq, len_change, ibuf_change);
+ }
+}
+
+/* Unused */
+static void sequencer_all_free_anim_ibufs(ListBase *seqbase, int timeline_frame)
+{
+ for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
+ if (seq->enddisp < timeline_frame || seq->startdisp > timeline_frame) {
+ BKE_sequence_free_anim(seq);
+ }
+ if (seq->type == SEQ_TYPE_META) {
+ sequencer_all_free_anim_ibufs(&seq->seqbase, timeline_frame);
+ }
+ }
+}
+
+/* Unused */
+void BKE_sequencer_all_free_anim_ibufs(Scene *scene, int timeline_frame)
+{
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ if (ed == NULL) {
+ return;
+ }
+ sequencer_all_free_anim_ibufs(&ed->seqbase, timeline_frame);
+ BKE_sequencer_cache_cleanup(scene);
+}
+
+static Sequence *sequencer_check_scene_recursion(Scene *scene, ListBase *seqbase)
+{
+ LISTBASE_FOREACH (Sequence *, seq, seqbase) {
+ if (seq->type == SEQ_TYPE_SCENE && seq->scene == scene) {
+ return seq;
+ }
+
+ if (seq->type == SEQ_TYPE_SCENE && (seq->flag & SEQ_SCENE_STRIPS)) {
+ if (sequencer_check_scene_recursion(scene, &seq->scene->ed->seqbase)) {
+ return seq;
+ }
+ }
+
+ if (seq->type == SEQ_TYPE_META && sequencer_check_scene_recursion(scene, &seq->seqbase)) {
+ return seq;
+ }
+ }
+
+ return NULL;
+}
+
+bool BKE_sequencer_check_scene_recursion(Scene *scene, ReportList *reports)
+{
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ if (ed == NULL) {
+ return false;
+ }
+
+ Sequence *recursive_seq = sequencer_check_scene_recursion(scene, &ed->seqbase);
+
+ if (recursive_seq != NULL) {
+ BKE_reportf(reports,
+ RPT_WARNING,
+ "Recursion detected in video sequencer. Strip %s at frame %d will not be rendered",
+ recursive_seq->name + 2,
+ recursive_seq->startdisp);
+
+ LISTBASE_FOREACH (Sequence *, seq, &ed->seqbase) {
+ if (seq->type != SEQ_TYPE_SCENE && sequencer_seq_generates_image(seq)) {
+ /* There are other strips to render, so render them. */
+ return false;
+ }
+ }
+ /* No other strips to render - cancel operator. */
+ return true;
+ }
+
+ return false;
+}
+
+/* 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;
+ }
+
+ if ((seq_main->seq1 && BKE_sequencer_render_loop_check(seq_main->seq1, seq)) ||
+ (seq_main->seq2 && BKE_sequencer_render_loop_check(seq_main->seq2, seq)) ||
+ (seq_main->seq3 && BKE_sequencer_render_loop_check(seq_main->seq3, seq))) {
+ return true;
+ }
+
+ SequenceModifierData *smd;
+ for (smd = seq_main->modifiers.first; smd; smd = smd->next) {
+ if (smd->mask_sequence && BKE_sequencer_render_loop_check(smd->mask_sequence, seq)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/* Function to free imbuf and anim data on changes */
+void BKE_sequence_free_anim(Sequence *seq)
+{
+ while (seq->anims.last) {
+ StripAnim *sanim = seq->anims.last;
+
+ if (sanim->anim) {
+ IMB_free_anim(sanim->anim);
+ sanim->anim = NULL;
+ }
+
+ BLI_freelinkN(&seq->anims, sanim);
+ }
+ BLI_listbase_clear(&seq->anims);
+}
+
+void BKE_sequence_session_uuid_generate(struct Sequence *sequence)
+{
+ sequence->runtime.session_uuid = BLI_session_uuid_generate();
+}
+
+void BKE_sequencer_check_uuids_unique_and_report(const Scene *scene)
+{
+ if (scene->ed == NULL) {
+ return;
+ }
+
+ struct GSet *used_uuids = BLI_gset_new(
+ BLI_session_uuid_ghash_hash, BLI_session_uuid_ghash_compare, "sequencer used uuids");
+
+ const Sequence *sequence;
+ SEQ_ALL_BEGIN (scene->ed, sequence) {
+ const SessionUUID *session_uuid = &sequence->runtime.session_uuid;
+ if (!BLI_session_uuid_is_generated(session_uuid)) {
+ printf("Sequence %s does not have UUID generated.\n", sequence->name);
+ continue;
+ }
+
+ if (BLI_gset_lookup(used_uuids, session_uuid) != NULL) {
+ printf("Sequence %s has duplicate UUID generated.\n", sequence->name);
+ continue;
+ }
+
+ BLI_gset_insert(used_uuids, (void *)session_uuid);
+ }
+ SEQ_ALL_END;
+
+ BLI_gset_free(used_uuids, NULL);
+}
diff --git a/source/blender/sequencer/intern/strip_select.c b/source/blender/sequencer/intern/strip_select.c
new file mode 100644
index 00000000000..478ae9be337
--- /dev/null
+++ b/source/blender/sequencer/intern/strip_select.c
@@ -0,0 +1,81 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+
+#include "BKE_scene.h"
+
+#include "SEQ_sequencer.h"
+
+Sequence *BKE_sequencer_active_get(Scene *scene)
+{
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+
+ if (ed == NULL) {
+ return NULL;
+ }
+
+ return ed->act_seq;
+}
+
+void BKE_sequencer_active_set(Scene *scene, Sequence *seq)
+{
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+
+ if (ed == NULL) {
+ return;
+ }
+
+ ed->act_seq = seq;
+}
+
+int BKE_sequencer_active_get_pair(Scene *scene, Sequence **seq_act, Sequence **seq_other)
+{
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+
+ *seq_act = BKE_sequencer_active_get(scene);
+
+ if (*seq_act == NULL) {
+ return 0;
+ }
+
+ Sequence *seq;
+
+ *seq_other = NULL;
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT && (seq != (*seq_act))) {
+ if (*seq_other) {
+ return 0;
+ }
+
+ *seq_other = seq;
+ }
+ }
+
+ return (*seq_other != NULL);
+}
diff --git a/source/blender/sequencer/intern/strip_time.c b/source/blender/sequencer/intern/strip_time.c
new file mode 100644
index 00000000000..a0ae6d6f16d
--- /dev/null
+++ b/source/blender/sequencer/intern/strip_time.c
@@ -0,0 +1,353 @@
+/*
+ * 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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+
+#include "BKE_movieclip.h"
+#include "BKE_scene.h"
+#include "BKE_sound.h"
+
+#include "IMB_imbuf.h"
+
+#include "SEQ_sequencer.h"
+
+#include "strip_time.h"
+#include "utils.h"
+
+float seq_give_frame_index(Sequence *seq, float timeline_frame)
+{
+ float frame_index;
+ int sta = seq->start;
+ int end = seq->start + seq->len - 1;
+
+ if (seq->type & SEQ_TYPE_EFFECT) {
+ end = seq->enddisp;
+ }
+
+ if (end < sta) {
+ return -1;
+ }
+
+ if (seq->flag & SEQ_REVERSE_FRAMES) {
+ /*reverse frame in this sequence */
+ if (timeline_frame <= sta) {
+ frame_index = end - sta;
+ }
+ else if (timeline_frame >= end) {
+ frame_index = 0;
+ }
+ else {
+ frame_index = end - timeline_frame;
+ }
+ }
+ else {
+ if (timeline_frame <= sta) {
+ frame_index = 0;
+ }
+ else if (timeline_frame >= end) {
+ frame_index = end - sta;
+ }
+ else {
+ frame_index = timeline_frame - sta;
+ }
+ }
+
+ if (seq->strobe < 1.0f) {
+ seq->strobe = 1.0f;
+ }
+
+ if (seq->strobe > 1.0f) {
+ frame_index -= fmodf((double)frame_index, (double)seq->strobe);
+ }
+
+ return frame_index;
+}
+
+static int metaseq_start(Sequence *metaseq)
+{
+ return metaseq->start + metaseq->startofs;
+}
+
+static int metaseq_end(Sequence *metaseq)
+{
+ return metaseq->start + metaseq->len - metaseq->endofs;
+}
+
+static void seq_update_sound_bounds_recursive_impl(Scene *scene,
+ Sequence *metaseq,
+ int start,
+ int end)
+{
+ Sequence *seq;
+
+ /* for sound we go over full meta tree to update bounds of the sound strips,
+ * since sound is played outside of evaluating the imbufs, */
+ for (seq = metaseq->seqbase.first; seq; seq = seq->next) {
+ if (seq->type == SEQ_TYPE_META) {
+ seq_update_sound_bounds_recursive_impl(
+ scene, seq, max_ii(start, metaseq_start(seq)), min_ii(end, metaseq_end(seq)));
+ }
+ else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
+ if (seq->scene_sound) {
+ int startofs = seq->startofs;
+ int endofs = seq->endofs;
+ if (seq->startofs + seq->start < start) {
+ startofs = start - seq->start;
+ }
+
+ if (seq->start + seq->len - seq->endofs > end) {
+ endofs = seq->start + seq->len - end;
+ }
+
+ BKE_sound_move_scene_sound(scene,
+ seq->scene_sound,
+ seq->start + startofs,
+ seq->start + seq->len - endofs,
+ startofs + seq->anim_startofs);
+ }
+ }
+ }
+}
+
+void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq)
+{
+ seq_update_sound_bounds_recursive_impl(
+ scene, metaseq, metaseq_start(metaseq), metaseq_end(metaseq));
+}
+
+void BKE_sequence_calc_disp(Scene *scene, Sequence *seq)
+{
+ if (seq->startofs && seq->startstill) {
+ seq->startstill = 0;
+ }
+ if (seq->endofs && seq->endstill) {
+ seq->endstill = 0;
+ }
+
+ seq->startdisp = seq->start + seq->startofs - seq->startstill;
+ seq->enddisp = seq->start + seq->len - seq->endofs + seq->endstill;
+
+ if (seq->type == SEQ_TYPE_META) {
+ seq_update_sound_bounds_recursive(scene, seq);
+ }
+}
+
+void BKE_sequence_calc(Scene *scene, Sequence *seq)
+{
+ Sequence *seqm;
+ int min, max;
+
+ /* check all metas recursively */
+ seqm = seq->seqbase.first;
+ while (seqm) {
+ if (seqm->seqbase.first) {
+ BKE_sequence_calc(scene, seqm);
+ }
+ seqm = seqm->next;
+ }
+
+ /* effects and meta: automatic start and end */
+ if (seq->type & SEQ_TYPE_EFFECT) {
+ if (seq->seq1) {
+ seq->startofs = seq->endofs = seq->startstill = seq->endstill = 0;
+ if (seq->seq3) {
+ seq->start = seq->startdisp = max_iii(
+ seq->seq1->startdisp, seq->seq2->startdisp, seq->seq3->startdisp);
+ seq->enddisp = min_iii(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp);
+ }
+ else if (seq->seq2) {
+ seq->start = seq->startdisp = max_ii(seq->seq1->startdisp, seq->seq2->startdisp);
+ seq->enddisp = min_ii(seq->seq1->enddisp, seq->seq2->enddisp);
+ }
+ else {
+ seq->start = seq->startdisp = seq->seq1->startdisp;
+ seq->enddisp = seq->seq1->enddisp;
+ }
+ /* we cant help if strips don't overlap, it wont give useful results.
+ * but at least ensure 'len' is never negative which causes bad bugs elsewhere. */
+ if (seq->enddisp < seq->startdisp) {
+ /* simple start/end swap */
+ seq->start = seq->enddisp;
+ seq->enddisp = seq->startdisp;
+ seq->startdisp = seq->start;
+ seq->flag |= SEQ_INVALID_EFFECT;
+ }
+ else {
+ seq->flag &= ~SEQ_INVALID_EFFECT;
+ }
+
+ seq->len = seq->enddisp - seq->startdisp;
+ }
+ else {
+ BKE_sequence_calc_disp(scene, seq);
+ }
+ }
+ else {
+ if (seq->type == SEQ_TYPE_META) {
+ seqm = seq->seqbase.first;
+ if (seqm) {
+ min = MAXFRAME * 2;
+ max = -MAXFRAME * 2;
+ while (seqm) {
+ if (seqm->startdisp < min) {
+ min = seqm->startdisp;
+ }
+ if (seqm->enddisp > max) {
+ max = seqm->enddisp;
+ }
+ seqm = seqm->next;
+ }
+ seq->start = min + seq->anim_startofs;
+ seq->len = max - min;
+ seq->len -= seq->anim_startofs;
+ seq->len -= seq->anim_endofs;
+ }
+ seq_update_sound_bounds_recursive(scene, seq);
+ }
+ BKE_sequence_calc_disp(scene, seq);
+ }
+}
+
+/** Comparison function suitable to be used with BLI_listbase_sort()... */
+int BKE_sequencer_cmp_time_startdisp(const void *a, const void *b)
+{
+ const Sequence *seq_a = a;
+ const Sequence *seq_b = b;
+
+ return (seq_a->startdisp > seq_b->startdisp);
+}
+
+int BKE_sequencer_find_next_prev_edit(Scene *scene,
+ int timeline_frame,
+ const short side,
+ const bool do_skip_mute,
+ const bool do_center,
+ const bool do_unselected)
+{
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+
+ int dist, best_dist, best_frame = timeline_frame;
+ int seq_frames[2], seq_frames_tot;
+
+ /* In case where both is passed,
+ * frame just finds the nearest end while frame_left the nearest start. */
+
+ best_dist = MAXFRAME * 2;
+
+ if (ed == NULL) {
+ return timeline_frame;
+ }
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ int i;
+
+ if (do_skip_mute && (seq->flag & SEQ_MUTE)) {
+ continue;
+ }
+
+ if (do_unselected && (seq->flag & SELECT)) {
+ continue;
+ }
+
+ if (do_center) {
+ seq_frames[0] = (seq->startdisp + seq->enddisp) / 2;
+ seq_frames_tot = 1;
+ }
+ else {
+ seq_frames[0] = seq->startdisp;
+ seq_frames[1] = seq->enddisp;
+
+ seq_frames_tot = 2;
+ }
+
+ for (i = 0; i < seq_frames_tot; i++) {
+ const int seq_frame = seq_frames[i];
+
+ dist = MAXFRAME * 2;
+
+ switch (side) {
+ case SEQ_SIDE_LEFT:
+ if (seq_frame < timeline_frame) {
+ dist = timeline_frame - seq_frame;
+ }
+ break;
+ case SEQ_SIDE_RIGHT:
+ if (seq_frame > timeline_frame) {
+ dist = seq_frame - timeline_frame;
+ }
+ break;
+ case SEQ_SIDE_BOTH:
+ dist = abs(seq_frame - timeline_frame);
+ break;
+ }
+
+ if (dist < best_dist) {
+ best_frame = seq_frame;
+ best_dist = dist;
+ }
+ }
+ }
+
+ return best_frame;
+}
+
+float BKE_sequence_get_fps(Scene *scene, Sequence *seq)
+{
+ switch (seq->type) {
+ case SEQ_TYPE_MOVIE: {
+ seq_open_anim_file(scene, seq, true);
+ if (BLI_listbase_is_empty(&seq->anims)) {
+ return 0.0f;
+ }
+ StripAnim *strip_anim = seq->anims.first;
+ if (strip_anim->anim == NULL) {
+ return 0.0f;
+ }
+ short frs_sec;
+ float frs_sec_base;
+ if (IMB_anim_get_fps(strip_anim->anim, &frs_sec, &frs_sec_base, true)) {
+ return (float)frs_sec / frs_sec_base;
+ }
+ break;
+ }
+ case SEQ_TYPE_MOVIECLIP:
+ if (seq->clip != NULL) {
+ return BKE_movieclip_get_fps(seq->clip);
+ }
+ break;
+ case SEQ_TYPE_SCENE:
+ if (seq->scene != NULL) {
+ return (float)seq->scene->r.frs_sec / seq->scene->r.frs_sec_base;
+ }
+ break;
+ }
+ return 0.0f;
+}
diff --git a/source/blender/sequencer/intern/strip_time.h b/source/blender/sequencer/intern/strip_time.h
new file mode 100644
index 00000000000..e4fb7f1d2ec
--- /dev/null
+++ b/source/blender/sequencer/intern/strip_time.h
@@ -0,0 +1,38 @@
+/*
+ * 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) 2004 Blender Foundation.
+ * All rights reserved.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup sequencer
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct Scene;
+struct Sequence;
+
+float seq_give_frame_index(struct Sequence *seq, float timeline_frame);
+void seq_update_sound_bounds_recursive(struct Scene *scene, struct Sequence *metaseq);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/sequencer/intern/strip_transform.c b/source/blender/sequencer/intern/strip_transform.c
new file mode 100644
index 00000000000..dd6b7e6dba5
--- /dev/null
+++ b/source/blender/sequencer/intern/strip_transform.c
@@ -0,0 +1,397 @@
+/*
+ * 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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+
+#include "BKE_scene.h"
+#include "BKE_sound.h"
+
+#include "SEQ_sequencer.h"
+
+static int seq_tx_get_start(Sequence *seq)
+{
+ return seq->start;
+}
+static int seq_tx_get_end(Sequence *seq)
+{
+ return seq->start + seq->len;
+}
+
+int BKE_sequence_tx_get_final_left(Sequence *seq, bool metaclip)
+{
+ if (metaclip && seq->tmp) {
+ /* return the range clipped by the parents range */
+ return max_ii(BKE_sequence_tx_get_final_left(seq, false),
+ BKE_sequence_tx_get_final_left((Sequence *)seq->tmp, true));
+ }
+
+ return (seq->start - seq->startstill) + seq->startofs;
+}
+int BKE_sequence_tx_get_final_right(Sequence *seq, bool metaclip)
+{
+ if (metaclip && seq->tmp) {
+ /* return the range clipped by the parents range */
+ return min_ii(BKE_sequence_tx_get_final_right(seq, false),
+ BKE_sequence_tx_get_final_right((Sequence *)seq->tmp, true));
+ }
+
+ return ((seq->start + seq->len) + seq->endstill) - seq->endofs;
+}
+
+void BKE_sequence_tx_set_final_left(Sequence *seq, int val)
+{
+ if (val < (seq)->start) {
+ seq->startstill = abs(val - (seq)->start);
+ seq->startofs = 0;
+ }
+ else {
+ seq->startofs = abs(val - (seq)->start);
+ seq->startstill = 0;
+ }
+}
+
+void BKE_sequence_tx_set_final_right(Sequence *seq, int val)
+{
+ if (val > (seq)->start + (seq)->len) {
+ seq->endstill = abs(val - (seq->start + (seq)->len));
+ seq->endofs = 0;
+ }
+ else {
+ seq->endofs = abs(val - ((seq)->start + (seq)->len));
+ seq->endstill = 0;
+ }
+}
+
+/* used so we can do a quick check for single image seq
+ * since they work a bit differently to normal image seq's (during transform) */
+bool BKE_sequence_single_check(Sequence *seq)
+{
+ return ((seq->len == 1) &&
+ (seq->type == SEQ_TYPE_IMAGE ||
+ ((seq->type & SEQ_TYPE_EFFECT) && BKE_sequence_effect_get_num_inputs(seq->type) == 0)));
+}
+
+/* check if the selected seq's reference unselected seq's */
+bool BKE_sequence_base_isolated_sel_check(ListBase *seqbase)
+{
+ Sequence *seq;
+ /* is there more than 1 select */
+ bool ok = false;
+
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT) {
+ ok = true;
+ break;
+ }
+ }
+
+ if (ok == false) {
+ return false;
+ }
+
+ /* test relationships */
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ if ((seq->type & SEQ_TYPE_EFFECT) == 0) {
+ continue;
+ }
+
+ if (seq->flag & SELECT) {
+ if ((seq->seq1 && (seq->seq1->flag & SELECT) == 0) ||
+ (seq->seq2 && (seq->seq2->flag & SELECT) == 0) ||
+ (seq->seq3 && (seq->seq3->flag & SELECT) == 0)) {
+ return false;
+ }
+ }
+ else {
+ if ((seq->seq1 && (seq->seq1->flag & SELECT)) || (seq->seq2 && (seq->seq2->flag & SELECT)) ||
+ (seq->seq3 && (seq->seq3->flag & SELECT))) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+/* use to impose limits when dragging/extending - so impossible situations don't happen
+ * Cant use the SEQ_LEFTSEL and SEQ_LEFTSEL directly because the strip may be in a metastrip */
+void BKE_sequence_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag)
+{
+ if (leftflag) {
+ if (BKE_sequence_tx_get_final_left(seq, false) >=
+ BKE_sequence_tx_get_final_right(seq, false)) {
+ BKE_sequence_tx_set_final_left(seq, BKE_sequence_tx_get_final_right(seq, false) - 1);
+ }
+
+ if (BKE_sequence_single_check(seq) == 0) {
+ if (BKE_sequence_tx_get_final_left(seq, false) >= seq_tx_get_end(seq)) {
+ BKE_sequence_tx_set_final_left(seq, seq_tx_get_end(seq) - 1);
+ }
+
+ /* doesn't work now - TODO */
+#if 0
+ if (seq_tx_get_start(seq) >= seq_tx_get_final_right(seq, 0)) {
+ int ofs;
+ ofs = seq_tx_get_start(seq) - seq_tx_get_final_right(seq, 0);
+ seq->start -= ofs;
+ seq_tx_set_final_left(seq, seq_tx_get_final_left(seq, 0) + ofs);
+ }
+#endif
+ }
+ }
+
+ if (rightflag) {
+ if (BKE_sequence_tx_get_final_right(seq, false) <=
+ BKE_sequence_tx_get_final_left(seq, false)) {
+ BKE_sequence_tx_set_final_right(seq, BKE_sequence_tx_get_final_left(seq, false) + 1);
+ }
+
+ if (BKE_sequence_single_check(seq) == 0) {
+ if (BKE_sequence_tx_get_final_right(seq, false) <= seq_tx_get_start(seq)) {
+ BKE_sequence_tx_set_final_right(seq, seq_tx_get_start(seq) + 1);
+ }
+ }
+ }
+
+ /* sounds cannot be extended past their endpoints */
+ if (seq->type == SEQ_TYPE_SOUND_RAM) {
+ seq->startstill = 0;
+ seq->endstill = 0;
+ }
+}
+
+void BKE_sequence_single_fix(Sequence *seq)
+{
+ int left, start, offset;
+ if (!BKE_sequence_single_check(seq)) {
+ return;
+ }
+
+ /* make sure the image is always at the start since there is only one,
+ * adjusting its start should be ok */
+ left = BKE_sequence_tx_get_final_left(seq, false);
+ start = seq->start;
+ if (start != left) {
+ offset = left - start;
+ BKE_sequence_tx_set_final_left(seq, BKE_sequence_tx_get_final_left(seq, false) - offset);
+ BKE_sequence_tx_set_final_right(seq, BKE_sequence_tx_get_final_right(seq, false) - offset);
+ seq->start += offset;
+ }
+}
+
+bool BKE_sequence_tx_test(Sequence *seq)
+{
+ return !(seq->type & SEQ_TYPE_EFFECT) || (BKE_sequence_effect_get_num_inputs(seq->type) == 0);
+}
+
+/**
+ * Return \a true if given \a seq needs a complete cleanup of its cache when it is transformed.
+ *
+ * Some (effect) strip types need a complete recache of themselves when they are transformed,
+ * because they do not 'contain' anything and do not have any explicit relations to other strips.
+ */
+bool BKE_sequence_tx_fullupdate_test(Sequence *seq)
+{
+ return BKE_sequence_tx_test(seq) && ELEM(seq->type, SEQ_TYPE_ADJUSTMENT, SEQ_TYPE_MULTICAM);
+}
+
+static bool seq_overlap(Sequence *seq1, Sequence *seq2)
+{
+ return (seq1 != seq2 && seq1->machine == seq2->machine &&
+ ((seq1->enddisp <= seq2->startdisp) || (seq1->startdisp >= seq2->enddisp)) == 0);
+}
+
+bool BKE_sequence_test_overlap(ListBase *seqbasep, Sequence *test)
+{
+ Sequence *seq;
+
+ seq = seqbasep->first;
+ while (seq) {
+ if (seq_overlap(test, seq)) {
+ return true;
+ }
+
+ seq = seq->next;
+ }
+ return false;
+}
+
+void BKE_sequence_translate(Scene *evil_scene, Sequence *seq, int delta)
+{
+ if (delta == 0) {
+ return;
+ }
+
+ BKE_sequencer_offset_animdata(evil_scene, seq, delta);
+ seq->start += delta;
+
+ if (seq->type == SEQ_TYPE_META) {
+ Sequence *seq_child;
+ for (seq_child = seq->seqbase.first; seq_child; seq_child = seq_child->next) {
+ BKE_sequence_translate(evil_scene, seq_child, delta);
+ }
+ }
+
+ BKE_sequence_calc_disp(evil_scene, seq);
+}
+
+/* return 0 if there weren't enough space */
+bool BKE_sequence_base_shuffle_ex(ListBase *seqbasep,
+ Sequence *test,
+ Scene *evil_scene,
+ int channel_delta)
+{
+ const int orig_machine = test->machine;
+ BLI_assert(ELEM(channel_delta, -1, 1));
+
+ test->machine += channel_delta;
+ BKE_sequence_calc(evil_scene, test);
+ while (BKE_sequence_test_overlap(seqbasep, test)) {
+ if ((channel_delta > 0) ? (test->machine >= MAXSEQ) : (test->machine < 1)) {
+ break;
+ }
+
+ test->machine += channel_delta;
+ BKE_sequence_calc(
+ evil_scene,
+ test); // XXX - I don't think this is needed since were only moving vertically, Campbell.
+ }
+
+ if ((test->machine < 1) || (test->machine > MAXSEQ)) {
+ /* Blender 2.4x would remove the strip.
+ * nicer to move it to the end */
+
+ Sequence *seq;
+ int new_frame = test->enddisp;
+
+ for (seq = seqbasep->first; seq; seq = seq->next) {
+ if (seq->machine == orig_machine) {
+ new_frame = max_ii(new_frame, seq->enddisp);
+ }
+ }
+
+ test->machine = orig_machine;
+ new_frame = new_frame + (test->start - test->startdisp); /* adjust by the startdisp */
+ BKE_sequence_translate(evil_scene, test, new_frame - test->start);
+
+ BKE_sequence_calc(evil_scene, test);
+ return false;
+ }
+
+ return true;
+}
+
+bool BKE_sequence_base_shuffle(ListBase *seqbasep, Sequence *test, Scene *evil_scene)
+{
+ return BKE_sequence_base_shuffle_ex(seqbasep, test, evil_scene, 1);
+}
+
+static int shuffle_seq_time_offset_test(ListBase *seqbasep, char dir)
+{
+ int offset = 0;
+ Sequence *seq, *seq_other;
+
+ for (seq = seqbasep->first; seq; seq = seq->next) {
+ if (seq->tmp) {
+ for (seq_other = seqbasep->first; seq_other; seq_other = seq_other->next) {
+ if (!seq_other->tmp && seq_overlap(seq, seq_other)) {
+ if (dir == 'L') {
+ offset = min_ii(offset, seq_other->startdisp - seq->enddisp);
+ }
+ else {
+ offset = max_ii(offset, seq_other->enddisp - seq->startdisp);
+ }
+ }
+ }
+ }
+ }
+ return offset;
+}
+
+static int shuffle_seq_time_offset(Scene *scene, ListBase *seqbasep, char dir)
+{
+ int ofs = 0;
+ int tot_ofs = 0;
+ Sequence *seq;
+ while ((ofs = shuffle_seq_time_offset_test(seqbasep, dir))) {
+ for (seq = seqbasep->first; seq; seq = seq->next) {
+ if (seq->tmp) {
+ /* seq_test_overlap only tests display values */
+ seq->startdisp += ofs;
+ seq->enddisp += ofs;
+ }
+ }
+
+ tot_ofs += ofs;
+ }
+
+ for (seq = seqbasep->first; seq; seq = seq->next) {
+ if (seq->tmp) {
+ BKE_sequence_calc_disp(scene, seq); /* corrects dummy startdisp/enddisp values */
+ }
+ }
+
+ return tot_ofs;
+}
+
+bool BKE_sequence_base_shuffle_time(ListBase *seqbasep,
+ Scene *evil_scene,
+ ListBase *markers,
+ const bool use_sync_markers)
+{
+ /* note: seq->tmp is used to tag strips to move */
+
+ Sequence *seq;
+
+ int offset_l = shuffle_seq_time_offset(evil_scene, seqbasep, 'L');
+ int offset_r = shuffle_seq_time_offset(evil_scene, seqbasep, 'R');
+ int offset = (-offset_l < offset_r) ? offset_l : offset_r;
+
+ if (offset) {
+ for (seq = seqbasep->first; seq; seq = seq->next) {
+ if (seq->tmp) {
+ BKE_sequence_translate(evil_scene, seq, offset);
+ seq->flag &= ~SEQ_OVERLAP;
+ }
+ }
+
+ if (use_sync_markers && !(evil_scene->toolsettings->lock_markers) && (markers != NULL)) {
+ TimeMarker *marker;
+ /* affect selected markers - it's unlikely that we will want to affect all in this way? */
+ for (marker = markers->first; marker; marker = marker->next) {
+ if (marker->flag & SELECT) {
+ marker->frame += offset;
+ }
+ }
+ }
+ }
+
+ return offset ? false : true;
+}
diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c
new file mode 100644
index 00000000000..2b1d36a7709
--- /dev/null
+++ b/source/blender/sequencer/intern/utils.c
@@ -0,0 +1,549 @@
+/*
+ * 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.
+ *
+ * - Blender Foundation, 2003-2009
+ * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_mask_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+
+#include "BLI_listbase.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+
+#include "BKE_image.h"
+#include "BKE_main.h"
+#include "BKE_scene.h"
+
+#include "SEQ_sequencer.h"
+
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
+#include "multiview.h"
+#include "proxy.h"
+#include "utils.h"
+
+void BKE_sequencer_sort(Scene *scene)
+{
+ /* all strips together per kind, and in order of y location ("machine") */
+ ListBase seqbase, effbase;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq, *seqt;
+
+ if (ed == NULL) {
+ return;
+ }
+
+ BLI_listbase_clear(&seqbase);
+ BLI_listbase_clear(&effbase);
+
+ while ((seq = BLI_pophead(ed->seqbasep))) {
+
+ if (seq->type & SEQ_TYPE_EFFECT) {
+ seqt = effbase.first;
+ while (seqt) {
+ if (seqt->machine >= seq->machine) {
+ BLI_insertlinkbefore(&effbase, seqt, seq);
+ break;
+ }
+ seqt = seqt->next;
+ }
+ if (seqt == NULL) {
+ BLI_addtail(&effbase, seq);
+ }
+ }
+ else {
+ seqt = seqbase.first;
+ while (seqt) {
+ if (seqt->machine >= seq->machine) {
+ BLI_insertlinkbefore(&seqbase, seqt, seq);
+ break;
+ }
+ seqt = seqt->next;
+ }
+ if (seqt == NULL) {
+ BLI_addtail(&seqbase, seq);
+ }
+ }
+ }
+
+ BLI_movelisttolist(&seqbase, &effbase);
+ *(ed->seqbasep) = seqbase;
+}
+
+typedef struct SeqUniqueInfo {
+ Sequence *seq;
+ char name_src[SEQ_NAME_MAXSTR];
+ char name_dest[SEQ_NAME_MAXSTR];
+ int count;
+ int match;
+} SeqUniqueInfo;
+
+static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui)
+{
+ Sequence *seq;
+ for (seq = seqbasep->first; seq; seq = seq->next) {
+ if ((sui->seq != seq) && STREQ(sui->name_dest, seq->name + 2)) {
+ /* SEQ_NAME_MAXSTR -4 for the number, -1 for \0, - 2 for r_prefix */
+ BLI_snprintf(sui->name_dest,
+ sizeof(sui->name_dest),
+ "%.*s.%03d",
+ SEQ_NAME_MAXSTR - 4 - 1 - 2,
+ sui->name_src,
+ sui->count++);
+ sui->match = 1; /* be sure to re-scan */
+ }
+ }
+}
+
+static int seqbase_unique_name_recursive_fn(Sequence *seq, void *arg_pt)
+{
+ if (seq->seqbase.first) {
+ seqbase_unique_name(&seq->seqbase, (SeqUniqueInfo *)arg_pt);
+ }
+ return 1;
+}
+
+void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, Sequence *seq)
+{
+ SeqUniqueInfo sui;
+ char *dot;
+ sui.seq = seq;
+ BLI_strncpy(sui.name_src, seq->name + 2, sizeof(sui.name_src));
+ BLI_strncpy(sui.name_dest, seq->name + 2, sizeof(sui.name_dest));
+
+ sui.count = 1;
+ sui.match = 1; /* assume the worst to start the loop */
+
+ /* Strip off the suffix */
+ if ((dot = strrchr(sui.name_src, '.'))) {
+ *dot = '\0';
+ dot++;
+
+ if (*dot) {
+ sui.count = atoi(dot) + 1;
+ }
+ }
+
+ while (sui.match) {
+ sui.match = 0;
+ seqbase_unique_name(seqbasep, &sui);
+ BKE_sequencer_base_recursive_apply(seqbasep, seqbase_unique_name_recursive_fn, &sui);
+ }
+
+ BLI_strncpy(seq->name + 2, sui.name_dest, sizeof(seq->name) - 2);
+}
+
+static const char *give_seqname_by_type(int type)
+{
+ switch (type) {
+ case SEQ_TYPE_META:
+ return "Meta";
+ case SEQ_TYPE_IMAGE:
+ return "Image";
+ case SEQ_TYPE_SCENE:
+ return "Scene";
+ case SEQ_TYPE_MOVIE:
+ return "Movie";
+ case SEQ_TYPE_MOVIECLIP:
+ return "Clip";
+ case SEQ_TYPE_MASK:
+ return "Mask";
+ case SEQ_TYPE_SOUND_RAM:
+ return "Audio";
+ case SEQ_TYPE_CROSS:
+ return "Cross";
+ case SEQ_TYPE_GAMCROSS:
+ return "Gamma Cross";
+ case SEQ_TYPE_ADD:
+ return "Add";
+ case SEQ_TYPE_SUB:
+ return "Sub";
+ case SEQ_TYPE_MUL:
+ return "Mul";
+ case SEQ_TYPE_ALPHAOVER:
+ return "Alpha Over";
+ case SEQ_TYPE_ALPHAUNDER:
+ return "Alpha Under";
+ case SEQ_TYPE_OVERDROP:
+ return "Over Drop";
+ case SEQ_TYPE_COLORMIX:
+ return "Color Mix";
+ case SEQ_TYPE_WIPE:
+ return "Wipe";
+ case SEQ_TYPE_GLOW:
+ return "Glow";
+ case SEQ_TYPE_TRANSFORM:
+ return "Transform";
+ case SEQ_TYPE_COLOR:
+ return "Color";
+ case SEQ_TYPE_MULTICAM:
+ return "Multicam";
+ case SEQ_TYPE_ADJUSTMENT:
+ return "Adjustment";
+ case SEQ_TYPE_SPEED:
+ return "Speed";
+ case SEQ_TYPE_GAUSSIAN_BLUR:
+ return "Gaussian Blur";
+ case SEQ_TYPE_TEXT:
+ return "Text";
+ default:
+ return NULL;
+ }
+}
+
+const char *BKE_sequence_give_name(Sequence *seq)
+{
+ const char *name = give_seqname_by_type(seq->type);
+
+ if (!name) {
+ if (!(seq->type & SEQ_TYPE_EFFECT)) {
+ return seq->strip->dir;
+ }
+
+ return "Effect";
+ }
+ return name;
+}
+
+ListBase *BKE_sequence_seqbase_get(Sequence *seq, int *r_offset)
+{
+ ListBase *seqbase = NULL;
+
+ switch (seq->type) {
+ case SEQ_TYPE_META: {
+ seqbase = &seq->seqbase;
+ *r_offset = seq->start;
+ break;
+ }
+ case SEQ_TYPE_SCENE: {
+ if (seq->flag & SEQ_SCENE_STRIPS && seq->scene) {
+ Editing *ed = BKE_sequencer_editing_get(seq->scene, false);
+ if (ed) {
+ seqbase = &ed->seqbase;
+ *r_offset = seq->scene->r.sfra;
+ }
+ }
+ break;
+ }
+ }
+
+ return seqbase;
+}
+
+void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile)
+{
+ char dir[FILE_MAX];
+ char name[FILE_MAX];
+ StripProxy *proxy;
+ bool use_proxy;
+ bool is_multiview_loaded = false;
+ Editing *ed = scene->ed;
+ const bool is_multiview = (seq->flag & SEQ_USE_VIEWS) != 0 &&
+ (scene->r.scemode & R_MULTIVIEW) != 0;
+
+ if ((seq->anims.first != NULL) && (((StripAnim *)seq->anims.first)->anim != NULL)) {
+ return;
+ }
+
+ /* reset all the previously created anims */
+ BKE_sequence_free_anim(seq);
+
+ BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name);
+ BLI_path_abs(name, BKE_main_blendfile_path_from_global());
+
+ proxy = seq->strip->proxy;
+
+ use_proxy = proxy && ((proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_DIR) != 0 ||
+ (ed->proxy_storage == SEQ_EDIT_PROXY_DIR_STORAGE));
+
+ if (use_proxy) {
+ if (ed->proxy_storage == SEQ_EDIT_PROXY_DIR_STORAGE) {
+ if (ed->proxy_dir[0] == 0) {
+ BLI_strncpy(dir, "//BL_proxy", sizeof(dir));
+ }
+ else {
+ BLI_strncpy(dir, ed->proxy_dir, sizeof(dir));
+ }
+ }
+ else {
+ BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir));
+ }
+ BLI_path_abs(dir, BKE_main_blendfile_path_from_global());
+ }
+
+ if (is_multiview && seq->views_format == R_IMF_VIEWS_INDIVIDUAL) {
+ int totfiles = seq_num_files(scene, seq->views_format, true);
+ char prefix[FILE_MAX];
+ const char *ext = NULL;
+ int i;
+
+ BKE_scene_multiview_view_prefix_get(scene, name, prefix, &ext);
+
+ if (prefix[0] != '\0') {
+ for (i = 0; i < totfiles; i++) {
+ const char *suffix = BKE_scene_multiview_view_id_suffix_get(&scene->r, i);
+ char str[FILE_MAX];
+ StripAnim *sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
+
+ BLI_addtail(&seq->anims, sanim);
+
+ BLI_snprintf(str, sizeof(str), "%s%s%s", prefix, suffix, ext);
+
+ if (openfile) {
+ sanim->anim = openanim(str,
+ IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex,
+ seq->strip->colorspace_settings.name);
+ }
+ else {
+ sanim->anim = openanim_noload(str,
+ IB_rect |
+ ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex,
+ seq->strip->colorspace_settings.name);
+ }
+
+ if (sanim->anim) {
+ /* we already have the suffix */
+ IMB_suffix_anim(sanim->anim, suffix);
+ }
+ else {
+ if (openfile) {
+ sanim->anim = openanim(name,
+ IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex,
+ seq->strip->colorspace_settings.name);
+ }
+ else {
+ sanim->anim = openanim_noload(name,
+ IB_rect |
+ ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex,
+ seq->strip->colorspace_settings.name);
+ }
+
+ /* No individual view files - monoscopic, stereo 3d or EXR multi-view. */
+ totfiles = 1;
+ }
+
+ if (sanim->anim && use_proxy) {
+ seq_proxy_index_dir_set(sanim->anim, dir);
+ }
+ }
+ is_multiview_loaded = true;
+ }
+ }
+
+ if (is_multiview_loaded == false) {
+ StripAnim *sanim;
+
+ sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
+ BLI_addtail(&seq->anims, sanim);
+
+ if (openfile) {
+ sanim->anim = openanim(name,
+ IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex,
+ seq->strip->colorspace_settings.name);
+ }
+ else {
+ sanim->anim = openanim_noload(name,
+ IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
+ seq->streamindex,
+ seq->strip->colorspace_settings.name);
+ }
+
+ if (sanim->anim && use_proxy) {
+ seq_proxy_index_dir_set(sanim->anim, dir);
+ }
+ }
+}
+
+const Sequence *BKE_sequencer_foreground_frame_get(const Scene *scene, int frame)
+{
+ const Editing *ed = scene->ed;
+ const Sequence *seq, *best_seq = NULL;
+ int best_machine = -1;
+
+ if (!ed) {
+ return NULL;
+ }
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) {
+ continue;
+ }
+ /* Only use strips that generate an image, not ones that combine
+ * other strips or apply some effect. */
+ if (ELEM(seq->type,
+ SEQ_TYPE_IMAGE,
+ SEQ_TYPE_META,
+ SEQ_TYPE_SCENE,
+ SEQ_TYPE_MOVIE,
+ SEQ_TYPE_COLOR,
+ SEQ_TYPE_TEXT)) {
+ if (seq->machine > best_machine) {
+ best_seq = seq;
+ best_machine = seq->machine;
+ }
+ }
+ }
+ return best_seq;
+}
+
+/* in cases where we done know the sequence's listbase */
+ListBase *BKE_sequence_seqbase(ListBase *seqbase, Sequence *seq)
+{
+ Sequence *iseq;
+ ListBase *lb = NULL;
+
+ for (iseq = seqbase->first; iseq; iseq = iseq->next) {
+ if (seq == iseq) {
+ return seqbase;
+ }
+ if (iseq->seqbase.first && (lb = BKE_sequence_seqbase(&iseq->seqbase, seq))) {
+ return lb;
+ }
+ }
+
+ return NULL;
+}
+
+Sequence *BKE_sequence_metastrip(ListBase *seqbase, Sequence *meta, Sequence *seq)
+{
+ Sequence *iseq;
+
+ for (iseq = seqbase->first; iseq; iseq = iseq->next) {
+ Sequence *rval;
+
+ if (seq == iseq) {
+ return meta;
+ }
+ if (iseq->seqbase.first && (rval = BKE_sequence_metastrip(&iseq->seqbase, iseq, seq))) {
+ return rval;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * Only use as last resort when the StripElem is available but no the Sequence.
+ * (needed for RNA)
+ */
+Sequence *BKE_sequencer_from_elem(ListBase *seqbase, StripElem *se)
+{
+ Sequence *iseq;
+
+ for (iseq = seqbase->first; iseq; iseq = iseq->next) {
+ Sequence *seq_found;
+ if ((iseq->strip && iseq->strip->stripdata) &&
+ (ARRAY_HAS_ITEM(se, iseq->strip->stripdata, iseq->len))) {
+ break;
+ }
+ if ((seq_found = BKE_sequencer_from_elem(&iseq->seqbase, se))) {
+ iseq = seq_found;
+ break;
+ }
+ }
+
+ return iseq;
+}
+
+Sequence *BKE_sequence_get_by_name(ListBase *seqbase, const char *name, bool recursive)
+{
+ Sequence *iseq = NULL;
+ Sequence *rseq = NULL;
+
+ for (iseq = seqbase->first; iseq; iseq = iseq->next) {
+ if (STREQ(name, iseq->name + 2)) {
+ return iseq;
+ }
+ if (recursive && (iseq->seqbase.first) &&
+ (rseq = BKE_sequence_get_by_name(&iseq->seqbase, name, 1))) {
+ return rseq;
+ }
+ }
+
+ return NULL;
+}
+
+Mask *BKE_sequencer_mask_get(Scene *scene)
+{
+ Sequence *seq_act = BKE_sequencer_active_get(scene);
+
+ if (seq_act && seq_act->type == SEQ_TYPE_MASK) {
+ return seq_act->mask;
+ }
+
+ return NULL;
+}
+
+void BKE_sequence_alpha_mode_from_extension(Sequence *seq)
+{
+ if (seq->strip && seq->strip->stripdata) {
+ const char *filename = seq->strip->stripdata->name;
+ seq->alpha_mode = BKE_image_alpha_mode_from_extension_ex(filename);
+ }
+}
+
+/* called on draw, needs to be fast,
+ * we could cache and use a flag if we want to make checks for file paths resolving for eg. */
+bool BKE_sequence_is_valid_check(Sequence *seq)
+{
+ switch (seq->type) {
+ case SEQ_TYPE_MASK:
+ return (seq->mask != NULL);
+ case SEQ_TYPE_MOVIECLIP:
+ return (seq->clip != NULL);
+ case SEQ_TYPE_SCENE:
+ return (seq->scene != NULL);
+ case SEQ_TYPE_SOUND_RAM:
+ return (seq->sound != NULL);
+ }
+
+ return true;
+}
+
+bool sequencer_seq_generates_image(Sequence *seq)
+{
+ switch (seq->type) {
+ case SEQ_TYPE_IMAGE:
+ case SEQ_TYPE_SCENE:
+ case SEQ_TYPE_MOVIE:
+ case SEQ_TYPE_MOVIECLIP:
+ case SEQ_TYPE_MASK:
+ case SEQ_TYPE_COLOR:
+ case SEQ_TYPE_TEXT:
+ return true;
+ }
+ return false;
+}
diff --git a/source/blender/sequencer/intern/utils.h b/source/blender/sequencer/intern/utils.h
new file mode 100644
index 00000000000..fe6041ec5e8
--- /dev/null
+++ b/source/blender/sequencer/intern/utils.h
@@ -0,0 +1,41 @@
+/*
+ * 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) 2004 Blender Foundation.
+ * All rights reserved.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup sequencer
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct Scene;
+struct anim;
+
+bool sequencer_seq_generates_image(struct Sequence *seq);
+void seq_open_anim_file(struct Scene *scene, struct Sequence *seq, bool openfile);
+struct Sequence *BKE_sequence_metastrip(ListBase *seqbase /* = ed->seqbase */,
+ struct Sequence *meta /* = NULL */,
+ struct Sequence *seq);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/shader_fx/CMakeLists.txt b/source/blender/shader_fx/CMakeLists.txt
index a68b343d416..0167591c3ba 100644
--- a/source/blender/shader_fx/CMakeLists.txt
+++ b/source/blender/shader_fx/CMakeLists.txt
@@ -31,7 +31,7 @@ set(INC
../editors/include
../makesdna
../makesrna
- ../render/extern/include
+ ../render
../windowmanager
../../../intern/eigen
../../../intern/guardedalloc
diff --git a/source/blender/shader_fx/intern/FX_ui_common.c b/source/blender/shader_fx/intern/FX_ui_common.c
index 87402877281..c1e3b2e21cd 100644
--- a/source/blender/shader_fx/intern/FX_ui_common.c
+++ b/source/blender/shader_fx/intern/FX_ui_common.c
@@ -203,7 +203,7 @@ PanelType *shaderfx_panel_register(ARegionType *region_type, ShaderFxType type,
/* Give the panel the special flag that says it was built here and corresponds to a
* shader effect rather than a PanelType. */
- panel_type->flag = PNL_LAYOUT_HEADER_EXPAND | PNL_DRAW_BOX | PNL_INSTANCED;
+ panel_type->flag = PANEL_TYPE_HEADER_EXPAND | PANEL_TYPE_DRAW_BOX | PANEL_TYPE_INSTANCED;
panel_type->reorder = shaderfx_reorder;
panel_type->get_list_data_expand_flag = get_shaderfx_expand_flag;
panel_type->set_list_data_expand_flag = set_shaderfx_expand_flag;
@@ -240,7 +240,7 @@ PanelType *shaderfx_subpanel_register(ARegionType *region_type,
panel_type->draw_header = draw_header;
panel_type->draw = draw;
panel_type->poll = shaderfx_ui_poll;
- panel_type->flag = (PNL_DEFAULT_CLOSED | PNL_DRAW_BOX);
+ panel_type->flag = (PANEL_TYPE_DEFAULT_CLOSED | PANEL_TYPE_DRAW_BOX);
BLI_assert(parent != NULL);
BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME);
diff --git a/source/blender/simulation/SIM_mass_spring.h b/source/blender/simulation/SIM_mass_spring.h
index 219ead477c2..42d7c86b539 100644
--- a/source/blender/simulation/SIM_mass_spring.h
+++ b/source/blender/simulation/SIM_mass_spring.h
@@ -18,7 +18,7 @@
*/
/** \file
- * \ingroup bph
+ * \ingroup sim
*/
#pragma once
diff --git a/source/blender/simulation/intern/ConstrainedConjugateGradient.h b/source/blender/simulation/intern/ConstrainedConjugateGradient.h
index 0dc80c03bb5..11dc3ebe91b 100644
--- a/source/blender/simulation/intern/ConstrainedConjugateGradient.h
+++ b/source/blender/simulation/intern/ConstrainedConjugateGradient.h
@@ -19,6 +19,10 @@
#pragma once
+/** \file
+ * \ingroup sim
+ */
+
#include <Eigen/Core>
namespace Eigen {
diff --git a/source/blender/simulation/intern/SIM_mass_spring.cpp b/source/blender/simulation/intern/SIM_mass_spring.cpp
index 42cfb11a15a..ce626498e8e 100644
--- a/source/blender/simulation/intern/SIM_mass_spring.cpp
+++ b/source/blender/simulation/intern/SIM_mass_spring.cpp
@@ -18,7 +18,7 @@
*/
/** \file
- * \ingroup bph
+ * \ingroup sim
*/
#include "MEM_guardedalloc.h"
@@ -219,7 +219,7 @@ void SIM_cloth_solver_free(ClothModifierData *clmd)
if (cloth->implicit) {
SIM_mass_spring_solver_free(cloth->implicit);
- cloth->implicit = NULL;
+ cloth->implicit = nullptr;
}
}
@@ -317,8 +317,7 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob),
float len, c, l, vec[3];
spring = (ClothSpring *)node->link;
- if (spring->type != CLOTH_SPRING_TYPE_STRUCTURAL &&
- spring->type != CLOTH_SPRING_TYPE_SHEAR) {
+ if (!ELEM(spring->type, CLOTH_SPRING_TYPE_STRUCTURAL, CLOTH_SPRING_TYPE_SHEAR)) {
continue;
}
@@ -569,7 +568,7 @@ static void hair_get_boundbox(ClothModifierData *clmd, float gmin[3], float gmax
INIT_MINMAX(gmin, gmax);
for (i = 0; i < mvert_num; i++) {
float x[3];
- SIM_mass_spring_get_motion_state(data, i, x, NULL);
+ SIM_mass_spring_get_motion_state(data, i, x, nullptr);
DO_MINMAX(x, gmin, gmax);
}
}
@@ -625,7 +624,7 @@ static void cloth_calc_force(
SIM_mass_spring_force_drag(data, drag);
#endif
/* handle pressure forces (making sure that this never gets computed for hair). */
- if ((parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE) && (clmd->hairdata == NULL)) {
+ if ((parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE) && (clmd->hairdata == nullptr)) {
/* The difference in pressure between the inside and outside of the mesh.*/
float pressure_difference = 0.0f;
float volume_factor = 1.0f;
@@ -659,7 +658,7 @@ static void cloth_calc_force(
/* Compute the hydrostatic pressure gradient if enabled. */
float fluid_density = clmd->sim_parms->fluid_density * 1000; /* kg/l -> kg/m3 */
- float *hydrostatic_pressure = NULL;
+ float *hydrostatic_pressure = nullptr;
if (fabs(fluid_density) > 1e-6f) {
float hydrostatic_vector[3];
@@ -712,7 +711,7 @@ static void cloth_calc_force(
/* handle external forces like wind */
if (effectors) {
- bool is_not_hair = (clmd->hairdata == NULL) && (cloth->primitive_num > 0);
+ bool is_not_hair = (clmd->hairdata == nullptr) && (cloth->primitive_num > 0);
bool has_wind = false, has_force = false;
/* cache per-vertex forces to avoid redundant calculation */
@@ -727,12 +726,12 @@ static void cloth_calc_force(
SIM_mass_spring_get_motion_state(data, i, x, v);
pd_point_from_loc(scene, x, v, i, &epoint);
BKE_effectors_apply(effectors,
- NULL,
+ nullptr,
clmd->sim_parms->effector_weights,
&epoint,
forcevec[i],
winvec[i],
- NULL);
+ nullptr);
has_wind = has_wind || !is_zero_v3(winvec[i]);
has_force = has_force || !is_zero_v3(forcevec[i]);
@@ -824,7 +823,7 @@ BLI_INLINE LinkNode *hair_spring_next(LinkNode *spring_link)
return next;
}
}
- return NULL;
+ return nullptr;
}
/* XXX this is nasty: cloth meshes do not explicitly store
@@ -841,15 +840,15 @@ static LinkNode *cloth_continuum_add_hair_segments(HairGrid *grid,
LinkNode *spring_link)
{
Implicit_Data *data = cloth->implicit;
- LinkNode *next_spring_link = NULL; /* return value */
+ LinkNode *next_spring_link = nullptr; /* return value */
ClothSpring *spring1, *spring2, *spring3;
// ClothVertex *verts = cloth->verts;
// ClothVertex *vert3, *vert4;
float x1[3], v1[3], x2[3], v2[3], x3[3], v3[3], x4[3], v4[3];
float dir1[3], dir2[3], dir3[3];
- spring1 = NULL;
- spring2 = NULL;
+ spring1 = nullptr;
+ spring2 = nullptr;
spring3 = (ClothSpring *)spring_link->link;
zero_v3(x1);
@@ -895,15 +894,25 @@ static LinkNode *cloth_continuum_add_hair_segments(HairGrid *grid,
normalize_v3(dir3);
}
else {
- spring3 = NULL;
+ spring3 = nullptr;
// vert4 = NULL;
zero_v3(x4);
zero_v3(v4);
zero_v3(dir3);
}
- SIM_hair_volume_add_segment(
- grid, x1, v1, x2, v2, x3, v3, x4, v4, spring1 ? dir1 : NULL, dir2, spring3 ? dir3 : NULL);
+ SIM_hair_volume_add_segment(grid,
+ x1,
+ v1,
+ x2,
+ v2,
+ x3,
+ v3,
+ x4,
+ v4,
+ spring1 ? dir1 : nullptr,
+ dir2,
+ spring3 ? dir3 : nullptr);
}
return next_spring_link;
@@ -930,7 +939,7 @@ static void cloth_continuum_fill_grid(HairGrid *grid, Cloth *cloth)
/* scale and offset for transforming vertex locations into grid space
* (cell size is 0..1, gmin becomes origin)
*/
- SIM_hair_volume_grid_geometry(grid, &cellsize, NULL, gmin, NULL);
+ SIM_hair_volume_grid_geometry(grid, &cellsize, nullptr, gmin, nullptr);
cell_scale = cellsize > 0.0f ? 1.0f / cellsize : 0.0f;
mul_v3_v3fl(cell_offset, gmin, cell_scale);
negate_v3(cell_offset);
@@ -1256,7 +1265,7 @@ int SIM_cloth_solve(
* Bad design, TODO
*/
Scene *scene = DEG_get_evaluated_scene(depsgraph);
- const bool is_hair = (clmd->hairdata != NULL);
+ const bool is_hair = (clmd->hairdata != nullptr);
unsigned int i = 0;
float step = 0.0f, tf = clmd->sim_parms->timescale;
@@ -1339,7 +1348,7 @@ int SIM_cloth_solve(
}
}
- SIM_mass_spring_get_motion_state(id, i, verts[i].txold, NULL);
+ SIM_mass_spring_get_motion_state(id, i, verts[i].txold, nullptr);
}
step += dt;
diff --git a/source/blender/simulation/intern/eigen_utils.h b/source/blender/simulation/intern/eigen_utils.h
index 897ba8b2a67..a5d7d5bc808 100644
--- a/source/blender/simulation/intern/eigen_utils.h
+++ b/source/blender/simulation/intern/eigen_utils.h
@@ -20,7 +20,7 @@
#pragma once
/** \file
- * \ingroup bph
+ * \ingroup sim
*/
#if defined(__GNUC__) && !defined(__clang__)
diff --git a/source/blender/simulation/intern/hair_volume.cpp b/source/blender/simulation/intern/hair_volume.cpp
index c24b7154d13..123b91edaac 100644
--- a/source/blender/simulation/intern/hair_volume.cpp
+++ b/source/blender/simulation/intern/hair_volume.cpp
@@ -18,7 +18,7 @@
*/
/** \file
- * \ingroup bph
+ * \ingroup sim
*/
#include "MEM_guardedalloc.h"
@@ -224,7 +224,7 @@ void SIM_hair_volume_vertex_grid_forces(HairGrid *grid,
x,
&gdensity,
gvelocity,
- NULL,
+ nullptr,
ggrad,
gvelgrad);
diff --git a/source/blender/simulation/intern/implicit.h b/source/blender/simulation/intern/implicit.h
index c5afa90aa91..a8693c61018 100644
--- a/source/blender/simulation/intern/implicit.h
+++ b/source/blender/simulation/intern/implicit.h
@@ -20,7 +20,7 @@
#pragma once
/** \file
- * \ingroup bph
+ * \ingroup sim
*/
#include "stdio.h"
diff --git a/source/blender/simulation/intern/implicit_blender.c b/source/blender/simulation/intern/implicit_blender.c
index df8c4782acd..4c4d3e8a821 100644
--- a/source/blender/simulation/intern/implicit_blender.c
+++ b/source/blender/simulation/intern/implicit_blender.c
@@ -18,7 +18,7 @@
*/
/** \file
- * \ingroup bph
+ * \ingroup sim
*/
#include "implicit.h"
diff --git a/source/blender/simulation/intern/implicit_eigen.cpp b/source/blender/simulation/intern/implicit_eigen.cpp
index b30a46909b9..ea1729589d6 100644
--- a/source/blender/simulation/intern/implicit_eigen.cpp
+++ b/source/blender/simulation/intern/implicit_eigen.cpp
@@ -18,7 +18,7 @@
*/
/** \file
- * \ingroup bph
+ * \ingroup sim
*/
#include "implicit.h"
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index 07e962aaf89..6de36acb343 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -36,13 +36,16 @@ set(INC
../makesdna
../makesrna
../nodes
- ../render/extern/include
+ ../render
../sequencer
../../../intern/clog
../../../intern/ghost
../../../intern/glew-mx
../../../intern/guardedalloc
../../../intern/memutil
+
+ # for writefile.c: dna_type_offsets.h
+ ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
)
set(INC_SYS
@@ -206,3 +209,6 @@ if(WITH_XR_OPENXR)
endif()
blender_add_lib_nolist(bf_windowmanager "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+
+# Needed so we can use dna_type_offsets.h for defaults initialization.
+add_dependencies(bf_windowmanager bf_dna)
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 8d4ef29af74..fd0b99fb9ae 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -729,6 +729,7 @@ enum {
WM_JOB_TYPE_LIGHT_BAKE,
WM_JOB_TYPE_FSMENU_BOOKMARK_VALIDATE,
WM_JOB_TYPE_QUADRIFLOW_REMESH,
+ WM_JOB_TYPE_TRACE_IMAGE,
/* add as needed, bake, seq proxy build
* if having hard coded values is a problem */
};
@@ -856,6 +857,9 @@ void WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4]);
float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]);
bool WM_event_is_tablet(const struct wmEvent *event);
+int WM_event_absolute_delta_x(const struct wmEvent *event);
+int WM_event_absolute_delta_y(const struct wmEvent *event);
+
#ifdef WITH_INPUT_IME
bool WM_event_is_ime_switch(const struct wmEvent *event);
#endif
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index a8d24205268..7fa2851cbf3 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -595,6 +595,10 @@ typedef struct wmEvent {
/** Ascii, unicode, mouse coords, angles, vectors, dragdrop info. */
void *customdata;
+ /* True if the operating system inverted the delta x/y values and resulting
+ * prev x/y values, for natural scroll direction. For absolute scroll direction,
+ * the delta must be negated again. */
+ char is_direction_inverted;
} wmEvent;
/**
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
index b81b12a1b06..a56a506b1ab 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
@@ -611,6 +611,7 @@ void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
r_mat);
}
+/* -------------------------------------------------------------------- */
/** \name Gizmo Property Access
*
* Matches `WM_operator_properties` conventions.
@@ -755,6 +756,7 @@ void WM_gizmo_properties_free(PointerRNA *ptr)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name General Utilities
*
* \{ */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
index eea046cd1cf..e9a1b5e3df0 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -344,6 +344,7 @@ bool wm_gizmogroup_is_any_selected(const wmGizmoGroup *gzgroup)
/** \} */
+/* -------------------------------------------------------------------- */
/** \name Gizmo operators
*
* Basic operators for gizmo interaction with user configurable keymaps.
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c
index f594ced6b66..a9e24867351 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c
@@ -38,6 +38,7 @@
#include "wm_gizmo_intern.h"
#include "wm_gizmo_wmapi.h"
+/* -------------------------------------------------------------------- */
/** \name GizmoGroup Type Append
*
* \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends.
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c
index 3956ff8fd36..efd7a13d02a 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c
@@ -45,6 +45,7 @@
#include "wm_gizmo_intern.h"
#include "wm_gizmo_wmapi.h"
+/* -------------------------------------------------------------------- */
/** \name Gizmo Type Append
*
* \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends.
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index e7010461c68..a10284e9740 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -25,6 +25,9 @@
* Also Blender's main event loop (WM_main).
*/
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#include <stddef.h>
#include <string.h>
@@ -69,6 +72,8 @@
# include "BPY_extern_run.h"
#endif
+#include "BLO_read_write.h"
+
/* ****************************************************** */
static void window_manager_free_data(ID *id)
@@ -98,6 +103,158 @@ static void window_manager_foreach_id(ID *id, LibraryForeachIDData *data)
}
}
+static void write_wm_xr_data(BlendWriter *writer, wmXrData *xr_data)
+{
+ BKE_screen_view3d_shading_blend_write(writer, &xr_data->session_settings.shading);
+}
+
+static void window_manager_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ wmWindowManager *wm = (wmWindowManager *)id;
+
+ BLO_write_id_struct(writer, wmWindowManager, id_address, &wm->id);
+ BKE_id_blend_write(writer, &wm->id);
+ write_wm_xr_data(writer, &wm->xr);
+
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
+ /* update deprecated screen member (for so loading in 2.7x uses the correct screen) */
+ win->screen = BKE_workspace_active_screen_get(win->workspace_hook);
+
+ BLO_write_struct(writer, wmWindow, win);
+ BLO_write_struct(writer, WorkSpaceInstanceHook, win->workspace_hook);
+ BLO_write_struct(writer, Stereo3dFormat, win->stereo3d_format);
+
+ BKE_screen_area_map_blend_write(writer, &win->global_areas);
+
+ /* data is written, clear deprecated data again */
+ win->screen = NULL;
+ }
+}
+
+static void direct_link_wm_xr_data(BlendDataReader *reader, wmXrData *xr_data)
+{
+ BKE_screen_view3d_shading_blend_read_data(reader, &xr_data->session_settings.shading);
+}
+
+static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ wmWindowManager *wm = (wmWindowManager *)id;
+
+ id_us_ensure_real(&wm->id);
+ BLO_read_list(reader, &wm->windows);
+
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
+ BLO_read_data_address(reader, &win->parent);
+
+ WorkSpaceInstanceHook *hook = win->workspace_hook;
+ BLO_read_data_address(reader, &win->workspace_hook);
+
+ /* This will be NULL for any pre-2.80 blend file. */
+ if (win->workspace_hook != NULL) {
+ /* We need to restore a pointer to this later when reading workspaces,
+ * so store in global oldnew-map.
+ * Note that this is only needed for versioning of older .blend files now.. */
+ BLO_read_data_globmap_add(reader, hook, win->workspace_hook);
+ /* Cleanup pointers to data outside of this data-block scope. */
+ win->workspace_hook->act_layout = NULL;
+ win->workspace_hook->temp_workspace_store = NULL;
+ win->workspace_hook->temp_layout_store = NULL;
+ }
+
+ BKE_screen_area_map_blend_read_data(reader, &win->global_areas);
+
+ win->ghostwin = NULL;
+ win->gpuctx = NULL;
+ win->eventstate = NULL;
+ win->cursor_keymap_status = NULL;
+ win->tweak = NULL;
+#ifdef WIN32
+ win->ime_data = NULL;
+#endif
+
+ BLI_listbase_clear(&win->queue);
+ BLI_listbase_clear(&win->handlers);
+ BLI_listbase_clear(&win->modalhandlers);
+ BLI_listbase_clear(&win->gesture);
+
+ win->active = 0;
+
+ win->cursor = 0;
+ win->lastcursor = 0;
+ win->modalcursor = 0;
+ win->grabcursor = 0;
+ win->addmousemove = true;
+ BLO_read_data_address(reader, &win->stereo3d_format);
+
+ /* Multi-view always fallback to anaglyph at file opening
+ * otherwise quad-buffer saved files can break Blender. */
+ if (win->stereo3d_format) {
+ win->stereo3d_format->display_mode = S3D_DISPLAY_ANAGLYPH;
+ }
+ }
+
+ direct_link_wm_xr_data(reader, &wm->xr);
+
+ BLI_listbase_clear(&wm->timers);
+ BLI_listbase_clear(&wm->operators);
+ BLI_listbase_clear(&wm->paintcursors);
+ BLI_listbase_clear(&wm->queue);
+ BKE_reports_init(&wm->reports, RPT_STORE);
+
+ BLI_listbase_clear(&wm->keyconfigs);
+ wm->defaultconf = NULL;
+ wm->addonconf = NULL;
+ wm->userconf = NULL;
+ wm->undo_stack = NULL;
+
+ wm->message_bus = NULL;
+
+ wm->xr.runtime = NULL;
+
+ BLI_listbase_clear(&wm->jobs);
+ BLI_listbase_clear(&wm->drags);
+
+ wm->windrawable = NULL;
+ wm->winactive = NULL;
+ wm->initialized = 0;
+ wm->op_undo_depth = 0;
+ wm->is_interface_locked = 0;
+}
+
+static void lib_link_wm_xr_data(BlendLibReader *reader, ID *parent_id, wmXrData *xr_data)
+{
+ BLO_read_id_address(reader, parent_id->lib, &xr_data->session_settings.base_pose_object);
+}
+
+static void lib_link_workspace_instance_hook(BlendLibReader *reader,
+ WorkSpaceInstanceHook *hook,
+ ID *id)
+{
+ WorkSpace *workspace = BKE_workspace_active_get(hook);
+ BLO_read_id_address(reader, id->lib, &workspace);
+ BKE_workspace_active_set(hook, workspace);
+}
+
+static void window_manager_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+ wmWindowManager *wm = (wmWindowManager *)id;
+
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
+ if (win->workspace_hook) { /* NULL for old files */
+ lib_link_workspace_instance_hook(reader, win->workspace_hook, &wm->id);
+ }
+ BLO_read_id_address(reader, wm->id.lib, &win->scene);
+ /* deprecated, but needed for versioning (will be NULL'ed then) */
+ BLO_read_id_address(reader, NULL, &win->screen);
+
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
+ BKE_screen_area_blend_read_lib(reader, &wm->id, area);
+ }
+
+ lib_link_wm_xr_data(reader, &wm->id, &wm->xr);
+ }
+}
+
IDTypeInfo IDType_ID_WM = {
.id_code = ID_WM,
.id_filter = 0,
@@ -116,10 +273,12 @@ IDTypeInfo IDType_ID_WM = {
.foreach_id = window_manager_foreach_id,
.foreach_cache = NULL,
- .blend_write = NULL,
- .blend_read_data = NULL,
- .blend_read_lib = NULL,
+ .blend_write = window_manager_blend_write,
+ .blend_read_data = window_manager_blend_read_data,
+ .blend_read_lib = window_manager_blend_read_lib,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
#define MAX_OP_REGISTERED 32
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 3449c6974f5..b11dae27d19 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -103,7 +103,7 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region)
continue;
}
- if ((pc->region_type != RGN_TYPE_ANY) && (region->regiontype != pc->region_type)) {
+ if (!ELEM(pc->region_type, RGN_TYPE_ANY, region->regiontype)) {
continue;
}
diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c
index db80296bdb8..a996796104b 100644
--- a/source/blender/windowmanager/intern/wm_event_query.c
+++ b/source/blender/windowmanager/intern/wm_event_query.c
@@ -423,6 +423,38 @@ bool WM_event_is_tablet(const struct wmEvent *event)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Event Scroll's Absolute Deltas
+ *
+ * User may change the scroll behavior, and the deltas are automatically inverted.
+ * These functions return the absolute direction, swipe up/right gives positive values.
+ *
+ * \{ */
+
+int WM_event_absolute_delta_x(const struct wmEvent *event)
+{
+ int dx = event->x - event->prevx;
+
+ if (!event->is_direction_inverted) {
+ dx = -dx;
+ }
+
+ return dx;
+}
+
+int WM_event_absolute_delta_y(const struct wmEvent *event)
+{
+ int dy = event->y - event->prevy;
+
+ if (!event->is_direction_inverted) {
+ dy = -dy;
+ }
+
+ return dy;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Event IME Input Access
* \{ */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 8f141a8e23b..1aaefeabd08 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -180,6 +180,14 @@ void wm_event_free(wmEvent *event)
MEM_freeN(event);
}
+static void wm_event_free_last(wmWindow *win)
+{
+ wmEvent *event = BLI_poptail(&win->queue);
+ if (event != NULL) {
+ wm_event_free(event);
+ }
+}
+
void wm_event_free_all(wmWindow *win)
{
wmEvent *event;
@@ -1731,8 +1739,21 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers)
BLI_assert(handler_base->type != 0);
if (handler_base->type == WM_HANDLER_TYPE_OP) {
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
+
if (handler->op) {
wmWindow *win = CTX_wm_window(C);
+
+ if (handler->is_fileselect) {
+ /* Exit File Browsers referring to this handler/operator. */
+ LISTBASE_FOREACH (wmWindow *, temp_win, &wm->windows) {
+ ScrArea *file_area = ED_fileselect_handler_area_find(temp_win, handler->op);
+ if (!file_area) {
+ continue;
+ }
+ ED_area_exit(C, file_area);
+ }
+ }
+
if (handler->op->type->cancel) {
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
@@ -3471,25 +3492,15 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
if (handler->is_fileselect == false) {
continue;
}
- bScreen *screen = CTX_wm_screen(C);
- bool cancel_handler = true;
- /* 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;
+ ScrArea *file_area = ED_fileselect_handler_area_find(win, handler->op);
- if (sfile->op == handler->op) {
- CTX_wm_area_set(C, area);
- wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_CANCEL);
- cancel_handler = false;
- break;
- }
- }
+ if (file_area) {
+ CTX_wm_area_set(C, file_area);
+ wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_CANCEL);
}
-
/* If not found we stop the handler without changing the screen. */
- if (cancel_handler) {
+ else {
wm_handler_fileselect_do(
C, &win->modalhandlers, handler, EVT_FILESELECT_EXTERNAL_CANCEL);
}
@@ -4303,6 +4314,26 @@ static wmEvent *wm_event_add_mousemove(wmWindow *win, const wmEvent *event)
return event_new;
}
+static wmEvent *wm_event_add_trackpad(wmWindow *win, const wmEvent *event, int deltax, int deltay)
+{
+ /* Ignore in between trackpad events for performance, we only need high accuracy
+ * for painting with mouse moves, for navigation using the accumulated value is ok. */
+ wmEvent *event_last = win->queue.last;
+ if (event_last && event_last->type == event->type) {
+ deltax += event_last->x - event_last->prevx;
+ deltay += event_last->y - event_last->prevy;
+
+ wm_event_free_last(win);
+ }
+
+ /* Set prevx/prevy, the delta is computed from this in operators. */
+ wmEvent *event_new = wm_event_add(win, event);
+ event_new->prevx = event_new->x - deltax;
+ event_new->prevy = event_new->y - deltay;
+
+ return event_new;
+}
+
/* 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)
@@ -4390,14 +4421,13 @@ 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. */
- event.prevx = event.x - pd->deltaX;
- event.prevy = event.y - (-pd->deltaY);
+ /* The direction is inverted from the device due to system preferences. */
+ event.is_direction_inverted = pd->isDirectionInverted;
- wm_event_add(win, &event);
+ wm_event_add_trackpad(win, &event, pd->deltaX, -pd->deltaY);
break;
}
- /* ,ouse button, */
+ /* Mouse button. */
case GHOST_kEventButtonDown:
case GHOST_kEventButtonUp: {
GHOST_TEventButtonData *bd = customdata;
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index a862d221815..4706287a3a9 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2482,7 +2482,7 @@ void WM_OT_open_mainfile(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_boolean(
ot->srna, "load_ui", true, "Load UI", "Load user interface setup in the .blend file");
@@ -2804,7 +2804,7 @@ void WM_OT_save_as_mainfile(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_boolean(ot->srna, "compress", false, "Compress", "Write compressed .blend file");
RNA_def_boolean(ot->srna,
"relative_remap",
@@ -2874,7 +2874,7 @@ void WM_OT_save_mainfile(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
RNA_def_boolean(ot->srna, "compress", false, "Compress", "Write compressed .blend file");
RNA_def_boolean(ot->srna,
"relative_remap",
@@ -3190,8 +3190,13 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
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);
+ /* By default, the space between icon and text/buttons will be equal to the 'columnspace',
+ this extra padding will add some space by increasing the left column width,
+ making the icon placement more symmetrical, between the block edge and the text. */
+ const float icon_padding = 6.0f * U.dpi_fac;
/* Calculate icon column factor. */
- const float split_factor = (float)icon_size / (float)(dialog_width - style->columnspace);
+ const float split_factor = ((float)icon_size + icon_padding) /
+ (float)(dialog_width - style->columnspace);
uiBlock *block = UI_block_begin(C, region, close_file_dialog_name, UI_EMBOSS);
@@ -3207,8 +3212,10 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
uiLayout *split_block = uiLayoutSplit(block_layout, split_factor, false);
/* Alert Icon. */
- uiLayout *layout = uiLayoutColumn(split_block, false);
- uiDefButAlert(block, ALERT_ICON_QUESTION, 0, 0, 0, icon_size);
+ uiLayout *layout = uiLayoutRow(split_block, false);
+ /* Using 'align_left' with 'row' avoids stretching the icon along the width of column. */
+ uiLayoutSetAlignment(layout, UI_LAYOUT_ALIGN_LEFT);
+ uiDefButAlert(block, ALERT_ICON_QUESTION, 0, 0, icon_size, icon_size);
/* The rest of the content on the right. */
layout = uiLayoutColumn(split_block, false);
@@ -3221,10 +3228,9 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
char filename[FILE_MAX];
if (blendfile_pathpath[0] != '\0') {
BLI_split_file_part(blendfile_pathpath, filename, sizeof(filename));
- BLI_path_extension_replace(filename, sizeof(filename), "");
}
else {
- STRNCPY(filename, IFACE_("Untitled"));
+ STRNCPY(filename, IFACE_("untitled.blend"));
}
uiItemL(layout, filename, ICON_NONE);
@@ -3236,7 +3242,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
LISTBASE_FOREACH (Report *, report, &reports.list) {
uiLayout *row = uiLayoutColumn(layout, false);
uiLayoutSetScaleY(row, 0.6f);
- uiItemS_ex(row, 1.2f);
+ uiItemS(row);
/* Error messages created in ED_image_save_all_modified_info() can be long,
* but are made to separate into two parts at first colon between text and paths.
@@ -3259,12 +3265,8 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
/* Modified Images Checkbox. */
if (modified_images_count > 0) {
char message[64];
- BLI_snprintf(message,
- sizeof(message),
- (modified_images_count == 1) ? "Save %u modified image" :
- "Save %u modified images",
- modified_images_count);
- uiItemS_ex(layout, 2.0f);
+ BLI_snprintf(message, sizeof(message), "Save %u modified image(s)", modified_images_count);
+ uiItemS(layout);
uiDefButBitC(block,
UI_BTYPE_CHECKBOX,
1,
@@ -3284,7 +3286,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
BKE_reports_clear(&reports);
- uiItemS_ex(layout, 1.0f);
+ uiItemS_ex(layout, modified_images_count > 0 ? 2.0f : 4.0f);
/* Buttons. */
#ifdef _WIN32
@@ -3296,13 +3298,10 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
if (windows_layout) {
/* Windows standard layout. */
- uiLayout *split = uiLayoutSplit(block_layout, 0.174f, true);
+ uiLayout *split = uiLayoutSplit(layout, 0.0f, true);
uiLayoutSetScaleY(split, 1.2f);
uiLayoutColumn(split, false);
- uiItemS(layout);
-
- uiLayoutColumn(split, false);
wm_block_file_close_save_button(block, post_action);
uiLayoutColumn(split, false);
@@ -3314,21 +3313,16 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
else {
/* Non-Windows layout (macOS and Linux). */
- uiLayout *split = uiLayoutSplit(block_layout, 0.167f, true);
+ uiLayout *split = uiLayoutSplit(layout, 0.3f, true);
uiLayoutSetScaleY(split, 1.2f);
- layout = uiLayoutColumn(split, false);
- uiItemS(layout);
-
- /* Split button area into two sections: 40/60. */
- uiLayout *split_left = uiLayoutSplit(split, 0.40f, true);
-
- /* First button uses 75% of left side (30% of original). */
- uiLayoutSplit(split_left, 0.75f, true);
+ uiLayoutColumn(split, false);
wm_block_file_close_discard_button(block, post_action);
- /* The right side is split 50/50 (each 30% of original). */
- uiLayout *split_right = uiLayoutSplit(split_left, 0.50f, true);
+ uiLayout *split_right = uiLayoutSplit(split, 0.1f, true);
+
+ uiLayoutColumn(split_right, false);
+ /* Empty space. */
uiLayoutColumn(split_right, false);
wm_block_file_close_cancel_button(block, post_action);
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index cfbc037d19c..49ac250d9a3 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -598,7 +598,7 @@ void WM_OT_link(wmOperatorType *ot)
WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME |
WM_FILESEL_RELPATH | WM_FILESEL_FILES | WM_FILESEL_SHOW_PROPS,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
wm_link_append_properties_common(ot, true);
}
@@ -622,7 +622,7 @@ void WM_OT_append(wmOperatorType *ot)
WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME |
WM_FILESEL_FILES | WM_FILESEL_SHOW_PROPS,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
wm_link_append_properties_common(ot, false);
RNA_def_boolean(ot->srna,
@@ -1172,7 +1172,7 @@ void WM_OT_lib_relocate(wmOperatorType *ot)
WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME |
WM_FILESEL_FILES | WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
static int wm_lib_reload_exec(bContext *C, wmOperator *op)
@@ -1202,7 +1202,7 @@ void WM_OT_lib_reload(wmOperatorType *ot)
WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME |
WM_FILESEL_RELPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA);
+ FILE_SORT_DEFAULT);
}
/** \} */
diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c
index edf9a3bc693..07d68293714 100644
--- a/source/blender/windowmanager/intern/wm_gesture_ops.c
+++ b/source/blender/windowmanager/intern/wm_gesture_ops.c
@@ -818,7 +818,7 @@ void WM_OT_lasso_gesture(wmOperatorType *ot)
ot->poll = WM_operator_winactive;
prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
+ RNA_def_property_struct_runtime(ot->srna, prop, &RNA_OperatorMousePath);
}
#endif
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index ac9d3848f3a..926e61f4a0e 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -72,15 +72,16 @@
#include "BKE_addon.h"
#include "BKE_appdir.h"
-#include "BKE_mask.h" /* free mask clipboard */
-#include "BKE_material.h" /* BKE_material_copybuf_clear */
-#include "BKE_sequencer.h" /* free seq clipboard */
+#include "BKE_mask.h" /* free mask clipboard */
+#include "BKE_material.h" /* BKE_material_copybuf_clear */
#include "BKE_studiolight.h"
#include "BKE_tracking.h" /* free tracking clipboard */
#include "RE_engine.h"
#include "RE_pipeline.h" /* RE_ free stuff */
+#include "SEQ_sequencer.h" /* free seq clipboard */
+
#include "IMB_thumbs.h"
#ifdef WITH_PYTHON
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 361b3ed3d7f..a1140c01d44 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -35,7 +35,8 @@
#include "BKE_context.h"
#include "BKE_global.h"
-#include "BKE_sequencer.h"
+
+#include "SEQ_sequencer.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -226,7 +227,7 @@ bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
/* job can be running or about to run (suspended) */
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
if (wm_job->owner == owner) {
- if (job_type == WM_JOB_TYPE_ANY || (wm_job->job_type == job_type)) {
+ if (ELEM(job_type, WM_JOB_TYPE_ANY, wm_job->job_type)) {
if (wm_job->running || wm_job->suspended) {
return true;
}
@@ -250,7 +251,7 @@ float WM_jobs_progress(wmWindowManager *wm, void *owner)
static void wm_jobs_update_progress_bars(wmWindowManager *wm)
{
- float total_progress = 0.f;
+ float total_progress = 0.0f;
float jobs_progress = 0;
LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
@@ -586,7 +587,7 @@ void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type)
next_job = wm_job->next;
if (!owner || wm_job->owner == owner) {
- if (job_type == WM_JOB_TYPE_ANY || wm_job->job_type == job_type) {
+ if (ELEM(job_type, WM_JOB_TYPE_ANY, wm_job->job_type)) {
wm_jobs_kill_job(wm, wm_job);
}
}
diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c
index 62294d70306..631a4d23eb5 100644
--- a/source/blender/windowmanager/intern/wm_operator_props.c
+++ b/source/blender/windowmanager/intern/wm_operator_props.c
@@ -48,6 +48,30 @@ void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
+/**
+ * Extends rna_enum_fileselect_params_sort_items with a default item for operators to use.
+ */
+static const EnumPropertyItem *wm_operator_properties_filesel_sort_items_itemf(
+ struct bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
+{
+ EnumPropertyItem *items;
+ const EnumPropertyItem default_item = {
+ FILE_SORT_DEFAULT,
+ "DEFAULT",
+ 0,
+ "Default",
+ "Automatically determine sort method for files",
+ };
+ int totitem = 0;
+
+ RNA_enum_item_add(&items, &totitem, &default_item);
+ RNA_enum_items_add(&items, &totitem, rna_enum_fileselect_params_sort_items);
+ RNA_enum_item_end(&items, &totitem);
+ *r_free = true;
+
+ return items;
+}
+
/* default properties for fileselect */
void WM_operator_properties_filesel(wmOperatorType *ot,
int filter,
@@ -204,8 +228,8 @@ void WM_operator_properties_filesel(wmOperatorType *ot,
prop = RNA_def_enum(ot->srna, "display_type", file_display_items, display, "Display Type", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
- prop = RNA_def_enum(
- ot->srna, "sort_method", rna_enum_file_sort_items, sort, "File sorting mode", "");
+ prop = RNA_def_enum(ot->srna, "sort_method", DummyRNA_NULL_items, sort, "File sorting mode", "");
+ RNA_def_enum_funcs(prop, wm_operator_properties_filesel_sort_items_itemf);
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
@@ -260,12 +284,12 @@ void WM_operator_properties_select_random(wmOperatorType *ot)
{
RNA_def_float_percentage(ot->srna,
"percent",
- 50.f,
+ 50.0f,
0.0f,
100.0f,
"Percent",
"Percentage of objects to select randomly",
- 0.f,
+ 0.0f,
100.0f);
RNA_def_int(ot->srna,
"seed",
diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c
index cde0cb77678..7621862708e 100644
--- a/source/blender/windowmanager/intern/wm_operator_type.c
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@ -95,6 +95,7 @@ void WM_operatortype_iter(GHashIterator *ghi)
BLI_ghashIterator_init(ghi, global_ops_hash);
}
+/* -------------------------------------------------------------------- */
/** \name Operator Type Append
* \{ */
@@ -324,13 +325,11 @@ static int wm_macro_end(wmOperator *op, int retval)
/* macro exec only runs exec calls */
static int wm_macro_exec(bContext *C, wmOperator *op)
{
- wmOperator *opm;
int retval = OPERATOR_FINISHED;
wm_macro_start(op);
- for (opm = op->macro.first; opm; opm = opm->next) {
-
+ LISTBASE_FOREACH (wmOperator *, opm, &op->macro) {
if (opm->type->exec) {
retval = opm->type->exec(C, opm);
OPERATOR_RETVAL_CHECK(retval);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 613de5a9b17..9eedd5b2faa 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1810,7 +1810,7 @@ static void WM_OT_call_menu(wmOperatorType *ot)
{
ot->name = "Call Menu";
ot->idname = "WM_OT_call_menu";
- ot->description = "Call (draw) a pre-defined menu";
+ ot->description = "Call (draw) a predefined menu";
ot->exec = wm_call_menu_exec;
ot->poll = WM_operator_winactive;
@@ -1841,7 +1841,7 @@ static void WM_OT_call_menu_pie(wmOperatorType *ot)
{
ot->name = "Call Pie Menu";
ot->idname = "WM_OT_call_menu_pie";
- ot->description = "Call (draw) a pre-defined pie menu";
+ ot->description = "Call (draw) a predefined pie menu";
ot->invoke = wm_call_pie_menu_invoke;
ot->exec = wm_call_pie_menu_exec;
@@ -1875,7 +1875,7 @@ static void WM_OT_call_panel(wmOperatorType *ot)
{
ot->name = "Call Panel";
ot->idname = "WM_OT_call_panel";
- ot->description = "Call (draw) a pre-defined panel";
+ ot->description = "Call (draw) a predefined panel";
ot->exec = wm_call_panel_exec;
ot->poll = WM_operator_winactive;
@@ -2886,7 +2886,7 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
case PROP_FACTOR:
new_value = (WM_RADIAL_CONTROL_DISPLAY_SIZE - dist) / WM_RADIAL_CONTROL_DISPLAY_WIDTH;
if (snap) {
- new_value = ((int)ceil(new_value * 10.f) * 10.0f) / 100.f;
+ new_value = ((int)ceil(new_value * 10.0f) * 10.0f) / 100.0f;
}
/* Invert new value to increase the factor moving the mouse to the right */
new_value = 1 - new_value;
@@ -3771,7 +3771,7 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_CIRCLE_SIZE, "SIZE", 0, "Size", ""},
{GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""},
- {GESTURE_MODAL_DESELECT, "DESELECT", 0, "DeSelect", ""},
+ {GESTURE_MODAL_DESELECT, "DESELECT", 0, "Deselect", ""},
{GESTURE_MODAL_NOP, "NOP", 0, "No Operation", ""},
{0, NULL, 0, NULL, NULL},
@@ -3834,7 +3834,7 @@ static void gesture_box_modal_keymap(wmKeyConfig *keyconf)
static const EnumPropertyItem modal_items[] = {
{GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
{GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""},
- {GESTURE_MODAL_DESELECT, "DESELECT", 0, "DeSelect", ""},
+ {GESTURE_MODAL_DESELECT, "DESELECT", 0, "Deselect", ""},
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
{GESTURE_MODAL_MOVE, "MOVE", 0, "Move", ""},
{0, NULL, 0, NULL, NULL},
@@ -3968,39 +3968,40 @@ void wm_window_keymap(wmKeyConfig *keyconf)
*
* \{ */
-static bool rna_id_enum_filter_single(ID *id, void *user_data)
+static bool rna_id_enum_filter_single(const ID *id, void *user_data)
{
return (id != user_data);
}
/* Generic itemf's for operators that take library args */
-static const EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C),
- PointerRNA *UNUSED(ptr),
- bool *r_free,
+static const EnumPropertyItem *rna_id_itemf(bool *r_free,
ID *id,
bool local,
- bool (*filter_ids)(ID *id, void *user_data),
+ bool (*filter_ids)(const ID *id, void *user_data),
void *user_data)
{
EnumPropertyItem item_tmp = {0}, *item = NULL;
int totitem = 0;
int i = 0;
- for (; id; id = id->next) {
- if ((filter_ids != NULL) && filter_ids(user_data, id) == false) {
- i++;
- continue;
- }
- if (local == false || !ID_IS_LINKED(id)) {
- item_tmp.identifier = item_tmp.name = id->name + 2;
- item_tmp.value = i++;
-
- /* Show collection color tag icons in menus. */
- if (GS(id->name) == ID_GR) {
- item_tmp.icon = UI_icon_color_from_collection((Collection *)id);
+ if (id != NULL) {
+ const short id_type = GS(id->name);
+ for (; id; id = id->next) {
+ if ((filter_ids != NULL) && filter_ids(id, user_data) == false) {
+ i++;
+ continue;
}
+ if (local == false || !ID_IS_LINKED(id)) {
+ item_tmp.identifier = item_tmp.name = id->name + 2;
+ item_tmp.value = i++;
- RNA_enum_item_add(&item, &totitem, &item_tmp);
+ /* Show collection color tag icons in menus. */
+ if (id_type == ID_GR) {
+ item_tmp.icon = UI_icon_color_from_collection((Collection *)id);
+ }
+
+ RNA_enum_item_add(&item, &totitem, &item_tmp);
+ }
}
}
@@ -4012,119 +4013,111 @@ static const EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C),
/* can add more as needed */
const EnumPropertyItem *RNA_action_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
- return rna_id_itemf(
- C, ptr, r_free, C ? (ID *)CTX_data_main(C)->actions.first : NULL, false, NULL, NULL);
+
+ return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->actions.first : NULL, false, NULL, NULL);
}
#if 0 /* UNUSED */
const EnumPropertyItem *RNA_action_local_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
- return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, true);
+ return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, true);
}
#endif
const EnumPropertyItem *RNA_collection_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
return rna_id_itemf(
- C, ptr, r_free, C ? (ID *)CTX_data_main(C)->collections.first : NULL, false, NULL, NULL);
+ r_free, C ? (ID *)CTX_data_main(C)->collections.first : NULL, false, NULL, NULL);
}
const EnumPropertyItem *RNA_collection_local_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
return rna_id_itemf(
- C, ptr, r_free, C ? (ID *)CTX_data_main(C)->collections.first : NULL, true, NULL, NULL);
+ r_free, C ? (ID *)CTX_data_main(C)->collections.first : NULL, true, NULL, NULL);
}
const EnumPropertyItem *RNA_image_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
- return rna_id_itemf(
- C, ptr, r_free, C ? (ID *)CTX_data_main(C)->images.first : NULL, false, NULL, NULL);
+ return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->images.first : NULL, false, NULL, NULL);
}
const EnumPropertyItem *RNA_image_local_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
- return rna_id_itemf(
- C, ptr, r_free, C ? (ID *)CTX_data_main(C)->images.first : NULL, true, NULL, NULL);
+ return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->images.first : NULL, true, NULL, NULL);
}
const EnumPropertyItem *RNA_scene_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
- return rna_id_itemf(
- C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scenes.first : NULL, false, NULL, NULL);
+ return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->scenes.first : NULL, false, NULL, NULL);
}
const EnumPropertyItem *RNA_scene_local_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
- return rna_id_itemf(
- C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scenes.first : NULL, true, NULL, NULL);
+ return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->scenes.first : NULL, true, NULL, NULL);
}
const EnumPropertyItem *RNA_scene_without_active_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
Scene *scene_active = C ? CTX_data_scene(C) : NULL;
- return rna_id_itemf(C,
- ptr,
- r_free,
+ return rna_id_itemf(r_free,
C ? (ID *)CTX_data_main(C)->scenes.first : NULL,
false,
rna_id_enum_filter_single,
scene_active);
}
const EnumPropertyItem *RNA_movieclip_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
return rna_id_itemf(
- C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclips.first : NULL, false, NULL, NULL);
+ r_free, C ? (ID *)CTX_data_main(C)->movieclips.first : NULL, false, NULL, NULL);
}
const EnumPropertyItem *RNA_movieclip_local_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
return rna_id_itemf(
- C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclips.first : NULL, true, NULL, NULL);
+ r_free, C ? (ID *)CTX_data_main(C)->movieclips.first : NULL, true, NULL, NULL);
}
const EnumPropertyItem *RNA_mask_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
- return rna_id_itemf(
- C, ptr, r_free, C ? (ID *)CTX_data_main(C)->masks.first : NULL, false, NULL, NULL);
+ return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->masks.first : NULL, false, NULL, NULL);
}
const EnumPropertyItem *RNA_mask_local_itemf(bContext *C,
- PointerRNA *ptr,
+ PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
- return rna_id_itemf(
- C, ptr, r_free, C ? (ID *)CTX_data_main(C)->masks.first : NULL, true, NULL, NULL);
+ return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->masks.first : NULL, true, NULL, NULL);
}
/** \} */
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 5d1607fe506..60bcb687dbf 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -1274,7 +1274,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
g_WS.ghost_system = GHOST_CreateSystem();
GHOST_AddEventConsumer(g_WS.ghost_system, consumer);
- playanim_window_open("Blender:Anim", start_x, start_y, ibuf->x, ibuf->y);
+ playanim_window_open("Blender Animation Player", start_x, start_y, ibuf->x, ibuf->y);
}
GHOST_GetMainDisplayDimensions(g_WS.ghost_system, &maxwinx, &maxwiny);
@@ -1391,7 +1391,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
while (ps.picture) {
int hasevent;
#ifndef USE_IMB_CACHE
- if (ibuf != NULL && ibuf->ftype == 0) {
+ if (ibuf != NULL && ibuf->ftype == IMB_FTYPE_NONE) {
IMB_freeImBuf(ibuf);
}
#endif
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 6c9b6915da8..589b8e2f156 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -1767,7 +1767,7 @@ static char *wm_clipboard_text_get_ex(bool selection, int *r_len, bool firstline
if (firstline) {
/* will return an over-alloc'ed value in the case there are newlines */
for (char *p = buf; *p; p++) {
- if ((*p != '\n') && (*p != '\r')) {
+ if (!ELEM(*p, '\n', '\r')) {
*(p2++) = *p;
}
else {
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 74c2797856d..b48f4bdd4b9 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -31,7 +31,7 @@ blender_include_dirs(
../blender/editors/include
../blender/imbuf
../blender/makesrna
- ../blender/render/extern/include
+ ../blender/render
../blender/gpu
../blender/makesdna
../blender/windowmanager
@@ -152,32 +152,47 @@ if(WITH_BUILDINFO)
add_definitions(-DWITH_BUILDINFO)
# --------------------------------------------------------------------------
# These defines could all be moved into the header below
- string(REPLACE " " "\ " BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}")
- string(REPLACE " " "\ " BUILDINFO_CXXFLAGS "${CMAKE_CXX_FLAGS}")
- string(REPLACE " " "\ " BUILDINFO_LINKFLAGS "${PLATFORM_LINKFLAGS}")
- add_definitions(
- # # define in header now, else these get out of date on rebuilds.
- # -DBUILD_DATE="${BUILD_DATE}"
- # -DBUILD_TIME="${BUILD_TIME}"
- # -DBUILD_COMMIT_TIMESTAMP="${BUILD_COMMIT_TIMESTAMP}"
- # -DBUILD_COMMIT_TIME="${BUILD_COMMIT_TIME}"
- # -DBUILD_COMMIT_DATE="${BUILD_COMMIT_DATE}"
- # -DBUILD_HASH="${BUILD_HASH}"
- # -DBUILD_BRANCH="${BUILD_BRANCH}"
- -DWITH_BUILDINFO_HEADER # alternative to lines above
- -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
- -DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
- -DBUILD_CFLAGS="${BUILDINFO_CFLAGS}"
- -DBUILD_CXXFLAGS="${BUILDINFO_CXXFLAGS}"
- -DBUILD_LINKFLAGS="${BUILDINFO_LINKFLAGS}"
- -DBUILD_SYSTEM="CMake"
+
+ # Write strings into a separate header since we can escape C-strings
+ # in a way that's not practical when passing defines.
+ set(BUILD_PLATFORM "${CMAKE_SYSTEM_NAME}")
+ set(BUILD_TYPE "${CMAKE_BUILD_TYPE}")
+ set(BUILD_CFLAGS "${CMAKE_C_FLAGS}")
+ set(BUILD_CXXFLAGS "${CMAKE_CXX_FLAGS}")
+ set(BUILD_LINKFLAGS "${PLATFORM_LINKFLAGS}")
+ set(BUILD_SYSTEM "CMake")
+
+ if(WITH_COMPILER_SHORT_FILE_MACRO)
+ # It's not necessary to include path information
+ # about the system building Blender in the executable.
+ string(REPLACE "${PLATFORM_CFLAGS_FMACRO_PREFIX_MAP}" " " BUILD_CFLAGS "${BUILD_CFLAGS}")
+ string(REPLACE "${PLATFORM_CFLAGS_FMACRO_PREFIX_MAP}" " " BUILD_CXXFLAGS "${BUILD_CXXFLAGS}")
+ endif()
+
+ # Use `configure_file` instead of definitions since properly
+ # escaping the multiple command line arguments which themselves
+ # contain strings and spaces becomes overly error-prone & complicated.
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/build_files/cmake/buildinfo_static.h.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/buildinfo_static.h"
+ ESCAPE_QUOTES
+ @ONLY
)
+ unset(BUILD_PLATFORM)
+ unset(BUILD_TYPE)
+ unset(BUILD_CFLAGS)
+ unset(BUILD_CXXFLAGS)
+ unset(BUILD_LINKFLAGS)
+ unset(BUILD_SYSTEM)
+
# --------------------------------------------------------------------------
# write header for values that change each build
# note, generaed file is in build dir's source/creator
# except when used as an include path.
+ add_definitions(-DWITH_BUILDINFO_HEADER)
+
# include the output directory, where the buildinfo.h file is generated
include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 65610ea9b70..fbc97028d35 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -72,7 +72,7 @@
#include "IMB_imbuf.h" /* For #IMB_init. */
#include "RE_engine.h"
-#include "RE_render_ext.h"
+#include "RE_texture.h"
#include "ED_datafiles.h"
@@ -163,7 +163,7 @@ static void callback_main_atexit(void *user_data)
struct CreatorAtExitData *app_init_data = user_data;
if (app_init_data->ba) {
- BLI_argsFree(app_init_data->ba);
+ BLI_args_destroy(app_init_data->ba);
app_init_data->ba = NULL;
}
@@ -293,7 +293,7 @@ int main(int argc,
MEM_use_guarded_allocator();
break;
}
- else if (STREQ(argv[i], "--")) {
+ if (STREQ(argv[i], "--")) {
break;
}
}
@@ -349,7 +349,7 @@ int main(int argc,
#if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE) && !defined(WITH_HEADLESS)
/* Patch to ignore argument finder gives us (PID?) */
- if (argc == 2 && STREQLEN(argv[1], "-psn_", 5)) {
+ if (argc == 2 && STRPREFIX(argv[1], "-psn_")) {
extern int GHOST_HACK_getFirstFile(char buf[]);
static char firstfilebuf[512];
@@ -392,7 +392,7 @@ int main(int argc,
/* First test for background-mode (#Global.background) */
#ifndef WITH_PYTHON_MODULE
- ba = BLI_argsInit(argc, (const char **)argv); /* skip binary path */
+ ba = BLI_args_create(argc, (const char **)argv); /* skip binary path */
/* Ensure we free on early exit. */
app_init_data.ba = ba;
@@ -403,35 +403,42 @@ int main(int argc,
* (such as '--version' & '--help') don't report leaks. */
MEM_use_memleak_detection(false);
- BLI_argsParse(ba, 1, NULL, NULL);
-
- main_signal_setup();
+ /* Parse environment handling arguments. */
+ BLI_args_parse(ba, ARG_PASS_ENVIRONMENT, NULL, NULL);
#else
/* Using preferences or user startup makes no sense for #WITH_PYTHON_MODULE. */
G.factory_startup = true;
#endif
- /* After parsing the first level of arguments as `--env-*` impact BKE_appdir behavior. */
+ /* After parsing #ARG_PASS_ENVIRONMENT such as `--env-*`,
+ * since they impact `BKE_appdir` behavior. */
BKE_appdir_init();
/* After parsing number of threads argument. */
BLI_task_scheduler_init();
- /* After parsing `--env-system-datafiles` which control where paths are searched
- * (color-management) uses BKE_appdir to initialize. */
+ /* Initialize sub-systems that use `BKE_appdir.h`. */
IMB_init();
+#ifndef WITH_PYTHON_MODULE
+ /* First test for background-mode (#Global.background) */
+ BLI_args_parse(ba, ARG_PASS_SETTINGS, NULL, NULL);
+
+ main_signal_setup();
+#endif
+
#ifdef WITH_FFMPEG
+ /* Keep after #ARG_PASS_SETTINGS since debug flags are checked. */
IMB_ffmpeg_init();
#endif
- /* After level 1 arguments, this is so #WM_main_playanim skips #RNA_init. */
+ /* After #ARG_PASS_SETTINGS arguments, this is so #WM_main_playanim skips #RNA_init. */
RNA_init();
RE_engines_init();
- init_nodesystem();
- psys_init_rng();
+ BKE_node_system_init();
+ BKE_particle_init_rng();
/* End second initialization. */
#if defined(WITH_PYTHON_MODULE) || defined(WITH_HEADLESS)
@@ -452,20 +459,15 @@ int main(int argc,
BKE_materials_init();
- if (G.background == 0) {
#ifndef WITH_PYTHON_MODULE
- BLI_argsParse(ba, 2, NULL, NULL);
- BLI_argsParse(ba, 3, NULL, NULL);
-#endif
- WM_init(C, argc, (const char **)argv);
+ if (G.background == 0) {
+ BLI_args_parse(ba, ARG_PASS_SETTINGS_GUI, NULL, NULL);
}
- else {
-#ifndef WITH_PYTHON_MODULE
- BLI_argsParse(ba, 3, NULL, NULL);
+ BLI_args_parse(ba, ARG_PASS_SETTINGS_FORCE, NULL, NULL);
#endif
- WM_init(C, argc, (const char **)argv);
- }
+ WM_init(C, argc, (const char **)argv);
+
#ifndef WITH_PYTHON
printf(
"\n* WARNING * - Blender compiled without Python!\n"
@@ -483,6 +485,7 @@ int main(int argc,
/* OK we are ready for it */
#ifndef WITH_PYTHON_MODULE
+ /* Handles #ARG_PASS_FINAL. */
main_args_setup_post(C, ba);
#endif
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 3b54811657d..c6a1c565350 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -48,7 +48,6 @@
# include "BKE_blender_version.h"
# include "BKE_context.h"
-# include "BKE_appdir.h"
# include "BKE_global.h"
# include "BKE_image.h"
# include "BKE_lib_id.h"
@@ -57,7 +56,9 @@
# include "BKE_scene.h"
# include "BKE_sound.h"
-# include "IMB_imbuf.h"
+# ifdef WITH_FFMPEG
+# include "IMB_imbuf.h"
+# endif
# ifdef WITH_PYTHON
# include "BPY_extern_python.h"
@@ -118,15 +119,13 @@ static bool parse_int_relative(const char *str,
*r_err_msg = msg;
return false;
}
- else if ((errno == ERANGE) || ((value < INT_MIN || value > INT_MAX))) {
+ if ((errno == ERANGE) || ((value < INT_MIN || value > INT_MAX))) {
static const char *msg = "exceeds range";
*r_err_msg = msg;
return false;
}
- else {
- *r_value = (int)value;
- return true;
- }
+ *r_value = (int)value;
+ return true;
}
static const char *parse_int_range_sep_search(const char *str, const char *str_end_test)
@@ -165,9 +164,7 @@ static bool parse_int_range_relative(const char *str,
str_end_range + 2, str_end_test, pos, neg, &r_value_range[1], r_err_msg)) {
return true;
}
- else {
- return false;
- }
+ return false;
}
static bool parse_int_relative_clamp(const char *str,
@@ -183,9 +180,7 @@ static bool parse_int_relative_clamp(const char *str,
CLAMP(*r_value, min, max);
return true;
}
- else {
- return false;
- }
+ return false;
}
static bool parse_int_range_relative_clamp(const char *str,
@@ -204,9 +199,7 @@ static bool parse_int_range_relative_clamp(const char *str,
CLAMP(r_value_range[1], min, max);
return true;
}
- else {
- return false;
- }
+ return false;
}
/**
@@ -230,15 +223,13 @@ static bool parse_int_strict_range(const char *str,
*r_err_msg = msg;
return false;
}
- else if ((errno == ERANGE) || ((value < min || value > max))) {
+ if ((errno == ERANGE) || ((value < min || value > max))) {
static const char *msg = "exceeds range";
*r_err_msg = msg;
return false;
}
- else {
- *r_value = (int)value;
- return true;
- }
+ *r_value = (int)value;
+ return true;
}
static bool parse_int(const char *str,
@@ -260,9 +251,7 @@ static bool parse_int_clamp(const char *str,
CLAMP(*r_value, min, max);
return true;
}
- else {
- return false;
- }
+ return false;
}
# if 0
@@ -342,7 +331,7 @@ static int (*parse_int_range_relative_clamp_n(const char *str,
while (true) {
const char *str_end_range;
const char *str_end = strchr(str, sep);
- if ((*str == sep) || (*str == '\0')) {
+ if (ELEM(*str, sep, '\0')) {
static const char *msg = "incorrect comma use";
*r_err_msg = msg;
goto fail;
@@ -516,128 +505,128 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
printf("Usage: blender [args ...] [file] [args ...]\n\n");
printf("Render Options:\n");
- BLI_argsPrintArgDoc(ba, "--background");
- BLI_argsPrintArgDoc(ba, "--render-anim");
- BLI_argsPrintArgDoc(ba, "--scene");
- BLI_argsPrintArgDoc(ba, "--render-frame");
- BLI_argsPrintArgDoc(ba, "--frame-start");
- BLI_argsPrintArgDoc(ba, "--frame-end");
- BLI_argsPrintArgDoc(ba, "--frame-jump");
- BLI_argsPrintArgDoc(ba, "--render-output");
- BLI_argsPrintArgDoc(ba, "--engine");
- BLI_argsPrintArgDoc(ba, "--threads");
+ BLI_args_print_arg_doc(ba, "--background");
+ BLI_args_print_arg_doc(ba, "--render-anim");
+ BLI_args_print_arg_doc(ba, "--scene");
+ BLI_args_print_arg_doc(ba, "--render-frame");
+ BLI_args_print_arg_doc(ba, "--frame-start");
+ BLI_args_print_arg_doc(ba, "--frame-end");
+ BLI_args_print_arg_doc(ba, "--frame-jump");
+ BLI_args_print_arg_doc(ba, "--render-output");
+ BLI_args_print_arg_doc(ba, "--engine");
+ BLI_args_print_arg_doc(ba, "--threads");
printf("\n");
printf("Format Options:\n");
- BLI_argsPrintArgDoc(ba, "--render-format");
- BLI_argsPrintArgDoc(ba, "--use-extension");
+ BLI_args_print_arg_doc(ba, "--render-format");
+ BLI_args_print_arg_doc(ba, "--use-extension");
printf("\n");
printf("Animation Playback Options:\n");
- BLI_argsPrintArgDoc(ba, "-a");
+ BLI_args_print_arg_doc(ba, "-a");
printf("\n");
printf("Window Options:\n");
- BLI_argsPrintArgDoc(ba, "--window-border");
- BLI_argsPrintArgDoc(ba, "--window-fullscreen");
- BLI_argsPrintArgDoc(ba, "--window-geometry");
- BLI_argsPrintArgDoc(ba, "--window-maximized");
- BLI_argsPrintArgDoc(ba, "--start-console");
- BLI_argsPrintArgDoc(ba, "--no-native-pixels");
- BLI_argsPrintArgDoc(ba, "--no-window-focus");
+ BLI_args_print_arg_doc(ba, "--window-border");
+ BLI_args_print_arg_doc(ba, "--window-fullscreen");
+ BLI_args_print_arg_doc(ba, "--window-geometry");
+ BLI_args_print_arg_doc(ba, "--window-maximized");
+ BLI_args_print_arg_doc(ba, "--start-console");
+ BLI_args_print_arg_doc(ba, "--no-native-pixels");
+ BLI_args_print_arg_doc(ba, "--no-window-focus");
printf("\n");
printf("Python Options:\n");
- BLI_argsPrintArgDoc(ba, "--enable-autoexec");
- BLI_argsPrintArgDoc(ba, "--disable-autoexec");
+ BLI_args_print_arg_doc(ba, "--enable-autoexec");
+ BLI_args_print_arg_doc(ba, "--disable-autoexec");
printf("\n");
- BLI_argsPrintArgDoc(ba, "--python");
- BLI_argsPrintArgDoc(ba, "--python-text");
- BLI_argsPrintArgDoc(ba, "--python-expr");
- BLI_argsPrintArgDoc(ba, "--python-console");
- BLI_argsPrintArgDoc(ba, "--python-exit-code");
- BLI_argsPrintArgDoc(ba, "--python-use-system-env");
- BLI_argsPrintArgDoc(ba, "--addons");
+ BLI_args_print_arg_doc(ba, "--python");
+ BLI_args_print_arg_doc(ba, "--python-text");
+ BLI_args_print_arg_doc(ba, "--python-expr");
+ BLI_args_print_arg_doc(ba, "--python-console");
+ BLI_args_print_arg_doc(ba, "--python-exit-code");
+ BLI_args_print_arg_doc(ba, "--python-use-system-env");
+ BLI_args_print_arg_doc(ba, "--addons");
printf("\n");
printf("Logging Options:\n");
- BLI_argsPrintArgDoc(ba, "--log");
- BLI_argsPrintArgDoc(ba, "--log-level");
- BLI_argsPrintArgDoc(ba, "--log-show-basename");
- BLI_argsPrintArgDoc(ba, "--log-show-backtrace");
- BLI_argsPrintArgDoc(ba, "--log-show-timestamp");
- BLI_argsPrintArgDoc(ba, "--log-file");
+ BLI_args_print_arg_doc(ba, "--log");
+ BLI_args_print_arg_doc(ba, "--log-level");
+ BLI_args_print_arg_doc(ba, "--log-show-basename");
+ BLI_args_print_arg_doc(ba, "--log-show-backtrace");
+ BLI_args_print_arg_doc(ba, "--log-show-timestamp");
+ BLI_args_print_arg_doc(ba, "--log-file");
printf("\n");
printf("Debug Options:\n");
- BLI_argsPrintArgDoc(ba, "--debug");
- BLI_argsPrintArgDoc(ba, "--debug-value");
+ BLI_args_print_arg_doc(ba, "--debug");
+ BLI_args_print_arg_doc(ba, "--debug-value");
printf("\n");
- BLI_argsPrintArgDoc(ba, "--debug-events");
+ BLI_args_print_arg_doc(ba, "--debug-events");
# ifdef WITH_FFMPEG
- BLI_argsPrintArgDoc(ba, "--debug-ffmpeg");
+ BLI_args_print_arg_doc(ba, "--debug-ffmpeg");
# endif
- BLI_argsPrintArgDoc(ba, "--debug-handlers");
+ BLI_args_print_arg_doc(ba, "--debug-handlers");
# ifdef WITH_LIBMV
- BLI_argsPrintArgDoc(ba, "--debug-libmv");
+ BLI_args_print_arg_doc(ba, "--debug-libmv");
# endif
# ifdef WITH_CYCLES_LOGGING
- BLI_argsPrintArgDoc(ba, "--debug-cycles");
+ BLI_args_print_arg_doc(ba, "--debug-cycles");
# endif
- BLI_argsPrintArgDoc(ba, "--debug-memory");
- BLI_argsPrintArgDoc(ba, "--debug-jobs");
- BLI_argsPrintArgDoc(ba, "--debug-python");
- BLI_argsPrintArgDoc(ba, "--debug-depsgraph");
- BLI_argsPrintArgDoc(ba, "--debug-depsgraph-eval");
- BLI_argsPrintArgDoc(ba, "--debug-depsgraph-build");
- BLI_argsPrintArgDoc(ba, "--debug-depsgraph-tag");
- BLI_argsPrintArgDoc(ba, "--debug-depsgraph-no-threads");
- BLI_argsPrintArgDoc(ba, "--debug-depsgraph-time");
- BLI_argsPrintArgDoc(ba, "--debug-depsgraph-pretty");
- BLI_argsPrintArgDoc(ba, "--debug-gpu");
- BLI_argsPrintArgDoc(ba, "--debug-gpumem");
- BLI_argsPrintArgDoc(ba, "--debug-gpu-shaders");
- BLI_argsPrintArgDoc(ba, "--debug-gpu-force-workarounds");
- BLI_argsPrintArgDoc(ba, "--debug-wm");
+ BLI_args_print_arg_doc(ba, "--debug-memory");
+ BLI_args_print_arg_doc(ba, "--debug-jobs");
+ BLI_args_print_arg_doc(ba, "--debug-python");
+ BLI_args_print_arg_doc(ba, "--debug-depsgraph");
+ BLI_args_print_arg_doc(ba, "--debug-depsgraph-eval");
+ BLI_args_print_arg_doc(ba, "--debug-depsgraph-build");
+ BLI_args_print_arg_doc(ba, "--debug-depsgraph-tag");
+ BLI_args_print_arg_doc(ba, "--debug-depsgraph-no-threads");
+ BLI_args_print_arg_doc(ba, "--debug-depsgraph-time");
+ BLI_args_print_arg_doc(ba, "--debug-depsgraph-pretty");
+ BLI_args_print_arg_doc(ba, "--debug-gpu");
+ BLI_args_print_arg_doc(ba, "--debug-gpumem");
+ BLI_args_print_arg_doc(ba, "--debug-gpu-shaders");
+ BLI_args_print_arg_doc(ba, "--debug-gpu-force-workarounds");
+ BLI_args_print_arg_doc(ba, "--debug-wm");
# ifdef WITH_XR_OPENXR
- BLI_argsPrintArgDoc(ba, "--debug-xr");
- BLI_argsPrintArgDoc(ba, "--debug-xr-time");
+ BLI_args_print_arg_doc(ba, "--debug-xr");
+ BLI_args_print_arg_doc(ba, "--debug-xr-time");
# endif
- BLI_argsPrintArgDoc(ba, "--debug-all");
- BLI_argsPrintArgDoc(ba, "--debug-io");
+ BLI_args_print_arg_doc(ba, "--debug-all");
+ BLI_args_print_arg_doc(ba, "--debug-io");
printf("\n");
- BLI_argsPrintArgDoc(ba, "--debug-fpe");
- BLI_argsPrintArgDoc(ba, "--disable-crash-handler");
- BLI_argsPrintArgDoc(ba, "--disable-abort-handler");
+ BLI_args_print_arg_doc(ba, "--debug-fpe");
+ BLI_args_print_arg_doc(ba, "--disable-crash-handler");
+ BLI_args_print_arg_doc(ba, "--disable-abort-handler");
printf("\n");
printf("Misc Options:\n");
- BLI_argsPrintArgDoc(ba, "--app-template");
- BLI_argsPrintArgDoc(ba, "--factory-startup");
- BLI_argsPrintArgDoc(ba, "--enable-event-simulate");
+ BLI_args_print_arg_doc(ba, "--app-template");
+ BLI_args_print_arg_doc(ba, "--factory-startup");
+ BLI_args_print_arg_doc(ba, "--enable-event-simulate");
printf("\n");
- BLI_argsPrintArgDoc(ba, "--env-system-datafiles");
- BLI_argsPrintArgDoc(ba, "--env-system-scripts");
- BLI_argsPrintArgDoc(ba, "--env-system-python");
+ BLI_args_print_arg_doc(ba, "--env-system-datafiles");
+ BLI_args_print_arg_doc(ba, "--env-system-scripts");
+ BLI_args_print_arg_doc(ba, "--env-system-python");
printf("\n");
- BLI_argsPrintArgDoc(ba, "-noaudio");
- BLI_argsPrintArgDoc(ba, "-setaudio");
+ BLI_args_print_arg_doc(ba, "-noaudio");
+ BLI_args_print_arg_doc(ba, "-setaudio");
printf("\n");
- BLI_argsPrintArgDoc(ba, "--help");
+ BLI_args_print_arg_doc(ba, "--help");
/* WIN32 only (ignored for non-win32) */
- BLI_argsPrintArgDoc(ba, "-R");
- BLI_argsPrintArgDoc(ba, "-r");
+ BLI_args_print_arg_doc(ba, "-R");
+ BLI_args_print_arg_doc(ba, "-r");
- BLI_argsPrintArgDoc(ba, "--version");
+ BLI_args_print_arg_doc(ba, "--version");
- BLI_argsPrintArgDoc(ba, "--");
+ BLI_args_print_arg_doc(ba, "--");
// printf("\n");
// printf("Experimental Features:\n");
@@ -645,7 +634,7 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
/* Other options _must_ be last (anything not handled will show here) */
printf("\n");
printf("Other Options:\n");
- BLI_argsPrintOtherDoc(ba);
+ BLI_args_print_other_doc(ba);
printf("\n");
printf("Argument Parsing:\n");
@@ -801,10 +790,8 @@ static int arg_handle_log_level_set(int argc, const char **argv, void *UNUSED(da
}
return 1;
}
- else {
- printf("\nError: '%s' no args given.\n", arg_id);
- return 0;
- }
+ printf("\nError: '%s' no args given.\n", arg_id);
+ return 0;
}
static const char arg_handle_log_show_basename_set_doc[] =
@@ -864,10 +851,8 @@ static int arg_handle_log_file_set(int argc, const char **argv, void *UNUSED(dat
}
return 1;
}
- else {
- printf("\nError: '%s' no args given.\n", arg_id);
- return 0;
- }
+ printf("\nError: '%s' no args given.\n", arg_id);
+ return 0;
}
static const char arg_handle_log_set_doc[] =
@@ -907,10 +892,8 @@ static int arg_handle_log_set(int argc, const char **argv, void *UNUSED(data))
}
return 1;
}
- else {
- printf("\nError: '%s' no args given.\n", arg_id);
- return 0;
- }
+ printf("\nError: '%s' no args given.\n", arg_id);
+ return 0;
}
static const char arg_handle_debug_mode_set_doc[] =
@@ -933,7 +916,7 @@ static int arg_handle_debug_mode_set(int UNUSED(argc), const char **UNUSED(argv)
printf("Build: %s %s %s %s\n", build_date, build_time, build_platform, build_type);
# endif
- BLI_argsPrint(data);
+ BLI_args_print(data);
return 0;
}
@@ -1093,10 +1076,8 @@ static int arg_handle_debug_value_set(int argc, const char **argv, void *UNUSED(
return 1;
}
- else {
- printf("\nError: you must specify debug value to set.\n");
- return 0;
- }
+ printf("\nError: you must specify debug value to set.\n");
+ return 0;
}
static const char arg_handle_debug_fpe_set_doc[] =
@@ -1120,10 +1101,8 @@ static int arg_handle_app_template(int argc, const char **argv, void *UNUSED(dat
WM_init_state_app_template_set(app_template);
return 1;
}
- else {
- printf("\nError: App template must follow '--app-template'.\n");
- return 0;
- }
+ printf("\nError: App template must follow '--app-template'.\n");
+ return 0;
}
static const char arg_handle_factory_startup_set_doc[] =
@@ -1204,8 +1183,6 @@ static int arg_handle_playback_mode(int argc, const char **argv, void *UNUSED(da
{
/* not if -b was given first */
if (G.background == 0) {
- BKE_appdir_init();
- IMB_init();
# ifdef WITH_FFMPEG
/* Setup FFmpeg with current debug flags. */
IMB_ffmpeg_init();
@@ -1383,10 +1360,8 @@ static int arg_handle_output_set(int argc, const char **argv, void *data)
}
return 1;
}
- else {
- printf("\nError: you must specify a path after '-o / --render-output'.\n");
- return 0;
- }
+ printf("\nError: you must specify a path after '-o / --render-output'.\n");
+ return 0;
}
static const char arg_handle_engine_set_doc[] =
@@ -1426,10 +1401,8 @@ static int arg_handle_engine_set(int argc, const char **argv, void *data)
return 1;
}
- else {
- printf("\nEngine not specified, give 'help' for a list of available engines.\n");
- return 0;
- }
+ printf("\nEngine not specified, give 'help' for a list of available engines.\n");
+ return 0;
}
static const char arg_handle_image_type_set_doc[] =
@@ -1466,10 +1439,8 @@ static int arg_handle_image_type_set(int argc, const char **argv, void *data)
}
return 1;
}
- else {
- printf("\nError: you must specify a format after '-F / --render-format'.\n");
- return 0;
- }
+ printf("\nError: you must specify a format after '-F / --render-format'.\n");
+ return 0;
}
static const char arg_handle_threads_set_doc[] =
@@ -1496,10 +1467,8 @@ static int arg_handle_threads_set(int argc, const char **argv, void *UNUSED(data
BLI_system_num_threads_override_set(threads);
return 1;
}
- else {
- printf("\nError: you must specify a number of threads in [%d..%d] '%s'.\n", min, max, arg_id);
- return 0;
- }
+ printf("\nError: you must specify a number of threads in [%d..%d] '%s'.\n", min, max, arg_id);
+ return 0;
}
static const char arg_handle_verbosity_set_doc[] =
@@ -1525,10 +1494,8 @@ static int arg_handle_verbosity_set(int argc, const char **argv, void *UNUSED(da
return 1;
}
- else {
- printf("\nError: you must specify a verbosity level.\n");
- return 0;
- }
+ printf("\nError: you must specify a verbosity level.\n");
+ return 0;
}
static const char arg_handle_extension_set_doc[] =
@@ -1559,10 +1526,8 @@ static int arg_handle_extension_set(int argc, const char **argv, void *data)
}
return 1;
}
- else {
- printf("\nError: you must specify a path after '- '.\n");
- return 0;
- }
+ printf("\nError: you must specify a path after '- '.\n");
+ return 0;
}
static const char arg_handle_render_frame_doc[] =
@@ -1617,15 +1582,11 @@ static int arg_handle_render_frame(int argc, const char **argv, void *data)
MEM_freeN(frame_range_arr);
return 1;
}
- else {
- printf("\nError: frame number must follow '%s'.\n", arg_id);
- return 0;
- }
- }
- else {
- printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
+ printf("\nError: frame number must follow '%s'.\n", arg_id);
return 0;
}
+ printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
+ return 0;
}
static const char arg_handle_render_animation_doc[] =
@@ -1674,10 +1635,8 @@ static int arg_handle_scene_set(int argc, const char **argv, void *data)
}
return 1;
}
- else {
- printf("\nError: Scene name must follow '-S / --scene'.\n");
- return 0;
- }
+ printf("\nError: Scene name must follow '-S / --scene'.\n");
+ return 0;
}
static const char arg_handle_frame_start_set_doc[] =
@@ -1706,15 +1665,11 @@ static int arg_handle_frame_start_set(int argc, const char **argv, void *data)
}
return 1;
}
- else {
- printf("\nError: frame number must follow '%s'.\n", arg_id);
- return 0;
- }
- }
- else {
- printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
+ printf("\nError: frame number must follow '%s'.\n", arg_id);
return 0;
}
+ printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
+ return 0;
}
static const char arg_handle_frame_end_set_doc[] =
@@ -1743,15 +1698,11 @@ static int arg_handle_frame_end_set(int argc, const char **argv, void *data)
}
return 1;
}
- else {
- printf("\nError: frame number must follow '%s'.\n", arg_id);
- return 0;
- }
- }
- else {
- printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
+ printf("\nError: frame number must follow '%s'.\n", arg_id);
return 0;
}
+ printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
+ return 0;
}
static const char arg_handle_frame_skip_set_doc[] =
@@ -1773,15 +1724,11 @@ static int arg_handle_frame_skip_set(int argc, const char **argv, void *data)
}
return 1;
}
- else {
- printf("\nError: number of frames to step must follow '%s'.\n", arg_id);
- return 0;
- }
- }
- else {
- printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
+ printf("\nError: number of frames to step must follow '%s'.\n", arg_id);
return 0;
}
+ printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
+ return 0;
}
static const char arg_handle_python_file_run_doc[] =
@@ -1808,10 +1755,9 @@ static int arg_handle_python_file_run(int argc, const char **argv, void *data)
}
return 1;
}
- else {
- printf("\nError: you must specify a filepath after '%s'.\n", argv[0]);
- return 0;
- }
+ printf("\nError: you must specify a filepath after '%s'.\n", argv[0]);
+ return 0;
+
# else
UNUSED_VARS(argc, argv, data);
printf("This Blender was built without Python support\n");
@@ -1850,10 +1796,9 @@ static int arg_handle_python_text_run(int argc, const char **argv, void *data)
return 1;
}
- else {
- printf("\nError: you must specify a text block after '%s'.\n", argv[0]);
- return 0;
- }
+ printf("\nError: you must specify a text block after '%s'.\n", argv[0]);
+ return 0;
+
# else
UNUSED_VARS(argc, argv, data);
printf("This Blender was built without Python support\n");
@@ -1880,10 +1825,9 @@ static int arg_handle_python_expr_run(int argc, const char **argv, void *data)
}
return 1;
}
- else {
- printf("\nError: you must specify a Python expression after '%s'.\n", argv[0]);
- return 0;
- }
+ printf("\nError: you must specify a Python expression after '%s'.\n", argv[0]);
+ return 0;
+
# else
UNUSED_VARS(argc, argv, data);
printf("This Blender was built without Python support\n");
@@ -1933,10 +1877,8 @@ static int arg_handle_python_exit_code_set(int argc, const char **argv, void *UN
app_state.exit_code_on_error.python = (unsigned char)exit_code;
return 1;
}
- else {
- printf("\nError: you must specify an exit code number '%s'.\n", arg_id);
- return 0;
- }
+ printf("\nError: you must specify an exit code number '%s'.\n", arg_id);
+ return 0;
}
static const char arg_handle_python_use_system_env_set_doc[] =
@@ -1979,10 +1921,8 @@ static int arg_handle_addons_set(int argc, const char **argv, void *data)
# endif /* WITH_PYTHON */
return 1;
}
- else {
- printf("\nError: you must specify a comma separated list after '--addons'.\n");
- return 0;
- }
+ printf("\nError: you must specify a comma separated list after '--addons'.\n");
+ return 0;
}
static int arg_handle_load_file(int UNUSED(argc), const char **argv, void *data)
@@ -2054,239 +1994,232 @@ void main_args_setup(bContext *C, bArgs *ba)
# define CB(a) a##_doc, a
# define CB_EX(a, b) a##_doc_##b, a
- // BLI_argsAdd(ba, pass, short_arg, long_arg, doc, cb, C);
-
/* end argument processing after -- */
- BLI_argsAdd(ba, -1, "--", NULL, CB(arg_handle_arguments_end), NULL);
-
- /* first pass: background mode, disable python and commands that exit after usage */
- BLI_argsAdd(ba, 1, "-h", "--help", CB(arg_handle_print_help), ba);
+ BLI_args_pass_set(ba, -1);
+ BLI_args_add(ba, "--", NULL, CB(arg_handle_arguments_end), NULL);
+
+ /* Pass: Environment Setup
+ *
+ * It's important these run before any initialization is done, since they set up
+ * the environment used to access data-files, which are be used when initializing
+ * sub-systems such as color management. */
+ BLI_args_pass_set(ba, ARG_PASS_ENVIRONMENT);
+ BLI_args_add(
+ ba, NULL, "--python-use-system-env", CB(arg_handle_python_use_system_env_set), NULL);
+
+ /* Note that we could add used environment variables too. */
+ BLI_args_add(
+ ba, NULL, "--env-system-datafiles", CB_EX(arg_handle_env_system_set, datafiles), NULL);
+ BLI_args_add(ba, NULL, "--env-system-scripts", CB_EX(arg_handle_env_system_set, scripts), NULL);
+ BLI_args_add(ba, NULL, "--env-system-python", CB_EX(arg_handle_env_system_set, python), NULL);
+
+ BLI_args_add(ba, "-t", "--threads", CB(arg_handle_threads_set), NULL);
+
+ /* Pass: Background Mode & Settings
+ *
+ * Also and commands that exit after usage. */
+ BLI_args_pass_set(ba, ARG_PASS_SETTINGS);
+ BLI_args_add(ba, "-h", "--help", CB(arg_handle_print_help), ba);
/* Windows only */
- BLI_argsAdd(ba, 1, "/?", NULL, CB_EX(arg_handle_print_help, win32), ba);
+ BLI_args_add(ba, "/?", NULL, CB_EX(arg_handle_print_help, win32), ba);
- BLI_argsAdd(ba, 1, "-v", "--version", CB(arg_handle_print_version), NULL);
+ BLI_args_add(ba, "-v", "--version", CB(arg_handle_print_version), NULL);
- BLI_argsAdd(
- ba, 1, "-y", "--enable-autoexec", CB_EX(arg_handle_python_set, enable), (void *)true);
- BLI_argsAdd(
- ba, 1, "-Y", "--disable-autoexec", CB_EX(arg_handle_python_set, disable), (void *)false);
+ BLI_args_add(ba, "-y", "--enable-autoexec", CB_EX(arg_handle_python_set, enable), (void *)true);
+ BLI_args_add(
+ ba, "-Y", "--disable-autoexec", CB_EX(arg_handle_python_set, disable), (void *)false);
- BLI_argsAdd(ba, 1, NULL, "--disable-crash-handler", CB(arg_handle_crash_handler_disable), NULL);
- BLI_argsAdd(ba, 1, NULL, "--disable-abort-handler", CB(arg_handle_abort_handler_disable), NULL);
+ BLI_args_add(ba, NULL, "--disable-crash-handler", CB(arg_handle_crash_handler_disable), NULL);
+ BLI_args_add(ba, NULL, "--disable-abort-handler", CB(arg_handle_abort_handler_disable), NULL);
- BLI_argsAdd(ba, 1, "-b", "--background", CB(arg_handle_background_mode_set), NULL);
+ BLI_args_add(ba, "-b", "--background", CB(arg_handle_background_mode_set), NULL);
- BLI_argsAdd(ba, 1, "-a", NULL, CB(arg_handle_playback_mode), NULL);
+ BLI_args_add(ba, "-a", NULL, CB(arg_handle_playback_mode), NULL);
- BLI_argsAdd(ba, 1, NULL, "--log", CB(arg_handle_log_set), ba);
- BLI_argsAdd(ba, 1, NULL, "--log-level", CB(arg_handle_log_level_set), ba);
- BLI_argsAdd(ba, 1, NULL, "--log-show-basename", CB(arg_handle_log_show_basename_set), ba);
- BLI_argsAdd(ba, 1, NULL, "--log-show-backtrace", CB(arg_handle_log_show_backtrace_set), ba);
- BLI_argsAdd(ba, 1, NULL, "--log-show-timestamp", CB(arg_handle_log_show_timestamp_set), ba);
- BLI_argsAdd(ba, 1, NULL, "--log-file", CB(arg_handle_log_file_set), ba);
+ BLI_args_add(ba, NULL, "--log", CB(arg_handle_log_set), ba);
+ BLI_args_add(ba, NULL, "--log-level", CB(arg_handle_log_level_set), ba);
+ BLI_args_add(ba, NULL, "--log-show-basename", CB(arg_handle_log_show_basename_set), ba);
+ BLI_args_add(ba, NULL, "--log-show-backtrace", CB(arg_handle_log_show_backtrace_set), ba);
+ BLI_args_add(ba, NULL, "--log-show-timestamp", CB(arg_handle_log_show_timestamp_set), ba);
+ BLI_args_add(ba, NULL, "--log-file", CB(arg_handle_log_file_set), ba);
- BLI_argsAdd(ba, 1, "-d", "--debug", CB(arg_handle_debug_mode_set), ba);
+ BLI_args_add(ba, "-d", "--debug", CB(arg_handle_debug_mode_set), ba);
# ifdef WITH_FFMPEG
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-ffmpeg",
- CB_EX(arg_handle_debug_mode_generic_set, ffmpeg),
- (void *)G_DEBUG_FFMPEG);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-ffmpeg",
+ CB_EX(arg_handle_debug_mode_generic_set, ffmpeg),
+ (void *)G_DEBUG_FFMPEG);
# endif
# ifdef WITH_FREESTYLE
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-freestyle",
- CB_EX(arg_handle_debug_mode_generic_set, freestyle),
- (void *)G_DEBUG_FREESTYLE);
+ BLI_args_add(ba,
+
+ NULL,
+ "--debug-freestyle",
+ CB_EX(arg_handle_debug_mode_generic_set, freestyle),
+ (void *)G_DEBUG_FREESTYLE);
# endif
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-python",
- CB_EX(arg_handle_debug_mode_generic_set, python),
- (void *)G_DEBUG_PYTHON);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-events",
- CB_EX(arg_handle_debug_mode_generic_set, events),
- (void *)G_DEBUG_EVENTS);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-handlers",
- CB_EX(arg_handle_debug_mode_generic_set, handlers),
- (void *)G_DEBUG_HANDLERS);
- BLI_argsAdd(
- ba, 1, NULL, "--debug-wm", CB_EX(arg_handle_debug_mode_generic_set, wm), (void *)G_DEBUG_WM);
+ BLI_args_add(ba,
+
+ NULL,
+ "--debug-python",
+ CB_EX(arg_handle_debug_mode_generic_set, python),
+ (void *)G_DEBUG_PYTHON);
+ BLI_args_add(ba,
+
+ NULL,
+ "--debug-events",
+ CB_EX(arg_handle_debug_mode_generic_set, events),
+ (void *)G_DEBUG_EVENTS);
+ BLI_args_add(ba,
+
+ NULL,
+ "--debug-handlers",
+ CB_EX(arg_handle_debug_mode_generic_set, handlers),
+ (void *)G_DEBUG_HANDLERS);
+ BLI_args_add(
+ ba, NULL, "--debug-wm", CB_EX(arg_handle_debug_mode_generic_set, wm), (void *)G_DEBUG_WM);
# ifdef WITH_XR_OPENXR
- BLI_argsAdd(
- ba, 1, NULL, "--debug-xr", CB_EX(arg_handle_debug_mode_generic_set, xr), (void *)G_DEBUG_XR);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-xr-time",
- CB_EX(arg_handle_debug_mode_generic_set, xr_time),
- (void *)G_DEBUG_XR_TIME);
+ BLI_args_add(
+ ba, NULL, "--debug-xr", CB_EX(arg_handle_debug_mode_generic_set, xr), (void *)G_DEBUG_XR);
+ BLI_args_add(ba,
+
+ NULL,
+ "--debug-xr-time",
+ CB_EX(arg_handle_debug_mode_generic_set, xr_time),
+ (void *)G_DEBUG_XR_TIME);
# endif
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-ghost",
- CB_EX(arg_handle_debug_mode_generic_set, handlers),
- (void *)G_DEBUG_GHOST);
- BLI_argsAdd(ba, 1, NULL, "--debug-all", CB(arg_handle_debug_mode_all), NULL);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-ghost",
+ CB_EX(arg_handle_debug_mode_generic_set, handlers),
+ (void *)G_DEBUG_GHOST);
+ BLI_args_add(ba, NULL, "--debug-all", CB(arg_handle_debug_mode_all), NULL);
- BLI_argsAdd(ba, 1, NULL, "--debug-io", CB(arg_handle_debug_mode_io), NULL);
+ BLI_args_add(ba, NULL, "--debug-io", CB(arg_handle_debug_mode_io), NULL);
- BLI_argsAdd(ba, 1, NULL, "--debug-fpe", CB(arg_handle_debug_fpe_set), NULL);
+ BLI_args_add(ba, NULL, "--debug-fpe", CB(arg_handle_debug_fpe_set), NULL);
# ifdef WITH_LIBMV
- BLI_argsAdd(ba, 1, NULL, "--debug-libmv", CB(arg_handle_debug_mode_libmv), NULL);
+ BLI_args_add(ba, NULL, "--debug-libmv", CB(arg_handle_debug_mode_libmv), NULL);
# endif
# ifdef WITH_CYCLES_LOGGING
- BLI_argsAdd(ba, 1, NULL, "--debug-cycles", CB(arg_handle_debug_mode_cycles), NULL);
+ BLI_args_add(ba, NULL, "--debug-cycles", CB(arg_handle_debug_mode_cycles), NULL);
# endif
- BLI_argsAdd(ba, 1, NULL, "--debug-memory", CB(arg_handle_debug_mode_memory_set), NULL);
-
- BLI_argsAdd(ba, 1, NULL, "--debug-value", CB(arg_handle_debug_value_set), NULL);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-jobs",
- CB_EX(arg_handle_debug_mode_generic_set, jobs),
- (void *)G_DEBUG_JOBS);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-gpu",
- CB_EX(arg_handle_debug_mode_generic_set, gpu),
- (void *)G_DEBUG_GPU);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-depsgraph",
- CB_EX(arg_handle_debug_mode_generic_set, depsgraph),
- (void *)G_DEBUG_DEPSGRAPH);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-depsgraph-build",
- CB_EX(arg_handle_debug_mode_generic_set, depsgraph_build),
- (void *)G_DEBUG_DEPSGRAPH_BUILD);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-depsgraph-eval",
- CB_EX(arg_handle_debug_mode_generic_set, depsgraph_eval),
- (void *)G_DEBUG_DEPSGRAPH_EVAL);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-depsgraph-tag",
- CB_EX(arg_handle_debug_mode_generic_set, depsgraph_tag),
- (void *)G_DEBUG_DEPSGRAPH_TAG);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-depsgraph-time",
- CB_EX(arg_handle_debug_mode_generic_set, depsgraph_time),
- (void *)G_DEBUG_DEPSGRAPH_TIME);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-depsgraph-no-threads",
- CB_EX(arg_handle_debug_mode_generic_set, depsgraph_no_threads),
- (void *)G_DEBUG_DEPSGRAPH_NO_THREADS);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-depsgraph-pretty",
- CB_EX(arg_handle_debug_mode_generic_set, depsgraph_pretty),
- (void *)G_DEBUG_DEPSGRAPH_PRETTY);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-depsgraph-uuid",
- CB_EX(arg_handle_debug_mode_generic_set, depsgraph_build),
- (void *)G_DEBUG_DEPSGRAPH_UUID);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-gpumem",
- CB_EX(arg_handle_debug_mode_generic_set, gpumem),
- (void *)G_DEBUG_GPU_MEM);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-gpu-shaders",
- CB_EX(arg_handle_debug_mode_generic_set, gpumem),
- (void *)G_DEBUG_GPU_SHADERS);
- BLI_argsAdd(ba,
- 1,
- NULL,
- "--debug-gpu-force-workarounds",
- CB_EX(arg_handle_debug_mode_generic_set, gpumem),
- (void *)G_DEBUG_GPU_FORCE_WORKAROUNDS);
- BLI_argsAdd(ba, 1, NULL, "--debug-exit-on-error", CB(arg_handle_debug_exit_on_error), NULL);
-
- BLI_argsAdd(ba, 1, NULL, "--verbose", CB(arg_handle_verbosity_set), NULL);
-
- BLI_argsAdd(ba, 1, NULL, "--app-template", CB(arg_handle_app_template), NULL);
- BLI_argsAdd(ba, 1, NULL, "--factory-startup", CB(arg_handle_factory_startup_set), NULL);
- BLI_argsAdd(ba, 1, NULL, "--enable-event-simulate", CB(arg_handle_enable_event_simulate), NULL);
-
- /* TODO, add user env vars? */
- BLI_argsAdd(
- ba, 1, NULL, "--env-system-datafiles", CB_EX(arg_handle_env_system_set, datafiles), NULL);
- BLI_argsAdd(
- ba, 1, NULL, "--env-system-scripts", CB_EX(arg_handle_env_system_set, scripts), NULL);
- BLI_argsAdd(ba, 1, NULL, "--env-system-python", CB_EX(arg_handle_env_system_set, python), NULL);
-
- BLI_argsAdd(
- ba, 1, NULL, "--python-use-system-env", CB(arg_handle_python_use_system_env_set), NULL);
-
- /* second pass: custom window stuff */
- BLI_argsAdd(ba, 2, "-p", "--window-geometry", CB(arg_handle_window_geometry), NULL);
- BLI_argsAdd(ba, 2, "-w", "--window-border", CB(arg_handle_with_borders), NULL);
- BLI_argsAdd(ba, 2, "-W", "--window-fullscreen", CB(arg_handle_without_borders), NULL);
- BLI_argsAdd(ba, 2, "-M", "--window-maximized", CB(arg_handle_window_maximized), NULL);
- BLI_argsAdd(ba, 2, NULL, "--no-window-focus", CB(arg_handle_no_window_focus), NULL);
- BLI_argsAdd(ba, 2, "-con", "--start-console", CB(arg_handle_start_with_console), NULL);
- BLI_argsAdd(ba, 2, "-R", NULL, CB(arg_handle_register_extension), NULL);
- BLI_argsAdd(ba, 2, "-r", NULL, CB_EX(arg_handle_register_extension, silent), ba);
- BLI_argsAdd(ba, 2, NULL, "--no-native-pixels", CB(arg_handle_native_pixels_set), ba);
-
- /* third pass: disabling things and forcing settings */
- BLI_argsAddCase(ba, 3, "-noaudio", 1, NULL, 0, CB(arg_handle_audio_disable), NULL);
- BLI_argsAddCase(ba, 3, "-setaudio", 1, NULL, 0, CB(arg_handle_audio_set), NULL);
-
- /* fourth pass: processing arguments */
- BLI_argsAdd(ba, 4, "-f", "--render-frame", CB(arg_handle_render_frame), C);
- BLI_argsAdd(ba, 4, "-a", "--render-anim", CB(arg_handle_render_animation), C);
- BLI_argsAdd(ba, 4, "-S", "--scene", CB(arg_handle_scene_set), C);
- BLI_argsAdd(ba, 4, "-s", "--frame-start", CB(arg_handle_frame_start_set), C);
- BLI_argsAdd(ba, 4, "-e", "--frame-end", CB(arg_handle_frame_end_set), C);
- BLI_argsAdd(ba, 4, "-j", "--frame-jump", CB(arg_handle_frame_skip_set), C);
- BLI_argsAdd(ba, 4, "-P", "--python", CB(arg_handle_python_file_run), C);
- BLI_argsAdd(ba, 4, NULL, "--python-text", CB(arg_handle_python_text_run), C);
- BLI_argsAdd(ba, 4, NULL, "--python-expr", CB(arg_handle_python_expr_run), C);
- BLI_argsAdd(ba, 4, NULL, "--python-console", CB(arg_handle_python_console_run), C);
- BLI_argsAdd(ba, 4, NULL, "--python-exit-code", CB(arg_handle_python_exit_code_set), NULL);
- BLI_argsAdd(ba, 4, NULL, "--addons", CB(arg_handle_addons_set), C);
-
- BLI_argsAdd(ba, 4, "-o", "--render-output", CB(arg_handle_output_set), C);
- BLI_argsAdd(ba, 4, "-E", "--engine", CB(arg_handle_engine_set), C);
-
- BLI_argsAdd(ba, 4, "-F", "--render-format", CB(arg_handle_image_type_set), C);
- BLI_argsAdd(ba, 1, "-t", "--threads", CB(arg_handle_threads_set), NULL);
- BLI_argsAdd(ba, 4, "-x", "--use-extension", CB(arg_handle_extension_set), C);
+ BLI_args_add(ba, NULL, "--debug-memory", CB(arg_handle_debug_mode_memory_set), NULL);
+
+ BLI_args_add(ba, NULL, "--debug-value", CB(arg_handle_debug_value_set), NULL);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-jobs",
+ CB_EX(arg_handle_debug_mode_generic_set, jobs),
+ (void *)G_DEBUG_JOBS);
+ BLI_args_add(
+ ba, NULL, "--debug-gpu", CB_EX(arg_handle_debug_mode_generic_set, gpu), (void *)G_DEBUG_GPU);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-depsgraph",
+ CB_EX(arg_handle_debug_mode_generic_set, depsgraph),
+ (void *)G_DEBUG_DEPSGRAPH);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-depsgraph-build",
+ CB_EX(arg_handle_debug_mode_generic_set, depsgraph_build),
+ (void *)G_DEBUG_DEPSGRAPH_BUILD);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-depsgraph-eval",
+ CB_EX(arg_handle_debug_mode_generic_set, depsgraph_eval),
+ (void *)G_DEBUG_DEPSGRAPH_EVAL);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-depsgraph-tag",
+ CB_EX(arg_handle_debug_mode_generic_set, depsgraph_tag),
+ (void *)G_DEBUG_DEPSGRAPH_TAG);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-depsgraph-time",
+ CB_EX(arg_handle_debug_mode_generic_set, depsgraph_time),
+ (void *)G_DEBUG_DEPSGRAPH_TIME);
+ BLI_args_add(ba,
+
+ NULL,
+ "--debug-depsgraph-no-threads",
+ CB_EX(arg_handle_debug_mode_generic_set, depsgraph_no_threads),
+ (void *)G_DEBUG_DEPSGRAPH_NO_THREADS);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-depsgraph-pretty",
+ CB_EX(arg_handle_debug_mode_generic_set, depsgraph_pretty),
+ (void *)G_DEBUG_DEPSGRAPH_PRETTY);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-depsgraph-uuid",
+ CB_EX(arg_handle_debug_mode_generic_set, depsgraph_build),
+ (void *)G_DEBUG_DEPSGRAPH_UUID);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-gpumem",
+ CB_EX(arg_handle_debug_mode_generic_set, gpumem),
+ (void *)G_DEBUG_GPU_MEM);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-gpu-shaders",
+ CB_EX(arg_handle_debug_mode_generic_set, gpumem),
+ (void *)G_DEBUG_GPU_SHADERS);
+ BLI_args_add(ba,
+ NULL,
+ "--debug-gpu-force-workarounds",
+ CB_EX(arg_handle_debug_mode_generic_set, gpumem),
+ (void *)G_DEBUG_GPU_FORCE_WORKAROUNDS);
+ BLI_args_add(ba, NULL, "--debug-exit-on-error", CB(arg_handle_debug_exit_on_error), NULL);
+
+ BLI_args_add(ba, NULL, "--verbose", CB(arg_handle_verbosity_set), NULL);
+
+ BLI_args_add(ba, NULL, "--app-template", CB(arg_handle_app_template), NULL);
+ BLI_args_add(ba, NULL, "--factory-startup", CB(arg_handle_factory_startup_set), NULL);
+ BLI_args_add(ba, NULL, "--enable-event-simulate", CB(arg_handle_enable_event_simulate), NULL);
+
+ /* Pass: Custom Window Stuff. */
+ BLI_args_pass_set(ba, ARG_PASS_SETTINGS_GUI);
+ BLI_args_add(ba, "-p", "--window-geometry", CB(arg_handle_window_geometry), NULL);
+ BLI_args_add(ba, "-w", "--window-border", CB(arg_handle_with_borders), NULL);
+ BLI_args_add(ba, "-W", "--window-fullscreen", CB(arg_handle_without_borders), NULL);
+ BLI_args_add(ba, "-M", "--window-maximized", CB(arg_handle_window_maximized), NULL);
+ BLI_args_add(ba, NULL, "--no-window-focus", CB(arg_handle_no_window_focus), NULL);
+ BLI_args_add(ba, "-con", "--start-console", CB(arg_handle_start_with_console), NULL);
+ BLI_args_add(ba, "-R", NULL, CB(arg_handle_register_extension), NULL);
+ BLI_args_add(ba, "-r", NULL, CB_EX(arg_handle_register_extension, silent), ba);
+ BLI_args_add(ba, NULL, "--no-native-pixels", CB(arg_handle_native_pixels_set), ba);
+
+ /* Pass: Disabling Things & Forcing Settings. */
+ BLI_args_pass_set(ba, ARG_PASS_SETTINGS_FORCE);
+ BLI_args_add_case(ba, "-noaudio", 1, NULL, 0, CB(arg_handle_audio_disable), NULL);
+ BLI_args_add_case(ba, "-setaudio", 1, NULL, 0, CB(arg_handle_audio_set), NULL);
+
+ /* Pass: Processing Arguments. */
+ BLI_args_pass_set(ba, ARG_PASS_FINAL);
+ BLI_args_add(ba, "-f", "--render-frame", CB(arg_handle_render_frame), C);
+ BLI_args_add(ba, "-a", "--render-anim", CB(arg_handle_render_animation), C);
+ BLI_args_add(ba, "-S", "--scene", CB(arg_handle_scene_set), C);
+ BLI_args_add(ba, "-s", "--frame-start", CB(arg_handle_frame_start_set), C);
+ BLI_args_add(ba, "-e", "--frame-end", CB(arg_handle_frame_end_set), C);
+ BLI_args_add(ba, "-j", "--frame-jump", CB(arg_handle_frame_skip_set), C);
+ BLI_args_add(ba, "-P", "--python", CB(arg_handle_python_file_run), C);
+ BLI_args_add(ba, NULL, "--python-text", CB(arg_handle_python_text_run), C);
+ BLI_args_add(ba, NULL, "--python-expr", CB(arg_handle_python_expr_run), C);
+ BLI_args_add(ba, NULL, "--python-console", CB(arg_handle_python_console_run), C);
+ BLI_args_add(ba, NULL, "--python-exit-code", CB(arg_handle_python_exit_code_set), NULL);
+ BLI_args_add(ba, NULL, "--addons", CB(arg_handle_addons_set), C);
+
+ BLI_args_add(ba, "-o", "--render-output", CB(arg_handle_output_set), C);
+ BLI_args_add(ba, "-E", "--engine", CB(arg_handle_engine_set), C);
+
+ BLI_args_add(ba, "-F", "--render-format", CB(arg_handle_image_type_set), C);
+ BLI_args_add(ba, "-x", "--use-extension", CB(arg_handle_extension_set), C);
# undef CB
# undef CB_EX
@@ -2297,7 +2230,7 @@ void main_args_setup(bContext *C, bArgs *ba)
*/
void main_args_setup_post(bContext *C, bArgs *ba)
{
- BLI_argsParse(ba, 4, arg_handle_load_file, C);
+ BLI_args_parse(ba, ARG_PASS_FINAL, arg_handle_load_file, C);
}
/** \} */
diff --git a/source/creator/creator_intern.h b/source/creator/creator_intern.h
index 7ff3247e17e..0a13f45eef1 100644
--- a/source/creator/creator_intern.h
+++ b/source/creator/creator_intern.h
@@ -38,7 +38,7 @@ void main_signal_setup_fpe(void);
#endif /* WITH_PYTHON_MODULE */
-/* Shared data for argument handlers to store state in */
+/** Shared data for argument handlers to store state in. */
struct ApplicationState {
struct {
bool use_crash_handler;
@@ -52,6 +52,24 @@ struct ApplicationState {
};
extern struct ApplicationState app_state; /* creator.c */
+/**
+ * Passes for use by #main_args_setup.
+ * Keep in order of execution.
+ */
+enum {
+ /** Run before sub-system initialization. */
+ ARG_PASS_ENVIRONMENT = 1,
+ /** General settings parsing, also animation player. */
+ ARG_PASS_SETTINGS = 2,
+ /** Windowing & graphical settings (ignored in background mode). */
+ ARG_PASS_SETTINGS_GUI = 3,
+ /** Currently use for audio devices. */
+ ARG_PASS_SETTINGS_FORCE = 4,
+
+ /** Actions & fall back to loading blend file. */
+ ARG_PASS_FINAL = 5,
+};
+
/* for the callbacks: */
#ifndef WITH_PYTHON_MODULE
# define BLEND_VERSION_FMT "Blender %d.%02d.%d"
@@ -80,4 +98,4 @@ extern char build_cflags[];
extern char build_cxxflags[];
extern char build_linkflags[];
extern char build_system[];
-#endif
+#endif /* BUILD_DATE */
diff --git a/source/tools b/source/tools
-Subproject 7011d02c292ac1c91a5c9cc1a075ea2727982ce
+Subproject 660be0ca10abc8261178159afcd1032be662e38