Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dalai@blender.org>2020-11-06 20:22:36 +0300
committerDalai Felinto <dalai@blender.org>2020-11-06 20:22:36 +0300
commite5c637f5fea31251f49980f0ef6eb19695a6cba2 (patch)
tree4e9a6b9eb723c35e640bf451eeac308bceea3b2b /source/blender
parent11d12d543d15993810861db70c83bf6b9e58eb02 (diff)
parent3310e6d63ed229ec8f92fa7f630e8680204f6073 (diff)
Merge remote-tracking branch 'origin/master' into geometry-nodes
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blendthumb/CMakeLists.txt2
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/BKE_collection.h12
-rw-r--r--source/blender/blenkernel/BKE_idtype.h11
-rw-r--r--source/blender/blenkernel/BKE_layer.h4
-rw-r--r--source/blender/blenkernel/BKE_node.h4
-rw-r--r--source/blender/blenkernel/BKE_object.h2
-rw-r--r--source/blender/blenkernel/BKE_particle.h6
-rw-r--r--source/blender/blenkernel/BKE_screen.h12
-rw-r--r--source/blender/blenkernel/CMakeLists.txt2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c2
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c2
-rw-r--r--source/blender/blenkernel/intern/action.c2
-rw-r--r--source/blender/blenkernel/intern/armature.c6
-rw-r--r--source/blender/blenkernel/intern/blender.c2
-rw-r--r--source/blender/blenkernel/intern/boids.c2
-rw-r--r--source/blender/blenkernel/intern/brush.c33
-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/collection.c6
-rw-r--r--source/blender/blenkernel/intern/colortools.c6
-rw-r--r--source/blender/blenkernel/intern/curve.c50
-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/dynamicpaint.c15
-rw-r--r--source/blender/blenkernel/intern/effect.c13
-rw-r--r--source/blender/blenkernel/intern/fcurve.c2
-rw-r--r--source/blender/blenkernel/intern/fluid.c26
-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.c18
-rw-r--r--source/blender/blenkernel/intern/gpencil_geom.c10
-rw-r--r--source/blender/blenkernel/intern/hair.c2
-rw-r--r--source/blender/blenkernel/intern/image.c10
-rw-r--r--source/blender/blenkernel/intern/ipo.c2
-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/layer.c9
-rw-r--r--source/blender/blenkernel/intern/lib_id.c13
-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/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.c3
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c5
-rw-r--r--source/blender/blenkernel/intern/mesh_merge.c2
-rw-r--r--source/blender/blenkernel/intern/movieclip.c4
-rw-r--r--source/blender/blenkernel/intern/node.c11
-rw-r--r--source/blender/blenkernel/intern/object.c2
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c2
-rw-r--r--source/blender/blenkernel/intern/paint.c14
-rw-r--r--source/blender/blenkernel/intern/particle.c89
-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.c189
-rw-r--r--source/blender/blenkernel/intern/pointcache.c5
-rw-r--r--source/blender/blenkernel/intern/pointcloud.c2
-rw-r--r--source/blender/blenkernel/intern/scene.c239
-rw-r--r--source/blender/blenkernel/intern/screen.c20
-rw-r--r--source/blender/blenkernel/intern/simulation.cc2
-rw-r--r--source/blender/blenkernel/intern/softbody.c8
-rw-r--r--source/blender/blenkernel/intern/sound.c2
-rw-r--r--source/blender/blenkernel/intern/speaker.c2
-rw-r--r--source/blender/blenkernel/intern/text.c6
-rw-r--r--source/blender/blenkernel/intern/texture.c2
-rw-r--r--source/blender/blenkernel/intern/tracking_util.c4
-rw-r--r--source/blender/blenkernel/intern/undo_system.c2
-rw-r--r--source/blender/blenkernel/intern/unit.c10
-rw-r--r--source/blender/blenkernel/intern/volume.cc3
-rw-r--r--source/blender/blenkernel/intern/workspace.c2
-rw-r--r--source/blender/blenkernel/intern/world.c2
-rw-r--r--source/blender/blenlib/BLI_args.h45
-rw-r--r--source/blender/blenlib/BLI_bitmap.h2
-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/intern/BLI_args.c51
-rw-r--r--source/blender/blenlib/intern/array_store.c4
-rw-r--r--source/blender/blenlib/intern/delaunay_2d.cc2
-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_geom.c4
-rw-r--r--source/blender/blenlib/intern/math_interp.c6
-rw-r--r--source/blender/blenlib/intern/math_matrix.c63
-rw-r--r--source/blender/blenlib/intern/mesh_boolean.cc2
-rw-r--r--source/blender/blenlib/intern/mesh_intersect.cc5
-rw-r--r--source/blender/blenlib/intern/noise.c300
-rw-r--r--source/blender/blenlib/intern/scanfill_utils.c4
-rw-r--r--source/blender/blenlib/intern/storage_apple.mm2
-rw-r--r--source/blender/blenlib/intern/voxel.c44
-rw-r--r--source/blender/blenlib/tests/BLI_delaunay_2d_test.cc2
-rw-r--r--source/blender/blenloader/CMakeLists.txt2
-rw-r--r--source/blender/blenloader/intern/readfile.c113
-rw-r--r--source/blender/blenloader/intern/versioning_250.c16
-rw-r--r--source/blender/blenloader/intern/versioning_260.c7
-rw-r--r--source/blender/blenloader/intern/versioning_280.c13
-rw-r--r--source/blender/blenloader/intern/versioning_290.c169
-rw-r--r--source/blender/blenloader/intern/versioning_cycles.c5
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c2
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c12
-rw-r--r--source/blender/blenloader/intern/writefile.c10
-rw-r--r--source/blender/blenloader/tests/blendfile_loading_base_test.cc2
-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_operators.c6
-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.c2
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c6
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c69
-rw-r--r--source/blender/bmesh/tools/bmesh_edgenet.c2
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.cpp2
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp19
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedOperation.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.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.cpp2
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp1
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CryptomatteOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DenoiseOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.cpp2
-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.cpp2
-rw-r--r--source/blender/compositor/operations/COM_KeyingOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.cpp40
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_PixelateOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.cpp2
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.cpp2
-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.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SunBeamsOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_TrackPositionOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_WrapOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.cpp4
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc7
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc4
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.cc5
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline.cc3
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_flush.cc3
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_id.cc2
-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.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c5
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl15
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_data.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_engine.c5
-rw-r--r--source/blender/draw/engines/overlay/overlay_extra.c5
-rw-r--r--source/blender/draw/engines/overlay/overlay_image.c40
-rw-r--r--source/blender/draw/engines/overlay/overlay_private.h3
-rw-r--r--source/blender/draw/intern/DRW_render.h1
-rw-r--r--source/blender/draw/intern/draw_cache.c22
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh.c12
-rw-r--r--source/blender/draw/intern/draw_cache_impl_lattice.c6
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c17
-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.c5
-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.c21
-rw-r--r--source/blender/editors/armature/armature_select.c4
-rw-r--r--source/blender/editors/armature/pose_slide.c6
-rw-r--r--source/blender/editors/curve/editcurve.c18
-rw-r--r--source/blender/editors/curve/editcurve_add.c10
-rw-r--r--source/blender/editors/curve/editcurve_query.c4
-rw-r--r--source/blender/editors/curve/editfont.c10
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c40
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c12
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c12
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_merge.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_uv.c6
-rw-r--r--source/blender/editors/include/ED_buttons.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_numinput.h1
-rw-r--r--source/blender/editors/include/ED_object.h1
-rw-r--r--source/blender/editors/include/ED_view3d.h2
-rw-r--r--source/blender/editors/include/UI_interface.h15
-rw-r--r--source/blender/editors/interface/interface.c15
-rw-r--r--source/blender/editors/interface/interface_button_group.c4
-rw-r--r--source/blender/editors/interface/interface_draw.c6
-rw-r--r--source/blender/editors/interface/interface_handlers.c34
-rw-r--r--source/blender/editors/interface/interface_intern.h2
-rw-r--r--source/blender/editors/interface/interface_layout.c8
-rw-r--r--source/blender/editors/interface/interface_panel.c248
-rw-r--r--source/blender/editors/interface/interface_template_search_menu.c4
-rw-r--r--source/blender/editors/interface/interface_templates.c4
-rw-r--r--source/blender/editors/interface/interface_utils.c2
-rw-r--r--source/blender/editors/interface/interface_widgets.c20
-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/mask/mask_add.c2
-rw-r--r--source/blender/editors/mask/mask_draw.c2
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c100
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin.c3
-rw-r--r--source/blender/editors/mesh/editmesh_mask_extract.c6
-rw-r--r--source/blender/editors/mesh/editmesh_preselect_edgering.c2
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c3
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c4
-rw-r--r--source/blender/editors/mesh/meshtools.c2
-rw-r--r--source/blender/editors/object/object_add.c2
-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_modifier.c2
-rw-r--r--source/blender/editors/object/object_relations.c16
-rw-r--r--source/blender/editors/object/object_transform.c4
-rw-r--r--source/blender/editors/object/object_vgroup.c78
-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/rigidbody_world.c2
-rw-r--r--source/blender/editors/render/render_opengl.c18
-rw-r--r--source/blender/editors/screen/area.c6
-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.c12
-rw-r--r--source/blender/editors/screen/screendump.c2
-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.c21
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c36
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_face_set.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c4
-rw-r--r--source/blender/editors/sound/sound_ops.c9
-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_ops.c4
-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_file/file_ops.c21
-rw-r--r--source/blender/editors/space_file/filelist.c7
-rw-r--r--source/blender/editors/space_file/filesel.c81
-rw-r--r--source/blender/editors/space_file/fsmenu.c4
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c4
-rw-r--r--source/blender/editors/space_graph/graph_edit.c6
-rw-r--r--source/blender/editors/space_image/image_ops.c11
-rw-r--r--source/blender/editors/space_info/info_ops.c2
-rw-r--r--source/blender/editors/space_nla/space_nla.c2
-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_edit.c2
-rw-r--r--source/blender/editors/space_node/node_group.c56
-rw-r--r--source/blender/editors/space_node/node_view.c36
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c15
-rw-r--r--source/blender/editors/space_outliner/outliner_sync.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c10
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c13
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c21
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c32
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c4
-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.c12
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_camera_control.c7
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c6
-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_snap.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c15
-rw-r--r--source/blender/editors/transform/transform.c10
-rw-r--r--source/blender/editors/transform/transform.h96
-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_generics.c3
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c3
-rw-r--r--source/blender/editors/transform/transform_mode.c10
-rw-r--r--source/blender/editors/transform/transform_mode_bend.c2
-rw-r--r--source/blender/editors/transform/transform_mode_tosphere.c82
-rw-r--r--source/blender/editors/transform/transform_ops.c2
-rw-r--r--source/blender/editors/util/ed_util_imbuf.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c5
-rw-r--r--source/blender/freestyle/intern/application/AppCanvas.cpp4
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp8
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp2
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp4
-rw-r--r--source/blender/freestyle/intern/geometry/matrix_util.cpp2
-rw-r--r--source/blender/freestyle/intern/geometry/matrix_util.h14
-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/Interface1D/BPy_FEdge.cpp2
-rw-r--r--source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp3
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeLight.cpp2
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp3
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp10
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.h34
-rw-r--r--source/blender/freestyle/intern/stroke/Chain.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/Operators.cpp6
-rw-r--r--source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp2
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/TextStrokeRenderer.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/BoxGrid.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp4
-rw-r--r--source/blender/freestyle/intern/view_map/SphericalGrid.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp4
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp2
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.cpp2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c4
-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_state.h1
-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_codegen.c21
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer_private.hh6
-rw-r--r--source/blender/gpu/intern/gpu_immediate_private.hh2
-rw-r--r--source/blender/gpu/intern/gpu_immediate_util.c12
-rw-r--r--source/blender/gpu/intern/gpu_material.c10
-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_viewport.c3
-rw-r--r--source/blender/gpu/opengl/gl_framebuffer.cc2
-rw-r--r--source/blender/gpu/opengl/gl_framebuffer.hh10
-rw-r--r--source/blender/gpu/opengl/gl_state.cc16
-rw-r--r--source/blender/gpu/opengl/gl_vertex_array.cc2
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl10
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_output_material.glsl12
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp14
-rw-r--r--source/blender/imbuf/IMB_imbuf.h2
-rw-r--r--source/blender/imbuf/intern/bmp.c2
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c7
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.c11
-rw-r--r--source/blender/imbuf/intern/iris.c2
-rw-r--r--source/blender/imbuf/intern/jpeg.c4
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp4
-rw-r--r--source/blender/imbuf/intern/png.c2
-rw-r--r--source/blender/imbuf/intern/radiance_hdr.c6
-rw-r--r--source/blender/imbuf/intern/rectop.c77
-rw-r--r--source/blender/imbuf/intern/targa.c4
-rw-r--r--source/blender/imbuf/intern/tiff.c2
-rw-r--r--source/blender/io/alembic/exporter/abc_export_capi.cc2
-rw-r--r--source/blender/io/alembic/exporter/abc_subdiv_disabler.cc2
-rw-r--r--source/blender/io/alembic/intern/alembic_capi.cc2
-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/CMakeLists.txt2
-rw-r--r--source/blender/io/collada/collada_internal.cpp2
-rw-r--r--source/blender/io/common/intern/abstract_hierarchy_iterator.cc2
-rw-r--r--source/blender/io/usd/intern/usd_capi.cc2
-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_brush_types.h2
-rw-r--r--source/blender/makesdna/DNA_camera_defaults.h2
-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_screen_types.h18
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h7
-rw-r--r--source/blender/makesdna/DNA_space_types.h39
-rw-r--r--source/blender/makesdna/DNA_userdef_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_enum_types.h3
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt4
-rw-r--r--source/blender/makesrna/intern/makesrna.c13
-rw-r--r--source/blender/makesrna/intern/rna_ID.c2
-rw-r--r--source/blender/makesrna/intern/rna_armature.c2
-rw-r--r--source/blender/makesrna/intern/rna_camera.c6
-rw-r--r--source/blender/makesrna/intern/rna_color.c1
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c46
-rw-r--r--source/blender/makesrna/intern/rna_define.c6
-rw-r--r--source/blender/makesrna/intern/rna_image.c2
-rw-r--r--source/blender/makesrna/intern/rna_linestyle.c4
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c36
-rw-r--r--source/blender/makesrna/intern/rna_object.c9
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c5
-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.c7
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c75
-rw-r--r--source/blender/makesrna/intern/rna_sequencer_api.c4
-rw-r--r--source/blender/makesrna/intern/rna_space.c39
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c2
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c23
-rw-r--r--source/blender/modifiers/intern/MOD_array.c2
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c3
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c6
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c101
-rw-r--r--source/blender/modifiers/intern/MOD_volume_to_mesh.cc32
-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.cc4
-rw-r--r--source/blender/nodes/intern/node_util.c43
-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_output_material.c23
-rw-r--r--source/blender/python/generic/blf_py_api.c2
-rw-r--r--source/blender/python/intern/bpy_app_translations.c8
-rw-r--r--source/blender/python/intern/bpy_operator.c4
-rw-r--r--source/blender/python/intern/bpy_rna.c22
-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_noise.c41
-rw-r--r--source/blender/render/CMakeLists.txt4
-rw-r--r--source/blender/render/intern/source/imagetexture.c112
-rw-r--r--source/blender/render/intern/source/pipeline.c20
-rw-r--r--source/blender/render/intern/source/pointdensity.c14
-rw-r--r--source/blender/render/intern/source/render_result.c4
-rw-r--r--source/blender/render/intern/source/render_texture.c280
-rw-r--r--source/blender/sequencer/CMakeLists.txt10
-rw-r--r--source/blender/sequencer/SEQ_sequencer.h80
-rw-r--r--source/blender/sequencer/intern/effects.c19
-rw-r--r--source/blender/sequencer/intern/image_cache.c127
-rw-r--r--source/blender/sequencer/intern/modifier.c379
-rw-r--r--source/blender/sequencer/intern/prefetch.c37
-rw-r--r--source/blender/sequencer/intern/proxy.c570
-rw-r--r--source/blender/sequencer/intern/proxy.h40
-rw-r--r--source/blender/sequencer/intern/render.c2106
-rw-r--r--source/blender/sequencer/intern/render.h75
-rw-r--r--source/blender/sequencer/intern/sequencer.c2845
-rw-r--r--source/blender/sequencer/intern/sequencer.h67
-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.cpp5
-rw-r--r--source/blender/simulation/intern/eigen_utils.h2
-rw-r--r--source/blender/simulation/intern/hair_volume.cpp2
-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/intern/wm.c2
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c33
-rw-r--r--source/blender/windowmanager/intern/wm_files.c6
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c8
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c6
-rw-r--r--source/blender/windowmanager/intern/wm_operator_props.c32
-rw-r--r--source/blender/windowmanager/intern/wm_operator_type.c4
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c8
-rw-r--r--source/blender/windowmanager/intern/wm_window.c2
553 files changed, 7611 insertions, 5492 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/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 59e6b5629f0..5a64140b917 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 1
+#define BLENDER_FILE_SUBVERSION 3
/* 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 06fcc038f69..f35dafa15a8 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -35,17 +35,17 @@ 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 ViewLayer;
-struct BlendWriter;
-struct BlendDataReader;
-struct BlendLibReader;
-struct BlendExpander;
struct SceneCollection;
-struct Library;
+struct ViewLayer;
typedef struct CollectionParent {
struct CollectionParent *next, *prev;
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 39ba417c988..3d5062eada0 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -34,6 +34,8 @@ extern "C" {
#define TODO_LAYER /* generic todo */
struct Base;
+struct BlendDataReader;
+struct BlendLibReader;
struct Collection;
struct Depsgraph;
struct LayerCollection;
@@ -42,8 +44,6 @@ struct Object;
struct Scene;
struct View3D;
struct ViewLayer;
-struct BlendDataReader;
-struct BlendLibReader;
typedef enum eViewLayerCopyMethod {
VIEWLAYER_ADD_NEW = 0,
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 839047036ce..5ea99b14dbb 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1364,8 +1364,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..b7015942cb4 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,
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 755fca5a2dc..5df42e4ccd6 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -45,6 +45,8 @@ struct ParticleSystemModifierData;
struct BVHTreeRay;
struct BVHTreeRayHit;
+struct BlendDataReader;
+struct BlendLibReader;
struct CustomData_MeshMasks;
struct Depsgraph;
struct EdgeHash;
@@ -60,8 +62,6 @@ struct ModifierData;
struct Object;
struct RNG;
struct Scene;
-struct BlendDataReader;
-struct BlendLibReader;
#define PARTICLE_COLLISION_MAX_COLLISIONS 10
@@ -263,7 +263,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)
{
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index da87ff3e969..fd7f20d8839 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;
@@ -58,9 +61,6 @@ struct wmMsgBus;
struct wmNotifier;
struct wmWindow;
struct wmWindowManager;
-struct BlendWriter;
-struct BlendDataReader;
-struct BlendLibReader;
/* spacetype has everything stored to get an editor working, it gets initialized via
* ED_spacetypes_init() in editors/space_api/spacetypes.c */
@@ -365,8 +365,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);
@@ -387,7 +387,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);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index becd10dbb57..e091bf61f6a 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -708,7 +708,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 7b2e1be7b5d..eeff04788f9 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -2190,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..c77153960ea 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -295,6 +295,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 ************** */
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index bad2ed53436..fb885527cce 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;
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 897552723ee..71c859e1514 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -100,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/brush.c b/source/blender/blenkernel/intern/brush.c
index 17243b328e8..806b9ca1416 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -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/collection.c b/source/blender/blenkernel/intern/collection.c
index 870a137ede9..7ab63810719 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -174,6 +174,8 @@ 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);
@@ -198,7 +200,6 @@ static void collection_blend_write(BlendWriter *writer, ID *id, const void *id_a
/* write LibData */
BLO_write_id_struct(writer, Collection, id_address, &collection->id);
- BKE_id_blend_write(writer, &collection->id);
BKE_collection_blend_write_nolib(writer, collection);
}
@@ -359,6 +360,8 @@ IDTypeInfo IDType_ID_GR = {
.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,
};
/** \} */
@@ -472,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..8723cd13e35 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 */
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index fa45a4ba836..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],
@@ -2182,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)
{
@@ -2636,7 +2654,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
BPoint *bp;
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;
@@ -2732,7 +2750,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
*seglen = len_v3v3(bevp->vec, bp->vec);
bevp++;
bevp->offset = *seglen;
- if (*seglen > treshold) {
+ if (*seglen > threshold) {
*segbevcount = 1;
}
else {
@@ -2808,7 +2826,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
bevp->offset = *seglen;
seglen++;
/* match segbevcount to the cleaned up bevel lists (see STEP 2) */
- if (bevp->offset > treshold) {
+ if (bevp->offset > threshold) {
*segbevcount = 1;
}
segbevcount++;
@@ -2851,15 +2869,15 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
/* indicate with handlecodes double points */
if (prevbezt->h1 == prevbezt->h2) {
- if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) {
+ if (ELEM(prevbezt->h1, 0, HD_VECT)) {
bevp->split_tag = true;
}
}
else {
- if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) {
+ if (ELEM(prevbezt->h1, 0, HD_VECT)) {
bevp->split_tag = true;
}
- else if (prevbezt->h2 == 0 || prevbezt->h2 == HD_VECT) {
+ else if (ELEM(prevbezt->h2, 0, HD_VECT)) {
bevp->split_tag = true;
}
}
@@ -2873,7 +2891,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
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) {
+ if (bevp->offset > threshold) {
*seglen += bevp->offset;
*segbevcount += 1;
}
@@ -2942,7 +2960,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
/* 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) {
+ if (bevp->offset > threshold) {
*seglen += bevp->offset;
*segbevcount += 1;
}
@@ -2968,6 +2986,8 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
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) {
@@ -2982,19 +3002,15 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
nr--;
while (nr--) {
if (seglen != NULL) {
- if (fabsf(bevp1->offset) < treshold) {
+ if (fabsf(bevp1->offset) < threshold) {
bevp0->dupe_tag = true;
bl->dupe_nr++;
}
}
else {
- if (fabsf(bevp0->vec[0] - bevp1->vec[0]) < 0.00001f) {
- if (fabsf(bevp0->vec[1] - bevp1->vec[1]) < 0.00001f) {
- if (fabsf(bevp0->vec[2] - bevp1->vec[2]) < 0.00001f) {
- 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;
@@ -4945,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;
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/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index fef4b49de7e..95408c7d01f 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -123,7 +123,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 +762,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 +2700,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 +3034,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 +3736,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 +4710,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 +5115,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/effect.c b/source/blender/blenkernel/intern/effect.c
index 967b961dbea..f9d3fff1cec 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -699,8 +699,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 +1009,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 bd7d65f1e6f..47d4b70fef5 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1260,7 +1260,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];
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index af4b98e1c8d..a940a8a97c7 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -1993,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);
@@ -3293,7 +3293,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) {
@@ -4430,7 +4430,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;
@@ -4697,9 +4697,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;
}
@@ -4710,10 +4712,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;
}
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..4cf8e365cf6 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -288,6 +288,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,
};
/* ************************************************** */
@@ -2009,12 +2011,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,
@@ -2668,7 +2670,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 +2712,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_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index 66a7ae757a2..ff7dde27db8 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -189,7 +189,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");
}
@@ -778,7 +778,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 +838,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 +902,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. */
@@ -1402,7 +1402,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);
}
}
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/image.c b/source/blender/blenkernel/intern/image.c
index cadd442ad9e..f87b1b5ff45 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -325,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 */
@@ -666,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;
}
@@ -803,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));
@@ -1314,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
@@ -1664,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;
}
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index c09c5bf5cda..5d2defa3030 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -132,6 +132,8 @@ IDTypeInfo IDType_ID_IP = {
.blend_read_data = NULL,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
+
+ .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/layer.c b/source/blender/blenkernel/intern/layer.c
index 5b88a68b921..4915ad4eaac 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1450,12 +1450,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;
}
@@ -1900,9 +1897,7 @@ void BKE_view_layer_blend_read_lib(BlendLibReader *reader, Library *lib, ViewLay
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;
-
+ 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);
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index ae6ee71da82..cf9fff811ce 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/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/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 2d2519ada59..9ccdf5189d1 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -333,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 {
@@ -879,6 +881,7 @@ void BKE_mesh_copy_settings(Mesh *me_dst, const Mesh *me_src)
me_dst->remesh_voxel_size = me_src->remesh_voxel_size;
me_dst->remesh_voxel_adaptivity = me_src->remesh_voxel_adaptivity;
me_dst->remesh_mode = me_src->remesh_mode;
+ me_dst->symmetry = me_src->symmetry;
me_dst->face_sets_color_seed = me_src->face_sets_color_seed;
me_dst->face_sets_color_default = me_src->face_sets_color_default;
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index 052fd156a19..9711dcc8ef3 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -1657,6 +1657,11 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src,
tmp.totselect = 0;
tmp.texflag &= ~ME_AUTOSPACE_EVALUATED;
+ /* Clear any run-time data.
+ * Even though this mesh wont typically have run-time data, the Python API can for e.g.
+ * create loop-triangle cache here, which is confusing when left in the mesh, see: T81136. */
+ BKE_mesh_runtime_clear_geometry(&tmp);
+
/* skip the listbase */
MEMCPY_STRUCT_AFTER(mesh_dst, &tmp, id.prev);
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/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 40b12d8a777..564496744df 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -359,6 +359,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 *************************/
@@ -519,7 +521,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/node.c b/source/blender/blenkernel/intern/node.c
index 1976461432a..fd3f111c103 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -408,6 +408,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) {
@@ -529,9 +531,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);
}
@@ -859,6 +858,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)
@@ -4699,7 +4700,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");
@@ -4726,7 +4727,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 6bfee0194b0..f658594d878 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -538,6 +538,8 @@ IDTypeInfo IDType_ID_OB = {
.blend_read_data = NULL,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
void BKE_object_workob_clear(Object *workob)
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/paint.c b/source/blender/blenkernel/intern/paint.c
index e46c91e4bf4..f2af5520d16 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};
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 71f78592bc5..d323849d72d 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -506,13 +506,15 @@ IDTypeInfo IDType_ID_PA = {
.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++) {
@@ -1196,7 +1198,7 @@ static float interpolate_particle_value(
value += w[3] * v4;
}
- CLAMP(value, 0.f, 1.f);
+ CLAMP(value, 0.0f, 1.0f);
return value;
}
@@ -1425,7 +1427,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));
@@ -1595,7 +1597,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);
@@ -1614,7 +1616,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);
}
}
@@ -2479,7 +2481,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,
@@ -2829,12 +2831,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;
@@ -2862,15 +2864,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) {
@@ -2879,7 +2881,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];
@@ -2895,13 +2897,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];
@@ -3338,7 +3340,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);
@@ -3995,19 +3997,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) {
@@ -4015,9 +4023,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;
}
}
@@ -4271,9 +4281,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;
}
@@ -4381,14 +4391,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;
}
@@ -4933,8 +4944,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;
@@ -4961,13 +4972,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;
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..91bdfaeae95 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -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/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 45440eebacd..33b1c7a0ab3 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -462,7 +462,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;
}
@@ -738,8 +738,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) {
diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c
index 68f77d492f5..fcd69f2e9e3 100644
--- a/source/blender/blenkernel/intern/pointcloud.c
+++ b/source/blender/blenkernel/intern/pointcloud.c
@@ -184,6 +184,8 @@ IDTypeInfo IDType_ID_PT = {
.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 = NULL,
};
static void pointcloud_random(PointCloud *pointcloud)
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 6a9fe4615f7..5153618d6e7 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -104,6 +104,8 @@
#include "SEQ_sequencer.h"
+#include "BLO_read_write.h"
+
#include "engines/eevee/eevee_lightcache.h"
#include "PIL_time.h"
@@ -455,53 +457,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)
@@ -593,7 +758,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) {
@@ -620,6 +785,22 @@ static void scene_foreach_cache(ID *id,
user_data);
}
+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,
@@ -643,6 +824,8 @@ IDTypeInfo IDType_ID_SCE = {
.blend_read_data = NULL,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = scene_undo_preserve,
};
const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE";
@@ -1972,7 +2155,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 a357b5d98fb..1b8360a1cec 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -293,6 +293,8 @@ IDTypeInfo IDType_ID_SCR = {
.blend_read_data = NULL,
.blend_read_lib = screen_blend_read_lib,
.blend_read_expand = NULL,
+
+ .blend_read_undo_preserve = NULL,
};
/* ************ Spacetype/regiontype handling ************** */
@@ -354,7 +356,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;
@@ -369,7 +371,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;
@@ -446,7 +448,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);
@@ -960,7 +962,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;
@@ -978,7 +980,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;
@@ -1015,7 +1017,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) {
@@ -1036,7 +1038,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;
@@ -1368,14 +1370,12 @@ static void write_area_regions(BlendWriter *writer, ScrArea *area)
}
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);
}
@@ -1397,9 +1397,7 @@ void BKE_screen_area_map_blend_write(BlendWriter *writer, ScrAreaMap *area_map)
BLO_write_struct(writer, ScrArea, area);
-#ifdef WITH_GLOBAL_AREA_WRITING
BLO_write_struct(writer, ScrGlobalAreaData, area->global);
-#endif
write_area_regions(writer, area);
diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc
index 418746a680e..491cdbacd10 100644
--- a/source/blender/blenkernel/intern/simulation.cc
+++ b/source/blender/blenkernel/intern/simulation.cc
@@ -171,6 +171,8 @@ IDTypeInfo IDType_ID_SIM = {
/* 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 */ NULL,
};
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..efed9453003 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");
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 2ee48a13454..07532d525bd 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -212,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
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/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..a77e0ed2b7d 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -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_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 a319c55709d..b687254fd69 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -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);
}
}
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index a5418b8b8c5..249a35a0af8 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -815,8 +815,14 @@ static char *find_next_op(const char *str, char *remaining_str, int len_max)
/* 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). */
+ if ((remaining_str[i] == '/') && ELEM(remaining_str[i - 1], 't', 'T', 'm', 'M') &&
+ ELEM(remaining_str[i + 1], 's', 'S')) {
+ continue;
+ }
+
/* Check for scientific notation. */
- if (remaining_str[i - 1] == 'e' || remaining_str[i - 1] == 'E') {
+ if (ELEM(remaining_str[i - 1], 'e', 'E')) {
scientific_notation = true;
continue;
}
@@ -1178,7 +1184,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 5e6f0bb42ef..9c60cb842ae 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -633,6 +633,8 @@ 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 */ NULL,
};
void BKE_volume_init_grids(Volume *volume)
@@ -1154,6 +1156,7 @@ VolumeGrid *BKE_volume_grid_active_get(const Volume *volume)
return BKE_volume_grid_get(volume, index);
}
+/* Tries to find a grid with the given name. Make sure that that the volume has been loaded. */
VolumeGrid *BKE_volume_grid_find(const Volume *volume, const char *name)
{
int num_grids = BKE_volume_num_grids(volume);
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 52420810171..291116556c3 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -190,6 +190,8 @@ IDTypeInfo IDType_ID_WS = {
.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,
};
/* -------------------------------------------------------------------- */
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 2bd0e7b9019..b12b7ff5d1e 100644
--- a/source/blender/blenlib/BLI_args.h
+++ b/source/blender/blenlib/BLI_args.h
@@ -38,42 +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_argsAdd. */
-void BLI_argsPassSet(struct bArgs *ba, int current_pass);
+/** 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,
- 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,
- 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_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/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c
index 45061c5a150..3d4521a3304 100644
--- a/source/blender/blenlib/intern/BLI_args.c
+++ b/source/blender/blenlib/intern/BLI_args.c
@@ -111,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");
@@ -120,13 +120,13 @@ bArgs *BLI_argsInit(int argc, const char **argv)
ba->argc = argc;
ba->argv = argv;
- /* Must be initialized by #BLI_argsPassSet. */
+ /* 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);
@@ -134,13 +134,13 @@ void BLI_argsFree(struct bArgs *ba)
MEM_freeN(ba);
}
-void BLI_argsPassSet(struct bArgs *ba, int current_pass)
+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_argsPrint(struct bArgs *ba)
+void BLI_args_print(struct bArgs *ba)
{
int i;
for (i = 0; i < ba->argc; i++) {
@@ -148,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,
@@ -211,14 +206,14 @@ static void internalAdd(
BLI_ghash_insert(ba->items, key, a);
}
-void BLI_argsAddCase(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_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);
@@ -231,14 +226,14 @@ void BLI_argsAddCase(struct bArgs *ba,
}
}
-void BLI_argsAdd(struct bArgs *ba,
- 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, 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)
@@ -256,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);
@@ -269,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;
@@ -280,7 +275,7 @@ 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;
diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c
index 85d480593e5..847cb42186a 100644
--- a/source/blender/blenlib/intern/array_store.c
+++ b/source/blender/blenlib/intern/array_store.c
@@ -1313,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;
@@ -1412,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,
diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc
index 60439f27b01..568a3206b18 100644
--- a/source/blender/blenlib/intern/delaunay_2d.cc
+++ b/source/blender/blenlib/intern/delaunay_2d.cc
@@ -2008,7 +2008,7 @@ 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;
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_geom.c b/source/blender/blenlib/intern/math_geom.c
index dcdc7c4d668..1d2480f4d62 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,
@@ -5497,7 +5497,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 cf6945529f2..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];
@@ -2223,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]);
@@ -2230,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.
@@ -2275,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])
{
@@ -2305,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],
@@ -2485,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`
*/
@@ -2867,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/mesh_boolean.cc b/source/blender/blenlib/intern/mesh_boolean.cc
index bad0b84d10f..c85adf835fe 100644
--- a/source/blender/blenlib/intern/mesh_boolean.cc
+++ b/source/blender/blenlib/intern/mesh_boolean.cc
@@ -2851,7 +2851,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 a777833dff4..b1b8bd61b40 100644
--- a/source/blender/blenlib/intern/mesh_intersect.cc
+++ b/source/blender/blenlib/intern/mesh_intersect.cc
@@ -2637,8 +2637,7 @@ struct SubdivideTrisData {
tm(tm),
itt_map(itt_map),
overlap(overlap),
- arena(arena),
- overlap_tri_range{}
+ arena(arena)
{
}
};
@@ -2771,7 +2770,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..f9b6218eae5 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,14 @@ float mg_RidgedMultiFractal(float x,
}
}
- signal = offset - fabsf(noisefunc(x, y, z));
- signal *= signal;
- result = signal;
-
- for (i = 1; i < (int)octaves; i++) {
+ float result, signal = powf(offset - fabsf(noisefunc(x, y, z)), 2);
+ 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 +1661,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 +1691,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 +1700,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 +1727,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 +1737,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/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/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/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_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
index 14db4254f70..caacbf1a2c4 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;
}
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index c44bd8d0039..833a5abb630 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -33,8 +33,8 @@ set(INC
../render/extern/include
../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 004b0664fd3..bceb3cc0021 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2521,7 +2521,9 @@ static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo)
/* Undo generic endian switching. */
if (BLO_read_requires_endian_switch(reader)) {
BLI_endian_switch_int16(&ipo->blocktype);
- BLI_endian_switch_int16(&icu->driver->blocktype);
+ if (icu->driver != NULL) {
+ BLI_endian_switch_int16(&icu->driver->blocktype);
+ }
}
}
}
@@ -2658,8 +2660,8 @@ static void direct_link_constraints(BlendDataReader *reader, ListBase *lb)
case CONSTRAINT_TYPE_KINEMATIC: {
bKinematicConstraint *data = con->data;
- con->lin_error = 0.f;
- con->rot_error = 0.f;
+ 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;
@@ -4390,7 +4392,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
seq->strip->proxy->anim = NULL;
}
else if (seq->flag & SEQ_USE_PROXY) {
- BKE_sequencer_proxy_set(seq, true);
+ SEQ_proxy_set(seq, true);
}
/* need to load color balance to it could be converted to modifier */
@@ -5669,15 +5671,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);
@@ -5689,6 +5682,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);
}
@@ -6120,6 +6118,18 @@ static void lib_link_all(FileData *fd, Main *bmain)
}
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;
@@ -7058,6 +7068,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,
@@ -7103,19 +7138,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;
@@ -7161,19 +7189,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);
}
@@ -7207,23 +7228,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);
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 83cd5dfb6f3..c86ad639216 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -1166,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;
}
}
}
@@ -1501,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;
}
@@ -1516,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;
@@ -1836,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 6642749d907..c33f2a8cad5 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -2066,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_280.c b/source/blender/blenloader/intern/versioning_280.c
index 472400998b1..0b7830c922a 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2100,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));
}
@@ -3420,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;
}
@@ -3494,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;
}
@@ -3663,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);
}
@@ -4079,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")) {
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 37987b2c31d..fab4ce6727f 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -44,12 +44,14 @@
#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"
@@ -59,12 +61,154 @@
#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)) {
@@ -292,6 +436,31 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
}
}
+ 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.
*
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 2659cc13bcc..9178ec97d3d 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -1253,7 +1253,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;
}
}
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 6b6d226bd90..d152230e4bf 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -800,6 +800,14 @@ 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;
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
@@ -813,10 +821,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 95cfeef4243..e4995c991e1 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1639,12 +1639,6 @@ static void write_windowmanager(BlendWriter *writer, wmWindowManager *wm, const
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);
@@ -1652,11 +1646,7 @@ static void write_windowmanager(BlendWriter *writer, wmWindowManager *wm, const
BLO_write_struct(writer, WorkSpaceInstanceHook, win->workspace_hook);
BLO_write_struct(writer, Stereo3dFormat, win->stereo3d_format);
-#ifdef WITH_GLOBAL_AREA_WRITING
BKE_screen_area_map_blend_write(writer, &win->global_areas);
-#else
- win->global_areas = global_areas;
-#endif
/* data is written, clear deprecated data again */
win->screen = NULL;
diff --git a/source/blender/blenloader/tests/blendfile_loading_base_test.cc b/source/blender/blenloader/tests/blendfile_loading_base_test.cc
index e34be68abbf..cb5fcdbe3c6 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;
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_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_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 8132230334b..7d56e560275 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -983,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 {
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/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 3a6ae9883e2..ce58b8b8382 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -59,6 +59,8 @@
#define BEVEL_SMALL_ANG DEG2RADF(10.0f)
/** Difference in dot products that corresponds to 10 degree difference between vectors. */
#define BEVEL_SMALL_ANG_DOT 1 - cosf(BEVEL_SMALL_ANG)
+/** Difference in dot products that corresponds to 2.0 degree difference between vectors. */
+#define BEVEL_EPSILON_ANG_DOT 1 - cosf(BEVEL_EPSILON_ANG)
#define BEVEL_MAX_ADJUST_PCT 10.0f
#define BEVEL_MAX_AUTO_ADJUST_PCT 300.0f
#define BEVEL_MATCH_SPEC_WEIGHT 0.2
@@ -301,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 {
@@ -432,6 +434,18 @@ static bool nearly_parallel(const float d1[3], const float d2[3])
return (fabsf(ang) < BEVEL_EPSILON_ANG) || (fabsf(ang - (float)M_PI) < BEVEL_EPSILON_ANG);
}
+/**
+ * \return True if d1 and d2 are parallel or nearly parallel.
+ */
+static bool nearly_parallel_normalized(const float d1[3], const float d2[3])
+{
+ BLI_ASSERT_UNIT_V3(d1);
+ BLI_ASSERT_UNIT_V3(d2);
+
+ const float direction_dot = dot_v3v3(d1, d2);
+ return compare_ff(fabsf(direction_dot), 1.0f, BEVEL_EPSILON_ANG_DOT);
+}
+
/* Make a new BoundVert of the given kind, inserting it at the end of the circular linked
* list with entry point bv->boundstart, and return it. */
static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, const float co[3])
@@ -1087,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);
@@ -1096,6 +1110,12 @@ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v)
sub_v3_v3v3(dir2, v->co, v2->co);
normalize_v3(dir1);
normalize_v3(dir2);
+
+ /* First check for in-line edges using a simpler test. */
+ if (nearly_parallel_normalized(dir1, dir2)) {
+ return ANGLE_STRAIGHT;
+ }
+
/* Angles are in [0,pi]. Need to compare cross product with normal to see if they are reflex. */
float cross[3];
cross_v3_v3v3(cross, dir1, dir2);
@@ -1110,11 +1130,8 @@ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v)
else {
no = v->no;
}
- float dot = dot_v3v3(cross, no);
- if (fabsf(dot) < BEVEL_EPSILON_BIG) {
- return ANGLE_STRAIGHT;
- }
- if (dot < 0.0f) {
+
+ if (dot_v3v3(cross, no) < 0.0f) {
return ANGLE_LARGER;
}
return ANGLE_SMALLER;
@@ -1382,7 +1399,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 {
@@ -1539,7 +1556,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);
@@ -2141,7 +2158,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;
@@ -2424,7 +2441,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;
@@ -3010,7 +3027,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,
@@ -3088,7 +3105,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) {
@@ -4551,13 +4568,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);
@@ -4568,9 +4585,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);
}
}
@@ -4602,7 +4619,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);
@@ -4911,7 +4928,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);
}
@@ -6212,7 +6229,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) {
@@ -6754,7 +6771,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);
}
}
@@ -7215,7 +7232,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_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/compositor/intern/COM_CPUDevice.cpp b/source/blender/compositor/intern/COM_CPUDevice.cpp
index bcb14e4dbb2..26fe1ba0bc3 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)
{
}
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index 60676ee42b7..15a52d10071 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -116,12 +116,19 @@
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)
diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
index 029be6d44b1..98239166860 100644
--- a/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
+++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_SingleThreadedOperation.h"
-SingleThreadedOperation::SingleThreadedOperation() : NodeOperation()
+SingleThreadedOperation::SingleThreadedOperation()
{
this->m_cachedInstance = NULL;
setComplex(true);
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp
index a0ccaf0b9da..53cf64c5c3f 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.cpp
+++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp
@@ -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));
}
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..e1e58c9521a 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
@@ -112,7 +112,7 @@ static int extrapolate9(float *E0,
#undef PCPY
}
-AntiAliasOperation::AntiAliasOperation() : NodeOperation()
+AntiAliasOperation::AntiAliasOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
index 8168867a522..93193aef360 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
@@ -21,7 +21,7 @@
#include "RE_pipeline.h"
-BilateralBlurOperation::BilateralBlurOperation() : NodeOperation()
+BilateralBlurOperation::BilateralBlurOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index ef0f259c592..0d9a1a184d6 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -22,7 +22,7 @@
#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);
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
index c00ef2468c0..987c5946e48 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);
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
index 3fd9a77d879..be3f637e4bb 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;
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
index c5f0108bf5a..d7d779ed0bb 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
@@ -20,7 +20,7 @@
#include "BLI_math.h"
#include "DNA_node_types.h"
-BoxMaskOperation::BoxMaskOperation() : NodeOperation()
+BoxMaskOperation::BoxMaskOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
index b6c22029899..c72d227138d 100644
--- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_BrightnessOperation.h"
-BrightnessOperation::BrightnessOperation() : NodeOperation()
+BrightnessOperation::BrightnessOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
index ecd61e95f43..115d415a8f8 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
@@ -22,7 +22,7 @@
#include "IMB_colormanagement.h"
-CalculateMeanOperation::CalculateMeanOperation() : NodeOperation()
+CalculateMeanOperation::CalculateMeanOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
index 059040d6f05..476626ffcb6 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 */
}
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
index ddbc400777f..b7ee3ad6de3 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_ChangeHSVOperation.h"
-ChangeHSVOperation::ChangeHSVOperation() : NodeOperation()
+ChangeHSVOperation::ChangeHSVOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
index cbd46ea71f8..8dcee8c6070 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_ChannelMatteOperation.h"
#include "BLI_math.h"
-ChannelMatteOperation::ChannelMatteOperation() : NodeOperation()
+ChannelMatteOperation::ChannelMatteOperation()
{
addInputSocket(COM_DT_COLOR);
addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
index 62dc74d2092..c55f434801d 100644
--- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_ChromaMatteOperation.h"
#include "BLI_math.h"
-ChromaMatteOperation::ChromaMatteOperation() : NodeOperation()
+ChromaMatteOperation::ChromaMatteOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
index a515b9a6a67..91418c47665 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
@@ -31,7 +31,7 @@ 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);
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
index 1578a805d1e..849540db1fc 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
@@ -36,7 +36,7 @@ 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);
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
index 893c052831c..d99444344bd 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
@@ -21,7 +21,7 @@
#include "IMB_colormanagement.h"
-ColorCorrectionOperation::ColorCorrectionOperation() : NodeOperation()
+ColorCorrectionOperation::ColorCorrectionOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
index 9d514c872f7..8bdaa8ec28b 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);
@@ -98,7 +98,7 @@ void ColorCurveOperation::deinitExecution()
// Constant level curve mapping
-ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation() : CurveBaseOperation()
+ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
index 90b7f4a63b5..e3aa3aef5a4 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_ColorMatteOperation.h"
#include "BLI_math.h"
-ColorMatteOperation::ColorMatteOperation() : NodeOperation()
+ColorMatteOperation::ColorMatteOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
index 95e0bd2d82b..e7f5ca1af5e 100644
--- a/source/blender/compositor/operations/COM_ColorRampOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
@@ -20,7 +20,7 @@
#include "BKE_colorband.h"
-ColorRampOperation::ColorRampOperation() : NodeOperation()
+ColorRampOperation::ColorRampOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
index 99ab6105934..4356eb4b745 100644
--- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
@@ -20,7 +20,7 @@
#include "BLI_math.h"
#define AVG(a, b) ((a + b) / 2)
-ColorSpillOperation::ColorSpillOperation() : NodeOperation()
+ColorSpillOperation::ColorSpillOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index 8d55fe53aa7..63e7817606f 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -32,7 +32,7 @@
#include "PIL_time.h"
-CompositorOperation::CompositorOperation() : NodeOperation()
+CompositorOperation::CompositorOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
index 6a4c5db856c..39143aaf3b8 100644
--- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
@@ -20,7 +20,7 @@
#include "IMB_imbuf.h"
-ConvertColorProfileOperation::ConvertColorProfileOperation() : NodeOperation()
+ConvertColorProfileOperation::ConvertColorProfileOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
index 1a1ea794d24..56c4fb44d4f 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
@@ -21,7 +21,7 @@
#include "BLI_math.h"
#include "DNA_camera_types.h"
-ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation() : NodeOperation()
+ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.cpp b/source/blender/compositor/operations/COM_ConvertOperation.cpp
index 0bd3f5b8796..dae4a9f1bab 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertOperation.cpp
@@ -397,7 +397,7 @@ void ConvertStraightToPremulOperation::executePixelSampled(float output[4],
/* ******** Separate Channels ******** */
-SeparateChannelOperation::SeparateChannelOperation() : NodeOperation()
+SeparateChannelOperation::SeparateChannelOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VALUE);
@@ -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);
diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
index 1439c7abb45..1932098fd30 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 */
}
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
index 3f47bfda618..fabde28d7a2 100644
--- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
@@ -22,7 +22,7 @@
#include "MEM_guardedalloc.h"
-ConvolutionFilterOperation::ConvolutionFilterOperation() : NodeOperation()
+ConvolutionFilterOperation::ConvolutionFilterOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp
index 625490dd3ab..3dda1a94989 100644
--- a/source/blender/compositor/operations/COM_CropOperation.cpp
+++ b/source/blender/compositor/operations/COM_CropOperation.cpp
@@ -19,7 +19,7 @@
#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);
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..5cfea97475a 100644
--- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
@@ -20,7 +20,7 @@
#include "BKE_colortools.h"
-CurveBaseOperation::CurveBaseOperation() : NodeOperation()
+CurveBaseOperation::CurveBaseOperation()
{
this->m_curveMapping = NULL;
}
diff --git a/source/blender/compositor/operations/COM_DenoiseOperation.cpp b/source/blender/compositor/operations/COM_DenoiseOperation.cpp
index 4087056a79d..97e2dba5e18 100644
--- a/source/blender/compositor/operations/COM_DenoiseOperation.cpp
+++ b/source/blender/compositor/operations/COM_DenoiseOperation.cpp
@@ -26,7 +26,7 @@ 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);
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
index 9b8d72da26d..5d8481562ab 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
@@ -22,7 +22,7 @@
#include "BLI_utildefines.h"
-DespeckleOperation::DespeckleOperation() : NodeOperation()
+DespeckleOperation::DespeckleOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
index ea3526eb7e0..92a804ec3ec 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_DifferenceMatteOperation.h"
#include "BLI_math.h"
-DifferenceMatteOperation::DifferenceMatteOperation() : NodeOperation()
+DifferenceMatteOperation::DifferenceMatteOperation()
{
addInputSocket(COM_DT_COLOR);
addInputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
index 52bc00e9b84..0fbdb37081b 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
@@ -23,7 +23,7 @@
#include "MEM_guardedalloc.h"
// DilateErode Distance Threshold
-DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation()
+DilateErodeThresholdOperation::DilateErodeThresholdOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
@@ -159,7 +159,7 @@ bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(
}
// Dilate Distance
-DilateDistanceOperation::DilateDistanceOperation() : NodeOperation()
+DilateDistanceOperation::DilateDistanceOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
@@ -317,7 +317,7 @@ void ErodeDistanceOperation::executeOpenCL(OpenCLDevice *device,
}
// Dilate step
-DilateStepOperation::DilateStepOperation() : NodeOperation()
+DilateStepOperation::DilateStepOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
index 31eb74fbc42..efe40cc8b58 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
@@ -23,7 +23,7 @@
#include "RE_pipeline.h"
-DirectionalBlurOperation::DirectionalBlurOperation() : NodeOperation()
+DirectionalBlurOperation::DirectionalBlurOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
index 73790447216..31b4d41320f 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);
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
index 32eb5679d9d..10d274b6fc5 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);
diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
index ff337455658..23e133ad711 100644
--- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_DistanceRGBMatteOperation.h"
#include "BLI_math.h"
-DistanceRGBMatteOperation::DistanceRGBMatteOperation() : NodeOperation()
+DistanceRGBMatteOperation::DistanceRGBMatteOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
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..263a7060a49 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.cpp
+++ b/source/blender/compositor/operations/COM_DotproductOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_DotproductOperation.h"
-DotproductOperation::DotproductOperation() : NodeOperation()
+DotproductOperation::DotproductOperation()
{
this->addInputSocket(COM_DT_VECTOR);
this->addInputSocket(COM_DT_VECTOR);
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
index 95ccb462ade..de60e53d3d0 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
@@ -1306,7 +1306,7 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float
}
}
-DoubleEdgeMaskOperation::DoubleEdgeMaskOperation() : NodeOperation()
+DoubleEdgeMaskOperation::DoubleEdgeMaskOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
index 0dc42b3457f..1dc1b0e2be6 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
@@ -20,7 +20,7 @@
#include "BLI_math.h"
#include "DNA_node_types.h"
-EllipseMaskOperation::EllipseMaskOperation() : NodeOperation()
+EllipseMaskOperation::EllipseMaskOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index 0ccb959712f..0387f495f0c 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -256,7 +256,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
}
///
-FastGaussianBlurValueOperation::FastGaussianBlurValueOperation() : NodeOperation()
+FastGaussianBlurValueOperation::FastGaussianBlurValueOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_FlipOperation.cpp b/source/blender/compositor/operations/COM_FlipOperation.cpp
index 57b686986b7..f248133d389 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.cpp
+++ b/source/blender/compositor/operations/COM_FlipOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_FlipOperation.h"
-FlipOperation::FlipOperation() : NodeOperation()
+FlipOperation::FlipOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
index 36272c05774..a333ca18fc2 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_GammaCorrectOperation.h"
#include "BLI_math.h"
-GammaCorrectOperation::GammaCorrectOperation() : NodeOperation()
+GammaCorrectOperation::GammaCorrectOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -61,7 +61,7 @@ void GammaCorrectOperation::deinitExecution()
this->m_inputProgram = NULL;
}
-GammaUncorrectOperation::GammaUncorrectOperation() : NodeOperation()
+GammaUncorrectOperation::GammaUncorrectOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_GammaOperation.cpp b/source/blender/compositor/operations/COM_GammaOperation.cpp
index ee6b42c349f..af483e612f0 100644
--- a/source/blender/compositor/operations/COM_GammaOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_GammaOperation.h"
#include "BLI_math.h"
-GammaOperation::GammaOperation() : NodeOperation()
+GammaOperation::GammaOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
index 278e65a7dfd..633b4821358 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_GlareBaseOperation.h"
#include "BLI_math.h"
-GlareBaseOperation::GlareBaseOperation() : SingleThreadedOperation()
+GlareBaseOperation::GlareBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
index d050d9b58a9..e61d4e8d8a7 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
@@ -21,7 +21,7 @@
#include "IMB_colormanagement.h"
-GlareThresholdOperation::GlareThresholdOperation() : NodeOperation()
+GlareThresholdOperation::GlareThresholdOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_FIT);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
index 8292413f6f1..1d9c493d52b 100644
--- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
@@ -22,7 +22,7 @@
#include "BKE_colortools.h"
-HueSaturationValueCorrectOperation::HueSaturationValueCorrectOperation() : CurveBaseOperation()
+HueSaturationValueCorrectOperation::HueSaturationValueCorrectOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
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..73c560ca473 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_ImageOperation.cpp
@@ -31,7 +31,7 @@
#include "RE_render_ext.h"
#include "RE_shader_ext.h"
-BaseImageOperation::BaseImageOperation() : NodeOperation()
+BaseImageOperation::BaseImageOperation()
{
this->m_image = NULL;
this->m_buffer = NULL;
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp
index 0555ee24b9b..335af3a8287 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.cpp
+++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp
@@ -27,7 +27,7 @@
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);
diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp
index bfd9d14a1ef..f0d677d3d2f 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_InvertOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_InvertOperation.h"
-InvertOperation::InvertOperation() : NodeOperation()
+InvertOperation::InvertOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
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..97eea6267b0 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);
diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp
index 50562143ce6..dfc433dcfc6 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);
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
index 082091411fb..36093a931d0 100644
--- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
@@ -30,7 +30,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-KeyingScreenOperation::KeyingScreenOperation() : NodeOperation()
+KeyingScreenOperation::KeyingScreenOperation()
{
this->addOutputSocket(COM_DT_COLOR);
this->m_movieClip = NULL;
diff --git a/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp b/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp
index dff88d49e80..8e501838d7b 100644
--- a/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_KeyingSetAlphaOperation.h"
-KeyingSetAlphaOperation::KeyingSetAlphaOperation() : NodeOperation()
+KeyingSetAlphaOperation::KeyingSetAlphaOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
index 936ac00a0e8..50de043b641 100644
--- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
@@ -21,7 +21,7 @@
#include "IMB_colormanagement.h"
-LuminanceMatteOperation::LuminanceMatteOperation() : NodeOperation()
+LuminanceMatteOperation::LuminanceMatteOperation()
{
addInputSocket(COM_DT_COLOR);
addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
index ff5804a63a4..e4fe6065164 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);
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp
index 9101b82202a..ed250bc28b6 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);
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp
index 45104d11210..908ad7f1317 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_MapValueOperation.h"
-MapValueOperation::MapValueOperation() : NodeOperation()
+MapValueOperation::MapValueOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp
index 9fc7448ce42..7c21ee5d757 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_MaskOperation.cpp
@@ -26,7 +26,7 @@
#include "BKE_lib_id.h"
#include "BKE_mask.h"
-MaskOperation::MaskOperation() : NodeOperation()
+MaskOperation::MaskOperation()
{
this->addOutputSocket(COM_DT_VALUE);
this->m_mask = NULL;
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index 1363b75433a..c37874c7c9b 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -20,7 +20,7 @@
#include "BLI_math.h"
-MathBaseOperation::MathBaseOperation() : NodeOperation()
+MathBaseOperation::MathBaseOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_MixOperation.cpp b/source/blender/compositor/operations/COM_MixOperation.cpp
index 371da20044f..376e27b1f30 100644
--- a/source/blender/compositor/operations/COM_MixOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixOperation.cpp
@@ -22,7 +22,7 @@
/* ******** Mix Base Operation ******** */
-MixBaseOperation::MixBaseOperation() : NodeOperation()
+MixBaseOperation::MixBaseOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
@@ -97,7 +97,7 @@ void MixBaseOperation::deinitExecution()
/* ******** 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..f4e860316b3 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;
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
index 17794ae879e..9d1779b3573 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
@@ -26,7 +26,7 @@
#include "IMB_imbuf.h"
-MovieClipBaseOperation::MovieClipBaseOperation() : NodeOperation()
+MovieClipBaseOperation::MovieClipBaseOperation()
{
this->m_movieClip = NULL;
this->m_movieClipBuffer = NULL;
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
index 67491d51547..5accf9a2dc3 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
@@ -23,7 +23,7 @@
#include "BLI_linklist.h"
-MovieDistortionOperation::MovieDistortionOperation(bool distortion) : NodeOperation()
+MovieDistortionOperation::MovieDistortionOperation(bool distortion)
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
index 8878b05ade7..952225d5fb7 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;
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.cpp b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
index 55faa480b83..1e7986c6009 100644
--- a/source/blender/compositor/operations/COM_NormalizeOperation.cpp
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_NormalizeOperation.h"
-NormalizeOperation::NormalizeOperation() : NodeOperation()
+NormalizeOperation::NormalizeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_PixelateOperation.cpp b/source/blender/compositor/operations/COM_PixelateOperation.cpp
index 18e691d3c34..01cd7fcfd97 100644
--- a/source/blender/compositor/operations/COM_PixelateOperation.cpp
+++ b/source/blender/compositor/operations/COM_PixelateOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_PixelateOperation.h"
-PixelateOperation::PixelateOperation(DataType datatype) : NodeOperation()
+PixelateOperation::PixelateOperation(DataType datatype)
{
this->addInputSocket(datatype);
this->addOutputSocket(datatype);
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..0f6d5d0d4d7 100644
--- a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp
@@ -44,7 +44,7 @@ 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);
@@ -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.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..46ac466fd19 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cpp
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -35,7 +35,7 @@
PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings,
const ColorManagedDisplaySettings *displaySettings)
- : NodeOperation()
+
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->m_preview = NULL;
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
index 32933f1b966..921b7ed474c 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
@@ -20,7 +20,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOperation()
+ProjectorLensDistortionOperation::ProjectorLensDistortionOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
index 99cc9f5dd01..9139ac200c8 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
@@ -20,7 +20,7 @@
#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;
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
index c8a68c70c4d..b7b1da1bb89 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@ -29,7 +29,7 @@
/* ******** 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;
diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp
index 3ccf36cec2c..e25d5af1aed 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.cpp
+++ b/source/blender/compositor/operations/COM_RotateOperation.cpp
@@ -19,7 +19,7 @@
#include "COM_RotateOperation.h"
#include "BLI_math.h"
-RotateOperation::RotateOperation() : NodeOperation()
+RotateOperation::RotateOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
index b7731a34c91..4b92be65b3e 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -24,7 +24,7 @@
#include "PIL_time.h"
-ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation()
+ScreenLensDistortionOperation::ScreenLensDistortionOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
index 68c165411b2..cc4e4a562db 100644
--- a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_SetAlphaOperation.h"
-SetAlphaOperation::SetAlphaOperation() : NodeOperation()
+SetAlphaOperation::SetAlphaOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
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..3c6a5104352 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);
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..cace3b40b44 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.cpp
+++ b/source/blender/compositor/operations/COM_SplitOperation.cpp
@@ -27,7 +27,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-SplitOperation::SplitOperation() : NodeOperation()
+SplitOperation::SplitOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
index 4a7139537c1..ef3c0700119 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);
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index 07316280bbc..5a8c40d8c8c 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -25,7 +25,7 @@
#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
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp
index 59354ff7581..2e330e287b2 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.cpp
+++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp
@@ -22,7 +22,7 @@
#include "IMB_colormanagement.h"
-TonemapOperation::TonemapOperation() : NodeOperation()
+TonemapOperation::TonemapOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
index 5c4f3b99f58..eca87a7b5a3 100644
--- a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
+++ b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
@@ -28,7 +28,7 @@
#include "BKE_node.h"
#include "BKE_tracking.h"
-TrackPositionOperation::TrackPositionOperation() : NodeOperation()
+TrackPositionOperation::TrackPositionOperation()
{
this->addOutputSocket(COM_DT_VALUE);
this->m_movieClip = NULL;
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp
index b45e6a2b6a1..e92d1034e25 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.cpp
+++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp
@@ -18,7 +18,7 @@
#include "COM_TranslateOperation.h"
-TranslateOperation::TranslateOperation() : NodeOperation()
+TranslateOperation::TranslateOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 057dc553f7f..afc318a0c5b 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.
@@ -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..4f41a60f3c3 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -43,7 +43,7 @@ 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
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
index 61312355a39..a78a8c47ea3 100644
--- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
@@ -20,7 +20,7 @@
#include "BKE_colortools.h"
-VectorCurveOperation::VectorCurveOperation() : CurveBaseOperation()
+VectorCurveOperation::VectorCurveOperation()
{
this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(COM_DT_VECTOR);
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index e1d891559a7..254d6975bee 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -32,7 +32,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-ViewerOperation::ViewerOperation() : NodeOperation()
+ViewerOperation::ViewerOperation()
{
this->setImage(NULL);
this->setImageUser(NULL);
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..883dd48ccfe 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
@@ -21,7 +21,7 @@
#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);
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
index 767280e2cd2..935272e0dbe 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);
@@ -95,7 +95,7 @@ void ZCombineOperation::deinitExecution()
}
// MASK combine
-ZCombineMaskOperation::ZCombineMaskOperation() : NodeOperation()
+ZCombineMaskOperation::ZCombineMaskOperation()
{
this->addInputSocket(COM_DT_VALUE); // mask
this->addInputSocket(COM_DT_COLOR);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index a739e9cc46b..a04a33d8cfa 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -1200,7 +1200,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);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index af281c3f0cf..40b856b1896 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -743,7 +743,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). */
@@ -1854,7 +1854,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. */
@@ -2814,8 +2814,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
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..17f364118ae 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_drivers.cc
@@ -39,9 +39,7 @@ namespace blender {
namespace 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_(),
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index 18b24179edf..442537bd79a 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -209,8 +209,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 +324,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;
}
diff --git a/source/blender/depsgraph/intern/builder/pipeline.cc b/source/blender/depsgraph/intern/builder/pipeline.cc
index b13077e4792..76b6f17a243 100644
--- a/source/blender/depsgraph/intern/builder/pipeline.cc
+++ b/source/blender/depsgraph/intern/builder/pipeline.cc
@@ -37,8 +37,7 @@ 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)
{
}
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 868f88d8fcd..8055e65595b 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -308,7 +308,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;
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index 5ccdcbec858..73e35b4c77a 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -145,8 +145,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;
}
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc
index 8d19949adc8..53269544afa 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_id.cc
@@ -137,7 +137,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;
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 4904f34a00b..b515ea9c625 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -1058,6 +1058,7 @@ static void eevee_lightbake_render_grid_sample(void *ved, void *user_data)
/* Disable specular lighting when rendering probes to avoid feedback loops (looks bad). */
common_data->spec_toggle = false;
+ common_data->sss_toggle = false;
common_data->prb_num_planar = 0;
common_data->prb_num_render_cube = 0;
common_data->ray_type = EEVEE_RAY_DIFFUSE;
@@ -1127,6 +1128,7 @@ static void eevee_lightbake_render_probe_sample(void *ved, void *user_data)
/* Disable specular lighting when rendering probes to avoid feedback loops (looks bad). */
common_data->spec_toggle = false;
+ common_data->sss_toggle = false;
common_data->prb_num_planar = 0;
common_data->prb_num_render_cube = 0;
common_data->ray_type = EEVEE_RAY_GLOSSY;
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_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index f60c2661cb0..530becfe771 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -490,7 +490,7 @@ void EEVEE_motion_blur_swap_data(EEVEE_Data *vedata)
BLI_assert((effects->enabled_effects & EFFECT_MOTION_BLUR) != 0);
/* Camera Data. */
- effects->motion_blur.camera[MB_PREV] = effects->motion_blur.camera[MB_CURR];
+ effects->motion_blur.camera[MB_PREV] = effects->motion_blur.camera[MB_NEXT];
/* Object Data. */
for (BLI_ghashIterator_init(&ghi, effects->motion_blur.object);
@@ -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_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index e5dac6423c4..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);
}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl
index 145939cefb2..9182171bab4 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl
@@ -13,16 +13,19 @@ void main()
{
/* Extract pixel motion vector from camera movement. */
ivec2 texel = ivec2(gl_FragCoord.xy);
- vec2 uv = gl_FragCoord.xy / vec2(textureSize(depthBuffer, 0).xy);
+ vec2 uv_curr = gl_FragCoord.xy / vec2(textureSize(depthBuffer, 0).xy);
float depth = texelFetch(depthBuffer, texel, 0).r;
- vec3 world_position = project_point(currViewProjMatrixInv, vec3(uv, depth) * 2.0 - 1.0);
- vec2 uv_prev = project_point(prevViewProjMatrix, world_position).xy * 0.5 + 0.5;
- vec2 uv_next = project_point(nextViewProjMatrix, world_position).xy * 0.5 + 0.5;
+ uv_curr = uv_curr * 2.0 - 1.0;
+ depth = depth * 2.0 - 1.0;
- outData.xy = uv_prev - uv;
- outData.zw = uv_next - uv;
+ vec3 world_position = project_point(currViewProjMatrixInv, vec3(uv_curr, depth));
+ vec2 uv_prev = project_point(prevViewProjMatrix, world_position).xy;
+ vec2 uv_next = project_point(nextViewProjMatrix, world_position).xy;
+
+ outData.xy = uv_prev - uv_curr;
+ outData.zw = uv_next - uv_curr;
/* Encode to unsigned normalized 16bit texture. */
outData = outData * 0.5 + 0.5;
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.c b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
index 4361f6f9b51..18ca2e4ccc9 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_data.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
@@ -371,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/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c
index 30b39e5d5e1..e49b2e45580 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -509,6 +509,11 @@ static void OVERLAY_draw_scene(void *vedata)
OVERLAY_FramebufferList *fbl = data->fbl;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
+ /* Needs to be done first as it modifies the scene color and depth buffer. */
+ if (!pd->is_image_editor) {
+ OVERLAY_image_scene_background_draw(vedata);
+ }
+
if (DRW_state_is_fbo()) {
const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
GPU_framebuffer_bind(dfbl->overlay_only_fb);
diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c
index 09061450a1a..adb0dc22e16 100644
--- a/source/blender/draw/engines/overlay/overlay_extra.c
+++ b/source/blender/draw/engines/overlay/overlay_extra.c
@@ -1586,10 +1586,13 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob)
const bool draw_xform = draw_ctx->object_mode == OB_MODE_OBJECT &&
(scene->toolsettings->transform_flag & SCE_XFORM_DATA_ORIGIN) &&
(ob->base_flag & BASE_SELECTED) && !is_select_mode;
+ /* Don't show fluid domain overlay extras outside of cache range. */
const bool draw_volume = !from_dupli &&
(md = BKE_modifiers_findby_type(ob, eModifierType_Fluid)) &&
(BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) &&
- (((FluidModifierData *)md)->domain != NULL);
+ (((FluidModifierData *)md)->domain != NULL) &&
+ (CFRA >= (((FluidModifierData *)md)->domain->cache_frame_start)) &&
+ (CFRA <= (((FluidModifierData *)md)->domain->cache_frame_end));
float *color;
int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color);
diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.c
index 08cddf4e185..9695f8616a5 100644
--- a/source/blender/draw/engines/overlay/overlay_image.c
+++ b/source/blender/draw/engines/overlay/overlay_image.c
@@ -57,6 +57,8 @@ void OVERLAY_image_cache_init(OVERLAY_Data *vedata)
state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_GREATER | DRW_STATE_BLEND_ALPHA_PREMUL;
DRW_PASS_CREATE(psl->image_background_ps, state);
+ state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_UNDER_PREMUL;
+ DRW_PASS_CREATE(psl->image_background_scene_ps, state);
state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
DRW_PASS_CREATE(psl->image_empties_ps, state | pd->clipping_state);
@@ -68,6 +70,7 @@ void OVERLAY_image_cache_init(OVERLAY_Data *vedata)
state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_PREMUL;
DRW_PASS_CREATE(psl->image_empties_front_ps, state);
DRW_PASS_CREATE(psl->image_foreground_ps, state);
+ DRW_PASS_CREATE(psl->image_foreground_scene_ps, state);
}
static void overlay_image_calc_aspect(Image *ima, const int size[2], float r_image_aspect[2])
@@ -136,7 +139,8 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
const DRWContextState *draw_ctx,
OVERLAY_PrivateData *pd,
float *r_aspect,
- bool *r_use_alpha_premult)
+ bool *r_use_alpha_premult,
+ bool *r_use_view_transform)
{
void *lock;
Image *image = bgpic->ima;
@@ -148,6 +152,7 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
int width, height;
int ctime = (int)DEG_get_ctime(draw_ctx->depsgraph);
*r_use_alpha_premult = false;
+ *r_use_view_transform = false;
switch (bgpic->source) {
case CAM_BGIMG_SOURCE_IMAGE:
@@ -155,6 +160,7 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
return NULL;
}
*r_use_alpha_premult = (image->alpha_mode == IMA_ALPHA_PREMUL);
+ *r_use_view_transform = (image->flag & IMA_VIEW_AS_RENDER) != 0;
BKE_image_user_frame_calc(image, iuser, ctime);
if (image->source == IMA_SRC_SEQUENCE && !(iuser->flag & IMA_USER_FRAME_IN_RANGE)) {
@@ -183,7 +189,6 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
aspect_x = bgpic->ima->aspx;
aspect_y = bgpic->ima->aspy;
-
break;
case CAM_BGIMG_SOURCE_MOVIE:
@@ -208,6 +213,7 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
aspect_x = clip->aspx;
aspect_y = clip->aspy;
+ *r_use_view_transform = true;
BKE_movieclip_get_size(clip, &bgpic->cuser, &width, &height);
@@ -328,21 +334,27 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob)
float aspect = 1.0;
bool use_alpha_premult;
+ bool use_view_transform = false;
float mat[4][4];
/* retrieve the image we want to show, continue to next when no image could be found */
GPUTexture *tex = image_camera_background_texture_get(
- bgpic, draw_ctx, pd, &aspect, &use_alpha_premult);
+ bgpic, draw_ctx, pd, &aspect, &use_alpha_premult, &use_view_transform);
if (tex) {
image_camera_background_matrix_get(cam, bgpic, draw_ctx, aspect, mat);
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
+ * 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. */
+ const float color_premult_alpha[4] = {1.0f, 1.0f, 1.0f, MIN2(bgpic->alpha, 0.999999)};
- const float color_premult_alpha[4] = {1.0f, 1.0f, 1.0f, bgpic->alpha};
-
- DRWPass *pass = is_foreground ? psl->image_foreground_ps : psl->image_background_ps;
+ DRWPass *pass = is_foreground ? (use_view_transform ? psl->image_foreground_scene_ps :
+ psl->image_foreground_ps) :
+ (use_view_transform ? psl->image_background_scene_ps :
+ psl->image_background_ps);
GPUShader *sh = OVERLAY_shader_image();
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
@@ -449,6 +461,22 @@ void OVERLAY_image_cache_finish(OVERLAY_Data *vedata)
DRW_pass_sort_shgroup_z(psl->image_empties_back_ps);
}
+/* This function draws images that needs the view transform applied.
+ * It draws these images directly into the scene color buffer. */
+void OVERLAY_image_scene_background_draw(OVERLAY_Data *vedata)
+{
+ OVERLAY_PassList *psl = vedata->psl;
+
+ if (DRW_state_is_fbo() && (!DRW_pass_is_empty(psl->image_background_scene_ps) ||
+ !DRW_pass_is_empty(psl->image_foreground_scene_ps))) {
+ const DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
+ GPU_framebuffer_bind(dfbl->default_fb);
+
+ DRW_draw_pass(psl->image_background_scene_ps);
+ DRW_draw_pass(psl->image_foreground_scene_ps);
+ }
+}
+
void OVERLAY_image_background_draw(OVERLAY_Data *vedata)
{
OVERLAY_PassList *psl = vedata->psl;
diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h
index ef7a2db476c..d5ba0a5423f 100644
--- a/source/blender/draw/engines/overlay/overlay_private.h
+++ b/source/blender/draw/engines/overlay/overlay_private.h
@@ -103,11 +103,13 @@ typedef struct OVERLAY_PassList {
DRWPass *fade_ps[2];
DRWPass *grid_ps;
DRWPass *image_background_ps;
+ DRWPass *image_background_scene_ps;
DRWPass *image_empties_ps;
DRWPass *image_empties_back_ps;
DRWPass *image_empties_blend_ps;
DRWPass *image_empties_front_ps;
DRWPass *image_foreground_ps;
+ DRWPass *image_foreground_scene_ps;
DRWPass *metaball_ps[2];
DRWPass *motion_paths_ps;
DRWPass *outlines_prepass_ps;
@@ -592,6 +594,7 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob);
void OVERLAY_image_cache_finish(OVERLAY_Data *vedata);
void OVERLAY_image_draw(OVERLAY_Data *vedata);
void OVERLAY_image_background_draw(OVERLAY_Data *vedata);
+void OVERLAY_image_scene_background_draw(OVERLAY_Data *vedata);
void OVERLAY_image_in_front_draw(OVERLAY_Data *vedata);
void OVERLAY_metaball_cache_init(OVERLAY_Data *vedata);
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 6f40e04ab7e..fbe71900915 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -347,6 +347,7 @@ typedef enum {
/** Use dual source blending. WARNING: Only one color buffer allowed. */
DRW_STATE_BLEND_CUSTOM = (9 << 11),
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),
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 52e7e91a995..dd2617342e1 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -1694,8 +1694,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 +2389,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 +2463,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_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c
index ff1efccd507..7766ce906b8 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -902,12 +902,16 @@ static void extract_tris_finish(const MeshRenderData *mr,
MeshExtract_Tri_Data *data = _data;
GPU_indexbuf_build_in_place(&data->elb, ibo);
- /* HACK: Create ibo sub-ranges and assign them to each #GPUBatch. */
- /* The `surface_per_mat` tests are there when object shading type is set to Wire or Bounds. In
- * these cases there isn't a surface per material. */
- if (mr->use_final_mesh && cache->surface_per_mat && cache->surface_per_mat[0]) {
+ /* Create ibo sub-ranges. Always do this to avoid error when the standard surface batch
+ * is created before the surfaces-per-material. */
+ if (mr->use_final_mesh && cache->final.tris_per_mat) {
MeshBufferCache *mbc = &cache->final;
for (int i = 0; i < mr->mat_len; i++) {
+ /* Theses IBOs have not been queried yet but we create them just in case they are needed
+ * later since they are not tracked by mesh_buffer_cache_create_requested(). */
+ if (mbc->tris_per_mat[i] == NULL) {
+ mbc->tris_per_mat[i] = GPU_indexbuf_calloc();
+ }
/* Multiply by 3 because these are triangle indices. */
const int mat_start = data->tri_mat_start[i];
const int mat_end = data->tri_mat_end[i];
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_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 0da132a8cab..7217be106ae 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -496,10 +496,8 @@ static void mesh_batch_cache_init(Mesh *me)
cache->mat_len = mesh_render_mat_len_get(me);
cache->surface_per_mat = MEM_callocN(sizeof(*cache->surface_per_mat) * cache->mat_len, __func__);
- FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) {
- mbufcache->tris_per_mat = MEM_callocN(sizeof(*mbufcache->tris_per_mat) * cache->mat_len,
+ cache->final.tris_per_mat = MEM_callocN(sizeof(*cache->final.tris_per_mat) * cache->mat_len,
__func__);
- }
cache->is_dirty = false;
cache->batch_ready = 0;
@@ -707,16 +705,13 @@ static void mesh_batch_cache_clear(Mesh *me)
for (int i = 0; i < sizeof(mbufcache->ibo) / sizeof(void *); i++) {
GPU_INDEXBUF_DISCARD_SAFE(ibos[i]);
}
+ }
- BLI_assert((mbufcache->tris_per_mat != NULL) || (cache->mat_len == 0));
- BLI_assert((mbufcache->tris_per_mat != NULL) && (cache->mat_len > 0));
- if (mbufcache->tris_per_mat) {
- for (int i = 0; i < cache->mat_len; i++) {
- GPU_INDEXBUF_DISCARD_SAFE(mbufcache->tris_per_mat[i]);
- }
- MEM_SAFE_FREE(mbufcache->tris_per_mat);
- }
+ for (int i = 0; i < cache->mat_len; i++) {
+ GPU_INDEXBUF_DISCARD_SAFE(cache->final.tris_per_mat[i]);
}
+ MEM_SAFE_FREE(cache->final.tris_per_mat);
+
for (int i = 0; i < sizeof(cache->batch) / sizeof(void *); i++) {
GPUBatch **batch = (GPUBatch **)&cache->batch;
GPU_BATCH_DISCARD_SAFE(batch[i]);
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 b60583deda3..f51328e9bc9 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;
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 808b5cc675b..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;
@@ -203,6 +206,9 @@ void drw_state_set(DRWState state)
case DRW_STATE_LOGIC_INVERT:
blend = GPU_BLEND_INVERT;
break;
+ case DRW_STATE_BLEND_ALPHA_UNDER_PREMUL:
+ blend = GPU_BLEND_ALPHA_UNDER_PREMUL;
+ break;
default:
blend = GPU_BLEND_NONE;
break;
@@ -648,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);
@@ -762,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;
}
@@ -884,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)
@@ -893,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/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 66c12a0d0d7..60fe8ee7dee 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -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/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 d39c7eb0d95..db472c9ffa7 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1029,10 +1029,10 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
* need this to make further step with copying non-cv related curves copying
* not touching cv's f-curves */
LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, orig_curves) {
- if (STREQLEN(fcu->rna_path, "splines", 7)) {
+ 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);
}
}
@@ -1060,7 +1060,7 @@ 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) */
LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, orig_curves) {
- if (STREQLEN(fcu->rna_path, "splines", 7)) {
+ if (STRPREFIX(fcu->rna_path, "splines")) {
fcurve_remove(adt, orig_curves, fcu);
}
else {
@@ -2055,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");
@@ -2083,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");
@@ -2309,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++;
}
@@ -3868,7 +3868,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
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;
}
@@ -4408,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 {
@@ -4416,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 {
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 369137cbe25..56392aab5bf 100644
--- a/source/blender/editors/curve/editcurve_query.c
+++ b/source/blender/editors/curve/editcurve_query.c
@@ -185,7 +185,7 @@ void ED_curve_nurb_vert_selected_find(
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/editfont.c b/source/blender/editors/curve/editfont.c
index 1e5984ee14c..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);
}
/** \} */
@@ -651,7 +651,7 @@ static void txt_add_object(bContext *C,
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;
@@ -1695,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) {
@@ -2160,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/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index c06a2f06a98..a9f9625db7a 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -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/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 2d9f49fa1ed..237b5839c42 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;
}
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 07a1b34fa84..2cee06c36ad 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -1557,14 +1557,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;
@@ -3035,7 +3035,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;
}
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 77575d88cd3..4ba75bcd604 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1042,7 +1042,7 @@ 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;
}
@@ -2737,12 +2737,12 @@ 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);
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* only editable and visible layers are considered */
@@ -3221,13 +3221,13 @@ 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)) {
+ 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;
@@ -4389,7 +4389,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;
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 3c1f538cb99..f06a1d6b6c8 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,
diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c
index ca93e8de844..938f4ab26af 100644
--- a/source/blender/editors/gpencil/gpencil_merge.c
+++ b/source/blender/editors/gpencil/gpencil_merge.c
@@ -314,7 +314,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;
}
@@ -413,7 +413,7 @@ static int gpencil_analyze_strokes(tGPencilPointCache *src_array,
BLI_ghash_free(strokes, NULL, NULL);
/* add the stroke to array */
- if (gps->next != NULL) {
+ if (gps_next != NULL) {
BLI_ghash_insert(all_strokes, gps_next, gps_next);
last = gpencil_insert_to_array(src_array, dst_array, totpoints, gps_next, reverse, last);
/* replace last end */
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 543ff8e7e9a..82c30dea91d 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;
}
}
@@ -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..55180885c5d 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;
}
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 28a90a26a9d..0fdd70c55bc 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -555,7 +555,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 */
@@ -1429,7 +1429,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]);
}
@@ -2289,7 +2289,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);
@@ -2982,8 +2982,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..3bd2c3e6be6 100644
--- a/source/blender/editors/gpencil/gpencil_uv.c
+++ b/source/blender/editors/gpencil/gpencil_uv.c
@@ -502,13 +502,13 @@ 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. */
diff --git a/source/blender/editors/include/ED_buttons.h b/source/blender/editors/include/ED_buttons.h
index 90d3a527b0c..1ff160b2ca8 100644
--- a/source/blender/editors/include/ED_buttons.h
+++ b/source/blender/editors/include/ED_buttons.h
@@ -26,8 +26,8 @@
extern "C" {
#endif
-struct bContext;
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);
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_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_view3d.h b/source/blender/editors/include/ED_view3d.h
index d3eb6c00f57..f64c6a42f18 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -693,7 +693,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 db3bbc8a128..4c3fd57131c 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) ||
@@ -900,6 +900,8 @@ static bool ui_but_update_from_old_block(const bContext *C,
/* 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. */
+ ui_button_group_replace_but_ptr(block, but, oldbut);
oldbut->block = block;
*but_p = oldbut;
@@ -4067,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) {
@@ -4254,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 1f544831982..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) {
@@ -86,9 +85,6 @@ void ui_button_group_replace_but_ptr(uiBlock *block, const void *old_but_ptr, ui
}
}
}
-
- /* The button should be in a group. */
- BLI_assert(false);
}
/** \} */
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_handlers.c b/source/blender/editors/interface/interface_handlers.c
index ac31148340a..fb5844d24f3 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1024,7 +1024,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 +3564,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);
@@ -4740,7 +4740,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;
}
@@ -5052,7 +5052,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;
@@ -5244,13 +5244,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;
@@ -5374,7 +5374,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;
@@ -5997,7 +5997,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;
@@ -6328,7 +6328,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;
@@ -6396,7 +6396,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;
}
}
@@ -6499,15 +6499,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;
}
}
@@ -6602,7 +6602,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;
@@ -7315,7 +7315,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;
@@ -7348,7 +7348,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;
@@ -7421,7 +7421,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;
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 1a8b1ae0a1a..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];
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index efb29fe75c3..df7fd3dee0e 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1002,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);
@@ -1886,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;
}
}
@@ -2295,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);
@@ -5480,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 7fa45545a16..0d81b43146d 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;
@@ -320,7 +321,7 @@ Panel *UI_panel_add_instanced(const bContext *C,
}
/**
- * 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)
@@ -455,7 +456,7 @@ 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_context_poll(region, panel->type, context)) {
@@ -466,7 +467,7 @@ 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) {
@@ -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)
@@ -621,6 +622,18 @@ static bool panel_set_flag_recursive(Panel *panel, int flag, bool value)
return changed;
}
+/**
+ * Set runtime flag state for a panel and its sub-panels.
+ */
+static void panel_set_runtime_flag_recursive(Panel *panel, int 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)
{
const bool has_category_tabs = UI_panel_category_is_visible(region);
@@ -657,7 +670,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,7 +694,7 @@ 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));
@@ -753,8 +766,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 +777,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 +798,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);
}
}
@@ -878,7 +891,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,13 +920,11 @@ 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 header-less panels in some cases. */
@@ -924,8 +935,7 @@ static void panel_set_expansion_from_seach_filter_recursive(const bContext *C,
LISTBASE_FOREACH (Panel *, child_panel, &panel->children) {
/* 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,22 +944,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) {
- /* Checking if the panel is active is only an optimization, it would be fine to run this on
- * inactive panels. */
- if (panel->runtime_flag & PANEL_ACTIVE) {
- panel_set_expansion_from_seach_filter_recursive(C, panel, use_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)
{
@@ -1033,42 +1040,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);
@@ -1632,14 +1621,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;
}
/**
@@ -1861,15 +1845,13 @@ static void ui_do_animate(bContext *C, Panel *panel)
}
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);
}
+
+ panel_activate_state(C, panel, PANEL_STATE_EXIT);
return;
}
}
@@ -1878,7 +1860,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);
@@ -1906,10 +1888,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) {
@@ -1969,28 +1951,13 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
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);
+ /* 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);
- 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. */
- 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);
-
- uiAlignPanelStep(region, 0.2f, true);
- }
+ uiAlignPanelStep(region, 0.2f, true);
ED_region_tag_redraw(region);
}
@@ -2139,9 +2106,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)
{
@@ -2191,27 +2158,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);
@@ -2248,7 +2198,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));
}
@@ -2329,10 +2279,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;
}
}
@@ -2340,11 +2290,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__);
@@ -2440,7 +2385,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);
@@ -2621,7 +2566,7 @@ 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_activate_state(const bContext *C, Panel *panel, const uiHandlePanelState state)
{
uiHandlePanelData *data = panel->activedata;
wmWindow *win = CTX_wm_window(C);
@@ -2631,15 +2576,20 @@ static void panel_activate_state(const bContext *C, Panel *panel, uiHandlePanelS
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) {
+ /*
+ * Note on "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. */
+ if (state == PANEL_STATE_DRAG) {
+ panel_set_flag_recursive(panel, PNL_SELECT, true);
+ panel_set_runtime_flag_recursive(panel, PANEL_IS_DRAG_DROP, true);
+ }
+ else if (state == PANEL_STATE_ANIMATION) {
panel_set_flag_recursive(panel, PNL_SELECT, false);
}
- else {
- panel_set_flag_recursive(panel, PNL_SELECT, true);
+ else if (state == PANEL_STATE_EXIT) {
+ panel_set_runtime_flag_recursive(panel, PANEL_IS_DRAG_DROP, false);
}
if (data && data->animtimer) {
@@ -2678,32 +2628,12 @@ static void panel_activate_state(const bContext *C, Panel *panel, uiHandlePanelS
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();
-
- /* 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;
- }
}
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_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 62c387638dc..83274db9db9 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -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;
}
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 1abde7cf714..958a0bc03cd 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -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 e2250c764b1..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 {
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/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/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 012bca050cf..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,27 +604,6 @@ 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[] = {
@@ -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_mask_extract.c b/source/blender/editors/mesh/editmesh_mask_extract.c
index 96abd2226db..8ef1f9ee176 100644
--- a/source/blender/editors/mesh/editmesh_mask_extract.c
+++ b/source/blender/editors/mesh/editmesh_mask_extract.c
@@ -225,6 +225,8 @@ static int geometry_extract_apply(bContext *C,
/* Remove the mask from the new object so it can be sculpted directly after extracting. */
CustomData_free_layers(&new_ob_mesh->vdata, CD_PAINT_MASK, new_ob_mesh->totvert);
+ BKE_mesh_copy_settings(new_ob_mesh, mesh);
+
if (params->apply_shrinkwrap) {
BKE_shrinkwrap_mesh_nearest_surface_deform(C, new_ob, ob);
}
@@ -556,8 +558,12 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
mesh);
BM_mesh_free(bm);
+ /* Remove the mask from the new object so it can be sculpted directly after slicing. */
+ CustomData_free_layers(&new_ob_mesh->vdata, CD_PAINT_MASK, new_ob_mesh->totvert);
+
BKE_mesh_nomain_to_mesh(new_ob_mesh, new_ob->data, new_ob, &CD_MASK_MESH, true);
BKE_mesh_calc_normals(new_ob->data);
+ BKE_mesh_copy_settings(new_ob->data, mesh);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, new_ob);
BKE_mesh_batch_cache_dirty_tag(new_ob->data, BKE_MESH_BATCH_DIRTY_ALL);
DEG_relations_tag_update(bmain);
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_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 66d57de70d3..03b4cda2005 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -880,6 +880,7 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed
BMLoop *l;
BMEdge *e_best;
BMVert *v;
+ const int totvert_orig = bm->totvert;
const int totedge_orig = bm->totedge;
float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1]};
@@ -988,7 +989,7 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed
MEM_freeN(fill_uloop_pairs);
}
- if (totedge_orig == bm->totedge) {
+ if ((totvert_orig == bm->totvert) && (totedge_orig == bm->totedge)) {
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 85cc19e7471..c8367c720a7 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -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/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/object/object_add.c b/source/blender/editors/object/object_add.c
index 36e780f7472..8973a74cd1d 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2930,7 +2930,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_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 df940d3fa25..70c3552e8da 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_modifier.c b/source/blender/editors/object/object_modifier.c
index a59d438ad6b..6c4adce1365 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -1911,7 +1911,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 3d65a9e5fcb..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,
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 26863fd0848..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,32 +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_ex(C, ob);
+}
+
+static bool vertex_group_mesh_poll_ex(bContext *C, Object *ob)
+{
+ if (!vertex_group_poll_ex(C, ob)) {
+ return false;
+ }
+
+ if (ob->type != OB_MESH) {
+ CTX_wm_operator_poll_msg_set(C, "Only mesh objects are supported");
+ return false;
+ }
- return (vertex_group_poll(C) && ob->type == OB_MESH);
+ 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;
}
@@ -2717,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;
}
@@ -2770,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;
}
@@ -2791,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;
}
@@ -3165,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);
}
/** \} */
@@ -3313,7 +3353,7 @@ void OBJECT_OT_vertex_group_fix(wmOperatorType *ot)
"groups' weights (this tool may be slow for many vertices)";
/* api callbacks */
- ot->poll = vertex_group_mesh_poll;
+ ot->poll = vertex_group_mesh_with_dvert_poll;
ot->exec = vertex_group_fix_exec;
/* flags */
@@ -3329,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",
@@ -3345,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/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/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 5d355ada77c..79eaf007fcb 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -489,19 +489,19 @@ 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,
- oglrender->depsgraph,
- scene,
- oglrender->sizex,
- oglrender->sizey,
- 100,
- false,
- &context);
+ SEQ_render_new_render_data(oglrender->bmain,
+ oglrender->depsgraph,
+ scene,
+ oglrender->sizex,
+ oglrender->sizey,
+ 100,
+ false,
+ &context);
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/screen/area.c b/source/blender/editors/screen/area.c
index cffcb1cb4dc..720d4608125 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;
@@ -3582,7 +3582,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_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 6f80165ed3c..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);
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/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 96d34dd6145..5ee38069fd9 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -42,6 +42,7 @@
#include "BKE_brush.h"
#include "BKE_ccg.h"
#include "BKE_context.h"
+#include "BKE_lib_id.h"
#include "BKE_mesh.h"
#include "BKE_multires.h"
#include "BKE_paint.h"
@@ -993,7 +994,7 @@ static void sculpt_gesture_trim_normals_update(SculptGestureContext *sgcontext)
}),
trim_mesh);
BM_mesh_free(bm);
- BKE_mesh_free(trim_mesh);
+ BKE_id_free(NULL, trim_mesh);
trim_operation->mesh = result;
}
@@ -1207,7 +1208,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
static void sculpt_gesture_trim_geometry_free(SculptGestureContext *sgcontext)
{
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)sgcontext->operation;
- BKE_mesh_free(trim_operation->mesh);
+ BKE_id_free(NULL, trim_operation->mesh);
MEM_freeN(trim_operation->true_mesh_co);
}
@@ -1218,7 +1219,6 @@ static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data))
static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
{
-
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)sgcontext->operation;
Mesh *sculpt_mesh = BKE_mesh_from_object(sgcontext->vc.obact);
Mesh *trim_mesh = trim_operation->mesh;
@@ -1293,15 +1293,20 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
BLI_assert(false);
break;
}
- BM_mesh_boolean(bm, looptris, tottri, bm_face_isect_pair, NULL, 2, false, boolean_mode);
+ BM_mesh_boolean(bm, looptris, tottri, bm_face_isect_pair, NULL, 2, true, boolean_mode);
}
- Mesh *result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, sculpt_mesh);
+ MEM_freeN(looptris);
+
+ Mesh *result = BKE_mesh_from_bmesh_nomain(bm,
+ (&(struct BMeshToMeshParams){
+ .calc_object_remap = false,
+ }),
+ sculpt_mesh);
BM_mesh_free(bm);
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
-
- BKE_mesh_nomain_to_mesh(result, sculpt_mesh, sgcontext->vc.obact, &CD_MASK_MESH, true);
- BKE_mesh_free(result);
+ BKE_mesh_nomain_to_mesh(
+ result, sgcontext->vc.obact->data, sgcontext->vc.obact, &CD_MASK_MESH, true);
}
static void sculpt_gesture_trim_begin(bContext *C, SculptGestureContext *sgcontext)
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_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 754204201f4..421a3653d8c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -298,6 +298,21 @@ void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3])
SCULPT_vertex_normal_get(ss, SCULPT_active_vertex_get(ss), normal);
}
+MVert *SCULPT_mesh_deformed_mverts_get(SculptSession *ss)
+{
+ switch (BKE_pbvh_type(ss->pbvh)) {
+ case PBVH_FACES:
+ if (ss->shapekey_active || ss->deform_modifiers_active) {
+ return BKE_pbvh_get_verts(ss->pbvh);
+ }
+ return ss->mvert;
+ case PBVH_BMESH:
+ case PBVH_GRIDS:
+ return NULL;
+ }
+ return NULL;
+}
+
float *SCULPT_brush_deform_target_vertex_co_get(SculptSession *ss,
const int deform_target,
PBVHVertexIter *iter)
@@ -2347,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);
@@ -3907,7 +3922,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;
}
}
@@ -6258,7 +6273,9 @@ static void do_tiled(
/* Position of the "prototype" stroke for tiling. */
float orgLoc[3];
+ float original_initial_location[3];
copy_v3_v3(orgLoc, cache->location);
+ copy_v3_v3(original_initial_location, cache->initial_location);
for (int dim = 0; dim < 3; dim++) {
if ((sd->paint.symmetry_flags & (PAINT_TILE_X << dim)) && step[dim] > 0) {
@@ -6289,6 +6306,7 @@ static void do_tiled(
for (int dim = 0; dim < 3; dim++) {
cache->location[dim] = cur[dim] * step[dim] + orgLoc[dim];
cache->plane_offset[dim] = cur[dim] * step[dim];
+ cache->initial_location[dim] = cur[dim] * step[dim] + original_initial_location[dim];
}
action(sd, ob, brush, ups);
}
@@ -9359,8 +9377,9 @@ static void dyntopo_detail_size_edit_draw(const bContext *UNUSED(C),
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);
- GPU_matrix_pop();
+ immUnbindProgram();
+ GPU_matrix_pop();
GPU_blend(GPU_BLEND_NONE);
GPU_line_smooth(false);
}
@@ -9511,7 +9530,16 @@ static int dyntopo_detail_size_edit_invoke(bContext *C, wmOperator *op, const wm
copy_m4_m4(cursor_trans, active_object->obmat);
translate_m4(
cursor_trans, ss->cursor_location[0], ss->cursor_location[1], ss->cursor_location[2]);
- rotation_between_vecs_to_quat(quat, z_axis, ss->cursor_normal);
+
+ 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);
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c
index 3c87407b2db..6eb51c77aef 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -132,6 +132,8 @@ static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
ss, &test, data->brush->falloff_shape);
const int thread_id = BLI_task_parallel_thread_id(tls);
+ MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss);
+
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
@@ -140,7 +142,7 @@ static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
const MPoly *p = &ss->mpoly[vert_map->indices[j]];
float poly_center[3];
- BKE_mesh_calc_poly_center(p, &ss->mloop[p->loopstart], ss->mvert, poly_center);
+ BKE_mesh_calc_poly_center(p, &ss->mloop[p->loopstart], mvert, poly_center);
if (sculpt_brush_test_sq_fn(&test, poly_center)) {
const float fade = bstrength * SCULPT_brush_strength_factor(ss,
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 6313c934774..1a596909d8d 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -170,6 +170,10 @@ int SCULPT_active_vertex_get(SculptSession *ss);
const float *SCULPT_active_vertex_co_get(SculptSession *ss);
void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]);
+/* Returns PBVH deformed vertices array if shape keys or deform modifiers are used, otherwise
+ * returns mesh original vertices array. */
+struct MVert *SCULPT_mesh_deformed_mverts_get(SculptSession *ss);
+
/* Fake Neighbors */
#define FAKE_NEIGHBOR_NONE -1
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 8bf14f85b89..c6961cc9d4b 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -171,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");
}
@@ -198,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");
}
@@ -512,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)
@@ -722,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_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_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_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_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 7cfd749d013..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);
}
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index faa23bc4f83..9e51b6ca4ba 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -583,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) {
@@ -599,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;
@@ -1294,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);
@@ -1560,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/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 b7d47902fe8..d8556711c55 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -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] == '!') {
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index a491ce29bd4..9c7c859a05d 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 0f3dda6f905..ae15b651059 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2090,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,
@@ -2884,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;
@@ -3576,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_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 0cdd3f4f204..69e9c975bd1 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);
}
/** \} */
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_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 7e3f90b01ba..c6fe1b8539e 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -148,7 +148,7 @@ static void nla_init(struct wmWindowManager *wm, ScrArea *area)
/* init dopesheet data if non-existent (i.e. for old files) */
if (snla->ads == NULL) {
snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
- snla->ads->source = (ID *)WM_window_get_active_scene(wm->winactive);
+ snla->ads->source = (wm->winactive) ? (ID *)WM_window_get_active_scene(wm->winactive) : NULL;
}
ED_area_tag_refresh(area);
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 51486e398c2..165e88242d1 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_edit.c b/source/blender/editors/space_node/node_edit.c
index 76fde9a36e2..039ddad71ef 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 1e679d7d7c9..f2abe272f48 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, "GeometryNodeTree")) {
+ if (STR_ELEM(snode->tree_idname,
+ "ShaderNodeTree",
+ "CompositorNodeTree",
+ "TextureNodeTree",
+ "GeometryNodeTree")) {
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_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/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 779efc3cacb..0d7255b5558 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -440,7 +440,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_select.c b/source/blender/editors/space_outliner/outliner_select.c
index beba1fc9e8d..703624f5735 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -725,20 +725,9 @@ static eOLDrawState tree_element_active_bone(bContext *C,
static void tree_element_active_ebone__sel(bContext *C, bArmature *arm, EditBone *ebone, short sel)
{
if (sel) {
- ebone->flag |= BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL;
arm->act_edbone = ebone;
- /* Flush to parent? */
- if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
- ebone->parent->flag |= BONE_TIPSEL;
- }
- }
- else {
- ebone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
- /* Flush to parent? */
- if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
- ebone->parent->flag &= ~BONE_TIPSEL;
- }
}
+ ED_armature_ebone_select_set(ebone, sel);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, CTX_data_edit_object(C));
}
static eOLDrawState tree_element_active_ebone(bContext *C,
@@ -1435,7 +1424,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 e1a96da1c91..4591a545783 100644
--- a/source/blender/editors/space_outliner/outliner_sync.c
+++ b/source/blender/editors/space_outliner/outliner_sync.c
@@ -253,11 +253,13 @@ static void outliner_select_sync_to_edit_bone(ViewLayer *view_layer,
if (EBONE_SELECTABLE(arm, ebone)) {
if (tselem->flag & TSE_SELECTED) {
- ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-
+ ED_armature_ebone_select_set(ebone, true);
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. */
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
}
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 79376686342..9cd38ac07f5 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1557,7 +1557,7 @@ static void outliner_add_layer_collection_objects(SpaceOutliner *space_outliner,
TreeElement *te_object = outliner_add_element(space_outliner, tree, base->object, ten, 0, 0);
te_object->directdata = base;
- if (!(base->flag & BASE_VISIBLE_DEPSGRAPH)) {
+ if (!(base->flag & BASE_VISIBLE_VIEWLAYER)) {
te_object->flag |= TE_DISABLED;
}
}
@@ -2207,6 +2207,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;
@@ -2289,6 +2292,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)) {
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 42abc97bebe..7335882e947 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -315,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;
}
}
@@ -639,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)
@@ -725,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,
@@ -780,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");
@@ -903,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);
@@ -972,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_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index eb35cced95b..7e23f4ed281 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -626,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) {
@@ -1259,13 +1259,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);
@@ -1285,10 +1285,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, cfra + frame_ofs, special_seq_update);
}
else {
- ibuf = BKE_sequencer_give_ibuf(&context, cfra + frame_ofs, sseq->chanshown);
+ ibuf = SEQ_render_give_ibuf(&context, cfra + frame_ofs, sseq->chanshown);
}
if (viewport) {
@@ -2086,7 +2086,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;
@@ -2132,14 +2132,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]);
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 92449126d2c..8f3a3ba50a0 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -154,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;
@@ -171,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);
@@ -234,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) {
@@ -589,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;
}
@@ -1106,7 +1106,7 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
/* Check if the current frame has a gap already. */
for (cfra = CFRA; cfra >= sfra; cfra--) {
- if (BKE_sequencer_evaluate_frame(scene, cfra)) {
+ if (SEQ_render_evaluate_frame(scene, cfra)) {
first = true;
break;
}
@@ -1115,13 +1115,13 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
for (; cfra < efra; cfra++) {
/* 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, cfra)) {
first = true;
}
}
- else if (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
+ else if (SEQ_render_evaluate_frame(scene, cfra) == 0) {
done = true;
- while (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
+ while (SEQ_render_evaluate_frame(scene, cfra) == 0) {
done = sequence_offset_after_frame(scene, -1, cfra);
if (done == false) {
break;
@@ -2681,7 +2681,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
while (cfra < frame_end) {
/* New seq. */
- se = BKE_sequencer_give_stripelem(seq, cfra);
+ se = SEQ_render_give_stripelem(seq, cfra);
seq_new = BKE_sequence_dupli_recursive(
scene, scene, ed->seqbasep, seq, SEQ_DUPE_UNIQUE_NAME);
@@ -3221,7 +3221,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;
@@ -3505,12 +3505,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);
}
@@ -3569,7 +3569,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;
}
@@ -3919,7 +3919,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,
@@ -4064,7 +4064,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_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 2af708494cb..f7c8c35d563 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -206,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);
}
@@ -466,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);
}
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 1ca7222e02d..52a5ff609d8 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -416,7 +416,7 @@ 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");
}
@@ -751,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. */
}
/** \} */
@@ -1722,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;
@@ -1897,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;
@@ -1987,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;
@@ -3065,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;
}
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 f67eb73bbd1..36da0791c4f 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -280,7 +280,7 @@ 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;
BPoint *bp;
diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c
index 1d5b33e7b90..bce0e49d60a 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,7 @@ 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->transflag & OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK;
vctrl->persp_backup = rv3d->persp;
vctrl->dist_backup = rv3d->dist;
@@ -153,7 +152,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..897777c9159 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -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;
@@ -4828,7 +4828,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_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..22cdbb090a5 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]);
@@ -552,7 +552,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 +656,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/transform.c b/source/blender/editors/transform/transform.c
index 1b1740cd5bc..77ce9c10c77 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -684,7 +684,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
{TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""},
{TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""},
{TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""},
- {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint", ""},
+ {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -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 17ef9a3034f..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
@@ -282,8 +284,6 @@ typedef struct TransInfo {
short state;
/** Current context/options for transform. */
int options;
- /** Initial value for some transformations (and rotation angle). */
- float val;
void (*transform)(struct TransInfo *, const int[2]);
/** Transform function pointer. */
eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *);
@@ -331,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. */
@@ -370,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).
@@ -399,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;
@@ -419,9 +419,13 @@ typedef struct TransInfo {
TransCustomDataContainer custom;
} TransInfo;
-/* ******************** Macros & Prototypes *********************** */
+/** \} */
-/* transinfo->state */
+/* -------------------------------------------------------------------- */
+/** \name Flags
+ * \{ */
+
+/** #TransInfo.state */
enum {
TRANS_STARTING = 0,
TRANS_RUNNING = 1,
@@ -429,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. */
@@ -454,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. */
@@ -471,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,
@@ -486,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,
};
@@ -505,8 +510,6 @@ enum {
*/
// #define USE_NODE_CENTER
-/* ******************************************************************************** */
-
/** #TransInfo.helpline */
enum {
HLP_NONE = 0,
@@ -540,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,
@@ -561,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,
@@ -571,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,
@@ -603,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,
@@ -648,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,
@@ -718,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_generics.c b/source/blender/editors/transform/transform_generics.c
index 1b8c9b47c04..60848eb5678 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -270,9 +270,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->data_len_all = 0;
- t->val = 0.0f;
-
- zero_v3(t->vec);
zero_v3(t->center_global);
unit_m3(t->mat);
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index a22f6c35139..a71915d8122 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) {
diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c
index 67b3a16627f..af0a8e5e505 100644
--- a/source/blender/editors/transform/transform_mode.c
+++ b/source/blender/editors/transform/transform_mode.c
@@ -532,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);
diff --git a/source/blender/editors/transform/transform_mode_bend.c b/source/blender/editors/transform/transform_mode_bend.c
index 21a6a1ebafc..adf3a0346a0 100644
--- a/source/blender/editors/transform/transform_mode_bend.c
+++ b/source/blender/editors/transform/transform_mode_bend.c
@@ -276,8 +276,6 @@ void initBend(TransInfo *t)
}
calculateCenterLocal(t, t->center_global);
- t->val = 0.0f;
-
data = MEM_callocN(sizeof(*data), __func__);
curs = t->scene->cursor.location;
diff --git a/source/blender/editors/transform/transform_mode_tosphere.c b/source/blender/editors/transform/transform_mode_tosphere.c
index c7a278fe5ea..15906f2c90c 100644
--- a/source/blender/editors/transform/transform_mode_tosphere.c
+++ b/source/blender/editors/transform/transform_mode_tosphere.c
@@ -26,6 +26,8 @@
#include "BLI_math.h"
#include "BLI_string.h"
+#include "MEM_guardedalloc.h"
+
#include "BKE_context.h"
#include "BKE_unit.h"
@@ -40,11 +42,64 @@
#include "transform_snap.h"
/* -------------------------------------------------------------------- */
+/** \name To Sphere Utilities
+ * \{ */
+
+struct ToSphereInfo {
+ float prop_size_prev;
+ float radius;
+};
+
+/** Calculate average radius. */
+static void to_sphere_radius_update(TransInfo *t)
+{
+ struct ToSphereInfo *data = t->custom.mode.data;
+ float radius = 0.0f;
+
+ const bool is_local_center = transdata_check_local_center(t, t->around);
+
+ if (t->flag & T_PROP_EDIT_ALL) {
+ int factor_accum = 0.0f;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (int i = 0; i < tc->data_len; i++, td++) {
+ if (td->factor == 0.0f) {
+ continue;
+ }
+ const float *center = is_local_center ? td->center : tc->center_local;
+ radius += td->factor * len_v3v3(center, td->iloc);
+ factor_accum += td->factor;
+ }
+ }
+ if (factor_accum != 0.0f) {
+ radius /= factor_accum;
+ }
+ }
+ else {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ TransData *td = tc->data;
+ for (int i = 0; i < tc->data_len; i++, td++) {
+ const float *center = is_local_center ? td->center : tc->center_local;
+ radius += len_v3v3(center, td->iloc);
+ }
+ }
+ radius /= (float)t->data_len_all;
+ }
+
+ data->prop_size_prev = t->prop_size;
+ data->radius = radius;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Transform (ToSphere)
* \{ */
static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
{
+ const bool is_local_center = transdata_check_local_center(t, t->around);
+
float vec[3];
float ratio, radius;
int i;
@@ -73,6 +128,11 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), TIP_("To Sphere: %.4f %s"), ratio, t->proptext);
}
+ const struct ToSphereInfo *data = t->custom.mode.data;
+ if (data->prop_size_prev != t->prop_size) {
+ to_sphere_radius_update(t);
+ }
+
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
@@ -81,15 +141,17 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
continue;
}
- sub_v3_v3v3(vec, td->iloc, tc->center_local);
+ const float *center = is_local_center ? td->center : tc->center_local;
+
+ sub_v3_v3v3(vec, td->iloc, center);
radius = normalize_v3(vec);
tratio = ratio * td->factor;
- mul_v3_fl(vec, radius * (1.0f - tratio) + t->val * tratio);
+ mul_v3_fl(vec, radius * (1.0f - tratio) + data->radius * tratio);
- add_v3_v3v3(td->loc, tc->center_local, vec);
+ add_v3_v3v3(td->loc, center, vec);
}
}
@@ -100,8 +162,6 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
void initToSphere(TransInfo *t)
{
- int i;
-
t->mode = TFM_TOSPHERE;
t->transform = applyToSphere;
@@ -119,14 +179,10 @@ void initToSphere(TransInfo *t)
t->num.val_flag[0] |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
t->flag |= T_NO_CONSTRAINT;
- /* Calculate average radius */
- FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++) {
- t->val += len_v3v3(tc->center_local, td->iloc);
- }
- }
+ struct ToSphereInfo *data = MEM_callocN(sizeof(*data), __func__);
+ t->custom.mode.data = data;
+ t->custom.mode.use_free = true;
- t->val /= (float)t->data_len_all;
+ to_sphere_radius_update(t);
}
/** \} */
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 9f39099ea4b..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,
diff --git a/source/blender/editors/util/ed_util_imbuf.c b/source/blender/editors/util/ed_util_imbuf.c
index 9ae5cbbdfe9..b832d9a1d86 100644
--- a/source/blender/editors/util/ed_util_imbuf.c
+++ b/source/blender/editors/util/ed_util_imbuf.c
@@ -370,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/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp
index d34be79cd66..66e41222ee6 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;
_MapsPath = Config::Path::getInstance()->getMapsDir().c_str();
}
-AppCanvas::AppCanvas(AppView *iViewer) : Canvas()
+AppCanvas::AppCanvas(AppView *iViewer)
{
_pViewer = iViewer;
}
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
index ee584f8953c..291a38d23df 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
@@ -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
@@ -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 {
@@ -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);
}
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index f31d7c95997..2f465a973fc 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();
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index 2446bfc13dc..9680e7d25a3 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -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;
}
diff --git a/source/blender/freestyle/intern/geometry/matrix_util.cpp b/source/blender/freestyle/intern/geometry/matrix_util.cpp
index 9d25a240a63..637c2d05574 100644
--- a/source/blender/freestyle/intern/geometry/matrix_util.cpp
+++ b/source/blender/freestyle/intern/geometry/matrix_util.cpp
@@ -149,7 +149,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) {
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/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/Interface1D/BPy_FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
index e04a89bad3b..d337bf7f90e 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
@@ -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);
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
index fe0fc715e34..89c4bedd676 100644
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
@@ -23,7 +23,7 @@
namespace Freestyle {
-IndexedFaceSet::IndexedFaceSet() : Rep()
+IndexedFaceSet::IndexedFaceSet()
{
_Vertices = NULL;
_Normals = NULL;
@@ -68,7 +68,6 @@ IndexedFaceSet::IndexedFaceSet(float *iVertices,
unsigned *iTIndices,
unsigned iTISize,
unsigned iCopy)
- : Rep()
{
if (1 == iCopy) {
_VSize = iVSize;
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/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..0d4f21d9b11 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
@@ -170,13 +170,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 +256,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;
@@ -646,7 +646,7 @@ int GuidingLinesShader::shade(Stroke &stroke) const
//
/////////////////////////////////////////
-TipRemoverShader::TipRemoverShader(real tipLength) : StrokeShader()
+TipRemoverShader::TipRemoverShader(real tipLength)
{
_tipLength = tipLength;
}
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/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/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp
index 25954c7ecbf..307122833e4 100644
--- a/source/blender/freestyle/intern/stroke/Operators.cpp
+++ b/source/blender/freestyle/intern/stroke/Operators.cpp
@@ -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:
@@ -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;
@@ -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:
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..3e1463e8631 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -342,7 +342,7 @@ void StrokeAttribute::setAttributeVec3f(const char *iName, const Vec3f &att)
/* */
/**********************************/
-StrokeVertex::StrokeVertex() : CurvePoint()
+StrokeVertex::StrokeVertex()
{
_CurvilignAbscissa = 0.0f;
_StrokeLength = 0.0f;
@@ -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/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/view_map/BoxGrid.cpp b/source/blender/freestyle/intern/view_map/BoxGrid.cpp
index 5a490e3c7cc..aea54afc0f5 100644
--- a/source/blender/freestyle/intern/view_map/BoxGrid.cpp
+++ b/source/blender/freestyle/intern/view_map/BoxGrid.cpp
@@ -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..b53771ad2c2 100644
--- a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
+++ b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
@@ -191,7 +191,7 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
// 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();
}
@@ -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/SphericalGrid.cpp b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
index 0c6e9741fbd..1399ac396b0 100644
--- a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
+++ b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
@@ -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/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
index aecd37fa0de..8866ec2e267 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
@@ -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();
@@ -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();
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.cpp b/source/blender/freestyle/intern/view_map/ViewMap.cpp
index fa2f95dac72..b4faee7946b 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMap.cpp
@@ -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..2ef01ce0874 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
@@ -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()
{
}
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
index f11f30130c8..57eca876913 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
@@ -119,7 +119,7 @@ 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)) {
+ if (ELEM(_nPosDotP, 2, 0)) {
_pSmoothEdge = NULL;
return _pSmoothEdge;
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c
index 35bf870b259..6a630cbf978 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c
@@ -97,7 +97,7 @@ 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];
@@ -105,7 +105,7 @@ static void deformStroke(GpencilModifierData *md,
BKE_gpencil_stroke_geometry_update(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;
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_state.h b/source/blender/gpu/GPU_state.h
index b7bea4b0a08..f5a1ccbc40b 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -71,6 +71,7 @@ typedef enum eGPUBlend {
/** Custom blend parameters using dual source blending : SRC0 + SRC1 * DST
* NOTE: Can only be used with _ONE_ Draw Buffer and shader needs to be specialized. */
GPU_BLEND_CUSTOM,
+ GPU_BLEND_ALPHA_UNDER_PREMUL,
} eGPUBlend;
typedef enum eGPUDepthTest {
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_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_framebuffer_private.hh b/source/blender/gpu/intern/gpu_framebuffer_private.hh
index 87f0f3823e6..7afa56bfe3d 100644
--- a/source/blender/gpu/intern/gpu_framebuffer_private.hh
+++ b/source/blender/gpu/intern/gpu_framebuffer_private.hh
@@ -100,10 +100,10 @@ class FrameBuffer {
/** Debug name. */
char name_[DEBUG_NAME_LEN];
/** Frame-buffer state. */
- int viewport_[4];
- int scissor_[4];
+ int viewport_[4] = {0};
+ int scissor_[4] = {0};
bool scissor_test_ = false;
- bool dirty_state_;
+ bool dirty_state_ = true;
public:
FrameBuffer(const char *name);
diff --git a/source/blender/gpu/intern/gpu_immediate_private.hh b/source/blender/gpu/intern/gpu_immediate_private.hh
index e6c11120d7e..9fcbe2bdc0b 100644
--- a/source/blender/gpu/intern/gpu_immediate_private.hh
+++ b/source/blender/gpu/intern/gpu_immediate_private.hh
@@ -47,7 +47,7 @@ class Immediate {
/** Current draw call specification. */
GPUPrimType prim_type = GPU_PRIM_NONE;
- GPUVertFormat vertex_format;
+ GPUVertFormat vertex_format = {};
GPUShader *shader = NULL;
/** Enforce strict vertex count (disabled when using immBeginAtMost). */
bool strict_vertex_len = true;
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_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_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_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_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc
index cd87fc88144..a180aa270b0 100644
--- a/source/blender/gpu/opengl/gl_framebuffer.cc
+++ b/source/blender/gpu/opengl/gl_framebuffer.cc
@@ -288,7 +288,7 @@ void GLFrameBuffer::bind(bool enabled_srgb)
if (context_->active_fb != this || enabled_srgb_ != enabled_srgb) {
enabled_srgb_ = enabled_srgb;
- if (enabled_srgb) {
+ if (enabled_srgb && srgb_) {
glEnable(GL_FRAMEBUFFER_SRGB);
}
else {
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_state.cc b/source/blender/gpu/opengl/gl_state.cc
index 27c9b501add..8f2e0e2a72d 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(void)
{
/* Set other states that never change. */
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
@@ -421,6 +421,13 @@ void GLStateManager::set_blend(const eGPUBlend value)
dst_alpha = GL_SRC_ALPHA;
break;
}
+ case GPU_BLEND_ALPHA_UNDER_PREMUL: {
+ src_rgb = GL_ONE_MINUS_DST_ALPHA;
+ dst_rgb = GL_ONE;
+ src_alpha = GL_ONE_MINUS_DST_ALPHA;
+ dst_alpha = GL_ONE;
+ break;
+ }
case GPU_BLEND_CUSTOM: {
src_rgb = GL_ONE;
dst_rgb = GL_SRC1_COLOR;
@@ -430,6 +437,13 @@ void GLStateManager::set_blend(const eGPUBlend value)
}
}
+ if (value == GPU_BLEND_SUBTRACT) {
+ glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
+ }
+ else {
+ glBlendEquation(GL_FUNC_ADD);
+ }
+
/* Always set the blend function. This avoid a rendering error when blending is disabled but
* GPU_BLEND_CUSTOM was used just before and the frame-buffer is using more than 1 color target.
*/
diff --git a/source/blender/gpu/opengl/gl_vertex_array.cc b/source/blender/gpu/opengl/gl_vertex_array.cc
index ed6699e51f3..7585a327b3b 100644
--- a/source/blender/gpu/opengl/gl_vertex_array.cc
+++ b/source/blender/gpu/opengl/gl_vertex_array.cc
@@ -76,7 +76,7 @@ static uint16_t vbo_bind(const ShaderInterface *interface,
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/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/gpu/shaders/material/gpu_shader_material_output_material.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_output_material.glsl
index 4cb00c15b78..14271f9d107 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_output_material.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_output_material.glsl
@@ -1,5 +1,9 @@
-void node_output_material(
- Closure surface, Closure volume, vec3 displacement, float alpha_threshold, out Closure result)
+void node_output_material(Closure surface,
+ Closure volume,
+ vec3 displacement,
+ float alpha_threshold,
+ float shadow_threshold,
+ out Closure result)
{
#ifdef VOLUMETRICS
result = volume;
@@ -7,9 +11,9 @@ void node_output_material(
result = surface;
# if defined(USE_ALPHA_HASH)
/* Alpha clip emulation. */
- if (alpha_threshold >= 0.0) {
+ if ((rayType != EEVEE_RAY_SHADOW) ? (alpha_threshold >= 0.0) : (shadow_threshold >= 0.0)) {
float alpha = saturate(1.0 - avg(result.transmittance));
- result.transmittance = vec3(step(alpha, alpha_threshold));
+ result.transmittance = vec3(step(alpha, max(alpha_threshold, shadow_threshold)));
}
# endif
#endif
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index e127e377858..3efb78fe1ca 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -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;
}
@@ -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;
}
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 839b0b12b83..2f848b5be08 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -684,6 +684,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/intern/bmp.c b/source/blender/imbuf/intern/bmp.c
index ab818d451d6..f897b1c6df3 100644
--- a/source/blender/imbuf/intern/bmp.c
+++ b/source/blender/imbuf/intern/bmp.c
@@ -301,7 +301,7 @@ int 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/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..d5f5691c5f0 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.c
+++ b/source/blender/imbuf/intern/cineon/logImageCore.c
@@ -215,7 +215,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 +223,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 +442,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 +679,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 +688,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/iris.c b/source/blender/imbuf/intern/iris.c
index 12c4c63849c..214cdf1b63b 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -286,7 +286,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;
}
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index 525284bd867..38f8806d910 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -246,7 +246,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 +362,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
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index ca70ec633c1..08577f767e7 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -1210,7 +1210,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 "
@@ -1610,7 +1610,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;
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index dbae641f707..c4fbd3f7563 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -521,7 +521,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);
diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c
index 3dd26e1f7a2..4cd44a25cb8 100644
--- a/source/blender/imbuf/intern/radiance_hdr.c
+++ b/source/blender/imbuf/intern/radiance_hdr.c
@@ -329,9 +329,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]);
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c
index 8b4f33bb306..cdc8cd1068c 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 colorspace.
+ * For images with float buffer use color display colorspace.
+ * If display colorspace can not be referenced, use color in SRGB colorspace.
+ *
+ * \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: colorspace 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..5a3cbd375b6 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -703,7 +703,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 +777,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..bc69a14fa47 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -888,7 +888,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/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc
index 892109dc578..7663d1790b6 100644
--- a/source/blender/io/alembic/exporter/abc_export_capi.cc
+++ b/source/blender/io/alembic/exporter/abc_export_capi.cc
@@ -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/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc
index eba7f64db02..026a11ca25e 100644
--- a/source/blender/io/alembic/intern/alembic_capi.cc
+++ b/source/blender/io/alembic/intern/alembic_capi.cc
@@ -709,7 +709,7 @@ bool ABC_import(bContext *C,
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);
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/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/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/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/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc
index 7b375689543..12fc04e2142 100644
--- a/source/blender/io/usd/intern/usd_capi.cc
+++ b/source/blender/io/usd/intern/usd_capi.cc
@@ -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_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 713f5ee2afa..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),
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_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 4a0902913db..9a86de0556c 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -924,6 +924,8 @@ typedef struct NodeTexMagic {
typedef struct NodeShaderAttribute {
char name[64];
+ int type;
+ char _pad[4];
} NodeShaderAttribute;
typedef struct NodeShaderVectTransform {
@@ -1093,6 +1095,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_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index d2360d700d2..7101dacc803 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. */
@@ -322,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
@@ -576,15 +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),
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 1d89657faf6..1847fbfa986 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 {
@@ -494,8 +497,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_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 7785c700e1c..1b7ec3889bc 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)
* \{ */
@@ -309,11 +305,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 +321,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 +334,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 */
@@ -764,7 +761,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 +775,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 +1681,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 +1697,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_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 733b459495d..ed232d4ad89 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -1046,7 +1046,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 */
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_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 1c2f130025d..4de560c5d4b 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)
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index e193aa78353..5aa684539af 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"
@@ -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 a6084ae6a43..0fd35a25b41 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_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_camera.c b/source/blender/makesrna/intern/rna_camera.c
index c6b2489f831..1810cee5cee 100644
--- a/source/blender/makesrna/intern/rna_camera.c
+++ b/source/blender/makesrna/intern/rna_camera.c
@@ -384,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 "
@@ -584,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");
@@ -592,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_color.c b/source/blender/makesrna/intern/rna_color.c
index e8bef4a8a9e..ac47f434c3b 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -942,6 +942,7 @@ static void rna_def_color_ramp_element(BlenderRNA *brna)
prop = RNA_def_property(srna, "position", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pos");
RNA_def_property_range(prop, 0, 1);
+ RNA_def_property_ui_range(prop, 0, 1, 1, 3);
RNA_def_property_ui_text(prop, "Position", "Set position of selected color stop");
RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
}
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_define.c b/source/blender/makesrna/intern/rna_define.c
index 8eb964b8c17..b298d49fad5 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -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) {
@@ -1843,6 +1843,10 @@ void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type)
DefRNA.error = true;
break;
}
+
+ if ((type->flag & STRUCT_ID) != 0) {
+ prop->flag |= PROP_PTR_NO_OWNERSHIP;
+ }
}
void RNA_def_property_enum_native_type(PropertyRNA *prop, const char *native_enum_type)
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 1c43815d3a2..ea36289d361 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -1034,7 +1034,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_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 927a2805757..335268b91db 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -4379,10 +4379,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", "");
@@ -7107,7 +7135,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", ""},
@@ -7162,7 +7190,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");
@@ -7171,7 +7199,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");
@@ -8054,7 +8082,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..19a367a0c55 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -2031,7 +2031,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 +2048,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 0484a75a773..c132c434468 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1158,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;
}
@@ -2794,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);
}
@@ -6538,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");
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 8da2d762c94..1882fce3f54 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -470,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)
@@ -1409,18 +1381,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");
@@ -2151,7 +2140,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");
@@ -2173,24 +2162,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", "");
diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c
index 1ee84ef080c..9b8386dd1b1 100644
--- a/source/blender/makesrna/intern/rna_sequencer_api.c
+++ b/source/blender/makesrna/intern/rna_sequencer_api.c
@@ -93,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;
@@ -477,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_space.c b/source/blender/makesrna/intern/rna_space.c
index 87191064eb8..a32a2658723 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -307,6 +307,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 +479,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", ""},
@@ -2312,8 +2312,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),
@@ -3015,6 +3015,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},
};
@@ -5792,7 +5793,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_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index effea4d5c8f..f9597fdd7af 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -1186,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_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index e6821d6e4a7..932aa260bd5 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -4223,7 +4223,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);
@@ -4284,26 +4284,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");
@@ -5659,13 +5659,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);
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 12930a7e9b8..da1754b8ebd 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -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]);
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index d3dc8c93c02..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);
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 203736fb9ff..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;
}
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 0c91c1a7715..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];
@@ -424,15 +457,9 @@ static void freeBindData(SDefBindWeightData *const bwdata)
MEM_freeN(bwdata);
}
-BLI_INLINE float computeAngularWeight(const float point_angle, const float edgemid_angle)
+BLI_INLINE float computeAngularWeight(const float point_angle)
{
- float weight;
-
- weight = point_angle;
- weight /= edgemid_angle;
- weight *= M_PI_2;
-
- return sinf(weight);
+ return sinf(point_angle * M_PI_2);
}
BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
@@ -472,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;
@@ -481,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;
}
@@ -536,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);
@@ -546,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);
@@ -601,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;
@@ -658,15 +685,12 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
/* Compute angular weight component */
if (epolys->num == 1) {
- ang_weights[0] = computeAngularWeight(bpolys[0]->point_edgemid_angles[edge_on_poly[0]],
- bpolys[0]->edgemid_angle);
+ ang_weights[0] = computeAngularWeight(bpolys[0]->point_edgemid_angles[edge_on_poly[0]]);
bpolys[0]->weight_angular *= ang_weights[0] * ang_weights[0];
}
else if (epolys->num == 2) {
- ang_weights[0] = computeAngularWeight(bpolys[0]->point_edgemid_angles[edge_on_poly[0]],
- bpolys[0]->edgemid_angle);
- ang_weights[1] = computeAngularWeight(bpolys[1]->point_edgemid_angles[edge_on_poly[1]],
- bpolys[1]->edgemid_angle);
+ ang_weights[0] = computeAngularWeight(bpolys[0]->point_edgemid_angles[edge_on_poly[0]]);
+ ang_weights[1] = computeAngularWeight(bpolys[1]->point_edgemid_angles[edge_on_poly[1]]);
bpolys[0]->weight_angular *= ang_weights[0] * ang_weights[1];
bpolys[1]->weight_angular *= ang_weights[0] * ang_weights[1];
@@ -674,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;
@@ -707,9 +731,14 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
bpoly->dominant_angle_weight = sinf(bpoly->dominant_angle_weight * M_PI_2);
/* Compute quadratic angular scale interpolation weight */
- scale_weight = bpoly->point_edgemid_angles[bpoly->dominant_edge] / bpoly->edgemid_angle;
- scale_weight /= scale_weight +
- (bpoly->point_edgemid_angles[!bpoly->dominant_edge] / bpoly->edgemid_angle);
+ {
+ const float edge_angle_a = bpoly->point_edgemid_angles[bpoly->dominant_edge];
+ const float edge_angle_b = bpoly->point_edgemid_angles[!bpoly->dominant_edge];
+ /* Clamp so skinny faces with near zero `edgemid_angle`
+ * won't cause numeric problems. see T81988. */
+ scale_weight = edge_angle_a / max_ff(edge_angle_a, bpoly->edgemid_angle);
+ scale_weight /= scale_weight + (edge_angle_b / max_ff(edge_angle_b, bpoly->edgemid_angle));
+ }
sqr = scale_weight * scale_weight;
inv_sqr = 1.0f - scale_weight;
@@ -776,6 +805,11 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
bpoly->weight = 1.0f / bpoly->weight_angular / bpoly->weight_dist_proj / bpoly->weight_dist;
}
+ /* Apply after other kinds of scaling so the faces corner angle is always
+ * scaled in a uniform way, preventing heavily sub-divided triangle fans
+ * from having a lop-sided influence on the weighting, see T81988. */
+ bpoly->weight *= bpoly->edgemid_angle / M_PI;
+
tot_weight += bpoly->weight;
}
@@ -891,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++) {
@@ -1289,9 +1323,8 @@ static void surfacedeformModifier_do(ModifierData *md,
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;
}
@@ -1455,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 {
@@ -1484,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_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
index bbd1bdb6955..8556271bf87 100644
--- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
+++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
@@ -45,6 +45,8 @@
#include "BLI_span.hh"
#include "BLI_timeit.hh"
+#include "DEG_depsgraph_query.h"
+
#ifdef WITH_OPENVDB
# include <openvdb/tools/GridTransformer.h>
# include <openvdb/tools/VolumeToMesh.h>
@@ -237,7 +239,8 @@ static Mesh *new_mesh_from_openvdb_data(Span<openvdb::Vec3s> verts,
mesh->mpoly[i].loopstart = 3 * i;
mesh->mpoly[i].totloop = 3;
for (int j = 0; j < 3; j++) {
- mesh->mloop[3 * i + j].v = tris[i][j];
+ /* Reverse vertex order to get correct normals. */
+ mesh->mloop[3 * i + j].v = tris[i][2 - j];
}
}
@@ -248,7 +251,8 @@ static Mesh *new_mesh_from_openvdb_data(Span<openvdb::Vec3s> verts,
mesh->mpoly[poly_offset + i].loopstart = loop_offset + 4 * i;
mesh->mpoly[poly_offset + i].totloop = 4;
for (int j = 0; j < 4; j++) {
- mesh->mloop[loop_offset + 4 * i + j].v = quads[i][j];
+ /* Reverse vertex order to get correct normals. */
+ mesh->mloop[loop_offset + 4 * i + j].v = quads[i][3 - j];
}
}
@@ -258,31 +262,39 @@ static Mesh *new_mesh_from_openvdb_data(Span<openvdb::Vec3s> verts,
}
#endif
+static Mesh *create_empty_mesh(const Mesh *input_mesh)
+{
+ Mesh *new_mesh = BKE_mesh_new_nomain(0, 0, 0, 0, 0);
+ BKE_mesh_copy_settings(new_mesh, input_mesh);
+ return new_mesh;
+}
+
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *input_mesh)
{
#ifdef WITH_OPENVDB
VolumeToMeshModifierData *vmmd = reinterpret_cast<VolumeToMeshModifierData *>(md);
if (vmmd->object == nullptr) {
- return input_mesh;
+ return create_empty_mesh(input_mesh);
}
if (vmmd->object->type != OB_VOLUME) {
- return input_mesh;
+ return create_empty_mesh(input_mesh);
}
if (vmmd->resolution_mode == VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_SIZE &&
vmmd->voxel_size == 0.0f) {
- return input_mesh;
+ return create_empty_mesh(input_mesh);
}
if (vmmd->resolution_mode == VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_AMOUNT &&
vmmd->voxel_amount == 0) {
- return input_mesh;
+ return create_empty_mesh(input_mesh);
}
Volume *volume = static_cast<Volume *>(vmmd->object->data);
+ 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(vmmd->object, md, "Cannot find '%s' grid", vmmd->grid_name);
- return input_mesh;
+ BKE_modifier_set_error(ctx->object, md, "Cannot find '%s' grid", vmmd->grid_name);
+ return create_empty_mesh(input_mesh);
}
const openvdb::GridBase::ConstPtr grid = BKE_volume_grid_openvdb_for_read(volume, volume_grid);
@@ -291,7 +303,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
VolumeToMeshOp to_mesh_op{*grid, *vmmd, *ctx};
if (!BKE_volume_grid_type_operation(grid_type, to_mesh_op)) {
BKE_modifier_set_error(ctx->object, md, "Expected a scalar grid");
- return input_mesh;
+ return create_empty_mesh(input_mesh);
}
Mesh *mesh = new_mesh_from_openvdb_data(to_mesh_op.verts, to_mesh_op.tris, to_mesh_op.quads);
@@ -303,7 +315,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
#else
UNUSED_VARS(md);
BKE_modifier_set_error(ctx->object, md, "Compiled without OpenVDB");
- return input_mesh;
+ return create_empty_mesh(input_mesh);
#endif
}
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 31bed283d6b..b2874a0fdbb 100644
--- a/source/blender/nodes/intern/node_socket.cc
+++ b/source/blender/nodes/intern/node_socket.cc
@@ -544,8 +544,8 @@ static bNodeSocketType *make_socket_type_virtual(void)
ED_init_node_socket_type_virtual(stype);
stype->use_link_limits_of_type = true;
- stype->input_link_limit = 1;
- stype->output_link_limit = 1;
+ stype->input_link_limit = 0xFFF;
+ stype->output_link_limit = 0xFFF;
return 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/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_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c
index 578262e9f17..fb0b6e7b263 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_material.c
@@ -45,18 +45,29 @@ static int node_shader_gpu_output_material(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- GPUNodeLink *outlink, *alpha_threshold_link;
-
+ GPUNodeLink *outlink, *alpha_threshold_link, *shadow_threshold_link;
Material *ma = GPU_material_get_material(mat);
- if (ma && ma->blend_method == MA_BM_CLIP) {
- alpha_threshold_link = GPU_uniform(&ma->alpha_threshold);
+
+ static float no_alpha_threshold = -1.0f;
+ if (ma) {
+ alpha_threshold_link = GPU_uniform((ma->blend_method == MA_BM_CLIP) ? &ma->alpha_threshold :
+ &no_alpha_threshold);
+ shadow_threshold_link = GPU_uniform((ma->blend_shadow == MA_BS_CLIP) ? &ma->alpha_threshold :
+ &no_alpha_threshold);
}
else {
- static float no_alpha_threshold = -1.0f;
alpha_threshold_link = GPU_uniform(&no_alpha_threshold);
+ shadow_threshold_link = GPU_uniform(&no_alpha_threshold);
}
- GPU_stack_link(mat, node, "node_output_material", in, out, alpha_threshold_link, &outlink);
+ GPU_stack_link(mat,
+ node,
+ "node_output_material",
+ in,
+ out,
+ alpha_threshold_link,
+ shadow_threshold_link,
+ &outlink);
GPU_material_output_link(mat, outlink);
return true;
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/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c
index 476ddf2019a..30e0d94939d 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
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 d6ab76dac60..c16715b46fb 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -3604,20 +3604,30 @@ static PyObject *pyrna_struct_values(BPy_PropertyRNA *self)
}
PyDoc_STRVAR(pyrna_struct_is_property_set_doc,
- ".. method:: is_property_set(property)\n"
+ ".. method:: is_property_set(property, ghost=True)\n"
"\n"
" Check if a property is set, use for testing operator properties.\n"
"\n"
+ " :arg ghost: Used for operators that re-run with previous settings.\n"
+ " In this case the property is not marked as set,\n"
+ " yet the value from the previous execution is used.\n"
+ "\n"
+ " In rare cases you may want to set this option to false.\n"
+ "\n"
+ " :type ghost: boolean\n"
" :return: True when the property has been set.\n"
" :rtype: boolean\n");
-static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args)
+static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args, PyObject *kw)
{
PropertyRNA *prop;
const char *name;
+ bool use_ghost = true;
PYRNA_STRUCT_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "s:is_property_set", &name)) {
+ static const char *_keywords[] = {"", "ghost", NULL};
+ static _PyArg_Parser _parser = {"s|$O&:is_property_set", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &name, PyC_ParseBool, &use_ghost)) {
return NULL;
}
@@ -3629,7 +3639,7 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg
return NULL;
}
- return PyBool_FromLong(RNA_property_is_set(&self->ptr, prop));
+ return PyBool_FromLong(RNA_property_is_set_ex(&self->ptr, prop, use_ghost));
}
PyDoc_STRVAR(pyrna_struct_property_unset_doc,
@@ -5421,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;
}
@@ -5654,7 +5664,7 @@ static struct PyMethodDef pyrna_struct_methods[] = {
{"is_property_set",
(PyCFunction)pyrna_struct_is_property_set,
- METH_VARARGS,
+ METH_VARARGS | METH_KEYWORDS,
pyrna_struct_is_property_set_doc},
{"property_unset",
(PyCFunction)pyrna_struct_property_unset,
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_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..41caee1a39c 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -101,8 +101,8 @@ 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")
+ string(APPEND CMAKE_C_FLAGS_RELEASE " -mfpmath=sse")
+ string(APPEND CMAKE_CXX_FLAGS_RELEASE " -mfpmath=sse")
endif()
endif()
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index dd179f9461b..31c169f621b 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -200,7 +200,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 +282,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 */
@@ -798,7 +798,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 +807,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 +820,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 +830,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 +839,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 +847,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 +859,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 +871,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 +906,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 +932,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 +1032,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 +1102,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;
@@ -1196,8 +1196,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 +1206,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 +1224,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);
@@ -1264,7 +1264,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;
@@ -1275,16 +1275,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 +1308,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 +1377,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 +1386,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 +1425,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,9 +1435,9 @@ 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()
@@ -1449,7 +1449,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 +1699,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,9 +1964,9 @@ 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() */
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index fee1a26ca85..edf627c4e54 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1498,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/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index 12b80da9f59..e730aeb263d 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -656,13 +656,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_result.c b/source/blender/render/intern/source/render_result.c
index db75cb5cfed..990373bafa0 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -992,9 +992,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/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 12abc0f9216..ff9c462f603 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -174,37 +174,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 +214,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 +296,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 +348,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 +474,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 +541,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 +596,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 +657,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 +708,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 +758,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 +809,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/sequencer/CMakeLists.txt b/source/blender/sequencer/CMakeLists.txt
index 7aac6eebc66..3841a6e6414 100644
--- a/source/blender/sequencer/CMakeLists.txt
+++ b/source/blender/sequencer/CMakeLists.txt
@@ -42,12 +42,16 @@ set(INC_SYS
set(SRC
SEQ_sequencer.h
- intern/sequencer.c
- intern/sequencer.h
- intern/image_cache.c
intern/effects.c
+ intern/image_cache.c
intern/modifier.c
intern/prefetch.c
+ intern/proxy.c
+ intern/proxy.h
+ intern/render.c
+ intern/render.h
+ intern/sequencer.c
+ intern/sequencer.h
)
set(LIB
diff --git a/source/blender/sequencer/SEQ_sequencer.h b/source/blender/sequencer/SEQ_sequencer.h
index 90b1d611842..d969b43bd50 100644
--- a/source/blender/sequencer/SEQ_sequencer.h
+++ b/source/blender/sequencer/SEQ_sequencer.h
@@ -36,6 +36,7 @@ struct Main;
struct Mask;
struct ReportList;
struct Scene;
+struct SeqIndexBuildContext;
struct Sequence;
struct SequenceModifierData;
struct Stereo3dFormat;
@@ -43,7 +44,6 @@ struct StripElem;
struct TextVars;
struct bContext;
struct bSound;
-struct SeqIndexBuildContext;
/* Wipe effect */
enum {
@@ -108,7 +108,7 @@ void BKE_sequence_iterator_next(SeqIterator *iter);
void BKE_sequence_iterator_end(SeqIterator *iter);
/* **********************************************************************
- * sequencer.c
+ * render.c
*
* Sequencer render functions
* **********************************************************************
@@ -142,35 +142,37 @@ typedef struct SeqRenderData {
// bool gpu_full_samples;
} SeqRenderData;
-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);
-void BKE_sequence_alpha_mode_from_extension(struct Sequence *seq);
-void BKE_sequence_init_colorspace(struct Sequence *seq);
-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);
+struct ImBuf *SEQ_render_give_ibuf(const SeqRenderData *context, float cfra, int chanshown);
+struct ImBuf *SEQ_render_give_ibuf_direct(const SeqRenderData *context,
+ float cfra,
+ 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 cfra);
+struct StripElem *SEQ_render_give_stripelem(struct Sequence *seq, int cfra);
/* **********************************************************************
- * sequencer.c
+ * render.c
*
* Sequencer color space functions
* ********************************************************************** */
-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]);
+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 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);
@@ -212,28 +214,36 @@ 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);
-struct StripElem *BKE_sequencer_give_stripelem(struct Sequence *seq, int cfra);
+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_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);
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);
-double BKE_sequencer_rendersize_to_scale_factor(int size);
+
+/* **********************************************************************
+ * proxy.c
+ *
+ * Proxy functions
+ * ********************************************************************** */
+
+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
@@ -247,7 +257,7 @@ void BKE_sequencer_cache_iterate(struct Scene *scene,
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));
diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c
index ee94ecadb14..039c18bf51d 100644
--- a/source/blender/sequencer/intern/effects.c
+++ b/source/blender/sequencer/intern/effects.c
@@ -62,6 +62,7 @@
#include "BLF_api.h"
+#include "render.h"
#include "sequencer.h"
static struct SeqEffectHandle get_sequence_effect_impl(int seq_type);
@@ -151,15 +152,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);
@@ -2989,7 +2990,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, cfra, seq->multicam_source, seqbasep);
return out;
}
@@ -3018,7 +3019,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, cfra, seq->machine - 1, seqbasep);
}
/* found nothing? so let's work the way up the metastrip stack, so
@@ -3253,7 +3254,7 @@ float BKE_sequencer_speed_effect_target_frame_get(const SeqRenderData *context,
float cfra,
int input)
{
- int nr = BKE_sequencer_give_stripelem_index(seq, cfra);
+ int nr = seq_give_stripelem_index(seq, cfra);
SpeedControlVars *s = (SpeedControlVars *)seq->effectdata;
BKE_sequence_effect_speed_rebuild_map(context->scene, seq, false);
@@ -3272,7 +3273,7 @@ float BKE_sequencer_speed_effect_target_frame_get(const SeqRenderData *context,
static float speed_effect_interpolation_ratio_get(SpeedControlVars *s, Sequence *seq, float cfra)
{
- int nr = BKE_sequencer_give_stripelem_index(seq, cfra);
+ int nr = seq_give_stripelem_index(seq, cfra);
return s->frameMap[nr] - floor(s->frameMap[nr]);
}
@@ -3293,7 +3294,7 @@ static ImBuf *do_speed_effect(const SeqRenderData *context,
out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
facf0 = facf1 = speed_effect_interpolation_ratio_get(s, seq, cfra);
/* Current frame is ibuf1, next frame is ibuf2. */
- out = BKE_sequencer_effect_execute_threaded(
+ out = seq_render_effect_execute_threaded(
&cross_effect, context, NULL, cfra, facf0, facf1, ibuf1, ibuf2, ibuf3);
return out;
}
@@ -3905,7 +3906,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 */
diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c
index 1cde481cf16..4bbf1838b4e 100644
--- a/source/blender/sequencer/intern/image_cache.c
+++ b/source/blender/sequencer/intern/image_cache.c
@@ -50,6 +50,7 @@
#include "SEQ_sequencer.h"
+#include "render.h"
#include "sequencer.h"
/**
@@ -158,17 +159,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)
{
@@ -379,7 +383,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,
@@ -448,8 +452,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);
}
}
@@ -556,7 +561,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;
@@ -577,7 +582,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;
}
}
@@ -713,7 +718,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;
@@ -725,18 +730,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_stripelem_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)
@@ -849,15 +861,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;
}
}
@@ -866,17 +876,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;
@@ -956,8 +963,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;
}
}
@@ -965,8 +971,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;
}
}
@@ -1077,7 +1082,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) {
@@ -1092,9 +1097,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);
@@ -1191,10 +1201,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);
}
@@ -1202,8 +1211,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);
}
@@ -1215,8 +1225,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) {
@@ -1248,7 +1261,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);
@@ -1270,10 +1283,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);
}
}
}
@@ -1283,7 +1296,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,
@@ -1302,7 +1315,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;
}
@@ -1313,7 +1326,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,
@@ -1333,7 +1346,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;
@@ -1368,7 +1381,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;
@@ -1418,11 +1432,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) {
@@ -1439,7 +1456,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/modifier.c b/source/blender/sequencer/intern/modifier.c
index 6ddbbc6a8e9..cb15028cc23 100644
--- a/source/blender/sequencer/intern/modifier.c
+++ b/source/blender/sequencer/intern/modifier.c
@@ -46,6 +46,7 @@
#include "SEQ_sequencer.h"
+#include "render.h"
#include "sequencer.h"
static SequenceModifierTypeInfo *modifiersTypes[NUM_SEQUENCE_MODIFIER_TYPES];
@@ -82,19 +83,58 @@ typedef struct ModifierThread {
modifier_apply_threaded_cb apply_callback;
} ModifierThread;
+/**
+ * \a cfra 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 cfra,
+ 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, 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;
+}
+
static ImBuf *modifier_mask_get(SequenceModifierData *smd,
const SeqRenderData *context,
int cfra,
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,
+ cfra,
+ fra_offset,
+ make_float);
}
static void modifier_init_handle(void *handle_v, int start_line, int tot_line, void *init_data_v)
@@ -174,6 +214,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;
@@ -188,11 +513,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 = {
@@ -495,7 +850,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);
@@ -887,7 +1242,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];
@@ -1060,7 +1415,7 @@ ImBuf *BKE_sequence_modifier_apply_stack(const SeqRenderData *context,
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) {
@@ -1100,7 +1455,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;
diff --git a/source/blender/sequencer/intern/prefetch.c b/source/blender/sequencer/intern/prefetch.c
index 3ea3b6f1ac7..6eac15dec52 100644
--- a/source/blender/sequencer/intern/prefetch.c
+++ b/source/blender/sequencer/intern/prefetch.c
@@ -55,6 +55,7 @@
#include "SEQ_sequencer.h"
+#include "render.h"
#include "sequencer.h"
typedef struct PrefetchJob {
@@ -286,25 +287,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
@@ -361,7 +362,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;
@@ -460,7 +461,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);
diff --git a/source/blender/sequencer/intern/proxy.c b/source/blender/sequencer/intern/proxy.c
new file mode 100644
index 00000000000..94d5f5b701d
--- /dev/null
+++ b/source/blender/sequencer/intern/proxy.c
@@ -0,0 +1,570 @@
+/*
+ * 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 "SEQ_sequencer.h"
+
+#include "IMB_colormanagement.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_metadata.h"
+
+#include "proxy.h"
+#include "render.h"
+#include "sequencer.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 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 = 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, cfra)->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 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)seq_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) {
+ 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 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 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 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 */
+
+ 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 (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 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;
+ }
+}
diff --git a/source/blender/sequencer/intern/proxy.h b/source/blender/sequencer/intern/proxy.h
new file mode 100644
index 00000000000..3777cea9317
--- /dev/null
+++ b/source/blender/sequencer/intern/proxy.h
@@ -0,0 +1,40 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * 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 SeqRenderData;
+struct Sequence;
+
+#define PROXY_MAXFILE (2 * FILE_MAXDIR + FILE_MAXFILE)
+struct ImBuf *seq_proxy_fetch(const struct SeqRenderData *context, struct Sequence *seq, int cfra);
+bool seq_proxy_get_custom_file_fname(struct Sequence *seq, char *name, const int view_id);
+
+#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..c2e04ebeff8
--- /dev/null
+++ b/source/blender/sequencer/intern/render.c
@@ -0,0 +1,2106 @@
+/*
+ * 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 "proxy.h"
+#include "render.h"
+#include "sequencer.h"
+
+static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
+ SeqRenderState *state,
+ ListBase *seqbasep,
+ float cfra,
+ int chanshown);
+
+static ThreadMutex seq_render_mutex = BLI_MUTEX_INITIALIZER;
+SequencerDrawView sequencer_view3d_fn = NULL; /* NULL in background mode */
+
+/* -------------------------------------------------------------------- */
+/** \name Colorspace 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;
+}
+
+float seq_give_stripelem_index(Sequence *seq, float cfra)
+{
+ float nr;
+ 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 (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 *SEQ_render_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)seq_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 SEQ_render_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 seq_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;
+}
+
+/* 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(cfra))
+{
+ 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 cfra,
+ ImBuf *ibuf,
+ const bool UNUSED(is_proxy_image))
+{
+ 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, cfra);
+
+ 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 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;
+}
+
+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 *seq_render_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 = seq_render_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;
+}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \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(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 = SEQ_render_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)seq_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;
+ }
+
+ 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 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;
+}
+
+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 */
+ 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, 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;
+}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Strip stack rendering functions
+ * \{ */
+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 = seq_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) {
+ 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, nr);
+ break;
+ }
+ }
+
+ if (ibuf) {
+ seq_imbuf_assign_spaces(context->scene, ibuf);
+ }
+
+ return ibuf;
+}
+
+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);
+ 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 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 = seq_render_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 = seq_render_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 = seq_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 *SEQ_render_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;
+ seq_render_state_init(&state);
+ ImBuf *out = NULL;
+ Sequence *seq_arr[MAXSEQ + 1];
+ int count;
+
+ count = seq_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 *seq_render_give_ibuf_seqbase(const SeqRenderData *context,
+ float cfra,
+ int chan_shown,
+ ListBase *seqbasep)
+{
+ SeqRenderState state;
+ seq_render_state_init(&state);
+
+ return seq_render_strip_stack(context, &state, seqbasep, cfra, chan_shown);
+}
+
+ImBuf *SEQ_render_give_ibuf_direct(const SeqRenderData *context, float cfra, Sequence *seq)
+{
+ SeqRenderState state;
+ seq_render_state_init(&state);
+
+ ImBuf *ibuf = seq_render_strip(context, &state, seq, cfra);
+
+ return ibuf;
+}
+/** \} */
diff --git a/source/blender/sequencer/intern/render.h b/source/blender/sequencer/intern/render.h
new file mode 100644
index 00000000000..83214934e05
--- /dev/null
+++ b/source/blender/sequencer/intern/render.h
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+/* 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 cfra,
+ int chan_shown,
+ struct ListBase *seqbasep);
+struct ImBuf *seq_render_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_imbuf_to_sequencer_space(struct Scene *scene, struct ImBuf *ibuf, bool make_float);
+float seq_give_stripelem_index(struct Sequence *seq, float cfra);
+int seq_get_shown_sequences(struct ListBase *seqbasep,
+ int cfra,
+ int chanshown,
+ struct Sequence **seq_arr_out);
+struct ImBuf *seq_render_strip(const struct SeqRenderData *context,
+ struct SeqRenderState *state,
+ struct Sequence *seq,
+ float cfra);
+struct ImBuf *seq_render_mask(const struct SeqRenderData *context,
+ struct Mask *mask,
+ float nr,
+ 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 42134b38666..89709c54942 100644
--- a/source/blender/sequencer/intern/sequencer.c
+++ b/source/blender/sequencer/intern/sequencer.c
@@ -103,41 +103,14 @@
# include <AUD_Special.h>
#endif
-/* mutable state for sequencer */
-typedef struct SeqRenderState {
- LinkNode *scene_parents;
-} SeqRenderState;
-
-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)
{
@@ -162,11 +135,6 @@ static void printf_strip(Sequence *seq)
}
#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)
@@ -333,7 +301,7 @@ void BKE_sequence_free_anim(Sequence *seq)
/* 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;
@@ -523,147 +491,6 @@ 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 ***************** */
@@ -911,12 +738,12 @@ void BKE_sequence_calc(Scene *scene, Sequence *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)
+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);
@@ -1394,273 +1221,8 @@ ListBase *BKE_sequence_seqbase_get(Sequence *seq, int *r_offset)
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)
-{
- float nr;
- 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 (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)
+int seq_num_files(Scene *scene, char views_format, const bool is_multiview)
{
if (!is_multiview) {
return 1;
@@ -1673,7 +1235,7 @@ static int seq_num_files(Scene *scene, char views_format, const bool is_multivie
return BKE_scene_multiview_num_views_get(&scene->r);
}
-static void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir)
+void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir)
{
char dir[FILE_MAX];
char fname[FILE_MAXFILE];
@@ -1684,7 +1246,7 @@ static void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir)
IMB_anim_set_index_dir(anim, dir);
}
-static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile)
+void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile)
{
char dir[FILE_MAX];
char name[FILE_MAX];
@@ -1813,2362 +1375,6 @@ static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile)
}
}
-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)
{
@@ -5347,6 +2553,8 @@ static Strip *seq_strip_alloc(int type)
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");
}
@@ -5397,35 +2605,6 @@ void BKE_sequence_alpha_mode_from_extension(Sequence *seq)
}
}
-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);
- }
- }
- }
-}
-
float BKE_sequence_get_fps(Scene *scene, Sequence *seq)
{
switch (seq->type) {
diff --git a/source/blender/sequencer/intern/sequencer.h b/source/blender/sequencer/intern/sequencer.h
index 55e19f80fcd..a7217e45ddf 100644
--- a/source/blender/sequencer/intern/sequencer.h
+++ b/source/blender/sequencer/intern/sequencer.h
@@ -44,61 +44,10 @@ struct StripElem;
/* **********************************************************************
* sequencer.c
*
- * sequencer render functions
- * ********************************************************************** */
-
-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);
-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);
-
-/* **********************************************************************
- * sequencer.c
- *
- * sequencer color space functions
- * ********************************************************************** */
-
-void BKE_sequencer_imbuf_to_sequencer_space(struct Scene *scene,
- struct ImBuf *ibuf,
- bool make_float);
-
-/* **********************************************************************
- * sequencer.c
- *
* sequencer scene functions
* ********************************************************************** */
void BKE_sequencer_base_clipboard_pointers_free(struct ListBase *seqbase);
-int BKE_sequencer_get_shown_sequences(struct ListBase *seqbasep,
- int cfra,
- int chanshown,
- struct Sequence **seq_arr_out);
-bool BKE_sequencer_input_have_to_preprocess(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra);
-float BKE_sequencer_give_stripelem_index(struct Sequence *seq, float cfra);
-
/* **********************************************************************
* image_cache.c
*
@@ -107,12 +56,12 @@ float BKE_sequencer_give_stripelem_index(struct Sequence *seq, float cfra);
struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context,
struct Sequence *seq,
- float cfra,
+ float timeline_frame,
int type,
bool skip_disk_cache);
void BKE_sequencer_cache_put(const SeqRenderData *context,
struct Sequence *seq,
- float cfra,
+ float timeline_frame,
int type,
struct ImBuf *i,
float cost,
@@ -125,7 +74,7 @@ bool BKE_sequencer_cache_put_if_possible(const SeqRenderData *context,
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_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,
@@ -174,6 +123,16 @@ void BKE_sequence_sound_init(struct Scene *scene, struct Sequence *seq);
struct Sequence *BKE_sequence_metastrip(ListBase *seqbase /* = ed->seqbase */,
struct Sequence *meta /* = NULL */,
struct Sequence *seq);
+void seq_free_sequence_recurse(struct Scene *scene, struct Sequence *seq, const bool do_id_user);
+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);
+void seq_open_anim_file(struct Scene *scene, struct Sequence *seq, bool openfile);
+void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir);
/* **********************************************************************
* sequencer.c
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..57276be469c 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"
@@ -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;
}
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..49868296295 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"
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/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index e7010461c68..68547323761 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -120,6 +120,8 @@ IDTypeInfo IDType_ID_WM = {
.blend_read_data = NULL,
.blend_read_lib = NULL,
.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_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 4f2be59eb1a..071951abda3 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1731,8 +1731,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 +3484,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);
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 19e4adde19c..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",
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_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index eccad214305..a1140c01d44 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -227,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;
}
@@ -251,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) {
@@ -587,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 523147cd4f3..7621862708e 100644
--- a/source/blender/windowmanager/intern/wm_operator_type.c
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@ -325,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 4604f66d866..7b1d69e83c7 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;
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 {