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:
authorHans Goudey <h.goudey@me.com>2020-08-12 04:59:16 +0300
committerHans Goudey <h.goudey@me.com>2020-08-12 04:59:16 +0300
commitef11238c743e6985fe325280fb13e05d6ec27378 (patch)
tree1dd2605a676bee52296535825b99f000a9c255eb
parent1f768bbe4145daed111636ca09dd53b25b8d29b5 (diff)
parentec5f39208785c1bbe723054ffe69e1ac2ab470dd (diff)
Merge branch 'master' into property-search-uiproperty-search-ui
-rw-r--r--.clang-tidy9
-rw-r--r--CMakeLists.txt2
-rw-r--r--build_files/build_environment/CMakeLists.txt1
-rw-r--r--build_files/build_environment/cmake/gmp.cmake88
-rw-r--r--build_files/build_environment/cmake/harvest.cmake2
-rw-r--r--build_files/build_environment/cmake/ispc.cmake1
-rw-r--r--build_files/build_environment/cmake/versions.cmake4
-rwxr-xr-xbuild_files/build_environment/install_deps.sh373
-rw-r--r--build_files/build_environment/patches/cmakelists_gmpxx.txt22
-rw-r--r--build_files/build_environment/patches/config_gmpxx.h668
-rw-r--r--build_files/buildbot/buildbot_utils.py6
-rwxr-xr-xbuild_files/buildbot/worker_bundle_dmg.py17
-rw-r--r--build_files/buildbot/worker_compile.py5
-rw-r--r--build_files/buildbot/worker_pack.py5
-rw-r--r--build_files/cmake/Modules/FindAlembic.cmake2
-rw-r--r--build_files/cmake/Modules/FindBlosc.cmake2
-rw-r--r--build_files/cmake/Modules/FindEmbree.cmake12
-rw-r--r--build_files/cmake/Modules/FindGLEW.cmake2
-rw-r--r--build_files/cmake/Modules/FindGMP.cmake96
-rw-r--r--build_files/cmake/Modules/FindOSL.cmake (renamed from build_files/cmake/Modules/FindOpenShadingLanguage.cmake)0
-rw-r--r--build_files/cmake/Modules/FindOpenCOLLADA.cmake3
-rw-r--r--build_files/cmake/Modules/FindOpenSubdiv.cmake3
-rw-r--r--build_files/cmake/Modules/FindOpenVDB.cmake2
-rw-r--r--build_files/cmake/Modules/FindXR_OpenXR_SDK.cmake (renamed from build_files/cmake/Modules/FindXR-OpenXR-SDK.cmake)2
-rw-r--r--build_files/cmake/Modules/GTest.cmake550
-rw-r--r--build_files/cmake/Modules/GTestAddTests.cmake191
-rw-r--r--build_files/cmake/config/blender_full.cmake1
-rw-r--r--build_files/cmake/config/blender_lite.cmake1
-rw-r--r--build_files/cmake/config/blender_release.cmake1
-rw-r--r--build_files/cmake/macros.cmake23
-rw-r--r--build_files/cmake/platform/platform_apple.cmake12
-rw-r--r--build_files/cmake/platform/platform_unix.cmake14
-rw-r--r--build_files/cmake/platform/platform_win32.cmake7
-rw-r--r--doc/python_api/examples/gpu.7.py1
-rw-r--r--doc/python_api/examples/gpu.8.py1
-rw-r--r--extern/audaspace/bindings/python/PySound.cpp6
-rw-r--r--extern/audaspace/src/respec/JOSResampleReader.cpp8
-rw-r--r--extern/bullet2/patches/btPolyhedralConvexShape_Inertia_fix.patch41
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp16
-rw-r--r--extern/mantaflow/preprocessed/gitinfo.h2
-rw-r--r--extern/mantaflow/preprocessed/grid.h102
-rw-r--r--extern/mantaflow/preprocessed/grid.h.reg.cpp186
-rw-r--r--intern/CMakeLists.txt4
-rw-r--r--intern/clog/clog.c29
-rw-r--r--intern/cycles/blender/blender_mesh.cpp77
-rw-r--r--intern/cycles/blender/blender_session.cpp5
-rw-r--r--intern/cycles/blender/blender_shader.cpp4
-rw-r--r--intern/cycles/blender/blender_util.h6
-rw-r--r--intern/cycles/blender/blender_volume.cpp75
-rw-r--r--intern/cycles/kernel/kernel_light_background.h2
-rw-r--r--intern/cycles/render/graph.cpp4
-rw-r--r--intern/cycles/render/image.cpp6
-rw-r--r--intern/cycles/render/image.h2
-rw-r--r--intern/cycles/render/session.cpp10
-rw-r--r--intern/cycles/test/CMakeLists.txt1
-rw-r--r--intern/cycles/test/util_transform_test.cpp53
-rw-r--r--intern/cycles/util/util_math_fast.h20
-rw-r--r--intern/cycles/util/util_math_float4.h18
-rw-r--r--intern/cycles/util/util_transform.cpp28
-rw-r--r--intern/cycles/util/util_transform.h11
-rw-r--r--intern/ffmpeg/CMakeLists.txt (renamed from tests/gtests/ffmpeg/CMakeLists.txt)46
-rw-r--r--intern/ffmpeg/tests/ffmpeg_codecs.cc (renamed from tests/gtests/ffmpeg/ffmpeg_codecs.cc)12
-rw-r--r--intern/ghost/GHOST_C-api.h5
-rw-r--r--intern/ghost/GHOST_IContext.h5
-rw-r--r--intern/ghost/GHOST_IEvent.h5
-rw-r--r--intern/ghost/GHOST_IEventConsumer.h5
-rw-r--r--intern/ghost/GHOST_ISystem.h5
-rw-r--r--intern/ghost/GHOST_ISystemPaths.h5
-rw-r--r--intern/ghost/GHOST_ITimerTask.h5
-rw-r--r--intern/ghost/GHOST_IWindow.h5
-rw-r--r--intern/ghost/GHOST_IXrContext.h5
-rw-r--r--intern/ghost/GHOST_Path-api.h5
-rw-r--r--intern/ghost/GHOST_Rect.h5
-rw-r--r--intern/ghost/GHOST_Types.h5
-rw-r--r--intern/ghost/intern/GHOST_Buttons.h5
-rw-r--r--intern/ghost/intern/GHOST_CallbackEventConsumer.h5
-rw-r--r--intern/ghost/intern/GHOST_Context.h5
-rw-r--r--intern/ghost/intern/GHOST_ContextCGL.h5
-rw-r--r--intern/ghost/intern/GHOST_ContextD3D.h5
-rw-r--r--intern/ghost/intern/GHOST_ContextEGL.cpp2
-rw-r--r--intern/ghost/intern/GHOST_ContextEGL.h5
-rw-r--r--intern/ghost/intern/GHOST_ContextGLX.h5
-rw-r--r--intern/ghost/intern/GHOST_ContextNone.h5
-rw-r--r--intern/ghost/intern/GHOST_ContextSDL.h5
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.h5
-rw-r--r--intern/ghost/intern/GHOST_Debug.h5
-rw-r--r--intern/ghost/intern/GHOST_DisplayManager.h5
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerCocoa.h5
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerNULL.h5
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerSDL.h5
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerWin32.h5
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerX11.h5
-rw-r--r--intern/ghost/intern/GHOST_DropTargetWin32.h5
-rw-r--r--intern/ghost/intern/GHOST_DropTargetX11.h5
-rw-r--r--intern/ghost/intern/GHOST_Event.h5
-rw-r--r--intern/ghost/intern/GHOST_EventButton.h5
-rw-r--r--intern/ghost/intern/GHOST_EventCursor.h5
-rw-r--r--intern/ghost/intern/GHOST_EventDragnDrop.h5
-rw-r--r--intern/ghost/intern/GHOST_EventKey.h5
-rw-r--r--intern/ghost/intern/GHOST_EventManager.h5
-rw-r--r--intern/ghost/intern/GHOST_EventNDOF.h5
-rw-r--r--intern/ghost/intern/GHOST_EventPrinter.h5
-rw-r--r--intern/ghost/intern/GHOST_EventString.h5
-rw-r--r--intern/ghost/intern/GHOST_EventTrackpad.h5
-rw-r--r--intern/ghost/intern/GHOST_EventWheel.h5
-rw-r--r--intern/ghost/intern/GHOST_IXrGraphicsBinding.h5
-rw-r--r--intern/ghost/intern/GHOST_IconX11.h5
-rw-r--r--intern/ghost/intern/GHOST_ImeWin32.h4
-rw-r--r--intern/ghost/intern/GHOST_ModifierKeys.h5
-rw-r--r--intern/ghost/intern/GHOST_NDOFManager.h5
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerCocoa.h5
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerUnix.h5
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerWin32.h5
-rw-r--r--intern/ghost/intern/GHOST_System.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemNULL.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemPaths.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsCocoa.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsUnix.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsWin32.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemSDL.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp8
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h4
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp6
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.h5
-rw-r--r--intern/ghost/intern/GHOST_TaskbarWin32.h5
-rw-r--r--intern/ghost/intern/GHOST_TaskbarX11.h5
-rw-r--r--intern/ghost/intern/GHOST_TimerManager.h5
-rw-r--r--intern/ghost/intern/GHOST_TimerTask.h5
-rw-r--r--intern/ghost/intern/GHOST_Window.h5
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.h5
-rw-r--r--intern/ghost/intern/GHOST_WindowManager.h5
-rw-r--r--intern/ghost/intern/GHOST_WindowNULL.h5
-rw-r--r--intern/ghost/intern/GHOST_WindowSDL.h5
-rw-r--r--intern/ghost/intern/GHOST_WindowWayland.h5
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.h5
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp22
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.h5
-rw-r--r--intern/ghost/intern/GHOST_XrContext.h5
-rw-r--r--intern/ghost/intern/GHOST_XrException.h5
-rw-r--r--intern/ghost/intern/GHOST_XrSession.h5
-rw-r--r--intern/ghost/intern/GHOST_XrSwapchain.h5
-rw-r--r--intern/ghost/intern/GHOST_Xr_intern.h5
-rw-r--r--intern/ghost/intern/GHOST_Xr_openxr_includes.h5
-rw-r--r--intern/ghost/test/multitest/MultiTest.c9
-rw-r--r--intern/guardedalloc/CMakeLists.txt16
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h2
-rw-r--r--intern/guardedalloc/intern/leak_detector.cc2
-rw-r--r--intern/guardedalloc/intern/mallocn_guarded_impl.c21
-rw-r--r--intern/guardedalloc/intern/mallocn_lockfree_impl.c10
-rw-r--r--intern/guardedalloc/intern/mmap_win.c43
-rw-r--r--intern/guardedalloc/tests/guardedalloc_alignment_test.cc (renamed from tests/gtests/guardedalloc/guardedalloc_alignment_test.cc)0
-rw-r--r--intern/guardedalloc/tests/guardedalloc_overflow_test.cc (renamed from tests/gtests/guardedalloc/guardedalloc_overflow_test.cc)5
-rw-r--r--intern/itasc/Scene.cpp1079
-rw-r--r--intern/mantaflow/extern/manta_fluid_API.h17
-rw-r--r--intern/mantaflow/intern/MANTA_main.cpp542
-rw-r--r--intern/mantaflow/intern/MANTA_main.h170
-rw-r--r--intern/mantaflow/intern/manta_fluid_API.cpp93
-rw-r--r--intern/mantaflow/intern/strings/fluid_script.h26
-rw-r--r--intern/opencolorio/ocio_impl_glsl.cc141
-rw-r--r--intern/rigidbody/RBI_api.h8
-rw-r--r--intern/rigidbody/rb_bullet_api.cpp69
-rw-r--r--intern/sky/include/sky_model.h8
-rw-r--r--intern/sky/source/sky_model.cpp12
m---------release/datafiles/locale0
m---------release/scripts/addons0
-rw-r--r--release/scripts/modules/bl_i18n_utils/utils_spell_check.py6
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/blender_default.py83
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py12
-rw-r--r--release/scripts/startup/bl_operators/uvcalc_lightmap.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_constraint.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_paint_common.py58
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_rigidbody.py46
-rw-r--r--release/scripts/startup/bl_ui/space_graph.py2
-rw-r--r--release/scripts/startup/bl_ui/space_node.py4
-rw-r--r--release/scripts/startup/bl_ui/space_sequencer.py2
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py66
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py91
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py19
-rw-r--r--release/scripts/startup/nodeitems_builtins.py3
-rw-r--r--source/blender/blenfont/BLF_api.h5
-rw-r--r--source/blender/blenfont/intern/blf.c4
-rw-r--r--source/blender/blenfont/intern/blf_internal.h5
-rw-r--r--source/blender/blenfont/intern/blf_internal_types.h5
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h6
-rw-r--r--source/blender/blenkernel/BKE_action.h10
-rw-r--r--source/blender/blenkernel/BKE_addon.h5
-rw-r--r--source/blender/blenkernel/BKE_anim_data.h5
-rw-r--r--source/blender/blenkernel/BKE_anim_path.h5
-rw-r--r--source/blender/blenkernel/BKE_anim_visualization.h5
-rw-r--r--source/blender/blenkernel/BKE_animsys.h18
-rw-r--r--source/blender/blenkernel/BKE_appdir.h5
-rw-r--r--source/blender/blenkernel/BKE_armature.h27
-rw-r--r--source/blender/blenkernel/BKE_autoexec.h5
-rw-r--r--source/blender/blenkernel/BKE_blender.h5
-rw-r--r--source/blender/blenkernel/BKE_blender_copybuffer.h5
-rw-r--r--source/blender/blenkernel/BKE_blender_undo.h5
-rw-r--r--source/blender/blenkernel/BKE_blender_user_menu.h5
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h5
-rw-r--r--source/blender/blenkernel/BKE_blendfile.h5
-rw-r--r--source/blender/blenkernel/BKE_boids.h5
-rw-r--r--source/blender/blenkernel/BKE_bpath.h5
-rw-r--r--source/blender/blenkernel/BKE_brush.h5
-rw-r--r--source/blender/blenkernel/BKE_bvhutils.h5
-rw-r--r--source/blender/blenkernel/BKE_cachefile.h5
-rw-r--r--source/blender/blenkernel/BKE_callbacks.h5
-rw-r--r--source/blender/blenkernel/BKE_camera.h5
-rw-r--r--source/blender/blenkernel/BKE_ccg.h5
-rw-r--r--source/blender/blenkernel/BKE_cdderivedmesh.h5
-rw-r--r--source/blender/blenkernel/BKE_cloth.h5
-rw-r--r--source/blender/blenkernel/BKE_collection.h5
-rw-r--r--source/blender/blenkernel/BKE_collision.h5
-rw-r--r--source/blender/blenkernel/BKE_colorband.h5
-rw-r--r--source/blender/blenkernel/BKE_colortools.h7
-rw-r--r--source/blender/blenkernel/BKE_constraint.h5
-rw-r--r--source/blender/blenkernel/BKE_context.h5
-rw-r--r--source/blender/blenkernel/BKE_crazyspace.h5
-rw-r--r--source/blender/blenkernel/BKE_curve.h11
-rw-r--r--source/blender/blenkernel/BKE_curveprofile.h7
-rw-r--r--source/blender/blenkernel/BKE_customdata.h6
-rw-r--r--source/blender/blenkernel/BKE_customdata_file.h5
-rw-r--r--source/blender/blenkernel/BKE_data_transfer.h5
-rw-r--r--source/blender/blenkernel/BKE_deform.h5
-rw-r--r--source/blender/blenkernel/BKE_displist.h5
-rw-r--r--source/blender/blenkernel/BKE_displist_tangent.h5
-rw-r--r--source/blender/blenkernel/BKE_duplilist.h5
-rw-r--r--source/blender/blenkernel/BKE_dynamicpaint.h5
-rw-r--r--source/blender/blenkernel/BKE_editlattice.h5
-rw-r--r--source/blender/blenkernel/BKE_editmesh.h5
-rw-r--r--source/blender/blenkernel/BKE_editmesh_bvh.h5
-rw-r--r--source/blender/blenkernel/BKE_editmesh_cache.h5
-rw-r--r--source/blender/blenkernel/BKE_editmesh_tangent.h5
-rw-r--r--source/blender/blenkernel/BKE_effect.h5
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h5
-rw-r--r--source/blender/blenkernel/BKE_fcurve_driver.h5
-rw-r--r--source/blender/blenkernel/BKE_fluid.h5
-rw-r--r--source/blender/blenkernel/BKE_font.h5
-rw-r--r--source/blender/blenkernel/BKE_freestyle.h5
-rw-r--r--source/blender/blenkernel/BKE_global.h28
-rw-r--r--source/blender/blenkernel/BKE_gpencil.h5
-rw-r--r--source/blender/blenkernel/BKE_gpencil_curve.h5
-rw-r--r--source/blender/blenkernel/BKE_gpencil_geom.h7
-rw-r--r--source/blender/blenkernel/BKE_gpencil_modifier.h5
-rw-r--r--source/blender/blenkernel/BKE_hair.h5
-rw-r--r--source/blender/blenkernel/BKE_icons.h5
-rw-r--r--source/blender/blenkernel/BKE_idprop.h5
-rw-r--r--source/blender/blenkernel/BKE_idtype.h5
-rw-r--r--source/blender/blenkernel/BKE_image.h34
-rw-r--r--source/blender/blenkernel/BKE_image_save.h5
-rw-r--r--source/blender/blenkernel/BKE_ipo.h5
-rw-r--r--source/blender/blenkernel/BKE_kelvinlet.h5
-rw-r--r--source/blender/blenkernel/BKE_key.h5
-rw-r--r--source/blender/blenkernel/BKE_keyconfig.h5
-rw-r--r--source/blender/blenkernel/BKE_lattice.h9
-rw-r--r--source/blender/blenkernel/BKE_layer.h5
-rw-r--r--source/blender/blenkernel/BKE_lib_id.h5
-rw-r--r--source/blender/blenkernel/BKE_lib_override.h7
-rw-r--r--source/blender/blenkernel/BKE_lib_query.h5
-rw-r--r--source/blender/blenkernel/BKE_lib_remap.h5
-rw-r--r--source/blender/blenkernel/BKE_library.h5
-rw-r--r--source/blender/blenkernel/BKE_light.h5
-rw-r--r--source/blender/blenkernel/BKE_lightprobe.h5
-rw-r--r--source/blender/blenkernel/BKE_linestyle.h5
-rw-r--r--source/blender/blenkernel/BKE_main.h5
-rw-r--r--source/blender/blenkernel/BKE_main_idmap.h5
-rw-r--r--source/blender/blenkernel/BKE_mask.h5
-rw-r--r--source/blender/blenkernel/BKE_material.h5
-rw-r--r--source/blender/blenkernel/BKE_mball.h5
-rw-r--r--source/blender/blenkernel/BKE_mball_tessellate.h5
-rw-r--r--source/blender/blenkernel/BKE_mesh.h7
-rw-r--r--source/blender/blenkernel/BKE_mesh_iterators.h5
-rw-r--r--source/blender/blenkernel/BKE_mesh_mapping.h5
-rw-r--r--source/blender/blenkernel/BKE_mesh_mirror.h5
-rw-r--r--source/blender/blenkernel/BKE_mesh_remap.h5
-rw-r--r--source/blender/blenkernel/BKE_mesh_remesh_voxel.h5
-rw-r--r--source/blender/blenkernel/BKE_mesh_runtime.h5
-rw-r--r--source/blender/blenkernel/BKE_mesh_tangent.h5
-rw-r--r--source/blender/blenkernel/BKE_mesh_wrapper.h5
-rw-r--r--source/blender/blenkernel/BKE_modifier.h11
-rw-r--r--source/blender/blenkernel/BKE_movieclip.h10
-rw-r--r--source/blender/blenkernel/BKE_multires.h5
-rw-r--r--source/blender/blenkernel/BKE_nla.h5
-rw-r--r--source/blender/blenkernel/BKE_node.h8
-rw-r--r--source/blender/blenkernel/BKE_object.h35
-rw-r--r--source/blender/blenkernel/BKE_object_deform.h5
-rw-r--r--source/blender/blenkernel/BKE_object_facemap.h5
-rw-r--r--source/blender/blenkernel/BKE_ocean.h11
-rw-r--r--source/blender/blenkernel/BKE_outliner_treehash.h5
-rw-r--r--source/blender/blenkernel/BKE_packedFile.h5
-rw-r--r--source/blender/blenkernel/BKE_paint.h107
-rw-r--r--source/blender/blenkernel/BKE_particle.h9
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h5
-rw-r--r--source/blender/blenkernel/BKE_persistent_data_handle.hh7
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h5
-rw-r--r--source/blender/blenkernel/BKE_pointcloud.h5
-rw-r--r--source/blender/blenkernel/BKE_report.h5
-rw-r--r--source/blender/blenkernel/BKE_rigidbody.h5
-rw-r--r--source/blender/blenkernel/BKE_scene.h5
-rw-r--r--source/blender/blenkernel/BKE_screen.h7
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h12
-rw-r--r--source/blender/blenkernel/BKE_sequencer_offscreen.h5
-rw-r--r--source/blender/blenkernel/BKE_shader_fx.h5
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h5
-rw-r--r--source/blender/blenkernel/BKE_simulation.h5
-rw-r--r--source/blender/blenkernel/BKE_softbody.h5
-rw-r--r--source/blender/blenkernel/BKE_sound.h5
-rw-r--r--source/blender/blenkernel/BKE_speaker.h5
-rw-r--r--source/blender/blenkernel/BKE_studiolight.h5
-rw-r--r--source/blender/blenkernel/BKE_subdiv.h5
-rw-r--r--source/blender/blenkernel/BKE_subdiv_ccg.h7
-rw-r--r--source/blender/blenkernel/BKE_subdiv_deform.h5
-rw-r--r--source/blender/blenkernel/BKE_subdiv_eval.h5
-rw-r--r--source/blender/blenkernel/BKE_subdiv_foreach.h5
-rw-r--r--source/blender/blenkernel/BKE_subdiv_mesh.h5
-rw-r--r--source/blender/blenkernel/BKE_subdiv_topology.h5
-rw-r--r--source/blender/blenkernel/BKE_subsurf.h5
-rw-r--r--source/blender/blenkernel/BKE_text.h5
-rw-r--r--source/blender/blenkernel/BKE_text_suggestions.h5
-rw-r--r--source/blender/blenkernel/BKE_texture.h5
-rw-r--r--source/blender/blenkernel/BKE_tracking.h5
-rw-r--r--source/blender/blenkernel/BKE_undo_system.h5
-rw-r--r--source/blender/blenkernel/BKE_unit.h5
-rw-r--r--source/blender/blenkernel/BKE_volume.h5
-rw-r--r--source/blender/blenkernel/BKE_volume_render.h5
-rw-r--r--source/blender/blenkernel/BKE_workspace.h5
-rw-r--r--source/blender/blenkernel/BKE_world.h5
-rw-r--r--source/blender/blenkernel/BKE_writeavi.h5
-rw-r--r--source/blender/blenkernel/BKE_writeffmpeg.h5
-rw-r--r--source/blender/blenkernel/CMakeLists.txt2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c10
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.h5
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_inline.h5
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_intern.h5
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c34
-rw-r--r--source/blender/blenkernel/intern/action.c49
-rw-r--r--source/blender/blenkernel/intern/anim_data.c86
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c2
-rw-r--r--source/blender/blenkernel/intern/armature.c46
-rw-r--r--source/blender/blenkernel/intern/armature_update.c2
-rw-r--r--source/blender/blenkernel/intern/boids.c2
-rw-r--r--source/blender/blenkernel/intern/bpath.c2
-rw-r--r--source/blender/blenkernel/intern/brush.c69
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c22
-rw-r--r--source/blender/blenkernel/intern/cachefile.c2
-rw-r--r--source/blender/blenkernel/intern/camera.c124
-rw-r--r--source/blender/blenkernel/intern/cloth.c4
-rw-r--r--source/blender/blenkernel/intern/collection.c37
-rw-r--r--source/blender/blenkernel/intern/collision.c41
-rw-r--r--source/blender/blenkernel/intern/colorband.c21
-rw-r--r--source/blender/blenkernel/intern/colortools.c51
-rw-r--r--source/blender/blenkernel/intern/constraint.c24
-rw-r--r--source/blender/blenkernel/intern/context.c97
-rw-r--r--source/blender/blenkernel/intern/curve.c219
-rw-r--r--source/blender/blenkernel/intern/curve_bevel.c272
-rw-r--r--source/blender/blenkernel/intern/curveprofile.c29
-rw-r--r--source/blender/blenkernel/intern/customdata.c77
-rw-r--r--source/blender/blenkernel/intern/customdata_file.c10
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c39
-rw-r--r--source/blender/blenkernel/intern/data_transfer_intern.h5
-rw-r--r--source/blender/blenkernel/intern/deform.c83
-rw-r--r--source/blender/blenkernel/intern/displist.c24
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c20
-rw-r--r--source/blender/blenkernel/intern/editmesh_bvh.c3
-rw-r--r--source/blender/blenkernel/intern/editmesh_cache.c9
-rw-r--r--source/blender/blenkernel/intern/editmesh_tangent.c4
-rw-r--r--source/blender/blenkernel/intern/effect.c4
-rw-r--r--source/blender/blenkernel/intern/fcurve.c4
-rw-r--r--source/blender/blenkernel/intern/fcurve_driver.c35
-rw-r--r--source/blender/blenkernel/intern/fluid.c136
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c71
-rw-r--r--source/blender/blenkernel/intern/font.c67
-rw-r--r--source/blender/blenkernel/intern/gpencil.c68
-rw-r--r--source/blender/blenkernel/intern/gpencil_curve.c18
-rw-r--r--source/blender/blenkernel/intern/gpencil_geom.c55
-rw-r--r--source/blender/blenkernel/intern/gpencil_modifier.c5
-rw-r--r--source/blender/blenkernel/intern/hair.c4
-rw-r--r--source/blender/blenkernel/intern/icons.c19
-rw-r--r--source/blender/blenkernel/intern/idprop.c33
-rw-r--r--source/blender/blenkernel/intern/idtype.c5
-rw-r--r--source/blender/blenkernel/intern/image.c262
-rw-r--r--source/blender/blenkernel/intern/image_gpu.c774
-rw-r--r--source/blender/blenkernel/intern/ipo.c16
-rw-r--r--source/blender/blenkernel/intern/key.c2
-rw-r--r--source/blender/blenkernel/intern/lattice.c14
-rw-r--r--source/blender/blenkernel/intern/lattice_deform.c2
-rw-r--r--source/blender/blenkernel/intern/layer.c27
-rw-r--r--source/blender/blenkernel/intern/lib_id.c15
-rw-r--r--source/blender/blenkernel/intern/lib_intern.h5
-rw-r--r--source/blender/blenkernel/intern/lib_override.c7
-rw-r--r--source/blender/blenkernel/intern/lib_query.c5
-rw-r--r--source/blender/blenkernel/intern/light.c2
-rw-r--r--source/blender/blenkernel/intern/main_idmap.c2
-rw-r--r--source/blender/blenkernel/intern/mask.c137
-rw-r--r--source/blender/blenkernel/intern/mask_evaluate.c13
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c70
-rw-r--r--source/blender/blenkernel/intern/material.c65
-rw-r--r--source/blender/blenkernel/intern/mball.c7
-rw-r--r--source/blender/blenkernel/intern/mball_tessellate.c6
-rw-r--r--source/blender/blenkernel/intern/mesh.c68
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c28
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c34
-rw-r--r--source/blender/blenkernel/intern/mesh_mapping.c7
-rw-r--r--source/blender/blenkernel/intern/mesh_merge.c18
-rw-r--r--source/blender/blenkernel/intern/mesh_mirror.c2
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c10
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c18
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c48
-rw-r--r--source/blender/blenkernel/intern/mesh_wrapper.c8
-rw-r--r--source/blender/blenkernel/intern/modifier.c65
-rw-r--r--source/blender/blenkernel/intern/movieclip.c90
-rw-r--r--source/blender/blenkernel/intern/multires.c29
-rw-r--r--source/blender/blenkernel/intern/multires_inline.h5
-rw-r--r--source/blender/blenkernel/intern/multires_reshape.h4
-rw-r--r--source/blender/blenkernel/intern/multires_reshape_apply_base.c6
-rw-r--r--source/blender/blenkernel/intern/multires_reshape_ccg.c2
-rw-r--r--source/blender/blenkernel/intern/multires_reshape_util.c2
-rw-r--r--source/blender/blenkernel/intern/multires_unsubdivide.c8
-rw-r--r--source/blender/blenkernel/intern/multires_unsubdivide.h5
-rw-r--r--source/blender/blenkernel/intern/nla.c103
-rw-r--r--source/blender/blenkernel/intern/node.c40
-rw-r--r--source/blender/blenkernel/intern/object.c183
-rw-r--r--source/blender/blenkernel/intern/object_deform.c2
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c176
-rw-r--r--source/blender/blenkernel/intern/object_facemap.c2
-rw-r--r--source/blender/blenkernel/intern/ocean.c23
-rw-r--r--source/blender/blenkernel/intern/ocean_intern.h5
-rw-r--r--source/blender/blenkernel/intern/packedFile.c29
-rw-r--r--source/blender/blenkernel/intern/paint.c104
-rw-r--r--source/blender/blenkernel/intern/particle.c200
-rw-r--r--source/blender/blenkernel/intern/particle_child.c9
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c16
-rw-r--r--source/blender/blenkernel/intern/particle_system.c331
-rw-r--r--source/blender/blenkernel/intern/pbvh.c92
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c14
-rw-r--r--source/blender/blenkernel/intern/pbvh_intern.h5
-rw-r--r--source/blender/blenkernel/intern/pointcache.c81
-rw-r--r--source/blender/blenkernel/intern/pointcloud.c4
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c127
-rw-r--r--source/blender/blenkernel/intern/scene.c170
-rw-r--r--source/blender/blenkernel/intern/screen.c8
-rw-r--r--source/blender/blenkernel/intern/seqcache.c25
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c33
-rw-r--r--source/blender/blenkernel/intern/seqmodifier.c8
-rw-r--r--source/blender/blenkernel/intern/seqprefetch.c2
-rw-r--r--source/blender/blenkernel/intern/sequencer.c215
-rw-r--r--source/blender/blenkernel/intern/shader_fx.c5
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c35
-rw-r--r--source/blender/blenkernel/intern/simulation.cc9
-rw-r--r--source/blender/blenkernel/intern/softbody.c31
-rw-r--r--source/blender/blenkernel/intern/sound.c12
-rw-r--r--source/blender/blenkernel/intern/studiolight.c51
-rw-r--r--source/blender/blenkernel/intern/subdiv_ccg.c56
-rw-r--r--source/blender/blenkernel/intern/subdiv_converter.h5
-rw-r--r--source/blender/blenkernel/intern/subdiv_displacement_multires.c9
-rw-r--r--source/blender/blenkernel/intern/subdiv_eval.c2
-rw-r--r--source/blender/blenkernel/intern/subdiv_foreach.c6
-rw-r--r--source/blender/blenkernel/intern/subdiv_inline.h5
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c36
-rw-r--r--source/blender/blenkernel/intern/text.c37
-rw-r--r--source/blender/blenkernel/intern/texture.c4
-rw-r--r--source/blender/blenkernel/intern/tracking.c183
-rw-r--r--source/blender/blenkernel/intern/tracking_solver.c2
-rw-r--r--source/blender/blenkernel/intern/tracking_stabilize.c56
-rw-r--r--source/blender/blenkernel/intern/undo_system.c5
-rw-r--r--source/blender/blenkernel/intern/unit.c13
-rw-r--r--source/blender/blenkernel/intern/volume.cc72
-rw-r--r--source/blender/blenkernel/intern/volume_render.cc5
-rw-r--r--source/blender/blenkernel/intern/workspace.c12
-rw-r--r--source/blender/blenkernel/nla_private.h5
-rw-r--r--source/blender/blenkernel/particle_private.h5
-rw-r--r--source/blender/blenkernel/tracking_private.h5
-rw-r--r--source/blender/blenlib/BLI_alloca.h7
-rw-r--r--source/blender/blenlib/BLI_allocator.hh20
-rw-r--r--source/blender/blenlib/BLI_args.h5
-rw-r--r--source/blender/blenlib/BLI_array.h5
-rw-r--r--source/blender/blenlib/BLI_array.hh10
-rw-r--r--source/blender/blenlib/BLI_array_store.h5
-rw-r--r--source/blender/blenlib/BLI_array_store_utils.h5
-rw-r--r--source/blender/blenlib/BLI_array_utils.h5
-rw-r--r--source/blender/blenlib/BLI_asan.h5
-rw-r--r--source/blender/blenlib/BLI_assert.h48
-rw-r--r--source/blender/blenlib/BLI_astar.h5
-rw-r--r--source/blender/blenlib/BLI_bitmap.h5
-rw-r--r--source/blender/blenlib/BLI_bitmap_draw_2d.h5
-rw-r--r--source/blender/blenlib/BLI_blenlib.h5
-rw-r--r--source/blender/blenlib/BLI_boxpack_2d.h5
-rw-r--r--source/blender/blenlib/BLI_buffer.h5
-rw-r--r--source/blender/blenlib/BLI_color.hh17
-rw-r--r--source/blender/blenlib/BLI_compiler_attrs.h5
-rw-r--r--source/blender/blenlib/BLI_compiler_compat.h5
-rw-r--r--source/blender/blenlib/BLI_compiler_typecheck.h5
-rw-r--r--source/blender/blenlib/BLI_console.h5
-rw-r--r--source/blender/blenlib/BLI_convexhull_2d.h5
-rw-r--r--source/blender/blenlib/BLI_delaunay_2d.h5
-rw-r--r--source/blender/blenlib/BLI_dial_2d.h9
-rw-r--r--source/blender/blenlib/BLI_disjoint_set.hh5
-rw-r--r--source/blender/blenlib/BLI_dlrbTree.h5
-rw-r--r--source/blender/blenlib/BLI_dot_export.hh83
-rw-r--r--source/blender/blenlib/BLI_dot_export_attribute_enums.hh5
-rw-r--r--source/blender/blenlib/BLI_dynlib.h5
-rw-r--r--source/blender/blenlib/BLI_dynstr.h5
-rw-r--r--source/blender/blenlib/BLI_easing.h5
-rw-r--r--source/blender/blenlib/BLI_edgehash.h5
-rw-r--r--source/blender/blenlib/BLI_endian_switch_inline.h5
-rw-r--r--source/blender/blenlib/BLI_expr_pylike_eval.h5
-rw-r--r--source/blender/blenlib/BLI_fileops.h5
-rw-r--r--source/blender/blenlib/BLI_fileops_types.h5
-rw-r--r--source/blender/blenlib/BLI_float2.hh5
-rw-r--r--source/blender/blenlib/BLI_float3.hh25
-rw-r--r--source/blender/blenlib/BLI_float4x4.hh15
-rw-r--r--source/blender/blenlib/BLI_fnmatch.h5
-rw-r--r--source/blender/blenlib/BLI_ghash.h5
-rw-r--r--source/blender/blenlib/BLI_gsqueue.h5
-rw-r--r--source/blender/blenlib/BLI_hash.h5
-rw-r--r--source/blender/blenlib/BLI_hash.hh22
-rw-r--r--source/blender/blenlib/BLI_hash_md5.h5
-rw-r--r--source/blender/blenlib/BLI_hash_mm2a.h5
-rw-r--r--source/blender/blenlib/BLI_hash_mm3.h5
-rw-r--r--source/blender/blenlib/BLI_hash_tables.hh19
-rw-r--r--source/blender/blenlib/BLI_heap.h5
-rw-r--r--source/blender/blenlib/BLI_heap_simple.h5
-rw-r--r--source/blender/blenlib/BLI_index_mask.hh5
-rw-r--r--source/blender/blenlib/BLI_index_range.hh5
-rw-r--r--source/blender/blenlib/BLI_iterator.h5
-rw-r--r--source/blender/blenlib/BLI_jitter_2d.h5
-rw-r--r--source/blender/blenlib/BLI_kdopbvh.h5
-rw-r--r--source/blender/blenlib/BLI_kdtree.h5
-rw-r--r--source/blender/blenlib/BLI_lasso_2d.h5
-rw-r--r--source/blender/blenlib/BLI_linear_allocator.hh20
-rw-r--r--source/blender/blenlib/BLI_link_utils.h5
-rw-r--r--source/blender/blenlib/BLI_linklist.h5
-rw-r--r--source/blender/blenlib/BLI_linklist_lockfree.h5
-rw-r--r--source/blender/blenlib/BLI_linklist_stack.h5
-rw-r--r--source/blender/blenlib/BLI_listbase.h5
-rw-r--r--source/blender/blenlib/BLI_listbase_wrapper.hh9
-rw-r--r--source/blender/blenlib/BLI_map.hh13
-rw-r--r--source/blender/blenlib/BLI_map_slots.hh5
-rw-r--r--source/blender/blenlib/BLI_math.h5
-rw-r--r--source/blender/blenlib/BLI_math_base.h5
-rw-r--r--source/blender/blenlib/BLI_math_base_safe.h5
-rw-r--r--source/blender/blenlib/BLI_math_bits.h5
-rw-r--r--source/blender/blenlib/BLI_math_color.h5
-rw-r--r--source/blender/blenlib/BLI_math_color_blend.h5
-rw-r--r--source/blender/blenlib/BLI_math_geom.h27
-rw-r--r--source/blender/blenlib/BLI_math_inline.h5
-rw-r--r--source/blender/blenlib/BLI_math_interp.h5
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h5
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h5
-rw-r--r--source/blender/blenlib/BLI_math_solvers.h5
-rw-r--r--source/blender/blenlib/BLI_math_statistics.h5
-rw-r--r--source/blender/blenlib/BLI_math_vector.h5
-rw-r--r--source/blender/blenlib/BLI_memarena.h5
-rw-r--r--source/blender/blenlib/BLI_memblock.h5
-rw-r--r--source/blender/blenlib/BLI_memiter.h5
-rw-r--r--source/blender/blenlib/BLI_memory_utils.hh41
-rw-r--r--source/blender/blenlib/BLI_mempool.h5
-rw-r--r--source/blender/blenlib/BLI_multi_value_map.hh5
-rw-r--r--source/blender/blenlib/BLI_noise.h5
-rw-r--r--source/blender/blenlib/BLI_path_util.h5
-rw-r--r--source/blender/blenlib/BLI_polyfill_2d.h5
-rw-r--r--source/blender/blenlib/BLI_polyfill_2d_beautify.h5
-rw-r--r--source/blender/blenlib/BLI_probing_strategies.hh7
-rw-r--r--source/blender/blenlib/BLI_quadric.h5
-rw-r--r--source/blender/blenlib/BLI_rand.h5
-rw-r--r--source/blender/blenlib/BLI_rand.hh11
-rw-r--r--source/blender/blenlib/BLI_rect.h5
-rw-r--r--source/blender/blenlib/BLI_resource_collector.hh5
-rw-r--r--source/blender/blenlib/BLI_scanfill.h5
-rw-r--r--source/blender/blenlib/BLI_session_uuid.h68
-rw-r--r--source/blender/blenlib/BLI_set.hh9
-rw-r--r--source/blender/blenlib/BLI_set_slots.hh5
-rw-r--r--source/blender/blenlib/BLI_smallhash.h5
-rw-r--r--source/blender/blenlib/BLI_sort.h5
-rw-r--r--source/blender/blenlib/BLI_sort_utils.h5
-rw-r--r--source/blender/blenlib/BLI_span.hh17
-rw-r--r--source/blender/blenlib/BLI_stack.h5
-rw-r--r--source/blender/blenlib/BLI_stack.hh12
-rw-r--r--source/blender/blenlib/BLI_strict_flags.h5
-rw-r--r--source/blender/blenlib/BLI_string.h5
-rw-r--r--source/blender/blenlib/BLI_string_cursor_utf8.h5
-rw-r--r--source/blender/blenlib/BLI_string_ref.hh183
-rw-r--r--source/blender/blenlib/BLI_string_utf8.h5
-rw-r--r--source/blender/blenlib/BLI_string_utils.h5
-rw-r--r--source/blender/blenlib/BLI_sys_types.h5
-rw-r--r--source/blender/blenlib/BLI_system.h5
-rw-r--r--source/blender/blenlib/BLI_threads.h5
-rw-r--r--source/blender/blenlib/BLI_timecode.h5
-rw-r--r--source/blender/blenlib/BLI_timeit.hh5
-rw-r--r--source/blender/blenlib/BLI_timer.h5
-rw-r--r--source/blender/blenlib/BLI_utildefines_iter.h5
-rw-r--r--source/blender/blenlib/BLI_utildefines_stack.h5
-rw-r--r--source/blender/blenlib/BLI_utildefines_variadic.h5
-rw-r--r--source/blender/blenlib/BLI_utility_mixins.hh5
-rw-r--r--source/blender/blenlib/BLI_uvproject.h7
-rw-r--r--source/blender/blenlib/BLI_vector.hh23
-rw-r--r--source/blender/blenlib/BLI_vector_adaptor.hh5
-rw-r--r--source/blender/blenlib/BLI_vector_set.hh12
-rw-r--r--source/blender/blenlib/BLI_vector_set_slots.hh5
-rw-r--r--source/blender/blenlib/BLI_vfontdata.h5
-rw-r--r--source/blender/blenlib/BLI_voronoi_2d.h5
-rw-r--r--source/blender/blenlib/BLI_voxel.h5
-rw-r--r--source/blender/blenlib/BLI_winstuff.h5
-rw-r--r--source/blender/blenlib/CMakeLists.txt37
-rw-r--r--source/blender/blenlib/PIL_time.h5
-rw-r--r--source/blender/blenlib/PIL_time_utildefines.h5
-rw-r--r--source/blender/blenlib/intern/BLI_args.c8
-rw-r--r--source/blender/blenlib/intern/BLI_assert.c51
-rw-r--r--source/blender/blenlib/intern/BLI_dial_2d.c2
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c42
-rw-r--r--source/blender/blenlib/intern/BLI_ghash_utils.c4
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c90
-rw-r--r--source/blender/blenlib/intern/BLI_linklist.c2
-rw-r--r--source/blender/blenlib/intern/BLI_memiter.c16
-rw-r--r--source/blender/blenlib/intern/DLRB_tree.c8
-rw-r--r--source/blender/blenlib/intern/array_store.c26
-rw-r--r--source/blender/blenlib/intern/array_utils.c2
-rw-r--r--source/blender/blenlib/intern/bitmap_draw_2d.c28
-rw-r--r--source/blender/blenlib/intern/boxpack_2d.c12
-rw-r--r--source/blender/blenlib/intern/convexhull_2d.c17
-rw-r--r--source/blender/blenlib/intern/delaunay_2d.c64
-rw-r--r--source/blender/blenlib/intern/dot_export.cc38
-rw-r--r--source/blender/blenlib/intern/easing.c35
-rw-r--r--source/blender/blenlib/intern/edgehash.c14
-rw-r--r--source/blender/blenlib/intern/fileops.c19
-rw-r--r--source/blender/blenlib/intern/lasso_2d.c7
-rw-r--r--source/blender/blenlib/intern/listbase.c5
-rw-r--r--source/blender/blenlib/intern/math_color.c10
-rw-r--r--source/blender/blenlib/intern/math_geom.c830
-rw-r--r--source/blender/blenlib/intern/math_geom_inline.c4
-rw-r--r--source/blender/blenlib/intern/math_interp.c2
-rw-r--r--source/blender/blenlib/intern/math_rotation.c34
-rw-r--r--source/blender/blenlib/intern/math_vector.c18
-rw-r--r--source/blender/blenlib/intern/path_util.c73
-rw-r--r--source/blender/blenlib/intern/polyfill_2d.c14
-rw-r--r--source/blender/blenlib/intern/polyfill_2d_beautify.c15
-rw-r--r--source/blender/blenlib/intern/quadric.c10
-rw-r--r--source/blender/blenlib/intern/rand.cc4
-rw-r--r--source/blender/blenlib/intern/rct.c194
-rw-r--r--source/blender/blenlib/intern/scanfill.c96
-rw-r--r--source/blender/blenlib/intern/scanfill_utils.c5
-rw-r--r--source/blender/blenlib/intern/session_uuid.c78
-rw-r--r--source/blender/blenlib/intern/smallhash.c7
-rw-r--r--source/blender/blenlib/intern/sort_utils.c42
-rw-r--r--source/blender/blenlib/intern/storage.c8
-rw-r--r--source/blender/blenlib/intern/string.c36
-rw-r--r--source/blender/blenlib/intern/string_utf8.c8
-rw-r--r--source/blender/blenlib/intern/string_utils.c2
-rw-r--r--source/blender/blenlib/intern/system.c2
-rw-r--r--source/blender/blenlib/intern/threads.cc4
-rw-r--r--source/blender/blenlib/intern/uvproject.c2
-rw-r--r--source/blender/blenlib/intern/voronoi_2d.c6
-rw-r--r--source/blender/blenlib/tests/BLI_array_store_test.cc (renamed from tests/gtests/blenlib/BLI_array_store_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_array_utils_test.cc (renamed from tests/gtests/blenlib/BLI_array_utils_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_delaunay_2d_test.cc (renamed from tests/gtests/blenlib/BLI_delaunay_2d_test.cc)58
-rw-r--r--source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc (renamed from tests/gtests/blenlib/BLI_expr_pylike_eval_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_ghash_test.cc (renamed from tests/gtests/blenlib/BLI_ghash_test.cc)4
-rw-r--r--source/blender/blenlib/tests/BLI_hash_mm2a_test.cc (renamed from tests/gtests/blenlib/BLI_hash_mm2a_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_heap_simple_test.cc (renamed from tests/gtests/blenlib/BLI_heap_simple_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_heap_test.cc (renamed from tests/gtests/blenlib/BLI_heap_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_kdopbvh_test.cc (renamed from tests/gtests/blenlib/BLI_kdopbvh_test.cc)2
-rw-r--r--source/blender/blenlib/tests/BLI_linear_allocator_test.cc2
-rw-r--r--source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc (renamed from tests/gtests/blenlib/BLI_linklist_lockfree_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_listbase_test.cc (renamed from tests/gtests/blenlib/BLI_listbase_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_math_base_test.cc (renamed from tests/gtests/blenlib/BLI_math_base_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_math_bits_test.cc (renamed from tests/gtests/blenlib/BLI_math_bits_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_math_color_test.cc (renamed from tests/gtests/blenlib/BLI_math_color_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_math_geom_test.cc (renamed from tests/gtests/blenlib/BLI_math_geom_test.cc)2
-rw-r--r--source/blender/blenlib/tests/BLI_math_matrix_test.cc (renamed from tests/gtests/blenlib/BLI_math_matrix_test.cc)4
-rw-r--r--source/blender/blenlib/tests/BLI_math_vector_test.cc (renamed from tests/gtests/blenlib/BLI_math_vector_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_memiter_test.cc (renamed from tests/gtests/blenlib/BLI_memiter_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_path_util_test.cc (renamed from tests/gtests/blenlib/BLI_path_util_test.cc)49
-rw-r--r--source/blender/blenlib/tests/BLI_polyfill_2d_test.cc (renamed from tests/gtests/blenlib/BLI_polyfill_2d_test.cc)8
-rw-r--r--source/blender/blenlib/tests/BLI_ressource_strings.h (renamed from tests/gtests/blenlib/BLI_ressource_strings.h)0
-rw-r--r--source/blender/blenlib/tests/BLI_session_uuid_test.cc20
-rw-r--r--source/blender/blenlib/tests/BLI_set_test.cc10
-rw-r--r--source/blender/blenlib/tests/BLI_span_test.cc2
-rw-r--r--source/blender/blenlib/tests/BLI_stack_test.cc (renamed from tests/gtests/blenlib/BLI_stack_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_string_ref_test.cc24
-rw-r--r--source/blender/blenlib/tests/BLI_string_test.cc (renamed from tests/gtests/blenlib/BLI_string_test.cc)19
-rw-r--r--source/blender/blenlib/tests/BLI_string_utf8_test.cc (renamed from tests/gtests/blenlib/BLI_string_utf8_test.cc)19
-rw-r--r--source/blender/blenlib/tests/BLI_task_graph_test.cc (renamed from tests/gtests/blenlib/BLI_task_graph_test.cc)0
-rw-r--r--source/blender/blenlib/tests/BLI_task_test.cc (renamed from tests/gtests/blenlib/BLI_task_test.cc)0
-rw-r--r--source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc (renamed from tests/gtests/blenlib/BLI_ghash_performance_test.cc)56
-rw-r--r--source/blender/blenlib/tests/performance/BLI_task_performance_test.cc (renamed from tests/gtests/blenlib/BLI_task_performance_test.cc)0
-rw-r--r--source/blender/blenlib/tests/performance/CMakeLists.txt (renamed from tests/gtests/guardedalloc/CMakeLists.txt)8
-rw-r--r--source/blender/blenloader/BLO_blend_defs.h5
-rw-r--r--source/blender/blenloader/BLO_blend_validate.h5
-rw-r--r--source/blender/blenloader/BLO_read_write.h5
-rw-r--r--source/blender/blenloader/BLO_readfile.h5
-rw-r--r--source/blender/blenloader/BLO_undofile.h5
-rw-r--r--source/blender/blenloader/BLO_writefile.h5
-rw-r--r--source/blender/blenloader/CMakeLists.txt14
-rw-r--r--source/blender/blenloader/intern/readblenentry.c45
-rw-r--r--source/blender/blenloader/intern/readfile.c177
-rw-r--r--source/blender/blenloader/intern/readfile.h5
-rw-r--r--source/blender/blenloader/intern/versioning_250.c13
-rw-r--r--source/blender/blenloader/intern/versioning_260.c15
-rw-r--r--source/blender/blenloader/intern/versioning_270.c10
-rw-r--r--source/blender/blenloader/intern/versioning_280.c62
-rw-r--r--source/blender/blenloader/intern/versioning_290.c55
-rw-r--r--source/blender/blenloader/intern/versioning_cycles.c2
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c14
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c5
-rw-r--r--source/blender/blenloader/intern/writefile.c64
-rw-r--r--source/blender/blenloader/tests/blendfile_load_test.cc (renamed from tests/gtests/blenloader/blendfile_load_test.cc)0
-rw-r--r--source/blender/blenloader/tests/blendfile_loading_base_test.cc (renamed from tests/gtests/blenloader/blendfile_loading_base_test.cc)0
-rw-r--r--source/blender/blenloader/tests/blendfile_loading_base_test.h (renamed from tests/gtests/blenloader/blendfile_loading_base_test.h)2
-rw-r--r--source/blender/blentranslation/BLT_lang.h5
-rw-r--r--source/blender/blentranslation/BLT_translation.h5
-rw-r--r--source/blender/blentranslation/intern/blt_translation.c24
-rw-r--r--source/blender/bmesh/CMakeLists.txt13
-rw-r--r--source/blender/bmesh/bmesh.h5
-rw-r--r--source/blender/bmesh/bmesh_class.h5
-rw-r--r--source/blender/bmesh/bmesh_tools.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_callback_generic.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_core.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_delete.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_edgeloop.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_error.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_inline.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.c6
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators_inline.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_log.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_convert.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_convert.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_duplicate.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_validate.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api_inline.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c24
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_operators_private.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon_edgenet.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_private.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_query.c25
-rw-r--r--source/blender/bmesh/intern/bmesh_query.h8
-rw-r--r--source/blender/bmesh/intern/bmesh_query_inline.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_query_uv.c14
-rw-r--r--source/blender/bmesh/intern/bmesh_query_uv.h7
-rw-r--r--source/blender/bmesh/intern/bmesh_structure.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_structure_inline.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_private.h5
-rw-r--r--source/blender/bmesh/operators/bmo_beautify.c5
-rw-r--r--source/blender/bmesh/operators/bmo_smooth_laplacian.c2
-rw-r--r--source/blender/bmesh/tests/bmesh_core_test.cc (renamed from tests/gtests/bmesh/bmesh_core_test.cc)0
-rw-r--r--source/blender/bmesh/tools/bmesh_beautify.c9
-rw-r--r--source/blender/bmesh/tools/bmesh_beautify.h8
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c2839
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_bisect_plane.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_dissolve.c5
-rw-r--r--source/blender/bmesh/tools/bmesh_edgenet.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_edgesplit.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_intersect.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_intersect.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_intersect_edges.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_intersect_edges.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_path.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_path_region.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_path_region_uv.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_path_uv.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_region_match.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_separate.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_triangulate.h5
-rw-r--r--source/blender/bmesh/tools/bmesh_wireframe.h5
-rw-r--r--source/blender/compositor/COM_compositor.h4
-rw-r--r--source/blender/compositor/COM_defines.h5
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.h5
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.h5
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrderHotspot.h5
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.cpp5
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.h5
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp10
-rw-r--r--source/blender/compositor/intern/COM_Converter.h4
-rw-r--r--source/blender/compositor/intern/COM_Debug.h5
-rw-r--r--source/blender/compositor/intern/COM_Device.h5
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.h5
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h5
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cpp7
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h5
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.h6
-rw-r--r--source/blender/compositor/intern/COM_Node.h5
-rw-r--r--source/blender/compositor/intern/COM_NodeConverter.h5
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.h5
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cpp51
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h5
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.h5
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.h5
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedOperation.h5
-rw-r--r--source/blender/compositor/intern/COM_SocketReader.h6
-rw-r--r--source/blender/compositor/intern/COM_WorkPackage.h6
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.h5
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_BrightnessNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ChromaMatteNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ColorCorrectionNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ColorCurveNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ColorMatteNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ColorNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ColorSpillNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ColorToBWNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_CombineColorNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ConvertAlphaNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_CornerPinNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_CryptomatteNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_DenoiseNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_DespeckleNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_DistanceMatteNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_GammaNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_IDMaskNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_InpaintNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_InvertNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_KeyingScreenNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_LuminanceMatteNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_MapRangeNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_MapUVNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_MaskNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_MovieDistortionNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_NormalizeNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_PixelateNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_RotateNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_SeparateColorNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.cpp23
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_SunBeamsNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_SwitchViewNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_TonemapNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_TrackPositionNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ValueNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_VectorCurveNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.h4
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.h5
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_CryptomatteOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_DenoiseOperation.cpp25
-rw-r--r--source/blender/compositor/operations/COM_DenoiseOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.cpp13
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp33
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp46
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.cpp15
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_GlareFogGlowOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_GlareGhostOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_GlareGhostOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_GlareSimpleStarOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_GlareStreaksOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.cpp15
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_KeyingBlurOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_KeyingClipOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_KeyingDespillOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_KeyingOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.cpp15
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_PixelateOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_PlaneCornerPinOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_PlaneDistortCommonOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cpp21
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_QualityStepHelper.h5
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.h5
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_SplitOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_SunBeamsOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_SunBeamsOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_TrackPositionOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp5
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_WrapOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.h6
-rw-r--r--source/blender/datatoc/datatoc_icon.c2
-rw-r--r--source/blender/depsgraph/CMakeLists.txt10
-rw-r--r--source/blender/depsgraph/DEG_depsgraph.h5
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_build.h5
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_debug.h5
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_physics.h5
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_query.h5
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cache.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_map.h2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc9
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc86
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h16
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.cc14
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_transitive.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline.cc132
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline.h77
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_compositor.cc49
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_compositor.h47
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_from_ids.cc154
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_from_ids.h62
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_render.cc49
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_render.h41
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_view_layer.cc48
-rw-r--r--source/blender/depsgraph/intern/builder/pipeline_view_layer.h41
-rw-r--r--source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc357
-rw-r--r--source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc261
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_iter.cc19
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc9
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc5
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc36
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc22
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.h26
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc48
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h9
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc10
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.h6
-rw-r--r--source/blender/depsgraph/intern/node/deg_node.cc7
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_component.cc8
-rw-r--r--source/blender/draw/CMakeLists.txt24
-rw-r--r--source/blender/draw/DRW_engine.h5
-rw-r--r--source/blender/draw/DRW_engine_types.h5
-rw-r--r--source/blender/draw/DRW_select_buffer.h5
-rw-r--r--source/blender/draw/engines/basic/basic_engine.h5
-rw-r--r--source/blender/draw/engines/eevee/eevee_data.c46
-rw-r--r--source/blender/draw/engines/eevee/eevee_depth_of_field.c38
-rw-r--r--source/blender/draw/engines/eevee/eevee_effects.c3
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c34
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.h5
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c107
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.h5
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightprobes.c49
-rw-r--r--source/blender/draw/engines/eevee/eevee_lookdev.c158
-rw-r--r--source/blender/draw/engines/eevee/eevee_lut.h5
-rw-r--r--source/blender/draw/engines/eevee/eevee_lut_gen.c30
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c126
-rw-r--r--source/blender/draw/engines/eevee/eevee_mist.c18
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c113
-rw-r--r--source/blender/draw/engines/eevee/eevee_occlusion.c23
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h35
-rw-r--r--source/blender/draw/engines/eevee/eevee_render.c40
-rw-r--r--source/blender/draw/engines/eevee/eevee_renderpasses.c10
-rw-r--r--source/blender/draw/engines/eevee/eevee_sampling.c8
-rw-r--r--source/blender/draw/engines/eevee/eevee_screen_raytrace.c28
-rw-r--r--source/blender/draw/engines/eevee/eevee_shaders.c465
-rw-r--r--source/blender/draw/engines/eevee/eevee_shadows.c27
-rw-r--r--source/blender/draw/engines/eevee/eevee_shadows_cascade.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_subsurface.c44
-rw-r--r--source/blender/draw/engines/eevee/eevee_temporal_sampling.c15
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c119
-rw-r--r--source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl14
-rw-r--r--source/blender/draw/engines/eevee/shaders/background_vert.glsl18
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl877
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_lut_frag.glsl5
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl11
-rw-r--r--source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl5
-rw-r--r--source/blender/draw/engines/eevee/shaders/closure_lib.glsl181
-rw-r--r--source/blender/draw/engines/eevee/shaders/closure_lit_lib.glsl (renamed from source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl)42
-rw-r--r--source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl7
-rw-r--r--source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl65
-rw-r--r--source/blender/draw/engines/eevee/shaders/default_frag.glsl51
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl12
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl38
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_mist_frag.glsl5
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl7
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl9
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl29
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl6
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl13
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_velocity_tile_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl57
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_geom.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl20
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/lights_lib.glsl95
-rw-r--r--source/blender/draw/engines/eevee/shaders/lookdev_world_frag.glsl (renamed from source/blender/draw/engines/eevee/shaders/default_world_frag.glsl)43
-rw-r--r--source/blender/draw/engines/eevee/shaders/ltc_lib.glsl6
-rw-r--r--source/blender/draw/engines/eevee/shaders/object_motion_vert.glsl5
-rw-r--r--source/blender/draw/engines/eevee/shaders/prepass_frag.glsl14
-rw-r--r--source/blender/draw/engines/eevee/shaders/prepass_vert.glsl11
-rw-r--r--source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl8
-rw-r--r--source/blender/draw/engines/eevee/shaders/renderpass_lib.glsl43
-rw-r--r--source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl6
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl12
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_vert.glsl36
-rw-r--r--source/blender/draw/engines/eevee/shaders/ssr_lib.glsl7
-rw-r--r--source/blender/draw/engines/eevee/shaders/surface_frag.glsl89
-rw-r--r--source/blender/draw/engines/eevee/shaders/surface_geom.glsl46
-rw-r--r--source/blender/draw/engines/eevee/shaders/surface_lib.glsl43
-rw-r--r--source/blender/draw/engines/eevee/shaders/surface_vert.glsl (renamed from source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl)33
-rw-r--r--source/blender/draw/engines/eevee/shaders/update_noise_frag.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl5
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_geom.glsl8
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl22
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_vert.glsl8
-rw-r--r--source/blender/draw/engines/external/external_engine.c2
-rw-r--r--source/blender/draw/engines/external/external_engine.h5
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_antialiasing.c2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_cache_utils.c11
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_data.c9
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c6
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h5
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_render.c4
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl2
-rw-r--r--source/blender/draw/engines/overlay/overlay_antialiasing.c4
-rw-r--r--source/blender/draw/engines/overlay/overlay_armature.c23
-rw-r--r--source/blender/draw/engines/overlay/overlay_edit_text.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_engine.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_engine.h5
-rw-r--r--source/blender/draw/engines/overlay/overlay_extra.c23
-rw-r--r--source/blender/draw/engines/overlay/overlay_image.c22
-rw-r--r--source/blender/draw/engines/overlay/overlay_motion_path.c4
-rw-r--r--source/blender/draw/engines/overlay/overlay_outline.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_paint.c10
-rw-r--r--source/blender/draw/engines/overlay/overlay_private.h5
-rw-r--r--source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl2
-rw-r--r--source/blender/draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl13
-rw-r--r--source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl6
-rw-r--r--source/blender/draw/engines/overlay/shaders/grid_frag.glsl2
-rw-r--r--source/blender/draw/engines/overlay/shaders/grid_vert.glsl2
-rw-r--r--source/blender/draw/engines/select/select_engine.h5
-rw-r--r--source/blender/draw/engines/select/select_private.h5
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl4
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl28
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl2
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl10
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl2
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_prepass_pointcloud_vert.glsl2
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl2
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_transparent_accum_frag.glsl2
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl10
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_antialiasing.c103
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_dof.c6
-rw-r--r--source/blender/draw/engines/workbench/workbench_engine.c6
-rw-r--r--source/blender/draw/engines/workbench/workbench_engine.h5
-rw-r--r--source/blender/draw/engines/workbench/workbench_materials.c16
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h5
-rw-r--r--source/blender/draw/engines/workbench/workbench_shader.c10
-rw-r--r--source/blender/draw/engines/workbench/workbench_shadow.c4
-rw-r--r--source/blender/draw/engines/workbench/workbench_volume.c17
-rw-r--r--source/blender/draw/intern/DRW_render.h26
-rw-r--r--source/blender/draw/intern/draw_cache.c126
-rw-r--r--source/blender/draw/intern/draw_cache.h5
-rw-r--r--source/blender/draw/intern/draw_cache_extract.h5
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh.c34
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h5
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_gpencil.c9
-rw-r--r--source/blender/draw/intern/draw_cache_impl_lattice.c25
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c7
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c20
-rw-r--r--source/blender/draw/intern/draw_cache_inline.h7
-rw-r--r--source/blender/draw/intern/draw_color_management.h5
-rw-r--r--source/blender/draw/intern/draw_common.c6
-rw-r--r--source/blender/draw/intern/draw_common.h23
-rw-r--r--source/blender/draw/intern/draw_debug.h5
-rw-r--r--source/blender/draw/intern/draw_fluid.c (renamed from source/blender/gpu/intern/gpu_texture_smoke.cc)35
-rw-r--r--source/blender/draw/intern/draw_hair.c8
-rw-r--r--source/blender/draw/intern/draw_hair_private.h5
-rw-r--r--source/blender/draw/intern/draw_instance_data.c43
-rw-r--r--source/blender/draw/intern/draw_instance_data.h5
-rw-r--r--source/blender/draw/intern/draw_manager.c38
-rw-r--r--source/blender/draw/intern/draw_manager.h5
-rw-r--r--source/blender/draw/intern/draw_manager_data.c82
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c19
-rw-r--r--source/blender/draw/intern/draw_manager_profiling.h5
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c37
-rw-r--r--source/blender/draw/intern/draw_manager_text.h5
-rw-r--r--source/blender/draw/intern/draw_manager_texture.c6
-rw-r--r--source/blender/draw/intern/draw_view.c5
-rw-r--r--source/blender/draw/intern/draw_view.h5
-rw-r--r--source/blender/draw/intern/shaders/common_hair_lib.glsl22
-rw-r--r--source/blender/draw/intern/shaders/common_math_geom_lib.glsl2
-rw-r--r--source/blender/draw/intern/shaders/common_pointcloud_lib.glsl2
-rw-r--r--source/blender/draw/intern/shaders/common_view_lib.glsl109
-rw-r--r--source/blender/draw/intern/smaa_textures.h4
-rw-r--r--source/blender/editors/animation/anim_draw.c4
-rw-r--r--source/blender/editors/animation/anim_filter.c2
-rw-r--r--source/blender/editors/animation/anim_intern.h5
-rw-r--r--source/blender/editors/armature/armature_intern.h5
-rw-r--r--source/blender/editors/armature/armature_relations.c1
-rw-r--r--source/blender/editors/armature/armature_skinning.c6
-rw-r--r--source/blender/editors/armature/armature_utils.c14
-rw-r--r--source/blender/editors/armature/meshlaplacian.c8
-rw-r--r--source/blender/editors/armature/meshlaplacian.h5
-rw-r--r--source/blender/editors/armature/pose_slide.c12
-rw-r--r--source/blender/editors/curve/curve_intern.h5
-rw-r--r--source/blender/editors/curve/editcurve.c21
-rw-r--r--source/blender/editors/curve/editcurve_add.c20
-rw-r--r--source/blender/editors/curve/editfont.c4
-rw-r--r--source/blender/editors/gizmo_library/gizmo_geometry.h5
-rw-r--r--source/blender/editors/gizmo_library/gizmo_library_intern.h5
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c2
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c2
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c2
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c2
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c152
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_armature.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c18
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c205
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h13
-rw-r--r--source/blender/editors/gpencil/gpencil_mesh.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c41
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c259
-rw-r--r--source/blender/editors/gpencil/gpencil_sculpt_paint.c22
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c45
-rw-r--r--source/blender/editors/gpencil/gpencil_uv.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_vertex_paint.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_weight_paint.c16
-rw-r--r--source/blender/editors/include/BIF_glutil.h13
-rw-r--r--source/blender/editors/include/ED_anim_api.h5
-rw-r--r--source/blender/editors/include/ED_armature.h13
-rw-r--r--source/blender/editors/include/ED_buttons.h5
-rw-r--r--source/blender/editors/include/ED_clip.h5
-rw-r--r--source/blender/editors/include/ED_curve.h5
-rw-r--r--source/blender/editors/include/ED_datafiles.h5
-rw-r--r--source/blender/editors/include/ED_fileselect.h5
-rw-r--r--source/blender/editors/include/ED_gizmo_library.h5
-rw-r--r--source/blender/editors/include/ED_gizmo_utils.h5
-rw-r--r--source/blender/editors/include/ED_gpencil.h5
-rw-r--r--source/blender/editors/include/ED_image.h5
-rw-r--r--source/blender/editors/include/ED_info.h5
-rw-r--r--source/blender/editors/include/ED_keyframes_draw.h5
-rw-r--r--source/blender/editors/include/ED_keyframes_edit.h5
-rw-r--r--source/blender/editors/include/ED_keyframing.h5
-rw-r--r--source/blender/editors/include/ED_lattice.h5
-rw-r--r--source/blender/editors/include/ED_markers.h5
-rw-r--r--source/blender/editors/include/ED_mask.h5
-rw-r--r--source/blender/editors/include/ED_mball.h5
-rw-r--r--source/blender/editors/include/ED_mesh.h5
-rw-r--r--source/blender/editors/include/ED_node.h5
-rw-r--r--source/blender/editors/include/ED_numinput.h5
-rw-r--r--source/blender/editors/include/ED_object.h5
-rw-r--r--source/blender/editors/include/ED_outliner.h8
-rw-r--r--source/blender/editors/include/ED_paint.h5
-rw-r--r--source/blender/editors/include/ED_particle.h5
-rw-r--r--source/blender/editors/include/ED_physics.h5
-rw-r--r--source/blender/editors/include/ED_render.h5
-rw-r--r--source/blender/editors/include/ED_scene.h5
-rw-r--r--source/blender/editors/include/ED_screen.h17
-rw-r--r--source/blender/editors/include/ED_screen_types.h5
-rw-r--r--source/blender/editors/include/ED_sculpt.h5
-rw-r--r--source/blender/editors/include/ED_select_utils.h5
-rw-r--r--source/blender/editors/include/ED_sequencer.h5
-rw-r--r--source/blender/editors/include/ED_sound.h5
-rw-r--r--source/blender/editors/include/ED_space_api.h5
-rw-r--r--source/blender/editors/include/ED_text.h5
-rw-r--r--source/blender/editors/include/ED_time_scrub_ui.h5
-rw-r--r--source/blender/editors/include/ED_transform.h5
-rw-r--r--source/blender/editors/include/ED_transform_snap_object_context.h5
-rw-r--r--source/blender/editors/include/ED_transverts.h5
-rw-r--r--source/blender/editors/include/ED_types.h5
-rw-r--r--source/blender/editors/include/ED_undo.h5
-rw-r--r--source/blender/editors/include/ED_userpref.h5
-rw-r--r--source/blender/editors/include/ED_util.h5
-rw-r--r--source/blender/editors/include/ED_util_imbuf.h5
-rw-r--r--source/blender/editors/include/ED_uvedit.h8
-rw-r--r--source/blender/editors/include/ED_view3d.h44
-rw-r--r--source/blender/editors/include/ED_view3d_offscreen.h13
-rw-r--r--source/blender/editors/include/UI_interface.h25
-rw-r--r--source/blender/editors/include/UI_interface_icons.h5
-rw-r--r--source/blender/editors/include/UI_resources.h5
-rw-r--r--source/blender/editors/include/UI_view2d.h5
-rw-r--r--source/blender/editors/interface/interface.c278
-rw-r--r--source/blender/editors/interface/interface_align.c2
-rw-r--r--source/blender/editors/interface/interface_anim.c40
-rw-r--r--source/blender/editors/interface/interface_context_menu.c2
-rw-r--r--source/blender/editors/interface/interface_draw.c28
-rw-r--r--source/blender/editors/interface/interface_eyedropper_color.c4
-rw-r--r--source/blender/editors/interface/interface_eyedropper_colorband.c4
-rw-r--r--source/blender/editors/interface/interface_eyedropper_gpencil_color.c9
-rw-r--r--source/blender/editors/interface/interface_eyedropper_intern.h5
-rw-r--r--source/blender/editors/interface/interface_handlers.c147
-rw-r--r--source/blender/editors/interface/interface_icons_event.c2
-rw-r--r--source/blender/editors/interface/interface_intern.h120
-rw-r--r--source/blender/editors/interface/interface_layout.c154
-rw-r--r--source/blender/editors/interface/interface_ops.c9
-rw-r--r--source/blender/editors/interface/interface_panel.c12
-rw-r--r--source/blender/editors/interface/interface_query.c4
-rw-r--r--source/blender/editors/interface/interface_region_color_picker.c161
-rw-r--r--source/blender/editors/interface/interface_region_hud.c2
-rw-r--r--source/blender/editors/interface/interface_region_popup.c2
-rw-r--r--source/blender/editors/interface/interface_region_search.c74
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c2
-rw-r--r--source/blender/editors/interface/interface_regions_intern.h5
-rw-r--r--source/blender/editors/interface/interface_style.c2
-rw-r--r--source/blender/editors/interface/interface_templates.c321
-rw-r--r--source/blender/editors/interface/interface_utils.c2
-rw-r--r--source/blender/editors/interface/interface_widgets.c89
-rw-r--r--source/blender/editors/interface/view2d.c6
-rw-r--r--source/blender/editors/interface/view2d_ops.c2
-rw-r--r--source/blender/editors/io/io_alembic.h5
-rw-r--r--source/blender/editors/io/io_cache.h5
-rw-r--r--source/blender/editors/io/io_collada.h5
-rw-r--r--source/blender/editors/io/io_ops.h5
-rw-r--r--source/blender/editors/io/io_usd.h5
-rw-r--r--source/blender/editors/lattice/lattice_intern.h5
-rw-r--r--source/blender/editors/mask/mask_add.c4
-rw-r--r--source/blender/editors/mask/mask_draw.c2
-rw-r--r--source/blender/editors/mask/mask_intern.h5
-rw-r--r--source/blender/editors/mask/mask_shapekey.c2
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c12
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin.c2
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c2
-rw-r--r--source/blender/editors/mesh/editmesh_knife_project.c2
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c6
-rw-r--r--source/blender/editors/mesh/editmesh_preselect_edgering.c6
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c7
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c26
-rw-r--r--source/blender/editors/mesh/mesh_intern.h5
-rw-r--r--source/blender/editors/mesh/meshtools.c8
-rw-r--r--source/blender/editors/metaball/mball_intern.h5
-rw-r--r--source/blender/editors/object/object_add.c64
-rw-r--r--source/blender/editors/object/object_bake.c4
-rw-r--r--source/blender/editors/object/object_bake_api.c8
-rw-r--r--source/blender/editors/object/object_intern.h5
-rw-r--r--source/blender/editors/object/object_modifier.c22
-rw-r--r--source/blender/editors/object/object_relations.c5
-rw-r--r--source/blender/editors/object/object_remesh.c7
-rw-r--r--source/blender/editors/object/object_transform.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c4
-rw-r--r--source/blender/editors/physics/particle_edit_utildefines.h5
-rw-r--r--source/blender/editors/physics/physics_intern.h5
-rw-r--r--source/blender/editors/render/render_intern.h5
-rw-r--r--source/blender/editors/render/render_opengl.c8
-rw-r--r--source/blender/editors/render/render_preview.c2
-rw-r--r--source/blender/editors/render/render_shading.c5
-rw-r--r--source/blender/editors/screen/area.c58
-rw-r--r--source/blender/editors/screen/glutil.c24
-rw-r--r--source/blender/editors/screen/screen_context.c1
-rw-r--r--source/blender/editors/screen/screen_edit.c56
-rw-r--r--source/blender/editors/screen/screen_intern.h15
-rw-r--r--source/blender/editors/screen/screen_ops.c6
-rw-r--r--source/blender/editors/screen/workspace_edit.c31
-rw-r--r--source/blender/editors/screen/workspace_layout_edit.c60
-rw-r--r--source/blender/editors/sculpt_paint/CMakeLists.txt1
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c1146
-rw-r--r--source/blender/editors/sculpt_paint/paint_curve.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c35
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c26
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h6
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c111
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c5
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c12
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c6
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c93
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_boundary.c865
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_cloth.c430
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_detail.c6
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_face_set.c54
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_color.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_mesh.c72
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h35
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_mask_expand.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c14
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_paint_color.c6
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_pose.c34
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_smooth.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c2
-rw-r--r--source/blender/editors/sound/sound_intern.h5
-rw-r--r--source/blender/editors/space_action/action_intern.h5
-rw-r--r--source/blender/editors/space_action/space_action.c4
-rw-r--r--source/blender/editors/space_api/spacetypes.c5
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c1
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h5
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c1
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c14
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c12
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c4
-rw-r--r--source/blender/editors/space_clip/clip_draw.c2
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c10
-rw-r--r--source/blender/editors/space_clip/clip_intern.h5
-rw-r--r--source/blender/editors/space_clip/space_clip.c26
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c6
-rw-r--r--source/blender/editors/space_clip/tracking_ops_intern.h5
-rw-r--r--source/blender/editors/space_clip/tracking_select.c12
-rw-r--r--source/blender/editors/space_console/console_intern.h5
-rw-r--r--source/blender/editors/space_console/space_console.c4
-rw-r--r--source/blender/editors/space_file/file_draw.c4
-rw-r--r--source/blender/editors/space_file/file_intern.h5
-rw-r--r--source/blender/editors/space_file/file_ops.c16
-rw-r--r--source/blender/editors/space_file/filelist.c2
-rw-r--r--source/blender/editors/space_file/filelist.h5
-rw-r--r--source/blender/editors/space_file/fsmenu.h5
-rw-r--r--source/blender/editors/space_file/space_file.c8
-rw-r--r--source/blender/editors/space_graph/graph_draw.c4
-rw-r--r--source/blender/editors/space_graph/graph_edit.c2
-rw-r--r--source/blender/editors/space_graph/graph_intern.h5
-rw-r--r--source/blender/editors/space_graph/space_graph.c4
-rw-r--r--source/blender/editors/space_image/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_image/image_draw.c12
-rw-r--r--source/blender/editors/space_image/image_edit.c5
-rw-r--r--source/blender/editors/space_image/image_intern.h5
-rw-r--r--source/blender/editors/space_image/image_ops.c11
-rw-r--r--source/blender/editors/space_image/image_undo.c7
-rw-r--r--source/blender/editors/space_image/space_image.c26
-rw-r--r--source/blender/editors/space_info/info_draw.c4
-rw-r--r--source/blender/editors/space_info/info_intern.h5
-rw-r--r--source/blender/editors/space_info/space_info.c4
-rw-r--r--source/blender/editors/space_info/textview.c2
-rw-r--r--source/blender/editors/space_info/textview.h5
-rw-r--r--source/blender/editors/space_nla/nla_draw.c2
-rw-r--r--source/blender/editors/space_nla/nla_intern.h5
-rw-r--r--source/blender/editors/space_nla/space_nla.c4
-rw-r--r--source/blender/editors/space_node/drawnode.c6
-rw-r--r--source/blender/editors/space_node/node_draw.c2
-rw-r--r--source/blender/editors/space_node/node_edit.c2
-rw-r--r--source/blender/editors/space_node/node_group.c127
-rw-r--r--source/blender/editors/space_node/node_intern.h5
-rw-r--r--source/blender/editors/space_node/node_relationships.c8
-rw-r--r--source/blender/editors/space_node/space_node.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c159
-rw-r--r--source/blender/editors/space_outliner/outliner_dragdrop.c76
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c236
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c233
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h60
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c141
-rw-r--r--source/blender/editors/space_outliner/outliner_sync.c62
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c429
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c563
-rw-r--r--source/blender/editors/space_outliner/outliner_utils.c45
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c75
-rw-r--r--source/blender/editors/space_script/script_intern.h5
-rw-r--r--source/blender/editors/space_script/space_script.c4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c8
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c10
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c27
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h5
-rw-r--r--source/blender/editors/space_sequencer/sequencer_scopes.c2
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c18
-rw-r--r--source/blender/editors/space_statusbar/space_statusbar.c4
-rw-r--r--source/blender/editors/space_text/space_text.c4
-rw-r--r--source/blender/editors/space_text/text_autocomplete.c2
-rw-r--r--source/blender/editors/space_text/text_format.h5
-rw-r--r--source/blender/editors/space_text/text_intern.h5
-rw-r--r--source/blender/editors/space_text/text_ops.c2
-rw-r--r--source/blender/editors/space_topbar/space_topbar.c4
-rw-r--r--source/blender/editors/space_userpref/space_userpref.c6
-rw-r--r--source/blender/editors/space_userpref/userpref_intern.h5
-rw-r--r--source/blender/editors/space_view3d/drawobject.c2
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_camera_control.c64
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c39
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c11
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c17
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_ruler.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h5
-rw-r--r--source/blender/editors/space_view3d/view3d_placement.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_project.c37
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c20
-rw-r--r--source/blender/editors/transform/transform.h5
-rw-r--r--source/blender/editors/transform/transform_constraints.c12
-rw-r--r--source/blender/editors/transform/transform_constraints.h5
-rw-r--r--source/blender/editors/transform/transform_convert.h4
-rw-r--r--source/blender/editors/transform/transform_convert_gpencil.c2
-rw-r--r--source/blender/editors/transform/transform_convert_mesh.c41
-rw-r--r--source/blender/editors/transform/transform_data.h5
-rw-r--r--source/blender/editors/transform/transform_draw_cursors.h5
-rw-r--r--source/blender/editors/transform/transform_gizmo_2d.c6
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c2
-rw-r--r--source/blender/editors/transform/transform_gizmo_extrude_3d.c2
-rw-r--r--source/blender/editors/transform/transform_input.c2
-rw-r--r--source/blender/editors/transform/transform_mode.c4
-rw-r--r--source/blender/editors/transform/transform_mode.h4
-rw-r--r--source/blender/editors/transform/transform_mode_bbone_resize.c5
-rw-r--r--source/blender/editors/transform/transform_mode_edge_slide.c4
-rw-r--r--source/blender/editors/transform/transform_mode_shear.c10
-rw-r--r--source/blender/editors/transform/transform_mode_vert_slide.c6
-rw-r--r--source/blender/editors/transform/transform_orientations.c4
-rw-r--r--source/blender/editors/transform/transform_snap.h5
-rw-r--r--source/blender/editors/transform/transform_snap_object.c10
-rw-r--r--source/blender/editors/undo/undo_intern.h5
-rw-r--r--source/blender/editors/util/CMakeLists.txt1
-rw-r--r--source/blender/editors/util/ed_util.c1
-rw-r--r--source/blender/editors/uvedit/uvedit_intern.h15
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c18
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c20
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.h5
-rw-r--r--source/blender/editors/uvedit/uvedit_path.c264
-rw-r--r--source/blender/editors/uvedit/uvedit_rip.c25
-rw-r--r--source/blender/editors/uvedit/uvedit_select.c237
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c21
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c8
-rw-r--r--source/blender/freestyle/FRS_freestyle.h7
-rw-r--r--source/blender/freestyle/intern/application/AppCanvas.cpp5
-rw-r--r--source/blender/freestyle/intern/application/AppCanvas.h5
-rw-r--r--source/blender/freestyle/intern/application/AppConfig.h5
-rw-r--r--source/blender/freestyle/intern/application/AppView.h5
-rw-r--r--source/blender/freestyle/intern/application/Controller.cpp7
-rw-r--r--source/blender/freestyle/intern/application/Controller.h5
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp2
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h5
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h5
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h5
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp4
-rw-r--r--source/blender/freestyle/intern/geometry/BBox.h5
-rw-r--r--source/blender/freestyle/intern/geometry/Bezier.h5
-rw-r--r--source/blender/freestyle/intern/geometry/FastGrid.h5
-rw-r--r--source/blender/freestyle/intern/geometry/FitCurve.cpp4
-rw-r--r--source/blender/freestyle/intern/geometry/FitCurve.h5
-rw-r--r--source/blender/freestyle/intern/geometry/Geom.h5
-rw-r--r--source/blender/freestyle/intern/geometry/GeomCleaner.h5
-rw-r--r--source/blender/freestyle/intern/geometry/GeomUtils.cpp30
-rw-r--r--source/blender/freestyle/intern/geometry/GeomUtils.h5
-rw-r--r--source/blender/freestyle/intern/geometry/Grid.h5
-rw-r--r--source/blender/freestyle/intern/geometry/GridHelpers.h5
-rw-r--r--source/blender/freestyle/intern/geometry/HashGrid.h5
-rw-r--r--source/blender/freestyle/intern/geometry/Noise.h5
-rw-r--r--source/blender/freestyle/intern/geometry/Polygon.h5
-rw-r--r--source/blender/freestyle/intern/geometry/SweepLine.h5
-rw-r--r--source/blender/freestyle/intern/geometry/VecMat.h5
-rw-r--r--source/blender/freestyle/intern/geometry/matrix_util.h5
-rw-r--r--source/blender/freestyle/intern/geometry/normal_cycle.h5
-rw-r--r--source/blender/freestyle/intern/image/GaussianFilter.h5
-rw-r--r--source/blender/freestyle/intern/image/Image.h5
-rw-r--r--source/blender/freestyle/intern/image/ImagePyramid.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_BBox.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_ContextFunctions.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.cpp38
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_Freestyle.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Freestyle.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp12
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsMaterial.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsNoise.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_Id.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Id.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_IntegrationType.cpp13
-rw-r--r--source/blender/freestyle/intern/python/BPy_IntegrationType.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface0D.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface1D.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_Iterator.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_MediumType.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_Nature.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_Operators.cpp8
-rw-r--r--source/blender/freestyle/intern/python/BPy_Operators.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_SShape.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp4
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeShader.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewMap.h5
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewShape.h5
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/Director.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp8
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp3
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h5
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp3
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp6
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp6
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h5
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h5
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/DrawingStyle.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/FrsMaterial.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/LineRep.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/Node.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeCamera.cpp8
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeCamera.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeGroup.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeLight.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeShape.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeTransform.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeViewLayer.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp4
-rw-r--r--source/blender/freestyle/intern/scene_graph/OrientedLineRep.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/Rep.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/SceneHash.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/SceneVisitor.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/TriangleRep.h5
-rw-r--r--source/blender/freestyle/intern/scene_graph/VertexRep.h5
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h5
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h5
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedPredicates1D.h5
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h5
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.h5
-rw-r--r--source/blender/freestyle/intern/stroke/Canvas.h5
-rw-r--r--source/blender/freestyle/intern/stroke/Chain.h5
-rw-r--r--source/blender/freestyle/intern/stroke/ChainingIterators.cpp2
-rw-r--r--source/blender/freestyle/intern/stroke/ChainingIterators.h5
-rw-r--r--source/blender/freestyle/intern/stroke/ContextFunctions.h5
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.cpp6
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.h5
-rw-r--r--source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h5
-rw-r--r--source/blender/freestyle/intern/stroke/CurveIterators.h5
-rw-r--r--source/blender/freestyle/intern/stroke/Modifiers.h5
-rw-r--r--source/blender/freestyle/intern/stroke/Module.h5
-rw-r--r--source/blender/freestyle/intern/stroke/Operators.h5
-rw-r--r--source/blender/freestyle/intern/stroke/PSStrokeRenderer.h5
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates0D.h5
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates1D.h5
-rw-r--r--source/blender/freestyle/intern/stroke/QInformationMap.h5
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeIO.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeIterators.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeLayer.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRenderer.cpp5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRenderer.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeShader.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeTesselator.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StyleModule.h5
-rw-r--r--source/blender/freestyle/intern/system/BaseIterator.h5
-rw-r--r--source/blender/freestyle/intern/system/BaseObject.h5
-rw-r--r--source/blender/freestyle/intern/system/Cast.h5
-rw-r--r--source/blender/freestyle/intern/system/Exception.h5
-rw-r--r--source/blender/freestyle/intern/system/FreestyleConfig.h5
-rw-r--r--source/blender/freestyle/intern/system/Id.h5
-rw-r--r--source/blender/freestyle/intern/system/Interpreter.h5
-rw-r--r--source/blender/freestyle/intern/system/Iterator.h5
-rw-r--r--source/blender/freestyle/intern/system/PointerSequence.h5
-rw-r--r--source/blender/freestyle/intern/system/Precision.h5
-rw-r--r--source/blender/freestyle/intern/system/ProgressBar.h5
-rw-r--r--source/blender/freestyle/intern/system/PseudoNoise.cpp5
-rw-r--r--source/blender/freestyle/intern/system/PseudoNoise.h5
-rw-r--r--source/blender/freestyle/intern/system/PythonInterpreter.h5
-rw-r--r--source/blender/freestyle/intern/system/RandGen.h5
-rw-r--r--source/blender/freestyle/intern/system/RenderMonitor.h5
-rw-r--r--source/blender/freestyle/intern/system/StringUtils.h5
-rw-r--r--source/blender/freestyle/intern/system/TimeStamp.h5
-rw-r--r--source/blender/freestyle/intern/system/TimeUtils.h5
-rw-r--r--source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h5
-rw-r--r--source/blender/freestyle/intern/view_map/AutoPtrHelper.h5
-rw-r--r--source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h5
-rw-r--r--source/blender/freestyle/intern/view_map/BoxGrid.h5
-rw-r--r--source/blender/freestyle/intern/view_map/CulledOccluderSource.h5
-rw-r--r--source/blender/freestyle/intern/view_map/FEdgeXDetector.h5
-rw-r--r--source/blender/freestyle/intern/view_map/Functions0D.h5
-rw-r--r--source/blender/freestyle/intern/view_map/Functions1D.h5
-rw-r--r--source/blender/freestyle/intern/view_map/GridDensityProvider.h5
-rw-r--r--source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.cpp15
-rw-r--r--source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.h5
-rw-r--r--source/blender/freestyle/intern/view_map/Interface0D.h5
-rw-r--r--source/blender/freestyle/intern/view_map/Interface1D.h5
-rw-r--r--source/blender/freestyle/intern/view_map/OccluderSource.cpp9
-rw-r--r--source/blender/freestyle/intern/view_map/OccluderSource.h5
-rw-r--r--source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.h5
-rw-r--r--source/blender/freestyle/intern/view_map/Silhouette.h5
-rw-r--r--source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h5
-rw-r--r--source/blender/freestyle/intern/view_map/SphericalGrid.h5
-rw-r--r--source/blender/freestyle/intern/view_map/SteerableViewMap.h5
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp68
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h5
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.cpp18
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.h5
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h11
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp23
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.h5
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIO.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIO.h5
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIterators.h5
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapTesselator.h5
-rw-r--r--source/blender/freestyle/intern/winged_edge/Curvature.h5
-rw-r--r--source/blender/freestyle/intern/winged_edge/Nature.h5
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.cpp7
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.h5
-rw-r--r--source/blender/freestyle/intern/winged_edge/WFillGrid.h5
-rw-r--r--source/blender/freestyle/intern/winged_edge/WSFillGrid.h5
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.h5
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h5
-rw-r--r--source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h5
-rw-r--r--source/blender/functions/FN_array_spans.hh5
-rw-r--r--source/blender/functions/FN_attributes_ref.hh13
-rw-r--r--source/blender/functions/FN_cpp_type.hh79
-rw-r--r--source/blender/functions/FN_generic_vector_array.hh8
-rw-r--r--source/blender/functions/FN_multi_function.hh5
-rw-r--r--source/blender/functions/FN_multi_function_builder.hh20
-rw-r--r--source/blender/functions/FN_multi_function_context.hh9
-rw-r--r--source/blender/functions/FN_multi_function_data_type.hh7
-rw-r--r--source/blender/functions/FN_multi_function_network.hh23
-rw-r--r--source/blender/functions/FN_multi_function_network_evaluation.hh5
-rw-r--r--source/blender/functions/FN_multi_function_network_optimization.hh5
-rw-r--r--source/blender/functions/FN_multi_function_param_type.hh5
-rw-r--r--source/blender/functions/FN_multi_function_params.hh5
-rw-r--r--source/blender/functions/FN_multi_function_signature.hh5
-rw-r--r--source/blender/functions/FN_spans.hh14
-rw-r--r--source/blender/functions/intern/attributes_ref.cc17
-rw-r--r--source/blender/functions/intern/multi_function_network.cc4
-rw-r--r--source/blender/functions/intern/multi_function_network_evaluation.cc128
-rw-r--r--source/blender/functions/intern/multi_function_network_optimization.cc16
-rw-r--r--source/blender/functions/tests/FN_multi_function_network_test.cc2
-rw-r--r--source/blender/functions/tests/FN_multi_function_test.cc4
-rw-r--r--source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h5
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h5
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c5
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h5
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c4
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c4
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c4
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c3
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c2
-rw-r--r--source/blender/gpu/CMakeLists.txt33
-rw-r--r--source/blender/gpu/GPU_attr_binding.h5
-rw-r--r--source/blender/gpu/GPU_batch.h11
-rw-r--r--source/blender/gpu/GPU_batch_presets.h7
-rw-r--r--source/blender/gpu/GPU_batch_utils.h5
-rw-r--r--source/blender/gpu/GPU_buffers.h5
-rw-r--r--source/blender/gpu/GPU_common.h5
-rw-r--r--source/blender/gpu/GPU_context.h23
-rw-r--r--source/blender/gpu/GPU_debug.h5
-rw-r--r--source/blender/gpu/GPU_draw.h81
-rw-r--r--source/blender/gpu/GPU_element.h5
-rw-r--r--source/blender/gpu/GPU_extensions.h9
-rw-r--r--source/blender/gpu/GPU_framebuffer.h5
-rw-r--r--source/blender/gpu/GPU_glew.h5
-rw-r--r--source/blender/gpu/GPU_immediate.h10
-rw-r--r--source/blender/gpu/GPU_immediate_util.h5
-rw-r--r--source/blender/gpu/GPU_init_exit.h7
-rw-r--r--source/blender/gpu/GPU_legacy_stubs.h5
-rw-r--r--source/blender/gpu/GPU_material.h16
-rw-r--r--source/blender/gpu/GPU_matrix.h5
-rw-r--r--source/blender/gpu/GPU_platform.h5
-rw-r--r--source/blender/gpu/GPU_primitive.h5
-rw-r--r--source/blender/gpu/GPU_select.h5
-rw-r--r--source/blender/gpu/GPU_shader.h7
-rw-r--r--source/blender/gpu/GPU_shader_interface.h5
-rw-r--r--source/blender/gpu/GPU_state.h6
-rw-r--r--source/blender/gpu/GPU_texture.h41
-rw-r--r--source/blender/gpu/GPU_uniformbuffer.h8
-rw-r--r--source/blender/gpu/GPU_vertex_buffer.h11
-rw-r--r--source/blender/gpu/GPU_vertex_format.h15
-rw-r--r--source/blender/gpu/GPU_viewport.h10
-rw-r--r--source/blender/gpu/intern/gpu_attr_binding_private.h5
-rw-r--r--source/blender/gpu/intern/gpu_backend.hh (renamed from source/blender/editors/include/ED_logic.h)27
-rw-r--r--source/blender/gpu/intern/gpu_batch.cc61
-rw-r--r--source/blender/gpu/intern/gpu_batch_presets.c25
-rw-r--r--source/blender/gpu/intern/gpu_batch_private.h5
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c15
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c532
-rw-r--r--source/blender/gpu/intern/gpu_codegen.h10
-rw-r--r--source/blender/gpu/intern/gpu_context.cc278
-rw-r--r--source/blender/gpu/intern/gpu_context_private.hh (renamed from source/blender/gpu/intern/gpu_context_private.h)43
-rw-r--r--source/blender/gpu/intern/gpu_element.cc13
-rw-r--r--source/blender/gpu/intern/gpu_extensions.cc22
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.cc21
-rw-r--r--source/blender/gpu/intern/gpu_immediate.cc50
-rw-r--r--source/blender/gpu/intern/gpu_immediate_util.c24
-rw-r--r--source/blender/gpu/intern/gpu_init_exit.c3
-rw-r--r--source/blender/gpu/intern/gpu_material.c17
-rw-r--r--source/blender/gpu/intern/gpu_material_library.c13
-rw-r--r--source/blender/gpu/intern/gpu_material_library.h5
-rw-r--r--source/blender/gpu/intern/gpu_matrix.cc (renamed from source/blender/gpu/intern/gpu_matrix.c)53
-rw-r--r--source/blender/gpu/intern/gpu_matrix_private.h5
-rw-r--r--source/blender/gpu/intern/gpu_node_graph.c4
-rw-r--r--source/blender/gpu/intern/gpu_node_graph.h5
-rw-r--r--source/blender/gpu/intern/gpu_primitive_private.h5
-rw-r--r--source/blender/gpu/intern/gpu_private.h5
-rw-r--r--source/blender/gpu/intern/gpu_select_pick.c15
-rw-r--r--source/blender/gpu/intern/gpu_select_private.h5
-rw-r--r--source/blender/gpu/intern/gpu_select_sample_query.c5
-rw-r--r--source/blender/gpu/intern/gpu_shader.cc839
-rw-r--r--source/blender/gpu/intern/gpu_shader_builtin.c (renamed from source/blender/gpu/intern/gpu_shader.c)727
-rw-r--r--source/blender/gpu/intern/gpu_shader_interface.cc (renamed from source/blender/gpu/intern/gpu_shader_interface.c)136
-rw-r--r--source/blender/gpu/intern/gpu_shader_private.h7
-rw-r--r--source/blender/gpu/intern/gpu_state.cc (renamed from source/blender/gpu/intern/gpu_state.c)72
-rw-r--r--source/blender/gpu/intern/gpu_texture.cc (renamed from source/blender/gpu/intern/gpu_texture.c)583
-rw-r--r--source/blender/gpu/intern/gpu_texture_image.cc1480
-rw-r--r--source/blender/gpu/intern/gpu_uniformbuffer.cc (renamed from source/blender/gpu/intern/gpu_uniformbuffer.c)317
-rw-r--r--source/blender/gpu/intern/gpu_vertex_buffer.cc (renamed from source/blender/gpu/intern/gpu_vertex_buffer.c)27
-rw-r--r--source/blender/gpu/intern/gpu_vertex_format.cc (renamed from source/blender/gpu/intern/gpu_vertex_format.c)57
-rw-r--r--source/blender/gpu/intern/gpu_vertex_format_private.h6
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c17
-rw-r--r--source/blender/gpu/opengl/gl_backend.hh57
-rw-r--r--source/blender/gpu/opengl/gl_context.cc239
-rw-r--r--source/blender/gpu/opengl/gl_context.hh97
-rw-r--r--source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl87
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl2
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl12
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl2
-rw-r--r--source/blender/ikplugin/BIK_api.h13
-rw-r--r--source/blender/ikplugin/intern/ikplugin_api.c2
-rw-r--r--source/blender/ikplugin/intern/ikplugin_api.h5
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c29
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.h5
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp25
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.h5
-rw-r--r--source/blender/imbuf/CMakeLists.txt2
-rw-r--r--source/blender/imbuf/IMB_colormanagement.h5
-rw-r--r--source/blender/imbuf/IMB_imbuf.h30
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h5
-rw-r--r--source/blender/imbuf/IMB_metadata.h5
-rw-r--r--source/blender/imbuf/IMB_moviecache.h5
-rw-r--r--source/blender/imbuf/IMB_thumbs.h5
-rw-r--r--source/blender/imbuf/intern/IMB_allocimbuf.h5
-rw-r--r--source/blender/imbuf/intern/IMB_anim.h5
-rw-r--r--source/blender/imbuf/intern/IMB_colormanagement_intern.h5
-rw-r--r--source/blender/imbuf/intern/IMB_filetype.h5
-rw-r--r--source/blender/imbuf/intern/IMB_filter.h5
-rw-r--r--source/blender/imbuf/intern/IMB_indexer.h5
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c9
-rw-r--r--source/blender/imbuf/intern/anim_movie.c32
-rw-r--r--source/blender/imbuf/intern/bmp.c6
-rw-r--r--source/blender/imbuf/intern/cineon/cineon_dpx.c4
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.h5
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c2
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.h5
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.c31
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.h5
-rw-r--r--source/blender/imbuf/intern/cineon/logmemfile.c36
-rw-r--r--source/blender/imbuf/intern/cineon/logmemfile.h5
-rw-r--r--source/blender/imbuf/intern/colormanagement.c16
-rw-r--r--source/blender/imbuf/intern/dds/BlockDXT.cpp50
-rw-r--r--source/blender/imbuf/intern/dds/BlockDXT.h5
-rw-r--r--source/blender/imbuf/intern/dds/Color.h5
-rw-r--r--source/blender/imbuf/intern/dds/ColorBlock.h5
-rw-r--r--source/blender/imbuf/intern/dds/Common.h5
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp115
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.h5
-rw-r--r--source/blender/imbuf/intern/dds/FlipDXT.cpp2
-rw-r--r--source/blender/imbuf/intern/dds/FlipDXT.h5
-rw-r--r--source/blender/imbuf/intern/dds/Image.h5
-rw-r--r--source/blender/imbuf/intern/dds/PixelFormat.h5
-rw-r--r--source/blender/imbuf/intern/dds/Stream.cpp20
-rw-r--r--source/blender/imbuf/intern/dds/Stream.h5
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.cpp32
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.h5
-rw-r--r--source/blender/imbuf/intern/divers.c4
-rw-r--r--source/blender/imbuf/intern/filetype.c3
-rw-r--r--source/blender/imbuf/intern/filter.c5
-rw-r--r--source/blender/imbuf/intern/imbuf.h5
-rw-r--r--source/blender/imbuf/intern/indexer.c14
-rw-r--r--source/blender/imbuf/intern/iris.c19
-rw-r--r--source/blender/imbuf/intern/jp2.c27
-rw-r--r--source/blender/imbuf/intern/jpeg.c8
-rw-r--r--source/blender/imbuf/intern/moviecache.c7
-rw-r--r--source/blender/imbuf/intern/oiio/openimageio_api.cpp6
-rw-r--r--source/blender/imbuf/intern/oiio/openimageio_api.h5
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp38
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.h5
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_multi.h5
-rw-r--r--source/blender/imbuf/intern/png.c10
-rw-r--r--source/blender/imbuf/intern/rectop.c2
-rw-r--r--source/blender/imbuf/intern/rotate.c6
-rw-r--r--source/blender/imbuf/intern/scaling.c106
-rw-r--r--source/blender/imbuf/intern/stereoimbuf.c92
-rw-r--r--source/blender/imbuf/intern/tiff.c40
-rw-r--r--source/blender/imbuf/intern/util.c20
-rw-r--r--source/blender/imbuf/intern/util_gpu.c260
-rw-r--r--source/blender/imbuf/intern/writeimage.c2
-rw-r--r--source/blender/io/alembic/ABC_alembic.h10
-rw-r--r--source/blender/io/alembic/CMakeLists.txt14
-rw-r--r--source/blender/io/alembic/exporter/abc_export_capi.cc37
-rw-r--r--source/blender/io/alembic/intern/abc_axis_conversion.cc2
-rw-r--r--source/blender/io/alembic/intern/abc_axis_conversion.h2
-rw-r--r--source/blender/io/alembic/intern/abc_customdata.cc4
-rw-r--r--source/blender/io/alembic/intern/abc_reader_archive.cc2
-rw-r--r--source/blender/io/alembic/intern/alembic_capi.cc146
-rw-r--r--source/blender/io/alembic/tests/abc_export_test.cc (renamed from tests/gtests/alembic/abc_export_test.cc)0
-rw-r--r--source/blender/io/alembic/tests/abc_matrix_test.cc (renamed from tests/gtests/alembic/abc_matrix_test.cc)0
-rw-r--r--source/blender/io/avi/AVI_avi.h5
-rw-r--r--source/blender/io/avi/intern/avi.c10
-rw-r--r--source/blender/io/avi/intern/avi_endian.h5
-rw-r--r--source/blender/io/avi/intern/avi_intern.h5
-rw-r--r--source/blender/io/avi/intern/avi_mjpeg.h5
-rw-r--r--source/blender/io/avi/intern/avi_rgb.c45
-rw-r--r--source/blender/io/avi/intern/avi_rgb.h5
-rw-r--r--source/blender/io/avi/intern/avi_rgb32.h5
-rw-r--r--source/blender/io/collada/AnimationClipExporter.h5
-rw-r--r--source/blender/io/collada/AnimationExporter.cpp23
-rw-r--r--source/blender/io/collada/AnimationExporter.h5
-rw-r--r--source/blender/io/collada/AnimationImporter.cpp162
-rw-r--r--source/blender/io/collada/AnimationImporter.h5
-rw-r--r--source/blender/io/collada/ArmatureExporter.h5
-rw-r--r--source/blender/io/collada/ArmatureImporter.h5
-rw-r--r--source/blender/io/collada/BCAnimationCurve.cpp5
-rw-r--r--source/blender/io/collada/BCAnimationCurve.h5
-rw-r--r--source/blender/io/collada/BCAnimationSampler.cpp2
-rw-r--r--source/blender/io/collada/BCAnimationSampler.h5
-rw-r--r--source/blender/io/collada/BCMath.h5
-rw-r--r--source/blender/io/collada/BCSampleData.h5
-rw-r--r--source/blender/io/collada/BlenderContext.h5
-rw-r--r--source/blender/io/collada/BlenderTypes.h5
-rw-r--r--source/blender/io/collada/CameraExporter.h5
-rw-r--r--source/blender/io/collada/ControllerExporter.h5
-rw-r--r--source/blender/io/collada/DocumentExporter.h5
-rw-r--r--source/blender/io/collada/DocumentImporter.cpp3
-rw-r--r--source/blender/io/collada/DocumentImporter.h5
-rw-r--r--source/blender/io/collada/EffectExporter.h5
-rw-r--r--source/blender/io/collada/ErrorHandler.h5
-rw-r--r--source/blender/io/collada/ExportSettings.h5
-rw-r--r--source/blender/io/collada/ExtraHandler.h5
-rw-r--r--source/blender/io/collada/ExtraTags.h5
-rw-r--r--source/blender/io/collada/GeometryExporter.h5
-rw-r--r--source/blender/io/collada/ImageExporter.h5
-rw-r--r--source/blender/io/collada/ImportSettings.h5
-rw-r--r--source/blender/io/collada/InstanceWriter.h5
-rw-r--r--source/blender/io/collada/LightExporter.h5
-rw-r--r--source/blender/io/collada/MaterialExporter.h5
-rw-r--r--source/blender/io/collada/Materials.h5
-rw-r--r--source/blender/io/collada/MeshImporter.h5
-rw-r--r--source/blender/io/collada/SceneExporter.h5
-rw-r--r--source/blender/io/collada/SkinInfo.h5
-rw-r--r--source/blender/io/collada/TransformReader.h5
-rw-r--r--source/blender/io/collada/TransformWriter.h5
-rw-r--r--source/blender/io/collada/collada.h5
-rw-r--r--source/blender/io/collada/collada_internal.cpp2
-rw-r--r--source/blender/io/collada/collada_internal.h5
-rw-r--r--source/blender/io/collada/collada_utils.cpp28
-rw-r--r--source/blender/io/collada/collada_utils.h9
-rw-r--r--source/blender/io/common/CMakeLists.txt5
-rw-r--r--source/blender/io/common/IO_abstract_hierarchy_iterator.h5
-rw-r--r--source/blender/io/common/IO_dupli_persistent_id.hh5
-rw-r--r--source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc3
-rw-r--r--source/blender/io/common/intern/dupli_parent_finder.hh5
-rw-r--r--source/blender/io/usd/intern/usd_exporter_context.h5
-rw-r--r--source/blender/io/usd/intern/usd_hierarchy_iterator.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_abstract.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_camera.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_hair.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_light.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_mesh.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_metaball.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_transform.h5
-rw-r--r--source/blender/io/usd/usd.h5
-rw-r--r--source/blender/makesdna/DNA_ID.h5
-rw-r--r--source/blender/makesdna/DNA_action_types.h8
-rw-r--r--source/blender/makesdna/DNA_anim_types.h5
-rw-r--r--source/blender/makesdna/DNA_armature_types.h5
-rw-r--r--source/blender/makesdna/DNA_boid_types.h5
-rw-r--r--source/blender/makesdna/DNA_brush_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_brush_types.h56
-rw-r--r--source/blender/makesdna/DNA_cachefile_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_cachefile_types.h18
-rw-r--r--source/blender/makesdna/DNA_camera_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_camera_types.h5
-rw-r--r--source/blender/makesdna/DNA_cloth_types.h5
-rw-r--r--source/blender/makesdna/DNA_collection_types.h5
-rw-r--r--source/blender/makesdna/DNA_color_types.h5
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h5
-rw-r--r--source/blender/makesdna/DNA_curve_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_curve_types.h5
-rw-r--r--source/blender/makesdna/DNA_curveprofile_types.h7
-rw-r--r--source/blender/makesdna/DNA_customdata_types.h5
-rw-r--r--source/blender/makesdna/DNA_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_defs.h5
-rw-r--r--source/blender/makesdna/DNA_dynamicpaint_types.h5
-rw-r--r--source/blender/makesdna/DNA_effect_types.h5
-rw-r--r--source/blender/makesdna/DNA_fileglobal_types.h5
-rw-r--r--source/blender/makesdna/DNA_fluid_types.h13
-rw-r--r--source/blender/makesdna/DNA_freestyle_types.h5
-rw-r--r--source/blender/makesdna/DNA_genfile.h5
-rw-r--r--source/blender/makesdna/DNA_gpencil_modifier_types.h5
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h5
-rw-r--r--source/blender/makesdna/DNA_gpu_types.h5
-rw-r--r--source/blender/makesdna/DNA_hair_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_hair_types.h5
-rw-r--r--source/blender/makesdna/DNA_image_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_image_types.h17
-rw-r--r--source/blender/makesdna/DNA_ipo_types.h5
-rw-r--r--source/blender/makesdna/DNA_key_types.h5
-rw-r--r--source/blender/makesdna/DNA_lattice_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_lattice_types.h5
-rw-r--r--source/blender/makesdna/DNA_layer_types.h5
-rw-r--r--source/blender/makesdna/DNA_light_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_light_types.h5
-rw-r--r--source/blender/makesdna/DNA_lightprobe_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_lightprobe_types.h11
-rw-r--r--source/blender/makesdna/DNA_linestyle_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_linestyle_types.h5
-rw-r--r--source/blender/makesdna/DNA_listBase.h5
-rw-r--r--source/blender/makesdna/DNA_mask_types.h5
-rw-r--r--source/blender/makesdna/DNA_material_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_material_types.h4
-rw-r--r--source/blender/makesdna/DNA_mesh_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h14
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h5
-rw-r--r--source/blender/makesdna/DNA_meta_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_meta_types.h5
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h43
-rw-r--r--source/blender/makesdna/DNA_movieclip_types.h9
-rw-r--r--source/blender/makesdna/DNA_nla_types.h5
-rw-r--r--source/blender/makesdna/DNA_node_types.h5
-rw-r--r--source/blender/makesdna/DNA_object_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_object_enums.h5
-rw-r--r--source/blender/makesdna/DNA_object_fluidsim_types.h5
-rw-r--r--source/blender/makesdna/DNA_object_force_types.h5
-rw-r--r--source/blender/makesdna/DNA_object_types.h31
-rw-r--r--source/blender/makesdna/DNA_outliner_types.h5
-rw-r--r--source/blender/makesdna/DNA_packedFile_types.h5
-rw-r--r--source/blender/makesdna/DNA_particle_types.h5
-rw-r--r--source/blender/makesdna/DNA_pointcache_types.h5
-rw-r--r--source/blender/makesdna/DNA_pointcloud_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_pointcloud_types.h5
-rw-r--r--source/blender/makesdna/DNA_rigidbody_types.h7
-rw-r--r--source/blender/makesdna/DNA_scene_defaults.h4
-rw-r--r--source/blender/makesdna/DNA_scene_types.h5
-rw-r--r--source/blender/makesdna/DNA_screen_types.h5
-rw-r--r--source/blender/makesdna/DNA_sdna_types.h5
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h13
-rw-r--r--source/blender/makesdna/DNA_session_uuid_types.h43
-rw-r--r--source/blender/makesdna/DNA_shader_fx_types.h4
-rw-r--r--source/blender/makesdna/DNA_simulation_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_simulation_types.h5
-rw-r--r--source/blender/makesdna/DNA_sound_types.h5
-rw-r--r--source/blender/makesdna/DNA_space_types.h5
-rw-r--r--source/blender/makesdna/DNA_speaker_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_speaker_types.h5
-rw-r--r--source/blender/makesdna/DNA_text_types.h5
-rw-r--r--source/blender/makesdna/DNA_texture_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_texture_types.h5
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h5
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h5
-rw-r--r--source/blender/makesdna/DNA_vec_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_vec_types.h5
-rw-r--r--source/blender/makesdna/DNA_vfont_types.h5
-rw-r--r--source/blender/makesdna/DNA_view2d_types.h7
-rw-r--r--source/blender/makesdna/DNA_view3d_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_view3d_enums.h5
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h5
-rw-r--r--source/blender/makesdna/DNA_volume_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_volume_types.h5
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h9
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h5
-rw-r--r--source/blender/makesdna/DNA_world_defaults.h5
-rw-r--r--source/blender/makesdna/DNA_world_types.h5
-rw-r--r--source/blender/makesdna/DNA_xr_types.h5
-rw-r--r--source/blender/makesdna/intern/CMakeLists.txt2
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c275
-rw-r--r--source/blender/makesdna/intern/dna_utils.h5
-rw-r--r--source/blender/makesdna/intern/makesdna.c9
-rw-r--r--source/blender/makesrna/RNA_define.h5
-rw-r--r--source/blender/makesrna/RNA_enum_types.h5
-rw-r--r--source/blender/makesrna/intern/makesrna.c7
-rw-r--r--source/blender/makesrna/intern/rna_access_internal.h5
-rw-r--r--source/blender/makesrna/intern/rna_brush.c112
-rw-r--r--source/blender/makesrna/intern/rna_cachefile.c26
-rw-r--r--source/blender/makesrna/intern/rna_color.c2
-rw-r--r--source/blender/makesrna/intern/rna_context.c2
-rw-r--r--source/blender/makesrna/intern/rna_curve.c4
-rw-r--r--source/blender/makesrna/intern/rna_curve_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_curveprofile.c2
-rw-r--r--source/blender/makesrna/intern/rna_define.c2
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c2
-rw-r--r--source/blender/makesrna/intern/rna_fluid.c21
-rw-r--r--source/blender/makesrna/intern/rna_image.c5
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c6
-rw-r--r--source/blender/makesrna/intern/rna_internal.h5
-rw-r--r--source/blender/makesrna/intern/rna_internal_types.h5
-rw-r--r--source/blender/makesrna/intern/rna_mesh_utils.h5
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c110
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c10
-rw-r--r--source/blender/makesrna/intern/rna_object.c9
-rw-r--r--source/blender/makesrna/intern/rna_particle.c2
-rw-r--r--source/blender/makesrna/intern/rna_rigidbody.c20
-rw-r--r--source/blender/makesrna/intern/rna_scene.c4
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c9
-rw-r--r--source/blender/makesrna/intern/rna_screen.c2
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c2
-rw-r--r--source/blender/makesrna/intern/rna_shader_fx.c2
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c2
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c12
-rw-r--r--source/blender/modifiers/MOD_modifiertypes.h5
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c7
-rw-r--r--source/blender/modifiers/intern/MOD_array.c11
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c5
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c2
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c7
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c52
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c5
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c5
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c118
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c7
-rw-r--r--source/blender/modifiers/intern/MOD_mask.cc13
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache_mdd.c33
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache_pc2.c31
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache_util.h5
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c22
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c4
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c34
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c9
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c4
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c2
-rw-r--r--source/blender/modifiers/intern/MOD_simulation.cc38
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c19
-rw-r--r--source/blender/modifiers/intern/MOD_solidify_extrude.c10
-rw-r--r--source/blender/modifiers/intern/MOD_solidify_nonmanifold.c11
-rw-r--r--source/blender/modifiers/intern/MOD_solidify_util.h5
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c9
-rw-r--r--source/blender/modifiers/intern/MOD_ui_common.c7
-rw-r--r--source/blender/modifiers/intern/MOD_ui_common.h5
-rw-r--r--source/blender/modifiers/intern/MOD_util.c7
-rw-r--r--source/blender/modifiers/intern/MOD_util.h4
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c2
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c8
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c7
-rw-r--r--source/blender/modifiers/intern/MOD_weighted_normal.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.c4
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.h4
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c4
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c19
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weld.c63
-rw-r--r--source/blender/nodes/CMakeLists.txt3
-rw-r--r--source/blender/nodes/NOD_common.h5
-rw-r--r--source/blender/nodes/NOD_composite.h5
-rw-r--r--source/blender/nodes/NOD_derived_node_tree.hh10
-rw-r--r--source/blender/nodes/NOD_function.h6
-rw-r--r--source/blender/nodes/NOD_node_tree_dependencies.hh5
-rw-r--r--source/blender/nodes/NOD_node_tree_multi_function.hh29
-rw-r--r--source/blender/nodes/NOD_node_tree_ref.hh9
-rw-r--r--source/blender/nodes/NOD_shader.h5
-rw-r--r--source/blender/nodes/NOD_simulation.h7
-rw-r--r--source/blender/nodes/NOD_socket.h10
-rw-r--r--source/blender/nodes/NOD_static_types.h4
-rw-r--r--source/blender/nodes/NOD_texture.h5
-rw-r--r--source/blender/nodes/composite/node_composite_util.h5
-rw-r--r--source/blender/nodes/function/node_function_util.hh5
-rw-r--r--source/blender/nodes/function/nodes/node_fn_random_float.cc89
-rw-r--r--source/blender/nodes/intern/derived_node_tree.cc11
-rw-r--r--source/blender/nodes/intern/node_common.c13
-rw-r--r--source/blender/nodes/intern/node_common.h5
-rw-r--r--source/blender/nodes/intern/node_exec.h5
-rw-r--r--source/blender/nodes/intern/node_socket.cc48
-rw-r--r--source/blender/nodes/intern/node_tree_dependencies.cc4
-rw-r--r--source/blender/nodes/intern/node_tree_multi_function.cc11
-rw-r--r--source/blender/nodes/intern/node_tree_ref.cc8
-rw-r--r--source/blender/nodes/intern/node_util.c2
-rw-r--r--source/blender/nodes/intern/node_util.h5
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c14
-rw-r--r--source/blender/nodes/shader/node_shader_util.h5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_attribute.c15
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_clamp.cc5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_curves.c29
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_displacement.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_geometry.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mapping.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.cc5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mixRgb.c9
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tangent.c37
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_environment.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_sky.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_valToRgb.cc5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_displacement.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_math.cc5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_rotate.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_wireframe.c18
-rw-r--r--source/blender/nodes/simulation/node_simulation_tree.cc4
-rw-r--r--source/blender/nodes/simulation/node_simulation_util.h5
-rw-r--r--source/blender/nodes/simulation/nodes/node_sim_age_reached_event.cc38
-rw-r--r--source/blender/nodes/simulation/nodes/node_sim_kill_particle.cc36
-rw-r--r--source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc1
-rw-r--r--source/blender/nodes/texture/node_texture_util.c13
-rw-r--r--source/blender/nodes/texture/node_texture_util.h5
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_curves.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_rotate.c2
-rw-r--r--source/blender/python/BPY_extern.h6
-rw-r--r--source/blender/python/BPY_extern_clog.h5
-rw-r--r--source/blender/python/bmesh/bmesh_py_api.h5
-rw-r--r--source/blender/python/bmesh/bmesh_py_geometry.h5
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops.c8
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops.h5
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops_call.c24
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops_call.h5
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c680
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.h5
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c108
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.h5
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_meshdata.c113
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_meshdata.h5
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_select.c76
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_select.h5
-rw-r--r--source/blender/python/bmesh/bmesh_py_utils.c63
-rw-r--r--source/blender/python/bmesh/bmesh_py_utils.h5
-rw-r--r--source/blender/python/generic/bgl.c2293
-rw-r--r--source/blender/python/generic/bgl.h5
-rw-r--r--source/blender/python/generic/bl_math_py_api.h5
-rw-r--r--source/blender/python/generic/blf_py_api.h5
-rw-r--r--source/blender/python/generic/idprop_py_api.c124
-rw-r--r--source/blender/python/generic/idprop_py_api.h5
-rw-r--r--source/blender/python/generic/imbuf_py_api.c14
-rw-r--r--source/blender/python/generic/imbuf_py_api.h5
-rw-r--r--source/blender/python/generic/py_capi_utils.c204
-rw-r--r--source/blender/python/generic/py_capi_utils.h1
-rw-r--r--source/blender/python/generic/python_utildefines.h5
-rw-r--r--source/blender/python/gpu/gpu_py_api.c4
-rw-r--r--source/blender/python/gpu/gpu_py_api.h11
-rw-r--r--source/blender/python/gpu/gpu_py_batch.c9
-rw-r--r--source/blender/python/gpu/gpu_py_batch.h5
-rw-r--r--source/blender/python/gpu/gpu_py_element.h5
-rw-r--r--source/blender/python/gpu/gpu_py_matrix.h5
-rw-r--r--source/blender/python/gpu/gpu_py_offscreen.h5
-rw-r--r--source/blender/python/gpu/gpu_py_select.h5
-rw-r--r--source/blender/python/gpu/gpu_py_shader.h5
-rw-r--r--source/blender/python/gpu/gpu_py_types.h5
-rw-r--r--source/blender/python/gpu/gpu_py_vertex_buffer.h5
-rw-r--r--source/blender/python/gpu/gpu_py_vertex_format.h5
-rw-r--r--source/blender/python/intern/bpy.h5
-rw-r--r--source/blender/python/intern/bpy_app.h5
-rw-r--r--source/blender/python/intern/bpy_app_alembic.h5
-rw-r--r--source/blender/python/intern/bpy_app_build_options.h5
-rw-r--r--source/blender/python/intern/bpy_app_ffmpeg.h5
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c18
-rw-r--r--source/blender/python/intern/bpy_app_handlers.h5
-rw-r--r--source/blender/python/intern/bpy_app_icons.h5
-rw-r--r--source/blender/python/intern/bpy_app_ocio.h5
-rw-r--r--source/blender/python/intern/bpy_app_oiio.h5
-rw-r--r--source/blender/python/intern/bpy_app_opensubdiv.h5
-rw-r--r--source/blender/python/intern/bpy_app_openvdb.h5
-rw-r--r--source/blender/python/intern/bpy_app_sdl.h5
-rw-r--r--source/blender/python/intern/bpy_app_timers.h5
-rw-r--r--source/blender/python/intern/bpy_app_translations.c8
-rw-r--r--source/blender/python/intern/bpy_app_translations.h5
-rw-r--r--source/blender/python/intern/bpy_app_usd.h5
-rw-r--r--source/blender/python/intern/bpy_capi_utils.h5
-rw-r--r--source/blender/python/intern/bpy_driver.c16
-rw-r--r--source/blender/python/intern/bpy_driver.h5
-rw-r--r--source/blender/python/intern/bpy_gizmo_wrap.h5
-rw-r--r--source/blender/python/intern/bpy_interface.c9
-rw-r--r--source/blender/python/intern/bpy_intern_string.h5
-rw-r--r--source/blender/python/intern/bpy_library.h5
-rw-r--r--source/blender/python/intern/bpy_library_load.c118
-rw-r--r--source/blender/python/intern/bpy_msgbus.h5
-rw-r--r--source/blender/python/intern/bpy_operator.c9
-rw-r--r--source/blender/python/intern/bpy_operator.h5
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.h5
-rw-r--r--source/blender/python/intern/bpy_path.h5
-rw-r--r--source/blender/python/intern/bpy_props.c60
-rw-r--r--source/blender/python/intern/bpy_props.h5
-rw-r--r--source/blender/python/intern/bpy_rna.c839
-rw-r--r--source/blender/python/intern/bpy_rna.h5
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c216
-rw-r--r--source/blender/python/intern/bpy_rna_anim.h5
-rw-r--r--source/blender/python/intern/bpy_rna_array.c125
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c76
-rw-r--r--source/blender/python/intern/bpy_rna_callback.h5
-rw-r--r--source/blender/python/intern/bpy_rna_driver.h5
-rw-r--r--source/blender/python/intern/bpy_rna_gizmo.c8
-rw-r--r--source/blender/python/intern/bpy_rna_gizmo.h5
-rw-r--r--source/blender/python/intern/bpy_rna_id_collection.h5
-rw-r--r--source/blender/python/intern/bpy_rna_types_capi.h5
-rw-r--r--source/blender/python/intern/bpy_traceback.h5
-rw-r--r--source/blender/python/intern/bpy_utils_previews.h5
-rw-r--r--source/blender/python/intern/bpy_utils_units.h5
-rw-r--r--source/blender/python/mathutils/mathutils.c101
-rw-r--r--source/blender/python/mathutils/mathutils.h5
-rw-r--r--source/blender/python/mathutils/mathutils_Color.c34
-rw-r--r--source/blender/python/mathutils/mathutils_Color.h5
-rw-r--r--source/blender/python/mathutils/mathutils_Euler.c34
-rw-r--r--source/blender/python/mathutils/mathutils_Euler.h5
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c245
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.h5
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.c47
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.h5
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c115
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.h5
-rw-r--r--source/blender/python/mathutils/mathutils_bvhtree.c92
-rw-r--r--source/blender/python/mathutils/mathutils_bvhtree.h5
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c284
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.h5
-rw-r--r--source/blender/python/mathutils/mathutils_interpolate.h5
-rw-r--r--source/blender/python/mathutils/mathutils_kdtree.h5
-rw-r--r--source/blender/python/mathutils/mathutils_noise.h5
-rw-r--r--source/blender/render/extern/include/RE_bake.h5
-rw-r--r--source/blender/render/extern/include/RE_engine.h5
-rw-r--r--source/blender/render/extern/include/RE_multires_bake.h5
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h9
-rw-r--r--source/blender/render/extern/include/RE_render_ext.h5
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h5
-rw-r--r--source/blender/render/intern/include/initrender.h5
-rw-r--r--source/blender/render/intern/include/render_result.h5
-rw-r--r--source/blender/render/intern/include/render_types.h5
-rw-r--r--source/blender/render/intern/include/renderpipeline.h5
-rw-r--r--source/blender/render/intern/include/texture.h5
-rw-r--r--source/blender/render/intern/include/zbuf.h5
-rw-r--r--source/blender/render/intern/source/external_engine.c12
-rw-r--r--source/blender/render/intern/source/imagetexture.c6
-rw-r--r--source/blender/render/intern/source/initrender.c12
-rw-r--r--source/blender/render/intern/source/multires_bake.c2
-rw-r--r--source/blender/render/intern/source/pipeline.c48
-rw-r--r--source/blender/render/intern/source/pointdensity.c6
-rw-r--r--source/blender/render/intern/source/render_result.c26
-rw-r--r--source/blender/render/intern/source/render_texture.c27
-rw-r--r--source/blender/shader_fx/FX_shader_types.h5
-rw-r--r--source/blender/shader_fx/intern/FX_shader_util.h5
-rw-r--r--source/blender/shader_fx/intern/FX_ui_common.h5
-rw-r--r--source/blender/simulation/SIM_mass_spring.h5
-rw-r--r--source/blender/simulation/SIM_simulation_update.hh5
-rw-r--r--source/blender/simulation/intern/ConstrainedConjugateGradient.h5
-rw-r--r--source/blender/simulation/intern/eigen_utils.h5
-rw-r--r--source/blender/simulation/intern/hair_volume.cpp16
-rw-r--r--source/blender/simulation/intern/implicit.h5
-rw-r--r--source/blender/simulation/intern/implicit_blender.c74
-rw-r--r--source/blender/simulation/intern/particle_allocator.cc4
-rw-r--r--source/blender/simulation/intern/particle_allocator.hh5
-rw-r--r--source/blender/simulation/intern/particle_function.cc5
-rw-r--r--source/blender/simulation/intern/particle_function.hh5
-rw-r--r--source/blender/simulation/intern/particle_mesh_emitter.cc14
-rw-r--r--source/blender/simulation/intern/particle_mesh_emitter.hh12
-rw-r--r--source/blender/simulation/intern/simulation_collect_influences.cc173
-rw-r--r--source/blender/simulation/intern/simulation_collect_influences.hh5
-rw-r--r--source/blender/simulation/intern/simulation_solver.cc193
-rw-r--r--source/blender/simulation/intern/simulation_solver.hh5
-rw-r--r--source/blender/simulation/intern/simulation_solver_influences.cc4
-rw-r--r--source/blender/simulation/intern/simulation_solver_influences.hh50
-rw-r--r--source/blender/simulation/intern/simulation_update.cc11
-rw-r--r--source/blender/simulation/intern/time_interval.hh5
-rw-r--r--source/blender/windowmanager/WM_api.h7
-rw-r--r--source/blender/windowmanager/WM_keymap.h5
-rw-r--r--source/blender/windowmanager/WM_message.h5
-rw-r--r--source/blender/windowmanager/WM_toolsystem.h5
-rw-r--r--source/blender/windowmanager/WM_types.h5
-rw-r--r--source/blender/windowmanager/gizmo/WM_gizmo_api.h5
-rw-r--r--source/blender/windowmanager/gizmo/WM_gizmo_types.h5
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo.c4
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c23
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h5
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c16
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c12
-rw-r--r--source/blender/windowmanager/gizmo/wm_gizmo_fn.h5
-rw-r--r--source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h5
-rw-r--r--source/blender/windowmanager/intern/wm.c12
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c8
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c4
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c17
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c325
-rw-r--r--source/blender/windowmanager/intern/wm_files.c28
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c6
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c2
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c14
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c4
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c16
-rw-r--r--source/blender/windowmanager/intern/wm_keymap_utils.c25
-rw-r--r--source/blender/windowmanager/intern/wm_operator_type.c8
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c337
-rw-r--r--source/blender/windowmanager/intern/wm_platform_support.h5
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c3
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c15
-rw-r--r--source/blender/windowmanager/intern/wm_window.c41
-rw-r--r--source/blender/windowmanager/intern/wm_window_private.h5
-rw-r--r--source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h5
-rw-r--r--source/blender/windowmanager/message_bus/wm_message_bus.h5
-rw-r--r--source/blender/windowmanager/wm.h5
-rw-r--r--source/blender/windowmanager/wm_cursors.h5
-rw-r--r--source/blender/windowmanager/wm_draw.h5
-rw-r--r--source/blender/windowmanager/wm_event_system.h5
-rw-r--r--source/blender/windowmanager/wm_event_types.h5
-rw-r--r--source/blender/windowmanager/wm_files.h5
-rw-r--r--source/blender/windowmanager/wm_surface.h5
-rw-r--r--source/blender/windowmanager/wm_window.h5
-rw-r--r--source/blender/windowmanager/xr/intern/wm_xr_draw.c2
-rw-r--r--source/blender/windowmanager/xr/intern/wm_xr_intern.h13
-rw-r--r--source/blender/windowmanager/xr/intern/wm_xr_session.c83
-rw-r--r--source/blender/windowmanager/xr/wm_xr.h7
-rw-r--r--source/creator/CMakeLists.txt17
-rw-r--r--source/creator/creator.c63
-rw-r--r--source/creator/creator_args.c6
-rw-r--r--source/creator/creator_intern.h5
-rw-r--r--source/creator/creator_signals.c9
-rw-r--r--tests/gtests/CMakeLists.txt14
-rw-r--r--tests/gtests/alembic/CMakeLists.txt63
-rw-r--r--tests/gtests/blenlib/CMakeLists.txt71
-rw-r--r--tests/gtests/blenlib/stubs/bf_intern_eigen_stubs.h27
-rw-r--r--tests/gtests/blenloader/CMakeLists.txt92
-rw-r--r--tests/gtests/bmesh/CMakeLists.txt49
-rw-r--r--tests/gtests/runner/BlenderAddTests.cmake3
-rw-r--r--tests/gtests/runner/CMakeLists.txt34
-rw-r--r--tests/gtests/testing/testing_main.cc2
-rw-r--r--tests/python/CMakeLists.txt2
-rw-r--r--tests/python/cycles_render_tests.py7
-rwxr-xr-xtests/python/modules/render_report.py11
2580 files changed, 31965 insertions, 29249 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 7cf2830d438..3f24e7718e2 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -12,12 +12,8 @@ Checks: >
-readability-misleading-indentation,
- -readability-else-after-return,
-readability-inconsistent-declaration-parameter-name,
-readability-redundant-preprocessor,
- -readability-function-size,
- -readability-function-size,
- -readability-redundant-string-init,
-readability-redundant-member-init,
-readability-const-return-type,
-readability-static-accessed-through-instance,
@@ -35,11 +31,6 @@ Checks: >
-bugprone-sizeof-expression,
-bugprone-integer-division,
-bugprone-incorrect-roundings,
- -bugprone-suspicious-string-compare,
- -bugprone-not-null-terminated-result,
- -bugprone-suspicious-missing-comma,
- -bugprone-parent-virtual-call,
- -bugprone-infinite-loop,
-bugprone-copy-constructor-init,
WarningsAsErrors: '*'
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bc4d4e032af..cd518227e27 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -214,6 +214,8 @@ if(WITH_GHOST_X11)
option(WITH_GHOST_XDND "Enable drag'n'drop support on X11 using XDND protocol" ON)
endif()
+option(WITH_GMP "Use the gmp library for more accurate booleans" OFF)
+
# Misc...
option(WITH_HEADLESS "Build without graphical support (renderfarm, server mode only)" OFF)
mark_as_advanced(WITH_HEADLESS)
diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt
index 276311fe2d8..c26b90637c3 100644
--- a/build_files/build_environment/CMakeLists.txt
+++ b/build_files/build_environment/CMakeLists.txt
@@ -117,6 +117,7 @@ if(WIN32)
endif()
if(NOT WIN32 OR ENABLE_MINGW64)
+ include(cmake/gmp.cmake)
include(cmake/openjpeg.cmake)
if(NOT WIN32 OR BUILD_MODE STREQUAL Release)
if(WIN32)
diff --git a/build_files/build_environment/cmake/gmp.cmake b/build_files/build_environment/cmake/gmp.cmake
new file mode 100644
index 00000000000..40d8e04b3a7
--- /dev/null
+++ b/build_files/build_environment/cmake/gmp.cmake
@@ -0,0 +1,88 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(GMP_EXTRA_ARGS -enable-cxx)
+
+if(WIN32)
+ # Shared for windows because static libs will drag in a libgcc dependency.
+ set(GMP_OPTIONS --disable-static --enable-shared --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32)
+else()
+ set(GMP_OPTIONS --enable-static --disable-shared )
+endif()
+
+ExternalProject_Add(external_gmp
+ URL ${GMP_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${GMP_HASH}
+ PREFIX ${BUILD_DIR}/gmp
+ CONFIGURE_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/gmp/src/external_gmp/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/gmp ${GMP_OPTIONS} ${GMP_EXTRA_ARGS}
+ BUILD_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/gmp/src/external_gmp/ && make -j${MAKE_THREADS}
+ INSTALL_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/gmp/src/external_gmp/ && make install
+ INSTALL_DIR ${LIBDIR}/gmp
+)
+
+if(MSVC)
+ set_target_properties(external_gmp PROPERTIES FOLDER Mingw)
+endif()
+
+if(BUILD_MODE STREQUAL Release AND WIN32)
+ ExternalProject_Add_Step(external_gmp after_install
+ COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-3.dll.def ${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.def
+ COMMAND lib /def:${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.def /machine:x64 /out:${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/gmp/bin/libgmp-10.dll ${HARVEST_TARGET}/gmp/lib/libgmp-10.dll
+ COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.lib ${HARVEST_TARGET}/gmp/lib/libgmp-10.lib
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/gmp/include ${HARVEST_TARGET}/gmp/include
+ DEPENDEES install
+ )
+endif()
+
+if(BUILD_MODE STREQUAL Debug AND WIN32)
+ExternalProject_Add_Step(external_gmp after_install
+ COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-3.dll.def ${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.def
+ COMMAND lib /def:${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.def /machine:x64 /out:${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.lib
+ DEPENDEES install
+ )
+endif()
+
+if(WIN32)
+ # gmpxx is somewhat special, it builds on top of the C style gmp library but exposes C++ bindings
+ # given the C++ ABI between MSVC and mingw is not compatible, we need to build the bindings
+ # with MSVC, while GMP can only be build with mingw.
+ ExternalProject_Add(external_gmpxx
+ URL ${GMP_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${GMP_HASH}
+ PREFIX ${BUILD_DIR}/gmpxx
+ PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_gmpxx.txt ${BUILD_DIR}/gmpxx/src/external_gmpxx/CMakeLists.txt &&
+ ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/config_gmpxx.h ${BUILD_DIR}/gmpxx/src/external_gmpxx/config.h
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/gmpxx ${DEFAULT_CMAKE_FLAGS} -DGMP_LIBRARY=${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.lib -DGMP_INCLUDE_DIR=${BUILD_DIR}/gmp/src/external_gmp -DCMAKE_DEBUG_POSTFIX=_d
+ INSTALL_DIR ${LIBDIR}/gmpxx
+ )
+ set_target_properties(external_gmpxx PROPERTIES FOLDER Mingw)
+
+ add_dependencies(
+ external_gmpxx
+ external_gmp
+ )
+
+ ExternalProject_Add_Step(external_gmpxx after_install
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/gmpxx/ ${HARVEST_TARGET}/gmp
+ DEPENDEES install
+ )
+
+endif()
diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake
index 3f5d2044dbc..dbb3a33e705 100644
--- a/build_files/build_environment/cmake/harvest.cmake
+++ b/build_files/build_environment/cmake/harvest.cmake
@@ -89,6 +89,8 @@ harvest(freetype/include freetype/include "*.h")
harvest(freetype/lib/libfreetype2ST.a freetype/lib/libfreetype.a)
harvest(glew/include glew/include "*.h")
harvest(glew/lib glew/lib "*.a")
+harvest(gmp/include gmp/include "*.h")
+harvest(gmp/lib gmp/lib "*.a")
harvest(jemalloc/include jemalloc/include "*.h")
harvest(jemalloc/lib jemalloc/lib "*.a")
harvest(jpg/include jpeg/include "*.h")
diff --git a/build_files/build_environment/cmake/ispc.cmake b/build_files/build_environment/cmake/ispc.cmake
index b67351dcf9f..a352f87a9aa 100644
--- a/build_files/build_environment/cmake/ispc.cmake
+++ b/build_files/build_environment/cmake/ispc.cmake
@@ -73,4 +73,3 @@ if(WIN32)
external_flexbison
)
endif()
-
diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
index ce2a1191f17..30a0b1184c2 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -315,3 +315,7 @@ set(XR_OPENXR_SDK_HASH c6de63d2e0f9029aa58dfa97cad8ce07)
set(ISPC_VERSION v1.13.0)
set(ISPC_URI https://github.com/ispc/ispc/archive/${ISPC_VERSION}.tar.gz)
set(ISPC_HASH 4bf5e8d0020c4b9980faa702c1a6f25f)
+
+set(GMP_VERSION 6.2.0)
+set(GMP_URI https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.xz)
+set(GMP_HASH a325e3f09e6d91e62101e59f9bda3ec1)
diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index 49d7b8209ee..46f1694ed38 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -374,71 +374,96 @@ NO_BUILD=false
NO_CONFIRM=false
USE_CXX11=true
+# Note about versions: Min is inclusive, Max is exclusive (i.e. XXX_VERSION_MIN <= ACTUAL_VERSION < XXX_VERSION_MAX)
+# XXX_VERSION is officially supported/used version in official builds.
+# XXX_VERSION_SHORT is used for various things, like preferred version (when distribution provides several of them),
+# and to name shortcuts to built libraries' installation directories...
+
CLANG_FORMAT_VERSION_MIN="6.0"
+CLANG_FORMAT_VERSION_MAX="10.0"
PYTHON_VERSION="3.7.7"
+PYTHON_VERSION_SHORT="3.7"
PYTHON_VERSION_MIN="3.7"
+PYTHON_VERSION_MAX="3.9"
PYTHON_VERSION_INSTALLED=$PYTHON_VERSION_MIN
PYTHON_FORCE_BUILD=false
PYTHON_FORCE_REBUILD=false
PYTHON_SKIP=false
-NUMPY_VERSION="1.17.0"
+NUMPY_VERSION="1.17.5"
+NUMPY_VERSION_SHORT="1.17"
NUMPY_VERSION_MIN="1.8"
+NUMPY_VERSION_MAX="2.0"
NUMPY_FORCE_BUILD=false
NUMPY_FORCE_REBUILD=false
NUMPY_SKIP=false
BOOST_VERSION="1.70.0"
+BOOST_VERSION_SHORT="1.70"
BOOST_VERSION_MIN="1.49"
+BOOST_VERSION_MAX="2.0"
BOOST_FORCE_BUILD=false
BOOST_FORCE_REBUILD=false
BOOST_SKIP=false
TBB_VERSION="2019"
+TBB_VERSION_SHORT="2019"
TBB_VERSION_UPDATE="_U9" # Used for source packages...
TBB_VERSION_MIN="2018"
+TBB_VERSION_MAX="2021"
TBB_FORCE_BUILD=false
TBB_FORCE_REBUILD=false
TBB_SKIP=false
-OCIO_VERSION="1.1.0"
+OCIO_VERSION="1.1.1"
+OCIO_VERSION_SHORT="1.1"
OCIO_VERSION_MIN="1.0"
+OCIO_VERSION_MAX="1.2"
OCIO_FORCE_BUILD=false
OCIO_FORCE_REBUILD=false
OCIO_SKIP=false
OPENEXR_VERSION="2.4.0"
+OPENEXR_VERSION_SHORT="2.4"
OPENEXR_VERSION_MIN="2.3"
+OPENEXR_VERSION_MAX="3.0"
OPENEXR_FORCE_BUILD=false
OPENEXR_FORCE_REBUILD=false
OPENEXR_SKIP=false
_with_built_openexr=false
-OIIO_VERSION="1.8.13"
-OIIO_VERSION_MIN="1.8.13"
-OIIO_VERSION_MAX="99.99.0" # UNKNOWN currently # Not supported by current OSL...
+OIIO_VERSION="2.1.15"
+OIIO_VERSION_SHORT="2.1"
+OIIO_VERSION_MIN="1.8"
+OIIO_VERSION_MAX="3.0"
OIIO_FORCE_BUILD=false
OIIO_FORCE_REBUILD=false
OIIO_SKIP=false
LLVM_VERSION="9.0.1"
+LLVM_VERSION_SHORT="9.0"
LLVM_VERSION_MIN="6.0"
+LLVM_VERSION_MAX="11.0"
LLVM_VERSION_FOUND=""
LLVM_FORCE_BUILD=false
LLVM_FORCE_REBUILD=false
LLVM_SKIP=false
# OSL needs to be compiled for now!
-OSL_VERSION="1.10.9"
-OSL_VERSION_MIN=$OSL_VERSION
+OSL_VERSION="1.10.10"
+OSL_VERSION_SHORT="1.10"
+OSL_VERSION_MIN="1.10"
+OSL_VERSION_MAX="2.0"
OSL_FORCE_BUILD=false
OSL_FORCE_REBUILD=false
OSL_SKIP=false
# OpenSubdiv needs to be compiled for now
OSD_VERSION="3.4.3"
-OSD_VERSION_MIN=$OSD_VERSION
+OSD_VERSION_SHORT="3.4"
+OSD_VERSION_MIN="3.4"
+OSD_VERSION_MAX="4.0"
OSD_FORCE_BUILD=false
OSD_FORCE_REBUILD=false
OSD_SKIP=false
@@ -447,46 +472,69 @@ OSD_SKIP=false
OPENVDB_BLOSC_VERSION="1.5.0"
OPENVDB_VERSION="7.0.0"
-OPENVDB_VERSION_MIN=$OPENVDB_VERSION
+OPENVDB_VERSION_SHORT="7.0"
+OPENVDB_VERSION_MIN="7.0"
+OPENVDB_VERSION_MAX="8.0"
OPENVDB_FORCE_BUILD=false
OPENVDB_FORCE_REBUILD=false
OPENVDB_SKIP=false
# Alembic needs to be compiled for now
ALEMBIC_VERSION="1.7.12"
-ALEMBIC_VERSION_MIN=$ALEMBIC_VERSION
+ALEMBIC_VERSION_SHORT="1.7"
+ALEMBIC_VERSION_MIN="1.7"
+ALEMBIC_VERSION_MAX="2.0"
ALEMBIC_FORCE_BUILD=false
ALEMBIC_FORCE_REBUILD=false
ALEMBIC_SKIP=false
USD_VERSION="20.05"
+USD_VERSION_SHORT="20.05"
+USD_VERSION_MIN="20.05"
+USD_VERSION_MAX="20.06"
USD_FORCE_BUILD=false
USD_FORCE_REBUILD=false
USD_SKIP=false
OPENCOLLADA_VERSION="1.6.68"
+OPENCOLLADA_VERSION_SHORT="1.6"
+OPENCOLLADA_VERSION_MIN="1.6.68"
+OPENCOLLADA_VERSION_MAX="1.7"
OPENCOLLADA_FORCE_BUILD=false
OPENCOLLADA_FORCE_REBUILD=false
OPENCOLLADA_SKIP=false
EMBREE_VERSION="3.10.0"
+EMBREE_VERSION_SHORT="3.10"
+EMBREE_VERSION_MIN="3.10"
+EMBREE_VERSION_MAX="4.0"
EMBREE_FORCE_BUILD=false
EMBREE_FORCE_REBUILD=false
EMBREE_SKIP=false
-OIDN_VERSION="1.0.0"
+OIDN_VERSION="1.2.1"
+OIDN_VERSION_SHORT="1.2"
+OIDN_VERSION_MIN="1.2.0"
+OIDN_VERSION_MAX="1.3"
OIDN_FORCE_BUILD=false
OIDN_FORCE_REBUILD=false
OIDN_SKIP=false
+ISPC_VERSION="1.14.0"
+
FFMPEG_VERSION="4.2.3"
-FFMPEG_VERSION_MIN="2.8.4"
+FFMPEG_VERSION_SHORT="4.2"
+FFMPEG_VERSION_MIN="3.0"
+FFMPEG_VERSION_MAX="5.0"
FFMPEG_FORCE_BUILD=false
FFMPEG_FORCE_REBUILD=false
FFMPEG_SKIP=false
_ffmpeg_list_sep=";"
XR_OPENXR_VERSION="1.0.8"
+XR_OPENXR_VERSION_SHORT="1.0"
+XR_OPENXR_VERSION_MIN="1.0.8"
+XR_OPENXR_VERSION_MAX="2.0"
XR_OPENXR_FORCE_BUILD=false
XR_OPENXR_FORCE_REBUILD=false
XR_OPENXR_SKIP=false
@@ -634,36 +682,43 @@ while true; do
--ver-ocio)
OCIO_VERSION="$2"
OCIO_VERSION_MIN=$OCIO_VERSION
+ OCIO_VERSION_SHORT=$OCIO_VERSION
shift; shift; continue
;;
--ver-oiio)
OIIO_VERSION="$2"
OIIO_VERSION_MIN=$OIIO_VERSION
+ OIIO_VERSION_SHORT=$OIIO_VERSION
shift; shift; continue
;;
--ver-llvm)
LLVM_VERSION="$2"
LLVM_VERSION_MIN=$LLVM_VERSION
+ LLVM_VERSION_SHORT=$LLVM_VERSION
shift; shift; continue
;;
--ver-osl)
OSL_VERSION="$2"
OSL_VERSION_MIN=$OSL_VERSION
+ OSL_VERSION_SHORT=$OSL_VERSION
shift; shift; continue
;;
--ver-osd)
OSD_VERSION="$2"
OSD_VERSION_MIN=$OSD_VERSION
+ OSD_VERSION_SHORT=$OSD_VERSION
shift; shift; continue
;;
--ver-openvdb)
OPENVDB_VERSION="$2"
OPENVDB_VERSION_MIN=$OPENVDB_VERSION
+ OPENVDB_VERSION_SHORT=$OPENVDB_VERSION
shift; shift; continue
;;
--ver-xr-openxr)
XR_OPENXR_VERSION="$2"
XR_OPENXR_VERSION_MIN=$XR_OPENXR_VERSION
+ XR_OPENXR_VERSION_SHORT=$XR_OPENXR_VERSION
shift; shift; continue
;;
--build-all)
@@ -1005,6 +1060,8 @@ OIDN_SOURCE=( "https://github.com/OpenImageDenoise/oidn/releases/download/v${OID
#~ OIDN_REPO_UID="dabfd9c80101edae9d25a710160d12d6d963c591"
#~ OIDN_REPO_BRANCH="master"
+ISPC_BINARY=( "https://github.com/ispc/ispc/releases/download/v${ISPC_VERSION}/ispc-v${ISPC_VERSION}-linux.tar.gz" )
+
FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
XR_OPENXR_USE_REPO=false
@@ -1030,7 +1087,7 @@ Those libraries should be available as packages in all recent distributions (opt
* libjpeg, libpng, libtiff, [openjpeg2], [libopenal].
* libx11, libxcursor, libxi, libxrandr, libxinerama (and other libx... as needed).
* libsqlite3, libbz2, libssl, libfftw3, libxml2, libtinyxml, yasm, libyaml-cpp.
- * libsdl2, libglew, [libglewmx].\""
+ * libsdl2, libglew, [libgmp], [libglewmx].\""
DEPS_SPECIFIC_INFO="\"BUILDABLE DEPENDENCIES:
@@ -1270,7 +1327,7 @@ _init_python() {
_src=$SRC/Python-$PYTHON_VERSION
_git=false
_inst=$INST/python-$PYTHON_VERSION
- _inst_shortcut=$INST/python-$PYTHON_VERSION_MIN
+ _inst_shortcut=$INST/python-$PYTHON_VERSION_SHORT
}
_update_deps_python() {
@@ -1345,7 +1402,7 @@ compile_Python() {
INFO "If you want to force rebuild of this lib, use the --force-python option."
fi
- run_ldconfig "python-$PYTHON_VERSION_MIN"
+ run_ldconfig "python-$PYTHON_VERSION_SHORT"
}
# ----------------------------------------------------------------------------
@@ -1355,8 +1412,8 @@ _init_numpy() {
_src=$SRC/numpy-$NUMPY_VERSION
_git=false
_inst=$INST/numpy-$NUMPY_VERSION
- _python=$INST/python-$PYTHON_VERSION
- _site=lib/python$PYTHON_VERSION_MIN/site-packages
+ _python=$INST/python-$PYTHON_VERSION_SHORT
+ _site=lib/python$PYTHON_VERSION_SHORT/site-packages
_inst_shortcut=$_python/$_site/numpy
}
@@ -1435,7 +1492,7 @@ compile_Numpy() {
_init_boost() {
_src=$SRC/boost-$BOOST_VERSION
_git=false
- _inst=$INST/boost-$BOOST_VERSION
+ _inst=$INST/boost-$BOOST_VERSION_SHORT
_inst_shortcut=$INST/boost
}
@@ -1528,7 +1585,7 @@ compile_Boost() {
_init_tbb() {
_src=$SRC/TBB-$TBB_VERSION
_git=false
- _inst=$INST/tbb-$TBB_VERSION
+ _inst=$INST/tbb-$TBB_VERSION_SHORT
_inst_shortcut=$INST/tbb
}
@@ -1656,7 +1713,7 @@ _init_ocio() {
else
_git=false
fi
- _inst=$INST/ocio-$OCIO_VERSION
+ _inst=$INST/ocio-$OCIO_VERSION_SHORT
_inst_shortcut=$INST/ocio
}
@@ -1781,7 +1838,7 @@ compile_OCIO() {
_init_openexr() {
_src=$SRC/OpenEXR-$OPENEXR_VERSION
_git=false
- _inst=$INST/openexr-$OPENEXR_VERSION
+ _inst=$INST/openexr-$OPENEXR_VERSION_SHORT
_inst_shortcut=$INST/openexr
}
@@ -1911,7 +1968,7 @@ compile_OPENEXR() {
_init_oiio() {
_src=$SRC/OpenImageIO-$OIIO_VERSION
_git=true
- _inst=$INST/oiio-$OIIO_VERSION
+ _inst=$INST/oiio-$OIIO_VERSION_SHORT
_inst_shortcut=$INST/oiio
}
@@ -2066,7 +2123,7 @@ _init_llvm() {
_src=$SRC/LLVM-$LLVM_VERSION
_src_clang=$SRC/CLANG-$LLVM_VERSION
_git=false
- _inst=$INST/llvm-$LLVM_VERSION
+ _inst=$INST/llvm-$LLVM_VERSION_SHORT
_inst_shortcut=$INST/llvm
}
@@ -2178,7 +2235,7 @@ compile_LLVM() {
_init_osl() {
_src=$SRC/OpenShadingLanguage-$OSL_VERSION
_git=true
- _inst=$INST/osl-$OSL_VERSION
+ _inst=$INST/osl-$OSL_VERSION_SHORT
_inst_shortcut=$INST/osl
}
@@ -2323,7 +2380,7 @@ compile_OSL() {
_init_osd() {
_src=$SRC/OpenSubdiv-$OSD_VERSION
_git=true
- _inst=$INST/osd-$OSD_VERSION
+ _inst=$INST/osd-$OSD_VERSION_SHORT
_inst_shortcut=$INST/osd
}
@@ -2537,7 +2594,7 @@ compile_BLOSC() {
_init_openvdb() {
_src=$SRC/openvdb-$OPENVDB_VERSION
_git=false
- _inst=$INST/openvdb-$OPENVDB_VERSION
+ _inst=$INST/openvdb-$OPENVDB_VERSION_SHORT
_inst_shortcut=$INST/openvdb
}
@@ -2655,7 +2712,7 @@ compile_OPENVDB() {
_init_alembic() {
_src=$SRC/alembic-$ALEMBIC_VERSION
_git=false
- _inst=$INST/alembic-$ALEMBIC_VERSION
+ _inst=$INST/alembic-$ALEMBIC_VERSION_SHORT
_inst_shortcut=$INST/alembic
}
@@ -2760,7 +2817,7 @@ compile_ALEMBIC() {
_init_usd() {
_src=$SRC/USD-$USD_VERSION
_git=false
- _inst=$INST/usd-$USD_VERSION
+ _inst=$INST/usd-$USD_VERSION_SHORT
_inst_shortcut=$INST/usd
}
@@ -2859,7 +2916,7 @@ compile_USD() {
_init_opencollada() {
_src=$SRC/OpenCOLLADA-$OPENCOLLADA_VERSION
_git=true
- _inst=$INST/opencollada-$OPENCOLLADA_VERSION
+ _inst=$INST/opencollada-$OPENCOLLADA_VERSION_SHORT
_inst_shortcut=$INST/opencollada
}
@@ -2965,7 +3022,7 @@ compile_OpenCOLLADA() {
_init_embree() {
_src=$SRC/embree-$EMBREE_VERSION
_git=true
- _inst=$INST/embree-$EMBREE_VERSION
+ _inst=$INST/embree-$EMBREE_VERSION_SHORT
_inst_shortcut=$INST/embree
}
@@ -3075,10 +3132,83 @@ compile_Embree() {
# ----------------------------------------------------------------------------
# Build OpenImageDenoise
+_init_ispc() {
+ _src=$SRC/ispc-v$ISPC_VERSION
+ _inst=$INST/ispc-v$ISPC_VERSION
+ _inst_shortcut=$INST/ispc
+}
+
+_update_deps_ispc() {
+ OIDN_FORCE_REBUILD=true
+ if [ "$_is_building" = true ]; then
+ OIDN_FORCE_BUILD=true
+ fi
+}
+
+clean_ispc() {
+ _init_ispc
+ if [ -d $_inst ]; then
+ _update_deps_ispc
+ fi
+ _clean
+}
+
+install_ISPC() {
+ # To be changed each time we make edits that would modify the compiled results!
+ ispc_magic=0
+ _init_ispc
+
+ # Clean install if needed!
+ magic_compile_check ispc-$ISPC_VERSION $ispc_magic
+ if [ $? -eq 1 ]; then
+ clean_ispc
+ fi
+
+ if [ ! -d $_inst ]; then
+ INFO "Installing Implicit SPMD Program Compiler v$ISPC_VERSION"
+ _is_building=true
+
+ # Rebuild dependencies as well!
+ _update_deps_ispc
+
+ prepare_opt
+
+ if [ ! -d $_src ]; then
+ mkdir -p $SRC
+ download ISPC_BINARY[@] "$_src.tar.gz"
+ INFO "Unpacking ISPC-v$ISPC_VERSION"
+ tar -C $SRC --transform "s,(.*/?)ispc-v$ISPC_VERSION-linux[^/]*(.*),\1ispc-v$ISPC_VERSION\2,x" \
+ -xf $_src.tar.gz
+ fi
+
+ mkdir -p $_inst
+ cp -r $_src/bin $_inst/bin
+
+ if [ -d $_inst ]; then
+ _create_inst_shortcut
+ else
+ ERROR "ISPC-v$ISPC_VERSION failed to install, exiting"
+ exit 1
+ fi
+
+ magic_compile_set ispc-$ISPC_VERSION $ispc_magic
+
+ cd $CWD
+ INFO "Done compiling ISPC-v$ISPC_VERSION!"
+ _is_building=false
+ else
+ INFO "Own ISPC-v$ISPC_VERSION is up to date, nothing to do!"
+ fi
+
+ _ispc_path_bin=$_inst/bin
+ run_ldconfig "ispc"
+}
+
+
_init_oidn() {
_src=$SRC/oidn-$OIDN_VERSION
_git=true
- _inst=$INST/oidn-$OIDN_VERSION
+ _inst=$INST/oidn-$OIDN_VERSION_SHORT
_inst_shortcut=$INST/oidn
}
@@ -3100,6 +3230,9 @@ compile_OIDN() {
return
fi
+ # Latest OIDN requires ISPC compiler tool...
+ install_ISPC
+
# To be changed each time we make edits that would modify the compiled results!
oidn_magic=9
_init_oidn
@@ -3152,6 +3285,7 @@ compile_OIDN() {
cmake_d="$cmake_d -D WITH_EXAMPLE=OFF"
cmake_d="$cmake_d -D WITH_TEST=OFF"
cmake_d="$cmake_d -D OIDN_STATIC_LIB=ON"
+ cmake_d="$cmake_d -D ISPC_DIR_HINT=$_ispc_path_bin"
if [ -d $INST/tbb ]; then
make_d="$make_d TBB_ROOT=$INST/tbb"
@@ -3187,7 +3321,7 @@ compile_OIDN() {
_init_ffmpeg() {
_src=$SRC/ffmpeg-$FFMPEG_VERSION
- _inst=$INST/ffmpeg-$FFMPEG_VERSION
+ _inst=$INST/ffmpeg-$FFMPEG_VERSION_SHORT
_inst_shortcut=$INST/ffmpeg
}
@@ -3316,7 +3450,7 @@ compile_FFmpeg() {
_init_xr_openxr_sdk() {
_src=$SRC/XR-OpenXR-SDK-$XR_OPENXR_VERSION
_git=true
- _inst=$INST/xr-openxr-sdk-$XR_OPENXR_VERSION
+ _inst=$INST/xr-openxr-sdk-$XR_OPENXR_VERSION_SHORT
_inst_shortcut=$INST/xr-openxr-sdk
}
@@ -3524,7 +3658,8 @@ install_DEB() {
libxcursor-dev libxi-dev wget libsqlite3-dev libxrandr-dev libxinerama-dev \
libbz2-dev libncurses5-dev libssl-dev liblzma-dev libreadline-dev \
libopenal-dev libglew-dev yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV \
- libsdl2-dev libfftw3-dev patch bzip2 libxml2-dev libtinyxml-dev libjemalloc-dev"
+ libsdl2-dev libfftw3-dev patch bzip2 libxml2-dev libtinyxml-dev libjemalloc-dev \
+ libgmp-dev"
# libglewmx-dev (broken in deb testing currently...)
VORBIS_USE=true
@@ -3554,13 +3689,18 @@ install_DEB() {
PRINT ""
CLANG_FORMAT="clang-format"
- check_package_version_ge_DEB $CLANG_FORMAT $CLANG_FORMAT_VERSION_MIN
+ check_package_version_ge_DEB $CLANG_FORMAT $CLANG_FORMAT_VERSION
if [ $? -eq 0 ]; then
_packages="$_packages $CLANG_FORMAT"
else
- PRINT ""
- WARNING "clang-format $CLANG_FORMAT_VERSION_MIN or higher not found, this is NOT needed to get Blender compiling..."
- PRINT ""
+ check_package_version_ge_DEB $CLANG_FORMAT $CLANG_FORMAT_VERSION_MIN
+ if [ $? -eq 0 ]; then
+ _packages="$_packages $CLANG_FORMAT"
+ else
+ PRINT ""
+ WARNING "clang-format $CLANG_FORMAT_VERSION_MIN or higher not found, this is NOT needed to get Blender compiling..."
+ PRINT ""
+ fi
fi
if [ "$WITH_JACK" = true ]; then
@@ -3675,7 +3815,7 @@ install_DEB() {
INFO "Forced Python/NumPy building, as requested..."
_do_compile_python=true
else
- check_package_version_ge_DEB python3-dev $PYTHON_VERSION_MIN
+ check_package_version_ge_lt_DEB python3-dev $PYTHON_VERSION_MIN $PYTHON_VERSION_MAX
if [ $? -eq 0 ]; then
PYTHON_VERSION_INSTALLED=$(echo `get_package_version_DEB python3-dev` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
@@ -3717,7 +3857,7 @@ install_DEB() {
INFO "Forced Boost building, as requested..."
compile_Boost
else
- check_package_version_ge_DEB libboost-dev $BOOST_VERSION_MIN
+ check_package_version_ge_lt_DEB libboost-dev $BOOST_VERSION_MIN $BOOST_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_DEB libboost-dev
@@ -3738,7 +3878,7 @@ install_DEB() {
INFO "Forced TBB building, as requested..."
compile_TBB
else
- check_package_version_ge_DEB libtbb-dev $TBB_VERSION_MIN
+ check_package_version_ge_lt_DEB libtbb-dev $TBB_VERSION_MIN $TBB_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_DEB libtbb-dev
clean_TBB
@@ -3755,14 +3895,13 @@ install_DEB() {
INFO "Forced OpenColorIO building, as requested..."
compile_OCIO
else
- # XXX Always force build of own OCIO, until linux distro guys update their package to default libyaml-cpp ver (0.5)!
- #check_package_version_ge_DEB libopencolorio-dev $OCIO_VERSION_MIN
- #if [ $? -eq 0 ]; then
- #install_packages_DEB libopencolorio-dev
- #clean_OCIO
- #else
+ check_package_version_ge_lt_DEB libopencolorio-dev $OCIO_VERSION_MIN $OCIO_VERSION_MAX
+ if [ $? -eq 0 ]; then
+ install_packages_DEB libopencolorio-dev
+ clean_OCIO
+ else
compile_OCIO
- #fi
+ fi
fi
@@ -3773,7 +3912,7 @@ install_DEB() {
INFO "Forced ILMBase/OpenEXR building, as requested..."
compile_OPENEXR
else
- check_package_version_ge_DEB libopenexr-dev $OPENEXR_VERSION_MIN
+ check_package_version_ge_lt_DEB libopenexr-dev $OPENEXR_VERSION_MIN $OPENEXR_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_DEB libopenexr-dev
OPENEXR_VERSION=`get_package_version_DEB libopenexr-dev`
@@ -3792,14 +3931,13 @@ install_DEB() {
INFO "Forced OpenImageIO building, as requested..."
compile_OIIO
else
- # XXX Debian Testing / Ubuntu 16.04 pulls in WAY too many deps (gtk2/opencv ?!) incl. OCIO build against libyaml-cpp0.3 so build for now...
- #check_package_version_ge_lt_DEB libopenimageio-dev $OIIO_VERSION_MIN $OIIO_VERSION_MAX
- #if [ $? -eq 0 -a "$_with_built_openexr" = false ]; then
- # install_packages_DEB libopenimageio-dev
- # clean_OIIO
- #else
+ check_package_version_ge_lt_DEB libopenimageio-dev $OIIO_VERSION_MIN $OIIO_VERSION_MAX
+ if [ $? -eq 0 -a "$_with_built_openexr" = false ]; then
+ install_packages_DEB libopenimageio-dev
+ clean_OIIO
+ else
compile_OIIO
- #fi
+ fi
fi
@@ -3813,11 +3951,12 @@ install_DEB() {
INFO "Forced LLVM building, as requested..."
_do_compile_llvm=true
else
- check_package_DEB clang-$LLVM_VERSION_MIN
+ check_package_version_ge_lt_DEB llvm-dev $LLVM_VERSION_MIN $LLVM_VERSION_MAX
if [ $? -eq 0 ]; then
- install_packages_DEB llvm-$LLVM_VERSION_MIN-dev clang-$LLVM_VERSION_MIN
+ install_packages_DEB llvm-dev clang
have_llvm=true
- LLVM_VERSION_FOUND=$LLVM_VERSION_MIN
+ LLVM_VERSION=`get_package_version_DEB llvm-dev`
+ LLVM_VERSION_FOUND=$LLVM_VERSION
clean_LLVM
else
_do_compile_llvm=true
@@ -3843,8 +3982,13 @@ install_DEB() {
INFO "Forced OpenShadingLanguage building, as requested..."
_do_compile_osl=true
else
- # No package currently!
- _do_compile_osl=true
+ check_package_version_ge_lt_DEB libopenshadinglanguage-dev $OSL_VERSION_MIN $OSL_VERSION_MAX
+ if [ $? -eq 0 ]; then
+ install_packages_DEB libopenshadinglanguage-dev
+ clean_OSL
+ else
+ _do_compile_osl=true
+ fi
fi
if [ "$_do_compile_osl" = true ]; then
@@ -3876,7 +4020,7 @@ install_DEB() {
INFO "Forced OpenVDB building, as requested..."
compile_OPENVDB
else
- check_package_version_ge_DEB libopenvdb-dev $OPENVDB_VERSION_MIN
+ check_package_version_ge_lt_DEB libopenvdb-dev $OPENVDB_VERSION_MIN $OPENVDB_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_DEB libopenvdb-dev libblosc-dev
clean_OPENVDB
@@ -3937,8 +4081,14 @@ install_DEB() {
INFO "Forced Embree building, as requested..."
_do_compile_embree=true
else
- # No package currently!
- _do_compile_embree=true
+ # There is a package, but it does not provide everything that Blender needs...
+ #~ check_package_version_ge_lt_DEB libembree-dev $EMBREE_VERSION_MIN $EMBREE_VERSION_MAX
+ #~ if [ $? -eq 0 ]; then
+ #~ install_packages_DEB libembree-dev
+ #~ clean_Embree
+ #~ else
+ _do_compile_embree=true
+ #~ fi
fi
if [ "$_do_compile_embree" = true ]; then
@@ -3974,7 +4124,7 @@ install_DEB() {
# XXX Debian Testing / Ubuntu 16.04 finally includes FFmpeg, so check as usual
check_package_DEB ffmpeg
if [ $? -eq 0 ]; then
- check_package_version_ge_DEB ffmpeg $FFMPEG_VERSION_MIN
+ check_package_version_ge_lt_DEB ffmpeg $FFMPEG_VERSION_MIN $FFMPEG_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_DEB libavdevice-dev
clean_FFmpeg
@@ -4175,7 +4325,7 @@ install_RPM() {
libX11-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel \
wget ncurses-devel readline-devel $OPENJPEG_DEV openal-soft-devel \
glew-devel yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV patch \
- libxml2-devel yaml-cpp-devel tinyxml-devel jemalloc-devel"
+ libxml2-devel yaml-cpp-devel tinyxml-devel jemalloc-devel gmp-devel"
OPENJPEG_USE=true
VORBIS_USE=true
@@ -4298,7 +4448,7 @@ install_RPM() {
INFO "Forced Python/NumPy building, as requested..."
_do_compile_python=true
else
- check_package_version_ge_RPM python3-devel $PYTHON_VERSION_MIN
+ check_package_version_ge_lt_RPM python3-devel $PYTHON_VERSION_MIN $PYTHON_VERSION_MAX
if [ $? -eq 0 ]; then
PYTHON_VERSION_INSTALLED=$(echo `get_package_version_RPM python3-devel` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
@@ -4308,7 +4458,7 @@ install_RPM() {
if [ "$NUMPY_SKIP" = true ]; then
WARNING "Skipping NumPy installation, as requested..."
else
- check_package_version_ge_RPM python3-numpy $NUMPY_VERSION_MIN
+ check_package_version_ge_lt_RPM python3-numpy $NUMPY_VERSION_MIN $NUMPY_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_RPM python3-numpy
else
@@ -4341,7 +4491,7 @@ install_RPM() {
INFO "Forced Boost building, as requested..."
_do_compile_boost=true
else
- check_package_version_ge_RPM boost-devel $BOOST_VERSION_MIN
+ check_package_version_ge_lt_RPM boost-devel $BOOST_VERSION_MIN $BOOST_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_RPM boost-devel
clean_Boost
@@ -4368,7 +4518,7 @@ install_RPM() {
INFO "Forced TBB building, as requested..."
compile_TBB
else
- check_package_version_ge_RPM tbb-devel $TBB_VERSION_MIN
+ check_package_version_ge_lt_RPM tbb-devel $TBB_VERSION_MIN $TBB_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_RPM tbb-devel
clean_TBB
@@ -4386,7 +4536,7 @@ install_RPM() {
compile_OCIO
else
if [ "$RPM" = "SUSE" ]; then
- check_package_version_ge_RPM OpenColorIO-devel $OCIO_VERSION_MIN
+ check_package_version_ge_lt_RPM OpenColorIO-devel $OCIO_VERSION_MIN $OCIO_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_RPM OpenColorIO-devel
clean_OCIO
@@ -4406,7 +4556,7 @@ install_RPM() {
INFO "Forced ILMBase/OpenEXR building, as requested..."
compile_OPENEXR
else
- check_package_version_ge_RPM openexr-devel $OPENEXR_VERSION_MIN
+ check_package_version_ge_lt_RPM openexr-devel $OPENEXR_VERSION_MIN $OPENEXR_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_RPM openexr-devel
OPENEXR_VERSION=`get_package_version_RPM openexr-devel`
@@ -4424,7 +4574,6 @@ install_RPM() {
INFO "Forced OpenImageIO building, as requested..."
compile_OIIO
else
- # XXX RPM distros pulls in too much and depends on old libs, so better to build for now...
#check_package_version_ge_lt_RPM OpenImageIO-devel $OIIO_VERSION_MIN $OIIO_VERSION_MAX
#if [ $? -eq 0 -a $_with_built_openexr == false ]; then
# install_packages_RPM OpenImageIO-devel
@@ -4450,10 +4599,11 @@ install_RPM() {
else
CLANG_DEV="clang-devel"
fi
- check_package_version_match_RPM $CLANG_DEV $LLVM_VERSION
+ check_package_version_ge_lt_RPM llvm-devel $LLVM_VERSION_MIN $LLVM_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_RPM llvm-devel $CLANG_DEV
have_llvm=true
+ LLVM_VERSION=`get_package_version_RPM llvm-devel`
LLVM_VERSION_FOUND=$LLVM_VERSION
clean_LLVM
else
@@ -4480,8 +4630,18 @@ install_RPM() {
INFO "Forced OpenShadingLanguage building, as requested..."
_do_compile_osl=true
else
- # No package currently!
- _do_compile_osl=true
+ if [ "$RPM" = "SUSE" ]; then
+ OSL_DEV="OpenShadingLanguage-devel"
+ else
+ OSL_DEV="openshadinglanguage-devel"
+ fi
+ check_package_version_ge_lt_RPM $OSL_DEV $OSL_VERSION_MIN $OSL_VERSION_MAX
+ if [ $? -eq 0 ]; then
+ install_packages_RPM $OSL_DEV
+ clean_OSL
+ else
+ _do_compile_osl=true
+ fi
fi
if [ "$_do_compile_osl" = true ]; then
@@ -4569,8 +4729,14 @@ install_RPM() {
INFO "Forced Embree building, as requested..."
_do_compile_embree=true
else
- # No package...
- _do_compile_embree=true
+ # There is a package, but it does not provide everything that Blender needs...
+ #~ check_package_version_ge_lt_RPM embree-devel $EMBREE_VERSION_MIN $EMBREE_VERSION_MAX
+ #~ if [ $? -eq 0 ]; then
+ #~ install_packages_RPM embree-devel
+ #~ clean_Embree
+ #~ else
+ _do_compile_embree=true
+ #~ fi
fi
if [ "$_do_compile_embree" = true ]; then
@@ -4603,7 +4769,7 @@ install_RPM() {
INFO "Forced FFMpeg building, as requested..."
compile_FFmpeg
else
- check_package_version_ge_RPM ffmpeg-devel $FFMPEG_VERSION_MIN
+ check_package_version_ge_lt_RPM ffmpeg-devel $FFMPEG_VERSION_MIN $FFMPEG_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_RPM ffmpeg ffmpeg-devel
clean_FFmpeg
@@ -4735,7 +4901,7 @@ install_ARCH() {
_packages="$BASE_DEVEL git cmake \
libxi libxcursor libxrandr libxinerama glew libpng libtiff wget openal \
$OPENJPEG_DEV $VORBIS_DEV $OGG_DEV $THEORA_DEV yasm sdl2 fftw \
- libxml2 yaml-cpp tinyxml python-requests jemalloc"
+ libxml2 yaml-cpp tinyxml python-requests jemalloc gmp"
OPENJPEG_USE=true
VORBIS_USE=true
@@ -4823,7 +4989,7 @@ install_ARCH() {
INFO "Forced Python/NumPy building, as requested..."
_do_compile_python=true
else
- check_package_version_ge_ARCH python $PYTHON_VERSION_MIN
+ check_package_version_ge_lt_ARCH python $PYTHON_VERSION_MIN $PYTHON_VERSION_MAX
if [ $? -eq 0 ]; then
PYTHON_VERSION_INSTALLED=$(echo `get_package_version_ARCH python` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
@@ -4833,7 +4999,7 @@ install_ARCH() {
if [ "$NUMPY_SKIP" = true ]; then
WARNING "Skipping NumPy installation, as requested..."
else
- check_package_version_ge_ARCH python-numpy $NUMPY_VERSION_MIN
+ check_package_version_ge_ARCH python-numpy $NUMPY_VERSION_MIN $NUMPY_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_ARCH python-numpy
else
@@ -4865,7 +5031,7 @@ install_ARCH() {
INFO "Forced Boost building, as requested..."
compile_Boost
else
- check_package_version_ge_ARCH boost $BOOST_VERSION_MIN
+ check_package_version_ge_lt_ARCH boost $BOOST_VERSION_MIN $BOOST_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_ARCH boost
clean_Boost
@@ -4882,7 +5048,7 @@ install_ARCH() {
INFO "Forced TBB building, as requested..."
compile_TBB
else
- check_package_version_ge_ARCH intel-tbb $TBB_VERSION_MIN
+ check_package_version_ge_lt_ARCH intel-tbb $TBB_VERSION_MIN $TBB_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_ARCH intel-tbb
clean_TBB
@@ -4899,7 +5065,7 @@ install_ARCH() {
INFO "Forced OpenColorIO building, as requested..."
compile_OCIO
else
- check_package_version_ge_ARCH opencolorio $OCIO_VERSION_MIN
+ check_package_version_ge_lt_ARCH opencolorio $OCIO_VERSION_MIN $OCIO_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_ARCH opencolorio
clean_OCIO
@@ -4916,7 +5082,7 @@ install_ARCH() {
INFO "Forced ILMBase/OpenEXR building, as requested..."
compile_OPENEXR
else
- check_package_version_ge_ARCH openexr $OPENEXR_VERSION_MIN
+ check_package_version_ge_lt_ARCH openexr $OPENEXR_VERSION_MIN $OPENEXR_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_ARCH openexr
OPENEXR_VERSION=`get_package_version_ARCH openexr`
@@ -4955,7 +5121,7 @@ install_ARCH() {
INFO "Forced LLVM building, as requested..."
_do_compile_llvm=true
else
- check_package_version_match_ARCH llvm $LLVM_VERSION_MIN
+ check_package_version_ge_lt_ARCH llvm $LLVM_VERSION_MIN $LLVM_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_ARCH llvm clang
have_llvm=true
@@ -4986,14 +5152,13 @@ install_ARCH() {
INFO "Forced OpenShadingLanguage building, as requested..."
_do_compile_osl=true
else
- # XXX Compile for now due to requirement of LLVM 3.4 ...
- #check_package_version_ge_ARCH openshadinglanguage $OSL_VERSION_MIN
- #if [ $? -eq 0 ]; then
- # install_packages_ARCH openshadinglanguage
- # clean_OSL
- #else
+ check_package_version_ge_lt_ARCH openshadinglanguage $OSL_VERSION_MIN $OSL_VERSION_MAX
+ if [ $? -eq 0 ]; then
+ install_packages_ARCH openshadinglanguage
+ clean_OSL
+ else
_do_compile_osl=true
- #fi
+ fi
fi
if [ "$_do_compile_osl" = true ]; then
@@ -5013,7 +5178,7 @@ install_ARCH() {
INFO "Forced OpenSubdiv building, as requested..."
compile_OSD
else
- check_package_version_ge_ARCH opensubdiv $OSD_VERSION_MIN
+ check_package_version_ge_lt_ARCH opensubdiv $OSD_VERSION_MIN $OSD_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_ARCH opensubdiv
clean_OSD
@@ -5030,7 +5195,7 @@ install_ARCH() {
INFO "Forced OpenVDB building, as requested..."
compile_OPENVDB
else
- check_package_version_ge_ARCH openvdb $OPENVDB_VERSION_MIN
+ check_package_version_ge_lt_ARCH openvdb $OPENVDB_VERSION_MIN $OPENVDB_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_ARCH openvdb
clean_OPENVDB
@@ -5095,13 +5260,14 @@ install_ARCH() {
INFO "Forced Embree building, as requested..."
_do_compile_embree=true
else
- check_package_ARCH embree
- if [ $? -eq 0 ]; then
- install_packages_ARCH embree
- clean_Embree
- else
+ # There is a package, but it does not provide everything that Blender needs...
+ #~ check_package_version_ge_lt_ARCH embree $EMBREE_VERSION_MIN $EMBREE_VERSION_MAX
+ #~ if [ $? -eq 0 ]; then
+ #~ install_packages_ARCH embree
+ #~ clean_Embree
+ #~ else
_do_compile_embree=true
- fi
+ #~ fi
fi
if [ "$_do_compile_embree" = true ]; then
@@ -5134,7 +5300,7 @@ install_ARCH() {
INFO "Forced FFMpeg building, as requested..."
compile_FFmpeg
else
- check_package_version_ge_ARCH ffmpeg $FFMPEG_VERSION_MIN
+ check_package_version_ge_lt_ARCH ffmpeg $FFMPEG_VERSION_MIN $FFMPEG_VERSION_MAX
if [ $? -eq 0 ]; then
install_packages_ARCH ffmpeg
clean_FFmpeg
@@ -5412,6 +5578,7 @@ print_info() {
_buildargs="-U *SNDFILE* -U PYTHON* -U *BOOST* -U *Boost* -U *TBB*"
_buildargs="$_buildargs -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CYCLES*"
_buildargs="$_buildargs -U *OPENSUBDIV* -U *OPENVDB* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC* -U *USD*"
+ _buildargs="$_buildargs -U *EMBREE* -U *OPENIMAGEDENOISE* -U *OPENXR*"
_1="-D WITH_CODEC_SNDFILE=ON"
PRINT " $_1"
diff --git a/build_files/build_environment/patches/cmakelists_gmpxx.txt b/build_files/build_environment/patches/cmakelists_gmpxx.txt
new file mode 100644
index 00000000000..5aa6c404035
--- /dev/null
+++ b/build_files/build_environment/patches/cmakelists_gmpxx.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.1)
+project(libgmpxx)
+
+include_directories(. cxx ${GMP_INCLUDE_DIR})
+add_definitions(-D__GMP_WITHIN_GMPXX)
+add_library(libgmpxx SHARED
+ cxx/dummy.cc
+ cxx/isfuns.cc
+ cxx/ismpf.cc
+ cxx/ismpq.cc
+ cxx/ismpz.cc
+ cxx/ismpznw.cc
+ cxx/limits.cc
+ cxx/osdoprnti.cc
+ cxx/osfuns.cc
+ cxx/osmpf.cc
+ cxx/osmpq.cc
+ cxx/osmpz.cc
+)
+
+target_link_libraries(libgmpxx ${GMP_LIBRARY})
+install(TARGETS libgmpxx DESTINATION lib)
diff --git a/build_files/build_environment/patches/config_gmpxx.h b/build_files/build_environment/patches/config_gmpxx.h
new file mode 100644
index 00000000000..842d6d5d240
--- /dev/null
+++ b/build_files/build_environment/patches/config_gmpxx.h
@@ -0,0 +1,668 @@
+/* config.h. Generated from config.in by configure. */
+/* config.in. Generated from configure.ac by autoheader. */
+
+/*
+
+Copyright 1996-2020 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of either:
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+or
+
+ * 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.
+
+or both in parallel, as here.
+
+The GNU MP Library 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 copies of the GNU General Public License and the
+GNU Lesser General Public License along with the GNU MP Library. If not,
+see https://www.gnu.org/licenses/.
+*/
+
+/* Define if building universal (internal helper macro) */
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
+
+/* The gmp-mparam.h file (a string) the tune program should suggest updating.
+ */
+#define GMP_MPARAM_H_SUGGEST "./mpn/x86_64/coreisbr/gmp-mparam.h"
+
+/* Define to 1 if you have the `alarm' function. */
+#define HAVE_ALARM 1
+
+/* Define to 1 if alloca() works (via gmp-impl.h). */
+#define HAVE_ALLOCA 1
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+ */
+/* #undef HAVE_ALLOCA_H */
+
+/* Define to 1 if the compiler accepts gcc style __attribute__ ((const)) */
+//#define HAVE_ATTRIBUTE_CONST 1
+
+/* Define to 1 if the compiler accepts gcc style __attribute__ ((malloc)) */
+//#define HAVE_ATTRIBUTE_MALLOC 1
+
+/* Define to 1 if the compiler accepts gcc style __attribute__ ((mode (XX)))
+ */
+//#define HAVE_ATTRIBUTE_MODE 1
+
+/* Define to 1 if the compiler accepts gcc style __attribute__ ((noreturn)) */
+//#define HAVE_ATTRIBUTE_NORETURN 1
+
+/* Define to 1 if you have the `attr_get' function. */
+/* #undef HAVE_ATTR_GET */
+
+/* Define to 1 if tests/libtests has calling conventions checking for the CPU
+ */
+/* #undef HAVE_CALLING_CONVENTIONS */
+
+/* Define to 1 if you have the `clock' function. */
+#define HAVE_CLOCK 1
+
+/* Define to 1 if you have the `clock_gettime' function */
+/* #undef HAVE_CLOCK_GETTIME */
+
+/* Define to 1 if you have the `cputime' function. */
+/* #undef HAVE_CPUTIME */
+
+/* Define to 1 if you have the declaration of `fgetc', and to 0 if you don't.
+ */
+#define HAVE_DECL_FGETC 1
+
+/* Define to 1 if you have the declaration of `fscanf', and to 0 if you don't.
+ */
+#define HAVE_DECL_FSCANF 1
+
+/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't.
+ */
+#define HAVE_DECL_OPTARG 1
+
+/* Define to 1 if you have the declaration of `sys_errlist', and to 0 if you
+ don't. */
+#define HAVE_DECL_SYS_ERRLIST 0
+
+/* Define to 1 if you have the declaration of `sys_nerr', and to 0 if you
+ don't. */
+#define HAVE_DECL_SYS_NERR 0
+
+/* Define to 1 if you have the declaration of `ungetc', and to 0 if you don't.
+ */
+#define HAVE_DECL_UNGETC 1
+
+/* Define to 1 if you have the declaration of `vfprintf', and to 0 if you
+ don't. */
+#define HAVE_DECL_VFPRINTF 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+/* #undef HAVE_DLFCN_H */
+
+/* Define one of the following to 1 for the format of a `double'.
+ If your format is not among these choices, or you don't know what it is,
+ then leave all undefined.
+ IEEE_LITTLE_SWAPPED means little endian, but with the two 4-byte halves
+ swapped, as used by ARM CPUs in little endian mode. */
+/* #undef HAVE_DOUBLE_IEEE_BIG_ENDIAN */
+#define HAVE_DOUBLE_IEEE_LITTLE_ENDIAN 1
+/* #undef HAVE_DOUBLE_IEEE_LITTLE_SWAPPED */
+/* #undef HAVE_DOUBLE_VAX_D */
+/* #undef HAVE_DOUBLE_VAX_G */
+/* #undef HAVE_DOUBLE_CRAY_CFP */
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the <float.h> header file. */
+#define HAVE_FLOAT_H 1
+
+/* Define to 1 if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define to 1 if you have the `getrusage' function. */
+/* #undef HAVE_GETRUSAGE */
+
+/* Define to 1 if you have the `getsysinfo' function. */
+/* #undef HAVE_GETSYSINFO */
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if the compiler accepts gcc style __attribute__ ((visibility))
+ and __attribute__ ((alias)) */
+#define HAVE_HIDDEN_ALIAS 1
+
+/* Define one of these to 1 for the host CPU family.
+ If your CPU is not in any of these families, leave all undefined.
+ For an AMD64 chip, define "x86" in ABI=32, but not in ABI=64. */
+/* #undef HAVE_HOST_CPU_FAMILY_alpha */
+/* #undef HAVE_HOST_CPU_FAMILY_m68k */
+/* #undef HAVE_HOST_CPU_FAMILY_power */
+/* #undef HAVE_HOST_CPU_FAMILY_powerpc */
+/* #undef HAVE_HOST_CPU_FAMILY_x86 */
+#define HAVE_HOST_CPU_FAMILY_x86_64 1
+
+/* Define one of the following to 1 for the host CPU, as per the output of
+ ./config.guess. If your CPU is not listed here, leave all undefined. */
+/* #undef HAVE_HOST_CPU_alphaev67 */
+/* #undef HAVE_HOST_CPU_alphaev68 */
+/* #undef HAVE_HOST_CPU_alphaev7 */
+/* #undef HAVE_HOST_CPU_m68020 */
+/* #undef HAVE_HOST_CPU_m68030 */
+/* #undef HAVE_HOST_CPU_m68040 */
+/* #undef HAVE_HOST_CPU_m68060 */
+/* #undef HAVE_HOST_CPU_m68360 */
+/* #undef HAVE_HOST_CPU_powerpc604 */
+/* #undef HAVE_HOST_CPU_powerpc604e */
+/* #undef HAVE_HOST_CPU_powerpc750 */
+/* #undef HAVE_HOST_CPU_powerpc7400 */
+/* #undef HAVE_HOST_CPU_supersparc */
+/* #undef HAVE_HOST_CPU_i386 */
+/* #undef HAVE_HOST_CPU_i586 */
+/* #undef HAVE_HOST_CPU_i686 */
+/* #undef HAVE_HOST_CPU_pentium */
+/* #undef HAVE_HOST_CPU_pentiummmx */
+/* #undef HAVE_HOST_CPU_pentiumpro */
+/* #undef HAVE_HOST_CPU_pentium2 */
+/* #undef HAVE_HOST_CPU_pentium3 */
+/* #undef HAVE_HOST_CPU_pentium4 */
+/* #undef HAVE_HOST_CPU_core2 */
+/* #undef HAVE_HOST_CPU_nehalem */
+/* #undef HAVE_HOST_CPU_westmere */
+/* #undef HAVE_HOST_CPU_sandybridge */
+#define HAVE_HOST_CPU_ivybridge 1
+/* #undef HAVE_HOST_CPU_haswell */
+/* #undef HAVE_HOST_CPU_broadwell */
+/* #undef HAVE_HOST_CPU_skylake */
+/* #undef HAVE_HOST_CPU_silvermont */
+/* #undef HAVE_HOST_CPU_goldmont */
+/* #undef HAVE_HOST_CPU_k8 */
+/* #undef HAVE_HOST_CPU_k10 */
+/* #undef HAVE_HOST_CPU_bulldozer */
+/* #undef HAVE_HOST_CPU_piledriver */
+/* #undef HAVE_HOST_CPU_steamroller */
+/* #undef HAVE_HOST_CPU_excavator */
+/* #undef HAVE_HOST_CPU_zen */
+/* #undef HAVE_HOST_CPU_bobcat */
+/* #undef HAVE_HOST_CPU_jaguar */
+/* #undef HAVE_HOST_CPU_s390_z900 */
+/* #undef HAVE_HOST_CPU_s390_z990 */
+/* #undef HAVE_HOST_CPU_s390_z9 */
+/* #undef HAVE_HOST_CPU_s390_z10 */
+/* #undef HAVE_HOST_CPU_s390_z196 */
+
+/* Define to 1 iff we have a s390 with 64-bit registers. */
+/* #undef HAVE_HOST_CPU_s390_zarch */
+
+/* Define to 1 if the system has the type `intmax_t'. */
+#define HAVE_INTMAX_T 1
+
+/* Define to 1 if the system has the type `intptr_t'. */
+#define HAVE_INTPTR_T 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <invent.h> header file. */
+/* #undef HAVE_INVENT_H */
+
+/* Define to 1 if you have the <langinfo.h> header file. */
+/* #undef HAVE_LANGINFO_H */
+
+/* Define one of these to 1 for the endianness of `mp_limb_t'.
+ If the endianness is not a simple big or little, or you don't know what
+ it is, then leave both undefined. */
+/* #undef HAVE_LIMB_BIG_ENDIAN */
+#define HAVE_LIMB_LITTLE_ENDIAN 1
+
+/* Define to 1 if you have the `localeconv' function. */
+#define HAVE_LOCALECONV 1
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if the system has the type `long double'. */
+#define HAVE_LONG_DOUBLE 1
+
+/* Define to 1 if the system has the type `long long'. */
+#define HAVE_LONG_LONG 1
+
+/* Define to 1 if you have the <machine/hal_sysinfo.h> header file. */
+/* #undef HAVE_MACHINE_HAL_SYSINFO_H */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the `mmap' function. */
+/* #undef HAVE_MMAP */
+
+/* Define to 1 if you have the `mprotect' function. */
+#define HAVE_MPROTECT 1
+
+/* Define to 1 each of the following for which a native (ie. CPU specific)
+ implementation of the corresponding routine exists. */
+#define HAVE_NATIVE_mpn_add_n 1
+/* #undef HAVE_NATIVE_mpn_add_n_sub_n */
+#define HAVE_NATIVE_mpn_add_nc 1
+/* #undef HAVE_NATIVE_mpn_addaddmul_1msb0 */
+#define HAVE_NATIVE_mpn_addlsh1_n 1
+#define HAVE_NATIVE_mpn_addlsh2_n 1
+#define HAVE_NATIVE_mpn_addlsh_n 1
+#define HAVE_NATIVE_mpn_addlsh1_nc 1
+#define HAVE_NATIVE_mpn_addlsh2_nc 1
+#define HAVE_NATIVE_mpn_addlsh_nc 1
+/* #undef HAVE_NATIVE_mpn_addlsh1_n_ip1 */
+/* #undef HAVE_NATIVE_mpn_addlsh2_n_ip1 */
+/* #undef HAVE_NATIVE_mpn_addlsh_n_ip1 */
+/* #undef HAVE_NATIVE_mpn_addlsh1_nc_ip1 */
+/* #undef HAVE_NATIVE_mpn_addlsh2_nc_ip1 */
+/* #undef HAVE_NATIVE_mpn_addlsh_nc_ip1 */
+/* #undef HAVE_NATIVE_mpn_addlsh1_n_ip2 */
+/* #undef HAVE_NATIVE_mpn_addlsh2_n_ip2 */
+/* #undef HAVE_NATIVE_mpn_addlsh_n_ip2 */
+/* #undef HAVE_NATIVE_mpn_addlsh1_nc_ip2 */
+/* #undef HAVE_NATIVE_mpn_addlsh2_nc_ip2 */
+/* #undef HAVE_NATIVE_mpn_addlsh_nc_ip2 */
+/* #undef HAVE_NATIVE_mpn_addmul_1c */
+#define HAVE_NATIVE_mpn_addmul_2 1
+/* #undef HAVE_NATIVE_mpn_addmul_3 */
+/* #undef HAVE_NATIVE_mpn_addmul_4 */
+/* #undef HAVE_NATIVE_mpn_addmul_5 */
+/* #undef HAVE_NATIVE_mpn_addmul_6 */
+/* #undef HAVE_NATIVE_mpn_addmul_7 */
+/* #undef HAVE_NATIVE_mpn_addmul_8 */
+/* #undef HAVE_NATIVE_mpn_addmul_2s */
+#define HAVE_NATIVE_mpn_and_n 1
+#define HAVE_NATIVE_mpn_andn_n 1
+#define HAVE_NATIVE_mpn_bdiv_dbm1c 1
+#define HAVE_NATIVE_mpn_bdiv_q_1 1
+#define HAVE_NATIVE_mpn_pi1_bdiv_q_1 1
+#define HAVE_NATIVE_mpn_cnd_add_n 1
+#define HAVE_NATIVE_mpn_cnd_sub_n 1
+#define HAVE_NATIVE_mpn_com 1
+#define HAVE_NATIVE_mpn_copyd 1
+#define HAVE_NATIVE_mpn_copyi 1
+/* #undef HAVE_NATIVE_mpn_div_qr_1n_pi1 */
+/* #undef HAVE_NATIVE_mpn_div_qr_2 */
+#define HAVE_NATIVE_mpn_divexact_1 1
+/* #undef HAVE_NATIVE_mpn_divexact_by3c */
+#define HAVE_NATIVE_mpn_divrem_1 1
+/* #undef HAVE_NATIVE_mpn_divrem_1c */
+#define HAVE_NATIVE_mpn_divrem_2 1
+/* #undef HAVE_NATIVE_mpn_gcd_1 */
+#define HAVE_NATIVE_mpn_gcd_11 1
+/* #undef HAVE_NATIVE_mpn_gcd_22 */
+#define HAVE_NATIVE_mpn_hamdist 1
+#define HAVE_NATIVE_mpn_invert_limb 1
+#define HAVE_NATIVE_mpn_ior_n 1
+#define HAVE_NATIVE_mpn_iorn_n 1
+#define HAVE_NATIVE_mpn_lshift 1
+#define HAVE_NATIVE_mpn_lshiftc 1
+/* #undef HAVE_NATIVE_mpn_lshsub_n */
+/* #undef HAVE_NATIVE_mpn_mod_1 */
+#define HAVE_NATIVE_mpn_mod_1_1p 1
+/* #undef HAVE_NATIVE_mpn_mod_1c */
+#define HAVE_NATIVE_mpn_mod_1s_2p 1
+#define HAVE_NATIVE_mpn_mod_1s_4p 1
+#define HAVE_NATIVE_mpn_mod_34lsub1 1
+#define HAVE_NATIVE_mpn_modexact_1_odd 1
+#define HAVE_NATIVE_mpn_modexact_1c_odd 1
+#define HAVE_NATIVE_mpn_mul_1 1
+#define HAVE_NATIVE_mpn_mul_1c 1
+#define HAVE_NATIVE_mpn_mul_2 1
+/* #undef HAVE_NATIVE_mpn_mul_3 */
+/* #undef HAVE_NATIVE_mpn_mul_4 */
+/* #undef HAVE_NATIVE_mpn_mul_5 */
+/* #undef HAVE_NATIVE_mpn_mul_6 */
+#define HAVE_NATIVE_mpn_mul_basecase 1
+#define HAVE_NATIVE_mpn_mullo_basecase 1
+#define HAVE_NATIVE_mpn_nand_n 1
+#define HAVE_NATIVE_mpn_nior_n 1
+#define HAVE_NATIVE_mpn_popcount 1
+#define HAVE_NATIVE_mpn_preinv_divrem_1 1
+/* #undef HAVE_NATIVE_mpn_preinv_mod_1 */
+#define HAVE_NATIVE_mpn_redc_1 1
+/* #undef HAVE_NATIVE_mpn_redc_2 */
+#define HAVE_NATIVE_mpn_rsblsh1_n 1
+#define HAVE_NATIVE_mpn_rsblsh2_n 1
+#define HAVE_NATIVE_mpn_rsblsh_n 1
+#define HAVE_NATIVE_mpn_rsblsh1_nc 1
+/* #undef HAVE_NATIVE_mpn_rsblsh2_nc */
+/* #undef HAVE_NATIVE_mpn_rsblsh_nc */
+#define HAVE_NATIVE_mpn_rsh1add_n 1
+#define HAVE_NATIVE_mpn_rsh1add_nc 1
+#define HAVE_NATIVE_mpn_rsh1sub_n 1
+#define HAVE_NATIVE_mpn_rsh1sub_nc 1
+#define HAVE_NATIVE_mpn_rshift 1
+/* #undef HAVE_NATIVE_mpn_sbpi1_bdiv_r */
+#define HAVE_NATIVE_mpn_sqr_basecase 1
+/* #undef HAVE_NATIVE_mpn_sqr_diagonal */
+#define HAVE_NATIVE_mpn_sqr_diag_addlsh1 1
+#define HAVE_NATIVE_mpn_sub_n 1
+#define HAVE_NATIVE_mpn_sub_nc 1
+#define HAVE_NATIVE_mpn_sublsh1_n 1
+#define HAVE_NATIVE_mpn_sublsh2_n 1
+/* #undef HAVE_NATIVE_mpn_sublsh_n */
+/* #undef HAVE_NATIVE_mpn_sublsh1_nc */
+/* #undef HAVE_NATIVE_mpn_sublsh2_nc */
+/* #undef HAVE_NATIVE_mpn_sublsh_nc */
+/* #undef HAVE_NATIVE_mpn_sublsh1_n_ip1 */
+/* #undef HAVE_NATIVE_mpn_sublsh2_n_ip1 */
+/* #undef HAVE_NATIVE_mpn_sublsh_n_ip1 */
+/* #undef HAVE_NATIVE_mpn_sublsh1_nc_ip1 */
+/* #undef HAVE_NATIVE_mpn_sublsh2_nc_ip1 */
+/* #undef HAVE_NATIVE_mpn_sublsh_nc_ip1 */
+/* #undef HAVE_NATIVE_mpn_submul_1c */
+/* #undef HAVE_NATIVE_mpn_tabselect */
+/* #undef HAVE_NATIVE_mpn_udiv_qrnnd */
+/* #undef HAVE_NATIVE_mpn_udiv_qrnnd_r */
+/* #undef HAVE_NATIVE_mpn_umul_ppmm */
+/* #undef HAVE_NATIVE_mpn_umul_ppmm_r */
+#define HAVE_NATIVE_mpn_xor_n 1
+#define HAVE_NATIVE_mpn_xnor_n 1
+
+/* Define to 1 if you have the `nl_langinfo' function. */
+/* #undef HAVE_NL_LANGINFO */
+
+/* Define to 1 if you have the <nl_types.h> header file. */
+/* #undef HAVE_NL_TYPES_H */
+
+/* Define to 1 if you have the `obstack_vprintf' function. */
+/* #undef HAVE_OBSTACK_VPRINTF */
+
+/* Define to 1 if you have the `popen' function. */
+#define HAVE_POPEN 1
+
+/* Define to 1 if you have the `processor_info' function. */
+/* #undef HAVE_PROCESSOR_INFO */
+
+/* Define to 1 if <sys/pstat.h> `struct pst_processor' exists and contains
+ `psp_iticksperclktick'. */
+/* #undef HAVE_PSP_ITICKSPERCLKTICK */
+
+/* Define to 1 if you have the `pstat_getprocessor' function. */
+/* #undef HAVE_PSTAT_GETPROCESSOR */
+
+/* Define to 1 if the system has the type `ptrdiff_t'. */
+#define HAVE_PTRDIFF_T 1
+
+/* Define to 1 if the system has the type `quad_t'. */
+/* #undef HAVE_QUAD_T */
+
+/* Define to 1 if you have the `raise' function. */
+#define HAVE_RAISE 1
+
+/* Define to 1 if you have the `read_real_time' function. */
+/* #undef HAVE_READ_REAL_TIME */
+
+/* Define to 1 if you have the `sigaction' function. */
+/* #undef HAVE_SIGACTION */
+
+/* Define to 1 if you have the `sigaltstack' function. */
+/* #undef HAVE_SIGALTSTACK */
+
+/* Define to 1 if you have the `sigstack' function. */
+/* #undef HAVE_SIGSTACK */
+
+/* Tune directory speed_cyclecounter, undef=none, 1=32bits, 2=64bits) */
+#define HAVE_SPEED_CYCLECOUNTER 2
+
+/* Define to 1 if you have the <sstream> header file. */
+#define HAVE_SSTREAM 1
+
+/* Define to 1 if the system has the type `stack_t'. */
+/* #undef HAVE_STACK_T */
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if the system has the type `std::locale'. */
+#define HAVE_STD__LOCALE 1
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strnlen' function. */
+#define HAVE_STRNLEN 1
+
+/* Define to 1 if you have the `strtol' function. */
+#define HAVE_STRTOL 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* Define to 1 if you have the `sysconf' function. */
+/* #undef HAVE_SYSCONF */
+
+/* Define to 1 if you have the `sysctl' function. */
+/* #undef HAVE_SYSCTL */
+
+/* Define to 1 if you have the `sysctlbyname' function. */
+/* #undef HAVE_SYSCTLBYNAME */
+
+/* Define to 1 if you have the `syssgi' function. */
+/* #undef HAVE_SYSSGI */
+
+/* Define to 1 if you have the <sys/attributes.h> header file. */
+/* #undef HAVE_SYS_ATTRIBUTES_H */
+
+/* Define to 1 if you have the <sys/iograph.h> header file. */
+/* #undef HAVE_SYS_IOGRAPH_H */
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+/* #undef HAVE_SYS_MMAN_H */
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/processor.h> header file. */
+/* #undef HAVE_SYS_PROCESSOR_H */
+
+/* Define to 1 if you have the <sys/pstat.h> header file. */
+/* #undef HAVE_SYS_PSTAT_H */
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+/* #undef HAVE_SYS_RESOURCE_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/sysctl.h> header file. */
+/* #undef HAVE_SYS_SYSCTL_H */
+
+/* Define to 1 if you have the <sys/sysinfo.h> header file. */
+/* #undef HAVE_SYS_SYSINFO_H */
+
+/* Define to 1 if you have the <sys/syssgi.h> header file. */
+/* #undef HAVE_SYS_SYSSGI_H */
+
+/* Define to 1 if you have the <sys/systemcfg.h> header file. */
+/* #undef HAVE_SYS_SYSTEMCFG_H */
+
+/* Define to 1 if you have the <sys/times.h> header file. */
+/* #undef HAVE_SYS_TIMES_H */
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the `times' function. */
+/* #undef HAVE_TIMES */
+
+/* Define to 1 if the system has the type `uint_least32_t'. */
+#define HAVE_UINT_LEAST32_T 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `vsnprintf' function and it works properly. */
+/* #undef HAVE_VSNPRINTF */
+
+/* Define to 1 for Windos/64 */
+#define HOST_DOS64 1
+
+/* Assembler local label prefix */
+#define LSYM_PREFIX "L"
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* Define to 1 to disable the use of inline assembly */
+/* #undef NO_ASM */
+
+/* Name of package */
+#define PACKAGE "gmp"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "gmp-bugs@gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "GNU MP"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "GNU MP 6.2.0"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "gmp"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "http://www.gnu.org/software/gmp/"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "6.2.0"
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE void
+
+/* The size of `mp_limb_t', as computed by sizeof. */
+#define SIZEOF_MP_LIMB_T 8
+
+/* The size of `unsigned', as computed by sizeof. */
+#define SIZEOF_UNSIGNED 4
+
+/* The size of `unsigned long', as computed by sizeof. */
+#define SIZEOF_UNSIGNED_LONG 4
+
+/* The size of `unsigned short', as computed by sizeof. */
+#define SIZEOF_UNSIGNED_SHORT 2
+
+/* The size of `void *', as computed by sizeof. */
+#define SIZEOF_VOID_P 8
+
+/* Define to 1 if sscanf requires writable inputs */
+/* #undef SSCANF_WRITABLE_INPUT */
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Maximum size the tune program can test for SQR_TOOM2_THRESHOLD */
+/* #undef TUNE_SQR_TOOM2_MAX */
+
+/* Version number of package */
+#define VERSION "6.2.0"
+
+/* Define to 1 to enable ASSERT checking, per --enable-assert */
+/* #undef WANT_ASSERT */
+
+/* Define to 1 to enable GMP_CPU_TYPE faking cpuid, per --enable-fake-cpuid */
+/* #undef WANT_FAKE_CPUID */
+
+/* Define to 1 when building a fat binary. */
+/* #undef WANT_FAT_BINARY */
+
+/* Define to 1 to enable FFTs for multiplication, per --enable-fft */
+#define WANT_FFT 1
+
+/* Define to 1 to enable old mpn_mul_fft_full for multiplication, per
+ --enable-old-fft-full */
+/* #undef WANT_OLD_FFT_FULL */
+
+/* Define to 1 if --enable-profiling=gprof */
+/* #undef WANT_PROFILING_GPROF */
+
+/* Define to 1 if --enable-profiling=instrument */
+/* #undef WANT_PROFILING_INSTRUMENT */
+
+/* Define to 1 if --enable-profiling=prof */
+/* #undef WANT_PROFILING_PROF */
+
+/* Define one of these to 1 for the desired temporary memory allocation
+ method, per --enable-alloca. */
+#define WANT_TMP_ALLOCA 1
+/* #undef WANT_TMP_REENTRANT */
+/* #undef WANT_TMP_NOTREENTRANT */
+/* #undef WANT_TMP_DEBUG */
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+/* # undef WORDS_BIGENDIAN */
+# endif
+#endif
+
+/* Define to 1 if the assembler understands the mulx instruction */
+/* #undef X86_ASM_MULX */
+
+/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
+ `char[]'. */
+/* #undef YYTEXT_POINTER */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+/* Define to the equivalent of the C99 'restrict' keyword, or to
+ nothing if this is not supported. Do not define if restrict is
+ supported directly. */
+#define restrict __restrict
+/* Work around a bug in Sun C++: it does not support _Restrict or
+ __restrict__, even though the corresponding Sun C compiler ends up with
+ "#define restrict _Restrict" or "#define restrict __restrict__" in the
+ previous line. Perhaps some future version of Sun C++ will work with
+ restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
+#if defined __SUNPRO_CC && !defined __RESTRICT
+# define _Restrict
+# define __restrict__
+#endif
+
+/* Define to empty if the keyword `volatile' does not work. Warning: valid
+ code using `volatile' can become incorrect without. Disable with care. */
+/* #undef volatile */
diff --git a/build_files/buildbot/buildbot_utils.py b/build_files/buildbot/buildbot_utils.py
index e8adf5ba810..a0c33155da1 100644
--- a/build_files/buildbot/buildbot_utils.py
+++ b/build_files/buildbot/buildbot_utils.py
@@ -33,10 +33,11 @@ def is_tool(name):
return which(name) is not None
class Builder:
- def __init__(self, name, branch):
+ def __init__(self, name, branch, codesign):
self.name = name
self.branch = branch
self.is_release_branch = re.match("^blender-v(.*)-release$", branch) is not None
+ self.codesign = codesign
# Buildbot runs from build/ directory
self.blender_dir = os.path.abspath(os.path.join('..', 'blender.git'))
@@ -67,8 +68,9 @@ def create_builder_from_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('builder_name')
parser.add_argument('branch', default='master', nargs='?')
+ parser.add_argument("--codesign", action="store_true")
args = parser.parse_args()
- return Builder(args.builder_name, args.branch)
+ return Builder(args.builder_name, args.branch, args.codesign)
class VersionInfo:
diff --git a/build_files/buildbot/worker_bundle_dmg.py b/build_files/buildbot/worker_bundle_dmg.py
index cd3da85e12a..56e0d7da88e 100755
--- a/build_files/buildbot/worker_bundle_dmg.py
+++ b/build_files/buildbot/worker_bundle_dmg.py
@@ -82,6 +82,10 @@ def create_argument_parser():
type=Path,
help="Optional path to applescript to set up folder looks of DMG."
"If not provided default Blender's one is used.")
+ parser.add_argument(
+ '--codesign',
+ action="store_true",
+ help="Code sign and notarize DMG contents.")
return parser
@@ -395,7 +399,8 @@ def create_final_dmg(app_bundles: List[Path],
dmg_filepath: Path,
background_image_filepath: Path,
volume_name: str,
- applescript: Path) -> None:
+ applescript: Path,
+ codesign: bool) -> None:
"""
Create DMG with all app bundles
@@ -421,7 +426,8 @@ def create_final_dmg(app_bundles: List[Path],
#
# This allows to recurs into the content of bundles without worrying about
# possible interfereice of Application symlink.
- codesign_app_bundles_in_dmg(mount_directory)
+ if codesign:
+ codesign_app_bundles_in_dmg(mount_directory)
copy_background_if_needed(background_image_filepath, mount_directory)
create_applications_link(mount_directory)
@@ -434,7 +440,8 @@ def create_final_dmg(app_bundles: List[Path],
compress_dmg(writable_dmg_filepath, dmg_filepath)
writable_dmg_filepath.unlink()
- codesign_and_notarize_dmg(dmg_filepath)
+ if codesign:
+ codesign_and_notarize_dmg(dmg_filepath)
def ensure_dmg_extension(filepath: Path) -> Path:
@@ -521,6 +528,7 @@ def main():
source_dir = args.source_dir.absolute()
background_image_filepath = get_background_image(args.background_image)
applescript = get_applescript(args.applescript)
+ codesign = args.codesign
app_bundles = collect_and_log_app_bundles(source_dir)
if not app_bundles:
@@ -535,7 +543,8 @@ def main():
dmg_filepath,
background_image_filepath,
volume_name,
- applescript)
+ applescript,
+ codesign)
if __name__ == "__main__":
diff --git a/build_files/buildbot/worker_compile.py b/build_files/buildbot/worker_compile.py
index f1357e1864f..8e19c9436f8 100644
--- a/build_files/buildbot/worker_compile.py
+++ b/build_files/buildbot/worker_compile.py
@@ -24,7 +24,7 @@ import shutil
import buildbot_utils
def get_cmake_options(builder):
- post_install_script = os.path.join(
+ codesign_script = os.path.join(
builder.blender_dir, 'build_files', 'buildbot', 'worker_codesign.cmake')
config_file = "build_files/cmake/config/blender_release.cmake"
@@ -36,7 +36,8 @@ def get_cmake_options(builder):
options.append('-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9')
elif builder.platform == 'win':
options.extend(['-G', 'Visual Studio 16 2019', '-A', 'x64'])
- options.extend(['-DPOSTINSTALL_SCRIPT:PATH=' + post_install_script])
+ if builder.codesign:
+ options.extend(['-DPOSTINSTALL_SCRIPT:PATH=' + codesign_script])
elif builder.platform == 'linux':
config_file = "build_files/buildbot/config/blender_linux.cmake"
diff --git a/build_files/buildbot/worker_pack.py b/build_files/buildbot/worker_pack.py
index 87ee49c87d8..96c8db8e6c8 100644
--- a/build_files/buildbot/worker_pack.py
+++ b/build_files/buildbot/worker_pack.py
@@ -117,6 +117,8 @@ def pack_mac(builder):
if info.is_development_build:
background_image = os.path.join(release_dir, 'buildbot', 'background.tif')
command += ['--background-image', background_image]
+ if builder.codesign:
+ command += ['--codesign']
command += [builder.install_dir]
buildbot_utils.call(command)
@@ -150,7 +152,8 @@ def pack_win(builder):
package_filename = package_name + '.msi'
package_filepath = os.path.join(builder.build_dir, package_filename)
- sign_file_or_directory(package_filepath)
+ if builder.codesign:
+ sign_file_or_directory(package_filepath)
package_files += [(package_filepath, package_filename)]
diff --git a/build_files/cmake/Modules/FindAlembic.cmake b/build_files/cmake/Modules/FindAlembic.cmake
index 2d69613ad84..45cda7ae2c5 100644
--- a/build_files/cmake/Modules/FindAlembic.cmake
+++ b/build_files/cmake/Modules/FindAlembic.cmake
@@ -51,7 +51,7 @@ FIND_LIBRARY(ALEMBIC_LIBRARY
# handle the QUIETLY and REQUIRED arguments and set ALEMBIC_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALEMBIC DEFAULT_MSG ALEMBIC_LIBRARY ALEMBIC_INCLUDE_DIR)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Alembic DEFAULT_MSG ALEMBIC_LIBRARY ALEMBIC_INCLUDE_DIR)
IF(ALEMBIC_FOUND)
SET(ALEMBIC_LIBRARIES ${ALEMBIC_LIBRARY})
diff --git a/build_files/cmake/Modules/FindBlosc.cmake b/build_files/cmake/Modules/FindBlosc.cmake
index bec934ad7c3..e0baa2d3382 100644
--- a/build_files/cmake/Modules/FindBlosc.cmake
+++ b/build_files/cmake/Modules/FindBlosc.cmake
@@ -53,7 +53,7 @@ FIND_LIBRARY(BLOSC_LIBRARY
# handle the QUIETLY and REQUIRED arguments and set BLOSC_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(BLOSC DEFAULT_MSG
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Blosc DEFAULT_MSG
BLOSC_LIBRARY BLOSC_INCLUDE_DIR)
IF(BLOSC_FOUND)
diff --git a/build_files/cmake/Modules/FindEmbree.cmake b/build_files/cmake/Modules/FindEmbree.cmake
index fa613f62308..90cf23d3e13 100644
--- a/build_files/cmake/Modules/FindEmbree.cmake
+++ b/build_files/cmake/Modules/FindEmbree.cmake
@@ -7,9 +7,6 @@
# EMBREE_ROOT_DIR, The base directory to search for Embree.
# This can also be an environment variable.
# EMBREEFOUND, If false, do not try to use Embree.
-#
-# also defined, but not for general use are
-# EMBREE_LIBRARY, where to find the Embree library.
#=============================================================================
# Copyright 2018 Blender Foundation.
@@ -70,15 +67,6 @@ FOREACH(COMPONENT ${_embree_FIND_COMPONENTS})
ENDFOREACH()
-FIND_LIBRARY(EMBREE_LIBRARY
- NAMES
- libembree3
- HINTS
- ${_embree_SEARCH_DIRS}
- PATH_SUFFIXES
- lib64 lib
-)
-
# handle the QUIETLY and REQUIRED arguments and set EMBREE_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
diff --git a/build_files/cmake/Modules/FindGLEW.cmake b/build_files/cmake/Modules/FindGLEW.cmake
index 652b0835807..390e3878d6a 100644
--- a/build_files/cmake/Modules/FindGLEW.cmake
+++ b/build_files/cmake/Modules/FindGLEW.cmake
@@ -51,7 +51,7 @@ FIND_LIBRARY(GLEW_LIBRARY
# handle the QUIETLY and REQUIRED arguments and set GLEW_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Glew DEFAULT_MSG
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLEW DEFAULT_MSG
GLEW_LIBRARY GLEW_INCLUDE_DIR)
IF(GLEW_FOUND)
diff --git a/build_files/cmake/Modules/FindGMP.cmake b/build_files/cmake/Modules/FindGMP.cmake
new file mode 100644
index 00000000000..4469f32c785
--- /dev/null
+++ b/build_files/cmake/Modules/FindGMP.cmake
@@ -0,0 +1,96 @@
+# - Find GMP library
+# Find the native GMP includes and library
+# This module defines
+# GMP_INCLUDE_DIRS, where to find gmp.h, Set when
+# GMP_INCLUDE_DIR is found.
+# GMP_LIBRARIES, libraries to link against to use GMP.
+# GMP_ROOT_DIR, The base directory to search for GMP.
+# This can also be an environment variable.
+# GMP_FOUND, If false, do not try to use GMP.
+#
+# also defined, but not for general use are
+# GMP_LIBRARY, where to find the GMP library.
+
+#=============================================================================
+# Copyright 2011 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# If GMP_ROOT_DIR was defined in the environment, use it.
+IF(NOT GMP_ROOT_DIR AND NOT $ENV{GMP_ROOT_DIR} STREQUAL "")
+ SET(GMP_ROOT_DIR $ENV{GMP_ROOT_DIR})
+ENDIF()
+
+SET(_gmp_SEARCH_DIRS
+ ${GMP_ROOT_DIR}
+ /opt/lib/gmp
+)
+
+FIND_PATH(GMP_INCLUDE_DIR
+ NAMES
+ gmp.h
+ HINTS
+ ${_gmp_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include/gmp
+)
+
+FIND_PATH(GMPXX_INCLUDE_DIR
+ NAMES
+ gmpxx.h
+ HINTS
+ ${_gmp_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include/gmp
+)
+
+FIND_LIBRARY(GMP_LIBRARY
+ NAMES
+ gmp
+ HINTS
+ ${_gmp_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib
+ )
+
+FIND_LIBRARY(GMPXX_LIBRARY
+ NAMES
+ gmpxx
+ HINTS
+ ${_gmp_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib
+ )
+
+if(GMP_INCLUDE_DIR)
+ SET(_version_regex "^#define[ \t]+__GNU_MP_VERSION[ \t]+\"([^\"]+)\".*")
+ file(STRINGS "${GMP_INCLUDE_DIR}/gmp.h"
+ GMP_VERSION REGEX "${_version_regex}")
+ string(REGEX REPLACE "${_version_regex}" "\\1"
+ GMP_VERSION "${GMP_VERSION}")
+ unset(_version_regex)
+endif()
+
+# handle the QUIETLY and REQUIRED arguments and set GMP_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMP DEFAULT_MSG
+ GMP_LIBRARY GMPXX_LIBRARY GMP_INCLUDE_DIR GMPXX_INCLUDE_DIR)
+
+IF(GMP_FOUND)
+ SET(GMP_LIBRARIES ${GMP_LIBRARY} ${GMPXX_LIBRARY})
+ SET(GMP_INCLUDE_DIRS ${GMP_INCLUDE_DIR} ${GMPXX_INCLUDE_DIR})
+ENDIF(GMP_FOUND)
+
+MARK_AS_ADVANCED(
+ GMP_INCLUDE_DIR
+ GMP_LIBRARY
+ GMPXX_INCLUDE_DIR
+ GMPXX_LIBRARY
+)
diff --git a/build_files/cmake/Modules/FindOpenShadingLanguage.cmake b/build_files/cmake/Modules/FindOSL.cmake
index 07ed2c86e19..07ed2c86e19 100644
--- a/build_files/cmake/Modules/FindOpenShadingLanguage.cmake
+++ b/build_files/cmake/Modules/FindOSL.cmake
diff --git a/build_files/cmake/Modules/FindOpenCOLLADA.cmake b/build_files/cmake/Modules/FindOpenCOLLADA.cmake
index acf9e9ed9ce..239d46499b9 100644
--- a/build_files/cmake/Modules/FindOpenCOLLADA.cmake
+++ b/build_files/cmake/Modules/FindOpenCOLLADA.cmake
@@ -7,9 +7,6 @@
# OPENCOLLADA_ROOT_DIR, The base directory to search for OpenCOLLADA.
# This can also be an environment variable.
# OPENCOLLADA_FOUND, If false, do not try to use OpenCOLLADA.
-#
-# also defined, but not for general use are
-# OPENCOLLADA_LIBRARY, where to find the OpenCOLLADA library.
#=============================================================================
# Copyright 2011 Blender Foundation.
diff --git a/build_files/cmake/Modules/FindOpenSubdiv.cmake b/build_files/cmake/Modules/FindOpenSubdiv.cmake
index d7a8567a399..2c9fbf0ba60 100644
--- a/build_files/cmake/Modules/FindOpenSubdiv.cmake
+++ b/build_files/cmake/Modules/FindOpenSubdiv.cmake
@@ -7,9 +7,6 @@
# OPENSUBDIV_ROOT_DIR, the base directory to search for OpenSubdiv.
# This can also be an environment variable.
# OPENSUBDIV_FOUND, if false, do not try to use OpenSubdiv.
-#
-# also defined, but not for general use are
-# OPENSUBDIV_LIBRARY, where to find the OpenSubdiv library.
#=============================================================================
# Copyright 2013 Blender Foundation.
diff --git a/build_files/cmake/Modules/FindOpenVDB.cmake b/build_files/cmake/Modules/FindOpenVDB.cmake
index 2a1378e3a2b..5f24231fcf4 100644
--- a/build_files/cmake/Modules/FindOpenVDB.cmake
+++ b/build_files/cmake/Modules/FindOpenVDB.cmake
@@ -53,7 +53,7 @@ FIND_LIBRARY(OPENVDB_LIBRARY
# handle the QUIETLY and REQUIRED arguments and set OPENVDB_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENVDB DEFAULT_MSG
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenVDB DEFAULT_MSG
OPENVDB_LIBRARY OPENVDB_INCLUDE_DIR)
IF(OPENVDB_FOUND)
diff --git a/build_files/cmake/Modules/FindXR-OpenXR-SDK.cmake b/build_files/cmake/Modules/FindXR_OpenXR_SDK.cmake
index 71b40ec1bde..567a0101b4a 100644
--- a/build_files/cmake/Modules/FindXR-OpenXR-SDK.cmake
+++ b/build_files/cmake/Modules/FindXR_OpenXR_SDK.cmake
@@ -59,7 +59,7 @@ FIND_LIBRARY(XR_OPENXR_SDK_LOADER_LIBRARY
# handle the QUIETLY and REQUIRED arguments and set XR_OPENXR_SDK_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(XR_OPENXR_SDK DEFAULT_MSG
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(XR_OpenXR_SDK DEFAULT_MSG
XR_OPENXR_SDK_LOADER_LIBRARY XR_OPENXR_SDK_INCLUDE_DIR)
IF(XR_OPENXR_SDK_FOUND)
diff --git a/build_files/cmake/Modules/GTest.cmake b/build_files/cmake/Modules/GTest.cmake
new file mode 100644
index 00000000000..9a82fc49628
--- /dev/null
+++ b/build_files/cmake/Modules/GTest.cmake
@@ -0,0 +1,550 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+GoogleTest
+----------
+
+.. versionadded:: 3.9
+
+This module defines functions to help use the Google Test infrastructure. Two
+mechanisms for adding tests are provided. :command:`gtest_add_tests` has been
+around for some time, originally via ``find_package(GTest)``.
+:command:`gtest_discover_tests` was introduced in CMake 3.10.
+
+The (older) :command:`gtest_add_tests` scans source files to identify tests.
+This is usually effective, with some caveats, including in cross-compiling
+environments, and makes setting additional properties on tests more convenient.
+However, its handling of parameterized tests is less comprehensive, and it
+requires re-running CMake to detect changes to the list of tests.
+
+The (newer) :command:`gtest_discover_tests` discovers tests by asking the
+compiled test executable to enumerate its tests. This is more robust and
+provides better handling of parameterized tests, and does not require CMake
+to be re-run when tests change. However, it may not work in a cross-compiling
+environment, and setting test properties is less convenient.
+
+More details can be found in the documentation of the respective functions.
+
+Both commands are intended to replace use of :command:`add_test` to register
+tests, and will create a separate CTest test for each Google Test test case.
+Note that this is in some cases less efficient, as common set-up and tear-down
+logic cannot be shared by multiple test cases executing in the same instance.
+However, it provides more fine-grained pass/fail information to CTest, which is
+usually considered as more beneficial. By default, the CTest test name is the
+same as the Google Test name (i.e. ``suite.testcase``); see also
+``TEST_PREFIX`` and ``TEST_SUFFIX``.
+
+.. command:: gtest_add_tests
+
+ Automatically add tests with CTest by scanning source code for Google Test
+ macros::
+
+ gtest_add_tests(TARGET target
+ [SOURCES src1...]
+ [EXTRA_ARGS arg1...]
+ [WORKING_DIRECTORY dir]
+ [TEST_PREFIX prefix]
+ [TEST_SUFFIX suffix]
+ [SKIP_DEPENDENCY]
+ [TEST_LIST outVar]
+ )
+
+ ``gtest_add_tests`` attempts to identify tests by scanning source files.
+ Although this is generally effective, it uses only a basic regular expression
+ match, which can be defeated by atypical test declarations, and is unable to
+ fully "split" parameterized tests. Additionally, it requires that CMake be
+ re-run to discover any newly added, removed or renamed tests (by default,
+ this means that CMake is re-run when any test source file is changed, but see
+ ``SKIP_DEPENDENCY``). However, it has the advantage of declaring tests at
+ CMake time, which somewhat simplifies setting additional properties on tests,
+ and always works in a cross-compiling environment.
+
+ The options are:
+
+ ``TARGET target``
+ Specifies the Google Test executable, which must be a known CMake
+ executable target. CMake will substitute the location of the built
+ executable when running the test.
+
+ ``SOURCES src1...``
+ When provided, only the listed files will be scanned for test cases. If
+ this option is not given, the :prop_tgt:`SOURCES` property of the
+ specified ``target`` will be used to obtain the list of sources.
+
+ ``EXTRA_ARGS arg1...``
+ Any extra arguments to pass on the command line to each test case.
+
+ ``WORKING_DIRECTORY dir``
+ Specifies the directory in which to run the discovered test cases. If this
+ option is not provided, the current binary directory is used.
+
+ ``TEST_PREFIX prefix``
+ Specifies a ``prefix`` to be prepended to the name of each discovered test
+ case. This can be useful when the same source files are being used in
+ multiple calls to ``gtest_add_test()`` but with different ``EXTRA_ARGS``.
+
+ ``TEST_SUFFIX suffix``
+ Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of
+ every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may
+ be specified.
+
+ ``SKIP_DEPENDENCY``
+ Normally, the function creates a dependency which will cause CMake to be
+ re-run if any of the sources being scanned are changed. This is to ensure
+ that the list of discovered tests is updated. If this behavior is not
+ desired (as may be the case while actually writing the test cases), this
+ option can be used to prevent the dependency from being added.
+
+ ``TEST_LIST outVar``
+ The variable named by ``outVar`` will be populated in the calling scope
+ with the list of discovered test cases. This allows the caller to do
+ things like manipulate test properties of the discovered tests.
+
+ .. code-block:: cmake
+
+ include(GoogleTest)
+ add_executable(FooTest FooUnitTest.cxx)
+ gtest_add_tests(TARGET FooTest
+ TEST_SUFFIX .noArgs
+ TEST_LIST noArgsTests
+ )
+ gtest_add_tests(TARGET FooTest
+ EXTRA_ARGS --someArg someValue
+ TEST_SUFFIX .withArgs
+ TEST_LIST withArgsTests
+ )
+ set_tests_properties(${noArgsTests} PROPERTIES TIMEOUT 10)
+ set_tests_properties(${withArgsTests} PROPERTIES TIMEOUT 20)
+
+ For backward compatibility, the following form is also supported::
+
+ gtest_add_tests(exe args files...)
+
+ ``exe``
+ The path to the test executable or the name of a CMake target.
+ ``args``
+ A ;-list of extra arguments to be passed to executable. The entire
+ list must be passed as a single argument. Enclose it in quotes,
+ or pass ``""`` for no arguments.
+ ``files...``
+ A list of source files to search for tests and test fixtures.
+ Alternatively, use ``AUTO`` to specify that ``exe`` is the name
+ of a CMake executable target whose sources should be scanned.
+
+ .. code-block:: cmake
+
+ include(GoogleTest)
+ set(FooTestArgs --foo 1 --bar 2)
+ add_executable(FooTest FooUnitTest.cxx)
+ gtest_add_tests(FooTest "${FooTestArgs}" AUTO)
+
+.. command:: gtest_discover_tests
+
+ Automatically add tests with CTest by querying the compiled test executable
+ for available tests::
+
+ gtest_discover_tests(target
+ [EXTRA_ARGS arg1...]
+ [WORKING_DIRECTORY dir]
+ [TEST_PREFIX prefix]
+ [TEST_SUFFIX suffix]
+ [NO_PRETTY_TYPES] [NO_PRETTY_VALUES]
+ [PROPERTIES name1 value1...]
+ [TEST_LIST var]
+ [DISCOVERY_TIMEOUT seconds]
+ [XML_OUTPUT_DIR dir]
+ [DISCOVERY_MODE <POST_BUILD|PRE_TEST>]
+ )
+
+ ``gtest_discover_tests()`` sets up a post-build command on the test executable
+ that generates the list of tests by parsing the output from running the test
+ with the ``--gtest_list_tests`` argument. Compared to the source parsing
+ approach of :command:`gtest_add_tests`, this ensures that the full list of
+ tests, including instantiations of parameterized tests, is obtained. Since
+ test discovery occurs at build time, it is not necessary to re-run CMake when
+ the list of tests changes.
+ However, it requires that :prop_tgt:`CROSSCOMPILING_EMULATOR` is properly set
+ in order to function in a cross-compiling environment.
+
+ Additionally, setting properties on tests is somewhat less convenient, since
+ the tests are not available at CMake time. Additional test properties may be
+ assigned to the set of tests as a whole using the ``PROPERTIES`` option. If
+ more fine-grained test control is needed, custom content may be provided
+ through an external CTest script using the :prop_dir:`TEST_INCLUDE_FILES`
+ directory property. The set of discovered tests is made accessible to such a
+ script via the ``<target>_TESTS`` variable.
+
+ The options are:
+
+ ``target``
+ Specifies the Google Test executable, which must be a known CMake
+ executable target. CMake will substitute the location of the built
+ executable when running the test.
+
+ ``EXTRA_ARGS arg1...``
+ Any extra arguments to pass on the command line to each test case.
+
+ ``WORKING_DIRECTORY dir``
+ Specifies the directory in which to run the discovered test cases. If this
+ option is not provided, the current binary directory is used.
+
+ ``TEST_PREFIX prefix``
+ Specifies a ``prefix`` to be prepended to the name of each discovered test
+ case. This can be useful when the same test executable is being used in
+ multiple calls to ``gtest_discover_tests()`` but with different
+ ``EXTRA_ARGS``.
+
+ ``TEST_SUFFIX suffix``
+ Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of
+ every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may
+ be specified.
+
+ ``NO_PRETTY_TYPES``
+ By default, the type index of type-parameterized tests is replaced by the
+ actual type name in the CTest test name. If this behavior is undesirable
+ (e.g. because the type names are unwieldy), this option will suppress this
+ behavior.
+
+ ``NO_PRETTY_VALUES``
+ By default, the value index of value-parameterized tests is replaced by the
+ actual value in the CTest test name. If this behavior is undesirable
+ (e.g. because the value strings are unwieldy), this option will suppress
+ this behavior.
+
+ ``PROPERTIES name1 value1...``
+ Specifies additional properties to be set on all tests discovered by this
+ invocation of ``gtest_discover_tests()``.
+
+ ``TEST_LIST var``
+ Make the list of tests available in the variable ``var``, rather than the
+ default ``<target>_TESTS``. This can be useful when the same test
+ executable is being used in multiple calls to ``gtest_discover_tests()``.
+ Note that this variable is only available in CTest.
+
+ ``DISCOVERY_TIMEOUT num``
+ Specifies how long (in seconds) CMake will wait for the test to enumerate
+ available tests. If the test takes longer than this, discovery (and your
+ build) will fail. Most test executables will enumerate their tests very
+ quickly, but under some exceptional circumstances, a test may require a
+ longer timeout. The default is 5. See also the ``TIMEOUT`` option of
+ :command:`execute_process`.
+
+ .. note::
+
+ In CMake versions 3.10.1 and 3.10.2, this option was called ``TIMEOUT``.
+ This clashed with the ``TIMEOUT`` test property, which is one of the
+ common properties that would be set with the ``PROPERTIES`` keyword,
+ usually leading to legal but unintended behavior. The keyword was
+ changed to ``DISCOVERY_TIMEOUT`` in CMake 3.10.3 to address this
+ problem. The ambiguous behavior of the ``TIMEOUT`` keyword in 3.10.1
+ and 3.10.2 has not been preserved.
+
+ ``XML_OUTPUT_DIR dir``
+ If specified, the parameter is passed along with ``--gtest_output=xml:``
+ to test executable. The actual file name is the same as the test target,
+ including prefix and suffix. This should be used instead of
+ ``EXTRA_ARGS --gtest_output=xml`` to avoid race conditions writing the
+ XML result output when using parallel test execution.
+
+ ``DISCOVERY_MODE``
+ Provides greater control over when ``gtest_discover_tests()`` performs test
+ discovery. By default, ``POST_BUILD`` sets up a post-build command
+ to perform test discovery at build time. In certain scenarios, like
+ cross-compiling, this ``POST_BUILD`` behavior is not desirable.
+ By contrast, ``PRE_TEST`` delays test discovery until just prior to test
+ execution. This way test discovery occurs in the target environment
+ where the test has a better chance at finding appropriate runtime
+ dependencies.
+
+ ``DISCOVERY_MODE`` defaults to the value of the
+ ``CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE`` variable if it is not
+ passed when calling ``gtest_discover_tests()``. This provides a mechanism
+ for globally selecting a preferred test discovery behavior without having
+ to modify each call site.
+
+#]=======================================================================]
+
+# Save project's policies
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
+#------------------------------------------------------------------------------
+function(gtest_add_tests)
+
+ if (ARGC LESS 1)
+ message(FATAL_ERROR "No arguments supplied to gtest_add_tests()")
+ endif()
+
+ set(options
+ SKIP_DEPENDENCY
+ )
+ set(oneValueArgs
+ TARGET
+ WORKING_DIRECTORY
+ TEST_PREFIX
+ TEST_SUFFIX
+ TEST_LIST
+ )
+ set(multiValueArgs
+ SOURCES
+ EXTRA_ARGS
+ )
+ set(allKeywords ${options} ${oneValueArgs} ${multiValueArgs})
+
+ unset(sources)
+ if("${ARGV0}" IN_LIST allKeywords)
+ cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ set(autoAddSources YES)
+ else()
+ # Non-keyword syntax, convert to keyword form
+ if (ARGC LESS 3)
+ message(FATAL_ERROR "gtest_add_tests() without keyword options requires at least 3 arguments")
+ endif()
+ set(ARGS_TARGET "${ARGV0}")
+ set(ARGS_EXTRA_ARGS "${ARGV1}")
+ if(NOT "${ARGV2}" STREQUAL "AUTO")
+ set(ARGS_SOURCES "${ARGV}")
+ list(REMOVE_AT ARGS_SOURCES 0 1)
+ endif()
+ endif()
+
+ # The non-keyword syntax allows the first argument to be an arbitrary
+ # executable rather than a target if source files are also provided. In all
+ # other cases, both forms require a target.
+ if(NOT TARGET "${ARGS_TARGET}" AND NOT ARGS_SOURCES)
+ message(FATAL_ERROR "${ARGS_TARGET} does not define an existing CMake target")
+ endif()
+ if(NOT ARGS_WORKING_DIRECTORY)
+ unset(workDir)
+ else()
+ set(workDir WORKING_DIRECTORY "${ARGS_WORKING_DIRECTORY}")
+ endif()
+
+ if(NOT ARGS_SOURCES)
+ get_property(ARGS_SOURCES TARGET ${ARGS_TARGET} PROPERTY SOURCES)
+ endif()
+
+ unset(testList)
+
+ set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+) *, *([A-Za-z_0-9]+) *\\).*")
+ set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)")
+
+ foreach(source IN LISTS ARGS_SOURCES)
+ if(NOT ARGS_SKIP_DEPENDENCY)
+ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source})
+ endif()
+ file(READ "${source}" contents)
+ string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests "${contents}")
+ foreach(hit ${found_tests})
+ string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit})
+
+ # Parameterized tests have a different signature for the filter
+ if("x${test_type}" STREQUAL "xTEST_P")
+ string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" gtest_test_name ${hit})
+ elseif("x${test_type}" STREQUAL "xTEST_F" OR "x${test_type}" STREQUAL "xTEST")
+ string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" gtest_test_name ${hit})
+ elseif("x${test_type}" STREQUAL "xTYPED_TEST")
+ string(REGEX REPLACE ${gtest_case_name_regex} "\\1/*.\\2" gtest_test_name ${hit})
+ else()
+ message(WARNING "Could not parse GTest ${hit} for adding to CTest.")
+ continue()
+ endif()
+
+ # Make sure tests disabled in GTest get disabled in CTest
+ if(gtest_test_name MATCHES "(^|\\.)DISABLED_")
+ # Add the disabled test if CMake is new enough
+ # Note that this check is to allow backwards compatibility so this
+ # module can be copied locally in projects to use with older CMake
+ # versions
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.8.20170401)
+ string(REGEX REPLACE
+ "(^|\\.)DISABLED_" "\\1"
+ orig_test_name "${gtest_test_name}"
+ )
+ set(ctest_test_name
+ ${ARGS_TEST_PREFIX}${orig_test_name}${ARGS_TEST_SUFFIX}
+ )
+ add_test(NAME ${ctest_test_name}
+ ${workDir}
+ COMMAND ${ARGS_TARGET}
+ --gtest_also_run_disabled_tests
+ --gtest_filter=${gtest_test_name}
+ ${ARGS_EXTRA_ARGS}
+ )
+ set_tests_properties(${ctest_test_name} PROPERTIES DISABLED TRUE)
+ list(APPEND testList ${ctest_test_name})
+ endif()
+ else()
+ set(ctest_test_name ${ARGS_TEST_PREFIX}${gtest_test_name}${ARGS_TEST_SUFFIX})
+ add_test(NAME ${ctest_test_name}
+ ${workDir}
+ COMMAND ${ARGS_TARGET}
+ --gtest_filter=${gtest_test_name}
+ ${ARGS_EXTRA_ARGS}
+ )
+ list(APPEND testList ${ctest_test_name})
+ endif()
+ endforeach()
+ endforeach()
+
+ if(ARGS_TEST_LIST)
+ set(${ARGS_TEST_LIST} ${testList} PARENT_SCOPE)
+ endif()
+
+endfunction()
+
+#------------------------------------------------------------------------------
+
+function(gtest_discover_tests TARGET)
+ cmake_parse_arguments(
+ ""
+ "NO_PRETTY_TYPES;NO_PRETTY_VALUES"
+ "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;DISCOVERY_TIMEOUT;XML_OUTPUT_DIR;DISCOVERY_MODE"
+ "EXTRA_ARGS;PROPERTIES"
+ ${ARGN}
+ )
+
+ if(NOT _WORKING_DIRECTORY)
+ set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
+ endif()
+ if(NOT _TEST_LIST)
+ set(_TEST_LIST ${TARGET}_TESTS)
+ endif()
+ if(NOT _DISCOVERY_TIMEOUT)
+ set(_DISCOVERY_TIMEOUT 5)
+ endif()
+ if(NOT _DISCOVERY_MODE)
+ if(NOT CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE)
+ set(CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE "POST_BUILD")
+ endif()
+ set(_DISCOVERY_MODE ${CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE})
+ endif()
+
+ get_property(
+ has_counter
+ TARGET ${TARGET}
+ PROPERTY CTEST_DISCOVERED_TEST_COUNTER
+ SET
+ )
+ if(has_counter)
+ get_property(
+ counter
+ TARGET ${TARGET}
+ PROPERTY CTEST_DISCOVERED_TEST_COUNTER
+ )
+ math(EXPR counter "${counter} + 1")
+ else()
+ set(counter 1)
+ endif()
+ set_property(
+ TARGET ${TARGET}
+ PROPERTY CTEST_DISCOVERED_TEST_COUNTER
+ ${counter}
+ )
+
+ # Define rule to generate test list for aforementioned test executable
+ # Blender: use _ instead of [] to avoid problems with zsh regex.
+ set(ctest_file_base "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_${counter}_")
+ set(ctest_include_file "${ctest_file_base}_include.cmake")
+ set(ctest_tests_file "${ctest_file_base}_tests.cmake")
+ get_property(crosscompiling_emulator
+ TARGET ${TARGET}
+ PROPERTY CROSSCOMPILING_EMULATOR
+ )
+
+ if(_DISCOVERY_MODE STREQUAL "POST_BUILD")
+ add_custom_command(
+ TARGET ${TARGET} POST_BUILD
+ BYPRODUCTS "${ctest_tests_file}"
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_TARGET=${TARGET}"
+ -D "TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>"
+ -D "TEST_EXECUTOR=${crosscompiling_emulator}"
+ -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}"
+ -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}"
+ -D "TEST_PROPERTIES=${_PROPERTIES}"
+ -D "TEST_PREFIX=${_TEST_PREFIX}"
+ -D "TEST_SUFFIX=${_TEST_SUFFIX}"
+ -D "NO_PRETTY_TYPES=${_NO_PRETTY_TYPES}"
+ -D "NO_PRETTY_VALUES=${_NO_PRETTY_VALUES}"
+ -D "TEST_LIST=${_TEST_LIST}"
+ -D "CTEST_FILE=${ctest_tests_file}"
+ -D "TEST_DISCOVERY_TIMEOUT=${_DISCOVERY_TIMEOUT}"
+ -D "TEST_XML_OUTPUT_DIR=${_XML_OUTPUT_DIR}"
+ -P "${_GOOGLETEST_DISCOVER_TESTS_SCRIPT}"
+ VERBATIM
+ )
+
+ file(WRITE "${ctest_include_file}"
+ "if(EXISTS \"${ctest_tests_file}\")\n"
+ " include(\"${ctest_tests_file}\")\n"
+ "else()\n"
+ " add_test(${TARGET}_NOT_BUILT ${TARGET}_NOT_BUILT)\n"
+ "endif()\n"
+ )
+ elseif(_DISCOVERY_MODE STREQUAL "PRE_TEST")
+
+ get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL
+ PROPERTY GENERATOR_IS_MULTI_CONFIG
+ )
+
+ if(GENERATOR_IS_MULTI_CONFIG)
+ set(ctest_tests_file "${ctest_file_base}_tests-$<CONFIG>.cmake")
+ endif()
+
+ string(CONCAT ctest_include_content
+ "if(EXISTS \"$<TARGET_FILE:${TARGET}>\")" "\n"
+ " if(\"$<TARGET_FILE:${TARGET}>\" IS_NEWER_THAN \"${ctest_tests_file}\")" "\n"
+ " include(\"${_GOOGLETEST_DISCOVER_TESTS_SCRIPT}\")" "\n"
+ " gtest_discover_tests_impl(" "\n"
+ " TEST_EXECUTABLE" " [==[" "$<TARGET_FILE:${TARGET}>" "]==]" "\n"
+ " TEST_EXECUTOR" " [==[" "${crosscompiling_emulator}" "]==]" "\n"
+ " TEST_WORKING_DIR" " [==[" "${_WORKING_DIRECTORY}" "]==]" "\n"
+ " TEST_EXTRA_ARGS" " [==[" "${_EXTRA_ARGS}" "]==]" "\n"
+ " TEST_PROPERTIES" " [==[" "${_PROPERTIES}" "]==]" "\n"
+ " TEST_PREFIX" " [==[" "${_TEST_PREFIX}" "]==]" "\n"
+ " TEST_SUFFIX" " [==[" "${_TEST_SUFFIX}" "]==]" "\n"
+ " NO_PRETTY_TYPES" " [==[" "${_NO_PRETTY_TYPES}" "]==]" "\n"
+ " NO_PRETTY_VALUES" " [==[" "${_NO_PRETTY_VALUES}" "]==]" "\n"
+ " TEST_LIST" " [==[" "${_TEST_LIST}" "]==]" "\n"
+ " CTEST_FILE" " [==[" "${ctest_tests_file}" "]==]" "\n"
+ " TEST_DISCOVERY_TIMEOUT" " [==[" "${_DISCOVERY_TIMEOUT}" "]==]" "\n"
+ " TEST_XML_OUTPUT_DIR" " [==[" "${_XML_OUTPUT_DIR}" "]==]" "\n"
+ " )" "\n"
+ " endif()" "\n"
+ " include(\"${ctest_tests_file}\")" "\n"
+ "else()" "\n"
+ " add_test(${TARGET}_NOT_BUILT ${TARGET}_NOT_BUILT)" "\n"
+ "endif()" "\n"
+ )
+
+ if(GENERATOR_IS_MULTI_CONFIG)
+ foreach(_config ${CMAKE_CONFIGURATION_TYPES})
+ file(GENERATE OUTPUT "${ctest_file_base}_include-${_config}.cmake" CONTENT "${ctest_include_content}" CONDITION $<CONFIG:${_config}>)
+ endforeach()
+ file(WRITE "${ctest_include_file}" "include(\"${ctest_file_base}_include-\${CTEST_CONFIGURATION_TYPE}.cmake\")")
+ else()
+ file(GENERATE OUTPUT "${ctest_file_base}_include.cmake" CONTENT "${ctest_include_content}")
+ file(WRITE "${ctest_include_file}" "include(\"${ctest_file_base}_include.cmake\")")
+ endif()
+
+ else()
+ message(FATAL_ERROR "Unknown DISCOVERY_MODE: ${_DISCOVERY_MODE}")
+ endif()
+
+ # Add discovered tests to directory TEST_INCLUDE_FILES
+ set_property(DIRECTORY
+ APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}"
+ )
+
+endfunction()
+
+###############################################################################
+
+set(_GOOGLETEST_DISCOVER_TESTS_SCRIPT
+ ${CMAKE_CURRENT_LIST_DIR}/GTestAddTests.cmake
+)
+
+# Restore project's policies
+cmake_policy(POP)
diff --git a/build_files/cmake/Modules/GTestAddTests.cmake b/build_files/cmake/Modules/GTestAddTests.cmake
new file mode 100644
index 00000000000..8be07b8e2e5
--- /dev/null
+++ b/build_files/cmake/Modules/GTestAddTests.cmake
@@ -0,0 +1,191 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# Blender: disable ASAN leak detection when trying to discover tests.
+set(ENV{ASAN_OPTIONS} "detect_leaks=0")
+
+cmake_minimum_required(VERSION ${CMAKE_VERSION})
+
+# Overwrite possibly existing ${_CTEST_FILE} with empty file
+set(flush_tests_MODE WRITE)
+
+# Flushes script to ${_CTEST_FILE}
+macro(flush_script)
+ file(${flush_tests_MODE} "${_CTEST_FILE}" "${script}")
+ set(flush_tests_MODE APPEND)
+
+ set(script "")
+endmacro()
+
+# Flushes tests_buffer to tests
+macro(flush_tests_buffer)
+ list(APPEND tests "${tests_buffer}")
+ set(tests_buffer "")
+endmacro()
+
+macro(add_command NAME)
+ set(_args "")
+ foreach(_arg ${ARGN})
+ if(_arg MATCHES "[^-./:a-zA-Z0-9_]")
+ string(APPEND _args " [==[${_arg}]==]")
+ else()
+ string(APPEND _args " ${_arg}")
+ endif()
+ endforeach()
+ string(APPEND script "${NAME}(${_args})\n")
+ string(LENGTH "${script}" _script_len)
+ if(${_script_len} GREATER "50000")
+ flush_script()
+ endif()
+ # Unsets macro local variables to prevent leakage outside of this macro.
+ unset(_args)
+ unset(_script_len)
+endmacro()
+
+function(gtest_discover_tests_impl)
+
+ cmake_parse_arguments(
+ ""
+ ""
+ "NO_PRETTY_TYPES;NO_PRETTY_VALUES;TEST_EXECUTABLE;TEST_EXECUTOR;TEST_WORKING_DIR;TEST_PREFIX;TEST_SUFFIX;TEST_LIST;CTEST_FILE;TEST_DISCOVERY_TIMEOUT;TEST_XML_OUTPUT_DIR"
+ "TEST_EXTRA_ARGS;TEST_PROPERTIES"
+ ${ARGN}
+ )
+
+ set(prefix "${_TEST_PREFIX}")
+ set(suffix "${_TEST_SUFFIX}")
+ set(extra_args ${_TEST_EXTRA_ARGS})
+ set(properties ${_TEST_PROPERTIES})
+ set(script)
+ set(suite)
+ set(tests)
+ set(tests_buffer)
+
+ # Run test executable to get list of available tests
+ if(NOT EXISTS "${_TEST_EXECUTABLE}")
+ message(FATAL_ERROR
+ "Specified test executable does not exist.\n"
+ " Path: '${_TEST_EXECUTABLE}'"
+ )
+ endif()
+ execute_process(
+ COMMAND ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" --gtest_list_tests
+ WORKING_DIRECTORY "${_TEST_WORKING_DIR}"
+ TIMEOUT ${_TEST_DISCOVERY_TIMEOUT}
+ OUTPUT_VARIABLE output
+ RESULT_VARIABLE result
+ )
+ if(NOT ${result} EQUAL 0)
+ string(REPLACE "\n" "\n " output "${output}")
+ message(FATAL_ERROR
+ "Error running test executable.\n"
+ " Path: '${_TEST_EXECUTABLE}'\n"
+ " Result: ${result}\n"
+ " Output:\n"
+ " ${output}\n"
+ )
+ endif()
+
+ # Preserve semicolon in test-parameters
+ string(REPLACE [[;]] [[\;]] output "${output}")
+ string(REPLACE "\n" ";" output "${output}")
+
+ # Parse output
+ foreach(line ${output})
+ # Skip header
+ if(NOT line MATCHES "gtest_main\\.cc")
+ # Do we have a module name or a test name?
+ if(NOT line MATCHES "^ ")
+ # Module; remove trailing '.' to get just the name...
+ string(REGEX REPLACE "\\.( *#.*)?" "" suite "${line}")
+ if(line MATCHES "#" AND NOT _NO_PRETTY_TYPES)
+ string(REGEX REPLACE "/[0-9]\\.+ +#.*= +" "/" pretty_suite "${line}")
+ else()
+ set(pretty_suite "${suite}")
+ endif()
+ string(REGEX REPLACE "^DISABLED_" "" pretty_suite "${pretty_suite}")
+ else()
+ # Test name; strip spaces and comments to get just the name...
+ string(REGEX REPLACE " +" "" test "${line}")
+ if(test MATCHES "#" AND NOT _NO_PRETTY_VALUES)
+ string(REGEX REPLACE "/[0-9]+#GetParam..=" "/" pretty_test "${test}")
+ else()
+ string(REGEX REPLACE "#.*" "" pretty_test "${test}")
+ endif()
+ string(REGEX REPLACE "^DISABLED_" "" pretty_test "${pretty_test}")
+ string(REGEX REPLACE "#.*" "" test "${test}")
+ if(NOT "${_TEST_XML_OUTPUT_DIR}" STREQUAL "")
+ set(TEST_XML_OUTPUT_PARAM "--gtest_output=xml:${_TEST_XML_OUTPUT_DIR}/${prefix}${suite}.${test}${suffix}.xml")
+ else()
+ unset(TEST_XML_OUTPUT_PARAM)
+ endif()
+
+ # sanitize test name for further processing downstream
+ set(testname "${prefix}${pretty_suite}.${pretty_test}${suffix}")
+ # escape \
+ string(REPLACE [[\]] [[\\]] testname "${testname}")
+ # escape ;
+ string(REPLACE [[;]] [[\;]] testname "${testname}")
+ # escape $
+ string(REPLACE [[$]] [[\$]] testname "${testname}")
+
+ # ...and add to script
+ add_command(add_test
+ "${testname}"
+ ${_TEST_EXECUTOR}
+ "${_TEST_EXECUTABLE}"
+ "--gtest_filter=${suite}.${test}"
+ "--gtest_also_run_disabled_tests"
+ ${TEST_XML_OUTPUT_PARAM}
+ ${extra_args}
+ )
+ if(suite MATCHES "^DISABLED" OR test MATCHES "^DISABLED")
+ add_command(set_tests_properties
+ "${testname}"
+ PROPERTIES DISABLED TRUE
+ )
+ endif()
+ add_command(set_tests_properties
+ "${testname}"
+ PROPERTIES
+ WORKING_DIRECTORY "${_TEST_WORKING_DIR}"
+ SKIP_REGULAR_EXPRESSION "\\\\[ SKIPPED \\\\]"
+ ${properties}
+ )
+ list(APPEND tests_buffer "${testname}")
+ list(LENGTH tests_buffer tests_buffer_length)
+ if(${tests_buffer_length} GREATER "250")
+ flush_tests_buffer()
+ endif()
+ endif()
+ endif()
+ endforeach()
+
+
+ # Create a list of all discovered tests, which users may use to e.g. set
+ # properties on the tests
+ flush_tests_buffer()
+ add_command(set ${_TEST_LIST} ${tests})
+
+ # Write CTest script
+ flush_script()
+
+endfunction()
+
+if(CMAKE_SCRIPT_MODE_FILE)
+ gtest_discover_tests_impl(
+ NO_PRETTY_TYPES ${NO_PRETTY_TYPES}
+ NO_PRETTY_VALUES ${NO_PRETTY_VALUES}
+ TEST_EXECUTABLE ${TEST_EXECUTABLE}
+ TEST_EXECUTOR ${TEST_EXECUTOR}
+ TEST_WORKING_DIR ${TEST_WORKING_DIR}
+ TEST_PREFIX ${TEST_PREFIX}
+ TEST_SUFFIX ${TEST_SUFFIX}
+ TEST_LIST ${TEST_LIST}
+ CTEST_FILE ${CTEST_FILE}
+ TEST_DISCOVERY_TIMEOUT ${TEST_DISCOVERY_TIMEOUT}
+ TEST_XML_OUTPUT_DIR ${TEST_XML_OUTPUT_DIR}
+ TEST_EXTRA_ARGS ${TEST_EXTRA_ARGS}
+ TEST_PROPERTIES ${TEST_PROPERTIES}
+ )
+endif()
diff --git a/build_files/cmake/config/blender_full.cmake b/build_files/cmake/config/blender_full.cmake
index 41bee263e22..7d3284af158 100644
--- a/build_files/cmake/config/blender_full.cmake
+++ b/build_files/cmake/config/blender_full.cmake
@@ -15,6 +15,7 @@ set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
set(WITH_DRACO ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
+set(WITH_GMP OFF CACHE BOOL "" FORCE)
set(WITH_LIBMV ON CACHE BOOL "" FORCE)
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS ON CACHE BOOL "" FORCE)
set(WITH_COMPOSITOR ON CACHE BOOL "" FORCE)
diff --git a/build_files/cmake/config/blender_lite.cmake b/build_files/cmake/config/blender_lite.cmake
index 68b9bd1d94d..16c15961c59 100644
--- a/build_files/cmake/config/blender_lite.cmake
+++ b/build_files/cmake/config/blender_lite.cmake
@@ -20,6 +20,7 @@ set(WITH_CYCLES_OSL OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEVICE_OPTIX OFF CACHE BOOL "" FORCE)
set(WITH_DRACO OFF CACHE BOOL "" FORCE)
set(WITH_FFTW3 OFF CACHE BOOL "" FORCE)
+set(WITH_GMP OFF CACHE BOOL "" FORCE)
set(WITH_LIBMV OFF CACHE BOOL "" FORCE)
set(WITH_LLVM OFF CACHE BOOL "" FORCE)
set(WITH_COMPOSITOR OFF CACHE BOOL "" FORCE)
diff --git a/build_files/cmake/config/blender_release.cmake b/build_files/cmake/config/blender_release.cmake
index e6fc73a75ed..ddd9aa1d766 100644
--- a/build_files/cmake/config/blender_release.cmake
+++ b/build_files/cmake/config/blender_release.cmake
@@ -16,6 +16,7 @@ set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
set(WITH_DRACO ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
+set(WITH_GMP OFF CACHE BOOL "" FORCE)
set(WITH_LIBMV ON CACHE BOOL "" FORCE)
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS ON CACHE BOOL "" FORCE)
set(WITH_COMPOSITOR ON CACHE BOOL "" FORCE)
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 708efc3d2f7..51cfadecc3e 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -169,6 +169,26 @@ function(blender_include_dirs_sys
include_directories(SYSTEM ${_ALL_INCS})
endfunction()
+# Set include paths for header files included with "*.h" syntax.
+# This enables auto-complete suggestions for user header files on Xcode.
+# Build process is not affected since the include paths are the same
+# as in HEADER_SEARCH_PATHS.
+function(blender_user_header_search_paths
+ name
+ includes
+ )
+
+ if(XCODE)
+ set(_ALL_INCS "")
+ foreach(_INC ${includes})
+ get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
+ # _ALL_INCS is a space-separated string of file paths in quotes.
+ set(_ALL_INCS "${_ALL_INCS} \"${_ABS_INC}\"")
+ endforeach()
+ set_target_properties(${name} PROPERTIES XCODE_ATTRIBUTE_USER_HEADER_SEARCH_PATHS "${_ALL_INCS}")
+ endif()
+endfunction()
+
function(blender_source_group
name
sources
@@ -317,6 +337,7 @@ function(blender_add_lib__impl
# works fine without having the includes
# listed is helpful for IDE's (QtCreator/MSVC)
blender_source_group("${name}" "${sources}")
+ blender_user_header_search_paths("${name}" "${includes}")
list_assert_duplicates("${sources}")
list_assert_duplicates("${includes}")
@@ -397,7 +418,7 @@ function(setup_heavy_lib_pool)
list(APPEND _HEAVY_LIBS "cycles_device" "cycles_kernel")
endif()
if(WITH_LIBMV)
- list(APPEND _HEAVY_LIBS "bf_intern_libmv")
+ list(APPEND _HEAVY_LIBS "extern_ceres" "bf_intern_libmv")
endif()
if(WITH_OPENVDB)
list(APPEND _HEAVY_LIBS "bf_intern_openvdb")
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index a80b0b56901..5949e761551 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -430,13 +430,21 @@ if(WITH_OPENMP)
endif()
if(WITH_XR_OPENXR)
- find_package(OpenXR-SDK)
- if(NOT OPENXR_SDK_FOUND)
+ find_package(XR_OpenXR_SDK)
+ if(NOT XR_OPENXR_SDK_FOUND)
message(WARNING "OpenXR-SDK was not found, disabling WITH_XR_OPENXR")
set(WITH_XR_OPENXR OFF)
endif()
endif()
+if(WITH_GMP)
+ find_package(GMP)
+ if(NOT GMP_FOUND)
+ message(WARNING "GMP not found, disabling WITH_GMP")
+ set(WITH_GMP OFF)
+ endif()
+endif()
+
set(EXETYPE MACOSX_BUNDLE)
set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index c5e8893424b..83909a0cf66 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -234,10 +234,10 @@ endif()
if(WITH_CYCLES_OSL)
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
- if(NOT OSL_ROOT)
+ if(EXISTS ${CYCLES_OSL} AND NOT OSL_ROOT)
set(OSL_ROOT ${CYCLES_OSL})
endif()
- find_package_wrapper(OpenShadingLanguage)
+ find_package_wrapper(OSL)
if(OSL_FOUND)
if(${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6")
# Note: --whole-archive is needed to force loading of all symbols in liboslexec,
@@ -428,13 +428,21 @@ if(WITH_TBB)
endif()
if(WITH_XR_OPENXR)
- find_package(XR-OpenXR-SDK)
+ find_package(XR_OpenXR_SDK)
if(NOT XR_OPENXR_SDK_FOUND)
message(WARNING "OpenXR-SDK not found, disabling WITH_XR_OPENXR")
set(WITH_XR_OPENXR OFF)
endif()
endif()
+if(WITH_GMP)
+ find_package_wrapper(GMP)
+ if(NOT GMP_FOUND)
+ message(WARNING "GMP not found, disabling WITH_GMP")
+ set(WITH_GMP OFF)
+ endif()
+endif()
+
if(EXISTS ${LIBDIR})
without_system_libs_end()
endif()
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 01d48364435..dfcd5d75444 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -750,3 +750,10 @@ if(WITH_XR_OPENXR)
set(WITH_XR_OPENXR OFF)
endif()
endif()
+
+if(WITH_GMP)
+ set(GMP_INCLUDE_DIRS ${LIBDIR}/gmp/include)
+ set(GMP_LIBRARIES ${LIBDIR}/gmp/lib/libgmp-10.lib optimized ${LIBDIR}/gmp/lib/libgmpxx.lib debug ${LIBDIR}/gmp/lib/libgmpxx_d.lib)
+ set(GMP_ROOT_DIR ${LIBDIR}/gmp)
+ set(GMP_FOUND On)
+endif()
diff --git a/doc/python_api/examples/gpu.7.py b/doc/python_api/examples/gpu.7.py
index 56cbb93c61a..d6055898807 100644
--- a/doc/python_api/examples/gpu.7.py
+++ b/doc/python_api/examples/gpu.7.py
@@ -20,6 +20,7 @@ from gpu_extras.presets import draw_circle_2d
offscreen = gpu.types.GPUOffScreen(512, 512)
with offscreen.bind():
+ bgl.glClearColor(0.0, 0.0, 0.0, 0.0)
bgl.glClear(bgl.GL_COLOR_BUFFER_BIT)
with gpu.matrix.push_pop():
# reset matrices -> use normalized device coordinates [-1, 1]
diff --git a/doc/python_api/examples/gpu.8.py b/doc/python_api/examples/gpu.8.py
index 470bd8a2dad..e67c601def9 100644
--- a/doc/python_api/examples/gpu.8.py
+++ b/doc/python_api/examples/gpu.8.py
@@ -25,6 +25,7 @@ RING_AMOUNT = 10
offscreen = gpu.types.GPUOffScreen(WIDTH, HEIGHT)
with offscreen.bind():
+ bgl.glClearColor(0.0, 0.0, 0.0, 0.0)
bgl.glClear(bgl.GL_COLOR_BUFFER_BIT)
with gpu.matrix.push_pop():
# reset matrices -> use normalized device coordinates [-1, 1]
diff --git a/extern/audaspace/bindings/python/PySound.cpp b/extern/audaspace/bindings/python/PySound.cpp
index 62ee3435e82..f2debccfd33 100644
--- a/extern/audaspace/bindings/python/PySound.cpp
+++ b/extern/audaspace/bindings/python/PySound.cpp
@@ -1395,9 +1395,9 @@ PyDoc_STRVAR(M_aud_Sound_threshold_doc,
" all between to 0.\n\n"
" :arg threshold: Threshold value over which an amplitude counts\n"
" non-zero.\n\n"
- ":type threshold: float\n"
- ":return: The created :class:`Sound` object.\n"
- ":rtype: :class:`Sound`");
+ " :type threshold: float\n"
+ " :return: The created :class:`Sound` object.\n"
+ " :rtype: :class:`Sound`");
static PyObject *
Sound_threshold(Sound* self, PyObject* args)
diff --git a/extern/audaspace/src/respec/JOSResampleReader.cpp b/extern/audaspace/src/respec/JOSResampleReader.cpp
index 6753a2e8b6b..378986fee28 100644
--- a/extern/audaspace/src/respec/JOSResampleReader.cpp
+++ b/extern/audaspace/src/respec/JOSResampleReader.cpp
@@ -119,8 +119,8 @@ void JOSResampleReader::updateBuffer(int size, double factor, int samplesize)
P = int_to_fp(m_L) - P;\
\
end = std::floor((m_len - 1) / double(m_L) + m_P) - 1;\
- if(m_cache_valid - m_n - 2 < end)\
- end = m_cache_valid - m_n - 2;\
+ if(m_cache_valid - int(m_n) - 2 < end)\
+ end = m_cache_valid - int(m_n) - 2;\
\
data = buf + (m_n + 2 + end) * m_channels - 1;\
l = fp_to_int(P);\
@@ -166,8 +166,8 @@ void JOSResampleReader::updateBuffer(int size, double factor, int samplesize)
P = 0 - P;\
\
end = (int_to_fp(m_len) - P) / P_increment - 1;\
- if(m_cache_valid - m_n - 2 < end)\
- end = m_cache_valid - m_n - 2;\
+ if(m_cache_valid - int(m_n) - 2 < end)\
+ end = m_cache_valid - int(m_n) - 2;\
\
P += P_increment * end;\
data = buf + (m_n + 2 + end) * m_channels - 1;\
diff --git a/extern/bullet2/patches/btPolyhedralConvexShape_Inertia_fix.patch b/extern/bullet2/patches/btPolyhedralConvexShape_Inertia_fix.patch
new file mode 100644
index 00000000000..abafb5855dd
--- /dev/null
+++ b/extern/bullet2/patches/btPolyhedralConvexShape_Inertia_fix.patch
@@ -0,0 +1,41 @@
+diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
+index 9095c592d87..b831e20c2f9 100644
+--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
++++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
+@@ -406,17 +406,17 @@ void btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& ine
+ #ifndef __SPU__
+ //not yet, return box inertia
+
+- btScalar margin = getMargin();
++ //btScalar margin = getMargin();
+
+ btTransform ident;
+ ident.setIdentity();
+ btVector3 aabbMin,aabbMax;
+- getAabb(ident,aabbMin,aabbMax);
++ getAabb(ident,aabbMin,aabbMax); // This already contains the margin
+ btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
+
+- btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
+- btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
+- btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
++ btScalar lx=btScalar(2.)*(halfExtents.x());
++ btScalar ly=btScalar(2.)*(halfExtents.y());
++ btScalar lz=btScalar(2.)*(halfExtents.z());
+ const btScalar x2 = lx*lx;
+ const btScalar y2 = ly*ly;
+ const btScalar z2 = lz*lz;
+@@ -476,10 +476,10 @@ void btPolyhedralConvexAabbCachingShape::recalcLocalAabb()
+
+ for ( int i = 0; i < 3; ++i )
+ {
+- m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin;
+- m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin;
++ m_localAabbMax[i] = _supporting[i][i];
++ m_localAabbMin[i] = _supporting[i + 3][i];
+ }
+-
++
+ #else
+
+ for (int i=0;i<3;i++)
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
index e8c8c336cd2..1e7f36e0a17 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
@@ -180,7 +180,7 @@ void btCompoundShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVect
localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
- btMatrix3x3 abs_b = trans.getBasis().absolute();
+ btMatrix3x3 abs_b = trans.getBasis().absolute();
btVector3 center = trans(localCenter);
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
index 9095c592d87..b831e20c2f9 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
@@ -406,17 +406,17 @@ void btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& ine
#ifndef __SPU__
//not yet, return box inertia
- btScalar margin = getMargin();
+ //btScalar margin = getMargin();
btTransform ident;
ident.setIdentity();
btVector3 aabbMin,aabbMax;
- getAabb(ident,aabbMin,aabbMax);
+ getAabb(ident,aabbMin,aabbMax); // This already contains the margin
btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
- btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
- btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
- btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
+ btScalar lx=btScalar(2.)*(halfExtents.x());
+ btScalar ly=btScalar(2.)*(halfExtents.y());
+ btScalar lz=btScalar(2.)*(halfExtents.z());
const btScalar x2 = lx*lx;
const btScalar y2 = ly*ly;
const btScalar z2 = lz*lz;
@@ -476,10 +476,10 @@ void btPolyhedralConvexAabbCachingShape::recalcLocalAabb()
for ( int i = 0; i < 3; ++i )
{
- m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin;
- m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin;
+ m_localAabbMax[i] = _supporting[i][i];
+ m_localAabbMin[i] = _supporting[i + 3][i];
}
-
+
#else
for (int i=0;i<3;i++)
diff --git a/extern/mantaflow/preprocessed/gitinfo.h b/extern/mantaflow/preprocessed/gitinfo.h
index ce088d6c400..e87c8739cf4 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
-#define MANTA_GIT_VERSION "commit 841bfd09c068dfb95637c0ec14fa78305286a433"
+#define MANTA_GIT_VERSION "commit e2f6e59e3679f88e5100ae2145410cca4971b9df"
diff --git a/extern/mantaflow/preprocessed/grid.h b/extern/mantaflow/preprocessed/grid.h
index a7aac80891a..9bd4e5d72d9 100644
--- a/extern/mantaflow/preprocessed/grid.h
+++ b/extern/mantaflow/preprocessed/grid.h
@@ -355,6 +355,38 @@ class GridBase : public PbClass {
return isInBounds(Vec3i(i, j, k), bnd);
}
+#ifdef BLENDER
+ //! expose name field to Python for Blender
+ void setName(const std::string &name)
+ {
+ mName = name;
+ }
+ static PyObject *_W_9(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ {
+ try {
+ PbArgs _args(_linargs, _kwds);
+ GridBase *pbo = dynamic_cast<GridBase *>(Pb::objFromPy(_self));
+ bool noTiming = _args.getOpt<bool>("notiming", -1, 0);
+ pbPreparePlugin(pbo->getParent(), "GridBase::setName", !noTiming);
+ PyObject *_retval = 0;
+ {
+ ArgLocker _lock;
+ const std::string &name = _args.get<std::string>("name", 0, &_lock);
+ pbo->_args.copy(_args);
+ _retval = getPyNone();
+ pbo->setName(name);
+ pbo->_args.check();
+ }
+ pbFinalizePlugin(pbo->getParent(), "GridBase::setName", !noTiming);
+ return _retval;
+ }
+ catch (std::exception &e) {
+ pbSetError("GridBase::setName", e.what());
+ return 0;
+ }
+ }
+
+#endif
protected:
GridType mType;
Vec3i mSize;
@@ -373,7 +405,7 @@ template<class T> class Grid : public GridBase {
public:
//! init new grid, values are set to zero
Grid(FluidSolver *parent, bool show = true);
- static int _W_9(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static int _W_10(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
PbClass *obj = Pb::objFromPy(_self);
if (obj)
@@ -410,7 +442,7 @@ template<class T> class Grid : public GridBase {
typedef GridBase BASETYPE_GRID;
int save(std::string name);
- static PyObject *_W_10(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_11(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -435,7 +467,7 @@ template<class T> class Grid : public GridBase {
}
int load(std::string name);
- static PyObject *_W_11(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_12(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -461,7 +493,7 @@ template<class T> class Grid : public GridBase {
//! set all cells to zero
void clear();
- static PyObject *_W_12(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_13(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -588,7 +620,7 @@ template<class T> class Grid : public GridBase {
// Grid<T>& operator=(const Grid<T>& a);
//! copy content from other grid (use this one instead of operator= !)
Grid<T> &copyFrom(const Grid<T> &a, bool copyType = true);
- static PyObject *_W_13(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_14(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -618,7 +650,7 @@ template<class T> class Grid : public GridBase {
//! get grid type
int getGridType();
- static PyObject *_W_14(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_15(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -643,7 +675,7 @@ template<class T> class Grid : public GridBase {
//! add/subtract other grid
void add(const Grid<T> &a);
- static PyObject *_W_15(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_16(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -669,7 +701,7 @@ template<class T> class Grid : public GridBase {
}
void sub(const Grid<T> &a);
- static PyObject *_W_16(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_17(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -696,7 +728,7 @@ template<class T> class Grid : public GridBase {
//! set all cells to constant value
void setConst(T s);
- static PyObject *_W_17(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_18(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -723,7 +755,7 @@ template<class T> class Grid : public GridBase {
//! add constant to all grid cells
void addConst(T s);
- static PyObject *_W_18(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_19(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -750,7 +782,7 @@ template<class T> class Grid : public GridBase {
//! add scaled other grid to current one (note, only "Real" factor, "T" type not supported here!)
void addScaled(const Grid<T> &a, const T &factor);
- static PyObject *_W_19(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_20(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -778,7 +810,7 @@ template<class T> class Grid : public GridBase {
//! multiply contents of grid
void mult(const Grid<T> &a);
- static PyObject *_W_20(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_21(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -805,7 +837,7 @@ template<class T> class Grid : public GridBase {
//! multiply each cell by a constant scalar value
void multConst(T s);
- static PyObject *_W_21(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_22(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -832,7 +864,7 @@ template<class T> class Grid : public GridBase {
//! safely divide contents of grid (with zero check)
Grid<T> &safeDivide(const Grid<T> &a);
- static PyObject *_W_22(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_23(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -858,7 +890,7 @@ template<class T> class Grid : public GridBase {
//! clamp content to range (for vec3, clamps each component separately)
void clamp(Real min, Real max);
- static PyObject *_W_23(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_24(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -886,7 +918,7 @@ template<class T> class Grid : public GridBase {
//! reduce small values to zero
void stomp(const T &threshold);
- static PyObject *_W_24(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_25(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -913,7 +945,7 @@ template<class T> class Grid : public GridBase {
//! permute grid axes, e.g. switch y with z (0,2,1)
void permuteAxes(int axis0, int axis1, int axis2);
- static PyObject *_W_25(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_26(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -942,7 +974,7 @@ template<class T> class Grid : public GridBase {
//! permute grid axes, e.g. switch y with z (0,2,1)
void permuteAxesCopyToGrid(int axis0, int axis1, int axis2, Grid<T> &out);
- static PyObject *_W_26(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_27(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -972,7 +1004,7 @@ template<class T> class Grid : public GridBase {
//! join other grid by either keeping min or max value at cell
void join(const Grid<T> &a, bool keepMax = true);
- static PyObject *_W_27(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_28(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1001,7 +1033,7 @@ template<class T> class Grid : public GridBase {
// common compound operators
//! get absolute max value in grid
Real getMaxAbs() const;
- static PyObject *_W_28(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_29(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1026,7 +1058,7 @@ template<class T> class Grid : public GridBase {
//! get max value in grid
Real getMax() const;
- static PyObject *_W_29(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_30(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1051,7 +1083,7 @@ template<class T> class Grid : public GridBase {
//! get min value in grid
Real getMin() const;
- static PyObject *_W_30(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_31(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1076,7 +1108,7 @@ template<class T> class Grid : public GridBase {
//! calculate L1 norm of grid content
Real getL1(int bnd = 0);
- static PyObject *_W_31(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_32(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1102,7 +1134,7 @@ template<class T> class Grid : public GridBase {
//! calculate L2 norm of grid content
Real getL2(int bnd = 0);
- static PyObject *_W_32(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_33(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1128,7 +1160,7 @@ template<class T> class Grid : public GridBase {
//! set all boundary cells to constant value (Dirichlet)
void setBound(T value, int boundaryWidth = 1);
- static PyObject *_W_33(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_34(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1156,7 +1188,7 @@ template<class T> class Grid : public GridBase {
//! set all boundary cells to last inner value (Neumann)
void setBoundNeumann(int boundaryWidth = 1);
- static PyObject *_W_34(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_35(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1183,7 +1215,7 @@ template<class T> class Grid : public GridBase {
//! get data pointer of grid
std::string getDataPointer();
- static PyObject *_W_35(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_36(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1208,7 +1240,7 @@ template<class T> class Grid : public GridBase {
//! debugging helper, print grid from python. skip boundary of width bnd
void printGrid(int zSlice = -1, bool printIndex = false, int bnd = 1);
- static PyObject *_W_36(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_37(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1276,7 +1308,7 @@ class MACGrid : public Grid<Vec3> {
{
mType = (GridType)(TypeMAC | TypeVec3);
}
- static int _W_37(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static int _W_38(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
PbClass *obj = Pb::objFromPy(_self);
if (obj)
@@ -1358,7 +1390,7 @@ class MACGrid : public Grid<Vec3> {
//! set all boundary cells of a MAC grid to certain value (Dirchlet). Respects staggered grid
//! locations optionally, only set normal components
void setBoundMAC(Vec3 value, int boundaryWidth, bool normalOnly = false);
- static PyObject *_W_38(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_39(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1399,7 +1431,7 @@ class FlagGrid : public Grid<int> {
{
mType = (GridType)(TypeFlags | TypeInt);
}
- static int _W_39(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static int _W_40(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
PbClass *obj = Pb::objFromPy(_self);
if (obj)
@@ -1579,7 +1611,7 @@ class FlagGrid : public Grid<int> {
const std::string &inflow = " ",
const std::string &outflow = " ",
Grid<Real> *phiWalls = 0x00);
- static PyObject *_W_40(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_41(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1613,7 +1645,7 @@ class FlagGrid : public Grid<int> {
//! set fluid flags inside levelset (liquids)
void updateFromLevelset(LevelsetGrid &levelset);
- static PyObject *_W_41(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_42(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1640,7 +1672,7 @@ class FlagGrid : public Grid<int> {
//! set all cells (except obs/in/outflow) to type (fluid by default)
void fillGrid(int type = TypeFluid);
- static PyObject *_W_42(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_43(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
@@ -1669,7 +1701,7 @@ class FlagGrid : public Grid<int> {
//! warning for large grids! only regular int returned (due to python interface)
//! optionally creates mask in RealGrid (1 where flag matches, 0 otherwise)
int countCells(int flag, int bnd = 0, Grid<Real> *mask = NULL);
- static PyObject *_W_43(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
+ static PyObject *_W_44(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
try {
PbArgs _args(_linargs, _kwds);
diff --git a/extern/mantaflow/preprocessed/grid.h.reg.cpp b/extern/mantaflow/preprocessed/grid.h.reg.cpp
index 9fe3e7298fa..2c95c002dad 100644
--- a/extern/mantaflow/preprocessed/grid.h.reg.cpp
+++ b/extern/mantaflow/preprocessed/grid.h.reg.cpp
@@ -8,103 +8,103 @@ namespace Manta {
#ifdef _C_FlagGrid
static const Pb::Register _R_26("FlagGrid", "FlagGrid", "Grid<int>");
template<> const char *Namify<FlagGrid>::S = "FlagGrid";
-static const Pb::Register _R_27("FlagGrid", "FlagGrid", FlagGrid::_W_39);
-static const Pb::Register _R_28("FlagGrid", "initDomain", FlagGrid::_W_40);
-static const Pb::Register _R_29("FlagGrid", "updateFromLevelset", FlagGrid::_W_41);
-static const Pb::Register _R_30("FlagGrid", "fillGrid", FlagGrid::_W_42);
-static const Pb::Register _R_31("FlagGrid", "countCells", FlagGrid::_W_43);
+static const Pb::Register _R_27("FlagGrid", "FlagGrid", FlagGrid::_W_40);
+static const Pb::Register _R_28("FlagGrid", "initDomain", FlagGrid::_W_41);
+static const Pb::Register _R_29("FlagGrid", "updateFromLevelset", FlagGrid::_W_42);
+static const Pb::Register _R_30("FlagGrid", "fillGrid", FlagGrid::_W_43);
+static const Pb::Register _R_31("FlagGrid", "countCells", FlagGrid::_W_44);
#endif
#ifdef _C_Grid
static const Pb::Register _R_32("Grid<int>", "Grid<int>", "GridBase");
template<> const char *Namify<Grid<int>>::S = "Grid<int>";
-static const Pb::Register _R_33("Grid<int>", "Grid", Grid<int>::_W_9);
-static const Pb::Register _R_34("Grid<int>", "save", Grid<int>::_W_10);
-static const Pb::Register _R_35("Grid<int>", "load", Grid<int>::_W_11);
-static const Pb::Register _R_36("Grid<int>", "clear", Grid<int>::_W_12);
-static const Pb::Register _R_37("Grid<int>", "copyFrom", Grid<int>::_W_13);
-static const Pb::Register _R_38("Grid<int>", "getGridType", Grid<int>::_W_14);
-static const Pb::Register _R_39("Grid<int>", "add", Grid<int>::_W_15);
-static const Pb::Register _R_40("Grid<int>", "sub", Grid<int>::_W_16);
-static const Pb::Register _R_41("Grid<int>", "setConst", Grid<int>::_W_17);
-static const Pb::Register _R_42("Grid<int>", "addConst", Grid<int>::_W_18);
-static const Pb::Register _R_43("Grid<int>", "addScaled", Grid<int>::_W_19);
-static const Pb::Register _R_44("Grid<int>", "mult", Grid<int>::_W_20);
-static const Pb::Register _R_45("Grid<int>", "multConst", Grid<int>::_W_21);
-static const Pb::Register _R_46("Grid<int>", "safeDivide", Grid<int>::_W_22);
-static const Pb::Register _R_47("Grid<int>", "clamp", Grid<int>::_W_23);
-static const Pb::Register _R_48("Grid<int>", "stomp", Grid<int>::_W_24);
-static const Pb::Register _R_49("Grid<int>", "permuteAxes", Grid<int>::_W_25);
-static const Pb::Register _R_50("Grid<int>", "permuteAxesCopyToGrid", Grid<int>::_W_26);
-static const Pb::Register _R_51("Grid<int>", "join", Grid<int>::_W_27);
-static const Pb::Register _R_52("Grid<int>", "getMaxAbs", Grid<int>::_W_28);
-static const Pb::Register _R_53("Grid<int>", "getMax", Grid<int>::_W_29);
-static const Pb::Register _R_54("Grid<int>", "getMin", Grid<int>::_W_30);
-static const Pb::Register _R_55("Grid<int>", "getL1", Grid<int>::_W_31);
-static const Pb::Register _R_56("Grid<int>", "getL2", Grid<int>::_W_32);
-static const Pb::Register _R_57("Grid<int>", "setBound", Grid<int>::_W_33);
-static const Pb::Register _R_58("Grid<int>", "setBoundNeumann", Grid<int>::_W_34);
-static const Pb::Register _R_59("Grid<int>", "getDataPointer", Grid<int>::_W_35);
-static const Pb::Register _R_60("Grid<int>", "printGrid", Grid<int>::_W_36);
+static const Pb::Register _R_33("Grid<int>", "Grid", Grid<int>::_W_10);
+static const Pb::Register _R_34("Grid<int>", "save", Grid<int>::_W_11);
+static const Pb::Register _R_35("Grid<int>", "load", Grid<int>::_W_12);
+static const Pb::Register _R_36("Grid<int>", "clear", Grid<int>::_W_13);
+static const Pb::Register _R_37("Grid<int>", "copyFrom", Grid<int>::_W_14);
+static const Pb::Register _R_38("Grid<int>", "getGridType", Grid<int>::_W_15);
+static const Pb::Register _R_39("Grid<int>", "add", Grid<int>::_W_16);
+static const Pb::Register _R_40("Grid<int>", "sub", Grid<int>::_W_17);
+static const Pb::Register _R_41("Grid<int>", "setConst", Grid<int>::_W_18);
+static const Pb::Register _R_42("Grid<int>", "addConst", Grid<int>::_W_19);
+static const Pb::Register _R_43("Grid<int>", "addScaled", Grid<int>::_W_20);
+static const Pb::Register _R_44("Grid<int>", "mult", Grid<int>::_W_21);
+static const Pb::Register _R_45("Grid<int>", "multConst", Grid<int>::_W_22);
+static const Pb::Register _R_46("Grid<int>", "safeDivide", Grid<int>::_W_23);
+static const Pb::Register _R_47("Grid<int>", "clamp", Grid<int>::_W_24);
+static const Pb::Register _R_48("Grid<int>", "stomp", Grid<int>::_W_25);
+static const Pb::Register _R_49("Grid<int>", "permuteAxes", Grid<int>::_W_26);
+static const Pb::Register _R_50("Grid<int>", "permuteAxesCopyToGrid", Grid<int>::_W_27);
+static const Pb::Register _R_51("Grid<int>", "join", Grid<int>::_W_28);
+static const Pb::Register _R_52("Grid<int>", "getMaxAbs", Grid<int>::_W_29);
+static const Pb::Register _R_53("Grid<int>", "getMax", Grid<int>::_W_30);
+static const Pb::Register _R_54("Grid<int>", "getMin", Grid<int>::_W_31);
+static const Pb::Register _R_55("Grid<int>", "getL1", Grid<int>::_W_32);
+static const Pb::Register _R_56("Grid<int>", "getL2", Grid<int>::_W_33);
+static const Pb::Register _R_57("Grid<int>", "setBound", Grid<int>::_W_34);
+static const Pb::Register _R_58("Grid<int>", "setBoundNeumann", Grid<int>::_W_35);
+static const Pb::Register _R_59("Grid<int>", "getDataPointer", Grid<int>::_W_36);
+static const Pb::Register _R_60("Grid<int>", "printGrid", Grid<int>::_W_37);
static const Pb::Register _R_61("Grid<Real>", "Grid<Real>", "GridBase");
template<> const char *Namify<Grid<Real>>::S = "Grid<Real>";
-static const Pb::Register _R_62("Grid<Real>", "Grid", Grid<Real>::_W_9);
-static const Pb::Register _R_63("Grid<Real>", "save", Grid<Real>::_W_10);
-static const Pb::Register _R_64("Grid<Real>", "load", Grid<Real>::_W_11);
-static const Pb::Register _R_65("Grid<Real>", "clear", Grid<Real>::_W_12);
-static const Pb::Register _R_66("Grid<Real>", "copyFrom", Grid<Real>::_W_13);
-static const Pb::Register _R_67("Grid<Real>", "getGridType", Grid<Real>::_W_14);
-static const Pb::Register _R_68("Grid<Real>", "add", Grid<Real>::_W_15);
-static const Pb::Register _R_69("Grid<Real>", "sub", Grid<Real>::_W_16);
-static const Pb::Register _R_70("Grid<Real>", "setConst", Grid<Real>::_W_17);
-static const Pb::Register _R_71("Grid<Real>", "addConst", Grid<Real>::_W_18);
-static const Pb::Register _R_72("Grid<Real>", "addScaled", Grid<Real>::_W_19);
-static const Pb::Register _R_73("Grid<Real>", "mult", Grid<Real>::_W_20);
-static const Pb::Register _R_74("Grid<Real>", "multConst", Grid<Real>::_W_21);
-static const Pb::Register _R_75("Grid<Real>", "safeDivide", Grid<Real>::_W_22);
-static const Pb::Register _R_76("Grid<Real>", "clamp", Grid<Real>::_W_23);
-static const Pb::Register _R_77("Grid<Real>", "stomp", Grid<Real>::_W_24);
-static const Pb::Register _R_78("Grid<Real>", "permuteAxes", Grid<Real>::_W_25);
-static const Pb::Register _R_79("Grid<Real>", "permuteAxesCopyToGrid", Grid<Real>::_W_26);
-static const Pb::Register _R_80("Grid<Real>", "join", Grid<Real>::_W_27);
-static const Pb::Register _R_81("Grid<Real>", "getMaxAbs", Grid<Real>::_W_28);
-static const Pb::Register _R_82("Grid<Real>", "getMax", Grid<Real>::_W_29);
-static const Pb::Register _R_83("Grid<Real>", "getMin", Grid<Real>::_W_30);
-static const Pb::Register _R_84("Grid<Real>", "getL1", Grid<Real>::_W_31);
-static const Pb::Register _R_85("Grid<Real>", "getL2", Grid<Real>::_W_32);
-static const Pb::Register _R_86("Grid<Real>", "setBound", Grid<Real>::_W_33);
-static const Pb::Register _R_87("Grid<Real>", "setBoundNeumann", Grid<Real>::_W_34);
-static const Pb::Register _R_88("Grid<Real>", "getDataPointer", Grid<Real>::_W_35);
-static const Pb::Register _R_89("Grid<Real>", "printGrid", Grid<Real>::_W_36);
+static const Pb::Register _R_62("Grid<Real>", "Grid", Grid<Real>::_W_10);
+static const Pb::Register _R_63("Grid<Real>", "save", Grid<Real>::_W_11);
+static const Pb::Register _R_64("Grid<Real>", "load", Grid<Real>::_W_12);
+static const Pb::Register _R_65("Grid<Real>", "clear", Grid<Real>::_W_13);
+static const Pb::Register _R_66("Grid<Real>", "copyFrom", Grid<Real>::_W_14);
+static const Pb::Register _R_67("Grid<Real>", "getGridType", Grid<Real>::_W_15);
+static const Pb::Register _R_68("Grid<Real>", "add", Grid<Real>::_W_16);
+static const Pb::Register _R_69("Grid<Real>", "sub", Grid<Real>::_W_17);
+static const Pb::Register _R_70("Grid<Real>", "setConst", Grid<Real>::_W_18);
+static const Pb::Register _R_71("Grid<Real>", "addConst", Grid<Real>::_W_19);
+static const Pb::Register _R_72("Grid<Real>", "addScaled", Grid<Real>::_W_20);
+static const Pb::Register _R_73("Grid<Real>", "mult", Grid<Real>::_W_21);
+static const Pb::Register _R_74("Grid<Real>", "multConst", Grid<Real>::_W_22);
+static const Pb::Register _R_75("Grid<Real>", "safeDivide", Grid<Real>::_W_23);
+static const Pb::Register _R_76("Grid<Real>", "clamp", Grid<Real>::_W_24);
+static const Pb::Register _R_77("Grid<Real>", "stomp", Grid<Real>::_W_25);
+static const Pb::Register _R_78("Grid<Real>", "permuteAxes", Grid<Real>::_W_26);
+static const Pb::Register _R_79("Grid<Real>", "permuteAxesCopyToGrid", Grid<Real>::_W_27);
+static const Pb::Register _R_80("Grid<Real>", "join", Grid<Real>::_W_28);
+static const Pb::Register _R_81("Grid<Real>", "getMaxAbs", Grid<Real>::_W_29);
+static const Pb::Register _R_82("Grid<Real>", "getMax", Grid<Real>::_W_30);
+static const Pb::Register _R_83("Grid<Real>", "getMin", Grid<Real>::_W_31);
+static const Pb::Register _R_84("Grid<Real>", "getL1", Grid<Real>::_W_32);
+static const Pb::Register _R_85("Grid<Real>", "getL2", Grid<Real>::_W_33);
+static const Pb::Register _R_86("Grid<Real>", "setBound", Grid<Real>::_W_34);
+static const Pb::Register _R_87("Grid<Real>", "setBoundNeumann", Grid<Real>::_W_35);
+static const Pb::Register _R_88("Grid<Real>", "getDataPointer", Grid<Real>::_W_36);
+static const Pb::Register _R_89("Grid<Real>", "printGrid", Grid<Real>::_W_37);
static const Pb::Register _R_90("Grid<Vec3>", "Grid<Vec3>", "GridBase");
template<> const char *Namify<Grid<Vec3>>::S = "Grid<Vec3>";
-static const Pb::Register _R_91("Grid<Vec3>", "Grid", Grid<Vec3>::_W_9);
-static const Pb::Register _R_92("Grid<Vec3>", "save", Grid<Vec3>::_W_10);
-static const Pb::Register _R_93("Grid<Vec3>", "load", Grid<Vec3>::_W_11);
-static const Pb::Register _R_94("Grid<Vec3>", "clear", Grid<Vec3>::_W_12);
-static const Pb::Register _R_95("Grid<Vec3>", "copyFrom", Grid<Vec3>::_W_13);
-static const Pb::Register _R_96("Grid<Vec3>", "getGridType", Grid<Vec3>::_W_14);
-static const Pb::Register _R_97("Grid<Vec3>", "add", Grid<Vec3>::_W_15);
-static const Pb::Register _R_98("Grid<Vec3>", "sub", Grid<Vec3>::_W_16);
-static const Pb::Register _R_99("Grid<Vec3>", "setConst", Grid<Vec3>::_W_17);
-static const Pb::Register _R_100("Grid<Vec3>", "addConst", Grid<Vec3>::_W_18);
-static const Pb::Register _R_101("Grid<Vec3>", "addScaled", Grid<Vec3>::_W_19);
-static const Pb::Register _R_102("Grid<Vec3>", "mult", Grid<Vec3>::_W_20);
-static const Pb::Register _R_103("Grid<Vec3>", "multConst", Grid<Vec3>::_W_21);
-static const Pb::Register _R_104("Grid<Vec3>", "safeDivide", Grid<Vec3>::_W_22);
-static const Pb::Register _R_105("Grid<Vec3>", "clamp", Grid<Vec3>::_W_23);
-static const Pb::Register _R_106("Grid<Vec3>", "stomp", Grid<Vec3>::_W_24);
-static const Pb::Register _R_107("Grid<Vec3>", "permuteAxes", Grid<Vec3>::_W_25);
-static const Pb::Register _R_108("Grid<Vec3>", "permuteAxesCopyToGrid", Grid<Vec3>::_W_26);
-static const Pb::Register _R_109("Grid<Vec3>", "join", Grid<Vec3>::_W_27);
-static const Pb::Register _R_110("Grid<Vec3>", "getMaxAbs", Grid<Vec3>::_W_28);
-static const Pb::Register _R_111("Grid<Vec3>", "getMax", Grid<Vec3>::_W_29);
-static const Pb::Register _R_112("Grid<Vec3>", "getMin", Grid<Vec3>::_W_30);
-static const Pb::Register _R_113("Grid<Vec3>", "getL1", Grid<Vec3>::_W_31);
-static const Pb::Register _R_114("Grid<Vec3>", "getL2", Grid<Vec3>::_W_32);
-static const Pb::Register _R_115("Grid<Vec3>", "setBound", Grid<Vec3>::_W_33);
-static const Pb::Register _R_116("Grid<Vec3>", "setBoundNeumann", Grid<Vec3>::_W_34);
-static const Pb::Register _R_117("Grid<Vec3>", "getDataPointer", Grid<Vec3>::_W_35);
-static const Pb::Register _R_118("Grid<Vec3>", "printGrid", Grid<Vec3>::_W_36);
+static const Pb::Register _R_91("Grid<Vec3>", "Grid", Grid<Vec3>::_W_10);
+static const Pb::Register _R_92("Grid<Vec3>", "save", Grid<Vec3>::_W_11);
+static const Pb::Register _R_93("Grid<Vec3>", "load", Grid<Vec3>::_W_12);
+static const Pb::Register _R_94("Grid<Vec3>", "clear", Grid<Vec3>::_W_13);
+static const Pb::Register _R_95("Grid<Vec3>", "copyFrom", Grid<Vec3>::_W_14);
+static const Pb::Register _R_96("Grid<Vec3>", "getGridType", Grid<Vec3>::_W_15);
+static const Pb::Register _R_97("Grid<Vec3>", "add", Grid<Vec3>::_W_16);
+static const Pb::Register _R_98("Grid<Vec3>", "sub", Grid<Vec3>::_W_17);
+static const Pb::Register _R_99("Grid<Vec3>", "setConst", Grid<Vec3>::_W_18);
+static const Pb::Register _R_100("Grid<Vec3>", "addConst", Grid<Vec3>::_W_19);
+static const Pb::Register _R_101("Grid<Vec3>", "addScaled", Grid<Vec3>::_W_20);
+static const Pb::Register _R_102("Grid<Vec3>", "mult", Grid<Vec3>::_W_21);
+static const Pb::Register _R_103("Grid<Vec3>", "multConst", Grid<Vec3>::_W_22);
+static const Pb::Register _R_104("Grid<Vec3>", "safeDivide", Grid<Vec3>::_W_23);
+static const Pb::Register _R_105("Grid<Vec3>", "clamp", Grid<Vec3>::_W_24);
+static const Pb::Register _R_106("Grid<Vec3>", "stomp", Grid<Vec3>::_W_25);
+static const Pb::Register _R_107("Grid<Vec3>", "permuteAxes", Grid<Vec3>::_W_26);
+static const Pb::Register _R_108("Grid<Vec3>", "permuteAxesCopyToGrid", Grid<Vec3>::_W_27);
+static const Pb::Register _R_109("Grid<Vec3>", "join", Grid<Vec3>::_W_28);
+static const Pb::Register _R_110("Grid<Vec3>", "getMaxAbs", Grid<Vec3>::_W_29);
+static const Pb::Register _R_111("Grid<Vec3>", "getMax", Grid<Vec3>::_W_30);
+static const Pb::Register _R_112("Grid<Vec3>", "getMin", Grid<Vec3>::_W_31);
+static const Pb::Register _R_113("Grid<Vec3>", "getL1", Grid<Vec3>::_W_32);
+static const Pb::Register _R_114("Grid<Vec3>", "getL2", Grid<Vec3>::_W_33);
+static const Pb::Register _R_115("Grid<Vec3>", "setBound", Grid<Vec3>::_W_34);
+static const Pb::Register _R_116("Grid<Vec3>", "setBoundNeumann", Grid<Vec3>::_W_35);
+static const Pb::Register _R_117("Grid<Vec3>", "getDataPointer", Grid<Vec3>::_W_36);
+static const Pb::Register _R_118("Grid<Vec3>", "printGrid", Grid<Vec3>::_W_37);
#endif
#ifdef _C_GridBase
static const Pb::Register _R_119("GridBase", "GridBase", "PbClass");
@@ -118,12 +118,13 @@ static const Pb::Register _R_125("GridBase", "is3D", GridBase::_W_5);
static const Pb::Register _R_126("GridBase", "is4D", GridBase::_W_6);
static const Pb::Register _R_127("GridBase", "getSizeT", GridBase::_W_7);
static const Pb::Register _R_128("GridBase", "getStrideT", GridBase::_W_8);
+static const Pb::Register _R_129("GridBase", "setName", GridBase::_W_9);
#endif
#ifdef _C_MACGrid
-static const Pb::Register _R_129("MACGrid", "MACGrid", "Grid<Vec3>");
+static const Pb::Register _R_130("MACGrid", "MACGrid", "Grid<Vec3>");
template<> const char *Namify<MACGrid>::S = "MACGrid";
-static const Pb::Register _R_130("MACGrid", "MACGrid", MACGrid::_W_37);
-static const Pb::Register _R_131("MACGrid", "setBoundMAC", MACGrid::_W_38);
+static const Pb::Register _R_131("MACGrid", "MACGrid", MACGrid::_W_38);
+static const Pb::Register _R_132("MACGrid", "setBoundMAC", MACGrid::_W_39);
#endif
static const Pb::Register _R_7("GridType_TypeNone", 0);
static const Pb::Register _R_8("GridType_TypeReal", 1);
@@ -253,6 +254,7 @@ void PbRegister_file_7()
KEEP_UNUSED(_R_129);
KEEP_UNUSED(_R_130);
KEEP_UNUSED(_R_131);
+ KEEP_UNUSED(_R_132);
}
}
} // namespace Manta \ No newline at end of file
diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index 0758567bb78..c1792a312b2 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -77,6 +77,10 @@ if(WITH_QUADRIFLOW)
add_subdirectory(quadriflow)
endif()
+if(WITH_CODEC_FFMPEG)
+ add_subdirectory(ffmpeg)
+endif()
+
if(UNIX AND NOT APPLE)
add_subdirectory(libc_compat)
endif()
diff --git a/intern/clog/clog.c b/intern/clog/clog.c
index 921ee17a672..d384b9a89e6 100644
--- a/intern/clog/clog.c
+++ b/intern/clog/clog.c
@@ -153,7 +153,6 @@ static void clg_str_reserve(CLogStringBuf *cstr, const uint len)
cstr->data = data;
cstr->is_alloc = true;
}
- cstr->len_alloc = len;
}
}
@@ -179,26 +178,34 @@ static void clg_str_vappendf(CLogStringBuf *cstr, const char *fmt, va_list args)
{
/* Use limit because windows may use '-1' for a formatting error. */
const uint len_max = 65535;
- uint len_avail = (cstr->len_alloc - cstr->len);
- if (len_avail == 0) {
- len_avail = CLOG_BUF_LEN_INIT;
- clg_str_reserve(cstr, len_avail);
- }
while (true) {
+ uint len_avail = cstr->len_alloc - cstr->len;
+
va_list args_cpy;
va_copy(args_cpy, args);
int retval = vsnprintf(cstr->data + cstr->len, len_avail, fmt, args_cpy);
va_end(args_cpy);
- if (retval != -1) {
- cstr->len += retval;
+
+ if (retval < 0) {
+ /* Some encoding error happened, not much we can do here, besides skipping/cancelling this
+ * message. */
+ break;
+ }
+ else if ((uint)retval <= len_avail) {
+ /* Copy was successful. */
+ cstr->len += (uint)retval;
break;
}
else {
- len_avail *= 2;
- if (len_avail >= len_max) {
+ /* vsnprintf was not successful, due to lack of allocated space, retval contains expected
+ * length of the formated string, use it to allocate required amount of memory. */
+ uint len_alloc = cstr->len + (uint)retval;
+ if (len_alloc >= len_max) {
+ /* Safe upper-limit, just in case... */
break;
}
- clg_str_reserve(cstr, len_avail);
+ clg_str_reserve(cstr, len_alloc);
+ len_avail = cstr->len_alloc - cstr->len;
}
}
}
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 49407799fcd..f4354d5166e 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -923,6 +923,74 @@ static void create_subd_mesh(Scene *scene,
/* Sync */
+static BL::MeshSequenceCacheModifier object_mesh_cache_find(BL::Object &b_ob,
+ BL::Scene /*b_scene*/)
+{
+ BL::Object::modifiers_iterator b_mod;
+
+ for (b_ob.modifiers.begin(b_mod); b_mod != b_ob.modifiers.end(); ++b_mod) {
+ if (!b_mod->is_a(&RNA_MeshSequenceCacheModifier)) {
+ continue;
+ }
+
+ BL::MeshSequenceCacheModifier mesh_cache = BL::MeshSequenceCacheModifier(*b_mod);
+
+ if (MeshSequenceCacheModifier_has_velocity_get(&mesh_cache.ptr)) {
+ return mesh_cache;
+ }
+ }
+
+ return BL::MeshSequenceCacheModifier(PointerRNA_NULL);
+}
+
+static void sync_mesh_cached_velocities(BL::Object &b_ob,
+ BL::Scene b_scene,
+ Scene *scene,
+ Mesh *mesh)
+{
+ if (scene->need_motion() == Scene::MOTION_NONE)
+ return;
+
+ BL::MeshSequenceCacheModifier b_mesh_cache = object_mesh_cache_find(b_ob, b_scene);
+
+ if (!b_mesh_cache) {
+ return;
+ }
+
+ /* Find or add attribute */
+ float3 *P = &mesh->verts[0];
+ Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
+
+ if (!attr_mP) {
+ attr_mP = mesh->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION);
+ }
+
+ if (!MeshSequenceCacheModifier_read_velocity_get(&b_mesh_cache.ptr)) {
+ return;
+ }
+
+ const size_t numverts = mesh->verts.size();
+
+ if (b_mesh_cache.vertex_velocities.length() != numverts) {
+ return;
+ }
+
+ /* Only export previous and next frame, we don't have any in between data. */
+ float motion_times[2] = {-1.0f, 1.0f};
+ for (int step = 0; step < 2; step++) {
+ const float relative_time = motion_times[step] * scene->motion_shutter_time() * 0.5f;
+ float3 *mP = attr_mP->data_float3() + step * numverts;
+
+ BL::MeshSequenceCacheModifier::vertex_velocities_iterator vvi;
+ int i = 0;
+
+ for (b_mesh_cache.vertex_velocities.begin(vvi); vvi != b_mesh_cache.vertex_velocities.end();
+ ++vvi, ++i) {
+ mP[i] = P[i] + get_float3(vvi->velocity()) * relative_time;
+ }
+ }
+}
+
static void sync_mesh_fluid_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh)
{
if (scene->need_motion() == Scene::MOTION_NONE)
@@ -1002,6 +1070,9 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph,
}
}
+ /* cached velocities (e.g. from alembic archive) */
+ sync_mesh_cached_velocities(b_ob, b_depsgraph.scene(), scene, mesh);
+
/* mesh fluid motion mantaflow */
sync_mesh_fluid_motion(b_ob, scene, mesh);
@@ -1023,6 +1094,12 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
return;
}
+ /* Cached motion blur already exported. */
+ BL::MeshSequenceCacheModifier mesh_cache = object_mesh_cache_find(b_ob, b_scene);
+ if (mesh_cache) {
+ return;
+ }
+
/* Skip if no vertices were exported. */
size_t numverts = mesh->verts.size();
if (numverts == 0) {
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index ca363802919..a06030c8b7d 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -59,6 +59,7 @@ BlenderSession::BlenderSession(BL::RenderEngine &b_engine,
BL::BlendData &b_data,
bool preview_osl)
: session(NULL),
+ scene(NULL),
sync(NULL),
b_engine(b_engine),
b_userpref(b_userpref),
@@ -88,6 +89,7 @@ BlenderSession::BlenderSession(BL::RenderEngine &b_engine,
int width,
int height)
: session(NULL),
+ scene(NULL),
sync(NULL),
b_engine(b_engine),
b_userpref(b_userpref),
@@ -970,7 +972,8 @@ void BlenderSession::update_status_progress()
remaining_time = (1.0 - (double)progress) * (render_time / (double)progress);
if (background) {
- scene_status += " | " + scene->name;
+ if (scene)
+ scene_status += " | " + scene->name;
if (b_rlay_name != "")
scene_status += ", " + b_rlay_name;
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 33e73b5a4b9..ae681432a43 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -678,7 +678,7 @@ static ShaderNode *add_node(Scene *scene,
* builtin names for packed images and movies
*/
int scene_frame = b_scene.frame_current();
- int image_frame = image_user_frame_number(b_image_user, scene_frame);
+ int image_frame = image_user_frame_number(b_image_user, b_image, scene_frame);
image->handle = scene->image_manager->add_image(
new BlenderImageLoader(b_image, image_frame), image->image_params());
}
@@ -713,7 +713,7 @@ static ShaderNode *add_node(Scene *scene,
if (is_builtin) {
int scene_frame = b_scene.frame_current();
- int image_frame = image_user_frame_number(b_image_user, scene_frame);
+ int image_frame = image_user_frame_number(b_image_user, b_image, scene_frame);
env->handle = scene->image_manager->add_image(new BlenderImageLoader(b_image, image_frame),
env->image_params());
}
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index ad90a5f8d52..1ea34b41aa2 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -238,7 +238,7 @@ static inline string image_user_file_path(BL::ImageUser &iuser,
{
char filepath[1024];
iuser.tile(0);
- BKE_image_user_frame_calc(NULL, iuser.ptr.data, cfra);
+ BKE_image_user_frame_calc(ima.ptr.data, iuser.ptr.data, cfra);
BKE_image_user_file_path(iuser.ptr.data, ima.ptr.data, filepath);
string filepath_str = string(filepath);
@@ -248,9 +248,9 @@ static inline string image_user_file_path(BL::ImageUser &iuser,
return filepath_str;
}
-static inline int image_user_frame_number(BL::ImageUser &iuser, int cfra)
+static inline int image_user_frame_number(BL::ImageUser &iuser, BL::Image &ima, int cfra)
{
- BKE_image_user_frame_calc(NULL, iuser.ptr.data, cfra);
+ BKE_image_user_frame_calc(ima.ptr.data, iuser.ptr.data, cfra);
return iuser.frame_current();
}
diff --git a/intern/cycles/blender/blender_volume.cpp b/intern/cycles/blender/blender_volume.cpp
index 80591e0eec8..d0e1e4d6131 100644
--- a/intern/cycles/blender/blender_volume.cpp
+++ b/intern/cycles/blender/blender_volume.cpp
@@ -217,43 +217,29 @@ static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float
class BlenderVolumeLoader : public VDBImageLoader {
public:
BlenderVolumeLoader(BL::BlendData &b_data, BL::Volume &b_volume, const string &grid_name)
- : VDBImageLoader(grid_name), b_data(b_data), b_volume(b_volume), unload(false)
- {
- }
-
- bool load_metadata(ImageMetaData &metadata) override
+ : VDBImageLoader(grid_name), b_volume(b_volume)
{
b_volume.grids.load(b_data.ptr.data);
- BL::VolumeGrid b_volume_grid = find_grid();
-
- if (!b_volume_grid) {
- return false;
- }
-
- unload = !b_volume_grid.is_loaded();
#ifdef WITH_OPENVDB
- Volume *volume = (Volume *)b_volume.ptr.data;
- VolumeGrid *volume_grid = (VolumeGrid *)b_volume_grid.ptr.data;
- grid = BKE_volume_grid_openvdb_for_read(volume, volume_grid);
-#endif
+ BL::Volume::grids_iterator b_grid_iter;
+ for (b_volume.grids.begin(b_grid_iter); b_grid_iter != b_volume.grids.end(); ++b_grid_iter) {
+ BL::VolumeGrid b_volume_grid(*b_grid_iter);
+ if (b_volume_grid.name() == grid_name) {
+ const bool unload = !b_volume_grid.is_loaded();
- return VDBImageLoader::load_metadata(metadata);
- }
+ Volume *volume = (Volume *)b_volume.ptr.data;
+ VolumeGrid *volume_grid = (VolumeGrid *)b_volume_grid.ptr.data;
+ grid = BKE_volume_grid_openvdb_for_read(volume, volume_grid);
- bool load_pixels(const ImageMetaData &metadata,
- void *pixels,
- const size_t pixel_size,
- const bool associate_alpha) override
- {
- b_volume.grids.load(b_data.ptr.data);
- BL::VolumeGrid b_volume_grid = find_grid();
+ if (unload) {
+ b_volume_grid.unload();
+ }
- if (!b_volume_grid) {
- return false;
+ break;
+ }
}
-
- return VDBImageLoader::load_pixels(metadata, pixels, pixel_size, associate_alpha);
+#endif
}
bool equals(const ImageLoader &other) const override
@@ -263,36 +249,7 @@ class BlenderVolumeLoader : public VDBImageLoader {
return b_volume == other_loader.b_volume && grid_name == other_loader.grid_name;
}
- void cleanup() override
- {
- VDBImageLoader::cleanup();
-
- BL::VolumeGrid b_volume_grid = find_grid();
- if (b_volume_grid && unload) {
- b_volume_grid.unload();
- }
- }
-
- /* Find grid with matching name. Grid point not stored in the class since
- * grids may be unloaded before we load the pixels, for example for motion
- * blur where we move between frames. */
- BL::VolumeGrid find_grid()
- {
-#ifdef WITH_OPENVDB
- BL::Volume::grids_iterator b_grid_iter;
- for (b_volume.grids.begin(b_grid_iter); b_grid_iter != b_volume.grids.end(); ++b_grid_iter) {
- if (b_grid_iter->name() == grid_name) {
- return *b_grid_iter;
- }
- }
-#endif
-
- return BL::VolumeGrid(PointerRNA_NULL);
- }
-
- BL::BlendData b_data;
BL::Volume b_volume;
- bool unload;
};
static void sync_volume_object(BL::BlendData &b_data, BL::Object &b_ob, Scene *scene, Mesh *mesh)
@@ -342,7 +299,7 @@ static void sync_volume_object(BL::BlendData &b_data, BL::Object &b_ob, Scene *s
ImageParams params;
params.frame = b_volume.grids.frame();
- attr->data_voxel() = scene->image_manager->add_image(loader, params);
+ attr->data_voxel() = scene->image_manager->add_image(loader, params, false);
}
}
}
diff --git a/intern/cycles/kernel/kernel_light_background.h b/intern/cycles/kernel/kernel_light_background.h
index 30e336f0f80..5fa25069fcd 100644
--- a/intern/cycles/kernel/kernel_light_background.h
+++ b/intern/cycles/kernel/kernel_light_background.h
@@ -445,4 +445,4 @@ ccl_device float background_light_pdf(KernelGlobals *kg, float3 P, float3 direct
#endif
-CCL_NAMESPACE_END \ No newline at end of file
+CCL_NAMESPACE_END
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 436324b00ba..1b138455515 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -484,8 +484,8 @@ void ShaderGraph::remove_proxy_nodes()
vector<ShaderInput *> links(output->links);
foreach (ShaderInput *to, links) {
- /* remove any autoconvert nodes too if they lead to
- * sockets with an automatically set default value */
+ /* Remove any auto-convert nodes too if they lead to
+ * sockets with an automatically set default value. */
ShaderNode *tonode = to->parent;
if (tonode->special_type == SHADER_SPECIAL_TYPE_AUTOCONVERT) {
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 8d187814d64..691eb162dd0 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -362,9 +362,11 @@ ImageHandle ImageManager::add_image(const string &filename,
return handle;
}
-ImageHandle ImageManager::add_image(ImageLoader *loader, const ImageParams &params)
+ImageHandle ImageManager::add_image(ImageLoader *loader,
+ const ImageParams &params,
+ const bool builtin)
{
- const int slot = add_image_slot(loader, params, true);
+ const int slot = add_image_slot(loader, params, builtin);
ImageHandle handle;
handle.tile_slots.push_back(slot);
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index fffe7c5152a..47be0ee559a 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -169,7 +169,7 @@ class ImageManager {
ImageHandle add_image(const string &filename,
const ImageParams &params,
const vector<int> &tiles);
- ImageHandle add_image(ImageLoader *loader, const ImageParams &params);
+ ImageHandle add_image(ImageLoader *loader, const ImageParams &params, const bool builtin = true);
void device_update(Device *device, Scene *scene, Progress &progress);
void device_update_slot(Device *device, Scene *scene, int slot, Progress *progress);
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index c5033359c6b..08a8cb08254 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -945,8 +945,14 @@ void Session::set_pause(bool pause_)
}
}
- if (notify)
- pause_cond.notify_all();
+ if (session_thread) {
+ if (notify) {
+ pause_cond.notify_all();
+ }
+ }
+ else if (pause_) {
+ update_status_time(pause_);
+ }
}
void Session::set_denoising(const DenoiseParams &denoising)
diff --git a/intern/cycles/test/CMakeLists.txt b/intern/cycles/test/CMakeLists.txt
index 6dcc7f7b3dd..07b345baff8 100644
--- a/intern/cycles/test/CMakeLists.txt
+++ b/intern/cycles/test/CMakeLists.txt
@@ -112,3 +112,4 @@ set_source_files_properties(util_avxf_avx_test.cpp PROPERTIES COMPILE_FLAGS "${C
CYCLES_TEST(util_avxf_avx "cycles_util;bf_intern_numaapi;${OPENIMAGEIO_LIBRARIES};${BOOST_LIBRARIES}")
set_source_files_properties(util_avxf_avx2_test.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX2_KERNEL_FLAGS}")
CYCLES_TEST(util_avxf_avx2 "cycles_util;bf_intern_numaapi;${OPENIMAGEIO_LIBRARIES};${BOOST_LIBRARIES}")
+CYCLES_TEST(util_transform "cycles_util;${OPENIMAGEIO_LIBRARIES};${BOOST_LIBRARIES}")
diff --git a/intern/cycles/test/util_transform_test.cpp b/intern/cycles/test/util_transform_test.cpp
new file mode 100644
index 00000000000..58ce0fdfee4
--- /dev/null
+++ b/intern/cycles/test/util_transform_test.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2011-2020 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "testing/testing.h"
+
+#include "util/util_transform.h"
+#include "util/util_vector.h"
+
+CCL_NAMESPACE_BEGIN
+
+TEST(transform_motion_decompose, Degenerated)
+{
+ // Simple case: single degenerated matrix.
+ {
+ vector<Transform> motion = {transform_scale(0.0f, 0.0f, 0.0f)};
+ vector<DecomposedTransform> decomp(motion.size());
+ transform_motion_decompose(decomp.data(), motion.data(), motion.size());
+ EXPECT_TRUE(transform_decomposed_isfinite_safe(&decomp[0]));
+ }
+
+ // Copy from previous to current.
+ {
+ vector<Transform> motion = {transform_rotate(M_PI_4_F, make_float3(1.0f, 1.0f, 1.0f)),
+ transform_scale(0.0f, 0.0f, 0.0f)};
+ vector<DecomposedTransform> decomp(motion.size());
+ transform_motion_decompose(decomp.data(), motion.data(), motion.size());
+ EXPECT_NEAR(len(decomp[1].x - decomp[0].x), 0.0f, 1e-6f);
+ }
+
+ // Copy from next to current.
+ {
+ vector<Transform> motion = {transform_scale(0.0f, 0.0f, 0.0f),
+ transform_rotate(M_PI_4_F, make_float3(1.0f, 1.0f, 1.0f))};
+ vector<DecomposedTransform> decomp(motion.size());
+ transform_motion_decompose(decomp.data(), motion.data(), motion.size());
+ EXPECT_NEAR(len(decomp[0].x - decomp[1].x), 0.0f, 1e-6f);
+ }
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_math_fast.h b/intern/cycles/util/util_math_fast.h
index e979bd9e0c0..07b0878e3d5 100644
--- a/intern/cycles/util/util_math_fast.h
+++ b/intern/cycles/util/util_math_fast.h
@@ -87,7 +87,7 @@ ccl_device_inline int fast_rint(float x)
/* Single roundps instruction on SSE4.1+ (for gcc/clang at least). */
return float_to_int(rintf(x));
#else
- /* emulate rounding by adding/substracting 0.5. */
+ /* emulate rounding by adding/subtracting 0.5. */
return float_to_int(x + copysignf(0.5f, x));
#endif
}
@@ -445,12 +445,10 @@ ccl_device_inline float fast_expf(float x)
return fast_exp2f(x / M_LN2_F);
}
-#ifndef __KERNEL_GPU__
-/* MSVC seems to have a code-gen bug here in at least SSE41/AVX
- * see T78047 for details. */
-# ifdef _MSC_VER
-# pragma optimize("", off)
-# endif
+#if defined(__KERNEL_CPU__) && !defined(_MSC_VER)
+/* MSVC seems to have a code-gen bug here in at least SSE41/AVX, see
+ * T78047 and T78869 for details. Just disable for now, it only makes
+ * a small difference in denoising performance. */
ccl_device float4 fast_exp2f4(float4 x)
{
const float4 one = make_float4(1.0f);
@@ -466,14 +464,16 @@ ccl_device float4 fast_exp2f4(float4 x)
r = madd4(x, r, make_float4(1.0f));
return __int4_as_float4(__float4_as_int4(r) + (m << 23));
}
-# ifdef _MSC_VER
-# pragma optimize("", on)
-# endif
ccl_device_inline float4 fast_expf4(float4 x)
{
return fast_exp2f4(x / M_LN2_F);
}
+#else
+ccl_device_inline float4 fast_expf4(float4 x)
+{
+ return make_float4(fast_expf(x.x), fast_expf(x.y), fast_expf(x.z), fast_expf(x.w));
+}
#endif
ccl_device_inline float fast_exp10(float x)
diff --git a/intern/cycles/util/util_math_float4.h b/intern/cycles/util/util_math_float4.h
index cd4b3e3b74c..ec5328adb31 100644
--- a/intern/cycles/util/util_math_float4.h
+++ b/intern/cycles/util/util_math_float4.h
@@ -477,6 +477,24 @@ ccl_device_inline float4 safe_divide_float4_float(const float4 a, const float b)
return (b != 0.0f) ? a / b : make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
+ccl_device_inline bool isfinite4_safe(float4 v)
+{
+ return isfinite_safe(v.x) && isfinite_safe(v.y) && isfinite_safe(v.z) && isfinite_safe(v.w);
+}
+
+ccl_device_inline float4 ensure_finite4(float4 v)
+{
+ if (!isfinite_safe(v.x))
+ v.x = 0.0f;
+ if (!isfinite_safe(v.y))
+ v.y = 0.0f;
+ if (!isfinite_safe(v.z))
+ v.z = 0.0f;
+ if (!isfinite_safe(v.w))
+ v.w = 0.0f;
+ return v;
+}
+
CCL_NAMESPACE_END
#endif /* __UTIL_MATH_FLOAT4_H__ */
diff --git a/intern/cycles/util/util_transform.cpp b/intern/cycles/util/util_transform.cpp
index 101122740d7..e8233b7fe6d 100644
--- a/intern/cycles/util/util_transform.cpp
+++ b/intern/cycles/util/util_transform.cpp
@@ -269,17 +269,17 @@ static void transform_decompose(DecomposedTransform *decomp, const Transform *tf
/* extract scale and shear first */
float3 scale, shear;
scale.x = len(colx);
- colx /= scale.x;
+ colx = safe_divide_float3_float(colx, scale.x);
shear.z = dot(colx, coly);
coly -= shear.z * colx;
scale.y = len(coly);
- coly /= scale.y;
+ coly = safe_divide_float3_float(coly, scale.y);
shear.y = dot(colx, colz);
colz -= shear.y * colx;
shear.x = dot(coly, colz);
colz -= shear.x * coly;
scale.z = len(colz);
- colz /= scale.z;
+ colz = safe_divide_float3_float(colz, scale.z);
transform_set_column(&M, 0, colx);
transform_set_column(&M, 1, coly);
@@ -300,6 +300,7 @@ static void transform_decompose(DecomposedTransform *decomp, const Transform *tf
void transform_motion_decompose(DecomposedTransform *decomp, const Transform *motion, size_t size)
{
+ /* Decompose and correct rotation. */
for (size_t i = 0; i < size; i++) {
transform_decompose(decomp + i, motion + i);
@@ -310,6 +311,27 @@ void transform_motion_decompose(DecomposedTransform *decomp, const Transform *mo
decomp[i].x = -decomp[i].x;
}
}
+
+ /* Copy rotation to decomposed transform where scale is degenerate. This avoids weird object
+ * rotation interpolation when the scale goes to 0 for a time step.
+ *
+ * Note that this is very simple and naive implementation, which only deals with degenerated
+ * scale happening only on one frame. It is possible to improve it further by interpolating
+ * rotation into s degenerated range using rotation from time-steps from adjacent non-degenerated
+ * time steps. */
+ for (size_t i = 0; i < size; i++) {
+ const float3 scale = make_float3(decomp[i].y.w, decomp[i].z.w, decomp[i].w.w);
+ if (!is_zero(scale)) {
+ continue;
+ }
+
+ if (i > 0) {
+ decomp[i].x = decomp[i - 1].x;
+ }
+ else if (i < size - 1) {
+ decomp[i].x = decomp[i + 1].x;
+ }
+ }
}
Transform transform_from_viewplane(BoundBox2D &viewplane)
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index d0a6264d5cf..d8bbd389aa6 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -466,6 +466,17 @@ ccl_device void transform_motion_array_interpolate(Transform *tfm,
transform_compose(tfm, &decomp);
}
+ccl_device_inline bool transform_isfinite_safe(Transform *tfm)
+{
+ return isfinite4_safe(tfm->x) && isfinite4_safe(tfm->y) && isfinite4_safe(tfm->z);
+}
+
+ccl_device_inline bool transform_decomposed_isfinite_safe(DecomposedTransform *decomp)
+{
+ return isfinite4_safe(decomp->x) && isfinite4_safe(decomp->y) && isfinite4_safe(decomp->z) &&
+ isfinite4_safe(decomp->w);
+}
+
#ifndef __KERNEL_GPU__
class BoundBox2D;
diff --git a/tests/gtests/ffmpeg/CMakeLists.txt b/intern/ffmpeg/CMakeLists.txt
index dbd4f9f1fed..e141da9cbca 100644
--- a/tests/gtests/ffmpeg/CMakeLists.txt
+++ b/intern/ffmpeg/CMakeLists.txt
@@ -14,31 +14,29 @@
# 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) 2014, Blender Foundation
+# The Original Code is Copyright (C) 2020, Blender Foundation
# All rights reserved.
# ***** END GPL LICENSE BLOCK *****
-set(INC
- .
- ..
-
- ${FFMPEG_INCLUDE_DIRS}
- ${PNG_INCLUDE_DIRS}
- ${ZLIB_INCLUDE_DIRS}
-)
-
-set(LIB
- ${PNG_LIBRARIES}
- ${FFMPEG_LIBRARIES}
- ${ZLIB_LIBRARIES}
-)
-
-if(WITH_IMAGE_OPENJPEG)
- set(LIB ${LIB} ${OPENJPEG_LIBRARIES})
+if(WITH_GTESTS)
+ set(TEST_SRC
+ tests/ffmpeg_codecs.cc
+ )
+ set(TEST_INC
+ )
+ set(TEST_INC_SYS
+ ${FFMPEG_INCLUDE_DIRS}
+ ${PNG_INCLUDE_DIRS}
+ ${ZLIB_INCLUDE_DIRS}
+ )
+ set(TEST_LIB
+ ${PNG_LIBRARIES}
+ ${FFMPEG_LIBRARIES}
+ ${ZLIB_LIBRARIES}
+ )
+ if(WITH_IMAGE_OPENJPEG)
+ set(TEST_LIB ${TEST_LIB} ${OPENJPEG_LIBRARIES})
+ endif()
+ include(GTestTesting)
+ blender_add_test_lib(bf_intern_ffmpeg_tests "${TEST_SRC}" "${TEST_INC}" "${TEST_INC_SYS}" "${TEST_LIB}")
endif()
-
-setup_platform_linker_flags()
-link_directories(${FFMPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH})
-include_directories(${INC})
-
-BLENDER_SRC_GTEST(ffmpeg "ffmpeg_codecs.cc" "${LIB}")
diff --git a/tests/gtests/ffmpeg/ffmpeg_codecs.cc b/intern/ffmpeg/tests/ffmpeg_codecs.cc
index bbf2b3a4111..9538bac84d2 100644
--- a/tests/gtests/ffmpeg/ffmpeg_codecs.cc
+++ b/intern/ffmpeg/tests/ffmpeg_codecs.cc
@@ -5,6 +5,8 @@ extern "C" {
#include <libavutil/log.h>
}
+namespace {
+
bool test_vcodec(AVCodec *codec, AVPixelFormat pixelformat)
{
av_log_set_level(AV_LOG_QUIET);
@@ -85,29 +87,31 @@ bool test_codec_audio_by_name(const char *codecname, AVSampleFormat fmt)
#define str(s) #s
#define FFMPEG_TEST_VCODEC_ID(codec, fmt) \
- TEST(CheckCodec, codec##_##fmt) \
+ TEST(ffmpeg, codec##_##fmt) \
{ \
EXPECT_TRUE(test_codec_video_by_codecid(codec, fmt)); \
}
#define FFMPEG_TEST_VCODEC_NAME(codec, fmt) \
- TEST(CheckCodec, codec##_##fmt) \
+ TEST(ffmpeg, codec##_##fmt) \
{ \
EXPECT_TRUE(test_codec_video_by_name(str(codec), fmt)); \
}
#define FFMPEG_TEST_ACODEC_ID(codec, fmt) \
- TEST(CheckCodec, codec##_##fmt) \
+ TEST(ffmpeg, codec##_##fmt) \
{ \
EXPECT_TRUE(test_codec_audio_by_codecid(codec, fmt)); \
}
#define FFMPEG_TEST_ACODEC_NAME(codec, fmt) \
- TEST(CheckCodec, codec) \
+ TEST(ffmpeg, codec) \
{ \
EXPECT_TRUE(test_codec_audio_by_name(str(codec), fmt)); \
}
+} // namespace
+
/* generic codec ID's used in blender */
FFMPEG_TEST_VCODEC_ID(AV_CODEC_ID_HUFFYUV, AV_PIX_FMT_BGRA)
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 92061f55128..f23742a9166 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -21,8 +21,7 @@
* \brief GHOST C-API function and type declarations.
*/
-#ifndef __GHOST_C_API_H__
-#define __GHOST_C_API_H__
+#pragma once
#include "GHOST_Types.h"
@@ -1072,5 +1071,3 @@ GHOST_TSuccess GHOST_XrEventsHandle(GHOST_XrContextHandle xr_context);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/intern/ghost/GHOST_IContext.h b/intern/ghost/GHOST_IContext.h
index 8c24261644a..c6316e90ce4 100644
--- a/intern/ghost/GHOST_IContext.h
+++ b/intern/ghost/GHOST_IContext.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_IContext interface class.
*/
-#ifndef __GHOST_IContext_H__
-#define __GHOST_IContext_H__
+#pragma once
#include "GHOST_Types.h"
@@ -63,5 +62,3 @@ class GHOST_IContext {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IContext")
#endif
};
-
-#endif // __GHOST_IContext_H__
diff --git a/intern/ghost/GHOST_IEvent.h b/intern/ghost/GHOST_IEvent.h
index 0d9bfb2c4de..c63064c123a 100644
--- a/intern/ghost/GHOST_IEvent.h
+++ b/intern/ghost/GHOST_IEvent.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_IEvent interface class.
*/
-#ifndef __GHOST_IEVENT_H__
-#define __GHOST_IEVENT_H__
+#pragma once
#include "GHOST_Types.h"
#include <stddef.h>
@@ -78,5 +77,3 @@ class GHOST_IEvent {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IEvent")
#endif
};
-
-#endif // __GHOST_IEVENT_H__
diff --git a/intern/ghost/GHOST_IEventConsumer.h b/intern/ghost/GHOST_IEventConsumer.h
index d677a632a4b..b5975068da0 100644
--- a/intern/ghost/GHOST_IEventConsumer.h
+++ b/intern/ghost/GHOST_IEventConsumer.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_IEventConsumer interface class.
*/
-#ifndef __GHOST_IEVENTCONSUMER_H__
-#define __GHOST_IEVENTCONSUMER_H__
+#pragma once
#include "GHOST_IEvent.h"
@@ -56,5 +55,3 @@ class GHOST_IEventConsumer {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IEventConsumer")
#endif
};
-
-#endif /* __GHOST_IEVENTCONSUMER_H__ */
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 33600fd1219..04e9d5e4e14 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -24,8 +24,7 @@
* Contains the doxygen documentation main page.
*/
-#ifndef __GHOST_ISYSTEM_H__
-#define __GHOST_ISYSTEM_H__
+#pragma once
#include <stdlib.h>
@@ -494,5 +493,3 @@ class GHOST_ISystem {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ISystem")
#endif
};
-
-#endif // __GHOST_ISYSTEM_H__
diff --git a/intern/ghost/GHOST_ISystemPaths.h b/intern/ghost/GHOST_ISystemPaths.h
index 297f6333a77..b47d14984d8 100644
--- a/intern/ghost/GHOST_ISystemPaths.h
+++ b/intern/ghost/GHOST_ISystemPaths.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_ISYSTEMPATHS_H__
-#define __GHOST_ISYSTEMPATHS_H__
+#pragma once
#include "GHOST_Types.h"
@@ -97,5 +96,3 @@ class GHOST_ISystemPaths {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ISystemPaths")
#endif
};
-
-#endif
diff --git a/intern/ghost/GHOST_ITimerTask.h b/intern/ghost/GHOST_ITimerTask.h
index 46f4fdbc303..0f4ac74c466 100644
--- a/intern/ghost/GHOST_ITimerTask.h
+++ b/intern/ghost/GHOST_ITimerTask.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_ITimerTask interface class.
*/
-#ifndef __GHOST_ITIMERTASK_H__
-#define __GHOST_ITIMERTASK_H__
+#pragma once
#include "GHOST_Types.h"
@@ -76,5 +75,3 @@ class GHOST_ITimerTask {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ITimerTask")
#endif
};
-
-#endif // __GHOST_ITIMERTASK_H__
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index 9c72b6f07f9..6e8b61ae5a1 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_IWindow interface class.
*/
-#ifndef __GHOST_IWINDOW_H__
-#define __GHOST_IWINDOW_H__
+#pragma once
#include "GHOST_Rect.h"
#include "GHOST_Types.h"
@@ -363,5 +362,3 @@ class GHOST_IWindow {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IWindow")
#endif
};
-
-#endif // __GHOST_IWINDOW_H__
diff --git a/intern/ghost/GHOST_IXrContext.h b/intern/ghost/GHOST_IXrContext.h
index 3076de96690..dd266a3b6ae 100644
--- a/intern/ghost/GHOST_IXrContext.h
+++ b/intern/ghost/GHOST_IXrContext.h
@@ -18,8 +18,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_IXRCONTEXT_H__
-#define __GHOST_IXRCONTEXT_H__
+#pragma once
#include "GHOST_Types.h"
@@ -40,5 +39,3 @@ class GHOST_IXrContext {
virtual bool needsUpsideDownDrawing() const = 0;
};
-
-#endif // __GHOST_IXRCONTEXT_H__
diff --git a/intern/ghost/GHOST_Path-api.h b/intern/ghost/GHOST_Path-api.h
index 53abdf68bb4..4cc232be6b6 100644
--- a/intern/ghost/GHOST_Path-api.h
+++ b/intern/ghost/GHOST_Path-api.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_PATH_API_H__
-#define __GHOST_PATH_API_H__
+#pragma once
#include "GHOST_Types.h"
@@ -71,5 +70,3 @@ extern void GHOST_addToSystemRecentFiles(const char *filename);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/intern/ghost/GHOST_Rect.h b/intern/ghost/GHOST_Rect.h
index 13632a1c03b..fcc9da20197 100644
--- a/intern/ghost/GHOST_Rect.h
+++ b/intern/ghost/GHOST_Rect.h
@@ -22,8 +22,7 @@
* Macro's used in GHOST debug target.
*/
-#ifndef __GHOST_RECT_H__
-#define __GHOST_RECT_H__
+#pragma once
#include "GHOST_Types.h"
@@ -263,5 +262,3 @@ inline bool GHOST_Rect::isInside(GHOST_TInt32 x, GHOST_TInt32 y) const
{
return (x >= m_l) && (x <= m_r) && (y >= m_t) && (y <= m_b);
}
-
-#endif // __GHOST_RECT_H__
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index b8de31df6c6..5f0516ae121 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_TYPES_H__
-#define __GHOST_TYPES_H__
+#pragma once
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
@@ -677,5 +676,3 @@ typedef struct GHOST_XrError {
} GHOST_XrError;
#endif
-
-#endif // __GHOST_TYPES_H__
diff --git a/intern/ghost/intern/GHOST_Buttons.h b/intern/ghost/intern/GHOST_Buttons.h
index 0b824739950..e28fae8870c 100644
--- a/intern/ghost/intern/GHOST_Buttons.h
+++ b/intern/ghost/intern/GHOST_Buttons.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_Buttons struct.
*/
-#ifndef __GHOST_BUTTONS_H__
-#define __GHOST_BUTTONS_H__
+#pragma once
#include "GHOST_Types.h"
@@ -62,5 +61,3 @@ struct GHOST_Buttons {
GHOST_TUns8 m_ButtonMiddle : 1;
GHOST_TUns8 m_ButtonRight : 1;
};
-
-#endif // __GHOST_BUTTONS_H__
diff --git a/intern/ghost/intern/GHOST_CallbackEventConsumer.h b/intern/ghost/intern/GHOST_CallbackEventConsumer.h
index 9c3fc642209..a1664e77717 100644
--- a/intern/ghost/intern/GHOST_CallbackEventConsumer.h
+++ b/intern/ghost/intern/GHOST_CallbackEventConsumer.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_CallbackEventConsumer class.
*/
-#ifndef __GHOST_CALLBACKEVENTCONSUMER_H__
-#define __GHOST_CALLBACKEVENTCONSUMER_H__
+#pragma once
#include "GHOST_C-api.h"
#include "GHOST_IEventConsumer.h"
@@ -66,5 +65,3 @@ class GHOST_CallbackEventConsumer : public GHOST_IEventConsumer {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_CallbackEventConsumer")
#endif
};
-
-#endif // __GHOST_CALLBACKEVENTCONSUMER_H__
diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h
index 411a7de5c79..33eeacbb203 100644
--- a/intern/ghost/intern/GHOST_Context.h
+++ b/intern/ghost/intern/GHOST_Context.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_Context class.
*/
-#ifndef __GHOST_CONTEXT_H__
-#define __GHOST_CONTEXT_H__
+#pragma once
#include "GHOST_IContext.h"
#include "GHOST_Types.h"
@@ -160,5 +159,3 @@ bool win32_silent_chk(bool result);
# define WIN32_CHK_SILENT(x, silent) ((silent) ? win32_silent_chk(x) : WIN32_CHK(x))
#endif /* _WIN32 */
-
-#endif // __GHOST_CONTEXT_H__
diff --git a/intern/ghost/intern/GHOST_ContextCGL.h b/intern/ghost/intern/GHOST_ContextCGL.h
index 37c1ac34299..7b1e186dede 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.h
+++ b/intern/ghost/intern/GHOST_ContextCGL.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_CONTEXTCGL_H__
-#define __GHOST_CONTEXTCGL_H__
+#pragma once
#include "GHOST_Context.h"
@@ -137,5 +136,3 @@ class GHOST_ContextCGL : public GHOST_Context {
void metalUpdateFramebuffer();
void metalSwapBuffers();
};
-
-#endif // __GHOST_CONTEXTCGL_H__
diff --git a/intern/ghost/intern/GHOST_ContextD3D.h b/intern/ghost/intern/GHOST_ContextD3D.h
index c482992a6e2..e85516838fc 100644
--- a/intern/ghost/intern/GHOST_ContextD3D.h
+++ b/intern/ghost/intern/GHOST_ContextD3D.h
@@ -18,8 +18,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_CONTEXTD3D_H__
-#define __GHOST_CONTEXTD3D_H__
+#pragma once
#ifndef WIN32
# error WIN32 only!
@@ -132,5 +131,3 @@ class GHOST_ContextD3D : public GHOST_Context {
ID3D11Device *m_device;
ID3D11DeviceContext *m_device_ctx;
};
-
-#endif /* __GHOST_CONTEXTD3D_H__ */
diff --git a/intern/ghost/intern/GHOST_ContextEGL.cpp b/intern/ghost/intern/GHOST_ContextEGL.cpp
index 02daad2111a..bac7057d953 100644
--- a/intern/ghost/intern/GHOST_ContextEGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextEGL.cpp
@@ -118,7 +118,7 @@ static const char *get_egl_error_message_string(EGLint error)
case EGL_CONTEXT_LOST:
return (
"A power management event has occurred. "
- "The application must destroy all contexts and reinitialise OpenGL ES state "
+ "The application must destroy all contexts and reinitialize OpenGL ES state "
"and objects to continue rendering.");
default:
diff --git a/intern/ghost/intern/GHOST_ContextEGL.h b/intern/ghost/intern/GHOST_ContextEGL.h
index da5ca7ef93f..e5dae0d22a8 100644
--- a/intern/ghost/intern/GHOST_ContextEGL.h
+++ b/intern/ghost/intern/GHOST_ContextEGL.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_CONTEXTEGL_H__
-#define __GHOST_CONTEXTEGL_H__
+#pragma once
#include "GHOST_Context.h"
@@ -137,5 +136,3 @@ class GHOST_ContextEGL : public GHOST_Context {
static HMODULE s_d3dcompiler;
#endif
};
-
-#endif // __GHOST_CONTEXTEGL_H__
diff --git a/intern/ghost/intern/GHOST_ContextGLX.h b/intern/ghost/intern/GHOST_ContextGLX.h
index 07d2601cd17..e5654b1aed7 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.h
+++ b/intern/ghost/intern/GHOST_ContextGLX.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_CONTEXTGLX_H__
-#define __GHOST_CONTEXTGLX_H__
+#pragma once
#include "GHOST_Context.h"
@@ -128,5 +127,3 @@ class GHOST_ContextGLX : public GHOST_Context {
/* used to get GLX info */
int GHOST_X11_GL_GetAttributes(
int *attribs, int attribs_max, bool is_stereo_visual, bool need_alpha, bool for_fb_config);
-
-#endif // __GHOST_CONTEXTGLX_H__
diff --git a/intern/ghost/intern/GHOST_ContextNone.h b/intern/ghost/intern/GHOST_ContextNone.h
index 2a3c08701b4..b1ac349e4a7 100644
--- a/intern/ghost/intern/GHOST_ContextNone.h
+++ b/intern/ghost/intern/GHOST_ContextNone.h
@@ -23,8 +23,7 @@
* Declaration of GHOST_Context class.
*/
-#ifndef __GHOST_CONTEXTNONE_H__
-#define __GHOST_CONTEXTNONE_H__
+#pragma once
#include "GHOST_Context.h"
@@ -86,5 +85,3 @@ class GHOST_ContextNone : public GHOST_Context {
private:
int m_swapInterval;
};
-
-#endif // __GHOST_CONTEXTNONE_H__
diff --git a/intern/ghost/intern/GHOST_ContextSDL.h b/intern/ghost/intern/GHOST_ContextSDL.h
index 670d930e1e7..ead2e91181c 100644
--- a/intern/ghost/intern/GHOST_ContextSDL.h
+++ b/intern/ghost/intern/GHOST_ContextSDL.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_CONTEXTSDL_H__
-#define __GHOST_CONTEXTSDL_H__
+#pragma once
#include "GHOST_Context.h"
@@ -121,5 +120,3 @@ class GHOST_ContextSDL : public GHOST_Context {
static SDL_GLContext s_sharedContext;
static int s_sharedCount;
};
-
-#endif // __GHOST_CONTEXTSDL_H__
diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h
index a8d2c18b463..087fca100e4 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.h
+++ b/intern/ghost/intern/GHOST_ContextWGL.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_CONTEXTWGL_H__
-#define __GHOST_CONTEXTWGL_H__
+#pragma once
//#define WIN32_COMPOSITING
@@ -130,5 +129,3 @@ class GHOST_ContextWGL : public GHOST_Context {
static HGLRC s_sharedHGLRC;
static int s_sharedCount;
};
-
-#endif // __GHOST_CONTEXTWGL_H__
diff --git a/intern/ghost/intern/GHOST_Debug.h b/intern/ghost/intern/GHOST_Debug.h
index 5b5c2688297..424f95aa573 100644
--- a/intern/ghost/intern/GHOST_Debug.h
+++ b/intern/ghost/intern/GHOST_Debug.h
@@ -22,8 +22,7 @@
* Macro's used in GHOST debug target.
*/
-#ifndef __GHOST_DEBUG_H__
-#define __GHOST_DEBUG_H__
+#pragma once
#ifdef _MSC_VER
# ifdef DEBUG
@@ -79,5 +78,3 @@
#else // WITH_GHOST_DEBUG
# define GHOST_ASSERT(x, info) ((void)0)
#endif // WITH_GHOST_DEBUG
-
-#endif // __GHOST_DEBUG_H__
diff --git a/intern/ghost/intern/GHOST_DisplayManager.h b/intern/ghost/intern/GHOST_DisplayManager.h
index 58b36c0035b..67b9aada55f 100644
--- a/intern/ghost/intern/GHOST_DisplayManager.h
+++ b/intern/ghost/intern/GHOST_DisplayManager.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_DisplayManager class.
*/
-#ifndef __GHOST_DISPLAYMANAGER_H__
-#define __GHOST_DISPLAYMANAGER_H__
+#pragma once
#include "GHOST_Types.h"
@@ -127,5 +126,3 @@ class GHOST_DisplayManager {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_DisplayManager")
#endif
};
-
-#endif // __GHOST_DISPLAYMANAGER_H__
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.h b/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
index c99e93279f7..5edd555a78b 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
+++ b/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_DisplayManagerCocoa class.
*/
-#ifndef __GHOST_DISPLAYMANAGERCOCOA_H__
-#define __GHOST_DISPLAYMANAGERCOCOA_H__
+#pragma once
#ifndef __APPLE__
# error Apple only!
@@ -93,5 +92,3 @@ class GHOST_DisplayManagerCocoa : public GHOST_DisplayManager {
/** Cached display id's for each display. */
// CGDirectDisplayID* m_displayIDs;
};
-
-#endif // __GHOST_DISPLAYMANAGERCOCOA_H__
diff --git a/intern/ghost/intern/GHOST_DisplayManagerNULL.h b/intern/ghost/intern/GHOST_DisplayManagerNULL.h
index 266a3e9a699..4ca06faec12 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerNULL.h
+++ b/intern/ghost/intern/GHOST_DisplayManagerNULL.h
@@ -19,8 +19,7 @@
* Declaration of GHOST_DisplayManagerNULL class.
*/
-#ifndef __GHOST_DISPLAYMANAGERNULL_H__
-#define __GHOST_DISPLAYMANAGERNULL_H__
+#pragma once
#include "GHOST_DisplayManager.h"
#include "GHOST_SystemNULL.h"
@@ -58,5 +57,3 @@ class GHOST_DisplayManagerNULL : public GHOST_DisplayManager {
private:
GHOST_SystemNULL *m_system;
};
-
-#endif /* __GHOST_DISPLAYMANAGERNULL_H__ */
diff --git a/intern/ghost/intern/GHOST_DisplayManagerSDL.h b/intern/ghost/intern/GHOST_DisplayManagerSDL.h
index f7704d57ab0..9a79a842057 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerSDL.h
+++ b/intern/ghost/intern/GHOST_DisplayManagerSDL.h
@@ -19,8 +19,7 @@
* Declaration of GHOST_DisplayManagerSDL class.
*/
-#ifndef __GHOST_DISPLAYMANAGERSDL_H__
-#define __GHOST_DISPLAYMANAGERSDL_H__
+#pragma once
#include "GHOST_DisplayManager.h"
@@ -58,5 +57,3 @@ class GHOST_DisplayManagerSDL : public GHOST_DisplayManager {
GHOST_SystemSDL *m_system;
SDL_DisplayMode m_mode;
};
-
-#endif /* __GHOST_DISPLAYMANAGERSDL_H__ */
diff --git a/intern/ghost/intern/GHOST_DisplayManagerWin32.h b/intern/ghost/intern/GHOST_DisplayManagerWin32.h
index c4ad90b1de7..3392d515c16 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerWin32.h
+++ b/intern/ghost/intern/GHOST_DisplayManagerWin32.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_DisplayManagerWin32 class.
*/
-#ifndef __GHOST_DISPLAYMANAGERWIN32_H__
-#define __GHOST_DISPLAYMANAGERWIN32_H__
+#pragma once
#ifndef WIN32
# error WIN32 only!
@@ -87,5 +86,3 @@ class GHOST_DisplayManagerWin32 : public GHOST_DisplayManager {
protected:
};
-
-#endif // __GHOST_DISPLAYMANAGERWIN32_H__
diff --git a/intern/ghost/intern/GHOST_DisplayManagerX11.h b/intern/ghost/intern/GHOST_DisplayManagerX11.h
index 941152aa034..a36ff8d49f1 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerX11.h
+++ b/intern/ghost/intern/GHOST_DisplayManagerX11.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_DisplayManagerX11 class.
*/
-#ifndef __GHOST_DISPLAYMANAGERX11_H__
-#define __GHOST_DISPLAYMANAGERX11_H__
+#pragma once
#include "GHOST_DisplayManager.h"
@@ -86,5 +85,3 @@ class GHOST_DisplayManagerX11 : public GHOST_DisplayManager {
private:
GHOST_SystemX11 *m_system;
};
-
-#endif //
diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.h b/intern/ghost/intern/GHOST_DropTargetWin32.h
index ee75c017981..ecce3a68835 100644
--- a/intern/ghost/intern/GHOST_DropTargetWin32.h
+++ b/intern/ghost/intern/GHOST_DropTargetWin32.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_DROPTARGETWIN32_H__
-#define __GHOST_DROPTARGETWIN32_H__
+#pragma once
#include "GHOST_SystemWin32.h"
#include "GHOST_WindowWin32.h"
@@ -150,5 +149,3 @@ class GHOST_DropTargetWin32 : public IDropTarget {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_DropTargetWin32")
#endif
};
-
-#endif // __GHOST_DROPTARGETWIN32_H__
diff --git a/intern/ghost/intern/GHOST_DropTargetX11.h b/intern/ghost/intern/GHOST_DropTargetX11.h
index 9ca12442085..066f2f6bba2 100644
--- a/intern/ghost/intern/GHOST_DropTargetX11.h
+++ b/intern/ghost/intern/GHOST_DropTargetX11.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_DROPTARGETX11_H__
-#define __GHOST_DROPTARGETX11_H__
+#pragma once
#include "GHOST_SystemX11.h"
#include "GHOST_WindowX11.h"
@@ -126,5 +125,3 @@ class GHOST_DropTargetX11 {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_DropTargetX11")
#endif
};
-
-#endif // __GHOST_DROPTARGETX11_H__
diff --git a/intern/ghost/intern/GHOST_Event.h b/intern/ghost/intern/GHOST_Event.h
index 2c14df7f243..845d62fa810 100644
--- a/intern/ghost/intern/GHOST_Event.h
+++ b/intern/ghost/intern/GHOST_Event.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_Event class.
*/
-#ifndef __GHOST_EVENT_H__
-#define __GHOST_EVENT_H__
+#pragma once
#include "GHOST_IEvent.h"
@@ -90,5 +89,3 @@ class GHOST_Event : public GHOST_IEvent {
/** Pointer to the event data. */
GHOST_TEventDataPtr m_data;
};
-
-#endif // __GHOST_EVENT_H__
diff --git a/intern/ghost/intern/GHOST_EventButton.h b/intern/ghost/intern/GHOST_EventButton.h
index 4247ae150a4..7072e0c5409 100644
--- a/intern/ghost/intern/GHOST_EventButton.h
+++ b/intern/ghost/intern/GHOST_EventButton.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_EventButton class.
*/
-#ifndef __GHOST_EVENTBUTTON_H__
-#define __GHOST_EVENTBUTTON_H__
+#pragma once
#include "GHOST_Event.h"
#include "GHOST_Window.h"
@@ -57,5 +56,3 @@ class GHOST_EventButton : public GHOST_Event {
/** The button event data. */
GHOST_TEventButtonData m_buttonEventData;
};
-
-#endif // __GHOST_EVENTBUTTON_H__
diff --git a/intern/ghost/intern/GHOST_EventCursor.h b/intern/ghost/intern/GHOST_EventCursor.h
index 8ba657fd9fa..ba85cd74723 100644
--- a/intern/ghost/intern/GHOST_EventCursor.h
+++ b/intern/ghost/intern/GHOST_EventCursor.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_EventCursor class.
*/
-#ifndef __GHOST_EVENTCURSOR_H__
-#define __GHOST_EVENTCURSOR_H__
+#pragma once
#include "GHOST_Event.h"
@@ -58,5 +57,3 @@ class GHOST_EventCursor : public GHOST_Event {
/** The x,y-coordinates of the cursor position. */
GHOST_TEventCursorData m_cursorEventData;
};
-
-#endif // __GHOST_EVENTCURSOR_H__
diff --git a/intern/ghost/intern/GHOST_EventDragnDrop.h b/intern/ghost/intern/GHOST_EventDragnDrop.h
index 36291e8a254..10975792993 100644
--- a/intern/ghost/intern/GHOST_EventDragnDrop.h
+++ b/intern/ghost/intern/GHOST_EventDragnDrop.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_EVENTDRAGNDROP_H__
-#define __GHOST_EVENTDRAGNDROP_H__
+#pragma once
#include "GHOST_Event.h"
extern "C" {
@@ -122,5 +121,3 @@ class GHOST_EventDragnDrop : public GHOST_Event {
/** The x,y-coordinates of the cursor position. */
GHOST_TEventDragnDropData m_dragnDropEventData;
};
-
-#endif // __GHOST_EVENTDRAGNDROP_H__
diff --git a/intern/ghost/intern/GHOST_EventKey.h b/intern/ghost/intern/GHOST_EventKey.h
index 8f59c555914..cb71b452d80 100644
--- a/intern/ghost/intern/GHOST_EventKey.h
+++ b/intern/ghost/intern/GHOST_EventKey.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_EventKey class.
*/
-#ifndef __GHOST_EVENTKEY_H__
-#define __GHOST_EVENTKEY_H__
+#pragma once
#include <string.h>
@@ -84,5 +83,3 @@ class GHOST_EventKey : public GHOST_Event {
/** The key event data. */
GHOST_TEventKeyData m_keyEventData;
};
-
-#endif // __GHOST_EVENTKEY_H__
diff --git a/intern/ghost/intern/GHOST_EventManager.h b/intern/ghost/intern/GHOST_EventManager.h
index ada5abda89b..befbdc72a5c 100644
--- a/intern/ghost/intern/GHOST_EventManager.h
+++ b/intern/ghost/intern/GHOST_EventManager.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_EventManager class.
*/
-#ifndef __GHOST_EVENTMANAGER_H__
-#define __GHOST_EVENTMANAGER_H__
+#pragma once
#include <deque>
#include <vector>
@@ -140,5 +139,3 @@ class GHOST_EventManager {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_EventManager")
#endif
};
-
-#endif // __GHOST_EVENTMANAGER_H__
diff --git a/intern/ghost/intern/GHOST_EventNDOF.h b/intern/ghost/intern/GHOST_EventNDOF.h
index 196d3868ccd..64e67434b74 100644
--- a/intern/ghost/intern/GHOST_EventNDOF.h
+++ b/intern/ghost/intern/GHOST_EventNDOF.h
@@ -18,8 +18,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_EVENTNDOF_H__
-#define __GHOST_EVENTNDOF_H__
+#pragma once
#ifndef WITH_INPUT_NDOF
# error NDOF code included in non-NDOF-enabled build
@@ -50,5 +49,3 @@ class GHOST_EventNDOFButton : public GHOST_Event {
m_data = &m_buttonData;
}
};
-
-#endif // __GHOST_EVENTNDOF_H__
diff --git a/intern/ghost/intern/GHOST_EventPrinter.h b/intern/ghost/intern/GHOST_EventPrinter.h
index ead16525ec6..42de4da5ee5 100644
--- a/intern/ghost/intern/GHOST_EventPrinter.h
+++ b/intern/ghost/intern/GHOST_EventPrinter.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_EventPrinter class.
*/
-#ifndef __GHOST_EVENTPRINTER_H__
-#define __GHOST_EVENTPRINTER_H__
+#pragma once
#include "GHOST_IEventConsumer.h"
@@ -48,5 +47,3 @@ class GHOST_EventPrinter : public GHOST_IEventConsumer {
*/
void getKeyString(GHOST_TKey key, char str[32]) const;
};
-
-#endif // __GHOST_EVENTPRINTER_H__
diff --git a/intern/ghost/intern/GHOST_EventString.h b/intern/ghost/intern/GHOST_EventString.h
index f0d3ffb9e91..8cd24a8a78b 100644
--- a/intern/ghost/intern/GHOST_EventString.h
+++ b/intern/ghost/intern/GHOST_EventString.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_EventString class.
*/
-#ifndef __GHOST_EVENTSTRING_H__
-#define __GHOST_EVENTSTRING_H__
+#pragma once
#include "GHOST_Event.h"
@@ -54,5 +53,3 @@ class GHOST_EventString : public GHOST_Event {
free(m_data);
}
};
-
-#endif // __GHOST_EVENTSTRING_H__
diff --git a/intern/ghost/intern/GHOST_EventTrackpad.h b/intern/ghost/intern/GHOST_EventTrackpad.h
index 795e969b16d..a22f8a34fad 100644
--- a/intern/ghost/intern/GHOST_EventTrackpad.h
+++ b/intern/ghost/intern/GHOST_EventTrackpad.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_EventTrackpad class.
*/
-#ifndef __GHOST_EVENTTRACKPAD_H__
-#define __GHOST_EVENTTRACKPAD_H__
+#pragma once
#include "GHOST_Event.h"
@@ -61,5 +60,3 @@ class GHOST_EventTrackpad : public GHOST_Event {
/** The mouse pan data */
GHOST_TEventTrackpadData m_trackpadEventData;
};
-
-#endif // _GHOST_EVENT_PAN_H_
diff --git a/intern/ghost/intern/GHOST_EventWheel.h b/intern/ghost/intern/GHOST_EventWheel.h
index 4d3eeb9cd83..ea62e02d08d 100644
--- a/intern/ghost/intern/GHOST_EventWheel.h
+++ b/intern/ghost/intern/GHOST_EventWheel.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_EventWheel class.
*/
-#ifndef __GHOST_EVENTWHEEL_H__
-#define __GHOST_EVENTWHEEL_H__
+#pragma once
#include "GHOST_Event.h"
@@ -51,5 +50,3 @@ class GHOST_EventWheel : public GHOST_Event {
/** The z-displacement of the mouse wheel. */
GHOST_TEventWheelData m_wheelEventData;
};
-
-#endif // __GHOST_EVENTWHEEL_H__
diff --git a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
index b199c5f9b28..de8bf9f1a5a 100644
--- a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
+++ b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h
@@ -18,8 +18,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_IXRGRAPHICSBINDING_H__
-#define __GHOST_IXRGRAPHICSBINDING_H__
+#pragma once
#include <memory>
#include <string>
@@ -71,5 +70,3 @@ class GHOST_IXrGraphicsBinding {
std::unique_ptr<GHOST_IXrGraphicsBinding> GHOST_XrGraphicsBindingCreateFromType(
GHOST_TXrGraphicsBinding type, GHOST_Context *ghost_ctx);
-
-#endif /* __GHOST_IXRGRAPHICSBINDING_H__ */
diff --git a/intern/ghost/intern/GHOST_IconX11.h b/intern/ghost/intern/GHOST_IconX11.h
index c5bcf4bedeb..615a7dae6b5 100644
--- a/intern/ghost/intern/GHOST_IconX11.h
+++ b/intern/ghost/intern/GHOST_IconX11.h
@@ -22,8 +22,7 @@
* Icon image data for X11.
*/
-#ifndef __GHOST_ICONX11_H__
-#define __GHOST_ICONX11_H__
+#pragma once
/*
* import bpy
@@ -1013,5 +1012,3 @@ static const unsigned long BLENDER_ICONS_WM_X11[] = {
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
-
-#endif // __GHOST_ICONX11_H__
diff --git a/intern/ghost/intern/GHOST_ImeWin32.h b/intern/ghost/intern/GHOST_ImeWin32.h
index 112217023a7..74698d50659 100644
--- a/intern/ghost/intern/GHOST_ImeWin32.h
+++ b/intern/ghost/intern/GHOST_ImeWin32.h
@@ -23,8 +23,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_IME_H__
-#define __GHOST_IME_H__
+#pragma once
#ifdef WITH_INPUT_IME
@@ -388,4 +387,3 @@ class GHOST_ImeWin32 {
};
#endif // WITH_INPUT_IME
-#endif // __GHOST_IME_H__
diff --git a/intern/ghost/intern/GHOST_ModifierKeys.h b/intern/ghost/intern/GHOST_ModifierKeys.h
index 27ad4034068..c41ce8b7f39 100644
--- a/intern/ghost/intern/GHOST_ModifierKeys.h
+++ b/intern/ghost/intern/GHOST_ModifierKeys.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_ModifierKeys struct.
*/
-#ifndef __GHOST_MODIFIERKEYS_H__
-#define __GHOST_MODIFIERKEYS_H__
+#pragma once
#include "GHOST_Types.h"
@@ -87,5 +86,3 @@ struct GHOST_ModifierKeys {
/** Bitfield that stores the appropriate key state. */
GHOST_TUns8 m_OS : 1;
};
-
-#endif // __GHOST_MODIFIERKEYS_H__
diff --git a/intern/ghost/intern/GHOST_NDOFManager.h b/intern/ghost/intern/GHOST_NDOFManager.h
index a190607ca66..d0b49bc13c2 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.h
+++ b/intern/ghost/intern/GHOST_NDOFManager.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __GHOST_NDOFMANAGER_H__
-#define __GHOST_NDOFMANAGER_H__
+#pragma once
#ifndef WITH_INPUT_NDOF
# error NDOF code included in non-NDOF-enabled build
@@ -167,5 +166,3 @@ class GHOST_NDOFManager {
bool m_motionEventPending;
float m_deadZone; // discard motion with each component < this
};
-
-#endif
diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h
index bd1e6903f94..f7c3599502e 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h
+++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __GHOST_NDOFMANAGERCOCOA_H__
-#define __GHOST_NDOFMANAGERCOCOA_H__
+#pragma once
#include "GHOST_NDOFManager.h"
@@ -29,5 +28,3 @@ class GHOST_NDOFManagerCocoa : public GHOST_NDOFManager {
bool available();
};
-
-#endif // #include guard
diff --git a/intern/ghost/intern/GHOST_NDOFManagerUnix.h b/intern/ghost/intern/GHOST_NDOFManagerUnix.h
index 75bd022631a..6dd4289ffac 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerUnix.h
+++ b/intern/ghost/intern/GHOST_NDOFManagerUnix.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __GHOST_NDOFMANAGERUNIX_H__
-#define __GHOST_NDOFMANAGERUNIX_H__
+#pragma once
#include "GHOST_NDOFManager.h"
@@ -32,5 +31,3 @@ class GHOST_NDOFManagerUnix : public GHOST_NDOFManager {
private:
bool m_available;
};
-
-#endif /* __GHOST_NDOFMANAGERUNIX_H__ */
diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.h b/intern/ghost/intern/GHOST_NDOFManagerWin32.h
index 9ed5e6ab978..62d9b9207dc 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerWin32.h
+++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __GHOST_NDOFMANAGERWIN32_H__
-#define __GHOST_NDOFMANAGERWIN32_H__
+#pragma once
#include "GHOST_NDOFManager.h"
@@ -24,5 +23,3 @@ class GHOST_NDOFManagerWin32 : public GHOST_NDOFManager {
GHOST_NDOFManagerWin32(GHOST_System &);
bool available();
};
-
-#endif // #include guard
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index c2d712c11cd..e29a9ba0c29 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_System class.
*/
-#ifndef __GHOST_SYSTEM_H__
-#define __GHOST_SYSTEM_H__
+#pragma once
#include "GHOST_ISystem.h"
@@ -424,5 +423,3 @@ inline GHOST_NDOFManager *GHOST_System::getNDOFManager() const
return m_ndofManager;
}
#endif
-
-#endif // __GHOST_SYSTEM_H__
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index bbd6f1d8995..8e36cebb88a 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_SystemCocoa class.
*/
-#ifndef __GHOST_SYSTEMCOCOA_H__
-#define __GHOST_SYSTEMCOCOA_H__
+#pragma once
#ifndef __APPLE__
# error Apple OSX only!
@@ -313,5 +312,3 @@ class GHOST_SystemCocoa : public GHOST_System {
/** Is the scroll wheel event generated by a multitouch trackpad or mouse? */
bool m_multiTouchScroll;
};
-
-#endif // __GHOST_SYSTEMCOCOA_H__
diff --git a/intern/ghost/intern/GHOST_SystemNULL.h b/intern/ghost/intern/GHOST_SystemNULL.h
index 186cb92d1aa..5becf110b15 100644
--- a/intern/ghost/intern/GHOST_SystemNULL.h
+++ b/intern/ghost/intern/GHOST_SystemNULL.h
@@ -19,8 +19,7 @@
* Declaration of GHOST_SystemNULL class.
*/
-#ifndef __GHOST_SYSTEMNULL_H__
-#define __GHOST_SYSTEMNULL_H__
+#pragma once
#include "../GHOST_Types.h"
#include "GHOST_DisplayManagerNULL.h"
@@ -130,5 +129,3 @@ class GHOST_SystemNULL : public GHOST_System {
((glSettings.flags & GHOST_glStereoVisual) != 0));
}
};
-
-#endif /* __GHOST_SYSTEMNULL_H__ */
diff --git a/intern/ghost/intern/GHOST_SystemPaths.h b/intern/ghost/intern/GHOST_SystemPaths.h
index 04180a143cb..ab53b2813cd 100644
--- a/intern/ghost/intern/GHOST_SystemPaths.h
+++ b/intern/ghost/intern/GHOST_SystemPaths.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_SYSTEMPATHS_H__
-#define __GHOST_SYSTEMPATHS_H__
+#pragma once
#include "GHOST_ISystemPaths.h"
@@ -70,5 +69,3 @@ class GHOST_SystemPaths : public GHOST_ISystemPaths {
*/
virtual void addToSystemRecentFiles(const char *filename) const = 0;
};
-
-#endif
diff --git a/intern/ghost/intern/GHOST_SystemPathsCocoa.h b/intern/ghost/intern/GHOST_SystemPathsCocoa.h
index b66379649e7..188f6f02286 100644
--- a/intern/ghost/intern/GHOST_SystemPathsCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemPathsCocoa.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_SYSTEMPATHSCOCOA_H__
-#define __GHOST_SYSTEMPATHSCOCOA_H__
+#pragma once
#ifndef __APPLE__
# error Apple OSX only!
@@ -67,5 +66,3 @@ class GHOST_SystemPathsCocoa : public GHOST_SystemPaths {
*/
void addToSystemRecentFiles(const char *filename) const;
};
-
-#endif // __GHOST_SYSTEMPATHSCOCOA_H__
diff --git a/intern/ghost/intern/GHOST_SystemPathsUnix.h b/intern/ghost/intern/GHOST_SystemPathsUnix.h
index f9f89f6e79b..8d2f26a28aa 100644
--- a/intern/ghost/intern/GHOST_SystemPathsUnix.h
+++ b/intern/ghost/intern/GHOST_SystemPathsUnix.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_SYSTEMPATHSUNIX_H__
-#define __GHOST_SYSTEMPATHSUNIX_H__
+#pragma once
#include "../GHOST_Types.h"
#include "GHOST_SystemPaths.h"
@@ -65,5 +64,3 @@ class GHOST_SystemPathsUnix : public GHOST_SystemPaths {
*/
void addToSystemRecentFiles(const char *filename) const;
};
-
-#endif /* __GHOST_SYSTEMPATHSUNIX_H__ */
diff --git a/intern/ghost/intern/GHOST_SystemPathsWin32.h b/intern/ghost/intern/GHOST_SystemPathsWin32.h
index f1924ea51bc..1a1eab21bad 100644
--- a/intern/ghost/intern/GHOST_SystemPathsWin32.h
+++ b/intern/ghost/intern/GHOST_SystemPathsWin32.h
@@ -21,8 +21,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_SYSTEMPATHSWIN32_H__
-#define __GHOST_SYSTEMPATHSWIN32_H__
+#pragma once
#ifndef WIN32
# error WIN32 only!
@@ -74,5 +73,3 @@ class GHOST_SystemPathsWin32 : public GHOST_SystemPaths {
*/
void addToSystemRecentFiles(const char *filename) const;
};
-
-#endif // __GHOST_SYSTEMPATHSWIN32_H__
diff --git a/intern/ghost/intern/GHOST_SystemSDL.h b/intern/ghost/intern/GHOST_SystemSDL.h
index 8feec9de61d..4b2c52f8282 100644
--- a/intern/ghost/intern/GHOST_SystemSDL.h
+++ b/intern/ghost/intern/GHOST_SystemSDL.h
@@ -19,8 +19,7 @@
* Declaration of GHOST_SystemSDL class.
*/
-#ifndef __GHOST_SYSTEMSDL_H__
-#define __GHOST_SYSTEMSDL_H__
+#pragma once
#include "../GHOST_Types.h"
#include "GHOST_DisplayManagerSDL.h"
@@ -102,5 +101,3 @@ class GHOST_SystemSDL : public GHOST_System {
/// The vector of windows that need to be updated.
std::vector<GHOST_WindowSDL *> m_dirty_windows;
};
-
-#endif
diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h
index 89cd3406b69..30ee7679287 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.h
+++ b/intern/ghost/intern/GHOST_SystemWayland.h
@@ -19,8 +19,7 @@
* Declaration of GHOST_SystemWayland class.
*/
-#ifndef __GHOST_SYSTEMWAYLAND_H__
-#define __GHOST_SYSTEMWAYLAND_H__
+#pragma once
#include "../GHOST_Types.h"
#include "GHOST_System.h"
@@ -107,5 +106,3 @@ class GHOST_SystemWayland : public GHOST_System {
struct display_t *d;
std::string selection;
};
-
-#endif /* __GHOST_SYSTEMWAYLAND_H__ */
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 849aa5a96f5..f59b106afd6 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -1143,10 +1143,16 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA
BYTE state[256] = {0};
int r;
GetKeyboardState((PBYTE)state);
+ bool ctrl_pressed = state[VK_CONTROL] & 0x80;
+ bool alt_pressed = state[VK_MENU] & 0x80;
+ /* No text with control key pressed (Alt can be used to insert special characters though!). */
+ if (ctrl_pressed && !alt_pressed) {
+ utf8_char[0] = '\0';
+ }
// Don't call ToUnicodeEx on dead keys as it clears the buffer and so won't allow diacritical
// composition.
- if (MapVirtualKeyW(vk, 2) != 0) {
+ else if (MapVirtualKeyW(vk, 2) != 0) {
// todo: ToUnicodeEx can respond with up to 4 utf16 chars (only 2 here).
// Could be up to 24 utf8 bytes.
if ((r = ToUnicodeEx(
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index 6b7901c2ade..24925b9c403 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_SystemWin32 class.
*/
-#ifndef __GHOST_SYSTEMWIN32_H__
-#define __GHOST_SYSTEMWIN32_H__
+#pragma once
#ifndef WIN32
# error WIN32 only!
@@ -488,4 +487,3 @@ inline void GHOST_SystemWin32::handleKeyboardChange(void)
}
}
}
-#endif // __GHOST_SYSTEMWIN32_H__
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 96073c21e79..c0676618101 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -1951,7 +1951,7 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt,
switch (*context) {
/* There is no context, do an XConvertSelection() */
case XCLIB_XCOUT_NONE:
- /* Initialise return length to 0 */
+ /* Initialize return length to 0. */
if (*len > 0) {
free(*txt);
*len = 0;
@@ -2169,7 +2169,7 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const
}
}
else if (owner == None)
- return (NULL);
+ return NULL;
/* Restore events so copy doesn't swallow other event types (keyboard/mouse). */
vector<XEvent> restore_events;
@@ -2237,7 +2237,7 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const
return tmp_data;
}
- return (NULL);
+ return NULL;
}
void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const
diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h
index 5888605ec95..ad58138d416 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_SystemX11 class.
*/
-#ifndef __GHOST_SYSTEMX11_H__
-#define __GHOST_SYSTEMX11_H__
+#pragma once
#include <X11/XKBlib.h> /* allow detectable autorepeate */
#include <X11/Xlib.h>
@@ -392,5 +391,3 @@ class GHOST_SystemX11 : public GHOST_System {
bool generateWindowExposeEvents();
};
-
-#endif
diff --git a/intern/ghost/intern/GHOST_TaskbarWin32.h b/intern/ghost/intern/GHOST_TaskbarWin32.h
index 58641123c24..e6464f5e626 100644
--- a/intern/ghost/intern/GHOST_TaskbarWin32.h
+++ b/intern/ghost/intern/GHOST_TaskbarWin32.h
@@ -17,8 +17,7 @@
/** \file
* \ingroup GHOST
*/
-#ifndef __GHOST_TASKBARWIN32_H__
-#define __GHOST_TASKBARWIN32_H__
+#pragma once
#ifndef WIN32
# error WIN32 only!
@@ -128,5 +127,3 @@ class ITaskbarList3 : public ITaskbarList2 {
virtual HRESULT STDMETHODCALLTYPE SetThumbnailClip(HWND hwnd, RECT *prcClip) = 0;
};
#endif /* ITaskbarList3 */
-
-#endif /*__GHOST_TASKBARWIN32_H__*/
diff --git a/intern/ghost/intern/GHOST_TaskbarX11.h b/intern/ghost/intern/GHOST_TaskbarX11.h
index cd00e25106c..25de5aa9511 100644
--- a/intern/ghost/intern/GHOST_TaskbarX11.h
+++ b/intern/ghost/intern/GHOST_TaskbarX11.h
@@ -17,8 +17,7 @@
/** \file
* \ingroup GHOST
*/
-#ifndef __GHOST_TASKBARX11_H__
-#define __GHOST_TASKBARX11_H__
+#pragma once
class GHOST_TaskBarX11 {
public:
@@ -34,5 +33,3 @@ class GHOST_TaskBarX11 {
private:
void *handle;
};
-
-#endif /*__GHOST_TASKBARX11_H__*/
diff --git a/intern/ghost/intern/GHOST_TimerManager.h b/intern/ghost/intern/GHOST_TimerManager.h
index 039663a7a0e..2e0f5d42230 100644
--- a/intern/ghost/intern/GHOST_TimerManager.h
+++ b/intern/ghost/intern/GHOST_TimerManager.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_TimerManager class.
*/
-#ifndef __GHOST_TIMERMANAGER_H__
-#define __GHOST_TIMERMANAGER_H__
+#pragma once
#include <vector>
@@ -112,5 +111,3 @@ class GHOST_TimerManager {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_TimerManager")
#endif
};
-
-#endif // __GHOST_TIMERMANAGER_H__
diff --git a/intern/ghost/intern/GHOST_TimerTask.h b/intern/ghost/intern/GHOST_TimerTask.h
index 561d9b3e705..6dc0728e19b 100644
--- a/intern/ghost/intern/GHOST_TimerTask.h
+++ b/intern/ghost/intern/GHOST_TimerTask.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_TimerTask class.
*/
-#ifndef __GHOST_TIMERTASK_H__
-#define __GHOST_TIMERTASK_H__
+#pragma once
#include "GHOST_ITimerTask.h"
@@ -179,5 +178,3 @@ class GHOST_TimerTask : public GHOST_ITimerTask {
/** Auxiliary storage room. */
GHOST_TUns32 m_auxData;
};
-
-#endif // __GHOST_TIMERTASK_H__
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 7cfea5110c5..c8c21b2b08f 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_Window class.
*/
-#ifndef __GHOST_WINDOW_H__
-#define __GHOST_WINDOW_H__
+#pragma once
#include "GHOST_IWindow.h"
@@ -456,5 +455,3 @@ inline GHOST_TStandardCursor GHOST_Window::getCursorShape() const
{
return m_cursorShape;
}
-
-#endif // _GHOST_WINDOW_H
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.h b/intern/ghost/intern/GHOST_WindowCocoa.h
index 15429eab5db..97486c9e77a 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.h
+++ b/intern/ghost/intern/GHOST_WindowCocoa.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_WindowCocoa class.
*/
-#ifndef __GHOST_WINDOWCOCOA_H__
-#define __GHOST_WINDOWCOCOA_H__
+#pragma once
#ifndef __APPLE__
# error Apple OSX only!
@@ -327,5 +326,3 @@ class GHOST_WindowCocoa : public GHOST_Window {
bool m_debug_context; // for debug messages during context setup
bool m_is_dialog;
};
-
-#endif // __GHOST_WINDOWCOCOA_H__
diff --git a/intern/ghost/intern/GHOST_WindowManager.h b/intern/ghost/intern/GHOST_WindowManager.h
index 661439191c5..34fdfd30f27 100644
--- a/intern/ghost/intern/GHOST_WindowManager.h
+++ b/intern/ghost/intern/GHOST_WindowManager.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_WindowManager class.
*/
-#ifndef __GHOST_WINDOWMANAGER_H__
-#define __GHOST_WINDOWMANAGER_H__
+#pragma once
#include <vector>
@@ -149,5 +148,3 @@ class GHOST_WindowManager {
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_WindowManager")
#endif
};
-
-#endif // __GHOST_WINDOWMANAGER_H__
diff --git a/intern/ghost/intern/GHOST_WindowNULL.h b/intern/ghost/intern/GHOST_WindowNULL.h
index e1aa0cb7f13..0b5a7ee3450 100644
--- a/intern/ghost/intern/GHOST_WindowNULL.h
+++ b/intern/ghost/intern/GHOST_WindowNULL.h
@@ -19,8 +19,7 @@
* Declaration of GHOST_WindowNULL class.
*/
-#ifndef __GHOST_WINDOWNULL_H__
-#define __GHOST_WINDOWNULL_H__
+#pragma once
#include "GHOST_Window.h"
@@ -177,5 +176,3 @@ class GHOST_WindowNULL : public GHOST_Window {
return NULL;
}
};
-
-#endif // __GHOST_WINDOWNULL_H__
diff --git a/intern/ghost/intern/GHOST_WindowSDL.h b/intern/ghost/intern/GHOST_WindowSDL.h
index 5039c742c9d..643c54c282e 100644
--- a/intern/ghost/intern/GHOST_WindowSDL.h
+++ b/intern/ghost/intern/GHOST_WindowSDL.h
@@ -19,8 +19,7 @@
* Declaration of GHOST_WindowSDL class.
*/
-#ifndef __GHOST_WINDOWSDL_H__
-#define __GHOST_WINDOWSDL_H__
+#pragma once
#include "GHOST_SystemSDL.h"
#include "GHOST_Window.h"
@@ -149,5 +148,3 @@ class GHOST_WindowSDL : public GHOST_Window {
GHOST_TUns16 getDPIHint();
};
-
-#endif // __GHOST_WINDOWSDL_H__
diff --git a/intern/ghost/intern/GHOST_WindowWayland.h b/intern/ghost/intern/GHOST_WindowWayland.h
index ff1eb60e154..1ee41f4d0f6 100644
--- a/intern/ghost/intern/GHOST_WindowWayland.h
+++ b/intern/ghost/intern/GHOST_WindowWayland.h
@@ -20,8 +20,7 @@
* Declaration of GHOST_WindowWayland class.
*/
-#ifndef __GHOST_WINDOWWAYLAND_H__
-#define __GHOST_WINDOWWAYLAND_H__
+#pragma once
#include "GHOST_Window.h"
@@ -124,5 +123,3 @@ class GHOST_WindowWayland : public GHOST_Window {
*/
GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type) override;
};
-
-#endif // __GHOST_WINDOWWAYLAND_H__
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index dbed7c5ee5f..224ff53bf7b 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_WindowWin32 class.
*/
-#ifndef __GHOST_WINDOWWIN32_H__
-#define __GHOST_WINDOWWIN32_H__
+#pragma once
#ifndef WIN32
# error WIN32 only!
@@ -586,5 +585,3 @@ class GHOST_WindowWin32 : public GHOST_Window {
#endif
bool m_debug_context;
};
-
-#endif // __GHOST_WINDOWWIN32_H__
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 691f1790a2d..9a38631adb9 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -901,7 +901,7 @@ bool GHOST_WindowX11::netwmIsMaximized(void) const
if (prop_ret)
XFree(prop_ret);
- return (st);
+ return st;
}
void GHOST_WindowX11::netwmFullScreen(bool set)
@@ -964,7 +964,7 @@ bool GHOST_WindowX11::netwmIsFullScreen(void) const
if (prop_ret)
XFree(prop_ret);
- return (st);
+ return st;
}
void GHOST_WindowX11::motifFullScreen(bool set)
@@ -1018,7 +1018,7 @@ bool GHOST_WindowX11::motifIsFullScreen(void) const
if (prop_ret)
XFree(prop_ret);
- return (state);
+ return state;
}
GHOST_TWindowState GHOST_WindowX11::getState() const
@@ -1040,7 +1040,7 @@ GHOST_TWindowState GHOST_WindowX11::getState() const
state_ret = GHOST_kWindowStateFullScreen;
else if (netwmIsMaximized() == True)
state_ret = GHOST_kWindowStateMaximized;
- return (state_ret);
+ return state_ret;
}
GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
@@ -1078,7 +1078,7 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
if (is_motif_full == True)
motifFullScreen(False);
icccmSetState(NormalState);
- return (GHOST_kSuccess);
+ return GHOST_kSuccess;
}
if (state == GHOST_kWindowStateFullScreen) {
@@ -1087,7 +1087,7 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
* isn't mapped.
*/
if (cur_state == GHOST_kWindowStateMinimized)
- return (GHOST_kFailure);
+ return GHOST_kFailure;
m_normal_state = cur_state;
@@ -1097,7 +1097,7 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
netwmFullScreen(True);
if (is_motif_full == False)
motifFullScreen(True);
- return (GHOST_kSuccess);
+ return GHOST_kSuccess;
}
if (state == GHOST_kWindowStateMaximized) {
@@ -1106,7 +1106,7 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
* isn't mapped.
*/
if (cur_state == GHOST_kWindowStateMinimized)
- return (GHOST_kFailure);
+ return GHOST_kFailure;
if (is_full == True)
netwmFullScreen(False);
@@ -1114,7 +1114,7 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
motifFullScreen(False);
if (is_max == False)
netwmMaximized(True);
- return (GHOST_kSuccess);
+ return GHOST_kSuccess;
}
if (state == GHOST_kWindowStateMinimized) {
@@ -1123,10 +1123,10 @@ GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
* the window (maximized, full screen, etc).
*/
icccmSetState(IconicState);
- return (GHOST_kSuccess);
+ return GHOST_kSuccess;
}
- return (GHOST_kFailure);
+ return GHOST_kFailure;
}
GHOST_TSuccess GHOST_WindowX11::setOrder(GHOST_TWindowOrder order)
diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h
index 4232ff40b52..ef5d1755f1a 100644
--- a/intern/ghost/intern/GHOST_WindowX11.h
+++ b/intern/ghost/intern/GHOST_WindowX11.h
@@ -22,8 +22,7 @@
* Declaration of GHOST_WindowX11 class.
*/
-#ifndef __GHOST_WINDOWX11_H__
-#define __GHOST_WINDOWX11_H__
+#pragma once
#include "GHOST_Window.h"
#include <X11/Xlib.h>
@@ -288,5 +287,3 @@ class GHOST_WindowX11 : public GHOST_Window {
void motifFullScreen(bool set);
bool motifIsFullScreen() const;
};
-
-#endif // __GHOST_WINDOWX11_H__
diff --git a/intern/ghost/intern/GHOST_XrContext.h b/intern/ghost/intern/GHOST_XrContext.h
index 9be57cd90cc..d2edb40c080 100644
--- a/intern/ghost/intern/GHOST_XrContext.h
+++ b/intern/ghost/intern/GHOST_XrContext.h
@@ -18,8 +18,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_XRCONTEXT_H__
-#define __GHOST_XRCONTEXT_H__
+#pragma once
#include <memory>
#include <vector>
@@ -131,5 +130,3 @@ class GHOST_XrContext : public GHOST_IXrContext {
GHOST_TXrGraphicsBinding determineGraphicsBindingTypeToEnable(
const GHOST_XrContextCreateInfo *create_info);
};
-
-#endif // __GHOST_XRCONTEXT_H__
diff --git a/intern/ghost/intern/GHOST_XrException.h b/intern/ghost/intern/GHOST_XrException.h
index 9f779961e4f..30c33eaf98f 100644
--- a/intern/ghost/intern/GHOST_XrException.h
+++ b/intern/ghost/intern/GHOST_XrException.h
@@ -18,8 +18,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_XREXCEPTION_H__
-#define __GHOST_XREXCEPTION_H__
+#pragma once
#include <exception>
@@ -41,5 +40,3 @@ class GHOST_XrException : public std::exception {
const char *m_msg;
int m_result;
};
-
-#endif // __GHOST_XREXCEPTION_H__
diff --git a/intern/ghost/intern/GHOST_XrSession.h b/intern/ghost/intern/GHOST_XrSession.h
index da0128b2851..74555c0c170 100644
--- a/intern/ghost/intern/GHOST_XrSession.h
+++ b/intern/ghost/intern/GHOST_XrSession.h
@@ -18,8 +18,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_XRSESSION_H__
-#define __GHOST_XRSESSION_H__
+#pragma once
#include <map>
#include <memory>
@@ -84,5 +83,3 @@ class GHOST_XrSession {
void beginFrameDrawing();
void endFrameDrawing(std::vector<XrCompositionLayerBaseHeader *> *layers);
};
-
-#endif /* GHOST_XRSESSION_H__ */
diff --git a/intern/ghost/intern/GHOST_XrSwapchain.h b/intern/ghost/intern/GHOST_XrSwapchain.h
index 7a3e7fcea68..33a1c17b993 100644
--- a/intern/ghost/intern/GHOST_XrSwapchain.h
+++ b/intern/ghost/intern/GHOST_XrSwapchain.h
@@ -18,8 +18,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_XRSWAPCHAIN_H__
-#define __GHOST_XRSWAPCHAIN_H__
+#pragma once
#include <memory>
@@ -45,5 +44,3 @@ class GHOST_XrSwapchain {
int32_t m_image_width, m_image_height;
bool m_is_srgb_buffer = false;
};
-
-#endif // GHOST_XRSWAPCHAIN_H
diff --git a/intern/ghost/intern/GHOST_Xr_intern.h b/intern/ghost/intern/GHOST_Xr_intern.h
index d59ffd31940..137541c4528 100644
--- a/intern/ghost/intern/GHOST_Xr_intern.h
+++ b/intern/ghost/intern/GHOST_Xr_intern.h
@@ -18,8 +18,7 @@
* \ingroup GHOST
*/
-#ifndef __GHOST_XR_INTERN_H__
-#define __GHOST_XR_INTERN_H__
+#pragma once
#include <memory>
#include <vector>
@@ -46,5 +45,3 @@
(void)_res; \
} \
(void)0
-
-#endif /* __GHOST_XR_INTERN_H__ */
diff --git a/intern/ghost/intern/GHOST_Xr_openxr_includes.h b/intern/ghost/intern/GHOST_Xr_openxr_includes.h
index 9cac43b1549..d1deaeb0d1a 100644
--- a/intern/ghost/intern/GHOST_Xr_openxr_includes.h
+++ b/intern/ghost/intern/GHOST_Xr_openxr_includes.h
@@ -22,8 +22,7 @@
* installed.
*/
-#ifndef __GHOST_XR_SYSTEM_INCLUDES_H__
-#define __GHOST_XR_SYSTEM_INCLUDES_H__
+#pragma once
/* Platform headers */
#ifdef XR_USE_PLATFORM_WIN32
@@ -48,5 +47,3 @@
#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>
-
-#endif /* __GHOST_XR_SYSTEM_INCLUDES_H__ */
diff --git a/intern/ghost/test/multitest/MultiTest.c b/intern/ghost/test/multitest/MultiTest.c
index 5ddcb2470a8..cf7a06bf3e5 100644
--- a/intern/ghost/test/multitest/MultiTest.c
+++ b/intern/ghost/test/multitest/MultiTest.c
@@ -330,8 +330,7 @@ MainWindow *mainwindow_new(MultiTestApp *app)
if (win) {
MainWindow *mw = MEM_callocN(sizeof(*mw), "mainwindow_new");
- GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(win);
- mw->gpu_context = GPU_context_create(default_fb);
+ mw->gpu_context = GPU_context_create(win);
GPU_init();
mw->app = app;
@@ -587,8 +586,7 @@ LoggerWindow *loggerwindow_new(MultiTestApp *app)
if (win) {
LoggerWindow *lw = MEM_callocN(sizeof(*lw), "loggerwindow_new");
- GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(win);
- lw->gpu_context = GPU_context_create(default_fb);
+ lw->gpu_context = GPU_context_create(win);
GPU_init();
int bbox[2][2];
@@ -788,8 +786,7 @@ ExtraWindow *extrawindow_new(MultiTestApp *app)
if (win) {
ExtraWindow *ew = MEM_callocN(sizeof(*ew), "mainwindow_new");
- GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(win);
- ew->gpu_context = GPU_context_create(default_fb);
+ ew->gpu_context = GPU_context_create(win);
GPU_init();
ew->app = app;
diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt
index 1ab365a376a..ccc1500c014 100644
--- a/intern/guardedalloc/CMakeLists.txt
+++ b/intern/guardedalloc/CMakeLists.txt
@@ -78,3 +78,19 @@ if(WITH_CXX_GUARDEDALLOC)
)
blender_add_lib(bf_intern_guardedalloc_cpp "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
endif()
+
+if(WITH_GTESTS)
+ set(TEST_SRC
+ tests/guardedalloc_alignment_test.cc
+ tests/guardedalloc_overflow_test.cc
+ )
+ set(TEST_INC
+ ../../source/blender/blenlib
+ )
+ set(TEST_LIB
+ bf_intern_guardedalloc
+ bf_blenlib
+ )
+ include(GTestTesting)
+ blender_add_test_lib(bf_intern_guardedalloc_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
+endif()
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index 604330bd1d3..9c62b2396f6 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -213,7 +213,7 @@ extern const char *(*MEM_name_ptr)(void *vmemh);
/** This should be called as early as possible in the program. When it has been called, information
* about memory leaks will be printed on exit. */
-void MEM_initialize_memleak_detection(void);
+void MEM_init_memleak_detection(void);
/* Switch allocator to slower but fully guarded mode. */
void MEM_use_guarded_allocator(void);
diff --git a/intern/guardedalloc/intern/leak_detector.cc b/intern/guardedalloc/intern/leak_detector.cc
index 4b2689ee28c..d7b6f749742 100644
--- a/intern/guardedalloc/intern/leak_detector.cc
+++ b/intern/guardedalloc/intern/leak_detector.cc
@@ -46,7 +46,7 @@ class MemLeakPrinter {
};
} // namespace
-void MEM_initialize_memleak_detection(void)
+void MEM_init_memleak_detection(void)
{
/**
* This variable is constructed when this function is first called. This should happen as soon as
diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c
index 2c207935e43..6c08cb3bb62 100644
--- a/intern/guardedalloc/intern/mallocn_guarded_impl.c
+++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c
@@ -249,9 +249,8 @@ size_t MEM_guarded_allocN_len(const void *vmemh)
memh--;
return memh->len;
}
- else {
- return 0;
- }
+
+ return 0;
}
void *MEM_guarded_dupallocN(const void *vmemh)
@@ -611,12 +610,11 @@ static int compare_len(const void *p1, const void *p2)
if (pb1->len < pb2->len) {
return 1;
}
- else if (pb1->len == pb2->len) {
+ if (pb1->len == pb2->len) {
return 0;
}
- else {
- return -1;
- }
+
+ return -1;
}
void MEM_guarded_printmemlist_stats(void)
@@ -682,7 +680,7 @@ void MEM_guarded_printmemlist_stats(void)
if (a == b) {
continue;
}
- else if (strcmp(printblock[a].name, printblock[b].name) == 0) {
+ if (strcmp(printblock[a].name, printblock[b].name) == 0) {
printblock[b].len += printblock[a].len;
printblock[b].items++;
}
@@ -1162,7 +1160,7 @@ static const char *check_memlist(MemHead *memh)
return ("Additional error in header");
}
- return (name);
+ return name;
}
size_t MEM_guarded_get_peak_memory(void)
@@ -1213,8 +1211,7 @@ const char *MEM_guarded_name_ptr(void *vmemh)
memh--;
return memh->name;
}
- else {
- return "MEM_guarded_name_ptr(NULL)";
- }
+
+ return "MEM_guarded_name_ptr(NULL)";
}
#endif /* NDEBUG */
diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.c b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
index b71e2c963eb..8f5c9cf85a9 100644
--- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c
+++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
@@ -94,9 +94,8 @@ size_t MEM_lockfree_allocN_len(const void *vmemh)
if (vmemh) {
return MEMHEAD_FROM_PTR(vmemh)->len & ~((size_t)(MEMHEAD_ALIGN_FLAG));
}
- else {
- return 0;
- }
+
+ return 0;
}
void MEM_lockfree_freeN(void *vmemh)
@@ -436,8 +435,7 @@ const char *MEM_lockfree_name_ptr(void *vmemh)
if (vmemh) {
return "unknown block name ptr";
}
- else {
- return "MEM_lockfree_name_ptr(NULL)";
- }
+
+ return "MEM_lockfree_name_ptr(NULL)";
}
#endif /* NDEBUG */
diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c
index 245fe05b6af..a02a0f88fa9 100644
--- a/intern/guardedalloc/intern/mmap_win.c
+++ b/intern/guardedalloc/intern/mmap_win.c
@@ -138,10 +138,12 @@ void *mmap(void *UNUSED(start), size_t len, int prot, int flags, int fd, off_t o
ptr = MapViewOfFile(maphandle, access_flags, 0, offset, 0);
if (ptr == NULL) {
DWORD dwLastErr = GetLastError();
- if (dwLastErr == ERROR_MAPPED_ALIGNMENT)
+ if (dwLastErr == ERROR_MAPPED_ALIGNMENT) {
errno = EINVAL;
- else
+ }
+ else {
errno = EACCES;
+ }
CloseHandle(maphandle);
return MAP_FAILED;
}
@@ -182,18 +184,22 @@ static void mmap_addtail(volatile mmapListBase *listbase, void *vlink)
{
struct mmapLink *link = vlink;
- if (link == NULL)
+ if (link == NULL) {
return;
- if (listbase == NULL)
+ }
+ if (listbase == NULL) {
return;
+ }
link->next = 0;
link->prev = listbase->last;
- if (listbase->last)
+ if (listbase->last) {
((struct mmapLink *)listbase->last)->next = link;
- if (listbase->first == NULL)
+ }
+ if (listbase->first == NULL) {
listbase->first = link;
+ }
listbase->last = link;
}
@@ -201,30 +207,37 @@ static void mmap_remlink(volatile mmapListBase *listbase, void *vlink)
{
struct mmapLink *link = vlink;
- if (link == NULL)
+ if (link == NULL) {
return;
- if (listbase == NULL)
+ }
+ if (listbase == NULL) {
return;
-
- if (link->next)
+ }
+ if (link->next) {
link->next->prev = link->prev;
- if (link->prev)
+ }
+ if (link->prev) {
link->prev->next = link->next;
+ }
- if (listbase->last == link)
+ if (listbase->last == link) {
listbase->last = link->prev;
- if (listbase->first == link)
+ }
+ if (listbase->first == link) {
listbase->first = link->next;
+ }
}
static void *mmap_findlink(volatile mmapListBase *listbase, void *ptr)
{
MemMap *mm;
- if (ptr == NULL)
+ if (ptr == NULL) {
return NULL;
- if (listbase == NULL)
+ }
+ if (listbase == NULL) {
return NULL;
+ }
mm = (MemMap *)listbase->first;
while (mm) {
diff --git a/tests/gtests/guardedalloc/guardedalloc_alignment_test.cc b/intern/guardedalloc/tests/guardedalloc_alignment_test.cc
index 4c676c6cc76..4c676c6cc76 100644
--- a/tests/gtests/guardedalloc/guardedalloc_alignment_test.cc
+++ b/intern/guardedalloc/tests/guardedalloc_alignment_test.cc
diff --git a/tests/gtests/guardedalloc/guardedalloc_overflow_test.cc b/intern/guardedalloc/tests/guardedalloc_overflow_test.cc
index bd47482d033..eb9a2a68cb0 100644
--- a/tests/gtests/guardedalloc/guardedalloc_overflow_test.cc
+++ b/intern/guardedalloc/tests/guardedalloc_overflow_test.cc
@@ -11,6 +11,11 @@
# define ABORT_PREDICATE ::testing::KilledBySignal(SIGABRT)
#endif
+#ifdef __GNUC__
+/* Disable since it's the purpose of this test. */
+# pragma GCC diagnostic ignored "-Walloc-size-larger-than="
+#endif
+
namespace {
void MallocArray(size_t len, size_t size)
diff --git a/intern/itasc/Scene.cpp b/intern/itasc/Scene.cpp
index 5438a005d7c..0d2486ceac7 100644
--- a/intern/itasc/Scene.cpp
+++ b/intern/itasc/Scene.cpp
@@ -16,532 +16,623 @@
namespace iTaSC {
class SceneLock : public ControlledObject::JointLockCallback {
-private:
- Scene* m_scene;
- Range m_qrange;
-
-public:
- SceneLock(Scene* scene) :
- m_scene(scene), m_qrange(0,0) {}
- virtual ~SceneLock() {}
-
- void setRange(Range& range)
- {
- m_qrange = range;
- }
- // lock a joint, no need to update output
- virtual void lockJoint(unsigned int q_nr, unsigned int ndof)
- {
- q_nr += m_qrange.start;
- project(m_scene->m_Wq, Range(q_nr, ndof), m_qrange).setZero();
- }
- // lock a joint and update output in view of reiteration
- virtual void lockJoint(unsigned int q_nr, unsigned int ndof, double* qdot)
- {
- q_nr += m_qrange.start;
- project(m_scene->m_Wq, Range(q_nr, ndof), m_qrange).setZero();
- // update the output vector so that the movement of this joint will be
- // taken into account and we can put the joint back in its initial position
- // which means that the jacobian doesn't need to be changed
- for (unsigned int i=0 ;i<ndof ; ++i, ++q_nr) {
- m_scene->m_ydot -= m_scene->m_A.col(q_nr)*qdot[i];
- }
- }
+ private:
+ Scene *m_scene;
+ Range m_qrange;
+
+ public:
+ SceneLock(Scene *scene) : m_scene(scene), m_qrange(0, 0)
+ {
+ }
+ virtual ~SceneLock()
+ {
+ }
+
+ void setRange(Range &range)
+ {
+ m_qrange = range;
+ }
+ // lock a joint, no need to update output
+ virtual void lockJoint(unsigned int q_nr, unsigned int ndof)
+ {
+ q_nr += m_qrange.start;
+ project(m_scene->m_Wq, Range(q_nr, ndof), m_qrange).setZero();
+ }
+ // lock a joint and update output in view of reiteration
+ virtual void lockJoint(unsigned int q_nr, unsigned int ndof, double *qdot)
+ {
+ q_nr += m_qrange.start;
+ project(m_scene->m_Wq, Range(q_nr, ndof), m_qrange).setZero();
+ // update the output vector so that the movement of this joint will be
+ // taken into account and we can put the joint back in its initial position
+ // which means that the jacobian doesn't need to be changed
+ for (unsigned int i = 0; i < ndof; ++i, ++q_nr) {
+ m_scene->m_ydot -= m_scene->m_A.col(q_nr) * qdot[i];
+ }
+ }
};
-Scene::Scene():
- m_A(), m_B(), m_Atemp(), m_Wq(), m_Jf(), m_Jq(), m_Ju(), m_Cf(), m_Cq(), m_Jf_inv(),
- m_Vf(),m_Uf(), m_Wy(), m_ydot(), m_qdot(), m_xdot(), m_Sf(),m_tempf(),
- m_ncTotal(0),m_nqTotal(0),m_nuTotal(0),m_nsets(0),
- m_solver(NULL),m_cache(NULL)
+Scene::Scene()
+ : m_A(),
+ m_B(),
+ m_Atemp(),
+ m_Wq(),
+ m_Jf(),
+ m_Jq(),
+ m_Ju(),
+ m_Cf(),
+ m_Cq(),
+ m_Jf_inv(),
+ m_Vf(),
+ m_Uf(),
+ m_Wy(),
+ m_ydot(),
+ m_qdot(),
+ m_xdot(),
+ m_Sf(),
+ m_tempf(),
+ m_ncTotal(0),
+ m_nqTotal(0),
+ m_nuTotal(0),
+ m_nsets(0),
+ m_solver(NULL),
+ m_cache(NULL)
{
- m_minstep = 0.01;
- m_maxstep = 0.06;
+ m_minstep = 0.01;
+ m_maxstep = 0.06;
}
-Scene::~Scene()
+Scene::~Scene()
{
- ConstraintMap::iterator constraint_it;
- while ((constraint_it = constraints.begin()) != constraints.end()) {
- delete constraint_it->second;
- constraints.erase(constraint_it);
- }
- ObjectMap::iterator object_it;
- while ((object_it = objects.begin()) != objects.end()) {
- delete object_it->second;
- objects.erase(object_it);
- }
+ ConstraintMap::iterator constraint_it;
+ while ((constraint_it = constraints.begin()) != constraints.end()) {
+ delete constraint_it->second;
+ constraints.erase(constraint_it);
+ }
+ ObjectMap::iterator object_it;
+ while ((object_it = objects.begin()) != objects.end()) {
+ delete object_it->second;
+ objects.erase(object_it);
+ }
}
bool Scene::setParam(SceneParam paramId, double value)
{
- switch (paramId) {
- case MIN_TIMESTEP:
- m_minstep = value;
- break;
- case MAX_TIMESTEP:
- m_maxstep = value;
- break;
- default:
- return false;
- }
- return true;
+ switch (paramId) {
+ case MIN_TIMESTEP:
+ m_minstep = value;
+ break;
+ case MAX_TIMESTEP:
+ m_maxstep = value;
+ break;
+ default:
+ return false;
+ }
+ return true;
}
-bool Scene::addObject(const std::string& name, Object* object, UncontrolledObject* base, const std::string& baseFrame)
+bool Scene::addObject(const std::string &name,
+ Object *object,
+ UncontrolledObject *base,
+ const std::string &baseFrame)
{
- // finalize the object before adding
- if (!object->finalize())
- return false;
- //Check if Object is controlled or uncontrolled.
- if(object->getType()==Object::Controlled){
- int baseFrameIndex = base->addEndEffector(baseFrame);
- if (baseFrameIndex < 0)
- return false;
- std::pair<ObjectMap::iterator, bool> result;
- if (base->getNrOfCoordinates() == 0) {
- // base is fixed object, no coordinate range
- result = objects.insert(ObjectMap::value_type(
- name, new Object_struct(object,base,baseFrameIndex,
- Range(m_nqTotal,object->getNrOfCoordinates()),
- Range(m_ncTotal,((ControlledObject*)object)->getNrOfConstraints()),
- Range(0,0))));
- } else {
- // base is a moving object, must be in list already
- ObjectMap::iterator base_it;
- for (base_it=objects.begin(); base_it != objects.end(); base_it++) {
- if (base_it->second->object == base)
- break;
- }
- if (base_it == objects.end())
- return false;
- result = objects.insert(ObjectMap::value_type(
- name, new Object_struct(object,base,baseFrameIndex,
- Range(m_nqTotal,object->getNrOfCoordinates()),
- Range(m_ncTotal,((ControlledObject*)object)->getNrOfConstraints()),
- base_it->second->coordinaterange)));
- }
- if (!result.second) {
- return false;
- }
- m_nqTotal+=object->getNrOfCoordinates();
- m_ncTotal+=((ControlledObject*)object)->getNrOfConstraints();
- return true;
+ // finalize the object before adding
+ if (!object->finalize())
+ return false;
+ // Check if Object is controlled or uncontrolled.
+ if (object->getType() == Object::Controlled) {
+ int baseFrameIndex = base->addEndEffector(baseFrame);
+ if (baseFrameIndex < 0)
+ return false;
+ std::pair<ObjectMap::iterator, bool> result;
+ if (base->getNrOfCoordinates() == 0) {
+ // base is fixed object, no coordinate range
+ result = objects.insert(ObjectMap::value_type(
+ name,
+ new Object_struct(object,
+ base,
+ baseFrameIndex,
+ Range(m_nqTotal, object->getNrOfCoordinates()),
+ Range(m_ncTotal, ((ControlledObject *)object)->getNrOfConstraints()),
+ Range(0, 0))));
+ }
+ else {
+ // base is a moving object, must be in list already
+ ObjectMap::iterator base_it;
+ for (base_it = objects.begin(); base_it != objects.end(); base_it++) {
+ if (base_it->second->object == base)
+ break;
+ }
+ if (base_it == objects.end())
+ return false;
+ result = objects.insert(ObjectMap::value_type(
+ name,
+ new Object_struct(object,
+ base,
+ baseFrameIndex,
+ Range(m_nqTotal, object->getNrOfCoordinates()),
+ Range(m_ncTotal, ((ControlledObject *)object)->getNrOfConstraints()),
+ base_it->second->coordinaterange)));
}
- if(object->getType()==Object::UnControlled){
- if ((WorldObject*)base != &Object::world)
- return false;
- std::pair<ObjectMap::iterator,bool> result = objects.insert(ObjectMap::value_type(
- name,new Object_struct(object,base,0,
- Range(0,0),
- Range(0,0),
- Range(m_nuTotal,object->getNrOfCoordinates()))));
- if(!result.second)
- return false;
- m_nuTotal+=object->getNrOfCoordinates();
- return true;
+ if (!result.second) {
+ return false;
}
- return false;
+ m_nqTotal += object->getNrOfCoordinates();
+ m_ncTotal += ((ControlledObject *)object)->getNrOfConstraints();
+ return true;
+ }
+ if (object->getType() == Object::UnControlled) {
+ if ((WorldObject *)base != &Object::world)
+ return false;
+ std::pair<ObjectMap::iterator, bool> result = objects.insert(
+ ObjectMap::value_type(name,
+ new Object_struct(object,
+ base,
+ 0,
+ Range(0, 0),
+ Range(0, 0),
+ Range(m_nuTotal, object->getNrOfCoordinates()))));
+ if (!result.second)
+ return false;
+ m_nuTotal += object->getNrOfCoordinates();
+ return true;
+ }
+ return false;
}
-bool Scene::addConstraintSet(const std::string& name,ConstraintSet* task,const std::string& object1,const std::string& object2, const std::string& ee1, const std::string& ee2)
+bool Scene::addConstraintSet(const std::string &name,
+ ConstraintSet *task,
+ const std::string &object1,
+ const std::string &object2,
+ const std::string &ee1,
+ const std::string &ee2)
{
- //Check if objects exist:
- ObjectMap::iterator object1_it = objects.find(object1);
- ObjectMap::iterator object2_it = objects.find(object2);
- if(object1_it==objects.end()||object2_it==objects.end())
- return false;
- int ee1_index = object1_it->second->object->addEndEffector(ee1);
- int ee2_index = object2_it->second->object->addEndEffector(ee2);
- if (ee1_index < 0 || ee2_index < 0)
- return false;
- std::pair<ConstraintMap::iterator,bool> result =
- constraints.insert(ConstraintMap::value_type(name,new ConstraintSet_struct(
- task,object1_it,ee1_index,object2_it,ee2_index,
- Range(m_ncTotal,task->getNrOfConstraints()),Range(6*m_nsets,6))));
- if(!result.second)
- return false;
- m_ncTotal+=task->getNrOfConstraints();
- m_nsets+=1;
- return true;
+ // Check if objects exist:
+ ObjectMap::iterator object1_it = objects.find(object1);
+ ObjectMap::iterator object2_it = objects.find(object2);
+ if (object1_it == objects.end() || object2_it == objects.end())
+ return false;
+ int ee1_index = object1_it->second->object->addEndEffector(ee1);
+ int ee2_index = object2_it->second->object->addEndEffector(ee2);
+ if (ee1_index < 0 || ee2_index < 0)
+ return false;
+ std::pair<ConstraintMap::iterator, bool> result = constraints.insert(ConstraintMap::value_type(
+ name,
+ new ConstraintSet_struct(task,
+ object1_it,
+ ee1_index,
+ object2_it,
+ ee2_index,
+ Range(m_ncTotal, task->getNrOfConstraints()),
+ Range(6 * m_nsets, 6))));
+ if (!result.second)
+ return false;
+ m_ncTotal += task->getNrOfConstraints();
+ m_nsets += 1;
+ return true;
}
-bool Scene::addSolver(Solver* _solver){
- if(m_solver==NULL){
- m_solver=_solver;
- return true;
- }
- else
- return false;
+bool Scene::addSolver(Solver *_solver)
+{
+ if (m_solver == NULL) {
+ m_solver = _solver;
+ return true;
+ }
+ else
+ return false;
}
-bool Scene::addCache(Cache* _cache){
- if(m_cache==NULL){
- m_cache=_cache;
- return true;
- }
- else
- return false;
+bool Scene::addCache(Cache *_cache)
+{
+ if (m_cache == NULL) {
+ m_cache = _cache;
+ return true;
+ }
+ else
+ return false;
}
-bool Scene::initialize(){
-
- //prepare all matrices:
- if (m_ncTotal == 0 || m_nqTotal == 0 || m_nsets == 0)
- return false;
-
- m_A = e_zero_matrix(m_ncTotal,m_nqTotal);
- if (m_nuTotal > 0) {
- m_B = e_zero_matrix(m_ncTotal,m_nuTotal);
- m_xdot = e_zero_vector(m_nuTotal);
- m_Ju = e_zero_matrix(6*m_nsets,m_nuTotal);
- }
- m_Atemp = e_zero_matrix(m_ncTotal,6*m_nsets);
- m_ydot = e_zero_vector(m_ncTotal);
- m_qdot = e_zero_vector(m_nqTotal);
- m_Wq = e_zero_matrix(m_nqTotal,m_nqTotal);
- m_Wy = e_zero_vector(m_ncTotal);
- m_Jq = e_zero_matrix(6*m_nsets,m_nqTotal);
- m_Jf = e_zero_matrix(6*m_nsets,6*m_nsets);
- m_Jf_inv = m_Jf;
- m_Cf = e_zero_matrix(m_ncTotal,m_Jf.rows());
- m_Cq = e_zero_matrix(m_ncTotal,m_nqTotal);
-
- bool result=true;
- // finalize all objects
- for (ObjectMap::iterator it=objects.begin(); it!=objects.end(); ++it) {
- Object_struct* os = it->second;
-
- os->object->initCache(m_cache);
- if (os->constraintrange.count > 0)
- project(m_Cq,os->constraintrange,os->jointrange) = (((ControlledObject*)(os->object))->getCq());
- }
-
- m_ytask.resize(m_ncTotal);
- bool toggle=true;
- int cnt = 0;
- //Initialize all ConstraintSets:
- for(ConstraintMap::iterator it=constraints.begin();it!=constraints.end();++it){
- //Calculate the external pose:
- ConstraintSet_struct* cs = it->second;
- Frame external_pose;
- getConstraintPose(cs->task, cs, external_pose);
- result&=cs->task->initialise(external_pose);
- cs->task->initCache(m_cache);
- for (int i=0; i<cs->constraintrange.count; i++, cnt++) {
- m_ytask[cnt] = toggle;
- }
- toggle = !toggle;
- project(m_Cf,cs->constraintrange,cs->featurerange)=cs->task->getCf();
- }
+bool Scene::initialize()
+{
- if(m_solver!=NULL)
- m_solver->init(m_nqTotal,m_ncTotal,m_ytask);
- else
- return false;
+ // prepare all matrices:
+ if (m_ncTotal == 0 || m_nqTotal == 0 || m_nsets == 0)
+ return false;
+ m_A = e_zero_matrix(m_ncTotal, m_nqTotal);
+ if (m_nuTotal > 0) {
+ m_B = e_zero_matrix(m_ncTotal, m_nuTotal);
+ m_xdot = e_zero_vector(m_nuTotal);
+ m_Ju = e_zero_matrix(6 * m_nsets, m_nuTotal);
+ }
+ m_Atemp = e_zero_matrix(m_ncTotal, 6 * m_nsets);
+ m_ydot = e_zero_vector(m_ncTotal);
+ m_qdot = e_zero_vector(m_nqTotal);
+ m_Wq = e_zero_matrix(m_nqTotal, m_nqTotal);
+ m_Wy = e_zero_vector(m_ncTotal);
+ m_Jq = e_zero_matrix(6 * m_nsets, m_nqTotal);
+ m_Jf = e_zero_matrix(6 * m_nsets, 6 * m_nsets);
+ m_Jf_inv = m_Jf;
+ m_Cf = e_zero_matrix(m_ncTotal, m_Jf.rows());
+ m_Cq = e_zero_matrix(m_ncTotal, m_nqTotal);
+
+ bool result = true;
+ // finalize all objects
+ for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
+ Object_struct *os = it->second;
+
+ os->object->initCache(m_cache);
+ if (os->constraintrange.count > 0)
+ project(m_Cq,
+ os->constraintrange,
+ os->jointrange) = (((ControlledObject *)(os->object))->getCq());
+ }
+
+ m_ytask.resize(m_ncTotal);
+ bool toggle = true;
+ int cnt = 0;
+ // Initialize all ConstraintSets:
+ for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
+ // Calculate the external pose:
+ ConstraintSet_struct *cs = it->second;
+ Frame external_pose;
+ getConstraintPose(cs->task, cs, external_pose);
+ result &= cs->task->initialise(external_pose);
+ cs->task->initCache(m_cache);
+ for (int i = 0; i < cs->constraintrange.count; i++, cnt++) {
+ m_ytask[cnt] = toggle;
+ }
+ toggle = !toggle;
+ project(m_Cf, cs->constraintrange, cs->featurerange) = cs->task->getCf();
+ }
- return result;
+ if (m_solver != NULL)
+ m_solver->init(m_nqTotal, m_ncTotal, m_ytask);
+ else
+ return false;
+
+ return result;
}
-bool Scene::getConstraintPose(ConstraintSet* constraint, void *_param, KDL::Frame& _pose)
+bool Scene::getConstraintPose(ConstraintSet *constraint, void *_param, KDL::Frame &_pose)
{
- // function called from constraint when they need to get the external pose
- ConstraintSet_struct* cs = (ConstraintSet_struct*)_param;
- // verification, the pointer MUST match
- assert (constraint == cs->task);
- Object_struct* ob1 = cs->object1->second;
- Object_struct* ob2 = cs->object2->second;
- //Calculate the external pose:
- _pose=(ob1->base->getPose(ob1->baseFrameIndex)*ob1->object->getPose(cs->ee1index)).Inverse()*(ob2->base->getPose(ob2->baseFrameIndex)*ob2->object->getPose(cs->ee2index));
- return true;
+ // function called from constraint when they need to get the external pose
+ ConstraintSet_struct *cs = (ConstraintSet_struct *)_param;
+ // verification, the pointer MUST match
+ assert(constraint == cs->task);
+ Object_struct *ob1 = cs->object1->second;
+ Object_struct *ob2 = cs->object2->second;
+ // Calculate the external pose:
+ _pose =
+ (ob1->base->getPose(ob1->baseFrameIndex) * ob1->object->getPose(cs->ee1index)).Inverse() *
+ (ob2->base->getPose(ob2->baseFrameIndex) * ob2->object->getPose(cs->ee2index));
+ return true;
}
-bool Scene::update(double timestamp, double timestep, unsigned int numsubstep, bool reiterate, bool cache, bool interpolate)
+bool Scene::update(double timestamp,
+ double timestep,
+ unsigned int numsubstep,
+ bool reiterate,
+ bool cache,
+ bool interpolate)
{
- // we must have valid timestep and timestamp
- if (timestamp < KDL::epsilon || timestep < 0.0)
- return false;
- Timestamp ts;
- ts.realTimestamp = timestamp;
- // initially we start with the full timestep to allow velocity estimation over the full interval
- ts.realTimestep = timestep;
- setCacheTimestamp(ts);
- ts.substep = 0;
- // for reiteration don't load cache
- // reiteration=additional iteration with same timestamp if application finds the convergence not good enough
- ts.reiterate = (reiterate) ? 1 : 0;
- ts.interpolate = (interpolate) ? 1 : 0;
- ts.cache = (cache) ? 1 : 0;
- ts.update = 1;
- ts.numstep = (numsubstep & 0xFF);
- bool autosubstep = (numsubstep == 0) ? true : false;
- if (numsubstep < 1)
- numsubstep = 1;
- double timesubstep = timestep/numsubstep;
- double timeleft = timestep;
-
- if (timeleft == 0.0) {
- // this special case correspond to a request to cache data
- for(ObjectMap::iterator it=objects.begin();it!=objects.end();++it){
- it->second->object->pushCache(ts);
- }
- //Update the Constraints
- for(ConstraintMap::iterator it=constraints.begin();it!=constraints.end();++it){
- it->second->task->pushCache(ts);
- }
- return true;
- }
-
- // double maxqdot; // UNUSED
- e_scalar nlcoef;
- SceneLock lockCallback(this);
- Frame external_pose;
- bool locked;
-
- // initially we keep timestep unchanged so that update function compute the velocity over
- while (numsubstep > 0) {
- // get objects
- for(ObjectMap::iterator it=objects.begin();it!=objects.end();++it) {
- Object_struct* os = it->second;
- if (os->object->getType()==Object::Controlled) {
- ((ControlledObject*)(os->object))->updateControlOutput(ts);
- if (os->constraintrange.count > 0) {
- project(m_ydot, os->constraintrange) = ((ControlledObject*)(os->object))->getControlOutput();
- project(m_Wy, os->constraintrange) = ((ControlledObject*)(os->object))->getWy();
- // project(m_Cq,os->constraintrange,os->jointrange) = (((ControlledObject*)(os->object))->getCq());
- }
- if (os->jointrange.count > 0) {
- project(m_Wq,os->jointrange,os->jointrange) = ((ControlledObject*)(os->object))->getWq();
- }
- }
- if (os->object->getType()==Object::UnControlled && ((UncontrolledObject*)os->object)->getNrOfCoordinates() != 0) {
- ((UncontrolledObject*)(os->object))->updateCoordinates(ts);
- if (!ts.substep) {
- // velocity of uncontrolled object remains constant during substepping
- project(m_xdot,os->coordinaterange) = ((UncontrolledObject*)(os->object))->getXudot();
- }
- }
- }
-
- //get new Constraints values
- for(ConstraintMap::iterator it=constraints.begin();it!=constraints.end();++it) {
- ConstraintSet_struct* cs = it->second;
- Object_struct* ob1 = cs->object1->second;
- Object_struct* ob2 = cs->object2->second;
-
- if (ob1->base->updated() || ob1->object->updated() || ob2->base->updated() || ob2->object->updated()) {
- // the object from which the constraint depends have changed position
- // recompute the constraint pose
- getConstraintPose(cs->task, cs, external_pose);
- cs->task->initialise(external_pose);
- }
- cs->task->updateControlOutput(ts);
- project(m_ydot,cs->constraintrange)=cs->task->getControlOutput();
- if (!ts.substep || cs->task->substep()) {
- project(m_Wy,cs->constraintrange)=(cs->task)->getWy();
- //project(m_Cf,cs->constraintrange,cs->featurerange)=cs->task->getCf();
- }
-
- project(m_Jf,cs->featurerange,cs->featurerange)=cs->task->getJf();
- //std::cout << "Jf = " << Jf << std::endl;
- //Transform the reference frame of this jacobian to the world reference frame
- Eigen::Block<e_matrix> Jf_part = project(m_Jf,cs->featurerange,cs->featurerange);
- changeBase(Jf_part,ob1->base->getPose(ob1->baseFrameIndex)*ob1->object->getPose(cs->ee1index));
- //std::cout << "Jf_w = " << Jf << std::endl;
-
- //calculate the inverse of Jf
- KDL::svd_eigen_HH(project(m_Jf,cs->featurerange,cs->featurerange),m_Uf,m_Sf,m_Vf,m_tempf);
- for(unsigned int i=0;i<6;++i)
- if(m_Sf(i)<KDL::epsilon)
- m_Uf.col(i).setConstant(0.0);
- else
- m_Uf.col(i)*=(1/m_Sf(i));
- project(m_Jf_inv,cs->featurerange,cs->featurerange).noalias()=m_Vf*m_Uf.transpose();
-
- //Get the robotjacobian associated with this constraintset
- //Each jacobian is expressed in robot base frame => convert to world reference
- //and negate second robot because it is taken reversed when closing the loop:
- if(ob1->object->getType()==Object::Controlled){
- project(m_Jq,cs->featurerange,ob1->jointrange) = (((ControlledObject*)(ob1->object))->getJq(cs->ee1index));
- //Transform the reference frame of this jacobian to the world reference frame:
- Eigen::Block<e_matrix> Jq_part = project(m_Jq,cs->featurerange,ob1->jointrange);
- changeBase(Jq_part,ob1->base->getPose(ob1->baseFrameIndex));
- // if the base of this object is moving, get the Ju part
- if (ob1->base->getNrOfCoordinates() != 0) {
- // Ju is already computed for world reference frame
- project(m_Ju,cs->featurerange,ob1->coordinaterange)=ob1->base->getJu(ob1->baseFrameIndex);
- }
- } else if (ob1->object->getType() == Object::UnControlled && ((UncontrolledObject*)ob1->object)->getNrOfCoordinates() != 0) {
- // object1 is uncontrolled moving object
- project(m_Ju,cs->featurerange,ob1->coordinaterange)=((UncontrolledObject*)ob1->object)->getJu(cs->ee1index);
- }
- if(ob2->object->getType()==Object::Controlled){
- //Get the robotjacobian associated with this constraintset
- // process a special case where object2 and object1 are equal but using different end effector
- if (ob1->object == ob2->object) {
- // we must create a temporary matrix
- e_matrix JqTemp(((ControlledObject*)(ob2->object))->getJq(cs->ee2index));
- //Transform the reference frame of this jacobian to the world reference frame:
- changeBase(JqTemp,ob2->base->getPose(ob2->baseFrameIndex));
- // substract in place
- project(m_Jq,cs->featurerange,ob2->jointrange) -= JqTemp;
- } else {
- project(m_Jq,cs->featurerange,ob2->jointrange) = -(((ControlledObject*)(ob2->object))->getJq(cs->ee2index));
- //Transform the reference frame of this jacobian to the world reference frame:
- Eigen::Block<e_matrix> Jq_part = project(m_Jq,cs->featurerange,ob2->jointrange);
- changeBase(Jq_part,ob2->base->getPose(ob2->baseFrameIndex));
- }
- if (ob2->base->getNrOfCoordinates() != 0) {
- // if base is the same as first object or first object base,
- // that portion of m_Ju has been set already => substract inplace
- if (ob2->base == ob1->base || ob2->base == ob1->object) {
- project(m_Ju,cs->featurerange,ob2->coordinaterange) -= ob2->base->getJu(ob2->baseFrameIndex);
- } else {
- project(m_Ju,cs->featurerange,ob2->coordinaterange) = -ob2->base->getJu(ob2->baseFrameIndex);
- }
- }
- } else if (ob2->object->getType() == Object::UnControlled && ((UncontrolledObject*)ob2->object)->getNrOfCoordinates() != 0) {
- if (ob2->object == ob1->base || ob2->object == ob1->object) {
- project(m_Ju,cs->featurerange,ob2->coordinaterange) -= ((UncontrolledObject*)ob2->object)->getJu(cs->ee2index);
- } else {
- project(m_Ju,cs->featurerange,ob2->coordinaterange) = -((UncontrolledObject*)ob2->object)->getJu(cs->ee2index);
- }
- }
- }
-
- //Calculate A
- m_Atemp.noalias()=m_Cf*m_Jf_inv;
- m_A.noalias() = m_Cq-(m_Atemp*m_Jq);
- if (m_nuTotal > 0) {
- m_B.noalias()=m_Atemp*m_Ju;
- m_ydot.noalias() += m_B*m_xdot;
- }
-
- //Call the solver with A, Wq, Wy, ydot to solver qdot:
- if(!m_solver->solve(m_A,m_Wy,m_ydot,m_Wq,m_qdot,nlcoef))
- // this should never happen
- return false;
- //send result to the objects
- for(ObjectMap::iterator it=objects.begin();it!=objects.end();++it) {
- Object_struct* os = it->second;
- if(os->object->getType()==Object::Controlled)
- ((ControlledObject*)(os->object))->setJointVelocity(project(m_qdot,os->jointrange));
- }
- // compute the constraint velocity
- for(ConstraintMap::iterator it=constraints.begin();it!=constraints.end();++it){
- ConstraintSet_struct* cs = it->second;
- Object_struct* ob1 = cs->object1->second;
- Object_struct* ob2 = cs->object2->second;
- //Calculate the twist of the world reference frame due to the robots (Jq*qdot+Ju*chiudot):
- e_vector6 external_vel = e_zero_vector(6);
- if (ob1->jointrange.count > 0)
- external_vel.noalias() += (project(m_Jq,cs->featurerange,ob1->jointrange)*project(m_qdot,ob1->jointrange));
- if (ob2->jointrange.count > 0)
- external_vel.noalias() += (project(m_Jq,cs->featurerange,ob2->jointrange)*project(m_qdot,ob2->jointrange));
- if (ob1->coordinaterange.count > 0)
- external_vel.noalias() += (project(m_Ju,cs->featurerange,ob1->coordinaterange)*project(m_xdot,ob1->coordinaterange));
- if (ob2->coordinaterange.count > 0)
- external_vel.noalias() += (project(m_Ju,cs->featurerange,ob2->coordinaterange)*project(m_xdot,ob2->coordinaterange));
- //the twist caused by the constraint must be opposite because of the closed loop
- //estimate the velocity of the joints using the inverse jacobian
- e_vector6 estimated_chidot = project(m_Jf_inv,cs->featurerange,cs->featurerange)*(-external_vel);
- cs->task->setJointVelocity(estimated_chidot);
- }
-
- if (autosubstep) {
- // automatic computing of substep based on maximum joint change
- // and joint limit gain variation
- // We will pass the joint velocity to each object and they will recommend a maximum timestep
- timesubstep = timeleft;
- // get armature max joint velocity to estimate the maximum duration of integration
- // maxqdot = m_qdot.cwise().abs().maxCoeff(); // UNUSED
- double maxsubstep = nlcoef*m_maxstep;
- if (maxsubstep < m_minstep)
- maxsubstep = m_minstep;
- if (timesubstep > maxsubstep)
- timesubstep = maxsubstep;
- for(ObjectMap::iterator it=objects.begin();it!=objects.end();++it){
- Object_struct* os = it->second;
- if(os->object->getType()==Object::Controlled)
- ((ControlledObject*)(os->object))->getMaxTimestep(timesubstep);
- }
- for(ConstraintMap::iterator it=constraints.begin();it!=constraints.end();++it){
- ConstraintSet_struct* cs = it->second;
- cs->task->getMaxTimestep(timesubstep);
- }
- // use substep that are even dividers of timestep for more regularity
- maxsubstep = 2.0*floor(timestep/2.0/timesubstep-0.66666);
- timesubstep = (maxsubstep < 0.0) ? timestep : timestep/(2.0+maxsubstep);
- if (timesubstep >= timeleft-(m_minstep/2.0)) {
- timesubstep = timeleft;
- numsubstep = 1;
- timeleft = 0.;
- } else {
- numsubstep = 2;
- timeleft -= timesubstep;
- }
- }
- if (numsubstep > 1) {
- ts.substep = 1;
- } else {
- // set substep to false for last iteration so that controlled output
- // can be updated in updateKinematics() and model_update)() before next call to Secne::update()
- ts.substep = 0;
- }
- // change timestep so that integration is done correctly
- ts.realTimestep = timesubstep;
-
- do {
- ObjectMap::iterator it;
- Object_struct* os;
- locked = false;
- for(it=objects.begin();it!=objects.end();++it){
- os = it->second;
- if (os->object->getType()==Object::Controlled) {
- lockCallback.setRange(os->jointrange);
- if (((ControlledObject*)os->object)->updateJoint(ts, lockCallback)) {
- // this means one of the joint was locked and we must rerun
- // the solver to update the remaining joints
- locked = true;
- break;
- }
- }
- }
- if (locked) {
- // Some rows of m_Wq have been cleared so that the corresponding joint will not move
- if(!m_solver->solve(m_A,m_Wy,m_ydot,m_Wq,m_qdot,nlcoef))
- // this should never happen
- return false;
-
- //send result to the objects
- for(it=objects.begin();it!=objects.end();++it) {
- os = it->second;
- if(os->object->getType()==Object::Controlled)
- ((ControlledObject*)(os->object))->setJointVelocity(project(m_qdot,os->jointrange));
- }
- }
- } while (locked);
-
- //Update the Objects
- for(ObjectMap::iterator it=objects.begin();it!=objects.end();++it){
- it->second->object->updateKinematics(ts);
- // mark this object not updated since the constraint will be updated anyway
- // this flag is only useful to detect external updates
- it->second->object->updated(false);
- }
- //Update the Constraints
- for(ConstraintMap::iterator it=constraints.begin();it!=constraints.end();++it){
- ConstraintSet_struct* cs = it->second;
- //Calculate the external pose:
- getConstraintPose(cs->task, cs, external_pose);
- cs->task->modelUpdate(external_pose,ts);
- // update the constraint output and cache
- cs->task->updateKinematics(ts);
- }
- numsubstep--;
- }
- return true;
-}
+ // we must have valid timestep and timestamp
+ if (timestamp < KDL::epsilon || timestep < 0.0)
+ return false;
+ Timestamp ts;
+ ts.realTimestamp = timestamp;
+ // initially we start with the full timestep to allow velocity estimation over the full interval
+ ts.realTimestep = timestep;
+ setCacheTimestamp(ts);
+ ts.substep = 0;
+ // for reiteration don't load cache
+ // reiteration=additional iteration with same timestamp if application finds the convergence not
+ // good enough
+ ts.reiterate = (reiterate) ? 1 : 0;
+ ts.interpolate = (interpolate) ? 1 : 0;
+ ts.cache = (cache) ? 1 : 0;
+ ts.update = 1;
+ ts.numstep = (numsubstep & 0xFF);
+ bool autosubstep = (numsubstep == 0) ? true : false;
+ if (numsubstep < 1)
+ numsubstep = 1;
+ double timesubstep = timestep / numsubstep;
+ double timeleft = timestep;
+
+ if (timeleft == 0.0) {
+ // this special case correspond to a request to cache data
+ for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
+ it->second->object->pushCache(ts);
+ }
+ // Update the Constraints
+ for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
+ it->second->task->pushCache(ts);
+ }
+ return true;
+ }
+
+ // double maxqdot; // UNUSED
+ e_scalar nlcoef;
+ SceneLock lockCallback(this);
+ Frame external_pose;
+ bool locked;
+
+ // initially we keep timestep unchanged so that update function compute the velocity over
+ while (numsubstep > 0) {
+ // get objects
+ for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
+ Object_struct *os = it->second;
+ if (os->object->getType() == Object::Controlled) {
+ ((ControlledObject *)(os->object))->updateControlOutput(ts);
+ if (os->constraintrange.count > 0) {
+ project(m_ydot,
+ os->constraintrange) = ((ControlledObject *)(os->object))->getControlOutput();
+ project(m_Wy, os->constraintrange) = ((ControlledObject *)(os->object))->getWy();
+ // project(m_Cq,os->constraintrange,os->jointrange) =
+ // (((ControlledObject*)(os->object))->getCq());
+ }
+ if (os->jointrange.count > 0) {
+ project(
+ m_Wq, os->jointrange, os->jointrange) = ((ControlledObject *)(os->object))->getWq();
+ }
+ }
+ if (os->object->getType() == Object::UnControlled &&
+ ((UncontrolledObject *)os->object)->getNrOfCoordinates() != 0) {
+ ((UncontrolledObject *)(os->object))->updateCoordinates(ts);
+ if (!ts.substep) {
+ // velocity of uncontrolled object remains constant during substepping
+ project(m_xdot, os->coordinaterange) = ((UncontrolledObject *)(os->object))->getXudot();
+ }
+ }
+ }
+
+ // get new Constraints values
+ for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
+ ConstraintSet_struct *cs = it->second;
+ Object_struct *ob1 = cs->object1->second;
+ Object_struct *ob2 = cs->object2->second;
+
+ if (ob1->base->updated() || ob1->object->updated() || ob2->base->updated() ||
+ ob2->object->updated()) {
+ // the object from which the constraint depends have changed position
+ // recompute the constraint pose
+ getConstraintPose(cs->task, cs, external_pose);
+ cs->task->initialise(external_pose);
+ }
+ cs->task->updateControlOutput(ts);
+ project(m_ydot, cs->constraintrange) = cs->task->getControlOutput();
+ if (!ts.substep || cs->task->substep()) {
+ project(m_Wy, cs->constraintrange) = (cs->task)->getWy();
+ // project(m_Cf,cs->constraintrange,cs->featurerange)=cs->task->getCf();
+ }
+
+ project(m_Jf, cs->featurerange, cs->featurerange) = cs->task->getJf();
+ // std::cout << "Jf = " << Jf << std::endl;
+ // Transform the reference frame of this jacobian to the world reference frame
+ Eigen::Block<e_matrix> Jf_part = project(m_Jf, cs->featurerange, cs->featurerange);
+ changeBase(Jf_part,
+ ob1->base->getPose(ob1->baseFrameIndex) * ob1->object->getPose(cs->ee1index));
+ // std::cout << "Jf_w = " << Jf << std::endl;
+
+ // calculate the inverse of Jf
+ KDL::svd_eigen_HH(
+ project(m_Jf, cs->featurerange, cs->featurerange), m_Uf, m_Sf, m_Vf, m_tempf);
+ for (unsigned int i = 0; i < 6; ++i)
+ if (m_Sf(i) < KDL::epsilon)
+ m_Uf.col(i).setConstant(0.0);
+ else
+ m_Uf.col(i) *= (1 / m_Sf(i));
+ project(m_Jf_inv, cs->featurerange, cs->featurerange).noalias() = m_Vf * m_Uf.transpose();
+
+ // Get the robotjacobian associated with this constraintset
+ // Each jacobian is expressed in robot base frame => convert to world reference
+ // and negate second robot because it is taken reversed when closing the loop:
+ if (ob1->object->getType() == Object::Controlled) {
+ project(m_Jq,
+ cs->featurerange,
+ ob1->jointrange) = (((ControlledObject *)(ob1->object))->getJq(cs->ee1index));
+ // Transform the reference frame of this jacobian to the world reference frame:
+ Eigen::Block<e_matrix> Jq_part = project(m_Jq, cs->featurerange, ob1->jointrange);
+ changeBase(Jq_part, ob1->base->getPose(ob1->baseFrameIndex));
+ // if the base of this object is moving, get the Ju part
+ if (ob1->base->getNrOfCoordinates() != 0) {
+ // Ju is already computed for world reference frame
+ project(m_Ju, cs->featurerange, ob1->coordinaterange) = ob1->base->getJu(
+ ob1->baseFrameIndex);
+ }
+ }
+ else if (ob1->object->getType() == Object::UnControlled &&
+ ((UncontrolledObject *)ob1->object)->getNrOfCoordinates() != 0) {
+ // object1 is uncontrolled moving object
+ project(m_Ju,
+ cs->featurerange,
+ ob1->coordinaterange) = ((UncontrolledObject *)ob1->object)->getJu(cs->ee1index);
+ }
+ if (ob2->object->getType() == Object::Controlled) {
+ // Get the robotjacobian associated with this constraintset
+ // process a special case where object2 and object1 are equal but using different end
+ // effector
+ if (ob1->object == ob2->object) {
+ // we must create a temporary matrix
+ e_matrix JqTemp(((ControlledObject *)(ob2->object))->getJq(cs->ee2index));
+ // Transform the reference frame of this jacobian to the world reference frame:
+ changeBase(JqTemp, ob2->base->getPose(ob2->baseFrameIndex));
+ // subtract in place
+ project(m_Jq, cs->featurerange, ob2->jointrange) -= JqTemp;
+ }
+ else {
+ project(m_Jq, cs->featurerange, ob2->jointrange) = -(
+ ((ControlledObject *)(ob2->object))->getJq(cs->ee2index));
+ // Transform the reference frame of this jacobian to the world reference frame:
+ Eigen::Block<e_matrix> Jq_part = project(m_Jq, cs->featurerange, ob2->jointrange);
+ changeBase(Jq_part, ob2->base->getPose(ob2->baseFrameIndex));
+ }
+ if (ob2->base->getNrOfCoordinates() != 0) {
+ // if base is the same as first object or first object base,
+ // that portion of m_Ju has been set already => subtract inplace
+ if (ob2->base == ob1->base || ob2->base == ob1->object) {
+ project(m_Ju, cs->featurerange, ob2->coordinaterange) -= ob2->base->getJu(
+ ob2->baseFrameIndex);
+ }
+ else {
+ project(m_Ju, cs->featurerange, ob2->coordinaterange) = -ob2->base->getJu(
+ ob2->baseFrameIndex);
+ }
+ }
+ }
+ else if (ob2->object->getType() == Object::UnControlled &&
+ ((UncontrolledObject *)ob2->object)->getNrOfCoordinates() != 0) {
+ if (ob2->object == ob1->base || ob2->object == ob1->object) {
+ project(m_Ju, cs->featurerange, ob2->coordinaterange) -=
+ ((UncontrolledObject *)ob2->object)->getJu(cs->ee2index);
+ }
+ else {
+ project(m_Ju, cs->featurerange, ob2->coordinaterange) =
+ -((UncontrolledObject *)ob2->object)->getJu(cs->ee2index);
+ }
+ }
+ }
+
+ // Calculate A
+ m_Atemp.noalias() = m_Cf * m_Jf_inv;
+ m_A.noalias() = m_Cq - (m_Atemp * m_Jq);
+ if (m_nuTotal > 0) {
+ m_B.noalias() = m_Atemp * m_Ju;
+ m_ydot.noalias() += m_B * m_xdot;
+ }
+ // Call the solver with A, Wq, Wy, ydot to solver qdot:
+ if (!m_solver->solve(m_A, m_Wy, m_ydot, m_Wq, m_qdot, nlcoef))
+ // this should never happen
+ return false;
+ // send result to the objects
+ for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
+ Object_struct *os = it->second;
+ if (os->object->getType() == Object::Controlled)
+ ((ControlledObject *)(os->object))->setJointVelocity(project(m_qdot, os->jointrange));
+ }
+ // compute the constraint velocity
+ for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
+ ConstraintSet_struct *cs = it->second;
+ Object_struct *ob1 = cs->object1->second;
+ Object_struct *ob2 = cs->object2->second;
+ // Calculate the twist of the world reference frame due to the robots (Jq*qdot+Ju*chiudot):
+ e_vector6 external_vel = e_zero_vector(6);
+ if (ob1->jointrange.count > 0)
+ external_vel.noalias() += (project(m_Jq, cs->featurerange, ob1->jointrange) *
+ project(m_qdot, ob1->jointrange));
+ if (ob2->jointrange.count > 0)
+ external_vel.noalias() += (project(m_Jq, cs->featurerange, ob2->jointrange) *
+ project(m_qdot, ob2->jointrange));
+ if (ob1->coordinaterange.count > 0)
+ external_vel.noalias() += (project(m_Ju, cs->featurerange, ob1->coordinaterange) *
+ project(m_xdot, ob1->coordinaterange));
+ if (ob2->coordinaterange.count > 0)
+ external_vel.noalias() += (project(m_Ju, cs->featurerange, ob2->coordinaterange) *
+ project(m_xdot, ob2->coordinaterange));
+ // the twist caused by the constraint must be opposite because of the closed loop
+ // estimate the velocity of the joints using the inverse jacobian
+ e_vector6 estimated_chidot = project(m_Jf_inv, cs->featurerange, cs->featurerange) *
+ (-external_vel);
+ cs->task->setJointVelocity(estimated_chidot);
+ }
+
+ if (autosubstep) {
+ // automatic computing of substep based on maximum joint change
+ // and joint limit gain variation
+ // We will pass the joint velocity to each object and they will recommend a maximum timestep
+ timesubstep = timeleft;
+ // get armature max joint velocity to estimate the maximum duration of integration
+ // maxqdot = m_qdot.cwise().abs().maxCoeff(); // UNUSED
+ double maxsubstep = nlcoef * m_maxstep;
+ if (maxsubstep < m_minstep)
+ maxsubstep = m_minstep;
+ if (timesubstep > maxsubstep)
+ timesubstep = maxsubstep;
+ for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
+ Object_struct *os = it->second;
+ if (os->object->getType() == Object::Controlled)
+ ((ControlledObject *)(os->object))->getMaxTimestep(timesubstep);
+ }
+ for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
+ ConstraintSet_struct *cs = it->second;
+ cs->task->getMaxTimestep(timesubstep);
+ }
+ // use substep that are even dividers of timestep for more regularity
+ maxsubstep = 2.0 * floor(timestep / 2.0 / timesubstep - 0.66666);
+ timesubstep = (maxsubstep < 0.0) ? timestep : timestep / (2.0 + maxsubstep);
+ if (timesubstep >= timeleft - (m_minstep / 2.0)) {
+ timesubstep = timeleft;
+ numsubstep = 1;
+ timeleft = 0.;
+ }
+ else {
+ numsubstep = 2;
+ timeleft -= timesubstep;
+ }
+ }
+ if (numsubstep > 1) {
+ ts.substep = 1;
+ }
+ else {
+ // set substep to false for last iteration so that controlled output
+ // can be updated in updateKinematics() and model_update)() before next call to
+ // Secne::update()
+ ts.substep = 0;
+ }
+ // change timestep so that integration is done correctly
+ ts.realTimestep = timesubstep;
+
+ do {
+ ObjectMap::iterator it;
+ Object_struct *os;
+ locked = false;
+ for (it = objects.begin(); it != objects.end(); ++it) {
+ os = it->second;
+ if (os->object->getType() == Object::Controlled) {
+ lockCallback.setRange(os->jointrange);
+ if (((ControlledObject *)os->object)->updateJoint(ts, lockCallback)) {
+ // this means one of the joint was locked and we must rerun
+ // the solver to update the remaining joints
+ locked = true;
+ break;
+ }
+ }
+ }
+ if (locked) {
+ // Some rows of m_Wq have been cleared so that the corresponding joint will not move
+ if (!m_solver->solve(m_A, m_Wy, m_ydot, m_Wq, m_qdot, nlcoef))
+ // this should never happen
+ return false;
+
+ // send result to the objects
+ for (it = objects.begin(); it != objects.end(); ++it) {
+ os = it->second;
+ if (os->object->getType() == Object::Controlled)
+ ((ControlledObject *)(os->object))->setJointVelocity(project(m_qdot, os->jointrange));
+ }
+ }
+ } while (locked);
+
+ // Update the Objects
+ for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
+ it->second->object->updateKinematics(ts);
+ // mark this object not updated since the constraint will be updated anyway
+ // this flag is only useful to detect external updates
+ it->second->object->updated(false);
+ }
+ // Update the Constraints
+ for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
+ ConstraintSet_struct *cs = it->second;
+ // Calculate the external pose:
+ getConstraintPose(cs->task, cs, external_pose);
+ cs->task->modelUpdate(external_pose, ts);
+ // update the constraint output and cache
+ cs->task->updateKinematics(ts);
+ }
+ numsubstep--;
+ }
+ return true;
}
+
+} // namespace iTaSC
diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index 3da1d8f53f0..124671467f7 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -33,10 +33,10 @@ struct MANTA;
/* Fluid functions */
struct MANTA *manta_init(int *res, struct FluidModifierData *fmd);
void manta_free(struct MANTA *fluid);
-void manta_ensure_obstacle(struct MANTA *fluid, struct FluidModifierData *fmd);
-void manta_ensure_guiding(struct MANTA *fluid, struct FluidModifierData *fmd);
-void manta_ensure_invelocity(struct MANTA *fluid, struct FluidModifierData *fmd);
-void manta_ensure_outflow(struct MANTA *fluid, struct FluidModifierData *fmd);
+int manta_ensure_obstacle(struct MANTA *fluid, struct FluidModifierData *fmd);
+int manta_ensure_guiding(struct MANTA *fluid, struct FluidModifierData *fmd);
+int manta_ensure_invelocity(struct MANTA *fluid, struct FluidModifierData *fmd);
+int manta_ensure_outflow(struct MANTA *fluid, struct FluidModifierData *fmd);
int manta_write_config(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_write_data(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
int manta_write_noise(struct MANTA *fluid, struct FluidModifierData *fmd, int framenr);
@@ -77,6 +77,7 @@ int manta_get_frame(struct MANTA *fluid);
float manta_get_timestep(struct MANTA *fluid);
void manta_adapt_timestep(struct MANTA *fluid);
bool manta_needs_realloc(struct MANTA *fluid, struct FluidModifierData *fmd);
+void manta_update_pointers(struct MANTA *fluid, struct FluidModifierData *fmd, bool flush);
/* Fluid accessors */
size_t manta_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */);
@@ -121,9 +122,9 @@ void manta_noise_get_rgba_fixed_color(struct MANTA *smoke,
float color[3],
float *data,
int sequential);
-void manta_smoke_ensure_heat(struct MANTA *smoke, struct FluidModifierData *fmd);
-void manta_smoke_ensure_fire(struct MANTA *smoke, struct FluidModifierData *fmd);
-void manta_smoke_ensure_colors(struct MANTA *smoke, struct FluidModifierData *fmd);
+int manta_smoke_ensure_heat(struct MANTA *smoke, struct FluidModifierData *fmd);
+int manta_smoke_ensure_fire(struct MANTA *smoke, struct FluidModifierData *fmd);
+int manta_smoke_ensure_colors(struct MANTA *smoke, struct FluidModifierData *fmd);
/* Smoke accessors */
float *manta_smoke_get_density(struct MANTA *smoke);
@@ -167,7 +168,7 @@ int manta_noise_get_cells(struct MANTA *smoke);
/* Liquid functions */
void manta_liquid_export_script(struct MANTA *smoke, struct FluidModifierData *fmd);
-void manta_liquid_ensure_sndparts(struct MANTA *fluid, struct FluidModifierData *fmd);
+int manta_liquid_ensure_sndparts(struct MANTA *fluid, struct FluidModifierData *fmd);
/* Liquid accessors */
int manta_liquid_get_particle_res_x(struct MANTA *liquid);
diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp
index 5b2cbb09979..5997e819ccf 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -27,10 +27,6 @@
#include <sstream>
#include <zlib.h>
-#if OPENVDB == 1
-# include "openvdb/openvdb.h"
-#endif
-
#include "MANTA_main.h"
#include "Python.h"
#include "fluid_script.h"
@@ -60,13 +56,6 @@ using std::to_string;
atomic<int> MANTA::solverID(0);
int MANTA::with_debug(0);
-/* Number of particles that the cache reads at once (with zlib). */
-#define PARTICLE_CHUNK 20000
-/* Number of mesh nodes that the cache reads at once (with zlib). */
-#define NODE_CHUNK 20000
-/* Number of mesh triangles that the cache reads at once (with zlib). */
-#define TRIANGLE_CHUNK 20000
-
MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
{
if (with_debug)
@@ -96,8 +85,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
mUsingInvel = (fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
mUsingOutflow = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
- // Simulation constants
- mTempAmb = 0; // TODO: Maybe use this later for buoyancy calculation
+ /* Simulation constants. */
mResX = res[0];
mResY = res[1];
mResZ = res[2];
@@ -105,7 +93,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
mTotalCells = mResX * mResY * mResZ;
mResGuiding = fds->res;
- // Smoke low res grids
+ /* Smoke low res grids. */
mDensity = nullptr;
mShadow = nullptr;
mHeat = nullptr;
@@ -131,7 +119,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
mReactIn = nullptr;
mEmissionIn = nullptr;
- // Smoke high res grids
+ /* Smoke high res grids. */
mDensityHigh = nullptr;
mFlameHigh = nullptr;
mFuelHigh = nullptr;
@@ -146,19 +134,19 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
mTextureV2 = nullptr;
mTextureW2 = nullptr;
- // Fluid low res grids
+ /* Fluid low res grids. */
mPhiIn = nullptr;
mPhiStaticIn = nullptr;
mPhiOutIn = nullptr;
mPhiOutStaticIn = nullptr;
mPhi = nullptr;
- // Mesh
+ /* Mesh. */
mMeshNodes = nullptr;
mMeshTriangles = nullptr;
mMeshVelocities = nullptr;
- // Fluid obstacle
+ /* Fluid obstacle. */
mPhiObsIn = nullptr;
mPhiObsStaticIn = nullptr;
mNumObstacle = nullptr;
@@ -166,47 +154,48 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
mObVelocityY = nullptr;
mObVelocityZ = nullptr;
- // Fluid guiding
+ /* Fluid guiding. */
mPhiGuideIn = nullptr;
mNumGuide = nullptr;
mGuideVelocityX = nullptr;
mGuideVelocityY = nullptr;
mGuideVelocityZ = nullptr;
- // Fluid initial velocity
+ /* Fluid initial velocity. */
mInVelocityX = nullptr;
mInVelocityY = nullptr;
mInVelocityZ = nullptr;
- // Secondary particles
+ /* Secondary particles. */
mFlipParticleData = nullptr;
mFlipParticleVelocity = nullptr;
- mSndParticleData = nullptr;
- mSndParticleVelocity = nullptr;
- mSndParticleLife = nullptr;
+ mParticleData = nullptr;
+ mParticleVelocity = nullptr;
+ mParticleLife = nullptr;
- // Cache read success indicators
+ /* Cache read success indicators. */
mFlipFromFile = false;
mMeshFromFile = false;
mParticlesFromFile = false;
- // Setup Mantaflow in Python
+ /* Setup Mantaflow in Python. */
initializeMantaflow();
- // Initializa RNA map with values that Python will need
+ /* Initializa RNA map with values that Python will need. */
initializeRNAMap(fmd);
- // Initialize Mantaflow variables in Python
- // Liquid
+ bool initSuccess = true;
+ /* Initialize Mantaflow variables in Python. */
+ /* Liquid. */
if (mUsingLiquid) {
- initDomain();
- initLiquid();
+ initSuccess &= initDomain();
+ initSuccess &= initLiquid();
if (mUsingObstacle)
- initObstacle();
+ initSuccess &= initObstacle();
if (mUsingInvel)
- initInVelocity();
+ initSuccess &= initInVelocity();
if (mUsingOutflow)
- initOutflow();
+ initSuccess &= initOutflow();
if (mUsingDrops || mUsingBubbles || mUsingFloats || mUsingTracers) {
mUpresParticle = fds->particle_scale;
@@ -215,8 +204,8 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
mResZParticle = mUpresParticle * mResZ;
mTotalCellsParticles = mResXParticle * mResYParticle * mResZParticle;
- initSndParts();
- initLiquidSndParts();
+ initSuccess &= initSndParts();
+ initSuccess &= initLiquidSndParts();
}
if (mUsingMesh) {
@@ -226,44 +215,44 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
mResZMesh = mUpresMesh * mResZ;
mTotalCellsMesh = mResXMesh * mResYMesh * mResZMesh;
- // Initialize Mantaflow variables in Python
- initMesh();
- initLiquidMesh();
+ /* Initialize Mantaflow variables in Python. */
+ initSuccess &= initMesh();
+ initSuccess &= initLiquidMesh();
}
if (mUsingDiffusion) {
- initCurvature();
+ initSuccess &= initCurvature();
}
if (mUsingGuiding) {
mResGuiding = (fds->guide_parent) ? fds->guide_res : fds->res;
- initGuiding();
+ initSuccess &= initGuiding();
}
if (mUsingFractions) {
- initFractions();
+ initSuccess &= initFractions();
}
}
- // Smoke
+ /* Smoke. */
if (mUsingSmoke) {
- initDomain();
- initSmoke();
+ initSuccess &= initDomain();
+ initSuccess &= initSmoke();
if (mUsingHeat)
- initHeat();
+ initSuccess &= initHeat();
if (mUsingFire)
- initFire();
+ initSuccess &= initFire();
if (mUsingColors)
- initColors();
+ initSuccess &= initColors();
if (mUsingObstacle)
- initObstacle();
+ initSuccess &= initObstacle();
if (mUsingInvel)
- initInVelocity();
+ initSuccess &= initInVelocity();
if (mUsingOutflow)
- initOutflow();
+ initSuccess &= initOutflow();
if (mUsingGuiding) {
mResGuiding = (fds->guide_parent) ? fds->guide_res : fds->res;
- initGuiding();
+ initSuccess &= initGuiding();
}
if (mUsingNoise) {
@@ -273,31 +262,33 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
mResZNoise = amplify * mResZ;
mTotalCellsHigh = mResXNoise * mResYNoise * mResZNoise;
- // Initialize Mantaflow variables in Python
- initNoise();
- initSmokeNoise();
+ /* Initialize Mantaflow variables in Python. */
+ initSuccess &= initNoise();
+ initSuccess &= initSmokeNoise();
if (mUsingFire)
- initFireHigh();
+ initSuccess &= initFireHigh();
if (mUsingColors)
- initColorsHigh();
+ initSuccess &= initColorsHigh();
}
}
- updatePointers();
+ /* All requested initializations must not fail in constructor. */
+ BLI_assert(initSuccess);
+ updatePointers(fmd);
}
-void MANTA::initDomain(FluidModifierData *fmd)
+bool MANTA::initDomain(FluidModifierData *fmd)
{
- // Vector will hold all python commands that are to be executed
+ /* Vector will hold all python commands that are to be executed. */
vector<string> pythonCommands;
- // Set manta debug level first
+ /* Set manta debug level first. */
pythonCommands.push_back(manta_import + manta_debuglevel);
ostringstream ss;
ss << "set_manta_debuglevel(" << with_debug << ")";
pythonCommands.push_back(ss.str());
- // Now init basic fluid domain
+ /* Now init basic fluid domain. */
string tmpString = fluid_variables + fluid_solver + fluid_alloc + fluid_cache_helper +
fluid_bake_multiprocessing + fluid_bake_data + fluid_bake_noise +
fluid_bake_mesh + fluid_bake_particles + fluid_bake_guiding +
@@ -305,20 +296,20 @@ void MANTA::initDomain(FluidModifierData *fmd)
fluid_adapt_time_step + fluid_time_stepping;
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
+ return runPythonString(pythonCommands);
}
-void MANTA::initNoise(FluidModifierData *fmd)
+bool MANTA::initNoise(FluidModifierData *fmd)
{
vector<string> pythonCommands;
string tmpString = fluid_variables_noise + fluid_solver_noise;
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
+ return runPythonString(pythonCommands);
}
-void MANTA::initSmoke(FluidModifierData *fmd)
+bool MANTA::initSmoke(FluidModifierData *fmd)
{
vector<string> pythonCommands;
string tmpString = smoke_variables + smoke_alloc + smoke_adaptive_step + smoke_save_data +
@@ -326,10 +317,10 @@ void MANTA::initSmoke(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
+ return runPythonString(pythonCommands);
}
-void MANTA::initSmokeNoise(FluidModifierData *fmd)
+bool MANTA::initSmokeNoise(FluidModifierData *fmd)
{
vector<string> pythonCommands;
string tmpString = smoke_variables_noise + smoke_alloc_noise + smoke_wavelet_noise +
@@ -337,11 +328,11 @@ void MANTA::initSmokeNoise(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingNoise = true;
+ return runPythonString(pythonCommands);
}
-void MANTA::initHeat(FluidModifierData *fmd)
+bool MANTA::initHeat(FluidModifierData *fmd)
{
if (!mHeat) {
vector<string> pythonCommands;
@@ -349,12 +340,13 @@ void MANTA::initHeat(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingHeat = true;
+ return runPythonString(pythonCommands);
}
+ return false;
}
-void MANTA::initFire(FluidModifierData *fmd)
+bool MANTA::initFire(FluidModifierData *fmd)
{
if (!mFuel) {
vector<string> pythonCommands;
@@ -362,12 +354,13 @@ void MANTA::initFire(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingFire = true;
+ return runPythonString(pythonCommands);
}
+ return false;
}
-void MANTA::initFireHigh(FluidModifierData *fmd)
+bool MANTA::initFireHigh(FluidModifierData *fmd)
{
if (!mFuelHigh) {
vector<string> pythonCommands;
@@ -375,12 +368,13 @@ void MANTA::initFireHigh(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingFire = true;
+ return runPythonString(pythonCommands);
}
+ return false;
}
-void MANTA::initColors(FluidModifierData *fmd)
+bool MANTA::initColors(FluidModifierData *fmd)
{
if (!mColorR) {
vector<string> pythonCommands;
@@ -388,12 +382,13 @@ void MANTA::initColors(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingColors = true;
+ return runPythonString(pythonCommands);
}
+ return false;
}
-void MANTA::initColorsHigh(FluidModifierData *fmd)
+bool MANTA::initColorsHigh(FluidModifierData *fmd)
{
if (!mColorRHigh) {
vector<string> pythonCommands;
@@ -401,12 +396,13 @@ void MANTA::initColorsHigh(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingColors = true;
+ return runPythonString(pythonCommands);
}
+ return false;
}
-void MANTA::initLiquid(FluidModifierData *fmd)
+bool MANTA::initLiquid(FluidModifierData *fmd)
{
if (!mPhiIn) {
vector<string> pythonCommands;
@@ -415,44 +411,45 @@ void MANTA::initLiquid(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingLiquid = true;
+ return runPythonString(pythonCommands);
}
+ return false;
}
-void MANTA::initMesh(FluidModifierData *fmd)
+bool MANTA::initMesh(FluidModifierData *fmd)
{
vector<string> pythonCommands;
string tmpString = fluid_variables_mesh + fluid_solver_mesh + liquid_load_mesh;
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingMesh = true;
+ return runPythonString(pythonCommands);
}
-void MANTA::initLiquidMesh(FluidModifierData *fmd)
+bool MANTA::initLiquidMesh(FluidModifierData *fmd)
{
vector<string> pythonCommands;
string tmpString = liquid_alloc_mesh + liquid_step_mesh + liquid_save_mesh;
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingMesh = true;
+ return runPythonString(pythonCommands);
}
-void MANTA::initCurvature(FluidModifierData *fmd)
+bool MANTA::initCurvature(FluidModifierData *fmd)
{
std::vector<std::string> pythonCommands;
std::string finalString = parseScript(liquid_alloc_curvature, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingDiffusion = true;
+ return runPythonString(pythonCommands);
}
-void MANTA::initObstacle(FluidModifierData *fmd)
+bool MANTA::initObstacle(FluidModifierData *fmd)
{
if (!mPhiObsIn) {
vector<string> pythonCommands;
@@ -460,12 +457,13 @@ void MANTA::initObstacle(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingObstacle = true;
+ return runPythonString(pythonCommands);
}
+ return false;
}
-void MANTA::initGuiding(FluidModifierData *fmd)
+bool MANTA::initGuiding(FluidModifierData *fmd)
{
if (!mPhiGuideIn) {
vector<string> pythonCommands;
@@ -474,23 +472,24 @@ void MANTA::initGuiding(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingGuiding = true;
+ return runPythonString(pythonCommands);
}
+ return false;
}
-void MANTA::initFractions(FluidModifierData *fmd)
+bool MANTA::initFractions(FluidModifierData *fmd)
{
vector<string> pythonCommands;
string tmpString = fluid_alloc_fractions + fluid_with_fractions;
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingFractions = true;
+ return runPythonString(pythonCommands);
}
-void MANTA::initInVelocity(FluidModifierData *fmd)
+bool MANTA::initInVelocity(FluidModifierData *fmd)
{
if (!mInVelocityX) {
vector<string> pythonCommands;
@@ -498,12 +497,13 @@ void MANTA::initInVelocity(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingInvel = true;
+ return runPythonString(pythonCommands);
}
+ return false;
}
-void MANTA::initOutflow(FluidModifierData *fmd)
+bool MANTA::initOutflow(FluidModifierData *fmd)
{
if (!mPhiOutIn) {
vector<string> pythonCommands;
@@ -511,24 +511,25 @@ void MANTA::initOutflow(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
mUsingOutflow = true;
+ return runPythonString(pythonCommands);
}
+ return false;
}
-void MANTA::initSndParts(FluidModifierData *fmd)
+bool MANTA::initSndParts(FluidModifierData *fmd)
{
vector<string> pythonCommands;
string tmpString = fluid_variables_particles + fluid_solver_particles;
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
+ return runPythonString(pythonCommands);
}
-void MANTA::initLiquidSndParts(FluidModifierData *fmd)
+bool MANTA::initLiquidSndParts(FluidModifierData *fmd)
{
- if (!mSndParticleData) {
+ if (!mParticleData) {
vector<string> pythonCommands;
string tmpString = liquid_alloc_particles + liquid_variables_particles +
liquid_step_particles + fluid_with_sndparts + liquid_load_particles +
@@ -536,8 +537,9 @@ void MANTA::initLiquidSndParts(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- runPythonString(pythonCommands);
+ return runPythonString(pythonCommands);
}
+ return false;
}
MANTA::~MANTA()
@@ -546,7 +548,7 @@ MANTA::~MANTA()
cout << "~FLUID: " << mCurrentID << " with res(" << mResX << ", " << mResY << ", " << mResZ
<< ")" << endl;
- // Destruction string for Python
+ /* Destruction string for Python. */
string tmpString = "";
vector<string> pythonCommands;
bool result = false;
@@ -554,10 +556,10 @@ MANTA::~MANTA()
tmpString += manta_import;
tmpString += fluid_delete_all;
- // Initializa RNA map with values that Python will need
+ /* Initializa RNA map with values that Python will need. */
initializeRNAMap();
- // Leave out fmd argument in parseScript since only looking up IDs
+ /* Leave out fmd argument in parseScript since only looking up IDs. */
string finalString = parseScript(tmpString);
pythonCommands.push_back(finalString);
result = runPythonString(pythonCommands);
@@ -619,10 +621,10 @@ void MANTA::initializeMantaflow()
string filename = "manta_scene_" + to_string(mCurrentID) + ".py";
vector<string> fill = vector<string>();
- // Initialize extension classes and wrappers
+ /* Initialize extension classes and wrappers. */
srand(0);
PyGILState_STATE gilstate = PyGILState_Ensure();
- Pb::setup(filename, fill); // Namespace from Mantaflow (registry)
+ Pb::setup(filename, fill); /* Namespace from Mantaflow (registry). */
PyGILState_Release(gilstate);
}
@@ -632,7 +634,7 @@ void MANTA::terminateMantaflow()
cout << "Fluid: Releasing Mantaflow framework" << endl;
PyGILState_STATE gilstate = PyGILState_Ensure();
- Pb::finalize(); // Namespace from Mantaflow (registry)
+ Pb::finalize(); /* Namespace from Mantaflow (registry). */
PyGILState_Release(gilstate);
}
@@ -1014,7 +1016,7 @@ void MANTA::initializeRNAMap(FluidModifierData *fmd)
mRNAMap["NAME_GUIDEVEL_X"] = FLUID_NAME_GUIDEVEL_X;
mRNAMap["NAME_GUIDEVEL_Y"] = FLUID_NAME_GUIDEVEL_Y;
mRNAMap["NAME_GUIDEVEL_Z"] = FLUID_NAME_GUIDEVEL_Z;
- mRNAMap["NAME_GUIDEVEL"] = FLUID_NAME_GUIDEVEL;
+ mRNAMap["NAME_VELOCITY_GUIDE"] = FLUID_NAME_VELOCITY_GUIDE;
/* Cache file names. */
mRNAMap["NAME_CONFIG"] = FLUID_NAME_CONFIG;
@@ -1073,7 +1075,7 @@ string MANTA::parseScript(const string &setup_string, FluidModifierData *fmd)
ostringstream res;
string line = "";
- // Update RNA map if modifier data is handed over
+ /* Update RNA map if modifier data is handed over. */
if (fmd) {
initializeRNAMap(fmd);
}
@@ -1111,7 +1113,8 @@ bool MANTA::writeConfiguration(FluidModifierData *fmd, int framenr)
/* Create 'config' subdir if it does not exist already. */
BLI_dir_create_recursive(directory.c_str());
- gzFile gzf = (gzFile)BLI_gzopen(file.c_str(), "wb1"); // do some compression
+ /* Open new file with some compression. */
+ gzFile gzf = (gzFile)BLI_gzopen(file.c_str(), "wb1");
if (!gzf) {
cerr << "Fluid Error -- Cannot open file " << file << endl;
return false;
@@ -1539,6 +1542,7 @@ bool MANTA::bakeGuiding(FluidModifierData *fmd, int framenr)
cacheDirGuiding[0] = '\0';
string volume_format = getCacheFileEnding(fds->cache_data_format);
+ string resumable_cache = !(fds->flags & FLUID_DOMAIN_USE_RESUMABLE_CACHE) ? "False" : "True";
BLI_path_join(cacheDirGuiding,
sizeof(cacheDirGuiding),
@@ -1549,7 +1553,7 @@ bool MANTA::bakeGuiding(FluidModifierData *fmd, int framenr)
ss.str("");
ss << "bake_guiding_" << mCurrentID << "('" << escapeSlashes(cacheDirGuiding) << "', " << framenr
- << ", '" << volume_format << "')";
+ << ", '" << volume_format << "', " << resumable_cache << ")";
pythonCommands.push_back(ss.str());
return runPythonString(pythonCommands);
@@ -1615,10 +1619,10 @@ void MANTA::exportSmokeScript(FluidModifierData *fmd)
string manta_script;
- // Libraries
+ /* Libraries. */
manta_script += header_libraries + manta_import;
- // Variables
+ /* Variables. */
manta_script += header_variables + fluid_variables + smoke_variables;
if (noise) {
manta_script += fluid_variables_noise + smoke_variables_noise;
@@ -1626,14 +1630,14 @@ void MANTA::exportSmokeScript(FluidModifierData *fmd)
if (guiding)
manta_script += fluid_variables_guiding;
- // Solvers
+ /* Solvers. */
manta_script += header_solvers + fluid_solver;
if (noise)
manta_script += fluid_solver_noise;
if (guiding)
manta_script += fluid_solver_guiding;
- // Grids
+ /* Grids. */
manta_script += header_grids + fluid_alloc + smoke_alloc;
if (noise) {
manta_script += smoke_alloc_noise;
@@ -1657,36 +1661,36 @@ void MANTA::exportSmokeScript(FluidModifierData *fmd)
if (outflow)
manta_script += fluid_alloc_outflow;
- // Noise field
+ /* Noise field. */
if (noise)
manta_script += smoke_wavelet_noise;
- // Time
+ /* Time. */
manta_script += header_time + fluid_time_stepping + fluid_adapt_time_step;
- // Import
+ /* Import. */
manta_script += header_import + fluid_file_import + fluid_cache_helper + smoke_load_data;
if (noise)
manta_script += smoke_load_noise;
if (guiding)
manta_script += fluid_load_guiding;
- // Pre/Post Steps
+ /* Pre/Post Steps. */
manta_script += header_prepost + fluid_pre_step + fluid_post_step;
- // Steps
+ /* Steps. */
manta_script += header_steps + smoke_adaptive_step + smoke_step;
if (noise) {
manta_script += smoke_step_noise;
}
- // Main
+ /* Main. */
manta_script += header_main + smoke_standalone + fluid_standalone;
- // Fill in missing variables in script
+ /* Fill in missing variables in script. */
string final_script = MANTA::parseScript(manta_script, fmd);
- // Write script
+ /* Write script. */
ofstream myfile;
myfile.open(cacheDirScript);
myfile << final_script;
@@ -1725,10 +1729,10 @@ void MANTA::exportLiquidScript(FluidModifierData *fmd)
string manta_script;
- // Libraries
+ /* Libraries. */
manta_script += header_libraries + manta_import;
- // Variables
+ /* Variables. */
manta_script += header_variables + fluid_variables + liquid_variables;
if (mesh)
manta_script += fluid_variables_mesh;
@@ -1737,7 +1741,7 @@ void MANTA::exportLiquidScript(FluidModifierData *fmd)
if (guiding)
manta_script += fluid_variables_guiding;
- // Solvers
+ /* Solvers. */
manta_script += header_solvers + fluid_solver;
if (mesh)
manta_script += fluid_solver_mesh;
@@ -1746,7 +1750,7 @@ void MANTA::exportLiquidScript(FluidModifierData *fmd)
if (guiding)
manta_script += fluid_solver_guiding;
- // Grids
+ /* Grids. */
manta_script += header_grids + fluid_alloc + liquid_alloc;
if (mesh)
manta_script += liquid_alloc_mesh;
@@ -1763,13 +1767,13 @@ void MANTA::exportLiquidScript(FluidModifierData *fmd)
if (outflow)
manta_script += fluid_alloc_outflow;
- // Domain init
+ /* Domain init. */
manta_script += header_gridinit + liquid_init_phi;
- // Time
+ /* Time. */
manta_script += header_time + fluid_time_stepping + fluid_adapt_time_step;
- // Import
+ /* Import. */
manta_script += header_import + fluid_file_import + fluid_cache_helper + liquid_load_data;
if (mesh)
manta_script += liquid_load_mesh;
@@ -1778,23 +1782,23 @@ void MANTA::exportLiquidScript(FluidModifierData *fmd)
if (guiding)
manta_script += fluid_load_guiding;
- // Pre/Post Steps
+ /* Pre/Post Steps. */
manta_script += header_prepost + fluid_pre_step + fluid_post_step;
- // Steps
+ /* Steps. */
manta_script += header_steps + liquid_adaptive_step + liquid_step;
if (mesh)
manta_script += liquid_step_mesh;
if (drops || bubble || floater || tracer)
manta_script += liquid_step_particles;
- // Main
+ /* Main. */
manta_script += header_main + liquid_standalone + fluid_standalone;
- // Fill in missing variables in script
+ /* Fill in missing variables in script. */
string final_script = MANTA::parseScript(manta_script, fmd);
- // Write script
+ /* Write script. */
ofstream myfile;
myfile.open(cacheDirScript);
myfile << final_script;
@@ -1823,12 +1827,18 @@ static PyObject *callPythonFunction(string varName, string functionName, bool is
/* Be sure to initialize Python before using it. */
Py_Initialize();
- // Get pyobject that holds result value
+ /* Get pyobject that holds result value. */
if (!manta_main_module) {
PyGILState_Release(gilstate);
return nullptr;
}
+ /* Ensure that requested variable is present in module - avoid attribute errors later on. */
+ if (!PyObject_HasAttrString(manta_main_module, varName.c_str())) {
+ PyGILState_Release(gilstate);
+ return nullptr;
+ }
+
var = PyObject_GetAttrString(manta_main_module, varName.c_str());
if (!var) {
PyGILState_Release(gilstate);
@@ -1911,6 +1921,11 @@ static long pyObjectToLong(PyObject *inputObject)
return result;
}
+template<class T> static T *getPointer(string pyObjectName, string pyFunctionName)
+{
+ return static_cast<T *>(pyObjectToPointer(callPythonFunction(pyObjectName, pyFunctionName)));
+}
+
int MANTA::getFrame()
{
if (with_debug)
@@ -1955,137 +1970,137 @@ void MANTA::adaptTimestep()
runPythonString(pythonCommands);
}
-void MANTA::updatePointers()
+void MANTA::updatePointers(FluidModifierData *fmd, bool flush)
{
if (with_debug)
cout << "MANTA::updatePointers()" << endl;
+ FluidDomainSettings *fds = fmd->domain;
+
+ bool liquid = !flush && (fds->type == FLUID_DOMAIN_TYPE_LIQUID);
+ bool smoke = !flush && (fds->type == FLUID_DOMAIN_TYPE_GAS);
+ bool noise = !flush && smoke && fds->flags & FLUID_DOMAIN_USE_NOISE;
+ bool heat = !flush && smoke && fds->active_fields & FLUID_DOMAIN_ACTIVE_HEAT;
+ bool colors = !flush && smoke && fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS;
+ bool fire = !flush && smoke && fds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE;
+ bool obstacle = !flush && fds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE;
+ bool guiding = !flush && fds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE;
+ bool invel = !flush && fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL;
+ bool outflow = !flush && fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW;
+ bool drops = !flush && liquid && fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY;
+ bool bubble = !flush && liquid && fds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE;
+ bool floater = !flush && liquid && fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM;
+ bool tracer = !flush && liquid && fds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER;
+ bool parts = !flush && liquid && (drops | bubble | floater | tracer);
+ bool mesh = !flush && liquid && fds->flags & FLUID_DOMAIN_USE_MESH;
+ bool meshvel = !flush && liquid && mesh && fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS;
+
string func = "getDataPointer";
string funcNodes = "getNodesDataPointer";
string funcTris = "getTrisDataPointer";
string id = to_string(mCurrentID);
- string solver = "s" + id;
- string parts = "pp" + id;
- string snd = "sp" + id;
- string mesh = "sm" + id;
- string mesh2 = "mesh" + id;
- string noise = "sn" + id;
- string solver_ext = "_" + solver;
- string parts_ext = "_" + parts;
- string snd_ext = "_" + snd;
- string mesh_ext = "_" + mesh;
- string mesh_ext2 = "_" + mesh2;
- string noise_ext = "_" + noise;
-
- mFlags = (int *)pyObjectToPointer(callPythonFunction("flags" + solver_ext, func));
- mPhiIn = (float *)pyObjectToPointer(callPythonFunction("phiIn" + solver_ext, func));
- mPhiStaticIn = (float *)pyObjectToPointer(callPythonFunction("phiSIn" + solver_ext, func));
- mVelocityX = (float *)pyObjectToPointer(callPythonFunction("x_vel" + solver_ext, func));
- mVelocityY = (float *)pyObjectToPointer(callPythonFunction("y_vel" + solver_ext, func));
- mVelocityZ = (float *)pyObjectToPointer(callPythonFunction("z_vel" + solver_ext, func));
- mForceX = (float *)pyObjectToPointer(callPythonFunction("x_force" + solver_ext, func));
- mForceY = (float *)pyObjectToPointer(callPythonFunction("y_force" + solver_ext, func));
- mForceZ = (float *)pyObjectToPointer(callPythonFunction("z_force" + solver_ext, func));
-
- if (mUsingOutflow) {
- mPhiOutIn = (float *)pyObjectToPointer(callPythonFunction("phiOutIn" + solver_ext, func));
- mPhiOutStaticIn = (float *)pyObjectToPointer(
- callPythonFunction("phiOutSIn" + solver_ext, func));
- }
- if (mUsingObstacle) {
- mPhiObsIn = (float *)pyObjectToPointer(callPythonFunction("phiObsIn" + solver_ext, func));
- mPhiObsStaticIn = (float *)pyObjectToPointer(
- callPythonFunction("phiObsSIn" + solver_ext, func));
- mObVelocityX = (float *)pyObjectToPointer(callPythonFunction("x_obvel" + solver_ext, func));
- mObVelocityY = (float *)pyObjectToPointer(callPythonFunction("y_obvel" + solver_ext, func));
- mObVelocityZ = (float *)pyObjectToPointer(callPythonFunction("z_obvel" + solver_ext, func));
- mNumObstacle = (float *)pyObjectToPointer(callPythonFunction("numObs" + solver_ext, func));
- }
- if (mUsingGuiding) {
- mPhiGuideIn = (float *)pyObjectToPointer(callPythonFunction("phiGuideIn" + solver_ext, func));
- mGuideVelocityX = (float *)pyObjectToPointer(
- callPythonFunction("x_guidevel" + solver_ext, func));
- mGuideVelocityY = (float *)pyObjectToPointer(
- callPythonFunction("y_guidevel" + solver_ext, func));
- mGuideVelocityZ = (float *)pyObjectToPointer(
- callPythonFunction("z_guidevel" + solver_ext, func));
- mNumGuide = (float *)pyObjectToPointer(callPythonFunction("numGuides" + solver_ext, func));
- }
- if (mUsingInvel) {
- mInVelocityX = (float *)pyObjectToPointer(callPythonFunction("x_invel" + solver_ext, func));
- mInVelocityY = (float *)pyObjectToPointer(callPythonFunction("y_invel" + solver_ext, func));
- mInVelocityZ = (float *)pyObjectToPointer(callPythonFunction("z_invel" + solver_ext, func));
- }
- if (mUsingSmoke) {
- mDensity = (float *)pyObjectToPointer(callPythonFunction("density" + solver_ext, func));
- mDensityIn = (float *)pyObjectToPointer(callPythonFunction("densityIn" + solver_ext, func));
- mShadow = (float *)pyObjectToPointer(callPythonFunction("shadow" + solver_ext, func));
- mEmissionIn = (float *)pyObjectToPointer(callPythonFunction("emissionIn" + solver_ext, func));
- }
- if (mUsingSmoke && mUsingHeat) {
- mHeat = (float *)pyObjectToPointer(callPythonFunction("heat" + solver_ext, func));
- mHeatIn = (float *)pyObjectToPointer(callPythonFunction("heatIn" + solver_ext, func));
- }
- if (mUsingSmoke && mUsingFire) {
- mFlame = (float *)pyObjectToPointer(callPythonFunction("flame" + solver_ext, func));
- mFuel = (float *)pyObjectToPointer(callPythonFunction("fuel" + solver_ext, func));
- mReact = (float *)pyObjectToPointer(callPythonFunction("react" + solver_ext, func));
- mFuelIn = (float *)pyObjectToPointer(callPythonFunction("fuelIn" + solver_ext, func));
- mReactIn = (float *)pyObjectToPointer(callPythonFunction("reactIn" + solver_ext, func));
- }
- if (mUsingSmoke && mUsingColors) {
- mColorR = (float *)pyObjectToPointer(callPythonFunction("color_r" + solver_ext, func));
- mColorG = (float *)pyObjectToPointer(callPythonFunction("color_g" + solver_ext, func));
- mColorB = (float *)pyObjectToPointer(callPythonFunction("color_b" + solver_ext, func));
- mColorRIn = (float *)pyObjectToPointer(callPythonFunction("color_r_in" + solver_ext, func));
- mColorGIn = (float *)pyObjectToPointer(callPythonFunction("color_g_in" + solver_ext, func));
- mColorBIn = (float *)pyObjectToPointer(callPythonFunction("color_b_in" + solver_ext, func));
- }
- if (mUsingSmoke && mUsingNoise) {
- mDensityHigh = (float *)pyObjectToPointer(callPythonFunction("density" + noise_ext, func));
- mTextureU = (float *)pyObjectToPointer(callPythonFunction("texture_u" + solver_ext, func));
- mTextureV = (float *)pyObjectToPointer(callPythonFunction("texture_v" + solver_ext, func));
- mTextureW = (float *)pyObjectToPointer(callPythonFunction("texture_w" + solver_ext, func));
- mTextureU2 = (float *)pyObjectToPointer(callPythonFunction("texture_u2" + solver_ext, func));
- mTextureV2 = (float *)pyObjectToPointer(callPythonFunction("texture_v2" + solver_ext, func));
- mTextureW2 = (float *)pyObjectToPointer(callPythonFunction("texture_w2" + solver_ext, func));
- }
- if (mUsingSmoke && mUsingNoise && mUsingFire) {
- mFlameHigh = (float *)pyObjectToPointer(callPythonFunction("flame" + noise_ext, func));
- mFuelHigh = (float *)pyObjectToPointer(callPythonFunction("fuel" + noise_ext, func));
- mReactHigh = (float *)pyObjectToPointer(callPythonFunction("react" + noise_ext, func));
- }
- if (mUsingSmoke && mUsingNoise && mUsingColors) {
- mColorRHigh = (float *)pyObjectToPointer(callPythonFunction("color_r" + noise_ext, func));
- mColorGHigh = (float *)pyObjectToPointer(callPythonFunction("color_g" + noise_ext, func));
- mColorBHigh = (float *)pyObjectToPointer(callPythonFunction("color_b" + noise_ext, func));
- }
- if (mUsingLiquid) {
- mPhi = (float *)pyObjectToPointer(callPythonFunction("phi" + solver_ext, func));
- mFlipParticleData = (vector<pData> *)pyObjectToPointer(
- callPythonFunction("pp" + solver_ext, func));
- mFlipParticleVelocity = (vector<pVel> *)pyObjectToPointer(
- callPythonFunction("pVel" + parts_ext, func));
- }
- if (mUsingLiquid && mUsingMesh) {
- mMeshNodes = (vector<Node> *)pyObjectToPointer(
- callPythonFunction("mesh" + mesh_ext, funcNodes));
- mMeshTriangles = (vector<Triangle> *)pyObjectToPointer(
- callPythonFunction("mesh" + mesh_ext, funcTris));
- }
- if (mUsingLiquid && mUsingMVel) {
- mMeshVelocities = (vector<pVel> *)pyObjectToPointer(
- callPythonFunction("mVel" + mesh_ext2, func));
- }
- if (mUsingLiquid && (mUsingDrops | mUsingBubbles | mUsingFloats | mUsingTracers)) {
- mSndParticleData = (vector<pData> *)pyObjectToPointer(
- callPythonFunction("ppSnd" + snd_ext, func));
- mSndParticleVelocity = (vector<pVel> *)pyObjectToPointer(
- callPythonFunction("pVelSnd" + parts_ext, func));
- mSndParticleLife = (vector<float> *)pyObjectToPointer(
- callPythonFunction("pLifeSnd" + parts_ext, func));
- }
+ string s_ext = "_s" + id;
+ string pp_ext = "_pp" + id;
+ string snd_ext = "_sp" + id;
+ string sm_ext = "_sm" + id;
+ string mesh_ext = "_mesh" + id;
+ string sn_ext = "_sn" + id;
+
+ mFlags = (smoke || liquid) ? getPointer<int>("flags" + s_ext, func) : nullptr;
+ mPhiIn = (smoke || liquid) ? getPointer<float>("phiIn" + s_ext, func) : nullptr;
+ mPhiStaticIn = (smoke || liquid) ? getPointer<float>("phiSIn" + s_ext, func) : nullptr;
+ mVelocityX = (smoke || liquid) ? getPointer<float>("x_vel" + s_ext, func) : nullptr;
+ mVelocityY = (smoke || liquid) ? getPointer<float>("y_vel" + s_ext, func) : nullptr;
+ mVelocityZ = (smoke || liquid) ? getPointer<float>("z_vel" + s_ext, func) : nullptr;
+ mForceX = (smoke || liquid) ? getPointer<float>("x_force" + s_ext, func) : nullptr;
+ mForceY = (smoke || liquid) ? getPointer<float>("y_force" + s_ext, func) : nullptr;
+ mForceZ = (smoke || liquid) ? getPointer<float>("z_force" + s_ext, func) : nullptr;
+
+ /* Outflow. */
+ mPhiOutIn = (outflow) ? getPointer<float>("phiOutIn" + s_ext, func) : nullptr;
+ mPhiOutStaticIn = (outflow) ? getPointer<float>("phiOutSIn" + s_ext, func) : nullptr;
+
+ /* Obstacles. */
+ mPhiObsIn = (obstacle) ? getPointer<float>("phiObsIn" + s_ext, func) : nullptr;
+ mPhiObsStaticIn = (obstacle) ? getPointer<float>("phiObsSIn" + s_ext, func) : nullptr;
+ mObVelocityX = (obstacle) ? getPointer<float>("x_obvel" + s_ext, func) : nullptr;
+ mObVelocityY = (obstacle) ? getPointer<float>("y_obvel" + s_ext, func) : nullptr;
+ mObVelocityZ = (obstacle) ? getPointer<float>("z_obvel" + s_ext, func) : nullptr;
+ mNumObstacle = (obstacle) ? getPointer<float>("numObs" + s_ext, func) : nullptr;
+
+ /* Guiding. */
+ mPhiGuideIn = (guiding) ? getPointer<float>("phiGuideIn" + s_ext, func) : nullptr;
+ mGuideVelocityX = (guiding) ? getPointer<float>("x_guidevel" + s_ext, func) : nullptr;
+ mGuideVelocityY = (guiding) ? getPointer<float>("y_guidevel" + s_ext, func) : nullptr;
+ mGuideVelocityZ = (guiding) ? getPointer<float>("z_guidevel" + s_ext, func) : nullptr;
+ mNumGuide = (guiding) ? getPointer<float>("numGuides" + s_ext, func) : nullptr;
+
+ /* Initial velocities. */
+ mInVelocityX = (invel) ? getPointer<float>("x_invel" + s_ext, func) : nullptr;
+ mInVelocityY = (invel) ? getPointer<float>("y_invel" + s_ext, func) : nullptr;
+ mInVelocityZ = (invel) ? getPointer<float>("z_invel" + s_ext, func) : nullptr;
+
+ /* Smoke. */
+ mDensity = (smoke) ? getPointer<float>("density" + s_ext, func) : nullptr;
+ mDensityIn = (smoke) ? getPointer<float>("densityIn" + s_ext, func) : nullptr;
+ mShadow = (smoke) ? getPointer<float>("shadow" + s_ext, func) : nullptr;
+ mEmissionIn = (smoke) ? getPointer<float>("emissionIn" + s_ext, func) : nullptr;
+
+ /* Heat. */
+ mHeat = (heat) ? getPointer<float>("heat" + s_ext, func) : nullptr;
+ mHeatIn = (heat) ? getPointer<float>("heatIn" + s_ext, func) : nullptr;
+
+ /* Fire. */
+ mFlame = (fire) ? getPointer<float>("flame" + s_ext, func) : nullptr;
+ mFuel = (fire) ? getPointer<float>("fuel" + s_ext, func) : nullptr;
+ mReact = (fire) ? getPointer<float>("react" + s_ext, func) : nullptr;
+ mFuelIn = (fire) ? getPointer<float>("fuelIn" + s_ext, func) : nullptr;
+ mReactIn = (fire) ? getPointer<float>("reactIn" + s_ext, func) : nullptr;
+
+ /* Colors. */
+ mColorR = (colors) ? getPointer<float>("color_r" + s_ext, func) : nullptr;
+ mColorG = (colors) ? getPointer<float>("color_g" + s_ext, func) : nullptr;
+ mColorB = (colors) ? getPointer<float>("color_b" + s_ext, func) : nullptr;
+ mColorRIn = (colors) ? getPointer<float>("color_r_in" + s_ext, func) : nullptr;
+ mColorGIn = (colors) ? getPointer<float>("color_g_in" + s_ext, func) : nullptr;
+ mColorBIn = (colors) ? getPointer<float>("color_b_in" + s_ext, func) : nullptr;
+
+ /* Noise. */
+ mDensityHigh = (noise) ? getPointer<float>("density" + sn_ext, func) : nullptr;
+ mTextureU = (noise) ? getPointer<float>("texture_u" + s_ext, func) : nullptr;
+ mTextureV = (noise) ? getPointer<float>("texture_v" + s_ext, func) : nullptr;
+ mTextureW = (noise) ? getPointer<float>("texture_w" + s_ext, func) : nullptr;
+ mTextureU2 = (noise) ? getPointer<float>("texture_u2" + s_ext, func) : nullptr;
+ mTextureV2 = (noise) ? getPointer<float>("texture_v2" + s_ext, func) : nullptr;
+ mTextureW2 = (noise) ? getPointer<float>("texture_w2" + s_ext, func) : nullptr;
+
+ /* Fire with noise. */
+ mFlameHigh = (noise && fire) ? getPointer<float>("flame" + sn_ext, func) : nullptr;
+ mFuelHigh = (noise && fire) ? getPointer<float>("fuel" + sn_ext, func) : nullptr;
+ mReactHigh = (noise && fire) ? getPointer<float>("react" + sn_ext, func) : nullptr;
+
+ /* Colors with noise. */
+ mColorRHigh = (noise && colors) ? getPointer<float>("color_r" + sn_ext, func) : nullptr;
+ mColorGHigh = (noise && colors) ? getPointer<float>("color_g" + sn_ext, func) : nullptr;
+ mColorBHigh = (noise && colors) ? getPointer<float>("color_b" + sn_ext, func) : nullptr;
+
+ /* Liquid. */
+ mPhi = (liquid) ? getPointer<float>("phi" + s_ext, func) : nullptr;
+ mFlipParticleData = (liquid) ? getPointer<vector<pData>>("pp" + s_ext, func) : nullptr;
+ mFlipParticleVelocity = (liquid) ? getPointer<vector<pVel>>("pVel" + pp_ext, func) : nullptr;
+
+ /* Mesh. */
+ mMeshNodes = (mesh) ? getPointer<vector<Node>>("mesh" + sm_ext, funcNodes) : nullptr;
+ mMeshTriangles = (mesh) ? getPointer<vector<Triangle>>("mesh" + sm_ext, funcTris) : nullptr;
+
+ /* Mesh velocities. */
+ mMeshVelocities = (meshvel) ? getPointer<vector<pVel>>("mVel" + mesh_ext, func) : nullptr;
+
+ /* Secondary particles. */
+ mParticleData = (parts) ? getPointer<vector<pData>>("ppSnd" + snd_ext, func) : nullptr;
+ mParticleVelocity = (parts) ? getPointer<vector<pVel>>("pVelSnd" + pp_ext, func) : nullptr;
+ mParticleLife = (parts) ? getPointer<vector<float>>("pLifeSnd" + pp_ext, func) : nullptr;
mFlipFromFile = false;
mMeshFromFile = false;
@@ -2190,9 +2205,16 @@ bool MANTA::hasParticles(FluidModifierData *fmd, int framenr)
bool MANTA::hasGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain)
{
string subdirectory = (sourceDomain) ? FLUID_DOMAIN_DIR_DATA : FLUID_DOMAIN_DIR_GUIDE;
- string filename = (sourceDomain) ? FLUID_NAME_VELOCITY : FLUID_NAME_GUIDEVEL;
+ string filename = (sourceDomain) ? FLUID_NAME_DATA : FLUID_NAME_GUIDING;
string extension = getCacheFileEnding(fmd->domain->cache_data_format);
bool exists = BLI_exists(getFile(fmd, subdirectory, filename, extension, framenr).c_str());
+
+ /* Check old file naming. */
+ if (!exists) {
+ filename = (sourceDomain) ? FLUID_NAME_VEL : FLUID_NAME_GUIDEVEL;
+ exists = BLI_exists(getFile(fmd, subdirectory, filename, extension, framenr).c_str());
+ }
+
if (with_debug)
cout << "Fluid: Has Guiding: " << exists << endl;
diff --git a/intern/mantaflow/intern/MANTA_main.h b/intern/mantaflow/intern/MANTA_main.h
index dae2aea4e08..5fd94ca01bc 100644
--- a/intern/mantaflow/intern/MANTA_main.h
+++ b/intern/mantaflow/intern/MANTA_main.h
@@ -41,7 +41,7 @@ struct MANTA {
MANTA(){};
virtual ~MANTA();
- // Mirroring Mantaflow structures for particle data (pVel also used for mesh vert vels)
+ /* Mirroring Mantaflow structures for particle data (pVel also used for mesh vert vels). */
typedef struct PData {
float pos[3];
int flag;
@@ -50,7 +50,7 @@ struct MANTA {
float pos[3];
} pVel;
- // Mirroring Mantaflow structures for meshes
+ /* Mirroring Mantaflow structures for meshes. */
typedef struct Node {
int flags;
float pos[3], normal[3];
@@ -60,36 +60,33 @@ struct MANTA {
int flags;
} Triangle;
- // Manta step, handling everything
- void step(struct FluidModifierData *fmd, int startFrame);
-
- // Grid initialization functions
- void initHeat(struct FluidModifierData *fmd = NULL);
- void initFire(struct FluidModifierData *fmd = NULL);
- void initColors(struct FluidModifierData *fmd = NULL);
- void initFireHigh(struct FluidModifierData *fmd = NULL);
- void initColorsHigh(struct FluidModifierData *fmd = NULL);
- void initLiquid(FluidModifierData *fmd = NULL);
- void initLiquidMesh(FluidModifierData *fmd = NULL);
- void initObstacle(FluidModifierData *fmd = NULL);
- void initCurvature(FluidModifierData *fmd = NULL);
- void initGuiding(FluidModifierData *fmd = NULL);
- void initFractions(FluidModifierData *fmd = NULL);
- void initInVelocity(FluidModifierData *fmd = NULL);
- void initOutflow(FluidModifierData *fmd = NULL);
- void initSndParts(FluidModifierData *fmd = NULL);
- void initLiquidSndParts(FluidModifierData *fmd = NULL);
-
- // Pointer transfer: Mantaflow -> Blender
- void updatePointers();
-
- // Write cache
+ /* Grid initialization functions. */
+ bool initHeat(struct FluidModifierData *fmd = nullptr);
+ bool initFire(struct FluidModifierData *fmd = nullptr);
+ bool initColors(struct FluidModifierData *fmd = nullptr);
+ bool initFireHigh(struct FluidModifierData *fmd = nullptr);
+ bool initColorsHigh(struct FluidModifierData *fmd = nullptr);
+ bool initLiquid(FluidModifierData *fmd = nullptr);
+ bool initLiquidMesh(FluidModifierData *fmd = nullptr);
+ bool initObstacle(FluidModifierData *fmd = nullptr);
+ bool initCurvature(FluidModifierData *fmd = nullptr);
+ bool initGuiding(FluidModifierData *fmd = nullptr);
+ bool initFractions(FluidModifierData *fmd = nullptr);
+ bool initInVelocity(FluidModifierData *fmd = nullptr);
+ bool initOutflow(FluidModifierData *fmd = nullptr);
+ bool initSndParts(FluidModifierData *fmd = nullptr);
+ bool initLiquidSndParts(FluidModifierData *fmd = nullptr);
+
+ /* Pointer transfer: Mantaflow -> Blender. Use flush to reset all pointers to nullptr. */
+ void updatePointers(FluidModifierData *fmd, bool flush = false);
+
+ /* Write cache. */
bool writeConfiguration(FluidModifierData *fmd, int framenr);
bool writeData(FluidModifierData *fmd, int framenr);
bool writeNoise(FluidModifierData *fmd, int framenr);
- // write calls for mesh and particles were left in bake calls for now
+ /* Write calls for mesh and particles were left in bake calls for now. */
- // Read cache (via Manta save/load)
+ /* Read cache (via Python). */
bool readConfiguration(FluidModifierData *fmd, int framenr);
bool readData(FluidModifierData *fmd, int framenr, bool resumable);
bool readNoise(FluidModifierData *fmd, int framenr, bool resumable);
@@ -97,26 +94,21 @@ struct MANTA {
bool readParticles(FluidModifierData *fmd, int framenr, bool resumable);
bool readGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain);
- // Read cache (via file read functions in MANTA - e.g. read .bobj.gz meshes, .uni particles)
- bool updateMeshStructures(FluidModifierData *fmd, int framenr);
- bool updateFlipStructures(FluidModifierData *fmd, int framenr);
- bool updateParticleStructures(FluidModifierData *fmd, int framenr);
- bool updateSmokeStructures(FluidModifierData *fmd, int framenr);
- bool updateNoiseStructures(FluidModifierData *fmd, int framenr);
+ /* Propagate variable changes from RNA to Python. */
bool updateVariables(FluidModifierData *fmd);
- // Bake cache
+ /* Bake cache. */
bool bakeData(FluidModifierData *fmd, int framenr);
bool bakeNoise(FluidModifierData *fmd, int framenr);
bool bakeMesh(FluidModifierData *fmd, int framenr);
bool bakeParticles(FluidModifierData *fmd, int framenr);
bool bakeGuiding(FluidModifierData *fmd, int framenr);
- // IO for Mantaflow scene script
+ /* IO for Mantaflow scene script. */
void exportSmokeScript(struct FluidModifierData *fmd);
void exportLiquidScript(struct FluidModifierData *fmd);
- // Check cache status by frame
+ /* Check cache status by frame. */
bool hasConfig(FluidModifierData *fmd, int framenr);
bool hasData(FluidModifierData *fmd, int framenr);
bool hasNoise(FluidModifierData *fmd, int framenr);
@@ -193,7 +185,7 @@ struct MANTA {
return mUpresParticle;
}
- // Smoke getters
+ /* Smoke getters. */
inline float *getDensity()
{
return mDensity;
@@ -422,9 +414,9 @@ struct MANTA {
}
static atomic<int> solverID;
- static int with_debug; // on or off (1 or 0), also sets manta debug level
+ static int with_debug; /* On or off (1 or 0), also sets manta debug level. */
- // Mesh getters
+ /* Mesh getters. */
inline int getNumVertices()
{
return (mMeshNodes && !mMeshNodes->empty()) ? mMeshNodes->size() : 0;
@@ -563,9 +555,9 @@ struct MANTA {
inline int getSndParticleFlagAt(int i)
{
assert(i >= 0);
- if (mSndParticleData && !mSndParticleData->empty()) {
- assert(i < mSndParticleData->size());
- return (*mSndParticleData)[i].flag;
+ if (mParticleData && !mParticleData->empty()) {
+ assert(i < mParticleData->size());
+ return (*mParticleData)[i].flag;
}
return 0;
}
@@ -601,27 +593,27 @@ struct MANTA {
inline float getSndParticlePositionXAt(int i)
{
assert(i >= 0);
- if (mSndParticleData && !mSndParticleData->empty()) {
- assert(i < mSndParticleData->size());
- return (*mSndParticleData)[i].pos[0];
+ if (mParticleData && !mParticleData->empty()) {
+ assert(i < mParticleData->size());
+ return (*mParticleData)[i].pos[0];
}
return 0.0f;
}
inline float getSndParticlePositionYAt(int i)
{
assert(i >= 0);
- if (mSndParticleData && !mSndParticleData->empty()) {
- assert(i < mSndParticleData->size());
- return (*mSndParticleData)[i].pos[1];
+ if (mParticleData && !mParticleData->empty()) {
+ assert(i < mParticleData->size());
+ return (*mParticleData)[i].pos[1];
}
return 0.0f;
}
inline float getSndParticlePositionZAt(int i)
{
assert(i >= 0);
- if (mSndParticleData && !mSndParticleData->empty()) {
- assert(i < mSndParticleData->size());
- return (*mSndParticleData)[i].pos[2];
+ if (mParticleData && !mParticleData->empty()) {
+ assert(i < mParticleData->size());
+ return (*mParticleData)[i].pos[2];
}
return 0.0f;
}
@@ -657,27 +649,27 @@ struct MANTA {
inline float getSndParticleVelocityXAt(int i)
{
assert(i >= 0);
- if (mSndParticleVelocity && !mSndParticleVelocity->empty()) {
- assert(i < mSndParticleVelocity->size());
- return (*mSndParticleVelocity)[i].pos[0];
+ if (mParticleVelocity && !mParticleVelocity->empty()) {
+ assert(i < mParticleVelocity->size());
+ return (*mParticleVelocity)[i].pos[0];
}
return 0.0f;
}
inline float getSndParticleVelocityYAt(int i)
{
assert(i >= 0);
- if (mSndParticleVelocity && !mSndParticleVelocity->empty()) {
- assert(i < mSndParticleVelocity->size());
- return (*mSndParticleVelocity)[i].pos[1];
+ if (mParticleVelocity && !mParticleVelocity->empty()) {
+ assert(i < mParticleVelocity->size());
+ return (*mParticleVelocity)[i].pos[1];
}
return 0.0f;
}
inline float getSndParticleVelocityZAt(int i)
{
assert(i >= 0);
- if (mSndParticleVelocity && !mSndParticleVelocity->empty()) {
- assert(i < mSndParticleVelocity->size());
- return (*mSndParticleVelocity)[i].pos[2];
+ if (mParticleVelocity && !mParticleVelocity->empty()) {
+ assert(i < mParticleVelocity->size());
+ return (*mParticleVelocity)[i].pos[2];
}
return 0.0f;
}
@@ -686,30 +678,28 @@ struct MANTA {
{
return (mFlipParticleData && !mFlipParticleData->empty()) ?
(float *)&mFlipParticleData->front() :
- NULL;
+ nullptr;
}
inline float *getSndParticleData()
{
- return (mSndParticleData && !mSndParticleData->empty()) ? (float *)&mSndParticleData->front() :
- NULL;
+ return (mParticleData && !mParticleData->empty()) ? (float *)&mParticleData->front() : nullptr;
}
inline float *getFlipParticleVelocity()
{
return (mFlipParticleVelocity && !mFlipParticleVelocity->empty()) ?
(float *)&mFlipParticleVelocity->front() :
- NULL;
+ nullptr;
}
inline float *getSndParticleVelocity()
{
- return (mSndParticleVelocity && !mSndParticleVelocity->empty()) ?
- (float *)&mSndParticleVelocity->front() :
- NULL;
+ return (mParticleVelocity && !mParticleVelocity->empty()) ?
+ (float *)&mParticleVelocity->front() :
+ nullptr;
}
inline float *getSndParticleLife()
{
- return (mSndParticleLife && !mSndParticleLife->empty()) ? (float *)&mSndParticleLife->front() :
- NULL;
+ return (mParticleLife && !mParticleLife->empty()) ? (float *)&mParticleLife->front() : nullptr;
}
inline int getNumFlipParticles()
@@ -718,7 +708,7 @@ struct MANTA {
}
inline int getNumSndParticles()
{
- return (mSndParticleData && !mSndParticleData->empty()) ? mSndParticleData->size() : 0;
+ return (mParticleData && !mParticleData->empty()) ? mParticleData->size() : 0;
}
inline bool usingFlipFromFile()
@@ -734,7 +724,7 @@ struct MANTA {
return mParticlesFromFile;
}
- // Direct access to solver time attributes
+ /* Direct access to solver time attributes. */
int getFrame();
float getTimestep();
void adaptTimestep();
@@ -742,7 +732,7 @@ struct MANTA {
bool needsRealloc(FluidModifierData *fmd);
private:
- // simulation constants
+ /* Simulation constants. */
size_t mTotalCells;
size_t mTotalCellsHigh;
size_t mTotalCellsMesh;
@@ -750,6 +740,7 @@ struct MANTA {
unordered_map<string, string> mRNAMap;
+ /* The ID of the solver objects will be incremented for every new object. */
int mCurrentID;
bool mUsingHeat;
@@ -796,10 +787,7 @@ struct MANTA {
int mUpresMesh;
int mUpresParticle;
- float mTempAmb; /* ambient temperature */
- float mConstantScaling;
-
- // Fluid grids
+ /* Fluid grids. */
float *mVelocityX;
float *mVelocityY;
float *mVelocityZ;
@@ -819,7 +807,7 @@ struct MANTA {
float *mNumObstacle;
float *mNumGuide;
- // Smoke grids
+ /* Smoke grids. */
float *mDensity;
float *mHeat;
float *mFlame;
@@ -851,7 +839,7 @@ struct MANTA {
float *mTextureV2;
float *mTextureW2;
- // Liquid grids
+ /* Liquid grids. */
float *mPhiIn;
float *mPhiStaticIn;
float *mPhiObsIn;
@@ -861,31 +849,31 @@ struct MANTA {
float *mPhiOutStaticIn;
float *mPhi;
- // Mesh fields
+ /* Mesh fields. */
vector<Node> *mMeshNodes;
vector<Triangle> *mMeshTriangles;
vector<pVel> *mMeshVelocities;
- // Particle fields
+ /* Particle fields. */
vector<pData> *mFlipParticleData;
vector<pVel> *mFlipParticleVelocity;
- vector<pData> *mSndParticleData;
- vector<pVel> *mSndParticleVelocity;
- vector<float> *mSndParticleLife;
+ vector<pData> *mParticleData;
+ vector<pVel> *mParticleVelocity;
+ vector<float> *mParticleLife;
- void initializeRNAMap(struct FluidModifierData *fmd = NULL);
- void initDomain(struct FluidModifierData *fmd = NULL);
- void initNoise(struct FluidModifierData *fmd = NULL);
- void initMesh(struct FluidModifierData *fmd = NULL);
- void initSmoke(struct FluidModifierData *fmd = NULL);
- void initSmokeNoise(struct FluidModifierData *fmd = NULL);
+ void initializeRNAMap(struct FluidModifierData *doRnaRefresh = nullptr);
+ bool initDomain(struct FluidModifierData *doRnaRefresh = nullptr);
+ bool initNoise(struct FluidModifierData *doRnaRefresh = nullptr);
+ bool initMesh(struct FluidModifierData *doRnaRefresh = nullptr);
+ bool initSmoke(struct FluidModifierData *doRnaRefresh = nullptr);
+ bool initSmokeNoise(struct FluidModifierData *doRnaRefresh = nullptr);
void initializeMantaflow();
void terminateMantaflow();
bool runPythonString(vector<string> commands);
string getRealValue(const string &varName);
string parseLine(const string &line);
- string parseScript(const string &setup_string, FluidModifierData *fmd = NULL);
+ string parseScript(const string &setup_string, FluidModifierData *fmd = nullptr);
string getDirectory(struct FluidModifierData *fmd, string subdirectory);
string getFile(struct FluidModifierData *fmd,
string subdirectory,
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp
index 60546bc1183..530dbd49b7c 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -37,33 +37,29 @@ void manta_free(MANTA *fluid)
fluid = nullptr;
}
-void manta_ensure_obstacle(MANTA *fluid, struct FluidModifierData *fmd)
+int manta_ensure_obstacle(MANTA *fluid, struct FluidModifierData *fmd)
{
- if (!fluid)
- return;
- fluid->initObstacle(fmd);
- fluid->updatePointers();
+ if (!fluid || !fmd)
+ return 0;
+ return fluid->initObstacle(fmd);
}
-void manta_ensure_guiding(MANTA *fluid, struct FluidModifierData *fmd)
+int manta_ensure_guiding(MANTA *fluid, struct FluidModifierData *fmd)
{
- if (!fluid)
- return;
- fluid->initGuiding(fmd);
- fluid->updatePointers();
+ if (!fluid || !fmd)
+ return 0;
+ return fluid->initGuiding(fmd);
}
-void manta_ensure_invelocity(MANTA *fluid, struct FluidModifierData *fmd)
+int manta_ensure_invelocity(MANTA *fluid, struct FluidModifierData *fmd)
{
- if (!fluid)
- return;
- fluid->initInVelocity(fmd);
- fluid->updatePointers();
+ if (!fluid || !fmd)
+ return 0;
+ return fluid->initInVelocity(fmd);
}
-void manta_ensure_outflow(MANTA *fluid, struct FluidModifierData *fmd)
+int manta_ensure_outflow(MANTA *fluid, struct FluidModifierData *fmd)
{
- if (!fluid)
- return;
- fluid->initOutflow(fmd);
- fluid->updatePointers();
+ if (!fluid || !fmd)
+ return 0;
+ return fluid->initOutflow(fmd);
}
int manta_write_config(MANTA *fluid, FluidModifierData *fmd, int framenr)
@@ -229,11 +225,18 @@ void manta_adapt_timestep(MANTA *fluid)
bool manta_needs_realloc(MANTA *fluid, FluidModifierData *fmd)
{
- if (!fluid)
+ if (!fluid || !fmd)
return false;
return fluid->needsRealloc(fmd);
}
+void manta_update_pointers(struct MANTA *fluid, struct FluidModifierData *fmd, bool flush)
+{
+ if (!fluid || !fmd)
+ return;
+ fluid->updatePointers(fmd, flush);
+}
+
/* Fluid accessors */
size_t manta_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */)
{
@@ -441,34 +444,35 @@ void manta_noise_get_rgba_fixed_color(MANTA *smoke, float color[3], float *data,
get_rgba_fixed_color(color, smoke->getTotalCellsHigh(), data, sequential);
}
-void manta_smoke_ensure_heat(MANTA *smoke, struct FluidModifierData *fmd)
+int manta_smoke_ensure_heat(MANTA *smoke, struct FluidModifierData *fmd)
{
- if (smoke) {
- smoke->initHeat(fmd);
- smoke->updatePointers();
- }
+ if (!smoke || !fmd)
+ return 0;
+ return smoke->initHeat(fmd);
}
-void manta_smoke_ensure_fire(MANTA *smoke, struct FluidModifierData *fmd)
+int manta_smoke_ensure_fire(MANTA *smoke, struct FluidModifierData *fmd)
{
- if (smoke) {
- smoke->initFire(fmd);
- if (smoke->usingNoise()) {
- smoke->initFireHigh(fmd);
- }
- smoke->updatePointers();
+ if (!smoke || !fmd)
+ return 0;
+
+ int result = smoke->initFire(fmd);
+ if (smoke->usingNoise()) {
+ result &= smoke->initFireHigh(fmd);
}
+ return result;
}
-void manta_smoke_ensure_colors(MANTA *smoke, struct FluidModifierData *fmd)
+int manta_smoke_ensure_colors(MANTA *smoke, struct FluidModifierData *fmd)
{
- if (smoke) {
- smoke->initColors(fmd);
- if (smoke->usingNoise()) {
- smoke->initColorsHigh(fmd);
- }
- smoke->updatePointers();
+ if (!smoke || !fmd)
+ return 0;
+
+ int result = smoke->initColors(fmd);
+ if (smoke->usingNoise()) {
+ result &= smoke->initColorsHigh(fmd);
}
+ return result;
}
/* Smoke accessors */
@@ -645,12 +649,11 @@ void manta_liquid_export_script(MANTA *liquid, FluidModifierData *fmd)
liquid->exportLiquidScript(fmd);
}
-void manta_liquid_ensure_sndparts(MANTA *liquid, struct FluidModifierData *fmd)
+int manta_liquid_ensure_sndparts(MANTA *liquid, struct FluidModifierData *fmd)
{
- if (liquid) {
- liquid->initLiquidSndParts(fmd);
- liquid->updatePointers();
- }
+ if (!liquid || !fmd)
+ return 0;
+ return liquid->initLiquidSndParts(fmd);
}
/* Liquid accessors */
diff --git a/intern/mantaflow/intern/strings/fluid_script.h b/intern/mantaflow/intern/strings/fluid_script.h
index 0045d839be4..d669e8cf3b4 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -329,7 +329,7 @@ y_guidevel_s$ID$ = s$ID$.create(RealGrid, name='$NAME_GUIDEVEL_Y$')\n\
z_guidevel_s$ID$ = s$ID$.create(RealGrid, name='$NAME_GUIDEVEL_Z$')\n\
\n\
# Final guide vel grid needs to have independent size\n\
-guidevel_sg$ID$ = sg$ID$.create(MACGrid, name='$NAME_GUIDEVEL$')\n\
+guidevel_sg$ID$ = sg$ID$.create(MACGrid, name='$NAME_VELOCITY_GUIDE$')\n\
\n\
# Keep track of important objects in dict to load them later on\n\
fluid_guiding_dict_s$ID$ = { 'guidevel' : guidevel_sg$ID$ }\n";
@@ -418,19 +418,6 @@ const std::string fluid_post_step =
"\n\
def fluid_post_step_$ID$():\n\
mantaMsg('Fluid post step')\n\
- forces_s$ID$.clear()\n\
- x_force_s$ID$.clear()\n\
- y_force_s$ID$.clear()\n\
- z_force_s$ID$.clear()\n\
- \n\
- if using_guiding_s$ID$:\n\
- weightGuide_s$ID$.clear()\n\
- if using_invel_s$ID$:\n\
- x_invel_s$ID$.clear()\n\
- y_invel_s$ID$.clear()\n\
- z_invel_s$ID$.clear()\n\
- invel_s$ID$.clear()\n\
- invelC_s$ID$.clear()\n\
\n\
# Copy vel grid to reals grids (which Blender internal will in turn use for vel access)\n\
copyVec3ToReal(source=vel_s$ID$, targetX=x_vel_s$ID$, targetY=y_vel_s$ID$, targetZ=z_vel_s$ID$)\n";
@@ -700,14 +687,16 @@ const std::string fluid_load_guiding =
"\n\
def fluid_load_guiding_$ID$(path, framenr, file_format):\n\
mantaMsg('Fluid load guiding, frame ' + str(framenr))\n\
+ guidevel_sg$ID$.setName('$NAME_VELOCITY_GUIDE$')\n\
fluid_file_import_s$ID$(dict=fluid_guiding_dict_s$ID$, path=path, framenr=framenr, file_format=file_format, file_name=file_guiding_s$ID$)\n";
const std::string fluid_load_vel =
"\n\
def fluid_load_vel_$ID$(path, framenr, file_format):\n\
mantaMsg('Fluid load vel, frame ' + str(framenr))\n\
+ guidevel_sg$ID$.setName('$NAME_VELOCITY$') # for loading data the guidevel grid will pretend to be the vel grid\n\
fluid_vel_dict_s$ID$ = { 'vel' : guidevel_sg$ID$ }\n\
- fluid_file_import_s$ID$(dict=fluid_vel_dict_s$ID$, path=path, framenr=framenr, file_format=file_format)\n";
+ fluid_file_import_s$ID$(dict=fluid_vel_dict_s$ID$, path=path, framenr=framenr, file_format=file_format, file_name=file_data_s$ID$)\n";
//////////////////////////////////////////////////////////////////////
// EXPORT
@@ -748,12 +737,13 @@ def fluid_file_export_s$ID$(framenr, file_format, path, dict, file_name=None, mo
const std::string fluid_save_guiding =
"\n\
-def fluid_save_guiding_$ID$(path, framenr, file_format):\n\
+def fluid_save_guiding_$ID$(path, framenr, file_format, resumable):\n\
mantaMsg('Fluid save guiding, frame ' + str(framenr))\n\
+ dict = fluid_guiding_dict_s$ID$\n\
if not withMPSave or isWindows:\n\
- fluid_file_export_s$ID$(dict=fluid_guiding_dict_s$ID$, framenr=framenr, file_format=file_format, path=path, file_name=file_guiding_s$ID$)\n\
+ fluid_file_export_s$ID$(dict=dict, framenr=framenr, file_format=file_format, path=path, file_name=file_guiding_s$ID$)\n\
else:\n\
- fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, file_name=file_guiding_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=fluid_guiding_dict_s$ID$, do_join=False)\n";
+ fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, file_name=file_guiding_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=dict, do_join=False)\n";
//////////////////////////////////////////////////////////////////////
// STANDALONE MODE
diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc
index 43416f734c5..f766f57732a 100644
--- a/intern/opencolorio/ocio_impl_glsl.cc
+++ b/intern/opencolorio/ocio_impl_glsl.cc
@@ -45,9 +45,8 @@
# pragma warning(pop)
#endif
-extern "C" {
#include "GPU_immediate.h"
-}
+#include "GPU_shader.h"
using namespace OCIO_NAMESPACE;
@@ -94,18 +93,15 @@ struct OCIO_GLSLCurveMappingParameters {
struct OCIO_GLSLShader {
/** Cache IDs */
std::string cacheId;
- /** TODO(fclem): Remove. IMM shader interface. */
- struct GPUShaderInterface *interface;
- /** OpenGL Shader objects handles. */
- GLuint frag;
- GLuint vert;
- GLuint program;
+
+ struct GPUShader *shader;
/** Uniform locations. */
GLint dither_loc;
GLint overlay_loc;
GLint overlay_tex_loc;
GLint predivide_loc;
GLint curve_mapping_loc;
+ GLint ubo_bind;
/** Error checking. */
bool valid;
};
@@ -152,56 +148,6 @@ static OCIO_GLSLDrawState *allocateOpenGLState(void)
/** \name Shader
* \{ */
-static GLuint compileShaderText(GLenum shader_type, const char *text)
-{
- GLuint shader;
- GLint stat;
-
- shader = glCreateShader(shader_type);
- glShaderSource(shader, 1, (const GLchar **)&text, NULL);
- glCompileShader(shader);
- glGetShaderiv(shader, GL_COMPILE_STATUS, &stat);
-
- if (!stat) {
- GLchar log[1000];
- GLsizei len;
- glGetShaderInfoLog(shader, 1000, &len, log);
- fprintf(stderr, "Shader compile error:\n%s\n", log);
- return 0;
- }
-
- return shader;
-}
-
-static GLuint linkShaders(GLuint frag, GLuint vert)
-{
- if (!frag || !vert) {
- return 0;
- }
-
- GLuint program = glCreateProgram();
-
- glAttachShader(program, frag);
- glAttachShader(program, vert);
-
- glLinkProgram(program);
-
- /* check link */
- {
- GLint stat;
- glGetProgramiv(program, GL_LINK_STATUS, &stat);
- if (!stat) {
- GLchar log[1000];
- GLsizei len;
- glGetProgramInfoLog(program, 1000, &len, log);
- fprintf(stderr, "Shader link error:\n%s\n", log);
- return 0;
- }
- }
-
- return program;
-}
-
static void updateGLSLShader(OCIO_GLSLShader *shader,
ConstProcessorRcPtr *processor_scene_to_ui,
ConstProcessorRcPtr *processpr_ui_to_display,
@@ -213,28 +159,14 @@ static void updateGLSLShader(OCIO_GLSLShader *shader,
}
/* Delete any previous shader. */
- glDeleteProgram(shader->program);
- glDeleteShader(shader->frag);
- glDeleteShader(shader->vert);
-
- if (shader->interface) {
- GPU_shaderinterface_discard(shader->interface);
+ if (shader->shader) {
+ GPU_shader_free(shader->shader);
}
- {
- /* Vertex shader */
- std::ostringstream osv;
-
- osv << "#version 330\n";
- osv << datatoc_gpu_shader_display_transform_vertex_glsl;
-
- shader->vert = compileShaderText(GL_VERTEX_SHADER, osv.str().c_str());
- }
+ std::ostringstream os;
{
/* Fragment shader */
- std::ostringstream os;
- os << "#version 330\n";
/* Work around OpenColorIO not supporting latest GLSL yet. */
os << "#define texture2D texture\n";
os << "#define texture3D texture\n";
@@ -246,41 +178,36 @@ static void updateGLSLShader(OCIO_GLSLShader *shader,
os << (*processpr_ui_to_display)->getGpuShaderText(*shader_desc) << "\n";
os << datatoc_gpu_shader_display_transform_glsl;
-
- shader->frag = compileShaderText(GL_FRAGMENT_SHADER, os.str().c_str());
}
- /* shader_Program */
- if (shader->frag && shader->vert) {
- shader->program = linkShaders(shader->frag, shader->vert);
- }
+ shader->shader = GPU_shader_create(datatoc_gpu_shader_display_transform_vertex_glsl,
+ os.str().c_str(),
+ NULL,
+ NULL,
+ NULL,
+ __func__);
- if (shader->program) {
- shader->dither_loc = glGetUniformLocation(shader->program, "dither");
- shader->overlay_tex_loc = glGetUniformLocation(shader->program, "overlay_texture");
- shader->overlay_loc = glGetUniformLocation(shader->program, "overlay");
- shader->predivide_loc = glGetUniformLocation(shader->program, "predivide");
- shader->curve_mapping_loc = glGetUniformLocation(shader->program, "curve_mapping");
+ if (shader->shader) {
+ shader->dither_loc = GPU_shader_get_uniform(shader->shader, "dither");
+ shader->overlay_tex_loc = GPU_shader_get_uniform(shader->shader, "overlay_texture");
+ shader->overlay_loc = GPU_shader_get_uniform(shader->shader, "overlay");
+ shader->predivide_loc = GPU_shader_get_uniform(shader->shader, "predivide");
+ shader->curve_mapping_loc = GPU_shader_get_uniform(shader->shader, "curve_mapping");
+ shader->ubo_bind = GPU_shader_get_uniform_block_binding(shader->shader,
+ "OCIO_GLSLCurveMappingParameters");
- glUseProgram(shader->program);
-
- /* TODO(fclem) Remove this. Make caller always assume viewport space and
- * specify texco via vertex attribs. */
- shader->interface = GPU_shaderinterface_create(shader->program);
-
- /* Set UBO binding location. */
- GLuint index = glGetUniformBlockIndex(shader->program, "OCIO_GLSLCurveMappingParameters");
- glUniformBlockBinding(shader->program, index, UBO_BIND_LOC);
+ GPU_shader_bind(shader->shader);
/* Set texture bind point uniform once. This is saved by the shader. */
- glUniform1i(glGetUniformLocation(shader->program, "image_texture"), 0);
- glUniform1i(glGetUniformLocation(shader->program, "lut3d_texture"), 2);
- glUniform1i(glGetUniformLocation(shader->program, "lut3d_display_texture"), 3);
- glUniform1i(glGetUniformLocation(shader->program, "curve_mapping_texture"), 4);
+ GPUShader *sh = shader->shader;
+ GPU_shader_uniform_int(sh, GPU_shader_get_uniform(sh, "image_texture"), 0);
+ GPU_shader_uniform_int(sh, GPU_shader_get_uniform(sh, "lut3d_texture"), 2);
+ GPU_shader_uniform_int(sh, GPU_shader_get_uniform(sh, "lut3d_display_texture"), 3);
+ GPU_shader_uniform_int(sh, GPU_shader_get_uniform(sh, "curve_mapping_texture"), 4);
}
shader->cacheId = cache_id;
- shader->valid = (shader->program != 0);
+ shader->valid = (shader->shader != NULL);
}
static void ensureGLSLShader(OCIO_GLSLShader **shader_ptr,
@@ -302,12 +229,8 @@ static void ensureGLSLShader(OCIO_GLSLShader **shader_ptr,
static void freeGLSLShader(OCIO_GLSLShader *shader)
{
- glDeleteProgram(shader->program);
- glDeleteShader(shader->frag);
- glDeleteShader(shader->vert);
-
- if (shader->interface) {
- GPU_shaderinterface_discard(shader->interface);
+ if (shader->shader) {
+ GPU_shader_free(shader->shader);
}
OBJECT_GUARDED_DELETE(shader, OCIO_GLSLShader);
@@ -674,10 +597,10 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r,
glActiveTexture(GL_TEXTURE0);
/* Bind UBO. */
- glBindBufferBase(GL_UNIFORM_BUFFER, 0, shader_curvemap->buffer);
+ glBindBufferBase(GL_UNIFORM_BUFFER, shader->ubo_bind, shader_curvemap->buffer);
/* TODO(fclem) remove remains of IMM. */
- immBindProgram(shader->program, shader->interface);
+ immBindShader(shader->shader);
/* Bind Shader and set uniforms. */
// glUseProgram(shader->program);
diff --git a/intern/rigidbody/RBI_api.h b/intern/rigidbody/RBI_api.h
index d46cb5a7eed..07cda49e04b 100644
--- a/intern/rigidbody/RBI_api.h
+++ b/intern/rigidbody/RBI_api.h
@@ -238,6 +238,14 @@ rbCollisionShape *RB_shape_new_trimesh(rbMeshData *mesh);
/* 2b - GImpact Meshes */
rbCollisionShape *RB_shape_new_gimpact_mesh(rbMeshData *mesh);
+/* Compound Shape ---------------- */
+
+rbCollisionShape *RB_shape_new_compound(void);
+void RB_compound_add_child_shape(rbCollisionShape *collisionShape,
+ rbCollisionShape *shape,
+ const float loc[3],
+ const float rot[4]);
+
/* Cleanup --------------------------- */
void RB_shape_delete(rbCollisionShape *shape);
diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp
index a8bf1420523..db8c062990c 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -98,6 +98,8 @@ struct rbMeshData {
struct rbCollisionShape {
btCollisionShape *cshape;
rbMeshData *mesh;
+ rbCollisionShape **compoundChildShapes;
+ int compoundChilds;
};
struct rbFilterCallback : public btOverlapFilterCallback {
@@ -331,6 +333,7 @@ rbRigidBody *RB_body_new(rbCollisionShape *shape, const float loc[3], const floa
rbRigidBody *object = new rbRigidBody;
/* current transform */
btTransform trans;
+ trans.setIdentity();
trans.setOrigin(btVector3(loc[0], loc[1], loc[2]));
trans.setRotation(btQuaternion(rot[1], rot[2], rot[3], rot[0]));
@@ -413,6 +416,10 @@ void RB_body_set_mass(rbRigidBody *object, float value)
shape->calculateLocalInertia(value, localInertia);
}
+ btVector3 minAabb, maxAabb;
+ btTransform ident;
+ ident.setIdentity();
+ body->getCollisionShape()->getAabb(ident, minAabb, maxAabb);
body->setMassProps(value, localInertia);
body->updateInertiaTensor();
}
@@ -597,6 +604,7 @@ void RB_body_set_loc_rot(rbRigidBody *object, const float loc[3], const float ro
/* set transform matrix */
btTransform trans;
+ trans.setIdentity();
trans.setOrigin(btVector3(loc[0], loc[1], loc[2]));
trans.setRotation(btQuaternion(rot[1], rot[2], rot[3], rot[0]));
@@ -655,6 +663,8 @@ rbCollisionShape *RB_shape_new_box(float x, float y, float z)
rbCollisionShape *shape = new rbCollisionShape;
shape->cshape = new btBoxShape(btVector3(x, y, z));
shape->mesh = NULL;
+ shape->compoundChilds = 0;
+ shape->compoundChildShapes = NULL;
return shape;
}
@@ -663,6 +673,8 @@ rbCollisionShape *RB_shape_new_sphere(float radius)
rbCollisionShape *shape = new rbCollisionShape;
shape->cshape = new btSphereShape(radius);
shape->mesh = NULL;
+ shape->compoundChilds = 0;
+ shape->compoundChildShapes = NULL;
return shape;
}
@@ -671,6 +683,8 @@ rbCollisionShape *RB_shape_new_capsule(float radius, float height)
rbCollisionShape *shape = new rbCollisionShape;
shape->cshape = new btCapsuleShapeZ(radius, height);
shape->mesh = NULL;
+ shape->compoundChilds = 0;
+ shape->compoundChildShapes = NULL;
return shape;
}
@@ -679,6 +693,8 @@ rbCollisionShape *RB_shape_new_cone(float radius, float height)
rbCollisionShape *shape = new rbCollisionShape;
shape->cshape = new btConeShapeZ(radius, height);
shape->mesh = NULL;
+ shape->compoundChilds = 0;
+ shape->compoundChildShapes = NULL;
return shape;
}
@@ -687,6 +703,8 @@ rbCollisionShape *RB_shape_new_cylinder(float radius, float height)
rbCollisionShape *shape = new rbCollisionShape;
shape->cshape = new btCylinderShapeZ(btVector3(radius, radius, height));
shape->mesh = NULL;
+ shape->compoundChilds = 0;
+ shape->compoundChildShapes = NULL;
return shape;
}
@@ -709,6 +727,8 @@ rbCollisionShape *RB_shape_new_convex_hull(
shape->cshape = hull_shape;
shape->mesh = NULL;
+ shape->compoundChilds = 0;
+ shape->compoundChildShapes = NULL;
return shape;
}
@@ -773,6 +793,8 @@ rbCollisionShape *RB_shape_new_trimesh(rbMeshData *mesh)
shape->cshape = new btScaledBvhTriangleMeshShape(unscaledShape, btVector3(1.0f, 1.0f, 1.0f));
shape->mesh = mesh;
+ shape->compoundChilds = 0;
+ shape->compoundChildShapes = NULL;
return shape;
}
@@ -813,9 +835,46 @@ rbCollisionShape *RB_shape_new_gimpact_mesh(rbMeshData *mesh)
shape->cshape = gimpactShape;
shape->mesh = mesh;
+ shape->compoundChilds = 0;
+ shape->compoundChildShapes = NULL;
return shape;
}
+/* Compound Shape ---------------- */
+
+rbCollisionShape *RB_shape_new_compound()
+{
+ rbCollisionShape *shape = new rbCollisionShape;
+ btCompoundShape *compoundShape = new btCompoundShape();
+
+ shape->cshape = compoundShape;
+ shape->mesh = NULL;
+ shape->compoundChilds = 0;
+ shape->compoundChildShapes = NULL;
+ return shape;
+}
+
+void RB_compound_add_child_shape(rbCollisionShape *parentShape,
+ rbCollisionShape *shape,
+ const float loc[3],
+ const float rot[4])
+{
+ /* set transform matrix */
+ btTransform trans;
+ trans.setIdentity();
+ trans.setOrigin(btVector3(loc[0], loc[1], loc[2]));
+ trans.setRotation(btQuaternion(rot[1], rot[2], rot[3], rot[0]));
+
+ btCompoundShape *compoundShape = (btCompoundShape *)(parentShape->cshape);
+ compoundShape->addChildShape(trans, shape->cshape);
+
+ /* Store shapes for deletion later */
+ parentShape->compoundChildShapes = (rbCollisionShape **)(realloc(
+ parentShape->compoundChildShapes,
+ sizeof(rbCollisionShape *) * (++parentShape->compoundChilds)));
+ parentShape->compoundChildShapes[parentShape->compoundChilds - 1] = shape;
+}
+
/* Cleanup --------------------------- */
void RB_shape_delete(rbCollisionShape *shape)
@@ -829,6 +888,15 @@ void RB_shape_delete(rbCollisionShape *shape)
if (shape->mesh)
RB_trimesh_data_delete(shape->mesh);
delete shape->cshape;
+
+ /* Delete compound child shapes if there are any */
+ for (int i = 0; i < shape->compoundChilds; i++) {
+ RB_shape_delete(shape->compoundChildShapes[i]);
+ }
+ if (shape->compoundChildShapes != NULL) {
+ free(shape->compoundChildShapes);
+ }
+
delete shape;
}
@@ -873,6 +941,7 @@ static void make_constraint_transforms(btTransform &transform1,
float orn[4])
{
btTransform pivot_transform = btTransform();
+ pivot_transform.setIdentity();
pivot_transform.setOrigin(btVector3(pivot[0], pivot[1], pivot[2]));
pivot_transform.setRotation(btQuaternion(orn[1], orn[2], orn[3], orn[0]));
diff --git a/intern/sky/include/sky_model.h b/intern/sky/include/sky_model.h
index 021086e1e02..983b90fed35 100644
--- a/intern/sky/include/sky_model.h
+++ b/intern/sky/include/sky_model.h
@@ -112,7 +112,7 @@ bands, you would need something like
ArHosekSkyModelState * skymodel_state[num_channels];
-You then have to allocate and initialise these states. In the following code
+You then have to allocate and initialize these states. In the following code
snippet, we assume that 'albedo' is defined as
double albedo[num_channels];
@@ -228,7 +228,7 @@ actually not altered at all in this release. All we did was to add some support
functionality for doing this more easily with the existing data and functions,
and to add some explanations.
-Just use 'arhosekskymodelstate_alienworld_alloc_init()' to initialise the sky
+Just use 'arhosekskymodelstate_alienworld_alloc_init()' to initialize the sky
model states (you will have to provide values for star temperature and solar
intensity compared to the terrestrial sun), and do everything else as you
did before.
@@ -351,7 +351,7 @@ typedef struct SKY_ArHosekSkyModelState {
arhosekskymodelstate_alloc_init() function
------------------------------------------
- Initialises an ArHosekSkyModelState struct for a terrestrial setting.
+ Initializes an #ArHosekSkyModelState struct for a terrestrial setting.
---------------------------------------------------------------------------- */
@@ -364,7 +364,7 @@ SKY_ArHosekSkyModelState *SKY_arhosekskymodelstate_alloc_init(const double solar
arhosekskymodelstate_alienworld_alloc_init() function
-----------------------------------------------------
- Initialises an ArHosekSkyModelState struct for an "alien world" setting
+ Initializes an ArHosekSkyModelState struct for an "alien world" setting
with a sun of a surface temperature given in 'kelvin'. The parameter
'solar_intensity' controls the overall brightness of the sky, relative
to the solar irradiance on Earth. A value of 1.0 yields a sky dome that
diff --git a/intern/sky/source/sky_model.cpp b/intern/sky/source/sky_model.cpp
index 64cf14ec030..e835e04d164 100644
--- a/intern/sky/source/sky_model.cpp
+++ b/intern/sky/source/sky_model.cpp
@@ -178,8 +178,9 @@ static void ArHosekSkyModel_CookConfiguration(ArHosekSkyModel_Dataset dataset,
pow(solar_elevation, 5.0) * elev_matrix[i + 45]);
}
- if (int_turbidity == 10)
+ if (int_turbidity == 10) {
return;
+ }
// alb 0 high turb
elev_matrix = dataset + (9 * 6 * (int_turbidity));
@@ -243,8 +244,9 @@ static double ArHosekSkyModel_CookRadianceConfiguration(ArHosekSkyModel_Radiance
10.0 * pow(1.0 - solar_elevation, 2.0) * pow(solar_elevation, 3.0) * elev_matrix[3] +
5.0 * (1.0 - solar_elevation) * pow(solar_elevation, 4.0) * elev_matrix[4] +
pow(solar_elevation, 5.0) * elev_matrix[5]);
- if (int_turbidity == 10)
+ if (int_turbidity == 10) {
return res;
+ }
// alb 0 high turb
elev_matrix = dataset + (6 * (int_turbidity));
@@ -298,16 +300,18 @@ double SKY_arhosekskymodel_radiance(SKY_ArHosekSkyModelState *state,
{
int low_wl = (int)((wavelength - 320.0) / 40.0);
- if (low_wl < 0 || low_wl >= 11)
+ if (low_wl < 0 || low_wl >= 11) {
return 0.0;
+ }
double interp = fmod((wavelength - 320.0) / 40.0, 1.0);
double val_low = ArHosekSkyModel_GetRadianceInternal(state->configs[low_wl], theta, gamma) *
state->radiances[low_wl] * state->emission_correction_factor_sky[low_wl];
- if (interp < 1e-6)
+ if (interp < 1e-6) {
return val_low;
+ }
double result = (1.0 - interp) * val_low;
diff --git a/release/datafiles/locale b/release/datafiles/locale
-Subproject 4af22e0492f401c609a0203cad1a9bc7fa00b86
+Subproject a7bbfac76c00edd0fb79a4766b7ac7c5dcbcac5
diff --git a/release/scripts/addons b/release/scripts/addons
-Subproject 25b00a0a52c81408b9dc15ea320a79ee956b3c0
+Subproject 82ed41ec632483fa9260d90dae7afdf3192c509
diff --git a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py
index aa80611ac6b..0ec3a322173 100644
--- a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py
+++ b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py
@@ -72,7 +72,7 @@ class SpellChecker:
"wasn", # wasn't
# Merged words
- "antialiasing",
+ "antialiasing", "antialias",
"arcsine", "arccosine", "arctangent",
"autoclip",
"autocomplete",
@@ -241,7 +241,7 @@ class SpellChecker:
"unsets",
"unshadowed",
"unspill",
- "unstitchable",
+ "unstitchable", "unstitch",
"unsubdivided", "unsubdivide",
"untrusted",
"vectorscope",
@@ -421,6 +421,7 @@ class SpellChecker:
"searchable",
"spacebar",
"subtractive",
+ "superellipse",
"tooltip", "tooltips",
"trackpad",
"tuple",
@@ -618,6 +619,7 @@ class SpellChecker:
"musgrave",
"nayar",
"netravali",
+ "nishita",
"ogawa",
"oren",
"peucker", # Ramer-Douglas-Peucker
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index a2bb19b1323..3ef65e3ab01 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -1929,9 +1929,8 @@ def km_file_browser_main(params):
("file.execute", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'},
{"properties": [("need_active", True)]}),
("file.refresh", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
- ("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK'},
+ ("file.select", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("open", False), ("deselect_all", not params.legacy)]}),
- ("file.select", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
{"properties": [("extend", True), ("open", False)]}),
("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
@@ -3367,16 +3366,14 @@ def km_grease_pencil_stroke_paint_fill(params):
# Fill
("gpencil.fill", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("on_back", False)]}),
- ("gpencil.fill", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
- {"properties": [("on_back", True)]}),
+ ("gpencil.fill", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties": [("on_back", False)]}),
# If press alternate key, the brush now it's for drawing areas
- ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
- {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True)]}),
+ ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True), ("disable_stabilizer", True)]}),
# If press alternative key, the brush now it's for drawing lines
- ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
- {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True), ("disable_fill", True)]}),
- # Lasso select
- ("gpencil.select_lasso", {"type": params.action_tweak, "value": 'ANY', "ctrl": True, "alt": True}, None),
+ ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True, "shift": True},
+ {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True), ("disable_stabilizer", True), ("disable_fill", True)]}),
])
return keymap
@@ -4535,6 +4532,8 @@ def km_mesh(params):
("mesh.dissolve_mode", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None),
("mesh.knife_tool", {"type": 'K', "value": 'PRESS'},
{"properties": [("use_occlude_geometry", True), ("only_selected", False)]}),
+ ("mesh.knife_tool", {"type": 'K', "value": 'PRESS', "shift": True},
+ {"properties": [("use_occlude_geometry", False), ("only_selected", True)]}),
("object.vertex_parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, None),
# Menus.
op_menu("VIEW3D_MT_edit_mesh_faces", {"type": 'F', "value": 'PRESS', "ctrl": True}),
@@ -4570,8 +4569,6 @@ def km_mesh(params):
("mesh.faces_select_linked_flat", {"type": 'F', "value": 'PRESS', "shift": True, "ctrl": True, "alt": True}, None),
("mesh.spin", {"type": 'R', "value": 'PRESS', "alt": True}, None),
("mesh.beautify_fill", {"type": 'F', "value": 'PRESS', "shift": True, "alt": True}, None),
- ("mesh.knife_tool", {"type": 'K', "value": 'PRESS', "shift": True},
- {"properties": [("use_occlude_geometry", False), ("only_selected", True)]}),
*_template_items_object_subdivision_set(),
])
@@ -6290,10 +6287,10 @@ def km_3d_view_tool_sculpt_box_mask(params):
"3D View Tool: Sculpt, Box Mask",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
- ("view3d.select_box", {"type": params.tool_tweak, "value": 'ANY'},
- {"properties": [("mode", 'ADD')]}),
- ("view3d.select_box", {"type": params.tool_tweak, "value": 'ANY', "ctrl": True},
- {"properties": [("mode", 'SUB')]}),
+ ("paint.mask_box_gesture", {"type": params.tool_tweak, "value": 'ANY'},
+ {"properties": [("value", 1.0)]}),
+ ("paint.mask_box_gesture", {"type": params.tool_tweak, "value": 'ANY', "ctrl": True},
+ {"properties": [("value", 0.0)]}),
]},
)
@@ -6387,12 +6384,12 @@ def km_3d_view_tool_paint_gpencil_line(params):
"3D View Tool: Paint Gpencil, Line",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
- ("gpencil.primitive", {"type": params.tool_tweak, "value": 'ANY'},
- {"properties": [("type", 'LINE'), ("wait_for_input", False)]}),
- ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
- {"properties": [("type", 'LINE'), ("wait_for_input", False)]}),
- ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
- {"properties": [("type", 'LINE'), ("wait_for_input", False)]}),
+ ("gpencil.primitive_line", {"type": params.tool_tweak, "value": 'ANY'},
+ {"properties": [("wait_for_input", False)]}),
+ ("gpencil.primitive_line", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties": [("wait_for_input", False)]}),
+ ("gpencil.primitive_line", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties": [("wait_for_input", False)]}),
# Lasso select
("gpencil.select_lasso", {"type": params.action_tweak, "value": 'ANY', "ctrl": True, "alt": True}, None),
]},
@@ -6403,10 +6400,10 @@ def km_3d_view_tool_paint_gpencil_polyline(params):
"3D View Tool: Paint Gpencil, Polyline",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
- ("gpencil.primitive", {"type": params.tool_tweak, "value": 'ANY'},
- {"properties": [("type", 'POLYLINE'), ("wait_for_input", False)]}),
- ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
- {"properties": [("type", 'POLYLINE'), ("wait_for_input", False)]}),
+ ("gpencil.primitive_polyline", {"type": params.tool_tweak, "value": 'ANY'},
+ {"properties": [("wait_for_input", False)]}),
+ ("gpencil.primitive_polyline", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties": [("wait_for_input", False)]}),
# Lasso select
("gpencil.select_lasso", {"type": params.action_tweak, "value": 'ANY', "ctrl": True, "alt": True}, None),
]},
@@ -6417,12 +6414,12 @@ def km_3d_view_tool_paint_gpencil_box(params):
"3D View Tool: Paint Gpencil, Box",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
- ("gpencil.primitive", {"type": params.tool_tweak, "value": 'ANY'},
- {"properties": [("type", 'BOX'), ("wait_for_input", False)]}),
- ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
- {"properties": [("type", 'BOX'), ("wait_for_input", False)]}),
- ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
- {"properties": [("type", 'BOX'), ("wait_for_input", False)]}),
+ ("gpencil.primitive_box", {"type": params.tool_tweak, "value": 'ANY'},
+ {"properties": [("wait_for_input", False)]}),
+ ("gpencil.primitive_box", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties": [("wait_for_input", False)]}),
+ ("gpencil.primitive_box", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties": [("wait_for_input", False)]}),
# Lasso select
("gpencil.select_lasso", {"type": params.action_tweak, "value": 'ANY', "ctrl": True, "alt": True}, None),
]},
@@ -6434,12 +6431,12 @@ def km_3d_view_tool_paint_gpencil_circle(params):
"3D View Tool: Paint Gpencil, Circle",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
- ("gpencil.primitive", {"type": params.tool_tweak, "value": 'ANY'},
- {"properties": [("type", 'CIRCLE'), ("wait_for_input", False)]}),
- ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
- {"properties": [("type", 'CIRCLE'), ("wait_for_input", False)]}),
- ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
- {"properties": [("type", 'CIRCLE'), ("wait_for_input", False)]}),
+ ("gpencil.primitive_circle", {"type": params.tool_tweak, "value": 'ANY'},
+ {"properties": [("wait_for_input", False)]}),
+ ("gpencil.primitive_circle", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties": [("wait_for_input", False)]}),
+ ("gpencil.primitive_circle", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties": [("wait_for_input", False)]}),
# Lasso select
("gpencil.select_lasso", {"type": params.action_tweak, "value": 'ANY', "ctrl": True, "alt": True}, None),
]},
@@ -6451,12 +6448,12 @@ def km_3d_view_tool_paint_gpencil_arc(params):
"3D View Tool: Paint Gpencil, Arc",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
- ("gpencil.primitive", {"type": params.tool_tweak, "value": 'ANY'},
- {"properties": [("type", 'ARC'), ("wait_for_input", False)]}),
- ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ ("gpencil.primitive_curve", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("type", 'ARC'), ("wait_for_input", False)]}),
- ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
+ ("gpencil.primitive_curve", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
{"properties": [("type", 'ARC'), ("wait_for_input", False)]}),
+ ("gpencil.primitive_curve", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties": [("type",'ARC'), ("wait_for_input", False)]}),
# Lasso select
("gpencil.select_lasso", {"type": params.action_tweak, "value": 'ANY', "ctrl": True, "alt": True}, None),
]},
@@ -6468,7 +6465,7 @@ def km_3d_view_tool_paint_gpencil_curve(params):
"3D View Tool: Paint Gpencil, Curve",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
- ("gpencil.primitive", {"type": params.tool_tweak, "value": 'ANY'},
+ ("gpencil.primitive_curve", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("type", 'CURVE'), ("wait_for_input", False)]}),
# Lasso select
("gpencil.select_lasso", {"type": params.action_tweak, "value": 'ANY', "ctrl": True, "alt": True}, None),
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index eedf07935c8..04721a1704a 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -2465,16 +2465,14 @@ def km_grease_pencil_stroke_paint_fill(params):
# Fill
("gpencil.fill", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("on_back", False)]}),
- ("gpencil.fill", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
- {"properties": [("on_back", True)]}),
+ ("gpencil.fill", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+ {"properties": [("on_back", False)]}),
# If press alternate key, the brush now it's for drawing areas
- ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
- {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True)]}),
+ ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True), ("disable_stabilizer", True)]}),
# If press alternative key, the brush now it's for drawing lines
("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True, "shift": True},
- {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True), ("disable_fill", True)]}),
- # Lasso select
- ("gpencil.select_lasso", {"type": params.action_tweak, "value": 'ANY', "ctrl": True, "alt": True}, None),
+ {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True), ("disable_stabilizer", True), ("disable_fill", True)]}),
])
return keymap
diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py
index 2befb7c73e2..7af5cd5ee5f 100644
--- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py
+++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py
@@ -613,7 +613,7 @@ class LightMapPack(Operator):
# Image & UVs...
PREF_PACK_IN_ONE: BoolProperty(
- name="Share Tex Space",
+ name="Share Texture Space",
description=(
"Objects Share texture space, map all objects "
"into 1 uvmap"
diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py
index f5177b81c95..a42995714b6 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -1031,7 +1031,7 @@ class ConstraintButtonsSubPanel(Panel):
col = layout.column(align=True)
col.prop(con, "map_to_z_from", expand=False, text="Z Source Axis")
col.prop(con, "to_min_z" + ext, text="Min")
- col.prop(con, "to_max_z" + ext, text="Max")
+ col.prop(con, "to_max_z" + ext, text="Max")
layout.prop(con, "mix_mode" + ext, text="Mix")
@@ -1398,7 +1398,7 @@ class BONE_PT_bTransformConstraint_from(BoneConstraintPanel, ConstraintButtonsSu
def draw(self, context):
self.draw_transform_from(context)
-
+
class OBJECT_PT_bTransformConstraint_destination(ObjectConstraintPanel, ConstraintButtonsSubPanel):
bl_parent_id = "OBJECT_PT_bTransformConstraint"
bl_label = "Map To"
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 6dde1e715bb..397ce5d0324 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -646,6 +646,8 @@ def brush_settings(layout, context, brush, popover=False):
layout.prop(brush, "pose_smooth_iterations")
if brush.pose_deform_type == 'ROTATE_TWIST' and brush.pose_origin_type in {'TOPOLOGY', 'FACE_SETS'}:
layout.prop(brush, "pose_ik_segments")
+ if brush.pose_deform_type == 'SCALE_TRANSLATE':
+ layout.prop(brush, "use_pose_lock_rotation")
layout.prop(brush, "use_pose_ik_anchored")
layout.prop(brush, "use_connected_only")
layout.prop(brush, "disconnected_distance_max")
@@ -654,14 +656,21 @@ def brush_settings(layout, context, brush, popover=False):
elif sculpt_tool == 'CLOTH':
layout.separator()
- layout.prop(brush, "cloth_sim_limit")
- layout.prop(brush, "cloth_sim_falloff")
+ layout.prop(brush, "cloth_simulation_area_type")
+ if brush.cloth_simulation_area_type == 'LOCAL':
+ layout.prop(brush, "cloth_sim_limit")
+ layout.prop(brush, "cloth_sim_falloff")
+ layout.prop(brush, "use_cloth_pin_simulation_boundary")
+
layout.separator()
layout.prop(brush, "cloth_deform_type")
layout.prop(brush, "cloth_force_falloff_type")
layout.separator()
layout.prop(brush, "cloth_mass")
layout.prop(brush, "cloth_damping")
+ layout.prop(brush, "cloth_constraint_softbody_strength")
+ layout.separator()
+ layout.prop(brush, "use_cloth_collision")
layout.separator()
elif sculpt_tool == 'SCRAPE':
@@ -710,6 +719,10 @@ def brush_settings(layout, context, brush, popover=False):
col = layout.column()
col.prop(brush, "smear_deform_type")
+ elif sculpt_tool == 'BOUNDARY':
+ col = layout.column()
+ col.prop(brush, "boundary_deform_type")
+
elif sculpt_tool == 'TOPOLOGY':
col = layout.column()
col.prop(brush, "slide_deform_type")
@@ -1096,6 +1109,45 @@ def brush_basic_texpaint_settings(layout, context, brush, *, compact=False):
header=True
)
+def brush_basic__draw_color_selector(context, layout, brush, gp_settings, props):
+ tool_settings = context.scene.tool_settings
+ settings = tool_settings.gpencil_paint
+ ma = gp_settings.material
+
+ row = layout.row(align=True)
+ if not gp_settings.use_material_pin:
+ ma = context.object.active_material
+ icon_id = 0
+ if ma:
+ icon_id = ma.id_data.preview.icon_id
+ txt_ma = ma.name
+ maxw = 25
+ if len(txt_ma) > maxw:
+ txt_ma = txt_ma[:maxw - 5] + '..' + txt_ma[-3:]
+ else:
+ txt_ma = ""
+
+ sub = row.row()
+ sub.ui_units_x = 8
+ sub.popover(
+ panel="TOPBAR_PT_gpencil_materials",
+ text=txt_ma,
+ icon_value=icon_id,
+ )
+
+ row.prop(gp_settings, "use_material_pin", text="")
+
+ if brush.gpencil_tool in {'DRAW', 'FILL'}:
+ row.separator(factor=1.0)
+ row.prop_enum(settings, "color_mode", 'MATERIAL', text="", icon='MATERIAL')
+ row.prop_enum(settings, "color_mode", 'VERTEXCOLOR', text="", icon='VPAINT_HLT')
+ sub_row = row.row(align=True)
+ sub_row.enabled = settings.color_mode == 'VERTEXCOLOR'
+ sub_row.prop_with_popover(brush, "color", text="", panel="TOPBAR_PT_gpencil_vertexcolor")
+
+ if props:
+ row = layout.row(align=True)
+ row.prop(props, "subdivision")
def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False):
tool_settings = context.tool_settings
@@ -1129,6 +1181,8 @@ def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False)
# FIXME: tools must use their own UI drawing!
elif brush.gpencil_tool == 'FILL':
row = layout.row(align=True)
+ row.prop(gp_settings, "fill_direction", text="", expand=True)
+ row = layout.row(align=True)
row.prop(gp_settings, "fill_leak", text="Leak Size")
row = layout.row(align=True)
row.prop(brush, "size", text="Thickness")
diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
index b03f80bd600..a55bd89ca18 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
@@ -23,10 +23,10 @@ from bpy.types import (
)
-def rigid_body_warning(layout):
+def rigid_body_warning(layout, text):
row = layout.row(align=True)
row.alignment = 'RIGHT'
- row.label(text="Object does not have a Rigid Body")
+ row.label(text=text, icon='ERROR')
class PHYSICS_PT_rigidbody_panel:
@@ -49,13 +49,24 @@ class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel):
layout.use_property_split = True
ob = context.object
+ parent = ob.parent
rbo = ob.rigid_body
if rbo is None:
- rigid_body_warning(layout)
+ rigid_body_warning(layout, "Object does not have a Rigid Body")
return
- layout.prop(rbo, "type", text="Type")
+ if parent is not None and parent.rigid_body is not None:
+ if parent.rigid_body.collision_shape == 'COMPOUND':
+ row = layout.row(align=True)
+ row.alignment = 'RIGHT'
+ row.label(text="This object is part of a compound shape", icon='INFO')
+ else:
+ rigid_body_warning(layout, "Rigid Body can't be child of a non compound Rigid Body")
+ return
+
+ if parent is None or parent.rigid_body is None:
+ layout.prop(rbo, "type", text="Type")
class PHYSICS_PT_rigid_body_settings(PHYSICS_PT_rigidbody_panel, Panel):
@@ -66,6 +77,8 @@ class PHYSICS_PT_rigid_body_settings(PHYSICS_PT_rigidbody_panel, Panel):
@classmethod
def poll(cls, context):
obj = context.object
+ if obj.parent is not None and obj.parent.rigid_body is not None:
+ return False
return (obj and obj.rigid_body and (context.engine in cls.COMPAT_ENGINES))
def draw(self, context):
@@ -76,7 +89,7 @@ class PHYSICS_PT_rigid_body_settings(PHYSICS_PT_rigidbody_panel, Panel):
rbo = ob.rigid_body
if rbo is None:
- rigid_body_warning(layout)
+ rigid_body_warning(layout, "Object does not have a Rigid Body")
return
col = layout.column()
@@ -96,17 +109,32 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
@classmethod
def poll(cls, context):
obj = context.object
+ if obj.parent is not None and obj.parent.rigid_body is not None and not obj.parent.rigid_body.collision_shape == 'COMPOUND':
+ return False
return (obj and obj.rigid_body and (context.engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
ob = context.object
+ parent = ob.parent
rbo = ob.rigid_body
layout.use_property_split = True
layout.prop(rbo, "collision_shape", text="Shape")
+ if rbo.collision_shape == 'COMPOUND':
+ if parent is not None and parent.rigid_body is not None and parent.rigid_body.collision_shape == 'COMPOUND':
+ rigid_body_warning(layout, "Sub compound shapes are not allowed")
+ else:
+ found = False
+ for child in ob.children:
+ if child.rigid_body is not None:
+ found = True
+ break
+ if not found:
+ rigid_body_warning(layout, "There are no child rigid bodies")
+
if rbo.collision_shape in {'MESH', 'CONVEX_HULL'}:
layout.prop(rbo, "mesh_source", text="Source")
@@ -123,6 +151,8 @@ class PHYSICS_PT_rigid_body_collisions_surface(PHYSICS_PT_rigidbody_panel, Panel
@classmethod
def poll(cls, context):
obj = context.object
+ if obj.parent is not None and obj.parent.rigid_body is not None:
+ return False
return (obj and obj.rigid_body and (context.engine in cls.COMPAT_ENGINES))
def draw(self, context):
@@ -149,6 +179,8 @@ class PHYSICS_PT_rigid_body_collisions_sensitivity(PHYSICS_PT_rigidbody_panel, P
@classmethod
def poll(cls, context):
obj = context.object
+ if obj.parent is not None and obj.parent.rigid_body is not None and not obj.parent.rigid_body.collision_shape == 'COMPOUND':
+ return False
return (obj and obj.rigid_body and (context.engine in cls.COMPAT_ENGINES))
def draw(self, context):
@@ -180,6 +212,8 @@ class PHYSICS_PT_rigid_body_collisions_collections(PHYSICS_PT_rigidbody_panel, P
@classmethod
def poll(cls, context):
obj = context.object
+ if obj.parent is not None and obj.parent.rigid_body is not None:
+ return False
return (obj and obj.rigid_body and (context.engine in cls.COMPAT_ENGINES))
def draw(self, context):
@@ -200,6 +234,8 @@ class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel):
@classmethod
def poll(cls, context):
obj = context.object
+ if obj.parent is not None and obj.parent.rigid_body is not None:
+ return False
return (obj and obj.rigid_body and obj.rigid_body.type == 'ACTIVE'
and (context.engine in cls.COMPAT_ENGINES))
diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py
index c251d55714f..078b1c9ff38 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -293,7 +293,7 @@ class GRAPH_MT_key(Menu):
# Using the modal operation doesn't make sense for this variant
# as we do not have a modal mode for it, so just execute it.
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("graph.decimate", text="Decimate (Allowed Change)").mode = 'ERROR'
layout.operator_context = operator_context
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index b5926692324..faf4036f9b3 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -275,7 +275,7 @@ class NODE_MT_select(Menu):
layout.separator()
layout.operator("node.select_all").action = 'TOGGLE'
- layout.operator("node.select_all", text="Inverse").action = 'INVERT'
+ layout.operator("node.select_all", text="Invert").action = 'INVERT'
layout.operator("node.select_linked_from")
layout.operator("node.select_linked_to")
@@ -433,7 +433,7 @@ class NODE_MT_context_menu(Menu):
layout.operator("node.delete")
layout.operator("node.clipboard_copy", text="Copy")
layout.operator("node.clipboard_paste", text="Paste")
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("node.delete_reconnect")
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 8dfa182f52d..9f251a9abad 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -796,7 +796,7 @@ class SEQUENCER_MT_context_menu(Menu):
props = layout.operator("wm.call_panel", text="Rename...")
props.name = "TOPBAR_PT_name"
props.keep_open = False
- layout.operator("sequencer.delete", text="Delete...")
+ layout.operator("sequencer.delete", text="Delete")
layout.separator()
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 83b3a27154a..ae144d9e8d0 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1226,22 +1226,32 @@ class _defs_sculpt:
@ToolDef.from_fn
def mask_border():
+ def draw_settings(_context, layout, tool):
+ props = tool.operator_properties("paint.mask_box_gesture")
+ layout.prop(props, "use_front_faces_only", expand=False)
+
return dict(
idname="builtin.box_mask",
label="Box Mask",
icon="ops.sculpt.border_mask",
widget=None,
keymap=(),
+ draw_settings=draw_settings,
)
@ToolDef.from_fn
def mask_lasso():
+ def draw_settings(_context, layout, tool):
+ props = tool.operator_properties("paint.mask_lasso_gesture")
+ layout.prop(props, "use_front_faces_only", expand=False)
+
return dict(
idname="builtin.lasso_mask",
label="Lasso Mask",
icon="ops.sculpt.lasso_mask",
widget=None,
keymap=(),
+ draw_settings=draw_settings,
)
@ToolDef.from_fn
@@ -1257,6 +1267,8 @@ class _defs_sculpt:
layout.prop(props, "surface_smooth_current_vertex", expand=False)
elif props.type == 'SHARPEN':
layout.prop(props, "sharpen_smooth_ratio", expand=False)
+ layout.prop(props, "sharpen_intensify_detail_strength", expand=False)
+ layout.prop(props, "sharpen_curvature_smooth_iterations", expand=False)
return dict(
idname="builtin.mesh_filter",
@@ -1276,6 +1288,7 @@ class _defs_sculpt:
layout.prop(props, "cloth_mass")
layout.prop(props, "cloth_damping")
layout.prop(props, "use_face_sets")
+ layout.prop(props, "use_collisions")
return dict(
idname="builtin.cloth_filter",
@@ -1658,6 +1671,29 @@ class _defs_image_uv_sculpt:
class _defs_gpencil_paint:
@staticmethod
+ def gpencil_primitive_toolbar(context, layout, tool, props):
+ paint = context.tool_settings.gpencil_paint
+ brush = paint.brush
+
+ if brush is None:
+ return False
+
+ gp_settings = brush.gpencil_settings
+
+ row = layout.row(align=True)
+ tool_settings = context.scene.tool_settings
+ settings = tool_settings.gpencil_paint
+ row.template_ID_preview(settings, "brush", rows=3, cols=8, hide_buttons=True)
+
+ from bl_ui.properties_paint_common import (
+ brush_basic_gpencil_paint_settings,
+ brush_basic__draw_color_selector,
+ )
+
+ brush_basic__draw_color_selector(context, layout, brush, gp_settings, props)
+ brush_basic_gpencil_paint_settings(layout, context, brush, compact=True)
+
+ @staticmethod
def generate_from_brushes(context):
return generate_from_enum_ex(
context,
@@ -1684,6 +1720,10 @@ class _defs_gpencil_paint:
@ToolDef.from_fn
def line():
+ def draw_settings(context, layout, tool):
+ props = tool.operator_properties("gpencil.primitive_line")
+ _defs_gpencil_paint.gpencil_primitive_toolbar(context, layout, tool, props)
+
return dict(
idname="builtin.line",
label="Line",
@@ -1691,10 +1731,15 @@ class _defs_gpencil_paint:
cursor='CROSSHAIR',
widget=None,
keymap=(),
+ draw_settings=draw_settings,
)
@ToolDef.from_fn
def polyline():
+ def draw_settings(context, layout, tool):
+ props = tool.operator_properties("gpencil.primitive_polyline")
+ _defs_gpencil_paint.gpencil_primitive_toolbar(context, layout, tool, props)
+
return dict(
idname="builtin.polyline",
label="Polyline",
@@ -1702,10 +1747,15 @@ class _defs_gpencil_paint:
cursor='CROSSHAIR',
widget=None,
keymap=(),
+ draw_settings=draw_settings,
)
@ToolDef.from_fn
def box():
+ def draw_settings(context, layout, tool):
+ props = tool.operator_properties("gpencil.primitive_box")
+ _defs_gpencil_paint.gpencil_primitive_toolbar(context, layout, tool, props)
+
return dict(
idname="builtin.box",
label="Box",
@@ -1713,10 +1763,15 @@ class _defs_gpencil_paint:
cursor='CROSSHAIR',
widget=None,
keymap=(),
+ draw_settings=draw_settings,
)
@ToolDef.from_fn
def circle():
+ def draw_settings(context, layout, tool):
+ props = tool.operator_properties("gpencil.primitive_circle")
+ _defs_gpencil_paint.gpencil_primitive_toolbar(context, layout, tool, props)
+
return dict(
idname="builtin.circle",
label="Circle",
@@ -1724,10 +1779,15 @@ class _defs_gpencil_paint:
cursor='CROSSHAIR',
widget=None,
keymap=(),
+ draw_settings=draw_settings,
)
@ToolDef.from_fn
def arc():
+ def draw_settings(context, layout, tool):
+ props = tool.operator_properties("gpencil.primitive_curve")
+ _defs_gpencil_paint.gpencil_primitive_toolbar(context, layout, tool, props)
+
return dict(
idname="builtin.arc",
label="Arc",
@@ -1735,10 +1795,15 @@ class _defs_gpencil_paint:
cursor='CROSSHAIR',
widget=None,
keymap=(),
+ draw_settings=draw_settings,
)
@ToolDef.from_fn
def curve():
+ def draw_settings(context, layout, tool):
+ props = tool.operator_properties("gpencil.primitive_curve")
+ _defs_gpencil_paint.gpencil_primitive_toolbar(context, layout, tool, props)
+
return dict(
idname="builtin.curve",
label="Curve",
@@ -1746,6 +1811,7 @@ class _defs_gpencil_paint:
cursor='CROSSHAIR',
widget=None,
keymap=(),
+ draw_settings=draw_settings,
)
@ToolDef.from_fn
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 0a1be2dc698..c251b4bfcac 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -385,19 +385,7 @@ class _draw_tool_settings_context_mode:
if tool is None:
return False
- # is_paint = True
- # FIXME: tools must use their own UI drawing!
- if tool.idname in {
- "builtin.line",
- "builtin.box",
- "builtin.circle",
- "builtin.arc",
- "builtin.curve",
- "builtin.polyline",
- }:
- # is_paint = False
- pass
- elif tool.idname == "builtin.cutter":
+ if tool.idname == "builtin.cutter":
row = layout.row(align=True)
row.prop(context.tool_settings.gpencil_sculpt, "intersection_threshold")
return False
@@ -411,47 +399,16 @@ class _draw_tool_settings_context_mode:
gp_settings = brush.gpencil_settings
- def draw_color_selector():
- ma = gp_settings.material
- row = layout.row(align=True)
- if not gp_settings.use_material_pin:
- ma = context.object.active_material
- icon_id = 0
- if ma:
- icon_id = ma.id_data.preview.icon_id
- txt_ma = ma.name
- maxw = 25
- if len(txt_ma) > maxw:
- txt_ma = txt_ma[:maxw - 5] + '..' + txt_ma[-3:]
- else:
- txt_ma = ""
-
- sub = row.row()
- sub.ui_units_x = 8
- sub.popover(
- panel="TOPBAR_PT_gpencil_materials",
- text=txt_ma,
- icon_value=icon_id,
- )
-
- row.prop(gp_settings, "use_material_pin", text="")
-
- if brush.gpencil_tool in {'DRAW', 'FILL'}:
- row.separator(factor=1.0)
- subrow = row.row(align=True)
- row.prop_enum(settings, "color_mode", 'MATERIAL', text="", icon='MATERIAL')
- row.prop_enum(settings, "color_mode", 'VERTEXCOLOR', text="", icon='VPAINT_HLT')
- sub_row = row.row(align=True)
- sub_row.enabled = settings.color_mode == 'VERTEXCOLOR'
- sub_row.prop_with_popover(brush, "color", text="", panel="TOPBAR_PT_gpencil_vertexcolor")
-
row = layout.row(align=True)
tool_settings = context.scene.tool_settings
settings = tool_settings.gpencil_paint
row.template_ID_preview(settings, "brush", rows=3, cols=8, hide_buttons=True)
if context.object and brush.gpencil_tool in {'FILL', 'DRAW'}:
- draw_color_selector()
+ from bl_ui.properties_paint_common import (
+ brush_basic__draw_color_selector,
+ )
+ brush_basic__draw_color_selector(context, layout, brush, gp_settings, None)
if context.object and brush.gpencil_tool == 'TINT':
row.separator(factor=0.4)
@@ -986,7 +943,7 @@ class VIEW3D_MT_transform_base(Menu):
if context.mode != 'OBJECT':
layout.operator("transform.vertex_warp", text="Warp")
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("transform.vertex_random", text="Randomize").offset = 0.1
layout.operator_context = 'INVOKE_REGION_WIN'
@@ -1551,7 +1508,7 @@ class VIEW3D_MT_edit_mesh_select_by_trait(Menu):
layout.separator()
- layout.operator("mesh.select_ungrouped", text="Ungrouped Verts")
+ layout.operator("mesh.select_ungrouped", text="Ungrouped Vertices")
class VIEW3D_MT_edit_mesh_select_more_less(Menu):
@@ -1813,7 +1770,7 @@ class VIEW3D_MT_select_edit_lattice(Menu):
layout.separator()
- layout.operator("lattice.select_ungrouped", text="Ungrouped Verts")
+ layout.operator("lattice.select_ungrouped", text="Ungrouped Vertices")
class VIEW3D_MT_select_edit_armature(Menu):
@@ -1940,7 +1897,7 @@ class VIEW3D_MT_select_paint_mask_vertex(Menu):
layout.separator()
- layout.operator("paint.vert_select_ungrouped", text="Ungrouped Verts")
+ layout.operator("paint.vert_select_ungrouped", text="Ungrouped Vertices")
class VIEW3D_MT_angle_control(Menu):
@@ -2058,7 +2015,7 @@ class VIEW3D_MT_edit_metaball_context_menu(Menu):
layout.separator()
# Remove
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("mball.delete_metaelems", text="Delete")
@@ -2333,7 +2290,7 @@ class VIEW3D_MT_object(Menu):
layout.separator()
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("object.delete", text="Delete").use_global = False
layout.operator("object.delete", text="Delete Global").use_global = True
@@ -2597,7 +2554,7 @@ class VIEW3D_MT_object_context_menu(Menu):
layout.separator()
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("object.delete", text="Delete").use_global = False
@@ -2683,7 +2640,7 @@ class VIEW3D_MT_object_parent(Menu):
layout.separator()
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("object.parent_no_inverse_set")
layout.operator_context = operator_context_default
@@ -2774,7 +2731,7 @@ class VIEW3D_MT_make_single_user(Menu):
def draw(self, _context):
layout = self.layout
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'EXEC_REGION_WIN'
props = layout.operator("object.make_single_user", text="Object")
props.object = True
@@ -3688,7 +3645,7 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
row = layout.row()
if is_vert_mode:
- col = row.column()
+ col = row.column(align=True)
col.label(text="Vertex Context Menu", icon='VERTEXSEL')
col.separator()
@@ -3714,7 +3671,7 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
col.operator("transform.shrink_fatten", text="Shrink/Fatten")
col.operator("transform.shear", text="Shear")
col.operator("transform.vert_slide", text="Slide Vertices")
- col.operator_context = 'EXEC_DEFAULT'
+ col.operator_context = 'EXEC_REGION_WIN'
col.operator("transform.vertex_random", text="Randomize Vertices").offset = 0.1
col.operator("mesh.vertices_smooth", text="Smooth Vertices").factor = 0.5
col.operator_context = 'INVOKE_REGION_WIN'
@@ -3738,7 +3695,7 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
if is_edge_mode:
render = context.scene.render
- col = row.column()
+ col = row.column(align=True)
col.label(text="Edge Context Menu", icon='EDGESEL')
col.separator()
@@ -3806,7 +3763,7 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
col.operator("mesh.delete", text="Delete Edges").type = 'EDGE'
if is_face_mode:
- col = row.column()
+ col = row.column(align=True)
col.label(text="Face Context Menu", icon='FACESEL')
col.separator()
@@ -3941,7 +3898,7 @@ class VIEW3D_MT_edit_mesh_vertices(Menu):
layout.separator()
layout.operator("transform.vert_slide", text="Slide Vertices")
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("mesh.vertices_smooth", text="Smooth Vertices").factor = 0.5
layout.operator("mesh.vertices_smooth_laplacian", text="Smooth Vertices (Laplacian)")
layout.operator_context = 'INVOKE_REGION_WIN'
@@ -4149,7 +4106,7 @@ class VIEW3D_MT_edit_mesh_normals_select_strength(Menu):
class VIEW3D_MT_edit_mesh_normals_set_strength(Menu):
- bl_label = "Select by Face Strength"
+ bl_label = "Set Face Strength"
def draw(self, _context):
layout = self.layout
@@ -4195,7 +4152,7 @@ class VIEW3D_MT_edit_mesh_normals(Menu):
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("transform.rotate_normal", text="Rotate...")
layout.operator("mesh.point_normals", text="Point to Target...")
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("mesh.merge_normals", text="Merge")
layout.operator("mesh.split_normals", text="Split")
@@ -4211,8 +4168,8 @@ class VIEW3D_MT_edit_mesh_normals(Menu):
layout.separator()
- layout.menu("VIEW3D_MT_edit_mesh_normals_select_strength", text="Select by Face Strength")
- layout.menu("VIEW3D_MT_edit_mesh_normals_set_strength", text="Set Face Strength")
+ layout.menu("VIEW3D_MT_edit_mesh_normals_select_strength")
+ layout.menu("VIEW3D_MT_edit_mesh_normals_set_strength")
class VIEW3D_MT_edit_mesh_shading(Menu):
@@ -4662,7 +4619,7 @@ class VIEW3D_MT_edit_meta(Menu):
layout.menu("VIEW3D_MT_edit_meta_showhide")
- layout.operator_context = 'EXEC_DEFAULT'
+ layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("mball.delete_metaelems", text="Delete")
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 6e31808d27d..1b8869d0bc8 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1375,6 +1375,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_advanced(View3DPanel, Panel):
bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_settings'
bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
+ bl_ui_units_x = 12
@classmethod
def poll(cls, context):
@@ -1393,6 +1394,9 @@ class VIEW3D_PT_tools_grease_pencil_brush_advanced(View3DPanel, Panel):
col = layout.column(align=True)
if brush is not None:
+ col.prop(gp_settings, "brush_draw_mode")
+ col.separator()
+
if brush.gpencil_tool != 'FILL':
col.prop(gp_settings, "input_samples")
col.separator()
@@ -1421,11 +1425,22 @@ class VIEW3D_PT_tools_grease_pencil_brush_advanced(View3DPanel, Panel):
row = col.row(align=True)
row.prop(gp_settings, "fill_draw_mode", text="Boundary")
row.prop(gp_settings, "show_fill_boundary", text="", icon='GRID')
+
+ col.separator()
+ row = col.row(align=True)
+ row.prop(gp_settings, "fill_layer_mode", text="Layers")
+
col.separator()
col.prop(gp_settings, "fill_factor", text="Resolution")
if gp_settings.fill_draw_mode != 'STROKE':
- col.prop(gp_settings, "show_fill", text="Ignore Transparent Strokes")
- col.prop(gp_settings, "fill_threshold", text="Threshold")
+ col = layout.column(align=False, heading="Ignore Transparent")
+ col.use_property_decorate = False
+ row = col.row(align=True)
+ sub = row.row(align=True)
+ sub.prop(gp_settings, "show_fill", text="")
+ sub = sub.row(align=True)
+ sub.active = gp_settings.show_fill
+ sub.prop(gp_settings, "fill_threshold", text="")
class VIEW3D_PT_tools_grease_pencil_brush_stroke(Panel, View3DPanel):
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 7321f4f6345..f62c2ead144 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -500,6 +500,7 @@ simulation_node_categories = [
SimulationNodeCategory("SIM_EVENTS", "Events", items=[
NodeItem("SimulationNodeParticleBirthEvent"),
NodeItem("SimulationNodeParticleTimeStepEvent"),
+ NodeItem("SimulationNodeAgeReachedEvent"),
not_implemented_node("SimulationNodeParticleMeshCollisionEvent"),
]),
SimulationNodeCategory("SIM_FORCES", "Forces", items=[
@@ -508,6 +509,7 @@ simulation_node_categories = [
SimulationNodeCategory("SIM_EXECUTE", "Execute", items=[
NodeItem("SimulationNodeSetParticleAttribute"),
NodeItem("SimulationNodeExecuteCondition"),
+ NodeItem("SimulationNodeKillParticle"),
not_implemented_node("SimulationNodeMultiExecute"),
]),
SimulationNodeCategory("SIM_NOISE", "Noise", items=[
@@ -537,6 +539,7 @@ simulation_node_categories = [
NodeItem("FunctionNodeFloatCompare"),
not_implemented_node("FunctionNodeSwitch"),
NodeItem("FunctionNodeCombineStrings"),
+ NodeItem("FunctionNodeRandomFloat"),
]),
SimulationNodeCategory("SIM_GROUP", "Group", items=node_group_items),
SimulationNodeCategory("SIM_LAYOUT", "Layout", items=[
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index 1d0cb2f524c..9013836fd1e 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -21,8 +21,7 @@
* \ingroup blf
*/
-#ifndef __BLF_API_H__
-#define __BLF_API_H__
+#pragma once
#include "BLI_compiler_attrs.h"
#include "BLI_sys_types.h"
@@ -305,5 +304,3 @@ struct ResultBLF {
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLF_API_H__ */
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 2f7d5a60a6f..95b074fa2df 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -509,7 +509,7 @@ void BLF_color4fv(int fontid, const float rgba[4])
void BLF_color4f(int fontid, float r, float g, float b, float a)
{
- float rgba[4] = {r, g, b, a};
+ const float rgba[4] = {r, g, b, a};
BLF_color4fv(fontid, rgba);
}
@@ -523,7 +523,7 @@ void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha)
void BLF_color3f(int fontid, float r, float g, float b)
{
- float rgba[4] = {r, g, b, 1.0f};
+ const float rgba[4] = {r, g, b, 1.0f};
BLF_color4fv(fontid, rgba);
}
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h
index 4ae592d323f..ba0873f4fd4 100644
--- a/source/blender/blenfont/intern/blf_internal.h
+++ b/source/blender/blenfont/intern/blf_internal.h
@@ -21,8 +21,7 @@
* \ingroup blf
*/
-#ifndef __BLF_INTERNAL_H__
-#define __BLF_INTERNAL_H__
+#pragma once
struct FontBLF;
struct GlyphBLF;
@@ -151,5 +150,3 @@ extern FT_Error FT_New_Face__win32_compat(FT_Library library,
FT_Face *aface);
# endif
#endif
-
-#endif /* __BLF_INTERNAL_H__ */
diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h
index 34b674670fd..36bb8769306 100644
--- a/source/blender/blenfont/intern/blf_internal_types.h
+++ b/source/blender/blenfont/intern/blf_internal_types.h
@@ -21,8 +21,7 @@
* \ingroup blf
*/
-#ifndef __BLF_INTERNAL_TYPES_H__
-#define __BLF_INTERNAL_TYPES_H__
+#pragma once
#include "GPU_texture.h"
#include "GPU_vertex_buffer.h"
@@ -258,5 +257,3 @@ typedef struct DirBLF {
/* full path where search fonts. */
char *path;
} DirBLF;
-
-#endif /* __BLF_INTERNAL_TYPES_H__ */
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 9162ed56655..76c610fb5bd 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_DERIVEDMESH_H__
-#define __BKE_DERIVEDMESH_H__
+#pragma once
/** \file
* \ingroup bke
@@ -382,7 +381,6 @@ void DM_calc_loop_tangents(DerivedMesh *dm,
#ifndef NDEBUG
char *DM_debug_info(DerivedMesh *dm);
void DM_debug_print(DerivedMesh *dm);
-void DM_debug_print_cdlayers(CustomData *cdata);
bool DM_is_valid(DerivedMesh *dm);
#endif
@@ -390,5 +388,3 @@ bool DM_is_valid(DerivedMesh *dm);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_DERIVEDMESH_H__ */
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index b7904ce1879..e08604f02ad 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_ACTION_H__
-#define __BKE_ACTION_H__
+#pragma once
/** \file
* \ingroup bke
@@ -129,6 +128,8 @@ void BKE_pose_channel_free(struct bPoseChannel *pchan);
void BKE_pose_channel_free_ex(struct bPoseChannel *pchan, bool do_id_user);
void BKE_pose_channel_runtime_reset(struct bPoseChannel_Runtime *runtime);
+void BKE_pose_channel_runtime_reset_on_copy(struct bPoseChannel_Runtime *runtime);
+
void BKE_pose_channel_runtime_free(struct bPoseChannel_Runtime *runtime);
void BKE_pose_channel_free_bbone_cache(struct bPoseChannel_Runtime *runtime);
@@ -153,12 +154,15 @@ void BKE_pose_copy_data_ex(struct bPose **dst,
const bool copy_constraints);
void BKE_pose_copy_data(struct bPose **dst, const struct bPose *src, const bool copy_constraints);
void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from);
+void BKE_pose_channel_session_uuid_generate(struct bPoseChannel *pchan);
struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name);
struct bPoseChannel *BKE_pose_channel_active(struct Object *ob);
struct bPoseChannel *BKE_pose_channel_active_or_first_selected(struct Object *ob);
struct bPoseChannel *BKE_pose_channel_verify(struct bPose *pose, const char *name);
struct bPoseChannel *BKE_pose_channel_get_mirrored(const struct bPose *pose, const char *name);
+void BKE_pose_check_uuids_unique_and_report(const struct bPose *pose);
+
#ifndef NDEBUG
bool BKE_pose_channels_is_valid(const struct bPose *pose);
#endif
@@ -218,5 +222,3 @@ void BKE_pose_tag_recalc(struct Main *bmain, struct bPose *pose);
#ifdef __cplusplus
};
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_addon.h b/source/blender/blenkernel/BKE_addon.h
index 741be17bb25..73e3f6e41dc 100644
--- a/source/blender/blenkernel/BKE_addon.h
+++ b/source/blender/blenkernel/BKE_addon.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_ADDON_H__
-#define __BKE_ADDON_H__
+#pragma once
/** \file
* \ingroup bke
@@ -56,5 +55,3 @@ void BKE_addon_free(struct bAddon *addon);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_ADDON_H__ */
diff --git a/source/blender/blenkernel/BKE_anim_data.h b/source/blender/blenkernel/BKE_anim_data.h
index 48e95740b9d..189e45f4fe5 100644
--- a/source/blender/blenkernel/BKE_anim_data.h
+++ b/source/blender/blenkernel/BKE_anim_data.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_ANIM_DATA_H__
-#define __BKE_ANIM_DATA_H__
+#pragma once
/** \file
* \ingroup bke
@@ -98,5 +97,3 @@ void BKE_animdata_merge_copy(struct Main *bmain,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_ANIM_DATA_H__*/
diff --git a/source/blender/blenkernel/BKE_anim_path.h b/source/blender/blenkernel/BKE_anim_path.h
index 4de853303ad..ae2d13530ed 100644
--- a/source/blender/blenkernel/BKE_anim_path.h
+++ b/source/blender/blenkernel/BKE_anim_path.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_ANIM_PATH_H__
-#define __BKE_ANIM_PATH_H__
+#pragma once
/** \file
* \ingroup bke
@@ -47,5 +46,3 @@ bool where_on_path(const struct Object *ob,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_anim_visualization.h b/source/blender/blenkernel/BKE_anim_visualization.h
index 5dcbfa0919e..fb7875a112e 100644
--- a/source/blender/blenkernel/BKE_anim_visualization.h
+++ b/source/blender/blenkernel/BKE_anim_visualization.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_ANIM_VISUALIZATION_H__
-#define __BKE_ANIM_VISUALIZATION_H__
+#pragma once
/** \file
* \ingroup bke
@@ -52,5 +51,3 @@ struct bMotionPath *animviz_verify_motionpaths(struct ReportList *reports,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index ddfe6b61cfb..ef74bb61a7e 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_ANIMSYS_H__
-#define __BKE_ANIMSYS_H__
+#pragma once
/** \file
* \ingroup bke
@@ -148,17 +147,18 @@ bool BKE_animdata_fix_paths_remove(struct ID *id, const char *path);
/* -------------------------------------- */
+typedef struct AnimationBasePathChange {
+ struct AnimationBasePathChange *next, *prev;
+ const char *src_basepath;
+ const char *dst_basepath;
+} AnimationBasePathChange;
+
/* Move animation data from src to destination if it's paths are based on basepaths */
-void BKE_animdata_separate_by_basepath(struct Main *bmain,
+void BKE_animdata_transfer_by_basepath(struct Main *bmain,
struct ID *srcID,
struct ID *dstID,
struct ListBase *basepaths);
-/* Move F-Curves from src to destination if it's path is based on basepath */
-void action_move_fcurves_by_basepath(struct bAction *srcAct,
- struct bAction *dstAct,
- const char basepath[]);
-
char *BKE_animdata_driver_path_hack(struct bContext *C,
struct PointerRNA *ptr,
struct PropertyRNA *prop,
@@ -275,5 +275,3 @@ void BKE_animsys_update_driver_array(struct ID *id);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_ANIMSYS_H__*/
diff --git a/source/blender/blenkernel/BKE_appdir.h b/source/blender/blenkernel/BKE_appdir.h
index e49fc260810..b8a4497c7be 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_APPDIR_H__
-#define __BKE_APPDIR_H__
+#pragma once
/** \file
* \ingroup bli
@@ -101,5 +100,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_APPDIR_H__ */
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 6fb6675a05a..6d48397b1af 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_ARMATURE_H__
-#define __BKE_ARMATURE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -123,22 +122,24 @@ void get_objectspace_bone_matrix(struct Bone *bone,
float M_accumulatedMatrix[4][4],
int root,
int posed);
-void vec_roll_to_mat3(const float vec[3], const float roll, float mat[3][3]);
-void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat[3][3]);
+void vec_roll_to_mat3(const float vec[3], const float roll, float r_mat[3][3]);
+void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float r_mat[3][3]);
void mat3_to_vec_roll(const float mat[3][3], float r_vec[3], float *r_roll);
void mat3_vec_to_roll(const float mat[3][3], const float vec[3], float *r_roll);
/* Common Conversions Between Co-ordinate Spaces */
-void BKE_armature_mat_world_to_pose(struct Object *ob, float inmat[4][4], float outmat[4][4]);
+void BKE_armature_mat_world_to_pose(struct Object *ob,
+ const float inmat[4][4],
+ float outmat[4][4]);
void BKE_armature_loc_world_to_pose(struct Object *ob, const float inloc[3], float outloc[3]);
void BKE_armature_mat_pose_to_bone(struct bPoseChannel *pchan,
- float inmat[4][4],
+ const float inmat[4][4],
float outmat[4][4]);
void BKE_armature_loc_pose_to_bone(struct bPoseChannel *pchan,
const float inloc[3],
float outloc[3]);
void BKE_armature_mat_bone_to_pose(struct bPoseChannel *pchan,
- float inmat[4][4],
+ const float inmat[4][4],
float outmat[4][4]);
void BKE_armature_mat_pose_to_delta(float delta_mat[4][4],
float pose_mat[4][4],
@@ -147,13 +148,13 @@ void BKE_armature_mat_pose_to_delta(float delta_mat[4][4],
void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph,
struct Object *ob,
struct bPoseChannel *pchan,
- float inmat[4][4],
+ const float inmat[4][4],
float outmat[4][4]);
-void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[3][3], bool use_compat);
-void BKE_pchan_rot_to_mat3(const struct bPoseChannel *pchan, float mat[3][3]);
-void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[4][4], bool use_comat);
-void BKE_pchan_to_mat4(const struct bPoseChannel *pchan, float chan_mat[4][4]);
+void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, const float mat[3][3], bool use_compat);
+void BKE_pchan_rot_to_mat3(const struct bPoseChannel *pchan, float r_mat[3][3]);
+void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, const float mat[4][4], bool use_comat);
+void BKE_pchan_to_mat4(const struct bPoseChannel *pchan, float r_mat[4][4]);
void BKE_pchan_calc_mat(struct bPoseChannel *pchan);
/* Simple helper, computes the offset bone matrix. */
@@ -387,5 +388,3 @@ void BKE_armature_deform_coords_with_editmesh(const struct Object *ob_arm,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_autoexec.h b/source/blender/blenkernel/BKE_autoexec.h
index bb847d49a4b..84d83ae5d30 100644
--- a/source/blender/blenkernel/BKE_autoexec.h
+++ b/source/blender/blenkernel/BKE_autoexec.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_AUTOEXEC_H__
-#define __BKE_AUTOEXEC_H__
+#pragma once
/** \file
* \ingroup bke
@@ -29,5 +28,3 @@ bool BKE_autoexec_match(const char *path);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_AUTOEXEC_H__ */
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 3feba4b3a66..abc0ce1f092 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_BLENDER_H__
-#define __BKE_BLENDER_H__
+#pragma once
/** \file
* \ingroup bke
@@ -54,5 +53,3 @@ void BKE_blender_atexit(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_BLENDER_H__ */
diff --git a/source/blender/blenkernel/BKE_blender_copybuffer.h b/source/blender/blenkernel/BKE_blender_copybuffer.h
index ca20d3d9bba..1dd6d495276 100644
--- a/source/blender/blenkernel/BKE_blender_copybuffer.h
+++ b/source/blender/blenkernel/BKE_blender_copybuffer.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_BLENDER_COPYBUFFER_H__
-#define __BKE_BLENDER_COPYBUFFER_H__
+#pragma once
/** \file
* \ingroup bke
@@ -48,5 +47,3 @@ int BKE_copybuffer_paste(struct bContext *C,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_BLENDER_COPYBUFFER_H__ */
diff --git a/source/blender/blenkernel/BKE_blender_undo.h b/source/blender/blenkernel/BKE_blender_undo.h
index 4ecedbbfc1e..e5ce91df3fb 100644
--- a/source/blender/blenkernel/BKE_blender_undo.h
+++ b/source/blender/blenkernel/BKE_blender_undo.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_BLENDER_UNDO_H__
-#define __BKE_BLENDER_UNDO_H__
+#pragma once
/** \file
* \ingroup bke
@@ -41,5 +40,3 @@ void BKE_memfile_undo_free(struct MemFileUndoData *mfu);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_BLENDER_UNDO_H__ */
diff --git a/source/blender/blenkernel/BKE_blender_user_menu.h b/source/blender/blenkernel/BKE_blender_user_menu.h
index 805a343b976..8d00cde488e 100644
--- a/source/blender/blenkernel/BKE_blender_user_menu.h
+++ b/source/blender/blenkernel/BKE_blender_user_menu.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_BLENDER_USER_MENU_H__
-#define __BKE_BLENDER_USER_MENU_H__
+#pragma once
/** \file
* \ingroup bke
@@ -43,5 +42,3 @@ void BKE_blender_user_menu_item_free_list(struct ListBase *lb);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_BLENDER_USER_MENU_H__ */
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 800a3a426b7..ae0a669bfb3 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_BLENDER_VERSION_H__
-#define __BKE_BLENDER_VERSION_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -54,5 +53,3 @@ const char *BKE_blender_version_string(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_BLENDER_VERSION_H__ */
diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h
index e835137bfa1..94d203eeb2c 100644
--- a/source/blender/blenkernel/BKE_blendfile.h
+++ b/source/blender/blenkernel/BKE_blendfile.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_BLENDFILE_H__
-#define __BKE_BLENDFILE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -81,5 +80,3 @@ void BKE_blendfile_write_partial_end(struct Main *bmain_src);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_BLENDFILE_H__ */
diff --git a/source/blender/blenkernel/BKE_boids.h b/source/blender/blenkernel/BKE_boids.h
index f9fd814b5f2..c9e6f0e7346 100644
--- a/source/blender/blenkernel/BKE_boids.h
+++ b/source/blender/blenkernel/BKE_boids.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_BOIDS_H__
-#define __BKE_BOIDS_H__
+#pragma once
/** \file
* \ingroup bke
@@ -62,5 +61,3 @@ BoidState *boid_get_current_state(BoidSettings *boids);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_bpath.h b/source/blender/blenkernel/BKE_bpath.h
index cc8dd0d5b33..787dc4d1147 100644
--- a/source/blender/blenkernel/BKE_bpath.h
+++ b/source/blender/blenkernel/BKE_bpath.h
@@ -20,8 +20,7 @@
* so for BPath we don't need to malloc
*/
-#ifndef __BKE_BPATH_H__
-#define __BKE_BPATH_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -92,5 +91,3 @@ void BKE_bpath_absolute_convert(struct Main *bmain,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_BPATH_H__ */
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index 4e9430ab3e1..af299c917eb 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_BRUSH_H__
-#define __BKE_BRUSH_H__
+#pragma once
/** \file
* \ingroup bke
@@ -157,5 +156,3 @@ void BKE_brush_debug_print_state(struct Brush *br);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h
index 5d7e8fe743e..e973bee9e20 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2006 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_BVHUTILS_H__
-#define __BKE_BVHUTILS_H__
+#pragma once
/** \file
* \ingroup bke
@@ -263,5 +262,3 @@ void bvhcache_free(struct BVHCache *bvh_cache);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h
index 596085f9c6f..9912b4e4b70 100644
--- a/source/blender/blenkernel/BKE_cachefile.h
+++ b/source/blender/blenkernel/BKE_cachefile.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_CACHEFILE_H__
-#define __BKE_CACHEFILE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -66,5 +65,3 @@ void BKE_cachefile_reader_free(struct CacheFile *cache_file, struct CacheReader
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_CACHEFILE_H__ */
diff --git a/source/blender/blenkernel/BKE_callbacks.h b/source/blender/blenkernel/BKE_callbacks.h
index 284948da634..fadba5644de 100644
--- a/source/blender/blenkernel/BKE_callbacks.h
+++ b/source/blender/blenkernel/BKE_callbacks.h
@@ -18,8 +18,7 @@
* \ingroup bke
*/
-#ifndef __BKE_CALLBACKS_H__
-#define __BKE_CALLBACKS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -88,5 +87,3 @@ void BKE_callback_global_finalize(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_CALLBACKS_H__ */
diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h
index 812f5d520d7..533d5ae13cd 100644
--- a/source/blender/blenkernel/BKE_camera.h
+++ b/source/blender/blenkernel/BKE_camera.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_CAMERA_H__
-#define __BKE_CAMERA_H__
+#pragma once
/** \file
* \ingroup bke
@@ -167,5 +166,3 @@ void BKE_camera_background_image_clear(struct Camera *cam);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_ccg.h b/source/blender/blenkernel/BKE_ccg.h
index ad1e05ee367..acdaa81da8d 100644
--- a/source/blender/blenkernel/BKE_ccg.h
+++ b/source/blender/blenkernel/BKE_ccg.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_CCG_H__
-#define __BKE_CCG_H__
+#pragma once
/** \file
* \ingroup bke
@@ -166,5 +165,3 @@ BLI_INLINE CCGElem *CCG_elem_next(const CCGKey *key, CCGElem *elem)
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h
index dd7d20c0407..e997678001f 100644
--- a/source/blender/blenkernel/BKE_cdderivedmesh.h
+++ b/source/blender/blenkernel/BKE_cdderivedmesh.h
@@ -26,8 +26,7 @@
* \note This is deprecated & should eventually be removed.
*/
-#ifndef __BKE_CDDERIVEDMESH_H__
-#define __BKE_CDDERIVEDMESH_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -49,5 +48,3 @@ struct DerivedMesh *CDDM_copy(struct DerivedMesh *dm);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index cd78746a3f0..5af37829577 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) Blender Foundation.
* All rights reserved.
*/
-#ifndef __BKE_CLOTH_H__
-#define __BKE_CLOTH_H__
+#pragma once
/** \file
* \ingroup bke
@@ -307,5 +306,3 @@ void cloth_parallel_transport_hair_frame(float mat[3][3],
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index 25bc2006ee3..f4393742dff 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_COLLECTION_H__
-#define __BKE_COLLECTION_H__
+#pragma once
/** \file
* \ingroup bke
@@ -255,5 +254,3 @@ void BKE_scene_objects_iterator_end(struct BLI_Iterator *iter);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_COLLECTION_H__ */
diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h
index c3ecd0b7ed0..579adb61057 100644
--- a/source/blender/blenkernel/BKE_collision.h
+++ b/source/blender/blenkernel/BKE_collision.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) Blender Foundation.
* All rights reserved.
*/
-#ifndef __BKE_COLLISION_H__
-#define __BKE_COLLISION_H__
+#pragma once
/** \file
* \ingroup bke
@@ -178,5 +177,3 @@ void BKE_collider_cache_free(struct ListBase **colliders);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_colorband.h b/source/blender/blenkernel/BKE_colorband.h
index 355682671fe..6ac96a1ed36 100644
--- a/source/blender/blenkernel/BKE_colorband.h
+++ b/source/blender/blenkernel/BKE_colorband.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_COLORBAND_H__
-#define __BKE_COLORBAND_H__
+#pragma once
/** \file
* \ingroup bke
@@ -47,5 +46,3 @@ void BKE_colorband_update_sort(struct ColorBand *coba);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_COLORBAND_H__ */
diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h
index 0623e0e5395..1ada83c0163 100644
--- a/source/blender/blenkernel/BKE_colortools.h
+++ b/source/blender/blenkernel/BKE_colortools.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2006 Blender Foundation.
* All rights reserved.
*/
-#ifndef __BKE_COLORTOOLS_H__
-#define __BKE_COLORTOOLS_H__
+#pragma once
/** \file
* \ingroup bke
@@ -70,7 +69,7 @@ void BKE_curvemapping_changed(struct CurveMapping *cumap, const bool rem_doubles
void BKE_curvemapping_changed_all(struct CurveMapping *cumap);
/* call before _all_ evaluation functions */
-void BKE_curvemapping_initialize(struct CurveMapping *cumap);
+void BKE_curvemapping_init(struct CurveMapping *cumap);
/* keep these (const CurveMap) - to help with thread safety */
/* single curve, no table check */
@@ -152,5 +151,3 @@ bool BKE_color_managed_colorspace_settings_equals(
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index 8d7fe875c37..94349f4db22 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_CONSTRAINT_H__
-#define __BKE_CONSTRAINT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -224,5 +223,3 @@ void BKE_constraints_solve(struct Depsgraph *depsgraph,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index 7544789d864..eb26f1c3969 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_CONTEXT_H__
-#define __BKE_CONTEXT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -346,5 +345,3 @@ struct Depsgraph *CTX_data_depsgraph_on_load(const bContext *C);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_crazyspace.h b/source/blender/blenkernel/BKE_crazyspace.h
index 6ac6b17d468..b95be70379f 100644
--- a/source/blender/blenkernel/BKE_crazyspace.h
+++ b/source/blender/blenkernel/BKE_crazyspace.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_CRAZYSPACE_H__
-#define __BKE_CRAZYSPACE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -65,5 +64,3 @@ void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index ca41e51984b..0bd4e3a7582 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_CURVE_H__
-#define __BKE_CURVE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -98,15 +97,15 @@ bool BKE_curve_minmax(struct Curve *cu, bool use_radius, float min[3], float max
bool BKE_curve_center_median(struct Curve *cu, float cent[3]);
bool BKE_curve_center_bounds(struct Curve *cu, float cent[3]);
void BKE_curve_transform_ex(struct Curve *cu,
- float mat[4][4],
+ const float mat[4][4],
const bool do_keys,
const bool do_props,
const float unit_scale);
void BKE_curve_transform(struct Curve *cu,
- float mat[4][4],
+ const float mat[4][4],
const bool do_keys,
const bool do_props);
-void BKE_curve_translate(struct Curve *cu, float offset[3], const bool do_keys);
+void BKE_curve_translate(struct Curve *cu, const float offset[3], const bool do_keys);
void BKE_curve_material_index_remove(struct Curve *cu, int index);
bool BKE_curve_material_index_used(struct Curve *cu, int index);
void BKE_curve_material_index_clear(struct Curve *cu);
@@ -339,5 +338,3 @@ void BKE_curve_deform_co(const struct Object *ob_curve,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_CURVE_H__ */
diff --git a/source/blender/blenkernel/BKE_curveprofile.h b/source/blender/blenkernel/BKE_curveprofile.h
index 877ab887138..9c72a866fa9 100644
--- a/source/blender/blenkernel/BKE_curveprofile.h
+++ b/source/blender/blenkernel/BKE_curveprofile.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_CURVEPROFILE_H__
-#define __BKE_CURVEPROFILE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -72,7 +71,7 @@ void BKE_curveprofile_create_samples(struct CurveProfile *profile,
bool sample_straight_edges,
struct CurveProfilePoint *r_samples);
-void BKE_curveprofile_initialize(struct CurveProfile *profile, short segments_len);
+void BKE_curveprofile_init(struct CurveProfile *profile, short segments_len);
/* Called for a complete update of the widget after modifications */
enum {
@@ -101,5 +100,3 @@ void BKE_curveprofile_blend_read(struct BlendDataReader *reader, struct CurvePro
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 42beda352f5..92bfa3a9490 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -22,8 +22,7 @@
* \brief CustomData interface, see also DNA_customdata_types.h.
*/
-#ifndef __BKE_CUSTOMDATA_H__
-#define __BKE_CUSTOMDATA_H__
+#pragma once
#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
@@ -455,6 +454,7 @@ bool CustomData_from_bmeshpoly_test(CustomData *fdata, CustomData *ldata, bool f
bool CustomData_layer_validate(struct CustomDataLayer *layer,
const uint totitems,
const bool do_fixes);
+void CustomData_layers__print(struct CustomData *data);
/* External file storage */
@@ -574,5 +574,3 @@ void CustomData_data_transfer(const struct MeshPairRemap *me_remap,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_customdata_file.h b/source/blender/blenkernel/BKE_customdata_file.h
index 2be2f71a168..f9f02204bb9 100644
--- a/source/blender/blenkernel/BKE_customdata_file.h
+++ b/source/blender/blenkernel/BKE_customdata_file.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_CUSTOMDATA_FILE_H__
-#define __BKE_CUSTOMDATA_FILE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -60,5 +59,3 @@ CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_CUSTOMDATA_FILE_H__ */
diff --git a/source/blender/blenkernel/BKE_data_transfer.h b/source/blender/blenkernel/BKE_data_transfer.h
index a723a9ed38c..d861baba14d 100644
--- a/source/blender/blenkernel/BKE_data_transfer.h
+++ b/source/blender/blenkernel/BKE_data_transfer.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_DATA_TRANSFER_H__
-#define __BKE_DATA_TRANSFER_H__
+#pragma once
#include "BKE_customdata.h"
@@ -181,5 +180,3 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_DATA_TRANSFER_H__ */
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h
index f59e796c98c..35111d5240e 100644
--- a/source/blender/blenkernel/BKE_deform.h
+++ b/source/blender/blenkernel/BKE_deform.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_DEFORM_H__
-#define __BKE_DEFORM_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -166,5 +165,3 @@ void BKE_defvert_weight_to_rgb(float r_rgb[3], const float weight);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_DEFORM_H__ */
diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h
index b7e4acdc636..7e1a6e54ede 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_DISPLIST_H__
-#define __BKE_DISPLIST_H__
+#pragma once
/** \file
* \ingroup bke
@@ -119,5 +118,3 @@ void BKE_displist_minmax(struct ListBase *dispbase, float min[3], float max[3]);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_displist_tangent.h b/source/blender/blenkernel/BKE_displist_tangent.h
index 5e1c6ac8a21..c91c2c97dda 100644
--- a/source/blender/blenkernel/BKE_displist_tangent.h
+++ b/source/blender/blenkernel/BKE_displist_tangent.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_DISPLIST_TANGENT_H__
-#define __BKE_DISPLIST_TANGENT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -30,5 +29,3 @@ void BKE_displist_tangent_calc(const DispList *dl, float (*fnormals)[3], float (
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_DISPLIST_TANGENT_H__ */
diff --git a/source/blender/blenkernel/BKE_duplilist.h b/source/blender/blenkernel/BKE_duplilist.h
index 13918dd4fb1..c142d5338d1 100644
--- a/source/blender/blenkernel/BKE_duplilist.h
+++ b/source/blender/blenkernel/BKE_duplilist.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_DUPLILIST_H__
-#define __BKE_DUPLILIST_H__
+#pragma once
/** \file
* \ingroup bke
@@ -64,5 +63,3 @@ typedef struct DupliObject {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h
index 5e3603a8339..99b58b2f40a 100644
--- a/source/blender/blenkernel/BKE_dynamicpaint.h
+++ b/source/blender/blenkernel/BKE_dynamicpaint.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_DYNAMICPAINT_H__
-#define __BKE_DYNAMICPAINT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -124,5 +123,3 @@ void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_DYNAMICPAINT_H__ */
diff --git a/source/blender/blenkernel/BKE_editlattice.h b/source/blender/blenkernel/BKE_editlattice.h
index c587ddb551b..be791487c27 100644
--- a/source/blender/blenkernel/BKE_editlattice.h
+++ b/source/blender/blenkernel/BKE_editlattice.h
@@ -18,8 +18,7 @@
* \ingroup bke
*/
-#ifndef __BKE_EDITLATTICE_H__
-#define __BKE_EDITLATTICE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -34,5 +33,3 @@ void BKE_editlattice_load(struct Object *obedit);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_EDITLATTICE_H__ */
diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h
index 9bd62858902..819e91b438e 100644
--- a/source/blender/blenkernel/BKE_editmesh.h
+++ b/source/blender/blenkernel/BKE_editmesh.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_EDITMESH_H__
-#define __BKE_EDITMESH_H__
+#pragma once
/** \file
* \ingroup bke
@@ -107,5 +106,3 @@ struct BoundBox *BKE_editmesh_cage_boundbox_get(BMEditMesh *em);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_EDITMESH_H__ */
diff --git a/source/blender/blenkernel/BKE_editmesh_bvh.h b/source/blender/blenkernel/BKE_editmesh_bvh.h
index b8d1e26fad2..8f8e573ee2f 100644
--- a/source/blender/blenkernel/BKE_editmesh_bvh.h
+++ b/source/blender/blenkernel/BKE_editmesh_bvh.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_EDITMESH_BVH_H__
-#define __BKE_EDITMESH_BVH_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -104,5 +103,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_EDITMESH_BVH_H__ */
diff --git a/source/blender/blenkernel/BKE_editmesh_cache.h b/source/blender/blenkernel/BKE_editmesh_cache.h
index 6c812098b2e..bc2a70124fe 100644
--- a/source/blender/blenkernel/BKE_editmesh_cache.h
+++ b/source/blender/blenkernel/BKE_editmesh_cache.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_EDITMESH_CACHE_H__
-#define __BKE_EDITMESH_CACHE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -41,5 +40,3 @@ bool BKE_editmesh_cache_calc_minmax(struct BMEditMesh *em,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_EDITMESH_CACHE_H__ */
diff --git a/source/blender/blenkernel/BKE_editmesh_tangent.h b/source/blender/blenkernel/BKE_editmesh_tangent.h
index 27f24438528..0e3f063ae44 100644
--- a/source/blender/blenkernel/BKE_editmesh_tangent.h
+++ b/source/blender/blenkernel/BKE_editmesh_tangent.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_EDITMESH_TANGENT_H__
-#define __BKE_EDITMESH_TANGENT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -39,5 +38,3 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_EDITMESH_TANGENT_H__ */
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index 0518ce8ffa3..0585f67703c 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_EFFECT_H__
-#define __BKE_EFFECT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -283,5 +282,3 @@ void BKE_sim_debug_data_clear_category(const char *category);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index b846e2e5b7b..3717eb0f282 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_FCURVE_H__
-#define __BKE_FCURVE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -315,5 +314,3 @@ void fcurve_store_samples(
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_FCURVE_H__*/
diff --git a/source/blender/blenkernel/BKE_fcurve_driver.h b/source/blender/blenkernel/BKE_fcurve_driver.h
index 6803485f843..5b4da4a78a4 100644
--- a/source/blender/blenkernel/BKE_fcurve_driver.h
+++ b/source/blender/blenkernel/BKE_fcurve_driver.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_FCURVE_DRIVER_H__
-#define __BKE_FCURVE_DRIVER_H__
+#pragma once
/** \file
* \ingroup bke
@@ -103,5 +102,3 @@ float evaluate_driver(struct PathResolvedRNA *anim_rna,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_FCURVE_DRIVER_H__*/
diff --git a/source/blender/blenkernel/BKE_fluid.h b/source/blender/blenkernel/BKE_fluid.h
index 2392263181d..88a5492d85b 100644
--- a/source/blender/blenkernel/BKE_fluid.h
+++ b/source/blender/blenkernel/BKE_fluid.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_FLUID_H__
-#define __BKE_FLUID_H__
+#pragma once
/** \file
* \ingroup bke
@@ -101,5 +100,3 @@ void BKE_fluid_flow_behavior_set(struct Object *object,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_FLUID_H__ */
diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index 35f7d8b7d53..b23ccbe25ff 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_FONT_H__
-#define __BKE_FONT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -102,5 +101,3 @@ void BKE_vfont_clipboard_get(char32_t **r_text_buf,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_freestyle.h b/source/blender/blenkernel/BKE_freestyle.h
index 888a3d96aa2..47f0b547d83 100644
--- a/source/blender/blenkernel/BKE_freestyle.h
+++ b/source/blender/blenkernel/BKE_freestyle.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_FREESTYLE_H__
-#define __BKE_FREESTYLE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -66,5 +65,3 @@ void BKE_freestyle_lineset_unique_name(FreestyleConfig *config, FreestyleLineSet
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 61c270202f1..9ffd496616d 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_GLOBAL_H__
-#define __BKE_GLOBAL_H__
+#pragma once
/** \file
* \ingroup bke
@@ -145,18 +144,19 @@ enum {
G_DEBUG_DEPSGRAPH_TIME = (1 << 11), /* depsgraph timing statistics and messages */
G_DEBUG_DEPSGRAPH_NO_THREADS = (1 << 12), /* single threaded depsgraph */
G_DEBUG_DEPSGRAPH_PRETTY = (1 << 13), /* use pretty colors in depsgraph messages */
+ G_DEBUG_DEPSGRAPH_UUID = (1 << 14), /* use pretty colors in depsgraph messages */
G_DEBUG_DEPSGRAPH = (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_EVAL | G_DEBUG_DEPSGRAPH_TAG |
- G_DEBUG_DEPSGRAPH_TIME),
- G_DEBUG_SIMDATA = (1 << 14), /* sim debug data display */
- G_DEBUG_GPU_MEM = (1 << 15), /* gpu memory in status bar */
- G_DEBUG_GPU = (1 << 16), /* gpu debug */
- G_DEBUG_IO = (1 << 17), /* IO Debugging (for Collada, ...)*/
- G_DEBUG_GPU_SHADERS = (1 << 18), /* GLSL shaders */
- G_DEBUG_GPU_FORCE_WORKAROUNDS = (1 << 19), /* force gpu workarounds bypassing detections. */
- G_DEBUG_XR = (1 << 20), /* XR/OpenXR messages */
- G_DEBUG_XR_TIME = (1 << 21), /* XR/OpenXR timing messages */
-
- G_DEBUG_GHOST = (1 << 20), /* Debug GHOST module. */
+ G_DEBUG_DEPSGRAPH_TIME | G_DEBUG_DEPSGRAPH_UUID),
+ G_DEBUG_SIMDATA = (1 << 15), /* sim debug data display */
+ G_DEBUG_GPU_MEM = (1 << 16), /* gpu memory in status bar */
+ G_DEBUG_GPU = (1 << 17), /* gpu debug */
+ G_DEBUG_IO = (1 << 18), /* IO Debugging (for Collada, ...)*/
+ G_DEBUG_GPU_SHADERS = (1 << 19), /* GLSL shaders */
+ G_DEBUG_GPU_FORCE_WORKAROUNDS = (1 << 20), /* force gpu workarounds bypassing detections. */
+ G_DEBUG_XR = (1 << 21), /* XR/OpenXR messages */
+ G_DEBUG_XR_TIME = (1 << 22), /* XR/OpenXR timing messages */
+
+ G_DEBUG_GHOST = (1 << 23), /* Debug GHOST module. */
};
#define G_DEBUG_ALL \
@@ -223,5 +223,3 @@ extern Global G;
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index cd434566e43..6defc2ffd68 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -17,8 +17,7 @@
* This is a new part of Blender
*/
-#ifndef __BKE_GPENCIL_H__
-#define __BKE_GPENCIL_H__
+#pragma once
/** \file
* \ingroup bke
@@ -280,5 +279,3 @@ void BKE_gpencil_update_layer_parent(const struct Depsgraph *depsgraph, struct O
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_GPENCIL_H__ */
diff --git a/source/blender/blenkernel/BKE_gpencil_curve.h b/source/blender/blenkernel/BKE_gpencil_curve.h
index cf6f9074bda..3fbd0ce1a51 100644
--- a/source/blender/blenkernel/BKE_gpencil_curve.h
+++ b/source/blender/blenkernel/BKE_gpencil_curve.h
@@ -17,8 +17,7 @@
* This is a new part of Blender
*/
-#ifndef __BKE_GPENCIL_CURVE_H__
-#define __BKE_GPENCIL_CURVE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -43,5 +42,3 @@ void BKE_gpencil_convert_curve(struct Main *bmain,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_GPENCIL_CURVE_H__ */
diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h b/source/blender/blenkernel/BKE_gpencil_geom.h
index 964764d99e7..0abd87d3d4e 100644
--- a/source/blender/blenkernel/BKE_gpencil_geom.h
+++ b/source/blender/blenkernel/BKE_gpencil_geom.h
@@ -17,8 +17,7 @@
* This is a new part of Blender
*/
-#ifndef __BKE_GPENCIL_GEOM_H__
-#define __BKE_GPENCIL_GEOM_H__
+#pragma once
/** \file
* \ingroup bke
@@ -76,7 +75,7 @@ void BKE_gpencil_stroke_fill_triangulate(struct bGPDstroke *gps);
void BKE_gpencil_stroke_geometry_update(struct bGPDstroke *gps);
void BKE_gpencil_stroke_uv_update(struct bGPDstroke *gps);
-void BKE_gpencil_transform(struct bGPdata *gpd, float mat[4][4]);
+void BKE_gpencil_transform(struct bGPdata *gpd, const float mat[4][4]);
typedef struct GPencilPointCoordinates {
/* This is used when doing "move only origin" in object_data_transform.c.
@@ -131,5 +130,3 @@ void BKE_gpencil_convert_mesh(struct Main *bmain,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_GPENCIL_GEOM_H__ */
diff --git a/source/blender/blenkernel/BKE_gpencil_modifier.h b/source/blender/blenkernel/BKE_gpencil_modifier.h
index ac5f4607838..8eafbe04a14 100644
--- a/source/blender/blenkernel/BKE_gpencil_modifier.h
+++ b/source/blender/blenkernel/BKE_gpencil_modifier.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_GPENCIL_MODIFIER_H__
-#define __BKE_GPENCIL_MODIFIER_H__
+#pragma once
/** \file
* \ingroup bke
@@ -316,5 +315,3 @@ struct bGPDframe *BKE_gpencil_frame_retime_get(struct Depsgraph *depsgraph,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_GPENCIL_MODIFIER_H__ */
diff --git a/source/blender/blenkernel/BKE_hair.h b/source/blender/blenkernel/BKE_hair.h
index ea515416b58..bf386e099e0 100644
--- a/source/blender/blenkernel/BKE_hair.h
+++ b/source/blender/blenkernel/BKE_hair.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_HAIR_H__
-#define __BKE_HAIR_H__
+#pragma once
/** \file
* \ingroup bke
@@ -61,5 +60,3 @@ extern void (*BKE_hair_batch_cache_free_cb)(struct Hair *hair);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_icons.h b/source/blender/blenkernel/BKE_icons.h
index 56c50c22bf4..8a4fc78eb97 100644
--- a/source/blender/blenkernel/BKE_icons.h
+++ b/source/blender/blenkernel/BKE_icons.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_ICONS_H__
-#define __BKE_ICONS_H__
+#pragma once
/** \file
* \ingroup bke
@@ -173,5 +172,3 @@ int BKE_icon_ensure_studio_light(struct StudioLight *sl, int id_type);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_ICONS_H__ */
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index dc01e8ea27b..58629cde6ec 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_IDPROP_H__
-#define __BKE_IDPROP_H__
+#pragma once
/** \file
* \ingroup bke
@@ -200,5 +199,3 @@ void IDP_print(const struct IDProperty *prop);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_IDPROP_H__ */
diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index 38322427374..aefba9ef02a 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_IDTYPE_H__
-#define __BKE_IDTYPE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -246,5 +245,3 @@ void BKE_idtype_id_foreach_cache(struct ID *id,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_IDTYPE_H__ */
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 1e5573ab014..f052ba400fc 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_IMAGE_H__
-#define __BKE_IMAGE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -55,6 +54,7 @@ void BKE_image_free_packedfiles(struct Image *image);
void BKE_image_free_views(struct Image *image);
void BKE_image_free_buffers(struct Image *image);
void BKE_image_free_buffers_ex(struct Image *image, bool do_lock);
+void BKE_image_free_gputextures(struct Image *ima);
/* call from library */
void BKE_image_free(struct Image *image);
@@ -274,6 +274,10 @@ void BKE_image_free_anim_ibufs(struct Image *ima, int except_frame);
/* does all images with type MOVIE or SEQUENCE */
void BKE_image_all_free_anim_ibufs(struct Main *bmain, int except_frame);
+void BKE_image_free_all_gputextures(struct Main *bmain);
+void BKE_image_free_anim_gputextures(struct Main *bmain);
+void BKE_image_free_old_gputextures(struct Main *bmain);
+
bool BKE_image_memorypack(struct Image *ima);
void BKE_image_packfiles(struct ReportList *reports, struct Image *ima, const char *basepath);
void BKE_image_packfiles_from_mem(struct ReportList *reports,
@@ -362,6 +366,30 @@ bool BKE_image_has_loaded_ibuf(struct Image *image);
struct ImBuf *BKE_image_get_ibuf_with_name(struct Image *image, const char *name);
struct ImBuf *BKE_image_get_first_ibuf(struct Image *image);
+/* Not to be use directly. */
+struct GPUTexture *BKE_image_create_gpu_texture_from_ibuf(struct Image *image, struct ImBuf *ibuf);
+
+/* Get the GPUTexture for a given `Image`.
+ *
+ * `iuser` and `ibuf` are mutual exclusive parameters. The caller can pass the `ibuf` when already
+ * available. It is also required when requesting the GPUTexture for a render result. */
+struct GPUTexture *BKE_image_get_gpu_texture(struct Image *image,
+ struct ImageUser *iuser,
+ struct ImBuf *ibuf);
+struct GPUTexture *BKE_image_get_gpu_tiles(struct Image *image,
+ struct ImageUser *iuser,
+ struct ImBuf *ibuf);
+struct GPUTexture *BKE_image_get_gpu_tilemap(struct Image *image,
+ struct ImageUser *iuser,
+ struct ImBuf *ibuf);
+
+void BKE_image_update_gputexture(
+ struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h);
+void BKE_image_paint_set_mipmap(struct Main *bmain, bool mipmap);
+
+/* Delayed free of OpenGL buffers by main thread */
+void BKE_image_free_unused_gpu_textures(void);
+
struct RenderSlot *BKE_image_add_renderslot(struct Image *ima, const char *name);
bool BKE_image_remove_renderslot(struct Image *ima, struct ImageUser *iuser, int slot);
struct RenderSlot *BKE_image_get_renderslot(struct Image *ima, int slot);
@@ -370,5 +398,3 @@ bool BKE_image_clear_renderslot(struct Image *ima, struct ImageUser *iuser, int
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_image_save.h b/source/blender/blenkernel/BKE_image_save.h
index 8dfece944ff..0620442d998 100644
--- a/source/blender/blenkernel/BKE_image_save.h
+++ b/source/blender/blenkernel/BKE_image_save.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_IMAGE_SAVE_H__
-#define __BKE_IMAGE_SAVE_H__
+#pragma once
#include "DNA_scene_types.h"
@@ -62,5 +61,3 @@ bool BKE_image_save(struct ReportList *reports,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_IMAGE_SAVE_H__ */
diff --git a/source/blender/blenkernel/BKE_ipo.h b/source/blender/blenkernel/BKE_ipo.h
index ab5d2f66441..40b9f738bfd 100644
--- a/source/blender/blenkernel/BKE_ipo.h
+++ b/source/blender/blenkernel/BKE_ipo.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_IPO_H__
-#define __BKE_IPO_H__
+#pragma once
/** \file
* \ingroup bke
@@ -37,5 +36,3 @@ void do_versions_ipos_to_animato(struct Main *main);
#ifdef __cplusplus
};
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_kelvinlet.h b/source/blender/blenkernel/BKE_kelvinlet.h
index b8290730751..b3966d3ca4a 100644
--- a/source/blender/blenkernel/BKE_kelvinlet.h
+++ b/source/blender/blenkernel/BKE_kelvinlet.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) Blender Foundation.
* All rights reserved.
*/
-#ifndef __BKE_KELVINLET_H__
-#define __BKE_KELVINLET_H__
+#pragma once
/** \file
* \ingroup bke
@@ -81,5 +80,3 @@ void BKE_kelvinlet_twist(float r_elem_disp[3],
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index b0eef02611b..e67df194431 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_KEY_H__
-#define __BKE_KEY_H__
+#pragma once
/** \file
* \ingroup bke
@@ -139,5 +138,3 @@ void BKE_keyblock_data_set(struct Key *key, const int shape_index, const void *d
#ifdef __cplusplus
};
#endif
-
-#endif /* __BKE_KEY_H__ */
diff --git a/source/blender/blenkernel/BKE_keyconfig.h b/source/blender/blenkernel/BKE_keyconfig.h
index bc33cc2669e..ab42d5742ea 100644
--- a/source/blender/blenkernel/BKE_keyconfig.h
+++ b/source/blender/blenkernel/BKE_keyconfig.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_KEYCONFIG_H__
-#define __BKE_KEYCONFIG_H__
+#pragma once
/** \file
* \ingroup bke
@@ -76,5 +75,3 @@ void BKE_keyconfig_pref_filter_items(struct UserDef *userdef,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_KEYCONFIG_H__ */
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index bb23ad63020..03c57d4caac 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_LATTICE_H__
-#define __BKE_LATTICE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -67,8 +66,8 @@ void BKE_lattice_minmax_dl(struct Object *ob, struct Lattice *lt, float min[3],
void BKE_lattice_minmax(struct Lattice *lt, float min[3], float max[3]);
void BKE_lattice_center_median(struct Lattice *lt, float cent[3]);
void BKE_lattice_center_bounds(struct Lattice *lt, float cent[3]);
-void BKE_lattice_translate(struct Lattice *lt, float offset[3], bool do_keys);
-void BKE_lattice_transform(struct Lattice *lt, float mat[4][4], bool do_keys);
+void BKE_lattice_translate(struct Lattice *lt, const float offset[3], bool do_keys);
+void BKE_lattice_transform(struct Lattice *lt, const float mat[4][4], bool do_keys);
bool BKE_lattice_is_any_selected(const struct Lattice *lt);
@@ -140,5 +139,3 @@ void BKE_lattice_deform_coords_with_editmesh(const struct Object *ob_lattice,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_LATTICE_H__ */
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 7a0252e6813..7fe932edf31 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_LAYER_H__
-#define __BKE_LAYER_H__
+#pragma once
/** \file
* \ingroup bke
@@ -416,5 +415,3 @@ bool BKE_view_layer_filter_edit_mesh_has_edges(struct Object *ob, void *user_dat
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_LAYER_H__ */
diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h
index d46a03e90af..a2cbe537349 100644
--- a/source/blender/blenkernel/BKE_lib_id.h
+++ b/source/blender/blenkernel/BKE_lib_id.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_LIB_ID_H__
-#define __BKE_LIB_ID_H__
+#pragma once
/** \file
* \ingroup bke
@@ -291,5 +290,3 @@ void BKE_id_reorder(const struct ListBase *lb, struct ID *id, struct ID *relativ
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_LIB_ID_H__ */
diff --git a/source/blender/blenkernel/BKE_lib_override.h b/source/blender/blenkernel/BKE_lib_override.h
index 6a05f0c22b6..5843992b25c 100644
--- a/source/blender/blenkernel/BKE_lib_override.h
+++ b/source/blender/blenkernel/BKE_lib_override.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_LIB_OVERRIDE_H__
-#define __BKE_LIB_OVERRIDE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -141,7 +140,7 @@ void BKE_lib_override_library_main_update(struct Main *bmain);
/* For now, we just use a temp main list. */
typedef struct Main OverrideLibraryStorage;
-OverrideLibraryStorage *BKE_lib_override_library_operations_store_initialize(void);
+OverrideLibraryStorage *BKE_lib_override_library_operations_store_init(void);
struct ID *BKE_lib_override_library_operations_store_start(
struct Main *bmain, OverrideLibraryStorage *override_storage, struct ID *local);
void BKE_lib_override_library_operations_store_end(OverrideLibraryStorage *override_storage,
@@ -151,5 +150,3 @@ void BKE_lib_override_library_operations_store_finalize(OverrideLibraryStorage *
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_LIB_OVERRIDE_H__ */
diff --git a/source/blender/blenkernel/BKE_lib_query.h b/source/blender/blenkernel/BKE_lib_query.h
index c5a25e8e7af..b6abe0bf18c 100644
--- a/source/blender/blenkernel/BKE_lib_query.h
+++ b/source/blender/blenkernel/BKE_lib_query.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2014 by Blender Foundation.
* All rights reserved.
*/
-#ifndef __BKE_LIB_QUERY_H__
-#define __BKE_LIB_QUERY_H__
+#pragma once
/** \file
* \ingroup bke
@@ -182,5 +181,3 @@ void BKE_library_indirectly_used_data_tag_clear(struct Main *bmain);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_LIB_QUERY_H__ */
diff --git a/source/blender/blenkernel/BKE_lib_remap.h b/source/blender/blenkernel/BKE_lib_remap.h
index 8129b9dbafb..fb14e340d8b 100644
--- a/source/blender/blenkernel/BKE_lib_remap.h
+++ b/source/blender/blenkernel/BKE_lib_remap.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_LIB_REMAP_H__
-#define __BKE_LIB_REMAP_H__
+#pragma once
/** \file
* \ingroup bke
@@ -113,5 +112,3 @@ void BKE_library_callback_remap_editor_id_reference_set(
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_LIB_REMAP_H__ */
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 7883d740b0a..3981a4c14ea 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_LIBRARY_H__
-#define __BKE_LIBRARY_H__
+#pragma once
/** \file
* \ingroup bke
@@ -39,5 +38,3 @@ void BKE_library_filepath_set(struct Main *bmain, struct Library *lib, const cha
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_LIBRARY_H__ */
diff --git a/source/blender/blenkernel/BKE_light.h b/source/blender/blenkernel/BKE_light.h
index ead27ec8002..026e5d1a13b 100644
--- a/source/blender/blenkernel/BKE_light.h
+++ b/source/blender/blenkernel/BKE_light.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_LIGHT_H__
-#define __BKE_LIGHT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -44,5 +43,3 @@ void BKE_light_eval(struct Depsgraph *depsgraph, struct Light *la);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_lightprobe.h b/source/blender/blenkernel/BKE_lightprobe.h
index 6304f61a1f4..e66d4ef75ca 100644
--- a/source/blender/blenkernel/BKE_lightprobe.h
+++ b/source/blender/blenkernel/BKE_lightprobe.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_LIGHTPROBE_H__
-#define __BKE_LIGHTPROBE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -39,5 +38,3 @@ struct LightProbe *BKE_lightprobe_copy(struct Main *bmain, const struct LightPro
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_LIGHTPROBE_H__ */
diff --git a/source/blender/blenkernel/BKE_linestyle.h b/source/blender/blenkernel/BKE_linestyle.h
index b086f244923..19238c4d090 100644
--- a/source/blender/blenkernel/BKE_linestyle.h
+++ b/source/blender/blenkernel/BKE_linestyle.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_LINESTYLE_H__
-#define __BKE_LINESTYLE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -106,5 +105,3 @@ void BKE_linestyle_default_shader(const struct bContext *C, FreestyleLineStyle *
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_LINESTYLE_H__ */
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index b7c70168a49..2187ab6b9f5 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_MAIN_H__
-#define __BKE_MAIN_H__
+#pragma once
/** \file
* \ingroup bke
@@ -250,5 +249,3 @@ int set_listbasepointers(struct Main *main, struct ListBase *lb[MAX_LIBARRAY]);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MAIN_H__ */
diff --git a/source/blender/blenkernel/BKE_main_idmap.h b/source/blender/blenkernel/BKE_main_idmap.h
index e392b7db60e..b89714cefa4 100644
--- a/source/blender/blenkernel/BKE_main_idmap.h
+++ b/source/blender/blenkernel/BKE_main_idmap.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_MAIN_IDMAP_H__
-#define __BKE_MAIN_IDMAP_H__
+#pragma once
/** \file
* \ingroup bke
@@ -69,5 +68,3 @@ struct ID *BKE_main_idmap_lookup_uuid(struct IDNameLib_Map *id_typemap,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MAIN_IDMAP_H__ */
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h
index dca677343ce..ab731c5e42f 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_MASK_H__
-#define __BKE_MASK_H__
+#pragma once
/** \file
* \ingroup bke
@@ -331,5 +330,3 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MASK_H__ */
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index cae79326dda..a30d7d55985 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_MATERIAL_H__
-#define __BKE_MATERIAL_H__
+#pragma once
/** \file
* \ingroup bke
@@ -136,5 +135,3 @@ void BKE_material_eval(struct Depsgraph *depsgraph, struct Material *material);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h
index 5f51f528d14..f2ad23a35f1 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_MBALL_H__
-#define __BKE_MBALL_H__
+#pragma once
/** \file
* \ingroup bke
@@ -92,5 +91,3 @@ extern void (*BKE_mball_batch_cache_free_cb)(struct MetaBall *mb);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_mball_tessellate.h b/source/blender/blenkernel/BKE_mball_tessellate.h
index 4e0649cf930..0ffbcf5bb05 100644
--- a/source/blender/blenkernel/BKE_mball_tessellate.h
+++ b/source/blender/blenkernel/BKE_mball_tessellate.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_MBALL_TESSELLATE_H__
-#define __BKE_MBALL_TESSELLATE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -38,5 +37,3 @@ void BKE_mball_cubeTable_free(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MBALL_TESSELLATE_H__ */
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index b2510be656e..045563f8e52 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_MESH_H__
-#define __BKE_MESH_H__
+#pragma once
/** \file
* \ingroup bke
@@ -231,7 +230,7 @@ void BKE_mesh_nomain_to_meshkey(struct Mesh *mesh_src, struct Mesh *mesh_dst, st
/* vertex level transformations & checks (no derived mesh) */
bool BKE_mesh_minmax(const struct Mesh *me, float r_min[3], float r_max[3]);
-void BKE_mesh_transform(struct Mesh *me, float mat[4][4], bool do_keys);
+void BKE_mesh_transform(struct Mesh *me, const float mat[4][4], bool do_keys);
void BKE_mesh_translate(struct Mesh *me, const float offset[3], const bool do_keys);
void BKE_mesh_ensure_navmesh(struct Mesh *me);
@@ -707,5 +706,3 @@ BLI_INLINE int BKE_mesh_origindex_mface_mpoly(const int *index_mf_to_mpoly,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MESH_H__ */
diff --git a/source/blender/blenkernel/BKE_mesh_iterators.h b/source/blender/blenkernel/BKE_mesh_iterators.h
index f7eaa7f69b8..103e7b5b78f 100644
--- a/source/blender/blenkernel/BKE_mesh_iterators.h
+++ b/source/blender/blenkernel/BKE_mesh_iterators.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_MESH_ITERATORS_H__
-#define __BKE_MESH_ITERATORS_H__
+#pragma once
/** \file
* \ingroup bke
@@ -70,5 +69,3 @@ void BKE_mesh_foreach_mapped_vert_coords_get(struct Mesh *me_eval,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MESH_ITERATORS_H__ */
diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h
index 5ad5238bbb5..140a60dbdb7 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_MESH_MAPPING_H__
-#define __BKE_MESH_MAPPING_H__
+#pragma once
/** \file
* \ingroup bke
@@ -258,5 +257,3 @@ int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MESH_MAPPING_H__ */
diff --git a/source/blender/blenkernel/BKE_mesh_mirror.h b/source/blender/blenkernel/BKE_mesh_mirror.h
index 0a68d028e35..2c6920a18bf 100644
--- a/source/blender/blenkernel/BKE_mesh_mirror.h
+++ b/source/blender/blenkernel/BKE_mesh_mirror.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_MESH_MIRROR_H__
-#define __BKE_MESH_MIRROR_H__
+#pragma once
/** \file
* \ingroup bke
@@ -49,5 +48,3 @@ struct Mesh *BKE_mesh_mirror_apply_mirror_on_axis(struct MirrorModifierData *mmd
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MESH_MIRROR_H__ */
diff --git a/source/blender/blenkernel/BKE_mesh_remap.h b/source/blender/blenkernel/BKE_mesh_remap.h
index fff89e50744..d9b6ab3813e 100644
--- a/source/blender/blenkernel/BKE_mesh_remap.h
+++ b/source/blender/blenkernel/BKE_mesh_remap.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_MESH_REMAP_H__
-#define __BKE_MESH_REMAP_H__
+#pragma once
/** \file
* \ingroup bke
@@ -234,5 +233,3 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MESH_REMAP_H__ */
diff --git a/source/blender/blenkernel/BKE_mesh_remesh_voxel.h b/source/blender/blenkernel/BKE_mesh_remesh_voxel.h
index 24f95f7ed20..2265fa6e105 100644
--- a/source/blender/blenkernel/BKE_mesh_remesh_voxel.h
+++ b/source/blender/blenkernel/BKE_mesh_remesh_voxel.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_MESH_REMESH_VOXEL_H__
-#define __BKE_MESH_REMESH_VOXEL_H__
+#pragma once
/** \file
* \ingroup bke
@@ -66,5 +65,3 @@ void BKE_remesh_reproject_sculpt_face_sets(struct Mesh *target, struct Mesh *sou
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MESH_REMESH_VOXEL_H__ */
diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h
index 468ec6a44cd..adb7c357049 100644
--- a/source/blender/blenkernel/BKE_mesh_runtime.h
+++ b/source/blender/blenkernel/BKE_mesh_runtime.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_MESH_RUNTIME_H__
-#define __BKE_MESH_RUNTIME_H__
+#pragma once
/** \file
* \ingroup bke
@@ -111,5 +110,3 @@ bool BKE_mesh_runtime_is_valid(struct Mesh *me_eval);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MESH_RUNTIME_H__ */
diff --git a/source/blender/blenkernel/BKE_mesh_tangent.h b/source/blender/blenkernel/BKE_mesh_tangent.h
index 7b686f112aa..96eaa23ce71 100644
--- a/source/blender/blenkernel/BKE_mesh_tangent.h
+++ b/source/blender/blenkernel/BKE_mesh_tangent.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_MESH_TANGENT_H__
-#define __BKE_MESH_TANGENT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -87,5 +86,3 @@ void BKE_mesh_calc_loop_tangent_step_0(const struct CustomData *loopData,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MESH_TANGENT_H__ */
diff --git a/source/blender/blenkernel/BKE_mesh_wrapper.h b/source/blender/blenkernel/BKE_mesh_wrapper.h
index 00e2dd08726..2fe264fd0f7 100644
--- a/source/blender/blenkernel/BKE_mesh_wrapper.h
+++ b/source/blender/blenkernel/BKE_mesh_wrapper.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_MESH_WRAPPER_H__
-#define __BKE_MESH_WRAPPER_H__
+#pragma once
/** \file
* \ingroup bke
@@ -55,5 +54,3 @@ void BKE_mesh_wrapper_vert_coords_copy_with_mat4(const struct Mesh *me,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_MESH_WRAPPER_H__ */
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index e16a9284425..98dc411239e 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_MODIFIER_H__
-#define __BKE_MODIFIER_H__
+#pragma once
/** \file
* \ingroup bke
@@ -414,9 +413,13 @@ void BKE_modifier_type_panel_id(ModifierType type, char *r_idname);
* default values if pointer is optional.
*/
struct ModifierData *BKE_modifier_new(int type);
+
void BKE_modifier_free_ex(struct ModifierData *md, const int flag);
void BKE_modifier_free(struct ModifierData *md);
+/* Generate new UUID for the given modifier. */
+void BKE_modifier_session_uuid_generate(struct ModifierData *md);
+
bool BKE_modifier_unique_name(struct ListBase *modifiers, struct ModifierData *md);
void BKE_modifier_copydata_generic(const struct ModifierData *md,
@@ -540,8 +543,8 @@ void BKE_modifier_deform_vertsEM(ModifierData *md,
struct Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(struct Object *ob_eval,
const bool get_cage_mesh);
+void BKE_modifier_check_uuids_unique_and_report(const struct Object *object);
+
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h
index dbd6eb15bf2..958fbef1f97 100644
--- a/source/blender/blenkernel/BKE_movieclip.h
+++ b/source/blender/blenkernel/BKE_movieclip.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_MOVIECLIP_H__
-#define __BKE_MOVIECLIP_H__
+#pragma once
/** \file
* \ingroup bke
@@ -113,6 +112,11 @@ bool BKE_movieclip_put_frame_if_possible(struct MovieClip *clip,
struct MovieClipUser *user,
struct ImBuf *ibuf);
+struct GPUTexture *BKE_movieclip_get_gpu_texture(struct MovieClip *clip,
+ struct MovieClipUser *cuser);
+
+void BKE_movieclip_free_gputexture(struct MovieClip *clip);
+
/* Dependency graph evaluation. */
void BKE_movieclip_eval_update(struct Depsgraph *depsgraph,
@@ -132,5 +136,3 @@ void BKE_movieclip_eval_selection_update(struct Depsgraph *depsgraph, struct Mov
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index 15ba72ef5b5..db2dc7ec87f 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_MULTIRES_H__
-#define __BKE_MULTIRES_H__
+#pragma once
/** \file
* \ingroup bke
@@ -235,5 +234,3 @@ BLI_INLINE void BKE_multires_construct_tangent_matrix(float tangent_matrix[3][3]
#endif
#include "intern/multires_inline.h"
-
-#endif /* __BKE_MULTIRES_H__ */
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h
index 2be8d657bf4..8b3231e5302 100644
--- a/source/blender/blenkernel/BKE_nla.h
+++ b/source/blender/blenkernel/BKE_nla.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_NLA_H__
-#define __BKE_NLA_H__
+#pragma once
/** \file
* \ingroup bke
@@ -149,5 +148,3 @@ float BKE_nla_tweakedit_remap(struct AnimData *adt, float cframe, short mode);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 4c55488ecd5..ef46bc0f202 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_NODE_H__
-#define __BKE_NODE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -1331,6 +1330,8 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
#define SIM_NODE_EMIT_PARTICLES 1009
#define SIM_NODE_TIME 1010
#define SIM_NODE_PARTICLE_ATTRIBUTE 1011
+#define SIM_NODE_AGE_REACHED_EVENT 1012
+#define SIM_NODE_KILL_PARTICLE 1013
/** \} */
@@ -1344,6 +1345,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
#define FN_NODE_GROUP_INSTANCE_ID 1203
#define FN_NODE_COMBINE_STRINGS 1204
#define FN_NODE_OBJECT_TRANSFORMS 1205
+#define FN_NODE_RANDOM_FLOAT 1206
/** \} */
@@ -1365,5 +1367,3 @@ extern struct bNodeSocketType NodeSocketTypeUndefined;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_NODE_H__ */
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index f2a022c84a3..2029f4d38a1 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_OBJECT_H__
-#define __BKE_OBJECT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -144,21 +143,21 @@ struct Object *BKE_object_duplicate(struct Main *bmain,
void BKE_object_obdata_size_init(struct Object *ob, const float scale);
-void BKE_object_scale_to_mat3(struct Object *ob, float mat[3][3]);
-void BKE_object_rot_to_mat3(const struct Object *ob, float mat[3][3], bool use_drot);
-void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], bool use_compat);
-void BKE_object_to_mat3(struct Object *ob, float mat[3][3]);
-void BKE_object_to_mat4(struct Object *ob, float mat[4][4]);
+void BKE_object_scale_to_mat3(struct Object *ob, float r_mat[3][3]);
+void BKE_object_rot_to_mat3(const struct Object *ob, float r_mat[3][3], bool use_drot);
+void BKE_object_mat3_to_rot(struct Object *ob, float r_mat[3][3], bool use_compat);
+void BKE_object_to_mat3(struct Object *ob, float r_mat[3][3]);
+void BKE_object_to_mat4(struct Object *ob, float r_mat[4][4]);
void BKE_object_apply_mat4(struct Object *ob,
- float mat[4][4],
+ const float mat[4][4],
const bool use_compat,
const bool use_parent);
void BKE_object_apply_mat4_ex(struct Object *ob,
- float mat[4][4],
+ const float mat[4][4],
struct Object *parent,
- float parentinv[4][4],
+ const float parentinv[4][4],
const bool use_compat);
-void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]);
+void BKE_object_matrix_local_get(struct Object *ob, float r_mat[4][4]);
bool BKE_object_pose_context_check(const struct Object *ob);
struct Object *BKE_object_pose_armature_get(struct Object *ob);
@@ -188,7 +187,7 @@ struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer,
struct View3D *v3d,
unsigned int *r_bases_len);
-void BKE_object_get_parent_matrix(struct Object *ob, struct Object *par, float parentmat[4][4]);
+void BKE_object_get_parent_matrix(struct Object *ob, struct Object *par, float r_parentmat[4][4]);
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,
@@ -199,7 +198,7 @@ void BKE_object_where_is_calc_time(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob,
float ctime);
-void BKE_object_where_is_calc_mat4(struct Object *ob, float obmat[4][4]);
+void BKE_object_where_is_calc_mat4(struct Object *ob, float r_obmat[4][4]);
/* possibly belong in own moduke? */
struct BoundBox *BKE_boundbox_alloc_unit(void);
@@ -207,12 +206,12 @@ void BKE_boundbox_init_from_minmax(struct BoundBox *bb, const float min[3], cons
void BKE_boundbox_calc_center_aabb(const struct BoundBox *bb, float r_cent[3]);
void BKE_boundbox_calc_size_aabb(const struct BoundBox *bb, float r_size[3]);
void BKE_boundbox_minmax(const struct BoundBox *bb,
- float obmat[4][4],
+ const float obmat[4][4],
float r_min[3],
float r_max[3]);
struct BoundBox *BKE_object_boundbox_get(struct Object *ob);
-void BKE_object_dimensions_get(struct Object *ob, float vec[3]);
+void BKE_object_dimensions_get(struct Object *ob, float r_vec[3]);
void BKE_object_dimensions_set_ex(struct Object *ob,
const float value[3],
int axis_mask,
@@ -233,7 +232,7 @@ bool BKE_object_minmax_dupli(struct Depsgraph *depsgraph,
/* sometimes min-max isn't enough, we need to loop over each point */
void BKE_object_foreach_display_point(struct Object *ob,
- float obmat[4][4],
+ const float obmat[4][4],
void (*func_cb)(const float[3], void *),
void *user_data);
void BKE_scene_foreach_display_point(struct Depsgraph *depsgraph,
@@ -410,8 +409,8 @@ struct Mesh *BKE_object_to_mesh(struct Depsgraph *depsgraph,
void BKE_object_to_mesh_clear(struct Object *object);
+void BKE_object_check_uuids_unique_and_report(const struct Object *object);
+
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_object_deform.h b/source/blender/blenkernel/BKE_object_deform.h
index e4813aa2288..a10158254c2 100644
--- a/source/blender/blenkernel/BKE_object_deform.h
+++ b/source/blender/blenkernel/BKE_object_deform.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_OBJECT_DEFORM_H__
-#define __BKE_OBJECT_DEFORM_H__
+#pragma once
/** \file
* \ingroup bke
@@ -95,5 +94,3 @@ void BKE_object_defgroup_mirror_selection(struct Object *ob,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_OBJECT_DEFORM_H__ */
diff --git a/source/blender/blenkernel/BKE_object_facemap.h b/source/blender/blenkernel/BKE_object_facemap.h
index 83780d8fad5..10cb4a54bde 100644
--- a/source/blender/blenkernel/BKE_object_facemap.h
+++ b/source/blender/blenkernel/BKE_object_facemap.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_OBJECT_FACEMAP_H__
-#define __BKE_OBJECT_FACEMAP_H__
+#pragma once
/** \file
* \ingroup bke
@@ -48,5 +47,3 @@ void BKE_object_facemap_index_map_apply(int *fmap, int fmap_len, const int *map,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_OBJECT_FACEMAP_H__ */
diff --git a/source/blender/blenkernel/BKE_ocean.h b/source/blender/blenkernel/BKE_ocean.h
index 6ce2e13cf18..1f8cdf27eb1 100644
--- a/source/blender/blenkernel/BKE_ocean.h
+++ b/source/blender/blenkernel/BKE_ocean.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_OCEAN_H__
-#define __BKE_OCEAN_H__
+#pragma once
#include <stdbool.h>
@@ -70,8 +69,10 @@ typedef struct OceanCache {
struct Ocean *BKE_ocean_add(void);
void BKE_ocean_free_data(struct Ocean *oc);
void BKE_ocean_free(struct Ocean *oc);
-bool BKE_ocean_ensure(struct OceanModifierData *omd);
-void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd);
+bool BKE_ocean_ensure(struct OceanModifierData *omd, const int resolution);
+void BKE_ocean_init_from_modifier(struct Ocean *ocean,
+ struct OceanModifierData const *omd,
+ const int resolution);
void BKE_ocean_init(struct Ocean *o,
int M,
@@ -135,5 +136,3 @@ float BLI_ocean_spectrum_jonswap(const struct Ocean *oc, const float kx, const f
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_outliner_treehash.h b/source/blender/blenkernel/BKE_outliner_treehash.h
index 9f4ebffdcf4..94bf0f622d6 100644
--- a/source/blender/blenkernel/BKE_outliner_treehash.h
+++ b/source/blender/blenkernel/BKE_outliner_treehash.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_OUTLINER_TREEHASH_H__
-#define __BKE_OUTLINER_TREEHASH_H__
+#pragma once
/** \file
* \ingroup bke
@@ -59,5 +58,3 @@ void BKE_outliner_treehash_free(void *treehash);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h
index fb2578b81b0..1e8721045cd 100644
--- a/source/blender/blenkernel/BKE_packedFile.h
+++ b/source/blender/blenkernel/BKE_packedFile.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_PACKEDFILE_H__
-#define __BKE_PACKEDFILE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -125,5 +124,3 @@ void BKE_packedfile_id_unpack(struct Main *bmain,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 1c02aece06f..58687858a9e 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_PAINT_H__
-#define __BKE_PAINT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -42,6 +41,7 @@ struct EdgeSet;
struct GHash;
struct GridPaintMask;
struct ImagePool;
+struct ListBase;
struct MLoop;
struct MLoopTri;
struct MVert;
@@ -260,10 +260,20 @@ typedef struct SculptPoseIKChain {
/* Cloth Brush */
typedef struct SculptClothLengthConstraint {
- int v1;
- int v2;
+ /* Elements that are affected by the constraint. */
+ /* Element a should always be a mesh vertex with the index stored in elem_index_a as it is always
+ * deformed. Element b could be another vertex of the same mesh or any other position (arbitrary
+ * point, position for a previous state). In that case, elem_index_a and elem_index_b should be
+ * the same to avoid affecting two different vertices when solving the constraints.
+ * *elem_position points to the position which is owned by the element. */
+ int elem_index_a;
+ float *elem_position_a;
+
+ int elem_index_b;
+ float *elem_position_b;
float length;
+ float strength;
} SculptClothLengthConstraint;
typedef struct SculptClothSimulation {
@@ -273,6 +283,11 @@ typedef struct SculptClothSimulation {
int capacity_length_constraints;
float *length_constraint_tweak;
+ /* Position anchors for deformation brushes. These positions are modified by the brush and the
+ * final positions of the simulated vertices are updated with constraints that use these points
+ * as targets. */
+ float (*deformation_pos)[3];
+
float mass;
float damping;
@@ -280,7 +295,9 @@ typedef struct SculptClothSimulation {
float (*pos)[3];
float (*init_pos)[3];
float (*prev_pos)[3];
+ float (*last_iteration_pos)[3];
+ struct ListBase *collider_list;
} SculptClothSimulation;
typedef struct SculptPersistentBase {
@@ -297,6 +314,76 @@ typedef struct SculptVertexInfo {
BLI_bitmap *boundary;
} SculptVertexInfo;
+typedef struct SculptBoundaryEditInfo {
+ /* Vertex index from where the topology propagation reached this vertex. */
+ int original_vertex;
+
+ /* How many steps were needed to reach this vertex from the boundary. */
+ int num_propagation_steps;
+
+ /* Stregth that is used to deform this vertex. */
+ float strength_factor;
+} SculptBoundaryEditInfo;
+
+/* Edge for drawing the boundary preview in the cursor. */
+typedef struct SculptBoundaryPreviewEdge {
+ int v1;
+ int v2;
+} SculptBoundaryPreviewEdge;
+
+typedef struct SculptBoundary {
+ /* Vertex indices of the active boundary. */
+ int *vertices;
+ int vertices_capacity;
+ int num_vertices;
+
+ /* Data for drawing the preview. */
+ SculptBoundaryPreviewEdge *edges;
+ int edges_capacity;
+ int num_edges;
+
+ /* True if the boundary loops into itself. */
+ bool forms_loop;
+
+ /* Initial vertex in the boundary which is closest to the current sculpt active vertex. */
+ int initial_vertex;
+
+ /* Vertex that at max_propagation_steps from the boundary and closest to the original active
+ * vertex that was used to initialize the boundary. This is used as a reference to check how much
+ * the deformation will go into the mesh and to calculate the strength of the brushes. */
+ int pivot_vertex;
+
+ /* Stores the initial positions of the pivot and boundary initial vertex as they may be deformed
+ * during the brush action. This allows to use them as a reference positions and vectors for some
+ * brush effects. */
+ float initial_vertex_position[3];
+ float initial_pivot_position[3];
+
+ /* Maximum number of topology steps that were calculated from the boundary. */
+ int max_propagation_steps;
+
+ /* Indexed by vertex index, contains the topology information needed for boundary deformations.
+ */
+ struct SculptBoundaryEditInfo *edit_info;
+
+ /* Bend Deform type. */
+ struct {
+ float (*pivot_rotation_axis)[3];
+ float (*pivot_positions)[3];
+ } bend;
+
+ /* Slide Deform type. */
+ struct {
+ float (*directions)[3];
+ } slide;
+
+ /* Twist Deform type. */
+ struct {
+ float rotation_axis[3];
+ float pivot_position[3];
+ } twist;
+} SculptBoundary;
+
typedef struct SculptFakeNeighbors {
bool use_fake_neighbors;
@@ -318,6 +405,9 @@ typedef struct SculptSession {
int level;
} multires;
+ /* Depsgraph for the Cloth Brush solver to get the colliders. */
+ struct Depsgraph *depsgraph;
+
/* These are always assigned to base mesh data when using PBVH_FACES and PBVH_GRIDS. */
struct MVert *mvert;
struct MPoly *mpoly;
@@ -395,6 +485,9 @@ typedef struct SculptSession {
float pose_origin[3];
SculptPoseIKChain *pose_ik_chain_preview;
+ /* Boundary Brush Preview */
+ SculptBoundary *boundary_preview;
+
/* Mesh State Persistence */
/* This is freed with the PBVH, so it is always in sync with the mesh. */
SculptPersistentBase *persistent_base;
@@ -471,6 +564,10 @@ struct PBVH *BKE_sculpt_object_pbvh_ensure(struct Depsgraph *depsgraph, struct O
void BKE_sculpt_bvh_update_from_ccg(struct PBVH *pbvh, struct SubdivCCG *subdiv_ccg);
+/* This ensure that all elements in the mesh (both vertices and grids) have their visibility
+ * updated according to the face sets. */
+void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg);
+
bool BKE_sculptsession_use_pbvh_draw(const struct Object *ob, const struct View3D *v3d);
enum {
@@ -481,5 +578,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 7de588450d6..7d317538f44 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -20,8 +20,7 @@
* Copyright 2011-2012 AutoCRC
*/
-#ifndef __BKE_PARTICLE_H__
-#define __BKE_PARTICLE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -217,7 +216,7 @@ typedef struct ParticleCollision {
/** Collision modifier for current object. */
struct CollisionModifierData *md;
- /** Time factor of previous collision, needed for substracting face velocity. */
+ /** Time factor of previous collision, needed for subtracting face velocity. */
float f;
float fac1, fac2;
@@ -580,7 +579,7 @@ void psys_particle_on_dm(struct Mesh *mesh_final,
/* particle_system.c */
void distribute_particles(struct ParticleSimulationData *sim, int from);
-void initialize_particle(struct ParticleSimulationData *sim, struct ParticleData *pa);
+void init_particle(struct ParticleSimulationData *sim, struct ParticleData *pa);
void psys_calc_dmcache(struct Object *ob,
struct Mesh *mesh_final,
struct Mesh *mesh_original,
@@ -631,5 +630,3 @@ extern void (*BKE_particle_batch_cache_free_cb)(struct ParticleSystem *psys);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_PARTICLE_H__ */
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index da9280148fd..9826dfaa4a5 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_PBVH_H__
-#define __BKE_PBVH_H__
+#pragma once
/** \file
* \ingroup bke
@@ -489,5 +488,3 @@ void BKE_pbvh_node_color_buffer_free(PBVH *pbvh);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_PBVH_H__ */
diff --git a/source/blender/blenkernel/BKE_persistent_data_handle.hh b/source/blender/blenkernel/BKE_persistent_data_handle.hh
index 884e4c00766..42a853886d7 100644
--- a/source/blender/blenkernel/BKE_persistent_data_handle.hh
+++ b/source/blender/blenkernel/BKE_persistent_data_handle.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_PERSISTENT_DATA_HANDLE_H__
-#define __BKE_PERSISTENT_DATA_HANDLE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -69,7 +68,7 @@ class PersistentDataHandle {
uint64_t hash() const
{
- return (uint64_t)handle_;
+ return static_cast<uint64_t>(handle_);
}
};
@@ -128,5 +127,3 @@ class PersistentDataHandleMap {
};
} // namespace blender::bke
-
-#endif /* __BKE_PERSISTENT_DATA_HANDLE_H__ */
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index dc99ec7f56f..c5bf94cc0c8 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_POINTCACHE_H__
-#define __BKE_POINTCACHE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -387,5 +386,3 @@ void BKE_ptcache_invalidate(struct PointCache *cache);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_pointcloud.h b/source/blender/blenkernel/BKE_pointcloud.h
index d641d3feb62..b2e7e1d23ee 100644
--- a/source/blender/blenkernel/BKE_pointcloud.h
+++ b/source/blender/blenkernel/BKE_pointcloud.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_POINTCLOUD_H__
-#define __BKE_POINTCLOUD_H__
+#pragma once
/** \file
* \ingroup bke
@@ -64,5 +63,3 @@ extern void (*BKE_pointcloud_batch_cache_free_cb)(struct PointCloud *pointcloud)
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_report.h b/source/blender/blenkernel/BKE_report.h
index 063c0831a0d..5b22918e84c 100644
--- a/source/blender/blenkernel/BKE_report.h
+++ b/source/blender/blenkernel/BKE_report.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_REPORT_H__
-#define __BKE_REPORT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -69,5 +68,3 @@ bool BKE_report_write_file(const char *filepath, ReportList *reports, const char
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index b4aa0ac2b93..c2059144388 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -22,8 +22,7 @@
* \brief API for Blender-side Rigid Body stuff
*/
-#ifndef __BKE_RIGIDBODY_H__
-#define __BKE_RIGIDBODY_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -162,5 +161,3 @@ void BKE_rigidbody_object_sync_transforms(struct Depsgraph *depsgraph,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_RIGIDBODY_H__ */
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 800370318c4..8cd86593873 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_SCENE_H__
-#define __BKE_SCENE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -260,5 +259,3 @@ void BKE_scene_eval_sequencer_sequences(struct Depsgraph *depsgraph, struct Scen
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 13716ddb5c6..edab543fc37 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_SCREEN_H__
-#define __BKE_SCREEN_H__
+#pragma once
/** \file
* \ingroup bke
@@ -73,7 +72,7 @@ typedef struct SpaceType {
/* Initial allocation, after this WM will call init() too. Some editors need
* area and scene data (e.g. frame range) to set their initial scrolling. */
- struct SpaceLink *(*new)(const struct ScrArea *area, const struct Scene *scene);
+ struct SpaceLink *(*create)(const struct ScrArea *area, const struct Scene *scene);
/* not free spacelink itself */
void (*free)(struct SpaceLink *sl);
@@ -436,5 +435,3 @@ void BKE_screen_header_alignment_reset(struct bScreen *screen);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 2873a13d1f7..b6d901c8ef2 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_SEQUENCER_H__
-#define __BKE_SEQUENCER_H__
+#pragma once
/** \file
* \ingroup bke
@@ -527,6 +526,9 @@ typedef struct Sequence *(*SeqLoadFn)(struct bContext *, ListBase *, struct SeqL
struct Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine, int type);
+/* Generate new UUID for the given sequence. */
+void BKE_sequence_session_uuid_generate(struct Sequence *sequence);
+
void BKE_sequence_alpha_mode_from_extension(struct Sequence *seq);
void BKE_sequence_init_colorspace(struct Sequence *seq);
@@ -630,8 +632,10 @@ void BKE_sequencer_flag_for_removal(struct Scene *scene,
struct Sequence *seq);
void BKE_sequencer_remove_flagged_sequences(struct Scene *scene, struct ListBase *seqbase);
+/* A debug and development function which checks whether sequences have unique UUIDs.
+ * Errors will be reported to the console. */
+void BKE_sequencer_check_uuids_unique_and_report(const struct Scene *scene);
+
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_SEQUENCER_H__ */
diff --git a/source/blender/blenkernel/BKE_sequencer_offscreen.h b/source/blender/blenkernel/BKE_sequencer_offscreen.h
index cc822e97270..90d3f80320a 100644
--- a/source/blender/blenkernel/BKE_sequencer_offscreen.h
+++ b/source/blender/blenkernel/BKE_sequencer_offscreen.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_SEQUENCER_OFFSCREEN_H__
-#define __BKE_SEQUENCER_OFFSCREEN_H__
+#pragma once
/** \file
* \ingroup bke
@@ -52,5 +51,3 @@ extern SequencerDrawView sequencer_view3d_fn;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_SEQUENCER_H__ */
diff --git a/source/blender/blenkernel/BKE_shader_fx.h b/source/blender/blenkernel/BKE_shader_fx.h
index 31e14c6c884..1eb52b389d1 100644
--- a/source/blender/blenkernel/BKE_shader_fx.h
+++ b/source/blender/blenkernel/BKE_shader_fx.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_SHADER_FX_H__
-#define __BKE_SHADER_FX_H__
+#pragma once
/** \file
* \ingroup bke
@@ -189,5 +188,3 @@ bool BKE_shaderfx_has_gpencil(struct Object *ob);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_SHADER_FX_H__ */
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index 83129bed5f7..bcf702ea797 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) Blender Foundation.
* All rights reserved.
*/
-#ifndef __BKE_SHRINKWRAP_H__
-#define __BKE_SHRINKWRAP_H__
+#pragma once
/** \file
* \ingroup bke
@@ -192,5 +191,3 @@ void BKE_shrinkwrap_snap_point_to_surface(const struct ShrinkwrapTreeData *tree,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_SHRINKWRAP_H__ */
diff --git a/source/blender/blenkernel/BKE_simulation.h b/source/blender/blenkernel/BKE_simulation.h
index 6cbe77e8de3..2c436f2bff8 100644
--- a/source/blender/blenkernel/BKE_simulation.h
+++ b/source/blender/blenkernel/BKE_simulation.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_SIMULATION_H__
-#define __BKE_SIMULATION_H__
+#pragma once
#include "DNA_simulation_types.h"
@@ -56,5 +55,3 @@ void BKE_simulation_state_copy_data(const SimulationState *src_state, Simulation
template<typename StateType> const char *BKE_simulation_get_state_type_name();
#endif
-
-#endif /* __BKE_SIMULATION_H__ */
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h
index e4012094b74..28d299679ed 100644
--- a/source/blender/blenkernel/BKE_softbody.h
+++ b/source/blender/blenkernel/BKE_softbody.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) Blender Foundation.
* All rights reserved.
*/
-#ifndef __BKE_SOFTBODY_H__
-#define __BKE_SOFTBODY_H__
+#pragma once
/** \file
* \ingroup bke
@@ -76,5 +75,3 @@ extern void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], f
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index b93591b7b60..57ce33a239f 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_SOUND_H__
-#define __BKE_SOUND_H__
+#pragma once
/** \file
* \ingroup bke
@@ -194,5 +193,3 @@ void BKE_sound_evaluate(struct Depsgraph *depsgraph, struct Main *bmain, struct
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_SOUND_H__ */
diff --git a/source/blender/blenkernel/BKE_speaker.h b/source/blender/blenkernel/BKE_speaker.h
index 54bb7274e4b..b01824dd794 100644
--- a/source/blender/blenkernel/BKE_speaker.h
+++ b/source/blender/blenkernel/BKE_speaker.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_SPEAKER_H__
-#define __BKE_SPEAKER_H__
+#pragma once
/** \file
* \ingroup bke
@@ -35,5 +34,3 @@ struct Speaker *BKE_speaker_copy(struct Main *bmain, const struct Speaker *spk);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h
index ff11f581cc4..32c571e5f91 100644
--- a/source/blender/blenkernel/BKE_studiolight.h
+++ b/source/blender/blenkernel/BKE_studiolight.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_STUDIOLIGHT_H__
-#define __BKE_STUDIOLIGHT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -168,5 +167,3 @@ void BKE_studiolight_unset_icon_id(StudioLight *sl, int icon_id);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_STUDIOLIGHT_H__ */
diff --git a/source/blender/blenkernel/BKE_subdiv.h b/source/blender/blenkernel/BKE_subdiv.h
index 1323938e479..96a79d753cf 100644
--- a/source/blender/blenkernel/BKE_subdiv.h
+++ b/source/blender/blenkernel/BKE_subdiv.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_SUBDIV_H__
-#define __BKE_SUBDIV_H__
+#pragma once
#include "BLI_compiler_compat.h"
#include "BLI_sys_types.h"
@@ -302,5 +301,3 @@ BLI_INLINE float BKE_subdiv_edge_crease_to_sharpness_char(char edge_crease);
#endif
#include "intern/subdiv_inline.h"
-
-#endif /* __BKE_SUBDIV_H__ */
diff --git a/source/blender/blenkernel/BKE_subdiv_ccg.h b/source/blender/blenkernel/BKE_subdiv_ccg.h
index 5808f223f32..2277eb27ef1 100644
--- a/source/blender/blenkernel/BKE_subdiv_ccg.h
+++ b/source/blender/blenkernel/BKE_subdiv_ccg.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_SUBDIV_CCG_H__
-#define __BKE_SUBDIV_CCG_H__
+#pragma once
#include "BKE_DerivedMesh.h"
#include "BKE_customdata.h"
@@ -338,8 +337,8 @@ SubdivCCGAdjacencyType BKE_subdiv_ccg_coarse_mesh_adjacency_info_get(const Subdi
const int *BKE_subdiv_ccg_start_face_grid_index_ensure(SubdivCCG *subdiv_ccg);
const int *BKE_subdiv_ccg_start_face_grid_index_get(const SubdivCCG *subdiv_ccg);
+void BKE_subdiv_ccg_grid_hidden_ensure(SubdivCCG *subdiv_ccg, int grid_index);
+
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_SUBDIV_CCG_H__ */
diff --git a/source/blender/blenkernel/BKE_subdiv_deform.h b/source/blender/blenkernel/BKE_subdiv_deform.h
index 735cd20a6c8..1cdb8d2c794 100644
--- a/source/blender/blenkernel/BKE_subdiv_deform.h
+++ b/source/blender/blenkernel/BKE_subdiv_deform.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_SUBDIV_DEFORM_H__
-#define __BKE_SUBDIV_DEFORM_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -48,5 +47,3 @@ void BKE_subdiv_deform_coarse_vertices(struct Subdiv *subdiv,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_SUBDIV_DEFORM_H__ */
diff --git a/source/blender/blenkernel/BKE_subdiv_eval.h b/source/blender/blenkernel/BKE_subdiv_eval.h
index aa27df88be8..204e802da6e 100644
--- a/source/blender/blenkernel/BKE_subdiv_eval.h
+++ b/source/blender/blenkernel/BKE_subdiv_eval.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_SUBDIV_EVAL_H__
-#define __BKE_SUBDIV_EVAL_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -149,5 +148,3 @@ void BKE_subdiv_eval_limit_patch_resolution_point_and_short_normal(struct Subdiv
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_SUBDIV_EVAL_H__ */
diff --git a/source/blender/blenkernel/BKE_subdiv_foreach.h b/source/blender/blenkernel/BKE_subdiv_foreach.h
index bef141b5ac5..a351b9a3d11 100644
--- a/source/blender/blenkernel/BKE_subdiv_foreach.h
+++ b/source/blender/blenkernel/BKE_subdiv_foreach.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_SUBDIV_FOREACH_H__
-#define __BKE_SUBDIV_FOREACH_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -178,5 +177,3 @@ bool BKE_subdiv_foreach_subdiv_geometry(struct Subdiv *subdiv,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_SUBDIV_FOREACH_H__ */
diff --git a/source/blender/blenkernel/BKE_subdiv_mesh.h b/source/blender/blenkernel/BKE_subdiv_mesh.h
index 9928c41a92b..73a3e8ed02e 100644
--- a/source/blender/blenkernel/BKE_subdiv_mesh.h
+++ b/source/blender/blenkernel/BKE_subdiv_mesh.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_SUBDIV_MESH_H__
-#define __BKE_SUBDIV_MESH_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -53,5 +52,3 @@ struct Mesh *BKE_subdiv_to_mesh(struct Subdiv *subdiv,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_SUBDIV)MESH_H__ */
diff --git a/source/blender/blenkernel/BKE_subdiv_topology.h b/source/blender/blenkernel/BKE_subdiv_topology.h
index cc32b4c03b3..42bd9392aa4 100644
--- a/source/blender/blenkernel/BKE_subdiv_topology.h
+++ b/source/blender/blenkernel/BKE_subdiv_topology.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_SUBDIV_TOPOLOGY_H__
-#define __BKE_SUBDIV_TOPOLOGY_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -35,5 +34,3 @@ int BKE_subdiv_topology_num_fvar_layers_get(const struct Subdiv *subdiv);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_SUBDIV_TOPOLOGY_H__ */
diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h
index 0ed58180ffa..07bbeafb1ae 100644
--- a/source/blender/blenkernel/BKE_subsurf.h
+++ b/source/blender/blenkernel/BKE_subsurf.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_SUBSURF_H__
-#define __BKE_SUBSURF_H__
+#pragma once
/** \file
* \ingroup bke
@@ -158,5 +157,3 @@ typedef struct CCGDerivedMesh {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h
index 51d589e61c3..289ad351429 100644
--- a/source/blender/blenkernel/BKE_text.h
+++ b/source/blender/blenkernel/BKE_text.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_TEXT_H__
-#define __BKE_TEXT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -118,5 +117,3 @@ void txt_from_buf_for_undo(struct Text *text, const char *buf, int buf_len);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_text_suggestions.h b/source/blender/blenkernel/BKE_text_suggestions.h
index d618fcd6d11..f54e45b6c2f 100644
--- a/source/blender/blenkernel/BKE_text_suggestions.h
+++ b/source/blender/blenkernel/BKE_text_suggestions.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2008, Blender Foundation
* All rights reserved.
*/
-#ifndef __BKE_TEXT_SUGGESTIONS_H__
-#define __BKE_TEXT_SUGGESTIONS_H__
+#pragma once
/** \file
* \ingroup bke
@@ -85,5 +84,3 @@ void texttool_docs_clear(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_TEXT_SUGGESTIONS_H__ */
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index 43ef2b1ba7f..c4c2498c2b1 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_TEXTURE_H__
-#define __BKE_TEXTURE_H__
+#pragma once
/** \file
* \ingroup bke
@@ -102,5 +101,3 @@ void BKE_texture_fetch_images_for_pool(struct Tex *texture, struct ImagePool *po
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index bb88fbf863b..2d763132923 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_TRACKING_H__
-#define __BKE_TRACKING_H__
+#pragma once
/** \file
* \ingroup bke
@@ -493,5 +492,3 @@ void BKE_tracking_get_rna_path_prefix_for_plane_track(
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h
index b32c3e315ff..4f933ca7a87 100644
--- a/source/blender/blenkernel/BKE_undo_system.h
+++ b/source/blender/blenkernel/BKE_undo_system.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_UNDO_SYSTEM_H__
-#define __BKE_UNDO_SYSTEM_H__
+#pragma once
/** \file
* \ingroup bke
@@ -212,5 +211,3 @@ void BKE_undosys_print(UndoStack *ustack);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_UNDO_SYSTEM_H__ */
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index 4f9ff61c9a6..a797c5555ff 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_UNIT_H__
-#define __BKE_UNIT_H__
+#pragma once
/** \file
* \ingroup bke
@@ -93,5 +92,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_UNIT_H__ */
diff --git a/source/blender/blenkernel/BKE_volume.h b/source/blender/blenkernel/BKE_volume.h
index 224f3ede45d..b3437454f31 100644
--- a/source/blender/blenkernel/BKE_volume.h
+++ b/source/blender/blenkernel/BKE_volume.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_VOLUME_H__
-#define __BKE_VOLUME_H__
+#pragma once
/** \file
* \ingroup bke
@@ -159,5 +158,3 @@ openvdb::GridBase::Ptr BKE_volume_grid_openvdb_for_write(const struct Volume *vo
struct VolumeGrid *grid,
const bool clear);
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_volume_render.h b/source/blender/blenkernel/BKE_volume_render.h
index 5c3cd0102cf..a42f24a5312 100644
--- a/source/blender/blenkernel/BKE_volume_render.h
+++ b/source/blender/blenkernel/BKE_volume_render.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_VOLUME_RENDER_H__
-#define __BKE_VOLUME_RENDER_H__
+#pragma once
/** \file
* \ingroup bke
@@ -66,5 +65,3 @@ float BKE_volume_density_scale(const struct Volume *volume, const float matrix[4
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index 8a6afd8a753..5ff1ba2c6f5 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -18,8 +18,7 @@
* \ingroup bke
*/
-#ifndef __BKE_WORKSPACE_H__
-#define __BKE_WORKSPACE_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -112,5 +111,3 @@ void BKE_workspace_id_tag_all_visible(struct Main *bmain, int tag) ATTR_NONNULL(
#ifdef __cplusplus
}
#endif
-
-#endif /* __BKE_WORKSPACE_H__ */
diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h
index 3c8f8547b46..82830facccc 100644
--- a/source/blender/blenkernel/BKE_world.h
+++ b/source/blender/blenkernel/BKE_world.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BKE_WORLD_H__
-#define __BKE_WORLD_H__
+#pragma once
/** \file
* \ingroup bke
@@ -39,5 +38,3 @@ void BKE_world_eval(struct Depsgraph *depsgraph, struct World *world);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h
index 79605e99306..97f998cc1c1 100644
--- a/source/blender/blenkernel/BKE_writeavi.h
+++ b/source/blender/blenkernel/BKE_writeavi.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_WRITEAVI_H__
-#define __BKE_WRITEAVI_H__
+#pragma once
/** \file
* \ingroup bke
@@ -73,5 +72,3 @@ void BKE_movie_filepath_get(char *string,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h
index 467e6ab7242..4c966c55e41 100644
--- a/source/blender/blenkernel/BKE_writeffmpeg.h
+++ b/source/blender/blenkernel/BKE_writeffmpeg.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BKE_WRITEFFMPEG_H__
-#define __BKE_WRITEFFMPEG_H__
+#pragma once
/** \file
* \ingroup bke
@@ -100,5 +99,3 @@ void BKE_ffmpeg_context_free(void *context_v);
# endif
#endif
-
-#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index d702da55ea8..ada341ff570 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -100,6 +100,7 @@ set(SRC
intern/context.c
intern/crazyspace.c
intern/curve.c
+ intern/curve_bevel.c
intern/curve_decimate.c
intern/curve_deform.c
intern/curveprofile.c
@@ -134,6 +135,7 @@ set(SRC
intern/idtype.c
intern/image.c
intern/image_gen.c
+ intern/image_gpu.c
intern/image_save.c
intern/ipo.c
intern/kelvinlet.c
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 8d8301362b3..c572b1dacf0 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -713,8 +713,8 @@ CCGError ccgSubSurf_syncFace(
if (f) {
if (f->numVerts != numVerts ||
- memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
- memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts)) {
+ memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) != 0 ||
+ memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts) != 0) {
topologyChanged = 1;
}
}
@@ -784,8 +784,8 @@ CCGError ccgSubSurf_syncFace(
if (f) {
if (f->numVerts != numVerts ||
- memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) ||
- memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts)) {
+ memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) != 0 ||
+ memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts) != 0) {
topologyChanged = 1;
}
}
@@ -1543,7 +1543,7 @@ void CCG_key(CCGKey *key, const CCGSubSurf *ss, int level)
/* if normals are present, always the last three floats of an
* element */
if (key->has_normals) {
- key->normal_offset = key->elem_size - sizeof(float) * 3;
+ key->normal_offset = key->elem_size - sizeof(float[3]);
}
else {
key->normal_offset = -1;
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h
index 2e5100db6de..e1805a9c512 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __CCGSUBSURF_H__
-#define __CCGSUBSURF_H__
+#pragma once
/** \file
* \ingroup bke
@@ -210,5 +209,3 @@ void ccgEdgeIterator_next(CCGEdgeIterator *ei);
CCGFace *ccgFaceIterator_getCurrent(CCGFaceIterator *fi);
int ccgFaceIterator_isStopped(CCGFaceIterator *fi);
void ccgFaceIterator_next(CCGFaceIterator *fi);
-
-#endif /* __CCGSUBSURF_H__ */
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_inline.h b/source/blender/blenkernel/intern/CCGSubSurf_inline.h
index 86012bd2a43..8aa1fede57d 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_inline.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf_inline.h
@@ -18,8 +18,7 @@
* \ingroup bke
*/
-#ifndef __CCGSUBSURF_INLINE_H__
-#define __CCGSUBSURF_INLINE_H__
+#pragma once
BLI_INLINE int ccg_gridsize(int level)
{
@@ -274,5 +273,3 @@ BLI_INLINE void VertDataAvg4(float v[],
v[i] = (a[i] + b[i] + c[i] + d[i]) * 0.25f;
}
}
-
-#endif /* __CCGSUBSURF_INLINE_H__ */
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_intern.h b/source/blender/blenkernel/intern/CCGSubSurf_intern.h
index 7c35d2ccfce..82ca22e193a 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_intern.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf_intern.h
@@ -18,8 +18,7 @@
* \ingroup bke
*/
-#ifndef __CCGSUBSURF_INTERN_H__
-#define __CCGSUBSURF_INTERN_H__
+#pragma once
/**
* Definitions which defines internal behavior of CCGSubSurf.
@@ -286,5 +285,3 @@ void ccgSubSurf__dumpCoords(CCGSubSurf *ss);
#endif
#include "CCGSubSurf_inline.h"
-
-#endif /* __CCGSUBSURF_INTERN_H__ */
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index b40cc4e8b9f..63e7933dd56 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -80,11 +80,9 @@
//#define USE_MODIFIER_VALIDATE
#ifdef USE_MODIFIER_VALIDATE
-# define ASSERT_IS_VALID_DM(dm) (BLI_assert((dm == NULL) || (DM_is_valid(dm) == true)))
# define ASSERT_IS_VALID_MESH(mesh) \
(BLI_assert((mesh == NULL) || (BKE_mesh_is_valid(mesh) == true)))
#else
-# define ASSERT_IS_VALID_DM(dm)
# define ASSERT_IS_VALID_MESH(mesh)
#endif
@@ -671,7 +669,7 @@ static float (*get_editbmesh_orco_verts(BMEditMesh *em))[3]
/* these may not really be the orco's, but it's only for preview.
* could be solver better once, but isn't simple */
- orco = MEM_malloc_arrayN(em->bm->totvert, sizeof(float) * 3, "BMEditMesh Orco");
+ orco = MEM_malloc_arrayN(em->bm->totvert, sizeof(float[3]), "BMEditMesh Orco");
BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) {
copy_v3_v3(orco[i], eve->co);
@@ -774,7 +772,7 @@ static void add_orco_mesh(Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orc
layerorco = CustomData_get_layer(&mesh->vdata, layer);
}
- memcpy(layerorco, orco, sizeof(float) * 3 * totvert);
+ memcpy(layerorco, orco, sizeof(float[3]) * totvert);
if (free) {
MEM_freeN(orco);
}
@@ -1373,7 +1371,7 @@ float (*editbmesh_vert_coords_alloc(BMEditMesh *em, int *r_vert_len))[3]
*r_vert_len = em->bm->totvert;
- cos = MEM_malloc_arrayN(em->bm->totvert, 3 * sizeof(float), "vertexcos");
+ cos = MEM_malloc_arrayN(em->bm->totvert, sizeof(float[3]), "vertexcos");
BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) {
copy_v3_v3(cos[i], eve->co);
@@ -2358,32 +2356,6 @@ void DM_debug_print(DerivedMesh *dm)
MEM_freeN(str);
}
-void DM_debug_print_cdlayers(CustomData *data)
-{
- int i;
- const CustomDataLayer *layer;
-
- printf("{\n");
-
- for (i = 0, layer = data->layers; i < data->totlayer; i++, layer++) {
-
- const char *name = CustomData_layertype_name(layer->type);
- const int size = CustomData_sizeof(layer->type);
- const char *structname;
- int structnum;
- CustomData_file_write_info(layer->type, &structname, &structnum);
- printf(" dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
- name,
- structname,
- layer->type,
- (const void *)layer->data,
- size,
- (int)(MEM_allocN_len(layer->data) / size));
- }
-
- printf("}\n");
-}
-
bool DM_is_valid(DerivedMesh *dm)
{
const bool do_verbose = true;
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index fa7eee83a68..85ac2c693cb 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -37,6 +37,7 @@
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
#include "BLI_math.h"
+#include "BLI_session_uuid.h"
#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
@@ -482,6 +483,11 @@ void action_groups_clear_tempflags(bAction *act)
/* *************** Pose channels *************** */
+void BKE_pose_channel_session_uuid_generate(bPoseChannel *pchan)
+{
+ pchan->runtime.session_uuid = BLI_session_uuid_generate();
+}
+
/**
* Return a pointer to the pose channel of the given name
* from this pose.
@@ -524,6 +530,8 @@ bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name)
/* If not, create it and add it */
chan = MEM_callocN(sizeof(bPoseChannel), "verifyPoseChannel");
+ BKE_pose_channel_session_uuid_generate(chan);
+
BLI_strncpy(chan->name, name, sizeof(chan->name));
chan->custom_scale = 1.0f;
@@ -698,6 +706,10 @@ void BKE_pose_copy_data_ex(bPose **dst,
id_us_plus((ID *)pchan->custom);
}
+ if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
+ BKE_pose_channel_session_uuid_generate(pchan);
+ }
+
/* warning, O(n2) here, if done without the hash, but these are rarely used features. */
if (pchan->custom_tx) {
pchan->custom_tx = BKE_pose_channel_find_name(outPose, pchan->custom_tx->name);
@@ -726,7 +738,7 @@ void BKE_pose_copy_data_ex(bPose **dst,
pchan->draw_data = NULL; /* Drawing cache, no need to copy. */
/* Runtime data, no need to copy. */
- memset(&pchan->runtime, 0, sizeof(pchan->runtime));
+ BKE_pose_channel_runtime_reset_on_copy(&pchan->runtime);
}
/* for now, duplicate Bone Groups too when doing this */
@@ -956,6 +968,14 @@ void BKE_pose_channel_runtime_reset(bPoseChannel_Runtime *runtime)
memset(runtime, 0, sizeof(*runtime));
}
+/* Reset all non-persistent fields. */
+void BKE_pose_channel_runtime_reset_on_copy(bPoseChannel_Runtime *runtime)
+{
+ const SessionUUID uuid = runtime->session_uuid;
+ memset(runtime, 0, sizeof(*runtime));
+ runtime->session_uuid = uuid;
+}
+
/** Deallocates runtime cache of a pose channel */
void BKE_pose_channel_runtime_free(bPoseChannel_Runtime *runtime)
{
@@ -1692,3 +1712,30 @@ void what_does_obaction(Object *ob,
BKE_animsys_evaluate_animdata(&workob->id, &adt, anim_eval_context, ADT_RECALC_ANIM, false);
}
}
+
+void BKE_pose_check_uuids_unique_and_report(const bPose *pose)
+{
+ if (pose == NULL) {
+ return;
+ }
+
+ struct GSet *used_uuids = BLI_gset_new(
+ BLI_session_uuid_ghash_hash, BLI_session_uuid_ghash_compare, "sequencer used uuids");
+
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
+ const SessionUUID *session_uuid = &pchan->runtime.session_uuid;
+ if (!BLI_session_uuid_is_generated(session_uuid)) {
+ printf("Pose channel %s does not have UUID generated.\n", pchan->name);
+ continue;
+ }
+
+ if (BLI_gset_lookup(used_uuids, session_uuid) != NULL) {
+ printf("Pose channel %s has duplicate UUID generated.\n", pchan->name);
+ continue;
+ }
+
+ BLI_gset_insert(used_uuids, (void *)session_uuid);
+ }
+
+ BLI_gset_free(used_uuids, NULL);
+}
diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c
index 61181278c60..038a0d14ddb 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -505,24 +505,43 @@ static bool animpath_matches_basepath(const char path[], const char basepath[])
return (path && basepath) && STRPREFIX(path, basepath);
}
+static void animpath_update_basepath(FCurve *fcu,
+ const char *old_basepath,
+ const char *new_basepath)
+{
+ BLI_assert(animpath_matches_basepath(fcu->rna_path, old_basepath));
+ if (STREQ(old_basepath, new_basepath)) {
+ return;
+ }
+
+ char *new_path = BLI_sprintfN("%s%s", new_basepath, fcu->rna_path + strlen(old_basepath));
+ MEM_freeN(fcu->rna_path);
+ fcu->rna_path = new_path;
+}
+
/* Move F-Curves in src action to dst action, setting up all the necessary groups
* for this to happen, but only if the F-Curves being moved have the appropriate
* "base path".
* - This is used when data moves from one data-block to another, causing the
* F-Curves to need to be moved over too
*/
-void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const char basepath[])
+static void action_move_fcurves_by_basepath(bAction *srcAct,
+ bAction *dstAct,
+ const char *src_basepath,
+ const char *dst_basepath)
{
FCurve *fcu, *fcn = NULL;
/* sanity checks */
- if (ELEM(NULL, srcAct, dstAct, basepath)) {
+ if (ELEM(NULL, srcAct, dstAct, src_basepath, dst_basepath)) {
if (G.debug & G_DEBUG) {
CLOG_ERROR(&LOG,
- "srcAct: %p, dstAct: %p, basepath: %p has insufficient info to work with",
+ "srcAct: %p, dstAct: %p, src_basepath: %p, dst_basepath: %p has insufficient "
+ "info to work with",
(void *)srcAct,
(void *)dstAct,
- (void *)basepath);
+ (void *)src_basepath,
+ (void *)dst_basepath);
}
return;
}
@@ -540,7 +559,7 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha
/* should F-Curve be moved over?
* - we only need the start of the path to match basepath
*/
- if (animpath_matches_basepath(fcu->rna_path, basepath)) {
+ if (animpath_matches_basepath(fcu->rna_path, src_basepath)) {
bActionGroup *agrp = NULL;
/* if grouped... */
@@ -562,6 +581,8 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha
/* perform the migration now */
action_groups_remove_channel(srcAct, fcu);
+ animpath_update_basepath(fcu, src_basepath, dst_basepath);
+
if (agrp) {
action_groups_add_channel(dstAct, agrp, fcu);
}
@@ -594,14 +615,31 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha
}
}
+static void animdata_move_drivers_by_basepath(AnimData *srcAdt,
+ AnimData *dstAdt,
+ const char *src_basepath,
+ const char *dst_basepath)
+{
+ LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, &srcAdt->drivers) {
+ if (animpath_matches_basepath(fcu->rna_path, src_basepath)) {
+ animpath_update_basepath(fcu, src_basepath, dst_basepath);
+ BLI_remlink(&srcAdt->drivers, fcu);
+ BLI_addtail(&dstAdt->drivers, fcu);
+
+ /* TODO: add depsgraph flushing calls? */
+ }
+ }
+}
+
/* Transfer the animation data from srcID to dstID where the srcID
* animation data is based off "basepath", creating new AnimData and
- * associated data as necessary
+ * associated data as necessary.
+ *
+ * basepaths is a list of AnimationBasePathChange.
*/
-void BKE_animdata_separate_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBase *basepaths)
+void BKE_animdata_transfer_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBase *basepaths)
{
AnimData *srcAdt = NULL, *dstAdt = NULL;
- LinkData *ld;
/* sanity checks */
if (ELEM(NULL, srcID, dstID)) {
@@ -643,35 +681,19 @@ void BKE_animdata_separate_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBa
}
/* loop over base paths, trying to fix for each one... */
- for (ld = basepaths->first; ld; ld = ld->next) {
- const char *basepath = (const char *)ld->data;
- action_move_fcurves_by_basepath(srcAdt->action, dstAdt->action, basepath);
+ LISTBASE_FOREACH (const AnimationBasePathChange *, basepath_change, basepaths) {
+ action_move_fcurves_by_basepath(srcAdt->action,
+ dstAdt->action,
+ basepath_change->src_basepath,
+ basepath_change->dst_basepath);
}
}
/* drivers */
if (srcAdt->drivers.first) {
- FCurve *fcu, *fcn = NULL;
-
- /* check each driver against all the base paths to see if any should go */
- for (fcu = srcAdt->drivers.first; fcu; fcu = fcn) {
- fcn = fcu->next;
-
- /* try each basepath in turn, but stop on the first one which works */
- for (ld = basepaths->first; ld; ld = ld->next) {
- const char *basepath = (const char *)ld->data;
-
- if (animpath_matches_basepath(fcu->rna_path, basepath)) {
- /* just need to change lists */
- BLI_remlink(&srcAdt->drivers, fcu);
- BLI_addtail(&dstAdt->drivers, fcu);
-
- /* TODO: add depsgraph flushing calls? */
-
- /* can stop now, as moved already */
- break;
- }
- }
+ LISTBASE_FOREACH (const AnimationBasePathChange *, basepath_change, basepaths) {
+ animdata_move_drivers_by_basepath(
+ srcAdt, dstAdt, basepath_change->src_basepath, basepath_change->dst_basepath);
}
}
}
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index ea5a4bd99d1..5b5e32f1d81 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1150,7 +1150,7 @@ static int nlaevalchan_validate_index(NlaEvalChannel *nec, int index)
return 0;
}
-/* Initialise default values for NlaEvalChannel from the property data. */
+/* Initialize default values for NlaEvalChannel from the property data. */
static void nlaevalchan_get_default_values(NlaEvalChannel *nec, float *r_values)
{
PointerRNA *ptr = &nec->key.ptr;
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index bf04603aa46..631ce4edd20 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1382,7 +1382,7 @@ void get_objectspace_bone_matrix(struct Bone *bone,
}
/* Convert World-Space Matrix to Pose-Space Matrix */
-void BKE_armature_mat_world_to_pose(Object *ob, float inmat[4][4], float outmat[4][4])
+void BKE_armature_mat_world_to_pose(Object *ob, const float inmat[4][4], float outmat[4][4])
{
float obmat[4][4];
@@ -1674,7 +1674,9 @@ void BKE_bone_parent_transform_apply(const struct BoneParentTransform *bpt,
/* Convert Pose-Space Matrix to Bone-Space Matrix.
* NOTE: this cannot be used to convert to pose-space transforms of the supplied
* pose-channel into its local space (i.e. 'visual'-keyframing) */
-void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
+void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan,
+ const float inmat[4][4],
+ float outmat[4][4])
{
BoneParentTransform bpt;
@@ -1684,7 +1686,9 @@ void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[4][4], float
}
/* Convert Bone-Space Matrix to Pose-Space Matrix. */
-void BKE_armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
+void BKE_armature_mat_bone_to_pose(bPoseChannel *pchan,
+ const float inmat[4][4],
+ float outmat[4][4])
{
BoneParentTransform bpt;
@@ -1720,7 +1724,7 @@ void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], fl
void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph,
Object *ob,
bPoseChannel *pchan,
- float inmat[4][4],
+ const float inmat[4][4],
float outmat[4][4])
{
bPoseChannel work_pchan = *pchan;
@@ -1741,7 +1745,7 @@ void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph,
/**
* Same as #BKE_object_mat3_to_rot().
*/
-void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], bool use_compat)
+void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, const float mat[3][3], bool use_compat)
{
BLI_ASSERT_UNIT_M3(mat);
@@ -1766,17 +1770,17 @@ void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], bool use_compat
/**
* Same as #BKE_object_rot_to_mat3().
*/
-void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3])
+void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float r_mat[3][3])
{
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
if (pchan->rotmode > 0) {
/* euler rotations (will cause gimble lock,
* but this can be alleviated a bit with rotation orders) */
- eulO_to_mat3(mat, pchan->eul, pchan->rotmode);
+ eulO_to_mat3(r_mat, pchan->eul, pchan->rotmode);
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
/* axis-angle - not really that great for 3D-changing orientations */
- axis_angle_to_mat3(mat, pchan->rotAxis, pchan->rotAngle);
+ axis_angle_to_mat3(r_mat, pchan->rotAxis, pchan->rotAngle);
}
else {
/* quats are normalized before use to eliminate scaling issues */
@@ -1786,7 +1790,7 @@ void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3])
* since this was kindof evil in some cases but if this proves to be too problematic,
* switch back to the old system of operating directly on the stored copy. */
normalize_qt_qt(quat, pchan->quat);
- quat_to_mat3(mat, quat);
+ quat_to_mat3(r_mat, quat);
}
}
@@ -1794,7 +1798,7 @@ void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3])
* Apply a 4x4 matrix to the pose bone,
* similar to #BKE_object_apply_mat4().
*/
-void BKE_pchan_apply_mat4(bPoseChannel *pchan, float mat[4][4], bool use_compat)
+void BKE_pchan_apply_mat4(bPoseChannel *pchan, const float mat[4][4], bool use_compat)
{
float rot[3][3];
mat4_to_loc_rot_size(pchan->loc, rot, pchan->size, mat);
@@ -1998,7 +2002,7 @@ void mat3_vec_to_roll(const float mat[3][3], const float vec[3], float *r_roll)
* └ -2 * x * z, x^2 - z^2 ┘
* </pre>
*/
-void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat[3][3])
+void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float r_mat[3][3])
{
#define THETA_THRESHOLD_NEGY 1.0e-9f
#define THETA_THRESHOLD_NEGY_CLOSE 1.0e-5f
@@ -2052,18 +2056,18 @@ void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat
axis_angle_normalized_to_mat3(rMatrix, nor, roll);
/* Combine and output result */
- mul_m3_m3m3(mat, rMatrix, bMatrix);
+ mul_m3_m3m3(r_mat, rMatrix, bMatrix);
#undef THETA_THRESHOLD_NEGY
#undef THETA_THRESHOLD_NEGY_CLOSE
}
-void vec_roll_to_mat3(const float vec[3], const float roll, float mat[3][3])
+void vec_roll_to_mat3(const float vec[3], const float roll, float r_mat[3][3])
{
float nor[3];
normalize_v3_v3(nor, vec);
- vec_roll_to_mat3_normalized(nor, roll, mat);
+ vec_roll_to_mat3_normalized(nor, roll, r_mat);
}
/** \} */
@@ -2201,7 +2205,7 @@ static void pose_proxy_sync(Object *ob, Object *from, int layer_protected)
pchan->mpath = NULL;
/* Reset runtime data, we don't want to share that with the proxy. */
- BKE_pose_channel_runtime_reset(&pchanw.runtime);
+ BKE_pose_channel_runtime_reset_on_copy(&pchanw.runtime);
/* this is freed so copy a copy, else undo crashes */
if (pchanw.prop) {
@@ -2418,8 +2422,10 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
/** \name Pose Solver
* \{ */
-/* loc/rot/size to given mat4 */
-void BKE_pchan_to_mat4(const bPoseChannel *pchan, float chan_mat[4][4])
+/**
+ * Convert the loc/rot/size to \a r_chanmat (typically #bPoseChannel.chan_mat).
+ */
+void BKE_pchan_to_mat4(const bPoseChannel *pchan, float r_chanmat[4][4])
{
float smat[3][3];
float rmat[3][3];
@@ -2433,12 +2439,12 @@ void BKE_pchan_to_mat4(const bPoseChannel *pchan, float chan_mat[4][4])
/* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */
mul_m3_m3m3(tmat, rmat, smat);
- copy_m4_m3(chan_mat, tmat);
+ copy_m4_m3(r_chanmat, tmat);
/* prevent action channels breaking chains */
/* need to check for bone here, CONSTRAINT_TYPE_ACTION uses this call */
if ((pchan->bone == NULL) || !(pchan->bone->flag & BONE_CONNECTED)) {
- copy_v3_v3(chan_mat[3], pchan->loc);
+ copy_v3_v3(r_chanmat[3], pchan->loc);
}
}
@@ -2576,7 +2582,7 @@ void BKE_pose_where_is(struct Depsgraph *depsgraph, Scene *scene, Object *ob)
}
/* 2a. construct the IK tree (standard IK) */
- BIK_initialize_tree(depsgraph, scene, ob, ctime);
+ BIK_init_tree(depsgraph, scene, ob, ctime);
/* 2b. construct the Spline IK trees
* - this is not integrated as an IK plugin, since it should be able
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index d66991aed70..97c717572bc 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -658,7 +658,7 @@ void BKE_pose_eval_init_ik(struct Depsgraph *depsgraph, Scene *scene, Object *ob
return;
}
/* construct the IK tree (standard IK) */
- BIK_initialize_tree(depsgraph, scene, object, ctime);
+ BIK_init_tree(depsgraph, scene, object, ctime);
/* construct the Spline IK trees
* - this is not integrated as an IK plugin, since it should be able
* to function in conjunction with standard IK. */
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index a0da1b1677d..a7324ffe738 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -873,7 +873,7 @@ static Object *boid_find_ground(BoidBrainData *bbd,
return bpa->ground;
}
- float zvec[3] = {0.0f, 0.0f, 2000.0f};
+ const float zvec[3] = {0.0f, 0.0f, 2000.0f};
ParticleCollision col;
ColliderCache *coll;
BVHTreeRayHit hit;
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index e2d17f34992..1833ad5a748 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -165,7 +165,7 @@ void BKE_bpath_relative_rebase(Main *bmain,
ReportList *reports)
{
BPathRebase_Data data = {NULL};
- const int flag = BKE_BPATH_TRAVERSE_SKIP_LIBRARY;
+ const int flag = (BKE_BPATH_TRAVERSE_SKIP_LIBRARY | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE);
BLI_assert(basedir_src[0] != '\0');
BLI_assert(basedir_dst[0] != '\0');
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 355bdfd10fd..af186dc4940 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -503,7 +503,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.4f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->input_samples = 10;
brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
@@ -557,7 +557,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
/* Curve. */
custom_curve = brush->gpencil_settings->curve_sensitivity;
BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(custom_curve);
+ BKE_curvemapping_init(custom_curve);
brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INK);
brush->gpencil_settings->icon_id = GP_BRUSH_ICON_INK;
@@ -594,7 +594,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
/* Curve. */
custom_curve = brush->gpencil_settings->curve_sensitivity;
BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(custom_curve);
+ BKE_curvemapping_init(custom_curve);
brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INKNOISE);
brush->gpencil_settings->icon_id = GP_BRUSH_ICON_INKNOISE;
@@ -631,7 +631,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
/* Curve. */
custom_curve = brush->gpencil_settings->curve_sensitivity;
BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(custom_curve);
+ BKE_curvemapping_init(custom_curve);
brush_gpencil_curvemap_reset(custom_curve->cm, 4, GPCURVE_PRESET_MARKER);
brush->gpencil_settings->icon_id = GP_BRUSH_ICON_MARKER;
@@ -667,12 +667,12 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
/* Curve. */
custom_curve = brush->gpencil_settings->curve_sensitivity;
BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(custom_curve);
+ BKE_curvemapping_init(custom_curve);
brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_CHISEL_SENSIVITY);
custom_curve = brush->gpencil_settings->curve_strength;
BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(custom_curve);
+ BKE_curvemapping_init(custom_curve);
brush_gpencil_curvemap_reset(custom_curve->cm, 4, GPCURVE_PRESET_CHISEL_STRENGTH);
brush->gpencil_settings->icon_id = GP_BRUSH_ICON_CHISEL;
@@ -686,7 +686,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag &= ~GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 1.0f;
- brush->gpencil_settings->flag &= ~GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag &= ~GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->input_samples = 10;
brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
@@ -717,7 +717,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.4f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->input_samples = 10;
brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
@@ -760,7 +760,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.6f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->input_samples = 10;
brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
@@ -812,7 +812,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->draw_strength = 0.5f;
brush->gpencil_settings->flag |= GP_BRUSH_DEFAULT_ERASER;
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_SOFT;
brush->gpencil_tool = GPAINT_TOOL_ERASE;
brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_SOFT;
@@ -859,7 +859,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.8f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
zero_v3(brush->secondary_rgb);
break;
@@ -872,7 +872,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.8f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
zero_v3(brush->secondary_rgb);
break;
@@ -885,7 +885,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.8f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
zero_v3(brush->secondary_rgb);
break;
@@ -898,7 +898,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.8f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
zero_v3(brush->secondary_rgb);
break;
@@ -911,7 +911,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.8f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
zero_v3(brush->secondary_rgb);
break;
@@ -924,7 +924,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.8f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
zero_v3(brush->secondary_rgb);
break;
@@ -937,7 +937,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.3f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_flag = GP_SCULPT_FLAG_SMOOTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
@@ -951,7 +951,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.3f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_flag = GP_SCULPT_FLAG_SMOOTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
@@ -965,7 +965,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.5f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
break;
@@ -978,7 +978,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->size = 25.0f;
brush->gpencil_settings->draw_strength = 0.3f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
break;
@@ -991,7 +991,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.3f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
break;
@@ -1004,7 +1004,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.3f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
break;
@@ -1017,7 +1017,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.5f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
break;
@@ -1030,7 +1030,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.5f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
break;
@@ -1043,7 +1043,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->size = 25.0f;
brush->gpencil_settings->draw_strength = 1.0f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
break;
@@ -1056,7 +1056,7 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.8f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
break;
@@ -1566,6 +1566,12 @@ void BKE_brush_sculpt_reset(Brush *br)
br->flag &= ~BRUSH_SPACE;
br->flag &= ~BRUSH_SPACE_ATTEN;
break;
+ case SCULPT_TOOL_BOUNDARY:
+ br->flag &= ~BRUSH_ALPHA_PRESSURE;
+ br->flag &= ~BRUSH_SPACE;
+ br->flag &= ~BRUSH_SPACE_ATTEN;
+ br->curve_preset = BRUSH_CURVE_CONSTANT;
+ break;
case SCULPT_TOOL_DRAW_FACE_SETS:
br->alpha = 0.5f;
br->flag &= ~BRUSH_ALPHA_PRESSURE;
@@ -1660,6 +1666,7 @@ void BKE_brush_sculpt_reset(Brush *br)
case SCULPT_TOOL_ROTATE:
case SCULPT_TOOL_ELASTIC_DEFORM:
case SCULPT_TOOL_POSE:
+ case SCULPT_TOOL_BOUNDARY:
case SCULPT_TOOL_SLIDE_RELAX:
br->add_col[0] = 1.0f;
br->add_col[1] = 0.95f;
@@ -1740,7 +1747,7 @@ float BKE_brush_sample_tex_3d(const Scene *scene,
}
else if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) {
float rotation = -mtex->rot;
- float point_2d[2] = {point[0], point[1]};
+ const float point_2d[2] = {point[0], point[1]};
float x, y;
float co[3];
@@ -1770,7 +1777,7 @@ float BKE_brush_sample_tex_3d(const Scene *scene,
}
else {
float rotation = -mtex->rot;
- float point_2d[2] = {point[0], point[1]};
+ const float point_2d[2] = {point[0], point[1]};
float x = 0.0f, y = 0.0f; /* Quite warnings */
float invradius = 1.0f; /* Quite warnings */
float co[3];
@@ -1853,7 +1860,7 @@ float BKE_brush_sample_masktex(
}
if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) {
float rotation = -mtex->rot;
- float point_2d[2] = {point[0], point[1]};
+ const float point_2d[2] = {point[0], point[1]};
float x, y;
float co[3];
@@ -1883,7 +1890,7 @@ float BKE_brush_sample_masktex(
}
else {
float rotation = -mtex->rot;
- float point_2d[2] = {point[0], point[1]};
+ const float point_2d[2] = {point[0], point[1]};
float x = 0.0f, y = 0.0f; /* Quite warnings */
float invradius = 1.0f; /* Quite warnings */
float co[3];
@@ -2274,7 +2281,7 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary, bool
int half = side / 2;
int i, j;
- BKE_curvemapping_initialize(br->curve);
+ BKE_curvemapping_init(br->curve);
texcache = BKE_brush_gen_texture_cache(br, half, secondary);
im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect");
im->x = im->y = side;
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 93794eb9709..bea8fdd5719 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -717,11 +717,14 @@ BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
/* printf("BVHTree built and saved on cache\n"); */
BVHCache *bvh_cache = *bvh_cache_p;
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
- bvhcache_unlock(bvh_cache, lock_started);
in_cache = true;
}
}
+ if (bvh_cache_p) {
+ bvhcache_unlock(*bvh_cache_p, lock_started);
+ }
+
/* Setup BVHTreeFromMesh */
bvhtree_from_mesh_verts_setup_data(data, tree, in_cache, vert, vert_allocated);
@@ -929,11 +932,14 @@ BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
/* Save on cache for later use */
/* printf("BVHTree built and saved on cache\n"); */
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
- bvhcache_unlock(bvh_cache, lock_started);
in_cache = true;
}
}
+ if (bvh_cache_p) {
+ bvhcache_unlock(*bvh_cache_p, lock_started);
+ }
+
/* Setup BVHTreeFromMesh */
bvhtree_from_mesh_edges_setup_data(
data, tree, in_cache, vert, vert_allocated, edge, edge_allocated);
@@ -1058,11 +1064,14 @@ BVHTree *bvhtree_from_mesh_faces_ex(BVHTreeFromMesh *data,
/* printf("BVHTree built and saved on cache\n"); */
BVHCache *bvh_cache = *bvh_cache_p;
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
- bvhcache_unlock(bvh_cache, lock_started);
in_cache = true;
}
}
+ if (bvh_cache_p) {
+ bvhcache_unlock(*bvh_cache_p, lock_started);
+ }
+
/* Setup BVHTreeFromMesh */
bvhtree_from_mesh_faces_setup_data(
data, tree, in_cache, vert, vert_allocated, face, face_allocated);
@@ -1298,11 +1307,14 @@ BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
if (bvh_cache_p) {
BVHCache *bvh_cache = *bvh_cache_p;
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
- bvhcache_unlock(bvh_cache, lock_started);
in_cache = true;
}
}
+ if (bvh_cache_p) {
+ bvhcache_unlock(*bvh_cache_p, lock_started);
+ }
+
/* Setup BVHTreeFromMesh */
bvhtree_from_mesh_looptri_setup_data(data,
tree,
@@ -1428,8 +1440,6 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
mesh->medge, mesh->totedge, mesh->mvert, verts_len, &loose_vert_len);
}
- /* TODO: a global mutex lock held during the expensive operation of
- * building the BVH tree is really bad for performance. */
tree = bvhtree_from_mesh_verts_ex(data,
mesh->mvert,
verts_len,
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index da9dab36044..9ad6ae84c5c 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -61,6 +61,8 @@ static void cache_file_init_data(ID *id)
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cache_file, id));
cache_file->scale = 1.0f;
+ cache_file->velocity_unit = CACHEFILE_VELOCITY_UNIT_SECOND;
+ BLI_strncpy(cache_file->velocity_name, ".velocities", sizeof(cache_file->velocity_name));
}
static void cache_file_copy_data(Main *UNUSED(bmain),
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 7c0e4064cdb..d8b4150b2b1 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -186,9 +186,8 @@ int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey)
if (sizex >= sizey) {
return CAMERA_SENSOR_FIT_HOR;
}
- else {
- return CAMERA_SENSOR_FIT_VERT;
- }
+
+ return CAMERA_SENSOR_FIT_VERT;
}
return sensor_fit;
@@ -636,64 +635,63 @@ static bool camera_frame_fit_calc_from_data(CameraParams *params,
return true;
}
- else {
- float plane_isect_1[3], plane_isect_1_no[3], plane_isect_1_other[3];
- float plane_isect_2[3], plane_isect_2_no[3], plane_isect_2_other[3];
- float plane_isect_pt_1[3], plane_isect_pt_2[3];
+ float plane_isect_1[3], plane_isect_1_no[3], plane_isect_1_other[3];
+ float plane_isect_2[3], plane_isect_2_no[3], plane_isect_2_other[3];
- /* apply the dist-from-plane's to the transformed plane points */
- for (i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) {
- float co[3];
- mul_v3_v3fl(co, data->normal_tx[i], sqrtf_signed(data->dist_vals_sq[i]));
- plane_from_point_normal_v3(plane_tx[i], co, data->normal_tx[i]);
- }
+ float plane_isect_pt_1[3], plane_isect_pt_2[3];
- if ((!isect_plane_plane_v3(plane_tx[0], plane_tx[2], plane_isect_1, plane_isect_1_no)) ||
- (!isect_plane_plane_v3(plane_tx[1], plane_tx[3], plane_isect_2, plane_isect_2_no))) {
- return false;
- }
+ /* apply the dist-from-plane's to the transformed plane points */
+ for (i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) {
+ float co[3];
+ mul_v3_v3fl(co, data->normal_tx[i], sqrtf_signed(data->dist_vals_sq[i]));
+ plane_from_point_normal_v3(plane_tx[i], co, data->normal_tx[i]);
+ }
- add_v3_v3v3(plane_isect_1_other, plane_isect_1, plane_isect_1_no);
- add_v3_v3v3(plane_isect_2_other, plane_isect_2, plane_isect_2_no);
+ if ((!isect_plane_plane_v3(plane_tx[0], plane_tx[2], plane_isect_1, plane_isect_1_no)) ||
+ (!isect_plane_plane_v3(plane_tx[1], plane_tx[3], plane_isect_2, plane_isect_2_no))) {
+ return false;
+ }
- if (isect_line_line_v3(plane_isect_1,
- plane_isect_1_other,
- plane_isect_2,
- plane_isect_2_other,
- plane_isect_pt_1,
- plane_isect_pt_2) != 0) {
- float cam_plane_no[3];
- float plane_isect_delta[3];
- float plane_isect_delta_len;
+ add_v3_v3v3(plane_isect_1_other, plane_isect_1, plane_isect_1_no);
+ add_v3_v3v3(plane_isect_2_other, plane_isect_2, plane_isect_2_no);
- float shift_fac = BKE_camera_sensor_size(
- params->sensor_fit, params->sensor_x, params->sensor_y) /
- params->lens;
+ if (isect_line_line_v3(plane_isect_1,
+ plane_isect_1_other,
+ plane_isect_2,
+ plane_isect_2_other,
+ plane_isect_pt_1,
+ plane_isect_pt_2) != 0) {
+ float cam_plane_no[3];
+ float plane_isect_delta[3];
+ float plane_isect_delta_len;
- /* we want (0, 0, -1) transformed by camera_rotmat, this is a quicker shortcut. */
- negate_v3_v3(cam_plane_no, data->camera_rotmat[2]);
+ float shift_fac = BKE_camera_sensor_size(
+ params->sensor_fit, params->sensor_x, params->sensor_y) /
+ params->lens;
- sub_v3_v3v3(plane_isect_delta, plane_isect_pt_2, plane_isect_pt_1);
- plane_isect_delta_len = len_v3(plane_isect_delta);
+ /* we want (0, 0, -1) transformed by camera_rotmat, this is a quicker shortcut. */
+ negate_v3_v3(cam_plane_no, data->camera_rotmat[2]);
- if (dot_v3v3(plane_isect_delta, cam_plane_no) > 0.0f) {
- copy_v3_v3(r_co, plane_isect_pt_1);
+ sub_v3_v3v3(plane_isect_delta, plane_isect_pt_2, plane_isect_pt_1);
+ plane_isect_delta_len = len_v3(plane_isect_delta);
- /* offset shift */
- normalize_v3(plane_isect_1_no);
- madd_v3_v3fl(r_co, plane_isect_1_no, params->shifty * plane_isect_delta_len * shift_fac);
- }
- else {
- copy_v3_v3(r_co, plane_isect_pt_2);
+ if (dot_v3v3(plane_isect_delta, cam_plane_no) > 0.0f) {
+ copy_v3_v3(r_co, plane_isect_pt_1);
- /* offset shift */
- normalize_v3(plane_isect_2_no);
- madd_v3_v3fl(r_co, plane_isect_2_no, params->shiftx * plane_isect_delta_len * shift_fac);
- }
+ /* offset shift */
+ normalize_v3(plane_isect_1_no);
+ madd_v3_v3fl(r_co, plane_isect_1_no, params->shifty * plane_isect_delta_len * shift_fac);
+ }
+ else {
+ copy_v3_v3(r_co, plane_isect_pt_2);
- return true;
+ /* offset shift */
+ normalize_v3(plane_isect_2_no);
+ madd_v3_v3fl(r_co, plane_isect_2_no, params->shiftx * plane_isect_delta_len * shift_fac);
}
+
+ return true;
}
return false;
@@ -775,11 +773,10 @@ static void camera_stereo3d_model_matrix(const Object *camera,
camera_model_matrix(camera, r_modelmat);
return;
}
- else {
- float size[3];
- mat4_to_size(size, camera->obmat);
- size_to_mat4(sizemat, size);
- }
+
+ float size[3];
+ mat4_to_size(size, camera->obmat);
+ size_to_mat4(sizemat, size);
if (pivot == CAM_S3D_PIVOT_CENTER) {
fac = 0.5f;
@@ -931,9 +928,8 @@ bool BKE_camera_multiview_spherical_stereo(const RenderData *rd, const Object *c
if (camera->type != OB_CAMERA) {
return false;
}
- else {
- cam = camera->data;
- }
+
+ cam = camera->data;
if ((rd->views_format == SCE_VIEWS_FORMAT_STEREO_3D) && ELEM(cam->type, CAM_PANO, CAM_PERSP) &&
((cam->stereo.flag & CAM_S3D_SPHERICAL) != 0)) {
@@ -984,13 +980,12 @@ Object *BKE_camera_multiview_render(const Scene *scene, Object *camera, const ch
if (!is_multiview) {
return camera;
}
- else if (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D) {
+ if (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D) {
return camera;
}
- else { /* SCE_VIEWS_FORMAT_MULTIVIEW */
- const char *suffix = BKE_scene_multiview_view_suffix_get(&scene->r, viewname);
- return camera_multiview_advanced(scene, camera, suffix);
- }
+ /* SCE_VIEWS_FORMAT_MULTIVIEW */
+ const char *suffix = BKE_scene_multiview_view_suffix_get(&scene->r, viewname);
+ return camera_multiview_advanced(scene, camera, suffix);
}
static float camera_stereo3d_shift_x(const Object *camera, const char *viewname)
@@ -1044,12 +1039,11 @@ float BKE_camera_multiview_shift_x(const RenderData *rd,
if (!is_multiview) {
return data->shiftx;
}
- else if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW) {
+ if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW) {
return data->shiftx;
}
- else { /* SCE_VIEWS_SETUP_BASIC */
- return camera_stereo3d_shift_x(camera, viewname);
- }
+ /* SCE_VIEWS_SETUP_BASIC */
+ return camera_stereo3d_shift_x(camera, viewname);
}
void BKE_camera_multiview_params(const RenderData *rd,
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 467bd68c631..027761335b0 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -825,7 +825,7 @@ static int cloth_from_object(
MVert *mvert = NULL;
ClothVertex *verts = NULL;
float(*shapekey_rest)[3] = NULL;
- float tnull[3] = {0, 0, 0};
+ const float tnull[3] = {0, 0, 0};
// If we have a clothObject, free it.
if (clmd->clothObject != NULL) {
@@ -1355,7 +1355,7 @@ BLI_INLINE void cross_identity_v3(float r[3][3], const float v[3])
r[2][1] = -v[0];
}
-BLI_INLINE void madd_m3_m3fl(float r[3][3], float m[3][3], float f)
+BLI_INLINE void madd_m3_m3fl(float r[3][3], const float m[3][3], float f)
{
r[0][0] += m[0][0] * f;
r[0][1] += m[0][1] * f;
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 6118325c231..0d65ee5faa3 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -408,9 +408,9 @@ static Collection *collection_duplicate_recursive(Main *bmain,
}
if (do_objects) {
- /* We can loop on collection_old's objects, that list is currently identical the collection_new
- * objects, and won't be changed here. */
- LISTBASE_FOREACH (CollectionObject *, cob, &collection_old->gobject) {
+ /* We can loop on collection_old's objects, but have to consider it mutable because with master
+ * collections collection_old and collection_new are the same data here. */
+ LISTBASE_FOREACH_MUTABLE (CollectionObject *, cob, &collection_old->gobject) {
Object *ob_old = cob->ob;
Object *ob_new = (Object *)ob_old->id.newid;
@@ -540,9 +540,8 @@ const char *BKE_collection_ui_name_get(struct Collection *collection)
if (collection->flag & COLLECTION_IS_MASTER) {
return IFACE_("Scene Collection");
}
- else {
- return collection->id.name + 2;
- }
+
+ return collection->id.name + 2;
}
/** \} */
@@ -617,9 +616,8 @@ Base *BKE_collection_or_layer_objects(const ViewLayer *view_layer, Collection *c
if (collection) {
return BKE_collection_object_cache_get(collection).first;
}
- else {
- return FIRSTBASE(view_layer);
- }
+
+ return FIRSTBASE(view_layer);
}
/** \} */
@@ -671,14 +669,13 @@ static bool collection_object_cyclic_check_internal(Object *object, Collection *
if (dup_collection == collection) {
return true;
}
- else {
- FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (dup_collection, collection_object) {
- if (collection_object_cyclic_check_internal(collection_object, dup_collection)) {
- return true;
- }
+
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (dup_collection, collection_object) {
+ if (collection_object_cyclic_check_internal(collection_object, dup_collection)) {
+ return true;
}
- FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
/* un-flag the object, it's allowed to have the same collection multiple times in parallel */
dup_collection->id.tag |= LIB_TAG_DOIT;
@@ -725,9 +722,8 @@ static Collection *collection_next_find(Main *bmain, Scene *scene, Collection *c
if (scene && collection == scene->master_collection) {
return bmain->collections.first;
}
- else {
- return collection->id.next;
- }
+
+ return collection->id.next;
}
Collection *BKE_collection_object_find(Main *bmain,
@@ -1510,9 +1506,8 @@ bool BKE_collection_objects_select(ViewLayer *view_layer, Collection *collection
if (layer_collection != NULL) {
return BKE_layer_collection_objects_select(view_layer, layer_collection, deselect);
}
- else {
- return collection_objects_select(view_layer, collection, deselect);
- }
+
+ return collection_objects_select(view_layer, collection, deselect);
}
/** \} */
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 31d49dd4508..f358355912b 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -212,7 +212,6 @@ static float compute_collision_point_tri_tri(const float a1[3],
float dist = FLT_MAX;
float tmp_co1[3], tmp_co2[3];
float isect_a[3], isect_b[3];
- int isect_count = 0;
float tmp, tmp_vec[3];
float normal[3], cent[3];
bool backside = false;
@@ -226,38 +225,16 @@ static float compute_collision_point_tri_tri(const float a1[3],
copy_v3_v3(b[2], b3);
/* Find intersections. */
- for (int i = 0; i < 3; i++) {
- if (isect_line_segment_tri_v3(a[i], a[next_ind(i)], b[0], b[1], b[2], &tmp, NULL)) {
- interp_v3_v3v3(isect_a, a[i], a[next_ind(i)], tmp);
- isect_count++;
- }
- }
-
- if (isect_count == 0) {
- for (int i = 0; i < 3; i++) {
- if (isect_line_segment_tri_v3(b[i], b[next_ind(i)], a[0], a[1], a[2], &tmp, NULL)) {
- isect_count++;
- }
- }
- }
- else if (isect_count == 1) {
- for (int i = 0; i < 3; i++) {
- if (isect_line_segment_tri_v3(b[i], b[next_ind(i)], a[0], a[1], a[2], &tmp, NULL)) {
- interp_v3_v3v3(isect_b, b[i], b[next_ind(i)], tmp);
- break;
- }
- }
- }
+ int tri_a_edge_isect_count;
+ const bool is_intersecting = isect_tri_tri_v3_ex(
+ a, b, isect_a, isect_b, &tri_a_edge_isect_count);
/* Determine collision side. */
if (culling) {
normal_tri_v3(normal, b[0], b[1], b[2]);
mid_v3_v3v3v3(cent, b[0], b[1], b[2]);
- if (isect_count == 2) {
- backside = true;
- }
- else if (isect_count == 0) {
+ if (!is_intersecting) {
for (int i = 0; i < 3; i++) {
sub_v3_v3v3(tmp_vec, a[i], cent);
if (dot_v3v3(tmp_vec, normal) < 0.0f) {
@@ -266,12 +243,16 @@ static float compute_collision_point_tri_tri(const float a1[3],
}
}
}
+ else if (tri_a_edge_isect_count != 1) {
+ /* It is not Edge intersection. */
+ backside = true;
+ }
}
else if (use_normal) {
normal_tri_v3(normal, b[0], b[1], b[2]);
}
- if (isect_count == 1) {
+ if (tri_a_edge_isect_count == 1) {
/* Edge intersection. */
copy_v3_v3(r_a, isect_a);
copy_v3_v3(r_b, isect_b);
@@ -383,7 +364,7 @@ static float compute_collision_point_tri_tri(const float a1[3],
}
/* Closest edge. */
- if (isect_count == 0) {
+ if (!is_intersecting) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
isect_seg_seg_v3(a[i], a[next_ind(i)], b[j], b[next_ind(j)], tmp_co1, tmp_co2);
@@ -398,7 +379,7 @@ static float compute_collision_point_tri_tri(const float a1[3],
}
}
- if (isect_count == 0) {
+ if (!is_intersecting) {
sub_v3_v3v3(r_vec, r_a, r_b);
dist = sqrtf(dist);
}
diff --git a/source/blender/blenkernel/intern/colorband.c b/source/blender/blenkernel/intern/colorband.c
index 499b0305c9d..323a2f0cf53 100644
--- a/source/blender/blenkernel/intern/colorband.c
+++ b/source/blender/blenkernel/intern/colorband.c
@@ -587,7 +587,7 @@ static int vergcband(const void *a1, const void *a2)
if (x1->pos > x2->pos) {
return 1;
}
- else if (x1->pos < x2->pos) {
+ if (x1->pos < x2->pos) {
return -1;
}
return 0;
@@ -620,18 +620,17 @@ CBData *BKE_colorband_element_add(struct ColorBand *coba, float position)
if (coba->tot == MAXCOLORBAND) {
return NULL;
}
- else {
- CBData *xnew;
- xnew = &coba->data[coba->tot];
- xnew->pos = position;
+ CBData *xnew;
- if (coba->tot != 0) {
- BKE_colorband_evaluate(coba, position, &xnew->r);
- }
- else {
- zero_v4(&xnew->r);
- }
+ xnew = &coba->data[coba->tot];
+ xnew->pos = position;
+
+ if (coba->tot != 0) {
+ BKE_colorband_evaluate(coba, position, &xnew->r);
+ }
+ else {
+ zero_v4(&xnew->r);
}
coba->tot++;
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 4f4eb8f9f9d..116d8b1a82f 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -603,28 +603,24 @@ static float curvemap_calc_extend(const CurveMapping *cumap,
/* extrapolate horizontally */
return first[1];
}
- else {
- if (cuma->ext_in[0] == 0.0f) {
- return first[1] + cuma->ext_in[1] * 10000.0f;
- }
- else {
- return first[1] + cuma->ext_in[1] * (x - first[0]) / cuma->ext_in[0];
- }
+
+ if (cuma->ext_in[0] == 0.0f) {
+ return first[1] + cuma->ext_in[1] * 10000.0f;
}
+
+ return first[1] + cuma->ext_in[1] * (x - first[0]) / cuma->ext_in[0];
}
- else if (x >= last[0]) {
+ if (x >= last[0]) {
if ((cumap->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
/* extrapolate horizontally */
return last[1];
}
- else {
- if (cuma->ext_out[0] == 0.0f) {
- return last[1] - cuma->ext_out[1] * 10000.0f;
- }
- else {
- return last[1] + cuma->ext_out[1] * (x - last[0]) / cuma->ext_out[0];
- }
+
+ if (cuma->ext_out[0] == 0.0f) {
+ return last[1] - cuma->ext_out[1] * 10000.0f;
}
+
+ return last[1] + cuma->ext_out[1] * (x - last[0]) / cuma->ext_out[0];
}
return 0.0f;
}
@@ -728,14 +724,14 @@ static void curvemap_make_table(const CurveMapping *cumap, CurveMap *cuma)
bezt[a + 1].vec[1][0],
point,
CM_RESOL - 1,
- 2 * sizeof(float));
+ sizeof(float[2]));
BKE_curve_forward_diff_bezier(bezt[a].vec[1][1],
bezt[a].vec[2][1],
bezt[a + 1].vec[0][1],
bezt[a + 1].vec[1][1],
point + 1,
CM_RESOL - 1,
- 2 * sizeof(float));
+ sizeof(float[2]));
}
/* store first and last handle for extrapolation, unit length */
@@ -870,7 +866,7 @@ static int sort_curvepoints(const void *a1, const void *a2)
if (x1->x > x2->x) {
return 1;
}
- else if (x1->x < x2->x) {
+ if (x1->x < x2->x) {
return -1;
}
return 0;
@@ -984,17 +980,16 @@ float BKE_curvemap_evaluateF(const CurveMapping *cumap, const CurveMap *cuma, fl
if (fi < 0.0f || fi > CM_TABLE) {
return curvemap_calc_extend(cumap, cuma, value, &cuma->table[0].x, &cuma->table[CM_TABLE].x);
}
- else {
- if (i < 0) {
- return cuma->table[0].y;
- }
- if (i >= CM_TABLE) {
- return cuma->table[CM_TABLE].y;
- }
- fi = fi - (float)i;
- return (1.0f - fi) * cuma->table[i].y + (fi)*cuma->table[i + 1].y;
+ if (i < 0) {
+ return cuma->table[0].y;
}
+ if (i >= CM_TABLE) {
+ return cuma->table[CM_TABLE].y;
+ }
+
+ fi = fi - (float)i;
+ return (1.0f - fi) * cuma->table[i].y + (fi)*cuma->table[i + 1].y;
}
/* works with curve 'cur' */
@@ -1202,7 +1197,7 @@ int BKE_curvemapping_RGBA_does_something(const CurveMapping *cumap)
return 0;
}
-void BKE_curvemapping_initialize(CurveMapping *cumap)
+void BKE_curvemapping_init(CurveMapping *cumap)
{
int a;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 2ef32895db9..01ce95d9d70 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -537,7 +537,7 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m
MDeformWeight *dw = BKE_defvert_find_index(dv, defgroup);
if (dw && dw->weight > 0.0f) {
/* copy coordinates of point to temporary vector, then add to find average */
- memcpy(tvec, co ? co : bp->vec, 3 * sizeof(float));
+ memcpy(tvec, co ? co : bp->vec, sizeof(float[3]));
add_v3_v3(vec, tvec);
grouped++;
@@ -2404,7 +2404,7 @@ static void armdef_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
}
}
-static void armdef_accumulate_matrix(float obmat[4][4],
+static void armdef_accumulate_matrix(const float obmat[4][4],
const float iobmat[4][4],
const float basemat[4][4],
const float bonemat[4][4],
@@ -5284,9 +5284,8 @@ const bConstraintTypeInfo *BKE_constraint_typeinfo_from_type(int type)
/* there shouldn't be any segfaults here... */
return constraintsTypeInfo[type];
}
- else {
- CLOG_WARN(&LOG, "No valid constraint type-info data available. Type = %i", type);
- }
+
+ CLOG_WARN(&LOG, "No valid constraint type-info data available. Type = %i", type);
return NULL;
}
@@ -5300,9 +5299,8 @@ const bConstraintTypeInfo *BKE_constraint_typeinfo_get(bConstraint *con)
if (con) {
return BKE_constraint_typeinfo_from_type(con->type);
}
- else {
- return NULL;
- }
+
+ return NULL;
}
/* ************************* General Constraints API ************************** */
@@ -5384,9 +5382,8 @@ bool BKE_constraint_remove(ListBase *list, bConstraint *con)
BLI_freelinkN(list, con);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
bool BKE_constraint_remove_ex(ListBase *list, Object *ob, bConstraint *con, bool clear_dep)
@@ -5399,9 +5396,8 @@ bool BKE_constraint_remove_ex(ListBase *list, Object *ob, bConstraint *con, bool
}
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/* ......... */
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 30f021b0e81..e9ba3a5f873 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -255,13 +255,12 @@ static void *ctx_wm_python_context_get(const bContext *C,
if (RNA_struct_is_a(result.ptr.type, member_type)) {
return result.ptr.data;
}
- else {
- CLOG_WARN(&LOG,
- "PyContext '%s' is a '%s', expected a '%s'",
- member,
- RNA_struct_identifier(result.ptr.type),
- RNA_struct_identifier(member_type));
- }
+
+ CLOG_WARN(&LOG,
+ "PyContext '%s' is a '%s', expected a '%s'",
+ member,
+ RNA_struct_identifier(result.ptr.type),
+ RNA_struct_identifier(member_type));
}
}
#else
@@ -360,9 +359,8 @@ static void *ctx_data_pointer_get(const bContext *C, const char *member)
BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
return result.ptr.data;
}
- else {
- return NULL;
- }
+
+ return NULL;
}
static int ctx_data_pointer_verify(const bContext *C, const char *member, void **pointer)
@@ -374,15 +372,14 @@ static int ctx_data_pointer_verify(const bContext *C, const char *member, void *
*pointer = NULL;
return 1;
}
- else if (ctx_data_get((bContext *)C, member, &result) == 1) {
+ if (ctx_data_get((bContext *)C, member, &result) == 1) {
BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
*pointer = result.ptr.data;
return 1;
}
- else {
- *pointer = NULL;
- return 0;
- }
+
+ *pointer = NULL;
+ return 0;
}
static int ctx_data_collection_get(const bContext *C, const char *member, ListBase *list)
@@ -441,9 +438,8 @@ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
return result.ptr;
}
- else {
- return PointerRNA_NULL;
- }
+
+ return PointerRNA_NULL;
}
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
@@ -454,13 +450,12 @@ PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, Stru
if (RNA_struct_is_a(ptr.type, type)) {
return ptr;
}
- else {
- CLOG_WARN(&LOG,
- "member '%s' is '%s', not '%s'",
- member,
- RNA_struct_identifier(ptr.type),
- RNA_struct_identifier(type));
- }
+
+ CLOG_WARN(&LOG,
+ "member '%s' is '%s', not '%s'",
+ member,
+ RNA_struct_identifier(ptr.type),
+ RNA_struct_identifier(type));
}
return PointerRNA_NULL;
@@ -473,9 +468,8 @@ PointerRNA CTX_data_pointer_get_type_silent(const bContext *C, const char *membe
if (ptr.data && RNA_struct_is_a(ptr.type, type)) {
return ptr;
}
- else {
- return PointerRNA_NULL;
- }
+
+ return PointerRNA_NULL;
}
ListBase CTX_data_collection_get(const bContext *C, const char *member)
@@ -486,10 +480,9 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member)
BLI_assert(result.type == CTX_DATA_TYPE_COLLECTION);
return result.list;
}
- else {
- ListBase list = {NULL, NULL};
- return list;
- }
+
+ ListBase list = {NULL, NULL};
+ return list;
}
/* 1:found, -1:found but not set, 0:not found */
@@ -667,9 +660,8 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBas
BLI_freelistN(&list);
return tot;
}
- else {
- return 0;
- }
+
+ return 0;
}
void CTX_data_dir_set(bContextDataResult *result, const char **dir)
@@ -985,9 +977,8 @@ Main *CTX_data_main(const bContext *C)
if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain)) {
return bmain;
}
- else {
- return C->data.main;
- }
+
+ return C->data.main;
}
void CTX_data_main_set(bContext *C, Main *bmain)
@@ -1003,9 +994,8 @@ Scene *CTX_data_scene(const bContext *C)
if (ctx_data_pointer_verify(C, "scene", (void *)&scene)) {
return scene;
}
- else {
- return C->data.scene;
- }
+
+ return C->data.scene;
}
ViewLayer *CTX_data_view_layer(const bContext *C)
@@ -1102,34 +1092,34 @@ enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit,
if (object_mode & OB_MODE_POSE) {
return CTX_MODE_POSE;
}
- else if (object_mode & OB_MODE_SCULPT) {
+ if (object_mode & OB_MODE_SCULPT) {
return CTX_MODE_SCULPT;
}
- else if (object_mode & OB_MODE_WEIGHT_PAINT) {
+ if (object_mode & OB_MODE_WEIGHT_PAINT) {
return CTX_MODE_PAINT_WEIGHT;
}
- else if (object_mode & OB_MODE_VERTEX_PAINT) {
+ if (object_mode & OB_MODE_VERTEX_PAINT) {
return CTX_MODE_PAINT_VERTEX;
}
- else if (object_mode & OB_MODE_TEXTURE_PAINT) {
+ if (object_mode & OB_MODE_TEXTURE_PAINT) {
return CTX_MODE_PAINT_TEXTURE;
}
- else if (object_mode & OB_MODE_PARTICLE_EDIT) {
+ if (object_mode & OB_MODE_PARTICLE_EDIT) {
return CTX_MODE_PARTICLE;
}
- else if (object_mode & OB_MODE_PAINT_GPENCIL) {
+ if (object_mode & OB_MODE_PAINT_GPENCIL) {
return CTX_MODE_PAINT_GPENCIL;
}
- else if (object_mode & OB_MODE_EDIT_GPENCIL) {
+ if (object_mode & OB_MODE_EDIT_GPENCIL) {
return CTX_MODE_EDIT_GPENCIL;
}
- else if (object_mode & OB_MODE_SCULPT_GPENCIL) {
+ if (object_mode & OB_MODE_SCULPT_GPENCIL) {
return CTX_MODE_SCULPT_GPENCIL;
}
- else if (object_mode & OB_MODE_WEIGHT_GPENCIL) {
+ if (object_mode & OB_MODE_WEIGHT_GPENCIL) {
return CTX_MODE_WEIGHT_GPENCIL;
}
- else if (object_mode & OB_MODE_VERTEX_GPENCIL) {
+ if (object_mode & OB_MODE_VERTEX_GPENCIL) {
return CTX_MODE_VERTEX_GPENCIL;
}
}
@@ -1173,9 +1163,8 @@ ToolSettings *CTX_data_tool_settings(const bContext *C)
if (scene) {
return scene->toolsettings;
}
- else {
- return NULL;
- }
+
+ return NULL;
}
int CTX_data_selected_nodes(const bContext *C, ListBase *list)
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index fb424b2d859..45ca89ac47e 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -725,7 +725,7 @@ float BKE_nurb_calc_length(const Nurb *nu, int resolution)
bezt->vec[1][j],
points + j,
resolu,
- 3 * sizeof(float));
+ sizeof(float[3]));
}
prevpntsit = pntsit = points;
@@ -1726,205 +1726,6 @@ static void forward_diff_bezier_cotangent(const float p0[3],
}
}
-/* ***************** BEVEL ****************** */
-
-void BKE_curve_bevel_make(Object *ob, ListBase *disp)
-{
- DispList *dl, *dlnew;
- Curve *bevcu, *cu;
- float *fp, facx, facy, angle, dangle;
- int nr, a;
-
- cu = ob->data;
- BLI_listbase_clear(disp);
-
- /* if a font object is being edited, then do nothing */
- // XXX if ( ob == obedit && ob->type == OB_FONT ) return;
-
- if (cu->bevobj) {
- if (cu->bevobj->type != OB_CURVE) {
- return;
- }
-
- bevcu = cu->bevobj->data;
- if (bevcu->ext1 == 0.0f && bevcu->ext2 == 0.0f) {
- ListBase bevdisp = {NULL, NULL};
- facx = cu->bevobj->scale[0];
- facy = cu->bevobj->scale[1];
-
- if (cu->bevobj->runtime.curve_cache) {
- dl = cu->bevobj->runtime.curve_cache->disp.first;
- }
- else {
- BLI_assert(cu->bevobj->runtime.curve_cache != NULL);
- dl = NULL;
- }
-
- while (dl) {
- if (ELEM(dl->type, DL_POLY, DL_SEGM)) {
- dlnew = MEM_mallocN(sizeof(DispList), "makebevelcurve1");
- *dlnew = *dl;
- dlnew->verts = MEM_malloc_arrayN(
- dl->parts * dl->nr, 3 * sizeof(float), "makebevelcurve1");
- memcpy(dlnew->verts, dl->verts, 3 * sizeof(float) * dl->parts * dl->nr);
-
- if (dlnew->type == DL_SEGM) {
- dlnew->flag |= (DL_FRONT_CURVE | DL_BACK_CURVE);
- }
-
- BLI_addtail(disp, dlnew);
- fp = dlnew->verts;
- nr = dlnew->parts * dlnew->nr;
- while (nr--) {
- fp[2] = fp[1] * facy;
- fp[1] = -fp[0] * facx;
- fp[0] = 0.0;
- fp += 3;
- }
- }
- dl = dl->next;
- }
-
- BKE_displist_free(&bevdisp);
- }
- }
- else if (cu->ext1 == 0.0f && cu->ext2 == 0.0f) {
- /* pass */
- }
- else if (cu->ext2 == 0.0f) {
- dl = MEM_callocN(sizeof(DispList), "makebevelcurve2");
- dl->verts = MEM_malloc_arrayN(2, sizeof(float[3]), "makebevelcurve2");
- BLI_addtail(disp, dl);
- dl->type = DL_SEGM;
- dl->parts = 1;
- dl->flag = DL_FRONT_CURVE | DL_BACK_CURVE;
- dl->nr = 2;
-
- fp = dl->verts;
- fp[0] = fp[1] = 0.0;
- fp[2] = -cu->ext1;
- fp[3] = fp[4] = 0.0;
- fp[5] = cu->ext1;
- }
- else if ((cu->flag & (CU_FRONT | CU_BACK)) == 0 && cu->ext1 == 0.0f) {
- /* We make a full round bevel in that case. */
-
- nr = 4 + 2 * cu->bevresol;
-
- dl = MEM_callocN(sizeof(DispList), "makebevelcurve p1");
- dl->verts = MEM_malloc_arrayN(nr, sizeof(float[3]), "makebevelcurve p1");
- BLI_addtail(disp, dl);
- dl->type = DL_POLY;
- dl->parts = 1;
- dl->flag = DL_BACK_CURVE;
- dl->nr = nr;
-
- /* a circle */
- fp = dl->verts;
- dangle = (2.0f * (float)M_PI / (nr));
- angle = -(nr - 1) * dangle;
-
- for (a = 0; a < nr; a++) {
- fp[0] = 0.0;
- fp[1] = (cosf(angle) * (cu->ext2));
- fp[2] = (sinf(angle) * (cu->ext2)) - cu->ext1;
- angle += dangle;
- fp += 3;
- }
- }
- else {
- /* The general case for nonzero extrusion or an incomplete loop. */
- dl = MEM_callocN(sizeof(DispList), "makebevelcurve");
- if ((cu->flag & (CU_FRONT | CU_BACK)) == 0) {
- /* The full loop. */
- nr = 4 * cu->bevresol + 6;
- dl->flag = DL_FRONT_CURVE | DL_BACK_CURVE;
- }
- else if ((cu->flag & CU_FRONT) && (cu->flag & CU_BACK)) {
- /* Half the loop. */
- nr = 2 * (cu->bevresol + 1) + ((cu->ext1 == 0.0f) ? 1 : 2);
- dl->flag = DL_FRONT_CURVE | DL_BACK_CURVE;
- }
- else {
- /* One quarter of the loop (just front or back). */
- nr = (cu->ext1 == 0.0f) ? cu->bevresol + 2 : cu->bevresol + 3;
- dl->flag = (cu->flag & CU_FRONT) ? DL_FRONT_CURVE : DL_BACK_CURVE;
- }
-
- dl->verts = MEM_malloc_arrayN(nr, sizeof(float[3]), "makebevelcurve");
- BLI_addtail(disp, dl);
- /* Use a different type depending on whether the loop is complete or not. */
- dl->type = ((cu->flag & (CU_FRONT | CU_BACK)) == 0) ? DL_POLY : DL_SEGM;
- dl->parts = 1;
- dl->nr = nr;
-
- fp = dl->verts;
- dangle = (float)M_PI_2 / (cu->bevresol + 1);
- angle = 0.0;
-
- /* Build the back section. */
- if (cu->flag & CU_BACK || !(cu->flag & CU_FRONT)) {
- angle = (float)M_PI_2 * 3.0f;
- for (a = 0; a < cu->bevresol + 2; a++) {
- fp[0] = 0.0;
- fp[1] = (float)(cosf(angle) * (cu->ext2));
- fp[2] = (float)(sinf(angle) * (cu->ext2)) - cu->ext1;
- angle += dangle;
- fp += 3;
- }
- if ((cu->ext1 != 0.0f) && !(cu->flag & CU_FRONT) && (cu->flag & CU_BACK)) {
- /* Add the extrusion if we're only building the back. */
- fp[0] = 0.0;
- fp[1] = cu->ext2;
- fp[2] = cu->ext1;
- }
- }
-
- /* Build the front section. */
- if (cu->flag & CU_FRONT || !(cu->flag & CU_BACK)) {
- if ((cu->ext1 != 0.0f) && !(cu->flag & CU_BACK) && (cu->flag & CU_FRONT)) {
- /* Add the extrusion if we're only building the back. */
- fp[0] = 0.0;
- fp[1] = cu->ext2;
- fp[2] = -cu->ext1;
- fp += 3;
- }
- /* Don't duplicate the last back vertex. */
- angle = (cu->ext1 == 0.0f && (cu->flag & CU_BACK)) ? dangle : 0;
- int front_len = (cu->ext1 == 0.0f && ((cu->flag & CU_BACK) || !(cu->flag & CU_FRONT))) ?
- cu->bevresol + 1 :
- cu->bevresol + 2;
- for (a = 0; a < front_len; a++) {
- fp[0] = 0.0;
- fp[1] = (float)(cosf(angle) * (cu->ext2));
- fp[2] = (float)(sinf(angle) * (cu->ext2)) + cu->ext1;
- angle += dangle;
- fp += 3;
- }
- }
-
- /* Build the other half only if we're building the full loop. */
- if (!(cu->flag & (CU_FRONT | CU_BACK))) {
- for (a = 0; a < cu->bevresol + 1; a++) {
- fp[0] = 0.0;
- fp[1] = (float)(cosf(angle) * (cu->ext2));
- fp[2] = (float)(sinf(angle) * (cu->ext2)) + cu->ext1;
- angle += dangle;
- fp += 3;
- }
-
- angle = (float)M_PI;
- for (a = 0; a < cu->bevresol + 1; a++) {
- fp[0] = 0.0;
- fp[1] = (float)(cosf(angle) * (cu->ext2));
- fp[2] = (float)(sinf(angle) * (cu->ext2)) - cu->ext1;
- angle += dangle;
- fp += 3;
- }
- }
- }
-}
-
static int cu_isectLL(const float v1[3],
const float v2[3],
const float v3[3],
@@ -2500,7 +2301,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
while (nr--) {
/* make perpendicular, modify tan in place, is ok */
float cross_tmp[3];
- float zero[3] = {0, 0, 0};
+ const float zero[3] = {0, 0, 0};
cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir);
normalize_v3(cross_tmp);
@@ -3797,7 +3598,10 @@ static void bezier_clamp(
}
/* write changes to a bezier handle */
-static void bezier_output_handle_inner(BezTriple *bezt, bool right, float newval[3], bool endpoint)
+static void bezier_output_handle_inner(BezTriple *bezt,
+ bool right,
+ const float newval[3],
+ bool endpoint)
{
float tmp[3];
@@ -5309,8 +5113,11 @@ bool BKE_curve_center_bounds(Curve *cu, float cent[3])
return false;
}
-void BKE_curve_transform_ex(
- Curve *cu, float mat[4][4], const bool do_keys, const bool do_props, const float unit_scale)
+void BKE_curve_transform_ex(Curve *cu,
+ const float mat[4][4],
+ const bool do_keys,
+ const bool do_props,
+ const float unit_scale)
{
Nurb *nu;
BPoint *bp;
@@ -5373,13 +5180,13 @@ void BKE_curve_transform_ex(
}
}
-void BKE_curve_transform(Curve *cu, float mat[4][4], const bool do_keys, const bool do_props)
+void BKE_curve_transform(Curve *cu, const float mat[4][4], const bool do_keys, const bool do_props)
{
float unit_scale = mat4_to_scale(mat);
BKE_curve_transform_ex(cu, mat, do_keys, do_props, unit_scale);
}
-void BKE_curve_translate(Curve *cu, float offset[3], const bool do_keys)
+void BKE_curve_translate(Curve *cu, const float offset[3], const bool do_keys)
{
ListBase *nurb_lb = BKE_curve_nurbs_get(cu);
Nurb *nu;
diff --git a/source/blender/blenkernel/intern/curve_bevel.c b/source/blender/blenkernel/intern/curve_bevel.c
new file mode 100644
index 00000000000..edf5b82f822
--- /dev/null
+++ b/source/blender/blenkernel/intern/curve_bevel.c
@@ -0,0 +1,272 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup bke
+ *
+ * Handle curve object data bevel options,
+ * both extruding
+ */
+
+#include <string.h>
+
+#include "BLI_listbase.h"
+#include "BLI_math_base.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_curve_types.h"
+#include "DNA_object_types.h"
+
+#include "BKE_curve.h"
+#include "BKE_displist.h"
+
+typedef enum CurveBevelFillType {
+ BACK = 0,
+ FRONT,
+ HALF,
+ FULL,
+} CurveBevelFillType;
+
+static CurveBevelFillType curve_bevel_get_fill_type(const Curve *curve)
+{
+ if (!(curve->flag & (CU_FRONT | CU_BACK))) {
+ return FULL;
+ }
+ if ((curve->flag & CU_FRONT) && (curve->flag & CU_BACK)) {
+ return HALF;
+ }
+
+ return (curve->flag & CU_FRONT) ? FRONT : BACK;
+}
+
+static void curve_bevel_make_extrude_and_fill(Curve *cu,
+ ListBase *disp,
+ const bool use_extrude,
+ const CurveBevelFillType fill_type)
+{
+ DispList *dl = MEM_callocN(sizeof(DispList), __func__);
+
+ int nr;
+ if (fill_type == FULL) {
+ /* The full loop. */
+ nr = 4 * cu->bevresol + 6;
+ dl->flag = DL_FRONT_CURVE | DL_BACK_CURVE;
+ }
+ else if (fill_type == HALF) {
+ /* Half the loop. */
+ nr = 2 * (cu->bevresol + 1) + (use_extrude ? 2 : 1);
+ dl->flag = DL_FRONT_CURVE | DL_BACK_CURVE;
+ }
+ else {
+ /* One quarter of the loop (just front or back). */
+ nr = use_extrude ? cu->bevresol + 3 : cu->bevresol + 2;
+ dl->flag = (fill_type == FRONT) ? DL_FRONT_CURVE : DL_BACK_CURVE;
+ }
+
+ dl->verts = MEM_malloc_arrayN(nr, sizeof(float[3]), __func__);
+ BLI_addtail(disp, dl);
+ /* Use a different type depending on whether the loop is complete or not. */
+ dl->type = (fill_type == FULL) ? DL_POLY : DL_SEGM;
+ dl->parts = 1;
+ dl->nr = nr;
+
+ float *fp = dl->verts;
+ const float dangle = (float)M_PI_2 / (cu->bevresol + 1);
+ float angle = 0.0f;
+
+ /* Build the back section. */
+ if (ELEM(fill_type, BACK, HALF, FULL)) {
+ angle = (float)M_PI_2 * 3.0f;
+ for (int i = 0; i < cu->bevresol + 2; i++) {
+ fp[0] = 0.0f;
+ fp[1] = (float)(cosf(angle) * (cu->ext2));
+ fp[2] = (float)(sinf(angle) * (cu->ext2)) - cu->ext1;
+ angle += dangle;
+ fp += 3;
+ }
+ if (use_extrude && fill_type == BACK) {
+ /* Add the extrusion if we're only building the back. */
+ fp[0] = 0.0f;
+ fp[1] = cu->ext2;
+ fp[2] = cu->ext1;
+ }
+ }
+
+ /* Build the front section. */
+ if (ELEM(fill_type, FRONT, HALF, FULL)) {
+ if (use_extrude && fill_type == FRONT) {
+ /* Add the extrusion if we're only building the front. */
+ fp[0] = 0.0f;
+ fp[1] = cu->ext2;
+ fp[2] = -cu->ext1;
+ fp += 3;
+ }
+ /* Don't duplicate the last back vertex. */
+ angle = (!use_extrude && ELEM(fill_type, HALF, FULL)) ? dangle : 0;
+ int front_len = (!use_extrude && ELEM(fill_type, HALF, FULL)) ? cu->bevresol + 1 :
+ cu->bevresol + 2;
+ for (int i = 0; i < front_len; i++) {
+ fp[0] = 0.0f;
+ fp[1] = (float)(cosf(angle) * (cu->ext2));
+ fp[2] = (float)(sinf(angle) * (cu->ext2)) + cu->ext1;
+ angle += dangle;
+ fp += 3;
+ }
+ }
+
+ /* Build the other half only if we're building the full loop. */
+ if (fill_type == FULL) {
+ for (int i = 0; i < cu->bevresol + 1; i++) {
+ fp[0] = 0.0f;
+ fp[1] = (float)(cosf(angle) * (cu->ext2));
+ fp[2] = (float)(sinf(angle) * (cu->ext2)) + cu->ext1;
+ angle += dangle;
+ fp += 3;
+ }
+
+ angle = (float)M_PI;
+ for (int i = 0; i < cu->bevresol + 1; i++) {
+ fp[0] = 0.0f;
+ fp[1] = (float)(cosf(angle) * (cu->ext2));
+ fp[2] = (float)(sinf(angle) * (cu->ext2)) - cu->ext1;
+ angle += dangle;
+ fp += 3;
+ }
+ }
+}
+
+static void curve_bevel_make_full_circle(Curve *cu, ListBase *disp)
+{
+ const int nr = 4 + 2 * cu->bevresol;
+
+ DispList *dl = MEM_callocN(sizeof(DispList), __func__);
+ dl->verts = MEM_malloc_arrayN(nr, sizeof(float[3]), __func__);
+ BLI_addtail(disp, dl);
+ dl->type = DL_POLY;
+ dl->parts = 1;
+ dl->flag = DL_BACK_CURVE;
+ dl->nr = nr;
+
+ float *fp = dl->verts;
+ const float dangle = (2.0f * (float)M_PI / (nr));
+ float angle = -(nr - 1) * dangle;
+
+ for (int i = 0; i < nr; i++) {
+ fp[0] = 0.0;
+ fp[1] = (cosf(angle) * (cu->ext2));
+ fp[2] = (sinf(angle) * (cu->ext2)) - cu->ext1;
+ angle += dangle;
+ fp += 3;
+ }
+}
+
+static void curve_bevel_make_only_extrude(Curve *cu, ListBase *disp)
+{
+ DispList *dl = MEM_callocN(sizeof(DispList), __func__);
+ dl->verts = MEM_malloc_arrayN(2, sizeof(float[3]), __func__);
+ BLI_addtail(disp, dl);
+ dl->type = DL_SEGM;
+ dl->parts = 1;
+ dl->flag = DL_FRONT_CURVE | DL_BACK_CURVE;
+ dl->nr = 2;
+
+ float *fp = dl->verts;
+ fp[0] = fp[1] = 0.0;
+ fp[2] = -cu->ext1;
+ fp[3] = fp[4] = 0.0;
+ fp[5] = cu->ext1;
+}
+
+static void curve_bevel_make_from_object(Curve *cu, ListBase *disp)
+{
+ if (cu->bevobj->type != OB_CURVE) {
+ return;
+ }
+
+ Curve *bevcu = cu->bevobj->data;
+ if (bevcu->ext1 == 0.0f && bevcu->ext2 == 0.0f) {
+ ListBase bevdisp = {NULL, NULL};
+ float facx = cu->bevobj->scale[0];
+ float facy = cu->bevobj->scale[1];
+
+ DispList *dl;
+ if (cu->bevobj->runtime.curve_cache) {
+ dl = cu->bevobj->runtime.curve_cache->disp.first;
+ }
+ else {
+ BLI_assert(cu->bevobj->runtime.curve_cache != NULL);
+ dl = NULL;
+ }
+
+ while (dl) {
+ if (ELEM(dl->type, DL_POLY, DL_SEGM)) {
+ DispList *dlnew = MEM_mallocN(sizeof(DispList), __func__);
+ *dlnew = *dl;
+ dlnew->verts = MEM_malloc_arrayN(dl->parts * dl->nr, sizeof(float[3]), __func__);
+ memcpy(dlnew->verts, dl->verts, sizeof(float[3]) * dl->parts * dl->nr);
+
+ if (dlnew->type == DL_SEGM) {
+ dlnew->flag |= (DL_FRONT_CURVE | DL_BACK_CURVE);
+ }
+
+ BLI_addtail(disp, dlnew);
+ float *fp = dlnew->verts;
+ int nr = dlnew->parts * dlnew->nr;
+ while (nr--) {
+ fp[2] = fp[1] * facy;
+ fp[1] = -fp[0] * facx;
+ fp[0] = 0.0;
+ fp += 3;
+ }
+ }
+ dl = dl->next;
+ }
+
+ BKE_displist_free(&bevdisp);
+ }
+}
+
+void BKE_curve_bevel_make(Object *ob, ListBase *disp)
+{
+ Curve *curve = ob->data;
+
+ const bool use_extrude = curve->ext1 != 0.0f;
+ const bool use_bevel = curve->ext2 != 0.0f;
+
+ BLI_listbase_clear(disp);
+
+ if (curve->bevobj) {
+ curve_bevel_make_from_object(curve, disp);
+ }
+ else if (!(use_extrude || use_bevel)) {
+ /* Pass. */
+ }
+ else if (use_extrude && !use_bevel) {
+ curve_bevel_make_only_extrude(curve, disp);
+ }
+ else {
+ CurveBevelFillType fill_type = curve_bevel_get_fill_type(curve);
+
+ if (!use_extrude && fill_type == FULL) {
+ curve_bevel_make_full_circle(curve, disp);
+ }
+ else {
+ /* The general case for nonzero extrusion or an incomplete loop. */
+ curve_bevel_make_extrude_and_fill(curve, disp, use_extrude, fill_type);
+ }
+ }
+}
diff --git a/source/blender/blenkernel/intern/curveprofile.c b/source/blender/blenkernel/intern/curveprofile.c
index 6919d4fa10f..068f8845e64 100644
--- a/source/blender/blenkernel/intern/curveprofile.c
+++ b/source/blender/blenkernel/intern/curveprofile.c
@@ -254,7 +254,7 @@ void BKE_curveprofile_remove_by_flag(CurveProfile *profile, const short flag)
CurveProfilePoint *BKE_curveprofile_insert(CurveProfile *profile, float x, float y)
{
CurveProfilePoint *new_pt = NULL;
- float new_loc[2] = {x, y};
+ const float new_loc[2] = {x, y};
/* Don't add more control points than the maximum size of the higher resolution table. */
if (profile->path_len == PROF_TABLE_MAX - 1) {
@@ -266,8 +266,8 @@ CurveProfilePoint *BKE_curveprofile_insert(CurveProfile *profile, float x, float
float min_distance = FLT_MAX;
int i_insert = 0;
for (int i = 0; i < profile->path_len - 1; i++) {
- float loc1[2] = {profile->path[i].x, profile->path[i].y};
- float loc2[2] = {profile->path[i + 1].x, profile->path[i + 1].y};
+ const float loc1[2] = {profile->path[i].x, profile->path[i].y};
+ const float loc2[2] = {profile->path[i + 1].x, profile->path[i + 1].y};
distance = dist_squared_to_line_segment_v2(new_loc, loc1, loc2);
if (distance < min_distance) {
@@ -689,9 +689,8 @@ static int sort_points_curvature(const void *in_a, const void *in_b)
if (a->bezt_curvature > b->bezt_curvature) {
return 0;
}
- else {
- return 1;
- }
+
+ return 1;
}
/**
@@ -886,7 +885,7 @@ void BKE_curveprofile_create_samples(CurveProfile *profile,
*/
static void curveprofile_make_table(CurveProfile *profile)
{
- int n_samples = PROF_N_TABLE(profile->path_len);
+ int n_samples = PROF_TABLE_LEN(profile->path_len);
CurveProfilePoint *new_table = MEM_callocN(sizeof(CurveProfilePoint) * (n_samples + 1),
"high-res table");
@@ -1040,7 +1039,7 @@ void BKE_curveprofile_update(CurveProfile *profile, const int update_flags)
* Also sets the number of segments used for the display preview of the locations
* of the sampled points.
*/
-void BKE_curveprofile_initialize(CurveProfile *profile, short segments_len)
+void BKE_curveprofile_init(CurveProfile *profile, short segments_len)
{
if (segments_len != profile->segments_len) {
profile->flag |= PROF_DIRTY_PRESET;
@@ -1055,11 +1054,11 @@ void BKE_curveprofile_initialize(CurveProfile *profile, short segments_len)
* Gives the distance to the next point in the widgets sampled table, in other words the length
* of the \a 'i' edge of the table.
*
- * \note Requires curveprofile_initialize or #BKE_curveprofile_update call before to fill table.
+ * \note Requires #BKE_curveprofile_init or #BKE_curveprofile_update call before to fill table.
*/
static float curveprofile_distance_to_next_table_point(const CurveProfile *profile, int i)
{
- BLI_assert(i < PROF_N_TABLE(profile->path_len));
+ BLI_assert(i < PROF_TABLE_LEN(profile->path_len));
return len_v2v2(&profile->table[i].x, &profile->table[i + 1].x);
}
@@ -1067,12 +1066,12 @@ static float curveprofile_distance_to_next_table_point(const CurveProfile *profi
/**
* Calculates the total length of the profile from the curves sampled in the table.
*
- * \note Requires curveprofile_initialize or #BKE_curveprofile_update call before to fill table.
+ * \note Requires #BKE_curveprofile_init or #BKE_curveprofile_update call before to fill table.
*/
float BKE_curveprofile_total_length(const CurveProfile *profile)
{
float total_length = 0;
- for (int i = 0; i < PROF_N_TABLE(profile->path_len) - 1; i++) {
+ for (int i = 0; i < PROF_TABLE_LEN(profile->path_len) - 1; i++) {
total_length += len_v2v2(&profile->table[i].x, &profile->table[i + 1].x);
}
return total_length;
@@ -1082,7 +1081,7 @@ float BKE_curveprofile_total_length(const CurveProfile *profile)
* Samples evenly spaced positions along the curve profile's table (generated from path). Fills
* an entire table at once for a speedup if all of the results are going to be used anyway.
*
- * \note Requires curveprofile_initialize or #BKE_curveprofile_update call before to fill table.
+ * \note Requires #BKE_curveprofile_init or #BKE_curveprofile_update call before to fill table.
* \note Working, but would conflict with "Sample Straight Edges" option, so this is unused for
* now.
*/
@@ -1145,7 +1144,7 @@ void BKE_curveprofile_create_samples_even_spacing(CurveProfile *profile,
* Travels down (length_portion * path) length and returns the position at that point.
*
* \param length_portion: The portion (0 to 1) of the path's full length to sample at.
- * \note Requires curveprofile_initialize or #BKE_curveprofile_update call before to fill table.
+ * \note Requires #BKE_curveprofile_init or #BKE_curveprofile_update call before to fill table.
*/
void BKE_curveprofile_evaluate_length_portion(const CurveProfile *profile,
float length_portion,
@@ -1160,7 +1159,7 @@ void BKE_curveprofile_evaluate_length_portion(const CurveProfile *profile,
float length_travelled = 0.0f;
while (length_travelled < requested_length) {
/* Check if we reached the last point before the final one. */
- if (i == PROF_N_TABLE(profile->path_len) - 2) {
+ if (i == PROF_TABLE_LEN(profile->path_len) - 2) {
break;
}
float new_length = curveprofile_distance_to_next_table_point(profile, i);
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 7bf11d86a63..f728436a759 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -597,14 +597,14 @@ static void layerSwap_mdisps(void *data, const int *ci)
MEM_freeN(s->disps);
s->totdisp = (s->totdisp / corners) * nverts;
- s->disps = MEM_calloc_arrayN(s->totdisp, sizeof(float) * 3, "mdisp swap");
+ s->disps = MEM_calloc_arrayN(s->totdisp, sizeof(float[3]), "mdisp swap");
return;
}
- d = MEM_calloc_arrayN(s->totdisp, 3 * sizeof(float), "mdisps swap");
+ d = MEM_calloc_arrayN(s->totdisp, sizeof(float[3]), "mdisps swap");
for (S = 0; S < corners; S++) {
- memcpy(d + cornersize * S, s->disps + cornersize * ci[S], cornersize * 3 * sizeof(float));
+ memcpy(d + cornersize * S, s->disps + cornersize * ci[S], sizeof(float[3]) * cornersize);
}
MEM_freeN(s->disps);
@@ -660,10 +660,10 @@ static int layerRead_mdisps(CDataFile *cdf, void *data, int count)
for (i = 0; i < count; i++) {
if (!d[i].disps) {
- d[i].disps = MEM_calloc_arrayN(d[i].totdisp, 3 * sizeof(float), "mdisps read");
+ d[i].disps = MEM_calloc_arrayN(d[i].totdisp, sizeof(float[3]), "mdisps read");
}
- if (!cdf_read_data(cdf, d[i].totdisp * 3 * sizeof(float), d[i].disps)) {
+ if (!cdf_read_data(cdf, sizeof(float[3]) * d[i].totdisp, d[i].disps)) {
CLOG_ERROR(&LOG, "failed to read multires displacement %d/%d %d", i, count, d[i].totdisp);
return 0;
}
@@ -678,7 +678,7 @@ static int layerWrite_mdisps(CDataFile *cdf, const void *data, int count)
int i;
for (i = 0; i < count; i++) {
- if (!cdf_write_data(cdf, d[i].totdisp * 3 * sizeof(float), d[i].disps)) {
+ if (!cdf_write_data(cdf, sizeof(float[3]) * d[i].totdisp, d[i].disps)) {
CLOG_ERROR(&LOG, "failed to write multires displacement %d/%d %d", i, count, d[i].totdisp);
return 0;
}
@@ -694,7 +694,7 @@ static size_t layerFilesize_mdisps(CDataFile *UNUSED(cdf), const void *data, int
int i;
for (i = 0; i < count; i++) {
- size += d[i].totdisp * 3 * sizeof(float);
+ size += sizeof(float[3]) * d[i].totdisp;
}
return size;
@@ -771,7 +771,7 @@ static void layerCopyValue_mloopcol(const void *source,
if (mixmode == CDT_MIX_REPLACE_ABOVE_THRESHOLD && f < mixfactor) {
return; /* Do Nothing! */
}
- else if (mixmode == CDT_MIX_REPLACE_BELOW_THRESHOLD && f > mixfactor) {
+ if (mixmode == CDT_MIX_REPLACE_BELOW_THRESHOLD && f > mixfactor) {
return; /* Do Nothing! */
}
}
@@ -1358,7 +1358,7 @@ static void layerCopyValue_propcol(const void *source,
if (mixmode == CDT_MIX_REPLACE_ABOVE_THRESHOLD && f < mixfactor) {
return; /* Do Nothing! */
}
- else if (mixmode == CDT_MIX_REPLACE_BELOW_THRESHOLD && f > mixfactor) {
+ if (mixmode == CDT_MIX_REPLACE_BELOW_THRESHOLD && f > mixfactor) {
return; /* Do Nothing! */
}
}
@@ -1564,7 +1564,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
/* 0: CD_MVERT */
{sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL},
/* 1: CD_MSTICKY */ /* DEPRECATED */
- {sizeof(float) * 2, "", 1, NULL, NULL, NULL, NULL, NULL, NULL},
+ {sizeof(float[2]), "", 1, NULL, NULL, NULL, NULL, NULL, NULL},
/* 2: CD_MDEFORMVERT */
{sizeof(MDeformVert),
"MDeformVert",
@@ -1602,7 +1602,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerMaxNum_tface},
/* 6: CD_MCOL */
/* 4 MCol structs per face */
- {sizeof(MCol) * 4,
+ {sizeof(MCol[4]),
"MCol",
4,
N_("Col"),
@@ -1626,7 +1626,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, layerDefault_origindex},
/* 8: CD_NORMAL */
/* 3 floats per normal vector */
- {sizeof(float) * 3,
+ {sizeof(float[3]),
"vec3f",
1,
NULL,
@@ -1677,7 +1677,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerSwap_origspace_face,
layerDefault_origspace_face},
/* 14: CD_ORCO */
- {sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
+ {sizeof(float[3]), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 15: CD_MTEXPOLY */ /* DEPRECATED */
/* note, when we expose the UV Map / TexFace split to the user,
* change this back to face Texture. */
@@ -1725,7 +1725,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
NULL,
layerMaxNum_mloopcol},
/* 18: CD_TANGENT */
- {sizeof(float) * 4 * 4, "", 0, N_("Tangent"), NULL, NULL, NULL, NULL, NULL},
+ {sizeof(float[4][4]), "", 0, N_("Tangent"), NULL, NULL, NULL, NULL, NULL},
/* 19: CD_MDISPS */
{sizeof(MDisps),
"MDisps",
@@ -1747,7 +1747,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerWrite_mdisps,
layerFilesize_mdisps},
/* 20: CD_PREVIEW_MCOL */
- {sizeof(MCol) * 4,
+ {sizeof(MCol[4]),
"MCol",
4,
N_("PreviewCol"),
@@ -1757,9 +1757,9 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerSwap_mcol,
layerDefault_mcol},
/* 21: CD_ID_MCOL */ /* DEPRECATED */
- {sizeof(MCol) * 4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
+ {sizeof(MCol[4]), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 22: CD_TEXTURE_MCOL */
- {sizeof(MCol) * 4,
+ {sizeof(MCol[4]),
"MCol",
4,
N_("TexturedCol"),
@@ -1769,7 +1769,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerSwap_mcol,
layerDefault_mcol},
/* 23: CD_CLOTH_ORCO */
- {sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
+ {sizeof(float[3]), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 24: CD_RECAST */
{sizeof(MRecast), "MRecast", 1, N_("Recast"), NULL, NULL, NULL, NULL},
@@ -1781,7 +1781,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
/* 27: CD_SHAPE_KEYINDEX */
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 28: CD_SHAPEKEY */
- {sizeof(float) * 3, "", 0, N_("ShapeKey"), NULL, NULL, layerInterp_shapekey},
+ {sizeof(float[3]), "", 0, N_("ShapeKey"), NULL, NULL, layerInterp_shapekey},
/* 29: CD_BWEIGHT */
{sizeof(float), "", 0, N_("BevelWeight"), NULL, NULL, layerInterp_bweight},
/* 30: CD_CREASE */
@@ -2201,13 +2201,13 @@ bool CustomData_merge(const struct CustomData *source,
if (flag & CD_FLAG_NOCOPY) {
continue;
}
- else if (!(mask & CD_TYPE_AS_MASK(type))) {
+ if (!(mask & CD_TYPE_AS_MASK(type))) {
continue;
}
- else if ((maxnumber != -1) && (number >= maxnumber)) {
+ if ((maxnumber != -1) && (number >= maxnumber)) {
continue;
}
- else if (CustomData_get_named_layer_index(dest, type, layer->name) != -1) {
+ if (CustomData_get_named_layer_index(dest, type, layer->name) != -1) {
continue;
}
@@ -4052,9 +4052,8 @@ bool CustomData_data_equals(int type, const void *data1, const void *data2)
if (typeInfo->equal) {
return typeInfo->equal(data1, data2);
}
- else {
- return !memcmp(data1, data2, typeInfo->size);
- }
+
+ return !memcmp(data1, data2, typeInfo->size);
}
void CustomData_data_initminmax(int type, void *min, void *max)
@@ -4411,7 +4410,7 @@ int CustomData_layertype_layers_max(const int type)
if (typeInfo->defaultname == NULL) {
return 1;
}
- else if (typeInfo->layers_max == NULL) {
+ if (typeInfo->layers_max == NULL) {
return -1;
}
@@ -4571,6 +4570,32 @@ bool CustomData_layer_validate(CustomDataLayer *layer, const uint totitems, cons
return false;
}
+void CustomData_layers__print(CustomData *data)
+{
+ int i;
+ const CustomDataLayer *layer;
+
+ printf("{\n");
+
+ for (i = 0, layer = data->layers; i < data->totlayer; i++, layer++) {
+
+ const char *name = CustomData_layertype_name(layer->type);
+ const int size = CustomData_sizeof(layer->type);
+ const char *structname;
+ int structnum;
+ CustomData_file_write_info(layer->type, &structname, &structnum);
+ printf(" dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
+ name,
+ structname,
+ layer->type,
+ (const void *)layer->data,
+ size,
+ (int)(MEM_allocN_len(layer->data) / size));
+ }
+
+ printf("}\n");
+}
+
/****************************** External Files *******************************/
static void customdata_external_filename(char filename[FILE_MAX],
diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c
index 1463e50f6e3..4fa232a368b 100644
--- a/source/blender/blenkernel/intern/customdata_file.c
+++ b/source/blender/blenkernel/intern/customdata_file.c
@@ -101,9 +101,8 @@ static int cdf_endian(void)
if (ENDIAN_ORDER == L_ENDIAN) {
return CDF_ENDIAN_LITTLE;
}
- else {
- return CDF_ENDIAN_BIG;
- }
+
+ return CDF_ENDIAN_BIG;
}
CDataFile *cdf_create(int type)
@@ -318,9 +317,8 @@ bool cdf_read_layer(CDataFile *cdf, CDataFileLayer *blay)
if (&cdf->layer[a] == blay) {
break;
}
- else {
- offset += cdf->layer[a].datasize;
- }
+
+ offset += cdf->layer[a].datasize;
}
return (fseek(cdf->readf, offset, SEEK_SET) == 0);
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 9bdd80fd668..1b35fdd1706 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -43,6 +43,7 @@
#include "BKE_mesh_mapping.h"
#include "BKE_mesh_remap.h"
#include "BKE_mesh_runtime.h"
+#include "BKE_mesh_wrapper.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_object_deform.h"
@@ -960,7 +961,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
}
return true;
}
- else if (cddata_type == CD_FAKE_BWEIGHT) {
+ if (cddata_type == CD_FAKE_BWEIGHT) {
const size_t elem_size = sizeof(*((MVert *)NULL));
const size_t data_size = sizeof(((MVert *)NULL)->bweight);
const size_t data_offset = offsetof(MVert, bweight);
@@ -992,7 +993,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
}
return true;
}
- else if (cddata_type == CD_FAKE_MDEFORMVERT) {
+ if (cddata_type == CD_FAKE_MDEFORMVERT) {
bool ret;
cd_src = &me_src->vdata;
@@ -1017,7 +1018,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
me_dst->dvert = CustomData_get_layer(&me_dst->vdata, CD_MDEFORMVERT);
return ret;
}
- else if (cddata_type == CD_FAKE_SHAPEKEY) {
+ if (cddata_type == CD_FAKE_SHAPEKEY) {
/* TODO: leaving shapekeys aside for now, quite specific case,
* since we can't access them from MVert :/ */
return false;
@@ -1048,7 +1049,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
}
return true;
}
- else if (cddata_type == CD_FAKE_CREASE) {
+ if (cddata_type == CD_FAKE_CREASE) {
const size_t elem_size = sizeof(*((MEdge *)NULL));
const size_t data_size = sizeof(((MEdge *)NULL)->crease);
const size_t data_offset = offsetof(MEdge, crease);
@@ -1080,7 +1081,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
}
return true;
}
- else if (cddata_type == CD_FAKE_BWEIGHT) {
+ if (cddata_type == CD_FAKE_BWEIGHT) {
const size_t elem_size = sizeof(*((MEdge *)NULL));
const size_t data_size = sizeof(((MEdge *)NULL)->bweight);
const size_t data_offset = offsetof(MEdge, bweight);
@@ -1112,7 +1113,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
}
return true;
}
- else if (r_map && ELEM(cddata_type, CD_FAKE_SHARP, CD_FAKE_SEAM)) {
+ if (r_map && ELEM(cddata_type, CD_FAKE_SHARP, CD_FAKE_SEAM)) {
const size_t elem_size = sizeof(*((MEdge *)NULL));
const size_t data_size = sizeof(((MEdge *)NULL)->flag);
const size_t data_offset = offsetof(MEdge, flag);
@@ -1135,9 +1136,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
interp_data);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
else if (elem_type == ME_LOOP) {
if (cddata_type == CD_FAKE_UV) {
@@ -1175,9 +1175,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
}
return true;
}
- else {
- return false;
- }
+
+ return false;
}
else if (elem_type == ME_POLY) {
if (cddata_type == CD_FAKE_UV) {
@@ -1208,7 +1207,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
}
return true;
}
- else if (r_map && cddata_type == CD_FAKE_SHARP) {
+ if (r_map && cddata_type == CD_FAKE_SHARP) {
const size_t elem_size = sizeof(*((MPoly *)NULL));
const size_t data_size = sizeof(((MPoly *)NULL)->flag);
const size_t data_offset = offsetof(MPoly, flag);
@@ -1231,9 +1230,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
interp_data);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
return false;
@@ -1467,6 +1465,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
if (!me_src) {
return changed;
}
+ BKE_mesh_wrapper_ensure_mdata(me_src);
if (auto_transform) {
if (space_transform == NULL) {
@@ -1573,7 +1572,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
space_transform)) {
CustomDataTransferLayerMap *lay_mapit;
- changed = (lay_map.first != NULL);
+ changed |= (lay_map.first != NULL);
for (lay_mapit = lay_map.first; lay_mapit; lay_mapit = lay_mapit->next) {
CustomData_data_transfer(&geom_map[VDATA], lay_mapit);
@@ -1651,7 +1650,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
space_transform)) {
CustomDataTransferLayerMap *lay_mapit;
- changed = (lay_map.first != NULL);
+ changed |= (lay_map.first != NULL);
for (lay_mapit = lay_map.first; lay_mapit; lay_mapit = lay_mapit->next) {
CustomData_data_transfer(&geom_map[EDATA], lay_mapit);
@@ -1747,7 +1746,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
space_transform)) {
CustomDataTransferLayerMap *lay_mapit;
- changed = (lay_map.first != NULL);
+ changed |= (lay_map.first != NULL);
for (lay_mapit = lay_map.first; lay_mapit; lay_mapit = lay_mapit->next) {
CustomData_data_transfer(&geom_map[LDATA], lay_mapit);
@@ -1838,7 +1837,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
space_transform)) {
CustomDataTransferLayerMap *lay_mapit;
- changed = (lay_map.first != NULL);
+ changed |= (lay_map.first != NULL);
for (lay_mapit = lay_map.first; lay_mapit; lay_mapit = lay_mapit->next) {
CustomData_data_transfer(&geom_map[PDATA], lay_mapit);
diff --git a/source/blender/blenkernel/intern/data_transfer_intern.h b/source/blender/blenkernel/intern/data_transfer_intern.h
index 68ded6e2bc4..c5d7dd42cb8 100644
--- a/source/blender/blenkernel/intern/data_transfer_intern.h
+++ b/source/blender/blenkernel/intern/data_transfer_intern.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __DATA_TRANSFER_INTERN_H__
-#define __DATA_TRANSFER_INTERN_H__
+#pragma once
#include "BKE_customdata.h" /* For cd_datatransfer_interp */
@@ -75,5 +74,3 @@ void customdata_data_transfer_interp_normal_normals(const CustomDataTransferLaye
const float *weights,
const int count,
const float mix_factor);
-
-#endif /* __DATA_TRANSFER_INTERN_H__ */
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 98fc5f9a23a..1a32deac776 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -510,36 +510,35 @@ int *BKE_object_defgroup_flip_map(const Object *ob, int *flip_map_len, const boo
if (defbase_tot == 0) {
return NULL;
}
- else {
- bDeformGroup *dg;
- char name_flip[sizeof(dg->name)];
- int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);
- for (i = 0; i < defbase_tot; i++) {
- map[i] = -1;
- }
+ bDeformGroup *dg;
+ char name_flip[sizeof(dg->name)];
+ int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);
- for (dg = ob->defbase.first, i = 0; dg; dg = dg->next, i++) {
- if (map[i] == -1) { /* may be calculated previously */
+ for (i = 0; i < defbase_tot; i++) {
+ map[i] = -1;
+ }
- /* in case no valid value is found, use this */
- if (use_default) {
- map[i] = i;
- }
+ for (dg = ob->defbase.first, i = 0; dg; dg = dg->next, i++) {
+ if (map[i] == -1) { /* may be calculated previously */
- BLI_string_flip_side_name(name_flip, dg->name, false, sizeof(name_flip));
+ /* in case no valid value is found, use this */
+ if (use_default) {
+ map[i] = i;
+ }
- if (!STREQ(name_flip, dg->name)) {
- flip_num = BKE_object_defgroup_name_index(ob, name_flip);
- if (flip_num >= 0) {
- map[i] = flip_num;
- map[flip_num] = i; /* save an extra lookup */
- }
+ BLI_string_flip_side_name(name_flip, dg->name, false, sizeof(name_flip));
+
+ if (!STREQ(name_flip, dg->name)) {
+ flip_num = BKE_object_defgroup_name_index(ob, name_flip);
+ if (flip_num >= 0) {
+ map[i] = flip_num;
+ map[flip_num] = i; /* save an extra lookup */
}
}
}
- return map;
}
+ return map;
}
/**
@@ -555,29 +554,28 @@ int *BKE_object_defgroup_flip_map_single(const Object *ob,
if (defbase_tot == 0) {
return NULL;
}
- else {
- bDeformGroup *dg;
- char name_flip[sizeof(dg->name)];
- int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);
- for (i = 0; i < defbase_tot; i++) {
- map[i] = use_default ? i : -1;
- }
+ bDeformGroup *dg;
+ char name_flip[sizeof(dg->name)];
+ int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);
- dg = BLI_findlink(&ob->defbase, defgroup);
+ for (i = 0; i < defbase_tot; i++) {
+ map[i] = use_default ? i : -1;
+ }
- BLI_string_flip_side_name(name_flip, dg->name, false, sizeof(name_flip));
- if (!STREQ(name_flip, dg->name)) {
- flip_num = BKE_object_defgroup_name_index(ob, name_flip);
+ dg = BLI_findlink(&ob->defbase, defgroup);
- if (flip_num != -1) {
- map[defgroup] = flip_num;
- map[flip_num] = defgroup;
- }
- }
+ BLI_string_flip_side_name(name_flip, dg->name, false, sizeof(name_flip));
+ if (!STREQ(name_flip, dg->name)) {
+ flip_num = BKE_object_defgroup_name_index(ob, name_flip);
- return map;
+ if (flip_num != -1) {
+ map[defgroup] = flip_num;
+ map[flip_num] = defgroup;
+ }
}
+
+ return map;
}
int BKE_object_defgroup_flip_index(const Object *ob, int index, const bool use_default)
@@ -658,7 +656,7 @@ float BKE_defvert_array_find_weight_safe(const struct MDeformVert *dvert,
if (defgroup == -1) {
return 1.0f;
}
- else if (dvert == NULL) {
+ if (dvert == NULL) {
return 0.0f;
}
@@ -909,10 +907,9 @@ float BKE_defvert_calc_lock_relative_weight(float weight,
if (weight != 0.0f) {
return 1.0f;
}
- else {
- /* resolve 0/0 to 0 */
- return 0.0f;
- }
+
+ /* resolve 0/0 to 0 */
+ return 0.0f;
}
/* non-degenerate division */
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index a3e1eeb89c7..5c162486c85 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -172,7 +172,7 @@ void BKE_displist_normals_add(ListBase *lb)
while (dl) {
if (dl->type == DL_INDEX3) {
if (dl->nors == NULL) {
- dl->nors = MEM_callocN(sizeof(float) * 3, "dlnors");
+ dl->nors = MEM_callocN(sizeof(float[3]), "dlnors");
if (dl->flag & DL_BACK_CURVE) {
dl->nors[2] = -1.0f;
@@ -184,7 +184,7 @@ void BKE_displist_normals_add(ListBase *lb)
}
else if (dl->type == DL_SURF) {
if (dl->nors == NULL) {
- dl->nors = MEM_callocN(sizeof(float) * 3 * dl->nr * dl->parts, "dlnors");
+ dl->nors = MEM_callocN(sizeof(float[3]) * dl->nr * dl->parts, "dlnors");
vdata = dl->verts;
ndata = dl->nors;
@@ -411,7 +411,7 @@ static void curve_to_displist(Curve *cu,
bezt->vec[1][j],
data + j,
resolu,
- 3 * sizeof(float));
+ sizeof(float[3]));
}
data += 3 * resolu;
@@ -444,7 +444,7 @@ static void curve_to_displist(Curve *cu,
else {
dl->type = DL_SEGM;
}
- BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float));
+ BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, sizeof(float[3]));
}
else if (nu->type == CU_POLY) {
len = nu->pntsu;
@@ -571,8 +571,8 @@ void BKE_displist_fill(ListBase *dispbase,
dlnew->nr = totvert;
dlnew->parts = tot;
- dlnew->index = MEM_mallocN(tot * 3 * sizeof(int), "dlindex");
- dlnew->verts = MEM_mallocN(totvert * 3 * sizeof(float), "dlverts");
+ dlnew->index = MEM_mallocN(sizeof(int[3]) * tot, "dlindex");
+ dlnew->verts = MEM_mallocN(sizeof(float[3]) * totvert, "dlverts");
/* vert data */
f1 = dlnew->verts;
@@ -641,7 +641,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
if ((cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE)) {
dlnew = MEM_callocN(sizeof(DispList), "filldisp");
BLI_addtail(&front, dlnew);
- dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1");
+ dlnew->verts = fp1 = MEM_mallocN(sizeof(float[3]) * dl->parts, "filldisp1");
dlnew->nr = dl->parts;
dlnew->parts = 1;
dlnew->type = DL_POLY;
@@ -662,7 +662,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
if ((cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE)) {
dlnew = MEM_callocN(sizeof(DispList), "filldisp");
BLI_addtail(&back, dlnew);
- dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1");
+ dlnew->verts = fp1 = MEM_mallocN(sizeof(float[3]) * dl->parts, "filldisp1");
dlnew->nr = dl->parts;
dlnew->parts = 1;
dlnew->type = DL_POLY;
@@ -948,7 +948,7 @@ static float (*displist_vert_coords_alloc(ListBase *dispbase, int *r_vert_len))[
*r_vert_len += (dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr;
}
- allverts = MEM_mallocN((*r_vert_len) * sizeof(float) * 3, "displist_vert_coords_alloc allverts");
+ allverts = MEM_mallocN(sizeof(float[3]) * (*r_vert_len), "displist_vert_coords_alloc allverts");
fp = (float *)allverts;
for (dl = dispbase->first; dl; dl = dl->next) {
int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr);
@@ -1185,7 +1185,7 @@ static void displist_surf_indices(DispList *dl)
dl->totindex = 0;
- index = dl->index = MEM_mallocN(4 * sizeof(int) * (dl->parts + 1) * (dl->nr + 1),
+ index = dl->index = MEM_mallocN(sizeof(int[4]) * (dl->parts + 1) * (dl->nr + 1),
"index array nurbs");
for (a = 0; a < dl->parts; a++) {
@@ -1274,7 +1274,7 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
dl->type = DL_SEGM;
}
- BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float));
+ BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, sizeof(float[3]));
}
else {
len = (nu->pntsu * resolu) * (nu->pntsv * resolv);
@@ -1388,7 +1388,7 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp
dl = MEM_callocN(sizeof(DispList), "makeDispListbev2");
dl->verts = MEM_mallocN(sizeof(float[3]) * dlb->nr, "dlverts");
- memcpy(dl->verts, prev_fp, 3 * sizeof(float) * dlb->nr);
+ memcpy(dl->verts, prev_fp, sizeof(float[3]) * dlb->nr);
dl->type = DL_POLY;
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index b9279ace39f..1c61afe5e5a 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -320,7 +320,7 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface)
if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) {
return 0; /* not supported atm */
}
- else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
+ if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
const Mesh *canvas_mesh = dynamicPaint_canvas_mesh_get(surface->canvas);
return (canvas_mesh) ? canvas_mesh->totvert : 0;
}
@@ -353,7 +353,7 @@ bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object
Mesh *me = ob->data;
return (CustomData_get_named_layer_index(&me->ldata, CD_MLOOPCOL, name) != -1);
}
- else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
+ if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
return (BKE_object_defgroup_name_index(ob, name) != -1);
}
}
@@ -602,7 +602,7 @@ static bool boundIntersectPoint(Bounds3D *b, const float point[3], const float r
}
/* expand bounds by a new point */
-static void boundInsert(Bounds3D *b, float point[3])
+static void boundInsert(Bounds3D *b, const float point[3])
{
if (!b->valid) {
copy_v3_v3(b->min, point);
@@ -2675,7 +2675,7 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
int w = bdata->w, h = bdata->h, px = bdata->px, py = bdata->py;
- int final_pixel[2] = {(int)floorf(tgt_pixel[0] * w), (int)floorf(tgt_pixel[1] * h)};
+ const int final_pixel[2] = {(int)floorf(tgt_pixel[0] * w), (int)floorf(tgt_pixel[1] * h)};
/* If current pixel uv is outside of texture */
if (final_pixel[0] < 0 || final_pixel[0] >= w || final_pixel[1] < 0 || final_pixel[1] >= h) {
@@ -3742,7 +3742,7 @@ static bool meshBrush_boundsIntersect(Bounds3D *b1,
if (brush->collision == MOD_DPAINT_COL_VOLUME) {
return boundsIntersect(b1, b2);
}
- else if (brush->collision == MOD_DPAINT_COL_DIST || brush->collision == MOD_DPAINT_COL_VOLDIST) {
+ if (brush->collision == MOD_DPAINT_COL_DIST || brush->collision == MOD_DPAINT_COL_VOLDIST) {
return boundsIntersectDist(b1, b2, brush_radius);
}
return true;
@@ -4203,7 +4203,7 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
brushVelocity[v3].v,
weights);
- /* substract canvas point velocity */
+ /* subtract canvas point velocity */
if (bData->velocity) {
sub_v3_v3v3(velocity, brushPointVelocity, bData->velocity[index].v);
}
@@ -4548,7 +4548,7 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex(
ParticleData *pa = psys->particles + part_index;
mul_v3_v3fl(velocity, pa->state.vel, particle_timestep);
- /* substract canvas point velocity */
+ /* subtract canvas point velocity */
if (bData->velocity) {
sub_v3_v3(velocity, bData->velocity[index].v);
}
@@ -4739,7 +4739,7 @@ static void dynamic_paint_paint_single_point_cb_ex(void *__restrict userdata,
if (brush->flags & MOD_DPAINT_USES_VELOCITY) {
float velocity[3];
- /* substract canvas point velocity */
+ /* subtract canvas point velocity */
if (bData->velocity) {
sub_v3_v3v3(velocity, brushVelocity->v, bData->velocity[index].v);
}
@@ -5166,7 +5166,7 @@ static int dynamicPaint_prepareEffectStep(struct Depsgraph *depsgraph,
ListBase *effectors = BKE_effectors_create(depsgraph, ob, NULL, surface->effector_weights);
/* allocate memory for force data (dir vector + strength) */
- *force = MEM_mallocN(sData->total_points * 4 * sizeof(float), "PaintEffectForces");
+ *force = MEM_mallocN(sizeof(float[4]) * sData->total_points, "PaintEffectForces");
if (*force) {
DynamicPaintEffectData data = {
@@ -6260,7 +6260,7 @@ static int dynamicPaint_doStep(Depsgraph *depsgraph,
/* calculate brush speed vectors if required */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT && brush->flags & MOD_DPAINT_DO_SMUDGE) {
- bData->brush_velocity = MEM_callocN(sData->total_points * sizeof(float) * 4,
+ bData->brush_velocity = MEM_callocN(sizeof(float[4]) * sData->total_points,
"Dynamic Paint brush velocity");
/* init adjacency data if not already */
if (!sData->adj_data) {
diff --git a/source/blender/blenkernel/intern/editmesh_bvh.c b/source/blender/blenkernel/intern/editmesh_bvh.c
index 72793919570..dc194f0077c 100644
--- a/source/blender/blenkernel/intern/editmesh_bvh.c
+++ b/source/blender/blenkernel/intern/editmesh_bvh.c
@@ -563,8 +563,7 @@ static bool bmbvh_overlap_cb(void *userdata, int index_a, int index_b, int UNUSE
}
}
- return (isect_tri_tri_epsilon_v3(
- UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1], data->epsilon) &&
+ return (isect_tri_tri_v3(UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1]) &&
/* if we share a vertex, check the intersection isn't a 'point' */
((verts_shared == 0) || (len_squared_v3v3(ix_pair[0], ix_pair[1]) > data->epsilon)));
}
diff --git a/source/blender/blenkernel/intern/editmesh_cache.c b/source/blender/blenkernel/intern/editmesh_cache.c
index 5017a48d14e..d0509c94fc6 100644
--- a/source/blender/blenkernel/intern/editmesh_cache.c
+++ b/source/blender/blenkernel/intern/editmesh_cache.c
@@ -148,11 +148,10 @@ bool BKE_editmesh_cache_calc_minmax(struct BMEditMesh *em,
}
return true;
}
- else {
- zero_v3(min);
- zero_v3(max);
- return false;
- }
+
+ zero_v3(min);
+ zero_v3(max);
+ return false;
}
/** \} */
diff --git a/source/blender/blenkernel/intern/editmesh_tangent.c b/source/blender/blenkernel/intern/editmesh_tangent.c
index 6fcaf84d4ca..897fc7e692b 100644
--- a/source/blender/blenkernel/intern/editmesh_tangent.c
+++ b/source/blender/blenkernel/intern/editmesh_tangent.c
@@ -274,8 +274,8 @@ static void emDM_calc_loop_tangents_thread(TaskPool *__restrict UNUSED(pool), vo
/**
* \see #BKE_mesh_calc_loop_tangent, same logic but used arrays instead of #BMesh data.
*
- * \note This function is not so normal, its using `bm->ldata` as input,
- * but output's to `dm->loopData`.
+ * \note This function is not so normal, its using #BMesh.ldata as input,
+ * but output's to #Mesh.ldata.
* This is done because #CD_TANGENT is cache data used only for drawing.
*/
void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index a43553ee89f..97f9cebf58b 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -313,10 +313,10 @@ ListBase *BKE_effectors_create(Depsgraph *depsgraph,
if (ob == ob_src) {
continue;
}
- else if (weights->weight[ob->pd->forcefield] == 0.0f) {
+ if (weights->weight[ob->pd->forcefield] == 0.0f) {
continue;
}
- else if (ob->pd->shape == PFIELD_SHAPE_POINTS && BKE_object_get_evaluated_mesh(ob) == NULL) {
+ if (ob->pd->shape == PFIELD_SHAPE_POINTS && BKE_object_get_evaluated_mesh(ob) == NULL) {
continue;
}
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index acbbf50701a..abed90e7192 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -320,7 +320,7 @@ int BKE_fcurves_filter(ListBase *dst, ListBase *src, const char *dataPrefix, con
if (ELEM(NULL, dst, src, dataPrefix, dataName)) {
return 0;
}
- else if ((dataPrefix[0] == 0) || (dataName[0] == 0)) {
+ if ((dataPrefix[0] == 0) || (dataName[0] == 0)) {
return 0;
}
@@ -915,7 +915,7 @@ void bezt_add_to_cfra_elem(ListBase *lb, BezTriple *bezt)
return;
}
/* should key be inserted before this column? */
- else if (ce->cfra > bezt->vec[1][0]) {
+ if (ce->cfra > bezt->vec[1][0]) {
break;
}
}
diff --git a/source/blender/blenkernel/intern/fcurve_driver.c b/source/blender/blenkernel/intern/fcurve_driver.c
index 87cb77930f5..b11a3cb9457 100644
--- a/source/blender/blenkernel/intern/fcurve_driver.c
+++ b/source/blender/blenkernel/intern/fcurve_driver.c
@@ -488,10 +488,9 @@ static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar)
dtar->flag |= DTAR_FLAG_INVALID;
return 0.0f;
}
- else {
- /* Target should be valid now. */
- dtar->flag &= ~DTAR_FLAG_INVALID;
- }
+
+ /* Target should be valid now. */
+ dtar->flag &= ~DTAR_FLAG_INVALID;
/* Try to get pose-channel. */
pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
@@ -560,20 +559,17 @@ static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar)
/* Not valid channel. */
return 0.0f;
}
- else if (dtar->transChan == DTAR_TRANSCHAN_SCALE_AVG) {
+ if (dtar->transChan == DTAR_TRANSCHAN_SCALE_AVG) {
/* Cubic root of the change in volume, equal to the geometric mean
* of scale over all three axes unless the matrix includes shear. */
return cbrtf(mat4_to_volume_scale(mat));
}
- else if (ELEM(dtar->transChan,
- DTAR_TRANSCHAN_SCALEX,
- DTAR_TRANSCHAN_SCALEY,
- DTAR_TRANSCHAN_SCALEZ)) {
+ if (ELEM(dtar->transChan, DTAR_TRANSCHAN_SCALEX, DTAR_TRANSCHAN_SCALEY, DTAR_TRANSCHAN_SCALEZ)) {
/* Extract scale, and choose the right axis,
* inline 'mat4_to_size'. */
return len_v3(mat[dtar->transChan - DTAR_TRANSCHAN_SCALEX]);
}
- else if (dtar->transChan >= DTAR_TRANSCHAN_ROTX) {
+ if (dtar->transChan >= DTAR_TRANSCHAN_ROTX) {
/* Extract rotation as eulers (if needed)
* - definitely if rotation order isn't eulers already
* - if eulers, then we have 2 options:
@@ -602,10 +598,9 @@ static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar)
return quat[channel];
}
- else {
- /* Extract location and choose right axis. */
- return mat[3][dtar->transChan];
- }
+
+ /* Extract location and choose right axis. */
+ return mat[3][dtar->transChan];
}
/* Convert a quaternion to pseudo-angles representing the weighted amount of rotation. */
@@ -715,9 +710,8 @@ static const DriverVarTypeInfo *get_dvar_typeinfo(int type)
if ((type >= 0) && (type < MAX_DVAR_TYPES)) {
return &dvar_types[type];
}
- else {
- return NULL;
- }
+
+ return NULL;
}
/** \} */
@@ -1126,10 +1120,9 @@ bool BKE_driver_expression_depends_on_time(ChannelDriver *driver)
/* Simple expressions can be checked exactly. */
return driver_check_simple_expr_depends_on_time(driver->expr_simple);
}
- else {
- /* Otherwise, heuristically scan the expression string for certain patterns. */
- return python_driver_exression_depends_on_time(driver->expression);
- }
+
+ /* Otherwise, heuristically scan the expression string for certain patterns. */
+ return python_driver_exression_depends_on_time(driver->expression);
}
/* Reset cached compiled expression data */
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 079b436a3ea..ee7d85ba3fb 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -533,14 +533,14 @@ static bool BKE_fluid_modifier_init(
/* Allocate fluid. */
return BKE_fluid_reallocate_fluid(fds, fds->res, 0);
}
- else if (fmd->type & MOD_FLUID_TYPE_FLOW) {
+ if (fmd->type & MOD_FLUID_TYPE_FLOW) {
if (!fmd->flow) {
BKE_fluid_modifier_create_type_data(fmd);
}
fmd->time = scene_framenr;
return true;
}
- else if (fmd->type & MOD_FLUID_TYPE_EFFEC) {
+ if (fmd->type & MOD_FLUID_TYPE_EFFEC) {
if (!fmd->effector) {
BKE_fluid_modifier_create_type_data(fmd);
}
@@ -575,7 +575,7 @@ static int get_light(ViewLayer *view_layer, float *light)
copy_v3_v3(light, base_tmp->object->obmat[3]);
return 1;
}
- else if (!found_light) {
+ if (!found_light) {
copy_v3_v3(light, base_tmp->object->obmat[3]);
found_light = 1;
}
@@ -655,7 +655,7 @@ typedef struct FluidObjectBB {
int total_cells, valid;
} FluidObjectBB;
-static void bb_boundInsert(FluidObjectBB *bb, float point[3])
+static void bb_boundInsert(FluidObjectBB *bb, const float point[3])
{
int i = 0;
if (!bb->valid) {
@@ -695,7 +695,7 @@ static void bb_allocateData(FluidObjectBB *bb, bool use_velocity, bool use_influ
bb->influence = MEM_calloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_influence");
}
if (use_velocity) {
- bb->velocity = MEM_calloc_arrayN(bb->total_cells * 3, sizeof(float), "fluid_bb_velocity");
+ bb->velocity = MEM_calloc_arrayN(bb->total_cells, sizeof(float[3]), "fluid_bb_velocity");
}
bb->distances = MEM_malloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_distances");
@@ -955,7 +955,7 @@ static void obstacles_from_mesh_task_cb(void *__restrict userdata,
for (int y = data->min[1]; y < data->max[1]; y++) {
const int index = manta_get_index(
x - bb->min[0], bb->res[0], y - bb->min[1], bb->res[1], z - bb->min[2]);
- float ray_start[3] = {(float)x + 0.5f, (float)y + 0.5f, (float)z + 0.5f};
+ const float ray_start[3] = {(float)x + 0.5f, (float)y + 0.5f, (float)z + 0.5f};
/* Calculate object velocities. Result in bb->velocity. */
sample_effector(data->fes,
@@ -1021,14 +1021,14 @@ static void obstacles_from_mesh(Object *coll_ob,
/* TODO (sebbas): Make initialization of vertex velocities optional? */
{
- vert_vel = MEM_callocN(sizeof(float) * numverts * 3, "manta_obs_velocity");
+ vert_vel = MEM_callocN(sizeof(float[3]) * numverts, "manta_obs_velocity");
if (fes->numverts != numverts || !fes->verts_old) {
if (fes->verts_old) {
MEM_freeN(fes->verts_old);
}
- fes->verts_old = MEM_callocN(sizeof(float) * numverts * 3, "manta_obs_verts_old");
+ fes->verts_old = MEM_callocN(sizeof(float[3]) * numverts, "manta_obs_verts_old");
fes->numverts = numverts;
}
else {
@@ -1119,6 +1119,7 @@ static void ensure_obstaclefields(FluidDomainSettings *fds)
if (fds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE) {
manta_ensure_guiding(fds->fluid, fds->fmd);
}
+ manta_update_pointers(fds->fluid, fds->fmd, false);
}
static void update_obstacleflags(FluidDomainSettings *fds,
@@ -1577,9 +1578,9 @@ static void emit_from_particles(Object *flow_ob,
totchild = psys->totchild * psys->part->disp / 100;
}
- particle_pos = MEM_callocN(sizeof(float) * (totpart + totchild) * 3,
+ particle_pos = MEM_callocN(sizeof(float[3]) * (totpart + totchild),
"manta_flow_particles_pos");
- particle_vel = MEM_callocN(sizeof(float) * (totpart + totchild) * 3,
+ particle_vel = MEM_callocN(sizeof(float[3]) * (totpart + totchild),
"manta_flow_particles_vel");
/* setup particle radius emission if enabled */
@@ -1756,14 +1757,13 @@ static void update_distances(int index,
{0.0f, -1.0f, 1.0f}, {0.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f}, {1.0f, -1.0f, 1.0f},
{-1.0f, 1.0f, 1.0f}, {-1.0f, -1.0f, 1.0f}, {1.0f, 1.0f, -1.0f}, {1.0f, -1.0f, -1.0f},
{-1.0f, 1.0f, -1.0f}, {-1.0f, -1.0f, -1.0f}};
- size_t ray_cnt = sizeof ray_dirs / sizeof ray_dirs[0];
/* Count ray mesh misses (i.e. no face hit) and cases where the ray direction matches the face
* normal direction. From this information it can be derived whether a cell is inside or
* outside the mesh. */
int miss_cnt = 0, dir_cnt = 0;
- for (int i = 0; i < ray_cnt; i++) {
+ for (int i = 0; i < ARRAY_SIZE(ray_dirs); i++) {
BVHTreeRayHit hit_tree = {0};
hit_tree.index = -1;
hit_tree.dist = PHI_MAX;
@@ -1797,7 +1797,7 @@ static void update_distances(int index,
/* Point lies inside mesh. Use negative sign for distance value.
* This "if statement" has 2 conditions that can be true for points outside mesh. */
- if (!(miss_cnt > 0 || dir_cnt == ray_cnt)) {
+ if (!(miss_cnt > 0 || dir_cnt == ARRAY_SIZE(ray_dirs))) {
min_dist = (-1.0f) * fabsf(min_dist);
}
@@ -2100,13 +2100,13 @@ static void emit_from_mesh(
mloopuv = CustomData_get_layer_named(&me->ldata, CD_MLOOPUV, ffs->uvlayer_name);
if (ffs->flags & FLUID_FLOW_INITVELOCITY) {
- vert_vel = MEM_callocN(sizeof(float) * numverts * 3, "manta_flow_velocity");
+ vert_vel = MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_velocity");
if (ffs->numverts != numverts || !ffs->verts_old) {
if (ffs->verts_old) {
MEM_freeN(ffs->verts_old);
}
- ffs->verts_old = MEM_callocN(sizeof(float) * numverts * 3, "manta_flow_verts_old");
+ ffs->verts_old = MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_verts_old");
ffs->numverts = numverts;
}
else {
@@ -2596,7 +2596,7 @@ static void ensure_flowsfields(FluidDomainSettings *fds)
manta_smoke_ensure_fire(fds->fluid, fds->fmd);
}
if (fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) {
- /* initialize all smoke with "active_color" */
+ /* Initialize all smoke with "active_color". */
manta_smoke_ensure_colors(fds->fluid, fds->fmd);
}
if (fds->type == FLUID_DOMAIN_TYPE_LIQUID &&
@@ -2605,6 +2605,7 @@ static void ensure_flowsfields(FluidDomainSettings *fds)
fds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER)) {
manta_liquid_ensure_sndparts(fds->fluid, fds->fmd);
}
+ manta_update_pointers(fds->fluid, fds->fmd, false);
}
static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int numflowobj)
@@ -2617,7 +2618,7 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n
FLUID_DOMAIN_ACTIVE_HEAT | FLUID_DOMAIN_ACTIVE_FIRE);
active_fields &= ~prev_flags;
- /* Monitor active fields based on flow settings */
+ /* Monitor active fields based on flow settings. */
for (flow_index = 0; flow_index < numflowobj; flow_index++) {
Object *flow_ob = flowobjs[flow_index];
FluidModifierData *fmd2 = (FluidModifierData *)BKE_modifiers_findby_type(flow_ob,
@@ -2628,6 +2629,7 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n
continue;
}
+ /* Activate specific grids if at least one flow object requires this grid. */
if ((fmd2->type & MOD_FLUID_TYPE_FLOW) && fmd2->flow) {
FluidFlowSettings *ffs = fmd2->flow;
if (!ffs) {
@@ -2648,17 +2650,17 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n
continue;
}
- /* activate heat field if flow produces any heat */
- if (ffs->temperature) {
+ /* Activate heat field if a flow object produces any heat. */
+ if (ffs->temperature != 0.0) {
active_fields |= FLUID_DOMAIN_ACTIVE_HEAT;
}
- /* activate fuel field if flow adds any fuel */
- if (ffs->fuel_amount &&
- (ffs->type == FLUID_FLOW_TYPE_FIRE || ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE)) {
+ /* Activate fuel field if a flow object is of fire type. */
+ if (ffs->fuel_amount != 0.0 || ffs->type == FLUID_FLOW_TYPE_FIRE ||
+ ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE) {
active_fields |= FLUID_DOMAIN_ACTIVE_FIRE;
}
- /* activate color field if flows add smoke with varying colors */
- if (ffs->density &&
+ /* Activate color field if flows add smoke with varying colors. */
+ if (ffs->density != 0.0 &&
(ffs->type == FLUID_FLOW_TYPE_SMOKE || ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE)) {
if (!(active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET)) {
copy_v3_v3(fds->active_color, ffs->color);
@@ -2671,11 +2673,11 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n
}
}
}
- /* Monitor active fields based on domain settings */
+ /* Monitor active fields based on domain settings. */
if (fds->type == FLUID_DOMAIN_TYPE_GAS && active_fields & FLUID_DOMAIN_ACTIVE_FIRE) {
- /* heat is always needed for fire */
+ /* Heat is always needed for fire. */
active_fields |= FLUID_DOMAIN_ACTIVE_HEAT;
- /* also activate colors if domain smoke color differs from active color */
+ /* Also activate colors if domain smoke color differs from active color. */
if (!(active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET)) {
copy_v3_v3(fds->active_color, fds->flame_smoke_color);
active_fields |= FLUID_DOMAIN_ACTIVE_COLOR_SET;
@@ -2924,8 +2926,21 @@ static void update_flowsfluids(struct Depsgraph *depsgraph,
float *velx_initial = manta_get_in_velocity_x(fds->fluid);
float *vely_initial = manta_get_in_velocity_y(fds->fluid);
float *velz_initial = manta_get_in_velocity_z(fds->fluid);
- uint z;
+ float *forcex = manta_get_force_x(fds->fluid);
+ float *forcey = manta_get_force_y(fds->fluid);
+ float *forcez = manta_get_force_z(fds->fluid);
+
+ BLI_assert(forcex && forcey && forcez);
+
+ /* Either all or no components have to exist. */
+ BLI_assert((color_r && color_g && color_b) || (!color_r && !color_g && !color_b));
+ BLI_assert((color_r_in && color_g_in && color_b_in) ||
+ (!color_r_in && !color_g_in && !color_b_in));
+ BLI_assert((velx_initial && vely_initial && velz_initial) ||
+ (!velx_initial && !vely_initial && !velz_initial));
+
+ uint z;
/* Grid reset before writing again. */
for (z = 0; z < fds->res[0] * fds->res[1] * fds->res[2]; z++) {
/* Only reset static phi on first frame, dynamic phi gets reset every time. */
@@ -2949,7 +2964,7 @@ static void update_flowsfluids(struct Depsgraph *depsgraph,
if (heat_in) {
heat_in[z] = heat[z];
}
- if (color_r_in) {
+ if (color_r_in && color_g_in && color_b_in) {
color_r_in[z] = color_r[z];
color_g_in[z] = color_b[z];
color_b_in[z] = color_g[z];
@@ -2961,11 +2976,15 @@ static void update_flowsfluids(struct Depsgraph *depsgraph,
if (emission_in) {
emission_in[z] = 0.0f;
}
- if (velx_initial) {
+ if (velx_initial && vely_initial && velz_initial) {
velx_initial[z] = 0.0f;
vely_initial[z] = 0.0f;
velz_initial[z] = 0.0f;
}
+ /* Reset forces here as update_effectors() is skipped when no external forces are present. */
+ forcex[z] = 0.0f;
+ forcey[z] = 0.0f;
+ forcez[z] = 0.0f;
}
/* Apply emission data for every flow object. */
@@ -3149,13 +3168,13 @@ static void update_effectors_task_cb(void *__restrict userdata,
continue;
}
- /* get velocities from manta grid space and convert to blender units */
+ /* Get velocities from manta grid space and convert to blender units. */
vel[0] = data->velocity_x[index];
vel[1] = data->velocity_y[index];
vel[2] = data->velocity_z[index];
mul_v3_fl(vel, fds->dx);
- /* convert vel to global space */
+ /* Convert vel to global space. */
mag = len_v3(vel);
mul_mat3_m4_v3(fds->obmat, vel);
normalize_v3(vel);
@@ -3166,18 +3185,18 @@ static void update_effectors_task_cb(void *__restrict userdata,
voxel_center[2] = fds->p0[2] + fds->cell_size[2] * ((float)(z + fds->res_min[2]) + 0.5f);
mul_m4_v3(fds->obmat, voxel_center);
- /* do effectors */
+ /* Do effectors. */
pd_point_from_loc(data->scene, voxel_center, vel, index, &epoint);
BKE_effectors_apply(
data->effectors, NULL, fds->effector_weights, &epoint, retvel, NULL, NULL);
- /* convert retvel to local space */
+ /* Convert retvel to local space. */
mag = len_v3(retvel);
mul_mat3_m4_v3(fds->imat, retvel);
normalize_v3(retvel);
mul_v3_fl(retvel, mag);
- /* constrain forces to interval -1 to 1 */
+ /* Constrain forces to interval -1 to 1. */
data->force_x[index] = min_ff(max_ff(-1.0f, retvel[0] * 0.2f), 1.0f);
data->force_y[index] = min_ff(max_ff(-1.0f, retvel[1] * 0.2f), 1.0f);
data->force_z[index] = min_ff(max_ff(-1.0f, retvel[2] * 0.2f), 1.0f);
@@ -3311,7 +3330,7 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds, Mesh *orgmesh, Obj
co_offset[2] = (fds->p0[2] + fds->p1[2]) / 2.0f;
/* Normals. */
- normals = MEM_callocN(sizeof(short) * num_normals * 3, "Fluidmesh_tmp_normals");
+ normals = MEM_callocN(sizeof(short[3]) * num_normals, "Fluidmesh_tmp_normals");
/* Loop for vertices and normals. */
for (i = 0, no_s = normals; i < num_verts && i < num_normals; i++, mverts++, no_s += 3) {
@@ -3617,14 +3636,16 @@ static int manta_step(
fds->time_per_frame = time_per_frame;
fds->time_total = time_total;
}
+
/* Total time must not exceed framecount times framelength. Correct tiny errors here. */
CLAMP(fds->time_total, fds->time_total, time_total_old + fds->frame_length);
+ /* Compute shadow grid for gas simulations. Make sure to skip if bake job was canceled early. */
if (fds->type == FLUID_DOMAIN_TYPE_GAS && result) {
manta_smoke_calc_transparency(fds, DEG_get_evaluated_view_layer(depsgraph));
}
- BLI_mutex_unlock(&object_update_lock);
+ BLI_mutex_unlock(&object_update_lock);
return result;
}
@@ -3716,29 +3737,35 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
int mode = fds->cache_type;
/* Do not process modifier if current frame is out of cache range. */
+ bool escape = false;
switch (mode) {
case FLUID_DOMAIN_CACHE_ALL:
case FLUID_DOMAIN_CACHE_MODULAR:
if (fds->cache_frame_offset > 0) {
if (scene_framenr < fds->cache_frame_start ||
scene_framenr > fds->cache_frame_end + fds->cache_frame_offset) {
- return;
+ escape = true;
}
}
else {
if (scene_framenr < fds->cache_frame_start + fds->cache_frame_offset ||
scene_framenr > fds->cache_frame_end) {
- return;
+ escape = true;
}
}
break;
case FLUID_DOMAIN_CACHE_REPLAY:
default:
if (scene_framenr < fds->cache_frame_start || scene_framenr > fds->cache_frame_end) {
- return;
+ escape = true;
}
break;
}
+ /* If modifier will not be processed, update/flush pointers from (old) fluid object once more. */
+ if (escape && fds->fluid) {
+ manta_update_pointers(fds->fluid, fmd, true);
+ return;
+ }
/* Reset fluid if no fluid present. Also resets active fields. */
if (!fds->fluid) {
@@ -3830,7 +3857,15 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
has_mesh = manta_has_mesh(fds->fluid, fmd, scene_framenr);
has_particles = manta_has_particles(fds->fluid, fmd, scene_framenr);
has_guide = manta_has_guiding(fds->fluid, fmd, scene_framenr, guide_parent);
- has_config = false;
+ has_config = manta_read_config(fds->fluid, fmd, scene_framenr);
+
+ /* When reading data from cache (has_config == true) ensure that active fields are allocated.
+ * update_flowsflags() and update_obstacleflags() will not find flow sources hidden from renders.
+ * See also: T72192. */
+ if (has_config) {
+ ensure_flowsfields(fds);
+ ensure_obstaclefields(fds);
+ }
bool baking_data, baking_noise, baking_mesh, baking_particles, baking_guide;
baking_data = fds->cache_flag & FLUID_DOMAIN_BAKING_DATA;
@@ -3947,7 +3982,9 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
/* Read mesh cache. */
if (with_liquid && with_mesh) {
- has_config = manta_read_config(fds->fluid, fmd, mesh_frame);
+ if (mesh_frame != scene_framenr) {
+ has_config = manta_read_config(fds->fluid, fmd, mesh_frame);
+ }
/* Update mesh data from file is faster than via Python (manta_read_mesh()). */
has_mesh = manta_read_mesh(fds->fluid, fmd, mesh_frame);
@@ -3955,7 +3992,9 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
/* Read particles cache. */
if (with_liquid && with_particles) {
- has_config = manta_read_config(fds->fluid, fmd, particles_frame);
+ if (particles_frame != scene_framenr) {
+ has_config = manta_read_config(fds->fluid, fmd, particles_frame);
+ }
read_partial = !baking_data && !baking_particles && next_particles;
read_all = !read_partial && with_resumable_cache;
@@ -3970,7 +4009,9 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
/* Read noise and data cache */
if (with_smoke && with_noise) {
- has_config = manta_read_config(fds->fluid, fmd, noise_frame);
+ if (noise_frame != scene_framenr) {
+ has_config = manta_read_config(fds->fluid, fmd, noise_frame);
+ }
/* Only reallocate when just reading cache or when resuming during bake. */
if (has_data && has_config && manta_needs_realloc(fds->fluid, fmd)) {
@@ -3988,7 +4029,9 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
}
/* Read data cache only */
else {
- has_config = manta_read_config(fds->fluid, fmd, data_frame);
+ if (data_frame != scene_framenr) {
+ has_config = manta_read_config(fds->fluid, fmd, data_frame);
+ }
if (with_smoke) {
/* Read config and realloc fluid object if needed. */
@@ -4073,6 +4116,9 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
}
}
+ /* Ensure that fluid pointers are always up to date at the end of modifier processing. */
+ manta_update_pointers(fds->fluid, fmd, false);
+
fds->flags &= ~FLUID_DOMAIN_FILE_LOAD;
fmd->time = scene_framenr;
}
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index c85283e3653..c973b681fe7 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -285,9 +285,8 @@ static double sinc(double x)
if (fabs(x) < 0.0001) {
return 1.0;
}
- else {
- return sin(M_PI * x) / (M_PI * x);
- }
+
+ return sin(M_PI * x) / (M_PI * x);
}
static void fcm_fn_generator_evaluate(
@@ -525,29 +524,28 @@ int BKE_fcm_envelope_find_index(FCM_EnvelopeData array[],
CLOG_WARN(&LOG, "encountered invalid array");
return 0;
}
- else {
- /* check whether to add before/after/on */
- float framenum;
- /* 'First' Point (when only one point, this case is used) */
- framenum = array[0].time;
- if (IS_EQT(frame, framenum, BINARYSEARCH_FRAMEEQ_THRESH)) {
- *r_exists = true;
- return 0;
- }
- else if (frame < framenum) {
- return 0;
- }
+ /* check whether to add before/after/on */
+ float framenum;
- /* 'Last' Point */
- framenum = array[(arraylen - 1)].time;
- if (IS_EQT(frame, framenum, BINARYSEARCH_FRAMEEQ_THRESH)) {
- *r_exists = true;
- return (arraylen - 1);
- }
- else if (frame > framenum) {
- return arraylen;
- }
+ /* 'First' Point (when only one point, this case is used) */
+ framenum = array[0].time;
+ if (IS_EQT(frame, framenum, BINARYSEARCH_FRAMEEQ_THRESH)) {
+ *r_exists = true;
+ return 0;
+ }
+ if (frame < framenum) {
+ return 0;
+ }
+
+ /* 'Last' Point */
+ framenum = array[(arraylen - 1)].time;
+ if (IS_EQT(frame, framenum, BINARYSEARCH_FRAMEEQ_THRESH)) {
+ *r_exists = true;
+ return (arraylen - 1);
+ }
+ if (frame > framenum) {
+ return arraylen;
}
/* most of the time, this loop is just to find where to put it
@@ -1076,9 +1074,8 @@ const FModifierTypeInfo *get_fmodifier_typeinfo(const int type)
/* there shouldn't be any segfaults here... */
return fmodifiersTypeInfo[type];
}
- else {
- CLOG_ERROR(&LOG, "No valid F-Curve Modifier type-info data available. Type = %i", type);
- }
+
+ CLOG_ERROR(&LOG, "No valid F-Curve Modifier type-info data available. Type = %i", type);
return NULL;
}
@@ -1092,9 +1089,8 @@ const FModifierTypeInfo *fmodifier_get_typeinfo(const FModifier *fcm)
if (fcm) {
return get_fmodifier_typeinfo(fcm->type);
}
- else {
- return NULL;
- }
+
+ return NULL;
}
/* API --------------------------- */
@@ -1239,12 +1235,11 @@ bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
return true;
}
- else {
- /* XXX this case can probably be removed some day, as it shouldn't happen... */
- CLOG_STR_ERROR(&LOG, "no modifier stack given");
- MEM_freeN(fcm);
- return false;
- }
+
+ /* XXX this case can probably be removed some day, as it shouldn't happen... */
+ CLOG_STR_ERROR(&LOG, "no modifier stack given");
+ MEM_freeN(fcm);
+ return false;
}
/* Remove all of a given F-Curve's modifiers */
@@ -1397,13 +1392,13 @@ static float eval_fmodifier_influence(FModifier *fcm, float evaltime)
/* out of range */
return 0.0f;
}
- else if ((evaltime > fcm->sfra) && (evaltime < fcm->sfra + fcm->blendin)) {
+ if ((evaltime > fcm->sfra) && (evaltime < fcm->sfra + fcm->blendin)) {
/* blend in range */
float a = fcm->sfra;
float b = fcm->sfra + fcm->blendin;
return influence * (evaltime - a) / (b - a);
}
- else if ((evaltime < fcm->efra) && (evaltime > fcm->efra - fcm->blendout)) {
+ if ((evaltime < fcm->efra) && (evaltime > fcm->efra - fcm->blendout)) {
/* blend out range */
float a = fcm->efra;
float b = fcm->efra - fcm->blendout;
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 958acf0589b..4bedba8f76b 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -193,13 +193,12 @@ static PackedFile *get_builtin_packedfile(void)
return NULL;
}
- else {
- void *mem = MEM_mallocN(builtin_font_size, "vfd_builtin");
- memcpy(mem, builtin_font_data, builtin_font_size);
+ void *mem = MEM_mallocN(builtin_font_size, "vfd_builtin");
- return BKE_packedfile_new_from_memory(mem, builtin_font_size);
- }
+ memcpy(mem, builtin_font_data, builtin_font_size);
+
+ return BKE_packedfile_new_from_memory(mem, builtin_font_size);
}
static VFontData *vfont_get_data(VFont *vfont)
@@ -621,12 +620,11 @@ int BKE_vfont_select_get(Object *ob, int *r_start, int *r_end)
if (start == end + 1) {
return 0;
}
- else {
- BLI_assert(start < end + 1);
- *r_start = start;
- *r_end = end;
- return direction;
- }
+
+ BLI_assert(start < end + 1);
+ *r_start = start;
+ *r_end = end;
+ return direction;
}
void BKE_vfont_select_clamp(Object *ob)
@@ -647,12 +645,11 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info)
if (che == NULL) {
return 0.0f;
}
- else if (info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
+ if (info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
return che->width * cu->smallcaps_scale;
}
- else {
- return che->width;
- }
+
+ return che->width;
}
static void textbox_scale(TextBox *tb_dst, const TextBox *tb_src, float scale)
@@ -1603,32 +1600,32 @@ static bool vfont_to_curve(Object *ob,
}
return true;
}
+
+ ok = true;
+finally:
+ if (r_text) {
+ *r_text = mem;
+ *r_text_len = slen;
+ *r_text_free = (ef == NULL);
+ }
else {
- ok = true;
- finally:
- if (r_text) {
- *r_text = mem;
- *r_text_len = slen;
- *r_text_free = (ef == NULL);
+ if (ef == NULL) {
+ MEM_freeN((void *)mem);
+ }
+ }
+
+ if (chartransdata) {
+ if (ok && r_chartransdata) {
+ *r_chartransdata = chartransdata;
}
else {
- if (ef == NULL) {
- MEM_freeN((void *)mem);
- }
+ MEM_freeN(chartransdata);
}
+ }
- if (chartransdata) {
- if (ok && r_chartransdata) {
- *r_chartransdata = chartransdata;
- }
- else {
- MEM_freeN(chartransdata);
- }
- }
+ /* Store the effective scale, to use for the textbox lines. */
+ cu->fsize_realtime = font_size;
- /* Store the effective scale, to use for the textbox lines. */
- cu->fsize_realtime = font_size;
- }
return ok;
#undef MARGIN_X_MIN
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index eeb55c44d6e..c64f1b86eab 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -381,7 +381,7 @@ bGPDframe *BKE_gpencil_frame_addcopy(bGPDlayer *gpl, int cframe)
/* no layer */
return NULL;
}
- else if (gpl->actframe == NULL) {
+ if (gpl->actframe == NULL) {
/* no active frame, so just create a new one from scratch */
return BKE_gpencil_frame_addnew(gpl, cframe);
}
@@ -398,7 +398,7 @@ bGPDframe *BKE_gpencil_frame_addcopy(bGPDlayer *gpl, int cframe)
found = true;
break;
}
- else if (gpf->framenum == cframe) {
+ if (gpf->framenum == cframe) {
/* This only happens when we're editing with framelock on...
* - Delete the new frame and don't do anything else here...
*/
@@ -1009,7 +1009,7 @@ bGPDframe *BKE_gpencil_layer_frame_get(bGPDlayer *gpl, int cframe, eGP_GetFrame_
found = true;
break;
}
- else if ((gpf->next) && (gpf->next->framenum > cframe)) {
+ if ((gpf->next) && (gpf->next->framenum > cframe)) {
found = true;
break;
}
@@ -1484,10 +1484,9 @@ Material *BKE_gpencil_object_material_ensure_from_brush(Main *bmain, Object *ob,
return ma;
}
- else {
- /* using active material instead */
- return BKE_object_material_get(ob, ob->actcol);
- }
+
+ /* using active material instead */
+ return BKE_object_material_get(ob, ob->actcol);
}
/**
@@ -1546,9 +1545,8 @@ Material *BKE_gpencil_object_material_from_brush_get(Object *ob, Brush *brush)
Material *ma = BKE_gpencil_brush_material_get(brush);
return ma;
}
- else {
- return BKE_object_material_get(ob, ob->actcol);
- }
+
+ return BKE_object_material_get(ob, ob->actcol);
}
/**
@@ -1562,9 +1560,8 @@ int BKE_gpencil_object_material_get_index_from_brush(Object *ob, Brush *brush)
if ((brush) && (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED)) {
return BKE_gpencil_object_material_index_get(ob, brush->gpencil_settings->material);
}
- else {
- return ob->actcol - 1;
- }
+
+ return ob->actcol - 1;
}
/**
@@ -1581,9 +1578,8 @@ Material *BKE_gpencil_object_material_ensure_from_active_input_toolsettings(Main
return BKE_gpencil_object_material_ensure_from_active_input_brush(
bmain, ob, ts->gp_paint->paint.brush);
}
- else {
- return BKE_gpencil_object_material_ensure_from_active_input_brush(bmain, ob, NULL);
- }
+
+ return BKE_gpencil_object_material_ensure_from_active_input_brush(bmain, ob, NULL);
}
/**
@@ -1602,7 +1598,7 @@ Material *BKE_gpencil_object_material_ensure_from_active_input_brush(Main *bmain
if (ma) {
return ma;
}
- else if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
+ if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
/* it is easier to just unpin a NULL material, instead of setting a new one */
brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED;
}
@@ -2425,31 +2421,29 @@ void BKE_gpencil_parent_matrix_get(const Depsgraph *depsgraph,
unit_m4(diff_mat);
return;
}
- else {
- if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) {
- mul_m4_m4m4(diff_mat, obparent_eval->obmat, gpl->inverse);
+
+ if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) {
+ mul_m4_m4m4(diff_mat, obparent_eval->obmat, gpl->inverse);
+ add_v3_v3(diff_mat[3], ob_eval->obmat[3]);
+ return;
+ }
+ if (gpl->partype == PARBONE) {
+ bPoseChannel *pchan = BKE_pose_channel_find_name(obparent_eval->pose, gpl->parsubstr);
+ if (pchan) {
+ float tmp_mat[4][4];
+ mul_m4_m4m4(tmp_mat, obparent_eval->obmat, pchan->pose_mat);
+ mul_m4_m4m4(diff_mat, tmp_mat, gpl->inverse);
add_v3_v3(diff_mat[3], ob_eval->obmat[3]);
- return;
- }
- else if (gpl->partype == PARBONE) {
- bPoseChannel *pchan = BKE_pose_channel_find_name(obparent_eval->pose, gpl->parsubstr);
- if (pchan) {
- float tmp_mat[4][4];
- mul_m4_m4m4(tmp_mat, obparent_eval->obmat, pchan->pose_mat);
- mul_m4_m4m4(diff_mat, tmp_mat, gpl->inverse);
- add_v3_v3(diff_mat[3], ob_eval->obmat[3]);
- }
- else {
- /* if bone not found use object (armature) */
- mul_m4_m4m4(diff_mat, obparent_eval->obmat, gpl->inverse);
- add_v3_v3(diff_mat[3], ob_eval->obmat[3]);
- }
- return;
}
else {
- unit_m4(diff_mat); /* not defined type */
+ /* if bone not found use object (armature) */
+ mul_m4_m4m4(diff_mat, obparent_eval->obmat, gpl->inverse);
+ add_v3_v3(diff_mat[3], ob_eval->obmat[3]);
}
+ return;
}
+
+ unit_m4(diff_mat); /* not defined type */
}
/**
diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c
index 66e9e2184c1..6db5eaf28e0 100644
--- a/source/blender/blenkernel/intern/gpencil_curve.c
+++ b/source/blender/blenkernel/intern/gpencil_curve.c
@@ -50,11 +50,12 @@
#include "DEG_depsgraph_query.h"
/* Helper: Check materials with same color. */
-static int gpencil_check_same_material_color(Object *ob_gp, float color[4], Material **r_mat)
+static int gpencil_check_same_material_color(Object *ob_gp, const float color[4], Material **r_mat)
{
Material *ma = NULL;
float color_cu[4];
- linearrgb_to_srgb_v3_v3(color_cu, color);
+ copy_v4_v4(color_cu, color);
+
float hsv1[4];
rgb_to_hsv_v(color_cu, hsv1);
hsv1[3] = color[3];
@@ -95,12 +96,12 @@ static Material *gpencil_add_from_curve_material(Main *bmain,
gp_style->flag |= GP_MATERIAL_STROKE_SHOW;
}
else {
- linearrgb_to_srgb_v4(gp_style->stroke_rgba, cu_color);
+ copy_v4_v4(mat_gp->gp_style->stroke_rgba, cu_color);
gp_style->flag &= ~GP_MATERIAL_STROKE_SHOW;
}
/* Fill color. */
- linearrgb_to_srgb_v4(gp_style->fill_rgba, cu_color);
+ copy_v4_v4(mat_gp->gp_style->fill_rgba, cu_color);
/* Fill is false if the original curve hasn't material assigned, so enable it. */
if (fill) {
gp_style->flag |= GP_MATERIAL_FILL_SHOW;
@@ -173,7 +174,7 @@ static void gpencil_convert_spline(Main *bmain,
/* Create Stroke. */
bGPDstroke *gps = MEM_callocN(sizeof(bGPDstroke), "bGPDstroke");
- gps->thickness = 10.0f;
+ gps->thickness = 1.0f;
gps->fill_opacity_fac = 1.0f;
gps->hardeness = 1.0f;
gps->uv_scale = 1.0f;
@@ -249,8 +250,7 @@ static void gpencil_convert_spline(Main *bmain,
if ((!only_stroke) && (ob_cu->totcol > 1) && (BKE_object_material_get(ob_cu, 2))) {
mat_curve = BKE_object_material_get(ob_cu, 2);
if (mat_curve) {
- linearrgb_to_srgb_v3_v3(mat_gp->gp_style->stroke_rgba, &mat_curve->r);
- mat_gp->gp_style->stroke_rgba[3] = mat_curve->a;
+ copy_v4_v4(mat_gp->gp_style->stroke_rgba, &mat_curve->r);
}
}
else if ((only_stroke) || (do_stroke)) {
@@ -329,7 +329,7 @@ static void gpencil_convert_spline(Main *bmain,
bezt->vec[1][j],
coord_array + j,
resolu - 1,
- 3 * sizeof(float));
+ sizeof(float[3]));
}
/* Save first point coordinates. */
if (s == 0) {
@@ -363,7 +363,7 @@ static void gpencil_convert_spline(Main *bmain,
BKE_nurb_makeCurve(nu, coord_array, NULL, NULL, NULL, resolu, sizeof(float[3]));
/* Allocate memory for storage points. */
- gps->totpoints = nurb_points - 1;
+ gps->totpoints = nurb_points;
gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points");
/* Add points. */
diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index 53bfd3aa8ff..65ce117431b 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -237,7 +237,7 @@ static int stroke_march_next_point(const bGPDstroke *gps,
copy_v3_v3(result, &pt->x);
*pressure = gps->points[next_point_index].pressure;
*strength = gps->points[next_point_index].strength;
- memcpy(vert_color, gps->points[next_point_index].vert_color, sizeof(float) * 4);
+ memcpy(vert_color, gps->points[next_point_index].vert_color, sizeof(float[4]));
*index_from = next_point_index - 1;
*index_to = next_point_index;
@@ -245,24 +245,23 @@ static int stroke_march_next_point(const bGPDstroke *gps,
return 0;
}
- else {
- float ratio = remaining_march / remaining_till_next;
- interp_v3_v3v3(result, step_start, point, ratio);
- *pressure = interpf(
- gps->points[next_point_index].pressure, gps->points[next_point_index - 1].pressure, ratio);
- *strength = interpf(
- gps->points[next_point_index].strength, gps->points[next_point_index - 1].strength, ratio);
- interp_v4_v4v4(vert_color,
- gps->points[next_point_index - 1].vert_color,
- gps->points[next_point_index].vert_color,
- ratio);
- *index_from = next_point_index - 1;
- *index_to = next_point_index;
- *ratio_result = ratio;
+ float ratio = remaining_march / remaining_till_next;
+ interp_v3_v3v3(result, step_start, point, ratio);
+ *pressure = interpf(
+ gps->points[next_point_index].pressure, gps->points[next_point_index - 1].pressure, ratio);
+ *strength = interpf(
+ gps->points[next_point_index].strength, gps->points[next_point_index - 1].strength, ratio);
+ interp_v4_v4v4(vert_color,
+ gps->points[next_point_index - 1].vert_color,
+ gps->points[next_point_index].vert_color,
+ ratio);
- return next_point_index;
- }
+ *index_from = next_point_index - 1;
+ *index_to = next_point_index;
+ *ratio_result = ratio;
+
+ return next_point_index;
}
static int stroke_march_next_point_no_interp(const bGPDstroke *gps,
@@ -306,11 +305,10 @@ static int stroke_march_next_point_no_interp(const bGPDstroke *gps,
copy_v3_v3(result, &pt->x);
return 0;
}
- else {
- float ratio = remaining_march / remaining_till_next;
- interp_v3_v3v3(result, step_start, point, ratio);
- return next_point_index;
- }
+
+ float ratio = remaining_march / remaining_till_next;
+ interp_v3_v3v3(result, step_start, point, ratio);
+ return next_point_index;
}
static int stroke_march_count(const bGPDstroke *gps, const float dist)
@@ -447,7 +445,7 @@ bool BKE_gpencil_stroke_sample(bGPDstroke *gps, const float dist, const bool sel
copy_v3_v3(&pt2->x, last_coord);
new_pt[i].pressure = pt[0].pressure;
new_pt[i].strength = pt[0].strength;
- memcpy(new_pt[i].vert_color, pt[0].vert_color, sizeof(float) * 4);
+ memcpy(new_pt[i].vert_color, pt[0].vert_color, sizeof(float[4]));
if (select) {
new_pt[i].flag |= GP_SPOINT_SELECT;
}
@@ -473,7 +471,7 @@ bool BKE_gpencil_stroke_sample(bGPDstroke *gps, const float dist, const bool sel
copy_v3_v3(&pt2->x, last_coord);
new_pt[i].pressure = pressure;
new_pt[i].strength = strength;
- memcpy(new_pt[i].vert_color, vert_color, sizeof(float) * 4);
+ memcpy(new_pt[i].vert_color, vert_color, sizeof(float[4]));
if (select) {
new_pt[i].flag |= GP_SPOINT_SELECT;
}
@@ -1352,10 +1350,9 @@ bool BKE_gpencil_stroke_trim(bGPDstroke *gps)
if ((lambda <= 0.0f) || (lambda >= 1.0f)) {
continue;
}
- else {
- intersect = true;
- break;
- }
+
+ intersect = true;
+ break;
}
}
}
@@ -2427,7 +2424,7 @@ void BKE_gpencil_convert_mesh(Main *bmain,
* \param gpd: Grease pencil data-block
* \param mat: Transformation matrix
*/
-void BKE_gpencil_transform(bGPdata *gpd, float mat[4][4])
+void BKE_gpencil_transform(bGPdata *gpd, const float mat[4][4])
{
if (gpd == NULL) {
return;
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index e92bf5a4502..c2e330e8f04 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -348,9 +348,8 @@ const GpencilModifierTypeInfo *BKE_gpencil_modifier_get_info(GpencilModifierType
modifier_gpencil_types[type]->name[0] != '\0') {
return modifier_gpencil_types[type];
}
- else {
- return NULL;
- }
+
+ return NULL;
}
/**
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index 90761d24b73..2905bfc978a 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -202,8 +202,8 @@ BoundBox *BKE_hair_boundbox_get(Object *ob)
for (int a = 0; a < hair->totpoint; a++) {
float *co = hair_co[a];
float radius = (hair_radius) ? hair_radius[a] : 0.0f;
- float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius};
- float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius};
+ const float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius};
+ const float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius};
DO_MIN(co_min, min);
DO_MAX(co_max, max);
}
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index 6da48195aab..bec0da750e1 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -765,9 +765,8 @@ bool BKE_icon_delete(const int icon_id)
icon_free(icon);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
bool BKE_icon_delete_unmanaged(const int icon_id)
@@ -783,15 +782,13 @@ bool BKE_icon_delete_unmanaged(const int icon_id)
BLI_ghash_insert(gIcons, POINTER_FROM_INT(icon_id), icon);
return false;
}
- else {
- icon_free_data(icon_id, icon);
- icon_free(icon);
- return true;
- }
- }
- else {
- return false;
+
+ icon_free_data(icon_id, icon);
+ icon_free(icon);
+ return true;
}
+
+ return false;
}
/* -------------------------------------------------------------------- */
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index c3c67b9ed51..529ae227df9 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -55,10 +55,10 @@ static size_t idp_size_table[] = {
1, /*strings*/
sizeof(int),
sizeof(float),
- sizeof(float) * 3, /*Vector type, deprecated*/
- sizeof(float) * 16, /*Matrix type, deprecated*/
- 0, /*arrays don't have a fixed size*/
- sizeof(ListBase), /*Group type*/
+ sizeof(float[3]), /*Vector type, deprecated*/
+ sizeof(float[16]), /*Matrix type, deprecated*/
+ 0, /*arrays don't have a fixed size*/
+ sizeof(ListBase), /*Group type*/
sizeof(void *),
sizeof(double),
};
@@ -181,7 +181,7 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
prop->len = newlen;
return;
}
- else if (newlen >= prop->len) {
+ if (newlen >= prop->len) {
prop->len = newlen;
return;
}
@@ -836,17 +836,16 @@ IDProperty *IDP_GetProperties(ID *id, const bool create_if_needed)
if (id->properties) {
return id->properties;
}
- else {
- if (create_if_needed) {
- id->properties = MEM_callocN(sizeof(IDProperty), "IDProperty");
- id->properties->type = IDP_GROUP;
- /* don't overwrite the data's name and type
- * some functions might need this if they
- * don't have a real ID, should be named elsewhere - Campbell */
- /* strcpy(id->name, "top_level_group");*/
- }
- return id->properties;
+
+ if (create_if_needed) {
+ id->properties = MEM_callocN(sizeof(IDProperty), "IDProperty");
+ id->properties->type = IDP_GROUP;
+ /* don't overwrite the data's name and type
+ * some functions might need this if they
+ * don't have a real ID, should be named elsewhere - Campbell */
+ /* strcpy(id->name, "top_level_group");*/
}
+ return id->properties;
}
/**
@@ -856,10 +855,10 @@ bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is
if (prop1 == NULL && prop2 == NULL) {
return true;
}
- else if (prop1 == NULL || prop2 == NULL) {
+ if (prop1 == NULL || prop2 == NULL) {
return is_strict ? false : true;
}
- else if (prop1->type != prop2->type) {
+ if (prop1->type != prop2->type) {
return false;
}
diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c
index 1166ad9ad2f..4ab7d362e0e 100644
--- a/source/blender/blenkernel/intern/idtype.c
+++ b/source/blender/blenkernel/intern/idtype.c
@@ -135,9 +135,8 @@ const IDTypeInfo *BKE_idtype_get_info_from_idcode(const short id_code)
id_types[id_index]->name[0] != '\0') {
return id_types[id_index];
}
- else {
- return NULL;
- }
+
+ return NULL;
}
const IDTypeInfo *BKE_idtype_get_info_from_id(const ID *id)
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 042a5233978..7ff34acca7a 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -90,7 +90,6 @@
#include "RE_pipeline.h"
-#include "GPU_draw.h"
#include "GPU_texture.h"
#include "BLI_sys_types.h" // for intptr_t support
@@ -393,7 +392,7 @@ void BKE_image_free_buffers_ex(Image *ima, bool do_lock)
ima->rr = NULL;
}
- GPU_free_image(ima);
+ BKE_image_free_gputextures(ima);
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
tile->ok = IMA_OK;
@@ -668,9 +667,8 @@ char BKE_image_alpha_mode_from_extension_ex(const char *filepath)
if (BLI_path_extension_check_n(filepath, ".exr", ".cin", ".dpx", ".hdr", NULL)) {
return IMA_ALPHA_PREMUL;
}
- else {
- return IMA_ALPHA_STRAIGHT;
- }
+
+ return IMA_ALPHA_STRAIGHT;
}
void BKE_image_alpha_mode_from_extension(Image *image)
@@ -1202,57 +1200,56 @@ int BKE_image_imtype_to_ftype(const char imtype, ImbFormatOptions *r_options)
if (imtype == R_IMF_IMTYPE_TARGA) {
return IMB_FTYPE_TGA;
}
- else if (imtype == R_IMF_IMTYPE_RAWTGA) {
+ if (imtype == R_IMF_IMTYPE_RAWTGA) {
r_options->flag = RAWTGA;
return IMB_FTYPE_TGA;
}
- else if (imtype == R_IMF_IMTYPE_IRIS) {
+ if (imtype == R_IMF_IMTYPE_IRIS) {
return IMB_FTYPE_IMAGIC;
}
#ifdef WITH_HDR
- else if (imtype == R_IMF_IMTYPE_RADHDR) {
+ if (imtype == R_IMF_IMTYPE_RADHDR) {
return IMB_FTYPE_RADHDR;
}
#endif
- else if (imtype == R_IMF_IMTYPE_PNG) {
+ if (imtype == R_IMF_IMTYPE_PNG) {
r_options->quality = 15;
return IMB_FTYPE_PNG;
}
#ifdef WITH_DDS
- else if (imtype == R_IMF_IMTYPE_DDS) {
+ if (imtype == R_IMF_IMTYPE_DDS) {
return IMB_FTYPE_DDS;
}
#endif
- else if (imtype == R_IMF_IMTYPE_BMP) {
+ if (imtype == R_IMF_IMTYPE_BMP) {
return IMB_FTYPE_BMP;
}
#ifdef WITH_TIFF
- else if (imtype == R_IMF_IMTYPE_TIFF) {
+ if (imtype == R_IMF_IMTYPE_TIFF) {
return IMB_FTYPE_TIF;
}
#endif
- else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) {
+ if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) {
return IMB_FTYPE_OPENEXR;
}
#ifdef WITH_CINEON
- else if (imtype == R_IMF_IMTYPE_CINEON) {
+ if (imtype == R_IMF_IMTYPE_CINEON) {
return IMB_FTYPE_CINEON;
}
- else if (imtype == R_IMF_IMTYPE_DPX) {
+ if (imtype == R_IMF_IMTYPE_DPX) {
return IMB_FTYPE_DPX;
}
#endif
#ifdef WITH_OPENJPEG
- else if (imtype == R_IMF_IMTYPE_JP2) {
+ if (imtype == R_IMF_IMTYPE_JP2) {
r_options->flag |= JP2_JP2;
r_options->quality = 90;
return IMB_FTYPE_JP2;
}
#endif
- else {
- r_options->quality = 90;
- return IMB_FTYPE_JPG;
- }
+
+ r_options->quality = 90;
+ return IMB_FTYPE_JPG;
}
char BKE_image_ftype_to_imtype(const int ftype, const ImbFormatOptions *options)
@@ -1260,57 +1257,55 @@ char BKE_image_ftype_to_imtype(const int ftype, const ImbFormatOptions *options)
if (ftype == 0) {
return R_IMF_IMTYPE_TARGA;
}
- else if (ftype == IMB_FTYPE_IMAGIC) {
+ if (ftype == IMB_FTYPE_IMAGIC) {
return R_IMF_IMTYPE_IRIS;
}
#ifdef WITH_HDR
- else if (ftype == IMB_FTYPE_RADHDR) {
+ if (ftype == IMB_FTYPE_RADHDR) {
return R_IMF_IMTYPE_RADHDR;
}
#endif
- else if (ftype == IMB_FTYPE_PNG) {
+ if (ftype == IMB_FTYPE_PNG) {
return R_IMF_IMTYPE_PNG;
}
#ifdef WITH_DDS
- else if (ftype == IMB_FTYPE_DDS) {
+ if (ftype == IMB_FTYPE_DDS) {
return R_IMF_IMTYPE_DDS;
}
#endif
- else if (ftype == IMB_FTYPE_BMP) {
+ if (ftype == IMB_FTYPE_BMP) {
return R_IMF_IMTYPE_BMP;
}
#ifdef WITH_TIFF
- else if (ftype == IMB_FTYPE_TIF) {
+ if (ftype == IMB_FTYPE_TIF) {
return R_IMF_IMTYPE_TIFF;
}
#endif
- else if (ftype == IMB_FTYPE_OPENEXR) {
+ if (ftype == IMB_FTYPE_OPENEXR) {
return R_IMF_IMTYPE_OPENEXR;
}
#ifdef WITH_CINEON
- else if (ftype == IMB_FTYPE_CINEON) {
+ if (ftype == IMB_FTYPE_CINEON) {
return R_IMF_IMTYPE_CINEON;
}
- else if (ftype == IMB_FTYPE_DPX) {
+ if (ftype == IMB_FTYPE_DPX) {
return R_IMF_IMTYPE_DPX;
}
#endif
- else if (ftype == IMB_FTYPE_TGA) {
+ if (ftype == IMB_FTYPE_TGA) {
if (options && (options->flag & RAWTGA)) {
return R_IMF_IMTYPE_RAWTGA;
}
- else {
- return R_IMF_IMTYPE_TARGA;
- }
+
+ return R_IMF_IMTYPE_TARGA;
}
#ifdef WITH_OPENJPEG
- else if (ftype == IMB_FTYPE_JP2) {
+ if (ftype == IMB_FTYPE_JP2) {
return R_IMF_IMTYPE_JP2;
}
#endif
- else {
- return R_IMF_IMTYPE_JPEG90;
- }
+
+ return R_IMF_IMTYPE_JPEG90;
}
bool BKE_imtype_is_movie(const char imtype)
@@ -1444,78 +1439,77 @@ char BKE_imtype_from_arg(const char *imtype_arg)
if (STREQ(imtype_arg, "TGA")) {
return R_IMF_IMTYPE_TARGA;
}
- else if (STREQ(imtype_arg, "IRIS")) {
+ if (STREQ(imtype_arg, "IRIS")) {
return R_IMF_IMTYPE_IRIS;
}
#ifdef WITH_DDS
- else if (STREQ(imtype_arg, "DDS")) {
+ if (STREQ(imtype_arg, "DDS")) {
return R_IMF_IMTYPE_DDS;
}
#endif
- else if (STREQ(imtype_arg, "JPEG")) {
+ if (STREQ(imtype_arg, "JPEG")) {
return R_IMF_IMTYPE_JPEG90;
}
- else if (STREQ(imtype_arg, "IRIZ")) {
+ if (STREQ(imtype_arg, "IRIZ")) {
return R_IMF_IMTYPE_IRIZ;
}
- else if (STREQ(imtype_arg, "RAWTGA")) {
+ if (STREQ(imtype_arg, "RAWTGA")) {
return R_IMF_IMTYPE_RAWTGA;
}
- else if (STREQ(imtype_arg, "AVIRAW")) {
+ if (STREQ(imtype_arg, "AVIRAW")) {
return R_IMF_IMTYPE_AVIRAW;
}
- else if (STREQ(imtype_arg, "AVIJPEG")) {
+ if (STREQ(imtype_arg, "AVIJPEG")) {
return R_IMF_IMTYPE_AVIJPEG;
}
- else if (STREQ(imtype_arg, "PNG")) {
+ if (STREQ(imtype_arg, "PNG")) {
return R_IMF_IMTYPE_PNG;
}
- else if (STREQ(imtype_arg, "BMP")) {
+ if (STREQ(imtype_arg, "BMP")) {
return R_IMF_IMTYPE_BMP;
}
#ifdef WITH_HDR
- else if (STREQ(imtype_arg, "HDR")) {
+ if (STREQ(imtype_arg, "HDR")) {
return R_IMF_IMTYPE_RADHDR;
}
#endif
#ifdef WITH_TIFF
- else if (STREQ(imtype_arg, "TIFF")) {
+ if (STREQ(imtype_arg, "TIFF")) {
return R_IMF_IMTYPE_TIFF;
}
#endif
#ifdef WITH_OPENEXR
- else if (STREQ(imtype_arg, "OPEN_EXR")) {
+ if (STREQ(imtype_arg, "OPEN_EXR")) {
return R_IMF_IMTYPE_OPENEXR;
}
- else if (STREQ(imtype_arg, "OPEN_EXR_MULTILAYER")) {
+ if (STREQ(imtype_arg, "OPEN_EXR_MULTILAYER")) {
return R_IMF_IMTYPE_MULTILAYER;
}
- else if (STREQ(imtype_arg, "EXR")) {
+ if (STREQ(imtype_arg, "EXR")) {
return R_IMF_IMTYPE_OPENEXR;
}
- else if (STREQ(imtype_arg, "MULTILAYER")) {
+ if (STREQ(imtype_arg, "MULTILAYER")) {
return R_IMF_IMTYPE_MULTILAYER;
}
#endif
- else if (STREQ(imtype_arg, "FFMPEG")) {
+ if (STREQ(imtype_arg, "FFMPEG")) {
return R_IMF_IMTYPE_FFMPEG;
}
#ifdef WITH_CINEON
- else if (STREQ(imtype_arg, "CINEON")) {
+ if (STREQ(imtype_arg, "CINEON")) {
return R_IMF_IMTYPE_CINEON;
}
- else if (STREQ(imtype_arg, "DPX")) {
+ if (STREQ(imtype_arg, "DPX")) {
return R_IMF_IMTYPE_DPX;
}
#endif
#ifdef WITH_OPENJPEG
- else if (STREQ(imtype_arg, "JP2")) {
+ if (STREQ(imtype_arg, "JP2")) {
return R_IMF_IMTYPE_JP2;
}
#endif
- else {
- return R_IMF_IMTYPE_INVALID;
- }
+
+ return R_IMF_IMTYPE_INVALID;
}
static bool do_add_image_extension(char *string,
@@ -1639,13 +1633,11 @@ static bool do_add_image_extension(char *string,
if (BLI_path_extension_check_array(string, imb_ext_image)) {
return BLI_path_extension_replace(string, FILE_MAX, extension);
}
- else {
- return BLI_path_extension_ensure(string, FILE_MAX, extension);
- }
- }
- else {
- return false;
+
+ return BLI_path_extension_ensure(string, FILE_MAX, extension);
}
+
+ return false;
}
int BKE_image_path_ensure_ext_from_imformat(char *string, const ImageFormatData *im_format)
@@ -2885,7 +2877,7 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, const ImageFormatData *imf)
perror(name);
}
- return (ok);
+ return ok;
}
/* same as BKE_imbuf_write() but crappy workaround not to permanently modify
@@ -3013,7 +3005,7 @@ struct anim *openanim(const char *name, int flags, int streamindex, char colorsp
}
IMB_freeImBuf(ibuf);
- return (anim);
+ return anim;
}
/* ************************* New Image API *************** */
@@ -3549,9 +3541,8 @@ static RenderPass *image_render_pass_get(RenderLayer *rl,
/* no multiview or left eye */
break;
}
- else {
- rp_name = rpass->name;
- }
+
+ rp_name = rpass->name;
}
/* multiview */
else if (rp_name[0] && STREQ(rpass->name, rp_name) && (rpass->view_id == view)) {
@@ -3714,9 +3705,8 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser)
iuser->multi_index = index + rp_index;
break;
}
- else {
- index += BLI_listbase_count(&rl->passes);
- }
+
+ index += BLI_listbase_count(&rl->passes);
}
}
@@ -3943,7 +3933,7 @@ static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr)
#endif /* WITH_OPENEXR */
/* common stuff to do with images after loading */
-static void image_initialize_after_load(Image *ima, ImageUser *iuser, ImBuf *UNUSED(ibuf))
+static void image_init_after_load(Image *ima, ImageUser *iuser, ImBuf *UNUSED(ibuf))
{
/* Preview is NULL when it has never been used as an icon before.
* Never handle previews/icons outside of main thread. */
@@ -3987,13 +3977,12 @@ static int image_num_files(Image *ima)
if (!is_multiview) {
return 1;
}
- else if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
+ if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
return 1;
}
/* R_IMF_VIEWS_INDIVIDUAL */
- else {
- return BLI_listbase_count(&ima->views);
- }
+
+ return BLI_listbase_count(&ima->views);
}
static ImBuf *load_sequence_single(
@@ -4046,11 +4035,11 @@ static ImBuf *load_sequence_single(
}
}
else {
- image_initialize_after_load(ima, iuser, ibuf);
+ image_init_after_load(ima, iuser, ibuf);
*r_assign = true;
}
#else
- image_initialize_after_load(ima, iuser, ibuf);
+ image_init_after_load(ima, iuser, ibuf);
*r_assign = true;
#endif
}
@@ -4155,7 +4144,7 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int e
BKE_imbuf_stamp_info(ima->rr, ibuf);
- image_initialize_after_load(ima, iuser, ibuf);
+ image_init_after_load(ima, iuser, ibuf);
image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, entry);
}
// else printf("pass not found\n");
@@ -4219,7 +4208,7 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i
ibuf = IMB_makeSingleUser(IMB_anim_absolute(ia->anim, fra, IMB_TC_RECORD_RUN, IMB_PROXY_NONE));
if (ibuf) {
- image_initialize_after_load(ima, iuser, ibuf);
+ image_init_after_load(ima, iuser, ibuf);
}
else {
tile->ok = 0;
@@ -4364,7 +4353,7 @@ static ImBuf *load_image_single(Image *ima,
else
#endif
{
- image_initialize_after_load(ima, iuser, ibuf);
+ image_init_after_load(ima, iuser, ibuf);
*r_assign = true;
/* make packed file for autopack */
@@ -4478,7 +4467,7 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser)
if (rpass) {
ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0);
- image_initialize_after_load(ima, iuser, ibuf);
+ image_init_after_load(ima, iuser, ibuf);
ibuf->rect_float = rpass->rect;
ibuf->flags |= IB_rectfloat;
@@ -4708,7 +4697,7 @@ static int image_get_multiview_index(Image *ima, ImageUser *iuser)
if (is_multilayer) {
return iuser ? iuser->multi_index : index;
}
- else if (is_backdrop) {
+ if (is_backdrop) {
if (BKE_image_is_stereo(ima)) {
/* backdrop hackaround (since there is no iuser */
return ima->eye;
@@ -4845,7 +4834,7 @@ BLI_INLINE bool image_quick_test(Image *ima, const ImageUser *iuser)
if (tile == NULL) {
return false;
}
- else if (tile->ok == 0) {
+ if (tile->ok == 0) {
return false;
}
@@ -5162,58 +5151,57 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, bool *r_is_in_ran
if (len == 0) {
return 0;
}
- else {
- int framenr;
- cfra = cfra - iuser->sfra + 1;
-
- /* cyclic */
- if (iuser->cycl) {
- cfra = ((cfra) % len);
- if (cfra < 0) {
- cfra += len;
- }
- if (cfra == 0) {
- cfra = len;
- }
- if (r_is_in_range) {
- *r_is_in_range = true;
- }
- }
+ int framenr;
+ cfra = cfra - iuser->sfra + 1;
+ /* cyclic */
+ if (iuser->cycl) {
+ cfra = ((cfra) % len);
if (cfra < 0) {
- cfra = 0;
+ cfra += len;
}
- else if (cfra > len) {
+ if (cfra == 0) {
cfra = len;
}
- else {
- if (r_is_in_range) {
- *r_is_in_range = true;
- }
- }
- /* transform to images space */
- framenr = cfra;
- if (framenr > iuser->frames) {
- framenr = iuser->frames;
+ if (r_is_in_range) {
+ *r_is_in_range = true;
}
+ }
- if (iuser->cycl) {
- framenr = ((framenr) % len);
- while (framenr < 0) {
- framenr += len;
- }
- if (framenr == 0) {
- framenr = len;
- }
+ if (cfra < 0) {
+ cfra = 0;
+ }
+ else if (cfra > len) {
+ cfra = len;
+ }
+ else {
+ if (r_is_in_range) {
+ *r_is_in_range = true;
}
+ }
- /* important to apply after else we cant loop on frames 100 - 110 for eg. */
- framenr += iuser->offset;
+ /* transform to images space */
+ framenr = cfra;
+ if (framenr > iuser->frames) {
+ framenr = iuser->frames;
+ }
- return framenr;
+ if (iuser->cycl) {
+ framenr = ((framenr) % len);
+ while (framenr < 0) {
+ framenr += len;
+ }
+ if (framenr == 0) {
+ framenr = len;
+ }
}
+
+ /* important to apply after else we cant loop on frames 100 - 110 for eg. */
+ framenr += iuser->offset;
+
+ return framenr;
}
void BKE_image_user_frame_calc(Image *ima, ImageUser *iuser, int cfra)
@@ -5379,9 +5367,8 @@ bool BKE_image_has_alpha(struct Image *image)
if (planes == 32) {
return true;
}
- else {
- return false;
- }
+
+ return false;
}
void BKE_image_get_size(Image *image, ImageUser *iuser, int *r_width, int *r_height)
@@ -5847,17 +5834,16 @@ bool BKE_image_clear_renderslot(Image *ima, ImageUser *iuser, int index)
RE_ClearResult(re);
return true;
}
- else {
- RenderSlot *slot = BLI_findlink(&ima->renderslots, index);
- if (!slot) {
- return false;
- }
- if (slot->render) {
- RE_FreeRenderResult(slot->render);
- slot->render = NULL;
- }
- return true;
+
+ RenderSlot *slot = BLI_findlink(&ima->renderslots, index);
+ if (!slot) {
+ return false;
}
+ if (slot->render) {
+ RE_FreeRenderResult(slot->render);
+ slot->render = NULL;
+ }
+ return true;
}
RenderSlot *BKE_image_get_renderslot(Image *ima, int index)
diff --git a/source/blender/blenkernel/intern/image_gpu.c b/source/blender/blenkernel/intern/image_gpu.c
new file mode 100644
index 00000000000..78a705ae145
--- /dev/null
+++ b/source/blender/blenkernel/intern/image_gpu.c
@@ -0,0 +1,774 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_boxpack_2d.h"
+#include "BLI_linklist.h"
+#include "BLI_listbase.h"
+#include "BLI_threads.h"
+
+#include "DNA_image_types.h"
+#include "DNA_userdef_types.h"
+
+#include "IMB_colormanagement.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
+#include "BKE_global.h"
+#include "BKE_image.h"
+#include "BKE_main.h"
+
+#include "GPU_extensions.h"
+#include "GPU_state.h"
+#include "GPU_texture.h"
+
+#include "PIL_time.h"
+
+/* Prototypes. */
+static void gpu_free_unused_buffers(void);
+static void image_free_gpu(Image *ima, const bool immediate);
+
+/* -------------------------------------------------------------------- */
+/** \name UDIM gpu texture
+ * \{ */
+
+static bool is_over_resolution_limit(int w, int h)
+{
+ return (w > GPU_texture_size_with_limit(w) || h > GPU_texture_size_with_limit(h));
+}
+
+static int smaller_power_of_2_limit(int num)
+{
+ return power_of_2_min_i(GPU_texture_size_with_limit(num));
+}
+
+static GPUTexture *gpu_texture_create_tile_mapping(Image *ima, const int multiview_eye)
+{
+ GPUTexture *tilearray = ima->gputexture[TEXTARGET_2D_ARRAY][multiview_eye];
+
+ if (tilearray == NULL) {
+ return 0;
+ }
+
+ float array_w = GPU_texture_width(tilearray);
+ float array_h = GPU_texture_height(tilearray);
+
+ ImageTile *last_tile = (ImageTile *)ima->tiles.last;
+ /* Tiles are sorted by number. */
+ int max_tile = last_tile->tile_number - 1001;
+
+ /* create image */
+ int width = max_tile + 1;
+ float *data = (float *)MEM_callocN(width * 8 * sizeof(float), __func__);
+ for (int i = 0; i < width; i++) {
+ data[4 * i] = -1.0f;
+ }
+ LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
+ int i = tile->tile_number - 1001;
+ data[4 * i] = tile->runtime.tilearray_layer;
+
+ float *tile_info = &data[4 * width + 4 * i];
+ tile_info[0] = tile->runtime.tilearray_offset[0] / array_w;
+ tile_info[1] = tile->runtime.tilearray_offset[1] / array_h;
+ tile_info[2] = tile->runtime.tilearray_size[0] / array_w;
+ tile_info[3] = tile->runtime.tilearray_size[1] / array_h;
+ }
+
+ GPUTexture *tex = GPU_texture_create_1d_array(width, 2, GPU_RGBA32F, data, NULL);
+ GPU_texture_mipmap_mode(tex, false, false);
+
+ MEM_freeN(data);
+
+ return tex;
+}
+
+typedef struct PackTile {
+ FixedSizeBoxPack boxpack;
+ ImageTile *tile;
+ float pack_score;
+} PackTile;
+
+static int compare_packtile(const void *a, const void *b)
+{
+ const PackTile *tile_a = (const PackTile *)a;
+ const PackTile *tile_b = (const PackTile *)b;
+
+ return tile_a->pack_score < tile_b->pack_score;
+}
+
+static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
+{
+ int arraywidth = 0, arrayheight = 0;
+ ListBase boxes = {NULL};
+
+ LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
+ ImageUser iuser;
+ BKE_imageuser_default(&iuser);
+ iuser.tile = tile->tile_number;
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
+
+ if (ibuf) {
+ PackTile *packtile = (PackTile *)MEM_callocN(sizeof(PackTile), __func__);
+ packtile->tile = tile;
+ packtile->boxpack.w = ibuf->x;
+ packtile->boxpack.h = ibuf->y;
+
+ if (is_over_resolution_limit(packtile->boxpack.w, packtile->boxpack.h)) {
+ packtile->boxpack.w = smaller_power_of_2_limit(packtile->boxpack.w);
+ packtile->boxpack.h = smaller_power_of_2_limit(packtile->boxpack.h);
+ }
+ arraywidth = max_ii(arraywidth, packtile->boxpack.w);
+ arrayheight = max_ii(arrayheight, packtile->boxpack.h);
+
+ /* We sort the tiles by decreasing size, with an additional penalty term
+ * for high aspect ratios. This improves packing efficiency. */
+ float w = packtile->boxpack.w, h = packtile->boxpack.h;
+ packtile->pack_score = max_ff(w, h) / min_ff(w, h) * w * h;
+
+ BKE_image_release_ibuf(ima, ibuf, NULL);
+ BLI_addtail(&boxes, packtile);
+ }
+ }
+
+ BLI_assert(arraywidth > 0 && arrayheight > 0);
+
+ BLI_listbase_sort(&boxes, compare_packtile);
+ int arraylayers = 0;
+ /* Keep adding layers until all tiles are packed. */
+ while (boxes.first != NULL) {
+ ListBase packed = {NULL};
+ BLI_box_pack_2d_fixedarea(&boxes, arraywidth, arrayheight, &packed);
+ BLI_assert(packed.first != NULL);
+
+ LISTBASE_FOREACH (PackTile *, packtile, &packed) {
+ ImageTile *tile = packtile->tile;
+ int *tileoffset = tile->runtime.tilearray_offset;
+ int *tilesize = tile->runtime.tilearray_size;
+
+ tileoffset[0] = packtile->boxpack.x;
+ tileoffset[1] = packtile->boxpack.y;
+ tilesize[0] = packtile->boxpack.w;
+ tilesize[1] = packtile->boxpack.h;
+ tile->runtime.tilearray_layer = arraylayers;
+ }
+
+ BLI_freelistN(&packed);
+ arraylayers++;
+ }
+
+ const bool use_high_bitdepth = (ima->flag & IMA_HIGH_BITDEPTH);
+ /* Create Texture without content. */
+ GPUTexture *tex = IMB_touch_gpu_texture(
+ main_ibuf, arraywidth, arrayheight, arraylayers, use_high_bitdepth);
+
+ GPU_texture_bind(tex, 0);
+
+ /* Upload each tile one by one. */
+ LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
+ int tilelayer = tile->runtime.tilearray_layer;
+ int *tileoffset = tile->runtime.tilearray_offset;
+ int *tilesize = tile->runtime.tilearray_size;
+
+ if (tilesize[0] == 0 || tilesize[1] == 0) {
+ continue;
+ }
+
+ ImageUser iuser;
+ BKE_imageuser_default(&iuser);
+ iuser.tile = tile->tile_number;
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
+
+ if (ibuf) {
+ const bool store_premultiplied = ibuf->rect_float ? (ima->alpha_mode != IMA_ALPHA_STRAIGHT) :
+ (ima->alpha_mode == IMA_ALPHA_PREMUL);
+ IMB_update_gpu_texture_sub(tex,
+ ibuf,
+ UNPACK2(tileoffset),
+ tilelayer,
+ UNPACK2(tilesize),
+ use_high_bitdepth,
+ store_premultiplied);
+ }
+
+ BKE_image_release_ibuf(ima, ibuf, NULL);
+ }
+
+ if (GPU_mipmap_enabled()) {
+ GPU_texture_generate_mipmap(tex);
+ GPU_texture_mipmap_mode(tex, true, true);
+ if (ima) {
+ ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
+ }
+ }
+ else {
+ GPU_texture_mipmap_mode(tex, false, true);
+ }
+
+ GPU_texture_unbind(tex);
+
+ return tex;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Regular gpu texture
+ * \{ */
+
+static GPUTexture **get_image_gpu_texture_ptr(Image *ima,
+ eGPUTextureTarget textarget,
+ const int multiview_eye)
+{
+ const bool in_range = (textarget >= 0) && (textarget < TEXTARGET_COUNT);
+ BLI_assert(in_range);
+
+ if (in_range) {
+ return &(ima->gputexture[textarget][multiview_eye]);
+ }
+ return NULL;
+}
+
+static GPUTexture *image_gpu_texture_error_create(eGPUTextureTarget textarget)
+{
+ switch (textarget) {
+ case TEXTARGET_2D_ARRAY:
+ return GPU_texture_create_error(2, true);
+ case TEXTARGET_TILE_MAPPING:
+ return GPU_texture_create_error(1, true);
+ case TEXTARGET_2D:
+ default:
+ return GPU_texture_create_error(2, false);
+ }
+}
+
+static GPUTexture *image_get_gpu_texture(Image *ima,
+ ImageUser *iuser,
+ ImBuf *ibuf,
+ eGPUTextureTarget textarget)
+{
+ if (ima == NULL) {
+ return NULL;
+ }
+
+ /* Free any unused GPU textures, since we know we are in a thread with OpenGL
+ * context and might as well ensure we have as much space free as possible. */
+ gpu_free_unused_buffers();
+
+ /* currently, gpu refresh tagging is used by ima sequences */
+ if (ima->gpuflag & IMA_GPU_REFRESH) {
+ image_free_gpu(ima, true);
+ ima->gpuflag &= ~IMA_GPU_REFRESH;
+ }
+
+ /* Tag as in active use for garbage collector. */
+ BKE_image_tag_time(ima);
+
+ /* Test if we already have a texture. */
+ GPUTexture **tex = get_image_gpu_texture_ptr(ima, textarget, iuser ? iuser->multiview_eye : 0);
+ if (*tex) {
+ return *tex;
+ }
+
+ /* Check if we have a valid image. If not, we return a dummy
+ * texture with zero bind-code so we don't keep trying. */
+ ImageTile *tile = BKE_image_get_tile(ima, 0);
+ if (tile == NULL || tile->ok == 0) {
+ *tex = image_gpu_texture_error_create(textarget);
+ return *tex;
+ }
+
+ /* check if we have a valid image buffer */
+ ImBuf *ibuf_intern = ibuf;
+ if (ibuf_intern == NULL) {
+ ibuf_intern = BKE_image_acquire_ibuf(ima, iuser, NULL);
+ if (ibuf_intern == NULL) {
+ *tex = image_gpu_texture_error_create(textarget);
+ return *tex;
+ }
+ }
+
+ if (textarget == TEXTARGET_2D_ARRAY) {
+ *tex = gpu_texture_create_tile_array(ima, ibuf_intern);
+ }
+ else if (textarget == TEXTARGET_TILE_MAPPING) {
+ *tex = gpu_texture_create_tile_mapping(ima, iuser ? iuser->multiview_eye : 0);
+ }
+ else {
+ const bool use_high_bitdepth = (ima->flag & IMA_HIGH_BITDEPTH);
+ const bool store_premultiplied = ibuf_intern->rect_float ?
+ (ima ? (ima->alpha_mode != IMA_ALPHA_STRAIGHT) : false) :
+ (ima ? (ima->alpha_mode == IMA_ALPHA_PREMUL) : true);
+
+ *tex = IMB_create_gpu_texture(ibuf_intern, use_high_bitdepth, store_premultiplied);
+
+ if (GPU_mipmap_enabled()) {
+ GPU_texture_bind(*tex, 0);
+ GPU_texture_generate_mipmap(*tex);
+ GPU_texture_unbind(*tex);
+ if (ima) {
+ ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
+ }
+ GPU_texture_mipmap_mode(*tex, true, true);
+ }
+ else {
+ GPU_texture_mipmap_mode(*tex, false, true);
+ }
+ }
+
+ /* if `ibuf` was given, we don't own the `ibuf_intern` */
+ if (ibuf == NULL) {
+ BKE_image_release_ibuf(ima, ibuf_intern, NULL);
+ }
+
+ GPU_texture_orig_size_set(*tex, ibuf_intern->x, ibuf_intern->y);
+
+ return *tex;
+}
+
+GPUTexture *BKE_image_get_gpu_texture(Image *image, ImageUser *iuser, ImBuf *ibuf)
+{
+ return image_get_gpu_texture(image, iuser, ibuf, TEXTARGET_2D);
+}
+
+GPUTexture *BKE_image_get_gpu_tiles(Image *image, ImageUser *iuser, ImBuf *ibuf)
+{
+ return image_get_gpu_texture(image, iuser, ibuf, TEXTARGET_2D_ARRAY);
+}
+
+GPUTexture *BKE_image_get_gpu_tilemap(Image *image, ImageUser *iuser, ImBuf *ibuf)
+{
+ return image_get_gpu_texture(image, iuser, ibuf, TEXTARGET_TILE_MAPPING);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Delayed GPU texture free
+ *
+ * Image datablocks can be deleted by any thread, but there may not be any active OpenGL context.
+ * In that case we push them into a queue and free the buffers later.
+ * \{ */
+
+static LinkNode *gpu_texture_free_queue = NULL;
+static ThreadMutex gpu_texture_queue_mutex = BLI_MUTEX_INITIALIZER;
+
+static void gpu_free_unused_buffers(void)
+{
+ if (gpu_texture_free_queue == NULL) {
+ return;
+ }
+
+ BLI_mutex_lock(&gpu_texture_queue_mutex);
+
+ while (gpu_texture_free_queue != NULL) {
+ GPUTexture *tex = BLI_linklist_pop(&gpu_texture_free_queue);
+ GPU_texture_free(tex);
+ }
+
+ BLI_mutex_unlock(&gpu_texture_queue_mutex);
+}
+
+void BKE_image_free_unused_gpu_textures()
+{
+ if (BLI_thread_is_main()) {
+ gpu_free_unused_buffers();
+ }
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Deletion
+ * \{ */
+
+static void image_free_gpu(Image *ima, const bool immediate)
+{
+ for (int eye = 0; eye < 2; eye++) {
+ for (int i = 0; i < TEXTARGET_COUNT; i++) {
+ if (ima->gputexture[i][eye] != NULL) {
+ if (immediate) {
+ GPU_texture_free(ima->gputexture[i][eye]);
+ }
+ else {
+ BLI_mutex_lock(&gpu_texture_queue_mutex);
+ BLI_linklist_prepend(&gpu_texture_free_queue, ima->gputexture[i][eye]);
+ BLI_mutex_unlock(&gpu_texture_queue_mutex);
+ }
+
+ ima->gputexture[i][eye] = NULL;
+ }
+ }
+ }
+
+ ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
+}
+
+void BKE_image_free_gputextures(Image *ima)
+{
+ image_free_gpu(ima, BLI_thread_is_main());
+}
+
+void BKE_image_free_all_gputextures(Main *bmain)
+{
+ if (bmain) {
+ LISTBASE_FOREACH (Image *, ima, &bmain->images) {
+ BKE_image_free_gputextures(ima);
+ }
+ }
+}
+
+/* same as above but only free animated images */
+void BKE_image_free_anim_gputextures(Main *bmain)
+{
+ if (bmain) {
+ LISTBASE_FOREACH (Image *, ima, &bmain->images) {
+ if (BKE_image_is_animated(ima)) {
+ BKE_image_free_gputextures(ima);
+ }
+ }
+ }
+}
+
+void BKE_image_free_old_gputextures(Main *bmain)
+{
+ static int lasttime = 0;
+ int ctime = (int)PIL_check_seconds_timer();
+
+ /*
+ * Run garbage collector once for every collecting period of time
+ * if textimeout is 0, that's the option to NOT run the collector
+ */
+ if (U.textimeout == 0 || ctime % U.texcollectrate || ctime == lasttime) {
+ return;
+ }
+
+ /* of course not! */
+ if (G.is_rendering) {
+ return;
+ }
+
+ lasttime = ctime;
+
+ LISTBASE_FOREACH (Image *, ima, &bmain->images) {
+ if ((ima->flag & IMA_NOCOLLECT) == 0 && ctime - ima->lastused > U.textimeout) {
+ /* If it's in GL memory, deallocate and set time tag to current time
+ * This gives textures a "second chance" to be used before dying. */
+ if (BKE_image_has_opengl_texture(ima)) {
+ BKE_image_free_gputextures(ima);
+ ima->lastused = ctime;
+ }
+ /* Otherwise, just kill the buffers */
+ else {
+ BKE_image_free_buffers(ima);
+ }
+ }
+ }
+}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Paint Update
+ * \{ */
+
+static ImBuf *update_do_scale(uchar *rect,
+ float *rect_float,
+ int *x,
+ int *y,
+ int *w,
+ int *h,
+ int limit_w,
+ int limit_h,
+ int full_w,
+ int full_h)
+{
+ /* Partial update with scaling. */
+ float xratio = limit_w / (float)full_w;
+ float yratio = limit_h / (float)full_h;
+
+ int part_w = *w, part_h = *h;
+
+ /* Find sub coordinates in scaled image. Take ceiling because we will be
+ * losing 1 pixel due to rounding errors in x,y. */
+ *x *= xratio;
+ *y *= yratio;
+ *w = (int)ceil(xratio * (*w));
+ *h = (int)ceil(yratio * (*h));
+
+ /* ...but take back if we are over the limit! */
+ if (*x + *w > limit_w) {
+ (*w)--;
+ }
+ if (*y + *h > limit_h) {
+ (*h)--;
+ }
+
+ /* Scale pixels. */
+ ImBuf *ibuf = IMB_allocFromBuffer((uint *)rect, rect_float, part_w, part_h, 4);
+ IMB_scaleImBuf(ibuf, *w, *h);
+
+ return ibuf;
+}
+
+static void gpu_texture_update_scaled(GPUTexture *tex,
+ uchar *rect,
+ float *rect_float,
+ int full_w,
+ int full_h,
+ int x,
+ int y,
+ int layer,
+ const int *tile_offset,
+ const int *tile_size,
+ int w,
+ int h)
+{
+ ImBuf *ibuf;
+ if (layer > -1) {
+ ibuf = update_do_scale(
+ rect, rect_float, &x, &y, &w, &h, tile_size[0], tile_size[1], full_w, full_h);
+
+ /* Shift to account for tile packing. */
+ x += tile_offset[0];
+ y += tile_offset[1];
+ }
+ else {
+ /* Partial update with scaling. */
+ int limit_w = smaller_power_of_2_limit(full_w);
+ int limit_h = smaller_power_of_2_limit(full_h);
+
+ ibuf = update_do_scale(rect, rect_float, &x, &y, &w, &h, limit_w, limit_h, full_w, full_h);
+ }
+
+ void *data = (ibuf->rect_float) ? (void *)(ibuf->rect_float) : (void *)(ibuf->rect);
+ eGPUDataFormat data_format = (ibuf->rect_float) ? GPU_DATA_FLOAT : GPU_DATA_UNSIGNED_BYTE;
+
+ GPU_texture_update_sub(tex, data_format, data, x, y, layer, w, h, 1);
+
+ IMB_freeImBuf(ibuf);
+}
+
+static void gpu_texture_update_unscaled(GPUTexture *tex,
+ uchar *rect,
+ float *rect_float,
+ int x,
+ int y,
+ int layer,
+ const int tile_offset[2],
+ int w,
+ int h,
+ int tex_stride,
+ int tex_offset)
+{
+ if (layer > -1) {
+ /* Shift to account for tile packing. */
+ x += tile_offset[0];
+ y += tile_offset[1];
+ }
+
+ void *data = (rect_float) ? (void *)(rect_float + tex_offset) : (void *)(rect + tex_offset);
+ eGPUDataFormat data_format = (rect_float) ? GPU_DATA_FLOAT : GPU_DATA_UNSIGNED_BYTE;
+
+ /* Partial update without scaling. Stride and offset are used to copy only a
+ * subset of a possible larger buffer than what we are updating. */
+ GPU_unpack_row_length_set(tex_stride);
+
+ GPU_texture_update_sub(tex, data_format, data, x, y, layer, w, h, 1);
+ /* Restore default. */
+ GPU_unpack_row_length_set(0);
+}
+
+static void gpu_texture_update_from_ibuf(
+ GPUTexture *tex, Image *ima, ImBuf *ibuf, ImageTile *tile, int x, int y, int w, int h)
+{
+ bool scaled;
+ if (tile != NULL) {
+ int *tilesize = tile->runtime.tilearray_size;
+ scaled = (ibuf->x != tilesize[0]) || (ibuf->y != tilesize[1]);
+ }
+ else {
+ scaled = is_over_resolution_limit(ibuf->x, ibuf->y);
+ }
+
+ if (scaled) {
+ /* Extra padding to account for bleed from neighboring pixels. */
+ const int padding = 4;
+ const int xmax = min_ii(x + w + padding, ibuf->x);
+ const int ymax = min_ii(y + h + padding, ibuf->y);
+ x = max_ii(x - padding, 0);
+ y = max_ii(y - padding, 0);
+ w = xmax - x;
+ h = ymax - y;
+ }
+
+ /* Get texture data pointers. */
+ float *rect_float = ibuf->rect_float;
+ uchar *rect = (uchar *)ibuf->rect;
+ int tex_stride = ibuf->x;
+ int tex_offset = ibuf->channels * (y * ibuf->x + x);
+
+ if (rect_float == NULL) {
+ /* Byte pixels. */
+ if (!IMB_colormanagement_space_is_data(ibuf->rect_colorspace)) {
+ const bool compress_as_srgb = !IMB_colormanagement_space_is_scene_linear(
+ ibuf->rect_colorspace);
+
+ rect = (uchar *)MEM_mallocN(sizeof(uchar[4]) * w * h, __func__);
+ if (rect == NULL) {
+ return;
+ }
+
+ tex_stride = w;
+ tex_offset = 0;
+
+ /* Convert to scene linear with sRGB compression, and premultiplied for
+ * correct texture interpolation. */
+ const bool store_premultiplied = (ima->alpha_mode == IMA_ALPHA_PREMUL);
+ IMB_colormanagement_imbuf_to_byte_texture(
+ rect, x, y, w, h, ibuf, compress_as_srgb, store_premultiplied);
+ }
+ }
+ else {
+ /* Float pixels. */
+ const bool store_premultiplied = (ima->alpha_mode != IMA_ALPHA_STRAIGHT);
+
+ if (ibuf->channels != 4 || scaled || !store_premultiplied) {
+ rect_float = (float *)MEM_mallocN(sizeof(float[4]) * w * h, __func__);
+ if (rect_float == NULL) {
+ return;
+ }
+
+ tex_stride = w;
+ tex_offset = 0;
+
+ IMB_colormanagement_imbuf_to_float_texture(
+ rect_float, x, y, w, h, ibuf, store_premultiplied);
+ }
+ }
+
+ GPU_texture_bind(tex, 0);
+
+ if (scaled) {
+ /* Slower update where we first have to scale the input pixels. */
+ if (tile != NULL) {
+ int *tileoffset = tile->runtime.tilearray_offset;
+ int *tilesize = tile->runtime.tilearray_size;
+ int tilelayer = tile->runtime.tilearray_layer;
+ gpu_texture_update_scaled(
+ tex, rect, rect_float, ibuf->x, ibuf->y, x, y, tilelayer, tileoffset, tilesize, w, h);
+ }
+ else {
+ gpu_texture_update_scaled(
+ tex, rect, rect_float, ibuf->x, ibuf->y, x, y, -1, NULL, NULL, w, h);
+ }
+ }
+ else {
+ /* Fast update at same resolution. */
+ if (tile != NULL) {
+ int *tileoffset = tile->runtime.tilearray_offset;
+ int tilelayer = tile->runtime.tilearray_layer;
+ gpu_texture_update_unscaled(
+ tex, rect, rect_float, x, y, tilelayer, tileoffset, w, h, tex_stride, tex_offset);
+ }
+ else {
+ gpu_texture_update_unscaled(
+ tex, rect, rect_float, x, y, -1, NULL, w, h, tex_stride, tex_offset);
+ }
+ }
+
+ /* Free buffers if needed. */
+ if (rect && rect != (uchar *)ibuf->rect) {
+ MEM_freeN(rect);
+ }
+ if (rect_float && rect_float != ibuf->rect_float) {
+ MEM_freeN(rect_float);
+ }
+
+ if (GPU_mipmap_enabled()) {
+ GPU_texture_generate_mipmap(tex);
+ }
+ else {
+ ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
+ }
+
+ GPU_texture_unbind(tex);
+}
+
+/* Partial update of texture for texture painting. This is often much
+ * quicker than fully updating the texture for high resolution images. */
+void BKE_image_update_gputexture(Image *ima, ImageUser *iuser, int x, int y, int w, int h)
+{
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
+ ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
+
+ if ((ibuf == NULL) || (w == 0) || (h == 0)) {
+ /* Full reload of texture. */
+ BKE_image_free_gputextures(ima);
+ }
+
+ GPUTexture *tex = ima->gputexture[TEXTARGET_2D][0];
+ /* Check if we need to update the main gputexture. */
+ if (tex != NULL && tile == ima->tiles.first) {
+ gpu_texture_update_from_ibuf(tex, ima, ibuf, NULL, x, y, w, h);
+ }
+
+ /* Check if we need to update the array gputexture. */
+ tex = ima->gputexture[TEXTARGET_2D_ARRAY][0];
+ if (tex != NULL) {
+ gpu_texture_update_from_ibuf(tex, ima, ibuf, tile, x, y, w, h);
+ }
+
+ BKE_image_release_ibuf(ima, ibuf, NULL);
+}
+
+/* these two functions are called on entering and exiting texture paint mode,
+ * temporary disabling/enabling mipmapping on all images for quick texture
+ * updates with glTexSubImage2D. images that didn't change don't have to be
+ * re-uploaded to OpenGL */
+void BKE_image_paint_set_mipmap(Main *bmain, bool mipmap)
+{
+ LISTBASE_FOREACH (Image *, ima, &bmain->images) {
+ if (BKE_image_has_opengl_texture(ima)) {
+ if (ima->gpuflag & IMA_GPU_MIPMAP_COMPLETE) {
+ for (int eye = 0; eye < 2; eye++) {
+ for (int a = 0; a < TEXTARGET_COUNT; a++) {
+ if (ELEM(a, TEXTARGET_2D, TEXTARGET_2D_ARRAY)) {
+ GPUTexture *tex = ima->gputexture[a][eye];
+ if (tex != NULL) {
+ GPU_texture_mipmap_mode(tex, mipmap, true);
+ }
+ }
+ }
+ }
+ }
+ else {
+ BKE_image_free_gputextures(ima);
+ }
+ }
+ else {
+ ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
+ }
+ }
+}
+
+/** \} */
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 7bf9cb2d0a1..94a142600b6 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -158,7 +158,7 @@ static AdrBit2Path ob_layer_bits[] = {
/* quick macro for returning the appropriate array for adrcode_bitmaps_to_paths() */
#define RET_ABP(items) \
{ \
- *tot = sizeof(items) / sizeof(AdrBit2Path); \
+ *tot = ARRAY_SIZE(items); \
return items; \
} \
(void)0
@@ -517,9 +517,8 @@ static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index))
BLI_snprintf(buf, 128, "%s.%s", base, prop);
return buf;
}
- else {
- return NULL;
- }
+
+ return NULL;
}
/* Texture types */
@@ -1074,10 +1073,9 @@ static char *get_rna_access(ID *id,
return NULL;
}
- else {
- if (array_index) {
- *array_index = dummy_index;
- }
+
+ if (array_index) {
+ *array_index = dummy_index;
}
/* 'buf' _must_ be initialized in this block */
@@ -1976,7 +1974,7 @@ void do_versions_ipos_to_animato(Main *bmain)
CLOG_WARN(&LOG, "Animation data too new to convert (Version %d)", bmain->versionfile);
return;
}
- else if (G.debug & G_DEBUG) {
+ if (G.debug & G_DEBUG) {
printf("INFO: Converting to Animato...\n");
}
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index a71b9cc2a1d..0108befa710 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -569,7 +569,7 @@ static char *key_block_get_data(Key *key, KeyBlock *actkb, KeyBlock *kb, char **
if (me->edit_mesh && me->edit_mesh->bm->totvert == kb->totelem) {
a = 0;
- co = MEM_mallocN(sizeof(float) * 3 * me->edit_mesh->bm->totvert, "key_block_get_data");
+ co = MEM_mallocN(sizeof(float[3]) * me->edit_mesh->bm->totvert, "key_block_get_data");
BM_ITER_MESH (eve, &iter, me->edit_mesh->bm, BM_VERTS_OF_MESH) {
copy_v3_v3(co[a], eve->co);
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 8820434cbcf..4d073593da7 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -356,9 +356,8 @@ bool object_deform_mball(Object *ob, ListBase *dispbase)
return true;
}
- else {
- return false;
- }
+
+ return false;
}
static BPoint *latt_bp(Lattice *lt, int u, int v, int w)
@@ -575,9 +574,8 @@ struct BPoint *BKE_lattice_active_point_get(Lattice *lt)
if ((lt->actbp != LT_ACTBP_NONE) && (lt->actbp < lt->pntsu * lt->pntsv * lt->pntsw)) {
return &lt->def[lt->actbp];
}
- else {
- return NULL;
- }
+
+ return NULL;
}
void BKE_lattice_center_median(Lattice *lt, float cent[3])
@@ -672,7 +670,7 @@ void BKE_lattice_center_bounds(Lattice *lt, float cent[3])
mid_v3_v3v3(cent, min, max);
}
-void BKE_lattice_transform(Lattice *lt, float mat[4][4], bool do_keys)
+void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
{
BPoint *bp = lt->def;
int i = lt->pntsu * lt->pntsv * lt->pntsw;
@@ -694,7 +692,7 @@ void BKE_lattice_transform(Lattice *lt, float mat[4][4], bool do_keys)
}
}
-void BKE_lattice_translate(Lattice *lt, float offset[3], bool do_keys)
+void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys)
{
int i, numVerts;
diff --git a/source/blender/blenkernel/intern/lattice_deform.c b/source/blender/blenkernel/intern/lattice_deform.c
index 674ee9ed2c5..33f7d9851db 100644
--- a/source/blender/blenkernel/intern/lattice_deform.c
+++ b/source/blender/blenkernel/intern/lattice_deform.c
@@ -80,7 +80,7 @@ LatticeDeformData *BKE_lattice_deform_data_create(const Object *oblatt, const Ob
}
bp = lt->def;
- fp = latticedata = MEM_mallocN(sizeof(float) * 3 * lt->pntsu * lt->pntsv * lt->pntsw,
+ fp = latticedata = MEM_mallocN(sizeof(float[3]) * lt->pntsu * lt->pntsv * lt->pntsw,
"latticedata");
/* for example with a particle system: (ob == NULL) */
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 64649d84320..cf6139d9449 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -221,7 +221,7 @@ ViewLayer *BKE_view_layer_add(Scene *scene,
view_layer_new = view_layer_add(name);
BLI_addtail(&scene->view_layers, view_layer_new);
- /* Initialise layercollections */
+ /* Initialize layer-collections. */
BKE_layer_collection_sync(scene, view_layer_new);
layer_collection_exclude_all(view_layer_new->layer_collections.first);
@@ -555,21 +555,19 @@ static bool layer_collection_hidden(ViewLayer *view_layer, LayerCollection *lc)
if (lc->flag & LAYER_COLLECTION_HIDE || lc->collection->flag & COLLECTION_RESTRICT_VIEWPORT) {
return true;
}
- else {
- /* Restriction flags stay set, so we need to check parents */
- CollectionParent *parent = lc->collection->parents.first;
- if (parent) {
- lc = BKE_layer_collection_first_from_scene_collection(view_layer, parent->collection);
+ /* Restriction flags stay set, so we need to check parents */
+ CollectionParent *parent = lc->collection->parents.first;
- return lc && layer_collection_hidden(view_layer, lc);
- }
- else {
- return false;
- }
+ if (parent) {
+ lc = BKE_layer_collection_first_from_scene_collection(view_layer, parent->collection);
+
+ return lc && layer_collection_hidden(view_layer, lc);
}
return false;
+
+ return false;
}
/**
@@ -1610,10 +1608,9 @@ void BKE_view_layer_selected_editable_objects_iterator_begin(BLI_Iterator *iter,
// First object is valid (selectable and not libdata) -> all good.
return;
}
- else {
- // Object is selectable but not editable -> search for another one.
- BKE_view_layer_selected_editable_objects_iterator_next(iter);
- }
+
+ // Object is selectable but not editable -> search for another one.
+ BKE_view_layer_selected_editable_objects_iterator_next(iter);
}
}
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index a64e550579d..3b7aae98327 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -2203,13 +2203,12 @@ char *BKE_id_to_unique_string_key(const struct ID *id)
if (id->lib == NULL) {
return BLI_strdup(id->name);
}
- else {
- /* Prefix with an ascii character in the range of 32..96 (visible)
- * this ensures we can't have a library ID pair that collide.
- * Where 'LIfooOBbarOBbaz' could be ('LIfoo, OBbarOBbaz') or ('LIfooOBbar', 'OBbaz'). */
- const char ascii_len = strlen(id->lib->id.name + 2) + 32;
- return BLI_sprintfN("%c%s%s", ascii_len, id->lib->id.name, id->name);
- }
+
+ /* Prefix with an ascii character in the range of 32..96 (visible)
+ * this ensures we can't have a library ID pair that collide.
+ * Where 'LIfooOBbarOBbaz' could be ('LIfoo, OBbarOBbaz') or ('LIfooOBbar', 'OBbaz'). */
+ const char ascii_len = strlen(id->lib->id.name + 2) + 32;
+ return BLI_sprintfN("%c%s%s", ascii_len, id->lib->id.name, id->name);
}
void BKE_id_tag_set_atomic(ID *id, int tag)
@@ -2258,7 +2257,7 @@ static int id_order_compare(const void *a, const void *b)
if (*order_a < *order_b) {
return -1;
}
- else if (*order_a > *order_b) {
+ if (*order_a > *order_b) {
return 1;
}
}
diff --git a/source/blender/blenkernel/intern/lib_intern.h b/source/blender/blenkernel/intern/lib_intern.h
index 9cc5db64d17..7305785573b 100644
--- a/source/blender/blenkernel/intern/lib_intern.h
+++ b/source/blender/blenkernel/intern/lib_intern.h
@@ -21,11 +21,8 @@
* \ingroup bke
*/
-#ifndef __LIB_INTERN_H__
-#define __LIB_INTERN_H__
+#pragma once
extern BKE_library_free_notifier_reference_cb free_notifier_reference_cb;
extern BKE_library_remap_editor_id_reference_cb remap_editor_id_reference_cb;
-
-#endif /* __LIB_INTERN_H__ */
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 2989c910c45..12d7f0e9e8e 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -117,9 +117,8 @@ void BKE_lib_override_library_copy(ID *dst_id, const ID *src_id, const bool do_f
BKE_lib_override_library_free(&dst_id->override_library, true);
return;
}
- else {
- BKE_lib_override_library_clear(dst_id->override_library, true);
- }
+
+ BKE_lib_override_library_clear(dst_id->override_library, true);
}
else if (src_id->override_library == NULL) {
/* Virtual overrides of embedded data does not require any extra work. */
@@ -1515,7 +1514,7 @@ void BKE_lib_override_library_main_update(Main *bmain)
*/
/** Initialize an override storage. */
-OverrideLibraryStorage *BKE_lib_override_library_operations_store_initialize(void)
+OverrideLibraryStorage *BKE_lib_override_library_operations_store_init(void)
{
return BKE_main_new();
}
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c
index 0f81d45c10f..e687e94073d 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -96,9 +96,8 @@ bool BKE_lib_query_foreachid_process(LibraryForeachIDData *data, ID **id_pp, int
}
return true;
}
- else {
- return false;
- }
+
+ return false;
}
int BKE_lib_query_foreachid_process_flags_get(LibraryForeachIDData *data)
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index aa1005c663f..f42df6765c4 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -58,7 +58,7 @@ static void light_init_data(ID *id)
MEMCPY_STRUCT_AFTER(la, DNA_struct_default_get(Light), id);
la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
- BKE_curvemapping_initialize(la->curfalloff);
+ BKE_curvemapping_init(la->curfalloff);
}
/**
diff --git a/source/blender/blenkernel/intern/main_idmap.c b/source/blender/blenkernel/intern/main_idmap.c
index d5499374e06..718af1f032d 100644
--- a/source/blender/blenkernel/intern/main_idmap.c
+++ b/source/blender/blenkernel/intern/main_idmap.c
@@ -166,7 +166,7 @@ static bool idkey_cmp(const void *a, const void *b)
{
const struct IDNameLib_Key *idkey_a = a;
const struct IDNameLib_Key *idkey_b = b;
- return strcmp(idkey_a->name, idkey_b->name) || (idkey_a->lib != idkey_b->lib);
+ return !STREQ(idkey_a->name, idkey_b->name) || (idkey_a->lib != idkey_b->lib);
}
ID *BKE_main_idmap_lookup_name(struct IDNameLib_Map *id_map,
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 7e859799a4e..444ed0c65b5 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -124,13 +124,11 @@ static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline,
if (spline->flag & MASK_SPLINE_CYCLIC) {
return &points_array[0];
}
- else {
- return NULL;
- }
- }
- else {
- return point + 1;
+
+ return NULL;
}
+
+ return point + 1;
}
static MaskSplinePoint *mask_spline_point_prev(MaskSpline *spline,
@@ -141,13 +139,11 @@ static MaskSplinePoint *mask_spline_point_prev(MaskSpline *spline,
if (spline->flag & MASK_SPLINE_CYCLIC) {
return &points_array[spline->tot_point - 1];
}
- else {
- return NULL;
- }
- }
- else {
- return point - 1;
+
+ return NULL;
}
+
+ return point - 1;
}
BezTriple *BKE_mask_spline_point_next_bezt(MaskSpline *spline,
@@ -158,13 +154,11 @@ BezTriple *BKE_mask_spline_point_next_bezt(MaskSpline *spline,
if (spline->flag & MASK_SPLINE_CYCLIC) {
return &(points_array[0].bezt);
}
- else {
- return NULL;
- }
- }
- else {
- return &((point + 1))->bezt;
+
+ return NULL;
}
+
+ return &((point + 1))->bezt;
}
MaskSplinePoint *BKE_mask_spline_point_array(MaskSpline *spline)
@@ -703,15 +697,14 @@ float BKE_mask_point_weight_scalar(MaskSpline *spline, MaskSplinePoint *point, c
if (!bezt_next) {
return bezt->weight;
}
- else if (u <= 0.0f) {
+ if (u <= 0.0f) {
return bezt->weight;
}
- else if (u >= 1.0f) {
+ if (u >= 1.0f) {
return bezt_next->weight;
}
- else {
- return mask_point_interp_weight(bezt, bezt_next, u);
- }
+
+ return mask_point_interp_weight(bezt, bezt_next, u);
}
float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, const float u)
@@ -724,53 +717,51 @@ float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, const fl
if (!bezt_next) {
return bezt->weight;
}
- else if (u <= 0.0f) {
+ if (u <= 0.0f) {
return bezt->weight;
}
- else if (u >= 1.0f) {
+ if (u >= 1.0f) {
return bezt_next->weight;
}
- else {
- float cur_u = 0.0f, cur_w = 0.0f, next_u = 0.0f, next_w = 0.0f, fac; /* Quite warnings */
- int i;
- for (i = 0; i <= point->tot_uw; i++) {
+ float cur_u = 0.0f, cur_w = 0.0f, next_u = 0.0f, next_w = 0.0f, fac; /* Quite warnings */
+ int i;
- if (i == 0) {
- cur_u = 0.0f;
- cur_w = 1.0f; /* mask_point_interp_weight will scale it */
- }
- else {
- cur_u = point->uw[i - 1].u;
- cur_w = point->uw[i - 1].w;
- }
+ for (i = 0; i <= point->tot_uw; i++) {
- if (i == point->tot_uw) {
- next_u = 1.0f;
- next_w = 1.0f; /* mask_point_interp_weight will scale it */
- }
- else {
- next_u = point->uw[i].u;
- next_w = point->uw[i].w;
- }
-
- if (u >= cur_u && u <= next_u) {
- break;
- }
+ if (i == 0) {
+ cur_u = 0.0f;
+ cur_w = 1.0f; /* mask_point_interp_weight will scale it */
+ }
+ else {
+ cur_u = point->uw[i - 1].u;
+ cur_w = point->uw[i - 1].w;
}
- fac = (u - cur_u) / (next_u - cur_u);
-
- cur_w *= mask_point_interp_weight(bezt, bezt_next, cur_u);
- next_w *= mask_point_interp_weight(bezt, bezt_next, next_u);
-
- if (spline->weight_interp == MASK_SPLINE_INTERP_EASE) {
- return cur_w + (next_w - cur_w) * (3.0f * fac * fac - 2.0f * fac * fac * fac);
+ if (i == point->tot_uw) {
+ next_u = 1.0f;
+ next_w = 1.0f; /* mask_point_interp_weight will scale it */
}
else {
- return (1.0f - fac) * cur_w + fac * next_w;
+ next_u = point->uw[i].u;
+ next_w = point->uw[i].w;
}
+
+ if (u >= cur_u && u <= next_u) {
+ break;
+ }
+ }
+
+ fac = (u - cur_u) / (next_u - cur_u);
+
+ cur_w *= mask_point_interp_weight(bezt, bezt_next, cur_u);
+ next_w *= mask_point_interp_weight(bezt, bezt_next, next_u);
+
+ if (spline->weight_interp == MASK_SPLINE_INTERP_EASE) {
+ return cur_w + (next_w - cur_w) * (3.0f * fac * fac - 2.0f * fac * fac * fac);
}
+
+ return (1.0f - fac) * cur_w + fac * next_w;
}
MaskSplinePointUW *BKE_mask_point_sort_uw(MaskSplinePoint *point, MaskSplinePointUW *uw)
@@ -1521,7 +1512,8 @@ static void mask_layer_shape_from_mask_point(BezTriple *bezt,
fp[7] = bezt->radius;
}
-static void mask_layer_shape_to_mask_point(BezTriple *bezt, float fp[MASK_OBJECT_SHAPE_ELEM_SIZE])
+static void mask_layer_shape_to_mask_point(BezTriple *bezt,
+ const float fp[MASK_OBJECT_SHAPE_ELEM_SIZE])
{
copy_v2_v2(bezt->vec[0], &fp[0]);
copy_v2_v2(bezt->vec[1], &fp[2]);
@@ -1642,7 +1634,7 @@ MaskLayerShape *BKE_mask_layer_shape_find_frame(MaskLayer *masklay, const int fr
if (frame == masklay_shape->frame) {
return masklay_shape;
}
- else if (frame < masklay_shape->frame) {
+ if (frame < masklay_shape->frame) {
break;
}
}
@@ -1667,17 +1659,16 @@ int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay,
*r_masklay_shape_b = NULL;
return 1;
}
- else if (frame < masklay_shape->frame) {
+ if (frame < masklay_shape->frame) {
if (masklay_shape->prev) {
*r_masklay_shape_a = masklay_shape->prev;
*r_masklay_shape_b = masklay_shape;
return 2;
}
- else {
- *r_masklay_shape_a = masklay_shape;
- *r_masklay_shape_b = NULL;
- return 1;
- }
+
+ *r_masklay_shape_a = masklay_shape;
+ *r_masklay_shape_b = NULL;
+ return 1;
}
}
@@ -1686,12 +1677,11 @@ int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay,
*r_masklay_shape_b = NULL;
return 1;
}
- else {
- *r_masklay_shape_a = NULL;
- *r_masklay_shape_b = NULL;
- return 0;
- }
+ *r_masklay_shape_a = NULL;
+ *r_masklay_shape_b = NULL;
+
+ return 0;
}
MaskLayerShape *BKE_mask_layer_shape_verify_frame(MaskLayer *masklay, const int frame)
@@ -1738,12 +1728,11 @@ static int mask_layer_shape_sort_cb(const void *masklay_shape_a_ptr,
if (masklay_shape_a->frame < masklay_shape_b->frame) {
return -1;
}
- else if (masklay_shape_a->frame > masklay_shape_b->frame) {
+ if (masklay_shape_a->frame > masklay_shape_b->frame) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
void BKE_mask_layer_shape_sort(MaskLayer *masklay)
diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c
index 9b281103a0f..2fbf5f8648d 100644
--- a/source/blender/blenkernel/intern/mask_evaluate.c
+++ b/source/blender/blenkernel/intern/mask_evaluate.c
@@ -126,9 +126,8 @@ int BKE_mask_spline_differentiate_calc_total(const MaskSpline *spline, const uns
if (spline->flag & MASK_SPLINE_CYCLIC) {
return spline->tot_point * resol;
}
- else {
- return ((spline->tot_point - 1) * resol) + 1;
- }
+
+ return ((spline->tot_point - 1) * resol) + 1;
}
float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline,
@@ -179,7 +178,7 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline,
bezt_curr->vec[1][j],
&(*fp)[j],
resol,
- 2 * sizeof(float));
+ sizeof(float[2]));
}
fp += resol;
@@ -688,7 +687,7 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__double
bezt_curr->vec[1][j],
&(*fp)[j],
resol,
- 2 * sizeof(float));
+ sizeof(float[2]));
}
/* scale by the uw's */
@@ -846,7 +845,7 @@ float *BKE_mask_point_segment_diff(MaskSpline *spline,
/* resol+1 because of 'forward_diff_bezier' function */
*tot_diff_point = resol + 1;
- diff_points = fp = MEM_callocN((resol + 1) * 2 * sizeof(float), "mask segment vets");
+ diff_points = fp = MEM_callocN(sizeof(float[2]) * (resol + 1), "mask segment vets");
for (j = 0; j < 2; j++) {
BKE_curve_forward_diff_bezier(bezt->vec[1][j],
@@ -855,7 +854,7 @@ float *BKE_mask_point_segment_diff(MaskSpline *spline,
bezt_next->vec[1][j],
fp + j,
resol,
- 2 * sizeof(float));
+ sizeof(float[2]));
}
copy_v2_v2(fp + 2 * resol, bezt_next->vec[1]);
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 01d44d070b3..92885535f57 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -354,43 +354,38 @@ static bool layer_bucket_isect_test(const MaskRasterLayer *layer,
if (isect_point_tri_v2(cent, v1, v2, v3)) {
return true;
}
- else {
- if ((dist_squared_to_line_segment_v2(cent, v1, v2) < bucket_max_rad_squared) ||
- (dist_squared_to_line_segment_v2(cent, v2, v3) < bucket_max_rad_squared) ||
- (dist_squared_to_line_segment_v2(cent, v3, v1) < bucket_max_rad_squared)) {
- return true;
- }
- else {
- // printf("skip tri\n");
- return false;
- }
- }
- }
- else {
- const float *v1 = cos[face[0]];
- const float *v2 = cos[face[1]];
- const float *v3 = cos[face[2]];
- const float *v4 = cos[face[3]];
- if (isect_point_tri_v2(cent, v1, v2, v3)) {
+ if ((dist_squared_to_line_segment_v2(cent, v1, v2) < bucket_max_rad_squared) ||
+ (dist_squared_to_line_segment_v2(cent, v2, v3) < bucket_max_rad_squared) ||
+ (dist_squared_to_line_segment_v2(cent, v3, v1) < bucket_max_rad_squared)) {
return true;
}
- else if (isect_point_tri_v2(cent, v1, v3, v4)) {
- return true;
- }
- else {
- if ((dist_squared_to_line_segment_v2(cent, v1, v2) < bucket_max_rad_squared) ||
- (dist_squared_to_line_segment_v2(cent, v2, v3) < bucket_max_rad_squared) ||
- (dist_squared_to_line_segment_v2(cent, v3, v4) < bucket_max_rad_squared) ||
- (dist_squared_to_line_segment_v2(cent, v4, v1) < bucket_max_rad_squared)) {
- return true;
- }
- else {
- // printf("skip quad\n");
- return false;
- }
- }
+
+ // printf("skip tri\n");
+ return false;
+ }
+
+ const float *v1 = cos[face[0]];
+ const float *v2 = cos[face[1]];
+ const float *v3 = cos[face[2]];
+ const float *v4 = cos[face[3]];
+
+ if (isect_point_tri_v2(cent, v1, v2, v3)) {
+ return true;
+ }
+ if (isect_point_tri_v2(cent, v1, v3, v4)) {
+ return true;
}
+
+ if ((dist_squared_to_line_segment_v2(cent, v1, v2) < bucket_max_rad_squared) ||
+ (dist_squared_to_line_segment_v2(cent, v2, v3) < bucket_max_rad_squared) ||
+ (dist_squared_to_line_segment_v2(cent, v3, v4) < bucket_max_rad_squared) ||
+ (dist_squared_to_line_segment_v2(cent, v4, v1) < bucket_max_rad_squared)) {
+ return true;
+ }
+
+ // printf("skip quad\n");
+ return false;
}
static void layer_bucket_init_dummy(MaskRasterLayer *layer)
@@ -791,7 +786,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
co_feather[2] = 1.0f;
if (spline->flag & MASK_SPLINE_NOINTERSECT) {
- diff_feather_points_flip = MEM_mallocN(sizeof(float) * 2 * tot_diff_feather_points,
+ diff_feather_points_flip = MEM_mallocN(sizeof(float[2]) * tot_diff_feather_points,
"diff_feather_points_flip");
for (j = 0; j < tot_diff_point; j++) {
@@ -944,7 +939,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
ListBase isect_remedgebase = {NULL, NULL};
/* now we have all the splines */
- face_coords = MEM_mallocN((sizeof(float) * 3) * sf_vert_tot, "maskrast_face_coords");
+ face_coords = MEM_mallocN((sizeof(float[3])) * sf_vert_tot, "maskrast_face_coords");
/* init bounds */
BLI_rctf_init_minmax(&bounds);
@@ -1348,9 +1343,8 @@ static float layer_bucket_depth_from_xy(MaskRasterLayer *layer, const float xy[2
}
return best_dist;
}
- else {
- return 1.0f;
- }
+
+ return 1.0f;
}
float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float xy[2])
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index aa72493e472..0520ba3faae 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -268,27 +268,27 @@ Material ***BKE_object_material_array_p(Object *ob)
Mesh *me = ob->data;
return &(me->mat);
}
- else if (ELEM(ob->type, OB_CURVE, OB_FONT, OB_SURF)) {
+ if (ELEM(ob->type, OB_CURVE, OB_FONT, OB_SURF)) {
Curve *cu = ob->data;
return &(cu->mat);
}
- else if (ob->type == OB_MBALL) {
+ if (ob->type == OB_MBALL) {
MetaBall *mb = ob->data;
return &(mb->mat);
}
- else if (ob->type == OB_GPENCIL) {
+ if (ob->type == OB_GPENCIL) {
bGPdata *gpd = ob->data;
return &(gpd->mat);
}
- else if (ob->type == OB_HAIR) {
+ if (ob->type == OB_HAIR) {
Hair *hair = ob->data;
return &(hair->mat);
}
- else if (ob->type == OB_POINTCLOUD) {
+ if (ob->type == OB_POINTCLOUD) {
PointCloud *pointcloud = ob->data;
return &(pointcloud->mat);
}
- else if (ob->type == OB_VOLUME) {
+ if (ob->type == OB_VOLUME) {
Volume *volume = ob->data;
return &(volume->mat);
}
@@ -301,27 +301,27 @@ short *BKE_object_material_len_p(Object *ob)
Mesh *me = ob->data;
return &(me->totcol);
}
- else if (ELEM(ob->type, OB_CURVE, OB_FONT, OB_SURF)) {
+ if (ELEM(ob->type, OB_CURVE, OB_FONT, OB_SURF)) {
Curve *cu = ob->data;
return &(cu->totcol);
}
- else if (ob->type == OB_MBALL) {
+ if (ob->type == OB_MBALL) {
MetaBall *mb = ob->data;
return &(mb->totcol);
}
- else if (ob->type == OB_GPENCIL) {
+ if (ob->type == OB_GPENCIL) {
bGPdata *gpd = ob->data;
return &(gpd->totcol);
}
- else if (ob->type == OB_HAIR) {
+ if (ob->type == OB_HAIR) {
Hair *hair = ob->data;
return &(hair->totcol);
}
- else if (ob->type == OB_POINTCLOUD) {
+ if (ob->type == OB_POINTCLOUD) {
PointCloud *pointcloud = ob->data;
return &(pointcloud->totcol);
}
- else if (ob->type == OB_VOLUME) {
+ if (ob->type == OB_VOLUME) {
Volume *volume = ob->data;
return &(volume->totcol);
}
@@ -582,7 +582,7 @@ Material **BKE_object_material_get_p(Object *ob, short act)
if (act > ob->totcol) {
return NULL;
}
- else if (act <= 0) {
+ if (act <= 0) {
if (act < 0) {
CLOG_ERROR(&LOG, "Negative material index!");
}
@@ -627,9 +627,8 @@ Material *BKE_gpencil_material(Object *ob, short act)
if (ma != NULL) {
return ma;
}
- else {
- return BKE_material_default_gpencil();
- }
+
+ return BKE_material_default_gpencil();
}
MaterialGPencilStyle *BKE_gpencil_material_settings(Object *ob, short act)
@@ -642,9 +641,8 @@ MaterialGPencilStyle *BKE_gpencil_material_settings(Object *ob, short act)
return ma->gp_style;
}
- else {
- return BKE_material_default_gpencil()->gp_style;
- }
+
+ return BKE_material_default_gpencil()->gp_style;
}
void BKE_object_material_resize(Main *bmain, Object *ob, const short totcol, bool do_id_user)
@@ -1135,9 +1133,8 @@ static bNode *nodetree_uv_node_recursive(bNode *node)
if (inode->typeinfo->nclass == NODE_CLASS_INPUT && inode->typeinfo->type == SH_NODE_UVMAP) {
return inode;
}
- else {
- return nodetree_uv_node_recursive(inode);
- }
+
+ return nodetree_uv_node_recursive(inode);
}
}
@@ -1718,6 +1715,29 @@ static void material_default_volume_init(Material *ma)
nodeSetActive(ntree, output);
}
+static void material_default_holdout_init(Material *ma)
+{
+ bNodeTree *ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname);
+ ma->nodetree = ntree;
+ ma->use_nodes = true;
+
+ bNode *holdout = nodeAddStaticNode(NULL, ntree, SH_NODE_HOLDOUT);
+ bNode *output = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_MATERIAL);
+
+ nodeAddLink(ntree,
+ holdout,
+ nodeFindSocket(holdout, SOCK_OUT, "Holdout"),
+ output,
+ nodeFindSocket(output, SOCK_IN, "Surface"));
+
+ holdout->locx = 10.0f;
+ holdout->locy = 300.0f;
+ output->locx = 300.0f;
+ output->locy = 300.0f;
+
+ nodeSetActive(ntree, output);
+}
+
Material *BKE_material_default_empty(void)
{
return &default_material_empty;
@@ -1763,6 +1783,7 @@ void BKE_materials_init(void)
material_default_surface_init(&default_material_surface);
material_default_volume_init(&default_material_volume);
+ material_default_holdout_init(&default_material_holdout);
material_default_gpencil_init(&default_material_gpencil);
}
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 94e5f435a43..de07c96e3f0 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -281,7 +281,7 @@ float *BKE_mball_make_orco(Object *ob, ListBase *dispbase)
size[2] = bb->vec[1][2] - loc[2];
dl = dispbase->first;
- orcodata = MEM_mallocN(sizeof(float) * 3 * dl->nr, "MballOrco");
+ orcodata = MEM_mallocN(sizeof(float[3]) * dl->nr, "MballOrco");
data = dl->verts;
orco = orcodata;
@@ -341,9 +341,8 @@ bool BKE_mball_is_basis_for(Object *ob1, Object *ob2)
if (STREQ(basis1name, basis2name)) {
return BKE_mball_is_basis(ob1);
}
- else {
- return false;
- }
+
+ return false;
}
bool BKE_mball_is_any_selected(const MetaBall *mb)
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index ad178e76ef6..92e16be878f 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -315,7 +315,7 @@ static float densfunc(const MetaElem *ball, float x, float y, float z)
float dist2;
float dvec[3] = {x, y, z};
- mul_m4_v3((float(*)[4])ball->imat, dvec);
+ mul_m4_v3((const float(*)[4])ball->imat, dvec);
switch (ball->type) {
case MB_BALL:
@@ -1276,8 +1276,8 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje
new_ml = BLI_memarena_alloc(process->pgn_elements, sizeof(MetaElem));
*(new_ml) = *ml;
new_ml->bb = BLI_memarena_alloc(process->pgn_elements, sizeof(BoundBox));
- new_ml->mat = BLI_memarena_alloc(process->pgn_elements, 4 * 4 * sizeof(float));
- new_ml->imat = BLI_memarena_alloc(process->pgn_elements, 4 * 4 * sizeof(float));
+ new_ml->mat = BLI_memarena_alloc(process->pgn_elements, sizeof(float[4][4]));
+ new_ml->imat = BLI_memarena_alloc(process->pgn_elements, sizeof(float[4][4]));
/* too big stiffness seems only ugly due to linear interpolation
* no need to have possibility for too big stiffness */
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 48baedadd73..2a16d0eb0f8 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -95,7 +95,15 @@ static void mesh_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
/* This is a direct copy of a main mesh, so for now it has the same topology. */
mesh_dst->runtime.deformed_only = true;
}
- /* XXX WHAT? Why? Comment, please! And pretty sure this is not valid for regular Mesh copying? */
+ /* This option is set for run-time meshes that have been copied from the current objects mode.
+ * Currently this is used for edit-mesh although it could be used for sculpt or other
+ * kinds of data specific to an objects mode.
+ *
+ * The flag signals that the mesh hasn't been modified from the data that generated it,
+ * allowing us to use the object-mode data for drawing.
+ *
+ * While this could be the callers responsibility, keep here since it's
+ * highly unlikely we want to create a duplicate and not use it for drawing. */
mesh_dst->runtime.is_original = false;
/* Only do tessface if we have no polys. */
@@ -591,9 +599,8 @@ bool BKE_mesh_has_custom_loop_normals(Mesh *me)
if (me->edit_mesh) {
return CustomData_has_layer(&me->edit_mesh->bm->ldata, CD_CUSTOMLOOPNORMAL);
}
- else {
- return CustomData_has_layer(&me->ldata, CD_CUSTOMLOOPNORMAL);
- }
+
+ return CustomData_has_layer(&me->ldata, CD_CUSTOMLOOPNORMAL);
}
/** Free (or release) any data used by this mesh (does not free the mesh itself). */
@@ -1096,9 +1103,8 @@ Mesh *BKE_mesh_from_object(Object *ob)
if (ob->type == OB_MESH) {
return ob->data;
}
- else {
- return NULL;
- }
+
+ return NULL;
}
void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *me)
@@ -1270,12 +1276,11 @@ int BKE_mesh_edge_other_vert(const MEdge *e, int v)
if (e->v1 == v) {
return e->v2;
}
- else if (e->v2 == v) {
+ if (e->v2 == v) {
return e->v1;
}
- else {
- return -1;
- }
+
+ return -1;
}
/**
@@ -1305,7 +1310,7 @@ bool BKE_mesh_minmax(const Mesh *me, float r_min[3], float r_max[3])
return (me->totvert != 0);
}
-void BKE_mesh_transform(Mesh *me, float mat[4][4], bool do_keys)
+void BKE_mesh_transform(Mesh *me, const float mat[4][4], bool do_keys)
{
int i;
MVert *mvert = me->mvert;
@@ -1406,30 +1411,29 @@ void BKE_mesh_do_versions_cd_flag_init(Mesh *mesh)
if (UNLIKELY(mesh->cd_flag)) {
return;
}
- else {
- MVert *mv;
- MEdge *med;
- int i;
- for (mv = mesh->mvert, i = 0; i < mesh->totvert; mv++, i++) {
- if (mv->bweight != 0) {
- mesh->cd_flag |= ME_CDFLAG_VERT_BWEIGHT;
- break;
- }
+ MVert *mv;
+ MEdge *med;
+ int i;
+
+ for (mv = mesh->mvert, i = 0; i < mesh->totvert; mv++, i++) {
+ if (mv->bweight != 0) {
+ mesh->cd_flag |= ME_CDFLAG_VERT_BWEIGHT;
+ break;
}
+ }
- for (med = mesh->medge, i = 0; i < mesh->totedge; med++, i++) {
- if (med->bweight != 0) {
- mesh->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT;
- if (mesh->cd_flag & ME_CDFLAG_EDGE_CREASE) {
- break;
- }
+ for (med = mesh->medge, i = 0; i < mesh->totedge; med++, i++) {
+ if (med->bweight != 0) {
+ mesh->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT;
+ if (mesh->cd_flag & ME_CDFLAG_EDGE_CREASE) {
+ break;
}
- if (med->crease != 0) {
- mesh->cd_flag |= ME_CDFLAG_EDGE_CREASE;
- if (mesh->cd_flag & ME_CDFLAG_EDGE_BWEIGHT) {
- break;
- }
+ }
+ if (med->crease != 0) {
+ mesh->cd_flag |= ME_CDFLAG_EDGE_CREASE;
+ if (mesh->cd_flag & ME_CDFLAG_EDGE_BWEIGHT) {
+ break;
}
}
}
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index 9e5565d744a..76a6d23bc8f 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -286,12 +286,14 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
}
}
else if (dl->type == DL_SURF) {
- int tot;
- totvert += dl->parts * dl->nr;
- tot = (dl->parts - 1 + ((dl->flag & DL_CYCL_V) == 2)) *
- (dl->nr - 1 + (dl->flag & DL_CYCL_U));
- totpoly += tot;
- totloop += tot * 4;
+ if (dl->parts != 0) {
+ int tot;
+ totvert += dl->parts * dl->nr;
+ tot = (((dl->flag & DL_CYCL_U) ? 1 : 0) + (dl->nr - 1)) *
+ (((dl->flag & DL_CYCL_V) ? 1 : 0) + (dl->parts - 1));
+ totpoly += tot;
+ totloop += tot * 4;
+ }
}
else if (dl->type == DL_INDEX3) {
int tot;
@@ -312,11 +314,11 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
*r_allvert = mvert = MEM_calloc_arrayN(totvert, sizeof(MVert), "nurbs_init mvert");
*r_alledge = medge = MEM_calloc_arrayN(totedge, sizeof(MEdge), "nurbs_init medge");
*r_allloop = mloop = MEM_calloc_arrayN(
- totpoly, 4 * sizeof(MLoop), "nurbs_init mloop"); // totloop
+ totpoly, sizeof(MLoop[4]), "nurbs_init mloop"); // totloop
*r_allpoly = mpoly = MEM_calloc_arrayN(totpoly, sizeof(MPoly), "nurbs_init mloop");
if (r_alluv) {
- *r_alluv = mloopuv = MEM_calloc_arrayN(totpoly, 4 * sizeof(MLoopUV), "nurbs_init mloopuv");
+ *r_alluv = mloopuv = MEM_calloc_arrayN(totpoly, sizeof(MLoopUV[4]), "nurbs_init mloopuv");
}
/* verts and faces */
@@ -1296,11 +1298,11 @@ static void add_shapekey_layers(Mesh *mesh_dest, Mesh *mesh_src)
mesh_src->totvert,
kb->name,
kb->totelem);
- array = MEM_calloc_arrayN((size_t)mesh_src->totvert, 3 * sizeof(float), __func__);
+ array = MEM_calloc_arrayN((size_t)mesh_src->totvert, sizeof(float[3]), __func__);
}
else {
- array = MEM_malloc_arrayN((size_t)mesh_src->totvert, 3 * sizeof(float), __func__);
- memcpy(array, kb->data, (size_t)mesh_src->totvert * 3 * sizeof(float));
+ array = MEM_malloc_arrayN((size_t)mesh_src->totvert, sizeof(float[3]), __func__);
+ memcpy(array, kb->data, sizeof(float[3]) * (size_t)mesh_src->totvert);
}
CustomData_add_layer_named(
@@ -1403,7 +1405,7 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act
cos = CustomData_get_layer_n(&mesh_src->vdata, CD_SHAPEKEY, i);
kb->totelem = mesh_src->totvert;
- kb->data = kbcos = MEM_malloc_arrayN(kb->totelem, 3 * sizeof(float), __func__);
+ kb->data = kbcos = MEM_malloc_arrayN(kb->totelem, sizeof(float[3]), __func__);
if (kb->uid == actshape_uid) {
MVert *mvert = mesh_src->mvert;
@@ -1425,7 +1427,7 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act
}
kb->totelem = mesh_src->totvert;
- kb->data = MEM_calloc_arrayN(kb->totelem, 3 * sizeof(float), __func__);
+ kb->data = MEM_calloc_arrayN(kb->totelem, sizeof(float[3]), __func__);
CLOG_ERROR(&LOG, "lost a shapekey layer: '%s'! (bmesh internal error)", kb->name);
}
}
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 49957b584ad..fe4b8a60796 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -1408,7 +1408,7 @@ static bool loop_split_generator_check_cyclic_smooth_fan(const MLoop *mloops,
return false;
}
/* Smooth loop/edge... */
- else if (BLI_BITMAP_TEST(skip_loops, mlfan_vert_index)) {
+ if (BLI_BITMAP_TEST(skip_loops, mlfan_vert_index)) {
if (mlfan_vert_index == ml_curr_index) {
/* We walked around a whole cyclic smooth fan without finding any already-processed loop,
* means we can use initial ml_curr/ml_prev edge as start for this smooth fan. */
@@ -1417,10 +1417,9 @@ static bool loop_split_generator_check_cyclic_smooth_fan(const MLoop *mloops,
/* ... already checked in some previous looping, we can abort. */
return false;
}
- else {
- /* ... we can skip it in future, and keep checking the smooth fan. */
- BLI_BITMAP_ENABLE(skip_loops, mlfan_vert_index);
- }
+
+ /* ... we can skip it in future, and keep checking the smooth fan. */
+ BLI_BITMAP_ENABLE(skip_loops, mlfan_vert_index);
}
}
@@ -2315,22 +2314,21 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const
return area_tri_v3(
mvarray[loopstart[0].v].co, mvarray[loopstart[1].v].co, mvarray[loopstart[2].v].co);
}
- else {
- int i;
- const MLoop *l_iter = loopstart;
- float area;
- float(*vertexcos)[3] = BLI_array_alloca(vertexcos, (size_t)mpoly->totloop);
-
- /* pack vertex cos into an array for area_poly_v3 */
- for (i = 0; i < mpoly->totloop; i++, l_iter++) {
- copy_v3_v3(vertexcos[i], mvarray[l_iter->v].co);
- }
- /* finally calculate the area */
- area = area_poly_v3((const float(*)[3])vertexcos, (unsigned int)mpoly->totloop);
+ int i;
+ const MLoop *l_iter = loopstart;
+ float area;
+ float(*vertexcos)[3] = BLI_array_alloca(vertexcos, (size_t)mpoly->totloop);
- return area;
+ /* pack vertex cos into an array for area_poly_v3 */
+ for (i = 0; i < mpoly->totloop; i++, l_iter++) {
+ copy_v3_v3(vertexcos[i], mvarray[l_iter->v].co);
}
+
+ /* finally calculate the area */
+ area = area_poly_v3((const float(*)[3])vertexcos, (unsigned int)mpoly->totloop);
+
+ return area;
}
float BKE_mesh_calc_area(const Mesh *me)
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index 686f58a0ceb..3572939f78c 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -1047,10 +1047,9 @@ static bool mesh_check_island_boundary_uv(const MPoly *UNUSED(mp),
}
return false;
}
- else {
- /* Edge is UV boundary if tagged as seam. */
- return (me->flag & ME_SEAM) != 0;
- }
+
+ /* Edge is UV boundary if tagged as seam. */
+ return (me->flag & ME_SEAM) != 0;
}
static bool mesh_calc_islands_loop_poly_uv(MVert *UNUSED(verts),
diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c
index 1b9b8ea6572..ef28e9958fc 100644
--- a/source/blender/blenkernel/intern/mesh_merge.c
+++ b/source/blender/blenkernel/intern/mesh_merge.c
@@ -115,11 +115,10 @@ static int cddm_poly_compare(MLoop *mloop_array,
same_loops = true;
break; /* Polys are identical */
}
- else {
- compare_completed = true;
- same_loops = false;
- break; /* Polys are different */
- }
+
+ compare_completed = true;
+ same_loops = false;
+ break; /* Polys are different */
}
mloop_source++;
@@ -201,9 +200,8 @@ static bool poly_gset_compare_fn(const void *k1, const void *k2)
/* Equality - note that this does not mean equality of polys */
return false;
}
- else {
- return true;
- }
+
+ return true;
}
/**
@@ -412,7 +410,7 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
/* In this mode, all vertices merged is enough to dump face */
continue;
}
- else if (merge_mode == MESH_MERGE_VERTS_DUMP_IF_EQUAL) {
+ if (merge_mode == MESH_MERGE_VERTS_DUMP_IF_EQUAL) {
/* Additional condition for face dump: target vertices must make up an identical face */
/* The test has 2 steps: (1) first step is fast ghash lookup, but not failproof */
/* (2) second step is thorough but more costly poly compare */
@@ -578,7 +576,7 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
BLI_assert(created_edges == 0);
continue;
}
- else if (UNLIKELY(c < 3)) {
+ if (UNLIKELY(c < 3)) {
STACK_DISCARD(oldl, c);
STACK_DISCARD(mloop, c);
if (created_edges > 0) {
diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c
index d9be9a99b2b..46764a56e60 100644
--- a/source/blender/blenkernel/intern/mesh_mirror.c
+++ b/source/blender/blenkernel/intern/mesh_mirror.c
@@ -197,7 +197,7 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis(MirrorModifierData *mmd,
if (do_vtargetmap) {
/* second half is filled with -1 */
- vtargetmap = MEM_malloc_arrayN(maxVerts, 2 * sizeof(int), "MOD_mirror tarmap");
+ vtargetmap = MEM_malloc_arrayN(maxVerts, sizeof(int[2]), "MOD_mirror tarmap");
vtmap_a = vtargetmap;
vtmap_b = vtargetmap + maxVerts;
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index a4991675d2d..a8937f74dee 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -73,9 +73,8 @@ static bool mesh_remap_bvhtree_query_nearest(BVHTreeFromMesh *treedata,
*r_hit_dist = sqrtf(nearest->dist_sq);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
static bool mesh_remap_bvhtree_query_raycast(BVHTreeFromMesh *treedata,
@@ -107,9 +106,8 @@ static bool mesh_remap_bvhtree_query_raycast(BVHTreeFromMesh *treedata,
*r_hit_dist = rayhit->dist;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/** \} */
diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c
index 932423bc445..b9eb3876dde 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -43,8 +43,6 @@
/** \name Mesh Runtime Struct Utils
* \{ */
-static ThreadRWMutex loops_cache_lock = PTHREAD_RWLOCK_INITIALIZER;
-
/**
* Default values defined at read time.
*/
@@ -159,23 +157,21 @@ const MLoopTri *BKE_mesh_runtime_looptri_ensure(Mesh *mesh)
{
MLoopTri *looptri;
- BLI_rw_mutex_lock(&loops_cache_lock, THREAD_LOCK_READ);
+ ThreadMutex *mesh_eval_mutex = (ThreadMutex *)mesh->runtime.eval_mutex;
+ BLI_mutex_lock(mesh_eval_mutex);
+
looptri = mesh->runtime.looptris.array;
- BLI_rw_mutex_unlock(&loops_cache_lock);
if (looptri != NULL) {
BLI_assert(BKE_mesh_runtime_looptri_len(mesh) == mesh->runtime.looptris.len);
}
else {
- BLI_rw_mutex_lock(&loops_cache_lock, THREAD_LOCK_WRITE);
- /* We need to ensure array is still NULL inside mutex-protected code,
- * some other thread might have already recomputed those looptris. */
- if (mesh->runtime.looptris.array == NULL) {
- BKE_mesh_runtime_looptri_recalc(mesh);
- }
+ BKE_mesh_runtime_looptri_recalc(mesh);
looptri = mesh->runtime.looptris.array;
- BLI_rw_mutex_unlock(&loops_cache_lock);
}
+
+ BLI_mutex_unlock(mesh_eval_mutex);
+
return looptri;
}
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index f64ed609d18..338420641cf 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -111,7 +111,7 @@ static int int64_cmp(const void *v1, const void *v2)
if (x1 > x2) {
return 1;
}
- else if (x1 < x2) {
+ if (x1 < x2) {
return -1;
}
@@ -125,28 +125,28 @@ static int search_face_cmp(const void *v1, const void *v2)
if (sfa->es[0].edval > sfb->es[0].edval) {
return 1;
}
- else if (sfa->es[0].edval < sfb->es[0].edval) {
+ if (sfa->es[0].edval < sfb->es[0].edval) {
return -1;
}
- else if (sfa->es[1].edval > sfb->es[1].edval) {
+ if (sfa->es[1].edval > sfb->es[1].edval) {
return 1;
}
- else if (sfa->es[1].edval < sfb->es[1].edval) {
+ if (sfa->es[1].edval < sfb->es[1].edval) {
return -1;
}
- else if (sfa->es[2].edval > sfb->es[2].edval) {
+ if (sfa->es[2].edval > sfb->es[2].edval) {
return 1;
}
- else if (sfa->es[2].edval < sfb->es[2].edval) {
+ if (sfa->es[2].edval < sfb->es[2].edval) {
return -1;
}
- else if (sfa->es[3].edval > sfb->es[3].edval) {
+ if (sfa->es[3].edval > sfb->es[3].edval) {
return 1;
}
- else if (sfa->es[3].edval < sfb->es[3].edval) {
+ if (sfa->es[3].edval < sfb->es[3].edval) {
return -1;
}
@@ -214,6 +214,7 @@ static int search_polyloop_cmp(const void *v1, const void *v2)
*
* \return false if no changes needed to be made.
*/
+/* NOLINTNEXTLINE: readability-function-size */
bool BKE_mesh_validate_arrays(Mesh *mesh,
MVert *mverts,
unsigned int totvert,
@@ -547,6 +548,16 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
for (i = 0, mp = mpolys; i < totpoly; i++, mp++, sp++) {
sp->index = i;
+ /* Material index, isolated from other tests here. While large indices are clamped,
+ * negative indices aren't supported by drawing, exporters etc.
+ * To check the indices are in range, use #BKE_mesh_validate_material_indices */
+ if (mp->mat_nr < 0) {
+ PRINT_ERR("\tPoly %u has invalid material (%d)", sp->index, mp->mat_nr);
+ if (do_fixes) {
+ mp->mat_nr = 0;
+ }
+ }
+
if (mp->loopstart < 0 || mp->totloop < 3) {
/* Invalid loop data. */
PRINT_ERR("\tPoly %u is invalid (loopstart: %d, totloop: %d)",
@@ -1072,9 +1083,8 @@ bool BKE_mesh_validate(Mesh *me, const bool do_verbose, const bool cddata_check_
DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/**
@@ -1133,14 +1143,15 @@ bool BKE_mesh_is_valid(Mesh *me)
*/
bool BKE_mesh_validate_material_indices(Mesh *me)
{
+ /* Cast to unsigned to catch negative indices too. */
+ const uint16_t mat_nr_max = max_ii(0, me->totcol - 1);
MPoly *mp;
- const int max_idx = max_ii(0, me->totcol - 1);
const int totpoly = me->totpoly;
int i;
bool is_valid = true;
for (mp = me->mpoly, i = 0; i < totpoly; i++, mp++) {
- if (mp->mat_nr > max_idx) {
+ if ((uint16_t)mp->mat_nr > mat_nr_max) {
mp->mat_nr = 0;
is_valid = false;
}
@@ -1150,9 +1161,8 @@ bool BKE_mesh_validate_material_indices(Mesh *me)
DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/** \} */
@@ -1330,13 +1340,13 @@ static int vergedgesort(const void *v1, const void *v2)
if (x1->v1 > x2->v1) {
return 1;
}
- else if (x1->v1 < x2->v1) {
+ if (x1->v1 < x2->v1) {
return -1;
}
- else if (x1->v2 > x2->v2) {
+ if (x1->v2 > x2->v2) {
return 1;
}
- else if (x1->v2 < x2->v2) {
+ if (x1->v2 < x2->v2) {
return -1;
}
diff --git a/source/blender/blenkernel/intern/mesh_wrapper.c b/source/blender/blenkernel/intern/mesh_wrapper.c
index 6a8bc698b11..acd272ac305 100644
--- a/source/blender/blenkernel/intern/mesh_wrapper.c
+++ b/source/blender/blenkernel/intern/mesh_wrapper.c
@@ -40,6 +40,7 @@
#include "BLI_ghash.h"
#include "BLI_math.h"
+#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BKE_editmesh.h"
@@ -96,9 +97,14 @@ Mesh *BKE_mesh_wrapper_from_editmesh(BMEditMesh *em,
void BKE_mesh_wrapper_ensure_mdata(Mesh *me)
{
+ ThreadMutex *mesh_eval_mutex = (ThreadMutex *)me->runtime.eval_mutex;
+ BLI_mutex_lock(mesh_eval_mutex);
+
if (me->runtime.wrapper_type == ME_WRAPPER_TYPE_MDATA) {
+ BLI_mutex_unlock(mesh_eval_mutex);
return;
}
+
const eMeshWrapperType geom_type_orig = me->runtime.wrapper_type;
me->runtime.wrapper_type = ME_WRAPPER_TYPE_MDATA;
@@ -130,6 +136,8 @@ void BKE_mesh_wrapper_ensure_mdata(Mesh *me)
if (me->runtime.wrapper_type_finalize) {
BKE_mesh_wrapper_deferred_finalize(me, &me->runtime.cd_mask_extra);
}
+
+ BLI_mutex_unlock(mesh_eval_mutex);
}
bool BKE_mesh_wrapper_minmax(const Mesh *me, float min[3], float max[3])
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 327e8bfca7a..afd02d7001e 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -41,6 +41,7 @@
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
+#include "BLI_session_uuid.h"
#include "BLI_string.h"
#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
@@ -112,9 +113,8 @@ const ModifierTypeInfo *BKE_modifier_get_info(ModifierType type)
if (type < NUM_MODIFIER_TYPES && modifier_types[type] && modifier_types[type]->name[0] != '\0') {
return modifier_types[type];
}
- else {
- return NULL;
- }
+
+ return NULL;
}
/**
@@ -151,6 +151,8 @@ ModifierData *BKE_modifier_new(int type)
mti->initData(md);
}
+ BKE_modifier_session_uuid_generate(md);
+
return md;
}
@@ -193,6 +195,11 @@ void BKE_modifier_free(ModifierData *md)
BKE_modifier_free_ex(md, 0);
}
+void BKE_modifier_session_uuid_generate(ModifierData *md)
+{
+ md->session_uuid = BLI_session_uuid_generate();
+}
+
bool BKE_modifier_unique_name(ListBase *modifiers, ModifierData *md)
{
if (modifiers && md) {
@@ -369,6 +376,17 @@ void BKE_modifier_copydata_ex(ModifierData *md, ModifierData *target, const int
mti->foreachObjectLink(target, NULL, (ObjectWalkFunc)modifier_copy_data_id_us_cb, NULL);
}
}
+
+ if (flag & LIB_ID_CREATE_NO_MAIN) {
+ /* Make sure UUID is the same between the source and the target.
+ * This is needed in the cases when UUID is to be preserved and when there is no copyData
+ * callback, or the copyData does not do full byte copy of the modifier data. */
+ target->session_uuid = md->session_uuid;
+ }
+ else {
+ /* In the case copyData made full byte copy force UUID to be re-generated. */
+ BKE_modifier_session_uuid_generate(md);
+ }
}
void BKE_modifier_copydata(ModifierData *md, ModifierData *target)
@@ -919,11 +937,10 @@ const char *BKE_modifier_path_relbase(Main *bmain, Object *ob)
if (G.relbase_valid || ID_IS_LINKED(ob)) {
return ID_BLEND_PATH(bmain, &ob->id);
}
- else {
- /* last resort, better then using "" which resolves to the current
- * working directory */
- return BKE_tempdir_session();
- }
+
+ /* last resort, better then using "" which resolves to the current
+ * working directory */
+ return BKE_tempdir_session();
}
const char *BKE_modifier_path_relbase_from_global(Object *ob)
@@ -931,11 +948,10 @@ const char *BKE_modifier_path_relbase_from_global(Object *ob)
if (G.relbase_valid || ID_IS_LINKED(ob)) {
return ID_BLEND_PATH_FROM_GLOBAL(&ob->id);
}
- else {
- /* last resort, better then using "" which resolves to the current
- * working directory */
- return BKE_tempdir_session();
- }
+
+ /* last resort, better then using "" which resolves to the current
+ * working directory */
+ return BKE_tempdir_session();
}
/* initializes the path with either */
@@ -1074,3 +1090,26 @@ struct ModifierData *BKE_modifier_get_evaluated(Depsgraph *depsgraph,
}
return BKE_modifiers_findby_name(object_eval, md->name);
}
+
+void BKE_modifier_check_uuids_unique_and_report(const Object *object)
+{
+ struct GSet *used_uuids = BLI_gset_new(
+ BLI_session_uuid_ghash_hash, BLI_session_uuid_ghash_compare, "modifier used uuids");
+
+ LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
+ const SessionUUID *session_uuid = &md->session_uuid;
+ if (!BLI_session_uuid_is_generated(session_uuid)) {
+ printf("Modifier %s -> %s does not have UUID generated.\n", object->id.name + 2, md->name);
+ continue;
+ }
+
+ if (BLI_gset_lookup(used_uuids, session_uuid) != NULL) {
+ printf("Modifier %s -> %s has duplicate UUID generated.\n", object->id.name + 2, md->name);
+ continue;
+ }
+
+ BLI_gset_insert(used_uuids, (void *)session_uuid);
+ }
+
+ BLI_gset_free(used_uuids, NULL);
+}
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 4a65c6ff5e7..dcac7b01899 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -717,9 +717,8 @@ static bool put_imbuf_cache(
IMB_moviecache_put(clip->cache->moviecache, &key, ibuf);
return true;
}
- else {
- return IMB_moviecache_put_if_possible(clip->cache->moviecache, &key, ibuf);
- }
+
+ return IMB_moviecache_put_if_possible(clip->cache->moviecache, &key, ibuf);
}
static bool moviecache_check_free_proxy(ImBuf *UNUSED(ibuf), void *userkey, void *UNUSED(userdata))
@@ -1866,3 +1865,88 @@ void BKE_movieclip_eval_selection_update(struct Depsgraph *depsgraph, MovieClip
DEG_debug_print_eval(depsgraph, __func__, clip->id.name, clip);
movieclip_selection_sync(clip, (MovieClip *)clip->id.orig_id);
}
+
+/* -------------------------------------------------------------------- */
+/** \name GPU textures
+ * \{ */
+
+static GPUTexture **movieclip_get_gputexture_ptr(MovieClip *clip,
+ MovieClipUser *cuser,
+ eGPUTextureTarget textarget)
+{
+ /* Check if we have an existing entry for that clip user. */
+ MovieClip_RuntimeGPUTexture *tex;
+ for (tex = clip->runtime.gputextures.first; tex; tex = tex->next) {
+ if (memcmp(&tex->user, cuser, sizeof(MovieClipUser)) == 0) {
+ break;
+ }
+ }
+
+ /* If not, allocate a new one. */
+ if (tex == NULL) {
+ tex = (MovieClip_RuntimeGPUTexture *)MEM_mallocN(sizeof(MovieClip_RuntimeGPUTexture),
+ __func__);
+
+ for (int i = 0; i < TEXTARGET_COUNT; i++) {
+ tex->gputexture[i] = NULL;
+ }
+
+ memcpy(&tex->user, cuser, sizeof(MovieClipUser));
+ BLI_addtail(&clip->runtime.gputextures, tex);
+ }
+
+ return &tex->gputexture[textarget];
+}
+
+GPUTexture *BKE_movieclip_get_gpu_texture(MovieClip *clip, MovieClipUser *cuser)
+{
+ if (clip == NULL) {
+ return NULL;
+ }
+
+ GPUTexture **tex = movieclip_get_gputexture_ptr(clip, cuser, TEXTARGET_2D);
+ if (*tex) {
+ return *tex;
+ }
+
+ /* check if we have a valid image buffer */
+ ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, cuser);
+ if (ibuf == NULL) {
+ *tex = GPU_texture_create_error(2, false);
+ return *tex;
+ }
+
+ /* This only means RGBA16F instead of RGBA32F. */
+ const bool high_bitdepth = false;
+ const bool store_premultiplied = ibuf->rect_float ? false : true;
+ *tex = IMB_create_gpu_texture(ibuf, high_bitdepth, store_premultiplied);
+
+ /* Do not generate mips for movieclips... too slow. */
+ GPU_texture_mipmap_mode(*tex, false, true);
+
+ IMB_freeImBuf(ibuf);
+
+ return *tex;
+}
+
+void BKE_movieclip_free_gputexture(struct MovieClip *clip)
+{
+ /* number of gpu textures to keep around as cache
+ * We don't want to keep too many GPU textures for
+ * movie clips around, as they can be large.*/
+ const int MOVIECLIP_NUM_GPUTEXTURES = 1;
+
+ while (BLI_listbase_count(&clip->runtime.gputextures) > MOVIECLIP_NUM_GPUTEXTURES) {
+ MovieClip_RuntimeGPUTexture *tex = (MovieClip_RuntimeGPUTexture *)BLI_pophead(
+ &clip->runtime.gputextures);
+ for (int i = 0; i < TEXTARGET_COUNT; i++) {
+ /* free glsl image binding */
+ if (tex->gputexture[i]) {
+ GPU_texture_free(tex->gputexture[i]);
+ tex->gputexture[i] = NULL;
+ }
+ }
+ MEM_freeN(tex);
+ }
+}
+/** \} */
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 71d49dd1c19..6e1168d8a16 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -241,7 +241,7 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level)
md->hidden = subd;
}
-static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
+static MDisps *multires_mdisps_init_hidden(Mesh *me, int level)
{
MDisps *mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, CD_CALLOC, NULL, me->totloop);
int gridsize = BKE_ccg_gridsize(level);
@@ -407,15 +407,14 @@ int multires_get_level(const Scene *scene,
return (scene != NULL) ? get_render_subsurf_level(&scene->r, mmd->renderlvl, true) :
mmd->renderlvl;
}
- else if (ob->mode == OB_MODE_SCULPT) {
+ if (ob->mode == OB_MODE_SCULPT) {
return mmd->sculptlvl;
}
- else if (ignore_simplify) {
+ if (ignore_simplify) {
return mmd->lvl;
}
- else {
- return (scene != NULL) ? get_render_subsurf_level(&scene->r, mmd->lvl, false) : mmd->lvl;
- }
+
+ return (scene != NULL) ? get_render_subsurf_level(&scene->r, mmd->lvl, false) : mmd->lvl;
}
void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl)
@@ -553,7 +552,7 @@ static int get_levels_from_disps(Object *ob)
if (md->totdisp == lvl_totdisp) {
break;
}
- else if (md->totdisp < lvl_totdisp) {
+ if (md->totdisp < lvl_totdisp) {
totlvl--;
}
else {
@@ -609,7 +608,7 @@ static void multires_reallocate_mdisps(int totloop, MDisps *mdisps, int lvl)
/* reallocate displacements to be filled in */
for (i = 0; i < totloop; i++) {
int totdisp = multires_grid_tot[lvl];
- float(*disps)[3] = MEM_calloc_arrayN(totdisp, 3 * sizeof(float), "multires disps");
+ float(*disps)[3] = MEM_calloc_arrayN(totdisp, sizeof(float[3]), "multires disps");
if (mdisps[i].disps) {
MEM_freeN(mdisps[i].disps);
@@ -727,7 +726,7 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
float(*disps)[3], (*ndisps)[3], (*hdisps)[3];
int totdisp = multires_grid_tot[lvl];
- disps = MEM_calloc_arrayN(totdisp, 3 * sizeof(float), "multires disps");
+ disps = MEM_calloc_arrayN(totdisp, sizeof(float[3]), "multires disps");
if (mdisp->disps != NULL) {
ndisps = disps;
@@ -868,7 +867,7 @@ static void multires_subdivide_legacy(
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
if (!mdisps) {
- mdisps = multires_mdisps_initialize_hidden(me, totlvl);
+ mdisps = multires_mdisps_init_hidden(me, totlvl);
}
if (mdisps->disps && !updateblock && lvl != 0) {
@@ -1541,7 +1540,7 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
int x, y, S;
float(*disps)[3], (*out)[3], u = 0.0f, v = 0.0f; /* Quite gcc barking. */
- disps = MEM_calloc_arrayN(newtotdisp, 3 * sizeof(float), "multires disps");
+ disps = MEM_calloc_arrayN(newtotdisp, sizeof(float[3]), "multires disps");
out = disps;
for (S = 0; S < nvert; S++) {
@@ -1601,7 +1600,7 @@ void multires_load_old_250(Mesh *me)
for (j = 0; j < nvert; j++, k++) {
mdisps2[k].disps = MEM_calloc_arrayN(
- totdisp, 3 * sizeof(float), "multires disp in conversion");
+ totdisp, sizeof(float[3]), "multires disp in conversion");
mdisps2[k].totdisp = totdisp;
mdisps2[k].level = mdisps[i].level;
memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp * j, totdisp);
@@ -1673,7 +1672,7 @@ static void create_old_vert_face_map(ListBase **map,
IndexNode *node = NULL;
(*map) = MEM_calloc_arrayN(totvert, sizeof(ListBase), "vert face map");
- (*mem) = MEM_calloc_arrayN(totface, 4 * sizeof(IndexNode), "vert face map mem");
+ (*mem) = MEM_calloc_arrayN(totface, sizeof(IndexNode[4]), "vert face map mem");
node = *mem;
/* Find the users */
@@ -1695,7 +1694,7 @@ static void create_old_vert_edge_map(ListBase **map,
IndexNode *node = NULL;
(*map) = MEM_calloc_arrayN(totvert, sizeof(ListBase), "vert edge map");
- (*mem) = MEM_calloc_arrayN(totedge, 2 * sizeof(IndexNode), "vert edge map mem");
+ (*mem) = MEM_calloc_arrayN(totedge, sizeof(IndexNode[2]), "vert edge map mem");
node = *mem;
/* Find the users */
@@ -2377,7 +2376,7 @@ void multires_topology_changed(Mesh *me)
if (!mdisp->totdisp || !mdisp->disps) {
if (grid) {
mdisp->totdisp = grid;
- mdisp->disps = MEM_calloc_arrayN(3 * sizeof(float), mdisp->totdisp, "mdisp topology");
+ mdisp->disps = MEM_calloc_arrayN(sizeof(float[3]), mdisp->totdisp, "mdisp topology");
}
continue;
diff --git a/source/blender/blenkernel/intern/multires_inline.h b/source/blender/blenkernel/intern/multires_inline.h
index 3d00101ec29..49329698b3a 100644
--- a/source/blender/blenkernel/intern/multires_inline.h
+++ b/source/blender/blenkernel/intern/multires_inline.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __MULTIRES_INLINE_H__
-#define __MULTIRES_INLINE_H__
+#pragma once
#include "BKE_multires.h"
#include "BLI_math_vector.h"
@@ -57,5 +56,3 @@ BLI_INLINE void BKE_multires_construct_tangent_matrix(float tangent_matrix[3][3]
normalize_v3(tangent_matrix[1]);
normalize_v3(tangent_matrix[2]);
}
-
-#endif /* __MULTIRES_INLINE_H__ */
diff --git a/source/blender/blenkernel/intern/multires_reshape.h b/source/blender/blenkernel/intern/multires_reshape.h
index 12816a455ee..d6c1d79dfd7 100644
--- a/source/blender/blenkernel/intern/multires_reshape.h
+++ b/source/blender/blenkernel/intern/multires_reshape.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_INTERN_MULTIRES_RESHAPE_H__
-#define __BKE_INTERN_MULTIRES_RESHAPE_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -331,4 +330,3 @@ void multires_reshape_apply_base_refine_from_base(MultiresReshapeContext *reshap
*
* NOTE: Will re-evaluate all leading modifiers, so it's not cheap. */
void multires_reshape_apply_base_refine_from_deform(MultiresReshapeContext *reshape_context);
-#endif /* __BKE_INTERN_MULTIRES_RESHAPE_H__ */
diff --git a/source/blender/blenkernel/intern/multires_reshape_apply_base.c b/source/blender/blenkernel/intern/multires_reshape_apply_base.c
index 105e56e4219..6e7e2b90c05 100644
--- a/source/blender/blenkernel/intern/multires_reshape_apply_base.c
+++ b/source/blender/blenkernel/intern/multires_reshape_apply_base.c
@@ -72,7 +72,7 @@ void multires_reshape_apply_base_update_mesh_coords(MultiresReshapeContext *resh
/* Assumes no is normalized; return value's sign is negative if v is on the other side of the
* plane. */
-static float v3_dist_from_plane(float v[3], float center[3], float no[3])
+static float v3_dist_from_plane(const float v[3], const float center[3], const float no[3])
{
float s[3];
sub_v3_v3v3(s, v, center);
@@ -99,7 +99,7 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape
base_mesh->totloop);
float(*origco)[3] = MEM_calloc_arrayN(
- base_mesh->totvert, 3 * sizeof(float), "multires apply base origco");
+ base_mesh->totvert, sizeof(float[3]), "multires apply base origco");
for (int i = 0; i < base_mesh->totvert; i++) {
copy_v3_v3(origco[i], base_mesh->mvert[i].co);
}
@@ -140,7 +140,7 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape
fake_poly.totloop = p->totloop;
fake_poly.loopstart = 0;
fake_loops = MEM_malloc_arrayN(p->totloop, sizeof(MLoop), "fake_loops");
- fake_co = MEM_malloc_arrayN(p->totloop, 3 * sizeof(float), "fake_co");
+ fake_co = MEM_malloc_arrayN(p->totloop, sizeof(float[3]), "fake_co");
for (int k = 0; k < p->totloop; k++) {
const int vndx = base_mesh->mloop[p->loopstart + k].v;
diff --git a/source/blender/blenkernel/intern/multires_reshape_ccg.c b/source/blender/blenkernel/intern/multires_reshape_ccg.c
index 8273845e820..55f7766c878 100644
--- a/source/blender/blenkernel/intern/multires_reshape_ccg.c
+++ b/source/blender/blenkernel/intern/multires_reshape_ccg.c
@@ -58,7 +58,7 @@ bool multires_reshape_assign_final_coords_from_ccg(const MultiresReshapeContext
BLI_assert(grid_element.displacement != NULL);
memcpy(grid_element.displacement,
CCG_grid_elem_co(&reshape_level_key, ccg_grid, x, y),
- sizeof(float) * 3);
+ sizeof(float[3]));
if (reshape_level_key.has_mask) {
BLI_assert(grid_element.mask != NULL);
diff --git a/source/blender/blenkernel/intern/multires_reshape_util.c b/source/blender/blenkernel/intern/multires_reshape_util.c
index e9a779dafeb..c8179dd8a2d 100644
--- a/source/blender/blenkernel/intern/multires_reshape_util.c
+++ b/source/blender/blenkernel/intern/multires_reshape_util.c
@@ -522,7 +522,7 @@ static void allocate_displacement_grid(MDisps *displacement_grid, const int leve
{
const int grid_size = BKE_subdiv_grid_size_from_level(level);
const int grid_area = grid_size * grid_size;
- float(*disps)[3] = MEM_calloc_arrayN(grid_area, 3 * sizeof(float), "multires disps");
+ float(*disps)[3] = MEM_calloc_arrayN(grid_area, sizeof(float[3]), "multires disps");
if (displacement_grid->disps != NULL) {
MEM_freeN(displacement_grid->disps);
}
diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.c b/source/blender/blenkernel/intern/multires_unsubdivide.c
index fa1a53f946e..e3d670f7c39 100644
--- a/source/blender/blenkernel/intern/multires_unsubdivide.c
+++ b/source/blender/blenkernel/intern/multires_unsubdivide.c
@@ -111,7 +111,7 @@ static BMVert *unsubdivide_find_any_pole(BMesh *bm, int *elem_id, int elem)
if (is_vertex_in_id(v, elem_id, elem) && is_vertex_pole_three(v)) {
return v;
}
- else if (is_vertex_in_id(v, elem_id, elem) && is_vertex_pole(v)) {
+ if (is_vertex_in_id(v, elem_id, elem) && is_vertex_pole(v)) {
pole = v;
}
}
@@ -677,7 +677,7 @@ static void store_grid_data(MultiresUnsubdivideContext *context,
const int grid_size = BKE_ccg_gridsize(context->num_original_levels);
const int face_grid_size = BKE_ccg_gridsize(context->num_original_levels + 1);
const int face_grid_area = face_grid_size * face_grid_size;
- float(*face_grid)[3] = MEM_calloc_arrayN(face_grid_area, 3 * sizeof(float), "face_grid");
+ float(*face_grid)[3] = MEM_calloc_arrayN(face_grid_area, sizeof(float[3]), "face_grid");
for (int i = 0; i < poly->totloop; i++) {
const int loop_index = poly->loopstart + i;
@@ -731,7 +731,7 @@ static void multires_unsubdivide_extract_single_grid_from_face_edge(
const int unsubdiv_grid_size = grid->grid_size = BKE_ccg_gridsize(context->num_total_levels);
grid->grid_size = unsubdiv_grid_size;
grid->grid_co = MEM_calloc_arrayN(
- unsubdiv_grid_size * unsubdiv_grid_size, 3 * sizeof(float), "grids coordinates");
+ unsubdiv_grid_size * unsubdiv_grid_size, sizeof(float[3]), "grids coordinates");
/* Get the vertex on the corner of the grid. This vertex was tagged previously as it also exist
* on the base mesh. */
@@ -1198,7 +1198,7 @@ static void multires_create_grids_in_unsubdivided_base_mesh(MultiresUnsubdivideC
/* Allocate the MDISPS grids and copy the extracted data from context. */
for (int i = 0; i < totloop; i++) {
- float(*disps)[3] = MEM_calloc_arrayN(totdisp, 3 * sizeof(float), "multires disps");
+ float(*disps)[3] = MEM_calloc_arrayN(totdisp, sizeof(float[3]), "multires disps");
if (mdisps[i].disps) {
MEM_freeN(mdisps[i].disps);
diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.h b/source/blender/blenkernel/intern/multires_unsubdivide.h
index e00a1ae6d8b..39c6da0b6c8 100644
--- a/source/blender/blenkernel/intern/multires_unsubdivide.h
+++ b/source/blender/blenkernel/intern/multires_unsubdivide.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __BKE_INTERN_MULTIRES_UNSUBDIVIDE_H__
-#define __BKE_INTERN_MULTIRES_UNSUBDIVIDE_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -90,5 +89,3 @@ void multires_unsubdivide_context_free(MultiresUnsubdivideContext *context);
/* Rebuilds all subdivision to the level 0 base mesh. */
bool multires_unsubdivide_to_basemesh(MultiresUnsubdivideContext *context);
-
-#endif /* __BKE_INTERN_MULTIRES_UNSUBDIVIDE_H__ */
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 7012688686b..1ba82b352d1 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -480,46 +480,41 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short
if (mode == NLATIME_CONVERT_MAP) {
return strip->end - scale * (cframe - strip->actstart);
}
- else if (mode == NLATIME_CONVERT_UNMAP) {
+ if (mode == NLATIME_CONVERT_UNMAP) {
return (strip->end + (strip->actstart * scale - cframe)) / scale;
}
- else { /* if (mode == NLATIME_CONVERT_EVAL) */
- if (IS_EQF((float)cframe, strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
- /* This case prevents the motion snapping back to the first frame at the end of the strip
- * by catching the case where repeats is a whole number, which means that the end of the
- * strip could also be interpreted as the end of the start of a repeat. */
- return strip->actstart;
- }
- else {
- /* - the 'fmod(..., actlength * scale)' is needed to get the repeats working
- * - the '/ scale' is needed to ensure that scaling influences the timing within the repeat
- */
- return strip->actend - fmodf(cframe - strip->start, actlength * scale) / scale;
- }
+ /* if (mode == NLATIME_CONVERT_EVAL) */
+ if (IS_EQF((float)cframe, strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
+ /* This case prevents the motion snapping back to the first frame at the end of the strip
+ * by catching the case where repeats is a whole number, which means that the end of the
+ * strip could also be interpreted as the end of the start of a repeat. */
+ return strip->actstart;
}
+
+ /* - the 'fmod(..., actlength * scale)' is needed to get the repeats working
+ * - the '/ scale' is needed to ensure that scaling influences the timing within the repeat
+ */
+ return strip->actend - fmodf(cframe - strip->start, actlength * scale) / scale;
}
- else {
- if (mode == NLATIME_CONVERT_MAP) {
- return strip->start + scale * (cframe - strip->actstart);
- }
- else if (mode == NLATIME_CONVERT_UNMAP) {
- return strip->actstart + (cframe - strip->start) / scale;
- }
- else { /* if (mode == NLATIME_CONVERT_EVAL) */
- if (IS_EQF(cframe, strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
- /* This case prevents the motion snapping back to the first frame at the end of the strip
- * by catching the case where repeats is a whole number, which means that the end of the
- * strip could also be interpreted as the end of the start of a repeat. */
- return strip->actend;
- }
- else {
- /* - the 'fmod(..., actlength * scale)' is needed to get the repeats working
- * - the '/ scale' is needed to ensure that scaling influences the timing within the repeat
- */
- return strip->actstart + fmodf(cframe - strip->start, actlength * scale) / scale;
- }
- }
+
+ if (mode == NLATIME_CONVERT_MAP) {
+ return strip->start + scale * (cframe - strip->actstart);
+ }
+ if (mode == NLATIME_CONVERT_UNMAP) {
+ return strip->actstart + (cframe - strip->start) / scale;
+ }
+ /* if (mode == NLATIME_CONVERT_EVAL) */
+ if (IS_EQF(cframe, strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
+ /* This case prevents the motion snapping back to the first frame at the end of the strip
+ * by catching the case where repeats is a whole number, which means that the end of the
+ * strip could also be interpreted as the end of the start of a repeat. */
+ return strip->actend;
}
+
+ /* - the 'fmod(..., actlength * scale)' is needed to get the repeats working
+ * - the '/ scale' is needed to ensure that scaling influences the timing within the repeat
+ */
+ return strip->actstart + fmodf(cframe - strip->start, actlength * scale) / scale;
}
/* non clipped mapping for strip-time <-> global time (for Transitions)
@@ -537,18 +532,15 @@ static float nlastrip_get_frame_transition(NlaStrip *strip, float cframe, short
if (mode == NLATIME_CONVERT_MAP) {
return strip->end - (length * cframe);
}
- else {
- return (strip->end - cframe) / length;
- }
+
+ return (strip->end - cframe) / length;
}
- else {
- if (mode == NLATIME_CONVERT_MAP) {
- return (length * cframe) + strip->start;
- }
- else {
- return (cframe - strip->start) / length;
- }
+
+ if (mode == NLATIME_CONVERT_MAP) {
+ return (length * cframe) + strip->start;
}
+
+ return (cframe - strip->start) / length;
}
/* non clipped mapping for strip-time <-> global time
@@ -882,11 +874,10 @@ bool BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
return true;
}
- else { /* failed... no room before */
- return false;
- }
+ /* failed... no room before */
+ return false;
}
- else if (strip->end > mstrip->end) {
+ if (strip->end > mstrip->end) {
/* check if strip to the right (if it exists) starts before the
* end of the strip we're trying to add
*/
@@ -897,14 +888,12 @@ bool BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
return true;
}
- else { /* failed... no room after */
- return false;
- }
- }
- else {
- /* just try to add to the meta-strip (no dimension changes needed) */
- return BKE_nlastrips_add_strip(&mstrip->strips, strip);
+ /* failed... no room after */
+ return false;
}
+
+ /* just try to add to the meta-strip (no dimension changes needed) */
+ return BKE_nlastrips_add_strip(&mstrip->strips, strip);
}
/* Adjust the settings of NLA-Strips contained within a Meta-Strip (recursively),
@@ -1034,7 +1023,7 @@ NlaTrack *BKE_nlatrack_find_tweaked(AnimData *adt)
if (BLI_findindex(&nlt->strips, adt->actstrip) != -1) {
return nlt;
}
- else if (G.debug & G_DEBUG) {
+ if (G.debug & G_DEBUG) {
printf("%s: Active strip (%p, %s) not in NLA track found (%p, %s)\n",
__func__,
adt->actstrip,
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 8d7cb90fb71..a89285a28c1 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1266,9 +1266,8 @@ bNode *nodeFindRootParent(bNode *node)
if (node->parent) {
return nodeFindRootParent(node->parent);
}
- else {
- return node->type == NODE_FRAME ? node : NULL;
- }
+
+ return node->type == NODE_FRAME ? node : NULL;
}
/**
@@ -1280,7 +1279,7 @@ bool nodeIsChildOf(const bNode *parent, const bNode *child)
if (parent == child) {
return true;
}
- else if (child->parent) {
+ if (child->parent) {
return nodeIsChildOf(parent, child->parent);
}
return false;
@@ -1339,9 +1338,8 @@ static void iter_backwards_ex(const bNodeTree *ntree,
if (link->fromnode->iter_flag & recursion_mask) {
continue;
}
- else {
- link->fromnode->iter_flag |= recursion_mask;
- }
+
+ link->fromnode->iter_flag |= recursion_mask;
if (!callback(link->fromnode, link->tonode, userdata)) {
return;
@@ -1919,7 +1917,7 @@ bNodePreview *BKE_node_preview_verify(
}
if (preview->rect == NULL) {
- preview->rect = MEM_callocN(4 * xsize + xsize * ysize * sizeof(char) * 4, "node preview rect");
+ preview->rect = MEM_callocN(4 * xsize + xsize * ysize * sizeof(char[4]), "node preview rect");
preview->xsize = xsize;
preview->ysize = ysize;
}
@@ -2057,7 +2055,7 @@ static void node_preview_sync(bNodePreview *to, bNodePreview *from)
if (to->rect && from->rect) {
int xsize = to->xsize;
int ysize = to->ysize;
- memcpy(to->rect, from->rect, xsize * ysize * sizeof(char) * 4);
+ memcpy(to->rect, from->rect, xsize * ysize * sizeof(char[4]));
}
}
@@ -2582,9 +2580,8 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
return ltree;
}
- else {
- return NULL;
- }
+
+ return NULL;
}
/* sync local composite with real tree */
@@ -2989,9 +2986,8 @@ bNode *nodeGetActiveID(bNodeTree *ntree, short idtype)
return node_get_active_id_recursive(
ntree->active_viewer_key, NODE_INSTANCE_KEY_BASE, ntree, idtype);
}
- else {
- return NULL;
- }
+
+ return NULL;
}
bool nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
@@ -3127,9 +3123,8 @@ int nodeSocketLinkLimit(struct bNodeSocket *sock)
int limit = (sock->in_out == SOCK_IN) ? stype->input_link_limit : stype->output_link_limit;
return limit;
}
- else {
- return sock->limit;
- }
+
+ return sock->limit;
}
/* ************** Node Clipboard *********** */
@@ -3419,9 +3414,8 @@ bool BKE_node_instance_hash_tag_key(bNodeInstanceHash *hash, bNodeInstanceKey ke
entry->tag = 1;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash,
@@ -3835,6 +3829,7 @@ static bool node_poll_instance_default(bNode *node, bNodeTree *ntree)
return node->typeinfo->poll(node->typeinfo, ntree);
}
+/* NOLINTNEXTLINE: readability-function-size */
void node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
{
/* Use static type info header to map static int type to identifier string and RNA struct type.
@@ -4352,6 +4347,8 @@ static void registerSimulationNodes(void)
register_node_type_sim_emit_particles();
register_node_type_sim_time();
register_node_type_sim_particle_attribute();
+ register_node_type_sim_age_reached_event();
+ register_node_type_sim_kill_particle();
}
static void registerFunctionNodes(void)
@@ -4362,6 +4359,7 @@ static void registerFunctionNodes(void)
register_node_type_fn_group_instance_id();
register_node_type_fn_combine_strings();
register_node_type_fn_object_transforms();
+ register_node_type_fn_random_float();
}
void init_nodesystem(void)
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index f77c79a2be7..31420b3adc6 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -666,14 +666,14 @@ bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type)
if (ob->type == OB_HAIR) {
return (mti->modifyHair != NULL) || (mti->flags & eModifierTypeFlag_AcceptsVertexCosOnly);
}
- else if (ob->type == OB_POINTCLOUD) {
+ if (ob->type == OB_POINTCLOUD) {
return (mti->modifyPointCloud != NULL) ||
(mti->flags & eModifierTypeFlag_AcceptsVertexCosOnly);
}
- else if (ob->type == OB_VOLUME) {
+ if (ob->type == OB_VOLUME) {
return (mti->modifyVolume != NULL);
}
- else if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
+ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
if (ob->type == OB_LATTICE && (mti->flags & eModifierTypeFlag_AcceptsVertexCosOnly) == 0) {
return false;
}
@@ -1597,9 +1597,8 @@ bool BKE_object_pose_context_check(const Object *ob)
if ((ob) && (ob->type == OB_ARMATURE) && (ob->pose) && (ob->mode & OB_MODE_POSE)) {
return true;
}
- else {
- return false;
- }
+
+ return false;
}
Object *BKE_object_pose_armature_get(Object *ob)
@@ -2344,7 +2343,7 @@ void BKE_object_tfm_copy(Object *object_dst, const Object *object_src)
#undef TFMCPY4D
}
-void BKE_object_to_mat3(Object *ob, float mat[3][3]) /* no parent */
+void BKE_object_to_mat3(Object *ob, float r_mat[3][3]) /* no parent */
{
float smat[3][3];
float rmat[3][3];
@@ -2355,38 +2354,38 @@ void BKE_object_to_mat3(Object *ob, float mat[3][3]) /* no parent */
/* rot */
BKE_object_rot_to_mat3(ob, rmat, true);
- mul_m3_m3m3(mat, rmat, smat);
+ mul_m3_m3m3(r_mat, rmat, smat);
}
-void BKE_object_to_mat4(Object *ob, float mat[4][4])
+void BKE_object_to_mat4(Object *ob, float r_mat[4][4])
{
float tmat[3][3];
BKE_object_to_mat3(ob, tmat);
- copy_m4_m3(mat, tmat);
+ copy_m4_m3(r_mat, tmat);
- add_v3_v3v3(mat[3], ob->loc, ob->dloc);
+ add_v3_v3v3(r_mat[3], ob->loc, ob->dloc);
}
-void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4])
+void BKE_object_matrix_local_get(struct Object *ob, float r_mat[4][4])
{
if (ob->parent) {
float par_imat[4][4];
BKE_object_get_parent_matrix(ob, ob->parent, par_imat);
invert_m4(par_imat);
- mul_m4_m4m4(mat, par_imat, ob->obmat);
+ mul_m4_m4m4(r_mat, par_imat, ob->obmat);
}
else {
- copy_m4_m4(mat, ob->obmat);
+ copy_m4_m4(r_mat, ob->obmat);
}
}
/**
* \return success if \a mat is set.
*/
-static bool ob_parcurve(Object *ob, Object *par, float mat[4][4])
+static bool ob_parcurve(Object *ob, Object *par, float r_mat[4][4])
{
Curve *cu = par->data;
float vec[4], dir[3], quat[4], radius, ctime;
@@ -2420,34 +2419,34 @@ static bool ob_parcurve(Object *ob, Object *par, float mat[4][4])
}
CLAMP(ctime, 0.0f, 1.0f);
- unit_m4(mat);
+ unit_m4(r_mat);
/* vec: 4 items! */
if (where_on_path(par, ctime, vec, dir, (cu->flag & CU_FOLLOW) ? quat : NULL, &radius, NULL)) {
if (cu->flag & CU_FOLLOW) {
quat_apply_track(quat, ob->trackflag, ob->upflag);
normalize_qt(quat);
- quat_to_mat4(mat, quat);
+ quat_to_mat4(r_mat, quat);
}
if (cu->flag & CU_PATH_RADIUS) {
float tmat[4][4], rmat[4][4];
scale_m4_fl(tmat, radius);
- mul_m4_m4m4(rmat, tmat, mat);
- copy_m4_m4(mat, rmat);
+ mul_m4_m4m4(rmat, tmat, r_mat);
+ copy_m4_m4(r_mat, rmat);
}
- copy_v3_v3(mat[3], vec);
+ copy_v3_v3(r_mat[3], vec);
}
return true;
}
-static void ob_parbone(Object *ob, Object *par, float mat[4][4])
+static void ob_parbone(Object *ob, Object *par, float r_mat[4][4])
{
bPoseChannel *pchan;
float vec[3];
if (par->type != OB_ARMATURE) {
- unit_m4(mat);
+ unit_m4(r_mat);
return;
}
@@ -2456,7 +2455,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[4][4])
if (!pchan || !pchan->bone) {
CLOG_ERROR(
&LOG, "Object %s with Bone parent: bone %s doesn't exist", ob->id.name + 2, ob->parsubstr);
- unit_m4(mat);
+ unit_m4(r_mat);
return;
}
@@ -2464,15 +2463,15 @@ static void ob_parbone(Object *ob, Object *par, float mat[4][4])
if (pchan->bone->flag & BONE_RELATIVE_PARENTING) {
/* the new option uses the root - expected behavior, but differs from old... */
/* XXX check on version patching? */
- copy_m4_m4(mat, pchan->chan_mat);
+ copy_m4_m4(r_mat, pchan->chan_mat);
}
else {
- copy_m4_m4(mat, pchan->pose_mat);
+ copy_m4_m4(r_mat, pchan->pose_mat);
/* but for backwards compatibility, the child has to move to the tail */
- copy_v3_v3(vec, mat[1]);
+ copy_v3_v3(vec, r_mat[1]);
mul_v3_fl(vec, pchan->bone->length);
- add_v3_v3(mat[3], vec);
+ add_v3_v3(r_mat[3], vec);
}
}
@@ -2594,7 +2593,7 @@ static void give_parvert(Object *par, int nr, float vec[3])
}
}
-static void ob_parvert3(Object *ob, Object *par, float mat[4][4])
+static void ob_parvert3(Object *ob, Object *par, float r_mat[4][4])
{
/* in local ob space */
@@ -2607,16 +2606,16 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4])
tri_to_quat(q, v1, v2, v3);
quat_to_mat3(cmat, q);
- copy_m4_m3(mat, cmat);
+ copy_m4_m3(r_mat, cmat);
- mid_v3_v3v3v3(mat[3], v1, v2, v3);
+ mid_v3_v3v3v3(r_mat[3], v1, v2, v3);
}
else {
- unit_m4(mat);
+ unit_m4(r_mat);
}
}
-void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4])
+void BKE_object_get_parent_matrix(Object *ob, Object *par, float r_parentmat[4][4])
{
float tmat[4][4];
float vec[3];
@@ -2632,31 +2631,31 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4]
}
if (ok) {
- mul_m4_m4m4(parentmat, par->obmat, tmat);
+ mul_m4_m4m4(r_parentmat, par->obmat, tmat);
}
else {
- copy_m4_m4(parentmat, par->obmat);
+ copy_m4_m4(r_parentmat, par->obmat);
}
break;
case PARBONE:
ob_parbone(ob, par, tmat);
- mul_m4_m4m4(parentmat, par->obmat, tmat);
+ mul_m4_m4m4(r_parentmat, par->obmat, tmat);
break;
case PARVERT1:
- unit_m4(parentmat);
+ unit_m4(r_parentmat);
give_parvert(par, ob->par1, vec);
- mul_v3_m4v3(parentmat[3], par->obmat, vec);
+ mul_v3_m4v3(r_parentmat[3], par->obmat, vec);
break;
case PARVERT3:
ob_parvert3(ob, par, tmat);
- mul_m4_m4m4(parentmat, par->obmat, tmat);
+ mul_m4_m4m4(r_parentmat, par->obmat, tmat);
break;
case PARSKEL:
- copy_m4_m4(parentmat, par->obmat);
+ copy_m4_m4(r_parentmat, par->obmat);
break;
}
}
@@ -2672,7 +2671,7 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4]
* (without its own matrix applied)
*/
static void solve_parenting(
- Object *ob, Object *par, float obmat[4][4], float r_originmat[3][3], const bool set_origin)
+ Object *ob, Object *par, const bool set_origin, float r_obmat[4][4], float r_originmat[3][3])
{
float totmat[4][4];
float tmat[4][4];
@@ -2684,7 +2683,7 @@ static void solve_parenting(
/* total */
mul_m4_m4m4(tmat, totmat, ob->parentinv);
- mul_m4_m4m4(obmat, tmat, locmat);
+ mul_m4_m4m4(r_obmat, tmat, locmat);
if (r_originmat) {
/* usable originmat */
@@ -2714,7 +2713,7 @@ static void object_where_is_calc_ex(Depsgraph *depsgraph,
Object *par = ob->parent;
/* calculate parent matrix */
- solve_parenting(ob, par, ob->obmat, r_originmat, true);
+ solve_parenting(ob, par, true, ob->obmat, r_originmat);
}
else {
BKE_object_to_mat4(ob, ob->obmat);
@@ -2757,14 +2756,14 @@ void BKE_object_where_is_calc_time(Depsgraph *depsgraph, Scene *scene, Object *o
* constraints -- assume dependencies are already solved by depsgraph.
* no changes to object and it's parent would be done.
* used for bundles orientation in 3d space relative to parented blender camera */
-void BKE_object_where_is_calc_mat4(Object *ob, float obmat[4][4])
+void BKE_object_where_is_calc_mat4(Object *ob, float r_obmat[4][4])
{
if (ob->parent) {
Object *par = ob->parent;
- solve_parenting(ob, par, obmat, NULL, false);
+ solve_parenting(ob, par, false, r_obmat, NULL);
}
else {
- BKE_object_to_mat4(ob, obmat);
+ BKE_object_to_mat4(ob, r_obmat);
}
}
@@ -2825,8 +2824,11 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o
* \param use_compat: true to ensure that rotations are set using the
* min difference between the old and new orientation.
*/
-void BKE_object_apply_mat4_ex(
- Object *ob, float mat[4][4], Object *parent, float parentinv[4][4], const bool use_compat)
+void BKE_object_apply_mat4_ex(Object *ob,
+ const float mat[4][4],
+ Object *parent,
+ const float parentinv[4][4],
+ const bool use_compat)
{
/* see BKE_pchan_apply_mat4() for the equivalent 'pchan' function */
@@ -2867,7 +2869,7 @@ void BKE_object_apply_mat4_ex(
/* XXX: should be removed after COW operators port to use BKE_object_apply_mat4_ex directly */
void BKE_object_apply_mat4(Object *ob,
- float mat[4][4],
+ const float mat[4][4],
const bool use_compat,
const bool use_parent)
{
@@ -2917,7 +2919,10 @@ void BKE_boundbox_calc_size_aabb(const BoundBox *bb, float r_size[3])
r_size[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]);
}
-void BKE_boundbox_minmax(const BoundBox *bb, float obmat[4][4], float r_min[3], float r_max[3])
+void BKE_boundbox_minmax(const BoundBox *bb,
+ const float obmat[4][4],
+ float r_min[3],
+ float r_max[3])
{
int i;
for (i = 0; i < 8; i++) {
@@ -3009,7 +3014,7 @@ void BKE_object_boundbox_calc_from_mesh(struct Object *ob, struct Mesh *me_eval)
* \warning Setting dimensions is prone to feedback loops in evaluation.
* \{ */
-void BKE_object_dimensions_get(Object *ob, float vec[3])
+void BKE_object_dimensions_get(Object *ob, float r_vec[3])
{
BoundBox *bb = NULL;
@@ -3019,12 +3024,12 @@ void BKE_object_dimensions_get(Object *ob, float vec[3])
mat4_to_size(scale, ob->obmat);
- vec[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
- vec[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
- vec[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
+ r_vec[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
+ r_vec[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
+ r_vec[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
}
else {
- zero_v3(vec);
+ zero_v3(r_vec);
}
}
@@ -3201,9 +3206,8 @@ bool BKE_object_empty_image_frame_is_visible_in_view3d(const Object *ob, const R
if (rv3d->is_persp) {
return (visibility_flag & OB_EMPTY_IMAGE_HIDE_PERSPECTIVE) == 0;
}
- else {
- return (visibility_flag & OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC) == 0;
- }
+
+ return (visibility_flag & OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC) == 0;
}
bool BKE_object_empty_image_data_is_visible_in_view3d(const Object *ob, const RegionView3D *rv3d)
@@ -3263,37 +3267,36 @@ bool BKE_object_minmax_dupli(Depsgraph *depsgraph,
if ((ob->transflag & OB_DUPLI) == 0) {
return ok;
}
- else {
- ListBase *lb;
- DupliObject *dob;
- lb = object_duplilist(depsgraph, scene, ob);
- for (dob = lb->first; dob; dob = dob->next) {
- if ((use_hidden == false) && (dob->no_draw != 0)) {
- /* pass */
- }
- else {
- BoundBox *bb = BKE_object_boundbox_get(dob->ob);
-
- if (bb) {
- int i;
- for (i = 0; i < 8; i++) {
- float vec[3];
- mul_v3_m4v3(vec, dob->mat, bb->vec[i]);
- minmax_v3v3_v3(r_min, r_max, vec);
- }
- ok = true;
+ ListBase *lb;
+ DupliObject *dob;
+ lb = object_duplilist(depsgraph, scene, ob);
+ for (dob = lb->first; dob; dob = dob->next) {
+ if ((use_hidden == false) && (dob->no_draw != 0)) {
+ /* pass */
+ }
+ else {
+ BoundBox *bb = BKE_object_boundbox_get(dob->ob);
+
+ if (bb) {
+ int i;
+ for (i = 0; i < 8; i++) {
+ float vec[3];
+ mul_v3_m4v3(vec, dob->mat, bb->vec[i]);
+ minmax_v3v3_v3(r_min, r_max, vec);
}
+
+ ok = true;
}
}
- free_object_duplilist(lb); /* does restore */
}
+ free_object_duplilist(lb); /* does restore */
return ok;
}
void BKE_object_foreach_display_point(Object *ob,
- float obmat[4][4],
+ const float obmat[4][4],
void (*func_cb)(const float[3], void *),
void *user_data)
{
@@ -3630,9 +3633,8 @@ static int pc_cmp(const void *a, const void *b)
if (POINTER_AS_INT(ad->data) > POINTER_AS_INT(bd->data)) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
int BKE_object_insert_ptcache(Object *ob)
@@ -3911,12 +3913,11 @@ bool BKE_object_flag_test_recursive(const Object *ob, short flag)
if (ob->flag & flag) {
return true;
}
- else if (ob->parent) {
+ if (ob->parent) {
return BKE_object_flag_test_recursive(ob->parent, flag);
}
- else {
- return false;
- }
+
+ return false;
}
bool BKE_object_is_child_recursive(const Object *ob_parent, const Object *ob_child)
@@ -4023,15 +4024,15 @@ static bool constructive_modifier_is_deform_modified(ModifierData *md)
(amd->curve_ob != NULL && object_moves_in_time(amd->curve_ob)) ||
(amd->offset_ob != NULL && object_moves_in_time(amd->offset_ob));
}
- else if (md->type == eModifierType_Mirror) {
+ if (md->type == eModifierType_Mirror) {
MirrorModifierData *mmd = (MirrorModifierData *)md;
return mmd->mirror_ob != NULL && object_moves_in_time(mmd->mirror_ob);
}
- else if (md->type == eModifierType_Screw) {
+ if (md->type == eModifierType_Screw) {
ScrewModifierData *smd = (ScrewModifierData *)md;
return smd->ob_axis != NULL && object_moves_in_time(smd->ob_axis);
}
- else if (md->type == eModifierType_MeshSequenceCache) {
+ if (md->type == eModifierType_MeshSequenceCache) {
/* NOTE: Not ideal because it's unknown whether topology changes or not.
* This will be detected later, so by assuming it's only deformation
* going on here we allow to bake deform-only mesh to Alembic and have
@@ -4713,3 +4714,9 @@ void BKE_object_to_mesh_clear(Object *object)
BKE_id_free(NULL, object->runtime.object_as_temp_mesh);
object->runtime.object_as_temp_mesh = NULL;
}
+
+void BKE_object_check_uuids_unique_and_report(const Object *object)
+{
+ BKE_pose_check_uuids_unique_and_report(object->pose);
+ BKE_modifier_check_uuids_unique_and_report(object);
+}
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index 51ec89cf77d..04f7529c6cd 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -145,7 +145,7 @@ MDeformVert *BKE_object_defgroup_data_create(ID *id)
me->dvert = CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, me->totvert);
return me->dvert;
}
- else if (GS(id->name) == ID_LT) {
+ if (GS(id->name) == ID_LT) {
Lattice *lt = (Lattice *)id;
lt->dvert = MEM_callocN(sizeof(MDeformVert) * lt->pntsu * lt->pntsv * lt->pntsw,
"lattice deformVert");
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 413acde62d5..de14d2ceff6 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -37,6 +37,7 @@
#include "DNA_collection_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_vfont_types.h"
@@ -61,7 +62,9 @@
#include "BLI_hash.h"
#include "BLI_strict_flags.h"
-/* Dupli-Geometry */
+/* -------------------------------------------------------------------- */
+/** \name Internal Duplicate Context
+ * \{ */
typedef struct DupliContext {
Depsgraph *depsgraph;
@@ -91,7 +94,9 @@ typedef struct DupliGenerator {
static const DupliGenerator *get_dupli_generator(const DupliContext *ctx);
-/* create initial context for root object */
+/**
+ * Create initial context for root object.
+ */
static void init_context(DupliContext *r_ctx,
Depsgraph *depsgraph,
Scene *scene,
@@ -118,7 +123,9 @@ static void init_context(DupliContext *r_ctx,
r_ctx->duplilist = NULL;
}
-/* create sub-context for recursive duplis */
+/**
+ * Create sub-context for recursive duplis.
+ */
static void copy_dupli_context(
DupliContext *r_ctx, const DupliContext *ctx, Object *ob, const float mat[4][4], int index)
{
@@ -140,10 +147,15 @@ static void copy_dupli_context(
r_ctx->gen = get_dupli_generator(r_ctx);
}
-/* generate a dupli instance
- * mat is transform of the object relative to current context (including object obmat)
+/**
+ * Generate a dupli instance.
+ *
+ * \param mat: is transform of the object relative to current context (including #Object.obmat).
*/
-static DupliObject *make_dupli(const DupliContext *ctx, Object *ob, float mat[4][4], int index)
+static DupliObject *make_dupli(const DupliContext *ctx,
+ Object *ob,
+ const float mat[4][4],
+ int index)
{
DupliObject *dob;
int i;
@@ -201,8 +213,10 @@ static DupliObject *make_dupli(const DupliContext *ctx, Object *ob, float mat[4]
return dob;
}
-/* recursive dupli objects
- * space_mat is the local dupli space (excluding dupli object obmat!)
+/**
+ * Recursive dupli objects.
+ *
+ * \param space_mat: is the local dupli space (excluding dupli #Object.obmat).
*/
static void make_recursive_duplis(const DupliContext *ctx,
Object *ob,
@@ -219,7 +233,11 @@ static void make_recursive_duplis(const DupliContext *ctx,
}
}
-/* ---- Child Duplis ---- */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Internal Child Duplicates (Used by Other Functions)
+ * \{ */
typedef void (*MakeChildDuplisFunc)(const DupliContext *ctx, void *userdata, Object *child);
@@ -235,7 +253,9 @@ static bool is_child(const Object *ob, const Object *parent)
return false;
}
-/* create duplis from every child in scene or collection */
+/**
+ * Create duplis from every child in scene or collection.
+ */
static void make_child_duplis(const DupliContext *ctx,
void *userdata,
MakeChildDuplisFunc make_child_duplis_cb)
@@ -278,9 +298,12 @@ static void make_child_duplis(const DupliContext *ctx,
}
}
-/*---- Implementations ----*/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Dupli-Collection Implementation (#OB_DUPLICOLLECTION)
+ * \{ */
-/* OB_DUPLICOLLECTION */
static void make_duplis_collection(const DupliContext *ctx)
{
Object *ob = ctx->object;
@@ -320,7 +343,12 @@ static const DupliGenerator gen_dupli_collection = {
make_duplis_collection /* make_duplis */
};
-/* OB_DUPLIVERTS */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Dupli-Vertices Implementation (#OB_DUPLIVERTS for Geometry)
+ * \{ */
+
typedef struct VertexDupliData {
Mesh *me_eval;
BMEditMesh *edit_mesh;
@@ -446,7 +474,12 @@ static const DupliGenerator gen_dupli_verts = {
make_duplis_verts /* make_duplis */
};
-/* OB_DUPLIVERTS - FONT */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Dupli-Vertices Implementation (#OB_DUPLIVERTS for 3D Text)
+ * \{ */
+
static Object *find_family_object(
Main *bmain, const char *family, size_t family_len, unsigned int ch, GHash *family_gh)
{
@@ -573,7 +606,74 @@ static const DupliGenerator gen_dupli_verts_font = {
make_duplis_font /* make_duplis */
};
-/* OB_DUPLIFACES */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Dupli-Vertices Implementation (#OB_DUPLIVERTS for #PointCloud)
+ * \{ */
+
+static void make_child_duplis_pointcloud(const DupliContext *ctx,
+ void *UNUSED(userdata),
+ Object *child)
+{
+ const Object *parent = ctx->object;
+ const PointCloud *pointcloud = parent->data;
+ const float(*co)[3] = pointcloud->co;
+ const float *radius = pointcloud->radius;
+ const float(*rotation)[4] = NULL; /* TODO: add optional rotation attribute. */
+ const float(*orco)[3] = NULL; /* TODO: add optional texture coordinate attribute. */
+
+ /* Relative transform from parent to child space. */
+ float child_imat[4][4];
+ mul_m4_m4m4(child_imat, child->imat, parent->obmat);
+
+ for (int i = 0; i < pointcloud->totpoint; i++) {
+ /* Transform matrix from point position, radius and rotation. */
+ float quat[4] = {1.0f, 0.0f, 0.0f, 0.0f};
+ float size[3] = {1.0f, 1.0f, 1.0f};
+ if (radius) {
+ copy_v3_fl(size, radius[i]);
+ }
+ if (rotation) {
+ copy_v4_v4(quat, rotation[i]);
+ }
+
+ float space_mat[4][4];
+ loc_quat_size_to_mat4(space_mat, co[i], quat, size);
+
+ /* Make offset relative to child object using relative child transform,
+ * and apply object matrix after local vertex transform. */
+ mul_mat3_m4_v3(child_imat, space_mat[3]);
+
+ /* Create dupli object. */
+ float obmat[4][4];
+ mul_m4_m4m4(obmat, child->obmat, space_mat);
+ DupliObject *dob = make_dupli(ctx, child, obmat, i);
+ if (orco) {
+ copy_v3_v3(dob->orco, orco[i]);
+ }
+
+ /* Recursion. */
+ make_recursive_duplis(ctx, child, space_mat, i);
+ }
+}
+
+static void make_duplis_pointcloud(const DupliContext *ctx)
+{
+ make_child_duplis(ctx, NULL, make_child_duplis_pointcloud);
+}
+
+static const DupliGenerator gen_dupli_verts_pointcloud = {
+ OB_DUPLIVERTS, /* type */
+ make_duplis_pointcloud /* make_duplis */
+};
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Dupli-Faces Implementation (#OB_DUPLIFACES)
+ * \{ */
+
typedef struct FaceDupliData {
Mesh *me_eval;
int totface;
@@ -728,7 +828,12 @@ static const DupliGenerator gen_dupli_faces = {
make_duplis_faces /* make_duplis */
};
-/* OB_DUPLIPARTS */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Dupli-Particles Implementation (#OB_DUPLIPARTS)
+ * \{ */
+
static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem *psys)
{
Scene *scene = ctx->scene;
@@ -955,13 +1060,12 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
if (psys_get_particle_state(&sim, a, &state, 0) == 0) {
continue;
}
- else {
- float tquat[4];
- normalize_qt_qt(tquat, state.rot);
- quat_to_mat4(pamat, tquat);
- copy_v3_v3(pamat[3], state.co);
- pamat[3][3] = 1.0f;
- }
+
+ float tquat[4];
+ normalize_qt_qt(tquat, state.rot);
+ quat_to_mat4(pamat, tquat);
+ copy_v3_v3(pamat[3], state.co);
+ pamat[3][3] = 1.0f;
}
if (part->ren_as == PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
@@ -1077,9 +1181,12 @@ static const DupliGenerator gen_dupli_particles = {
make_duplis_particles /* make_duplis */
};
-/* ------------- */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Dupli-Generator Selector For The Given Context
+ * \{ */
-/* select dupli generator from given context */
static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
{
int transflag = ctx->object->transflag;
@@ -1098,13 +1205,16 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
if (transflag & OB_DUPLIPARTS) {
return &gen_dupli_particles;
}
- else if (transflag & OB_DUPLIVERTS) {
+ if (transflag & OB_DUPLIVERTS) {
if (ctx->object->type == OB_MESH) {
return &gen_dupli_verts;
}
- else if (ctx->object->type == OB_FONT) {
+ if (ctx->object->type == OB_FONT) {
return &gen_dupli_verts_font;
}
+ if (ctx->object->type == OB_POINTCLOUD) {
+ return &gen_dupli_verts_pointcloud;
+ }
}
else if (transflag & OB_DUPLIFACES) {
if (ctx->object->type == OB_MESH) {
@@ -1118,9 +1228,15 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
return NULL;
}
-/* ---- ListBase dupli container implementation ---- */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Dupli-Container Implementation
+ * \{ */
-/* Returns a list of DupliObject */
+/**
+ * \return a #ListBase of #DupliObject.
+ */
ListBase *object_duplilist(Depsgraph *depsgraph, Scene *sce, Object *ob)
{
ListBase *duplilist = MEM_callocN(sizeof(ListBase), "duplilist");
@@ -1139,3 +1255,5 @@ void free_object_duplilist(ListBase *lb)
BLI_freelistN(lb);
MEM_freeN(lb);
}
+
+/** \} */
diff --git a/source/blender/blenkernel/intern/object_facemap.c b/source/blender/blenkernel/intern/object_facemap.c
index 10a3e35e382..c44ec2b510e 100644
--- a/source/blender/blenkernel/intern/object_facemap.c
+++ b/source/blender/blenkernel/intern/object_facemap.c
@@ -55,7 +55,7 @@ static bool fmap_unique_check(void *arg, const char *name)
for (fmap = data->ob->fmaps.first; fmap; fmap = fmap->next) {
if (data->fm != fmap) {
- if (!strcmp(fmap->name, name)) {
+ if (STREQ(fmap->name, name)) {
return true;
}
}
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index f94ef946851..ff7cbff06bf 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -753,18 +753,25 @@ struct Ocean *BKE_ocean_add(void)
return oc;
}
-bool BKE_ocean_ensure(struct OceanModifierData *omd)
+bool BKE_ocean_ensure(struct OceanModifierData *omd, const int resolution)
{
if (omd->ocean) {
- return false;
+ /* Check that the ocean has the same resolution than we want now. */
+ if (omd->ocean->_M == resolution * resolution) {
+ return false;
+ }
+
+ BKE_ocean_free(omd->ocean);
}
omd->ocean = BKE_ocean_add();
- BKE_ocean_init_from_modifier(omd->ocean, omd);
+ BKE_ocean_init_from_modifier(omd->ocean, omd, resolution);
return true;
}
-void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd)
+void BKE_ocean_init_from_modifier(struct Ocean *ocean,
+ struct OceanModifierData const *omd,
+ const int resolution)
{
short do_heightfield, do_chop, do_normals, do_jacobian;
@@ -774,9 +781,10 @@ void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData
do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM);
BKE_ocean_free_data(ocean);
+
BKE_ocean_init(ocean,
- omd->resolution * omd->resolution,
- omd->resolution * omd->resolution,
+ resolution * resolution,
+ resolution * resolution,
omd->spatial_size,
omd->spatial_size,
omd->wind_velocity,
@@ -1607,7 +1615,8 @@ void BKE_ocean_bake(struct Ocean *UNUSED(o),
}
void BKE_ocean_init_from_modifier(struct Ocean *UNUSED(ocean),
- struct OceanModifierData const *UNUSED(omd))
+ struct OceanModifierData const *UNUSED(omd),
+ int UNUSED(resolution))
{
}
diff --git a/source/blender/blenkernel/intern/ocean_intern.h b/source/blender/blenkernel/intern/ocean_intern.h
index 7da88419219..39ce0db09d6 100644
--- a/source/blender/blenkernel/intern/ocean_intern.h
+++ b/source/blender/blenkernel/intern/ocean_intern.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BKE_OCEAN_INTERN_H__
-#define __BKE_OCEAN_INTERN_H__
+#pragma once
/** \file
* \ingroup bli
@@ -133,5 +132,3 @@ typedef struct Ocean {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 2cd5588ccb8..6793f5e1169 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -80,7 +80,7 @@ int BKE_packedfile_seek(PackedFile *pf, int offset, int whence)
pf->seek = seek;
}
- return (oldseek);
+ return oldseek;
}
void BKE_packedfile_rewind(PackedFile *pf)
@@ -108,7 +108,7 @@ int BKE_packedfile_read(PackedFile *pf, void *data, int size)
size = -1;
}
- return (size);
+ return size;
}
int BKE_packedfile_count_all(Main *bmain)
@@ -234,7 +234,7 @@ PackedFile *BKE_packedfile_new(ReportList *reports, const char *filename, const
// XXX waitcursor(0);
- return (pf);
+ return pf;
}
/* no libraries for now */
@@ -365,7 +365,7 @@ int BKE_packedfile_write_to_file(ReportList *reports,
if (guimode) {
} // XXX waitcursor(0);
- return (ret_value);
+ return ret_value;
}
/**
@@ -415,11 +415,10 @@ enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name,
ret_val = PF_CMP_DIFFERS;
break;
}
- else {
- if (memcmp(buf, ((char *)pf->data) + i, len)) {
- ret_val = PF_CMP_DIFFERS;
- break;
- }
+
+ if (memcmp(buf, ((char *)pf->data) + i, len) != 0) {
+ ret_val = PF_CMP_DIFFERS;
+ break;
}
}
@@ -427,7 +426,7 @@ enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name,
}
}
- return (ret_val);
+ return ret_val;
}
/**
@@ -580,7 +579,7 @@ int BKE_packedfile_unpack_vfont(Main *bmain,
}
}
- return (ret_value);
+ return ret_value;
}
int BKE_packedfile_unpack_sound(Main *bmain,
@@ -610,7 +609,7 @@ int BKE_packedfile_unpack_sound(Main *bmain,
}
}
- return (ret_value);
+ return ret_value;
}
int BKE_packedfile_unpack_image(Main *bmain,
@@ -663,7 +662,7 @@ int BKE_packedfile_unpack_image(Main *bmain,
BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD);
}
- return (ret_value);
+ return ret_value;
}
int BKE_packedfile_unpack_volume(Main *bmain,
@@ -693,7 +692,7 @@ int BKE_packedfile_unpack_volume(Main *bmain,
}
}
- return (ret_value);
+ return ret_value;
}
int BKE_packedfile_unpack_all_libraries(Main *bmain, ReportList *reports)
@@ -724,7 +723,7 @@ int BKE_packedfile_unpack_all_libraries(Main *bmain, ReportList *reports)
}
}
- return (ret_value);
+ return ret_value;
}
void BKE_packedfile_pack_all_libraries(Main *bmain, ReportList *reports)
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index d4edcf88389..19d5c34ad73 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -426,7 +426,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
if (sima->mode == SI_MODE_PAINT) {
return &ts->imapaint.paint;
}
- else if (sima->mode == SI_MODE_UV) {
+ if (sima->mode == SI_MODE_UV) {
return &ts->uvsculpt->paint;
}
}
@@ -460,7 +460,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
if (sima->mode == SI_MODE_PAINT) {
return PAINT_MODE_TEXTURE_2D;
}
- else if (sima->mode == SI_MODE_UV) {
+ if (sima->mode == SI_MODE_UV) {
return PAINT_MODE_SCULPT_UV;
}
}
@@ -715,7 +715,7 @@ static int palettecolor_compare_hsv(const void *a1, const void *a2)
if (ps1->h > ps2->h) {
return 1;
}
- else if (ps1->h < ps2->h) {
+ if (ps1->h < ps2->h) {
return -1;
}
@@ -723,7 +723,7 @@ static int palettecolor_compare_hsv(const void *a1, const void *a2)
if (ps1->s > ps2->s) {
return 1;
}
- else if (ps1->s < ps2->s) {
+ if (ps1->s < ps2->s) {
return -1;
}
@@ -731,7 +731,7 @@ static int palettecolor_compare_hsv(const void *a1, const void *a2)
if (1.0f - ps1->v > 1.0f - ps2->v) {
return 1;
}
- else if (1.0f - ps1->v < 1.0f - ps2->v) {
+ if (1.0f - ps1->v < 1.0f - ps2->v) {
return -1;
}
@@ -747,7 +747,7 @@ static int palettecolor_compare_svh(const void *a1, const void *a2)
if (ps1->s > ps2->s) {
return 1;
}
- else if (ps1->s < ps2->s) {
+ if (ps1->s < ps2->s) {
return -1;
}
@@ -755,7 +755,7 @@ static int palettecolor_compare_svh(const void *a1, const void *a2)
if (1.0f - ps1->v > 1.0f - ps2->v) {
return 1;
}
- else if (1.0f - ps1->v < 1.0f - ps2->v) {
+ if (1.0f - ps1->v < 1.0f - ps2->v) {
return -1;
}
@@ -763,7 +763,7 @@ static int palettecolor_compare_svh(const void *a1, const void *a2)
if (ps1->h > ps2->h) {
return 1;
}
- else if (ps1->h < ps2->h) {
+ if (ps1->h < ps2->h) {
return -1;
}
@@ -778,7 +778,7 @@ static int palettecolor_compare_vhs(const void *a1, const void *a2)
if (1.0f - ps1->v > 1.0f - ps2->v) {
return 1;
}
- else if (1.0f - ps1->v < 1.0f - ps2->v) {
+ if (1.0f - ps1->v < 1.0f - ps2->v) {
return -1;
}
@@ -786,7 +786,7 @@ static int palettecolor_compare_vhs(const void *a1, const void *a2)
if (ps1->h > ps2->h) {
return 1;
}
- else if (ps1->h < ps2->h) {
+ if (ps1->h < ps2->h) {
return -1;
}
@@ -794,7 +794,7 @@ static int palettecolor_compare_vhs(const void *a1, const void *a2)
if (ps1->s > ps2->s) {
return 1;
}
- else if (ps1->s < ps2->s) {
+ if (ps1->s < ps2->s) {
return -1;
}
@@ -811,7 +811,7 @@ static int palettecolor_compare_luminance(const void *a1, const void *a2)
if (lumi1 > lumi2) {
return -1;
}
- else if (lumi1 < lumi2) {
+ if (lumi1 < lumi2) {
return 1;
}
@@ -1424,9 +1424,8 @@ MultiresModifierData *BKE_sculpt_multires_active(Scene *scene, Object *ob)
if (mmd->sculptlvl > 0) {
return mmd;
}
- else {
- return NULL;
- }
+
+ return NULL;
}
}
@@ -1468,7 +1467,7 @@ static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
if (mti->type == eModifierTypeType_OnlyDeform) {
return true;
}
- else if ((sd->flags & SCULPT_ONLY_DEFORM) == 0) {
+ if ((sd->flags & SCULPT_ONLY_DEFORM) == 0) {
return true;
}
}
@@ -1493,6 +1492,8 @@ static void sculpt_update_object(Depsgraph *depsgraph,
MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
const bool use_face_sets = (ob->mode & OB_MODE_SCULPT) != 0;
+ ss->depsgraph = depsgraph;
+
ss->deform_modifiers_active = sculpt_modifiers_active(scene, sd, ob);
ss->show_mask = (sd->flags & SCULPT_HIDE_MASK) == 0;
ss->show_face_sets = (sd->flags & SCULPT_HIDE_FACE_SETS) == 0;
@@ -1824,6 +1825,64 @@ static bool check_sculpt_object_deformed(Object *object, const bool for_construc
return deformed;
}
+static void sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh)
+{
+ int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
+ if (!face_sets) {
+ return;
+ }
+
+ for (int i = 0; i < mesh->totvert; i++) {
+ mesh->mvert[i].flag |= ME_HIDE;
+ }
+
+ for (int i = 0; i < mesh->totpoly; i++) {
+ if (face_sets[i] >= 0) {
+ for (int l = 0; l < mesh->mpoly[i].totloop; l++) {
+ MLoop *loop = &mesh->mloop[mesh->mpoly[i].loopstart + l];
+ mesh->mvert[loop->v].flag &= ~ME_HIDE;
+ }
+ }
+ }
+}
+
+static void sculpt_sync_face_sets_visibility_to_grids(Mesh *mesh, SubdivCCG *subdiv_ccg)
+{
+ int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
+ if (!face_sets) {
+ return;
+ }
+
+ if (!subdiv_ccg) {
+ return;
+ }
+
+ CCGKey key;
+ BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
+ for (int i = 0; i < mesh->totloop; i++) {
+ const int face_index = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, i);
+ const bool is_hidden = (face_sets[face_index] < 0);
+
+ /* Avoid creating and modifying the grid_hidden bitmap if the base mesh face is visible and
+ * there is not bitmap for the grid. This is because missing grid_hidden implies grid is fully
+ * visible. */
+ if (is_hidden) {
+ BKE_subdiv_ccg_grid_hidden_ensure(subdiv_ccg, i);
+ }
+
+ BLI_bitmap *gh = subdiv_ccg->grid_hidden[i];
+ if (gh) {
+ BLI_bitmap_set_all(gh, is_hidden, key.grid_area);
+ }
+ }
+}
+
+void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg)
+{
+ sculpt_sync_face_sets_visibility_to_base_mesh(mesh);
+ sculpt_sync_face_sets_visibility_to_grids(mesh, subdiv_ccg);
+}
+
static PBVH *build_pbvh_for_dynamic_topology(Object *ob)
{
PBVH *pbvh = BKE_pbvh_new();
@@ -1849,6 +1908,8 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool
BKE_mesh_recalc_looptri(me->mloop, me->mpoly, me->mvert, me->totloop, me->totpoly, looptri);
+ BKE_sculpt_sync_face_set_visibility(me, NULL);
+
BKE_pbvh_build_mesh(pbvh,
me,
me->mpoly,
@@ -1881,6 +1942,10 @@ static PBVH *build_pbvh_from_ccg(Object *ob, SubdivCCG *subdiv_ccg, bool respect
BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
PBVH *pbvh = BKE_pbvh_new();
BKE_pbvh_respect_hide_set(pbvh, respect_hide);
+
+ Mesh *base_mesh = BKE_mesh_from_object(ob);
+ BKE_sculpt_sync_face_set_visibility(base_mesh, subdiv_ccg);
+
BKE_pbvh_build_grids(pbvh,
subdiv_ccg->grids,
subdiv_ccg->num_grids,
@@ -1964,8 +2029,7 @@ bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const View3D *v3d)
const bool full_shading = (v3d && (v3d->shading.type > OB_SOLID));
return !(ss->shapekey_active || ss->deform_modifiers_active || full_shading);
}
- else {
- /* Multires and dyntopo always draw directly from the PBVH. */
- return true;
- }
+
+ /* Multires and dyntopo always draw directly from the PBVH. */
+ return true;
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index a003daf1042..b3da6c53b34 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -512,9 +512,8 @@ bool psys_check_edited(ParticleSystem *psys)
if (psys->part && psys->part->type == PART_HAIR) {
return (psys->flag & PSYS_EDITED || (psys->edit && psys->edit->edited));
}
- else {
- return (psys->pointcache->edit && psys->pointcache->edit->edited);
- }
+
+ return (psys->pointcache->edit && psys->pointcache->edit->edited);
}
void psys_find_group_weights(ParticleSettings *part)
@@ -1653,12 +1652,11 @@ int psys_particle_dm_face_lookup(Mesh *mesh_final,
// printf("\tNO CD_ORIGSPACE, assuming not needed\n");
return findex_orig;
}
- else {
- printf("\tNO CD_ORIGSPACE, error out of range\n");
- return DMCACHE_NOTFOUND;
- }
+
+ printf("\tNO CD_ORIGSPACE, error out of range\n");
+ return DMCACHE_NOTFOUND;
}
- else if (findex_orig >= mesh_original->totface) {
+ if (findex_orig >= mesh_original->totface) {
return DMCACHE_NOTFOUND; /* index not in the original mesh */
}
@@ -1919,7 +1917,7 @@ static void psys_particle_on_shape(int UNUSED(distr),
float orco[3])
{
/* TODO */
- float zerovec[3] = {0.0f, 0.0f, 0.0f};
+ const float zerovec[3] = {0.0f, 0.0f, 0.0f};
if (vec) {
copy_v3_v3(vec, zerovec);
}
@@ -2170,10 +2168,10 @@ int do_guides(Depsgraph *depsgraph,
{
ParticleKey key;
- float par_co[3] = {0.0f, 0.0f, 0.0f};
- float par_vel[3] = {0.0f, 0.0f, 0.0f};
- float par_rot[4] = {1.0f, 0.0f, 0.0f, 0.0f};
- float orco_offset[3] = {0.0f, 0.0f, 0.0f};
+ const float par_co[3] = {0.0f, 0.0f, 0.0f};
+ const float par_vel[3] = {0.0f, 0.0f, 0.0f};
+ const float par_rot[4] = {1.0f, 0.0f, 0.0f, 0.0f};
+ const float orco_offset[3] = {0.0f, 0.0f, 0.0f};
copy_v3_v3(key.co, vec_to_point);
do_kink(&key,
@@ -2555,9 +2553,8 @@ static void psys_thread_create_path(ParticleTask *task,
if (!needupdate) {
return;
}
- else {
- memset(child_keys, 0, sizeof(*child_keys) * (ctx->segments + 1));
- }
+
+ memset(child_keys, 0, sizeof(*child_keys) * (ctx->segments + 1));
}
/* get parent paths */
@@ -3483,7 +3480,7 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat
{
float det, w1, w2, d1[2], d2[2];
- memset(mat, 0, sizeof(float) * 4 * 4);
+ memset(mat, 0, sizeof(float[4][4]));
mat[3][3] = 1.0f;
/* first axis is the normal */
@@ -3871,7 +3868,7 @@ void BKE_particlesettings_clump_curve_init(ParticleSettings *part)
cumap->cm[0].curve[1].x = 1.0f;
cumap->cm[0].curve[1].y = 1.0f;
- BKE_curvemapping_initialize(cumap);
+ BKE_curvemapping_init(cumap);
part->clumpcurve = cumap;
}
@@ -3885,7 +3882,7 @@ void BKE_particlesettings_rough_curve_init(ParticleSettings *part)
cumap->cm[0].curve[1].x = 1.0f;
cumap->cm[0].curve[1].y = 1.0f;
- BKE_curvemapping_initialize(cumap);
+ BKE_curvemapping_init(cumap);
part->roughcurve = cumap;
}
@@ -3899,7 +3896,7 @@ void BKE_particlesettings_twist_curve_init(ParticleSettings *part)
cumap->cm[0].curve[1].x = 1.0f;
cumap->cm[0].curve[1].y = 1.0f;
- BKE_curvemapping_initialize(cumap);
+ BKE_curvemapping_init(cumap);
part->twistcurve = cumap;
}
@@ -4388,7 +4385,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
short cpa_from;
/* initialize keys to zero */
- memset(keys, 0, 4 * sizeof(ParticleKey));
+ memset(keys, 0, sizeof(ParticleKey[4]));
t = state->time;
CLAMP(t, 0.0f, 1.0f);
@@ -4666,10 +4663,9 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
psys_get_particle_on_path(sim, p, state, 1);
return 1;
}
- else {
- cpa = sim->psys->child + p - totpart;
- pa = sim->psys->particles + cpa->parent;
- }
+
+ cpa = sim->psys->child + p - totpart;
+ pa = sim->psys->particles + cpa->parent;
}
else {
pa = sim->psys->particles + p;
@@ -4691,106 +4687,105 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
psys_get_particle_on_path(sim, p, state, 1);
return 1;
}
- else {
- if (cpa) {
- float mat[4][4];
- ParticleKey *key1;
- float t = (cfra - pa->time) / pa->lifetime;
- float par_orco[3] = {0.0f, 0.0f, 0.0f};
- key1 = &pa->state;
- offset_child(cpa, key1, key1->rot, state, part->childflat, part->childrad);
+ if (cpa) {
+ float mat[4][4];
+ ParticleKey *key1;
+ float t = (cfra - pa->time) / pa->lifetime;
+ const float par_orco[3] = {0.0f, 0.0f, 0.0f};
- CLAMP(t, 0.0f, 1.0f);
+ key1 = &pa->state;
+ offset_child(cpa, key1, key1->rot, state, part->childflat, part->childrad);
- unit_m4(mat);
- ParticleChildModifierContext modifier_ctx = {NULL};
- modifier_ctx.thread_ctx = NULL;
- modifier_ctx.sim = sim;
- modifier_ctx.ptex = NULL;
- modifier_ctx.cpa = cpa;
- modifier_ctx.orco = cpa->fuv;
- modifier_ctx.par_co = key1->co;
- modifier_ctx.par_vel = key1->vel;
- modifier_ctx.par_rot = key1->rot;
- modifier_ctx.par_orco = par_orco;
- modifier_ctx.parent_keys = psys->childcache ? psys->childcache[p - totpart] : NULL;
+ CLAMP(t, 0.0f, 1.0f);
- do_child_modifiers(&modifier_ctx, mat, state, t);
+ unit_m4(mat);
+ ParticleChildModifierContext modifier_ctx = {NULL};
+ modifier_ctx.thread_ctx = NULL;
+ modifier_ctx.sim = sim;
+ modifier_ctx.ptex = NULL;
+ modifier_ctx.cpa = cpa;
+ modifier_ctx.orco = cpa->fuv;
+ modifier_ctx.par_co = key1->co;
+ modifier_ctx.par_vel = key1->vel;
+ modifier_ctx.par_rot = key1->rot;
+ modifier_ctx.par_orco = par_orco;
+ modifier_ctx.parent_keys = psys->childcache ? psys->childcache[p - totpart] : NULL;
- if (psys->lattice_deform_data) {
- BKE_lattice_deform_data_eval_co(
- psys->lattice_deform_data, state->co, psys->lattice_strength);
- }
+ do_child_modifiers(&modifier_ctx, mat, state, t);
+
+ if (psys->lattice_deform_data) {
+ BKE_lattice_deform_data_eval_co(
+ psys->lattice_deform_data, state->co, psys->lattice_strength);
+ }
+ }
+ else {
+ if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) {
+ copy_particle_key(state, &pa->state, 1);
+ }
+ else if (pa->prev_state.time == cfra) {
+ copy_particle_key(state, &pa->prev_state, 1);
}
else {
- if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) {
- copy_particle_key(state, &pa->state, 1);
- }
- else if (pa->prev_state.time == cfra) {
- copy_particle_key(state, &pa->prev_state, 1);
- }
- 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) {
- /* 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;
+ 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) {
+ /* 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;
- copy_particle_key(state, &pa->state, 1);
+ copy_particle_key(state, &pa->state, 1);
- madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec);
- }
- else {
- ParticleKey keys[4];
- float keytime;
+ madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec);
+ }
+ else {
+ ParticleKey keys[4];
+ float keytime;
- copy_particle_key(keys + 1, &pa->prev_state, 1);
- copy_particle_key(keys + 2, &pa->state, 1);
+ copy_particle_key(keys + 1, &pa->prev_state, 1);
+ copy_particle_key(keys + 2, &pa->state, 1);
- dfra = keys[2].time - keys[1].time;
+ dfra = keys[2].time - keys[1].time;
- keytime = (state->time - keys[1].time) / dfra;
+ keytime = (state->time - keys[1].time) / dfra;
- /* convert velocity to timestep size */
- mul_v3_fl(keys[1].vel, dfra * timestep);
- mul_v3_fl(keys[2].vel, dfra * timestep);
+ /* convert velocity to timestep size */
+ mul_v3_fl(keys[1].vel, dfra * timestep);
+ mul_v3_fl(keys[2].vel, dfra * timestep);
- psys_interpolate_particle(-1, keys, keytime, state, 1);
+ psys_interpolate_particle(-1, keys, keytime, state, 1);
- /* convert back to real velocity */
- mul_v3_fl(state->vel, 1.f / (dfra * timestep));
+ /* convert back to real velocity */
+ mul_v3_fl(state->vel, 1.f / (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);
- }
+ 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) {
- /* linear interpolation using only pa->state */
+ }
+ else if (pa->state.time + 1.f >= state->time && pa->state.time - 1.f <= state->time) {
+ /* linear interpolation using only pa->state */
- dfra = state->time - pa->state.time;
+ dfra = state->time - pa->state.time;
- copy_particle_key(state, &pa->state, 1);
+ copy_particle_key(state, &pa->state, 1);
- madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec);
- }
- else {
- /* Extrapolating over big ranges is not accurate
- * so let's just give something close to reasonable back. */
- copy_particle_key(state, &pa->state, 0);
- }
+ madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec);
}
-
- if (sim->psys->lattice_deform_data) {
- BKE_lattice_deform_data_eval_co(
- sim->psys->lattice_deform_data, state->co, psys->lattice_strength);
+ else {
+ /* Extrapolating over big ranges is not accurate
+ * so let's just give something close to reasonable back. */
+ copy_particle_key(state, &pa->state, 0);
}
}
- return 1;
+ if (sim->psys->lattice_deform_data) {
+ BKE_lattice_deform_data_eval_co(
+ sim->psys->lattice_deform_data, state->co, psys->lattice_strength);
+ }
}
+
+ return 1;
}
void psys_get_dupli_texture(ParticleSystem *psys,
@@ -4844,9 +4839,8 @@ void psys_get_dupli_texture(ParticleSystem *psys,
orco);
return;
}
- else {
- pa = psys->particles + cpa->pa[0];
- }
+
+ pa = psys->particles + cpa->pa[0];
}
if ((part->from == PART_FROM_FACE) && (psmd->mesh_final != NULL) && !is_grid) {
diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c
index dcd2a0b8fae..da5fdc85561 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -305,10 +305,9 @@ static bool check_path_length(int k,
/* something over the maximum step value */
return false;
}
- else {
- *cur_length += step_length;
- return true;
- }
+
+ *cur_length += step_length;
+ return true;
}
void psys_apply_child_modifiers(ParticleThreadContext *ctx,
@@ -685,7 +684,7 @@ static void do_rough(const float loc[3],
}
static void do_rough_end(
- const float loc[3], float mat[4][4], float t, float fac, float shape, ParticleKey *state)
+ const float loc[3], const float mat[4][4], float t, float fac, float shape, ParticleKey *state)
{
float rough[2];
float roughfac;
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index e0dccd4d14a..fad93245a04 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -382,7 +382,7 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount)
x -= (float)floor(x);
}
- jit2 = MEM_mallocN(12 + 2 * sizeof(float) * num, "initjit");
+ jit2 = MEM_mallocN(12 + sizeof(float[2]) * num, "initjit");
for (i = 0; i < 4; i++) {
BLI_jitterate1((float(*)[2])jit, (float(*)[2])jit2, num, rad1);
@@ -829,22 +829,20 @@ static int distribute_compare_orig_index(const void *p1, const void *p2, void *u
if (index1 < index2) {
return -1;
}
- else if (index1 == index2) {
+ if (index1 == index2) {
/* this pointer comparison appears to make qsort stable for glibc,
* and apparently on solaris too, makes the renders reproducible */
if (p1 < p2) {
return -1;
}
- else if (p1 == p2) {
+ if (p1 == p2) {
return 0;
}
- else {
- return 1;
- }
- }
- else {
+
return 1;
}
+
+ return 1;
}
static void distribute_invalid(ParticleSimulationData *sim, int from)
@@ -1282,7 +1280,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
hammersley_create(jit, jitlevel + 1, psys->seed, part->jitfac);
}
BLI_array_randomize(
- jit, 2 * sizeof(float), jitlevel, psys->seed); /* for custom jit or even distribution */
+ jit, sizeof(float[2]), jitlevel, psys->seed); /* for custom jit or even distribution */
}
/* Setup things for threaded distribution */
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index bec9cbbad79..7bfc0ca764f 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -106,9 +106,8 @@ static int particles_are_dynamic(ParticleSystem *psys)
if (psys->part->type == PART_HAIR) {
return psys->flag & PSYS_HAIR_DYNAMICS;
}
- else {
- return ELEM(psys->part->phystype, PART_PHYS_NEWTON, PART_PHYS_BOIDS, PART_PHYS_FLUID);
- }
+
+ return ELEM(psys->part->phystype, PART_PHYS_NEWTON, PART_PHYS_BOIDS, PART_PHYS_FLUID);
}
float psys_get_current_display_percentage(ParticleSystem *psys, const bool use_render_params)
@@ -131,12 +130,11 @@ static int tot_particles(ParticleSystem *psys, PTCacheID *pid)
if (pid && psys->pointcache->flag & PTCACHE_EXTERNAL) {
return pid->cache->totpoint;
}
- else if (psys->part->distr == PART_DISTR_GRID && psys->part->from != PART_FROM_VERT) {
+ if (psys->part->distr == PART_DISTR_GRID && psys->part->from != PART_FROM_VERT) {
return psys->part->grid_res * psys->part->grid_res * psys->part->grid_res - psys->totunexist;
}
- else {
- return psys->part->totpart - psys->totunexist;
- }
+
+ return psys->part->totpart - psys->totunexist;
}
void psys_reset(ParticleSystem *psys, int mode)
@@ -570,7 +568,7 @@ void psys_thread_context_free(ParticleThreadContext *ctx)
}
}
-static void initialize_particle_texture(ParticleSimulationData *sim, ParticleData *pa, int p)
+static void init_particle_texture(ParticleSimulationData *sim, ParticleData *pa, int p)
{
ParticleSystem *psys = sim->psys;
ParticleSettings *part = psys->part;
@@ -595,7 +593,7 @@ static void initialize_particle_texture(ParticleSimulationData *sim, ParticleDat
}
/* set particle parameters that don't change during particle's life */
-void initialize_particle(ParticleSimulationData *sim, ParticleData *pa)
+void init_particle(ParticleSimulationData *sim, ParticleData *pa)
{
ParticleSettings *part = sim->psys->part;
float birth_time = (float)(pa - sim->psys->particles) / (float)sim->psys->totpart;
@@ -629,7 +627,7 @@ static void initialize_all_particles(ParticleSimulationData *sim)
LOOP_PARTICLES
{
if (!(emit_from_volume_grid && (pa->flag & PARS_UNEXIST) != 0)) {
- initialize_particle(sim, pa);
+ init_particle(sim, pa);
}
}
}
@@ -1092,7 +1090,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
* We could only do it now because we'll need to know coordinate
* before sampling the texture.
*/
- initialize_particle_texture(sim, pa, p);
+ init_particle_texture(sim, pa, p);
if (part->phystype == PART_PHYS_BOIDS && pa->boid) {
BoidParticle *bpa = pa->boid;
@@ -1709,13 +1707,12 @@ static void sph_evaluate_func(BVHTree *tree,
BLI_bvhtree_range_query(tree, co, interaction_radius, callback, pfr);
break;
}
- else {
- BLI_rw_mutex_lock(&psys_bvhtree_rwlock, THREAD_LOCK_READ);
- BLI_bvhtree_range_query(psys[i]->bvhtree, co, interaction_radius, callback, pfr);
+ BLI_rw_mutex_lock(&psys_bvhtree_rwlock, THREAD_LOCK_READ);
- BLI_rw_mutex_unlock(&psys_bvhtree_rwlock);
- }
+ BLI_bvhtree_range_query(psys[i]->bvhtree, co, interaction_radius, callback, pfr);
+
+ BLI_rw_mutex_unlock(&psys_bvhtree_rwlock);
}
}
static void sph_density_accum_cb(void *userdata, int index, const float co[3], float squared_dist)
@@ -2612,9 +2609,8 @@ static float collision_newton_rhapson(ParticleCollision *col,
d1 = 0.f;
continue;
}
- else {
- return -1.f;
- }
+
+ return -1.f;
}
dd = (t1 - t0) / (d1 - d0);
@@ -2634,7 +2630,7 @@ static float collision_newton_rhapson(ParticleCollision *col,
d1 = 0.f;
continue;
}
- else if (iter == 1 && (t1 < -COLLISION_ZERO || t1 > 1.f)) {
+ if (iter == 1 && (t1 < -COLLISION_ZERO || t1 > 1.f)) {
return -1.f;
}
@@ -2648,9 +2644,8 @@ static float collision_newton_rhapson(ParticleCollision *col,
return t1;
}
- else {
- return -1.f;
- }
+
+ return -1.f;
}
}
return -1.0;
@@ -2927,164 +2922,163 @@ static int collision_response(ParticleSimulationData *sim,
return 0;
}
/* figure out velocity and other data after collision */
- else {
- /* velocity directly before collision to be modified into velocity directly after collision */
- float v0[3];
- /* normal component of v0 */
- float v0_nor[3];
- /* tangential component of v0 */
- float v0_tan[3];
- /* tangential component of collision surface velocity */
- float vc_tan[3];
- float v0_dot, vc_dot;
- float damp = pd->pdef_damp + pd->pdef_rdamp * 2 * (BLI_rng_get_float(rng) - 0.5f);
- float frict = pd->pdef_frict + pd->pdef_rfrict * 2 * (BLI_rng_get_float(rng) - 0.5f);
- float distance, nor[3], dot;
-
- CLAMP(damp, 0.0f, 1.0f);
- CLAMP(frict, 0.0f, 1.0f);
-
- /* get exact velocity right before collision */
- madd_v3_v3v3fl(v0, col->ve1, col->acc, dt1);
-
- /* Convert collider velocity from `1/frame_step` to `1/s` TODO:
- * here we assume 1 frame step for collision modifier. */
- mul_v3_fl(pce->vel, col->inv_timestep);
-
- /* calculate tangential particle velocity */
- v0_dot = dot_v3v3(pce->nor, v0);
- madd_v3_v3v3fl(v0_tan, v0, pce->nor, -v0_dot);
-
- /* calculate tangential collider velocity */
- vc_dot = dot_v3v3(pce->nor, pce->vel);
- madd_v3_v3v3fl(vc_tan, pce->vel, pce->nor, -vc_dot);
-
- /* handle friction effects (tangential and angular velocity) */
- if (frict > 0.0f) {
- /* angular <-> linear velocity */
- if (dynamic_rotation) {
- float vr_tan[3], v1_tan[3], ave[3];
-
- /* linear velocity of particle surface */
- cross_v3_v3v3(vr_tan, pce->nor, pa->state.ave);
- mul_v3_fl(vr_tan, pa->size);
-
- /* change to coordinates that move with the collision plane */
- sub_v3_v3v3(v1_tan, v0_tan, vc_tan);
-
- /* The resulting velocity is a weighted average of particle cm & surface
- * velocity. This weight (related to particle's moment of inertia) could
- * be made a parameter for angular <-> linear conversion.
- */
- madd_v3_v3fl(v1_tan, vr_tan, -0.4);
- mul_v3_fl(v1_tan, 1.0f / 1.4f); /* 1/(1+0.4) */
- /* rolling friction is around 0.01 of sliding friction
- * (could be made a parameter) */
- mul_v3_fl(v1_tan, 1.0f - 0.01f * frict);
-
- /* surface_velocity is opposite to cm velocity */
- negate_v3_v3(vr_tan, v1_tan);
-
- /* get back to global coordinates */
- add_v3_v3(v1_tan, vc_tan);
-
- /* convert to angular velocity*/
- cross_v3_v3v3(ave, vr_tan, pce->nor);
- mul_v3_fl(ave, 1.0f / MAX2(pa->size, 0.001f));
-
- /* only friction will cause change in linear & angular velocity */
- interp_v3_v3v3(pa->state.ave, pa->state.ave, ave, frict);
- interp_v3_v3v3(v0_tan, v0_tan, v1_tan, frict);
- }
- else {
- /* just basic friction (unphysical due to the friction model used in Blender) */
- interp_v3_v3v3(v0_tan, v0_tan, vc_tan, frict);
- }
+ /* velocity directly before collision to be modified into velocity directly after collision */
+ float v0[3];
+ /* normal component of v0 */
+ float v0_nor[3];
+ /* tangential component of v0 */
+ float v0_tan[3];
+ /* tangential component of collision surface velocity */
+ float vc_tan[3];
+ float v0_dot, vc_dot;
+ float damp = pd->pdef_damp + pd->pdef_rdamp * 2 * (BLI_rng_get_float(rng) - 0.5f);
+ float frict = pd->pdef_frict + pd->pdef_rfrict * 2 * (BLI_rng_get_float(rng) - 0.5f);
+ float distance, nor[3], dot;
+
+ CLAMP(damp, 0.0f, 1.0f);
+ CLAMP(frict, 0.0f, 1.0f);
+
+ /* get exact velocity right before collision */
+ madd_v3_v3v3fl(v0, col->ve1, col->acc, dt1);
+
+ /* Convert collider velocity from `1/frame_step` to `1/s` TODO:
+ * here we assume 1 frame step for collision modifier. */
+ mul_v3_fl(pce->vel, col->inv_timestep);
+
+ /* calculate tangential particle velocity */
+ v0_dot = dot_v3v3(pce->nor, v0);
+ madd_v3_v3v3fl(v0_tan, v0, pce->nor, -v0_dot);
+
+ /* calculate tangential collider velocity */
+ vc_dot = dot_v3v3(pce->nor, pce->vel);
+ madd_v3_v3v3fl(vc_tan, pce->vel, pce->nor, -vc_dot);
+
+ /* handle friction effects (tangential and angular velocity) */
+ if (frict > 0.0f) {
+ /* angular <-> linear velocity */
+ if (dynamic_rotation) {
+ float vr_tan[3], v1_tan[3], ave[3];
+
+ /* linear velocity of particle surface */
+ cross_v3_v3v3(vr_tan, pce->nor, pa->state.ave);
+ mul_v3_fl(vr_tan, pa->size);
+
+ /* change to coordinates that move with the collision plane */
+ sub_v3_v3v3(v1_tan, v0_tan, vc_tan);
+
+ /* The resulting velocity is a weighted average of particle cm & surface
+ * velocity. This weight (related to particle's moment of inertia) could
+ * be made a parameter for angular <-> linear conversion.
+ */
+ madd_v3_v3fl(v1_tan, vr_tan, -0.4);
+ mul_v3_fl(v1_tan, 1.0f / 1.4f); /* 1/(1+0.4) */
+
+ /* rolling friction is around 0.01 of sliding friction
+ * (could be made a parameter) */
+ mul_v3_fl(v1_tan, 1.0f - 0.01f * frict);
+
+ /* surface_velocity is opposite to cm velocity */
+ negate_v3_v3(vr_tan, v1_tan);
+
+ /* get back to global coordinates */
+ add_v3_v3(v1_tan, vc_tan);
+
+ /* convert to angular velocity*/
+ cross_v3_v3v3(ave, vr_tan, pce->nor);
+ mul_v3_fl(ave, 1.0f / MAX2(pa->size, 0.001f));
+
+ /* only friction will cause change in linear & angular velocity */
+ interp_v3_v3v3(pa->state.ave, pa->state.ave, ave, frict);
+ interp_v3_v3v3(v0_tan, v0_tan, v1_tan, frict);
}
+ else {
+ /* just basic friction (unphysical due to the friction model used in Blender) */
+ interp_v3_v3v3(v0_tan, v0_tan, vc_tan, frict);
+ }
+ }
- /* Stickiness was possibly added before,
- * so cancel that before calculating new normal velocity.
- * Otherwise particles go flying out of the surface
- * because of high reversed sticky velocity. */
- if (v0_dot < 0.0f) {
- v0_dot += pd->pdef_stickness;
- if (v0_dot > 0.0f) {
- v0_dot = 0.0f;
- }
+ /* Stickiness was possibly added before,
+ * so cancel that before calculating new normal velocity.
+ * Otherwise particles go flying out of the surface
+ * because of high reversed sticky velocity. */
+ if (v0_dot < 0.0f) {
+ v0_dot += pd->pdef_stickness;
+ if (v0_dot > 0.0f) {
+ v0_dot = 0.0f;
}
+ }
- /* damping and flipping of velocity around normal */
- v0_dot *= 1.0f - damp;
- vc_dot *= through ? damp : 1.0f;
+ /* damping and flipping of velocity around normal */
+ v0_dot *= 1.0f - damp;
+ vc_dot *= through ? damp : 1.0f;
- /* calculate normal particle velocity */
- /* special case for object hitting the particle from behind */
- if (through == 0 && ((vc_dot > 0.0f && v0_dot > 0.0f && vc_dot > v0_dot) ||
- (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) {
- mul_v3_v3fl(v0_nor, pce->nor, vc_dot + v0_dot);
- }
- else {
- mul_v3_v3fl(v0_nor, pce->nor, vc_dot + (through ? 1.0f : -1.0f) * v0_dot);
- }
+ /* calculate normal particle velocity */
+ /* special case for object hitting the particle from behind */
+ if (through == 0 && ((vc_dot > 0.0f && v0_dot > 0.0f && vc_dot > v0_dot) ||
+ (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) {
+ mul_v3_v3fl(v0_nor, pce->nor, vc_dot + v0_dot);
+ }
+ else {
+ mul_v3_v3fl(v0_nor, pce->nor, vc_dot + (through ? 1.0f : -1.0f) * v0_dot);
+ }
- /* combine components together again */
- add_v3_v3v3(v0, v0_nor, v0_tan);
+ /* combine components together again */
+ add_v3_v3v3(v0, v0_nor, v0_tan);
- if (col->boid) {
- /* keep boids above ground */
- BoidParticle *bpa = pa->boid;
- if (bpa->data.mode == eBoidMode_OnLand || co[2] <= col->boid_z) {
- co[2] = col->boid_z;
- v0[2] = 0.0f;
- }
+ if (col->boid) {
+ /* keep boids above ground */
+ BoidParticle *bpa = pa->boid;
+ if (bpa->data.mode == eBoidMode_OnLand || co[2] <= col->boid_z) {
+ co[2] = col->boid_z;
+ v0[2] = 0.0f;
}
+ }
- /* re-apply acceleration to final location and velocity */
- madd_v3_v3v3fl(pa->state.co, co, v0, dt2);
- madd_v3_v3fl(pa->state.co, col->acc, 0.5f * dt2 * dt2);
- madd_v3_v3v3fl(pa->state.vel, v0, col->acc, dt2);
+ /* re-apply acceleration to final location and velocity */
+ madd_v3_v3v3fl(pa->state.co, co, v0, dt2);
+ madd_v3_v3fl(pa->state.co, col->acc, 0.5f * dt2 * dt2);
+ madd_v3_v3v3fl(pa->state.vel, v0, col->acc, dt2);
- /* 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);
+ /* 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);
- if (distance < col->radius + COLLISION_MIN_DISTANCE) {
- madd_v3_v3fl(co, nor, col->radius + COLLISION_MIN_DISTANCE - distance);
- }
+ 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) {
- madd_v3_v3fl(v0, nor, -dot);
- }
+ dot = dot_v3v3(nor, v0);
+ if (dot < 0.f) {
+ 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.f, col, nor);
- if (distance < col->radius + COLLISION_MIN_DISTANCE) {
- madd_v3_v3fl(pa->state.co, nor, col->radius + COLLISION_MIN_DISTANCE - distance);
- }
+ 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) {
- madd_v3_v3fl(pa->state.vel, nor, -dot);
- }
+ dot = dot_v3v3(nor, pa->state.vel);
+ if (dot < 0.f) {
+ madd_v3_v3fl(pa->state.vel, nor, -dot);
}
+ }
- /* add stickiness to surface */
- madd_v3_v3fl(pa->state.vel, pce->nor, -pd->pdef_stickness);
+ /* add stickiness to surface */
+ madd_v3_v3fl(pa->state.vel, pce->nor, -pd->pdef_stickness);
- /* set coordinates for next iteration */
- copy_v3_v3(col->co1, co);
- copy_v3_v3(col->co2, pa->state.co);
+ /* set coordinates for next iteration */
+ copy_v3_v3(col->co1, co);
+ copy_v3_v3(col->co2, pa->state.co);
- copy_v3_v3(col->ve1, v0);
- copy_v3_v3(col->ve2, pa->state.vel);
+ copy_v3_v3(col->ve1, v0);
+ copy_v3_v3(col->ve2, pa->state.vel);
- col->f = f;
- }
+ col->f = f;
/* if permeability random roll succeeded, disable collider for this sim step */
if (through) {
@@ -3676,12 +3670,11 @@ static float sync_timestep(ParticleSystem *psys, float t_frac)
if (t_frac == 1.0f) {
return psys->dt_frac;
}
- else if (t_frac + (psys->dt_frac * TIMESTEP_EXPANSION_TOLERANCE) >= 1.0f) {
+ if (t_frac + (psys->dt_frac * TIMESTEP_EXPANSION_TOLERANCE) >= 1.0f) {
return 1.0f - t_frac;
}
- else {
- return psys->dt_frac;
- }
+
+ return psys->dt_frac;
}
/************************************************/
@@ -4372,7 +4365,7 @@ static void particles_fluid_step(ParticleSimulationData *sim,
max_size = MAX3(size[0] / (float)upres, size[1] / (float)upres, size[2] / (float)upres);
/* Set particle position. */
- float posParticle[3] = {posX, posY, posZ};
+ const float posParticle[3] = {posX, posY, posZ};
copy_v3_v3(pa->state.co, posParticle);
/* Normalize to unit cube around 0. */
@@ -4405,7 +4398,7 @@ static void particles_fluid_step(ParticleSimulationData *sim,
pa->state.co[0], pa->state.co[1], pa->state.co[2]);
# endif
/* Set particle velocity. */
- float velParticle[3] = {velX, velY, velZ};
+ const float velParticle[3] = {velX, velY, velZ};
copy_v3_v3(pa->state.vel, velParticle);
mul_v3_fl(pa->state.vel, fds->dx);
# if 0
@@ -4537,11 +4530,11 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
return;
}
/* Cache is supposed to be baked, but no data was found so bail out */
- else if (cache->flag & PTCACHE_BAKED) {
+ if (cache->flag & PTCACHE_BAKED) {
psys_reset(psys, PSYS_RESET_CACHE_MISS);
return;
}
- else if (cache_result == PTCACHE_READ_OLD) {
+ if (cache_result == PTCACHE_READ_OLD) {
psys->cfra = (float)cache->simframe;
cached_step(sim, psys->cfra, use_render_params);
}
@@ -4584,7 +4577,7 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
psys->dt_frac = get_base_time_step(part);
}
else if ((int)cfra == startframe) {
- /* Variable time step; initialise to subframes */
+ /* Variable time step; initialize to sub-frames. */
psys->dt_frac = get_base_time_step(part);
}
else if (psys->dt_frac < MIN_TIMESTEP) {
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 67988427bd2..1e4ea19adb6 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -109,18 +109,15 @@ int BB_widest_axis(const BB *bb)
if (dim[0] > dim[2]) {
return 0;
}
- else {
- return 2;
- }
+
+ return 2;
}
- else {
- if (dim[1] > dim[2]) {
- return 1;
- }
- else {
- return 2;
- }
+
+ if (dim[1] > dim[2]) {
+ return 1;
}
+
+ return 2;
}
void BBC_update_centroid(BBC *bbc)
@@ -275,9 +272,8 @@ static int map_insert_vert(
*value_p = POINTER_FROM_INT(value_i);
return value_i;
}
- else {
- return POINTER_AS_INT(*value_p);
- }
+
+ return POINTER_AS_INT(*value_p);
}
/* Find vertices used by the faces in this node and update the draw buffers */
@@ -644,7 +640,7 @@ void BKE_pbvh_build_grids(PBVH *pbvh,
pbvh->totgrid = totgrid;
pbvh->gridkey = *key;
pbvh->grid_hidden = grid_hidden;
- pbvh->leaf_limit = max_ii(LEAF_LIMIT / ((gridsize - 1) * (gridsize - 1)), 1);
+ pbvh->leaf_limit = max_ii(LEAF_LIMIT / (gridsize * gridsize), 1);
BB cb;
BB_reset(&cb);
@@ -804,14 +800,13 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter)
/* immediately hit leaf node */
return node;
}
- else {
- /* come back later when children are done */
- pbvh_stack_push(iter, node, true);
- /* push two child nodes on the stack */
- pbvh_stack_push(iter, iter->pbvh->nodes + node->children_offset + 1, false);
- pbvh_stack_push(iter, iter->pbvh->nodes + node->children_offset, false);
- }
+ /* come back later when children are done */
+ pbvh_stack_push(iter, node, true);
+
+ /* push two child nodes on the stack */
+ pbvh_stack_push(iter, iter->pbvh->nodes + node->children_offset + 1, false);
+ pbvh_stack_push(iter, iter->pbvh->nodes + node->children_offset, false);
}
return NULL;
@@ -838,10 +833,9 @@ static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter)
/* immediately hit leaf node */
return node;
}
- else {
- pbvh_stack_push(iter, iter->pbvh->nodes + node->children_offset + 1, false);
- pbvh_stack_push(iter, iter->pbvh->nodes + node->children_offset, false);
- }
+
+ pbvh_stack_push(iter, iter->pbvh->nodes + node->children_offset + 1, false);
+ pbvh_stack_push(iter, iter->pbvh->nodes + node->children_offset, false);
}
return NULL;
@@ -1391,16 +1385,15 @@ static int pbvh_flush_bb(PBVH *pbvh, PBVHNode *node, int flag)
return update;
}
- else {
- update |= pbvh_flush_bb(pbvh, pbvh->nodes + node->children_offset, flag);
- update |= pbvh_flush_bb(pbvh, pbvh->nodes + node->children_offset + 1, flag);
- if (update & PBVH_UpdateBB) {
- update_node_vb(pbvh, node);
- }
- if (update & PBVH_UpdateOriginalBB) {
- node->orig_vb = node->vb;
- }
+ update |= pbvh_flush_bb(pbvh, pbvh->nodes + node->children_offset, flag);
+ update |= pbvh_flush_bb(pbvh, pbvh->nodes + node->children_offset + 1, flag);
+
+ if (update & PBVH_UpdateBB) {
+ update_node_vb(pbvh, node);
+ }
+ if (update & PBVH_UpdateOriginalBB) {
+ node->orig_vb = node->vb;
}
return update;
@@ -1667,9 +1660,8 @@ bool BKE_pbvh_has_faces(const PBVH *pbvh)
if (pbvh->type == PBVH_BMESH) {
return (pbvh->bm->totface != 0);
}
- else {
- return (pbvh->totprim != 0);
- }
+
+ return (pbvh->totprim != 0);
}
void BKE_pbvh_bounding_box(const PBVH *pbvh, float min[3], float max[3])
@@ -2029,9 +2021,8 @@ bool ray_face_intersection_quad(const float ray_start[3],
*depth = depth_test;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
bool ray_face_intersection_tri(const float ray_start[3],
@@ -2047,9 +2038,8 @@ bool ray_face_intersection_tri(const float ray_start[3],
*depth = depth_test;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/* Take advantage of the fact we know this wont be an intersection.
@@ -2100,9 +2090,8 @@ bool ray_face_nearest_quad(const float ray_start[3],
}
return true;
}
- else {
- return false;
- }
+
+ return false;
}
bool ray_face_nearest_tri(const float ray_start[3],
@@ -2122,9 +2111,8 @@ bool ray_face_nearest_tri(const float ray_start[3],
*depth = depth_test;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
static bool pbvh_faces_node_raycast(PBVH *pbvh,
@@ -2357,7 +2345,7 @@ void BKE_pbvh_raycast_project_ray_root(
struct IsectRayAABB_Precalc ray;
float ray_normal_inv[3];
float offset = 1.0f + 1e-3f;
- float offset_vec[3] = {1e-3f, 1e-3f, 1e-3f};
+ const float offset_vec[3] = {1e-3f, 1e-3f, 1e-3f};
if (original) {
BKE_pbvh_node_get_original_BB(pbvh->nodes, bb_min_root, bb_max_root);
@@ -2617,7 +2605,7 @@ static PlaneAABBIsect test_frustum_aabb(const float bb_min[3],
if (dot_v3v3(planes[i], vmin) + planes[i][3] < 0) {
return ISECT_OUTSIDE;
}
- else if (dot_v3v3(planes[i], vmax) + planes[i][3] <= 0) {
+ if (dot_v3v3(planes[i], vmax) + planes[i][3] <= 0) {
ret = ISECT_INTERSECT;
}
}
@@ -2924,7 +2912,7 @@ PBVHColorBufferNode *BKE_pbvh_node_color_buffer_get(PBVHNode *node)
{
if (!node->color_buffer.color) {
- node->color_buffer.color = MEM_callocN(node->uniq_verts * sizeof(float) * 4, "Color buffer");
+ node->color_buffer.color = MEM_callocN(sizeof(float[4]) * node->uniq_verts, "Color buffer");
}
return &node->color_buffer;
}
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index e87c7c8d46d..a04fa1506d0 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -184,14 +184,13 @@ static BMVert *bm_vert_hash_lookup_chain(GHash *deleted_verts, BMVert *v)
/* not remapped*/
return v;
}
- else if (*v_next_p == NULL) {
+ if (*v_next_p == NULL) {
/* removed and not remapped */
return NULL;
}
- else {
- /* remapped */
- v = *v_next_p;
- }
+
+ /* remapped */
+ v = *v_next_p;
}
}
@@ -1738,9 +1737,8 @@ static void pbvh_bmesh_node_limit_ensure_fast(
candidate = i_iter;
break;
}
- else {
- num_child2++;
- }
+
+ num_child2++;
}
if (candidate != -1) {
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h
index 6f8bae822ea..63bc8753fc7 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __PBVH_INTERN_H__
-#define __PBVH_INTERN_H__
+#pragma once
/** \file
* \ingroup bli
@@ -235,5 +234,3 @@ bool pbvh_bmesh_node_nearest_to_ray(PBVHNode *node,
bool use_original);
void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode);
-
-#endif
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 4b09f7542c7..64e642462af 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -126,19 +126,19 @@ static CLG_LogRef LOG = {"bke.pointcache"};
static int ptcache_data_size[] = {
sizeof(unsigned int), // BPHYS_DATA_INDEX
- 3 * sizeof(float), // BPHYS_DATA_LOCATION
- 3 * sizeof(float), // BPHYS_DATA_VELOCITY
- 4 * sizeof(float), // BPHYS_DATA_ROTATION
- 3 * sizeof(float), // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST
+ sizeof(float[3]), // BPHYS_DATA_LOCATION
+ sizeof(float[3]), // BPHYS_DATA_VELOCITY
+ sizeof(float[4]), // BPHYS_DATA_ROTATION
+ sizeof(float[3]), // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST
sizeof(float), // BPHYS_DATA_SIZE
- 3 * sizeof(float), // BPHYS_DATA_TIMES
+ sizeof(float[3]), // BPHYS_DATA_TIMES
sizeof(BoidData), // case BPHYS_DATA_BOIDS
};
static int ptcache_extra_datasize[] = {
0,
sizeof(ParticleSpring),
- sizeof(float) * 3,
+ sizeof(float[3]),
};
/* forward declarations */
@@ -212,8 +212,8 @@ static void ptcache_softbody_read(
BodyPoint *bp = soft->bpoint + index;
if (old_data) {
- memcpy(bp->pos, data, 3 * sizeof(float));
- memcpy(bp->vec, data + 3, 3 * sizeof(float));
+ memcpy(bp->pos, data, sizeof(float[3]));
+ memcpy(bp->vec, data + 3, sizeof(float[3]));
}
else {
PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, bp->pos);
@@ -241,8 +241,8 @@ static void ptcache_softbody_interpolate(int index,
copy_v3_v3(keys[1].vel, bp->vec);
if (old_data) {
- memcpy(keys[2].co, old_data, 3 * sizeof(float));
- memcpy(keys[2].vel, old_data + 3, 3 * sizeof(float));
+ memcpy(keys[2].co, old_data, sizeof(float[3]));
+ memcpy(keys[2].vel, old_data + 3, sizeof(float[3]));
}
else {
BKE_ptcache_make_particle_key(keys + 2, 0, data, cfra2);
@@ -545,9 +545,9 @@ static void ptcache_cloth_read(
ClothVertex *vert = cloth->verts + index;
if (old_data) {
- memcpy(vert->x, data, 3 * sizeof(float));
- memcpy(vert->xconst, data + 3, 3 * sizeof(float));
- memcpy(vert->v, data + 6, 3 * sizeof(float));
+ memcpy(vert->x, data, sizeof(float[3]));
+ memcpy(vert->xconst, data + 3, sizeof(float[3]));
+ memcpy(vert->v, data + 6, sizeof(float[3]));
}
else {
PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, vert->x);
@@ -577,8 +577,8 @@ static void ptcache_cloth_interpolate(int index,
copy_v3_v3(keys[1].vel, vert->v);
if (old_data) {
- memcpy(keys[2].co, old_data, 3 * sizeof(float));
- memcpy(keys[2].vel, old_data + 6, 3 * sizeof(float));
+ memcpy(keys[2].co, old_data, sizeof(float[3]));
+ memcpy(keys[2].vel, old_data + 6, sizeof(float[3]));
}
else {
BKE_ptcache_make_particle_key(keys + 2, 0, data, cfra2);
@@ -1404,9 +1404,8 @@ static int ptcache_dynamicpaint_totpoint(void *sd, int UNUSED(cfra))
if (!surface->data) {
return 0;
}
- else {
- return surface->data->total_points;
- }
+
+ return surface->data->total_points;
}
static void ptcache_dynamicpaint_error(void *UNUSED(sd), const char *UNUSED(message))
@@ -1422,7 +1421,7 @@ static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
int cache_compress = 1;
/* version header */
- ptcache_file_write(pf, DPAINT_CACHE_VERSION, 1, sizeof(char) * 4);
+ ptcache_file_write(pf, DPAINT_CACHE_VERSION, 1, sizeof(char[4]));
if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
int total_points = surface->data->total_points;
@@ -1460,7 +1459,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
char version[4];
/* version header */
- ptcache_file_read(pf, version, 1, sizeof(char) * 4);
+ ptcache_file_read(pf, version, 1, sizeof(char[4]));
if (!STREQLEN(version, DPAINT_CACHE_VERSION, 4)) {
CLOG_ERROR(&LOG, "Dynamic Paint: Invalid cache version: '%c%c%c%c'!", UNPACK4(version));
return 0;
@@ -1511,7 +1510,7 @@ static int ptcache_rigidbody_write(int index, void *rb_v, void **data, int UNUSE
if (ob && ob->rigidbody_object) {
RigidBodyOb *rbo = ob->rigidbody_object;
- if (rbo->type == RBO_TYPE_ACTIVE) {
+ if (rbo->type == RBO_TYPE_ACTIVE && rbo->shared->physics_object != NULL) {
#ifdef WITH_BULLET
RB_body_get_position(rbo->shared->physics_object, rbo->pos);
RB_body_get_orientation(rbo->shared->physics_object, rbo->orn);
@@ -1539,8 +1538,8 @@ static void ptcache_rigidbody_read(
if (rbo->type == RBO_TYPE_ACTIVE) {
if (old_data) {
- memcpy(rbo->pos, data, 3 * sizeof(float));
- memcpy(rbo->orn, data + 3, 4 * sizeof(float));
+ memcpy(rbo->pos, data, sizeof(float[3]));
+ memcpy(rbo->orn, data + 3, sizeof(float[4]));
}
else {
PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, rbo->pos);
@@ -1578,8 +1577,8 @@ static void ptcache_rigidbody_interpolate(int index,
copy_qt_qt(keys[1].rot, rbo->orn);
if (old_data) {
- memcpy(keys[2].co, data, 3 * sizeof(float));
- memcpy(keys[2].rot, data + 3, 4 * sizeof(float));
+ memcpy(keys[2].co, data, sizeof(float[3]));
+ memcpy(keys[2].rot, data + 3, sizeof(float[4]));
}
else {
BKE_ptcache_make_particle_key(&keys[2], 0, data, cfra2);
@@ -2128,7 +2127,7 @@ static int ptcache_path(PTCacheID *pid, char *filename)
return BLI_path_slash_ensure(filename); /* new strlen() */
}
- else if (G.relbase_valid || lib) {
+ if (G.relbase_valid || lib) {
char file[MAX_PTCACHE_PATH]; /* we don't want the dir, only the file */
BLI_split_file_part(blendfilename, file, sizeof(file));
@@ -2277,7 +2276,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result,
size_t out_len = len;
#endif
unsigned char *in;
- unsigned char *props = MEM_callocN(16 * sizeof(char), "tmp");
+ unsigned char *props = MEM_callocN(sizeof(char[16]), "tmp");
ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char));
if (compressed) {
@@ -2323,7 +2322,7 @@ static int ptcache_file_compressed_write(
int r = 0;
unsigned char compressed = 0;
size_t out_len = 0;
- unsigned char *props = MEM_callocN(16 * sizeof(char), "tmp");
+ unsigned char *props = MEM_callocN(sizeof(char[16]), "tmp");
size_t sizeOfIt = 5;
(void)mode; /* unused when building w/o compression */
@@ -2521,9 +2520,8 @@ int BKE_ptcache_mem_index_find(PTCacheMem *pm, unsigned int index)
return -1;
}
- else {
- return (index < pm->totpoint ? index : -1);
- }
+
+ return (index < pm->totpoint ? index : -1);
}
void BKE_ptcache_mem_pointers_init(PTCacheMem *pm)
@@ -2625,13 +2623,13 @@ static void ptcache_mem_clear(PTCacheMem *pm)
static int ptcache_old_elemsize(PTCacheID *pid)
{
if (pid->type == PTCACHE_TYPE_SOFTBODY) {
- return 6 * sizeof(float);
+ return sizeof(float[6]);
}
- else if (pid->type == PTCACHE_TYPE_PARTICLES) {
+ if (pid->type == PTCACHE_TYPE_PARTICLES) {
return sizeof(ParticleKey);
}
- else if (pid->type == PTCACHE_TYPE_CLOTH) {
- return 9 * sizeof(float);
+ if (pid->type == PTCACHE_TYPE_CLOTH) {
+ return sizeof(float[9]);
}
return 0;
@@ -3585,16 +3583,15 @@ int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
return BLI_exists(filename);
}
- else {
- PTCacheMem *pm = pid->cache->mem_cache.first;
- for (; pm; pm = pm->next) {
- if (pm->frame == cfra) {
- return 1;
- }
+ PTCacheMem *pm = pid->cache->mem_cache.first;
+
+ for (; pm; pm = pm->next) {
+ if (pm->frame == cfra) {
+ return 1;
}
- return 0;
}
+ return 0;
}
void BKE_ptcache_id_time(
PTCacheID *pid, Scene *scene, float cfra, int *startframe, int *endframe, float *timescale)
diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c
index df5d93beccb..21889acba3c 100644
--- a/source/blender/blenkernel/intern/pointcloud.c
+++ b/source/blender/blenkernel/intern/pointcloud.c
@@ -169,8 +169,8 @@ BoundBox *BKE_pointcloud_boundbox_get(Object *ob)
for (int a = 0; a < pointcloud->totpoint; a++) {
float *co = pointcloud_co[a];
float radius = (pointcloud_radius) ? pointcloud_radius[a] : 0.0f;
- float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius};
- float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius};
+ const float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius};
+ const float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius};
DO_MIN(co_min, min);
DO_MAX(co_max, max);
}
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 4752782eaeb..ece7d0f9136 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -466,10 +466,10 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
return shape;
}
-/* Create new physics sim collision shape for object and store it,
- * or remove the existing one first and replace...
+/* Helper function to create physics collision shape for object.
+ * Returns a new collision shape.
*/
-static void rigidbody_validate_sim_shape(Object *ob, bool rebuild)
+static rbCollisionShape *rigidbody_validate_sim_shape_helper(RigidBodyWorld *rbw, Object *ob)
{
RigidBodyOb *rbo = ob->rigidbody_object;
rbCollisionShape *new_shape = NULL;
@@ -484,12 +484,7 @@ static void rigidbody_validate_sim_shape(Object *ob, bool rebuild)
/* sanity check */
if (rbo == NULL) {
- return;
- }
-
- /* don't create a new shape if we already have one and don't want to rebuild it */
- if (rbo->shared->physics_shape && !rebuild) {
- return;
+ return NULL;
}
/* if automatically determining dimensions, use the Object's boundbox
@@ -539,7 +534,7 @@ static void rigidbody_validate_sim_shape(Object *ob, bool rebuild)
break;
case RB_SHAPE_CONVEXH:
- /* try to emged collision margin */
+ /* try to embed collision margin */
has_volume = (MIN3(size[0], size[1], size[2]) > 0.0f);
if (!(rbo->flag & RBO_FLAG_USE_MARGIN) && has_volume) {
@@ -555,18 +550,69 @@ static void rigidbody_validate_sim_shape(Object *ob, bool rebuild)
case RB_SHAPE_TRIMESH:
new_shape = rigidbody_get_shape_trimesh_from_mesh(ob);
break;
+ case RB_SHAPE_COMPOUND:
+ new_shape = RB_shape_new_compound();
+ rbCollisionShape *childShape = NULL;
+ float loc[3], rot[4];
+ float mat[4][4];
+ /* Add children to the compound shape */
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->group, childObject) {
+ if (childObject->parent == ob) {
+ childShape = rigidbody_validate_sim_shape_helper(rbw, childObject);
+ if (childShape) {
+ BKE_object_matrix_local_get(childObject, mat);
+ mat4_to_loc_quat(loc, rot, mat);
+ RB_compound_add_child_shape(new_shape, childShape, loc, rot);
+ }
+ }
+ }
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
+
+ break;
}
- /* use box shape if we can't fall back to old shape */
- if (new_shape == NULL && rbo->shared->physics_shape == NULL) {
+ /* use box shape if it failed to create new shape */
+ if (new_shape == NULL) {
new_shape = RB_shape_new_box(size[0], size[1], size[2]);
}
+ if (new_shape) {
+ RB_shape_set_margin(new_shape, RBO_GET_MARGIN(rbo));
+ }
+
+ return new_shape;
+}
+
+/* Create new physics sim collision shape for object and store it,
+ * or remove the existing one first and replace...
+ */
+static void rigidbody_validate_sim_shape(RigidBodyWorld *rbw, Object *ob, bool rebuild)
+{
+ RigidBodyOb *rbo = ob->rigidbody_object;
+ rbCollisionShape *new_shape = NULL;
+
+ /* sanity check */
+ if (rbo == NULL) {
+ return;
+ }
+
+ /* don't create a new shape if we already have one and don't want to rebuild it */
+ if (rbo->shared->physics_shape && !rebuild) {
+ return;
+ }
+
+ /* Also don't create a shape if this object is parent of a compound shape */
+ if (ob->parent != NULL && ob->parent->rigidbody_object != NULL &&
+ ob->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) {
+ return;
+ }
+
+ new_shape = rigidbody_validate_sim_shape_helper(rbw, ob);
+
/* assign new collision shape if creation was successful */
if (new_shape) {
if (rbo->shared->physics_shape) {
RB_shape_delete(rbo->shared->physics_shape);
}
rbo->shared->physics_shape = new_shape;
- RB_shape_set_margin(rbo->shared->physics_shape, RBO_GET_MARGIN(rbo));
}
}
@@ -750,7 +796,7 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool
/* FIXME we shouldn't always have to rebuild collision shapes when rebuilding objects,
* but it's needed for constraints to update correctly. */
if (rbo->shared->physics_shape == NULL || rebuild) {
- rigidbody_validate_sim_shape(ob, true);
+ rigidbody_validate_sim_shape(rbw, ob, true);
}
if (rbo->shared->physics_object) {
@@ -760,6 +806,12 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool
/* remove rigid body if it already exists before creating a new one */
if (rbo->shared->physics_object) {
RB_body_delete(rbo->shared->physics_object);
+ rbo->shared->physics_object = NULL;
+ }
+ /* Don't create rigid body object if the parent is a compound shape */
+ if (ob->parent != NULL && ob->parent->rigidbody_object != NULL &&
+ ob->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) {
+ return;
}
mat4_to_loc_quat(loc, rot, ob->obmat);
@@ -793,7 +845,7 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool
rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
}
- if (rbw && rbw->shared->physics_world) {
+ if (rbw && rbw->shared->physics_world && rbo->shared->physics_object) {
RB_dworld_add_body(rbw->shared->physics_world, rbo->shared->physics_object, rbo->col_groups);
}
}
@@ -1179,9 +1231,12 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type)
* - object must exist
* - cannot add rigid body if it already exists
*/
- if (ob == NULL || (ob->rigidbody_object != NULL)) {
+ if (ob == NULL) {
return NULL;
}
+ if (ob->rigidbody_object != NULL) {
+ return ob->rigidbody_object;
+ }
/* create new settings data, and link it up */
rbo = MEM_callocN(sizeof(RigidBodyOb), "RigidBodyOb");
@@ -1530,7 +1585,11 @@ static void rigidbody_update_ob_array(RigidBodyWorld *rbw)
int n = 0;
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->group, object) {
(void)object;
- n++;
+ /* Ignore if this object is the direct child of an object with a compound shape */
+ if (object->parent == NULL || object->parent->rigidbody_object == NULL ||
+ object->parent->rigidbody_object->shape != RB_SHAPE_COMPOUND) {
+ n++;
+ }
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
@@ -1541,8 +1600,12 @@ static void rigidbody_update_ob_array(RigidBodyWorld *rbw)
int i = 0;
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->group, object) {
- rbw->objects[i] = object;
- i++;
+ /* Ignore if this object is the direct child of an object with a compound shape */
+ if (object->parent == NULL || object->parent->rigidbody_object == NULL ||
+ object->parent->rigidbody_object->shape != RB_SHAPE_COMPOUND) {
+ rbw->objects[i] = object;
+ i++;
+ }
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
@@ -1754,11 +1817,13 @@ static void rigidbody_update_simulation(Depsgraph *depsgraph,
/* refresh shape... */
if (rbo->flag & RBO_FLAG_NEEDS_RESHAPE) {
/* mesh/shape data changed, so force shape refresh */
- rigidbody_validate_sim_shape(ob, true);
+ rigidbody_validate_sim_shape(rbw, ob, true);
/* now tell RB sim about it */
/* XXX: we assume that this can only get applied for active/passive shapes
* that will be included as rigidbodies. */
- RB_body_set_collision_shape(rbo->shared->physics_object, rbo->shared->physics_shape);
+ if (rbo->shared->physics_object != NULL && rbo->shared->physics_shape != NULL) {
+ RB_body_set_collision_shape(rbo->shared->physics_object, rbo->shared->physics_shape);
+ }
}
}
rbo->flag &= ~(RBO_FLAG_NEEDS_VALIDATE | RBO_FLAG_NEEDS_RESHAPE);
@@ -1817,7 +1882,8 @@ static void rigidbody_update_simulation_post_step(Depsgraph *depsgraph, RigidBod
Base *base = BKE_view_layer_base_find(view_layer, ob);
RigidBodyOb *rbo = ob->rigidbody_object;
/* Reset kinematic state for transformed objects. */
- if (rbo && base && (base->flag & BASE_SELECTED) && (G.moving & G_TRANSFORM_OBJ)) {
+ if (rbo && base && (base->flag & BASE_SELECTED) && (G.moving & G_TRANSFORM_OBJ) &&
+ rbo->shared->physics_object) {
RB_body_set_kinematic_state(rbo->shared->physics_object,
rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
RB_body_set_mass(rbo->shared->physics_object, RBO_GET_MASS(rbo));
@@ -1840,8 +1906,13 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime)
{
RigidBodyOb *rbo = ob->rigidbody_object;
+ /* True if the shape of this object's parent is of type compound */
+ bool obCompoundParent = (ob->parent != NULL && ob->parent->rigidbody_object != NULL &&
+ ob->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND);
+
/* keep original transform for kinematic and passive objects */
- if (ELEM(NULL, rbw, rbo) || rbo->flag & RBO_FLAG_KINEMATIC || rbo->type == RBO_TYPE_PASSIVE) {
+ if (ELEM(NULL, rbw, rbo) || rbo->flag & RBO_FLAG_KINEMATIC || rbo->type == RBO_TYPE_PASSIVE ||
+ obCompoundParent) {
return;
}
@@ -1963,7 +2034,11 @@ void BKE_rigidbody_rebuild_world(Depsgraph *depsgraph, Scene *scene, float ctime
int n = 0;
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->group, object) {
(void)object;
- n++;
+ /* Ignore if this object is the direct child of an object with a compound shape */
+ if (object->parent == NULL || object->parent->rigidbody_object == NULL ||
+ object->parent->rigidbody_object->shape != RB_SHAPE_COMPOUND) {
+ n++;
+ }
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
@@ -2000,7 +2075,7 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
return;
}
/* make sure we don't go out of cache frame range */
- else if (ctime > endframe) {
+ if (ctime > endframe) {
ctime = endframe;
}
@@ -2008,7 +2083,7 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
if (rbw->shared->physics_world == NULL && !(cache->flag & PTCACHE_BAKED)) {
return;
}
- else if (rbw->objects == NULL) {
+ if (rbw->objects == NULL) {
rigidbody_update_ob_array(rbw);
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 5ae2f4b9005..bdda03bab12 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -127,7 +127,7 @@ static void scene_init_data(ID *id)
mblur_shutter_curve = &scene->r.mblur_shutter_curve;
BKE_curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(mblur_shutter_curve);
+ BKE_curvemapping_init(mblur_shutter_curve);
BKE_curvemap_reset(mblur_shutter_curve->cm,
&mblur_shutter_curve->clipr,
CURVE_PRESET_MAX,
@@ -140,13 +140,13 @@ static void scene_init_data(ID *id)
/* grease pencil multiframe falloff curve */
scene->toolsettings->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
CurveMapping *gp_falloff_curve = scene->toolsettings->gp_sculpt.cur_falloff;
- BKE_curvemapping_initialize(gp_falloff_curve);
+ BKE_curvemapping_init(gp_falloff_curve);
BKE_curvemap_reset(
gp_falloff_curve->cm, &gp_falloff_curve->clipr, CURVE_PRESET_GAUSS, CURVEMAP_SLOPE_POSITIVE);
scene->toolsettings->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
CurveMapping *gp_primitive_curve = scene->toolsettings->gp_sculpt.cur_primitive;
- BKE_curvemapping_initialize(gp_primitive_curve);
+ BKE_curvemapping_init(gp_primitive_curve);
BKE_curvemap_reset(gp_primitive_curve->cm,
&gp_primitive_curve->clipr,
CURVE_PRESET_BELL,
@@ -839,83 +839,78 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
return sce_copy;
}
- else {
- eDupli_ID_Flags duplicate_flags = U.dupflag | USER_DUP_OBJECT;
- BKE_id_copy(bmain, (ID *)sce, (ID **)&sce_copy);
- id_us_min(&sce_copy->id);
- id_us_ensure_real(&sce_copy->id);
+ eDupli_ID_Flags duplicate_flags = U.dupflag | USER_DUP_OBJECT;
- BKE_animdata_duplicate_id_action(bmain, &sce_copy->id, duplicate_flags);
+ BKE_id_copy(bmain, (ID *)sce, (ID **)&sce_copy);
+ id_us_min(&sce_copy->id);
+ id_us_ensure_real(&sce_copy->id);
- /* Extra actions, most notably SCE_FULL_COPY also duplicates several 'children' datablocks. */
+ BKE_animdata_duplicate_id_action(bmain, &sce_copy->id, duplicate_flags);
- if (type == SCE_COPY_FULL) {
- /* Scene duplication is always root of duplication currently. */
- const bool is_subprocess = false;
+ /* Extra actions, most notably SCE_FULL_COPY also duplicates several 'children' datablocks. */
- if (!is_subprocess) {
- BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false);
- BKE_main_id_clear_newpoins(bmain);
- /* In case root duplicated ID is linked, assume we want to get a local copy of it and
- * duplicate all expected linked data. */
- if (ID_IS_LINKED(sce)) {
- duplicate_flags |= USER_DUP_LINKED_ID;
- }
+ if (type == SCE_COPY_FULL) {
+ /* Scene duplication is always root of duplication currently. */
+ const bool is_subprocess = false;
+
+ if (!is_subprocess) {
+ BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false);
+ BKE_main_id_clear_newpoins(bmain);
+ /* In case root duplicated ID is linked, assume we want to get a local copy of it and
+ * duplicate all expected linked data. */
+ if (ID_IS_LINKED(sce)) {
+ duplicate_flags |= USER_DUP_LINKED_ID;
}
+ }
- /* Copy Freestyle LineStyle datablocks. */
- LISTBASE_FOREACH (ViewLayer *, view_layer_dst, &sce_copy->view_layers) {
- LISTBASE_FOREACH (
- FreestyleLineSet *, lineset, &view_layer_dst->freestyle_config.linesets) {
- BKE_id_copy_for_duplicate(bmain, (ID *)lineset->linestyle, duplicate_flags);
- }
+ /* Copy Freestyle LineStyle datablocks. */
+ LISTBASE_FOREACH (ViewLayer *, view_layer_dst, &sce_copy->view_layers) {
+ LISTBASE_FOREACH (FreestyleLineSet *, lineset, &view_layer_dst->freestyle_config.linesets) {
+ BKE_id_copy_for_duplicate(bmain, (ID *)lineset->linestyle, duplicate_flags);
}
+ }
- /* Full copy of world (included animations) */
- BKE_id_copy_for_duplicate(bmain, (ID *)sce->world, duplicate_flags);
+ /* Full copy of world (included animations) */
+ BKE_id_copy_for_duplicate(bmain, (ID *)sce->world, duplicate_flags);
- /* Full copy of GreasePencil. */
- BKE_id_copy_for_duplicate(bmain, (ID *)sce->gpd, duplicate_flags);
+ /* Full copy of GreasePencil. */
+ BKE_id_copy_for_duplicate(bmain, (ID *)sce->gpd, duplicate_flags);
- /* Deep-duplicate collections and objects (using preferences' settings for which sub-data to
- * duplicate along the object itself). */
- BKE_collection_duplicate(bmain,
- NULL,
- sce_copy->master_collection,
- duplicate_flags,
- LIB_ID_DUPLICATE_IS_SUBPROCESS);
+ /* Deep-duplicate collections and objects (using preferences' settings for which sub-data to
+ * duplicate along the object itself). */
+ BKE_collection_duplicate(
+ bmain, NULL, sce_copy->master_collection, duplicate_flags, LIB_ID_DUPLICATE_IS_SUBPROCESS);
- if (!is_subprocess) {
- /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW.*/
- BKE_libblock_relink_to_newid(&sce_copy->id);
+ if (!is_subprocess) {
+ /* This code will follow into all ID links using an ID tagged with LIB_TAG_NEW.*/
+ BKE_libblock_relink_to_newid(&sce_copy->id);
#ifndef NDEBUG
- /* Call to `BKE_libblock_relink_to_newid` above is supposed to have cleared all those
- * flags. */
- ID *id_iter;
- FOREACH_MAIN_ID_BEGIN (bmain, id_iter) {
- BLI_assert((id_iter->tag & LIB_TAG_NEW) == 0);
- }
- FOREACH_MAIN_ID_END;
+ /* Call to `BKE_libblock_relink_to_newid` above is supposed to have cleared all those
+ * flags. */
+ ID *id_iter;
+ FOREACH_MAIN_ID_BEGIN (bmain, id_iter) {
+ BLI_assert((id_iter->tag & LIB_TAG_NEW) == 0);
+ }
+ FOREACH_MAIN_ID_END;
#endif
- /* Cleanup. */
- BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false);
- BKE_main_id_clear_newpoins(bmain);
+ /* Cleanup. */
+ BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false);
+ BKE_main_id_clear_newpoins(bmain);
- BKE_main_collection_sync(bmain);
- }
+ BKE_main_collection_sync(bmain);
}
- else {
- /* Remove sequencer if not full copy */
- /* XXX Why in Hell? :/ */
- remove_sequencer_fcurves(sce_copy);
- BKE_sequencer_editing_free(sce_copy, true);
- }
-
- return sce_copy;
}
+ else {
+ /* Remove sequencer if not full copy */
+ /* XXX Why in Hell? :/ */
+ remove_sequencer_fcurves(sce_copy);
+ BKE_sequencer_editing_free(sce_copy, true);
+ }
+
+ return sce_copy;
}
void BKE_scene_groups_relink(Scene *sce)
@@ -1642,7 +1637,7 @@ bool BKE_scene_remove_render_view(Scene *scene, SceneRenderView *srv)
if (act == -1) {
return false;
}
- else if (scene->r.views.first == scene->r.views.last) {
+ if (scene->r.views.first == scene->r.views.last) {
/* ensure 1 view is kept */
return false;
}
@@ -1663,13 +1658,11 @@ int get_render_subsurf_level(const RenderData *r, int lvl, bool for_render)
if (for_render) {
return min_ii(r->simplify_subsurf_render, lvl);
}
- else {
- return min_ii(r->simplify_subsurf, lvl);
- }
- }
- else {
- return lvl;
+
+ return min_ii(r->simplify_subsurf, lvl);
}
+
+ return lvl;
}
int get_render_child_particle_number(const RenderData *r, int num, bool for_render)
@@ -1678,13 +1671,11 @@ int get_render_child_particle_number(const RenderData *r, int num, bool for_rend
if (for_render) {
return (int)(r->simplify_particles_render * num);
}
- else {
- return (int)(r->simplify_particles * num);
- }
- }
- else {
- return num;
+
+ return (int)(r->simplify_particles * num);
}
+
+ return num;
}
/**
@@ -1699,7 +1690,7 @@ Base *_setlooper_base_step(Scene **sce_iter, ViewLayer *view_layer, Base *base)
/* Common case, step to the next. */
return base->next;
}
- else if ((base == NULL) && (view_layer != NULL)) {
+ if ((base == NULL) && (view_layer != NULL)) {
/* First time looping, return the scenes first base. */
/* For the first loop we should get the layer from workspace when available. */
if (view_layer->object_bases.first) {
@@ -2018,9 +2009,8 @@ const char *BKE_scene_multiview_render_view_name_get(const RenderData *rd, const
if (srv) {
return srv->name;
}
- else {
- return "";
- }
+
+ return "";
}
int BKE_scene_multiview_view_id_get(const RenderData *rd, const char *viewname)
@@ -2041,9 +2031,8 @@ int BKE_scene_multiview_view_id_get(const RenderData *rd, const char *viewname)
if (STREQ(viewname, srv->name)) {
return nr;
}
- else {
- nr += 1;
- }
+
+ nr += 1;
}
}
@@ -2094,9 +2083,8 @@ const char *BKE_scene_multiview_view_suffix_get(const RenderData *rd, const char
if (srv) {
return srv->suffix;
}
- else {
- return viewname;
- }
+
+ return viewname;
}
const char *BKE_scene_multiview_view_id_suffix_get(const RenderData *rd, const int view_id)
@@ -2104,10 +2092,9 @@ const char *BKE_scene_multiview_view_id_suffix_get(const RenderData *rd, const i
if ((rd->scemode & R_MULTIVIEW) == 0) {
return "";
}
- else {
- const char *viewname = BKE_scene_multiview_render_view_name_get(rd, view_id);
- return BKE_scene_multiview_view_suffix_get(rd, viewname);
- }
+
+ const char *viewname = BKE_scene_multiview_render_view_name_get(rd, view_id);
+ return BKE_scene_multiview_view_suffix_get(rd, viewname);
}
void BKE_scene_multiview_view_prefix_get(Scene *scene,
@@ -2175,10 +2162,9 @@ int BKE_scene_multiview_num_videos_get(const RenderData *rd)
if (rd->im_format.views_format == R_IMF_VIEWS_STEREO_3D) {
return 1;
}
- else {
- /* R_IMF_VIEWS_INDIVIDUAL */
- return BKE_scene_multiview_num_views_get(rd);
- }
+
+ /* R_IMF_VIEWS_INDIVIDUAL */
+ return BKE_scene_multiview_num_views_get(rd);
}
/* Manipulation of depsgraph storage. */
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index c510b3a2dfb..3a49c180172 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -159,15 +159,15 @@ void BKE_screen_foreach_id_screen_area(LibraryForeachIDData *data, ScrArea *area
break;
}
case SPACE_OUTLINER: {
- SpaceOutliner *so = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
- BKE_LIB_FOREACHID_PROCESS_ID(data, so->search_tse.id, IDWALK_CB_NOP);
+ BKE_LIB_FOREACHID_PROCESS_ID(data, space_outliner->search_tse.id, IDWALK_CB_NOP);
- if (so->treestore != NULL) {
+ if (space_outliner->treestore != NULL) {
TreeStoreElem *tselem;
BLI_mempool_iter iter;
- BLI_mempool_iternew(so->treestore, &iter);
+ BLI_mempool_iternew(space_outliner->treestore, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
BKE_LIB_FOREACHID_PROCESS_ID(data, tselem->id, IDWALK_CB_NOP);
}
diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c
index 5c2d5b0087f..3d1f33190dc 100644
--- a/source/blender/blenkernel/intern/seqcache.c
+++ b/source/blender/blenkernel/intern/seqcache.c
@@ -444,7 +444,7 @@ static void seq_disk_cache_delete_invalid_files(SeqDiskCache *disk_cache,
while (cache_file) {
next_file = cache_file->next;
if (cache_file->cache_type & invalidate_types) {
- if (strcmp(cache_dir, cache_file->dir) == 0) {
+ 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) {
seq_disk_cache_delete_file(disk_cache, cache_file);
@@ -483,10 +483,9 @@ static size_t deflate_imbuf_to_file(ImBuf *ibuf,
return BLI_gzip_mem_to_file_at_pos(
ibuf->rect, header_entry->size_raw, file, header_entry->offset, level);
}
- else {
- return BLI_gzip_mem_to_file_at_pos(
- ibuf->rect_float, header_entry->size_raw, file, header_entry->offset, level);
- }
+
+ return BLI_gzip_mem_to_file_at_pos(
+ ibuf->rect_float, header_entry->size_raw, file, header_entry->offset, level);
}
static size_t inflate_file_to_imbuf(ImBuf *ibuf, FILE *file, DiskCacheHeaderEntry *header_entry)
@@ -495,10 +494,9 @@ static size_t inflate_file_to_imbuf(ImBuf *ibuf, FILE *file, DiskCacheHeaderEntr
return BLI_ungzip_file_to_mem_at_pos(
ibuf->rect, header_entry->size_raw, file, header_entry->offset);
}
- else {
- return BLI_ungzip_file_to_mem_at_pos(
- ibuf->rect_float, header_entry->size_raw, file, header_entry->offset);
- }
+
+ return BLI_ungzip_file_to_mem_at_pos(
+ ibuf->rect_float, header_entry->size_raw, file, header_entry->offset);
}
static void seq_disk_cache_read_header(FILE *file, DiskCacheHeader *header)
@@ -1304,11 +1302,10 @@ bool BKE_sequencer_cache_put_if_possible(const SeqRenderData *context,
BKE_sequencer_cache_put(context, seq, cfra, type, ibuf, cost, skip_disk_cache);
return true;
}
- else {
- seq_cache_set_temp_cache_linked(scene, scene->ed->cache->last_key);
- scene->ed->cache->last_key = NULL;
- return false;
- }
+
+ seq_cache_set_temp_cache_linked(scene, scene->ed->cache->last_key);
+ scene->ed->cache->last_key = NULL;
+ return false;
}
void BKE_sequencer_cache_put(const SeqRenderData *context,
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 4a2ad88bb28..afec9b835a5 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -303,10 +303,10 @@ static void do_alphaover_effect_float(
mfac = 1.0f - (fac2 * rt1[3]);
if (fac <= 0.0f) {
- memcpy(rt, rt2, 4 * sizeof(float));
+ memcpy(rt, rt2, sizeof(float[4]));
}
else if (mfac <= 0) {
- memcpy(rt, rt1, 4 * sizeof(float));
+ memcpy(rt, rt1, sizeof(float[4]));
}
else {
rt[0] = fac * rt1[0] + mfac * rt2[0];
@@ -330,10 +330,10 @@ static void do_alphaover_effect_float(
mfac = 1.0f - (fac4 * rt1[3]);
if (fac <= 0.0f) {
- memcpy(rt, rt2, 4 * sizeof(float));
+ memcpy(rt, rt2, sizeof(float[4]));
}
else if (mfac <= 0.0f) {
- memcpy(rt, rt1, 4 * sizeof(float));
+ memcpy(rt, rt1, sizeof(float[4]));
}
else {
rt[0] = fac * rt1[0] + mfac * rt2[0];
@@ -499,16 +499,16 @@ static void do_alphaunder_effect_float(
* 'skybuf' can be crossed in
*/
if (rt2[3] <= 0 && fac2 >= 1.0f) {
- memcpy(rt, rt1, 4 * sizeof(float));
+ memcpy(rt, rt1, sizeof(float[4]));
}
else if (rt2[3] >= 1.0f) {
- memcpy(rt, rt2, 4 * sizeof(float));
+ memcpy(rt, rt2, sizeof(float[4]));
}
else {
fac = fac2 * (1.0f - rt2[3]);
if (fac == 0) {
- memcpy(rt, rt2, 4 * sizeof(float));
+ memcpy(rt, rt2, sizeof(float[4]));
}
else {
rt[0] = fac * rt1[0] + rt2[0];
@@ -530,16 +530,16 @@ static void do_alphaunder_effect_float(
x = xo;
while (x--) {
if (rt2[3] <= 0 && fac4 >= 1.0f) {
- memcpy(rt, rt1, 4 * sizeof(float));
+ memcpy(rt, rt1, sizeof(float[4]));
}
else if (rt2[3] >= 1.0f) {
- memcpy(rt, rt2, 4 * sizeof(float));
+ memcpy(rt, rt2, sizeof(float[4]));
}
else {
fac = fac4 * (1.0f - rt2[3]);
if (fac == 0) {
- memcpy(rt, rt2, 4 * sizeof(float));
+ memcpy(rt, rt2, sizeof(float[4]));
}
else {
rt[0] = fac * rt1[0] + rt2[0];
@@ -2522,7 +2522,7 @@ static void RVBlurBitmap2_float(float *map, int width, int height, float blur, i
}
/* Allocate memory for the tempmap and the blur filter matrix */
- temp = MEM_mallocN((width * height * 4 * sizeof(float)), "blurbitmaptemp");
+ temp = MEM_mallocN(sizeof(float[4]) * width * height, "blurbitmaptemp");
if (!temp) {
return;
}
@@ -2746,8 +2746,8 @@ static void do_glow_effect_byte(Sequence *seq,
float *outbuf, *inbuf;
GlowVars *glow = (GlowVars *)seq->effectdata;
- inbuf = MEM_mallocN(4 * sizeof(float) * x * y, "glow effect input");
- outbuf = MEM_mallocN(4 * sizeof(float) * x * y, "glow effect output");
+ inbuf = MEM_mallocN(sizeof(float[4]) * x * y, "glow effect input");
+ outbuf = MEM_mallocN(sizeof(float[4]) * x * y, "glow effect output");
IMB_buffer_float_from_byte(inbuf, rect1, IB_PROFILE_SRGB, IB_PROFILE_SRGB, false, x, y, x, x);
IMB_buffer_float_premultiply(inbuf, x, y);
@@ -3269,9 +3269,8 @@ float BKE_sequencer_speed_effect_target_frame_get(const SeqRenderData *context,
if (input == 0) { /* Current frame. */
return floor(seq->start + s->frameMap[nr]);
}
- else { /* Next frame. */
- return ceil(seq->start + s->frameMap[nr]);
- }
+ /* Next frame. */
+ return ceil(seq->start + s->frameMap[nr]);
}
static float speed_effect_interpolation_ratio_get(SpeedControlVars *s, Sequence *seq, float cfra)
@@ -4024,7 +4023,7 @@ static int early_out_fade(Sequence *UNUSED(seq), float facf0, float facf1)
if (facf0 == 0.0f && facf1 == 0.0f) {
return EARLY_USE_INPUT_1;
}
- else if (facf0 == 1.0f && facf1 == 1.0f) {
+ if (facf0 == 1.0f && facf1 == 1.0f) {
return EARLY_USE_INPUT_2;
}
return EARLY_DO_EFFECT;
diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c
index a630170d6d5..a38fe252731 100644
--- a/source/blender/blenkernel/intern/seqmodifier.c
+++ b/source/blender/blenkernel/intern/seqmodifier.c
@@ -393,10 +393,10 @@ static void curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *m
{
CurvesModifierData *cmd = (CurvesModifierData *)smd;
- float black[3] = {0.0f, 0.0f, 0.0f};
- float white[3] = {1.0f, 1.0f, 1.0f};
+ const float black[3] = {0.0f, 0.0f, 0.0f};
+ const float white[3] = {1.0f, 1.0f, 1.0f};
- BKE_curvemapping_initialize(&cmd->curve_mapping);
+ BKE_curvemapping_init(&cmd->curve_mapping);
BKE_curvemapping_premultiply(&cmd->curve_mapping, 0);
BKE_curvemapping_set_black_white(&cmd->curve_mapping, black, white);
@@ -525,7 +525,7 @@ static void hue_correct_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImB
{
HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
- BKE_curvemapping_initialize(&hcmd->curve_mapping);
+ BKE_curvemapping_init(&hcmd->curve_mapping);
modifier_apply_threaded(ibuf, mask, hue_correct_apply_threaded, &hcmd->curve_mapping);
}
diff --git a/source/blender/blenkernel/intern/seqprefetch.c b/source/blender/blenkernel/intern/seqprefetch.c
index ff3829bdebb..795086fffa4 100644
--- a/source/blender/blenkernel/intern/seqprefetch.c
+++ b/source/blender/blenkernel/intern/seqprefetch.c
@@ -138,7 +138,7 @@ static bool seq_prefetch_job_is_waiting(Scene *scene)
static Sequence *sequencer_prefetch_get_original_sequence(Sequence *seq, ListBase *seqbase)
{
LISTBASE_FOREACH (Sequence *, seq_orig, seqbase) {
- if (strcmp(seq->name, seq_orig->name) == 0) {
+ if (STREQ(seq->name, seq_orig->name)) {
return seq_orig;
}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index b16fc08a4af..a2a45ae56b3 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -46,6 +46,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_path_util.h"
+#include "BLI_session_uuid.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_threads.h"
@@ -1355,9 +1356,8 @@ const char *BKE_sequence_give_name(Sequence *seq)
if (!(seq->type & SEQ_TYPE_EFFECT)) {
return seq->strip->dir;
}
- else {
- return "Effect";
- }
+
+ return "Effect";
}
return name;
}
@@ -1661,13 +1661,12 @@ static int seq_num_files(Scene *scene, char views_format, const bool is_multivie
if (!is_multiview) {
return 1;
}
- else if (views_format == R_IMF_VIEWS_STEREO_3D) {
+ if (views_format == R_IMF_VIEWS_STEREO_3D) {
return 1;
}
/* R_IMF_VIEWS_INDIVIDUAL */
- else {
- return BKE_scene_multiview_num_views_get(&scene->r);
- }
+
+ return BKE_scene_multiview_num_views_get(&scene->r);
}
static void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir)
@@ -1958,9 +1957,8 @@ static ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int c
return ibuf;
}
- else {
- return NULL;
- }
+
+ return NULL;
}
static void seq_proxy_build_frame(const SeqRenderData *context,
@@ -2055,9 +2053,8 @@ static bool seq_proxy_multiview_context_invalid(Sequence *seq, Scene *scene, con
if (BLI_access(str, R_OK) == 0) {
return false;
}
- else {
- return view_id != 0;
- }
+
+ return view_id != 0;
}
return false;
}
@@ -2425,7 +2422,7 @@ static void color_balance_byte_float(StripColorBalance *cb_,
while (p < e) {
if (m) {
- float t[3] = {m[0] / 255.0f, m[1] / 255.0f, m[2] / 255.0f};
+ 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]];
@@ -3154,12 +3151,33 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context,
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)
{
@@ -3169,10 +3187,19 @@ static ImBuf *seq_render_movie_strip_view(const SeqRenderData *context,
IMB_anim_set_preseek(sanim->anim, seq->anim_preseek);
if (seq_can_use_proxy(seq, psize)) {
- ibuf = IMB_anim_absolute(sanim->anim,
- nr + seq->anim_startofs,
- seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN,
- 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;
}
@@ -3221,7 +3248,7 @@ static ImBuf *seq_render_movie_strip(
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, sanim, r_is_proxy_image);
+ context, seq, nr, cfra, sanim, r_is_proxy_image);
}
}
@@ -3258,7 +3285,7 @@ static ImBuf *seq_render_movie_strip(
MEM_freeN(ibuf_arr);
}
else {
- ibuf = seq_render_movie_strip_view(context, seq, nr, sanim, r_is_proxy_image);
+ ibuf = seq_render_movie_strip_view(context, seq, nr, cfra, sanim, r_is_proxy_image);
}
if (ibuf == NULL) {
@@ -3350,35 +3377,34 @@ static ImBuf *seq_render_mask(const SeqRenderData *context, Mask *mask, float nr
if (!mask) {
return NULL;
}
- else {
- AnimData *adt;
- Mask *mask_temp;
- MaskRasterHandle *mr_handle;
- mask_temp = BKE_mask_copy_nolib(mask);
+ AnimData *adt;
+ Mask *mask_temp;
+ MaskRasterHandle *mr_handle;
- BKE_mask_evaluate(mask_temp, mask->sfra + nr, true);
+ mask_temp = BKE_mask_copy_nolib(mask);
- /* 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);
+ BKE_mask_evaluate(mask_temp, mask->sfra + nr, true);
- maskbuf = MEM_mallocN(sizeof(float) * context->rectx * context->recty, __func__);
+ /* 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);
- mr_handle = BKE_maskrasterize_handle_new();
+ maskbuf = MEM_mallocN(sizeof(float) * context->rectx * context->recty, __func__);
- BKE_maskrasterize_handle_init(
- mr_handle, mask_temp, context->rectx, context->recty, true, true, true);
+ mr_handle = BKE_maskrasterize_handle_new();
- BKE_mask_free(mask_temp);
- MEM_freeN(mask_temp);
+ BKE_maskrasterize_handle_init(
+ mr_handle, mask_temp, context->rectx, context->recty, true, true, true);
- BKE_maskrasterize_buffer(mr_handle, context->rectx, context->recty, maskbuf);
+ BKE_mask_free(mask_temp);
+ MEM_freeN(mask_temp);
- BKE_maskrasterize_handle_free(mr_handle);
- }
+ BKE_maskrasterize_buffer(mr_handle, context->rectx, context->recty, maskbuf);
+
+ BKE_maskrasterize_handle_free(mr_handle);
if (make_float) {
/* pixels */
@@ -3626,7 +3652,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
ibufs_arr[view_id] = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat);
memcpy(ibufs_arr[view_id]->rect_float,
rres.rectf,
- 4 * sizeof(float) * rres.rectx * rres.recty);
+ sizeof(float[4]) * rres.rectx * rres.recty);
if (rres.rectz) {
addzbuffloatImBuf(ibufs_arr[view_id]);
@@ -3822,9 +3848,8 @@ static float seq_estimate_render_cost_end(Scene *scene, clock_t begin)
if (time_max != 0) {
return time_spent / time_max;
}
- else {
- return 1;
- }
+
+ return 1;
}
static ImBuf *seq_render_preprocess_ibuf(const SeqRenderData *context,
@@ -3925,7 +3950,7 @@ static int seq_get_early_out_for_blend_mode(Sequence *seq)
if (early_out == EARLY_USE_INPUT_2) {
return EARLY_USE_INPUT_1;
}
- else if (early_out == EARLY_USE_INPUT_1) {
+ if (early_out == EARLY_USE_INPUT_1) {
return EARLY_USE_INPUT_2;
}
}
@@ -4428,9 +4453,8 @@ int BKE_sequence_tx_get_final_left(Sequence *seq, bool metaclip)
return max_ii(BKE_sequence_tx_get_final_left(seq, false),
BKE_sequence_tx_get_final_left((Sequence *)seq->tmp, true));
}
- else {
- return (seq->start - seq->startstill) + seq->startofs;
- }
+
+ return (seq->start - seq->startstill) + seq->startofs;
}
int BKE_sequence_tx_get_final_right(Sequence *seq, bool metaclip)
{
@@ -4439,9 +4463,8 @@ int BKE_sequence_tx_get_final_right(Sequence *seq, bool metaclip)
return min_ii(BKE_sequence_tx_get_final_right(seq, false),
BKE_sequence_tx_get_final_right((Sequence *)seq->tmp, true));
}
- else {
- return ((seq->start + seq->len) + seq->endstill) - seq->endofs;
- }
+
+ return ((seq->start + seq->len) + seq->endstill) - seq->endofs;
}
void BKE_sequence_tx_set_final_left(Sequence *seq, int val)
@@ -4733,9 +4756,8 @@ bool BKE_sequence_base_shuffle_ex(ListBase *seqbasep,
BKE_sequence_calc(evil_scene, test);
return false;
}
- else {
- return true;
- }
+
+ return true;
}
bool BKE_sequence_base_shuffle(ListBase *seqbasep, Sequence *test, Scene *evil_scene)
@@ -4980,7 +5002,7 @@ ListBase *BKE_sequence_seqbase(ListBase *seqbase, Sequence *seq)
if (seq == iseq) {
return seqbase;
}
- else if (iseq->seqbase.first && (lb = BKE_sequence_seqbase(&iseq->seqbase, seq))) {
+ if (iseq->seqbase.first && (lb = BKE_sequence_seqbase(&iseq->seqbase, seq))) {
return lb;
}
}
@@ -4998,7 +5020,7 @@ Sequence *BKE_sequence_metastrip(ListBase *seqbase, Sequence *meta, Sequence *se
if (seq == iseq) {
return meta;
}
- else if (iseq->seqbase.first && (rval = BKE_sequence_metastrip(&iseq->seqbase, iseq, seq))) {
+ if (iseq->seqbase.first && (rval = BKE_sequence_metastrip(&iseq->seqbase, iseq, seq))) {
return rval;
}
}
@@ -5183,8 +5205,8 @@ Sequence *BKE_sequence_get_by_name(ListBase *seqbase, const char *name, bool rec
if (STREQ(name, iseq->name + 2)) {
return iseq;
}
- else if (recursive && (iseq->seqbase.first) &&
- (rseq = BKE_sequence_get_by_name(&iseq->seqbase, name, 1))) {
+ if (recursive && (iseq->seqbase.first) &&
+ (rseq = BKE_sequence_get_by_name(&iseq->seqbase, name, 1))) {
return rseq;
}
}
@@ -5206,7 +5228,7 @@ Sequence *BKE_sequencer_from_elem(ListBase *seqbase, StripElem *se)
(ARRAY_HAS_ITEM(se, iseq->strip->stripdata, iseq->len))) {
break;
}
- else if ((seq_found = BKE_sequencer_from_elem(&iseq->seqbase, se))) {
+ if ((seq_found = BKE_sequencer_from_elem(&iseq->seqbase, se))) {
iseq = seq_found;
break;
}
@@ -5246,24 +5268,22 @@ int BKE_sequencer_active_get_pair(Scene *scene, Sequence **seq_act, Sequence **s
if (*seq_act == NULL) {
return 0;
}
- else {
- Sequence *seq;
- *seq_other = NULL;
+ Sequence *seq;
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT && (seq != (*seq_act))) {
- if (*seq_other) {
- return 0;
- }
- else {
- *seq_other = seq;
- }
+ *seq_other = NULL;
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT && (seq != (*seq_act))) {
+ if (*seq_other) {
+ return 0;
}
- }
- return (*seq_other != NULL);
+ *seq_other = seq;
+ }
}
+
+ return (*seq_other != NULL);
}
Mask *BKE_sequencer_mask_get(Scene *scene)
@@ -5273,9 +5293,8 @@ Mask *BKE_sequencer_mask_get(Scene *scene)
if (seq_act && seq_act->type == SEQ_TYPE_MASK) {
return seq_act->mask;
}
- else {
- return NULL;
- }
+
+ return NULL;
}
/* api like funcs for adding */
@@ -5352,9 +5371,16 @@ Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine, int type)
seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Sequence Stereo Format");
seq->cache_flag = SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_PREPROCESSED | SEQ_CACHE_STORE_COMPOSITE;
+ BKE_sequence_session_uuid_generate(seq);
+
return seq;
}
+void BKE_sequence_session_uuid_generate(struct Sequence *sequence)
+{
+ sequence->runtime.session_uuid = BLI_session_uuid_generate();
+}
+
void BKE_sequence_alpha_mode_from_extension(Sequence *seq)
{
if (seq->strip && seq->strip->stripdata) {
@@ -5584,6 +5610,9 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
}
}
+ if (seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
+ seq_load->channel++;
+ }
seq = BKE_sequence_alloc(seqbasep, seq_load->start_frame, seq_load->channel, SEQ_TYPE_MOVIE);
/* multiview settings */
@@ -5640,11 +5669,8 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
if (seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
int start_frame_back = seq_load->start_frame;
seq_load->channel--;
-
seq_load->seq_sound = BKE_sequencer_add_sound_strip(C, seqbasep, seq_load);
-
seq_load->start_frame = start_frame_back;
- seq_load->channel++;
}
/* can be NULL */
@@ -5664,6 +5690,10 @@ static Sequence *seq_dupli(const Scene *scene_src,
{
Sequence *seqn = MEM_dupallocN(seq);
+ if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
+ BKE_sequence_session_uuid_generate(seq);
+ }
+
seq->tmp = seqn;
seqn->strip = MEM_dupallocN(seq->strip);
@@ -6127,3 +6157,32 @@ void BKE_sequencer_remove_flagged_sequences(Scene *scene, ListBase *seqbase)
}
}
}
+
+void BKE_sequencer_check_uuids_unique_and_report(const Scene *scene)
+{
+ if (scene->ed == NULL) {
+ return;
+ }
+
+ struct GSet *used_uuids = BLI_gset_new(
+ BLI_session_uuid_ghash_hash, BLI_session_uuid_ghash_compare, "sequencer used uuids");
+
+ const Sequence *sequence;
+ SEQ_BEGIN (scene->ed, sequence) {
+ const SessionUUID *session_uuid = &sequence->runtime.session_uuid;
+ if (!BLI_session_uuid_is_generated(session_uuid)) {
+ printf("Sequence %s does not have UUID generated.\n", sequence->name);
+ continue;
+ }
+
+ if (BLI_gset_lookup(used_uuids, session_uuid) != NULL) {
+ printf("Sequence %s has duplicate UUID generated.\n", sequence->name);
+ continue;
+ }
+
+ BLI_gset_insert(used_uuids, (void *)session_uuid);
+ }
+ SEQ_END;
+
+ BLI_gset_free(used_uuids, NULL);
+}
diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c
index 2923298c5d5..b3d350f5ccd 100644
--- a/source/blender/blenkernel/intern/shader_fx.c
+++ b/source/blender/blenkernel/intern/shader_fx.c
@@ -160,9 +160,8 @@ const ShaderFxTypeInfo *BKE_shaderfx_get_info(ShaderFxType type)
if (type < NUM_SHADER_FX_TYPES && type > 0 && shader_fx_types[type]->name[0] != '\0') {
return shader_fx_types[type];
}
- else {
- return NULL;
- }
+
+ return NULL;
}
/**
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 29f4c7dc6c1..0ff5bdda9e9 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -136,30 +136,29 @@ bool BKE_shrinkwrap_init_tree(
return data->bvh != NULL;
}
- else {
- if (mesh->totpoly <= 0) {
- return false;
- }
- data->bvh = BKE_bvhtree_from_mesh_get(&data->treeData, mesh, BVHTREE_FROM_LOOPTRI, 4);
+ if (mesh->totpoly <= 0) {
+ return false;
+ }
- if (data->bvh == NULL) {
- return false;
- }
+ data->bvh = BKE_bvhtree_from_mesh_get(&data->treeData, mesh, BVHTREE_FROM_LOOPTRI, 4);
- if (force_normals || BKE_shrinkwrap_needs_normals(shrinkType, shrinkMode)) {
- data->pnors = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
- if ((mesh->flag & ME_AUTOSMOOTH) != 0) {
- data->clnors = CustomData_get_layer(&mesh->ldata, CD_NORMAL);
- }
- }
+ if (data->bvh == NULL) {
+ return false;
+ }
- if (shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
- data->boundary = mesh->runtime.shrinkwrap_data;
+ if (force_normals || BKE_shrinkwrap_needs_normals(shrinkType, shrinkMode)) {
+ data->pnors = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
+ if ((mesh->flag & ME_AUTOSMOOTH) != 0) {
+ data->clnors = CustomData_get_layer(&mesh->ldata, CD_NORMAL);
}
+ }
- return true;
+ if (shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
+ data->boundary = mesh->runtime.shrinkwrap_data;
}
+
+ return true;
}
/* Frees the tree data if necessary. */
@@ -761,7 +760,7 @@ static void target_project_tri_deviation(void *userdata, const float x[3], float
{
TargetProjectTriData *data = userdata;
- float w[3] = {x[0], x[1], 1.0f - x[0] - x[1]};
+ const float w[3] = {x[0], x[1], 1.0f - x[0] - x[1]};
interp_v3_v3v3v3(data->co_interp, data->vtri_co[0], data->vtri_co[1], data->vtri_co[2], w);
interp_v3_v3v3v3(data->no_interp, data->vtri_no[0], data->vtri_no[1], data->vtri_no[2], w);
diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc
index c0fc8fcb464..6b03721cab8 100644
--- a/source/blender/blenkernel/intern/simulation.cc
+++ b/source/blender/blenkernel/intern/simulation.cc
@@ -295,21 +295,20 @@ using StateTypeMap = blender::Map<std::string, std::unique_ptr<SimulationStateTy
template<typename T>
static void add_state_type(StateTypeMap &map,
- const char *name,
void (*init)(T *state),
void (*reset)(T *state),
void (*remove)(T *state),
void (*copy)(const T *src, T *dst))
{
SimulationStateType state_type{
- name,
- (int)sizeof(T),
+ BKE_simulation_get_state_type_name<T>(),
+ static_cast<int>(sizeof(T)),
(StateInitFunction)init,
(StateResetFunction)reset,
(StateRemoveFunction)remove,
(StateCopyFunction)copy,
};
- map.add_new(name, std::make_unique<SimulationStateType>(state_type));
+ map.add_new(state_type.name, std::make_unique<SimulationStateType>(state_type));
}
static StateTypeMap init_state_types()
@@ -317,7 +316,6 @@ static StateTypeMap init_state_types()
StateTypeMap map;
add_state_type<ParticleSimulationState>(
map,
- SIM_TYPE_NAME_PARTICLE_SIMULATION,
[](ParticleSimulationState *state) { CustomData_reset(&state->attributes); },
[](ParticleSimulationState *state) {
CustomData_free(&state->attributes, state->tot_particles);
@@ -337,7 +335,6 @@ static StateTypeMap init_state_types()
add_state_type<ParticleMeshEmitterSimulationState>(
map,
- SIM_TYPE_NAME_PARTICLE_MESH_EMITTER,
[](ParticleMeshEmitterSimulationState *UNUSED(state)) {},
[](ParticleMeshEmitterSimulationState *state) { state->last_birth_time = 0.0f; },
[](ParticleMeshEmitterSimulationState *UNUSED(state)) {},
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index b7b325644ca..1ab9766a7ec 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -230,7 +230,7 @@ static float _final_goal(Object *ob, BodyPoint *bp) /*jow_go_for2_5 */
}
f = sb->mingoal + bp->goal * fabsf(sb->maxgoal - sb->mingoal);
f = pow(f, 4.0f);
- return (f);
+ return f;
}
}
CLOG_ERROR(&LOG, "sb or bp == NULL");
@@ -1051,7 +1051,7 @@ static int sb_detect_aabb_collisionCached(float UNUSED(force[3]),
/* --- the aabb section*/
/* +++ the face external section*/
-static int sb_detect_face_pointCached(float face_v1[3],
+static int sb_detect_face_pointCached(const float face_v1[3],
const float face_v2[3],
const float face_v3[3],
float *damp,
@@ -1149,7 +1149,7 @@ static int sb_detect_face_pointCached(float face_v1[3],
return deflected;
}
-static int sb_detect_face_collisionCached(float face_v1[3],
+static int sb_detect_face_collisionCached(const float face_v1[3],
const float face_v2[3],
const float face_v3[3],
float *damp,
@@ -1328,7 +1328,7 @@ static void scan_for_ext_face_forces(Object *ob, float timenow)
/* +++ the spring external section*/
-static int sb_detect_edge_collisionCached(float edge_v1[3],
+static int sb_detect_edge_collisionCached(const float edge_v1[3],
const float edge_v2[3],
float *damp,
float force[3],
@@ -1619,7 +1619,7 @@ static int choose_winner(
case 3:
copy_v3_v3(w, cc);
}
- return (winner);
+ return winner;
}
static int sb_detect_vertex_collisionCached(float opco[3],
@@ -1833,7 +1833,7 @@ static int sb_deflect_face(Object *ob,
deflected = sb_detect_vertex_collisionCachedEx(
s_actpos, facenormal, cf, force, ob, time, vel, intrusion);
#endif
- return (deflected);
+ return deflected;
}
/* hiding this for now .. but the jacobian may pop up on other tasks .. so i'd like to keep it */
@@ -1991,13 +1991,13 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene,
}
else {
CLOG_ERROR(&LOG, "expected a SB here");
- return (999);
+ return 999;
}
/* debugerin */
if (sb->totpoint < ifirst) {
printf("Aye 998");
- return (998);
+ return 998;
}
/* debugerin */
@@ -3211,12 +3211,11 @@ static int object_has_edges(Object *ob)
if (ob->type == OB_MESH) {
return ((Mesh *)ob->data)->totedge;
}
- else if (ob->type == OB_LATTICE) {
+ if (ob->type == OB_LATTICE) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
/* SB global visible functions */
@@ -3281,8 +3280,8 @@ void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float ls
if (!sb || !sb->bpoint) {
return;
}
- opos = MEM_callocN((sb->totpoint) * 3 * sizeof(float), "SB_OPOS");
- rpos = MEM_callocN((sb->totpoint) * 3 * sizeof(float), "SB_RPOS");
+ opos = MEM_callocN(sizeof(float[3]) * sb->totpoint, "SB_OPOS");
+ rpos = MEM_callocN(sizeof(float[3]) * sb->totpoint, "SB_RPOS");
/* might filter vertex selection with a vertex group */
for (a = 0, bp = sb->bpoint, rp = sb->scratch->Ref.ivert; a < sb->totpoint; a++, bp++, rp++) {
copy_v3_v3(rpos[a], rp->pos);
@@ -3563,7 +3562,7 @@ void sbObjectStep(struct Depsgraph *depsgraph,
BKE_ptcache_invalidate(cache);
return;
}
- else if (framenr > endframe) {
+ if (framenr > endframe) {
framenr = endframe;
}
@@ -3631,7 +3630,7 @@ void sbObjectStep(struct Depsgraph *depsgraph,
return;
}
- else if (cache_result == PTCACHE_READ_OLD) {
+ if (cache_result == PTCACHE_READ_OLD) {
/* pass */
}
else if (/*ob->id.lib || */
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 1fcfc9b060f..b72c5e99b43 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -898,9 +898,8 @@ double BKE_sound_sync_scene(Scene *scene)
if (scene->audio.flag & AUDIO_SYNC) {
return AUD_getSynchronizerPosition(scene->playback_handle);
}
- else {
- return AUD_Handle_getPosition(scene->playback_handle);
- }
+
+ return AUD_Handle_getPosition(scene->playback_handle);
}
return NAN_FLT;
}
@@ -922,9 +921,8 @@ int BKE_sound_scene_playing(Scene *scene)
if (scene->audio.flag & AUDIO_SYNC) {
return AUD_isSynchronizerPlaying();
}
- else {
- return -1;
- }
+
+ return -1;
}
void BKE_sound_free_waveform(bSound *sound)
@@ -959,7 +957,7 @@ void BKE_sound_read_waveform(Main *bmain, bSound *sound, short *stop)
if (info.length > 0) {
int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND;
- waveform->data = MEM_mallocN(length * sizeof(float) * 3, "SoundWaveform.samples");
+ waveform->data = MEM_mallocN(sizeof(float[3]) * length, "SoundWaveform.samples");
waveform->length = AUD_readSound(
sound->playback_handle, waveform->data, length, SOUND_WAVE_SAMPLES_PER_SECOND, stop);
}
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index 46341652544..10830a3d4ba 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -366,23 +366,22 @@ static float *studiolight_multilayer_convert_pass(ImBuf *ibuf,
if (channels == 4) {
return rect;
}
- else {
- float *new_rect = MEM_callocN(sizeof(float[4]) * ibuf->x * ibuf->y, __func__);
-
- IMB_buffer_float_from_float(new_rect,
- rect,
- channels,
- IB_PROFILE_LINEAR_RGB,
- IB_PROFILE_LINEAR_RGB,
- false,
- ibuf->x,
- ibuf->y,
- ibuf->x,
- ibuf->x);
- MEM_freeN(rect);
- return new_rect;
- }
+ float *new_rect = MEM_callocN(sizeof(float[4]) * ibuf->x * ibuf->y, __func__);
+
+ IMB_buffer_float_from_float(new_rect,
+ rect,
+ channels,
+ IB_PROFILE_LINEAR_RGB,
+ IB_PROFILE_LINEAR_RGB,
+ false,
+ ibuf->x,
+ ibuf->y,
+ ibuf->x,
+ ibuf->x);
+
+ MEM_freeN(rect);
+ return new_rect;
}
static void studiolight_multilayer_addpass(void *base,
@@ -694,7 +693,7 @@ static void studiolight_calculate_cubemap_vector_weight(
static void studiolight_spherical_harmonics_calculate_coefficients(StudioLight *sl, float (*sh)[3])
{
float weight_accum = 0.0f;
- memset(sh, 0, sizeof(float) * 3 * STUDIOLIGHT_SH_COEFS_LEN);
+ memset(sh, 0, sizeof(float[3]) * STUDIOLIGHT_SH_COEFS_LEN);
for (int face = 0; face < 6; face++) {
ITER_PIXELS (float,
@@ -1229,12 +1228,11 @@ static int studiolight_cmp(const void *a, const void *b)
if (flagorder1 < flagorder2) {
return -1;
}
- else if (flagorder1 > flagorder2) {
+ if (flagorder1 > flagorder2) {
return 1;
}
- else {
- return BLI_strcasecmp(sl1->name, sl2->name);
- }
+
+ return BLI_strcasecmp(sl1->name, sl2->name);
}
/* icons */
@@ -1245,7 +1243,7 @@ static int studiolight_cmp(const void *a, const void *b)
static uint alpha_circle_mask(float u, float v, float inner_edge, float outer_edge)
{
/* Coords from center. */
- float co[2] = {u - 0.5f, v - 0.5f};
+ const float co[2] = {u - 0.5f, v - 0.5f};
float dist = len_v2(co);
float alpha = 1.0f + (inner_edge - dist) / (outer_edge - inner_edge);
uint mask = (uint)floorf(255.0f * min_ff(max_ff(alpha, 0.0f), 1.0f));
@@ -1277,7 +1275,7 @@ static void studiolight_radiance_preview(uint *icon_buffer, StudioLight *sl)
uint alphamask = alpha_circle_mask(dx, dy, 0.5f - texel_size[0], 0.5f);
if (alphamask != 0) {
float normal[3], direction[3], color[4];
- float incoming[3] = {0.0f, 0.0f, -1.0f};
+ const float incoming[3] = {0.0f, 0.0f, -1.0f};
sphere_normal_from_uv(normal, dx, dy);
reflect_v3_v3v3(direction, incoming, normal);
/* We want to see horizon not poles. */
@@ -1496,10 +1494,9 @@ struct StudioLight *BKE_studiolight_find(const char *name, int flag)
if ((sl->flag & flag)) {
return sl;
}
- else {
- /* flags do not match, so use default */
- return BKE_studiolight_find_default(flag);
- }
+
+ /* flags do not match, so use default */
+ return BKE_studiolight_find_default(flag);
}
}
/* When not found, use the default studio light */
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c
index 22649a2af07..86c57491393 100644
--- a/source/blender/blenkernel/intern/subdiv_ccg.c
+++ b/source/blender/blenkernel/intern/subdiv_ccg.c
@@ -85,7 +85,7 @@ static int element_size_bytes_get(const SubdivCCG *subdiv_ccg)
static void subdiv_ccg_init_layers(SubdivCCG *subdiv_ccg, const SubdivToCCGSettings *settings)
{
/* CCG always contains coordinates. Rest of layers are coming after them. */
- int layer_offset = sizeof(float) * 3;
+ int layer_offset = sizeof(float[3]);
/* Mask. */
if (settings->need_mask) {
subdiv_ccg->has_mask = true;
@@ -103,7 +103,7 @@ static void subdiv_ccg_init_layers(SubdivCCG *subdiv_ccg, const SubdivToCCGSetti
if (settings->need_normal) {
subdiv_ccg->has_normal = true;
subdiv_ccg->normal_offset = layer_offset;
- layer_offset += sizeof(float) * 3;
+ layer_offset += sizeof(float[3]);
}
else {
subdiv_ccg->has_normal = false;
@@ -709,7 +709,7 @@ static void subdiv_ccg_recalc_inner_face_normals(SubdivCCG *subdiv_ccg,
CCGElem *grid = subdiv_ccg->grids[grid_index];
if (tls->face_normals == NULL) {
tls->face_normals = MEM_malloc_arrayN(
- grid_size_1 * grid_size_1, 3 * sizeof(float), "CCG TLS normals");
+ grid_size_1 * grid_size_1, sizeof(float[3]), "CCG TLS normals");
}
for (int y = 0; y < grid_size - 1; y++) {
for (int x = 0; x < grid_size - 1; x++) {
@@ -1618,6 +1618,18 @@ static int prev_adjacent_edge_point_index(const SubdivCCG *subdiv_ccg, const int
return point_index - 1;
}
+/* When the point index corresponds to a grid corner, returns the point index which corresponds to
+ * the corner of the adjacent grid, as the adjacent edge has two separate points for each grid
+ * corner at the middle of the edge. */
+static int adjacent_grid_corner_point_index_on_edge(const SubdivCCG *subdiv_ccg,
+ const int point_index)
+{
+ if (point_index == subdiv_ccg->grid_size) {
+ return point_index - 1;
+ }
+ return point_index + 1;
+}
+
/* Common implementation of neighbor calculation when input coordinate is at the edge between two
* coarse faces, but is not at the coarse vertex. */
static void neighbor_coords_edge_get(const SubdivCCG *subdiv_ccg,
@@ -1626,6 +1638,7 @@ static void neighbor_coords_edge_get(const SubdivCCG *subdiv_ccg,
SubdivCCGNeighbors *r_neighbors)
{
+ const bool is_corner = is_corner_grid_coord(subdiv_ccg, coord);
const int adjacent_edge_index = adjacent_edge_index_from_coord(subdiv_ccg, coord);
BLI_assert(adjacent_edge_index >= 0);
BLI_assert(adjacent_edge_index < subdiv_ccg->num_adjacent_edges);
@@ -1633,15 +1646,27 @@ static void neighbor_coords_edge_get(const SubdivCCG *subdiv_ccg,
/* 2 neighbor points along the edge, plus one inner point per every adjacent grid. */
const int num_adjacent_faces = adjacent_edge->num_adjacent_faces;
- subdiv_ccg_neighbors_init(
- r_neighbors, num_adjacent_faces + 2, (include_duplicates) ? num_adjacent_faces - 1 : 0);
+ int num_duplicates = 0;
+ if (include_duplicates) {
+ num_duplicates += num_adjacent_faces - 1;
+ if (is_corner) {
+ /* When the coord is a grid corner, add an extra duplicate per adjacent grid in all adjacent
+ * faces to the edge. */
+ num_duplicates += num_adjacent_faces;
+ }
+ }
+ subdiv_ccg_neighbors_init(r_neighbors, num_adjacent_faces + 2, num_duplicates);
const int point_index = adjacent_edge_point_index_from_coord(
subdiv_ccg, coord, adjacent_edge_index);
+ const int point_index_duplicate = adjacent_grid_corner_point_index_on_edge(subdiv_ccg,
+ point_index);
+
const int next_point_index = next_adjacent_edge_point_index(subdiv_ccg, point_index);
const int prev_point_index = prev_adjacent_edge_point_index(subdiv_ccg, point_index);
- for (int i = 0, duplicate_i = num_adjacent_faces; i < num_adjacent_faces; ++i) {
+ int duplicate_i = num_adjacent_faces;
+ for (int i = 0; i < num_adjacent_faces; ++i) {
SubdivCCGCoord *boundary_coords = adjacent_edge->boundary_coords[i];
/* One step into the grid from the edge for each adjacent face. */
SubdivCCGCoord grid_coord = boundary_coords[point_index];
@@ -1657,7 +1682,15 @@ static void neighbor_coords_edge_get(const SubdivCCG *subdiv_ccg,
r_neighbors->coords[duplicate_i + 2] = grid_coord;
duplicate_i++;
}
+
+ /* When it is a corner, add the duplicate of the adjacent grid in the same face. */
+ if (include_duplicates && is_corner) {
+ SubdivCCGCoord duplicate_corner_grid_coord = boundary_coords[point_index_duplicate];
+ r_neighbors->coords[duplicate_i + 2] = duplicate_corner_grid_coord;
+ duplicate_i++;
+ }
}
+ BLI_assert(duplicate_i - num_adjacent_faces == num_duplicates);
}
/* The corner is at the middle of edge between faces. */
@@ -1889,4 +1922,15 @@ SubdivCCGAdjacencyType BKE_subdiv_ccg_coarse_mesh_adjacency_info_get(const Subdi
return SUBDIV_CCG_ADJACENT_NONE;
}
+void BKE_subdiv_ccg_grid_hidden_ensure(SubdivCCG *subdiv_ccg, int grid_index)
+{
+ if (subdiv_ccg->grid_hidden[grid_index] != NULL) {
+ return;
+ }
+
+ CCGKey key;
+ BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
+ subdiv_ccg->grid_hidden[grid_index] = BLI_BITMAP_NEW(key.grid_area, __func__);
+}
+
/** \} */
diff --git a/source/blender/blenkernel/intern/subdiv_converter.h b/source/blender/blenkernel/intern/subdiv_converter.h
index fb0e84ade13..ea0efe994b5 100644
--- a/source/blender/blenkernel/intern/subdiv_converter.h
+++ b/source/blender/blenkernel/intern/subdiv_converter.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __SUBDIV_CONVERTER_H__
-#define __SUBDIV_CONVERTER_H__
+#pragma once
/** \file
* \ingroup bke
@@ -51,5 +50,3 @@ int BKE_subdiv_converter_vtx_boundary_interpolation_from_settings(const SubdivSe
/* TODO(sergey): Find a way to make it OpenSubdiv_FVarLinearInterpolation,
* without breaking compilation without OpenSubdiv. */
int BKE_subdiv_converter_fvar_linear_from_settings(const SubdivSettings *settings);
-
-#endif /* __SUBDIV_CONVERTER_H__ */
diff --git a/source/blender/blenkernel/intern/subdiv_displacement_multires.c b/source/blender/blenkernel/intern/subdiv_displacement_multires.c
index 617f37834f9..a63c2994687 100644
--- a/source/blender/blenkernel/intern/subdiv_displacement_multires.c
+++ b/source/blender/blenkernel/intern/subdiv_displacement_multires.c
@@ -128,10 +128,10 @@ BLI_INLINE eAverageWith read_displacement_grid(const MDisps *displacement_grid,
if (x == 0 && y == 0) {
return AVERAGE_WITH_ALL;
}
- else if (x == 0) {
+ if (x == 0) {
return AVERAGE_WITH_PREV;
}
- else if (y == 0) {
+ if (y == 0) {
return AVERAGE_WITH_NEXT;
}
return AVERAGE_WITH_NONE;
@@ -321,9 +321,8 @@ static int displacement_get_face_corner(MultiresDisplacementData *data,
float dummy_corner_u, dummy_corner_v;
return BKE_subdiv_rotate_quad_to_corner(u, v, &dummy_corner_u, &dummy_corner_v);
}
- else {
- return poly_corner->corner;
- }
+
+ return poly_corner->corner;
}
static void initialize(SubdivDisplacement *displacement)
diff --git a/source/blender/blenkernel/intern/subdiv_eval.c b/source/blender/blenkernel/intern/subdiv_eval.c
index 1c10a9a1935..baee8a80f5a 100644
--- a/source/blender/blenkernel/intern/subdiv_eval.c
+++ b/source/blender/blenkernel/intern/subdiv_eval.c
@@ -46,7 +46,7 @@ bool BKE_subdiv_eval_begin(Subdiv *subdiv)
* or when OpenSubdiv is disabled */
return false;
}
- else if (subdiv->evaluator == NULL) {
+ if (subdiv->evaluator == NULL) {
BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_EVALUATOR_CREATE);
subdiv->evaluator = openSubdiv_createEvaluatorFromTopologyRefiner(subdiv->topology_refiner);
BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_EVALUATOR_CREATE);
diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c b/source/blender/blenkernel/intern/subdiv_foreach.c
index ff7f6fad5f0..37cca12721a 100644
--- a/source/blender/blenkernel/intern/subdiv_foreach.c
+++ b/source/blender/blenkernel/intern/subdiv_foreach.c
@@ -1040,7 +1040,7 @@ static void subdiv_foreach_boundary_edges(SubdivForeachTaskContext *ctx,
static void rotate_indices(const int rot, int *a, int *b, int *c, int *d)
{
- int values[4] = {*a, *b, *c, *d};
+ const int values[4] = {*a, *b, *c, *d};
*a = values[(0 - rot + 4) % 4];
*b = values[(1 - rot + 4) % 4];
*c = values[(2 - rot + 4) % 4];
@@ -1123,10 +1123,10 @@ static int subdiv_foreach_loops_corner_index(const float u,
if (u + du <= 0.5f && v + dv <= 0.5f) {
return 0;
}
- else if (u >= 0.5f && v + dv <= 0.5f) {
+ if (u >= 0.5f && v + dv <= 0.5f) {
return 1;
}
- else if (u >= 0.5f && v >= 0.5f) {
+ if (u >= 0.5f && v >= 0.5f) {
return 2;
}
return 3;
diff --git a/source/blender/blenkernel/intern/subdiv_inline.h b/source/blender/blenkernel/intern/subdiv_inline.h
index a51a33feb3d..ba45d0a4997 100644
--- a/source/blender/blenkernel/intern/subdiv_inline.h
+++ b/source/blender/blenkernel/intern/subdiv_inline.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __SUBDIV_INLINE_H__
-#define __SUBDIV_INLINE_H__
+#pragma once
#include "BLI_assert.h"
#include "BLI_compiler_compat.h"
@@ -114,5 +113,3 @@ BLI_INLINE float BKE_subdiv_edge_crease_to_sharpness_char(char edge_crease)
const float edge_crease_f = edge_crease / 255.0f;
return BKE_subdiv_edge_crease_to_sharpness_f(edge_crease_f);
}
-
-#endif /* __SUBDIV_INLINE_H__ */
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 7a0a5645b80..45dca79342e 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -150,7 +150,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int numLaye
ifc.vertDataSize = sizeof(float) * numLayers;
normalOffset += sizeof(float) * numLayers;
if (flags & CCG_CALC_NORMALS) {
- ifc.vertDataSize += sizeof(float) * 3;
+ ifc.vertDataSize += sizeof(float[3]);
}
if (flags & CCG_ALLOC_MASK) {
ifc.vertDataSize += sizeof(float);
@@ -203,12 +203,11 @@ static int getEdgeIndex(CCGSubSurf *ss, CCGEdge *e, int x, int edgeSize)
if (x == 0) {
return v0idx;
}
- else if (x == edgeSize - 1) {
+ if (x == edgeSize - 1) {
return v1idx;
}
- else {
- return edgeBase + x - 1;
- }
+
+ return edgeBase + x - 1;
}
static int getFaceIndex(
@@ -221,42 +220,39 @@ static int getFaceIndex(
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
return *((int *)ccgSubSurf_getVertUserData(ss, v));
}
- else if (x == gridSize - 1) {
+ if (x == gridSize - 1) {
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
CCGEdge *e = ccgSubSurf_getFaceEdge(f, S);
int edgeBase = *((int *)ccgSubSurf_getEdgeUserData(ss, e));
if (v == ccgSubSurf_getEdgeVert0(e)) {
return edgeBase + (gridSize - 1 - y) - 1;
}
- else {
- return edgeBase + (edgeSize - 2 - 1) - ((gridSize - 1 - y) - 1);
- }
+
+ return edgeBase + (edgeSize - 2 - 1) - ((gridSize - 1 - y) - 1);
}
- else if (y == gridSize - 1) {
+ if (y == gridSize - 1) {
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
CCGEdge *e = ccgSubSurf_getFaceEdge(f, (S + numVerts - 1) % numVerts);
int edgeBase = *((int *)ccgSubSurf_getEdgeUserData(ss, e));
if (v == ccgSubSurf_getEdgeVert0(e)) {
return edgeBase + (gridSize - 1 - x) - 1;
}
- else {
- return edgeBase + (edgeSize - 2 - 1) - ((gridSize - 1 - x) - 1);
- }
+
+ return edgeBase + (edgeSize - 2 - 1) - ((gridSize - 1 - x) - 1);
}
- else if (x == 0 && y == 0) {
+ if (x == 0 && y == 0) {
return faceBase;
}
- else if (x == 0) {
+ if (x == 0) {
S = (S + numVerts - 1) % numVerts;
return faceBase + 1 + (gridSize - 2) * S + (y - 1);
}
- else if (y == 0) {
+ if (y == 0) {
return faceBase + 1 + (gridSize - 2) * S + (x - 1);
}
- else {
- return faceBase + 1 + (gridSize - 2) * numVerts + S * (gridSize - 2) * (gridSize - 2) +
- (y - 1) * (gridSize - 2) + (x - 1);
- }
+
+ return faceBase + 1 + (gridSize - 2) * numVerts + S * (gridSize - 2) * (gridSize - 2) +
+ (y - 1) * (gridSize - 2) + (x - 1);
}
static void get_face_uv_map_vert(
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 5f85e1a1664..8a055423d6f 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -812,9 +812,8 @@ int txt_calc_tab_right(TextLine *tl, int ch)
return i - ch;
}
- else {
- return 0;
- }
+
+ return 0;
}
void txt_move_left(Text *text, const bool sel)
@@ -1664,9 +1663,8 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case)
txt_move_to(text, newl, newc + strlen(findstr), 1);
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
/** \} */
@@ -1797,7 +1795,7 @@ void txt_delete_char(Text *text)
txt_make_dirty(text);
return;
}
- else if (text->curc == text->curl->len) { /* Appending two lines */
+ if (text->curc == text->curl->len) { /* Appending two lines */
if (text->curl->next) {
txt_combine_lines(text, text->curl, text->curl->next);
txt_pop_sel(text);
@@ -1844,7 +1842,7 @@ void txt_backspace_char(Text *text)
txt_make_dirty(text);
return;
}
- else if (text->curc == 0) { /* Appending two lines */
+ if (text->curc == 0) { /* Appending two lines */
if (!text->curl->prev) {
return;
}
@@ -2052,10 +2050,9 @@ static void txt_select_prefix(Text *text, const char *add, bool skip_blank_lines
}
break;
}
- else {
- text->curl = text->curl->next;
- num++;
- }
+
+ text->curl = text->curl->next;
+ num++;
}
while (num > 0) {
@@ -2140,10 +2137,9 @@ static bool txt_select_unprefix(Text *text, const char *remove, const bool requi
}
break;
}
- else {
- text->curl = text->curl->next;
- num++;
- }
+
+ text->curl = text->curl->next;
+ num++;
}
if (unindented_first) {
@@ -2253,9 +2249,8 @@ int txt_setcurr_tab_spaces(Text *text, int space)
if (i == text->curc) {
return i;
}
- else {
- i++;
- }
+
+ i++;
}
if (strstr(text->curl->line, word)) {
/* if we find a ':' on this line, then add a tab but not if it is:
@@ -2270,7 +2265,7 @@ int txt_setcurr_tab_spaces(Text *text, int space)
if (ch == '#') {
break;
}
- else if (ch == ':') {
+ if (ch == ':') {
is_indent = 1;
}
else if (ch != ' ' && ch != '\t') {
@@ -2309,7 +2304,7 @@ int text_check_bracket(const char ch)
if (ch == opens[a]) {
return a + 1;
}
- else if (ch == close[a]) {
+ if (ch == close[a]) {
return -(a + 1);
}
}
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index e2c3c20e36e..8d5a0497e28 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -664,11 +664,11 @@ bool BKE_texture_dependsOnTime(const struct Tex *texture)
if (texture->ima && BKE_image_is_animated(texture->ima)) {
return true;
}
- else if (texture->adt) {
+ if (texture->adt) {
/* assume anything in adt means the texture is animated */
return true;
}
- else if (texture->type == TEX_NOISE) {
+ if (texture->type == TEX_NOISE) {
/* noise always varies with time */
return true;
}
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index f17467e4a26..7c34562e119 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -1188,38 +1188,36 @@ MovieTrackingMarker *BKE_tracking_marker_insert(MovieTrackingTrack *track,
return old_marker;
}
- else {
- int a = track->markersnr;
- /* find position in array where to add new marker */
- while (a--) {
- if (track->markers[a].framenr < marker->framenr) {
- break;
- }
+ int a = track->markersnr;
+
+ /* find position in array where to add new marker */
+ while (a--) {
+ if (track->markers[a].framenr < marker->framenr) {
+ break;
}
+ }
- track->markersnr++;
+ track->markersnr++;
- if (track->markers) {
- track->markers = MEM_reallocN(track->markers,
- sizeof(MovieTrackingMarker) * track->markersnr);
- }
- else {
- track->markers = MEM_callocN(sizeof(MovieTrackingMarker), "MovieTracking markers");
- }
+ if (track->markers) {
+ track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker) * track->markersnr);
+ }
+ else {
+ track->markers = MEM_callocN(sizeof(MovieTrackingMarker), "MovieTracking markers");
+ }
- /* shift array to "free" space for new marker */
- memmove(track->markers + a + 2,
- track->markers + a + 1,
- (track->markersnr - a - 2) * sizeof(MovieTrackingMarker));
+ /* shift array to "free" space for new marker */
+ memmove(track->markers + a + 2,
+ track->markers + a + 1,
+ (track->markersnr - a - 2) * sizeof(MovieTrackingMarker));
- /* put new marker */
- track->markers[a + 1] = *marker;
+ /* put new marker */
+ track->markers[a + 1] = *marker;
- track->last_marker = a + 1;
+ track->last_marker = a + 1;
- return &track->markers[a + 1];
- }
+ return &track->markers[a + 1];
}
void BKE_tracking_marker_delete(MovieTrackingTrack *track, int framenr)
@@ -1337,21 +1335,20 @@ MovieTrackingMarker *BKE_tracking_marker_get(MovieTrackingTrack *track, int fram
/* if there's no marker for exact position, use nearest marker from left side */
return &track->markers[a - 1];
}
- else {
- while (a >= 0 && track->markers[a].framenr >= framenr) {
- if (track->markers[a].framenr == framenr) {
- track->last_marker = a;
- return &track->markers[a];
- }
+ while (a >= 0 && track->markers[a].framenr >= framenr) {
+ if (track->markers[a].framenr == framenr) {
+ track->last_marker = a;
- a--;
+ return &track->markers[a];
}
- /* if there's no marker for exact position, use nearest marker from left side */
- return &track->markers[a];
+ a--;
}
+ /* if there's no marker for exact position, use nearest marker from left side */
+ return &track->markers[a];
+
return NULL;
}
@@ -1655,32 +1652,31 @@ MovieTrackingPlaneMarker *BKE_tracking_plane_marker_insert(MovieTrackingPlaneTra
return old_plane_marker;
}
- else {
- int a = plane_track->markersnr;
- /* Find position in array where to add new marker. */
- /* TODO(sergey): we could use bisect to speed things up. */
- while (a--) {
- if (plane_track->markers[a].framenr < plane_marker->framenr) {
- break;
- }
+ int a = plane_track->markersnr;
+
+ /* Find position in array where to add new marker. */
+ /* TODO(sergey): we could use bisect to speed things up. */
+ while (a--) {
+ if (plane_track->markers[a].framenr < plane_marker->framenr) {
+ break;
}
+ }
- plane_track->markersnr++;
- plane_track->markers = MEM_reallocN(plane_track->markers,
- sizeof(MovieTrackingPlaneMarker) * plane_track->markersnr);
+ plane_track->markersnr++;
+ plane_track->markers = MEM_reallocN(plane_track->markers,
+ sizeof(MovieTrackingPlaneMarker) * plane_track->markersnr);
- /* Shift array to "free" space for new marker. */
- memmove(plane_track->markers + a + 2,
- plane_track->markers + a + 1,
- (plane_track->markersnr - a - 2) * sizeof(MovieTrackingPlaneMarker));
+ /* Shift array to "free" space for new marker. */
+ memmove(plane_track->markers + a + 2,
+ plane_track->markers + a + 1,
+ (plane_track->markersnr - a - 2) * sizeof(MovieTrackingPlaneMarker));
- /* Put new marker to an array. */
- plane_track->markers[a + 1] = *plane_marker;
- plane_track->last_marker = a + 1;
+ /* Put new marker to an array. */
+ plane_track->markers[a + 1] = *plane_marker;
+ plane_track->last_marker = a + 1;
- return &plane_track->markers[a + 1];
- }
+ return &plane_track->markers[a + 1];
}
void BKE_tracking_plane_marker_delete(MovieTrackingPlaneTrack *plane_track, int framenr)
@@ -1748,21 +1744,20 @@ MovieTrackingPlaneMarker *BKE_tracking_plane_marker_get(MovieTrackingPlaneTrack
/* If there's no marker for exact position, use nearest marker from left side. */
return &plane_track->markers[a - 1];
}
- else {
- while (a >= 0 && plane_track->markers[a].framenr >= framenr) {
- if (plane_track->markers[a].framenr == framenr) {
- plane_track->last_marker = a;
- return &plane_track->markers[a];
- }
+ while (a >= 0 && plane_track->markers[a].framenr >= framenr) {
+ if (plane_track->markers[a].framenr == framenr) {
+ plane_track->last_marker = a;
- a--;
+ return &plane_track->markers[a];
}
- /* If there's no marker for exact position, use nearest marker from left side. */
- return &plane_track->markers[a];
+ a--;
}
+ /* If there's no marker for exact position, use nearest marker from left side. */
+ return &plane_track->markers[a];
+
return NULL;
}
@@ -1988,18 +1983,16 @@ static int reconstructed_camera_index_get(MovieTrackingReconstruction *reconstru
if (nearest) {
return 0;
}
- else {
- return -1;
- }
+
+ return -1;
}
if (framenr > cameras[reconstruction->camnr - 1].framenr) {
if (nearest) {
return reconstruction->camnr - 1;
}
- else {
- return -1;
- }
+
+ return -1;
}
if (reconstruction->last_camera < reconstruction->camnr) {
@@ -2020,9 +2013,8 @@ static int reconstructed_camera_index_get(MovieTrackingReconstruction *reconstru
if (nearest) {
return a - 1;
}
- else {
- break;
- }
+
+ break;
}
if (d < 0 && cfra < framenr) {
@@ -2030,9 +2022,8 @@ static int reconstructed_camera_index_get(MovieTrackingReconstruction *reconstru
if (nearest) {
return a;
}
- else {
- break;
- }
+
+ break;
}
if (cfra == framenr) {
@@ -2705,9 +2696,8 @@ static int channels_alpha_sort(const void *a, const void *b)
if (BLI_strcasecmp(channel_a->track->name, channel_b->track->name) > 0) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
static int channels_total_track_sort(const void *a, const void *b)
@@ -2718,9 +2708,8 @@ static int channels_total_track_sort(const void *a, const void *b)
if (channel_a->total_frames > channel_b->total_frames) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
static int channels_longest_segment_sort(const void *a, const void *b)
@@ -2731,9 +2720,8 @@ static int channels_longest_segment_sort(const void *a, const void *b)
if (channel_a->max_segment > channel_b->max_segment) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
static int channels_average_error_sort(const void *a, const void *b)
@@ -2744,9 +2732,8 @@ static int channels_average_error_sort(const void *a, const void *b)
if (channel_a->track->error > channel_b->track->error) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
static int channels_alpha_inverse_sort(const void *a, const void *b)
@@ -2754,9 +2741,8 @@ static int channels_alpha_inverse_sort(const void *a, const void *b)
if (channels_alpha_sort(a, b)) {
return 0;
}
- else {
- return 1;
- }
+
+ return 1;
}
static int channels_total_track_inverse_sort(const void *a, const void *b)
@@ -2764,9 +2750,8 @@ static int channels_total_track_inverse_sort(const void *a, const void *b)
if (channels_total_track_sort(a, b)) {
return 0;
}
- else {
- return 1;
- }
+
+ return 1;
}
static int channels_longest_segment_inverse_sort(const void *a, const void *b)
@@ -2774,9 +2759,8 @@ static int channels_longest_segment_inverse_sort(const void *a, const void *b)
if (channels_longest_segment_sort(a, b)) {
return 0;
}
- else {
- return 1;
- }
+
+ return 1;
}
static int channels_average_error_inverse_sort(const void *a, const void *b)
@@ -2787,9 +2771,8 @@ static int channels_average_error_inverse_sort(const void *a, const void *b)
if (channel_a->track->error < channel_b->track->error) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
/* Calculate frames segments at which track is tracked continuously. */
@@ -2840,7 +2823,7 @@ static void tracking_dopesheet_channels_segments_calc(MovieTrackingDopesheetChan
return;
}
- channel->segments = MEM_callocN(2 * sizeof(int) * channel->tot_segment,
+ channel->segments = MEM_callocN(sizeof(int[2]) * channel->tot_segment,
"tracking channel segments");
/* create segments */
@@ -2965,7 +2948,7 @@ static int coverage_from_count(int count)
if (count < 8) {
return TRACKING_COVERAGE_BAD;
}
- else if (count < 16) {
+ if (count < 16) {
return TRACKING_COVERAGE_ACCEPTABLE;
}
return TRACKING_COVERAGE_OK;
diff --git a/source/blender/blenkernel/intern/tracking_solver.c b/source/blender/blenkernel/intern/tracking_solver.c
index 46870a03e62..7df8bf62b16 100644
--- a/source/blender/blenkernel/intern/tracking_solver.c
+++ b/source/blender/blenkernel/intern/tracking_solver.c
@@ -335,7 +335,7 @@ bool BKE_tracking_reconstruction_check(MovieTracking *tracking,
/* TODO: check for number of tracks? */
return true;
}
- else if ((tracking->settings.reconstruction_flag & TRACKING_USE_KEYFRAME_SELECTION) == 0) {
+ if ((tracking->settings.reconstruction_flag & TRACKING_USE_KEYFRAME_SELECTION) == 0) {
/* automatic keyframe selection does not require any pre-process checks */
if (reconstruct_count_tracks_on_both_keyframes(tracking, object) < 8) {
BLI_strncpy(error_msg,
diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c
index e09e92588c6..46e3e10b01b 100644
--- a/source/blender/blenkernel/intern/tracking_stabilize.c
+++ b/source/blender/blenkernel/intern/tracking_stabilize.c
@@ -215,7 +215,7 @@ static void use_values_from_fcurves(StabContext *ctx, bool toggle)
/* Prepare per call private working area.
* Used for access to possibly animated values: retrieve available F-curves.
*/
-static StabContext *initialize_stabilization_working_context(MovieClip *clip)
+static StabContext *init_stabilization_working_context(MovieClip *clip)
{
StabContext *ctx = MEM_callocN(sizeof(StabContext), "2D stabilization animation runtime data");
ctx->clip = clip;
@@ -357,9 +357,8 @@ static MovieTrackingMarker *get_closest_marker(StabContext *ctx,
if ((next_higher - ref_frame) < (ref_frame - next_lower)) {
return BKE_tracking_marker_get_exact(track, next_higher);
}
- else {
- return BKE_tracking_marker_get_exact(track, next_lower);
- }
+
+ return BKE_tracking_marker_get_exact(track, next_lower);
}
/* Retrieve tracking data, if available and applicable for this frame.
@@ -377,11 +376,10 @@ static MovieTrackingMarker *get_tracking_data_point(StabContext *ctx,
*r_weight = get_animated_weight(ctx, track, framenr);
return marker;
}
- else {
- /* No marker at this frame (=gap) or marker disabled. */
- *r_weight = 0.0f;
- return NULL;
- }
+
+ /* No marker at this frame (=gap) or marker disabled. */
+ *r_weight = 0.0f;
+ return NULL;
}
/* Define the reference point for rotation/scale measurement and compensation.
@@ -841,14 +839,14 @@ static int establish_track_initialization_order(StabContext *ctx, TrackInitOrder
*
* NOTE: when done, this track is marked as initialized
*/
-static void initialize_track_for_stabilization(StabContext *ctx,
- MovieTrackingTrack *track,
- int reference_frame,
- float aspect,
- const float average_translation[2],
- const float pivot[2],
- const float average_angle,
- const float average_scale_step)
+static void init_track_for_stabilization(StabContext *ctx,
+ MovieTrackingTrack *track,
+ int reference_frame,
+ float aspect,
+ const float average_translation[2],
+ const float pivot[2],
+ const float average_angle,
+ const float average_scale_step)
{
float pos[2], angle, len;
TrackStabilizationBase *local_data = access_stabilization_baseline_data(ctx, track);
@@ -876,7 +874,7 @@ static void initialize_track_for_stabilization(StabContext *ctx,
local_data->is_init_for_stabilization = true;
}
-static void initialize_all_tracks(StabContext *ctx, float aspect)
+static void init_all_tracks(StabContext *ctx, float aspect)
{
size_t track_len = 0;
MovieClip *clip = ctx->clip;
@@ -936,14 +934,14 @@ static void initialize_all_tracks(StabContext *ctx, float aspect)
&average_angle,
&average_scale_step);
}
- initialize_track_for_stabilization(ctx,
- track,
- reference_frame,
- aspect,
- average_translation,
- pivot,
- average_angle,
- average_scale_step);
+ init_track_for_stabilization(ctx,
+ track,
+ reference_frame,
+ aspect,
+ average_translation,
+ pivot,
+ average_angle,
+ average_scale_step);
}
cleanup:
@@ -1094,7 +1092,7 @@ static void stabilization_data_to_mat4(float pixel_aspect,
{
float translation_mat[4][4], rotation_mat[4][4], scale_mat[4][4], pivot_mat[4][4],
inv_pivot_mat[4][4], aspect_mat[4][4], inv_aspect_mat[4][4];
- float scale_vector[3] = {scale, scale, 1.0f};
+ const float scale_vector[3] = {scale, scale, 1.0f};
unit_m4(translation_mat);
unit_m4(rotation_mat);
@@ -1257,9 +1255,9 @@ static float calculate_autoscale_factor(StabContext *ctx, int size, float aspect
*/
static StabContext *init_stabilizer(MovieClip *clip, int size, float aspect)
{
- StabContext *ctx = initialize_stabilization_working_context(clip);
+ StabContext *ctx = init_stabilization_working_context(clip);
BLI_assert(ctx != NULL);
- initialize_all_tracks(ctx, aspect);
+ init_all_tracks(ctx, aspect);
if (ctx->stab->flag & TRACKING_AUTOSCALE) {
ctx->stab->scale = 1.0;
ctx->stab->scale = calculate_autoscale_factor(ctx, size, aspect);
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index 0809e8dda6d..0a0f81f7829 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -476,9 +476,8 @@ UndoStep *BKE_undosys_step_push_init_with_type(UndoStack *ustack,
undosys_stack_validate(ustack, false);
return us;
}
- else {
- return NULL;
- }
+
+ return NULL;
}
UndoStep *BKE_undosys_step_push_init(UndoStack *ustack, bContext *C, const char *name)
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index f37feab4b85..8414f93ddaa 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -130,7 +130,7 @@ typedef struct bUnitCollection {
/* Keep table lignment. */
/* clang-format off */
-#define UNIT_COLLECTION_LENGTH(def) (sizeof(def) / sizeof(bUnitDef) - 1)
+#define UNIT_COLLECTION_LENGTH(def) (ARRAY_SIZE(def) - 1)
#define NULL_UNIT {NULL, NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
/* Dummy */
@@ -970,9 +970,8 @@ double bUnit_PreferredInputUnitScalar(const struct UnitSettings *settings, int t
if (unit) {
return unit->scalar;
}
- else {
- return bUnit_BaseScalar(units.system, type);
- }
+
+ return bUnit_BaseScalar(units.system, type);
}
/* make a copy of the string that replaces the units with numbers
@@ -1005,7 +1004,6 @@ bool bUnit_ReplaceString(
/* Fix cases like "-1m50cm" which would evaluate to -0.5m without this. */
changed |= unit_distribute_negatives(str, len_max);
- printf("%s\n", str);
/* Try to find a default unit from current or previous string. */
default_unit = unit_detect_from_str(usys, str, str_prev);
@@ -1156,9 +1154,8 @@ double bUnit_BaseScalar(int system, int type)
if (usys) {
return unit_default(usys)->scalar;
}
- else {
- return 1.0;
- }
+
+ return 1.0;
}
/* external access */
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index 48b920c8a05..54fb0f612d1 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -218,7 +218,9 @@ static struct VolumeFileCache {
cache.erase(entry);
}
else if (entry.num_tree_users == 0) {
- entry.grid->clear();
+ /* Note we replace the grid rather than clearing, so that if there is
+ * any other shared pointer to the grid it will keep the tree. */
+ entry.grid = entry.grid->copyGridWithNewTree();
entry.is_loaded = false;
}
}
@@ -239,15 +241,14 @@ struct VolumeGrid {
VolumeGrid(const VolumeFileCache::Entry &template_entry) : entry(NULL), is_loaded(false)
{
entry = GLOBAL_CACHE.add_metadata_user(template_entry);
- vdb = entry->grid;
}
- VolumeGrid(const openvdb::GridBase::Ptr &vdb) : vdb(vdb), entry(NULL), is_loaded(true)
+ VolumeGrid(const openvdb::GridBase::Ptr &grid) : entry(NULL), local_grid(grid), is_loaded(true)
{
}
VolumeGrid(const VolumeGrid &other)
- : vdb(other.vdb), entry(other.entry), is_loaded(other.is_loaded)
+ : entry(other.entry), local_grid(other.local_grid), is_loaded(other.is_loaded)
{
if (entry) {
GLOBAL_CACHE.copy_user(*entry, is_loaded);
@@ -330,7 +331,7 @@ struct VolumeGrid {
void clear_reference(const char *UNUSED(volume_name))
{
/* Clear any reference to a grid in the file cache. */
- vdb = vdb->copyGridWithNewTree();
+ local_grid = grid()->copyGridWithNewTree();
if (entry) {
GLOBAL_CACHE.remove_user(*entry, is_loaded);
entry = NULL;
@@ -344,7 +345,7 @@ struct VolumeGrid {
* file cache. Load file grid into memory first if needed. */
load(volume_name, filepath);
/* TODO: avoid deep copy if we are the only user. */
- vdb = vdb->deepCopyGrid();
+ local_grid = grid()->deepCopyGrid();
if (entry) {
GLOBAL_CACHE.remove_user(*entry, is_loaded);
entry = NULL;
@@ -356,7 +357,7 @@ struct VolumeGrid {
{
/* Don't use vdb.getName() since it copies the string, we want a pointer to the
* original so it doesn't get freed out of scope. */
- openvdb::StringMetadata::ConstPtr name_meta = vdb->getMetadata<openvdb::StringMetadata>(
+ openvdb::StringMetadata::ConstPtr name_meta = grid()->getMetadata<openvdb::StringMetadata>(
openvdb::GridBase::META_GRID_NAME);
return (name_meta) ? name_meta->value().c_str() : "";
}
@@ -366,15 +367,26 @@ struct VolumeGrid {
if (is_loaded && entry && !entry->error_msg.empty()) {
return entry->error_msg.c_str();
}
- else {
- return NULL;
- }
+
+ return NULL;
+ }
+
+ const bool grid_is_loaded() const
+ {
+ return is_loaded;
+ }
+
+ const openvdb::GridBase::Ptr &grid() const
+ {
+ return (entry) ? entry->grid : local_grid;
}
- /* OpenVDB grid. */
- openvdb::GridBase::Ptr vdb;
- /* File cache entry. */
+ protected:
+ /* File cache entry when grid comes directly from a file and may be shared
+ * with other volume datablocks. */
VolumeFileCache::Entry *entry;
+ /* OpenVDB grid if it's not shared through the file cache. */
+ openvdb::GridBase::Ptr local_grid;
/* Indicates if the tree has been loaded for this grid. Note that vdb.tree()
* may actually be loaded by another user while this is false. But only after
* calling load() and is_loaded changes to true is it safe to access. */
@@ -1047,7 +1059,7 @@ void BKE_volume_grid_unload(const Volume *volume, VolumeGrid *grid)
bool BKE_volume_grid_is_loaded(const VolumeGrid *grid)
{
#ifdef WITH_OPENVDB
- return grid->is_loaded;
+ return grid->grid_is_loaded();
#else
UNUSED_VARS(grid);
return true;
@@ -1069,39 +1081,39 @@ const char *BKE_volume_grid_name(const VolumeGrid *volume_grid)
VolumeGridType BKE_volume_grid_type(const VolumeGrid *volume_grid)
{
#ifdef WITH_OPENVDB
- const openvdb::GridBase::Ptr &grid = volume_grid->vdb;
+ const openvdb::GridBase::Ptr &grid = volume_grid->grid();
if (grid->isType<openvdb::FloatGrid>()) {
return VOLUME_GRID_FLOAT;
}
- else if (grid->isType<openvdb::Vec3fGrid>()) {
+ if (grid->isType<openvdb::Vec3fGrid>()) {
return VOLUME_GRID_VECTOR_FLOAT;
}
- else if (grid->isType<openvdb::BoolGrid>()) {
+ if (grid->isType<openvdb::BoolGrid>()) {
return VOLUME_GRID_BOOLEAN;
}
- else if (grid->isType<openvdb::DoubleGrid>()) {
+ if (grid->isType<openvdb::DoubleGrid>()) {
return VOLUME_GRID_DOUBLE;
}
- else if (grid->isType<openvdb::Int32Grid>()) {
+ if (grid->isType<openvdb::Int32Grid>()) {
return VOLUME_GRID_INT;
}
- else if (grid->isType<openvdb::Int64Grid>()) {
+ if (grid->isType<openvdb::Int64Grid>()) {
return VOLUME_GRID_INT64;
}
- else if (grid->isType<openvdb::Vec3IGrid>()) {
+ if (grid->isType<openvdb::Vec3IGrid>()) {
return VOLUME_GRID_VECTOR_INT;
}
- else if (grid->isType<openvdb::Vec3dGrid>()) {
+ if (grid->isType<openvdb::Vec3dGrid>()) {
return VOLUME_GRID_VECTOR_DOUBLE;
}
- else if (grid->isType<openvdb::StringGrid>()) {
+ if (grid->isType<openvdb::StringGrid>()) {
return VOLUME_GRID_STRING;
}
- else if (grid->isType<openvdb::MaskGrid>()) {
+ if (grid->isType<openvdb::MaskGrid>()) {
return VOLUME_GRID_MASK;
}
- else if (grid->isType<openvdb::points::PointDataGrid>()) {
+ if (grid->isType<openvdb::points::PointDataGrid>()) {
return VOLUME_GRID_POINTS;
}
#else
@@ -1138,7 +1150,7 @@ int BKE_volume_grid_channels(const VolumeGrid *grid)
void BKE_volume_grid_transform_matrix(const VolumeGrid *volume_grid, float mat[4][4])
{
#ifdef WITH_OPENVDB
- const openvdb::GridBase::Ptr &grid = volume_grid->vdb;
+ const openvdb::GridBase::Ptr &grid = volume_grid->grid();
const openvdb::math::Transform &transform = grid->transform();
/* Perspective not supported for now, getAffineMap() will leave out the
@@ -1162,7 +1174,7 @@ bool BKE_volume_grid_bounds(const VolumeGrid *volume_grid, float min[3], float m
{
#ifdef WITH_OPENVDB
/* TODO: we can get this from grid metadata in some cases? */
- const openvdb::GridBase::Ptr &grid = volume_grid->vdb;
+ const openvdb::GridBase::Ptr &grid = volume_grid->grid();
BLI_assert(BKE_volume_grid_is_loaded(volume_grid));
openvdb::CoordBBox coordbbox;
@@ -1287,14 +1299,14 @@ void BKE_volume_grid_remove(Volume *volume, VolumeGrid *grid)
#ifdef WITH_OPENVDB
openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_metadata(const VolumeGrid *grid)
{
- return grid->vdb;
+ return grid->grid();
}
openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_read(const Volume *volume,
VolumeGrid *grid)
{
BKE_volume_grid_load(volume, grid);
- return grid->vdb;
+ return grid->grid();
}
openvdb::GridBase::Ptr BKE_volume_grid_openvdb_for_write(const Volume *volume,
@@ -1310,6 +1322,6 @@ openvdb::GridBase::Ptr BKE_volume_grid_openvdb_for_write(const Volume *volume,
grid->duplicate_reference(volume_name, grids.filepath);
}
- return grid->vdb;
+ return grid->grid();
}
#endif
diff --git a/source/blender/blenkernel/intern/volume_render.cc b/source/blender/blenkernel/intern/volume_render.cc
index 135c6f78fef..98d3617c822 100644
--- a/source/blender/blenkernel/intern/volume_render.cc
+++ b/source/blender/blenkernel/intern/volume_render.cc
@@ -363,7 +363,6 @@ float BKE_volume_density_scale(const Volume *volume, const float matrix[4][4])
mul_mat3_m4_v3(matrix, unit);
return 1.0f / len_v3(unit);
}
- else {
- return 1.0f;
- }
+
+ return 1.0f;
}
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 4625fd76293..f653a190704 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -157,9 +157,8 @@ static void *workspace_relation_get_data_matching_parent(const ListBase *relatio
if (relation != NULL) {
return relation->value;
}
- else {
- return NULL;
- }
+
+ return NULL;
}
/**
@@ -397,10 +396,9 @@ bool BKE_workspace_owner_id_check(const WorkSpace *workspace, const char *owner_
if ((*owner_id == '\0') || ((workspace->flags & WORKSPACE_USE_FILTER_BY_ORIGIN) == 0)) {
return true;
}
- else {
- /* We could use hash lookup, for now this list is highly likely under < ~16 items. */
- return BLI_findstring(&workspace->owner_ids, owner_id, offsetof(wmOwnerID, name)) != NULL;
- }
+
+ /* We could use hash lookup, for now this list is highly likely under < ~16 items. */
+ return BLI_findstring(&workspace->owner_ids, owner_id, offsetof(wmOwnerID, name)) != NULL;
}
void BKE_workspace_id_tag_all_visible(Main *bmain, int tag)
diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h
index 67e9afdf7fa..7057e9ab5bd 100644
--- a/source/blender/blenkernel/nla_private.h
+++ b/source/blender/blenkernel/nla_private.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __NLA_PRIVATE_H__
-#define __NLA_PRIVATE_H__
+#pragma once
#include "BLI_bitmap.h"
#include "BLI_ghash.h"
@@ -190,5 +189,3 @@ void nladata_flush_channels(PointerRNA *ptr,
#ifdef __cplusplus
}
#endif
-
-#endif /* __NLA_PRIVATE_H__ */
diff --git a/source/blender/blenkernel/particle_private.h b/source/blender/blenkernel/particle_private.h
index 6f80089be29..33277d1caac 100644
--- a/source/blender/blenkernel/particle_private.h
+++ b/source/blender/blenkernel/particle_private.h
@@ -21,8 +21,7 @@
* \ingroup bke
*/
-#ifndef __PARTICLE_PRIVATE_H__
-#define __PARTICLE_PRIVATE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -72,5 +71,3 @@ void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx,
#ifdef __cplusplus
}
#endif
-
-#endif /* __PARTICLE_PRIVATE_H__ */
diff --git a/source/blender/blenkernel/tracking_private.h b/source/blender/blenkernel/tracking_private.h
index 955a0b8753e..0965cef0d9b 100644
--- a/source/blender/blenkernel/tracking_private.h
+++ b/source/blender/blenkernel/tracking_private.h
@@ -24,8 +24,7 @@
* by multiple tracking files but which should not be public.
*/
-#ifndef __TRACKING_PRIVATE_H__
-#define __TRACKING_PRIVATE_H__
+#pragma once
#include "BLI_threads.h"
@@ -152,5 +151,3 @@ void tracking_image_accessor_destroy(TrackingImageAccessor *accessor);
#ifdef __cplusplus
}
#endif
-
-#endif /* __TRACKING_PRIVATE_H__ */
diff --git a/source/blender/blenlib/BLI_alloca.h b/source/blender/blenlib/BLI_alloca.h
index 5297296b7ef..92567ed35fa 100644
--- a/source/blender/blenlib/BLI_alloca.h
+++ b/source/blender/blenlib/BLI_alloca.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_ALLOCA_H__
-#define __BLI_ALLOCA_H__
+#pragma once
/** \file
* \ingroup bli
@@ -25,6 +24,8 @@
/* BLI_array_alloca / alloca */
+#include <stdlib.h>
+
#if defined(__GNUC__) || defined(__clang__)
# if defined(__cplusplus) && (__cplusplus > 199711L)
# define BLI_array_alloca(arr, realsize) (decltype(arr)) alloca(sizeof(*arr) * (realsize))
@@ -34,5 +35,3 @@
#else
# define BLI_array_alloca(arr, realsize) alloca(sizeof(*arr) * (realsize))
#endif
-
-#endif /* __BLI_ALLOCA_H__ */
diff --git a/source/blender/blenlib/BLI_allocator.hh b/source/blender/blenlib/BLI_allocator.hh
index 47d8156476f..899c8499807 100644
--- a/source/blender/blenlib/BLI_allocator.hh
+++ b/source/blender/blenlib/BLI_allocator.hh
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_ALLOCATOR_HH__
-#define __BLI_ALLOCATOR_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -80,19 +79,20 @@ class RawAllocator {
public:
void *allocate(size_t size, size_t alignment, const char *UNUSED(name))
{
- BLI_assert(is_power_of_2_i((int)alignment));
+ BLI_assert(is_power_of_2_i(static_cast<int>(alignment)));
void *ptr = malloc(size + alignment + sizeof(MemHead));
- void *used_ptr = (void *)((uintptr_t)POINTER_OFFSET(ptr, alignment + sizeof(MemHead)) &
- ~((uintptr_t)alignment - 1));
- int offset = (int)((intptr_t)used_ptr - (intptr_t)ptr);
- BLI_assert(offset >= (int)sizeof(MemHead));
- ((MemHead *)used_ptr - 1)->offset = (int)offset;
+ void *used_ptr = reinterpret_cast<void *>(
+ reinterpret_cast<uintptr_t>(POINTER_OFFSET(ptr, alignment + sizeof(MemHead))) &
+ ~(static_cast<uintptr_t>(alignment) - 1));
+ int offset = static_cast<int>((intptr_t)used_ptr - (intptr_t)ptr);
+ BLI_assert(offset >= static_cast<int>(sizeof(MemHead)));
+ (static_cast<MemHead *>(used_ptr) - 1)->offset = offset;
return used_ptr;
}
void deallocate(void *ptr)
{
- MemHead *head = (MemHead *)ptr - 1;
+ MemHead *head = static_cast<MemHead *>(ptr) - 1;
int offset = -head->offset;
void *actual_pointer = POINTER_OFFSET(ptr, offset);
free(actual_pointer);
@@ -100,5 +100,3 @@ class RawAllocator {
};
} // namespace blender
-
-#endif /* __BLI_ALLOCATOR_HH__ */
diff --git a/source/blender/blenlib/BLI_args.h b/source/blender/blenlib/BLI_args.h
index 9031cd2ba2f..54b5161f15a 100644
--- a/source/blender/blenlib/BLI_args.h
+++ b/source/blender/blenlib/BLI_args.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_ARGS_H__
-#define __BLI_ARGS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -78,5 +77,3 @@ const char **BLI_argsArgv(struct bArgs *ba);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h
index 5b85711f8ac..6ea01d45f79 100644
--- a/source/blender/blenlib/BLI_array.h
+++ b/source/blender/blenlib/BLI_array.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_ARRAY_H__
-#define __BLI_ARRAY_H__
+#pragma once
/** \file
* \ingroup bli
@@ -173,5 +172,3 @@ void _bli_array_grow_func(void **arr_p,
((void)0)
/** \} */
-
-#endif /* __BLI_ARRAY_H__ */
diff --git a/source/blender/blenlib/BLI_array.hh b/source/blender/blenlib/BLI_array.hh
index c7b4bdc977f..9b307dc6a04 100644
--- a/source/blender/blenlib/BLI_array.hh
+++ b/source/blender/blenlib/BLI_array.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_ARRAY_HH__
-#define __BLI_ARRAY_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -177,7 +176,7 @@ class Array {
{
destruct_n(data_, size_);
if (!this->uses_inline_buffer()) {
- allocator_.deallocate((void *)data_);
+ allocator_.deallocate(static_cast<void *>(data_));
}
}
@@ -352,7 +351,8 @@ class Array {
T *allocate(int64_t size)
{
- return (T *)allocator_.allocate((size_t)size * sizeof(T), alignof(T), AT);
+ return static_cast<T *>(
+ allocator_.allocate(static_cast<size_t>(size) * sizeof(T), alignof(T), AT));
}
bool uses_inline_buffer() const
@@ -369,5 +369,3 @@ template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capaci
using RawArray = Array<T, InlineBufferCapacity, RawAllocator>;
} // namespace blender
-
-#endif /* __BLI_ARRAY_HH__ */
diff --git a/source/blender/blenlib/BLI_array_store.h b/source/blender/blenlib/BLI_array_store.h
index a8a7dde63b5..78d718117ba 100644
--- a/source/blender/blenlib/BLI_array_store.h
+++ b/source/blender/blenlib/BLI_array_store.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_ARRAY_STORE_H__
-#define __BLI_ARRAY_STORE_H__
+#pragma once
/** \file
* \ingroup bli
@@ -53,5 +52,3 @@ bool BLI_array_store_is_valid(BArrayStore *bs);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_ARRAY_STORE_H__ */
diff --git a/source/blender/blenlib/BLI_array_store_utils.h b/source/blender/blenlib/BLI_array_store_utils.h
index 5b5263bf8a4..771f4f962a7 100644
--- a/source/blender/blenlib/BLI_array_store_utils.h
+++ b/source/blender/blenlib/BLI_array_store_utils.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_ARRAY_STORE_UTILS_H__
-#define __BLI_ARRAY_STORE_UTILS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -47,5 +46,3 @@ void BLI_array_store_at_size_calc_memory_usage(struct BArrayStore_AtSize *bs_str
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_ARRAY_STORE_UTILS_H__ */
diff --git a/source/blender/blenlib/BLI_array_utils.h b/source/blender/blenlib/BLI_array_utils.h
index afa9a3d2241..b8d63e7cdc1 100644
--- a/source/blender/blenlib/BLI_array_utils.h
+++ b/source/blender/blenlib/BLI_array_utils.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_ARRAY_UTILS_H__
-#define __BLI_ARRAY_UTILS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -93,5 +92,3 @@ bool _bli_array_is_zeroed(const void *arr, unsigned int arr_len, size_t arr_stri
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_ARRAY_UTILS_H__ */
diff --git a/source/blender/blenlib/BLI_asan.h b/source/blender/blenlib/BLI_asan.h
index fdade805c2a..a2a44e164ab 100644
--- a/source/blender/blenlib/BLI_asan.h
+++ b/source/blender/blenlib/BLI_asan.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_ADDRESS_SANITIZER_H__
-#define __BLI_ADDRESS_SANITIZER_H__
+#pragma once
/* Clang defines this. */
#ifndef __has_feature
@@ -41,5 +40,3 @@
* Mark a region of memory as usable again.
*/
#define BLI_asan_unpoison(addr, size) ASAN_UNPOISON_MEMORY_REGION(addr, size)
-
-#endif /* __BLI_ADDRESS_SANITIZER_H__ */
diff --git a/source/blender/blenlib/BLI_assert.h b/source/blender/blenlib/BLI_assert.h
index 603be115b35..172a2fb44ca 100644
--- a/source/blender/blenlib/BLI_assert.h
+++ b/source/blender/blenlib/BLI_assert.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_ASSERT_H__
-#define __BLI_ASSERT_H__
+#pragma once
/** \file
* \ingroup bli
@@ -30,58 +29,33 @@
extern "C" {
#endif
-#ifndef NDEBUG /* for BLI_assert */
-# include <stdio.h>
-#endif
+/* Utility functions. */
+void _BLI_assert_print_pos(const char *file, const int line, const char *function, const char *id);
+void _BLI_assert_print_backtrace(void);
+void _BLI_assert_abort(void);
#ifdef _MSC_VER
# include <crtdbg.h> /* for _STATIC_ASSERT */
#endif
-/* BLI_assert(), default only to print
- * for aborting need to define WITH_ASSERT_ABORT
- */
-/* For 'abort' only. */
-#include <stdlib.h>
-
#ifndef NDEBUG
-# include "BLI_system.h"
/* _BLI_ASSERT_PRINT_POS */
# if defined(__GNUC__)
-# define _BLI_ASSERT_PRINT_POS(a) \
- fprintf(stderr, \
- "BLI_assert failed: %s:%d, %s(), at \'%s\'\n", \
- __FILE__, \
- __LINE__, \
- __func__, \
- #a)
+# define _BLI_ASSERT_PRINT_POS(a) _BLI_assert_print_pos(__FILE__, __LINE__, __func__, # a)
# elif defined(_MSC_VER)
-# define _BLI_ASSERT_PRINT_POS(a) \
- fprintf(stderr, \
- "BLI_assert failed: %s:%d, %s(), at \'%s\'\n", \
- __FILE__, \
- __LINE__, \
- __FUNCTION__, \
- #a)
+# define _BLI_ASSERT_PRINT_POS(a) _BLI_assert_print_pos(__FILE__, __LINE__, __func__, # a)
# else
-# define _BLI_ASSERT_PRINT_POS(a) \
- fprintf(stderr, "BLI_assert failed: %s:%d, at \'%s\'\n", __FILE__, __LINE__, #a)
+# define _BLI_ASSERT_PRINT_POS(a) _BLI_assert_print_pos(__FILE__, __LINE__, "<?>", # a)
# endif
/* _BLI_ASSERT_ABORT */
# ifdef WITH_ASSERT_ABORT
-# ifdef __GNUC__
-/* Cast to remove 'noreturn' attribute since this suppresses missing return statements,
- * allowing changes to debug builds to accidentally to break release builds. */
-# define _BLI_ASSERT_ABORT ((void (*)(void))(*(((void **)abort))))
-# else
-# define _BLI_ASSERT_ABORT abort
-# endif
+# define _BLI_ASSERT_ABORT _BLI_assert_abort
# else
# define _BLI_ASSERT_ABORT() (void)0
# endif
/* BLI_assert */
# define BLI_assert(a) \
- (void)((!(a)) ? ((BLI_system_backtrace(stderr), \
+ (void)((!(a)) ? ((_BLI_assert_print_backtrace(), \
_BLI_ASSERT_PRINT_POS(a), \
_BLI_ASSERT_ABORT(), \
NULL)) : \
@@ -117,5 +91,3 @@ extern "C" {
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_ASSERT_H__ */
diff --git a/source/blender/blenlib/BLI_astar.h b/source/blender/blenlib/BLI_astar.h
index 8a70371cbcb..fe5c4ddad69 100644
--- a/source/blender/blenlib/BLI_astar.h
+++ b/source/blender/blenlib/BLI_astar.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_ASTAR_H__
-#define __BLI_ASTAR_H__
+#pragma once
/** \file
* \ingroup bli
@@ -121,5 +120,3 @@ bool BLI_astar_graph_solve(BLI_AStarGraph *as_graph,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_ASTAR_H__ */
diff --git a/source/blender/blenlib/BLI_bitmap.h b/source/blender/blenlib/BLI_bitmap.h
index 2b811e50efb..61a50662d79 100644
--- a/source/blender/blenlib/BLI_bitmap.h
+++ b/source/blender/blenlib/BLI_bitmap.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_BITMAP_H__
-#define __BLI_BITMAP_H__
+#pragma once
/** \file
* \ingroup bli
@@ -118,5 +117,3 @@ void BLI_bitmap_or_all(BLI_bitmap *dst, const BLI_bitmap *src, size_t bits);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenlib/BLI_bitmap_draw_2d.h b/source/blender/blenlib/BLI_bitmap_draw_2d.h
index f5f8b28b27f..8331d8fac08 100644
--- a/source/blender/blenlib/BLI_bitmap_draw_2d.h
+++ b/source/blender/blenlib/BLI_bitmap_draw_2d.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_BITMAP_DRAW_2D_H__
-#define __BLI_BITMAP_DRAW_2D_H__
+#pragma once
/** \file
* \ingroup bli
@@ -48,5 +47,3 @@ void BLI_bitmap_draw_2d_poly_v2i_n(const int xmin,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_BITMAP_DRAW_2D_H__ */
diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h
index 4ebef814337..a9e8c55b6b4 100644
--- a/source/blender/blenlib/BLI_blenlib.h
+++ b/source/blender/blenlib/BLI_blenlib.h
@@ -47,8 +47,7 @@
* standard libraries.
*/
-#ifndef __BLI_BLENLIB_H__
-#define __BLI_BLENLIB_H__
+#pragma once
#include <stdlib.h>
@@ -63,5 +62,3 @@
#include "BLI_fileops.h"
#include "BLI_rect.h"
-
-#endif
diff --git a/source/blender/blenlib/BLI_boxpack_2d.h b/source/blender/blenlib/BLI_boxpack_2d.h
index 762cb7aaa44..c36cbc03928 100644
--- a/source/blender/blenlib/BLI_boxpack_2d.h
+++ b/source/blender/blenlib/BLI_boxpack_2d.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_BOXPACK_2D_H__
-#define __BLI_BOXPACK_2D_H__
+#pragma once
/** \file
* \ingroup bli
@@ -64,5 +63,3 @@ void BLI_box_pack_2d_fixedarea(struct ListBase *boxes,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_BOXPACK_2D_H__ */
diff --git a/source/blender/blenlib/BLI_buffer.h b/source/blender/blenlib/BLI_buffer.h
index d81446af14b..fc348c25c46 100644
--- a/source/blender/blenlib/BLI_buffer.h
+++ b/source/blender/blenlib/BLI_buffer.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_BUFFER_H__
-#define __BLI_BUFFER_H__
+#pragma once
/** \file
* \ingroup bli
@@ -100,5 +99,3 @@ void _bli_buffer_free(BLI_Buffer *buffer);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_BUFFER_H__ */
diff --git a/source/blender/blenlib/BLI_color.hh b/source/blender/blenlib/BLI_color.hh
index 72caa5b1118..e57a5109a66 100644
--- a/source/blender/blenlib/BLI_color.hh
+++ b/source/blender/blenlib/BLI_color.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_COLOR_HH__
-#define __BLI_COLOR_HH__
+#pragma once
#include <iostream>
@@ -64,10 +63,10 @@ struct Color4f {
uint64_t hash() const
{
- uint64_t x1 = *(uint32_t *)&r;
- uint64_t x2 = *(uint32_t *)&g;
- uint64_t x3 = *(uint32_t *)&b;
- uint64_t x4 = *(uint32_t *)&a;
+ uint64_t x1 = *reinterpret_cast<const uint32_t *>(&r);
+ uint64_t x2 = *reinterpret_cast<const uint32_t *>(&g);
+ uint64_t x3 = *reinterpret_cast<const uint32_t *>(&b);
+ uint64_t x4 = *reinterpret_cast<const uint32_t *>(&a);
return (x1 * 1283591) ^ (x2 * 850177) ^ (x3 * 735391) ^ (x4 * 442319);
}
};
@@ -121,11 +120,9 @@ struct Color4b {
uint64_t hash() const
{
- return ((uint64_t)r * 1283591) ^ ((uint64_t)g * 850177) ^ ((uint64_t)b * 735391) ^
- ((uint64_t)a * 442319);
+ return static_cast<uint64_t>(r * 1283591) ^ static_cast<uint64_t>(g * 850177) ^
+ static_cast<uint64_t>(b * 735391) ^ static_cast<uint64_t>(a * 442319);
}
};
} // namespace blender
-
-#endif /* __BLI_COLOR_HH__ */
diff --git a/source/blender/blenlib/BLI_compiler_attrs.h b/source/blender/blenlib/BLI_compiler_attrs.h
index 24da0be122c..680c4bc78da 100644
--- a/source/blender/blenlib/BLI_compiler_attrs.h
+++ b/source/blender/blenlib/BLI_compiler_attrs.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_COMPILER_ATTRS_H__
-#define __BLI_COMPILER_ATTRS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -99,5 +98,3 @@
#else
# define ATTR_ALIGN(x) __attribute__((aligned(x)))
#endif
-
-#endif /* __BLI_COMPILER_ATTRS_H__ */
diff --git a/source/blender/blenlib/BLI_compiler_compat.h b/source/blender/blenlib/BLI_compiler_compat.h
index 056ea1a08c6..0870d01872a 100644
--- a/source/blender/blenlib/BLI_compiler_compat.h
+++ b/source/blender/blenlib/BLI_compiler_compat.h
@@ -19,8 +19,8 @@
/* #define typeof() triggers a bug in some clang-format versions, disable format
* for entire file to keep results consistent. */
-#ifndef __BLI_COMPILER_COMPAT_H__
-#define __BLI_COMPILER_COMPAT_H__
+#pragma once
+
/** \file
* \ingroup bli
@@ -56,4 +56,3 @@ template<typename T> static inline T decltype_helper(T x)
# define BLI_NOINLINE
#endif
-#endif /* __BLI_COMPILER_COMPAT_H__ */
diff --git a/source/blender/blenlib/BLI_compiler_typecheck.h b/source/blender/blenlib/BLI_compiler_typecheck.h
index 0a2eddc4ecc..d9c2bfc1d58 100644
--- a/source/blender/blenlib/BLI_compiler_typecheck.h
+++ b/source/blender/blenlib/BLI_compiler_typecheck.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_COMPILER_TYPECHECK_H__
-#define __BLI_COMPILER_TYPECHECK_H__
+#pragma once
/** \file
* \ingroup bli
@@ -692,5 +691,3 @@
/* clang-format on */
#define GENERIC_TYPE_ANY(...) VA_NARGS_CALL_OVERLOAD(_VA_GENERIC_TYPE_ANY, __VA_ARGS__)
-
-#endif /* __BLI_COMPILER_TYPECHECK_H__ */
diff --git a/source/blender/blenlib/BLI_console.h b/source/blender/blenlib/BLI_console.h
index d666de3a8e8..dc07d3df754 100644
--- a/source/blender/blenlib/BLI_console.h
+++ b/source/blender/blenlib/BLI_console.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_CONSOLE_H__
-#define __BLI_CONSOLE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -40,5 +39,3 @@ extern "C" {
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_CONSOLE_H__ */
diff --git a/source/blender/blenlib/BLI_convexhull_2d.h b/source/blender/blenlib/BLI_convexhull_2d.h
index 7417c1e3a98..e930117822f 100644
--- a/source/blender/blenlib/BLI_convexhull_2d.h
+++ b/source/blender/blenlib/BLI_convexhull_2d.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_CONVEXHULL_2D_H__
-#define __BLI_CONVEXHULL_2D_H__
+#pragma once
/** \file
* \ingroup bli
@@ -34,5 +33,3 @@ float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], unsigned int n
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_CONVEXHULL_2D_H__ */
diff --git a/source/blender/blenlib/BLI_delaunay_2d.h b/source/blender/blenlib/BLI_delaunay_2d.h
index 95111dbbbf7..a826a6b2677 100644
--- a/source/blender/blenlib/BLI_delaunay_2d.h
+++ b/source/blender/blenlib/BLI_delaunay_2d.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_DELAUNAY_2D_H__
-#define __BLI_DELAUNAY_2D_H__
+#pragma once
/** \file
* \ingroup bli
@@ -209,5 +208,3 @@ void BLI_delaunay_2d_cdt_free(CDT_result *result);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_DELAUNAY_2D_H__ */
diff --git a/source/blender/blenlib/BLI_dial_2d.h b/source/blender/blenlib/BLI_dial_2d.h
index a39543720e6..fdbc3d4430b 100644
--- a/source/blender/blenlib/BLI_dial_2d.h
+++ b/source/blender/blenlib/BLI_dial_2d.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_DIAL_2D_H__
-#define __BLI_DIAL_2D_H__
+#pragma once
/** \file
* \ingroup bli
@@ -38,7 +37,7 @@
* float angle;
* Dial *dial;
*
- * dial = BLI_dial_initialize(start_position, threshold);
+ * dial = BLI_dial_init(start_position, threshold);
*
* angle = BLI_dial_angle(dial, current_position);
*
@@ -52,12 +51,10 @@ extern "C" {
typedef struct Dial Dial;
-Dial *BLI_dial_initialize(const float start_position[2], float threshold);
+Dial *BLI_dial_init(const float start_position[2], float threshold);
float BLI_dial_angle(Dial *dial, const float current_position[2]);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_DIAL_2D_H__ */
diff --git a/source/blender/blenlib/BLI_disjoint_set.hh b/source/blender/blenlib/BLI_disjoint_set.hh
index e0580709a44..2002577f956 100644
--- a/source/blender/blenlib/BLI_disjoint_set.hh
+++ b/source/blender/blenlib/BLI_disjoint_set.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_DISJOINT_SET_HH__
-#define __BLI_DISJOINT_SET_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -102,5 +101,3 @@ class DisjointSet {
};
} // namespace blender
-
-#endif /* __BLI_DISJOINT_SET_HH__ */
diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h
index 5db0dd16a34..fc52904d699 100644
--- a/source/blender/blenlib/BLI_dlrbTree.h
+++ b/source/blender/blenlib/BLI_dlrbTree.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_DLRBTREE_H__
-#define __BLI_DLRBTREE_H__
+#pragma once
/** \file
* \ingroup bli
@@ -166,5 +165,3 @@ void BLI_dlrbTree_insert(DLRBT_Tree *tree, DLRBT_Node *node);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_DLRBTREE_H__ */
diff --git a/source/blender/blenlib/BLI_dot_export.hh b/source/blender/blenlib/BLI_dot_export.hh
index 0870d8c4c30..a026a85dd62 100644
--- a/source/blender/blenlib/BLI_dot_export.hh
+++ b/source/blender/blenlib/BLI_dot_export.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_DOT_EXPORT_HH__
-#define __BLI_DOT_EXPORT_HH__
+#pragma once
/**
* Language grammar: https://www.graphviz.org/doc/info/lang.html
@@ -44,9 +43,8 @@ class NodePort;
class DirectedEdge;
class UndirectedEdge;
class Cluster;
-class AttributeList;
-class AttributeList {
+class Attributes {
private:
Map<std::string, std::string> attributes_;
@@ -57,11 +55,15 @@ class AttributeList {
{
attributes_.add_overwrite(key, value);
}
+
+ void set(StringRef key, float value)
+ {
+ attributes_.add_overwrite(key, std::to_string(value));
+ }
};
class Graph {
private:
- AttributeList attributes_;
Vector<std::unique_ptr<Node>> nodes_;
Vector<std::unique_ptr<Cluster>> clusters_;
@@ -72,19 +74,17 @@ class Graph {
friend Node;
public:
+ Attributes attributes;
+
+ public:
Node &new_node(StringRef label);
Cluster &new_cluster(StringRef label = "");
void export__declare_nodes_and_clusters(std::stringstream &ss) const;
- void set_attribute(StringRef key, StringRef value)
- {
- attributes_.set(key, value);
- }
-
void set_rankdir(Attr_rankdir rankdir)
{
- this->set_attribute("rankdir", rankdir_to_string(rankdir));
+ attributes.set("rankdir", rankdir_to_string(rankdir));
}
void set_random_cluster_bgcolors();
@@ -92,7 +92,6 @@ class Graph {
class Cluster {
private:
- AttributeList attributes_;
Graph &graph_;
Cluster *parent_ = nullptr;
Set<Cluster *> children_;
@@ -101,6 +100,9 @@ class Cluster {
friend Graph;
friend Node;
+ public:
+ Attributes attributes;
+
Cluster(Graph &graph) : graph_(graph)
{
}
@@ -108,9 +110,9 @@ class Cluster {
public:
void export__declare_nodes_and_clusters(std::stringstream &ss) const;
- void set_attribute(StringRef key, StringRef value)
+ std::string name() const
{
- attributes_.set(key, value);
+ return "cluster_" + std::to_string((uintptr_t)this);
}
void set_parent_cluster(Cluster *cluster);
@@ -119,53 +121,52 @@ class Cluster {
this->set_parent_cluster(&cluster);
}
+ Cluster *parent_cluster()
+ {
+ return parent_;
+ }
+
void set_random_cluster_bgcolors();
+
+ bool contains(Node &node) const;
};
class Node {
private:
- AttributeList attributes_;
Graph &graph_;
Cluster *cluster_ = nullptr;
friend Graph;
- Node(Graph &graph) : graph_(graph)
- {
- }
-
public:
- const AttributeList &attributes() const
- {
- return attributes_;
- }
+ Attributes attributes;
- AttributeList &attributes()
+ Node(Graph &graph) : graph_(graph)
{
- return attributes_;
}
+ public:
void set_parent_cluster(Cluster *cluster);
void set_parent_cluster(Cluster &cluster)
{
this->set_parent_cluster(&cluster);
}
- void set_attribute(StringRef key, StringRef value)
+ Cluster *parent_cluster()
{
- attributes_.set(key, value);
+ return cluster_;
}
void set_shape(Attr_shape shape)
{
- this->set_attribute("shape", shape_to_string(shape));
+ attributes.set("shape", shape_to_string(shape));
}
/* See https://www.graphviz.org/doc/info/attrs.html#k:color. */
void set_background_color(StringRef name)
{
- this->set_attribute("fillcolor", name);
- this->set_attribute("style", "filled");
+ attributes.set("fillcolor", name);
+ attributes.set("style", "filled");
}
void export__as_id(std::stringstream &ss) const;
@@ -209,33 +210,35 @@ class NodePort {
class Edge : blender::NonCopyable, blender::NonMovable {
protected:
- AttributeList attributes_;
NodePort a_;
NodePort b_;
public:
- Edge(NodePort a, NodePort b) : a_(std::move(a)), b_(std::move(b))
- {
- }
+ Attributes attributes;
- void set_attribute(StringRef key, StringRef value)
+ public:
+ Edge(NodePort a, NodePort b) : a_(std::move(a)), b_(std::move(b))
{
- attributes_.set(key, value);
}
void set_arrowhead(Attr_arrowType type)
{
- this->set_attribute("arrowhead", arrowType_to_string(type));
+ attributes.set("arrowhead", arrowType_to_string(type));
}
void set_arrowtail(Attr_arrowType type)
{
- this->set_attribute("arrowtail", arrowType_to_string(type));
+ attributes.set("arrowtail", arrowType_to_string(type));
}
void set_dir(Attr_dirType type)
{
- this->set_attribute("dir", dirType_to_string(type));
+ attributes.set("dir", dirType_to_string(type));
+ }
+
+ void set_label(StringRef label)
+ {
+ attributes.set("label", label);
}
};
@@ -288,5 +291,3 @@ class NodeWithSocketsRef {
};
} // namespace blender::dot
-
-#endif /* __BLI_DOT_EXPORT_HH__ */
diff --git a/source/blender/blenlib/BLI_dot_export_attribute_enums.hh b/source/blender/blenlib/BLI_dot_export_attribute_enums.hh
index 94c7025b2a6..8cbe7a3e6e6 100644
--- a/source/blender/blenlib/BLI_dot_export_attribute_enums.hh
+++ b/source/blender/blenlib/BLI_dot_export_attribute_enums.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_DOT_EXPORT_ATTRIBUTE_ENUMS_HH__
-#define __BLI_DOT_EXPORT_ATTRIBUTE_ENUMS_HH__
+#pragma once
#include "BLI_string_ref.hh"
@@ -119,5 +118,3 @@ inline StringRef dirType_to_string(Attr_dirType value)
}
} // namespace blender::dot
-
-#endif /* __BLI_DOT_EXPORT_ATTRIBUTE_ENUMS_HH__ */
diff --git a/source/blender/blenlib/BLI_dynlib.h b/source/blender/blenlib/BLI_dynlib.h
index 4adffd51e17..628e33b6f02 100644
--- a/source/blender/blenlib/BLI_dynlib.h
+++ b/source/blender/blenlib/BLI_dynlib.h
@@ -21,8 +21,7 @@
* \ingroup bli
*/
-#ifndef __BLI_DYNLIB_H__
-#define __BLI_DYNLIB_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -38,5 +37,3 @@ void BLI_dynlib_close(DynamicLibrary *lib);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_DYNLIB_H__ */
diff --git a/source/blender/blenlib/BLI_dynstr.h b/source/blender/blenlib/BLI_dynstr.h
index cb1f3d58f23..075786c4424 100644
--- a/source/blender/blenlib/BLI_dynstr.h
+++ b/source/blender/blenlib/BLI_dynstr.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_DYNSTR_H__
-#define __BLI_DYNSTR_H__
+#pragma once
/** \file
* \ingroup bli
@@ -64,5 +63,3 @@ void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL();
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_DYNSTR_H__ */
diff --git a/source/blender/blenlib/BLI_easing.h b/source/blender/blenlib/BLI_easing.h
index 73e17be31b7..e6bf8c3bdfa 100644
--- a/source/blender/blenlib/BLI_easing.h
+++ b/source/blender/blenlib/BLI_easing.h
@@ -28,8 +28,7 @@
* All rights reserved.
*/
-#ifndef __BLI_EASING_H__
-#define __BLI_EASING_H__
+#pragma once
/** \file
* \ingroup bli
@@ -80,5 +79,3 @@ float BLI_easing_sine_ease_in_out(float time, float begin, float change, float d
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_EASING_H__ */
diff --git a/source/blender/blenlib/BLI_edgehash.h b/source/blender/blenlib/BLI_edgehash.h
index 0e2d0b538c7..44dc3cf096b 100644
--- a/source/blender/blenlib/BLI_edgehash.h
+++ b/source/blender/blenlib/BLI_edgehash.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_EDGEHASH_H__
-#define __BLI_EDGEHASH_H__
+#pragma once
/** \file
* \ingroup bli
@@ -158,5 +157,3 @@ BLI_INLINE bool BLI_edgesetIterator_isDone(EdgeSetIterator *esi)
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_EDGEHASH_H__ */
diff --git a/source/blender/blenlib/BLI_endian_switch_inline.h b/source/blender/blenlib/BLI_endian_switch_inline.h
index 316e24cfc6d..70d428147e2 100644
--- a/source/blender/blenlib/BLI_endian_switch_inline.h
+++ b/source/blender/blenlib/BLI_endian_switch_inline.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_ENDIAN_SWITCH_INLINE_H__
-#define __BLI_ENDIAN_SWITCH_INLINE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -92,5 +91,3 @@ BLI_INLINE void BLI_endian_switch_double(double *val)
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_ENDIAN_SWITCH_INLINE_H__ */
diff --git a/source/blender/blenlib/BLI_expr_pylike_eval.h b/source/blender/blenlib/BLI_expr_pylike_eval.h
index 1db91ea4205..c074b5d8130 100644
--- a/source/blender/blenlib/BLI_expr_pylike_eval.h
+++ b/source/blender/blenlib/BLI_expr_pylike_eval.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_EXPR_PYLIKE_EVAL_H__
-#define __BLI_EXPR_PYLIKE_EVAL_H__
+#pragma once
/** \file
* \ingroup bli
@@ -57,5 +56,3 @@ eExprPyLike_EvalStatus BLI_expr_pylike_eval(struct ExprPyLike_Parsed *expr,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_EXPR_PYLIKE_EVAL_H__ */
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h
index fe4600b9121..e61e20ee5e9 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -22,8 +22,7 @@
* \brief File and directory operations.
* */
-#ifndef __BLI_FILEOPS_H__
-#define __BLI_FILEOPS_H__
+#pragma once
#include <stdint.h>
#include <stdio.h>
@@ -189,5 +188,3 @@ void BLI_get_short_name(char short_name[256], const char *filename);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_FILEOPS_H__ */
diff --git a/source/blender/blenlib/BLI_fileops_types.h b/source/blender/blenlib/BLI_fileops_types.h
index 41f916ed0ca..cdae9665f98 100644
--- a/source/blender/blenlib/BLI_fileops_types.h
+++ b/source/blender/blenlib/BLI_fileops_types.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_FILEOPS_TYPES_H__
-#define __BLI_FILEOPS_TYPES_H__
+#pragma once
/** \file
* \ingroup bli
@@ -64,5 +63,3 @@ struct dirlink {
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_FILEOPS_TYPES_H__ */
diff --git a/source/blender/blenlib/BLI_float2.hh b/source/blender/blenlib/BLI_float2.hh
index 5fe9d1b8ca9..e55a8de4633 100644
--- a/source/blender/blenlib/BLI_float2.hh
+++ b/source/blender/blenlib/BLI_float2.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_FLOAT2_HH__
-#define __BLI_FLOAT2_HH__
+#pragma once
#include "BLI_float3.hh"
@@ -120,5 +119,3 @@ struct float2 {
};
} // namespace blender
-
-#endif /* __BLI_FLOAT2_HH__ */
diff --git a/source/blender/blenlib/BLI_float3.hh b/source/blender/blenlib/BLI_float3.hh
index a0979bc75bd..2d90498fee8 100644
--- a/source/blender/blenlib/BLI_float3.hh
+++ b/source/blender/blenlib/BLI_float3.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_FLOAT3_HH__
-#define __BLI_FLOAT3_HH__
+#pragma once
#include <iostream>
@@ -32,7 +31,7 @@ struct float3 {
{
}
- float3(const float (*ptr)[3]) : float3((const float *)ptr)
+ float3(const float (*ptr)[3]) : float3(static_cast<const float *>(ptr[0]))
{
}
@@ -63,11 +62,12 @@ struct float3 {
return {a.x + b.x, a.y + b.y, a.z + b.z};
}
- void operator+=(const float3 &b)
+ float3 &operator+=(const float3 &b)
{
this->x += b.x;
this->y += b.y;
this->z += b.z;
+ return *this;
}
friend float3 operator-(const float3 &a, const float3 &b)
@@ -80,25 +80,28 @@ struct float3 {
return {-a.x, -a.y, -a.z};
}
- void operator-=(const float3 &b)
+ float3 &operator-=(const float3 &b)
{
this->x -= b.x;
this->y -= b.y;
this->z -= b.z;
+ return *this;
}
- void operator*=(float scalar)
+ float3 &operator*=(float scalar)
{
this->x *= scalar;
this->y *= scalar;
this->z *= scalar;
+ return *this;
}
- void operator*=(const float3 &other)
+ float3 &operator*=(const float3 &other)
{
this->x *= other.x;
this->y *= other.y;
this->z *= other.z;
+ return *this;
}
friend float3 operator*(const float3 &a, const float3 &b)
@@ -201,9 +204,9 @@ struct float3 {
uint64_t hash() const
{
- uint64_t x1 = *(uint32_t *)&x;
- uint64_t x2 = *(uint32_t *)&y;
- uint64_t x3 = *(uint32_t *)&z;
+ uint64_t x1 = *reinterpret_cast<const uint32_t *>(&x);
+ uint64_t x2 = *reinterpret_cast<const uint32_t *>(&y);
+ uint64_t x3 = *reinterpret_cast<const uint32_t *>(&z);
return (x1 * 435109) ^ (x2 * 380867) ^ (x3 * 1059217);
}
@@ -243,5 +246,3 @@ struct float3 {
};
} // namespace blender
-
-#endif /* __BLI_FLOAT3_HH__ */
diff --git a/source/blender/blenlib/BLI_float4x4.hh b/source/blender/blenlib/BLI_float4x4.hh
index b4f12f17cc2..0433197b22a 100644
--- a/source/blender/blenlib/BLI_float4x4.hh
+++ b/source/blender/blenlib/BLI_float4x4.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_FLOAT4X4_HH__
-#define __BLI_FLOAT4X4_HH__
+#pragma once
#include "BLI_float3.hh"
#include "BLI_math_matrix.h"
@@ -32,18 +31,18 @@ struct float4x4 {
memcpy(values, matrix, sizeof(float) * 16);
}
- float4x4(const float matrix[4][4]) : float4x4((float *)matrix)
+ float4x4(const float matrix[4][4]) : float4x4(static_cast<const float *>(matrix[0]))
{
}
operator float *()
{
- return (float *)this;
+ return &values[0][0];
}
operator const float *() const
{
- return (const float *)this;
+ return &values[0][0];
}
friend float4x4 operator*(const float4x4 &a, const float4x4 &b)
@@ -125,13 +124,11 @@ struct float4x4 {
{
uint64_t h = 435109;
for (int i = 0; i < 16; i++) {
- float value = ((const float *)this)[i];
- h = h * 33 + (*(uint32_t *)&value);
+ float value = (static_cast<const float *>(values[0]))[i];
+ h = h * 33 + *reinterpret_cast<const uint32_t *>(&value);
}
return h;
}
};
} // namespace blender
-
-#endif /* __BLI_FLOAT4X4_HH__ */
diff --git a/source/blender/blenlib/BLI_fnmatch.h b/source/blender/blenlib/BLI_fnmatch.h
index 28169c36e23..d09a14621d8 100644
--- a/source/blender/blenlib/BLI_fnmatch.h
+++ b/source/blender/blenlib/BLI_fnmatch.h
@@ -19,8 +19,7 @@
* Bugs can be reported to bug-glibc@prep.ai.mit.edu.
*/
-#ifndef __BLI_FNMATCH_H__
-#define __BLI_FNMATCH_H__
+#pragma once
/** \file
* \ingroup bli
@@ -77,5 +76,3 @@ extern int fnmatch __P((const char *__pattern, const char *__string, int __flags
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_FNMATCH_H__ */
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index 31a9658bd7e..cd84dd4f327 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_GHASH_H__
-#define __BLI_GHASH_H__
+#pragma once
/** \file
* \ingroup bli
@@ -416,5 +415,3 @@ GSet *BLI_gset_int_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_GHASH_H__ */
diff --git a/source/blender/blenlib/BLI_gsqueue.h b/source/blender/blenlib/BLI_gsqueue.h
index b69bdb7057c..077d1646d1d 100644
--- a/source/blender/blenlib/BLI_gsqueue.h
+++ b/source/blender/blenlib/BLI_gsqueue.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_GSQUEUE_H__
-#define __BLI_GSQUEUE_H__
+#pragma once
/** \file
* \ingroup bli
@@ -42,5 +41,3 @@ void BLI_gsqueue_free(GSQueue *gq);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_GSQUEUE_H__ */
diff --git a/source/blender/blenlib/BLI_hash.h b/source/blender/blenlib/BLI_hash.h
index 96111ffaf5a..c2be416ef5f 100644
--- a/source/blender/blenlib/BLI_hash.h
+++ b/source/blender/blenlib/BLI_hash.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_HASH_H__
-#define __BLI_HASH_H__
+#pragma once
/** \file
* \ingroup bli
@@ -91,5 +90,3 @@ BLI_INLINE void BLI_hash_pointer_to_color(const void *ptr, int *r, int *g, int *
#ifdef __cplusplus
}
#endif
-
-#endif // __BLI_HASH_H__
diff --git a/source/blender/blenlib/BLI_hash.hh b/source/blender/blenlib/BLI_hash.hh
index b14a4ca933c..2e3212cc83b 100644
--- a/source/blender/blenlib/BLI_hash.hh
+++ b/source/blender/blenlib/BLI_hash.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_HASH_HH__
-#define __BLI_HASH_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -111,7 +110,7 @@ template<typename T> struct DefaultHash<const T> {
template<> struct DefaultHash<TYPE> { \
uint64_t operator()(TYPE value) const \
{ \
- return (uint64_t)value; \
+ return static_cast<uint64_t>(value); \
} \
}
@@ -136,14 +135,14 @@ TRIVIAL_DEFAULT_INT_HASH(uint64_t);
template<> struct DefaultHash<float> {
uint64_t operator()(float value) const
{
- return *(uint32_t *)&value;
+ return *reinterpret_cast<uint32_t *>(&value);
}
};
template<> struct DefaultHash<bool> {
uint64_t operator()(bool value) const
{
- return (uint64_t)(value != false) * 1298191;
+ return static_cast<uint64_t>((value != false) * 1298191);
}
};
@@ -181,14 +180,21 @@ template<> struct DefaultHash<StringRefNull> {
}
};
+template<> struct DefaultHash<std::string_view> {
+ uint64_t operator()(StringRef value) const
+ {
+ return hash_string(value);
+ }
+};
+
/**
* While we cannot guarantee that the lower 4 bits of a pointer are zero, it is often the case.
*/
template<typename T> struct DefaultHash<T *> {
uint64_t operator()(const T *value) const
{
- uintptr_t ptr = (uintptr_t)value;
- uint64_t hash = (uint64_t)(ptr >> 4);
+ uintptr_t ptr = reinterpret_cast<uintptr_t>(value);
+ uint64_t hash = static_cast<uint64_t>(ptr >> 4);
return hash;
}
};
@@ -210,5 +216,3 @@ template<typename T1, typename T2> struct DefaultHash<std::pair<T1, T2>> {
};
} // namespace blender
-
-#endif /* __BLI_HASH_HH__ */
diff --git a/source/blender/blenlib/BLI_hash_md5.h b/source/blender/blenlib/BLI_hash_md5.h
index b326b17c19b..4a5cd8b19f3 100644
--- a/source/blender/blenlib/BLI_hash_md5.h
+++ b/source/blender/blenlib/BLI_hash_md5.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_HASH_MD5_H__
-#define __BLI_HASH_MD5_H__
+#pragma once
/** \file
* \ingroup bli
@@ -43,5 +42,3 @@ char *BLI_hash_md5_to_hexdigest(void *resblock, char r_hex_digest[33]);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_HASH_MD5_H__ */
diff --git a/source/blender/blenlib/BLI_hash_mm2a.h b/source/blender/blenlib/BLI_hash_mm2a.h
index 840ff31dd19..193a78e6293 100644
--- a/source/blender/blenlib/BLI_hash_mm2a.h
+++ b/source/blender/blenlib/BLI_hash_mm2a.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_HASH_MM2A_H__
-#define __BLI_HASH_MM2A_H__
+#pragma once
/** \file
* \ingroup bli
@@ -47,5 +46,3 @@ uint32_t BLI_hash_mm2(const unsigned char *data, size_t len, uint32_t seed);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_HASH_MM2A_H__ */
diff --git a/source/blender/blenlib/BLI_hash_mm3.h b/source/blender/blenlib/BLI_hash_mm3.h
index e76808812bc..99c24f53dd4 100644
--- a/source/blender/blenlib/BLI_hash_mm3.h
+++ b/source/blender/blenlib/BLI_hash_mm3.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_HASH_MM3_H__
-#define __BLI_HASH_MM3_H__
+#pragma once
/** \file
* \ingroup bli
@@ -32,5 +31,3 @@ uint32_t BLI_hash_mm3(const unsigned char *data, size_t len, uint32_t seed);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_HASH_MM2A_H__ */
diff --git a/source/blender/blenlib/BLI_hash_tables.hh b/source/blender/blenlib/BLI_hash_tables.hh
index 5d8f8862a09..9fc8ff30f79 100644
--- a/source/blender/blenlib/BLI_hash_tables.hh
+++ b/source/blender/blenlib/BLI_hash_tables.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_OPEN_ADDRESSING_HH__
-#define __BLI_OPEN_ADDRESSING_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -57,7 +56,8 @@ inline constexpr int64_t log2_floor_constexpr(const int64_t x)
inline constexpr int64_t log2_ceil_constexpr(const int64_t x)
{
BLI_assert(x >= 0);
- return (is_power_of_2_constexpr((int)x)) ? log2_floor_constexpr(x) : log2_floor_constexpr(x) + 1;
+ return (is_power_of_2_constexpr(static_cast<int>(x))) ? log2_floor_constexpr(x) :
+ log2_floor_constexpr(x) + 1;
}
inline constexpr int64_t power_of_2_max_constexpr(const int64_t x)
@@ -84,14 +84,17 @@ inline constexpr int64_t ceil_division_by_fraction(const int64_t x,
const int64_t numerator,
const int64_t denominator)
{
- return (int64_t)ceil_division((uint64_t)x * (uint64_t)denominator, (uint64_t)numerator);
+ return static_cast<int64_t>(
+ ceil_division(static_cast<uint64_t>(x) * static_cast<uint64_t>(denominator),
+ static_cast<uint64_t>(numerator)));
}
inline constexpr int64_t floor_multiplication_with_fraction(const int64_t x,
const int64_t numerator,
const int64_t denominator)
{
- return (int64_t)((uint64_t)x * (uint64_t)numerator / (uint64_t)denominator);
+ return static_cast<int64_t>((static_cast<uint64_t>(x) * static_cast<uint64_t>(numerator) /
+ static_cast<uint64_t>(denominator)));
}
inline constexpr int64_t total_slot_amount_for_usable_slots(
@@ -131,7 +134,7 @@ class LoadFactor {
int64_t *r_total_slots,
int64_t *r_usable_slots) const
{
- BLI_assert(is_power_of_2_i((int)min_total_slots));
+ BLI_assert(is_power_of_2_i(static_cast<int>(min_total_slots)));
int64_t total_slots = this->compute_total_slots(min_usable_slots, numerator_, denominator_);
total_slots = std::max(total_slots, min_total_slots);
@@ -298,7 +301,7 @@ class HashTableStats {
removed_amount_ = hash_table.removed_amount();
size_per_element_ = hash_table.size_per_element();
size_in_bytes_ = hash_table.size_in_bytes();
- address_ = (const void *)&hash_table;
+ address_ = static_cast<const void *>(&hash_table);
for (const auto &key : keys) {
int64_t collisions = hash_table.count_collisions(key);
@@ -353,5 +356,3 @@ struct DefaultEquality {
};
} // namespace blender
-
-#endif /* __BLI_OPEN_ADDRESSING_HH__ */
diff --git a/source/blender/blenlib/BLI_heap.h b/source/blender/blenlib/BLI_heap.h
index ca5edcbead5..4cfb7945303 100644
--- a/source/blender/blenlib/BLI_heap.h
+++ b/source/blender/blenlib/BLI_heap.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_HEAP_H__
-#define __BLI_HEAP_H__
+#pragma once
/** \file
* \ingroup bli
@@ -61,5 +60,3 @@ bool BLI_heap_is_valid(const Heap *heap);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_HEAP_H__ */
diff --git a/source/blender/blenlib/BLI_heap_simple.h b/source/blender/blenlib/BLI_heap_simple.h
index d2bc542491c..b2a1b5582e5 100644
--- a/source/blender/blenlib/BLI_heap_simple.h
+++ b/source/blender/blenlib/BLI_heap_simple.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_HEAP_SIMPLE_H__
-#define __BLI_HEAP_SIMPLE_H__
+#pragma once
/** \file
* \ingroup bli
@@ -44,5 +43,3 @@ void *BLI_heapsimple_pop_min(HeapSimple *heap) ATTR_NONNULL(1);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_HEAP_SIMPLE_H__ */
diff --git a/source/blender/blenlib/BLI_index_mask.hh b/source/blender/blenlib/BLI_index_mask.hh
index ff271faa0c2..48b01edcd6f 100644
--- a/source/blender/blenlib/BLI_index_mask.hh
+++ b/source/blender/blenlib/BLI_index_mask.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_INDEX_MASK_HH__
-#define __BLI_INDEX_MASK_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -208,5 +207,3 @@ class IndexMask {
};
} // namespace blender
-
-#endif /* __BLI_INDEX_MASK_HH__ */
diff --git a/source/blender/blenlib/BLI_index_range.hh b/source/blender/blenlib/BLI_index_range.hh
index 7c813f58b2c..2b060c986cd 100644
--- a/source/blender/blenlib/BLI_index_range.hh
+++ b/source/blender/blenlib/BLI_index_range.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_INDEX_RANGE_HH__
-#define __BLI_INDEX_RANGE_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -245,5 +244,3 @@ class IndexRange {
};
} // namespace blender
-
-#endif /* __BLI_INDEX_RANGE_HH__ */
diff --git a/source/blender/blenlib/BLI_iterator.h b/source/blender/blenlib/BLI_iterator.h
index ce2311aa3f7..c1cd1c21dac 100644
--- a/source/blender/blenlib/BLI_iterator.h
+++ b/source/blender/blenlib/BLI_iterator.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_ITERATOR_H__
-#define __BLI_ITERATOR_H__
+#pragma once
/** \file
* \ingroup bli
@@ -58,5 +57,3 @@ typedef void (*IteratorBeginCb)(BLI_Iterator *iter, void *data_in);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_ITERATOR_H__ */
diff --git a/source/blender/blenlib/BLI_jitter_2d.h b/source/blender/blenlib/BLI_jitter_2d.h
index fa184916b5b..a0af352ddd2 100644
--- a/source/blender/blenlib/BLI_jitter_2d.h
+++ b/source/blender/blenlib/BLI_jitter_2d.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_JITTER_2D_H__
-#define __BLI_JITTER_2D_H__
+#pragma once
/** \file
* \ingroup bli
@@ -35,5 +34,3 @@ void BLI_jitterate2(float (*jit1)[2], float (*jit2)[2], int num, float radius2);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_JITTER_2D_H__ */
diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h
index 9e4e30181b9..5e317c89625 100644
--- a/source/blender/blenlib/BLI_kdopbvh.h
+++ b/source/blender/blenlib/BLI_kdopbvh.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_KDOPBVH_H__
-#define __BLI_KDOPBVH_H__
+#pragma once
/** \file
* \ingroup bli
@@ -264,5 +263,3 @@ extern const float bvhtree_kdop_axes[13][3];
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_KDOPBVH_H__ */
diff --git a/source/blender/blenlib/BLI_kdtree.h b/source/blender/blenlib/BLI_kdtree.h
index 9ba045fdbf8..76f39dfbacb 100644
--- a/source/blender/blenlib/BLI_kdtree.h
+++ b/source/blender/blenlib/BLI_kdtree.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_KDTREE_H__
-#define __BLI_KDTREE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -73,5 +72,3 @@ extern "C" {
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_KDTREE_H__ */
diff --git a/source/blender/blenlib/BLI_lasso_2d.h b/source/blender/blenlib/BLI_lasso_2d.h
index fb661c41784..e920d1189a2 100644
--- a/source/blender/blenlib/BLI_lasso_2d.h
+++ b/source/blender/blenlib/BLI_lasso_2d.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_LASSO_2D_H__
-#define __BLI_LASSO_2D_H__
+#pragma once
/** \file
* \ingroup bli
@@ -47,5 +46,3 @@ bool BLI_lasso_is_edge_inside(const int mcoords[][2],
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_LASSO_2D_H__ */
diff --git a/source/blender/blenlib/BLI_linear_allocator.hh b/source/blender/blenlib/BLI_linear_allocator.hh
index 39a3ed27f42..a616ec5cf28 100644
--- a/source/blender/blenlib/BLI_linear_allocator.hh
+++ b/source/blender/blenlib/BLI_linear_allocator.hh
@@ -22,8 +22,7 @@
* memory. When the current buffer is full, it reallocates a new larger buffer and continues.
*/
-#ifndef __BLI_LINEAR_ALLOCATOR_HH__
-#define __BLI_LINEAR_ALLOCATOR_HH__
+#pragma once
#include "BLI_string_ref.hh"
#include "BLI_utility_mixins.hh"
@@ -83,7 +82,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
if (potential_allocation_end <= current_end_) {
current_begin_ = potential_allocation_end;
- return (void *)potential_allocation_begin;
+ return reinterpret_cast<void *>(potential_allocation_begin);
}
else {
this->allocate_new_buffer(size + alignment);
@@ -98,7 +97,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
*/
template<typename T> T *allocate()
{
- return (T *)this->allocate(sizeof(T), alignof(T));
+ return static_cast<T *>(this->allocate(sizeof(T), alignof(T)));
}
/**
@@ -108,7 +107,8 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
*/
template<typename T> MutableSpan<T> allocate_array(int64_t size)
{
- return MutableSpan<T>((T *)this->allocate(sizeof(T) * size, alignof(T)), size);
+ T *array = static_cast<T *>(this->allocate(sizeof(T) * size, alignof(T)));
+ return MutableSpan<T>(array, size);
}
/**
@@ -143,9 +143,9 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
StringRefNull copy_string(StringRef str)
{
const int64_t alloc_size = str.size() + 1;
- char *buffer = (char *)this->allocate(alloc_size, 1);
+ char *buffer = static_cast<char *>(this->allocate(alloc_size, 1));
str.copy(buffer, alloc_size);
- return StringRefNull((const char *)buffer);
+ return StringRefNull(static_cast<const char *>(buffer));
}
MutableSpan<void *> allocate_elements_and_pointer_array(int64_t element_amount,
@@ -173,7 +173,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
MutableSpan<T *> pointers = void_pointers.cast<T *>();
for (int64_t i : IndexRange(n)) {
- new ((void *)pointers[i]) T(std::forward<Args>(args)...);
+ new (static_cast<void *>(pointers[i])) T(std::forward<Args>(args)...);
}
return pointers;
@@ -185,7 +185,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
*/
void provide_buffer(void *buffer, uint size)
{
- unused_borrowed_buffers_.append(Span<char>((char *)buffer, size));
+ unused_borrowed_buffers_.append(Span<char>(static_cast<char *>(buffer), size));
}
template<size_t Size, size_t Alignment>
@@ -219,5 +219,3 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
};
} // namespace blender
-
-#endif /* __BLI_LINEAR_ALLOCATOR_HH__ */
diff --git a/source/blender/blenlib/BLI_link_utils.h b/source/blender/blenlib/BLI_link_utils.h
index c0db53ca9a3..a877860cd8d 100644
--- a/source/blender/blenlib/BLI_link_utils.h
+++ b/source/blender/blenlib/BLI_link_utils.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_LINK_UTILS_H__
-#define __BLI_LINK_UTILS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -67,5 +66,3 @@
} \
} \
(void)0
-
-#endif /* __BLI_LINK_UTILS_H__ */
diff --git a/source/blender/blenlib/BLI_linklist.h b/source/blender/blenlib/BLI_linklist.h
index 324da859af1..25d58a3050c 100644
--- a/source/blender/blenlib/BLI_linklist.h
+++ b/source/blender/blenlib/BLI_linklist.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_LINKLIST_H__
-#define __BLI_LINKLIST_H__
+#pragma once
/** \file
* \ingroup bli
@@ -101,5 +100,3 @@ LinkNode *BLI_linklist_sort_r(LinkNode *list,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_LINKLIST_H__ */
diff --git a/source/blender/blenlib/BLI_linklist_lockfree.h b/source/blender/blenlib/BLI_linklist_lockfree.h
index 647b00ec658..142fa1cf243 100644
--- a/source/blender/blenlib/BLI_linklist_lockfree.h
+++ b/source/blender/blenlib/BLI_linklist_lockfree.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_LINKLIST_LOCKFREE_H__
-#define __BLI_LINKLIST_LOCKFREE_H__
+#pragma once
/** \file
* \ingroup bli
@@ -73,5 +72,3 @@ void BLI_linklist_lockfree_insert(LockfreeLinkList *list, LockfreeLinkNode *node
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_LINKLIST_H__ */
diff --git a/source/blender/blenlib/BLI_linklist_stack.h b/source/blender/blenlib/BLI_linklist_stack.h
index 3725682d380..065ed12f353 100644
--- a/source/blender/blenlib/BLI_linklist_stack.h
+++ b/source/blender/blenlib/BLI_linklist_stack.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_LINKLIST_STACK_H__
-#define __BLI_LINKLIST_STACK_H__
+#pragma once
/** \file
* \ingroup bli
@@ -194,5 +193,3 @@
(void)0
/** \} */
-
-#endif /* __BLI_LINKLIST_STACK_H__ */
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h
index b027acb88da..fa7cf7a1847 100644
--- a/source/blender/blenlib/BLI_listbase.h
+++ b/source/blender/blenlib/BLI_listbase.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_LISTBASE_H__
-#define __BLI_LISTBASE_H__
+#pragma once
/** \file
* \ingroup bli
@@ -190,5 +189,3 @@ struct LinkData *BLI_genericNodeN(void *data);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_LISTBASE_H__ */
diff --git a/source/blender/blenlib/BLI_listbase_wrapper.hh b/source/blender/blenlib/BLI_listbase_wrapper.hh
index 46f4a9d49fa..c31694d7d9e 100644
--- a/source/blender/blenlib/BLI_listbase_wrapper.hh
+++ b/source/blender/blenlib/BLI_listbase_wrapper.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_LISTBASE_WRAPPER_HH__
-#define __BLI_LISTBASE_WRAPPER_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -81,7 +80,7 @@ template<typename T> class ListBaseWrapper {
Iterator begin() const
{
- return Iterator(listbase_, (T *)listbase_->first);
+ return Iterator(listbase_, static_cast<T *>(listbase_->first));
}
Iterator end() const
@@ -93,7 +92,7 @@ template<typename T> class ListBaseWrapper {
{
void *ptr = BLI_findlink(listbase_, index);
BLI_assert(ptr);
- return (T *)ptr;
+ return static_cast<T *>(ptr);
}
int64_t index_of(const T *value) const
@@ -111,5 +110,3 @@ template<typename T> class ListBaseWrapper {
};
} /* namespace blender */
-
-#endif /* __BLI_LISTBASE_WRAPPER_HH__ */
diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh
index dd375272fdb..229bbfad0e4 100644
--- a/source/blender/blenlib/BLI_map.hh
+++ b/source/blender/blenlib/BLI_map.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_MAP_HH__
-#define __BLI_MAP_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -825,7 +824,7 @@ class Map {
*/
int64_t size_in_bytes() const
{
- return (int64_t)(sizeof(Slot) * slots_.size());
+ return static_cast<int64_t>(sizeof(Slot) * slots_.size());
}
/**
@@ -864,7 +863,7 @@ class Map {
max_load_factor_.compute_total_and_usable_slots(
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
BLI_assert(total_slots >= 1);
- const uint64_t new_slot_mask = (uint64_t)total_slots - 1;
+ const uint64_t new_slot_mask = static_cast<uint64_t>(total_slots) - 1;
/**
* Optimize the case when the map was empty beforehand. We can avoid some copies here.
@@ -1108,7 +1107,7 @@ class Map {
bool add_overwrite__impl(ForwardKey &&key, ForwardValue &&value, uint64_t hash)
{
auto create_func = [&](Value *ptr) {
- new ((void *)ptr) Value(std::forward<ForwardValue>(value));
+ new (static_cast<void *>(ptr)) Value(std::forward<ForwardValue>(value));
return true;
};
auto modify_func = [&](Value *ptr) {
@@ -1186,7 +1185,7 @@ template<typename Key, typename Value> class StdUnorderedMapWrapper {
public:
int64_t size() const
{
- return (int64_t)map_.size();
+ return static_cast<int64_t>(map_.size());
}
bool is_empty() const
@@ -1242,5 +1241,3 @@ template<typename Key, typename Value> class StdUnorderedMapWrapper {
};
} // namespace blender
-
-#endif /* __BLI_MAP_HH__ */
diff --git a/source/blender/blenlib/BLI_map_slots.hh b/source/blender/blenlib/BLI_map_slots.hh
index b5360795a13..25fb92d61a3 100644
--- a/source/blender/blenlib/BLI_map_slots.hh
+++ b/source/blender/blenlib/BLI_map_slots.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_MAP_SLOTS_HH__
-#define __BLI_MAP_SLOTS_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -357,5 +356,3 @@ template<typename Key, typename Value> struct DefaultMapSlot<Key *, Value> {
};
} // namespace blender
-
-#endif /* __BLI_MAP_SLOTS_HH__ */
diff --git a/source/blender/blenlib/BLI_math.h b/source/blender/blenlib/BLI_math.h
index f8de8b7ed53..51833d081d0 100644
--- a/source/blender/blenlib/BLI_math.h
+++ b/source/blender/blenlib/BLI_math.h
@@ -20,8 +20,7 @@
*
* */
-#ifndef __BLI_MATH_H__
-#define __BLI_MATH_H__
+#pragma once
/** \file
* \ingroup bli
@@ -73,5 +72,3 @@
#include "BLI_math_solvers.h"
#include "BLI_math_statistics.h"
#include "BLI_math_vector.h"
-
-#endif /* __BLI_MATH_H__ */
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index c456ab0ecef..f407da3133f 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -20,8 +20,7 @@
*
* */
-#ifndef __BLI_MATH_BASE_H__
-#define __BLI_MATH_BASE_H__
+#pragma once
/** \file
* \ingroup bli
@@ -289,5 +288,3 @@ double double_round(double x, int ndigits);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_BASE_H__ */
diff --git a/source/blender/blenlib/BLI_math_base_safe.h b/source/blender/blenlib/BLI_math_base_safe.h
index 88a08c3cbc7..1d6590b2faa 100644
--- a/source/blender/blenlib/BLI_math_base_safe.h
+++ b/source/blender/blenlib/BLI_math_base_safe.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_MATH_BASE_SAFE_H__
-#define __BLI_MATH_BASE_SAFE_H__
+#pragma once
/** \file
* \ingroup bli
@@ -46,5 +45,3 @@ MINLINE float safe_powf(float base, float exponent);
#if BLI_MATH_DO_INLINE
# include "intern/math_base_safe_inline.c"
#endif
-
-#endif /* __BLI_MATH_BASE_SAFE_H__ */
diff --git a/source/blender/blenlib/BLI_math_bits.h b/source/blender/blenlib/BLI_math_bits.h
index 0283622ca89..b602900bedc 100644
--- a/source/blender/blenlib/BLI_math_bits.h
+++ b/source/blender/blenlib/BLI_math_bits.h
@@ -15,8 +15,7 @@
*
* */
-#ifndef __BLI_MATH_BITS_H__
-#define __BLI_MATH_BITS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -68,5 +67,3 @@ MINLINE float xor_fl(float x, int y);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_BITS_H__ */
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 48f8e7d31d9..943f0fc764f 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -20,8 +20,7 @@
*
* */
-#ifndef __BLI_MATH_COLOR_H__
-#define __BLI_MATH_COLOR_H__
+#pragma once
/** \file
* \ingroup bli
@@ -162,5 +161,3 @@ void lift_gamma_gain_to_asc_cdl(const float *lift,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_COLOR_H__ */
diff --git a/source/blender/blenlib/BLI_math_color_blend.h b/source/blender/blenlib/BLI_math_color_blend.h
index 60ada1e4509..d5e4eedb1a6 100644
--- a/source/blender/blenlib/BLI_math_color_blend.h
+++ b/source/blender/blenlib/BLI_math_color_blend.h
@@ -20,8 +20,7 @@
*
* */
-#ifndef __BLI_MATH_COLOR_BLEND_H__
-#define __BLI_MATH_COLOR_BLEND_H__
+#pragma once
/** \file
* \ingroup bli
@@ -151,5 +150,3 @@ MINLINE void blend_color_interpolate_float(float dst[4],
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_COLOR_BLEND_H__ */
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 3a24209b07c..213f5a029b0 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -20,8 +20,7 @@
*
* */
-#ifndef __BLI_MATH_GEOM_H__
-#define __BLI_MATH_GEOM_H__
+#pragma once
/** \file
* \ingroup bli
@@ -403,15 +402,19 @@ bool isect_ray_tri_epsilon_v3(const float ray_origin[3],
float *r_lambda,
float r_uv[2],
const float epsilon);
-bool isect_tri_tri_epsilon_v3(const float t_a0[3],
- const float t_a1[3],
- const float t_a2[3],
- const float t_b0[3],
- const float t_b1[3],
- const float t_b2[3],
- float r_i1[3],
- float r_i2[3],
- const float epsilon);
+bool isect_tri_tri_v3_ex(const float tri_a[3][3],
+ const float tri_b[3][3],
+ float r_i1[3],
+ float r_i2[3],
+ int *r_tri_a_edge_isect_count);
+bool isect_tri_tri_v3(const float t_a0[3],
+ const float t_a1[3],
+ const float t_a2[3],
+ const float t_b0[3],
+ const float t_b1[3],
+ const float t_b2[3],
+ float r_i1[3],
+ float r_i2[3]);
bool isect_tri_tri_v2(const float p1[2],
const float q1[2],
@@ -825,5 +828,3 @@ float cubic_tangent_factor_circle_v3(const float tan_l[3], const float tan_r[3])
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_GEOM_H__ */
diff --git a/source/blender/blenlib/BLI_math_inline.h b/source/blender/blenlib/BLI_math_inline.h
index 3e32a517471..506386f8d25 100644
--- a/source/blender/blenlib/BLI_math_inline.h
+++ b/source/blender/blenlib/BLI_math_inline.h
@@ -20,8 +20,7 @@
*
* */
-#ifndef __BLI_MATH_INLINE_H__
-#define __BLI_MATH_INLINE_H__
+#pragma once
/** \file
* \ingroup bli
@@ -56,5 +55,3 @@ extern "C" {
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_INLINE_H__ */
diff --git a/source/blender/blenlib/BLI_math_interp.h b/source/blender/blenlib/BLI_math_interp.h
index 0f3032fa625..3e9839b4d3a 100644
--- a/source/blender/blenlib/BLI_math_interp.h
+++ b/source/blender/blenlib/BLI_math_interp.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_MATH_INTERP_H__
-#define __BLI_MATH_INTERP_H__
+#pragma once
/** \file
* \ingroup bli
@@ -95,5 +94,3 @@ void BLI_ewa_filter(const int width,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_INTERP_H__ */
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 33fcd750aee..a00fdaa0ae9 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -19,8 +19,7 @@
* The Original Code is: some of this file.
* */
-#ifndef __BLI_MATH_MATRIX_H__
-#define __BLI_MATH_MATRIX_H__
+#pragma once
/** \file
* \ingroup bli
@@ -399,5 +398,3 @@ void print_m4(const char *str, const float M[4][4]);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_MATRIX_H__ */
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h
index b7ae35b2e23..61708528e24 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -20,8 +20,7 @@
*
* */
-#ifndef __BLI_MATH_ROTATION_H__
-#define __BLI_MATH_ROTATION_H__
+#pragma once
/** \file
* \ingroup bli
@@ -246,5 +245,3 @@ bool mat3_from_axis_conversion_single(int src_axis, int dst_axis, float r_mat[3]
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_ROTATION_H__ */
diff --git a/source/blender/blenlib/BLI_math_solvers.h b/source/blender/blenlib/BLI_math_solvers.h
index 193bbdd4e8c..9b2d1eedec7 100644
--- a/source/blender/blenlib/BLI_math_solvers.h
+++ b/source/blender/blenlib/BLI_math_solvers.h
@@ -17,8 +17,7 @@
* All rights reserved.
* */
-#ifndef __BLI_MATH_SOLVERS_H__
-#define __BLI_MATH_SOLVERS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -76,5 +75,3 @@ bool BLI_newton3d_solve(Newton3D_DeltaFunc func_delta,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_SOLVERS_H__ */
diff --git a/source/blender/blenlib/BLI_math_statistics.h b/source/blender/blenlib/BLI_math_statistics.h
index a9f9ae39506..aebc445002b 100644
--- a/source/blender/blenlib/BLI_math_statistics.h
+++ b/source/blender/blenlib/BLI_math_statistics.h
@@ -17,8 +17,7 @@
* All rights reserved.
* */
-#ifndef __BLI_MATH_STATISTICS_H__
-#define __BLI_MATH_STATISTICS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -57,5 +56,3 @@ void BLI_covariance_m3_v3n(const float (*cos_v3)[3],
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_STATISTICS_H__ */
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 362ab3769a0..1ccfe5d86b1 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -20,8 +20,7 @@
*
* */
-#ifndef __BLI_MATH_VECTOR_H__
-#define __BLI_MATH_VECTOR_H__
+#pragma once
/** \file
* \ingroup bli
@@ -526,5 +525,3 @@ void mul_vn_db(double *array_tar, const int size, const double f);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MATH_VECTOR_H__ */
diff --git a/source/blender/blenlib/BLI_memarena.h b/source/blender/blenlib/BLI_memarena.h
index e0aff82e874..87a320e336d 100644
--- a/source/blender/blenlib/BLI_memarena.h
+++ b/source/blender/blenlib/BLI_memarena.h
@@ -21,8 +21,7 @@
* \ingroup bli
*/
-#ifndef __BLI_MEMARENA_H__
-#define __BLI_MEMARENA_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -55,5 +54,3 @@ void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MEMARENA_H__ */
diff --git a/source/blender/blenlib/BLI_memblock.h b/source/blender/blenlib/BLI_memblock.h
index 8f66ee3b9cb..cb6b31d54e0 100644
--- a/source/blender/blenlib/BLI_memblock.h
+++ b/source/blender/blenlib/BLI_memblock.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_MEMBLOCK_H__
-#define __BLI_MEMBLOCK_H__
+#pragma once
/** \file
* \ingroup bli
@@ -63,5 +62,3 @@ void *BLI_memblock_elem_get(BLI_memblock *mblk, int chunk, int elem) ATTR_WARN_U
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MEMBLOCK_H__ */
diff --git a/source/blender/blenlib/BLI_memiter.h b/source/blender/blenlib/BLI_memiter.h
index 4aa9cdb6b6c..c7a715309e1 100644
--- a/source/blender/blenlib/BLI_memiter.h
+++ b/source/blender/blenlib/BLI_memiter.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_MEMITER_H__
-#define __BLI_MEMITER_H__
+#pragma once
/** \file
* \ingroup bli
@@ -69,5 +68,3 @@ void *BLI_memiter_iter_step_size(BLI_memiter_handle *iter, uint *r_size) ATTR_WA
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MEMITER_H__ */
diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh
index 9f65fe0742e..7216536a884 100644
--- a/source/blender/blenlib/BLI_memory_utils.hh
+++ b/source/blender/blenlib/BLI_memory_utils.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_MEMORY_UTILS_HH__
-#define __BLI_MEMORY_UTILS_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -85,7 +84,7 @@ template<typename T> void default_construct_n(T *ptr, int64_t n)
int64_t current = 0;
try {
for (; current < n; current++) {
- new ((void *)(ptr + current)) T;
+ new (static_cast<void *>(ptr + current)) T;
}
}
catch (...) {
@@ -134,7 +133,7 @@ template<typename T> void uninitialized_copy_n(const T *src, int64_t n, T *dst)
int64_t current = 0;
try {
for (; current < n; current++) {
- new ((void *)(dst + current)) T(src[current]);
+ new (static_cast<void *>(dst + current)) T(src[current]);
}
}
catch (...) {
@@ -163,7 +162,7 @@ void uninitialized_convert_n(const From *src, int64_t n, To *dst)
int64_t current = 0;
try {
for (; current < n; current++) {
- new ((void *)(dst + current)) To((To)src[current]);
+ new (static_cast<void *>(dst + current)) To((To)src[current]);
}
}
catch (...) {
@@ -212,7 +211,7 @@ template<typename T> void uninitialized_move_n(T *src, int64_t n, T *dst)
int64_t current = 0;
try {
for (; current < n; current++) {
- new ((void *)(dst + current)) T(std::move(src[current]));
+ new (static_cast<void *>(dst + current)) T(std::move(src[current]));
}
}
catch (...) {
@@ -299,7 +298,7 @@ template<typename T> void uninitialized_fill_n(T *dst, int64_t n, const T &value
int64_t current = 0;
try {
for (; current < n; current++) {
- new ((void *)(dst + current)) T(value);
+ new (static_cast<void *>(dst + current)) T(value);
}
}
catch (...) {
@@ -333,22 +332,22 @@ template<size_t Size, size_t Alignment> class alignas(Alignment) AlignedBuffer {
public:
operator void *()
{
- return (void *)buffer_;
+ return buffer_;
}
operator const void *() const
{
- return (void *)buffer_;
+ return buffer_;
}
void *ptr()
{
- return (void *)buffer_;
+ return buffer_;
}
const void *ptr() const
{
- return (const void *)buffer_;
+ return buffer_;
}
};
@@ -364,42 +363,42 @@ template<typename T, int64_t Size = 1> class TypedBuffer {
public:
operator T *()
{
- return (T *)&buffer_;
+ return static_cast<T *>(buffer_.ptr());
}
operator const T *() const
{
- return (const T *)&buffer_;
+ return static_cast<const T *>(buffer_.ptr());
}
T &operator*()
{
- return *(T *)&buffer_;
+ return *static_cast<T *>(buffer_.ptr());
}
const T &operator*() const
{
- return *(const T *)&buffer_;
+ return *static_cast<const T *>(buffer_.ptr());
}
T *ptr()
{
- return (T *)&buffer_;
+ return static_cast<T *>(buffer_.ptr());
}
const T *ptr() const
{
- return (const T *)&buffer_;
+ return static_cast<const T *>(buffer_.ptr());
}
T &ref()
{
- return *(T *)&buffer_;
+ return *static_cast<T *>(buffer_.ptr());
}
const T &ref() const
{
- return *(const T *)&buffer_;
+ return *static_cast<const T *>(buffer_.ptr());
}
};
@@ -425,9 +424,7 @@ inline constexpr bool is_convertible_pointer_v =
*/
inline constexpr int64_t default_inline_buffer_capacity(size_t element_size)
{
- return ((int64_t)element_size < 100) ? 4 : 0;
+ return (static_cast<int64_t>(element_size) < 100) ? 4 : 0;
}
} // namespace blender
-
-#endif /* __BLI_MEMORY_UTILS_HH__ */
diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h
index 3749f9e1b76..3ee6f182593 100644
--- a/source/blender/blenlib/BLI_mempool.h
+++ b/source/blender/blenlib/BLI_mempool.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_MEMPOOL_H__
-#define __BLI_MEMPOOL_H__
+#pragma once
/** \file
* \ingroup bli
@@ -97,5 +96,3 @@ void BLI_mempool_iter_threadsafe_free(BLI_mempool_iter *iter_arr) ATTR_NONNULL()
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_MEMPOOL_H__ */
diff --git a/source/blender/blenlib/BLI_multi_value_map.hh b/source/blender/blenlib/BLI_multi_value_map.hh
index c20c4ef9677..018f080e633 100644
--- a/source/blender/blenlib/BLI_multi_value_map.hh
+++ b/source/blender/blenlib/BLI_multi_value_map.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_MULTI_VALUE_MAP_HH__
-#define __BLI_MULTI_VALUE_MAP_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -130,5 +129,3 @@ template<typename Key, typename Value> class MultiValueMap {
};
} // namespace blender
-
-#endif /* __BLI_MULTI_VALUE_MAP_HH__ */
diff --git a/source/blender/blenlib/BLI_noise.h b/source/blender/blenlib/BLI_noise.h
index 32731ff24fc..cb66b0552df 100644
--- a/source/blender/blenlib/BLI_noise.h
+++ b/source/blender/blenlib/BLI_noise.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_NOISE_H__
-#define __BLI_NOISE_H__
+#pragma once
/** \file
* \ingroup bli
@@ -79,5 +78,3 @@ void cellNoiseV(float x, float y, float z, float r_ca[3]);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index 30823773d6c..05c256ccf1c 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BLI_PATH_UTIL_H__
-#define __BLI_PATH_UTIL_H__
+#pragma once
/** \file
* \ingroup bli
@@ -158,5 +157,3 @@ bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_PATH_UTIL_H__ */
diff --git a/source/blender/blenlib/BLI_polyfill_2d.h b/source/blender/blenlib/BLI_polyfill_2d.h
index cb12b73c1d5..ca63ea5af87 100644
--- a/source/blender/blenlib/BLI_polyfill_2d.h
+++ b/source/blender/blenlib/BLI_polyfill_2d.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_POLYFILL_2D_H__
-#define __BLI_POLYFILL_2D_H__
+#pragma once
/** \file
* \ingroup bli
@@ -45,5 +44,3 @@ void BLI_polyfill_calc(const float (*coords)[2],
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_POLYFILL_2D_H__ */
diff --git a/source/blender/blenlib/BLI_polyfill_2d_beautify.h b/source/blender/blenlib/BLI_polyfill_2d_beautify.h
index 94c4b412225..2c5296269ae 100644
--- a/source/blender/blenlib/BLI_polyfill_2d_beautify.h
+++ b/source/blender/blenlib/BLI_polyfill_2d_beautify.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_POLYFILL_2D_BEAUTIFY_H__
-#define __BLI_POLYFILL_2D_BEAUTIFY_H__
+#pragma once
/** \file
* \ingroup bli
@@ -51,5 +50,3 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(const float v1[2],
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_POLYFILL_2D_BEAUTIFY_H__ */
diff --git a/source/blender/blenlib/BLI_probing_strategies.hh b/source/blender/blenlib/BLI_probing_strategies.hh
index 0e5338fa6ed..d0b7eaafbf6 100644
--- a/source/blender/blenlib/BLI_probing_strategies.hh
+++ b/source/blender/blenlib/BLI_probing_strategies.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_PROBING_STRATEGIES_HH__
-#define __BLI_PROBING_STRATEGIES_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -236,7 +235,7 @@ using DefaultProbingStrategy = PythonProbingStrategy<>;
int64_t linear_offset = 0; \
uint64_t current_hash = probing_strategy.get(); \
do { \
- int64_t R_SLOT_INDEX = (int64_t)((current_hash + (uint64_t)linear_offset) & MASK);
+ int64_t R_SLOT_INDEX = static_cast<int64_t>((current_hash + static_cast<uint64_t>(linear_offset)) & MASK);
#define SLOT_PROBING_END() \
} while (++linear_offset < probing_strategy.linear_steps()); \
@@ -246,5 +245,3 @@ using DefaultProbingStrategy = PythonProbingStrategy<>;
// clang-format on
} // namespace blender
-
-#endif /* __BLI_PROBING_STRATEGIES_HH__ */
diff --git a/source/blender/blenlib/BLI_quadric.h b/source/blender/blenlib/BLI_quadric.h
index 1383a19ed1f..fdb7d1e67ac 100644
--- a/source/blender/blenlib/BLI_quadric.h
+++ b/source/blender/blenlib/BLI_quadric.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_QUADRIC_H__
-#define __BLI_QUADRIC_H__
+#pragma once
/** \file
* \ingroup bli
@@ -50,5 +49,3 @@ bool BLI_quadric_optimize(const Quadric *q, double v[3], const double epsilon);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_QUADRIC_H__ */
diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h
index c55bbd26db5..78a323c2431 100644
--- a/source/blender/blenlib/BLI_rand.h
+++ b/source/blender/blenlib/BLI_rand.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_RAND_H__
-#define __BLI_RAND_H__
+#pragma once
#include "BLI_compiler_attrs.h"
#include "BLI_sys_types.h"
@@ -116,5 +115,3 @@ void BLI_hammersley_2d_sequence(unsigned int n, double *r);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_RAND_H__ */
diff --git a/source/blender/blenlib/BLI_rand.hh b/source/blender/blenlib/BLI_rand.hh
index 7a98ee0f2bb..1b321bd7bcd 100644
--- a/source/blender/blenlib/BLI_rand.hh
+++ b/source/blender/blenlib/BLI_rand.hh
@@ -18,8 +18,7 @@
* \ingroup bli
*/
-#ifndef __BLI_RAND_HH__
-#define __BLI_RAND_HH__
+#pragma once
#include "BLI_float2.hh"
#include "BLI_float3.hh"
@@ -45,7 +44,7 @@ class RandomNumberGenerator {
void seed(uint32_t seed)
{
constexpr uint64_t lowseed = 0x330E;
- x_ = (((uint64_t)seed) << 16) | lowseed;
+ x_ = (static_cast<uint64_t>(seed) << 16) | lowseed;
}
void seed_random(uint32_t seed);
@@ -53,13 +52,13 @@ class RandomNumberGenerator {
uint32_t get_uint32()
{
this->step();
- return (uint32_t)(x_ >> 17);
+ return static_cast<uint32_t>(x_ >> 17);
}
int32_t get_int32()
{
this->step();
- return (int32_t)(x_ >> 17);
+ return static_cast<int32_t>(x_ >> 17);
}
/**
@@ -143,5 +142,3 @@ class RandomNumberGenerator {
};
} // namespace blender
-
-#endif /* __BLI_RAND_HH__ */
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index 14d18308ed6..ae3eb9d2144 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_RECT_H__
-#define __BLI_RECT_H__
+#pragma once
/** \file
* \ingroup bli
@@ -166,5 +165,3 @@ BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_RECT_H__ */
diff --git a/source/blender/blenlib/BLI_resource_collector.hh b/source/blender/blenlib/BLI_resource_collector.hh
index e1be87d8af2..20180f3b2c9 100644
--- a/source/blender/blenlib/BLI_resource_collector.hh
+++ b/source/blender/blenlib/BLI_resource_collector.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_RESOURCE_COLLECTOR_HH__
-#define __BLI_RESOURCE_COLLECTOR_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -147,5 +146,3 @@ class ResourceCollector : NonCopyable, NonMovable {
};
} // namespace blender
-
-#endif /* __BLI_RESOURCE_COLLECTOR_HH__ */
diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h
index 376ea9d88de..cf74bc14cac 100644
--- a/source/blender/blenlib/BLI_scanfill.h
+++ b/source/blender/blenlib/BLI_scanfill.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_SCANFILL_H__
-#define __BLI_SCANFILL_H__
+#pragma once
/** \file
* \ingroup bli
@@ -131,5 +130,3 @@ bool BLI_scanfill_calc_self_isect(ScanFillContext *sf_ctx,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenlib/BLI_session_uuid.h b/source/blender/blenlib/BLI_session_uuid.h
new file mode 100644
index 00000000000..05355a85b39
--- /dev/null
+++ b/source/blender/blenlib/BLI_session_uuid.h
@@ -0,0 +1,68 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup bli
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "DNA_session_uuid_types.h"
+
+/* Generate new UUID which is unique throughout the Blender session. */
+SessionUUID BLI_session_uuid_generate(void);
+
+/* Check whether the UUID is properly generated. */
+bool BLI_session_uuid_is_generated(const SessionUUID *uuid);
+
+/* Check whether two UUIDs are identical. */
+bool BLI_session_uuid_is_equal(const SessionUUID *lhs, const SessionUUID *rhs);
+
+uint64_t BLI_session_uuid_hash_uint64(const SessionUUID *uuid);
+
+/* Utility functions to make it possible to create GHash/GSet with UUID as a key. */
+uint BLI_session_uuid_ghash_hash(const void *uuid_v);
+bool BLI_session_uuid_ghash_compare(const void *lhs_v, const void *rhs_v);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+
+namespace blender {
+
+inline const bool operator==(const SessionUUID &lhs, const SessionUUID &rhs)
+{
+ return BLI_session_uuid_is_equal(&lhs, &rhs);
+}
+
+template<typename T> struct DefaultHash;
+
+template<> struct DefaultHash<SessionUUID> {
+ uint64_t operator()(const SessionUUID &value) const
+ {
+ return BLI_session_uuid_hash_uint64(&value);
+ }
+};
+
+} // namespace blender
+
+#endif
diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh
index 90adea69e06..477a03cf623 100644
--- a/source/blender/blenlib/BLI_set.hh
+++ b/source/blender/blenlib/BLI_set.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_SET_HH__
-#define __BLI_SET_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -557,7 +556,7 @@ class Set {
max_load_factor_.compute_total_and_usable_slots(
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
BLI_assert(total_slots >= 1);
- const uint64_t new_slot_mask = (uint64_t)total_slots - 1;
+ const uint64_t new_slot_mask = static_cast<uint64_t>(total_slots) - 1;
/**
* Optimize the case when the set was empty beforehand. We can avoid some copies here.
@@ -749,7 +748,7 @@ template<typename Key> class StdUnorderedSetWrapper {
public:
int64_t size() const
{
- return (int64_t)set_.size();
+ return static_cast<int64_t>(set_.size());
}
bool is_empty() const
@@ -831,5 +830,3 @@ template<typename Key,
using RawSet = Set<Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, RawAllocator>;
} // namespace blender
-
-#endif /* __BLI_SET_HH__ */
diff --git a/source/blender/blenlib/BLI_set_slots.hh b/source/blender/blenlib/BLI_set_slots.hh
index b78ed37f534..ee5da17fcaf 100644
--- a/source/blender/blenlib/BLI_set_slots.hh
+++ b/source/blender/blenlib/BLI_set_slots.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_SET_SLOTS_HH__
-#define __BLI_SET_SLOTS_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -411,5 +410,3 @@ template<typename Key> struct DefaultSetSlot<Key *> {
};
} // namespace blender
-
-#endif /* __BLI_SET_SLOTS_HH__ */
diff --git a/source/blender/blenlib/BLI_smallhash.h b/source/blender/blenlib/BLI_smallhash.h
index cb0330d1bad..daea2fcd914 100644
--- a/source/blender/blenlib/BLI_smallhash.h
+++ b/source/blender/blenlib/BLI_smallhash.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_SMALLHASH_H__
-#define __BLI_SMALLHASH_H__
+#pragma once
/** \file
* \ingroup bli
@@ -81,5 +80,3 @@ double BLI_smallhash_calc_quality(SmallHash *sh);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_SMALLHASH_H__ */
diff --git a/source/blender/blenlib/BLI_sort.h b/source/blender/blenlib/BLI_sort.h
index 08e61915a83..969816086e2 100644
--- a/source/blender/blenlib/BLI_sort.h
+++ b/source/blender/blenlib/BLI_sort.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_SORT_H__
-#define __BLI_SORT_H__
+#pragma once
/** \file
* \ingroup bli
@@ -39,5 +38,3 @@ void BLI_qsort_r(void *a, size_t n, size_t es, BLI_sort_cmp_t cmp, void *thunk)
__attribute__((nonnull(1, 5)))
#endif
;
-
-#endif /* __BLI_SORT_H__ */
diff --git a/source/blender/blenlib/BLI_sort_utils.h b/source/blender/blenlib/BLI_sort_utils.h
index 9c99f893a1f..e54252f4e1b 100644
--- a/source/blender/blenlib/BLI_sort_utils.h
+++ b/source/blender/blenlib/BLI_sort_utils.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_SORT_UTILS_H__
-#define __BLI_SORT_UTILS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -64,5 +63,3 @@ int BLI_sortutil_cmp_ptr_reverse(const void *a_, const void *b_);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_SORT_UTILS_H__ */
diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh
index 81b86f647f6..165814cf23c 100644
--- a/source/blender/blenlib/BLI_span.hh
+++ b/source/blender/blenlib/BLI_span.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_SPAN_HH__
-#define __BLI_SPAN_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -102,7 +101,7 @@ template<typename T> class Span {
}
template<typename U, typename std::enable_if_t<is_convertible_pointer_v<U, T>> * = nullptr>
- Span(const U *start, int64_t size) : data_((const T *)start), size_(size)
+ Span(const U *start, int64_t size) : data_(static_cast<const T *>(start)), size_(size)
{
BLI_assert(size >= 0);
}
@@ -118,11 +117,12 @@ template<typename T> class Span {
* Span<int> span = {1, 2, 3, 4};
* call_function_with_array(span);
*/
- Span(const std::initializer_list<T> &list) : Span(list.begin(), (int64_t)list.size())
+ Span(const std::initializer_list<T> &list)
+ : Span(list.begin(), static_cast<int64_t>(list.size()))
{
}
- Span(const std::vector<T> &vector) : Span(vector.data(), (int64_t)vector.size())
+ Span(const std::vector<T> &vector) : Span(vector.data(), static_cast<int64_t>(vector.size()))
{
}
@@ -133,10 +133,9 @@ template<typename T> class Span {
/**
* Support implicit conversions like the ones below:
* Span<T *> -> Span<const T *>
- * Span<Derived *> -> Span<Base *>
*/
template<typename U, typename std::enable_if_t<is_convertible_pointer_v<U, T>> * = nullptr>
- Span(Span<U> array) : data_((T *)array.data()), size_(array.size())
+ Span(Span<U> array) : data_(static_cast<const T *>(array.data())), size_(array.size())
{
}
@@ -374,7 +373,7 @@ template<typename T> class Span {
{
const int64_t index = this->first_index_try(search_value);
BLI_assert(index >= 0);
- return (int64_t)index;
+ return index;
}
/**
@@ -656,5 +655,3 @@ void assert_same_size(const T1 &v1, const T2 &v2, const T3 &v3)
}
} /* namespace blender */
-
-#endif /* __BLI_SPAN_HH__ */
diff --git a/source/blender/blenlib/BLI_stack.h b/source/blender/blenlib/BLI_stack.h
index 9fc25e378a3..b00bc0a2e57 100644
--- a/source/blender/blenlib/BLI_stack.h
+++ b/source/blender/blenlib/BLI_stack.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_STACK_H__
-#define __BLI_STACK_H__
+#pragma once
/** \file
* \ingroup bli
@@ -55,5 +54,3 @@ bool BLI_stack_is_empty(const BLI_Stack *stack) ATTR_WARN_UNUSED_RESULT ATTR_NON
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_STACK_H__ */
diff --git a/source/blender/blenlib/BLI_stack.hh b/source/blender/blenlib/BLI_stack.hh
index 75ae9df79a4..8eca356ec54 100644
--- a/source/blender/blenlib/BLI_stack.hh
+++ b/source/blender/blenlib/BLI_stack.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_STACK_HH__
-#define __BLI_STACK_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -351,11 +350,12 @@ class Stack {
void *buffer = allocator_.allocate(
sizeof(Chunk) + sizeof(T) * new_capacity + alignof(T), alignof(Chunk), AT);
void *chunk_buffer = buffer;
- void *data_buffer = (void *)(((uintptr_t)buffer + sizeof(Chunk) + alignof(T) - 1) &
- ~(alignof(T) - 1));
+ void *data_buffer = reinterpret_cast<void *>(
+ (reinterpret_cast<uintptr_t>(buffer) + sizeof(Chunk) + alignof(T) - 1) &
+ ~(alignof(T) - 1));
Chunk *new_chunk = new (chunk_buffer) Chunk();
- new_chunk->begin = (T *)data_buffer;
+ new_chunk->begin = static_cast<T *>(data_buffer);
new_chunk->capacity_end = new_chunk->begin + new_capacity;
new_chunk->above = nullptr;
new_chunk->below = top_chunk_;
@@ -386,5 +386,3 @@ template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capaci
using RawStack = Stack<T, InlineBufferCapacity, RawAllocator>;
} /* namespace blender */
-
-#endif /* __BLI_STACK_HH__ */
diff --git a/source/blender/blenlib/BLI_strict_flags.h b/source/blender/blenlib/BLI_strict_flags.h
index cf7888d3c5e..6cee6b64797 100644
--- a/source/blender/blenlib/BLI_strict_flags.h
+++ b/source/blender/blenlib/BLI_strict_flags.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_STRICT_FLAGS_H__
-#define __BLI_STRICT_FLAGS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -53,5 +52,3 @@
# pragma warning(error : 4305) /* truncation from 'type1' to 'type2' */
# pragma warning(error : 4389) /* signed/unsigned mismatch */
#endif
-
-#endif /* __BLI_STRICT_FLAGS_H__ */
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index 00e4e3485d1..d1fab065959 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_STRING_H__
-#define __BLI_STRING_H__
+#pragma once
/** \file
* \ingroup bli
@@ -206,5 +205,3 @@ int BLI_string_find_split_words(const char *str,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_STRING_H__ */
diff --git a/source/blender/blenlib/BLI_string_cursor_utf8.h b/source/blender/blenlib/BLI_string_cursor_utf8.h
index f8afff214a3..e78c7b56cf7 100644
--- a/source/blender/blenlib/BLI_string_cursor_utf8.h
+++ b/source/blender/blenlib/BLI_string_cursor_utf8.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_STRING_CURSOR_UTF8_H__
-#define __BLI_STRING_CURSOR_UTF8_H__
+#pragma once
/** \file
* \ingroup bli
@@ -59,5 +58,3 @@ void BLI_str_cursor_step_utf32(const char32_t *str,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_STRING_CURSOR_UTF8_H__ */
diff --git a/source/blender/blenlib/BLI_string_ref.hh b/source/blender/blenlib/BLI_string_ref.hh
index 06fc66f6b55..e30eccca891 100644
--- a/source/blender/blenlib/BLI_string_ref.hh
+++ b/source/blender/blenlib/BLI_string_ref.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_STRING_REF_HH__
-#define __BLI_STRING_REF_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -38,13 +37,16 @@
* Both types are certainly very similar. The main benefit of using StringRef in Blender is that
* this allows us to add convenience methods at any time. Especially, when doing a lot of string
* manipulation, this helps to keep the code clean. Furthermore, we need StringRefNull anyway,
- * because there is a lot of C code that expects null-terminated strings. Once we use C++17,
- * implicit conversions to and from string_view can be added.
+ * because there is a lot of C code that expects null-terminated strings. Conversion between
+ * StringRef and string_view is very cheap and can be done at api boundaries at essentially no
+ * cost. Another benefit of using StringRef is that it uses signed integers, thus developers
+ * have to deal less with issues resulting from unsigned integers.
*/
#include <cstring>
#include <sstream>
#include <string>
+#include <string_view>
#include "BLI_span.hh"
#include "BLI_utildefines.h"
@@ -67,6 +69,9 @@ class StringRefBase {
}
public:
+ /* Similar to string_view::npos, but signed. */
+ static constexpr int64_t not_found = -1;
+
/**
* Return the (byte-)length of the referenced string, without any null-terminator.
*/
@@ -75,6 +80,11 @@ class StringRefBase {
return size_;
}
+ bool is_empty() const
+ {
+ return size_ == 0;
+ }
+
/**
* Return a pointer to the start of the string.
*/
@@ -94,7 +104,12 @@ class StringRefBase {
*/
operator std::string() const
{
- return std::string(data_, (size_t)size_);
+ return std::string(data_, static_cast<size_t>(size_));
+ }
+
+ operator std::string_view() const
+ {
+ return std::string_view(data_, static_cast<size_t>(size_));
}
const char *begin() const
@@ -114,7 +129,7 @@ class StringRefBase {
*/
void unsafe_copy(char *dst) const
{
- memcpy(dst, data_, (size_t)size_);
+ memcpy(dst, data_, static_cast<size_t>(size_));
dst[size_] = '\0';
}
@@ -153,6 +168,41 @@ class StringRefBase {
bool endswith(StringRef suffix) const;
StringRef substr(int64_t start, const int64_t size) const;
+
+ /**
+ * Get the first char in the string. This invokes undefined behavior when the string is empty.
+ */
+ const char &front() const
+ {
+ BLI_assert(size_ >= 1);
+ return data_[0];
+ }
+
+ /**
+ * Get the last char in the string. This invokes undefined behavior when the string is empty.
+ */
+ const char &back() const
+ {
+ BLI_assert(size_ >= 1);
+ return data_[size_ - 1];
+ }
+
+ /**
+ * The behavior of those functions matches the standard library implementation of
+ * std::string_view.
+ */
+ int64_t find(char c, int64_t pos = 0) const;
+ int64_t find(StringRef str, int64_t pos = 0) const;
+ int64_t rfind(char c, int64_t pos = INT64_MAX) const;
+ int64_t rfind(StringRef str, int64_t pos = INT64_MAX) const;
+ int64_t find_first_of(StringRef chars, int64_t pos = 0) const;
+ int64_t find_first_of(char c, int64_t pos = 0) const;
+ int64_t find_last_of(StringRef chars, int64_t pos = INT64_MAX) const;
+ int64_t find_last_of(char c, int64_t pos = INT64_MAX) const;
+ int64_t find_first_not_of(StringRef chars, int64_t pos = 0) const;
+ int64_t find_first_not_of(char c, int64_t pos = 0) const;
+ int64_t find_last_not_of(StringRef chars, int64_t pos = INT64_MAX) const;
+ int64_t find_last_not_of(char c, int64_t pos = INT64_MAX) const;
};
/**
@@ -166,9 +216,10 @@ class StringRefNull : public StringRefBase {
}
/**
- * Construct a StringRefNull from a null terminated c-string. The pointer must not point to NULL.
+ * Construct a StringRefNull from a null terminated c-string. The pointer must not point to
+ * NULL.
*/
- StringRefNull(const char *str) : StringRefBase(str, (int64_t)strlen(str))
+ StringRefNull(const char *str) : StringRefBase(str, static_cast<int64_t>(strlen(str)))
{
BLI_assert(str != NULL);
BLI_assert(data_[size_] == '\0');
@@ -180,7 +231,7 @@ class StringRefNull : public StringRefBase {
*/
StringRefNull(const char *str, const int64_t size) : StringRefBase(str, size)
{
- BLI_assert((int64_t)strlen(str) == size);
+ BLI_assert(static_cast<int64_t>(strlen(str)) == size);
}
/**
@@ -232,7 +283,7 @@ class StringRef : public StringRefBase {
/**
* Create a StringRef from a null-terminated c-string.
*/
- StringRef(const char *str) : StringRefBase(str, str ? (int64_t)strlen(str) : 0)
+ StringRef(const char *str) : StringRefBase(str, str ? static_cast<int64_t>(strlen(str)) : 0)
{
}
@@ -245,7 +296,7 @@ class StringRef : public StringRefBase {
* second point points to a smaller address than the first one.
*/
StringRef(const char *begin, const char *one_after_end)
- : StringRefBase(begin, (int64_t)(one_after_end - begin))
+ : StringRefBase(begin, static_cast<int64_t>(one_after_end - begin))
{
BLI_assert(begin <= one_after_end);
}
@@ -254,12 +305,18 @@ class StringRef : public StringRefBase {
* Reference a std::string. Remember that when the std::string is destructed, the StringRef
* will point to uninitialized memory.
*/
- StringRef(const std::string &str) : StringRefBase(str.data(), (int64_t)str.size())
+ StringRef(const std::string &str) : StringRefBase(str.data(), static_cast<int64_t>(str.size()))
+ {
+ }
+
+ StringRef(std::string_view view) : StringRefBase(view.data(), static_cast<int64_t>(view.size()))
{
}
/**
- * Return a new StringRef that does not contain the first n chars.
+ * Returns a new StringRef that does not contain the first n chars.
+ *
+ * This is similar to std::string_view::remove_prefix.
*/
StringRef drop_prefix(const int64_t n) const
{
@@ -269,8 +326,8 @@ class StringRef : public StringRefBase {
}
/**
- * Return a new StringRef that with the given prefix being skipped.
- * Asserts that the string begins with the given prefix.
+ * Return a new StringRef with the given prefix being skipped. This invokes undefined behavior if
+ * the string does not begin with the given prefix.
*/
StringRef drop_prefix(StringRef prefix) const
{
@@ -279,6 +336,18 @@ class StringRef : public StringRefBase {
}
/**
+ * Return a new StringRef that does not contain the last n chars.
+ *
+ * This is similar to std::string_view::remove_suffix.
+ */
+ StringRef drop_suffix(const int64_t n) const
+ {
+ BLI_assert(n >= 0);
+ BLI_assert(n <= size_);
+ return StringRef(data_, size_ - n);
+ }
+
+ /**
* Get the char at the given index.
*/
char operator[](int64_t index) const
@@ -313,6 +382,10 @@ inline std::string operator+(StringRef a, StringRef b)
return std::string(a) + std::string(b);
}
+/* This does not compare StringRef and std::string_view, because of ambiguous overloads. This is
+ * not a problem when std::string_view is only used at api boundaries. To compare a StringRef and a
+ * std::string_view, one should convert the std::string_view to StringRef (which is very cheap).
+ * Ideally, we only use StringRef in our code to avoid this problem altogether. */
inline bool operator==(StringRef a, StringRef b)
{
if (a.size() != b.size()) {
@@ -362,14 +435,82 @@ inline bool StringRefBase::endswith(StringRef suffix) const
/**
* Return a new #StringRef containing only a sub-string of the original string.
*/
-inline StringRef StringRefBase::substr(const int64_t start, const int64_t size) const
+inline StringRef StringRefBase::substr(const int64_t start,
+ const int64_t max_size = INT64_MAX) const
{
- BLI_assert(size >= 0);
+ BLI_assert(max_size >= 0);
BLI_assert(start >= 0);
- BLI_assert(start + size <= size_);
- return StringRef(data_ + start, size);
+ const int64_t substr_size = std::min(max_size, size_ - start);
+ return StringRef(data_ + start, substr_size);
}
-} // namespace blender
+inline int64_t index_or_npos_to_int64(size_t index)
+{
+ /* The compiler will probably optimize this check away. */
+ if (index == std::string_view::npos) {
+ return StringRef::not_found;
+ }
+ return static_cast<int64_t>(index);
+}
+
+inline int64_t StringRefBase::find(char c, int64_t pos) const
+{
+ BLI_assert(pos >= 0);
+ return index_or_npos_to_int64(std::string_view(*this).find(c, static_cast<size_t>(pos)));
+}
+
+inline int64_t StringRefBase::find(StringRef str, int64_t pos) const
+{
+ BLI_assert(pos >= 0);
+ return index_or_npos_to_int64(std::string_view(*this).find(str, static_cast<size_t>(pos)));
+}
+
+inline int64_t StringRefBase::find_first_of(StringRef chars, int64_t pos) const
+{
+ BLI_assert(pos >= 0);
+ return index_or_npos_to_int64(
+ std::string_view(*this).find_first_of(chars, static_cast<size_t>(pos)));
+}
+
+inline int64_t StringRefBase::find_first_of(char c, int64_t pos) const
+{
+ return this->find_first_of(StringRef(&c, 1), pos);
+}
+
+inline int64_t StringRefBase::find_last_of(StringRef chars, int64_t pos) const
+{
+ BLI_assert(pos >= 0);
+ return index_or_npos_to_int64(
+ std::string_view(*this).find_last_of(chars, static_cast<size_t>(pos)));
+}
-#endif /* __BLI_STRING_REF_HH__ */
+inline int64_t StringRefBase::find_last_of(char c, int64_t pos) const
+{
+ return this->find_last_of(StringRef(&c, 1), pos);
+}
+
+inline int64_t StringRefBase::find_first_not_of(StringRef chars, int64_t pos) const
+{
+ BLI_assert(pos >= 0);
+ return index_or_npos_to_int64(
+ std::string_view(*this).find_first_not_of(chars, static_cast<size_t>(pos)));
+}
+
+inline int64_t StringRefBase::find_first_not_of(char c, int64_t pos) const
+{
+ return this->find_first_not_of(StringRef(&c, 1), pos);
+}
+
+inline int64_t StringRefBase::find_last_not_of(StringRef chars, int64_t pos) const
+{
+ BLI_assert(pos >= 0);
+ return index_or_npos_to_int64(
+ std::string_view(*this).find_last_not_of(chars, static_cast<size_t>(pos)));
+}
+
+inline int64_t StringRefBase::find_last_not_of(char c, int64_t pos) const
+{
+ return this->find_last_not_of(StringRef(&c, 1), pos);
+}
+
+} // namespace blender
diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h
index 78e7113b6ef..3620a3ccc55 100644
--- a/source/blender/blenlib/BLI_string_utf8.h
+++ b/source/blender/blenlib/BLI_string_utf8.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_STRING_UTF8_H__
-#define __BLI_STRING_UTF8_H__
+#pragma once
/** \file
* \ingroup bli
@@ -115,5 +114,3 @@ int BLI_str_utf8_offset_from_column(const char *str, int column);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenlib/BLI_string_utils.h b/source/blender/blenlib/BLI_string_utils.h
index 857b22540e9..46fb096599f 100644
--- a/source/blender/blenlib/BLI_string_utils.h
+++ b/source/blender/blenlib/BLI_string_utils.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_STRING_UTILS_H__
-#define __BLI_STRING_UTILS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -97,5 +96,3 @@ bool BLI_uniquename(struct ListBase *list,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_STRING_UTILS_H__ */
diff --git a/source/blender/blenlib/BLI_sys_types.h b/source/blender/blenlib/BLI_sys_types.h
index ef15ce111b6..ff1f6af9573 100644
--- a/source/blender/blenlib/BLI_sys_types.h
+++ b/source/blender/blenlib/BLI_sys_types.h
@@ -31,8 +31,7 @@
* For these rogue platforms, we make the typedefs ourselves.
*/
-#ifndef __BLI_SYS_TYPES_H__
-#define __BLI_SYS_TYPES_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -89,5 +88,3 @@ typedef unsigned char uchar;
#ifdef __cplusplus
}
#endif
-
-#endif /* eof */
diff --git a/source/blender/blenlib/BLI_system.h b/source/blender/blenlib/BLI_system.h
index 50f8adc20f6..8dd0706e1e2 100644
--- a/source/blender/blenlib/BLI_system.h
+++ b/source/blender/blenlib/BLI_system.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_SYSTEM_H__
-#define __BLI_SYSTEM_H__
+#pragma once
#include <stdio.h>
@@ -64,5 +63,3 @@ void BLI_windows_handle_exception(void *exception);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_SYSTEM_H__ */
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index 920a0a8f650..a281aaa5b51 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_THREADS_H__
-#define __BLI_THREADS_H__
+#pragma once
/** \file
* \ingroup bli
@@ -205,5 +204,3 @@ void BLI_thread_put_thread_on_fast_node(void);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenlib/BLI_timecode.h b/source/blender/blenlib/BLI_timecode.h
index d3c6803130a..1dff50efa23 100644
--- a/source/blender/blenlib/BLI_timecode.h
+++ b/source/blender/blenlib/BLI_timecode.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_TIMECODE_H__
-#define __BLI_TIMECODE_H__
+#pragma once
/** \file
* \ingroup BLI
@@ -49,5 +48,3 @@ size_t BLI_timecode_string_from_time_seconds(char *str,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_TIMECODE_H__ */
diff --git a/source/blender/blenlib/BLI_timeit.hh b/source/blender/blenlib/BLI_timeit.hh
index f0968587597..8e107585576 100644
--- a/source/blender/blenlib/BLI_timeit.hh
+++ b/source/blender/blenlib/BLI_timeit.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_TIMEIT_HH__
-#define __BLI_TIMEIT_HH__
+#pragma once
#include <chrono>
#include <iostream>
@@ -56,5 +55,3 @@ class ScopedTimer {
} // namespace blender::timeit
#define SCOPED_TIMER(name) blender::timeit::ScopedTimer scoped_timer(name)
-
-#endif /* __BLI_TIMEIT_HH__ */
diff --git a/source/blender/blenlib/BLI_timer.h b/source/blender/blenlib/BLI_timer.h
index 144fcd0a0d7..19275ff5b9a 100644
--- a/source/blender/blenlib/BLI_timer.h
+++ b/source/blender/blenlib/BLI_timer.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_TIMER_H__
-#define __BLI_TIMER_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -61,5 +60,3 @@ void BLI_timer_on_file_load(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_TIMER_H__ */
diff --git a/source/blender/blenlib/BLI_utildefines_iter.h b/source/blender/blenlib/BLI_utildefines_iter.h
index bbd83573e53..5fb6248e1e9 100644
--- a/source/blender/blenlib/BLI_utildefines_iter.h
+++ b/source/blender/blenlib/BLI_utildefines_iter.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_UTILDEFINES_ITER_H__
-#define __BLI_UTILDEFINES_ITER_H__
+#pragma once
/** \file
* \ingroup bli
@@ -42,5 +41,3 @@
for (int _src = (src), _src2 = _src * 2, _dst2 = (dst)*2, _error = _dst2 - _src, i = 0, _delta; \
((void)(_delta = divide_floor_i(_error, _dst2)), (void)(i -= _delta), (i < _src)); \
_error -= (_delta * _dst2) + _src2)
-
-#endif /* __BLI_UTILDEFINES_ITER_H__ */
diff --git a/source/blender/blenlib/BLI_utildefines_stack.h b/source/blender/blenlib/BLI_utildefines_stack.h
index 9f9bfb0405d..f50004ef79a 100644
--- a/source/blender/blenlib/BLI_utildefines_stack.h
+++ b/source/blender/blenlib/BLI_utildefines_stack.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_UTILDEFINES_STACK_H__
-#define __BLI_UTILDEFINES_STACK_H__
+#pragma once
/** \file
* \ingroup bli
@@ -99,5 +98,3 @@
} \
((void)0)
#endif
-
-#endif /* __BLI_UTILDEFINES_STACK_H__ */
diff --git a/source/blender/blenlib/BLI_utildefines_variadic.h b/source/blender/blenlib/BLI_utildefines_variadic.h
index f5a420a7faf..be0d0b93cc7 100644
--- a/source/blender/blenlib/BLI_utildefines_variadic.h
+++ b/source/blender/blenlib/BLI_utildefines_variadic.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_UTILDEFINES_VARIADIC_H__
-#define __BLI_UTILDEFINES_VARIADIC_H__
+#pragma once
/** \file
* \ingroup bli
@@ -47,5 +46,3 @@
_VA_NARGS_GLUE(_VA_NARGS_OVERLOAD_MACRO(name, VA_NARGS_COUNT(__VA_ARGS__)), (__VA_ARGS__))
/* clang-format on */
-
-#endif /* __BLI_UTILDEFINES_VARIADIC_H__ */
diff --git a/source/blender/blenlib/BLI_utility_mixins.hh b/source/blender/blenlib/BLI_utility_mixins.hh
index 61444e36725..69b1d85b3b6 100644
--- a/source/blender/blenlib/BLI_utility_mixins.hh
+++ b/source/blender/blenlib/BLI_utility_mixins.hh
@@ -18,8 +18,7 @@
* \ingroup bli
*/
-#ifndef __BLI_UTILITY_MIXINS_HH__
-#define __BLI_UTILITY_MIXINS_HH__
+#pragma once
namespace blender {
@@ -54,5 +53,3 @@ class NonMovable {
};
} // namespace blender
-
-#endif /* __BLI_UTILITY_MIXINS_HH__ */
diff --git a/source/blender/blenlib/BLI_uvproject.h b/source/blender/blenlib/BLI_uvproject.h
index 8a33ea6961c..6028d95bda0 100644
--- a/source/blender/blenlib/BLI_uvproject.h
+++ b/source/blender/blenlib/BLI_uvproject.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_UVPROJECT_H__
-#define __BLI_UVPROJECT_H__
+#pragma once
/** \file
* \ingroup bli
@@ -45,7 +44,7 @@ void BLI_uvproject_from_view(float target[2],
float winy);
/* apply ortho uv's */
-void BLI_uvproject_from_view_ortho(float target[2], float source[3], float rotmat[4][4]);
+void BLI_uvproject_from_view_ortho(float target[2], float source[3], const float rotmat[4][4]);
/* so we can adjust scale with keeping the struct private */
void BLI_uvproject_camera_info_scale(struct ProjCameraInfo *uci, float scale_x, float scale_y);
@@ -53,5 +52,3 @@ void BLI_uvproject_camera_info_scale(struct ProjCameraInfo *uci, float scale_x,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh
index 7eac511bf4a..48110ef2814 100644
--- a/source/blender/blenlib/BLI_vector.hh
+++ b/source/blender/blenlib/BLI_vector.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_VECTOR_HH__
-#define __BLI_VECTOR_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -101,7 +100,8 @@ class Vector {
*/
#ifndef NDEBUG
int64_t debug_size_;
-# define UPDATE_VECTOR_SIZE(ptr) (ptr)->debug_size_ = (int64_t)((ptr)->end_ - (ptr)->begin_)
+# define UPDATE_VECTOR_SIZE(ptr) \
+ (ptr)->debug_size_ = static_cast<int64_t>((ptr)->end_ - (ptr)->begin_)
#else
# define UPDATE_VECTOR_SIZE(ptr) ((void)0)
#endif
@@ -244,7 +244,8 @@ class Vector {
else {
/* Copy from inline buffer to newly allocated buffer. */
const int64_t capacity = size;
- begin_ = (T *)allocator_.allocate(sizeof(T) * (size_t)capacity, alignof(T), AT);
+ begin_ = static_cast<T *>(
+ allocator_.allocate(sizeof(T) * static_cast<size_t>(capacity), alignof(T), AT));
end_ = begin_ + size;
capacity_end_ = begin_ + capacity;
uninitialized_relocate_n(other.begin_, size, begin_);
@@ -579,8 +580,9 @@ class Vector {
*/
int64_t size() const
{
- BLI_assert(debug_size_ == (int64_t)(end_ - begin_));
- return (int64_t)(end_ - begin_);
+ const int64_t current_size = static_cast<int64_t>(end_ - begin_);
+ BLI_assert(debug_size_ == current_size);
+ return current_size;
}
/**
@@ -676,7 +678,7 @@ class Vector {
{
for (const T *current = begin_; current != end_; current++) {
if (*current == value) {
- return (int64_t)(current - begin_);
+ return static_cast<int64_t>(current - begin_);
}
}
return -1;
@@ -750,7 +752,7 @@ class Vector {
*/
int64_t capacity() const
{
- return (int64_t)(capacity_end_ - begin_);
+ return static_cast<int64_t>(capacity_end_ - begin_);
}
/**
@@ -809,7 +811,8 @@ class Vector {
const int64_t new_capacity = std::max(min_capacity, min_new_capacity);
const int64_t size = this->size();
- T *new_array = (T *)allocator_.allocate((size_t)new_capacity * sizeof(T), alignof(T), AT);
+ T *new_array = static_cast<T *>(
+ allocator_.allocate(static_cast<size_t>(new_capacity) * sizeof(T), alignof(T), AT));
uninitialized_relocate_n(begin_, size, new_array);
if (!this->is_inline()) {
@@ -832,5 +835,3 @@ template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capaci
using RawVector = Vector<T, InlineBufferCapacity, RawAllocator>;
} /* namespace blender */
-
-#endif /* __BLI_VECTOR_HH__ */
diff --git a/source/blender/blenlib/BLI_vector_adaptor.hh b/source/blender/blenlib/BLI_vector_adaptor.hh
index cadffc0b445..9c805f242e4 100644
--- a/source/blender/blenlib/BLI_vector_adaptor.hh
+++ b/source/blender/blenlib/BLI_vector_adaptor.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_VECTOR_ADAPTOR_HH__
-#define __BLI_VECTOR_ADAPTOR_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -101,5 +100,3 @@ template<typename T> class VectorAdaptor {
};
} // namespace blender
-
-#endif /* __BLI_VECTOR_ADAPTOR_HH__ */
diff --git a/source/blender/blenlib/BLI_vector_set.hh b/source/blender/blenlib/BLI_vector_set.hh
index f007d41118f..9d7c61f9e3b 100644
--- a/source/blender/blenlib/BLI_vector_set.hh
+++ b/source/blender/blenlib/BLI_vector_set.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_VECTOR_SET_HH__
-#define __BLI_VECTOR_SET_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -458,7 +457,7 @@ class VectorSet {
*/
int64_t size_in_bytes() const
{
- return (int64_t)(sizeof(Slot) * slots_.size() + sizeof(Key) * usable_slots_);
+ return static_cast<int64_t>(sizeof(Slot) * slots_.size() + sizeof(Key) * usable_slots_);
}
/**
@@ -487,7 +486,7 @@ class VectorSet {
max_load_factor_.compute_total_and_usable_slots(
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
BLI_assert(total_slots >= 1);
- const uint64_t new_slot_mask = (uint64_t)total_slots - 1;
+ const uint64_t new_slot_mask = static_cast<uint64_t>(total_slots) - 1;
/* Optimize the case when the set was empty beforehand. We can avoid some copies here. */
if (this->size() == 0) {
@@ -723,7 +722,8 @@ class VectorSet {
Key *allocate_keys_array(const int64_t size)
{
- return (Key *)slots_.allocator().allocate(sizeof(Key) * (size_t)size, alignof(Key), AT);
+ return static_cast<Key *>(
+ slots_.allocator().allocate(sizeof(Key) * static_cast<size_t>(size), alignof(Key), AT));
}
void deallocate_keys_array(Key *keys)
@@ -744,5 +744,3 @@ template<typename Key,
using RawVectorSet = VectorSet<Key, ProbingStrategy, Hash, IsEqual, Slot, RawAllocator>;
} // namespace blender
-
-#endif /* __BLI_VECTOR_SET_HH__ */
diff --git a/source/blender/blenlib/BLI_vector_set_slots.hh b/source/blender/blenlib/BLI_vector_set_slots.hh
index 49e6d4daedb..0e75c4690a4 100644
--- a/source/blender/blenlib/BLI_vector_set_slots.hh
+++ b/source/blender/blenlib/BLI_vector_set_slots.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_VECTOR_SET_SLOTS_HH__
-#define __BLI_VECTOR_SET_SLOTS_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -167,5 +166,3 @@ template<typename Key> struct DefaultVectorSetSlot {
};
} // namespace blender
-
-#endif /* __BLI_VECTOR_SET_SLOTS_HH__ */
diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h
index 047a72ec59a..0bb32ca24b7 100644
--- a/source/blender/blenlib/BLI_vfontdata.h
+++ b/source/blender/blenlib/BLI_vfontdata.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_VFONTDATA_H__
-#define __BLI_VFONTDATA_H__
+#pragma once
/** \file
* \ingroup bli
@@ -59,5 +58,3 @@ VChar *BLI_vfontchar_copy(const VChar *vchar_src, const int flag);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/blenlib/BLI_voronoi_2d.h b/source/blender/blenlib/BLI_voronoi_2d.h
index a48f32c283a..92c7d367b48 100644
--- a/source/blender/blenlib/BLI_voronoi_2d.h
+++ b/source/blender/blenlib/BLI_voronoi_2d.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_VORONOI_2D_H__
-#define __BLI_VORONOI_2D_H__
+#pragma once
struct ListBase;
@@ -81,5 +80,3 @@ void BLI_voronoi_triangulate(const VoronoiSite *sites,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_VORONOI_2D_H__ */
diff --git a/source/blender/blenlib/BLI_voxel.h b/source/blender/blenlib/BLI_voxel.h
index 82854c57928..eb84f0a27ee 100644
--- a/source/blender/blenlib/BLI_voxel.h
+++ b/source/blender/blenlib/BLI_voxel.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_VOXEL_H__
-#define __BLI_VOXEL_H__
+#pragma once
/** \file
* \ingroup bli
@@ -46,5 +45,3 @@ float BLI_voxel_sample_tricubic(const float *data,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_VOXEL_H__ */
diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h
index 3d59ad21251..2de6098f6be 100644
--- a/source/blender/blenlib/BLI_winstuff.h
+++ b/source/blender/blenlib/BLI_winstuff.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLI_WINSTUFF_H__
-#define __BLI_WINSTUFF_H__
+#pragma once
/** \file
* \ingroup bli
@@ -111,5 +110,3 @@ int BLI_getInstallationDir(char *str);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLI_WINSTUFF_H__ */
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 4997917a93f..819c74b6946 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -37,6 +37,7 @@ set(INC_SYS
set(SRC
intern/BLI_args.c
intern/BLI_array.c
+ intern/BLI_assert.c
intern/BLI_dial_2d.c
intern/BLI_dynstr.c
intern/BLI_filelist.c
@@ -110,6 +111,7 @@ set(SRC
intern/rct.c
intern/scanfill.c
intern/scanfill_utils.c
+ intern/session_uuid.c
intern/smallhash.c
intern/sort.c
intern/sort_utils.c
@@ -239,6 +241,7 @@ set(SRC
BLI_rect.h
BLI_resource_collector.hh
BLI_scanfill.h
+ BLI_session_uuid.h
BLI_set.hh
BLI_set_slots.hh
BLI_smallhash.h
@@ -344,26 +347,58 @@ blender_add_lib(bf_blenlib "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
if(WITH_GTESTS)
set(TEST_SRC
+ tests/BLI_array_store_test.cc
tests/BLI_array_test.cc
+ tests/BLI_array_utils_test.cc
+ tests/BLI_delaunay_2d_test.cc
tests/BLI_disjoint_set_test.cc
tests/BLI_edgehash_test.cc
+ tests/BLI_expr_pylike_eval_test.cc
+ tests/BLI_ghash_test.cc
+ tests/BLI_hash_mm2a_test.cc
+ tests/BLI_heap_simple_test.cc
+ tests/BLI_heap_test.cc
tests/BLI_index_mask_test.cc
tests/BLI_index_range_test.cc
+ tests/BLI_kdopbvh_test.cc
tests/BLI_linear_allocator_test.cc
+ tests/BLI_linklist_lockfree_test.cc
+ tests/BLI_listbase_test.cc
tests/BLI_map_test.cc
tests/BLI_math_base_safe_test.cc
+ tests/BLI_math_base_test.cc
+ tests/BLI_math_bits_test.cc
+ tests/BLI_math_color_test.cc
+ tests/BLI_math_geom_test.cc
+ tests/BLI_math_matrix_test.cc
+ tests/BLI_math_vector_test.cc
+ tests/BLI_memiter_test.cc
tests/BLI_memory_utils_test.cc
tests/BLI_multi_value_map_test.cc
+ tests/BLI_path_util_test.cc
+ tests/BLI_polyfill_2d_test.cc
+ tests/BLI_ressource_strings.h
+ tests/BLI_session_uuid_test.cc
tests/BLI_set_test.cc
tests/BLI_span_test.cc
tests/BLI_stack_cxx_test.cc
+ tests/BLI_stack_test.cc
tests/BLI_string_ref_test.cc
+ tests/BLI_string_test.cc
+ tests/BLI_string_utf8_test.cc
+ tests/BLI_task_graph_test.cc
+ tests/BLI_task_test.cc
tests/BLI_vector_set_test.cc
tests/BLI_vector_test.cc
)
+ set(TEST_INC
+ ../imbuf
+ )
set(TEST_LIB
bf_blenlib
)
include(GTestTesting)
- blender_add_test_lib(bf_bli_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
+ blender_add_test_lib(bf_blenlib_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
+
+ add_subdirectory(tests/performance)
endif()
diff --git a/source/blender/blenlib/PIL_time.h b/source/blender/blenlib/PIL_time.h
index 21ebc9d4b90..311869e844a 100644
--- a/source/blender/blenlib/PIL_time.h
+++ b/source/blender/blenlib/PIL_time.h
@@ -22,8 +22,7 @@
* \brief Platform independent time functions.
*/
-#ifndef __PIL_TIME_H__
-#define __PIL_TIME_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -51,5 +50,3 @@ void PIL_sleep_ms(int ms);
#ifdef __cplusplus
}
#endif
-
-#endif /* __PIL_TIME_H__ */
diff --git a/source/blender/blenlib/PIL_time_utildefines.h b/source/blender/blenlib/PIL_time_utildefines.h
index ffe753badf8..d404a8b2b8a 100644
--- a/source/blender/blenlib/PIL_time_utildefines.h
+++ b/source/blender/blenlib/PIL_time_utildefines.h
@@ -22,8 +22,7 @@
* \brief Utility defines for timing/benchmarks.
*/
-#ifndef __PIL_TIME_UTILDEFINES_H__
-#define __PIL_TIME_UTILDEFINES_H__
+#pragma once
#include "BLI_utildefines.h" /* for AT */
#include "PIL_time.h" /* for PIL_check_seconds_timer */
@@ -127,5 +126,3 @@
fflush(stdout); \
} \
(void)0
-
-#endif /* __PIL_TIME_UTILDEFINES_H__ */
diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c
index 2b078b3bae5..91aabca7747 100644
--- a/source/blender/blenlib/intern/BLI_args.c
+++ b/source/blender/blenlib/intern/BLI_args.c
@@ -92,13 +92,9 @@ static bool keycmp(const void *a, const void *b)
if (ka->case_str == 1 || kb->case_str == 1) {
return (BLI_strcasecmp(ka->arg, kb->arg) != 0);
}
- else {
- return (!STREQ(ka->arg, kb->arg));
- }
- }
- else {
- return BLI_ghashutil_intcmp((const void *)ka->pass, (const void *)kb->pass);
+ return (!STREQ(ka->arg, kb->arg));
}
+ return BLI_ghashutil_intcmp((const void *)ka->pass, (const void *)kb->pass);
}
static bArgument *lookUp(struct bArgs *ba, const char *arg, int pass, int case_str)
diff --git a/source/blender/blenlib/intern/BLI_assert.c b/source/blender/blenlib/intern/BLI_assert.c
new file mode 100644
index 00000000000..dc22d035459
--- /dev/null
+++ b/source/blender/blenlib/intern/BLI_assert.c
@@ -0,0 +1,51 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup bli
+ *
+ * Helper functions for BLI_assert.h header.
+ */
+
+#include "BLI_assert.h" /* Own include. */
+#include "BLI_system.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void _BLI_assert_print_pos(const char *file, int line, const char *function, const char *id)
+{
+ fprintf(stderr, "BLI_assert failed: %s:%d, %s(), at \'%s\'\n", file, line, function, id);
+}
+
+void _BLI_assert_print_backtrace(void)
+{
+#ifndef NDEBUG
+ BLI_system_backtrace(stderr);
+#endif
+}
+
+/**
+ * Wrap to remove 'noreturn' attribute since this suppresses missing return statements,
+ * allowing changes to debug builds to accidentally to break release builds.
+ *
+ * For example `BLI_assert(0);` at the end of a function that returns a value,
+ * will hide that it's missing a return.
+ */
+void _BLI_assert_abort(void)
+{
+ abort();
+}
diff --git a/source/blender/blenlib/intern/BLI_dial_2d.c b/source/blender/blenlib/intern/BLI_dial_2d.c
index c6d28e20f35..7363233d573 100644
--- a/source/blender/blenlib/intern/BLI_dial_2d.c
+++ b/source/blender/blenlib/intern/BLI_dial_2d.c
@@ -45,7 +45,7 @@ struct Dial {
bool initialized;
};
-Dial *BLI_dial_initialize(const float start_position[2], float threshold)
+Dial *BLI_dial_init(const float start_position[2], float threshold)
{
Dial *dial = MEM_callocN(sizeof(Dial), "dial");
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 09dbf18acd0..69602cd4209 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -538,10 +538,8 @@ BLI_INLINE bool ghash_insert_safe(GHash *gh,
}
return false;
}
- else {
- ghash_insert_ex(gh, key, val, bucket_index);
- return true;
- }
+ ghash_insert_ex(gh, key, val, bucket_index);
+ return true;
}
BLI_INLINE bool ghash_insert_safe_keyonly(GHash *gh,
@@ -564,10 +562,8 @@ BLI_INLINE bool ghash_insert_safe_keyonly(GHash *gh,
}
return false;
}
- else {
- ghash_insert_ex_keyonly(gh, key, bucket_index);
- return true;
- }
+ ghash_insert_ex_keyonly(gh, key, bucket_index);
+ return true;
}
/**
@@ -792,9 +788,7 @@ void *BLI_ghash_replace_key(GHash *gh, void *key)
e->e.key = key;
return key_prev;
}
- else {
- return NULL;
- }
+ return NULL;
}
/**
@@ -915,9 +909,7 @@ bool BLI_ghash_remove(GHash *gh,
BLI_mempool_free(gh->entrypool, e);
return true;
}
- else {
- return false;
- }
+ return false;
}
/* same as above but return the value,
@@ -940,9 +932,7 @@ void *BLI_ghash_popkey(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp)
BLI_mempool_free(gh->entrypool, e);
return val;
}
- else {
- return NULL;
- }
+ return NULL;
}
/**
@@ -975,10 +965,9 @@ bool BLI_ghash_pop(GHash *gh, GHashIterState *state, void **r_key, void **r_val)
BLI_mempool_free(gh->entrypool, e);
return true;
}
- else {
- *r_key = *r_val = NULL;
- return false;
- }
+
+ *r_key = *r_val = NULL;
+ return false;
}
/**
@@ -1246,10 +1235,9 @@ bool BLI_gset_pop(GSet *gs, GSetIterState *state, void **r_key)
BLI_mempool_free(((GHash *)gs)->entrypool, e);
return true;
}
- else {
- *r_key = NULL;
- return false;
- }
+
+ *r_key = NULL;
+ return false;
}
void BLI_gset_clear_ex(GSet *gs, GSetKeyFreeFP keyfreefp, const uint nentries_reserve)
@@ -1309,9 +1297,7 @@ void *BLI_gset_pop_key(GSet *gs, const void *key)
BLI_mempool_free(((GHash *)gs)->entrypool, e);
return key_ret;
}
- else {
- return NULL;
- }
+ return NULL;
}
/** \} */
diff --git a/source/blender/blenlib/intern/BLI_ghash_utils.c b/source/blender/blenlib/intern/BLI_ghash_utils.c
index d6a4b24682f..9323ec46d5b 100644
--- a/source/blender/blenlib/intern/BLI_ghash_utils.c
+++ b/source/blender/blenlib/intern/BLI_ghash_utils.c
@@ -55,7 +55,7 @@ uint BLI_ghashutil_ptrhash(const void *key)
/* Note: Unlike Python 'sizeof(uint)' is used instead of 'sizeof(void *)',
* Otherwise casting to 'uint' ignores the upper bits on 64bit platforms. */
- return (uint)(y >> 4) | ((uint)y << (8 * sizeof(uint) - 4));
+ return (uint)(y >> 4) | ((uint)y << (sizeof(uint[8]) - 4));
}
#endif
bool BLI_ghashutil_ptrcmp(const void *a, const void *b)
@@ -78,7 +78,7 @@ uint BLI_ghashutil_uinthash_v4(const uint key[4])
uint BLI_ghashutil_uinthash_v4_murmur(const uint key[4])
{
- return BLI_hash_mm2((const unsigned char *)key, sizeof(int) * 4 /* sizeof(key) */, 0);
+ return BLI_hash_mm2((const unsigned char *)key, sizeof(int[4]) /* sizeof(key) */, 0);
}
bool BLI_ghashutil_uinthash_v4_cmp(const void *a, const void *b)
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index a3f93ccc753..f63a523ca60 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -284,28 +284,19 @@ static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis)
if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
return a[mid];
}
- else {
- if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
- return a[hi];
- }
- else {
- return a[lo];
- }
+ if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
+ return a[hi];
}
+ return a[lo];
}
- else {
- if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
- if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
- return a[lo];
- }
- else {
- return a[hi];
- }
- }
- else {
- return a[mid];
+
+ if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
+ if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
+ return a[lo];
}
+ return a[hi];
}
+ return a[mid];
}
/**
@@ -422,18 +413,12 @@ static char get_largest_axis(const float *bv)
if (middle_point[0] > middle_point[2]) {
return 1; /* max x axis */
}
- else {
- return 5; /* max z axis */
- }
+ return 5; /* max z axis */
}
- else {
- if (middle_point[1] > middle_point[2]) {
- return 3; /* max y axis */
- }
- else {
- return 5; /* max z axis */
- }
+ if (middle_point[1] > middle_point[2]) {
+ return 3; /* max y axis */
}
+ return 5; /* max z axis */
}
/**
@@ -619,13 +604,11 @@ static int implicit_leafs_index(const BVHBuildHelper *data, const int depth, con
if (min_leaf_index <= data->remain_leafs) {
return min_leaf_index;
}
- else if (data->leafs_per_child[depth]) {
+ if (data->leafs_per_child[depth]) {
return data->totleafs -
(data->branches_on_level[depth - 1] - child_index) * data->leafs_per_child[depth];
}
- else {
- return data->remain_leafs;
- }
+ return data->remain_leafs;
}
/**
@@ -1668,10 +1651,8 @@ static bool dfs_find_duplicate_fast_dfs(BVHNearestData *data, BVHNode *node)
data->callback(data->userdata, node->index, data->co, &data->nearest);
return (data->nearest.dist_sq < dist_sq);
}
- else {
- data->nearest.index = node->index;
- return true;
- }
+ data->nearest.index = node->index;
+ return true;
}
}
else {
@@ -1805,9 +1786,7 @@ static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *nod
(t1x > data->hit.dist || t1y > data->hit.dist || t1z > data->hit.dist)) {
return FLT_MAX;
}
- else {
- return max_fff(t1x, t1y, t1z);
- }
+ return max_fff(t1x, t1y, t1z);
}
static void dfs_raycast(BVHRayCastData *data, BVHNode *node)
@@ -2354,26 +2333,25 @@ static bool bvhtree_walk_dfs_recursive(BVHTree_WalkData *walk_data, const BVHNod
return walk_data->walk_leaf_cb(
(const BVHTreeAxisRange *)node->bv, node->index, walk_data->userdata);
}
- else {
- /* First pick the closest node to recurse into */
- if (walk_data->walk_order_cb(
- (const BVHTreeAxisRange *)node->bv, node->main_axis, walk_data->userdata)) {
- for (int i = 0; i != node->totnode; i++) {
- if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
- walk_data->userdata)) {
- if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
- return false;
- }
+
+ /* First pick the closest node to recurse into */
+ if (walk_data->walk_order_cb(
+ (const BVHTreeAxisRange *)node->bv, node->main_axis, walk_data->userdata)) {
+ for (int i = 0; i != node->totnode; i++) {
+ if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
+ walk_data->userdata)) {
+ if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
+ return false;
}
}
}
- else {
- for (int i = node->totnode - 1; i >= 0; i--) {
- if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
- walk_data->userdata)) {
- if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
- return false;
- }
+ }
+ else {
+ for (int i = node->totnode - 1; i >= 0; i--) {
+ if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv,
+ walk_data->userdata)) {
+ if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) {
+ return false;
}
}
}
diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c
index dc5d20ece99..4cac526088b 100644
--- a/source/blender/blenlib/intern/BLI_linklist.c
+++ b/source/blender/blenlib/intern/BLI_linklist.c
@@ -147,7 +147,7 @@ void BLI_linklist_move_item(LinkNode **listp, int curr_index, int new_index)
lnk_pdst = lnk;
break;
}
- else if (i == curr_index - 1) {
+ if (i == curr_index - 1) {
lnk_psrc = lnk;
}
}
diff --git a/source/blender/blenlib/intern/BLI_memiter.c b/source/blender/blenlib/intern/BLI_memiter.c
index 1b9509e36d8..428dd1e2ad8 100644
--- a/source/blender/blenlib/intern/BLI_memiter.c
+++ b/source/blender/blenlib/intern/BLI_memiter.c
@@ -269,9 +269,7 @@ void *BLI_memiter_elem_first(BLI_memiter *mi)
BLI_memiter_elem *elem = (BLI_memiter_elem *)chunk->data;
return elem->data;
}
- else {
- return NULL;
- }
+ return NULL;
}
void *BLI_memiter_elem_first_size(BLI_memiter *mi, uint *r_size)
@@ -282,9 +280,7 @@ void *BLI_memiter_elem_first_size(BLI_memiter *mi, uint *r_size)
*r_size = (uint)elem->size;
return elem->data;
}
- else {
- return NULL;
- }
+ return NULL;
}
/** \} */
@@ -334,9 +330,7 @@ void *BLI_memiter_iter_step_size(BLI_memiter_handle *iter, uint *r_size)
iter->elem = (BLI_memiter_elem *)&data[data_offset_from_size(size)];
return (void *)data;
}
- else {
- return NULL;
- }
+ return NULL;
}
void *BLI_memiter_iter_step(BLI_memiter_handle *iter)
@@ -352,9 +346,7 @@ void *BLI_memiter_iter_step(BLI_memiter_handle *iter)
iter->elem = (BLI_memiter_elem *)&data[data_offset_from_size(size)];
return (void *)data;
}
- else {
- return NULL;
- }
+ return NULL;
}
/** \} */
diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c
index 6810601d527..b0c3379ac97 100644
--- a/source/blender/blenlib/intern/DLRB_tree.c
+++ b/source/blender/blenlib/intern/DLRB_tree.c
@@ -299,9 +299,7 @@ static DLRBT_Node *get_grandparent(DLRBT_Node *node)
if (node && node->parent) {
return node->parent->parent;
}
- else {
- return NULL;
- }
+ return NULL;
}
/* get the sibling node (e.g. if node is left child of parent, return right child of parent) */
@@ -311,9 +309,7 @@ static DLRBT_Node *get_sibling(DLRBT_Node *node)
if (node == node->parent->left) {
return node->parent->right;
}
- else {
- return node->parent->left;
- }
+ return node->parent->left;
}
/* sibling not found */
diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c
index 85fbe7ece0f..387f9837159 100644
--- a/source/blender/blenlib/intern/array_store.c
+++ b/source/blender/blenlib/intern/array_store.c
@@ -355,9 +355,7 @@ static bool bchunk_data_compare(const BChunk *chunk,
if (offset + (size_t)chunk->data_len <= data_base_len) {
return (memcmp(&data_base[offset], chunk->data, chunk->data_len) == 0);
}
- else {
- return false;
- }
+ return false;
}
/** \} */
@@ -893,20 +891,18 @@ static hash_key key_from_chunk_ref(const BArrayInfo *info,
# endif
return key;
}
- else {
- /* corner case - we're too small, calculate the key each time. */
+ /* corner case - we're too small, calculate the key each time. */
- hash_array_from_cref(info, cref, info->accum_read_ahead_bytes, hash_store);
- hash_accum_single(hash_store, hash_store_len, info->accum_steps);
- hash_key key = hash_store[0];
+ hash_array_from_cref(info, cref, info->accum_read_ahead_bytes, hash_store);
+ hash_accum_single(hash_store, hash_store_len, info->accum_steps);
+ hash_key key = hash_store[0];
# ifdef USE_HASH_TABLE_KEY_CACHE
- if (UNLIKELY(key == HASH_TABLE_KEY_UNSET)) {
- key = HASH_TABLE_KEY_FALLBACK;
- }
-# endif
- return key;
+ if (UNLIKELY(key == HASH_TABLE_KEY_UNSET)) {
+ key = HASH_TABLE_KEY_FALLBACK;
}
+# endif
+ return key;
}
static const BChunkRef *table_lookup(const BArrayInfo *info,
@@ -1083,9 +1079,7 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info,
if (cref == cref_match_first) {
break;
}
- else {
- cref = cref->next;
- }
+ cref = cref->next;
}
/* happens when bytes are removed from the end of the array */
if (chunk_size_step == data_len_original) {
diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c
index 5dec10a5756..e9ef5e2a927 100644
--- a/source/blender/blenlib/intern/array_utils.c
+++ b/source/blender/blenlib/intern/array_utils.c
@@ -208,7 +208,7 @@ bool _bli_array_iter_span(const void *arr,
if (arr_len == 0) {
return false;
}
- else if (use_wrap && (span_step[0] != arr_len) && (span_step[0] > span_step[1])) {
+ if (use_wrap && (span_step[0] != arr_len) && (span_step[0] > span_step[1])) {
return false;
}
diff --git a/source/blender/blenlib/intern/bitmap_draw_2d.c b/source/blender/blenlib/intern/bitmap_draw_2d.c
index 17debb38326..33250105c79 100644
--- a/source/blender/blenlib/intern/bitmap_draw_2d.c
+++ b/source/blender/blenlib/intern/bitmap_draw_2d.c
@@ -316,27 +316,25 @@ static int draw_poly_v2i_n__span_y_sort(const void *a_p, const void *b_p, void *
if (co_a[1] < co_b[1]) {
return -1;
}
- else if (co_a[1] > co_b[1]) {
+ if (co_a[1] > co_b[1]) {
return 1;
}
- else if (co_a[0] < co_b[0]) {
+ if (co_a[0] < co_b[0]) {
return -1;
}
- else if (co_a[0] > co_b[0]) {
+ if (co_a[0] > co_b[0]) {
return 1;
}
- else {
- /* co_a & co_b are identical, use the line closest to the x-min */
- const int *co = co_a;
- co_a = verts[a[1]];
- co_b = verts[b[1]];
- int ord = (((co_b[0] - co[0]) * (co_a[1] - co[1])) - ((co_a[0] - co[0]) * (co_b[1] - co[1])));
- if (ord > 0) {
- return -1;
- }
- if (ord < 0) {
- return 1;
- }
+ /* co_a & co_b are identical, use the line closest to the x-min */
+ const int *co = co_a;
+ co_a = verts[a[1]];
+ co_b = verts[b[1]];
+ int ord = (((co_b[0] - co[0]) * (co_a[1] - co[1])) - ((co_a[0] - co[0]) * (co_b[1] - co[1])));
+ if (ord > 0) {
+ return -1;
+ }
+ if (ord < 0) {
+ return 1;
}
return 0;
}
diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c
index 83866f766df..250a3fdf21b 100644
--- a/source/blender/blenlib/intern/boxpack_2d.c
+++ b/source/blender/blenlib/intern/boxpack_2d.c
@@ -216,7 +216,7 @@ static int box_areasort(const void *p1, const void *p2)
if (a1 < a2) {
return 1;
}
- else if (a1 > a2) {
+ if (a1 > a2) {
return -1;
}
return 0;
@@ -246,10 +246,10 @@ static int vertex_sort(const void *p1, const void *p2, void *vs_ctx_p)
if (UNLIKELY(v1->free == 0 && v2->free == 0)) {
return 0;
}
- else if (UNLIKELY(v1->free == 0)) {
+ if (UNLIKELY(v1->free == 0)) {
return 1;
}
- else if (UNLIKELY(v2->free == 0)) {
+ if (UNLIKELY(v2->free == 0)) {
return -1;
}
#endif
@@ -266,7 +266,7 @@ static int vertex_sort(const void *p1, const void *p2, void *vs_ctx_p)
if (a1 > a2) {
return 1;
}
- else if (a1 < a2) {
+ if (a1 < a2) {
return -1;
}
return 0;
@@ -309,8 +309,8 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
qsort(boxarray, (size_t)len, sizeof(BoxPack), box_areasort);
/* add verts to the boxes, these are only used internally */
- vert = MEM_mallocN((size_t)len * 4 * sizeof(BoxVert), "BoxPack Verts");
- vertex_pack_indices = MEM_mallocN((size_t)len * 3 * sizeof(int), "BoxPack Indices");
+ vert = MEM_mallocN(sizeof(BoxVert[4]) * (size_t)len, "BoxPack Verts");
+ vertex_pack_indices = MEM_mallocN(sizeof(int[3]) * (size_t)len, "BoxPack Indices");
vs_ctx.vertarray = vert;
diff --git a/source/blender/blenlib/intern/convexhull_2d.c b/source/blender/blenlib/intern/convexhull_2d.c
index b37dc73db29..6e4a8623077 100644
--- a/source/blender/blenlib/intern/convexhull_2d.c
+++ b/source/blender/blenlib/intern/convexhull_2d.c
@@ -115,9 +115,7 @@ int BLI_convexhull_2d_sorted(const float (*points)[2], const int n, int r_points
if (is_left(points[r_points[top - 1]], points[r_points[top]], points[i]) > 0.0f) {
break; /* points[i] is a new hull vertex */
}
- else {
- top--; /* pop top point off stack */
- }
+ top--; /* pop top point off stack */
}
r_points[++top] = i; /* push points[i] onto stack */
@@ -141,9 +139,7 @@ int BLI_convexhull_2d_sorted(const float (*points)[2], const int n, int r_points
if (is_left(points[r_points[top - 1]], points[r_points[top]], points[i]) > 0.0f) {
break; /* points[i] is a new hull vertex */
}
- else {
- top--; /* pop top point off stack */
- }
+ top--; /* pop top point off stack */
}
if (points[i][0] == points[r_points[0]][0] && points[i][1] == points[r_points[0]][1]) {
@@ -172,20 +168,17 @@ static int pointref_cmp_yx(const void *a_, const void *b_)
if (a->pt[1] > b->pt[1]) {
return 1;
}
- else if (a->pt[1] < b->pt[1]) {
+ if (a->pt[1] < b->pt[1]) {
return -1;
}
if (a->pt[0] > b->pt[0]) {
return 1;
}
- else if (a->pt[0] < b->pt[0]) {
+ if (a->pt[0] < b->pt[0]) {
return -1;
}
-
- else {
- return 0;
- }
+ return 0;
}
/**
diff --git a/source/blender/blenlib/intern/delaunay_2d.c b/source/blender/blenlib/intern/delaunay_2d.c
index 5f663dcb2e1..baf49ddaffd 100644
--- a/source/blender/blenlib/intern/delaunay_2d.c
+++ b/source/blender/blenlib/intern/delaunay_2d.c
@@ -600,19 +600,19 @@ static int site_lexicographic_cmp(const void *a, const void *b)
if (co1[0] < co2[0]) {
return -1;
}
- else if (co1[0] > co2[0]) {
+ if (co1[0] > co2[0]) {
return 1;
}
- else if (co1[1] < co2[1]) {
+ if (co1[1] < co2[1]) {
return -1;
}
- else if (co1[1] > co2[1]) {
+ if (co1[1] > co2[1]) {
return 1;
}
- else if (s1->orig_index < s2->orig_index) {
+ if (s1->orig_index < s2->orig_index) {
return -1;
}
- else if (s1->orig_index > s2->orig_index) {
+ if (s1->orig_index > s2->orig_index) {
return 1;
}
return 0;
@@ -974,7 +974,7 @@ static void initial_triangulation(CDT_state *cdt)
if (jco[0] > xend) {
break; /* No more j's to process. */
}
- else if (jco[1] > yend) {
+ if (jco[1] > yend) {
/* Get past any string of v's with the same x and too-big y. */
xcur = jco[0];
while (++j < n) {
@@ -1414,7 +1414,7 @@ static bool get_next_crossing_from_vert(CDT_state *cdt,
ok = true;
break;
}
- else if (t->face != cdt->outer_face) {
+ if (t->face != cdt->outer_face) {
orient2 = orient2d(vcur->co, vb->co, v2->co);
#ifdef DEBUG_CDT
if (dbg_level > 1) {
@@ -1683,14 +1683,12 @@ static void add_edge_constraint(
(cd_prev->lambda != 0.0 && cd_prev->in->vert != v && cd_prev->in->next->vert != v)) {
break;
}
- else {
- cd_prev->lambda = -1.0; /* Mark cd_prev as 'deleted'. */
+ cd_prev->lambda = -1.0; /* Mark cd_prev as 'deleted'. */
#ifdef DEBUG_CDT
- if (dbg_level > 0) {
- fprintf(stderr, "deleted crossing %d\n", j);
- }
-#endif
+ if (dbg_level > 0) {
+ fprintf(stderr, "deleted crossing %d\n", j);
}
+#endif
}
if (j < i - 1) {
/* Some crossings were deleted. Fix the in and out edges across gap. */
@@ -2002,19 +2000,19 @@ static int evl_cmp(const void *a, const void *b)
if (area->e_id < sb->e_id) {
return -1;
}
- else if (area->e_id > sb->e_id) {
+ if (area->e_id > sb->e_id) {
return 1;
}
- else if (area->lambda < sb->lambda) {
+ if (area->lambda < sb->lambda) {
return -1;
}
- else if (area->lambda > sb->lambda) {
+ if (area->lambda > sb->lambda) {
return 1;
}
- else if (area->v_id < sb->v_id) {
+ if (area->v_id < sb->v_id) {
return -1;
}
- else if (area->v_id > sb->v_id) {
+ if (area->v_id > sb->v_id) {
return 1;
}
return 0;
@@ -2236,16 +2234,15 @@ static const CDT_input *modify_input_for_near_edge_ends(const CDT_input *input,
new_input->epsilon = input->epsilon;
new_input->verts_len = input->verts_len;
new_input->vert_coords = (float(*)[2])MEM_malloc_arrayN(
- new_input->verts_len, 2 * sizeof(float), __func__);
+ new_input->verts_len, sizeof(float[2]), __func__);
/* We don't do it now, but may decide to change coords of snapped verts. */
memmove(new_input->vert_coords,
input->vert_coords,
- (size_t)new_input->verts_len * sizeof(float) * 2);
+ sizeof(float[2]) * (size_t)new_input->verts_len);
if (edges_len > 0) {
new_input->edges_len = new_tot_con_edges;
- new_input->edges = (int(*)[2])MEM_malloc_arrayN(
- new_tot_con_edges, 2 * sizeof(int), __func__);
+ new_input->edges = (int(*)[2])MEM_malloc_arrayN(new_tot_con_edges, sizeof(int[2]), __func__);
}
if (input->faces_len > 0) {
@@ -2386,9 +2383,7 @@ static const CDT_input *modify_input_for_near_edge_ends(const CDT_input *input,
if (new_input != NULL) {
return (const CDT_input *)new_input;
}
- else {
- return input;
- }
+ return input;
}
static void free_modified_input(CDT_input *input)
@@ -2745,7 +2740,7 @@ static int edge_to_sort_cmp(const void *a, const void *b)
if (e1->len_squared > e2->len_squared) {
return -1;
}
- else if (e1->len_squared < e2->len_squared) {
+ if (e1->len_squared < e2->len_squared) {
return 1;
}
return 0;
@@ -4570,17 +4565,13 @@ static double orient2d(const double *pa, const double *pb, const double *pc)
if (detright <= 0.0) {
return det;
}
- else {
- detsum = detleft + detright;
- }
+ detsum = detleft + detright;
}
else if (detleft < 0.0) {
if (detright >= 0.0) {
return det;
}
- else {
- detsum = -detleft - detright;
- }
+ detsum = -detleft - detright;
}
else {
return det;
@@ -4609,8 +4600,13 @@ static double orient2d(const double *pa, const double *pb, const double *pc)
* returned value has the correct sign. Hence, incircle() is usually quite
* fast, but will run more slowly when the input points are cocircular or
* nearly so.
- */
-
+ *
+ * This function is allowed to be long for two reasons. Firstly, it was taken
+ * from an external source and only slightly adapted, and keeping its original
+ * form will make integration of upstream changes easier. Secondly, it is very
+ * sensitive to floating point errors, and refactoring may break it in subtle
+ * and hard to detect ways.
+ * NOLINTNEXTLINE: readability-function-size */
static double incircleadapt(
const double *pa, const double *pb, const double *pc, const double *pd, double permanent)
{
diff --git a/source/blender/blenlib/intern/dot_export.cc b/source/blender/blenlib/intern/dot_export.cc
index 48b6dc826d0..9ffb1895d04 100644
--- a/source/blender/blenlib/intern/dot_export.cc
+++ b/source/blender/blenlib/intern/dot_export.cc
@@ -28,7 +28,7 @@ Node &Graph::new_node(StringRef label)
Node *node = new Node(*this);
nodes_.append(std::unique_ptr<Node>(node));
top_level_nodes_.add_new(node);
- node->set_attribute("label", label);
+ node->attributes.set("label", label);
return *node;
}
@@ -37,7 +37,7 @@ Cluster &Graph::new_cluster(StringRef label)
Cluster *cluster = new Cluster(*this);
clusters_.append(std::unique_ptr<Cluster>(cluster));
top_level_clusters_.add_new(cluster);
- cluster->set_attribute("label", label);
+ cluster->attributes.set("label", label);
return *cluster;
}
@@ -60,7 +60,7 @@ void Cluster::set_parent_cluster(Cluster *new_parent)
if (parent_ == new_parent) {
return;
}
- else if (parent_ == nullptr) {
+ if (parent_ == nullptr) {
graph_.top_level_clusters_.remove(this);
new_parent->children_.add_new(this);
}
@@ -80,7 +80,7 @@ void Node::set_parent_cluster(Cluster *cluster)
if (cluster_ == cluster) {
return;
}
- else if (cluster_ == nullptr) {
+ if (cluster_ == nullptr) {
graph_.top_level_nodes_.remove(this);
cluster->nodes_.add_new(this);
}
@@ -110,13 +110,25 @@ void Cluster::set_random_cluster_bgcolors()
float hue = rand() / (float)RAND_MAX;
float staturation = 0.3f;
float value = 0.8f;
- this->set_attribute("bgcolor", color_attr_from_hsv(hue, staturation, value));
+ this->attributes.set("bgcolor", color_attr_from_hsv(hue, staturation, value));
for (Cluster *cluster : children_) {
cluster->set_random_cluster_bgcolors();
}
}
+bool Cluster::contains(Node &node) const
+{
+ Cluster *current = node.parent_cluster();
+ while (current != nullptr) {
+ if (current == this) {
+ return true;
+ }
+ current = current->parent_;
+ }
+ return false;
+}
+
/* Dot Generation
**********************************************/
@@ -155,7 +167,7 @@ std::string UndirectedGraph::to_dot_string() const
void Graph::export__declare_nodes_and_clusters(std::stringstream &ss) const
{
ss << "graph ";
- attributes_.export__as_bracket_list(ss);
+ attributes.export__as_bracket_list(ss);
ss << "\n\n";
for (Node *node : top_level_nodes_) {
@@ -169,10 +181,10 @@ void Graph::export__declare_nodes_and_clusters(std::stringstream &ss) const
void Cluster::export__declare_nodes_and_clusters(std::stringstream &ss) const
{
- ss << "subgraph cluster_" << (uintptr_t)this << " {\n";
+ ss << "subgraph " << this->name() << " {\n";
ss << "graph ";
- attributes_.export__as_bracket_list(ss);
+ attributes.export__as_bracket_list(ss);
ss << "\n\n";
for (Node *node : nodes_) {
@@ -192,7 +204,7 @@ void DirectedEdge::export__as_edge_statement(std::stringstream &ss) const
ss << " -> ";
b_.to_dot_string(ss);
ss << " ";
- attributes_.export__as_bracket_list(ss);
+ attributes.export__as_bracket_list(ss);
}
void UndirectedEdge::export__as_edge_statement(std::stringstream &ss) const
@@ -201,10 +213,10 @@ void UndirectedEdge::export__as_edge_statement(std::stringstream &ss) const
ss << " -- ";
b_.to_dot_string(ss);
ss << " ";
- attributes_.export__as_bracket_list(ss);
+ attributes.export__as_bracket_list(ss);
}
-void AttributeList::export__as_bracket_list(std::stringstream &ss) const
+void Attributes::export__as_bracket_list(std::stringstream &ss) const
{
ss << "[";
attributes_.foreach_item([&](StringRef key, StringRef value) {
@@ -228,7 +240,7 @@ void Node::export__as_declaration(std::stringstream &ss) const
{
this->export__as_id(ss);
ss << " ";
- attributes_.export__as_bracket_list(ss);
+ attributes.export__as_bracket_list(ss);
ss << "\n";
}
@@ -296,7 +308,7 @@ NodeWithSocketsRef::NodeWithSocketsRef(Node &node,
ss << "</table>>";
- node_->set_attribute("label", ss.str());
+ node_->attributes.set("label", ss.str());
node_->set_shape(Attr_shape::Rectangle);
}
diff --git a/source/blender/blenlib/intern/easing.c b/source/blender/blenlib/intern/easing.c
index 9532f78bd44..07aafc1b57b 100644
--- a/source/blender/blenlib/intern/easing.c
+++ b/source/blender/blenlib/intern/easing.c
@@ -72,18 +72,16 @@ float BLI_easing_bounce_ease_out(float time, float begin, float change, float du
if (time < (1 / 2.75f)) {
return change * (7.5625f * time * time) + begin;
}
- else if (time < (2 / 2.75f)) {
+ if (time < (2 / 2.75f)) {
time -= (1.5f / 2.75f);
return change * ((7.5625f * time) * time + 0.75f) + begin;
}
- else if (time < (2.5f / 2.75f)) {
+ if (time < (2.5f / 2.75f)) {
time -= (2.25f / 2.75f);
return change * ((7.5625f * time) * time + 0.9375f) + begin;
}
- else {
- time -= (2.625f / 2.75f);
- return change * ((7.5625f * time) * time + 0.984375f) + begin;
- }
+ time -= (2.625f / 2.75f);
+ return change * ((7.5625f * time) * time + 0.984375f) + begin;
}
float BLI_easing_bounce_ease_in(float time, float begin, float change, float duration)
@@ -96,10 +94,8 @@ float BLI_easing_bounce_ease_in_out(float time, float begin, float change, float
if (time < duration / 2) {
return BLI_easing_bounce_ease_in(time * 2, 0, change, duration) * 0.5f + begin;
}
- else {
- return BLI_easing_bounce_ease_out(time * 2 - duration, 0, change, duration) * 0.5f +
- change * 0.5f + begin;
- }
+ return BLI_easing_bounce_ease_out(time * 2 - duration, 0, change, duration) * 0.5f +
+ change * 0.5f + begin;
}
float BLI_easing_circ_ease_in(float time, float begin, float change, float duration)
@@ -271,13 +267,12 @@ float BLI_easing_elastic_ease_in_out(
sinf((time * duration - s) * (2 * (float)M_PI) / period))) +
begin;
}
- else {
- time = -time;
- f *= 0.5f;
- return (f * (amplitude * powf(2, 10 * time) *
- sinf((time * duration - s) * (2 * (float)M_PI) / period))) +
- change + begin;
- }
+
+ time = -time;
+ f *= 0.5f;
+ return (f * (amplitude * powf(2, 10 * time) *
+ sinf((time * duration - s) * (2 * (float)M_PI) / period))) +
+ change + begin;
}
static const float pow_min = 0.0009765625f; /* = 2^(-10) */
@@ -306,10 +301,8 @@ float BLI_easing_expo_ease_in_out(float time, float begin, float change, float d
if (time <= duration_half) {
return BLI_easing_expo_ease_in(time, begin, change_half, duration_half);
}
- else {
- return BLI_easing_expo_ease_out(
- time - duration_half, begin + change_half, change_half, duration_half);
- }
+ return BLI_easing_expo_ease_out(
+ time - duration_half, begin + change_half, change_half, duration_half);
}
float BLI_easing_linear_ease(float time, float begin, float change, float duration)
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index 56529581dd3..05ee02ad869 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -185,7 +185,7 @@ BLI_INLINE EdgeHashEntry *edgehash_insert(EdgeHash *eh, Edge edge, void *value)
if (index == SLOT_EMPTY) {
return edgehash_insert_at_slot(eh, slot, edge, value);
}
- else if (index == SLOT_DUMMY) {
+ if (index == SLOT_DUMMY) {
eh->dummy_count--;
return edgehash_insert_at_slot(eh, slot, edge, value);
}
@@ -200,7 +200,7 @@ BLI_INLINE EdgeHashEntry *edgehash_lookup_entry(EdgeHash *eh, uint v0, uint v1)
if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
return &eh->entries[index];
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
return NULL;
}
}
@@ -294,7 +294,7 @@ bool BLI_edgehash_reinsert(EdgeHash *eh, uint v0, uint v1, void *value)
eh->entries[index].value = value;
return false;
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
if (edgehash_ensure_can_insert(eh)) {
edgehash_insert(eh, edge, value);
}
@@ -360,7 +360,7 @@ bool BLI_edgehash_ensure_p(EdgeHash *eh, uint v0, uint v1, void ***r_value)
*r_value = &eh->entries[index].value;
return true;
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
if (edgehash_ensure_can_insert(eh)) {
*r_value = &edgehash_insert(eh, edge, NULL)->value;
}
@@ -413,7 +413,7 @@ void *BLI_edgehash_popkey(EdgeHash *eh, uint v0, uint v1)
}
return value;
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
return NULL;
}
}
@@ -583,7 +583,7 @@ bool BLI_edgeset_add(EdgeSet *es, uint v0, uint v1)
if (ES_INDEX_HAS_EDGE(es, index, edge)) {
return false;
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
edgeset_insert_at_slot(es, slot, edge);
return true;
}
@@ -615,7 +615,7 @@ bool BLI_edgeset_haskey(EdgeSet *es, uint v0, uint v1)
if (ES_INDEX_HAS_EDGE(es, index, edge)) {
return true;
}
- else if (index == SLOT_EMPTY) {
+ if (index == SLOT_EMPTY) {
return false;
}
}
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index e61cbd318fc..014c5217896 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -950,8 +950,8 @@ static int delete_soft(const char *file, const char **error_message)
char *xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP");
char *xdg_session_desktop = getenv("XDG_SESSION_DESKTOP");
- if ((xdg_current_desktop != NULL && strcmp(xdg_current_desktop, "KDE") == 0) ||
- (xdg_session_desktop != NULL && strcmp(xdg_session_desktop, "KDE") == 0)) {
+ if ((xdg_current_desktop != NULL && STREQ(xdg_current_desktop, "KDE")) ||
+ (xdg_session_desktop != NULL && STREQ(xdg_session_desktop, "KDE"))) {
args[0] = "kioclient5";
args[1] = "move";
args[2] = file;
@@ -980,7 +980,7 @@ static int delete_soft(const char *file, const char **error_message)
"Blender may not support moving files or directories to trash on your system.";
return -1;
}
- else if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus)) {
+ if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus)) {
*error_message = process_failed;
return -1;
}
@@ -1036,12 +1036,10 @@ int BLI_delete(const char *file, bool dir, bool recursive)
if (recursive) {
return recursive_operation(file, NULL, NULL, delete_single_file, delete_callback_post);
}
- else if (dir) {
+ if (dir) {
return rmdir(file);
}
- else {
- return remove(file);
- }
+ return remove(file);
}
/**
@@ -1184,8 +1182,7 @@ static int copy_single_file(const char *from, const char *to)
return RecursiveOp_Callback_OK;
}
- else if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode) || S_ISFIFO(st.st_mode) ||
- S_ISSOCK(st.st_mode)) {
+ if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode) || S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) {
/* copy special type of file */
if (mknod(to, st.st_mode, st.st_rdev)) {
perror("mknod");
@@ -1198,7 +1195,7 @@ static int copy_single_file(const char *from, const char *to)
return RecursiveOp_Callback_OK;
}
- else if (!S_ISREG(st.st_mode)) {
+ if (!S_ISREG(st.st_mode)) {
fprintf(stderr, "Copying of this kind of files isn't supported yet\n");
return RecursiveOp_Callback_Error;
}
@@ -1337,7 +1334,7 @@ bool BLI_dir_create_recursive(const char *dirname)
if (BLI_is_dir(dirname)) {
return true;
}
- else if (BLI_exists(dirname)) {
+ if (BLI_exists(dirname)) {
return false;
}
diff --git a/source/blender/blenlib/intern/lasso_2d.c b/source/blender/blenlib/intern/lasso_2d.c
index a01adf4fa6a..a3b111cf0f2 100644
--- a/source/blender/blenlib/intern/lasso_2d.c
+++ b/source/blender/blenlib/intern/lasso_2d.c
@@ -60,10 +60,9 @@ bool BLI_lasso_is_point_inside(const int mcoords[][2],
if (sx == error_value || mcoords_len == 0) {
return false;
}
- else {
- int pt[2] = {sx, sy};
- return isect_point_poly_v2_int(pt, mcoords, mcoords_len, true);
- }
+
+ const int pt[2] = {sx, sy};
+ return isect_point_poly_v2_int(pt, mcoords, mcoords_len, true);
}
/* edge version for lasso select. we assume boundbox check was done */
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index 892eca768b3..5e88f8f3e44 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -162,9 +162,8 @@ bool BLI_remlink_safe(ListBase *listbase, void *vlink)
BLI_remlink(listbase, vlink);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/**
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 651a062e3d5..09bb7ea5711 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -439,9 +439,8 @@ float srgb_to_linearrgb(float c)
if (c < 0.04045f) {
return (c < 0.0f) ? 0.0f : c * (1.0f / 12.92f);
}
- else {
- return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f);
- }
+
+ return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f);
}
float linearrgb_to_srgb(float c)
@@ -449,9 +448,8 @@ float linearrgb_to_srgb(float c)
if (c < 0.0031308f) {
return (c < 0.0f) ? 0.0f : c * 12.92f;
}
- else {
- return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f;
- }
+
+ return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f;
}
void minmax_rgb(short c[3])
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 937bf8b1ae6..1afcf83bf73 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -231,9 +231,8 @@ float cotangent_tri_weight_v3(const float v1[3], const float v2[3], const float
if (c_len > FLT_EPSILON) {
return dot_v3v3(a, b) / c_len;
}
- else {
- return 0.0f;
- }
+
+ return 0.0f;
}
/********************************* Planes **********************************/
@@ -589,9 +588,8 @@ float dist_signed_squared_to_corner_v3v3v3(const float p[3],
if (flip) {
return min_ff(dist_a, dist_b);
}
- else {
- return max_ff(dist_a, dist_b);
- }
+
+ return max_ff(dist_a, dist_b);
}
/**
@@ -1146,9 +1144,8 @@ int isect_line_line_v2_point(
return ISECT_LINE_LINE_CROSS;
}
- else {
- return ISECT_LINE_LINE_COLINEAR;
- }
+
+ return ISECT_LINE_LINE_COLINEAR;
}
/* intersect Line-Line, floats */
@@ -1304,55 +1301,54 @@ int isect_seg_seg_v2_point_ex(const float v0[2],
/* out of segment intersection */
return -1;
}
- else {
- if ((cross_v2v2(s10, s30) == 0.0f) && (cross_v2v2(s32, s30) == 0.0f)) {
- /* equal lines */
- float s20[2];
- float u_a, u_b;
-
- if (equals_v2v2(v0, v1)) {
- if (len_squared_v2v2(v2, v3) > square_f(eps)) {
- /* use non-point segment as basis */
- SWAP(const float *, v0, v2);
- SWAP(const float *, v1, v3);
-
- sub_v2_v2v2(s10, v1, v0);
- sub_v2_v2v2(s30, v3, v0);
- }
- else { /* both of segments are points */
- if (equals_v2v2(v0, v2)) { /* points are equal */
- copy_v2_v2(r_vi, v0);
- return 1;
- }
- /* two different points */
- return -1;
- }
- }
+ if ((cross_v2v2(s10, s30) == 0.0f) && (cross_v2v2(s32, s30) == 0.0f)) {
+ /* equal lines */
+ float s20[2];
+ float u_a, u_b;
- sub_v2_v2v2(s20, v2, v0);
+ if (equals_v2v2(v0, v1)) {
+ if (len_squared_v2v2(v2, v3) > square_f(eps)) {
+ /* use non-point segment as basis */
+ SWAP(const float *, v0, v2);
+ SWAP(const float *, v1, v3);
- u_a = dot_v2v2(s20, s10) / dot_v2v2(s10, s10);
- u_b = dot_v2v2(s30, s10) / dot_v2v2(s10, s10);
-
- if (u_a > u_b) {
- SWAP(float, u_a, u_b);
+ sub_v2_v2v2(s10, v1, v0);
+ sub_v2_v2v2(s30, v3, v0);
}
+ else { /* both of segments are points */
+ if (equals_v2v2(v0, v2)) { /* points are equal */
+ copy_v2_v2(r_vi, v0);
+ return 1;
+ }
- if (u_a > endpoint_max || u_b < endpoint_min) {
- /* non-overlapping segments */
+ /* two different points */
return -1;
}
- else if (max_ff(0.0f, u_a) == min_ff(1.0f, u_b)) {
- /* one common point: can return result */
- madd_v2_v2v2fl(r_vi, v0, s10, max_ff(0, u_a));
- return 1;
- }
}
- /* lines are collinear */
- return -1;
+ sub_v2_v2v2(s20, v2, v0);
+
+ u_a = dot_v2v2(s20, s10) / dot_v2v2(s10, s10);
+ u_b = dot_v2v2(s30, s10) / dot_v2v2(s10, s10);
+
+ if (u_a > u_b) {
+ SWAP(float, u_a, u_b);
+ }
+
+ if (u_a > endpoint_max || u_b < endpoint_min) {
+ /* non-overlapping segments */
+ return -1;
+ }
+ if (max_ff(0.0f, u_a) == min_ff(1.0f, u_b)) {
+ /* one common point: can return result */
+ madd_v2_v2v2fl(r_vi, v0, s10, max_ff(0, u_a));
+ return 1;
+ }
}
+
+ /* lines are collinear */
+ return -1;
}
int isect_seg_seg_v2_point(
@@ -1472,13 +1468,13 @@ int isect_line_sphere_v3(const float l1[3],
/* no intersections */
return 0;
}
- else if (i == 0.0f) {
+ if (i == 0.0f) {
/* one intersection */
mu = -b / (2.0f * a);
madd_v3_v3v3fl(r_p1, l1, ldir, mu);
return 1;
}
- else if (i > 0.0f) {
+ if (i > 0.0f) {
const float i_sqrt = sqrtf(i); /* avoid calc twice */
/* first intersection */
@@ -1490,10 +1486,9 @@ int isect_line_sphere_v3(const float l1[3],
madd_v3_v3v3fl(r_p2, l1, ldir, mu);
return 2;
}
- else {
- /* math domain error - nan */
- return -1;
- }
+
+ /* math domain error - nan */
+ return -1;
}
/* keep in sync with isect_line_sphere_v3 */
@@ -1520,13 +1515,13 @@ int isect_line_sphere_v2(const float l1[2],
/* no intersections */
return 0;
}
- else if (i == 0.0f) {
+ if (i == 0.0f) {
/* one intersection */
mu = -b / (2.0f * a);
madd_v2_v2v2fl(r_p1, l1, ldir, mu);
return 1;
}
- else if (i > 0.0f) {
+ if (i > 0.0f) {
const float i_sqrt = sqrtf(i); /* avoid calc twice */
/* first intersection */
@@ -1538,10 +1533,9 @@ int isect_line_sphere_v2(const float l1[2],
madd_v2_v2v2fl(r_p2, l1, ldir, mu);
return 2;
}
- else {
- /* math domain error - nan */
- return -1;
- }
+
+ /* math domain error - nan */
+ return -1;
}
/* point in polygon (keep float and int versions in sync) */
@@ -1957,34 +1951,32 @@ bool isect_ray_tri_watertight_v3(const float ray_origin[3],
if (UNLIKELY(det == 0.0f || !isfinite(det))) {
return false;
}
- else {
- /* Calculate scaled z-coordinates of vertices and use them to calculate
- * the hit distance.
- */
- const int sign_det = (float_as_int(det) & (int)0x80000000);
- const float t = (u * a_kz + v * b_kz + w * c_kz) * sz;
- const float sign_t = xor_fl(t, sign_det);
- if ((sign_t < 0.0f)
- /* Differ from Cycles, don't read r_lambda's original value
- * otherwise we won't match any of the other intersect functions here...
- * which would be confusing. */
+
+ /* Calculate scaled z-coordinates of vertices and use them to calculate
+ * the hit distance.
+ */
+ const int sign_det = (float_as_int(det) & (int)0x80000000);
+ const float t = (u * a_kz + v * b_kz + w * c_kz) * sz;
+ const float sign_t = xor_fl(t, sign_det);
+ if ((sign_t < 0.0f)
+ /* Differ from Cycles, don't read r_lambda's original value
+ * otherwise we won't match any of the other intersect functions here...
+ * which would be confusing. */
#if 0
|| (sign_T > *r_lambda * xor_signmask(det, sign_mask))
#endif
- ) {
- return false;
- }
- else {
- /* Normalize u, v and t. */
- const float inv_det = 1.0f / det;
- if (r_uv) {
- r_uv[0] = u * inv_det;
- r_uv[1] = v * inv_det;
- }
- *r_lambda = t * inv_det;
- return true;
- }
+ ) {
+ return false;
}
+
+ /* Normalize u, v and t. */
+ const float inv_det = 1.0f / det;
+ if (r_uv) {
+ r_uv[0] = u * inv_det;
+ r_uv[1] = v * inv_det;
+ }
+ *r_lambda = t * inv_det;
+ return true;
}
bool isect_ray_tri_watertight_v3_simple(const float ray_origin[3],
@@ -2102,7 +2094,7 @@ bool isect_ray_seg_v2(const float ray_origin[2],
det = cross_v2v2(ray_direction, s10);
if (det != 0.0f) {
const float v = cross_v2v2(v0_local, v1_local);
- float p[2] = {(ray_direction[0] * v) / det, (ray_direction[1] * v) / det};
+ const float p[2] = {(ray_direction[0] * v) / det, (ray_direction[1] * v) / det};
const float t = (dot_v2v2(p, ray_direction) / dot_v2v2(ray_direction, ray_direction));
if ((t >= 0.0f) == 0) {
@@ -2215,10 +2207,9 @@ bool isect_line_plane_v3(float r_isect_co[3],
madd_v3_v3v3fl(r_isect_co, l1, u, lambda);
return true;
}
- else {
- /* The segment is parallel to plane */
- return false;
- }
+
+ /* The segment is parallel to plane */
+ return false;
}
/**
@@ -2257,9 +2248,8 @@ bool isect_plane_plane_plane_v3(const float plane_a[4],
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/**
@@ -2303,117 +2293,178 @@ bool isect_plane_plane_v3(const float plane_a[4],
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/**
* Intersect two triangles.
*
- * \param r_i1, r_i2: Optional arguments to retrieve the overlapping edge between the 2 triangles.
+ * \param r_i1, r_i2: Retrieve the overlapping edge between the 2 triangles.
+ * \param r_tri_a_edge_isect_count: Indicates how many edges in the first triangle are intersected.
* \return true when the triangles intersect.
*
+ * \note If it exists, \a r_i1 will be a point on the edge of the 1st triangle.
* \note intersections between coplanar triangles are currently undetected.
*/
-bool isect_tri_tri_epsilon_v3(const float t_a0[3],
- const float t_a1[3],
- const float t_a2[3],
- const float t_b0[3],
- const float t_b1[3],
- const float t_b2[3],
- float r_i1[3],
- float r_i2[3],
- const float epsilon)
-{
- const float *tri_pair[2][3] = {{t_a0, t_a1, t_a2}, {t_b0, t_b1, t_b2}};
- float plane_a[4], plane_b[4];
- float plane_co[3], plane_no[3];
-
- BLI_assert((r_i1 != NULL) == (r_i2 != NULL));
-
- /* normalizing is needed for small triangles T46007 */
- normal_tri_v3(plane_a, UNPACK3(tri_pair[0]));
- normal_tri_v3(plane_b, UNPACK3(tri_pair[1]));
-
- plane_a[3] = -dot_v3v3(plane_a, t_a0);
- plane_b[3] = -dot_v3v3(plane_b, t_b0);
-
- if (isect_plane_plane_v3(plane_a, plane_b, plane_co, plane_no) &&
- (normalize_v3(plane_no) > epsilon)) {
- /**
- * Implementation note: its simpler to project the triangles onto the intersection plane
- * before intersecting their edges with the ray, defined by 'isect_plane_plane_v3'.
- * This way we can use 'line_point_factor_v3_ex' to see if an edge crosses 'co_proj',
- * then use the factor to calculate the world-space point.
- */
- struct {
- float min, max;
- } range[2] = {{FLT_MAX, -FLT_MAX}, {FLT_MAX, -FLT_MAX}};
- int t;
- float co_proj[3];
-
- closest_to_plane3_normalized_v3(co_proj, plane_no, plane_co);
-
- /* For both triangles, find the overlap with the line defined by the ray [co_proj, plane_no].
- * When the ranges overlap we know the triangles do too. */
- for (t = 0; t < 2; t++) {
- int j, j_prev;
- float tri_proj[3][3];
-
- closest_to_plane3_normalized_v3(tri_proj[0], plane_no, tri_pair[t][0]);
- closest_to_plane3_normalized_v3(tri_proj[1], plane_no, tri_pair[t][1]);
- closest_to_plane3_normalized_v3(tri_proj[2], plane_no, tri_pair[t][2]);
-
- for (j = 0, j_prev = 2; j < 3; j_prev = j++) {
- /* note that its important to have a very small nonzero epsilon here
- * otherwise this fails for very small faces.
- * However if its too small, large adjacent faces will count as intersecting */
- const float edge_fac = line_point_factor_v3_ex(
- co_proj, tri_proj[j_prev], tri_proj[j], 1e-10f, -1.0f);
- /* ignore collinear lines, they are either an edge shared between 2 tri's
- * (which runs along [co_proj, plane_no], but can be safely ignored).
- *
- * or a collinear edge placed away from the ray -
- * which we don't intersect with & can ignore. */
- if (UNLIKELY(edge_fac == -1.0f)) {
- /* pass */
- }
- /* Important to include 0.0f and 1.0f as one of the triangles vertices may be placed
- * exactly on the plane. In this case both it's edges will have a factor of 0 or 1,
- * but not be going through the plane. See T73566. */
- else if (edge_fac >= 0.0f && edge_fac <= 1.0f) {
- float ix_tri[3];
- float span_fac;
-
- interp_v3_v3v3(ix_tri, tri_pair[t][j_prev], tri_pair[t][j], edge_fac);
- /* the actual distance, since 'plane_no' is normalized */
- span_fac = dot_v3v3(plane_no, ix_tri);
-
- range[t].min = min_ff(range[t].min, span_fac);
- range[t].max = max_ff(range[t].max, span_fac);
- }
- }
+bool isect_tri_tri_v3_ex(const float tri_a[3][3],
+ const float tri_b[3][3],
+ float r_i1[3],
+ float r_i2[3],
+ int *r_tri_a_edge_isect_count)
+{
+ struct {
+ /* Factor that indicates the position of the intersection point on the line
+ * that intersects the planes of the triangles. */
+ float min, max;
+ /* Intersection point location. */
+ float loc[2][3];
+ } range[2];
+
+ float side[2][3];
+ float ba[3], bc[3], plane_a[4], plane_b[4];
+ *r_tri_a_edge_isect_count = 0;
+
+ sub_v3_v3v3(ba, tri_a[0], tri_a[1]);
+ sub_v3_v3v3(bc, tri_a[2], tri_a[1]);
+ cross_v3_v3v3(plane_a, ba, bc);
+ plane_a[3] = -dot_v3v3(tri_a[1], plane_a);
+ side[1][0] = plane_point_side_v3(plane_a, tri_b[0]);
+ side[1][1] = plane_point_side_v3(plane_a, tri_b[1]);
+ side[1][2] = plane_point_side_v3(plane_a, tri_b[2]);
+
+ if (!side[1][0] && !side[1][1] && !side[1][2]) {
+ /* Coplanar case is not supported. */
+ return false;
+ }
- if (range[t].min == FLT_MAX) {
- return false;
+ if ((side[1][0] && side[1][1] && side[1][2]) && (side[1][0] < 0.0f) == (side[1][1] < 0.0f) &&
+ (side[1][0] < 0.0f) == (side[1][2] < 0.0f)) {
+ /* All vertices of the 2nd triangle are positioned on the same side to the
+ * plane defined by the 1st triangle. */
+ return false;
+ }
+
+ sub_v3_v3v3(ba, tri_b[0], tri_b[1]);
+ sub_v3_v3v3(bc, tri_b[2], tri_b[1]);
+ cross_v3_v3v3(plane_b, ba, bc);
+ plane_b[3] = -dot_v3v3(tri_b[1], plane_b);
+ side[0][0] = plane_point_side_v3(plane_b, tri_a[0]);
+ side[0][1] = plane_point_side_v3(plane_b, tri_a[1]);
+ side[0][2] = plane_point_side_v3(plane_b, tri_a[2]);
+ if ((side[0][0] && side[0][1] && side[0][2]) && (side[0][0] < 0.0f) == (side[0][1] < 0.0f) &&
+ (side[0][0] < 0.0f) == (side[0][2] < 0.0f)) {
+ /* All vertices of the 1st triangle are positioned on the same side to the
+ * plane defined by the 2nd triangle. */
+ return false;
+ }
+
+ /* Direction of the line that intersects the planes of the triangles. */
+ float isect_dir[3];
+ cross_v3_v3v3(isect_dir, plane_a, plane_b);
+ for (int i = 0; i < 2; i++) {
+ const float(*tri)[3] = i == 0 ? tri_a : tri_b;
+ /* Rearrange the triangle so that the vertex that is alone on one side
+ * of the plane is located at index 1. */
+ int tri_i[3];
+ if ((side[i][0] && side[i][1]) && (side[i][0] < 0.0f) == (side[i][1] < 0.0f)) {
+ tri_i[0] = 1;
+ tri_i[1] = 2;
+ tri_i[2] = 0;
+ }
+ else if ((side[i][1] && side[i][2]) && (side[i][1] < 0.0f) == (side[i][2] < 0.0f)) {
+ tri_i[0] = 2;
+ tri_i[1] = 0;
+ tri_i[2] = 1;
+ }
+ else {
+ tri_i[0] = 0;
+ tri_i[1] = 1;
+ tri_i[2] = 2;
+ }
+
+ float dot_b = dot_v3v3(isect_dir, tri[tri_i[1]]);
+ range[i].min = dot_b;
+ range[i].max = dot_b;
+
+ float sidec = side[i][tri_i[1]];
+ if (sidec) {
+ float dot_a = dot_v3v3(isect_dir, tri[tri_i[0]]);
+ float dot_c = dot_v3v3(isect_dir, tri[tri_i[2]]);
+ float fac0 = sidec / (sidec - side[i][tri_i[0]]);
+ float fac1 = sidec / (sidec - side[i][tri_i[2]]);
+ float offset0 = fac0 * (dot_a - dot_b);
+ float offset1 = fac1 * (dot_c - dot_b);
+ if (offset0 > offset1) {
+ /* Sort min max. */
+ SWAP(float, offset0, offset1);
+ SWAP(float, fac0, fac1);
+ SWAP(int, tri_i[0], tri_i[2]);
}
+
+ range[i].min += offset0;
+ range[i].max += offset1;
+ interp_v3_v3v3(range[i].loc[0], tri[tri_i[1]], tri[tri_i[0]], fac0);
+ interp_v3_v3v3(range[i].loc[1], tri[tri_i[1]], tri[tri_i[2]], fac1);
+ }
+ else {
+ copy_v3_v3(range[i].loc[0], tri[tri_i[1]]);
+ copy_v3_v3(range[i].loc[1], tri[tri_i[1]]);
}
+ }
- if (((range[0].min > range[1].max) || (range[0].max < range[1].min)) == 0) {
- if (r_i1 && r_i2) {
- project_plane_normalized_v3_v3v3(plane_co, plane_co, plane_no);
- madd_v3_v3v3fl(r_i1, plane_co, plane_no, max_ff(range[0].min, range[1].min));
- madd_v3_v3v3fl(r_i2, plane_co, plane_no, min_ff(range[0].max, range[1].max));
+ if ((range[0].max >= range[1].min) && (range[0].min <= range[1].max)) {
+ /* The triangles intersect because they overlap on the intersection line.
+ * Now identify the two points of intersection that are in the middle to get the actual
+ * intersection between the triangles. (B--C from A--B--C--D) */
+ if (range[0].min >= range[1].min) {
+ copy_v3_v3(r_i1, range[0].loc[0]);
+ if (range[0].max <= range[1].max) {
+ copy_v3_v3(r_i2, range[0].loc[1]);
+ *r_tri_a_edge_isect_count = 2;
+ }
+ else {
+ copy_v3_v3(r_i2, range[1].loc[1]);
+ *r_tri_a_edge_isect_count = 1;
+ }
+ }
+ else {
+ if (range[0].max <= range[1].max) {
+ copy_v3_v3(r_i1, range[0].loc[1]);
+ copy_v3_v3(r_i2, range[1].loc[0]);
+ *r_tri_a_edge_isect_count = 1;
+ }
+ else {
+ copy_v3_v3(r_i1, range[1].loc[0]);
+ copy_v3_v3(r_i2, range[1].loc[1]);
}
-
- return true;
}
+ return true;
}
return false;
}
+bool isect_tri_tri_v3(const float t_a0[3],
+ const float t_a1[3],
+ const float t_a2[3],
+ const float t_b0[3],
+ const float t_b1[3],
+ const float t_b2[3],
+ float r_i1[3],
+ float r_i2[3])
+{
+ float tri_a[3][3], tri_b[3][3];
+ int dummy;
+ copy_v3_v3(tri_a[0], t_a0);
+ copy_v3_v3(tri_a[1], t_a1);
+ copy_v3_v3(tri_a[2], t_a2);
+ copy_v3_v3(tri_b[0], t_b0);
+ copy_v3_v3(tri_b[1], t_b1);
+ copy_v3_v3(tri_b[2], t_b2);
+ return isect_tri_tri_v3_ex(tri_a, tri_b, r_i1, r_i2, &dummy);
+}
+
/* -------------------------------------------------------------------- */
/** \name Tri-Tri Intersect 2D
*
@@ -2436,65 +2487,54 @@ static bool isect_tri_tri_v2_impl_vert(const float t_a0[2],
if (line_point_side_v2(t_a0, t_b1, t_a1) <= 0.0f) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
- else {
- if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
- if (line_point_side_v2(t_a1, t_a2, t_b0) >= 0.0f) {
- return 1;
- }
- else {
- return 0;
- }
- }
- else {
- return 0;
+
+ if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
+ if (line_point_side_v2(t_a1, t_a2, t_b0) >= 0.0f) {
+ return 1;
}
+
+ return 0;
}
+
+ return 0;
}
- else if (line_point_side_v2(t_a0, t_b1, t_a1) <= 0.0f) {
+ if (line_point_side_v2(t_a0, t_b1, t_a1) <= 0.0f) {
if (line_point_side_v2(t_b2, t_b1, t_a2) <= 0.0f) {
if (line_point_side_v2(t_a1, t_a2, t_b1) >= 0.0f) {
return 1;
}
- else {
- return 0;
- }
- }
- else {
+
return 0;
}
- }
- else {
+
return 0;
}
+
+ return 0;
}
- else if (line_point_side_v2(t_b2, t_b0, t_a2) >= 0.0f) {
+ if (line_point_side_v2(t_b2, t_b0, t_a2) >= 0.0f) {
if (line_point_side_v2(t_a1, t_a2, t_b2) >= 0.0f) {
if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
- else if (line_point_side_v2(t_a1, t_a2, t_b1) >= 0.0f) {
+ if (line_point_side_v2(t_a1, t_a2, t_b1) >= 0.0f) {
if (line_point_side_v2(t_b2, t_a2, t_b1) >= 0.0f) {
return 1;
}
- else {
- return 0;
- }
- }
- else {
+
return 0;
}
- }
- else {
+
return 0;
}
+
+ return 0;
}
static bool isect_tri_tri_v2_impl_edge(const float t_a0[2],
@@ -2511,47 +2551,38 @@ static bool isect_tri_tri_v2_impl_edge(const float t_a0[2],
if (line_point_side_v2(t_a0, t_a1, t_b2) >= 0.0f) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
- else {
- if (line_point_side_v2(t_a1, t_a2, t_b0) >= 0.0f) {
- if (line_point_side_v2(t_a2, t_a0, t_b0) >= 0.0f) {
- return 1;
- }
- else {
- return 0;
- }
- }
- else {
- return 0;
+
+ if (line_point_side_v2(t_a1, t_a2, t_b0) >= 0.0f) {
+ if (line_point_side_v2(t_a2, t_a0, t_b0) >= 0.0f) {
+ return 1;
}
+
+ return 0;
}
+
+ return 0;
}
- else {
- if (line_point_side_v2(t_b2, t_b0, t_a2) >= 0.0f) {
- if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
- if (line_point_side_v2(t_a0, t_a2, t_b2) >= 0.0f) {
- return 1;
- }
- else {
- if (line_point_side_v2(t_a1, t_a2, t_b2) >= 0.0f) {
- return 1;
- }
- else {
- return 0;
- }
- }
+
+ if (line_point_side_v2(t_b2, t_b0, t_a2) >= 0.0f) {
+ if (line_point_side_v2(t_a0, t_b0, t_a2) >= 0.0f) {
+ if (line_point_side_v2(t_a0, t_a2, t_b2) >= 0.0f) {
+ return 1;
}
- else {
- return 0;
+
+ if (line_point_side_v2(t_a1, t_a2, t_b2) >= 0.0f) {
+ return 1;
}
- }
- else {
+
return 0;
}
+
+ return 0;
}
+
+ return 0;
}
static int isect_tri_tri_impl_ccw_v2(const float t_a0[2],
@@ -2566,32 +2597,26 @@ static int isect_tri_tri_impl_ccw_v2(const float t_a0[2],
if (line_point_side_v2(t_b2, t_b0, t_a0) >= 0.0f) {
return 1;
}
- else {
- return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
- }
+
+ return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
}
- else {
- if (line_point_side_v2(t_b2, t_b0, t_a0) >= 0.0f) {
- return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b2, t_b0, t_b1);
- }
- else {
- return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
- }
+
+ if (line_point_side_v2(t_b2, t_b0, t_a0) >= 0.0f) {
+ return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b2, t_b0, t_b1);
}
+
+ return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
}
- else {
- if (line_point_side_v2(t_b1, t_b2, t_a0) >= 0.0f) {
- if (line_point_side_v2(t_b2, t_b0, t_a0) >= 0.0f) {
- return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b1, t_b2, t_b0);
- }
- else {
- return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b1, t_b2, t_b0);
- }
- }
- else {
- return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b2, t_b0, t_b1);
+
+ if (line_point_side_v2(t_b1, t_b2, t_a0) >= 0.0f) {
+ if (line_point_side_v2(t_b2, t_b0, t_a0) >= 0.0f) {
+ return isect_tri_tri_v2_impl_edge(t_a0, t_a1, t_a2, t_b1, t_b2, t_b0);
}
+
+ return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b1, t_b2, t_b0);
}
+
+ return isect_tri_tri_v2_impl_vert(t_a0, t_a1, t_a2, t_b2, t_b0, t_b1);
}
bool isect_tri_tri_v2(const float t_a0[2],
@@ -2605,18 +2630,15 @@ bool isect_tri_tri_v2(const float t_a0[2],
if (line_point_side_v2(t_b0, t_b1, t_b2) < 0.0f) {
return isect_tri_tri_impl_ccw_v2(t_a0, t_a2, t_a1, t_b0, t_b2, t_b1);
}
- else {
- return isect_tri_tri_impl_ccw_v2(t_a0, t_a2, t_a1, t_b0, t_b1, t_b2);
- }
+
+ return isect_tri_tri_impl_ccw_v2(t_a0, t_a2, t_a1, t_b0, t_b1, t_b2);
}
- else {
- if (line_point_side_v2(t_b0, t_b1, t_b2) < 0.0f) {
- return isect_tri_tri_impl_ccw_v2(t_a0, t_a1, t_a2, t_b0, t_b2, t_b1);
- }
- else {
- return isect_tri_tri_impl_ccw_v2(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
- }
+
+ if (line_point_side_v2(t_b0, t_b1, t_b2) < 0.0f) {
+ return isect_tri_tri_impl_ccw_v2(t_a0, t_a1, t_a2, t_b0, t_b2, t_b1);
}
+
+ return isect_tri_tri_impl_ccw_v2(t_a0, t_a1, t_a2, t_b0, t_b1, t_b2);
}
/** \} */
@@ -2682,8 +2704,7 @@ int isect_aabb_planes_v3(const float (*planes)[4],
if (plane_point_side_v3(planes[i], bb_far) < 0.0f) {
return ISECT_AABB_PLANE_BEHIND_ANY;
}
- else if ((ret != ISECT_AABB_PLANE_CROSS_ANY) &&
- (plane_point_side_v3(planes[i], bb_near) < 0.0f)) {
+ if ((ret != ISECT_AABB_PLANE_CROSS_ANY) && (plane_point_side_v3(planes[i], bb_near) < 0.0f)) {
ret = ISECT_AABB_PLANE_CROSS_ANY;
}
}
@@ -2967,7 +2988,7 @@ int isect_line_line_epsilon_v3(const float v1[3],
return 0;
}
/* test if the two lines are coplanar */
- else if (UNLIKELY(fabsf(d) <= epsilon)) {
+ if (UNLIKELY(fabsf(d) <= epsilon)) {
cross_v3_v3v3(cb, c, b);
mul_v3_fl(a, dot_v3v3(cb, ab) / div);
@@ -2977,34 +2998,33 @@ int isect_line_line_epsilon_v3(const float v1[3],
return 1; /* one intersection only */
}
/* if not */
- else {
- float n[3], t[3];
- float v3t[3], v4t[3];
- sub_v3_v3v3(t, v1, v3);
- /* offset between both plane where the lines lies */
- cross_v3_v3v3(n, a, b);
- project_v3_v3v3(t, t, n);
+ float n[3], t[3];
+ float v3t[3], v4t[3];
+ sub_v3_v3v3(t, v1, v3);
- /* for the first line, offset the second line until it is coplanar */
- add_v3_v3v3(v3t, v3, t);
- add_v3_v3v3(v4t, v4, t);
+ /* offset between both plane where the lines lies */
+ cross_v3_v3v3(n, a, b);
+ project_v3_v3v3(t, t, n);
- sub_v3_v3v3(c, v3t, v1);
- sub_v3_v3v3(a, v2, v1);
- sub_v3_v3v3(b, v4t, v3t);
+ /* for the first line, offset the second line until it is coplanar */
+ add_v3_v3v3(v3t, v3, t);
+ add_v3_v3v3(v4t, v4, t);
- cross_v3_v3v3(ab, a, b);
- cross_v3_v3v3(cb, c, b);
+ sub_v3_v3v3(c, v3t, v1);
+ sub_v3_v3v3(a, v2, v1);
+ sub_v3_v3v3(b, v4t, v3t);
- mul_v3_fl(a, dot_v3v3(cb, ab) / dot_v3v3(ab, ab));
- add_v3_v3v3(r_i1, v1, a);
+ cross_v3_v3v3(ab, a, b);
+ cross_v3_v3v3(cb, c, b);
- /* for the second line, just substract the offset from the first intersection point */
- sub_v3_v3v3(r_i2, r_i1, t);
+ mul_v3_fl(a, dot_v3v3(cb, ab) / dot_v3v3(ab, ab));
+ add_v3_v3v3(r_i1, v1, a);
- return 2; /* two nearest points */
- }
+ /* for the second line, just subtract the offset from the first intersection point */
+ sub_v3_v3v3(r_i2, r_i1, t);
+
+ return 2; /* two nearest points */
}
int isect_line_line_v3(const float v1[3],
@@ -3047,31 +3067,29 @@ bool isect_line_line_strict_v3(const float v1[3],
return false;
}
/* test if the two lines are coplanar */
- else if (UNLIKELY(fabsf(d) < epsilon)) {
+ if (UNLIKELY(fabsf(d) < epsilon)) {
return false;
}
- else {
- float f1, f2;
- cross_v3_v3v3(cb, c, b);
- cross_v3_v3v3(ca, c, a);
- f1 = dot_v3v3(cb, ab) / div;
- f2 = dot_v3v3(ca, ab) / div;
+ float f1, f2;
+ cross_v3_v3v3(cb, c, b);
+ cross_v3_v3v3(ca, c, a);
- if (f1 >= 0 && f1 <= 1 && f2 >= 0 && f2 <= 1) {
- mul_v3_fl(a, f1);
- add_v3_v3v3(vi, v1, a);
+ f1 = dot_v3v3(cb, ab) / div;
+ f2 = dot_v3v3(ca, ab) / div;
- if (r_lambda) {
- *r_lambda = f1;
- }
+ if (f1 >= 0 && f1 <= 1 && f2 >= 0 && f2 <= 1) {
+ mul_v3_fl(a, f1);
+ add_v3_v3v3(vi, v1, a);
- return true; /* intersection found */
- }
- else {
- return false;
+ if (r_lambda) {
+ *r_lambda = f1;
}
+
+ return true; /* intersection found */
}
+
+ return false;
}
/**
@@ -3237,15 +3255,14 @@ bool isect_ray_aabb_v3_simple(const float orig[3],
if ((hit_dist[1] < 0.0f || hit_dist[0] > hit_dist[1])) {
return false;
}
- else {
- if (tmin) {
- *tmin = hit_dist[0];
- }
- if (tmax) {
- *tmax = hit_dist[1];
- }
- return true;
+
+ if (tmin) {
+ *tmin = hit_dist[0];
}
+ if (tmax) {
+ *tmax = hit_dist[1];
+ }
+ return true;
}
float closest_to_ray_v3(float r_close[3],
@@ -3463,7 +3480,7 @@ static bool point_in_slice(const float p[3],
/* adult sister defining the slice planes by the origin and the normal
* NOTE |normal| may not be 1 but defining the thickness of the slice */
-static bool point_in_slice_as(float p[3], float origin[3], float normal[3])
+static bool point_in_slice_as(const float p[3], const float origin[3], const float normal[3])
{
float h, rp[3];
sub_v3_v3v3(rp, p, origin);
@@ -3522,9 +3539,8 @@ bool isect_point_tri_v3(
return true;
}
- else {
- return false;
- }
+
+ return false;
}
bool clip_segment_v3_plane(
@@ -3547,7 +3563,7 @@ bool clip_segment_v3_plane(
if (t >= div) {
return false;
}
- else if (t > 0.0f) {
+ if (t > 0.0f) {
const float p1_copy[3] = {UNPACK3(p1)};
copy_v3_v3(r_p2, p2);
madd_v3_v3v3fl(r_p1, p1_copy, dp, t / div);
@@ -3559,7 +3575,7 @@ bool clip_segment_v3_plane(
if (t >= 0.0f) {
return false;
}
- else if (t > div) {
+ if (t > div) {
const float p1_copy[3] = {UNPACK3(p1)};
copy_v3_v3(r_p1, p1);
madd_v3_v3v3fl(r_p2, p1_copy, dp, t / div);
@@ -3598,7 +3614,7 @@ bool clip_segment_v3_plane_n(const float p1[3],
if (t >= div) {
return false;
}
- else if (t > 0.0f) {
+ if (t > 0.0f) {
t /= div;
if (t > p1_fac) {
p1_fac = t;
@@ -3613,7 +3629,7 @@ bool clip_segment_v3_plane_n(const float p1[3],
if (t >= 0.0f) {
return false;
}
- else if (t > div) {
+ if (t > div) {
t /= div;
if (t < p2_fac) {
p2_fac = t;
@@ -3797,8 +3813,8 @@ int barycentric_inside_triangle_v2(const float w[3])
if (IN_RANGE(w[0], 0.0f, 1.0f) && IN_RANGE(w[1], 0.0f, 1.0f) && IN_RANGE(w[2], 0.0f, 1.0f)) {
return 1;
}
- else if (IN_RANGE_INCL(w[0], 0.0f, 1.0f) && IN_RANGE_INCL(w[1], 0.0f, 1.0f) &&
- IN_RANGE_INCL(w[2], 0.0f, 1.0f)) {
+ if (IN_RANGE_INCL(w[0], 0.0f, 1.0f) && IN_RANGE_INCL(w[1], 0.0f, 1.0f) &&
+ IN_RANGE_INCL(w[2], 0.0f, 1.0f)) {
return 2;
}
@@ -4095,68 +4111,67 @@ int interp_sparse_array(float *array, const int list_size, const float skipval)
if (found_valid == 0) {
return -1;
}
- else if (found_invalid == 0) {
+ if (found_invalid == 0) {
return 0;
}
- else {
- /* found invalid depths, interpolate */
- float valid_last = skipval;
- int valid_ofs = 0;
- float *array_up = MEM_callocN(sizeof(float) * (size_t)list_size, "interp_sparse_array up");
- float *array_down = MEM_callocN(sizeof(float) * (size_t)list_size, "interp_sparse_array up");
+ /* found invalid depths, interpolate */
+ float valid_last = skipval;
+ int valid_ofs = 0;
- int *ofs_tot_up = MEM_callocN(sizeof(int) * (size_t)list_size, "interp_sparse_array tup");
- int *ofs_tot_down = MEM_callocN(sizeof(int) * (size_t)list_size, "interp_sparse_array tdown");
+ float *array_up = MEM_callocN(sizeof(float) * (size_t)list_size, "interp_sparse_array up");
+ float *array_down = MEM_callocN(sizeof(float) * (size_t)list_size, "interp_sparse_array up");
- for (i = 0; i < list_size; i++) {
- if (array[i] == skipval) {
- array_up[i] = valid_last;
- ofs_tot_up[i] = ++valid_ofs;
- }
- else {
- valid_last = array[i];
- valid_ofs = 0;
- }
+ int *ofs_tot_up = MEM_callocN(sizeof(int) * (size_t)list_size, "interp_sparse_array tup");
+ int *ofs_tot_down = MEM_callocN(sizeof(int) * (size_t)list_size, "interp_sparse_array tdown");
+
+ for (i = 0; i < list_size; i++) {
+ if (array[i] == skipval) {
+ array_up[i] = valid_last;
+ ofs_tot_up[i] = ++valid_ofs;
}
+ else {
+ valid_last = array[i];
+ valid_ofs = 0;
+ }
+ }
- valid_last = skipval;
- valid_ofs = 0;
+ valid_last = skipval;
+ valid_ofs = 0;
- for (i = list_size - 1; i >= 0; i--) {
- if (array[i] == skipval) {
- array_down[i] = valid_last;
- ofs_tot_down[i] = ++valid_ofs;
- }
- else {
- valid_last = array[i];
- valid_ofs = 0;
- }
+ for (i = list_size - 1; i >= 0; i--) {
+ if (array[i] == skipval) {
+ array_down[i] = valid_last;
+ ofs_tot_down[i] = ++valid_ofs;
}
+ else {
+ valid_last = array[i];
+ valid_ofs = 0;
+ }
+ }
- /* now blend */
- for (i = 0; i < list_size; i++) {
- if (array[i] == skipval) {
- if (array_up[i] != skipval && array_down[i] != skipval) {
- array[i] = ((array_up[i] * (float)ofs_tot_down[i]) +
- (array_down[i] * (float)ofs_tot_up[i])) /
- (float)(ofs_tot_down[i] + ofs_tot_up[i]);
- }
- else if (array_up[i] != skipval) {
- array[i] = array_up[i];
- }
- else if (array_down[i] != skipval) {
- array[i] = array_down[i];
- }
+ /* now blend */
+ for (i = 0; i < list_size; i++) {
+ if (array[i] == skipval) {
+ if (array_up[i] != skipval && array_down[i] != skipval) {
+ array[i] = ((array_up[i] * (float)ofs_tot_down[i]) +
+ (array_down[i] * (float)ofs_tot_up[i])) /
+ (float)(ofs_tot_down[i] + ofs_tot_up[i]);
+ }
+ else if (array_up[i] != skipval) {
+ array[i] = array_up[i];
+ }
+ else if (array_down[i] != skipval) {
+ array[i] = array_down[i];
}
}
+ }
- MEM_freeN(array_up);
- MEM_freeN(array_down);
+ MEM_freeN(array_up);
+ MEM_freeN(array_down);
- MEM_freeN(ofs_tot_up);
- MEM_freeN(ofs_tot_down);
- }
+ MEM_freeN(ofs_tot_up);
+ MEM_freeN(ofs_tot_down);
return 1;
}
@@ -4279,7 +4294,7 @@ void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[
ix_flag = IS_POINT_IX;
break;
}
- else if (UNLIKELY(dist_squared_to_line_segment_v3(co, v_curr, v_next) < eps_sq)) {
+ if (UNLIKELY(dist_squared_to_line_segment_v3(co, v_curr, v_next) < eps_sq)) {
ix_flag = IS_SEGMENT_IX;
break;
}
@@ -4364,7 +4379,7 @@ void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[
ix_flag = IS_POINT_IX;
break;
}
- else if (UNLIKELY(dist_squared_to_line_segment_v2(co, v_curr, v_next) < eps_sq)) {
+ if (UNLIKELY(dist_squared_to_line_segment_v2(co, v_curr, v_next) < eps_sq)) {
ix_flag = IS_SEGMENT_IX;
break;
}
@@ -4647,17 +4662,15 @@ float resolve_quad_u_v2(const float st[2],
if (IS_ZERO(fDen) == 0) {
return (float)(a / fDen);
}
- else {
- return 0.0f;
- }
- }
- else {
- const double desc_sq = b * b - a * fC;
- const double desc = sqrt(desc_sq < 0.0 ? 0.0 : desc_sq);
- const double s = signed_area > 0 ? (-1.0) : 1.0;
- return (float)(((a - b) + s * desc) / denom);
+ return 0.0f;
}
+
+ const double desc_sq = b * b - a * fC;
+ const double desc = sqrt(desc_sq < 0.0 ? 0.0 : desc_sq);
+ const double s = signed_area > 0 ? (-1.0) : 1.0;
+
+ return (float)(((a - b) + s * desc) / denom);
}
#undef IS_ZERO
@@ -4959,7 +4972,7 @@ void projmat_from_subregion(const float projmat[4][4],
}
}
-static void i_multmatrix(float icand[4][4], float Vm[4][4])
+static void i_multmatrix(const float icand[4][4], float Vm[4][4])
{
int row, col;
float temp[4][4];
@@ -5155,7 +5168,7 @@ void map_to_sphere(float *r_u, float *r_v, const float x, const float y, const f
void map_to_plane_v2_v3v3(float r_co[2], const float co[3], const float no[3])
{
- float target[3] = {0.0f, 0.0f, 1.0f};
+ const float target[3] = {0.0f, 0.0f, 1.0f};
float axis[3];
cross_v3_v3v3(axis, no, target);
@@ -6139,17 +6152,16 @@ float cubic_tangent_factor_circle_v3(const float tan_l[3], const float tan_r[3])
/* no angle difference (use fallback, length wont make any difference) */
return (1.0f / 3.0f) * 0.75f;
}
- else if (tan_dot < -1.0f + eps) {
+ if (tan_dot < -1.0f + eps) {
/* parallele tangents (half-circle) */
return (1.0f / 2.0f);
}
- else {
- /* non-aligned tangents, calculate handle length */
- const float angle = acosf(tan_dot) / 2.0f;
- /* could also use 'angle_sin = len_vnvn(tan_l, tan_r, dims) / 2.0' */
- const float angle_sin = sinf(angle);
- const float angle_cos = cosf(angle);
- return ((1.0f - angle_cos) / (angle_sin * 2.0f)) / angle_sin;
- }
+ /* non-aligned tangents, calculate handle length */
+ const float angle = acosf(tan_dot) / 2.0f;
+
+ /* could also use 'angle_sin = len_vnvn(tan_l, tan_r, dims) / 2.0' */
+ const float angle_sin = sinf(angle);
+ const float angle_cos = cosf(angle);
+ return ((1.0f - angle_cos) / (angle_sin * 2.0f)) / angle_sin;
}
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c
index 893c978d084..db317f5e81d 100644
--- a/source/blender/blenlib/intern/math_geom_inline.c
+++ b/source/blender/blenlib/intern/math_geom_inline.c
@@ -62,12 +62,12 @@ MINLINE float area_squared_tri_v2(const float v1[2], const float v2[2], const fl
MINLINE void zero_sh(float r[9])
{
- memset(r, 0, sizeof(float) * 9);
+ memset(r, 0, sizeof(float[9]));
}
MINLINE void copy_sh_sh(float r[9], const float a[9])
{
- memcpy(r, a, sizeof(float) * 9);
+ memcpy(r, a, sizeof(float[9]));
}
MINLINE void mul_sh_fl(float r[9], const float f)
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c
index 6277b1cd9dc..13a1816f1bd 100644
--- a/source/blender/blenlib/intern/math_interp.c
+++ b/source/blender/blenlib/intern/math_interp.c
@@ -286,7 +286,7 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer,
if (float_output) {
const float *row1, *row2, *row3, *row4;
- float empty[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float empty[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* pixel value must be already wrapped, however values at boundaries may flip */
if (wrap_x) {
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index a2f7cc24dd3..d38c081ec2b 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -644,9 +644,8 @@ float angle_signed_normalized_qt(const float q[4])
if (q[0] >= 0.0f) {
return 2.0f * saacos(q[0]);
}
- else {
- return -2.0f * saacos(-q[0]);
- }
+
+ return -2.0f * saacos(-q[0]);
}
float angle_signed_normalized_qtqt(const float q1[4], const float q2[4])
@@ -654,11 +653,10 @@ float angle_signed_normalized_qtqt(const float q1[4], const float q2[4])
if (dot_qtqt(q1, q2) >= 0.0f) {
return angle_normalized_qtqt(q1, q2);
}
- else {
- float q2_copy[4];
- negate_v4_v4(q2_copy, q2);
- return -angle_normalized_qtqt(q1, q2_copy);
- }
+
+ float q2_copy[4];
+ negate_v4_v4(q2_copy, q2);
+ return -angle_normalized_qtqt(q1, q2_copy);
}
float angle_signed_qt(const float q[4])
@@ -675,11 +673,10 @@ float angle_signed_qtqt(const float q1[4], const float q2[4])
if (dot_qtqt(q1, q2) >= 0.0f) {
return angle_qtqt(q1, q2);
}
- else {
- float q2_copy[4];
- negate_v4_v4(q2_copy, q2);
- return -angle_qtqt(q1, q2_copy);
- }
+
+ float q2_copy[4];
+ negate_v4_v4(q2_copy, q2);
+ return -angle_qtqt(q1, q2_copy);
}
/** \} */
@@ -1594,12 +1591,11 @@ static const RotOrderInfo *get_rotation_order_info(const short order)
if (order < 1) {
return &rotOrders[0];
}
- else if (order < 6) {
+ if (order < 6) {
return &rotOrders[order - 1];
}
- else {
- return &rotOrders[5];
- }
+
+ return &rotOrders[5];
}
/* Construct quaternion from Euler angles (in radians). */
@@ -2367,8 +2363,8 @@ bool mat3_from_axis_conversion(
value = ((src_forward << (0 * 3)) | (src_up << (1 * 3)) | (dst_forward << (2 * 3)) |
(dst_up << (3 * 3)));
- for (uint i = 0; i < (sizeof(_axis_convert_matrix) / sizeof(*_axis_convert_matrix)); i++) {
- for (uint j = 0; j < (sizeof(*_axis_convert_lut) / sizeof(*_axis_convert_lut[0])); j++) {
+ for (uint i = 0; i < (ARRAY_SIZE(_axis_convert_matrix)); i++) {
+ for (uint j = 0; j < (ARRAY_SIZE(*_axis_convert_lut)); j++) {
if (_axis_convert_lut[i][j] == value) {
copy_m3_m3(r_mat, _axis_convert_matrix[i]);
return true;
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 7f1840228e2..909d508e262 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -506,11 +506,10 @@ float angle_normalized_v3v3(const float v1[3], const float v2[3])
if (dot_v3v3(v1, v2) >= 0.0f) {
return 2.0f * saasin(len_v3v3(v1, v2) / 2.0f);
}
- else {
- float v2_n[3];
- negate_v3_v3(v2_n, v2);
- return (float)M_PI - 2.0f * saasin(len_v3v3(v1, v2_n) / 2.0f);
- }
+
+ float v2_n[3];
+ negate_v3_v3(v2_n, v2);
+ return (float)M_PI - 2.0f * saasin(len_v3v3(v1, v2_n) / 2.0f);
}
float angle_normalized_v2v2(const float v1[2], const float v2[2])
@@ -523,11 +522,10 @@ float angle_normalized_v2v2(const float v1[2], const float v2[2])
if (dot_v2v2(v1, v2) >= 0.0f) {
return 2.0f * saasin(len_v2v2(v1, v2) / 2.0f);
}
- else {
- float v2_n[2];
- negate_v2_v2(v2_n, v2);
- return (float)M_PI - 2.0f * saasin(len_v2v2(v1, v2_n) / 2.0f);
- }
+
+ float v2_n[2];
+ negate_v2_v2(v2_n, v2);
+ return (float)M_PI - 2.0f * saasin(len_v2v2(v1, v2_n) / 2.0f);
}
/**
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index d912cb8d464..67d41ffb779 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -427,9 +427,8 @@ static int BLI_path_unc_prefix_len(const char *path)
/* we assume long UNC path like \\?\server\share\folder etc... */
return 4;
}
- else {
- return 2;
- }
+
+ return 2;
}
return 0;
@@ -683,7 +682,7 @@ bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char
has_extension = true;
break;
}
- else if (ELEM(string[a], '/', '\\')) {
+ if (ELEM(string[a], '/', '\\')) {
break;
}
}
@@ -713,9 +712,8 @@ bool BLI_path_parent_dir(char *path)
strcpy(path, tmp); /* We assume pardir is always shorter... */
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/**
@@ -764,11 +762,10 @@ static bool stringframe_chars(const char *path, int *char_start, int *char_end)
*char_end = ch_end;
return true;
}
- else {
- *char_start = -1;
- *char_end = -1;
- return false;
- }
+
+ *char_start = -1;
+ *char_end = -1;
+ return false;
}
/**
@@ -1731,9 +1728,8 @@ void BLI_join_dirfile(char *__restrict dst,
dst[dirlen - 1] = '\0';
return; /* dir fills the path */
}
- else {
- memcpy(dst, dir, dirlen + 1);
- }
+
+ memcpy(dst, dir, dirlen + 1);
if (dirlen + 1 >= maxlen) {
return; /* fills the path */
@@ -1891,32 +1887,31 @@ bool BLI_path_name_at_index(const char *__restrict path,
}
return false;
}
- else {
- /* negative number, reverse where -1 is the last element */
- int index_step = -1;
- int prev = strlen(path);
- int i = prev - 1;
- while (true) {
- const char c = i >= 0 ? path[i] : '\0';
- if (ELEM(c, SEP, ALTSEP, '\0')) {
- if (prev - 1 != i) {
- i += 1;
- if (index_step == index) {
- *r_offset = i;
- *r_len = prev - i;
- return true;
- }
- index_step -= 1;
- }
- if (c == '\0') {
- break;
+
+ /* negative number, reverse where -1 is the last element */
+ int index_step = -1;
+ int prev = strlen(path);
+ int i = prev - 1;
+ while (true) {
+ const char c = i >= 0 ? path[i] : '\0';
+ if (ELEM(c, SEP, ALTSEP, '\0')) {
+ if (prev - 1 != i) {
+ i += 1;
+ if (index_step == index) {
+ *r_offset = i;
+ *r_len = prev - i;
+ return true;
}
- prev = i;
+ index_step -= 1;
}
- i -= 1;
+ if (c == '\0') {
+ break;
+ }
+ prev = i;
}
- return false;
+ i -= 1;
}
+ return false;
}
/**
@@ -1930,7 +1925,7 @@ const char *BLI_path_slash_find(const char *string)
if (!ffslash) {
return fbslash;
}
- else if (!fbslash) {
+ if (!fbslash) {
return ffslash;
}
@@ -1948,7 +1943,7 @@ const char *BLI_path_slash_rfind(const char *string)
if (!lfslash) {
return lbslash;
}
- else if (!lbslash) {
+ if (!lbslash) {
return lfslash;
}
diff --git a/source/blender/blenlib/intern/polyfill_2d.c b/source/blender/blenlib/intern/polyfill_2d.c
index 90a4a4f4c2d..d1e2bd58909 100644
--- a/source/blender/blenlib/intern/polyfill_2d.c
+++ b/source/blender/blenlib/intern/polyfill_2d.c
@@ -177,12 +177,11 @@ BLI_INLINE eSign signum_enum(float a)
if (UNLIKELY(a == 0.0f)) {
return 0;
}
- else if (a > 0.0f) {
+ if (a > 0.0f) {
return 1;
}
- else {
- return -1;
- }
+
+ return -1;
}
/**
@@ -250,7 +249,7 @@ static uint kdtree2d_balance_recursive(
if (totnode <= 0) {
return KDNODE_UNSET;
}
- else if (totnode == 1) {
+ if (totnode == 1) {
return 0 + ofs;
}
@@ -330,9 +329,8 @@ static void kdtree2d_node_remove(struct KDTree2D *tree, uint index)
if (node_index == KDNODE_UNSET) {
return;
}
- else {
- tree->nodes_map[index] = KDNODE_UNSET;
- }
+
+ tree->nodes_map[index] = KDNODE_UNSET;
node = &tree->nodes[node_index];
tree->totnode -= 1;
diff --git a/source/blender/blenlib/intern/polyfill_2d_beautify.c b/source/blender/blenlib/intern/polyfill_2d_beautify.c
index 41364c5a3a9..7bfca149ffb 100644
--- a/source/blender/blenlib/intern/polyfill_2d_beautify.c
+++ b/source/blender/blenlib/intern/polyfill_2d_beautify.c
@@ -64,14 +64,14 @@ static int oedge_cmp(const void *a1, const void *a2)
if (x1->verts[0] > x2->verts[0]) {
return 1;
}
- else if (x1->verts[0] < x2->verts[0]) {
+ if (x1->verts[0] < x2->verts[0]) {
return -1;
}
if (x1->verts[1] > x2->verts[1]) {
return 1;
}
- else if (x1->verts[1] < x2->verts[1]) {
+ if (x1->verts[1] < x2->verts[1]) {
return -1;
}
@@ -79,7 +79,7 @@ static int oedge_cmp(const void *a1, const void *a2)
if (x1->e_half > x2->e_half) {
return 1;
}
- else if (x1->e_half < x2->e_half) {
+ if (x1->e_half < x2->e_half) {
return -1;
}
/* Should never get here, no two edges should be the same. */
@@ -141,7 +141,7 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(const float v1[2],
if ((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f)) {
break;
}
- else if ((fabsf(area_2x_123) <= eps_zero_area) || (fabsf(area_2x_134) <= eps_zero_area)) {
+ if ((fabsf(area_2x_123) <= eps_zero_area) || (fabsf(area_2x_134) <= eps_zero_area)) {
break;
}
@@ -150,11 +150,10 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(const float v1[2],
if (lock_degenerate) {
break;
}
- else {
- return -FLT_MAX; /* always rotate */
- }
+
+ return -FLT_MAX; /* always rotate */
}
- else if ((fabsf(area_2x_234) <= eps_zero_area) || (fabsf(area_2x_241) <= eps_zero_area)) {
+ if ((fabsf(area_2x_234) <= eps_zero_area) || (fabsf(area_2x_241) <= eps_zero_area)) {
return -FLT_MAX; /* always rotate */
}
diff --git a/source/blender/blenlib/intern/quadric.c b/source/blender/blenlib/intern/quadric.c
index 3ad1844cfe1..ac522171951 100644
--- a/source/blender/blenlib/intern/quadric.c
+++ b/source/blender/blenlib/intern/quadric.c
@@ -107,9 +107,8 @@ static bool quadric_to_tensor_m3_inverse(const Quadric *q, double m[3][3], doubl
return true;
}
- else {
- return false;
- }
+
+ return false;
}
void BLI_quadric_to_vector_v3(const Quadric *q, double v[3])
@@ -161,7 +160,6 @@ bool BLI_quadric_optimize(const Quadric *q, double v[3], const double epsilon)
negate_v3_db(v);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
diff --git a/source/blender/blenlib/intern/rand.cc b/source/blender/blenlib/intern/rand.cc
index 9bafc422db5..224db31471d 100644
--- a/source/blender/blenlib/intern/rand.cc
+++ b/source/blender/blenlib/intern/rand.cc
@@ -93,7 +93,7 @@ void BLI_rng_srandom(RNG *rng, unsigned int seed)
void BLI_rng_get_char_n(RNG *rng, char *bytes, size_t bytes_len)
{
- rng->rng.get_bytes(blender::MutableSpan(bytes, (int64_t)bytes_len));
+ rng->rng.get_bytes(blender::MutableSpan(bytes, static_cast<int64_t>(bytes_len)));
}
int BLI_rng_get_int(RNG *rng)
@@ -428,7 +428,7 @@ float2 RandomNumberGenerator::get_triangle_sample(float2 v1, float2 v2, float2 v
void RandomNumberGenerator::get_bytes(MutableSpan<char> r_bytes)
{
constexpr int64_t mask_bytes = 2;
- constexpr int64_t rand_stride = (int64_t)sizeof(x_) - mask_bytes;
+ constexpr int64_t rand_stride = static_cast<int64_t>(sizeof(x_)) - mask_bytes;
int64_t last_len = 0;
int64_t trim_len = r_bytes.size();
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index bf3c8730b01..f952b62cb61 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -238,15 +238,14 @@ static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], c
if (div == 0.0) {
return 1; /* co-linear */
}
- else {
- const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
- (v1[0] - v3[0]) * (v4[1] - v3[1])) /
- div;
- const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) -
- (v1[0] - v3[0]) * (v2[1] - v1[1])) /
- div;
- return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
- }
+
+ const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
+ (v1[0] - v3[0]) * (v4[1] - v3[1])) /
+ div;
+ const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) -
+ (v1[0] - v3[0]) * (v2[1] - v1[1])) /
+ div;
+ return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
}
static int isect_segments_fl(const float v1[2],
const float v2[2],
@@ -258,15 +257,14 @@ static int isect_segments_fl(const float v1[2],
if (div == 0.0) {
return 1; /* co-linear */
}
- else {
- const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
- (v1[0] - v3[0]) * (v4[1] - v3[1])) /
- div;
- const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) -
- (v1[0] - v3[0]) * (v2[1] - v1[1])) /
- div;
- return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
- }
+
+ const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
+ (v1[0] - v3[0]) * (v4[1] - v3[1])) /
+ div;
+ const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) -
+ (v1[0] - v3[0]) * (v2[1] - v1[1])) /
+ div;
+ return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
}
bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
@@ -289,31 +287,30 @@ bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
if (BLI_rcti_isect_pt_v(rect, s1) || BLI_rcti_isect_pt_v(rect, s2)) {
return true;
}
- else {
- /* both points are outside but may intersect the rect */
- int tvec1[2];
- int tvec2[2];
- /* diagonal: [/] */
- tvec1[0] = rect->xmin;
- tvec1[1] = rect->ymin;
- tvec2[0] = rect->xmin;
- tvec2[1] = rect->ymax;
- if (isect_segments_i(s1, s2, tvec1, tvec2)) {
- return true;
- }
- /* diagonal: [\] */
- tvec1[0] = rect->xmin;
- tvec1[1] = rect->ymax;
- tvec2[0] = rect->xmax;
- tvec2[1] = rect->ymin;
- if (isect_segments_i(s1, s2, tvec1, tvec2)) {
- return true;
- }
+ /* both points are outside but may intersect the rect */
+ int tvec1[2];
+ int tvec2[2];
+ /* diagonal: [/] */
+ tvec1[0] = rect->xmin;
+ tvec1[1] = rect->ymin;
+ tvec2[0] = rect->xmin;
+ tvec2[1] = rect->ymax;
+ if (isect_segments_i(s1, s2, tvec1, tvec2)) {
+ return true;
+ }
- /* no intersection */
- return false;
+ /* diagonal: [\] */
+ tvec1[0] = rect->xmin;
+ tvec1[1] = rect->ymax;
+ tvec2[0] = rect->xmax;
+ tvec2[1] = rect->ymin;
+ if (isect_segments_i(s1, s2, tvec1, tvec2)) {
+ return true;
}
+
+ /* no intersection */
+ return false;
}
bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2])
@@ -336,31 +333,30 @@ bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[
if (BLI_rctf_isect_pt_v(rect, s1) || BLI_rctf_isect_pt_v(rect, s2)) {
return true;
}
- else {
- /* both points are outside but may intersect the rect */
- float tvec1[2];
- float tvec2[2];
- /* diagonal: [/] */
- tvec1[0] = rect->xmin;
- tvec1[1] = rect->ymin;
- tvec2[0] = rect->xmin;
- tvec2[1] = rect->ymax;
- if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
- return true;
- }
- /* diagonal: [\] */
- tvec1[0] = rect->xmin;
- tvec1[1] = rect->ymax;
- tvec2[0] = rect->xmax;
- tvec2[1] = rect->ymin;
- if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
- return true;
- }
+ /* both points are outside but may intersect the rect */
+ float tvec1[2];
+ float tvec2[2];
+ /* diagonal: [/] */
+ tvec1[0] = rect->xmin;
+ tvec1[1] = rect->ymin;
+ tvec2[0] = rect->xmin;
+ tvec2[1] = rect->ymax;
+ if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
+ return true;
+ }
- /* no intersection */
- return false;
+ /* diagonal: [\] */
+ tvec1[0] = rect->xmin;
+ tvec1[1] = rect->ymax;
+ tvec2[0] = rect->xmax;
+ tvec2[1] = rect->ymin;
+ if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
+ return true;
}
+
+ /* no intersection */
+ return false;
}
bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radius)
@@ -890,15 +886,14 @@ bool BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest)
}
return true;
}
- else {
- if (dest) {
- dest->xmin = 0;
- dest->xmax = 0;
- dest->ymin = 0;
- dest->ymax = 0;
- }
- return false;
+
+ if (dest) {
+ dest->xmin = 0;
+ dest->xmax = 0;
+ dest->ymin = 0;
+ dest->ymax = 0;
}
+ return false;
}
bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
@@ -920,15 +915,14 @@ bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
}
return true;
}
- else {
- if (dest) {
- dest->xmin = 0;
- dest->xmax = 0;
- dest->ymin = 0;
- dest->ymax = 0;
- }
- return false;
+
+ if (dest) {
+ dest->xmin = 0;
+ dest->xmax = 0;
+ dest->ymin = 0;
+ dest->ymax = 0;
}
+ return false;
}
bool BLI_rctf_isect_rect_x(const rctf *src1, const rctf *src2, float range_x[2])
@@ -943,13 +937,12 @@ bool BLI_rctf_isect_rect_x(const rctf *src1, const rctf *src2, float range_x[2])
}
return true;
}
- else {
- if (range_x) {
- range_x[0] = 0;
- range_x[1] = 0;
- }
- return false;
+
+ if (range_x) {
+ range_x[0] = 0;
+ range_x[1] = 0;
}
+ return false;
}
bool BLI_rctf_isect_rect_y(const rctf *src1, const rctf *src2, float range_y[2])
@@ -964,13 +957,12 @@ bool BLI_rctf_isect_rect_y(const rctf *src1, const rctf *src2, float range_y[2])
}
return true;
}
- else {
- if (range_y) {
- range_y[0] = 0;
- range_y[1] = 0;
- }
- return false;
+
+ if (range_y) {
+ range_y[0] = 0;
+ range_y[1] = 0;
}
+ return false;
}
bool BLI_rcti_isect_rect_x(const rcti *src1, const rcti *src2, int range_x[2])
@@ -985,13 +977,12 @@ bool BLI_rcti_isect_rect_x(const rcti *src1, const rcti *src2, int range_x[2])
}
return true;
}
- else {
- if (range_x) {
- range_x[0] = 0;
- range_x[1] = 0;
- }
- return false;
+
+ if (range_x) {
+ range_x[0] = 0;
+ range_x[1] = 0;
}
+ return false;
}
bool BLI_rcti_isect_rect_y(const rcti *src1, const rcti *src2, int range_y[2])
@@ -1006,13 +997,12 @@ bool BLI_rcti_isect_rect_y(const rcti *src1, const rcti *src2, int range_y[2])
}
return true;
}
- else {
- if (range_y) {
- range_y[0] = 0;
- range_y[1] = 0;
- }
- return false;
+
+ if (range_y) {
+ range_y[0] = 0;
+ range_y[1] = 0;
}
+ return false;
}
void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index 4723a3532ac..8b536354af2 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -91,13 +91,13 @@ static int vergscdata(const void *a1, const void *a2)
if (x1->vert->xy[1] < x2->vert->xy[1]) {
return 1;
}
- else if (x1->vert->xy[1] > x2->vert->xy[1]) {
+ if (x1->vert->xy[1] > x2->vert->xy[1]) {
return -1;
}
- else if (x1->vert->xy[0] > x2->vert->xy[0]) {
+ if (x1->vert->xy[0] > x2->vert->xy[0]) {
return 1;
}
- else if (x1->vert->xy[0] < x2->vert->xy[0]) {
+ if (x1->vert->xy[0] < x2->vert->xy[0]) {
return -1;
}
@@ -111,13 +111,13 @@ static int vergpoly(const void *a1, const void *a2)
if (x1->min_xy[0] > x2->min_xy[0]) {
return 1;
}
- else if (x1->min_xy[0] < x2->min_xy[0]) {
+ if (x1->min_xy[0] < x2->min_xy[0]) {
return -1;
}
- else if (x1->min_xy[1] > x2->min_xy[1]) {
+ if (x1->min_xy[1] > x2->min_xy[1]) {
return 1;
}
- else if (x1->min_xy[1] < x2->min_xy[1]) {
+ if (x1->min_xy[1] < x2->min_xy[1]) {
return -1;
}
@@ -259,7 +259,7 @@ static bool testedgeside(const float v1[2], const float v2[2], const float v3[2]
if (inp < 0.0f) {
return false;
}
- else if (inp == 0.0f) {
+ if (inp == 0.0f) {
if (v1[0] == v3[0] && v1[1] == v3[1]) {
return false;
}
@@ -417,25 +417,24 @@ static void testvertexnearedge(ScanFillContext *sf_ctx)
eve->edge_tot = 0;
break;
}
- else if (compare_v2v2(eve->xy, eed->v2->xy, SF_EPSILON)) {
+ if (compare_v2v2(eve->xy, eed->v2->xy, SF_EPSILON)) {
ed1->v2 = eed->v2;
eed->v2->edge_tot++;
eve->edge_tot = 0;
break;
}
- else {
- if (boundinsideEV(eed, eve)) {
- const float dist = dist_squared_to_line_v2(eed->v1->xy, eed->v2->xy, eve->xy);
- if (dist < SF_EPSILON_SQ) {
- /* new edge */
- ed1 = BLI_scanfill_edge_add(sf_ctx, eed->v1, eve);
-
- /* printf("fill: vertex near edge %x\n", eve); */
- ed1->poly_nr = eed->poly_nr;
- eed->v1 = eve;
- eve->edge_tot = 3;
- break;
- }
+
+ if (boundinsideEV(eed, eve)) {
+ const float dist = dist_squared_to_line_v2(eed->v1->xy, eed->v2->xy, eve->xy);
+ if (dist < SF_EPSILON_SQ) {
+ /* new edge */
+ ed1 = BLI_scanfill_edge_add(sf_ctx, eed->v1, eve);
+
+ /* printf("fill: vertex near edge %x\n", eve); */
+ ed1->poly_nr = eed->poly_nr;
+ eed->v1 = eve;
+ eve->edge_tot = 3;
+ break;
}
}
}
@@ -875,41 +874,40 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
if (UNLIKELY(eve == NULL)) {
return 0;
}
+
+ float n[3];
+
+ if (nor_proj) {
+ copy_v3_v3(n, nor_proj);
+ }
else {
- float n[3];
+ /* define projection: with 'best' normal */
+ /* Newell's Method */
+ /* Similar code used elsewhere, but this checks for double ups
+ * which historically this function supports so better not change */
- if (nor_proj) {
- copy_v3_v3(n, nor_proj);
- }
- else {
- /* define projection: with 'best' normal */
- /* Newell's Method */
- /* Similar code used elsewhere, but this checks for double ups
- * which historically this function supports so better not change */
-
- /* warning: this only gives stable direction with single polygons,
- * ideally we'd calculate connectivity and each polys normal, see T41047 */
- const float *v_prev;
-
- zero_v3(n);
- eve = sf_ctx->fillvertbase.last;
- v_prev = eve->co;
-
- for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
- if (LIKELY(!compare_v3v3(v_prev, eve->co, SF_EPSILON))) {
- add_newell_cross_v3_v3v3(n, v_prev, eve->co);
- v_prev = eve->co;
- }
- }
- }
+ /* warning: this only gives stable direction with single polygons,
+ * ideally we'd calculate connectivity and each polys normal, see T41047 */
+ const float *v_prev;
- if (UNLIKELY(normalize_v3(n) == 0.0f)) {
- return 0;
+ zero_v3(n);
+ eve = sf_ctx->fillvertbase.last;
+ v_prev = eve->co;
+
+ for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
+ if (LIKELY(!compare_v3v3(v_prev, eve->co, SF_EPSILON))) {
+ add_newell_cross_v3_v3v3(n, v_prev, eve->co);
+ v_prev = eve->co;
+ }
}
+ }
- axis_dominant_v3_to_m3_negate(mat_2d, n);
+ if (UNLIKELY(normalize_v3(n) == 0.0f)) {
+ return 0;
}
+ axis_dominant_v3_to_m3_negate(mat_2d, n);
+
/* STEP 1: COUNT POLYS */
if (sf_ctx->poly_nr != SF_POLY_UNSET) {
poly = (unsigned short)(sf_ctx->poly_nr + 1);
diff --git a/source/blender/blenlib/intern/scanfill_utils.c b/source/blender/blenlib/intern/scanfill_utils.c
index 31b2bf85142..660d3dca807 100644
--- a/source/blender/blenlib/intern/scanfill_utils.c
+++ b/source/blender/blenlib/intern/scanfill_utils.c
@@ -139,9 +139,8 @@ static int edge_isect_ls_sort_cb(void *thunk, const void *def_a_ptr, const void
if (a > b) {
return -1;
}
- else {
- return (a < b);
- }
+
+ return (a < b);
}
static ScanFillEdge *edge_step(PolyInfo *poly_info,
diff --git a/source/blender/blenlib/intern/session_uuid.c b/source/blender/blenlib/intern/session_uuid.c
new file mode 100644
index 00000000000..8ed96f02149
--- /dev/null
+++ b/source/blender/blenlib/intern/session_uuid.c
@@ -0,0 +1,78 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup bli
+ */
+
+#include "BLI_session_uuid.h"
+
+#include "BLI_utildefines.h"
+
+#include "atomic_ops.h"
+
+/* Special value which indicates the UUID has not been assigned yet. */
+#define BLI_SESSION_UUID_NONE 0
+
+static const SessionUUID global_session_uuid_none = {BLI_SESSION_UUID_NONE};
+
+/* Denotes last used UUID.
+ * It might eventually overflow, and easiest is to add more bits to it. */
+static SessionUUID global_session_uuid = {BLI_SESSION_UUID_NONE};
+
+SessionUUID BLI_session_uuid_generate(void)
+{
+ SessionUUID result;
+ result.uuid_ = atomic_add_and_fetch_uint64(&global_session_uuid.uuid_, 1);
+ if (!BLI_session_uuid_is_generated(&result)) {
+ /* Happens when the UUID overflows.
+ *
+ * Just request the UUID once again, hoping that there are not a lot of high-priority threads
+ * which will overflow the counter once again between the previous call and this one.
+ *
+ * NOTE: It is possible to have collisions after such overflow. */
+ result.uuid_ = atomic_add_and_fetch_uint64(&global_session_uuid.uuid_, 1);
+ }
+ return result;
+}
+
+bool BLI_session_uuid_is_generated(const SessionUUID *uuid)
+{
+ return !BLI_session_uuid_is_equal(uuid, &global_session_uuid_none);
+}
+
+bool BLI_session_uuid_is_equal(const SessionUUID *lhs, const SessionUUID *rhs)
+{
+ return lhs->uuid_ == rhs->uuid_;
+}
+
+uint64_t BLI_session_uuid_hash_uint64(const SessionUUID *uuid)
+{
+ return uuid->uuid_;
+}
+
+uint BLI_session_uuid_ghash_hash(const void *uuid_v)
+{
+ const SessionUUID *uuid = (const SessionUUID *)uuid_v;
+ return uuid->uuid_ & 0xffffffff;
+}
+
+bool BLI_session_uuid_ghash_compare(const void *lhs_v, const void *rhs_v)
+{
+ const SessionUUID *lhs = (const SessionUUID *)lhs_v;
+ const SessionUUID *rhs = (const SessionUUID *)rhs_v;
+ return BLI_session_uuid_is_equal(lhs, rhs);
+}
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index 6d1ce3c84cd..ab2b0fd2928 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -253,10 +253,9 @@ bool BLI_smallhash_reinsert(SmallHash *sh, uintptr_t key, void *item)
e->val = item;
return false;
}
- else {
- BLI_smallhash_insert(sh, key, item);
- return true;
- }
+
+ BLI_smallhash_insert(sh, key, item);
+ return true;
}
#ifdef USE_REMOVE
diff --git a/source/blender/blenlib/intern/sort_utils.c b/source/blender/blenlib/intern/sort_utils.c
index 09babd3d424..e02d77de0c7 100644
--- a/source/blender/blenlib/intern/sort_utils.c
+++ b/source/blender/blenlib/intern/sort_utils.c
@@ -44,12 +44,11 @@ int BLI_sortutil_cmp_float(const void *a_, const void *b_)
if (a->sort_value > b->sort_value) {
return 1;
}
- else if (a->sort_value < b->sort_value) {
+ if (a->sort_value < b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
@@ -59,12 +58,11 @@ int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
if (a->sort_value < b->sort_value) {
return 1;
}
- else if (a->sort_value > b->sort_value) {
+ if (a->sort_value > b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
int BLI_sortutil_cmp_int(const void *a_, const void *b_)
@@ -74,12 +72,11 @@ int BLI_sortutil_cmp_int(const void *a_, const void *b_)
if (a->sort_value > b->sort_value) {
return 1;
}
- else if (a->sort_value < b->sort_value) {
+ if (a->sort_value < b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_)
@@ -89,12 +86,11 @@ int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_)
if (a->sort_value < b->sort_value) {
return 1;
}
- else if (a->sort_value > b->sort_value) {
+ if (a->sort_value > b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
int BLI_sortutil_cmp_ptr(const void *a_, const void *b_)
@@ -104,12 +100,11 @@ int BLI_sortutil_cmp_ptr(const void *a_, const void *b_)
if (a->sort_value > b->sort_value) {
return 1;
}
- else if (a->sort_value < b->sort_value) {
+ if (a->sort_value < b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
int BLI_sortutil_cmp_ptr_reverse(const void *a_, const void *b_)
@@ -119,10 +114,9 @@ int BLI_sortutil_cmp_ptr_reverse(const void *a_, const void *b_)
if (a->sort_value < b->sort_value) {
return 1;
}
- else if (a->sort_value > b->sort_value) {
+ if (a->sort_value > b->sort_value) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index d3191148c90..db062ff50fd 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -96,9 +96,7 @@ char *BLI_current_working_dir(char *dir, const size_t maxncpy)
memcpy(dir, pwd, srclen + 1);
return dir;
}
- else {
- return NULL;
- }
+ return NULL;
}
return getcwd(dir, maxncpy);
#endif
@@ -373,13 +371,13 @@ int BLI_exists(const char *name)
free(tmp_16);
if (res == -1) {
- return (0);
+ return 0;
}
#else
struct stat st;
BLI_assert(!BLI_path_is_rel(name));
if (stat(name, &st)) {
- return (0);
+ return 0;
}
#endif
return (st.st_mode);
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index abdae06acd5..755637ac274 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -87,7 +87,7 @@ char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2)
str = MEM_mallocN(str1_len + str2_len, "strdupcat");
s = str;
- memcpy(s, str1, str1_len);
+ memcpy(s, str1, str1_len); /* NOLINT: bugprone-not-null-terminated-result */
s += str1_len;
memcpy(s, str2, str2_len);
@@ -394,9 +394,7 @@ char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict
if (LIKELY(*(endMatch - 1) != '\\')) {
break;
}
- else {
- endMatch++;
- }
+ endMatch++;
}
if (endMatch) {
@@ -470,11 +468,9 @@ char *BLI_str_replaceN(const char *__restrict str,
return str_new;
}
- else {
- /* Just create a new copy of the entire string - we avoid going through the assembly buffer
- * for what should be a bit more efficiency. */
- return BLI_strdup(str);
- }
+ /* Just create a new copy of the entire string - we avoid going through the assembly buffer
+ * for what should be a bit more efficiency. */
+ return BLI_strdup(str);
}
/**
@@ -518,7 +514,7 @@ char *BLI_strcasestr(const char *s, const char *find)
do {
do {
if ((sc = *s++) == 0) {
- return (NULL);
+ return NULL;
}
sc = tolower(sc);
} while (sc != c);
@@ -574,10 +570,10 @@ int BLI_strcasecmp(const char *s1, const char *s2)
if (c1 < c2) {
return -1;
}
- else if (c1 > c2) {
+ if (c1 > c2) {
return 1;
}
- else if (c1 == 0) {
+ if (c1 == 0) {
break;
}
}
@@ -597,10 +593,10 @@ int BLI_strncasecmp(const char *s1, const char *s2, size_t len)
if (c1 < c2) {
return -1;
}
- else if (c1 > c2) {
+ if (c1 > c2) {
return 1;
}
- else if (c1 == 0) {
+ if (c1 == 0) {
break;
}
}
@@ -627,15 +623,13 @@ static int left_number_strcmp(const char *s1, const char *s2, int *tiebreaker)
if (isdigit(*(p1 + numdigit)) && isdigit(*(p2 + numdigit))) {
continue;
}
- else if (isdigit(*(p1 + numdigit))) {
+ if (isdigit(*(p1 + numdigit))) {
return 1; /* s2 is bigger */
}
- else if (isdigit(*(p2 + numdigit))) {
+ if (isdigit(*(p2 + numdigit))) {
return -1; /* s1 is bigger */
}
- else {
- break;
- }
+ break;
}
/* same number of digits, compare size of number */
@@ -759,14 +753,14 @@ int BLI_strcmp_ignore_pad(const char *str1, const char *str2, const char pad)
if (str1_len == str2_len) {
return strncmp(str1, str2, str2_len);
}
- else if (str1_len > str2_len) {
+ if (str1_len > str2_len) {
int ret = strncmp(str1, str2, str2_len);
if (ret == 0) {
ret = 1;
}
return ret;
}
- else {
+ {
int ret = strncmp(str1, str2, str1_len);
if (ret == 0) {
ret = -1;
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index e9fdce83710..0a723a623f0 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -215,11 +215,9 @@ int BLI_utf8_invalid_strip(char *str, size_t length)
tot++;
break;
}
- else {
- /* strip, keep looking */
- memmove(str, str + 1, length + 1); /* +1 for NULL char! */
- tot++;
- }
+ /* strip, keep looking */
+ memmove(str, str + 1, length + 1); /* +1 for NULL char! */
+ tot++;
}
return tot;
diff --git a/source/blender/blenlib/intern/string_utils.c b/source/blender/blenlib/intern/string_utils.c
index fb9530b5cb5..dbeb75570fb 100644
--- a/source/blender/blenlib/intern/string_utils.c
+++ b/source/blender/blenlib/intern/string_utils.c
@@ -72,7 +72,7 @@ size_t BLI_split_name_num(char *left, int *nr, const char *name, const char deli
}
return a;
}
- else if (isdigit(name[a]) == 0) {
+ if (isdigit(name[a]) == 0) {
/* non-numeric suffix - give up */
break;
}
diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c
index 20edbb97561..e3572b7f05e 100644
--- a/source/blender/blenlib/intern/system.c
+++ b/source/blender/blenlib/intern/system.c
@@ -183,7 +183,7 @@ size_t BLI_system_memory_max_in_megabytes(void)
/* Maximum addressable bytes on this platform.
*
* NOTE: Due to the shift arithmetic this is a half of the memory. */
- const size_t limit_bytes_half = (((size_t)1) << ((sizeof(size_t) * 8) - 1));
+ const size_t limit_bytes_half = (((size_t)1) << ((sizeof(size_t[8])) - 1));
/* Convert it to megabytes and return. */
return (limit_bytes_half >> 20) * 2;
}
diff --git a/source/blender/blenlib/intern/threads.cc b/source/blender/blenlib/intern/threads.cc
index a8333d0c696..002b78bec39 100644
--- a/source/blender/blenlib/intern/threads.cc
+++ b/source/blender/blenlib/intern/threads.cc
@@ -309,7 +309,7 @@ int BLI_system_thread_count(void)
if (num_threads_override != 0) {
return num_threads_override;
}
- else if (LIKELY(t != -1)) {
+ if (LIKELY(t != -1)) {
return t;
}
@@ -751,7 +751,7 @@ void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms)
if (pthread_cond_timedwait(&queue->push_cond, &queue->mutex, &timeout) == ETIMEDOUT) {
break;
}
- else if (PIL_check_seconds_timer() - t >= ms * 0.001) {
+ if (PIL_check_seconds_timer() - t >= ms * 0.001) {
break;
}
}
diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c
index a34c551767a..00fef29587c 100644
--- a/source/blender/blenlib/intern/uvproject.c
+++ b/source/blender/blenlib/intern/uvproject.c
@@ -183,7 +183,7 @@ ProjCameraInfo *BLI_uvproject_camera_info(Object *ob, float (*rotmat)[4], float
return NULL;
}
-void BLI_uvproject_from_view_ortho(float target[2], float source[3], float rotmat[4][4])
+void BLI_uvproject_from_view_ortho(float target[2], float source[3], const float rotmat[4][4])
{
float pv[3];
diff --git a/source/blender/blenlib/intern/voronoi_2d.c b/source/blender/blenlib/intern/voronoi_2d.c
index bc11a2c7a1c..5b998973a20 100644
--- a/source/blender/blenlib/intern/voronoi_2d.c
+++ b/source/blender/blenlib/intern/voronoi_2d.c
@@ -83,7 +83,9 @@ static void voronoi_insertEvent(VoronoiProcess *process, VoronoiEvent *event)
}
/* edge */
-static VoronoiEdge *voronoiEdge_new(float start[2], float left[2], float right[2])
+static VoronoiEdge *voronoiEdge_new(const float start[2],
+ const float left[2],
+ const float right[2])
{
VoronoiEdge *edge = MEM_callocN(sizeof(VoronoiEdge), "voronoi edge");
@@ -118,7 +120,7 @@ static VoronoiParabola *voronoiParabola_new(void)
return parabola;
}
-static VoronoiParabola *voronoiParabola_newSite(float site[2])
+static VoronoiParabola *voronoiParabola_newSite(const float site[2])
{
VoronoiParabola *parabola = MEM_callocN(sizeof(VoronoiParabola), "voronoi parabola site");
diff --git a/tests/gtests/blenlib/BLI_array_store_test.cc b/source/blender/blenlib/tests/BLI_array_store_test.cc
index a1ec8ec7bb3..a1ec8ec7bb3 100644
--- a/tests/gtests/blenlib/BLI_array_store_test.cc
+++ b/source/blender/blenlib/tests/BLI_array_store_test.cc
diff --git a/tests/gtests/blenlib/BLI_array_utils_test.cc b/source/blender/blenlib/tests/BLI_array_utils_test.cc
index 33b4cd35d52..33b4cd35d52 100644
--- a/tests/gtests/blenlib/BLI_array_utils_test.cc
+++ b/source/blender/blenlib/tests/BLI_array_utils_test.cc
diff --git a/tests/gtests/blenlib/BLI_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
index 8d62b111e12..752f833461d 100644
--- a/tests/gtests/blenlib/BLI_delaunay_2d_test.cc
+++ b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
@@ -126,6 +126,7 @@ static void fill_input_from_string(CDT_input *r_input, const char *spec)
}
}
+#if DO_FILE_TESTS
static void fill_input_from_file(CDT_input *in, const char *filename)
{
std::FILE *fp = std::fopen(filename, "rb");
@@ -142,6 +143,7 @@ static void fill_input_from_file(CDT_input *in, const char *filename)
printf("couldn't open file %s\n", filename);
}
}
+#endif
static void free_spec_arrays(CDT_input *in)
{
@@ -180,8 +182,9 @@ static int get_edge(const CDT_result *r, int out_index_1, int out_index_2)
for (i = 0; i < r->edges_len; i++) {
if ((r->edges[i][0] == out_index_1 && r->edges[i][1] == out_index_2) ||
- (r->edges[i][0] == out_index_2 && r->edges[i][1] == out_index_1))
+ (r->edges[i][0] == out_index_2 && r->edges[i][1] == out_index_1)) {
return i;
+ }
}
return -1;
}
@@ -189,28 +192,33 @@ static int get_edge(const CDT_result *r, int out_index_1, int out_index_2)
/* return true if given output edge has given input edge id in its originals list */
static bool out_edge_has_input_id(const CDT_result *r, int out_edge_index, int in_edge_index)
{
- if (r->edges_orig == NULL)
+ if (r->edges_orig == NULL) {
return false;
- if (out_edge_index < 0 || out_edge_index >= r->edges_len)
+ }
+ if (out_edge_index < 0 || out_edge_index >= r->edges_len) {
return false;
+ }
for (int i = 0; i < r->edges_orig_len_table[out_edge_index]; i++) {
- if (r->edges_orig[r->edges_orig_start_table[out_edge_index] + i] == in_edge_index)
+ if (r->edges_orig[r->edges_orig_start_table[out_edge_index] + i] == in_edge_index) {
return true;
+ }
}
return false;
}
/* which face is for given output vertex ngon? */
-static int get_face(const CDT_result *r, int *out_indices, int nverts)
+static int get_face(const CDT_result *r, const int *out_indices, int nverts)
{
int f, cycle_start, k, fstart;
bool ok;
- if (r->faces_len == 0)
+ if (r->faces_len == 0) {
return -1;
+ }
for (f = 0; f < r->faces_len; f++) {
- if (r->faces_len_table[f] != nverts)
+ if (r->faces_len_table[f] != nverts) {
continue;
+ }
fstart = r->faces_start_table[f];
for (cycle_start = 0; cycle_start < nverts; cycle_start++) {
ok = true;
@@ -240,17 +248,21 @@ static int get_face_tri(const CDT_result *r, int out_index_1, int out_index_2, i
/* return true if given otuput face has given input face id in its originals list */
static bool out_face_has_input_id(const CDT_result *r, int out_face_index, int in_face_index)
{
- if (r->faces_orig == NULL)
+ if (r->faces_orig == NULL) {
return false;
- if (out_face_index < 0 || out_face_index >= r->faces_len)
+ }
+ if (out_face_index < 0 || out_face_index >= r->faces_len) {
return false;
+ }
for (int i = 0; i < r->faces_orig_len_table[out_face_index]; i++) {
- if (r->faces_orig[r->faces_orig_start_table[out_face_index] + i] == in_face_index)
+ if (r->faces_orig[r->faces_orig_start_table[out_face_index] + i] == in_face_index) {
return true;
+ }
}
return false;
}
+#if DO_FILE_TESTS
/* for debugging */
static void dump_result(CDT_result *r)
{
@@ -263,44 +275,51 @@ static void dump_result(CDT_result *r)
r->edges_len,
r->faces_len);
fprintf(stderr, "\nvert coords:\n");
- for (i = 0; i < r->verts_len; i++)
+ for (i = 0; i < r->verts_len; i++) {
fprintf(stderr, "%d: (%f,%f)\n", i, r->vert_coords[i][0], r->vert_coords[i][1]);
+ }
fprintf(stderr, "vert orig:\n");
for (i = 0; i < r->verts_len; i++) {
fprintf(stderr, "%d:", i);
- for (j = 0; j < r->verts_orig_len_table[i]; j++)
+ for (j = 0; j < r->verts_orig_len_table[i]; j++) {
fprintf(stderr, " %d", r->verts_orig[r->verts_orig_start_table[i] + j]);
+ }
fprintf(stderr, "\n");
}
fprintf(stderr, "\nedges:\n");
- for (i = 0; i < r->edges_len; i++)
+ for (i = 0; i < r->edges_len; i++) {
fprintf(stderr, "%d: (%d,%d)\n", i, r->edges[i][0], r->edges[i][1]);
+ }
if (r->edges_orig) {
fprintf(stderr, "edge orig:\n");
for (i = 0; i < r->edges_len; i++) {
fprintf(stderr, "%d:", i);
- for (j = 0; j < r->edges_orig_len_table[i]; j++)
+ for (j = 0; j < r->edges_orig_len_table[i]; j++) {
fprintf(stderr, " %d", r->edges_orig[r->edges_orig_start_table[i] + j]);
+ }
fprintf(stderr, "\n");
}
}
fprintf(stderr, "\nfaces:\n");
for (i = 0; i < r->faces_len; i++) {
fprintf(stderr, "%d: ", i);
- for (j = 0; j < r->faces_len_table[i]; j++)
+ for (j = 0; j < r->faces_len_table[i]; j++) {
fprintf(stderr, " %d", r->faces[r->faces_start_table[i] + j]);
+ }
fprintf(stderr, "\n");
}
if (r->faces_orig) {
fprintf(stderr, "face orig:\n");
for (i = 0; i < r->faces_len; i++) {
fprintf(stderr, "%d:", i);
- for (j = 0; j < r->faces_orig_len_table[i]; j++)
+ for (j = 0; j < r->faces_orig_len_table[i]; j++) {
fprintf(stderr, " %d", r->faces_orig[r->faces_orig_start_table[i] + j]);
+ }
fprintf(stderr, "\n");
}
}
}
+#endif
#if DO_REGULAR_TESTS
TEST(delaunay, Empty)
@@ -904,8 +923,9 @@ TEST(delaunay, OverlapFaces)
EXPECT_TRUE(out_face_has_input_id(out, f1_out, 0));
EXPECT_TRUE(out_face_has_input_id(out, f1_out, 1));
f2_out = get_face_tri(out, v_out[8], v_out[9], v_out[10]);
- if (f2_out == -1)
+ if (f2_out == -1) {
f2_out = get_face_tri(out, v_out[8], v_out[9], v_out[11]);
+ }
EXPECT_NE(f2_out, -1);
EXPECT_TRUE(out_face_has_input_id(out, f2_out, 0));
EXPECT_TRUE(out_face_has_input_id(out, f2_out, 2));
@@ -1708,8 +1728,8 @@ TEST(delaunay, random_tris_circle_b)
#endif
#if DO_FILE_TESTS
-/* For timing large examples of points only.
- * See fill_input_from_file for file format.
+/* For manually testing performance by timing a large number of points from a
+ * file. See fill_input_from_file for file format.
*/
static void points_from_file_test(const char *filename)
{
diff --git a/tests/gtests/blenlib/BLI_expr_pylike_eval_test.cc b/source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc
index aad21ae4ad4..aad21ae4ad4 100644
--- a/tests/gtests/blenlib/BLI_expr_pylike_eval_test.cc
+++ b/source/blender/blenlib/tests/BLI_expr_pylike_eval_test.cc
diff --git a/tests/gtests/blenlib/BLI_ghash_test.cc b/source/blender/blenlib/tests/BLI_ghash_test.cc
index fcc0512cb9e..484f158a85c 100644
--- a/tests/gtests/blenlib/BLI_ghash_test.cc
+++ b/source/blender/blenlib/tests/BLI_ghash_test.cc
@@ -80,8 +80,8 @@ TEST(ghash, InsertLookup)
BLI_ghash_free(ghash, NULL, NULL);
}
-/* Here we simply insert and then remove all keys, ensuring we do get an empty, unshrinked ghash.
- */
+/* Here we simply insert and then remove all keys, ensuring we do get an empty,
+ * ghash that has not been shrunk. */
TEST(ghash, InsertRemove)
{
GHash *ghash = BLI_ghash_new(BLI_ghashutil_inthash_p, BLI_ghashutil_intcmp, __func__);
diff --git a/tests/gtests/blenlib/BLI_hash_mm2a_test.cc b/source/blender/blenlib/tests/BLI_hash_mm2a_test.cc
index c7bea8e15de..c7bea8e15de 100644
--- a/tests/gtests/blenlib/BLI_hash_mm2a_test.cc
+++ b/source/blender/blenlib/tests/BLI_hash_mm2a_test.cc
diff --git a/tests/gtests/blenlib/BLI_heap_simple_test.cc b/source/blender/blenlib/tests/BLI_heap_simple_test.cc
index e717a6e2653..e717a6e2653 100644
--- a/tests/gtests/blenlib/BLI_heap_simple_test.cc
+++ b/source/blender/blenlib/tests/BLI_heap_simple_test.cc
diff --git a/tests/gtests/blenlib/BLI_heap_test.cc b/source/blender/blenlib/tests/BLI_heap_test.cc
index 87e68c175a2..87e68c175a2 100644
--- a/tests/gtests/blenlib/BLI_heap_test.cc
+++ b/source/blender/blenlib/tests/BLI_heap_test.cc
diff --git a/tests/gtests/blenlib/BLI_kdopbvh_test.cc b/source/blender/blenlib/tests/BLI_kdopbvh_test.cc
index f8a4fc1290a..2e8032400e3 100644
--- a/tests/gtests/blenlib/BLI_kdopbvh_test.cc
+++ b/source/blender/blenlib/tests/BLI_kdopbvh_test.cc
@@ -11,8 +11,6 @@
#include "BLI_math_vector.h"
#include "BLI_rand.h"
-#include "stubs/bf_intern_eigen_stubs.h"
-
/* -------------------------------------------------------------------- */
/* Helper Functions */
diff --git a/source/blender/blenlib/tests/BLI_linear_allocator_test.cc b/source/blender/blenlib/tests/BLI_linear_allocator_test.cc
index 44b70d1f55d..a35fbf70711 100644
--- a/source/blender/blenlib/tests/BLI_linear_allocator_test.cc
+++ b/source/blender/blenlib/tests/BLI_linear_allocator_test.cc
@@ -8,7 +8,7 @@ namespace blender::tests {
static bool is_aligned(void *ptr, uint alignment)
{
- BLI_assert(is_power_of_2_i((int)alignment));
+ BLI_assert(is_power_of_2_i(static_cast<int>(alignment)));
return (POINTER_AS_UINT(ptr) & (alignment - 1)) == 0;
}
diff --git a/tests/gtests/blenlib/BLI_linklist_lockfree_test.cc b/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc
index d1a527d57ac..d1a527d57ac 100644
--- a/tests/gtests/blenlib/BLI_linklist_lockfree_test.cc
+++ b/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc
diff --git a/tests/gtests/blenlib/BLI_listbase_test.cc b/source/blender/blenlib/tests/BLI_listbase_test.cc
index e5b504a0040..e5b504a0040 100644
--- a/tests/gtests/blenlib/BLI_listbase_test.cc
+++ b/source/blender/blenlib/tests/BLI_listbase_test.cc
diff --git a/tests/gtests/blenlib/BLI_math_base_test.cc b/source/blender/blenlib/tests/BLI_math_base_test.cc
index dc20c75576d..dc20c75576d 100644
--- a/tests/gtests/blenlib/BLI_math_base_test.cc
+++ b/source/blender/blenlib/tests/BLI_math_base_test.cc
diff --git a/tests/gtests/blenlib/BLI_math_bits_test.cc b/source/blender/blenlib/tests/BLI_math_bits_test.cc
index 4fa4809beed..4fa4809beed 100644
--- a/tests/gtests/blenlib/BLI_math_bits_test.cc
+++ b/source/blender/blenlib/tests/BLI_math_bits_test.cc
diff --git a/tests/gtests/blenlib/BLI_math_color_test.cc b/source/blender/blenlib/tests/BLI_math_color_test.cc
index 7df47e74eb0..7df47e74eb0 100644
--- a/tests/gtests/blenlib/BLI_math_color_test.cc
+++ b/source/blender/blenlib/tests/BLI_math_color_test.cc
diff --git a/tests/gtests/blenlib/BLI_math_geom_test.cc b/source/blender/blenlib/tests/BLI_math_geom_test.cc
index ea86e5aa97e..44154d49128 100644
--- a/tests/gtests/blenlib/BLI_math_geom_test.cc
+++ b/source/blender/blenlib/tests/BLI_math_geom_test.cc
@@ -4,8 +4,6 @@
#include "BLI_math.h"
-#include "stubs/bf_intern_eigen_stubs.h"
-
TEST(math_geom, DistToLine2DSimple)
{
float p[2] = {5.0f, 1.0f}, a[2] = {0.0f, 0.0f}, b[2] = {2.0f, 0.0f};
diff --git a/tests/gtests/blenlib/BLI_math_matrix_test.cc b/source/blender/blenlib/tests/BLI_math_matrix_test.cc
index 9c47c02ceaf..2a4e0e98613 100644
--- a/tests/gtests/blenlib/BLI_math_matrix_test.cc
+++ b/source/blender/blenlib/tests/BLI_math_matrix_test.cc
@@ -45,8 +45,8 @@ TEST(math_matrix, interp_m4_m4m4_regular)
TEST(math_matrix, interp_m3_m3m3_singularity)
{
- /* A singluarity means that there is an axis mirror in the rotation component of the matrix. This
- * is reflected in its negative determinant.
+ /* A singularity means that there is an axis mirror in the rotation component of the matrix.
+ * This is reflected in its negative determinant.
*
* The interpolation of 4x4 matrices performs linear interpolation on the translation component,
* and then uses the 3x3 interpolation function to handle rotation and scale. As a result, this
diff --git a/tests/gtests/blenlib/BLI_math_vector_test.cc b/source/blender/blenlib/tests/BLI_math_vector_test.cc
index 7e75a521d4c..7e75a521d4c 100644
--- a/tests/gtests/blenlib/BLI_math_vector_test.cc
+++ b/source/blender/blenlib/tests/BLI_math_vector_test.cc
diff --git a/tests/gtests/blenlib/BLI_memiter_test.cc b/source/blender/blenlib/tests/BLI_memiter_test.cc
index 3cc86630005..3cc86630005 100644
--- a/tests/gtests/blenlib/BLI_memiter_test.cc
+++ b/source/blender/blenlib/tests/BLI_memiter_test.cc
diff --git a/tests/gtests/blenlib/BLI_path_util_test.cc b/source/blender/blenlib/tests/BLI_path_util_test.cc
index c9e6f3357ff..6cfebd0ea05 100644
--- a/tests/gtests/blenlib/BLI_path_util_test.cc
+++ b/source/blender/blenlib/tests/BLI_path_util_test.cc
@@ -2,57 +2,12 @@
#include "testing/testing.h"
-#include "../../../source/blender/imbuf/IMB_imbuf.h"
+#include "IMB_imbuf.h"
+
#include "BLI_fileops.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
-#ifdef _WIN32
-# include "../../../source/blender/blenkernel/BKE_global.h"
-#endif
-
-/* -------------------------------------------------------------------- */
-/* stubs */
-
-extern "C" {
-
-#if _WIN32
-Global G = {0};
-#endif
-
-const char *GHOST_getUserDir(int version, const char *versionstr);
-const char *GHOST_getSystemDir(int version, const char *versionstr);
-#ifdef __linux__
-char *zLhm65070058860608_br_find_exe(const char *default_exe);
-#endif
-
-const char *GHOST_getUserDir(int version, const char *versionstr)
-{
- return "/home/user";
-}
-
-const char *GHOST_getSystemDir(int version, const char *versionstr)
-{
- return "/system/path";
-}
-
-struct ImBuf;
-void IMB_freeImBuf(struct ImBuf *ibuf)
-{
-}
-struct ImBuf *IMB_dupImBuf(const ImBuf *ibuf)
-{
- return NULL;
-}
-
-#ifdef __linux__
-char *zLhm65070058860608_br_find_exe(const char *default_exe)
-{
- return NULL;
-}
-#endif
-}
-
/* -------------------------------------------------------------------- */
/* tests */
diff --git a/tests/gtests/blenlib/BLI_polyfill_2d_test.cc b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
index 527a23ac3a8..624a296e758 100644
--- a/tests/gtests/blenlib/BLI_polyfill_2d_test.cc
+++ b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
@@ -27,8 +27,6 @@
# include "BLI_polyfill_2d_beautify.h"
#endif
-#include "stubs/bf_intern_eigen_stubs.h"
-
static void polyfill_to_obj(const char *id,
const float poly[][2],
const unsigned int poly_tot,
@@ -58,7 +56,7 @@ static void test_valid_polyfill_prepare(unsigned int tris[][3], unsigned int tri
* - all tris set.
* - all verts used at least once.
*/
-static void test_polyfill_simple(const float poly[][2],
+static void test_polyfill_simple(const float /*poly*/[][2],
const unsigned int poly_tot,
const unsigned int tris[][3],
const unsigned int tris_tot)
@@ -81,7 +79,7 @@ static void test_polyfill_simple(const float poly[][2],
MEM_freeN(tot_used);
}
-static void test_polyfill_topology(const float poly[][2],
+static void test_polyfill_topology(const float /*poly*/[][2],
const unsigned int poly_tot,
const unsigned int tris[][3],
const unsigned int tris_tot)
@@ -127,7 +125,7 @@ static void test_polyfill_topology(const float poly[][2],
* Check all faces are flipped the same way
*/
static void test_polyfill_winding(const float poly[][2],
- const unsigned int poly_tot,
+ const unsigned int /*poly_tot*/,
const unsigned int tris[][3],
const unsigned int tris_tot)
{
diff --git a/tests/gtests/blenlib/BLI_ressource_strings.h b/source/blender/blenlib/tests/BLI_ressource_strings.h
index 119aaeb0036..119aaeb0036 100644
--- a/tests/gtests/blenlib/BLI_ressource_strings.h
+++ b/source/blender/blenlib/tests/BLI_ressource_strings.h
diff --git a/source/blender/blenlib/tests/BLI_session_uuid_test.cc b/source/blender/blenlib/tests/BLI_session_uuid_test.cc
new file mode 100644
index 00000000000..1a5f17be06c
--- /dev/null
+++ b/source/blender/blenlib/tests/BLI_session_uuid_test.cc
@@ -0,0 +1,20 @@
+/* Apache License, Version 2.0 */
+
+#include "testing/testing.h"
+
+#include "BLI_session_uuid.h"
+
+TEST(SessionUUID, GenerateBasic)
+{
+ {
+ const SessionUUID uuid = BLI_session_uuid_generate();
+ EXPECT_TRUE(BLI_session_uuid_is_generated(&uuid));
+ }
+
+ {
+ const SessionUUID uuid1 = BLI_session_uuid_generate();
+ const SessionUUID uuid2 = BLI_session_uuid_generate();
+
+ EXPECT_FALSE(BLI_session_uuid_is_equal(&uuid1, &uuid2));
+ }
+}
diff --git a/source/blender/blenlib/tests/BLI_set_test.cc b/source/blender/blenlib/tests/BLI_set_test.cc
index 7bd0b258df8..df3f7ab544c 100644
--- a/source/blender/blenlib/tests/BLI_set_test.cc
+++ b/source/blender/blenlib/tests/BLI_set_test.cc
@@ -452,6 +452,16 @@ TEST(set, LookupKeyPtr)
EXPECT_EQ(set.lookup_key_ptr({3, 50}), nullptr);
}
+TEST(set, StringViewKeys)
+{
+ Set<std::string_view> set;
+ set.add("hello");
+ set.add("world");
+ EXPECT_FALSE(set.contains("worlds"));
+ EXPECT_TRUE(set.contains("world"));
+ EXPECT_TRUE(set.contains("hello"));
+}
+
/**
* Set this to 1 to activate the benchmark. It is disabled by default, because it prints a lot.
*/
diff --git a/source/blender/blenlib/tests/BLI_span_test.cc b/source/blender/blenlib/tests/BLI_span_test.cc
index 587497624f4..6ad2a5633ad 100644
--- a/source/blender/blenlib/tests/BLI_span_test.cc
+++ b/source/blender/blenlib/tests/BLI_span_test.cc
@@ -197,7 +197,7 @@ TEST(span, SizeInBytes)
{
std::array<int, 10> a;
Span<int> a_span(a);
- EXPECT_EQ(a_span.size_in_bytes(), (int64_t)sizeof(a));
+ EXPECT_EQ(a_span.size_in_bytes(), static_cast<int64_t>(sizeof(a)));
EXPECT_EQ(a_span.size_in_bytes(), 40);
}
diff --git a/tests/gtests/blenlib/BLI_stack_test.cc b/source/blender/blenlib/tests/BLI_stack_test.cc
index 211916e3193..211916e3193 100644
--- a/tests/gtests/blenlib/BLI_stack_test.cc
+++ b/source/blender/blenlib/tests/BLI_stack_test.cc
diff --git a/source/blender/blenlib/tests/BLI_string_ref_test.cc b/source/blender/blenlib/tests/BLI_string_ref_test.cc
index d08c8a77455..2d488feff71 100644
--- a/source/blender/blenlib/tests/BLI_string_ref_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_ref_test.cc
@@ -254,6 +254,14 @@ TEST(string_ref, DropPrefix)
EXPECT_EQ(ref2, "t");
}
+TEST(string_ref, DropSuffix)
+{
+ StringRef ref("test");
+ StringRef ref2 = ref.drop_suffix(1);
+ EXPECT_EQ(ref2.size(), 3);
+ EXPECT_EQ(ref2, "tes");
+}
+
TEST(string_ref, Substr)
{
StringRef ref("hello world");
@@ -261,6 +269,8 @@ TEST(string_ref, Substr)
EXPECT_EQ(ref.substr(4, 0), "");
EXPECT_EQ(ref.substr(3, 4), "lo w");
EXPECT_EQ(ref.substr(6, 5), "world");
+ EXPECT_EQ(ref.substr(8), "rld");
+ EXPECT_EQ(ref.substr(8, 100), "rld");
}
TEST(string_ref, Copy)
@@ -274,4 +284,18 @@ TEST(string_ref, Copy)
EXPECT_EQ(ref, dst);
}
+TEST(string_ref, FromStringView)
+{
+ std::string_view view = "hello";
+ StringRef ref = view;
+ EXPECT_EQ(ref, "hello");
+}
+
+TEST(string_ref, ToStringView)
+{
+ StringRef ref = "hello";
+ std::string_view view = ref;
+ EXPECT_EQ(view, "hello");
+}
+
} // namespace blender::tests
diff --git a/tests/gtests/blenlib/BLI_string_test.cc b/source/blender/blenlib/tests/BLI_string_test.cc
index 0358a1611f2..1760b7966e3 100644
--- a/tests/gtests/blenlib/BLI_string_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_test.cc
@@ -20,25 +20,6 @@ using std::string;
using std::vector;
/* -------------------------------------------------------------------- */
-/* stubs */
-
-extern "C" {
-
-int mk_wcwidth(wchar_t ucs);
-int mk_wcswidth(const wchar_t *pwcs, size_t n);
-
-int mk_wcwidth(wchar_t ucs)
-{
- return 0;
-}
-
-int mk_wcswidth(const wchar_t *pwcs, size_t n)
-{
- return 0;
-}
-}
-
-/* -------------------------------------------------------------------- */
/* tests */
/* BLI_str_partition */
diff --git a/tests/gtests/blenlib/BLI_string_utf8_test.cc b/source/blender/blenlib/tests/BLI_string_utf8_test.cc
index c496f918dc0..96df4d2b71a 100644
--- a/tests/gtests/blenlib/BLI_string_utf8_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_utf8_test.cc
@@ -11,25 +11,6 @@
* quite their share of lines, they deserved their own file. */
/* -------------------------------------------------------------------- */
-/* stubs */
-
-extern "C" {
-
-int mk_wcwidth(wchar_t ucs);
-int mk_wcswidth(const wchar_t *pwcs, size_t n);
-
-int mk_wcwidth(wchar_t ucs)
-{
- return 0;
-}
-
-int mk_wcswidth(const wchar_t *pwcs, size_t n)
-{
- return 0;
-}
-}
-
-/* -------------------------------------------------------------------- */
/* tests */
/* Breaking strings is confusing here, prefer over-long lines. */
diff --git a/tests/gtests/blenlib/BLI_task_graph_test.cc b/source/blender/blenlib/tests/BLI_task_graph_test.cc
index efcbf923625..efcbf923625 100644
--- a/tests/gtests/blenlib/BLI_task_graph_test.cc
+++ b/source/blender/blenlib/tests/BLI_task_graph_test.cc
diff --git a/tests/gtests/blenlib/BLI_task_test.cc b/source/blender/blenlib/tests/BLI_task_test.cc
index 3abaf6a6c0b..3abaf6a6c0b 100644
--- a/tests/gtests/blenlib/BLI_task_test.cc
+++ b/source/blender/blenlib/tests/BLI_task_test.cc
diff --git a/tests/gtests/blenlib/BLI_ghash_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
index afabbcaae80..f93c40f05fb 100644
--- a/tests/gtests/blenlib/BLI_ghash_performance_test.cc
+++ b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
@@ -479,61 +479,7 @@ TEST(ghash, Int2NoHash50000000)
}
#endif
-/* Int_v2: 20M of randomly-generated integer vectors. */
-
-static void int2_ghash_tests(GHash *ghash, const char *id, const unsigned int nbr)
-{
- printf("\n========== STARTING %s ==========\n", id);
-
- void *data_v = MEM_mallocN(sizeof(unsigned int[2]) * (size_t)nbr, __func__);
- unsigned int(*data)[2] = (unsigned int(*)[2])data_v;
- unsigned int(*dt)[2];
- unsigned int i, j;
-
- {
- RNG *rng = BLI_rng_new(1);
- for (i = nbr, dt = data; i--; dt++) {
- for (j = 2; j--;) {
- (*dt)[j] = BLI_rng_get_uint(rng);
- }
- }
- BLI_rng_free(rng);
- }
-
- {
- TIMEIT_START(int_v2_insert);
-
-#ifdef GHASH_RESERVE
- BLI_ghash_reserve(ghash, nbr);
-#endif
-
- for (i = nbr, dt = data; i--; dt++) {
- BLI_ghash_insert(ghash, *dt, POINTER_FROM_UINT(i));
- }
-
- TIMEIT_END(int_v2_insert);
- }
-
- PRINTF_GHASH_STATS(ghash);
-
- {
- TIMEIT_START(int_v2_lookup);
-
- for (i = nbr, dt = data; i--; dt++) {
- void *v = BLI_ghash_lookup(ghash, (void *)(*dt));
- EXPECT_EQ(POINTER_AS_UINT(v), i);
- }
-
- TIMEIT_END(int_v2_lookup);
- }
-
- BLI_ghash_free(ghash, NULL, NULL);
- MEM_freeN(data);
-
- printf("========== ENDED %s ==========\n\n", id);
-}
-
-/* MultiSmall: create and manipulate a lot of very small ghashes
+/* MultiSmall: create and manipulate a lot of very small ghash's
* (90% < 10 items, 9% < 100 items, 1% < 1000 items). */
static void multi_small_ghash_tests_one(GHash *ghash, RNG *rng, const unsigned int nbr)
diff --git a/tests/gtests/blenlib/BLI_task_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
index 208f168b599..208f168b599 100644
--- a/tests/gtests/blenlib/BLI_task_performance_test.cc
+++ b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc
diff --git a/tests/gtests/guardedalloc/CMakeLists.txt b/source/blender/blenlib/tests/performance/CMakeLists.txt
index 6ca444f28b3..88fbed0a49b 100644
--- a/tests/gtests/guardedalloc/CMakeLists.txt
+++ b/source/blender/blenlib/tests/performance/CMakeLists.txt
@@ -21,15 +21,13 @@
set(INC
.
..
- ../../../intern/guardedalloc
- ../../../source/blender/blenlib
)
+setup_libdirs()
include_directories(${INC})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
-
-BLENDER_TEST(guardedalloc_alignment "")
-BLENDER_TEST(guardedalloc_overflow "")
+BLENDER_TEST_PERFORMANCE(BLI_ghash_performance "bf_blenlib")
+BLENDER_TEST_PERFORMANCE(BLI_task_performance "bf_blenlib")
diff --git a/source/blender/blenloader/BLO_blend_defs.h b/source/blender/blenloader/BLO_blend_defs.h
index fec61605dca..40da63f20e8 100644
--- a/source/blender/blenloader/BLO_blend_defs.h
+++ b/source/blender/blenloader/BLO_blend_defs.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLO_BLEND_DEFS_H__
-#define __BLO_BLEND_DEFS_H__
+#pragma once
/** \file
* \ingroup blenloader
@@ -72,5 +71,3 @@ enum {
};
#define BLEN_THUMB_MEMSIZE_FILE(_x, _y) (sizeof(int) * (2 + (size_t)(_x) * (size_t)(_y)))
-
-#endif /* __BLO_BLEND_DEFS_H__ */
diff --git a/source/blender/blenloader/BLO_blend_validate.h b/source/blender/blenloader/BLO_blend_validate.h
index 1ffaddef02f..78aa481d4b1 100644
--- a/source/blender/blenloader/BLO_blend_validate.h
+++ b/source/blender/blenloader/BLO_blend_validate.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLO_BLEND_VALIDATE_H__
-#define __BLO_BLEND_VALIDATE_H__
+#pragma once
/** \file
* \ingroup blenloader
@@ -31,5 +30,3 @@ struct ReportList;
bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports);
bool BLO_main_validate_shapekeys(struct Main *bmain, struct ReportList *reports);
-
-#endif
diff --git a/source/blender/blenloader/BLO_read_write.h b/source/blender/blenloader/BLO_read_write.h
index 7c9738b67c5..024b6a6c5e4 100644
--- a/source/blender/blenloader/BLO_read_write.h
+++ b/source/blender/blenloader/BLO_read_write.h
@@ -38,8 +38,7 @@
* necessary.
*/
-#ifndef __BLO_READ_WRITE_H__
-#define __BLO_READ_WRITE_H__
+#pragma once
/* for SDNA_TYPE_FROM_STRUCT() macro */
#include "dna_type_offsets.h"
@@ -223,5 +222,3 @@ void BLO_expand_id(BlendExpander *expander, struct ID *id);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLO_READ_WRITE_H__ */
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index e4908eb7257..97c77ed2e19 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __BLO_READFILE_H__
-#define __BLO_READFILE_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -196,5 +195,3 @@ extern const struct UserDef U_default;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BLO_READFILE_H__ */
diff --git a/source/blender/blenloader/BLO_undofile.h b/source/blender/blenloader/BLO_undofile.h
index f9300f8a521..f5527c13429 100644
--- a/source/blender/blenloader/BLO_undofile.h
+++ b/source/blender/blenloader/BLO_undofile.h
@@ -18,8 +18,7 @@
* external writefile function prototypes
*/
-#ifndef __BLO_UNDOFILE_H__
-#define __BLO_UNDOFILE_H__
+#pragma once
/** \file
* \ingroup blenloader
@@ -85,5 +84,3 @@ extern struct Main *BLO_memfile_main_get(struct MemFile *memfile,
struct Main *bmain,
struct Scene **r_scene);
extern bool BLO_memfile_write_file(struct MemFile *memfile, const char *filename);
-
-#endif /* __BLO_UNDOFILE_H__ */
diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h
index 8fe04e764f9..746c663926d 100644
--- a/source/blender/blenloader/BLO_writefile.h
+++ b/source/blender/blenloader/BLO_writefile.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BLO_WRITEFILE_H__
-#define __BLO_WRITEFILE_H__
+#pragma once
/** \file
* \ingroup blenloader
@@ -73,5 +72,3 @@ extern bool BLO_write_file_mem(struct Main *mainvar,
int write_flags);
/** \} */
-
-#endif
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 7eab0651d97..c56e0b5ad2e 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -98,3 +98,17 @@ blender_add_lib(bf_blenloader "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# needed so writefile.c can use dna_type_offsets.h
add_dependencies(bf_blenloader bf_dna)
+
+if(WITH_GTESTS)
+ set(TEST_SRC
+ tests/blendfile_loading_base_test.cc
+ tests/blendfile_load_test.cc
+ )
+ set(TEST_INC
+ )
+ set(TEST_LIB
+ bf_blenloader
+ )
+ include(GTestTesting)
+ blender_add_test_lib(bf_blenloader_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
+endif()
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index cb2094d050f..888863dda06 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -102,28 +102,27 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
if (bhead->code == ENDB) {
break;
}
- else {
- const short *sp = fd->filesdna->structs[bhead->SDNAnr];
- const char *name = fd->filesdna->types[sp[0]];
- char buf[4];
-
- buf[0] = (bhead->code >> 24) & 0xFF;
- buf[1] = (bhead->code >> 16) & 0xFF;
- buf[2] = (bhead->code >> 8) & 0xFF;
- buf[3] = (bhead->code >> 0) & 0xFF;
-
- buf[0] = buf[0] ? buf[0] : ' ';
- buf[1] = buf[1] ? buf[1] : ' ';
- buf[2] = buf[2] ? buf[2] : ' ';
- buf[3] = buf[3] ? buf[3] : ' ';
-
- fprintf(fp,
- "['%.4s', '%s', %d, %ld ],\n",
- buf,
- name,
- bhead->nr,
- (long int)(bhead->len + sizeof(BHead)));
- }
+
+ const short *sp = fd->filesdna->structs[bhead->SDNAnr];
+ const char *name = fd->filesdna->types[sp[0]];
+ char buf[4];
+
+ buf[0] = (bhead->code >> 24) & 0xFF;
+ buf[1] = (bhead->code >> 16) & 0xFF;
+ buf[2] = (bhead->code >> 8) & 0xFF;
+ buf[3] = (bhead->code >> 0) & 0xFF;
+
+ buf[0] = buf[0] ? buf[0] : ' ';
+ buf[1] = buf[1] ? buf[1] : ' ';
+ buf[2] = buf[2] ? buf[2] : ' ';
+ buf[3] = buf[3] ? buf[3] : ' ';
+
+ fprintf(fp,
+ "['%.4s', '%s', %d, %ld ],\n",
+ buf,
+ name,
+ bhead->nr,
+ (long int)(bhead->len + sizeof(BHead)));
}
fprintf(fp, "]\n");
}
@@ -268,7 +267,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
if (bhead->code == ENDB) {
break;
}
- else if (BKE_idtype_idcode_is_valid(bhead->code)) {
+ if (BKE_idtype_idcode_is_valid(bhead->code)) {
if (BKE_idtype_idcode_is_linkable(bhead->code)) {
const char *str = BKE_idtype_idcode_to_name(bhead->code);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index b37029726f4..42b97550db1 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -373,7 +373,7 @@ static void oldnewmap_insert_or_replace(OldNewMap *onm, OldNew entry)
onm->nentries++;
break;
}
- else if (onm->entries[index].oldp == entry.oldp) {
+ if (onm->entries[index].oldp == entry.oldp) {
onm->entries[index] = entry;
break;
}
@@ -1112,9 +1112,8 @@ static bool read_file_dna(FileData *fd, const char **r_error_message)
return true;
}
- else {
- return false;
- }
+
+ return false;
}
else if (bhead->code == ENDB) {
break;
@@ -1135,7 +1134,7 @@ static int *read_file_thumbnail(FileData *fd)
const bool do_endian_swap = (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0;
int *data = (int *)(bhead + 1);
- if (bhead->len < (2 * sizeof(int))) {
+ if (bhead->len < (sizeof(int[2]))) {
break;
}
@@ -1156,7 +1155,7 @@ static int *read_file_thumbnail(FileData *fd)
blend_thumb = data;
break;
}
- else if (bhead->code != REND) {
+ if (bhead->code != REND) {
/* Thumbnail is stored in TEST immediately after first REND... */
break;
}
@@ -1187,7 +1186,7 @@ static int fd_read_data_from_file(FileData *filedata,
filedata->file_offset += readsize;
}
- return (readsize);
+ return readsize;
}
static off64_t fd_seek_data_from_file(FileData *filedata, off64_t offset, int whence)
@@ -1212,7 +1211,7 @@ static int fd_read_gzip_from_file(FileData *filedata,
filedata->file_offset += readsize;
}
- return (readsize);
+ return readsize;
}
/* Memory reading. */
@@ -1228,7 +1227,7 @@ static int fd_read_from_memory(FileData *filedata,
memcpy(buffer, filedata->buffer + filedata->file_offset, readsize);
filedata->file_offset += readsize;
- return (readsize);
+ return readsize;
}
/* MemFile reading. */
@@ -1373,9 +1372,8 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath,
errno ? strerror(errno) : TIP_("insufficient content"));
return NULL;
}
- else {
- BLI_lseek(file, 0, SEEK_SET);
- }
+
+ BLI_lseek(file, 0, SEEK_SET);
/* Regular file. */
if (memcmp(header, "BLENDER", sizeof(header)) == 0) {
@@ -1397,12 +1395,11 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath,
errno ? strerror(errno) : TIP_("unknown error reading file"));
return NULL;
}
- else {
- /* 'seek_fn' is too slow for gzip, don't set it. */
- read_fn = fd_read_gzip_from_file;
- /* Caller must close. */
- file = -1;
- }
+
+ /* 'seek_fn' is too slow for gzip, don't set it. */
+ read_fn = fd_read_gzip_from_file;
+ /* Caller must close. */
+ file = -1;
}
if (read_fn == NULL) {
@@ -1487,14 +1484,14 @@ static int fd_read_gzip_from_memory(FileData *filedata,
if (err == Z_STREAM_END) {
return 0;
}
- else if (err != Z_OK) {
+ if (err != Z_OK) {
printf("fd_read_gzip_from_memory: zlib error\n");
return 0;
}
filedata->file_offset += size;
- return (size);
+ return size;
}
static int fd_read_gzip_from_memory_init(FileData *fd)
@@ -1521,28 +1518,27 @@ FileData *blo_filedata_from_memory(const void *mem, int memsize, ReportList *rep
BKE_report(reports, RPT_WARNING, (mem) ? TIP_("Unable to read") : TIP_("Unable to open"));
return NULL;
}
- else {
- FileData *fd = filedata_new();
- const char *cp = mem;
- fd->buffer = mem;
- fd->buffersize = memsize;
+ FileData *fd = filedata_new();
+ const char *cp = mem;
- /* test if gzip */
- if (cp[0] == 0x1f && cp[1] == 0x8b) {
- if (0 == fd_read_gzip_from_memory_init(fd)) {
- blo_filedata_free(fd);
- return NULL;
- }
- }
- else {
- fd->read = fd_read_from_memory;
+ fd->buffer = mem;
+ fd->buffersize = memsize;
+
+ /* test if gzip */
+ if (cp[0] == 0x1f && cp[1] == 0x8b) {
+ if (0 == fd_read_gzip_from_memory_init(fd)) {
+ blo_filedata_free(fd);
+ return NULL;
}
+ }
+ else {
+ fd->read = fd_read_from_memory;
+ }
- fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
+ fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
- return blo_decode_and_check(fd, reports);
- }
+ return blo_decode_and_check(fd, reports);
}
FileData *blo_filedata_from_memfile(MemFile *memfile,
@@ -1553,16 +1549,15 @@ FileData *blo_filedata_from_memfile(MemFile *memfile,
BKE_report(reports, RPT_WARNING, "Unable to open blend <memory>");
return NULL;
}
- else {
- FileData *fd = filedata_new();
- fd->memfile = memfile;
- fd->undo_direction = params->undo_direction;
- fd->read = fd_read_from_memfile;
- fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
+ FileData *fd = filedata_new();
+ fd->memfile = memfile;
+ fd->undo_direction = params->undo_direction;
+
+ fd->read = fd_read_from_memfile;
+ fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
- return blo_decode_and_check(fd, reports);
- }
+ return blo_decode_and_check(fd, reports);
}
void blo_filedata_free(FileData *fd)
@@ -1695,7 +1690,7 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha
if (BLO_has_bfile_extension(r_dir) && BLI_is_file(r_dir)) {
break;
}
- else if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) {
+ if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) {
break;
}
@@ -5145,6 +5140,9 @@ static void direct_link_pose(BlendDataReader *reader, bPose *pose)
pose->chan_array = NULL;
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ BKE_pose_channel_runtime_reset(&pchan->runtime);
+ BKE_pose_channel_session_uuid_generate(pchan);
+
pchan->bone = NULL;
BLO_read_data_address(reader, &pchan->parent);
BLO_read_data_address(reader, &pchan->child);
@@ -5170,7 +5168,6 @@ static void direct_link_pose(BlendDataReader *reader, bPose *pose)
CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
pchan->draw_data = NULL;
- BKE_pose_channel_runtime_reset(&pchan->runtime);
}
pose->ikdata = NULL;
if (pose->ikparam != NULL) {
@@ -5299,6 +5296,8 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object
BLO_read_list(reader, lb);
for (md = lb->first; md; md = md->next) {
+ BKE_modifier_session_uuid_generate(md);
+
md->error = NULL;
md->runtime = NULL;
@@ -5516,7 +5515,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
if (gpmd->curve_intensity) {
BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
/* initialize the curve. Maybe this could be moved to modififer logic */
- BKE_curvemapping_initialize(gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
}
else if (md->type == eGpencilModifierType_Thick) {
@@ -5525,7 +5524,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_thickness);
if (gpmd->curve_thickness) {
BKE_curvemapping_blend_read(reader, gpmd->curve_thickness);
- BKE_curvemapping_initialize(gpmd->curve_thickness);
+ BKE_curvemapping_init(gpmd->curve_thickness);
}
}
else if (md->type == eGpencilModifierType_Tint) {
@@ -5534,7 +5533,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_initialize(gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
}
else if (md->type == eGpencilModifierType_Smooth) {
@@ -5542,7 +5541,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_initialize(gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
}
else if (md->type == eGpencilModifierType_Color) {
@@ -5550,7 +5549,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_initialize(gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
}
else if (md->type == eGpencilModifierType_Opacity) {
@@ -5558,7 +5557,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
- BKE_curvemapping_initialize(gpmd->curve_intensity);
+ BKE_curvemapping_init(gpmd->curve_intensity);
}
}
}
@@ -6030,7 +6029,7 @@ static void direct_link_lightcache_texture(BlendDataReader *reader, LightCacheTe
if (lctex->data) {
BLO_read_data_address(reader, &lctex->data);
- if (BLO_read_requires_endian_switch(reader)) {
+ if (lctex->data && BLO_read_requires_endian_switch(reader)) {
int data_size = lctex->components * lctex->tex_size[0] * lctex->tex_size[1] *
lctex->tex_size[2];
@@ -6042,10 +6041,15 @@ static void direct_link_lightcache_texture(BlendDataReader *reader, LightCacheTe
}
}
}
+
+ if (lctex->data == NULL) {
+ zero_v3_int(lctex->tex_size);
+ }
}
static void direct_link_lightcache(BlendDataReader *reader, LightCache *cache)
{
+ cache->flag &= ~LIGHTCACHE_NOT_USABLE;
direct_link_lightcache_texture(reader, &cache->cube_tx);
direct_link_lightcache_texture(reader, &cache->grid_tx);
@@ -6086,6 +6090,14 @@ static bool scene_validate_setscene__liblink(Scene *sce, const int totscene)
}
for (a = 0, sce_iter = sce; sce_iter->set; sce_iter = sce_iter->set, a++) {
+ /* This runs per library (before each libraries #Main has been joined),
+ * so we can't step into other libraries since `totscene` is only for this library.
+ *
+ * Also, other libraries may not have been linked yet,
+ * while we could check #LIB_TAG_NEED_LINK the library pointer check is sufficient. */
+ if (sce->id.lib != sce_iter->id.lib) {
+ return true;
+ }
if (sce_iter->flag & SCE_READFILE_LIBLINK_NEED_SETSCENE_CHECK) {
return true;
}
@@ -6461,6 +6473,9 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
link_recurs_seq(reader, &ed->seqbase);
SEQ_BEGIN (ed, seq) {
+ /* Do as early as possible, so that other parts of reading can rely on valid session UUID. */
+ BKE_sequence_session_uuid_generate(seq);
+
BLO_read_data_address(reader, &seq->seq1);
BLO_read_data_address(reader, &seq->seq2);
BLO_read_data_address(reader, &seq->seq3);
@@ -6951,31 +6966,31 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
BLO_read_data_address(reader, &snla->ads);
}
else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soops = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
/* use newdataadr_no_us and do not free old memory avoiding double
* frees and use of freed memory. this could happen because of a
* bug fixed in revision 58959 where the treestore memory address
* was not unique */
- TreeStore *ts = newdataadr_no_us(reader->fd, soops->treestore);
- soops->treestore = NULL;
+ TreeStore *ts = newdataadr_no_us(reader->fd, space_outliner->treestore);
+ space_outliner->treestore = NULL;
if (ts) {
TreeStoreElem *elems = newdataadr_no_us(reader->fd, ts->data);
- soops->treestore = BLI_mempool_create(
+ space_outliner->treestore = BLI_mempool_create(
sizeof(TreeStoreElem), ts->usedelem, 512, BLI_MEMPOOL_ALLOW_ITER);
if (ts->usedelem && elems) {
int i;
for (i = 0; i < ts->usedelem; i++) {
- TreeStoreElem *new_elem = BLI_mempool_alloc(soops->treestore);
+ TreeStoreElem *new_elem = BLI_mempool_alloc(space_outliner->treestore);
*new_elem = elems[i];
}
}
/* we only saved what was used */
- soops->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
+ space_outliner->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
}
- soops->treehash = NULL;
- soops->tree.first = soops->tree.last = NULL;
+ space_outliner->treehash = NULL;
+ space_outliner->tree.first = space_outliner->tree.last = NULL;
}
else if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
@@ -7202,20 +7217,20 @@ static void lib_link_area(BlendLibReader *reader, ID *parent_id, ScrArea *area)
break;
}
case SPACE_OUTLINER: {
- SpaceOutliner *so = (SpaceOutliner *)sl;
- BLO_read_id_address(reader, NULL, &so->search_tse.id);
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ BLO_read_id_address(reader, NULL, &space_outliner->search_tse.id);
- if (so->treestore) {
+ if (space_outliner->treestore) {
TreeStoreElem *tselem;
BLI_mempool_iter iter;
- BLI_mempool_iternew(so->treestore, &iter);
+ BLI_mempool_iternew(space_outliner->treestore, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
BLO_read_id_address(reader, NULL, &tselem->id);
}
- if (so->treehash) {
+ if (space_outliner->treehash) {
/* rebuild hash table, because it depends on ids too */
- so->storeflag |= SO_TREESTORE_REBUILD;
+ space_outliner->storeflag |= SO_TREESTORE_REBUILD;
}
}
break;
@@ -7774,15 +7789,16 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
}
}
else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
- so->search_tse.id = restore_pointer_by_name(id_map, so->search_tse.id, USER_IGNORE);
+ space_outliner->search_tse.id = restore_pointer_by_name(
+ id_map, space_outliner->search_tse.id, USER_IGNORE);
- if (so->treestore) {
+ if (space_outliner->treestore) {
TreeStoreElem *tselem;
BLI_mempool_iter iter;
- BLI_mempool_iternew(so->treestore, &iter);
+ BLI_mempool_iternew(space_outliner->treestore, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
/* Do not try to restore pointers to drivers/sequence/etc.,
* can crash in undo case! */
@@ -7793,9 +7809,9 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
tselem->id = NULL;
}
}
- if (so->treehash) {
+ if (space_outliner->treehash) {
/* rebuild hash table, because it depends on ids too */
- so->storeflag |= SO_TREESTORE_REBUILD;
+ space_outliner->storeflag |= SO_TREESTORE_REBUILD;
}
}
}
@@ -9235,17 +9251,16 @@ static bool read_libblock_undo_restore(
*r_id_old = id_old;
return true;
}
- else if (id_old != NULL) {
+ if (id_old != NULL) {
/* Local datablock was changed. Restore at the address of the old datablock. */
DEBUG_PRINTF("read to old existing address\n");
*r_id_old = id_old;
return false;
}
- else {
- /* Local datablock does not exist in the undo step, so read from scratch. */
- DEBUG_PRINTF("read at new address\n");
- return false;
- }
+
+ /* Local datablock does not exist in the undo step, so read from scratch. */
+ DEBUG_PRINTF("read at new address\n");
+ return false;
}
/* This routine reads a datablock and its direct data, and advances bhead to
@@ -10016,7 +10031,7 @@ static int verg_bheadsort(const void *v1, const void *v2)
if (x1->old > x2->old) {
return 1;
}
- else if (x1->old < x2->old) {
+ if (x1->old < x2->old) {
return -1;
}
return 0;
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index f8c91c77634..34a670a8357 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -22,8 +22,7 @@
* \ingroup blenloader
*/
-#ifndef __READFILE_H__
-#define __READFILE_H__
+#pragma once
#include "DNA_sdna_types.h"
#include "DNA_space_types.h"
@@ -199,5 +198,3 @@ void do_versions_after_linking_270(struct Main *bmain);
void do_versions_after_linking_280(struct Main *bmain, struct ReportList *reports);
void do_versions_after_linking_290(struct Main *bmain, struct ReportList *reports);
void do_versions_after_linking_cycles(struct Main *bmain);
-
-#endif
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 3ed59a0baa1..0e753c84476 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -270,9 +270,9 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb)
break;
case SPACE_OUTLINER: {
- SpaceOutliner *soops = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
- memcpy(&region->v2d, &soops->v2d, sizeof(View2D));
+ memcpy(&region->v2d, &space_outliner->v2d, sizeof(View2D));
region->v2d.scroll &= ~V2D_SCROLL_LEFT;
region->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
@@ -280,7 +280,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb)
region->v2d.keepzoom |= (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_KEEPASPECT);
region->v2d.keeptot = V2D_KEEPTOT_STRICT;
region->v2d.minzoom = region->v2d.maxzoom = 1.0f;
- // region->v2d.flag |= V2D_IS_INITIALISED;
+ // region->v2d.flag |= V2D_IS_INIT;
break;
}
case SPACE_GRAPH: {
@@ -297,7 +297,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb)
region->v2d.max[0] = MAXFRAMEF;
region->v2d.max[1] = FLT_MAX;
- // region->v2d.flag |= V2D_IS_INITIALISED;
+ // region->v2d.flag |= V2D_IS_INIT;
break;
}
case SPACE_NLA: {
@@ -355,7 +355,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb)
region->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HANDLES);
region->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_VERTICAL_HANDLES);
region->v2d.align = V2D_ALIGN_NO_NEG_Y;
- region->v2d.flag |= V2D_IS_INITIALISED;
+ region->v2d.flag |= V2D_IS_INIT;
break;
}
case SPACE_NODE: {
@@ -635,6 +635,7 @@ static void do_versions_socket_default_value_259(bNodeSocket *sock)
}
}
+/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
@@ -965,7 +966,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
bPoseChannel *pchan;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- /* just need to initialise rotation axis properly... */
+ /* Just need to initialize rotation axis properly. */
pchan->rotAxis[1] = 1.0f;
}
}
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 5e91fea3e20..1ac90398c0a 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -658,6 +658,7 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro
}
}
+/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
if (bmain->versionfile < 260) {
@@ -1205,7 +1206,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (region->regiontype == RGN_TYPE_PREVIEW) {
if (region->alignment != RGN_ALIGN_NONE) {
region->flag |= RGN_FLAG_HIDDEN;
- region->v2d.flag &= ~V2D_IS_INITIALISED;
+ region->v2d.flag &= ~V2D_IS_INIT;
region->alignment = RGN_ALIGN_NONE;
hide = true;
@@ -2348,10 +2349,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (area = screen->areabase.first; area; area = area->next) {
for (sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
-
- if (!ELEM(so->outlinevis, SO_SCENES, SO_LIBRARIES, SO_SEQUENCE, SO_DATA_API)) {
- so->outlinevis = SO_SCENES;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+
+ if (!ELEM(space_outliner->outlinevis,
+ SO_SCENES,
+ SO_LIBRARIES,
+ SO_SEQUENCE,
+ SO_DATA_API)) {
+ space_outliner->outlinevis = SO_SCENES;
}
}
}
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 521fc4b9b82..b19c6221391 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -242,7 +242,7 @@ static void do_version_action_editor_properties_region(ListBase *regionbase)
/* already exists */
return;
}
- else if (region->regiontype == RGN_TYPE_WINDOW) {
+ if (region->regiontype == RGN_TYPE_WINDOW) {
/* add new region here */
ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
@@ -377,9 +377,8 @@ static char *replace_bbone_easing_rnapath(char *old_path)
MEM_freeN(old_path);
return new_path;
}
- else {
- return old_path;
- }
+
+ return old_path;
}
static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id),
@@ -421,6 +420,7 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id),
}
}
+/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
if (!MAIN_VERSION_ATLEAST(bmain, 270, 0)) {
@@ -1108,7 +1108,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve;
BKE_curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(curve_mapping);
+ BKE_curvemapping_init(curve_mapping);
BKE_curvemap_reset(
curve_mapping->cm, &curve_mapping->clipr, CURVE_PRESET_MAX, CURVEMAP_SLOPE_POS_NEG);
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 111ac728cc3..fced95ee629 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -190,7 +190,7 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
static void do_version_area_change_space_to_space_action(ScrArea *area, const Scene *scene)
{
SpaceType *stype = BKE_spacetype_from_id(SPACE_ACTION);
- SpaceAction *saction = (SpaceAction *)stype->new (area, scene);
+ SpaceAction *saction = (SpaceAction *)stype->create(area, scene);
ARegion *region_channels;
/* Properly free current regions */
@@ -1201,7 +1201,7 @@ static void do_version_fcurve_hide_viewport_fix(struct ID *UNUSED(id),
struct FCurve *fcu,
void *UNUSED(user_data))
{
- if (strcmp(fcu->rna_path, "hide")) {
+ if (!STREQ(fcu->rna_path, "hide")) {
return;
}
@@ -1282,20 +1282,20 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
if (space->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soutliner = (SpaceOutliner *)space;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)space;
- soutliner->outlinevis = SO_VIEW_LAYER;
+ space_outliner->outlinevis = SO_VIEW_LAYER;
if (BLI_listbase_count_at_most(&layer->layer_collections, 2) == 1) {
- if (soutliner->treestore == NULL) {
- soutliner->treestore = BLI_mempool_create(
+ if (space_outliner->treestore == NULL) {
+ space_outliner->treestore = BLI_mempool_create(
sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
}
/* Create a tree store element for the collection. This is normally
* done in check_persistent (outliner_tree.c), but we need to access
* it here :/ (expand element if it's the only one) */
- TreeStoreElem *tselem = BLI_mempool_calloc(soutliner->treestore);
+ TreeStoreElem *tselem = BLI_mempool_calloc(space_outliner->treestore);
tselem->type = TSE_LAYER_COLLECTION;
tselem->id = layer->layer_collections.first;
tselem->nr = tselem->used = 0;
@@ -1792,6 +1792,7 @@ static void do_versions_seq_set_cache_defaults(Editing *ed)
ed->recycle_max_cost = 10.0f;
}
+/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
bool use_collection_compat_28 = true;
@@ -1958,7 +1959,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
if ((gset) && (gset->cur_falloff == NULL)) {
gset->cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(gset->cur_falloff);
+ BKE_curvemapping_init(gset->cur_falloff);
BKE_curvemap_reset(gset->cur_falloff->cm,
&gset->cur_falloff->clipr,
CURVE_PRESET_GAUSS,
@@ -2024,15 +2025,15 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (area = screen->areabase.first; area; area = area->next) {
for (sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
- if (!ELEM(so->outlinevis,
+ if (!ELEM(space_outliner->outlinevis,
SO_SCENES,
SO_LIBRARIES,
SO_SEQUENCE,
SO_DATA_API,
SO_ID_ORPHANS)) {
- so->outlinevis = SO_VIEW_LAYER;
+ space_outliner->outlinevis = SO_VIEW_LAYER;
}
}
}
@@ -2412,9 +2413,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soops = (SpaceOutliner *)sl;
- soops->filter_id_type = ID_GR;
- soops->outlinevis = SO_VIEW_LAYER;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ space_outliner->filter_id_type = ID_GR;
+ space_outliner->outlinevis = SO_VIEW_LAYER;
}
}
}
@@ -3341,7 +3342,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
- memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char) * 256);
+ memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char[256]));
}
}
}
@@ -3371,7 +3372,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
if ((gset) && (gset->cur_primitive == NULL)) {
gset->cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- BKE_curvemapping_initialize(gset->cur_primitive);
+ BKE_curvemapping_init(gset->cur_primitive);
BKE_curvemap_reset(gset->cur_primitive->cm,
&gset->cur_primitive->clipr,
CURVE_PRESET_BELL,
@@ -3411,9 +3412,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
break;
}
case SPACE_OUTLINER: {
- SpaceOutliner *so = (SpaceOutliner *)sl;
- so->filter &= ~(SO_FILTER_UNUSED_1 | SO_FILTER_UNUSED_5 | SO_FILTER_UNUSED_12);
- so->storeflag &= ~(SO_TREESTORE_UNUSED_1);
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ space_outliner->filter &= ~(SO_FILTER_UNUSED_1 | SO_FILTER_UNUSED_5 |
+ SO_FILTER_UNUSED_12);
+ space_outliner->storeflag &= ~(SO_TREESTORE_UNUSED_1);
break;
}
case SPACE_FILE: {
@@ -4027,9 +4029,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (sl->spacetype != SPACE_OUTLINER) {
continue;
}
- SpaceOutliner *so = (SpaceOutliner *)sl;
- so->filter &= ~SO_FLAG_UNUSED_1;
- so->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ space_outliner->filter &= ~SO_FLAG_UNUSED_1;
+ space_outliner->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE;
}
}
}
@@ -4161,9 +4163,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
/* Mark outliners as dirty for syncing and enable synced selection */
if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soutliner = (SpaceOutliner *)sl;
- soutliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL;
- soutliner->flag |= SO_SYNC_SELECT;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ space_outliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL;
+ space_outliner->flag |= SO_SYNC_SELECT;
}
}
}
@@ -4767,7 +4769,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (mmd->curve_intensity == NULL) {
mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (mmd->curve_intensity) {
- BKE_curvemapping_initialize(mmd->curve_intensity);
+ BKE_curvemapping_init(mmd->curve_intensity);
}
}
break;
@@ -4778,7 +4780,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (mmd->curve_intensity == NULL) {
mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (mmd->curve_intensity) {
- BKE_curvemapping_initialize(mmd->curve_intensity);
+ BKE_curvemapping_init(mmd->curve_intensity);
}
}
break;
@@ -4788,7 +4790,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (mmd->curve_intensity == NULL) {
mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (mmd->curve_intensity) {
- BKE_curvemapping_initialize(mmd->curve_intensity);
+ BKE_curvemapping_init(mmd->curve_intensity);
}
}
break;
@@ -4798,7 +4800,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (mmd->curve_intensity == NULL) {
mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (mmd->curve_intensity) {
- BKE_curvemapping_initialize(mmd->curve_intensity);
+ BKE_curvemapping_init(mmd->curve_intensity);
}
}
break;
@@ -4808,7 +4810,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (mmd->curve_intensity == NULL) {
mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (mmd->curve_intensity) {
- BKE_curvemapping_initialize(mmd->curve_intensity);
+ BKE_curvemapping_init(mmd->curve_intensity);
}
}
break;
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index b6caa018756..12b5a297df5 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -22,12 +22,15 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_brush_types.h"
+#include "DNA_cachefile_types.h"
#include "DNA_constraint_types.h"
#include "DNA_genfile.h"
#include "DNA_gpencil_modifier_types.h"
+#include "DNA_gpencil_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
@@ -35,6 +38,7 @@
#include "BKE_collection.h"
#include "BKE_colortools.h"
+#include "BKE_gpencil.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_node.h"
@@ -183,6 +187,23 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
}
}
}
+
+ /* Patch first frame for old files. */
+ Scene *scene = bmain->scenes.first;
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
+ if (ob->type != OB_GPENCIL) {
+ continue;
+ }
+ bGPdata *gpd = ob->data;
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ bGPDframe *gpf = gpl->frames.first;
+ if (gpf && gpf->framenum > scene->r.sfra) {
+ bGPDframe *gpf_dup = BKE_gpencil_frame_duplicate(gpf);
+ gpf_dup->framenum = scene->r.sfra;
+ BLI_addhead(&gpl->frames, gpf_dup);
+ }
+ }
+ }
}
/**
@@ -427,5 +448,39 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ /* Initialise additional velocity parameter for CacheFiles. */
+ if (!DNA_struct_elem_find(
+ fd->filesdna, "MeshSeqCacheModifierData", "float", "velocity_scale")) {
+ for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
+ LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
+ if (md->type == eModifierType_MeshSequenceCache) {
+ MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
+ mcmd->velocity_scale = 1.0f;
+ mcmd->vertex_velocities = NULL;
+ mcmd->num_vertices = 0;
+ }
+ }
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "CacheFile", "char", "velocity_unit")) {
+ for (CacheFile *cache_file = bmain->cachefiles.first; cache_file != NULL;
+ cache_file = cache_file->id.next) {
+ BLI_strncpy(cache_file->velocity_name, ".velocities", sizeof(cache_file->velocity_name));
+ cache_file->velocity_unit = CACHEFILE_VELOCITY_UNIT_SECOND;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "OceanModifierData", "int", "viewport_resolution")) {
+ for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
+ LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
+ if (md->type == eModifierType_Ocean) {
+ OceanModifierData *omd = (OceanModifierData *)md;
+ omd->viewport_resolution = omd->resolution;
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c
index 46faddf6e5a..26329fca6fa 100644
--- a/source/blender/blenloader/intern/versioning_cycles.c
+++ b/source/blender/blenloader/intern/versioning_cycles.c
@@ -1447,7 +1447,7 @@ void do_versions_after_linking_cycles(Main *bmain)
if (is_fstop) {
continue;
}
- else if (aperture_size > 0.0f) {
+ if (aperture_size > 0.0f) {
if (camera->type == CAM_ORTHO) {
camera->dof.aperture_fstop = 1.0f / (2.0f * aperture_size);
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 7f75c0100b8..631961e342d 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -106,7 +106,7 @@ static void blo_update_defaults_screen(bScreen *screen,
/* Some toolbars have been saved as initialized,
* we don't want them to have odd zoom-level or scrolling set, see: T47047 */
if (ELEM(region->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) {
- region->v2d.flag &= ~V2D_IS_INITIALISED;
+ region->v2d.flag &= ~V2D_IS_INIT;
}
}
@@ -326,7 +326,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
if (ts->gp_sculpt.cur_falloff == NULL) {
ts->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff;
- BKE_curvemapping_initialize(gp_falloff_curve);
+ BKE_curvemapping_init(gp_falloff_curve);
BKE_curvemap_reset(gp_falloff_curve->cm,
&gp_falloff_curve->clipr,
CURVE_PRESET_GAUSS,
@@ -335,7 +335,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
if (ts->gp_sculpt.cur_primitive == NULL) {
ts->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive;
- BKE_curvemapping_initialize(gp_primitive_curve);
+ BKE_curvemapping_init(gp_primitive_curve);
BKE_curvemap_reset(gp_primitive_curve->cm,
&gp_primitive_curve->clipr,
CURVE_PRESET_BELL,
@@ -698,6 +698,14 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
brush->sculpt_tool = SCULPT_TOOL_SMEAR;
}
+ brush_name = "Boundary";
+ brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
+ if (!brush) {
+ brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT);
+ id_us_min(&brush->id);
+ brush->sculpt_tool = SCULPT_TOOL_BOUNDARY;
+ }
+
brush_name = "Simplify";
brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
if (!brush) {
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 44c7c35e47d..88ccb551e16 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -102,7 +102,7 @@ static void vcol_to_fcol(Mesh *me)
return;
}
- mcoln = mcolmain = MEM_malloc_arrayN(me->totface, 4 * sizeof(int), "mcoln");
+ mcoln = mcolmain = MEM_malloc_arrayN(me->totface, sizeof(int[4]), "mcoln");
mcol = (uint *)me->mcol;
mface = me->mface;
for (a = me->totface; a > 0; a--, mface++) {
@@ -493,6 +493,7 @@ void blo_do_version_old_trackto_to_constraints(Object *ob)
ob->track = NULL;
}
+/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
@@ -2096,7 +2097,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (la->curfalloff == NULL) {
la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
- BKE_curvemapping_initialize(la->curfalloff);
+ BKE_curvemapping_init(la->curfalloff);
}
}
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 3db2fada85f..ed4f997a856 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -152,6 +152,7 @@
#include "MEM_guardedalloc.h" // MEM_freeN
#include "BKE_action.h"
+#include "BKE_armature.h"
#include "BKE_blender_version.h"
#include "BKE_bpath.h"
#include "BKE_collection.h"
@@ -240,9 +241,8 @@ static bool ww_open_none(WriteWrap *ww, const char *filepath)
FILE_HANDLE(ww) = file;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
static bool ww_close_none(WriteWrap *ww)
{
@@ -267,9 +267,8 @@ static bool ww_open_zlib(WriteWrap *ww, const char *filepath)
FILE_HANDLE(ww) = file;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
static bool ww_close_zlib(WriteWrap *ww)
{
@@ -1582,7 +1581,7 @@ static void write_constraints(BlendWriter *writer, ListBase *conlist)
}
}
-static void write_pose(BlendWriter *writer, bPose *pose)
+static void write_pose(BlendWriter *writer, bPose *pose, bArmature *arm)
{
bPoseChannel *chan;
bActionGroup *grp;
@@ -1592,6 +1591,8 @@ static void write_pose(BlendWriter *writer, bPose *pose)
return;
}
+ BLI_assert(arm != NULL);
+
/* Write channels */
for (chan = pose->chanbase.first; chan; chan = chan->next) {
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
@@ -1604,11 +1605,15 @@ static void write_pose(BlendWriter *writer, bPose *pose)
write_motionpath(writer, chan->mpath);
- /* prevent crashes with autosave,
- * when a bone duplicated in editmode has not yet been assigned to its posechannel */
- if (chan->bone) {
+ /* Prevent crashes with autosave,
+ * when a bone duplicated in editmode has not yet been assigned to its posechannel.
+ * Also needed with memundo, in some cases we can store a step before pose has been
+ * properly rebuilt from previous undo step. */
+ Bone *bone = (pose->flag & POSE_RECALC) ? BKE_armature_find_bone_name(arm, chan->name) :
+ chan->bone;
+ if (bone != NULL) {
/* gets restored on read, for library armatures */
- chan->selectflag = chan->bone->flag & BONE_SELECTED;
+ chan->selectflag = bone->flag & BONE_SELECTED;
}
BLO_write_struct(writer, bPoseChannel, chan);
@@ -1853,15 +1858,16 @@ static void write_object(BlendWriter *writer, Object *ob, const void *id_address
BLO_write_pointer_array(writer, ob->totcol, ob->mat);
BLO_write_raw(writer, sizeof(char) * ob->totcol, ob->matbits);
+ bArmature *arm = NULL;
if (ob->type == OB_ARMATURE) {
- bArmature *arm = ob->data;
+ arm = ob->data;
if (arm && ob->pose && arm->act_bone) {
BLI_strncpy(
ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
}
}
- write_pose(writer, ob->pose);
+ write_pose(writer, ob->pose, arm);
write_defgroups(writer, &ob->defbase);
write_fmaps(writer, &ob->fmaps);
write_constraints(writer, &ob->constraints);
@@ -2497,7 +2503,12 @@ static void write_lightcache_texture(BlendWriter *writer, LightCacheTexture *tex
else if (tex->data_type == LIGHTCACHETEX_UINT) {
data_size *= sizeof(uint);
}
- BLO_write_raw(writer, data_size, tex->data);
+
+ /* FIXME: We can't save more than what 32bit systems can handle.
+ * The solution would be to split the texture but it is too late for 2.90. (see T78529) */
+ if (data_size < INT_MAX) {
+ BLO_write_raw(writer, data_size, tex->data);
+ }
}
}
@@ -2835,12 +2846,12 @@ static void write_uilist(BlendWriter *writer, uiList *ui_list)
}
}
-static void write_soops(BlendWriter *writer, SpaceOutliner *so)
+static void write_space_outliner(BlendWriter *writer, SpaceOutliner *space_outliner)
{
- BLI_mempool *ts = so->treestore;
+ BLI_mempool *ts = space_outliner->treestore;
if (ts) {
- SpaceOutliner so_flat = *so;
+ SpaceOutliner space_outliner_flat = *space_outliner;
int elems = BLI_mempool_len(ts);
/* linearize mempool to array */
@@ -2861,7 +2872,7 @@ static void write_soops(BlendWriter *writer, SpaceOutliner *so)
ts_flat.totelem = elems;
ts_flat.data = data_addr;
- BLO_write_struct(writer, SpaceOutliner, so);
+ BLO_write_struct(writer, SpaceOutliner, space_outliner);
BLO_write_struct_at_address(writer, TreeStore, ts, &ts_flat);
BLO_write_struct_array_at_address(writer, TreeStoreElem, elems, data_addr, data);
@@ -2869,12 +2880,12 @@ static void write_soops(BlendWriter *writer, SpaceOutliner *so)
MEM_freeN(data);
}
else {
- so_flat.treestore = NULL;
- BLO_write_struct_at_address(writer, SpaceOutliner, so, &so_flat);
+ space_outliner_flat.treestore = NULL;
+ BLO_write_struct_at_address(writer, SpaceOutliner, space_outliner, &space_outliner_flat);
}
}
else {
- BLO_write_struct(writer, SpaceOutliner, so);
+ BLO_write_struct(writer, SpaceOutliner, space_outliner);
}
}
@@ -2950,8 +2961,8 @@ static void write_area_regions(BlendWriter *writer, ScrArea *area)
BLO_write_struct(writer, SpaceSeq, sl);
}
else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = (SpaceOutliner *)sl;
- write_soops(writer, so);
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ write_space_outliner(writer, space_outliner);
}
else if (sl->spacetype == SPACE_IMAGE) {
BLO_write_struct(writer, SpaceImage, sl);
@@ -4047,8 +4058,9 @@ static bool write_file_handle(Main *mainvar,
* avoid thumbnail detecting changes because of this. */
mywrite_flush(wd);
- OverrideLibraryStorage *override_storage =
- wd->use_memfile ? NULL : BKE_lib_override_library_operations_store_initialize();
+ OverrideLibraryStorage *override_storage = wd->use_memfile ?
+ NULL :
+ BKE_lib_override_library_operations_store_init();
#define ID_BUFFER_STATIC_SIZE 8192
/* This outer loop allows to save first data-blocks from real mainvar,
@@ -4599,7 +4611,7 @@ void BLO_write_pointer_array(BlendWriter *writer, int size, const void *data_ptr
void BLO_write_float3_array(BlendWriter *writer, int size, const float *data_ptr)
{
- BLO_write_raw(writer, sizeof(float) * 3 * size, data_ptr);
+ BLO_write_raw(writer, sizeof(float[3]) * size, data_ptr);
}
/**
diff --git a/tests/gtests/blenloader/blendfile_load_test.cc b/source/blender/blenloader/tests/blendfile_load_test.cc
index 2ba3e3fcd88..2ba3e3fcd88 100644
--- a/tests/gtests/blenloader/blendfile_load_test.cc
+++ b/source/blender/blenloader/tests/blendfile_load_test.cc
diff --git a/tests/gtests/blenloader/blendfile_loading_base_test.cc b/source/blender/blenloader/tests/blendfile_loading_base_test.cc
index d74bab4b31c..d74bab4b31c 100644
--- a/tests/gtests/blenloader/blendfile_loading_base_test.cc
+++ b/source/blender/blenloader/tests/blendfile_loading_base_test.cc
diff --git a/tests/gtests/blenloader/blendfile_loading_base_test.h b/source/blender/blenloader/tests/blendfile_loading_base_test.h
index 6ed32168737..a5e75ef6df8 100644
--- a/tests/gtests/blenloader/blendfile_loading_base_test.h
+++ b/source/blender/blenloader/tests/blendfile_loading_base_test.h
@@ -47,7 +47,7 @@ class BlendfileLoadingBaseTest : public testing::Test {
* Requires the CLI argument --test-asset-dir to point to ../../lib/tests.
*
* WARNING: only files saved with Blender 2.80+ can be loaded. Since Blender
- * is only partially initialised (most importantly, without window manager),
+ * is only partially initialized (most importantly, without window manager),
* the space types are not registered, so any versioning code that handles
* those will SEGFAULT.
*/
diff --git a/source/blender/blentranslation/BLT_lang.h b/source/blender/blentranslation/BLT_lang.h
index 6ce9a0ba71c..dcd4de10416 100644
--- a/source/blender/blentranslation/BLT_lang.h
+++ b/source/blender/blentranslation/BLT_lang.h
@@ -21,8 +21,7 @@
* \ingroup blt
*/
-#ifndef __BLT_LANG_H__
-#define __BLT_LANG_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -60,5 +59,3 @@ struct EnumPropertyItem *BLT_lang_RNA_enum_properties(void);
#ifdef __cplusplus
};
#endif
-
-#endif /* __BLT_LANG_H__ */
diff --git a/source/blender/blentranslation/BLT_translation.h b/source/blender/blentranslation/BLT_translation.h
index 817b99e8b91..b8979caa909 100644
--- a/source/blender/blentranslation/BLT_translation.h
+++ b/source/blender/blentranslation/BLT_translation.h
@@ -21,8 +21,7 @@
* \ingroup blt
*/
-#ifndef __BLT_TRANSLATION_H__
-#define __BLT_TRANSLATION_H__
+#pragma once
#include "BLI_utildefines.h" /* for bool type */
@@ -221,5 +220,3 @@ typedef struct {
#ifdef __cplusplus
};
#endif
-
-#endif /* __BLT_TRANSLATION_H__ */
diff --git a/source/blender/blentranslation/intern/blt_translation.c b/source/blender/blentranslation/intern/blt_translation.c
index 0ca068d4263..00118bc72e6 100644
--- a/source/blender/blentranslation/intern/blt_translation.c
+++ b/source/blender/blentranslation/intern/blt_translation.c
@@ -120,9 +120,9 @@ const char *BLT_translate_do(const char *msgctxt, const char *msgid)
if (BLT_translate()) {
return BLT_pgettext(msgctxt, msgid);
}
- else {
- return msgid;
- }
+
+ return msgid;
+
#else
(void)msgctxt;
return msgid;
@@ -135,9 +135,9 @@ const char *BLT_translate_do_iface(const char *msgctxt, const char *msgid)
if (BLT_translate_iface()) {
return BLT_pgettext(msgctxt, msgid);
}
- else {
- return msgid;
- }
+
+ return msgid;
+
#else
(void)msgctxt;
return msgid;
@@ -150,9 +150,9 @@ const char *BLT_translate_do_tooltip(const char *msgctxt, const char *msgid)
if (BLT_translate_tooltips()) {
return BLT_pgettext(msgctxt, msgid);
}
- else {
- return msgid;
- }
+
+ return msgid;
+
#else
(void)msgctxt;
return msgid;
@@ -165,9 +165,9 @@ const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid
if (BLT_translate_new_dataname()) {
return BLT_pgettext(msgctxt, msgid);
}
- else {
- return msgid;
- }
+
+ return msgid;
+
#else
(void)msgctxt;
return msgid;
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index fca411e594f..b97b5cc95f2 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -204,3 +204,16 @@ if(WITH_FREESTYLE)
endif()
blender_add_lib(bf_bmesh "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+
+if(WITH_GTESTS)
+ set(TEST_SRC
+ tests/bmesh_core_test.cc
+ )
+ set(TEST_INC
+ )
+ set(TEST_LIB
+ bf_bmesh
+ )
+ include(GTestTesting)
+ blender_add_test_lib(bf_bmesh_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
+endif()
diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h
index c1f4b9daf27..5f5d6baaba2 100644
--- a/source/blender/bmesh/bmesh.h
+++ b/source/blender/bmesh/bmesh.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_H__
-#define __BMESH_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -231,5 +230,3 @@ extern "C" {
#ifdef __cplusplus
}
#endif
-
-#endif /* __BMESH_H__ */
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 1393e24e48e..edb355993c1 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_CLASS_H__
-#define __BMESH_CLASS_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -472,5 +471,3 @@ typedef bool (*BMLoopFilterFunc)(const BMLoop *, void *user_data);
#else
# define BM_OMP_LIMIT 10000
#endif
-
-#endif /* __BMESH_CLASS_H__ */
diff --git a/source/blender/bmesh/bmesh_tools.h b/source/blender/bmesh/bmesh_tools.h
index 4593f34792b..ee53cb9804d 100644
--- a/source/blender/bmesh/bmesh_tools.h
+++ b/source/blender/bmesh/bmesh_tools.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_TOOLS_H__
-#define __BMESH_TOOLS_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -45,5 +44,3 @@ extern "C" {
#ifdef __cplusplus
}
#endif
-
-#endif /* __BMESH_TOOLS_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_callback_generic.h b/source/blender/bmesh/intern/bmesh_callback_generic.h
index 5191bd31873..3f3a48fd546 100644
--- a/source/blender/bmesh/intern/bmesh_callback_generic.h
+++ b/source/blender/bmesh/intern/bmesh_callback_generic.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_CALLBACK_GENERIC_H__
-#define __BMESH_CALLBACK_GENERIC_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -35,5 +34,3 @@ bool BM_elem_cb_check_elem_not_equal(BMElem *ele, void *user_data);
#define BM_elem_cb_check_hflag_disabled_simple(type, hflag_n) \
(bool (*)(type, void *)) BM_elem_cb_check_hflag_disabled, POINTER_FROM_UINT(hflag_n)
-
-#endif /* __BMESH_CALLBACK_GENERIC_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_construct.h b/source/blender/bmesh/intern/bmesh_construct.h
index ae2b137d38a..3523c4aec1a 100644
--- a/source/blender/bmesh/intern/bmesh_construct.h
+++ b/source/blender/bmesh/intern/bmesh_construct.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_CONSTRUCT_H__
-#define __BMESH_CONSTRUCT_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -78,5 +77,3 @@ char BM_vert_flag_from_mflag(const char mflag);
char BM_face_flag_to_mflag(BMFace *f);
short BM_edge_flag_to_mflag(BMEdge *e);
char BM_vert_flag_to_mflag(BMVert *v);
-
-#endif /* __BMESH_CONSTRUCT_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index 4e9775bcfa7..6c4f98e125f 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -182,7 +182,7 @@ BMEdge *BM_edge_create(
e->v2 = v2;
e->l = NULL;
- memset(&e->v1_disk_link, 0, sizeof(BMDiskLink) * 2);
+ memset(&e->v1_disk_link, 0, sizeof(BMDiskLink[2]));
/* --- done --- */
bmesh_disk_edge_append(e, e->v1);
diff --git a/source/blender/bmesh/intern/bmesh_core.h b/source/blender/bmesh/intern/bmesh_core.h
index 3308f93d5d3..0e19437a527 100644
--- a/source/blender/bmesh/intern/bmesh_core.h
+++ b/source/blender/bmesh/intern/bmesh_core.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_CORE_H__
-#define __BMESH_CORE_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -128,5 +127,3 @@ BMFace *bmesh_kernel_join_face_kill_edge(BMesh *bm, BMFace *f1, BMFace *f2, BMEd
BMVert *bmesh_kernel_unglue_region_make_vert(BMesh *bm, BMLoop *l_sep);
BMVert *bmesh_kernel_unglue_region_make_vert_multi(BMesh *bm, BMLoop **larr, int larr_len);
BMVert *bmesh_kernel_unglue_region_make_vert_multi_isolated(BMesh *bm, BMLoop *l_sep);
-
-#endif /* __BMESH_CORE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_delete.h b/source/blender/bmesh/intern/bmesh_delete.h
index d41f26baddd..fcbcb8a90fc 100644
--- a/source/blender/bmesh/intern/bmesh_delete.h
+++ b/source/blender/bmesh/intern/bmesh_delete.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_DELETE_H__
-#define __BMESH_DELETE_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -26,5 +25,3 @@ void BM_mesh_delete_hflag_tagged(BMesh *bm, const char hflag, const char htype);
void BMO_mesh_delete_oflag_context(BMesh *bm, const short oflag, const int type);
void BM_mesh_delete_hflag_context(BMesh *bm, const char hflag, const int type);
-
-#endif /* __BMESH_DELETE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.h b/source/blender/bmesh/intern/bmesh_edgeloop.h
index 4c76ea4f9cf..2e5c4d0193e 100644
--- a/source/blender/bmesh/intern/bmesh_edgeloop.h
+++ b/source/blender/bmesh/intern/bmesh_edgeloop.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BMESH_EDGELOOP_H__
-#define __BMESH_EDGELOOP_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -84,5 +83,3 @@ bool BM_edgeloop_overlap_check(struct BMEdgeLoopStore *el_store_a,
#define BM_EDGELOOP_NEXT(el_store) \
(CHECK_TYPE_INLINE(el_store, struct BMEdgeLoopStore *), \
(struct BMEdgeLoopStore *)((LinkData *)el_store)->next)
-
-#endif /* __BMESH_EDGELOOP_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_error.h b/source/blender/bmesh/intern/bmesh_error.h
index 289b603d134..2307377fd71 100644
--- a/source/blender/bmesh/intern/bmesh_error.h
+++ b/source/blender/bmesh/intern/bmesh_error.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_ERROR_H__
-#define __BMESH_ERROR_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -84,5 +83,3 @@ enum {
_BMESH_DUMMY_ABORT(), \
NULL)) : \
NULL)
-
-#endif /* __BMESH_ERROR_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_inline.h b/source/blender/bmesh/intern/bmesh_inline.h
index 13691776a27..203f44a540d 100644
--- a/source/blender/bmesh/intern/bmesh_inline.h
+++ b/source/blender/bmesh/intern/bmesh_inline.h
@@ -20,8 +20,7 @@
* BM Inline functions.
*/
-#ifndef __BMESH_INLINE_H__
-#define __BMESH_INLINE_H__
+#pragma once
/* stuff for dealing with header flags */
#define BM_elem_flag_test(ele, hflag) _bm_elem_flag_test(&(ele)->head, hflag)
@@ -135,5 +134,3 @@ BLI_INLINE int _bm_elem_index_get(const BMHeader *head)
{
return head->index;
}
-
-#endif /* __BMESH_INLINE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index e8298f4dffc..2f811dbe463 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -295,7 +295,7 @@ static bool quad_co(const float v1[3],
float r_uv[2])
{
float projverts[5][3], n2[3];
- float origin[2] = {0.0f, 0.0f};
+ const float origin[2] = {0.0f, 0.0f};
int i;
/* project points into 2d along normal */
@@ -328,7 +328,7 @@ static bool quad_co(const float v1[3],
return true;
}
-static void mdisp_axis_from_quad(float v1[3],
+static void mdisp_axis_from_quad(const float v1[3],
const float v2[3],
float UNUSED(v3[3]),
const float v4[3],
@@ -535,7 +535,7 @@ void BM_loop_interp_multires_ex(BMesh *UNUSED(bm),
md_dst->totdisp = md_src->totdisp;
md_dst->level = md_src->level;
if (md_dst->totdisp) {
- md_dst->disps = MEM_callocN(sizeof(float) * 3 * md_dst->totdisp, __func__);
+ md_dst->disps = MEM_callocN(sizeof(float[3]) * md_dst->totdisp, __func__);
}
else {
return;
diff --git a/source/blender/bmesh/intern/bmesh_interp.h b/source/blender/bmesh/intern/bmesh_interp.h
index bd3824ed3fd..0399b796cfd 100644
--- a/source/blender/bmesh/intern/bmesh_interp.h
+++ b/source/blender/bmesh/intern/bmesh_interp.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_INTERP_H__
-#define __BMESH_INTERP_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -82,5 +81,3 @@ void BM_vert_loop_groups_data_layer_merge_weights(BMesh *bm,
struct LinkNode *groups,
const int layer_n,
const float *loop_weights);
-
-#endif /* __BMESH_INTERP_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_iterators.h b/source/blender/bmesh/intern/bmesh_iterators.h
index a809c9a3d32..9314e23b21f 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.h
+++ b/source/blender/bmesh/intern/bmesh_iterators.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_ITERATORS_H__
-#define __BMESH_ITERATORS_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -252,5 +251,3 @@ BMITER_CB_DEF(loop_of_face);
(BM_ITER_CHECK_TYPE_DATA(data), BM_iter_new(iter, bm, itype, data))
#define BM_iter_init(iter, bm, itype, data) \
(BM_ITER_CHECK_TYPE_DATA(data), BM_iter_init(iter, bm, itype, data))
-
-#endif /* __BMESH_ITERATORS_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_iterators_inline.h b/source/blender/bmesh/intern/bmesh_iterators_inline.h
index 4b9fbf52630..c384fb03cd9 100644
--- a/source/blender/bmesh/intern/bmesh_iterators_inline.h
+++ b/source/blender/bmesh/intern/bmesh_iterators_inline.h
@@ -20,8 +20,7 @@
* BMesh inline iterator functions.
*/
-#ifndef __BMESH_ITERATORS_INLINE_H__
-#define __BMESH_ITERATORS_INLINE_H__
+#pragma once
/* inline here optimizes out the switch statement when called with
* constant values (which is very common), nicer for loop-in-loop situations */
@@ -210,5 +209,3 @@ BLI_INLINE void BM_iter_parallel(BMesh *bm,
}
#endif /* __BLI_TASK_H__ */
-
-#endif /* __BMESH_ITERATORS_INLINE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_log.h b/source/blender/bmesh/intern/bmesh_log.h
index 25c58132802..5c0ca78bddf 100644
--- a/source/blender/bmesh/intern/bmesh_log.h
+++ b/source/blender/bmesh/intern/bmesh_log.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_LOG_H__
-#define __BMESH_LOG_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -98,5 +97,3 @@ void BM_log_original_vert_data(BMLog *log, BMVert *v, const float **r_co, const
/* For internal use only (unit testing) */
BMLogEntry *BM_log_current_entry(BMLog *log);
struct RangeTreeUInt *BM_log_unused_ids(BMLog *log);
-
-#endif
diff --git a/source/blender/bmesh/intern/bmesh_marking.h b/source/blender/bmesh/intern/bmesh_marking.h
index 06314a7a388..958980bdc23 100644
--- a/source/blender/bmesh/intern/bmesh_marking.h
+++ b/source/blender/bmesh/intern/bmesh_marking.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_MARKING_H__
-#define __BMESH_MARKING_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -137,5 +136,3 @@ void BM_select_history_merge_from_targetmap(
(bm)->selected = _bm_prev_selected; \
} \
(void)0
-
-#endif /* __BMESH_MARKING_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h
index 0d665f1d391..a6b8b629ddf 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.h
+++ b/source/blender/bmesh/intern/bmesh_mesh.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_MESH_H__
-#define __BMESH_MESH_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -171,5 +170,3 @@ void BM_mesh_vert_coords_apply(BMesh *bm, const float (*orco)[3]);
void BM_mesh_vert_coords_apply_with_mat4(BMesh *bm,
const float (*vert_coords)[3],
const float mat[4][4]);
-
-#endif /* __BMESH_MESH_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.c b/source/blender/bmesh/intern/bmesh_mesh_convert.c
index 65bc4da49bc..8db125970fd 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_convert.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_convert.c
@@ -860,7 +860,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
if (act_is_basis) {
const float(*fp)[3] = actkey->data;
- ofs = MEM_callocN(sizeof(float) * 3 * bm->totvert, "currkey->data");
+ ofs = MEM_callocN(sizeof(float[3]) * bm->totvert, "currkey->data");
mvert = me->mvert;
BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
const int keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset);
diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.h b/source/blender/bmesh/intern/bmesh_mesh_convert.h
index 1ad43558c60..1b5d001d35d 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_convert.h
+++ b/source/blender/bmesh/intern/bmesh_mesh_convert.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BMESH_MESH_CONV_H__
-#define __BMESH_MESH_CONV_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -71,5 +70,3 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm,
struct Mesh *me,
const struct CustomData_MeshMasks *cd_mask_extra)
ATTR_NONNULL(1, 2);
-
-#endif /* __BMESH_MESH_CONV_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_mesh_duplicate.h b/source/blender/bmesh/intern/bmesh_mesh_duplicate.h
index 17d4071b69f..8ace555d61f 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_duplicate.h
+++ b/source/blender/bmesh/intern/bmesh_mesh_duplicate.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_MESH_DUPLICATE_H__
-#define __BMESH_MESH_DUPLICATE_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -29,5 +28,3 @@ void BM_mesh_copy_arrays(BMesh *bm_src,
uint edges_src_len,
BMFace **faces_src,
uint faces_src_len);
-
-#endif /* __BMESH_MESH_DUPLICATE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_mesh_validate.h b/source/blender/bmesh/intern/bmesh_mesh_validate.h
index 32bb4fb023b..2112e1f3200 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_validate.h
+++ b/source/blender/bmesh/intern/bmesh_mesh_validate.h
@@ -17,13 +17,10 @@
* All rights reserved.
*/
-#ifndef __BMESH_MESH_VALIDATE_H__
-#define __BMESH_MESH_VALIDATE_H__
+#pragma once
/** \file
* \ingroup bmesh
*/
bool BM_mesh_validate(BMesh *bm);
-
-#endif /* __BMESH_MESH_VALIDATE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_mods.h b/source/blender/bmesh/intern/bmesh_mods.h
index 36cb85bc9bc..8099d1dd603 100644
--- a/source/blender/bmesh/intern/bmesh_mods.h
+++ b/source/blender/bmesh/intern/bmesh_mods.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_MODS_H__
-#define __BMESH_MODS_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -94,5 +93,3 @@ enum {
BMVert *BM_face_loop_separate(BMesh *bm, BMLoop *l_sep);
BMVert *BM_face_loop_separate_multi_isolated(BMesh *bm, BMLoop *l_sep);
BMVert *BM_face_loop_separate_multi(BMesh *bm, BMLoop **larr, int larr_len);
-
-#endif /* __BMESH_MODS_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h
index 5af812d1b1d..a9282b8e5d0 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_OPERATOR_API_H__
-#define __BMESH_OPERATOR_API_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -668,5 +667,3 @@ int BMO_opcode_from_opname(const char *opname);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BMESH_OPERATOR_API_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
index 2bda2d121c2..43628f01bc8 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
@@ -20,8 +20,7 @@
* BMesh inline operator functions.
*/
-#ifndef __BMESH_OPERATOR_API_INLINE_H__
-#define __BMESH_OPERATOR_API_INLINE_H__
+#pragma once
/* tool flag API. never, ever ever should tool code put junk in
* header flags (element->head.flag), nor should they use
@@ -236,5 +235,3 @@ ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) BLI_INLINE
return NULL;
}
-
-#endif /* __BMESH_OPERATOR_API_INLINE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 19e42b33c80..746e9668671 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -55,17 +55,17 @@ BLI_STATIC_ASSERT(ARRAY_SIZE(bmo_error_messages) == BMERR_TOTAL, "message mismat
/* operator slot type information - size of one element of the type given. */
const int BMO_OPSLOT_TYPEINFO[BMO_OP_SLOT_TOTAL_TYPES] = {
- 0, /* 0: BMO_OP_SLOT_SENTINEL */
- sizeof(int), /* 1: BMO_OP_SLOT_BOOL */
- sizeof(int), /* 2: BMO_OP_SLOT_INT */
- sizeof(float), /* 3: BMO_OP_SLOT_FLT */
- sizeof(void *), /* 4: BMO_OP_SLOT_PNT */
- sizeof(void *), /* 5: BMO_OP_SLOT_PNT */
- 0, /* 6: unused */
- 0, /* 7: unused */
- sizeof(float) * 3, /* 8: BMO_OP_SLOT_VEC */
- sizeof(void *), /* 9: BMO_OP_SLOT_ELEMENT_BUF */
- sizeof(void *), /* 10: BMO_OP_SLOT_MAPPING */
+ 0, /* 0: BMO_OP_SLOT_SENTINEL */
+ sizeof(int), /* 1: BMO_OP_SLOT_BOOL */
+ sizeof(int), /* 2: BMO_OP_SLOT_INT */
+ sizeof(float), /* 3: BMO_OP_SLOT_FLT */
+ sizeof(void *), /* 4: BMO_OP_SLOT_PNT */
+ sizeof(void *), /* 5: BMO_OP_SLOT_PNT */
+ 0, /* 6: unused */
+ 0, /* 7: unused */
+ sizeof(float[3]), /* 8: BMO_OP_SLOT_VEC */
+ sizeof(void *), /* 9: BMO_OP_SLOT_ELEMENT_BUF */
+ sizeof(void *), /* 10: BMO_OP_SLOT_MAPPING */
};
/* Dummy slot so there is something to return when slot name lookup fails */
@@ -418,7 +418,7 @@ void BMO_slot_mat_set(BMOperator *op,
}
slot->len = 4;
- slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float) * 4 * 4);
+ slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float[4][4]));
if (size == 4) {
copy_m4_m4(slot->data.p, (float(*)[4])mat);
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index c0e59758120..2f7d91c78c4 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_OPERATORS_H__
-#define __BMESH_OPERATORS_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -193,5 +192,3 @@ void BM_mesh_calc_uvs_cone(BMesh *bm,
void BM_mesh_calc_uvs_cube(BMesh *bm, const short oflag);
#include "intern/bmesh_operator_api_inline.h"
-
-#endif /* __BMESH_OPERATORS_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_operators_private.h b/source/blender/bmesh/intern/bmesh_operators_private.h
index 137c5aa338e..1c53c3d5c89 100644
--- a/source/blender/bmesh/intern/bmesh_operators_private.h
+++ b/source/blender/bmesh/intern/bmesh_operators_private.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_OPERATORS_PRIVATE_H__
-#define __BMESH_OPERATORS_PRIVATE_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -103,5 +102,3 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op);
void bmo_unsubdivide_exec(BMesh *bm, BMOperator *op);
void bmo_weld_verts_exec(BMesh *bm, BMOperator *op);
void bmo_wireframe_exec(BMesh *bm, BMOperator *op);
-
-#endif /* __BMESH_OPERATORS_PRIVATE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 0b93db6a91e..06bab8c8cc1 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -163,7 +163,7 @@ void BM_face_calc_tessellation(const BMFace *f,
float(*projverts)[2] = BLI_array_alloca(projverts, f->len);
int j;
- axis_dominant_v3_to_m3(axis_mat, f->no);
+ axis_dominant_v3_to_m3_negate(axis_mat, f->no);
j = 0;
l_iter = l_first;
@@ -174,7 +174,7 @@ void BM_face_calc_tessellation(const BMFace *f,
} while ((l_iter = l_iter->next) != l_first);
/* complete the loop */
- BLI_polyfill_calc(projverts, f->len, -1, r_index);
+ BLI_polyfill_calc(projverts, f->len, 1, r_index);
}
}
diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h
index 1611bc0b893..d9413e303e3 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.h
+++ b/source/blender/bmesh/intern/bmesh_polygon.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_POLYGON_H__
-#define __BMESH_POLYGON_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -114,5 +113,3 @@ void BM_face_as_array_loop_quad(BMFace *f, BMLoop *r_loops[4]) ATTR_NONNULL();
void BM_vert_tri_calc_tangent_edge(BMVert *verts[3], float r_tangent[3]);
void BM_vert_tri_calc_tangent_edge_pair(BMVert *verts[3], float r_tangent[3]);
-
-#endif /* __BMESH_POLYGON_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.h b/source/blender/bmesh/intern/bmesh_polygon_edgenet.h
index 38af944d0cd..6833f067421 100644
--- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.h
+++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_POLYGON_EDGENET_H__
-#define __BMESH_POLYGON_EDGENET_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -37,5 +36,3 @@ bool BM_face_split_edgenet_connect_islands(BMesh *bm,
BMEdge ***r_edge_net_new,
uint *r_edge_net_new_len) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1, 2, 3, 6, 7, 8);
-
-#endif /* __BMESH_POLYGON_EDGENET_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h
index 8b4a59d5b9b..2c3bac6df33 100644
--- a/source/blender/bmesh/intern/bmesh_private.h
+++ b/source/blender/bmesh/intern/bmesh_private.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BMESH_PRIVATE_H__
-#define __BMESH_PRIVATE_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -90,5 +89,3 @@ void poly_rotate_plane(const float normal[3], float (*verts)[3], const uint nver
/* include the rest of our private declarations */
#include "bmesh_structure.h"
-
-#endif /* __BMESH_PRIVATE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c
index 80634618f6f..61a81e56a2e 100644
--- a/source/blender/bmesh/intern/bmesh_query.c
+++ b/source/blender/bmesh/intern/bmesh_query.c
@@ -179,13 +179,12 @@ BMLoop *BM_loop_other_vert_loop_by_edge(BMLoop *l, BMEdge *e)
if (l->e == e) {
return l->next;
}
- else if (l->prev->e == e) {
+ if (l->prev->e == e) {
return l->prev;
}
- else {
- BLI_assert(0);
- return NULL;
- }
+
+ BLI_assert(0);
+ return NULL;
}
/**
@@ -2512,6 +2511,22 @@ bool BM_face_is_any_edge_flag_test(const BMFace *f, const char hflag)
return false;
}
+bool BM_edge_is_any_face_len_test(const BMEdge *e, const int len)
+{
+ if (e->l) {
+ BMLoop *l_iter, *l_first;
+
+ l_iter = l_first = e->l;
+ do {
+ if (l_iter->f->len == len) {
+ return true;
+ }
+ } while ((l_iter = l_iter->radial_next) != l_first);
+ }
+
+ return false;
+}
+
/**
* Use within assert's to check normals are valid.
*/
diff --git a/source/blender/bmesh/intern/bmesh_query.h b/source/blender/bmesh/intern/bmesh_query.h
index 0d95efb778f..1ff2558ce83 100644
--- a/source/blender/bmesh/intern/bmesh_query.h
+++ b/source/blender/bmesh/intern/bmesh_query.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_QUERY_H__
-#define __BMESH_QUERY_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -244,6 +243,9 @@ bool BM_face_is_any_vert_flag_test(const BMFace *f, const char hflag) ATTR_WARN_
bool BM_face_is_any_edge_flag_test(const BMFace *f, const char hflag) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL();
+bool BM_edge_is_any_face_len_test(const BMEdge *e, const int len) ATTR_WARN_UNUSED_RESULT
+ ATTR_NONNULL();
+
bool BM_face_is_normal_valid(const BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
double BM_mesh_calc_volume(BMesh *bm, bool is_signed) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
@@ -273,5 +275,3 @@ int BM_mesh_calc_edge_groups_as_arrays(BMesh *bm,
float bmesh_subd_falloff_calc(const int falloff, float val) ATTR_WARN_UNUSED_RESULT;
#include "bmesh_query_inline.h"
-
-#endif /* __BMESH_QUERY_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_query_inline.h b/source/blender/bmesh/intern/bmesh_query_inline.h
index 90919cc361b..8b12ccace20 100644
--- a/source/blender/bmesh/intern/bmesh_query_inline.h
+++ b/source/blender/bmesh/intern/bmesh_query_inline.h
@@ -18,8 +18,7 @@
* \ingroup bmesh
*/
-#ifndef __BMESH_QUERY_INLINE_H__
-#define __BMESH_QUERY_INLINE_H__
+#pragma once
/**
* Returns whether or not a given vertex is
@@ -152,5 +151,3 @@ ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) BLI_INLINE bool BM_vert_is_wire_endpoint
}
return false;
}
-
-#endif /* __BMESH_QUERY_INLINE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_query_uv.c b/source/blender/bmesh/intern/bmesh_query_uv.c
index b9ea51f0c4d..1aa75bfb037 100644
--- a/source/blender/bmesh/intern/bmesh_query_uv.c
+++ b/source/blender/bmesh/intern/bmesh_query_uv.c
@@ -95,6 +95,20 @@ void BM_face_uv_calc_center_median_weighted(const BMFace *f,
#undef UV_ASPECT
+void BM_face_uv_calc_center_median(const BMFace *f, const int cd_loop_uv_offset, float r_cent[2])
+{
+ const BMLoop *l_iter;
+ const BMLoop *l_first;
+ zero_v2(r_cent);
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset);
+ add_v2_v2(r_cent, luv->uv);
+ } while ((l_iter = l_iter->next) != l_first);
+
+ mul_v2_fl(r_cent, 1.0f / (float)f->len);
+}
+
/**
* Calculate the UV cross product (use the sign to check the winding).
*/
diff --git a/source/blender/bmesh/intern/bmesh_query_uv.h b/source/blender/bmesh/intern/bmesh_query_uv.h
index 2558f814f32..0a86c0cbeae 100644
--- a/source/blender/bmesh/intern/bmesh_query_uv.h
+++ b/source/blender/bmesh/intern/bmesh_query_uv.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_QUERY_UV_H__
-#define __BMESH_QUERY_UV_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -32,6 +31,8 @@ void BM_face_uv_calc_center_median_weighted(const BMFace *f,
const float aspect[2],
const int cd_loop_uv_offset,
float r_cent[2]) ATTR_NONNULL();
+void BM_face_uv_calc_center_median(const BMFace *f, const int cd_loop_uv_offset, float r_cent[2])
+ ATTR_NONNULL();
float BM_face_uv_calc_cross(const BMFace *f, const int cd_loop_uv_offset) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL();
@@ -54,5 +55,3 @@ bool BM_loop_uv_share_vert_check(BMLoop *l_a,
BMLoop *l_b,
const int cd_loop_uv_offset) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL();
-
-#endif /* __BMESH_QUERY_UV_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_structure.h b/source/blender/bmesh/intern/bmesh_structure.h
index 38c75dec354..b3b9536618c 100644
--- a/source/blender/bmesh/intern/bmesh_structure.h
+++ b/source/blender/bmesh/intern/bmesh_structure.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BMESH_STRUCTURE_H__
-#define __BMESH_STRUCTURE_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -93,5 +92,3 @@ BMEdge *bmesh_disk_edge_exists(const BMVert *v1, const BMVert *v2) ATTR_WARN_UNU
bool bmesh_disk_validate(int len, BMEdge *e, BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
#include "intern/bmesh_structure_inline.h"
-
-#endif /* __BMESH_STRUCTURE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_structure_inline.h b/source/blender/bmesh/intern/bmesh_structure_inline.h
index 26d161693af..85a84dde4ad 100644
--- a/source/blender/bmesh/intern/bmesh_structure_inline.h
+++ b/source/blender/bmesh/intern/bmesh_structure_inline.h
@@ -20,8 +20,7 @@
* BMesh inline operator functions.
*/
-#ifndef __BMESH_STRUCTURE_INLINE_H__
-#define __BMESH_STRUCTURE_INLINE_H__
+#pragma once
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2)
BLI_INLINE BMDiskLink *bmesh_disk_edge_link_from_vert(const BMEdge *e, const BMVert *v)
@@ -72,5 +71,3 @@ ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2) BLI_INLINE BMEdge *bmesh_disk_edge_pr
{
return BM_DISK_EDGE_PREV(e, v);
}
-
-#endif /* __BMESH_STRUCTURE_INLINE_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_walkers.h b/source/blender/bmesh/intern/bmesh_walkers.h
index 0b862a5e9a1..a973e12a4c7 100644
--- a/source/blender/bmesh/intern/bmesh_walkers.h
+++ b/source/blender/bmesh/intern/bmesh_walkers.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_WALKERS_H__
-#define __BMESH_WALKERS_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -130,5 +129,3 @@ enum {
/* use with BMW_init, so as not to confuse with restrict flags */
#define BMW_NIL_LAY 0
-
-#endif /* __BMESH_WALKERS_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_walkers_private.h b/source/blender/bmesh/intern/bmesh_walkers_private.h
index 3457a2b9187..721f3c2c65b 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_private.h
+++ b/source/blender/bmesh/intern/bmesh_walkers_private.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_WALKERS_PRIVATE_H__
-#define __BMESH_WALKERS_PRIVATE_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -94,5 +93,3 @@ typedef struct BMwConnectedVertexWalker {
BMwGenericWalker header;
BMVert *curvert;
} BMwConnectedVertexWalker;
-
-#endif /* __BMESH_WALKERS_PRIVATE_H__ */
diff --git a/source/blender/bmesh/operators/bmo_beautify.c b/source/blender/bmesh/operators/bmo_beautify.c
index 36122e06e9b..de26ca5ebd2 100644
--- a/source/blender/bmesh/operators/bmo_beautify.c
+++ b/source/blender/bmesh/operators/bmo_beautify.c
@@ -39,7 +39,10 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
BMFace *f;
BMEdge *e;
const bool use_restrict_tag = BMO_slot_bool_get(op->slots_in, "use_restrict_tag");
- const short flag = (use_restrict_tag ? VERT_RESTRICT_TAG : 0);
+ const short flag =
+ ((use_restrict_tag ? VERT_RESTRICT_TAG : 0) |
+ /* Enable to avoid iterative edge rotation to cause the direction of faces to flip. */
+ EDGE_RESTRICT_DEGENERATE);
const short method = (short)BMO_slot_int_get(op->slots_in, "method");
BMEdge **edge_array;
diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
index 01bdf5d933a..a9879ce025a 100644
--- a/source/blender/bmesh/operators/bmo_smooth_laplacian.c
+++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
@@ -115,7 +115,7 @@ static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numFaces, in
return NULL;
}
- sys->fweights = MEM_callocN(sizeof(float) * 3 * sys->numFaces, "ModLaplSmoothFWeight");
+ sys->fweights = MEM_callocN(sizeof(float[3]) * sys->numFaces, "ModLaplSmoothFWeight");
if (!sys->fweights) {
delete_laplacian_system(sys);
return NULL;
diff --git a/tests/gtests/bmesh/bmesh_core_test.cc b/source/blender/bmesh/tests/bmesh_core_test.cc
index afbc11e0722..afbc11e0722 100644
--- a/tests/gtests/bmesh/bmesh_core_test.cc
+++ b/source/blender/bmesh/tests/bmesh_core_test.cc
diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c
index c877c534376..a25e4666a22 100644
--- a/source/blender/bmesh/tools/bmesh_beautify.c
+++ b/source/blender/bmesh/tools/bmesh_beautify.c
@@ -141,7 +141,8 @@ static void erot_state_alternate(const BMEdge *e, EdRotState *e_state)
static float bm_edge_calc_rotate_beauty__area(const float v1[3],
const float v2[3],
const float v3[3],
- const float v4[3])
+ const float v4[3],
+ const bool lock_degenerate)
{
/* not a loop (only to be able to break out) */
do {
@@ -199,7 +200,8 @@ static float bm_edge_calc_rotate_beauty__area(const float v1[3],
* Allowing to rotate out of a degenerate state can flip the faces
* (when performed iteratively).
*/
- return BLI_polyfill_beautify_quad_rotate_calc_ex(v1_xy, v2_xy, v3_xy, v4_xy, true, NULL);
+ return BLI_polyfill_beautify_quad_rotate_calc_ex(
+ v1_xy, v2_xy, v3_xy, v4_xy, lock_degenerate, NULL);
} while (false);
return FLT_MAX;
@@ -262,7 +264,8 @@ float BM_verts_calc_rotate_beauty(const BMVert *v1,
switch (method) {
case 0:
- return bm_edge_calc_rotate_beauty__area(v1->co, v2->co, v3->co, v4->co);
+ return bm_edge_calc_rotate_beauty__area(
+ v1->co, v2->co, v3->co, v4->co, flag & EDGE_RESTRICT_DEGENERATE);
default:
return bm_edge_calc_rotate_beauty__angle(v1->co, v2->co, v3->co, v4->co);
}
diff --git a/source/blender/bmesh/tools/bmesh_beautify.h b/source/blender/bmesh/tools/bmesh_beautify.h
index f957f0d3560..d0fef828e7c 100644
--- a/source/blender/bmesh/tools/bmesh_beautify.h
+++ b/source/blender/bmesh/tools/bmesh_beautify.h
@@ -14,15 +14,17 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_BEAUTIFY_H__
-#define __BMESH_BEAUTIFY_H__
+#pragma once
/** \file
* \ingroup bmesh
*/
enum {
+ /** Vertices tags must match (special case). */
VERT_RESTRICT_TAG = (1 << 0),
+ /** Don't rotate out of degenerate state (needed for iterative rotation). */
+ EDGE_RESTRICT_DEGENERATE = (1 << 1),
};
void BM_mesh_beautify_fill(BMesh *bm,
@@ -39,5 +41,3 @@ float BM_verts_calc_rotate_beauty(const BMVert *v1,
const BMVert *v4,
const short flag,
const short method);
-
-#endif /* __BMESH_BEAUTIFY_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 39174a49283..b9c9aa3aec8 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -45,6 +45,11 @@
#include "./intern/bmesh_private.h"
+// #define BEVEL_DEBUG_TIME
+#ifdef BEVEL_DEBUG_TIME
+# include "PIL_time.h"
+#endif
+
#define BEVEL_EPSILON_D 1e-6
#define BEVEL_EPSILON 1e-6f
#define BEVEL_EPSILON_SQ 1e-12f
@@ -422,9 +427,8 @@ static FKind get_face_kind(BevelParams *bp, BMFace *f)
/* Are d1 and d2 parallel or nearly so? */
static bool nearly_parallel(const float d1[3], const float d2[3])
{
- float ang;
+ float ang = angle_v3v3(d1, d2);
- ang = angle_v3v3(d1, d2);
return (fabsf(ang) < BEVEL_EPSILON_ANG) || (fabsf(ang - (float)M_PI) < BEVEL_EPSILON_ANG);
}
@@ -488,10 +492,8 @@ static void create_mesh_bmvert(BMesh *bm, VMesh *vm, int i, int j, int k, BMVert
static void copy_mesh_vert(VMesh *vm, int ito, int jto, int kto, int ifrom, int jfrom, int kfrom)
{
- NewVert *nvto, *nvfrom;
-
- nvto = mesh_vert(vm, ito, jto, kto);
- nvfrom = mesh_vert(vm, ifrom, jfrom, kfrom);
+ NewVert *nvto = mesh_vert(vm, ito, jto, kto);
+ NewVert *nvfrom = mesh_vert(vm, ifrom, jfrom, kfrom);
nvto->v = nvfrom->v;
copy_v3_v3(nvto->co, nvfrom->co);
}
@@ -499,9 +501,7 @@ static void copy_mesh_vert(VMesh *vm, int ito, int jto, int kto, int ifrom, int
/* Find the EdgeHalf in bv's array that has edge bme. */
static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme)
{
- int i;
-
- for (i = 0; i < bv->edgecount; i++) {
+ for (int i = 0; i < bv->edgecount; i++) {
if (bv->edges[i].e == bme) {
return &bv->edges[i];
}
@@ -522,15 +522,12 @@ static BevVert *find_bevvert(BevelParams *bp, BMVert *bmv)
*/
static EdgeHalf *find_other_end_edge_half(BevelParams *bp, EdgeHalf *e, BevVert **r_bvother)
{
- BevVert *bvo;
- EdgeHalf *eother;
-
- bvo = find_bevvert(bp, e->is_rev ? e->e->v1 : e->e->v2);
+ BevVert *bvo = find_bevvert(bp, e->is_rev ? e->e->v1 : e->e->v2);
if (bvo) {
if (r_bvother) {
*r_bvother = bvo;
}
- eother = find_edge_half(bvo, e->e);
+ EdgeHalf *eother = find_edge_half(bvo, e->e);
BLI_assert(eother != NULL);
return eother;
}
@@ -544,12 +541,10 @@ static EdgeHalf *find_other_end_edge_half(BevelParams *bp, EdgeHalf *e, BevVert
* If from_e is NULL, find the first beveled edge. */
static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e)
{
- EdgeHalf *e;
-
if (from_e == NULL) {
from_e = &bv->edges[bv->edgecount - 1];
}
- e = from_e;
+ EdgeHalf *e = from_e;
do {
if (e->is_bev) {
return e;
@@ -579,9 +574,8 @@ static int count_ccw_edges_between(EdgeHalf *e1, EdgeHalf *e2)
* where the next or previous edge in the face must be bme2. */
static bool edges_face_connected_at_vert(BMEdge *bme1, BMEdge *bme2)
{
- BMLoop *l;
BMIter iter;
-
+ BMLoop *l;
BM_ITER_ELEM (l, &iter, bme1, BM_LOOPS_OF_EDGE) {
if (l->prev->e == bme2 || l->next->e == bme2) {
return true;
@@ -599,9 +593,9 @@ static bool edges_face_connected_at_vert(BMEdge *bme1, BMEdge *bme2)
*/
static BMFace *boundvert_rep_face(BoundVert *v, BMFace **r_fother)
{
- BMFace *frep, *frep2;
+ BMFace *frep;
- frep2 = NULL;
+ BMFace *frep2 = NULL;
if (v->ebev) {
frep = v->ebev->fprev;
if (v->efirst->fprev != frep) {
@@ -670,20 +664,16 @@ static BMFace *bev_create_ngon(BMesh *bm,
int mat_nr,
bool do_interp)
{
- BMIter iter;
- BMLoop *l;
- BMFace *f, *interp_f;
- BMEdge *bme;
- float save_co[3];
- int i;
-
- f = BM_face_create_verts(bm, vert_arr, totv, facerep, BM_CREATE_NOP, true);
+ BMFace *f = BM_face_create_verts(bm, vert_arr, totv, facerep, BM_CREATE_NOP, true);
if ((facerep || (face_arr && face_arr[0])) && f) {
BM_elem_attrs_copy(bm, bm, facerep ? facerep : face_arr[0], f);
if (do_interp) {
- i = 0;
+ int i = 0;
+ BMIter iter;
+ BMLoop *l;
BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
+ BMFace *interp_f;
if (face_arr) {
/* Assume loops of created face are in same order as verts. */
BLI_assert(l->v == vert_arr[i]);
@@ -693,10 +683,11 @@ static BMFace *bev_create_ngon(BMesh *bm,
interp_f = facerep;
}
if (interp_f) {
- bme = NULL;
+ BMEdge *bme = NULL;
if (edge_arr) {
bme = edge_arr[i];
}
+ float save_co[3];
if (bme) {
copy_v3_v3(save_co, l->v->co);
closest_to_line_segment_v3(l->v->co, save_co, bme->v1->co, bme->v2->co);
@@ -715,6 +706,8 @@ static BMFace *bev_create_ngon(BMesh *bm,
* this is done so the operator can select newly created geometry. */
if (f) {
BM_elem_flag_enable(f, BM_ELEM_TAG);
+ BMIter iter;
+ BMEdge *bme;
BM_ITER_ELEM (bme, &iter, f, BM_EDGES_OF_FACE) {
flag_out_edge(bm, bme);
}
@@ -779,16 +772,11 @@ static bool contig_ldata_across_loops(BMesh *bm, BMLoop *l1, BMLoop *l2, int lay
*/
static bool contig_ldata_across_edge(BMesh *bm, BMEdge *e, BMFace *f1, BMFace *f2)
{
- BMLoop *lef1, *lef2;
- BMLoop *lv1f1, *lv1f2, *lv2f1, *lv2f2;
- BMVert *v1, *v2;
- UNUSED_VARS_NDEBUG(v1, v2);
- int i;
-
if (bm->ldata.totlayer == 0) {
return true;
}
+ BMLoop *lef1, *lef2;
if (!BM_edge_loop_pair(e, &lef1, &lef2)) {
return false;
}
@@ -801,16 +789,17 @@ static bool contig_ldata_across_edge(BMesh *bm, BMEdge *e, BMFace *f1, BMFace *f
if (lef1->f != f1 || lef2->f != f2) {
return false;
}
- v1 = lef1->v;
- v2 = lef2->v;
+ BMVert *v1 = lef1->v;
+ BMVert *v2 = lef2->v;
BLI_assert((v1 == e->v1 && v2 == e->v2) || (v1 == e->v2 && v2 == e->v1));
- lv1f1 = lef1;
- lv2f1 = lef1->next;
- lv1f2 = lef2->next;
- lv2f2 = lef2;
+ UNUSED_VARS_NDEBUG(v1, v2);
+ BMLoop *lv1f1 = lef1;
+ BMLoop *lv2f1 = lef1->next;
+ BMLoop *lv1f2 = lef2->next;
+ BMLoop *lv2f2 = lef2;
BLI_assert(lv1f1->v == v1 && lv1f1->f == f1 && lv2f1->v == v2 && lv2f1->f == f1 &&
lv1f2->v == v1 && lv1f2->f == f2 && lv2f2->v == v2 && lv2f2->f == f2);
- for (i = 0; i < bm->ldata.totlayer; i++) {
+ for (int i = 0; i < bm->ldata.totlayer; i++) {
if (CustomData_layer_has_math(&bm->ldata, i)) {
if (!contig_ldata_across_loops(bm, lv1f1, lv1f2, i) ||
!contig_ldata_across_loops(bm, lv2f1, lv2f2, i)) {
@@ -829,18 +818,9 @@ static bool contig_ldata_across_edge(BMesh *bm, BMEdge *e, BMFace *f1, BMFace *f
*/
static void math_layer_info_init(BevelParams *bp, BMesh *bm)
{
- int i, f, stack_top, totface, current_component;
- int bmf_index, bmf_other_index;
- int *face_component;
- BMFace *bmf, *bmf_other;
- BMEdge *bme;
- BMFace **stack;
- bool *in_stack;
- BMIter eiter, fiter;
-
bp->math_layer_info.has_math_layers = false;
bp->math_layer_info.face_component = NULL;
- for (i = 0; i < bm->ldata.totlayer; i++) {
+ for (int i = 0; i < bm->ldata.totlayer; i++) {
if (CustomData_has_layer(&bm->ldata, CD_MLOOPUV)) {
bp->math_layer_info.has_math_layers = true;
break;
@@ -852,32 +832,32 @@ static void math_layer_info_init(BevelParams *bp, BMesh *bm)
BM_mesh_elem_index_ensure(bm, BM_FACE);
BM_mesh_elem_table_ensure(bm, BM_FACE);
- totface = bm->totface;
- face_component = BLI_memarena_alloc(bp->mem_arena, totface * sizeof(int));
+ int totface = bm->totface;
+ int *face_component = BLI_memarena_alloc(bp->mem_arena, sizeof(int) * totface);
bp->math_layer_info.face_component = face_component;
/* Use an array as a stack. Stack size can't exceed total faces if keep track of what is in
* stack. */
- stack = MEM_malloc_arrayN(totface, sizeof(BMFace *), __func__);
- in_stack = MEM_malloc_arrayN(totface, sizeof(bool), __func__);
+ BMFace **stack = MEM_malloc_arrayN(totface, sizeof(BMFace *), __func__);
+ bool *in_stack = MEM_malloc_arrayN(totface, sizeof(bool), __func__);
/* Set all component ids by DFS from faces with unassigned components. */
- for (f = 0; f < totface; f++) {
+ for (int f = 0; f < totface; f++) {
face_component[f] = -1;
in_stack[f] = false;
}
- current_component = -1;
- for (f = 0; f < totface; f++) {
+ int current_component = -1;
+ for (int f = 0; f < totface; f++) {
if (face_component[f] == -1 && !in_stack[f]) {
- stack_top = 0;
+ int stack_top = 0;
current_component++;
BLI_assert(stack_top < totface);
stack[stack_top] = BM_face_at_index(bm, f);
in_stack[f] = true;
while (stack_top >= 0) {
- bmf = stack[stack_top];
+ BMFace *bmf = stack[stack_top];
stack_top--;
- bmf_index = BM_elem_index_get(bmf);
+ int bmf_index = BM_elem_index_get(bmf);
in_stack[bmf_index] = false;
if (face_component[bmf_index] != -1) {
continue;
@@ -887,10 +867,14 @@ static void math_layer_info_init(BevelParams *bp, BMesh *bm)
* are where contig_ldata_across_edge(...) is true for the
* shared edge and two faces.
*/
+ BMIter eiter;
+ BMEdge *bme;
BM_ITER_ELEM (bme, &eiter, bmf, BM_EDGES_OF_FACE) {
+ BMIter fiter;
+ BMFace *bmf_other;
BM_ITER_ELEM (bmf_other, &fiter, bme, BM_FACES_OF_EDGE) {
if (bmf_other != bmf) {
- bmf_other_index = BM_elem_index_get(bmf_other);
+ int bmf_other_index = BM_elem_index_get(bmf_other);
if (face_component[bmf_other_index] != -1 || in_stack[bmf_other_index]) {
continue;
}
@@ -924,26 +908,22 @@ static void math_layer_info_init(BevelParams *bp, BMesh *bm)
*/
static BMFace *choose_rep_face(BevelParams *bp, BMFace **face, int nfaces)
{
- int bmf_index, value_index, best_f, i;
- BMFace *bmf;
- float cent[3];
#define VEC_VALUE_LEN 6
float(*value_vecs)[VEC_VALUE_LEN] = NULL;
- bool *still_viable = NULL;
int num_viable = 0;
value_vecs = BLI_array_alloca(value_vecs, nfaces);
- still_viable = BLI_array_alloca(still_viable, nfaces);
+ bool *still_viable = BLI_array_alloca(still_viable, nfaces);
for (int f = 0; f < nfaces; f++) {
- bmf = face[f];
+ BMFace *bmf = face[f];
if (bmf == NULL) {
still_viable[f] = false;
continue;
}
still_viable[f] = true;
num_viable++;
- bmf_index = BM_elem_index_get(bmf);
- value_index = 0;
+ int bmf_index = BM_elem_index_get(bmf);
+ int value_index = 0;
/* First tie-breaker: lower math-layer connected component id. */
value_vecs[f][value_index++] = bp->math_layer_info.face_component ?
(float)bp->math_layer_info.face_component[bmf_index] :
@@ -953,6 +933,7 @@ static BMFace *choose_rep_face(BevelParams *bp, BMFace **face, int nfaces)
/* Next tie-breaker: lower material index. */
value_vecs[f][value_index++] = bmf->mat_nr >= 0 ? (float)bmf->mat_nr : 0.0f;
/* Next three tie-breakers: z, x, y components of face center. */
+ float cent[3];
BM_face_calc_center_bounds(bmf, cent);
value_vecs[f][value_index++] = cent[2];
value_vecs[f][value_index++] = cent[0];
@@ -963,8 +944,8 @@ static BMFace *choose_rep_face(BevelParams *bp, BMFace **face, int nfaces)
/* Look for a face that has a unique minimum value for in a value_index,
* trying each value_index in turn until find a unique minimum.
*/
- best_f = -1;
- for (value_index = 0; num_viable > 1 && value_index < VEC_VALUE_LEN; value_index++) {
+ int best_f = -1;
+ for (int value_index = 0; num_viable > 1 && value_index < VEC_VALUE_LEN; value_index++) {
for (int f = 0; f < nfaces; f++) {
if (!still_viable[f] || f == best_f) {
continue;
@@ -976,7 +957,7 @@ static BMFace *choose_rep_face(BevelParams *bp, BMFace **face, int nfaces)
if (value_vecs[f][value_index] < value_vecs[best_f][value_index]) {
best_f = f;
/* Previous f's are now not viable any more. */
- for (i = f - 1; i >= 0; i--) {
+ for (int i = f - 1; i >= 0; i--) {
if (still_viable[i]) {
still_viable[i] = false;
num_viable--;
@@ -1000,32 +981,28 @@ static BMFace *choose_rep_face(BevelParams *bp, BMFace **face, int nfaces)
* Caller should ensure that no seams are violated by doing this. */
static void bev_merge_uvs(BMesh *bm, BMVert *v)
{
- BMIter iter;
- MLoopUV *luv;
- BMLoop *l;
- float uv[2];
- int n;
int num_of_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
- int i;
- for (i = 0; i < num_of_uv_layers; i++) {
+ for (int i = 0; i < num_of_uv_layers; i++) {
int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i);
if (cd_loop_uv_offset == -1) {
return;
}
- n = 0;
- zero_v2(uv);
+ int n = 0;
+ float uv[2] = {0.0f, 0.0f};
+ BMIter iter;
+ BMLoop *l;
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
add_v2_v2(uv, luv->uv);
n++;
}
if (n > 1) {
mul_v2_fl(uv, 1.0f / (float)n);
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
copy_v2_v2(luv->uv, uv);
}
}
@@ -1036,15 +1013,12 @@ static void bev_merge_uvs(BMesh *bm, BMVert *v)
* and part of faces that share edge bme. */
static void bev_merge_edge_uvs(BMesh *bm, BMEdge *bme, BMVert *v)
{
- BMIter iter;
- MLoopUV *luv;
- BMLoop *l, *l1, *l2;
- float uv[2];
int num_of_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
- int i;
- l1 = NULL;
- l2 = NULL;
+ BMLoop *l1 = NULL;
+ BMLoop *l2 = NULL;
+ BMIter iter;
+ BMLoop *l;
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
if (l->e == bme) {
l1 = l;
@@ -1057,15 +1031,15 @@ static void bev_merge_edge_uvs(BMesh *bm, BMEdge *bme, BMVert *v)
return;
}
- for (i = 0; i < num_of_uv_layers; i++) {
+ for (int i = 0; i < num_of_uv_layers; i++) {
int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i);
if (cd_loop_uv_offset == -1) {
return;
}
- zero_v2(uv);
- luv = BM_ELEM_CD_GET_VOID_P(l1, cd_loop_uv_offset);
+ float uv[2] = {0.0f, 0.0f};
+ MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l1, cd_loop_uv_offset);
add_v2_v2(uv, luv->uv);
luv = BM_ELEM_CD_GET_VOID_P(l2, cd_loop_uv_offset);
add_v2_v2(uv, luv->uv);
@@ -1080,10 +1054,10 @@ static void bev_merge_edge_uvs(BMesh *bm, BMEdge *bme, BMVert *v)
/* Calculate coordinates of a point a distance d from v on e->e and return it in slideco. */
static void slide_dist(EdgeHalf *e, BMVert *v, float d, float r_slideco[3])
{
- float dir[3], len;
-
+ float dir[3];
sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co);
- len = normalize_v3(dir);
+ float len = normalize_v3(dir);
+
if (d > len) {
d = len - (float)(50.0 * BEVEL_EPSILON_D);
}
@@ -1094,12 +1068,13 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float r_slideco[3])
/* Is co not on the edge e? If not, return the closer end of e in ret_closer_v. */
static bool is_outside_edge(EdgeHalf *e, const float co[3], BMVert **ret_closer_v)
{
- float h[3], u[3], lambda, lenu, *l1 = e->e->v1->co;
+ float h[3], u[3];
+ float *l1 = e->e->v1->co;
sub_v3_v3v3(u, e->e->v2->co, l1);
sub_v3_v3v3(h, co, l1);
- lenu = normalize_v3(u);
- lambda = dot_v3v3(u, h);
+ float lenu = normalize_v3(u);
+ float lambda = dot_v3v3(u, h);
if (lambda <= -BEVEL_EPSILON_BIG * lenu) {
*ret_closer_v = e->e->v1;
return true;
@@ -1114,18 +1089,18 @@ 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)
{
- BMVert *v1, *v2;
- float dir1[3], dir2[3], cross[3], *no, dot;
-
- v1 = BM_edge_other_vert(e1->e, v);
- v2 = BM_edge_other_vert(e2->e, v);
+ BMVert *v1 = BM_edge_other_vert(e1->e, v);
+ BMVert *v2 = BM_edge_other_vert(e2->e, v);
+ float dir1[3], dir2[3];
sub_v3_v3v3(dir1, v->co, v1->co);
sub_v3_v3v3(dir2, v->co, v2->co);
normalize_v3(dir1);
normalize_v3(dir2);
/* 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);
normalize_v3(cross);
+ float *no;
if (e1->fnext) {
no = e1->fnext->no;
}
@@ -1135,7 +1110,7 @@ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v)
else {
no = v->no;
}
- dot = dot_v3v3(cross, no);
+ float dot = dot_v3v3(cross, no);
if (fabsf(dot) < BEVEL_EPSILON_BIG) {
return ANGLE_STRAIGHT;
}
@@ -1147,22 +1122,21 @@ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v)
/* co should be approximately on the plane between e1 and e2, which share common vert v and common
* face f (which cannot be NULL). Is it between those edges, sweeping CCW? */
-static bool point_between_edges(float co[3], BMVert *v, BMFace *f, EdgeHalf *e1, EdgeHalf *e2)
+static bool point_between_edges(
+ const float co[3], BMVert *v, BMFace *f, EdgeHalf *e1, EdgeHalf *e2)
{
- BMVert *v1, *v2;
float dir1[3], dir2[3], dirco[3], no[3];
- float ang11, ang1co;
- v1 = BM_edge_other_vert(e1->e, v);
- v2 = BM_edge_other_vert(e2->e, v);
+ BMVert *v1 = BM_edge_other_vert(e1->e, v);
+ BMVert *v2 = BM_edge_other_vert(e2->e, v);
sub_v3_v3v3(dir1, v->co, v1->co);
sub_v3_v3v3(dir2, v->co, v2->co);
sub_v3_v3v3(dirco, v->co, co);
normalize_v3(dir1);
normalize_v3(dir2);
normalize_v3(dirco);
- ang11 = angle_normalized_v3v3(dir1, dir2);
- ang1co = angle_normalized_v3v3(dir1, dirco);
+ float ang11 = angle_normalized_v3v3(dir1, dir2);
+ float ang1co = angle_normalized_v3v3(dir1, dirco);
/* Angles are in [0,pi]. Need to compare cross product with normal to see if they are reflex. */
cross_v3_v3v3(no, dir1, dir2);
if (dot_v3v3(no, f->no) < 0.0f) {
@@ -1201,22 +1175,15 @@ static void offset_meet(EdgeHalf *e1,
float meetco[3],
const EdgeHalf *e_in_plane)
{
- float dir1[3], dir2[3], dir1n[3], dir2p[3], norm_v[3], norm_v1[3], norm_v2[3];
- float norm_perp1[3], norm_perp2[3], off1a[3], off1b[3], off2a[3], off2b[3];
- float isect2[3], dropco[3], plane[4];
- float ang, d;
- BMVert *closer_v;
- EdgeHalf *e, *e1next, *e2prev;
- BMFace *fnext;
- int isect_kind;
-
/* Get direction vectors for two offset lines. */
+ float dir1[3], dir2[3];
sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co);
sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
+ float dir1n[3], dir2p[3];
if (edges_between) {
- e1next = e1->next;
- e2prev = e2->prev;
+ EdgeHalf *e1next = e1->next;
+ EdgeHalf *e2prev = e2->prev;
sub_v3_v3v3(dir1n, BM_edge_other_vert(e1next->e, v)->co, v->co);
sub_v3_v3v3(dir2p, v->co, BM_edge_other_vert(e2prev->e, v)->co);
}
@@ -1226,7 +1193,8 @@ static void offset_meet(EdgeHalf *e1,
zero_v3(dir2p);
}
- ang = angle_v3v3(dir1, dir2);
+ float ang = angle_v3v3(dir1, dir2);
+ float norm_perp1[3];
if (ang < BEVEL_EPSILON_ANG) {
/* Special case: e1 and e2 are parallel; put offset point perp to both, from v.
* need to find a suitable plane.
@@ -1236,6 +1204,7 @@ static void offset_meet(EdgeHalf *e1,
* If offsets are different, we're out of luck:
* Use the max of the two (so get consistent looking results if the same situation
* arises elsewhere in the object but with opposite roles for e1 and e2. */
+ float norm_v[3];
if (f) {
copy_v3_v3(norm_v, f->no);
}
@@ -1245,8 +1214,9 @@ static void offset_meet(EdgeHalf *e1,
add_v3_v3(dir1, dir2);
cross_v3_v3v3(norm_perp1, dir1, norm_v);
normalize_v3(norm_perp1);
+ float off1a[3];
copy_v3_v3(off1a, v->co);
- d = max_ff(e1->offset_r, e2->offset_l);
+ float d = max_ff(e1->offset_r, e2->offset_l);
d = d / cosf(ang / 2.0f);
madd_v3_v3fl(off1a, norm_perp1, d);
copy_v3_v3(meetco, off1a);
@@ -1254,7 +1224,7 @@ static void offset_meet(EdgeHalf *e1,
else if (fabsf(ang - (float)M_PI) < BEVEL_EPSILON_ANG) {
/* Special case: e1 and e2 are antiparallel, so bevel is into a zero-area face.
* Just make the offset point on the common line, at offset distance from v. */
- d = max_ff(e1->offset_r, e2->offset_l);
+ float d = max_ff(e1->offset_r, e2->offset_l);
slide_dist(e2, v, d, meetco);
}
else {
@@ -1267,6 +1237,7 @@ static void offset_meet(EdgeHalf *e1,
* If e1-v-e2 is a reflex angle (viewed from vertex normal side), need to flip.
* Use f->no to figure out which side to look at angle from, as even if f is non-planar,
* will be more accurate than vertex normal. */
+ float norm_v1[3], norm_v2[3];
if (f && ang < BEVEL_SMALL_ANG) {
copy_v3_v3(norm_v1, f->no);
copy_v3_v3(norm_v2, f->no);
@@ -1296,12 +1267,14 @@ static void offset_meet(EdgeHalf *e1,
}
/* Get vectors perp to each edge, perp to norm_v, and pointing into face. */
+ float norm_perp2[3];
cross_v3_v3v3(norm_perp1, dir1, norm_v1);
cross_v3_v3v3(norm_perp2, dir2, norm_v2);
normalize_v3(norm_perp1);
normalize_v3(norm_perp2);
/* Get points that are offset distances from each line, then another point on each line. */
+ float off1a[3], off1b[3], off2a[3], off2b[3];
copy_v3_v3(off1a, v->co);
madd_v3_v3fl(off1a, norm_perp1, e1->offset_r);
add_v3_v3v3(off1b, off1a, dir1);
@@ -1310,7 +1283,8 @@ static void offset_meet(EdgeHalf *e1,
add_v3_v3v3(off2b, off2a, dir2);
/* Intersect the offset lines. */
- isect_kind = isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2);
+ float isect2[3];
+ int isect_kind = isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2);
if (isect_kind == 0) {
/* Lines are collinear: we already tested for this, but this used a different epsilon. */
copy_v3_v3(meetco, off1a); /* Just to do something. */
@@ -1320,6 +1294,7 @@ static void offset_meet(EdgeHalf *e1,
* One problem to check: if one of the offsets is 0, then we don't want an intersection
* that is outside that edge itself. This can happen if angle between them is > 180 degrees,
* or if the offset amount is > the edge length. */
+ BMVert *closer_v;
if (e1->offset_r == 0.0f && is_outside_edge(e1, meetco, &closer_v)) {
copy_v3_v3(meetco, closer_v->co);
}
@@ -1332,12 +1307,14 @@ static void offset_meet(EdgeHalf *e1,
/* Lines didn't meet in 3d: get average of meetco and isect2. */
mid_v3_v3v3(meetco, meetco, isect2);
}
- for (e = e1; e != e2; e = e->next) {
- fnext = e->fnext;
+ for (EdgeHalf *e = e1; e != e2; e = e->next) {
+ BMFace *fnext = e->fnext;
if (!fnext) {
continue;
}
+ float plane[4];
plane_from_point_normal_v3(plane, v->co, fnext->no);
+ float dropco[3];
closest_to_plane_normalized_v3(dropco, plane, meetco);
/* Don't drop to the faces next to the in plane edge. */
if (e_in_plane) {
@@ -1370,21 +1347,21 @@ static void offset_meet(EdgeHalf *e1,
static bool offset_meet_edge(
EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float meetco[3], float *r_angle)
{
- float dir1[3], dir2[3], fno[3], ang, sinang;
-
+ float dir1[3], dir2[3];
sub_v3_v3v3(dir1, BM_edge_other_vert(e1->e, v)->co, v->co);
sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
normalize_v3(dir1);
normalize_v3(dir2);
/* Find angle from dir1 to dir2 as viewed from vertex normal side. */
- ang = angle_normalized_v3v3(dir1, dir2);
+ float ang = angle_normalized_v3v3(dir1, dir2);
if (fabsf(ang) < BEVEL_GOOD_ANGLE) {
if (r_angle) {
*r_angle = 0.0f;
}
return false;
}
+ float fno[3];
cross_v3_v3v3(fno, dir1, dir2);
if (dot_v3v3(fno, v->no) < 0.0f) {
ang = 2.0f * (float)M_PI - ang; /* Angle is reflex. */
@@ -1401,7 +1378,7 @@ static bool offset_meet_edge(
return false;
}
- sinang = sinf(ang);
+ float sinang = sinf(ang);
copy_v3_v3(meetco, v->co);
if (e1->offset_r == 0.0f) {
@@ -1434,15 +1411,14 @@ static bool good_offset_on_edge_between(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *em
static bool offset_on_edge_between(
EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, BMVert *v, float meetco[3], float *r_sinratio)
{
- float ang1, ang2;
- float meet1[3], meet2[3];
- bool ok1, ok2;
bool retval = false;
BLI_assert(e1->is_bev && e2->is_bev && !emid->is_bev);
- ok1 = offset_meet_edge(e1, emid, v, meet1, &ang1);
- ok2 = offset_meet_edge(emid, e2, v, meet2, &ang2);
+ float ang1, ang2;
+ 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 (ok1 && ok2) {
mid_v3_v3v3(meetco, meet1, meet2);
if (r_sinratio) {
@@ -1470,11 +1446,9 @@ static bool offset_on_edge_between(
* If plane_no is NULL, choose an arbitrary plane different from eh's direction. */
static void offset_in_plane(EdgeHalf *e, const float plane_no[3], bool left, float r_co[3])
{
- float dir[3], no[3], fdir[3];
- BMVert *v;
-
- v = e->is_rev ? e->e->v2 : e->e->v1;
+ BMVert *v = e->is_rev ? e->e->v2 : e->e->v1;
+ float dir[3], no[3];
sub_v3_v3v3(dir, BM_edge_other_vert(e->e, v)->co, v->co);
normalize_v3(dir);
if (plane_no) {
@@ -1489,6 +1463,8 @@ static void offset_in_plane(EdgeHalf *e, const float plane_no[3], bool left, flo
no[1] = 1.0f;
}
}
+
+ float fdir[3];
if (left) {
cross_v3_v3v3(fdir, dir, no);
}
@@ -1507,7 +1483,6 @@ static void project_to_edge(const BMEdge *e,
float projco[3])
{
float otherco[3];
-
if (!isect_line_line_v3(e->v1->co, e->v2->co, co_a, co_b, projco, otherco)) {
#ifdef BEVEL_ASSERT_PROJECT
BLI_assert(!"project meet failure");
@@ -1520,11 +1495,11 @@ static void project_to_edge(const BMEdge *e,
* It is the closest point on the beveled edge to the line segment between bndv and bndv->next. */
static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
{
- float start[3], end[3], co3[3], d1[3], d2[3];
bool do_linear_interp = true;
EdgeHalf *e = bndv->ebev;
Profile *pro = &bndv->profile;
+ float start[3], end[3];
copy_v3_v3(start, bndv->nv.co);
copy_v3_v3(end, bndv->next->nv.co);
if (e) {
@@ -1540,6 +1515,7 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
copy_v3_v3(pro->start, start);
copy_v3_v3(pro->end, end);
/* Default plane to project onto is the one with triangle start - middle - end in it. */
+ float d1[3], d2[3];
sub_v3_v3v3(d1, pro->middle, start);
sub_v3_v3v3(d2, pro->middle, end);
normalize_v3(d1);
@@ -1571,6 +1547,7 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
do_linear_interp = true;
}
else {
+ float co3[3];
add_v3_v3v3(co3, start, d3);
add_v3_v3v3(co4, end, d4);
isect_kind = isect_line_line_v3(start, co3, end, co4, meetco, isect2);
@@ -1644,24 +1621,27 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
*/
static void move_profile_plane(BoundVert *bndv, BMVert *bmvert)
{
- float d1[3], d2[3], no[3], no2[3], no3[3], dot2, dot3;
Profile *pro = &bndv->profile;
/* Only do this if projecting, and start, end, and proj_dir are not coplanar. */
if (is_zero_v3(pro->proj_dir)) {
return;
}
+
+ float d1[3], d2[3];
sub_v3_v3v3(d1, bmvert->co, pro->start);
normalize_v3(d1);
sub_v3_v3v3(d2, bmvert->co, pro->end);
normalize_v3(d2);
+ float no[3], no2[3], no3[3];
cross_v3_v3v3(no, d1, d2);
cross_v3_v3v3(no2, d1, pro->proj_dir);
cross_v3_v3v3(no3, d2, pro->proj_dir);
+
if (normalize_v3(no) > BEVEL_EPSILON_BIG && normalize_v3(no2) > BEVEL_EPSILON_BIG &&
normalize_v3(no3) > BEVEL_EPSILON_BIG) {
- dot2 = dot_v3v3(no, no2);
- dot3 = dot_v3v3(no, no3);
+ float dot2 = dot_v3v3(no, no2);
+ float dot3 = dot_v3v3(no, no3);
if (fabsf(dot2) < (1 - BEVEL_EPSILON_BIG) && fabsf(dot3) < (1 - BEVEL_EPSILON_BIG)) {
copy_v3_v3(bndv->profile.plane_no, no);
}
@@ -1680,25 +1660,26 @@ static void move_profile_plane(BoundVert *bndv, BMVert *bmvert)
*/
static void move_weld_profile_planes(BevVert *bv, BoundVert *bndv1, BoundVert *bndv2)
{
- float d1[3], d2[3], no[3], no2[3], no3[3], dot1, dot2, l1, l2, l3;
-
/* Only do this if projecting, and d1, d2, and proj_dir are not coplanar. */
if (is_zero_v3(bndv1->profile.proj_dir) || is_zero_v3(bndv2->profile.proj_dir)) {
return;
}
+ float d1[3], d2[3], no[3];
sub_v3_v3v3(d1, bv->v->co, bndv1->nv.co);
sub_v3_v3v3(d2, bv->v->co, bndv2->nv.co);
cross_v3_v3v3(no, d1, d2);
- l1 = normalize_v3(no);
+ float l1 = normalize_v3(no);
+
/* "no" is new normal projection plane, but don't move if it is coplanar with both of the
* projection dirs. */
+ float no2[3], no3[3];
cross_v3_v3v3(no2, d1, bndv1->profile.proj_dir);
- l2 = normalize_v3(no2);
+ float l2 = normalize_v3(no2);
cross_v3_v3v3(no3, d2, bndv2->profile.proj_dir);
- l3 = normalize_v3(no3);
+ float l3 = normalize_v3(no3);
if (l1 > BEVEL_EPSILON && (l2 > BEVEL_EPSILON || l3 > BEVEL_EPSILON)) {
- dot1 = fabsf(dot_v3v3(no, no2));
- dot2 = fabsf(dot_v3v3(no, no3));
+ float dot1 = fabsf(dot_v3v3(no, no2));
+ float dot2 = fabsf(dot_v3v3(no, no3));
if (fabsf(dot1 - 1.0f) > BEVEL_EPSILON) {
copy_v3_v3(bndv1->profile.plane_no, no);
}
@@ -1716,13 +1697,11 @@ static void move_weld_profile_planes(BevVert *bv, BoundVert *bndv1, BoundVert *b
* and -1 if they are reversed, and 0 if there is no shared face f. */
static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f)
{
- BMLoop *la, *lb;
-
if (!f) {
return 0;
}
- la = BM_face_edge_share_loop(f, a);
- lb = BM_face_edge_share_loop(f, b);
+ BMLoop *la = BM_face_edge_share_loop(f, a);
+ BMLoop *lb = BM_face_edge_share_loop(f, b);
if (!la || !lb) {
return 0;
}
@@ -1755,8 +1734,7 @@ static bool make_unit_square_map(const float va[3],
const float vb[3],
float r_mat[4][4])
{
- float vo[3], vd[3], vb_vmid[3], va_vmid[3], vddir[3];
-
+ float vb_vmid[3], va_vmid[3];
sub_v3_v3v3(va_vmid, vmid, va);
sub_v3_v3v3(vb_vmid, vmid, vb);
@@ -1768,6 +1746,7 @@ static bool make_unit_square_map(const float va[3],
return false;
}
+ float vo[3], vd[3], vddir[3];
sub_v3_v3v3(vo, va, vb_vmid);
cross_v3_v3v3(vddir, vb_vmid, va_vmid);
normalize_v3(vddir);
@@ -1865,8 +1844,6 @@ static double superellipse_co(double x, float r, bool rbig)
*/
static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int nseg, float r_co[3])
{
- int subsample_spacing;
-
if (bp->seg == 1) {
if (i == 0) {
copy_v3_v3(r_co, pro->start);
@@ -1884,13 +1861,66 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int ns
else {
BLI_assert(is_power_of_2_i(nseg) && nseg <= bp->pro_spacing.seg_2);
/* Find spacing between subsamples in prof_co_2. */
- subsample_spacing = bp->pro_spacing.seg_2 / nseg;
+ int subsample_spacing = bp->pro_spacing.seg_2 / nseg;
copy_v3_v3(r_co, pro->prof_co_2 + 3 * i * subsample_spacing);
}
}
}
/**
+ * Helper for #calculate_profile that builds the 3D locations for the segments
+ * and the higher power of 2 segments.
+ */
+static void calculate_profile_segments(const Profile *profile,
+ const float map[4][4],
+ const bool use_map,
+ const bool reversed,
+ const int ns,
+ const double *xvals,
+ const double *yvals,
+ float *r_prof_co)
+{
+ /* Iterate over the vertices along the boundary arc. */
+ for (int k = 0; k <= ns; k++) {
+ float co[3];
+ if (k == 0) {
+ copy_v3_v3(co, profile->start);
+ }
+ else if (k == ns) {
+ copy_v3_v3(co, profile->end);
+ }
+ else {
+ if (use_map) {
+ const float p[3] = {
+ reversed ? (float)yvals[ns - k] : (float)xvals[k],
+ reversed ? (float)xvals[ns - k] : (float)yvals[k],
+ 0.0f,
+ };
+ /* Do the 2D->3D transformation of the profile coordinates. */
+ mul_v3_m4v3(co, map, p);
+ }
+ else {
+ interp_v3_v3v3(co, profile->start, profile->end, (float)k / (float)ns);
+ }
+ }
+ /* Finish the 2D->3D transformation by projecting onto the final profile plane. */
+ float *prof_co_k = r_prof_co + 3 * k;
+ if (!is_zero_v3(profile->proj_dir)) {
+ float co2[3];
+ add_v3_v3v3(co2, co, profile->proj_dir);
+ /* pro->plane_co and pro->plane_no are filled in #set_profile_params. */
+ if (!isect_line_plane_v3(prof_co_k, co, co2, profile->plane_co, profile->plane_no)) {
+ /* Shouldn't happen. */
+ copy_v3_v3(prof_co_k, co);
+ }
+ }
+ else {
+ copy_v3_v3(prof_co_k, co);
+ }
+ }
+}
+
+/**
* Calculate the actual coordinate values for bndv's profile.
* This is only needed if bp->seg > 1.
* Allocate the space for them if that hasn't been done already.
@@ -1900,12 +1930,6 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int ns
*/
static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, bool miter)
{
- int i, k, ns;
- const double *xvals, *yvals;
- float co[3], co2[3], p[3], map[4][4], bottom_corner[3], top_corner[3];
- float *prof_co, *prof_co_k;
- float r;
- bool need_2, map_ok;
Profile *pro = &bndv->profile;
ProfileSpacing *pro_spacing = (miter) ? &bp->pro_spacing_miter : &bp->pro_spacing;
@@ -1913,89 +1937,51 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, b
return;
}
- need_2 = bp->seg != bp->pro_spacing.seg_2;
- if (!pro->prof_co) {
- pro->prof_co = (float *)BLI_memarena_alloc(bp->mem_arena,
- ((size_t)bp->seg + 1) * 3 * sizeof(float));
+ bool need_2 = bp->seg != bp->pro_spacing.seg_2;
+ if (pro->prof_co == NULL) {
+ pro->prof_co = (float *)BLI_memarena_alloc(bp->mem_arena, sizeof(float[3]) * (bp->seg + 1));
if (need_2) {
- pro->prof_co_2 = (float *)BLI_memarena_alloc(
- bp->mem_arena, ((size_t)bp->pro_spacing.seg_2 + 1) * 3 * sizeof(float));
+ pro->prof_co_2 = (float *)BLI_memarena_alloc(bp->mem_arena,
+ sizeof(float[3]) * (bp->pro_spacing.seg_2 + 1));
}
else {
pro->prof_co_2 = pro->prof_co;
}
}
- r = pro->super_r;
- if (bp->profile_type == BEVEL_PROFILE_SUPERELLIPSE && r == PRO_LINE_R) {
- map_ok = false;
+
+ bool use_map;
+ float map[4][4];
+ if (bp->profile_type == BEVEL_PROFILE_SUPERELLIPSE && pro->super_r == PRO_LINE_R) {
+ use_map = false;
}
else {
- map_ok = make_unit_square_map(pro->start, pro->middle, pro->end, map);
+ use_map = make_unit_square_map(pro->start, pro->middle, pro->end, map);
}
- if (bp->vmesh_method == BEVEL_VMESH_CUTOFF && map_ok) {
+ if (bp->vmesh_method == BEVEL_VMESH_CUTOFF && use_map) {
/* Calculate the "height" of the profile by putting the (0,0) and (1,1) corners of the
* un-transformed profile through the 2D->3D map and calculating the distance between them. */
- zero_v3(p);
- mul_v3_m4v3(bottom_corner, map, p);
- p[0] = 1.0f;
- p[1] = 1.0f;
- mul_v3_m4v3(top_corner, map, p);
+ float bottom_corner[3] = {0.0f, 0.0f, 0.0f};
+ mul_v3_m4v3(bottom_corner, map, bottom_corner);
+ float top_corner[3] = {1.0f, 1.0f, 0.0f};
+ mul_v3_m4v3(top_corner, map, top_corner);
+
pro->height = len_v3v3(bottom_corner, top_corner);
}
- /* The first iteration is the nseg case, the second is the seg_2 case (if it's needed) .*/
- for (i = 0; i < 2; i++) {
- if (i == 0) {
- ns = bp->seg;
- xvals = pro_spacing->xvals;
- yvals = pro_spacing->yvals;
- prof_co = pro->prof_co;
- }
- else {
- if (!need_2) {
- break; /* Shares coords with pro->prof_co. */
- }
- ns = bp->pro_spacing.seg_2;
- xvals = pro_spacing->xvals_2;
- yvals = pro_spacing->yvals_2;
- prof_co = pro->prof_co_2;
- }
-
- /* Iterate over the vertices along the boundary arc. */
- for (k = 0; k <= ns; k++) {
- if (k == 0) {
- copy_v3_v3(co, pro->start);
- }
- else if (k == ns) {
- copy_v3_v3(co, pro->end);
- }
- else {
- if (map_ok) {
- p[0] = reversed ? (float)yvals[ns - k] : (float)xvals[k];
- p[1] = reversed ? (float)xvals[ns - k] : (float)yvals[k];
- p[2] = 0.0f;
- /* Do the 2D->3D transformation of the profile coordinates. */
- mul_v3_m4v3(co, map, p);
- }
- else {
- interp_v3_v3v3(co, pro->start, pro->end, (float)k / (float)ns);
- }
- }
- /* Finish the 2D->3D transformation by projecting onto the final profile plane. */
- prof_co_k = prof_co + 3 * k; /* Each coord takes up 3 spaces. */
- if (!is_zero_v3(pro->proj_dir)) {
- add_v3_v3v3(co2, co, pro->proj_dir);
- /* pro->plane_co and pro->plane_no are filled in "set_profile_params". */
- if (!isect_line_plane_v3(prof_co_k, co, co2, pro->plane_co, pro->plane_no)) {
- /* Shouldn't happen. */
- copy_v3_v3(prof_co_k, co);
- }
- }
- else {
- copy_v3_v3(prof_co_k, co);
- }
- }
+ /* Calculate the 3D locations for the profile points */
+ calculate_profile_segments(
+ pro, map, use_map, reversed, bp->seg, pro_spacing->xvals, pro_spacing->yvals, pro->prof_co);
+ /* Also calculate for the is the seg_2 case if it's needed .*/
+ if (need_2) {
+ calculate_profile_segments(pro,
+ map,
+ use_map,
+ reversed,
+ bp->pro_spacing.seg_2,
+ pro_spacing->xvals_2,
+ pro_spacing->yvals_2,
+ pro->prof_co_2);
}
}
@@ -2007,16 +1993,18 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, b
*/
static void snap_to_superellipsoid(float co[3], const float super_r, bool midline)
{
- float a, b, c, x, y, z, r, rinv, dx, dy;
- r = super_r;
+ float r = super_r;
if (r == PRO_CIRCLE_R) {
normalize_v3(co);
return;
}
- x = a = max_ff(0.0f, co[0]);
- y = b = max_ff(0.0f, co[1]);
- z = c = max_ff(0.0f, co[2]);
+ float a = max_ff(0.0f, co[0]);
+ float b = max_ff(0.0f, co[1]);
+ float c = max_ff(0.0f, co[2]);
+ float x = a;
+ float y = b;
+ float z = c;
if (r == PRO_SQUARE_R || r == PRO_SQUARE_IN_R) {
/* Will only be called for 2d profile. */
BLI_assert(fabsf(z) < BEVEL_EPSILON);
@@ -2025,8 +2013,8 @@ static void snap_to_superellipsoid(float co[3], const float super_r, bool midlin
y = min_ff(1.0f, y);
if (r == PRO_SQUARE_R) {
/* Snap to closer of x==1 and y==1 lines, or maybe both. */
- dx = 1.0f - x;
- dy = 1.0f - y;
+ float dx = 1.0f - x;
+ float dy = 1.0f - y;
if (dx < dy) {
x = 1.0f;
y = midline ? 1.0f : y;
@@ -2049,7 +2037,7 @@ static void snap_to_superellipsoid(float co[3], const float super_r, bool midlin
}
}
else {
- rinv = 1.0f / r;
+ float rinv = 1.0f / r;
if (a == 0.0f) {
if (b == 0.0f) {
x = 0.0f;
@@ -2234,11 +2222,8 @@ static void bevel_extend_edge_data(BevVert *bv)
/* Mark edges as sharp if they are between a smooth reconstructed face and a new face. */
static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp)
{
- BMIter fiter, liter;
- BMFace *f, *fother;
- BMLoop *l, *lother;
- FKind fkind;
-
+ BMIter fiter;
+ BMFace *f;
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(f, BM_ELEM_SMOOTH)) {
continue;
@@ -2246,12 +2231,14 @@ static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp)
if (get_face_kind(bp, f) != F_RECON) {
continue;
}
+ BMIter liter;
+ BMLoop *l;
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
/* Cases we care about will have exactly one adjacent face. */
- lother = l->radial_next;
- fother = lother->f;
+ BMLoop *lother = l->radial_next;
+ BMFace *fother = lother->f;
if (lother != l && fother) {
- fkind = get_face_kind(bp, lother->f);
+ FKind fkind = get_face_kind(bp, lother->f);
if (ELEM(fkind, F_EDGE, F_VERT)) {
BM_elem_flag_disable(l->e, BM_ELEM_SMOOTH);
}
@@ -2270,15 +2257,6 @@ static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp)
*/
static void bevel_harden_normals(BevelParams *bp, BMesh *bm)
{
- BMIter liter, fiter;
- BMFace *f;
- BMLoop *l, *lnext, *lprev, *lprevprev, *lnextnext;
- BMEdge *estep;
- FKind fkind, fprevkind, fnextkind, fprevprevkind, fnextnextkind;
- int cd_clnors_offset, l_index;
- short *clnors;
- float *pnorm, norm[3];
-
if (bp->offset == 0.0 || !bp->harden_normals) {
return;
}
@@ -2287,7 +2265,7 @@ static void bevel_harden_normals(BevelParams *bp, BMesh *bm)
/* I suspect this is not necessary. TODO: test that guess. */
BM_mesh_normals_update(bm);
- cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
+ int cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
/* If there is not already a custom split normal layer then making one (with BM_lnorspace_update)
* will not respect the autosmooth angle between smooth faces. To get that to happen, we have
@@ -2306,19 +2284,25 @@ static void bevel_harden_normals(BevelParams *bp, BMesh *bm)
cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
}
+ BMIter fiter;
+ BMFace *f;
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
- fkind = get_face_kind(bp, f);
+ FKind fkind = get_face_kind(bp, f);
if (fkind == F_ORIG || fkind == F_RECON) {
continue;
}
+ BMIter liter;
+ BMLoop *l;
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- estep = l->prev->e; /* Causes CW walk around l->v fan. */
- lprev = BM_vert_step_fan_loop(l, &estep);
+ BMEdge *estep = l->prev->e; /* Causes CW walk around l->v fan. */
+ BMLoop *lprev = BM_vert_step_fan_loop(l, &estep);
estep = l->e; /* Causes CCW walk around l->v fan. */
- lnext = BM_vert_step_fan_loop(l, &estep);
- fprevkind = lprev ? get_face_kind(bp, lprev->f) : F_NONE;
- fnextkind = lnext ? get_face_kind(bp, lnext->f) : F_NONE;
- pnorm = NULL;
+ BMLoop *lnext = BM_vert_step_fan_loop(l, &estep);
+ FKind fprevkind = lprev ? get_face_kind(bp, lprev->f) : F_NONE;
+ FKind fnextkind = lnext ? get_face_kind(bp, lnext->f) : F_NONE;
+
+ float norm[3];
+ float *pnorm = NULL;
if (fkind == F_EDGE) {
if (fprevkind == F_EDGE && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
add_v3_v3v3(norm, f->no, lprev->f->no);
@@ -2349,6 +2333,7 @@ static void bevel_harden_normals(BevelParams *bp, BMesh *bm)
pnorm = lnext->f->no;
}
else {
+ BMLoop *lprevprev, *lnextnext;
if (lprev) {
estep = lprev->prev->e;
lprevprev = BM_vert_step_fan_loop(lprev, &estep);
@@ -2363,8 +2348,8 @@ static void bevel_harden_normals(BevelParams *bp, BMesh *bm)
else {
lnextnext = NULL;
}
- fprevprevkind = lprevprev ? get_face_kind(bp, lprevprev->f) : F_NONE;
- fnextnextkind = lnextnext ? get_face_kind(bp, lnextnext->f) : F_NONE;
+ FKind fprevprevkind = lprevprev ? get_face_kind(bp, lprevprev->f) : F_NONE;
+ FKind fnextnextkind = lnextnext ? get_face_kind(bp, lnextnext->f) : F_NONE;
if (fprevkind == F_EDGE && fprevprevkind == F_RECON) {
pnorm = lprevprev->f->no;
}
@@ -2385,8 +2370,8 @@ static void bevel_harden_normals(BevelParams *bp, BMesh *bm)
if (pnorm == norm) {
normalize_v3(norm);
}
- l_index = BM_elem_index_get(l);
- clnors = BM_ELEM_CD_GET_VOID_P(l, cd_clnors_offset);
+ int l_index = BM_elem_index_get(l);
+ short *clnors = BM_ELEM_CD_GET_VOID_P(l, cd_clnors_offset);
BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[l_index], pnorm, clnors);
}
}
@@ -2395,12 +2380,7 @@ static void bevel_harden_normals(BevelParams *bp, BMesh *bm)
static void bevel_set_weighted_normal_face_strength(BMesh *bm, BevelParams *bp)
{
- BMFace *f;
- BMIter fiter;
- FKind fkind;
- int strength;
- int mode = bp->face_strength_mode;
- bool do_set_strength;
+ const int mode = bp->face_strength_mode;
const char *wn_layer_id = MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID;
int cd_prop_int_idx = CustomData_get_named_layer_index(&bm->pdata, CD_PROP_INT32, wn_layer_id);
@@ -2412,9 +2392,12 @@ static void bevel_set_weighted_normal_face_strength(BMesh *bm, BevelParams *bp)
const int cd_prop_int_offset = CustomData_get_n_offset(
&bm->pdata, CD_PROP_INT32, cd_prop_int_idx);
+ BMIter fiter;
+ BMFace *f;
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
- fkind = get_face_kind(bp, f);
- do_set_strength = true;
+ FKind fkind = get_face_kind(bp, f);
+ bool do_set_strength = true;
+ int strength;
switch (fkind) {
case F_VERT:
strength = FACE_STRENGTH_WEAK;
@@ -2445,14 +2428,11 @@ static void bevel_set_weighted_normal_face_strength(BMesh *bm, BevelParams *bp)
/* Set the any_seam property for a BevVert and all its BoundVerts. */
static void set_bound_vert_seams(BevVert *bv, bool mark_seam, bool mark_sharp)
{
- BoundVert *v;
- EdgeHalf *e;
-
bv->any_seam = false;
- v = bv->vmesh->boundstart;
+ BoundVert *v = bv->vmesh->boundstart;
do {
v->any_seam = false;
- for (e = v->efirst; e; e = e->next) {
+ for (EdgeHalf *e = v->efirst; e; e = e->next) {
v->any_seam |= e->is_seam;
if (e == v->elast) {
break;
@@ -2471,14 +2451,12 @@ static void set_bound_vert_seams(BevVert *bv, bool mark_seam, bool mark_sharp)
static int count_bound_vert_seams(BevVert *bv)
{
- int ans, i;
-
if (!bv->any_seam) {
return 0;
}
- ans = 0;
- for (i = 0; i < bv->edgecount; i++) {
+ int ans = 0;
+ for (int i = 0; i < bv->edgecount; i++) {
if (bv->edges[i].is_seam) {
ans++;
}
@@ -2489,10 +2467,8 @@ static int count_bound_vert_seams(BevVert *bv)
/* Is e between two faces with a 180 degree angle between their normals? */
static bool eh_on_plane(EdgeHalf *e)
{
- float dot;
-
if (e->fprev && e->fnext) {
- dot = dot_v3v3(e->fprev->no, e->fnext->no);
+ float dot = dot_v3v3(e->fprev->no, e->fnext->no);
if (fabsf(dot + 1.0f) <= BEVEL_EPSILON_BIG || fabsf(dot - 1.0f) <= BEVEL_EPSILON_BIG) {
return true;
}
@@ -2530,17 +2506,16 @@ static void calculate_vm_profiles(BevelParams *bp, BevVert *bv, VMesh *vm)
static void build_boundary_vertex_only(BevelParams *bp, BevVert *bv, bool construct)
{
VMesh *vm = bv->vmesh;
- EdgeHalf *efirst, *e;
- BoundVert *v;
- float co[3];
BLI_assert(bp->affect_type == BEVEL_AFFECT_VERTICES);
- e = efirst = &bv->edges[0];
+ EdgeHalf *efirst = &bv->edges[0];
+ EdgeHalf *e = efirst;
do {
+ float co[3];
slide_dist(e, bv->v, e->offset_l, co);
if (construct) {
- v = add_new_bound_vert(bp->mem_arena, vm, co);
+ BoundVert *v = add_new_bound_vert(bp->mem_arena, vm, co);
v->efirst = v->elast = e;
e->leftv = e->rightv = v;
}
@@ -2575,19 +2550,15 @@ static void build_boundary_terminal_edge(BevelParams *bp,
{
MemArena *mem_arena = bp->mem_arena;
VMesh *vm = bv->vmesh;
- BoundVert *bndv;
- EdgeHalf *e;
- const float *no;
- float co[3], d;
- bool use_tri_fan;
- e = efirst;
+ EdgeHalf *e = efirst;
+ float co[3];
if (bv->edgecount == 2) {
/* Only 2 edges in, so terminate the edge with an artificial vertex on the unbeveled edge. */
- no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL);
+ const float *no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL);
offset_in_plane(e, no, true, co);
if (construct) {
- bndv = add_new_bound_vert(mem_arena, vm, co);
+ BoundVert *bndv = add_new_bound_vert(mem_arena, vm, co);
bndv->efirst = bndv->elast = bndv->ebev = e;
e->leftv = bndv;
}
@@ -2597,7 +2568,7 @@ static void build_boundary_terminal_edge(BevelParams *bp,
no = e->fnext ? e->fnext->no : (e->fprev ? e->fprev->no : NULL);
offset_in_plane(e, no, false, co);
if (construct) {
- bndv = add_new_bound_vert(mem_arena, vm, co);
+ BoundVert *bndv = add_new_bound_vert(mem_arena, vm, co);
bndv->efirst = bndv->elast = e;
e->rightv = bndv;
}
@@ -2607,7 +2578,7 @@ static void build_boundary_terminal_edge(BevelParams *bp,
/* Make artificial extra point along unbeveled edge, and form triangle. */
slide_dist(e->next, bv->v, e->offset_l, co);
if (construct) {
- bndv = add_new_bound_vert(mem_arena, vm, co);
+ BoundVert *bndv = add_new_bound_vert(mem_arena, vm, co);
bndv->efirst = bndv->elast = e->next;
e->next->leftv = e->next->rightv = bndv;
set_bound_vert_seams(bv, bp->mark_seam, bp->mark_sharp);
@@ -2623,7 +2594,7 @@ static void build_boundary_terminal_edge(BevelParams *bp,
/* TODO: should do something else if angle between e and e->prev > 180 */
offset_meet(e->prev, e, bv->v, e->fprev, false, co, NULL);
if (construct) {
- bndv = add_new_bound_vert(mem_arena, vm, co);
+ BoundVert *bndv = add_new_bound_vert(mem_arena, vm, co);
bndv->efirst = e->prev;
bndv->elast = bndv->ebev = e;
e->leftv = bndv;
@@ -2635,7 +2606,7 @@ static void build_boundary_terminal_edge(BevelParams *bp,
e = e->next;
offset_meet(e->prev, e, bv->v, e->fprev, false, co, NULL);
if (construct) {
- bndv = add_new_bound_vert(mem_arena, vm, co);
+ BoundVert *bndv = add_new_bound_vert(mem_arena, vm, co);
bndv->efirst = e->prev;
bndv->elast = e;
e->leftv = e->rightv = bndv;
@@ -2645,14 +2616,14 @@ static void build_boundary_terminal_edge(BevelParams *bp,
adjust_bound_vert(e->leftv, co);
}
/* For the edges not adjacent to the beveled edge, slide the bevel amount along. */
- d = efirst->offset_l_spec;
+ float d = efirst->offset_l_spec;
if (bp->profile_type == BEVEL_PROFILE_CUSTOM || bp->profile < 0.25f) {
d *= sqrtf(2.0f); /* Need to go further along the edge to make room for full profile area. */
}
for (e = e->next; e->next != efirst; e = e->next) {
slide_dist(e, bv->v, d, co);
if (construct) {
- bndv = add_new_bound_vert(mem_arena, vm, co);
+ BoundVert *bndv = add_new_bound_vert(mem_arena, vm, co);
bndv->efirst = bndv->elast = e;
e->leftv = e->rightv = bndv;
}
@@ -2664,7 +2635,7 @@ static void build_boundary_terminal_edge(BevelParams *bp,
if (bv->edgecount >= 3) {
/* Special case: snap profile to plane of adjacent two edges. */
- bndv = vm->boundstart;
+ BoundVert *bndv = vm->boundstart;
BLI_assert(bndv->ebev != NULL);
set_profile_params(bp, bv, bndv);
move_profile_plane(bndv, bv->v);
@@ -2677,10 +2648,10 @@ static void build_boundary_terminal_edge(BevelParams *bp,
vm->mesh_kind = M_NONE;
}
else if (vm->count == 3) {
- use_tri_fan = true;
+ bool use_tri_fan = true;
if (bp->profile_type == BEVEL_PROFILE_CUSTOM) {
/* Prevent overhanging edges: use M_POLY if the extra point is planar with the profile. */
- bndv = efirst->leftv;
+ BoundVert *bndv = efirst->leftv;
float profile_plane[4];
plane_from_point_normal_v3(profile_plane, bndv->profile.plane_co, bndv->profile.plane_no);
bndv = efirst->rightv->next; /* The added boundvert placed along the non-adjacent edge. */
@@ -2699,13 +2670,10 @@ static void build_boundary_terminal_edge(BevelParams *bp,
/* Helper for build_boundary to handle special miters. */
static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
{
- float co1[3], co2[3], co3[3], edge_dir[3], line_p[3];
- BoundVert *v1, *v2, *v3, *v1prev, *v3next;
- BMVert *vother;
- EdgeHalf *emiter_other;
int miter_outer = bp->miter_outer;
- v1 = emiter->rightv;
+ BoundVert *v1 = emiter->rightv;
+ BoundVert *v2, *v3;
if (miter_outer == BEVEL_MITER_PATCH) {
v2 = v1->next;
v3 = v2->next;
@@ -2715,8 +2683,9 @@ static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
v2 = NULL;
v3 = v1->next;
}
- v1prev = v1->prev;
- v3next = v3->next;
+ BoundVert *v1prev = v1->prev;
+ BoundVert *v3next = v3->next;
+ float co2[3];
copy_v3_v3(co2, v1->nv.co);
if (v1->is_arc_start) {
copy_v3_v3(v1->profile.middle, co2);
@@ -2724,7 +2693,8 @@ static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
/* co1 is intersection of line through co2 in dir of emiter->e
* and plane with normal the dir of emiter->e and through v1prev. */
- vother = BM_edge_other_vert(emiter->e, bv->v);
+ float co1[3], edge_dir[3], line_p[3];
+ BMVert *vother = BM_edge_other_vert(emiter->e, bv->v);
sub_v3_v3v3(edge_dir, bv->v->co, vother->co);
normalize_v3(edge_dir);
float d = bp->offset / (bp->seg / 2.0f); /* A fallback amount to move. */
@@ -2735,7 +2705,8 @@ static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
adjust_bound_vert(v1, co1);
/* co3 is similar, but plane is through v3next and line is other side of miter edge. */
- emiter_other = v3->elast;
+ float co3[3];
+ EdgeHalf *emiter_other = v3->elast;
vother = BM_edge_other_vert(emiter_other->e, bv->v);
sub_v3_v3v3(edge_dir, bv->v->co, vother->co);
normalize_v3(edge_dir);
@@ -2748,19 +2719,16 @@ static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
static void adjust_miter_inner_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
{
- BoundVert *v, *vstart, *v3;
- EdgeHalf *e;
- BMVert *vother;
- float edge_dir[3], co[3];
-
- v = vstart = bv->vmesh->boundstart;
+ BoundVert *vstart = bv->vmesh->boundstart;
+ BoundVert *v = vstart;
do {
if (v->is_arc_start) {
- v3 = v->next;
- e = v->efirst;
+ BoundVert *v3 = v->next;
+ EdgeHalf *e = v->efirst;
if (e != emiter) {
+ float edge_dir[3], co[3];
copy_v3_v3(co, v->nv.co);
- vother = BM_edge_other_vert(e->e, bv->v);
+ BMVert *vother = BM_edge_other_vert(e->e, bv->v);
sub_v3_v3v3(edge_dir, vother->co, bv->v->co);
normalize_v3(edge_dir);
madd_v3_v3v3fl(v->nv.co, co, edge_dir, bp->spread);
@@ -2795,12 +2763,6 @@ static void adjust_miter_inner_coords(BevelParams *bp, BevVert *bv, EdgeHalf *em
static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
{
MemArena *mem_arena = bp->mem_arena;
- EdgeHalf *efirst, *e, *e2, *e3, *enip, *eip, *eon, *emiter;
- BoundVert *v, *v1, *v2, *v3;
- VMesh *vm;
- float co[3], r;
- int in_plane, not_in_plane, miter_outer, miter_inner;
- int ang_kind;
/* Current bevel does nothing if only one edge into a vertex. */
if (bv->edgecount <= 1) {
@@ -2812,11 +2774,11 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
return;
}
- vm = bv->vmesh;
+ VMesh *vm = bv->vmesh;
/* Find a beveled edge to be efirst. */
- e = efirst = next_bev(bv, NULL);
- BLI_assert(e->is_bev);
+ EdgeHalf *efirst = next_bev(bv, NULL);
+ BLI_assert(efirst->is_bev);
if (bv->selcount == 1) {
/* Special case: only one beveled edge in. */
@@ -2825,26 +2787,29 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
}
/* Special miters outside only for 3 or more beveled edges. */
- miter_outer = (bv->selcount >= 3) ? bp->miter_outer : BEVEL_MITER_SHARP;
- miter_inner = bp->miter_inner;
+ int miter_outer = (bv->selcount >= 3) ? bp->miter_outer : BEVEL_MITER_SHARP;
+ int miter_inner = bp->miter_inner;
/* Keep track of the first beveled edge of an outside miter (there can be at most 1 per bv). */
- emiter = NULL;
+ EdgeHalf *emiter = NULL;
/* There is more than one beveled edge.
* We make BoundVerts to connect the sides of the beveled edges.
* Non-beveled edges in between will just join to the appropriate juncture point. */
- e = efirst;
+ EdgeHalf *e = efirst;
do {
BLI_assert(e->is_bev);
- eon = NULL;
+ EdgeHalf *eon = NULL;
/* Make the BoundVert for the right side of e; the other side will be made when the beveled
* edge to the left of e is handled.
* Analyze edges until next beveled edge: They are either "in plane" (preceding and subsequent
* faces are coplanar) or not. The "non-in-plane" edges affect the silhouette and we prefer to
* slide along one of those if possible. */
- in_plane = not_in_plane = 0; /* Counts of in-plane / not-in-plane. */
- enip = eip = NULL; /* Representatives of each type. */
+ int in_plane = 0; /* Counts of in-plane / not-in-plane. */
+ int not_in_plane = 0;
+ EdgeHalf *enip = NULL; /* Representatives of each type. */
+ EdgeHalf *eip = NULL;
+ EdgeHalf *e2;
for (e2 = e->next; !e2->is_bev; e2 = e2->next) {
if (eh_on_plane(e2)) {
in_plane++;
@@ -2856,6 +2821,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
}
}
+ float r, co[3];
if (in_plane == 0 && not_in_plane == 0) {
offset_meet(e, e2, bv->v, e->fnext, false, co, NULL);
}
@@ -2882,7 +2848,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
}
if (construct) {
- v = add_new_bound_vert(mem_arena, vm, co);
+ BoundVert *v = add_new_bound_vert(mem_arena, vm, co);
v->efirst = e;
v->elast = e2;
v->ebev = e2;
@@ -2892,10 +2858,10 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
}
e->rightv = v;
e2->leftv = v;
- for (e3 = e->next; e3 != e2; e3 = e3->next) {
+ for (EdgeHalf *e3 = e->next; e3 != e2; e3 = e3->next) {
e3->leftv = e3->rightv = v;
}
- ang_kind = edges_angle_kind(e, e2, bv->v);
+ int 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,
@@ -2907,15 +2873,16 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
emiter = e;
}
/* Make one or two more boundverts; for now all will have same co. */
- v1 = v;
+ BoundVert *v1 = v;
v1->ebev = NULL;
+ BoundVert *v2;
if (ang_kind == ANGLE_LARGER && miter_outer == BEVEL_MITER_PATCH) {
v2 = add_new_bound_vert(mem_arena, vm, co);
}
else {
v2 = NULL;
}
- v3 = add_new_bound_vert(mem_arena, vm, co);
+ BoundVert *v3 = add_new_bound_vert(mem_arena, vm, co);
v3->ebev = e2;
v3->efirst = e2;
v3->elast = e2;
@@ -2935,7 +2902,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
}
else {
v2->efirst = e->next;
- for (e3 = e->next; e3 != e2; e3 = e3->next) {
+ for (EdgeHalf *e3 = e->next; e3 != e2; e3 = e3->next) {
e3->leftv = e3->rightv = v2;
v2->elast = e3;
}
@@ -2954,7 +2921,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
int i = 0;
/* Put first half of in-between edges at index 0, second half at index bp->seg.
* If between is odd, put middle one at mid-index. */
- for (e3 = e->next; e3 != e2; e3 = e3->next) {
+ for (EdgeHalf *e3 = e->next; e3 != e2; e3 = e3->next) {
v1->elast = e3;
if (i < bet2) {
e3->profile_index = 0;
@@ -2972,13 +2939,15 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
}
}
else { /* construct == false. */
- ang_kind = edges_angle_kind(e, e2, bv->v);
+ int 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) {
emiter = e;
}
- v1 = e->rightv;
+ BoundVert *v1 = e->rightv;
+ BoundVert *v2;
+ BoundVert *v3;
if (ang_kind == ANGLE_LARGER && miter_outer == BEVEL_MITER_PATCH) {
v2 = v1->next;
v3 = v2->next;
@@ -3032,28 +3001,21 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
#ifdef DEBUG_ADJUST
static void print_adjust_stats(BoundVert *vstart)
{
- BoundVert *v;
- EdgeHalf *eleft, *eright;
- double even_residual2, spec_residual2;
- double max_even_r, max_even_r_pct;
- double max_spec_r, max_spec_r_pct;
- double delta, delta_pct;
-
printf("\nSolution analysis\n");
- even_residual2 = 0.0;
- spec_residual2 = 0.0;
- max_even_r = 0.0;
- max_even_r_pct = 0.0;
- max_spec_r = 0.0;
- max_spec_r_pct = 0.0;
+ double even_residual2 = 0.0;
+ double spec_residual2 = 0.0;
+ double max_even_r = 0.0;
+ double max_even_r_pct = 0.0;
+ double max_spec_r = 0.0;
+ double max_spec_r_pct = 0.0;
printf("width matching\n");
- v = vstart;
+ BoundVert *v = vstart;
do {
if (v->adjchain != NULL) {
- eright = v->efirst;
- eleft = v->adjchain->elast;
- delta = fabs(eright->offset_r - eleft->offset_l);
- delta_pct = 100.0 * delta / eright->offset_r_spec;
+ EdgeHalf *eright = v->efirst;
+ EdgeHalf *eleft = v->adjchain->elast;
+ double delta = fabs(eright->offset_r - eleft->offset_l);
+ double delta_pct = 100.0 * delta / eright->offset_r_spec;
printf("e%d r(%f) vs l(%f): abs(delta)=%f, delta_pct=%f\n",
BM_elem_index_get(eright->e),
eright->offset_r,
@@ -3075,10 +3037,10 @@ static void print_adjust_stats(BoundVert *vstart)
v = vstart;
do {
if (v->adjchain != NULL) {
- eright = v->efirst;
- eleft = v->adjchain->elast;
- delta = eright->offset_r - eright->offset_r_spec;
- delta_pct = 100.0 * delta / eright->offset_r_spec;
+ EdgeHalf *eright = v->efirst;
+ EdgeHalf *eleft = v->adjchain->elast;
+ double delta = eright->offset_r - eright->offset_r_spec;
+ double delta_pct = 100.0 * delta / eright->offset_r_spec;
printf("e%d r(%f) vs r spec(%f): delta=%f, delta_pct=%f\n",
BM_elem_index_get(eright->e),
eright->offset_r,
@@ -3134,19 +3096,12 @@ static void print_adjust_stats(BoundVert *vstart)
* But keep it here for a while in case performance issues demand that it be used sometimes. */
static bool adjust_the_cycle_or_chain_fast(BoundVert *vstart, int np, bool iscycle)
{
- BoundVert *v;
- EdgeHalf *eleft, *eright;
- float *g;
- float *g_prod;
- float gprod, gprod_sum, spec_sum, p;
- int i;
+ float *g = MEM_mallocN(np * sizeof(float), "beveladjust");
+ float *g_prod = MEM_mallocN(np * sizeof(float), "beveladjust");
- g = MEM_mallocN(np * sizeof(float), "beveladjust");
- g_prod = MEM_mallocN(np * sizeof(float), "beveladjust");
-
- v = vstart;
- spec_sum = 0.0f;
- i = 0;
+ BoundVert *v = vstart;
+ float spec_sum = 0.0f;
+ int i = 0;
do {
g[i] = v->sinratio;
if (iscycle || v->adjchain != NULL) {
@@ -3159,8 +3114,8 @@ static bool adjust_the_cycle_or_chain_fast(BoundVert *vstart, int np, bool iscyc
v = v->adjchain;
} while (v && v != vstart);
- gprod = 1.00f;
- gprod_sum = 1.0f;
+ float gprod = 1.00f;
+ float gprod_sum = 1.0f;
for (i = np - 1; i > 0; i--) {
gprod *= g[i];
g_prod[i] = gprod;
@@ -3181,15 +3136,15 @@ static bool adjust_the_cycle_or_chain_fast(BoundVert *vstart, int np, bool iscyc
MEM_freeN(g_prod);
return false;
}
- p = spec_sum / gprod_sum;
+ float p = spec_sum / gprod_sum;
/* Apply the new offsets. */
v = vstart;
i = 0;
do {
if (iscycle || v->adjchain != NULL) {
- eright = v->efirst;
- eleft = v->elast;
+ EdgeHalf *eright = v->efirst;
+ EdgeHalf *eleft = v->elast;
eright->offset_r = g_prod[(i + 1) % np] * p;
if (iscycle || v != vstart) {
eleft->offset_l = v->sinratio * eright->offset_r;
@@ -3197,7 +3152,7 @@ static bool adjust_the_cycle_or_chain_fast(BoundVert *vstart, int np, bool iscyc
}
else {
/* Not a cycle, and last of chain. */
- eleft = v->elast;
+ EdgeHalf *eleft = v->elast;
eleft->offset_l = p;
}
i++;
@@ -3227,80 +3182,77 @@ static EdgeHalf *next_edgehalf_bev(BevelParams *bp,
bool toward_bv,
BevVert **r_bv)
{
- EdgeHalf *new_edge;
- EdgeHalf *next_edge = NULL;
- float dir_start_edge[3], dir_new_edge[3];
- float second_best_dot = 0.0f, best_dot = 0.0f;
- float new_dot;
+ /* Case 1: The next EdgeHalf is the other side of the BMEdge.
+ * It's part of the same BMEdge, so we know the other EdgeHalf is also beveled. */
+ if (!toward_bv) {
+ return find_other_end_edge_half(bp, start_edge, r_bv);
+ }
- /* Case 1: The next EdgeHalf is across a BevVert from the current EdgeHalf. */
- if (toward_bv) {
- /* Skip all the logic if there's only one beveled edge at the vertex, we're at an end. */
- if ((*r_bv)->selcount == 1) {
- return NULL; /* No other edges to go to. */
- }
+ /* Case 2: The next EdgeHalf is across a BevVert from the current EdgeHalf. */
+ /* Skip all the logic if there's only one beveled edge at the vertex, we're at an end. */
+ if ((*r_bv)->selcount == 1) {
+ return NULL; /* No other edges to go to. */
+ }
- /* The case with only one other edge connected to the vertex is special too. */
- if ((*r_bv)->selcount == 2) {
- /* Just find the next beveled edge, that's the only other option. */
- new_edge = start_edge;
- do {
- new_edge = new_edge->next;
- } while (!new_edge->is_bev);
+ /* The case with only one other edge connected to the vertex is special too. */
+ if ((*r_bv)->selcount == 2) {
+ /* Just find the next beveled edge, that's the only other option. */
+ EdgeHalf *new_edge = start_edge;
+ do {
+ new_edge = new_edge->next;
+ } while (!new_edge->is_bev);
- return new_edge;
- }
+ return new_edge;
+ }
+
+ /* Find the direction vector of the current edge (pointing INTO the BevVert).
+ * v1 and v2 don't necessarily have an order, so we need to check which is closer to bv. */
+ float dir_start_edge[3];
+ if (start_edge->e->v1 == (*r_bv)->v) {
+ sub_v3_v3v3(dir_start_edge, start_edge->e->v1->co, start_edge->e->v2->co);
+ }
+ else {
+ sub_v3_v3v3(dir_start_edge, start_edge->e->v2->co, start_edge->e->v1->co);
+ }
+ normalize_v3(dir_start_edge);
- /* Find the direction vector of the current edge (pointing INTO the BevVert).
- * v1 and v2 don't necessarily have an order, so we need to check which is closer to bv. */
- if (start_edge->e->v1 == (*r_bv)->v) {
- sub_v3_v3v3(dir_start_edge, start_edge->e->v1->co, start_edge->e->v2->co);
+ /* Find the beveled edge coming out of the BevVert that's most parallel to the current edge. */
+ EdgeHalf *new_edge = start_edge->next;
+ float second_best_dot = 0.0f, best_dot = 0.0f;
+ EdgeHalf *next_edge = NULL;
+ while (new_edge != start_edge) {
+ if (!new_edge->is_bev) {
+ new_edge = new_edge->next;
+ continue;
+ }
+ /* Find direction vector of the possible next edge (pointing OUT of the BevVert). */
+ float dir_new_edge[3];
+ if (new_edge->e->v2 == (*r_bv)->v) {
+ sub_v3_v3v3(dir_new_edge, new_edge->e->v1->co, new_edge->e->v2->co);
}
else {
- sub_v3_v3v3(dir_start_edge, start_edge->e->v2->co, start_edge->e->v1->co);
+ sub_v3_v3v3(dir_new_edge, new_edge->e->v2->co, new_edge->e->v1->co);
}
- normalize_v3(dir_start_edge);
-
- /* Find the beveled edge coming out of the BevVert that's most parallel to the current edge. */
- new_edge = start_edge->next;
- while (new_edge != start_edge) {
- if (!new_edge->is_bev) {
- new_edge = new_edge->next;
- continue;
- }
- /* Find direction vector of the possible next edge (pointing OUT of the BevVert). */
- if (new_edge->e->v2 == (*r_bv)->v) {
- sub_v3_v3v3(dir_new_edge, new_edge->e->v1->co, new_edge->e->v2->co);
- }
- else {
- sub_v3_v3v3(dir_new_edge, new_edge->e->v2->co, new_edge->e->v1->co);
- }
- normalize_v3(dir_new_edge);
+ normalize_v3(dir_new_edge);
- /* Use this edge if it is the most parallel to the orignial so far. */
- new_dot = dot_v3v3(dir_new_edge, dir_start_edge);
- if (new_dot > best_dot) {
- second_best_dot = best_dot; /* For remembering if the choice was too close. */
- best_dot = new_dot;
- next_edge = new_edge;
- }
- else if (new_dot > second_best_dot) {
- second_best_dot = new_dot;
- }
-
- new_edge = new_edge->next;
+ /* Use this edge if it is the most parallel to the orignial so far. */
+ float new_dot = dot_v3v3(dir_new_edge, dir_start_edge);
+ if (new_dot > best_dot) {
+ second_best_dot = best_dot; /* For remembering if the choice was too close. */
+ best_dot = new_dot;
+ next_edge = new_edge;
}
-
- /* Only return a new Edge if one was found and if the choice of next edge was not too close. */
- if ((next_edge != NULL) && compare_ff(best_dot, second_best_dot, BEVEL_SMALL_ANG_DOT)) {
- return NULL;
+ else if (new_dot > second_best_dot) {
+ second_best_dot = new_dot;
}
- return next_edge;
+
+ new_edge = new_edge->next;
}
- /* Case 2: The next EdgeHalf is the other side of the BMEdge.
- * It's part of the same BMEdge, so we know the other EdgeHalf is also beveled. */
- next_edge = find_other_end_edge_half(bp, start_edge, r_bv);
+ /* Only return a new Edge if one was found and if the choice of next edge was not too close. */
+ if ((next_edge != NULL) && compare_ff(best_dot, second_best_dot, BEVEL_SMALL_ANG_DOT)) {
+ return NULL;
+ }
return next_edge;
}
@@ -3325,13 +3277,10 @@ static void regularize_profile_orientation(BevelParams *bp, BMEdge *bme)
start_edgehalf->visited_rpo = true;
/* First loop starts in the away from BevVert direction and the second starts toward it. */
- bool toward_bv;
- BevVert *bv;
- EdgeHalf *edgehalf;
for (int i = 0; i < 2; i++) {
- edgehalf = start_edgehalf;
- bv = start_bv;
- toward_bv = (i == 0);
+ EdgeHalf *edgehalf = start_edgehalf;
+ BevVert *bv = start_bv;
+ bool toward_bv = (i == 0);
edgehalf = next_edgehalf_bev(bp, edgehalf, toward_bv, &bv);
/* Keep traveling until there is no unvisited beveled edgehalf to visit next. */
@@ -3366,17 +3315,11 @@ static void regularize_profile_orientation(BevelParams *bp, BMEdge *bme)
*/
static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
{
- BoundVert *v;
- EdgeHalf *eleft, *eright, *enextleft;
- LinearSolver *solver;
- double weight, val;
- int i, np, nrows, row;
-
- np = 0;
+ int np = 0;
#ifdef DEBUG_ADJUST
printf("\nadjust the %s (with eigen)\n", iscycle ? "cycle" : "chain");
#endif
- v = vstart;
+ BoundVert *v = vstart;
do {
#ifdef DEBUG_ADJUST
eleft = v->elast;
@@ -3396,13 +3339,15 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
}
#endif
- nrows = iscycle ? 3 * np : 3 * np - 3;
+ int nrows = iscycle ? 3 * np : 3 * np - 3;
- solver = EIG_linear_least_squares_solver_new(nrows, np, 1);
+ LinearSolver *solver = EIG_linear_least_squares_solver_new(nrows, np, 1);
v = vstart;
- i = 0;
- weight = BEVEL_MATCH_SPEC_WEIGHT; /* Sqrt of factor to weight down importance of spec match. */
+ int i = 0;
+ /* Sqrt of factor to weight down importance of spec match. */
+ double weight = BEVEL_MATCH_SPEC_WEIGHT;
+ EdgeHalf *eleft, *eright, *enextleft;
do {
/* Except at end of chain, v's indep variable is offset_r of v->efirst. */
if (iscycle || i < np - 1) {
@@ -3433,7 +3378,7 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
/* Residue np + 2*i (if cycle) else np - 1 + 2*i:
* right offset for parm i matches its spec; weighted. */
- row = iscycle ? np + 2 * i : np - 1 + 2 * i;
+ int row = iscycle ? np + 2 * i : np - 1 + 2 * i;
EIG_linear_solver_matrix_add(solver, row, i, weight);
EIG_linear_solver_right_hand_side_add(solver, 0, row, weight * eright->offset_r);
#ifdef DEBUG_ADJUST
@@ -3484,7 +3429,7 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
v = vstart;
i = 0;
do {
- val = EIG_linear_solver_variable_get(solver, 0, i);
+ double val = EIG_linear_solver_variable_get(solver, 0, i);
if (iscycle || i < np - 1) {
eright = v->efirst;
eleft = v->elast;
@@ -3532,25 +3477,20 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
*/
static void adjust_offsets(BevelParams *bp, BMesh *bm)
{
- BMVert *bmv;
- BevVert *bv, *bvcur;
- BoundVert *v, *vanchor, *vchainstart, *vchainend, *vnext;
- EdgeHalf *enext;
- BMIter iter;
- bool iscycle;
- int chainlen;
-
/* Find and process chains and cycles of unvisited BoundVerts that have eon set. */
/* Note: for repeatability, iterate over all verts of mesh rather than over ghash'ed BMVerts. */
+ BMIter iter;
+ BMVert *bmv;
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
continue;
}
- bv = bvcur = find_bevvert(bp, bmv);
+ BevVert *bv = find_bevvert(bp, bmv);
+ BevVert *bvcur = bv;
if (!bv) {
continue;
}
- vanchor = bv->vmesh->boundstart;
+ BoundVert *vanchor = bv->vmesh->boundstart;
do {
if (vanchor->visited || !vanchor->eon) {
continue;
@@ -3567,20 +3507,22 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm)
* pairs with the right side of the next edge in the cycle or chain. */
/* First follow paired edges in left->right direction. */
+ BoundVert *v, *vchainstart, *vchainend;
v = vchainstart = vchainend = vanchor;
- iscycle = false;
- chainlen = 1;
+
+ bool iscycle = false;
+ int chainlen = 1;
while (v->eon && !v->visited && !iscycle) {
v->visited = true;
if (!v->efirst) {
break;
}
- enext = find_other_end_edge_half(bp, v->efirst, &bvcur);
+ EdgeHalf *enext = find_other_end_edge_half(bp, v->efirst, &bvcur);
if (!enext) {
break;
}
BLI_assert(enext != NULL);
- vnext = enext->leftv;
+ BoundVert *vnext = enext->leftv;
v->adjchain = vnext;
vchainend = vnext;
chainlen++;
@@ -3603,11 +3545,11 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm)
if (!v->elast) {
break;
}
- enext = find_other_end_edge_half(bp, v->elast, &bvcur);
+ EdgeHalf *enext = find_other_end_edge_half(bp, v->elast, &bvcur);
if (!enext) {
break;
}
- vnext = enext->rightv;
+ BoundVert *vnext = enext->rightv;
vnext->adjchain = v;
chainlen++;
vchainstart = vnext;
@@ -3623,7 +3565,7 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm)
/* Rebuild boundaries with new width specs. */
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
- bv = find_bevvert(bp, bmv);
+ BevVert *bv = find_bevvert(bp, bmv);
if (bv) {
build_boundary(bp, bv, false);
}
@@ -3642,22 +3584,18 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm)
*/
static BoundVert *pipe_test(BevVert *bv)
{
- EdgeHalf *e, *epipe;
- VMesh *vm;
- BoundVert *v1, *v2, *v3;
- float dir1[3], dir3[3];
-
- vm = bv->vmesh;
+ VMesh *vm = bv->vmesh;
if (vm->count < 3 || vm->count > 4 || bv->selcount < 3 || bv->selcount > 4) {
return NULL;
}
/* Find v1, v2, v3 all with beveled edges, where v1 and v3 have collinear edges. */
- epipe = NULL;
- v1 = vm->boundstart;
+ EdgeHalf *epipe = NULL;
+ BoundVert *v1 = vm->boundstart;
+ float dir1[3], dir3[3];
do {
- v2 = v1->next;
- v3 = v2->next;
+ BoundVert *v2 = v1->next;
+ BoundVert *v3 = v2->next;
if (v1->ebev && v2->ebev && v3->ebev) {
sub_v3_v3v3(dir1, bv->v->co, BM_edge_other_vert(v1->ebev->e, bv->v)->co);
sub_v3_v3v3(dir3, BM_edge_other_vert(v3->ebev->e, bv->v)->co, bv->v->co);
@@ -3675,7 +3613,7 @@ static BoundVert *pipe_test(BevVert *bv)
}
/* Check face planes: all should have normals perpendicular to epipe. */
- for (e = &bv->edges[0]; e != &bv->edges[bv->edgecount]; e++) {
+ for (EdgeHalf *e = &bv->edges[0]; e != &bv->edges[bv->edgecount]; e++) {
if (e->fnext) {
if (fabsf(dot_v3v3(dir1, e->fnext->no)) > BEVEL_EPSILON_BIG) {
return NULL;
@@ -3687,14 +3625,12 @@ static BoundVert *pipe_test(BevVert *bv)
static VMesh *new_adj_vmesh(MemArena *mem_arena, int count, int seg, BoundVert *bounds)
{
- VMesh *vm;
-
- vm = (VMesh *)BLI_memarena_alloc(mem_arena, sizeof(VMesh));
+ VMesh *vm = (VMesh *)BLI_memarena_alloc(mem_arena, sizeof(VMesh));
vm->count = count;
vm->seg = seg;
vm->boundstart = bounds;
- vm->mesh = (NewVert *)BLI_memarena_alloc(
- mem_arena, (size_t)(count * (1 + seg / 2) * (1 + seg)) * sizeof(NewVert));
+ vm->mesh = (NewVert *)BLI_memarena_alloc(mem_arena,
+ sizeof(NewVert) * count * (1 + seg / 2) * (1 + seg));
vm->mesh_kind = M_ADJ;
return vm;
}
@@ -3711,28 +3647,22 @@ static VMesh *new_adj_vmesh(MemArena *mem_arena, int count, int seg, BoundVert *
*/
static NewVert *mesh_vert_canon(VMesh *vm, int i, int j, int k)
{
- int n, ns, ns2, odd;
- NewVert *ans;
-
- n = vm->count;
- ns = vm->seg;
- ns2 = ns / 2;
- odd = ns % 2;
+ int n = vm->count;
+ int ns = vm->seg;
+ int ns2 = ns / 2;
+ int odd = ns % 2;
BLI_assert(0 <= i && i <= n && 0 <= j && j <= ns && 0 <= k && k <= ns);
if (!odd && j == ns2 && k == ns2) {
- ans = mesh_vert(vm, 0, j, k);
+ return mesh_vert(vm, 0, j, k);
}
- else if (j <= ns2 - 1 + odd && k <= ns2) {
- ans = mesh_vert(vm, i, j, k);
+ if (j <= ns2 - 1 + odd && k <= ns2) {
+ return mesh_vert(vm, i, j, k);
}
- else if (k <= ns2) {
- ans = mesh_vert(vm, (i + n - 1) % n, k, ns - j);
- }
- else {
- ans = mesh_vert(vm, (i + 1) % n, ns - k, j);
+ if (k <= ns2) {
+ return mesh_vert(vm, (i + n - 1) % n, k, ns - j);
}
- return ans;
+ return mesh_vert(vm, (i + 1) % n, ns - k, j);
}
static bool is_canon(VMesh *vm, int i, int j, int k)
@@ -3748,20 +3678,17 @@ static bool is_canon(VMesh *vm, int i, int j, int k)
/* Copy the vertex data to all of vm verts from canonical ones. */
static void vmesh_copy_equiv_verts(VMesh *vm)
{
- int n, ns, ns2, i, j, k;
- NewVert *v0, *v1;
-
- n = vm->count;
- ns = vm->seg;
- ns2 = ns / 2;
- for (i = 0; i < n; i++) {
- for (j = 0; j <= ns2; j++) {
- for (k = 0; k <= ns; k++) {
+ int n = vm->count;
+ int ns = vm->seg;
+ int ns2 = ns / 2;
+ for (int i = 0; i < n; i++) {
+ for (int j = 0; j <= ns2; j++) {
+ for (int k = 0; k <= ns; k++) {
if (is_canon(vm, i, j, k)) {
continue;
}
- v1 = mesh_vert(vm, i, j, k);
- v0 = mesh_vert_canon(vm, i, j, k);
+ NewVert *v1 = mesh_vert(vm, i, j, k);
+ NewVert *v0 = mesh_vert_canon(vm, i, j, k);
copy_v3_v3(v1->co, v0->co);
v1->v = v0->v;
}
@@ -3772,13 +3699,11 @@ static void vmesh_copy_equiv_verts(VMesh *vm)
/* Calculate and return in r_cent the centroid of the center poly. */
static void vmesh_center(VMesh *vm, float r_cent[3])
{
- int n, ns2, i;
-
- n = vm->count;
- ns2 = vm->seg / 2;
+ int n = vm->count;
+ int ns2 = vm->seg / 2;
if (vm->seg % 2) {
zero_v3(r_cent);
- for (i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++) {
add_v3_v3(r_cent, mesh_vert(vm, i, ns2, ns2)->co);
}
mul_v3_fl(r_cent, 1.0f / (float)n);
@@ -3800,53 +3725,47 @@ static void avg4(
/* Gamma needed for smooth Catmull-Clark, Sabin modification. */
static float sabin_gamma(int n)
{
- double ans, k, k2, k4, k6, x, y;
-
/* pPrecalculated for common cases of n. */
if (n < 3) {
return 0.0f;
}
if (n == 3) {
- ans = 0.065247584f;
- }
- else if (n == 4) {
- ans = 0.25f;
- }
- else if (n == 5) {
- ans = 0.401983447f;
- }
- else if (n == 6) {
- ans = 0.523423277f;
- }
- else {
- k = cos(M_PI / (double)n);
- /* Need x, real root of x^3 + (4k^2 - 3)x - 2k = 0.
- * Answer calculated via Wolfram Alpha. */
- k2 = k * k;
- k4 = k2 * k2;
- k6 = k4 * k2;
- y = pow(M_SQRT3 * sqrt(64.0 * k6 - 144.0 * k4 + 135.0 * k2 - 27.0) + 9.0 * k, 1.0 / 3.0);
- x = 0.480749856769136 * y - (0.231120424783545 * (12.0 * k2 - 9.0)) / y;
- ans = (k * x + 2.0 * k2 - 1.0) / (x * x * (k * x + 1.0));
- }
- return (float)ans;
+ return 0.065247584f;
+ }
+ if (n == 4) {
+ return 0.25f;
+ }
+ if (n == 5) {
+ return 0.401983447f;
+ }
+ if (n == 6) {
+ return 0.523423277f;
+ }
+ double k = cos(M_PI / (double)n);
+ /* Need x, real root of x^3 + (4k^2 - 3)x - 2k = 0.
+ * Answer calculated via Wolfram Alpha. */
+ double k2 = k * k;
+ double k4 = k2 * k2;
+ double k6 = k4 * k2;
+ double y = pow(M_SQRT3 * sqrt(64.0 * k6 - 144.0 * k4 + 135.0 * k2 - 27.0) + 9.0 * k, 1.0 / 3.0);
+ double x = 0.480749856769136 * y - (0.231120424783545 * (12.0 * k2 - 9.0)) / y;
+ return (k * x + 2.0 * k2 - 1.0) / (x * x * (k * x + 1.0));
}
/* Fill frac with fractions of the way along ring 0 for vertex i, for use with interp_range
* function. */
static void fill_vmesh_fracs(VMesh *vm, float *frac, int i)
{
- int k, ns;
float total = 0.0f;
- ns = vm->seg;
+ int ns = vm->seg;
frac[0] = 0.0f;
- for (k = 0; k < ns; k++) {
+ for (int k = 0; k < ns; k++) {
total += len_v3v3(mesh_vert(vm, i, 0, k)->co, mesh_vert(vm, i, 0, k + 1)->co);
frac[k + 1] = total;
}
if (total > 0.0f) {
- for (k = 1; k <= ns; k++) {
+ for (int k = 1; k <= ns; k++) {
frac[k] /= total;
}
}
@@ -3858,20 +3777,19 @@ static void fill_vmesh_fracs(VMesh *vm, float *frac, int i)
/* Like fill_vmesh_fracs but want fractions for profile points of bndv, with ns segments. */
static void fill_profile_fracs(BevelParams *bp, BoundVert *bndv, float *frac, int ns)
{
- int k;
float co[3], nextco[3];
float total = 0.0f;
frac[0] = 0.0f;
copy_v3_v3(co, bndv->nv.co);
- for (k = 0; k < ns; k++) {
+ for (int k = 0; k < ns; k++) {
get_profile_point(bp, &bndv->profile, k + 1, ns, nextco);
total += len_v3v3(co, nextco);
frac[k + 1] = total;
copy_v3_v3(co, nextco);
}
if (total > 0.0f) {
- for (k = 1; k <= ns; k++) {
+ for (int k = 1; k <= ns; k++) {
frac[k] /= total;
}
}
@@ -3884,13 +3802,10 @@ static void fill_profile_fracs(BevelParams *bp, BoundVert *bndv, float *frac, in
* and put fraction of rest of way between frac[i] and frac[i + 1] into r_rest. */
static int interp_range(const float *frac, int n, const float f, float *r_rest)
{
- int i;
- float rest;
-
/* Could binary search in frac, but expect n to be reasonably small. */
- for (i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++) {
if (f <= frac[i + 1]) {
- rest = f - frac[i];
+ float rest = f - frac[i];
if (rest == 0) {
*r_rest = 0.0f;
}
@@ -3914,39 +3829,34 @@ static int interp_range(const float *frac, int n, const float f, float *r_rest)
* neighbors. */
static VMesh *interp_vmesh(BevelParams *bp, VMesh *vm_in, int nseg)
{
- int n_bndv, ns_in, nseg2, odd, i, j, k, j_in, k_in, k_in_prev, j0inc, k0inc;
- float *prev_frac, *frac, *new_frac, *prev_new_frac;
- float fraction, restj, restk, restkprev;
- float quad[4][3], co[3], center[3];
- VMesh *vm_out;
- BoundVert *bndv;
-
- n_bndv = vm_in->count;
- ns_in = vm_in->seg;
- nseg2 = nseg / 2;
- odd = nseg % 2;
- vm_out = new_adj_vmesh(bp->mem_arena, n_bndv, nseg, vm_in->boundstart);
-
- prev_frac = BLI_array_alloca(prev_frac, (ns_in + 1));
- frac = BLI_array_alloca(frac, (ns_in + 1));
- new_frac = BLI_array_alloca(new_frac, (nseg + 1));
- prev_new_frac = BLI_array_alloca(prev_new_frac, (nseg + 1));
+ int n_bndv = vm_in->count;
+ int ns_in = vm_in->seg;
+ int nseg2 = nseg / 2;
+ int odd = nseg % 2;
+ VMesh *vm_out = new_adj_vmesh(bp->mem_arena, n_bndv, nseg, vm_in->boundstart);
+
+ float *prev_frac = BLI_array_alloca(prev_frac, (ns_in + 1));
+ float *frac = BLI_array_alloca(frac, (ns_in + 1));
+ float *new_frac = BLI_array_alloca(new_frac, (nseg + 1));
+ float *prev_new_frac = BLI_array_alloca(prev_new_frac, (nseg + 1));
fill_vmesh_fracs(vm_in, prev_frac, n_bndv - 1);
- bndv = vm_in->boundstart;
+ BoundVert *bndv = vm_in->boundstart;
fill_profile_fracs(bp, bndv->prev, prev_new_frac, nseg);
- for (i = 0; i < n_bndv; i++) {
+ for (int i = 0; i < n_bndv; i++) {
fill_vmesh_fracs(vm_in, frac, i);
fill_profile_fracs(bp, bndv, new_frac, nseg);
- for (j = 0; j <= nseg2 - 1 + odd; j++) {
- for (k = 0; k <= nseg2; k++) {
+ for (int j = 0; j <= nseg2 - 1 + odd; j++) {
+ for (int k = 0; k <= nseg2; k++) {
/* Finding the locations where "fraction" fits into previous and current "frac". */
- fraction = new_frac[k];
- k_in = interp_range(frac, ns_in, fraction, &restk);
+ float fraction = new_frac[k];
+ float restk;
+ float restkprev;
+ int k_in = interp_range(frac, ns_in, fraction, &restk);
fraction = prev_new_frac[nseg - j];
- k_in_prev = interp_range(prev_frac, ns_in, fraction, &restkprev);
- j_in = ns_in - k_in_prev;
- restj = -restkprev;
+ int k_in_prev = interp_range(prev_frac, ns_in, fraction, &restkprev);
+ int j_in = ns_in - k_in_prev;
+ float restj = -restkprev;
if (restj > -BEVEL_EPSILON) {
restj = 0.0f;
}
@@ -3955,12 +3865,14 @@ static VMesh *interp_vmesh(BevelParams *bp, VMesh *vm_in, int nseg)
restj = 1.0f + restj;
}
/* Use bilinear interpolation within the source quad; could be smarter here. */
+ float co[3];
if (restj < BEVEL_EPSILON && restk < BEVEL_EPSILON) {
copy_v3_v3(co, mesh_vert_canon(vm_in, i, j_in, k_in)->co);
}
else {
- j0inc = (restj < BEVEL_EPSILON || j_in == ns_in) ? 0 : 1;
- k0inc = (restk < BEVEL_EPSILON || k_in == ns_in) ? 0 : 1;
+ int j0inc = (restj < BEVEL_EPSILON || j_in == ns_in) ? 0 : 1;
+ int k0inc = (restk < BEVEL_EPSILON || k_in == ns_in) ? 0 : 1;
+ float quad[4][3];
copy_v3_v3(quad[0], mesh_vert_canon(vm_in, i, j_in, k_in)->co);
copy_v3_v3(quad[1], mesh_vert_canon(vm_in, i, j_in, k_in + k0inc)->co);
copy_v3_v3(quad[2], mesh_vert_canon(vm_in, i, j_in + j0inc, k_in + k0inc)->co);
@@ -3971,10 +3883,11 @@ static VMesh *interp_vmesh(BevelParams *bp, VMesh *vm_in, int nseg)
}
}
bndv = bndv->next;
- memcpy(prev_frac, frac, (size_t)(ns_in + 1) * sizeof(float));
- memcpy(prev_new_frac, new_frac, (size_t)(nseg + 1) * sizeof(float));
+ memcpy(prev_frac, frac, sizeof(float) * (ns_in + 1));
+ memcpy(prev_new_frac, new_frac, sizeof(float) * (nseg + 1));
}
if (!odd) {
+ float center[3];
vmesh_center(vm_in, center);
copy_v3_v3(mesh_vert(vm_out, 0, nseg2, nseg2)->co, center);
}
@@ -3988,28 +3901,24 @@ static VMesh *interp_vmesh(BevelParams *bp, VMesh *vm_in, int nseg)
* See Levin 1999 paper: "Filling an N-sided hole using combined subdivision schemes". */
static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
{
- int n_boundary, ns_in, ns_in2, ns_out;
- int i, j, k, inext;
- float co[3], co1[3], co2[3], acc[3];
- float beta, gamma;
- VMesh *vm_out;
- BoundVert *bndv;
-
- n_boundary = vm_in->count;
- ns_in = vm_in->seg;
- ns_in2 = ns_in / 2;
+ float co[3];
+
+ int n_boundary = vm_in->count;
+ int ns_in = vm_in->seg;
+ int ns_in2 = ns_in / 2;
BLI_assert(ns_in % 2 == 0);
- ns_out = 2 * ns_in;
- vm_out = new_adj_vmesh(bp->mem_arena, n_boundary, ns_out, vm_in->boundstart);
+ int ns_out = 2 * ns_in;
+ VMesh *vm_out = new_adj_vmesh(bp->mem_arena, n_boundary, ns_out, vm_in->boundstart);
/* First we adjust the boundary vertices of the input mesh, storing in output mesh. */
- for (i = 0; i < n_boundary; i++) {
+ for (int i = 0; i < n_boundary; i++) {
copy_v3_v3(mesh_vert(vm_out, i, 0, 0)->co, mesh_vert(vm_in, i, 0, 0)->co);
- for (k = 1; k < ns_in; k++) {
+ for (int k = 1; k < ns_in; k++) {
copy_v3_v3(co, mesh_vert(vm_in, i, 0, k)->co);
/* Smooth boundary rule. Custom profiles shouldn't be smoothed. */
if (bp->profile_type != BEVEL_PROFILE_CUSTOM) {
+ float co1[3], co2[3], acc[3];
copy_v3_v3(co1, mesh_vert(vm_in, i, 0, k - 1)->co);
copy_v3_v3(co2, mesh_vert(vm_in, i, 0, k + 1)->co);
@@ -4022,13 +3931,14 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
}
}
/* Now adjust odd boundary vertices in output mesh, based on even ones. */
- bndv = vm_out->boundstart;
- for (i = 0; i < n_boundary; i++) {
- for (k = 1; k < ns_out; k += 2) {
+ BoundVert *bndv = vm_out->boundstart;
+ for (int i = 0; i < n_boundary; i++) {
+ for (int k = 1; k < ns_out; k += 2) {
get_profile_point(bp, &bndv->profile, k, ns_out, co);
/* Smooth if using a non-custom profile. */
if (bp->profile_type != BEVEL_PROFILE_CUSTOM) {
+ float co1[3], co2[3], acc[3];
copy_v3_v3(co1, mesh_vert_canon(vm_out, i, 0, k - 1)->co);
copy_v3_v3(co2, mesh_vert_canon(vm_out, i, 0, k + 1)->co);
@@ -4044,8 +3954,8 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
vmesh_copy_equiv_verts(vm_out);
/* Copy adjusted verts back into vm_in. */
- for (i = 0; i < n_boundary; i++) {
- for (k = 0; k < ns_in; k++) {
+ for (int i = 0; i < n_boundary; i++) {
+ for (int k = 0; k < ns_in; k++) {
copy_v3_v3(mesh_vert(vm_in, i, 0, k)->co, mesh_vert(vm_out, i, 0, 2 * k)->co);
}
}
@@ -4056,9 +3966,9 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
* and assuming all boundary vertices have valence 4. */
/* The new face vertices. */
- for (i = 0; i < n_boundary; i++) {
- for (j = 0; j < ns_in2; j++) {
- for (k = 0; k < ns_in2; k++) {
+ for (int i = 0; i < n_boundary; i++) {
+ for (int j = 0; j < ns_in2; j++) {
+ for (int k = 0; k < ns_in2; k++) {
/* Face up and right from (j, k). */
avg4(co,
mesh_vert(vm_in, i, j, k),
@@ -4071,9 +3981,9 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
}
/* The new vertical edge vertices. */
- for (i = 0; i < n_boundary; i++) {
- for (j = 0; j < ns_in2; j++) {
- for (k = 1; k <= ns_in2; k++) {
+ for (int i = 0; i < n_boundary; i++) {
+ for (int j = 0; j < ns_in2; j++) {
+ for (int k = 1; k <= ns_in2; k++) {
/* Vertical edge between (j, k) and (j+1, k). */
avg4(co,
mesh_vert(vm_in, i, j, k),
@@ -4086,9 +3996,9 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
}
/* The new horizontal edge vertices. */
- for (i = 0; i < n_boundary; i++) {
- for (j = 1; j < ns_in2; j++) {
- for (k = 0; k < ns_in2; k++) {
+ for (int i = 0; i < n_boundary; i++) {
+ for (int j = 1; j < ns_in2; j++) {
+ for (int k = 0; k < ns_in2; k++) {
/* Horizontal edge between (j, k) and (j, k+1). */
avg4(co,
mesh_vert(vm_in, i, j, k),
@@ -4101,11 +4011,12 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
}
/* The new vertices, not on border. */
- gamma = 0.25f;
- beta = -gamma;
- for (i = 0; i < n_boundary; i++) {
- for (j = 1; j < ns_in2; j++) {
- for (k = 1; k <= ns_in2; k++) {
+ float gamma = 0.25f;
+ float beta = -gamma;
+ for (int i = 0; i < n_boundary; i++) {
+ for (int j = 1; j < ns_in2; j++) {
+ for (int k = 1; k <= ns_in2; k++) {
+ float co1[3], co2[3];
/* co1 = centroid of adjacent new edge verts. */
avg4(co1,
mesh_vert_canon(vm_out, i, 2 * j, 2 * k - 1),
@@ -4133,9 +4044,10 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
gamma = sabin_gamma(n_boundary);
beta = -gamma;
/* Accumulate edge verts in co1, face verts in co2. */
+ float co1[3], co2[3];
zero_v3(co1);
zero_v3(co2);
- for (i = 0; i < n_boundary; i++) {
+ for (int i = 0; i < n_boundary; i++) {
add_v3_v3(co1, mesh_vert(vm_out, i, ns_in, ns_in - 1)->co);
add_v3_v3(co2, mesh_vert(vm_out, i, ns_in - 1, ns_in - 1)->co);
add_v3_v3(co2, mesh_vert(vm_out, i, ns_in - 1, ns_in + 1)->co);
@@ -4144,15 +4056,15 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
mul_v3_fl(co, 1.0f / (float)n_boundary);
madd_v3_v3fl(co, co2, beta / (2.0f * (float)n_boundary));
madd_v3_v3fl(co, mesh_vert(vm_in, 0, ns_in2, ns_in2)->co, gamma);
- for (i = 0; i < n_boundary; i++) {
+ for (int i = 0; i < n_boundary; i++) {
copy_v3_v3(mesh_vert(vm_out, i, ns_in, ns_in)->co, co);
}
/* Final step: Copy the profile vertices to the VMesh's boundary. */
bndv = vm_out->boundstart;
- for (i = 0; i < n_boundary; i++) {
- inext = (i + 1) % n_boundary;
- for (k = 0; k <= ns_out; k++) {
+ for (int i = 0; i < n_boundary; i++) {
+ int inext = (i + 1) % n_boundary;
+ for (int k = 0; k <= ns_out; k++) {
get_profile_point(bp, &bndv->profile, k, ns_out, co);
copy_v3_v3(mesh_vert(vm_out, i, 0, k)->co, co);
if (k >= ns_in && k < ns_out) {
@@ -4168,24 +4080,21 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
/* Special case for cube corner, when r is PRO_SQUARE_R, meaning straight sides. */
static VMesh *make_cube_corner_square(MemArena *mem_arena, int nseg)
{
- VMesh *vm;
- float co[3];
- int i, j, k, ns2;
-
- ns2 = nseg / 2;
- vm = new_adj_vmesh(mem_arena, 3, nseg, NULL);
+ int ns2 = nseg / 2;
+ VMesh *vm = new_adj_vmesh(mem_arena, 3, nseg, NULL);
vm->count = 0; /* Reset, so the following loop will end up with correct count. */
- for (i = 0; i < 3; i++) {
- zero_v3(co);
+ for (int i = 0; i < 3; i++) {
+ float co[3] = {0.0f, 0.0f, 0.0f};
co[i] = 1.0f;
add_new_bound_vert(mem_arena, vm, co);
}
- for (i = 0; i < 3; i++) {
- for (j = 0; j <= ns2; j++) {
- for (k = 0; k <= ns2; k++) {
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j <= ns2; j++) {
+ for (int k = 0; k <= ns2; k++) {
if (!is_canon(vm, i, j, k)) {
continue;
}
+ float co[3];
co[i] = 1.0f;
co[(i + 1) % 3] = (float)k * 2.0f / (float)nseg;
co[(i + 2) % 3] = (float)j * 2.0f / (float)nseg;
@@ -4205,28 +4114,26 @@ static VMesh *make_cube_corner_square(MemArena *mem_arena, int nseg)
*/
static VMesh *make_cube_corner_square_in(MemArena *mem_arena, int nseg)
{
- VMesh *vm;
- float co[3];
- float b;
- int i, k, ns2, odd;
-
- ns2 = nseg / 2;
- odd = nseg % 2;
- vm = new_adj_vmesh(mem_arena, 3, nseg, NULL);
+ int ns2 = nseg / 2;
+ int odd = nseg % 2;
+ VMesh *vm = new_adj_vmesh(mem_arena, 3, nseg, NULL);
vm->count = 0; /* Reset, so following loop will end up with correct count. */
- for (i = 0; i < 3; i++) {
- zero_v3(co);
+ for (int i = 0; i < 3; i++) {
+ float co[3] = {0.0f, 0.0f, 0.0f};
co[i] = 1.0f;
add_new_bound_vert(mem_arena, vm, co);
}
+
+ float b;
if (odd) {
b = 2.0f / (2.0f * (float)ns2 + (float)M_SQRT2);
}
else {
b = 2.0f / (float)nseg;
}
- for (i = 0; i < 3; i++) {
- for (k = 0; k <= ns2; k++) {
+ for (int i = 0; i < 3; i++) {
+ for (int k = 0; k <= ns2; k++) {
+ float co[3];
co[i] = 1.0f - (float)k * b;
co[(i + 1) % 3] = 0.0f;
co[(i + 2) % 3] = 0.0f;
@@ -4251,10 +4158,6 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
MemArena *mem_arena = bp->mem_arena;
int nseg = bp->seg;
float r = bp->pro_super_r;
- VMesh *vm0, *vm1;
- BoundVert *bndv;
- int i, j, k, ns2;
- float co[3], coc[3];
if (bp->profile_type != BEVEL_PROFILE_CUSTOM) {
if (r == PRO_SQUARE_R) {
@@ -4266,15 +4169,16 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
}
/* Initial mesh has 3 sides and 2 segments on each side. */
- vm0 = new_adj_vmesh(mem_arena, 3, 2, NULL);
+ VMesh *vm0 = new_adj_vmesh(mem_arena, 3, 2, NULL);
vm0->count = 0; /* Reset, so the following loop will end up with correct count. */
- for (i = 0; i < 3; i++) {
- zero_v3(co);
+ for (int i = 0; i < 3; i++) {
+ float co[3] = {0.0f, 0.0f, 0.0f};
co[i] = 1.0f;
add_new_bound_vert(mem_arena, vm0, co);
}
- bndv = vm0->boundstart;
- for (i = 0; i < 3; i++) {
+ BoundVert *bndv = vm0->boundstart;
+ for (int i = 0; i < 3; i++) {
+ float coc[3];
/* Get point, 1/2 of the way around profile, on arc between this and next. */
coc[i] = 1.0f;
coc[(i + 1) % 3] = 1.0f;
@@ -4296,6 +4200,7 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
bndv = bndv->next;
}
/* Center vertex. */
+ float co[3];
copy_v3_fl(co, (float)M_SQRT1_3);
if (nseg > 2) {
@@ -4310,7 +4215,7 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
vmesh_copy_equiv_verts(vm0);
- vm1 = vm0;
+ VMesh *vm1 = vm0;
while (vm1->seg < nseg) {
vm1 = cubic_subdiv(bp, vm1);
}
@@ -4319,10 +4224,10 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
}
/* Now snap each vertex to the superellipsoid. */
- ns2 = nseg / 2;
- for (i = 0; i < 3; i++) {
- for (j = 0; j <= ns2; j++) {
- for (k = 0; k <= nseg; k++) {
+ int ns2 = nseg / 2;
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j <= ns2; j++) {
+ for (int k = 0; k <= nseg; k++) {
snap_to_superellipsoid(mesh_vert(vm1, i, j, k)->co, r, false);
}
}
@@ -4334,9 +4239,6 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
/* Is this a good candidate for using tri_corner_adj_vmesh? */
static int tri_corner_test(BevelParams *bp, BevVert *bv)
{
- float ang, absang, totang, angdiff;
- EdgeHalf *e;
- int i;
int in_plane_e = 0;
/* The superellipse snapping of this case isn't helpful with custom profiles enabled. */
@@ -4350,11 +4252,11 @@ static int tri_corner_test(BevelParams *bp, BevVert *bv)
/* Only use the tri-corner special case if the offset is the same for every edge. */
float offset = bv->edges[0].offset_l;
- totang = 0.0f;
- for (i = 0; i < bv->edgecount; i++) {
- e = &bv->edges[i];
- ang = BM_edge_calc_face_angle_signed_ex(e->e, 0.0f);
- absang = fabsf(ang);
+ float totang = 0.0f;
+ for (int i = 0; i < bv->edgecount; i++) {
+ EdgeHalf *e = &bv->edges[i];
+ float ang = BM_edge_calc_face_angle_signed_ex(e->e, 0.0f);
+ float absang = fabsf(ang);
if (absang <= M_PI_4) {
in_plane_e++;
}
@@ -4371,7 +4273,7 @@ static int tri_corner_test(BevelParams *bp, BevVert *bv)
if (in_plane_e != bv->edgecount - 3) {
return -1;
}
- angdiff = fabsf(fabsf(totang) - 3.0f * (float)M_PI_2);
+ float angdiff = fabsf(fabsf(totang) - 3.0f * (float)M_PI_2);
if ((bp->pro_super_r == PRO_SQUARE_R && angdiff > (float)M_PI / 16.0f) ||
(angdiff > (float)M_PI_4)) {
return -1;
@@ -4384,25 +4286,24 @@ static int tri_corner_test(BevelParams *bp, BevVert *bv)
static VMesh *tri_corner_adj_vmesh(BevelParams *bp, BevVert *bv)
{
- int i, j, k, ns, ns2;
- float co0[3], co1[3], co2[3];
- float mat[4][4], v[4];
- VMesh *vm;
- BoundVert *bndv;
+ BoundVert *bndv = bv->vmesh->boundstart;
- bndv = bv->vmesh->boundstart;
+ float co0[3], co1[3], co2[3];
copy_v3_v3(co0, bndv->nv.co);
bndv = bndv->next;
copy_v3_v3(co1, bndv->nv.co);
bndv = bndv->next;
copy_v3_v3(co2, bndv->nv.co);
+
+ float mat[4][4];
make_unit_cube_map(co0, co1, co2, bv->v->co, mat);
- ns = bp->seg;
- ns2 = ns / 2;
- vm = make_cube_corner_adj_vmesh(bp);
- for (i = 0; i < 3; i++) {
- for (j = 0; j <= ns2; j++) {
- for (k = 0; k <= ns; k++) {
+ int ns = bp->seg;
+ int ns2 = ns / 2;
+ VMesh *vm = make_cube_corner_adj_vmesh(bp);
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j <= ns2; j++) {
+ for (int k = 0; k <= ns; k++) {
+ float v[4];
copy_v3_v3(v, mesh_vert(vm, i, j, k)->co);
v[3] = 1.0f;
mul_m4_v4(mat, v);
@@ -4417,14 +4318,9 @@ static VMesh *tri_corner_adj_vmesh(BevelParams *bp, BevVert *bv)
/* Makes the mesh that replaces the original vertex, bounded by the profiles on the sides. */
static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv)
{
- int n_bndv, nseg, i;
- VMesh *vm0, *vm1;
- float boundverts_center[3], original_vertex[3], negative_fullest[3], center_direction[3];
- BoundVert *bndv;
MemArena *mem_arena = bp->mem_arena;
- float fullness;
- n_bndv = bv->vmesh->count;
+ int n_bndv = bv->vmesh->count;
/* Same bevel as that of 3 edges of vert in a cube. */
if (n_bndv == 3 && tri_corner_test(bp, bv) != -1 && bp->pro_super_r != PRO_SQUARE_IN_R) {
@@ -4432,13 +4328,13 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv)
}
/* First construct an initial control mesh, with nseg == 2. */
- nseg = bv->vmesh->seg;
- vm0 = new_adj_vmesh(mem_arena, n_bndv, 2, bv->vmesh->boundstart);
+ int nseg = bv->vmesh->seg;
+ VMesh *vm0 = new_adj_vmesh(mem_arena, n_bndv, 2, bv->vmesh->boundstart);
/* Find the center of the boundverts that make up the vmesh. */
- bndv = vm0->boundstart;
- zero_v3(boundverts_center);
- for (i = 0; i < n_bndv; i++) {
+ BoundVert *bndv = vm0->boundstart;
+ float boundverts_center[3] = {0.0f, 0.0f, 0.0f};
+ for (int i = 0; i < n_bndv; i++) {
/* Boundaries just divide input polygon edges into 2 even segments. */
copy_v3_v3(mesh_vert(vm0, i, 0, 0)->co, bndv->nv.co);
get_profile_point(bp, &bndv->profile, 1, 2, mesh_vert(vm0, i, 0, 1)->co);
@@ -4451,12 +4347,14 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv)
* 'negative_fullest' is the reflection of the original vertex across the boundverts' center.
* 'fullness' is the fraction of the way from the boundvert's centroid to the original vertex
* (if positive) or to negative_fullest (if negative). */
+ float original_vertex[3], negative_fullest[3];
copy_v3_v3(original_vertex, bv->v->co);
sub_v3_v3v3(negative_fullest, boundverts_center, original_vertex);
add_v3_v3(negative_fullest, boundverts_center);
/* Find the vertex mesh's start center with the profile's fullness. */
- fullness = bp->pro_spacing.fullness;
+ float fullness = bp->pro_spacing.fullness;
+ float center_direction[3];
sub_v3_v3v3(center_direction, original_vertex, boundverts_center);
if (len_squared_v3(center_direction) > BEVEL_EPSILON_SQ) {
if (bp->profile_type == BEVEL_PROFILE_CUSTOM) {
@@ -4473,7 +4371,7 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv)
vmesh_copy_equiv_verts(vm0);
/* Do the subdivision process to go from the two segment start mesh to the final vertex mesh. */
- vm1 = vm0;
+ VMesh *vm1 = vm0;
do {
vm1 = cubic_subdiv(bp, vm1);
} while (vm1->seg < nseg);
@@ -4491,35 +4389,38 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv)
*/
static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3])
{
- float va[3], vb[3], edir[3], va0[3], vb0[3], vmid0[3];
- float plane[4], m[4][4], minv[4][4], p[3], snap[3];
Profile *pro = &vpipe->profile;
EdgeHalf *e = vpipe->ebev;
- copy_v3_v3(va, pro->start);
- copy_v3_v3(vb, pro->end);
- if (compare_v3v3(va, vb, BEVEL_EPSILON_D)) {
- copy_v3_v3(co, va);
+ if (compare_v3v3(pro->start, pro->end, BEVEL_EPSILON_D)) {
+ copy_v3_v3(co, pro->start);
return;
}
/* Get a plane with the normal pointing along the beveled edge. */
+ float edir[3], plane[4];
sub_v3_v3v3(edir, e->e->v1->co, e->e->v2->co);
plane_from_point_normal_v3(plane, co, edir);
- closest_to_plane_v3(va0, plane, va);
- closest_to_plane_v3(vb0, plane, vb);
+ 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 m[4][4], minv[4][4];
if (make_unit_square_map(va0, vmid0, vb0, m) && invert_m4_m4(minv, m)) {
/* Transform co and project it onto superellipse. */
+ float p[3];
mul_v3_m4v3(p, minv, co);
snap_to_superellipsoid(p, pro->super_r, midline);
+ float snap[3];
mul_v3_m4v3(snap, m, p);
copy_v3_v3(co, snap);
}
else {
/* Planar case: just snap to line va0--vb0. */
+ float p[3];
closest_to_line_segment_v3(p, co, va0, vb0);
copy_v3_v3(co, p);
}
@@ -4532,35 +4433,30 @@ static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3])
*/
static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe)
{
- int i, j, k, n_bndv, ns, half_ns, ipipe1, ipipe2, ring;
- VMesh *vm;
- bool even, midline;
- float *profile_point_pipe1, *profile_point_pipe2, f;
-
/* Some unnecessary overhead running this subdivision with custom profile snapping later on. */
- vm = adj_vmesh(bp, bv);
+ VMesh *vm = adj_vmesh(bp, bv);
/* Now snap all interior coordinates to be on the epipe profile. */
- n_bndv = bv->vmesh->count;
- ns = bv->vmesh->seg;
- half_ns = ns / 2;
- even = (ns % 2) == 0;
- ipipe1 = vpipe->index;
- ipipe2 = vpipe->next->next->index;
-
- for (i = 0; i < n_bndv; i++) {
- for (j = 1; j <= half_ns; j++) {
- for (k = 0; k <= half_ns; k++) {
+ int n_bndv = bv->vmesh->count;
+ int ns = bv->vmesh->seg;
+ int half_ns = ns / 2;
+ int ipipe1 = vpipe->index;
+ int ipipe2 = vpipe->next->next->index;
+
+ for (int i = 0; i < n_bndv; i++) {
+ for (int j = 1; j <= half_ns; j++) {
+ for (int k = 0; k <= half_ns; k++) {
if (!is_canon(vm, i, j, k)) {
continue;
}
/* With a custom profile just copy the shape of the profile at each ring. */
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 (n_bndv == 3 && i == ipipe1) {
/* This part of the vmesh is the triangular corner between the two pipe profiles. */
- ring = max_ii(j, k);
+ int ring = max_ii(j, k);
profile_point_pipe2 = mesh_vert(vm, i, 0, ring)->co;
profile_point_pipe1 = mesh_vert(vm, i, ring, 0)->co;
/* End profile index increases with k on one side and j on the other. */
@@ -4586,8 +4482,9 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe)
else {
/* A tricky case is for the 'square' profiles and an even nseg: we want certain
* vertices to snap to the midline on the pipe, not just to one plane or the other. */
- midline = even && k == half_ns &&
- ((i == 0 && j == half_ns) || (i == ipipe1 || i == ipipe2));
+ bool even = (ns % 2) == 0;
+ bool midline = even && k == half_ns &&
+ ((i == 0 && j == half_ns) || (i == ipipe1 || i == ipipe2));
snap_to_pipe_profile(vpipe, midline, mesh_vert(vm, i, j, k)->co);
}
}
@@ -4598,14 +4495,14 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe)
static void get_incident_edges(BMFace *f, BMVert *v, BMEdge **r_e1, BMEdge **r_e2)
{
- BMIter iter;
- BMEdge *e;
-
*r_e1 = NULL;
*r_e2 = NULL;
if (!f) {
return;
}
+
+ BMIter iter;
+ BMEdge *e;
BM_ITER_ELEM (e, &iter, f, BM_EDGES_OF_FACE) {
if (e->v1 == v || e->v2 == v) {
if (*r_e1 == NULL) {
@@ -4620,11 +4517,9 @@ static void get_incident_edges(BMFace *f, BMVert *v, BMEdge **r_e1, BMEdge **r_e
static BMEdge *find_closer_edge(float *co, BMEdge *e1, BMEdge *e2)
{
- float dsq1, dsq2;
-
BLI_assert(e1 != NULL && e2 != NULL);
- dsq1 = dist_squared_to_line_segment_v3(co, e1->v1->co, e1->v2->co);
- dsq2 = dist_squared_to_line_segment_v3(co, e2->v1->co, e2->v2->co);
+ float dsq1 = dist_squared_to_line_segment_v3(co, e1->v1->co, e1->v2->co);
+ float dsq2 = dist_squared_to_line_segment_v3(co, e2->v1->co, e2->v2->co);
if (dsq1 < dsq2) {
return e1;
}
@@ -4636,16 +4531,14 @@ static BMEdge *find_closer_edge(float *co, BMEdge *e1, BMEdge *e2)
* and the distance squared to the snap point as function return */
static float snap_face_dist_squared(float *co, BMFace *f, BMEdge **r_snap_e, float *r_snap_co)
{
- BMIter iter;
BMEdge *beste = NULL;
- float d2, beste_d2;
+ float beste_d2 = 1e20f;
+ BMIter iter;
BMEdge *e;
- float closest[3];
-
- beste_d2 = 1e20f;
BM_ITER_ELEM (e, &iter, f, BM_EDGES_OF_FACE) {
+ float closest[3];
closest_to_line_segment_v3(closest, co, e->v1->co, e->v2->co);
- d2 = len_squared_v3v3(closest, co);
+ float d2 = len_squared_v3v3(closest, co);
if (d2 < beste_d2) {
beste_d2 = d2;
beste = e;
@@ -4660,23 +4553,19 @@ static float snap_face_dist_squared(float *co, BMFace *f, BMEdge **r_snap_e, flo
*/
static float interp_poly_area(BevVert *bv, BMFace *frep)
{
- BoundVert *v;
VMesh *vm = bv->vmesh;
- BMEdge *snape;
- int n;
- float(*uv_co)[3] = NULL;
- float area;
BLI_assert(vm != NULL);
- uv_co = BLI_array_alloca(uv_co, vm->count);
- v = vm->boundstart;
- n = 0;
+ float(*uv_co)[3] = BLI_array_alloca(uv_co, vm->count);
+ BoundVert *v = vm->boundstart;
+ int n = 0;
do {
BLI_assert(n < vm->count);
+ BMEdge *snape;
snap_face_dist_squared(v->nv.v->co, frep, &snape, uv_co[n]);
n++;
} while ((v = v->next) != vm->boundstart);
- area = fabsf(area_poly_v3(uv_co, n));
+ float area = fabsf(area_poly_v3(uv_co, n));
return area;
}
@@ -4709,32 +4598,25 @@ static bool is_bad_uv_poly(BevVert *bv, BMFace *frep)
*/
static BMFace *frep_for_center_poly(BevelParams *bp, BevVert *bv)
{
- int i, j, fcount;
- BMFace **fchoices, *bmf, *bmf1, *bmf2, *any_bmf;
- BMFace *ftwo[2];
- bool already_there;
- bool consider_all_faces;
-
- fcount = 0;
- any_bmf = NULL;
- consider_all_faces = bv->selcount == 1;
+ int fcount = 0;
+ BMFace *any_bmf = NULL;
+ bool consider_all_faces = bv->selcount == 1;
/* Make an array that can hold maximum possible number of choices. */
- fchoices = BLI_array_alloca(fchoices, bv->edgecount);
- for (i = 0; i < bv->edgecount; i++) {
+ BMFace **fchoices = BLI_array_alloca(fchoices, bv->edgecount);
+ for (int i = 0; i < bv->edgecount; i++) {
if (!bv->edges[i].is_bev && !consider_all_faces) {
continue;
}
- bmf1 = bv->edges[i].fprev;
- bmf2 = bv->edges[i].fnext;
- ftwo[0] = bmf1;
- ftwo[1] = bmf2;
- bmf = choose_rep_face(bp, ftwo, 2);
+ BMFace *bmf1 = bv->edges[i].fprev;
+ BMFace *bmf2 = bv->edges[i].fnext;
+ BMFace *ftwo[2] = {bmf1, bmf2};
+ BMFace *bmf = choose_rep_face(bp, ftwo, 2);
if (bmf != NULL) {
if (any_bmf == NULL) {
any_bmf = bmf;
}
- already_there = false;
- for (j = fcount - 1; j >= 0; j--) {
+ bool already_there = false;
+ for (int j = fcount - 1; j >= 0; j--) {
if (fchoices[j] == bmf) {
already_there = true;
break;
@@ -4759,10 +4641,6 @@ static BMFace *frep_for_center_poly(BevelParams *bp, BevVert *bv)
static void build_center_ngon(BevelParams *bp, BMesh *bm, BevVert *bv, int mat_nr)
{
VMesh *vm = bv->vmesh;
- BoundVert *v;
- int i, ns2;
- BMFace *frep, *f;
- BMEdge *frep_e1, *frep_e2, *frep_e;
BMVert **vv = NULL;
BMFace **vf = NULL;
BMEdge **ve = NULL;
@@ -4770,7 +4648,9 @@ static void build_center_ngon(BevelParams *bp, BMesh *bm, BevVert *bv, int mat_n
BLI_array_staticdeclare(vf, BM_DEFAULT_NGON_STACK_SIZE);
BLI_array_staticdeclare(ve, BM_DEFAULT_NGON_STACK_SIZE);
- ns2 = vm->seg / 2;
+ int ns2 = vm->seg / 2;
+ BMFace *frep;
+ BMEdge *frep_e1, *frep_e2;
if (bv->any_seam) {
frep = frep_for_center_poly(bp, bv);
get_incident_edges(frep, bv->v, &frep_e1, &frep_e2);
@@ -4779,13 +4659,13 @@ static void build_center_ngon(BevelParams *bp, BMesh *bm, BevVert *bv, int mat_n
frep = NULL;
frep_e1 = frep_e2 = NULL;
}
- v = vm->boundstart;
+ BoundVert *v = vm->boundstart;
do {
- i = v->index;
+ int i = v->index;
BLI_array_append(vv, mesh_vert(vm, i, ns2, ns2)->v);
if (frep) {
BLI_array_append(vf, frep);
- frep_e = find_closer_edge(mesh_vert(vm, i, ns2, ns2)->v->co, frep_e1, frep_e2);
+ BMEdge *frep_e = find_closer_edge(mesh_vert(vm, i, ns2, ns2)->v->co, frep_e1, frep_e2);
BLI_array_append(ve, v == vm->boundstart ? NULL : frep_e);
}
else {
@@ -4793,7 +4673,7 @@ static void build_center_ngon(BevelParams *bp, BMesh *bm, BevVert *bv, int mat_n
BLI_array_append(ve, NULL);
}
} while ((v = v->next) != vm->boundstart);
- f = bev_create_ngon(bm, vv, BLI_array_len(vv), vf, frep, ve, mat_nr, true);
+ BMFace *f = bev_create_ngon(bm, vv, BLI_array_len(vv), vf, frep, ve, mat_nr, true);
record_face_kind(bp, f, F_VERT);
BLI_array_free(vv);
@@ -4809,17 +4689,14 @@ static void build_center_ngon(BevelParams *bp, BMesh *bm, BevVert *bv, int mat_n
*/
static void build_square_in_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv, VMesh *vm1)
{
- int n, ns, ns2, odd, i, k;
- VMesh *vm;
-
- vm = bv->vmesh;
- n = vm->count;
- ns = vm->seg;
- ns2 = ns / 2;
- odd = ns % 2;
+ VMesh *vm = bv->vmesh;
+ int n = vm->count;
+ int ns = vm->seg;
+ int ns2 = ns / 2;
+ int odd = ns % 2;
- for (i = 0; i < n; i++) {
- for (k = 1; k < ns; k++) {
+ for (int i = 0; i < n; i++) {
+ for (int k = 1; k < ns; k++) {
copy_v3_v3(mesh_vert(vm, i, 0, k)->co, mesh_vert(vm1, i, 0, k)->co);
if (i > 0 && k <= ns2) {
mesh_vert(vm, i, 0, k)->v = mesh_vert(vm, i - 1, 0, ns - k)->v;
@@ -4833,7 +4710,7 @@ static void build_square_in_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv, VMesh
}
}
if (odd) {
- for (i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++) {
mesh_vert(vm, i, ns2, ns2)->v = mesh_vert(vm, i, 0, ns2)->v;
}
build_center_ngon(bp, bm, bv, bp->mat_nr);
@@ -4843,7 +4720,7 @@ static void build_square_in_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv, VMesh
/**
* Copy whichever of \a a and \a b is closer to v into \a r.
*/
-static void closer_v3_v3v3v3(float r[3], float a[3], float b[3], float v[3])
+static void closer_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float v[3])
{
if (len_squared_v3v3(a, v) <= len_squared_v3v3(b, v)) {
copy_v3_v3(r, a);
@@ -4867,34 +4744,25 @@ static void closer_v3_v3v3v3(float r[3], float a[3], float b[3], float v[3])
*/
static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
{
- int n_bndv, ns, ns2, odd, i, j, k, ikind, im1, clstride, iprev, ang_kind;
- float bndco[3], dir1[3], dir2[3], co1[3], co2[3], meet1[3], meet2[3], v1co[3], v2co[3];
- float *on_edge_cur, *on_edge_prev, *p;
- float ns2inv, finalfrac, ang;
- BoundVert *bndv;
- EdgeHalf *e1, *e2;
- VMesh *vm;
- float *centerline;
- bool *cset, v1set, v2set;
-
- n_bndv = bv->vmesh->count;
- ns = bv->vmesh->seg;
- ns2 = ns / 2;
- odd = ns % 2;
- ns2inv = 1.0f / (float)ns2;
- vm = new_adj_vmesh(bp->mem_arena, n_bndv, ns, bv->vmesh->boundstart);
- clstride = 3 * (ns2 + 1);
- centerline = MEM_mallocN((size_t)(clstride * n_bndv) * sizeof(float), "bevel");
- cset = MEM_callocN((size_t)n_bndv * sizeof(bool), "bevel");
+ int n_bndv = bv->vmesh->count;
+ int ns = bv->vmesh->seg;
+ int ns2 = ns / 2;
+ int odd = ns % 2;
+ float ns2inv = 1.0f / (float)ns2;
+ VMesh *vm = new_adj_vmesh(bp->mem_arena, n_bndv, ns, bv->vmesh->boundstart);
+ int clstride = 3 * (ns2 + 1);
+ float *centerline = MEM_mallocN(sizeof(float) * clstride * n_bndv, "bevel");
+ bool *cset = MEM_callocN(sizeof(bool) * n_bndv, "bevel");
/* Find on_edge, place on bndv[i]'s elast where offset line would meet,
* taking min-distance-to bv->v with position where next sector's offset line would meet. */
- bndv = vm->boundstart;
- for (i = 0; i < n_bndv; i++) {
+ BoundVert *bndv = vm->boundstart;
+ for (int i = 0; i < n_bndv; i++) {
+ float bndco[3];
copy_v3_v3(bndco, bndv->nv.co);
- e1 = bndv->efirst;
- e2 = bndv->elast;
- ang_kind = ANGLE_STRAIGHT;
+ EdgeHalf *e1 = bndv->efirst;
+ EdgeHalf *e2 = bndv->elast;
+ int ang_kind = ANGLE_STRAIGHT;
if (e1 && e2) {
ang_kind = edges_angle_kind(e1, e2, bv->v);
}
@@ -4919,12 +4787,16 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
/* Leave cset[i] where it was - probably false, unless i == n - 1. */
}
else if (ang_kind == ANGLE_SMALLER) {
+ float dir1[3], dir2[3], co1[3], co2[3];
sub_v3_v3v3(dir1, e1->e->v1->co, e1->e->v2->co);
sub_v3_v3v3(dir2, e2->e->v1->co, e2->e->v2->co);
add_v3_v3v3(co1, bndco, dir1);
add_v3_v3v3(co2, bndco, dir2);
/* Intersect e1 with line through bndv parallel to e2 to get v1co. */
- ikind = isect_line_line_v3(e1->e->v1->co, e1->e->v2->co, bndco, co2, meet1, meet2);
+ float meet1[3], meet2[3];
+ int ikind = isect_line_line_v3(e1->e->v1->co, e1->e->v2->co, bndco, co2, meet1, meet2);
+ float v1co[3];
+ bool v1set;
if (ikind == 0) {
v1set = false;
}
@@ -4935,6 +4807,8 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
}
/* Intersect e2 with line through bndv parallel to e1 to get v2co. */
ikind = isect_line_line_v3(e2->e->v1->co, e2->e->v2->co, bndco, co1, meet1, meet2);
+ float v2co[3];
+ bool v2set;
if (ikind == 0) {
v2set = false;
}
@@ -4944,9 +4818,9 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
}
/* We want on_edge[i] to be min dist to bv->v of v2co and the v1co of next iteration. */
- on_edge_cur = centerline + clstride * i;
- iprev = (i == 0) ? n_bndv - 1 : i - 1;
- on_edge_prev = centerline + clstride * iprev;
+ float *on_edge_cur = centerline + clstride * i;
+ int iprev = (i == 0) ? n_bndv - 1 : i - 1;
+ float *on_edge_prev = centerline + clstride * iprev;
if (v2set) {
if (cset[i]) {
closer_v3_v3v3v3(on_edge_cur, on_edge_cur, v2co, bv->v->co);
@@ -4970,15 +4844,17 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
}
/* Maybe not everything was set by the previous loop. */
bndv = vm->boundstart;
- for (i = 0; i < n_bndv; i++) {
+ for (int i = 0; i < n_bndv; i++) {
if (!cset[i]) {
- on_edge_cur = centerline + clstride * i;
- e1 = bndv->next->efirst;
+ float *on_edge_cur = centerline + clstride * i;
+ EdgeHalf *e1 = bndv->next->efirst;
+ float co1[3], co2[3];
copy_v3_v3(co1, bndv->nv.co);
copy_v3_v3(co2, bndv->next->nv.co);
if (e1) {
if (bndv->prev->is_arc_start && bndv->next->is_arc_start) {
- ikind = isect_line_line_v3(e1->e->v1->co, e1->e->v2->co, co1, co2, meet1, meet2);
+ float meet1[3], meet2[3];
+ int ikind = isect_line_line_v3(e1->e->v1->co, e1->e->v2->co, co1, co2, meet1, meet2);
if (ikind != 0) {
copy_v3_v3(on_edge_cur, meet1);
cset[i] = true;
@@ -5003,11 +4879,13 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
}
/* Fill in rest of center-lines by interpolation. */
+ float co1[3], co2[3];
copy_v3_v3(co2, bv->v->co);
bndv = vm->boundstart;
- for (i = 0; i < n_bndv; i++) {
+ for (int i = 0; i < n_bndv; i++) {
if (odd) {
- ang = 0.5f * angle_v3v3v3(bndv->nv.co, co1, bndv->next->nv.co);
+ float ang = 0.5f * angle_v3v3v3(bndv->nv.co, co1, bndv->next->nv.co);
+ float finalfrac;
if (ang > BEVEL_SMALL_ANG) {
/* finalfrac is the length along arms of isosceles triangle with top angle 2*ang
* such that the base of the triangle is 1.
@@ -5024,10 +4902,10 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
ns2inv = 1.0f / (ns2 + finalfrac);
}
- p = centerline + clstride * i;
+ float *p = centerline + clstride * i;
copy_v3_v3(co1, p);
p += 3;
- for (j = 1; j <= ns2; j++) {
+ for (int j = 1; j <= ns2; j++) {
interp_v3_v3v3(p, co1, co2, j * ns2inv);
p += 3;
}
@@ -5036,14 +4914,14 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
/* Coords of edges and mid or near-mid line. */
bndv = vm->boundstart;
- for (i = 0; i < n_bndv; i++) {
+ for (int i = 0; i < n_bndv; i++) {
copy_v3_v3(co1, bndv->nv.co);
copy_v3_v3(co2, centerline + clstride * (i == 0 ? n_bndv - 1 : i - 1));
- for (j = 0; j < ns2 + odd; j++) {
+ for (int j = 0; j < ns2 + odd; j++) {
interp_v3_v3v3(mesh_vert(vm, i, j, 0)->co, co1, co2, j * ns2inv);
}
copy_v3_v3(co2, centerline + clstride * i);
- for (k = 1; k <= ns2; k++) {
+ for (int k = 1; k <= ns2; k++) {
interp_v3_v3v3(mesh_vert(vm, i, 0, k)->co, co1, co2, k * ns2inv);
}
bndv = bndv->next;
@@ -5055,16 +4933,17 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
/* Fill in interior points by interpolation from edges to center-lines. */
bndv = vm->boundstart;
- for (i = 0; i < n_bndv; i++) {
- im1 = (i == 0) ? n_bndv - 1 : i - 1;
- for (j = 1; j < ns2 + odd; j++) {
- for (k = 1; k <= ns2; k++) {
- ikind = isect_line_line_v3(mesh_vert(vm, i, 0, k)->co,
- centerline + clstride * im1 + 3 * k,
- mesh_vert(vm, i, j, 0)->co,
- centerline + clstride * i + 3 * j,
- meet1,
- meet2);
+ for (int i = 0; i < n_bndv; i++) {
+ int im1 = (i == 0) ? n_bndv - 1 : i - 1;
+ for (int j = 1; j < ns2 + odd; j++) {
+ for (int k = 1; k <= ns2; k++) {
+ float meet1[3], meet2[3];
+ int ikind = isect_line_line_v3(mesh_vert(vm, i, 0, k)->co,
+ centerline + clstride * im1 + 3 * k,
+ mesh_vert(vm, i, j, 0)->co,
+ centerline + clstride * i + 3 * j,
+ meet1,
+ meet2);
if (ikind == 0) {
/* How can this happen? fall back on interpolation in one direction if it does. */
interp_v3_v3v3(mesh_vert(vm, i, j, k)->co,
@@ -5097,22 +4976,15 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
*/
static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert *vpipe)
{
- int n_bndv, ns, ns2, odd, i, j, k, ring;
- VMesh *vm1, *vm;
- BoundVert *bndv;
- BMVert *bmv1, *bmv2, *bmv3, *bmv4;
- BMFace *f, *f2, *r_f, *fc;
- BMFace *fchoices[2];
- BMEdge *bme, *bme1, *bme2, *bme3;
- EdgeHalf *e;
int mat_nr = bp->mat_nr;
- n_bndv = bv->vmesh->count;
- ns = bv->vmesh->seg;
- ns2 = ns / 2;
- odd = ns % 2;
+ int n_bndv = bv->vmesh->count;
+ int ns = bv->vmesh->seg;
+ int ns2 = ns / 2;
+ int odd = ns % 2;
BLI_assert(n_bndv >= 3 && ns > 1);
+ VMesh *vm1;
if (bp->pro_super_r == PRO_SQUARE_R && bv->selcount >= 3 && !odd &&
bp->profile_type != BEVEL_PROFILE_CUSTOM) {
vm1 = square_out_adj_vmesh(bp, bv);
@@ -5134,10 +5006,10 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert
}
/* Copy final vmesh into bv->vmesh, make BMVerts and BMFaces. */
- vm = bv->vmesh;
- for (i = 0; i < n_bndv; i++) {
- for (j = 0; j <= ns2; j++) {
- for (k = 0; k <= ns; k++) {
+ VMesh *vm = bv->vmesh;
+ for (int i = 0; i < n_bndv; i++) {
+ for (int j = 0; j <= ns2; j++) {
+ for (int k = 0; k <= ns; k++) {
if (j == 0 && (k == 0 || k == ns)) {
continue; /* Boundary corners already made. */
}
@@ -5151,26 +5023,16 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert
}
vmesh_copy_equiv_verts(vm);
/* Make the polygons. */
- bndv = vm->boundstart;
+ BoundVert *bndv = vm->boundstart;
do {
- i = bndv->index;
- f = boundvert_rep_face(bndv, NULL);
- f2 = boundvert_rep_face(bndv->next, NULL);
- fchoices[0] = f;
- fchoices[1] = f2;
- if (odd) {
- fc = choose_rep_face(bp, fchoices, 2);
- }
- else {
- fc = NULL;
- }
- if (bp->affect_type == BEVEL_AFFECT_VERTICES) {
- e = bndv->efirst;
- }
- else {
- e = bndv->ebev;
- }
- bme = e ? e->e : NULL;
+ int i = bndv->index;
+ BMFace *f = boundvert_rep_face(bndv, NULL);
+ BMFace *f2 = boundvert_rep_face(bndv->next, NULL);
+ BMFace *fchoices[2] = {f, f2};
+ BMFace *fc = odd ? choose_rep_face(bp, fchoices, 2) : NULL;
+
+ EdgeHalf *e = (bp->affect_type == BEVEL_AFFECT_VERTICES) ? bndv->efirst : bndv->ebev;
+ BMEdge *bme = e ? e->e : NULL;
/* For odd ns, make polys with lower left corner at (i,j,k) for
* j in [0, ns2-1], k in [0, ns2]. And then the center ngon.
* For even ns,
@@ -5178,13 +5040,14 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert
*
* Recall: j is ring index, k is segment index.
*/
- for (j = 0; j < ns2; j++) {
- for (k = 0; k < ns2 + odd; k++) {
- bmv1 = mesh_vert(vm, i, j, k)->v;
- bmv2 = mesh_vert(vm, i, j, k + 1)->v;
- bmv3 = mesh_vert(vm, i, j + 1, k + 1)->v;
- bmv4 = mesh_vert(vm, i, j + 1, k)->v;
+ for (int j = 0; j < ns2; j++) {
+ for (int k = 0; k < ns2 + odd; k++) {
+ BMVert *bmv1 = mesh_vert(vm, i, j, k)->v;
+ BMVert *bmv2 = mesh_vert(vm, i, j, k + 1)->v;
+ BMVert *bmv3 = mesh_vert(vm, i, j + 1, k + 1)->v;
+ BMVert *bmv4 = mesh_vert(vm, i, j + 1, k)->v;
BLI_assert(bmv1 && bmv2 && bmv3 && bmv4);
+ BMFace *r_f;
if (bp->affect_type == BEVEL_AFFECT_VERTICES) {
if (j < k) {
if (k == ns2 && j == ns2 - 1) {
@@ -5240,12 +5103,12 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert
}
}
else {
- bme1 = k == ns2 - 1 ? bme : NULL;
- bme3 = NULL;
+ BMEdge *bme1 = k == ns2 - 1 ? bme : NULL;
+ BMEdge *bme3 = NULL;
if (j == ns2 - 1 && bndv->prev->ebev) {
bme3 = bndv->prev->ebev->e;
}
- bme2 = bme1 != NULL ? bme1 : bme3;
+ BMEdge *bme2 = bme1 != NULL ? bme1 : bme3;
r_f = bev_create_quad_ex(
bm, bmv1, bmv2, bmv3, bmv4, f, f, f, f, NULL, bme1, bme2, bme3, f, mat_nr);
}
@@ -5259,9 +5122,9 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert
if (!odd) {
bndv = vm->boundstart;
do {
- i = bndv->index;
+ int i = bndv->index;
if (!bndv->any_seam) {
- for (ring = 1; ring < ns2; ring++) {
+ for (int ring = 1; ring < ns2; ring++) {
BMVert *v_uv = mesh_vert(vm, i, ring, ns2)->v;
if (v_uv) {
bev_merge_uvs(bm, v_uv);
@@ -5269,9 +5132,9 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert
}
}
} while ((bndv = bndv->next) != vm->boundstart);
- bmv1 = mesh_vert(vm, 0, ns2, ns2)->v;
+ BMVert *bmv = mesh_vert(vm, 0, ns2, ns2)->v;
if (bp->affect_type == BEVEL_AFFECT_VERTICES || count_bound_vert_seams(bv) <= 1) {
- bev_merge_uvs(bm, bmv1);
+ bev_merge_uvs(bm, bmv);
}
}
@@ -5297,33 +5160,27 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv)
#ifdef DEBUG_CUSTOM_PROFILE_CUTOFF
printf("BEVEL BUILD CUTOFF\n");
# define F3(v) (v)[0], (v)[1], (v)[2]
- int j;
#endif
- int i;
int n_bndv = bv->vmesh->count;
- BoundVert *bndv;
- float length;
- float down_direction[3], new_vert[3];
- bool build_center_face;
- /* BMFace *repface; */
- BMVert **face_bmverts = NULL;
- BMEdge **bmedges = NULL;
- BMFace **bmfaces = NULL;
/* Find the locations for the corner vertices at the bottom of the cutoff faces. */
- bndv = bv->vmesh->boundstart;
+ BoundVert *bndv = bv->vmesh->boundstart;
do {
- i = bndv->index;
+ int i = bndv->index;
/* Find the "down" direction for this side of the cutoff face. */
/* Find the direction along the intersection of the two adjacent profile normals. */
+ float down_direction[3];
cross_v3_v3v3(down_direction, bndv->profile.plane_no, bndv->prev->profile.plane_no);
if (dot_v3v3(down_direction, bv->v->no) > 0.0f) {
negate_v3(down_direction);
}
/* Move down from the boundvert by average profile height from the two adjacent profiles. */
- length = (bndv->profile.height / sqrtf(2.0f) + bndv->prev->profile.height / sqrtf(2.0f)) / 2;
+ float length = (bndv->profile.height / sqrtf(2.0f) +
+ bndv->prev->profile.height / sqrtf(2.0f)) /
+ 2;
+ float new_vert[3];
madd_v3_v3v3fl(new_vert, bndv->nv.co, down_direction, length);
/* Use this location for this profile's first corner vert and the last profile's second. */
@@ -5334,13 +5191,13 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv)
#ifdef DEBUG_CUSTOM_PROFILE_CUTOFF
printf("Corner vertices:\n");
- for (j = 0; j < n_bndv; j++) {
+ for (int j = 0; j < n_bndv; j++) {
printf(" (%.3f, %.3f, %.3f)\n", F3(mesh_vert(bv->vmesh, j, 1, 0)->co));
}
#endif
/* Disable the center face if the corner vertices share the same location. */
- build_center_face = true;
+ bool build_center_face = true;
if (n_bndv == 3) { /* Vertices only collapse with a 3-way VMesh. */
build_center_face &= len_squared_v3v3(mesh_vert(bv->vmesh, 0, 1, 0)->co,
mesh_vert(bv->vmesh, 1, 1, 0)->co) > BEVEL_EPSILON;
@@ -5356,7 +5213,7 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv)
/* Create the corner vertex BMVerts. */
if (build_center_face) {
do {
- i = bndv->index;
+ int i = bndv->index;
create_mesh_bmvert(bm, bv->vmesh, i, 1, 0, bv->v);
/* The second corner vertex for the previous profile shares this BMVert. */
mesh_vert(bv->vmesh, bndv->prev->index, 1, 1)->v = mesh_vert(bv->vmesh, i, 1, 0)->v;
@@ -5366,7 +5223,7 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv)
else {
/* Use the same BMVert for all of the corner vertices. */
create_mesh_bmvert(bm, bv->vmesh, 0, 1, 0, bv->v);
- for (i = 1; i < n_bndv; i++) {
+ for (int i = 1; i < n_bndv; i++) {
mesh_vert(bv->vmesh, i, 1, 0)->v = mesh_vert(bv->vmesh, 0, 1, 0)->v;
}
}
@@ -5377,11 +5234,13 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv)
#ifdef DEBUG_CUSTOM_PROFILE_CUTOFF
printf("Building profile cutoff faces.\n");
#endif
- face_bmverts = BLI_memarena_alloc(
- bp->mem_arena, ((size_t)max_ii(bp->seg + 2 + build_center_face, n_bndv) * sizeof(BMVert *)));
+ BMVert **face_bmverts = BLI_memarena_alloc(
+ bp->mem_arena, sizeof(BMVert *) * max_ii(bp->seg + 2 + build_center_face, n_bndv));
bndv = bv->vmesh->boundstart;
do {
- i = bndv->index;
+ int i = bndv->index;
+ BMEdge **bmedges = NULL;
+ BMFace **bmfaces = NULL;
BLI_array_staticdeclare(bmedges, BM_DEFAULT_NGON_STACK_SIZE);
BLI_array_staticdeclare(bmfaces, BM_DEFAULT_NGON_STACK_SIZE);
@@ -5429,11 +5288,13 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv)
/* Create the bottom face if it should be built, reusing previous face_bmverts allocation. */
if (build_center_face) {
+ BMEdge **bmedges = NULL;
+ BMFace **bmfaces = NULL;
BLI_array_staticdeclare(bmedges, BM_DEFAULT_NGON_STACK_SIZE);
BLI_array_staticdeclare(bmfaces, BM_DEFAULT_NGON_STACK_SIZE);
/* Add all of the corner vertices to this face. */
- for (i = 0; i < n_bndv; i++) {
+ for (int i = 0; i < n_bndv; i++) {
/* Add verts from each cutoff face. */
face_bmverts[i] = mesh_vert(bv->vmesh, i, 1, 0)->v;
}
@@ -5447,11 +5308,7 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv)
static BMFace *bevel_build_poly(BevelParams *bp, BMesh *bm, BevVert *bv)
{
- BMFace *f, *repface;
- int n, k;
VMesh *vm = bv->vmesh;
- BoundVert *bndv;
- BMEdge *repface_e1, *repface_e2, *frep_e;
BMVert **bmverts = NULL;
BMEdge **bmedges = NULL;
BMFace **bmfaces = NULL;
@@ -5459,6 +5316,8 @@ static BMFace *bevel_build_poly(BevelParams *bp, BMesh *bm, BevVert *bv)
BLI_array_staticdeclare(bmedges, BM_DEFAULT_NGON_STACK_SIZE);
BLI_array_staticdeclare(bmfaces, BM_DEFAULT_NGON_STACK_SIZE);
+ BMFace *repface;
+ BMEdge *repface_e1, *repface_e2;
if (bv->any_seam) {
repface = frep_for_center_poly(bp, bv);
get_incident_edges(repface, bv->v, &repface_e1, &repface_e2);
@@ -5467,15 +5326,15 @@ static BMFace *bevel_build_poly(BevelParams *bp, BMesh *bm, BevVert *bv)
repface = NULL;
repface_e1 = repface_e2 = NULL;
}
- bndv = vm->boundstart;
- n = 0;
+ BoundVert *bndv = vm->boundstart;
+ int n = 0;
do {
/* Accumulate vertices for vertex ngon. */
/* Also accumulate faces in which uv interpolation is to happen for each. */
BLI_array_append(bmverts, bndv->nv.v);
if (repface) {
BLI_array_append(bmfaces, repface);
- frep_e = find_closer_edge(bndv->nv.v->co, repface_e1, repface_e2);
+ BMEdge *frep_e = find_closer_edge(bndv->nv.v->co, repface_e1, repface_e2);
BLI_array_append(bmedges, n > 0 ? frep_e : NULL);
}
else {
@@ -5484,11 +5343,11 @@ static BMFace *bevel_build_poly(BevelParams *bp, BMesh *bm, BevVert *bv)
}
n++;
if (bndv->ebev && bndv->ebev->seg > 1) {
- for (k = 1; k < bndv->ebev->seg; k++) {
+ for (int k = 1; k < bndv->ebev->seg; k++) {
BLI_array_append(bmverts, mesh_vert(vm, bndv->index, 0, k)->v);
if (repface) {
BLI_array_append(bmfaces, repface);
- frep_e = find_closer_edge(
+ BMEdge *frep_e = find_closer_edge(
mesh_vert(vm, bndv->index, 0, k)->v->co, repface_e1, repface_e2);
BLI_array_append(bmedges, k < bndv->ebev->seg / 2 ? NULL : frep_e);
}
@@ -5500,6 +5359,8 @@ static BMFace *bevel_build_poly(BevelParams *bp, BMesh *bm, BevVert *bv)
}
}
} while ((bndv = bndv->next) != vm->boundstart);
+
+ BMFace *f;
if (n > 2) {
f = bev_create_ngon(bm, bmverts, n, bmfaces, repface, bmedges, bp->mat_nr, true);
record_face_kind(bp, f, F_VERT);
@@ -5515,53 +5376,54 @@ static BMFace *bevel_build_poly(BevelParams *bp, BMesh *bm, BevVert *bv)
static void bevel_build_trifan(BevelParams *bp, BMesh *bm, BevVert *bv)
{
- BMFace *f;
BLI_assert(next_bev(bv, NULL)->seg == 1 || bv->selcount == 1);
- f = bevel_build_poly(bp, bm, bv);
+ BMFace *f = bevel_build_poly(bp, bm, bv);
- if (f) {
- /* We have a polygon which we know starts at the previous vertex, make it into a fan. */
- BMLoop *l_fan = BM_FACE_FIRST_LOOP(f)->prev;
- BMVert *v_fan = l_fan->v;
-
- while (f->len > 3) {
- BMLoop *l_new;
- BMFace *f_new;
- BLI_assert(v_fan == l_fan->v);
- f_new = BM_face_split(bm, f, l_fan, l_fan->next->next, &l_new, NULL, false);
- flag_out_edge(bm, l_new->e);
-
- if (f_new->len > f->len) {
- f = f_new;
- if (l_new->v == v_fan) {
- l_fan = l_new;
- }
- else if (l_new->next->v == v_fan) {
- l_fan = l_new->next;
- }
- else if (l_new->prev->v == v_fan) {
- l_fan = l_new->prev;
- }
- else {
- BLI_assert(0);
- }
+ if (f == NULL) {
+ return;
+ }
+
+ /* We have a polygon which we know starts at the previous vertex, make it into a fan. */
+ BMLoop *l_fan = BM_FACE_FIRST_LOOP(f)->prev;
+ BMVert *v_fan = l_fan->v;
+
+ while (f->len > 3) {
+ BMLoop *l_new;
+ BMFace *f_new;
+ BLI_assert(v_fan == l_fan->v);
+ f_new = BM_face_split(bm, f, l_fan, l_fan->next->next, &l_new, NULL, false);
+ flag_out_edge(bm, l_new->e);
+
+ if (f_new->len > f->len) {
+ f = f_new;
+ if (l_new->v == v_fan) {
+ l_fan = l_new;
+ }
+ else if (l_new->next->v == v_fan) {
+ l_fan = l_new->next;
+ }
+ else if (l_new->prev->v == v_fan) {
+ l_fan = l_new->prev;
}
else {
- if (l_fan->v == v_fan) { /* l_fan = l_fan. */
- }
- else if (l_fan->next->v == v_fan) {
- l_fan = l_fan->next;
- }
- else if (l_fan->prev->v == v_fan) {
- l_fan = l_fan->prev;
- }
- else {
- BLI_assert(0);
- }
+ BLI_assert(0);
}
- record_face_kind(bp, f_new, F_VERT);
}
+ else {
+ if (l_fan->v == v_fan) { /* l_fan = l_fan. */
+ }
+ else if (l_fan->next->v == v_fan) {
+ l_fan = l_fan->next;
+ }
+ else if (l_fan->prev->v == v_fan) {
+ l_fan = l_fan->prev;
+ }
+ else {
+ BLI_assert(0);
+ }
+ }
+ record_face_kind(bp, f_new, F_VERT);
}
}
@@ -5573,23 +5435,17 @@ static void bevel_build_trifan(BevelParams *bp, BMesh *bm, BevVert *bv)
static void bevel_vert_two_edges(BevelParams *bp, BMesh *bm, BevVert *bv)
{
VMesh *vm = bv->vmesh;
- BMVert *v1, *v2;
- BMEdge *e_eg, *bme;
- Profile *pro;
- float co[3];
- BoundVert *bndv;
- int ns, k;
BLI_assert(vm->count == 2 && bp->affect_type == BEVEL_AFFECT_VERTICES);
- v1 = mesh_vert(vm, 0, 0, 0)->v;
- v2 = mesh_vert(vm, 1, 0, 0)->v;
+ BMVert *v1 = mesh_vert(vm, 0, 0, 0)->v;
+ BMVert *v2 = mesh_vert(vm, 1, 0, 0)->v;
- ns = vm->seg;
+ int ns = vm->seg;
if (ns > 1) {
/* Set up profile parameters. */
- bndv = vm->boundstart;
- pro = &bndv->profile;
+ BoundVert *bndv = vm->boundstart;
+ Profile *pro = &bndv->profile;
pro->super_r = bp->pro_super_r;
copy_v3_v3(pro->start, v1->co);
copy_v3_v3(pro->end, v2->co);
@@ -5599,25 +5455,26 @@ static void bevel_vert_two_edges(BevelParams *bp, BMesh *bm, BevVert *bv)
zero_v3(pro->plane_no);
zero_v3(pro->proj_dir);
- for (k = 1; k < ns; k++) {
+ for (int k = 1; k < ns; k++) {
+ float co[3];
get_profile_point(bp, pro, k, ns, co);
copy_v3_v3(mesh_vert(vm, 0, 0, k)->co, co);
create_mesh_bmvert(bm, vm, 0, 0, k, bv->v);
}
copy_v3_v3(mesh_vert(vm, 0, 0, ns)->co, v2->co);
- for (k = 1; k < ns; k++) {
+ for (int k = 1; k < ns; k++) {
copy_mesh_vert(vm, 1, 0, ns - k, 0, 0, k);
}
}
if (BM_vert_face_check(bv->v) == false) {
- e_eg = bv->edges[0].e;
+ BMEdge *e_eg = bv->edges[0].e;
BLI_assert(e_eg != NULL);
- for (k = 0; k < ns; k++) {
+ for (int k = 0; k < ns; k++) {
v1 = mesh_vert(vm, 0, 0, k)->v;
v2 = mesh_vert(vm, 0, 0, k + 1)->v;
BLI_assert(v1 != NULL && v2 != NULL);
- bme = BM_edge_create(bm, v1, v2, e_eg, BM_CREATE_NO_DOUBLE);
+ BMEdge *bme = BM_edge_create(bm, v1, v2, e_eg, BM_CREATE_NO_DOUBLE);
if (bme) {
flag_out_edge(bm, bme);
}
@@ -5630,25 +5487,24 @@ static void bevel_vert_two_edges(BevelParams *bp, BMesh *bm, BevVert *bv)
static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv)
{
VMesh *vm = bv->vmesh;
- BoundVert *bndv, *weld1, *weld2, *vpipe;
- int n, ns, ns2, i, k, weld;
- float *v_weld1, *v_weld2, co[3];
+ float co[3];
- n = vm->count;
- ns = vm->seg;
- ns2 = ns / 2;
+ int n = vm->count;
+ int ns = vm->seg;
+ int ns2 = ns / 2;
vm->mesh = (NewVert *)BLI_memarena_alloc(bp->mem_arena,
- (size_t)(n * (ns2 + 1) * (ns + 1)) * sizeof(NewVert));
+ sizeof(NewVert) * n * (ns2 + 1) * (ns + 1));
/* Special case: just two beveled edges welded together. */
- weld = (bv->selcount == 2) && (vm->count == 2);
- weld1 = weld2 = NULL; /* Will hold two BoundVerts involved in weld. */
+ const bool weld = (bv->selcount == 2) && (vm->count == 2);
+ BoundVert *weld1 = NULL; /* Will hold two BoundVerts involved in weld. */
+ BoundVert *weld2 = NULL;
/* Make (i, 0, 0) mesh verts for all i boundverts. */
- bndv = vm->boundstart;
+ BoundVert *bndv = vm->boundstart;
do {
- i = bndv->index;
+ int i = bndv->index;
copy_v3_v3(mesh_vert(vm, i, 0, 0)->co, bndv->nv.co); /* Mesh NewVert to boundary NewVert. */
create_mesh_bmvert(bm, vm, i, 0, 0, bv->v); /* Create BMVert for that NewVert. */
bndv->nv.v = mesh_vert(vm, i, 0, 0)->v; /* Use the BMVert for the BoundVert's NewVert. */
@@ -5675,12 +5531,12 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv)
/* Copy other ends to (i, 0, ns) for all i, and fill in profiles for edges. */
bndv = vm->boundstart;
do {
- i = bndv->index;
+ int i = bndv->index;
/* bndv's last vert along the boundary arc is the first of the next BoundVert's arc. */
copy_mesh_vert(vm, i, 0, ns, bndv->next->index, 0, 0);
if (vm->mesh_kind != M_ADJ) {
- for (k = 1; k < ns; k++) {
+ for (int k = 1; k < ns; k++) {
if (bndv->ebev) {
get_profile_point(bp, &bndv->profile, k, ns, co);
copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co);
@@ -5701,9 +5557,9 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv)
/* Build the profile for the weld case (just a connection between the two boundverts). */
if (weld) {
bv->vmesh->mesh_kind = M_NONE;
- for (k = 1; k < ns; k++) {
- v_weld1 = mesh_vert(bv->vmesh, weld1->index, 0, k)->co;
- v_weld2 = mesh_vert(bv->vmesh, weld2->index, 0, ns - k)->co;
+ for (int k = 1; k < ns; k++) {
+ float *v_weld1 = mesh_vert(bv->vmesh, weld1->index, 0, k)->co;
+ float *v_weld2 = mesh_vert(bv->vmesh, weld2->index, 0, ns - k)->co;
if (bp->profile_type == BEVEL_PROFILE_CUSTOM) {
/* Don't bother with special case profile check from below. */
mid_v3_v3v3(co, v_weld1, v_weld2);
@@ -5724,13 +5580,13 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv)
copy_v3_v3(mesh_vert(bv->vmesh, weld1->index, 0, k)->co, co);
create_mesh_bmvert(bm, bv->vmesh, weld1->index, 0, k, bv->v);
}
- for (k = 1; k < ns; k++) {
+ for (int k = 1; k < ns; k++) {
copy_mesh_vert(bv->vmesh, weld2->index, 0, ns - k, weld1->index, 0, k);
}
}
/* Make sure the pipe case ADJ mesh is used for both the "Grid Fill" (ADJ) and cutoff options. */
- vpipe = NULL;
+ BoundVert *vpipe = NULL;
if ((vm->count == 3 || vm->count == 4) && bp->seg > 1) {
/* Result is passed to bevel_build_rings to avoid overhead. */
vpipe = pipe_test(bv);
@@ -5786,44 +5642,43 @@ static float edge_face_angle(EdgeHalf *e)
*/
static int bevel_edge_order_extend(BMesh *bm, BevVert *bv, int i)
{
- BMEdge *bme, *bme2, *nextbme;
- BMLoop *l;
- BMIter iter;
- int j, tryj, bestj, nsucs, sucindex, k;
BMEdge **sucs = NULL;
BMEdge **save_path = NULL;
BLI_array_staticdeclare(sucs, 4); /* Likely very few faces attached to same edge. */
BLI_array_staticdeclare(save_path, BM_DEFAULT_NGON_STACK_SIZE);
- bme = bv->edges[i].e;
/* Fill sucs with all unmarked edges of bmesh. */
+ BMEdge *bme = bv->edges[i].e;
+ BMIter iter;
+ BMLoop *l;
BM_ITER_ELEM (l, &iter, bme, BM_LOOPS_OF_EDGE) {
- bme2 = (l->v == bv->v) ? l->prev->e : l->next->e;
+ BMEdge *bme2 = (l->v == bv->v) ? l->prev->e : l->next->e;
if (!BM_BEVEL_EDGE_TAG_TEST(bme2)) {
BLI_array_append(sucs, bme2);
}
}
- nsucs = BLI_array_len(sucs);
+ int nsucs = BLI_array_len(sucs);
- bestj = j = i;
- for (sucindex = 0; sucindex < nsucs; sucindex++) {
- nextbme = sucs[sucindex];
+ int bestj = i;
+ int j = i;
+ for (int sucindex = 0; sucindex < nsucs; sucindex++) {
+ BMEdge *nextbme = sucs[sucindex];
BLI_assert(nextbme != NULL);
BLI_assert(!BM_BEVEL_EDGE_TAG_TEST(nextbme));
BLI_assert(j + 1 < bv->edgecount);
bv->edges[j + 1].e = nextbme;
BM_BEVEL_EDGE_TAG_ENABLE(nextbme);
- tryj = bevel_edge_order_extend(bm, bv, j + 1);
+ int tryj = bevel_edge_order_extend(bm, bv, j + 1);
if (tryj > bestj ||
(tryj == bestj && edges_face_connected_at_vert(bv->edges[tryj].e, bv->edges[0].e))) {
bestj = tryj;
BLI_array_clear(save_path);
- for (k = j + 1; k <= bestj; k++) {
+ for (int k = j + 1; k <= bestj; k++) {
BLI_array_append(save_path, bv->edges[k].e);
}
}
/* Now reset to path only-going-to-j state. */
- for (k = j + 1; k <= tryj; k++) {
+ for (int k = j + 1; k <= tryj; k++) {
BM_BEVEL_EDGE_TAG_DISABLE(bv->edges[k].e);
bv->edges[k].e = NULL;
}
@@ -5832,7 +5687,7 @@ static int bevel_edge_order_extend(BMesh *bm, BevVert *bv, int i)
if (bestj > j) {
/* Save_path should have from j + 1 to bestj inclusive.
* Edges to add to edges[] before returning. */
- for (k = j + 1; k <= bestj; k++) {
+ for (int k = j + 1; k <= bestj; k++) {
BLI_assert(save_path[k - (j + 1)] != NULL);
bv->edges[k].e = save_path[k - (j + 1)];
BM_BEVEL_EDGE_TAG_ENABLE(bv->edges[k].e);
@@ -5858,17 +5713,14 @@ static int bevel_edge_order_extend(BMesh *bm, BevVert *bv, int i)
* so for now will continue to use the legacy code. */
static bool fast_bevel_edge_order(BevVert *bv)
{
- int j, k, nsucs;
- BMEdge *bme, *bme2, *bmenext;
- BMIter iter;
- BMLoop *l;
-
- for (j = 1; j < bv->edgecount; j++) {
- bme = bv->edges[j - 1].e;
- bmenext = NULL;
- nsucs = 0;
+ for (int j = 1; j < bv->edgecount; j++) {
+ BMEdge *bme = bv->edges[j - 1].e;
+ BMEdge *bmenext = NULL;
+ int nsucs = 0;
+ BMIter iter;
+ BMLoop *l;
BM_ITER_ELEM (l, &iter, bme, BM_LOOPS_OF_EDGE) {
- bme2 = (l->v == bv->v) ? l->prev->e : l->next->e;
+ BMEdge *bme2 = (l->v == bv->v) ? l->prev->e : l->next->e;
if (!BM_BEVEL_EDGE_TAG_TEST(bme2)) {
nsucs++;
if (bmenext == NULL) {
@@ -5878,7 +5730,7 @@ static bool fast_bevel_edge_order(BevVert *bv)
}
if (nsucs == 0 || (nsucs == 2 && j != 1) || nsucs > 2 ||
(j == bv->edgecount - 1 && !edges_face_connected_at_vert(bmenext, bv->edges[0].e))) {
- for (k = 1; k < j; k++) {
+ for (int k = 1; k < j; k++) {
BM_BEVEL_EDGE_TAG_DISABLE(bv->edges[k].e);
bv->edges[k].e = NULL;
}
@@ -5892,29 +5744,29 @@ static bool fast_bevel_edge_order(BevVert *bv)
#else
static bool fast_bevel_edge_order(BevVert *bv)
{
- BMEdge *bme, *bme2, *first_suc;
- BMIter iter, iter2;
- BMFace *f;
- EdgeHalf *e;
- int i, k, ntot, num_shared_face;
-
- ntot = bv->edgecount;
+ int ntot = bv->edgecount;
/* Add edges to bv->edges in order that keeps adjacent edges sharing
* a unique face, if possible. */
- e = &bv->edges[0];
- bme = e->e;
+ EdgeHalf *e = &bv->edges[0];
+ BMEdge *bme = e->e;
if (!bme->l) {
return false;
}
- for (i = 1; i < ntot; i++) {
+
+ for (int i = 1; i < ntot; i++) {
/* Find an unflagged edge bme2 that shares a face f with previous bme. */
- num_shared_face = 0;
- first_suc = NULL; /* Keep track of first successor to match legacy behavior. */
+ int num_shared_face = 0;
+ BMEdge *first_suc = NULL; /* Keep track of first successor to match legacy behavior. */
+ BMIter iter;
+ BMEdge *bme2;
BM_ITER_ELEM (bme2, &iter, bv->v, BM_EDGES_OF_VERT) {
if (BM_BEVEL_EDGE_TAG_TEST(bme2)) {
continue;
}
+
+ BMIter iter2;
+ BMFace *f;
BM_ITER_ELEM (f, &iter2, bme2, BM_FACES_OF_EDGE) {
if (BM_face_edge_share_loop(f, bme)) {
num_shared_face++;
@@ -5933,7 +5785,7 @@ static bool fast_bevel_edge_order(BevVert *bv)
BM_BEVEL_EDGE_TAG_ENABLE(bme);
}
else {
- for (k = 1; k < i; k++) {
+ for (int k = 1; k < i; k++) {
BM_BEVEL_EDGE_TAG_DISABLE(bv->edges[k].e);
bv->edges[k].e = NULL;
}
@@ -5949,17 +5801,8 @@ static bool fast_bevel_edge_order(BevVert *bv)
* first_bme is a good edge to start with. */
static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme)
{
- BMEdge *bme, *bme2;
- BMIter iter;
- BMFace *f, *bestf;
- EdgeHalf *e;
- EdgeHalf *e2;
- BMLoop *l;
- int i, ntot;
-
- ntot = bv->edgecount;
- i = 0;
- for (;;) {
+ int ntot = bv->edgecount;
+ for (int i = 0;;) {
BLI_assert(first_bme != NULL);
bv->edges[i].e = first_bme;
BM_BEVEL_EDGE_TAG_ENABLE(first_bme);
@@ -5973,6 +5816,8 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme)
}
/* Not done yet: find a new first_bme. */
first_bme = NULL;
+ BMIter iter;
+ BMEdge *bme;
BM_ITER_ELEM (bme, &iter, bv->v, BM_EDGES_OF_VERT) {
if (BM_BEVEL_EDGE_TAG_TEST(bme)) {
continue;
@@ -5987,11 +5832,11 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme)
}
}
/* Now fill in the faces. */
- for (i = 0; i < ntot; i++) {
- e = &bv->edges[i];
- e2 = (i == bv->edgecount - 1) ? &bv->edges[0] : &bv->edges[i + 1];
- bme = e->e;
- bme2 = e2->e;
+ for (int i = 0; i < ntot; i++) {
+ EdgeHalf *e = &bv->edges[i];
+ EdgeHalf *e2 = (i == bv->edgecount - 1) ? &bv->edges[0] : &bv->edges[i + 1];
+ BMEdge *bme = e->e;
+ BMEdge *bme2 = e2->e;
BLI_assert(bme != NULL);
if (e->fnext != NULL || e2->fprev != NULL) {
continue;
@@ -5999,9 +5844,11 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme)
/* Which faces have successive loops that are for bme and bme2?
* There could be more than one. E.g., in manifold ntot==2 case.
* Prefer one that has loop in same direction as e. */
- bestf = NULL;
+ BMFace *bestf = NULL;
+ BMIter iter;
+ BMLoop *l;
BM_ITER_ELEM (l, &iter, bme, BM_LOOPS_OF_EDGE) {
- f = l->f;
+ BMFace *f = l->f;
if ((l->prev->e == bme2 || l->next->e == bme2)) {
if (!bestf || l->v == bv->v) {
bestf = f;
@@ -6017,19 +5864,6 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme)
/* Construction around the vertex. */
static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
{
- BMEdge *bme;
- BevVert *bv;
- BMEdge *first_bme;
- BMVert *v1, *v2;
- BMIter iter;
- EdgeHalf *e;
- float weight, z;
- float vert_axis[3] = {0, 0, 0};
- int i, ccw_test_sum;
- int nsel = 0;
- int tot_edges = 0;
- int tot_wire = 0;
-
/* Gather input selected edges.
* Only bevel selected edges that have exactly two incident faces.
* Want edges to be ordered so that they share faces.
@@ -6038,7 +5872,12 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
* Want to ignore wire edges completely for edge beveling.
* TODO: make following work when more than one gap. */
- first_bme = NULL;
+ int nsel = 0;
+ int tot_edges = 0;
+ int tot_wire = 0;
+ BMEdge *first_bme = NULL;
+ BMIter iter;
+ BMEdge *bme;
BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) {
int face_count = BM_edge_face_count(bme);
BM_BEVEL_EDGE_TAG_DISABLE(bme);
@@ -6076,15 +5915,15 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
return NULL;
}
- bv = (BevVert *)BLI_memarena_alloc(bp->mem_arena, (sizeof(BevVert)));
+ BevVert *bv = (BevVert *)BLI_memarena_alloc(bp->mem_arena, sizeof(BevVert));
bv->v = v;
bv->edgecount = tot_edges;
bv->selcount = nsel;
bv->wirecount = tot_wire;
bv->offset = bp->offset;
- bv->edges = (EdgeHalf *)BLI_memarena_alloc(bp->mem_arena, tot_edges * sizeof(EdgeHalf));
+ bv->edges = (EdgeHalf *)BLI_memarena_alloc(bp->mem_arena, sizeof(EdgeHalf) * tot_edges);
if (tot_wire) {
- bv->wire_edges = (BMEdge **)BLI_memarena_alloc(bp->mem_arena, tot_wire * sizeof(BMEdge *));
+ bv->wire_edges = (BMEdge **)BLI_memarena_alloc(bp->mem_arena, sizeof(BMEdge *) * tot_wire);
}
else {
bv->wire_edges = NULL;
@@ -6097,8 +5936,8 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
find_bevel_edge_order(bm, bv, first_bme);
/* Fill in other attributes of EdgeHalfs. */
- for (i = 0; i < tot_edges; i++) {
- e = &bv->edges[i];
+ for (int i = 0; i < tot_edges; i++) {
+ EdgeHalf *e = &bv->edges[i];
bme = e->e;
if (BM_elem_flag_test(bme, BM_ELEM_TAG) && bp->affect_type != BEVEL_AFFECT_VERTICES) {
e->is_bev = true;
@@ -6121,24 +5960,26 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
/* If edge array doesn't go CCW around vertex from average normal side,
* reverse the array, being careful to reverse face pointers too. */
if (tot_edges > 1) {
- ccw_test_sum = 0;
- for (i = 0; i < tot_edges; i++) {
+ int ccw_test_sum = 0;
+ for (int i = 0; i < tot_edges; i++) {
ccw_test_sum += bev_ccw_test(
bv->edges[i].e, bv->edges[(i + 1) % tot_edges].e, bv->edges[i].fnext);
}
if (ccw_test_sum < 0) {
- for (i = 0; i <= (tot_edges / 2) - 1; i++) {
+ for (int i = 0; i <= (tot_edges / 2) - 1; i++) {
SWAP(EdgeHalf, bv->edges[i], bv->edges[tot_edges - i - 1]);
SWAP(BMFace *, bv->edges[i].fprev, bv->edges[i].fnext);
SWAP(BMFace *, bv->edges[tot_edges - i - 1].fprev, bv->edges[tot_edges - i - 1].fnext);
}
if (tot_edges % 2 == 1) {
- i = tot_edges / 2;
+ int i = tot_edges / 2;
SWAP(BMFace *, bv->edges[i].fprev, bv->edges[i].fnext);
}
}
}
+ float weight;
+ float vert_axis[3] = {0, 0, 0};
if (bp->affect_type == BEVEL_AFFECT_VERTICES) {
/* Modify the offset by the vertex group or bevel weight if they are specified. */
if (bp->dvert != NULL && bp->vertex_group != -1) {
@@ -6152,8 +5993,9 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
/* Find center axis. Note: Don't use vert normal, can give unwanted results. */
if (ELEM(bp->offset_type, BEVEL_AMT_WIDTH, BEVEL_AMT_DEPTH)) {
float edge_dir[3];
- for (i = 0, e = bv->edges; i < tot_edges; i++, e++) {
- v2 = BM_edge_other_vert(e->e, bv->v);
+ EdgeHalf *e = bv->edges;
+ for (int i = 0; i < tot_edges; i++, e++) {
+ BMVert *v2 = BM_edge_other_vert(e->e, bv->v);
sub_v3_v3v3(edge_dir, bv->v->co, v2->co);
normalize_v3(edge_dir);
add_v3_v3v3(vert_axis, vert_axis, edge_dir);
@@ -6162,7 +6004,8 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
}
/* Set offsets for each beveled edge. */
- for (i = 0, e = bv->edges; i < tot_edges; i++, e++) {
+ EdgeHalf *e = bv->edges;
+ for (int i = 0; i < tot_edges; i++, e++) {
e->next = &bv->edges[(i + 1) % tot_edges];
e->prev = &bv->edges[(i + tot_edges - 1) % tot_edges];
@@ -6172,11 +6015,12 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
* Except for percent method, offset will be same on each side. */
switch (bp->offset_type) {
- case BEVEL_AMT_OFFSET:
+ case BEVEL_AMT_OFFSET: {
e->offset_l_spec = bp->offset;
break;
- case BEVEL_AMT_WIDTH:
- z = fabsf(2.0f * sinf(edge_face_angle(e) / 2.0f));
+ }
+ case BEVEL_AMT_WIDTH: {
+ float z = fabsf(2.0f * sinf(edge_face_angle(e) / 2.0f));
if (z < BEVEL_EPSILON) {
e->offset_l_spec = 0.01f * bp->offset; /* Undefined behavior, so tiny bevel. */
}
@@ -6184,8 +6028,9 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
e->offset_l_spec = bp->offset / z;
}
break;
- case BEVEL_AMT_DEPTH:
- z = fabsf(cosf(edge_face_angle(e) / 2.0f));
+ }
+ case BEVEL_AMT_DEPTH: {
+ float z = fabsf(cosf(edge_face_angle(e) / 2.0f));
if (z < BEVEL_EPSILON) {
e->offset_l_spec = 0.01f * bp->offset; /* Undefined behavior, so tiny bevel. */
}
@@ -6193,32 +6038,36 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
e->offset_l_spec = bp->offset / z;
}
break;
- case BEVEL_AMT_PERCENT:
+ }
+ case BEVEL_AMT_PERCENT: {
/* Offset needs to meet adjacent edges at percentage of their lengths. */
- v1 = BM_edge_other_vert(e->prev->e, v);
- v2 = BM_edge_other_vert(e->e, v);
- z = sinf(angle_v3v3v3(v1->co, v->co, v2->co));
+ BMVert *v1 = BM_edge_other_vert(e->prev->e, v);
+ BMVert *v2 = BM_edge_other_vert(e->e, v);
+ float z = sinf(angle_v3v3v3(v1->co, v->co, v2->co));
e->offset_l_spec = BM_edge_calc_length(e->prev->e) * bp->offset * z / 100.0f;
v1 = BM_edge_other_vert(e->e, v);
v2 = BM_edge_other_vert(e->next->e, v);
z = sinf(angle_v3v3v3(v1->co, v->co, v2->co));
e->offset_r_spec = BM_edge_calc_length(e->next->e) * bp->offset * z / 100.0f;
break;
- case BEVEL_AMT_ABSOLUTE:
+ }
+ case BEVEL_AMT_ABSOLUTE: {
/* Like Percent, but the amount gives the absolute distance along adjacent edges. */
- v1 = BM_edge_other_vert(e->prev->e, v);
- v2 = BM_edge_other_vert(e->e, v);
- z = sinf(angle_v3v3v3(v1->co, v->co, v2->co));
+ BMVert *v1 = BM_edge_other_vert(e->prev->e, v);
+ BMVert *v2 = BM_edge_other_vert(e->e, v);
+ float z = sinf(angle_v3v3v3(v1->co, v->co, v2->co));
e->offset_l_spec = bp->offset * z;
v1 = BM_edge_other_vert(e->e, v);
v2 = BM_edge_other_vert(e->next->e, v);
z = sinf(angle_v3v3v3(v1->co, v->co, v2->co));
e->offset_r_spec = bp->offset * z;
break;
- default:
+ }
+ default: {
BLI_assert(!"bad bevel offset kind");
e->offset_l_spec = bp->offset;
break;
+ }
}
if (bp->offset_type != BEVEL_AMT_PERCENT && bp->offset_type != BEVEL_AMT_ABSOLUTE) {
e->offset_r_spec = e->offset_l_spec;
@@ -6239,9 +6088,9 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
break;
}
case BEVEL_AMT_WIDTH: {
- v2 = BM_edge_other_vert(e->e, bv->v);
+ BMVert *v2 = BM_edge_other_vert(e->e, bv->v);
sub_v3_v3v3(edge_dir, bv->v->co, v2->co);
- z = fabsf(2.0f * sinf(angle_v3v3(vert_axis, edge_dir)));
+ float z = fabsf(2.0f * sinf(angle_v3v3(vert_axis, edge_dir)));
if (z < BEVEL_EPSILON) {
e->offset_l_spec = 0.01f * bp->offset; /* Undefined behavior, so tiny bevel. */
}
@@ -6251,9 +6100,9 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
break;
}
case BEVEL_AMT_DEPTH: {
- v2 = BM_edge_other_vert(e->e, bv->v);
+ BMVert *v2 = BM_edge_other_vert(e->e, bv->v);
sub_v3_v3v3(edge_dir, bv->v->co, v2->co);
- z = fabsf(cosf(angle_v3v3(vert_axis, edge_dir)));
+ float z = fabsf(cosf(angle_v3v3(vert_axis, edge_dir)));
if (z < BEVEL_EPSILON) {
e->offset_l_spec = 0.01f * bp->offset; /* Undefined behavior, so tiny bevel. */
}
@@ -6288,8 +6137,8 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
}
/* Collect wire edges if we found any earlier. */
- if (tot_wire) {
- i = 0;
+ if (tot_wire != 0) {
+ int i = 0;
BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) {
if (BM_edge_is_wire(bme)) {
BLI_assert(i < bv->wirecount);
@@ -6305,18 +6154,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
/* Face f has at least one beveled vertex. Rebuild f. */
static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
{
- BMIter liter, eiter, fiter;
- BMLoop *l, *lprev;
- BevVert *bv;
- BoundVert *v, *vstart, *vend;
- EdgeHalf *e, *eprev;
- VMesh *vm;
- int i, k, n, kstart, kend;
bool do_rebuild = false;
- bool go_ccw, corner3special, keep, on_profile_start;
- BMVert *bmv;
- BMEdge *bme, *bme_new, *bme_prev;
- BMFace *f_new, *f_other;
BMVert **vv = NULL;
BMVert **vv_fix = NULL;
BMEdge **ee = NULL;
@@ -6324,18 +6162,21 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
BLI_array_staticdeclare(vv_fix, BM_DEFAULT_NGON_STACK_SIZE);
BLI_array_staticdeclare(ee, BM_DEFAULT_NGON_STACK_SIZE);
+ BMIter liter;
+ BMLoop *l;
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
if (BM_elem_flag_test(l->v, BM_ELEM_TAG)) {
- lprev = l->prev;
- bv = find_bevvert(bp, l->v);
- vm = bv->vmesh;
- e = find_edge_half(bv, l->e);
+ BMLoop *lprev = l->prev;
+ BevVert *bv = find_bevvert(bp, l->v);
+ VMesh *vm = bv->vmesh;
+ EdgeHalf *e = find_edge_half(bv, l->e);
BLI_assert(e != NULL);
- bme = e->e;
- eprev = find_edge_half(bv, lprev->e);
+ BMEdge *bme = e->e;
+ EdgeHalf *eprev = find_edge_half(bv, lprev->e);
BLI_assert(eprev != NULL);
/* Which direction around our vertex do we travel to match orientation of f? */
+ bool go_ccw;
if (e->prev == eprev) {
if (eprev->prev == e) {
/* Valence 2 vertex: use f is one of e->fnext or e->fprev to break tie. */
@@ -6360,7 +6201,9 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
go_ccw = false;
}
}
- on_profile_start = false;
+ bool on_profile_start = false;
+ BoundVert *vstart;
+ BoundVert *vend;
if (go_ccw) {
vstart = eprev->rightv;
vend = e->leftv;
@@ -6378,16 +6221,17 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
}
}
BLI_assert(vstart != NULL && vend != NULL);
- v = vstart;
+ BoundVert *v = vstart;
if (!on_profile_start) {
BLI_array_append(vv, v->nv.v);
BLI_array_append(ee, bme);
}
while (v != vend) {
/* Check for special case: multisegment 3rd face opposite a beveled edge with no vmesh. */
- corner3special = (vm->mesh_kind == M_NONE && v->ebev != e && v->ebev != eprev);
+ bool corner3special = (vm->mesh_kind == M_NONE && v->ebev != e && v->ebev != eprev);
if (go_ccw) {
- i = v->index;
+ int i = v->index;
+ int kstart, kend;
if (on_profile_start) {
kstart = e->profile_index;
on_profile_start = false;
@@ -6401,8 +6245,8 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
else {
kend = vm->seg;
}
- for (k = kstart; k <= kend; k++) {
- bmv = mesh_vert(vm, i, 0, k)->v;
+ for (int k = kstart; k <= kend; k++) {
+ BMVert *bmv = mesh_vert(vm, i, 0, k)->v;
if (bmv) {
BLI_array_append(vv, bmv);
BLI_array_append(ee, bme); /* TODO: Maybe better edge here. */
@@ -6415,7 +6259,8 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
}
else {
/* Going cw. */
- i = v->prev->index;
+ int i = v->prev->index;
+ int kstart, kend;
if (on_profile_start) {
kstart = eprev->profile_index;
on_profile_start = false;
@@ -6429,8 +6274,8 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
else {
kend = 0;
}
- for (k = kstart; k >= kend; k--) {
- bmv = mesh_vert(vm, i, 0, k)->v;
+ for (int k = kstart; k >= kend; k--) {
+ BMVert *bmv = mesh_vert(vm, i, 0, k)->v;
if (bmv) {
BLI_array_append(vv, bmv);
BLI_array_append(ee, bme);
@@ -6450,18 +6295,18 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
}
}
if (do_rebuild) {
- n = BLI_array_len(vv);
- f_new = bev_create_ngon(bm, vv, n, NULL, f, NULL, -1, true);
+ int n = BLI_array_len(vv);
+ BMFace *f_new = bev_create_ngon(bm, vv, n, NULL, f, NULL, -1, true);
- for (k = 0; k < BLI_array_len(vv_fix); k++) {
+ for (int k = 0; k < BLI_array_len(vv_fix); k++) {
bev_merge_uvs(bm, vv_fix[k]);
}
/* Copy attributes from old edges. */
BLI_assert(n == BLI_array_len(ee));
- bme_prev = ee[n - 1];
- for (k = 0; k < n; k++) {
- bme_new = BM_edge_exists(vv[k], vv[(k + 1) % n]);
+ BMEdge *bme_prev = ee[n - 1];
+ for (int k = 0; k < n; k++) {
+ BMEdge *bme_new = BM_edge_exists(vv[k], vv[(k + 1) % n]);
BLI_assert(ee[k] && bme_new);
if (ee[k] != bme_new) {
BM_elem_attrs_copy(bm, bm, ee[k], bme_new);
@@ -6489,8 +6334,12 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
record_face_kind(bp, f_new, F_RECON);
BM_elem_flag_disable(f_new, BM_ELEM_TAG);
/* Also don't want new edges that aren't part of a new bevel face. */
+ BMIter eiter;
+ BMEdge *bme;
BM_ITER_ELEM (bme, &eiter, f_new, BM_EDGES_OF_FACE) {
- keep = false;
+ bool keep = false;
+ BMIter fiter;
+ BMFace *f_other;
BM_ITER_ELEM (f_other, &fiter, bme, BM_FACES_OF_EDGE) {
if (BM_elem_flag_test(f_other, BM_ELEM_TAG)) {
keep = true;
@@ -6535,38 +6384,31 @@ static void bevel_rebuild_existing_polygons(BMesh *bm, BevelParams *bp, BMVert *
/* If there were any wire edges, they need to be reattached somewhere. */
static void bevel_reattach_wires(BMesh *bm, BevelParams *bp, BMVert *v)
{
- BMEdge *e;
- BMVert *vclosest, *vother, *votherclosest;
- BevVert *bv, *bvother;
- BoundVert *bndv, *bndvother;
- float d, dclosest;
- int i;
-
- bv = find_bevvert(bp, v);
+ BevVert *bv = find_bevvert(bp, v);
if (!bv || bv->wirecount == 0 || !bv->vmesh) {
return;
}
- for (i = 0; i < bv->wirecount; i++) {
- e = bv->wire_edges[i];
+ for (int i = 0; i < bv->wirecount; i++) {
+ BMEdge *e = bv->wire_edges[i];
/* Look for the new vertex closest to the other end of e. */
- vclosest = NULL;
- dclosest = FLT_MAX;
- votherclosest = NULL;
- vother = BM_edge_other_vert(e, v);
- bvother = NULL;
+ BMVert *vclosest = NULL;
+ float dclosest = FLT_MAX;
+ BMVert *votherclosest = NULL;
+ BMVert *vother = BM_edge_other_vert(e, v);
+ BevVert *bvother = NULL;
if (BM_elem_flag_test(vother, BM_ELEM_TAG)) {
bvother = find_bevvert(bp, vother);
if (!bvother || !bvother->vmesh) {
return; /* Shouldn't happen. */
}
}
- bndv = bv->vmesh->boundstart;
+ BoundVert *bndv = bv->vmesh->boundstart;
do {
if (bvother) {
- bndvother = bvother->vmesh->boundstart;
+ BoundVert *bndvother = bvother->vmesh->boundstart;
do {
- d = len_squared_v3v3(bndvother->nv.co, bndv->nv.co);
+ float d = len_squared_v3v3(bndvother->nv.co, bndv->nv.co);
if (d < dclosest) {
vclosest = bndv->nv.v;
votherclosest = bndvother->nv.v;
@@ -6575,7 +6417,7 @@ static void bevel_reattach_wires(BMesh *bm, BevelParams *bp, BMVert *v)
} while ((bndvother = bndvother->next) != bvother->vmesh->boundstart);
}
else {
- d = len_squared_v3v3(vother->co, bndv->nv.co);
+ float d = len_squared_v3v3(vother->co, bndv->nv.co);
if (d < dclosest) {
vclosest = bndv->nv.v;
votherclosest = vother;
@@ -6592,11 +6434,10 @@ static void bevel_reattach_wires(BMesh *bm, BevelParams *bp, BMVert *v)
static void bev_merge_end_uvs(BMesh *bm, BevVert *bv, EdgeHalf *e)
{
VMesh *vm = bv->vmesh;
- int i, k, nseg;
- nseg = e->seg;
- i = e->leftv->index;
- for (k = 1; k < nseg; k++) {
+ int nseg = e->seg;
+ int i = e->leftv->index;
+ for (int k = 1; k < nseg; k++) {
bev_merge_uvs(bm, mesh_vert(vm, i, 0, k)->v);
}
}
@@ -6633,12 +6474,9 @@ static bool bevvert_is_weld_cross(BevVert *bv)
*/
static void weld_cross_attrs_copy(BMesh *bm, BevVert *bv, VMesh *vm, int vmindex, EdgeHalf *e)
{
- BMEdge *bme_prev, *bme_next, *bme;
- int i, nseg;
- bool disable_seam, enable_smooth;
-
- bme_prev = bme_next = NULL;
- for (i = 0; i < 4; i++) {
+ BMEdge *bme_prev = NULL;
+ BMEdge *bme_next = NULL;
+ for (int i = 0; i < 4; i++) {
if (&bv->edges[i] == e) {
bme_prev = bv->edges[(i + 3) % 4].e;
bme_next = bv->edges[(i + 1) % 4].e;
@@ -6648,14 +6486,15 @@ static void weld_cross_attrs_copy(BMesh *bm, BevVert *bv, VMesh *vm, int vmindex
BLI_assert(bme_prev && bme_next);
/* Want seams and sharp edges to cross only if that way on both sides. */
- disable_seam = BM_elem_flag_test(bme_prev, BM_ELEM_SEAM) !=
- BM_elem_flag_test(bme_next, BM_ELEM_SEAM);
- enable_smooth = BM_elem_flag_test(bme_prev, BM_ELEM_SMOOTH) !=
- BM_elem_flag_test(bme_next, BM_ELEM_SMOOTH);
-
- nseg = e->seg;
- for (i = 0; i < nseg; i++) {
- bme = BM_edge_exists(mesh_vert(vm, vmindex, 0, i)->v, mesh_vert(vm, vmindex, 0, i + 1)->v);
+ bool disable_seam = BM_elem_flag_test(bme_prev, BM_ELEM_SEAM) !=
+ BM_elem_flag_test(bme_next, BM_ELEM_SEAM);
+ bool enable_smooth = BM_elem_flag_test(bme_prev, BM_ELEM_SMOOTH) !=
+ BM_elem_flag_test(bme_next, BM_ELEM_SMOOTH);
+
+ int nseg = e->seg;
+ for (int i = 0; i < nseg; i++) {
+ BMEdge *bme = BM_edge_exists(mesh_vert(vm, vmindex, 0, i)->v,
+ mesh_vert(vm, vmindex, 0, i + 1)->v);
BLI_assert(bme);
BM_elem_attrs_copy(bm, bm, bme_prev, bme);
if (disable_seam) {
@@ -6672,31 +6511,19 @@ static void weld_cross_attrs_copy(BMesh *bm, BevVert *bv, VMesh *vm, int vmindex
*/
static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme)
{
- BevVert *bv1, *bv2;
- BMVert *bmv1, *bmv2, *bmv3, *bmv4;
- VMesh *vm1, *vm2;
- EdgeHalf *e1, *e2;
- BMEdge *bme1, *bme2, *center_bme;
- BMFace *f1, *f2, *f, *r_f, *f_choice;
- BMVert *verts[4];
- BMFace *faces[4];
- BMEdge *edges[4];
- BMLoop *l;
- BMIter iter;
- int k, nseg, i1, i2, odd, mid;
int mat_nr = bp->mat_nr;
if (!BM_edge_is_manifold(bme)) {
return;
}
- bv1 = find_bevvert(bp, bme->v1);
- bv2 = find_bevvert(bp, bme->v2);
+ BevVert *bv1 = find_bevvert(bp, bme->v1);
+ BevVert *bv2 = find_bevvert(bp, bme->v2);
BLI_assert(bv1 && bv2);
- e1 = find_edge_half(bv1, bme);
- e2 = find_edge_half(bv2, bme);
+ EdgeHalf *e1 = find_edge_half(bv1, bme);
+ EdgeHalf *e2 = find_edge_half(bv2, bme);
BLI_assert(e1 && e2);
@@ -6710,40 +6537,43 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme)
* \ | /
* bme->v2
*/
- nseg = e1->seg;
+ int nseg = e1->seg;
BLI_assert(nseg > 0 && nseg == e2->seg);
- bmv1 = e1->leftv->nv.v;
- bmv4 = e1->rightv->nv.v;
- bmv2 = e2->rightv->nv.v;
- bmv3 = e2->leftv->nv.v;
+ BMVert *bmv1 = e1->leftv->nv.v;
+ BMVert *bmv4 = e1->rightv->nv.v;
+ BMVert *bmv2 = e2->rightv->nv.v;
+ BMVert *bmv3 = e2->leftv->nv.v;
BLI_assert(bmv1 && bmv2 && bmv3 && bmv4);
- f1 = e1->fprev;
- f2 = e1->fnext;
- faces[0] = faces[1] = f1;
- faces[2] = faces[3] = f2;
- i1 = e1->leftv->index;
- i2 = e2->leftv->index;
- vm1 = bv1->vmesh;
- vm2 = bv2->vmesh;
+ BMFace *f1 = e1->fprev;
+ BMFace *f2 = e1->fnext;
+ BMFace *faces[4] = {f1, f1, f2, f2};
+
+ int i1 = e1->leftv->index;
+ int i2 = e2->leftv->index;
+ VMesh *vm1 = bv1->vmesh;
+ VMesh *vm2 = bv2->vmesh;
+ BMVert *verts[4];
verts[0] = bmv1;
verts[1] = bmv2;
- odd = nseg % 2;
- mid = nseg / 2;
- center_bme = NULL;
- for (k = 1; k <= nseg; k++) {
+ int odd = nseg % 2;
+ int mid = nseg / 2;
+ BMEdge *center_bme = NULL;
+ for (int k = 1; k <= nseg; k++) {
verts[3] = mesh_vert(vm1, i1, 0, k)->v;
verts[2] = mesh_vert(vm2, i2, 0, nseg - k)->v;
+ BMFace *r_f;
if (odd && k == mid + 1) {
BMFace *fchoices[2] = {f1, f2};
- f_choice = choose_rep_face(bp, fchoices, 2);
+ BMFace *f_choice = choose_rep_face(bp, fchoices, 2);
if (e1->is_seam) {
/* Straddles a seam: choose to interpolate in f_choice and snap the loops whose verts
* are in the non-chosen face to bme for interpolation purposes.
*/
+ BMEdge *edges[4];
if (f_choice == f1) {
edges[0] = edges[1] = NULL;
edges[2] = edges[3] = bme;
@@ -6761,25 +6591,25 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme)
}
else if (!odd && k == mid) {
/* Left poly that touches an even center line on right. */
- edges[0] = edges[1] = NULL;
- edges[2] = edges[3] = bme;
+ BMEdge *edges[4] = {NULL, NULL, bme, bme};
r_f = bev_create_ngon(bm, verts, 4, NULL, f1, edges, mat_nr, true);
center_bme = BM_edge_exists(verts[2], verts[3]);
BLI_assert(center_bme != NULL);
}
else if (!odd && k == mid + 1) {
/* Right poly that touches an even center line on left. */
- edges[0] = edges[1] = bme;
- edges[2] = edges[3] = NULL;
+ BMEdge *edges[4] = {bme, bme, NULL, NULL};
r_f = bev_create_ngon(bm, verts, 4, NULL, f2, edges, mat_nr, true);
}
else {
/* Doesn't cross or touch the center line, so interpolate in appropriate f1 or f2. */
- f = (k <= mid) ? f1 : f2;
+ BMFace *f = (k <= mid) ? f1 : f2;
r_f = bev_create_ngon(bm, verts, 4, NULL, f, NULL, mat_nr, true);
}
record_face_kind(bp, r_f, F_EDGE);
/* Tag the long edges: those out of verts[0] and verts[2]. */
+ BMIter iter;
+ BMLoop *l;
BM_ITER_ELEM (l, &iter, r_f, BM_LOOPS_OF_FACE) {
if (l->v == verts[0] || l->v == verts[2]) {
BM_elem_flag_enable(l, BM_ELEM_LONG_TAG);
@@ -6807,8 +6637,8 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme)
}
/* Copy edge data to first and last edge. */
- bme1 = BM_edge_exists(bmv1, bmv2);
- bme2 = BM_edge_exists(bmv3, bmv4);
+ BMEdge *bme1 = BM_edge_exists(bmv1, bmv2);
+ BMEdge *bme2 = BM_edge_exists(bmv3, bmv4);
BLI_assert(bme1 && bme2);
BM_elem_attrs_copy(bm, bm, bme, bme1);
BM_elem_attrs_copy(bm, bm, bme, bme2);
@@ -6828,34 +6658,32 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme)
* Assumes that the gradient is always between 1 and -1 for x in [x0, x0+dtarget]. */
static double find_superellipse_chord_endpoint(double x0, double dtarget, float r, bool rbig)
{
- double xmin, xmax, ymin, ymax, dmaxerr, dminerr, dnewerr, xnew, ynew;
double y0 = superellipse_co(x0, r, rbig);
const double tol = 1e-13; /* accumulates for many segments so use low value. */
const int maxiter = 10;
- bool lastupdated_upper;
/* For gradient between -1 and 1, xnew can only be in [x0 + sqrt(2)/2*dtarget, x0 + dtarget]. */
- xmin = x0 + M_SQRT2 / 2.0 * dtarget;
+ double xmin = x0 + M_SQRT2 / 2.0 * dtarget;
if (xmin > 1.0) {
xmin = 1.0;
}
- xmax = x0 + dtarget;
+ double xmax = x0 + dtarget;
if (xmax > 1.0) {
xmax = 1.0;
}
- ymin = superellipse_co(xmin, r, rbig);
- ymax = superellipse_co(xmax, r, rbig);
+ double ymin = superellipse_co(xmin, r, rbig);
+ double ymax = superellipse_co(xmax, r, rbig);
/* Note: using distance**2 (no sqrt needed) does not converge that well. */
- dmaxerr = sqrt(pow((xmax - x0), 2) + pow((ymax - y0), 2)) - dtarget;
- dminerr = sqrt(pow((xmin - x0), 2) + pow((ymin - y0), 2)) - dtarget;
+ double dmaxerr = sqrt(pow((xmax - x0), 2) + pow((ymax - y0), 2)) - dtarget;
+ double dminerr = sqrt(pow((xmin - x0), 2) + pow((ymin - y0), 2)) - dtarget;
- xnew = xmax - dmaxerr * (xmax - xmin) / (dmaxerr - dminerr);
- lastupdated_upper = true;
+ double xnew = xmax - dmaxerr * (xmax - xmin) / (dmaxerr - dminerr);
+ bool lastupdated_upper = true;
for (int iter = 0; iter < maxiter; iter++) {
- ynew = superellipse_co(xnew, r, rbig);
- dnewerr = sqrt(pow((xnew - x0), 2) + pow((ynew - y0), 2)) - dtarget;
+ double ynew = superellipse_co(xnew, r, rbig);
+ double dnewerr = sqrt(pow((xnew - x0), 2) + pow((ynew - y0), 2)) - dtarget;
if (fabs(dnewerr) < tol) {
break;
}
@@ -6900,19 +6728,12 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval
{
const int smoothitermax = 10;
const double error_tol = 1e-7;
- int i;
int imax = (seg + 1) / 2 - 1; /* Ceiling division - 1. */
- double d, dmin, dmax;
- double davg;
- double mx;
- double sum;
- double temp;
-
- bool precision_reached = true;
bool seg_odd = seg % 2;
- bool rbig;
+ bool rbig;
+ double mx;
if (r > 1.0f) {
rbig = true;
mx = pow(0.5, 1.0 / r);
@@ -6923,7 +6744,7 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval
}
/* Initial positions, linear spacing along x axis. */
- for (i = 0; i <= imax; i++) {
+ for (int i = 0; i <= imax; i++) {
xvals[i] = i * mx / seg * 2;
yvals[i] = superellipse_co(xvals[i], r, rbig);
}
@@ -6931,14 +6752,14 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval
/* Smooth distance loop. */
for (int iter = 0; iter < smoothitermax; iter++) {
- sum = 0.0;
- dmin = 2.0;
- dmax = 0.0;
+ double sum = 0.0;
+ double dmin = 2.0;
+ double dmax = 0.0;
/* Update distances between neighbor points. Store the highest and
* lowest to see if the maximum error to average distance (which isn't
* known yet) is below required precision. */
- for (i = 0; i < imax; i++) {
- d = sqrt(pow((xvals[i + 1] - xvals[i]), 2) + pow((yvals[i + 1] - yvals[i]), 2));
+ for (int i = 0; i < imax; i++) {
+ double d = sqrt(pow((xvals[i + 1] - xvals[i]), 2) + pow((yvals[i + 1] - yvals[i]), 2));
sum += d;
if (d > dmax) {
dmax = d;
@@ -6948,6 +6769,7 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval
}
}
/* For last distance, weight with 1/2 if seg_odd. */
+ double davg;
if (seg_odd) {
sum += M_SQRT2 / 2 * (yvals[imax] - xvals[imax]);
davg = sum / (imax + 0.5);
@@ -6957,6 +6779,7 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval
davg = sum / (imax + 1.0);
}
/* Max error in tolerance? -> Quit. */
+ bool precision_reached = true;
if (dmax - davg > error_tol) {
precision_reached = false;
}
@@ -6968,7 +6791,7 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval
}
/* Update new coordinates. */
- for (i = 1; i <= imax; i++) {
+ for (int i = 1; i <= imax; i++) {
xvals[i] = find_superellipse_chord_endpoint(xvals[i - 1], davg, r, rbig);
yvals[i] = superellipse_co(xvals[i], r, rbig);
}
@@ -6979,14 +6802,14 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval
xvals[imax + 1] = mx;
yvals[imax + 1] = mx;
}
- for (i = imax + 1; i <= seg; i++) {
+ for (int i = imax + 1; i <= seg; i++) {
yvals[i] = xvals[seg - i];
xvals[i] = yvals[seg - i];
}
if (!rbig) {
- for (i = 0; i <= seg; i++) {
- temp = xvals[i];
+ for (int i = 0; i <= seg; i++) {
+ double temp = xvals[i];
xvals[i] = 1.0 - yvals[i];
yvals[i] = 1.0 - temp;
}
@@ -7003,25 +6826,22 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval
*/
static void find_even_superellipse_chords(int n, float r, double *xvals, double *yvals)
{
- int i, n2;
- double temp;
bool seg_odd = n % 2;
-
- n2 = n / 2;
+ int n2 = n / 2;
/* Special cases. */
if (r == PRO_LINE_R) {
/* Linear spacing. */
- for (i = 0; i <= n; i++) {
+ for (int i = 0; i <= n; i++) {
xvals[i] = (double)i / n;
yvals[i] = 1.0 - (double)i / n;
}
return;
}
if (r == PRO_CIRCLE_R) {
- temp = (M_PI / 2) / n;
+ double temp = (M_PI / 2) / n;
/* Angle spacing. */
- for (i = 0; i <= n; i++) {
+ for (int i = 0; i <= n; i++) {
xvals[i] = sin(i * temp);
yvals[i] = cos(i * temp);
}
@@ -7030,7 +6850,7 @@ static void find_even_superellipse_chords(int n, float r, double *xvals, double
if (r == PRO_SQUARE_IN_R) {
/* n is even, distribute first and second half linear. */
if (!seg_odd) {
- for (i = 0; i <= n2; i++) {
+ for (int i = 0; i <= n2; i++) {
xvals[i] = 0.0;
yvals[i] = 1.0 - (double)i / n2;
xvals[n - i] = yvals[i];
@@ -7039,8 +6859,8 @@ static void find_even_superellipse_chords(int n, float r, double *xvals, double
}
/* n is odd, so get one corner-cut chord. */
else {
- temp = 1.0 / (n2 + M_SQRT2 / 2.0);
- for (i = 0; i <= n2; i++) {
+ double temp = 1.0 / (n2 + M_SQRT2 / 2.0);
+ for (int i = 0; i <= n2; i++) {
xvals[i] = 0.0;
yvals[i] = 1.0 - (double)i * temp;
xvals[n - i] = yvals[i];
@@ -7052,7 +6872,7 @@ static void find_even_superellipse_chords(int n, float r, double *xvals, double
if (r == PRO_SQUARE_R) {
/* n is even, distribute first and second half linear. */
if (!seg_odd) {
- for (i = 0; i <= n2; i++) {
+ for (int i = 0; i <= n2; i++) {
xvals[i] = (double)i / n2;
yvals[i] = 1.0;
xvals[n - i] = yvals[i];
@@ -7061,8 +6881,8 @@ static void find_even_superellipse_chords(int n, float r, double *xvals, double
}
/* n is odd, so get one corner-cut chord. */
else {
- temp = 1.0 / (n2 + M_SQRT2 / 2);
- for (i = 0; i <= n2; i++) {
+ double temp = 1.0 / (n2 + M_SQRT2 / 2);
+ for (int i = 0; i <= n2; i++) {
xvals[i] = (double)i * temp;
yvals[i] = 1.0;
xvals[n - i] = yvals[i];
@@ -7082,7 +6902,6 @@ static void find_even_superellipse_chords(int n, float r, double *xvals, double
*/
static float find_profile_fullness(BevelParams *bp)
{
- float fullness;
int nseg = bp->seg;
/* Precalculated fullness for circle profile radius and more common low seg values. */
@@ -7101,6 +6920,7 @@ static float find_profile_fullness(BevelParams *bp)
0.647f, /* 11 */
};
+ float fullness;
if (bp->profile_type == BEVEL_PROFILE_CUSTOM) {
/* Set fullness to the average "height" of the profile's sampled points. */
fullness = 0.0f;
@@ -7143,68 +6963,64 @@ static float find_profile_fullness(BevelParams *bp)
*/
static void set_profile_spacing(BevelParams *bp, ProfileSpacing *pro_spacing, bool custom)
{
- int seg, seg_2;
-
- seg = bp->seg;
- seg_2 = power_of_2_max_i(bp->seg);
- if (seg > 1) {
- /* Sample the input number of segments. */
- pro_spacing->xvals = (double *)BLI_memarena_alloc(bp->mem_arena,
- (size_t)(seg + 1) * sizeof(double));
- pro_spacing->yvals = (double *)BLI_memarena_alloc(bp->mem_arena,
- (size_t)(seg + 1) * sizeof(double));
+ int seg = bp->seg;
+
+ if (seg <= 1) {
+ /* Only 1 segment, we don't need any profile information. */
+ pro_spacing->xvals = NULL;
+ pro_spacing->yvals = NULL;
+ pro_spacing->xvals_2 = NULL;
+ pro_spacing->yvals_2 = NULL;
+ pro_spacing->seg_2 = 0;
+ return;
+ }
+
+ int seg_2 = max_ii(power_of_2_max_i(bp->seg), 4);
+
+ /* Sample the seg_2 segments used during vertex mesh subdivision. */
+ bp->pro_spacing.seg_2 = seg_2;
+ if (seg_2 == seg) {
+ pro_spacing->xvals_2 = pro_spacing->xvals;
+ pro_spacing->yvals_2 = pro_spacing->yvals;
+ }
+ else {
+ pro_spacing->xvals_2 = (double *)BLI_memarena_alloc(bp->mem_arena,
+ sizeof(double) * (seg_2 + 1));
+ pro_spacing->yvals_2 = (double *)BLI_memarena_alloc(bp->mem_arena,
+ sizeof(double) * (seg_2 + 1));
if (custom) {
- /* Make sure the curve profile's sample table is full. */
- if (bp->custom_profile->segments_len != seg || !bp->custom_profile->segments) {
- BKE_curveprofile_initialize((CurveProfile *)bp->custom_profile, (short)seg);
- }
+ /* Make sure the curve profile widget's sample table is full of the seg_2 samples. */
+ BKE_curveprofile_init((CurveProfile *)bp->custom_profile, (short)seg_2);
/* Copy segment locations into the profile spacing struct. */
- for (int i = 0; i < seg + 1; i++) {
- pro_spacing->xvals[i] = (double)bp->custom_profile->segments[i].y;
- pro_spacing->yvals[i] = (double)bp->custom_profile->segments[i].x;
+ for (int i = 0; i < seg_2 + 1; i++) {
+ pro_spacing->xvals_2[i] = (double)bp->custom_profile->segments[i].y;
+ pro_spacing->yvals_2[i] = (double)bp->custom_profile->segments[i].x;
}
}
else {
- find_even_superellipse_chords(seg, bp->pro_super_r, pro_spacing->xvals, pro_spacing->yvals);
+ find_even_superellipse_chords(
+ seg_2, bp->pro_super_r, pro_spacing->xvals_2, pro_spacing->yvals_2);
}
+ }
- /* Sample the seg_2 segments used for subdividing the vertex meshes. */
- if (seg_2 == 2) {
- seg_2 = 4;
- }
- bp->pro_spacing.seg_2 = seg_2;
- if (seg_2 == seg) {
- pro_spacing->xvals_2 = pro_spacing->xvals;
- pro_spacing->yvals_2 = pro_spacing->yvals;
+ /* Sample the input number of segments. */
+ pro_spacing->xvals = (double *)BLI_memarena_alloc(bp->mem_arena, sizeof(double) * (seg + 1));
+ pro_spacing->yvals = (double *)BLI_memarena_alloc(bp->mem_arena, sizeof(double) * (seg + 1));
+ if (custom) {
+ /* Make sure the curve profile's sample table is full. */
+ if (bp->custom_profile->segments_len != seg || !bp->custom_profile->segments) {
+ BKE_curveprofile_init((CurveProfile *)bp->custom_profile, (short)seg);
}
- else {
- pro_spacing->xvals_2 = (double *)BLI_memarena_alloc(bp->mem_arena,
- (size_t)(seg_2 + 1) * sizeof(double));
- pro_spacing->yvals_2 = (double *)BLI_memarena_alloc(bp->mem_arena,
- (size_t)(seg_2 + 1) * sizeof(double));
- if (custom) {
- /* Make sure the curve profile widget's sample table is full of the seg_2 samples. */
- BKE_curveprofile_initialize((CurveProfile *)bp->custom_profile, (short)seg_2);
-
- /* Copy segment locations into the profile spacing struct. */
- for (int i = 0; i < seg_2 + 1; i++) {
- pro_spacing->xvals_2[i] = (double)bp->custom_profile->segments[i].y;
- pro_spacing->yvals_2[i] = (double)bp->custom_profile->segments[i].x;
- }
- }
- else {
- find_even_superellipse_chords(
- seg_2, bp->pro_super_r, pro_spacing->xvals_2, pro_spacing->yvals_2);
- }
+
+ /* Copy segment locations into the profile spacing struct. */
+ for (int i = 0; i < seg + 1; i++) {
+ pro_spacing->xvals[i] = (double)bp->custom_profile->segments[i].y;
+ pro_spacing->yvals[i] = (double)bp->custom_profile->segments[i].x;
}
}
- else { /* Only 1 segment, we don't need any profile information. */
- pro_spacing->xvals = NULL;
- pro_spacing->yvals = NULL;
- pro_spacing->xvals_2 = NULL;
- pro_spacing->yvals_2 = NULL;
- pro_spacing->seg_2 = 0;
+ else {
+ find_even_superellipse_chords(seg, bp->pro_super_r, pro_spacing->xvals, pro_spacing->yvals);
}
}
@@ -7233,19 +7049,15 @@ static void set_profile_spacing(BevelParams *bp, ProfileSpacing *pro_spacing, bo
*/
static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
{
- EdgeHalf *ea, *ec, *ebother;
- BevVert *bvc;
- BMLoop *lb;
- BMVert *va, *vb, *vc, *vd;
- float ka, kb, kc, g, h, t, den, no_collide_offset, th1, th2, sin1, sin2, tan1, tan2, limit;
-
- limit = no_collide_offset = bp->offset + 1e6;
+ float no_collide_offset = bp->offset + 1e6;
+ float limit = no_collide_offset;
if (bp->offset == 0.0f) {
return no_collide_offset;
}
- kb = eb->offset_l_spec;
- ea = eb->next; /* Note: this is in direction b --> a. */
- ka = ea->offset_r_spec;
+ float kb = eb->offset_l_spec;
+ EdgeHalf *ea = eb->next; /* Note: this is in direction b --> a. */
+ float ka = ea->offset_r_spec;
+ BMVert *vb, *vc;
if (eb->is_rev) {
vc = eb->e->v1;
vb = eb->e->v2;
@@ -7254,9 +7066,12 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
vb = eb->e->v1;
vc = eb->e->v2;
}
- va = ea->is_rev ? ea->e->v1 : ea->e->v2;
- bvc = NULL;
- ebother = find_other_end_edge_half(bp, eb, &bvc);
+ BMVert *va = ea->is_rev ? ea->e->v1 : ea->e->v2;
+ BevVert *bvc = NULL;
+ EdgeHalf *ebother = find_other_end_edge_half(bp, eb, &bvc);
+ EdgeHalf *ec;
+ BMVert *vd;
+ float kc;
if (ebother != NULL) {
ec = ebother->prev; /* Note: this is in direction c --> d. */
vc = bvc->v;
@@ -7268,7 +7083,7 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
kc = 0.0f;
ec = NULL;
/* Find an edge from c that has same face. */
- lb = BM_face_edge_share_loop(eb->fnext, eb->e);
+ BMLoop *lb = BM_face_edge_share_loop(eb->fnext, eb->e);
if (!lb) {
return no_collide_offset;
}
@@ -7288,22 +7103,22 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
ka = ka / bp->offset;
kb = kb / bp->offset;
kc = kc / bp->offset;
- th1 = angle_v3v3v3(va->co, vb->co, vc->co);
- th2 = angle_v3v3v3(vb->co, vc->co, vd->co);
+ float th1 = angle_v3v3v3(va->co, vb->co, vc->co);
+ float th2 = angle_v3v3v3(vb->co, vc->co, vd->co);
/* First calculate offset at which edge B collapses, which happens
* when advancing clones of A, B, C all meet at a point.
* This only happens if at least two of those three edges have non-zero k's. */
- sin1 = sinf(th1);
- sin2 = sinf(th2);
+ float sin1 = sinf(th1);
+ float sin2 = sinf(th2);
if ((ka > 0.0f) + (kb > 0.0f) + (kc > 0.0f) >= 2) {
- tan1 = tanf(th1);
- tan2 = tanf(th2);
- g = tan1 * tan2;
- h = sin1 * sin2;
- den = g * (ka * sin2 + kc * sin1) + kb * h * (tan1 + tan2);
+ float tan1 = tanf(th1);
+ float tan2 = tanf(th2);
+ float g = tan1 * tan2;
+ float h = sin1 * sin2;
+ float den = g * (ka * sin2 + kc * sin1) + kb * h * (tan1 + tan2);
if (den != 0.0f) {
- t = BM_edge_calc_length(eb->e);
+ float t = BM_edge_calc_length(eb->e);
t *= g * h / den;
if (t >= 0.0f) {
limit = t;
@@ -7313,14 +7128,14 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
/* Now check edge slide cases. */
if (kb > 0.0f && ka == 0.0f /*&& bvb->selcount == 1 && bvb->edgecount > 2 */) {
- t = BM_edge_calc_length(ea->e);
+ float t = BM_edge_calc_length(ea->e);
t *= sin1 / kb;
if (t >= 0.0f && t < limit) {
limit = t;
}
}
if (kb > 0.0f && kc == 0.0f /* && bvc && ec && bvc->selcount == 1 && bvc->edgecount > 2 */) {
- t = BM_edge_calc_length(ec->e);
+ float t = BM_edge_calc_length(ec->e);
t *= sin2 / kb;
if (t >= 0.0f && t < limit) {
limit = t;
@@ -7336,18 +7151,16 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
*/
static float vertex_collide_offset(BevelParams *bp, EdgeHalf *ea)
{
- float limit, ka, kb, no_collide_offset, la, kab;
- EdgeHalf *eb;
-
- limit = no_collide_offset = bp->offset + 1e6;
+ float no_collide_offset = bp->offset + 1e6;
+ float limit = no_collide_offset;
if (bp->offset == 0.0f) {
return no_collide_offset;
}
- ka = ea->offset_l_spec / bp->offset;
- eb = find_other_end_edge_half(bp, ea, NULL);
- kb = eb ? eb->offset_l_spec / bp->offset : 0.0f;
- kab = ka + kb;
- la = BM_edge_calc_length(ea->e);
+ float ka = ea->offset_l_spec / bp->offset;
+ EdgeHalf *eb = find_other_end_edge_half(bp, ea, NULL);
+ float kb = eb ? eb->offset_l_spec / bp->offset : 0.0f;
+ float kab = ka + kb;
+ float la = BM_edge_calc_length(ea->e);
if (kab <= 0.0f) {
return no_collide_offset;
}
@@ -7362,32 +7175,27 @@ static float vertex_collide_offset(BevelParams *bp, EdgeHalf *ea)
*/
static void bevel_limit_offset(BevelParams *bp, BMesh *bm)
{
- BevVert *bv;
- EdgeHalf *eh;
+ float limited_offset = bp->offset;
BMIter iter;
BMVert *bmv;
- float limited_offset, offset_factor, collision_offset;
- int i;
-
- limited_offset = bp->offset;
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
continue;
}
- bv = find_bevvert(bp, bmv);
+ BevVert *bv = find_bevvert(bp, bmv);
if (!bv) {
continue;
}
- for (i = 0; i < bv->edgecount; i++) {
- eh = &bv->edges[i];
+ for (int i = 0; i < bv->edgecount; i++) {
+ EdgeHalf *eh = &bv->edges[i];
if (bp->affect_type == BEVEL_AFFECT_VERTICES) {
- collision_offset = vertex_collide_offset(bp, eh);
+ float collision_offset = vertex_collide_offset(bp, eh);
if (collision_offset < limited_offset) {
limited_offset = collision_offset;
}
}
else {
- collision_offset = geometry_collide_offset(bp, eh);
+ float collision_offset = geometry_collide_offset(bp, eh);
if (collision_offset < limited_offset) {
limited_offset = collision_offset;
}
@@ -7401,17 +7209,17 @@ static void bevel_limit_offset(BevelParams *bp, BMesh *bm)
* of the offset to have the effect of recalculating the specs
* with the new limited_offset.
*/
- offset_factor = limited_offset / bp->offset;
+ float offset_factor = limited_offset / bp->offset;
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
continue;
}
- bv = find_bevvert(bp, bmv);
+ BevVert *bv = find_bevvert(bp, bmv);
if (!bv) {
continue;
}
- for (i = 0; i < bv->edgecount; i++) {
- eh = &bv->edges[i];
+ for (int i = 0; i < bv->edgecount; i++) {
+ EdgeHalf *eh = &bv->edges[i];
eh->offset_l_spec *= offset_factor;
eh->offset_r_spec *= offset_factor;
eh->offset_l *= offset_factor;
@@ -7464,34 +7272,42 @@ void BM_mesh_bevel(BMesh *bm,
BMFace *f;
BMLoop *l;
BevVert *bv;
- BevelParams bp = {NULL};
-
- bp.offset = offset;
- bp.offset_type = offset_type;
- bp.seg = segments;
- bp.profile = profile;
- bp.pro_super_r = -logf(2.0) / logf(sqrtf(profile)); /* Convert to superellipse exponent. */
- bp.affect_type = affect_type;
- bp.use_weights = use_weights;
- bp.loop_slide = loop_slide;
- bp.limit_offset = limit_offset;
- bp.offset_adjust = bp.affect_type != BEVEL_AFFECT_VERTICES &&
- !ELEM(offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE);
- bp.dvert = dvert;
- bp.vertex_group = vertex_group;
- bp.mat_nr = mat;
- bp.mark_seam = mark_seam;
- bp.mark_sharp = mark_sharp;
- bp.harden_normals = harden_normals;
- bp.face_strength_mode = face_strength_mode;
- bp.miter_outer = miter_outer;
- bp.miter_inner = miter_inner;
- bp.spread = spread;
- bp.smoothresh = smoothresh;
- bp.face_hash = NULL;
- bp.profile_type = profile_type;
- bp.custom_profile = custom_profile;
- bp.vmesh_method = vmesh_method;
+ BevelParams bp = {
+ .offset = offset,
+ .offset_type = offset_type,
+ .seg = max_ii(segments, 1),
+ .profile = profile,
+ .pro_super_r = -logf(2.0) / logf(sqrtf(profile)), /* Convert to superellipse exponent. */
+ .affect_type = affect_type,
+ .use_weights = use_weights,
+ .loop_slide = loop_slide,
+ .limit_offset = limit_offset,
+ .offset_adjust = (bp.affect_type != BEVEL_AFFECT_VERTICES) &&
+ !ELEM(offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE),
+ .dvert = dvert,
+ .vertex_group = vertex_group,
+ .mat_nr = mat,
+ .mark_seam = mark_seam,
+ .mark_sharp = mark_sharp,
+ .harden_normals = harden_normals,
+ .face_strength_mode = face_strength_mode,
+ .miter_outer = miter_outer,
+ .miter_inner = miter_inner,
+ .spread = spread,
+ .smoothresh = smoothresh,
+ .face_hash = NULL,
+ .profile_type = profile_type,
+ .custom_profile = custom_profile,
+ .vmesh_method = vmesh_method,
+ };
+
+ if (bp.offset <= 0) {
+ return;
+ }
+
+#ifdef BEVEL_DEBUG_TIME
+ double start_time = PIL_check_seconds_timer();
+#endif
/* Disable the miters with the cutoff vertex mesh method, the combination isn't useful anyway. */
if (bp.vmesh_method == BEVEL_VMESH_CUTOFF) {
@@ -7499,10 +7315,6 @@ void BM_mesh_bevel(BMesh *bm,
bp.miter_inner = BEVEL_MITER_SHARP;
}
- if (bp.seg <= 1) {
- bp.seg = 1;
- }
-
if (profile >= 0.950f) { /* r ~ 692, so PRO_SQUARE_R is 1e4 */
bp.pro_super_r = PRO_SQUARE_R;
}
@@ -7516,149 +7328,152 @@ void BM_mesh_bevel(BMesh *bm,
bp.pro_super_r = PRO_SQUARE_IN_R;
}
- if (bp.offset > 0) {
- /* Primary alloc. */
- bp.vert_hash = BLI_ghash_ptr_new(__func__);
- bp.mem_arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), __func__);
- BLI_memarena_use_calloc(bp.mem_arena);
+ /* Primary alloc. */
+ bp.vert_hash = BLI_ghash_ptr_new(__func__);
+ bp.mem_arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), __func__);
+ BLI_memarena_use_calloc(bp.mem_arena);
- /* Get the 2D profile point locations from either the superellipse or the custom profile. */
- set_profile_spacing(&bp, &bp.pro_spacing, bp.profile_type == BEVEL_PROFILE_CUSTOM);
+ /* Get the 2D profile point locations from either the superellipse or the custom profile. */
+ set_profile_spacing(&bp, &bp.pro_spacing, bp.profile_type == BEVEL_PROFILE_CUSTOM);
- /* Get the 'fullness' of the profile for the ADJ vertex mesh method. */
- if (bp.seg > 1) {
- bp.pro_spacing.fullness = find_profile_fullness(&bp);
- }
-
- /* Get separate non-custom profile samples for the miter profiles if they are needed */
- if (bp.profile_type == BEVEL_PROFILE_CUSTOM &&
- (bp.miter_inner != BEVEL_MITER_SHARP || bp.miter_outer != BEVEL_MITER_SHARP)) {
- set_profile_spacing(&bp, &bp.pro_spacing_miter, false);
- }
-
- bp.face_hash = BLI_ghash_ptr_new(__func__);
- BLI_ghash_flag_set(bp.face_hash, GHASH_FLAG_ALLOW_DUPES);
+ /* Get the 'fullness' of the profile for the ADJ vertex mesh method. */
+ if (bp.seg > 1) {
+ bp.pro_spacing.fullness = find_profile_fullness(&bp);
+ }
- math_layer_info_init(&bp, bm);
+ /* Get separate non-custom profile samples for the miter profiles if they are needed */
+ if (bp.profile_type == BEVEL_PROFILE_CUSTOM &&
+ (bp.miter_inner != BEVEL_MITER_SHARP || bp.miter_outer != BEVEL_MITER_SHARP)) {
+ set_profile_spacing(&bp, &bp.pro_spacing_miter, false);
+ }
- /* Analyze input vertices, sorting edges and assigning initial new vertex positions. */
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
- bv = bevel_vert_construct(bm, &bp, v);
- if (!limit_offset && bv) {
- build_boundary(&bp, bv, true);
- }
- }
- }
+ bp.face_hash = BLI_ghash_ptr_new(__func__);
+ BLI_ghash_flag_set(bp.face_hash, GHASH_FLAG_ALLOW_DUPES);
- /* Perhaps clamp offset to avoid geometry colliisions. */
- if (limit_offset) {
- bevel_limit_offset(&bp, bm);
+ math_layer_info_init(&bp, bm);
- /* Assign initial new vertex positions. */
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
- bv = find_bevvert(&bp, v);
- if (bv) {
- build_boundary(&bp, bv, true);
- }
- }
+ /* Analyze input vertices, sorting edges and assigning initial new vertex positions. */
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ bv = bevel_vert_construct(bm, &bp, v);
+ if (!limit_offset && bv) {
+ build_boundary(&bp, bv, true);
}
}
+ }
- /* Perhaps do a pass to try to even out widths. */
- if (bp.offset_adjust) {
- adjust_offsets(&bp, bm);
- }
+ /* Perhaps clamp offset to avoid geometry colliisions. */
+ if (limit_offset) {
+ bevel_limit_offset(&bp, bm);
- /* Maintain consistent orientations for the asymmetrical custom profiles. */
- if (bp.profile_type == BEVEL_PROFILE_CUSTOM) {
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
- regularize_profile_orientation(&bp, e);
- }
- }
- }
-
- /* Build the meshes around vertices, now that positions are final. */
+ /* Assign initial new vertex positions. */
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
bv = find_bevvert(&bp, v);
if (bv) {
- build_vmesh(&bp, bm, bv);
+ build_boundary(&bp, bv, true);
}
}
}
+ }
- /* Build polygons for edges. */
- if (bp.affect_type != BEVEL_AFFECT_VERTICES) {
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
- bevel_build_edge_polygons(bm, &bp, e);
- }
+ /* Perhaps do a pass to try to even out widths. */
+ if (bp.offset_adjust) {
+ adjust_offsets(&bp, bm);
+ }
+
+ /* Maintain consistent orientations for the asymmetrical custom profiles. */
+ if (bp.profile_type == BEVEL_PROFILE_CUSTOM) {
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ regularize_profile_orientation(&bp, e);
}
}
+ }
- /* Extend edge data like sharp edges and precompute normals for harden. */
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
- bv = find_bevvert(&bp, v);
- if (bv) {
- bevel_extend_edge_data(bv);
- }
+ /* Build the meshes around vertices, now that positions are final. */
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ bv = find_bevvert(&bp, v);
+ if (bv) {
+ build_vmesh(&bp, bm, bv);
}
}
+ }
- /* Rebuild face polygons around affected vertices. */
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
- bevel_rebuild_existing_polygons(bm, &bp, v);
- bevel_reattach_wires(bm, &bp, v);
+ /* Build polygons for edges. */
+ if (bp.affect_type != BEVEL_AFFECT_VERTICES) {
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ bevel_build_edge_polygons(bm, &bp, e);
}
}
+ }
- BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
- BLI_assert(find_bevvert(&bp, v) != NULL);
- BM_vert_kill(bm, v);
+ /* Extend edge data like sharp edges and precompute normals for harden. */
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ bv = find_bevvert(&bp, v);
+ if (bv) {
+ bevel_extend_edge_data(bv);
}
}
+ }
- if (bp.harden_normals) {
- bevel_harden_normals(&bp, bm);
- }
- if (bp.face_strength_mode != BEVEL_FACE_STRENGTH_NONE) {
- bevel_set_weighted_normal_face_strength(bm, &bp);
+ /* Rebuild face polygons around affected vertices. */
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ bevel_rebuild_existing_polygons(bm, &bp, v);
+ bevel_reattach_wires(bm, &bp, v);
}
+ }
- /* When called from operator (as opposed to modifier), bm->use_toolflags
- * will be set, and we need to transfer the oflags to BM_ELEM_TAGs. */
- if (bm->use_toolflags) {
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BMO_vert_flag_test(bm, v, VERT_OUT)) {
- BM_elem_flag_enable(v, BM_ELEM_TAG);
- }
- }
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (BMO_edge_flag_test(bm, e, EDGE_OUT)) {
- BM_elem_flag_enable(e, BM_ELEM_TAG);
- }
- }
+ BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ BLI_assert(find_bevvert(&bp, v) != NULL);
+ BM_vert_kill(bm, v);
}
+ }
- /* Clear the BM_ELEM_LONG_TAG tags, which were only set on some edges in F_EDGE faces. */
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (get_face_kind(&bp, f) != F_EDGE) {
- continue;
+ if (bp.harden_normals) {
+ bevel_harden_normals(&bp, bm);
+ }
+ if (bp.face_strength_mode != BEVEL_FACE_STRENGTH_NONE) {
+ bevel_set_weighted_normal_face_strength(bm, &bp);
+ }
+
+ /* When called from operator (as opposed to modifier), bm->use_toolflags
+ * will be set, and we need to transfer the oflags to BM_ELEM_TAGs. */
+ if (bm->use_toolflags) {
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BMO_vert_flag_test(bm, v, VERT_OUT)) {
+ BM_elem_flag_enable(v, BM_ELEM_TAG);
}
- BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- BM_elem_flag_disable(l, BM_ELEM_LONG_TAG);
+ }
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BMO_edge_flag_test(bm, e, EDGE_OUT)) {
+ BM_elem_flag_enable(e, BM_ELEM_TAG);
}
}
+ }
- /* Primary free. */
- BLI_ghash_free(bp.vert_hash, NULL, NULL);
- BLI_ghash_free(bp.face_hash, NULL, NULL);
- BLI_memarena_free(bp.mem_arena);
+ /* Clear the BM_ELEM_LONG_TAG tags, which were only set on some edges in F_EDGE faces. */
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ if (get_face_kind(&bp, f) != F_EDGE) {
+ continue;
+ }
+ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+ BM_elem_flag_disable(l, BM_ELEM_LONG_TAG);
+ }
}
+
+ /* Primary free. */
+ BLI_ghash_free(bp.vert_hash, NULL, NULL);
+ BLI_ghash_free(bp.face_hash, NULL, NULL);
+ BLI_memarena_free(bp.mem_arena);
+
+#ifdef BEVEL_DEBUG_TIME
+ double end_time = PIL_check_seconds_timer();
+ printf("BMESH BEVEL TIME = %.3f\n", end_time - start_time);
+#endif
}
diff --git a/source/blender/bmesh/tools/bmesh_bevel.h b/source/blender/bmesh/tools/bmesh_bevel.h
index 317ca05b68a..de57e1c62a9 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.h
+++ b/source/blender/bmesh/tools/bmesh_bevel.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_BEVEL_H__
-#define __BMESH_BEVEL_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -47,5 +46,3 @@ void BM_mesh_bevel(BMesh *bm,
const float smoothresh,
const struct CurveProfile *custom_profile,
const int vmesh_method);
-
-#endif /* __BMESH_BEVEL_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.h b/source/blender/bmesh/tools/bmesh_bisect_plane.h
index ca6281be99f..f64b5d8097c 100644
--- a/source/blender/bmesh/tools/bmesh_bisect_plane.h
+++ b/source/blender/bmesh/tools/bmesh_bisect_plane.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_BISECT_PLANE_H__
-#define __BMESH_BISECT_PLANE_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -28,5 +27,3 @@ void BM_mesh_bisect_plane(BMesh *bm,
const short oflag_center,
const short oflag_new,
const float eps);
-
-#endif /* __BMESH_BISECT_PLANE_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_decimate.h b/source/blender/bmesh/tools/bmesh_decimate.h
index 669eb629e70..c62288c269a 100644
--- a/source/blender/bmesh/tools/bmesh_decimate.h
+++ b/source/blender/bmesh/tools/bmesh_decimate.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_DECIMATE_H__
-#define __BMESH_DECIMATE_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -45,5 +44,3 @@ void BM_mesh_decimate_dissolve(BMesh *bm,
const float angle_limit,
const bool do_dissolve_boundaries,
const BMO_Delimit delimit);
-
-#endif /* __BMESH_DECIMATE_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
index 3ed27ea580e..94a578fe1d7 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
@@ -171,7 +171,10 @@ static float bm_edge_calc_dissolve_error(const BMEdge *e,
#ifdef USE_DEGENERATE_CHECK
-static void mul_v2_m3v3_center(float r[2], float m[3][3], const float a[3], const float center[3])
+static void mul_v2_m3v3_center(float r[2],
+ const float m[3][3],
+ const float a[3],
+ const float center[3])
{
BLI_assert(r != a);
BLI_assert(r != center);
diff --git a/source/blender/bmesh/tools/bmesh_edgenet.h b/source/blender/bmesh/tools/bmesh_edgenet.h
index 5db0e1170f3..7855b2e2886 100644
--- a/source/blender/bmesh/tools/bmesh_edgenet.h
+++ b/source/blender/bmesh/tools/bmesh_edgenet.h
@@ -14,13 +14,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_EDGENET_H__
-#define __BMESH_EDGENET_H__
+#pragma once
/** \file
* \ingroup bmesh
*/
void BM_mesh_edgenet(BMesh *bm, const bool use_edge_tag, const bool use_new_face_tag);
-
-#endif /* __BMESH_EDGENET_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_edgesplit.h b/source/blender/bmesh/tools/bmesh_edgesplit.h
index 0b3884ec888..4b8c07fc992 100644
--- a/source/blender/bmesh/tools/bmesh_edgesplit.h
+++ b/source/blender/bmesh/tools/bmesh_edgesplit.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_EDGESPLIT_H__
-#define __BMESH_EDGESPLIT_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -25,5 +24,3 @@ void BM_mesh_edgesplit(BMesh *bm,
const bool use_verts,
const bool tag_only,
const bool copy_select);
-
-#endif /* __BMESH_EDGESPLIT_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c
index 6426fe9c687..371d8d59d6c 100644
--- a/source/blender/bmesh/tools/bmesh_intersect.c
+++ b/source/blender/bmesh/tools/bmesh_intersect.c
@@ -898,7 +898,7 @@ static int isect_bvhtree_point_v3(BVHTree *tree, const float **looptris, const f
&z_buffer,
};
BVHTreeRayHit hit = {0};
- float dir[3] = {1.0f, 0.0f, 0.0f};
+ const float dir[3] = {1.0f, 0.0f, 0.0f};
/* Need to initialize hit even tho it's not used.
* This is to make it so kd-tree believes we didn't intersect anything and
diff --git a/source/blender/bmesh/tools/bmesh_intersect.h b/source/blender/bmesh/tools/bmesh_intersect.h
index cbbc74d3f82..adb88f2fd76 100644
--- a/source/blender/bmesh/tools/bmesh_intersect.h
+++ b/source/blender/bmesh/tools/bmesh_intersect.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_INTERSECT_H__
-#define __BMESH_INTERSECT_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -42,5 +41,3 @@ enum {
BMESH_ISECT_BOOLEAN_UNION = 1,
BMESH_ISECT_BOOLEAN_DIFFERENCE = 2,
};
-
-#endif /* __BMESH_INTERSECT_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_intersect_edges.c b/source/blender/bmesh/tools/bmesh_intersect_edges.c
index 52231033fd3..5e266fdac0e 100644
--- a/source/blender/bmesh/tools/bmesh_intersect_edges.c
+++ b/source/blender/bmesh/tools/bmesh_intersect_edges.c
@@ -455,7 +455,7 @@ static void bm_elemxelem_bvhtree_overlap(const BVHTree *tree1,
int parallel_tasks_num = BLI_bvhtree_overlap_thread_num(tree1);
for (int i = 0; i < parallel_tasks_num; i++) {
if (pair_stack[i] == NULL) {
- pair_stack[i] = BLI_stack_new(sizeof(struct EDBMSplitElem[2]), __func__);
+ pair_stack[i] = BLI_stack_new(sizeof(const struct EDBMSplitElem[2]), __func__);
}
}
data->pair_stack = pair_stack;
diff --git a/source/blender/bmesh/tools/bmesh_intersect_edges.h b/source/blender/bmesh/tools/bmesh_intersect_edges.h
index 7e2252250d6..2736b7a52f9 100644
--- a/source/blender/bmesh/tools/bmesh_intersect_edges.h
+++ b/source/blender/bmesh/tools/bmesh_intersect_edges.h
@@ -18,10 +18,7 @@
* \ingroup bmesh
*/
-#ifndef __BMESH_INTERSECT_EDGES_H__
-#define __BMESH_INTERSECT_EDGES_H__
+#pragma once
bool BM_mesh_intersect_edges(
BMesh *bm, const char hflag, const float dist, const bool split_faces, GHash *r_targetmap);
-
-#endif /* __BMESH_INTERSECT_EDGES_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_path.h b/source/blender/bmesh/tools/bmesh_path.h
index 6d22a7e7e07..79c3d3a5d63 100644
--- a/source/blender/bmesh/tools/bmesh_path.h
+++ b/source/blender/bmesh/tools/bmesh_path.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_PATH_H__
-#define __BMESH_PATH_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -49,5 +48,3 @@ struct LinkNode *BM_mesh_calc_path_face(BMesh *bm,
bool (*filter_fn)(BMFace *, void *),
void *user_data) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1, 2, 3, 5);
-
-#endif /* __BMESH_PATH_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_path_region.h b/source/blender/bmesh/tools/bmesh_path_region.h
index 5204aa45da2..99a5b4a0960 100644
--- a/source/blender/bmesh/tools/bmesh_path_region.h
+++ b/source/blender/bmesh/tools/bmesh_path_region.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_PATH_REGION_H__
-#define __BMESH_PATH_REGION_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -41,5 +40,3 @@ struct LinkNode *BM_mesh_calc_path_region_face(BMesh *bm,
bool (*test_fn)(BMFace *, void *user_data),
void *user_data) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1, 2, 3);
-
-#endif /* __BMESH_PATH_REGION_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_path_region_uv.h b/source/blender/bmesh/tools/bmesh_path_region_uv.h
index 16e627ab461..18fe977c9fa 100644
--- a/source/blender/bmesh/tools/bmesh_path_region_uv.h
+++ b/source/blender/bmesh/tools/bmesh_path_region_uv.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_PATH_REGION_UV_H__
-#define __BMESH_PATH_REGION_UV_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -44,5 +43,3 @@ struct LinkNode *BM_mesh_calc_path_uv_region_face(BMesh *bm,
bool (*test_fn)(BMFace *, void *user_data),
void *user_data) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1, 2, 3);
-
-#endif /* __BMESH_PATH_REGION_UV_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_path_uv.h b/source/blender/bmesh/tools/bmesh_path_uv.h
index c7c5768f7d0..5f35d2c1594 100644
--- a/source/blender/bmesh/tools/bmesh_path_uv.h
+++ b/source/blender/bmesh/tools/bmesh_path_uv.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_PATH_UV_H__
-#define __BMESH_PATH_UV_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -43,5 +42,3 @@ struct LinkNode *BM_mesh_calc_path_uv_face(BMesh *bm,
bool (*filter_fn)(BMFace *, void *),
void *user_data) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1, 2, 3, 5);
-
-#endif /* __BMESH_PATH_UV_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_region_match.h b/source/blender/bmesh/tools/bmesh_region_match.h
index a0625543c51..799af938c31 100644
--- a/source/blender/bmesh/tools/bmesh_region_match.h
+++ b/source/blender/bmesh/tools/bmesh_region_match.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_REGION_MATCH_H__
-#define __BMESH_REGION_MATCH_H__
+#pragma once
/** \file
* \ingroup bmesh
@@ -25,5 +24,3 @@ int BM_mesh_region_match(BMesh *bm,
BMFace **faces_region,
uint faces_region_len,
ListBase *r_face_regions);
-
-#endif /* __BMESH_REGION_MATCH_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_separate.h b/source/blender/bmesh/tools/bmesh_separate.h
index 13293b155fd..9260903a8fa 100644
--- a/source/blender/bmesh/tools/bmesh_separate.h
+++ b/source/blender/bmesh/tools/bmesh_separate.h
@@ -14,13 +14,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BMESH_SEPARATE_H__
-#define __BMESH_SEPARATE_H__
+#pragma once
/** \file
* \ingroup bmesh
*/
void BM_mesh_separate_faces(BMesh *bm, BMFaceFilterFunc filter_fn, void *user_data);
-
-#endif /* __BMESH_SEPARATE_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_triangulate.h b/source/blender/bmesh/tools/bmesh_triangulate.h
index ababd78f9a1..5353b315a38 100644
--- a/source/blender/bmesh/tools/bmesh_triangulate.h
+++ b/source/blender/bmesh/tools/bmesh_triangulate.h
@@ -20,8 +20,7 @@
* Triangulate.
*/
-#ifndef __BMESH_TRIANGULATE_H__
-#define __BMESH_TRIANGULATE_H__
+#pragma once
void BM_mesh_triangulate(BMesh *bm,
const int quad_method,
@@ -31,5 +30,3 @@ void BM_mesh_triangulate(BMesh *bm,
BMOperator *op,
BMOpSlot *slot_facemap_out,
BMOpSlot *slot_doubles_out);
-
-#endif /* __BMESH_TRIANGULATE_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_wireframe.h b/source/blender/bmesh/tools/bmesh_wireframe.h
index 3be43b2e9f5..b2c2f5f5523 100644
--- a/source/blender/bmesh/tools/bmesh_wireframe.h
+++ b/source/blender/bmesh/tools/bmesh_wireframe.h
@@ -20,8 +20,7 @@
* Wire Frame.
*/
-#ifndef __BMESH_WIREFRAME_H__
-#define __BMESH_WIREFRAME_H__
+#pragma once
void BM_mesh_wireframe(BMesh *bm,
const float offset,
@@ -38,5 +37,3 @@ void BM_mesh_wireframe(BMesh *bm,
const short mat_offset,
const short mat_max,
const bool use_tag);
-
-#endif /* __BMESH_WIREFRAME_H__ */
diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h
index a24904551c6..b200fa8d266 100644
--- a/source/blender/compositor/COM_compositor.h
+++ b/source/blender/compositor/COM_compositor.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COMPOSITOR_H__
-#define __COM_COMPOSITOR_H__
+#pragma once
#include "DNA_color_types.h"
#include "DNA_node_types.h"
@@ -364,4 +363,3 @@ void COM_deinitialize(void);
}
#endif
-#endif /* __COM_COMPOSITOR_H__ */
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
index 3707845ef9b..a42719aaf09 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DEFINES_H__
-#define __COM_DEFINES_H__
+#pragma once
/**
* \brief possible data types for sockets
@@ -108,5 +107,3 @@ typedef enum OrderOfChunks {
#define COM_NUM_CHANNELS_COLOR 4
#define COM_BLUR_BOKEH_PIXELS 512
-
-#endif /* __COM_DEFINES_H__ */
diff --git a/source/blender/compositor/intern/COM_CPUDevice.h b/source/blender/compositor/intern/COM_CPUDevice.h
index 1d411569146..962380d7bc8 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.h
+++ b/source/blender/compositor/intern/COM_CPUDevice.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CPUDEVICE_H__
-#define __COM_CPUDEVICE_H__
+#pragma once
#include "COM_Device.h"
@@ -44,5 +43,3 @@ class CPUDevice : public Device {
protected:
int m_thread_id;
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.h b/source/blender/compositor/intern/COM_ChunkOrder.h
index e75c07136b4..32d8c07de83 100644
--- a/source/blender/compositor/intern/COM_ChunkOrder.h
+++ b/source/blender/compositor/intern/COM_ChunkOrder.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CHUNKORDER_H__
-#define __COM_CHUNKORDER_H__
+#pragma once
#include "COM_ChunkOrderHotspot.h"
class ChunkOrder {
@@ -53,5 +52,3 @@ class ChunkOrder {
return this->m_distance;
}
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
index f0bc92ad6d6..afacf5fc672 100644
--- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
+++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CHUNKORDERHOTSPOT_H__
-#define __COM_CHUNKORDERHOTSPOT_H__
+#pragma once
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
@@ -37,5 +36,3 @@ class ChunkOrderHotspot {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:ChunkOrderHotspot")
#endif
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp
index e572fe7c99e..3d55fcba086 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.cpp
+++ b/source/blender/compositor/intern/COM_CompositorContext.cpp
@@ -36,7 +36,6 @@ int CompositorContext::getFramenumber() const
if (this->m_rd) {
return this->m_rd->cfra;
}
- else {
- return -1; /* this should never happen */
- }
+
+ return -1; /* this should never happen */
}
diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h
index 7e775b7beaf..e29a8f67187 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.h
+++ b/source/blender/compositor/intern/COM_CompositorContext.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COMPOSITORCONTEXT_H__
-#define __COM_COMPOSITORCONTEXT_H__
+#pragma once
#include "BLI_rect.h"
#include "COM_defines.h"
@@ -269,5 +268,3 @@ class CompositorContext {
return (this->getbNodeTree()->flag & NTREE_COM_GROUPNODE_BUFFER) != 0;
}
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index edfeb3a3a04..60676ee42b7 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -416,19 +416,19 @@ NodeOperation *Converter::convertDataType(NodeOperationOutput *from, NodeOperati
if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) {
return new ConvertValueToColorOperation();
}
- else if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) {
+ if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) {
return new ConvertValueToVectorOperation();
}
- else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) {
+ if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) {
return new ConvertColorToValueOperation();
}
- else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) {
+ if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) {
return new ConvertColorToVectorOperation();
}
- else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_VALUE) {
+ if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_VALUE) {
return new ConvertVectorToValueOperation();
}
- else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) {
+ if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) {
return new ConvertVectorToColorOperation();
}
diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h
index 1213246b9c9..fe3b8b75ccc 100644
--- a/source/blender/compositor/intern/COM_Converter.h
+++ b/source/blender/compositor/intern/COM_Converter.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CONVERTER_H__
-#define __COM_CONVERTER_H__
+#pragma once
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
@@ -85,4 +84,3 @@ class Converter {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:Converter")
#endif
};
-#endif
diff --git a/source/blender/compositor/intern/COM_Debug.h b/source/blender/compositor/intern/COM_Debug.h
index 250f360fa35..35e44506ef2 100644
--- a/source/blender/compositor/intern/COM_Debug.h
+++ b/source/blender/compositor/intern/COM_Debug.h
@@ -16,8 +16,7 @@
* Copyright 2013, Blender Foundation.
*/
-#ifndef __COM_DEBUG_H__
-#define __COM_DEBUG_H__
+#pragma once
#include <map>
#include <string>
@@ -77,5 +76,3 @@ class DebugInfo {
static GroupStateMap m_group_states; /**< for visualizing group states */
#endif
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_Device.h b/source/blender/compositor/intern/COM_Device.h
index 8573f69658e..bb95f1e953c 100644
--- a/source/blender/compositor/intern/COM_Device.h
+++ b/source/blender/compositor/intern/COM_Device.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DEVICE_H__
-#define __COM_DEVICE_H__
+#pragma once
#include "COM_WorkPackage.h"
@@ -62,5 +61,3 @@ class Device {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:Device")
#endif
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h
index 0299dad2ee8..f0dca4e9b34 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.h
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_EXECUTIONGROUP_H__
-#define __COM_EXECUTIONGROUP_H__
+#pragma once
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
@@ -447,5 +446,3 @@ class ExecutionGroup {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionGroup")
#endif
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index bf65594fc4f..44b47787b06 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -18,8 +18,7 @@
class ExecutionGroup;
-#ifndef __COM_EXECUTIONSYSTEM_H__
-#define __COM_EXECUTIONSYSTEM_H__
+#pragma once
#include "BKE_text.h"
#include "COM_ExecutionGroup.h"
@@ -196,5 +195,3 @@ class ExecutionSystem {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionSystem")
#endif
};
-
-#endif /* __COM_EXECUTIONSYSTEM_H__ */
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
index b958314d1b4..f58d7a768cc 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -136,10 +136,9 @@ float MemoryBuffer::getMaximumValue(rcti *rect)
delete temp;
return result;
}
- else {
- BLI_assert(0);
- return 0.0f;
- }
+
+ BLI_assert(0);
+ return 0.0f;
}
MemoryBuffer::~MemoryBuffer()
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index 6ba8f144482..fce1310f6ef 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -18,8 +18,7 @@
class MemoryBuffer;
-#ifndef __COM_MEMORYBUFFER_H__
-#define __COM_MEMORYBUFFER_H__
+#pragma once
#include "COM_ExecutionGroup.h"
#include "COM_MemoryProxy.h"
@@ -357,5 +356,3 @@ class MemoryBuffer {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryBuffer")
#endif
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h
index afbe0e3c166..a40e6f95dce 100644
--- a/source/blender/compositor/intern/COM_MemoryProxy.h
+++ b/source/blender/compositor/intern/COM_MemoryProxy.h
@@ -18,8 +18,8 @@
class MemoryProxy;
-#ifndef __COM_MEMORYPROXY_H__
-#define __COM_MEMORYPROXY_H__
+#pragma once
+
#include "COM_ExecutionGroup.h"
#include "COM_MemoryBuffer.h"
@@ -129,5 +129,3 @@ class MemoryProxy {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryProxy")
#endif
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
index a2ab1996a19..0a34eff3492 100644
--- a/source/blender/compositor/intern/COM_Node.h
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_NODE_H__
-#define __COM_NODE_H__
+#pragma once
#include "DNA_node_types.h"
#include <algorithm>
@@ -329,5 +328,3 @@ class NodeOutput {
void getEditorValueColor(float *value);
void getEditorValueVector(float *value);
};
-
-#endif /* __COM_NODE_H__ */
diff --git a/source/blender/compositor/intern/COM_NodeConverter.h b/source/blender/compositor/intern/COM_NodeConverter.h
index 56e9aa85010..e9b05184857 100644
--- a/source/blender/compositor/intern/COM_NodeConverter.h
+++ b/source/blender/compositor/intern/COM_NodeConverter.h
@@ -16,8 +16,7 @@
* Copyright 2013, Blender Foundation.
*/
-#ifndef __COM_NODECONVERTER_H__
-#define __COM_NODECONVERTER_H__
+#pragma once
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
@@ -121,5 +120,3 @@ class NodeConverter {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompiler")
#endif
};
-
-#endif /* __COM_NODECONVERTER_H__ */
diff --git a/source/blender/compositor/intern/COM_NodeGraph.h b/source/blender/compositor/intern/COM_NodeGraph.h
index 531832c2c65..7cbd45bd0b5 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.h
+++ b/source/blender/compositor/intern/COM_NodeGraph.h
@@ -16,8 +16,7 @@
* Copyright 2013, Blender Foundation.
*/
-#ifndef __COM_NODEGRAPH_H__
-#define __COM_NODEGRAPH_H__
+#pragma once
#include <map>
#include <set>
@@ -135,5 +134,3 @@ class NodeGraph {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeGraph")
#endif
};
-
-#endif /* __COM_NODEGRAPH_H__ */
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp
index fa4b5a07c65..4e3c5d2df6c 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperation.cpp
@@ -145,9 +145,8 @@ NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex)
if (input && input->isConnected()) {
return &input->getLink()->getOperation();
}
- else {
- return NULL;
- }
+
+ return NULL;
}
void NodeOperation::getConnectedInputSockets(Inputs *sockets)
@@ -168,30 +167,29 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input,
BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax);
return false;
}
- else {
- rcti tempOutput;
- bool first = true;
- for (int i = 0; i < getNumberOfInputSockets(); i++) {
- NodeOperation *inputOperation = this->getInputOperation(i);
- if (inputOperation &&
- inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) {
- if (first) {
- output->xmin = tempOutput.xmin;
- output->ymin = tempOutput.ymin;
- output->xmax = tempOutput.xmax;
- output->ymax = tempOutput.ymax;
- first = false;
- }
- else {
- output->xmin = min(output->xmin, tempOutput.xmin);
- output->ymin = min(output->ymin, tempOutput.ymin);
- output->xmax = max(output->xmax, tempOutput.xmax);
- output->ymax = max(output->ymax, tempOutput.ymax);
- }
+
+ rcti tempOutput;
+ bool first = true;
+ for (int i = 0; i < getNumberOfInputSockets(); i++) {
+ NodeOperation *inputOperation = this->getInputOperation(i);
+ if (inputOperation &&
+ inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) {
+ if (first) {
+ output->xmin = tempOutput.xmin;
+ output->ymin = tempOutput.ymin;
+ output->xmax = tempOutput.xmax;
+ output->ymax = tempOutput.ymax;
+ first = false;
+ }
+ else {
+ output->xmin = min(output->xmin, tempOutput.xmin);
+ output->ymin = min(output->ymin, tempOutput.ymin);
+ output->xmax = max(output->xmax, tempOutput.xmax);
+ output->ymax = max(output->ymax, tempOutput.ymax);
}
}
- return !first;
}
+ return !first;
}
/*****************
@@ -210,9 +208,8 @@ SocketReader *NodeOperationInput::getReader()
if (isConnected()) {
return &m_link->getOperation();
}
- else {
- return NULL;
- }
+
+ return NULL;
}
void NodeOperationInput::determineResolution(unsigned int resolution[2],
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index d2c896a2e56..d9324729560 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_NODEOPERATION_H__
-#define __COM_NODEOPERATION_H__
+#pragma once
#include <list>
#include <sstream>
@@ -521,5 +520,3 @@ class NodeOperationOutput {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
#endif
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.h b/source/blender/compositor/intern/COM_NodeOperationBuilder.h
index 917fa2888fd..5dd4022b127 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.h
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.h
@@ -16,8 +16,7 @@
* Copyright 2013, Blender Foundation.
*/
-#ifndef __COM_NODEOPERATIONBUILDER_H__
-#define __COM_NODEOPERATIONBUILDER_H__
+#pragma once
#include <map>
#include <set>
@@ -176,5 +175,3 @@ class NodeOperationBuilder {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompilerImpl")
#endif
};
-
-#endif /* __COM_NODEOPERATIONBUILDER_H__ */
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h
index 3f6e0fb55ef..d502f5aa34b 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.h
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.h
@@ -18,8 +18,7 @@
class OpenCLDevice;
-#ifndef __COM_OPENCLDEVICE_H__
-#define __COM_OPENCLDEVICE_H__
+#pragma once
#include "COM_Device.h"
#include "COM_ReadBufferOperation.h"
@@ -133,5 +132,3 @@ class OpenCLDevice : public Device {
NodeOperation *operation);
cl_kernel COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp);
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.h b/source/blender/compositor/intern/COM_SingleThreadedOperation.h
index 68c7f05a6c2..7a97d790afe 100644
--- a/source/blender/compositor/intern/COM_SingleThreadedOperation.h
+++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SINGLETHREADEDOPERATION_H__
-#define __COM_SINGLETHREADEDOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class SingleThreadedOperation : public NodeOperation {
@@ -57,4 +57,3 @@ class SingleThreadedOperation : public NodeOperation {
return true;
}
};
-#endif
diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h
index 82bebd5e7b9..ee2a6e0e1bf 100644
--- a/source/blender/compositor/intern/COM_SocketReader.h
+++ b/source/blender/compositor/intern/COM_SocketReader.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SOCKETREADER_H__
-#define __COM_SOCKETREADER_H__
+#pragma once
+
#include "BLI_rect.h"
#include "COM_defines.h"
@@ -138,5 +138,3 @@ class SocketReader {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketReader")
#endif
};
-
-#endif /* __COM_SOCKETREADER_H__ */
diff --git a/source/blender/compositor/intern/COM_WorkPackage.h b/source/blender/compositor/intern/COM_WorkPackage.h
index 2a0e47301f5..f4370aa41be 100644
--- a/source/blender/compositor/intern/COM_WorkPackage.h
+++ b/source/blender/compositor/intern/COM_WorkPackage.h
@@ -18,8 +18,8 @@
class WorkPackage;
-#ifndef __COM_WORKPACKAGE_H__
-#define __COM_WORKPACKAGE_H__
+#pragma once
+
class ExecutionGroup;
#include "COM_ExecutionGroup.h"
@@ -67,5 +67,3 @@ class WorkPackage {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:WorkPackage")
#endif
};
-
-#endif
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h
index 3a1b4c533bd..2424d1bdb72 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.h
+++ b/source/blender/compositor/intern/COM_WorkScheduler.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_WORKSCHEDULER_H__
-#define __COM_WORKSCHEDULER_H__
+#pragma once
#include "COM_ExecutionGroup.h"
@@ -116,5 +115,3 @@ class WorkScheduler {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:WorkScheduler")
#endif
};
-
-#endif /* __COM_WORKSCHEDULER_H__ */
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.h b/source/blender/compositor/nodes/COM_AlphaOverNode.h
index 27e868e6f25..32cd2e20204 100644
--- a/source/blender/compositor/nodes/COM_AlphaOverNode.h
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_ALPHAOVERNODE_H__
-#define __COM_ALPHAOVERNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -32,5 +31,3 @@ class AlphaOverNode : public Node {
}
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.h b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
index abed491c891..39308c7d1b6 100644
--- a/source/blender/compositor/nodes/COM_BilateralBlurNode.h
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BILATERALBLURNODE_H__
-#define __COM_BILATERALBLURNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class BilateralBlurNode : public Node {
BilateralBlurNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_BlurNode.h b/source/blender/compositor/nodes/COM_BlurNode.h
index f0d6cad320e..3c832c93ca2 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.h
+++ b/source/blender/compositor/nodes/COM_BlurNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BLURNODE_H__
-#define __COM_BLURNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class BlurNode : public Node {
BlurNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.h b/source/blender/compositor/nodes/COM_BokehBlurNode.h
index e2f728fb30b..87aca9af1f6 100644
--- a/source/blender/compositor/nodes/COM_BokehBlurNode.h
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BOKEHBLURNODE_H__
-#define __COM_BOKEHBLURNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class BokehBlurNode : public Node {
BokehBlurNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.h b/source/blender/compositor/nodes/COM_BokehImageNode.h
index 3e78e8d5185..b9d957cd6df 100644
--- a/source/blender/compositor/nodes/COM_BokehImageNode.h
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BOKEHIMAGENODE_H__
-#define __COM_BOKEHIMAGENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class BokehImageNode : public Node {
BokehImageNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.h b/source/blender/compositor/nodes/COM_BoxMaskNode.h
index 0d39014bbd0..b815fd75284 100644
--- a/source/blender/compositor/nodes/COM_BoxMaskNode.h
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BOXMASKNODE_H__
-#define __COM_BOXMASKNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class BoxMaskNode : public Node {
BoxMaskNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.h b/source/blender/compositor/nodes/COM_BrightnessNode.h
index 8529fc17d9c..b64b622dd71 100644
--- a/source/blender/compositor/nodes/COM_BrightnessNode.h
+++ b/source/blender/compositor/nodes/COM_BrightnessNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BRIGHTNESSNODE_H__
-#define __COM_BRIGHTNESSNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class BrightnessNode : public Node {
BrightnessNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.h b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
index e6cd8bf6f0d..bca821fa60c 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_CHANNELMATTENODE_H__
-#define __COM_CHANNELMATTENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ChannelMatteNode : public Node {
ChannelMatteNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* COM_ChannelMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.h b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
index cfb6f23ebcb..d8febdde36f 100644
--- a/source/blender/compositor/nodes/COM_ChromaMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CHROMAMATTENODE_H__
-#define __COM_CHROMAMATTENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ChromaMatteNode : public Node {
ChromaMatteNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* COM_ChromaMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.h b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
index 482b34e7809..302b66863ca 100644
--- a/source/blender/compositor/nodes/COM_ColorBalanceNode.h
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORBALANCENODE_H__
-#define __COM_COLORBALANCENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ColorBalanceNode : public Node {
ColorBalanceNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* COM_ColorBalanceNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.h b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
index 0275106095e..be6545f0cfa 100644
--- a/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
+++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORCORRECTIONNODE_H__
-#define __COM_COLORCORRECTIONNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ColorCorrectionNode : public Node {
ColorCorrectionNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.h b/source/blender/compositor/nodes/COM_ColorCurveNode.h
index 2a529e5713e..6eaf1db6fbb 100644
--- a/source/blender/compositor/nodes/COM_ColorCurveNode.h
+++ b/source/blender/compositor/nodes/COM_ColorCurveNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORCURVENODE_H__
-#define __COM_COLORCURVENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ColorCurveNode : public Node {
ColorCurveNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.h b/source/blender/compositor/nodes/COM_ColorMatteNode.h
index 1f02a091307..e84bdfc836f 100644
--- a/source/blender/compositor/nodes/COM_ColorMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORMATTENODE_H__
-#define __COM_COLORMATTENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ColorMatteNode : public Node {
ColorMatteNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* COM_ColorMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorNode.h b/source/blender/compositor/nodes/COM_ColorNode.h
index 5c7580a9ec9..9b50e9ab7d4 100644
--- a/source/blender/compositor/nodes/COM_ColorNode.h
+++ b/source/blender/compositor/nodes/COM_ColorNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORNODE_H__
-#define __COM_COLORNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ColorNode : public Node {
ColorNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.h b/source/blender/compositor/nodes/COM_ColorRampNode.h
index 3f7a188e549..b53edf14dbd 100644
--- a/source/blender/compositor/nodes/COM_ColorRampNode.h
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORRAMPNODE_H__
-#define __COM_COLORRAMPNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ColorRampNode : public Node {
ColorRampNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* COM_ColorRampNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.h b/source/blender/compositor/nodes/COM_ColorSpillNode.h
index 4678d1dd7b1..3cf8072c7b7 100644
--- a/source/blender/compositor/nodes/COM_ColorSpillNode.h
+++ b/source/blender/compositor/nodes/COM_ColorSpillNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORSPILLNODE_H__
-#define __COM_COLORSPILLNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ColorSpillNode : public Node {
ColorSpillNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* COM_ColorSpillNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.h b/source/blender/compositor/nodes/COM_ColorToBWNode.h
index d811cab8019..6e7025de496 100644
--- a/source/blender/compositor/nodes/COM_ColorToBWNode.h
+++ b/source/blender/compositor/nodes/COM_ColorToBWNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORTOBWNODE_H__
-#define __COM_COLORTOBWNODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -30,4 +29,3 @@ class ColorToBWNode : public Node {
ColorToBWNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif
diff --git a/source/blender/compositor/nodes/COM_CombineColorNode.h b/source/blender/compositor/nodes/COM_CombineColorNode.h
index 203a8e84306..378a4855abf 100644
--- a/source/blender/compositor/nodes/COM_CombineColorNode.h
+++ b/source/blender/compositor/nodes/COM_CombineColorNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COMBINECOLORNODE_H__
-#define __COM_COMBINECOLORNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -65,5 +64,3 @@ class CombineYUVANode : public CombineColorNode {
NodeOperation *getColorConverter(const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.h b/source/blender/compositor/nodes/COM_CompositorNode.h
index 8fb2a5a5cf5..a75355dfc14 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.h
+++ b/source/blender/compositor/nodes/COM_CompositorNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COMPOSITORNODE_H__
-#define __COM_COMPOSITORNODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -30,4 +29,3 @@ class CompositorNode : public Node {
CompositorNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif
diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
index 8fdeae39ada..372f34a576f 100644
--- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
+++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_CONVERTALPHANODE_H__
-#define __COM_CONVERTALPHANODE_H__
+#pragma once
#include "COM_Node.h"
@@ -32,5 +31,3 @@ class ConvertAlphaNode : public Node {
}
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_CornerPinNode.h b/source/blender/compositor/nodes/COM_CornerPinNode.h
index a8e88a0ef4f..ba845a614fb 100644
--- a/source/blender/compositor/nodes/COM_CornerPinNode.h
+++ b/source/blender/compositor/nodes/COM_CornerPinNode.h
@@ -15,8 +15,7 @@
* Copyright 2014, Blender Foundation.
*/
-#ifndef __COM_CORNERPINNODE_H__
-#define __COM_CORNERPINNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -31,5 +30,3 @@ class CornerPinNode : public Node {
CornerPinNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_CORNERPINNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_CropNode.h b/source/blender/compositor/nodes/COM_CropNode.h
index 295d4fb77e1..f643ebbabcc 100644
--- a/source/blender/compositor/nodes/COM_CropNode.h
+++ b/source/blender/compositor/nodes/COM_CropNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CROPNODE_H__
-#define __COM_CROPNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class CropNode : public Node {
CropNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.h b/source/blender/compositor/nodes/COM_CryptomatteNode.h
index 91f8051f125..1fb8893efa0 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.h
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.h
@@ -16,8 +16,7 @@
* Copyright 2018, Blender Foundation.
*/
-#ifndef __COM_CRYPTOMATTENODE_H__
-#define __COM_CRYPTOMATTENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class CryptomatteNode : public Node {
CryptomatteNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.h b/source/blender/compositor/nodes/COM_DefocusNode.h
index f2589c7ae1a..c042e98c515 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.h
+++ b/source/blender/compositor/nodes/COM_DefocusNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DEFOCUSNODE_H__
-#define __COM_DEFOCUSNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class DefocusNode : public Node {
DefocusNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_DenoiseNode.h b/source/blender/compositor/nodes/COM_DenoiseNode.h
index 6cbe598f7d2..99f59c89fdb 100644
--- a/source/blender/compositor/nodes/COM_DenoiseNode.h
+++ b/source/blender/compositor/nodes/COM_DenoiseNode.h
@@ -16,8 +16,7 @@
* Copyright 2019, Blender Foundation.
*/
-#ifndef __COM_DENOISENODE_H__
-#define __COM_DENOISENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class DenoiseNode : public Node {
DenoiseNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.h b/source/blender/compositor/nodes/COM_DespeckleNode.h
index ee510a0568c..6b39dd94ac7 100644
--- a/source/blender/compositor/nodes/COM_DespeckleNode.h
+++ b/source/blender/compositor/nodes/COM_DespeckleNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DESPECKLENODE_H__
-#define __COM_DESPECKLENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class DespeckleNode : public Node {
DespeckleNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
index 3a86a0bbf85..26be5fe1e80 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DIFFERENCEMATTENODE_H__
-#define __COM_DIFFERENCEMATTENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class DifferenceMatteNode : public Node {
DifferenceMatteNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* COM_DifferenceMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h
index d5b2863a4bb..090095df447 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.h
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DILATEERODENODE_H__
-#define __COM_DILATEERODENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -33,5 +32,3 @@ class DilateErodeNode : public Node {
DilateErodeNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
index 0f9249a83a5..dfb705cbe64 100644
--- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DIRECTIONALBLURNODE_H__
-#define __COM_DIRECTIONALBLURNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class DirectionalBlurNode : public Node {
DirectionalBlurNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.h b/source/blender/compositor/nodes/COM_DisplaceNode.h
index e6a13e06772..a9e8a5ad657 100644
--- a/source/blender/compositor/nodes/COM_DisplaceNode.h
+++ b/source/blender/compositor/nodes/COM_DisplaceNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DISPLACENODE_H__
-#define __COM_DISPLACENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,4 +29,3 @@ class DisplaceNode : public Node {
DisplaceNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif
diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.h b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
index baba9bb8c97..6ae71ef715f 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DISTANCEMATTENODE_H__
-#define __COM_DISTANCEMATTENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class DistanceMatteNode : public Node {
DistanceMatteNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* COM_DistanceMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
index c45d42675f3..6d26cbbf528 100644
--- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
+++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DOUBLEEDGEMASKNODE_H__
-#define __COM_DOUBLEEDGEMASKNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class DoubleEdgeMaskNode : public Node {
DoubleEdgeMaskNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.h b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
index b7093bf68fa..d7376cad52e 100644
--- a/source/blender/compositor/nodes/COM_EllipseMaskNode.h
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_ELLIPSEMASKNODE_H__
-#define __COM_ELLIPSEMASKNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class EllipseMaskNode : public Node {
EllipseMaskNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_FilterNode.h b/source/blender/compositor/nodes/COM_FilterNode.h
index d0e824051bb..735d8925b48 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.h
+++ b/source/blender/compositor/nodes/COM_FilterNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_FILTERNODE_H__
-#define __COM_FILTERNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class FilterNode : public Node {
FilterNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_FILTERNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_FlipNode.h b/source/blender/compositor/nodes/COM_FlipNode.h
index 2122961dac9..e819c003430 100644
--- a/source/blender/compositor/nodes/COM_FlipNode.h
+++ b/source/blender/compositor/nodes/COM_FlipNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_FLIPNODE_H__
-#define __COM_FLIPNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class FlipNode : public Node {
FlipNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_GammaNode.h b/source/blender/compositor/nodes/COM_GammaNode.h
index 46573fc4b3f..1a4d02af160 100644
--- a/source/blender/compositor/nodes/COM_GammaNode.h
+++ b/source/blender/compositor/nodes/COM_GammaNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GAMMANODE_H__
-#define __COM_GAMMANODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class GammaNode : public Node {
GammaNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_GlareNode.h b/source/blender/compositor/nodes/COM_GlareNode.h
index 051ae1d1dc3..7463af97306 100644
--- a/source/blender/compositor/nodes/COM_GlareNode.h
+++ b/source/blender/compositor/nodes/COM_GlareNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GLARENODE_H__
-#define __COM_GLARENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class GlareNode : public Node {
GlareNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
index 270d29cc41b..01790c1a5fb 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_HUESATURATIONVALUECORRECTNODE_H__
-#define __COM_HUESATURATIONVALUECORRECTNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,4 +29,3 @@ class HueSaturationValueCorrectNode : public Node {
HueSaturationValueCorrectNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
index 5e023a0762d..7ef7abe4188 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_HUESATURATIONVALUENODE_H__
-#define __COM_HUESATURATIONVALUENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,4 +29,3 @@ class HueSaturationValueNode : public Node {
HueSaturationValueNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif
diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.h b/source/blender/compositor/nodes/COM_IDMaskNode.h
index 3f4019bf5b7..51076619951 100644
--- a/source/blender/compositor/nodes/COM_IDMaskNode.h
+++ b/source/blender/compositor/nodes/COM_IDMaskNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_IDMASKNODE_H__
-#define __COM_IDMASKNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class IDMaskNode : public Node {
IDMaskNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_ImageNode.h b/source/blender/compositor/nodes/COM_ImageNode.h
index 7883f4d7ab3..9481ef4f7b1 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.h
+++ b/source/blender/compositor/nodes/COM_ImageNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_IMAGENODE_H__
-#define __COM_IMAGENODE_H__
+#pragma once
#include "COM_Node.h"
#include "COM_defines.h"
@@ -46,5 +45,3 @@ class ImageNode : public Node {
ImageNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_IMAGENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_InpaintNode.h b/source/blender/compositor/nodes/COM_InpaintNode.h
index 61a7ac63146..3f778c8ba5c 100644
--- a/source/blender/compositor/nodes/COM_InpaintNode.h
+++ b/source/blender/compositor/nodes/COM_InpaintNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_INPAINTNODE_H__
-#define __COM_INPAINTNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class InpaintNode : public Node {
InpaintNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_InvertNode.h b/source/blender/compositor/nodes/COM_InvertNode.h
index 02e2eb38dc9..d90d6e48713 100644
--- a/source/blender/compositor/nodes/COM_InvertNode.h
+++ b/source/blender/compositor/nodes/COM_InvertNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_INVERTNODE_H__
-#define __COM_INVERTNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class InvertNode : public Node {
InvertNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.h b/source/blender/compositor/nodes/COM_KeyingNode.h
index fc5f55e33ae..cfb1f2e6ddf 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.h
+++ b/source/blender/compositor/nodes/COM_KeyingNode.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_KEYINGNODE_H__
-#define __COM_KEYINGNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -58,5 +57,3 @@ class KeyingNode : public Node {
KeyingNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_KEYINGNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.h b/source/blender/compositor/nodes/COM_KeyingScreenNode.h
index 12db2ed8889..ce9ef54543d 100644
--- a/source/blender/compositor/nodes/COM_KeyingScreenNode.h
+++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_KEYINGSCREENNODE_H__
-#define __COM_KEYINGSCREENNODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -31,5 +30,3 @@ class KeyingScreenNode : public Node {
KeyingScreenNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_KEYINGSCREENNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.h b/source/blender/compositor/nodes/COM_LensDistortionNode.h
index f4d9e127558..8df0e3f7df1 100644
--- a/source/blender/compositor/nodes/COM_LensDistortionNode.h
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_LENSDISTORTIONNODE_H__
-#define __COM_LENSDISTORTIONNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class LensDistortionNode : public Node {
LensDistortionNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
index 57a8f25602a..7f2d9dfbe95 100644
--- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_LUMINANCEMATTENODE_H__
-#define __COM_LUMINANCEMATTENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class LuminanceMatteNode : public Node {
LuminanceMatteNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_LUMINANCEMATTENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MapRangeNode.h b/source/blender/compositor/nodes/COM_MapRangeNode.h
index b63524291c1..b838ea858ee 100644
--- a/source/blender/compositor/nodes/COM_MapRangeNode.h
+++ b/source/blender/compositor/nodes/COM_MapRangeNode.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_MAPRANGENODE_H__
-#define __COM_MAPRANGENODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -30,5 +29,3 @@ class MapRangeNode : public Node {
MapRangeNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_MAPRANGENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MapUVNode.h b/source/blender/compositor/nodes/COM_MapUVNode.h
index 46892453b92..f9fc413dbe5 100644
--- a/source/blender/compositor/nodes/COM_MapUVNode.h
+++ b/source/blender/compositor/nodes/COM_MapUVNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MAPUVNODE_H__
-#define __COM_MAPUVNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,4 +29,3 @@ class MapUVNode : public Node {
MapUVNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.h b/source/blender/compositor/nodes/COM_MapValueNode.h
index 289b4f24138..60ee262d447 100644
--- a/source/blender/compositor/nodes/COM_MapValueNode.h
+++ b/source/blender/compositor/nodes/COM_MapValueNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MAPVALUENODE_H__
-#define __COM_MAPVALUENODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -30,5 +29,3 @@ class MapValueNode : public Node {
MapValueNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_MAPVALUENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MaskNode.h b/source/blender/compositor/nodes/COM_MaskNode.h
index 6c8006a8de6..4a03916b3c2 100644
--- a/source/blender/compositor/nodes/COM_MaskNode.h
+++ b/source/blender/compositor/nodes/COM_MaskNode.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_MASKNODE_H__
-#define __COM_MASKNODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -31,5 +30,3 @@ class MaskNode : public Node {
MaskNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_MASKNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MathNode.h b/source/blender/compositor/nodes/COM_MathNode.h
index e53d84a221f..41b144679ac 100644
--- a/source/blender/compositor/nodes/COM_MathNode.h
+++ b/source/blender/compositor/nodes/COM_MathNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MATHNODE_H__
-#define __COM_MATHNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -32,5 +31,3 @@ class MathNode : public Node {
}
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_MixNode.h b/source/blender/compositor/nodes/COM_MixNode.h
index 511e1ffa7a8..91ce29fdbf2 100644
--- a/source/blender/compositor/nodes/COM_MixNode.h
+++ b/source/blender/compositor/nodes/COM_MixNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MIXNODE_H__
-#define __COM_MIXNODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -30,4 +29,3 @@ class MixNode : public Node {
MixNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.h b/source/blender/compositor/nodes/COM_MovieClipNode.h
index 2c3f29772d5..58262592dca 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.h
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MOVIECLIPNODE_H__
-#define __COM_MOVIECLIPNODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -31,5 +30,3 @@ class MovieClipNode : public Node {
MovieClipNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_MOVIECLIPNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.h b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
index da687080691..f4df48dac13 100644
--- a/source/blender/compositor/nodes/COM_MovieDistortionNode.h
+++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MOVIEDISTORTIONNODE_H__
-#define __COM_MOVIEDISTORTIONNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class MovieDistortionNode : public Node {
MovieDistortionNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_NormalNode.h b/source/blender/compositor/nodes/COM_NormalNode.h
index 4151960c506..c23e83fb023 100644
--- a/source/blender/compositor/nodes/COM_NormalNode.h
+++ b/source/blender/compositor/nodes/COM_NormalNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_NORMALNODE_H__
-#define __COM_NORMALNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class NormalNode : public Node {
NormalNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* COM_NormalNODE_H */
diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.h b/source/blender/compositor/nodes/COM_NormalizeNode.h
index 593c98f2ce2..7e53ac7e9a0 100644
--- a/source/blender/compositor/nodes/COM_NormalizeNode.h
+++ b/source/blender/compositor/nodes/COM_NormalizeNode.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_NORMALIZENODE_H__
-#define __COM_NORMALIZENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class NormalizeNode : public Node {
NormalizeNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.h b/source/blender/compositor/nodes/COM_OutputFileNode.h
index 932fa375a3a..037a345fa50 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.h
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_OUTPUTFILENODE_H__
-#define __COM_OUTPUTFILENODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -31,5 +30,3 @@ class OutputFileNode : public Node {
OutputFileNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_PixelateNode.h b/source/blender/compositor/nodes/COM_PixelateNode.h
index f46035398e2..87cb4df59e8 100644
--- a/source/blender/compositor/nodes/COM_PixelateNode.h
+++ b/source/blender/compositor/nodes/COM_PixelateNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_PIXELATENODE_H__
-#define __COM_PIXELATENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class PixelateNode : public Node {
PixelateNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h
index 2c17739a220..36844bc1650 100644
--- a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h
+++ b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h
@@ -16,8 +16,7 @@
* Copyright 2013, Blender Foundation.
*/
-#ifndef __COM_PLANETRACKDEFORMNODE_H__
-#define __COM_PLANETRACKDEFORMNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -33,5 +32,3 @@ class PlaneTrackDeformNode : public Node {
PlaneTrackDeformNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_PLANETRACKDEFORMNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.h b/source/blender/compositor/nodes/COM_RenderLayersNode.h
index c992f60581f..1ffd084ad1e 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.h
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_RENDERLAYERSNODE_H__
-#define __COM_RENDERLAYERSNODE_H__
+#pragma once
#include "COM_Node.h"
#include "COM_RenderLayersProg.h"
@@ -49,5 +48,3 @@ class RenderLayersNode : public Node {
void missingSocketLink(NodeConverter &converter, NodeOutput *output) const;
void missingRenderLink(NodeConverter &converter) const;
};
-
-#endif /* __COM_RENDERLAYERSNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_RotateNode.h b/source/blender/compositor/nodes/COM_RotateNode.h
index e7440bb7a8e..b75fdd52683 100644
--- a/source/blender/compositor/nodes/COM_RotateNode.h
+++ b/source/blender/compositor/nodes/COM_RotateNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_ROTATENODE_H__
-#define __COM_ROTATENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class RotateNode : public Node {
RotateNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.h b/source/blender/compositor/nodes/COM_ScaleNode.h
index b6e589cfcec..c9a02411b1c 100644
--- a/source/blender/compositor/nodes/COM_ScaleNode.h
+++ b/source/blender/compositor/nodes/COM_ScaleNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SCALENODE_H__
-#define __COM_SCALENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ScaleNode : public Node {
ScaleNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateColorNode.h b/source/blender/compositor/nodes/COM_SeparateColorNode.h
index f98a9d6d12f..aaf86c6e22b 100644
--- a/source/blender/compositor/nodes/COM_SeparateColorNode.h
+++ b/source/blender/compositor/nodes/COM_SeparateColorNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SEPARATECOLORNODE_H__
-#define __COM_SEPARATECOLORNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -65,5 +64,3 @@ class SeparateYUVANode : public SeparateColorNode {
NodeOperation *getColorConverter(const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.h b/source/blender/compositor/nodes/COM_SetAlphaNode.h
index 9882b3e62e9..2e652539cec 100644
--- a/source/blender/compositor/nodes/COM_SetAlphaNode.h
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SETALPHANODE_H__
-#define __COM_SETALPHANODE_H__
+#pragma once
#include "COM_Node.h"
@@ -32,5 +31,3 @@ class SetAlphaNode : public Node {
}
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.h b/source/blender/compositor/nodes/COM_SocketProxyNode.h
index 21e888d323e..a0c0b63dafd 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.h
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SOCKETPROXYNODE_H__
-#define __COM_SOCKETPROXYNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -52,5 +51,3 @@ class SocketBufferNode : public Node {
SocketBufferNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.h b/source/blender/compositor/nodes/COM_SplitViewerNode.h
index 2e350720841..c9ce5164ef4 100644
--- a/source/blender/compositor/nodes/COM_SplitViewerNode.h
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SPLITVIEWERNODE_H__
-#define __COM_SPLITVIEWERNODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -30,4 +29,3 @@ class SplitViewerNode : public Node {
SplitViewerNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
index 7a308ac47b9..38db080a154 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
@@ -82,17 +82,32 @@ void Stabilize2dNode::convertToOperations(NodeConverter &converter,
converter.addOperation(rotateOperation);
converter.addOperation(psoperation);
- converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
- converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
- converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
- converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket());
+
+ if (invert) {
+ // Translate -> Rotate -> Scale.
+ converter.mapInputSocket(imageInput, translateOperation->getInputSocket(0));
+
+ converter.addLink(translateOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
+ converter.addLink(rotateOperation->getOutputSocket(), scaleOperation->getInputSocket(0));
+
+ converter.addLink(scaleOperation->getOutputSocket(), psoperation->getInputSocket(0));
+ }
+ else {
+ // Scale -> Rotate -> Translate.
+ converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
+
+ converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
+ converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
+
+ converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
+ }
}
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.h b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
index bbf7b239d82..cb46926a3f3 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.h
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_STABILIZE2DNODE_H__
-#define __COM_STABILIZE2DNODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -31,5 +30,3 @@ class Stabilize2dNode : public Node {
Stabilize2dNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_SunBeamsNode.h b/source/blender/compositor/nodes/COM_SunBeamsNode.h
index 9d35f40f760..9a56fc1fcea 100644
--- a/source/blender/compositor/nodes/COM_SunBeamsNode.h
+++ b/source/blender/compositor/nodes/COM_SunBeamsNode.h
@@ -15,8 +15,7 @@
* Copyright 2014, Blender Foundation.
*/
-#ifndef __COM_SUNBEAMSNODE_H__
-#define __COM_SUNBEAMSNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -29,5 +28,3 @@ class SunBeamsNode : public Node {
SunBeamsNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.h b/source/blender/compositor/nodes/COM_SwitchNode.h
index 509b748b18a..d4d8dd23a98 100644
--- a/source/blender/compositor/nodes/COM_SwitchNode.h
+++ b/source/blender/compositor/nodes/COM_SwitchNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SWITCHNODE_H__
-#define __COM_SWITCHNODE_H__
+#pragma once
#include "COM_Node.h"
#include "COM_NodeOperation.h"
@@ -31,4 +30,3 @@ class SwitchNode : public Node {
SwitchNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif
diff --git a/source/blender/compositor/nodes/COM_SwitchViewNode.h b/source/blender/compositor/nodes/COM_SwitchViewNode.h
index 0260621961d..9423740f668 100644
--- a/source/blender/compositor/nodes/COM_SwitchViewNode.h
+++ b/source/blender/compositor/nodes/COM_SwitchViewNode.h
@@ -16,8 +16,7 @@
* Copyright 2015, Blender Foundation.
*/
-#ifndef __COM_SWITCHVIEWNODE_H__
-#define __COM_SWITCHVIEWNODE_H__
+#pragma once
#include "COM_Node.h"
#include "COM_NodeOperation.h"
@@ -31,4 +30,3 @@ class SwitchViewNode : public Node {
SwitchViewNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif
diff --git a/source/blender/compositor/nodes/COM_TextureNode.h b/source/blender/compositor/nodes/COM_TextureNode.h
index 8fe620a89b3..4d780850190 100644
--- a/source/blender/compositor/nodes/COM_TextureNode.h
+++ b/source/blender/compositor/nodes/COM_TextureNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_TEXTURENODE_H__
-#define __COM_TEXTURENODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -31,5 +30,3 @@ class TextureNode : public Node {
TextureNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_TEXTURENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp
index 9722ead0716..247e0d11df6 100644
--- a/source/blender/compositor/nodes/COM_TimeNode.cpp
+++ b/source/blender/compositor/nodes/COM_TimeNode.cpp
@@ -49,7 +49,7 @@ void TimeNode::convertToOperations(NodeConverter &converter,
fac = (context.getFramenumber() - node->custom1) / (float)(node->custom2 - node->custom1);
}
- BKE_curvemapping_initialize((CurveMapping *)node->storage);
+ BKE_curvemapping_init((CurveMapping *)node->storage);
fac = BKE_curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac);
operation->setValue(clamp_f(fac, 0.0f, 1.0f));
converter.addOperation(operation);
diff --git a/source/blender/compositor/nodes/COM_TimeNode.h b/source/blender/compositor/nodes/COM_TimeNode.h
index 230ffe3b676..78177014dc1 100644
--- a/source/blender/compositor/nodes/COM_TimeNode.h
+++ b/source/blender/compositor/nodes/COM_TimeNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_TIMENODE_H__
-#define __COM_TIMENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class TimeNode : public Node {
TimeNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_TonemapNode.h b/source/blender/compositor/nodes/COM_TonemapNode.h
index 9e6c01a5e45..d934a1ede5b 100644
--- a/source/blender/compositor/nodes/COM_TonemapNode.h
+++ b/source/blender/compositor/nodes/COM_TonemapNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_TONEMAPNODE_H__
-#define __COM_TONEMAPNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class TonemapNode : public Node {
TonemapNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_TrackPositionNode.h b/source/blender/compositor/nodes/COM_TrackPositionNode.h
index 7136077a123..37d3d25d592 100644
--- a/source/blender/compositor/nodes/COM_TrackPositionNode.h
+++ b/source/blender/compositor/nodes/COM_TrackPositionNode.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_TRACKPOSITIONNODE_H__
-#define __COM_TRACKPOSITIONNODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -31,5 +30,3 @@ class TrackPositionNode : public Node {
TrackPositionNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_TRACKPOSITIONNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_TransformNode.h b/source/blender/compositor/nodes/COM_TransformNode.h
index 12eb66a19bb..bd01808d662 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.h
+++ b/source/blender/compositor/nodes/COM_TransformNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_TRANSFORMNODE_H__
-#define __COM_TRANSFORMNODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -31,5 +30,3 @@ class TransformNode : public Node {
TransformNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif /* __COM_TRANSFORMNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.h b/source/blender/compositor/nodes/COM_TranslateNode.h
index d9ef6c639a0..d381274c0e5 100644
--- a/source/blender/compositor/nodes/COM_TranslateNode.h
+++ b/source/blender/compositor/nodes/COM_TranslateNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_TRANSLATENODE_H__
-#define __COM_TRANSLATENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class TranslateNode : public Node {
TranslateNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_ValueNode.h b/source/blender/compositor/nodes/COM_ValueNode.h
index a973649aa46..5179e6828e4 100644
--- a/source/blender/compositor/nodes/COM_ValueNode.h
+++ b/source/blender/compositor/nodes/COM_ValueNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_VALUENODE_H__
-#define __COM_VALUENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ValueNode : public Node {
ValueNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.h b/source/blender/compositor/nodes/COM_VectorBlurNode.h
index 027c241f72d..f370c82a1ee 100644
--- a/source/blender/compositor/nodes/COM_VectorBlurNode.h
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_VECTORBLURNODE_H__
-#define __COM_VECTORBLURNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class VectorBlurNode : public Node {
VectorBlurNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.h b/source/blender/compositor/nodes/COM_VectorCurveNode.h
index 14bea25cf8d..4d7f92897a1 100644
--- a/source/blender/compositor/nodes/COM_VectorCurveNode.h
+++ b/source/blender/compositor/nodes/COM_VectorCurveNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_VECTORCURVENODE_H__
-#define __COM_VECTORCURVENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class VectorCurveNode : public Node {
VectorCurveNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.h b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
index 851b1ecbd78..0e931fed055 100644
--- a/source/blender/compositor/nodes/COM_ViewLevelsNode.h
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_VIEWLEVELSNODE_H__
-#define __COM_VIEWLEVELSNODE_H__
+#pragma once
#include "COM_Node.h"
@@ -30,5 +29,3 @@ class ViewLevelsNode : public Node {
ViewLevelsNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.h b/source/blender/compositor/nodes/COM_ViewerNode.h
index 6168623e69c..74758417014 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.h
+++ b/source/blender/compositor/nodes/COM_ViewerNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_VIEWERNODE_H__
-#define __COM_VIEWERNODE_H__
+#pragma once
#include "COM_Node.h"
#include "DNA_node_types.h"
@@ -30,4 +29,3 @@ class ViewerNode : public Node {
ViewerNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.h b/source/blender/compositor/nodes/COM_ZCombineNode.h
index 95e81ca8c8f..ca54fd7fffa 100644
--- a/source/blender/compositor/nodes/COM_ZCombineNode.h
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_ZCOMBINENODE_H__
-#define __COM_ZCOMBINENODE_H__
+#pragma once
#include "COM_Node.h"
@@ -32,5 +31,3 @@ class ZCombineNode : public Node {
}
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
index a4475bc2fbc..de3d6bd1ee0 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_ALPHAOVERKEYOPERATION_H__
-#define __COM_ALPHAOVERKEYOPERATION_H__
+#pragma once
+
#include "COM_MixOperation.h"
/**
@@ -36,4 +36,3 @@ class AlphaOverKeyOperation : public MixBaseOperation {
*/
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
index 88fa3d963f4..22d64807512 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_ALPHAOVERMIXEDOPERATION_H__
-#define __COM_ALPHAOVERMIXEDOPERATION_H__
+#pragma once
+
#include "COM_MixOperation.h"
/**
@@ -44,4 +44,3 @@ class AlphaOverMixedOperation : public MixBaseOperation {
this->m_x = x;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
index 4ef5f9d996e..bc5cd07baf8 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_ALPHAOVERPREMULTIPLYOPERATION_H__
-#define __COM_ALPHAOVERPREMULTIPLYOPERATION_H__
+#pragma once
+
#include "COM_MixOperation.h"
/**
@@ -36,4 +36,3 @@ class AlphaOverPremultiplyOperation : public MixBaseOperation {
*/
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
index 85725cc1d37..2c762323104 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
@@ -105,9 +105,9 @@ static int extrapolate9(float *E0,
}
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
+
#undef PEQ
#undef PCPY
}
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.h b/source/blender/compositor/operations/COM_AntiAliasOperation.h
index 6141fb92c3f..8600c6dd481 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.h
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_ANTIALIASOPERATION_H__
-#define __COM_ANTIALIASOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
@@ -56,4 +56,3 @@ class AntiAliasOperation : public NodeOperation {
ReadBufferOperation *readOperation,
rcti *output);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.h b/source/blender/compositor/operations/COM_BilateralBlurOperation.h
index c3482005d8c..a54e830459b 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.h
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BILATERALBLUROPERATION_H__
-#define __COM_BILATERALBLUROPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "COM_QualityStepHelper.h"
@@ -55,4 +55,3 @@ class BilateralBlurOperation : public NodeOperation, public QualityStepHelper {
this->m_data = data;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h
index 07893c19126..e4ac8b3c874 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.h
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BLURBASEOPERATION_H__
-#define __COM_BLURBASEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "COM_QualityStepHelper.h"
@@ -77,4 +77,3 @@ class BlurBaseOperation : public NodeOperation, public QualityStepHelper {
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h
index 4f594f16cb4..e6873a4b70b 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BOKEHBLUROPERATION_H__
-#define __COM_BOKEHBLUROPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
#include "COM_QualityStepHelper.h"
@@ -78,4 +77,3 @@ class BokehBlurOperation : public NodeOperation, public QualityStepHelper {
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h
index e907559d6e7..db1d3976d44 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.h
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BOKEHIMAGEOPERATION_H__
-#define __COM_BOKEHIMAGEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -149,4 +149,3 @@ class BokehImageOperation : public NodeOperation {
this->m_deleteData = true;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.h b/source/blender/compositor/operations/COM_BoxMaskOperation.h
index f770922ee7c..070a7f52b1b 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.h
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BOXMASKOPERATION_H__
-#define __COM_BOXMASKOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class BoxMaskOperation : public NodeOperation {
@@ -63,4 +63,3 @@ class BoxMaskOperation : public NodeOperation {
this->m_maskType = maskType;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.h b/source/blender/compositor/operations/COM_BrightnessOperation.h
index df6b3ef7b6e..28bd3576201 100644
--- a/source/blender/compositor/operations/COM_BrightnessOperation.h
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_BRIGHTNESSOPERATION_H__
-#define __COM_BRIGHTNESSOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class BrightnessOperation : public NodeOperation {
@@ -51,4 +51,3 @@ class BrightnessOperation : public NodeOperation {
void setUsePremultiply(bool use_premultiply);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.h b/source/blender/compositor/operations/COM_CalculateMeanOperation.h
index 38d68b2a6fd..aa08555467b 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.h
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CALCULATEMEANOPERATION_H__
-#define __COM_CALCULATEMEANOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
@@ -67,4 +67,3 @@ class CalculateMeanOperation : public NodeOperation {
protected:
void calculateMean(MemoryBuffer *tile);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
index 377276777f0..2ab0e82728d 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CALCULATESTANDARDDEVIATIONOPERATION_H__
-#define __COM_CALCULATESTANDARDDEVIATIONOPERATION_H__
+#pragma once
+
#include "COM_CalculateMeanOperation.h"
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
@@ -40,4 +40,3 @@ class CalculateStandardDeviationOperation : public CalculateMeanOperation {
void *initializeTileData(rcti *rect);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
index 3898345f922..b4fa1a3bdd4 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CHANGEHSVOPERATION_H__
-#define __COM_CHANGEHSVOPERATION_H__
+#pragma once
+
#include "COM_MixOperation.h"
/**
@@ -45,4 +45,3 @@ class ChangeHSVOperation : public NodeOperation {
*/
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h
index ad88b41cc91..d4c097fe66e 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h
@@ -16,8 +16,8 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_CHANNELMATTEOPERATION_H__
-#define __COM_CHANNELMATTEOPERATION_H__
+#pragma once
+
#include "COM_MixOperation.h"
/**
@@ -70,4 +70,3 @@ class ChannelMatteOperation : public NodeOperation {
this->m_matte_channel = custom2;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.h b/source/blender/compositor/operations/COM_ChromaMatteOperation.h
index 58da839823d..5c4ada8de38 100644
--- a/source/blender/compositor/operations/COM_ChromaMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CHROMAMATTEOPERATION_H__
-#define __COM_CHROMAMATTEOPERATION_H__
+#pragma once
+
#include "COM_MixOperation.h"
/**
@@ -49,4 +49,3 @@ class ChromaMatteOperation : public NodeOperation {
this->m_settings = nodeChroma;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
index fd1d51a293b..77ead2f1d26 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORBALANCEASCCDLOPERATION_H__
-#define __COM_COLORBALANCEASCCDLOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -70,4 +70,3 @@ class ColorBalanceASCCDLOperation : public NodeOperation {
copy_v3_v3(this->m_slope, slope);
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
index a2d4b4cd13a..c34591172b9 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORBALANCELGGOPERATION_H__
-#define __COM_COLORBALANCELGGOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -70,4 +70,3 @@ class ColorBalanceLGGOperation : public NodeOperation {
copy_v3_v3(this->m_gamma_inv, gamma_inv);
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
index ec9632acc7c..66213eb88a4 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORCORRECTIONOPERATION_H__
-#define __COM_COLORCORRECTIONOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class ColorCorrectionOperation : public NodeOperation {
@@ -68,4 +68,3 @@ class ColorCorrectionOperation : public NodeOperation {
this->m_blueChannelEnabled = enabled;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h
index 7869d1c4a56..65a822508b8 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.h
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORCURVEOPERATION_H__
-#define __COM_COLORCURVEOPERATION_H__
+#pragma once
+
#include "COM_CurveBaseOperation.h"
#include "COM_NodeOperation.h"
#include "DNA_color_types.h"
@@ -88,5 +88,3 @@ class ConstantLevelColorCurveOperation : public CurveBaseOperation {
copy_v3_v3(this->m_white, white);
}
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h
index 7e8a0e295e1..bb00c344606 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORMATTEOPERATION_H__
-#define __COM_COLORMATTEOPERATION_H__
+#pragma once
+
#include "COM_MixOperation.h"
/**
@@ -49,4 +49,3 @@ class ColorMatteOperation : public NodeOperation {
this->m_settings = nodeChroma;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.h b/source/blender/compositor/operations/COM_ColorRampOperation.h
index 3e2acda1d10..b4253a3f074 100644
--- a/source/blender/compositor/operations/COM_ColorRampOperation.h
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORRAMPOPERATION_H__
-#define __COM_COLORRAMPOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_texture_types.h"
@@ -52,4 +52,3 @@ class ColorRampOperation : public NodeOperation {
this->m_colorBand = colorBand;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h
index 73f4f5b045d..560d198693f 100644
--- a/source/blender/compositor/operations/COM_ColorSpillOperation.h
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COLORSPILLOPERATION_H__
-#define __COM_COLORSPILLOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -64,5 +64,3 @@ class ColorSpillOperation : public NodeOperation {
float calculateMapValue(float fac, float *input);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index 71cef9dc4da..8d55fe53aa7 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -65,11 +65,11 @@ void CompositorOperation::initExecution()
this->m_depthInput = getInputSocketReader(2);
if (this->getWidth() * this->getHeight() != 0) {
this->m_outputBuffer = (float *)MEM_callocN(
- this->getWidth() * this->getHeight() * 4 * sizeof(float), "CompositorOperation");
+ sizeof(float[4]) * this->getWidth() * this->getHeight(), "CompositorOperation");
}
if (this->m_depthInput != NULL) {
this->m_depthBuffer = (float *)MEM_callocN(
- this->getWidth() * this->getHeight() * sizeof(float), "CompositorOperation");
+ sizeof(float) * this->getWidth() * this->getHeight(), "CompositorOperation");
}
}
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h
index 8db8fe00d3c..3633bfd511c 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.h
+++ b/source/blender/compositor/operations/COM_CompositorOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_COMPOSITOROPERATION_H__
-#define __COM_COMPOSITOROPERATION_H__
+#pragma once
+
#include "BLI_rect.h"
#include "BLI_string.h"
#include "COM_NodeOperation.h"
@@ -123,4 +123,3 @@ class CompositorOperation : public NodeOperation {
this->m_active = active;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
index 7cc39a47dd0..8fce5ef3e1a 100644
--- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CONVERTCOLORPROFILEOPERATION_H__
-#define __COM_CONVERTCOLORPROFILEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -80,4 +80,3 @@ class ConvertColorProfileOperation : public NodeOperation {
this->m_predivided = predivided;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
index 66043abd951..50f8eab5fbc 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
@@ -39,9 +39,8 @@ float ConvertDepthToRadiusOperation::determineFocalDistance()
this->m_cam_lens = camera->lens;
return BKE_camera_object_dof_distance(this->m_cameraObject);
}
- else {
- return 10.0f;
- }
+
+ return 10.0f;
}
void ConvertDepthToRadiusOperation::initExecution()
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
index 7c3e0ed9738..3babcfe4dc3 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CONVERTDEPTHTORADIUSOPERATION_H__
-#define __COM_CONVERTDEPTHTORADIUSOPERATION_H__
+#pragma once
+
#include "COM_FastGaussianBlurOperation.h"
#include "COM_NodeOperation.h"
#include "DNA_object_types.h"
@@ -81,4 +81,3 @@ class ConvertDepthToRadiusOperation : public NodeOperation {
this->m_blurPostOperation = operation;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.h b/source/blender/compositor/operations/COM_ConvertOperation.h
index a4cf05372a5..ca026528a38 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CONVERTOPERATION_H__
-#define __COM_CONVERTOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -183,5 +182,3 @@ class CombineChannelsOperation : public NodeOperation {
void initExecution();
void deinitExecution();
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
index 17509b018bf..ab4b8a1dad1 100644
--- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
+++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CONVOLUTIONEDGEFILTEROPERATION_H__
-#define __COM_CONVOLUTIONEDGEFILTEROPERATION_H__
+#pragma once
#include "COM_ConvolutionFilterOperation.h"
@@ -26,5 +25,3 @@ class ConvolutionEdgeFilterOperation : public ConvolutionFilterOperation {
ConvolutionEdgeFilterOperation();
void executePixel(float output[4], int x, int y, void *data);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
index 78db5a5ae9d..d178b0a7418 100644
--- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CONVOLUTIONFILTEROPERATION_H__
-#define __COM_CONVOLUTIONFILTEROPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -43,5 +42,3 @@ class ConvolutionFilterOperation : public NodeOperation {
void initExecution();
void deinitExecution();
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h
index 36c18d29e92..f20664f0501 100644
--- a/source/blender/compositor/operations/COM_CropOperation.h
+++ b/source/blender/compositor/operations/COM_CropOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CROPOPERATION_H__
-#define __COM_CROPOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -64,4 +63,3 @@ class CropImageOperation : public CropBaseOperation {
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.h b/source/blender/compositor/operations/COM_CryptomatteOperation.h
index 459d8b65f12..8c5a3134720 100644
--- a/source/blender/compositor/operations/COM_CryptomatteOperation.h
+++ b/source/blender/compositor/operations/COM_CryptomatteOperation.h
@@ -16,8 +16,8 @@
* Copyright 2018, Blender Foundation.
*/
-#ifndef __COM_CRYPTOMATTEOPERATION_H__
-#define __COM_CRYPTOMATTEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class CryptomatteOperation : public NodeOperation {
@@ -34,4 +34,3 @@ class CryptomatteOperation : public NodeOperation {
void addObjectIndex(float objectIndex);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
index b18e77cf0e3..855f728f7bf 100644
--- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
@@ -35,7 +35,7 @@ CurveBaseOperation::~CurveBaseOperation()
void CurveBaseOperation::initExecution()
{
- BKE_curvemapping_initialize(this->m_curveMapping);
+ BKE_curvemapping_init(this->m_curveMapping);
}
void CurveBaseOperation::deinitExecution()
{
diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.h b/source/blender/compositor/operations/COM_CurveBaseOperation.h
index f42ce3c366f..63e667cfe12 100644
--- a/source/blender/compositor/operations/COM_CurveBaseOperation.h
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_CURVEBASEOPERATION_H__
-#define __COM_CURVEBASEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_color_types.h"
@@ -40,4 +40,3 @@ class CurveBaseOperation : public NodeOperation {
void setCurveMapping(CurveMapping *mapping);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_DenoiseOperation.cpp b/source/blender/compositor/operations/COM_DenoiseOperation.cpp
index d9a59002caf..4087056a79d 100644
--- a/source/blender/compositor/operations/COM_DenoiseOperation.cpp
+++ b/source/blender/compositor/operations/COM_DenoiseOperation.cpp
@@ -73,14 +73,13 @@ bool DenoiseOperation::determineDependingAreaOfInterest(rcti * /*input*/,
if (isCached()) {
return false;
}
- else {
- rcti newInput;
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+
+ rcti newInput;
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void DenoiseOperation::generateDenoise(float *data,
@@ -106,7 +105,7 @@ void DenoiseOperation::generateDenoise(float *data,
inputTileColor->getWidth(),
inputTileColor->getHeight(),
0,
- 4 * sizeof(float));
+ sizeof(float[4]));
if (inputTileNormal && inputTileNormal->getBuffer()) {
filter.setImage("normal",
inputTileNormal->getBuffer(),
@@ -114,7 +113,7 @@ void DenoiseOperation::generateDenoise(float *data,
inputTileNormal->getWidth(),
inputTileNormal->getHeight(),
0,
- 3 * sizeof(float));
+ sizeof(float[3]));
}
if (inputTileAlbedo && inputTileAlbedo->getBuffer()) {
filter.setImage("albedo",
@@ -123,7 +122,7 @@ void DenoiseOperation::generateDenoise(float *data,
inputTileAlbedo->getWidth(),
inputTileAlbedo->getHeight(),
0,
- 4 * sizeof(float));
+ sizeof(float[4]));
}
filter.setImage("output",
data,
@@ -131,7 +130,7 @@ void DenoiseOperation::generateDenoise(float *data,
inputTileColor->getWidth(),
inputTileColor->getHeight(),
0,
- 4 * sizeof(float));
+ sizeof(float[4]));
BLI_assert(settings);
if (settings) {
@@ -159,5 +158,5 @@ void DenoiseOperation::generateDenoise(float *data,
UNUSED_VARS(inputTileAlbedo, inputTileNormal, settings);
::memcpy(data,
inputBufferColor,
- inputTileColor->getWidth() * inputTileColor->getHeight() * sizeof(float) * 4);
+ sizeof(float[4]) * inputTileColor->getWidth() * inputTileColor->getHeight());
}
diff --git a/source/blender/compositor/operations/COM_DenoiseOperation.h b/source/blender/compositor/operations/COM_DenoiseOperation.h
index 6a53eead65c..5af6e16c958 100644
--- a/source/blender/compositor/operations/COM_DenoiseOperation.h
+++ b/source/blender/compositor/operations/COM_DenoiseOperation.h
@@ -16,8 +16,7 @@
* Copyright 2019, Blender Foundation.
*/
-#ifndef __COM_DENOISEOPERATION_H__
-#define __COM_DENOISEOPERATION_H__
+#pragma once
#include "COM_SingleThreadedOperation.h"
#include "DNA_node_types.h"
@@ -65,5 +64,3 @@ class DenoiseOperation : public SingleThreadedOperation {
MemoryBuffer *createMemoryBuffer(rcti *rect);
};
-
-#endif /* __COM_DENOISEOPERATION_H__ */
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.h b/source/blender/compositor/operations/COM_DespeckleOperation.h
index 280948b7fbe..af37c276bd2 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.h
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DESPECKLEOPERATION_H__
-#define __COM_DESPECKLEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class DespeckleOperation : public NodeOperation {
@@ -51,5 +51,3 @@ class DespeckleOperation : public NodeOperation {
void initExecution();
void deinitExecution();
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
index e96e212e511..beaa4400712 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DIFFERENCEMATTEOPERATION_H__
-#define __COM_DIFFERENCEMATTEOPERATION_H__
+#pragma once
+
#include "COM_MixOperation.h"
/**
@@ -49,4 +49,3 @@ class DifferenceMatteOperation : public NodeOperation {
this->m_settings = nodeChroma;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.h b/source/blender/compositor/operations/COM_DilateErodeOperation.h
index bd7e0938c58..95a799ab648 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.h
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DILATEERODEOPERATION_H__
-#define __COM_DILATEERODEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class DilateErodeThresholdOperation : public NodeOperation {
@@ -180,5 +180,3 @@ class ErodeStepOperation : public DilateStepOperation {
void *initializeTileData(rcti *rect);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
index f8b7bab010b..57fc0bb7fa3 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DIRECTIONALBLUROPERATION_H__
-#define __COM_DIRECTIONALBLUROPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "COM_QualityStepHelper.h"
@@ -64,4 +64,3 @@ class DirectionalBlurOperation : public NodeOperation, public QualityStepHelper
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> *clKernelsToCleanUp);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
index b775bfdee4c..73790447216 100644
--- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
@@ -74,13 +74,12 @@ bool DisplaceOperation::read_displacement(
r_v = 0.0f;
return false;
}
- else {
- float col[4];
- m_inputVectorProgram->readSampled(col, x, y, COM_PS_BILINEAR);
- r_u = origin[0] - col[0] * xscale;
- r_v = origin[1] - col[1] * yscale;
- return true;
- }
+
+ float col[4];
+ m_inputVectorProgram->readSampled(col, x, y, COM_PS_BILINEAR);
+ r_u = origin[0] - col[0] * xscale;
+ r_v = origin[1] - col[1] * yscale;
+ return true;
}
void DisplaceOperation::pixelTransform(const float xy[2], float r_uv[2], float r_deriv[2][2])
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.h b/source/blender/compositor/operations/COM_DisplaceOperation.h
index 4e44572fcf2..ee06bf320a6 100644
--- a/source/blender/compositor/operations/COM_DisplaceOperation.h
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DISPLACEOPERATION_H__
-#define __COM_DISPLACEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class DisplaceOperation : public NodeOperation {
@@ -64,4 +64,3 @@ class DisplaceOperation : public NodeOperation {
bool read_displacement(
float x, float y, float xscale, float yscale, const float origin[2], float &r_u, float &r_v);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
index 6d4d6047137..6930985b0e5 100644
--- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
@@ -16,8 +16,8 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_DISPLACESIMPLEOPERATION_H__
-#define __COM_DISPLACESIMPLEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class DisplaceSimpleOperation : public NodeOperation {
@@ -58,4 +58,3 @@ class DisplaceSimpleOperation : public NodeOperation {
*/
void deinitExecution();
};
-#endif
diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h
index c64c6da8d24..d99ab262c18 100644
--- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h
+++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DISTANCERGBMATTEOPERATION_H__
-#define __COM_DISTANCERGBMATTEOPERATION_H__
+#pragma once
+
#include "COM_MixOperation.h"
/**
@@ -51,4 +51,3 @@ class DistanceRGBMatteOperation : public NodeOperation {
this->m_settings = nodeChroma;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h
index 1cb477bc05d..e9b2cda6251 100644
--- a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h
+++ b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DISTANCEYCCMATTEOPERATION_H__
-#define __COM_DISTANCEYCCMATTEOPERATION_H__
+#pragma once
+
#include "COM_DistanceRGBMatteOperation.h"
#include "COM_MixOperation.h"
@@ -35,4 +35,3 @@ class DistanceYCCMatteOperation : public DistanceRGBMatteOperation {
*/
DistanceYCCMatteOperation();
};
-#endif
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.h b/source/blender/compositor/operations/COM_DotproductOperation.h
index 9ef9753f4c9..63b735ce30f 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.h
+++ b/source/blender/compositor/operations/COM_DotproductOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DOTPRODUCTOPERATION_H__
-#define __COM_DOTPRODUCTOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -33,5 +32,3 @@ class DotproductOperation : public NodeOperation {
void initExecution();
void deinitExecution();
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
index 84f7fe2d225..675a402de6f 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
@@ -1330,9 +1330,8 @@ bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti * /*input*/,
newInput.ymin = 0;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
- else {
- return false;
- }
+
+ return false;
}
void DoubleEdgeMaskOperation::initExecution()
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
index 40cfa370cb7..0c77e83daec 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_DOUBLEEDGEMASKOPERATION_H__
-#define __COM_DOUBLEEDGEMASKOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class DoubleEdgeMaskOperation : public NodeOperation {
@@ -65,4 +65,3 @@ class DoubleEdgeMaskOperation : public NodeOperation {
this->m_keepInside = keepInside;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.h b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
index b73a35a5452..2e6b1f782a1 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.h
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_ELLIPSEMASKOPERATION_H__
-#define __COM_ELLIPSEMASKOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class EllipseMaskOperation : public NodeOperation {
@@ -63,4 +63,3 @@ class EllipseMaskOperation : public NodeOperation {
this->m_maskType = maskType;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index 7a6b69d12fa..0ccb959712f 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -47,18 +47,17 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
}
- else {
- if (this->m_iirgaus) {
- return false;
- }
- else {
- newInput.xmin = 0;
- newInput.ymin = 0;
- newInput.xmax = this->getWidth();
- newInput.ymax = this->getHeight();
- }
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+
+ if (this->m_iirgaus) {
+ return false;
}
+
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void FastGaussianBlurOperation::initExecution()
@@ -282,12 +281,12 @@ bool FastGaussianBlurValueOperation::determineDependingAreaOfInterest(
if (this->m_iirgaus) {
return false;
}
- else {
- newInput.xmin = 0;
- newInput.ymin = 0;
- newInput.xmax = this->getWidth();
- newInput.ymax = this->getHeight();
- }
+
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
index 22f9a6f9cf2..6ab6474c20a 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_FASTGAUSSIANBLUROPERATION_H__
-#define __COM_FASTGAUSSIANBLUROPERATION_H__
+#pragma once
#include "COM_BlurBaseOperation.h"
#include "DNA_node_types.h"
@@ -80,5 +79,3 @@ class FastGaussianBlurValueOperation : public NodeOperation {
this->m_overlay = overlay;
}
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_FlipOperation.h b/source/blender/compositor/operations/COM_FlipOperation.h
index 2d00c50dc8a..711b51261e6 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.h
+++ b/source/blender/compositor/operations/COM_FlipOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_FLIPOPERATION_H__
-#define __COM_FLIPOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -45,5 +44,3 @@ class FlipOperation : public NodeOperation {
this->m_flipY = flipY;
}
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.h b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
index 26e31df880f..be57e279ac8 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.h
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GAMMACORRECTOPERATION_H__
-#define __COM_GAMMACORRECTOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class GammaCorrectOperation : public NodeOperation {
@@ -71,5 +71,3 @@ class GammaUncorrectOperation : public NodeOperation {
*/
void deinitExecution();
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_GammaOperation.h b/source/blender/compositor/operations/COM_GammaOperation.h
index ba0b84db931..493fdb1f889 100644
--- a/source/blender/compositor/operations/COM_GammaOperation.h
+++ b/source/blender/compositor/operations/COM_GammaOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GAMMAOPERATION_H__
-#define __COM_GAMMAOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class GammaOperation : public NodeOperation {
@@ -46,4 +46,3 @@ class GammaOperation : public NodeOperation {
*/
void deinitExecution();
};
-#endif
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
index 9de75ff53a7..a8e1ddfb885 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GAUSSIANALPHAXBLUROPERATION_H__
-#define __COM_GAUSSIANALPHAXBLUROPERATION_H__
+#pragma once
+
#include "COM_BlurBaseOperation.h"
#include "COM_NodeOperation.h"
@@ -65,4 +65,3 @@ class GaussianAlphaXBlurOperation : public BlurBaseOperation {
this->m_falloff = falloff;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
index 44689922bfc..df34f15fccc 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GAUSSIANALPHAYBLUROPERATION_H__
-#define __COM_GAUSSIANALPHAYBLUROPERATION_H__
+#pragma once
+
#include "COM_BlurBaseOperation.h"
#include "COM_NodeOperation.h"
@@ -65,4 +65,3 @@ class GaussianAlphaYBlurOperation : public BlurBaseOperation {
this->m_falloff = falloff;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
index 43e571c4bb7..dd479da864c 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -176,23 +176,22 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
}
+
+ if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+ }
else {
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
- newInput.xmin = 0;
- newInput.ymin = 0;
- newInput.xmax = this->getWidth();
- newInput.ymax = this->getHeight();
- }
- else {
- int addx = this->m_radx;
- int addy = this->m_rady;
- newInput.xmax = input->xmax + addx;
- newInput.xmin = input->xmin - addx;
- newInput.ymax = input->ymax + addy;
- newInput.ymin = input->ymin - addy;
- }
- return BlurBaseOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ int addx = this->m_radx;
+ int addy = this->m_rady;
+ newInput.xmax = input->xmax + addx;
+ newInput.xmin = input->xmin - addx;
+ newInput.ymax = input->ymax + addy;
+ newInput.ymin = input->ymin - addy;
}
+ return BlurBaseOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
// reference image
@@ -351,13 +350,12 @@ bool GaussianBlurReferenceOperation::determineDependingAreaOfInterest(
if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
return true;
}
- else {
- int addx = this->m_data.sizex + 2;
- int addy = this->m_data.sizey + 2;
- newInput.xmax = input->xmax + addx;
- newInput.xmin = input->xmin - addx;
- newInput.ymax = input->ymax + addy;
- newInput.ymin = input->ymin - addy;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+
+ int addx = this->m_data.sizex + 2;
+ int addy = this->m_data.sizey + 2;
+ newInput.xmax = input->xmax + addx;
+ newInput.xmin = input->xmin - addx;
+ newInput.ymax = input->ymax + addy;
+ newInput.ymin = input->ymin - addy;
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
index 3aa380853bd..b4b5c0e8b2f 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GAUSSIANBOKEHBLUROPERATION_H__
-#define __COM_GAUSSIANBOKEHBLUROPERATION_H__
+#pragma once
+
#include "COM_BlurBaseOperation.h"
#include "COM_NodeOperation.h"
#include "COM_QualityStepHelper.h"
@@ -75,5 +75,3 @@ class GaussianBlurReferenceOperation : public BlurBaseOperation {
ReadBufferOperation *readOperation,
rcti *output);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
index c5c08df8ce7..1bd6ef20a48 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GAUSSIANXBLUROPERATION_H__
-#define __COM_GAUSSIANXBLUROPERATION_H__
+#pragma once
+
#include "COM_BlurBaseOperation.h"
#include "COM_NodeOperation.h"
@@ -65,4 +65,3 @@ class GaussianXBlurOperation : public BlurBaseOperation {
this->setOpenCL(m_data.sizex >= 128);
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
index 92154aa7518..a9af28791f8 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GAUSSIANYBLUROPERATION_H__
-#define __COM_GAUSSIANYBLUROPERATION_H__
+#pragma once
+
#include "COM_BlurBaseOperation.h"
#include "COM_NodeOperation.h"
@@ -65,4 +65,3 @@ class GaussianYBlurOperation : public BlurBaseOperation {
this->setOpenCL(m_data.sizex >= 128);
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
index 593f1eaeefa..278e65a7dfd 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
@@ -58,12 +58,11 @@ bool GlareBaseOperation::determineDependingAreaOfInterest(rcti * /*input*/,
if (isCached()) {
return false;
}
- else {
- rcti newInput;
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+
+ rcti newInput;
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.h b/source/blender/compositor/operations/COM_GlareBaseOperation.h
index ba2b9a8f4b8..aabb76f5cf0 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.h
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GLAREBASEOPERATION_H__
-#define __COM_GLAREBASEOPERATION_H__
+#pragma once
#include "COM_SingleThreadedOperation.h"
#include "DNA_node_types.h"
@@ -74,4 +73,3 @@ class GlareBaseOperation : public SingleThreadedOperation {
MemoryBuffer *createMemoryBuffer(rcti *rect);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.h b/source/blender/compositor/operations/COM_GlareFogGlowOperation.h
index dae0b714e56..9084f27052e 100644
--- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.h
+++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GLAREFOGGLOWOPERATION_H__
-#define __COM_GLAREFOGGLOWOPERATION_H__
+#pragma once
+
#include "COM_GlareBaseOperation.h"
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
@@ -31,4 +31,3 @@ class GlareFogGlowOperation : public GlareBaseOperation {
protected:
void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
index 9f01cf5d63a..760b833d1e1 100644
--- a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
@@ -28,9 +28,8 @@ static float smoothMask(float x, float y)
if ((t = 1.0f - sqrtf(x * x + y * y)) > 0.0f) {
return t;
}
- else {
- return 0.0f;
- }
+
+ return 0.0f;
}
void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.h b/source/blender/compositor/operations/COM_GlareGhostOperation.h
index c0b41762c8a..8ecf8da3385 100644
--- a/source/blender/compositor/operations/COM_GlareGhostOperation.h
+++ b/source/blender/compositor/operations/COM_GlareGhostOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GLAREGHOSTOPERATION_H__
-#define __COM_GLAREGHOSTOPERATION_H__
+#pragma once
+
#include "COM_GlareBaseOperation.h"
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
@@ -31,4 +31,3 @@ class GlareGhostOperation : public GlareBaseOperation {
protected:
void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h
index b6e2e499f64..0f5913fcef9 100644
--- a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h
+++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GLARESIMPLESTAROPERATION_H__
-#define __COM_GLARESIMPLESTAROPERATION_H__
+#pragma once
+
#include "COM_GlareBaseOperation.h"
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
@@ -31,4 +31,3 @@ class GlareSimpleStarOperation : public GlareBaseOperation {
protected:
void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.h b/source/blender/compositor/operations/COM_GlareStreaksOperation.h
index 9f137f90b71..df31981170d 100644
--- a/source/blender/compositor/operations/COM_GlareStreaksOperation.h
+++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GLARESTREAKSOPERATION_H__
-#define __COM_GLARESTREAKSOPERATION_H__
+#pragma once
+
#include "COM_GlareBaseOperation.h"
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
@@ -31,4 +31,3 @@ class GlareStreaksOperation : public GlareBaseOperation {
protected:
void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
index 385111cdf0b..e4ac36f2053 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.h
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_GLARETHRESHOLDOPERATION_H__
-#define __COM_GLARETHRESHOLDOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_light_types.h"
@@ -58,4 +58,3 @@ class GlareThresholdOperation : public NodeOperation {
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
index 0624a5c022f..f29a932d7f8 100644
--- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_HUESATURATIONVALUECORRECTOPERATION_H__
-#define __COM_HUESATURATIONVALUECORRECTOPERATION_H__
+#pragma once
+
#include "COM_CurveBaseOperation.h"
#include "COM_NodeOperation.h"
@@ -46,4 +46,3 @@ class HueSaturationValueCorrectOperation : public CurveBaseOperation {
*/
void deinitExecution();
};
-#endif
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h
index b3a40106b9d..abd2a719371 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.h
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_IDMASKOPERATION_H__
-#define __COM_IDMASKOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class IDMaskOperation : public NodeOperation {
@@ -35,4 +35,3 @@ class IDMaskOperation : public NodeOperation {
this->m_objectIndex = objectIndex;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h
index 3e081ee0000..fcffdc7aae9 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.h
+++ b/source/blender/compositor/operations/COM_ImageOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_IMAGEOPERATION_H__
-#define __COM_IMAGEOPERATION_H__
+#pragma once
#include "BKE_image.h"
#include "BLI_listbase.h"
@@ -103,4 +102,3 @@ class ImageDepthOperation : public BaseImageOperation {
ImageDepthOperation();
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp
index b8329b1cb29..0555ee24b9b 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.cpp
+++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp
@@ -272,14 +272,13 @@ bool InpaintSimpleOperation::determineDependingAreaOfInterest(rcti * /*input*/,
if (this->m_cached_buffer_ready) {
return false;
}
- else {
- rcti newInput;
- newInput.xmax = getWidth();
- newInput.xmin = 0;
- newInput.ymax = getHeight();
- newInput.ymin = 0;
+ rcti newInput;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+ newInput.xmax = getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = getHeight();
+ newInput.ymin = 0;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.h b/source/blender/compositor/operations/COM_InpaintOperation.h
index 76c1ae81b28..86f3393e1ea 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.h
+++ b/source/blender/compositor/operations/COM_InpaintOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_INPAINTOPERATION_H__
-#define __COM_INPAINTOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class InpaintSimpleOperation : public NodeOperation {
@@ -72,5 +72,3 @@ class InpaintSimpleOperation : public NodeOperation {
bool next_pixel(int &x, int &y, int &curr, int iters);
void pix_step(int x, int y);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_InvertOperation.h b/source/blender/compositor/operations/COM_InvertOperation.h
index 39161455a76..5399122ab62 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.h
+++ b/source/blender/compositor/operations/COM_InvertOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_INVERTOPERATION_H__
-#define __COM_INVERTOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class InvertOperation : public NodeOperation {
@@ -58,4 +58,3 @@ class InvertOperation : public NodeOperation {
this->m_alpha = alpha;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.h b/source/blender/compositor/operations/COM_KeyingBlurOperation.h
index 0e45f1c32b8..6a2b43a6cd4 100644
--- a/source/blender/compositor/operations/COM_KeyingBlurOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_KEYINGBLUROPERATION_H__
-#define __COM_KEYINGBLUROPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -54,5 +53,3 @@ class KeyingBlurOperation : public NodeOperation {
ReadBufferOperation *readOperation,
rcti *output);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.h b/source/blender/compositor/operations/COM_KeyingClipOperation.h
index 8237c443cf2..9d876966e96 100644
--- a/source/blender/compositor/operations/COM_KeyingClipOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingClipOperation.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_KEYINGCLIPOPERATION_H__
-#define __COM_KEYINGCLIPOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -68,5 +67,3 @@ class KeyingClipOperation : public NodeOperation {
ReadBufferOperation *readOperation,
rcti *output);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.h b/source/blender/compositor/operations/COM_KeyingDespillOperation.h
index eb43a478e50..32df7939c43 100644
--- a/source/blender/compositor/operations/COM_KeyingDespillOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_KEYINGDESPILLOPERATION_H__
-#define __COM_KEYINGDESPILLOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -48,5 +47,3 @@ class KeyingDespillOperation : public NodeOperation {
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_KeyingOperation.h b/source/blender/compositor/operations/COM_KeyingOperation.h
index 81d23e76b2a..946d7bdc1f7 100644
--- a/source/blender/compositor/operations/COM_KeyingOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingOperation.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_KEYINGOPERATION_H__
-#define __COM_KEYINGOPERATION_H__
+#pragma once
#include <string.h>
@@ -48,5 +47,3 @@ class KeyingOperation : public NodeOperation {
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.h b/source/blender/compositor/operations/COM_KeyingScreenOperation.h
index 593e902117b..595301bb951 100644
--- a/source/blender/compositor/operations/COM_KeyingScreenOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_KEYINGSCREENOPERATION_H__
-#define __COM_KEYINGSCREENOPERATION_H__
+#pragma once
#include <string.h>
@@ -83,5 +82,3 @@ class KeyingScreenOperation : public NodeOperation {
void executePixel(float output[4], int x, int y, void *data);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
index 2df7847f7ff..2b77b3cde85 100644
--- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_LUMINANCEMATTEOPERATION_H__
-#define __COM_LUMINANCEMATTEOPERATION_H__
+#pragma once
+
#include "COM_MixOperation.h"
/**
@@ -48,4 +48,3 @@ class LuminanceMatteOperation : public NodeOperation {
this->m_settings = nodeChroma;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.h b/source/blender/compositor/operations/COM_MapRangeOperation.h
index 55b5cc7453c..8656b5539a0 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.h
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.h
@@ -16,8 +16,8 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_MAPRANGEOPERATION_H__
-#define __COM_MAPRANGEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_texture_types.h"
@@ -67,4 +67,3 @@ class MapRangeOperation : public NodeOperation {
this->m_useClamp = value;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp
index de55c9fb4b8..9101b82202a 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp
@@ -87,14 +87,13 @@ bool MapUVOperation::read_uv(float x, float y, float &r_u, float &r_v, float &r_
r_alpha = 0.0f;
return false;
}
- else {
- float vector[3];
- m_inputUVProgram->readSampled(vector, x, y, COM_PS_BILINEAR);
- r_u = vector[0] * m_inputColorProgram->getWidth();
- r_v = vector[1] * m_inputColorProgram->getHeight();
- r_alpha = vector[2];
- return true;
- }
+
+ float vector[3];
+ m_inputUVProgram->readSampled(vector, x, y, COM_PS_BILINEAR);
+ r_u = vector[0] * m_inputColorProgram->getWidth();
+ r_v = vector[1] * m_inputColorProgram->getHeight();
+ r_alpha = vector[2];
+ return true;
}
void MapUVOperation::pixelTransform(const float xy[2],
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.h b/source/blender/compositor/operations/COM_MapUVOperation.h
index 64e17b180b4..639b61847c4 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.h
+++ b/source/blender/compositor/operations/COM_MapUVOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MAPUVOPERATION_H__
-#define __COM_MAPUVOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class MapUVOperation : public NodeOperation {
@@ -65,5 +65,3 @@ class MapUVOperation : public NodeOperation {
private:
bool read_uv(float x, float y, float &r_u, float &r_v, float &r_alpha);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h
index 81071d78cd7..cdbc98bd2a5 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.h
+++ b/source/blender/compositor/operations/COM_MapValueOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MAPVALUEOPERATION_H__
-#define __COM_MAPVALUEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_texture_types.h"
@@ -62,4 +62,3 @@ class MapValueOperation : public NodeOperation {
this->m_settings = settings;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h
index 45363ea5220..eba14d10373 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.h
+++ b/source/blender/compositor/operations/COM_MaskOperation.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_MASKOPERATION_H__
-#define __COM_MASKOPERATION_H__
+#pragma once
#include "BLI_listbase.h"
#include "COM_NodeOperation.h"
@@ -94,5 +93,3 @@ class MaskOperation : public NodeOperation {
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h
index 199b59d8649..f844f668f08 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MATHBASEOPERATION_H__
-#define __COM_MATHBASEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -372,4 +372,3 @@ class MathSmoothMaxOperation : public MathBaseOperation {
}
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_MixOperation.h b/source/blender/compositor/operations/COM_MixOperation.h
index cea0e59b541..e597e8af63a 100644
--- a/source/blender/compositor/operations/COM_MixOperation.h
+++ b/source/blender/compositor/operations/COM_MixOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MIXOPERATION_H__
-#define __COM_MIXOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -193,5 +193,3 @@ class MixValueOperation : public MixBaseOperation {
MixValueOperation();
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
index 8a95293b470..449e5d01a37 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MOVIECLIPATTRIBUTEOPERATION_H__
-#define __COM_MOVIECLIPATTRIBUTEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_movieclip_types.h"
@@ -70,4 +70,3 @@ class MovieClipAttributeOperation : public NodeOperation {
this->m_invert = invert;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.h b/source/blender/compositor/operations/COM_MovieClipOperation.h
index 7ae85eac25e..8897f85f77c 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MOVIECLIPOPERATION_H__
-#define __COM_MOVIECLIPOPERATION_H__
+#pragma once
#include "BLI_listbase.h"
#include "COM_NodeOperation.h"
@@ -77,5 +76,3 @@ class MovieClipAlphaOperation : public MovieClipBaseOperation {
MovieClipAlphaOperation();
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
index 799c6385a10..f11ce485f97 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MOVIEDISTORTIONOPERATION_H__
-#define __COM_MOVIEDISTORTIONOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
#include "DNA_movieclip_types.h"
@@ -58,5 +57,3 @@ class MovieDistortionOperation : public NodeOperation {
ReadBufferOperation *readOperation,
rcti *output);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
index 10c475ced4d..adfcc975ade 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.h
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_MULTILAYERIMAGEOPERATION_H__
-#define __COM_MULTILAYERIMAGEOPERATION_H__
+#pragma once
#include "COM_ImageOperation.h"
@@ -67,5 +66,3 @@ class MultilayerVectorOperation : public MultilayerBaseOperation {
}
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.h b/source/blender/compositor/operations/COM_NormalizeOperation.h
index a38e79bb0ab..58c03e633e2 100644
--- a/source/blender/compositor/operations/COM_NormalizeOperation.h
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.h
@@ -16,8 +16,8 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_NORMALIZEOPERATION_H__
-#define __COM_NORMALIZEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
@@ -63,5 +63,3 @@ class NormalizeOperation : public NodeOperation {
ReadBufferOperation *readOperation,
rcti *output);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
index 609448c0bcb..1deaf121173 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
@@ -16,8 +16,8 @@
* Copyright 2015, Blender Foundation.
*/
-#ifndef __COM_OUTPUTFILEMULTIVIEWOPERATION_H__
-#define __COM_OUTPUTFILEMULTIVIEWOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "COM_OutputFileOperation.h"
@@ -77,5 +77,3 @@ class OutputStereoOperation : public OutputSingleLayerOperation {
void *get_handle(const char *filename);
void deinitExecution();
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index ee3779edcb4..374189a5c50 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -129,9 +129,8 @@ static float *init_buffer(unsigned int width, unsigned int height, DataType data
int size = get_datatype_size(datatype);
return (float *)MEM_callocN(width * height * size * sizeof(float), "OutputFile buffer");
}
- else {
- return NULL;
- }
+
+ return NULL;
}
static void write_buffer_rect(rcti *rect,
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h
index d00d1d0dc0d..b2454e17e3f 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_OUTPUTFILEOPERATION_H__
-#define __COM_OUTPUTFILEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "BLI_path_util.h"
@@ -140,5 +140,3 @@ void free_exr_channels(void *exrhandle,
const char *layerName,
const DataType datatype);
int get_datatype_size(DataType datatype);
-
-#endif
diff --git a/source/blender/compositor/operations/COM_PixelateOperation.h b/source/blender/compositor/operations/COM_PixelateOperation.h
index 86aab26ee00..c7595756d39 100644
--- a/source/blender/compositor/operations/COM_PixelateOperation.h
+++ b/source/blender/compositor/operations/COM_PixelateOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_PIXELATEOPERATION_H__
-#define __COM_PIXELATEOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -61,5 +60,3 @@ class PixelateOperation : public NodeOperation {
*/
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h
index 444616e13f2..1e892465db8 100644
--- a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h
@@ -15,8 +15,7 @@
* Copyright 2014, Blender Foundation.
*/
-#ifndef __COM_PLANECORNERPINOPERATION_H__
-#define __COM_PLANECORNERPINOPERATION_H__
+#pragma once
#include <string.h>
@@ -59,5 +58,3 @@ class PlaneCornerPinWarpImageOperation : public PlaneDistortWarpImageOperation {
ReadBufferOperation *readOperation,
rcti *output);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.h b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.h
index 35e7745cb5d..6cc9456c13f 100644
--- a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.h
@@ -16,8 +16,7 @@
* Copyright 2013, Blender Foundation.
*/
-#ifndef __COM_PLANEDISTORTCOMMONOPERATION_H__
-#define __COM_PLANEDISTORTCOMMONOPERATION_H__
+#pragma once
#include <string.h>
@@ -97,5 +96,3 @@ class PlaneDistortMaskOperation : public NodeOperation {
this->m_motion_blur_shutter = shutter;
}
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_PlaneTrackOperation.h b/source/blender/compositor/operations/COM_PlaneTrackOperation.h
index 875c8ce8fa0..fc0a0873d5f 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneTrackOperation.h
@@ -16,8 +16,7 @@
* Copyright 2013, Blender Foundation.
*/
-#ifndef __COM_PLANETRACKOPERATION_H__
-#define __COM_PLANETRACKOPERATION_H__
+#pragma once
#include <string.h>
@@ -96,5 +95,3 @@ class PlaneTrackWarpImageOperation : public PlaneDistortWarpImageOperation,
NodeOperation::determineResolution(temp, resolution);
}
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp
index 30fe2ca824d..43d20271141 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cpp
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -126,14 +126,27 @@ void PreviewOperation::determineResolution(unsigned int resolution[2],
unsigned int preferredResolution[2])
{
NodeOperation::determineResolution(resolution, preferredResolution);
- int width = resolution[0];
- int height = resolution[1];
+
+ /* If resolution is 0 there are two possible scenarios:
+ * - Either node is not connected at all
+ * - It is connected to input which doesn't have own resolution (i.e. color input).
+ *
+ * In the former case we rely on the execution system to not evaluate this node.
+ *
+ * For the latter case we use 1 pixel preview, so that it's possible to see preview color in the
+ * preview. This is how final F12 render will behave (flood-fill final frame with the color).
+ *
+ * Having things consistent in terms that node preview is scaled down F12 render is a very
+ * natural thing to do. */
+ int width = max_ii(1, resolution[0]);
+ int height = max_ii(1, resolution[1]);
+
this->m_divider = 0.0f;
if (width > height) {
- this->m_divider = COM_PREVIEW_SIZE / (width - 1);
+ this->m_divider = (float)COM_PREVIEW_SIZE / (width);
}
else {
- this->m_divider = COM_PREVIEW_SIZE / (height - 1);
+ this->m_divider = (float)COM_PREVIEW_SIZE / (height);
}
width = width * this->m_divider;
height = height * this->m_divider;
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h
index f31bd533971..eca50c5cda4 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.h
+++ b/source/blender/compositor/operations/COM_PreviewOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_PREVIEWOPERATION_H__
-#define __COM_PREVIEWOPERATION_H__
+#pragma once
+
#include "BKE_global.h"
#include "BLI_rect.h"
#include "COM_NodeOperation.h"
@@ -61,4 +61,3 @@ class PreviewOperation : public NodeOperation {
return true;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
index 3574f40e3bb..b9290fa1548 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_PROJECTORLENSDISTORTIONOPERATION_H__
-#define __COM_PROJECTORLENSDISTORTIONOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
@@ -58,4 +58,3 @@ class ProjectorLensDistortionOperation : public NodeOperation {
void updateDispersion();
};
-#endif
diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.h b/source/blender/compositor/operations/COM_QualityStepHelper.h
index 0814f5cdb4c..e437613fb29 100644
--- a/source/blender/compositor/operations/COM_QualityStepHelper.h
+++ b/source/blender/compositor/operations/COM_QualityStepHelper.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_QUALITYSTEPHELPER_H__
-#define __COM_QUALITYSTEPHELPER_H__
+#pragma once
+
#include "COM_defines.h"
typedef enum QualityHelper {
@@ -54,4 +54,3 @@ class QualityStepHelper {
this->m_quality = quality;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h
index 60d064a5582..e59cb5449d6 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.h
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_READBUFFEROPERATION_H__
-#define __COM_READBUFFEROPERATION_H__
+#pragma once
#include "COM_MemoryBuffer.h"
#include "COM_MemoryProxy.h"
@@ -73,5 +72,3 @@ class ReadBufferOperation : public NodeOperation {
void readResolutionFromWriteBuffer();
void updateMemoryBuffer();
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.h b/source/blender/compositor/operations/COM_RenderLayersProg.h
index 6f84eae3252..74664c128c0 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.h
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_RENDERLAYERSPROG_H__
-#define __COM_RENDERLAYERSPROG_H__
+#pragma once
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
@@ -150,5 +149,3 @@ class RenderLayersDepthProg : public RenderLayersProg {
}
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_RotateOperation.h b/source/blender/compositor/operations/COM_RotateOperation.h
index 46bdc68161e..0ef4466671a 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.h
+++ b/source/blender/compositor/operations/COM_RotateOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_ROTATEOPERATION_H__
-#define __COM_ROTATEOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -47,5 +46,3 @@ class RotateOperation : public NodeOperation {
void ensureDegree();
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h
index 28e32ff8606..f28b8237485 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.h
+++ b/source/blender/compositor/operations/COM_ScaleOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SCALEOPERATION_H__
-#define __COM_SCALEOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -129,5 +128,3 @@ class ScaleFixedSizeOperation : public BaseScaleOperation {
this->m_offsetY = y;
}
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
index 738c51fc719..b7731a34c91 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -124,9 +124,8 @@ bool ScreenLensDistortionOperation::get_delta(float r_sq,
distort_uv(uv, t, delta);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
void ScreenLensDistortionOperation::accumulate(MemoryBuffer *buffer,
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
index c9db5bc88b8..f9982d94f60 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SCREENLENSDISTORTIONOPERATION_H__
-#define __COM_SCREENLENSDISTORTIONOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
@@ -96,4 +96,3 @@ class ScreenLensDistortionOperation : public NodeOperation {
float sum[4],
int count[3]) const;
};
-#endif
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h
index 24f80b71eae..a84fb0f2228 100644
--- a/source/blender/compositor/operations/COM_SetAlphaOperation.h
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SETALPHAOPERATION_H__
-#define __COM_SETALPHAOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -43,4 +43,3 @@ class SetAlphaOperation : public NodeOperation {
void initExecution();
void deinitExecution();
};
-#endif
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h
index d16d3806864..0723ac8a8e4 100644
--- a/source/blender/compositor/operations/COM_SetColorOperation.h
+++ b/source/blender/compositor/operations/COM_SetColorOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SETCOLOROPERATION_H__
-#define __COM_SETCOLOROPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -82,4 +82,3 @@ class SetColorOperation : public NodeOperation {
return true;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h
index 62f01129ff7..c0b5d5a37be 100644
--- a/source/blender/compositor/operations/COM_SetSamplerOperation.h
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SETSAMPLEROPERATION_H__
-#define __COM_SETSAMPLEROPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -47,4 +47,3 @@ class SetSamplerOperation : public NodeOperation {
void initExecution();
void deinitExecution();
};
-#endif
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h
index 6fb2832450d..6645cd558b2 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.h
+++ b/source/blender/compositor/operations/COM_SetValueOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SETVALUEOPERATION_H__
-#define __COM_SETVALUEOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -54,4 +54,3 @@ class SetValueOperation : public NodeOperation {
return true;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h
index a2f9aaa6b3b..05c8e6dc56b 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.h
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SETVECTOROPERATION_H__
-#define __COM_SETVECTOROPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
/**
@@ -88,4 +88,3 @@ class SetVectorOperation : public NodeOperation {
setZ(vector[2]);
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h
index 3855c26088a..22c144598f6 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.h
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SOCKETPROXYOPERATION_H__
-#define __COM_SOCKETPROXYOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -46,5 +45,3 @@ class SocketProxyOperation : public NodeOperation {
private:
bool m_use_conversion;
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_SplitOperation.h b/source/blender/compositor/operations/COM_SplitOperation.h
index ea923123290..62d41a615ff 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.h
+++ b/source/blender/compositor/operations/COM_SplitOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_SPLITOPERATION_H__
-#define __COM_SPLITOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
class SplitOperation : public NodeOperation {
@@ -43,4 +43,3 @@ class SplitOperation : public NodeOperation {
this->m_xSplit = xsplit;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
index 6f47e0e190b..4a7139537c1 100644
--- a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
+++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
@@ -172,7 +172,7 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
return;
}
- /* initialise the iteration variables */
+ /* Initialize the iteration variables. */
float *buffer = init_buffer_iterator(
input, source, co, dist_min, dist_max, x, y, num, v, dv, falloff_factor);
zero_v3(border);
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.h b/source/blender/compositor/operations/COM_SunBeamsOperation.h
index d8153264d98..09bdb018cc3 100644
--- a/source/blender/compositor/operations/COM_SunBeamsOperation.h
+++ b/source/blender/compositor/operations/COM_SunBeamsOperation.h
@@ -15,8 +15,7 @@
* Copyright 2014, Blender Foundation.
*/
-#ifndef __COM_SUNBEAMSOPERATION_H__
-#define __COM_SUNBEAMSOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -45,5 +44,3 @@ class SunBeamsOperation : public NodeOperation {
float m_source_px[2];
float m_ray_length_px;
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h
index ebfdbb6513a..7fa85922b0b 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.h
+++ b/source/blender/compositor/operations/COM_TextureOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_TEXTUREOPERATION_H__
-#define __COM_TEXTUREOPERATION_H__
+#pragma once
#include "BLI_listbase.h"
#include "COM_NodeOperation.h"
@@ -81,5 +80,3 @@ class TextureAlphaOperation : public TextureBaseOperation {
TextureAlphaOperation();
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.h b/source/blender/compositor/operations/COM_TonemapOperation.h
index 11e82c1fc9c..066332fb7e4 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.h
+++ b/source/blender/compositor/operations/COM_TonemapOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_TONEMAPOPERATION_H__
-#define __COM_TONEMAPOPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
@@ -98,5 +98,3 @@ class PhotoreceptorTonemapOperation : public TonemapOperation {
*/
void executePixel(float output[4], int x, int y, void *data);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.h b/source/blender/compositor/operations/COM_TrackPositionOperation.h
index 695e85f4fa3..7d831ec5d8d 100644
--- a/source/blender/compositor/operations/COM_TrackPositionOperation.h
+++ b/source/blender/compositor/operations/COM_TrackPositionOperation.h
@@ -16,8 +16,7 @@
* Copyright 2012, Blender Foundation.
*/
-#ifndef __COM_TRACKPOSITIONOPERATION_H__
-#define __COM_TRACKPOSITIONOPERATION_H__
+#pragma once
#include <string.h>
@@ -97,5 +96,3 @@ class TrackPositionOperation : public NodeOperation {
return true;
}
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h
index 2d13813a86a..99cfb528858 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.h
+++ b/source/blender/compositor/operations/COM_TranslateOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_TRANSLATEOPERATION_H__
-#define __COM_TRANSLATEOPERATION_H__
+#pragma once
#include "COM_NodeOperation.h"
@@ -65,5 +64,3 @@ class TranslateOperation : public NodeOperation {
void setFactorXY(float factorX, float factorY);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
index 930bfd77943..82f41ad68e3 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_VARIABLESIZEBOKEHBLUROPERATION_H__
-#define __COM_VARIABLESIZEBOKEHBLUROPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "COM_QualityStepHelper.h"
@@ -123,4 +123,3 @@ class InverseSearchRadiusOperation : public NodeOperation {
}
};
#endif
-#endif
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
index 56e0ab9b93f..1e392b1f991 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -115,9 +115,8 @@ bool VectorBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/,
newInput.ymin = 0;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
- else {
- return false;
- }
+
+ return false;
}
void VectorBlurOperation::generateVectorBlur(float *data,
@@ -596,7 +595,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
float minspeed = (float)nbd->minspeed;
float minspeedsq = minspeed * minspeed;
- minvecbufrect = (float *)MEM_callocN(4 * sizeof(float) * xsize * ysize, "minspeed buf");
+ minvecbufrect = (float *)MEM_callocN(sizeof(float[4]) * xsize * ysize, "minspeed buf");
dvec1 = vecbufrect;
dvec2 = minvecbufrect;
@@ -622,7 +621,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
}
/* make vertex buffer with averaged speed and zvalues */
- rectvz = (float *)MEM_callocN(4 * sizeof(float) * (xsize + 1) * (ysize + 1), "vertices");
+ rectvz = (float *)MEM_callocN(sizeof(float[4]) * (xsize + 1) * (ysize + 1), "vertices");
dvz = rectvz;
for (y = 0; y <= ysize; y++) {
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.h b/source/blender/compositor/operations/COM_VectorBlurOperation.h
index 3caf5c5c8e4..846b69310bf 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.h
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_VECTORBLUROPERATION_H__
-#define __COM_VECTORBLUROPERATION_H__
+#pragma once
+
#include "COM_NodeOperation.h"
#include "COM_QualityStepHelper.h"
#include "DNA_node_types.h"
@@ -72,4 +72,3 @@ class VectorBlurOperation : public NodeOperation, public QualityStepHelper {
MemoryBuffer *inputSpeed,
MemoryBuffer *inputZ);
};
-#endif
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.h b/source/blender/compositor/operations/COM_VectorCurveOperation.h
index 65441dbdfb7..9fa5fe78a4b 100644
--- a/source/blender/compositor/operations/COM_VectorCurveOperation.h
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_VECTORCURVEOPERATION_H__
-#define __COM_VECTORCURVEOPERATION_H__
+#pragma once
+
#include "COM_CurveBaseOperation.h"
#include "COM_NodeOperation.h"
@@ -46,4 +46,3 @@ class VectorCurveOperation : public CurveBaseOperation {
*/
void deinitExecution();
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index fc26d6219e1..3d5d50e1c7f 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -199,7 +199,6 @@ CompositorPriority ViewerOperation::getRenderPriority() const
if (this->isActiveViewerOutput()) {
return COM_PRIORITY_HIGH;
}
- else {
- return COM_PRIORITY_LOW;
- }
+
+ return COM_PRIORITY_LOW;
}
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h
index aae2e912804..680744c70d9 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_VIEWEROPERATION_H__
-#define __COM_VIEWEROPERATION_H__
+#pragma once
+
#include "BKE_global.h"
#include "BLI_rect.h"
#include "COM_NodeOperation.h"
@@ -129,4 +129,3 @@ class ViewerOperation : public NodeOperation {
void updateImage(rcti *rect);
void initImage();
};
-#endif
diff --git a/source/blender/compositor/operations/COM_WrapOperation.h b/source/blender/compositor/operations/COM_WrapOperation.h
index 6360fa0c246..d1acfb10f25 100644
--- a/source/blender/compositor/operations/COM_WrapOperation.h
+++ b/source/blender/compositor/operations/COM_WrapOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_WRAPOPERATION_H__
-#define __COM_WRAPOPERATION_H__
+#pragma once
#include "COM_ReadBufferOperation.h"
@@ -38,5 +37,3 @@ class WrapOperation : public ReadBufferOperation {
void setFactorXY(float factorX, float factorY);
};
-
-#endif
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h
index be525db4420..a9f90830a92 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.h
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h
@@ -16,8 +16,7 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_WRITEBUFFEROPERATION_H__
-#define __COM_WRITEBUFFEROPERATION_H__
+#pragma once
#include "COM_MemoryProxy.h"
#include "COM_NodeOperation.h"
@@ -63,4 +62,3 @@ class WriteBufferOperation : public NodeOperation {
return m_input;
}
};
-#endif
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h
index 9a93d080a2f..8c6e73f8c55 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.h
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.h
@@ -16,8 +16,8 @@
* Copyright 2011, Blender Foundation.
*/
-#ifndef __COM_ZCOMBINEOPERATION_H__
-#define __COM_ZCOMBINEOPERATION_H__
+#pragma once
+
#include "COM_MixOperation.h"
/**
@@ -66,5 +66,3 @@ class ZCombineMaskOperation : public NodeOperation {
class ZCombineMaskAlphaOperation : public ZCombineMaskOperation {
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
-#endif
diff --git a/source/blender/datatoc/datatoc_icon.c b/source/blender/datatoc/datatoc_icon.c
index 80a335e22b7..4a9c5875c17 100644
--- a/source/blender/datatoc/datatoc_icon.c
+++ b/source/blender/datatoc/datatoc_icon.c
@@ -269,7 +269,7 @@ static bool icon_merge(const char *file_src,
/* init once */
*r_canvas_w = head.canvas_w;
*r_canvas_h = head.canvas_h;
- *r_pixels_canvas = calloc(1, (head.canvas_w * head.canvas_h) * sizeof(unsigned char[4]));
+ *r_pixels_canvas = calloc(1, (head.canvas_w * head.canvas_h) * sizeof(const unsigned char[4]));
}
canvas_w = *r_canvas_w;
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index 51fce738700..417aaa2c4c0 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -54,6 +54,11 @@ set(SRC
intern/builder/deg_builder_remove_noop.cc
intern/builder/deg_builder_rna.cc
intern/builder/deg_builder_transitive.cc
+ intern/builder/pipeline.cc
+ intern/builder/pipeline_compositor.cc
+ intern/builder/pipeline_from_ids.cc
+ intern/builder/pipeline_render.cc
+ intern/builder/pipeline_view_layer.cc
intern/debug/deg_debug.cc
intern/debug/deg_debug_relations_graphviz.cc
intern/debug/deg_debug_stats_gnuplot.cc
@@ -110,6 +115,11 @@ set(SRC
intern/builder/deg_builder_remove_noop.h
intern/builder/deg_builder_rna.h
intern/builder/deg_builder_transitive.h
+ intern/builder/pipeline.h
+ intern/builder/pipeline_compositor.h
+ intern/builder/pipeline_from_ids.h
+ intern/builder/pipeline_render.h
+ intern/builder/pipeline_view_layer.h
intern/debug/deg_debug.h
intern/debug/deg_time_average.h
intern/eval/deg_eval.h
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index d735d3b89bc..b3636743101 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -43,8 +43,7 @@
* - These are used in all depsgraph code and by all callers of Depsgraph API...
*/
-#ifndef __DEG_DEPSGRAPH_H__
-#define __DEG_DEPSGRAPH_H__
+#pragma once
#include "DNA_ID.h"
@@ -233,5 +232,3 @@ void DEG_debug_print_eval_time(struct Depsgraph *depsgraph,
#ifdef __cplusplus
} /* extern "C" */
#endif
-
-#endif /* __DEG_DEPSGRAPH_H__ */
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 81157102bb1..50f22b00028 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -23,8 +23,7 @@
* Public API for Depsgraph
*/
-#ifndef __DEG_DEPSGRAPH_BUILD_H__
-#define __DEG_DEPSGRAPH_BUILD_H__
+#pragma once
/* ************************************************* */
@@ -201,5 +200,3 @@ struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *node_handle);
#ifdef __cplusplus
} /* extern "C" */
#endif
-
-#endif /* __DEG_DEPSGRAPH_BUILD_H__ */
diff --git a/source/blender/depsgraph/DEG_depsgraph_debug.h b/source/blender/depsgraph/DEG_depsgraph_debug.h
index 73e03523003..e261ff67a20 100644
--- a/source/blender/depsgraph/DEG_depsgraph_debug.h
+++ b/source/blender/depsgraph/DEG_depsgraph_debug.h
@@ -23,8 +23,7 @@
* Public API for Querying and Filtering Depsgraph
*/
-#ifndef __DEG_DEPSGRAPH_DEBUG_H__
-#define __DEG_DEPSGRAPH_DEBUG_H__
+#pragma once
#include <stdio.h>
@@ -80,5 +79,3 @@ bool DEG_debug_consistency_check(struct Depsgraph *graph);
#ifdef __cplusplus
} /* extern "C" */
#endif
-
-#endif /* __DEG_DEPSGRAPH_DEBUG_H__ */
diff --git a/source/blender/depsgraph/DEG_depsgraph_physics.h b/source/blender/depsgraph/DEG_depsgraph_physics.h
index 7eae6b4eec4..7bd2994b426 100644
--- a/source/blender/depsgraph/DEG_depsgraph_physics.h
+++ b/source/blender/depsgraph/DEG_depsgraph_physics.h
@@ -23,8 +23,7 @@
* Physics utilities for effectors and collision.
*/
-#ifndef __DEG_DEPSGRAPH_PHYSICS_H__
-#define __DEG_DEPSGRAPH_PHYSICS_H__
+#pragma once
#include "DEG_depsgraph.h"
@@ -74,5 +73,3 @@ void DEG_add_forcefield_relations(struct DepsNodeHandle *handle,
#ifdef __cplusplus
} /* extern "C" */
#endif
-
-#endif /* __DEG_DEPSGRAPH_PHYSICS_H__ */
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index 3d570536223..e0166a13d69 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -23,8 +23,7 @@
* Public API for Querying Depsgraph.
*/
-#ifndef __DEG_DEPSGRAPH_QUERY_H__
-#define __DEG_DEPSGRAPH_QUERY_H__
+#pragma once
#include "BLI_iterator.h"
@@ -261,5 +260,3 @@ void DEG_foreach_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback, v
#ifdef __cplusplus
} /* extern "C" */
#endif
-
-#endif /* __DEG_DEPSGRAPH_QUERY_H__ */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
index 750bccf0e52..717239d7c64 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
@@ -76,7 +76,7 @@ uint64_t AnimatedPropertyID::hash() const
{
uintptr_t ptr1 = (uintptr_t)data;
uintptr_t ptr2 = (uintptr_t)property_rna;
- return (uint64_t)(((ptr1 >> 4) * 33) ^ (ptr2 >> 4));
+ return static_cast<uint64_t>(((ptr1 >> 4) * 33) ^ (ptr2 >> 4));
}
namespace {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_map.h b/source/blender/depsgraph/intern/builder/deg_builder_map.h
index 5dfc3297b3e..8b23d3d0d3b 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_map.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_map.h
@@ -40,7 +40,7 @@ class BuilderMap {
TAG_SCENE_COMPOSITOR = (1 << 4),
TAG_SCENE_SEQUENCER = (1 << 5),
- TAG_SCENE_AUDIO = (1 << 5),
+ TAG_SCENE_AUDIO = (1 << 6),
/* All ID components has been built. */
TAG_COMPLETE = (TAG_ANIMATION | TAG_PARAMETERS | TAG_TRANSFORM | TAG_GEOMETRY |
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 57bc673a521..e262c880421 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -1126,6 +1126,12 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
if (object->type != OB_MESH) {
continue;
}
+ if (object->rigidbody_object == nullptr) {
+ continue;
+ }
+ if (object->rigidbody_object->type == RBO_TYPE_PASSIVE) {
+ continue;
+ }
/* Create operation for flushing results. */
/* Object's transform component - where the rigidbody operation
* lives. */
@@ -1811,6 +1817,9 @@ void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene)
if (scene->ed == nullptr) {
return;
}
+ if (built_map_.checkIsBuiltAndTag(scene, BuilderMap::TAG_SCENE_SEQUENCER)) {
+ return;
+ }
build_scene_audio(scene);
Scene *scene_cow = get_cow_datablock(scene);
add_operation_node(&scene->id,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index d0e8246caa9..37b23833e00 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -254,9 +254,8 @@ TimeSourceNode *DepsgraphRelationBuilder::get_node(const TimeSourceKey &key) con
/* XXX TODO */
return nullptr;
}
- else {
- return graph_->time_source;
- }
+
+ return graph_->time_source;
}
ComponentNode *DepsgraphRelationBuilder::get_node(const ComponentKey &key) const
@@ -353,16 +352,16 @@ Relation *DepsgraphRelationBuilder::add_time_relation(TimeSourceNode *timesrc,
if (timesrc && node_to) {
return graph_->add_new_relation(timesrc, node_to, description, flags);
}
- else {
- DEG_DEBUG_PRINTF((::Depsgraph *)graph_,
- BUILD,
- "add_time_relation(%p = %s, %p = %s, %s) Failed\n",
- timesrc,
- (timesrc) ? timesrc->identifier().c_str() : "<None>",
- node_to,
- (node_to) ? node_to->identifier().c_str() : "<None>",
- description);
- }
+
+ DEG_DEBUG_PRINTF((::Depsgraph *)graph_,
+ BUILD,
+ "add_time_relation(%p = %s, %p = %s, %s) Failed\n",
+ timesrc,
+ (timesrc) ? timesrc->identifier().c_str() : "<None>",
+ node_to,
+ (node_to) ? node_to->identifier().c_str() : "<None>",
+ description);
+
return nullptr;
}
@@ -374,16 +373,16 @@ Relation *DepsgraphRelationBuilder::add_operation_relation(OperationNode *node_f
if (node_from && node_to) {
return graph_->add_new_relation(node_from, node_to, description, flags);
}
- else {
- DEG_DEBUG_PRINTF((::Depsgraph *)graph_,
- BUILD,
- "add_operation_relation(%p = %s, %p = %s, %s) Failed\n",
- node_from,
- (node_from) ? node_from->identifier().c_str() : "<None>",
- node_to,
- (node_to) ? node_to->identifier().c_str() : "<None>",
- description);
- }
+
+ DEG_DEBUG_PRINTF((::Depsgraph *)graph_,
+ BUILD,
+ "add_operation_relation(%p = %s, %p = %s, %s) Failed\n",
+ node_from,
+ (node_from) ? node_from->identifier().c_str() : "<None>",
+ node_to,
+ (node_to) ? node_to->identifier().c_str() : "<None>",
+ description);
+
return nullptr;
}
@@ -1013,6 +1012,9 @@ void DepsgraphRelationBuilder::build_object_pointcache(Object *object)
/* Check which components needs the point cache. */
int flag = -1;
if (ptcache_id->type == PTCACHE_TYPE_RIGIDBODY) {
+ if (object->rigidbody_object->type == RBO_TYPE_PASSIVE) {
+ continue;
+ }
flag = FLAG_TRANSFORM;
OperationKey transform_key(
&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_SIMULATION_INIT);
@@ -1698,6 +1700,22 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
if (object->type != OB_MESH) {
continue;
}
+ if (object->rigidbody_object == nullptr) {
+ continue;
+ }
+ if (object->rigidbody_object->type == RBO_TYPE_PASSIVE) {
+ continue;
+ }
+
+ if (object->parent != nullptr && object->parent->rigidbody_object != nullptr &&
+ object->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) {
+ /* If we are a child of a compound shape object, the transforms and sim evaluation will be
+ * handled by the parent compound shape object. Do not add any evaluation triggers
+ * for the child objects.
+ */
+ continue;
+ }
+
OperationKey rb_transform_copy_key(
&object->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
/* Rigid body synchronization depends on the actual simulation. */
@@ -1713,8 +1731,7 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
/* Geometry must be known to create the rigid body. RBO_MESH_BASE
* uses the non-evaluated mesh, so then the evaluation is
* unnecessary. */
- if (object->rigidbody_object != nullptr &&
- object->rigidbody_object->mesh_source != RBO_MESH_BASE) {
+ if (rigidbody_object_depends_on_evaluated_geometry(object->rigidbody_object)) {
/* NOTE: We prefer this relation to be never killed, to avoid
* access partially evaluated mesh from solver. */
ComponentKey object_geometry_key(&object->id, NodeType::GEOMETRY);
@@ -1747,13 +1764,18 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
/* final result of the constraint object's transform controls how
* the constraint affects the physics sim for these objects. */
ComponentKey trans_key(&object->id, NodeType::TRANSFORM);
- OperationKey ob1_key(
- &rbc->ob1->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
- OperationKey ob2_key(
- &rbc->ob2->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
- /* Constrained-objects sync depends on the constraint-holder. */
- add_relation(trans_key, ob1_key, "RigidBodyConstraint -> RBC.Object_1");
- add_relation(trans_key, ob2_key, "RigidBodyConstraint -> RBC.Object_2");
+ if (rbc->ob1->rigidbody_object->type == RBO_TYPE_ACTIVE) {
+ OperationKey ob1_key(
+ &rbc->ob1->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
+ /* Constrained-objects sync depends on the constraint-holder. */
+ add_relation(trans_key, ob1_key, "RigidBodyConstraint -> RBC.Object_1");
+ }
+ if (rbc->ob2->rigidbody_object->type == RBO_TYPE_ACTIVE) {
+ OperationKey ob2_key(
+ &rbc->ob2->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
+ /* Constrained-objects sync depends on the constraint-holder. */
+ add_relation(trans_key, ob2_key, "RigidBodyConstraint -> RBC.Object_2");
+ }
/* Ensure that sim depends on this constraint's transform. */
add_relation(trans_key, rb_simulate_key, "RigidBodyConstraint Transform -> RB Simulation");
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
index d4c28060878..b853ecd8e56 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
@@ -27,6 +27,7 @@
#include "DNA_ID.h"
#include "DNA_object_types.h"
+#include "DNA_rigidbody_types.h"
namespace blender {
namespace deg {
@@ -126,6 +127,19 @@ Relation *DepsgraphRelationBuilder::add_node_handle_relation(const KeyType &key_
return nullptr;
}
+static bool rigidbody_object_depends_on_evaluated_geometry(const RigidBodyOb *rbo)
+{
+ if (rbo == nullptr) {
+ return false;
+ }
+ if (ELEM(rbo->shape, RB_SHAPE_CONVEXH, RB_SHAPE_TRIMESH)) {
+ if (rbo->mesh_source != RBO_MESH_BASE) {
+ return true;
+ }
+ }
+ return false;
+}
+
template<typename KeyTo>
Relation *DepsgraphRelationBuilder::add_depends_on_transform_relation(ID *id,
const KeyTo &key_to,
@@ -134,7 +148,7 @@ Relation *DepsgraphRelationBuilder::add_depends_on_transform_relation(ID *id,
{
if (GS(id->name) == ID_OB) {
Object *object = reinterpret_cast<Object *>(id);
- if (object->rigidbody_object != nullptr) {
+ if (rigidbody_object_depends_on_evaluated_geometry(object->rigidbody_object)) {
OperationKey transform_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL);
return add_relation(transform_key, key_to, description, flags);
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index e3b667427a2..ec18b429c2e 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -190,7 +190,7 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
reinterpret_cast<const PropertyRNA *>(prop));
return node_identifier;
}
- else if (ptr->type == &RNA_PoseBone) {
+ if (ptr->type == &RNA_PoseBone) {
const bPoseChannel *pchan = static_cast<const bPoseChannel *>(ptr->data);
/* Bone - generally, we just want the bone component. */
node_identifier.type = NodeType::BONE;
@@ -222,7 +222,7 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
}
return node_identifier;
}
- else if (ptr->type == &RNA_Bone) {
+ if (ptr->type == &RNA_Bone) {
/* Armature-level bone mapped to Armature Eval, and thus Pose Init.
* Drivers have special code elsewhere that links them to the pose
* bone components, instead of using this generic code. */
@@ -236,7 +236,7 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
}
return node_identifier;
}
- else if (RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
+ if (RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
const Object *object = reinterpret_cast<const Object *>(ptr->owner_id);
const bConstraint *constraint = static_cast<const bConstraint *>(ptr->data);
RNANodeQueryIDData *id_data = ensure_id_data(&object->id);
@@ -256,7 +256,7 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
}
return node_identifier;
}
- else if (ELEM(ptr->type, &RNA_ConstraintTarget, &RNA_ConstraintTargetBone)) {
+ if (ELEM(ptr->type, &RNA_ConstraintTarget, &RNA_ConstraintTargetBone)) {
Object *object = reinterpret_cast<Object *>(ptr->owner_id);
bConstraintTarget *tgt = (bConstraintTarget *)ptr->data;
/* Check whether is object or bone constraint. */
@@ -315,17 +315,17 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
node_identifier.type = NodeType::TRANSFORM;
return node_identifier;
}
- else if (contains(prop_identifier, "data")) {
+ if (contains(prop_identifier, "data")) {
/* We access object.data, most likely a geometry.
* Might be a bone tho. */
node_identifier.type = NodeType::GEOMETRY;
return node_identifier;
}
- else if (STREQ(prop_identifier, "hide_viewport") || STREQ(prop_identifier, "hide_render")) {
+ if (STREQ(prop_identifier, "hide_viewport") || STREQ(prop_identifier, "hide_render")) {
node_identifier.type = NodeType::OBJECT_FROM_LAYER;
return node_identifier;
}
- else if (STREQ(prop_identifier, "dimensions")) {
+ if (STREQ(prop_identifier, "dimensions")) {
node_identifier.type = NodeType::PARAMETERS;
node_identifier.operation_code = OperationCode::DIMENSIONS;
return node_identifier;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
index bd6a364e08a..c5e020b3242 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
@@ -96,7 +96,7 @@ void deg_graph_transitive_reduction(Depsgraph *graph)
* need modifying. */
continue;
}
- else if (rel->from->custom_flags & OP_REACHABLE) {
+ if (rel->from->custom_flags & OP_REACHABLE) {
relations_to_remove.append(rel);
}
}
diff --git a/source/blender/depsgraph/intern/builder/pipeline.cc b/source/blender/depsgraph/intern/builder/pipeline.cc
new file mode 100644
index 00000000000..d6893ba11d8
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline.cc
@@ -0,0 +1,132 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+#include "pipeline.h"
+
+#include "PIL_time.h"
+
+#include "BKE_global.h"
+
+#include "DNA_scene_types.h"
+
+#include "deg_builder_cycle.h"
+#include "deg_builder_nodes.h"
+#include "deg_builder_relations.h"
+#include "deg_builder_transitive.h"
+
+namespace blender {
+namespace deg {
+
+AbstractBuilderPipeline::AbstractBuilderPipeline(::Depsgraph *graph,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer)
+ : deg_graph_(reinterpret_cast<Depsgraph *>(graph)),
+ bmain_(bmain),
+ scene_(scene),
+ view_layer_(view_layer),
+ builder_cache_()
+{
+}
+
+AbstractBuilderPipeline::~AbstractBuilderPipeline()
+{
+}
+
+void AbstractBuilderPipeline::build()
+{
+ double start_time = 0.0;
+ if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
+ start_time = PIL_check_seconds_timer();
+ }
+
+ build_step_sanity_check();
+ build_step_nodes();
+ build_step_relations();
+ build_step_finalize();
+
+ if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
+ printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
+ }
+}
+
+void AbstractBuilderPipeline::build_step_sanity_check()
+{
+ BLI_assert(BLI_findindex(&scene_->view_layers, view_layer_) != -1);
+ BLI_assert(deg_graph_->scene == scene_);
+ BLI_assert(deg_graph_->view_layer == view_layer_);
+}
+
+void AbstractBuilderPipeline::build_step_nodes()
+{
+ /* Generate all the nodes in the graph first */
+ unique_ptr<DepsgraphNodeBuilder> node_builder = construct_node_builder();
+ node_builder->begin_build();
+ build_nodes(*node_builder);
+ node_builder->end_build();
+}
+
+void AbstractBuilderPipeline::build_step_relations()
+{
+ /* Hook up relationships between operations - to determine evaluation order. */
+ unique_ptr<DepsgraphRelationBuilder> relation_builder = construct_relation_builder();
+ relation_builder->begin_build();
+ build_relations(*relation_builder);
+ relation_builder->build_copy_on_write_relations();
+ relation_builder->build_driver_relations();
+}
+
+void AbstractBuilderPipeline::build_step_finalize()
+{
+ /* Detect and solve cycles. */
+ deg_graph_detect_cycles(deg_graph_);
+ /* Simplify the graph by removing redundant relations (to optimize
+ * traversal later). */
+ /* TODO: it would be useful to have an option to disable this in cases where
+ * it is causing trouble. */
+ if (G.debug_value == 799) {
+ deg_graph_transitive_reduction(deg_graph_);
+ }
+ /* Store pointers to commonly used valuated datablocks. */
+ deg_graph_->scene_cow = (Scene *)deg_graph_->get_cow_id(&deg_graph_->scene->id);
+ /* Flush visibility layer and re-schedule nodes for update. */
+ deg_graph_build_finalize(bmain_, deg_graph_);
+ DEG_graph_on_visible_update(bmain_, reinterpret_cast<::Depsgraph *>(deg_graph_), false);
+#if 0
+ if (!DEG_debug_consistency_check(deg_graph_)) {
+ printf("Consistency validation failed, ABORTING!\n");
+ abort();
+ }
+#endif
+ /* Relations are up to date. */
+ deg_graph_->need_update = false;
+}
+
+unique_ptr<DepsgraphNodeBuilder> AbstractBuilderPipeline::construct_node_builder()
+{
+ return std::make_unique<DepsgraphNodeBuilder>(bmain_, deg_graph_, &builder_cache_);
+}
+
+unique_ptr<DepsgraphRelationBuilder> AbstractBuilderPipeline::construct_relation_builder()
+{
+ return std::make_unique<DepsgraphRelationBuilder>(bmain_, deg_graph_, &builder_cache_);
+}
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline.h b/source/blender/depsgraph/intern/builder/pipeline.h
new file mode 100644
index 00000000000..2c9c78bb2cb
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline.h
@@ -0,0 +1,77 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "deg_builder_cache.h"
+
+#include "intern/depsgraph_type.h"
+
+struct Main;
+struct Scene;
+struct ViewLayer;
+struct Depsgraph;
+
+namespace blender {
+namespace deg {
+
+struct Depsgraph;
+class DepsgraphNodeBuilder;
+class DepsgraphRelationBuilder;
+
+/* Base class for Depsgraph Builder pipelines.
+ *
+ * Basically it runs through the following steps:
+ * - sanity check
+ * - build nodes
+ * - build relations
+ * - finalize
+ */
+class AbstractBuilderPipeline {
+ public:
+ AbstractBuilderPipeline(::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer);
+ virtual ~AbstractBuilderPipeline();
+
+ void build();
+
+ protected:
+ Depsgraph *deg_graph_;
+ Main *bmain_;
+ Scene *scene_;
+ ViewLayer *view_layer_;
+ DepsgraphBuilderCache builder_cache_;
+
+ virtual unique_ptr<DepsgraphNodeBuilder> construct_node_builder();
+ virtual unique_ptr<DepsgraphRelationBuilder> construct_relation_builder();
+
+ virtual void build_step_sanity_check();
+ void build_step_nodes();
+ void build_step_relations();
+ void build_step_finalize();
+
+ virtual void build_nodes(DepsgraphNodeBuilder &node_builder) = 0;
+ virtual void build_relations(DepsgraphRelationBuilder &relation_builder) = 0;
+};
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_compositor.cc b/source/blender/depsgraph/intern/builder/pipeline_compositor.cc
new file mode 100644
index 00000000000..3e56f17fc7e
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_compositor.cc
@@ -0,0 +1,49 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+#include "pipeline_compositor.h"
+
+#include "intern/builder/deg_builder_nodes.h"
+#include "intern/builder/deg_builder_relations.h"
+#include "intern/depsgraph.h"
+
+namespace blender {
+namespace deg {
+
+CompositorBuilderPipeline::CompositorBuilderPipeline(
+ ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, bNodeTree *nodetree)
+ : AbstractBuilderPipeline(graph, bmain, scene, view_layer), nodetree_(nodetree)
+{
+ deg_graph_->is_render_pipeline_depsgraph = true;
+}
+
+void CompositorBuilderPipeline::build_nodes(DepsgraphNodeBuilder &node_builder)
+{
+ node_builder.build_scene_render(scene_, view_layer_);
+ node_builder.build_nodetree(nodetree_);
+}
+
+void CompositorBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_builder)
+{
+ relation_builder.build_scene_render(scene_, view_layer_);
+ relation_builder.build_nodetree(nodetree_);
+}
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_compositor.h b/source/blender/depsgraph/intern/builder/pipeline_compositor.h
new file mode 100644
index 00000000000..892ece7c2a4
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_compositor.h
@@ -0,0 +1,47 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "pipeline.h"
+
+struct bNodeTree;
+
+namespace blender {
+namespace deg {
+
+class CompositorBuilderPipeline : public AbstractBuilderPipeline {
+ public:
+ CompositorBuilderPipeline(
+ ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, bNodeTree *nodetree);
+
+ protected:
+ virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override;
+ virtual void build_relations(DepsgraphRelationBuilder &relation_builder) override;
+
+ private:
+ bNodeTree *nodetree_;
+};
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc
new file mode 100644
index 00000000000..e44f554f197
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc
@@ -0,0 +1,154 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+#include "pipeline_from_ids.h"
+
+#include "DNA_layer_types.h"
+
+#include "intern/builder/deg_builder_nodes.h"
+#include "intern/builder/deg_builder_relations.h"
+#include "intern/depsgraph.h"
+
+namespace blender {
+namespace deg {
+
+namespace {
+
+class DepsgraphFromIDsFilter {
+ public:
+ DepsgraphFromIDsFilter(ID **ids, const int num_ids)
+ {
+ for (int i = 0; i < num_ids; ++i) {
+ ids_.add(ids[i]);
+ }
+ }
+
+ bool contains(ID *id)
+ {
+ return ids_.contains(id);
+ }
+
+ protected:
+ Set<ID *> ids_;
+};
+
+class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder {
+ public:
+ DepsgraphFromIDsNodeBuilder(
+ Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids)
+ : DepsgraphNodeBuilder(bmain, graph, cache), filter_(ids, num_ids)
+ {
+ }
+
+ virtual bool need_pull_base_into_graph(Base *base) override
+ {
+ if (!filter_.contains(&base->object->id)) {
+ return false;
+ }
+ return DepsgraphNodeBuilder::need_pull_base_into_graph(base);
+ }
+
+ virtual void build_object_proxy_group(Object *object, bool is_visible) override
+ {
+ if (object->proxy_group == nullptr) {
+ return;
+ }
+ if (!filter_.contains(&object->proxy_group->id)) {
+ return;
+ }
+ DepsgraphNodeBuilder::build_object_proxy_group(object, is_visible);
+ }
+
+ protected:
+ DepsgraphFromIDsFilter filter_;
+};
+
+class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder {
+ public:
+ DepsgraphFromIDsRelationBuilder(
+ Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids)
+ : DepsgraphRelationBuilder(bmain, graph, cache), filter_(ids, num_ids)
+ {
+ }
+
+ virtual bool need_pull_base_into_graph(Base *base) override
+ {
+ if (!filter_.contains(&base->object->id)) {
+ return false;
+ }
+ return DepsgraphRelationBuilder::need_pull_base_into_graph(base);
+ }
+
+ virtual void build_object_proxy_group(Object *object) override
+ {
+ if (object->proxy_group == nullptr) {
+ return;
+ }
+ if (!filter_.contains(&object->proxy_group->id)) {
+ return;
+ }
+ DepsgraphRelationBuilder::build_object_proxy_group(object);
+ }
+
+ protected:
+ DepsgraphFromIDsFilter filter_;
+};
+
+} // namespace
+
+FromIDsBuilderPipeline::FromIDsBuilderPipeline(::Depsgraph *graph,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer,
+ ID **ids,
+ const int num_ids)
+ : AbstractBuilderPipeline(graph, bmain, scene, view_layer), ids_(ids), num_ids_(num_ids)
+{
+}
+
+unique_ptr<DepsgraphNodeBuilder> FromIDsBuilderPipeline::construct_node_builder()
+{
+ return std::make_unique<DepsgraphFromIDsNodeBuilder>(
+ bmain_, deg_graph_, &builder_cache_, ids_, num_ids_);
+}
+
+unique_ptr<DepsgraphRelationBuilder> FromIDsBuilderPipeline::construct_relation_builder()
+{
+ return std::make_unique<DepsgraphFromIDsRelationBuilder>(
+ bmain_, deg_graph_, &builder_cache_, ids_, num_ids_);
+}
+
+void FromIDsBuilderPipeline::build_nodes(DepsgraphNodeBuilder &node_builder)
+{
+ node_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY);
+ for (int i = 0; i < num_ids_; ++i) {
+ node_builder.build_id(ids_[i]);
+ }
+}
+
+void FromIDsBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_builder)
+{
+ relation_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY);
+ for (int i = 0; i < num_ids_; ++i) {
+ relation_builder.build_id(ids_[i]);
+ }
+}
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_from_ids.h b/source/blender/depsgraph/intern/builder/pipeline_from_ids.h
new file mode 100644
index 00000000000..4a507f2c728
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_from_ids.h
@@ -0,0 +1,62 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "pipeline.h"
+
+namespace blender {
+namespace deg {
+
+/* Optimized builders for dependency graph built from a given set of IDs.
+ *
+ * General notes:
+ *
+ * - We pull in all bases if their objects are in the set of IDs. This allows to have proper
+ * visibility and other flags assigned to the objects.
+ * All other bases (the ones which points to object which is outside of the set of IDs) are
+ * completely ignored.
+ *
+ * - Proxy groups pointing to objects which are outside of the IDs set are also ignored.
+ * This way we avoid high-poly character body pulled into the dependency graph when it's coming
+ * from a library into an animation file and the dependency graph constructed for a proxy rig. */
+
+class FromIDsBuilderPipeline : public AbstractBuilderPipeline {
+ public:
+ FromIDsBuilderPipeline(
+ ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, ID **ids, int num_ids);
+
+ protected:
+ virtual unique_ptr<DepsgraphNodeBuilder> construct_node_builder() override;
+ virtual unique_ptr<DepsgraphRelationBuilder> construct_relation_builder() override;
+
+ virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override;
+ virtual void build_relations(DepsgraphRelationBuilder &relation_builder) override;
+
+ private:
+ ID **ids_;
+ const int num_ids_;
+};
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_render.cc b/source/blender/depsgraph/intern/builder/pipeline_render.cc
new file mode 100644
index 00000000000..50a37d0d3e4
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_render.cc
@@ -0,0 +1,49 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+#include "pipeline_render.h"
+
+#include "intern/builder/deg_builder_nodes.h"
+#include "intern/builder/deg_builder_relations.h"
+#include "intern/depsgraph.h"
+
+namespace blender {
+namespace deg {
+
+RenderBuilderPipeline::RenderBuilderPipeline(::Depsgraph *graph,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer)
+ : AbstractBuilderPipeline(graph, bmain, scene, view_layer)
+{
+ deg_graph_->is_render_pipeline_depsgraph = true;
+}
+
+void RenderBuilderPipeline::build_nodes(DepsgraphNodeBuilder &node_builder)
+{
+ node_builder.build_scene_render(scene_, view_layer_);
+}
+
+void RenderBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_builder)
+{
+ relation_builder.build_scene_render(scene_, view_layer_);
+}
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_render.h b/source/blender/depsgraph/intern/builder/pipeline_render.h
new file mode 100644
index 00000000000..df7f9e0de68
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_render.h
@@ -0,0 +1,41 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "pipeline.h"
+
+namespace blender {
+namespace deg {
+
+class RenderBuilderPipeline : public AbstractBuilderPipeline {
+ public:
+ RenderBuilderPipeline(::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer);
+
+ protected:
+ virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override;
+ virtual void build_relations(DepsgraphRelationBuilder &relation_builder) override;
+};
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc b/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc
new file mode 100644
index 00000000000..3223f17f349
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_view_layer.cc
@@ -0,0 +1,48 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+#include "pipeline_view_layer.h"
+
+#include "intern/builder/deg_builder_nodes.h"
+#include "intern/builder/deg_builder_relations.h"
+#include "intern/depsgraph.h"
+
+namespace blender {
+namespace deg {
+
+ViewLayerBuilderPipeline::ViewLayerBuilderPipeline(::Depsgraph *graph,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer)
+ : AbstractBuilderPipeline(graph, bmain, scene, view_layer)
+{
+}
+
+void ViewLayerBuilderPipeline::build_nodes(DepsgraphNodeBuilder &node_builder)
+{
+ node_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY);
+}
+
+void ViewLayerBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_builder)
+{
+ relation_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY);
+}
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/builder/pipeline_view_layer.h b/source/blender/depsgraph/intern/builder/pipeline_view_layer.h
new file mode 100644
index 00000000000..fbd7b98acad
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/pipeline_view_layer.h
@@ -0,0 +1,41 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "pipeline.h"
+
+namespace blender {
+namespace deg {
+
+class ViewLayerBuilderPipeline : public AbstractBuilderPipeline {
+ public:
+ ViewLayerBuilderPipeline(::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer);
+
+ protected:
+ virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override;
+ virtual void build_relations(DepsgraphRelationBuilder &relation_builder) override;
+};
+
+} // namespace deg
+} // namespace blender
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
index 458baf4fb1e..d0356f44022 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
@@ -25,6 +25,7 @@
#include <cstdarg>
+#include "BLI_dot_export.hh"
#include "BLI_utildefines.h"
#include "DNA_listBase.h"
@@ -41,6 +42,7 @@
#include "intern/node/deg_node_time.h"
namespace deg = blender::deg;
+namespace dot = blender::dot;
/* ****************** */
/* Graphviz Debugging */
@@ -48,8 +50,6 @@ namespace deg = blender::deg;
namespace blender {
namespace deg {
-#define NL "\r\n"
-
/* Only one should be enabled, defines whether graphviz nodes
* get colored by individual types or classes.
*/
@@ -158,47 +158,43 @@ static int deg_debug_node_color_index(const Node *node)
#endif
}
-struct DebugContext {
- FILE *file;
+struct DotExportContext {
bool show_tags;
+ dot::DirectedGraph &digraph;
+ Map<const Node *, dot::Node *> nodes_map;
+ Map<const Node *, dot::Cluster *> clusters_map;
};
-static void deg_debug_fprintf(const DebugContext &ctx, const char *fmt, ...)
- ATTR_PRINTF_FORMAT(2, 3);
-static void deg_debug_fprintf(const DebugContext &ctx, const char *fmt, ...)
+static void deg_debug_graphviz_legend_color(const char *name,
+ const char *color,
+ std::stringstream &ss)
{
- va_list args;
- va_start(args, fmt);
- vfprintf(ctx.file, fmt, args);
- va_end(args);
-}
-static void deg_debug_graphviz_legend_color(const DebugContext &ctx,
- const char *name,
- const char *color)
-{
- deg_debug_fprintf(ctx, "<TR>");
- deg_debug_fprintf(ctx, "<TD>%s</TD>", name);
- deg_debug_fprintf(ctx, "<TD BGCOLOR=\"%s\"></TD>", color);
- deg_debug_fprintf(ctx, "</TR>" NL);
+ ss << "<TR>";
+ ss << "<TD>" << name << "</TD>";
+ ss << "<TD BGCOLOR=\"" << color << "\"></TD>";
+ ss << "</TR>";
}
-static void deg_debug_graphviz_legend(const DebugContext &ctx)
+static void deg_debug_graphviz_legend(DotExportContext &ctx)
{
- deg_debug_fprintf(ctx, "{" NL);
- deg_debug_fprintf(ctx, "rank = sink;" NL);
- deg_debug_fprintf(ctx, "Legend [shape=none, margin=0, label=<" NL);
- deg_debug_fprintf(
- ctx, " <TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"4\">" NL);
- deg_debug_fprintf(ctx, "<TR><TD COLSPAN=\"2\"><B>Legend</B></TD></TR>" NL);
+ dot::Node &legend_node = ctx.digraph.new_node("");
+ legend_node.attributes.set("rank", "sink");
+ legend_node.attributes.set("shape", "none");
+ legend_node.attributes.set("margin", 0);
+
+ std::stringstream ss;
+ ss << "<";
+ ss << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"4\">";
+ ss << "<TR><TD COLSPAN=\"2\"><B>Legend</B></TD></TR>";
#ifdef COLOR_SCHEME_NODE_CLASS
const char **colors = deg_debug_colors_light;
- deg_debug_graphviz_legend_color(ctx, "Operation", colors[4]);
- deg_debug_graphviz_legend_color(ctx, "Component", colors[1]);
- deg_debug_graphviz_legend_color(ctx, "ID Node", colors[5]);
- deg_debug_graphviz_legend_color(ctx, "NOOP", colors[8]);
- deg_debug_graphviz_legend_color(ctx, "Pinned OP", colors[7]);
+ deg_debug_graphviz_legend_color("Operation", colors[4], ss);
+ deg_debug_graphviz_legend_color("Component", colors[1], ss);
+ deg_debug_graphviz_legend_color("ID Node", colors[5], ss);
+ deg_debug_graphviz_legend_color("NOOP", colors[8], ss);
+ deg_debug_graphviz_legend_color("Pinned OP", colors[7], ss);
#endif
#ifdef COLOR_SCHEME_NODE_TYPE
@@ -206,18 +202,19 @@ static void deg_debug_graphviz_legend(const DebugContext &ctx)
for (pair = deg_debug_node_type_color_map; (*pair)[0] >= 0; pair++) {
DepsNodeFactory *nti = type_get_factory((NodeType)(*pair)[0]);
deg_debug_graphviz_legend_color(
- ctx, nti->tname().c_str(), deg_debug_colors_light[(*pair)[1] % deg_debug_max_colors]);
+ ctx, nti->tname().c_str(), deg_debug_colors_light[(*pair)[1] % deg_debug_max_colors], ss);
}
#endif
- deg_debug_fprintf(ctx, "</TABLE>" NL);
- deg_debug_fprintf(ctx, ">" NL);
- deg_debug_fprintf(ctx, ",fontname=\"%s\"", deg_debug_graphviz_fontname);
- deg_debug_fprintf(ctx, "];" NL);
- deg_debug_fprintf(ctx, "}" NL);
+ ss << "</TABLE>";
+ ss << ">";
+ legend_node.attributes.set("label", ss.str());
+ legend_node.attributes.set("fontname", deg_debug_graphviz_fontname);
}
-static void deg_debug_graphviz_node_color(const DebugContext &ctx, const Node *node)
+static void deg_debug_graphviz_node_color(DotExportContext &ctx,
+ const Node *node,
+ dot::Attributes &dot_attributes)
{
const char *color_default = "black";
const char *color_modified = "orangered4";
@@ -234,10 +231,12 @@ static void deg_debug_graphviz_node_color(const DebugContext &ctx, const Node *n
}
}
}
- deg_debug_fprintf(ctx, "\"%s\"", color);
+ dot_attributes.set("color", color);
}
-static void deg_debug_graphviz_node_penwidth(const DebugContext &ctx, const Node *node)
+static void deg_debug_graphviz_node_penwidth(DotExportContext &ctx,
+ const Node *node,
+ dot::Attributes &dot_attributes)
{
float penwidth_default = 1.0f;
float penwidth_modified = 4.0f;
@@ -254,20 +253,20 @@ static void deg_debug_graphviz_node_penwidth(const DebugContext &ctx, const Node
}
}
}
- deg_debug_fprintf(ctx, "\"%f\"", penwidth);
+ dot_attributes.set("penwidth", penwidth);
}
-static void deg_debug_graphviz_node_fillcolor(const DebugContext &ctx, const Node *node)
+static void deg_debug_graphviz_node_fillcolor(const Node *node, dot::Attributes &dot_attributes)
{
const char *defaultcolor = "gainsboro";
int color_index = deg_debug_node_color_index(node);
const char *fillcolor = color_index < 0 ?
defaultcolor :
deg_debug_colors_light[color_index % deg_debug_max_colors];
- deg_debug_fprintf(ctx, "\"%s\"", fillcolor);
+ dot_attributes.set("fillcolor", fillcolor);
}
-static void deg_debug_graphviz_relation_color(const DebugContext &ctx, const Relation *rel)
+static void deg_debug_graphviz_relation_color(const Relation *rel, dot::DirectedEdge &edge)
{
const char *color_default = "black";
const char *color_cyclic = "red4"; /* The color of crime scene. */
@@ -279,10 +278,10 @@ static void deg_debug_graphviz_relation_color(const DebugContext &ctx, const Rel
else if (rel->flag & RELATION_FLAG_GODMODE) {
color = color_godmode;
}
- deg_debug_fprintf(ctx, "%s", color);
+ edge.attributes.set("color", color);
}
-static void deg_debug_graphviz_relation_style(const DebugContext &ctx, const Relation *rel)
+static void deg_debug_graphviz_relation_style(const Relation *rel, dot::DirectedEdge &edge)
{
const char *style_default = "solid";
const char *style_no_flush = "dashed";
@@ -294,10 +293,10 @@ static void deg_debug_graphviz_relation_style(const DebugContext &ctx, const Rel
if (rel->flag & RELATION_FLAG_FLUSH_USER_EDIT_ONLY) {
style = style_flush_user_only;
}
- deg_debug_fprintf(ctx, "%s", style);
+ edge.attributes.set("style", style);
}
-static void deg_debug_graphviz_relation_arrowhead(const DebugContext &ctx, const Relation *rel)
+static void deg_debug_graphviz_relation_arrowhead(const Relation *rel, dot::DirectedEdge &edge)
{
const char *shape_default = "normal";
const char *shape_no_cow = "box";
@@ -311,12 +310,14 @@ static void deg_debug_graphviz_relation_arrowhead(const DebugContext &ctx, const
shape = shape_no_cow;
}
}
- deg_debug_fprintf(ctx, "%s", shape);
+ edge.attributes.set("arrowhead", shape);
}
-static void deg_debug_graphviz_node_style(const DebugContext &ctx, const Node *node)
+static void deg_debug_graphviz_node_style(DotExportContext &ctx,
+ const Node *node,
+ dot::Attributes &dot_attributes)
{
- const char *base_style = "filled"; /* default style */
+ StringRef base_style = "filled"; /* default style */
if (ctx.show_tags) {
if (node->get_class() == NodeClass::OPERATION) {
OperationNode *op_node = (OperationNode *)node;
@@ -327,95 +328,78 @@ static void deg_debug_graphviz_node_style(const DebugContext &ctx, const Node *n
}
switch (node->get_class()) {
case NodeClass::GENERIC:
- deg_debug_fprintf(ctx, "\"%s\"", base_style);
+ dot_attributes.set("style", base_style);
break;
case NodeClass::COMPONENT:
- deg_debug_fprintf(ctx, "\"%s\"", base_style);
+ dot_attributes.set("style", base_style);
break;
case NodeClass::OPERATION:
- deg_debug_fprintf(ctx, "\"%s,rounded\"", base_style);
+ dot_attributes.set("style", base_style + ",rounded");
break;
}
}
-static void deg_debug_graphviz_node_single(const DebugContext &ctx, const Node *node)
+static void deg_debug_graphviz_node_single(DotExportContext &ctx,
+ const Node *node,
+ dot::Cluster *parent_cluster)
{
- const char *shape = "box";
string name = node->identifier();
- deg_debug_fprintf(ctx, "// %s\n", name.c_str());
- deg_debug_fprintf(ctx, "\"node_%p\"", node);
- deg_debug_fprintf(ctx, "[");
- // deg_debug_fprintf(ctx, "label=<<B>%s</B>>", name);
- deg_debug_fprintf(ctx, "label=<%s>", name.c_str());
- deg_debug_fprintf(ctx, ",fontname=\"%s\"", deg_debug_graphviz_fontname);
- deg_debug_fprintf(ctx, ",fontsize=%f", deg_debug_graphviz_node_label_size);
- deg_debug_fprintf(ctx, ",shape=%s", shape);
- deg_debug_fprintf(ctx, ",style=");
- deg_debug_graphviz_node_style(ctx, node);
- deg_debug_fprintf(ctx, ",color=");
- deg_debug_graphviz_node_color(ctx, node);
- deg_debug_fprintf(ctx, ",fillcolor=");
- deg_debug_graphviz_node_fillcolor(ctx, node);
- deg_debug_fprintf(ctx, ",penwidth=");
- deg_debug_graphviz_node_penwidth(ctx, node);
- deg_debug_fprintf(ctx, "];" NL);
- deg_debug_fprintf(ctx, NL);
+
+ dot::Node &dot_node = ctx.digraph.new_node(name);
+ ctx.nodes_map.add_new(node, &dot_node);
+ dot_node.set_parent_cluster(parent_cluster);
+ dot_node.attributes.set("fontname", deg_debug_graphviz_fontname);
+ dot_node.attributes.set("frontsize", deg_debug_graphviz_node_label_size);
+ dot_node.attributes.set("shape", "box");
+
+ deg_debug_graphviz_node_style(ctx, node, dot_node.attributes);
+ deg_debug_graphviz_node_color(ctx, node, dot_node.attributes);
+ deg_debug_graphviz_node_fillcolor(node, dot_node.attributes);
+ deg_debug_graphviz_node_penwidth(ctx, node, dot_node.attributes);
}
-static void deg_debug_graphviz_node_cluster_begin(const DebugContext &ctx, const Node *node)
+static dot::Cluster &deg_debug_graphviz_node_cluster_create(DotExportContext &ctx,
+ const Node *node,
+ dot::Cluster *parent_cluster)
{
string name = node->identifier();
- deg_debug_fprintf(ctx, "// %s\n", name.c_str());
- deg_debug_fprintf(ctx, "subgraph \"cluster_%p\" {" NL, node);
- // deg_debug_fprintf(ctx, "label=<<B>%s</B>>;" NL, name);
- deg_debug_fprintf(ctx, "label=<%s>;" NL, name.c_str());
- deg_debug_fprintf(ctx, "fontname=\"%s\";" NL, deg_debug_graphviz_fontname);
- deg_debug_fprintf(ctx, "fontsize=%f;" NL, deg_debug_graphviz_node_label_size);
- deg_debug_fprintf(ctx, "margin=\"%d\";" NL, 16);
- deg_debug_fprintf(ctx, "style=");
- deg_debug_graphviz_node_style(ctx, node);
- deg_debug_fprintf(ctx, ";" NL);
- deg_debug_fprintf(ctx, "color=");
- deg_debug_graphviz_node_color(ctx, node);
- deg_debug_fprintf(ctx, ";" NL);
- deg_debug_fprintf(ctx, "fillcolor=");
- deg_debug_graphviz_node_fillcolor(ctx, node);
- deg_debug_fprintf(ctx, ";" NL);
- deg_debug_fprintf(ctx, "penwidth=");
- deg_debug_graphviz_node_penwidth(ctx, node);
- deg_debug_fprintf(ctx, ";" NL);
+ dot::Cluster &cluster = ctx.digraph.new_cluster(name);
+ cluster.set_parent_cluster(parent_cluster);
+ cluster.attributes.set("fontname", deg_debug_graphviz_fontname);
+ cluster.attributes.set("fontsize", deg_debug_graphviz_node_label_size);
+ cluster.attributes.set("margin", 16);
+ deg_debug_graphviz_node_style(ctx, node, cluster.attributes);
+ deg_debug_graphviz_node_color(ctx, node, cluster.attributes);
+ deg_debug_graphviz_node_fillcolor(node, cluster.attributes);
+ deg_debug_graphviz_node_penwidth(ctx, node, cluster.attributes);
/* dummy node, so we can add edges between clusters */
- deg_debug_fprintf(ctx, "\"node_%p\"", node);
- deg_debug_fprintf(ctx, "[");
- deg_debug_fprintf(ctx, "shape=%s", "point");
- deg_debug_fprintf(ctx, ",style=%s", "invis");
- deg_debug_fprintf(ctx, "];" NL);
- deg_debug_fprintf(ctx, NL);
+ dot::Node &dot_node = ctx.digraph.new_node("");
+ dot_node.attributes.set("shape", "point");
+ dot_node.attributes.set("style", "invis");
+ dot_node.set_parent_cluster(&cluster);
+ ctx.nodes_map.add_new(node, &dot_node);
+ ctx.clusters_map.add_new(node, &cluster);
+ return cluster;
}
-static void deg_debug_graphviz_node_cluster_end(const DebugContext &ctx)
-{
- deg_debug_fprintf(ctx, "}" NL);
- deg_debug_fprintf(ctx, NL);
-}
+static void deg_debug_graphviz_graph_nodes(DotExportContext &ctx, const Depsgraph *graph);
+static void deg_debug_graphviz_graph_relations(DotExportContext &ctx, const Depsgraph *graph);
-static void deg_debug_graphviz_graph_nodes(const DebugContext &ctx, const Depsgraph *graph);
-static void deg_debug_graphviz_graph_relations(const DebugContext &ctx, const Depsgraph *graph);
-
-static void deg_debug_graphviz_node(const DebugContext &ctx, const Node *node)
+static void deg_debug_graphviz_node(DotExportContext &ctx,
+ const Node *node,
+ dot::Cluster *parent_cluster)
{
switch (node->type) {
case NodeType::ID_REF: {
const IDNode *id_node = (const IDNode *)node;
if (id_node->components.is_empty()) {
- deg_debug_graphviz_node_single(ctx, node);
+ deg_debug_graphviz_node_single(ctx, node, parent_cluster);
}
else {
- deg_debug_graphviz_node_cluster_begin(ctx, node);
+ dot::Cluster &cluster = deg_debug_graphviz_node_cluster_create(ctx, node, parent_cluster);
for (const ComponentNode *comp : id_node->components.values()) {
- deg_debug_graphviz_node(ctx, comp);
+ deg_debug_graphviz_node(ctx, comp, &cluster);
}
- deg_debug_graphviz_node_cluster_end(ctx);
}
break;
}
@@ -445,127 +429,72 @@ static void deg_debug_graphviz_node(const DebugContext &ctx, const Node *node)
case NodeType::GENERIC_DATABLOCK:
case NodeType::SIMULATION: {
ComponentNode *comp_node = (ComponentNode *)node;
- if (!comp_node->operations.is_empty()) {
- deg_debug_graphviz_node_cluster_begin(ctx, node);
- for (Node *op_node : comp_node->operations) {
- deg_debug_graphviz_node(ctx, op_node);
- }
- deg_debug_graphviz_node_cluster_end(ctx);
+ if (comp_node->operations.is_empty()) {
+ deg_debug_graphviz_node_single(ctx, node, parent_cluster);
}
else {
- deg_debug_graphviz_node_single(ctx, node);
+ dot::Cluster &cluster = deg_debug_graphviz_node_cluster_create(ctx, node, parent_cluster);
+ for (Node *op_node : comp_node->operations) {
+ deg_debug_graphviz_node(ctx, op_node, &cluster);
+ }
}
break;
}
case NodeType::UNDEFINED:
case NodeType::TIMESOURCE:
case NodeType::OPERATION:
- deg_debug_graphviz_node_single(ctx, node);
+ deg_debug_graphviz_node_single(ctx, node, parent_cluster);
break;
case NodeType::NUM_TYPES:
break;
}
}
-static bool deg_debug_graphviz_is_cluster(const Node *node)
-{
- switch (node->type) {
- case NodeType::ID_REF: {
- const IDNode *id_node = (const IDNode *)node;
- return !id_node->components.is_empty();
- }
- case NodeType::PARAMETERS:
- case NodeType::ANIMATION:
- case NodeType::TRANSFORM:
- case NodeType::PROXY:
- case NodeType::GEOMETRY:
- case NodeType::SEQUENCER:
- case NodeType::EVAL_POSE:
- case NodeType::BONE: {
- ComponentNode *comp_node = (ComponentNode *)node;
- return !comp_node->operations.is_empty();
- }
- default:
- return false;
- }
-}
-
-static bool deg_debug_graphviz_is_owner(const Node *node, const Node *other)
-{
- switch (node->get_class()) {
- case NodeClass::COMPONENT: {
- ComponentNode *comp_node = (ComponentNode *)node;
- if (comp_node->owner == other) {
- return true;
- }
- break;
- }
- case NodeClass::OPERATION: {
- OperationNode *op_node = (OperationNode *)node;
- if (op_node->owner == other) {
- return true;
- }
- else if (op_node->owner->owner == other) {
- return true;
- }
- break;
- }
- default:
- break;
- }
- return false;
-}
-
-static void deg_debug_graphviz_node_relations(const DebugContext &ctx, const Node *node)
+static void deg_debug_graphviz_node_relations(DotExportContext &ctx, const Node *node)
{
for (Relation *rel : node->inlinks) {
float penwidth = 2.0f;
- const Node *tail = rel->to; /* same as node */
- const Node *head = rel->from;
- deg_debug_fprintf(
- ctx, "// %s -> %s\n", head->identifier().c_str(), tail->identifier().c_str());
- deg_debug_fprintf(ctx, "\"node_%p\"", head);
- deg_debug_fprintf(ctx, " -> ");
- deg_debug_fprintf(ctx, "\"node_%p\"", tail);
+ const Node *head = rel->to; /* same as node */
+ const Node *tail = rel->from;
+ dot::Node &dot_tail = *ctx.nodes_map.lookup(tail);
+ dot::Node &dot_head = *ctx.nodes_map.lookup(head);
+
+ dot::DirectedEdge &edge = ctx.digraph.new_edge(dot_tail, dot_head);
- deg_debug_fprintf(ctx, "[");
/* Note: without label an id seem necessary to avoid bugs in graphviz/dot */
- deg_debug_fprintf(ctx, "id=\"%s\"", rel->name);
- // deg_debug_fprintf(ctx, "label=\"%s\"", rel->name);
- deg_debug_fprintf(ctx, ",color=");
- deg_debug_graphviz_relation_color(ctx, rel);
- deg_debug_fprintf(ctx, ",style=");
- deg_debug_graphviz_relation_style(ctx, rel);
- deg_debug_fprintf(ctx, ",arrowhead=");
- deg_debug_graphviz_relation_arrowhead(ctx, rel);
- deg_debug_fprintf(ctx, ",penwidth=\"%f\"", penwidth);
+ edge.attributes.set("id", rel->name);
+ deg_debug_graphviz_relation_color(rel, edge);
+ deg_debug_graphviz_relation_style(rel, edge);
+ deg_debug_graphviz_relation_arrowhead(rel, edge);
+ edge.attributes.set("penwidth", penwidth);
+
/* NOTE: edge from node to own cluster is not possible and gives graphviz
* warning, avoid this here by just linking directly to the invisible
* placeholder node. */
- if (deg_debug_graphviz_is_cluster(tail) && !deg_debug_graphviz_is_owner(head, tail)) {
- deg_debug_fprintf(ctx, ",ltail=\"cluster_%p\"", tail);
+ dot::Cluster *tail_cluster = ctx.clusters_map.lookup_default(tail, nullptr);
+ if (tail_cluster != nullptr && tail_cluster->contains(dot_head)) {
+ edge.attributes.set("ltail", tail_cluster->name());
}
- if (deg_debug_graphviz_is_cluster(head) && !deg_debug_graphviz_is_owner(tail, head)) {
- deg_debug_fprintf(ctx, ",lhead=\"cluster_%p\"", head);
+ dot::Cluster *head_cluster = ctx.clusters_map.lookup_default(head, nullptr);
+ if (head_cluster != nullptr && head_cluster->contains(dot_tail)) {
+ edge.attributes.set("lhead", head_cluster->name());
}
- deg_debug_fprintf(ctx, "];" NL);
- deg_debug_fprintf(ctx, NL);
}
}
-static void deg_debug_graphviz_graph_nodes(const DebugContext &ctx, const Depsgraph *graph)
+static void deg_debug_graphviz_graph_nodes(DotExportContext &ctx, const Depsgraph *graph)
{
for (Node *node : graph->id_nodes) {
- deg_debug_graphviz_node(ctx, node);
+ deg_debug_graphviz_node(ctx, node, nullptr);
}
TimeSourceNode *time_source = graph->find_time_source();
if (time_source != nullptr) {
- deg_debug_graphviz_node(ctx, time_source);
+ deg_debug_graphviz_node(ctx, time_source, nullptr);
}
}
-static void deg_debug_graphviz_graph_relations(const DebugContext &ctx, const Depsgraph *graph)
+static void deg_debug_graphviz_graph_relations(DotExportContext &ctx, const Depsgraph *graph)
{
for (IDNode *id_node : graph->id_nodes) {
for (ComponentNode *comp_node : id_node->components.values()) {
@@ -592,27 +521,23 @@ void DEG_debug_relations_graphviz(const Depsgraph *graph, FILE *f, const char *l
const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph);
- deg::DebugContext ctx;
- ctx.file = f;
-
- deg::deg_debug_fprintf(ctx, "digraph depgraph {" NL);
- deg::deg_debug_fprintf(ctx, "rankdir=LR;" NL);
- deg::deg_debug_fprintf(ctx, "graph [");
- deg::deg_debug_fprintf(ctx, "compound=true");
- deg::deg_debug_fprintf(ctx, ",labelloc=\"t\"");
- deg::deg_debug_fprintf(ctx, ",fontsize=%f", deg::deg_debug_graphviz_graph_label_size);
- deg::deg_debug_fprintf(ctx, ",fontname=\"%s\"", deg::deg_debug_graphviz_fontname);
- deg::deg_debug_fprintf(ctx, ",label=\"%s\"", label);
- deg::deg_debug_fprintf(ctx, ",splines=ortho");
- deg::deg_debug_fprintf(ctx, ",overlap=scalexy"); // XXX: only when using neato
- deg::deg_debug_fprintf(ctx, "];" NL);
+ dot::DirectedGraph digraph;
+ deg::DotExportContext ctx{false, digraph};
+
+ digraph.set_rankdir(dot::Attr_rankdir::LeftToRight);
+ digraph.attributes.set("compound", "true");
+ digraph.attributes.set("labelloc", "t");
+ digraph.attributes.set("fontsize", deg::deg_debug_graphviz_graph_label_size);
+ digraph.attributes.set("fontname", deg::deg_debug_graphviz_fontname);
+ digraph.attributes.set("label", label);
+ digraph.attributes.set("splines", "ortho");
+ digraph.attributes.set("overlap", "scalexy");
deg::deg_debug_graphviz_graph_nodes(ctx, deg_graph);
deg::deg_debug_graphviz_graph_relations(ctx, deg_graph);
deg::deg_debug_graphviz_legend(ctx);
- deg::deg_debug_fprintf(ctx, "}" NL);
+ std::string dot_string = digraph.to_dot_string();
+ fprintf(f, "%s", dot_string.c_str());
}
-
-#undef NL
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc b/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc
index 515b53297b9..16bdc2d6115 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc
@@ -83,7 +83,7 @@ string gnuplotify_id_code(const string &name)
string gnuplotify_name(const string &name)
{
- string result = "";
+ string result;
const int length = name.length();
for (int i = 0; i < length; i++) {
const char ch = name[i];
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index c11d051e663..fb933cb38f3 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -43,12 +43,11 @@
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_debug.h"
-#include "builder/deg_builder.h"
-#include "builder/deg_builder_cache.h"
-#include "builder/deg_builder_cycle.h"
-#include "builder/deg_builder_nodes.h"
#include "builder/deg_builder_relations.h"
-#include "builder/deg_builder_transitive.h"
+#include "builder/pipeline_compositor.h"
+#include "builder/pipeline_from_ids.h"
+#include "builder/pipeline_render.h"
+#include "builder/pipeline_view_layer.h"
#include "intern/debug/deg_debug.h"
@@ -209,65 +208,14 @@ struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *node_handle)
/* ******************** */
/* Graph Building API's */
-static void graph_build_finalize_common(deg::Depsgraph *deg_graph, Main *bmain)
-{
- /* Detect and solve cycles. */
- deg::deg_graph_detect_cycles(deg_graph);
- /* Simplify the graph by removing redundant relations (to optimize
- * traversal later). */
- /* TODO: it would be useful to have an option to disable this in cases where
- * it is causing trouble. */
- if (G.debug_value == 799) {
- deg::deg_graph_transitive_reduction(deg_graph);
- }
- /* Store pointers to commonly used valuated datablocks. */
- deg_graph->scene_cow = (Scene *)deg_graph->get_cow_id(&deg_graph->scene->id);
- /* Flush visibility layer and re-schedule nodes for update. */
- deg::deg_graph_build_finalize(bmain, deg_graph);
- DEG_graph_on_visible_update(bmain, reinterpret_cast<::Depsgraph *>(deg_graph), false);
-#if 0
- if (!DEG_debug_consistency_check(deg_graph)) {
- printf("Consistency validation failed, ABORTING!\n");
- abort();
- }
-#endif
- /* Relations are up to date. */
- deg_graph->need_update = false;
-}
-
/* Build depsgraph for the given scene layer, and dump results in given graph container. */
void DEG_graph_build_from_view_layer(Depsgraph *graph,
Main *bmain,
Scene *scene,
ViewLayer *view_layer)
{
- double start_time = 0.0;
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- start_time = PIL_check_seconds_timer();
- }
- deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
- /* Perform sanity checks. */
- BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1);
- BLI_assert(deg_graph->scene == scene);
- BLI_assert(deg_graph->view_layer == view_layer);
- deg::DepsgraphBuilderCache builder_cache;
- /* Generate all the nodes in the graph first */
- deg::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache);
- node_builder.begin_build();
- node_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY);
- node_builder.end_build();
- /* Hook up relationships between operations - to determine evaluation order. */
- deg::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache);
- relation_builder.begin_build();
- relation_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY);
- relation_builder.build_copy_on_write_relations();
- relation_builder.build_driver_relations();
- /* Finalize building. */
- graph_build_finalize_common(deg_graph, bmain);
- /* Finish statistics. */
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
- }
+ deg::ViewLayerBuilderPipeline builder(graph, bmain, scene, view_layer);
+ builder.build();
}
void DEG_graph_build_for_render_pipeline(Depsgraph *graph,
@@ -275,170 +223,17 @@ void DEG_graph_build_for_render_pipeline(Depsgraph *graph,
Scene *scene,
ViewLayer *view_layer)
{
- double start_time = 0.0;
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- start_time = PIL_check_seconds_timer();
- }
- deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
- /* Perform sanity checks. */
- BLI_assert(deg_graph->scene == scene);
- deg_graph->is_render_pipeline_depsgraph = true;
- deg::DepsgraphBuilderCache builder_cache;
- /* Generate all the nodes in the graph first */
- deg::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache);
- node_builder.begin_build();
- node_builder.build_scene_render(scene, view_layer);
- node_builder.end_build();
- /* Hook up relationships between operations - to determine evaluation
- * order. */
- deg::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache);
- relation_builder.begin_build();
- relation_builder.build_scene_render(scene, view_layer);
- relation_builder.build_copy_on_write_relations();
- relation_builder.build_driver_relations();
- /* Finalize building. */
- graph_build_finalize_common(deg_graph, bmain);
- /* Finish statistics. */
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
- }
+ deg::RenderBuilderPipeline builder(graph, bmain, scene, view_layer);
+ builder.build();
}
void DEG_graph_build_for_compositor_preview(
Depsgraph *graph, Main *bmain, Scene *scene, struct ViewLayer *view_layer, bNodeTree *nodetree)
{
- double start_time = 0.0;
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- start_time = PIL_check_seconds_timer();
- }
- deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
- /* Perform sanity checks. */
- BLI_assert(deg_graph->scene == scene);
- deg_graph->is_render_pipeline_depsgraph = true;
- deg::DepsgraphBuilderCache builder_cache;
- /* Generate all the nodes in the graph first */
- deg::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache);
- node_builder.begin_build();
- node_builder.build_scene_render(scene, view_layer);
- node_builder.build_nodetree(nodetree);
- node_builder.end_build();
- /* Hook up relationships between operations - to determine evaluation
- * order. */
- deg::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache);
- relation_builder.begin_build();
- relation_builder.build_scene_render(scene, view_layer);
- relation_builder.build_nodetree(nodetree);
- relation_builder.build_copy_on_write_relations();
- relation_builder.build_driver_relations();
- /* Finalize building. */
- graph_build_finalize_common(deg_graph, bmain);
- /* Finish statistics. */
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
- }
+ deg::CompositorBuilderPipeline builder(graph, bmain, scene, view_layer, nodetree);
+ builder.build();
}
-/* Optimized builders for dependency graph built from a given set of IDs.
- *
- * General notes:
- *
- * - We pull in all bases if their objects are in the set of IDs. This allows to have proper
- * visibility and other flags assigned to the objects.
- * All other bases (the ones which points to object which is outside of the set of IDs) are
- * completely ignored.
- *
- * - Proxy groups pointing to objects which are outside of the IDs set are also ignored.
- * This way we avoid high-poly character body pulled into the dependency graph when it's coming
- * from a library into an animation file and the dependency graph constructed for a proxy rig. */
-
-namespace blender {
-namespace deg {
-namespace {
-
-class DepsgraphFromIDsFilter {
- public:
- DepsgraphFromIDsFilter(ID **ids, const int num_ids)
- {
- for (int i = 0; i < num_ids; ++i) {
- ids_.add(ids[i]);
- }
- }
-
- bool contains(ID *id)
- {
- return ids_.contains(id);
- }
-
- protected:
- Set<ID *> ids_;
-};
-
-class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder {
- public:
- DepsgraphFromIDsNodeBuilder(
- Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids)
- : DepsgraphNodeBuilder(bmain, graph, cache), filter_(ids, num_ids)
- {
- }
-
- virtual bool need_pull_base_into_graph(Base *base) override
- {
- if (!filter_.contains(&base->object->id)) {
- return false;
- }
- return DepsgraphNodeBuilder::need_pull_base_into_graph(base);
- }
-
- virtual void build_object_proxy_group(Object *object, bool is_visible) override
- {
- if (object->proxy_group == nullptr) {
- return;
- }
- if (!filter_.contains(&object->proxy_group->id)) {
- return;
- }
- DepsgraphNodeBuilder::build_object_proxy_group(object, is_visible);
- }
-
- protected:
- DepsgraphFromIDsFilter filter_;
-};
-
-class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder {
- public:
- DepsgraphFromIDsRelationBuilder(
- Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids)
- : DepsgraphRelationBuilder(bmain, graph, cache), filter_(ids, num_ids)
- {
- }
-
- virtual bool need_pull_base_into_graph(Base *base) override
- {
- if (!filter_.contains(&base->object->id)) {
- return false;
- }
- return DepsgraphRelationBuilder::need_pull_base_into_graph(base);
- }
-
- virtual void build_object_proxy_group(Object *object) override
- {
- if (object->proxy_group == nullptr) {
- return;
- }
- if (!filter_.contains(&object->proxy_group->id)) {
- return;
- }
- DepsgraphRelationBuilder::build_object_proxy_group(object);
- }
-
- protected:
- DepsgraphFromIDsFilter filter_;
-};
-
-} // namespace
-} // namespace deg
-} // namespace blender
-
void DEG_graph_build_from_ids(Depsgraph *graph,
Main *bmain,
Scene *scene,
@@ -446,40 +241,8 @@ void DEG_graph_build_from_ids(Depsgraph *graph,
ID **ids,
const int num_ids)
{
- double start_time = 0.0;
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- start_time = PIL_check_seconds_timer();
- }
- deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph);
- /* Perform sanity checks. */
- BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1);
- BLI_assert(deg_graph->scene == scene);
- BLI_assert(deg_graph->view_layer == view_layer);
- deg::DepsgraphBuilderCache builder_cache;
- /* Generate all the nodes in the graph first */
- deg::DepsgraphFromIDsNodeBuilder node_builder(bmain, deg_graph, &builder_cache, ids, num_ids);
- node_builder.begin_build();
- node_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY);
- for (int i = 0; i < num_ids; ++i) {
- node_builder.build_id(ids[i]);
- }
- node_builder.end_build();
- /* Hook up relationships between operations - to determine evaluation order. */
- deg::DepsgraphFromIDsRelationBuilder relation_builder(
- bmain, deg_graph, &builder_cache, ids, num_ids);
- relation_builder.begin_build();
- relation_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY);
- for (int i = 0; i < num_ids; ++i) {
- relation_builder.build_id(ids[i]);
- }
- relation_builder.build_copy_on_write_relations();
- relation_builder.build_driver_relations();
- /* Finalize building. */
- graph_build_finalize_common(deg_graph, bmain);
- /* Finish statistics. */
- if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
- printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
- }
+ deg::FromIDsBuilderPipeline builder(graph, bmain, scene, view_layer, ids, num_ids);
+ builder.build();
}
/* Tag graph relations for update. */
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
index 814f467e3d5..048c0125f53 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
@@ -282,15 +282,14 @@ void DEG_iterator_objects_next(BLI_Iterator *iter)
if (deg_objects_dupli_iterator_next(iter)) {
return;
}
- else {
- verify_id_properties_freed(data);
- free_object_duplilist(data->dupli_list);
- data->dupli_parent = nullptr;
- data->dupli_list = nullptr;
- data->dupli_object_next = nullptr;
- data->dupli_object_current = nullptr;
- deg_invalidate_iterator_work_data(data);
- }
+
+ verify_id_properties_freed(data);
+ free_object_duplilist(data->dupli_list);
+ data->dupli_parent = nullptr;
+ data->dupli_list = nullptr;
+ data->dupli_object_next = nullptr;
+ data->dupli_object_current = nullptr;
+ deg_invalidate_iterator_work_data(data);
}
++data->id_node_index;
@@ -324,7 +323,7 @@ static void DEG_iterator_ids_step(BLI_Iterator *iter, deg::IDNode *id_node, bool
iter->skip = true;
return;
}
- else if (only_updated && !(id_cow->recalc & ID_RECALC_ALL)) {
+ if (only_updated && !(id_cow->recalc & ID_RECALC_ALL)) {
bNodeTree *ntree = ntreeFromID(id_cow);
/* Nodetree is considered part of the datablock. */
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 1863a333930..4a2d47f9379 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -48,11 +48,8 @@
#include "BKE_idtype.h"
#include "BKE_node.h"
#include "BKE_scene.h"
-#include "BKE_workspace.h"
-
-#define new new_
#include "BKE_screen.h"
-#undef new
+#include "BKE_workspace.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_debug.h"
@@ -375,7 +372,7 @@ void graph_id_tag_update_single_flag(Main *bmain,
}
return;
}
- else if (tag == ID_RECALC_TIME) {
+ if (tag == ID_RECALC_TIME) {
if (graph != nullptr) {
graph->need_update_time = true;
}
@@ -432,7 +429,7 @@ string stringify_update_bitfield(int flag)
if (flag == 0) {
return "LEGACY_0";
}
- string result = "";
+ string result;
int current_flag = flag;
/* Special cases to avoid ALL flags form being split into
* individual bits. */
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index 6ca30a67f1f..1ede2cf914a 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -353,9 +353,8 @@ static TaskPool *deg_evaluate_task_pool_create(DepsgraphEvalState *state)
if (G.debug & G_DEBUG_DEPSGRAPH_NO_THREADS) {
return BLI_task_pool_create_no_threads(state);
}
- else {
- return BLI_task_pool_create_suspended(state, TASK_PRIORITY_HIGH);
- }
+
+ return BLI_task_pool_create_suspended(state, TASK_PRIORITY_HIGH);
}
/**
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 82cb311ec45..0bf6c38bc89 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -288,6 +288,14 @@ bool id_copy_inplace_no_main(const ID *id, ID *newid)
{
const ID *id_for_copy = id;
+ if (G.debug & G_DEBUG_DEPSGRAPH_UUID) {
+ const ID_Type id_type = GS(id_for_copy->name);
+ if (id_type == ID_OB) {
+ const Object *object = reinterpret_cast<const Object *>(id_for_copy);
+ BKE_object_check_uuids_unique_and_report(object);
+ }
+ }
+
#ifdef NESTED_ID_NASTY_WORKAROUND
NestedIDHackTempStorage id_hack_storage;
id_for_copy = nested_id_hack_get_discarded_pointers(&id_hack_storage, id);
@@ -311,6 +319,10 @@ bool scene_copy_inplace_no_main(const Scene *scene, Scene *new_scene)
{
const ID *id_for_copy = &scene->id;
+ if (G.debug & G_DEBUG_DEPSGRAPH_UUID) {
+ BKE_sequencer_check_uuids_unique_and_report(scene);
+ }
+
#ifdef NESTED_ID_NASTY_WORKAROUND
NestedIDHackTempStorage id_hack_storage;
id_for_copy = nested_id_hack_get_discarded_pointers(&id_hack_storage, &scene->id);
@@ -336,7 +348,7 @@ ViewLayer *get_original_view_layer(const Depsgraph *depsgraph, const IDNode *id_
if (id_node->linked_state == DEG_ID_LINKED_DIRECTLY) {
return depsgraph->view_layer;
}
- else if (id_node->linked_state == DEG_ID_LINKED_VIA_SET) {
+ if (id_node->linked_state == DEG_ID_LINKED_VIA_SET) {
Scene *scene_orig = reinterpret_cast<Scene *>(id_node->id_orig);
return BKE_view_layer_default_render(scene_orig);
}
@@ -370,7 +382,7 @@ void scene_remove_unused_view_layers(const Depsgraph *depsgraph,
}
return;
}
- else if (id_node->linked_state == DEG_ID_LINKED_INDIRECTLY) {
+ if (id_node->linked_state == DEG_ID_LINKED_INDIRECTLY) {
/* Indirectly linked scenes means it's not an input scene and not a set scene, and is pulled
* via some driver. Such scenes should not have view layers after copy. */
view_layer_input = nullptr;
@@ -481,25 +493,6 @@ void scene_setup_view_layers_after_remap(const Depsgraph *depsgraph,
* Still not an excuse to have those. */
}
-void update_sequence_orig_pointers(const ListBase *sequences_orig, ListBase *sequences_cow)
-{
- Sequence *sequence_orig = reinterpret_cast<Sequence *>(sequences_orig->first);
- Sequence *sequence_cow = reinterpret_cast<Sequence *>(sequences_cow->first);
- while (sequence_orig != nullptr) {
- update_sequence_orig_pointers(&sequence_orig->seqbase, &sequence_cow->seqbase);
- sequence_cow->orig_sequence = sequence_orig;
- sequence_cow = sequence_cow->next;
- sequence_orig = sequence_orig->next;
- }
-}
-
-void update_scene_orig_pointers(const Scene *scene_orig, Scene *scene_cow)
-{
- if (scene_orig->ed != nullptr) {
- update_sequence_orig_pointers(&scene_orig->ed->seqbase, &scene_cow->ed->seqbase);
- }
-}
-
/* Check whether given ID is expanded or still a shallow copy. */
inline bool check_datablock_expanded(const ID *id_cow)
{
@@ -812,7 +805,6 @@ void update_id_after_copy(const Depsgraph *depsgraph,
scene_cow->toolsettings = scene_orig->toolsettings;
scene_cow->eevee.light_cache_data = scene_orig->eevee.light_cache_data;
scene_setup_view_layers_after_remap(depsgraph, id_node, reinterpret_cast<Scene *>(id_cow));
- update_scene_orig_pointers(scene_orig, scene_cow);
break;
}
default:
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc
index 934403674a9..25bcf2bfe72 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc
@@ -23,28 +23,14 @@
#include "intern/eval/deg_eval_runtime_backup_modifier.h"
+#include "DNA_modifier_types.h"
+
namespace blender {
namespace deg {
-ModifierDataBackupID::ModifierDataBackupID(const Depsgraph * /*depsgraph*/)
- : ModifierDataBackupID(nullptr, eModifierType_None)
-{
-}
-
-ModifierDataBackupID::ModifierDataBackupID(ModifierData *modifier_data, ModifierType type)
- : modifier_data(modifier_data), type(type)
-{
-}
-
-bool operator==(const ModifierDataBackupID &a, const ModifierDataBackupID &b)
-{
- return a.modifier_data == b.modifier_data && a.type == b.type;
-}
-
-uint64_t ModifierDataBackupID::hash() const
+ModifierDataBackup::ModifierDataBackup(ModifierData *modifier_data)
+ : type(static_cast<ModifierType>(modifier_data->type)), runtime(modifier_data->runtime)
{
- uintptr_t ptr = (uintptr_t)modifier_data;
- return (ptr >> 4) ^ (uintptr_t)type;
}
} // namespace deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.h
index a5bdf2359ee..f02dc73c392 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.h
@@ -25,38 +25,18 @@
#include "BKE_modifier.h"
-#include "intern/depsgraph_type.h"
-
struct ModifierData;
namespace blender {
namespace deg {
-struct Depsgraph;
-
-/* Identifier used to match modifiers to backup/restore their runtime data.
- * Identification is happening using original modifier data pointer and the
- * modifier type.
- * It is not enough to only pointer, since it's possible to have a situation
- * when modifier is removed and a new one added, and due to memory allocation
- * policy they might have same pointer.
- * By adding type into matching we are at least ensuring that modifier will not
- * try to interpret runtime data created by another modifier type. */
-class ModifierDataBackupID {
+class ModifierDataBackup {
public:
- ModifierDataBackupID(const Depsgraph *depsgraph);
- ModifierDataBackupID(ModifierData *modifier_data, ModifierType type);
-
- friend bool operator==(const ModifierDataBackupID &a, const ModifierDataBackupID &b);
+ explicit ModifierDataBackup(ModifierData *modifier_data);
- uint64_t hash() const;
-
- ModifierData *modifier_data;
ModifierType type;
+ void *runtime;
};
-/* Storage for backed up runtime modifier data. */
-typedef Map<ModifierDataBackupID, void *> ModifierRuntimeDataBackup;
-
} // namespace deg
} // namespace blender
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc
index e0957a10cb1..addee3dc539 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc
@@ -62,21 +62,18 @@ void ObjectRuntimeBackup::init_from_object(Object *object)
backup_pose_channel_runtime_data(object);
}
-inline ModifierDataBackupID create_modifier_data_id(const ModifierData *modifier_data)
-{
- return ModifierDataBackupID(modifier_data->orig_modifier_data,
- static_cast<ModifierType>(modifier_data->type));
-}
-
void ObjectRuntimeBackup::backup_modifier_runtime_data(Object *object)
{
LISTBASE_FOREACH (ModifierData *, modifier_data, &object->modifiers) {
if (modifier_data->runtime == nullptr) {
continue;
}
+
+ const SessionUUID &session_uuid = modifier_data->session_uuid;
+ BLI_assert(BLI_session_uuid_is_generated(&session_uuid));
+
BLI_assert(modifier_data->orig_modifier_data != nullptr);
- ModifierDataBackupID modifier_data_id = create_modifier_data_id(modifier_data);
- modifier_runtime_data.add(modifier_data_id, modifier_data->runtime);
+ modifier_runtime_data.add(session_uuid, ModifierDataBackup(modifier_data));
modifier_data->runtime = nullptr;
}
}
@@ -85,11 +82,11 @@ void ObjectRuntimeBackup::backup_pose_channel_runtime_data(Object *object)
{
if (object->pose != nullptr) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
- /* This is nullptr in Edit mode. */
- if (pchan->orig_pchan != nullptr) {
- pose_channel_runtime_data.add(pchan->orig_pchan, pchan->runtime);
- BKE_pose_channel_runtime_reset(&pchan->runtime);
- }
+ const SessionUUID &session_uuid = pchan->runtime.session_uuid;
+ BLI_assert(BLI_session_uuid_is_generated(&session_uuid));
+
+ pose_channel_runtime_data.add(session_uuid, pchan->runtime);
+ BKE_pose_channel_runtime_reset(&pchan->runtime);
}
}
}
@@ -153,17 +150,17 @@ void ObjectRuntimeBackup::restore_modifier_runtime_data(Object *object)
{
LISTBASE_FOREACH (ModifierData *, modifier_data, &object->modifiers) {
BLI_assert(modifier_data->orig_modifier_data != nullptr);
- ModifierDataBackupID modifier_data_id = create_modifier_data_id(modifier_data);
- void *runtime = modifier_runtime_data.pop_default(modifier_data_id, nullptr);
- if (runtime != nullptr) {
- modifier_data->runtime = runtime;
+ const SessionUUID &session_uuid = modifier_data->session_uuid;
+ optional<ModifierDataBackup> backup = modifier_runtime_data.pop_try(session_uuid);
+ if (backup.has_value()) {
+ modifier_data->runtime = backup->runtime;
}
}
- for (ModifierRuntimeDataBackup::Item item : modifier_runtime_data.items()) {
- const ModifierTypeInfo *modifier_type_info = BKE_modifier_get_info(item.key.type);
+ for (ModifierDataBackup &backup : modifier_runtime_data.values()) {
+ const ModifierTypeInfo *modifier_type_info = BKE_modifier_get_info(backup.type);
BLI_assert(modifier_type_info != nullptr);
- modifier_type_info->freeRuntimeData(item.value);
+ modifier_type_info->freeRuntimeData(backup.runtime);
}
}
@@ -171,13 +168,10 @@ void ObjectRuntimeBackup::restore_pose_channel_runtime_data(Object *object)
{
if (object->pose != nullptr) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
- /* This is nullptr in Edit mode. */
- if (pchan->orig_pchan != nullptr) {
- optional<bPoseChannel_Runtime> runtime = pose_channel_runtime_data.pop_try(
- pchan->orig_pchan);
- if (runtime.has_value()) {
- pchan->runtime = *runtime;
- }
+ const SessionUUID &session_uuid = pchan->runtime.session_uuid;
+ optional<bPoseChannel_Runtime> runtime = pose_channel_runtime_data.pop_try(session_uuid);
+ if (runtime.has_value()) {
+ pchan->runtime = *runtime;
}
}
}
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h
index 04d7fb1bc22..5f6b443a2b2 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h
@@ -24,6 +24,9 @@
#pragma once
#include "DNA_object_types.h"
+#include "DNA_session_uuid_types.h"
+
+#include "BLI_session_uuid.h"
#include "intern/eval/deg_eval_runtime_backup_modifier.h"
#include "intern/eval/deg_eval_runtime_backup_pose.h"
@@ -33,6 +36,8 @@ struct Object;
namespace blender {
namespace deg {
+struct Depsgraph;
+
class ObjectRuntimeBackup {
public:
ObjectRuntimeBackup(const Depsgraph *depsgraph);
@@ -53,8 +58,8 @@ class ObjectRuntimeBackup {
Object_Runtime runtime;
short base_flag;
unsigned short base_local_view_bits;
- ModifierRuntimeDataBackup modifier_runtime_data;
- Map<bPoseChannel *, bPoseChannel_Runtime> pose_channel_runtime_data;
+ Map<SessionUUID, ModifierDataBackup> modifier_runtime_data;
+ Map<SessionUUID, bPoseChannel_Runtime> pose_channel_runtime_data;
};
} // namespace deg
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc
index 2780938fe05..ba7d20c0ba8 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc
@@ -26,6 +26,8 @@
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
+#include "BLI_assert.h"
+
#include "BKE_sequencer.h"
#include "BKE_sound.h"
@@ -43,7 +45,9 @@ void SequencerBackup::init_from_scene(Scene *scene)
SequenceBackup sequence_backup(depsgraph);
sequence_backup.init_from_sequence(sequence);
if (!sequence_backup.isEmpty()) {
- sequences_backup.add(sequence->orig_sequence, sequence_backup);
+ const SessionUUID &session_uuid = sequence->runtime.session_uuid;
+ BLI_assert(BLI_session_uuid_is_generated(&session_uuid));
+ sequences_backup.add(session_uuid, sequence_backup);
}
}
SEQ_END;
@@ -53,7 +57,9 @@ void SequencerBackup::restore_to_scene(Scene *scene)
{
Sequence *sequence;
SEQ_BEGIN (scene->ed, sequence) {
- SequenceBackup *sequence_backup = sequences_backup.lookup_ptr(sequence->orig_sequence);
+ const SessionUUID &session_uuid = sequence->runtime.session_uuid;
+ BLI_assert(BLI_session_uuid_is_generated(&session_uuid));
+ SequenceBackup *sequence_backup = sequences_backup.lookup_ptr(session_uuid);
if (sequence_backup != nullptr) {
sequence_backup->restore_to_sequence(sequence);
}
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.h
index 9fe38ec270c..4419238da32 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.h
@@ -23,6 +23,10 @@
#pragma once
+#include "DNA_session_uuid_types.h"
+
+#include "BLI_session_uuid.h"
+
#include "intern/depsgraph_type.h"
#include "intern/eval/deg_eval_runtime_backup_sequence.h"
@@ -43,7 +47,7 @@ class SequencerBackup {
const Depsgraph *depsgraph;
- Map<Sequence *, SequenceBackup> sequences_backup;
+ Map<SessionUUID, SequenceBackup> sequences_backup;
};
} // namespace deg
diff --git a/source/blender/depsgraph/intern/node/deg_node.cc b/source/blender/depsgraph/intern/node/deg_node.cc
index 9e386f13888..b10e66336dc 100644
--- a/source/blender/depsgraph/intern/node/deg_node.cc
+++ b/source/blender/depsgraph/intern/node/deg_node.cc
@@ -317,12 +317,11 @@ NodeClass Node::get_class() const
if (type == NodeType::OPERATION) {
return NodeClass::OPERATION;
}
- else if (type < NodeType::PARAMETERS) {
+ if (type < NodeType::PARAMETERS) {
return NodeClass::GENERIC;
}
- else {
- return NodeClass::COMPONENT;
- }
+
+ return NodeClass::COMPONENT;
}
/*******************************************************************************
diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc
index cd82b7be050..2767513d6df 100644
--- a/source/blender/depsgraph/intern/node/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_component.cc
@@ -251,7 +251,7 @@ OperationNode *ComponentNode::get_entry_operation()
if (entry_operation) {
return entry_operation;
}
- else if (operations_map != nullptr && operations_map->size() == 1) {
+ if (operations_map != nullptr && operations_map->size() == 1) {
OperationNode *op_node = nullptr;
/* TODO(sergey): This is somewhat slow. */
for (OperationNode *tmp : operations_map->values()) {
@@ -261,7 +261,7 @@ OperationNode *ComponentNode::get_entry_operation()
entry_operation = op_node;
return op_node;
}
- else if (operations.size() == 1) {
+ if (operations.size() == 1) {
return operations[0];
}
return nullptr;
@@ -272,7 +272,7 @@ OperationNode *ComponentNode::get_exit_operation()
if (exit_operation) {
return exit_operation;
}
- else if (operations_map != nullptr && operations_map->size() == 1) {
+ if (operations_map != nullptr && operations_map->size() == 1) {
OperationNode *op_node = nullptr;
/* TODO(sergey): This is somewhat slow. */
for (OperationNode *tmp : operations_map->values()) {
@@ -282,7 +282,7 @@ OperationNode *ComponentNode::get_exit_operation()
exit_operation = op_node;
return op_node;
}
- else if (operations.size() == 1) {
+ if (operations.size() == 1) {
return operations[0];
}
return nullptr;
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index cfcd4e0c65a..f85b03dc517 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -64,6 +64,7 @@ set(SRC
intern/draw_color_management.c
intern/draw_common.c
intern/draw_debug.c
+ intern/draw_fluid.c
intern/draw_hair.c
intern/draw_instance_data.c
intern/draw_manager.c
@@ -186,10 +187,10 @@ set(LIB
)
data_to_c_simple(engines/eevee/shaders/ambient_occlusion_lib.glsl SRC)
-data_to_c_simple(engines/eevee/shaders/default_frag.glsl SRC)
-data_to_c_simple(engines/eevee/shaders/default_world_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/background_vert.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/closure_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/common_uniforms_lib.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/common_utiltex_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lights_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl SRC)
@@ -204,8 +205,8 @@ data_to_c_simple(engines/eevee/shaders/lightprobe_grid_display_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_grid_fill_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_planar_display_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/lightprobe_planar_display_vert.glsl SRC)
-data_to_c_simple(engines/eevee/shaders/lit_surface_frag.glsl SRC)
-data_to_c_simple(engines/eevee/shaders/lit_surface_vert.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/lookdev_world_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/closure_lit_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_bloom_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_dof_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/effect_dof_frag.glsl SRC)
@@ -229,7 +230,6 @@ data_to_c_simple(engines/eevee/shaders/object_motion_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/prepass_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/prepass_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/shadow_accum_frag.glsl SRC)
-
data_to_c_simple(engines/eevee/shaders/shadow_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/shadow_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/bsdf_lut_frag.glsl SRC)
@@ -240,9 +240,14 @@ data_to_c_simple(engines/eevee/shaders/octahedron_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/cubemap_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/bsdf_sampling_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/raytrace_lib.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/renderpass_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/renderpass_postprocess_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/ltc_lib.glsl SRC)
data_to_c_simple(engines/eevee/shaders/ssr_lib.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/surface_frag.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/surface_geom.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/surface_lib.glsl SRC)
+data_to_c_simple(engines/eevee/shaders/surface_vert.glsl SRC)
data_to_c_simple(engines/eevee/shaders/update_noise_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/volumetric_accum_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/volumetric_lib.glsl SRC)
@@ -288,6 +293,8 @@ data_to_c_simple(intern/shaders/common_globals_lib.glsl SRC)
data_to_c_simple(intern/shaders/common_pointcloud_lib.glsl SRC)
data_to_c_simple(intern/shaders/common_hair_lib.glsl SRC)
data_to_c_simple(intern/shaders/common_hair_refine_vert.glsl SRC)
+data_to_c_simple(intern/shaders/common_math_lib.glsl SRC)
+data_to_c_simple(intern/shaders/common_math_geom_lib.glsl SRC)
data_to_c_simple(intern/shaders/common_view_lib.glsl SRC)
data_to_c_simple(intern/shaders/common_fxaa_lib.glsl SRC)
data_to_c_simple(intern/shaders/common_smaa_lib.glsl SRC)
@@ -397,6 +404,13 @@ data_to_c_simple(engines/overlay/shaders/xray_fade_frag.glsl SRC)
list(APPEND INC
)
+if(WITH_MOD_FLUID)
+ list(APPEND INC
+ ../../../intern/mantaflow/extern
+ )
+ add_definitions(-DWITH_FLUID)
+endif()
+
if(WITH_FREESTYLE)
add_definitions(-DWITH_FREESTYLE)
endif()
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index bc4efd82a03..6db3bb39643 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __DRW_ENGINE_H__
-#define __DRW_ENGINE_H__
+#pragma once
#include "BLI_sys_types.h" /* for bool */
@@ -174,5 +173,3 @@ void DRW_drawdata_free(struct ID *id);
#ifdef __cplusplus
}
#endif
-
-#endif /* __DRW_ENGINE_H__ */
diff --git a/source/blender/draw/DRW_engine_types.h b/source/blender/draw/DRW_engine_types.h
index d31bab5a1b5..807f654f559 100644
--- a/source/blender/draw/DRW_engine_types.h
+++ b/source/blender/draw/DRW_engine_types.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __DRW_ENGINE_TYPES_H__
-#define __DRW_ENGINE_TYPES_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -50,5 +49,3 @@ typedef struct DefaultTextureList {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DRW_ENGINE_H__ */
diff --git a/source/blender/draw/DRW_select_buffer.h b/source/blender/draw/DRW_select_buffer.h
index 66dee3a9aa9..43d4005c3a9 100644
--- a/source/blender/draw/DRW_select_buffer.h
+++ b/source/blender/draw/DRW_select_buffer.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __DRW_SELECT_BUFFER_H__
-#define __DRW_SELECT_BUFFER_H__
+#pragma once
#include "BLI_sys_types.h" /* for bool and uint */
@@ -126,5 +125,3 @@ uint DRW_select_buffer_find_nearest_to_point(struct Depsgraph *depsgraph,
void DRW_select_buffer_context_create(struct Base **bases,
const uint bases_len,
short select_mode);
-
-#endif /* __DRW_SELECT_BUFFER_H__ */
diff --git a/source/blender/draw/engines/basic/basic_engine.h b/source/blender/draw/engines/basic/basic_engine.h
index d17f1c24c37..8ace6f23cdc 100644
--- a/source/blender/draw/engines/basic/basic_engine.h
+++ b/source/blender/draw/engines/basic/basic_engine.h
@@ -20,9 +20,6 @@
* \ingroup draw_engine
*/
-#ifndef __BASIC_ENGINE_H__
-#define __BASIC_ENGINE_H__
+#pragma once
extern DrawEngineType draw_engine_basic_type;
-
-#endif /* __BASIC_ENGINE_H__ */
diff --git a/source/blender/draw/engines/eevee/eevee_data.c b/source/blender/draw/engines/eevee/eevee_data.c
index 87948f403a0..c475e5287c2 100644
--- a/source/blender/draw/engines/eevee/eevee_data.c
+++ b/source/blender/draw/engines/eevee/eevee_data.c
@@ -28,6 +28,7 @@
#include "BLI_memblock.h"
#include "BKE_duplilist.h"
+#include "BKE_modifier.h"
#include "DEG_depsgraph_query.h"
@@ -147,28 +148,46 @@ EEVEE_ObjectMotionData *EEVEE_motion_blur_object_data_get(EEVEE_MotionBlurData *
return ob_step;
}
-EEVEE_GeometryMotionData *EEVEE_motion_blur_geometry_data_get(EEVEE_MotionBlurData *mb,
- Object *ob,
- bool hair)
+static EEVEE_GeometryMotionData *motion_blur_geometry_data_get(EEVEE_MotionBlurData *mb,
+ void *key,
+ bool hair)
{
if (mb->geom == NULL) {
return NULL;
}
-
- /* Use original data as key to ensure matching accross update. */
- Object *ob_orig = DEG_get_original_object(ob);
-
- void *key = (char *)ob_orig->data + hair;
+ key = (char *)key + (int)hair;
EEVEE_GeometryMotionData *geom_step = BLI_ghash_lookup(mb->geom, key);
if (geom_step == NULL) {
geom_step = MEM_callocN(sizeof(EEVEE_GeometryMotionData), __func__);
- geom_step->type = (hair) ? EEVEE_HAIR_GEOM_MOTION_DATA : EEVEE_MESH_GEOM_MOTION_DATA;
+ geom_step->type = hair ? EEVEE_HAIR_GEOM_MOTION_DATA : EEVEE_MESH_GEOM_MOTION_DATA;
BLI_ghash_insert(mb->geom, key, geom_step);
}
-
return geom_step;
}
+EEVEE_GeometryMotionData *EEVEE_motion_blur_geometry_data_get(EEVEE_MotionBlurData *mb, Object *ob)
+{
+ /* Use original data as key to ensure matching accross update. */
+ return motion_blur_geometry_data_get(mb, DEG_get_original_object(ob)->data, false);
+}
+
+EEVEE_GeometryMotionData *EEVEE_motion_blur_hair_data_get(EEVEE_MotionBlurData *mb,
+ Object *ob,
+ ModifierData *md)
+{
+ void *key;
+ if (md) {
+ /* Particle system. */
+ key = BKE_modifier_get_original(md);
+ }
+ else {
+ /* Hair object. */
+ key = DEG_get_original_object(ob)->data;
+ }
+
+ return motion_blur_geometry_data_get(mb, key, true);
+}
+
/* View Layer data. */
void EEVEE_view_layer_data_free(void *storage)
@@ -218,6 +237,11 @@ EEVEE_ViewLayerData *EEVEE_view_layer_data_get(void)
return (EEVEE_ViewLayerData *)DRW_view_layer_engine_data_get(&draw_engine_eevee_type);
}
+static void eevee_view_layer_init(EEVEE_ViewLayerData *sldata)
+{
+ sldata->common_ubo = DRW_uniformbuffer_create(sizeof(sldata->common_data), NULL);
+}
+
EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure_ex(struct ViewLayer *view_layer)
{
EEVEE_ViewLayerData **sldata = (EEVEE_ViewLayerData **)DRW_view_layer_engine_data_ensure_ex(
@@ -225,6 +249,7 @@ EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure_ex(struct ViewLayer *view_laye
if (*sldata == NULL) {
*sldata = MEM_callocN(sizeof(**sldata), "EEVEE_ViewLayerData");
+ eevee_view_layer_init(*sldata);
}
return *sldata;
@@ -237,6 +262,7 @@ EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure(void)
if (*sldata == NULL) {
*sldata = MEM_callocN(sizeof(**sldata), "EEVEE_ViewLayerData");
+ eevee_view_layer_init(*sldata);
}
return *sldata;
diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
index 4a3cc36ddef..1d8082538a8 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -54,24 +54,30 @@ extern char datatoc_common_view_lib_glsl[];
static void eevee_create_shader_depth_of_field(const bool use_alpha)
{
- char *frag = BLI_string_joinN(datatoc_common_view_lib_glsl, datatoc_effect_dof_frag_glsl);
- e_data.dof_downsample_sh[use_alpha] = DRW_shader_create_fullscreen(
- frag,
+ DRWShaderLibrary *lib = EEVEE_shader_lib_get();
+
+ e_data.dof_downsample_sh[use_alpha] = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_dof_frag_glsl,
+ lib,
use_alpha ? "#define USE_ALPHA_DOF\n"
"#define STEP_DOWNSAMPLE\n" :
"#define STEP_DOWNSAMPLE\n");
- e_data.dof_scatter_sh[use_alpha] = DRW_shader_create(datatoc_effect_dof_vert_glsl,
- NULL,
- frag,
- use_alpha ? "#define USE_ALPHA_DOF\n"
- "#define STEP_SCATTER\n" :
- "#define STEP_SCATTER\n");
- e_data.dof_resolve_sh[use_alpha] = DRW_shader_create_fullscreen(frag,
- use_alpha ?
- "#define USE_ALPHA_DOF\n"
- "#define STEP_RESOLVE\n" :
- "#define STEP_RESOLVE\n");
- MEM_freeN(frag);
+
+ e_data.dof_scatter_sh[use_alpha] = DRW_shader_create_with_shaderlib(
+ datatoc_effect_dof_vert_glsl,
+ NULL,
+ datatoc_effect_dof_frag_glsl,
+ lib,
+ use_alpha ? "#define USE_ALPHA_DOF\n"
+ "#define STEP_SCATTER\n" :
+ "#define STEP_SCATTER\n");
+
+ e_data.dof_resolve_sh[use_alpha] = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_dof_frag_glsl,
+ lib,
+ use_alpha ? "#define USE_ALPHA_DOF\n"
+ "#define STEP_RESOLVE\n" :
+ "#define STEP_RESOLVE\n");
}
int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata),
@@ -255,7 +261,7 @@ void EEVEE_depth_of_field_draw(EEVEE_Data *vedata)
/* Depth Of Field */
if ((effects->enabled_effects & EFFECT_DOF) != 0) {
- float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* Downsample */
GPU_framebuffer_bind(fbl->dof_down_fb);
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c
index f6e74c6822c..4a03ef69d45 100644
--- a/source/blender/draw/engines/eevee/eevee_effects.c
+++ b/source/blender/draw/engines/eevee/eevee_effects.c
@@ -138,7 +138,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata,
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
const float *viewport_size = DRW_viewport_size_get();
- int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]};
+ const int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]};
/* Shaders */
if (!e_data.downsample_sh) {
@@ -147,6 +147,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata,
if (!stl->effects) {
stl->effects = MEM_callocN(sizeof(EEVEE_EffectsInfo), "EEVEE_EffectsInfo");
+ stl->effects->taa_render_sample = 1;
}
effects = stl->effects;
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index f42c60b04bf..72f008ea66a 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -32,6 +32,8 @@
#include "DNA_world_types.h"
+#include "IMB_imbuf.h"
+
#include "eevee_private.h"
#include "eevee_engine.h" /* own include */
@@ -79,11 +81,6 @@ static void eevee_engine_init(void *ved)
GPU_framebuffer_ensure_config(&fbl->main_color_fb,
{GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(txl->color)});
- if (sldata->common_ubo == NULL) {
- sldata->common_ubo = DRW_uniformbuffer_create(sizeof(sldata->common_data),
- &sldata->common_data);
- }
-
/* `EEVEE_renderpasses_init` will set the active render passes used by `EEVEE_effects_init`.
* `EEVEE_effects_init` needs to go second for TAA. */
EEVEE_renderpasses_init(vedata);
@@ -220,10 +217,10 @@ static void eevee_draw_scene(void *vedata)
}
while (loop_len--) {
- float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float clear_depth = 1.0f;
uint clear_stencil = 0x0;
- uint primes[3] = {2, 3, 7};
+ const uint primes[3] = {2, 3, 7};
double offset[3] = {0.0, 0.0, 0.0};
double r[3];
@@ -459,6 +456,9 @@ static void eevee_render_to_image(void *vedata,
}
EEVEE_PrivateData *g_data = ved->stl->g_data;
+ EEVEE_render_modules_init(vedata, engine, depsgraph);
+
+ int initial_frame = CFRA;
int steps = max_ii(1, scene->eevee.motion_blur_steps);
int time_steps_tot = (do_motion_blur) ? steps : 1;
g_data->render_tot_samples = divide_ceil_u(scene->eevee.taa_render_samples, time_steps_tot);
@@ -480,9 +480,10 @@ static void eevee_render_to_image(void *vedata,
}
else {
EEVEE_motion_blur_step_set(ved, MB_PREV);
- RE_engine_frame_set(engine, floorf(time_prev), fractf(time_prev));
+ DRW_render_set_time(engine, depsgraph, floorf(time_prev), fractf(time_prev));
+ EEVEE_render_modules_init(vedata, engine, depsgraph);
+ sldata = EEVEE_view_layer_data_ensure();
- EEVEE_render_view_sync(vedata, engine, depsgraph);
EEVEE_render_cache_init(sldata, vedata);
DRW_render_object_iter(vedata, engine, depsgraph, EEVEE_render_cache);
@@ -496,9 +497,10 @@ static void eevee_render_to_image(void *vedata,
/* Next motion step. */
if (do_motion_blur_fx) {
EEVEE_motion_blur_step_set(ved, MB_NEXT);
- RE_engine_frame_set(engine, floorf(time_next), fractf(time_next));
+ DRW_render_set_time(engine, depsgraph, floorf(time_next), fractf(time_next));
+ EEVEE_render_modules_init(vedata, engine, depsgraph);
+ sldata = EEVEE_view_layer_data_ensure();
- EEVEE_render_view_sync(vedata, engine, depsgraph);
EEVEE_render_cache_init(sldata, vedata);
DRW_render_object_iter(vedata, engine, depsgraph, EEVEE_render_cache);
@@ -512,10 +514,11 @@ static void eevee_render_to_image(void *vedata,
{
if (do_motion_blur) {
EEVEE_motion_blur_step_set(ved, MB_CURR);
- RE_engine_frame_set(engine, floorf(time_curr), fractf(time_curr));
+ DRW_render_set_time(engine, depsgraph, floorf(time_curr), fractf(time_curr));
+ EEVEE_render_modules_init(vedata, engine, depsgraph);
+ sldata = EEVEE_view_layer_data_ensure();
}
- EEVEE_render_view_sync(vedata, engine, depsgraph);
EEVEE_render_cache_init(sldata, vedata);
DRW_render_object_iter(vedata, engine, depsgraph, EEVEE_render_cache);
@@ -558,6 +561,11 @@ static void eevee_render_to_image(void *vedata,
/* Restore original viewport size. */
DRW_render_viewport_size_set((int[2]){g_data->size_orig[0], g_data->size_orig[1]});
+
+ if (CFRA != initial_frame) {
+ /* Restore original frame number. This is because the render pipeline expects it. */
+ RE_engine_frame_set(engine, initial_frame, 0.0f);
+ }
}
static void eevee_engine_free(void)
diff --git a/source/blender/draw/engines/eevee/eevee_engine.h b/source/blender/draw/engines/eevee/eevee_engine.h
index b27d16aa7d8..40784e2980b 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.h
+++ b/source/blender/draw/engines/eevee/eevee_engine.h
@@ -20,9 +20,6 @@
* \ingroup DNA
*/
-#ifndef __EEVEE_ENGINE_H__
-#define __EEVEE_ENGINE_H__
+#pragma once
extern RenderEngineType DRW_engine_viewport_eevee_type;
-
-#endif /* __EEVEE_ENGINE_H__ */
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 78fcd28eb5d..6d2577d5b78 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -203,6 +203,21 @@ static bool eevee_lightcache_version_check(LightCache *lcache)
}
}
+static bool eevee_lightcache_can_be_saved(LightCache *lcache)
+{
+ if (lcache->grid_tx.data) {
+ if (MEM_allocN_len(lcache->grid_tx.data) >= INT_MAX) {
+ return false;
+ }
+ }
+ if (lcache->cube_tx.data) {
+ if (MEM_allocN_len(lcache->cube_tx.data) >= INT_MAX) {
+ return false;
+ }
+ }
+ return true;
+}
+
static int eevee_lightcache_irradiance_sample_count(LightCache *lcache)
{
int total_irr_samples = 0;
@@ -228,7 +243,14 @@ void EEVEE_lightcache_info_update(SceneEEVEE *eevee)
if (lcache->cube_tx.tex_size[2] > GPU_max_texture_layers()) {
BLI_strncpy(eevee->light_cache_info,
- TIP_("Error: Light cache is too big for your GPU to be loaded"),
+ TIP_("Error: Light cache is too big for the GPU to be loaded"),
+ sizeof(eevee->light_cache_info));
+ return;
+ }
+
+ if (lcache->flag & LIGHTCACHE_INVALID) {
+ BLI_strncpy(eevee->light_cache_info,
+ TIP_("Error: Light cache dimensions not supported by the GPU"),
sizeof(eevee->light_cache_info));
return;
}
@@ -239,6 +261,13 @@ void EEVEE_lightcache_info_update(SceneEEVEE *eevee)
return;
}
+ if (!eevee_lightcache_can_be_saved(lcache)) {
+ BLI_strncpy(eevee->light_cache_info,
+ TIP_("Error: LightCache is too large and will not be saved to disk"),
+ sizeof(eevee->light_cache_info));
+ return;
+ }
+
char formatted_mem[15];
BLI_str_format_byte_unit(formatted_mem, eevee_lightcache_memsize_get(lcache), false);
@@ -281,7 +310,7 @@ static bool EEVEE_lightcache_validate(const LightCache *light_cache,
const int grid_len,
const int irr_size[3])
{
- if (light_cache) {
+ if (light_cache && !(light_cache->flag & LIGHTCACHE_INVALID)) {
/* See if we need the same amount of texture space. */
if ((irr_size[0] == light_cache->grid_tx.tex_size[0]) &&
(irr_size[1] == light_cache->grid_tx.tex_size[1]) &&
@@ -343,12 +372,18 @@ LightCache *EEVEE_lightcache_create(const int grid_len,
light_cache->cube_mips = MEM_callocN(sizeof(LightCacheTexture) * light_cache->mips_len,
"LightCacheTexture");
- for (int mip = 0; mip < light_cache->mips_len; mip++) {
- GPU_texture_get_mipmap_size(
- light_cache->cube_tx.tex, mip + 1, light_cache->cube_mips[mip].tex_size);
+ if (light_cache->grid_tx.tex == NULL || light_cache->cube_tx.tex == NULL) {
+ /* We could not create the requested textures size. Stop baking and do not use the cache. */
+ light_cache->flag = LIGHTCACHE_INVALID;
}
+ else {
+ light_cache->flag = LIGHTCACHE_UPDATE_WORLD | LIGHTCACHE_UPDATE_CUBE | LIGHTCACHE_UPDATE_GRID;
- light_cache->flag = LIGHTCACHE_UPDATE_WORLD | LIGHTCACHE_UPDATE_CUBE | LIGHTCACHE_UPDATE_GRID;
+ for (int mip = 0; mip < light_cache->mips_len; mip++) {
+ GPU_texture_get_mipmap_size(
+ light_cache->cube_tx.tex, mip + 1, light_cache->cube_mips[mip].tex_size);
+ }
+ }
return light_cache;
}
@@ -376,6 +411,12 @@ static bool eevee_lightcache_static_load(LightCache *lcache)
0,
false,
NULL);
+
+ if (lcache->grid_tx.tex == NULL) {
+ lcache->flag |= LIGHTCACHE_NOT_USABLE;
+ return false;
+ }
+
GPU_texture_filter_mode(lcache->grid_tx.tex, true);
}
@@ -401,6 +442,11 @@ static bool eevee_lightcache_static_load(LightCache *lcache)
NULL);
}
+ if (lcache->cube_tx.tex == NULL) {
+ lcache->flag |= LIGHTCACHE_NOT_USABLE;
+ return false;
+ }
+
for (int mip = 0; mip < lcache->mips_len; mip++) {
GPU_texture_add_mipmap(
lcache->cube_tx.tex, GPU_DATA_10_11_11_REV, mip + 1, lcache->cube_mips[mip].data);
@@ -420,6 +466,10 @@ bool EEVEE_lightcache_load(LightCache *lcache)
return false;
}
+ if (lcache->flag & (LIGHTCACHE_INVALID | LIGHTCACHE_NOT_USABLE)) {
+ return false;
+ }
+
switch (lcache->type) {
case LIGHTCACHE_TYPE_STATIC:
return eevee_lightcache_static_load(lcache);
@@ -481,6 +531,12 @@ void EEVEE_lightcache_free(LightCache *lcache)
static void eevee_lightbake_context_enable(EEVEE_LightBake *lbake)
{
+ if (GPU_use_main_context_workaround() && !BLI_thread_is_main()) {
+ GPU_context_main_lock();
+ DRW_opengl_context_enable();
+ return;
+ }
+
if (lbake->gl_context) {
DRW_opengl_render_context_enable(lbake->gl_context);
if (lbake->gpu_context == NULL) {
@@ -495,6 +551,12 @@ static void eevee_lightbake_context_enable(EEVEE_LightBake *lbake)
static void eevee_lightbake_context_disable(EEVEE_LightBake *lbake)
{
+ if (GPU_use_main_context_workaround() && !BLI_thread_is_main()) {
+ DRW_opengl_context_disable();
+ GPU_context_main_unlock();
+ return;
+ }
+
if (lbake->gl_context) {
DRW_gpu_render_context_disable(lbake->gpu_context);
DRW_opengl_render_context_disable(lbake->gl_context);
@@ -590,9 +652,7 @@ static void eevee_lightbake_create_resources(EEVEE_LightBake *lbake)
if (lbake->lcache == NULL) {
lbake->lcache = EEVEE_lightcache_create(
lbake->grid_len, lbake->cube_len, lbake->ref_cube_res, lbake->vis_res, lbake->irr_size);
- lbake->lcache->flag = LIGHTCACHE_UPDATE_WORLD | LIGHTCACHE_UPDATE_CUBE |
- LIGHTCACHE_UPDATE_GRID;
- lbake->lcache->vis_res = lbake->vis_res;
+
lbake->own_light_cache = true;
eevee->light_cache_data = lbake->lcache;
@@ -649,7 +709,7 @@ wmJob *EEVEE_lightbake_job_create(struct wmWindowManager *wm,
lbake->delay = delay;
lbake->frame = frame;
- if (lbake->gl_context == NULL) {
+ if (lbake->gl_context == NULL && !GPU_use_main_context_workaround()) {
lbake->gl_context = WM_opengl_context_create();
wm_window_reset_drawable();
}
@@ -694,7 +754,7 @@ void *EEVEE_lightbake_job_data_alloc(struct Main *bmain,
lbake->mutex = BLI_mutex_alloc();
lbake->frame = frame;
- if (run_as_job) {
+ if (run_as_job && !GPU_use_main_context_workaround()) {
lbake->gl_context = WM_opengl_context_create();
wm_window_reset_drawable();
}
@@ -801,14 +861,9 @@ static void eevee_lightbake_cache_create(EEVEE_Data *vedata, EEVEE_LightBake *lb
DRW_view_set_active(view);
}
- if (sldata->common_ubo == NULL) {
- sldata->common_ubo = DRW_uniformbuffer_create(sizeof(sldata->common_data),
- &sldata->common_data);
- }
-
/* HACK: set txl->color but unset it before Draw Manager frees it. */
txl->color = lbake->rt_color;
- int viewport_size[2] = {
+ const int viewport_size[2] = {
GPU_texture_width(txl->color),
GPU_texture_height(txl->color),
};
@@ -966,9 +1021,8 @@ static void compute_cell_id(EEVEE_LightGrid *egrid,
if (visited_cells == cell_idx) {
return;
}
- else {
- visited_cells++;
- }
+
+ visited_cells++;
}
}
}
@@ -977,7 +1031,7 @@ static void compute_cell_id(EEVEE_LightGrid *egrid,
BLI_assert(0);
}
-static void grid_loc_to_world_loc(EEVEE_LightGrid *egrid, int local_cell[3], float r_pos[3])
+static void grid_loc_to_world_loc(EEVEE_LightGrid *egrid, const int local_cell[3], float r_pos[3])
{
copy_v3_v3(r_pos, egrid->corner);
madd_v3_v3fl(r_pos, egrid->increment_x, local_cell[0]);
@@ -1269,6 +1323,17 @@ void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float
* We cannot do it in the main thread. */
eevee_lightbake_context_enable(lbake);
eevee_lightbake_create_resources(lbake);
+
+ /* Resource allocation can fail. Early exit in this case. */
+ if (lbake->lcache->flag & LIGHTCACHE_INVALID) {
+ *lbake->stop = 1;
+ *lbake->do_update = 1;
+ lbake->lcache->flag &= ~LIGHTCACHE_BAKING;
+ eevee_lightbake_context_disable(lbake);
+ eevee_lightbake_delete_resources(lbake);
+ return;
+ }
+
eevee_lightbake_create_render_target(lbake, lbake->rt_res);
eevee_lightbake_context_disable(lbake);
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.h b/source/blender/draw/engines/eevee/eevee_lightcache.h
index 0db36ce0c2e..834f0fc8a45 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.h
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.h
@@ -20,8 +20,7 @@
* \ingroup eevee
*/
-#ifndef __EEVEE_LIGHTCACHE_H__
-#define __EEVEE_LIGHTCACHE_H__
+#pragma once
#include "BLI_sys_types.h" /* for bool */
@@ -62,5 +61,3 @@ struct LightCache *EEVEE_lightcache_create(const int grid_len,
void EEVEE_lightcache_free(struct LightCache *lcache);
bool EEVEE_lightcache_load(struct LightCache *lcache);
void EEVEE_lightcache_info_update(struct SceneEEVEE *eevee);
-
-#endif /* __EEVEE_LIGHTCACHE_H__ */
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 72187dc29eb..0f4a9dc79b6 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -23,6 +23,7 @@
#include "DRW_render.h"
#include "BLI_rand.h"
+#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
#include "DNA_image_types.h"
@@ -161,6 +162,7 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
const DRWContextState *draw_ctx = DRW_context_state_get();
const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
+ vedata->info[0] = '\0';
if (!e_data.hammersley) {
EEVEE_shaders_lightprobe_shaders_init();
@@ -176,6 +178,13 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
stl->g_data->light_cache = scene_eval->eevee.light_cache_data;
}
else {
+ if (scene_eval->eevee.light_cache_data &&
+ (scene_eval->eevee.light_cache_data->flag & LIGHTCACHE_NOT_USABLE)) {
+ /* Error message info. */
+ BLI_snprintf(
+ vedata->info, sizeof(vedata->info), "Error: LightCache cannot be loaded on this GPU");
+ }
+
if (!sldata->fallback_lightcache) {
#if defined(IRRADIANCE_SH_L2)
int grid_res = 4;
@@ -326,38 +335,28 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
{
DRW_PASS_CREATE(psl->probe_background, DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
- struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
DRWShadingGroup *grp = NULL;
+ EEVEE_lookdev_cache_init(vedata, sldata, psl->probe_background, pinfo, &grp);
- Scene *scene = draw_ctx->scene;
- World *wo = scene->world;
-
- /* LookDev */
- EEVEE_lookdev_cache_init(vedata, sldata, &grp, psl->probe_background, wo, pinfo);
+ if (grp == NULL) {
+ Scene *scene = draw_ctx->scene;
+ World *world = (scene->world) ? scene->world : EEVEE_world_default_get();
- if (!grp && wo) {
- struct GPUMaterial *gpumat = EEVEE_material_get(vedata, scene, NULL, wo, VAR_WORLD_PROBE);
+ const int options = VAR_WORLD_BACKGROUND | VAR_WORLD_PROBE;
+ struct GPUMaterial *gpumat = EEVEE_material_get(vedata, scene, NULL, world, options);
grp = DRW_shgroup_material_create(gpumat, psl->probe_background);
DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
- /* TODO (fclem): remove those (need to clean the GLSL files). */
- DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
- DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
- DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
- DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
- DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
- DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
- DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
- DRW_shgroup_call(grp, geom, NULL);
}
- /* Fallback if shader fails or if not using nodetree. */
- if (grp == NULL) {
- grp = DRW_shgroup_create(EEVEE_shaders_probe_default_sh_get(), psl->probe_background);
- DRW_shgroup_uniform_vec3(grp, "color", G_draw.block.colorBackground, 1);
- DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
- DRW_shgroup_call(grp, geom, NULL);
- }
+ DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
+ DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
+ DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
+ DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
+ DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
+ DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
+ DRW_shgroup_uniform_block_ref(grp, "renderpass_block", &stl->g_data->renderpass_ubo);
+ DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL);
}
if (DRW_state_draw_support()) {
@@ -1113,7 +1112,7 @@ void EEVEE_lightbake_filter_diffuse(EEVEE_ViewLayerData *sldata,
#if defined(IRRADIANCE_SH_L2)
int size[2] = {3, 3};
#elif defined(IRRADIANCE_HL2)
- int size[2] = {3, 2};
+ const int size[2] = {3, 2};
pinfo->samples_len = 1024.0f;
#endif
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index b044213e029..f79d90500bd 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -97,10 +97,9 @@ static void eevee_lookdev_hdri_preview_init(EEVEE_Data *vedata, EEVEE_ViewLayerD
void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
EEVEE_ViewLayerData *sldata,
- DRWShadingGroup **r_grp,
DRWPass *pass,
- World *UNUSED(world),
- EEVEE_LightProbesInfo *pinfo)
+ EEVEE_LightProbesInfo *pinfo,
+ DRWShadingGroup **r_shgrp)
{
EEVEE_StorageList *stl = vedata->stl;
EEVEE_TextureList *txl = vedata->txl;
@@ -153,89 +152,88 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
const View3DShading *shading = &v3d->shading;
StudioLight *sl = BKE_studiolight_find(shading->lookdev_light,
STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE);
- if (sl && (sl->flag & STUDIOLIGHT_TYPE_WORLD)) {
- GPUShader *shader = probe_render ? EEVEE_shaders_default_studiolight_sh_get() :
- EEVEE_shaders_background_studiolight_sh_get();
+ if (sl == NULL || (sl->flag & STUDIOLIGHT_TYPE_WORLD) == 0) {
+ return;
+ }
+
+ GPUShader *shader = probe_render ? EEVEE_shaders_studiolight_probe_sh_get() :
+ EEVEE_shaders_studiolight_background_sh_get();
- const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
- int cube_res = scene_eval->eevee.gi_cubemap_resolution;
+ const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
+ int cube_res = scene_eval->eevee.gi_cubemap_resolution;
- /* If one of the component is missing we start from scratch. */
- if ((stl->lookdev_grid_data == NULL) || (stl->lookdev_cube_data == NULL) ||
- (txl->lookdev_grid_tx == NULL) || (txl->lookdev_cube_tx == NULL) ||
- (g_data->light_cache && g_data->light_cache->ref_res != cube_res)) {
- eevee_lookdev_lightcache_delete(vedata);
- }
+ /* If one of the component is missing we start from scratch. */
+ if ((stl->lookdev_grid_data == NULL) || (stl->lookdev_cube_data == NULL) ||
+ (txl->lookdev_grid_tx == NULL) || (txl->lookdev_cube_tx == NULL) ||
+ (g_data->light_cache && g_data->light_cache->ref_res != cube_res)) {
+ eevee_lookdev_lightcache_delete(vedata);
+ }
- if (stl->lookdev_lightcache == NULL) {
+ if (stl->lookdev_lightcache == NULL) {
#if defined(IRRADIANCE_SH_L2)
- int grid_res = 4;
+ int grid_res = 4;
#elif defined(IRRADIANCE_HL2)
- int grid_res = 4;
+ int grid_res = 4;
#endif
- stl->lookdev_lightcache = EEVEE_lightcache_create(
- 1, 1, cube_res, 8, (int[3]){grid_res, grid_res, 1});
-
- /* XXX: Fix memleak. TODO find out why. */
- MEM_SAFE_FREE(stl->lookdev_cube_mips);
-
- /* We do this to use a special light cache for lookdev.
- * This light-cache needs to be per viewport. But we need to
- * have correct freeing when the viewport is closed. So we
- * need to reference all textures to the txl and the memblocks
- * to the stl. */
- stl->lookdev_grid_data = stl->lookdev_lightcache->grid_data;
- stl->lookdev_cube_data = stl->lookdev_lightcache->cube_data;
- stl->lookdev_cube_mips = stl->lookdev_lightcache->cube_mips;
- txl->lookdev_grid_tx = stl->lookdev_lightcache->grid_tx.tex;
- txl->lookdev_cube_tx = stl->lookdev_lightcache->cube_tx.tex;
- }
-
- g_data->light_cache = stl->lookdev_lightcache;
-
- DRWShadingGroup *grp = *r_grp = DRW_shgroup_create(shader, pass);
- axis_angle_to_mat3_single(g_data->studiolight_matrix, 'Z', shading->studiolight_rot_z);
- DRW_shgroup_uniform_mat3(grp, "StudioLightMatrix", g_data->studiolight_matrix);
-
- if (probe_render) {
- DRW_shgroup_uniform_float_copy(
- grp, "studioLightIntensity", shading->studiolight_intensity);
- BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE);
- DRW_shgroup_uniform_texture(grp, "image", sl->equirect_radiance_gputexture);
- /* Do not fadeout when doing probe rendering, only when drawing the background */
- DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
- }
- else {
- float background_alpha = g_data->background_alpha * shading->studiolight_background;
- float studiolight_blur = powf(shading->studiolight_blur, 2.5f);
- DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", background_alpha);
- DRW_shgroup_uniform_float_copy(grp, "studioLightBlur", studiolight_blur);
- DRW_shgroup_uniform_texture(grp, "probeCubes", txl->lookdev_cube_tx);
- DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
- DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
- DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
- DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
- DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
- }
-
- DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL);
-
- /* Do we need to recalc the lightprobes? */
- if (g_data->studiolight_index != sl->index ||
- g_data->studiolight_rot_z != shading->studiolight_rot_z ||
- g_data->studiolight_intensity != shading->studiolight_intensity ||
- g_data->studiolight_cubemap_res != scene->eevee.gi_cubemap_resolution ||
- g_data->studiolight_glossy_clamp != scene->eevee.gi_glossy_clamp ||
- g_data->studiolight_filter_quality != scene->eevee.gi_filter_quality) {
- stl->lookdev_lightcache->flag |= LIGHTCACHE_UPDATE_WORLD;
- g_data->studiolight_index = sl->index;
- g_data->studiolight_rot_z = shading->studiolight_rot_z;
- g_data->studiolight_intensity = shading->studiolight_intensity;
- g_data->studiolight_cubemap_res = scene->eevee.gi_cubemap_resolution;
- g_data->studiolight_glossy_clamp = scene->eevee.gi_glossy_clamp;
- g_data->studiolight_filter_quality = scene->eevee.gi_filter_quality;
- }
+ stl->lookdev_lightcache = EEVEE_lightcache_create(
+ 1, 1, cube_res, 8, (int[3]){grid_res, grid_res, 1});
+
+ /* XXX: Fix memleak. TODO find out why. */
+ MEM_SAFE_FREE(stl->lookdev_cube_mips);
+
+ /* We do this to use a special light cache for lookdev.
+ * This light-cache needs to be per viewport. But we need to
+ * have correct freeing when the viewport is closed. So we
+ * need to reference all textures to the txl and the memblocks
+ * to the stl. */
+ stl->lookdev_grid_data = stl->lookdev_lightcache->grid_data;
+ stl->lookdev_cube_data = stl->lookdev_lightcache->cube_data;
+ stl->lookdev_cube_mips = stl->lookdev_lightcache->cube_mips;
+ txl->lookdev_grid_tx = stl->lookdev_lightcache->grid_tx.tex;
+ txl->lookdev_cube_tx = stl->lookdev_lightcache->cube_tx.tex;
+ }
+
+ g_data->light_cache = stl->lookdev_lightcache;
+
+ DRWShadingGroup *grp = DRW_shgroup_create(shader, pass);
+ axis_angle_to_mat3_single(g_data->studiolight_matrix, 'Z', shading->studiolight_rot_z);
+ DRW_shgroup_uniform_mat3(grp, "StudioLightMatrix", g_data->studiolight_matrix);
+
+ if (probe_render) {
+ /* Avoid artifact with equirectangular mapping. */
+ eGPUSamplerState state = (GPU_SAMPLER_FILTER | GPU_SAMPLER_REPEAT_S);
+ DRW_shgroup_uniform_float_copy(grp, "studioLightIntensity", shading->studiolight_intensity);
+ BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE);
+ DRW_shgroup_uniform_texture_ex(grp, "studioLight", sl->equirect_radiance_gputexture, state);
+ /* Do not fadeout when doing probe rendering, only when drawing the background */
+ DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
+ }
+ else {
+ float background_alpha = g_data->background_alpha * shading->studiolight_background;
+ float studiolight_blur = powf(shading->studiolight_blur, 2.5f);
+ DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", background_alpha);
+ DRW_shgroup_uniform_float_copy(grp, "studioLightBlur", studiolight_blur);
+ DRW_shgroup_uniform_texture(grp, "probeCubes", txl->lookdev_cube_tx);
+ }
+
+ /* Common UBOs are setup latter. */
+ *r_shgrp = grp;
+
+ /* Do we need to recalc the lightprobes? */
+ if (g_data->studiolight_index != sl->index ||
+ g_data->studiolight_rot_z != shading->studiolight_rot_z ||
+ g_data->studiolight_intensity != shading->studiolight_intensity ||
+ g_data->studiolight_cubemap_res != scene->eevee.gi_cubemap_resolution ||
+ g_data->studiolight_glossy_clamp != scene->eevee.gi_glossy_clamp ||
+ g_data->studiolight_filter_quality != scene->eevee.gi_filter_quality) {
+ stl->lookdev_lightcache->flag |= LIGHTCACHE_UPDATE_WORLD;
+ g_data->studiolight_index = sl->index;
+ g_data->studiolight_rot_z = shading->studiolight_rot_z;
+ g_data->studiolight_intensity = shading->studiolight_intensity;
+ g_data->studiolight_cubemap_res = scene->eevee.gi_cubemap_resolution;
+ g_data->studiolight_glossy_clamp = scene->eevee.gi_glossy_clamp;
+ g_data->studiolight_filter_quality = scene->eevee.gi_filter_quality;
}
}
}
@@ -247,7 +245,7 @@ static void eevee_lookdev_apply_taa(const EEVEE_EffectsInfo *effects,
if (DRW_state_is_image_render() || ((effects->enabled_effects & EFFECT_TAA) != 0)) {
double ht_point[2];
double ht_offset[2] = {0.0, 0.0};
- uint ht_primes[2] = {2, 3};
+ const uint ht_primes[2] = {2, 3};
float ofs[2];
BLI_halton_2d(ht_primes, ht_offset, effects->taa_current_sample, ht_point);
diff --git a/source/blender/draw/engines/eevee/eevee_lut.h b/source/blender/draw/engines/eevee/eevee_lut.h
index 04049efd758..d5dbf8ce690 100644
--- a/source/blender/draw/engines/eevee/eevee_lut.h
+++ b/source/blender/draw/engines/eevee/eevee_lut.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __EEVEE_LUT_H__
-#define __EEVEE_LUT_H__
+#pragma once
extern const float ltc_mat_ggx[64 * 64 * 4];
extern const float ltc_mag_ggx[64 * 64 * 2];
@@ -30,5 +29,3 @@ extern const float bsdf_split_sum_ggx[64 * 64 * 2];
extern const float ltc_disk_integral[64 * 64];
extern const float btdf_split_sum_ggx[32][64 * 64];
extern const float blue_noise[64 * 64][4];
-
-#endif /* __EEVEE_LUT_H__ */
diff --git a/source/blender/draw/engines/eevee/eevee_lut_gen.c b/source/blender/draw/engines/eevee/eevee_lut_gen.c
index 6cee05bf015..9b07a6908c3 100644
--- a/source/blender/draw/engines/eevee/eevee_lut_gen.c
+++ b/source/blender/draw/engines/eevee/eevee_lut_gen.c
@@ -31,6 +31,8 @@
#include "BLI_rand.h"
#include "BLI_string_utils.h"
+#include "eevee_private.h"
+
extern char datatoc_bsdf_lut_frag_glsl[];
extern char datatoc_btdf_lut_frag_glsl[];
extern char datatoc_bsdf_common_lib_glsl[];
@@ -45,15 +47,13 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
static float samples_len = 8192.0f;
static float inv_samples_len = 1.0f / 8192.0f;
- char *lib_str = BLI_string_joinN(datatoc_bsdf_common_lib_glsl, datatoc_bsdf_sampling_lib_glsl);
+ DRWShaderLibrary *lib = EEVEE_shader_lib_get();
- struct GPUShader *sh = DRW_shader_create_with_lib(datatoc_lightprobe_vert_glsl,
- datatoc_lightprobe_geom_glsl,
- datatoc_bsdf_lut_frag_glsl,
- lib_str,
- "#define HAMMERSLEY_SIZE 8192\n"
- "#define BRDF_LUT_SIZE 64\n"
- "#define NOISE_SIZE 64\n");
+ struct GPUShader *sh = DRW_shader_create_with_shaderlib(datatoc_lightprobe_vert_glsl,
+ datatoc_lightprobe_geom_glsl,
+ datatoc_bsdf_lut_frag_glsl,
+ lib,
+ "#define HAMMERSLEY_SIZE 8192\n");
DRWPass *pass = DRW_pass_create("LightProbe Filtering", DRW_STATE_WRITE_COLOR);
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
@@ -105,16 +105,10 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h)
static float a2 = 0.0f;
static float inv_samples_len = 1.0f / 8192.0f;
- char *frag_str = BLI_string_joinN(
- datatoc_bsdf_common_lib_glsl, datatoc_bsdf_sampling_lib_glsl, datatoc_btdf_lut_frag_glsl);
-
- struct GPUShader *sh = DRW_shader_create_fullscreen(frag_str,
- "#define HAMMERSLEY_SIZE 8192\n"
- "#define BRDF_LUT_SIZE 64\n"
- "#define NOISE_SIZE 64\n"
- "#define LUT_SIZE 64\n");
+ DRWShaderLibrary *lib = EEVEE_shader_lib_get();
- MEM_freeN(frag_str);
+ struct GPUShader *sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_btdf_lut_frag_glsl, lib, "#define HAMMERSLEY_SIZE 8192\n");
DRWPass *pass = DRW_pass_create("LightProbe Filtering", DRW_STATE_WRITE_COLOR);
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
@@ -194,4 +188,4 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h)
MEM_freeN(data);
return tex;
-} \ No newline at end of file
+}
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 143945b637a..fb07208be47 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -56,37 +56,6 @@ static struct {
float noise_offsets[3];
} e_data = {NULL}; /* Engine data */
-extern char datatoc_lights_lib_glsl[];
-extern char datatoc_lightprobe_lib_glsl[];
-extern char datatoc_ambient_occlusion_lib_glsl[];
-extern char datatoc_prepass_frag_glsl[];
-extern char datatoc_prepass_vert_glsl[];
-extern char datatoc_default_frag_glsl[];
-extern char datatoc_default_world_frag_glsl[];
-extern char datatoc_ltc_lib_glsl[];
-extern char datatoc_bsdf_common_lib_glsl[];
-extern char datatoc_bsdf_sampling_lib_glsl[];
-extern char datatoc_common_uniforms_lib_glsl[];
-extern char datatoc_common_hair_lib_glsl[];
-extern char datatoc_common_view_lib_glsl[];
-extern char datatoc_irradiance_lib_glsl[];
-extern char datatoc_octahedron_lib_glsl[];
-extern char datatoc_cubemap_lib_glsl[];
-extern char datatoc_lit_surface_frag_glsl[];
-extern char datatoc_lit_surface_vert_glsl[];
-extern char datatoc_raytrace_lib_glsl[];
-extern char datatoc_ssr_lib_glsl[];
-extern char datatoc_shadow_vert_glsl[];
-extern char datatoc_lightprobe_geom_glsl[];
-extern char datatoc_lightprobe_vert_glsl[];
-extern char datatoc_background_vert_glsl[];
-extern char datatoc_update_noise_frag_glsl[];
-extern char datatoc_volumetric_vert_glsl[];
-extern char datatoc_volumetric_geom_glsl[];
-extern char datatoc_volumetric_frag_glsl[];
-extern char datatoc_volumetric_lib_glsl[];
-extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
-
typedef struct EeveeMaterialCache {
struct DRWShadingGroup *depth_grp;
struct DRWShadingGroup *shading_grp;
@@ -238,46 +207,6 @@ void EEVEE_update_noise(EEVEE_PassList *psl, EEVEE_FramebufferList *fbl, const d
DRW_draw_pass(psl->update_noise_pass);
}
-void EEVEE_update_viewvecs(float invproj[4][4], float winmat[4][4], float (*r_viewvecs)[4])
-{
- /* view vectors for the corners of the view frustum.
- * Can be used to recreate the world space position easily */
- float view_vecs[4][4] = {
- {-1.0f, -1.0f, -1.0f, 1.0f},
- {1.0f, -1.0f, -1.0f, 1.0f},
- {-1.0f, 1.0f, -1.0f, 1.0f},
- {-1.0f, -1.0f, 1.0f, 1.0f},
- };
-
- /* convert the view vectors to view space */
- const bool is_persp = (winmat[3][3] == 0.0f);
- for (int i = 0; i < 4; i++) {
- mul_project_m4_v3(invproj, view_vecs[i]);
- /* normalized trick see:
- * http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer */
- if (is_persp) {
- /* Divide XY by Z. */
- mul_v2_fl(view_vecs[i], 1.0f / view_vecs[i][2]);
- }
- }
-
- /**
- * If ortho : view_vecs[0] is the near-bottom-left corner of the frustum and
- * view_vecs[1] is the vector going from the near-bottom-left corner to
- * the far-top-right corner.
- * If Persp : view_vecs[0].xy and view_vecs[1].xy are respectively the bottom-left corner
- * when Z = 1, and top-left corner if Z = 1.
- * view_vecs[0].z the near clip distance and view_vecs[1].z is the (signed)
- * distance from the near plane to the far clip plane.
- */
- copy_v4_v4(r_viewvecs[0], view_vecs[0]);
-
- /* we need to store the differences */
- r_viewvecs[1][0] = view_vecs[1][0] - view_vecs[0][0];
- r_viewvecs[1][1] = view_vecs[2][1] - view_vecs[0][1];
- r_viewvecs[1][2] = view_vecs[3][2] - view_vecs[0][2];
-}
-
void EEVEE_materials_init(EEVEE_ViewLayerData *sldata,
EEVEE_Data *vedata,
EEVEE_StorageList *stl,
@@ -305,15 +234,6 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata,
}
{
- /* Update view_vecs */
- float invproj[4][4], winmat[4][4];
- DRW_view_winmat_get(NULL, winmat, false);
- DRW_view_winmat_get(NULL, invproj, true);
-
- EEVEE_update_viewvecs(invproj, winmat, sldata->common_data.view_vecs);
- }
-
- {
/* Update noise Framebuffer. */
GPU_framebuffer_ensure_config(
&fbl->update_noise_fb,
@@ -391,39 +311,28 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
DRW_PASS_CREATE(psl->background_ps, DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
- struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
DRWShadingGroup *grp = NULL;
+ EEVEE_lookdev_cache_init(vedata, sldata, psl->background_ps, NULL, &grp);
- Scene *scene = draw_ctx->scene;
- World *wo = scene->world;
-
- EEVEE_lookdev_cache_init(vedata, sldata, &grp, psl->background_ps, wo, NULL);
+ if (grp == NULL) {
+ Scene *scene = draw_ctx->scene;
+ World *world = (scene->world) ? scene->world : EEVEE_world_default_get();
- if (!grp && wo) {
- struct GPUMaterial *gpumat = EEVEE_material_get(
- vedata, scene, NULL, wo, VAR_WORLD_BACKGROUND);
+ const int options = VAR_WORLD_BACKGROUND;
+ struct GPUMaterial *gpumat = EEVEE_material_get(vedata, scene, NULL, world, options);
grp = DRW_shgroup_material_create(gpumat, psl->background_ps);
DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1);
- /* TODO (fclem): remove those (need to clean the GLSL files). */
- DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
- DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
- DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
- DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
- DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
- DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
- DRW_shgroup_uniform_block_ref(grp, "renderpass_block", &stl->g_data->renderpass_ubo);
- DRW_shgroup_call(grp, geom, NULL);
}
- /* Fallback if shader fails or if not using nodetree. */
- if (grp == NULL) {
- GPUShader *sh = EEVEE_shaders_default_background_sh_get();
- grp = DRW_shgroup_create(sh, psl->background_ps);
- DRW_shgroup_uniform_vec3(grp, "color", G_draw.block.colorBackground, 1);
- DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1);
- DRW_shgroup_call(grp, geom, NULL);
- }
+ DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
+ DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
+ DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
+ DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
+ DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
+ DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
+ DRW_shgroup_uniform_block_ref(grp, "renderpass_block", &stl->g_data->renderpass_ubo);
+ DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL);
}
#define EEVEE_PASS_CREATE(pass, state) \
@@ -574,9 +483,8 @@ static EeveeMaterialCache material_opaque(EEVEE_Data *vedata,
if (BLI_ghash_ensure_p(pd->material_hash, key, (void ***)&emc_p)) {
return **emc_p;
}
- else {
- *emc_p = emc = BLI_memblock_alloc(sldata->material_cache);
- }
+
+ *emc_p = emc = BLI_memblock_alloc(sldata->material_cache);
material_shadow(vedata, sldata, ma, is_hair, emc);
@@ -999,7 +907,7 @@ static void material_renderpass_init(EEVEE_FramebufferList *fbl,
DRW_texture_ensure_fullscreen_2d(output_tx, format, 0);
/* Clear texture. */
if (do_clear) {
- float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* TODO(fclem) replace by GPU_texture_clear once it is fast. */
GPU_framebuffer_texture_attach(fbl->material_accum_fb, *output_tx, 0, 0);
GPU_framebuffer_bind(fbl->material_accum_fb);
diff --git a/source/blender/draw/engines/eevee/eevee_mist.c b/source/blender/draw/engines/eevee/eevee_mist.c
index 1cedd334d67..cfac6cc4d62 100644
--- a/source/blender/draw/engines/eevee/eevee_mist.c
+++ b/source/blender/draw/engines/eevee/eevee_mist.c
@@ -53,17 +53,13 @@ void EEVEE_mist_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
EEVEE_PrivateData *g_data = stl->g_data;
Scene *scene = draw_ctx->scene;
- float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
if (e_data.mist_sh == NULL) {
- char *frag_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_effect_mist_frag_glsl);
+ DRWShaderLibrary *lib = EEVEE_shader_lib_get();
- e_data.mist_sh = DRW_shader_create_fullscreen(frag_str, "#define FIRST_PASS\n");
-
- MEM_freeN(frag_str);
+ e_data.mist_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_mist_frag_glsl, lib, "#define FIRST_PASS\n");
}
/* Create FrameBuffer. */
@@ -98,11 +94,11 @@ void EEVEE_mist_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
}
}
else {
- float near = -sldata->common_data.view_vecs[0][2];
- float range = sldata->common_data.view_vecs[1][2];
+ float near = DRW_view_near_distance_get(NULL);
+ float far = DRW_view_far_distance_get(NULL);
/* Fallback */
g_data->mist_start = near;
- g_data->mist_inv_dist = 1.0f / fabsf(range);
+ g_data->mist_inv_dist = 1.0f / fabsf(far - near);
g_data->mist_falloff = 1.0f;
}
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index 586ee780f1d..2a315927015 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -37,6 +37,7 @@
#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_particle_types.h"
+#include "DNA_rigidbody_types.h"
#include "DNA_screen_types.h"
#include "ED_screen.h"
@@ -68,27 +69,23 @@ extern char datatoc_common_view_lib_glsl[];
static void eevee_create_shader_motion_blur(void)
{
- e_data.motion_blur_sh = DRW_shader_create_fullscreen(
- datatoc_effect_motion_blur_frag_glsl,
- "#define EEVEE_VELOCITY_TILE_SIZE " STRINGIFY(EEVEE_VELOCITY_TILE_SIZE) "\n");
- e_data.motion_blur_object_sh = DRW_shader_create_with_lib(datatoc_object_motion_vert_glsl,
- NULL,
- datatoc_object_motion_frag_glsl,
- datatoc_common_view_lib_glsl,
- NULL);
- e_data.velocity_tiles_sh = DRW_shader_create_fullscreen(
- datatoc_effect_velocity_tile_frag_glsl,
- "#define TILE_GATHER\n"
- "#define EEVEE_VELOCITY_TILE_SIZE " STRINGIFY(EEVEE_VELOCITY_TILE_SIZE) "\n");
+#define TILE_SIZE_STR "#define EEVEE_VELOCITY_TILE_SIZE " STRINGIFY(EEVEE_VELOCITY_TILE_SIZE) "\n"
+ DRWShaderLibrary *lib = EEVEE_shader_lib_get();
+ e_data.motion_blur_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_motion_blur_frag_glsl, lib, TILE_SIZE_STR);
+ e_data.motion_blur_object_sh = DRW_shader_create_with_shaderlib(
+ datatoc_object_motion_vert_glsl, NULL, datatoc_object_motion_frag_glsl, lib, NULL);
+
+ e_data.motion_blur_hair_sh = DRW_shader_create_with_shaderlib(datatoc_object_motion_vert_glsl,
+ NULL,
+ datatoc_object_motion_frag_glsl,
+ lib,
+ "#define HAIR\n");
+
+ e_data.velocity_tiles_sh = DRW_shader_create_fullscreen(datatoc_effect_velocity_tile_frag_glsl,
+ "#define TILE_GATHER\n" TILE_SIZE_STR);
e_data.velocity_tiles_expand_sh = DRW_shader_create_fullscreen(
- datatoc_effect_velocity_tile_frag_glsl,
- "#define TILE_EXPANSION\n"
- "#define EEVEE_VELOCITY_TILE_SIZE " STRINGIFY(EEVEE_VELOCITY_TILE_SIZE) "\n");
-
- char *vert = BLI_string_joinN(datatoc_common_hair_lib_glsl, datatoc_object_motion_vert_glsl);
- e_data.motion_blur_hair_sh = DRW_shader_create_with_lib(
- vert, NULL, datatoc_object_motion_frag_glsl, datatoc_common_view_lib_glsl, "#define HAIR\n");
- MEM_freeN(vert);
+ datatoc_effect_velocity_tile_frag_glsl, "#define TILE_EXPANSION\n" TILE_SIZE_STR);
}
int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
@@ -120,8 +117,10 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
}
const float *fs_size = DRW_viewport_size_get();
- int tx_size[2] = {1 + ((int)fs_size[0] / EEVEE_VELOCITY_TILE_SIZE),
- 1 + ((int)fs_size[1] / EEVEE_VELOCITY_TILE_SIZE)};
+ const int tx_size[2] = {
+ 1 + ((int)fs_size[0] / EEVEE_VELOCITY_TILE_SIZE),
+ 1 + ((int)fs_size[1] / EEVEE_VELOCITY_TILE_SIZE),
+ };
effects->velocity_tiles_x_tx = DRW_texture_pool_query_2d(
tx_size[0], fs_size[1], GPU_RGBA16, &draw_engine_eevee_type);
@@ -176,8 +175,10 @@ void EEVEE_motion_blur_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat
if ((effects->enabled_effects & EFFECT_MOTION_BLUR) != 0) {
const float *fs_size = DRW_viewport_size_get();
- int tx_size[2] = {GPU_texture_width(effects->velocity_tiles_tx),
- GPU_texture_height(effects->velocity_tiles_tx)};
+ const int tx_size[2] = {
+ GPU_texture_width(effects->velocity_tiles_tx),
+ GPU_texture_height(effects->velocity_tiles_tx),
+ };
eevee_motion_blur_sync_camera(vedata);
@@ -288,8 +289,8 @@ void EEVEE_motion_blur_hair_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata),
/* Store transform */
DRW_hair_duplimat_get(ob, psys, md, mb_data->obmat[mb_step]);
- EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_geometry_data_get(
- &effects->motion_blur, ob, true);
+ EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_hair_data_get(
+ &effects->motion_blur, ob, md);
if (mb_step == MB_CURR) {
/* Fill missing matrices if the object was hidden in previous or next frame. */
@@ -329,10 +330,20 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata),
return;
}
- const bool is_dupli = (ob->base_flag & BASE_FROM_DUPLI) != 0;
+ RigidBodyOb *rbo = ob->rigidbody_object;
+
+ /* active rigidbody objects only, as only those are affected by sim. */
+ const bool has_rigidbody = (rbo && (rbo->type == RBO_TYPE_ACTIVE));
+#if 0
/* For now we assume dupli objects are moving. */
- const bool object_moves = is_dupli || BKE_object_moves_in_time(ob, true);
- const bool is_deform = BKE_object_is_deform_modified(DRW_context_state_get()->scene, ob);
+ const bool is_dupli = (ob->base_flag & BASE_FROM_DUPLI) != 0;
+ const bool object_moves = is_dupli || has_rigidbody || BKE_object_moves_in_time(ob, true);
+#else
+ /* BKE_object_moves_in_time does not work in some cases. Better */
+ const bool object_moves = true;
+#endif
+ const bool is_deform = BKE_object_is_deform_modified(DRW_context_state_get()->scene, ob) ||
+ (has_rigidbody && (rbo->flag & RBO_FLAG_USE_DEFORM) != 0);
if (!(object_moves || is_deform)) {
return;
@@ -346,8 +357,8 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata),
/* Store transform */
copy_m4_m4(mb_data->obmat[mb_step], ob->obmat);
- EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_geometry_data_get(
- &effects->motion_blur, ob, false);
+ EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_geometry_data_get(&effects->motion_blur,
+ ob);
if (mb_step == MB_CURR) {
GPUBatch *batch = DRW_cache_object_surface_get(ob);
@@ -363,14 +374,6 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata),
copy_m4_m4(mb_data->obmat[MB_NEXT], mb_data->obmat[MB_CURR]);
}
- grp = DRW_shgroup_create(e_data.motion_blur_object_sh, psl->velocity_object);
- DRW_shgroup_uniform_mat4(grp, "prevModelMatrix", mb_data->obmat[MB_PREV]);
- DRW_shgroup_uniform_mat4(grp, "currModelMatrix", mb_data->obmat[MB_CURR]);
- DRW_shgroup_uniform_mat4(grp, "nextModelMatrix", mb_data->obmat[MB_NEXT]);
- DRW_shgroup_uniform_bool(grp, "useDeform", &mb_geom->use_deform, 1);
-
- DRW_shgroup_call(grp, batch, ob);
-
if (mb_geom->use_deform) {
EEVEE_ObjectEngineData *oedata = EEVEE_object_data_ensure(ob);
if (!oedata->geom_update) {
@@ -386,6 +389,21 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata),
/* Keep to modify later (after init). */
mb_geom->batch = batch;
}
+
+ /* Avoid drawing object that has no motions since object_moves is always true. */
+ if (!mb_geom->use_deform && /* Object deformation can happen without transform. */
+ equals_m4m4(mb_data->obmat[MB_PREV], mb_data->obmat[MB_CURR]) &&
+ equals_m4m4(mb_data->obmat[MB_NEXT], mb_data->obmat[MB_CURR])) {
+ return;
+ }
+
+ grp = DRW_shgroup_create(e_data.motion_blur_object_sh, psl->velocity_object);
+ DRW_shgroup_uniform_mat4(grp, "prevModelMatrix", mb_data->obmat[MB_PREV]);
+ DRW_shgroup_uniform_mat4(grp, "currModelMatrix", mb_data->obmat[MB_CURR]);
+ DRW_shgroup_uniform_mat4(grp, "nextModelMatrix", mb_data->obmat[MB_NEXT]);
+ DRW_shgroup_uniform_bool(grp, "useDeform", &mb_geom->use_deform, 1);
+
+ DRW_shgroup_call(grp, batch, ob);
}
else if (is_deform) {
/* Store vertex position buffer. */
@@ -466,16 +484,15 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata)
GPU_VERTBUF_DISCARD_SAFE(mb_geom->vbo[MB_NEXT]);
break;
}
+
+ /* Modify the batch to include the previous & next position. */
+ if (i == MB_PREV) {
+ GPU_batch_vertbuf_add_ex(batch, vbo, true);
+ mb_geom->vbo[i] = NULL;
+ }
else {
- /* Modify the batch to include the previous & next position. */
- if (i == MB_PREV) {
- GPU_batch_vertbuf_add_ex(batch, vbo, true);
- mb_geom->vbo[i] = NULL;
- }
- else {
- /* This VBO can be reuse by next time step. Don't pass ownership. */
- GPU_batch_vertbuf_add_ex(batch, vbo, false);
- }
+ /* This VBO can be reuse by next time step. Don't pass ownership. */
+ GPU_batch_vertbuf_add_ex(batch, vbo, false);
}
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_occlusion.c b/source/blender/draw/engines/eevee/eevee_occlusion.c
index a075210967c..9aae801197f 100644
--- a/source/blender/draw/engines/eevee/eevee_occlusion.c
+++ b/source/blender/draw/engines/eevee/eevee_occlusion.c
@@ -53,17 +53,14 @@ extern char datatoc_effect_gtao_frag_glsl[];
static void eevee_create_shader_occlusion(void)
{
- char *frag_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_ambient_occlusion_lib_glsl,
- datatoc_effect_gtao_frag_glsl);
-
- e_data.gtao_sh = DRW_shader_create_fullscreen(frag_str, NULL);
- e_data.gtao_layer_sh = DRW_shader_create_fullscreen(frag_str, "#define LAYERED_DEPTH\n");
- e_data.gtao_debug_sh = DRW_shader_create_fullscreen(frag_str, "#define DEBUG_AO\n");
-
- MEM_freeN(frag_str);
+ DRWShaderLibrary *lib = EEVEE_shader_lib_get();
+
+ e_data.gtao_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_gtao_frag_glsl, lib, NULL);
+ e_data.gtao_layer_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_gtao_frag_glsl, lib, "#define LAYERED_DEPTH\n");
+ e_data.gtao_debug_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_gtao_frag_glsl, lib, "#define DEBUG_AO\n");
}
int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
@@ -77,7 +74,7 @@ int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
if (!e_data.dummy_horizon_tx) {
- float pixel[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float pixel[4] = {0.0f, 0.0f, 0.0f, 0.0f};
e_data.dummy_horizon_tx = DRW_texture_create_2d(1, 1, GPU_RGBA8, DRW_TEX_WRAP, pixel);
}
@@ -146,7 +143,7 @@ void EEVEE_occlusion_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata
const eGPUTextureFormat texture_format = (tot_samples > 128) ? GPU_R32F : GPU_R16F;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
- float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* Should be enough precision for many samples. */
DRW_texture_ensure_fullscreen_2d(&txl->ao_accum, texture_format, 0);
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 81a50d36e17..34cd22ad13c 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -20,8 +20,7 @@
* \ingroup DNA
*/
-#ifndef __EEVEE_PRIVATE_H__
-#define __EEVEE_PRIVATE_H__
+#pragma once
#include "DRW_render.h"
@@ -29,6 +28,8 @@
#include "DNA_lightprobe_types.h"
+#include "GPU_viewport.h"
+
#include "BKE_camera.h"
struct EEVEE_ShadowCasterBuffer;
@@ -163,7 +164,7 @@ enum {
VAR_MAT_MESH = (1 << 0),
VAR_MAT_VOLUME = (1 << 1),
VAR_MAT_HAIR = (1 << 2),
- VAR_MAT_PROBE = (1 << 3),
+ /* VAR_MAT_PROBE = (1 << 3), UNUSED */
VAR_MAT_BLEND = (1 << 4),
VAR_MAT_LOOKDEV = (1 << 5),
VAR_MAT_HOLDOUT = (1 << 6),
@@ -747,7 +748,6 @@ typedef struct EEVEE_EffectsInfo {
* - sizeof(bool) == sizeof(int) in GLSL so use int in C */
typedef struct EEVEE_CommonUniformBuffer {
float prev_persmat[4][4]; /* mat4 */
- float view_vecs[2][4]; /* vec4[2] */
float mip_ratio[10][4]; /* vec2[10] */
/* Ambient Occlusion */
/* -- 16 byte aligned -- */
@@ -891,6 +891,7 @@ typedef struct EEVEE_Data {
EEVEE_TextureList *txl;
EEVEE_PassList *psl;
EEVEE_StorageList *stl;
+ char info[GPU_INFO_SIZE];
} EEVEE_Data;
typedef struct EEVEE_PrivateData {
@@ -910,6 +911,7 @@ typedef struct EEVEE_PrivateData {
/* Render Matrices */
float studiolight_matrix[3][3];
float overscan, overscan_pixels;
+ float camtexcofac[4];
float size_orig[2];
/* Mist Settings */
@@ -968,8 +970,10 @@ EEVEE_ObjectMotionData *EEVEE_motion_blur_object_data_get(EEVEE_MotionBlurData *
Object *ob,
bool hair);
EEVEE_GeometryMotionData *EEVEE_motion_blur_geometry_data_get(EEVEE_MotionBlurData *mb,
- Object *ob,
- bool hair);
+ Object *ob);
+EEVEE_GeometryMotionData *EEVEE_motion_blur_hair_data_get(EEVEE_MotionBlurData *mb,
+ Object *ob,
+ struct ModifierData *md);
EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_get(Object *ob);
EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_ensure(Object *ob);
EEVEE_LightEngineData *EEVEE_light_data_get(Object *ob);
@@ -1001,7 +1005,6 @@ void EEVEE_object_hair_cache_populate(EEVEE_Data *vedata,
void EEVEE_materials_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_materials_free(void);
void EEVEE_update_noise(EEVEE_PassList *psl, EEVEE_FramebufferList *fbl, const double offsets[3]);
-void EEVEE_update_viewvecs(float invproj[4][4], float winmat[4][4], float (*r_viewvecs)[4]);
void EEVEE_material_renderpasses_init(EEVEE_Data *vedata);
void EEVEE_material_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, uint tot_samples);
void EEVEE_material_output_accumulate(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
@@ -1057,15 +1060,14 @@ void EEVEE_random_rotation_m4(int sample_ofs, float scale, float r_mat[4][4]);
/* eevee_shaders.c */
void EEVEE_shaders_lightprobe_shaders_init(void);
void EEVEE_shaders_material_shaders_init(void);
+struct DRWShaderLibrary *EEVEE_shader_lib_get(void);
struct GPUShader *EEVEE_shaders_probe_filter_glossy_sh_get(void);
-struct GPUShader *EEVEE_shaders_probe_default_sh_get(void);
struct GPUShader *EEVEE_shaders_probe_filter_diffuse_sh_get(void);
struct GPUShader *EEVEE_shaders_probe_filter_visibility_sh_get(void);
struct GPUShader *EEVEE_shaders_probe_grid_fill_sh_get(void);
struct GPUShader *EEVEE_shaders_probe_planar_downsample_sh_get(void);
-struct GPUShader *EEVEE_shaders_default_studiolight_sh_get(void);
-struct GPUShader *EEVEE_shaders_default_background_sh_get(void);
-struct GPUShader *EEVEE_shaders_background_studiolight_sh_get(void);
+struct GPUShader *EEVEE_shaders_studiolight_probe_sh_get(void);
+struct GPUShader *EEVEE_shaders_studiolight_background_sh_get(void);
struct GPUShader *EEVEE_shaders_probe_cube_display_sh_get(void);
struct GPUShader *EEVEE_shaders_probe_grid_display_sh_get(void);
struct GPUShader *EEVEE_shaders_probe_planar_display_sh_get(void);
@@ -1077,6 +1079,7 @@ struct bNodeTree *EEVEE_shader_default_world_nodetree(World *wo);
Material *EEVEE_material_default_diffuse_get(void);
Material *EEVEE_material_default_glossy_get(void);
Material *EEVEE_material_default_error_get(void);
+World *EEVEE_world_default_get(void);
struct GPUMaterial *EEVEE_material_default_get(struct Scene *scene, Material *ma, int options);
struct GPUMaterial *EEVEE_material_get(
EEVEE_Data *vedata, struct Scene *scene, Material *ma, World *wo, int options);
@@ -1280,6 +1283,9 @@ bool EEVEE_render_init(EEVEE_Data *vedata,
void EEVEE_render_view_sync(EEVEE_Data *vedata,
struct RenderEngine *engine,
struct Depsgraph *depsgraph);
+void EEVEE_render_modules_init(EEVEE_Data *vedata,
+ struct RenderEngine *engine,
+ struct Depsgraph *depsgraph);
void EEVEE_render_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_render_cache(void *vedata,
struct Object *ob,
@@ -1300,10 +1306,9 @@ void EEVEE_render_update_passes(struct RenderEngine *engine,
/** eevee_lookdev.c */
void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
EEVEE_ViewLayerData *sldata,
- DRWShadingGroup **grp,
DRWPass *pass,
- struct World *world,
- EEVEE_LightProbesInfo *pinfo);
+ EEVEE_LightProbesInfo *pinfo,
+ DRWShadingGroup **r_shgrp);
void EEVEE_lookdev_draw(EEVEE_Data *vedata);
/** eevee_engine.c */
@@ -1351,5 +1356,3 @@ static const float cubefacemat[6][4][4] = {
{0.0f, 0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f}},
};
-
-#endif /* __EEVEE_PRIVATE_H__ */
diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c
index 787fc16a7da..62698bc5da3 100644
--- a/source/blender/draw/engines/eevee/eevee_render.c
+++ b/source/blender/draw/engines/eevee/eevee_render.c
@@ -53,11 +53,9 @@ bool EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph *
EEVEE_StorageList *stl = vedata->stl;
EEVEE_TextureList *txl = vedata->txl;
EEVEE_FramebufferList *fbl = vedata->fbl;
- EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
Scene *scene = DEG_get_evaluated_scene(depsgraph);
const float *size_orig = DRW_viewport_size_get();
float size_final[2];
- float camtexcofac[4];
/* Init default FB and render targets:
* In render mode the default framebuffer is not generated
@@ -75,6 +73,7 @@ bool EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph *
g_data->valid_double_buffer = 0;
copy_v2_v2(g_data->size_orig, size_orig);
+ float *camtexcofac = g_data->camtexcofac;
if (scene->eevee.flag & SCE_EEVEE_OVERSCAN) {
g_data->overscan = scene->eevee.overscan / 100.0f;
g_data->overscan_pixels = roundf(max_ff(size_orig[0], size_orig[1]) * g_data->overscan);
@@ -94,8 +93,10 @@ bool EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph *
copy_v4_fl4(camtexcofac, 1.0f, 1.0f, 0.0f, 0.0f);
}
- int final_res[2] = {size_orig[0] + g_data->overscan_pixels * 2.0f,
- size_orig[1] + g_data->overscan_pixels * 2.0f};
+ const int final_res[2] = {
+ size_orig[0] + g_data->overscan_pixels * 2.0f,
+ size_orig[1] + g_data->overscan_pixels * 2.0f,
+ };
int max_dim = max_ii(final_res[0], final_res[1]);
if (max_dim > GPU_max_texture_size()) {
@@ -125,19 +126,19 @@ bool EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph *
GPU_framebuffer_ensure_config(&fbl->main_color_fb,
{GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(txl->color)});
- /* Alloc common ubo data. */
- if (sldata->common_ubo == NULL) {
- sldata->common_ubo = DRW_uniformbuffer_create(sizeof(sldata->common_data),
- &sldata->common_data);
- }
-
- EEVEE_render_view_sync(vedata, engine, depsgraph);
+ return true;
+}
+void EEVEE_render_modules_init(EEVEE_Data *vedata,
+ RenderEngine *engine,
+ struct Depsgraph *depsgraph)
+{
+ EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_FramebufferList *fbl = vedata->fbl;
/* TODO(sergey): Shall render hold pointer to an evaluated camera instead? */
struct Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, RE_GetCamera(engine->re));
-
- DRWView *view = (DRWView *)DRW_view_default_get();
- DRW_view_camtexco_set(view, camtexcofac);
+ EEVEE_render_view_sync(vedata, engine, depsgraph);
/* `EEVEE_renderpasses_init` will set the active render passes used by `EEVEE_effects_init`.
* `EEVEE_effects_init` needs to go second for TAA. */
@@ -146,8 +147,6 @@ bool EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph *
EEVEE_materials_init(sldata, vedata, stl, fbl);
EEVEE_shadows_init(sldata);
EEVEE_lightprobes_init(sldata, vedata);
-
- return true;
}
void EEVEE_render_view_sync(EEVEE_Data *vedata, RenderEngine *engine, struct Depsgraph *depsgraph)
@@ -160,7 +159,7 @@ void EEVEE_render_view_sync(EEVEE_Data *vedata, RenderEngine *engine, struct Dep
struct Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, RE_GetCamera(engine->re));
RE_GetCameraWindow(engine->re, ob_camera_eval, winmat);
- RE_GetCameraWindowWithOverscan(engine->re, winmat, g_data->overscan);
+ RE_GetCameraWindowWithOverscan(engine->re, g_data->overscan, winmat);
RE_GetCameraModelMatrix(engine->re, ob_camera_eval, viewinv);
invert_m4_m4(viewmat, viewinv);
@@ -169,10 +168,13 @@ void EEVEE_render_view_sync(EEVEE_Data *vedata, RenderEngine *engine, struct Dep
DRW_view_reset();
DRW_view_default_set(view);
DRW_view_set_active(view);
+
+ DRW_view_camtexco_set(view, g_data->camtexcofac);
}
void EEVEE_render_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
+ EEVEE_view_layer_data_ensure();
EEVEE_bloom_cache_init(sldata, vedata);
EEVEE_depth_of_field_cache_init(sldata, vedata);
EEVEE_effects_cache_init(sldata, vedata);
@@ -523,10 +525,10 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
}
while (render_samples < tot_sample && !RE_engine_test_break(engine)) {
- float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float clear_depth = 1.0f;
uint clear_stencil = 0x00;
- uint primes[3] = {2, 3, 7};
+ const uint primes[3] = {2, 3, 7};
double offset[3] = {0.0, 0.0, 0.0};
double r[3];
diff --git a/source/blender/draw/engines/eevee/eevee_renderpasses.c b/source/blender/draw/engines/eevee/eevee_renderpasses.c
index be771d7cf42..089d8b7a287 100644
--- a/source/blender/draw/engines/eevee/eevee_renderpasses.c
+++ b/source/blender/draw/engines/eevee/eevee_renderpasses.c
@@ -199,12 +199,10 @@ void EEVEE_renderpasses_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ve
EEVEE_RENDERPASSES_WITH_POST_PROCESSING) > 0;
if (needs_post_processing) {
if (e_data.postprocess_sh == NULL) {
- char *frag_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_renderpass_postprocess_frag_glsl);
- e_data.postprocess_sh = DRW_shader_create_fullscreen(frag_str, NULL);
- MEM_freeN(frag_str);
+ DRWShaderLibrary *lib = EEVEE_shader_lib_get();
+
+ e_data.postprocess_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_renderpass_postprocess_frag_glsl, lib, NULL);
}
DRW_PASS_CREATE(psl->renderpass_pass, DRW_STATE_WRITE_COLOR);
diff --git a/source/blender/draw/engines/eevee/eevee_sampling.c b/source/blender/draw/engines/eevee/eevee_sampling.c
index 5e951928c5a..253dae79902 100644
--- a/source/blender/draw/engines/eevee/eevee_sampling.c
+++ b/source/blender/draw/engines/eevee/eevee_sampling.c
@@ -34,7 +34,7 @@ void EEVEE_sample_ball(int sample_ofs, float radius, float rsample[3])
{
double ht_point[3];
double ht_offset[3] = {0.0, 0.0, 0.0};
- uint ht_primes[3] = {2, 3, 7};
+ const uint ht_primes[3] = {2, 3, 7};
BLI_halton_3d(ht_primes, ht_offset, sample_ofs, ht_point);
@@ -65,7 +65,7 @@ void EEVEE_sample_rectangle(int sample_ofs,
{
double ht_point[2];
double ht_offset[2] = {0.0, 0.0};
- uint ht_primes[2] = {2, 3};
+ const uint ht_primes[2] = {2, 3};
BLI_halton_2d(ht_primes, ht_offset, sample_ofs, ht_point);
@@ -91,7 +91,7 @@ void EEVEE_sample_ellipse(int sample_ofs,
{
double ht_point[2];
double ht_offset[2] = {0.0, 0.0};
- uint ht_primes[2] = {2, 3};
+ const uint ht_primes[2] = {2, 3};
BLI_halton_2d(ht_primes, ht_offset, sample_ofs, ht_point);
@@ -114,7 +114,7 @@ void EEVEE_random_rotation_m4(int sample_ofs, float scale, float r_mat[4][4])
{
double ht_point[3];
double ht_offset[3] = {0.0, 0.0, 0.0};
- uint ht_primes[3] = {2, 3, 5};
+ const uint ht_primes[3] = {2, 3, 5};
BLI_halton_3d(ht_primes, ht_offset, sample_ofs, ht_point);
diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
index 32d758dba4b..88029c2e940 100644
--- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
+++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
@@ -48,30 +48,12 @@ static struct {
struct GPUTexture *depth_src;
} e_data = {{NULL}}; /* Engine data */
-extern char datatoc_ambient_occlusion_lib_glsl[];
-extern char datatoc_common_view_lib_glsl[];
-extern char datatoc_common_uniforms_lib_glsl[];
-extern char datatoc_bsdf_common_lib_glsl[];
-extern char datatoc_bsdf_sampling_lib_glsl[];
-extern char datatoc_octahedron_lib_glsl[];
-extern char datatoc_cubemap_lib_glsl[];
extern char datatoc_effect_ssr_frag_glsl[];
-extern char datatoc_lightprobe_lib_glsl[];
-extern char datatoc_raytrace_lib_glsl[];
static struct GPUShader *eevee_effects_screen_raytrace_shader_get(int options)
{
if (e_data.ssr_sh[options] == NULL) {
- char *ssr_shader_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_bsdf_sampling_lib_glsl,
- datatoc_ambient_occlusion_lib_glsl,
- datatoc_octahedron_lib_glsl,
- datatoc_cubemap_lib_glsl,
- datatoc_lightprobe_lib_glsl,
- datatoc_raytrace_lib_glsl,
- datatoc_effect_ssr_frag_glsl);
+ DRWShaderLibrary *lib = EEVEE_shader_lib_get();
DynStr *ds_defines = BLI_dynstr_new();
BLI_dynstr_append(ds_defines, SHADER_DEFINES);
@@ -91,9 +73,9 @@ static struct GPUShader *eevee_effects_screen_raytrace_shader_get(int options)
char *ssr_define_str = BLI_dynstr_get_cstring(ds_defines);
BLI_dynstr_free(ds_defines);
- e_data.ssr_sh[options] = DRW_shader_create_fullscreen(ssr_shader_str, ssr_define_str);
+ e_data.ssr_sh[options] = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_ssr_frag_glsl, lib, ssr_define_str);
- MEM_freeN(ssr_shader_str);
MEM_freeN(ssr_define_str);
}
@@ -156,7 +138,7 @@ int EEVEE_screen_raytrace_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
const int divisor = (effects->reflection_trace_full) ? 1 : 2;
int tracing_res[2] = {(int)viewport_size[0] / divisor, (int)viewport_size[1] / divisor};
- int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]};
+ const int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]};
const bool high_qual_input = true; /* TODO dither low quality input */
const eGPUTextureFormat format = (high_qual_input) ? GPU_RGBA16F : GPU_RGBA8;
@@ -348,7 +330,7 @@ void EEVEE_reflection_output_init(EEVEE_ViewLayerData *UNUSED(sldata),
EEVEE_StorageList *stl = vedata->stl;
EEVEE_EffectsInfo *effects = stl->effects;
- float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* Create FrameBuffer. */
const eGPUTextureFormat texture_format = (tot_samples > 256) ? GPU_RGBA32F : GPU_RGBA16F;
diff --git a/source/blender/draw/engines/eevee/eevee_shaders.c b/source/blender/draw/engines/eevee/eevee_shaders.c
index 09e74c84948..5f125d395d3 100644
--- a/source/blender/draw/engines/eevee/eevee_shaders.c
+++ b/source/blender/draw/engines/eevee/eevee_shaders.c
@@ -28,6 +28,8 @@
#include "BLI_dynstr.h"
#include "BLI_string_utils.h"
+#include "DNA_world_types.h"
+
#include "MEM_guardedalloc.h"
#include "GPU_material.h"
@@ -40,19 +42,17 @@
static const char *filter_defines = "#define HAMMERSLEY_SIZE " STRINGIFY(HAMMERSLEY_SIZE) "\n"
#if defined(IRRADIANCE_SH_L2)
- "#define IRRADIANCE_SH_L2\n"
-#elif defined(IRRADIANCE_CUBEMAP)
- "#define IRRADIANCE_CUBEMAP\n"
+ "#define IRRADIANCE_SH_L2\n";
#elif defined(IRRADIANCE_HL2)
- "#define IRRADIANCE_HL2\n"
+ "#define IRRADIANCE_HL2\n";
#endif
- "#define NOISE_SIZE 64\n";
static struct {
+ /* Lookdev */
+ struct GPUShader *studiolight_probe_sh;
+ struct GPUShader *studiolight_background_sh;
+
/* Probes */
- struct GPUShader *probe_default_sh;
- struct GPUShader *probe_default_studiolight_sh;
- struct GPUShader *probe_background_studiolight_sh;
struct GPUShader *probe_grid_display_sh;
struct GPUShader *probe_cube_display_sh;
struct GPUShader *probe_planar_display_sh;
@@ -70,17 +70,16 @@ static struct {
struct GPUShader *taa_resolve_reproject_sh;
/* General purpose Shaders. */
- struct GPUShader *default_background;
+ struct GPUShader *lookdev_background;
struct GPUShader *update_noise_sh;
/* Shader strings */
- char *frag_shader_lib;
- char *vert_shader_str;
- char *vert_shadow_shader_str;
- char *vert_background_shader_str;
- char *vert_volume_shader_str;
- char *geom_volume_shader_str;
- char *volume_shader_lib;
+ char *closure_lit_lib;
+ char *surface_lit_frag;
+ char *surface_prepass_frag;
+ char *surface_geom_barycentric;
+
+ DRWShaderLibrary *lib;
/* LookDev Materials */
Material *glossy_mat;
@@ -88,6 +87,8 @@ static struct {
Material *error_mat;
+ World *default_world;
+
/* Default Material */
struct {
bNodeTree *ntree;
@@ -103,16 +104,39 @@ static struct {
} world;
} e_data = {NULL}; /* Engine data */
-extern char datatoc_bsdf_common_lib_glsl[];
-extern char datatoc_bsdf_sampling_lib_glsl[];
-extern char datatoc_common_uniforms_lib_glsl[];
+extern char datatoc_common_hair_lib_glsl[];
+extern char datatoc_common_math_lib_glsl[];
+extern char datatoc_common_math_geom_lib_glsl[];
extern char datatoc_common_view_lib_glsl[];
+extern char datatoc_gpu_shader_common_obinfos_lib_glsl[];
extern char datatoc_ambient_occlusion_lib_glsl[];
extern char datatoc_background_vert_glsl[];
-extern char datatoc_common_hair_lib_glsl[];
+extern char datatoc_bsdf_common_lib_glsl[];
+extern char datatoc_bsdf_lut_frag_glsl[];
+extern char datatoc_bsdf_sampling_lib_glsl[];
+extern char datatoc_btdf_lut_frag_glsl[];
+extern char datatoc_closure_lib_glsl[];
+extern char datatoc_common_uniforms_lib_glsl[];
+extern char datatoc_common_utiltex_lib_glsl[];
extern char datatoc_cubemap_lib_glsl[];
-extern char datatoc_default_world_frag_glsl[];
+extern char datatoc_default_frag_glsl[];
+extern char datatoc_lookdev_world_frag_glsl[];
+extern char datatoc_effect_bloom_frag_glsl[];
+extern char datatoc_effect_dof_frag_glsl[];
+extern char datatoc_effect_dof_vert_glsl[];
+extern char datatoc_effect_downsample_cube_frag_glsl[];
+extern char datatoc_effect_downsample_frag_glsl[];
+extern char datatoc_effect_gtao_frag_glsl[];
+extern char datatoc_effect_minmaxz_frag_glsl[];
+extern char datatoc_effect_mist_frag_glsl[];
+extern char datatoc_effect_motion_blur_frag_glsl[];
+extern char datatoc_effect_ssr_frag_glsl[];
+extern char datatoc_effect_subsurface_frag_glsl[];
+extern char datatoc_effect_temporal_aa_glsl[];
+extern char datatoc_effect_translucency_frag_glsl[];
+extern char datatoc_effect_velocity_resolve_frag_glsl[];
+extern char datatoc_effect_velocity_tile_frag_glsl[];
extern char datatoc_irradiance_lib_glsl[];
extern char datatoc_lightprobe_cube_display_frag_glsl[];
extern char datatoc_lightprobe_cube_display_vert_glsl[];
@@ -131,72 +155,111 @@ extern char datatoc_lightprobe_planar_downsample_geom_glsl[];
extern char datatoc_lightprobe_planar_downsample_vert_glsl[];
extern char datatoc_lightprobe_vert_glsl[];
extern char datatoc_lights_lib_glsl[];
-extern char datatoc_lit_surface_frag_glsl[];
-extern char datatoc_lit_surface_vert_glsl[];
+extern char datatoc_closure_lit_lib_glsl[];
extern char datatoc_ltc_lib_glsl[];
+extern char datatoc_object_motion_frag_glsl[];
+extern char datatoc_object_motion_vert_glsl[];
extern char datatoc_octahedron_lib_glsl[];
extern char datatoc_prepass_frag_glsl[];
+extern char datatoc_prepass_vert_glsl[];
extern char datatoc_raytrace_lib_glsl[];
+extern char datatoc_renderpass_lib_glsl[];
+extern char datatoc_renderpass_postprocess_frag_glsl[];
+extern char datatoc_shadow_accum_frag_glsl[];
+extern char datatoc_shadow_frag_glsl[];
extern char datatoc_shadow_vert_glsl[];
extern char datatoc_ssr_lib_glsl[];
+extern char datatoc_surface_frag_glsl[];
+extern char datatoc_surface_geom_glsl[];
+extern char datatoc_surface_lib_glsl[];
+extern char datatoc_surface_vert_glsl[];
extern char datatoc_update_noise_frag_glsl[];
+extern char datatoc_volumetric_accum_frag_glsl[];
extern char datatoc_volumetric_frag_glsl[];
extern char datatoc_volumetric_geom_glsl[];
+extern char datatoc_volumetric_integration_frag_glsl[];
extern char datatoc_volumetric_lib_glsl[];
+extern char datatoc_volumetric_resolve_frag_glsl[];
+extern char datatoc_volumetric_scatter_frag_glsl[];
extern char datatoc_volumetric_vert_glsl[];
-/* Velocity Resolve */
-extern char datatoc_effect_velocity_resolve_frag_glsl[];
-
-/* Temporal Sampling */
-extern char datatoc_effect_temporal_aa_glsl[];
-
/* *********** FUNCTIONS *********** */
+static void eevee_shader_library_ensure(void)
+{
+ if (e_data.lib == NULL) {
+ e_data.lib = DRW_shader_library_create();
+ /* NOTE: Theses needs to be ordered by dependencies. */
+ DRW_SHADER_LIB_ADD(e_data.lib, common_math_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, common_math_geom_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, common_hair_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, common_view_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, common_uniforms_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, gpu_shader_common_obinfos_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, renderpass_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, bsdf_common_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, common_utiltex_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, bsdf_sampling_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, cubemap_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, raytrace_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, ambient_occlusion_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, octahedron_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, irradiance_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, lightprobe_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, ltc_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, lights_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, surface_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, volumetric_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, closure_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, ssr_lib);
+
+ /* Add one for each Closure */
+ e_data.closure_lit_lib = BLI_string_joinN(datatoc_closure_lit_lib_glsl,
+ datatoc_closure_lit_lib_glsl,
+ datatoc_closure_lit_lib_glsl,
+ datatoc_closure_lit_lib_glsl,
+ datatoc_closure_lit_lib_glsl,
+ datatoc_closure_lit_lib_glsl,
+ datatoc_closure_lit_lib_glsl,
+ datatoc_closure_lit_lib_glsl,
+ datatoc_closure_lit_lib_glsl,
+ datatoc_closure_lit_lib_glsl,
+ datatoc_closure_lit_lib_glsl);
+
+ DRW_shader_library_add_file(e_data.lib, e_data.closure_lit_lib, "closure_lit_lib.glsl");
+
+ e_data.surface_lit_frag = DRW_shader_library_create_shader_string(e_data.lib,
+ datatoc_surface_frag_glsl);
+
+ e_data.surface_prepass_frag = DRW_shader_library_create_shader_string(
+ e_data.lib, datatoc_prepass_frag_glsl);
+
+ e_data.surface_geom_barycentric = DRW_shader_library_create_shader_string(
+ e_data.lib, datatoc_surface_geom_glsl);
+ }
+}
+
void EEVEE_shaders_lightprobe_shaders_init(void)
{
BLI_assert(e_data.probe_filter_glossy_sh == NULL);
- char *shader_str = NULL;
-
- shader_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_bsdf_sampling_lib_glsl,
- datatoc_lightprobe_filter_glossy_frag_glsl);
-
- e_data.probe_filter_glossy_sh = DRW_shader_create(
- datatoc_lightprobe_vert_glsl, datatoc_lightprobe_geom_glsl, shader_str, filter_defines);
-
- e_data.probe_default_sh = DRW_shader_create_with_lib(datatoc_background_vert_glsl,
- NULL,
- datatoc_default_world_frag_glsl,
- datatoc_common_view_lib_glsl,
- NULL);
- MEM_freeN(shader_str);
+ eevee_shader_library_ensure();
- shader_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_bsdf_sampling_lib_glsl,
- datatoc_lightprobe_filter_diffuse_frag_glsl);
+ e_data.probe_filter_glossy_sh = DRW_shader_create_with_shaderlib(
+ datatoc_lightprobe_vert_glsl,
+ datatoc_lightprobe_geom_glsl,
+ datatoc_lightprobe_filter_glossy_frag_glsl,
+ e_data.lib,
+ filter_defines);
- e_data.probe_filter_diffuse_sh = DRW_shader_create_fullscreen(shader_str, filter_defines);
+ e_data.probe_filter_diffuse_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_lightprobe_filter_diffuse_frag_glsl, e_data.lib, filter_defines);
- MEM_freeN(shader_str);
+ e_data.probe_filter_visibility_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_lightprobe_filter_visibility_frag_glsl, e_data.lib, filter_defines);
- shader_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_bsdf_sampling_lib_glsl,
- datatoc_lightprobe_filter_visibility_frag_glsl);
-
- e_data.probe_filter_visibility_sh = DRW_shader_create_fullscreen(shader_str, filter_defines);
-
- MEM_freeN(shader_str);
-
- e_data.probe_grid_fill_sh = DRW_shader_create_fullscreen(datatoc_lightprobe_grid_fill_frag_glsl,
- filter_defines);
+ e_data.probe_grid_fill_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_lightprobe_grid_fill_frag_glsl, e_data.lib, filter_defines);
e_data.probe_planar_downsample_sh = DRW_shader_create(
datatoc_lightprobe_planar_downsample_vert_glsl,
@@ -207,70 +270,18 @@ void EEVEE_shaders_lightprobe_shaders_init(void)
void EEVEE_shaders_material_shaders_init(void)
{
- e_data.frag_shader_lib = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_bsdf_sampling_lib_glsl,
- datatoc_ambient_occlusion_lib_glsl,
- datatoc_raytrace_lib_glsl,
- datatoc_ssr_lib_glsl,
- datatoc_octahedron_lib_glsl,
- datatoc_cubemap_lib_glsl,
- datatoc_irradiance_lib_glsl,
- datatoc_lightprobe_lib_glsl,
- datatoc_ltc_lib_glsl,
- datatoc_lights_lib_glsl,
- /* Add one for each Closure */
- datatoc_lit_surface_frag_glsl,
- datatoc_lit_surface_frag_glsl,
- datatoc_lit_surface_frag_glsl,
- datatoc_lit_surface_frag_glsl,
- datatoc_lit_surface_frag_glsl,
- datatoc_lit_surface_frag_glsl,
- datatoc_lit_surface_frag_glsl,
- datatoc_lit_surface_frag_glsl,
- datatoc_lit_surface_frag_glsl,
- datatoc_lit_surface_frag_glsl,
- datatoc_lit_surface_frag_glsl,
- datatoc_volumetric_lib_glsl);
-
- e_data.volume_shader_lib = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_ambient_occlusion_lib_glsl,
- datatoc_octahedron_lib_glsl,
- datatoc_cubemap_lib_glsl,
- datatoc_irradiance_lib_glsl,
- datatoc_lightprobe_lib_glsl,
- datatoc_ltc_lib_glsl,
- datatoc_lights_lib_glsl,
- datatoc_volumetric_lib_glsl,
- datatoc_volumetric_frag_glsl);
-
- e_data.vert_shader_str = BLI_string_joinN(
- datatoc_common_view_lib_glsl, datatoc_common_hair_lib_glsl, datatoc_lit_surface_vert_glsl);
-
- e_data.vert_shadow_shader_str = BLI_string_joinN(
- datatoc_common_view_lib_glsl, datatoc_common_hair_lib_glsl, datatoc_shadow_vert_glsl);
-
- e_data.vert_background_shader_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_background_vert_glsl);
-
- e_data.vert_volume_shader_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_volumetric_vert_glsl);
-
- e_data.geom_volume_shader_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_volumetric_geom_glsl);
+ eevee_shader_library_ensure();
}
-GPUShader *EEVEE_shaders_probe_filter_glossy_sh_get(void)
+DRWShaderLibrary *EEVEE_shader_lib_get(void)
{
- return e_data.probe_filter_glossy_sh;
+ eevee_shader_library_ensure();
+ return e_data.lib;
}
-GPUShader *EEVEE_shaders_probe_default_sh_get(void)
+GPUShader *EEVEE_shaders_probe_filter_glossy_sh_get(void)
{
- return e_data.probe_default_sh;
+ return e_data.probe_filter_glossy_sh;
}
GPUShader *EEVEE_shaders_probe_filter_diffuse_sh_get(void)
@@ -293,59 +304,40 @@ GPUShader *EEVEE_shaders_probe_planar_downsample_sh_get(void)
return e_data.probe_planar_downsample_sh;
}
-GPUShader *EEVEE_shaders_default_studiolight_sh_get(void)
+GPUShader *EEVEE_shaders_studiolight_probe_sh_get(void)
{
- if (e_data.probe_default_studiolight_sh == NULL) {
- e_data.probe_default_studiolight_sh = DRW_shader_create_with_lib(
- datatoc_background_vert_glsl,
- NULL,
- datatoc_default_world_frag_glsl,
- datatoc_common_view_lib_glsl,
- "#define LOOKDEV\n");
- }
- return e_data.probe_default_studiolight_sh;
+ if (e_data.studiolight_probe_sh == NULL) {
+ e_data.studiolight_probe_sh = DRW_shader_create_with_shaderlib(datatoc_background_vert_glsl,
+ NULL,
+ datatoc_lookdev_world_frag_glsl,
+ e_data.lib,
+ SHADER_DEFINES);
+ }
+ return e_data.studiolight_probe_sh;
}
-GPUShader *EEVEE_shaders_background_studiolight_sh_get(void)
+GPUShader *EEVEE_shaders_studiolight_background_sh_get(void)
{
- if (e_data.probe_background_studiolight_sh == NULL) {
- char *frag_str = BLI_string_joinN(datatoc_octahedron_lib_glsl,
- datatoc_cubemap_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_lightprobe_lib_glsl,
- datatoc_default_world_frag_glsl);
-
- e_data.probe_background_studiolight_sh = DRW_shader_create_with_lib(
+ if (e_data.studiolight_background_sh == NULL) {
+ e_data.studiolight_background_sh = DRW_shader_create_with_shaderlib(
datatoc_background_vert_glsl,
NULL,
- frag_str,
- datatoc_common_view_lib_glsl,
+ datatoc_lookdev_world_frag_glsl,
+ e_data.lib,
"#define LOOKDEV_BG\n" SHADER_DEFINES);
-
- MEM_freeN(frag_str);
}
- return e_data.probe_background_studiolight_sh;
+ return e_data.studiolight_background_sh;
}
GPUShader *EEVEE_shaders_probe_cube_display_sh_get(void)
{
if (e_data.probe_cube_display_sh == NULL) {
- char *shader_str = BLI_string_joinN(datatoc_octahedron_lib_glsl,
- datatoc_cubemap_lib_glsl,
- datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_lightprobe_lib_glsl,
- datatoc_lightprobe_cube_display_frag_glsl);
-
- char *vert_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_lightprobe_cube_display_vert_glsl);
-
- e_data.probe_cube_display_sh = DRW_shader_create(vert_str, NULL, shader_str, SHADER_DEFINES);
-
- MEM_freeN(vert_str);
- MEM_freeN(shader_str);
+ e_data.probe_cube_display_sh = DRW_shader_create_with_shaderlib(
+ datatoc_lightprobe_cube_display_vert_glsl,
+ NULL,
+ datatoc_lightprobe_cube_display_frag_glsl,
+ e_data.lib,
+ SHADER_DEFINES);
}
return e_data.probe_cube_display_sh;
}
@@ -353,22 +345,12 @@ GPUShader *EEVEE_shaders_probe_cube_display_sh_get(void)
GPUShader *EEVEE_shaders_probe_grid_display_sh_get(void)
{
if (e_data.probe_grid_display_sh == NULL) {
- char *shader_str = BLI_string_joinN(datatoc_octahedron_lib_glsl,
- datatoc_cubemap_lib_glsl,
- datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_irradiance_lib_glsl,
- datatoc_lightprobe_lib_glsl,
- datatoc_lightprobe_grid_display_frag_glsl);
-
- char *vert_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_lightprobe_grid_display_vert_glsl);
-
- e_data.probe_grid_display_sh = DRW_shader_create(vert_str, NULL, shader_str, filter_defines);
-
- MEM_freeN(vert_str);
- MEM_freeN(shader_str);
+ e_data.probe_grid_display_sh = DRW_shader_create_with_shaderlib(
+ datatoc_lightprobe_grid_display_vert_glsl,
+ NULL,
+ datatoc_lightprobe_grid_display_frag_glsl,
+ e_data.lib,
+ filter_defines);
}
return e_data.probe_grid_display_sh;
}
@@ -376,16 +358,12 @@ GPUShader *EEVEE_shaders_probe_grid_display_sh_get(void)
GPUShader *EEVEE_shaders_probe_planar_display_sh_get(void)
{
if (e_data.probe_planar_display_sh == NULL) {
- char *vert_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_lightprobe_planar_display_vert_glsl);
-
- char *shader_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_lightprobe_planar_display_frag_glsl);
-
- e_data.probe_planar_display_sh = DRW_shader_create(vert_str, NULL, shader_str, NULL);
-
- MEM_freeN(vert_str);
- MEM_freeN(shader_str);
+ e_data.probe_planar_display_sh = DRW_shader_create_with_shaderlib(
+ datatoc_lightprobe_planar_display_vert_glsl,
+ NULL,
+ datatoc_lightprobe_planar_display_frag_glsl,
+ e_data.lib,
+ NULL);
}
return e_data.probe_planar_display_sh;
}
@@ -393,34 +371,17 @@ GPUShader *EEVEE_shaders_probe_planar_display_sh_get(void)
GPUShader *EEVEE_shaders_velocity_resolve_sh_get(void)
{
if (e_data.velocity_resolve_sh == NULL) {
- char *frag_str = BLI_string_joinN(datatoc_common_uniforms_lib_glsl,
- datatoc_common_view_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_effect_velocity_resolve_frag_glsl);
-
- e_data.velocity_resolve_sh = DRW_shader_create_fullscreen(frag_str, NULL);
-
- MEM_freeN(frag_str);
+ e_data.velocity_resolve_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_velocity_resolve_frag_glsl, e_data.lib, NULL);
}
return e_data.velocity_resolve_sh;
}
-GPUShader *EEVEE_shaders_default_background_sh_get(void)
-{
- if (e_data.default_background == NULL) {
- e_data.default_background = DRW_shader_create_with_lib(datatoc_background_vert_glsl,
- NULL,
- datatoc_default_world_frag_glsl,
- datatoc_common_view_lib_glsl,
- NULL);
- }
- return e_data.default_background;
-}
-
GPUShader *EEVEE_shaders_update_noise_sh_get(void)
{
if (e_data.update_noise_sh == NULL) {
- e_data.update_noise_sh = DRW_shader_create_fullscreen(datatoc_update_noise_frag_glsl, NULL);
+ e_data.update_noise_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_update_noise_frag_glsl, e_data.lib, NULL);
}
return e_data.update_noise_sh;
}
@@ -437,13 +398,8 @@ GPUShader *EEVEE_shaders_taa_resolve_sh_get(EEVEE_EffectsFlag enabled_effects)
sh = &e_data.taa_resolve_sh;
}
if (*sh == NULL) {
- char *frag_str = BLI_string_joinN(datatoc_common_uniforms_lib_glsl,
- datatoc_common_view_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_effect_temporal_aa_glsl);
-
- *sh = DRW_shader_create_fullscreen(frag_str, define);
- MEM_freeN(frag_str);
+ *sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_temporal_aa_glsl, e_data.lib, define);
}
return *sh;
@@ -583,6 +539,18 @@ struct bNodeTree *EEVEE_shader_default_world_nodetree(World *wo)
return e_data.world.ntree;
}
+World *EEVEE_world_default_get(void)
+{
+ if (e_data.default_world == NULL) {
+ e_data.default_world = BKE_id_new_nomain(ID_WO, "EEVEEE default world");
+ copy_v3_fl(&e_data.default_world->horr, 0.0f);
+ e_data.default_world->use_nodes = 0;
+ e_data.default_world->nodetree = NULL;
+ BLI_listbase_clear(&e_data.default_world->gpumaterial);
+ }
+ return e_data.default_world;
+}
+
static char *eevee_get_defines(int options)
{
char *str = NULL;
@@ -605,7 +573,7 @@ static char *eevee_get_defines(int options)
if ((options & VAR_MAT_HAIR) != 0) {
BLI_dynstr_append(ds, "#define HAIR_SHADER\n");
}
- if ((options & (VAR_MAT_PROBE | VAR_WORLD_PROBE)) != 0) {
+ if ((options & VAR_WORLD_PROBE) != 0) {
BLI_dynstr_append(ds, "#define PROBE_CAPTURE\n");
}
if ((options & VAR_MAT_HASH) != 0) {
@@ -635,13 +603,13 @@ static char *eevee_get_vert(int options)
char *str = NULL;
if ((options & VAR_MAT_VOLUME) != 0) {
- str = BLI_strdup(e_data.vert_volume_shader_str);
+ str = DRW_shader_library_create_shader_string(e_data.lib, datatoc_volumetric_vert_glsl);
}
else if ((options & (VAR_WORLD_PROBE | VAR_WORLD_BACKGROUND)) != 0) {
- str = BLI_strdup(e_data.vert_background_shader_str);
+ str = DRW_shader_library_create_shader_string(e_data.lib, datatoc_background_vert_glsl);
}
else {
- str = BLI_strdup(e_data.vert_shader_str);
+ str = DRW_shader_library_create_shader_string(e_data.lib, datatoc_surface_vert_glsl);
}
return str;
@@ -652,7 +620,7 @@ static char *eevee_get_geom(int options)
char *str = NULL;
if ((options & VAR_MAT_VOLUME) != 0) {
- str = BLI_strdup(e_data.geom_volume_shader_str);
+ str = DRW_shader_library_create_shader_string(e_data.lib, datatoc_volumetric_geom_glsl);
}
return str;
@@ -663,18 +631,36 @@ static char *eevee_get_frag(int options)
char *str = NULL;
if ((options & VAR_MAT_VOLUME) != 0) {
- str = BLI_strdup(e_data.volume_shader_lib);
+ str = DRW_shader_library_create_shader_string(e_data.lib, datatoc_volumetric_frag_glsl);
}
else if ((options & VAR_MAT_DEPTH) != 0) {
- str = BLI_string_joinN(e_data.frag_shader_lib, datatoc_prepass_frag_glsl);
+ str = BLI_strdup(e_data.surface_prepass_frag);
}
else {
- str = BLI_strdup(e_data.frag_shader_lib);
+ str = BLI_strdup(e_data.surface_lit_frag);
}
return str;
}
+static void eevee_material_post_eval(GPUMaterial *mat,
+ int options,
+ const char **UNUSED(vert_code),
+ const char **geom_code,
+ const char **UNUSED(frag_lib),
+ const char **UNUSED(defines))
+{
+ const bool is_hair = (options & VAR_MAT_HAIR) != 0;
+ const bool is_mesh = (options & VAR_MAT_MESH) != 0;
+
+ /* Force geometry usage if GPU_BARYCENTRIC_DIST or GPU_BARYCENTRIC_TEXCO are used.
+ * Note: GPU_BARYCENTRIC_TEXCO only requires it if the shader is not drawing hairs. */
+ if (!is_hair && is_mesh && GPU_material_flag_get(mat, GPU_MATFLAG_BARYCENTRIC) &&
+ *geom_code == NULL) {
+ *geom_code = e_data.surface_geom_barycentric;
+ }
+}
+
static struct GPUMaterial *eevee_material_get_ex(
struct Scene *scene, Material *ma, World *wo, int options, bool deferred)
{
@@ -702,14 +688,16 @@ static struct GPUMaterial *eevee_material_get_ex(
char *frag = eevee_get_frag(options);
if (ma) {
+ GPUMaterialEvalCallbackFn cbfn = &eevee_material_post_eval;
+
bNodeTree *ntree = !is_default ? ma->nodetree : EEVEE_shader_default_surface_nodetree(ma);
mat = DRW_shader_create_from_material(
- scene, ma, ntree, engine, options, is_volume, vert, geom, frag, defines, deferred);
+ scene, ma, ntree, engine, options, is_volume, vert, geom, frag, defines, deferred, cbfn);
}
else {
bNodeTree *ntree = !is_default ? wo->nodetree : EEVEE_shader_default_world_nodetree(wo);
mat = DRW_shader_create_from_world(
- scene, wo, ntree, engine, options, is_volume, vert, geom, frag, defines, deferred);
+ scene, wo, ntree, engine, options, is_volume, vert, geom, frag, defines, deferred, NULL);
}
MEM_SAFE_FREE(defines);
@@ -764,30 +752,31 @@ struct GPUMaterial *EEVEE_material_get(
void EEVEE_shaders_free(void)
{
- MEM_SAFE_FREE(e_data.frag_shader_lib);
- MEM_SAFE_FREE(e_data.vert_shader_str);
- MEM_SAFE_FREE(e_data.vert_shadow_shader_str);
- MEM_SAFE_FREE(e_data.vert_background_shader_str);
- MEM_SAFE_FREE(e_data.vert_volume_shader_str);
- MEM_SAFE_FREE(e_data.geom_volume_shader_str);
- MEM_SAFE_FREE(e_data.volume_shader_lib);
- DRW_SHADER_FREE_SAFE(e_data.default_background);
+ MEM_SAFE_FREE(e_data.closure_lit_lib);
+ MEM_SAFE_FREE(e_data.surface_prepass_frag);
+ MEM_SAFE_FREE(e_data.surface_lit_frag);
+ MEM_SAFE_FREE(e_data.surface_geom_barycentric);
+ DRW_SHADER_FREE_SAFE(e_data.lookdev_background);
DRW_SHADER_FREE_SAFE(e_data.update_noise_sh);
- DRW_SHADER_FREE_SAFE(e_data.probe_default_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_filter_glossy_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_filter_diffuse_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_filter_visibility_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_grid_fill_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_planar_downsample_sh);
- DRW_SHADER_FREE_SAFE(e_data.probe_default_studiolight_sh);
- DRW_SHADER_FREE_SAFE(e_data.probe_background_studiolight_sh);
+ DRW_SHADER_FREE_SAFE(e_data.studiolight_probe_sh);
+ DRW_SHADER_FREE_SAFE(e_data.studiolight_background_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_grid_display_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_cube_display_sh);
DRW_SHADER_FREE_SAFE(e_data.probe_planar_display_sh);
DRW_SHADER_FREE_SAFE(e_data.velocity_resolve_sh);
DRW_SHADER_FREE_SAFE(e_data.taa_resolve_sh);
DRW_SHADER_FREE_SAFE(e_data.taa_resolve_reproject_sh);
+ DRW_SHADER_LIB_FREE_SAFE(e_data.lib);
+ if (e_data.default_world) {
+ BKE_id_free(NULL, e_data.default_world);
+ e_data.default_world = NULL;
+ }
if (e_data.glossy_mat) {
BKE_id_free(NULL, e_data.glossy_mat);
e_data.glossy_mat = NULL;
diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c b/source/blender/draw/engines/eevee/eevee_shadows.c
index 8c50b26b45f..71a4da9fcab 100644
--- a/source/blender/draw/engines/eevee/eevee_shadows.c
+++ b/source/blender/draw/engines/eevee/eevee_shadows.c
@@ -42,11 +42,6 @@ static struct {
extern char datatoc_shadow_vert_glsl[];
extern char datatoc_shadow_frag_glsl[];
extern char datatoc_shadow_accum_frag_glsl[];
-extern char datatoc_common_view_lib_glsl[];
-extern char datatoc_common_uniforms_lib_glsl[];
-extern char datatoc_bsdf_common_lib_glsl[];
-extern char datatoc_lights_lib_glsl[];
-extern char datatoc_raytrace_lib_glsl[];
void eevee_contact_shadow_setup(const Light *la, EEVEE_Shadow *evsh)
{
@@ -65,23 +60,13 @@ void EEVEE_shadows_init(EEVEE_ViewLayerData *sldata)
const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
if (!e_data.shadow_sh) {
- e_data.shadow_sh = DRW_shader_create_with_lib(datatoc_shadow_vert_glsl,
- NULL,
- datatoc_shadow_frag_glsl,
- datatoc_common_view_lib_glsl,
- NULL);
- }
+ DRWShaderLibrary *lib = EEVEE_shader_lib_get();
- if (!e_data.shadow_accum_sh) {
- char *frag_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_raytrace_lib_glsl,
- datatoc_lights_lib_glsl,
- datatoc_shadow_accum_frag_glsl);
+ e_data.shadow_sh = DRW_shader_create_with_shaderlib(
+ datatoc_shadow_vert_glsl, NULL, datatoc_shadow_frag_glsl, lib, NULL);
- e_data.shadow_accum_sh = DRW_shader_create_fullscreen(frag_str, SHADER_DEFINES);
- MEM_freeN(frag_str);
+ e_data.shadow_accum_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_shadow_accum_frag_glsl, lib, SHADER_DEFINES);
}
if (!sldata->lights) {
@@ -400,7 +385,7 @@ void EEVEE_shadow_output_init(EEVEE_ViewLayerData *sldata,
EEVEE_EffectsInfo *effects = stl->effects;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
- float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* Create FrameBuffer. */
const eGPUTextureFormat texture_format = GPU_R32F;
diff --git a/source/blender/draw/engines/eevee/eevee_shadows_cascade.c b/source/blender/draw/engines/eevee/eevee_shadows_cascade.c
index 1fd8d818b33..246bc18b71a 100644
--- a/source/blender/draw/engines/eevee/eevee_shadows_cascade.c
+++ b/source/blender/draw/engines/eevee/eevee_shadows_cascade.c
@@ -139,7 +139,7 @@ static void eevee_shadow_cascade_setup(EEVEE_LightsInfo *linfo,
float jitter_ofs[2];
double ht_point[2];
double ht_offset[2] = {0.0, 0.0};
- uint ht_primes[2] = {2, 3};
+ const uint ht_primes[2] = {2, 3};
BLI_halton_2d(ht_primes, ht_offset, sample_ofs, ht_point);
diff --git a/source/blender/draw/engines/eevee/eevee_subsurface.c b/source/blender/draw/engines/eevee/eevee_subsurface.c
index ef4588f4aca..74fb7ac99b7 100644
--- a/source/blender/draw/engines/eevee/eevee_subsurface.c
+++ b/source/blender/draw/engines/eevee/eevee_subsurface.c
@@ -38,41 +38,19 @@ static struct {
struct GPUShader *sss_sh[3];
} e_data = {{NULL}}; /* Engine data */
-extern char datatoc_common_view_lib_glsl[];
-extern char datatoc_common_uniforms_lib_glsl[];
-extern char datatoc_lights_lib_glsl[];
-extern char datatoc_raytrace_lib_glsl[];
-extern char datatoc_octahedron_lib_glsl[];
-extern char datatoc_cubemap_lib_glsl[];
-extern char datatoc_bsdf_sampling_lib_glsl[];
-extern char datatoc_bsdf_common_lib_glsl[];
extern char datatoc_effect_subsurface_frag_glsl[];
extern char datatoc_effect_translucency_frag_glsl[];
static void eevee_create_shader_subsurface(void)
{
- char *frag_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_effect_subsurface_frag_glsl);
-
- /* TODO(fclem) remove some of these dependencies. */
- char *frag_translucent_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_bsdf_sampling_lib_glsl,
- datatoc_raytrace_lib_glsl,
- datatoc_octahedron_lib_glsl,
- datatoc_cubemap_lib_glsl,
- datatoc_lights_lib_glsl,
- datatoc_effect_translucency_frag_glsl);
-
- e_data.sss_sh[0] = DRW_shader_create_fullscreen(frag_str, "#define FIRST_PASS\n");
- e_data.sss_sh[1] = DRW_shader_create_fullscreen(frag_str, "#define SECOND_PASS\n");
- e_data.sss_sh[2] = DRW_shader_create_fullscreen(frag_translucent_str,
- "#define EEVEE_TRANSLUCENCY\n" SHADER_DEFINES);
-
- MEM_freeN(frag_translucent_str);
- MEM_freeN(frag_str);
+ DRWShaderLibrary *lib = EEVEE_shader_lib_get();
+
+ e_data.sss_sh[0] = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_subsurface_frag_glsl, lib, "#define FIRST_PASS\n");
+ e_data.sss_sh[1] = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_subsurface_frag_glsl, lib, "#define SECOND_PASS\n");
+ e_data.sss_sh[2] = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_effect_translucency_frag_glsl, lib, "#define EEVEE_TRANSLUCENCY\n" SHADER_DEFINES);
}
void EEVEE_subsurface_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *UNUSED(vedata))
@@ -188,7 +166,7 @@ void EEVEE_subsurface_output_init(EEVEE_ViewLayerData *UNUSED(sldata),
* pass in look dev mode active. `texture_created` will make sure that newly created textures
* are cleared. */
if (effects->taa_current_sample == 1 || texture_created) {
- float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
GPU_framebuffer_bind(fbl->sss_accum_fb);
GPU_framebuffer_clear_color(fbl->sss_accum_fb, clear);
}
@@ -304,7 +282,7 @@ void EEVEE_subsurface_data_render(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat
EEVEE_EffectsInfo *effects = stl->effects;
if ((effects->enabled_effects & EFFECT_SSS) != 0) {
- float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* Clear sss_data texture only... can this be done in a more clever way? */
GPU_framebuffer_bind(fbl->sss_clear_fb);
GPU_framebuffer_clear_color(fbl->sss_clear_fb, clear);
@@ -342,7 +320,7 @@ void EEVEE_subsurface_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
EEVEE_EffectsInfo *effects = stl->effects;
if ((effects->enabled_effects & EFFECT_SSS) != 0) {
- float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
DRW_stats_group_start("SSS");
diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
index 997f9a5be9d..5976a9505e8 100644
--- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
+++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
@@ -171,7 +171,7 @@ void EEVEE_temporal_sampling_update_matrices(EEVEE_Data *vedata)
double ht_point[2];
double ht_offset[2] = {0.0, 0.0};
- uint ht_primes[2] = {2, 3};
+ const uint ht_primes[2] = {2, 3};
BLI_halton_2d(ht_primes, ht_offset, effects->taa_current_sample - 1, ht_point);
@@ -212,7 +212,9 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data
* Reset for each "redraw". When rendering using ogl render,
* we accumulate the redraw inside the drawing loop in eevee_draw_scene().
**/
- effects->taa_render_sample = 1;
+ if (DRW_state_is_opengl_render()) {
+ effects->taa_render_sample = 1;
+ }
effects->bypass_drawing = false;
EEVEE_temporal_sampling_create_view(vedata);
@@ -269,7 +271,14 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data
}
}
else {
- effects->bypass_drawing = true;
+ const bool all_shaders_compiled = stl->g_data->queued_shaders_count_prev == 0;
+ /* Fix Texture painting (see T79370) and shader compilation (see T78520). */
+ if (DRW_state_is_navigating() || !all_shaders_compiled) {
+ effects->taa_current_sample = 1;
+ }
+ else {
+ effects->bypass_drawing = true;
+ }
}
return repro_flag | EFFECT_TAA | EFFECT_DOUBLE_BUFFER | EFFECT_DEPTH_DOUBLE_BUFFER |
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index 300022e97a9..e1e65c29b4f 100644
--- a/source/blender/draw/engines/eevee/eevee_volumes.c
+++ b/source/blender/draw/engines/eevee/eevee_volumes.c
@@ -44,16 +44,12 @@
#include "DEG_depsgraph_query.h"
-#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_material.h"
#include "GPU_texture.h"
#include "eevee_private.h"
static struct {
- char *volumetric_common_lib;
- char *volumetric_common_lights_lib;
-
struct GPUShader *volumetric_clear_sh;
struct GPUShader *scatter_sh;
struct GPUShader *scatter_with_lights_sh;
@@ -97,57 +93,48 @@ extern char datatoc_common_fullscreen_vert_glsl[];
static void eevee_create_shader_volumes(void)
{
- e_data.volumetric_common_lib = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_volumetric_lib_glsl);
-
- e_data.volumetric_common_lights_lib = BLI_string_joinN(datatoc_common_view_lib_glsl,
- datatoc_common_uniforms_lib_glsl,
- datatoc_bsdf_common_lib_glsl,
- datatoc_octahedron_lib_glsl,
- datatoc_cubemap_lib_glsl,
- datatoc_irradiance_lib_glsl,
- datatoc_lights_lib_glsl,
- datatoc_volumetric_lib_glsl);
-
- e_data.volumetric_clear_sh = DRW_shader_create_with_lib(datatoc_volumetric_vert_glsl,
- datatoc_volumetric_geom_glsl,
- datatoc_volumetric_frag_glsl,
- e_data.volumetric_common_lib,
- "#define VOLUMETRICS\n"
- "#define CLEAR\n");
- e_data.scatter_sh = DRW_shader_create_with_lib(datatoc_volumetric_vert_glsl,
- datatoc_volumetric_geom_glsl,
- datatoc_volumetric_scatter_frag_glsl,
- e_data.volumetric_common_lights_lib,
- SHADER_DEFINES
- "#define VOLUMETRICS\n"
- "#define VOLUME_SHADOW\n");
- e_data.scatter_with_lights_sh = DRW_shader_create_with_lib(datatoc_volumetric_vert_glsl,
- datatoc_volumetric_geom_glsl,
- datatoc_volumetric_scatter_frag_glsl,
- e_data.volumetric_common_lights_lib,
- SHADER_DEFINES
- "#define VOLUMETRICS\n"
- "#define VOLUME_LIGHTING\n"
- "#define VOLUME_SHADOW\n");
- e_data.volumetric_integration_sh = DRW_shader_create_with_lib(
+ DRWShaderLibrary *lib = EEVEE_shader_lib_get();
+
+ e_data.volumetric_clear_sh = DRW_shader_create_with_shaderlib(datatoc_volumetric_vert_glsl,
+ datatoc_volumetric_geom_glsl,
+ datatoc_volumetric_frag_glsl,
+ lib,
+ SHADER_DEFINES
+ "#define VOLUMETRICS\n"
+ "#define CLEAR\n");
+
+ e_data.scatter_sh = DRW_shader_create_with_shaderlib(datatoc_volumetric_vert_glsl,
+ datatoc_volumetric_geom_glsl,
+ datatoc_volumetric_scatter_frag_glsl,
+ lib,
+ SHADER_DEFINES
+ "#define VOLUMETRICS\n"
+ "#define VOLUME_SHADOW\n");
+
+ e_data.scatter_with_lights_sh = DRW_shader_create_with_shaderlib(
+ datatoc_volumetric_vert_glsl,
+ datatoc_volumetric_geom_glsl,
+ datatoc_volumetric_scatter_frag_glsl,
+ lib,
+ SHADER_DEFINES
+ "#define VOLUMETRICS\n"
+ "#define VOLUME_LIGHTING\n"
+ "#define VOLUME_SHADOW\n");
+
+ e_data.volumetric_integration_sh = DRW_shader_create_with_shaderlib(
datatoc_volumetric_vert_glsl,
datatoc_volumetric_geom_glsl,
datatoc_volumetric_integration_frag_glsl,
- e_data.volumetric_common_lib,
+ lib,
USE_VOLUME_OPTI ? "#extension GL_ARB_shader_image_load_store: enable\n"
"#extension GL_ARB_shading_language_420pack: enable\n"
- "#define USE_VOLUME_OPTI\n" :
- NULL);
- e_data.volumetric_resolve_sh = DRW_shader_create_with_lib(datatoc_common_fullscreen_vert_glsl,
- NULL,
- datatoc_volumetric_resolve_frag_glsl,
- e_data.volumetric_common_lib,
- NULL);
- e_data.volumetric_accum_sh = DRW_shader_create_fullscreen(datatoc_volumetric_accum_frag_glsl,
- NULL);
+ "#define USE_VOLUME_OPTI\n" SHADER_DEFINES :
+ SHADER_DEFINES);
+
+ e_data.volumetric_resolve_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_volumetric_resolve_frag_glsl, lib, SHADER_DEFINES);
+ e_data.volumetric_accum_sh = DRW_shader_create_fullscreen_with_shaderlib(
+ datatoc_volumetric_accum_frag_glsl, lib, SHADER_DEFINES);
const float density[4] = {1.0f, 1.0f, 1.0f, 1.0f};
e_data.dummy_density = DRW_texture_create_3d(1, 1, 1, GPU_RGBA8, DRW_TEX_WRAP, density);
@@ -162,7 +149,7 @@ void EEVEE_volumes_set_jitter(EEVEE_ViewLayerData *sldata, uint current_sample)
double ht_point[3];
double ht_offset[3] = {0.0, 0.0};
- uint ht_primes[3] = {3, 7, 2};
+ const uint ht_primes[3] = {3, 7, 2};
BLI_halton_3d(ht_primes, ht_offset, current_sample, ht_point);
@@ -259,17 +246,11 @@ void EEVEE_volumes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
common_data->vol_shadow_steps = 0;
}
- /* Update view_vecs */
- float invproj[4][4], winmat[4][4];
- DRW_view_winmat_get(NULL, winmat, false);
- DRW_view_winmat_get(NULL, invproj, true);
- EEVEE_update_viewvecs(invproj, winmat, sldata->common_data.view_vecs);
-
if (DRW_view_is_persp_get(NULL)) {
float sample_distribution = scene_eval->eevee.volumetric_sample_distribution;
sample_distribution = 4.0f * (max_ff(1.0f - sample_distribution, 1e-2f));
- const float clip_start = common_data->view_vecs[0][2];
+ const float clip_start = DRW_view_near_distance_get(NULL);
/* Negate */
float near = integration_start = min_ff(-integration_start, clip_start - 1e-4f);
float far = integration_end = min_ff(-integration_end, near - 1e-4f);
@@ -280,8 +261,8 @@ void EEVEE_volumes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
common_data->vol_depth_param[2] = sample_distribution;
}
else {
- const float clip_start = common_data->view_vecs[0][2];
- const float clip_end = clip_start + common_data->view_vecs[1][2];
+ const float clip_start = DRW_view_near_distance_get(NULL);
+ const float clip_end = DRW_view_far_distance_get(NULL);
integration_start = min_ff(integration_end, clip_start);
integration_end = max_ff(-integration_end, clip_end);
@@ -298,8 +279,8 @@ void EEVEE_volumes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
common_data->vol_use_lights = (scene_eval->eevee.flag & SCE_EEVEE_VOLUMETRIC_LIGHTS) != 0;
if (!e_data.dummy_scatter) {
- float scatter[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- float transmit[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+ const float scatter[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float transmit[4] = {1.0f, 1.0f, 1.0f, 1.0f};
e_data.dummy_scatter = DRW_texture_create_3d(1, 1, 1, GPU_RGBA8, DRW_TEX_WRAP, scatter);
e_data.dummy_transmit = DRW_texture_create_3d(1, 1, 1, GPU_RGBA8, DRW_TEX_WRAP, transmit);
}
@@ -504,12 +485,7 @@ static bool eevee_volume_object_mesh_init(Scene *scene,
#endif
if (fds->fluid && (fds->type == FLUID_DOMAIN_TYPE_GAS) /* && show_smoke */) {
- if (!(fds->flags & FLUID_DOMAIN_USE_NOISE)) {
- GPU_create_smoke(fmd, 0);
- }
- else if (fds->flags & FLUID_DOMAIN_USE_NOISE) {
- GPU_create_smoke(fmd, 1);
- }
+ DRW_smoke_ensure(fmd, fds->flags & FLUID_DOMAIN_USE_NOISE);
BLI_addtail(&e_data.smoke_domains, BLI_genericNodeN(fmd));
}
@@ -841,16 +817,13 @@ void EEVEE_volumes_free_smoke_textures(void)
/* Free Smoke Textures after rendering */
LISTBASE_FOREACH (LinkData *, link, &e_data.smoke_domains) {
FluidModifierData *fmd = (FluidModifierData *)link->data;
- GPU_free_smoke(fmd);
+ DRW_smoke_free(fmd);
}
BLI_freelistN(&e_data.smoke_domains);
}
void EEVEE_volumes_free(void)
{
- MEM_SAFE_FREE(e_data.volumetric_common_lib);
- MEM_SAFE_FREE(e_data.volumetric_common_lights_lib);
-
DRW_TEXTURE_FREE_SAFE(e_data.dummy_scatter);
DRW_TEXTURE_FREE_SAFE(e_data.dummy_transmit);
@@ -879,7 +852,7 @@ void EEVEE_volumes_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
EEVEE_PassList *psl = vedata->psl;
EEVEE_EffectsInfo *effects = stl->effects;
- float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* Create FrameBuffer. */
diff --git a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
index 57b16418696..2f6f8327f58 100644
--- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
@@ -1,4 +1,7 @@
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+#pragma BLENDER_REQUIRE(raytrace_lib.glsl)
+
/* Based on Practical Realtime Strategies for Accurate Indirect Occlusion
* http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pdf
* http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pptx
@@ -24,12 +27,6 @@
#define MAX_SEARCH_ITER 32
#define MAX_LOD 6.0
-#ifndef UTIL_TEX
-# define UTIL_TEX
-uniform sampler2DArray utilTex;
-# define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
-#endif /* UTIL_TEX */
-
uniform sampler2D horizonBuffer;
/* aoSettings flags */
@@ -243,6 +240,11 @@ float gtao_multibounce(float visibility, vec3 albedo)
return max(x, ((x * a + b) * x + c) * x);
}
+float specular_occlusion(float NV, float AO, float roughness)
+{
+ return saturate(pow(NV + AO, roughness) - 1.0 + AO);
+}
+
/* Use the right occlusion */
float occlusion_compute(vec3 N, vec3 vpos, float user_occlusion, vec4 rand, out vec3 bent_normal)
{
diff --git a/source/blender/draw/engines/eevee/shaders/background_vert.glsl b/source/blender/draw/engines/eevee/shaders/background_vert.glsl
index aff8e0857f6..ab5d9a7ebe4 100644
--- a/source/blender/draw/engines/eevee/shaders/background_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/background_vert.glsl
@@ -1,17 +1,17 @@
-in vec2 pos;
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(surface_lib.glsl)
-out vec3 viewPosition;
+in vec2 pos;
-#ifndef VOLUMETRICS
-/* necessary for compilation*/
-out vec3 worldPosition;
-out vec3 worldNormal;
-out vec3 viewNormal;
-#endif
+RESOURCE_ID_VARYING
void main()
{
+ GPU_INTEL_VERTEX_SHADER_WORKAROUND
+
+ PASS_RESOURCE_ID
+
gl_Position = vec4(pos, 1.0, 1.0);
viewPosition = vec3(pos, -1.0);
@@ -22,6 +22,6 @@ void main()
#endif
#ifdef USE_ATTR
- pass_attr(viewPosition);
+ pass_attr(viewPosition, NormalMatrix, ModelMatrixInverse);
#endif
}
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index a8b8566edec..deedde64194 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -1,487 +1,7 @@
-#define M_PI 3.14159265358979323846 /* pi */
-#define M_2PI 6.28318530717958647692 /* 2*pi */
-#define M_PI_2 1.57079632679489661923 /* pi/2 */
-#define M_1_PI 0.318309886183790671538 /* 1/pi */
-#define M_1_2PI 0.159154943091895335768 /* 1/(2*pi) */
-#define M_1_PI2 0.101321183642337771443 /* 1/(pi^2) */
-#define FLT_MAX 3.402823e+38
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
-#define LUT_SIZE 64
-
-/* Buffers */
-uniform sampler2D colorBuffer;
-uniform sampler2D depthBuffer;
-uniform sampler2D maxzBuffer;
-uniform sampler2D minzBuffer;
-uniform sampler2DArray planarDepth;
-
-#define cameraForward ViewMatrixInverse[2].xyz
-#define cameraPos ViewMatrixInverse[3].xyz
-#define cameraVec \
- ((ProjectionMatrix[3][3] == 0.0) ? normalize(cameraPos - worldPosition) : cameraForward)
-#define viewCameraVec \
- ((ProjectionMatrix[3][3] == 0.0) ? normalize(-viewPosition) : vec3(0.0, 0.0, 1.0))
-
-/* ------- Structures -------- */
-
-/* ------ Lights ----- */
-struct LightData {
- vec4 position_influence; /* w : InfluenceRadius (inversed and squared) */
- vec4 color_spec; /* w : Spec Intensity */
- vec4 spotdata_radius_shadow; /* x : spot size, y : spot blend, z : radius, w: shadow id */
- vec4 rightvec_sizex; /* xyz: Normalized up vector, w: area size X or spot scale X */
- vec4 upvec_sizey; /* xyz: Normalized right vector, w: area size Y or spot scale Y */
- vec4 forwardvec_type; /* xyz: Normalized forward vector, w: Light Type */
-};
-
-/* convenience aliases */
-#define l_color color_spec.rgb
-#define l_spec color_spec.a
-#define l_position position_influence.xyz
-#define l_influence position_influence.w
-#define l_sizex rightvec_sizex.w
-#define l_sizey upvec_sizey.w
-#define l_right rightvec_sizex.xyz
-#define l_up upvec_sizey.xyz
-#define l_forward forwardvec_type.xyz
-#define l_type forwardvec_type.w
-#define l_spot_size spotdata_radius_shadow.x
-#define l_spot_blend spotdata_radius_shadow.y
-#define l_radius spotdata_radius_shadow.z
-#define l_shadowid spotdata_radius_shadow.w
-
-/* ------ Shadows ----- */
-#ifndef MAX_CASCADE_NUM
-# define MAX_CASCADE_NUM 4
-#endif
-
-struct ShadowData {
- vec4 near_far_bias_id;
- vec4 contact_shadow_data;
-};
-
-struct ShadowCubeData {
- mat4 shadowmat;
- vec4 position;
-};
-
-struct ShadowCascadeData {
- mat4 shadowmat[MAX_CASCADE_NUM];
- vec4 split_start_distances;
- vec4 split_end_distances;
- vec4 shadow_vec_id;
-};
-
-/* convenience aliases */
-#define sh_near near_far_bias_id.x
-#define sh_far near_far_bias_id.y
-#define sh_bias near_far_bias_id.z
-#define sh_data_index near_far_bias_id.w
-#define sh_contact_dist contact_shadow_data.x
-#define sh_contact_offset contact_shadow_data.y
-#define sh_contact_spread contact_shadow_data.z
-#define sh_contact_thickness contact_shadow_data.w
-#define sh_shadow_vec shadow_vec_id.xyz
-#define sh_tex_index shadow_vec_id.w
-
-/* ------ Render Passes ----- */
-layout(std140) uniform renderpass_block
-{
- bool renderPassDiffuse;
- bool renderPassDiffuseLight;
- bool renderPassGlossy;
- bool renderPassGlossyLight;
- bool renderPassEmit;
- bool renderPassSSSColor;
- bool renderPassEnvironment;
-};
-
-vec3 render_pass_diffuse_mask(vec3 diffuse_color, vec3 diffuse_light)
-{
- return renderPassDiffuse ? (renderPassDiffuseLight ? diffuse_light : diffuse_color) : vec3(0.0);
-}
-
-vec3 render_pass_sss_mask(vec3 sss_color)
-{
- return renderPassSSSColor ? sss_color : vec3(0.0);
-}
-
-vec3 render_pass_glossy_mask(vec3 specular_color, vec3 specular_light)
-{
- return renderPassGlossy ? (renderPassGlossyLight ? specular_light : specular_color) : vec3(0.0);
-}
-
-vec3 render_pass_emission_mask(vec3 emission_light)
-{
- return renderPassEmit ? emission_light : vec3(0.0);
-}
-
-/* ------- Convenience functions --------- */
-
-vec3 mul(mat3 m, vec3 v)
-{
- return m * v;
-}
-mat3 mul(mat3 m1, mat3 m2)
-{
- return m1 * m2;
-}
-vec3 transform_direction(mat4 m, vec3 v)
-{
- return mat3(m) * v;
-}
-vec3 transform_point(mat4 m, vec3 v)
-{
- return (m * vec4(v, 1.0)).xyz;
-}
-vec3 project_point(mat4 m, vec3 v)
-{
- vec4 tmp = m * vec4(v, 1.0);
- return tmp.xyz / tmp.w;
-}
-
-#define min3(a, b, c) min(a, min(b, c))
-#define min4(a, b, c, d) min(a, min3(b, c, d))
-#define min5(a, b, c, d, e) min(a, min4(b, c, d, e))
-#define min6(a, b, c, d, e, f) min(a, min5(b, c, d, e, f))
-#define min7(a, b, c, d, e, f, g) min(a, min6(b, c, d, e, f, g))
-#define min8(a, b, c, d, e, f, g, h) min(a, min7(b, c, d, e, f, g, h))
-#define min9(a, b, c, d, e, f, g, h, i) min(a, min8(b, c, d, e, f, g, h, i))
-
-#define max3(a, b, c) max(a, max(b, c))
-#define max4(a, b, c, d) max(a, max3(b, c, d))
-#define max5(a, b, c, d, e) max(a, max4(b, c, d, e))
-#define max6(a, b, c, d, e, f) max(a, max5(b, c, d, e, f))
-#define max7(a, b, c, d, e, f, g) max(a, max6(b, c, d, e, f, g))
-#define max8(a, b, c, d, e, f, g, h) max(a, max7(b, c, d, e, f, g, h))
-#define max9(a, b, c, d, e, f, g, h, i) max(a, max8(b, c, d, e, f, g, h, i))
-
-#define avg3(a, b, c) (a + b + c) * (1.0 / 3.0)
-#define avg4(a, b, c, d) (a + b + c + d) * (1.0 / 4.0)
-#define avg5(a, b, c, d, e) (a + b + c + d + e) * (1.0 / 5.0)
-#define avg6(a, b, c, d, e, f) (a + b + c + d + e + f) * (1.0 / 6.0)
-#define avg7(a, b, c, d, e, f, g) (a + b + c + d + e + f + g) * (1.0 / 7.0)
-#define avg8(a, b, c, d, e, f, g, h) (a + b + c + d + e + f + g + h) * (1.0 / 8.0)
-#define avg9(a, b, c, d, e, f, g, h, i) (a + b + c + d + e + f + g + h + i) * (1.0 / 9.0)
-
-float min_v2(vec2 v)
-{
- return min(v.x, v.y);
-}
-float min_v3(vec3 v)
-{
- return min(v.x, min(v.y, v.z));
-}
-float min_v4(vec4 v)
-{
- return min(min(v.x, v.y), min(v.z, v.w));
-}
-float max_v2(vec2 v)
-{
- return max(v.x, v.y);
-}
-float max_v3(vec3 v)
-{
- return max(v.x, max(v.y, v.z));
-}
-float max_v4(vec4 v)
-{
- return max(max(v.x, v.y), max(v.z, v.w));
-}
-
-float sum(vec2 v)
-{
- return dot(vec2(1.0), v);
-}
-float sum(vec3 v)
-{
- return dot(vec3(1.0), v);
-}
-float sum(vec4 v)
-{
- return dot(vec4(1.0), v);
-}
-
-float avg(vec2 v)
-{
- return dot(vec2(1.0 / 2.0), v);
-}
-float avg(vec3 v)
-{
- return dot(vec3(1.0 / 3.0), v);
-}
-float avg(vec4 v)
-{
- return dot(vec4(1.0 / 4.0), v);
-}
-
-float saturate(float a)
-{
- return clamp(a, 0.0, 1.0);
-}
-vec2 saturate(vec2 a)
-{
- return clamp(a, 0.0, 1.0);
-}
-vec3 saturate(vec3 a)
-{
- return clamp(a, 0.0, 1.0);
-}
-vec4 saturate(vec4 a)
-{
- return clamp(a, 0.0, 1.0);
-}
-
-float distance_squared(vec2 a, vec2 b)
-{
- a -= b;
- return dot(a, a);
-}
-float distance_squared(vec3 a, vec3 b)
-{
- a -= b;
- return dot(a, a);
-}
-float len_squared(vec3 a)
-{
- return dot(a, a);
-}
-
-float inverse_distance(vec3 V)
-{
- return max(1 / length(V), 1e-8);
-}
-
-vec2 mip_ratio_interp(float mip)
-{
- float low_mip = floor(mip);
- return mix(mipRatio[int(low_mip)], mipRatio[int(low_mip + 1.0)], mip - low_mip);
-}
-
-/* ------- RNG ------- */
-
-float wang_hash_noise(uint s)
-{
- s = (s ^ 61u) ^ (s >> 16u);
- s *= 9u;
- s = s ^ (s >> 4u);
- s *= 0x27d4eb2du;
- s = s ^ (s >> 15u);
-
- return fract(float(s) / 4294967296.0);
-}
-
-/* ------- Fast Math ------- */
-
-/* [Drobot2014a] Low Level Optimizations for GCN */
-float fast_sqrt(float v)
-{
- return intBitsToFloat(0x1fbd1df5 + (floatBitsToInt(v) >> 1));
-}
-
-vec2 fast_sqrt(vec2 v)
-{
- return intBitsToFloat(0x1fbd1df5 + (floatBitsToInt(v) >> 1));
-}
-
-/* [Eberly2014] GPGPU Programming for Games and Science */
-float fast_acos(float v)
-{
- float res = -0.156583 * abs(v) + M_PI_2;
- res *= fast_sqrt(1.0 - abs(v));
- return (v >= 0) ? res : M_PI - res;
-}
-
-vec2 fast_acos(vec2 v)
-{
- vec2 res = -0.156583 * abs(v) + M_PI_2;
- res *= fast_sqrt(1.0 - abs(v));
- v.x = (v.x >= 0) ? res.x : M_PI - res.x;
- v.y = (v.y >= 0) ? res.y : M_PI - res.y;
- return v;
-}
-
-float point_plane_projection_dist(vec3 lineorigin, vec3 planeorigin, vec3 planenormal)
-{
- return dot(planenormal, planeorigin - lineorigin);
-}
-
-float line_plane_intersect_dist(vec3 lineorigin,
- vec3 linedirection,
- vec3 planeorigin,
- vec3 planenormal)
-{
- return dot(planenormal, planeorigin - lineorigin) / dot(planenormal, linedirection);
-}
-
-float line_plane_intersect_dist(vec3 lineorigin, vec3 linedirection, vec4 plane)
-{
- vec3 plane_co = plane.xyz * (-plane.w / len_squared(plane.xyz));
- vec3 h = lineorigin - plane_co;
- return -dot(plane.xyz, h) / dot(plane.xyz, linedirection);
-}
-
-vec3 line_plane_intersect(vec3 lineorigin, vec3 linedirection, vec3 planeorigin, vec3 planenormal)
-{
- float dist = line_plane_intersect_dist(lineorigin, linedirection, planeorigin, planenormal);
- return lineorigin + linedirection * dist;
-}
-
-vec3 line_plane_intersect(vec3 lineorigin, vec3 linedirection, vec4 plane)
-{
- float dist = line_plane_intersect_dist(lineorigin, linedirection, plane);
- return lineorigin + linedirection * dist;
-}
-
-float line_aligned_plane_intersect_dist(vec3 lineorigin, vec3 linedirection, vec3 planeorigin)
-{
- /* aligned plane normal */
- vec3 L = planeorigin - lineorigin;
- float diskdist = length(L);
- vec3 planenormal = -normalize(L);
- return -diskdist / dot(planenormal, linedirection);
-}
-
-vec3 line_aligned_plane_intersect(vec3 lineorigin, vec3 linedirection, vec3 planeorigin)
-{
- float dist = line_aligned_plane_intersect_dist(lineorigin, linedirection, planeorigin);
- if (dist < 0) {
- /* if intersection is behind we fake the intersection to be
- * really far and (hopefully) not inside the radius of interest */
- dist = 1e16;
- }
- return lineorigin + linedirection * dist;
-}
-
-float line_unit_sphere_intersect_dist(vec3 lineorigin, vec3 linedirection)
-{
- float a = dot(linedirection, linedirection);
- float b = dot(linedirection, lineorigin);
- float c = dot(lineorigin, lineorigin) - 1;
-
- float dist = 1e15;
- float determinant = b * b - a * c;
- if (determinant >= 0) {
- dist = (sqrt(determinant) - b) / a;
- }
-
- return dist;
-}
-
-float line_unit_box_intersect_dist(vec3 lineorigin, vec3 linedirection)
-{
- /* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
- */
- vec3 firstplane = (vec3(1.0) - lineorigin) / linedirection;
- vec3 secondplane = (vec3(-1.0) - lineorigin) / linedirection;
- vec3 furthestplane = max(firstplane, secondplane);
-
- return min_v3(furthestplane);
-}
-
-/* Return texture coordinates to sample Surface LUT */
-vec2 lut_coords(float cosTheta, float roughness)
-{
- float theta = acos(cosTheta);
- vec2 coords = vec2(roughness, theta / M_PI_2);
-
- /* scale and bias coordinates, for correct filtered lookup */
- return coords * (LUT_SIZE - 1.0) / LUT_SIZE + 0.5 / LUT_SIZE;
-}
-
-vec2 lut_coords_ltc(float cosTheta, float roughness)
-{
- vec2 coords = vec2(roughness, sqrt(1.0 - cosTheta));
-
- /* scale and bias coordinates, for correct filtered lookup */
- return coords * (LUT_SIZE - 1.0) / LUT_SIZE + 0.5 / LUT_SIZE;
-}
-
-/* -- Tangent Space conversion -- */
-vec3 tangent_to_world(vec3 vector, vec3 N, vec3 T, vec3 B)
-{
- return T * vector.x + B * vector.y + N * vector.z;
-}
-
-vec3 world_to_tangent(vec3 vector, vec3 N, vec3 T, vec3 B)
-{
- return vec3(dot(T, vector), dot(B, vector), dot(N, vector));
-}
-
-void make_orthonormal_basis(vec3 N, out vec3 T, out vec3 B)
-{
- vec3 UpVector = abs(N.z) < 0.99999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- T = normalize(cross(UpVector, N));
- B = cross(N, T);
-}
-
-/* ---- Opengl Depth conversion ---- */
-
-float linear_depth(bool is_persp, float z, float zf, float zn)
-{
- if (is_persp) {
- return (zn * zf) / (z * (zn - zf) + zf);
- }
- else {
- return (z * 2.0 - 1.0) * zf;
- }
-}
-
-float buffer_depth(bool is_persp, float z, float zf, float zn)
-{
- if (is_persp) {
- return (zf * (zn - z)) / (z * (zn - zf));
- }
- else {
- return (z / (zf * 2.0)) + 0.5;
- }
-}
-
-float get_view_z_from_depth(float depth)
-{
- if (ProjectionMatrix[3][3] == 0.0) {
- float d = 2.0 * depth - 1.0;
- return -ProjectionMatrix[3][2] / (d + ProjectionMatrix[2][2]);
- }
- else {
- return viewVecs[0].z + depth * viewVecs[1].z;
- }
-}
-
-float get_depth_from_view_z(float z)
-{
- if (ProjectionMatrix[3][3] == 0.0) {
- float d = (-ProjectionMatrix[3][2] / z) - ProjectionMatrix[2][2];
- return d * 0.5 + 0.5;
- }
- else {
- return (z - viewVecs[0].z) / viewVecs[1].z;
- }
-}
-
-vec2 get_uvs_from_view(vec3 view)
-{
- vec3 ndc = project_point(ProjectionMatrix, view);
- return ndc.xy * 0.5 + 0.5;
-}
-
-vec3 get_view_space_from_depth(vec2 uvcoords, float depth)
-{
- if (ProjectionMatrix[3][3] == 0.0) {
- return vec3(viewVecs[0].xy + uvcoords * viewVecs[1].xy, 1.0) * get_view_z_from_depth(depth);
- }
- else {
- return viewVecs[0].xyz + vec3(uvcoords, depth) * viewVecs[1].xyz;
- }
-}
-
-vec3 get_world_space_from_depth(vec2 uvcoords, float depth)
-{
- return (ViewMatrixInverse * vec4(get_view_space_from_depth(uvcoords, depth), 1.0)).xyz;
-}
-
-vec3 get_specular_reflection_dominant_dir(vec3 N, vec3 V, float roughness)
+vec3 specular_dominant_dir(vec3 N, vec3 V, float roughness)
{
vec3 R = -reflect(V, N);
float smoothness = 1.0 - roughness;
@@ -489,13 +9,6 @@ vec3 get_specular_reflection_dominant_dir(vec3 N, vec3 V, float roughness)
return normalize(mix(N, R, fac));
}
-float specular_occlusion(float NV, float AO, float roughness)
-{
- return saturate(pow(NV + AO, roughness) - 1.0 + AO);
-}
-
-/* --- Refraction utils --- */
-
float ior_from_f0(float f0)
{
float f = sqrt(f0);
@@ -508,7 +21,7 @@ float f0_from_ior(float eta)
return A * A;
}
-vec3 get_specular_refraction_dominant_dir(vec3 N, vec3 V, float roughness, float ior)
+vec3 refraction_dominant_dir(vec3 N, vec3 V, float roughness, float ior)
{
/* TODO: This a bad approximation. Better approximation should fit
* the refracted vector and roughness into the best prefiltered reflection
@@ -527,128 +40,6 @@ vec3 get_specular_refraction_dominant_dir(vec3 N, vec3 V, float roughness, float
return R;
}
-float get_btdf_lut(sampler2DArray btdf_lut_tex, float NV, float roughness, float ior)
-{
- const vec3 lut_scale_bias_texel_size = vec3((LUT_SIZE - 1.0), 0.5, 1.5) / LUT_SIZE;
-
- vec3 coords;
- /* Try to compensate for the low resolution and interpolation error. */
- coords.x = (ior > 1.0) ? (0.9 + lut_scale_bias_texel_size.z) +
- (0.1 - lut_scale_bias_texel_size.z) * f0_from_ior(ior) :
- (0.9 + lut_scale_bias_texel_size.z) * ior * ior;
- coords.y = 1.0 - saturate(NV);
- coords.xy *= lut_scale_bias_texel_size.x;
- coords.xy += lut_scale_bias_texel_size.y;
-
- const float lut_lvl_ofs = 4.0; /* First texture lvl of roughness. */
- const float lut_lvl_scale = 16.0; /* How many lvl of roughness in the lut. */
-
- float mip = roughness * lut_lvl_scale;
- float mip_floor = floor(mip);
-
- coords.z = lut_lvl_ofs + mip_floor + 1.0;
- float btdf_high = textureLod(btdf_lut_tex, coords, 0.0).r;
-
- coords.z -= 1.0;
- float btdf_low = textureLod(btdf_lut_tex, coords, 0.0).r;
-
- float btdf = (ior == 1.0) ? 1.0 : mix(btdf_low, btdf_high, mip - coords.z);
-
- return btdf;
-}
-
-/* ---- Encode / Decode Normal buffer data ---- */
-/* From http://aras-p.info/texts/CompactNormalStorage.html
- * Using Method #4: Spheremap Transform */
-vec2 normal_encode(vec3 n, vec3 view)
-{
- float p = sqrt(n.z * 8.0 + 8.0);
- return n.xy / p + 0.5;
-}
-
-vec3 normal_decode(vec2 enc, vec3 view)
-{
- vec2 fenc = enc * 4.0 - 2.0;
- float f = dot(fenc, fenc);
- float g = sqrt(1.0 - f / 4.0);
- vec3 n;
- n.xy = fenc * g;
- n.z = 1 - f / 2;
- return n;
-}
-
-/* ---- RGBM (shared multiplier) encoding ---- */
-/* From http://iwasbeingirony.blogspot.fr/2010/06/difference-between-rgbm-and-rgbd.html */
-
-/* Higher RGBM_MAX_RANGE gives imprecision issues in low intensity. */
-#define RGBM_MAX_RANGE 512.0
-
-vec4 rgbm_encode(vec3 rgb)
-{
- float maxRGB = max_v3(rgb);
- float M = maxRGB / RGBM_MAX_RANGE;
- M = ceil(M * 255.0) / 255.0;
- return vec4(rgb / (M * RGBM_MAX_RANGE), M);
-}
-
-vec3 rgbm_decode(vec4 data)
-{
- return data.rgb * (data.a * RGBM_MAX_RANGE);
-}
-
-/* ---- RGBE (shared exponent) encoding ---- */
-vec4 rgbe_encode(vec3 rgb)
-{
- float maxRGB = max_v3(rgb);
- float fexp = ceil(log2(maxRGB));
- return vec4(rgb / exp2(fexp), (fexp + 128.0) / 255.0);
-}
-
-vec3 rgbe_decode(vec4 data)
-{
- float fexp = data.a * 255.0 - 128.0;
- return data.rgb * exp2(fexp);
-}
-
-#if 1
-# define irradiance_encode rgbe_encode
-# define irradiance_decode rgbe_decode
-#else /* No ecoding (when using floating point format) */
-# define irradiance_encode(X) (X).rgbb
-# define irradiance_decode(X) (X).rgb
-#endif
-
-/* Irradiance Visibility Encoding */
-#if 1
-vec4 visibility_encode(vec2 accum, float range)
-{
- accum /= range;
-
- vec4 data;
- data.x = fract(accum.x);
- data.y = floor(accum.x) / 255.0;
- data.z = fract(accum.y);
- data.w = floor(accum.y) / 255.0;
-
- return data;
-}
-
-vec2 visibility_decode(vec4 data, float range)
-{
- return (data.xz + data.yw * 255.0) * range;
-}
-#else /* No ecoding (when using floating point format) */
-vec4 visibility_encode(vec2 accum, float range)
-{
- return accum.xyxy;
-}
-
-vec2 visibility_decode(vec4 data, float range)
-{
- return data.xy;
-}
-#endif
-
/* Fresnel monochromatic, perfect mirror */
float F_eta(float eta, float cos_theta)
{
@@ -766,265 +157,3 @@ float cone_cosine(float r)
/* Jimenez 2016 in Practical Realtime Strategies for Accurate Indirect Occlusion*/
return exp2(-3.32193 * r * r);
}
-
-/* --------- Closure ---------- */
-
-#ifdef VOLUMETRICS
-
-struct Closure {
- vec3 absorption;
- vec3 scatter;
- vec3 emission;
- float anisotropy;
-};
-
-Closure nodetree_exec(void); /* Prototype */
-
-# define CLOSURE_DEFAULT Closure(vec3(0.0), vec3(0.0), vec3(0.0), 0.0)
-
-Closure closure_mix(Closure cl1, Closure cl2, float fac)
-{
- Closure cl;
- cl.absorption = mix(cl1.absorption, cl2.absorption, fac);
- cl.scatter = mix(cl1.scatter, cl2.scatter, fac);
- cl.emission = mix(cl1.emission, cl2.emission, fac);
- cl.anisotropy = mix(cl1.anisotropy, cl2.anisotropy, fac);
- return cl;
-}
-
-Closure closure_add(Closure cl1, Closure cl2)
-{
- Closure cl;
- cl.absorption = cl1.absorption + cl2.absorption;
- cl.scatter = cl1.scatter + cl2.scatter;
- cl.emission = cl1.emission + cl2.emission;
- cl.anisotropy = (cl1.anisotropy + cl2.anisotropy) / 2.0; /* Average phase (no multi lobe) */
- return cl;
-}
-
-Closure closure_emission(vec3 rgb)
-{
- Closure cl = CLOSURE_DEFAULT;
- cl.emission = rgb;
- return cl;
-}
-
-#else /* VOLUMETRICS */
-
-struct Closure {
- vec3 radiance;
- vec3 transmittance;
- float holdout;
-# ifdef USE_SSS
- vec3 sss_irradiance;
- vec3 sss_albedo;
- float sss_radius;
-# endif
- vec4 ssr_data;
- vec2 ssr_normal;
- int flag;
-};
-
-Closure nodetree_exec(void); /* Prototype */
-
-# define FLAG_TEST(flag, val) (((flag) & (val)) != 0)
-
-# define CLOSURE_SSR_FLAG 1
-# define CLOSURE_SSS_FLAG 2
-# define CLOSURE_HOLDOUT_FLAG 4
-
-# ifdef USE_SSS
-# define CLOSURE_DEFAULT \
- Closure(vec3(0.0), vec3(0.0), 0.0, vec3(0.0), vec3(0.0), 0.0, vec4(0.0), vec2(0.0), 0)
-# else
-# define CLOSURE_DEFAULT Closure(vec3(0.0), vec3(0.0), 0.0, vec4(0.0), vec2(0.0), 0)
-# endif
-
-uniform int outputSsrId = 1;
-uniform int outputSssId = 1;
-
-void closure_load_ssr_data(
- vec3 ssr_spec, float roughness, vec3 N, vec3 viewVec, int ssr_id, inout Closure cl)
-{
- /* Still encode to avoid artifacts in the SSR pass. */
- vec3 vN = normalize(mat3(ViewMatrix) * N);
- cl.ssr_normal = normal_encode(vN, viewVec);
-
- if (ssr_id == outputSsrId) {
- cl.ssr_data = vec4(ssr_spec, roughness);
- cl.flag |= CLOSURE_SSR_FLAG;
- }
-}
-
-void closure_load_sss_data(
- float radius, vec3 sss_irradiance, vec3 sss_albedo, int sss_id, inout Closure cl)
-{
-# ifdef USE_SSS
- if (sss_id == outputSssId) {
- cl.sss_irradiance = sss_irradiance;
- cl.sss_radius = radius;
- cl.sss_albedo = sss_albedo;
- cl.flag |= CLOSURE_SSS_FLAG;
- cl.radiance += render_pass_diffuse_mask(sss_albedo, vec3(0));
- }
- else
-# endif
- {
- cl.radiance += render_pass_diffuse_mask(sss_albedo, sss_irradiance * sss_albedo);
- }
-}
-
-Closure closure_mix(Closure cl1, Closure cl2, float fac)
-{
- Closure cl;
- cl.holdout = mix(cl1.holdout, cl2.holdout, fac);
-
- if (FLAG_TEST(cl1.flag, CLOSURE_HOLDOUT_FLAG)) {
- fac = 1.0;
- }
- else if (FLAG_TEST(cl2.flag, CLOSURE_HOLDOUT_FLAG)) {
- fac = 0.0;
- }
-
- cl.transmittance = mix(cl1.transmittance, cl2.transmittance, fac);
- cl.radiance = mix(cl1.radiance, cl2.radiance, fac);
- cl.flag = cl1.flag | cl2.flag;
- cl.ssr_data = mix(cl1.ssr_data, cl2.ssr_data, fac);
- bool use_cl1_ssr = FLAG_TEST(cl1.flag, CLOSURE_SSR_FLAG);
- /* When mixing SSR don't blend roughness and normals but only specular (ssr_data.xyz).*/
- cl.ssr_data.w = (use_cl1_ssr) ? cl1.ssr_data.w : cl2.ssr_data.w;
- cl.ssr_normal = (use_cl1_ssr) ? cl1.ssr_normal : cl2.ssr_normal;
-
-# ifdef USE_SSS
- cl.sss_albedo = mix(cl1.sss_albedo, cl2.sss_albedo, fac);
- bool use_cl1_sss = FLAG_TEST(cl1.flag, CLOSURE_SSS_FLAG);
- /* It also does not make sense to mix SSS radius or irradiance. */
- cl.sss_radius = (use_cl1_sss) ? cl1.sss_radius : cl2.sss_radius;
- cl.sss_irradiance = (use_cl1_sss) ? cl1.sss_irradiance : cl2.sss_irradiance;
-# endif
- return cl;
-}
-
-Closure closure_add(Closure cl1, Closure cl2)
-{
- Closure cl;
- cl.transmittance = cl1.transmittance + cl2.transmittance;
- cl.radiance = cl1.radiance + cl2.radiance;
- cl.holdout = cl1.holdout + cl2.holdout;
- cl.flag = cl1.flag | cl2.flag;
- cl.ssr_data = cl1.ssr_data + cl2.ssr_data;
- bool use_cl1_ssr = FLAG_TEST(cl1.flag, CLOSURE_SSR_FLAG);
- /* When mixing SSR don't blend roughness and normals.*/
- cl.ssr_data.w = (use_cl1_ssr) ? cl1.ssr_data.w : cl2.ssr_data.w;
- cl.ssr_normal = (use_cl1_ssr) ? cl1.ssr_normal : cl2.ssr_normal;
-
-# ifdef USE_SSS
- cl.sss_albedo = cl1.sss_albedo + cl2.sss_albedo;
- bool use_cl1_sss = FLAG_TEST(cl1.flag, CLOSURE_SSS_FLAG);
- /* It also does not make sense to mix SSS radius or irradiance. */
- cl.sss_radius = (use_cl1_sss) ? cl1.sss_radius : cl2.sss_radius;
- cl.sss_irradiance = (use_cl1_sss) ? cl1.sss_irradiance : cl2.sss_irradiance;
-# endif
- return cl;
-}
-
-Closure closure_emission(vec3 rgb)
-{
- Closure cl = CLOSURE_DEFAULT;
- cl.radiance = rgb;
- return cl;
-}
-
-/* Breaking this across multiple lines causes issues for some older GLSL compilers. */
-/* clang-format off */
-# if defined(MESH_SHADER) && !defined(DEPTH_SHADER)
-/* clang-format on */
-# ifndef USE_ALPHA_BLEND
-layout(location = 0) out vec4 outRadiance;
-layout(location = 1) out vec2 ssrNormals;
-layout(location = 2) out vec4 ssrData;
-# ifdef USE_SSS
-layout(location = 3) out vec3 sssIrradiance;
-layout(location = 4) out float sssRadius;
-layout(location = 5) out vec3 sssAlbedo;
-# endif
-# else /* USE_ALPHA_BLEND */
-/* Use dual source blending to be able to make a whole range of effects. */
-layout(location = 0, index = 0) out vec4 outRadiance;
-layout(location = 0, index = 1) out vec4 outTransmittance;
-# endif /* USE_ALPHA_BLEND */
-
-# if defined(USE_ALPHA_BLEND)
-/* Prototype because this file is included before volumetric_lib.glsl */
-void volumetric_resolve(vec2 frag_uvs,
- float frag_depth,
- out vec3 transmittance,
- out vec3 scattering);
-# endif
-
-# define NODETREE_EXEC
-void main()
-{
- Closure cl = nodetree_exec();
-
- float holdout = saturate(1.0 - cl.holdout);
- float transmit = saturate(avg(cl.transmittance));
- float alpha = 1.0 - transmit;
-
-# ifdef USE_ALPHA_BLEND
- vec2 uvs = gl_FragCoord.xy * volCoordScale.zw;
- vec3 vol_transmit, vol_scatter;
- volumetric_resolve(uvs, gl_FragCoord.z, vol_transmit, vol_scatter);
-
- /* Removes part of the volume scattering that have
- * already been added to the destination pixels.
- * Since we do that using the blending pipeline we need to account for material transmittance. */
- vol_scatter -= vol_scatter * cl.transmittance;
-
- cl.radiance = cl.radiance * holdout * vol_transmit + vol_scatter;
- outRadiance = vec4(cl.radiance, alpha * holdout);
- outTransmittance = vec4(cl.transmittance, transmit) * holdout;
-# else
- outRadiance = vec4(cl.radiance, holdout);
- ssrNormals = cl.ssr_normal;
- ssrData = cl.ssr_data;
-# ifdef USE_SSS
- sssIrradiance = cl.sss_irradiance;
- sssRadius = cl.sss_radius;
- sssAlbedo = cl.sss_albedo;
-# endif
-# endif
-
- /* For Probe capture */
-# ifdef USE_SSS
- float fac = float(!sssToggle);
-
- /* TODO(fclem) we shouldn't need this.
- * Just disable USE_SSS when USE_REFRACTION is enabled. */
-# ifdef USE_REFRACTION
- /* SSRefraction pass is done after the SSS pass.
- * In order to not loose the diffuse light totally we
- * need to merge the SSS radiance to the main radiance. */
- fac = 1.0;
-# endif
-
- outRadiance.rgb += cl.sss_irradiance.rgb * cl.sss_albedo.rgb * fac;
-# endif
-
-# ifdef LOOKDEV
- gl_FragDepth = 0.0;
-# endif
-
-# ifndef USE_ALPHA_BLEND
- float alpha_div = 1.0 / max(1e-8, alpha);
- outRadiance.rgb *= alpha_div;
- ssrData.rgb *= alpha_div;
-# ifdef USE_SSS
- sssAlbedo.rgb *= alpha_div;
-# endif
-# endif
-}
-
-# endif /* MESH_SHADER */
-
-#endif /* VOLUMETRICS */
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_lut_frag.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_lut_frag.glsl
index f05b3396428..2b2da884fde 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_lut_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_lut_frag.glsl
@@ -1,3 +1,4 @@
+#pragma BLENDER_REQUIRE(bsdf_sampling_lib.glsl)
out vec4 FragColor;
@@ -5,8 +6,8 @@ void main()
{
vec3 N, T, B, V;
- float NV = (1.0 - (clamp(gl_FragCoord.y / BRDF_LUT_SIZE, 1e-4, 0.9999)));
- float sqrtRoughness = clamp(gl_FragCoord.x / BRDF_LUT_SIZE, 1e-4, 0.9999);
+ float NV = (1.0 - (clamp(gl_FragCoord.y / b, 1e-4, 0.9999)));
+ float sqrtRoughness = clamp(gl_FragCoord.x / LUT_SIZE, 1e-4, 0.9999);
float a = sqrtRoughness * sqrtRoughness;
float a2 = a * a;
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
index 5f2b719095e..066ea58e2bf 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_sampling_lib.glsl
@@ -1,6 +1,7 @@
+#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
+
uniform sampler1D texHammersley;
-uniform sampler2D texJitter;
uniform float sampleCount;
uniform float invSampleCount;
@@ -8,8 +9,7 @@ vec2 jitternoise = vec2(0.0);
#ifndef UTIL_TEX
# define UTIL_TEX
-uniform sampler2DArray utilTex;
-# define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
+
#endif /* UTIL_TEX */
void setup_noise(void)
@@ -17,6 +17,11 @@ void setup_noise(void)
jitternoise = texelfetch_noise_tex(gl_FragCoord.xy).rg; /* Global variable */
}
+vec3 tangent_to_world(vec3 vector, vec3 N, vec3 T, vec3 B)
+{
+ return T * vector.x + B * vector.y + N * vector.z;
+}
+
#ifdef HAMMERSLEY_SIZE
vec3 hammersley_3d(float i, float invsamplenbr)
{
diff --git a/source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl b/source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl
index 1389a9763c0..d815d9d4e6b 100644
--- a/source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl
@@ -1,3 +1,4 @@
+#pragma BLENDER_REQUIRE(bsdf_sampling_lib.glsl)
uniform float a2;
@@ -7,8 +8,8 @@ void main()
{
vec3 N, T, B, V;
- float x = gl_FragCoord.x / BRDF_LUT_SIZE;
- float y = gl_FragCoord.y / BRDF_LUT_SIZE;
+ float x = gl_FragCoord.x / LUT_SIZE;
+ float y = gl_FragCoord.y / LUT_SIZE;
/* There is little variation if ior > 1.0 so we
* maximize LUT precision for ior < 1.0 */
x = x * 1.1;
diff --git a/source/blender/draw/engines/eevee/shaders/closure_lib.glsl b/source/blender/draw/engines/eevee/shaders/closure_lib.glsl
new file mode 100644
index 00000000000..e572245ace9
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/closure_lib.glsl
@@ -0,0 +1,181 @@
+
+#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
+#pragma BLENDER_REQUIRE(renderpass_lib.glsl)
+
+#ifndef VOLUMETRICS
+
+uniform int outputSsrId = 1;
+uniform int outputSssId = 1;
+
+#endif
+
+struct Closure {
+#ifdef VOLUMETRICS
+ vec3 absorption;
+ vec3 scatter;
+ vec3 emission;
+ float anisotropy;
+
+#else /* SURFACE */
+ vec3 radiance;
+ vec3 transmittance;
+ float holdout;
+ vec4 ssr_data;
+ vec2 ssr_normal;
+ int flag;
+# ifdef USE_SSS
+ vec3 sss_irradiance;
+ vec3 sss_albedo;
+ float sss_radius;
+# endif
+
+#endif
+};
+
+/* Prototype */
+Closure nodetree_exec(void);
+
+/* clang-format off */
+/* Avoid multiline defines. */
+#ifdef VOLUMETRICS
+# define CLOSURE_DEFAULT Closure(vec3(0), vec3(0), vec3(0), 0.0)
+#elif !defined(USE_SSS)
+# define CLOSURE_DEFAULT Closure(vec3(0), vec3(0), 0.0, vec4(0), vec2(0), 0)
+#else
+# define CLOSURE_DEFAULT Closure(vec3(0), vec3(0), 0.0, vec4(0), vec2(0), 0, vec3(0), vec3(0), 0.0)
+#endif
+/* clang-format on */
+
+#define FLAG_TEST(flag, val) (((flag) & (val)) != 0)
+
+#define CLOSURE_SSR_FLAG 1
+#define CLOSURE_SSS_FLAG 2
+#define CLOSURE_HOLDOUT_FLAG 4
+
+#ifdef VOLUMETRICS
+Closure closure_mix(Closure cl1, Closure cl2, float fac)
+{
+ Closure cl;
+ cl.absorption = mix(cl1.absorption, cl2.absorption, fac);
+ cl.scatter = mix(cl1.scatter, cl2.scatter, fac);
+ cl.emission = mix(cl1.emission, cl2.emission, fac);
+ cl.anisotropy = mix(cl1.anisotropy, cl2.anisotropy, fac);
+ return cl;
+}
+
+Closure closure_add(Closure cl1, Closure cl2)
+{
+ Closure cl;
+ cl.absorption = cl1.absorption + cl2.absorption;
+ cl.scatter = cl1.scatter + cl2.scatter;
+ cl.emission = cl1.emission + cl2.emission;
+ cl.anisotropy = (cl1.anisotropy + cl2.anisotropy) / 2.0; /* Average phase (no multi lobe) */
+ return cl;
+}
+
+Closure closure_emission(vec3 rgb)
+{
+ Closure cl = CLOSURE_DEFAULT;
+ cl.emission = rgb;
+ return cl;
+}
+
+#else /* SURFACE */
+
+Closure closure_mix(Closure cl1, Closure cl2, float fac)
+{
+ Closure cl;
+ cl.holdout = mix(cl1.holdout, cl2.holdout, fac);
+
+ if (FLAG_TEST(cl1.flag, CLOSURE_HOLDOUT_FLAG)) {
+ fac = 1.0;
+ }
+ else if (FLAG_TEST(cl2.flag, CLOSURE_HOLDOUT_FLAG)) {
+ fac = 0.0;
+ }
+
+ cl.transmittance = mix(cl1.transmittance, cl2.transmittance, fac);
+ cl.radiance = mix(cl1.radiance, cl2.radiance, fac);
+ cl.flag = cl1.flag | cl2.flag;
+ cl.ssr_data = mix(cl1.ssr_data, cl2.ssr_data, fac);
+ bool use_cl1_ssr = FLAG_TEST(cl1.flag, CLOSURE_SSR_FLAG);
+ /* When mixing SSR don't blend roughness and normals but only specular (ssr_data.xyz).*/
+ cl.ssr_data.w = (use_cl1_ssr) ? cl1.ssr_data.w : cl2.ssr_data.w;
+ cl.ssr_normal = (use_cl1_ssr) ? cl1.ssr_normal : cl2.ssr_normal;
+
+# ifdef USE_SSS
+ cl.sss_albedo = mix(cl1.sss_albedo, cl2.sss_albedo, fac);
+ bool use_cl1_sss = FLAG_TEST(cl1.flag, CLOSURE_SSS_FLAG);
+ /* It also does not make sense to mix SSS radius or irradiance. */
+ cl.sss_radius = (use_cl1_sss) ? cl1.sss_radius : cl2.sss_radius;
+ cl.sss_irradiance = (use_cl1_sss) ? cl1.sss_irradiance : cl2.sss_irradiance;
+# endif
+ return cl;
+}
+
+Closure closure_add(Closure cl1, Closure cl2)
+{
+ Closure cl;
+ cl.transmittance = cl1.transmittance + cl2.transmittance;
+ cl.radiance = cl1.radiance + cl2.radiance;
+ cl.holdout = cl1.holdout + cl2.holdout;
+ cl.flag = cl1.flag | cl2.flag;
+ cl.ssr_data = cl1.ssr_data + cl2.ssr_data;
+ bool use_cl1_ssr = FLAG_TEST(cl1.flag, CLOSURE_SSR_FLAG);
+ /* When mixing SSR don't blend roughness and normals.*/
+ cl.ssr_data.w = (use_cl1_ssr) ? cl1.ssr_data.w : cl2.ssr_data.w;
+ cl.ssr_normal = (use_cl1_ssr) ? cl1.ssr_normal : cl2.ssr_normal;
+
+# ifdef USE_SSS
+ cl.sss_albedo = cl1.sss_albedo + cl2.sss_albedo;
+ bool use_cl1_sss = FLAG_TEST(cl1.flag, CLOSURE_SSS_FLAG);
+ /* It also does not make sense to mix SSS radius or irradiance. */
+ cl.sss_radius = (use_cl1_sss) ? cl1.sss_radius : cl2.sss_radius;
+ cl.sss_irradiance = (use_cl1_sss) ? cl1.sss_irradiance : cl2.sss_irradiance;
+# endif
+ return cl;
+}
+
+Closure closure_emission(vec3 rgb)
+{
+ Closure cl = CLOSURE_DEFAULT;
+ cl.radiance = rgb;
+ return cl;
+}
+
+#endif
+
+#ifndef VOLUMETRICS
+
+void closure_load_ssr_data(
+ vec3 ssr_spec, float roughness, vec3 N, vec3 viewVec, int ssr_id, inout Closure cl)
+{
+ /* Still encode to avoid artifacts in the SSR pass. */
+ vec3 vN = normalize(mat3(ViewMatrix) * N);
+ cl.ssr_normal = normal_encode(vN, viewVec);
+
+ if (ssr_id == outputSsrId) {
+ cl.ssr_data = vec4(ssr_spec, roughness);
+ cl.flag |= CLOSURE_SSR_FLAG;
+ }
+}
+
+void closure_load_sss_data(
+ float radius, vec3 sss_irradiance, vec3 sss_albedo, int sss_id, inout Closure cl)
+{
+# ifdef USE_SSS
+ if (sss_id == outputSssId) {
+ cl.sss_irradiance = sss_irradiance;
+ cl.sss_radius = radius;
+ cl.sss_albedo = sss_albedo;
+ cl.flag |= CLOSURE_SSS_FLAG;
+ cl.radiance += render_pass_diffuse_mask(sss_albedo, vec3(0));
+ }
+ else
+# endif
+ {
+ cl.radiance += render_pass_diffuse_mask(sss_albedo, sss_irradiance * sss_albedo);
+ }
+}
+
+#endif
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/closure_lit_lib.glsl
index bc7879763c3..bf33caf9854 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/closure_lit_lib.glsl
@@ -1,32 +1,8 @@
-#ifndef LIT_SURFACE_UNIFORM
-# define LIT_SURFACE_UNIFORM
-
-uniform float refractionDepth;
-
-# ifndef UTIL_TEX
-# define UTIL_TEX
-uniform sampler2DArray utilTex;
-# define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
-# endif /* UTIL_TEX */
-
-in vec3 worldPosition;
-in vec3 viewPosition;
-
-in vec3 worldNormal;
-in vec3 viewNormal;
-
-# ifdef HAIR_SHADER
-in vec3 hairTangent; /* world space */
-in float hairThickTime;
-in float hairThickness;
-in float hairTime;
-flat in int hairStrandID;
-
-uniform int hairThicknessRes = 1;
-# endif
-
-#endif /* LIT_SURFACE_UNIFORM */
+#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
+#pragma BLENDER_REQUIRE(lightprobe_lib.glsl)
+#pragma BLENDER_REQUIRE(ambient_occlusion_lib.glsl)
+#pragma BLENDER_REQUIRE(ssr_lib.glsl)
/**
* AUTO CONFIG
@@ -209,7 +185,7 @@ void CLOSURE_NAME(vec3 N
vec3 V = cameraVec;
- vec4 rand = texelFetch(utilTex, ivec3(ivec2(gl_FragCoord.xy) % LUT_SIZE, 2.0), 0);
+ vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy);
/* ---------------------------------------------------------------- */
/* -------------------- SCENE LIGHTS LIGHTING --------------------- */
@@ -328,11 +304,11 @@ void CLOSURE_NAME(vec3 N
# endif
# ifdef CLOSURE_GLOSSY
- vec3 spec_dir = get_specular_reflection_dominant_dir(N, V, roughnessSquared);
+ vec3 spec_dir = specular_dominant_dir(N, V, roughnessSquared);
# endif
# ifdef CLOSURE_CLEARCOAT
- vec3 C_spec_dir = get_specular_reflection_dominant_dir(C_N, V, C_roughnessSquared);
+ vec3 C_spec_dir = specular_dominant_dir(C_N, V, C_roughnessSquared);
# endif
# ifdef CLOSURE_REFRACTION
@@ -345,7 +321,7 @@ void CLOSURE_NAME(vec3 N
line_plane_intersect(
worldPosition, refr_V, worldPosition - N * refractionDepth, N) :
worldPosition;
- vec3 refr_dir = get_specular_refraction_dominant_dir(N, refr_V, roughness, final_ior);
+ vec3 refr_dir = refraction_dominant_dir(N, refr_V, roughness, final_ior);
# endif
# ifdef CLOSURE_REFRACTION
@@ -485,7 +461,7 @@ void CLOSURE_NAME(vec3 N
# endif
# ifdef CLOSURE_REFRACTION
- float btdf = get_btdf_lut(utilTex, NV, roughness, ior);
+ float btdf = get_btdf_lut(NV, roughness, ior);
out_refr += refr_accum.rgb * btdf;
# endif
diff --git a/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl b/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl
index 759b4098b37..a6c9eebaff2 100644
--- a/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl
@@ -2,7 +2,6 @@
layout(std140) uniform common_block
{
mat4 pastViewProjectionMatrix;
- vec4 viewVecs[2];
vec2 mipRatio[10]; /* To correct mip level texel misalignment */
/* Ambient Occlusion */
vec4 aoParameters[2];
@@ -70,3 +69,9 @@ layout(std140) uniform common_block
#define ssrQuality ssrParameters.x
#define ssrThickness ssrParameters.y
#define ssrPixelSize ssrParameters.zw
+
+vec2 mip_ratio_interp(float mip)
+{
+ float low_mip = floor(mip);
+ return mix(mipRatio[int(low_mip)], mipRatio[int(low_mip + 1.0)], mip - low_mip);
+}
diff --git a/source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl b/source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl
new file mode 100644
index 00000000000..95a585f0d9c
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl
@@ -0,0 +1,65 @@
+
+#pragma BLENDER_REQUIRE(bsdf_common_lib.glsl)
+
+/* ---------------------------------------------------------------------- */
+/** \name Utiltex
+ *
+ * Utiltex is a sampler2DArray that stores a number of useful small utilitary textures and lookup
+ * tables.
+ * \{ */
+
+uniform sampler2DArray utilTex;
+
+#define LUT_SIZE 64
+
+#define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
+
+/* Return texture coordinates to sample Surface LUT */
+vec2 lut_coords(float cosTheta, float roughness)
+{
+ float theta = acos(cosTheta);
+ vec2 coords = vec2(roughness, theta / M_PI_2);
+
+ /* scale and bias coordinates, for correct filtered lookup */
+ return coords * (LUT_SIZE - 1.0) / LUT_SIZE + 0.5 / LUT_SIZE;
+}
+
+vec2 lut_coords_ltc(float cosTheta, float roughness)
+{
+ vec2 coords = vec2(roughness, sqrt(1.0 - cosTheta));
+
+ /* scale and bias coordinates, for correct filtered lookup */
+ return coords * (LUT_SIZE - 1.0) / LUT_SIZE + 0.5 / LUT_SIZE;
+}
+
+float get_btdf_lut(float NV, float roughness, float ior)
+{
+ const vec3 lut_scale_bias_texel_size = vec3((LUT_SIZE - 1.0), 0.5, 1.5) / LUT_SIZE;
+
+ vec3 coords;
+ /* Try to compensate for the low resolution and interpolation error. */
+ coords.x = (ior > 1.0) ? (0.9 + lut_scale_bias_texel_size.z) +
+ (0.1 - lut_scale_bias_texel_size.z) * f0_from_ior(ior) :
+ (0.9 + lut_scale_bias_texel_size.z) * ior * ior;
+ coords.y = 1.0 - saturate(NV);
+ coords.xy *= lut_scale_bias_texel_size.x;
+ coords.xy += lut_scale_bias_texel_size.y;
+
+ const float lut_lvl_ofs = 4.0; /* First texture lvl of roughness. */
+ const float lut_lvl_scale = 16.0; /* How many lvl of roughness in the lut. */
+
+ float mip = roughness * lut_lvl_scale;
+ float mip_floor = floor(mip);
+
+ coords.z = lut_lvl_ofs + mip_floor + 1.0;
+ float btdf_high = textureLod(utilTex, coords, 0.0).r;
+
+ coords.z -= 1.0;
+ float btdf_low = textureLod(utilTex, coords, 0.0).r;
+
+ float btdf = (ior == 1.0) ? 1.0 : mix(btdf_low, btdf_high, mip - coords.z);
+
+ return btdf;
+}
+
+/** \} */
diff --git a/source/blender/draw/engines/eevee/shaders/default_frag.glsl b/source/blender/draw/engines/eevee/shaders/default_frag.glsl
deleted file mode 100644
index 1014b25033a..00000000000
--- a/source/blender/draw/engines/eevee/shaders/default_frag.glsl
+++ /dev/null
@@ -1,51 +0,0 @@
-
-uniform vec3 basecol;
-uniform float metallic;
-uniform float specular;
-uniform float roughness;
-
-Closure nodetree_exec(void)
-{
-#ifdef HAIR_SHADER
- vec3 B = normalize(cross(worldNormal, hairTangent));
- float cos_theta;
- if (hairThicknessRes == 1) {
- vec4 rand = texelFetch(utilTex, ivec3(ivec2(gl_FragCoord.xy) % LUT_SIZE, 2.0), 0);
- /* Random cosine normal distribution on the hair surface. */
- cos_theta = rand.x * 2.0 - 1.0;
- }
- else {
- /* Shade as a cylinder. */
- cos_theta = hairThickTime / hairThickness;
- }
- float sin_theta = sqrt(max(0.0, 1.0f - cos_theta * cos_theta));
- vec3 N = normalize(worldNormal * sin_theta + B * cos_theta);
- vec3 vN = mat3(ViewMatrix) * N;
-#else
- vec3 N = normalize(gl_FrontFacing ? worldNormal : -worldNormal);
- vec3 vN = normalize(gl_FrontFacing ? viewNormal : -viewNormal);
-#endif
-
- vec3 dielectric = vec3(0.034) * specular * 2.0;
- vec3 albedo = mix(basecol, vec3(0.0), metallic);
- vec3 f0 = mix(dielectric, basecol, metallic);
- vec3 f90 = mix(vec3(1.0), f0, (1.0 - specular) * metallic);
- vec3 out_diff, out_spec, ssr_spec;
- eevee_closure_default(N, albedo, f0, f90, 1, roughness, 1.0, true, out_diff, out_spec, ssr_spec);
-
- Closure cl = CLOSURE_DEFAULT;
- cl.radiance = render_pass_glossy_mask(vec3(1.0), out_spec) +
- render_pass_diffuse_mask(albedo, out_diff * albedo);
- closure_load_ssr_data(ssr_spec, roughness, N, viewCameraVec, 1, cl);
-
-#ifdef LOOKDEV
- gl_FragDepth = 0.0;
-#endif
-
-#ifdef HOLDOUT
- cl = CLOSURE_DEFAULT;
- cl.holdout = 1.0;
-#endif
-
- return cl;
-}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
index d56890769a7..9c1ca17f87c 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
@@ -1,4 +1,8 @@
+
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+
uniform sampler2D colorBuffer;
uniform sampler2D depthBuffer;
@@ -18,9 +22,6 @@ uniform vec4 bokehParams[2];
uniform vec2 nearFar; /* Near & far view depths values */
-#define M_PI 3.1415926535897932384626433832795
-#define M_2PI 6.2831853071795864769252868
-
/* -------------- Utils ------------- */
/* divide by sensor size to get the normalized size */
@@ -34,11 +35,6 @@ uniform vec2 nearFar; /* Near & far view depths values */
#define weighted_sum(a, b, c, d, e) \
(a * e.x + b * e.y + c * e.z + d * e.w) / max(1e-6, dot(e, vec4(1.0)));
-float max_v4(vec4 v)
-{
- return max(max(v.x, v.y), max(v.z, v.w));
-}
-
vec4 safe_color(vec4 c)
{
/* Clamp to avoid black square artifacts if a pixel goes NaN. */
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
index d83b410125a..6e35d4a54ae 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
@@ -1,4 +1,6 @@
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+
uniform vec4 bokehParams[2];
#define bokeh_rotation bokehParams[0].x
@@ -15,8 +17,6 @@ flat out float smoothFac;
flat out ivec2 edge;
out vec2 particlecoord;
-#define M_PI 3.1415926535897932384626433832795
-
/* Scatter pass, calculate a triangle covering the CoC. */
void main()
{
diff --git a/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl
index eea0ce0aae2..47fe21928b3 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl
@@ -1,14 +1,34 @@
+
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
+#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
+#pragma BLENDER_REQUIRE(ambient_occlusion_lib.glsl)
+
/**
* This shader only compute maximum horizon angles for each directions.
* The final integration is done at the resolve stage with the shading normal.
*/
-uniform float rotationOffset;
-
out vec4 FragColor;
-#ifdef DEBUG_AO
uniform sampler2D normalBuffer;
+#ifdef LAYERED_DEPTH
+uniform sampler2DArray depthBufferLayered;
+uniform int layer;
+# define gtao_depthBuffer depthBufferLayered
+# define gtao_textureLod(a, b, c) textureLod(a, vec3(b, layer), c)
+
+#else
+uniform sampler2D depthBuffer;
+# define gtao_depthBuffer depthBuffer
+# define gtao_textureLod(a, b, c) textureLod(a, b, c)
+
+#endif
+
+uniform float rotationOffset;
+
+#ifdef DEBUG_AO
void main()
{
@@ -34,18 +54,6 @@ void main()
#else
-# ifdef LAYERED_DEPTH
-uniform sampler2DArray depthBufferLayered;
-uniform int layer;
-# define gtao_depthBuffer depthBufferLayered
-# define gtao_textureLod(a, b, c) textureLod(a, vec3(b, layer), c)
-
-# else
-# define gtao_depthBuffer depthBuffer
-# define gtao_textureLod(a, b, c) textureLod(a, b, c)
-
-# endif
-
void main()
{
vec2 uvs = saturate(gl_FragCoord.xy / vec2(textureSize(gtao_depthBuffer, 0).xy));
diff --git a/source/blender/draw/engines/eevee/shaders/effect_mist_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_mist_frag.glsl
index edee55a07e0..7331f92ba6d 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_mist_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_mist_frag.glsl
@@ -1,5 +1,10 @@
+
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+
/* Convert depth to Mist factor */
uniform vec3 mistSettings;
+uniform sampler2D depthBuffer;
#define mistStart mistSettings.x
#define mistInvDistance mistSettings.y
diff --git a/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
index fbf507a2e40..3501a4448c5 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
@@ -1,4 +1,6 @@
+#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
+
/*
* Based on:
* A Fast and Stable Feature-Aware Motion Blur Filter
@@ -15,11 +17,6 @@ uniform sampler2D tileMaxBuffer;
#define KERNEL 8
-/* TODO(fclem) deduplicate this code. */
-uniform sampler2DArray utilTex;
-#define LUT_SIZE 64
-#define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
-
uniform float depthScale;
uniform ivec2 tileBufferSize;
uniform vec2 viewportSize;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
index 598cc3e5183..f8dccb7511a 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
@@ -1,4 +1,11 @@
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
+#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
+#pragma BLENDER_REQUIRE(raytrace_lib.glsl)
+#pragma BLENDER_REQUIRE(lightprobe_lib.glsl)
+#pragma BLENDER_REQUIRE(ssr_lib.glsl)
+
/* Based on Stochastic Screen Space Reflections
* https://www.ea.com/frostbite/news/stochastic-screen-space-reflections */
@@ -131,7 +138,7 @@ void main()
return;
}
- vec4 rand = texelFetch(utilTex, ivec3(halfres_texel % LUT_SIZE, 2), 0);
+ vec4 rand = texelfetch_noise_tex(halfres_texel);
/* Gives *perfect* reflection for very small roughness */
if (roughness < 0.04) {
diff --git a/source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl
index e9da49c9eb9..2a53a4f119f 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl
@@ -1,4 +1,9 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
+#pragma BLENDER_REQUIRE(common_uniforms_lib.glsl)
+
/* Based on Separable SSS. by Jorge Jimenez and Diego Gutierrez */
#define MAX_SSS_SAMPLES 65
@@ -14,36 +19,16 @@ uniform sampler2D sssIrradiance;
uniform sampler2D sssRadius;
uniform sampler2D sssAlbedo;
-#ifndef UTIL_TEX
-# define UTIL_TEX
-uniform sampler2DArray utilTex;
-# define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
-#endif /* UTIL_TEX */
-
layout(location = 0) out vec4 sssRadiance;
-float get_view_z_from_depth(float depth)
-{
- if (ProjectionMatrix[3][3] == 0.0) {
- float d = 2.0 * depth - 1.0;
- return -ProjectionMatrix[3][2] / (d + ProjectionMatrix[2][2]);
- }
- else {
- return viewVecs[0].z + depth * viewVecs[1].z;
- }
-}
-
-#define LUT_SIZE 64
-#define M_PI_2 1.5707963267948966 /* pi/2 */
-#define M_2PI 6.2831853071795865 /* 2*pi */
-
void main(void)
{
vec2 pixel_size = 1.0 / vec2(textureSize(depthBuffer, 0).xy); /* TODO precompute */
vec2 uvs = gl_FragCoord.xy * pixel_size;
vec3 sss_irradiance = texture(sssIrradiance, uvs).rgb;
float sss_radius = texture(sssRadius, uvs).r;
- float depth_view = get_view_z_from_depth(texture(depthBuffer, uvs).r);
+ float depth = texture(depthBuffer, uvs).r;
+ float depth_view = get_view_z_from_depth(depth);
float rand = texelfetch_noise_tex(gl_FragCoord.xy).r;
#ifdef FIRST_PASS
diff --git a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
index b44645174bd..28947e971d2 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
@@ -1,5 +1,11 @@
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+
+uniform sampler2D colorBuffer;
+uniform sampler2D depthBuffer;
uniform sampler2D colorHistoryBuffer;
+
uniform mat4 prevViewProjectionMatrix;
out vec4 FragColor;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
index 6531ceb8dbe..c85eff92e37 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
@@ -1,11 +1,16 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
+#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
+#pragma BLENDER_REQUIRE(lights_lib.glsl)
+
in vec4 uvcoordsvar;
out vec4 FragColor;
+uniform sampler2D depthBuffer;
uniform sampler1D sssTexProfile;
uniform sampler2D sssRadius;
-
uniform sampler2DArray sssShadowCubes;
uniform sampler2DArray sssShadowCascades;
@@ -27,12 +32,6 @@ vec3 sss_profile(float s)
return texture(sssTexProfile, saturate(s) * SSS_LUT_SCALE + SSS_LUT_BIAS).rgb;
}
-#ifndef UTIL_TEX
-# define UTIL_TEX
-uniform sampler2DArray utilTex;
-# define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
-#endif /* UTIL_TEX */
-
float light_translucent_power_with_falloff(LightData ld, vec3 N, vec4 l_vector)
{
float power, falloff;
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 d927fd78d30..145939cefb2 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
@@ -1,4 +1,8 @@
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+
+uniform sampler2D depthBuffer;
+
uniform mat4 prevViewProjMatrix;
uniform mat4 currViewProjMatrixInv;
uniform mat4 nextViewProjMatrix;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_velocity_tile_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_velocity_tile_frag.glsl
index 0eb598521af..f52acaf6f7f 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_velocity_tile_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_velocity_tile_frag.glsl
@@ -148,4 +148,4 @@ void main()
tileMaxVelocity = encode_velocity(max_motion);
}
-#endif \ No newline at end of file
+#endif
diff --git a/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl b/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl
index 64ea87001f4..2274bf8b950 100644
--- a/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl
@@ -1,18 +1,71 @@
-uniform sampler2DArray irradianceGrid;
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+#pragma BLENDER_REQUIRE(common_uniforms_lib.glsl)
+#pragma BLENDER_REQUIRE(octahedron_lib.glsl)
#define IRRADIANCE_LIB
+/* ---------------------------------------------------------------------- */
+/** \name Structure
+ * \{ */
+
#if defined(IRRADIANCE_SH_L2)
struct IrradianceData {
vec3 shcoefs[9];
};
+
#else /* defined(IRRADIANCE_HL2) */
struct IrradianceData {
vec3 cubesides[3];
};
+
#endif
+/** \} */
+
+/* ---------------------------------------------------------------------- */
+/** \name Resources
+ * \{ */
+
+uniform sampler2DArray irradianceGrid;
+
+/** \} */
+
+/* ---------------------------------------------------------------------- */
+/** \name Functions
+ * \{ */
+
+vec4 irradiance_encode(vec3 rgb)
+{
+ float maxRGB = max_v3(rgb);
+ float fexp = ceil(log2(maxRGB));
+ return vec4(rgb / exp2(fexp), (fexp + 128.0) / 255.0);
+}
+
+vec3 irradiance_decode(vec4 data)
+{
+ float fexp = data.a * 255.0 - 128.0;
+ return data.rgb * exp2(fexp);
+}
+
+vec4 visibility_encode(vec2 accum, float range)
+{
+ accum /= range;
+
+ vec4 data;
+ data.x = fract(accum.x);
+ data.y = floor(accum.x) / 255.0;
+ data.z = fract(accum.y);
+ data.w = floor(accum.y) / 255.0;
+
+ return data;
+}
+
+vec2 visibility_decode(vec4 data, float range)
+{
+ return (data.xz + data.yw * 255.0) * range;
+}
+
IrradianceData load_irradiance_cell(int cell, vec3 N)
{
/* Keep in sync with diffuse_filter_probe() */
@@ -155,3 +208,5 @@ vec3 irradiance_from_cell_get(int cell, vec3 ir_dir)
IrradianceData ir_data = load_irradiance_cell(cell, ir_dir);
return compute_irradiance(ir_dir, ir_data);
}
+
+/** \} */
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl
index 96fe94fc41e..b0da4274a13 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_frag.glsl
@@ -1,4 +1,7 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(lightprobe_lib.glsl)
+
flat in int pid;
in vec2 quadCoord;
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
index db780714091..d06ad553ca4 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
@@ -1,4 +1,6 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+
/* XXX TODO fix code duplication */
struct CubeData {
vec4 position_type;
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl
index b485511318b..bf45169ebaa 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl
@@ -1,4 +1,8 @@
+#pragma BLENDER_REQUIRE(bsdf_sampling_lib.glsl)
+#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
+#pragma BLENDER_REQUIRE(irradiance_lib.glsl)
+
uniform samplerCube probeHdr;
uniform int probeSize;
uniform float lodFactor;
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
index 00eb3c7e200..ccb77427ed2 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
@@ -1,4 +1,7 @@
+#pragma BLENDER_REQUIRE(bsdf_sampling_lib.glsl)
+#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
+
uniform samplerCube probeHdr;
uniform float roughnessSquared;
uniform float texelSize;
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl
index 5d8af21032a..8d7c58a93d5 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl
@@ -1,4 +1,8 @@
+#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
+#pragma BLENDER_REQUIRE(bsdf_sampling_lib.glsl)
+#pragma BLENDER_REQUIRE(irradiance_lib.glsl)
+
uniform samplerCube probeDepth;
uniform int outputSize;
uniform float lodFactor;
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_geom.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_geom.glsl
index f8bc1703c66..009ccf6535e 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_geom.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_geom.glsl
@@ -40,9 +40,6 @@ void main()
for (int v = 0; v < 3; v++) {
gl_Position = vPos[v];
worldPosition = x_axis[fFace] * vPos[v].x + y_axis[fFace] * vPos[v].y + maj_axes[fFace];
-#ifdef USE_ATTR
- pass_attr(v);
-#endif
EmitVertex();
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl
index f9bcc718a1e..dc5ec1e40f5 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_frag.glsl
@@ -1,3 +1,5 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(irradiance_lib.glsl)
flat in int cellOffset;
in vec2 quadCoord;
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
index 4e500db827e..6fefe1319bd 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
@@ -1,4 +1,6 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+
uniform float sphere_size;
uniform int offset;
uniform ivec3 grid_resolution;
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
index 6c6db88139b..a2e25b83532 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
@@ -1,3 +1,12 @@
+
+#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
+#pragma BLENDER_REQUIRE(common_uniforms_lib.glsl)
+#pragma BLENDER_REQUIRE(cubemap_lib.glsl)
+#pragma BLENDER_REQUIRE(ambient_occlusion_lib.glsl)
+#pragma BLENDER_REQUIRE(irradiance_lib.glsl)
+
/* ----------- Uniforms --------- */
uniform sampler2DArray probePlanars;
@@ -73,12 +82,6 @@ struct GridData {
# define MAX_PLANAR 1
#endif
-#ifndef UTIL_TEX
-# define UTIL_TEX
-uniform sampler2DArray utilTex;
-# define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
-#endif /* UTIL_TEX */
-
layout(std140) uniform probe_block
{
CubeData probes_data[MAX_PROBE];
@@ -218,7 +221,7 @@ void fallback_cubemap(vec3 N,
inout vec4 spec_accum)
{
/* Specular probes */
- vec3 spec_dir = get_specular_reflection_dominant_dir(N, V, roughnessSquared);
+ vec3 spec_dir = specular_dominant_dir(N, V, roughnessSquared);
#ifdef SSR_AO
vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy);
@@ -246,7 +249,6 @@ void fallback_cubemap(vec3 N,
}
}
-#ifdef IRRADIANCE_LIB
vec3 probe_evaluate_grid(GridData gd, vec3 W, vec3 N, vec3 localpos)
{
localpos = localpos * 0.5 + 0.5;
@@ -308,5 +310,3 @@ vec3 probe_evaluate_world_diff(vec3 N)
{
return irradiance_from_cell_get(0, N);
}
-
-#endif /* IRRADIANCE_LIB */
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl
index 2807488db6c..0a53abcb04a 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl
@@ -1,4 +1,6 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+
uniform sampler2DArray probePlanars;
in vec3 worldPosition;
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl
index 65506e5c7b1..6759c060259 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl
@@ -1,4 +1,6 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+
in vec3 pos;
in int probe_id;
diff --git a/source/blender/draw/engines/eevee/shaders/lights_lib.glsl b/source/blender/draw/engines/eevee/shaders/lights_lib.glsl
index 3b9d0a8f2bc..949e4d8f04f 100644
--- a/source/blender/draw/engines/eevee/shaders/lights_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lights_lib.glsl
@@ -1,8 +1,76 @@
-uniform sampler2DArrayShadow shadowCubeTexture;
-uniform sampler2DArrayShadow shadowCascadeTexture;
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
+#pragma BLENDER_REQUIRE(raytrace_lib.glsl)
+#pragma BLENDER_REQUIRE(ltc_lib.glsl)
+
+#ifndef MAX_CASCADE_NUM
+# define MAX_CASCADE_NUM 4
+#endif
+
+/* ---------------------------------------------------------------------- */
+/** \name Structure
+ * \{ */
+
+struct LightData {
+ vec4 position_influence; /* w : InfluenceRadius (inversed and squared) */
+ vec4 color_spec; /* w : Spec Intensity */
+ vec4 spotdata_radius_shadow; /* x : spot size, y : spot blend, z : radius, w: shadow id */
+ vec4 rightvec_sizex; /* xyz: Normalized up vector, w: area size X or spot scale X */
+ vec4 upvec_sizey; /* xyz: Normalized right vector, w: area size Y or spot scale Y */
+ vec4 forwardvec_type; /* xyz: Normalized forward vector, w: Light Type */
+};
+
+/* convenience aliases */
+#define l_color color_spec.rgb
+#define l_spec color_spec.a
+#define l_position position_influence.xyz
+#define l_influence position_influence.w
+#define l_sizex rightvec_sizex.w
+#define l_sizey upvec_sizey.w
+#define l_right rightvec_sizex.xyz
+#define l_up upvec_sizey.xyz
+#define l_forward forwardvec_type.xyz
+#define l_type forwardvec_type.w
+#define l_spot_size spotdata_radius_shadow.x
+#define l_spot_blend spotdata_radius_shadow.y
+#define l_radius spotdata_radius_shadow.z
+#define l_shadowid spotdata_radius_shadow.w
+
+struct ShadowData {
+ vec4 near_far_bias_id;
+ vec4 contact_shadow_data;
+};
+
+struct ShadowCubeData {
+ mat4 shadowmat;
+ vec4 position;
+};
+
+struct ShadowCascadeData {
+ mat4 shadowmat[MAX_CASCADE_NUM];
+ vec4 split_start_distances;
+ vec4 split_end_distances;
+ vec4 shadow_vec_id;
+};
+
+/* convenience aliases */
+#define sh_near near_far_bias_id.x
+#define sh_far near_far_bias_id.y
+#define sh_bias near_far_bias_id.z
+#define sh_data_index near_far_bias_id.w
+#define sh_contact_dist contact_shadow_data.x
+#define sh_contact_offset contact_shadow_data.y
+#define sh_contact_spread contact_shadow_data.z
+#define sh_contact_thickness contact_shadow_data.w
+#define sh_shadow_vec shadow_vec_id.xyz
+#define sh_tex_index shadow_vec_id.w
+
+/** \} */
-#define LAMPS_LIB
+/* ---------------------------------------------------------------------- */
+/** \name Resources
+ * \{ */
layout(std140) uniform shadow_block
{
@@ -16,6 +84,15 @@ layout(std140) uniform light_block
LightData lights_data[MAX_LIGHT];
};
+uniform sampler2DArrayShadow shadowCubeTexture;
+uniform sampler2DArrayShadow shadowCascadeTexture;
+
+/** \} */
+
+/* ---------------------------------------------------------------------- */
+/** \name Shadow Functions
+ * \{ */
+
/* type */
#define POINT 0.0
#define SUN 1.0
@@ -133,9 +210,11 @@ float sample_cascade_shadow(int shadow_id, vec3 W)
#undef scube
#undef scsmd
-/* ----------------------------------------------------------- */
-/* --------------------- Light Functions --------------------- */
-/* ----------------------------------------------------------- */
+/** \} */
+
+/* ---------------------------------------------------------------------- */
+/** \name Light Functions
+ * \{ */
/* From Frostbite PBR Course
* Distance based attenuation
@@ -258,7 +337,6 @@ float light_visibility(LightData ld,
l_atten);
}
-#ifdef USE_LTC
float light_diffuse(LightData ld, vec3 N, vec3 V, vec4 l_vector)
{
if (ld.l_type == AREA_RECT) {
@@ -321,4 +399,5 @@ float light_specular(LightData ld, vec4 ltc_mat, vec3 N, vec3 V, vec4 l_vector)
return ltc_evaluate_disk(N, V, ltc_matrix(ltc_mat), points);
}
}
-#endif
+
+/** \} */
diff --git a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl b/source/blender/draw/engines/eevee/shaders/lookdev_world_frag.glsl
index 8c876cf582c..9077b414026 100644
--- a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lookdev_world_frag.glsl
@@ -1,20 +1,17 @@
-uniform float backgroundAlpha;
-uniform vec3 color;
-
-out vec4 FragColor;
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(lightprobe_lib.glsl)
+#pragma BLENDER_REQUIRE(surface_lib.glsl)
-#if defined(LOOKDEV_BG) || defined(LOOKDEV)
+uniform sampler2D studioLight;
+uniform float backgroundAlpha;
uniform mat3 StudioLightMatrix;
-uniform sampler2D image;
uniform float studioLightIntensity = 1.0;
uniform float studioLightBlur = 0.0;
-in vec3 viewPosition;
-# ifndef M_PI
-# define M_PI 3.14159265358979323846
-# endif
+out vec4 FragColor;
vec3 background_transform_to_world(vec3 viewvec)
{
@@ -35,36 +32,20 @@ vec4 node_tex_environment_equirectangular(vec3 co, sampler2D ima)
vec3 nco = normalize(co);
float u = -atan(nco.y, nco.x) / (2.0 * M_PI) + 0.5;
float v = atan(nco.z, hypot(nco.x, nco.y)) / M_PI + 0.5;
-
- /* Fix pole bleeding */
- float width = float(textureSize(ima, 0).x);
- float texel_width = 1.0 / width;
- v = clamp(v, texel_width, 1.0 - texel_width);
-
- /* Fix u = 0 seam */
- /* This is caused by texture filtering, since uv don't have smooth derivatives
- * at u = 0 or 2PI, hardware filtering is using the smallest mipmap for certain
- * texels. So we force the highest mipmap and don't do anisotropic filtering. */
return textureLod(ima, vec2(u, v), 0.0);
}
-#endif
void main()
{
- vec3 background_color;
+ vec3 worldvec = background_transform_to_world(viewPosition);
+ vec3 background_color;
#if defined(LOOKDEV_BG)
- vec3 worldvec = background_transform_to_world(viewPosition);
background_color = probe_evaluate_world_spec(worldvec, studioLightBlur).rgb;
- background_color *= studioLightIntensity;
-
-#elif defined(LOOKDEV)
- vec3 worldvec = background_transform_to_world(viewPosition);
- background_color = node_tex_environment_equirectangular(StudioLightMatrix * worldvec, image).rgb;
- background_color *= studioLightIntensity;
-
#else
- background_color = color;
+ worldvec = StudioLightMatrix * worldvec;
+ background_color = node_tex_environment_equirectangular(worldvec, studioLight).rgb;
+ background_color *= studioLightIntensity;
#endif
FragColor = vec4(clamp(background_color, vec3(0.0), vec3(1e10)), 1.0) * backgroundAlpha;
diff --git a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
index dbfc7ad5a71..2750d42a74a 100644
--- a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
@@ -8,12 +8,6 @@
#define USE_LTC
-#ifndef UTIL_TEX
-# define UTIL_TEX
-uniform sampler2DArray utilTex;
-# define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
-#endif /* UTIL_TEX */
-
/* Diffuse *clipped* sphere integral. */
float diffuse_sphere_integral(float avg_dir_z, float form_factor)
{
diff --git a/source/blender/draw/engines/eevee/shaders/object_motion_vert.glsl b/source/blender/draw/engines/eevee/shaders/object_motion_vert.glsl
index 95cd69ba310..ef96bcbaedb 100644
--- a/source/blender/draw/engines/eevee/shaders/object_motion_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/object_motion_vert.glsl
@@ -1,4 +1,7 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(common_hair_lib.glsl)
+
uniform mat4 currModelMatrix;
uniform mat4 prevModelMatrix;
uniform mat4 nextModelMatrix;
@@ -19,6 +22,8 @@ out vec3 nextWorldPos;
void main()
{
+ GPU_INTEL_VERTEX_SHADER_WORKAROUND
+
#ifdef HAIR
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
float time, thick_time, thickness;
diff --git a/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl b/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl
index 9acd8f998f6..34999076f9c 100644
--- a/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl
@@ -1,4 +1,14 @@
+/* Required by some nodes. */
+#pragma BLENDER_REQUIRE(common_hair_lib.glsl)
+#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
+
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(common_uniforms_lib.glsl)
+#pragma BLENDER_REQUIRE(closure_lib.glsl)
+#pragma BLENDER_REQUIRE(closure_lit_lib.glsl)
+#pragma BLENDER_REQUIRE(surface_lib.glsl)
+
#ifdef USE_ALPHA_HASH
/* From the paper "Hashed Alpha Testing" by Chris Wyman and Morgan McGuire */
@@ -56,8 +66,6 @@ float hashed_alpha_threshold(vec3 co)
#endif
-#define NODETREE_EXEC
-
void main()
{
#if defined(USE_ALPHA_HASH)
@@ -66,11 +74,9 @@ void main()
float opacity = saturate(1.0 - avg(cl.transmittance));
-# if defined(USE_ALPHA_HASH)
/* Hashed Alpha Testing */
if (opacity < hashed_alpha_threshold(worldPosition)) {
discard;
}
-# endif
#endif
}
diff --git a/source/blender/draw/engines/eevee/shaders/prepass_vert.glsl b/source/blender/draw/engines/eevee/shaders/prepass_vert.glsl
index 2c7e0aca3fb..f650e2eeb8c 100644
--- a/source/blender/draw/engines/eevee/shaders/prepass_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/prepass_vert.glsl
@@ -1,16 +1,14 @@
+#pragma BLENDER_REQUIRE(common_hair_lib.glsl)
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+
#ifndef HAIR_SHADER
in vec3 pos;
#endif
void main()
{
-#ifdef GPU_INTEL
- /* Due to some shader compiler bug, we somewhat
- * need to access gl_VertexID to make it work. even
- * if it's actually dead code. */
- gl_Position.x = float(gl_VertexID);
-#endif
+ GPU_INTEL_VERTEX_SHADER_WORKAROUND
#ifdef HAIR_SHADER
float time, thick_time, thickness;
@@ -34,5 +32,4 @@ void main()
#ifdef CLIP_PLANES
gl_ClipDistance[0] = dot(vec4(worldPosition.xyz, 1.0), clipPlanes[0]);
#endif
- /* TODO motion vectors */
}
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
index f88cfdf3787..39db39f8756 100644
--- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -1,3 +1,11 @@
+
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+#pragma BLENDER_REQUIRE(common_uniforms_lib.glsl)
+
+uniform sampler2D maxzBuffer;
+uniform sampler2DArray planarDepth;
+
#define MAX_STEP 256
float sample_depth(vec2 uv, int index, float lod)
diff --git a/source/blender/draw/engines/eevee/shaders/renderpass_lib.glsl b/source/blender/draw/engines/eevee/shaders/renderpass_lib.glsl
new file mode 100644
index 00000000000..36cf3cecf40
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/renderpass_lib.glsl
@@ -0,0 +1,43 @@
+
+/* ---------------------------------------------------------------------- */
+/** \name Resources
+ * \{ */
+
+layout(std140) uniform renderpass_block
+{
+ bool renderPassDiffuse;
+ bool renderPassDiffuseLight;
+ bool renderPassGlossy;
+ bool renderPassGlossyLight;
+ bool renderPassEmit;
+ bool renderPassSSSColor;
+ bool renderPassEnvironment;
+};
+
+/** \} */
+
+/* ---------------------------------------------------------------------- */
+/** \name Functions
+ * \{ */
+
+vec3 render_pass_diffuse_mask(vec3 diffuse_color, vec3 diffuse_light)
+{
+ return renderPassDiffuse ? (renderPassDiffuseLight ? diffuse_light : diffuse_color) : vec3(0.0);
+}
+
+vec3 render_pass_sss_mask(vec3 sss_color)
+{
+ return renderPassSSSColor ? sss_color : vec3(0.0);
+}
+
+vec3 render_pass_glossy_mask(vec3 specular_color, vec3 specular_light)
+{
+ return renderPassGlossy ? (renderPassGlossyLight ? specular_light : specular_color) : vec3(0.0);
+}
+
+vec3 render_pass_emission_mask(vec3 emission_light)
+{
+ return renderPassEmit ? emission_light : vec3(0.0);
+}
+
+/** \} */
diff --git a/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl b/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl
index 361963d5ac3..89a411bc7cb 100644
--- a/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl
@@ -1,3 +1,7 @@
+
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
+
#define PASS_POST_UNDEFINED 0
#define PASS_POST_ACCUMULATED_COLOR 1
#define PASS_POST_ACCUMULATED_LIGHT 2
@@ -9,6 +13,8 @@
uniform int postProcessType;
uniform int currentSample;
+
+uniform sampler2D depthBuffer;
uniform sampler2D inputBuffer;
uniform sampler2D inputSecondLightBuffer;
uniform sampler2D inputColorBuffer;
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl
index 860ec9e1727..e0b9d4a60db 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl
@@ -1,11 +1,11 @@
-out vec4 fragColor;
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
+#pragma BLENDER_REQUIRE(lights_lib.glsl)
+
+uniform sampler2D depthBuffer;
-#ifndef UTIL_TEX
-# define UTIL_TEX
-uniform sampler2DArray utilTex;
-# define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
-#endif /* UTIL_TEX */
+out vec4 fragColor;
void main()
{
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
index c42f905cf7e..0e342938396 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
@@ -1,39 +1,23 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(common_hair_lib.glsl)
+#pragma BLENDER_REQUIRE(surface_lib.glsl)
+
in vec3 pos;
in vec3 nor;
-#ifdef MESH_SHADER
-out vec3 worldPosition;
-out vec3 viewPosition;
-out vec3 worldNormal;
-out vec3 viewNormal;
-#endif
-
-#ifdef HAIR_SHADER
-out vec3 hairTangent;
-out float hairThickTime;
-out float hairThickness;
-out float hairTime;
-flat out int hairStrandID;
-#endif
-
void main()
{
-#ifdef GPU_INTEL
- /* Due to some shader compiler bug, we somewhat
- * need to access gl_VertexID to make it work. even
- * if it's actually dead code. */
- gl_Position.x = float(gl_VertexID);
-#endif
+ GPU_INTEL_VERTEX_SHADER_WORKAROUND
#ifdef HAIR_SHADER
hairStrandID = hair_get_strand_id();
- vec3 world_pos, binor;
+ vec3 pos, binor;
hair_get_pos_tan_binor_time((ProjectionMatrix[3][3] == 0.0),
ModelMatrixInverse,
ViewMatrixInverse[3].xyz,
ViewMatrixInverse[2].xyz,
- world_pos,
+ pos,
hairTangent,
binor,
hairTime,
@@ -41,6 +25,7 @@ void main()
hairThickTime);
worldNormal = cross(hairTangent, binor);
+ vec3 world_pos = pos;
#else
vec3 world_pos = point_object_to_world(pos);
#endif
@@ -57,7 +42,10 @@ void main()
/* No need to normalize since this is just a rotation. */
viewNormal = normal_world_to_view(worldNormal);
# ifdef USE_ATTR
- pass_attr(pos);
+# ifdef HAIR_SHADER
+ pos = hair_get_strand_pos();
+# endif
+ pass_attr(pos, NormalMatrix, ModelMatrixInverse);
# endif
#endif
}
diff --git a/source/blender/draw/engines/eevee/shaders/ssr_lib.glsl b/source/blender/draw/engines/eevee/shaders/ssr_lib.glsl
index 0591b247541..29495e98355 100644
--- a/source/blender/draw/engines/eevee/shaders/ssr_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ssr_lib.glsl
@@ -1,3 +1,10 @@
+
+#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
+#pragma BLENDER_REQUIRE(bsdf_common_lib.glsl)
+#pragma BLENDER_REQUIRE(bsdf_sampling_lib.glsl)
+#pragma BLENDER_REQUIRE(raytrace_lib.glsl)
+#pragma BLENDER_REQUIRE(surface_lib.glsl)
+
/* ------------ Refraction ------------ */
#define BTDF_BIAS 0.85
diff --git a/source/blender/draw/engines/eevee/shaders/surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/surface_frag.glsl
new file mode 100644
index 00000000000..e746acfdfa3
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/surface_frag.glsl
@@ -0,0 +1,89 @@
+
+/* Required by some nodes. */
+#pragma BLENDER_REQUIRE(common_hair_lib.glsl)
+#pragma BLENDER_REQUIRE(common_utiltex_lib.glsl)
+
+#pragma BLENDER_REQUIRE(closure_lib.glsl)
+#pragma BLENDER_REQUIRE(closure_lit_lib.glsl)
+#pragma BLENDER_REQUIRE(surface_lib.glsl)
+#pragma BLENDER_REQUIRE(volumetric_lib.glsl)
+
+#ifdef USE_ALPHA_BLEND
+/* Use dual source blending to be able to make a whole range of effects. */
+layout(location = 0, index = 0) out vec4 outRadiance;
+layout(location = 0, index = 1) out vec4 outTransmittance;
+
+#else /* OPAQUE */
+layout(location = 0) out vec4 outRadiance;
+layout(location = 1) out vec2 ssrNormals;
+layout(location = 2) out vec4 ssrData;
+# ifdef USE_SSS
+layout(location = 3) out vec3 sssIrradiance;
+layout(location = 4) out float sssRadius;
+layout(location = 5) out vec3 sssAlbedo;
+# endif
+
+#endif
+
+void main()
+{
+ Closure cl = nodetree_exec();
+
+ float holdout = saturate(1.0 - cl.holdout);
+ float transmit = saturate(avg(cl.transmittance));
+ float alpha = 1.0 - transmit;
+
+#ifdef USE_ALPHA_BLEND
+ vec2 uvs = gl_FragCoord.xy * volCoordScale.zw;
+ vec3 vol_transmit, vol_scatter;
+ volumetric_resolve(uvs, gl_FragCoord.z, vol_transmit, vol_scatter);
+
+ /* Removes part of the volume scattering that have
+ * already been added to the destination pixels.
+ * Since we do that using the blending pipeline we need to account for material transmittance. */
+ vol_scatter -= vol_scatter * cl.transmittance;
+
+ cl.radiance = cl.radiance * holdout * vol_transmit + vol_scatter;
+ outRadiance = vec4(cl.radiance, alpha * holdout);
+ outTransmittance = vec4(cl.transmittance, transmit) * holdout;
+#else
+ outRadiance = vec4(cl.radiance, holdout);
+ ssrNormals = cl.ssr_normal;
+ ssrData = cl.ssr_data;
+# ifdef USE_SSS
+ sssIrradiance = cl.sss_irradiance;
+ sssRadius = cl.sss_radius;
+ sssAlbedo = cl.sss_albedo;
+# endif
+#endif
+
+ /* For Probe capture */
+#ifdef USE_SSS
+ float fac = float(!sssToggle);
+
+ /* TODO(fclem) we shouldn't need this.
+ * Just disable USE_SSS when USE_REFRACTION is enabled. */
+# ifdef USE_REFRACTION
+ /* SSRefraction pass is done after the SSS pass.
+ * In order to not loose the diffuse light totally we
+ * need to merge the SSS radiance to the main radiance. */
+ fac = 1.0;
+# endif
+
+ outRadiance.rgb += cl.sss_irradiance.rgb * cl.sss_albedo.rgb * fac;
+#endif
+
+#ifndef USE_ALPHA_BLEND
+ float alpha_div = 1.0 / max(1e-8, alpha);
+ outRadiance.rgb *= alpha_div;
+ ssrData.rgb *= alpha_div;
+# ifdef USE_SSS
+ sssAlbedo.rgb *= alpha_div;
+# endif
+#endif
+
+#ifdef LOOKDEV
+ /* Lookdev spheres are rendered in front. */
+ gl_FragDepth = 0.0;
+#endif
+}
diff --git a/source/blender/draw/engines/eevee/shaders/surface_geom.glsl b/source/blender/draw/engines/eevee/shaders/surface_geom.glsl
new file mode 100644
index 00000000000..ad437dca79a
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/surface_geom.glsl
@@ -0,0 +1,46 @@
+
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(surface_lib.glsl)
+
+layout(triangles) in;
+layout(triangle_strip, max_vertices = 3) out;
+
+RESOURCE_ID_VARYING
+
+/* Only used to compute barycentric coordinates. */
+
+void main()
+{
+#ifdef DO_BARYCENTRIC_DISTANCES
+ dataAttrOut.barycentricDist = calc_barycentric_distances(
+ dataIn[0].worldPosition, dataIn[1].worldPosition, dataIn[2].worldPosition);
+#endif
+
+ PASS_RESOURCE_ID
+
+#ifdef USE_ATTR
+ pass_attr(0);
+#endif
+ PASS_SURFACE_INTERFACE(0);
+ gl_Position = gl_in[0].gl_Position;
+ gl_ClipDistance[0] = gl_in[0].gl_ClipDistance[0];
+ EmitVertex();
+
+#ifdef USE_ATTR
+ pass_attr(1);
+#endif
+ PASS_SURFACE_INTERFACE(1);
+ gl_Position = gl_in[1].gl_Position;
+ gl_ClipDistance[0] = gl_in[1].gl_ClipDistance[0];
+ EmitVertex();
+
+#ifdef USE_ATTR
+ pass_attr(2);
+#endif
+ PASS_SURFACE_INTERFACE(2);
+ gl_Position = gl_in[2].gl_Position;
+ gl_ClipDistance[0] = gl_in[2].gl_ClipDistance[0];
+ EmitVertex();
+
+ EndPrimitive();
+}
diff --git a/source/blender/draw/engines/eevee/shaders/surface_lib.glsl b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl
new file mode 100644
index 00000000000..b93a3a23eff
--- /dev/null
+++ b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl
@@ -0,0 +1,43 @@
+/** This describe the entire interface of the shader. */
+
+/* Samplers */
+uniform sampler2D colorBuffer;
+uniform sampler2D depthBuffer;
+
+/* Uniforms */
+uniform float refractionDepth;
+
+#define SURFACE_INTERFACE \
+ vec3 worldPosition; \
+ vec3 viewPosition; \
+ vec3 worldNormal; \
+ vec3 viewNormal;
+
+#ifdef GPU_GEOMETRY_SHADER
+in ShaderStageInterface{SURFACE_INTERFACE} dataIn[];
+
+out ShaderStageInterface{SURFACE_INTERFACE} dataOut;
+
+# define PASS_SURFACE_INTERFACE(vert) \
+ dataOut.worldPosition = dataIn[vert].worldPosition; \
+ dataOut.viewPosition = dataIn[vert].viewPosition; \
+ dataOut.worldNormal = dataIn[vert].worldNormal; \
+ dataOut.viewNormal = dataIn[vert].viewNormal;
+
+#else
+
+IN_OUT ShaderStageInterface{SURFACE_INTERFACE};
+
+#endif
+
+#ifdef HAIR_SHADER
+IN_OUT ShaderHairInterface
+{
+ /* world space */
+ vec3 hairTangent;
+ float hairThickTime;
+ float hairThickness;
+ float hairTime;
+ flat int hairStrandID;
+};
+#endif
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl b/source/blender/draw/engines/eevee/shaders/surface_vert.glsl
index 1b94fc2bee1..0ad1393dd70 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/surface_vert.glsl
@@ -1,32 +1,20 @@
+#pragma BLENDER_REQUIRE(common_hair_lib.glsl)
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(surface_lib.glsl)
+
#ifndef HAIR_SHADER
in vec3 pos;
in vec3 nor;
#endif
-#ifdef MESH_SHADER
-out vec3 worldPosition;
-out vec3 viewPosition;
-out vec3 worldNormal;
-out vec3 viewNormal;
-#endif
-
-#ifdef HAIR_SHADER
-out vec3 hairTangent;
-out float hairThickTime;
-out float hairThickness;
-out float hairTime;
-flat out int hairStrandID;
-#endif
+RESOURCE_ID_VARYING
void main()
{
-#ifdef GPU_INTEL
- /* Due to some shader compiler bug, we somewhat
- * need to access gl_VertexID to make it work. even
- * if it's actually dead code. */
- gl_Position.x = float(gl_VertexID);
-#endif
+ GPU_INTEL_VERTEX_SHADER_WORKAROUND
+
+ PASS_RESOURCE_ID
#ifdef HAIR_SHADER
hairStrandID = hair_get_strand_id();
@@ -63,7 +51,10 @@ void main()
/* No need to normalize since this is just a rotation. */
viewNormal = normal_world_to_view(worldNormal);
# ifdef USE_ATTR
- pass_attr(pos);
+# ifdef HAIR_SHADER
+ pos = hair_get_strand_pos();
+# endif
+ pass_attr(pos, NormalMatrix, ModelMatrixInverse);
# endif
#endif
}
diff --git a/source/blender/draw/engines/eevee/shaders/update_noise_frag.glsl b/source/blender/draw/engines/eevee/shaders/update_noise_frag.glsl
index 02ad2170f06..0c01c46c2ba 100644
--- a/source/blender/draw/engines/eevee/shaders/update_noise_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/update_noise_frag.glsl
@@ -1,11 +1,11 @@
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+
uniform sampler2D blueNoise;
uniform vec3 offsets;
out vec4 FragColor;
-#define M_2PI 6.28318530717958647692
-
void main(void)
{
vec3 blue_noise = texelFetch(blueNoise, ivec2(gl_FragCoord.xy), 0).xyz;
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl
index 312fc07054a..bac69ab0355 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl
@@ -1,9 +1,10 @@
+#pragma BLENDER_REQUIRE(volumetric_lib.glsl)
+#pragma BLENDER_REQUIRE(closure_lib.glsl)
+
/* Based on Frosbite Unified Volumetric.
* https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */
-#define NODETREE_EXEC
-
#ifdef MESH_SHADER
uniform vec3 volumeOrcoLoc;
uniform vec3 volumeOrcoSize;
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_geom.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_geom.glsl
index 96b891c929f..30cda401284 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_geom.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_geom.glsl
@@ -1,4 +1,6 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+
#ifdef MESH_SHADER
/* TODO tight slices */
layout(triangles) in;
@@ -12,12 +14,16 @@ in vec4 vPos[];
flat out int slice;
+RESOURCE_ID_VARYING
+
#ifdef MESH_SHADER
/* TODO tight slices */
void main()
{
gl_Layer = slice = int(vPos[0].z);
+ PASS_RESOURCE_ID
+
# ifdef USE_ATTR
pass_attr(0);
# endif
@@ -48,6 +54,8 @@ void main()
{
gl_Layer = slice = int(vPos[0].z);
+ PASS_RESOURCE_ID
+
# ifdef USE_ATTR
pass_attr(0);
# endif
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl
index c3c442e7b69..f4276bd61bd 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl
@@ -1,4 +1,6 @@
+#pragma BLENDER_REQUIRE(volumetric_lib.glsl)
+
/* Based on Frosbite Unified Volumetric.
* https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */
@@ -11,9 +13,11 @@ uniform sampler3D volumeExtinction;
#ifdef USE_VOLUME_OPTI
uniform layout(binding = 0, r11f_g11f_b10f) writeonly restrict image3D finalScattering_img;
uniform layout(binding = 1, r11f_g11f_b10f) writeonly restrict image3D finalTransmittance_img;
+
vec3 finalScattering;
vec3 finalTransmittance;
#else
+
flat in int slice;
layout(location = 0) out vec3 finalScattering;
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
index 40eb3da42d1..9b852a57ec4 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
@@ -1,4 +1,8 @@
+#pragma BLENDER_REQUIRE(lights_lib.glsl)
+#pragma BLENDER_REQUIRE(lightprobe_lib.glsl)
+#pragma BLENDER_REQUIRE(irradiance_lib.glsl)
+
/* Based on Frosbite Unified Volumetric.
* https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */
@@ -58,7 +62,6 @@ float phase_function(vec3 v, vec3 l, float g)
return (1 - sqr_g) / max(1e-8, 4.0 * M_PI * pow(1 + sqr_g - 2 * g * cos_theta, 3.0 / 2.0));
}
-#ifdef LAMPS_LIB
vec3 light_volume(LightData ld, vec4 l_vector)
{
float power;
@@ -95,7 +98,7 @@ vec3 light_volume(LightData ld, vec4 l_vector)
return tint * lum;
}
-# define VOLUMETRIC_SHADOW_MAX_STEP 32.0
+#define VOLUMETRIC_SHADOW_MAX_STEP 32.0
vec3 participating_media_extinction(vec3 wpos, sampler3D volume_extinction)
{
@@ -109,7 +112,7 @@ vec3 participating_media_extinction(vec3 wpos, sampler3D volume_extinction)
vec3 light_volume_shadow(LightData ld, vec3 ray_wpos, vec4 l_vector, sampler3D volume_extinction)
{
-# if defined(VOLUME_SHADOW)
+#if defined(VOLUME_SHADOW)
/* Heterogeneous volume shadows */
float dd = l_vector.w / volShadowSteps;
vec3 L = l_vector.xyz * l_vector.w;
@@ -120,27 +123,24 @@ vec3 light_volume_shadow(LightData ld, vec3 ray_wpos, vec4 l_vector, sampler3D v
shadow *= exp(-s_extinction * dd);
}
return shadow;
-# else
+#else
return vec3(1.0);
-# endif /* VOLUME_SHADOW */
+#endif /* VOLUME_SHADOW */
}
-#endif
-#ifdef IRRADIANCE_LIB
vec3 irradiance_volumetric(vec3 wpos)
{
-# ifdef IRRADIANCE_HL2
+#ifdef IRRADIANCE_HL2
IrradianceData ir_data = load_irradiance_cell(0, vec3(1.0));
vec3 irradiance = ir_data.cubesides[0] + ir_data.cubesides[1] + ir_data.cubesides[2];
ir_data = load_irradiance_cell(0, vec3(-1.0));
irradiance += ir_data.cubesides[0] + ir_data.cubesides[1] + ir_data.cubesides[2];
irradiance *= 0.16666666; /* 1/6 */
return irradiance;
-# else
+#else
return vec3(0.0);
-# endif
-}
#endif
+}
uniform sampler3D inScattering;
uniform sampler3D inTransmittance;
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl
index 1ff7e848c40..6ab21587c9a 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl
@@ -1,4 +1,6 @@
+#pragma BLENDER_REQUIRE(volumetric_lib.glsl)
+
/* Based on Frosbite Unified Volumetric.
* https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl
index 9621fa1cc0d..806f1b5b205 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl
@@ -1,4 +1,6 @@
+#pragma BLENDER_REQUIRE(volumetric_lib.glsl)
+
/* Based on Frosbite Unified Volumetric.
* https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_vert.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_vert.glsl
index b96360febb0..b70747ecec3 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_vert.glsl
@@ -1,6 +1,10 @@
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+
out vec4 vPos;
+RESOURCE_ID_VARYING
+
void main()
{
/* Generate Triangle : less memory fetches from a VBO */
@@ -25,7 +29,9 @@ void main()
vPos.z = float(t_id);
vPos.w = 1.0;
+ PASS_RESOURCE_ID
+
#ifdef USE_ATTR
- pass_attr(vec3(0.0));
+ pass_attr(vec3(0.0), mat3(1), mat4(1));
#endif
}
diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c
index 3ef20dbe9ec..36d295d1dde 100644
--- a/source/blender/draw/engines/external/external_engine.c
+++ b/source/blender/draw/engines/external/external_engine.c
@@ -268,7 +268,7 @@ static void external_draw_scene(void *vedata)
* OpenGL render is used for quick preview (thumbnails or sequencer preview)
* where using the rendering engine to preview doesn't make so much sense. */
if (draw_ctx->evil_C) {
- float clear_col[4] = {0, 0, 0, 0};
+ const float clear_col[4] = {0, 0, 0, 0};
/* This is to keep compatibility with external engine. */
/* TODO(fclem) remove it eventually. */
GPU_framebuffer_bind(dfbl->default_fb);
diff --git a/source/blender/draw/engines/external/external_engine.h b/source/blender/draw/engines/external/external_engine.h
index 01edea38ab0..c645fb99e0e 100644
--- a/source/blender/draw/engines/external/external_engine.h
+++ b/source/blender/draw/engines/external/external_engine.h
@@ -20,9 +20,6 @@
* \ingroup draw_engine
*/
-#ifndef __EXTERNAL_ENGINE_H__
-#define __EXTERNAL_ENGINE_H__
+#pragma once
extern RenderEngineType DRW_engine_viewport_external_type;
-
-#endif /* __EXTERNAL_ENGINE_H__ */
diff --git a/source/blender/draw/engines/gpencil/gpencil_antialiasing.c b/source/blender/draw/engines/gpencil/gpencil_antialiasing.c
index 8955240c549..b9600ad8caf 100644
--- a/source/blender/draw/engines/gpencil/gpencil_antialiasing.c
+++ b/source/blender/draw/engines/gpencil/gpencil_antialiasing.c
@@ -36,7 +36,7 @@ void GPENCIL_antialiasing_init(struct GPENCIL_Data *vedata)
const float *size = DRW_viewport_size_get();
const float *sizeinv = DRW_viewport_invert_size_get();
- float metrics[4] = {sizeinv[0], sizeinv[1], size[0], size[1]};
+ const float metrics[4] = {sizeinv[0], sizeinv[1], size[0], size[1]};
if (pd->simplify_antialias) {
/* No AA fallback. */
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 8a4134ec8ea..363794e1be3 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -132,12 +132,11 @@ static int gpencil_tobject_dist_sort(const void *a, const void *b)
if (ob_a->camera_z > ob_b->camera_z) {
return 1;
}
- else if (ob_a->camera_z < ob_b->camera_z) {
+ if (ob_a->camera_z < ob_b->camera_z) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
void gpencil_object_cache_sort(GPENCIL_PrivateData *pd)
@@ -193,7 +192,7 @@ static float gpencil_layer_final_opacity_get(const GPENCIL_PrivateData *pd,
if (is_obact && is_fade) {
return gpl->opacity * pd->fade_layer_opacity;
}
- else if (!is_obact && (pd->fade_gp_object_opacity > -1.0f)) {
+ if (!is_obact && (pd->fade_gp_object_opacity > -1.0f)) {
return gpl->opacity * pd->fade_gp_object_opacity;
}
}
@@ -246,7 +245,7 @@ static void gpencil_layer_random_color_get(const Object *ob,
uint ob_hash = BLI_ghashutil_strhash_p_murmur(ob->id.name);
uint gpl_hash = BLI_ghashutil_strhash_p_murmur(gpl->info);
float hue = BLI_hash_int_01(ob_hash * gpl_hash);
- float hsv[3] = {hue, hsv_saturation, hsv_value};
+ const float hsv[3] = {hue, hsv_saturation, hsv_value};
hsv_to_rgb_v(hsv, r_color);
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.c b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
index d2aa0a45660..51152475a06 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_data.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
@@ -63,7 +63,7 @@ static struct GPUTexture *gpencil_image_texture_get(Image *image, bool *r_alpha_
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
if (ibuf != NULL && ibuf->rect != NULL) {
- gpu_tex = GPU_texture_from_blender(image, &iuser, ibuf, TEXTARGET_2D);
+ gpu_tex = BKE_image_get_gpu_texture(image, &iuser, ibuf);
*r_alpha_premult = (image->alpha_mode == IMA_ALPHA_PREMUL);
}
BKE_image_release_ibuf(image, ibuf, lock);
@@ -359,12 +359,11 @@ static float light_power_get(const Light *la)
if (la->type == LA_AREA) {
return 1.0f / (4.0f * M_PI);
}
- else if (la->type == LA_SPOT || la->type == LA_LOCAL) {
+ if (la->type == LA_SPOT || la->type == LA_LOCAL) {
return 1.0f / (4.0f * M_PI * M_PI);
}
- else {
- return 1.0f / M_PI;
- }
+
+ return 1.0f / M_PI;
}
void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob)
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index dbad226099e..746920e38c6 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -71,7 +71,7 @@ void GPENCIL_engine_init(void *ved)
}
if (txl->dummy_texture == NULL) {
- float pixels[1][4] = {{1.0f, 0.0f, 1.0f, 1.0f}};
+ const float pixels[1][4] = {{1.0f, 0.0f, 1.0f, 1.0f}};
txl->dummy_texture = DRW_texture_create_2d(1, 1, GPU_RGBA8, DRW_TEX_WRAP, (float *)pixels);
}
@@ -766,7 +766,7 @@ static void gpencil_draw_mask(GPENCIL_Data *vedata, GPENCIL_tObject *ob, GPENCIL
{
GPENCIL_PassList *psl = vedata->psl;
GPENCIL_FramebufferList *fbl = vedata->fbl;
- float clear_col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+ const float clear_col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
float clear_depth = ob->is_drawmode3d ? 1.0f : 0.0f;
bool inverted = false;
/* OPTI(fclem) we could optimize by only clearing if the new mask_bits does not contain all
@@ -813,7 +813,7 @@ static void GPENCIL_draw_object(GPENCIL_Data *vedata, GPENCIL_tObject *ob)
GPENCIL_PassList *psl = vedata->psl;
GPENCIL_PrivateData *pd = vedata->stl->pd;
GPENCIL_FramebufferList *fbl = vedata->fbl;
- float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
+ const float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
DRW_stats_group_start("GPencil Object");
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 7baca28dca3..a406df530fc 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __GPENCIL_ENGINE_H__
-#define __GPENCIL_ENGINE_H__
+#pragma once
#include "DNA_gpencil_types.h"
@@ -439,5 +438,3 @@ void GPENCIL_render_to_image(void *vedata,
void gpencil_light_pool_free(void *storage);
void gpencil_material_pool_free(void *storage);
GPENCIL_ViewLayerData *GPENCIL_view_layer_data_ensure(void);
-
-#endif /* __GPENCIL_ENGINE_H__ */
diff --git a/source/blender/draw/engines/gpencil/gpencil_render.c b/source/blender/draw/engines/gpencil/gpencil_render.c
index 4748858a6a8..df52b65aa78 100644
--- a/source/blender/draw/engines/gpencil/gpencil_render.c
+++ b/source/blender/draw/engines/gpencil/gpencil_render.c
@@ -129,7 +129,7 @@ void GPENCIL_render_init(GPENCIL_Data *vedata,
/* To avoid unpredictable result, clear buffers that have not be initialized. */
GPU_framebuffer_bind(fbl->render_fb);
if (do_clear_col) {
- float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
GPU_framebuffer_clear_color(fbl->render_fb, clear_col);
}
if (do_clear_z) {
@@ -143,9 +143,11 @@ void GPENCIL_render_init(GPENCIL_Data *vedata,
int w = BLI_rcti_size_x(rect);
int h = BLI_rcti_size_y(rect);
if (pix_col) {
+ GPU_texture_bind(txl->render_color_tx, 0);
GPU_texture_update_sub(txl->render_color_tx, GPU_DATA_FLOAT, pix_col, x, y, 0, w, h, 0);
}
if (pix_z) {
+ GPU_texture_bind(txl->render_depth_tx, 0);
GPU_texture_update_sub(txl->render_depth_tx, GPU_DATA_FLOAT, pix_z, x, y, 0, w, h, 0);
}
}
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
index 36fe9df9e5a..c19bf1e7b50 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
@@ -487,7 +487,7 @@ void stroke_vertex()
vec2 screen_ofs = miter * y;
- /* Reminder: we packed the cap flag into the sign of stength and thickness sign. */
+ /* Reminder: we packed the cap flag into the sign of strength and thickness sign. */
if ((is_stroke_start && strength1 > 0.0) || (is_stroke_end && thickness1 > 0.0) ||
(miter_break && !is_stroke_start && !is_stroke_end)) {
screen_ofs += line * x;
diff --git a/source/blender/draw/engines/overlay/overlay_antialiasing.c b/source/blender/draw/engines/overlay/overlay_antialiasing.c
index a32242d6292..9e95e860d0a 100644
--- a/source/blender/draw/engines/overlay/overlay_antialiasing.c
+++ b/source/blender/draw/engines/overlay/overlay_antialiasing.c
@@ -69,7 +69,7 @@ void OVERLAY_antialiasing_init(OVERLAY_Data *vedata)
/* Small texture which will have very small impact on rendertime. */
if (txl->dummy_depth_tx == NULL) {
- float pixel[1] = {1.0f};
+ const float pixel[1] = {1.0f};
txl->dummy_depth_tx = DRW_texture_create_2d(1, 1, GPU_DEPTH_COMPONENT24, 0, pixel);
}
@@ -202,7 +202,7 @@ void OVERLAY_antialiasing_start(OVERLAY_Data *vedata)
OVERLAY_PrivateData *pd = vedata->stl->pd;
if (pd->antialiasing.enabled) {
- float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
GPU_framebuffer_bind(fbl->overlay_line_fb);
GPU_framebuffer_clear_color(fbl->overlay_line_fb, clear_col);
}
diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c
index 960e5e424f2..49b8257e0c6 100644
--- a/source/blender/draw/engines/overlay/overlay_armature.c
+++ b/source/blender/draw/engines/overlay/overlay_armature.c
@@ -601,7 +601,7 @@ static void drw_shgroup_bone_custom_empty(ArmatureDrawContext *ctx,
const float color[4],
Object *custom)
{
- float final_color[4] = {color[0], color[1], color[2], 1.0f};
+ const float final_color[4] = {color[0], color[1], color[2], 1.0f};
float mat[4][4];
mul_m4_m4m4(mat, ctx->ob->obmat, bone_mat);
@@ -924,12 +924,11 @@ static float get_bone_wire_thickness(const ArmatureDrawContext *ctx, int bonefla
if (ctx->const_color) {
return ctx->const_wire;
}
- else if (boneflag & (BONE_DRAW_ACTIVE | BONE_SELECTED)) {
+ if (boneflag & (BONE_DRAW_ACTIVE | BONE_SELECTED)) {
return 2.0f;
}
- else {
- return 1.0f;
- }
+
+ return 1.0f;
}
static const float *get_bone_wire_color(const ArmatureDrawContext *ctx,
@@ -1079,7 +1078,7 @@ static void edbo_compute_bbone_child(bArmature *arm)
}
/* A version of BKE_pchan_bbone_spline_setup() for previewing editmode curve settings. */
-static void ebone_spline_preview(EditBone *ebone, float result_array[MAX_BBONE_SUBDIV][4][4])
+static void ebone_spline_preview(EditBone *ebone, const float result_array[MAX_BBONE_SUBDIV][4][4])
{
BBoneSplineParameters param;
EditBone *prev, *next;
@@ -2219,13 +2218,13 @@ static bool POSE_is_driven_by_active_armature(Object *ob)
}
return is_active;
}
- else {
- Object *ob_mesh_deform = BKE_modifiers_is_deformed_by_meshdeform(ob);
- if (ob_mesh_deform) {
- /* Recursive. */
- return POSE_is_driven_by_active_armature(ob_mesh_deform);
- }
+
+ Object *ob_mesh_deform = BKE_modifiers_is_deformed_by_meshdeform(ob);
+ if (ob_mesh_deform) {
+ /* Recursive. */
+ return POSE_is_driven_by_active_armature(ob_mesh_deform);
}
+
return false;
}
diff --git a/source/blender/draw/engines/overlay/overlay_edit_text.c b/source/blender/draw/engines/overlay/overlay_edit_text.c
index 6ddd0e6d9be..fd68b319f02 100644
--- a/source/blender/draw/engines/overlay/overlay_edit_text.c
+++ b/source/blender/draw/engines/overlay/overlay_edit_text.c
@@ -74,7 +74,7 @@ void OVERLAY_edit_text_cache_init(OVERLAY_Data *vedata)
/* Use 2D quad corners to create a matrix that set
* a [-1..1] quad at the right position. */
-static void v2_quad_corners_to_mat4(float corners[4][2], float r_mat[4][4])
+static void v2_quad_corners_to_mat4(const float corners[4][2], float r_mat[4][4])
{
unit_m4(r_mat);
sub_v2_v2v2(r_mat[0], corners[1], corners[0]);
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c
index bc96a03da31..1312408498a 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -440,7 +440,7 @@ static void OVERLAY_draw_scene(void *vedata)
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
if (DRW_state_is_fbo()) {
- float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
GPU_framebuffer_bind(dfbl->overlay_only_fb);
GPU_framebuffer_clear_color(dfbl->overlay_only_fb, clear_col);
}
diff --git a/source/blender/draw/engines/overlay/overlay_engine.h b/source/blender/draw/engines/overlay/overlay_engine.h
index 795e3805037..f9f6ee0511c 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.h
+++ b/source/blender/draw/engines/overlay/overlay_engine.h
@@ -20,9 +20,6 @@
* \ingroup draw_engine
*/
-#ifndef __OVERLAY_ENGINE_H__
-#define __OVERLAY_ENGINE_H__
+#pragma once
extern DrawEngineType draw_engine_overlay_type;
-
-#endif /* __OVERLAY_ENGINE_H__ */
diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c
index 47f05eda58e..ce678c7d03f 100644
--- a/source/blender/draw/engines/overlay/overlay_extra.c
+++ b/source/blender/draw/engines/overlay/overlay_extra.c
@@ -53,8 +53,6 @@
#include "ED_view3d.h"
-#include "GPU_draw.h"
-
#include "overlay_private.h"
#include "draw_common.h"
@@ -279,7 +277,7 @@ void OVERLAY_extra_wire(OVERLAY_ExtraCallBuffers *cb,
const float color[4])
{
float draw_mat[4][4];
- float col[4] = {UNPACK3(color), 0.0f /* No stipples. */};
+ const float col[4] = {UNPACK3(color), 0.0f /* No stipples. */};
pack_v4_in_mat4(draw_mat, mat, col);
DRW_shgroup_call_obmat(cb->extra_wire, geom, draw_mat);
}
@@ -547,7 +545,7 @@ static void OVERLAY_forcefield(OVERLAY_ExtraCallBuffers *cb, Object *ob, ViewLay
if (cu && (cu->flag & CU_PATH) && ob->runtime.curve_cache->path &&
ob->runtime.curve_cache->path->data) {
instdata.size_x = instdata.size_y = instdata.size_z = pd->f_strength;
- float pos[3], tmp[3];
+ float pos[4], tmp[3];
where_on_path(ob, 0.0f, pos, tmp, NULL, NULL, NULL);
copy_v3_v3(instdata.pos, ob->obmat[3]);
translate_m4(instdata.mat, pos[0], pos[1], pos[2]);
@@ -681,8 +679,8 @@ void OVERLAY_light_cache_populate(OVERLAY_Data *vedata, Object *ob)
DRW_buffer_add_entry(cb->light_spot, color, &instdata);
if ((la->mode & LA_SHOW_CONE) && !DRW_state_is_select()) {
- float color_inside[4] = {0.0f, 0.0f, 0.0f, 0.5f};
- float color_outside[4] = {1.0f, 1.0f, 1.0f, 0.3f};
+ const float color_inside[4] = {0.0f, 0.0f, 0.0f, 0.5f};
+ const float color_outside[4] = {1.0f, 1.0f, 1.0f, 0.3f};
DRW_buffer_add_entry(cb->light_spot_cone_front, color_inside, &instdata);
DRW_buffer_add_entry(cb->light_spot_cone_back, color_outside, &instdata);
}
@@ -1020,9 +1018,8 @@ static float camera_offaxis_shiftx_get(Scene *scene,
const float width = instdata->corner_x * 2.0f;
return delta_shiftx * width;
}
- else {
- return 0.0;
- }
+
+ return 0.0;
}
/**
* Draw the stereo 3d support elements (cameras, plane, volume).
@@ -1339,7 +1336,7 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb,
else {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
- if ((cti && cti->get_constraint_targets) && (curcon->ui_expand_flag && (1 << 0))) {
+ if ((cti && cti->get_constraint_targets) && (curcon->ui_expand_flag & (1 << 0))) {
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -1422,7 +1419,7 @@ static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb,
line_count /= fds->res[axis];
}
- GPU_create_smoke_velocity(fmd);
+ DRW_smoke_ensure_velocity(fmd);
GPUShader *sh = OVERLAY_shader_volume_velocity(use_needle);
DRWShadingGroup *grp = DRW_shgroup_create(sh, data->psl->extra_ps[0]);
@@ -1452,7 +1449,7 @@ static void OVERLAY_volume_free_smoke_textures(OVERLAY_Data *data)
LinkData *link;
while ((link = BLI_pophead(&data->stl->pd->smoke_domains))) {
FluidModifierData *fmd = (FluidModifierData *)link->data;
- GPU_free_smoke_velocity(fmd);
+ DRW_smoke_free_velocity(fmd);
MEM_freeN(link);
}
}
@@ -1542,7 +1539,7 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob)
}
/* Helpers for when we're transforming origins. */
if (draw_xform) {
- float color_xform[4] = {0.15f, 0.15f, 0.15f, 0.7f};
+ const float color_xform[4] = {0.15f, 0.15f, 0.15f, 0.7f};
DRW_buffer_add_entry(cb->origin_xform, color_xform, ob->obmat);
}
/* don't show object extras in set's */
diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.c
index 7aad84629e0..08cddf4e185 100644
--- a/source/blender/draw/engines/overlay/overlay_image.c
+++ b/source/blender/draw/engines/overlay/overlay_image.c
@@ -109,13 +109,12 @@ static eStereoViews camera_background_images_stereo_eye(const Scene *scene, cons
if ((scene->r.scemode & R_MULTIVIEW) == 0) {
return STEREO_LEFT_ID;
}
- else if (v3d->stereo3d_camera != STEREO_3D_ID) {
+ if (v3d->stereo3d_camera != STEREO_3D_ID) {
/* show only left or right camera */
return v3d->stereo3d_camera;
}
- else {
- return v3d->multiview_eye;
- }
+
+ return v3d->multiview_eye;
}
static void camera_background_images_stereo_setup(const Scene *scene,
@@ -162,9 +161,8 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
/* Frame is out of range, dont show. */
return NULL;
}
- else {
- camera_background_images_stereo_setup(scene, draw_ctx->v3d, image, iuser);
- }
+
+ camera_background_images_stereo_setup(scene, draw_ctx->v3d, image, iuser);
iuser->scene = draw_ctx->scene;
ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, &lock);
@@ -175,7 +173,7 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
}
width = ibuf->x;
height = ibuf->y;
- tex = GPU_texture_from_blender(image, iuser, ibuf, TEXTARGET_2D);
+ tex = BKE_image_get_gpu_texture(image, iuser, ibuf);
BKE_image_release_ibuf(image, ibuf, lock);
iuser->scene = NULL;
@@ -203,7 +201,7 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
}
BKE_movieclip_user_set_frame(&bgpic->cuser, ctime);
- tex = GPU_texture_from_movieclip(clip, &bgpic->cuser, TEXTARGET_2D);
+ tex = BKE_movieclip_get_gpu_texture(clip, &bgpic->cuser);
if (tex == NULL) {
return NULL;
}
@@ -232,7 +230,7 @@ static void OVERLAY_image_free_movieclips_textures(OVERLAY_Data *data)
LinkData *link;
while ((link = BLI_pophead(&data->stl->pd->bg_movie_clips))) {
MovieClip *clip = (MovieClip *)link->data;
- GPU_free_texture_movieclip(clip);
+ BKE_movieclip_free_gputexture(clip);
MEM_freeN(link);
}
}
@@ -342,7 +340,7 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob)
mul_m4_m4m4(mat, modelmat, mat);
const bool is_foreground = (bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != 0;
- float color_premult_alpha[4] = {1.0f, 1.0f, 1.0f, bgpic->alpha};
+ 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;
@@ -383,7 +381,7 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob)
if (ima != NULL) {
ImageUser iuser = *ob->iuser;
camera_background_images_stereo_setup(draw_ctx->scene, draw_ctx->v3d, ima, &iuser);
- tex = GPU_texture_from_blender(ima, &iuser, NULL, TEXTARGET_2D);
+ tex = BKE_image_get_gpu_texture(ima, &iuser, NULL);
if (tex) {
size[0] = GPU_texture_orig_width(tex);
size[1] = GPU_texture_orig_height(tex);
diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.c b/source/blender/draw/engines/overlay/overlay_motion_path.c
index 168f6f8a17f..0e5a52702fe 100644
--- a/source/blender/draw/engines/overlay/overlay_motion_path.c
+++ b/source/blender/draw/engines/overlay/overlay_motion_path.c
@@ -149,7 +149,7 @@ static void motion_path_cache(OVERLAY_Data *vedata,
/* Draw curve-line of path. */
if (show_lines) {
- int motion_path_settings[4] = {cfra, sfra, efra, mpath->start_frame};
+ const int motion_path_settings[4] = {cfra, sfra, efra, mpath->start_frame};
DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->motion_path_lines_grp);
DRW_shgroup_uniform_ivec4_copy(grp, "mpathLineSettings", motion_path_settings);
DRW_shgroup_uniform_int_copy(grp, "lineThickness", mpath->line_thickness);
@@ -162,7 +162,7 @@ static void motion_path_cache(OVERLAY_Data *vedata,
/* Draw points. */
{
int pt_size = max_ii(mpath->line_thickness - 1, 1);
- int motion_path_settings[4] = {pt_size, cfra, mpath->start_frame, stepsize};
+ const int motion_path_settings[4] = {pt_size, cfra, mpath->start_frame, stepsize};
DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->motion_path_points_grp);
DRW_shgroup_uniform_ivec4_copy(grp, "mpathPointSettings", motion_path_settings);
DRW_shgroup_uniform_bool_copy(grp, "showKeyFrames", show_keyframes);
diff --git a/source/blender/draw/engines/overlay/overlay_outline.c b/source/blender/draw/engines/overlay/overlay_outline.c
index 214322c4adc..e904066248f 100644
--- a/source/blender/draw/engines/overlay/overlay_outline.c
+++ b/source/blender/draw/engines/overlay/overlay_outline.c
@@ -342,7 +342,7 @@ void OVERLAY_outline_draw(OVERLAY_Data *vedata)
{
OVERLAY_FramebufferList *fbl = vedata->fbl;
OVERLAY_PassList *psl = vedata->psl;
- float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
bool do_outlines = psl->outlines_prepass_ps != NULL &&
!DRW_pass_is_empty(psl->outlines_prepass_ps);
diff --git a/source/blender/draw/engines/overlay/overlay_paint.c b/source/blender/draw/engines/overlay/overlay_paint.c
index 44eded94e63..f0a1e77cf05 100644
--- a/source/blender/draw/engines/overlay/overlay_paint.c
+++ b/source/blender/draw/engines/overlay/overlay_paint.c
@@ -22,6 +22,8 @@
#include "DRW_render.h"
+#include "BKE_image.h"
+
#include "DNA_mesh_types.h"
#include "DEG_depsgraph_query.h"
@@ -34,7 +36,7 @@ static bool paint_object_is_rendered_transparent(View3D *v3d, Object *ob)
if (v3d->shading.type == OB_WIRE) {
return true;
}
- else if (v3d->shading.type == OB_SOLID) {
+ if (v3d->shading.type == OB_SOLID) {
if (v3d->shading.flag & V3D_SHADING_XRAY) {
return true;
}
@@ -42,8 +44,8 @@ static bool paint_object_is_rendered_transparent(View3D *v3d, Object *ob)
if (ob && v3d->shading.color_type == V3D_SHADING_OBJECT_COLOR) {
return ob->color[3] < 1.0f;
}
- else if (ob && ob->type == OB_MESH && ob->data &&
- v3d->shading.color_type == V3D_SHADING_MATERIAL_COLOR) {
+ if (ob && ob->type == OB_MESH && ob->data &&
+ v3d->shading.color_type == V3D_SHADING_MATERIAL_COLOR) {
Mesh *me = ob->data;
for (int i = 0; i < me->totcol; i++) {
Material *mat = me->mat[i];
@@ -136,7 +138,7 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata)
state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA;
DRW_PASS_CREATE(psl->paint_color_ps, state | pd->clipping_state);
- GPUTexture *tex = GPU_texture_from_blender(imapaint->stencil, NULL, NULL, TEXTARGET_2D);
+ GPUTexture *tex = BKE_image_get_gpu_texture(imapaint->stencil, NULL, NULL);
const bool mask_premult = (imapaint->stencil->alpha_mode == IMA_ALPHA_PREMUL);
const bool mask_inverted = (imapaint->flag & IMAGEPAINT_PROJECT_LAYER_STENCIL_INV) != 0;
diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h
index efb9594f499..a8ac2616c02 100644
--- a/source/blender/draw/engines/overlay/overlay_private.h
+++ b/source/blender/draw/engines/overlay/overlay_private.h
@@ -20,8 +20,7 @@
* \ingroup DNA
*/
-#ifndef __OVERLAY_PRIVATE_H__
-#define __OVERLAY_PRIVATE_H__
+#pragma once
#ifdef __APPLE__
# define USE_GEOM_SHADER_WORKAROUND 1
@@ -630,5 +629,3 @@ GPUShader *OVERLAY_shader_xray_fade(void);
OVERLAY_InstanceFormats *OVERLAY_shader_instance_formats_get(void);
void OVERLAY_shader_free(void);
-
-#endif /* __OVERLAY_PRIVATE_H__ */
diff --git a/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl b/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl
index 0d01f67c6ea..2989e07691f 100644
--- a/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl
+++ b/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl
@@ -1,4 +1,6 @@
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+
uniform sampler2D colorTex;
uniform sampler2D depthTex;
uniform sampler2D lineTex;
diff --git a/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl b/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl
index 380708795e9..0925901a9c9 100644
--- a/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl
+++ b/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl
@@ -14,19 +14,6 @@ layout(depth_greater) out float gl_FragDepth;
layout(location = 0) out vec4 fragColor;
layout(location = 1) out vec4 lineOutput;
-#define cameraPos ViewMatrixInverse[3].xyz
-
-float get_depth_from_view_z(float z)
-{
- if (ProjectionMatrix[3][3] == 0.0) {
- z = (-ProjectionMatrix[3][2] / z) - ProjectionMatrix[2][2];
- }
- else {
- z = z * ProjectionMatrix[2][2] / (1.0 - ProjectionMatrix[3][2]);
- }
- return z * 0.5 + 0.5;
-}
-
void main()
{
const float sphere_radius = 0.05;
diff --git a/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
index 732e392ffe0..5818d8eca52 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
@@ -26,6 +26,7 @@ void discard_vert()
#define GP_EDIT_MULTIFRAME 4u /* 1 << 2 */
#define GP_EDIT_STROKE_START 8u /* 1 << 3 */
#define GP_EDIT_STROKE_END 16u /* 1 << 4 */
+#define GP_EDIT_POINT_DIMMED 32u /* 1 << 5 */
#ifdef USE_POINTS
# define colorUnselect colorGpencilVertex
@@ -60,6 +61,7 @@ void main()
bool is_multiframe = (vflag & GP_EDIT_MULTIFRAME) != 0u;
bool is_stroke_sel = (vflag & GP_EDIT_STROKE_SELECTED) != 0u;
bool is_point_sel = (vflag & GP_EDIT_POINT_SELECTED) != 0u;
+ bool is_point_dimmed = (vflag & GP_EDIT_POINT_DIMMED) != 0u;
if (doWeightColor) {
finalColor.rgb = weight_to_rgb(weight);
@@ -73,6 +75,10 @@ void main()
#ifdef USE_POINTS
gl_PointSize = sizeVertex * 2.0;
+ if (is_point_dimmed) {
+ finalColor.rgb = clamp(colorUnselect.rgb + vec3(0.3), 0.0, 1.0);
+ }
+
if (doStrokeEndpoints && !doWeightColor) {
bool is_stroke_start = (vflag & GP_EDIT_STROKE_START) != 0u;
bool is_stroke_end = (vflag & GP_EDIT_STROKE_END) != 0u;
diff --git a/source/blender/draw/engines/overlay/shaders/grid_frag.glsl b/source/blender/draw/engines/overlay/shaders/grid_frag.glsl
index 317e9fe0447..d0b68df0625 100644
--- a/source/blender/draw/engines/overlay/shaders/grid_frag.glsl
+++ b/source/blender/draw/engines/overlay/shaders/grid_frag.glsl
@@ -14,8 +14,6 @@ uniform float meshSize;
uniform float lineKernel = 0.0;
uniform sampler2D depthBuffer;
-#define cameraPos (ViewMatrixInverse[3].xyz)
-
uniform int gridFlag;
#define STEPS_LEN 8
diff --git a/source/blender/draw/engines/overlay/shaders/grid_vert.glsl b/source/blender/draw/engines/overlay/shaders/grid_vert.glsl
index 496bb011c74..dd0e771ad93 100644
--- a/source/blender/draw/engines/overlay/shaders/grid_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/grid_vert.glsl
@@ -7,8 +7,6 @@ uniform float meshSize;
uniform int gridFlag;
-#define cameraPos (ViewMatrixInverse[3].xyz)
-
#define PLANE_XY (1 << 4)
#define PLANE_XZ (1 << 5)
#define PLANE_YZ (1 << 6)
diff --git a/source/blender/draw/engines/select/select_engine.h b/source/blender/draw/engines/select/select_engine.h
index 79139d9deaf..2b35cf6bee5 100644
--- a/source/blender/draw/engines/select/select_engine.h
+++ b/source/blender/draw/engines/select/select_engine.h
@@ -20,8 +20,7 @@
* \ingroup draw_engine
*/
-#ifndef __SELECT_ENGINE_H__
-#define __SELECT_ENGINE_H__
+#pragma once
extern DrawEngineType draw_engine_select_type;
extern RenderEngineType DRW_engine_viewport_select_type;
@@ -30,5 +29,3 @@ struct SELECTID_Context *DRW_select_engine_context_get(void);
struct GPUFrameBuffer *DRW_engine_select_framebuffer_get(void);
struct GPUTexture *DRW_engine_select_texture_get(void);
-
-#endif /* __SELECT_ENGINE_H__ */
diff --git a/source/blender/draw/engines/select/select_private.h b/source/blender/draw/engines/select/select_private.h
index 1e99a49252e..763d1a0897d 100644
--- a/source/blender/draw/engines/select/select_private.h
+++ b/source/blender/draw/engines/select/select_private.h
@@ -20,8 +20,7 @@
* \ingroup draw_engine
*/
-#ifndef __SELECT_PRIVATE_H__
-#define __SELECT_PRIVATE_H__
+#pragma once
#define USE_CAGE_OCCLUSION
@@ -78,5 +77,3 @@ void select_id_draw_object(void *vedata,
uint *r_vert_offset,
uint *r_edge_offset,
uint *r_face_offset);
-
-#endif /* __SELECT_PRIVATE_H__ */
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl
index 722dbdd0b5e..d0d52c8485b 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl
@@ -28,7 +28,7 @@ void cavity_compute(vec2 screenco,
return;
}
- vec3 position = view_position_from_depth(screenco, depth, ViewVecs, ProjectionMatrix);
+ vec3 position = get_view_space_from_depth(screenco, depth);
vec3 normal = workbench_normal_decode(texture(normalBuffer, screenco));
vec2 jitter_co = (screenco * world_data.viewport_size.xy) * world_data.cavity_jitter_scale;
@@ -68,7 +68,7 @@ void cavity_compute(vec2 screenco,
bool is_background = (s_depth == 1.0);
/* This trick provide good edge effect even if no neighbor is found. */
s_depth = (is_background) ? depth : s_depth;
- vec3 s_pos = view_position_from_depth(uvcoords, s_depth, ViewVecs, ProjectionMatrix);
+ vec3 s_pos = get_view_space_from_depth(uvcoords, s_depth);
if (is_background) {
s_pos.z -= world_data.cavity_distance;
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
index c529f23265b..eb61edca6c7 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
@@ -67,31 +67,3 @@ void workbench_float_pair_decode(float data, out float v1, out float v2)
v1 = float(idata & v1_mask) * (1.0 / float(v1_mask));
v2 = float(idata >> int(ROUGHNESS_BITS)) * (1.0 / float(v2_mask));
}
-
-vec3 view_vector_from_screen_uv(vec2 uv, vec4 viewvecs[2], mat4 proj_mat)
-{
- if (proj_mat[3][3] == 0.0) {
- return normalize(vec3(viewvecs[0].xy + uv * viewvecs[1].xy, 1.0));
- }
- else {
- return vec3(0.0, 0.0, 1.0);
- }
-}
-
-vec3 view_position_from_depth(vec2 uvcoords, float depth, vec4 viewvecs[2], mat4 proj_mat)
-{
- if (proj_mat[3][3] == 0.0) {
- /* Perspective */
- float d = 2.0 * depth - 1.0;
-
- float zview = -proj_mat[3][2] / (d + proj_mat[2][2]);
-
- return zview * vec3(viewvecs[0].xy + uvcoords * viewvecs[1].xy, 1.0);
- }
- else {
- /* Orthographic */
- vec3 offset = vec3(uvcoords, depth);
-
- return viewvecs[0].xyz + offset * viewvecs[1].xyz;
- }
-}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl
index f3a238fd112..6e10a656fc1 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl
@@ -14,7 +14,7 @@ out vec4 fragColor;
void main()
{
/* Normal and Incident vector are in viewspace. Lighting is evaluated in viewspace. */
- vec3 I = view_vector_from_screen_uv(uvcoordsvar.st, ViewVecs, ProjectionMatrix);
+ vec3 I = get_view_vector_from_screen_uv(uvcoordsvar.st);
vec3 N = workbench_normal_decode(texture(normalBuffer, uvcoordsvar.st));
vec4 mat_data = texture(materialBuffer, uvcoordsvar.st);
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
index 51007a9f246..71816f6ff6e 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
@@ -1,3 +1,6 @@
+
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
+
/**
* Separable Hexagonal Bokeh Blur by Colin Barré-Brisebois
* https://colinbarrebrisebois.com/2017/04/18/hexagonal-bokeh-blur-revisited-part-1-basic-3-pass-version/
@@ -21,13 +24,6 @@ uniform sampler2D noiseTex;
#define dof_distance dofParams.y
#define dof_invsensorsize dofParams.z
-#define M_PI 3.1415926535897932 /* pi */
-
-float max_v4(vec4 v)
-{
- return max(max(v.x, v.y), max(v.z, v.w));
-}
-
#define weighted_sum(a, b, c, d, e, e_sum) \
((a)*e.x + (b)*e.y + (c)*e.z + (d)*e.w) / max(1e-6, e_sum);
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl
index 6a7bc185fe9..3e1ea14f47c 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_hair_vert.glsl
@@ -90,5 +90,5 @@ void main()
packed_rough_metal = workbench_float_pair_encode(roughness, metallic);
#endif
- object_id = int((uint(resource_id) + 1u) & 0xFFu);
+ object_id = int(uint(resource_handle) & 0xFFFFu) + 1;
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_pointcloud_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_pointcloud_vert.glsl
index 8e5c8a1b21f..6f61874b8f5 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_pointcloud_vert.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_pointcloud_vert.glsl
@@ -34,5 +34,5 @@ void main()
packed_rough_metal = workbench_float_pair_encode(roughness, metallic);
#endif
- object_id = int((uint(resource_id) + 1u) & 0xFFu);
+ object_id = int(uint(resource_handle) & 0xFFFFu) + 1;
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
index 31e298d1540..1192081caf1 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
@@ -36,5 +36,5 @@ void main()
packed_rough_metal = workbench_float_pair_encode(roughness, metallic);
#endif
- object_id = int((uint(resource_id) + 1u) & 0xFFu);
+ object_id = int(uint(resource_handle) & 0xFFFFu) + 1;
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_transparent_accum_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_transparent_accum_frag.glsl
index ba8eeff1001..fd4d00d96dd 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_transparent_accum_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_transparent_accum_frag.glsl
@@ -57,7 +57,7 @@ void main()
{
/* Normal and Incident vector are in viewspace. Lighting is evaluated in viewspace. */
vec2 uv_viewport = gl_FragCoord.xy * world_data.viewport_size_inv;
- vec3 I = view_vector_from_screen_uv(uv_viewport, ViewVecs, ProjectionMatrix);
+ vec3 I = get_view_vector_from_screen_uv(uv_viewport);
vec3 N = normalize(normal_interp);
vec3 color = color_interp;
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
index 6ab652cbf36..aa938d80fa3 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
@@ -1,4 +1,5 @@
+#pragma BLENDER_REQUIRE(common_math_lib.glsl)
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(gpu_shader_common_obinfos_lib.glsl)
#pragma BLENDER_REQUIRE(workbench_data_lib.glsl)
@@ -33,11 +34,6 @@ float phase_function_isotropic()
return 1.0 / (4.0 * M_PI);
}
-float max_v3(vec3 v)
-{
- return max(v.x, max(v.y, v.z));
-}
-
float line_unit_box_intersect_dist(vec3 lineorigin, vec3 linedirection)
{
/* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
@@ -194,8 +190,8 @@ void main()
float depth = texelFetch(depthBuffer, ivec2(gl_FragCoord.xy), 0).r;
float depth_end = min(depth, gl_FragCoord.z);
- vec3 vs_ray_end = view_position_from_depth(screen_uv, depth_end, ViewVecs, ProjectionMatrix);
- vec3 vs_ray_ori = view_position_from_depth(screen_uv, 0.0, ViewVecs, ProjectionMatrix);
+ vec3 vs_ray_end = get_view_space_from_depth(screen_uv, depth_end);
+ vec3 vs_ray_ori = get_view_space_from_depth(screen_uv, 0.0);
vec3 vs_ray_dir = (is_persp) ? (vs_ray_end - vs_ray_ori) : vec3(0.0, 0.0, -1.0);
vs_ray_dir /= abs(vs_ray_dir.z);
diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
index 0e896c4b7bb..47a03073839 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
@@ -112,17 +112,15 @@ int workbench_antialiasing_sample_count_get(WORKBENCH_PrivateData *wpd)
/* Only draw using SMAA or no AA when navigating. */
return min_ii(wpd->preferences->viewport_aa, 1);
}
- else if (DRW_state_is_image_render()) {
+ if (DRW_state_is_image_render()) {
if (draw_ctx->v3d) {
return scene->display.viewport_aa;
}
- else {
- return scene->display.render_aa;
- }
- }
- else {
- return wpd->preferences->viewport_aa;
+
+ return scene->display.render_aa;
}
+
+ return wpd->preferences->viewport_aa;
}
void workbench_antialiasing_view_updated(WORKBENCH_Data *vedata)
@@ -303,7 +301,7 @@ void workbench_antialiasing_cache_init(WORKBENCH_Data *vedata)
const float *size = DRW_viewport_size_get();
const float *sizeinv = DRW_viewport_invert_size_get();
- float metrics[4] = {sizeinv[0], sizeinv[1], size[0], size[1]};
+ const float metrics[4] = {sizeinv[0], sizeinv[1], size[0], size[1]};
{
/* Stage 1: Edge detection. */
@@ -361,53 +359,52 @@ bool workbench_antialiasing_setup(WORKBENCH_Data *vedata)
/* TAA accumulation has finish. Just copy the result back */
return false;
}
- else {
- const float *viewport_size = DRW_viewport_size_get();
- const DRWView *default_view = DRW_view_default_get();
- float *transform_offset;
-
- switch (wpd->taa_sample_len) {
- default:
- case 5:
- transform_offset = e_data.jitter_5[min_ii(wpd->taa_sample, 5)];
- break;
- case 8:
- transform_offset = e_data.jitter_8[min_ii(wpd->taa_sample, 8)];
- break;
- case 11:
- transform_offset = e_data.jitter_11[min_ii(wpd->taa_sample, 11)];
- break;
- case 16:
- transform_offset = e_data.jitter_16[min_ii(wpd->taa_sample, 16)];
- break;
- case 32:
- transform_offset = e_data.jitter_32[min_ii(wpd->taa_sample, 32)];
- break;
- }
-
- /* construct new matrices from transform delta */
- float winmat[4][4], viewmat[4][4], persmat[4][4];
- DRW_view_winmat_get(default_view, winmat, false);
- DRW_view_viewmat_get(default_view, viewmat, false);
- DRW_view_persmat_get(default_view, persmat, false);
- window_translate_m4(winmat,
- persmat,
- transform_offset[0] / viewport_size[0],
- transform_offset[1] / viewport_size[1]);
-
- if (wpd->view) {
- /* When rendering just update the view. This avoids recomputing the culling. */
- DRW_view_update_sub(wpd->view, viewmat, winmat);
- }
- else {
- /* TAA is not making a big change to the matrices.
- * Reuse the main view culling by creating a sub-view. */
- wpd->view = DRW_view_create_sub(default_view, viewmat, winmat);
- }
- DRW_view_set_active(wpd->view);
- return true;
+ const float *viewport_size = DRW_viewport_size_get();
+ const DRWView *default_view = DRW_view_default_get();
+ float *transform_offset;
+
+ switch (wpd->taa_sample_len) {
+ default:
+ case 5:
+ transform_offset = e_data.jitter_5[min_ii(wpd->taa_sample, 5)];
+ break;
+ case 8:
+ transform_offset = e_data.jitter_8[min_ii(wpd->taa_sample, 8)];
+ break;
+ case 11:
+ transform_offset = e_data.jitter_11[min_ii(wpd->taa_sample, 11)];
+ break;
+ case 16:
+ transform_offset = e_data.jitter_16[min_ii(wpd->taa_sample, 16)];
+ break;
+ case 32:
+ transform_offset = e_data.jitter_32[min_ii(wpd->taa_sample, 32)];
+ break;
+ }
+
+ /* construct new matrices from transform delta */
+ float winmat[4][4], viewmat[4][4], persmat[4][4];
+ DRW_view_winmat_get(default_view, winmat, false);
+ DRW_view_viewmat_get(default_view, viewmat, false);
+ DRW_view_persmat_get(default_view, persmat, false);
+
+ window_translate_m4(winmat,
+ persmat,
+ transform_offset[0] / viewport_size[0],
+ transform_offset[1] / viewport_size[1]);
+
+ if (wpd->view) {
+ /* When rendering just update the view. This avoids recomputing the culling. */
+ DRW_view_update_sub(wpd->view, viewmat, winmat);
+ }
+ else {
+ /* TAA is not making a big change to the matrices.
+ * Reuse the main view culling by creating a sub-view. */
+ wpd->view = DRW_view_create_sub(default_view, viewmat, winmat);
}
+ DRW_view_set_active(wpd->view);
+ return true;
}
void workbench_antialiasing_draw_pass(WORKBENCH_Data *vedata)
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c
index e13f7bfdd92..32f6a3392b5 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c
@@ -81,10 +81,10 @@ static void workbench_dof_setup_samples(struct GPUUniformBuffer **ubo,
float bokeh_ratio)
{
if (*data == NULL) {
- *data = MEM_callocN(sizeof(float) * 4 * SAMP_LEN, "workbench dof samples");
+ *data = MEM_callocN(sizeof(float[4]) * SAMP_LEN, "workbench dof samples");
}
if (*ubo == NULL) {
- *ubo = DRW_uniformbuffer_create(sizeof(float) * 4 * SAMP_LEN, NULL);
+ *ubo = DRW_uniformbuffer_create(sizeof(float[4]) * SAMP_LEN, NULL);
}
float *samp = *data;
@@ -155,7 +155,7 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata)
}
const float *full_size = DRW_viewport_size_get();
- int size[2] = {max_ii(1, (int)full_size[0] / 2), max_ii(1, (int)full_size[1] / 2)};
+ const int size[2] = {max_ii(1, (int)full_size[0] / 2), max_ii(1, (int)full_size[1] / 2)};
#if 0 /* TODO(fclem) finish COC min_max optimisation */
/* NOTE: We Ceil here in order to not miss any edge texel if using a NPO2 texture. */
int shrink_h_size[2] = {ceilf(size[0] / 8.0f), size[1]};
diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c
index 53119723fab..ca80b6a9002 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.c
+++ b/source/blender/draw/engines/workbench/workbench_engine.c
@@ -64,7 +64,7 @@ void workbench_engine_init(void *ved)
workbench_update_world_ubo(wpd);
if (txl->dummy_image_tx == NULL) {
- float fpixel[4] = {1.0f, 0.0f, 1.0f, 1.0f};
+ const float fpixel[4] = {1.0f, 0.0f, 1.0f, 1.0f};
txl->dummy_image_tx = DRW_texture_create_2d(1, 1, GPU_RGBA8, 0, fpixel);
}
wpd->dummy_image_tx = txl->dummy_image_tx;
@@ -480,8 +480,8 @@ void workbench_draw_sample(void *ved)
WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
WORKBENCH_PassList *psl = vedata->psl;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
- float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- float clear_col_with_alpha[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+ const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float clear_col_with_alpha[4] = {0.0f, 0.0f, 0.0f, 1.0f};
const bool do_render = workbench_antialiasing_setup(vedata);
const bool xray_is_visible = wpd->shading.xray_alpha > 0.0f;
diff --git a/source/blender/draw/engines/workbench/workbench_engine.h b/source/blender/draw/engines/workbench/workbench_engine.h
index eee53fcde07..8fd427c2683 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.h
+++ b/source/blender/draw/engines/workbench/workbench_engine.h
@@ -20,9 +20,6 @@
* \ingroup draw_engine
*/
-#ifndef __WORKBENCH_ENGINE_H__
-#define __WORKBENCH_ENGINE_H__
+#pragma once
extern RenderEngineType DRW_engine_viewport_workbench_type;
-
-#endif /* __WORKBENCH_ENGINE_H__ */
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index 0493b42f9c6..538083b4beb 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -60,7 +60,7 @@ void workbench_material_ubo_data(WORKBENCH_PrivateData *wpd,
hash = (hash * 13) ^ BLI_ghashutil_strhash_p_murmur(ob->id.lib->filepath);
}
float hue = BLI_hash_int_01(hash);
- float hsv[3] = {hue, HSV_SATURATION, HSV_VALUE};
+ const float hsv[3] = {hue, HSV_SATURATION, HSV_VALUE};
hsv_to_rgb_v(hsv, data->base_color);
break;
}
@@ -231,15 +231,15 @@ DRWShadingGroup *workbench_material_setup_ex(WORKBENCH_PrivateData *wpd,
workbench_material_ubo_data(wpd, ob, NULL, &wpd->material_ubo_data_curr[mat_id], color_type);
const bool transp = wpd->shading.xray_alpha < 1.0f || ob->color[3] < 1.0f;
- DRWShadingGroup *grp = wpd->prepass[transp][infront][datatype].common_shgrp;
+ DRWShadingGroup **grp = &wpd->prepass[transp][infront][datatype].common_shgrp;
if (resource_changed) {
- grp = DRW_shgroup_create_sub(grp);
- DRW_shgroup_uniform_block(grp, "material_block", wpd->material_ubo_curr);
+ *grp = DRW_shgroup_create_sub(*grp);
+ DRW_shgroup_uniform_block(*grp, "material_block", wpd->material_ubo_curr);
}
if (r_transp && transp) {
*r_transp = true;
}
- return grp;
+ return *grp;
}
}
}
@@ -261,11 +261,11 @@ DRWShadingGroup *workbench_image_setup_ex(WORKBENCH_PrivateData *wpd,
if (ima) {
if (ima->source == IMA_SRC_TILED) {
- tex = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_2D_ARRAY);
- tex_tile_data = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_TILE_MAPPING);
+ tex = BKE_image_get_gpu_tiles(ima, iuser, NULL);
+ tex_tile_data = BKE_image_get_gpu_tilemap(ima, iuser, NULL);
}
else {
- tex = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_2D);
+ tex = BKE_image_get_gpu_texture(ima, iuser, NULL);
}
}
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index 244ac695e78..4a6dadc32fd 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -20,8 +20,7 @@
* \ingroup draw_engine
*/
-#ifndef __WORKBENCH_PRIVATE_H__
-#define __WORKBENCH_PRIVATE_H__
+#pragma once
#include "BKE_studiolight.h"
@@ -520,5 +519,3 @@ void workbench_render(void *ved,
void workbench_render_update_passes(struct RenderEngine *engine,
struct Scene *scene,
struct ViewLayer *view_layer);
-
-#endif
diff --git a/source/blender/draw/engines/workbench/workbench_shader.c b/source/blender/draw/engines/workbench/workbench_shader.c
index 835f10598d4..9cc5087bd36 100644
--- a/source/blender/draw/engines/workbench/workbench_shader.c
+++ b/source/blender/draw/engines/workbench/workbench_shader.c
@@ -28,6 +28,8 @@
#include "workbench_engine.h"
#include "workbench_private.h"
+extern char datatoc_common_math_lib_glsl[];
+extern char datatoc_common_math_geom_lib_glsl[];
extern char datatoc_common_hair_lib_glsl[];
extern char datatoc_common_pointcloud_lib_glsl[];
extern char datatoc_common_view_lib_glsl[];
@@ -119,6 +121,8 @@ void workbench_shader_library_ensure(void)
if (e_data.lib == NULL) {
e_data.lib = DRW_shader_library_create();
/* NOTE: Theses needs to be ordered by dependencies. */
+ DRW_SHADER_LIB_ADD(e_data.lib, common_math_lib);
+ DRW_SHADER_LIB_ADD(e_data.lib, common_math_geom_lib);
DRW_SHADER_LIB_ADD(e_data.lib, common_hair_lib);
DRW_SHADER_LIB_ADD(e_data.lib, common_view_lib);
DRW_SHADER_LIB_ADD(e_data.lib, common_pointcloud_lib);
@@ -504,11 +508,11 @@ void workbench_shader_free(void)
struct GPUShader **sh_array = &e_data.transp_prepass_sh_cache[0][0][0][0];
DRW_SHADER_FREE_SAFE(sh_array[j]);
}
- for (int j = 0; j < sizeof(e_data.opaque_composite_sh) / sizeof(void *); j++) {
+ for (int j = 0; j < ARRAY_SIZE(e_data.opaque_composite_sh); j++) {
struct GPUShader **sh_array = &e_data.opaque_composite_sh[0];
DRW_SHADER_FREE_SAFE(sh_array[j]);
}
- for (int j = 0; j < sizeof(e_data.shadow_depth_pass_sh) / sizeof(void *); j++) {
+ for (int j = 0; j < ARRAY_SIZE(e_data.shadow_depth_pass_sh); j++) {
struct GPUShader **sh_array = &e_data.shadow_depth_pass_sh[0];
DRW_SHADER_FREE_SAFE(sh_array[j]);
}
@@ -520,7 +524,7 @@ void workbench_shader_free(void)
struct GPUShader **sh_array = &e_data.cavity_sh[0][0];
DRW_SHADER_FREE_SAFE(sh_array[j]);
}
- for (int j = 0; j < sizeof(e_data.smaa_sh) / sizeof(void *); j++) {
+ for (int j = 0; j < ARRAY_SIZE(e_data.smaa_sh); j++) {
struct GPUShader **sh_array = &e_data.smaa_sh[0];
DRW_SHADER_FREE_SAFE(sh_array[j]);
}
diff --git a/source/blender/draw/engines/workbench/workbench_shadow.c b/source/blender/draw/engines/workbench/workbench_shadow.c
index 2cf5f3c4c13..56a028d5a7e 100644
--- a/source/blender/draw/engines/workbench/workbench_shadow.c
+++ b/source/blender/draw/engines/workbench/workbench_shadow.c
@@ -62,7 +62,7 @@ static void workbench_shadow_update(WORKBENCH_PrivateData *wpd)
wpd->shadow_cached_direction, wpd->shadow_direction_ws, 1e-5f);
if (wpd->shadow_changed) {
- float up[3] = {0.0f, 0.0f, 1.0f};
+ const float up[3] = {0.0f, 0.0f, 1.0f};
unit_m4(wpd->shadow_mat);
/* TODO fix singularity. */
@@ -229,7 +229,7 @@ static float workbench_shadow_object_shadow_distance(WORKBENCH_PrivateData *wpd,
{
BoundBox *shadow_bbox = workbench_shadow_object_shadow_bbox_get(wpd, ob, oed);
- int corners[4] = {0, 3, 4, 7};
+ const int corners[4] = {0, 3, 4, 7};
float dist = 1e4f, dist_isect;
for (int i = 0; i < 4; i++) {
if (isect_ray_plane_v3(shadow_bbox->vec[corners[i]],
diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c
index 8e345f8275b..f71e77d5da5 100644
--- a/source/blender/draw/engines/workbench/workbench_volume.c
+++ b/source/blender/draw/engines/workbench/workbench_volume.c
@@ -38,15 +38,13 @@
#include "BKE_volume.h"
#include "BKE_volume_render.h"
-#include "GPU_draw.h"
-
void workbench_volume_engine_init(WORKBENCH_Data *vedata)
{
WORKBENCH_TextureList *txl = vedata->txl;
if (txl->dummy_volume_tx == NULL) {
- float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- float one[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+ const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float one[4] = {1.0f, 1.0f, 1.0f, 1.0f};
txl->dummy_volume_tx = GPU_texture_create_3d(1, 1, 1, GPU_RGBA8, zero, NULL);
txl->dummy_shadow_tx = GPU_texture_create_3d(1, 1, 1, GPU_RGBA8, one, NULL);
txl->dummy_coba_tx = GPU_texture_create_1d(1, GPU_RGBA8, zero, NULL);
@@ -79,13 +77,10 @@ static void workbench_volume_modifier_cache_populate(WORKBENCH_Data *vedata,
wpd->volumes_do = true;
if (fds->use_coba) {
- GPU_create_smoke_coba_field(fmd);
- }
- else if (!(fds->flags & FLUID_DOMAIN_USE_NOISE)) {
- GPU_create_smoke(fmd, 0);
+ DRW_smoke_ensure_coba_field(fmd);
}
- else if (fds->flags & FLUID_DOMAIN_USE_NOISE) {
- GPU_create_smoke(fmd, 1);
+ else {
+ DRW_smoke_ensure(fmd, fds->flags & FLUID_DOMAIN_USE_NOISE);
}
if ((!fds->use_coba && (fds->tex_density == NULL && fds->tex_color == NULL)) ||
@@ -293,7 +288,7 @@ void workbench_volume_draw_finish(WORKBENCH_Data *vedata)
* all viewport in a redraw at least. */
LISTBASE_FOREACH (LinkData *, link, &wpd->smoke_domains) {
FluidModifierData *fmd = (FluidModifierData *)link->data;
- GPU_free_smoke(fmd);
+ DRW_smoke_free(fmd);
}
BLI_freelistN(&wpd->smoke_domains);
}
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 7a889d9399e..956bddfb357 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -22,8 +22,7 @@
/* This is the Render Functions used by Realtime engines to draw with OpenGL */
-#ifndef __DRW_RENDER_H__
-#define __DRW_RENDER_H__
+#pragma once
#include "DRW_engine_types.h"
@@ -198,6 +197,17 @@ void DRW_uniformbuffer_free(struct GPUUniformBuffer *ubo);
} while (0)
/* Shaders */
+
+#ifndef __GPU_MATERIAL_H__
+/* FIXME: Meh avoid including all GPUMaterial. */
+typedef void (*GPUMaterialEvalCallbackFn)(struct GPUMaterial *mat,
+ int options,
+ const char **vert_code,
+ const char **geom_code,
+ const char **frag_lib,
+ const char **defines);
+#endif
+
struct GPUShader *DRW_shader_create(const char *vert,
const char *geom,
const char *frag,
@@ -237,7 +247,8 @@ struct GPUMaterial *DRW_shader_create_from_world(struct Scene *scene,
const char *geom,
const char *frag_lib,
const char *defines,
- bool deferred);
+ bool deferred,
+ GPUMaterialEvalCallbackFn callback);
struct GPUMaterial *DRW_shader_create_from_material(struct Scene *scene,
struct Material *ma,
struct bNodeTree *ntree,
@@ -248,7 +259,8 @@ struct GPUMaterial *DRW_shader_create_from_material(struct Scene *scene,
const char *geom,
const char *frag_lib,
const char *defines,
- bool deferred);
+ bool deferred,
+ GPUMaterialEvalCallbackFn callback);
void DRW_shader_free(struct GPUShader *shader);
#define DRW_SHADER_FREE_SAFE(shader) \
do { \
@@ -632,6 +644,10 @@ void DRW_render_object_iter(void *vedata,
struct RenderEngine *engine,
struct Depsgraph *depsgraph));
void DRW_render_instance_buffer_finish(void);
+void DRW_render_set_time(struct RenderEngine *engine,
+ struct Depsgraph *depsgraph,
+ int frame,
+ float subframe);
void DRW_render_viewport_size_set(const int size[2]);
void DRW_custom_pipeline(DrawEngineType *draw_engine_type,
@@ -736,5 +752,3 @@ typedef struct DRWContextState {
} DRWContextState;
const DRWContextState *DRW_context_state_get(void);
-
-#endif /* __DRW_RENDER_H__ */
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 20e346375a7..46b7a88b2a6 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -361,8 +361,8 @@ GPUBatch *DRW_cache_fullscreen_quad_get(void)
if (!SHC.drw_fullscreen_quad) {
/* Use a triangle instead of a real quad */
/* https://www.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau - slide 14 */
- float pos[3][2] = {{-1.0f, -1.0f}, {3.0f, -1.0f}, {-1.0f, 3.0f}};
- float uvs[3][2] = {{0.0f, 0.0f}, {2.0f, 0.0f}, {0.0f, 2.0f}};
+ const float pos[3][2] = {{-1.0f, -1.0f}, {3.0f, -1.0f}, {-1.0f, 3.0f}};
+ const float uvs[3][2] = {{0.0f, 0.0f}, {2.0f, 0.0f}, {0.0f, 2.0f}};
/* Position Only 2D format */
static GPUVertFormat format = {0};
@@ -400,7 +400,7 @@ GPUBatch *DRW_cache_quad_get(void)
int v = 0;
int flag = VCLASS_EMPTY_SCALED;
- float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
+ const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
for (int a = 0; a < 4; a++) {
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[a][0], p[a][1], 0.0f}, flag});
}
@@ -421,7 +421,7 @@ GPUBatch *DRW_cache_quad_wires_get(void)
int v = 0;
int flag = VCLASS_EMPTY_SCALED;
- float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
+ const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
for (int a = 0; a < 5; a++) {
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[a % 4][0], p[a % 4][1], 0.0f}, flag});
}
@@ -1650,7 +1650,7 @@ GPUBatch *DRW_cache_light_area_square_lines_get(void)
int flag = VCLASS_LIGHT_AREA_SHAPE;
for (int a = 0; a < 4; a++) {
for (int b = 0; b < 2; b++) {
- float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
+ const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
float x = p[(a + b) % 4][0];
float y = p[(a + b) % 4][1];
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x * 0.5f, y * 0.5f, 0.0f}, flag});
@@ -2426,7 +2426,7 @@ static float x_axis_name[4][2] = {
{-0.9f * S_X, 1.0f * S_Y},
{1.0f * S_X, -1.0f * S_Y},
};
-#define X_LEN (sizeof(x_axis_name) / (sizeof(float) * 2))
+#define X_LEN (sizeof(x_axis_name) / (sizeof(float[2])))
#undef S_X
#undef S_Y
@@ -2440,7 +2440,7 @@ static float y_axis_name[6][2] = {
{0.0f * S_X, -0.1f * S_Y},
{0.0f * S_X, -1.0f * S_Y},
};
-#define Y_LEN (sizeof(y_axis_name) / (sizeof(float) * 2))
+#define Y_LEN (sizeof(y_axis_name) / (sizeof(float[2])))
#undef S_X
#undef S_Y
@@ -2458,7 +2458,7 @@ static float z_axis_name[10][2] = {
{-1.00f * S_X, -1.00f * S_Y},
{1.00f * S_X, -1.00f * S_Y},
};
-#define Z_LEN (sizeof(z_axis_name) / (sizeof(float) * 2))
+#define Z_LEN (sizeof(z_axis_name) / (sizeof(float[2])))
#undef S_X
#undef S_Y
@@ -2485,7 +2485,7 @@ static float axis_marker[8][2] = {
{-S_X, 0.f}
#endif
};
-#define MARKER_LEN (sizeof(axis_marker) / (sizeof(float) * 2))
+#define MARKER_LEN (sizeof(axis_marker) / (sizeof(float[2])))
#define MARKER_FILL_LAYER 6
#undef S_X
#undef S_Y
@@ -2659,7 +2659,7 @@ GPUBatch *DRW_cache_camera_frame_get(void)
GPU_vertbuf_data_alloc(vbo, v_len);
int v = 0;
- float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
+ const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
/* Frame */
for (int a = 0; a < 4; a++) {
for (int b = 0; b < 2; b++) {
@@ -2740,7 +2740,7 @@ GPUBatch *DRW_cache_camera_tria_wire_get(void)
GPU_vertbuf_data_alloc(vbo, v_len);
int v = 0;
- float p[3][2] = {{-1.0f, 1.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}};
+ const float p[3][2] = {{-1.0f, 1.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}};
for (int a = 0; a < 3; a++) {
for (int b = 0; b < 2; b++) {
float x = p[(a + b) % 3][0];
@@ -2909,9 +2909,8 @@ GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
- else {
- return DRW_curve_batch_cache_get_wire_edge(cu);
- }
+
+ return DRW_curve_batch_cache_get_wire_edge(cu);
}
GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob)
@@ -2947,9 +2946,8 @@ GPUBatch *DRW_cache_curve_surface_get(Object *ob)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface(mesh_eval);
}
- else {
- return DRW_curve_batch_cache_get_triangles_with_normals(cu);
- }
+
+ return DRW_curve_batch_cache_get_triangles_with_normals(cu);
}
GPUBatch *DRW_cache_curve_loose_edges_get(Object *ob)
@@ -2961,11 +2959,10 @@ GPUBatch *DRW_cache_curve_loose_edges_get(Object *ob)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
- else {
- /* TODO */
- UNUSED_VARS(cu);
- return NULL;
- }
+
+ /* TODO */
+ UNUSED_VARS(cu);
+ return NULL;
}
GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob)
@@ -2977,9 +2974,8 @@ GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
}
- else {
- return DRW_curve_batch_cache_get_wireframes_face(cu);
- }
+
+ return DRW_curve_batch_cache_get_wireframes_face(cu);
}
GPUBatch *DRW_cache_curve_edge_detection_get(Object *ob, bool *r_is_manifold)
@@ -2990,9 +2986,8 @@ GPUBatch *DRW_cache_curve_edge_detection_get(Object *ob, bool *r_is_manifold)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
}
- else {
- return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
- }
+
+ return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
}
/* Return list of batches */
@@ -3007,9 +3002,8 @@ GPUBatch **DRW_cache_curve_surface_shaded_get(Object *ob,
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
}
- else {
- return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
- }
+
+ return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
}
/** \} */
@@ -3061,12 +3055,11 @@ GPUBatch *DRW_cache_text_edge_wire_get(Object *ob)
if (!has_surface) {
return NULL;
}
- else if (mesh_eval != NULL) {
+ if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
- else {
- return DRW_curve_batch_cache_get_wire_edge(cu);
- }
+
+ return DRW_curve_batch_cache_get_wire_edge(cu);
}
GPUBatch *DRW_cache_text_surface_get(Object *ob)
@@ -3080,9 +3073,8 @@ GPUBatch *DRW_cache_text_surface_get(Object *ob)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface(mesh_eval);
}
- else {
- return DRW_curve_batch_cache_get_triangles_with_normals(cu);
- }
+
+ return DRW_curve_batch_cache_get_triangles_with_normals(cu);
}
GPUBatch *DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold)
@@ -3096,9 +3088,8 @@ GPUBatch *DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
}
- else {
- return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
- }
+
+ return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
}
GPUBatch *DRW_cache_text_loose_edges_get(Object *ob)
@@ -3112,9 +3103,8 @@ GPUBatch *DRW_cache_text_loose_edges_get(Object *ob)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
- else {
- return DRW_curve_batch_cache_get_wire_edge(cu);
- }
+
+ return DRW_curve_batch_cache_get_wire_edge(cu);
}
GPUBatch *DRW_cache_text_face_wireframe_get(Object *ob)
@@ -3128,9 +3118,8 @@ GPUBatch *DRW_cache_text_face_wireframe_get(Object *ob)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
}
- else {
- return DRW_curve_batch_cache_get_wireframes_face(cu);
- }
+
+ return DRW_curve_batch_cache_get_wireframes_face(cu);
}
GPUBatch **DRW_cache_text_surface_shaded_get(Object *ob,
@@ -3146,9 +3135,8 @@ GPUBatch **DRW_cache_text_surface_shaded_get(Object *ob,
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
}
- else {
- return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
- }
+
+ return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
}
/** \} */
@@ -3166,9 +3154,8 @@ GPUBatch *DRW_cache_surf_surface_get(Object *ob)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface(mesh_eval);
}
- else {
- return DRW_curve_batch_cache_get_triangles_with_normals(cu);
- }
+
+ return DRW_curve_batch_cache_get_triangles_with_normals(cu);
}
GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob)
@@ -3180,9 +3167,8 @@ GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
- else {
- return DRW_curve_batch_cache_get_wire_edge(cu);
- }
+
+ return DRW_curve_batch_cache_get_wire_edge(cu);
}
GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob)
@@ -3194,9 +3180,8 @@ GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
}
- else {
- return DRW_curve_batch_cache_get_wireframes_face(cu);
- }
+
+ return DRW_curve_batch_cache_get_wireframes_face(cu);
}
GPUBatch *DRW_cache_surf_edge_detection_get(Object *ob, bool *r_is_manifold)
@@ -3207,9 +3192,8 @@ GPUBatch *DRW_cache_surf_edge_detection_get(Object *ob, bool *r_is_manifold)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
}
- else {
- return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
- }
+
+ return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
}
GPUBatch *DRW_cache_surf_loose_edges_get(Object *ob)
@@ -3221,11 +3205,10 @@ GPUBatch *DRW_cache_surf_loose_edges_get(Object *ob)
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
- else {
- /* TODO */
- UNUSED_VARS(cu);
- return NULL;
- }
+
+ /* TODO */
+ UNUSED_VARS(cu);
+ return NULL;
}
/* Return list of batches */
@@ -3240,9 +3223,8 @@ GPUBatch **DRW_cache_surf_surface_shaded_get(Object *ob,
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
}
- else {
- return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
- }
+
+ return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
}
/** \} */
@@ -3434,8 +3416,8 @@ GPUBatch *DRW_cache_cursor_get(bool crosshair_lines)
const int vert_len = segments + 8;
const int index_len = vert_len + 5;
- uchar red[3] = {255, 0, 0};
- uchar white[3] = {255, 255, 255};
+ const uchar red[3] = {255, 0, 0};
+ const uchar white[3] = {255, 255, 255};
static GPUVertFormat format = {0};
static struct {
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index 1ea53c91cb3..2a7448ce877 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __DRAW_CACHE_H__
-#define __DRAW_CACHE_H__
+#pragma once
struct GPUBatch;
struct GPUMaterial;
@@ -251,5 +250,3 @@ struct GPUBatch *DRW_cache_gpencil_face_wireframe_get(struct Object *ob);
struct bGPDstroke *DRW_cache_gpencil_sbuffer_stroke_data_get(struct Object *ob);
void DRW_cache_gpencil_sbuffer_clear(struct Object *ob);
-
-#endif /* __DRAW_CACHE_H__ */
diff --git a/source/blender/draw/intern/draw_cache_extract.h b/source/blender/draw/intern/draw_cache_extract.h
index 4156e2e79d8..2653b3127ae 100644
--- a/source/blender/draw/intern/draw_cache_extract.h
+++ b/source/blender/draw/intern/draw_cache_extract.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __DRAW_CACHE_EXTRACT_H__
-#define __DRAW_CACHE_EXTRACT_H__
+#pragma once
struct TaskGraph;
@@ -269,5 +268,3 @@ void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
const Scene *scene,
const ToolSettings *ts,
const bool use_hide);
-
-#endif /* __DRAW_CACHE_EXTRACT_H__ */
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c
index cca8ebcf2a8..934b47d583e 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -474,10 +474,9 @@ BLI_INLINE const float *bm_vert_co_get(const MeshRenderData *mr, const BMVert *e
if (vert_coords != NULL) {
return vert_coords[BM_elem_index_get(eve)];
}
- else {
- UNUSED_VARS(mr);
- return eve->co;
- }
+
+ UNUSED_VARS(mr);
+ return eve->co;
}
BLI_INLINE const float *bm_vert_no_get(const MeshRenderData *mr, const BMVert *eve)
@@ -486,10 +485,9 @@ BLI_INLINE const float *bm_vert_no_get(const MeshRenderData *mr, const BMVert *e
if (vert_normals != NULL) {
return vert_normals[BM_elem_index_get(eve)];
}
- else {
- UNUSED_VARS(mr);
- return eve->no;
- }
+
+ UNUSED_VARS(mr);
+ return eve->no;
}
BLI_INLINE const float *bm_face_no_get(const MeshRenderData *mr, const BMFace *efa)
@@ -498,10 +496,9 @@ BLI_INLINE const float *bm_face_no_get(const MeshRenderData *mr, const BMFace *e
if (poly_normals != NULL) {
return poly_normals[BM_elem_index_get(efa)];
}
- else {
- UNUSED_VARS(mr);
- return efa->no;
- }
+
+ UNUSED_VARS(mr);
+ return efa->no;
}
/** \} */
@@ -2937,7 +2934,7 @@ static float evaluate_vertex_weight(const MDeformVert *dvert, const DRW_MeshWeig
if ((wstate->defgroup_active < 0) && (wstate->defgroup_len > 0)) {
return -2.0f;
}
- else if (dvert == NULL) {
+ if (dvert == NULL) {
return (wstate->alert_mode != OB_DRAW_GROUPUSER_NONE) ? -1.0f : 0.0f;
}
@@ -3614,12 +3611,14 @@ static void compute_normalize_edge_vectors(float auv[2][2],
normalize_v3(av[1]);
}
-static short v2_to_short_angle(float v[2])
+static short v2_to_short_angle(const float v[2])
{
return atan2f(v[1], v[0]) * (float)M_1_PI * SHRT_MAX;
}
-static void edituv_get_stretch_angle(float auv[2][2], float av[2][3], UVStretchAngle *r_stretch)
+static void edituv_get_stretch_angle(float auv[2][2],
+ const float av[2][3],
+ UVStretchAngle *r_stretch)
{
/* Send UV's to the shader and let it compute the aspect corrected angle. */
r_stretch->uv_angles[0] = v2_to_short_angle(auv[0]);
@@ -4047,8 +4046,7 @@ static bool bvh_overlap_cb(void *userdata, int index_a, int index_b, int UNUSED(
return false;
}
- return (isect_tri_tri_epsilon_v3(
- UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1], data->epsilon) &&
+ return (isect_tri_tri_v3(UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1]) &&
/* if we share a vertex, check the intersection isn't a 'point' */
((verts_shared == 0) || (len_squared_v3v3(ix_pair[0], ix_pair[1]) > data->epsilon)));
}
@@ -4296,7 +4294,7 @@ static void statvis_calc_sharp(const MeshRenderData *mr, float *r_sharp)
/* non-manifold edge, yet... */
continue;
}
- else if (*pval != NULL) {
+ if (*pval != NULL) {
const float *f1_no = mr->poly_normals[mp_index];
const float *f2_no = *pval;
angle = angle_normalized_v3v3(f1_no, f2_no);
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 96d351794e6..784e52cfa17 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __DRAW_CACHE_IMPL_H__
-#define __DRAW_CACHE_IMPL_H__
+#pragma once
struct GPUBatch;
struct GPUIndexBuf;
@@ -254,5 +253,3 @@ struct GPUBatch *DRW_particles_batch_cache_get_edit_inner_points(struct Object *
struct GPUBatch *DRW_particles_batch_cache_get_edit_tip_points(struct Object *object,
struct ParticleSystem *psys,
struct PTCacheEdit *edit);
-
-#endif /* __DRAW_CACHE_IMPL_H__ */
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index e09f78aa51f..fb88945c5aa 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -444,7 +444,7 @@ static void displist_surf_fnors_ensure(const DispList *dl, float (**fnors)[3])
int u_len = dl->nr - ((dl->flag & DL_CYCL_U) ? 0 : 1);
int v_len = dl->parts - ((dl->flag & DL_CYCL_V) ? 0 : 1);
const float(*verts)[3] = (float(*)[3])dl->verts;
- float(*nor_flat)[3] = MEM_mallocN(sizeof(float) * 3 * u_len * v_len, __func__);
+ float(*nor_flat)[3] = MEM_mallocN(sizeof(float[3]) * u_len * v_len, __func__);
*fnors = nor_flat;
SURFACE_QUAD_ITER_BEGIN (dl) {
diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c b/source/blender/draw/intern/draw_cache_impl_gpencil.c
index d648245f232..d6b0c939114 100644
--- a/source/blender/draw/intern/draw_cache_impl_gpencil.c
+++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c
@@ -135,9 +135,8 @@ static GpencilBatchCache *gpencil_batch_cache_get(Object *ob, int cfra)
gpencil_batch_cache_clear(cache);
return gpencil_batch_cache_init(ob, cfra);
}
- else {
- return cache;
- }
+
+ return cache;
}
void DRW_gpencil_batch_cache_dirty_tag(bGPdata *gpd)
@@ -272,7 +271,7 @@ static void gpencil_buffer_add_point(gpStrokeVert *verts,
int v,
bool is_endpoint)
{
- /* Note: we use the sign of stength and thickness to pass cap flag. */
+ /* Note: we use the sign of strength and thickness to pass cap flag. */
const bool round_cap0 = (gps->caps[0] == GP_STROKE_CAP_ROUND);
const bool round_cap1 = (gps->caps[1] == GP_STROKE_CAP_ROUND);
gpStrokeVert *vert = &verts[v];
@@ -646,6 +645,7 @@ void DRW_cache_gpencil_sbuffer_clear(Object *ob)
#define GP_EDIT_MULTIFRAME (1 << 2)
#define GP_EDIT_STROKE_START (1 << 3)
#define GP_EDIT_STROKE_END (1 << 4)
+#define GP_EDIT_POINT_DIMMED (1 << 5)
typedef struct gpEditIterData {
gpEditVert *verts;
@@ -661,6 +661,7 @@ static uint32_t gpencil_point_edit_flag(const bool layer_lock,
SET_FLAG_FROM_TEST(sflag, (!layer_lock) && pt->flag & GP_SPOINT_SELECT, GP_EDIT_POINT_SELECTED);
SET_FLAG_FROM_TEST(sflag, v == 0, GP_EDIT_STROKE_START);
SET_FLAG_FROM_TEST(sflag, v == (v_len - 1), GP_EDIT_STROKE_END);
+ SET_FLAG_FROM_TEST(sflag, pt->runtime.pt_orig == NULL, GP_EDIT_POINT_DIMMED);
return sflag;
}
diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c
index 66a67d6b8fe..0f80b5159a7 100644
--- a/source/blender/draw/intern/draw_cache_impl_lattice.c
+++ b/source/blender/draw/intern/draw_cache_impl_lattice.c
@@ -83,10 +83,9 @@ static int lattice_render_verts_len_get(Lattice *lt)
if ((lt->flag & LT_OUTSIDE) == 0) {
return vert_len_calc(u, v, w);
}
- else {
- /* TODO remove internal coords */
- return vert_len_calc(u, v, w);
- }
+
+ /* TODO remove internal coords */
+ return vert_len_calc(u, v, w);
}
static int lattice_render_edges_len_get(Lattice *lt)
@@ -102,10 +101,9 @@ static int lattice_render_edges_len_get(Lattice *lt)
if ((lt->flag & LT_OUTSIDE) == 0) {
return edge_len_calc(u, v, w);
}
- else {
- /* TODO remove internal coords */
- return edge_len_calc(u, v, w);
- }
+
+ /* TODO remove internal coords */
+ return edge_len_calc(u, v, w);
}
/* ---------------------------------------------------------------------- */
@@ -252,12 +250,11 @@ static bool lattice_batch_cache_valid(Lattice *lt)
if (cache->is_dirty) {
return false;
}
- else {
- if ((cache->dims.u_len != lt->pntsu) || (cache->dims.v_len != lt->pntsv) ||
- (cache->dims.w_len != lt->pntsw) ||
- ((cache->show_only_outside != ((lt->flag & LT_OUTSIDE) != 0)))) {
- return false;
- }
+
+ if ((cache->dims.u_len != lt->pntsu) || (cache->dims.v_len != lt->pntsv) ||
+ (cache->dims.w_len != lt->pntsw) ||
+ ((cache->show_only_outside != ((lt->flag & LT_OUTSIDE) != 0)))) {
+ return false;
}
return true;
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 7cc10bd14e8..d6faeb16583 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -803,9 +803,8 @@ GPUBatch *DRW_mesh_batch_cache_get_loose_edges(Mesh *me)
if (cache->no_loose_wire) {
return NULL;
}
- else {
- return DRW_batch_request(&cache->batch.loose_edges);
- }
+
+ return DRW_batch_request(&cache->batch.loose_edges);
}
GPUBatch *DRW_mesh_batch_cache_get_surface_weights(Mesh *me)
@@ -1274,9 +1273,11 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph,
FOREACH_MESH_BUFFER_CACHE (cache, mbuffercache) {
GPU_VERTBUF_DISCARD_SAFE(mbuffercache->vbo.edituv_data);
GPU_VERTBUF_DISCARD_SAFE(mbuffercache->vbo.fdots_uv);
+ GPU_VERTBUF_DISCARD_SAFE(mbuffercache->vbo.fdots_edituv_data);
GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_tris);
GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_lines);
GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_points);
+ GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_fdots);
}
/* We only clear the batches as they may already have been
* referenced. */
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 331a1f80bec..3ecdbff1e96 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -128,9 +128,8 @@ static bool particle_batch_cache_valid(ParticleSystem *psys)
if (cache->is_dirty == false) {
return true;
}
- else {
- return false;
- }
+
+ return false;
return true;
}
@@ -647,14 +646,13 @@ static float particle_key_weight(const ParticleData *particle, int strand, float
if (t == 1.0) {
return hkeys[part->totkey - 1].weight;
}
- else {
- float interp = t / edit_key_seg_t;
- int index = (int)interp;
- interp -= floorf(interp); /* Time between 2 edit key */
- float s1 = hkeys[index].weight;
- float s2 = hkeys[index + 1].weight;
- return s1 + interp * (s2 - s1);
- }
+
+ float interp = t / edit_key_seg_t;
+ int index = (int)interp;
+ interp -= floorf(interp); /* Time between 2 edit key */
+ float s1 = hkeys[index].weight;
+ float s2 = hkeys[index + 1].weight;
+ return s1 + interp * (s2 - s1);
}
static int particle_batch_cache_fill_segments_edit(
diff --git a/source/blender/draw/intern/draw_cache_inline.h b/source/blender/draw/intern/draw_cache_inline.h
index 67f44b5fb0c..06d6f1afc31 100644
--- a/source/blender/draw/intern/draw_cache_inline.h
+++ b/source/blender/draw/intern/draw_cache_inline.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __DRAW_CACHE_INLINE_H__
-#define __DRAW_CACHE_INLINE_H__
+#pragma once
#include "GPU_batch.h"
#include "MEM_guardedalloc.h"
@@ -49,7 +48,7 @@ BLI_INLINE GPUBatch *DRW_batch_request(GPUBatch **batch)
{
/* XXX TODO(fclem): We are writing to batch cache here. Need to make this thread safe. */
if (*batch == NULL) {
- *batch = MEM_callocN(sizeof(GPUBatch), "GPUBatch");
+ *batch = GPU_batch_calloc(1);
}
return *batch;
}
@@ -110,5 +109,3 @@ BLI_INLINE bool DRW_vbo_requested(GPUVertBuf *vbo)
{
return (vbo != NULL && vbo->format.attr_len == 0);
}
-
-#endif /* __DRAW_CACHE_INLINE_H__ */
diff --git a/source/blender/draw/intern/draw_color_management.h b/source/blender/draw/intern/draw_color_management.h
index 9d83eccdce9..3150ec72138 100644
--- a/source/blender/draw/intern/draw_color_management.h
+++ b/source/blender/draw/intern/draw_color_management.h
@@ -20,9 +20,6 @@
* \ingroup draw
*/
-#ifndef __DRAW_COLOR_MANAGEMENT_H__
-#define __DRAW_COLOR_MANAGEMENT_H__
+#pragma once
void DRW_transform_none(struct GPUTexture *tex);
-
-#endif /* __DRAW_COLOR_MANAGEMENT_H__ */
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index 095e928aa74..f0d73d5bb84 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -455,11 +455,11 @@ bool DRW_object_is_flat(Object *ob, int *r_axis)
*r_axis = 0;
return true;
}
- else if (dim[1] == 0.0f) {
+ if (dim[1] == 0.0f) {
*r_axis = 1;
return true;
}
- else if (dim[2] == 0.0f) {
+ if (dim[2] == 0.0f) {
*r_axis = 2;
return true;
}
@@ -489,7 +489,7 @@ static void DRW_evaluate_weight_to_color(const float weight, float result[4])
* increasing widens yellow/cyan vs red/green/blue.
* Gamma 1.0 produces the original 2.79 color ramp. */
const float gamma = 1.5f;
- float hsv[3] = {(2.0f / 3.0f) * (1.0f - weight), 1.0f, pow(0.5f + 0.5f * weight, gamma)};
+ const float hsv[3] = {(2.0f / 3.0f) * (1.0f - weight), 1.0f, pow(0.5f + 0.5f * weight, gamma)};
hsv_to_rgb_v(hsv, result);
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index 81c0e97a1a8..6060dce47ac 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -20,15 +20,16 @@
* \ingroup draw
*/
-#ifndef __DRAW_COMMON_H__
-#define __DRAW_COMMON_H__
+#pragma once
struct DRWPass;
struct DRWShadingGroup;
struct GPUMaterial;
struct ModifierData;
+struct FluidModifierData;
struct Object;
struct ParticleSystem;
+struct RegionView3D;
struct ViewLayer;
#define UBO_FIRST_COLOR colorWire
@@ -159,14 +160,14 @@ void DRW_globals_update(void);
void DRW_globals_free(void);
struct DRWView *DRW_view_create_with_zoffset(const struct DRWView *parent_view,
- const RegionView3D *rv3d,
+ const struct RegionView3D *rv3d,
float offset);
int DRW_object_wire_theme_get(struct Object *ob, struct ViewLayer *view_layer, float **r_color);
float *DRW_color_background_blend_get(int theme_id);
-bool DRW_object_is_flat(Object *ob, int *r_axis);
-bool DRW_object_axis_orthogonal_to_view(Object *ob, int axis);
+bool DRW_object_is_flat(struct Object *ob, int *r_axis);
+bool DRW_object_axis_orthogonal_to_view(struct Object *ob, int axis);
/* draw_hair.c */
@@ -188,6 +189,16 @@ void DRW_hair_init(void);
void DRW_hair_update(void);
void DRW_hair_free(void);
+/* draw_fluid.c */
+
+/* Fluid simulation. */
+void DRW_smoke_ensure(struct FluidModifierData *fmd, int highres);
+void DRW_smoke_ensure_coba_field(struct FluidModifierData *fmd);
+void DRW_smoke_ensure_velocity(struct FluidModifierData *fmd);
+
+void DRW_smoke_free(struct FluidModifierData *fmd);
+void DRW_smoke_free_velocity(struct FluidModifierData *fmd);
+
/* draw_common.c */
struct DRW_Global {
/** If needed, contains all global/Theme colors
@@ -203,5 +214,3 @@ struct DRW_Global {
struct GPUUniformBuffer *view_ubo;
};
extern struct DRW_Global G_draw;
-
-#endif /* __DRAW_COMMON_H__ */
diff --git a/source/blender/draw/intern/draw_debug.h b/source/blender/draw/intern/draw_debug.h
index e7404b17384..149825974d4 100644
--- a/source/blender/draw/intern/draw_debug.h
+++ b/source/blender/draw/intern/draw_debug.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __DRAW_DEBUG_H__
-#define __DRAW_DEBUG_H__
+#pragma once
struct BoundBox;
@@ -34,5 +33,3 @@ void DRW_debug_m4(const float m[4][4]);
void DRW_debug_m4_as_bbox(const float m[4][4], const float color[4], const bool invert);
void DRW_debug_bbox(const BoundBox *bbox, const float color[4]);
void DRW_debug_sphere(const float center[3], const float radius, const float color[4]);
-
-#endif /* __DRAW_DEBUG_H__ */
diff --git a/source/blender/gpu/intern/gpu_texture_smoke.cc b/source/blender/draw/intern/draw_fluid.c
index 0f5aa361fa7..fea379126d2 100644
--- a/source/blender/gpu/intern/gpu_texture_smoke.cc
+++ b/source/blender/draw/intern/draw_fluid.c
@@ -35,10 +35,10 @@
#include "BKE_colorband.h"
-#include "GPU_draw.h"
-#include "GPU_glew.h"
#include "GPU_texture.h"
+#include "draw_common.h" /* Own include. */
+
#ifdef WITH_FLUID
# include "manta_fluid_API.h"
#endif
@@ -106,7 +106,7 @@ static void create_color_ramp(const struct ColorBand *coba, float *data)
static GPUTexture *create_transfer_function(int type, const struct ColorBand *coba)
{
- float *data = (float *)MEM_mallocN(sizeof(float) * 4 * TFUNC_WIDTH, __func__);
+ float *data = (float *)MEM_mallocN(sizeof(float[4]) * TFUNC_WIDTH, __func__);
switch (type) {
case TFUNC_FLAME_SPECTRUM:
@@ -185,7 +185,7 @@ static GPUTexture *create_field_texture(FluidDomainSettings *fds)
}
GPUTexture *tex = GPU_texture_create_nD(
- fds->res[0], fds->res[1], fds->res[2], 3, field, GPU_R8, GPU_DATA_FLOAT, 0, true, NULL);
+ UNPACK3(fds->res), 3, field, GPU_R8, GPU_DATA_FLOAT, 0, true, NULL);
swizzle_texture_channel_single(tex);
return tex;
@@ -204,7 +204,7 @@ static GPUTexture *create_density_texture(FluidDomainSettings *fds, int highres)
}
GPUTexture *tex = GPU_texture_create_nD(
- dim[0], dim[1], dim[2], 3, data, GPU_R8, GPU_DATA_FLOAT, 0, true, NULL);
+ UNPACK3(dim), 3, data, GPU_R8, GPU_DATA_FLOAT, 0, true, NULL);
swizzle_texture_channel_single(tex);
@@ -277,7 +277,7 @@ static GPUTexture *create_flame_texture(FluidDomainSettings *fds, int highres)
/** \name Public API
* \{ */
-void GPU_free_smoke(FluidModifierData *fmd)
+void DRW_smoke_free(FluidModifierData *fmd)
{
if (fmd->type & MOD_FLUID_TYPE_DOMAIN && fmd->domain) {
if (fmd->domain->tex_density) {
@@ -317,7 +317,7 @@ void GPU_free_smoke(FluidModifierData *fmd)
}
}
-void GPU_create_smoke_coba_field(FluidModifierData *fmd)
+void DRW_smoke_ensure_coba_field(FluidModifierData *fmd)
{
#ifndef WITH_FLUID
UNUSED_VARS(fmd);
@@ -335,7 +335,7 @@ void GPU_create_smoke_coba_field(FluidModifierData *fmd)
#endif
}
-void GPU_create_smoke(FluidModifierData *fmd, int highres)
+void DRW_smoke_ensure(FluidModifierData *fmd, int highres)
{
#ifndef WITH_FLUID
UNUSED_VARS(fmd, highres);
@@ -356,9 +356,7 @@ void GPU_create_smoke(FluidModifierData *fmd, int highres)
fds->tex_flame_coba = create_transfer_function(TFUNC_FLAME_SPECTRUM, NULL);
}
if (!fds->tex_shadow) {
- fds->tex_shadow = GPU_texture_create_nD(fds->res[0],
- fds->res[1],
- fds->res[2],
+ fds->tex_shadow = GPU_texture_create_nD(UNPACK3(fds->res),
3,
manta_smoke_get_shadow(fds->fluid),
GPU_R8,
@@ -371,7 +369,7 @@ void GPU_create_smoke(FluidModifierData *fmd, int highres)
#endif /* WITH_FLUID */
}
-void GPU_create_smoke_velocity(FluidModifierData *fmd)
+void DRW_smoke_ensure_velocity(FluidModifierData *fmd)
{
#ifndef WITH_FLUID
UNUSED_VARS(fmd);
@@ -388,19 +386,16 @@ void GPU_create_smoke_velocity(FluidModifierData *fmd)
}
if (!fds->tex_velocity_x) {
- fds->tex_velocity_x = GPU_texture_create_3d(
- fds->res[0], fds->res[1], fds->res[2], GPU_R16F, vel_x, NULL);
- fds->tex_velocity_y = GPU_texture_create_3d(
- fds->res[0], fds->res[1], fds->res[2], GPU_R16F, vel_y, NULL);
- fds->tex_velocity_z = GPU_texture_create_3d(
- fds->res[0], fds->res[1], fds->res[2], GPU_R16F, vel_z, NULL);
+ fds->tex_velocity_x = GPU_texture_create_3d(UNPACK3(fds->res), GPU_R16F, vel_x, NULL);
+ fds->tex_velocity_y = GPU_texture_create_3d(UNPACK3(fds->res), GPU_R16F, vel_y, NULL);
+ fds->tex_velocity_z = GPU_texture_create_3d(UNPACK3(fds->res), GPU_R16F, vel_z, NULL);
}
}
#endif /* WITH_FLUID */
}
-/* TODO Unify with the other GPU_free_smoke. */
-void GPU_free_smoke_velocity(FluidModifierData *fmd)
+/* TODO Unify with the other DRW_smoke_free. */
+void DRW_smoke_free_velocity(FluidModifierData *fmd)
{
if (fmd->type & MOD_FLUID_TYPE_DOMAIN && fmd->domain) {
if (fmd->domain->tex_velocity_x) {
diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c
index cbdcbbf9090..1992b1d291e 100644
--- a/source/blender/draw/intern/draw_hair.c
+++ b/source/blender/draw/intern/draw_hair.c
@@ -114,7 +114,7 @@ void DRW_hair_init(void)
g_dummy_vbo = GPU_vertbuf_create_with_format(&format);
- float vert[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float vert[4] = {0.0f, 0.0f, 0.0f, 0.0f};
GPU_vertbuf_data_alloc(g_dummy_vbo, 1);
GPU_vertbuf_attr_fill(g_dummy_vbo, dummy_id, vert);
/* Create vbo immediately to bind to texture buffer. */
@@ -330,7 +330,7 @@ void DRW_hair_update(void)
GPU_ATTACHMENT_TEXTURE(tex),
});
- float *data = MEM_mallocN(sizeof(float) * 4 * width * height, "tf fallback buffer");
+ float *data = MEM_mallocN(sizeof(float[4]) * width * height, "tf fallback buffer");
GPU_framebuffer_bind(fb);
while (g_tf_calls != NULL) {
@@ -347,8 +347,8 @@ void DRW_hair_update(void)
/* Upload back to VBO. */
GPU_vertbuf_use(pr_call->vbo);
glBufferSubData(GL_ARRAY_BUFFER,
- sizeof(float) * 4 * g_tf_id_offset,
- sizeof(float) * 4 * max_read_px_len,
+ sizeof(float[4]) * g_tf_id_offset,
+ sizeof(float[4]) * max_read_px_len,
data);
g_tf_id_offset += max_read_px_len;
diff --git a/source/blender/draw/intern/draw_hair_private.h b/source/blender/draw/intern/draw_hair_private.h
index b599ad389c1..33abae156cc 100644
--- a/source/blender/draw/intern/draw_hair_private.h
+++ b/source/blender/draw/intern/draw_hair_private.h
@@ -21,8 +21,7 @@
* \ingroup draw
*/
-#ifndef __DRAW_HAIR_PRIVATE_H__
-#define __DRAW_HAIR_PRIVATE_H__
+#pragma once
#define MAX_LAYER_NAME_CT 4 /* u0123456789, u, au, a0123456789 */
#define MAX_LAYER_NAME_LEN GPU_MAX_SAFE_ATTR_NAME + 2
@@ -92,5 +91,3 @@ bool hair_ensure_procedural_data(struct Object *object,
struct ParticleHairCache **r_hair_cache,
int subdiv,
int thickness_res);
-
-#endif /* __DRAW_HAIR_PRIVATE_H__ */
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index 45c201501b3..5005f38c558 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -92,8 +92,9 @@ static void instance_batch_free(GPUBatch *geom, void *UNUSED(user_data))
BLI_memblock *memblock = data_list->pool_instancing;
BLI_memblock_iter iter;
BLI_memblock_iternew(memblock, &iter);
- GPUBatch *batch;
- while ((batch = (GPUBatch *)BLI_memblock_iterstep(&iter))) {
+ GPUBatch **batch_ptr;
+ while ((batch_ptr = (GPUBatch **)BLI_memblock_iterstep(&iter))) {
+ GPUBatch *batch = *batch_ptr;
/* Only check verts[0] that's enough. */
if (batch->verts[0] == geom->verts[0]) {
GPU_batch_clear(batch);
@@ -142,7 +143,12 @@ GPUBatch *DRW_temp_batch_instance_request(DRWInstanceDataList *idatalist,
/* Only call with one of them. */
BLI_assert((instancer != NULL) != (buf != NULL));
- GPUBatch *batch = BLI_memblock_alloc(idatalist->pool_instancing);
+ GPUBatch **batch_ptr = BLI_memblock_alloc(idatalist->pool_instancing);
+ if (*batch_ptr == NULL) {
+ *batch_ptr = GPU_batch_calloc(1);
+ }
+
+ GPUBatch *batch = *batch_ptr;
bool instancer_compat = buf ? ((batch->inst[0] == buf) && (buf->vbo_id != 0)) :
((batch->inst[0] == instancer->inst[0]) &&
(batch->inst[1] == instancer->inst[1]));
@@ -173,7 +179,12 @@ GPUBatch *DRW_temp_batch_request(DRWInstanceDataList *idatalist,
GPUVertBuf *buf,
GPUPrimType prim_type)
{
- GPUBatch *batch = BLI_memblock_alloc(idatalist->pool_batching);
+ GPUBatch **batch_ptr = BLI_memblock_alloc(idatalist->pool_instancing);
+ if (*batch_ptr == NULL) {
+ *batch_ptr = GPU_batch_calloc(1);
+ }
+
+ GPUBatch *batch = *batch_ptr;
bool is_compatible = (batch->verts[0] == buf) && (buf->vbo_id != 0) &&
(batch->gl_prim_type == convert_prim_type_to_gl(prim_type));
if (!is_compatible) {
@@ -189,6 +200,11 @@ static void temp_buffer_handle_free(DRWTempBufferHandle *handle)
GPU_vertbuf_clear(&handle->buf);
}
+static void temp_batch_free(GPUBatch **batch)
+{
+ GPU_BATCH_DISCARD_SAFE(*batch);
+}
+
void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist)
{
/* Resize down buffers in use and send data to GPU. */
@@ -207,10 +223,11 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist)
}
}
/* Finish pending instancing batches. */
- GPUBatch *batch;
+ GPUBatch **batch_ptr;
BLI_memblock_iternew(idatalist->pool_instancing, &iter);
- while ((batch = BLI_memblock_iterstep(&iter))) {
- if (batch->phase == GPU_BATCH_READY_TO_BUILD) {
+ while ((batch_ptr = BLI_memblock_iterstep(&iter))) {
+ GPUBatch *batch = *batch_ptr;
+ if (batch && batch->phase == GPU_BATCH_READY_TO_BUILD) {
GPUVertBuf *inst_buf = batch->inst[0];
/* HACK see DRW_temp_batch_instance_request. */
GPUBatch *inst_batch = (void *)batch->inst[1];
@@ -228,8 +245,8 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist)
}
/* Resize pools and free unused. */
BLI_memblock_clear(idatalist->pool_buffers, (MemblockValFreeFP)temp_buffer_handle_free);
- BLI_memblock_clear(idatalist->pool_instancing, (MemblockValFreeFP)GPU_batch_clear);
- BLI_memblock_clear(idatalist->pool_batching, (MemblockValFreeFP)GPU_batch_clear);
+ BLI_memblock_clear(idatalist->pool_instancing, (MemblockValFreeFP)temp_batch_free);
+ BLI_memblock_clear(idatalist->pool_batching, (MemblockValFreeFP)temp_batch_free);
}
/** \} */
@@ -300,8 +317,8 @@ DRWInstanceDataList *DRW_instance_data_list_create(void)
{
DRWInstanceDataList *idatalist = MEM_callocN(sizeof(DRWInstanceDataList), "DRWInstanceDataList");
- idatalist->pool_batching = BLI_memblock_create(sizeof(GPUBatch));
- idatalist->pool_instancing = BLI_memblock_create(sizeof(GPUBatch));
+ idatalist->pool_batching = BLI_memblock_create(sizeof(GPUBatch *));
+ idatalist->pool_instancing = BLI_memblock_create(sizeof(GPUBatch *));
idatalist->pool_buffers = BLI_memblock_create(sizeof(DRWTempBufferHandle));
BLI_addtail(&g_idatalists, idatalist);
@@ -324,8 +341,8 @@ void DRW_instance_data_list_free(DRWInstanceDataList *idatalist)
}
BLI_memblock_destroy(idatalist->pool_buffers, (MemblockValFreeFP)temp_buffer_handle_free);
- BLI_memblock_destroy(idatalist->pool_instancing, (MemblockValFreeFP)GPU_batch_clear);
- BLI_memblock_destroy(idatalist->pool_batching, (MemblockValFreeFP)GPU_batch_clear);
+ BLI_memblock_destroy(idatalist->pool_instancing, (MemblockValFreeFP)temp_batch_free);
+ BLI_memblock_destroy(idatalist->pool_batching, (MemblockValFreeFP)temp_batch_free);
BLI_remlink(&g_idatalists, idatalist);
}
diff --git a/source/blender/draw/intern/draw_instance_data.h b/source/blender/draw/intern/draw_instance_data.h
index f891d380ee3..e562d99097e 100644
--- a/source/blender/draw/intern/draw_instance_data.h
+++ b/source/blender/draw/intern/draw_instance_data.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __DRAW_INSTANCE_DATA_H__
-#define __DRAW_INSTANCE_DATA_H__
+#pragma once
#include "BLI_compiler_attrs.h"
#include "BLI_sys_types.h"
@@ -55,5 +54,3 @@ 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);
-
-#endif /* __DRAW_INSTANCE_DATA_H__ */
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 712a93e8880..4a5e07476a9 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -792,9 +792,8 @@ DrawDataList *DRW_drawdatalist_from_id(ID *id)
IdDdtTemplate *idt = (IdDdtTemplate *)id;
return &idt->drawdata;
}
- else {
- return NULL;
- }
+
+ return NULL;
}
DrawData *DRW_drawdata_get(ID *id, DrawEngineType *engine_type)
@@ -1658,7 +1657,6 @@ void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph
Scene *scene = DEG_get_evaluated_scene(depsgraph);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
RenderEngineType *engine_type = engine->type;
- RenderData *r = &scene->r;
Render *render = engine->re;
DRW_render_context_enable(render);
@@ -1680,7 +1678,7 @@ void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph
drw_context_state_init();
DST.viewport = GPU_viewport_create();
- const int size[2] = {(r->size * r->xsch) / 100, (r->size * r->ysch) / 100};
+ const int size[2] = {engine->resolution_x, engine->resolution_y};
GPU_viewport_size_set(DST.viewport, size);
drw_viewport_var_init();
@@ -1954,13 +1952,21 @@ void DRW_render_instance_buffer_finish(void)
drw_resource_buffer_finish(DST.vmempool);
}
+/* WARNING: Changing frame might free the ViewLayerEngineData */
+void DRW_render_set_time(RenderEngine *engine, Depsgraph *depsgraph, int frame, float subframe)
+{
+ RE_engine_frame_set(engine, frame, subframe);
+ DST.draw_ctx.scene = DEG_get_evaluated_scene(depsgraph);
+ DST.draw_ctx.view_layer = DEG_get_evaluated_view_layer(depsgraph);
+}
+
/**
* object mode select-loop, see: ED_view3d_draw_select_loop (legacy drawing).
*/
void DRW_draw_select_loop(struct Depsgraph *depsgraph,
ARegion *region,
View3D *v3d,
- bool UNUSED(use_obedit_skip),
+ bool use_obedit_skip,
bool draw_surface,
bool UNUSED(use_nearest),
const rcti *rect,
@@ -1973,7 +1979,7 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
Object *obact = OBACT(view_layer);
- Object *obedit = OBEDIT_FROM_OBACT(obact);
+ Object *obedit = use_obedit_skip ? NULL : OBEDIT_FROM_OBACT(obact);
#ifndef USE_GPU_SELECT
UNUSED_VARS(scene, view_layer, v3d, region, rect);
#else
@@ -2024,7 +2030,7 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
}
}
- int viewport_size[2] = {BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)};
+ const int viewport_size[2] = {BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)};
struct GPUViewport *viewport = GPU_viewport_create();
GPU_viewport_size_set(viewport, viewport_size);
@@ -2716,7 +2722,13 @@ void DRW_engines_free(void)
void DRW_render_context_enable(Render *render)
{
if (G.background && DST.gl_context == NULL) {
- WM_init_opengl(G_MAIN);
+ WM_init_opengl();
+ }
+
+ if (GPU_use_main_context_workaround()) {
+ GPU_context_main_lock();
+ DRW_opengl_context_enable();
+ return;
}
void *re_gl_context = RE_gl_context_get(render);
@@ -2736,6 +2748,12 @@ void DRW_render_context_enable(Render *render)
void DRW_render_context_disable(Render *render)
{
+ if (GPU_use_main_context_workaround()) {
+ DRW_opengl_context_disable();
+ GPU_context_main_unlock();
+ return;
+ }
+
void *re_gl_context = RE_gl_context_get(render);
if (re_gl_context != NULL) {
@@ -2835,7 +2853,7 @@ void DRW_opengl_context_disable_ex(bool restore)
void DRW_opengl_context_enable(void)
{
if (G.background && DST.gl_context == NULL) {
- WM_init_opengl(G_MAIN);
+ WM_init_opengl();
}
DRW_opengl_context_enable_ex(true);
}
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index a448a94185a..92a01cbbe04 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -22,8 +22,7 @@
/* Private functions / structs of the draw manager */
-#ifndef __DRAW_MANAGER_H__
-#define __DRAW_MANAGER_H__
+#pragma once
#include "DRW_engine.h"
#include "DRW_render.h"
@@ -596,5 +595,3 @@ 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);
-
-#endif /* __DRAW_MANAGER_H__ */
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index a8105785d53..c12b4a96488 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -582,7 +582,7 @@ uint32_t DRW_object_resource_id_get(Object *UNUSED(ob))
/* Handle not yet allocated. Return next handle. */
handle = DST.resource_handle;
}
- return handle & ~(1 << 31);
+ return handle & ~(1u << 31);
}
static DRWResourceHandle drw_resource_handle(DRWShadingGroup *shgroup,
@@ -594,28 +594,26 @@ static DRWResourceHandle drw_resource_handle(DRWShadingGroup *shgroup,
DRWResourceHandle handle = 0;
return handle;
}
- else {
- return drw_resource_handle_new(obmat, NULL);
- }
+
+ return drw_resource_handle_new(obmat, NULL);
+ }
+
+ if (DST.ob_handle == 0) {
+ DST.ob_handle = drw_resource_handle_new(obmat, ob);
+ DST.ob_state_obinfo_init = false;
}
- else {
- if (DST.ob_handle == 0) {
- DST.ob_handle = drw_resource_handle_new(obmat, ob);
- DST.ob_state_obinfo_init = false;
- }
- if (shgroup->objectinfo) {
- if (!DST.ob_state_obinfo_init) {
- DST.ob_state_obinfo_init = true;
- DRWObjectInfos *ob_infos = DRW_memblock_elem_from_handle(DST.vmempool->obinfos,
- &DST.ob_handle);
+ if (shgroup->objectinfo) {
+ if (!DST.ob_state_obinfo_init) {
+ DST.ob_state_obinfo_init = true;
+ DRWObjectInfos *ob_infos = DRW_memblock_elem_from_handle(DST.vmempool->obinfos,
+ &DST.ob_handle);
- drw_call_obinfos_init(ob_infos, ob);
- }
+ drw_call_obinfos_init(ob_infos, ob);
}
-
- return DST.ob_handle;
}
+
+ return DST.ob_handle;
}
static void command_type_set(uint64_t *command_type_bits, int index, eDRWCommandType type)
@@ -1292,13 +1290,10 @@ static DRWShadingGroup *drw_shgroup_material_create_ex(GPUPass *gpupass, DRWPass
}
static void drw_shgroup_material_texture(DRWShadingGroup *grp,
- GPUMaterialTexture *tex,
+ GPUTexture *gputex,
const char *name,
- eGPUSamplerState state,
- eGPUTextureTarget textarget)
+ eGPUSamplerState state)
{
- GPUTexture *gputex = GPU_texture_from_blender(tex->ima, tex->iuser, NULL, textarget);
-
DRW_shgroup_uniform_texture_ex(grp, name, gputex, state);
GPUTexture **gputex_ref = BLI_memblock_alloc(DST.vmempool->images);
@@ -1314,15 +1309,16 @@ void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, struct GPUMaterial
LISTBASE_FOREACH (GPUMaterialTexture *, tex, &textures) {
if (tex->ima) {
/* Image */
+ GPUTexture *gputex;
if (tex->tiled_mapping_name[0]) {
- drw_shgroup_material_texture(
- grp, tex, tex->sampler_name, tex->sampler_state, TEXTARGET_2D_ARRAY);
- drw_shgroup_material_texture(
- grp, tex, tex->tiled_mapping_name, tex->sampler_state, TEXTARGET_TILE_MAPPING);
+ gputex = BKE_image_get_gpu_tiles(tex->ima, tex->iuser, NULL);
+ drw_shgroup_material_texture(grp, gputex, tex->sampler_name, tex->sampler_state);
+ gputex = BKE_image_get_gpu_tilemap(tex->ima, tex->iuser, NULL);
+ drw_shgroup_material_texture(grp, gputex, tex->tiled_mapping_name, tex->sampler_state);
}
else {
- drw_shgroup_material_texture(
- grp, tex, tex->sampler_name, tex->sampler_state, TEXTARGET_2D);
+ gputex = BKE_image_get_gpu_texture(tex->ima, tex->iuser, NULL);
+ drw_shgroup_material_texture(grp, gputex, tex->sampler_name, tex->sampler_state);
}
}
else if (tex->colorband) {
@@ -1870,7 +1866,7 @@ void DRW_view_clip_planes_set(DRWView *view, float (*planes)[4], int plane_len)
BLI_assert(plane_len <= MAX_CLIP_PLANES);
view->clip_planes_len = plane_len;
if (plane_len > 0) {
- memcpy(view->storage.clipplanes, planes, sizeof(float) * 4 * plane_len);
+ memcpy(view->storage.clipplanes, planes, sizeof(float[4]) * plane_len);
}
}
@@ -1906,9 +1902,8 @@ float DRW_view_near_distance_get(const DRWView *view)
if (DRW_view_is_persp_get(view)) {
return -projmat[3][2] / (projmat[2][2] - 1.0f);
}
- else {
- return -(projmat[3][2] + 1.0f) / projmat[2][2];
- }
+
+ return -(projmat[3][2] + 1.0f) / projmat[2][2];
}
float DRW_view_far_distance_get(const DRWView *view)
@@ -1919,9 +1914,8 @@ float DRW_view_far_distance_get(const DRWView *view)
if (DRW_view_is_persp_get(view)) {
return -projmat[3][2] / (projmat[2][2] + 1.0f);
}
- else {
- return -(projmat[3][2] - 1.0f) / projmat[2][2];
- }
+
+ return -(projmat[3][2] - 1.0f) / projmat[2][2];
}
void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse)
@@ -2028,18 +2022,16 @@ static int pass_shgroup_dist_sort(const void *a, const void *b)
if (shgrp_a->z_sorting.distance < shgrp_b->z_sorting.distance) {
return 1;
}
- else if (shgrp_a->z_sorting.distance > shgrp_b->z_sorting.distance) {
+ if (shgrp_a->z_sorting.distance > shgrp_b->z_sorting.distance) {
return -1;
}
- else {
- /* If distances are the same, keep original order. */
- if (shgrp_a->z_sorting.original_index > shgrp_b->z_sorting.original_index) {
- return -1;
- }
- else {
- return 0;
- }
+
+ /* If distances are the same, keep original order. */
+ if (shgrp_a->z_sorting.original_index > shgrp_b->z_sorting.original_index) {
+ return -1;
}
+
+ return 0;
}
/* ------------------ Shading group sorting --------------------- */
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index b6f51ada5a1..e3860b1bfb2 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -446,6 +446,7 @@ void DRW_state_reset(void)
DRW_state_reset_ex(DRW_STATE_DEFAULT);
GPU_texture_unbind_all();
+ GPU_uniformbuffer_unbind_all();
/* Should stay constant during the whole rendering. */
GPU_point_size(5);
@@ -517,7 +518,7 @@ static bool draw_culling_box_test(const float (*frustum_planes)[4], const BoundB
* Go to next plane. */
break;
}
- else if (v == 7) {
+ if (v == 7) {
/* 8 points behind this plane. */
return false;
}
@@ -591,7 +592,7 @@ void DRW_culling_frustum_corners_get(const DRWView *view, BoundBox *corners)
void DRW_culling_frustum_planes_get(const DRWView *view, float planes[6][4])
{
view = view ? view : DST.view_default;
- memcpy(planes, view->frustum_planes, sizeof(float) * 6 * 4);
+ memcpy(planes, view->frustum_planes, sizeof(float[6][4]));
}
static void draw_compute_culling(DRWView *view)
@@ -669,8 +670,7 @@ BLI_INLINE void draw_geometry_bind(DRWShadingGroup *shgroup, GPUBatch *geom)
DST.batch = geom;
- GPU_batch_program_set_no_use(
- geom, GPU_shader_get_program(shgroup->shader), GPU_shader_get_interface(shgroup->shader));
+ GPU_batch_set_shader_no_bind(geom, shgroup->shader);
geom->program_in_use = true; /* XXX hacking #GPUBatch */
@@ -773,10 +773,11 @@ static bool ubo_bindings_validate(DRWShadingGroup *shgroup)
DRWPass *parent_pass = DRW_memblock_elem_from_handle(DST.vmempool->passes,
&shgroup->pass_handle);
- printf("Pass : %s, Shader : %s, Block : %s\n",
+ printf("Pass : %s, Shader : %s, Block : %s, Binding %d\n",
parent_pass->name,
shgroup->shader->name,
- blockname);
+ blockname,
+ binding);
}
}
# endif
@@ -994,9 +995,8 @@ static void draw_call_single_do(DRWShadingGroup *shgroup,
draw_select_buffer(shgroup, state, batch, &handle);
return;
}
- else {
- GPU_select_load_id(state->select_id);
- }
+
+ GPU_select_load_id(state->select_id);
}
draw_geometry_execute(shgroup,
@@ -1106,6 +1106,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
/* Unbinding can be costly. Skip in normal condition. */
if (G.debug & G_DEBUG_GPU) {
GPU_texture_unbind_all();
+ GPU_uniformbuffer_unbind_all();
}
}
GPU_shader_bind(shgroup->shader);
diff --git a/source/blender/draw/intern/draw_manager_profiling.h b/source/blender/draw/intern/draw_manager_profiling.h
index 3da6a4c8b1c..3842bdffaff 100644
--- a/source/blender/draw/intern/draw_manager_profiling.h
+++ b/source/blender/draw/intern/draw_manager_profiling.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __DRAW_MANAGER_PROFILING_H__
-#define __DRAW_MANAGER_PROFILING_H__
+#pragma once
struct rcti;
@@ -36,5 +35,3 @@ void DRW_stats_query_start(const char *name);
void DRW_stats_query_end(void);
void DRW_stats_draw(const rcti *rect);
-
-#endif /* __DRAW_MANAGER_PROFILING_H__ */
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 0bb20631537..1c260721efb 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -34,6 +34,7 @@
#include "DEG_depsgraph_query.h"
+#include "GPU_extensions.h"
#include "GPU_material.h"
#include "GPU_shader.h"
@@ -106,6 +107,12 @@ static void drw_deferred_shader_compilation_exec(
BLI_assert(gl_context != NULL);
#endif
+ const bool use_main_context_workaround = GPU_use_main_context_workaround();
+ if (use_main_context_workaround) {
+ BLI_assert(gl_context == DST.gl_context);
+ GPU_context_main_lock();
+ }
+
WM_opengl_context_activate(gl_context);
while (true) {
@@ -154,6 +161,9 @@ static void drw_deferred_shader_compilation_exec(
}
WM_opengl_context_release(gl_context);
+ if (use_main_context_workaround) {
+ GPU_context_main_unlock();
+ }
}
static void drw_deferred_shader_compilation_free(void *custom_data)
@@ -196,6 +206,8 @@ static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred)
GPU_material_compile(mat);
return;
}
+ const bool use_main_context = GPU_use_main_context_workaround();
+ const bool job_own_context = !use_main_context;
DRWDeferredShader *dsh = MEM_callocN(sizeof(DRWDeferredShader), "Deferred Shader");
@@ -227,7 +239,7 @@ static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred)
if (old_comp->gl_context) {
comp->gl_context = old_comp->gl_context;
old_comp->own_context = false;
- comp->own_context = true;
+ comp->own_context = job_own_context;
}
}
@@ -235,9 +247,14 @@ static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred)
/* Create only one context. */
if (comp->gl_context == NULL) {
- comp->gl_context = WM_opengl_context_create();
- WM_opengl_context_activate(DST.gl_context);
- comp->own_context = true;
+ if (use_main_context) {
+ comp->gl_context = DST.gl_context;
+ }
+ else {
+ comp->gl_context = WM_opengl_context_create();
+ WM_opengl_context_activate(DST.gl_context);
+ }
+ comp->own_context = job_own_context;
}
WM_jobs_customdata_set(wm_job, comp, drw_deferred_shader_compilation_free);
@@ -430,7 +447,8 @@ GPUMaterial *DRW_shader_create_from_world(struct Scene *scene,
const char *geom,
const char *frag_lib,
const char *defines,
- bool deferred)
+ bool deferred,
+ GPUMaterialEvalCallbackFn callback)
{
GPUMaterial *mat = NULL;
if (DRW_state_is_image_render() || !deferred) {
@@ -450,7 +468,8 @@ GPUMaterial *DRW_shader_create_from_world(struct Scene *scene,
geom,
frag_lib,
defines,
- wo->id.name);
+ wo->id.name,
+ callback);
}
if (GPU_material_status(mat) == GPU_MAT_QUEUED) {
@@ -470,7 +489,8 @@ GPUMaterial *DRW_shader_create_from_material(struct Scene *scene,
const char *geom,
const char *frag_lib,
const char *defines,
- bool deferred)
+ bool deferred,
+ GPUMaterialEvalCallbackFn callback)
{
GPUMaterial *mat = NULL;
if (DRW_state_is_image_render() || !deferred) {
@@ -490,7 +510,8 @@ GPUMaterial *DRW_shader_create_from_material(struct Scene *scene,
geom,
frag_lib,
defines,
- ma->id.name);
+ ma->id.name,
+ callback);
}
if (GPU_material_status(mat) == GPU_MAT_QUEUED) {
diff --git a/source/blender/draw/intern/draw_manager_text.h b/source/blender/draw/intern/draw_manager_text.h
index 66ef2379e38..f6dff335f1f 100644
--- a/source/blender/draw/intern/draw_manager_text.h
+++ b/source/blender/draw/intern/draw_manager_text.h
@@ -20,8 +20,7 @@
* \ingroup draw
*/
-#ifndef __DRAW_MANAGER_TEXT_H__
-#define __DRAW_MANAGER_TEXT_H__
+#pragma once
struct ARegion;
struct DRWTextStore;
@@ -58,5 +57,3 @@ enum {
/* draw_manager.c */
struct DRWTextStore *DRW_text_cache_ensure(void);
-
-#endif /* __DRAW_MANAGER_TEXT_H__ */
diff --git a/source/blender/draw/intern/draw_manager_texture.c b/source/blender/draw/intern/draw_manager_texture.c
index 77b0462303d..b94a6db3bad 100644
--- a/source/blender/draw/intern/draw_manager_texture.c
+++ b/source/blender/draw/intern/draw_manager_texture.c
@@ -61,6 +61,10 @@ static bool drw_texture_format_supports_framebuffer(eGPUTextureFormat format)
void drw_texture_set_parameters(GPUTexture *tex, DRWTextureFlag flags)
{
+ if (tex == NULL) {
+ return;
+ }
+
if (flags & DRW_TEX_MIPMAP) {
GPU_texture_mipmap_mode(tex, true, flags & DRW_TEX_FILTER);
GPU_texture_bind(tex, 0);
@@ -119,7 +123,6 @@ GPUTexture *DRW_texture_create_cube(int w,
{
GPUTexture *tex = GPU_texture_create_cube(w, format, fpixels, NULL);
drw_texture_set_parameters(tex, flags);
-
return tex;
}
@@ -128,7 +131,6 @@ GPUTexture *DRW_texture_create_cube_array(
{
GPUTexture *tex = GPU_texture_create_cube_array(w, d, format, fpixels, NULL);
drw_texture_set_parameters(tex, flags);
-
return tex;
}
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 3c470f802ec..1458ff5341c 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -88,7 +88,7 @@ static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, Vie
/* no exception met? then don't draw cursor! */
return false;
}
- else if (draw_ctx->object_mode & OB_MODE_WEIGHT_GPENCIL) {
+ if (draw_ctx->object_mode & OB_MODE_WEIGHT_GPENCIL) {
/* grease pencil hide always in some modes */
return false;
}
@@ -184,8 +184,7 @@ void DRW_draw_cursor(void)
GPUBatch *cursor_batch = DRW_cache_cursor_get(is_aligned);
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR);
- GPU_batch_program_set(
- cursor_batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader));
+ GPU_batch_set_shader(cursor_batch, shader);
GPU_batch_draw(cursor_batch);
diff --git a/source/blender/draw/intern/draw_view.h b/source/blender/draw/intern/draw_view.h
index 04f7d2bbabb..a01a2d0dcce 100644
--- a/source/blender/draw/intern/draw_view.h
+++ b/source/blender/draw/intern/draw_view.h
@@ -20,13 +20,10 @@
* \ingroup draw
*/
-#ifndef __DRAW_VIEW_H__
-#define __DRAW_VIEW_H__
+#pragma once
void DRW_draw_region_info(void);
void DRW_clear_background(void);
void DRW_draw_cursor(void);
void DRW_draw_gizmo_3d(void);
void DRW_draw_gizmo_2d(void);
-
-#endif /* __DRAW_VIEW_H__ */
diff --git a/source/blender/draw/intern/shaders/common_hair_lib.glsl b/source/blender/draw/intern/shaders/common_hair_lib.glsl
index ffff631e34b..8684d82f228 100644
--- a/source/blender/draw/intern/shaders/common_hair_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_hair_lib.glsl
@@ -95,7 +95,7 @@ void hair_get_interp_attrs(
* For final drawing, the vertex index and the number of vertex per segment
*/
-#ifndef HAIR_PHASE_SUBDIV
+#if !defined(HAIR_PHASE_SUBDIV) && defined(GPU_VERTEX_SHADER)
int hair_get_strand_id(void)
{
return gl_VertexID / (hairStrandsRes * hairThicknessRes);
@@ -206,4 +206,24 @@ vec3 hair_get_strand_pos(void)
return texelFetch(hairPointBuffer, id).point_position;
}
+vec2 hair_get_barycentric(void)
+{
+ /* To match cycles without breaking into individual segment we encode if we need to invert
+ * the first component into the second component. We invert if the barycentricTexCo.y
+ * is NOT 0.0 or 1.0. */
+ int id = hair_get_base_id();
+ return vec2(float((id % 2) == 1), float(((id % 4) % 3) > 0));
+}
+
#endif
+
+/* To be fed the result of hair_get_barycentric from vertex shader. */
+vec2 hair_resolve_barycentric(vec2 vert_barycentric)
+{
+ if (fract(vert_barycentric.y) != 0.0) {
+ return vec2(vert_barycentric.x, 0.0);
+ }
+ else {
+ return vec2(1.0 - vert_barycentric.x, 0.0);
+ }
+}
diff --git a/source/blender/draw/intern/shaders/common_math_geom_lib.glsl b/source/blender/draw/intern/shaders/common_math_geom_lib.glsl
index e337376d7c4..643d7e7d942 100644
--- a/source/blender/draw/intern/shaders/common_math_geom_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_math_geom_lib.glsl
@@ -116,4 +116,4 @@ vec3 normal_decode(vec2 enc, vec3 view)
return n;
}
-/** \} */ \ No newline at end of file
+/** \} */
diff --git a/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl b/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl
index 36b67f2bd60..625e8bb1ff8 100644
--- a/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl
@@ -36,4 +36,4 @@ vec3 pointcloud_get_pos(void)
vec3 outpos, outnor;
pointcloud_get_pos_and_nor(outpos, outnor);
return outpos;
-} \ No newline at end of file
+}
diff --git a/source/blender/draw/intern/shaders/common_view_lib.glsl b/source/blender/draw/intern/shaders/common_view_lib.glsl
index 095bc64a19e..73c112fe3fb 100644
--- a/source/blender/draw/intern/shaders/common_view_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_view_lib.glsl
@@ -22,6 +22,16 @@ layout(std140) uniform viewBlock
vec4 CameraTexCoFactors;
};
+#define ViewNear (ViewVecs[0].w)
+#define ViewFar (ViewVecs[1].w)
+
+#define cameraForward ViewMatrixInverse[2].xyz
+#define cameraPos ViewMatrixInverse[3].xyz
+#define cameraVec \
+ ((ProjectionMatrix[3][3] == 0.0) ? normalize(cameraPos - worldPosition) : cameraForward)
+#define viewCameraVec \
+ ((ProjectionMatrix[3][3] == 0.0) ? normalize(-viewPosition) : vec3(0.0, 0.0, 1.0))
+
#ifdef world_clip_planes_calc_clip_distance
# undef world_clip_planes_calc_clip_distance
# define world_clip_planes_calc_clip_distance(p) \
@@ -75,7 +85,7 @@ vec4 pack_line_data(vec2 frag_co, vec2 edge_start, vec2 edge_pos)
uniform int resourceChunk;
#ifdef GPU_VERTEX_SHADER
-# ifdef GL_ARB_shader_draw_parameters
+# ifdef GPU_ARB_shader_draw_parameters
# define baseInstance gl_BaseInstanceARB
# else /* no ARB_shader_draw_parameters */
uniform int baseInstance;
@@ -104,10 +114,13 @@ uniform int resourceId;
/* Use this to declare and pass the value if
* the fragment shader uses the resource_id. */
-# define RESOURCE_ID_VARYING flat out int resourceIDFrag;
-# define RESOURCE_ID_VARYING_GEOM flat out int resourceIDGeom;
-# define PASS_RESOURCE_ID resourceIDFrag = resource_id;
-# define PASS_RESOURCE_ID_GEOM resourceIDGeom = resource_id;
+# ifdef USE_GEOMETRY_SHADER
+# define RESOURCE_ID_VARYING flat out int resourceIDGeom;
+# define PASS_RESOURCE_ID resourceIDGeom = resource_id;
+# else
+# define RESOURCE_ID_VARYING flat out int resourceIDFrag;
+# define PASS_RESOURCE_ID resourceIDFrag = resource_id;
+# endif
#endif
/* If used in a fragment / geometry shader, we pass
@@ -118,7 +131,7 @@ uniform int resourceId;
flat in int resourceIDGeom[];
# define resource_id resourceIDGeom
-# define PASS_RESOURCE_ID(i) resourceIDFrag = resource_id[i];
+# define PASS_RESOURCE_ID resourceIDFrag = resource_id[0];
#endif
#ifdef GPU_FRAGMENT_SHADER
@@ -171,9 +184,12 @@ uniform mat4 ModelMatrixInverse;
* Note: This is only valid because we are only using the mat3 of the ViewMatrixInverse.
* ViewMatrix * transpose(ModelMatrixInverse)
**/
-#define normal_object_to_view(n) (mat3(ViewMatrix) * (transpose(mat3(ModelMatrixInverse)) * n))
-#define normal_object_to_world(n) (transpose(mat3(ModelMatrixInverse)) * n)
-#define normal_world_to_object(n) (transpose(mat3(ModelMatrix)) * n)
+#define NormalMatrix transpose(mat3(ModelMatrixInverse))
+#define NormalMatrixInverse transpose(mat3(ModelMatrix))
+
+#define normal_object_to_view(n) (mat3(ViewMatrix) * (NormalMatrix * n))
+#define normal_object_to_world(n) (NormalMatrix * n)
+#define normal_world_to_object(n) (NormalMatrixInverse * n)
#define normal_world_to_view(n) (mat3(ViewMatrix) * n)
#define normal_view_to_world(n) (mat3(ViewMatrixInverse) * n)
@@ -199,3 +215,78 @@ uniform mat4 ModelMatrixInverse;
#define DRW_BASE_FROM_DUPLI (1 << 2)
#define DRW_BASE_FROM_SET (1 << 3)
#define DRW_BASE_ACTIVE (1 << 4)
+
+/* ---- Opengl Depth conversion ---- */
+
+float linear_depth(bool is_persp, float z, float zf, float zn)
+{
+ if (is_persp) {
+ return (zn * zf) / (z * (zn - zf) + zf);
+ }
+ else {
+ return (z * 2.0 - 1.0) * zf;
+ }
+}
+
+float buffer_depth(bool is_persp, float z, float zf, float zn)
+{
+ if (is_persp) {
+ return (zf * (zn - z)) / (z * (zn - zf));
+ }
+ else {
+ return (z / (zf * 2.0)) + 0.5;
+ }
+}
+
+float get_view_z_from_depth(float depth)
+{
+ if (ProjectionMatrix[3][3] == 0.0) {
+ float d = 2.0 * depth - 1.0;
+ return -ProjectionMatrix[3][2] / (d + ProjectionMatrix[2][2]);
+ }
+ else {
+ return ViewVecs[0].z + depth * ViewVecs[1].z;
+ }
+}
+
+float get_depth_from_view_z(float z)
+{
+ if (ProjectionMatrix[3][3] == 0.0) {
+ float d = (-ProjectionMatrix[3][2] / z) - ProjectionMatrix[2][2];
+ return d * 0.5 + 0.5;
+ }
+ else {
+ return (z - ViewVecs[0].z) / ViewVecs[1].z;
+ }
+}
+
+vec2 get_uvs_from_view(vec3 view)
+{
+ vec4 ndc = ProjectionMatrix * vec4(view, 1.0);
+ return (ndc.xy / ndc.w) * 0.5 + 0.5;
+}
+
+vec3 get_view_space_from_depth(vec2 uvcoords, float depth)
+{
+ if (ProjectionMatrix[3][3] == 0.0) {
+ return vec3(ViewVecs[0].xy + uvcoords * ViewVecs[1].xy, 1.0) * get_view_z_from_depth(depth);
+ }
+ else {
+ return ViewVecs[0].xyz + vec3(uvcoords, depth) * ViewVecs[1].xyz;
+ }
+}
+
+vec3 get_world_space_from_depth(vec2 uvcoords, float depth)
+{
+ return (ViewMatrixInverse * vec4(get_view_space_from_depth(uvcoords, depth), 1.0)).xyz;
+}
+
+vec3 get_view_vector_from_screen_uv(vec2 uv)
+{
+ if (ProjectionMatrix[3][3] == 0.0) {
+ return normalize(vec3(ViewVecs[0].xy + uv * ViewVecs[1].xy, 1.0));
+ }
+ else {
+ return vec3(0.0, 0.0, 1.0);
+ }
+}
diff --git a/source/blender/draw/intern/smaa_textures.h b/source/blender/draw/intern/smaa_textures.h
index 43b29340cac..7556f3a1952 100644
--- a/source/blender/draw/intern/smaa_textures.h
+++ b/source/blender/draw/intern/smaa_textures.h
@@ -26,8 +26,7 @@
* SOFTWARE.
*/
-#ifndef __SMAA_TEXTURES_H__
-#define __SMAA_TEXTURES_H__
+#pragma once
#define AREATEX_WIDTH 160
#define AREATEX_HEIGHT 560
@@ -15083,4 +15082,3 @@ static const unsigned char searchTexBytes[] = {
/* clang-format off */
-#endif /* __SMAA_TEXTURES_H__ */
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 4cbea0ded15..b2f687b49af 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -398,9 +398,9 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo
correct_bezpart(v1, v2, v3, v4);
BKE_curve_forward_diff_bezier(
- v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3);
+ v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float[3]));
BKE_curve_forward_diff_bezier(
- v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3);
+ v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float[3]));
for (int j = 0; j <= resol; ++j) {
const float *fp = &data[j * 3];
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 50733afe6fb..8280b58c21a 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -427,7 +427,7 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
ac->spacetype = (area) ? area->spacetype : 0;
ac->regiontype = (region) ? region->regiontype : 0;
- /* initialise default y-scale factor */
+ /* Initialize default y-scale factor. */
animedit_get_yscale_factor(ac);
/* get data context info */
diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h
index 7fb5540fdf7..fb7b6b8983a 100644
--- a/source/blender/editors/animation/anim_intern.h
+++ b/source/blender/editors/animation/anim_intern.h
@@ -21,8 +21,7 @@
* \ingroup edanimation
*/
-#ifndef __ANIM_INTERN_H__
-#define __ANIM_INTERN_H__
+#pragma once
/* KeyingSets/Keyframing Interface ------------- */
@@ -77,5 +76,3 @@ void ANIM_OT_driver_button_remove(struct wmOperatorType *ot);
void ANIM_OT_driver_button_edit(struct wmOperatorType *ot);
void ANIM_OT_copy_driver_button(struct wmOperatorType *ot);
void ANIM_OT_paste_driver_button(struct wmOperatorType *ot);
-
-#endif /* __ANIM_INTERN_H__ */
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 08d82bf13c9..9a04425a083 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -21,8 +21,7 @@
* \ingroup edarmature
*/
-#ifndef __ARMATURE_INTERN_H__
-#define __ARMATURE_INTERN_H__
+#pragma once
/* internal exports only */
struct wmOperatorType;
@@ -289,5 +288,3 @@ int bone_looper(struct Object *ob,
struct Bone *bone,
void *data,
int (*bone_func)(struct Object *, struct Bone *, void *));
-
-#endif /* __ARMATURE_INTERN_H__ */
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 0dd35fb9fdc..a737916e9a2 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -384,6 +384,7 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op)
BLI_remlink(curarm->edbo, curbone);
BLI_addtail(arm->edbo, curbone);
+ /* Pose channel is moved from one storage to another, its UUID is still unique. */
BLI_remlink(&opose->chanbase, pchan);
BLI_addtail(&pose->chanbase, pchan);
BKE_pose_channels_hash_free(opose);
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index b3c58f2575b..ea9b0eb92b9 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -342,9 +342,9 @@ static void add_verts_to_dgroups(ReportList *reports,
/* create an array of root and tip positions transformed into
* global coords */
- root = MEM_callocN(numbones * sizeof(float) * 3, "root");
- tip = MEM_callocN(numbones * sizeof(float) * 3, "tip");
- selected = MEM_callocN(numbones * sizeof(int), "selected");
+ root = MEM_callocN(sizeof(float[3]) * numbones, "root");
+ tip = MEM_callocN(sizeof(float[3]) * numbones, "tip");
+ selected = MEM_callocN(sizeof(int) * numbones, "selected");
for (j = 0; j < numbones; j++) {
bone = bonelist[j];
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index b2e329deee7..04c1ec97841 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -229,7 +229,7 @@ EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const ui
return NULL;
}
-void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3])
+void ED_armature_ebone_to_mat3(EditBone *ebone, float r_mat[3][3])
{
float delta[3], roll;
@@ -246,20 +246,20 @@ void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3])
}
}
- vec_roll_to_mat3_normalized(delta, roll, mat);
+ vec_roll_to_mat3_normalized(delta, roll, r_mat);
}
-void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4])
+void ED_armature_ebone_to_mat4(EditBone *ebone, float r_mat[4][4])
{
float m3[3][3];
ED_armature_ebone_to_mat3(ebone, m3);
- copy_m4_m3(mat, m3);
- copy_v3_v3(mat[3], ebone->head);
+ copy_m4_m3(r_mat, m3);
+ copy_v3_v3(r_mat[3], ebone->head);
}
-void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3])
+void ED_armature_ebone_from_mat3(EditBone *ebone, const float mat[3][3])
{
float vec[3], roll;
const float len = len_v3v3(ebone->head, ebone->tail);
@@ -270,7 +270,7 @@ void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3])
ebone->roll = roll;
}
-void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4])
+void ED_armature_ebone_from_mat4(EditBone *ebone, const float mat[4][4])
{
float mat3[3][3];
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index 11066595e2e..75ffd31854a 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -223,7 +223,7 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac
sys->verts = MEM_callocN(sizeof(float *) * totvert, "LaplacianSystemVerts");
sys->vpinned = MEM_callocN(sizeof(char) * totvert, "LaplacianSystemVpinned");
- sys->faces = MEM_callocN(sizeof(int) * 3 * totface, "LaplacianSystemFaces");
+ sys->faces = MEM_callocN(sizeof(int[3]) * totface, "LaplacianSystemFaces");
sys->totvert = 0;
sys->totface = 0;
@@ -296,7 +296,7 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
}
if (sys->storeweights) {
- sys->fweights = MEM_callocN(sizeof(float) * 3 * totface, "LaplacianFWeight");
+ sys->fweights = MEM_callocN(sizeof(float[3]) * totface, "LaplacianFWeight");
}
for (a = 0, face = sys->faces; a < totface; a++, face++) {
@@ -568,7 +568,7 @@ static void heat_calc_vnormals(LaplacianSystem *sys)
float fnor[3];
int a, v1, v2, v3, (*face)[3];
- sys->heat.vnors = MEM_callocN(sizeof(float) * 3 * sys->totvert, "HeatVNors");
+ sys->heat.vnors = MEM_callocN(sizeof(float[3]) * sys->totvert, "HeatVNors");
for (a = 0, face = sys->faces; a < sys->totface; a++, face++) {
v1 = (*face)[0];
@@ -1762,7 +1762,7 @@ void ED_mesh_deform_bind_callback(MeshDeformModifierData *mmd,
memset(&mdb, 0, sizeof(MeshDeformBind));
/* get mesh and cage mesh */
- mdb.vertexcos = MEM_callocN(sizeof(float) * 3 * totvert, "MeshDeformCos");
+ mdb.vertexcos = MEM_callocN(sizeof(float[3]) * totvert, "MeshDeformCos");
mdb.totvert = totvert;
mdb.cagemesh = cagemesh;
diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h
index 0a9e6e878e4..0405e361b2f 100644
--- a/source/blender/editors/armature/meshlaplacian.h
+++ b/source/blender/editors/armature/meshlaplacian.h
@@ -20,8 +20,7 @@
* \ingroup edarmature
*/
-#ifndef __MESHLAPLACIAN_H__
-#define __MESHLAPLACIAN_H__
+#pragma once
//#define RIGID_DEFORM
@@ -70,5 +69,3 @@ void rigid_deform_end(int cancel);
/* Harmonic Coordinates */
/* ED_mesh_deform_bind_callback(...) defined in ED_armature.h */
-
-#endif
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 8df9c99896e..e60270bc3f0 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -251,7 +251,7 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode)
*/
BLI_dlrbTree_init(&pso->keys);
- /* initialise numeric input */
+ /* Initialize numeric input. */
initNumInput(&pso->num);
pso->num.idx_max = 0; /* one axis */
pso->num.val_flag[0] |= NUM_NO_NEGATIVE;
@@ -1310,7 +1310,7 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev
pso = op->customdata;
- /* initialise percentage so that it won't pop on first mouse move */
+ /* Initialize percentage so that it won't pop on first mouse move. */
pose_slide_mouse_update_percentage(pso, op, event);
/* do common setup work */
@@ -1370,7 +1370,7 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e
pso = op->customdata;
- /* initialise percentage so that it won't pop on first mouse move */
+ /* Initialize percentage so that it won't pop on first mouse move. */
pose_slide_mouse_update_percentage(pso, op, event);
/* do common setup work */
@@ -1429,7 +1429,7 @@ static int pose_slide_push_rest_invoke(bContext *C, wmOperator *op, const wmEven
pso = op->customdata;
- /* initialise percentage so that it won't pop on first mouse move */
+ /* Initialize percentage so that it won't pop on first mouse move. */
pose_slide_mouse_update_percentage(pso, op, event);
/* do common setup work */
@@ -1489,7 +1489,7 @@ static int pose_slide_relax_rest_invoke(bContext *C, wmOperator *op, const wmEve
pso = op->customdata;
- /* initialise percentage so that it won't pop on first mouse move */
+ /* Initialize percentage so that it won't pop on first mouse move. */
pose_slide_mouse_update_percentage(pso, op, event);
/* do common setup work */
@@ -1549,7 +1549,7 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven
pso = op->customdata;
- /* initialise percentage so that it won't pop on first mouse move */
+ /* Initialize percentage so that it won't pop on first mouse move. */
pose_slide_mouse_update_percentage(pso, op, event);
/* do common setup work */
diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h
index 7d0a2e5edbc..4426739e421 100644
--- a/source/blender/editors/curve/curve_intern.h
+++ b/source/blender/editors/curve/curve_intern.h
@@ -21,8 +21,7 @@
* \ingroup edcurve
*/
-#ifndef __CURVE_INTERN_H__
-#define __CURVE_INTERN_H__
+#pragma once
/* internal exports only */
struct EditNurb;
@@ -194,5 +193,3 @@ void ED_curve_nurb_vert_selected_find(
/* editcurve_paint.c */
void CURVE_OT_draw(struct wmOperatorType *ot);
-
-#endif /* __CURVE_INTERN_H__ */
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 91a8ea0fa3a..d113e0693a4 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -569,14 +569,14 @@ GHash *ED_curve_keyindex_hash_duplicate(GHash *keyindex)
static void key_to_bezt(float *key, BezTriple *basebezt, BezTriple *bezt)
{
memcpy(bezt, basebezt, sizeof(BezTriple));
- memcpy(bezt->vec, key, sizeof(float) * 9);
+ memcpy(bezt->vec, key, sizeof(float[9]));
bezt->tilt = key[9];
bezt->radius = key[10];
}
static void bezt_to_key(BezTriple *bezt, float *key)
{
- memcpy(key, bezt->vec, sizeof(float) * 9);
+ memcpy(key, bezt->vec, sizeof(float[9]));
key[9] = bezt->tilt;
key[10] = bezt->radius;
}
@@ -691,7 +691,7 @@ static void calc_shapeKeys(Object *obedit, ListBase *newnurbs)
nu = nu->next;
}
- ofs = MEM_callocN(sizeof(float) * 3 * totvec, "currkey->data");
+ ofs = MEM_callocN(sizeof(float[3]) * totvec, "currkey->data");
nu = editnurb->nurbs.first;
i = 0;
while (nu) {
@@ -1137,7 +1137,7 @@ int ED_curve_updateAnimPaths(Main *bmain, Curve *cu)
/** \name Edit Mode Conversion (Make & Load)
* \{ */
-static int *initialize_index_map(Object *obedit, int *r_old_totvert)
+static int *init_index_map(Object *obedit, int *r_old_totvert)
{
Curve *curve = (Curve *)obedit->data;
EditNurb *editnurb = curve->editnurb;
@@ -1225,7 +1225,7 @@ static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
if ((object->parent) && (object->parent->data == curve) &&
ELEM(object->partype, PARVERT1, PARVERT3)) {
if (old_to_new_map == NULL) {
- old_to_new_map = initialize_index_map(obedit, &old_totvert);
+ old_to_new_map = init_index_map(obedit, &old_totvert);
}
if (object->par1 < old_totvert) {
@@ -1254,7 +1254,7 @@ static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit)
int i, j;
if (old_to_new_map == NULL) {
- old_to_new_map = initialize_index_map(obedit, &old_totvert);
+ old_to_new_map = init_index_map(obedit, &old_totvert);
}
for (i = j = 0; i < hmd->totindex; i++) {
@@ -1716,7 +1716,10 @@ static bool isNurbselV(Nurb *nu, int *u, int flag)
return 1;
}
-static void rotateflagNurb(ListBase *editnurb, short flag, const float cent[3], float rotmat[3][3])
+static void rotateflagNurb(ListBase *editnurb,
+ short flag,
+ const float cent[3],
+ const float rotmat[3][3])
{
/* all verts with (flag & 'flag') rotate */
Nurb *nu;
@@ -3495,7 +3498,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, nextbezt)) {
float prevvec[3][3];
- memcpy(prevvec, bezt->vec, sizeof(float) * 9);
+ memcpy(prevvec, bezt->vec, sizeof(float[9]));
for (i = 0; i < number_cuts; i++) {
factor = 1.0f / (number_cuts + 1 - i);
@@ -3527,7 +3530,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
beztn->radius = (bezt->radius + nextbezt->radius) / 2;
beztn->weight = (bezt->weight + nextbezt->weight) / 2;
- memcpy(prevvec, beztn->vec, sizeof(float) * 9);
+ memcpy(prevvec, beztn->vec, sizeof(float[9]));
beztn++;
}
}
diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c
index bacdd5b69b5..19b05f0af0c 100644
--- a/source/blender/editors/curve/editcurve_add.c
+++ b/source/blender/editors/curve/editcurve_add.c
@@ -153,7 +153,7 @@ Nurb *ED_curve_add_nurbs_primitive(
nu->resolu = cu->resolu;
if (cutype == CU_BEZIER) {
nu->pntsu = 2;
- nu->bezt = (BezTriple *)MEM_callocN(2 * sizeof(BezTriple), "addNurbprim1");
+ nu->bezt = (BezTriple *)MEM_callocN(sizeof(BezTriple) * nu->pntsu, "addNurbprim1");
bezt = nu->bezt;
bezt->h1 = bezt->h2 = HD_ALIGN;
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
@@ -190,7 +190,7 @@ Nurb *ED_curve_add_nurbs_primitive(
nu->pntsu = 4;
nu->pntsv = 1;
nu->orderu = 4;
- nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * 4, "addNurbprim3");
+ nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * nu->pntsu, "addNurbprim3");
bp = nu->bp;
for (a = 0; a < 4; a++, bp++) {
@@ -227,7 +227,7 @@ Nurb *ED_curve_add_nurbs_primitive(
nu->orderu = 5;
nu->flagu = CU_NURB_ENDPOINT; /* endpoint */
nu->resolu = cu->resolu;
- nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * 5, "addNurbprim3");
+ nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * nu->pntsu, "addNurbprim3");
bp = nu->bp;
for (a = 0; a < 5; a++, bp++) {
@@ -262,7 +262,7 @@ Nurb *ED_curve_add_nurbs_primitive(
if (cutype == CU_BEZIER) {
nu->pntsu = 4;
- nu->bezt = (BezTriple *)MEM_callocN(sizeof(BezTriple) * 4, "addNurbprim1");
+ nu->bezt = (BezTriple *)MEM_callocN(sizeof(BezTriple) * nu->pntsu, "addNurbprim1");
nu->flagu = CU_NURB_CYCLIC;
bezt = nu->bezt;
@@ -307,7 +307,7 @@ Nurb *ED_curve_add_nurbs_primitive(
nu->pntsu = 8;
nu->pntsv = 1;
nu->orderu = 4;
- nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * 8, "addNurbprim6");
+ nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * nu->pntsu, "addNurbprim6");
nu->flagu = CU_NURB_CYCLIC;
bp = nu->bp;
@@ -397,8 +397,8 @@ Nurb *ED_curve_add_nurbs_primitive(
break;
case CU_PRIM_SPHERE: /* sphere */
if (cutype == CU_NURBS) {
- float tmp_cent[3] = {0.f, 0.f, 0.f};
- float tmp_vec[3] = {0.f, 0.f, 1.f};
+ const float tmp_cent[3] = {0.f, 0.f, 0.f};
+ const float tmp_vec[3] = {0.f, 0.f, 1.f};
nu->pntsu = 5;
nu->pntsv = 1;
@@ -406,7 +406,7 @@ Nurb *ED_curve_add_nurbs_primitive(
nu->resolu = cu->resolu;
nu->resolv = cu->resolv;
nu->flag = CU_SMOOTH;
- nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * 5, "addNurbprim6");
+ nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * nu->pntsu, "addNurbprim6");
nu->flagu = 0;
bp = nu->bp;
@@ -451,8 +451,8 @@ Nurb *ED_curve_add_nurbs_primitive(
break;
case CU_PRIM_DONUT: /* torus */
if (cutype == CU_NURBS) {
- float tmp_cent[3] = {0.f, 0.f, 0.f};
- float tmp_vec[3] = {0.f, 0.f, 1.f};
+ const float tmp_cent[3] = {0.f, 0.f, 0.f};
+ const float tmp_vec[3] = {0.f, 0.f, 1.f};
xzproj = 1;
nu = ED_curve_add_nurbs_primitive(C, obedit, mat, CU_NURBS | CU_PRIM_CIRCLE, 0);
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index d78c543f94b..4147bb190e2 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -474,7 +474,7 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */
ef->selstart = ef->selend = 0;
}
- return (direction);
+ return direction;
}
/** \} */
@@ -648,7 +648,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
int nchars = 0, nbytes = 0;
char *s;
int a;
- float rot[3] = {0.f, 0.f, 0.f};
+ const float rot[3] = {0.f, 0.f, 0.f};
obedit = BKE_object_add(bmain, scene, view_layer, OB_FONT, NULL);
base = view_layer->basact;
diff --git a/source/blender/editors/gizmo_library/gizmo_geometry.h b/source/blender/editors/gizmo_library/gizmo_geometry.h
index a5f61158f66..70f508df8b6 100644
--- a/source/blender/editors/gizmo_library/gizmo_geometry.h
+++ b/source/blender/editors/gizmo_library/gizmo_geometry.h
@@ -27,8 +27,7 @@
* called geom_xxx_gizmo.c
*/
-#ifndef __GIZMO_GEOMETRY_H__
-#define __GIZMO_GEOMETRY_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -48,5 +47,3 @@ extern GizmoGeomInfo wm_gizmo_geom_data_cube;
/* dial gizmo */
extern GizmoGeomInfo wm_gizmo_geom_data_dial;
-
-#endif /* __GIZMO_GEOMETRY_H__ */
diff --git a/source/blender/editors/gizmo_library/gizmo_library_intern.h b/source/blender/editors/gizmo_library/gizmo_library_intern.h
index 31decb71c77..f3670708543 100644
--- a/source/blender/editors/gizmo_library/gizmo_library_intern.h
+++ b/source/blender/editors/gizmo_library/gizmo_library_intern.h
@@ -21,8 +21,7 @@
* \ingroup edgizmolib
*/
-#ifndef __GIZMO_LIBRARY_INTERN_H__
-#define __GIZMO_LIBRARY_INTERN_H__
+#pragma once
/**
* Data for common interactions. Used in gizmo_library_utils.c functions.
@@ -99,5 +98,3 @@ void wm_gizmo_geometryinfo_draw(const struct GizmoGeomInfo *info,
const float color[4]);
void wm_gizmo_vec_draw(
const float color[4], const float (*verts)[3], uint vert_count, uint pos, uint primitive_type);
-
-#endif /* __GIZMO_LIBRARY_INTERN_H__ */
diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
index f31e004264c..341f43d0662 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
@@ -239,7 +239,7 @@ static int gizmo_arrow_test_select(bContext *UNUSED(C), wmGizmo *gz, const int m
WM_gizmo_calc_matrix_final(gz, matrix_final);
/* Arrow in pixel space. */
- float arrow_start[2] = {matrix_final[3][0], matrix_final[3][1]};
+ const float arrow_start[2] = {matrix_final[3][0], matrix_final[3][1]};
float arrow_end[2];
{
float co[3] = {0, 0, arrow_length};
diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
index 04b93f35681..c5231b3cd96 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
@@ -99,7 +99,7 @@ static void button2d_geom_draw_backdrop(const wmGizmo *gz,
else {
/* Draw fill. */
if ((fill_alpha != 0.0f) || (select == true)) {
- float fill_color[4] = {UNPACK3(color), fill_alpha * color[3]};
+ const float fill_color[4] = {UNPACK3(color), fill_alpha * color[3]};
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor4fv(fill_color);
imm_draw_circle_fill_2d(pos, 0, 0, 1.0f, CIRCLE_RESOLUTION);
diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
index 85f84af5f14..406d66dfd8f 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
@@ -999,7 +999,7 @@ static int gizmo_cage2d_modal(bContext *C,
if (data->dial == NULL) {
MUL_V2_V3_M4_FINAL(test_co, data->orig_matrix_offset[3]);
- data->dial = BLI_dial_initialize(test_co, FLT_EPSILON);
+ data->dial = BLI_dial_init(test_co, FLT_EPSILON);
MUL_V2_V3_M4_FINAL(test_co, data->orig_mouse);
BLI_dial_angle(data->dial, test_co);
diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
index 8955a666e22..0bc65fe10a5 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
@@ -257,7 +257,7 @@ static void cage3d_draw_circle_handles(const RegionView3D *rv3d,
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor3fv(color);
- float sign[3] = {-1.0f, 0.0f, 1.0f};
+ const float sign[3] = {-1.0f, 0.0f, 1.0f};
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
for (int z = 0; z < 3; z++) {
diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
index a3921791427..24943ab5318 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
@@ -78,12 +78,11 @@ typedef struct SnapGizmo3D {
} SnapGizmo3D;
#ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
-static bool invert_snap(const wmGizmo *gz, const wmWindowManager *wm, const wmEvent *event)
+static bool invert_snap(SnapGizmo3D *snap_gizmo, const wmWindowManager *wm, const wmEvent *event)
{
- SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
- wmKeyMap *keymap = WM_keymap_active(wm, gizmo_snap->keymap);
+ wmKeyMap *keymap = WM_keymap_active(wm, snap_gizmo->keymap);
- const int snap_on = gizmo_snap->snap_on;
+ const int snap_on = snap_gizmo->snap_on;
for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (kmi->flag & KMI_INACTIVE) {
continue;
@@ -201,29 +200,34 @@ SnapObjectContext *ED_gizmotypes_snap_3d_context_ensure(Scene *scene,
const View3D *v3d,
wmGizmo *gz)
{
- SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
- if (gizmo_snap->snap_context_v3d == NULL) {
- gizmo_snap->snap_context_v3d = ED_transform_snap_object_context_create_view3d(
+ SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
+ if (snap_gizmo->snap_context_v3d == NULL) {
+ snap_gizmo->snap_context_v3d = ED_transform_snap_object_context_create_view3d(
scene, 0, region, v3d);
}
- return gizmo_snap->snap_context_v3d;
+ return snap_gizmo->snap_context_v3d;
}
bool ED_gizmotypes_snap_3d_invert_snap_get(struct wmGizmo *gz)
{
- SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
- return gizmo_snap->invert_snap;
+#ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
+ SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
+ return snap_gizmo->invert_snap;
+#else
+ return false;
+#endif
}
+
void ED_gizmotypes_snap_3d_toggle_set(wmGizmo *gz, bool enable)
{
- SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
- gizmo_snap->use_snap_override = (int)enable;
+ SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
+ snap_gizmo->use_snap_override = (int)enable;
}
void ED_gizmotypes_snap_3d_toggle_clear(wmGizmo *gz)
{
- SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
- gizmo_snap->use_snap_override = -1;
+ SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
+ snap_gizmo->use_snap_override = -1;
}
short ED_gizmotypes_snap_3d_update(wmGizmo *gz,
@@ -235,29 +239,29 @@ short ED_gizmotypes_snap_3d_update(wmGizmo *gz,
float r_loc[3],
float r_nor[3])
{
- SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
+ SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
Scene *scene = DEG_get_input_scene(depsgraph);
float co[3], no[3];
short snap_elem = 0;
int snap_elem_index[3] = {-1, -1, -1};
int index = -1;
- if (gizmo_snap->use_snap_override != -1) {
- if (gizmo_snap->use_snap_override == false) {
- gizmo_snap->snap_elem = 0;
+ if (snap_gizmo->use_snap_override != -1) {
+ if (snap_gizmo->use_snap_override == false) {
+ snap_gizmo->snap_elem = 0;
return 0;
}
}
#ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
if (wm && wm->winactive) {
- gizmo_snap->invert_snap = invert_snap(gz, wm, wm->winactive->eventstate);
+ snap_gizmo->invert_snap = invert_snap(snap_gizmo, wm, wm->winactive->eventstate);
}
- if (gizmo_snap->use_snap_override == -1) {
+ if (snap_gizmo->use_snap_override == -1) {
const ToolSettings *ts = scene->toolsettings;
- if (gizmo_snap->invert_snap != !(ts->snap_flag & SCE_SNAP)) {
- gizmo_snap->snap_elem = 0;
+ if (snap_gizmo->invert_snap != !(ts->snap_flag & SCE_SNAP)) {
+ snap_gizmo->snap_elem = 0;
return 0;
}
}
@@ -267,8 +271,8 @@ short ED_gizmotypes_snap_3d_update(wmGizmo *gz,
wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "snap_elements");
int snap_elements = RNA_property_enum_get(&gz_prop->ptr, gz_prop->prop);
- if (gz_prop->prop != gizmo_snap->prop_snap_force) {
- int snap_elements_force = RNA_property_enum_get(gz->ptr, gizmo_snap->prop_snap_force);
+ if (gz_prop->prop != snap_gizmo->prop_snap_force) {
+ int snap_elements_force = RNA_property_enum_get(gz->ptr, snap_gizmo->prop_snap_force);
snap_elements |= snap_elements_force;
}
snap_elements &= (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE |
@@ -276,8 +280,8 @@ short ED_gizmotypes_snap_3d_update(wmGizmo *gz,
if (snap_elements) {
float prev_co[3] = {0.0f};
- if (RNA_property_is_set(gz->ptr, gizmo_snap->prop_prevpoint)) {
- RNA_property_float_get_array(gz->ptr, gizmo_snap->prop_prevpoint, prev_co);
+ if (RNA_property_is_set(gz->ptr, snap_gizmo->prop_prevpoint)) {
+ RNA_property_float_get_array(gz->ptr, snap_gizmo->prop_prevpoint, prev_co);
}
else {
snap_elements &= ~SCE_SNAP_MODE_EDGE_PERPENDICULAR;
@@ -286,7 +290,7 @@ short ED_gizmotypes_snap_3d_update(wmGizmo *gz,
float dist_px = 12.0f * U.pixelsize;
ED_gizmotypes_snap_3d_context_ensure(scene, region, v3d, gz);
- snap_elem = ED_transform_snap_object_project_view3d_ex(gizmo_snap->snap_context_v3d,
+ snap_elem = ED_transform_snap_object_project_view3d_ex(snap_gizmo->snap_context_v3d,
depsgraph,
snap_elements,
&(const struct SnapObjectParams){
@@ -320,14 +324,15 @@ short ED_gizmotypes_snap_3d_update(wmGizmo *gz,
snap_elem_index[2] = index;
}
- gizmo_snap->snap_elem = snap_elem;
- RNA_property_float_set_array(gz->ptr, gizmo_snap->prop_location, co);
- RNA_property_float_set_array(gz->ptr, gizmo_snap->prop_normal, no);
- RNA_property_int_set_array(gz->ptr, gizmo_snap->prop_elem_index, snap_elem_index);
+ snap_gizmo->snap_elem = snap_elem;
+ RNA_property_float_set_array(gz->ptr, snap_gizmo->prop_location, co);
+ RNA_property_float_set_array(gz->ptr, snap_gizmo->prop_normal, no);
+ RNA_property_int_set_array(gz->ptr, snap_gizmo->prop_elem_index, snap_elem_index);
if (r_loc) {
copy_v3_v3(r_loc, co);
}
+
if (r_nor) {
copy_v3_v3(r_nor, no);
}
@@ -341,18 +346,18 @@ short ED_gizmotypes_snap_3d_update(wmGizmo *gz,
/** \name GIZMO_GT_snap_3d
* \{ */
-static void gizmo_snap_setup(wmGizmo *gz)
+static void snap_gizmo_setup(wmGizmo *gz)
{
- SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
+ SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
/* For quick access to the props. */
- gizmo_snap->prop_prevpoint = RNA_struct_find_property(gz->ptr, "prev_point");
- gizmo_snap->prop_location = RNA_struct_find_property(gz->ptr, "location");
- gizmo_snap->prop_normal = RNA_struct_find_property(gz->ptr, "normal");
- gizmo_snap->prop_elem_index = RNA_struct_find_property(gz->ptr, "snap_elem_index");
- gizmo_snap->prop_snap_force = RNA_struct_find_property(gz->ptr, "snap_elements_force");
+ snap_gizmo->prop_prevpoint = RNA_struct_find_property(gz->ptr, "prev_point");
+ snap_gizmo->prop_location = RNA_struct_find_property(gz->ptr, "location");
+ snap_gizmo->prop_normal = RNA_struct_find_property(gz->ptr, "normal");
+ snap_gizmo->prop_elem_index = RNA_struct_find_property(gz->ptr, "snap_elem_index");
+ snap_gizmo->prop_snap_force = RNA_struct_find_property(gz->ptr, "snap_elements_force");
- gizmo_snap->use_snap_override = -1;
+ snap_gizmo->use_snap_override = -1;
/* Prop fallback. */
WM_gizmo_target_property_def_rna(gz, "snap_elements", gz->ptr, "snap_elements_force", -1);
@@ -361,10 +366,10 @@ static void gizmo_snap_setup(wmGizmo *gz)
gz->flag |= WM_GIZMO_NO_TOOLTIP;
}
-static void gizmo_snap_draw(const bContext *C, wmGizmo *gz)
+static void snap_gizmo_draw(const bContext *C, wmGizmo *gz)
{
- SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
- if (gizmo_snap->snap_elem == 0) {
+ SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
+ if (snap_gizmo->snap_elem == 0) {
return;
}
@@ -376,22 +381,22 @@ static void gizmo_snap_draw(const bContext *C, wmGizmo *gz)
* And `snap_elem` is not really useful in this case. */
if ((rv3d->rflag & RV3D_NAVIGATING) ||
(!(gz->state & WM_GIZMO_STATE_HIGHLIGHT) && !wm_gizmomap_modal_get(region->gizmo_map))) {
- gizmo_snap->snap_elem = 0;
+ snap_gizmo->snap_elem = 0;
return;
}
float location[3], prev_point_stack[3], *prev_point = NULL;
uchar color_line[4], color_point[4];
- RNA_property_float_get_array(gz->ptr, gizmo_snap->prop_location, location);
+ RNA_property_float_get_array(gz->ptr, snap_gizmo->prop_location, location);
UI_GetThemeColor3ubv(TH_TRANSFORM, color_line);
color_line[3] = 128;
rgba_float_to_uchar(color_point, gz->color);
- if (RNA_property_is_set(gz->ptr, gizmo_snap->prop_prevpoint)) {
- RNA_property_float_get_array(gz->ptr, gizmo_snap->prop_prevpoint, prev_point_stack);
+ if (RNA_property_is_set(gz->ptr, snap_gizmo->prop_prevpoint)) {
+ RNA_property_float_get_array(gz->ptr, snap_gizmo->prop_prevpoint, prev_point_stack);
prev_point = prev_point_stack;
}
@@ -399,35 +404,36 @@ static void gizmo_snap_draw(const bContext *C, wmGizmo *gz)
GPU_line_width(1.0f);
ED_gizmotypes_snap_3d_draw_util(
- rv3d, prev_point, location, NULL, color_line, color_point, gizmo_snap->snap_elem);
+ rv3d, prev_point, location, NULL, color_line, color_point, snap_gizmo->snap_elem);
}
-static int gizmo_snap_test_select(bContext *C, wmGizmo *gz, const int mval[2])
+static int snap_gizmo_test_select(bContext *C, wmGizmo *gz, const int mval[2])
{
- SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
+ SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
#ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
wmWindowManager *wm = CTX_wm_manager(C);
- if (gizmo_snap->keymap == NULL) {
- gizmo_snap->keymap = WM_modalkeymap_find(wm->defaultconf, "Generic Gizmo Tweak Modal Map");
- RNA_enum_value_from_id(gizmo_snap->keymap->modal_items, "SNAP_ON", &gizmo_snap->snap_on);
+ if (snap_gizmo->keymap == NULL) {
+ snap_gizmo->keymap = WM_modalkeymap_find(wm->defaultconf, "Generic Gizmo Tweak Modal Map");
+ RNA_enum_value_from_id(snap_gizmo->keymap->modal_items, "SNAP_ON", &snap_gizmo->snap_on);
}
- const bool invert = wm->winactive ? invert_snap(gz, wm, wm->winactive->eventstate) : false;
- if (gizmo_snap->invert_snap == invert && gizmo_snap->mval[0] == mval[0] &&
- gizmo_snap->mval[1] == mval[1]) {
+ const bool invert = wm->winactive ? invert_snap(snap_gizmo, wm, wm->winactive->eventstate) :
+ false;
+ if (snap_gizmo->invert_snap == invert && snap_gizmo->mval[0] == mval[0] &&
+ snap_gizmo->mval[1] == mval[1]) {
/* Performance, do not update. */
- return gizmo_snap->snap_elem ? 0 : -1;
+ return snap_gizmo->snap_elem ? 0 : -1;
}
- gizmo_snap->invert_snap = invert;
+ snap_gizmo->invert_snap = invert;
#else
- if (gizmo_snap->mval[0] == mval[0] && gizmo_snap->mval[1] == mval[1]) {
+ if (snap_gizmo->mval[0] == mval[0] && snap_gizmo->mval[1] == mval[1]) {
/* Performance, do not update. */
- return gizmo_snap->snap_elem ? 0 : -1;
+ return snap_gizmo->snap_elem ? 0 : -1;
}
#endif
- copy_v2_v2_int(gizmo_snap->mval, mval);
+ copy_v2_v2_int(snap_gizmo->mval, mval);
ARegion *region = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -443,7 +449,7 @@ static int gizmo_snap_test_select(bContext *C, wmGizmo *gz, const int mval[2])
return -1;
}
-static int gizmo_snap_modal(bContext *UNUSED(C),
+static int snap_gizmo_modal(bContext *UNUSED(C),
wmGizmo *UNUSED(gz),
const wmEvent *UNUSED(event),
eWM_GizmoFlagTweak UNUSED(tweak_flag))
@@ -451,19 +457,19 @@ static int gizmo_snap_modal(bContext *UNUSED(C),
return OPERATOR_RUNNING_MODAL;
}
-static int gizmo_snap_invoke(bContext *UNUSED(C),
+static int snap_gizmo_invoke(bContext *UNUSED(C),
wmGizmo *UNUSED(gz),
const wmEvent *UNUSED(event))
{
return OPERATOR_RUNNING_MODAL;
}
-static void gizmo_snap_free(wmGizmo *gz)
+static void snap_gizmo_free(wmGizmo *gz)
{
- SnapGizmo3D *gizmo_snap = (SnapGizmo3D *)gz;
- if (gizmo_snap->snap_context_v3d) {
- ED_transform_snap_object_context_destroy(gizmo_snap->snap_context_v3d);
- gizmo_snap->snap_context_v3d = NULL;
+ SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
+ if (snap_gizmo->snap_context_v3d) {
+ ED_transform_snap_object_context_destroy(snap_gizmo->snap_context_v3d);
+ snap_gizmo->snap_context_v3d = NULL;
}
}
@@ -473,12 +479,12 @@ static void GIZMO_GT_snap_3d(wmGizmoType *gzt)
gzt->idname = "GIZMO_GT_snap_3d";
/* api callbacks */
- gzt->setup = gizmo_snap_setup;
- gzt->draw = gizmo_snap_draw;
- gzt->test_select = gizmo_snap_test_select;
- gzt->modal = gizmo_snap_modal;
- gzt->invoke = gizmo_snap_invoke;
- gzt->free = gizmo_snap_free;
+ gzt->setup = snap_gizmo_setup;
+ gzt->draw = snap_gizmo_draw;
+ gzt->test_select = snap_gizmo_test_select;
+ gzt->modal = snap_gizmo_modal;
+ gzt->invoke = snap_gizmo_invoke;
+ gzt->free = snap_gizmo_free;
gzt->struct_size = sizeof(SnapGizmo3D);
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 3aec1db2587..30e4fe0b531 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -271,7 +271,7 @@ static void annotation_get_3d_reference(tGPsdata *p, float vec[3])
/* Stroke Editing ---------------------------- */
/* check if the current mouse position is suitable for adding a new point */
-static bool annotation_stroke_filtermval(tGPsdata *p, const float mval[2], float pmval[2])
+static bool annotation_stroke_filtermval(tGPsdata *p, const float mval[2], const float pmval[2])
{
int dx = (int)fabsf(mval[0] - pmval[0]);
int dy = (int)fabsf(mval[1] - pmval[1]);
@@ -573,14 +573,14 @@ static short annotation_stroke_addpoint(tGPsdata *p,
/* Arrow end corner. */
if (gpd->runtime.sbuffer_sflag & GP_STROKE_USE_ARROW_END) {
pt++;
- float e_heading[2] = {start[0] - end[0], start[1] - end[1]};
+ const float e_heading[2] = {start[0] - end[0], start[1] - end[1]};
/* Calculate points for ending arrow. */
annotation_stroke_arrow_calc_points(
pt, e_heading, end, gpd->runtime.arrow_end, gpd->runtime.arrow_end_style);
}
/* Arrow start corner. */
if (gpd->runtime.sbuffer_sflag & GP_STROKE_USE_ARROW_START) {
- float s_heading[2] = {end[0] - start[0], end[1] - start[1]};
+ const float s_heading[2] = {end[0] - start[0], end[1] - start[1]};
/* Calculate points for starting arrow. */
annotation_stroke_arrow_calc_points(
NULL, s_heading, start, gpd->runtime.arrow_start, gpd->runtime.arrow_start_style);
@@ -603,7 +603,7 @@ static short annotation_stroke_addpoint(tGPsdata *p,
/* store settings */
copy_v2_v2(&pt->x, mval);
pt->pressure = pressure;
- /* unused for annotations, but initialise for easier conversions to GP Object */
+ /* Unused for annotations, but initialize for easier conversions to GP Object. */
pt->strength = 1.0f;
/* point time */
@@ -704,7 +704,7 @@ static void annotation_stroke_arrow_init_point(
tGPsdata *p, tGPspoint *ptc, bGPDspoint *pt, const float co[8], const int co_idx)
{
/* Note: provided co_idx should be always pair number as it's [x1, y1, x2, y2, x3, y3]. */
- float real_co[2] = {co[co_idx], co[co_idx + 1]};
+ const float real_co[2] = {co[co_idx], co[co_idx + 1]};
copy_v2_v2(&ptc->x, real_co);
annotation_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
annotation_stroke_arrow_init_point_default(pt);
diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index 962a74d9e6f..5cc5e7ecdcd 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -308,10 +308,10 @@ static void gpencil_add_verts_to_dgroups(
/* create an array of root and tip positions transformed into
* global coords */
- root = MEM_callocN(numbones * sizeof(float) * 3, "root");
- tip = MEM_callocN(numbones * sizeof(float) * 3, "tip");
- selected = MEM_callocN(numbones * sizeof(int), "selected");
- radsqr = MEM_callocN(numbones * sizeof(float), "radsqr");
+ root = MEM_callocN(sizeof(float[3]) * numbones, "root");
+ tip = MEM_callocN(sizeof(float[3]) * numbones, "tip");
+ selected = MEM_callocN(sizeof(int) * numbones, "selected");
+ radsqr = MEM_callocN(sizeof(float) * numbones, "radsqr");
for (j = 0; j < numbones; j++) {
bone = bonelist[j];
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index d4d37e7a9b7..21d755bea52 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -1707,7 +1707,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot)
0,
0,
32,
- "Bevel_Resolution",
+ "Bevel Resolution",
"Bevel resolution when depth is non-zero",
0,
32);
@@ -1722,7 +1722,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot)
1.0f,
0.0f,
1000.0f,
- "Radius Fac",
+ "Radius Factor",
"Multiplier for the points' radii (set from stroke width)",
0.0f,
10.0f);
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index f8010edfcdd..99e98df3397 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -94,6 +94,8 @@
/** \name Stroke Edit Mode Management
* \{ */
+static void gpencil_flip_stroke(bGPDstroke *gps);
+
/* poll callback for all stroke editing operators */
static bool gpencil_stroke_edit_poll(bContext *C)
{
@@ -1126,6 +1128,11 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
pt->flag |= GP_SPOINT_SELECT;
}
+ /* Flip stroke if it was only one point to consider extrude point as last point. */
+ if (gps->totpoints == 2) {
+ gpencil_flip_stroke(gps);
+ }
+
/* Calc geometry data. */
BKE_gpencil_stroke_geometry_update(gps);
@@ -1764,7 +1771,7 @@ static int gpencil_blank_frame_add_exec(bContext *C, wmOperator *op)
const bool all_layers = RNA_boolean_get(op->ptr, "all_layers");
- /* Initialise datablock and an active layer if nothing exists yet */
+ /* Initialize data-block and an active layer if nothing exists yet. */
if (ELEM(NULL, gpd, active_gpl)) {
/* Let's just be lazy, and call the "Add New Layer" operator,
* which sets everything up as required. */
@@ -3369,7 +3376,7 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a,
bGPDspoint point;
bGPDspoint *pt;
int i;
- float delta[3] = {1.0f, 1.0f, 1.0f};
+ const float delta[3] = {1.0f, 1.0f, 1.0f};
float deltatime = 0.0f;
/* sanity checks */
@@ -4283,11 +4290,14 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_prev, dupflag);
ob_dst = base_new->object;
ob_dst->mode = OB_MODE_OBJECT;
- /* create new grease pencil datablock */
+ /* Duplication will increment #bGPdata user-count, but since we create a new grease-pencil
+ * data-block for ob_dst (which gets its own user automatically),
+ * we have to decrement the user-count again. */
gpd_dst = BKE_gpencil_data_addnew(bmain, gpd_src->id.name + 2);
+ id_us_min(ob_dst->data);
ob_dst->data = (bGPdata *)gpd_dst;
- /* loop old datablock and separate parts */
+ /* Loop old data-block and separate parts. */
if ((mode == GP_SEPARATE_POINT) || (mode == GP_SEPARATE_STROKE)) {
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
gpl_dst = NULL;
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index d7525c3c6a5..2855f2cc0d7 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -104,6 +104,8 @@ typedef struct tGPDfill {
struct bGPdata *gpd;
/** current material */
struct Material *mat;
+ /** current brush */
+ struct Brush *brush;
/** layer */
struct bGPDlayer *gpl;
/** frame */
@@ -233,6 +235,8 @@ static void gpencil_draw_datablock(tGPDfill *tgpf, const float ink[4])
Object *ob = tgpf->ob;
bGPdata *gpd = tgpf->gpd;
+ Brush *brush = tgpf->brush;
+ BrushGpencilSettings *brush_settings = brush->gpencil_settings;
tGPDdraw tgpw;
tgpw.rv3d = tgpf->rv3d;
@@ -249,6 +253,12 @@ static void gpencil_draw_datablock(tGPDfill *tgpf, const float ink[4])
GPU_blend(true);
+ bGPDlayer *gpl_active = BKE_gpencil_layer_active_get(gpd);
+ BLI_assert(gpl_active != NULL);
+
+ const int gpl_active_index = BLI_findindex(&gpd->layers, gpl_active);
+ BLI_assert(gpl_active_index >= 0);
+
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* calculate parent position */
BKE_gpencil_parent_matrix_get(tgpw.depsgraph, ob, gpl, tgpw.diff_mat);
@@ -258,6 +268,44 @@ static void gpencil_draw_datablock(tGPDfill *tgpf, const float ink[4])
continue;
}
+ /* Decide if layer is included or not depending of the layer mode. */
+ const int gpl_index = BLI_findindex(&gpd->layers, gpl);
+ switch (brush_settings->fill_layer_mode) {
+ case GP_FILL_GPLMODE_ACTIVE: {
+ if (gpl_index != gpl_active_index) {
+ continue;
+ }
+ break;
+ }
+ case GP_FILL_GPLMODE_ABOVE: {
+ if (gpl_index != gpl_active_index + 1) {
+ continue;
+ }
+ break;
+ }
+ case GP_FILL_GPLMODE_BELOW: {
+ if (gpl_index != gpl_active_index - 1) {
+ continue;
+ }
+ break;
+ }
+ case GP_FILL_GPLMODE_ALL_ABOVE: {
+ if (gpl_index <= gpl_active_index) {
+ continue;
+ }
+ break;
+ }
+ case GP_FILL_GPLMODE_ALL_BELOW: {
+ if (gpl_index >= gpl_active_index) {
+ continue;
+ }
+ break;
+ }
+ case GP_FILL_GPLMODE_VISIBLE:
+ default:
+ break;
+ }
+
/* if active layer and no keyframe, create a new one */
if (gpl == tgpf->gpl) {
if ((gpl->actframe == NULL) || (gpl->actframe->framenum != tgpf->active_cfra)) {
@@ -408,7 +456,7 @@ static bool gpencil_render_offscreen(tGPDfill *tgpf)
GPU_matrix_set(tgpf->rv3d->viewmat);
/* draw strokes */
- float ink[4] = {1.0f, 0.0f, 0.0f, 1.0f};
+ const float ink[4] = {1.0f, 0.0f, 0.0f, 1.0f};
gpencil_draw_datablock(tgpf, ink);
GPU_matrix_pop_projection();
@@ -702,6 +750,92 @@ static void gpencil_set_borders(tGPDfill *tgpf, const bool transparent)
tgpf->ima->id.tag |= LIB_TAG_DOIT;
}
+/* Invert image to paint invese area. */
+static void gpencil_invert_image(tGPDfill *tgpf)
+{
+ ImBuf *ibuf;
+ void *lock;
+ const float fill_col[3][4] = {
+ {1.0f, 0.0f, 0.0f, 1.0f}, {0.0f, 1.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 0.0f}};
+ ibuf = BKE_image_acquire_ibuf(tgpf->ima, NULL, &lock);
+
+ const int maxpixel = (ibuf->x * ibuf->y) - 1;
+
+ for (int v = maxpixel; v != 0; v--) {
+ float color[4];
+ get_pixel(ibuf, v, color);
+ /* Green. */
+ if (color[1] == 1.0f) {
+ set_pixel(ibuf, v, fill_col[0]);
+ }
+ else if (color[0] == 1.0f) {
+ set_pixel(ibuf, v, fill_col[1]);
+ }
+ else {
+ set_pixel(ibuf, v, fill_col[2]);
+ }
+ }
+
+ /* release ibuf */
+ if (ibuf) {
+ BKE_image_release_ibuf(tgpf->ima, ibuf, lock);
+ }
+
+ tgpf->ima->id.tag |= LIB_TAG_DOIT;
+}
+
+/* Mark and clear processed areas. */
+static void gpencil_erase_processed_area(tGPDfill *tgpf)
+{
+ ImBuf *ibuf;
+ void *lock;
+ const float blue_col[4] = {0.0f, 0.0f, 1.0f, 1.0f};
+ const float clear_col[4] = {1.0f, 0.0f, 0.0f, 1.0f};
+ tGPspoint *point2D;
+
+ if (tgpf->sbuffer_used == 0) {
+ return;
+ }
+
+ ibuf = BKE_image_acquire_ibuf(tgpf->ima, NULL, &lock);
+ point2D = (tGPspoint *)tgpf->sbuffer;
+
+ /* First set in blue the perimeter. */
+ for (int i = 0; i < tgpf->sbuffer_used && point2D; i++, point2D++) {
+ int image_idx = ibuf->x * (int)point2D->y + (int)point2D->x;
+ set_pixel(ibuf, image_idx, blue_col);
+ }
+
+ /* Second, clean by lines any pixel between blue pixels. */
+ float rgba[4];
+
+ for (int idy = 0; idy < ibuf->y; idy++) {
+ bool clear = false;
+ for (int idx = 0; idx < ibuf->x; idx++) {
+ int image_idx = ibuf->x * idy + idx;
+ get_pixel(ibuf, image_idx, rgba);
+ /* Blue. */
+ if (rgba[2] == 1.0f) {
+ clear = true;
+ }
+ /* Red. */
+ else if (rgba[0] == 1.0f) {
+ clear = false;
+ }
+ if (clear) {
+ set_pixel(ibuf, image_idx, clear_col);
+ }
+ }
+ }
+
+ /* release ibuf */
+ if (ibuf) {
+ BKE_image_release_ibuf(tgpf->ima, ibuf, lock);
+ }
+
+ tgpf->ima->id.tag |= LIB_TAG_DOIT;
+}
+
/* Naive dilate
*
* Expand green areas into enclosing red areas.
@@ -713,7 +847,7 @@ static void gpencil_set_borders(tGPDfill *tgpf, const bool transparent)
* XXXX
* -----------
*/
-static void dilate(ImBuf *ibuf)
+static void dilate_shape(ImBuf *ibuf)
{
BLI_Stack *stack = BLI_stack_new(sizeof(int), __func__);
const float green[4] = {0.0f, 1.0f, 0.0f, 1.0f};
@@ -812,7 +946,7 @@ static void dilate(ImBuf *ibuf)
* This is a Blender customized version of the general algorithm described
* in https://en.wikipedia.org/wiki/Moore_neighborhood
*/
-static void gpencil_get_outline_points(tGPDfill *tgpf)
+static void gpencil_get_outline_points(tGPDfill *tgpf, const bool dilate)
{
ImBuf *ibuf;
float rgba[4];
@@ -844,8 +978,10 @@ static void gpencil_get_outline_points(tGPDfill *tgpf)
ibuf = BKE_image_acquire_ibuf(tgpf->ima, NULL, &lock);
int imagesize = ibuf->x * ibuf->y;
- /* dilate */
- dilate(ibuf);
+ /* Dilate. */
+ if (dilate) {
+ dilate_shape(ibuf);
+ }
/* find the initial point to start outline analysis */
for (int idx = imagesize - 1; idx != 0; idx--) {
@@ -979,12 +1115,12 @@ static void gpencil_get_depth_array(tGPDfill *tgpf)
}
/* create array of points using stack as source */
-static void gpencil_points_from_stack(tGPDfill *tgpf)
+static int gpencil_points_from_stack(tGPDfill *tgpf)
{
tGPspoint *point2D;
int totpoints = BLI_stack_count(tgpf->stack);
if (totpoints == 0) {
- return;
+ return 0;
}
tgpf->sbuffer_used = (short)totpoints;
@@ -1002,6 +1138,8 @@ static void gpencil_points_from_stack(tGPDfill *tgpf)
point2D->time = 0.0f;
point2D++;
}
+
+ return totpoints;
}
/* create a grease pencil stroke using points in buffer */
@@ -1247,6 +1385,7 @@ static tGPDfill *gpencil_session_init_fill(bContext *C, wmOperator *UNUSED(op))
/* save filling parameters */
Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
+ tgpf->brush = brush;
tgpf->flag = brush->gpencil_settings->flag;
tgpf->fill_leak = brush->gpencil_settings->fill_leak;
tgpf->fill_threshold = brush->gpencil_settings->fill_threshold;
@@ -1412,6 +1551,10 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
tGPDfill *tgpf = op->customdata;
Scene *scene = tgpf->scene;
+ Brush *brush = tgpf->brush;
+ BrushGpencilSettings *brush_settings = brush->gpencil_settings;
+ const bool is_brush_inv = brush_settings->fill_direction == BRUSH_DIR_IN;
+ const bool is_inverted = (is_brush_inv && !event->ctrl) || (!is_brush_inv && event->ctrl);
int estate = OPERATOR_PASS_THROUGH; /* default exit state - pass through */
@@ -1440,6 +1583,7 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
tgpf->active_cfra = CFRA;
/* render screen to temp image */
+ int totpoints = 1;
if (gpencil_render_offscreen(tgpf)) {
/* Set red borders to create a external limit. */
@@ -1448,30 +1592,45 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* apply boundary fill */
gpencil_boundaryfill_area(tgpf);
+ /* Invert direction if press Ctrl. */
+ if (is_inverted) {
+ gpencil_invert_image(tgpf);
+ }
+
/* Clean borders to avoid infinite loops. */
gpencil_set_borders(tgpf, false);
- /* analyze outline */
- gpencil_get_outline_points(tgpf);
+ while (totpoints > 0) {
+ /* analyze outline */
+ gpencil_get_outline_points(tgpf, (totpoints == 1) ? true : false);
- /* create array of points from stack */
- gpencil_points_from_stack(tgpf);
+ /* create array of points from stack */
+ totpoints = gpencil_points_from_stack(tgpf);
- /* create z-depth array for reproject */
- gpencil_get_depth_array(tgpf);
+ /* create z-depth array for reproject */
+ gpencil_get_depth_array(tgpf);
- /* create stroke and reproject */
- gpencil_stroke_from_buffer(tgpf);
- }
+ /* create stroke and reproject */
+ gpencil_stroke_from_buffer(tgpf);
- /* free temp stack data */
- if (tgpf->stack) {
- BLI_stack_free(tgpf->stack);
- }
+ if (is_inverted) {
+ gpencil_erase_processed_area(tgpf);
+ }
+ else {
+ /* Exit of the loop. */
+ totpoints = 0;
+ }
- /* Free memory. */
- MEM_SAFE_FREE(tgpf->sbuffer);
- MEM_SAFE_FREE(tgpf->depth_arr);
+ /* free temp stack data */
+ if (tgpf->stack) {
+ BLI_stack_free(tgpf->stack);
+ }
+
+ /* Free memory. */
+ MEM_SAFE_FREE(tgpf->sbuffer);
+ MEM_SAFE_FREE(tgpf->depth_arr);
+ }
+ }
/* restore size */
tgpf->region->winx = (short)tgpf->bwinx;
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 68424839ab0..e6fdbf1ad17 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -21,8 +21,7 @@
* \ingroup edgpencil
*/
-#ifndef __GPENCIL_INTERN_H__
-#define __GPENCIL_INTERN_H__
+#pragma once
#include "DNA_vec_types.h"
@@ -203,6 +202,8 @@ typedef struct tGPDprimitive {
tGPspoint *points;
/** number of edges allocated */
int point_count;
+ /** number of subdivisions. */
+ int subdiv;
/** stored number of polygon edges */
int tot_stored_edges;
/** number of polygon edges */
@@ -554,7 +555,11 @@ void GPENCIL_OT_interpolate_reverse(struct wmOperatorType *ot);
/* primitives ---------- */
-void GPENCIL_OT_primitive(struct wmOperatorType *ot);
+void GPENCIL_OT_primitive_box(struct wmOperatorType *ot);
+void GPENCIL_OT_primitive_line(struct wmOperatorType *ot);
+void GPENCIL_OT_primitive_polyline(struct wmOperatorType *ot);
+void GPENCIL_OT_primitive_circle(struct wmOperatorType *ot);
+void GPENCIL_OT_primitive_curve(struct wmOperatorType *ot);
/* vertex groups ------------ */
void GPENCIL_OT_vertex_group_assign(struct wmOperatorType *ot);
@@ -732,5 +737,3 @@ struct GP_EditableStrokes_Iter {
(void)0
/* ****************************************************** */
-
-#endif /* __GPENCIL_INTERN_H__ */
diff --git a/source/blender/editors/gpencil/gpencil_mesh.c b/source/blender/editors/gpencil/gpencil_mesh.c
index 11f42f7d3ac..a6088e31ff8 100644
--- a/source/blender/editors/gpencil/gpencil_mesh.c
+++ b/source/blender/editors/gpencil/gpencil_mesh.c
@@ -196,7 +196,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
bool newob = false;
if (STREQ(target, "*NEW")) {
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
- float loc[3] = {0.0f, 0.0f, 0.0f};
+ const float loc[3] = {0.0f, 0.0f, 0.0f};
ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits);
newob = true;
}
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index 3892f451e18..211ff895e67 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -665,7 +665,11 @@ void ED_operatortypes_gpencil(void)
WM_operatortype_append(GPENCIL_OT_interpolate_reverse);
/* Primitives */
- WM_operatortype_append(GPENCIL_OT_primitive);
+ WM_operatortype_append(GPENCIL_OT_primitive_box);
+ WM_operatortype_append(GPENCIL_OT_primitive_line);
+ WM_operatortype_append(GPENCIL_OT_primitive_polyline);
+ WM_operatortype_append(GPENCIL_OT_primitive_circle);
+ WM_operatortype_append(GPENCIL_OT_primitive_curve);
/* convert old 2.7 files to 2.8 */
WM_operatortype_append(GPENCIL_OT_convert_old_files);
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index b61baf3d0b1..680e7b37d31 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -250,7 +250,8 @@ typedef struct tGPsdata {
short shift;
/** size in pixels for uv calculation */
float totpixlen;
-
+ /** Special mode for fill brush. */
+ bool disable_stabilizer;
/* guide */
tGPguide guide;
@@ -362,7 +363,7 @@ static void gpencil_get_3d_reference(tGPsdata *p, float vec[3])
/* Stroke Editing ---------------------------- */
/* check if the current mouse position is suitable for adding a new point */
-static bool gpencil_stroke_filtermval(tGPsdata *p, const float mval[2], float mvalo[2])
+static bool gpencil_stroke_filtermval(tGPsdata *p, const float mval[2], const float mvalo[2])
{
Brush *brush = p->brush;
int dx = (int)fabsf(mval[0] - mvalo[0]);
@@ -374,7 +375,7 @@ static bool gpencil_stroke_filtermval(tGPsdata *p, const float mval[2], float mv
return true;
}
/* if lazy mouse, check minimum distance */
- if (GPENCIL_LAZY_MODE(brush, p->shift)) {
+ if (GPENCIL_LAZY_MODE(brush, p->shift) && (!p->disable_stabilizer)) {
brush->gpencil_settings->flag |= GP_BRUSH_STABILIZE_MOUSE_TEMP;
if ((dx * dx + dy * dy) > (brush->smooth_stroke_radius * brush->smooth_stroke_radius)) {
return true;
@@ -519,7 +520,7 @@ static void gpencil_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const
/* default angle of brush in radians */
float angle = brush->gpencil_settings->draw_angle;
/* angle vector of the brush with full thickness */
- float v0[2] = {cos(angle), sin(angle)};
+ const float v0[2] = {cos(angle), sin(angle)};
/* Apply to first point (only if there are 2 points because before no data to do it ) */
if (gpd->runtime.sbuffer_used == 1) {
@@ -836,7 +837,7 @@ static short gpencil_stroke_addpoint(tGPsdata *p,
}
/* color strength */
- if (brush_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) {
+ if (brush_settings->flag & GP_BRUSH_USE_STRENGTH_PRESSURE) {
pt->strength *= BKE_curvemapping_evaluateF(brush_settings->curve_strength, 0, pressure);
CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
}
@@ -1817,15 +1818,15 @@ static void gpencil_init_drawing_brush(bContext *C, tGPsdata *p)
changed = true;
}
/* Be sure curves are initializated. */
- BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_sensitivity);
- BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_strength);
- BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_jitter);
- BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_pressure);
- BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_strength);
- BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_uv);
- BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_hue);
- BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_saturation);
- BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_value);
+ BKE_curvemapping_init(paint->brush->gpencil_settings->curve_sensitivity);
+ BKE_curvemapping_init(paint->brush->gpencil_settings->curve_strength);
+ BKE_curvemapping_init(paint->brush->gpencil_settings->curve_jitter);
+ BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_pressure);
+ BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_strength);
+ BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_uv);
+ BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_hue);
+ BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_saturation);
+ BKE_curvemapping_init(paint->brush->gpencil_settings->curve_rand_value);
/* assign to temp tGPsdata */
p->brush = paint->brush;
@@ -1886,6 +1887,7 @@ static bool gpencil_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
p->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
p->win = CTX_wm_window(C);
p->disable_fill = RNA_boolean_get(op->ptr, "disable_fill");
+ p->disable_stabilizer = RNA_boolean_get(op->ptr, "disable_stabilizer");
unit_m4(p->imat);
unit_m4(p->mat);
@@ -2681,7 +2683,7 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra
else if (gpencil_stroke_filtermval(p, p->mval, p->mvalo)) {
/* if lazy mouse, interpolate the last and current mouse positions */
- if (GPENCIL_LAZY_MODE(p->brush, p->shift)) {
+ if (GPENCIL_LAZY_MODE(p->brush, p->shift) && (!p->disable_stabilizer)) {
float now_mouse[2];
float last_mouse[2];
copy_v2_v2(now_mouse, p->mval);
@@ -3247,7 +3249,7 @@ static void gpencil_brush_angle_segment(tGPsdata *p, tGPspoint *pt_prev, tGPspoi
float fac;
/* angle vector of the brush with full thickness */
- float v0[2] = {cos(angle), sin(angle)};
+ const float v0[2] = {cos(angle), sin(angle)};
mvec[0] = pt->x - pt_prev->x;
mvec[1] = pt->y - pt_prev->y;
@@ -3269,7 +3271,7 @@ static void gpencil_brush_angle_segment(tGPsdata *p, tGPspoint *pt_prev, tGPspoi
* + PtA - 1
* /
* CTL is the vertice of the triangle created between PtA and PtB */
-static void gpencil_add_arc_points(tGPsdata *p, float mval[2], int segments)
+static void gpencil_add_arc_points(tGPsdata *p, const float mval[2], int segments)
{
bGPdata *gpd = p->gpd;
BrushGpencilSettings *brush_settings = p->brush->gpencil_settings;
@@ -3443,7 +3445,7 @@ static void gpencil_add_fake_points(const wmEvent *event, tGPsdata *p)
{
Brush *brush = p->brush;
/* Lazy mode do not use fake events. */
- if (GPENCIL_LAZY_MODE(brush, p->shift)) {
+ if (GPENCIL_LAZY_MODE(brush, p->shift) && (!p->disable_stabilizer)) {
return;
}
@@ -3891,6 +3893,9 @@ void GPENCIL_OT_draw(wmOperatorType *ot)
"Disable fill to use stroke as fill boundary");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "disable_stabilizer", false, "No Stabilizer", "");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
/* guides */
prop = RNA_def_float(ot->srna,
"guide_last_angle",
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index f206f5c832a..75f08c37cba 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -109,7 +109,15 @@
/* ************************************************ */
/* Core/Shared Utilities */
-
+const static EnumPropertyItem gpencil_primitive_type[] = {
+ {GP_STROKE_BOX, "BOX", 0, "Box", ""},
+ {GP_STROKE_LINE, "LINE", 0, "Line", ""},
+ {GP_STROKE_POLYLINE, "POLYLINE", 0, "Polyline", ""},
+ {GP_STROKE_CIRCLE, "CIRCLE", 0, "Circle", ""},
+ {GP_STROKE_ARC, "ARC", 0, "Arc", ""},
+ {GP_STROKE_CURVE, "CURVE", 0, "Curve", ""},
+ {0, NULL, 0, NULL, NULL},
+};
/* clear the session buffers (call this before AND after a paint operation) */
static void gpencil_session_validatebuffer(tGPDprimitive *p)
{
@@ -378,7 +386,10 @@ static void gpencil_primitive_add_segment(tGPDprimitive *tgpi)
}
/* Helper: set control point */
-static void gpencil_primitive_set_cp(tGPDprimitive *tgpi, float p[2], float color[4], int size)
+static void gpencil_primitive_set_cp(tGPDprimitive *tgpi,
+ const float p[2],
+ float color[4],
+ int size)
{
if (tgpi->flag == IN_PROGRESS) {
return;
@@ -412,7 +423,8 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi
}
else if (tgpi->type == GP_STROKE_POLYLINE) {
BLI_strncpy(msg_str,
- TIP_("Line: ESC to cancel, LMB to set, Enter/MMB to confirm, Shift to align"),
+ TIP_("Polyline: ESC to cancel, LMB to set, Enter/MMB to confirm, WHEEL/+- to "
+ "adjust subdivision number, Shift to align"),
UI_MAX_DRAW_STR);
}
else if (tgpi->type == GP_STROKE_BOX) {
@@ -423,19 +435,20 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi
}
else if (tgpi->type == GP_STROKE_CIRCLE) {
BLI_strncpy(msg_str,
- TIP_("Circle: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge "
+ TIP_("Circle: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust subdivision "
"number, Shift to square, Alt to center"),
UI_MAX_DRAW_STR);
}
else if (tgpi->type == GP_STROKE_ARC) {
- BLI_strncpy(msg_str,
- TIP_("Arc: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge number, "
- "Shift to square, Alt to center, M: Flip, E: extrude"),
- UI_MAX_DRAW_STR);
+ BLI_strncpy(
+ msg_str,
+ TIP_("Arc: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust subdivision number, "
+ "Shift to square, Alt to center, M: Flip, E: extrude"),
+ UI_MAX_DRAW_STR);
}
else if (tgpi->type == GP_STROKE_CURVE) {
BLI_strncpy(msg_str,
- TIP_("Curve: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge "
+ TIP_("Curve: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust subdivision "
"number, Shift to square, Alt to center, E: extrude"),
UI_MAX_DRAW_STR);
}
@@ -515,16 +528,23 @@ static void gpencil_primitive_rectangle(tGPDprimitive *tgpi, tGPspoint *points2D
coords[4][0] = tgpi->start[0];
coords[4][1] = tgpi->start[1];
- const float step = 1.0f / (float)(tgpi->tot_edges);
- int i = tgpi->tot_stored_edges;
-
- for (int j = 0; j < 4; j++) {
- float a = 0.0f;
- for (int k = 0; k < tgpi->tot_edges; k++) {
- tGPspoint *p2d = &points2D[i];
- interp_v2_v2v2(&p2d->x, coords[j], coords[j + 1], a);
- a += step;
- i++;
+ if (tgpi->tot_edges == 1) {
+ for (int j = 0; j < 4; j++) {
+ tGPspoint *p2d = &points2D[j];
+ copy_v2_v2(&p2d->x, coords[j]);
+ }
+ }
+ else {
+ const float step = 1.0f / (float)(tgpi->tot_edges);
+ int i = tgpi->tot_stored_edges;
+ for (int j = 0; j < 4; j++) {
+ float a = 0.0f;
+ for (int k = 0; k < tgpi->tot_edges; k++) {
+ tGPspoint *p2d = &points2D[i];
+ interp_v2_v2v2(&p2d->x, coords[j], coords[j + 1], a);
+ a += step;
+ i++;
+ }
}
}
@@ -695,9 +715,9 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
bool is_depth = (bool)(*align_flag & (GP_PROJECT_DEPTH_VIEW | GP_PROJECT_DEPTH_STROKE));
const bool is_camera = (bool)(ts->gp_sculpt.lock_axis == 0) &&
(tgpi->rv3d->persp == RV3D_CAMOB) && (!is_depth);
- const bool is_vertex_stroke = GPENCIL_USE_VERTEX_COLOR_STROKE(ts, brush);
if (tgpi->type == GP_STROKE_BOX) {
+ tgpi->tot_edges--;
gps->totpoints = (tgpi->tot_edges * 4 + tgpi->tot_stored_edges);
}
else {
@@ -713,7 +733,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
/* compute screen-space coordinates for points */
tGPspoint *points2D = tgpi->points;
- if (tgpi->tot_edges > 1) {
+ if (tgpi->tot_edges > 0) {
switch (tgpi->type) {
case GP_STROKE_BOX:
gpencil_primitive_rectangle(tgpi, points2D);
@@ -741,13 +761,13 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
gpencil_session_validatebuffer(tgpi);
gpencil_init_colors(tgpi);
if (gset->flag & GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE) {
- BKE_curvemapping_initialize(ts->gp_sculpt.cur_primitive);
+ BKE_curvemapping_init(ts->gp_sculpt.cur_primitive);
}
if (brush_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) {
- BKE_curvemapping_initialize(brush_settings->curve_jitter);
+ BKE_curvemapping_init(brush_settings->curve_jitter);
}
- if (brush_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) {
- BKE_curvemapping_initialize(brush_settings->curve_strength);
+ if (brush_settings->flag & GP_BRUSH_USE_STRENGTH_PRESSURE) {
+ BKE_curvemapping_init(brush_settings->curve_strength);
}
/* get an array of depths, far depths are blended */
@@ -912,7 +932,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
}
/* color strength */
- if (brush_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) {
+ if (brush_settings->flag & GP_BRUSH_USE_STRENGTH_PRESSURE) {
float curvef = BKE_curvemapping_evaluateF(brush_settings->curve_strength, 0, curve_pressure);
strength *= curvef;
strength *= brush_settings->draw_strength;
@@ -1020,12 +1040,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
pt->time = 0.0f;
pt->flag = 0;
pt->uv_fac = tpt->uv_fac;
- if (is_vertex_stroke) {
- copy_v4_v4(pt->vert_color, tpt->vert_color);
- }
- else {
- zero_v4(pt->vert_color);
- }
+ ED_gpencil_point_vertex_color_set(ts, brush, pt, tpt);
if (gps->dvert != NULL) {
MDeformVert *dvert = &gps->dvert[i];
@@ -1091,7 +1106,7 @@ static void gpencil_primitive_update(bContext *C, wmOperator *op, tGPDprimitive
gpencil_primitive_update_strokes(C, tgpi);
}
-/* Initialise mouse points */
+/* Initialize mouse points. */
static void gpencil_primitive_interaction_begin(tGPDprimitive *tgpi, const wmEvent *event)
{
copy_v2fl_v2i(tgpi->mval, event->mval);
@@ -1213,31 +1228,10 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
tgpi->curve = false;
}
- /* set default edge count */
- switch (tgpi->type) {
- case GP_STROKE_POLYLINE: {
- RNA_int_set(op->ptr, "edges", 8);
- break;
- }
- case GP_STROKE_LINE: {
- RNA_int_set(op->ptr, "edges", 8);
- break;
- }
- case GP_STROKE_BOX: {
- RNA_int_set(op->ptr, "edges", 8);
- break;
- }
- case GP_STROKE_CIRCLE: {
- RNA_int_set(op->ptr, "edges", 96);
- break;
- }
- default: {
- RNA_int_set(op->ptr, "edges", 64);
- break;
- }
- }
-
tgpi->tot_stored_edges = 0;
+
+ tgpi->subdiv = RNA_int_get(op->ptr, "subdivision");
+ RNA_int_set(op->ptr, "edges", tgpi->subdiv + 2);
tgpi->tot_edges = RNA_int_get(op->ptr, "edges");
tgpi->flag = IDLE;
tgpi->lock_axis = ts->gp_sculpt.lock_axis;
@@ -1353,11 +1347,6 @@ static void gpencil_primitive_interaction_end(bContext *C,
}
}
- /* Close stroke with geometry */
- if ((tgpi->type == GP_STROKE_BOX) || (tgpi->type == GP_STROKE_CIRCLE)) {
- BKE_gpencil_stroke_close(gps);
- }
-
DEG_id_tag_update(&tgpi->gpd->id, ID_RECALC_COPY_ON_WRITE);
DEG_id_tag_update(&tgpi->gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
@@ -1631,9 +1620,12 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
case RIGHTMOUSE: {
if (event->val == KM_PRESS) {
tgpi->flag = IDLE;
+ int last_edges = tgpi->tot_edges;
tgpi->tot_edges = tgpi->tot_stored_edges ? 1 : 0;
+ RNA_int_set(op->ptr, "edges", tgpi->tot_edges);
gpencil_primitive_update_strokes(C, tgpi);
gpencil_primitive_interaction_end(C, op, win, tgpi);
+ RNA_int_set(op->ptr, "edges", last_edges);
return OPERATOR_FINISHED;
}
break;
@@ -1960,22 +1952,45 @@ static void gpencil_primitive_cancel(bContext *C, wmOperator *op)
gpencil_primitive_exit(C, op);
}
-void GPENCIL_OT_primitive(wmOperatorType *ot)
+static void gpencil_primitive_common_props(wmOperatorType *ot, int subdiv, int type)
{
- static EnumPropertyItem primitive_type[] = {
- {GP_STROKE_BOX, "BOX", 0, "Box", ""},
- {GP_STROKE_LINE, "LINE", 0, "Line", ""},
- {GP_STROKE_POLYLINE, "POLYLINE", 0, "Polyline", ""},
- {GP_STROKE_CIRCLE, "CIRCLE", 0, "Circle", ""},
- {GP_STROKE_ARC, "ARC", 0, "Arc", ""},
- {GP_STROKE_CURVE, "CURVE", 0, "Curve", ""},
- {0, NULL, 0, NULL, NULL},
- };
+ PropertyRNA *prop;
+
+ prop = RNA_def_int(ot->srna,
+ "subdivision",
+ subdiv,
+ 0,
+ MAX_EDGES,
+ "Subdivisions",
+ "Number of subdivision by edges",
+ 0,
+ MAX_EDGES);
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
+ /* Internal prop. */
+ prop = RNA_def_int(ot->srna,
+ "edges",
+ MIN_EDGES,
+ MIN_EDGES,
+ MAX_EDGES,
+ "Edges",
+ "Number of points by edge",
+ MIN_EDGES,
+ MAX_EDGES);
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
+
+ RNA_def_enum(ot->srna, "type", gpencil_primitive_type, type, "Type", "Type of shape");
+ prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+}
+
+void GPENCIL_OT_primitive_box(wmOperatorType *ot)
+{
/* identifiers */
- ot->name = "Grease Pencil Shapes";
- ot->idname = "GPENCIL_OT_primitive";
- ot->description = "Create predefined grease pencil stroke shapes";
+ ot->name = "Grease Pencil Box Shape";
+ ot->idname = "GPENCIL_OT_primitive_box";
+ ot->description = "Create predefined grease pencil stroke box shapes";
/* callbacks */
ot->invoke = gpencil_primitive_invoke;
@@ -1984,24 +1999,88 @@ void GPENCIL_OT_primitive(wmOperatorType *ot)
ot->poll = gpencil_primitive_add_poll;
/* flags */
- ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* properties */
- PropertyRNA *prop;
+ gpencil_primitive_common_props(ot, 3, GP_STROKE_BOX);
+}
- prop = RNA_def_int(ot->srna,
- "edges",
- 4,
- MIN_EDGES,
- MAX_EDGES,
- "Edges",
- "Number of polygon edges",
- MIN_EDGES,
- MAX_EDGES);
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+void GPENCIL_OT_primitive_line(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Grease Pencil Line Shape";
+ ot->idname = "GPENCIL_OT_primitive_line";
+ ot->description = "Create predefined grease pencil stroke lines";
- RNA_def_enum(ot->srna, "type", primitive_type, GP_STROKE_BOX, "Type", "Type of shape");
+ /* callbacks */
+ ot->invoke = gpencil_primitive_invoke;
+ ot->modal = gpencil_primitive_modal;
+ ot->cancel = gpencil_primitive_cancel;
+ ot->poll = gpencil_primitive_add_poll;
- prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "");
- RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+
+ /* properties */
+ gpencil_primitive_common_props(ot, 6, GP_STROKE_LINE);
+}
+
+void GPENCIL_OT_primitive_polyline(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Grease Pencil Polyline Shape";
+ ot->idname = "GPENCIL_OT_primitive_polyline";
+ ot->description = "Create predefined grease pencil stroke polylines";
+
+ /* callbacks */
+ ot->invoke = gpencil_primitive_invoke;
+ ot->modal = gpencil_primitive_modal;
+ ot->cancel = gpencil_primitive_cancel;
+ ot->poll = gpencil_primitive_add_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+
+ /* properties */
+ gpencil_primitive_common_props(ot, 6, GP_STROKE_POLYLINE);
+}
+
+void GPENCIL_OT_primitive_circle(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Grease Pencil Circle Shape";
+ ot->idname = "GPENCIL_OT_primitive_circle";
+ ot->description = "Create predefined grease pencil stroke circle shapes";
+
+ /* callbacks */
+ ot->invoke = gpencil_primitive_invoke;
+ ot->modal = gpencil_primitive_modal;
+ ot->cancel = gpencil_primitive_cancel;
+ ot->poll = gpencil_primitive_add_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+
+ /* properties */
+ gpencil_primitive_common_props(ot, 94, GP_STROKE_CIRCLE);
+}
+
+void GPENCIL_OT_primitive_curve(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Grease Pencil Curve Shape";
+ ot->idname = "GPENCIL_OT_primitive_curve";
+ ot->description = "Create predefined grease pencil stroke curve shapes";
+
+ /* callbacks */
+ ot->invoke = gpencil_primitive_invoke;
+ ot->modal = gpencil_primitive_modal;
+ ot->cancel = gpencil_primitive_cancel;
+ ot->poll = gpencil_primitive_add_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+
+ /* properties */
+ gpencil_primitive_common_props(ot, 62, GP_STROKE_CURVE);
}
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 20eeab65623..4a5da10cdbf 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -444,7 +444,9 @@ typedef struct tGPSB_Grab_StrokeData {
int size;
} tGPSB_Grab_StrokeData;
-/* initialise custom data for handling this stroke */
+/**
+ * Initialize custom data for handling this stroke.
+ */
static void gpencil_brush_grab_stroke_init(tGP_BrushEditData *gso, bGPDstroke *gps)
{
tGPSB_Grab_StrokeData *data = NULL;
@@ -910,13 +912,13 @@ typedef struct tGPSB_CloneBrushData {
GHash *new_colors;
} tGPSB_CloneBrushData;
-/* Initialise "clone" brush data */
+/* Initialize "clone" brush data. */
static void gpencil_brush_clone_init(bContext *C, tGP_BrushEditData *gso)
{
tGPSB_CloneBrushData *data;
bGPDstroke *gps;
- /* init custom data */
+ /* Initialize custom-data. */
gso->customdata = data = MEM_callocN(sizeof(tGPSB_CloneBrushData), "CloneBrushData");
/* compute midpoint of strokes on clipboard */
@@ -1188,7 +1190,7 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op)
Paint *paint = &ts->gp_sculptpaint->paint;
gso->brush = paint->brush;
- BKE_curvemapping_initialize(gso->brush->curve);
+ BKE_curvemapping_init(gso->brush->curve);
/* save mask */
gso->mask = ts->gpencil_selectmode_sculpt;
@@ -1200,10 +1202,10 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op)
/* Init multi-edit falloff curve data before doing anything,
* so we won't have to do it again later. */
if (gso->is_multiframe) {
- BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff);
+ BKE_curvemapping_init(ts->gp_sculpt.cur_falloff);
}
- /* initialise custom data for brushes */
+ /* Initialize custom data for brushes. */
char tool = gso->brush->gpencil_sculpt_tool;
switch (tool) {
case GPSCULPT_TOOL_CLONE: {
@@ -1229,13 +1231,13 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op)
op->customdata = NULL;
return false;
}
- /* initialise customdata */
+ /* Initialize custom-data. */
gpencil_brush_clone_init(C, gso);
break;
}
case GPSCULPT_TOOL_GRAB: {
- /* initialise the cache needed for this brush */
+ /* Initialize the cache needed for this brush. */
gso->stroke_customdata = BLI_ghash_ptr_new("GP Grab Brush - Strokes Hash");
break;
}
@@ -1924,7 +1926,7 @@ static int gpencil_sculpt_brush_invoke(bContext *C, wmOperator *op, const wmEven
/* the operator cannot work while play animation */
if (is_playing) {
- BKE_report(op->reports, RPT_ERROR, "Cannot sculpt while play animation");
+ BKE_report(op->reports, RPT_ERROR, "Cannot sculpt while animation is playing");
return OPERATOR_CANCELLED;
}
@@ -1936,7 +1938,7 @@ static int gpencil_sculpt_brush_invoke(bContext *C, wmOperator *op, const wmEven
gso = op->customdata;
- /* initialise type-specific data (used for the entire session) */
+ /* Initialize type-specific data (used for the entire session). */
char tool = gso->brush->gpencil_sculpt_tool;
switch (tool) {
/* Brushes requiring timer... */
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index f77bb394567..5aae10a5db5 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -1080,7 +1080,7 @@ void ED_gpencil_project_stroke_to_plane(const Scene *scene,
}
}
else {
- float scale[3] = {1.0f, 1.0f, 1.0f};
+ const float scale[3] = {1.0f, 1.0f, 1.0f};
plane_normal[2] = 1.0f;
float mat[4][4];
loc_eul_size_to_mat4(mat, cursor->location, cursor->rotation_euler, scale);
@@ -1285,7 +1285,7 @@ void ED_gpencil_project_point_to_plane(const Scene *scene,
}
}
else {
- float scale[3] = {1.0f, 1.0f, 1.0f};
+ const float scale[3] = {1.0f, 1.0f, 1.0f};
plane_normal[2] = 1.0f;
float mat[4][4];
loc_eul_size_to_mat4(mat, cursor->location, cursor->rotation_euler, scale);
@@ -1469,7 +1469,7 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata
/* Helper function to create new OB_GPENCIL Object */
Object *ED_gpencil_add_object(bContext *C, const float loc[3], ushort local_view_bits)
{
- float rot[3] = {0.0f};
+ const float rot[3] = {0.0f};
Object *ob = ED_object_add_type(C, OB_GPENCIL, NULL, loc, rot, false, local_view_bits);
@@ -1500,7 +1500,7 @@ void ED_gpencil_add_defaults(bContext *C, Object *ob)
if (ts->gp_sculpt.cur_falloff == NULL) {
ts->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff;
- BKE_curvemapping_initialize(gp_falloff_curve);
+ BKE_curvemapping_init(gp_falloff_curve);
BKE_curvemap_reset(gp_falloff_curve->cm,
&gp_falloff_curve->clipr,
CURVE_PRESET_GAUSS,
@@ -1723,7 +1723,7 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob)
/* Cursor drawing */
/* check if cursor is in drawing region */
-static bool gpencil_check_cursor_region(bContext *C, int mval_i[2])
+static bool gpencil_check_cursor_region(bContext *C, const int mval_i[2])
{
ARegion *region = CTX_wm_region(C);
ScrArea *area = CTX_wm_area(C);
@@ -2311,7 +2311,9 @@ static void gpencil_insert_point(
MEM_SAFE_FREE(temp_points);
}
-static float gpencil_calc_factor(float p2d_a1[2], float p2d_a2[2], float r_hit2d[2])
+static float gpencil_calc_factor(const float p2d_a1[2],
+ const float p2d_a2[2],
+ const float r_hit2d[2])
{
float dist1 = len_squared_v2v2(p2d_a1, p2d_a2);
float dist2 = len_squared_v2v2(p2d_a1, r_hit2d);
@@ -2688,7 +2690,11 @@ void ED_gpencil_tag_scene_gpencil(Scene *scene)
void ED_gpencil_fill_vertex_color_set(ToolSettings *ts, Brush *brush, bGPDstroke *gps)
{
- if (GPENCIL_USE_VERTEX_COLOR_FILL(ts, brush)) {
+ const bool is_vertex = (GPENCIL_USE_VERTEX_COLOR_FILL(ts, brush) &&
+ (brush->gpencil_settings->brush_draw_mode != GP_BRUSH_MODE_MATERIAL)) ||
+ (!GPENCIL_USE_VERTEX_COLOR_FILL(ts, brush) &&
+ (brush->gpencil_settings->brush_draw_mode == GP_BRUSH_MODE_VERTEXCOLOR));
+ if (is_vertex) {
copy_v3_v3(gps->vert_color_fill, brush->rgb);
gps->vert_color_fill[3] = brush->gpencil_settings->vertex_factor;
srgb_to_linearrgb_v4(gps->vert_color_fill, gps->vert_color_fill);
@@ -2703,7 +2709,12 @@ void ED_gpencil_point_vertex_color_set(ToolSettings *ts,
bGPDspoint *pt,
tGPspoint *tpt)
{
- if (GPENCIL_USE_VERTEX_COLOR_STROKE(ts, brush)) {
+ const bool is_vertex = (GPENCIL_USE_VERTEX_COLOR_STROKE(ts, brush) &&
+ (brush->gpencil_settings->brush_draw_mode != GP_BRUSH_MODE_MATERIAL)) ||
+ (!GPENCIL_USE_VERTEX_COLOR_STROKE(ts, brush) &&
+ (brush->gpencil_settings->brush_draw_mode == GP_BRUSH_MODE_VERTEXCOLOR));
+
+ if (is_vertex) {
if (tpt == NULL) {
copy_v3_v3(pt->vert_color, brush->rgb);
pt->vert_color[3] = brush->gpencil_settings->vertex_factor;
@@ -2859,6 +2870,18 @@ void ED_gpencil_sbuffer_vertex_color_set(Depsgraph *depsgraph,
bGPdata *gpd_eval = (bGPdata *)ob_eval->data;
MaterialGPencilStyle *gp_style = material->gp_style;
+ const bool is_vertex_fill =
+ (GPENCIL_USE_VERTEX_COLOR_FILL(ts, brush) &&
+ (brush->gpencil_settings->brush_draw_mode != GP_BRUSH_MODE_MATERIAL)) ||
+ (!GPENCIL_USE_VERTEX_COLOR_FILL(ts, brush) &&
+ (brush->gpencil_settings->brush_draw_mode == GP_BRUSH_MODE_VERTEXCOLOR));
+
+ const bool is_vertex_stroke =
+ (GPENCIL_USE_VERTEX_COLOR_STROKE(ts, brush) &&
+ (brush->gpencil_settings->brush_draw_mode != GP_BRUSH_MODE_MATERIAL)) ||
+ (!GPENCIL_USE_VERTEX_COLOR_STROKE(ts, brush) &&
+ (brush->gpencil_settings->brush_draw_mode == GP_BRUSH_MODE_VERTEXCOLOR));
+
int idx = gpd->runtime.sbuffer_used;
tGPspoint *tpt = (tGPspoint *)gpd->runtime.sbuffer + idx;
@@ -2868,14 +2891,14 @@ void ED_gpencil_sbuffer_vertex_color_set(Depsgraph *depsgraph,
srgb_to_linearrgb_v4(vertex_color, vertex_color);
/* Copy fill vertex color. */
- if (GPENCIL_USE_VERTEX_COLOR_FILL(ts, brush)) {
+ if (is_vertex_fill) {
copy_v4_v4(gpd->runtime.vert_color_fill, vertex_color);
}
else {
copy_v4_v4(gpd->runtime.vert_color_fill, gp_style->fill_rgba);
}
/* Copy stroke vertex color. */
- if (GPENCIL_USE_VERTEX_COLOR_STROKE(ts, brush)) {
+ if (is_vertex_stroke) {
copy_v4_v4(tpt->vert_color, vertex_color);
}
else {
@@ -2957,7 +2980,7 @@ bool ED_gpencil_stroke_point_is_inside(bGPDstroke *gps,
int(*mcoords)[2] = NULL;
int len = gps->totpoints;
- mcoords = MEM_mallocN(sizeof(int) * 2 * len, __func__);
+ mcoords = MEM_mallocN(sizeof(int[2]) * len, __func__);
/* Convert stroke to 2D array of points. */
bGPDspoint *pt;
diff --git a/source/blender/editors/gpencil/gpencil_uv.c b/source/blender/editors/gpencil/gpencil_uv.c
index e21b2049028..8304641611e 100644
--- a/source/blender/editors/gpencil/gpencil_uv.c
+++ b/source/blender/editors/gpencil/gpencil_uv.c
@@ -182,7 +182,7 @@ static bool gpencil_uv_transform_init(bContext *C, wmOperator *op)
if (i > 0) {
mul_v3_fl(center, 1.0f / i);
/* Create arrays to save all transformations. */
- opdata->array_loc = MEM_calloc_arrayN(i, 2 * sizeof(float), __func__);
+ opdata->array_loc = MEM_calloc_arrayN(i, sizeof(float[2]), __func__);
opdata->array_rot = MEM_calloc_arrayN(i, sizeof(float), __func__);
opdata->array_scale = MEM_calloc_arrayN(i, sizeof(float), __func__);
i = 0;
diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil/gpencil_vertex_paint.c
index c36bc4388d7..b0dff6589da 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_paint.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c
@@ -727,7 +727,7 @@ static bool gpencil_vertexpaint_brush_init(bContext *C, wmOperator *op)
gso->brush = paint->brush;
srgb_to_linearrgb_v3_v3(gso->linear_color, gso->brush->rgb);
- BKE_curvemapping_initialize(gso->brush->curve);
+ BKE_curvemapping_init(gso->brush->curve);
gso->is_painting = false;
gso->first = true;
@@ -759,7 +759,7 @@ static bool gpencil_vertexpaint_brush_init(bContext *C, wmOperator *op)
/* Init multi-edit falloff curve data before doing anything,
* so we won't have to do it again later. */
if (gso->is_multiframe) {
- BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff);
+ BKE_curvemapping_init(ts->gp_sculpt.cur_falloff);
}
/* Setup space conversions. */
diff --git a/source/blender/editors/gpencil/gpencil_weight_paint.c b/source/blender/editors/gpencil/gpencil_weight_paint.c
index e41146575e4..9d3e9c6ae45 100644
--- a/source/blender/editors/gpencil/gpencil_weight_paint.c
+++ b/source/blender/editors/gpencil/gpencil_weight_paint.c
@@ -295,7 +295,7 @@ static bool gpencil_weightpaint_brush_init(bContext *C, wmOperator *op)
gso->bmain = CTX_data_main(C);
gso->brush = paint->brush;
- BKE_curvemapping_initialize(gso->brush->curve);
+ BKE_curvemapping_init(gso->brush->curve);
gso->is_painting = false;
gso->first = true;
@@ -326,7 +326,7 @@ static bool gpencil_weightpaint_brush_init(bContext *C, wmOperator *op)
/* Init multi-edit falloff curve data before doing anything,
* so we won't have to do it again later. */
if (gso->is_multiframe) {
- BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff);
+ BKE_curvemapping_init(ts->gp_sculpt.cur_falloff);
}
/* Setup space conversions. */
@@ -453,9 +453,9 @@ static void gpencil_weightpaint_select_stroke(tGP_BrushWeightpaintData *gso,
/* To each point individually... */
pt = &gps->points[i];
- pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
- index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i;
+ pt_active = pt->runtime.pt_orig;
if (pt_active != NULL) {
+ index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i;
gpencil_save_selected_point(gso, gps_active, index, pc1);
}
@@ -469,9 +469,9 @@ static void gpencil_weightpaint_select_stroke(tGP_BrushWeightpaintData *gso,
*/
if (i + 1 == gps->totpoints - 1) {
pt = &gps->points[i + 1];
- pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
- index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i + 1;
+ pt_active = pt->runtime.pt_orig;
if (pt_active != NULL) {
+ index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i + 1;
gpencil_save_selected_point(gso, gps_active, index, pc2);
include_last = false;
}
@@ -487,9 +487,9 @@ static void gpencil_weightpaint_select_stroke(tGP_BrushWeightpaintData *gso,
* (but wasn't added then, to avoid double-ups).
*/
pt = &gps->points[i];
- pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
- index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i;
+ pt_active = pt->runtime.pt_orig;
if (pt_active != NULL) {
+ index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i;
gpencil_save_selected_point(gso, gps_active, index, pc1);
include_last = false;
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index cfd92bf3113..1d688b2ad68 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -21,8 +21,7 @@
* \ingroup editorui
*/
-#ifndef __BIF_GLUTIL_H__
-#define __BIF_GLUTIL_H__
+#pragma once
#include "GPU_texture.h"
@@ -73,7 +72,7 @@ void immDrawPixelsTex(IMMDrawPixelsTexState *state,
void *rect,
float xzoom,
float yzoom,
- float color[4]);
+ const float color[4]);
void immDrawPixelsTex_clipping(IMMDrawPixelsTexState *state,
float x,
float y,
@@ -88,7 +87,7 @@ void immDrawPixelsTex_clipping(IMMDrawPixelsTexState *state,
float clip_max_y,
float xzoom,
float yzoom,
- float color[4]);
+ const float color[4]);
void immDrawPixelsTexScaled(IMMDrawPixelsTexState *state,
float x,
float y,
@@ -101,7 +100,7 @@ void immDrawPixelsTexScaled(IMMDrawPixelsTexState *state,
float scaleY,
float xzoom,
float yzoom,
- float color[4]);
+ const float color[4]);
void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
float x,
float y,
@@ -118,7 +117,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
float clip_max_y,
float xzoom,
float yzoom,
- float color[4]);
+ const float color[4]);
/* Image buffer drawing functions, with display transform
*
@@ -175,5 +174,3 @@ void immDrawBorderCorners(unsigned int pos, const struct rcti *border, float zoo
#ifdef __cplusplus
}
#endif
-
-#endif /* __BIF_GLUTIL_H__ */
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 9d9f2925c23..36990414e6d 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_ANIM_API_H__
-#define __ED_ANIM_API_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -880,5 +879,3 @@ void animviz_get_object_motionpaths(struct Object *ob, ListBase *targets);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_ANIM_API_H__ */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index d82c7126cf2..62f4c068de0 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_ARMATURE_H__
-#define __ED_ARMATURE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -225,10 +224,10 @@ void ED_armature_ebone_remove(struct bArmature *arm, EditBone *exBone);
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child);
EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[],
const unsigned int ebone_child_tot);
-void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]);
-void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]);
-void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3]);
-void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]);
+void ED_armature_ebone_to_mat3(EditBone *ebone, float r_mat[3][3]);
+void ED_armature_ebone_to_mat4(EditBone *ebone, float r_mat[4][4]);
+void ED_armature_ebone_from_mat3(EditBone *ebone, const float mat[3][3]);
+void ED_armature_ebone_from_mat4(EditBone *ebone, const float mat[4][4]);
EditBone *ED_armature_ebone_find_name(const struct ListBase *edbo, const char *name);
EditBone *ED_armature_ebone_get_mirrored(const struct ListBase *edbo, EditBone *ebo);
void ED_armature_ebone_transform_mirror_update(struct bArmature *arm,
@@ -298,5 +297,3 @@ void ED_mesh_deform_bind_callback(struct MeshDeformModifierData *mmd,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_ARMATURE_H__ */
diff --git a/source/blender/editors/include/ED_buttons.h b/source/blender/editors/include/ED_buttons.h
index 455eee8580d..ccef62eb8d2 100644
--- a/source/blender/editors/include/ED_buttons.h
+++ b/source/blender/editors/include/ED_buttons.h
@@ -20,8 +20,7 @@
* \ingroup editors
*/
-#ifndef __ED_BUTTONS_H__
-#define __ED_BUTTONS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -34,5 +33,3 @@ int ED_buttons_tabs_list(struct SpaceProperties *sbuts, int *context_tabs_array)
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_BUTTONS_H__ */
diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h
index f270a0324f9..0a66c439f79 100644
--- a/source/blender/editors/include/ED_clip.h
+++ b/source/blender/editors/include/ED_clip.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_CLIP_H__
-#define __ED_CLIP_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -106,5 +105,3 @@ void ED_operatormacros_clip(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_CLIP_H__ */
diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h
index 79f5f62f293..f9b1d9cdc64 100644
--- a/source/blender/editors/include/ED_curve.h
+++ b/source/blender/editors/include/ED_curve.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_CURVE_H__
-#define __ED_CURVE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -111,5 +110,3 @@ void printknots(struct Object *obedit);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_CURVE_H__ */
diff --git a/source/blender/editors/include/ED_datafiles.h b/source/blender/editors/include/ED_datafiles.h
index ad1cde5406d..ba77da24406 100644
--- a/source/blender/editors/include/ED_datafiles.h
+++ b/source/blender/editors/include/ED_datafiles.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_DATAFILES_H__
-#define __ED_DATAFILES_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -301,5 +300,3 @@ extern char datatoc_gp_brush_erase_stroke_png[];
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_DATAFILES_H__ */
diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h
index 8a239559627..deda0861b60 100644
--- a/source/blender/editors/include/ED_fileselect.h
+++ b/source/blender/editors/include/ED_fileselect.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_FILESELECT_H__
-#define __ED_FILESELECT_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -214,5 +213,3 @@ void ED_fsmenu_entry_set_icon(struct FSMenuEntry *fsentry, const int icon);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_FILESELECT_H__ */
diff --git a/source/blender/editors/include/ED_gizmo_library.h b/source/blender/editors/include/ED_gizmo_library.h
index a1a5d65b61d..0ee3b00e426 100644
--- a/source/blender/editors/include/ED_gizmo_library.h
+++ b/source/blender/editors/include/ED_gizmo_library.h
@@ -22,8 +22,7 @@
* This is exposes pre-defined gizmos for re-use.
*/
-#ifndef __ED_GIZMO_LIBRARY_H__
-#define __ED_GIZMO_LIBRARY_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -278,5 +277,3 @@ short ED_gizmotypes_snap_3d_update(struct wmGizmo *gz,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_GIZMO_LIBRARY_H__ */
diff --git a/source/blender/editors/include/ED_gizmo_utils.h b/source/blender/editors/include/ED_gizmo_utils.h
index 70ff8a8d32f..0cfc3df9d54 100644
--- a/source/blender/editors/include/ED_gizmo_utils.h
+++ b/source/blender/editors/include/ED_gizmo_utils.h
@@ -20,8 +20,7 @@
* \name Generic Gizmo Utilities.
*/
-#ifndef __ED_GIZMO_UTILS_H__
-#define __ED_GIZMO_UTILS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -46,5 +45,3 @@ bool ED_gizmo_poll_or_unlink_delayed_from_tool(const struct bContext *C,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_GIZMO_UTILS_H__ */
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 64276706759..06839276027 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_GPENCIL_H__
-#define __ED_GPENCIL_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -362,5 +361,3 @@ bool ED_gpencil_stroke_point_is_inside(struct bGPDstroke *gps,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_GPENCIL_H__ */
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index e8343fbbc19..65ca181e160 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_IMAGE_H__
-#define __ED_IMAGE_H__
+#pragma once
#include "DNA_listBase.h"
#include "DNA_space_types.h"
@@ -157,5 +156,3 @@ ListBase ED_image_filesel_detect_sequences(struct Main *bmain,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_IMAGE_H__ */
diff --git a/source/blender/editors/include/ED_info.h b/source/blender/editors/include/ED_info.h
index e97fd424742..df6b6a20ddc 100644
--- a/source/blender/editors/include/ED_info.h
+++ b/source/blender/editors/include/ED_info.h
@@ -20,8 +20,7 @@
* \ingroup editors
*/
-#ifndef __ED_INFO_H__
-#define __ED_INFO_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -40,5 +39,3 @@ void ED_info_draw_stats(
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_INFO_H__ */
diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h
index 7000075d4b5..adc1e09821e 100644
--- a/source/blender/editors/include/ED_keyframes_draw.h
+++ b/source/blender/editors/include/ED_keyframes_draw.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_KEYFRAMES_DRAW_H__
-#define __ED_KEYFRAMES_DRAW_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -273,5 +272,3 @@ int actkeyblock_get_valid_hold(ActKeyColumn *ab);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_KEYFRAMES_DRAW_H__ */
diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h
index 28bc0b22790..b08ab57545f 100644
--- a/source/blender/editors/include/ED_keyframes_edit.h
+++ b/source/blender/editors/include/ED_keyframes_edit.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_KEYFRAMES_EDIT_H__
-#define __ED_KEYFRAMES_EDIT_H__
+#pragma once
#include "ED_anim_api.h" /* for enum eAnimFilter_Flags */
@@ -340,5 +339,3 @@ short paste_animedit_keys(struct bAnimContext *ac,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_KEYFRAMES_EDIT_H__ */
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 3fe6407aae7..7f833cd59bf 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_KEYFRAMING_H__
-#define __ED_KEYFRAMING_H__
+#pragma once
#include "DNA_anim_types.h"
#include "RNA_types.h"
@@ -516,5 +515,3 @@ bool ED_autokeyframe_property(struct bContext *C,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_KEYFRAMING_H__ */
diff --git a/source/blender/editors/include/ED_lattice.h b/source/blender/editors/include/ED_lattice.h
index 2e4b9472ce7..6982ad20f07 100644
--- a/source/blender/editors/include/ED_lattice.h
+++ b/source/blender/editors/include/ED_lattice.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_LATTICE_H__
-#define __ED_LATTICE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -51,5 +50,3 @@ void ED_lattice_undosys_type(struct UndoType *ut);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_LATTICE_H__ */
diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h
index 54a5d0cb0e1..8c10a8e36fd 100644
--- a/source/blender/editors/include/ED_markers.h
+++ b/source/blender/editors/include/ED_markers.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_MARKERS_H__
-#define __ED_MARKERS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -77,5 +76,3 @@ void debug_markers_print_list(struct ListBase *markers);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_MARKERS_H__ */
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h
index 5aafc0702da..80510d3afa1 100644
--- a/source/blender/editors/include/ED_mask.h
+++ b/source/blender/editors/include/ED_mask.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_MASK_H__
-#define __ED_MASK_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -125,5 +124,3 @@ void mirror_masklayer_frames(struct MaskLayer *mask_layer, short mode);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_MASK_H__ */
diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h
index 5c2106b934c..7648af159c9 100644
--- a/source/blender/editors/include/ED_mball.h
+++ b/source/blender/editors/include/ED_mball.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_MBALL_H__
-#define __ED_MBALL_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -65,5 +64,3 @@ void ED_mball_undosys_type(struct UndoType *ut);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_MBALL_H__ */
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 392a5075750..f2cad1acc84 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_MESH_H__
-#define __ED_MESH_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -517,5 +516,3 @@ void EDBM_mesh_elem_index_ensure_multi(struct Object **objects,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_MESH_H__ */
diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h
index 382902cd2de..ecb98a46f99 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_NODE_H__
-#define __ED_NODE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -127,5 +126,3 @@ bool ED_space_node_color_sample(struct Main *bmain,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_NODE_H__ */
diff --git a/source/blender/editors/include/ED_numinput.h b/source/blender/editors/include/ED_numinput.h
index 16d05a7793a..6c5aacafc7a 100644
--- a/source/blender/editors/include/ED_numinput.h
+++ b/source/blender/editors/include/ED_numinput.h
@@ -18,8 +18,7 @@
* \ingroup editors
*/
-#ifndef __ED_NUMINPUT_H__
-#define __ED_NUMINPUT_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -115,5 +114,3 @@ bool user_string_to_number(bContext *C,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_NUMINPUT_H__ */
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index e08be5937fe..4c7dd4fe66c 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_OBJECT_H__
-#define __ED_OBJECT_H__
+#pragma once
#include "BLI_compiler_attrs.h"
#include "DNA_object_enums.h"
@@ -502,5 +501,3 @@ void ED_object_data_xform_tag_update(struct XFormObjectData *xod);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_OBJECT_H__ */
diff --git a/source/blender/editors/include/ED_outliner.h b/source/blender/editors/include/ED_outliner.h
index 0325ad9fdba..1d1471f0be6 100644
--- a/source/blender/editors/include/ED_outliner.h
+++ b/source/blender/editors/include/ED_outliner.h
@@ -20,8 +20,7 @@
* \ingroup editors
*/
-#ifndef __ED_OUTLINER_H__
-#define __ED_OUTLINER_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -46,12 +45,11 @@ void ED_outliner_select_sync_from_all_tag(struct bContext *C);
bool ED_outliner_select_sync_is_dirty(const struct bContext *C);
-void ED_outliner_select_sync_from_outliner(struct bContext *C, struct SpaceOutliner *soops);
+void ED_outliner_select_sync_from_outliner(struct bContext *C,
+ struct SpaceOutliner *space_outliner);
void ED_outliner_select_sync_flag_outliners(const struct bContext *C);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_OUTLINER_H__ */
diff --git a/source/blender/editors/include/ED_paint.h b/source/blender/editors/include/ED_paint.h
index 4159f22703f..3412d62317e 100644
--- a/source/blender/editors/include/ED_paint.h
+++ b/source/blender/editors/include/ED_paint.h
@@ -18,8 +18,7 @@
* \ingroup editors
*/
-#ifndef __ED_PAINT_H__
-#define __ED_PAINT_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -104,5 +103,3 @@ void ED_paintcurve_undosys_type(struct UndoType *ut);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_PAINT_H__ */
diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h
index 789db5ae56e..e84298bd9c2 100644
--- a/source/blender/editors/include/ED_particle.h
+++ b/source/blender/editors/include/ED_particle.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_PARTICLE_H__
-#define __ED_PARTICLE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -83,5 +82,3 @@ void ED_particle_undosys_type(struct UndoType *ut);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_PARTICLE_H__ */
diff --git a/source/blender/editors/include/ED_physics.h b/source/blender/editors/include/ED_physics.h
index ebd7e387c83..f9c56f31ebd 100644
--- a/source/blender/editors/include/ED_physics.h
+++ b/source/blender/editors/include/ED_physics.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_PHYSICS_H__
-#define __ED_PHYSICS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -63,5 +62,3 @@ void ED_keymap_physics(struct wmKeyConfig *keyconf);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_PHYSICS_H__ */
diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h
index ba70abcc055..d580e36d0ce 100644
--- a/source/blender/editors/include/ED_render.h
+++ b/source/blender/editors/include/ED_render.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_RENDER_H__
-#define __ED_RENDER_H__
+#pragma once
#include "DNA_vec_types.h"
@@ -110,5 +109,3 @@ void ED_render_internal_init(void);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/editors/include/ED_scene.h b/source/blender/editors/include/ED_scene.h
index 27c2e9d0df8..e3abd26a4cd 100644
--- a/source/blender/editors/include/ED_scene.h
+++ b/source/blender/editors/include/ED_scene.h
@@ -18,8 +18,7 @@
* \ingroup editors
*/
-#ifndef __ED_SCENE_H__
-#define __ED_SCENE_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -46,5 +45,3 @@ void ED_operatortypes_scene(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_SCENE_H__ */
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 71b7d35908b..29fe766b2d0 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_SCREEN_H__
-#define __ED_SCREEN_H__
+#pragma once
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
@@ -73,7 +72,7 @@ void ED_region_exit(struct bContext *C, struct ARegion *region);
void ED_region_remove(struct bContext *C, struct ScrArea *area, struct ARegion *region);
void ED_region_pixelspace(struct ARegion *region);
void ED_region_update_rect(struct ARegion *region);
-void ED_region_floating_initialize(struct ARegion *region);
+void ED_region_floating_init(struct ARegion *region);
void ED_region_tag_redraw(struct ARegion *region);
void ED_region_tag_redraw_partial(struct ARegion *region, const struct rcti *rct, bool rebuild);
void ED_region_tag_redraw_cursor(struct ARegion *region);
@@ -171,7 +170,7 @@ void ED_spacetypes_keymap(struct wmKeyConfig *keyconf);
int ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *block, int yco);
/* areas */
-void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area);
+void ED_area_init(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area);
void ED_area_exit(struct bContext *C, struct ScrArea *area);
int ED_screen_area_active(const struct bContext *C);
void ED_screen_global_areas_refresh(struct wmWindow *win);
@@ -221,7 +220,7 @@ ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area);
vert_name->next)
/* screens */
-void ED_screens_initialize(struct Main *bmain, struct wmWindowManager *wm);
+void ED_screens_init(struct Main *bmain, struct wmWindowManager *wm);
void ED_screen_draw_edges(struct wmWindow *win);
void ED_screen_draw_join_shape(struct ScrArea *sa1, struct ScrArea *sa2);
void ED_screen_draw_split_preview(struct ScrArea *area, const int dir, const float fac);
@@ -287,6 +286,12 @@ bool ED_workspace_delete(struct WorkSpace *workspace,
struct bContext *C,
struct wmWindowManager *wm) ATTR_NONNULL();
void ED_workspace_scene_data_sync(struct WorkSpaceInstanceHook *hook, Scene *scene) ATTR_NONNULL();
+struct WorkSpaceLayout *ED_workspace_screen_change_ensure_unused_layout(
+ struct Main *bmain,
+ struct WorkSpace *workspace,
+ struct WorkSpaceLayout *layout_new,
+ const struct WorkSpaceLayout *layout_fallback_base,
+ struct wmWindow *win) ATTR_NONNULL();
struct WorkSpaceLayout *ED_workspace_layout_add(struct Main *bmain,
struct WorkSpace *workspace,
struct wmWindow *win,
@@ -477,5 +482,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_SCREEN_H__ */
diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h
index 9826ec8c3b8..0185de426f3 100644
--- a/source/blender/editors/include/ED_screen_types.h
+++ b/source/blender/editors/include/ED_screen_types.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_SCREEN_TYPES_H__
-#define __ED_SCREEN_TYPES_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -140,5 +139,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_SCREEN_TYPES_H__ */
diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h
index e61c7be5216..c3abde479f1 100644
--- a/source/blender/editors/include/ED_sculpt.h
+++ b/source/blender/editors/include/ED_sculpt.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_SCULPT_H__
-#define __ED_SCULPT_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -62,5 +61,3 @@ void ED_sculpt_undo_push_multires_mesh_end(struct bContext *C, const char *str);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_SCULPT_H__ */
diff --git a/source/blender/editors/include/ED_select_utils.h b/source/blender/editors/include/ED_select_utils.h
index 9c7cc0ef7a2..049ea7a092f 100644
--- a/source/blender/editors/include/ED_select_utils.h
+++ b/source/blender/editors/include/ED_select_utils.h
@@ -18,8 +18,7 @@
* \ingroup editors
*/
-#ifndef __ED_SELECT_UTILS_H__
-#define __ED_SELECT_UTILS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -78,5 +77,3 @@ eSelectOp ED_select_op_modal(const eSelectOp sel_op, const bool is_first);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_SELECT_UTILS_H__ */
diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h
index f35ed12cdb9..11eff2d583b 100644
--- a/source/blender/editors/include/ED_sequencer.h
+++ b/source/blender/editors/include/ED_sequencer.h
@@ -20,8 +20,7 @@
* \ingroup editors
*/
-#ifndef __ED_SEQUENCER_H__
-#define __ED_SEQUENCER_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -53,5 +52,3 @@ void ED_sequencer_special_preview_clear(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_SEQUENCER_H__ */
diff --git a/source/blender/editors/include/ED_sound.h b/source/blender/editors/include/ED_sound.h
index f7632bc81cb..022c7784ed3 100644
--- a/source/blender/editors/include/ED_sound.h
+++ b/source/blender/editors/include/ED_sound.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_SOUND_H__
-#define __ED_SOUND_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -33,5 +32,3 @@ void ED_operatortypes_sound(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_SOUND_H__ */
diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index ae4add2fca2..f3e867e8360 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_SPACE_API_H__
-#define __ED_SPACE_API_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -83,5 +82,3 @@ void ED_region_draw_mouse_line_cb(const struct bContext *C,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_SPACE_API_H__ */
diff --git a/source/blender/editors/include/ED_text.h b/source/blender/editors/include/ED_text.h
index 4f7b76675f0..6742561735e 100644
--- a/source/blender/editors/include/ED_text.h
+++ b/source/blender/editors/include/ED_text.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_TEXT_H__
-#define __ED_TEXT_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -51,5 +50,3 @@ bool ED_text_is_syntax_highlight_supported(struct Text *text);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_TEXT_H__ */
diff --git a/source/blender/editors/include/ED_time_scrub_ui.h b/source/blender/editors/include/ED_time_scrub_ui.h
index 483dce56577..216e67dd820 100644
--- a/source/blender/editors/include/ED_time_scrub_ui.h
+++ b/source/blender/editors/include/ED_time_scrub_ui.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_TIME_SCRUB_UI_H__
-#define __ED_TIME_SCRUB_UI_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -51,5 +50,3 @@ void ED_time_scrub_channel_search_draw(const struct bContext *C,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_TIME_SCRUB_UI_H__ */
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 29ed0485490..4c4672edffc 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_TRANSFORM_H__
-#define __ED_TRANSFORM_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -215,5 +214,3 @@ int ED_transform_calc_gizmo_stats(const struct bContext *C,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_TRANSFORM_H__ */
diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h b/source/blender/editors/include/ED_transform_snap_object_context.h
index 8feb73436a6..ebaa32941f2 100644
--- a/source/blender/editors/include/ED_transform_snap_object_context.h
+++ b/source/blender/editors/include/ED_transform_snap_object_context.h
@@ -18,8 +18,7 @@
* \ingroup editors
*/
-#ifndef __ED_TRANSFORM_SNAP_OBJECT_CONTEXT_H__
-#define __ED_TRANSFORM_SNAP_OBJECT_CONTEXT_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -157,5 +156,3 @@ bool ED_transform_snap_object_project_all_view3d_ex(SnapObjectContext *sctx,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_TRANSFORM_SNAP_OBJECT_CONTEXT_H__ */
diff --git a/source/blender/editors/include/ED_transverts.h b/source/blender/editors/include/ED_transverts.h
index 062658a562b..bff31149b75 100644
--- a/source/blender/editors/include/ED_transverts.h
+++ b/source/blender/editors/include/ED_transverts.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_TRANSVERTS_H__
-#define __ED_TRANSVERTS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -75,5 +74,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_TRANSVERTS_H__ */
diff --git a/source/blender/editors/include/ED_types.h b/source/blender/editors/include/ED_types.h
index 4abb7d446d1..ab9098a33c5 100644
--- a/source/blender/editors/include/ED_types.h
+++ b/source/blender/editors/include/ED_types.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_TYPES_H__
-#define __ED_TYPES_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -42,5 +41,3 @@ extern "C" {
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_TYPES_H__ */
diff --git a/source/blender/editors/include/ED_undo.h b/source/blender/editors/include/ED_undo.h
index 983e0c4f14a..dbd374415b0 100644
--- a/source/blender/editors/include/ED_undo.h
+++ b/source/blender/editors/include/ED_undo.h
@@ -18,8 +18,7 @@
* \ingroup editors
*/
-#ifndef __ED_UNDO_H__
-#define __ED_UNDO_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -89,5 +88,3 @@ struct MemFile *ED_undosys_stack_memfile_get_active(struct UndoStack *ustack);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_UNDO_H__ */
diff --git a/source/blender/editors/include/ED_userpref.h b/source/blender/editors/include/ED_userpref.h
index 1d43009e37c..e588fa31ad5 100644
--- a/source/blender/editors/include/ED_userpref.h
+++ b/source/blender/editors/include/ED_userpref.h
@@ -18,8 +18,7 @@
* \ingroup editors
*/
-#ifndef __ED_USERPREF_H__
-#define __ED_USERPREF_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ void ED_operatortypes_userpref(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_USERPREF_H__ */
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index 1f2706957a7..68ae3589064 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_UTIL_H__
-#define __ED_UTIL_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -71,5 +70,3 @@ void unpack_menu(struct bContext *C,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_UTIL_H__ */
diff --git a/source/blender/editors/include/ED_util_imbuf.h b/source/blender/editors/include/ED_util_imbuf.h
index 76171383b49..d142d3d6425 100644
--- a/source/blender/editors/include/ED_util_imbuf.h
+++ b/source/blender/editors/include/ED_util_imbuf.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_UTIL_IMBUF_H__
-#define __ED_UTIL_IMBUF_H__
+#pragma once
#include "BLI_compiler_attrs.h"
#include "BLI_sys_types.h"
@@ -48,5 +47,3 @@ bool ED_imbuf_sample_poll(struct bContext *C);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_UTIL_IMBUF_H__ */
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index c89a9fe0e99..53fb79bb012 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_UVEDIT_H__
-#define __ED_UVEDIT_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -217,6 +216,9 @@ struct BMLoop *ED_uvedit_active_vert_loop_get(struct BMesh *bm);
void ED_uvedit_active_edge_loop_set(struct BMesh *bm, struct BMLoop *l);
struct BMLoop *ED_uvedit_active_edge_loop_get(struct BMesh *bm);
+char ED_uvedit_select_mode_get(const Scene *scene);
+void ED_uvedit_select_sync_flush(const ToolSettings *ts, struct BMEditMesh *em, const bool select);
+
/* uvedit_unwrap_ops.c */
void ED_uvedit_live_unwrap_begin(struct Scene *scene, struct Object *obedit);
void ED_uvedit_live_unwrap_re_solve(void);
@@ -240,5 +242,3 @@ void ED_uvedit_buttons_register(struct ARegionType *art);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_UVEDIT_H__ */
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index f44b099f42e..ddbea592238 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_VIEW3D_H__
-#define __ED_VIEW3D_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -135,13 +134,13 @@ bool ED_view3d_has_workbench_in_texture_color(const struct Scene *scene,
void ED_view3d_cursor3d_position(struct bContext *C,
const int mval[2],
const bool use_depth,
- float cursor_co[3]);
+ float r_cursor_co[3]);
void ED_view3d_cursor3d_position_rotation(struct bContext *C,
const int mval[2],
const bool use_depth,
enum eV3DCursorOrient orientation,
- float cursor_co[3],
- float cursor_quat[4]);
+ float r_cursor_co[3],
+ float r_cursor_quat[4]);
void ED_view3d_cursor3d_update(struct bContext *C,
const int mval[2],
const bool use_depth,
@@ -403,10 +402,10 @@ bool ED_view3d_win_to_segment_clipped(struct Depsgraph *depsgraph,
const bool do_clip);
void ED_view3d_ob_project_mat_get(const struct RegionView3D *v3d,
struct Object *ob,
- float pmat[4][4]);
+ float r_pmat[4][4]);
void ED_view3d_ob_project_mat_get_from_obmat(const struct RegionView3D *rv3d,
- float obmat[4][4],
- float pmat[4][4]);
+ const float obmat[4][4],
+ float r_pmat[4][4]);
void ED_view3d_project(const struct ARegion *region, const float world[3], float r_region_co[3]);
bool ED_view3d_unproject(
@@ -460,7 +459,7 @@ void ED_view3d_clipping_calc(struct BoundBox *bb,
const struct ARegion *region,
const struct Object *ob,
const struct rcti *rect);
-void ED_view3d_clipping_local(struct RegionView3D *rv3d, float mat[4][4]);
+void ED_view3d_clipping_local(struct RegionView3D *rv3d, const float mat[4][4]);
bool ED_view3d_clipping_test(const struct RegionView3D *rv3d,
const float co[3],
const bool is_local);
@@ -601,8 +600,8 @@ void ED_view3d_draw_setup_view(const struct wmWindowManager *wm,
struct Scene *scene,
struct ARegion *region,
struct View3D *v3d,
- float viewmat[4][4],
- float winmat[4][4],
+ const float viewmat[4][4],
+ const float winmat[4][4],
const struct rcti *rect);
struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]);
@@ -613,11 +612,11 @@ void ED_view3d_update_viewmat(struct Depsgraph *depsgraph,
const struct Scene *scene,
struct View3D *v3d,
struct ARegion *region,
- float viewmat[4][4],
- float winmat[4][4],
+ const float viewmat[4][4],
+ const float winmat[4][4],
const struct rcti *rect,
bool offscreen);
-bool ED_view3d_quat_from_axis_view(const char view, const char view_axis_roll, float quat[4]);
+bool ED_view3d_quat_from_axis_view(const char view, const char view_axis_roll, float r_quat[4]);
bool ED_view3d_quat_to_axis_view(const float viewquat[4],
const float epsilon,
char *r_view,
@@ -676,7 +675,9 @@ void ED_view3d_lock_clear(struct View3D *v3d);
#define VIEW3D_MARGIN 1.4f
#define VIEW3D_DIST_FALLBACK 1.0f
-float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float dist_fallback);
+float ED_view3d_offset_distance(const float mat[4][4],
+ const float ofs[3],
+ const float dist_fallback);
void ED_view3d_distance_set(struct RegionView3D *rv3d, const float dist);
bool ED_view3d_distance_set_from_location(struct RegionView3D *rv3d,
const float dist_co[3],
@@ -697,17 +698,6 @@ float ED_view3d_grid_view_scale(struct Scene *scene,
void ED_scene_draw_fps(const struct Scene *scene, int xoffset, int *yoffset);
-/* view matrix properties utilities */
-/* unused */
-#if 0
-void ED_view3d_operator_properties_viewmat(struct wmOperatorType *ot);
-void ED_view3d_operator_properties_viewmat_set(struct bContext *C, struct wmOperator *op);
-void ED_view3d_operator_properties_viewmat_get(struct wmOperator *op,
- int *winx,
- int *winy,
- float persmat[4][4]);
-#endif
-
/* render */
void ED_view3d_stop_render_preview(struct wmWindowManager *wm, struct ARegion *region);
void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *area);
@@ -759,5 +749,3 @@ bool ED_view3d_is_region_xr_mirror_active(const struct wmWindowManager *wm,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_VIEW3D_H__ */
diff --git a/source/blender/editors/include/ED_view3d_offscreen.h b/source/blender/editors/include/ED_view3d_offscreen.h
index 11d1aed1e73..2833d205e77 100644
--- a/source/blender/editors/include/ED_view3d_offscreen.h
+++ b/source/blender/editors/include/ED_view3d_offscreen.h
@@ -21,8 +21,7 @@
* \ingroup editors
*/
-#ifndef __ED_VIEW3D_OFFSCREEN_H__
-#define __ED_VIEW3D_OFFSCREEN_H__
+#pragma once
#include "DNA_object_enums.h"
#include "DNA_view3d_types.h"
@@ -49,8 +48,8 @@ void ED_view3d_draw_offscreen(struct Depsgraph *depsgraph,
struct ARegion *region,
int winx,
int winy,
- float viewmat[4][4],
- float winmat[4][4],
+ const float viewmat[4][4],
+ const float winmat[4][4],
bool is_image_render,
bool do_sky,
bool is_persp,
@@ -65,8 +64,8 @@ void ED_view3d_draw_offscreen_simple(struct Depsgraph *depsgraph,
int winx,
int winy,
unsigned int draw_flags,
- float viewmat[4][4],
- float winmat[4][4],
+ const float viewmat[4][4],
+ const float winmat[4][4],
float clip_start,
float clip_end,
bool is_image_render,
@@ -106,5 +105,3 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Depsgraph *depsgraph,
#ifdef __cplusplus
}
#endif
-
-#endif /* __ED_VIEW3D_H__ */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index a3fc66484d0..10c9c81bddb 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -21,8 +21,7 @@
* \ingroup editorui
*/
-#ifndef __UI_INTERFACE_H__
-#define __UI_INTERFACE_H__
+#pragma once
#include "BLI_compiler_attrs.h"
#include "BLI_sys_types.h" /* size_t */
@@ -58,6 +57,7 @@ struct bNodeSocket;
struct bNodeTree;
struct bScreen;
struct rcti;
+struct uiButSearch;
struct uiFontStyle;
struct uiList;
struct uiStyle;
@@ -101,7 +101,7 @@ typedef struct uiPopupBlockHandle uiPopupBlockHandle;
/* use for clamping popups within the screen */
#define UI_SCREEN_MARGIN 10
-/* uiBlock->dt and uiBut->dt */
+/** #uiBlock.emboss and #uiBut.emboss */
enum {
UI_EMBOSS = 0, /* use widget style for drawing */
UI_EMBOSS_NONE = 1, /* Nothing, only icon and/or text */
@@ -377,12 +377,13 @@ typedef enum {
UI_BTYPE_SEPR_SPACER = 56 << 9,
/** Resize handle (resize uilist). */
UI_BTYPE_GRIP = 57 << 9,
+ UI_BTYPE_DECORATOR = 58 << 9,
} eButType;
#define BUTTYPE (63 << 9)
/** Gradient types, for color picker #UI_BTYPE_HSVCUBE etc. */
-enum {
+typedef enum eButGradientType {
UI_GRAD_SV = 0,
UI_GRAD_HV = 1,
UI_GRAD_HS = 2,
@@ -392,9 +393,7 @@ enum {
UI_GRAD_V_ALT = 9,
UI_GRAD_L_ALT = 10,
-};
-
-#define UI_PALETTE_COLOR 20
+} eButGradientType;
/* Drawing
*
@@ -506,7 +505,7 @@ typedef int (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
/* Search types. */
typedef struct ARegion *(*uiButSearchCreateFn)(struct bContext *C,
struct ARegion *butregion,
- uiBut *but);
+ struct uiButSearch *search_but);
typedef void (*uiButSearchUpdateFn)(const struct bContext *C,
void *arg,
const char *str,
@@ -543,7 +542,7 @@ typedef bool (*uiMenuStepFunc)(struct bContext *C, int direction, void *arg1);
bool UI_but_has_tooltip_label(const uiBut *but);
bool UI_but_is_tool(const uiBut *but);
bool UI_but_is_utf8(const uiBut *but);
-#define UI_but_is_decorator(but) ((but)->func == ui_but_anim_decorate_cb)
+#define UI_but_is_decorator(but) ((but)->type == UI_BTYPE_DECORATOR)
bool UI_block_is_empty_ex(const uiBlock *block, const bool skip_title);
bool UI_block_is_empty(const uiBlock *block);
@@ -662,7 +661,7 @@ bool UI_popup_block_name_exists(const struct bScreen *screen, const char *name);
uiBlock *UI_block_begin(const struct bContext *C,
struct ARegion *region,
const char *name,
- short dt);
+ char emboss);
void UI_block_end_ex(const struct bContext *C, uiBlock *block, const int xy[2], int r_xy[2]);
void UI_block_end(const struct bContext *C, uiBlock *block);
void UI_block_draw(const struct bContext *C, struct uiBlock *block);
@@ -676,7 +675,7 @@ enum {
};
void UI_block_theme_style_set(uiBlock *block, char theme_style);
char UI_block_emboss_get(uiBlock *block);
-void UI_block_emboss_set(uiBlock *block, char dt);
+void UI_block_emboss_set(uiBlock *block, char emboss);
bool UI_block_has_search_filter(const uiBlock *block);
bool UI_block_is_search_only(const uiBlock *block);
void UI_block_set_search_only(uiBlock *block, bool search_only);
@@ -1945,8 +1944,6 @@ uiLayout *uiLayoutGridFlow(uiLayout *layout,
uiLayout *uiLayoutBox(uiLayout *layout);
uiLayout *uiLayoutListBox(uiLayout *layout,
struct uiList *ui_list,
- struct PointerRNA *ptr,
- struct PropertyRNA *prop,
struct PointerRNA *actptr,
struct PropertyRNA *actprop);
uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align);
@@ -2597,5 +2594,3 @@ void UI_interface_tag_script_reload(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __UI_INTERFACE_H__ */
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index 0529ee08da6..7b59d45b203 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -21,8 +21,7 @@
* \ingroup editorui
*/
-#ifndef __UI_INTERFACE_ICONS_H__
-#define __UI_INTERFACE_ICONS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -111,5 +110,3 @@ int UI_library_icon_get(const struct ID *id);
#ifdef __cplusplus
}
#endif
-
-#endif /* __UI_INTERFACE_ICONS_H__ */
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index c5c4ca79f14..3f548f98e97 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -21,8 +21,7 @@
* \ingroup editorui
*/
-#ifndef __UI_RESOURCES_H__
-#define __UI_RESOURCES_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -458,5 +457,3 @@ void UI_make_axis_color(const unsigned char *src_col, unsigned char *dst_col, co
#ifdef __cplusplus
}
#endif
-
-#endif /* __UI_RESOURCES_H__ */
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 0ddc45f4878..6e0f4434b7b 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -23,8 +23,7 @@
* \ingroup editorui
*/
-#ifndef __UI_VIEW2D_H__
-#define __UI_VIEW2D_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -288,5 +287,3 @@ void VIEW2D_GGT_navigate_impl(struct wmGizmoGroupType *gzgt, const char *idname)
#ifdef __cplusplus
}
#endif
-
-#endif /* __UI_VIEW2D_H__ */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index b8c0199cd28..9ab63b4cb8f 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -807,7 +807,12 @@ static bool ui_but_update_from_old_block(const bContext *C,
SWAP(ListBase, but->extra_op_icons, oldbut->extra_op_icons);
- SWAP(struct uiButSearchData *, oldbut->search, but->search);
+ if (oldbut->type == UI_BTYPE_SEARCH_MENU) {
+ uiButSearch *search_oldbut = (uiButSearch *)oldbut, *search_but = (uiButSearch *)but;
+
+ SWAP(uiButSearchArgFreeFn, search_oldbut->arg_free_fn, search_but->arg_free_fn);
+ SWAP(void *, search_oldbut->arg, search_but->arg);
+ }
/* copy hardmin for list rows to prevent 'sticking' highlight to mouse position
* when scrolling without moving mouse (see [#28432]) */
@@ -815,10 +820,10 @@ static bool ui_but_update_from_old_block(const bContext *C,
oldbut->hardmax = but->hardmax;
}
- /* Selectively copy a1, a2 since their use differs across all button types
- * (and we'll probably split these out later) */
- if (ELEM(oldbut->type, UI_BTYPE_PROGRESS_BAR)) {
- oldbut->a1 = but->a1;
+ if (oldbut->type == UI_BTYPE_PROGRESS_BAR) {
+ uiButProgressbar *progress_oldbut = (uiButProgressbar *)oldbut;
+ uiButProgressbar *progress_but = (uiButProgressbar *)but;
+ progress_oldbut->progress = progress_but->progress;
}
if (!BLI_listbase_is_empty(&block->butstore)) {
@@ -892,6 +897,12 @@ bool UI_but_active_only_ex(
}
}
if ((activate == true) || (found == false)) {
+ /* There might still be another active button. */
+ uiBut *old_active = ui_region_find_active_but(region);
+ if (old_active) {
+ ui_but_active_free(C, old_active);
+ }
+
ui_but_activate_event((bContext *)C, region, but);
}
else if ((found == true) && (isactive == false)) {
@@ -1486,7 +1497,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
continue;
}
}
- else if (but->dt != UI_EMBOSS_PULLDOWN) {
+ else if (but->emboss != UI_EMBOSS_PULLDOWN) {
continue;
}
@@ -1767,7 +1778,7 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
ui_but_anim_flag(but, &anim_eval_context);
ui_but_override_flag(CTX_data_main(C), but);
if (UI_but_is_decorator(but)) {
- ui_but_anim_decorate_update_from_flag(but);
+ ui_but_anim_decorate_update_from_flag((uiButDecorator *)but);
}
ui_but_predefined_extra_operator_icons_add(but);
}
@@ -2015,6 +2026,7 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
case UI_BTYPE_HOTKEY_EVENT:
case UI_BTYPE_KEY_EVENT:
case UI_BTYPE_COLOR:
+ case UI_BTYPE_DECORATOR:
is_push = -1;
break;
case UI_BTYPE_BUT_TOGGLE:
@@ -2317,7 +2329,8 @@ bool ui_but_supports_cycling(const uiBut *but)
{
return ((ELEM(but->type, UI_BTYPE_ROW, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, UI_BTYPE_LISTBOX)) ||
(but->type == UI_BTYPE_MENU && ui_but_menu_step_poll(but)) ||
- (but->type == UI_BTYPE_COLOR && but->a1 != -1) || (but->menu_step_func != NULL));
+ (but->type == UI_BTYPE_COLOR && ((uiButColor *)but)->is_pallete_color) ||
+ (but->menu_step_func != NULL));
}
double ui_but_value_get(uiBut *but)
@@ -2939,10 +2952,10 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, PointerRNA_NULL, NULL);
return true;
}
+
+ uiButSearch *search_but = (but->type == UI_BTYPE_SEARCH_MENU) ? (uiButSearch *)but : NULL;
/* RNA pointer */
PointerRNA rptr;
- PointerRNA ptr = but->rnasearchpoin;
- PropertyRNA *prop = but->rnasearchprop;
/* This is kind of hackish, in theory think we could only ever use the second member of
* this if/else, since ui_searchbox_apply() is supposed to always set that pointer when
@@ -2950,12 +2963,16 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
* to try to break as little as possible existing code. All this is band-aids anyway.
* Fact remains, using editstr as main 'reference' over whole search button thingy
* is utterly weak and should be redesigned imho, but that's not a simple task. */
- if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) {
+ if (search_but && search_but->rnasearchprop &&
+ RNA_property_collection_lookup_string(
+ &search_but->rnasearchpoin, search_but->rnasearchprop, str, &rptr)) {
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, NULL);
}
- else if (but->func_arg2 != NULL) {
- RNA_pointer_create(
- NULL, RNA_property_pointer_type(&but->rnapoin, but->rnaprop), but->func_arg2, &rptr);
+ else if (search_but->item_active != NULL) {
+ RNA_pointer_create(NULL,
+ RNA_property_pointer_type(&but->rnapoin, but->rnaprop),
+ search_but->item_active,
+ &rptr);
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, NULL);
}
@@ -3092,8 +3109,38 @@ static double soft_range_round_down(double value, double max)
return newmax;
}
+void ui_but_range_set_hard(uiBut *but)
+{
+ if (but->rnaprop) {
+ const PropertyType type = RNA_property_type(but->rnaprop);
+ double hardmin, hardmax;
+
+ /* clamp button range to something reasonable in case
+ * we get -inf/inf from RNA properties */
+ if (type == PROP_INT) {
+ int imin, imax;
+
+ RNA_property_int_range(&but->rnapoin, but->rnaprop, &imin, &imax);
+ hardmin = (imin == INT_MIN) ? -1e4 : imin;
+ hardmax = (imin == INT_MAX) ? 1e4 : imax;
+ }
+ else if (type == PROP_FLOAT) {
+ float fmin, fmax;
+
+ RNA_property_float_range(&but->rnapoin, but->rnaprop, &fmin, &fmax);
+ hardmin = (fmin == -FLT_MAX) ? (float)-1e4 : fmin;
+ hardmax = (fmax == FLT_MAX) ? (float)1e4 : fmax;
+ }
+ else {
+ return;
+ }
+ but->hardmin = hardmin;
+ but->hardmax = hardmax;
+ }
+}
+
/* note: this could be split up into functions which handle arrays and not */
-static void ui_set_but_soft_range(uiBut *but)
+void ui_but_range_set_soft(uiBut *but)
{
/* ideally we would not limit this but practically, its more than
* enough worst case is very long vectors wont use a smart soft-range
@@ -3195,6 +3242,28 @@ static void ui_set_but_soft_range(uiBut *but)
/* ******************* Free ********************/
+/**
+ * Free data specific to a certain button type.
+ * For now just do in a switch-case, we could instead have a callback stored in #uiBut and set that
+ * in #ui_but_alloc_info().
+ */
+static void ui_but_free_type_specific(uiBut *but)
+{
+ switch (but->type) {
+ case UI_BTYPE_SEARCH_MENU: {
+ uiButSearch *search_but = (uiButSearch *)but;
+
+ if (search_but->arg_free_fn) {
+ search_but->arg_free_fn(search_but->arg);
+ search_but->arg = NULL;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+}
+
/* can be called with C==NULL */
static void ui_but_free(const bContext *C, uiBut *but)
{
@@ -3215,13 +3284,7 @@ static void ui_but_free(const bContext *C, uiBut *but)
MEM_freeN(but->hold_argN);
}
- if (but->search != NULL) {
- if (but->search->arg_free_fn) {
- but->search->arg_free_fn(but->search->arg);
- but->search->arg = NULL;
- }
- MEM_freeN(but->search);
- }
+ ui_but_free_type_specific(but);
if (but->active) {
/* XXX solve later, buttons should be free-able without context ideally,
@@ -3354,7 +3417,7 @@ void UI_block_region_set(uiBlock *block, ARegion *region)
block->oldblock = oldblock;
}
-uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, short dt)
+uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, char emboss)
{
uiBlock *block;
wmWindow *window;
@@ -3366,7 +3429,7 @@ uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, sh
block = MEM_callocN(sizeof(uiBlock), "uiBlock");
block->active = 1;
- block->dt = dt;
+ block->emboss = emboss;
block->evil_C = (void *)C; /* XXX */
/* Set the search filter for the properties editor. */
@@ -3412,12 +3475,12 @@ uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, sh
char UI_block_emboss_get(uiBlock *block)
{
- return block->dt;
+ return block->emboss;
}
-void UI_block_emboss_set(uiBlock *block, char dt)
+void UI_block_emboss_set(uiBlock *block, char emboss)
{
- block->dt = dt;
+ block->emboss = emboss;
}
void UI_block_theme_style_set(uiBlock *block, char theme_style)
@@ -3520,7 +3583,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
/* only update soft range while not editing */
if (!ui_but_is_editing(but)) {
if ((but->rnaprop != NULL) || (but->poin && (but->pointype & UI_BUT_POIN_TYPES))) {
- ui_set_but_soft_range(but);
+ ui_but_range_set_soft(but);
}
}
@@ -3723,14 +3786,111 @@ void ui_block_cm_to_display_space_v3(uiBlock *block, float pixel[3])
IMB_colormanagement_scene_linear_to_display_v3(pixel, display);
}
-static uiBut *ui_but_alloc(const eButType type)
+static void ui_but_alloc_info(const eButType type,
+ size_t *r_alloc_size,
+ const char **r_alloc_str,
+ bool *r_has_custom_type)
{
+ size_t alloc_size;
+ const char *alloc_str;
+ bool has_custom_type = true;
+
switch (type) {
+ case UI_BTYPE_COLOR:
+ alloc_size = sizeof(uiButColor);
+ alloc_str = "uiButColor";
+ break;
+ case UI_BTYPE_DECORATOR:
+ alloc_size = sizeof(uiButDecorator);
+ alloc_str = "uiButDecorator";
+ break;
case UI_BTYPE_TAB:
- return MEM_callocN(sizeof(uiButTab), "uiButTab");
+ alloc_size = sizeof(uiButTab);
+ alloc_str = "uiButTab";
+ break;
+ case UI_BTYPE_SEARCH_MENU:
+ alloc_size = sizeof(uiButSearch);
+ alloc_str = "uiButSearch";
+ break;
+ case UI_BTYPE_PROGRESS_BAR:
+ alloc_size = sizeof(uiButProgressbar);
+ alloc_str = "uiButProgressbar";
+ break;
+ case UI_BTYPE_HSVCUBE:
+ alloc_size = sizeof(uiButHSVCube);
+ alloc_str = "uiButHSVCube";
+ break;
default:
- return MEM_callocN(sizeof(uiBut), "uiBut");
+ alloc_size = sizeof(uiBut);
+ alloc_str = "uiBut";
+ has_custom_type = false;
+ break;
}
+
+ if (r_alloc_size) {
+ *r_alloc_size = alloc_size;
+ }
+ if (r_alloc_str) {
+ *r_alloc_str = alloc_str;
+ }
+ if (r_has_custom_type) {
+ *r_has_custom_type = has_custom_type;
+ }
+}
+
+static uiBut *ui_but_alloc(const eButType type)
+{
+ size_t alloc_size;
+ const char *alloc_str;
+
+ ui_but_alloc_info(type, &alloc_size, &alloc_str, NULL);
+
+ return MEM_callocN(alloc_size, alloc_str);
+}
+
+/**
+ * Reallocate the button (new address is returned) for a new button type.
+ * This should generally be avoided and instead the correct type be created right away.
+ *
+ * \note Only the #uiBut data can be kept. If the old button used a derived type (e.g. #uiButTab),
+ * the data that is not inside #uiBut will be lost.
+ */
+uiBut *ui_but_change_type(uiBut *but, eButType new_type)
+{
+ if (but->type != new_type) {
+ size_t alloc_size;
+ const char *alloc_str;
+ uiBut *insert_after_but = but->prev;
+ bool new_has_custom_type, old_has_custom_type;
+
+ /* Remove old button address */
+ BLI_remlink(&but->block->buttons, but);
+
+ ui_but_alloc_info(but->type, NULL, NULL, &old_has_custom_type);
+ ui_but_alloc_info(new_type, &alloc_size, &alloc_str, &new_has_custom_type);
+
+ if (new_has_custom_type || old_has_custom_type) {
+ const void *old_but_ptr = but;
+ /* Button may have pointer to a member within itself, this will have to be updated. */
+ const bool has_str_ptr_to_self = but->str == but->strdata;
+
+ but = MEM_recallocN_id(but, alloc_size, alloc_str);
+ but->type = new_type;
+ if (has_str_ptr_to_self) {
+ but->str = but->strdata;
+ }
+
+ BLI_insertlinkafter(&but->block->buttons, insert_after_but, but);
+
+ if (but->layout) {
+ const bool found_layout = ui_layout_replace_but_ptr(but->layout, old_but_ptr, but);
+ BLI_assert(found_layout);
+ UNUSED_VARS_NDEBUG(found_layout);
+ }
+ }
+ }
+
+ return but;
}
/**
@@ -3812,7 +3972,7 @@ static uiBut *ui_def_but(uiBlock *block,
but->tip = tip;
but->disabled_info = block->lockstr;
- but->dt = block->dt;
+ but->emboss = block->emboss;
but->pie_dir = UI_RADIAL_NONE;
but->block = block; /* pointer back, used for frontbuffer status, and picker */
@@ -3878,6 +4038,7 @@ static uiBut *ui_def_but(uiBlock *block,
if (ELEM(but->type,
UI_BTYPE_BLOCK,
UI_BTYPE_BUT,
+ UI_BTYPE_DECORATOR,
UI_BTYPE_LABEL,
UI_BTYPE_PULLDOWN,
UI_BTYPE_ROUNDBOX,
@@ -4345,7 +4506,7 @@ static uiBut *ui_def_but_rna(uiBlock *block,
}
if (type == UI_BTYPE_MENU) {
- if (but->dt == UI_EMBOSS_PULLDOWN) {
+ if (but->emboss == UI_EMBOSS_PULLDOWN) {
ui_but_submenu_enable(block, but);
}
}
@@ -6372,54 +6533,55 @@ void UI_but_func_search_set(uiBut *but,
uiButHandleFunc search_exec_fn,
void *active)
{
+ uiButSearch *search_but = (uiButSearch *)but;
+
+ BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+
/* needed since callers don't have access to internal functions
* (as an alternative we could expose it) */
if (search_create_fn == NULL) {
search_create_fn = ui_searchbox_create_generic;
}
- struct uiButSearchData *search = but->search;
- if (search != NULL) {
- if (search->arg_free_fn != NULL) {
- search->arg_free_fn(but->search->arg);
- search->arg = NULL;
- }
- }
- else {
- search = MEM_callocN(sizeof(*but->search), __func__);
- but->search = search;
+ if (search_but->arg_free_fn != NULL) {
+ search_but->arg_free_fn(search_but->arg);
+ search_but->arg = NULL;
}
- search->create_fn = search_create_fn;
- search->update_fn = search_update_fn;
+ search_but->popup_create_fn = search_create_fn;
+ search_but->items_update_fn = search_update_fn;
+ search_but->item_active = active;
- search->arg = arg;
- search->arg_free_fn = search_arg_free_fn;
+ search_but->arg = arg;
+ search_but->arg_free_fn = search_arg_free_fn;
if (search_exec_fn) {
#ifdef DEBUG
- if (but->func) {
+ if (search_but->but.func) {
/* watch this, can be cause of much confusion, see: T47691 */
printf("%s: warning, overwriting button callback with search function callback!\n",
__func__);
}
#endif
- UI_but_func_set(but, search_exec_fn, search->arg, active);
+ /* Handling will pass the active item as arg2 later, so keep it NULL here. */
+ UI_but_func_set(but, search_exec_fn, search_but->arg, NULL);
}
/* search buttons show red-alert if item doesn't exist, not for menus */
if (0 == (but->block->flag & UI_BLOCK_LOOP)) {
/* skip empty buttons, not all buttons need input, we only show invalid */
if (but->drawstr[0]) {
- ui_but_search_refresh(but);
+ ui_but_search_refresh(search_but);
}
}
}
void UI_but_func_search_set_context_menu(uiBut *but, uiButSearchContextMenuFn context_menu_fn)
{
- struct uiButSearchData *search = but->search;
- search->context_menu_fn = context_menu_fn;
+ uiButSearch *but_search = (uiButSearch *)but;
+ BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+
+ but_search->item_context_menu_fn = context_menu_fn;
}
/**
@@ -6428,14 +6590,18 @@ void UI_but_func_search_set_context_menu(uiBut *but, uiButSearchContextMenuFn co
*/
void UI_but_func_search_set_sep_string(uiBut *but, const char *search_sep_string)
{
- struct uiButSearchData *search = but->search;
- search->sep_string = search_sep_string;
+ uiButSearch *but_search = (uiButSearch *)but;
+ BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+
+ but_search->item_sep_string = search_sep_string;
}
void UI_but_func_search_set_tooltip(uiBut *but, uiButSearchTooltipFn tooltip_fn)
{
- struct uiButSearchData *search = but->search;
- search->tooltip_fn = tooltip_fn;
+ uiButSearch *but_search = (uiButSearch *)but;
+ BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+
+ but_search->item_tooltip_fn = tooltip_fn;
}
/* Callbacks for operator search button. */
diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c
index 8edae5d8740..4981ef111e0 100644
--- a/source/blender/editors/interface/interface_align.c
+++ b/source/blender/editors/interface/interface_align.c
@@ -371,7 +371,7 @@ static void ui_block_align_but_to_region(uiBut *but, const ARegion *region)
rect->xmin = rect->xmax - but_width;
break;
default:
- BLI_assert(0);
+ /* Tabs may be shown in unaligned regions too, they just appear as regular buttons then. */
break;
}
}
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 8d12a1dd1ad..cc58082cb02 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -120,35 +120,41 @@ void ui_but_anim_flag(uiBut *but, const AnimationEvalContext *anim_eval_context)
}
}
-static uiBut *ui_but_anim_decorate_find_attached_button(uiBut *but_decorate)
+static uiBut *ui_but_anim_decorate_find_attached_button(uiButDecorator *but_decorate)
{
uiBut *but_iter = NULL;
- BLI_assert(UI_but_is_decorator(but_decorate));
- BLI_assert(but_decorate->rnasearchpoin.data && but_decorate->rnasearchprop);
+ BLI_assert(UI_but_is_decorator(&but_decorate->but));
+ BLI_assert(but_decorate->rnapoin.data && but_decorate->rnaprop);
- LISTBASE_CIRCULAR_BACKWARD_BEGIN (&but_decorate->block->buttons, but_iter, but_decorate->prev) {
- if (but_iter != but_decorate &&
- ui_but_rna_equals_ex(but_iter,
- &but_decorate->rnasearchpoin,
- but_decorate->rnasearchprop,
- POINTER_AS_INT(but_decorate->custom_data))) {
+ LISTBASE_CIRCULAR_BACKWARD_BEGIN (
+ &but_decorate->but.block->buttons, but_iter, but_decorate->but.prev) {
+ if (but_iter != (uiBut *)but_decorate &&
+ ui_but_rna_equals_ex(
+ but_iter, &but_decorate->rnapoin, but_decorate->rnaprop, but_decorate->rnaindex)) {
return but_iter;
}
}
- LISTBASE_CIRCULAR_BACKWARD_END(&but_decorate->block->buttons, but_iter, but_decorate->prev);
+ LISTBASE_CIRCULAR_BACKWARD_END(
+ &but_decorate->but.block->buttons, but_iter, but_decorate->but.prev);
return NULL;
}
-void ui_but_anim_decorate_update_from_flag(uiBut *but)
+void ui_but_anim_decorate_update_from_flag(uiButDecorator *decorator_but)
{
- const uiBut *but_anim = ui_but_anim_decorate_find_attached_button(but);
+ if (!decorator_but->rnapoin.data || !decorator_but->rnaprop) {
+ /* Nothing to do. */
+ return;
+ }
+
+ const uiBut *but_anim = ui_but_anim_decorate_find_attached_button(decorator_but);
+ uiBut *but = &decorator_but->but;
if (!but_anim) {
printf("Could not find button with matching property to decorate (%s.%s)\n",
- RNA_struct_identifier(but->rnasearchpoin.type),
- RNA_property_identifier(but->rnasearchprop));
+ RNA_struct_identifier(decorator_but->rnapoin.type),
+ RNA_property_identifier(decorator_but->rnaprop));
return;
}
@@ -325,7 +331,7 @@ void ui_but_anim_paste_driver(bContext *C)
void ui_but_anim_decorate_cb(bContext *C, void *arg_but, void *UNUSED(arg_dummy))
{
wmWindowManager *wm = CTX_wm_manager(C);
- uiBut *but_decorate = arg_but;
+ uiButDecorator *but_decorate = arg_but;
uiBut *but_anim = ui_but_anim_decorate_find_attached_button(but_decorate);
if (!but_anim) {
@@ -333,7 +339,7 @@ void ui_but_anim_decorate_cb(bContext *C, void *arg_but, void *UNUSED(arg_dummy)
}
/* FIXME(campbell), swapping active pointer is weak. */
- SWAP(struct uiHandleButtonData *, but_anim->active, but_decorate->active);
+ SWAP(struct uiHandleButtonData *, but_anim->active, but_decorate->but.active);
wm->op_undo_depth++;
if (but_anim->flag & UI_BUT_DRIVEN) {
@@ -357,6 +363,6 @@ void ui_but_anim_decorate_cb(bContext *C, void *arg_but, void *UNUSED(arg_dummy)
WM_operator_properties_free(&props_ptr);
}
- SWAP(struct uiHandleButtonData *, but_anim->active, but_decorate->active);
+ SWAP(struct uiHandleButtonData *, but_anim->active, but_decorate->but.active);
wm->op_undo_depth--;
}
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index aaa5e1c0cf1..46876fca9a5 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -962,7 +962,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
const PropertyType prop_type = RNA_property_type(but->rnaprop);
if (((prop_type == PROP_POINTER) ||
(prop_type == PROP_STRING && but->type == UI_BTYPE_SEARCH_MENU &&
- but->search->update_fn == ui_rna_collection_search_update_fn)) &&
+ ((uiButSearch *)but)->items_update_fn == ui_rna_collection_search_update_fn)) &&
ui_jump_to_target_button_poll(C)) {
uiItemO(layout,
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Jump to Target"),
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 947b6e7ee9d..05f6e61ff40 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -840,7 +840,7 @@ static void draw_scope_end(const rctf *rect, GLint *scissor)
/* outline */
UI_draw_roundbox_corner_set(UI_CNR_ALL);
- float color[4] = {0.0f, 0.0f, 0.0f, 0.5f};
+ const float color[4] = {0.0f, 0.0f, 0.0f, 0.5f};
UI_draw_roundbox_4fv(
false, rect->xmin - 1, rect->ymin, rect->xmax + 1, rect->ymax + 1, 3.0f, color);
}
@@ -858,7 +858,7 @@ static void histogram_draw_one(float r,
const bool is_line,
uint pos_attr)
{
- float color[4] = {r, g, b, alpha};
+ const float color[4] = {r, g, b, alpha};
/* that can happen */
if (res == 0) {
@@ -1032,7 +1032,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
Scopes *scopes = (Scopes *)but->poin;
int scissor[4];
float colors[3][3];
- float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}};
+ const float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}};
/* colors pre multiplied by alpha for speed up */
float colors_alpha[3][3], colorsycc_alpha[3][3];
float min, max;
@@ -1172,7 +1172,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
/* LUMA (1 channel) */
if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
- float col[3] = {alpha, alpha, alpha};
+ const float col[3] = {alpha, alpha, alpha};
GPU_matrix_push();
GPU_matrix_translate_2f(rect.xmin, yofs);
@@ -1465,7 +1465,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
if (scopes->ok && scopes->vecscope != NULL) {
/* pixel point cloud */
- float col[3] = {alpha, alpha, alpha};
+ const float col[3] = {alpha, alpha, alpha};
GPU_blend_set_func(GPU_ONE, GPU_ONE);
GPU_point_size(1.0);
@@ -1773,7 +1773,7 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rect)
{
/* sphere color */
- float diffuse[3] = {1.0f, 1.0f, 1.0f};
+ const float diffuse[3] = {1.0f, 1.0f, 1.0f};
float light[3];
const float size = 0.5f * min_ff(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
@@ -1937,7 +1937,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
/* Do this first to not mess imm context */
if (but->a1 == UI_GRAD_H) {
/* magic trigger for curve backgrounds */
- float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */
+ const float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */
rcti grid = {
.xmin = rect->xmin + zoomx * (-offsx),
@@ -2256,12 +2256,12 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
/* Also add the last points on the right and bottom edges to close off the fill polygon. */
bool add_left_tri = profile->view_rect.xmin < 0.0f;
bool add_bottom_tri = profile->view_rect.ymin < 0.0f;
- uint tot_points = (uint)PROF_N_TABLE(profile->path_len) + 1 + add_left_tri + add_bottom_tri;
+ uint tot_points = (uint)PROF_TABLE_LEN(profile->path_len) + 1 + add_left_tri + add_bottom_tri;
uint tot_triangles = tot_points - 2;
/* Create array of the positions of the table's points. */
float(*table_coords)[2] = MEM_mallocN(sizeof(*table_coords) * tot_points, "table x coords");
- for (i = 0; i < (uint)PROF_N_TABLE(profile->path_len);
+ for (i = 0; i < (uint)PROF_TABLE_LEN(profile->path_len);
i++) { /* Only add the points from the table here. */
table_coords[i][0] = pts[i].x;
table_coords[i][1] = pts[i].y;
@@ -2483,7 +2483,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
(rect.ymax + 1) - (rect.ymin - 1));
if (scopes->track_disabled) {
- float color[4] = {0.7f, 0.3f, 0.3f, 0.3f};
+ const float color[4] = {0.7f, 0.3f, 0.3f, 0.3f};
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_4fv(
true, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
@@ -2532,7 +2532,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
float col_sel[4], col_outline[4];
if (scopes->use_track_mask) {
- float color[4] = {0.0f, 0.0f, 0.0f, 0.3f};
+ const float color[4] = {0.0f, 0.0f, 0.0f, 0.3f};
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_4fv(
true, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
@@ -2565,7 +2565,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
/* Do stipple cross with geometry */
immBegin(GPU_PRIM_LINES, 7 * 2 * 2);
- float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f};
+ const float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f};
for (int axe = 0; axe < 2; axe++) {
for (int i = 0; i < 7; i++) {
float x1 = pos_sel[i] * (1 - axe);
@@ -2595,7 +2595,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
}
if (!ok) {
- float color[4] = {0.0f, 0.0f, 0.0f, 0.3f};
+ const float color[4] = {0.0f, 0.0f, 0.0f, 0.3f};
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_4fv(
true, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
@@ -2773,7 +2773,7 @@ void ui_draw_dropshadow(
GPU_batch_draw(batch);
/* outline emphasis */
- float color[4] = {0.0f, 0.0f, 0.0f, 0.4f};
+ const float color[4] = {0.0f, 0.0f, 0.0f, 0.4f};
UI_draw_roundbox_4fv(false,
rct->xmin - 0.5f,
rct->ymin - 0.5f,
diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c
index 5da82b5be9c..c86e35f91db 100644
--- a/source/blender/editors/interface/interface_eyedropper_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_color.c
@@ -172,7 +172,7 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3])
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my);
if (region) {
SpaceNode *snode = area->spacedata.first;
- int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
+ const int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
if (ED_space_node_color_sample(bmain, snode, region, mval, r_col)) {
return;
@@ -194,7 +194,7 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3])
if (win) {
/* Fallback to simple opengl picker. */
- int mval[2] = {mx, my};
+ const int mval[2] = {mx, my};
WM_window_pixel_sample_read(wm, win, mval, r_col);
IMB_colormanagement_display_to_scene_linear_v3(r_col, display);
}
diff --git a/source/blender/editors/interface/interface_eyedropper_colorband.c b/source/blender/editors/interface/interface_eyedropper_colorband.c
index 7b8357f5ef1..b757341ae13 100644
--- a/source/blender/editors/interface/interface_eyedropper_colorband.c
+++ b/source/blender/editors/interface/interface_eyedropper_colorband.c
@@ -179,8 +179,8 @@ static void eyedropper_colorband_sample_segment(bContext *C,
/* Since the mouse tends to move rather rapidly we use #BLI_bitmap_draw_2d_line_v2v2i
* to interpolate between the reported coordinates */
struct EyedropperColorband_Context userdata = {C, eye};
- int p1[2] = {eye->last_x, eye->last_y};
- int p2[2] = {mx, my};
+ const int p1[2] = {eye->last_x, eye->last_y};
+ const int p2[2] = {mx, my};
BLI_bitmap_draw_2d_line_v2v2i(p1, p2, eyedropper_colorband_sample_callback, &userdata);
}
diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
index 978d8ac09de..aa5b4d2c255 100644
--- a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
@@ -106,8 +106,11 @@ static void eyedropper_gpencil_exit(bContext *C, wmOperator *op)
MEM_SAFE_FREE(op->customdata);
}
-static void eyedropper_add_material(
- bContext *C, float col_conv[4], const bool only_stroke, const bool only_fill, const bool both)
+static void eyedropper_add_material(bContext *C,
+ const float col_conv[4],
+ const bool only_stroke,
+ const bool only_fill,
+ const bool both)
{
Main *bmain = CTX_data_main(C);
Object *ob = CTX_data_active_object(C);
@@ -193,7 +196,7 @@ static void eyedropper_add_material(
}
/* Create a new palette color and palette if needed. */
-static void eyedropper_add_palette_color(bContext *C, float col_conv[4])
+static void eyedropper_add_palette_color(bContext *C, const float col_conv[4])
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
diff --git a/source/blender/editors/interface/interface_eyedropper_intern.h b/source/blender/editors/interface/interface_eyedropper_intern.h
index cabf997b725..fd60dcb7c86 100644
--- a/source/blender/editors/interface/interface_eyedropper_intern.h
+++ b/source/blender/editors/interface/interface_eyedropper_intern.h
@@ -20,8 +20,7 @@
* Share between interface_eyedropper_*.c files.
*/
-#ifndef __INTERFACE_EYEDROPPER_INTERN_H__
-#define __INTERFACE_EYEDROPPER_INTERN_H__
+#pragma once
/* interface_eyedropper.c */
void eyedropper_draw_cursor_text(const struct bContext *C,
@@ -48,5 +47,3 @@ enum {
EYE_MODAL_POINT_RESET,
EYE_MODAL_POINT_REMOVE_LAST,
};
-
-#endif /* __INTERFACE_EYEDROPPER_INTERN_H__ */
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 1128cceb6e3..2d3a6181f09 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -767,11 +767,12 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
after->rnapoin = but->rnapoin;
after->rnaprop = but->rnaprop;
- if (but->search != NULL) {
- after->search_arg_free_fn = but->search->arg_free_fn;
- after->search_arg = but->search->arg;
- but->search->arg_free_fn = NULL;
- but->search->arg = NULL;
+ if (but->type == UI_BTYPE_SEARCH_MENU) {
+ uiButSearch *search_but = (uiButSearch *)but;
+ after->search_arg_free_fn = search_but->arg_free_fn;
+ after->search_arg = search_but->arg;
+ search_but->arg_free_fn = NULL;
+ search_but->arg = NULL;
}
if (but->context) {
@@ -1047,8 +1048,19 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
but->rename_orig = data->origstr;
data->origstr = NULL;
}
+
+ void *orig_arg2 = but->func_arg2;
+
+ /* If arg2 isn't in use already, pass the active search item through it. */
+ if ((but->func_arg2 == NULL) && (but->type == UI_BTYPE_SEARCH_MENU)) {
+ uiButSearch *search_but = (uiButSearch *)but;
+ but->func_arg2 = search_but->item_active;
+ }
+
ui_apply_but_func(C, but);
+ but->func_arg2 = orig_arg2;
+
data->retval = but->retval;
data->applied = true;
}
@@ -1382,6 +1394,9 @@ static void ui_multibut_states_apply(bContext *C, uiHandleButtonData *data, uiBl
static bool ui_drag_toggle_but_is_supported(const uiBut *but)
{
+ if (but->flag & UI_BUT_DISABLED) {
+ return false;
+ }
if (ui_but_is_bool(but)) {
return true;
}
@@ -2084,6 +2099,7 @@ static void ui_apply_but(
/* handle different types */
switch (but->type) {
case UI_BTYPE_BUT:
+ case UI_BTYPE_DECORATOR:
ui_apply_but_BUT(C, but, data);
break;
case UI_BTYPE_TEXT:
@@ -3020,7 +3036,7 @@ static bool ui_textedit_insert_buf(uiBut *but,
static bool ui_textedit_insert_ascii(uiBut *but, uiHandleButtonData *data, char ascii)
{
- char buf[2] = {ascii, '\0'};
+ const char buf[2] = {ascii, '\0'};
if (UI_but_is_utf8(but) && (BLI_str_utf8_size(buf) == -1)) {
printf(
@@ -3318,7 +3334,9 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
/* optional searchbox */
if (but->type == UI_BTYPE_SEARCH_MENU) {
- data->searchbox = but->search->create_fn(C, data->region, but);
+ uiButSearch *search_but = (uiButSearch *)but;
+
+ data->searchbox = search_but->popup_create_fn(C, data->region, search_but);
ui_searchbox_update(C, data->searchbox, but, true); /* true = reset */
}
@@ -4387,7 +4405,7 @@ static int ui_do_but_TEX(
if (ELEM(event->type, EVT_PADENTER, EVT_RETKEY) && (!UI_but_is_utf8(but))) {
/* pass - allow filesel, enter to execute */
}
- else if (but->dt == UI_EMBOSS_NONE && !event->ctrl) {
+ else if (but->emboss == UI_EMBOSS_NONE && !event->ctrl) {
/* pass */
}
else {
@@ -5695,21 +5713,24 @@ static bool ui_numedit_but_UNITVEC(
return changed;
}
-static void ui_palette_set_active(uiBut *but)
+static void ui_palette_set_active(uiButColor *color_but)
{
- if ((int)(but->a1) == UI_PALETTE_COLOR) {
- Palette *palette = (Palette *)but->rnapoin.owner_id;
- PaletteColor *color = but->rnapoin.data;
+ if (color_but->is_pallete_color) {
+ Palette *palette = (Palette *)color_but->but.rnapoin.owner_id;
+ PaletteColor *color = color_but->but.rnapoin.data;
palette->active_color = BLI_findindex(&palette->colors, color);
}
}
static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
+ BLI_assert(but->type == UI_BTYPE_COLOR);
+ uiButColor *color_but = (uiButColor *)but;
+
if (data->state == BUTTON_STATE_HIGHLIGHT) {
/* first handle click on icondrag type button */
if (event->type == LEFTMOUSE && but->dragpoin && event->val == KM_PRESS) {
- ui_palette_set_active(but);
+ ui_palette_set_active(color_but);
if (ui_but_contains_point_px_icon(but, data->region, event)) {
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
@@ -5719,7 +5740,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
}
#ifdef USE_DRAG_TOGGLE
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
- ui_palette_set_active(but);
+ ui_palette_set_active(color_but);
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
data->dragstarty = event->y;
@@ -5728,7 +5749,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
#endif
/* regular open menu */
if (ELEM(event->type, LEFTMOUSE, EVT_PADENTER, EVT_RETKEY) && event->val == KM_PRESS) {
- ui_palette_set_active(but);
+ ui_palette_set_active(color_but);
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
return WM_UI_HANDLER_BREAK;
}
@@ -5759,8 +5780,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
ui_apply_but(C, but->block, but, data, true);
return WM_UI_HANDLER_BREAK;
}
- if ((int)(but->a1) == UI_PALETTE_COLOR && event->type == EVT_DELKEY &&
- event->val == KM_PRESS) {
+ if (color_but->is_pallete_color && (event->type == EVT_DELKEY) && (event->val == KM_PRESS)) {
Palette *palette = (Palette *)but->rnapoin.owner_id;
PaletteColor *color = but->rnapoin.data;
@@ -5791,7 +5811,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
}
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
- if ((int)(but->a1) == UI_PALETTE_COLOR) {
+ if (color_but->is_pallete_color) {
if (!event->ctrl) {
float color[3];
Paint *paint = BKE_paint_get_active_from_context(C);
@@ -5921,9 +5941,11 @@ static void clamp_axis_max_v3(float v[3], const float max)
}
}
-static void ui_rgb_to_color_picker_HSVCUBE_compat_v(uiBut *but, const float rgb[3], float hsv[3])
+static void ui_rgb_to_color_picker_HSVCUBE_compat_v(const uiButHSVCube *hsv_but,
+ const float rgb[3],
+ float hsv[3])
{
- if (but->a1 == UI_GRAD_L_ALT) {
+ if (hsv_but->gradient_type == UI_GRAD_L_ALT) {
rgb_to_hsl_compat_v(rgb, hsv);
}
else {
@@ -5931,9 +5953,11 @@ static void ui_rgb_to_color_picker_HSVCUBE_compat_v(uiBut *but, const float rgb[
}
}
-static void ui_rgb_to_color_picker_HSVCUBE_v(uiBut *but, const float rgb[3], float hsv[3])
+static void ui_rgb_to_color_picker_HSVCUBE_v(const uiButHSVCube *hsv_but,
+ const float rgb[3],
+ float hsv[3])
{
- if (but->a1 == UI_GRAD_L_ALT) {
+ if (hsv_but->gradient_type == UI_GRAD_L_ALT) {
rgb_to_hsl_v(rgb, hsv);
}
else {
@@ -5941,9 +5965,11 @@ static void ui_rgb_to_color_picker_HSVCUBE_v(uiBut *but, const float rgb[3], flo
}
}
-static void ui_color_picker_to_rgb_HSVCUBE_v(uiBut *but, const float hsv[3], float rgb[3])
+static void ui_color_picker_to_rgb_HSVCUBE_v(const uiButHSVCube *hsv_but,
+ const float hsv[3],
+ float rgb[3])
{
- if (but->a1 == UI_GRAD_L_ALT) {
+ if (hsv_but->gradient_type == UI_GRAD_L_ALT) {
hsl_to_rgb_v(hsv, rgb);
}
else {
@@ -5958,6 +5984,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but,
const enum eSnapType snap,
const bool shift)
{
+ const uiButHSVCube *hsv_but = (uiButHSVCube *)but;
ColorPicker *cpicker = but->custom_data;
float *hsv = cpicker->color_data;
float rgb[3];
@@ -5979,7 +6006,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but,
ui_but_v3_get(but, rgb);
ui_scene_linear_to_color_picker_space(but, rgb);
- ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv);
+ ui_rgb_to_color_picker_HSVCUBE_compat_v(hsv_but, rgb, hsv);
/* only apply the delta motion, not absolute */
if (shift) {
@@ -5994,10 +6021,10 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but,
copy_v3_v3(hsvo, hsv);
- ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsvo);
+ ui_rgb_to_color_picker_HSVCUBE_compat_v(hsv_but, rgb, hsvo);
/* and original position */
- ui_hsvcube_pos_from_vals(but, &rect_i, hsvo, &xpos, &ypos);
+ ui_hsvcube_pos_from_vals(hsv_but, &rect_i, hsvo, &xpos, &ypos);
mx_fl = xpos - (data->dragstartx - mx_fl);
my_fl = ypos - (data->dragstarty - my_fl);
@@ -6009,7 +6036,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but,
CLAMP(x, 0.0f, 1.0f);
CLAMP(y, 0.0f, 1.0f);
- switch ((int)but->a1) {
+ switch (hsv_but->gradient_type) {
case UI_GRAD_SV:
hsv[1] = x;
hsv[2] = y;
@@ -6047,16 +6074,16 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but,
}
if (snap != SNAP_OFF) {
- if (ELEM((int)but->a1, UI_GRAD_HV, UI_GRAD_HS, UI_GRAD_H)) {
+ if (ELEM(hsv_but->gradient_type, UI_GRAD_HV, UI_GRAD_HS, UI_GRAD_H)) {
ui_color_snap_hue(snap, &hsv[0]);
}
}
- ui_color_picker_to_rgb_HSVCUBE_v(but, hsv, rgb);
+ ui_color_picker_to_rgb_HSVCUBE_v(hsv_but, hsv, rgb);
ui_color_picker_to_scene_linear_space(but, rgb);
/* clamp because with color conversion we can exceed range [#34295] */
- if (but->a1 == UI_GRAD_V_ALT) {
+ if (hsv_but->gradient_type == UI_GRAD_V_ALT) {
clamp_axis_max_v3(rgb, but->softmax);
}
@@ -6069,23 +6096,23 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but,
}
#ifdef WITH_INPUT_NDOF
-static void ui_ndofedit_but_HSVCUBE(uiBut *but,
+static void ui_ndofedit_but_HSVCUBE(uiButHSVCube *hsv_but,
uiHandleButtonData *data,
const wmNDOFMotionData *ndof,
const enum eSnapType snap,
const bool shift)
{
- ColorPicker *cpicker = but->custom_data;
+ ColorPicker *cpicker = hsv_but->but.custom_data;
float *hsv = cpicker->color_data;
- const float hsv_v_max = max_ff(hsv[2], but->softmax);
+ const float hsv_v_max = max_ff(hsv[2], hsv_but->but.softmax);
float rgb[3];
float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
- ui_but_v3_get(but, rgb);
- ui_scene_linear_to_color_picker_space(but, rgb);
- ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv);
+ ui_but_v3_get(&hsv_but->but, rgb);
+ ui_scene_linear_to_color_picker_space(&hsv_but->but, rgb);
+ ui_rgb_to_color_picker_HSVCUBE_compat_v(hsv_but, rgb, hsv);
- switch ((int)but->a1) {
+ switch (hsv_but->gradient_type) {
case UI_GRAD_SV:
hsv[1] += ndof->rvec[2] * sensitivity;
hsv[2] += ndof->rvec[0] * sensitivity;
@@ -6114,7 +6141,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but,
/* exception only for value strip - use the range set in but->min/max */
hsv[2] += ndof->rvec[0] * sensitivity;
- CLAMP(hsv[2], but->softmin, but->softmax);
+ CLAMP(hsv[2], hsv_but->but.softmin, hsv_but->but.softmax);
break;
default:
assert(!"invalid hsv type");
@@ -6122,7 +6149,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but,
}
if (snap != SNAP_OFF) {
- if (ELEM((int)but->a1, UI_GRAD_HV, UI_GRAD_HS, UI_GRAD_H)) {
+ if (ELEM(hsv_but->gradient_type, UI_GRAD_HV, UI_GRAD_HS, UI_GRAD_H)) {
ui_color_snap_hue(snap, &hsv[0]);
}
}
@@ -6130,17 +6157,18 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but,
/* ndof specific: the changes above aren't clamping */
hsv_clamp_v(hsv, hsv_v_max);
- ui_color_picker_to_rgb_HSVCUBE_v(but, hsv, rgb);
- ui_color_picker_to_scene_linear_space(but, rgb);
+ ui_color_picker_to_rgb_HSVCUBE_v(hsv_but, hsv, rgb);
+ ui_color_picker_to_scene_linear_space(&hsv_but->but, rgb);
copy_v3_v3(data->vec, rgb);
- ui_but_v3_set(but, data->vec);
+ ui_but_v3_set(&hsv_but->but, data->vec);
}
#endif /* WITH_INPUT_NDOF */
static int ui_do_but_HSVCUBE(
bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
+ uiButHSVCube *hsv_but = (uiButHSVCube *)but;
int mx, my;
mx = event->x;
@@ -6169,7 +6197,7 @@ static int ui_do_but_HSVCUBE(
const wmNDOFMotionData *ndof = event->customdata;
const enum eSnapType snap = ui_event_to_snap(event);
- ui_ndofedit_but_HSVCUBE(but, data, ndof, snap, event->shift != 0);
+ ui_ndofedit_but_HSVCUBE(hsv_but, data, ndof, snap, event->shift != 0);
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_but(C, but->block, but, data, true);
@@ -6179,7 +6207,7 @@ static int ui_do_but_HSVCUBE(
#endif /* WITH_INPUT_NDOF */
/* XXX hardcoded keymap check.... */
if (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS) {
- if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) {
+ if (ELEM(hsv_but->gradient_type, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) {
int len;
/* reset only value */
@@ -6192,15 +6220,15 @@ static int ui_do_but_HSVCUBE(
float *hsv = cpicker->color_data;
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
- ui_rgb_to_color_picker_HSVCUBE_v(but, def, def_hsv);
+ ui_rgb_to_color_picker_HSVCUBE_v(hsv_but, def, def_hsv);
ui_but_v3_get(but, rgb);
- ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv);
+ ui_rgb_to_color_picker_HSVCUBE_compat_v(hsv_but, rgb, hsv);
def_hsv[0] = hsv[0];
def_hsv[1] = hsv[1];
- ui_color_picker_to_rgb_HSVCUBE_v(but, def_hsv, rgb);
+ ui_color_picker_to_rgb_HSVCUBE_v(hsv_but, def_hsv, rgb);
ui_but_v3_set(but, rgb);
RNA_property_update(C, &but->rnapoin, but->rnaprop);
@@ -6952,7 +6980,7 @@ static bool ui_numedit_but_CURVEPROFILE(uiBlock *block,
fy *= mval_factor;
/* Move all selected points. */
- float delta[2] = {fx, fy};
+ const float delta[2] = {fx, fy};
for (a = 0; a < profile->path_len; a++) {
/* Don't move the last and first control points. */
if ((pts[a].flag & PROF_SELECT) && (a != 0) && (a != profile->path_len)) {
@@ -7126,7 +7154,7 @@ static int ui_do_but_CURVEPROFILE(
dist_min_sq = square_f(U.dpi_fac * 8.0f); /* 8 pixel radius from each table point. */
/* Loop through the path's high resolution table and find what's near the click. */
- for (int i = 1; i <= PROF_N_TABLE(profile->path_len); i++) {
+ for (int i = 1; i <= PROF_TABLE_LEN(profile->path_len); i++) {
copy_v2_v2(f_xy_prev, f_xy);
BLI_rctf_transform_pt_v(&but->rect, &profile->view_rect, f_xy, &table[i].x);
@@ -7519,6 +7547,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
switch (but->type) {
case UI_BTYPE_BUT:
+ case UI_BTYPE_DECORATOR:
retval = ui_do_but_BUT(C, but, data, event);
break;
case UI_BTYPE_KEY_EVENT:
@@ -7594,13 +7623,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
retval = ui_do_but_BUT(C, but, data, event);
break;
case UI_BTYPE_COLOR:
- if (but->a1 == -1) {
- /* signal to prevent calling up color picker */
- retval = ui_do_but_EXIT(C, but, data, event);
- }
- else {
- retval = ui_do_but_COLOR(C, but, data, event);
- }
+ retval = ui_do_but_COLOR(C, but, data, event);
break;
case UI_BTYPE_UNITVEC:
retval = ui_do_but_UNITVEC(C, block, but, data, event);
@@ -7998,6 +8021,9 @@ static void button_activate_init(bContext *C,
{
uiHandleButtonData *data;
+ /* Only ever one active button! */
+ BLI_assert(ui_region_find_active_but(region) == NULL);
+
/* setup struct */
data = MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData");
data->wm = CTX_wm_manager(C);
@@ -8424,7 +8450,7 @@ void UI_context_update_anim_flag(const bContext *C)
ui_but_anim_flag(but, &anim_eval_context);
ui_but_override_flag(CTX_data_main(C), but);
if (UI_but_is_decorator(but)) {
- ui_but_anim_decorate_update_from_flag(but);
+ ui_but_anim_decorate_update_from_flag((uiButDecorator *)but);
}
ED_region_tag_redraw(region);
@@ -8900,6 +8926,11 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
/* for jumping to the next button with tab while text editing */
if (post_but) {
+ /* The post_but still has previous ranges (without the changes in active button considered),
+ * needs refreshing the ranges. */
+ ui_but_range_set_soft(post_but);
+ ui_but_range_set_hard(post_but);
+
button_activate_init(C, region, post_but, post_type);
}
else if (!((event->type == EVT_BUT_CANCEL) && (event->val == 1))) {
diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c
index fed29571185..4be2dbc0b4e 100644
--- a/source/blender/editors/interface/interface_icons_event.c
+++ b/source/blender/editors/interface/interface_icons_event.c
@@ -143,7 +143,7 @@ void icon_draw_rect_input(float x,
};
if ((event_type >= EVT_AKEY) && (event_type <= EVT_ZKEY)) {
- char str[2] = {'A' + (event_type - EVT_AKEY), '\0'};
+ const char str[2] = {'A' + (event_type - EVT_AKEY), '\0'};
icon_draw_rect_input_text(&rect, color, str, 13);
}
else if ((event_type >= EVT_F1KEY) && (event_type <= EVT_F12KEY)) {
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 582be87a36b..d6ebcef5c0b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -21,8 +21,7 @@
* \ingroup edinterface
*/
-#ifndef __INTERFACE_INTERN_H__
-#define __INTERFACE_INTERN_H__
+#pragma once
#include "BLI_compiler_attrs.h"
#include "BLI_rect.h"
@@ -149,19 +148,11 @@ enum {
/* max amount of items a radial menu (pie menu) can contain */
#define PIE_MAX_ITEMS 8
-struct uiButSearchData {
- uiButSearchCreateFn create_fn;
- uiButSearchUpdateFn update_fn;
- void *arg;
- uiButSearchArgFreeFn arg_free_fn;
- uiButSearchContextMenuFn context_menu_fn;
- uiButSearchTooltipFn tooltip_fn;
-
- const char *sep_string;
-};
-
struct uiBut {
struct uiBut *next, *prev;
+
+ /* Pointer back to the layout item holding this button. */
+ uiLayout *layout;
int flag, drawflag;
eButType type;
eButPointerType pointype;
@@ -182,13 +173,10 @@ struct uiBut {
/**
* For #uiBut.type:
- * - UI_BTYPE_HSVCUBE: Use UI_GRAD_* values.
* - UI_BTYPE_NUM: Use to store RNA 'step' value, for dragging and click-step.
* - UI_BTYPE_LABEL: Use `(a1 == 1.0f)` to use a2 as a blending factor (imaginative!).
* - UI_BTYPE_SCROLL: Use as scroll size.
* - UI_BTYPE_SEARCH_MENU: Use as number or rows.
- * - UI_BTYPE_COLOR: Use as indication of color palette.
- * - UI_BTYPE_PROGRESS_BAR: Use to store progress (0..1).
*/
float a1;
@@ -198,7 +186,6 @@ struct uiBut {
* - UI_BTYPE_NUM: Use to store RNA 'precision' value, for dragging and click-step.
* - UI_BTYPE_LABEL: If `(a1 == 1.0f)` use a2 as a blending factor.
* - UI_BTYPE_SEARCH_MENU: Use as number or columns.
- * - UI_BTYPE_COLOR: Use as index in palette (not so good, needs refactor).
*/
float a2;
@@ -216,8 +203,6 @@ struct uiBut {
uiButCompleteFunc autocomplete_func;
void *autofunc_arg;
- struct uiButSearchData *search;
-
uiButHandleRenameFunc rename_func;
void *rename_arg1;
void *rename_orig;
@@ -234,8 +219,8 @@ struct uiBut {
const char *disabled_info;
BIFIconID icon;
- /** drawtype: UI_EMBOSS, UI_EMBOSS_NONE ... etc, copied from the block */
- char dt;
+ /** emboss: UI_EMBOSS, UI_EMBOSS_NONE ... etc, copied from the #uiBlock.emboss */
+ char emboss;
/** direction in a pie menu, used for collision detection (RadialDirection) */
signed char pie_dir;
/** could be made into a single flag */
@@ -258,9 +243,6 @@ struct uiBut {
struct PropertyRNA *rnaprop;
int rnaindex;
- struct PointerRNA rnasearchpoin;
- struct PropertyRNA *rnasearchprop;
-
/* Operator data */
struct wmOperatorType *optype;
struct PointerRNA *opptr;
@@ -304,11 +286,62 @@ struct uiBut {
uiBlock *block;
};
+/** Derived struct for #UI_BTYPE_COLOR */
+typedef struct uiButColor {
+ uiBut but;
+
+ bool is_pallete_color;
+ int palette_color_index;
+} uiButColor;
+
+/** Derived struct for #UI_BTYPE_TAB */
typedef struct uiButTab {
uiBut but;
struct MenuType *menu;
} uiButTab;
+/** Derived struct for #UI_BTYPE_SEARCH_MENU */
+typedef struct uiButSearch {
+ uiBut but;
+
+ uiButSearchCreateFn popup_create_fn;
+ uiButSearchUpdateFn items_update_fn;
+ void *item_active;
+
+ void *arg;
+ uiButSearchArgFreeFn arg_free_fn;
+
+ uiButSearchContextMenuFn item_context_menu_fn;
+ uiButSearchTooltipFn item_tooltip_fn;
+
+ const char *item_sep_string;
+
+ struct PointerRNA rnasearchpoin;
+ struct PropertyRNA *rnasearchprop;
+} uiButSearch;
+
+/** Derived struct for #UI_BTYPE_DECORATOR */
+typedef struct uiButDecorator {
+ uiBut but;
+
+ struct PointerRNA rnapoin;
+ struct PropertyRNA *rnaprop;
+ int rnaindex;
+} uiButDecorator;
+
+typedef struct uiButProgressbar {
+ uiBut but;
+
+ /* 0..1 range */
+ float progress;
+} uiButProgressbar;
+
+typedef struct uiButHSVCube {
+ uiBut but;
+
+ eButGradientType gradient_type;
+} uiButHSVCube;
+
/**
* Additional, superimposed icon for a button, invoking an operator.
*/
@@ -414,8 +447,8 @@ struct uiBlock {
char direction;
/** UI_BLOCK_THEME_STYLE_* */
char theme_style;
- /** drawtype: UI_EMBOSS, UI_EMBOSS_NONE ... etc, copied to buttons */
- char dt;
+ /** UI_EMBOSS, UI_EMBOSS_NONE ... etc, copied to #uiBut.emboss */
+ char emboss;
bool auto_open;
char _pad[5];
double auto_open_last;
@@ -505,6 +538,8 @@ extern void ui_window_to_region_rcti(const struct ARegion *region,
extern void ui_region_to_window(const struct ARegion *region, int *x, int *y);
extern void ui_region_winrct_get_no_margin(const struct ARegion *region, struct rcti *r_rect);
+uiBut *ui_but_change_type(uiBut *but, eButType new_type);
+
extern double ui_but_value_get(uiBut *but);
extern void ui_but_value_set(uiBut *but, double value);
extern void ui_but_hsv_set(uiBut *but);
@@ -516,7 +551,7 @@ extern void ui_hsvcircle_vals_from_pos(
extern void ui_hsvcircle_pos_from_vals(
const ColorPicker *cpicker, const rcti *rect, const float *hsv, float *xpos, float *ypos);
extern void ui_hsvcube_pos_from_vals(
- const struct uiBut *but, const rcti *rect, const float *hsv, float *xp, float *yp);
+ const struct uiButHSVCube *hsv_but, const rcti *rect, const float *hsv, float *xp, float *yp);
extern void ui_but_string_get_ex(uiBut *but,
char *str,
@@ -548,6 +583,9 @@ extern void ui_but_rna_menu_convert_to_panel_type(struct uiBut *but, const char
extern void ui_but_rna_menu_convert_to_menu_type(struct uiBut *but, const char *menu_type);
extern bool ui_but_menu_draw_as_popover(const uiBut *but);
+void ui_but_range_set_hard(uiBut *but);
+void ui_but_range_set_soft(uiBut *but);
+
extern void ui_but_update(uiBut *but);
extern void ui_but_update_edited(uiBut *but);
extern bool ui_but_is_float(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
@@ -671,13 +709,13 @@ ColorPicker *ui_block_colorpicker_create(struct uiBlock *block);
/* Searchbox for string button */
struct ARegion *ui_searchbox_create_generic(struct bContext *C,
struct ARegion *butregion,
- uiBut *but);
+ uiButSearch *search_but);
struct ARegion *ui_searchbox_create_operator(struct bContext *C,
struct ARegion *butregion,
- uiBut *but);
+ uiButSearch *search_but);
struct ARegion *ui_searchbox_create_menu(struct bContext *C,
struct ARegion *butregion,
- uiBut *but);
+ uiButSearch *search_but);
bool ui_searchbox_inside(struct ARegion *region, int x, int y);
int ui_searchbox_find_index(struct ARegion *region, const char *name);
@@ -690,7 +728,7 @@ bool ui_searchbox_event(struct bContext *C,
const struct wmEvent *event);
bool ui_searchbox_apply(uiBut *but, struct ARegion *region);
void ui_searchbox_free(struct bContext *C, struct ARegion *region);
-void ui_but_search_refresh(uiBut *but);
+void ui_but_search_refresh(uiButSearch *but);
/* interface_region_menu_popup.c */
int ui_but_menu_step(uiBut *but, int step);
@@ -756,7 +794,10 @@ void ui_panel_set_search_filtered(struct Panel *panel, const bool value);
extern void ui_draw_dropshadow(
const rctf *rct, float radius, float aspect, float alpha, int select);
-void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, const float alpha);
+void ui_draw_gradient(const rcti *rect,
+ const float hsv[3],
+ const eButGradientType type,
+ const float alpha);
void ui_draw_but_TAB_outline(const rcti *rect,
float rad,
@@ -935,11 +976,12 @@ void ui_resources_free(void);
/* interface_layout.c */
void ui_layout_add_but(uiLayout *layout, uiBut *but);
-void ui_but_add_search(uiBut *but,
- PointerRNA *ptr,
- PropertyRNA *prop,
- PointerRNA *searchptr,
- PropertyRNA *searchprop);
+bool ui_layout_replace_but_ptr(uiLayout *layout, const void *old_but_ptr, uiBut *new_but);
+uiBut *ui_but_add_search(uiBut *but,
+ PointerRNA *ptr,
+ PropertyRNA *prop,
+ PointerRNA *searchptr,
+ PropertyRNA *searchprop);
void ui_layout_list_set_labels_active(uiLayout *layout);
/* menu callback */
void ui_item_menutype_func(struct bContext *C, struct uiLayout *layout, void *arg_mt);
@@ -960,7 +1002,7 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str);
void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, float cfra);
void ui_but_anim_decorate_cb(struct bContext *C, void *arg_but, void *arg_dummy);
-void ui_but_anim_decorate_update_from_flag(uiBut *but);
+void ui_but_anim_decorate_update_from_flag(uiButDecorator *but);
/* interface_query.c */
bool ui_but_is_editable(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
@@ -1087,5 +1129,3 @@ bool ui_jump_to_target_button_poll(struct bContext *C);
/* interface_queries.c */
void ui_interface_tag_script_reload_queries(void);
-
-#endif /* __INTERFACE_INTERN_H__ */
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 37d45d6283b..c867a31f932 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -688,7 +688,7 @@ static void ui_item_array(uiLayout *layout,
/* show checkboxes for rna on a non-emboss block (menu for eg) */
if (type == PROP_BOOLEAN &&
- ELEM(layout->root->block->dt, UI_EMBOSS_NONE, UI_EMBOSS_PULLDOWN)) {
+ ELEM(layout->root->block->emboss, UI_EMBOSS_NONE, UI_EMBOSS_PULLDOWN)) {
boolarr = MEM_callocN(sizeof(bool) * len, __func__);
RNA_property_boolean_get_array(ptr, prop, boolarr);
}
@@ -987,7 +987,7 @@ static uiBut *ui_item_with_label(uiLayout *layout,
int h,
int flag)
{
- uiLayout *sub;
+ uiLayout *sub = layout;
uiBut *but = NULL;
uiBut *label_but = NULL;
PropertyType type;
@@ -997,14 +997,20 @@ static uiBut *ui_item_with_label(uiLayout *layout,
uiBut *decorator_but = NULL;
uiLayout *layout_prop_decorate = NULL;
const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
+ const bool use_prop_decorate = use_prop_sep && (layout->item.flag & UI_ITEM_PROP_DECORATE) &&
+ (layout->item.flag & UI_ITEM_PROP_DECORATE_NO_PAD) == 0;
#endif
- /* Previously 'align' was enabled to make sure the label is spaced closely to the button.
- * Set the space to zero instead as aligning a large number of labels can end up aligning
- * thousands of buttons when displaying key-map search (a heavy operation), see: T78636. */
- sub = uiLayoutRow(layout, false);
- sub->space = 0;
- UI_block_layout_set_current(block, sub);
+ UI_block_layout_set_current(block, layout);
+
+ /* Only add new row if more than 1 item will be added. */
+ if (name[0] || use_prop_decorate) {
+ /* Also avoid setting 'align' if possible. Set the space to zero instead as aligning a large
+ * number of labels can end up aligning thousands of buttons when displaying key-map search (a
+ * heavy operation), see: T78636. */
+ sub = uiLayoutRow(layout, layout->align);
+ sub->space = 0;
+ }
#ifdef UI_PROP_DECORATE
if (name[0]) {
@@ -1103,12 +1109,8 @@ static uiBut *ui_item_with_label(uiLayout *layout,
#ifdef UI_PROP_DECORATE
/* Only for alignment. */
- if (use_prop_sep) { /* Flag may have been unset meanwhile. */
- if ((layout->item.flag & UI_ITEM_PROP_DECORATE) &&
- (layout->item.flag & UI_ITEM_PROP_DECORATE_NO_PAD) == 0) {
- decorator_but = uiItemL_(
- layout_prop_decorate ? layout_prop_decorate : sub, NULL, ICON_BLANK1);
- }
+ if (use_prop_decorate) { /* Note that sep flag may have been unset meanwhile. */
+ decorator_but = uiItemL_(layout_prop_decorate ? layout_prop_decorate : sub, NULL, ICON_BLANK1);
}
#endif /* UI_PROP_DECORATE */
@@ -2357,7 +2359,7 @@ void uiItemFullR(uiLayout *layout,
/* property with separate label */
else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) {
but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
- ui_but_add_search(but, ptr, prop, NULL, NULL);
+ but = ui_but_add_search(but, ptr, prop, NULL, NULL);
if (layout->redalert) {
UI_but_flag_enable(but, UI_BUT_REDALERT);
@@ -2416,7 +2418,7 @@ void uiItemFullR(uiLayout *layout,
/* Mark non-embossed textfields inside a listbox. */
if (but && (block->flag & UI_BLOCK_LIST_ITEM) && (but->type == UI_BTYPE_TEXT) &&
- (but->dt & UI_EMBOSS_NONE)) {
+ (but->emboss & UI_EMBOSS_NONE)) {
UI_but_flag_enable(but, UI_BUT_LIST_ITEM);
}
@@ -2737,7 +2739,10 @@ static void ui_rna_collection_search_arg_free_fn(void *ptr)
MEM_freeN(ptr);
}
-void ui_but_add_search(
+/**
+ * \note May reallocate \a but, so the possibly new address is returned.
+ */
+uiBut *ui_but_add_search(
uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop)
{
StructRNA *ptype;
@@ -2755,11 +2760,13 @@ void ui_but_add_search(
/* turn button into search button */
if (searchprop) {
uiRNACollectionSearch *coll_search = MEM_mallocN(sizeof(*coll_search), __func__);
+ uiButSearch *search_but;
- but->type = UI_BTYPE_SEARCH_MENU;
+ but = ui_but_change_type(but, UI_BTYPE_SEARCH_MENU);
+ search_but = (uiButSearch *)but;
+ search_but->rnasearchpoin = *searchptr;
+ search_but->rnasearchprop = searchprop;
but->hardmax = MAX2(but->hardmax, 256.0f);
- but->rnasearchpoin = *searchptr;
- but->rnasearchprop = searchprop;
but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT;
if (RNA_property_is_unlink(prop)) {
but->flag |= UI_BUT_VALUE_CLEAR;
@@ -2793,6 +2800,8 @@ void ui_but_add_search(
* so other code might have already set but->type to search menu... */
but->flag |= UI_BUT_DISABLED;
}
+
+ return but;
}
void uiItemPointerR_prop(uiLayout *layout,
@@ -3025,29 +3034,28 @@ void uiItemMContents(uiLayout *layout, const char *menuname)
void uiItemDecoratorR_prop(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index)
{
uiBlock *block = layout->root->block;
- uiBut *but = NULL;
-
uiLayout *col;
+
UI_block_layout_set_current(block, layout);
col = uiLayoutColumn(layout, false);
col->space = 0;
col->emboss = UI_EMBOSS_NONE;
if (ELEM(NULL, ptr, prop) || !RNA_property_animateable(ptr, prop)) {
- but = uiDefIconBut(block,
- UI_BTYPE_BUT,
- 0,
- ICON_BLANK1,
- 0,
- 0,
- UI_UNIT_X,
- UI_UNIT_Y,
- NULL,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- "");
+ uiBut *but = uiDefIconBut(block,
+ UI_BTYPE_DECORATOR,
+ 0,
+ ICON_BLANK1,
+ 0,
+ 0,
+ UI_UNIT_X,
+ UI_UNIT_Y,
+ NULL,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ "");
but->flag |= UI_BUT_DISABLED;
return;
}
@@ -3057,27 +3065,28 @@ void uiItemDecoratorR_prop(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop,
/* Loop for the array-case, but only do in case of an expanded array. */
for (int i = 0; i < (is_expand ? RNA_property_array_length(ptr, prop) : 1); i++) {
- but = uiDefIconBut(block,
- UI_BTYPE_BUT,
- 0,
- ICON_DOT,
- 0,
- 0,
- UI_UNIT_X,
- UI_UNIT_Y,
- NULL,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- TIP_("Animate property"));
- UI_but_func_set(but, ui_but_anim_decorate_cb, but, NULL);
- but->flag |= UI_BUT_UNDO | UI_BUT_DRAG_LOCK;
+ uiButDecorator *decorator_but = (uiButDecorator *)uiDefIconBut(block,
+ UI_BTYPE_DECORATOR,
+ 0,
+ ICON_DOT,
+ 0,
+ 0,
+ UI_UNIT_X,
+ UI_UNIT_Y,
+ NULL,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ TIP_("Animate property"));
+
+ UI_but_func_set(&decorator_but->but, ui_but_anim_decorate_cb, decorator_but, NULL);
+ decorator_but->but.flag |= UI_BUT_UNDO | UI_BUT_DRAG_LOCK;
/* Reusing RNA search members, setting actual RNA data has many side-effects. */
- but->rnasearchpoin = *ptr;
- but->rnasearchprop = prop;
+ decorator_but->rnapoin = *ptr;
+ decorator_but->rnaprop = prop;
/* ui_def_but_rna() sets non-array buttons to have a RNA index of 0. */
- but->custom_data = POINTER_FROM_INT((!is_array || is_expand) ? i : index);
+ decorator_but->rnaindex = (!is_array || is_expand) ? i : index;
}
}
@@ -3937,7 +3946,7 @@ static void ui_litem_layout_radial(uiLayout *litem)
bitem->but->rect.xmax += 1.5f * UI_UNIT_X;
/* enable drawing as pie item if supported by widget */
if (ui_item_is_radial_drawable(bitem)) {
- bitem->but->dt = UI_EMBOSS_RADIAL;
+ bitem->but->emboss = UI_EMBOSS_RADIAL;
bitem->but->drawflag |= UI_BUT_ICON_LEFT;
}
}
@@ -4925,8 +4934,6 @@ void ui_layout_list_set_labels_active(uiLayout *layout)
uiLayout *uiLayoutListBox(uiLayout *layout,
uiList *ui_list,
- PointerRNA *ptr,
- PropertyRNA *prop,
PointerRNA *actptr,
PropertyRNA *actprop)
{
@@ -4935,8 +4942,6 @@ uiLayout *uiLayoutListBox(uiLayout *layout,
but->custom_data = ui_list;
- but->rnasearchpoin = *ptr;
- but->rnasearchprop = prop;
but->rnapoin = *actptr;
but->rnaprop = actprop;
@@ -5155,7 +5160,7 @@ float uiLayoutGetUnitsY(uiLayout *layout)
int uiLayoutGetEmboss(uiLayout *layout)
{
if (layout->emboss == UI_EMBOSS_UNDEFINED) {
- return layout->root->block->dt;
+ return layout->root->block->emboss;
}
return layout->emboss;
}
@@ -5952,6 +5957,7 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but)
else {
BLI_addtail(&layout->items, bitem);
}
+ but->layout = layout;
if (layout->context) {
but->context = layout->context;
@@ -5959,10 +5965,34 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but)
}
if (layout->emboss != UI_EMBOSS_UNDEFINED) {
- but->dt = layout->emboss;
+ but->emboss = layout->emboss;
}
}
+bool ui_layout_replace_but_ptr(uiLayout *layout, const void *old_but_ptr, uiBut *new_but)
+{
+ ListBase *child_list = layout->child_items_layout ? &layout->child_items_layout->items :
+ &layout->items;
+
+ LISTBASE_FOREACH (uiItem *, item, child_list) {
+ if (item->type == ITEM_BUTTON) {
+ uiButtonItem *bitem = (uiButtonItem *)item;
+
+ if (bitem->but == old_but_ptr) {
+ bitem->but = new_but;
+ return true;
+ }
+ }
+ else {
+ if (ui_layout_replace_but_ptr((uiLayout *)item, old_but_ptr, new_but)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
void uiLayoutSetFixedSize(uiLayout *layout, bool fixed_size)
{
if (fixed_size) {
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 39c1b8bb909..5a49f3e70d0 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -1148,10 +1148,11 @@ static bool jump_to_target_button(bContext *C, bool poll)
/* For string properties with prop_search, look up the search collection item. */
if (type == PROP_STRING) {
const uiBut *but = UI_context_active_but_get(C);
+ const uiButSearch *search_but = (but->type == UI_BTYPE_SEARCH_MENU) ? (uiButSearch *)but :
+ NULL;
- if (but->type == UI_BTYPE_SEARCH_MENU && but->search &&
- but->search->update_fn == ui_rna_collection_search_update_fn) {
- uiRNACollectionSearch *coll_search = but->search->arg;
+ if (search_but && search_but->items_update_fn == ui_rna_collection_search_update_fn) {
+ uiRNACollectionSearch *coll_search = search_but->arg;
char str_buf[MAXBONENAME];
char *str_ptr = RNA_property_string_get_alloc(&ptr, prop, str_buf, sizeof(str_buf), NULL);
@@ -1807,7 +1808,7 @@ static void UI_OT_drop_color(wmOperatorType *ot)
ot->flag = OPTYPE_INTERNAL;
RNA_def_float_color(ot->srna, "color", 3, NULL, 0.0, FLT_MAX, "Color", "Source color", 0.0, 1.0);
- RNA_def_boolean(ot->srna, "gamma", 0, "Gamma Corrected", "The source color is gamma corrected ");
+ RNA_def_boolean(ot->srna, "gamma", 0, "Gamma Corrected", "The source color is gamma corrected");
}
/** \} */
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index bde7fc47ff7..8bb375e8941 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -336,7 +336,7 @@ void UI_list_panel_unique_str(Panel *panel, char *r_name)
* Remove the #uiBlock corresponding to a panel. The lookup is needed because panels don't store
* a reference to their corresponding #uiBlock.
*/
-static void panel_free_block(ARegion *region, Panel *panel)
+static void panel_free_block(const bContext *C, ARegion *region, Panel *panel)
{
BLI_assert(panel->type);
@@ -349,7 +349,7 @@ static void panel_free_block(ARegion *region, Panel *panel)
LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
if (STREQ(block->name, block_name)) {
BLI_remlink(&region->uiblocks, block);
- UI_block_free(NULL, block);
+ UI_block_free(C, block);
break; /* Only delete one block for this panel. */
}
}
@@ -362,15 +362,15 @@ static void panel_free_block(ARegion *region, Panel *panel)
* \note The only panels that should need to be deleted at runtime are panels with the
* #PNL_INSTANCED flag set.
*/
-static void panel_delete(ARegion *region, ListBase *panels, Panel *panel)
+static void panel_delete(const bContext *C, ARegion *region, ListBase *panels, Panel *panel)
{
/* Recursively delete children. */
LISTBASE_FOREACH_MUTABLE (Panel *, child, &panel->children) {
- panel_delete(region, &panel->children, child);
+ panel_delete(C, region, &panel->children, child);
}
BLI_freelistN(&panel->children);
- panel_free_block(region, panel);
+ panel_free_block(C, region, panel);
BLI_remlink(panels, panel);
if (panel->activedata) {
@@ -401,7 +401,7 @@ void UI_panels_free_instanced(bContext *C, ARegion *region)
}
/* Free the panel and its sub-panels. */
- panel_delete(region, &region->panels, panel);
+ panel_delete(C, region, &region->panels, panel);
}
}
}
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index 4634f4b95c9..edb5d51a392 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -90,7 +90,7 @@ bool ui_but_is_interactive(const uiBut *but, const bool labeledit)
if (but->flag & UI_SCROLLED) {
return false;
}
- if ((but->type == UI_BTYPE_TEXT) && (but->dt == UI_EMBOSS_NONE) && !labeledit) {
+ if ((but->type == UI_BTYPE_TEXT) && (but->emboss == UI_EMBOSS_NONE) && !labeledit) {
return false;
}
if ((but->type == UI_BTYPE_LISTROW) && labeledit) {
@@ -113,7 +113,7 @@ bool UI_but_is_utf8(const uiBut *but)
#ifdef USE_UI_POPOVER_ONCE
bool ui_but_is_popover_once_compat(const uiBut *but)
{
- return ((but->type == UI_BTYPE_BUT) || ui_but_is_toggle(but));
+ return (ELEM(but->type, UI_BTYPE_BUT, UI_BTYPE_DECORATOR) || ui_but_is_toggle(but));
}
#endif
diff --git a/source/blender/editors/interface/interface_region_color_picker.c b/source/blender/editors/interface/interface_region_color_picker.c
index f9873f8b96f..0d1b483716e 100644
--- a/source/blender/editors/interface/interface_region_color_picker.c
+++ b/source/blender/editors/interface/interface_region_color_picker.c
@@ -369,6 +369,7 @@ static void ui_colorpicker_circle(uiBlock *block,
ColorPicker *cpicker)
{
uiBut *bt;
+ uiButHSVCube *hsv_but;
/* HS circle */
bt = uiDefButR_prop(block,
@@ -392,91 +393,99 @@ static void ui_colorpicker_circle(uiBlock *block,
/* value */
if (U.color_picker_type == USER_CP_CIRCLE_HSL) {
- bt = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- PICKER_W + PICKER_SPACE,
- 0,
- PICKER_BAR,
- PICKER_H,
- ptr,
- prop,
- -1,
- 0.0,
- 0.0,
- UI_GRAD_L_ALT,
- 0,
- "Lightness");
- UI_but_func_set(bt, ui_colorpicker_rna_cb, bt, NULL);
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ PICKER_W + PICKER_SPACE,
+ 0,
+ PICKER_BAR,
+ PICKER_H,
+ ptr,
+ prop,
+ -1,
+ 0.0,
+ 0.0,
+ 0,
+ 0,
+ "Lightness");
+ hsv_but->gradient_type = UI_GRAD_L_ALT;
+ UI_but_func_set(&hsv_but->but, ui_colorpicker_rna_cb, &hsv_but->but, NULL);
}
else {
- bt = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- PICKER_W + PICKER_SPACE,
- 0,
- PICKER_BAR,
- PICKER_H,
- ptr,
- prop,
- -1,
- 0.0,
- 0.0,
- UI_GRAD_V_ALT,
- 0,
- TIP_("Value"));
- UI_but_func_set(bt, ui_colorpicker_rna_cb, bt, NULL);
- }
- bt->custom_data = cpicker;
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ PICKER_W + PICKER_SPACE,
+ 0,
+ PICKER_BAR,
+ PICKER_H,
+ ptr,
+ prop,
+ -1,
+ 0.0,
+ 0.0,
+ 0,
+ 0,
+ TIP_("Value"));
+ hsv_but->gradient_type = UI_GRAD_V_ALT;
+ UI_but_func_set(&hsv_but->but, ui_colorpicker_rna_cb, &hsv_but->but, NULL);
+ }
+ hsv_but->but.custom_data = cpicker;
}
-static void ui_colorpicker_square(
- uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int type, ColorPicker *cpicker)
+static void ui_colorpicker_square(uiBlock *block,
+ PointerRNA *ptr,
+ PropertyRNA *prop,
+ eButGradientType type,
+ ColorPicker *cpicker)
{
- uiBut *bt;
- int bartype = type + 3;
+ uiButHSVCube *hsv_but;
+
+ BLI_assert(type <= UI_GRAD_HS);
/* HS square */
- bt = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- PICKER_BAR + PICKER_SPACE,
- PICKER_TOTAL_W,
- PICKER_H,
- ptr,
- prop,
- -1,
- 0.0,
- 0.0,
- type,
- 0,
- TIP_("Color"));
- UI_but_func_set(bt, ui_colorpicker_rna_cb, bt, NULL);
- bt->custom_data = cpicker;
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ 0,
+ PICKER_BAR + PICKER_SPACE,
+ PICKER_TOTAL_W,
+ PICKER_H,
+ ptr,
+ prop,
+ -1,
+ 0.0,
+ 0.0,
+ 0,
+ 0,
+ TIP_("Color"));
+ hsv_but->gradient_type = type;
+ UI_but_func_set(&hsv_but->but, ui_colorpicker_rna_cb, &hsv_but->but, NULL);
+ hsv_but->but.custom_data = cpicker;
/* value */
- bt = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 0,
- PICKER_TOTAL_W,
- PICKER_BAR,
- ptr,
- prop,
- -1,
- 0.0,
- 0.0,
- bartype,
- 0,
- TIP_("Value"));
- UI_but_func_set(bt, ui_colorpicker_rna_cb, bt, NULL);
- bt->custom_data = cpicker;
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ 0,
+ 0,
+ PICKER_TOTAL_W,
+ PICKER_BAR,
+ ptr,
+ prop,
+ -1,
+ 0.0,
+ 0.0,
+ 0,
+ 0,
+ TIP_("Value"));
+ hsv_but->gradient_type = type + 3;
+ UI_but_func_set(&hsv_but->but, ui_colorpicker_rna_cb, &hsv_but->but, NULL);
+ hsv_but->but.custom_data = cpicker;
}
/* a HS circle, V slider, rgb/hsv/hex sliders */
diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c
index 1f8af7b9e6e..1773a7b3057 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.c
@@ -367,7 +367,7 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *area)
ED_area_update_region_sizes(wm, win, area);
}
- ED_region_floating_initialize(region);
+ ED_region_floating_init(region);
ED_region_tag_redraw(region);
/* Reset zoom level (not well supported). */
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c
index 2ad7e517c60..13c85952f52 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -759,7 +759,7 @@ uiBlock *ui_popup_block_refresh(bContext *C,
ui_popup_block_scrolltest(block);
/* adds subwindow */
- ED_region_floating_initialize(region);
+ ED_region_floating_init(region);
/* get winmat now that we actually have the subwindow */
wmGetProjectionMatrix(block->winmat, &region->winrct);
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index a9e87f4cc07..2010d89165e 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -302,8 +302,11 @@ bool ui_searchbox_inside(ARegion *region, int x, int y)
bool ui_searchbox_apply(uiBut *but, ARegion *region)
{
uiSearchboxData *data = region->regiondata;
+ uiButSearch *search_but = (uiButSearch *)but;
- but->func_arg2 = NULL;
+ BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+
+ search_but->item_active = NULL;
if (data->active != -1) {
const char *name = data->items.names[data->active] +
@@ -316,7 +319,7 @@ bool ui_searchbox_apply(uiBut *but, ARegion *region)
BLI_strncpy(but->editstr, name, name_sep ? (name_sep - name) + 1 : data->items.maxstrlen);
- but->func_arg2 = data->items.pointers[data->active];
+ search_but->item_active = data->items.pointers[data->active];
return true;
}
@@ -340,8 +343,13 @@ static struct ARegion *wm_searchbox_tooltip_init(struct bContext *C,
LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
- if (but->search && but->search->tooltip_fn) {
- return but->search->tooltip_fn(C, region, but->search->arg, but->func_arg2);
+ if (but->type != UI_BTYPE_SEARCH_MENU) {
+ continue;
+ }
+
+ uiButSearch *search_but = (uiButSearch *)but;
+ if (search_but->item_tooltip_fn) {
+ return search_but->item_tooltip_fn(C, region, search_but->arg, search_but->item_active);
}
}
}
@@ -352,10 +360,13 @@ bool ui_searchbox_event(
bContext *C, ARegion *region, uiBut *but, ARegion *butregion, const wmEvent *event)
{
uiSearchboxData *data = region->regiondata;
+ uiButSearch *search_but = (uiButSearch *)but;
int type = event->type, val = event->val;
bool handled = false;
bool tooltip_timer_started = false;
+ BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+
if (type == MOUSEPAN) {
ui_pan_to_scroll(event, &type, &val);
}
@@ -373,7 +384,7 @@ bool ui_searchbox_event(
break;
case RIGHTMOUSE:
if (val) {
- if (but->search->context_menu_fn) {
+ if (search_but->item_context_menu_fn) {
if (data->active != -1) {
/* Check the cursor is over the active element
* (a little confusing if this isn't the case, although it does work). */
@@ -383,7 +394,7 @@ bool ui_searchbox_event(
&rect, event->x - region->winrct.xmin, event->y - region->winrct.ymin)) {
void *active = data->items.pointers[data->active];
- if (but->search->context_menu_fn(C, but->search->arg, active, event)) {
+ if (search_but->item_context_menu_fn(C, search_but->arg, active, event)) {
handled = true;
}
}
@@ -417,7 +428,7 @@ bool ui_searchbox_event(
if (is_inside) {
if (data->active != -1) {
ScrArea *area = CTX_wm_area(C);
- but->func_arg2 = data->items.pointers[data->active];
+ search_but->item_active = data->items.pointers[data->active];
WM_tooltip_timer_init(C, CTX_wm_window(C), area, butregion, wm_searchbox_tooltip_init);
tooltip_timer_started = true;
}
@@ -437,18 +448,24 @@ bool ui_searchbox_event(
}
/** Wrap #uiButSearchUpdateFn callback. */
-static void ui_searchbox_update_fn(bContext *C, uiBut *but, const char *str, uiSearchItems *items)
+static void ui_searchbox_update_fn(bContext *C,
+ uiButSearch *search_but,
+ const char *str,
+ uiSearchItems *items)
{
wmWindow *win = CTX_wm_window(C);
WM_tooltip_clear(C, win);
- but->search->update_fn(C, but->search->arg, str, items);
+ search_but->items_update_fn(C, search_but->arg, str, items);
}
/* region is the search box itself */
void ui_searchbox_update(bContext *C, ARegion *region, uiBut *but, const bool reset)
{
+ uiButSearch *search_but = (uiButSearch *)but;
uiSearchboxData *data = region->regiondata;
+ BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+
/* reset vars */
data->items.totitem = 0;
data->items.more = 0;
@@ -460,9 +477,9 @@ void ui_searchbox_update(bContext *C, ARegion *region, uiBut *but, const bool re
data->active = -1;
/* handle active */
- if (but->search->update_fn && but->func_arg2) {
- data->items.active = but->func_arg2;
- ui_searchbox_update_fn(C, but, but->editstr, &data->items);
+ if (search_but->items_update_fn && search_but->item_active) {
+ data->items.active = search_but->item_active;
+ ui_searchbox_update_fn(C, search_but, but->editstr, &data->items);
data->items.active = NULL;
/* found active item, calculate real offset by centering it */
@@ -491,8 +508,8 @@ void ui_searchbox_update(bContext *C, ARegion *region, uiBut *but, const bool re
}
/* callback */
- if (but->search->update_fn) {
- ui_searchbox_update_fn(C, but, but->editstr, &data->items);
+ if (search_but->items_update_fn) {
+ ui_searchbox_update_fn(C, search_but, but->editstr, &data->items);
}
/* handle case where editstr is equal to one of items */
@@ -523,13 +540,16 @@ void ui_searchbox_update(bContext *C, ARegion *region, uiBut *but, const bool re
int ui_searchbox_autocomplete(bContext *C, ARegion *region, uiBut *but, char *str)
{
+ uiButSearch *search_but = (uiButSearch *)but;
uiSearchboxData *data = region->regiondata;
int match = AUTOCOMPLETE_NO_MATCH;
+ BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+
if (str[0]) {
data->items.autocpl = UI_autocomplete_begin(str, ui_but_string_get_max_length(but));
- ui_searchbox_update_fn(C, but, but->editstr, &data->items);
+ ui_searchbox_update_fn(C, search_but, but->editstr, &data->items);
match = UI_autocomplete_end(data->items.autocpl, str);
data->items.autocpl = NULL;
@@ -673,10 +693,11 @@ static void ui_searchbox_region_free_cb(ARegion *region)
region->regiondata = NULL;
}
-ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but)
+ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiButSearch *search_but)
{
wmWindow *win = CTX_wm_window(C);
const uiStyle *style = UI_style_get();
+ uiBut *but = &search_but->but;
static ARegionType type;
ARegion *region;
uiSearchboxData *data;
@@ -725,7 +746,7 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but
if (but->optype != NULL || (but->drawflag & UI_BUT_HAS_SHORTCUT) != 0) {
data->use_sep = true;
}
- data->sep_string = but->search->sep_string;
+ data->sep_string = search_but->item_sep_string;
/* compute position */
if (but->block->flag & UI_BLOCK_SEARCH_MENU) {
@@ -819,7 +840,7 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but
}
/* adds subwindow */
- ED_region_floating_initialize(region);
+ ED_region_floating_init(region);
/* notify change and redraw */
ED_region_tag_redraw(region);
@@ -945,12 +966,12 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe
}
}
-ARegion *ui_searchbox_create_operator(bContext *C, ARegion *butregion, uiBut *but)
+ARegion *ui_searchbox_create_operator(bContext *C, ARegion *butregion, uiButSearch *search_but)
{
ARegion *region;
- UI_but_drawflag_enable(but, UI_BUT_HAS_SHORTCUT);
- region = ui_searchbox_create_generic(C, butregion, but);
+ UI_but_drawflag_enable(&search_but->but, UI_BUT_HAS_SHORTCUT);
+ region = ui_searchbox_create_generic(C, butregion, search_but);
region->type->draw = ui_searchbox_region_draw_cb__operator;
@@ -967,12 +988,12 @@ static void ui_searchbox_region_draw_cb__menu(const bContext *UNUSED(C), ARegion
/* Currently unused. */
}
-ARegion *ui_searchbox_create_menu(bContext *C, ARegion *butregion, uiBut *but)
+ARegion *ui_searchbox_create_menu(bContext *C, ARegion *butregion, uiButSearch *search_but)
{
ARegion *region;
- UI_but_drawflag_enable(but, UI_BUT_HAS_SHORTCUT);
- region = ui_searchbox_create_generic(C, butregion, but);
+ UI_but_drawflag_enable(&search_but->but, UI_BUT_HAS_SHORTCUT);
+ region = ui_searchbox_create_generic(C, butregion, search_but);
if (false) {
region->type->draw = ui_searchbox_region_draw_cb__menu;
@@ -983,8 +1004,9 @@ ARegion *ui_searchbox_create_menu(bContext *C, ARegion *butregion, uiBut *but)
/* sets red alert if button holds a string it can't find */
/* XXX weak: search_func adds all partial matches... */
-void ui_but_search_refresh(uiBut *but)
+void ui_but_search_refresh(uiButSearch *search_but)
{
+ uiBut *but = &search_but->but;
uiSearchItems *items;
int x1;
@@ -1004,7 +1026,7 @@ void ui_but_search_refresh(uiBut *but)
items->names[x1] = MEM_callocN(but->hardmax + 1, "search names");
}
- ui_searchbox_update_fn(but->block->evil_C, but, but->drawstr, items);
+ ui_searchbox_update_fn(but->block->evil_C, search_but, but->drawstr, items);
/* only redalert when we are sure of it, this can miss cases when >10 matches */
if (items->totitem == 0) {
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index 7c64e4c2709..41b41cb3d75 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -1386,7 +1386,7 @@ static ARegion *ui_tooltip_create_with_data(bContext *C,
}
/* adds subwindow */
- ED_region_floating_initialize(region);
+ ED_region_floating_init(region);
/* notify change and redraw */
ED_region_tag_redraw(region);
diff --git a/source/blender/editors/interface/interface_regions_intern.h b/source/blender/editors/interface/interface_regions_intern.h
index c299562a357..0cb1fee9a92 100644
--- a/source/blender/editors/interface/interface_regions_intern.h
+++ b/source/blender/editors/interface/interface_regions_intern.h
@@ -20,8 +20,7 @@
* Share between interface_region_*.c files.
*/
-#ifndef __INTERFACE_REGIONS_INTERN_H__
-#define __INTERFACE_REGIONS_INTERN_H__
+#pragma once
/* interface_region_menu_popup.c */
uint ui_popup_menu_hash(const char *str);
@@ -29,5 +28,3 @@ uint ui_popup_menu_hash(const char *str);
/* interface_regions_intern.h */
ARegion *ui_region_temp_add(bScreen *screen);
void ui_region_temp_remove(struct bContext *C, bScreen *screen, ARegion *region);
-
-#endif /* __INTERFACE_REGIONS_INTERN_H__ */
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 64070725f2b..5310ff0e3ec 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -334,7 +334,7 @@ void UI_fontstyle_draw_simple_backdrop(const uiFontStyle *fs,
const float margin = height / 4.0f;
/* backdrop */
- float color[4] = {col_bg[0], col_bg[1], col_bg[2], 0.5f};
+ const float color[4] = {col_bg[0], col_bg[1], col_bg[2], 0.5f};
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_aa(true,
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 851c1d5bdcc..db7902f343d 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -5188,6 +5188,7 @@ void uiTemplateColorPicker(uiLayout *layout,
uiBlock *block = uiLayoutGetBlock(layout);
uiLayout *col, *row;
uiBut *but = NULL;
+ uiButHSVCube *hsv_but;
ColorPicker *cpicker = ui_block_colorpicker_create(block);
float softmin, softmax, step, precision;
@@ -5203,58 +5204,36 @@ void uiTemplateColorPicker(uiLayout *layout,
switch (U.color_picker_type) {
case USER_CP_SQUARE_SV:
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 0,
- WHEEL_SIZE,
- WHEEL_SIZE,
- ptr,
- prop,
- -1,
- 0.0,
- 0.0,
- UI_GRAD_SV,
- 0,
- "");
- break;
case USER_CP_SQUARE_HS:
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 0,
- WHEEL_SIZE,
- WHEEL_SIZE,
- ptr,
- prop,
- -1,
- 0.0,
- 0.0,
- UI_GRAD_HS,
- 0,
- "");
- break;
case USER_CP_SQUARE_HV:
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 0,
- WHEEL_SIZE,
- WHEEL_SIZE,
- ptr,
- prop,
- -1,
- 0.0,
- 0.0,
- UI_GRAD_HV,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ 0,
+ 0,
+ WHEEL_SIZE,
+ WHEEL_SIZE,
+ ptr,
+ prop,
+ -1,
+ 0.0,
+ 0.0,
+ 0,
+ 0,
+ "");
+ switch (U.color_picker_type) {
+ case USER_CP_SQUARE_SV:
+ hsv_but->gradient_type = UI_GRAD_SV;
+ break;
+ case USER_CP_SQUARE_HS:
+ hsv_but->gradient_type = UI_GRAD_HS;
+ break;
+ case USER_CP_SQUARE_HV:
+ hsv_but->gradient_type = UI_GRAD_HV;
+ break;
+ }
+ but = &hsv_but->but;
break;
/* user default */
@@ -5297,105 +5276,110 @@ void uiTemplateColorPicker(uiLayout *layout,
switch (U.color_picker_type) {
case USER_CP_CIRCLE_HSL:
uiItemS(row);
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- WHEEL_SIZE + 6,
- 0,
- 14 * UI_DPI_FAC,
- WHEEL_SIZE,
- ptr,
- prop,
- -1,
- softmin,
- softmax,
- UI_GRAD_L_ALT,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ WHEEL_SIZE + 6,
+ 0,
+ 14 * UI_DPI_FAC,
+ WHEEL_SIZE,
+ ptr,
+ prop,
+ -1,
+ softmin,
+ softmax,
+ 0,
+ 0,
+ "");
+ hsv_but->gradient_type = UI_GRAD_L_ALT;
break;
case USER_CP_SQUARE_SV:
uiItemS(col);
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 4,
- WHEEL_SIZE,
- 18 * UI_DPI_FAC,
- ptr,
- prop,
- -1,
- softmin,
- softmax,
- UI_GRAD_SV + 3,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ 0,
+ 4,
+ WHEEL_SIZE,
+ 18 * UI_DPI_FAC,
+ ptr,
+ prop,
+ -1,
+ softmin,
+ softmax,
+ 0,
+ 0,
+ "");
+ hsv_but->gradient_type = UI_GRAD_SV + 3;
break;
case USER_CP_SQUARE_HS:
uiItemS(col);
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 4,
- WHEEL_SIZE,
- 18 * UI_DPI_FAC,
- ptr,
- prop,
- -1,
- softmin,
- softmax,
- UI_GRAD_HS + 3,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ 0,
+ 4,
+ WHEEL_SIZE,
+ 18 * UI_DPI_FAC,
+ ptr,
+ prop,
+ -1,
+ softmin,
+ softmax,
+ 0,
+ 0,
+ "");
+ hsv_but->gradient_type = UI_GRAD_HS + 3;
break;
case USER_CP_SQUARE_HV:
uiItemS(col);
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 4,
- WHEEL_SIZE,
- 18 * UI_DPI_FAC,
- ptr,
- prop,
- -1,
- softmin,
- softmax,
- UI_GRAD_HV + 3,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ 0,
+ 4,
+ WHEEL_SIZE,
+ 18 * UI_DPI_FAC,
+ ptr,
+ prop,
+ -1,
+ softmin,
+ softmax,
+ 0,
+ 0,
+ "");
+ hsv_but->gradient_type = UI_GRAD_HV + 3;
break;
/* user default */
case USER_CP_CIRCLE_HSV:
default:
uiItemS(row);
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- WHEEL_SIZE + 6,
- 0,
- 14 * UI_DPI_FAC,
- WHEEL_SIZE,
- ptr,
- prop,
- -1,
- softmin,
- softmax,
- UI_GRAD_V_ALT,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ WHEEL_SIZE + 6,
+ 0,
+ 14 * UI_DPI_FAC,
+ WHEEL_SIZE,
+ ptr,
+ prop,
+ -1,
+ softmin,
+ softmax,
+ 0,
+ 0,
+ "");
+ hsv_but->gradient_type = UI_GRAD_V_ALT;
break;
}
- but->custom_data = cpicker;
+ hsv_but->but.custom_data = cpicker;
}
}
@@ -5512,22 +5496,24 @@ void uiTemplatePalette(uiLayout *layout,
}
RNA_pointer_create(&palette->id, &RNA_PaletteColor, color, &color_ptr);
- uiDefButR(block,
- UI_BTYPE_COLOR,
- 0,
- "",
- 0,
- 0,
- UI_UNIT_X,
- UI_UNIT_Y,
- &color_ptr,
- "color",
- -1,
- 0.0,
- 1.0,
- UI_PALETTE_COLOR,
- col_id,
- "");
+ uiButColor *color_but = (uiButColor *)uiDefButR(block,
+ UI_BTYPE_COLOR,
+ 0,
+ "",
+ 0,
+ 0,
+ UI_UNIT_X,
+ UI_UNIT_Y,
+ &color_ptr,
+ "color",
+ -1,
+ 0.0,
+ 1.0,
+ 0.0,
+ 0.0,
+ "");
+ color_but->is_pallete_color = true;
+ color_but->palette_color_index = col_id;
row_cols++;
col_id++;
}
@@ -6210,7 +6196,7 @@ void uiTemplateList(uiLayout *layout,
switch (layout_type) {
case UILST_LAYOUT_DEFAULT:
/* layout */
- box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop);
+ box = uiLayoutListBox(layout, ui_list, active_dataptr, activeprop);
glob = uiLayoutColumn(box, true);
row = uiLayoutRow(glob, false);
col = uiLayoutColumn(row, true);
@@ -6348,7 +6334,7 @@ void uiTemplateList(uiLayout *layout,
}
break;
case UILST_LAYOUT_GRID:
- box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop);
+ box = uiLayoutListBox(layout, ui_list, active_dataptr, activeprop);
glob = uiLayoutColumn(box, true);
row = uiLayoutRow(glob, false);
col = uiLayoutColumn(row, true);
@@ -6789,22 +6775,24 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
struct ProgressTooltip_Store *tip_arg = MEM_mallocN(sizeof(*tip_arg), __func__);
tip_arg->wm = wm;
tip_arg->owner = owner;
- uiBut *but_progress = uiDefIconTextBut(block,
- UI_BTYPE_PROGRESS_BAR,
- 0,
- 0,
- text,
- UI_UNIT_X,
- 0,
- UI_UNIT_X * 6.0f,
- UI_UNIT_Y,
- NULL,
- 0.0f,
- 0.0f,
- progress,
- 0,
- NULL);
- UI_but_func_tooltip_set(but_progress, progress_tooltip_func, tip_arg);
+ uiButProgressbar *but_progress = (uiButProgressbar *)uiDefIconTextBut(block,
+ UI_BTYPE_PROGRESS_BAR,
+ 0,
+ 0,
+ text,
+ UI_UNIT_X,
+ 0,
+ UI_UNIT_X * 6.0f,
+ UI_UNIT_Y,
+ NULL,
+ 0.0f,
+ 0.0f,
+ 0.0f,
+ 0,
+ NULL);
+
+ but_progress->progress = progress;
+ UI_but_func_tooltip_set(&but_progress->but, progress_tooltip_func, tip_arg);
}
if (!wm->is_interface_locked) {
@@ -7348,6 +7336,9 @@ void uiTemplateCacheFile(uiLayout *layout,
uiItemR(row, &fileptr, "scale", 0, IFACE_("Manual Scale"), ICON_NONE);
}
+ uiItemR(layout, &fileptr, "velocity_name", 0, NULL, ICON_NONE);
+ uiItemR(layout, &fileptr, "velocity_unit", 0, NULL, ICON_NONE);
+
/* TODO: unused for now, so no need to expose. */
#if 0
row = uiLayoutRow(layout, false);
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 208fd7136da..4a1c7be918e 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -148,7 +148,7 @@ uiBut *uiDefAutoButR(uiBlock *block,
if (RNA_property_array_check(prop) && index == -1) {
if (ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA)) {
but = uiDefButR_prop(
- block, UI_BTYPE_COLOR, 0, name, x1, y1, x2, y2, ptr, prop, -1, 0, 0, -1, -1, NULL);
+ block, UI_BTYPE_COLOR, 0, name, x1, y1, x2, y2, ptr, prop, -1, 0, 0, 0, 0, NULL);
}
else {
return NULL;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index c9c460c6a72..c4de2730600 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -518,7 +518,7 @@ GPUBatch *ui_batch_roundbox_shadow_get(void)
void UI_draw_anti_tria(
float x1, float y1, float x2, float y2, float x3, float y3, const float color[4])
{
- float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}};
+ const float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}};
float draw_color[4];
copy_v4_v4(draw_color, color);
@@ -1356,7 +1356,7 @@ static void widget_draw_preview(BIFIconID icon, float alpha, const rcti *rect)
static int ui_but_draw_menu_icon(const uiBut *but)
{
- return (but->flag & UI_BUT_ICON_SUBMENU) && (but->dt == UI_EMBOSS_PULLDOWN);
+ return (but->flag & UI_BUT_ICON_SUBMENU) && (but->emboss == UI_EMBOSS_PULLDOWN);
}
/* icons have been standardized... and this call draws in untransformed coordinates */
@@ -1400,8 +1400,8 @@ static void widget_draw_icon(
alpha *= but->a2;
}
}
- else if (ELEM(but->type, UI_BTYPE_BUT)) {
- if (but->flag & UI_BUT_DISABLED) {
+ else if (ELEM(but->type, UI_BTYPE_BUT, UI_BTYPE_DECORATOR)) {
+ if (but->flag & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
alpha *= 0.5f;
}
}
@@ -1417,7 +1417,7 @@ static void widget_draw_icon(
but->str && but->str[0] == '\0') {
xs = rect->xmin + 2.0f * ofs;
}
- else if (but->dt == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL) {
+ else if (but->emboss == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL) {
xs = rect->xmin + 2.0f * ofs;
}
else {
@@ -2375,7 +2375,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
/* pass (even if its a menu toolbar) */
}
else if (ui_block_is_pie_menu(but->block)) {
- if (but->dt == UI_EMBOSS_RADIAL) {
+ if (but->emboss == UI_EMBOSS_RADIAL) {
rect->xmin += 0.3f * U.widget_unit;
}
}
@@ -2403,7 +2403,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
}
else if (but->flag & UI_BUT_DRAG_MULTI) {
bool text_is_edited = ui_but_drag_multi_edit_get(but) != NULL;
- if (text_is_edited) {
+ if (text_is_edited || (but->drawflag & UI_BUT_TEXT_LEFT)) {
rect->xmin += text_padding;
}
}
@@ -2568,7 +2568,7 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag)
}
if (state & UI_BUT_REDALERT) {
- uchar red[4] = {255, 0, 0};
+ const uchar red[4] = {255, 0, 0};
if (wt->draw) {
color_blend_v3_v3(wt->wcol.inner, red, 0.4f);
}
@@ -2585,7 +2585,7 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag)
}
if (state & UI_BUT_NODE_ACTIVE) {
- uchar blue[4] = {86, 128, 194};
+ const uchar blue[4] = {86, 128, 194};
color_blend_v3_v3(wt->wcol.inner, blue, 0.3f);
}
}
@@ -2622,18 +2622,19 @@ static void widget_state_numslider(uiWidgetType *wt, int state, int drawflag)
/* labels use theme colors for text */
static void widget_state_option_menu(uiWidgetType *wt, int state, int drawflag)
{
- bTheme *btheme = UI_GetTheme(); /* XXX */
+ const bTheme *btheme = UI_GetTheme();
+
+ const uiWidgetColors *old_wcol = wt->wcol_theme;
+ uiWidgetColors wcol_menu_option = *wt->wcol_theme;
+
+ /* Override the checkbox theme colors to use the menu-back text colors. */
+ copy_v3_v3_uchar(wcol_menu_option.text, btheme->tui.wcol_menu_back.text);
+ copy_v3_v3_uchar(wcol_menu_option.text_sel, btheme->tui.wcol_menu_back.text_sel);
+ wt->wcol_theme = &wcol_menu_option;
- /* call this for option button */
widget_state(wt, state, drawflag);
- /* if not selected we get theme from menu back */
- if (state & UI_SELECT) {
- copy_v3_v3_uchar(wt->wcol.text, btheme->tui.wcol_menu_back.text_sel);
- }
- else {
- copy_v3_v3_uchar(wt->wcol.text, btheme->tui.wcol_menu_back.text);
- }
+ wt->wcol_theme = old_wcol;
}
static void widget_state_nothing(uiWidgetType *wt, int UNUSED(state), int UNUSED(drawflag))
@@ -2970,7 +2971,10 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const
* \{ */
/* draws in resolution of 48x4 colors */
-void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, const float alpha)
+void ui_draw_gradient(const rcti *rect,
+ const float hsv[3],
+ const eButGradientType type,
+ const float alpha)
{
/* allows for 4 steps (red->yellow) */
const int steps = 48;
@@ -3087,6 +3091,8 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
copy_v3_v3(col1[1], col1[2]);
copy_v3_v3(col1[3], col1[2]);
break;
+ default:
+ break;
}
/* rect */
@@ -3121,11 +3127,11 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
}
void ui_hsvcube_pos_from_vals(
- const uiBut *but, const rcti *rect, const float *hsv, float *r_xp, float *r_yp)
+ const uiButHSVCube *hsv_but, const rcti *rect, const float *hsv, float *r_xp, float *r_yp)
{
float x = 0.0f, y = 0.0f;
- switch ((int)but->a1) {
+ switch (hsv_but->gradient_type) {
case UI_GRAD_SV:
x = hsv[1];
y = hsv[2];
@@ -3158,7 +3164,7 @@ void ui_hsvcube_pos_from_vals(
case UI_GRAD_V_ALT:
x = 0.5f;
/* exception only for value strip - use the range set in but->min/max */
- y = (hsv[2] - but->softmin) / (but->softmax - but->softmin);
+ y = (hsv[2] - hsv_but->but.softmin) / (hsv_but->but.softmax - hsv_but->but.softmin);
break;
}
@@ -3169,6 +3175,7 @@ void ui_hsvcube_pos_from_vals(
static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
{
+ const uiButHSVCube *hsv_but = (uiButHSVCube *)but;
float rgb[3];
float x = 0.0f, y = 0.0f;
ColorPicker *cpicker = but->custom_data;
@@ -3182,9 +3189,9 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
ui_scene_linear_to_color_picker_space(but, rgb);
rgb_to_hsv_compat_v(rgb, hsv_n);
- ui_draw_gradient(rect, hsv_n, but->a1, 1.0f);
+ ui_draw_gradient(rect, hsv_n, hsv_but->gradient_type, 1.0f);
- ui_hsvcube_pos_from_vals(but, rect, hsv_n, &x, &y);
+ ui_hsvcube_pos_from_vals(hsv_but, rect, hsv_n, &x, &y);
CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f);
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
@@ -3201,6 +3208,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
/* vertical 'value' slider, using new widget code */
static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
{
+ const uiButHSVCube *hsv_but = (uiButHSVCube *)but;
bTheme *btheme = UI_GetTheme();
uiWidgetColors *wcol = &btheme->tui.wcol_numslider;
uiWidgetBase wtb;
@@ -3211,7 +3219,7 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
ui_but_v3_get(but, rgb);
ui_scene_linear_to_color_picker_space(but, rgb);
- if (but->a1 == UI_GRAD_L_ALT) {
+ if (hsv_but->gradient_type == UI_GRAD_L_ALT) {
rgb_to_hsl_v(rgb, hsv);
}
else {
@@ -3220,7 +3228,7 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
v = hsv[2];
/* map v from property range to [0,1] */
- if (but->a1 == UI_GRAD_V_ALT) {
+ if (hsv_but->gradient_type == UI_GRAD_V_ALT) {
float min = but->softmin, max = but->softmax;
v = (v - min) / (max - min);
}
@@ -3608,6 +3616,7 @@ static void widget_scroll(
static void widget_progressbar(
uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
{
+ uiButProgressbar *but_progressbar = (uiButProgressbar *)but;
uiWidgetBase wtb, wtb_bar;
rcti rect_prog = *rect, rect_bar = *rect;
@@ -3615,7 +3624,7 @@ static void widget_progressbar(
widget_init(&wtb_bar);
/* round corners */
- float value = but->a1;
+ float value = but_progressbar->progress;
float offs = wcol->roundness * BLI_rcti_size_y(&rect_prog);
float w = value * BLI_rcti_size_x(&rect_prog);
@@ -3767,6 +3776,8 @@ static void widget_numslider(
static void widget_swatch(
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
+ BLI_assert(but->type == UI_BTYPE_COLOR);
+ uiButColor *color_but = (uiButColor *)but;
uiWidgetBase wtb;
float rad, col[4];
@@ -3821,8 +3832,8 @@ static void widget_swatch(
}
widgetbase_draw_ex(&wtb, wcol, show_alpha_checkers);
- if (but->a1 == UI_PALETTE_COLOR &&
- ((Palette *)but->rnapoin.owner_id)->active_color == (int)but->a2) {
+ if (color_but->is_pallete_color &&
+ ((Palette *)but->rnapoin.owner_id)->active_color == color_but->palette_color_index) {
float width = rect->xmax - rect->xmin;
float height = rect->ymax - rect->ymin;
/* find color luminance and change it slightly */
@@ -4070,7 +4081,7 @@ static void widget_state_label(uiWidgetType *wt, int state, int drawflag)
}
if (state & UI_BUT_REDALERT) {
- uchar red[4] = {255, 0, 0};
+ const uchar red[4] = {255, 0, 0};
color_blend_v3_v3(wt->wcol.text, red, 0.4f);
}
}
@@ -4501,7 +4512,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
uiWidgetType *wt = NULL;
/* handle menus separately */
- if (but->dt == UI_EMBOSS_PULLDOWN) {
+ if (but->emboss == UI_EMBOSS_PULLDOWN) {
switch (but->type) {
case UI_BTYPE_LABEL:
widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect);
@@ -4514,7 +4525,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
break;
}
}
- else if (but->dt == UI_EMBOSS_NONE) {
+ else if (but->emboss == UI_EMBOSS_NONE) {
/* "nothing" */
switch (but->type) {
case UI_BTYPE_LABEL:
@@ -4525,11 +4536,11 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
break;
}
}
- else if (but->dt == UI_EMBOSS_RADIAL) {
+ else if (but->emboss == UI_EMBOSS_RADIAL) {
wt = widget_type(UI_WTYPE_MENU_ITEM_RADIAL);
}
else {
- BLI_assert(but->dt == UI_EMBOSS);
+ BLI_assert(but->emboss == UI_EMBOSS);
switch (but->type) {
case UI_BTYPE_LABEL:
@@ -4551,6 +4562,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
break;
case UI_BTYPE_BUT:
+ case UI_BTYPE_DECORATOR:
#ifdef USE_UI_TOOLBAR_HACK
if ((but->icon != ICON_NONE) && UI_but_is_tool(but)) {
wt = widget_type(UI_WTYPE_TOOLBAR_ITEM);
@@ -4665,8 +4677,10 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
widget_draw_extra_mask(C, but, widget_type(UI_WTYPE_BOX), rect);
break;
- case UI_BTYPE_HSVCUBE:
- if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) {
+ case UI_BTYPE_HSVCUBE: {
+ const uiButHSVCube *hsv_but = (uiButHSVCube *)but;
+
+ if (ELEM(hsv_but->gradient_type, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) {
/* vertical V slider, uses new widget draw now */
ui_draw_but_HSV_v(but, rect);
}
@@ -4674,6 +4688,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
ui_draw_but_HSVCUBE(but, rect);
}
break;
+ }
case UI_BTYPE_HSVCIRCLE:
ui_draw_but_HSVCIRCLE(but, &tui->wcol_regular, rect);
@@ -4778,7 +4793,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
}
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
- if (but->dt != UI_EMBOSS_PULLDOWN) {
+ if (but->emboss != UI_EMBOSS_PULLDOWN) {
disabled = true;
}
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 0cbf73280a3..3efed43e08c 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -242,7 +242,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
bool tot_changed = false, do_init;
const uiStyle *style = UI_style_get();
- do_init = (v2d->flag & V2D_IS_INITIALISED) == 0;
+ do_init = (v2d->flag & V2D_IS_INIT) == 0;
/* see eView2D_CommonViewTypes in UI_view2d.h for available view presets */
switch (type) {
@@ -374,8 +374,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
break;
}
- /* set initialized flag so that View2D doesn't get reinitialised next time again */
- v2d->flag |= V2D_IS_INITIALISED;
+ /* set initialized flag so that View2D doesn't get reinitialized next time again */
+ v2d->flag |= V2D_IS_INIT;
/* store view size */
v2d->winx = winx;
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 64cacd44e3d..d62058699d9 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -56,7 +56,7 @@ static bool view2d_poll(bContext *C)
{
ARegion *region = CTX_wm_region(C);
- return (region != NULL) && (region->v2d.flag & V2D_IS_INITIALISED);
+ return (region != NULL) && (region->v2d.flag & V2D_IS_INIT);
}
/** \} */
diff --git a/source/blender/editors/io/io_alembic.h b/source/blender/editors/io/io_alembic.h
index ecd8c1818f8..512f4e4636b 100644
--- a/source/blender/editors/io/io_alembic.h
+++ b/source/blender/editors/io/io_alembic.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __IO_ALEMBIC_H__
-#define __IO_ALEMBIC_H__
+#pragma once
/** \file
* \ingroup editor/io
@@ -28,5 +27,3 @@ struct wmOperatorType;
void WM_OT_alembic_export(struct wmOperatorType *ot);
void WM_OT_alembic_import(struct wmOperatorType *ot);
-
-#endif /* __IO_ALEMBIC_H__ */
diff --git a/source/blender/editors/io/io_cache.h b/source/blender/editors/io/io_cache.h
index c6fc50a236e..be6e31842af 100644
--- a/source/blender/editors/io/io_cache.h
+++ b/source/blender/editors/io/io_cache.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __IO_CACHE_H__
-#define __IO_CACHE_H__
+#pragma once
/** \file
* \ingroup editor/io
@@ -28,5 +27,3 @@ struct wmOperatorType;
void CACHEFILE_OT_open(struct wmOperatorType *ot);
void CACHEFILE_OT_reload(struct wmOperatorType *ot);
-
-#endif /* __IO_CACHE_H__ */
diff --git a/source/blender/editors/io/io_collada.h b/source/blender/editors/io/io_collada.h
index 6330fc9639a..5c0a1a8b927 100644
--- a/source/blender/editors/io/io_collada.h
+++ b/source/blender/editors/io/io_collada.h
@@ -21,12 +21,9 @@
* \ingroup editor/io
*/
-#ifndef __IO_COLLADA_H__
-#define __IO_COLLADA_H__
+#pragma once
struct wmOperatorType;
void WM_OT_collada_export(struct wmOperatorType *ot);
void WM_OT_collada_import(struct wmOperatorType *ot);
-
-#endif
diff --git a/source/blender/editors/io/io_ops.h b/source/blender/editors/io/io_ops.h
index 2923e052752..2e6cccbf438 100644
--- a/source/blender/editors/io/io_ops.h
+++ b/source/blender/editors/io/io_ops.h
@@ -21,9 +21,6 @@
* \ingroup editor/io
*/
-#ifndef __IO_OPS_H__
-#define __IO_OPS_H__
+#pragma once
void ED_operatortypes_io(void);
-
-#endif
diff --git a/source/blender/editors/io/io_usd.h b/source/blender/editors/io/io_usd.h
index c794dc744df..671984b6f34 100644
--- a/source/blender/editors/io/io_usd.h
+++ b/source/blender/editors/io/io_usd.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __IO_USD_H__
-#define __IO_USD_H__
+#pragma once
/** \file
* \ingroup editor/io
@@ -27,5 +26,3 @@
struct wmOperatorType;
void WM_OT_usd_export(struct wmOperatorType *ot);
-
-#endif /* __IO_USD_H__ */
diff --git a/source/blender/editors/lattice/lattice_intern.h b/source/blender/editors/lattice/lattice_intern.h
index fe3f35b9223..ee324a3b31e 100644
--- a/source/blender/editors/lattice/lattice_intern.h
+++ b/source/blender/editors/lattice/lattice_intern.h
@@ -21,8 +21,7 @@
* \ingroup edlattice
*/
-#ifndef __LATTICE_INTERN_H__
-#define __LATTICE_INTERN_H__
+#pragma once
/* editlattice_select.c */
void LATTICE_OT_select_all(struct wmOperatorType *ot);
@@ -35,5 +34,3 @@ void LATTICE_OT_select_mirror(struct wmOperatorType *ot);
/* editlattice_tools.c */
void LATTICE_OT_make_regular(struct wmOperatorType *ot);
void LATTICE_OT_flip(struct wmOperatorType *ot);
-
-#endif /* __LATTICE_INTERN_H__ */
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index c19a5b8ef68..3dc6227434e 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -796,7 +796,7 @@ static void define_primitive_add_properties(wmOperatorType *ot)
static int primitive_circle_add_exec(bContext *C, wmOperator *op)
{
const float points[4][2] = {{0.0f, 0.5f}, {0.5f, 1.0f}, {1.0f, 0.5f}, {0.5f, 0.0f}};
- int num_points = sizeof(points) / (2 * sizeof(float));
+ int num_points = sizeof(points) / (sizeof(float[2]));
create_primitive_from_points(C, op, points, num_points, HD_AUTO);
@@ -827,7 +827,7 @@ void MASK_OT_primitive_circle_add(wmOperatorType *ot)
static int primitive_square_add_exec(bContext *C, wmOperator *op)
{
const float points[4][2] = {{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}};
- int num_points = sizeof(points) / (2 * sizeof(float));
+ int num_points = sizeof(points) / (sizeof(float[2]));
create_primitive_from_points(C, op, points, num_points, HD_VECT);
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 12ce358a501..c617c921d70 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -735,7 +735,7 @@ void ED_mask_draw_region(
}
if (draw_flag & MASK_DRAWFLAG_OVERLAY) {
- float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
+ const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
float *buffer = mask_rasterize(mask_eval, width, height);
if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h
index 6a45af4d2a6..f6990583383 100644
--- a/source/blender/editors/mask/mask_intern.h
+++ b/source/blender/editors/mask/mask_intern.h
@@ -21,8 +21,7 @@
* \ingroup spclip
*/
-#ifndef __MASK_INTERN_H__
-#define __MASK_INTERN_H__
+#pragma once
struct Mask;
struct bContext;
@@ -130,5 +129,3 @@ void MASK_OT_shape_key_insert(struct wmOperatorType *ot);
void MASK_OT_shape_key_clear(struct wmOperatorType *ot);
void MASK_OT_shape_key_feather_reset(struct wmOperatorType *ot);
void MASK_OT_shape_key_rekey(struct wmOperatorType *ot);
-
-#endif /* __MASK_INTERN_H__ */
diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c
index 74348f2c8cf..1eb6613d8fe 100644
--- a/source/blender/editors/mask/mask_shapekey.c
+++ b/source/blender/editors/mask/mask_shapekey.c
@@ -327,7 +327,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
if (MASKPOINT_ISSEL_ANY(point)) {
if (do_location) {
- memcpy(shape_ele_dst->value, shape_ele_src->value, sizeof(float) * 6);
+ memcpy(shape_ele_dst->value, shape_ele_src->value, sizeof(float[6]));
}
if (do_feather) {
shape_ele_dst->value[6] = shape_ele_src->value[6];
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 61b40dd3e60..dd4b8146154 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -1158,12 +1158,12 @@ void MESH_OT_bevel(wmOperatorType *ot)
PROFILE_HARD_MIN,
1.0f);
- prop = RNA_def_enum(ot->srna,
- "affect",
- prop_affect_items,
- BEVEL_AFFECT_EDGES,
- "Affect",
- "Affect Edges or Vertices");
+ RNA_def_enum(ot->srna,
+ "affect",
+ prop_affect_items,
+ BEVEL_AFFECT_EDGES,
+ "Affect",
+ "Affect Edges or Vertices");
RNA_def_boolean(ot->srna,
"clamp_overlap",
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c
index 9f1d499bb6a..6dde45a4f5f 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin.c
@@ -57,7 +57,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
float cent[3], axis[3];
- float d[3] = {0.0f, 0.0f, 0.0f};
+ const float d[3] = {0.0f, 0.0f, 0.0f};
RNA_float_get_array(op->ptr, "center", cent);
RNA_float_get_array(op->ptr, "axis", axis);
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 1f411617c68..6f4f75e802a 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -2632,7 +2632,7 @@ static void knifetool_update_mval(KnifeTool_OpData *kcd, const float mval[2])
static void knifetool_update_mval_i(KnifeTool_OpData *kcd, const int mval_i[2])
{
- float mval[2] = {UNPACK2(mval_i)};
+ const float mval[2] = {UNPACK2(mval_i)};
knifetool_update_mval(kcd, mval);
}
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c
index ed22d381a02..ef78d31a6bb 100644
--- a/source/blender/editors/mesh/editmesh_knife_project.c
+++ b/source/blender/editors/mesh/editmesh_knife_project.c
@@ -164,7 +164,7 @@ void MESH_OT_knife_project(wmOperatorType *ot)
/* description */
ot->name = "Knife Project";
ot->idname = "MESH_OT_knife_project";
- ot->description = "Use other objects outlines & boundaries to project knife cuts";
+ ot->description = "Use other objects outlines and boundaries to project knife cuts";
/* callbacks */
ot->exec = knifeproject_exec;
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 2f453369d92..b57e486634f 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -174,8 +174,10 @@ static void ringsel_finish(bContext *C, wmOperator *op)
if (lcd->do_cut) {
const bool is_macro = (op->opm != NULL);
/* a single edge (rare, but better support) */
- const bool is_single = (BM_edge_is_wire(lcd->eed));
- const int seltype = is_single ? SUBDIV_SELECT_INNER : SUBDIV_SELECT_LOOPCUT;
+ const bool is_edge_wire = BM_edge_is_wire(lcd->eed);
+ const bool is_single = is_edge_wire || !BM_edge_is_any_face_len_test(lcd->eed, 4);
+ const int seltype = is_edge_wire ? SUBDIV_SELECT_INNER :
+ is_single ? SUBDIV_SELECT_NONE : SUBDIV_SELECT_LOOPCUT;
/* Enable gridfill, so that intersecting loopcut works as one would expect.
* Note though that it will break edgeslide in this specific case.
diff --git a/source/blender/editors/mesh/editmesh_preselect_edgering.c b/source/blender/editors/mesh/editmesh_preselect_edgering.c
index 50af79fc5e1..d9bd63ef35f 100644
--- a/source/blender/editors/mesh/editmesh_preselect_edgering.c
+++ b/source/blender/editors/mesh/editmesh_preselect_edgering.c
@@ -343,12 +343,12 @@ void EDBM_preselect_edgering_update_from_edge(struct EditMesh_PreSelEdgeRing *ps
BM_mesh_elem_index_ensure(bm, BM_VERT);
}
- if (BM_edge_is_wire(eed_start)) {
- view3d_preselect_mesh_edgering_update_verts_from_edge(
+ if (BM_edge_is_any_face_len_test(eed_start, 4)) {
+ view3d_preselect_mesh_edgering_update_edges_from_edge(
psel, bm, eed_start, previewlines, coords);
}
else {
- view3d_preselect_mesh_edgering_update_edges_from_edge(
+ view3d_preselect_mesh_edgering_update_verts_from_edge(
psel, bm, eed_start, previewlines, coords);
}
}
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 89a90dcf12d..62c646a81e4 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -343,8 +343,11 @@ static BMVert *edbm_ripsel_edloop_pair_start_vert(BMEdge *e)
return (edbm_ripsel_edge_uid_step(e, &v_test)) ? e->v1 : e->v2;
}
-static void edbm_ripsel_deselect_helper(
- BMesh *bm, EdgeLoopPair *eloop_pairs, ARegion *region, float projectMat[4][4], float fmval[2])
+static void edbm_ripsel_deselect_helper(BMesh *bm,
+ EdgeLoopPair *eloop_pairs,
+ ARegion *region,
+ float projectMat[4][4],
+ const float fmval[2])
{
EdgeLoopPair *lp;
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index d699d761709..1e4144db47e 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -2035,19 +2035,26 @@ static bool flip_custom_normals(BMesh *bm, BMLoopNorEditDataArray *lnors_ed_arr)
}
BMFace *f;
- BMLoop *l;
- BMIter iter_f, iter_l;
+ BMLoop *l, *l_start;
+ BMIter iter_f;
BM_ITER_MESH (f, &iter_f, bm, BM_FACES_OF_MESH) {
+ /* Flip all the custom loop normals on the selected faces. */
if (!BM_elem_flag_test(f, BM_ELEM_SELECT)) {
continue;
}
- /* Flip all the custom loop normals on the selected faces. */
- BM_ITER_ELEM (l, &iter_l, f, BM_LOOPS_OF_FACE) {
+ /* Because the winding has changed, we need to go the reverse way around the face to get the
+ * correct placement of the normals. However we need to derive the old loop index to get the
+ * correct data. Note that the first loop index is the same though. So the loop starts and ends
+ * in the same place as before the flip.
+ */
+ l_start = l = BM_FACE_FIRST_LOOP(f);
+ int old_index = BM_elem_index_get(l);
+ do {
int loop_index = BM_elem_index_get(l);
- BMLoopNorEditData *lnor_ed = lnors_ed_arr->lidx_to_lnor_editdata[loop_index];
+ BMLoopNorEditData *lnor_ed = lnors_ed_arr->lidx_to_lnor_editdata[old_index];
BMLoopNorEditData *lnor_ed_new = lnors_ed_arr_new_full->lidx_to_lnor_editdata[loop_index];
BLI_assert(lnor_ed != NULL && lnor_ed_new != NULL);
@@ -2055,7 +2062,10 @@ static bool flip_custom_normals(BMesh *bm, BMLoopNorEditDataArray *lnors_ed_arr)
BKE_lnor_space_custom_normal_to_data(
bm->lnor_spacearr->lspacearr[loop_index], lnor_ed->nloc, lnor_ed_new->clnors_data);
- }
+
+ old_index++;
+ l = l->prev;
+ } while (l != l_start);
}
BM_loop_normal_editdata_array_free(lnors_ed_arr_new_full);
return true;
@@ -4024,7 +4034,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
/* the floating point coordinates of verts in screen space will be
* stored in a hash table according to the vertices pointer */
- screen_vert_coords = sco = MEM_mallocN(bm->totvert * sizeof(float) * 2, __func__);
+ screen_vert_coords = sco = MEM_mallocN(sizeof(float[2]) * bm->totvert, __func__);
BM_ITER_MESH_INDEX (bv, &iter, bm, BM_VERTS_OF_MESH, i) {
if (ED_view3d_project_float_object(region, bv->co, *sco, V3D_PROJ_TEST_CLIP_NEAR) !=
@@ -7209,7 +7219,7 @@ void MESH_OT_wireframe(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name = "Wire Frame";
+ ot->name = "Wireframe";
ot->idname = "MESH_OT_wireframe";
ot->description = "Create a solid wire-frame from faces";
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index cec425d687d..bb5da8f3a9c 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -23,8 +23,7 @@
/* Internal for editmesh_xxxx.c functions */
-#ifndef __MESH_INTERN_H__
-#define __MESH_INTERN_H__
+#pragma once
struct BMEditMesh;
struct BMElem;
@@ -276,5 +275,3 @@ void MESH_OT_customdata_skin_add(struct wmOperatorType *ot);
void MESH_OT_customdata_skin_clear(struct wmOperatorType *ot);
void MESH_OT_customdata_custom_splitnormals_add(struct wmOperatorType *ot);
void MESH_OT_customdata_custom_splitnormals_clear(struct wmOperatorType *ot);
-
-#endif /* __MESH_INTERN_H__ */
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 4d84db9b35b..5278da67777 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -452,7 +452,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
if (kb->data) {
MEM_freeN(kb->data);
}
- kb->data = MEM_callocN(sizeof(float) * 3 * totvert, "join_shapekey");
+ kb->data = MEM_callocN(sizeof(float[3]) * totvert, "join_shapekey");
kb->totelem = totvert;
}
}
@@ -550,7 +550,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
BKE_keyblock_copy_settings(kbn, kb);
/* adjust settings to fit (allocate a new data-array) */
- kbn->data = MEM_callocN(sizeof(float) * 3 * totvert, "joined_shapekey");
+ kbn->data = MEM_callocN(sizeof(float[3]) * totvert, "joined_shapekey");
kbn->totelem = totvert;
}
@@ -1063,7 +1063,7 @@ static float *editmesh_get_mirror_uv(
BMFace *efa;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- uv_poly_center(efa, cent, cd_loop_uv_offset);
+ BM_face_uv_calc_center_median(efa, cd_loop_uv_offset, cent);
if ((fabsf(cent[0] - cent_vec[0]) < 0.001f) && (fabsf(cent[1] - cent_vec[1]) < 0.001f)) {
BMIter liter;
@@ -1154,7 +1154,7 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
int a;
mirrorverts = MEM_callocN(sizeof(int) * totvert, "MirrorVerts");
- mirrorfaces = MEM_callocN(sizeof(int) * 2 * totface, "MirrorFaces");
+ mirrorfaces = MEM_callocN(sizeof(int[2]) * totface, "MirrorFaces");
mvert = me_eval ? me_eval->mvert : me->mvert;
mface = me_eval ? me_eval->mface : me->mface;
diff --git a/source/blender/editors/metaball/mball_intern.h b/source/blender/editors/metaball/mball_intern.h
index dec94f97b8a..2b90667f612 100644
--- a/source/blender/editors/metaball/mball_intern.h
+++ b/source/blender/editors/metaball/mball_intern.h
@@ -21,8 +21,7 @@
* \ingroup edmeta
*/
-#ifndef __MBALL_INTERN_H__
-#define __MBALL_INTERN_H__
+#pragma once
#include "DNA_object_types.h"
@@ -37,5 +36,3 @@ void MBALL_OT_duplicate_metaelems(struct wmOperatorType *ot);
void MBALL_OT_select_all(struct wmOperatorType *ot);
void MBALL_OT_select_similar(struct wmOperatorType *ot);
void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot);
-
-#endif
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index f92dafcc7f9..81b8cd70353 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -205,7 +205,7 @@ void ED_object_rotation_from_quat(float rot[3], const float viewquat[4], const c
switch (align_axis) {
case 'X': {
/* Same as 'rv3d->viewinv[1]' */
- float axis_y[4] = {0.0f, 1.0f, 0.0f};
+ const float axis_y[4] = {0.0f, 1.0f, 0.0f};
float quat_y[4], quat[4];
axis_angle_to_quat(quat_y, axis_y, M_PI_2);
mul_qt_qtqt(quat, viewquat, quat_y);
@@ -255,13 +255,13 @@ void ED_object_base_init_transform_on_add(Object *object, const float loc[3], co
/* Uses context to figure out transform for primitive.
* Returns standard diameter. */
float ED_object_new_primitive_matrix(
- bContext *C, Object *obedit, const float loc[3], const float rot[3], float primmat[4][4])
+ bContext *C, Object *obedit, const float loc[3], const float rot[3], float r_primmat[4][4])
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3];
- unit_m4(primmat);
+ unit_m4(r_primmat);
eul_to_mat3(rmat, rot);
invert_m3(rmat);
@@ -270,13 +270,13 @@ float ED_object_new_primitive_matrix(
copy_m3_m4(mat, obedit->obmat);
mul_m3_m3m3(cmat, rmat, mat);
invert_m3_m3(imat, cmat);
- copy_m4_m3(primmat, imat);
+ copy_m4_m3(r_primmat, imat);
/* center */
- copy_v3_v3(primmat[3], loc);
- sub_v3_v3v3(primmat[3], primmat[3], obedit->obmat[3]);
+ copy_v3_v3(r_primmat[3], loc);
+ sub_v3_v3v3(r_primmat[3], r_primmat[3], obedit->obmat[3]);
invert_m3_m3(imat, mat);
- mul_m3_v3(imat, primmat[3]);
+ mul_m3_v3(imat, r_primmat[3]);
{
const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) :
@@ -692,6 +692,46 @@ void OBJECT_OT_lightprobe_add(wmOperatorType *ot)
* \{ */
/* for object add operator */
+
+static const char *get_effector_defname(ePFieldType type)
+{
+ switch (type) {
+ case PFIELD_FORCE:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Force");
+ case PFIELD_VORTEX:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Vortex");
+ case PFIELD_MAGNET:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Magnet");
+ case PFIELD_WIND:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Wind");
+ case PFIELD_GUIDE:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "CurveGuide");
+ case PFIELD_TEXTURE:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "TextureField");
+ case PFIELD_HARMONIC:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Harmonic");
+ case PFIELD_CHARGE:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Charge");
+ case PFIELD_LENNARDJ:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Lennard-Jones");
+ case PFIELD_BOID:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Boid");
+ case PFIELD_TURBULENCE:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Turbulence");
+ case PFIELD_DRAG:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Drag");
+ case PFIELD_FLUIDFLOW:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "FluidField");
+ case PFIELD_NULL:
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Field");
+ case NUM_PFIELD_TYPES:
+ break;
+ }
+
+ BLI_assert(false);
+ return CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Field");
+}
+
static int effector_add_exec(bContext *C, wmOperator *op)
{
Object *ob;
@@ -712,8 +752,8 @@ static int effector_add_exec(bContext *C, wmOperator *op)
if (type == PFIELD_GUIDE) {
Curve *cu;
- const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "CurveGuide");
- ob = ED_object_add_type(C, OB_CURVE, name, loc, rot, false, local_view_bits);
+ ob = ED_object_add_type(
+ C, OB_CURVE, get_effector_defname(type), loc, rot, false, local_view_bits);
cu = ob->data;
cu->flag |= CU_PATH | CU_3D;
@@ -726,8 +766,8 @@ static int effector_add_exec(bContext *C, wmOperator *op)
}
}
else {
- const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Field");
- ob = ED_object_add_type(C, OB_EMPTY, name, loc, rot, false, local_view_bits);
+ ob = ED_object_add_type(
+ C, OB_EMPTY, get_effector_defname(type), loc, rot, false, local_view_bits);
BKE_object_obdata_size_init(ob, dia);
if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX)) {
ob->empty_drawtype = OB_SINGLE_ARROW;
@@ -1237,7 +1277,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op)
break;
}
- /* if this is a new object, initialise default stuff (colors, etc.) */
+ /* If this is a new object, initialize default stuff (colors, etc.) */
if (newob) {
/* set default viewport color to black */
copy_v3_fl(ob->color, 0.0f);
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index baa24ab2f4e..ae1aae27b7f 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -60,8 +60,6 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-#include "GPU_draw.h" /* GPU_free_image */
-
#include "WM_api.h"
#include "WM_types.h"
@@ -530,7 +528,7 @@ static void multiresbake_freejob(void *bkv)
/* delete here, since this delete will be called from main thread */
for (link = data->images.first; link; link = link->next) {
Image *ima = (Image *)link->data;
- GPU_free_image(ima);
+ BKE_image_free_gputextures(ima);
}
MEM_freeN(data->ob_image.array);
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index c4cb21a67f3..cb92fab3cb0 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -68,8 +68,6 @@
#include "ED_screen.h"
#include "ED_uvedit.h"
-#include "GPU_draw.h"
-
#include "object_intern.h"
/* prototypes */
@@ -308,7 +306,7 @@ static void refresh_images(BakeImages *bake_images)
Image *ima = bake_images->data[i].image;
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
if (tile->ok == IMA_OK_LOADED) {
- GPU_free_image(ima);
+ BKE_image_free_gputextures(ima);
DEG_id_tag_update(&ima->id, 0);
break;
}
@@ -675,7 +673,7 @@ static void build_image_lookup(Main *bmain, Object *ob, BakeImages *bake_images)
/*
* returns the total number of pixels
*/
-static size_t initialize_internal_images(BakeImages *bake_images, ReportList *reports)
+static size_t init_internal_images(BakeImages *bake_images, ReportList *reports)
{
int i;
size_t tot_size = 0;
@@ -830,7 +828,7 @@ static int bake(Render *re,
build_image_lookup(bmain, ob_low, &bake_images);
if (is_save_internal) {
- num_pixels = initialize_internal_images(&bake_images, reports);
+ num_pixels = init_internal_images(&bake_images, reports);
if (num_pixels == 0) {
goto cleanup;
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 9dc204b9083..bc3c263e0a3 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -21,8 +21,7 @@
* \ingroup edobj
*/
-#ifndef __OBJECT_INTERN_H__
-#define __OBJECT_INTERN_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -311,5 +310,3 @@ void OBJECT_OT_datalayout_transfer(struct wmOperatorType *ot);
#ifdef __cplusplus
}
#endif
-
-#endif /* __OBJECT_INTERN_H__ */
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 8a736c380bf..8d6d2e3e31d 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -345,7 +345,8 @@ static bool object_modifier_remove(
object_remove_particle_system(bmain, scene, ob);
return true;
}
- else if (md->type == eModifierType_Softbody) {
+
+ if (md->type == eModifierType_Softbody) {
if (ob->soft) {
sbFree(ob);
ob->softflag = 0; /* TODO(Sybren): this should probably be moved into sbFree() */
@@ -888,12 +889,11 @@ int ED_object_modifier_copy(
BLI_insertlinkafter(&ob->modifiers, md, nmd);
return true;
}
- else {
- nmd = BKE_modifier_new(md->type);
- BKE_modifier_copydata(md, nmd);
- BLI_insertlinkafter(&ob->modifiers, md, nmd);
- BKE_modifier_unique_name(&ob->modifiers, nmd);
- }
+
+ nmd = BKE_modifier_new(md->type);
+ BKE_modifier_copydata(md, nmd);
+ BLI_insertlinkafter(&ob->modifiers, md, nmd);
+ BKE_modifier_unique_name(&ob->modifiers, nmd);
return 1;
}
@@ -1347,7 +1347,7 @@ static bool modifier_apply_poll_ex(bContext *C, bool allow_shared)
Object *ob = (ptr.owner_id != NULL) ? (Object *)ptr.owner_id : ED_object_active_context(C);
ModifierData *md = ptr.data; /* May be NULL. */
- if (ID_IS_OVERRIDE_LIBRARY(ob) || ID_IS_OVERRIDE_LIBRARY(ob->data)) {
+ if (ID_IS_OVERRIDE_LIBRARY(ob) || ((ob->data != NULL) && ID_IS_OVERRIDE_LIBRARY(ob->data))) {
CTX_wm_operator_poll_msg_set(C, "Modifiers cannot be applied on override data");
return false;
}
@@ -1458,9 +1458,7 @@ static int modifier_apply_as_shapekey_invoke(bContext *C, wmOperator *op, const
if (edit_modifier_invoke_properties(C, op, event, &retval)) {
return modifier_apply_as_shapekey_exec(C, op);
}
- else {
- return retval;
- }
+ return retval;
}
static char *modifier_apply_as_shapekey_get_description(struct bContext *UNUSED(C),
@@ -2813,7 +2811,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
/* make a copy of ocean to use for baking - threadsafety */
ocean = BKE_ocean_add();
- BKE_ocean_init_from_modifier(ocean, omd);
+ BKE_ocean_init_from_modifier(ocean, omd, omd->resolution);
#if 0
BKE_ocean_bake(ocean, och);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 9520b03f3a6..732d2f6ad52 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1175,7 +1175,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
else {
/* clear inverse matrix and also the object location */
unit_m4(ob->parentinv);
- memset(ob->loc, 0, 3 * sizeof(float));
+ memset(ob->loc, 0, sizeof(float[3]));
/* set recalc flags */
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
@@ -2283,7 +2283,8 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve
/* This invoke just calls another instance of this operator... */
return OPERATOR_INTERFACE;
}
- else if (ID_IS_LINKED(obact)) {
+
+ if (ID_IS_LINKED(obact)) {
/* Show menu with list of directly linked collections containing the active object. */
WM_enum_search_invoke(C, op, event);
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c
index 8981851394d..8d8f01dd61a 100644
--- a/source/blender/editors/object/object_remesh.c
+++ b/source/blender/editors/object/object_remesh.c
@@ -72,7 +72,6 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
-#include "GPU_draw.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
@@ -407,7 +406,7 @@ static int voxel_size_edit_modal(bContext *C, wmOperator *op, const wmEvent *eve
return OPERATOR_FINISHED;
}
- float mval[2] = {event->mval[0], event->mval[1]};
+ const float mval[2] = {event->mval[0], event->mval[1]};
float d = cd->init_mval[0] - mval[0];
@@ -471,7 +470,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev
BoundBox *bb = BKE_mesh_boundbox_get(cd->active_object);
/* Indices of the Bounding Box faces. */
- int BB_faces[6][4] = {
+ const int BB_faces[6][4] = {
{3, 0, 4, 7},
{1, 2, 6, 5},
{3, 2, 1, 0},
@@ -526,7 +525,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev
float d_a[3], d_b[3];
float d_a_proj[2], d_b_proj[2];
float preview_plane_proj[4][3];
- float y_axis_proj[2] = {0.0f, 1.0f};
+ const float y_axis_proj[2] = {0.0f, 1.0f};
mid_v3_v3v3(text_pos, cd->preview_plane[0], cd->preview_plane[2]);
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index f2d7ad3ac11..52b572fb0dd 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -1907,7 +1907,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
for (int x = -ofs; x <= ofs; x += ofs / 2) {
for (int y = -ofs; y <= ofs; y += ofs / 2) {
if (x != 0 && y != 0) {
- int mval_ofs[2] = {event->mval[0] + x, event->mval[1] + y};
+ const int mval_ofs[2] = {event->mval[0] + x, event->mval[1] + y};
float n[3];
if (ED_view3d_depth_read_cached_normal(&xfd->vc, mval_ofs, n)) {
add_v3_v3(normal, n);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 749c6cd640e..488bb7121a2 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -1386,7 +1386,7 @@ void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), Part
totface = mesh->totface;
/*totvert=dm->getNumVerts(dm);*/ /*UNUSED*/
- edit->emitter_cosnos = MEM_callocN(totface * 6 * sizeof(float), "emitter cosnos");
+ edit->emitter_cosnos = MEM_callocN(sizeof(float[6]) * totface, "emitter cosnos");
edit->emitter_field = BLI_kdtree_3d_new(totface);
@@ -4346,7 +4346,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
}
pa->size = 1.0f;
- initialize_particle(&sim, pa);
+ init_particle(&sim, pa);
reset_particle(&sim, pa, 0.0, 1.0);
point->flag |= PEP_EDIT_RECALC;
if (pe_x_mirror(ob)) {
diff --git a/source/blender/editors/physics/particle_edit_utildefines.h b/source/blender/editors/physics/particle_edit_utildefines.h
index dc858687341..289ca193f17 100644
--- a/source/blender/editors/physics/particle_edit_utildefines.h
+++ b/source/blender/editors/physics/particle_edit_utildefines.h
@@ -21,8 +21,7 @@
* \ingroup edphys
*/
-#ifndef __PARTICLE_EDIT_UTILDEFINES_H__
-#define __PARTICLE_EDIT_UTILDEFINES_H__
+#pragma once
#define KEY_K \
PTCacheEditKey *key; \
@@ -58,5 +57,3 @@
if (key->flag & PEK_TAG)
#define KEY_WCO ((key->flag & PEK_USE_WCO) ? key->world_co : key->co)
-
-#endif /* __PARTICLE_EDIT_UTILDEFINES_H__ */
diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h
index 87c3a709d47..4dc3ded9bd7 100644
--- a/source/blender/editors/physics/physics_intern.h
+++ b/source/blender/editors/physics/physics_intern.h
@@ -21,8 +21,7 @@
* \ingroup edphys
*/
-#ifndef __PHYSICS_INTERN_H__
-#define __PHYSICS_INTERN_H__
+#pragma once
struct Depsgraph;
struct Object;
@@ -152,5 +151,3 @@ void RIGIDBODY_OT_constraint_remove(struct wmOperatorType *ot);
void RIGIDBODY_OT_world_add(struct wmOperatorType *ot);
void RIGIDBODY_OT_world_remove(struct wmOperatorType *ot);
void RIGIDBODY_OT_world_export(struct wmOperatorType *ot);
-
-#endif /* __PHYSICS_INTERN_H__ */
diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h
index 88b913b84ca..d3a06f0fc2c 100644
--- a/source/blender/editors/render/render_intern.h
+++ b/source/blender/editors/render/render_intern.h
@@ -21,8 +21,7 @@
* \ingroup edrend
*/
-#ifndef __RENDER_INTERN_H__
-#define __RENDER_INTERN_H__
+#pragma once
struct ScrArea;
struct bContext;
@@ -90,5 +89,3 @@ void RENDER_OT_view_cancel(struct wmOperatorType *ot);
/* render_opengl.c */
void RENDER_OT_opengl(struct wmOperatorType *ot);
-
-#endif /* __RENDER_INTERN_H__ */
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 3d3936523f9..f75dd428968 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -349,7 +349,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
ED_annotation_draw_ex(scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ);
G.f &= ~G_FLAG_RENDER_VIEWPORT;
- gp_rect = MEM_mallocN(sizex * sizey * sizeof(uchar) * 4, "offscreen rect");
+ gp_rect = MEM_mallocN(sizeof(uchar[4]) * sizex * sizey, "offscreen rect");
GPU_offscreen_read_pixels(oglrender->ofs, GPU_DATA_UNSIGNED_BYTE, gp_rect);
for (i = 0; i < sizex * sizey * 4; i += 4) {
@@ -962,7 +962,7 @@ static void screen_opengl_render_cancel(bContext *C, wmOperator *op)
}
/* share between invoke and exec */
-static bool screen_opengl_render_anim_initialize(bContext *C, wmOperator *op)
+static bool screen_opengl_render_anim_init(bContext *C, wmOperator *op)
{
/* initialize animation */
OGLRender *oglrender;
@@ -1256,7 +1256,7 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, const wmEven
}
if (anim) {
- if (!screen_opengl_render_anim_initialize(C, op)) {
+ if (!screen_opengl_render_anim_init(C, op)) {
return OPERATOR_CANCELLED;
}
}
@@ -1292,7 +1292,7 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op)
bool ret = true;
- if (!screen_opengl_render_anim_initialize(C, op)) {
+ if (!screen_opengl_render_anim_init(C, op)) {
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 85fc6927063..9d0e4efa0b3 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -764,7 +764,7 @@ static void shader_preview_texture(ShaderPreview *sp, Tex *tex, Scene *sce, Rend
/* Create buffer in empty RenderView created in the init step. */
RenderResult *rr = RE_AcquireResultWrite(re);
RenderView *rv = (RenderView *)rr->views.first;
- rv->rectf = MEM_callocN(sizeof(float) * 4 * width * height, "texture render result");
+ rv->rectf = MEM_callocN(sizeof(float[4]) * width * height, "texture render result");
RE_ReleaseResult(re);
/* Get texture image pool (if any) */
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 536252f5003..711f89b9fda 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -945,6 +945,11 @@ static int light_cache_bake_modal(bContext *C, wmOperator *op, const wmEvent *ev
/* no running blender, remove handler and pass through */
if (0 == WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) {
+ LightCache *lcache = scene->eevee.light_cache_data;
+ if (lcache && (lcache->flag & LIGHTCACHE_INVALID)) {
+ BKE_report(op->reports, RPT_ERROR, "Lightcache cannot allocate resources");
+ return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
}
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 95f5bdbc394..63729b40571 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -291,7 +291,7 @@ static void region_draw_azone_tab_arrow(ScrArea *area, ARegion *region, AZone *a
/* Workaround for different color spaces between normal areas and the ones using GPUViewports. */
float alpha = WM_region_use_viewport(area, region) ? 0.6f : 0.4f;
- float color[4] = {0.05f, 0.05f, 0.05f, alpha};
+ const float color[4] = {0.05f, 0.05f, 0.05f, alpha};
UI_draw_roundbox_aa(
true, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, color);
@@ -813,7 +813,7 @@ void ED_workspace_status_text(bContext *C, const char *str)
/* ************************************************************ */
-static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea *area)
+static void area_azone_init(wmWindow *win, const bScreen *screen, ScrArea *area)
{
AZone *az;
@@ -883,7 +883,7 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea
}
}
-static void fullscreen_azone_initialize(ScrArea *area, ARegion *region)
+static void fullscreen_azone_init(ScrArea *area, ARegion *region)
{
AZone *az;
@@ -1007,10 +1007,10 @@ static bool region_azone_edge_poll(const ARegion *region, const bool is_fullscre
return true;
}
-static void region_azone_edge_initialize(ScrArea *area,
- ARegion *region,
- AZEdge edge,
- const bool is_fullscreen)
+static void region_azone_edge_init(ScrArea *area,
+ ARegion *region,
+ AZEdge edge,
+ const bool is_fullscreen)
{
AZone *az = NULL;
const bool is_hidden = (region->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL));
@@ -1033,9 +1033,9 @@ static void region_azone_edge_initialize(ScrArea *area,
}
}
-static void region_azone_scrollbar_initialize(ScrArea *area,
- ARegion *region,
- AZScrollDirection direction)
+static void region_azone_scrollbar_init(ScrArea *area,
+ ARegion *region,
+ AZScrollDirection direction)
{
rcti scroller_vert = (direction == AZ_SCROLL_VERT) ? region->v2d.vert : region->v2d.hor;
AZone *az = MEM_callocN(sizeof(*az), __func__);
@@ -1061,16 +1061,16 @@ static void region_azone_scrollbar_initialize(ScrArea *area,
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
-static void region_azones_scrollbars_initialize(ScrArea *area, ARegion *region)
+static void region_azones_scrollbars_init(ScrArea *area, ARegion *region)
{
const View2D *v2d = &region->v2d;
if ((v2d->scroll & V2D_SCROLL_VERTICAL) && ((v2d->scroll & V2D_SCROLL_VERTICAL_HANDLES) == 0)) {
- region_azone_scrollbar_initialize(area, region, AZ_SCROLL_VERT);
+ region_azone_scrollbar_init(area, region, AZ_SCROLL_VERT);
}
if ((v2d->scroll & V2D_SCROLL_HORIZONTAL) &&
((v2d->scroll & V2D_SCROLL_HORIZONTAL_HANDLES) == 0)) {
- region_azone_scrollbar_initialize(area, region, AZ_SCROLL_HOR);
+ region_azone_scrollbar_init(area, region, AZ_SCROLL_HOR);
}
}
@@ -1083,16 +1083,16 @@ static void region_azones_add_edge(ScrArea *area,
/* edge code (t b l r) is along which area edge azone will be drawn */
if (alignment == RGN_ALIGN_TOP) {
- region_azone_edge_initialize(area, region, AE_BOTTOM_TO_TOPLEFT, is_fullscreen);
+ region_azone_edge_init(area, region, AE_BOTTOM_TO_TOPLEFT, is_fullscreen);
}
else if (alignment == RGN_ALIGN_BOTTOM) {
- region_azone_edge_initialize(area, region, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen);
+ region_azone_edge_init(area, region, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen);
}
else if (alignment == RGN_ALIGN_RIGHT) {
- region_azone_edge_initialize(area, region, AE_LEFT_TO_TOPRIGHT, is_fullscreen);
+ region_azone_edge_init(area, region, AE_LEFT_TO_TOPRIGHT, is_fullscreen);
}
else if (alignment == RGN_ALIGN_LEFT) {
- region_azone_edge_initialize(area, region, AE_RIGHT_TO_TOPLEFT, is_fullscreen);
+ region_azone_edge_init(area, region, AE_RIGHT_TO_TOPLEFT, is_fullscreen);
}
}
@@ -1116,10 +1116,10 @@ static void region_azones_add(const bScreen *screen, ScrArea *area, ARegion *reg
}
if (is_fullscreen) {
- fullscreen_azone_initialize(area, region);
+ fullscreen_azone_init(area, region);
}
- region_azones_scrollbars_initialize(area, region);
+ region_azones_scrollbars_init(area, region);
}
/* dir is direction to check, not the splitting edge direction! */
@@ -1828,7 +1828,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar
region_rect_recursive(area, area->regionbase.first, &rect, &overlap_rect, 0);
/* Dynamically sized regions may have changed region sizes, so we have to force azone update. */
- area_azone_initialize(win, screen, area);
+ area_azone_init(win, screen, area);
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
region_subwindow(region);
@@ -1847,7 +1847,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar
}
/* called in screen_refresh, or screens_init, also area size changes */
-void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *area)
+void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area)
{
WorkSpace *workspace = WM_window_get_active_workspace(win);
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
@@ -1890,7 +1890,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *area)
}
/* clear all azones, add the area triangle widgets */
- area_azone_initialize(win, screen, area);
+ area_azone_init(win, screen, area);
/* region windows, default and own handlers */
for (region = area->regionbase.first; region; region = region->next) {
@@ -1944,7 +1944,7 @@ void ED_region_update_rect(ARegion *region)
}
/* externally called for floating regions like menus */
-void ED_region_floating_initialize(ARegion *region)
+void ED_region_floating_init(ARegion *region)
{
BLI_assert(region->alignment == RGN_ALIGN_FLOAT);
@@ -1980,7 +1980,7 @@ void ED_region_visibility_change_update(bContext *C, ScrArea *area, ARegion *reg
WM_event_remove_handlers(C, &region->handlers);
}
- ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), area);
+ ED_area_init(CTX_wm_manager(C), CTX_wm_window(C), area);
ED_area_tag_redraw(area);
}
@@ -2066,8 +2066,8 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2)
ED_area_data_copy(tmp, sa1, false);
ED_area_data_copy(sa1, sa2, true);
ED_area_data_copy(sa2, tmp, true);
- ED_area_initialize(CTX_wm_manager(C), win, sa1);
- ED_area_initialize(CTX_wm_manager(C), win, sa2);
+ ED_area_init(CTX_wm_manager(C), win, sa1);
+ ED_area_init(CTX_wm_manager(C), win, sa2);
BKE_screen_area_free(tmp);
MEM_freeN(tmp);
@@ -2126,7 +2126,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
area->spacetype = type;
area->type = st;
- /* If st->new may be called, don't use context until then. The
+ /* If st->create may be called, don't use context until then. The
* area->type->context() callback has changed but data may be invalid
* (e.g. with properties editor) until space-data is properly created */
@@ -2166,7 +2166,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
if (st) {
/* Don't get scene from context here which may depend on space-data. */
Scene *scene = WM_window_get_active_scene(win);
- sl = st->new (area, scene);
+ sl = st->create(area, scene);
BLI_addhead(&area->spacedata, sl);
/* swap regions */
@@ -2204,7 +2204,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
}
}
- ED_area_initialize(CTX_wm_manager(C), win, area);
+ ED_area_init(CTX_wm_manager(C), win, area);
/* tell WM to refresh, cursor types etc */
WM_event_add_mousemove(win);
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 07a122c7094..bcbb735d93d 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -106,13 +106,13 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
float clip_max_y,
float xzoom,
float yzoom,
- float color[4])
+ const float color[4])
{
int subpart_x, subpart_y, tex_w = 256, tex_h = 256;
int seamless, offset_x, offset_y, nsubparts_x, nsubparts_y;
int components;
const bool use_clipping = ((clip_min_x < clip_max_x) && (clip_min_y < clip_max_y));
- float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+ const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
if (ELEM(gpu_format, GPU_RGBA8, GPU_RGBA16F)) {
components = 4;
@@ -203,21 +203,21 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
* at edges of full image. */
if (subpart_w < tex_w) {
void *data = DATA(src_y, src_x + subpart_w - 1);
- int offset[2] = {subpart_w, 0};
- int extent[2] = {1, subpart_h};
+ const int offset[2] = {subpart_w, 0};
+ const int extent[2] = {1, subpart_h};
GPU_texture_update_sub(tex, gpu_data, data, UNPACK2(offset), 0, UNPACK2(extent), 0);
}
if (subpart_h < tex_h) {
void *data = DATA(src_y + subpart_h - 1, src_x);
- int offset[2] = {0, subpart_h};
- int extent[2] = {subpart_w, 1};
+ const int offset[2] = {0, subpart_h};
+ const int extent[2] = {subpart_w, 1};
GPU_texture_update_sub(tex, gpu_data, data, UNPACK2(offset), 0, UNPACK2(extent), 0);
}
if (subpart_w < tex_w && subpart_h < tex_h) {
void *data = DATA(src_y + subpart_h - 1, src_x + subpart_w - 1);
- int offset[2] = {subpart_w, subpart_h};
- int extent[2] = {1, 1};
+ const int offset[2] = {subpart_w, subpart_h};
+ const int extent[2] = {1, 1};
GPU_texture_update_sub(tex, gpu_data, data, UNPACK2(offset), 0, UNPACK2(extent), 0);
}
#undef DATA
@@ -272,7 +272,7 @@ void immDrawPixelsTexScaled(IMMDrawPixelsTexState *state,
float scaleY,
float xzoom,
float yzoom,
- float color[4])
+ const float color[4])
{
immDrawPixelsTexScaled_clipping(state,
x,
@@ -303,7 +303,7 @@ void immDrawPixelsTex(IMMDrawPixelsTexState *state,
void *rect,
float xzoom,
float yzoom,
- float color[4])
+ const float color[4])
{
immDrawPixelsTexScaled_clipping(state,
x,
@@ -338,7 +338,7 @@ void immDrawPixelsTex_clipping(IMMDrawPixelsTexState *state,
float clip_max_y,
float xzoom,
float yzoom,
- float color[4])
+ const float color[4])
{
immDrawPixelsTexScaled_clipping(state,
x,
@@ -566,7 +566,7 @@ int ED_draw_imbuf_method(ImBuf *ibuf)
if (U.image_draw_method == IMAGE_DRAW_METHOD_AUTO) {
/* Use faster GLSL when CPU to GPU transfer is unlikely to be a bottleneck,
* otherwise do color management on CPU side. */
- const size_t threshold = 2048 * 2048 * 4 * sizeof(float);
+ const size_t threshold = sizeof(float[4]) * 2048 * 2048;
const size_t data_size = (ibuf->rect_float) ? sizeof(float) : sizeof(uchar);
const size_t size = ibuf->x * ibuf->y * ibuf->channels * data_size;
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 7983ac889ef..c17a34f97b9 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -475,7 +475,6 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
CTX_data_id_pointer_set(result, &obpose->id);
}
return 1;
- return -1; /* found but not available */
}
if (CTX_data_equals(member, "sequences")) {
Editing *ed = BKE_sequencer_editing_get(scene, false);
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index b6f210d7f13..06e800433b1 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -516,7 +516,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
ED_screen_areas_iter (win, screen, area) {
/* set spacetype and region callbacks, calls init() */
/* sets subwindows for regions, adds handlers */
- ED_area_initialize(wm, win, area);
+ ED_area_init(wm, win, area);
}
/* wake up animtimer */
@@ -536,7 +536,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
}
/* file read, set all screens, ... */
-void ED_screens_initialize(Main *bmain, wmWindowManager *wm)
+void ED_screens_init(Main *bmain, wmWindowManager *wm)
{
wmWindow *win;
@@ -897,7 +897,7 @@ static void screen_global_area_refresh(wmWindow *win,
else {
area = screen_area_create_with_geometry(&win->global_areas, rect, space_type);
SpaceType *stype = BKE_spacetype_from_id(space_type);
- SpaceLink *slink = stype->new (area, WM_window_get_active_scene(win));
+ SpaceLink *slink = stype->create(area, WM_window_get_active_scene(win));
area->regionbase = slink->regionbase;
@@ -985,39 +985,15 @@ void ED_screen_global_areas_refresh(wmWindow *win)
/* -------------------------------------------------------------------- */
/* Screen changing */
-static bScreen *screen_fullscreen_find_associated_normal_screen(const Main *bmain, bScreen *screen)
-{
- for (bScreen *screen_iter = bmain->screens.first; screen_iter;
- screen_iter = screen_iter->id.next) {
- if ((screen_iter != screen) && ELEM(screen_iter->state, SCREENMAXIMIZED, SCREENFULL)) {
- ScrArea *area = screen_iter->areabase.first;
- if (area && area->full == screen) {
- return screen_iter;
- }
- }
- }
-
- return screen;
-}
-
/**
* \return the screen to activate.
* \warning The returned screen may not always equal \a screen_new!
*/
-bScreen *screen_change_prepare(
+void screen_change_prepare(
bScreen *screen_old, bScreen *screen_new, Main *bmain, bContext *C, wmWindow *win)
{
- /* validate screen, it's called with notifier reference */
- if (BLI_findindex(&bmain->screens, screen_new) == -1) {
- return NULL;
- }
-
- screen_new = screen_fullscreen_find_associated_normal_screen(bmain, screen_new);
-
- /* check for valid winid */
- if (!(screen_new->winid == 0 || screen_new->winid == win->winid)) {
- return NULL;
- }
+ UNUSED_VARS_NDEBUG(bmain);
+ BLI_assert(BLI_findindex(&bmain->screens, screen_new) != -1);
if (screen_old != screen_new) {
wmTimer *wt = screen_old->animtimer;
@@ -1038,11 +1014,7 @@ bScreen *screen_change_prepare(
if (wt) {
screen_new->animtimer = wt;
}
-
- return screen_new;
}
-
- return NULL;
}
void screen_change_update(bContext *C, wmWindow *win, bScreen *screen)
@@ -1075,12 +1047,20 @@ bool ED_screen_change(bContext *C, bScreen *screen)
{
Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
+ WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
+ WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, screen);
bScreen *screen_old = CTX_wm_screen(C);
- bScreen *screen_new = screen_change_prepare(screen_old, screen, bmain, C, win);
- if (screen_new) {
- WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
- WM_window_set_active_screen(win, workspace, screen);
+ /* Get the actual layout/screen to be activated (guaranteed to be unused, even if that means
+ * having to duplicate an existing one). */
+ WorkSpaceLayout *layout_new = ED_workspace_screen_change_ensure_unused_layout(
+ bmain, workspace, layout, layout, win);
+ bScreen *screen_new = BKE_workspace_layout_screen_get(layout_new);
+
+ screen_change_prepare(screen_old, screen_new, bmain, C, win);
+
+ if (screen_old != screen_new) {
+ WM_window_set_active_screen(win, workspace, screen_new);
screen_change_update(C, win, screen_new);
return true;
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index 2d42313d528..a5b5e222ae9 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -21,8 +21,7 @@
* \ingroup edscr
*/
-#ifndef __SCREEN_INTERN_H__
-#define __SCREEN_INTERN_H__
+#pragma once
struct Main;
struct bContext;
@@ -50,11 +49,11 @@ bScreen *screen_add(struct Main *bmain, const char *name, const rcti *rect);
void screen_data_copy(bScreen *to, bScreen *from);
void screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new);
void screen_change_update(struct bContext *C, wmWindow *win, bScreen *screen);
-bScreen *screen_change_prepare(bScreen *screen_old,
- bScreen *screen_new,
- struct Main *bmain,
- struct bContext *C,
- wmWindow *win);
+void screen_change_prepare(bScreen *screen_old,
+ bScreen *screen_new,
+ struct Main *bmain,
+ struct bContext *C,
+ wmWindow *win);
ScrArea *area_split(
const wmWindow *win, bScreen *screen, ScrArea *area, char dir, float fac, int merge);
int screen_area_join(struct bContext *C, bScreen *screen, ScrArea *sa1, ScrArea *sa2);
@@ -97,5 +96,3 @@ void SCREEN_OT_screenshot(struct wmOperatorType *ot);
/* workspace_layout_edit.c */
bool workspace_layout_set_poll(const struct WorkSpaceLayout *layout);
-
-#endif /* __SCREEN_INTERN_H__ */
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index fde1498bc5e..b002b23a7f3 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -4414,7 +4414,7 @@ static void screen_animation_region_tag_redraw(ScrArea *area,
* We do need to redraw when this area is in full screen as no other areas
* will be tagged for redrawing. */
if ((region->regiontype == RGN_TYPE_WINDOW) &&
- (ELEM(area->spacetype, SPACE_GRAPH, SPACE_NLA, SPACE_ACTION, SPACE_SEQ)) && !area->full) {
+ (ELEM(area->spacetype, SPACE_GRAPH, SPACE_NLA, SPACE_ACTION)) && !area->full) {
return;
}
ED_region_tag_redraw(region);
@@ -5184,7 +5184,7 @@ static void region_blend_end(bContext *C, ARegion *region, const bool is_running
else {
if (rgi->hidden) {
rgi->region->flag |= rgi->hidden;
- ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), rgi->area);
+ ED_area_init(CTX_wm_manager(C), CTX_wm_window(C), rgi->area);
}
/* area decoration needs redraw in end */
ED_area_tag_redraw(rgi->area);
@@ -5215,7 +5215,7 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARe
/* blend in, reinitialize regions because it got unhidden */
if (rgi->hidden == 0) {
- ED_area_initialize(wm, win, area);
+ ED_area_init(wm, win, area);
}
else {
WM_event_remove_handlers(C, &region->handlers);
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 478a0adfd9a..b20dc80d158 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -88,22 +88,15 @@ static void workspace_change_update(WorkSpace *workspace_new,
#endif
}
-static bool workspace_change_find_new_layout_cb(const WorkSpaceLayout *layout, void *UNUSED(arg))
-{
- /* return false to stop the iterator if we've found a layout that can be activated */
- return workspace_layout_set_poll(layout) ? false : true;
-}
-
static WorkSpaceLayout *workspace_change_get_new_layout(Main *bmain,
WorkSpace *workspace_new,
wmWindow *win)
{
- /* ED_workspace_duplicate may have stored a layout to activate
- * once the workspace gets activated. */
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
WorkSpaceLayout *layout_new;
- bScreen *screen_new;
+ /* ED_workspace_duplicate may have stored a layout to activate
+ * once the workspace gets activated. */
if (win->workspace_hook->temp_workspace_store) {
layout_new = win->workspace_hook->temp_layout_store;
}
@@ -113,20 +106,9 @@ static WorkSpaceLayout *workspace_change_get_new_layout(Main *bmain,
layout_new = workspace_new->layouts.first;
}
}
- screen_new = BKE_workspace_layout_screen_get(layout_new);
-
- if (screen_new->winid) {
- /* screen is already used, try to find a free one */
- WorkSpaceLayout *layout_temp = BKE_workspace_layout_iter_circular(
- workspace_new, layout_new, workspace_change_find_new_layout_cb, NULL, false);
- if (!layout_temp) {
- /* fallback solution: duplicate layout from old workspace */
- layout_temp = ED_workspace_layout_duplicate(bmain, workspace_new, layout_old, win);
- }
- layout_new = layout_temp;
- }
- return layout_new;
+ return ED_workspace_screen_change_ensure_unused_layout(
+ bmain, workspace_new, layout_new, layout_old, win);
}
/**
@@ -153,10 +135,7 @@ bool ED_workspace_change(WorkSpace *workspace_new, bContext *C, wmWindowManager
return false;
}
- screen_new = screen_change_prepare(screen_old, screen_new, bmain, C, win);
- if (BKE_workspace_layout_screen_get(layout_new) != screen_new) {
- layout_new = BKE_workspace_layout_find(workspace_new, screen_new);
- }
+ screen_change_prepare(screen_old, screen_new, bmain, C, win);
if (screen_new == NULL) {
return false;
diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c
index 0af81e0db21..8a36cffa1f1 100644
--- a/source/blender/editors/screen/workspace_layout_edit.c
+++ b/source/blender/editors/screen/workspace_layout_edit.c
@@ -160,6 +160,66 @@ bool ED_workspace_layout_delete(WorkSpace *workspace, WorkSpaceLayout *layout_ol
return false;
}
+static bool workspace_change_find_new_layout_cb(const WorkSpaceLayout *layout, void *UNUSED(arg))
+{
+ /* return false to stop the iterator if we've found a layout that can be activated */
+ return workspace_layout_set_poll(layout) ? false : true;
+}
+
+static bScreen *screen_fullscreen_find_associated_normal_screen(const Main *bmain, bScreen *screen)
+{
+ for (bScreen *screen_iter = bmain->screens.first; screen_iter;
+ screen_iter = screen_iter->id.next) {
+ if ((screen_iter != screen) && ELEM(screen_iter->state, SCREENMAXIMIZED, SCREENFULL)) {
+ ScrArea *area = screen_iter->areabase.first;
+ if (area && area->full == screen) {
+ return screen_iter;
+ }
+ }
+ }
+
+ return screen;
+}
+
+static bool screen_is_used_by_other_window(const wmWindow *win, const bScreen *screen)
+{
+ return BKE_screen_is_used(screen) && (screen->winid != win->winid);
+}
+
+/**
+ * Make sure there is a non-fullscreen layout to switch to that is not used yet by an other window.
+ * Needed for workspace or screen switching to ensure valid screens.
+ *
+ * \param layout_fallback_base: As last resort, this layout is duplicated and returned.
+ */
+WorkSpaceLayout *ED_workspace_screen_change_ensure_unused_layout(
+ Main *bmain,
+ WorkSpace *workspace,
+ WorkSpaceLayout *layout_new,
+ const WorkSpaceLayout *layout_fallback_base,
+ wmWindow *win)
+{
+ WorkSpaceLayout *layout_temp = layout_new;
+ bScreen *screen_temp = BKE_workspace_layout_screen_get(layout_new);
+
+ screen_temp = screen_fullscreen_find_associated_normal_screen(bmain, screen_temp);
+ layout_temp = BKE_workspace_layout_find(workspace, screen_temp);
+
+ if (screen_is_used_by_other_window(win, screen_temp)) {
+ /* Screen is already used, try to find a free one. */
+ layout_temp = BKE_workspace_layout_iter_circular(
+ workspace, layout_new, workspace_change_find_new_layout_cb, NULL, false);
+ screen_temp = layout_temp ? BKE_workspace_layout_screen_get(layout_temp) : NULL;
+
+ if (!layout_temp || screen_is_used_by_other_window(win, screen_temp)) {
+ /* Fallback solution: duplicate layout. */
+ layout_temp = ED_workspace_layout_duplicate(bmain, workspace, layout_fallback_base, win);
+ }
+ }
+
+ return layout_temp;
+}
+
static bool workspace_layout_cycle_iter_cb(const WorkSpaceLayout *layout, void *UNUSED(arg))
{
/* return false to stop iterator when we have found a layout to activate */
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index ed87d524627..51cfb912722 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -60,6 +60,7 @@ set(SRC
paint_vertex_weight_utils.c
sculpt.c
sculpt_automasking.c
+ sculpt_boundary.c
sculpt_cloth.c
sculpt_detail.c
sculpt_dyntopo.c
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index d0082769575..88998d5063d 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -56,7 +56,6 @@
#include "DEG_depsgraph.h"
-#include "GPU_draw.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
@@ -456,7 +455,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
}
buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex");
- BKE_curvemapping_initialize(br->curve);
+ BKE_curvemapping_init(br->curve);
LoadTexData data = {
.br = br,
@@ -540,54 +539,6 @@ static int project_brush_radius(ViewContext *vc, float radius, const float locat
return 0;
}
-static bool sculpt_get_brush_geometry(bContext *C,
- ViewContext *vc,
- int x,
- int y,
- int *pixel_radius,
- float location[3],
- UnifiedPaintSettings *ups)
-{
- Scene *scene = CTX_data_scene(C);
- Paint *paint = BKE_paint_get_active_from_context(C);
- float mouse[2];
- bool hit = false;
-
- mouse[0] = x;
- mouse[1] = y;
-
- if (vc->obact->sculpt && vc->obact->sculpt->pbvh) {
- if (!ups->stroke_active) {
- hit = SCULPT_stroke_get_location(C, location, mouse);
- }
- else {
- hit = ups->last_hit;
- copy_v3_v3(location, ups->last_location);
- }
- }
-
- if (hit) {
- Brush *brush = BKE_paint_brush(paint);
-
- *pixel_radius = project_brush_radius(
- vc, BKE_brush_unprojected_radius_get(scene, brush), location);
-
- if (*pixel_radius == 0) {
- *pixel_radius = BKE_brush_size_get(scene, brush);
- }
-
- mul_m4_v3(vc->obact->obmat, location);
- }
- else {
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- Brush *brush = BKE_paint_brush(&sd->paint);
-
- *pixel_radius = BKE_brush_size_get(scene, brush);
- }
-
- return hit;
-}
-
/* Draw an overlay that shows what effect the brush's texture will
* have on brush strength. */
static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
@@ -924,7 +875,7 @@ BLI_INLINE void draw_rect_point(uint pos,
imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy);
}
-BLI_INLINE void draw_bezier_handle_lines(uint pos, float sel_col[4], BezTriple *bez)
+BLI_INLINE void draw_bezier_handle_lines(uint pos, const float sel_col[4], BezTriple *bez)
{
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
GPU_line_width(3.0f);
@@ -1042,10 +993,10 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
/* Special actions taken when paint cursor goes over mesh */
/* TODO: sculpt only for now. */
-static void paint_cursor_on_hit(UnifiedPaintSettings *ups,
- Brush *brush,
- ViewContext *vc,
- const float location[3])
+static void paint_cursor_update_unprojected_radius(UnifiedPaintSettings *ups,
+ Brush *brush,
+ ViewContext *vc,
+ const float location[3])
{
float unprojected_radius, projected_radius;
@@ -1077,18 +1028,6 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups,
}
}
-static bool ommit_cursor_drawing(Paint *paint, ePaintMode mode, Brush *brush)
-{
- if (paint->flags & PAINT_SHOW_BRUSH) {
- if (ELEM(mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D) &&
- brush->imagepaint_tool == PAINT_TOOL_FILL) {
- return true;
- }
- return false;
- }
- return true;
-}
-
static void cursor_draw_point_screen_space(const uint gpuattr,
const ARegion *region,
const float true_location[3],
@@ -1188,8 +1127,27 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr,
}
}
-static void sculpt_geometry_preview_lines_draw(const uint gpuattr, SculptSession *ss)
+static void sculpt_geometry_preview_lines_draw(const uint gpuattr,
+ Brush *brush,
+ const bool is_multires,
+ SculptSession *ss)
{
+ if (!(brush->flag & BRUSH_GRAB_ACTIVE_VERTEX)) {
+ return;
+ }
+
+ if (is_multires) {
+ return;
+ }
+
+ if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) {
+ return;
+ }
+
+ if (!ss->deform_modifiers_active) {
+ return;
+ }
+
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.6f);
/* Cursor normally draws on top, but for this part we need depth tests. */
@@ -1215,30 +1173,21 @@ static void sculpt_geometry_preview_lines_draw(const uint gpuattr, SculptSession
static void SCULPT_layer_brush_height_preview_draw(const uint gpuattr,
const Brush *brush,
- const float obmat[4][4],
- const float location[3],
- const float normal[3],
const float rds,
const float line_width,
const float outline_col[3],
const float alpha)
{
- float cursor_trans[4][4], cursor_rot[4][4];
- float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f};
- float quat[4];
- float height_preview_trans[3];
- copy_m4_m4(cursor_trans, obmat);
- madd_v3_v3v3fl(height_preview_trans, location, normal, brush->height);
- translate_m4(
- cursor_trans, height_preview_trans[0], height_preview_trans[1], height_preview_trans[2]);
- rotation_between_vecs_to_quat(quat, z_axis, normal);
- quat_to_mat4(cursor_rot, quat);
+ float cursor_trans[4][4];
+ unit_m4(cursor_trans);
+ translate_m4(cursor_trans, 0.0f, 0.0f, brush->height);
+ GPU_matrix_push();
GPU_matrix_mul(cursor_trans);
- GPU_matrix_mul(cursor_rot);
GPU_line_width(line_width);
immUniformColor3fvAlpha(outline_col, alpha * 0.5f);
imm_draw_circle_wire_3d(gpuattr, 0, 0, rds, 80);
+ GPU_matrix_pop();
}
static bool paint_use_2d_cursor(ePaintMode mode)
@@ -1249,428 +1198,715 @@ static bool paint_use_2d_cursor(ePaintMode mode)
return false;
}
-static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
+typedef enum PaintCursorDrawingType {
+ PAINT_CURSOR_CURVE,
+ PAINT_CURSOR_2D,
+ PAINT_CURSOR_3D,
+} PaintCursorDrawingType;
+
+typedef struct PaintCursorContext {
+ bContext *C;
+ ARegion *region;
+ wmWindow *win;
+ wmWindowManager *wm;
+ Depsgraph *depsgraph;
+ Scene *scene;
+ UnifiedPaintSettings *ups;
+ Brush *brush;
+ Paint *paint;
+ ePaintMode mode;
+ ViewContext vc;
+
+ /* Sculpt related data. */
+ Sculpt *sd;
+ SculptSession *ss;
+ int prev_active_vertex_index;
+ bool is_stroke_active;
+ bool is_cursor_over_mesh;
+ bool is_multires;
+ float radius;
+
+ /* 3D view cursor position and normal. */
+ float location[3];
+ float scene_space_location[3];
+ float normal[3];
+
+ /* Cursor main colors. */
+ float outline_col[3];
+ float outline_alpha;
+
+ /* GPU attribute for drawing. */
+ uint pos;
+
+ PaintCursorDrawingType cursor_type;
+
+ /* This variable is set after drawing the overlay, not on initialization. It can't be used for
+ * checking if alpha overlay is enabled before drawing it. */
+ bool alpha_overlay_drawn;
+
+ float zoomx;
+ int x, y;
+ float translation[2];
+
+ float final_radius;
+ int pixel_radius;
+
+} PaintCursorContext;
+
+static bool paint_cursor_context_init(bContext *C,
+ const int x,
+ const int y,
+ PaintCursorContext *pcontext)
{
ARegion *region = CTX_wm_region(C);
if (region && region->regiontype != RGN_TYPE_WINDOW) {
- return;
+ return false;
}
- const wmWindowManager *wm = CTX_wm_manager(C);
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
- Scene *scene = CTX_data_scene(C);
- UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
- Paint *paint = BKE_paint_get_active_from_context(C);
- Brush *brush = BKE_paint_brush(paint);
- ePaintMode mode = BKE_paintmode_get_active_from_context(C);
+ pcontext->C = C;
+ pcontext->region = region;
+ pcontext->wm = CTX_wm_manager(C);
+ pcontext->win = CTX_wm_window(C);
+ pcontext->depsgraph = CTX_data_depsgraph_pointer(C);
+ pcontext->scene = CTX_data_scene(C);
+ pcontext->ups = &pcontext->scene->toolsettings->unified_paint_settings;
+ pcontext->paint = BKE_paint_get_active_from_context(C);
+ pcontext->brush = BKE_paint_brush(pcontext->paint);
+ pcontext->mode = BKE_paintmode_get_active_from_context(C);
+
+ ED_view3d_viewcontext_init(C, &pcontext->vc, pcontext->depsgraph);
+
+ if (pcontext->brush->flag & BRUSH_CURVE) {
+ pcontext->cursor_type = PAINT_CURSOR_CURVE;
+ }
+ else if (paint_use_2d_cursor(pcontext->mode)) {
+ pcontext->cursor_type = PAINT_CURSOR_2D;
+ }
+ else {
+ pcontext->cursor_type = PAINT_CURSOR_3D;
+ }
- /* 2d or 3d painting? */
- const bool use_2d_cursor = paint_use_2d_cursor(mode);
+ pcontext->x = x;
+ pcontext->y = y;
+ pcontext->translation[0] = (float)x;
+ pcontext->translation[1] = (float)y;
- /* check that brush drawing is enabled */
- if (ommit_cursor_drawing(paint, mode, brush)) {
- return;
+ float zoomx, zoomy;
+ get_imapaint_zoom(C, &zoomx, &zoomy);
+ pcontext->zoomx = max_ff(zoomx, zoomy);
+ pcontext->final_radius = (BKE_brush_size_get(pcontext->scene, pcontext->brush) * zoomx);
+
+ /* There is currently no way to check if the direction is inverted before starting the stroke,
+ * so this does not reflect the state of the brush in the UI. */
+ if (((pcontext->ups->draw_inverted == 0) ^ ((pcontext->brush->flag & BRUSH_DIR_IN) == 0)) &&
+ BKE_brush_sculpt_has_secondary_color(pcontext->brush)) {
+ copy_v3_v3(pcontext->outline_col, pcontext->brush->sub_col);
}
+ else {
+ copy_v3_v3(pcontext->outline_col, pcontext->brush->add_col);
+ }
+ pcontext->outline_alpha = pcontext->brush->add_col[3];
- /* Can't use stroke vc here because this will be called during
- * mouse over too, not just during a stroke. */
- ViewContext vc;
- ED_view3d_viewcontext_init(C, &vc, depsgraph);
+ Object *active_object = pcontext->vc.obact;
+ pcontext->ss = active_object ? active_object->sculpt : NULL;
- if (vc.rv3d && (vc.rv3d->rflag & RV3D_NAVIGATING)) {
- return;
- }
+ pcontext->is_stroke_active = pcontext->ups->stroke_active;
- /* Skip everything and draw brush here. */
- if (brush->flag & BRUSH_CURVE) {
- paint_draw_curve_cursor(brush, &vc);
- return;
+ return true;
+}
+
+static void paint_cursor_update_pixel_radius(PaintCursorContext *pcontext)
+{
+ if (pcontext->is_cursor_over_mesh) {
+ Brush *brush = BKE_paint_brush(pcontext->paint);
+ pcontext->pixel_radius = project_brush_radius(
+ &pcontext->vc,
+ BKE_brush_unprojected_radius_get(pcontext->scene, brush),
+ pcontext->location);
+
+ if (pcontext->pixel_radius == 0) {
+ pcontext->pixel_radius = BKE_brush_size_get(pcontext->scene, brush);
+ }
+
+ copy_v3_v3(pcontext->scene_space_location, pcontext->location);
+ mul_m4_v3(pcontext->vc.obact->obmat, pcontext->scene_space_location);
}
+ else {
+ Sculpt *sd = CTX_data_tool_settings(pcontext->C)->sculpt;
+ Brush *brush = BKE_paint_brush(&sd->paint);
- float zoomx, zoomy;
- get_imapaint_zoom(C, &zoomx, &zoomy);
- zoomx = max_ff(zoomx, zoomy);
+ pcontext->pixel_radius = BKE_brush_size_get(pcontext->scene, brush);
+ }
+}
- /* Set various defaults. */
- const float *outline_col = brush->add_col;
- const float outline_alpha = brush->add_col[3];
- float translation[2] = {x, y};
- float final_radius = (BKE_brush_size_get(scene, brush) * zoomx);
+static void paint_cursor_sculpt_session_update_and_init(PaintCursorContext *pcontext)
+{
+ BLI_assert(pcontext->ss != NULL);
+ BLI_assert(pcontext->mode == PAINT_MODE_SCULPT);
+
+ bContext *C = pcontext->C;
+ SculptSession *ss = pcontext->ss;
+ Brush *brush = pcontext->brush;
+ Scene *scene = pcontext->scene;
+ UnifiedPaintSettings *ups = pcontext->ups;
+ ViewContext *vc = &pcontext->vc;
+ SculptCursorGeometryInfo gi;
+
+ const float mouse[2] = {
+ pcontext->x - pcontext->region->winrct.xmin,
+ pcontext->y - pcontext->region->winrct.ymin,
+ };
- /* Don't calculate rake angles while a stroke is active because the rake variables are global
- * and we may get interference with the stroke itself.
- * For line strokes, such interference is visible. */
+ /* This updates the active vertex, which is needed for most of the Sculpt/Vertex Colors tools to
+ * work correctly */
+ pcontext->prev_active_vertex_index = ss->active_vertex_index;
if (!ups->stroke_active) {
- paint_calculate_rake_rotation(ups, brush, translation);
+ pcontext->is_cursor_over_mesh = SCULPT_cursor_geometry_info_update(
+ C, &gi, mouse, (pcontext->brush->falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE));
+ copy_v3_v3(pcontext->location, gi.location);
+ copy_v3_v3(pcontext->normal, gi.normal);
+ }
+ else {
+ pcontext->is_cursor_over_mesh = ups->last_hit;
+ copy_v3_v3(pcontext->location, ups->last_location);
}
- /* Draw overlay. */
- bool alpha_overlay_active = paint_draw_alpha_overlay(ups, brush, &vc, x, y, zoomx, mode);
+ paint_cursor_update_pixel_radius(pcontext);
- if (ups->draw_anchored) {
- final_radius = ups->anchored_size;
- copy_v2_fl2(translation,
- ups->anchored_initial_mouse[0] + region->winrct.xmin,
- ups->anchored_initial_mouse[1] + region->winrct.ymin);
+ if (BKE_brush_use_locked_size(scene, brush)) {
+ BKE_brush_size_set(scene, brush, pcontext->pixel_radius);
}
- /* Make lines pretty. */
- GPU_line_width(2.0f);
+ if (pcontext->is_cursor_over_mesh) {
+ paint_cursor_update_unprojected_radius(ups, brush, vc, pcontext->scene_space_location);
+ }
- /* TODO: also set blend mode? */
- GPU_blend(true);
+ pcontext->is_multires = ss->pbvh != NULL && BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS;
- GPU_line_smooth(true);
+ pcontext->sd = CTX_data_tool_settings(pcontext->C)->sculpt;
+}
- if (use_2d_cursor) {
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+static void paint_update_mouse_cursor(PaintCursorContext *pcontext)
+{
+ WM_cursor_set(pcontext->win, WM_CURSOR_PAINT);
+}
- immUniformColor3fvAlpha(outline_col, outline_alpha);
+static void paint_draw_2D_view_brush_cursor(PaintCursorContext *pcontext)
+{
+ immUniformColor3fvAlpha(pcontext->outline_col, pcontext->outline_alpha);
+
+ /* Draw brush outline. */
+ if (pcontext->ups->stroke_active && BKE_brush_use_size_pressure(pcontext->brush)) {
+ imm_draw_circle_wire_2d(pcontext->pos,
+ pcontext->translation[0],
+ pcontext->translation[1],
+ pcontext->final_radius * pcontext->ups->size_pressure_value,
+ 40);
+ /* Outer at half alpha. */
+ immUniformColor3fvAlpha(pcontext->outline_col, pcontext->outline_alpha * 0.5f);
+ }
- /* Draw brush outline. */
- if (ups->stroke_active && BKE_brush_use_size_pressure(brush)) {
- imm_draw_circle_wire_2d(
- pos, translation[0], translation[1], final_radius * ups->size_pressure_value, 40);
- /* Outer at half alpha. */
- immUniformColor3fvAlpha(outline_col, outline_alpha * 0.5f);
- }
+ GPU_line_width(1.0f);
+ imm_draw_circle_wire_2d(pcontext->pos,
+ pcontext->translation[0],
+ pcontext->translation[1],
+ pcontext->final_radius,
+ 40);
+}
- GPU_line_width(1.0f);
- imm_draw_circle_wire_2d(pos, translation[0], translation[1], final_radius, 40);
+static void paint_draw_legacy_3D_view_brush_cursor(PaintCursorContext *pcontext)
+{
+ GPU_line_width(1.0f);
+ immUniformColor3fvAlpha(pcontext->outline_col, pcontext->outline_alpha);
+ imm_draw_circle_wire_3d(pcontext->pos,
+ pcontext->translation[0],
+ pcontext->translation[1],
+ pcontext->final_radius,
+ 40);
+}
+
+static void paint_draw_3D_view_inactive_brush_cursor(PaintCursorContext *pcontext)
+{
+ GPU_line_width(1.0f);
+ /* Reduce alpha to increase the contrast when the cursor is over the mesh. */
+ immUniformColor3fvAlpha(pcontext->outline_col, pcontext->outline_alpha * 0.8);
+ imm_draw_circle_wire_3d(pcontext->pos,
+ pcontext->translation[0],
+ pcontext->translation[1],
+ pcontext->final_radius,
+ 80);
+ immUniformColor3fvAlpha(pcontext->outline_col, pcontext->outline_alpha * 0.35f);
+ imm_draw_circle_wire_3d(pcontext->pos,
+ pcontext->translation[0],
+ pcontext->translation[1],
+ pcontext->final_radius * clamp_f(pcontext->brush->alpha, 0.0f, 1.0f),
+ 80);
+}
+
+static void paint_cursor_update_object_space_radius(PaintCursorContext *pcontext)
+{
+ if (!BKE_brush_use_locked_size(pcontext->scene, pcontext->brush)) {
+ pcontext->radius = paint_calc_object_space_radius(
+ &pcontext->vc, pcontext->location, BKE_brush_size_get(pcontext->scene, pcontext->brush));
}
else {
- /* 3D Painting. */
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-
- /* TODO: as sculpt and other paint modes are unified, this
- * special mode of drawing will go away. */
- Object *obact = vc.obact;
- SculptSession *ss = obact ? obact->sculpt : NULL;
- if ((mode == PAINT_MODE_SCULPT) && ss) {
- float location[3];
- int pixel_radius;
-
- /* Test if brush is over the mesh. */
- bool hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location, ups);
-
- if (BKE_brush_use_locked_size(scene, brush)) {
- BKE_brush_size_set(scene, brush, pixel_radius);
- }
+ pcontext->radius = BKE_brush_unprojected_radius_get(pcontext->scene, pcontext->brush);
+ }
+}
- /* Check if brush is subtracting, use different color then */
- /* TODO: no way currently to know state of pen flip or
- * invert key modifier without starting a stroke. */
- if (((ups->draw_inverted == 0) ^ ((brush->flag & BRUSH_DIR_IN) == 0)) &&
- BKE_brush_sculpt_has_secondary_color(brush)) {
- outline_col = brush->sub_col;
- }
+static void paint_cursor_drawing_setup_cursor_space(PaintCursorContext *pcontext)
+{
+ float cursor_trans[4][4], cursor_rot[4][4];
+ const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f};
+ float quat[4];
+ copy_m4_m4(cursor_trans, pcontext->vc.obact->obmat);
+ translate_m4(cursor_trans, pcontext->location[0], pcontext->location[1], pcontext->location[2]);
+ rotation_between_vecs_to_quat(quat, z_axis, pcontext->normal);
+ quat_to_mat4(cursor_rot, quat);
+ GPU_matrix_mul(cursor_trans);
+ GPU_matrix_mul(cursor_rot);
+}
+
+static void paint_cursor_draw_main_inactive_cursor(PaintCursorContext *pcontext)
+{
+ immUniformColor3fvAlpha(pcontext->outline_col, pcontext->outline_alpha);
+ GPU_line_width(2.0f);
+ imm_draw_circle_wire_3d(pcontext->pos, 0, 0, pcontext->radius, 80);
+
+ GPU_line_width(1.0f);
+ immUniformColor3fvAlpha(pcontext->outline_col, pcontext->outline_alpha * 0.5f);
+ imm_draw_circle_wire_3d(
+ pcontext->pos, 0, 0, pcontext->radius * clamp_f(pcontext->brush->alpha, 0.0f, 1.0f), 80);
+}
+
+static void paint_cursor_pose_brush_segments_draw(PaintCursorContext *pcontext)
+{
+ SculptSession *ss = pcontext->ss;
+ immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f);
+ GPU_line_width(2.0f);
+
+ immBegin(GPU_PRIM_LINES, ss->pose_ik_chain_preview->tot_segments * 2);
+ for (int i = 0; i < ss->pose_ik_chain_preview->tot_segments; i++) {
+ immVertex3fv(pcontext->pos, ss->pose_ik_chain_preview->segments[i].initial_orig);
+ immVertex3fv(pcontext->pos, ss->pose_ik_chain_preview->segments[i].initial_head);
+ }
+
+ immEnd();
+}
+
+static void paint_cursor_pose_brush_origins_draw(PaintCursorContext *pcontext)
+{
+
+ SculptSession *ss = pcontext->ss;
+ immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f);
+ for (int i = 0; i < ss->pose_ik_chain_preview->tot_segments; i++) {
+ cursor_draw_point_screen_space(pcontext->pos,
+ pcontext->region,
+ ss->pose_ik_chain_preview->segments[i].initial_orig,
+ pcontext->vc.obact->obmat,
+ 3);
+ }
+}
- /* Only do if brush is over the mesh. */
- if (hit) {
- paint_cursor_on_hit(ups, brush, &vc, location);
+static void paint_cursor_preview_boundary_data_pivot_draw(PaintCursorContext *pcontext)
+{
+
+ if (!pcontext->ss->boundary_preview) {
+ /* There is no guarantee that a boundary preview exists as there may be no boundaries
+ * inside the brush radius. */
+ return;
+ }
+ immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f);
+ cursor_draw_point_screen_space(
+ pcontext->pos,
+ pcontext->region,
+ SCULPT_vertex_co_get(pcontext->ss, pcontext->ss->boundary_preview->pivot_vertex),
+ pcontext->vc.obact->obmat,
+ 3);
+}
+
+static void paint_cursor_preview_boundary_data_update(PaintCursorContext *pcontext,
+ const bool update_previews)
+{
+ SculptSession *ss = pcontext->ss;
+ if (!(update_previews || !ss->boundary_preview)) {
+ return;
+ }
+
+ /* Needed for updating the necessary SculptSession data in order to initialize the
+ * boundary data for the preview. */
+ BKE_sculpt_update_object_for_edit(pcontext->depsgraph, pcontext->vc.obact, true, false, false);
+
+ if (ss->boundary_preview) {
+ SCULPT_boundary_data_free(ss->boundary_preview);
+ }
+
+ ss->boundary_preview = SCULPT_boundary_data_init(
+ pcontext->vc.obact, ss->active_vertex_index, pcontext->radius);
+}
+
+static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext *pcontext)
+{
+ Brush *brush = pcontext->brush;
+
+ /* 2D falloff is better represented with the default 2D cursor,
+ * there is no need to draw anything else. */
+ if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
+ paint_draw_legacy_3D_view_brush_cursor(pcontext);
+ return;
+ }
+
+ if (pcontext->alpha_overlay_drawn) {
+ paint_draw_legacy_3D_view_brush_cursor(pcontext);
+ return;
+ }
+
+ if (!pcontext->is_cursor_over_mesh) {
+ paint_draw_3D_view_inactive_brush_cursor(pcontext);
+ return;
+ }
+
+ paint_cursor_update_object_space_radius(pcontext);
+
+ const bool update_previews = pcontext->prev_active_vertex_index !=
+ SCULPT_active_vertex_get(pcontext->ss);
+
+ /* Setup drawing. */
+ wmViewport(&pcontext->region->winrct);
+
+ /* Drawing of Cursor overlays in 2D screen space. */
+
+ /* Cursor location symmetry points. */
+
+ const float *active_vertex_co = SCULPT_active_vertex_co_get(pcontext->ss);
+ if (len_v3v3(active_vertex_co, pcontext->location) < pcontext->radius) {
+ immUniformColor3fvAlpha(pcontext->outline_col, pcontext->outline_alpha);
+ cursor_draw_point_with_symmetry(pcontext->pos,
+ pcontext->region,
+ active_vertex_co,
+ pcontext->sd,
+ pcontext->vc.obact,
+ pcontext->radius);
+ }
+
+ /* Pose brush updates and rotation origins. */
+
+ if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
+ /* Just after switching to the Pose Brush, the active vertex can be the same and the
+ * cursor won't be tagged to update, so always initialize the preview chain if it is
+ * null before drawing it. */
+ SculptSession *ss = pcontext->ss;
+ if (update_previews || !ss->pose_ik_chain_preview) {
+ BKE_sculpt_update_object_for_edit(
+ pcontext->depsgraph, pcontext->vc.obact, true, false, false);
+
+ /* Free the previous pose brush preview. */
+ if (ss->pose_ik_chain_preview) {
+ SCULPT_pose_ik_chain_free(ss->pose_ik_chain_preview);
}
+
+ /* Generate a new pose brush preview from the current cursor location. */
+ ss->pose_ik_chain_preview = SCULPT_pose_ik_chain_init(
+ pcontext->sd, pcontext->vc.obact, ss, brush, pcontext->location, pcontext->radius);
}
- immUniformColor3fvAlpha(outline_col, outline_alpha);
+ /* Draw the pose brush rotation origins. */
+ paint_cursor_pose_brush_origins_draw(pcontext);
+ }
+
+ if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) {
+ paint_cursor_preview_boundary_data_update(pcontext, update_previews);
+ paint_cursor_preview_boundary_data_pivot_draw(pcontext);
+ }
- if (ups->stroke_active && BKE_brush_use_size_pressure(brush) && mode != PAINT_MODE_SCULPT) {
- imm_draw_circle_wire_3d(
- pos, translation[0], translation[1], final_radius * ups->size_pressure_value, 40);
- /* Outer at half alpha. */
- immUniformColor3fvAlpha(outline_col, outline_alpha * 0.5f);
- }
+ /* Setup 3D perspective drawing. */
+ GPU_matrix_push_projection();
+ ED_view3d_draw_setup_view(pcontext->wm,
+ pcontext->win,
+ pcontext->depsgraph,
+ pcontext->scene,
+ pcontext->region,
+ CTX_wm_view3d(pcontext->C),
+ NULL,
+ NULL,
+ NULL);
+
+ GPU_matrix_push();
+ GPU_matrix_mul(pcontext->vc.obact->obmat);
- /* Only sculpt mode cursor for now. */
- /* Disable for PBVH_GRIDS. */
- bool is_multires = ss && ss->pbvh && BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS;
+ /* Drawing Cursor overlays in 3D object space. */
+ if (brush->sculpt_tool == SCULPT_TOOL_GRAB && (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX)) {
+ SCULPT_geometry_preview_lines_update(pcontext->C, pcontext->ss, pcontext->radius);
+ sculpt_geometry_preview_lines_draw(
+ pcontext->pos, pcontext->brush, pcontext->is_multires, pcontext->ss);
+ }
- SculptCursorGeometryInfo gi;
- float mouse[2] = {x - region->winrct.xmin, y - region->winrct.ymin};
- int prev_active_vertex_index = -1;
- bool is_cursor_over_mesh = false;
+ if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
+ paint_cursor_pose_brush_segments_draw(pcontext);
+ }
- /* Update the active vertex. */
- if ((mode == PAINT_MODE_SCULPT) && ss && !ups->stroke_active) {
- prev_active_vertex_index = ss->active_vertex_index;
- is_cursor_over_mesh = SCULPT_cursor_geometry_info_update(
- C, &gi, mouse, (brush->falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE));
+ if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) {
+ SCULPT_boundary_edges_preview_draw(
+ pcontext->pos, pcontext->ss, pcontext->outline_col, pcontext->outline_alpha);
+ SCULPT_boundary_pivot_line_preview_draw(pcontext->pos, pcontext->ss);
+ }
+
+ GPU_matrix_pop();
+
+ /* Drawing Cursor overlays in Paint Cursor space (as additional info on top of the brush cursor)
+ */
+ GPU_matrix_push();
+ paint_cursor_drawing_setup_cursor_space(pcontext);
+ /* Main inactive cursor. */
+ paint_cursor_draw_main_inactive_cursor(pcontext);
+
+ /* Cloth brush local simulation areas. */
+ if (brush->sculpt_tool == SCULPT_TOOL_CLOTH &&
+ brush->cloth_simulation_area_type == BRUSH_CLOTH_SIMULATION_AREA_LOCAL) {
+ const float white[3] = {1.0f, 1.0f, 1.0f};
+ const float zero_v[3] = {0.0f};
+ /* This functions sets its own drawing space in order to draw the simulation limits when the
+ * cursor is active. When used here, this cursor overlay is already in cursor space, so its
+ * position and normal should be set to 0. */
+ SCULPT_cloth_simulation_limits_draw(
+ pcontext->pos, brush, zero_v, zero_v, pcontext->radius, 1.0f, white, 0.25f);
+ }
+
+ /* Layer brush height. */
+ if (brush->sculpt_tool == SCULPT_TOOL_LAYER) {
+ SCULPT_layer_brush_height_preview_draw(pcontext->pos,
+ brush,
+ pcontext->radius,
+ 1.0f,
+ pcontext->outline_col,
+ pcontext->outline_alpha);
+ }
+
+ GPU_matrix_pop();
+
+ /* Reset drawing. */
+ GPU_matrix_pop_projection();
+ wmWindowViewport(pcontext->win);
+}
+
+static void paint_cursor_cursor_draw_3d_view_brush_cursor_active(PaintCursorContext *pcontext)
+{
+ BLI_assert(pcontext->ss != NULL);
+ BLI_assert(pcontext->mode == PAINT_MODE_SCULPT);
+
+ SculptSession *ss = pcontext->ss;
+ Brush *brush = pcontext->brush;
+
+ /* The cursor can be updated as active before creating the StrokeCache, so this needs to be
+ * checked. */
+ if (!ss->cache) {
+ return;
+ }
+
+ /* Most of the brushes initialize the necessary data for the custom cursor drawing after the
+ * first brush step, so make sure that it is not drawn before being initialized. */
+ if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) {
+ return;
+ }
+
+ /* Setup drawing. */
+ wmViewport(&pcontext->region->winrct);
+ GPU_matrix_push_projection();
+ ED_view3d_draw_setup_view(pcontext->wm,
+ pcontext->win,
+ pcontext->depsgraph,
+ pcontext->scene,
+ pcontext->region,
+ CTX_wm_view3d(pcontext->C),
+ NULL,
+ NULL,
+ NULL);
+ GPU_matrix_push();
+ GPU_matrix_mul(pcontext->vc.obact->obmat);
+
+ /* Draw the special active cursors different tools may have. */
+
+ if (brush->sculpt_tool == SCULPT_TOOL_GRAB) {
+ sculpt_geometry_preview_lines_draw(pcontext->pos, brush, pcontext->is_multires, ss);
+ }
+
+ if (brush->sculpt_tool == SCULPT_TOOL_MULTIPLANE_SCRAPE) {
+ SCULPT_multiplane_scrape_preview_draw(
+ pcontext->pos, brush, ss, pcontext->outline_col, pcontext->outline_alpha);
+ }
+
+ if (brush->sculpt_tool == SCULPT_TOOL_CLOTH) {
+ if (brush->cloth_force_falloff_type == BRUSH_CLOTH_FORCE_FALLOFF_PLANE) {
+ SCULPT_cloth_plane_falloff_preview_draw(
+ pcontext->pos, ss, pcontext->outline_col, pcontext->outline_alpha);
}
- /* Use special paint crosshair cursor in all paint modes. */
- wmWindow *win = CTX_wm_window(C);
- WM_cursor_set(win, WM_CURSOR_PAINT);
-
- if ((mode == PAINT_MODE_SCULPT) && ss &&
- (brush->falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE)) {
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
-
- if (!ups->stroke_active) {
- bool update_previews = false;
- if (is_cursor_over_mesh && !alpha_overlay_active) {
-
- if (prev_active_vertex_index != ss->active_vertex_index) {
- update_previews = true;
- }
-
- float rds;
- if (!BKE_brush_use_locked_size(scene, brush)) {
- rds = paint_calc_object_space_radius(
- &vc, gi.location, BKE_brush_size_get(scene, brush));
- }
- else {
- rds = BKE_brush_unprojected_radius_get(scene, brush);
- }
-
- wmViewport(&region->winrct);
-
- /* Draw 3D active vertex preview with symmetry. */
- if (len_v3v3(gi.active_vertex_co, gi.location) < rds) {
- cursor_draw_point_with_symmetry(pos, region, gi.active_vertex_co, sd, vc.obact, rds);
- }
-
- /* Draw pose brush origins. */
- if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
- immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f);
-
- /* Just after switching to the Pose Brush, the active vertex can be the same and the
- * cursor won't be tagged to update, so always initialize the preview chain if it is
- * null before drawing it. */
- if (update_previews || !ss->pose_ik_chain_preview) {
- BKE_sculpt_update_object_for_edit(depsgraph, vc.obact, true, false, false);
-
- /* Free the previous pose brush preview. */
- if (ss->pose_ik_chain_preview) {
- SCULPT_pose_ik_chain_free(ss->pose_ik_chain_preview);
- }
-
- /* Generate a new pose brush preview from the current cursor location. */
- ss->pose_ik_chain_preview = SCULPT_pose_ik_chain_init(
- sd, vc.obact, ss, brush, gi.location, rds);
- }
-
- /* Draw the pose brush rotation origins. */
- for (int i = 0; i < ss->pose_ik_chain_preview->tot_segments; i++) {
- cursor_draw_point_screen_space(pos,
- region,
- ss->pose_ik_chain_preview->segments[i].initial_orig,
- vc.obact->obmat,
- 3);
- }
- }
-
- /* Draw 3D brush cursor. */
- GPU_matrix_push_projection();
- ED_view3d_draw_setup_view(wm,
- CTX_wm_window(C),
- CTX_data_depsgraph_pointer(C),
- CTX_data_scene(C),
- region,
- CTX_wm_view3d(C),
- NULL,
- NULL,
- NULL);
-
- float cursor_trans[4][4], cursor_rot[4][4];
- float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f};
- float quat[4];
-
- copy_m4_m4(cursor_trans, vc.obact->obmat);
- translate_m4(cursor_trans, gi.location[0], gi.location[1], gi.location[2]);
- rotation_between_vecs_to_quat(quat, z_axis, gi.normal);
- quat_to_mat4(cursor_rot, quat);
-
- GPU_matrix_push();
- GPU_matrix_mul(cursor_trans);
- GPU_matrix_mul(cursor_rot);
- immUniformColor3fvAlpha(outline_col, outline_alpha);
- GPU_line_width(2.0f);
- imm_draw_circle_wire_3d(pos, 0, 0, rds, 80);
-
- GPU_line_width(1.0f);
- immUniformColor3fvAlpha(outline_col, outline_alpha * 0.5f);
- imm_draw_circle_wire_3d(pos, 0, 0, rds * clamp_f(brush->alpha, 0.0f, 1.0f), 80);
- GPU_matrix_pop();
-
- /* Cloth brush simulation areas. */
- if (brush->sculpt_tool == SCULPT_TOOL_CLOTH) {
- GPU_matrix_push();
- const float white[3] = {1.0f, 1.0f, 1.0f};
- SCULPT_cloth_simulation_limits_draw(
- pos, brush, vc.obact->obmat, gi.location, gi.normal, rds, 1.0f, white, 0.25f);
- GPU_matrix_pop();
- }
-
- /* Layer brush height. */
- if (brush->sculpt_tool == SCULPT_TOOL_LAYER) {
- GPU_matrix_push();
- SCULPT_layer_brush_height_preview_draw(pos,
- brush,
- vc.obact->obmat,
- gi.location,
- gi.normal,
- rds,
- 1.0f,
- outline_col,
- outline_alpha);
- GPU_matrix_pop();
- }
-
- /* Update and draw dynamic mesh preview lines. */
- GPU_matrix_push();
- GPU_matrix_mul(vc.obact->obmat);
- if (brush->sculpt_tool == SCULPT_TOOL_GRAB && (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX) &&
- !is_multires) {
- if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && ss->deform_modifiers_active) {
- SCULPT_geometry_preview_lines_update(C, ss, rds);
- sculpt_geometry_preview_lines_draw(pos, ss);
- }
- }
-
- /* Draw pose brush line preview. */
- if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
- immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f);
- GPU_line_width(2.0f);
-
- immBegin(GPU_PRIM_LINES, ss->pose_ik_chain_preview->tot_segments * 2);
- for (int i = 0; i < ss->pose_ik_chain_preview->tot_segments; i++) {
- immVertex3fv(pos, ss->pose_ik_chain_preview->segments[i].initial_orig);
- immVertex3fv(pos, ss->pose_ik_chain_preview->segments[i].initial_head);
- }
-
- immEnd();
- }
-
- GPU_matrix_pop();
-
- GPU_matrix_pop_projection();
-
- wmWindowViewport(win);
- }
- else {
- /* Draw default cursor when the mouse is not over the mesh or there are no supported
- * overlays active. */
- GPU_line_width(1.0f);
- /* Reduce alpha to increase the contrast when the cursor is over the mesh. */
- immUniformColor3fvAlpha(outline_col, outline_alpha * 0.8);
- imm_draw_circle_wire_3d(pos, translation[0], translation[1], final_radius, 80);
- immUniformColor3fvAlpha(outline_col, outline_alpha * 0.35f);
- imm_draw_circle_wire_3d(pos,
- translation[0],
- translation[1],
- final_radius * clamp_f(brush->alpha, 0.0f, 1.0f),
- 80);
- }
- }
- else {
- if (vc.obact->sculpt->cache &&
- !SCULPT_stroke_is_first_brush_step_of_symmetry_pass(vc.obact->sculpt->cache)) {
- wmViewport(&region->winrct);
-
- /* Draw cached dynamic mesh preview lines. */
- if (brush->sculpt_tool == SCULPT_TOOL_GRAB && (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX) &&
- !is_multires) {
- if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && ss->deform_modifiers_active) {
- GPU_matrix_push_projection();
- ED_view3d_draw_setup_view(wm,
- CTX_wm_window(C),
- CTX_data_depsgraph_pointer(C),
- CTX_data_scene(C),
- region,
- CTX_wm_view3d(C),
- NULL,
- NULL,
- NULL);
- GPU_matrix_push();
- GPU_matrix_mul(vc.obact->obmat);
- sculpt_geometry_preview_lines_draw(pos, ss);
- GPU_matrix_pop();
- GPU_matrix_pop_projection();
- }
- }
-
- if (brush->sculpt_tool == SCULPT_TOOL_MULTIPLANE_SCRAPE &&
- brush->flag2 & BRUSH_MULTIPLANE_SCRAPE_PLANES_PREVIEW &&
- !SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) {
- GPU_matrix_push_projection();
- ED_view3d_draw_setup_view(wm,
- CTX_wm_window(C),
- CTX_data_depsgraph_pointer(C),
- CTX_data_scene(C),
- region,
- CTX_wm_view3d(C),
- NULL,
- NULL,
- NULL);
- GPU_matrix_push();
- GPU_matrix_mul(vc.obact->obmat);
- SCULPT_multiplane_scrape_preview_draw(pos, ss, outline_col, outline_alpha);
- GPU_matrix_pop();
- GPU_matrix_pop_projection();
- }
-
- if (brush->sculpt_tool == SCULPT_TOOL_CLOTH &&
- !SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) {
- GPU_matrix_push_projection();
- ED_view3d_draw_setup_view(CTX_wm_manager(C),
- CTX_wm_window(C),
- CTX_data_depsgraph_pointer(C),
- CTX_data_scene(C),
- region,
- CTX_wm_view3d(C),
- NULL,
- NULL,
- NULL);
-
- /* Plane falloff preview */
- if (brush->cloth_force_falloff_type == BRUSH_CLOTH_FORCE_FALLOFF_PLANE) {
- GPU_matrix_push();
- GPU_matrix_mul(vc.obact->obmat);
- SCULPT_cloth_plane_falloff_preview_draw(pos, ss, outline_col, outline_alpha);
- GPU_matrix_pop();
- }
-
- /* Display the simulation limits if sculpting outside them. */
- /* This does not makes much sense of plane fallof as the fallof is infinte. */
- else if (brush->cloth_force_falloff_type == BRUSH_CLOTH_FORCE_FALLOFF_RADIAL) {
- if (len_v3v3(ss->cache->true_location, ss->cache->true_initial_location) >
- ss->cache->radius * (1.0f + brush->cloth_sim_limit)) {
- const float red[3] = {1.0f, 0.2f, 0.2f};
- GPU_matrix_push();
- SCULPT_cloth_simulation_limits_draw(pos,
- brush,
- vc.obact->obmat,
- ss->cache->true_initial_location,
- ss->cache->true_initial_normal,
- ss->cache->radius,
- 2.0f,
- red,
- 0.8f);
- GPU_matrix_pop();
- }
- }
-
- GPU_matrix_pop_projection();
- }
-
- wmWindowViewport(win);
- }
+ else if (brush->cloth_force_falloff_type == BRUSH_CLOTH_FORCE_FALLOFF_RADIAL &&
+ brush->cloth_simulation_area_type == BRUSH_CLOTH_SIMULATION_AREA_LOCAL) {
+ /* Display the simulation limits if sculpting outside them. */
+ /* This does not makes much sense of plane fallof as the fallof is infinte or global. */
+
+ if (len_v3v3(ss->cache->true_location, ss->cache->true_initial_location) >
+ ss->cache->radius * (1.0f + brush->cloth_sim_limit)) {
+ const float red[3] = {1.0f, 0.2f, 0.2f};
+ SCULPT_cloth_simulation_limits_draw(pcontext->pos,
+ brush,
+ ss->cache->true_initial_location,
+ ss->cache->true_initial_normal,
+ ss->cache->radius,
+ 2.0f,
+ red,
+ 0.8f);
}
}
- else {
- /* Draw default cursor in unsupported modes. */
- GPU_line_width(1.0f);
- imm_draw_circle_wire_3d(pos, translation[0], translation[1], final_radius, 40);
+ }
+
+ GPU_matrix_pop();
+
+ /* This Cloth brush cursor overlay always works in cursor space. */
+ paint_cursor_drawing_setup_cursor_space(pcontext);
+
+ GPU_matrix_pop_projection();
+ wmWindowViewport(pcontext->win);
+}
+
+static void paint_cursor_draw_3D_view_brush_cursor(PaintCursorContext *pcontext)
+{
+
+ /* These paint tools are not using the SculptSession, so they need to use the default 2D brush
+ * cursor in the 3D view. */
+ if (pcontext->mode != PAINT_MODE_SCULPT || !pcontext->ss) {
+ paint_draw_legacy_3D_view_brush_cursor(pcontext);
+ return;
+ }
+
+ paint_cursor_sculpt_session_update_and_init(pcontext);
+
+ if (pcontext->is_stroke_active) {
+ paint_cursor_cursor_draw_3d_view_brush_cursor_active(pcontext);
+ }
+ else {
+ paint_cursor_draw_3d_view_brush_cursor_inactive(pcontext);
+ }
+}
+
+static bool paint_cursor_is_3d_view_navigating(PaintCursorContext *pcontext)
+{
+ ViewContext *vc = &pcontext->vc;
+ return vc->rv3d && (vc->rv3d->rflag & RV3D_NAVIGATING);
+}
+
+static bool paint_cursor_is_brush_cursor_enabled(PaintCursorContext *pcontext)
+{
+ if (pcontext->paint->flags & PAINT_SHOW_BRUSH) {
+ if (ELEM(pcontext->mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D) &&
+ pcontext->brush->imagepaint_tool == PAINT_TOOL_FILL) {
+ return false;
}
+ return true;
}
+ return false;
+}
- immUnbindProgram();
+static void paint_cursor_update_rake_rotation(PaintCursorContext *pcontext)
+{
+ /* Don't calculate rake angles while a stroke is active because the rake variables are global
+ * and we may get interference with the stroke itself.
+ * For line strokes, such interference is visible. */
+ if (!pcontext->ups->stroke_active) {
+ paint_calculate_rake_rotation(pcontext->ups, pcontext->brush, pcontext->translation);
+ }
+}
+
+static void paint_cursor_check_and_draw_alpha_overlays(PaintCursorContext *pcontext)
+{
+ pcontext->alpha_overlay_drawn = paint_draw_alpha_overlay(pcontext->ups,
+ pcontext->brush,
+ &pcontext->vc,
+ pcontext->x,
+ pcontext->y,
+ pcontext->zoomx,
+ pcontext->mode);
+}
+
+static void paint_cursor_update_anchored_location(PaintCursorContext *pcontext)
+{
+ UnifiedPaintSettings *ups = pcontext->ups;
+ if (ups->draw_anchored) {
+ pcontext->final_radius = ups->anchored_size;
+ copy_v2_fl2(pcontext->translation,
+ ups->anchored_initial_mouse[0] + pcontext->region->winrct.xmin,
+ ups->anchored_initial_mouse[1] + pcontext->region->winrct.ymin);
+ }
+}
+
+static void paint_cursor_setup_2D_drawing(PaintCursorContext *pcontext)
+{
+ GPU_line_width(2.0f);
+ GPU_blend(true);
+ GPU_line_smooth(true);
+ pcontext->pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+}
+
+static void paint_cursor_setup_3D_drawing(PaintCursorContext *pcontext)
+{
+ GPU_line_width(2.0f);
+ GPU_blend(true);
+ GPU_line_smooth(true);
+ pcontext->pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+}
- /* Restore GL state. */
+static void paint_cursor_restore_drawing_state(void)
+{
+ immUnbindProgram();
GPU_blend(false);
GPU_line_smooth(false);
}
+static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
+{
+ PaintCursorContext pcontext;
+ if (!paint_cursor_context_init(C, x, y, &pcontext)) {
+ return;
+ }
+
+ if (!paint_cursor_is_brush_cursor_enabled(&pcontext)) {
+ return;
+ }
+ if (paint_cursor_is_3d_view_navigating(&pcontext)) {
+ return;
+ }
+
+ switch (pcontext.cursor_type) {
+ case PAINT_CURSOR_CURVE:
+ paint_draw_curve_cursor(pcontext.brush, &pcontext.vc);
+ break;
+ case PAINT_CURSOR_2D:
+ paint_cursor_update_rake_rotation(&pcontext);
+ paint_cursor_check_and_draw_alpha_overlays(&pcontext);
+ paint_cursor_update_anchored_location(&pcontext);
+
+ paint_cursor_setup_2D_drawing(&pcontext);
+ paint_draw_2D_view_brush_cursor(&pcontext);
+ paint_cursor_restore_drawing_state();
+ break;
+ case PAINT_CURSOR_3D:
+ paint_update_mouse_cursor(&pcontext);
+
+ paint_cursor_update_rake_rotation(&pcontext);
+ paint_cursor_check_and_draw_alpha_overlays(&pcontext);
+ paint_cursor_update_anchored_location(&pcontext);
+
+ paint_cursor_setup_3D_drawing(&pcontext);
+ paint_cursor_draw_3D_view_brush_cursor(&pcontext);
+ paint_cursor_restore_drawing_state();
+ break;
+ }
+}
+
/* Public API */
void paint_cursor_start(Paint *p, bool (*poll)(bContext *C))
diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c
index 74e022bf84f..458f021ddb4 100644
--- a/source/blender/editors/sculpt_paint/paint_curve.c
+++ b/source/blender/editors/sculpt_paint/paint_curve.c
@@ -193,7 +193,7 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2])
PaintCurvePoint *pcp;
wmWindow *window = CTX_wm_window(C);
ARegion *region = CTX_wm_region(C);
- float vec[3] = {loc[0], loc[1], 0.0};
+ const float vec[3] = {loc[0], loc[1], 0.0};
int add_index;
int i;
@@ -251,7 +251,7 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2])
static int paintcurve_add_point_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- int loc[2] = {event->mval[0], event->mval[1]};
+ const int loc[2] = {event->mval[0], event->mval[1]};
paintcurve_point_add(C, op, loc);
RNA_int_set_array(op->ptr, "location", loc);
return OPERATOR_FINISHED;
@@ -480,7 +480,7 @@ static bool paintcurve_point_select(
static int paintcurve_select_point_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- int loc[2] = {UNPACK2(event->mval)};
+ const int loc[2] = {UNPACK2(event->mval)};
bool toggle = RNA_boolean_get(op->ptr, "toggle");
bool extend = RNA_boolean_get(op->ptr, "extend");
if (paintcurve_point_select(C, op, loc, toggle, extend)) {
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 7f64fdf3501..431ab998f62 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -74,7 +74,6 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "GPU_draw.h"
#include "GPU_immediate.h"
#include "GPU_state.h"
@@ -182,7 +181,7 @@ void imapaint_image_update(
int h = imapaintpartial.y2 - imapaintpartial.y1;
if (w && h) {
/* Testing with partial update in uv editor too */
- GPU_paint_update_image(image, iuser, imapaintpartial.x1, imapaintpartial.y1, w, h);
+ BKE_image_update_gputexture(image, iuser, imapaintpartial.x1, imapaintpartial.y1, w, h);
}
}
}
@@ -1118,7 +1117,6 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
void ED_object_texture_paint_mode_enter_ex(Main *bmain, Scene *scene, Object *ob)
{
- bScreen *screen;
Image *ima = NULL;
ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
@@ -1142,17 +1140,16 @@ void ED_object_texture_paint_mode_enter_ex(Main *bmain, Scene *scene, Object *ob
}
if (ima) {
- for (screen = bmain->screens.first; screen; screen = screen->id.next) {
- ScrArea *area;
- for (area = screen->areabase.first; area; area = area->next) {
- SpaceLink *sl;
- for (sl = area->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
-
- if (!sima->pin) {
- ED_space_image_set(bmain, sima, NULL, ima, true);
- }
+ wmWindowManager *wm = bmain->wm.first;
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ const bScreen *screen = WM_window_get_active_screen(win);
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ SpaceLink *sl = area->spacedata.first;
+ if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+
+ if (!sima->pin) {
+ ED_space_image_set(bmain, sima, NULL, ima, true);
}
}
}
@@ -1166,9 +1163,9 @@ void ED_object_texture_paint_mode_enter_ex(Main *bmain, Scene *scene, Object *ob
BKE_paint_toolslots_brush_validate(bmain, &imapaint->paint);
if (U.glreslimit != 0) {
- GPU_free_images(bmain);
+ BKE_image_free_all_gputextures(bmain);
}
- GPU_paint_set_mipmap(bmain, 0);
+ BKE_image_paint_set_mipmap(bmain, 0);
toggle_paint_cursor(scene, true);
@@ -1191,9 +1188,9 @@ void ED_object_texture_paint_mode_exit_ex(Main *bmain, Scene *scene, Object *ob)
ob->mode &= ~OB_MODE_TEXTURE_PAINT;
if (U.glreslimit != 0) {
- GPU_free_images(bmain);
+ BKE_image_free_all_gputextures(bmain);
}
- GPU_paint_set_mipmap(bmain, 1);
+ BKE_image_paint_set_mipmap(bmain, 1);
toggle_paint_cursor(scene, false);
Mesh *me = BKE_mesh_from_object(ob);
@@ -1336,7 +1333,7 @@ void ED_imapaint_bucket_fill(struct bContext *C,
ED_image_undo_push_begin(op->type->name, PAINT_MODE_TEXTURE_2D);
- float mouse_init[2] = {mouse[0], mouse[1]};
+ const float mouse_init[2] = {mouse[0], mouse[1]};
paint_2d_bucket_fill(C, color, NULL, mouse_init, NULL, NULL);
ED_image_undo_push_end();
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index a7f09390a3d..d614c800350 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -57,8 +57,6 @@
#include "UI_view2d.h"
-#include "GPU_draw.h"
-
#include "paint_intern.h"
/* Brush Painting for 2D image editor */
@@ -1784,7 +1782,7 @@ void paint_2d_redraw(const bContext *C, void *ps, bool final)
if (final) {
if (s->image && !(s->sima && s->sima->lock)) {
- GPU_free_image(s->image);
+ BKE_image_free_gputextures(s->image);
}
/* compositor listener deals with updating */
@@ -2165,7 +2163,7 @@ void paint_2d_gradient_fill(
for (x_px = 0; x_px < ibuf->x; x_px++) {
for (y_px = 0; y_px < ibuf->y; y_px++) {
float f;
- float p[2] = {x_px - image_init[0], y_px - image_init[1]};
+ const float p[2] = {x_px - image_init[0], y_px - image_init[1]};
switch (br->gradient_fill_mode) {
case BRUSH_GRADIENT_LINEAR: {
@@ -2193,7 +2191,7 @@ void paint_2d_gradient_fill(
for (x_px = 0; x_px < ibuf->x; x_px++) {
for (y_px = 0; y_px < ibuf->y; y_px++) {
float f;
- float p[2] = {x_px - image_init[0], y_px - image_init[1]};
+ const float p[2] = {x_px - image_init[0], y_px - image_init[1]};
switch (br->gradient_fill_mode) {
case BRUSH_GRADIENT_LINEAR: {
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 5af3a3f4241..db7de01bee5 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -100,8 +100,6 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
-#include "GPU_draw.h"
-
#include "IMB_colormanagement.h"
//#include "bmesh_tools.h"
@@ -1385,7 +1383,7 @@ static void insert_seam_vert_array(const ProjPaintState *ps,
const int fidx[2] = {fidx1, ((fidx1 + 1) % 3)};
float vec[2];
- VertSeam *vseam = BLI_memarena_alloc(arena, sizeof(VertSeam) * 2);
+ VertSeam *vseam = BLI_memarena_alloc(arena, sizeof(VertSeam[2]));
vseam->prev = NULL;
vseam->next = NULL;
@@ -2787,10 +2785,10 @@ static void project_bucket_clip_face(const bool is_ortho,
}
if (flip) {
- qsort(isectVCosSS, *tot, sizeof(float) * 3, float_z_sort_flip);
+ qsort(isectVCosSS, *tot, sizeof(float[3]), float_z_sort_flip);
}
else {
- qsort(isectVCosSS, *tot, sizeof(float) * 3, float_z_sort);
+ qsort(isectVCosSS, *tot, sizeof(float[3]), float_z_sort);
}
doubles = true;
@@ -2930,7 +2928,7 @@ static void project_bucket_clip_face(const bool is_ortho,
/* checks if pt is inside a convex 2D polyline, the polyline must be ordered rotating clockwise
* otherwise it would have to test for mixed (line_point_side_v2 > 0.0f) cases */
-static bool IsectPoly2Df(const float pt[2], float uv[][2], const int tot)
+static bool IsectPoly2Df(const float pt[2], const float uv[][2], const int tot)
{
int i;
if (line_point_side_v2(uv[tot - 1], uv[0], pt) < 0.0f) {
@@ -2945,7 +2943,7 @@ static bool IsectPoly2Df(const float pt[2], float uv[][2], const int tot)
return true;
}
-static bool IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot)
+static bool IsectPoly2Df_twoside(const float pt[2], const float uv[][2], const int tot)
{
const bool side = (line_point_side_v2(uv[tot - 1], uv[0], pt) > 0.0f);
@@ -3311,7 +3309,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
has_x_isect = 0;
for (x = bounds_px.xmin; x < bounds_px.xmax; x++) {
- float puv[2] = {(float)x, (float)y};
+ const float puv[2] = {(float)x, (float)y};
bool in_bounds;
// uv[0] = (((float)x) + 0.5f) / (float)ibuf->x;
/* use offset uvs instead */
@@ -3874,7 +3872,7 @@ static void proj_paint_state_cavity_init(ProjPaintState *ps)
if (ps->do_mask_cavity) {
int *counter = MEM_callocN(sizeof(int) * ps->totvert_eval, "counter");
- float(*edges)[3] = MEM_callocN(sizeof(float) * 3 * ps->totvert_eval, "edges");
+ float(*edges)[3] = MEM_callocN(sizeof(float[3]) * ps->totvert_eval, "edges");
ps->cavities = MEM_mallocN(sizeof(float) * ps->totvert_eval, "ProjectPaint Cavities");
cavities = ps->cavities;
@@ -5758,7 +5756,7 @@ void paint_proj_stroke(const bContext *C,
View3D *v3d = CTX_wm_view3d(C);
ARegion *region = CTX_wm_region(C);
float *cursor = scene->cursor.location;
- int mval_i[2] = {(int)pos[0], (int)pos[1]};
+ const int mval_i[2] = {(int)pos[0], (int)pos[1]};
view3d_operator_needs_opengl(C);
@@ -6125,8 +6123,8 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- float pos[2] = {0.0, 0.0};
- float lastpos[2] = {0.0, 0.0};
+ const float pos[2] = {0.0, 0.0};
+ const float lastpos[2] = {0.0, 0.0};
int a;
project_paint_op(&ps, lastpos, pos);
@@ -6134,7 +6132,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
project_image_refresh_tagged(&ps);
for (a = 0; a < ps.image_tot; a++) {
- GPU_free_image(ps.projImages[a].ima);
+ BKE_image_free_gputextures(ps.projImages[a].ima);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ps.projImages[a].ima);
}
@@ -6175,7 +6173,7 @@ static bool texture_paint_image_from_view_poll(bContext *C)
CTX_wm_operator_poll_msg_set(C, "No 3D viewport found to create image from");
return false;
}
- if (G.background || !GPU_is_initialized()) {
+ if (G.background || !GPU_is_init()) {
return false;
}
return true;
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 0d4e957c77b..65f78a2d988 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -21,8 +21,7 @@
* \ingroup edsculpt
*/
-#ifndef __PAINT_INTERN_H__
-#define __PAINT_INTERN_H__
+#pragma once
struct ARegion;
struct Brush;
@@ -341,6 +340,7 @@ typedef enum {
void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot);
void PAINT_OT_mask_lasso_gesture(struct wmOperatorType *ot);
+void PAINT_OT_mask_box_gesture(struct wmOperatorType *ot);
/* paint_curve.c */
void PAINTCURVE_OT_new(struct wmOperatorType *ot);
@@ -366,5 +366,3 @@ void paint_delete_blur_kernel(BlurKernel *);
/* paint curve defines */
#define PAINT_CURVE_NUM_SEGMENTS 40
-
-#endif /* __PAINT_INTERN_H__ */
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 6e0402fc6e0..05ffb80d8a1 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -25,6 +25,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
+#include "DNA_vec_types.h"
#include "BLI_bitmap_draw_2d.h"
#include "BLI_lasso_2d.h"
@@ -99,6 +100,9 @@ typedef struct MaskTaskData {
PaintMaskFloodMode mode;
float value;
float (*clip_planes_final)[4];
+
+ bool front_faces_only;
+ float view_normal[3];
} MaskTaskData;
static void mask_flood_fill_task_cb(void *__restrict userdata,
@@ -264,9 +268,15 @@ static void mask_box_select_task_cb(void *__restrict userdata,
bool any_masked = false;
bool redraw = false;
+ float vertex_normal[3];
+
BKE_pbvh_vertex_iter_begin(data->pbvh, node, vi, PBVH_ITER_UNIQUE)
{
- if (is_effected(clip_planes_final, vi.co)) {
+ SCULPT_vertex_normal_get(data->ob->sculpt, vi.index, vertex_normal);
+ float dot = dot_v3v3(data->view_normal, vertex_normal);
+ const bool is_effected_front_face = !(data->front_faces_only && dot < 0.0f);
+
+ if (is_effected_front_face && is_effected(clip_planes_final, vi.co)) {
float prevmask = *vi.mask;
if (!any_masked) {
any_masked = true;
@@ -290,27 +300,33 @@ static void mask_box_select_task_cb(void *__restrict userdata,
}
}
-bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *rect, bool select)
+static int paint_mask_gesture_box_exec(bContext *C, wmOperator *op)
{
+ ViewContext vc;
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- Sculpt *sd = vc->scene->toolsettings->sculpt;
+ ED_view3d_viewcontext_init(C, &vc, depsgraph);
+
+ Sculpt *sd = vc.scene->toolsettings->sculpt;
BoundBox bb;
float clip_planes[4][4];
float clip_planes_final[4][4];
- ARegion *region = vc->region;
- Object *ob = vc->obact;
- PaintMaskFloodMode mode;
+ ARegion *region = vc.region;
+ Object *ob = vc.obact;
bool multires;
PBVH *pbvh;
PBVHNode **nodes;
int totnode;
int symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
- mode = PAINT_MASK_FLOOD_VALUE;
- float value = select ? 1.0f : 0.0f;
+ const PaintMaskFloodMode mode = RNA_enum_get(op->ptr, "mode");
+ const float value = RNA_float_get(op->ptr, "value");
+ const bool front_faces_only = RNA_boolean_get(op->ptr, "use_front_faces_only");
+
+ rcti rect;
+ WM_operator_properties_border_to_rcti(op, &rect);
/* Transform the clip planes in object space. */
- ED_view3d_clipping_calc(&bb, clip_planes, vc->region, vc->obact, rect);
+ ED_view3d_clipping_calc(&bb, clip_planes, vc.region, vc.obact, &rect);
BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true, false);
pbvh = ob->sculpt->pbvh;
@@ -318,6 +334,16 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *
SCULPT_undo_push_begin("Mask box fill");
+ /* Calculate the view normal in object space. */
+ float mat[3][3];
+ float view_dir[3] = {0.0f, 0.0f, 1.0f};
+ float true_view_normal[3];
+ copy_m3_m4(mat, vc.rv3d->viewinv);
+ mul_m3_v3(mat, view_dir);
+ copy_m3_m4(mat, ob->imat);
+ mul_m3_v3(mat, view_dir);
+ normalize_v3_v3(true_view_normal, view_dir);
+
for (int symmpass = 0; symmpass <= symm; symmpass++) {
if (symmpass == 0 || (symm & symmpass && (symm != 5 || symmpass != 3) &&
(symm != 6 || (symmpass != 3 && symmpass != 5)))) {
@@ -340,8 +366,11 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *
.mode = mode,
.value = value,
.clip_planes_final = clip_planes_final,
+ .front_faces_only = front_faces_only,
};
+ flip_v3_v3(data.view_normal, true_view_normal, symmpass);
+
TaskParallelSettings settings;
BKE_pbvh_parallel_range_settings(&settings, true, totnode);
BLI_task_parallel_range(0, totnode, &data, mask_box_select_task_cb, &settings);
@@ -383,7 +412,7 @@ typedef struct LassoMaskData {
* Lasso select. This could be defined as part of #VIEW3D_OT_select_lasso,
* still the shortcuts conflict, so we will use a separate operator.
*/
-static bool is_effected_lasso(LassoMaskData *data, float co[3])
+static bool is_effected_lasso(LassoMaskData *data, const float co[3])
{
float scr_co_f[2];
int scr_co_s[2];
@@ -433,9 +462,15 @@ static void mask_gesture_lasso_task_cb(void *__restrict userdata,
PBVHVertexIter vi;
bool any_masked = false;
+ float vertex_normal[3];
+
BKE_pbvh_vertex_iter_begin(data->pbvh, node, vi, PBVH_ITER_UNIQUE)
{
- if (is_effected_lasso(lasso_data, vi.co)) {
+ SCULPT_vertex_normal_get(data->ob->sculpt, vi.index, vertex_normal);
+ float dot = dot_v3v3(lasso_data->task_data.view_normal, vertex_normal);
+ const bool is_effected_front_face = !(data->front_faces_only && dot < 0.0f);
+
+ if (is_effected_front_face && is_effected_lasso(lasso_data, vi.co)) {
if (!any_masked) {
any_masked = true;
@@ -473,6 +508,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
bool multires;
PaintMaskFloodMode mode = RNA_enum_get(op->ptr, "mode");
float value = RNA_float_get(op->ptr, "value");
+ const bool front_faces_only = RNA_boolean_get(op->ptr, "use_front_faces_only");
/* Calculations of individual vertices are done in 2D screen space to diminish the amount of
* calculations done. Bounding box PBVH collision is not computed against enclosing rectangle
@@ -505,6 +541,16 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
SCULPT_undo_push_begin("Mask lasso fill");
+ /* Calculate the view normal in object space. */
+ float mat[3][3];
+ float view_dir[3] = {0.0f, 0.0f, 1.0f};
+ float true_view_normal[3];
+ copy_m3_m4(mat, vc.rv3d->viewinv);
+ mul_m3_v3(mat, view_dir);
+ copy_m3_m4(mat, ob->imat);
+ mul_m3_v3(mat, view_dir);
+ normalize_v3_v3(true_view_normal, view_dir);
+
for (int symmpass = 0; symmpass <= symm; symmpass++) {
if ((symmpass == 0) || (symm & symmpass && (symm != 5 || symmpass != 3) &&
(symm != 6 || (symmpass != 3 && symmpass != 5)))) {
@@ -514,6 +560,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
flip_plane(clip_planes_final[j], clip_planes[j], symmpass);
}
+ flip_v3_v3(data.task_data.view_normal, true_view_normal, symmpass);
+
data.symmpass = symmpass;
/* Gather nodes inside lasso's enclosing rectangle
@@ -530,6 +578,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
data.task_data.multires = multires;
data.task_data.mode = mode;
data.task_data.value = value;
+ data.task_data.front_faces_only = front_faces_only;
TaskParallelSettings settings;
BKE_pbvh_parallel_range_settings(&settings, true, totnode);
@@ -588,4 +637,44 @@ void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot)
"Mask level to use when mode is 'Value'; zero means no masking and one is fully masked",
0.0f,
1.0f);
+ RNA_def_boolean(ot->srna,
+ "use_front_faces_only",
+ false,
+ "Front Faces Only",
+ "Affect only faces facing towards the view");
+}
+
+void PAINT_OT_mask_box_gesture(wmOperatorType *ot)
+{
+ ot->name = "Mask Box Gesture";
+ ot->idname = "PAINT_OT_mask_box_gesture";
+ ot->description = "Add mask within the box as you move the brush";
+
+ ot->invoke = WM_gesture_box_invoke;
+ ot->modal = WM_gesture_box_modal;
+ ot->exec = paint_mask_gesture_box_exec;
+
+ ot->poll = SCULPT_mode_poll;
+
+ ot->flag = OPTYPE_REGISTER;
+
+ /* Properties. */
+ WM_operator_properties_border(ot);
+
+ RNA_def_enum(ot->srna, "mode", mode_items, PAINT_MASK_FLOOD_VALUE, "Mode", NULL);
+ RNA_def_float(
+ ot->srna,
+ "value",
+ 1.0f,
+ 0.0f,
+ 1.0f,
+ "Value",
+ "Mask level to use when mode is 'Value'; zero means no masking and one is fully masked",
+ 0.0f,
+ 1.0f);
+ RNA_def_boolean(ot->srna,
+ "use_front_faces_only",
+ false,
+ "Front Faces Only",
+ "Affect only faces facing towards the view");
}
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index d65f158174f..43ff03ea7e2 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -913,7 +913,7 @@ static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *ev
{
Paint *paint = BKE_paint_get_active_from_context(C);
Brush *br = BKE_paint_brush(paint);
- float mvalf[2] = {event->mval[0], event->mval[1]};
+ const float mvalf[2] = {event->mval[0], event->mval[1]};
ARegion *region = CTX_wm_region(C);
StencilControlData *scd;
int mask = RNA_enum_get(op->ptr, "texmode");
@@ -968,7 +968,7 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2]
#define PIXEL_MARGIN 5
float mdiff[2];
- float mvalf[2] = {mval[0], mval[1]};
+ const float mvalf[2] = {mval[0], mval[1]};
switch (scd->mode) {
case STENCIL_TRANSLATE:
sub_v2_v2v2(mdiff, mvalf, scd->init_mouse);
@@ -1356,6 +1356,7 @@ void ED_operatortypes_paint(void)
/* paint masking */
WM_operatortype_append(PAINT_OT_mask_flood_fill);
WM_operatortype_append(PAINT_OT_mask_lasso_gesture);
+ WM_operatortype_append(PAINT_OT_mask_box_gesture);
}
void ED_keymap_paint(wmKeyConfig *keyconf)
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index caecc7b708a..90b0f017bd6 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -225,6 +225,7 @@ static bool paint_tool_require_location(Brush *brush, ePaintMode mode)
SCULPT_TOOL_GRAB,
SCULPT_TOOL_ELASTIC_DEFORM,
SCULPT_TOOL_POSE,
+ SCULPT_TOOL_BOUNDARY,
SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK,
SCULPT_TOOL_THUMB)) {
@@ -265,6 +266,7 @@ static bool paint_tool_require_inbetween_mouse_events(Brush *brush, ePaintMode m
SCULPT_TOOL_SNAKE_HOOK,
SCULPT_TOOL_ELASTIC_DEFORM,
SCULPT_TOOL_CLOTH,
+ SCULPT_TOOL_BOUNDARY,
SCULPT_TOOL_POSE)) {
return false;
}
@@ -920,9 +922,9 @@ PaintStroke *paint_stroke_new(bContext *C,
ups->average_stroke_counter = 0;
/* initialize here to avoid initialization conflict with threaded strokes */
- BKE_curvemapping_initialize(br->curve);
+ BKE_curvemapping_init(br->curve);
if (p->flags & PAINT_USE_CAVITY_MASK) {
- BKE_curvemapping_initialize(p->cavity_curve);
+ BKE_curvemapping_init(p->cavity_curve);
}
BKE_paint_set_overlay_override(br->overlay_flags);
@@ -1008,6 +1010,7 @@ static bool sculpt_is_grab_tool(Brush *br)
SCULPT_TOOL_GRAB,
SCULPT_TOOL_ELASTIC_DEFORM,
SCULPT_TOOL_POSE,
+ SCULPT_TOOL_BOUNDARY,
SCULPT_TOOL_THUMB,
SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK);
@@ -1198,7 +1201,10 @@ static void paint_line_strokes_spacing(bContext *C,
*length_residue = length;
}
-static void paint_stroke_line_end(bContext *C, wmOperator *op, PaintStroke *stroke, float mouse[2])
+static void paint_stroke_line_end(bContext *C,
+ wmOperator *op,
+ PaintStroke *stroke,
+ const float mouse[2])
{
Brush *br = stroke->brush;
if (stroke->stroke_started && (br->flag & BRUSH_LINE)) {
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 6c5d6f4ee4e..b7e5a73cbb3 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -169,7 +169,7 @@ float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool *
{
float intensity;
float rgba_dummy[4];
- float co[3] = {u, v, 0.0f};
+ const float co[3] = {u, v, 0.0f};
RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba_dummy);
@@ -185,7 +185,7 @@ void paint_get_tex_pixel_col(const MTex *mtex,
bool convert_to_linear,
struct ColorSpace *colorspace)
{
- float co[3] = {u, v, 0.0f};
+ const float co[3] = {u, v, 0.0f};
float intensity;
const bool hasrgb = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
@@ -238,7 +238,7 @@ void paint_stroke_operator_properties(wmOperatorType *ot)
/* 3D Paint */
-static void imapaint_project(float matrix[4][4], const float co[3], float pco[4])
+static void imapaint_project(const float matrix[4][4], const float co[3], float pco[4])
{
copy_v3_v3(pco, co);
pco[3] = 1.0f;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index 6965946d2ce..73014f9f2de 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -757,8 +757,8 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
int y_start = RNA_int_get(op->ptr, "ystart");
int x_end = RNA_int_get(op->ptr, "xend");
int y_end = RNA_int_get(op->ptr, "yend");
- float sco_start[2] = {x_start, y_start};
- float sco_end[2] = {x_end, y_end};
+ const float sco_start[2] = {x_start, y_start};
+ const float sco_end[2] = {x_end, y_end};
const bool is_interactive = (gesture != NULL);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
@@ -811,7 +811,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
VPaint *wp = ts->wpaint;
struct Brush *brush = BKE_paint_brush(&wp->paint);
- BKE_curvemapping_initialize(brush->curve);
+ BKE_curvemapping_init(brush->curve);
data.brush = brush;
data.weightpaint = BKE_brush_weight_get(scene, brush);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 590d04bed3d..c87189997f2 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -196,7 +196,7 @@ void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3])
}
}
-static const float *sculpt_vertex_persistent_co_get(SculptSession *ss, int index)
+const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, int index)
{
if (ss->persistent_base) {
return ss->persistent_base[index].co;
@@ -204,7 +204,7 @@ static const float *sculpt_vertex_persistent_co_get(SculptSession *ss, int index
return SCULPT_vertex_co_get(ss, index);
}
-static void sculpt_vertex_persistent_normal_get(SculptSession *ss, int index, float no[3])
+void SCULPT_vertex_persistent_normal_get(SculptSession *ss, int index, float no[3])
{
if (ss->persistent_base) {
copy_v3_v3(no, ss->persistent_base[index].no);
@@ -581,7 +581,8 @@ static bool sculpt_check_unique_face_set_for_edge_in_base_mesh(SculptSession *ss
p1 = vert_map->indices[i];
break;
}
- else if (p2 == -1) {
+
+ if (p2 == -1) {
p2 = vert_map->indices[i];
break;
}
@@ -1125,6 +1126,7 @@ static bool sculpt_tool_needs_original(const char sculpt_tool)
SCULPT_TOOL_DRAW_SHARP,
SCULPT_TOOL_ELASTIC_DEFORM,
SCULPT_TOOL_SMOOTH,
+ SCULPT_TOOL_BOUNDARY,
SCULPT_TOOL_POSE);
}
@@ -1134,6 +1136,7 @@ static bool sculpt_tool_is_proxy_used(const char sculpt_tool)
SCULPT_TOOL_SMOOTH,
SCULPT_TOOL_LAYER,
SCULPT_TOOL_POSE,
+ SCULPT_TOOL_BOUNDARY,
SCULPT_TOOL_CLOTH,
SCULPT_TOOL_PAINT,
SCULPT_TOOL_SMEAR,
@@ -2337,6 +2340,7 @@ static float brush_strength(const Sculpt *sd,
case SCULPT_TOOL_ELASTIC_DEFORM:
case SCULPT_TOOL_POSE:
+ case SCULPT_TOOL_BOUNDARY:
return root_alpha * feather;
default:
@@ -2966,7 +2970,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
/* XXX - this shouldn't be necessary, but sculpting crashes in blender2.8 otherwise
* initialize before threads so they can do curve mapping. */
- BKE_curvemapping_initialize(brush->curve);
+ BKE_curvemapping_init(brush->curve);
/* Threaded loop over nodes. */
SculptThreadedTaskData data = {
@@ -3043,7 +3047,7 @@ static void do_draw_sharp_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
/* XXX - this shouldn't be necessary, but sculpting crashes in blender2.8 otherwise
* initialize before threads so they can do curve mapping. */
- BKE_curvemapping_initialize(brush->curve);
+ BKE_curvemapping_init(brush->curve);
/* Threaded loop over nodes. */
SculptThreadedTaskData data = {
@@ -3273,7 +3277,7 @@ static void do_slide_relax_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
return;
}
- BKE_curvemapping_initialize(brush->curve);
+ BKE_curvemapping_init(brush->curve);
SculptThreadedTaskData data = {
.sd = sd,
@@ -4341,9 +4345,9 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata,
float normal[3];
if (use_persistent_base) {
- sculpt_vertex_persistent_normal_get(ss, vi, normal);
+ SCULPT_vertex_persistent_normal_get(ss, vi, normal);
mul_v3_fl(normal, brush->height);
- madd_v3_v3v3fl(final_co, sculpt_vertex_persistent_co_get(ss, vi), normal, *disp_factor);
+ madd_v3_v3v3fl(final_co, SCULPT_vertex_persistent_co_get(ss, vi), normal, *disp_factor);
}
else {
normal_short_to_float_v3(normal, orig_data.no);
@@ -5509,19 +5513,28 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
/* Pose needs all nodes because it applies all symmetry iterations at the same time and the IK
* chain can grow to any area of the model. */
/* This can be optimized by filtering the nodes after calculating the chain. */
- if (ELEM(brush->sculpt_tool, SCULPT_TOOL_ELASTIC_DEFORM, SCULPT_TOOL_POSE)) {
+ if (ELEM(brush->sculpt_tool,
+ SCULPT_TOOL_ELASTIC_DEFORM,
+ SCULPT_TOOL_POSE,
+ SCULPT_TOOL_BOUNDARY)) {
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
}
else if (brush->sculpt_tool == SCULPT_TOOL_CLOTH) {
- SculptSearchSphereData data = {
- .ss = ss,
- .sd = sd,
- .radius_squared = square_f(ss->cache->radius * (1.0 + brush->cloth_sim_limit)),
- .original = false,
- .ignore_fully_ineffective = false,
- .center = ss->cache->initial_location,
- };
- BKE_pbvh_search_gather(ss->pbvh, SCULPT_search_sphere_cb, &data, &nodes, &totnode);
+ if (brush->cloth_simulation_area_type == BRUSH_CLOTH_SIMULATION_AREA_LOCAL) {
+ SculptSearchSphereData data = {
+ .ss = ss,
+ .sd = sd,
+ .radius_squared = square_f(ss->cache->initial_radius * (1.0 + brush->cloth_sim_limit)),
+ .original = false,
+ .ignore_fully_ineffective = false,
+ .center = ss->cache->initial_location,
+ };
+ BKE_pbvh_search_gather(ss->pbvh, SCULPT_search_sphere_cb, &data, &nodes, &totnode);
+ }
+ else {
+ /* Gobal simulation, get all nodes. */
+ BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
+ }
}
else {
const bool use_original = sculpt_tool_needs_original(brush->sculpt_tool) ? true :
@@ -5683,6 +5696,9 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
case SCULPT_TOOL_SLIDE_RELAX:
do_slide_relax_brush(sd, ob, nodes, totnode);
break;
+ case SCULPT_TOOL_BOUNDARY:
+ SCULPT_do_boundary_brush(sd, ob, nodes, totnode);
+ break;
case SCULPT_TOOL_CLOTH:
SCULPT_do_cloth_brush(sd, ob, nodes, totnode);
break;
@@ -5717,8 +5733,10 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
}
/* The cloth brush adds the gravity as a regular force and it is processed in the solver. */
- if (ss->cache->supports_gravity &&
- !ELEM(brush->sculpt_tool, SCULPT_TOOL_CLOTH, SCULPT_TOOL_DRAW_FACE_SETS)) {
+ if (ss->cache->supports_gravity && !ELEM(brush->sculpt_tool,
+ SCULPT_TOOL_CLOTH,
+ SCULPT_TOOL_DRAW_FACE_SETS,
+ SCULPT_TOOL_BOUNDARY)) {
do_gravity(sd, ob, nodes, totnode, sd->gravity_factor);
}
@@ -5770,6 +5788,7 @@ static void sculpt_combine_proxies_task_cb(void *__restrict userdata,
SCULPT_TOOL_ROTATE,
SCULPT_TOOL_THUMB,
SCULPT_TOOL_ELASTIC_DEFORM,
+ SCULPT_TOOL_BOUNDARY,
SCULPT_TOOL_POSE);
PBVHVertexIter vd;
@@ -6231,6 +6250,8 @@ static const char *sculpt_tool_name(Sculpt *sd)
return "Multi-plane Scrape Brush";
case SCULPT_TOOL_SLIDE_RELAX:
return "Slide/Relax Brush";
+ case SCULPT_TOOL_BOUNDARY:
+ return "Boundary Brush";
case SCULPT_TOOL_CLOTH:
return "Cloth Brush";
case SCULPT_TOOL_DRAW_FACE_SETS:
@@ -6259,6 +6280,12 @@ void SCULPT_cache_free(StrokeCache *cache)
SCULPT_pose_ik_chain_free(cache->pose_ik_chain);
}
+ for (int i = 0; i < PAINT_SYMM_AREAS; i++) {
+ if (cache->bdata[i]) {
+ SCULPT_boundary_data_free(cache->bdata[i]);
+ }
+ }
+
if (cache->cloth_sim) {
SCULPT_cloth_simulation_free(cache->cloth_sim);
}
@@ -6390,7 +6417,7 @@ static void sculpt_update_cache_invariants(
brush = br;
cache->saved_smooth_size = BKE_brush_size_get(scene, brush);
BKE_brush_size_set(scene, brush, size);
- BKE_curvemapping_initialize(brush->curve);
+ BKE_curvemapping_init(brush->curve);
}
}
}
@@ -6458,7 +6485,7 @@ static void sculpt_update_cache_invariants(
#define PIXEL_INPUT_THRESHHOLD 5
if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) {
- cache->dial = BLI_dial_initialize(cache->initial_mouse, PIXEL_INPUT_THRESHHOLD);
+ cache->dial = BLI_dial_init(cache->initial_mouse, PIXEL_INPUT_THRESHHOLD);
}
#undef PIXEL_INPUT_THRESHHOLD
@@ -6487,6 +6514,7 @@ static bool sculpt_needs_delta_from_anchored_origin(Brush *brush)
return ELEM(brush->sculpt_tool,
SCULPT_TOOL_GRAB,
SCULPT_TOOL_POSE,
+ SCULPT_TOOL_BOUNDARY,
SCULPT_TOOL_THUMB,
SCULPT_TOOL_ELASTIC_DEFORM) ||
SCULPT_is_cloth_deform_brush(brush);
@@ -6530,6 +6558,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
SCULPT_TOOL_CLAY_THUMB,
SCULPT_TOOL_SNAKE_HOOK,
SCULPT_TOOL_POSE,
+ SCULPT_TOOL_BOUNDARY,
SCULPT_TOOL_THUMB) ||
sculpt_brush_use_topology_rake(ss, brush)) {
float grab_location[3], imat[4][4], delta[3], loc[3];
@@ -6818,6 +6847,7 @@ static bool sculpt_needs_connectivity_info(const Sculpt *sd,
(brush->sculpt_tool == SCULPT_TOOL_SMOOTH) || (brush->autosmooth_factor > 0) ||
((brush->sculpt_tool == SCULPT_TOOL_MASK) && (brush->mask_tool == BRUSH_MASK_SMOOTH)) ||
(brush->sculpt_tool == SCULPT_TOOL_POSE) ||
+ (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) ||
(brush->sculpt_tool == SCULPT_TOOL_SLIDE_RELAX) ||
(brush->sculpt_tool == SCULPT_TOOL_CLOTH) || (brush->sculpt_tool == SCULPT_TOOL_SMEAR) ||
(brush->sculpt_tool == SCULPT_TOOL_DRAW_FACE_SETS));
@@ -7208,11 +7238,16 @@ static void sculpt_restore_mesh(Sculpt *sd, Object *ob)
SculptSession *ss = ob->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
+ /* For the cloth brush it makes more sense to not restore the mesh state to keep running the
+ * simulation from the previous state. */
+ if (brush->sculpt_tool == SCULPT_TOOL_CLOTH) {
+ return;
+ }
+
/* Restore the mesh before continuing with anchored stroke. */
if ((brush->flag & BRUSH_ANCHORED) ||
((brush->sculpt_tool == SCULPT_TOOL_GRAB ||
- brush->sculpt_tool == SCULPT_TOOL_ELASTIC_DEFORM ||
- brush->sculpt_tool == SCULPT_TOOL_CLOTH) &&
+ brush->sculpt_tool == SCULPT_TOOL_ELASTIC_DEFORM) &&
BKE_brush_use_size_pressure(brush)) ||
(brush->flag & BRUSH_DRAG_DOT)) {
@@ -8155,6 +8190,14 @@ void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float
return;
}
+ if (!ss->deform_modifiers_active) {
+ return;
+ }
+
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+ return;
+ }
+
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, false);
if (!ss->pmap) {
@@ -8942,7 +8985,7 @@ static void SCULPT_OT_mask_by_color(wmOperatorType *ot)
"preserve_previous_mask",
false,
"Preserve Previous Mask",
- "Preserve the previous mask and add or substract the new one generated by the colors");
+ "Preserve the previous mask and add or subtract the new one generated by the colors");
RNA_def_float(ot->srna,
"threshold",
diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.c b/source/blender/editors/sculpt_paint/sculpt_boundary.c
new file mode 100644
index 00000000000..a368214cb0b
--- /dev/null
+++ b/source/blender/editors/sculpt_paint/sculpt_boundary.c
@@ -0,0 +1,865 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edsculpt
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_edgehash.h"
+#include "BLI_math.h"
+#include "BLI_task.h"
+
+#include "DNA_brush_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_ccg.h"
+#include "BKE_colortools.h"
+#include "BKE_context.h"
+#include "BKE_mesh.h"
+#include "BKE_multires.h"
+#include "BKE_node.h"
+#include "BKE_object.h"
+#include "BKE_paint.h"
+#include "BKE_pbvh.h"
+#include "BKE_scene.h"
+
+#include "paint_intern.h"
+#include "sculpt_intern.h"
+
+#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
+#include "GPU_matrix.h"
+#include "GPU_state.h"
+
+#include "bmesh.h"
+
+#include <math.h>
+#include <stdlib.h>
+
+#define BOUNDARY_VERTEX_NONE -1
+#define BOUNDARY_STEPS_NONE -1
+
+typedef struct BoundaryInitialVertexFloodFillData {
+ int initial_vertex;
+ int boundary_initial_vertex_steps;
+ int boundary_initial_vertex;
+ int *floodfill_steps;
+ float radius_sq;
+} BoundaryInitialVertexFloodFillData;
+
+static bool boundary_initial_vertex_floodfill_cb(
+ SculptSession *ss, int from_v, int to_v, bool is_duplicate, void *userdata)
+{
+ BoundaryInitialVertexFloodFillData *data = userdata;
+
+ if (!is_duplicate) {
+ data->floodfill_steps[to_v] = data->floodfill_steps[from_v] + 1;
+ }
+ else {
+ data->floodfill_steps[to_v] = data->floodfill_steps[from_v];
+ }
+
+ if (SCULPT_vertex_is_boundary(ss, to_v)) {
+ if (data->floodfill_steps[to_v] < data->boundary_initial_vertex_steps) {
+ data->boundary_initial_vertex_steps = data->floodfill_steps[to_v];
+ data->boundary_initial_vertex = to_v;
+ }
+ }
+
+ const float len_sq = len_squared_v3v3(SCULPT_vertex_co_get(ss, data->initial_vertex),
+ SCULPT_vertex_co_get(ss, to_v));
+ return len_sq < data->radius_sq;
+}
+
+/* From a vertex index anywhere in the mesh, returns the closest vertex in a mesh boundary inside
+ * the given radius, if it exists. */
+static int sculpt_boundary_get_closest_boundary_vertex(SculptSession *ss,
+ const int initial_vertex,
+ const float radius)
+{
+
+ if (SCULPT_vertex_is_boundary(ss, initial_vertex)) {
+ return initial_vertex;
+ }
+
+ SculptFloodFill flood;
+ SCULPT_floodfill_init(ss, &flood);
+ SCULPT_floodfill_add_initial(&flood, initial_vertex);
+
+ BoundaryInitialVertexFloodFillData fdata = {
+ .initial_vertex = initial_vertex,
+ .boundary_initial_vertex = BOUNDARY_VERTEX_NONE,
+ .boundary_initial_vertex_steps = INT_MAX,
+ .radius_sq = radius * radius,
+ };
+
+ fdata.floodfill_steps = MEM_calloc_arrayN(
+ SCULPT_vertex_count_get(ss), sizeof(int), "floodfill steps");
+
+ SCULPT_floodfill_execute(ss, &flood, boundary_initial_vertex_floodfill_cb, &fdata);
+ SCULPT_floodfill_free(&flood);
+
+ MEM_freeN(fdata.floodfill_steps);
+ return fdata.boundary_initial_vertex;
+}
+
+/* Used to allocate the memory of the boundary index arrays. This was decided considered the most
+ * common use cases for the brush deformers, taking into account how many vertices those
+ * deformations usually need in the boundary. */
+static int BOUNDARY_INDICES_BLOCK_SIZE = 300;
+
+static void sculpt_boundary_index_add(SculptBoundary *bdata,
+ const int new_index,
+ GSet *included_vertices)
+{
+
+ bdata->vertices[bdata->num_vertices] = new_index;
+ if (included_vertices) {
+ BLI_gset_add(included_vertices, POINTER_FROM_INT(new_index));
+ }
+ bdata->num_vertices++;
+ if (bdata->num_vertices >= bdata->vertices_capacity) {
+ bdata->vertices_capacity += BOUNDARY_INDICES_BLOCK_SIZE;
+ bdata->vertices = MEM_reallocN_id(
+ bdata->vertices, bdata->vertices_capacity * sizeof(int), "boundary indices");
+ }
+};
+
+static void sculpt_boundary_preview_edge_add(SculptBoundary *bdata, const int v1, const int v2)
+{
+
+ bdata->edges[bdata->num_edges].v1 = v1;
+ bdata->edges[bdata->num_edges].v2 = v2;
+ bdata->num_edges++;
+
+ if (bdata->num_edges >= bdata->edges_capacity) {
+ bdata->edges_capacity += BOUNDARY_INDICES_BLOCK_SIZE;
+ bdata->edges = MEM_reallocN_id(
+ bdata->edges, bdata->edges_capacity * sizeof(SculptBoundaryPreviewEdge), "boundary edges");
+ }
+};
+
+/**
+ * This function is used to check where the propagation should stop when calculating the boundary,
+ * as well as to check if the initial vertex is valid.
+ */
+static bool sculpt_boundary_is_vertex_in_editable_boundary(SculptSession *ss,
+ const int initial_vertex)
+{
+
+ int neighbor_count = 0;
+ int boundary_vertex_count = 0;
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, initial_vertex, ni) {
+ neighbor_count++;
+ if (SCULPT_vertex_is_boundary(ss, ni.index)) {
+ boundary_vertex_count++;
+ }
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+
+ /* Corners are ambiguous as it can't be decide which boundary should be active. The flood fill
+ * should also stop at corners. */
+ if (neighbor_count <= 2) {
+ return false;
+ }
+
+ /* Non manifold geometry in the mesh boundary.
+ * The deformation result will be unpredictable and not very useful. */
+ if (boundary_vertex_count > 2) {
+ return false;
+ }
+
+ return true;
+}
+
+/* Flood fill that adds to the boundary data all the vertices from a boundary and its duplicates.
+ */
+
+typedef struct BoundaryFloodFillData {
+ SculptBoundary *bdata;
+ GSet *included_vertices;
+ EdgeSet *preview_edges;
+
+ int last_visited_vertex;
+
+} BoundaryFloodFillData;
+
+static bool boundary_floodfill_cb(
+ SculptSession *ss, int from_v, int to_v, bool is_duplicate, void *userdata)
+{
+ BoundaryFloodFillData *data = userdata;
+ SculptBoundary *bdata = data->bdata;
+ if (SCULPT_vertex_is_boundary(ss, to_v)) {
+ sculpt_boundary_index_add(bdata, to_v, data->included_vertices);
+ if (!is_duplicate) {
+ sculpt_boundary_preview_edge_add(bdata, from_v, to_v);
+ }
+ return sculpt_boundary_is_vertex_in_editable_boundary(ss, to_v);
+ }
+ return false;
+}
+
+static void sculpt_boundary_indices_init(SculptSession *ss,
+ SculptBoundary *bdata,
+ const int initial_boundary_index)
+{
+
+ bdata->vertices = MEM_malloc_arrayN(
+ BOUNDARY_INDICES_BLOCK_SIZE, sizeof(int), "boundary indices");
+ bdata->edges = MEM_malloc_arrayN(
+ BOUNDARY_INDICES_BLOCK_SIZE, sizeof(SculptBoundaryPreviewEdge), "boundary edges");
+
+ GSet *included_vertices = BLI_gset_int_new_ex("included vertices", BOUNDARY_INDICES_BLOCK_SIZE);
+ SculptFloodFill flood;
+ SCULPT_floodfill_init(ss, &flood);
+
+ bdata->initial_vertex = initial_boundary_index;
+ copy_v3_v3(bdata->initial_vertex_position, SCULPT_vertex_co_get(ss, bdata->initial_vertex));
+ sculpt_boundary_index_add(bdata, initial_boundary_index, included_vertices);
+ SCULPT_floodfill_add_initial(&flood, initial_boundary_index);
+
+ BoundaryFloodFillData fdata = {
+ .bdata = bdata,
+ .included_vertices = included_vertices,
+ .last_visited_vertex = BOUNDARY_VERTEX_NONE,
+
+ };
+
+ SCULPT_floodfill_execute(ss, &flood, boundary_floodfill_cb, &fdata);
+ SCULPT_floodfill_free(&flood);
+
+ /* Check if the boundary loops into itself and add the extra preview edge to close the loop. */
+ if (fdata.last_visited_vertex != BOUNDARY_VERTEX_NONE &&
+ sculpt_boundary_is_vertex_in_editable_boundary(ss, fdata.last_visited_vertex)) {
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, fdata.last_visited_vertex, ni) {
+ if (BLI_gset_haskey(included_vertices, POINTER_FROM_INT(ni.index)) &&
+ sculpt_boundary_is_vertex_in_editable_boundary(ss, ni.index)) {
+ sculpt_boundary_preview_edge_add(bdata, fdata.last_visited_vertex, ni.index);
+ bdata->forms_loop = true;
+ }
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ }
+
+ BLI_gset_free(included_vertices, NULL);
+}
+
+/**
+ * This functions initializes all data needed to calculate falloffs and deformation from the
+ * boundary into the mesh into a #SculptBoundaryEditInfo array. This includes how many steps are
+ * needed to go from a boundary vertex to an interior vertex and which vertex of the boundary is
+ * the closest one.
+ */
+static void sculpt_boundary_edit_data_init(SculptSession *ss,
+ SculptBoundary *bdata,
+ const int initial_vertex,
+ const float radius)
+{
+ const int totvert = SCULPT_vertex_count_get(ss);
+
+ const bool has_duplicates = BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS;
+
+ bdata->edit_info = MEM_malloc_arrayN(
+ totvert, sizeof(SculptBoundaryEditInfo), "Boundary edit info");
+
+ for (int i = 0; i < totvert; i++) {
+ bdata->edit_info[i].original_vertex = BOUNDARY_VERTEX_NONE;
+ bdata->edit_info[i].num_propagation_steps = BOUNDARY_STEPS_NONE;
+ }
+
+ GSQueue *current_iteration = BLI_gsqueue_new(sizeof(int));
+ GSQueue *next_iteration = BLI_gsqueue_new(sizeof(int));
+
+ /* Initialized the first iteration with the vertices already in the boundary. This is propagation
+ * step 0. */
+ BLI_bitmap *visited_vertices = BLI_BITMAP_NEW(SCULPT_vertex_count_get(ss), "visited_vertices");
+ for (int i = 0; i < bdata->num_vertices; i++) {
+ bdata->edit_info[bdata->vertices[i]].original_vertex = bdata->vertices[i];
+ bdata->edit_info[bdata->vertices[i]].num_propagation_steps = 0;
+
+ /* This ensures that all duplicate vertices in the boundary have the same original_vertex
+ * index, so the deformation for them will be the same. */
+ if (has_duplicates) {
+ SculptVertexNeighborIter ni_duplis;
+ SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN (ss, bdata->vertices[i], ni_duplis) {
+ if (ni_duplis.is_duplicate) {
+ bdata->edit_info[ni_duplis.index].original_vertex = bdata->vertices[i];
+ }
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni_duplis);
+ }
+
+ BLI_gsqueue_push(current_iteration, &bdata->vertices[i]);
+ }
+
+ int num_propagation_steps = 0;
+ float accum_distance = 0.0f;
+
+ while (true) {
+ /* This steps is further away from the boundary than the brush radius, so stop adding more
+ * steps. */
+ if (accum_distance > radius) {
+ bdata->max_propagation_steps = num_propagation_steps;
+ break;
+ }
+
+ while (!BLI_gsqueue_is_empty(current_iteration)) {
+ int from_v;
+ BLI_gsqueue_pop(current_iteration, &from_v);
+
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN (ss, from_v, ni) {
+ if (bdata->edit_info[ni.index].num_propagation_steps == BOUNDARY_STEPS_NONE) {
+ bdata->edit_info[ni.index].original_vertex = bdata->edit_info[from_v].original_vertex;
+
+ BLI_BITMAP_ENABLE(visited_vertices, ni.index);
+
+ if (ni.is_duplicate) {
+ /* Grids duplicates handling. */
+ bdata->edit_info[ni.index].num_propagation_steps =
+ bdata->edit_info[from_v].num_propagation_steps;
+ }
+ else {
+ bdata->edit_info[ni.index].num_propagation_steps =
+ bdata->edit_info[from_v].num_propagation_steps + 1;
+
+ BLI_gsqueue_push(next_iteration, &ni.index);
+
+ /* When copying the data to the neighbor for the next iteration, it has to be copied to
+ * all its duplicates too. This is because it is not possible to know if the updated
+ * neighbor or one if its uninitialized duplicates is going to come first in order to
+ * copy the data in the from_v neighbor iterator. */
+ if (has_duplicates) {
+ SculptVertexNeighborIter ni_duplis;
+ SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN (ss, ni.index, ni_duplis) {
+ if (ni_duplis.is_duplicate) {
+ bdata->edit_info[ni_duplis.index].original_vertex =
+ bdata->edit_info[from_v].original_vertex;
+ bdata->edit_info[ni_duplis.index].num_propagation_steps =
+ bdata->edit_info[from_v].num_propagation_steps + 1;
+ }
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni_duplis);
+ }
+
+ /* Check the distance using the vertex that was propagated from the initial vertex that
+ * was used to initialize the boundary. */
+ if (bdata->edit_info[from_v].original_vertex == initial_vertex) {
+ bdata->pivot_vertex = ni.index;
+ copy_v3_v3(bdata->initial_pivot_position, SCULPT_vertex_co_get(ss, ni.index));
+ accum_distance += len_v3v3(SCULPT_vertex_co_get(ss, from_v),
+ SCULPT_vertex_co_get(ss, ni.index));
+ }
+ }
+ }
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ }
+
+ /* Copy the new vertices to the queue to be processed in the next iteration. */
+ while (!BLI_gsqueue_is_empty(next_iteration)) {
+ int next_v;
+ BLI_gsqueue_pop(next_iteration, &next_v);
+ BLI_gsqueue_push(current_iteration, &next_v);
+ }
+
+ /* Stop if no vertices were added in this iteration. At this point, all the mesh should have
+ * been initialized with the edit data. */
+ if (BLI_gsqueue_is_empty(current_iteration)) {
+ break;
+ }
+
+ num_propagation_steps++;
+ }
+
+ MEM_SAFE_FREE(visited_vertices);
+
+ BLI_gsqueue_free(current_iteration);
+ BLI_gsqueue_free(next_iteration);
+}
+
+/* This functions assigns a falloff factor to each one of the SculptBoundaryEditInfo structs based
+ * on the brush curve and its propagation steps. The falloff goes from the boundary into the mesh.
+ */
+static void sculpt_boundary_falloff_factor_init(SculptSession *ss,
+ SculptBoundary *bdata,
+ Brush *brush)
+{
+ const int totvert = SCULPT_vertex_count_get(ss);
+ BKE_curvemapping_init(brush->curve);
+
+ for (int i = 0; i < totvert; i++) {
+ if (bdata->edit_info[i].num_propagation_steps != -1) {
+ bdata->edit_info[i].strength_factor = BKE_brush_curve_strength(
+ brush, bdata->edit_info[i].num_propagation_steps, bdata->max_propagation_steps);
+ }
+ }
+}
+
+/* Main function to get SculptBoundary data both for brush deformation and viewport preview. Can
+ * return NULL if there is no boundary from the given vertex using the given radius. */
+SculptBoundary *SCULPT_boundary_data_init(Object *object,
+ const int initial_vertex,
+ const float radius)
+{
+ SculptSession *ss = object->sculpt;
+
+ SCULPT_vertex_random_access_init(ss);
+ SCULPT_boundary_info_ensure(object);
+
+ const int boundary_initial_vertex = sculpt_boundary_get_closest_boundary_vertex(
+ ss, initial_vertex, radius);
+
+ if (boundary_initial_vertex == BOUNDARY_VERTEX_NONE) {
+ return NULL;
+ }
+
+ /* Starting from a vertex that is the limit of a boundary is ambiguous, so return NULL instead of
+ * forcing a random active boundary from a corner. */
+ if (!sculpt_boundary_is_vertex_in_editable_boundary(ss, initial_vertex)) {
+ return NULL;
+ }
+
+ SculptBoundary *bdata = MEM_callocN(sizeof(SculptBoundary), "Boundary edit data");
+
+ sculpt_boundary_indices_init(ss, bdata, boundary_initial_vertex);
+ sculpt_boundary_edit_data_init(ss, bdata, boundary_initial_vertex, radius);
+
+ return bdata;
+}
+
+void SCULPT_boundary_data_free(SculptBoundary *bdata)
+{
+ MEM_SAFE_FREE(bdata->vertices);
+ MEM_SAFE_FREE(bdata->edit_info);
+ MEM_SAFE_FREE(bdata->bend.pivot_positions);
+ MEM_SAFE_FREE(bdata->bend.pivot_rotation_axis);
+ MEM_SAFE_FREE(bdata->slide.directions);
+ MEM_SAFE_FREE(bdata);
+}
+
+/* These functions initialize the required vectors for the desired deformation using the
+ * SculptBoundaryEditInfo. They calculate the data using the vertices that have the
+ * max_propagation_steps value and them this data is copied to the rest of the vertices using the
+ * original vertex index. */
+static void sculpt_boundary_bend_data_init(SculptSession *ss, SculptBoundary *bdata)
+{
+ const int totvert = SCULPT_vertex_count_get(ss);
+ bdata->bend.pivot_rotation_axis = MEM_calloc_arrayN(
+ totvert, 3 * sizeof(float), "pivot rotation axis");
+ bdata->bend.pivot_positions = MEM_calloc_arrayN(totvert, 3 * sizeof(float), "pivot positions");
+
+ for (int i = 0; i < totvert; i++) {
+ if (bdata->edit_info[i].num_propagation_steps == bdata->max_propagation_steps) {
+ float dir[3];
+ float normal[3];
+ SCULPT_vertex_normal_get(ss, i, normal);
+ sub_v3_v3v3(dir,
+ SCULPT_vertex_co_get(ss, bdata->edit_info[i].original_vertex),
+ SCULPT_vertex_co_get(ss, i));
+ cross_v3_v3v3(
+ bdata->bend.pivot_rotation_axis[bdata->edit_info[i].original_vertex], dir, normal);
+ normalize_v3(bdata->bend.pivot_rotation_axis[bdata->edit_info[i].original_vertex]);
+ copy_v3_v3(bdata->bend.pivot_positions[bdata->edit_info[i].original_vertex],
+ SCULPT_vertex_co_get(ss, i));
+ }
+ }
+
+ for (int i = 0; i < totvert; i++) {
+ if (bdata->edit_info[i].num_propagation_steps != BOUNDARY_STEPS_NONE) {
+ copy_v3_v3(bdata->bend.pivot_positions[i],
+ bdata->bend.pivot_positions[bdata->edit_info[i].original_vertex]);
+ copy_v3_v3(bdata->bend.pivot_rotation_axis[i],
+ bdata->bend.pivot_rotation_axis[bdata->edit_info[i].original_vertex]);
+ }
+ }
+}
+
+static void sculpt_boundary_slide_data_init(SculptSession *ss, SculptBoundary *bdata)
+{
+ const int totvert = SCULPT_vertex_count_get(ss);
+ bdata->slide.directions = MEM_calloc_arrayN(totvert, 3 * sizeof(float), "slide directions");
+
+ for (int i = 0; i < totvert; i++) {
+ if (bdata->edit_info[i].num_propagation_steps == bdata->max_propagation_steps) {
+ sub_v3_v3v3(bdata->slide.directions[bdata->edit_info[i].original_vertex],
+ SCULPT_vertex_co_get(ss, bdata->edit_info[i].original_vertex),
+ SCULPT_vertex_co_get(ss, i));
+ normalize_v3(bdata->slide.directions[bdata->edit_info[i].original_vertex]);
+ }
+ }
+
+ for (int i = 0; i < totvert; i++) {
+ if (bdata->edit_info[i].num_propagation_steps != BOUNDARY_STEPS_NONE) {
+ copy_v3_v3(bdata->slide.directions[i],
+ bdata->slide.directions[bdata->edit_info[i].original_vertex]);
+ }
+ }
+}
+
+static void sculpt_boundary_twist_data_init(SculptSession *ss, SculptBoundary *bdata)
+{
+ zero_v3(bdata->twist.pivot_position);
+ float(*poly_verts)[3] = MEM_malloc_arrayN(bdata->num_vertices, sizeof(float) * 3, "poly verts");
+ for (int i = 0; i < bdata->num_vertices; i++) {
+ add_v3_v3(bdata->twist.pivot_position, SCULPT_vertex_co_get(ss, bdata->vertices[i]));
+ copy_v3_v3(poly_verts[i], SCULPT_vertex_co_get(ss, bdata->vertices[i]));
+ }
+ mul_v3_fl(bdata->twist.pivot_position, 1.0f / bdata->num_vertices);
+ if (bdata->forms_loop) {
+ normal_poly_v3(bdata->twist.rotation_axis, poly_verts, bdata->num_vertices);
+ }
+ else {
+ sub_v3_v3v3(bdata->twist.rotation_axis,
+ SCULPT_vertex_co_get(ss, bdata->pivot_vertex),
+ SCULPT_vertex_co_get(ss, bdata->initial_vertex));
+ normalize_v3(bdata->twist.rotation_axis);
+ }
+ MEM_freeN(poly_verts);
+}
+
+static float sculpt_boundary_displacement_from_grab_delta_get(SculptSession *ss,
+ SculptBoundary *bdata)
+{
+ float plane[4];
+ float pos[3];
+ float normal[3];
+ sub_v3_v3v3(normal, ss->cache->initial_location, bdata->initial_pivot_position);
+ normalize_v3(normal);
+ plane_from_point_normal_v3(plane, ss->cache->initial_location, normal);
+ add_v3_v3v3(pos, ss->cache->initial_location, ss->cache->grab_delta_symmetry);
+ return dist_signed_to_plane_v3(pos, plane);
+}
+
+/* Deformation tasks callbacks. */
+static void do_boundary_brush_bend_task_cb_ex(void *__restrict userdata,
+ const int n,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ const int symm_area = ss->cache->mirror_symmetry_pass;
+ SculptBoundary *bdata = ss->cache->bdata[symm_area];
+
+ const float strength = ss->cache->bstrength;
+
+ PBVHVertexIter vd;
+ SculptOrigVertData orig_data;
+ SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]);
+
+ const float disp = strength * sculpt_boundary_displacement_from_grab_delta_get(ss, bdata);
+ float angle_factor = disp / ss->cache->radius;
+ /* Angle Snapping when inverting the brush. */
+ if (ss->cache->invert) {
+ angle_factor = floorf(angle_factor * 10) / 10.0f;
+ }
+ const float angle = angle_factor * M_PI;
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+
+ if (bdata->edit_info[vd.index].num_propagation_steps != -1) {
+ SCULPT_orig_vert_data_update(&orig_data, &vd);
+ const float mask = vd.mask ? 1.0f - *vd.mask : 1.0f;
+ float t_orig_co[3];
+ sub_v3_v3v3(t_orig_co, orig_data.co, bdata->bend.pivot_positions[vd.index]);
+ rotate_v3_v3v3fl(vd.co,
+ t_orig_co,
+ bdata->bend.pivot_rotation_axis[vd.index],
+ angle * bdata->edit_info[vd.index].strength_factor * mask);
+ add_v3_v3(vd.co, bdata->bend.pivot_positions[vd.index]);
+ }
+
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void do_boundary_brush_slide_task_cb_ex(void *__restrict userdata,
+ const int n,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ const int symm_area = ss->cache->mirror_symmetry_pass;
+ SculptBoundary *bdata = ss->cache->bdata[symm_area];
+
+ const float strength = ss->cache->bstrength;
+
+ PBVHVertexIter vd;
+ SculptOrigVertData orig_data;
+ SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]);
+
+ const float disp = sculpt_boundary_displacement_from_grab_delta_get(ss, bdata);
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+
+ if (bdata->edit_info[vd.index].num_propagation_steps != -1) {
+ SCULPT_orig_vert_data_update(&orig_data, &vd);
+ const float mask = vd.mask ? 1.0f - *vd.mask : 1.0f;
+ madd_v3_v3v3fl(vd.co,
+ orig_data.co,
+ bdata->slide.directions[vd.index],
+ bdata->edit_info[vd.index].strength_factor * disp * mask * strength);
+ }
+
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void do_boundary_brush_inflate_task_cb_ex(void *__restrict userdata,
+ const int n,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ const int symm_area = ss->cache->mirror_symmetry_pass;
+ SculptBoundary *bdata = ss->cache->bdata[symm_area];
+
+ const float strength = ss->cache->bstrength;
+
+ PBVHVertexIter vd;
+ SculptOrigVertData orig_data;
+ SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]);
+
+ const float disp = sculpt_boundary_displacement_from_grab_delta_get(ss, bdata);
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+
+ if (bdata->edit_info[vd.index].num_propagation_steps != -1) {
+ SCULPT_orig_vert_data_update(&orig_data, &vd);
+ const float mask = vd.mask ? 1.0f - *vd.mask : 1.0f;
+ float normal[3];
+ normal_short_to_float_v3(normal, orig_data.no);
+ madd_v3_v3v3fl(vd.co,
+ orig_data.co,
+ normal,
+ bdata->edit_info[vd.index].strength_factor * disp * mask * strength);
+ }
+
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void do_boundary_brush_grab_task_cb_ex(void *__restrict userdata,
+ const int n,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ const int symm_area = ss->cache->mirror_symmetry_pass;
+ SculptBoundary *bdata = ss->cache->bdata[symm_area];
+
+ const float strength = ss->cache->bstrength;
+
+ PBVHVertexIter vd;
+ SculptOrigVertData orig_data;
+ SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]);
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+
+ if (bdata->edit_info[vd.index].num_propagation_steps != -1) {
+ SCULPT_orig_vert_data_update(&orig_data, &vd);
+ const float mask = vd.mask ? 1.0f - *vd.mask : 1.0f;
+ madd_v3_v3v3fl(vd.co,
+ orig_data.co,
+ ss->cache->grab_delta_symmetry,
+ bdata->edit_info[vd.index].strength_factor * mask * strength);
+ }
+
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+static void do_boundary_brush_twist_task_cb_ex(void *__restrict userdata,
+ const int n,
+ const TaskParallelTLS *__restrict UNUSED(tls))
+{
+ SculptThreadedTaskData *data = userdata;
+ SculptSession *ss = data->ob->sculpt;
+ const int symm_area = ss->cache->mirror_symmetry_pass;
+ SculptBoundary *bdata = ss->cache->bdata[symm_area];
+
+ const float strength = ss->cache->bstrength;
+
+ PBVHVertexIter vd;
+ SculptOrigVertData orig_data;
+ SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]);
+
+ const float disp = strength * sculpt_boundary_displacement_from_grab_delta_get(ss, bdata);
+ float angle_factor = disp / ss->cache->radius;
+ /* Angle Snapping when inverting the brush. */
+ if (ss->cache->invert) {
+ angle_factor = floorf(angle_factor * 10) / 10.0f;
+ }
+ const float angle = angle_factor * M_PI;
+
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+
+ if (bdata->edit_info[vd.index].num_propagation_steps != -1) {
+ const float mask = vd.mask ? 1.0f - *vd.mask : 1.0f;
+ SCULPT_orig_vert_data_update(&orig_data, &vd);
+ float t_orig_co[3];
+ sub_v3_v3v3(t_orig_co, orig_data.co, bdata->twist.pivot_position);
+ rotate_v3_v3v3fl(vd.co,
+ t_orig_co,
+ bdata->twist.rotation_axis,
+ angle * mask * bdata->edit_info[vd.index].strength_factor);
+ add_v3_v3(vd.co, bdata->twist.pivot_position);
+ }
+
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ BKE_pbvh_vertex_iter_end;
+}
+
+/* Main Brush Function. */
+void SCULPT_do_boundary_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
+{
+ SculptSession *ss = ob->sculpt;
+ Brush *brush = BKE_paint_brush(&sd->paint);
+
+ const int symm_area = ss->cache->mirror_symmetry_pass;
+ if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) {
+
+ int initial_vertex;
+ if (ss->cache->mirror_symmetry_pass == 0) {
+ initial_vertex = SCULPT_active_vertex_get(ss);
+ }
+ else {
+ float location[3];
+ flip_v3_v3(location, SCULPT_active_vertex_co_get(ss), symm_area);
+ initial_vertex = SCULPT_nearest_vertex_get(
+ sd, ob, location, ss->cache->radius_squared, false);
+ }
+
+ ss->cache->bdata[symm_area] = SCULPT_boundary_data_init(
+ ob, initial_vertex, ss->cache->initial_radius);
+
+ if (ss->cache->bdata[symm_area]) {
+
+ switch (brush->boundary_deform_type) {
+ case BRUSH_BOUNDARY_DEFORM_BEND:
+ sculpt_boundary_bend_data_init(ss, ss->cache->bdata[symm_area]);
+ break;
+ case BRUSH_BOUNDARY_DEFORM_EXPAND:
+ sculpt_boundary_slide_data_init(ss, ss->cache->bdata[symm_area]);
+ break;
+ case BRUSH_BOUNDARY_DEFORM_TWIST:
+ sculpt_boundary_twist_data_init(ss, ss->cache->bdata[symm_area]);
+ break;
+ case BRUSH_BOUNDARY_DEFORM_INFLATE:
+ case BRUSH_BOUNDARY_DEFORM_GRAB:
+ /* Do nothing. These deform modes don't need any extra data to be precomputed. */
+ break;
+ }
+
+ sculpt_boundary_falloff_factor_init(ss, ss->cache->bdata[symm_area], brush);
+ }
+ }
+
+ /* No active boundary under the cursor. */
+ if (!ss->cache->bdata[symm_area]) {
+ return;
+ }
+
+ SculptThreadedTaskData data = {
+ .sd = sd,
+ .ob = ob,
+ .brush = brush,
+ .nodes = nodes,
+ };
+
+ TaskParallelSettings settings;
+ BKE_pbvh_parallel_range_settings(&settings, true, totnode);
+
+ switch (brush->boundary_deform_type) {
+ case BRUSH_BOUNDARY_DEFORM_BEND:
+ BLI_task_parallel_range(0, totnode, &data, do_boundary_brush_bend_task_cb_ex, &settings);
+ break;
+ case BRUSH_BOUNDARY_DEFORM_EXPAND:
+ BLI_task_parallel_range(0, totnode, &data, do_boundary_brush_slide_task_cb_ex, &settings);
+ break;
+ case BRUSH_BOUNDARY_DEFORM_INFLATE:
+ BLI_task_parallel_range(0, totnode, &data, do_boundary_brush_inflate_task_cb_ex, &settings);
+ break;
+ case BRUSH_BOUNDARY_DEFORM_GRAB:
+ BLI_task_parallel_range(0, totnode, &data, do_boundary_brush_grab_task_cb_ex, &settings);
+ break;
+ case BRUSH_BOUNDARY_DEFORM_TWIST:
+ BLI_task_parallel_range(0, totnode, &data, do_boundary_brush_twist_task_cb_ex, &settings);
+ break;
+ }
+}
+
+void SCULPT_boundary_edges_preview_draw(const uint gpuattr,
+ SculptSession *ss,
+ const float outline_col[3],
+ const float outline_alpha)
+{
+ if (!ss->boundary_preview) {
+ return;
+ }
+ immUniformColor3fvAlpha(outline_col, outline_alpha);
+ GPU_line_width(2.0f);
+ immBegin(GPU_PRIM_LINES, ss->boundary_preview->num_edges * 2);
+ for (int i = 0; i < ss->boundary_preview->num_edges; i++) {
+ immVertex3fv(gpuattr, SCULPT_vertex_co_get(ss, ss->boundary_preview->edges[i].v1));
+ immVertex3fv(gpuattr, SCULPT_vertex_co_get(ss, ss->boundary_preview->edges[i].v2));
+ }
+ immEnd();
+}
+
+void SCULPT_boundary_pivot_line_preview_draw(const uint gpuattr, SculptSession *ss)
+{
+ if (!ss->boundary_preview) {
+ return;
+ }
+ immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f);
+ GPU_line_width(2.0f);
+ immBegin(GPU_PRIM_LINES, 2);
+ immVertex3fv(gpuattr, SCULPT_vertex_co_get(ss, ss->boundary_preview->pivot_vertex));
+ immVertex3fv(gpuattr, SCULPT_vertex_co_get(ss, ss->boundary_preview->initial_vertex));
+ immEnd();
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index 6a2137b6626..7d318760476 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -43,7 +43,9 @@
#include "DNA_scene_types.h"
#include "BKE_brush.h"
+#include "BKE_bvhutils.h"
#include "BKE_ccg.h"
+#include "BKE_collision.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_image.h"
@@ -69,6 +71,7 @@
#include "BKE_subsurf.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "WM_api.h"
#include "WM_message.h"
@@ -85,7 +88,6 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "GPU_draw.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
@@ -101,6 +103,33 @@
#include <stdlib.h>
#include <string.h>
+static float cloth_brush_simulation_falloff_get(const Brush *brush,
+ const float radius,
+ const float location[3],
+ const float co[3])
+{
+ /* Global simulation does not have any falloff as the entire mesh is being simulated. */
+ if (brush->cloth_simulation_area_type == BRUSH_CLOTH_SIMULATION_AREA_GLOBAL) {
+ return 1.0f;
+ }
+
+ const float distance = len_v3v3(location, co);
+ const float limit = radius + (radius * brush->cloth_sim_limit);
+ const float falloff = radius + (radius * brush->cloth_sim_limit * brush->cloth_sim_falloff);
+
+ if (distance > limit) {
+ /* Outiside the limits. */
+ return 0.0f;
+ }
+ if (distance < falloff) {
+ /* Before the falloff area. */
+ return 1.0f;
+ }
+ /* Do a smoothstep transition inside the falloff area. */
+ float p = 1.0f - ((distance - falloff) / (limit - falloff));
+ return 3.0f * p * p - 2.0f * p * p * p;
+}
+
#define CLOTH_LENGTH_CONSTRAINTS_BLOCK 100000
#define CLOTH_SIMULATION_ITERATIONS 5
#define CLOTH_MAX_CONSTRAINTS_PER_VERTEX 1024
@@ -113,19 +142,8 @@ static bool cloth_brush_sim_has_length_constraint(SculptClothSimulation *cloth_s
return BLI_edgeset_haskey(cloth_sim->created_length_constraints, v1, v2);
}
-static void cloth_brush_add_length_constraint(SculptSession *ss,
- SculptClothSimulation *cloth_sim,
- const int v1,
- const int v2)
+static void cloth_brush_reallocate_constraints(SculptClothSimulation *cloth_sim)
{
- cloth_sim->length_constraints[cloth_sim->tot_length_constraints].v1 = v1;
- cloth_sim->length_constraints[cloth_sim->tot_length_constraints].v2 = v2;
- cloth_sim->length_constraints[cloth_sim->tot_length_constraints].length = len_v3v3(
- SCULPT_vertex_co_get(ss, v1), SCULPT_vertex_co_get(ss, v2));
-
- cloth_sim->tot_length_constraints++;
-
- /* Reallocation if the array capacity is exceeded. */
if (cloth_sim->tot_length_constraints >= cloth_sim->capacity_length_constraints) {
cloth_sim->capacity_length_constraints += CLOTH_LENGTH_CONSTRAINTS_BLOCK;
cloth_sim->length_constraints = MEM_reallocN_id(cloth_sim->length_constraints,
@@ -133,23 +151,119 @@ static void cloth_brush_add_length_constraint(SculptSession *ss,
sizeof(SculptClothLengthConstraint),
"length constraints");
}
+}
+
+static void cloth_brush_add_length_constraint(SculptSession *ss,
+ SculptClothSimulation *cloth_sim,
+ const int v1,
+ const int v2,
+ const bool use_persistent)
+{
+ SculptClothLengthConstraint *length_constraint =
+ &cloth_sim->length_constraints[cloth_sim->tot_length_constraints];
+
+ length_constraint->elem_index_a = v1;
+ length_constraint->elem_index_b = v2;
+
+ length_constraint->elem_position_a = cloth_sim->pos[v1];
+ length_constraint->elem_position_b = cloth_sim->pos[v2];
+
+ if (use_persistent) {
+ length_constraint->length = len_v3v3(SCULPT_vertex_persistent_co_get(ss, v1),
+ SCULPT_vertex_persistent_co_get(ss, v2));
+ }
+ else {
+ length_constraint->length = len_v3v3(SCULPT_vertex_co_get(ss, v1),
+ SCULPT_vertex_co_get(ss, v2));
+ }
+ length_constraint->strength = 1.0f;
+
+ cloth_sim->tot_length_constraints++;
+
+ /* Reallocation if the array capacity is exceeded. */
+ cloth_brush_reallocate_constraints(cloth_sim);
/* Add the constraint to the GSet to avoid creating it again. */
BLI_edgeset_add(cloth_sim->created_length_constraints, v1, v2);
}
+static void cloth_brush_add_softbody_constraint(SculptClothSimulation *cloth_sim,
+ const int v,
+ const float strength)
+{
+ SculptClothLengthConstraint *length_constraint =
+ &cloth_sim->length_constraints[cloth_sim->tot_length_constraints];
+
+ length_constraint->elem_index_a = v;
+ length_constraint->elem_index_b = v;
+
+ length_constraint->elem_position_a = cloth_sim->pos[v];
+ length_constraint->elem_position_b = cloth_sim->init_pos[v];
+
+ length_constraint->length = 0.0f;
+ length_constraint->strength = strength;
+
+ cloth_sim->tot_length_constraints++;
+
+ /* Reallocation if the array capacity is exceeded. */
+ cloth_brush_reallocate_constraints(cloth_sim);
+}
+
+static void cloth_brush_add_deformation_constraint(SculptClothSimulation *cloth_sim,
+ const int v,
+ const float strength)
+{
+ SculptClothLengthConstraint *length_constraint =
+ &cloth_sim->length_constraints[cloth_sim->tot_length_constraints];
+
+ length_constraint->elem_index_a = v;
+ length_constraint->elem_index_b = v;
+
+ length_constraint->elem_position_a = cloth_sim->pos[v];
+ length_constraint->elem_position_b = cloth_sim->deformation_pos[v];
+
+ length_constraint->length = 0.0f;
+ length_constraint->strength = strength;
+
+ cloth_sim->tot_length_constraints++;
+
+ /* Reallocation if the array capacity is exceeded. */
+ cloth_brush_reallocate_constraints(cloth_sim);
+}
+
static void do_cloth_brush_build_constraints_task_cb_ex(
void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
{
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
+ const Brush *brush = data->brush;
PBVHVertexIter vd;
+ const bool pin_simulation_boundary = ss->cache != NULL && brush != NULL &&
+ brush->flag2 & BRUSH_CLOTH_PIN_SIMULATION_BOUNDARY;
+
+ const bool use_persistent = brush != NULL && brush->flag & BRUSH_PERSISTENT;
+
+ /* Brush can be NULL in tools that use the solver without relying of constraints with deformation
+ * positions. */
+ const bool cloth_is_deform_brush = ss->cache != NULL && brush != NULL &&
+ SCULPT_is_cloth_deform_brush(brush);
+ float radius_squared = 0.0f;
+ if (cloth_is_deform_brush) {
+ radius_squared = ss->cache->initial_radius * ss->cache->initial_radius;
+ }
+
+ /* Only limit the contraint creation to a radius when the simulation is local. */
+ const float cloth_sim_radius_squared = brush->cloth_simulation_area_type ==
+ BRUSH_CLOTH_SIMULATION_AREA_LOCAL ?
+ data->cloth_sim_radius * data->cloth_sim_radius :
+ FLT_MAX;
+
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
- if (len_squared_v3v3(vd.co, data->cloth_sim_initial_location) <
- data->cloth_sim_radius * data->cloth_sim_radius) {
+ const float len_squared = len_squared_v3v3(vd.co, data->cloth_sim_initial_location);
+ if (len_squared < cloth_sim_radius_squared) {
SculptVertexNeighborIter ni;
int build_indices[CLOTH_MAX_CONSTRAINTS_PER_VERTEX];
@@ -162,6 +276,11 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
}
SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ if (brush->cloth_constraint_softbody_strength > 0.0f) {
+ cloth_brush_add_softbody_constraint(
+ data->cloth_sim, vd.index, brush->cloth_constraint_softbody_strength);
+ }
+
/* As we don't know the order of the neighbor vertices, we create all possible combinations
* between the neighbor and the original vertex as length constraints. */
/* This results on a pattern that contains structural, shear and bending constraints for all
@@ -172,35 +291,29 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
if (c_i != c_j && !cloth_brush_sim_has_length_constraint(
data->cloth_sim, build_indices[c_i], build_indices[c_j])) {
cloth_brush_add_length_constraint(
- ss, data->cloth_sim, build_indices[c_i], build_indices[c_j]);
+ ss, data->cloth_sim, build_indices[c_i], build_indices[c_j], use_persistent);
}
}
}
}
- }
- BKE_pbvh_vertex_iter_end;
-}
-static float cloth_brush_simulation_falloff_get(const Brush *brush,
- const float radius,
- const float location[3],
- const float co[3])
-{
- const float distance = len_v3v3(location, co);
- const float limit = radius + (radius * brush->cloth_sim_limit);
- const float falloff = radius + (radius * brush->cloth_sim_limit * brush->cloth_sim_falloff);
+ if (cloth_is_deform_brush && len_squared < radius_squared) {
+ const float fade = BKE_brush_curve_strength(brush, sqrtf(len_squared), ss->cache->radius);
+ cloth_brush_add_deformation_constraint(data->cloth_sim, vd.index, fade);
+ }
- if (distance > limit) {
- /* Outiside the limits. */
- return 0.0f;
- }
- if (distance < falloff) {
- /* Before the falloff area. */
- return 1.0f;
+ if (pin_simulation_boundary) {
+ const float sim_falloff = cloth_brush_simulation_falloff_get(
+ brush, ss->cache->initial_radius, ss->cache->location, vd.co);
+ /* Vertex is inside the area of the simulation without any falloff aplied. */
+ if (sim_falloff < 1.0f) {
+ /* Create constraints with more strength the closer the vertex is to the simulation
+ * boundary. */
+ cloth_brush_add_softbody_constraint(data->cloth_sim, vd.index, 1.0f - sim_falloff);
+ }
+ }
}
- /* Do a smoothstep transition inside the falloff area. */
- float p = 1.0f - ((distance - falloff) / (limit - falloff));
- return 3.0f * p * p - 2.0f * p * p * p;
+ BKE_pbvh_vertex_iter_end;
}
static void cloth_brush_apply_force_to_vertex(SculptSession *UNUSED(ss),
@@ -254,8 +367,7 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
/* Gravity */
float gravity[3] = {0.0f};
if (ss->cache->supports_gravity) {
- madd_v3_v3fl(
- gravity, ss->cache->gravity_direction, -ss->cache->radius * data->sd->gravity_factor);
+ madd_v3_v3fl(gravity, ss->cache->gravity_direction, -data->sd->gravity_factor);
}
/* Original data for deform brushes. */
@@ -279,6 +391,11 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
copy_v3_v3(current_vertex_location, vd.co);
}
+ /* Apply gravity in the entire simulation area. */
+ float vertex_gravity[3];
+ mul_v3_v3fl(vertex_gravity, gravity, sim_factor);
+ cloth_brush_apply_force_to_vertex(ss, ss->cache->cloth_sim, vertex_gravity, vd.index);
+
/* When using the plane falloff mode the falloff is not constrained by the brush radius. */
if (sculpt_brush_test_sq_fn(&test, current_vertex_location) || use_falloff_plane) {
@@ -319,9 +436,10 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(force, offset, -fade);
break;
case BRUSH_CLOTH_DEFORM_GRAB:
- /* Grab writes the positions in the simulation directly without applying forces. */
- madd_v3_v3v3fl(
- cloth_sim->pos[vd.index], orig_data.co, ss->cache->grab_delta_symmetry, fade);
+ madd_v3_v3v3fl(cloth_sim->deformation_pos[vd.index],
+ orig_data.co,
+ ss->cache->grab_delta_symmetry,
+ fade);
zero_v3(force);
break;
case BRUSH_CLOTH_DEFORM_PINCH_POINT:
@@ -356,17 +474,42 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
break;
}
- madd_v3_v3fl(force, gravity, fade);
-
cloth_brush_apply_force_to_vertex(ss, ss->cache->cloth_sim, force, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
}
+static ListBase *cloth_brush_collider_cache_create(Depsgraph *depsgraph)
+{
+ ListBase *cache = NULL;
+ DEG_OBJECT_ITER_BEGIN (depsgraph,
+ ob,
+ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI) {
+ CollisionModifierData *cmd = (CollisionModifierData *)BKE_modifiers_findby_type(
+ ob, eModifierType_Collision);
+ if (cmd && cmd->bvhtree) {
+ if (cache == NULL) {
+ cache = MEM_callocN(sizeof(ListBase), "ColliderCache array");
+ }
+
+ ColliderCache *col = MEM_callocN(sizeof(ColliderCache), "ColliderCache");
+ col->ob = ob;
+ col->collmd = cmd;
+ collision_move_object(cmd, 1.0, 0.0, true);
+ BLI_addtail(cache, col);
+ }
+ }
+ DEG_OBJECT_ITER_END;
+ return cache;
+}
+
static SculptClothSimulation *cloth_brush_simulation_create(SculptSession *ss,
+ Brush *brush,
const float cloth_mass,
- const float cloth_damping)
+ const float cloth_damping,
+ const bool use_collisions)
{
const int totverts = SCULPT_vertex_count_get(ss);
SculptClothSimulation *cloth_sim;
@@ -378,19 +521,130 @@ static SculptClothSimulation *cloth_brush_simulation_create(SculptSession *ss,
"cloth length constraints");
cloth_sim->capacity_length_constraints = CLOTH_LENGTH_CONSTRAINTS_BLOCK;
- cloth_sim->acceleration = MEM_callocN(sizeof(float) * 3 * totverts, "cloth sim acceleration");
- cloth_sim->pos = MEM_callocN(sizeof(float) * 3 * totverts, "cloth sim pos");
- cloth_sim->prev_pos = MEM_callocN(sizeof(float) * 3 * totverts, "cloth sim prev pos");
- cloth_sim->init_pos = MEM_callocN(sizeof(float) * 3 * totverts, "cloth sim init pos");
- cloth_sim->length_constraint_tweak = MEM_callocN(sizeof(float) * totverts,
- "cloth sim length tweak");
+ cloth_sim->acceleration = MEM_calloc_arrayN(
+ totverts, sizeof(float[3]), "cloth sim acceleration");
+ cloth_sim->pos = MEM_calloc_arrayN(totverts, sizeof(float[3]), "cloth sim pos");
+ cloth_sim->prev_pos = MEM_calloc_arrayN(totverts, sizeof(float[3]), "cloth sim prev pos");
+ cloth_sim->last_iteration_pos = MEM_calloc_arrayN(
+ totverts, sizeof(float[3]), "cloth sim last iteration pos");
+ cloth_sim->init_pos = MEM_calloc_arrayN(totverts, sizeof(float[3]), "cloth sim init pos");
+ cloth_sim->length_constraint_tweak = MEM_calloc_arrayN(
+ totverts, sizeof(float), "cloth sim length tweak");
+
+ /* Brush can be NULL for tools that need the solver but don't rely on constraint to deformation
+ * positions. */
+ if (brush && SCULPT_is_cloth_deform_brush(brush)) {
+ cloth_sim->deformation_pos = MEM_calloc_arrayN(
+ totverts, sizeof(float[3]), "cloth sim deformation positions");
+ }
cloth_sim->mass = cloth_mass;
cloth_sim->damping = cloth_damping;
+ if (use_collisions) {
+ cloth_sim->collider_list = cloth_brush_collider_cache_create(ss->depsgraph);
+ }
+
return cloth_sim;
}
+typedef struct ClothBrushCollision {
+ CollisionModifierData *col_data;
+ struct IsectRayPrecalc isect_precalc;
+} ClothBrushCollision;
+
+static void cloth_brush_collision_cb(void *userdata,
+ int index,
+ const BVHTreeRay *ray,
+ BVHTreeRayHit *hit)
+{
+ ClothBrushCollision *col = (ClothBrushCollision *)userdata;
+ CollisionModifierData *col_data = col->col_data;
+ MVertTri *verttri = &col_data->tri[index];
+ MVert *mverts = col_data->x;
+ float *tri[3], no[3], co[3];
+
+ tri[0] = mverts[verttri->tri[0]].co;
+ tri[1] = mverts[verttri->tri[1]].co;
+ tri[2] = mverts[verttri->tri[2]].co;
+ float dist = 0.0f;
+
+ bool tri_hit = isect_ray_tri_watertight_v3(
+ ray->origin, &col->isect_precalc, UNPACK3(tri), &dist, NULL);
+ normal_tri_v3(no, UNPACK3(tri));
+ madd_v3_v3v3fl(co, ray->origin, ray->direction, dist);
+
+ if (tri_hit && dist < hit->dist) {
+ hit->index = index;
+ hit->dist = dist;
+
+ copy_v3_v3(hit->co, co);
+ copy_v3_v3(hit->no, no);
+ }
+}
+
+static void cloth_brush_solve_collision(Object *object,
+ SculptClothSimulation *cloth_sim,
+ const int i)
+{
+ const int raycast_flag = BVH_RAYCAST_DEFAULT & ~(BVH_RAYCAST_WATERTIGHT);
+
+ ColliderCache *collider_cache;
+ BVHTreeRayHit hit;
+
+ float obmat_inv[4][4];
+ invert_m4_m4(obmat_inv, object->obmat);
+
+ for (collider_cache = cloth_sim->collider_list->first; collider_cache;
+ collider_cache = collider_cache->next) {
+ float ray_start[3], ray_normal[3];
+ float pos_world_space[3], prev_pos_world_space[3];
+
+ mul_v3_m4v3(pos_world_space, object->obmat, cloth_sim->pos[i]);
+ mul_v3_m4v3(prev_pos_world_space, object->obmat, cloth_sim->last_iteration_pos[i]);
+ sub_v3_v3v3(ray_normal, pos_world_space, prev_pos_world_space);
+ copy_v3_v3(ray_start, prev_pos_world_space);
+ hit.index = -1;
+ hit.dist = len_v3(ray_normal);
+ normalize_v3(ray_normal);
+
+ ClothBrushCollision col;
+ CollisionModifierData *collmd = collider_cache->collmd;
+ col.col_data = collmd;
+ isect_ray_tri_watertight_v3_precalc(&col.isect_precalc, ray_normal);
+
+ BLI_bvhtree_ray_cast_ex(collmd->bvhtree,
+ ray_start,
+ ray_normal,
+ 0.3f,
+ &hit,
+ cloth_brush_collision_cb,
+ &col,
+ raycast_flag);
+
+ if (hit.index != -1) {
+
+ float collision_disp[3];
+ float movement_disp[3];
+ mul_v3_v3fl(collision_disp, hit.no, 0.005f);
+ sub_v3_v3v3(movement_disp, pos_world_space, prev_pos_world_space);
+ float friction_plane[4];
+ float pos_on_friction_plane[3];
+ plane_from_point_normal_v3(friction_plane, hit.co, hit.no);
+ closest_to_plane_v3(pos_on_friction_plane, friction_plane, pos_world_space);
+ sub_v3_v3v3(movement_disp, pos_on_friction_plane, hit.co);
+
+ /* TODO(pablodp606): This can be exposed in a brush/filter property as friction. */
+ mul_v3_fl(movement_disp, 0.35f);
+
+ copy_v3_v3(cloth_sim->pos[i], hit.co);
+ add_v3_v3(cloth_sim->pos[i], movement_disp);
+ add_v3_v3(cloth_sim->pos[i], collision_disp);
+ mul_v3_m4v3(cloth_sim->pos[i], obmat_inv, cloth_sim->pos[i]);
+ }
+ }
+}
+
static void do_cloth_brush_solve_simulation_task_cb_ex(
void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
{
@@ -421,14 +675,22 @@ static void do_cloth_brush_solve_simulation_task_cb_ex(
const float mask_v = (1.0f - (vd.mask ? *vd.mask : 0.0f)) *
SCULPT_automasking_factor_get(ss, vd.index);
+
madd_v3_v3fl(cloth_sim->pos[i], pos_diff, mask_v);
madd_v3_v3fl(cloth_sim->pos[i], cloth_sim->acceleration[i], mask_v);
- copy_v3_v3(cloth_sim->prev_pos[i], temp);
+ if (cloth_sim->collider_list != NULL) {
+ cloth_brush_solve_collision(data->ob, cloth_sim, i);
+ }
+
+ copy_v3_v3(cloth_sim->last_iteration_pos[i], cloth_sim->pos[i]);
+ copy_v3_v3(cloth_sim->prev_pos[i], temp);
+ copy_v3_v3(cloth_sim->last_iteration_pos[i], cloth_sim->pos[i]);
copy_v3_fl(cloth_sim->acceleration[i], 0.0f);
copy_v3_v3(vd.co, cloth_sim->pos[vd.index]);
+
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
}
@@ -482,11 +744,11 @@ static void cloth_brush_satisfy_constraints(SculptSession *ss,
for (int i = 0; i < cloth_sim->tot_length_constraints; i++) {
const SculptClothLengthConstraint *constraint = &cloth_sim->length_constraints[i];
- const int v1 = constraint->v1;
- const int v2 = constraint->v2;
+ const int v1 = constraint->elem_index_a;
+ const int v2 = constraint->elem_index_b;
float v1_to_v2[3];
- sub_v3_v3v3(v1_to_v2, cloth_sim->pos[v2], cloth_sim->pos[v1]);
+ sub_v3_v3v3(v1_to_v2, constraint->elem_position_b, constraint->elem_position_a);
const float current_distance = len_v3(v1_to_v2);
float correction_vector[3];
float correction_vector_half[3];
@@ -522,8 +784,14 @@ static void cloth_brush_satisfy_constraints(SculptSession *ss,
cloth_sim->init_pos[v2]) :
1.0f;
- madd_v3_v3fl(cloth_sim->pos[v1], correction_vector_half, 1.0f * mask_v1 * sim_factor_v1);
- madd_v3_v3fl(cloth_sim->pos[v2], correction_vector_half, -1.0f * mask_v2 * sim_factor_v2);
+ madd_v3_v3fl(cloth_sim->pos[v1],
+ correction_vector_half,
+ 1.0f * mask_v1 * sim_factor_v1 * constraint->strength);
+ if (v1 != v2) {
+ madd_v3_v3fl(cloth_sim->pos[v2],
+ correction_vector_half,
+ -1.0f * mask_v2 * sim_factor_v2 * constraint->strength);
+ }
}
}
}
@@ -575,7 +843,7 @@ static void cloth_brush_apply_brush_foces(Sculpt *sd, Object *ob, PBVHNode **nod
.mat = imat,
};
- BKE_curvemapping_initialize(brush->curve);
+ BKE_curvemapping_init(brush->curve);
/* Init the grab delta. */
copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
@@ -639,17 +907,27 @@ void SCULPT_do_cloth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
/* In the first brush step of each symmetry pass, build the constraints for the vertices in all
* nodes inside the simulation's limits. */
- /* Brush stroke types that restore the mesh on each brush step also need the cloth sim data to be
- * created on each step. */
+ /* Brushes that use anchored strokes and restore the mesh can't rely on symmetry passes and steps
+ * count as it is always the first step, so the simulation needs to be created when it does not
+ * exist for this stroke. */
if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache) || !ss->cache->cloth_sim) {
/* The simulation structure only needs to be created on the first symmetry pass. */
- if (SCULPT_stroke_is_first_brush_step(ss->cache)) {
+ if (SCULPT_stroke_is_first_brush_step(ss->cache) || !ss->cache->cloth_sim) {
+ const bool is_cloth_deform_brush = SCULPT_is_cloth_deform_brush(brush);
ss->cache->cloth_sim = cloth_brush_simulation_create(
- ss, brush->cloth_mass, brush->cloth_damping);
+ ss,
+ brush,
+ brush->cloth_mass,
+ brush->cloth_damping,
+ (brush->flag2 & BRUSH_CLOTH_USE_COLLISION));
for (int i = 0; i < totverts; i++) {
- copy_v3_v3(ss->cache->cloth_sim->prev_pos[i], SCULPT_vertex_co_get(ss, i));
+ copy_v3_v3(ss->cache->cloth_sim->last_iteration_pos[i], SCULPT_vertex_co_get(ss, i));
copy_v3_v3(ss->cache->cloth_sim->init_pos[i], SCULPT_vertex_co_get(ss, i));
+ copy_v3_v3(ss->cache->cloth_sim->prev_pos[i], SCULPT_vertex_co_get(ss, i));
+ if (is_cloth_deform_brush) {
+ copy_v3_v3(ss->cache->cloth_sim->deformation_pos[i], SCULPT_vertex_co_get(ss, i));
+ }
}
}
@@ -677,18 +955,22 @@ void SCULPT_do_cloth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
void SCULPT_cloth_simulation_free(struct SculptClothSimulation *cloth_sim)
{
MEM_SAFE_FREE(cloth_sim->pos);
+ MEM_SAFE_FREE(cloth_sim->last_iteration_pos);
MEM_SAFE_FREE(cloth_sim->prev_pos);
MEM_SAFE_FREE(cloth_sim->acceleration);
MEM_SAFE_FREE(cloth_sim->length_constraints);
MEM_SAFE_FREE(cloth_sim->length_constraint_tweak);
+ MEM_SAFE_FREE(cloth_sim->deformation_pos);
MEM_SAFE_FREE(cloth_sim->init_pos);
+ if (cloth_sim->collider_list) {
+ BKE_collider_cache_free(&cloth_sim->collider_list);
+ }
MEM_SAFE_FREE(cloth_sim);
}
/* Cursor drawing function. */
void SCULPT_cloth_simulation_limits_draw(const uint gpuattr,
const Brush *brush,
- const float obmat[4][4],
const float location[3],
const float normal[3],
const float rds,
@@ -697,12 +979,13 @@ void SCULPT_cloth_simulation_limits_draw(const uint gpuattr,
const float alpha)
{
float cursor_trans[4][4], cursor_rot[4][4];
- float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f};
+ const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f};
float quat[4];
- copy_m4_m4(cursor_trans, obmat);
+ unit_m4(cursor_trans);
translate_m4(cursor_trans, location[0], location[1], location[2]);
rotation_between_vecs_to_quat(quat, z_axis, normal);
quat_to_mat4(cursor_rot, quat);
+ GPU_matrix_push();
GPU_matrix_mul(cursor_trans);
GPU_matrix_mul(cursor_rot);
@@ -712,6 +995,7 @@ void SCULPT_cloth_simulation_limits_draw(const uint gpuattr,
gpuattr, 0, 0, rds + (rds * brush->cloth_sim_limit * brush->cloth_sim_falloff), 320);
immUniformColor3fvAlpha(outline_col, alpha * 0.7f);
imm_draw_circle_wire_3d(gpuattr, 0, 0, rds + rds * brush->cloth_sim_limit, 80);
+ GPU_matrix_pop();
}
void SCULPT_cloth_plane_falloff_preview_draw(const uint gpuattr,
@@ -858,6 +1142,7 @@ static int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, false);
const int totverts = SCULPT_vertex_count_get(ss);
+
for (int i = 0; i < totverts; i++) {
copy_v3_v3(ss->filter_cache->cloth_sim->pos[i], SCULPT_vertex_co_get(ss, i));
}
@@ -889,7 +1174,7 @@ static int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent
static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Object *ob = CTX_data_active_object(C);
- Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
SculptSession *ss = ob->sculpt;
@@ -910,11 +1195,15 @@ static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent
const float cloth_mass = RNA_float_get(op->ptr, "cloth_mass");
const float cloth_damping = RNA_float_get(op->ptr, "cloth_damping");
- ss->filter_cache->cloth_sim = cloth_brush_simulation_create(ss, cloth_mass, cloth_damping);
+ const bool use_collisions = RNA_boolean_get(op->ptr, "use_collisions");
+ ss->filter_cache->cloth_sim = cloth_brush_simulation_create(
+ ss, NULL, cloth_mass, cloth_damping, use_collisions);
+
copy_v3_v3(ss->filter_cache->cloth_sim_pinch_point, SCULPT_active_vertex_co_get(ss));
const int totverts = SCULPT_vertex_count_get(ss);
for (int i = 0; i < totverts; i++) {
+ copy_v3_v3(ss->filter_cache->cloth_sim->last_iteration_pos[i], SCULPT_vertex_co_get(ss, i));
copy_v3_v3(ss->filter_cache->cloth_sim->prev_pos[i], SCULPT_vertex_co_get(ss, i));
copy_v3_v3(ss->filter_cache->cloth_sim->init_pos[i], SCULPT_vertex_co_get(ss, i));
}
@@ -986,4 +1275,9 @@ void SCULPT_OT_cloth_filter(struct wmOperatorType *ot)
false,
"Use Face Sets",
"Apply the filter only to the Face Set under the cursor");
+ ot->prop = RNA_def_boolean(ot->srna,
+ "use_collisions",
+ false,
+ "Use Collisions",
+ "Collide with other collider objects in the scene");
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.c b/source/blender/editors/sculpt_paint/sculpt_detail.c
index 463233fd6fb..e08f477c981 100644
--- a/source/blender/editors/sculpt_paint/sculpt_detail.c
+++ b/source/blender/editors/sculpt_paint/sculpt_detail.c
@@ -179,7 +179,7 @@ static void sample_detail_voxel(bContext *C, ViewContext *vc, int mx, int my)
SCULPT_vertex_random_access_init(ss);
/* Update the active vertex. */
- float mouse[2] = {mx, my};
+ const float mouse[2] = {mx, my};
SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, false);
@@ -219,7 +219,7 @@ static void sample_detail_dyntopo(bContext *C, ViewContext *vc, ARegion *region,
SCULPT_stroke_modifiers_check(C, ob, brush);
- float mouse[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
+ const float mouse[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
float ray_start[3], ray_end[3], ray_normal[3];
float depth = SCULPT_raycast_init(vc, mouse, ray_start, ray_end, ray_normal, false);
@@ -316,7 +316,7 @@ static int sculpt_sample_detail_size_modal(bContext *C, wmOperator *op, const wm
switch (event->type) {
case LEFTMOUSE:
if (event->val == KM_PRESS) {
- int ss_co[2] = {event->x, event->y};
+ const int ss_co[2] = {event->x, event->y};
int mode = RNA_enum_get(op->ptr, "mode");
sample_detail(C, ss_co[0], ss_co[1], mode);
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c
index 1940b007cb0..a8de3be3baf 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -192,7 +192,7 @@ void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in
SculptSession *ss = ob->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
- BKE_curvemapping_initialize(brush->curve);
+ BKE_curvemapping_init(brush->curve);
/* Threaded loop over nodes. */
SculptThreadedTaskData data = {
@@ -1005,22 +1005,26 @@ static EnumPropertyItem prop_sculpt_face_sets_edit_types[] = {
static void sculpt_face_set_grow(Object *ob,
SculptSession *ss,
- int *prev_face_sets,
- const int active_face_set_id)
+ const int *prev_face_sets,
+ const int active_face_set_id,
+ const bool modify_hidden)
{
Mesh *mesh = BKE_mesh_from_object(ob);
for (int p = 0; p < mesh->totpoly; p++) {
+ if (!modify_hidden && prev_face_sets[p] <= 0) {
+ continue;
+ }
const MPoly *c_poly = &mesh->mpoly[p];
for (int l = 0; l < c_poly->totloop; l++) {
const MLoop *c_loop = &mesh->mloop[c_poly->loopstart + l];
const MeshElemMap *vert_map = &ss->pmap[c_loop->v];
for (int i = 0; i < vert_map->count; i++) {
const int neighbor_face_index = vert_map->indices[i];
- if (neighbor_face_index != p) {
-
- if (abs(prev_face_sets[neighbor_face_index]) == active_face_set_id) {
- ss->face_sets[p] = active_face_set_id;
- }
+ if (neighbor_face_index == p) {
+ continue;
+ }
+ if (abs(prev_face_sets[neighbor_face_index]) == active_face_set_id) {
+ ss->face_sets[p] = active_face_set_id;
}
}
}
@@ -1029,11 +1033,15 @@ static void sculpt_face_set_grow(Object *ob,
static void sculpt_face_set_shrink(Object *ob,
SculptSession *ss,
- int *prev_face_sets,
- const int active_face_set_id)
+ const int *prev_face_sets,
+ const int active_face_set_id,
+ const bool modify_hidden)
{
Mesh *mesh = BKE_mesh_from_object(ob);
for (int p = 0; p < mesh->totpoly; p++) {
+ if (!modify_hidden && prev_face_sets[p] <= 0) {
+ continue;
+ }
if (abs(prev_face_sets[p]) == active_face_set_id) {
const MPoly *c_poly = &mesh->mpoly[p];
for (int l = 0; l < c_poly->totloop; l++) {
@@ -1041,10 +1049,11 @@ static void sculpt_face_set_shrink(Object *ob,
const MeshElemMap *vert_map = &ss->pmap[c_loop->v];
for (int i = 0; i < vert_map->count; i++) {
const int neighbor_face_index = vert_map->indices[i];
- if (neighbor_face_index != p) {
- if (abs(prev_face_sets[neighbor_face_index]) != active_face_set_id) {
- ss->face_sets[p] = prev_face_sets[neighbor_face_index];
- }
+ if (neighbor_face_index == p) {
+ continue;
+ }
+ if (abs(prev_face_sets[neighbor_face_index]) != active_face_set_id) {
+ ss->face_sets[p] = prev_face_sets[neighbor_face_index];
}
}
}
@@ -1052,7 +1061,10 @@ static void sculpt_face_set_shrink(Object *ob,
}
}
-static void sculpt_face_set_apply_edit(Object *ob, const int active_face_set_id, const int mode)
+static void sculpt_face_set_apply_edit(Object *ob,
+ const int active_face_set_id,
+ const int mode,
+ const bool modify_hidden)
{
SculptSession *ss = ob->sculpt;
@@ -1060,10 +1072,10 @@ static void sculpt_face_set_apply_edit(Object *ob, const int active_face_set_id,
switch (mode) {
case SCULPT_FACE_SET_EDIT_GROW:
- sculpt_face_set_grow(ob, ss, prev_face_sets, active_face_set_id);
+ sculpt_face_set_grow(ob, ss, prev_face_sets, active_face_set_id, modify_hidden);
break;
case SCULPT_FACE_SET_EDIT_SHRINK:
- sculpt_face_set_shrink(ob, ss, prev_face_sets, active_face_set_id);
+ sculpt_face_set_shrink(ob, ss, prev_face_sets, active_face_set_id, modify_hidden);
break;
}
@@ -1099,8 +1111,9 @@ static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEven
SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
const int active_face_set = SCULPT_active_face_set_get(ss);
+ const bool modify_hidden = RNA_boolean_get(op->ptr, "modify_hidden");
- sculpt_face_set_apply_edit(ob, abs(active_face_set), mode);
+ sculpt_face_set_apply_edit(ob, abs(active_face_set), mode, modify_hidden);
SCULPT_undo_push_end();
@@ -1145,4 +1158,9 @@ void SCULPT_OT_face_sets_edit(struct wmOperatorType *ot)
RNA_def_enum(
ot->srna, "mode", prop_sculpt_face_sets_edit_types, SCULPT_FACE_SET_EDIT_GROW, "Mode", "");
+ ot->prop = RNA_def_boolean(ot->srna,
+ "modify_hidden",
+ true,
+ "Modify Hidden",
+ "Apply the edit operation to hidden Face Sets");
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.c b/source/blender/editors/sculpt_paint/sculpt_filter_color.c
index 59d82825740..912dfd808b0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_color.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.c
@@ -80,7 +80,7 @@ typedef enum eSculptColorFilterTypes {
COLOR_FILTER_SMOOTH,
} eSculptColorFilterTypes;
-EnumPropertyItem prop_color_filter_types[] = {
+static EnumPropertyItem prop_color_filter_types[] = {
{COLOR_FILTER_FILL, "FILL", 0, "Fill", "Fill with a specific color"},
{COLOR_FILTER_HUE, "HUE", 0, "Hue", "Change hue"},
{COLOR_FILTER_SATURATION, "SATURATION", 0, "Saturation", "Change saturation"},
@@ -322,6 +322,6 @@ void SCULPT_OT_color_filter(struct wmOperatorType *ot)
ot->srna, "strength", 1.0f, -10.0f, 10.0f, "Strength", "Filter Strength", -10.0f, 10.0f);
PropertyRNA *prop = RNA_def_float_color(
- ot->srna, "fill_color", 3, NULL, 0.0f, FLT_MAX, "Fill Color", "fill color", 0.0f, 1.0f);
+ ot->srna, "fill_color", 3, NULL, 0.0f, FLT_MAX, "Fill Color", "", 0.0f, 1.0f);
RNA_def_property_subtype(prop, PROP_COLOR_GAMMA);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index e9a98a17f8a..ebf511c7fd3 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -82,7 +82,7 @@ void SCULPT_filter_cache_init(Object *ob, Sculpt *sd, const int undo_type)
ss->filter_cache->random_seed = rand();
- float center[3] = {0.0f};
+ const float center[3] = {0.0f};
SculptSearchSphereData search_data = {
.original = true,
.center = center,
@@ -132,6 +132,7 @@ void SCULPT_filter_cache_free(SculptSession *ss)
MEM_SAFE_FREE(ss->filter_cache->automask);
MEM_SAFE_FREE(ss->filter_cache->surface_smooth_laplacian_disp);
MEM_SAFE_FREE(ss->filter_cache->sharpen_factor);
+ MEM_SAFE_FREE(ss->filter_cache->sharpen_detail_directions);
MEM_SAFE_FREE(ss->filter_cache);
}
@@ -356,6 +357,17 @@ static void mesh_filter_task_cb(void *__restrict userdata,
mul_v3_v3fl(
disp_avg, disp_avg, smooth_ratio * pow2f(ss->filter_cache->sharpen_factor[vd.index]));
add_v3_v3v3(disp, disp_avg, disp_sharpen);
+
+ /* Intensify details. */
+ if (ss->filter_cache->sharpen_intensify_detail_strength > 0.0f) {
+ float detail_strength[3];
+ normal_short_to_float_v3(detail_strength, orig_data.no);
+ copy_v3_v3(detail_strength, ss->filter_cache->sharpen_detail_directions[vd.index]);
+ madd_v3_v3fl(disp,
+ detail_strength,
+ -ss->filter_cache->sharpen_intensify_detail_strength *
+ ss->filter_cache->sharpen_factor[vd.index]);
+ }
break;
}
}
@@ -388,8 +400,10 @@ static void mesh_filter_sharpen_init_factors(SculptSession *ss)
for (int i = 0; i < totvert; i++) {
float avg[3];
SCULPT_neighbor_coords_average(ss, avg, i);
- ss->filter_cache->sharpen_factor[i] = len_v3v3(avg, SCULPT_vertex_co_get(ss, i));
+ sub_v3_v3v3(ss->filter_cache->sharpen_detail_directions[i], avg, SCULPT_vertex_co_get(ss, i));
+ ss->filter_cache->sharpen_factor[i] = len_v3(ss->filter_cache->sharpen_detail_directions[i]);
}
+
float max_factor = 0.0f;
for (int i = 0; i < totvert; i++) {
if (ss->filter_cache->sharpen_factor[i] > max_factor) {
@@ -402,6 +416,31 @@ static void mesh_filter_sharpen_init_factors(SculptSession *ss)
ss->filter_cache->sharpen_factor[i] *= max_factor;
ss->filter_cache->sharpen_factor[i] = 1.0f - pow2f(1.0f - ss->filter_cache->sharpen_factor[i]);
}
+
+ /* Smooth the calculated factors and directions to remove high frecuency detail. */
+ for (int smooth_iterations = 0;
+ smooth_iterations < ss->filter_cache->sharpen_curvature_smooth_iterations;
+ smooth_iterations++) {
+ for (int i = 0; i < totvert; i++) {
+ float direction_avg[3] = {0.0f, 0.0f, 0.0f};
+ float sharpen_avg = 0;
+ int total = 0;
+
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) {
+ add_v3_v3(direction_avg, ss->filter_cache->sharpen_detail_directions[ni.index]);
+ sharpen_avg += ss->filter_cache->sharpen_factor[ni.index];
+ total++;
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+
+ if (total > 0) {
+ mul_v3_v3fl(
+ ss->filter_cache->sharpen_detail_directions[i], direction_avg, 1.0f / (float)total);
+ ss->filter_cache->sharpen_factor[i] = sharpen_avg / (float)total;
+ }
+ }
+ }
}
static void mesh_filter_surface_smooth_displace_task_cb(
@@ -556,7 +595,7 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
}
if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_SURFACE_SMOOTH) {
- ss->filter_cache->surface_smooth_laplacian_disp = MEM_mallocN(3 * sizeof(float) * totvert,
+ ss->filter_cache->surface_smooth_laplacian_disp = MEM_mallocN(sizeof(float[3]) * totvert,
"surface smooth disp");
ss->filter_cache->surface_smooth_shape_preservation = RNA_float_get(
op->ptr, "surface_smooth_shape_preservation");
@@ -566,7 +605,14 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_SHARPEN) {
ss->filter_cache->sharpen_smooth_ratio = RNA_float_get(op->ptr, "sharpen_smooth_ratio");
+ ss->filter_cache->sharpen_intensify_detail_strength = RNA_float_get(
+ op->ptr, "sharpen_intensify_detail_strength");
+ ss->filter_cache->sharpen_curvature_smooth_iterations = RNA_int_get(
+ op->ptr, "sharpen_curvature_smooth_iterations");
+
ss->filter_cache->sharpen_factor = MEM_mallocN(sizeof(float) * totvert, "sharpen factor");
+ ss->filter_cache->sharpen_detail_directions = MEM_malloc_arrayN(
+ totvert, sizeof(float[3]), "sharpen detail direction");
mesh_filter_sharpen_init_factors(ss);
}
@@ -642,4 +688,24 @@ void SCULPT_OT_mesh_filter(struct wmOperatorType *ot)
"How much smoothing is applied to polished surfaces",
0.0f,
1.0f);
+
+ RNA_def_float(ot->srna,
+ "sharpen_intensify_detail_strength",
+ 0.0f,
+ 0.0f,
+ 10.0f,
+ "Intensify Details",
+ "How much creases and valleys are intensified",
+ 0.0f,
+ 1.0f);
+
+ RNA_def_int(ot->srna,
+ "sharpen_curvature_smooth_iterations",
+ 0,
+ 0,
+ 10,
+ "Curvature Smooth Iterations",
+ "How much smooth the resulting shape is, ignoring high frequency details",
+ 0,
+ 10);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index f834ab7b179..79b1a5bde7b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -21,8 +21,7 @@
* \ingroup edsculpt
*/
-#ifndef __SCULPT_INTERN_H__
-#define __SCULPT_INTERN_H__
+#pragma once
#include "DNA_brush_types.h"
#include "DNA_key_types.h"
@@ -98,6 +97,9 @@ void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3]);
float SCULPT_vertex_mask_get(struct SculptSession *ss, int index);
const float *SCULPT_vertex_color_get(SculptSession *ss, int index);
+const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, int index);
+void SCULPT_vertex_persistent_normal_get(SculptSession *ss, int index, float no[3]);
+
#define SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY 256
typedef struct SculptVertexNeighborIter {
/* Storage */
@@ -348,7 +350,6 @@ void SCULPT_cloth_simulation_free(struct SculptClothSimulation *cloth_sim);
void SCULPT_cloth_simulation_limits_draw(const uint gpuattr,
const struct Brush *brush,
- const float obmat[4][4],
const float location[3],
const float normal[3],
const float rds,
@@ -391,9 +392,26 @@ struct SculptPoseIKChain *SCULPT_pose_ik_chain_init(struct Sculpt *sd,
const float radius);
void SCULPT_pose_ik_chain_free(struct SculptPoseIKChain *ik_chain);
+/* Boundary Brush. */
+struct SculptBoundary *SCULPT_boundary_data_init(Object *object,
+ const int initial_vertex,
+ const float radius);
+void SCULPT_boundary_data_free(struct SculptBoundary *bdata);
+void SCULPT_do_boundary_brush(struct Sculpt *sd,
+ struct Object *ob,
+ struct PBVHNode **nodes,
+ int totnode);
+
+void SCULPT_boundary_edges_preview_draw(const uint gpuattr,
+ struct SculptSession *ss,
+ const float outline_col[3],
+ const float outline_alpha);
+void SCULPT_boundary_pivot_line_preview_draw(const uint gpuattr, struct SculptSession *ss);
+
/* Multiplane Scrape Brush. */
void SCULPT_do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr,
+ Brush *brush,
SculptSession *ss,
const float outline_col[3],
const float outline_alpha);
@@ -628,6 +646,9 @@ typedef struct SculptThreadedTaskData {
float transform_mats[8][4][4];
+ /* Boundary brush */
+ float boundary_deform_strength;
+
float cloth_time_step;
SculptClothSimulation *cloth_sim;
float *cloth_sim_initial_location;
@@ -853,6 +874,9 @@ typedef struct StrokeCache {
float initial_normal[3];
float true_initial_normal[3];
+ /* Boundary brush */
+ struct SculptBoundary *bdata[PAINT_SYMM_AREAS];
+
/* Surface Smooth Brush */
/* Stores the displacement produced by the laplacian step of HC smooth. */
float (*surface_smooth_laplacian_disp)[3];
@@ -906,7 +930,10 @@ typedef struct FilterCache {
/* Sharpen mesh filter. */
float sharpen_smooth_ratio;
+ float sharpen_intensify_detail_strength;
+ int sharpen_curvature_smooth_iterations;
float *sharpen_factor;
+ float (*sharpen_detail_directions)[3];
/* unmasked nodes */
PBVHNode **nodes;
@@ -991,5 +1018,3 @@ void SCULPT_OT_set_detail_size(struct wmOperatorType *ot);
/* Dyntopo. */
void SCULPT_OT_dynamic_topology_toggle(struct wmOperatorType *ot);
-
-#endif
diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
index 60483cc168d..aaa61ee9ed3 100644
--- a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
@@ -174,7 +174,7 @@ static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent *
ARegion *region = CTX_wm_region(C);
float prevclick_f[2];
copy_v2_v2(prevclick_f, op->customdata);
- int prevclick[2] = {(int)prevclick_f[0], (int)prevclick_f[1]};
+ const int prevclick[2] = {(int)prevclick_f[0], (int)prevclick_f[1]};
int len = (int)len_v2v2_int(prevclick, event->mval);
len = abs(len);
int mask_speed = RNA_int_get(op->ptr, "mask_speed");
@@ -359,7 +359,7 @@ static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent
SCULPT_vertex_random_access_init(ss);
- op->customdata = MEM_mallocN(2 * sizeof(float), "initial mouse position");
+ op->customdata = MEM_mallocN(sizeof(float[2]), "initial mouse position");
copy_v2_v2(op->customdata, mouse);
SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
diff --git a/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c b/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c
index b52036d753c..e47a94dff90 100644
--- a/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c
+++ b/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c
@@ -47,7 +47,6 @@
#include "paint_intern.h"
#include "sculpt_intern.h"
-#include "GPU_draw.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
@@ -376,7 +375,7 @@ void SCULPT_do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes,
/* Calculate the final left and right scrape planes. */
float plane_no[3];
float plane_no_rot[3];
- float y_axis[3] = {0.0f, 1.0f, 0.0f};
+ const float y_axis[3] = {0.0f, 1.0f, 0.0f};
float mat_inv[4][4];
invert_m4_m4(mat_inv, mat);
@@ -400,10 +399,15 @@ void SCULPT_do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes,
}
void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr,
+ Brush *brush,
SculptSession *ss,
const float outline_col[3],
const float outline_alpha)
{
+ if (!(brush->flag2 & BRUSH_MULTIPLANE_SCRAPE_PLANES_PREVIEW)) {
+ return;
+ }
+
float local_mat_inv[4][4];
invert_m4_m4(local_mat_inv, ss->cache->stroke_local_mat);
GPU_matrix_mul(local_mat_inv);
@@ -414,11 +418,11 @@ void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr,
float offset = ss->cache->radius * 0.25f;
- float p[3] = {0.0f, 0.0f, ss->cache->radius};
- float y_axis[3] = {0.0f, 1.0f, 0.0f};
+ const float p[3] = {0.0f, 0.0f, ss->cache->radius};
+ const float y_axis[3] = {0.0f, 1.0f, 0.0f};
float p_l[3];
float p_r[3];
- float area_center[3] = {0.0f, 0.0f, 0.0f};
+ const float area_center[3] = {0.0f, 0.0f, 0.0f};
rotate_v3_v3v3fl(p_r, p, y_axis, DEG2RADF((angle + 180) * 0.5f));
rotate_v3_v3v3fl(p_l, p, y_axis, DEG2RADF(-(angle + 180) * 0.5f));
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c
index f01a914fdd3..ed33542967b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c
@@ -255,7 +255,7 @@ void SCULPT_do_paint_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
return;
}
- BKE_curvemapping_initialize(brush->curve);
+ BKE_curvemapping_init(brush->curve);
float area_no[3];
float mat[4][4];
@@ -461,14 +461,14 @@ void SCULPT_do_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
if (SCULPT_stroke_is_first_brush_step(ss->cache)) {
if (!ss->cache->prev_colors) {
- ss->cache->prev_colors = MEM_callocN(sizeof(float) * 4 * totvert, "prev colors");
+ ss->cache->prev_colors = MEM_callocN(sizeof(float[4]) * totvert, "prev colors");
for (int i = 0; i < totvert; i++) {
copy_v4_v4(ss->cache->prev_colors[i], SCULPT_vertex_color_get(ss, i));
}
}
}
- BKE_curvemapping_initialize(brush->curve);
+ BKE_curvemapping_init(brush->curve);
SculptThreadedTaskData data = {
.sd = sd,
diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.c b/source/blender/editors/sculpt_paint/sculpt_pose.c
index a338b5346af..8a288877d43 100644
--- a/source/blender/editors/sculpt_paint/sculpt_pose.c
+++ b/source/blender/editors/sculpt_paint/sculpt_pose.c
@@ -830,17 +830,21 @@ static bool pose_face_sets_fk_find_masked_floodfill_cb(
}
const int to_face_set = SCULPT_vertex_face_set_get(ss, to_v);
- if (SCULPT_vertex_has_unique_face_set(ss, to_v) &&
- !SCULPT_vertex_has_unique_face_set(ss, from_v) &&
- SCULPT_vertex_has_face_set(ss, from_v, to_face_set)) {
+ if (!BLI_gset_haskey(data->visited_face_sets, POINTER_FROM_INT(to_face_set))) {
+ if (SCULPT_vertex_has_unique_face_set(ss, to_v) &&
+ !SCULPT_vertex_has_unique_face_set(ss, from_v) &&
+ SCULPT_vertex_has_face_set(ss, from_v, to_face_set)) {
- if (data->floodfill_it[to_v] > data->masked_face_set_it) {
- data->masked_face_set = to_face_set;
- data->masked_face_set_it = data->floodfill_it[to_v];
- }
+ BLI_gset_add(data->visited_face_sets, POINTER_FROM_INT(to_face_set));
+
+ if (data->floodfill_it[to_v] >= data->masked_face_set_it) {
+ data->masked_face_set = to_face_set;
+ data->masked_face_set_it = data->floodfill_it[to_v];
+ }
- if (data->target_face_set == SCULPT_FACE_SET_NONE) {
- data->target_face_set = to_face_set;
+ if (data->target_face_set == SCULPT_FACE_SET_NONE) {
+ data->target_face_set = to_face_set;
+ }
}
}
@@ -875,8 +879,10 @@ static SculptPoseIKChain *pose_ik_chain_init_face_sets_fk(
fdata.masked_face_set = SCULPT_FACE_SET_NONE;
fdata.target_face_set = SCULPT_FACE_SET_NONE;
fdata.masked_face_set_it = 0;
+ fdata.visited_face_sets = BLI_gset_int_new_ex("visited_face_sets", 3);
SCULPT_floodfill_execute(ss, &flood, pose_face_sets_fk_find_masked_floodfill_cb, &fdata);
SCULPT_floodfill_free(&flood);
+ BLI_gset_free(fdata.visited_face_sets, NULL);
int origin_count = 0;
float origin_acc[3] = {0.0f};
@@ -1000,7 +1006,7 @@ void SCULPT_pose_brush_init(Sculpt *sd, Object *ob, SculptSession *ss, Brush *br
static void sculpt_pose_do_translate_deform(SculptSession *ss, Brush *brush)
{
SculptPoseIKChain *ik_chain = ss->cache->pose_ik_chain;
- BKE_curvemapping_initialize(brush->curve);
+ BKE_curvemapping_init(brush->curve);
pose_solve_translate_chain(ik_chain, ss->cache->grab_delta);
}
@@ -1025,8 +1031,10 @@ static void sculpt_pose_do_scale_deform(SculptSession *ss, Brush *brush)
copy_v3_v3(ik_target, ss->cache->true_location);
add_v3_v3(ik_target, ss->cache->grab_delta);
- /* Solve the IK for the first segment to include rotation as part of scale. */
- pose_solve_ik_chain(ik_chain, ik_target, brush->flag2 & BRUSH_POSE_IK_ANCHORED);
+ /* Solve the IK for the first segment to include rotation as part of scale if enabled. */
+ if (!(brush->flag2 & BRUSH_POSE_USE_LOCK_ROTATION)) {
+ pose_solve_ik_chain(ik_chain, ik_target, brush->flag2 & BRUSH_POSE_IK_ANCHORED);
+ }
float scale[3];
copy_v3_fl(scale, sculpt_pose_get_scale_from_grab_delta(ss, ik_target));
@@ -1041,7 +1049,7 @@ static void sculpt_pose_do_twist_deform(SculptSession *ss, Brush *brush)
/* Calculate the maximum roll. 0.02 radians per pixel works fine. */
float roll = (ss->cache->initial_mouse[0] - ss->cache->mouse[0]) * ss->cache->bstrength * 0.02f;
- BKE_curvemapping_initialize(brush->curve);
+ BKE_curvemapping_init(brush->curve);
pose_solve_roll_chain(ik_chain, brush, roll);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c
index 7fbbcd1c896..9a64830cc20 100644
--- a/source/blender/editors/sculpt_paint/sculpt_smooth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c
@@ -443,7 +443,7 @@ void SCULPT_do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in
if (SCULPT_stroke_is_first_brush_step(ss->cache)) {
BLI_assert(ss->cache->surface_smooth_laplacian_disp == NULL);
ss->cache->surface_smooth_laplacian_disp = MEM_callocN(
- SCULPT_vertex_count_get(ss) * 3 * sizeof(float), "HC smooth laplacian b");
+ sizeof(float[3]) * SCULPT_vertex_count_get(ss), "HC smooth laplacian b");
}
/* Threaded loop over nodes. */
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 4b3df2dfea2..be509f4aed6 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -488,7 +488,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
op->customdata = data;
- BKE_curvemapping_initialize(ts->uvsculpt->paint.brush->curve);
+ BKE_curvemapping_init(ts->uvsculpt->paint.brush->curve);
if (data) {
int counter = 0, i;
diff --git a/source/blender/editors/sound/sound_intern.h b/source/blender/editors/sound/sound_intern.h
index 40cdb9ccf02..f4797838be0 100644
--- a/source/blender/editors/sound/sound_intern.h
+++ b/source/blender/editors/sound/sound_intern.h
@@ -21,7 +21,4 @@
* \ingroup edsnd
*/
-#ifndef __SOUND_INTERN_H__
-#define __SOUND_INTERN_H__
-
-#endif /* __SOUND_INTERN_H__ */
+#pragma once
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index bf1b90bbe98..ffe0606c98f 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -21,8 +21,7 @@
* \ingroup spaction
*/
-#ifndef __ACTION_INTERN_H__
-#define __ACTION_INTERN_H__
+#pragma once
struct ARegion;
struct ARegionType;
@@ -142,5 +141,3 @@ enum eActKeys_Mirror_Mode {
/* action_ops.c */
void action_operatortypes(void);
void action_keymap(struct wmKeyConfig *keyconf);
-
-#endif /* __ACTION_INTERN_H__ */
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 079cee290ae..db55eff8284 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -60,7 +60,7 @@
/* ******************** default callbacks for action space ***************** */
-static SpaceLink *action_new(const ScrArea *area, const Scene *scene)
+static SpaceLink *action_create(const ScrArea *area, const Scene *scene)
{
SpaceAction *saction;
ARegion *region;
@@ -863,7 +863,7 @@ void ED_spacetype_action(void)
st->spaceid = SPACE_ACTION;
strncpy(st->name, "Action", BKE_ST_MAXNAME);
- st->new = action_new;
+ st->create = action_create;
st->free = action_free;
st->init = action_init;
st->duplicate = action_duplicate;
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 49dbba5eba9..1656a76e2d4 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -44,7 +44,6 @@
#include "ED_gizmo_library.h"
#include "ED_gpencil.h"
#include "ED_lattice.h"
-#include "ED_logic.h"
#include "ED_markers.h"
#include "ED_mask.h"
#include "ED_mball.h"
@@ -281,7 +280,7 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
void ED_spacetype_xxx(void);
/* allocate and init some vars */
-static SpaceLink *xxx_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *xxx_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
return NULL;
}
@@ -325,7 +324,7 @@ void ED_spacetype_xxx(void)
st.spaceid = SPACE_VIEW3D;
- st.new = xxx_new;
+ st.create = xxx_create;
st.free = xxx_free;
st.init = xxx_init;
st.duplicate = xxx_duplicate;
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 5ca5a3400ca..f05fc61db0d 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -56,7 +56,6 @@
#include "RNA_access.h"
#include "ED_armature.h"
-#include "ED_buttons.h"
#include "ED_physics.h"
#include "ED_screen.h"
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index 459c0dc2448..a5419fea5ca 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -21,8 +21,7 @@
* \ingroup spbuttons
*/
-#ifndef __BUTTONS_INTERN_H__
-#define __BUTTONS_INTERN_H__
+#pragma once
#include "DNA_listBase.h"
#include "RNA_types.h"
@@ -96,5 +95,3 @@ void BUTTONS_OT_toggle_pin(struct wmOperatorType *ot);
void BUTTONS_OT_file_browse(struct wmOperatorType *ot);
void BUTTONS_OT_directory_browse(struct wmOperatorType *ot);
void BUTTONS_OT_context_menu(struct wmOperatorType *ot);
-
-#endif /* __BUTTONS_INTERN_H__ */
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index 3dc5eca8a8b..8e5aa00115b 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -63,7 +63,6 @@
#include "UI_interface.h"
#include "UI_resources.h"
-#include "ED_buttons.h"
#include "ED_node.h"
#include "ED_screen.h"
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 1fcd98246bf..0aa0a0fbc1a 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -55,7 +55,7 @@
/* ******************** default callbacks for buttons space ***************** */
-static SpaceLink *buttons_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *buttons_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceProperties *sbuts;
@@ -647,6 +647,10 @@ static void buttons_area_listener(wmWindow *UNUSED(win),
if (wmn->data == ND_SPACE_PROPERTIES) {
ED_area_tag_redraw(area);
}
+ else if (wmn->data == ND_SPACE_CHANGED) {
+ ED_area_tag_redraw(area);
+ sbuts->preview = 1;
+ }
break;
case NC_ID:
if (wmn->action == NA_RENAME) {
@@ -687,6 +691,12 @@ static void buttons_area_listener(wmWindow *UNUSED(win),
sbuts->preview = 1;
}
break;
+ case NC_SCREEN:
+ if (wmn->data == ND_LAYOUTSET) {
+ ED_area_tag_redraw(area);
+ sbuts->preview = 1;
+ }
+ break;
#ifdef WITH_FREESTYLE
case NC_LINESTYLE:
ED_area_tag_redraw(area);
@@ -762,7 +772,7 @@ void ED_spacetype_buttons(void)
st->spaceid = SPACE_PROPERTIES;
strncpy(st->name, "Buttons", BKE_ST_MAXNAME);
- st->new = buttons_new;
+ st->create = buttons_create;
st->free = buttons_free;
st->init = buttons_init;
st->duplicate = buttons_duplicate;
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index 3b1cc6fcab0..80ce07d39ef 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -259,6 +259,8 @@ typedef struct {
MovieTrackingTrack *track;
MovieTrackingMarker *marker;
+ /** current frame number */
+ int framenr;
/** position of marker in pixel coords */
float marker_pos[2];
/** position and dimensions of marker pattern in pixel coords */
@@ -271,7 +273,7 @@ typedef struct {
int marker_flag;
} MarkerUpdateCb;
-static void to_pixel_space(float r[2], float a[2], int width, int height)
+static void to_pixel_space(float r[2], const float a[2], int width, int height)
{
copy_v2_v2(r, a);
r[0] *= width;
@@ -286,7 +288,8 @@ static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
return;
}
- MovieTrackingMarker *marker = cb->marker;
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(cb->clip, cb->framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_ensure(cb->track, clip_framenr);
marker->flag = cb->marker_flag;
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL);
@@ -300,7 +303,9 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
BKE_movieclip_get_size(cb->clip, cb->user, &width, &height);
- MovieTrackingMarker *marker = cb->marker;
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(cb->clip, cb->framenr);
+ MovieTrackingMarker *marker = BKE_tracking_marker_ensure(cb->track, clip_framenr);
+
if (event == B_MARKER_POS) {
marker->pos[0] = cb->marker_pos[0] / width;
marker->pos[1] = cb->marker_pos[1] / height;
@@ -456,6 +461,7 @@ void uiTemplateMarker(uiLayout *layout,
cb->track = track;
cb->marker = marker;
cb->marker_flag = marker->flag;
+ cb->framenr = user->framenr;
if (compact) {
block = uiLayoutGetBlock(layout);
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index c3aca95910b..c7328ae9f8f 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -49,7 +49,9 @@
#include "clip_intern.h" /* own include */
-static void track_channel_color(MovieTrackingTrack *track, float default_color[3], float color[3])
+static void track_channel_color(MovieTrackingTrack *track,
+ const float default_color[3],
+ float color[3])
{
if (track->flag & TRACK_CUSTOMCOLOR) {
float bg[3];
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 1d510d2989c..07bdd337269 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -1515,7 +1515,7 @@ static void draw_tracking_tracks(SpaceClip *sc,
/* undistort */
if (count) {
- marker_pos = MEM_callocN(2 * sizeof(float) * count, "draw_tracking_tracks marker_pos");
+ marker_pos = MEM_callocN(sizeof(float[2]) * count, "draw_tracking_tracks marker_pos");
track = tracksbase->first;
fp = marker_pos;
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index 589831b1c45..ffd3241a30f 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -114,7 +114,7 @@ static void find_nearest_tracking_segment_cb(void *userdata,
float val)
{
MouseSelectUserData *data = userdata;
- float co[2] = {scene_framenr, val};
+ const float co[2] = {scene_framenr, val};
if (!clip_graph_value_visible(data->sc, value_source)) {
return;
@@ -151,7 +151,7 @@ static void find_nearest_tracking_knot_cb(void *userdata,
float val)
{
MouseSelectUserData *data = userdata;
- float mdiff[2] = {scene_framenr - data->mouse_co[0], val - data->mouse_co[1]};
+ const float mdiff[2] = {scene_framenr - data->mouse_co[0], val - data->mouse_co[1]};
float dist_sq = len_squared_v2(mdiff);
if (!clip_graph_value_visible(data->sc, value_source)) {
@@ -159,7 +159,7 @@ static void find_nearest_tracking_knot_cb(void *userdata,
}
if (data->marker == NULL || dist_sq < data->min_dist_sq) {
- float co[2] = {scene_framenr, val};
+ const float co[2] = {scene_framenr, val};
data->track = track;
data->marker = marker;
@@ -178,7 +178,7 @@ static void mouse_select_init_data(bContext *C, MouseSelectUserData *userdata, c
copy_v2_v2(userdata->mouse_co, co);
}
-static bool mouse_select_knot(bContext *C, float co[2], bool extend)
+static bool mouse_select_knot(bContext *C, const float co[2], bool extend)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -236,7 +236,7 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend)
return false;
}
-static bool mouse_select_curve(bContext *C, float co[2], bool extend)
+static bool mouse_select_curve(bContext *C, const float co[2], bool extend)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index 27493bb5ccd..4848ec72f79 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -21,8 +21,7 @@
* \ingroup spclip
*/
-#ifndef __CLIP_INTERN_H__
-#define __CLIP_INTERN_H__
+#pragma once
struct ARegion;
struct MovieClip;
@@ -245,5 +244,3 @@ void CLIP_OT_select_box(struct wmOperatorType *ot);
void CLIP_OT_select_lasso(struct wmOperatorType *ot);
void CLIP_OT_select_circle(struct wmOperatorType *ot);
void CLIP_OT_select_grouped(struct wmOperatorType *ot);
-
-#endif /* __CLIP_INTERN_H__ */
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 37d5f602291..d27b80efd40 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -237,7 +237,7 @@ static void clip_area_sync_frame_from_scene(ScrArea *area, Scene *scene)
/* ******************** default callbacks for clip space ***************** */
-static SpaceLink *clip_new(const ScrArea *area, const Scene *scene)
+static SpaceLink *clip_create(const ScrArea *area, const Scene *scene)
{
ARegion *region;
SpaceClip *sc;
@@ -684,7 +684,7 @@ static void clip_refresh(const bContext *C, ScrArea *area)
if (main_visible) {
if (region_main && (region_main->flag & RGN_FLAG_HIDDEN)) {
region_main->flag &= ~RGN_FLAG_HIDDEN;
- region_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_main->v2d.flag &= ~V2D_IS_INIT;
view_changed = true;
}
@@ -696,7 +696,7 @@ static void clip_refresh(const bContext *C, ScrArea *area)
else {
if (region_main && !(region_main->flag & RGN_FLAG_HIDDEN)) {
region_main->flag |= RGN_FLAG_HIDDEN;
- region_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_main->v2d.flag &= ~V2D_IS_INIT;
WM_event_remove_handlers((bContext *)C, &region_main->handlers);
view_changed = true;
}
@@ -709,7 +709,7 @@ static void clip_refresh(const bContext *C, ScrArea *area)
if (properties_visible) {
if (region_properties && (region_properties->flag & RGN_FLAG_HIDDEN)) {
region_properties->flag &= ~RGN_FLAG_HIDDEN;
- region_properties->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_properties->v2d.flag &= ~V2D_IS_INIT;
view_changed = true;
}
if (region_properties && region_properties->alignment != RGN_ALIGN_RIGHT) {
@@ -720,7 +720,7 @@ static void clip_refresh(const bContext *C, ScrArea *area)
else {
if (region_properties && !(region_properties->flag & RGN_FLAG_HIDDEN)) {
region_properties->flag |= RGN_FLAG_HIDDEN;
- region_properties->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_properties->v2d.flag &= ~V2D_IS_INIT;
WM_event_remove_handlers((bContext *)C, &region_properties->handlers);
view_changed = true;
}
@@ -733,7 +733,7 @@ static void clip_refresh(const bContext *C, ScrArea *area)
if (tools_visible) {
if (region_tools && (region_tools->flag & RGN_FLAG_HIDDEN)) {
region_tools->flag &= ~RGN_FLAG_HIDDEN;
- region_tools->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_tools->v2d.flag &= ~V2D_IS_INIT;
view_changed = true;
}
if (region_tools && region_tools->alignment != RGN_ALIGN_LEFT) {
@@ -744,7 +744,7 @@ static void clip_refresh(const bContext *C, ScrArea *area)
else {
if (region_tools && !(region_tools->flag & RGN_FLAG_HIDDEN)) {
region_tools->flag |= RGN_FLAG_HIDDEN;
- region_tools->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_tools->v2d.flag &= ~V2D_IS_INIT;
WM_event_remove_handlers((bContext *)C, &region_tools->handlers);
view_changed = true;
}
@@ -757,7 +757,7 @@ static void clip_refresh(const bContext *C, ScrArea *area)
if (preview_visible) {
if (region_preview && (region_preview->flag & RGN_FLAG_HIDDEN)) {
region_preview->flag &= ~RGN_FLAG_HIDDEN;
- region_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_preview->v2d.flag &= ~V2D_IS_INIT;
region_preview->v2d.cur = region_preview->v2d.tot;
view_changed = true;
}
@@ -769,7 +769,7 @@ static void clip_refresh(const bContext *C, ScrArea *area)
else {
if (region_preview && !(region_preview->flag & RGN_FLAG_HIDDEN)) {
region_preview->flag |= RGN_FLAG_HIDDEN;
- region_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_preview->v2d.flag &= ~V2D_IS_INIT;
WM_event_remove_handlers((bContext *)C, &region_preview->handlers);
view_changed = true;
}
@@ -782,7 +782,7 @@ static void clip_refresh(const bContext *C, ScrArea *area)
if (channels_visible) {
if (region_channels && (region_channels->flag & RGN_FLAG_HIDDEN)) {
region_channels->flag &= ~RGN_FLAG_HIDDEN;
- region_channels->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_channels->v2d.flag &= ~V2D_IS_INIT;
view_changed = true;
}
if (region_channels && region_channels->alignment != RGN_ALIGN_LEFT) {
@@ -793,7 +793,7 @@ static void clip_refresh(const bContext *C, ScrArea *area)
else {
if (region_channels && !(region_channels->flag & RGN_FLAG_HIDDEN)) {
region_channels->flag |= RGN_FLAG_HIDDEN;
- region_channels->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_channels->v2d.flag &= ~V2D_IS_INIT;
WM_event_remove_handlers((bContext *)C, &region_channels->handlers);
view_changed = true;
}
@@ -804,7 +804,7 @@ static void clip_refresh(const bContext *C, ScrArea *area)
}
if (view_changed) {
- ED_area_initialize(wm, window, area);
+ ED_area_init(wm, window, area);
ED_area_tag_redraw(area);
}
@@ -1351,7 +1351,7 @@ void ED_spacetype_clip(void)
st->spaceid = SPACE_CLIP;
strncpy(st->name, "Clip", BKE_ST_MAXNAME);
- st->new = clip_new;
+ st->create = clip_create;
st->free = clip_free;
st->init = clip_init;
st->duplicate = clip_duplicate;
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 739701b5595..177a0bc2bcf 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -513,7 +513,7 @@ static bool slide_check_corners(float (*corners)[2])
{
int i, next, prev;
float cross = 0.0f;
- float p[2] = {0.0f, 0.0f};
+ const float p[2] = {0.0f, 0.0f};
if (!isect_point_quad_v2(p, corners[0], corners[1], corners[2], corners[3])) {
return false;
@@ -861,7 +861,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, const wmEvent *event)
BKE_tracking_marker_clamp(data->marker, CLAMP_PAT_DIM);
}
else if (data->action == SLIDE_ACTION_OFFSET) {
- float d[2] = {dx, dy};
+ const float d[2] = {dx, dy};
for (int a = 0; a < data->track->markersnr; a++) {
add_v2_v2v2(data->track->markers[a].pos, data->old_markers[a], d);
}
@@ -940,7 +940,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, const wmEvent *event)
BKE_tracking_marker_clamp(data->marker, CLAMP_SEARCH_DIM);
}
else if (data->area == TRACK_AREA_SEARCH) {
- float d[2] = {dx, dy};
+ const float d[2] = {dx, dy};
add_v2_v2v2(data->min, data->old_search_min, d);
add_v2_v2v2(data->max, data->old_search_max, d);
}
diff --git a/source/blender/editors/space_clip/tracking_ops_intern.h b/source/blender/editors/space_clip/tracking_ops_intern.h
index c29a485e234..5a9a84a235b 100644
--- a/source/blender/editors/space_clip/tracking_ops_intern.h
+++ b/source/blender/editors/space_clip/tracking_ops_intern.h
@@ -21,8 +21,7 @@
* \ingroup spclip
*/
-#ifndef __TRACKING_OPS_INTERN_H__
-#define __TRACKING_OPS_INTERN_H__
+#pragma once
struct ListBase;
struct MovieClip;
@@ -40,5 +39,3 @@ void clip_tracking_hide_cursor(struct bContext *C);
void ed_tracking_deselect_all_tracks(struct ListBase *tracks_base);
void ed_tracking_deselect_all_plane_tracks(struct ListBase *plane_tracks_base);
-
-#endif /* __TRACKING_OPS_INTERN_H__ */
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
index b6f9ca9589f..80d0dd773b2 100644
--- a/source/blender/editors/space_clip/tracking_select.c
+++ b/source/blender/editors/space_clip/tracking_select.c
@@ -153,9 +153,9 @@ static float dist_to_rect(const float co[2],
const float max[2])
{
float d1, d2, d3, d4;
- float p[2] = {co[0] - pos[0], co[1] - pos[1]};
- float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]};
- float v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]};
+ const float p[2] = {co[0] - pos[0], co[1] - pos[1]};
+ const float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]};
+ const float v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]};
d1 = dist_squared_to_line_segment_v2(p, v1, v2);
d2 = dist_squared_to_line_segment_v2(p, v2, v3);
@@ -169,7 +169,7 @@ static float dist_to_rect(const float co[2],
static float dist_to_crns(const float co[2], const float pos[2], const float crns[4][2])
{
float d1, d2, d3, d4;
- float p[2] = {co[0] - pos[0], co[1] - pos[1]};
+ const float p[2] = {co[0] - pos[0], co[1] - pos[1]};
const float *v1 = crns[0], *v2 = crns[1];
const float *v3 = crns[2], *v4 = crns[3];
@@ -744,7 +744,9 @@ static int point_inside_ellipse(const float point[2],
return x * x + y * y < 1.0f;
}
-static int marker_inside_ellipse(MovieTrackingMarker *marker, float offset[2], float ellipse[2])
+static int marker_inside_ellipse(MovieTrackingMarker *marker,
+ const float offset[2],
+ const float ellipse[2])
{
return point_inside_ellipse(marker->pos, offset, ellipse);
}
diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h
index d051e351f3e..d4cb8363266 100644
--- a/source/blender/editors/space_console/console_intern.h
+++ b/source/blender/editors/space_console/console_intern.h
@@ -18,8 +18,7 @@
* \ingroup spconsole
*/
-#ifndef __CONSOLE_INTERN_H__
-#define __CONSOLE_INTERN_H__
+#pragma once
/* internal exports only */
@@ -75,5 +74,3 @@ enum {
DEL_NEXT_SEL,
DEL_PREV_SEL
};
-
-#endif /* __CONSOLE_INTERN_H__ */
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 3c62aeb1759..3a0125356f7 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -46,7 +46,7 @@
/* ******************** default callbacks for console space ***************** */
-static SpaceLink *console_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *console_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceConsole *sconsole;
@@ -312,7 +312,7 @@ void ED_spacetype_console(void)
st->spaceid = SPACE_CONSOLE;
strncpy(st->name, "Console", BKE_ST_MAXNAME);
- st->new = console_new;
+ st->create = console_create;
st->free = console_free;
st->init = console_init;
st->duplicate = console_duplicate;
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 68e9f76abc5..083d41747b3 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -875,7 +875,9 @@ void file_draw_list(const bContext *C, ARegion *region)
sfile->files, file, FILE_SEL_REMOVE, FILE_SEL_EDITING, CHECK_ALL);
}
}
- else {
+
+ /* file_selflag might have been modified by branch above. */
+ if ((file_selflag & FILE_SEL_EDITING) == 0) {
const int txpos = (params->display == FILE_IMGDISPLAY) ? sx : sx + 1 + icon_ofs;
const int typos = (params->display == FILE_IMGDISPLAY) ?
sy - layout->tile_h + layout->textheight :
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index b7e8d35ffee..44131693628 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -21,8 +21,7 @@
* \ingroup spfile
*/
-#ifndef __FILE_INTERN_H__
-#define __FILE_INTERN_H__
+#pragma once
/* internal exports only */
@@ -116,5 +115,3 @@ void file_execute_region_panels_register(struct ARegionType *art);
/* file_utils.c */
void file_tile_boundbox(const ARegion *region, FileLayout *layout, const int file, rcti *r_bounds);
-
-#endif /* __FILE_INTERN_H__ */
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 45e45093238..e9ffd4583d7 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -518,7 +518,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
rect.ymin = rect.ymax = event->mval[1];
if (!ED_fileselect_layout_is_inside_pt(sfile->layout, &region->v2d, rect.xmin, rect.ymin)) {
- return OPERATOR_CANCELLED;
+ return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
if (sfile && sfile->params) {
@@ -1697,6 +1697,19 @@ static int file_exec(bContext *C, wmOperator *exec_op)
return OPERATOR_FINISHED;
}
+static int file_exec_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ ARegion *region = CTX_wm_region(C);
+ SpaceFile *sfile = CTX_wm_space_file(C);
+
+ if (!ED_fileselect_layout_is_inside_pt(
+ sfile->layout, &region->v2d, event->mval[0], event->mval[1])) {
+ return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
+ }
+
+ return file_exec(C, op);
+}
+
void FILE_OT_execute(struct wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -1707,6 +1720,7 @@ void FILE_OT_execute(struct wmOperatorType *ot)
ot->idname = "FILE_OT_execute";
/* api callbacks */
+ ot->invoke = file_exec_invoke;
ot->exec = file_exec;
ot->poll = file_operator_poll;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 3ce80c11160..67ea22a7ef5 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -2212,7 +2212,7 @@ static bool file_is_blend_backup(const char *str)
}
}
- return (retval);
+ return retval;
}
/* TODO: Maybe we should move this to BLI?
diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h
index e90a8659417..53937e7a743 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -21,8 +21,7 @@
* \ingroup spfile
*/
-#ifndef __FILELIST_H__
-#define __FILELIST_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -139,5 +138,3 @@ bool filelist_cache_previews_running(struct FileList *filelist);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h
index 17cfdf1c7f0..c4af27a25aa 100644
--- a/source/blender/editors/space_file/fsmenu.h
+++ b/source/blender/editors/space_file/fsmenu.h
@@ -21,8 +21,7 @@
* \ingroup spfile
*/
-#ifndef __FSMENU_H__
-#define __FSMENU_H__
+#pragma once
/* XXX could become UserPref */
#define FSMENU_RECENT_MAX 10
@@ -76,5 +75,3 @@ void fsmenu_refresh_bookmarks_status(struct wmWindowManager *wm, struct FSMenu *
int fsmenu_get_active_indices(struct FSMenu *fsmenu,
enum FSMenuCategory category,
const char *dir);
-
-#endif
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 43939b9ff54..f520f91b89b 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -91,7 +91,7 @@ static ARegion *file_tool_props_region_ensure(ScrArea *area, ARegion *region_pre
/* ******************** default callbacks for file space ***************** */
-static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *file_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceFile *sfile;
@@ -235,7 +235,7 @@ static void file_ensure_valid_region_state(bContext *C,
ARegion *region_ui = BKE_area_find_region_type(area, RGN_TYPE_UI);
ARegion *region_props = BKE_area_find_region_type(area, RGN_TYPE_TOOL_PROPS);
ARegion *region_execute = BKE_area_find_region_type(area, RGN_TYPE_EXECUTE);
- bool needs_init = false; /* To avoid multiple ED_area_initialize() calls. */
+ bool needs_init = false; /* To avoid multiple ED_area_init() calls. */
/* If there's an file-operation, ensure we have the option and execute region */
if (sfile->op && (region_props == NULL)) {
@@ -261,7 +261,7 @@ static void file_ensure_valid_region_state(bContext *C,
}
if (needs_init) {
- ED_area_initialize(wm, win, area);
+ ED_area_init(wm, win, area);
}
}
@@ -693,7 +693,7 @@ void ED_spacetype_file(void)
st->spaceid = SPACE_FILE;
strncpy(st->name, "File", BKE_ST_MAXNAME);
- st->new = file_new;
+ st->create = file_create;
st->free = file_free;
st->init = file_init;
st->exit = file_exit;
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 5ae175f525f..f5861e792bc 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -810,9 +810,9 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
correct_bezpart(v1, v2, v3, v4);
- BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3);
+ BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float[3]));
BKE_curve_forward_diff_bezier(
- v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3);
+ v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float[3]));
for (fp = data; resol; resol--, fp += 3) {
immVertex2fv(pos, fp);
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 68fdef54a53..90fe95c6818 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1487,7 +1487,7 @@ static int graphkeys_decimate_invoke(bContext *C, wmOperator *op, const wmEvent
dgo->area = CTX_wm_area(C);
dgo->region = CTX_wm_region(C);
- /* initialise percentage so that it will have the correct value before the first mouse move. */
+ /* Initialize percentage so that it will have the correct value before the first mouse move. */
decimate_mouse_update_percentage(dgo, op, event);
decimate_draw_status_header(op, dgo);
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index 3ec36e43278..d00e911e3fc 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -21,8 +21,7 @@
* \ingroup spgraph
*/
-#ifndef __GRAPH_INTERN_H__
-#define __GRAPH_INTERN_H__
+#pragma once
struct ARegion;
struct ARegionType;
@@ -177,5 +176,3 @@ bool graphop_selected_fcurve_poll(struct bContext *C);
/* graph_ops.c */
void graphedit_keymap(struct wmKeyConfig *keyconf);
void graphedit_operatortypes(void);
-
-#endif /* __GRAPH_INTERN_H__ */
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index b1d995a7a0b..a4f76384cc6 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -64,7 +64,7 @@
/* ******************** default callbacks for ipo space ***************** */
-static SpaceLink *graph_new(const ScrArea *UNUSED(area), const Scene *scene)
+static SpaceLink *graph_create(const ScrArea *UNUSED(area), const Scene *scene)
{
ARegion *region;
SpaceGraph *sipo;
@@ -838,7 +838,7 @@ void ED_spacetype_ipo(void)
st->spaceid = SPACE_GRAPH;
strncpy(st->name, "Graph", BKE_ST_MAXNAME);
- st->new = graph_new;
+ st->create = graph_create;
st->free = graph_free;
st->init = graph_init;
st->duplicate = graph_duplicate;
diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt
index 12de74c6ae7..24ec7a89397 100644
--- a/source/blender/editors/space_image/CMakeLists.txt
+++ b/source/blender/editors/space_image/CMakeLists.txt
@@ -23,6 +23,7 @@ set(INC
../../blentranslation
../../bmesh
../../depsgraph
+ ../../draw
../../gpu
../../imbuf
../../makesdna
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 1038011e480..f70589ac5f1 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -168,9 +168,9 @@ void ED_image_draw_info(Scene *scene,
uchar green[3] = {0, 255, 0};
uchar blue[3] = {100, 100, 255};
#else
- uchar red[3] = {255, 255, 255};
- uchar green[3] = {255, 255, 255};
- uchar blue[3] = {255, 255, 255};
+ const uchar red[3] = {255, 255, 255};
+ const uchar green[3] = {255, 255, 255};
+ const uchar blue[3] = {255, 255, 255};
#endif
float hue = 0, sat = 0, val = 0, lum = 0, u = 0, v = 0;
float col[4], finalcol[4];
@@ -465,7 +465,7 @@ void ED_image_draw_info(Scene *scene,
static void sima_draw_zbuf_pixels(
float x1, float y1, int rectx, int recty, const int *rect, float zoomx, float zoomy)
{
- float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
+ const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
/* Slowwww */
float *rectf = MEM_mallocN(rectx * recty * sizeof(float), "temp");
@@ -494,7 +494,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene,
{
float bias, scale, *rectf, clip_end;
int a;
- float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
+ const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
if (scene->camera && scene->camera->type == OB_CAMERA) {
bias = ((Camera *)scene->camera->data)->clip_start;
@@ -798,7 +798,7 @@ static void draw_udim_tile_grid(uint pos_attr,
{
float x1, y1;
UI_view2d_view_to_region_fl(&region->v2d, x, y, &x1, &y1);
- int gridpos[5][2] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}};
+ const int gridpos[5][2] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}};
for (int i = 0; i < 4; i++) {
immAttr3fv(color_attr, color);
immVertex2f(pos_attr, x1 + gridpos[i][0] * stepx, y1 + gridpos[i][1] * stepy);
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index cb0fdcf23ca..4eb4e6649d9 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -400,7 +400,10 @@ bool ED_image_slot_cycle(struct Image *image, int direction)
}
}
- if (i == num_slots) {
+ if (num_slots == 1) {
+ image->render_slot = 0;
+ }
+ else if (i == num_slots) {
image->render_slot = ((cur == 1) ? 0 : 1);
}
diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h
index ae26363ad79..e6f5988aed8 100644
--- a/source/blender/editors/space_image/image_intern.h
+++ b/source/blender/editors/space_image/image_intern.h
@@ -21,8 +21,7 @@
* \ingroup spimage
*/
-#ifndef __IMAGE_INTERN_H__
-#define __IMAGE_INTERN_H__
+#pragma once
/* internal exports only */
struct ARegion;
@@ -96,5 +95,3 @@ void IMAGE_OT_tile_fill(struct wmOperatorType *ot);
/* image_panels.c */
struct ImageUser *ntree_get_active_iuser(struct bNodeTree *ntree);
void image_buttons_register(struct ARegionType *art);
-
-#endif /* __IMAGE_INTERN_H__ */
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 4e410d35df0..1a98ec0e7c1 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -69,7 +69,6 @@
#include "DEG_depsgraph.h"
-#include "GPU_draw.h"
#include "GPU_immediate.h"
#include "GPU_state.h"
@@ -2769,7 +2768,7 @@ static int image_invert_exec(bContext *C, wmOperator *op)
ED_image_undo_push_end();
/* force GPU reupload, all image is invalid */
- GPU_free_image(ima);
+ BKE_image_free_gputextures(ima);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
@@ -2860,7 +2859,7 @@ static int image_scale_exec(bContext *C, wmOperator *op)
ED_image_undo_push_end();
/* force GPU reupload, all image is invalid */
- GPU_free_image(ima);
+ BKE_image_free_gputextures(ima);
DEG_id_tag_update(&ima->id, 0);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
@@ -3715,7 +3714,7 @@ static void draw_fill_tile(PointerRNA *ptr, uiLayout *layout)
uiItemR(col[1], ptr, "float", 0, NULL, ICON_NONE);
}
-static void initialize_fill_tile(PointerRNA *ptr, Image *ima, ImageTile *tile)
+static void tile_fill_init(PointerRNA *ptr, Image *ima, ImageTile *tile)
{
ImageUser iuser;
BKE_imageuser_default(&iuser);
@@ -3828,7 +3827,7 @@ static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
}
ImageTile *tile = BLI_findlink(&ima->tiles, ima->active_tile_index);
- initialize_fill_tile(op->ptr, ima, tile);
+ tile_fill_init(op->ptr, ima, tile);
RNA_int_set(op->ptr, "number", next_number);
RNA_int_set(op->ptr, "count", 1);
@@ -3974,7 +3973,7 @@ static int tile_fill_exec(bContext *C, wmOperator *op)
static int tile_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- initialize_fill_tile(op->ptr, CTX_data_edit_image(C), NULL);
+ tile_fill_init(op->ptr, CTX_data_edit_image(C), NULL);
return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X);
}
diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c
index e0c44c3a0ba..27b84307f7d 100644
--- a/source/blender/editors/space_image/image_undo.c
+++ b/source/blender/editors/space_image/image_undo.c
@@ -60,8 +60,6 @@
#include "ED_undo.h"
#include "ED_util.h"
-#include "GPU_draw.h"
-
#include "WM_api.h"
static CLG_LogRef LOG = {"ed.image.undo"};
@@ -295,7 +293,8 @@ static void ptile_restore_runtime_list(ListBase *paint_tiles)
SWAP(uint *, ptile->rect.uint, tmpibuf->rect);
}
- GPU_free_image(image); /* force OpenGL reload (maybe partial update will operate better?) */
+ BKE_image_free_gputextures(
+ image); /* force OpenGL reload (maybe partial update will operate better?) */
if (ibuf->rect_float) {
ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
}
@@ -570,7 +569,7 @@ static void uhandle_restore_list(ListBase *undo_handles, bool use_init)
if (changed) {
BKE_image_mark_dirty(image, ibuf);
- GPU_free_image(image); /* force OpenGL reload */
+ BKE_image_free_gputextures(image); /* force OpenGL reload */
if (ibuf->rect_float) {
ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index d7d85112497..c01bc01588e 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -75,11 +75,10 @@
#include "GPU_batch_presets.h"
#include "GPU_framebuffer.h"
#include "GPU_viewport.h"
-#include "image_intern.h"
-/* TODO(fclem) remove bad level calls */
-#include "../draw/DRW_engine.h"
-#include "wm_draw.h"
+#include "DRW_engine_types.h"
+
+#include "image_intern.h"
/**************************** common state *****************************/
@@ -117,7 +116,7 @@ static void image_user_refresh_scene(const bContext *C, SpaceImage *sima)
/* ******************** default callbacks for image space ***************** */
-static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *image_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceImage *simage;
@@ -643,17 +642,18 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
// View2DScrollers *scrollers;
float col[3];
- /* XXX This is in order to draw UI batches with the DRW
- * old context since we now use it for drawing the entire area. */
- gpu_batch_presets_reset();
+ GPU_batch_presets_reset();
+ GPUViewport *viewport = WM_draw_region_get_viewport(region);
+ GPUFrameBuffer *framebuffer_default, *framebuffer_overlay;
+
+ framebuffer_default = GPU_viewport_framebuffer_default_get(viewport);
+ framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport);
- GPUViewport *viewport = region->draw_buffer->viewport;
- DefaultFramebufferList *fbl = GPU_viewport_framebuffer_list_get(viewport);
- GPU_framebuffer_bind(fbl->default_fb);
+ GPU_framebuffer_bind(framebuffer_default);
GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
GPU_clear(GPU_COLOR_BIT);
- GPU_framebuffer_bind(fbl->overlay_fb);
+ GPU_framebuffer_bind(framebuffer_overlay);
/* XXX not supported yet, disabling for now */
scene->r.scemode &= ~R_COMP_CROP;
@@ -1093,7 +1093,7 @@ void ED_spacetype_image(void)
st->spaceid = SPACE_IMAGE;
strncpy(st->name, "Image", BKE_ST_MAXNAME);
- st->new = image_new;
+ st->create = image_create;
st->free = image_free;
st->init = image_init;
st->duplicate = image_duplicate;
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index 6c818257ec7..72533b88406 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -270,12 +270,12 @@ void *info_text_pick(const SpaceInfo *sinfo,
int info_textview_height(const SpaceInfo *sinfo, const ARegion *region, const ReportList *reports)
{
- int mval[2] = {INT_MAX, INT_MAX};
+ const int mval[2] = {INT_MAX, INT_MAX};
return info_textview_main__internal(sinfo, region, reports, false, mval, NULL, NULL);
}
void info_textview_main(const SpaceInfo *sinfo, const ARegion *region, const ReportList *reports)
{
- int mval[2] = {INT_MAX, INT_MAX};
+ const int mval[2] = {INT_MAX, INT_MAX};
info_textview_main__internal(sinfo, region, reports, true, mval, NULL, NULL);
}
diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h
index 79bfb1fa047..a19ebe5ef04 100644
--- a/source/blender/editors/space_info/info_intern.h
+++ b/source/blender/editors/space_info/info_intern.h
@@ -21,8 +21,7 @@
* \ingroup spinfo
*/
-#ifndef __INFO_INTERN_H__
-#define __INFO_INTERN_H__
+#pragma once
/* internal exports only */
@@ -65,5 +64,3 @@ void INFO_OT_select_box(struct wmOperatorType *ot);
void INFO_OT_report_replay(struct wmOperatorType *ot);
void INFO_OT_report_delete(struct wmOperatorType *ot);
void INFO_OT_report_copy(struct wmOperatorType *ot);
-
-#endif /* __INFO_INTERN_H__ */
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 836830916ed..b9153ec0cbd 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -53,7 +53,7 @@
/* ******************** default callbacks for info space ***************** */
-static SpaceLink *info_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *info_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceInfo *sinfo;
@@ -287,7 +287,7 @@ void ED_spacetype_info(void)
st->spaceid = SPACE_INFO;
strncpy(st->name, "Info", BKE_ST_MAXNAME);
- st->new = info_new;
+ st->create = info_create;
st->free = info_free;
st->init = info_init;
st->duplicate = info_duplicate;
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index eee8b989cc2..93a79d9a2bc 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -264,7 +264,7 @@ static bool textview_draw_string(TextViewDrawState *tds,
if (tds->sel[0] != tds->sel[1]) {
textview_step_sel(tds, -final_offset);
- int pos[2] = {tds->xy[0], line_bottom};
+ const int pos[2] = {tds->xy[0], line_bottom};
textview_draw_sel(s, pos, len, tds, bg_sel);
}
diff --git a/source/blender/editors/space_info/textview.h b/source/blender/editors/space_info/textview.h
index 41f8baf634e..7520dbce191 100644
--- a/source/blender/editors/space_info/textview.h
+++ b/source/blender/editors/space_info/textview.h
@@ -18,8 +18,7 @@
* \ingroup spinfo
*/
-#ifndef __TEXTVIEW_H__
-#define __TEXTVIEW_H__
+#pragma once
enum eTextViewContext_LineFlag {
TVC_LINE_FG = (1 << 0),
@@ -79,5 +78,3 @@ int textview_draw(struct TextViewContext *tvc,
const int mval_init[2],
void **r_mval_pick_item,
int *r_mval_pick_offset);
-
-#endif /* __TEXTVIEW_H__ */
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 96599fd92a7..97939a93d01 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -378,7 +378,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uin
}
/* helper call to setup dashed-lines for strip outlines */
-static uint nla_draw_use_dashed_outlines(float color[4], bool muted)
+static uint nla_draw_use_dashed_outlines(const float color[4], bool muted)
{
/* Note that we use dashed shader here, and make it draw solid lines if not muted... */
uint shdr_pos = GPU_vertformat_attr_add(
diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h
index 6b0429230fe..9a9ea161f56 100644
--- a/source/blender/editors/space_nla/nla_intern.h
+++ b/source/blender/editors/space_nla/nla_intern.h
@@ -21,8 +21,7 @@
* \ingroup spnla
*/
-#ifndef __NLA_INTERN_H__
-#define __NLA_INTERN_H__
+#pragma once
/* internal exports only */
@@ -149,5 +148,3 @@ bool nlaedit_is_tweakmode_on(bAnimContext *ac);
void nla_operatortypes(void);
void nla_keymap(wmKeyConfig *keyconf);
-
-#endif /* __NLA_INTERN_H__ */
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index b09536e0621..7bbfe451eed 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -57,7 +57,7 @@
/* ******************** default callbacks for nla space ***************** */
-static SpaceLink *nla_new(const ScrArea *area, const Scene *scene)
+static SpaceLink *nla_create(const ScrArea *area, const Scene *scene)
{
ARegion *region;
SpaceNla *snla;
@@ -608,7 +608,7 @@ void ED_spacetype_nla(void)
st->spaceid = SPACE_NLA;
strncpy(st->name, "NLA", BKE_ST_MAXNAME);
- st->new = nla_new;
+ st->create = nla_create;
st->free = nla_free;
st->init = nla_init;
st->duplicate = nla_duplicate;
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 4203eac16c4..37daa881317 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3576,6 +3576,8 @@ static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout
break;
}
}
+
+ uiItemR(layout, ptr, "hide_value", DEFAULT_FLAGS, NULL, 0);
}
void ED_init_standard_node_socket_type(bNodeSocketType *stype)
@@ -3849,9 +3851,9 @@ bool node_link_bezier_points(
if (node_link_bezier_handles(v2d, snode, link, vec)) {
/* always do all three, to prevent data hanging around */
BKE_curve_forward_diff_bezier(
- vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[0] + 0, resol, sizeof(float) * 2);
+ vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[0] + 0, resol, sizeof(float[2]));
BKE_curve_forward_diff_bezier(
- vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0] + 1, resol, sizeof(float) * 2);
+ vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0] + 1, resol, sizeof(float[2]));
return 1;
}
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 52bd4d68649..3fd0b0a5a58 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -986,7 +986,7 @@ void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha)
else {
const float margin = 3.0f;
- float color[4] = {0.0f, 0.0f, 0.0f, 0.33f};
+ const float color[4] = {0.0f, 0.0f, 0.0f, 0.33f};
UI_draw_roundbox_aa(true,
rct->xmin - margin,
rct->ymin - margin,
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 3c927dbf25f..c88b6a1b297 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -2743,7 +2743,7 @@ static int clear_viewer_border_exec(bContext *C, wmOperator *UNUSED(op))
void NODE_OT_clear_viewer_border(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Clear Viewer Border";
+ ot->name = "Clear Viewer Region";
ot->description = "Clear the boundaries for viewer operations";
ot->idname = "NODE_OT_clear_viewer_border";
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index ef468c63d77..7894fade517 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -56,6 +56,7 @@
#include "UI_resources.h"
#include "NOD_common.h"
+#include "NOD_socket.h"
#include "node_intern.h" /* own include */
static bool node_group_operator_active(bContext *C)
@@ -179,6 +180,26 @@ void NODE_OT_group_edit(wmOperatorType *ot)
/* ******************** 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)
+{
+ AnimationBasePathChange *basepath_change = MEM_callocN(sizeof(*basepath_change), AT);
+ basepath_change->src_basepath = src_basepath;
+ basepath_change->dst_basepath = dst_basepath;
+ return basepath_change;
+}
+
+static void animation_basepath_change_free(AnimationBasePathChange *basepath_change)
+{
+ if (basepath_change->src_basepath != basepath_change->dst_basepath) {
+ MEM_freeN((void *)basepath_change->src_basepath);
+ }
+ MEM_freeN((void *)basepath_change->dst_basepath);
+ MEM_freeN(basepath_change);
+}
+
/* returns 1 if its OK */
static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
{
@@ -217,16 +238,11 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
/* keep track of this node's RNA "base" path (the part of the path identifying the node)
* if the old nodetree has animation data which potentially covers this node
*/
+ const char *old_animation_basepath = NULL;
if (wgroup->adt) {
PointerRNA ptr;
- char *path;
-
RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr);
- path = RNA_path_from_ID_to_struct(&ptr);
-
- if (path) {
- BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
- }
+ old_animation_basepath = RNA_path_from_ID_to_struct(&ptr);
}
/* migrate node */
@@ -236,6 +252,14 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
/* ensure unique node name in the node tree */
nodeUniqueName(ntree, node);
+ if (wgroup->adt) {
+ PointerRNA ptr;
+ RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
+ const char *new_animation_basepath = RNA_path_from_ID_to_struct(&ptr);
+ BLI_addtail(&anim_basepaths,
+ animation_basepath_change_new(old_animation_basepath, new_animation_basepath));
+ }
+
if (!node->parent) {
node->locx += gnode->locx;
node->locy += gnode->locy;
@@ -258,7 +282,6 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
/* and copy across the animation,
* note that the animation data's action can be NULL here */
if (wgroup->adt) {
- LinkData *ld, *ldn = NULL;
bAction *waction;
/* firstly, wgroup needs to temporary dummy action
@@ -266,14 +289,11 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
waction = wgroup->adt->action = BKE_action_copy(bmain, wgroup->adt->action);
/* now perform the moving */
- BKE_animdata_separate_by_basepath(bmain, &wgroup->id, &ntree->id, &anim_basepaths);
+ BKE_animdata_transfer_by_basepath(bmain, &wgroup->id, &ntree->id, &anim_basepaths);
/* paths + their wrappers need to be freed */
- for (ld = anim_basepaths.first; ld; ld = ldn) {
- ldn = ld->next;
-
- MEM_freeN(ld->data);
- BLI_freelinkN(&anim_basepaths, ld);
+ LISTBASE_FOREACH_MUTABLE (AnimationBasePathChange *, basepath_change, &anim_basepaths) {
+ animation_basepath_change_free(basepath_change);
}
/* free temp action too */
@@ -458,7 +478,7 @@ static int node_group_separate_selected(
path = RNA_path_from_ID_to_struct(&ptr);
if (path) {
- BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+ BLI_addtail(&anim_basepaths, animation_basepath_change_new(path, path));
}
}
@@ -511,17 +531,12 @@ static int node_group_separate_selected(
/* and copy across the animation,
* note that the animation data's action can be NULL here */
if (ngroup->adt) {
- LinkData *ld, *ldn = NULL;
-
/* now perform the moving */
- BKE_animdata_separate_by_basepath(bmain, &ngroup->id, &ntree->id, &anim_basepaths);
+ BKE_animdata_transfer_by_basepath(bmain, &ngroup->id, &ntree->id, &anim_basepaths);
/* paths + their wrappers need to be freed */
- for (ld = anim_basepaths.first; ld; ld = ldn) {
- ldn = ld->next;
-
- MEM_freeN(ld->data);
- BLI_freelinkN(&anim_basepaths, ld);
+ LISTBASE_FOREACH_MUTABLE (AnimationBasePathChange *, basepath_change, &anim_basepaths) {
+ animation_basepath_change_free(basepath_change);
}
}
@@ -685,7 +700,8 @@ static bool node_group_make_test_selected(bNodeTree *ntree,
return true;
}
-static int node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, float *max)
+static int node_get_selected_minmax(
+ bNodeTree *ntree, bNode *gnode, float *min, float *max, bool use_size)
{
bNode *node;
float loc[2];
@@ -696,6 +712,11 @@ static int node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min,
if (node_group_make_use_node(node, gnode)) {
nodeToView(node, 0.0f, 0.0f, &loc[0], &loc[1]);
minmax_v2v2_v2(min, max, loc);
+ if (use_size) {
+ loc[0] += node->width;
+ loc[1] -= node->height;
+ minmax_v2v2_v2(min, max, loc);
+ }
totselect++;
}
}
@@ -713,10 +734,10 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
Main *bmain = CTX_data_main(C);
bNodeTree *ngroup = (bNodeTree *)gnode->id;
bNodeLink *link, *linkn;
- bNode *node, *nextn;
- bNodeSocket *sock;
+ bNode *node, *nextn, *link_node;
+ bNodeSocket *sock, *link_sock;
ListBase anim_basepaths = {NULL, NULL};
- float min[2], max[2], center[2];
+ float min[2], max[2], real_min[2], real_max[2], center[2];
int totselect;
bool expose_visible = false;
bNode *input_node, *output_node;
@@ -730,10 +751,12 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
nodeSetSelected(node, false);
}
- totselect = node_get_selected_minmax(ntree, gnode, min, max);
+ totselect = node_get_selected_minmax(ntree, gnode, min, max, false);
add_v2_v2v2(center, min, max);
mul_v2_fl(center, 0.5f);
+ node_get_selected_minmax(ntree, gnode, real_min, real_max, true);
+
/* auto-add interface for "solo" nodes */
if (totselect == 1) {
expose_visible = true;
@@ -754,7 +777,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
path = RNA_path_from_ID_to_struct(&ptr);
if (path) {
- BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+ BLI_addtail(&anim_basepaths, animation_basepath_change_new(path, path));
}
}
@@ -774,16 +797,11 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
/* move animation data over */
if (ntree->adt) {
- LinkData *ld, *ldn = NULL;
-
- BKE_animdata_separate_by_basepath(bmain, &ntree->id, &ngroup->id, &anim_basepaths);
+ BKE_animdata_transfer_by_basepath(bmain, &ntree->id, &ngroup->id, &anim_basepaths);
/* paths + their wrappers need to be freed */
- for (ld = anim_basepaths.first; ld; ld = ldn) {
- ldn = ld->next;
-
- MEM_freeN(ld->data);
- BLI_freelinkN(&anim_basepaths, ld);
+ LISTBASE_FOREACH_MUTABLE (AnimationBasePathChange *, basepath_change, &anim_basepaths) {
+ animation_basepath_change_free(basepath_change);
}
}
@@ -792,12 +810,12 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
/* create input node */
input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT);
- input_node->locx = min[0] - center[0] - offsetx;
+ input_node->locx = real_min[0] - center[0] - offsetx;
input_node->locy = -offsety;
/* create output node */
output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT);
- output_node->locx = max[0] - center[0] + offsetx;
+ output_node->locx = real_max[0] - center[0] + offsetx * 0.25f;
output_node->locy = -offsety;
/* relink external sockets */
@@ -813,12 +831,9 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
*/
nodeRemLink(ntree, link);
}
- else if (fromselect && toselect) {
- BLI_remlink(&ntree->links, link);
- BLI_addtail(&ngroup->links, link);
- }
- else if (toselect) {
- bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link->tonode, link->tosock);
+ else if (toselect && !fromselect) {
+ node_socket_skip_reroutes(&ntree->links, link->tonode, link->tosock, &link_node, &link_sock);
+ bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link_node, link_sock);
bNodeSocket *input_sock;
/* update the group node and interface node sockets,
@@ -835,7 +850,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
link->tonode = gnode;
link->tosock = node_group_find_input_socket(gnode, iosock->identifier);
}
- else if (fromselect) {
+ else if (fromselect && !toselect) {
/* First check whether the source of this link is already connected to an output.
* If yes, reuse that output instead of duplicating it. */
bool connected = false;
@@ -851,8 +866,9 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
}
if (!connected) {
- bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(
- ngroup, link->fromnode, link->fromsock);
+ node_socket_skip_reroutes(
+ &ntree->links, link->fromnode, link->fromsock, &link_node, &link_sock);
+ bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link_node, link_sock);
bNodeSocket *output_sock;
/* update the group node and interface node sockets,
@@ -872,6 +888,19 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
}
}
+ /* move internal links */
+ for (link = ntree->links.first; link; link = linkn) {
+ int fromselect = node_group_make_use_node(link->fromnode, gnode);
+ int toselect = node_group_make_use_node(link->tonode, gnode);
+
+ linkn = link->next;
+
+ if (fromselect && toselect) {
+ BLI_remlink(&ntree->links, link);
+ BLI_addtail(&ngroup->links, link);
+ }
+ }
+
/* move nodes in the group to the center */
for (node = ngroup->nodes.first; node; node = node->next) {
if (node_group_make_use_node(node, gnode) && !node->parent) {
@@ -953,7 +982,7 @@ static bNode *node_group_make_from_selected(const bContext *C,
float min[2], max[2];
int totselect;
- totselect = node_get_selected_minmax(ntree, NULL, min, max);
+ totselect = node_get_selected_minmax(ntree, NULL, min, max, false);
/* don't make empty group */
if (totselect == 0) {
return NULL;
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 04186c3a727..9461892360e 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -21,8 +21,7 @@
* \ingroup spnode
*/
-#ifndef __NODE_INTERN_H__
-#define __NODE_INTERN_H__
+#pragma once
#include "BKE_node.h"
#include "UI_interface.h"
@@ -301,5 +300,3 @@ enum eNodeSpace_ButEvents {
B_NODE_LOADIMAGE,
B_NODE_SETIMAGE,
};
-
-#endif /* __NODE_INTERN_H__ */
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 0a4607d2869..a09c70b794a 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -251,6 +251,12 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree,
}
}
+ /* Always allow linking to an reroute node. The socket type of the reroute sockets might change
+ * after the link has been created. */
+ if (node->type == NODE_REROUTE) {
+ return node->outputs.first;
+ }
+
return NULL;
}
@@ -998,7 +1004,7 @@ void NODE_OT_link_make(wmOperatorType *ot)
}
/* ********************** Cut Link operator ***************** */
-static bool cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot)
+static bool cut_links_intersect(bNodeLink *link, const float mcoords[][2], int tot)
{
float coord_array[NODE_LINK_RESOL + 1][2];
int i, b;
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index d4adad3fc25..6d570001347 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -244,7 +244,7 @@ void snode_group_offset(SpaceNode *snode, float *x, float *y)
/* ******************** default callbacks for node space ***************** */
-static SpaceLink *node_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *node_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceNode *snode;
@@ -954,7 +954,7 @@ void ED_spacetype_node(void)
st->spaceid = SPACE_NODE;
strncpy(st->name, "Node", BKE_ST_MAXNAME);
- st->new = node_new;
+ st->create = node_create;
st->free = node_free;
st->init = node_init;
st->duplicate = node_duplicate;
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 0964e0c753e..efb91528e14 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -142,10 +142,14 @@ TreeTraversalAction outliner_find_selected_objects(TreeElement *te, void *custom
*/
void ED_outliner_selected_objects_get(const bContext *C, ListBase *objects)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
struct IDsSelectedData data = {{NULL}};
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, outliner_find_selected_objects, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ outliner_find_selected_objects,
+ &data);
LISTBASE_FOREACH (LinkData *, link, &data.selected_array) {
TreeElement *ten_selected = (TreeElement *)link->data;
Object *ob = (Object *)TREESTORE(ten_selected)->id;
@@ -162,14 +166,15 @@ void ED_outliner_selected_objects_get(const bContext *C, ListBase *objects)
bool ED_outliner_collections_editor_poll(bContext *C)
{
- SpaceOutliner *so = CTX_wm_space_outliner(C);
- return (so != NULL) && ELEM(so->outlinevis, SO_VIEW_LAYER, SO_SCENES, SO_LIBRARIES);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+ return (space_outliner != NULL) &&
+ ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES, SO_LIBRARIES);
}
static bool outliner_view_layer_collections_editor_poll(bContext *C)
{
- SpaceOutliner *so = CTX_wm_space_outliner(C);
- return (so != NULL) && (so->outlinevis == SO_VIEW_LAYER);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+ return (space_outliner != NULL) && (space_outliner->outlinevis == SO_VIEW_LAYER);
}
/** \} */
@@ -203,7 +208,7 @@ static TreeTraversalAction collection_find_selected_to_add(TreeElement *te, void
static int collection_new_exec(bContext *C, wmOperator *op)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -215,10 +220,14 @@ static int collection_new_exec(bContext *C, wmOperator *op)
};
if (RNA_boolean_get(op->ptr, "nested")) {
- outliner_build_tree(bmain, scene, view_layer, soops, region);
+ outliner_build_tree(bmain, scene, view_layer, space_outliner, region);
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, collection_find_selected_to_add, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ collection_find_selected_to_add,
+ &data);
if (data.error) {
BKE_report(op->reports, RPT_ERROR, "More than one collection is selected");
@@ -240,7 +249,7 @@ static int collection_new_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&data.collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
- outliner_cleanup_tree(soops);
+ outliner_cleanup_tree(space_outliner);
WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
return OPERATOR_FINISHED;
}
@@ -273,7 +282,7 @@ void OUTLINER_OT_collection_new(wmOperatorType *ot)
struct CollectionEditData {
Scene *scene;
- SpaceOutliner *soops;
+ SpaceOutliner *space_outliner;
GSet *collections_to_edit;
};
@@ -303,11 +312,11 @@ static TreeTraversalAction collection_find_data_to_edit(TreeElement *te, void *c
void outliner_collection_delete(
bContext *C, Main *bmain, Scene *scene, ReportList *reports, bool hierarchy)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
struct CollectionEditData data = {
.scene = scene,
- .soops = soops,
+ .space_outliner = space_outliner,
};
data.collections_to_edit = BLI_gset_ptr_new(__func__);
@@ -315,7 +324,7 @@ void outliner_collection_delete(
/* We first walk over and find the Collections we actually want to delete
* (ignoring duplicates). */
outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, collection_find_data_to_edit, &data);
+ space_outliner, &space_outliner->tree, 0, TSE_SELECTED, collection_find_data_to_edit, &data);
/* Effectively delete the collections. */
GSetIterator collections_to_edit_iter;
@@ -436,14 +445,18 @@ static TreeTraversalAction outliner_find_first_selected_layer_collection(TreeEle
static LayerCollection *outliner_active_layer_collection(bContext *C)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
struct CollectionObjectsSelectData data = {
.layer_collection = NULL,
};
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, outliner_find_first_selected_layer_collection, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ outliner_find_first_selected_layer_collection,
+ &data);
return data.layer_collection;
}
@@ -527,14 +540,18 @@ static TreeTraversalAction outliner_find_first_selected_collection(TreeElement *
static TreeElement *outliner_active_collection(bContext *C)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
struct CollectionDuplicateData data = {
.te = NULL,
};
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, outliner_find_first_selected_collection, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ outliner_find_first_selected_collection,
+ &data);
return data.te;
}
@@ -635,10 +652,10 @@ static int collection_link_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Collection *active_collection = CTX_data_layer_collection(C)->collection;
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
struct CollectionEditData data = {
.scene = scene,
- .soops = soops,
+ .space_outliner = space_outliner,
};
if (ID_IS_LINKED(active_collection) ||
@@ -651,7 +668,7 @@ static int collection_link_exec(bContext *C, wmOperator *op)
/* We first walk over and find the Collections we actually want to link (ignoring duplicates). */
outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, collection_find_data_to_edit, &data);
+ space_outliner, &space_outliner->tree, 0, TSE_SELECTED, collection_find_data_to_edit, &data);
/* Effectively link the collections. */
GSetIterator collections_to_edit_iter;
@@ -697,10 +714,10 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
struct CollectionEditData data = {
.scene = scene,
- .soops = soops,
+ .space_outliner = space_outliner,
};
data.collections_to_edit = BLI_gset_ptr_new(__func__);
@@ -708,7 +725,7 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op))
/* We first walk over and find the Collections we actually want to instance
* (ignoring duplicates). */
outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, collection_find_data_to_edit, &data);
+ space_outliner, &space_outliner->tree, 0, TSE_SELECTED, collection_find_data_to_edit, &data);
/* Find an active collection to add to, that doesn't give dependency cycles. */
LayerCollection *active_lc = BKE_layer_collection_get_active(view_layer);
@@ -790,21 +807,25 @@ static TreeTraversalAction layer_collection_find_data_to_edit(TreeElement *te, v
static bool collections_view_layer_poll(bContext *C, bool clear, int flag)
{
/* Poll function so the right click menu show current state of selected collections. */
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
- if (!(soops && soops->outlinevis == SO_VIEW_LAYER)) {
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+ if (!(space_outliner && space_outliner->outlinevis == SO_VIEW_LAYER)) {
return false;
}
Scene *scene = CTX_data_scene(C);
struct CollectionEditData data = {
.scene = scene,
- .soops = soops,
+ .space_outliner = space_outliner,
};
data.collections_to_edit = BLI_gset_ptr_new(__func__);
bool result = false;
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, layer_collection_find_data_to_edit, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ layer_collection_find_data_to_edit,
+ &data);
GSetIterator collections_to_edit_iter;
GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
@@ -857,10 +878,10 @@ static int collection_view_layer_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
struct CollectionEditData data = {
.scene = scene,
- .soops = soops,
+ .space_outliner = space_outliner,
};
bool clear = strstr(op->idname, "clear") != NULL;
int flag = strstr(op->idname, "holdout") ?
@@ -870,8 +891,12 @@ static int collection_view_layer_exec(bContext *C, wmOperator *op)
data.collections_to_edit = BLI_gset_ptr_new(__func__);
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, layer_collection_find_data_to_edit, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ layer_collection_find_data_to_edit,
+ &data);
GSetIterator collections_to_edit_iter;
GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
@@ -991,15 +1016,19 @@ static int collection_isolate_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
const bool extend = RNA_boolean_get(op->ptr, "extend");
struct CollectionEditData data = {
.scene = scene,
- .soops = soops,
+ .space_outliner = space_outliner,
};
data.collections_to_edit = BLI_gset_ptr_new(__func__);
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, layer_collection_find_data_to_edit, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ layer_collection_find_data_to_edit,
+ &data);
GSetIterator collections_to_edit_iter;
GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
@@ -1083,17 +1112,21 @@ static int collection_visibility_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
const bool is_inside = strstr(op->idname, "inside") != NULL;
const bool show = strstr(op->idname, "show") != NULL;
struct CollectionEditData data = {
.scene = scene,
- .soops = soops,
+ .space_outliner = space_outliner,
};
data.collections_to_edit = BLI_gset_ptr_new(__func__);
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, layer_collection_find_data_to_edit, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ layer_collection_find_data_to_edit,
+ &data);
GSetIterator collections_to_edit_iter;
GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
@@ -1225,20 +1258,24 @@ static int collection_flag_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
const bool is_render = strstr(op->idname, "render");
const bool clear = strstr(op->idname, "show") || strstr(op->idname, "enable");
int flag = is_render ? COLLECTION_RESTRICT_RENDER : COLLECTION_RESTRICT_VIEWPORT;
struct CollectionEditData data = {
.scene = scene,
- .soops = soops,
+ .space_outliner = space_outliner,
};
data.collections_to_edit = BLI_gset_ptr_new(__func__);
- const bool has_layer_collection = soops->outlinevis == SO_VIEW_LAYER;
+ const bool has_layer_collection = space_outliner->outlinevis == SO_VIEW_LAYER;
if (has_layer_collection) {
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, layer_collection_find_data_to_edit, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ layer_collection_find_data_to_edit,
+ &data);
GSetIterator collections_to_edit_iter;
GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
LayerCollection *layer_collection = BLI_gsetIterator_getKey(&collections_to_edit_iter);
@@ -1261,8 +1298,12 @@ static int collection_flag_exec(bContext *C, wmOperator *op)
BLI_gset_free(data.collections_to_edit, NULL);
}
else {
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, collection_find_data_to_edit, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ collection_find_data_to_edit,
+ &data);
GSetIterator collections_to_edit_iter;
GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter);
@@ -1351,7 +1392,7 @@ void OUTLINER_OT_collection_disable_render(wmOperatorType *ot)
struct OutlinerHideEditData {
Scene *scene;
ViewLayer *view_layer;
- SpaceOutliner *soops;
+ SpaceOutliner *space_outliner;
GSet *collections_to_edit;
GSet *bases_to_edit;
};
@@ -1397,17 +1438,21 @@ static int outliner_hide_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
struct OutlinerHideEditData data = {
.scene = scene,
.view_layer = view_layer,
- .soops = soops,
+ .space_outliner = space_outliner,
};
data.collections_to_edit = BLI_gset_ptr_new("outliner_hide_exec__collections_to_edit");
data.bases_to_edit = BLI_gset_ptr_new("outliner_hide_exec__bases_to_edit");
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, outliner_hide_find_data_to_edit, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ outliner_hide_find_data_to_edit,
+ &data);
GSetIterator collections_to_edit_iter;
GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index 5baaef958fa..94052223e39 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -90,13 +90,13 @@ static TreeElement *outliner_dropzone_element(TreeElement *te,
}
/* Find tree element to drop into. */
-static TreeElement *outliner_dropzone_find(const SpaceOutliner *soops,
+static TreeElement *outliner_dropzone_find(const SpaceOutliner *space_outliner,
const float fmval[2],
const bool children)
{
TreeElement *te;
- for (te = soops->tree.first; te; te = te->next) {
+ for (te = space_outliner->tree.first; te; te = te->next) {
TreeElement *te_valid = outliner_dropzone_element(te, fmval, children);
if (te_valid) {
return te_valid;
@@ -108,11 +108,11 @@ static TreeElement *outliner_dropzone_find(const SpaceOutliner *soops,
static TreeElement *outliner_drop_find(bContext *C, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
float fmval[2];
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
- return outliner_dropzone_find(soops, fmval, true);
+ return outliner_dropzone_find(space_outliner, fmval, true);
}
static ID *outliner_ID_drop_find(bContext *C, const wmEvent *event, short idcode)
@@ -131,14 +131,14 @@ static TreeElement *outliner_drop_insert_find(bContext *C,
const wmEvent *event,
TreeElementInsertType *r_insert_type)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
TreeElement *te_hovered;
float view_mval[2];
UI_view2d_region_to_view(
&region->v2d, event->mval[0], event->mval[1], &view_mval[0], &view_mval[1]);
- te_hovered = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]);
+ te_hovered = outliner_find_item_at_y(space_outliner, &space_outliner->tree, view_mval[1]);
if (te_hovered) {
/* Mouse hovers an element (ignoring x-axis),
@@ -146,7 +146,7 @@ static TreeElement *outliner_drop_insert_find(bContext *C,
const float margin = UI_UNIT_Y * (1.0f / 4);
if (view_mval[1] < (te_hovered->ys + margin)) {
- if (TSELEM_OPEN(TREESTORE(te_hovered), soops)) {
+ if (TSELEM_OPEN(TREESTORE(te_hovered), space_outliner)) {
/* inserting after a open item means we insert into it, but as first child */
if (BLI_listbase_is_empty(&te_hovered->subtree)) {
*r_insert_type = TE_INSERT_INTO;
@@ -168,8 +168,8 @@ static TreeElement *outliner_drop_insert_find(bContext *C,
/* Mouse doesn't hover any item (ignoring x-axis),
* so it's either above list bounds or below. */
- TreeElement *first = soops->tree.first;
- TreeElement *last = soops->tree.last;
+ TreeElement *first = space_outliner->tree.first;
+ TreeElement *last = space_outliner->tree.last;
if (view_mval[1] < last->ys) {
*r_insert_type = TE_INSERT_AFTER;
@@ -262,11 +262,11 @@ static bool parent_drop_allowed(TreeElement *te, Object *potential_child)
return true;
}
-static bool allow_parenting_without_modifier_key(SpaceOutliner *soops)
+static bool allow_parenting_without_modifier_key(SpaceOutliner *space_outliner)
{
- switch (soops->outlinevis) {
+ switch (space_outliner->outlinevis) {
case SO_VIEW_LAYER:
- return soops->filter & SO_FILTER_NO_COLLECTION;
+ return space_outliner->filter & SO_FILTER_NO_COLLECTION;
case SO_SCENES:
return true;
default:
@@ -279,9 +279,9 @@ static bool parent_drop_poll(bContext *C,
const wmEvent *event,
const char **UNUSED(r_tooltip))
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
- bool changed = outliner_flag_set(&soops->tree, TSE_DRAG_ANY, false);
+ bool changed = outliner_flag_set(&space_outliner->tree, TSE_DRAG_ANY, false);
if (changed) {
ED_region_tag_redraw_no_rebuild(CTX_wm_region(C));
}
@@ -291,7 +291,7 @@ static bool parent_drop_poll(bContext *C,
return false;
}
- if (!allow_parenting_without_modifier_key(soops)) {
+ if (!allow_parenting_without_modifier_key(space_outliner)) {
if (!event->shift) {
return false;
}
@@ -319,9 +319,9 @@ static void parent_drop_set_parents(bContext *C,
const bool keep_transform)
{
Main *bmain = CTX_data_main(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
- TreeElement *te = outliner_find_id(soops, &soops->tree, &parent->id);
+ TreeElement *te = outliner_find_id(space_outliner, &space_outliner->tree, &parent->id);
Scene *scene = (Scene *)outliner_search_back(te, ID_SCE);
if (scene == NULL) {
@@ -418,9 +418,9 @@ static bool parent_clear_poll(bContext *C,
const wmEvent *event,
const char **UNUSED(r_tooltip))
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
- if (!allow_parenting_without_modifier_key(soops)) {
+ if (!allow_parenting_without_modifier_key(space_outliner)) {
if (!event->shift) {
return false;
}
@@ -649,7 +649,7 @@ static bool collection_drop_init(bContext *C,
const wmEvent *event,
CollectionDrop *data)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
/* Get collection to drop into. */
TreeElementInsertType insert_type;
@@ -685,7 +685,7 @@ static bool collection_drop_init(bContext *C,
/* Get collection to drag out of. */
ID *parent = drag_id->from_parent;
Collection *from_collection = collection_parent_from_ID(parent);
- if (event->ctrl || soops->outlinevis == SO_SCENES) {
+ if (event->ctrl || space_outliner->outlinevis == SO_SCENES) {
from_collection = NULL;
}
@@ -712,9 +712,9 @@ static bool collection_drop_poll(bContext *C,
const wmEvent *event,
const char **r_tooltip)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
- bool changed = outliner_flag_set(&soops->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false);
+ bool changed = outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false);
CollectionDrop data;
if (!event->shift && collection_drop_init(C, drag, event, &data)) {
@@ -787,12 +787,12 @@ static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
bool relative_after = false;
if (ELEM(data.insert_type, TE_INSERT_BEFORE, TE_INSERT_AFTER)) {
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
relative = data.to;
relative_after = (data.insert_type == TE_INSERT_AFTER);
- TreeElement *parent_te = outliner_find_parent_element(&soops->tree, NULL, data.te);
+ TreeElement *parent_te = outliner_find_parent_element(&space_outliner->tree, NULL, data.te);
data.to = (parent_te) ? outliner_collection_from_tree_element(parent_te) : NULL;
}
@@ -860,14 +860,14 @@ void OUTLINER_OT_collection_drop(wmOperatorType *ot)
#define OUTLINER_DRAG_SCOLL_OUTSIDE_PAD 7 /* In UI units */
-static TreeElement *outliner_item_drag_element_find(SpaceOutliner *soops,
+static TreeElement *outliner_item_drag_element_find(SpaceOutliner *space_outliner,
ARegion *region,
const wmEvent *event)
{
/* note: using EVT_TWEAK_ events to trigger dragging is fine,
* it sends coordinates from where dragging was started */
const float my = UI_view2d_region_to_view_y(&region->v2d, event->mval[1]);
- return outliner_find_item_at_y(soops, &soops->tree, my);
+ return outliner_find_item_at_y(space_outliner, &space_outliner->tree, my);
}
static int outliner_item_drag_drop_invoke(bContext *C,
@@ -875,8 +875,8 @@ static int outliner_item_drag_drop_invoke(bContext *C,
const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
- TreeElement *te = outliner_item_drag_element_find(soops, region, event);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+ TreeElement *te = outliner_item_drag_element_find(space_outliner, region, event);
if (!te) {
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
@@ -912,7 +912,7 @@ static int outliner_item_drag_drop_invoke(bContext *C,
/* Only drag element under mouse if it was not selected before. */
if ((TREESTORE(te)->flag & TSE_SELECTED) == 0) {
- outliner_flag_set(&soops->tree, TSE_SELECTED, 0);
+ outliner_flag_set(&space_outliner->tree, TSE_SELECTED, 0);
TREESTORE(te)->flag |= TSE_SELECTED;
}
@@ -922,12 +922,20 @@ static int outliner_item_drag_drop_invoke(bContext *C,
};
if (GS(data.drag_id->name) == ID_OB) {
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, outliner_find_selected_objects, &selected);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ outliner_find_selected_objects,
+ &selected);
}
else {
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, outliner_find_selected_collections, &selected);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ outliner_find_selected_collections,
+ &selected);
}
LISTBASE_FOREACH (LinkData *, link, &selected.selected_array) {
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index a45b415b629..28e233b6dd2 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -86,7 +86,7 @@
/* ****************************************************** */
/* Tree Size Functions */
-static void outliner_tree_dimensions_impl(SpaceOutliner *soops,
+static void outliner_tree_dimensions_impl(SpaceOutliner *space_outliner,
ListBase *lb,
int *width,
int *height)
@@ -98,20 +98,20 @@ static void outliner_tree_dimensions_impl(SpaceOutliner *soops,
}
TreeStoreElem *tselem = TREESTORE(te);
- if (TSELEM_OPEN(tselem, soops)) {
- outliner_tree_dimensions_impl(soops, &te->subtree, width, height);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ outliner_tree_dimensions_impl(space_outliner, &te->subtree, width, height);
}
else {
- outliner_tree_dimensions_impl(soops, &te->subtree, width, NULL);
+ outliner_tree_dimensions_impl(space_outliner, &te->subtree, width, NULL);
}
}
}
-static void outliner_tree_dimensions(SpaceOutliner *soops, int *r_width, int *r_height)
+static void outliner_tree_dimensions(SpaceOutliner *space_outliner, int *r_width, int *r_height)
{
*r_width = 0;
*r_height = 0;
- outliner_tree_dimensions_impl(soops, &soops->tree, r_width, r_height);
+ outliner_tree_dimensions_impl(space_outliner, &space_outliner->tree, r_width, r_height);
}
/**
@@ -667,13 +667,13 @@ static void scenes__collection_set_flag_recursive_fn(bContext *C, void *poin, vo
static void namebutton_fn(bContext *C, void *tsep, char *oldname)
{
Main *bmain = CTX_data_main(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
Object *obedit = CTX_data_edit_object(C);
- BLI_mempool *ts = soops->treestore;
+ BLI_mempool *ts = space_outliner->treestore;
TreeStoreElem *tselem = tsep;
if (ts && tselem) {
- TreeElement *te = outliner_find_tree_element(&soops->tree, tselem);
+ TreeElement *te = outliner_find_tree_element(&space_outliner->tree, tselem);
if (tselem->type == 0) {
BLI_libblock_ensure_unique_name(bmain, tselem->id->name);
@@ -760,7 +760,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname)
char newname[sizeof(bone->name)];
/* always make current object active */
- tree_element_active(C, &tvc, soops, te, OL_SETSEL_NORMAL, true);
+ tree_element_active(C, &tvc, space_outliner, te, OL_SETSEL_NORMAL, true);
/* restore bone name */
BLI_strncpy(newname, bone->name, sizeof(bone->name));
@@ -778,7 +778,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname)
char newname[sizeof(pchan->name)];
/* always make current pose-bone active */
- tree_element_active(C, &tvc, soops, te, OL_SETSEL_NORMAL, true);
+ tree_element_active(C, &tvc, space_outliner, te, OL_SETSEL_NORMAL, true);
BLI_assert(ob->type == OB_ARMATURE);
@@ -980,7 +980,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
Scene *scene,
ViewLayer *view_layer,
ARegion *region,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
ListBase *lb,
RestrictPropertiesActive props_active_parent)
{
@@ -1022,28 +1022,28 @@ static void outliner_draw_restrictbuts(uiBlock *block,
int restrict_column_offset = 0;
/* This will determine the order of drawing from RIGHT to LEFT. */
- if (soops->outlinevis == SO_VIEW_LAYER) {
- if (soops->show_restrict_flags & SO_RESTRICT_INDIRECT_ONLY) {
+ if (space_outliner->outlinevis == SO_VIEW_LAYER) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_INDIRECT_ONLY) {
restrict_offsets.indirect_only = (++restrict_column_offset) * UI_UNIT_X + V2D_SCROLL_WIDTH;
}
- if (soops->show_restrict_flags & SO_RESTRICT_HOLDOUT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_HOLDOUT) {
restrict_offsets.holdout = (++restrict_column_offset) * UI_UNIT_X + V2D_SCROLL_WIDTH;
}
}
- if (soops->show_restrict_flags & SO_RESTRICT_RENDER) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_RENDER) {
restrict_offsets.render = (++restrict_column_offset) * UI_UNIT_X + V2D_SCROLL_WIDTH;
}
- if (soops->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
restrict_offsets.viewport = (++restrict_column_offset) * UI_UNIT_X + V2D_SCROLL_WIDTH;
}
- if (soops->show_restrict_flags & SO_RESTRICT_HIDE) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_HIDE) {
restrict_offsets.hide = (++restrict_column_offset) * UI_UNIT_X + V2D_SCROLL_WIDTH;
}
- if (soops->show_restrict_flags & SO_RESTRICT_SELECT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_SELECT) {
restrict_offsets.select = (++restrict_column_offset) * UI_UNIT_X + V2D_SCROLL_WIDTH;
}
BLI_assert((restrict_column_offset * UI_UNIT_X + V2D_SCROLL_WIDTH) ==
- outliner_restrict_columns_width(soops));
+ outliner_restrict_columns_width(space_outliner));
/* Create buttons. */
uiBut *bt;
@@ -1053,8 +1053,8 @@ static void outliner_draw_restrictbuts(uiBlock *block,
RestrictPropertiesActive props_active = props_active_parent;
if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) {
- if (tselem->type == TSE_R_LAYER && (soops->outlinevis == SO_SCENES)) {
- if (soops->show_restrict_flags & SO_RESTRICT_RENDER) {
+ if (tselem->type == TSE_R_LAYER && (space_outliner->outlinevis == SO_SCENES)) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_RENDER) {
/* View layer render toggle. */
ViewLayer *layer = te->directdata;
@@ -1087,7 +1087,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
Object *ob = (Object *)tselem->id;
RNA_id_pointer_create(&ob->id, &ptr);
- if (soops->show_restrict_flags & SO_RESTRICT_HIDE) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_HIDE) {
Base *base = (te->directdata) ? (Base *)te->directdata :
BKE_view_layer_base_find(view_layer, ob);
if (base) {
@@ -1119,7 +1119,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
}
}
- if (soops->show_restrict_flags & SO_RESTRICT_SELECT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_SELECT) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1144,7 +1144,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
}
}
- if (soops->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1169,7 +1169,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
}
}
- if (soops->show_restrict_flags & SO_RESTRICT_RENDER) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_RENDER) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1200,7 +1200,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
PointerRNA ptr;
RNA_pointer_create(tselem->id, &RNA_Constraint, con, &ptr);
- if (soops->show_restrict_flags & SO_RESTRICT_HIDE) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_HIDE) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1229,7 +1229,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
PointerRNA ptr;
RNA_pointer_create(tselem->id, &RNA_Modifier, md, &ptr);
- if (soops->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1252,7 +1252,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
}
}
- if (soops->show_restrict_flags & SO_RESTRICT_RENDER) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_RENDER) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1284,7 +1284,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
RNA_pointer_create(&arm->id, &RNA_Bone, bone, &ptr);
- if (soops->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1306,7 +1306,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE);
}
- if (soops->show_restrict_flags & SO_RESTRICT_SELECT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_SELECT) {
bt = uiDefIconButBitI(block,
UI_BTYPE_ICON_TOGGLE,
BONE_UNSELECTABLE,
@@ -1330,7 +1330,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
else if (tselem->type == TSE_EBONE) {
EditBone *ebone = (EditBone *)te->directdata;
- if (soops->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
bt = uiDefIconButBitI(block,
UI_BTYPE_ICON_TOGGLE,
BONE_HIDDEN_A,
@@ -1351,7 +1351,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE);
}
- if (soops->show_restrict_flags & SO_RESTRICT_SELECT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_SELECT) {
bt = uiDefIconButBitI(block,
UI_BTYPE_ICON_TOGGLE,
BONE_UNSELECTABLE,
@@ -1376,7 +1376,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
ID *id = tselem->id;
bGPDlayer *gpl = (bGPDlayer *)te->directdata;
- if (soops->show_restrict_flags & SO_RESTRICT_HIDE) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_HIDE) {
bt = uiDefIconButBitS(block,
UI_BTYPE_ICON_TOGGLE,
GP_LAYER_HIDE,
@@ -1397,7 +1397,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE);
}
- if (soops->show_restrict_flags & SO_RESTRICT_SELECT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_SELECT) {
bt = uiDefIconButBitS(block,
UI_BTYPE_ICON_TOGGLE,
GP_LAYER_LOCKED,
@@ -1430,7 +1430,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
Collection *collection = outliner_collection_from_tree_element(te);
if (layer_collection != NULL) {
- if (soops->show_restrict_flags & SO_RESTRICT_HIDE) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_HIDE) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1459,7 +1459,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
}
}
- if (soops->show_restrict_flags & SO_RESTRICT_HOLDOUT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_HOLDOUT) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1488,7 +1488,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
}
}
- if (soops->show_restrict_flags & SO_RESTRICT_INDIRECT_ONLY) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_INDIRECT_ONLY) {
bt = uiDefIconButR_prop(
block,
UI_BTYPE_ICON_TOGGLE,
@@ -1521,7 +1521,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
}
}
- if (soops->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1558,7 +1558,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
}
}
- if (soops->show_restrict_flags & SO_RESTRICT_RENDER) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_RENDER) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1593,7 +1593,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
}
}
- if (soops->show_restrict_flags & SO_RESTRICT_SELECT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_SELECT) {
bt = uiDefIconButR_prop(block,
UI_BTYPE_ICON_TOGGLE,
0,
@@ -1637,16 +1637,16 @@ static void outliner_draw_restrictbuts(uiBlock *block,
scene, te, &collection_ptr, &layer_collection_ptr, &props, &props_active);
}
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
outliner_draw_restrictbuts(
- block, scene, view_layer, region, soops, &te->subtree, props_active);
+ block, scene, view_layer, region, space_outliner, &te->subtree, props_active);
}
}
}
static void outliner_draw_userbuts(uiBlock *block,
ARegion *region,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
ListBase *lb)
{
@@ -1707,8 +1707,8 @@ static void outliner_draw_userbuts(uiBlock *block,
}
}
- if (TSELEM_OPEN(tselem, soops)) {
- outliner_draw_userbuts(block, region, soops, &te->subtree);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ outliner_draw_userbuts(block, region, space_outliner, &te->subtree);
}
}
}
@@ -1742,7 +1742,7 @@ static void outliner_draw_rnacols(ARegion *region, int sizex)
}
static void outliner_draw_rnabuts(
- uiBlock *block, ARegion *region, SpaceOutliner *soops, int sizex, ListBase *lb)
+ uiBlock *block, ARegion *region, SpaceOutliner *space_outliner, int sizex, ListBase *lb)
{
PointerRNA *ptr;
PropertyRNA *prop;
@@ -1754,7 +1754,7 @@ static void outliner_draw_rnabuts(
ptr = &te->rnaptr;
prop = te->directdata;
- if (!TSELEM_OPEN(tselem, soops)) {
+ if (!TSELEM_OPEN(tselem, space_outliner)) {
if (RNA_property_type(prop) == PROP_POINTER) {
uiBut *but = uiDefAutoButR(block,
ptr,
@@ -1811,8 +1811,8 @@ static void outliner_draw_rnabuts(
}
}
- if (TSELEM_OPEN(tselem, soops)) {
- outliner_draw_rnabuts(block, region, soops, sizex, &te->subtree);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ outliner_draw_rnabuts(block, region, space_outliner, sizex, &te->subtree);
}
}
}
@@ -1823,7 +1823,7 @@ static void outliner_buttons(const bContext *C,
const float restrict_column_width,
TreeElement *te)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
uiBut *bt;
TreeStoreElem *tselem;
int spx, dx, len;
@@ -1850,7 +1850,7 @@ static void outliner_buttons(const bContext *C,
spx = te->xs + 1.8f * UI_UNIT_X;
if ((tselem->type == TSE_LAYER_COLLECTION) &&
- (soops->show_restrict_flags & SO_RESTRICT_ENABLE)) {
+ (space_outliner->show_restrict_flags & SO_RESTRICT_ENABLE)) {
spx += UI_UNIT_X;
}
dx = region->v2d.cur.xmax - (spx + restrict_column_width + 0.2f * UI_UNIT_X);
@@ -2694,7 +2694,7 @@ static void outliner_draw_iconrow_number(const uiFontStyle *fstyle,
int ys,
const int num_elements)
{
- float color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+ const float color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
float ufac = 0.25f * UI_UNIT_X;
float offset_x = (float)offsx + UI_UNIT_X * 0.35f;
@@ -2833,7 +2833,7 @@ static void outliner_draw_iconrow(bContext *C,
uiBlock *block,
const uiFontStyle *fstyle,
const TreeViewContext *tvc,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
ListBase *lb,
int level,
int xmax,
@@ -2858,7 +2858,7 @@ static void outliner_draw_iconrow(bContext *C,
active = OL_DRAWSEL_ACTIVE;
}
else {
- active = tree_element_active(C, tvc, soops, te, OL_SETSEL_NONE, false);
+ active = tree_element_active(C, tvc, space_outliner, te, OL_SETSEL_NONE, false);
}
}
else if (tselem->type == TSE_GP_LAYER) {
@@ -2866,7 +2866,8 @@ static void outliner_draw_iconrow(bContext *C,
active = (gpl->flag & GP_LAYER_ACTIVE) ? OL_DRAWSEL_ACTIVE : OL_DRAWSEL_NONE;
}
else {
- active = tree_element_type_active(C, tvc, soops, te, tselem, OL_SETSEL_NONE, false);
+ active = tree_element_type_active(
+ C, tvc, space_outliner, te, tselem, OL_SETSEL_NONE, false);
}
if (!ELEM(tselem->type, 0, TSE_LAYER_COLLECTION, TSE_R_LAYER, TSE_GP_LAYER)) {
@@ -2888,7 +2889,7 @@ static void outliner_draw_iconrow(bContext *C,
block,
fstyle,
tvc,
- soops,
+ space_outliner,
&te->subtree,
level + 1,
xmax,
@@ -2947,7 +2948,7 @@ static void outliner_draw_tree_element(bContext *C,
const uiFontStyle *fstyle,
const TreeViewContext *tvc,
ARegion *region,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
TreeElement *te,
bool draw_grayed_out,
int startx,
@@ -3021,7 +3022,7 @@ static void outliner_draw_tree_element(bContext *C,
active = OL_DRAWSEL_ACTIVE;
}
else {
- if (tree_element_active(C, tvc, soops, te, OL_SETSEL_NONE, false)) {
+ if (tree_element_active(C, tvc, space_outliner, te, OL_SETSEL_NONE, false)) {
/* active items like camera or material */
icon_bgcolor[3] = 0.2f;
active = OL_DRAWSEL_ACTIVE;
@@ -3036,14 +3037,14 @@ static void outliner_draw_tree_element(bContext *C,
}
}
else {
- active = tree_element_type_active(C, tvc, soops, te, tselem, OL_SETSEL_NONE, false);
+ active = tree_element_type_active(C, tvc, space_outliner, te, tselem, OL_SETSEL_NONE, false);
/* active collection*/
icon_bgcolor[3] = 0.2f;
}
/* Checkbox to enable collections. */
if ((tselem->type == TSE_LAYER_COLLECTION) &&
- (soops->show_restrict_flags & SO_RESTRICT_ENABLE)) {
+ (space_outliner->show_restrict_flags & SO_RESTRICT_ENABLE)) {
tselem_draw_layer_collection_enable_icon(
tvc->scene, block, xmax, (float)startx + offsx + UI_UNIT_X, (float)*starty, te, 0.8f);
offsx += UI_UNIT_X;
@@ -3081,7 +3082,7 @@ static void outliner_draw_tree_element(bContext *C,
int icon_x = startx;
/* Icons a bit higher. */
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
UI_icon_draw_alpha((float)icon_x + 2 * ufac,
(float)*starty + 1 * ufac,
ICON_DISCLOSURE_TRI_DOWN,
@@ -3130,7 +3131,7 @@ static void outliner_draw_tree_element(bContext *C,
offsx += (int)(UI_UNIT_X + UI_fontstyle_string_width(fstyle, te->name));
/* closed item, we draw the icons, not when it's a scene, or master-server list though */
- if (!TSELEM_OPEN(tselem, soops)) {
+ if (!TSELEM_OPEN(tselem, space_outliner)) {
if (te->subtree.first) {
if (tselem->type == 0 && te->idcode == ID_SCE) {
/* pass */
@@ -3146,7 +3147,7 @@ static void outliner_draw_tree_element(bContext *C,
block,
fstyle,
tvc,
- soops,
+ space_outliner,
&te->subtree,
0,
xmax,
@@ -3165,7 +3166,7 @@ static void outliner_draw_tree_element(bContext *C,
te->ys = *starty;
te->xend = startx + offsx;
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
*starty -= UI_UNIT_Y;
LISTBASE_FOREACH (TreeElement *, ten, &te->subtree) {
@@ -3177,7 +3178,7 @@ static void outliner_draw_tree_element(bContext *C,
fstyle,
tvc,
region,
- soops,
+ space_outliner,
ten,
draw_children_grayed_out,
startx + UI_UNIT_X,
@@ -3196,7 +3197,7 @@ static void outliner_draw_tree_element(bContext *C,
}
static void outliner_draw_hierarchy_lines_recursive(uint pos,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
ListBase *lb,
int startx,
const uchar col[4],
@@ -3264,9 +3265,14 @@ static void outliner_draw_hierarchy_lines_recursive(uint pos,
*starty -= UI_UNIT_Y;
- if (TSELEM_OPEN(tselem, soops)) {
- outliner_draw_hierarchy_lines_recursive(
- pos, soops, &te->subtree, startx + UI_UNIT_X, col, draw_children_grayed_out, starty);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ outliner_draw_hierarchy_lines_recursive(pos,
+ space_outliner,
+ &te->subtree,
+ startx + UI_UNIT_X,
+ col,
+ draw_children_grayed_out,
+ starty);
}
}
@@ -3296,7 +3302,7 @@ static void outliner_draw_hierarchy_lines_recursive(uint pos,
}
}
-static void outliner_draw_hierarchy_lines(SpaceOutliner *soops,
+static void outliner_draw_hierarchy_lines(SpaceOutliner *space_outliner,
ListBase *lb,
int startx,
int *starty)
@@ -3310,14 +3316,14 @@ static void outliner_draw_hierarchy_lines(SpaceOutliner *soops,
col[3] = 255;
GPU_blend(true);
- outliner_draw_hierarchy_lines_recursive(pos, soops, lb, startx, col, false, starty);
+ outliner_draw_hierarchy_lines_recursive(pos, space_outliner, lb, startx, col, false, starty);
GPU_blend(false);
immUnbindProgram();
}
static void outliner_draw_struct_marks(ARegion *region,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
ListBase *lb,
int *starty)
{
@@ -3325,7 +3331,7 @@ static void outliner_draw_struct_marks(ARegion *region,
TreeStoreElem *tselem = TREESTORE(te);
/* selection status */
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
if (tselem->type == TSE_RNA_STRUCT) {
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
@@ -3337,8 +3343,8 @@ static void outliner_draw_struct_marks(ARegion *region,
}
*starty -= UI_UNIT_Y;
- if (TSELEM_OPEN(tselem, soops)) {
- outliner_draw_struct_marks(region, soops, &te->subtree, starty);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ outliner_draw_struct_marks(region, space_outliner, &te->subtree, starty);
if (tselem->type == TSE_RNA_STRUCT) {
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -3358,7 +3364,7 @@ static void outliner_draw_struct_marks(ARegion *region,
static void outliner_draw_highlights_recursive(uint pos,
const ARegion *region,
- const SpaceOutliner *soops,
+ const SpaceOutliner *space_outliner,
const ListBase *lb,
const float col_selection[4],
const float col_active[4],
@@ -3367,8 +3373,9 @@ static void outliner_draw_highlights_recursive(uint pos,
int start_x,
int *io_start_y)
{
- const bool is_searching = (SEARCHING_OUTLINER(soops) ||
- (soops->outlinevis == SO_DATA_API && soops->search_string[0] != 0));
+ const bool is_searching = (SEARCHING_OUTLINER(space_outliner) ||
+ (space_outliner->outlinevis == SO_DATA_API &&
+ space_outliner->search_string[0] != 0));
LISTBASE_FOREACH (TreeElement *, te, lb) {
const TreeStoreElem *tselem = TREESTORE(te);
@@ -3427,10 +3434,10 @@ static void outliner_draw_highlights_recursive(uint pos,
}
*io_start_y -= UI_UNIT_Y;
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
outliner_draw_highlights_recursive(pos,
region,
- soops,
+ space_outliner,
&te->subtree,
col_selection,
col_active,
@@ -3443,7 +3450,7 @@ static void outliner_draw_highlights_recursive(uint pos,
}
static void outliner_draw_highlights(ARegion *region,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
int startx,
int *starty)
{
@@ -3463,8 +3470,8 @@ static void outliner_draw_highlights(ARegion *region,
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
outliner_draw_highlights_recursive(pos,
region,
- soops,
- &soops->tree,
+ space_outliner,
+ &space_outliner->tree,
col_selection,
col_active,
col_highlight,
@@ -3479,7 +3486,7 @@ static void outliner_draw_tree(bContext *C,
uiBlock *block,
const TreeViewContext *tvc,
ARegion *region,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
const float restrict_column_width,
TreeElement **te_edit)
{
@@ -3489,16 +3496,16 @@ static void outliner_draw_tree(bContext *C,
GPU_blend_set_func_separate(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* Only once. */
- if (soops->outlinevis == SO_DATA_API) {
+ if (space_outliner->outlinevis == SO_DATA_API) {
/* struct marks */
starty = (int)region->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET;
- outliner_draw_struct_marks(region, soops, &soops->tree, &starty);
+ outliner_draw_struct_marks(region, space_outliner, &space_outliner->tree, &starty);
}
/* draw highlights before hierarchy */
starty = (int)region->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET;
startx = 0;
- outliner_draw_highlights(region, soops, startx, &starty);
+ outliner_draw_highlights(region, space_outliner, startx, &starty);
/* set scissor so tree elements or lines can't overlap restriction icons */
float scissor[4] = {0};
@@ -3513,18 +3520,18 @@ static void outliner_draw_tree(bContext *C,
/* Gray hierarchy lines. */
starty = (int)region->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET;
startx = UI_UNIT_X / 2 - (U.pixelsize + 1) / 2;
- outliner_draw_hierarchy_lines(soops, &soops->tree, startx, &starty);
+ outliner_draw_hierarchy_lines(space_outliner, &space_outliner->tree, startx, &starty);
/* Items themselves. */
starty = (int)region->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET;
startx = 0;
- LISTBASE_FOREACH (TreeElement *, te, &soops->tree) {
+ LISTBASE_FOREACH (TreeElement *, te, &space_outliner->tree) {
outliner_draw_tree_element(C,
block,
fstyle,
tvc,
region,
- soops,
+ space_outliner,
te,
(te->flag & TE_DRAGGING) != 0,
startx,
@@ -3582,21 +3589,23 @@ static int outliner_data_api_buttons_start_x(int max_tree_width)
return max_ii(OL_RNA_COLX, max_tree_width + OL_RNA_COL_SPACEX);
}
-static int outliner_width(SpaceOutliner *soops, int max_tree_width, float restrict_column_width)
+static int outliner_width(SpaceOutliner *space_outliner,
+ int max_tree_width,
+ float restrict_column_width)
{
- if (soops->outlinevis == SO_DATA_API) {
+ if (space_outliner->outlinevis == SO_DATA_API) {
return outliner_data_api_buttons_start_x(max_tree_width) + OL_RNA_COL_SIZEX + 10 * UI_DPI_FAC;
}
return max_tree_width + restrict_column_width;
}
static void outliner_update_viewable_area(ARegion *region,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
int tree_width,
int tree_height,
float restrict_column_width)
{
- int sizex = outliner_width(soops, tree_width, restrict_column_width);
+ int sizex = outliner_width(space_outliner, tree_width, restrict_column_width);
int sizey = tree_height;
/* extend size to allow for horizontal scrollbar and extra offset */
@@ -3613,14 +3622,14 @@ void draw_outliner(const bContext *C)
Main *mainvar = CTX_data_main(C);
ARegion *region = CTX_wm_region(C);
View2D *v2d = &region->v2d;
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
uiBlock *block;
TreeElement *te_edit = NULL;
TreeViewContext tvc;
outliner_viewcontext_init(C, &tvc);
- outliner_build_tree(mainvar, tvc.scene, tvc.view_layer, soops, region); /* Always. */
+ outliner_build_tree(mainvar, tvc.scene, tvc.view_layer, space_outliner, region); /* Always. */
/* If global sync select is dirty, flag other outliners */
if (ED_outliner_select_sync_is_dirty(C)) {
@@ -3628,9 +3637,9 @@ void draw_outliner(const bContext *C)
}
/* Sync selection state from view layer */
- if (!ELEM(soops->outlinevis, SO_LIBRARIES, SO_DATA_API, SO_ID_ORPHANS) &&
- soops->flag & SO_SYNC_SELECT) {
- outliner_sync_selection(C, soops);
+ if (!ELEM(space_outliner->outlinevis, SO_LIBRARIES, SO_DATA_API, SO_ID_ORPHANS) &&
+ space_outliner->flag & SO_SYNC_SELECT) {
+ outliner_sync_selection(C, space_outliner);
}
/* force display to pixel coords */
@@ -3639,37 +3648,43 @@ void draw_outliner(const bContext *C)
UI_view2d_view_ortho(v2d);
/* draw outliner stuff (background, hierarchy lines and names) */
- const float restrict_column_width = outliner_restrict_columns_width(soops);
+ const float restrict_column_width = outliner_restrict_columns_width(space_outliner);
outliner_back(region);
block = UI_block_begin(C, region, __func__, UI_EMBOSS);
- outliner_draw_tree((bContext *)C, block, &tvc, region, soops, restrict_column_width, &te_edit);
+ outliner_draw_tree(
+ (bContext *)C, block, &tvc, region, space_outliner, restrict_column_width, &te_edit);
/* Compute outliner dimensions after it has been drawn. */
int tree_width, tree_height;
- outliner_tree_dimensions(soops, &tree_width, &tree_height);
+ outliner_tree_dimensions(space_outliner, &tree_width, &tree_height);
/* Default to no emboss for outliner UI. */
UI_block_emboss_set(block, UI_EMBOSS_NONE);
- if (soops->outlinevis == SO_DATA_API) {
+ if (space_outliner->outlinevis == SO_DATA_API) {
int buttons_start_x = outliner_data_api_buttons_start_x(tree_width);
/* draw rna buttons */
outliner_draw_rnacols(region, buttons_start_x);
UI_block_emboss_set(block, UI_EMBOSS);
- outliner_draw_rnabuts(block, region, soops, buttons_start_x, &soops->tree);
+ outliner_draw_rnabuts(block, region, space_outliner, buttons_start_x, &space_outliner->tree);
UI_block_emboss_set(block, UI_EMBOSS_NONE);
}
- else if (soops->outlinevis == SO_ID_ORPHANS) {
+ else if (space_outliner->outlinevis == SO_ID_ORPHANS) {
/* draw user toggle columns */
- outliner_draw_userbuts(block, region, soops, &soops->tree);
+ outliner_draw_userbuts(block, region, space_outliner, &space_outliner->tree);
}
else if (restrict_column_width > 0.0f) {
/* draw restriction columns */
RestrictPropertiesActive props_active;
memset(&props_active, 1, sizeof(RestrictPropertiesActive));
- outliner_draw_restrictbuts(
- block, tvc.scene, tvc.view_layer, region, soops, &soops->tree, props_active);
+ outliner_draw_restrictbuts(block,
+ tvc.scene,
+ tvc.view_layer,
+ region,
+ space_outliner,
+ &space_outliner->tree,
+ props_active);
}
UI_block_emboss_set(block, UI_EMBOSS);
@@ -3683,5 +3698,6 @@ void draw_outliner(const bContext *C)
UI_block_draw(C, block);
/* Update total viewable region. */
- outliner_update_viewable_area(region, soops, tree_width, tree_height, restrict_column_width);
+ outliner_update_viewable_area(
+ region, space_outliner, tree_width, tree_height, restrict_column_width);
}
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 4fe3d5b0df7..cd2fcd8e2cf 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -103,21 +103,22 @@ static int outliner_highlight_update(bContext *C, wmOperator *UNUSED(op), const
}
ARegion *region = CTX_wm_region(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
float view_mval[2];
UI_view2d_region_to_view(
&region->v2d, event->mval[0], event->mval[1], &view_mval[0], &view_mval[1]);
- TreeElement *hovered_te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]);
+ TreeElement *hovered_te = outliner_find_item_at_y(
+ space_outliner, &space_outliner->tree, view_mval[1]);
if (hovered_te) {
- hovered_te = outliner_find_item_at_x_in_row(soops, hovered_te, view_mval[0], NULL);
+ hovered_te = outliner_find_item_at_x_in_row(space_outliner, hovered_te, view_mval[0], NULL);
}
bool changed = false;
if (!hovered_te || !(hovered_te->store_elem->flag & TSE_HIGHLIGHTED)) {
- changed = outliner_flag_set(&soops->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false);
+ changed = outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false);
if (hovered_te) {
hovered_te->store_elem->flag |= TSE_HIGHLIGHTED;
changed = true;
@@ -174,14 +175,14 @@ typedef struct OpenCloseData {
static int outliner_item_openclose_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
float view_mval[2];
UI_view2d_region_to_view(
&region->v2d, event->mval[0], event->mval[1], &view_mval[0], &view_mval[1]);
if (event->type == MOUSEMOVE) {
- TreeElement *te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]);
+ TreeElement *te = outliner_find_item_at_y(space_outliner, &space_outliner->tree, view_mval[1]);
OpenCloseData *data = (OpenCloseData *)op->customdata;
@@ -221,7 +222,7 @@ static int outliner_item_openclose_modal(bContext *C, wmOperator *op, const wmEv
static int outliner_item_openclose_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
const bool toggle_all = RNA_boolean_get(op->ptr, "all");
@@ -229,7 +230,7 @@ static int outliner_item_openclose_invoke(bContext *C, wmOperator *op, const wmE
UI_view2d_region_to_view(
&region->v2d, event->mval[0], event->mval[1], &view_mval[0], &view_mval[1]);
- TreeElement *te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]);
+ TreeElement *te = outliner_find_item_at_y(space_outliner, &space_outliner->tree, view_mval[1]);
if (te && outliner_item_is_co_within_close_toggle(te, view_mval[0])) {
TreeStoreElem *tselem = TREESTORE(te);
@@ -312,7 +313,7 @@ static void item_object_mode_enter_exit(bContext *C, ReportList *reports, Object
outliner_object_mode_toggle(C, scene, view_layer, base);
}
-void item_object_mode_enter_cb(bContext *C,
+void item_object_mode_enter_fn(bContext *C,
ReportList *reports,
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -324,7 +325,7 @@ void item_object_mode_enter_cb(bContext *C,
item_object_mode_enter_exit(C, reports, ob, true);
}
-void item_object_mode_exit_cb(bContext *C,
+void item_object_mode_exit_fn(bContext *C,
ReportList *reports,
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -404,7 +405,7 @@ static void do_item_rename(ARegion *region,
}
}
-void item_rename_cb(bContext *C,
+void item_rename_fn(bContext *C,
ReportList *reports,
Scene *UNUSED(scene),
TreeElement *te,
@@ -438,13 +439,14 @@ static void do_outliner_item_rename(ReportList *reports,
static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
TreeElement *te;
float fmval[2];
/* Rename active element if key pressed, otherwise rename element at cursor coordinates */
if (event->val == KM_PRESS) {
- TreeElement *active_element = outliner_find_element_with_flag(&soops->tree, TSE_ACTIVE);
+ TreeElement *active_element = outliner_find_element_with_flag(&space_outliner->tree,
+ TSE_ACTIVE);
if (active_element) {
do_item_rename(region, active_element, TREESTORE(active_element), op->reports);
@@ -456,7 +458,7 @@ static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *even
else {
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
- for (te = soops->tree.first; te; te = te->next) {
+ for (te = space_outliner->tree.first; te; te = te->next) {
do_outliner_item_rename(op->reports, region, te, fmval);
}
}
@@ -521,7 +523,7 @@ static void id_delete(bContext *C, ReportList *reports, TreeElement *te, TreeSto
WM_event_add_notifier(C, NC_WINDOW, NULL);
}
-void id_delete_cb(bContext *C,
+void id_delete_fn(bContext *C,
ReportList *reports,
Scene *UNUSED(scene),
TreeElement *te,
@@ -567,15 +569,15 @@ static int outliner_id_delete_invoke_do(bContext *C,
static int outliner_id_delete_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
TreeElement *te;
float fmval[2];
- BLI_assert(region && soops);
+ BLI_assert(region && space_outliner);
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
- for (te = soops->tree.first; te; te = te->next) {
+ for (te = space_outliner->tree.first; te; te = te->next) {
int ret;
if ((ret = outliner_id_delete_invoke_do(C, op->reports, te, fmval))) {
@@ -608,7 +610,7 @@ void OUTLINER_OT_id_delete(wmOperatorType *ot)
static int outliner_id_remap_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
const short id_type = (short)RNA_enum_get(op->ptr, "id_type");
ID *old_id = BLI_findlink(which_libbase(CTX_data_main(C), id_type),
@@ -617,7 +619,7 @@ static int outliner_id_remap_exec(bContext *C, wmOperator *op)
RNA_enum_get(op->ptr, "new_id"));
/* check for invalid states */
- if (soops == NULL) {
+ if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
@@ -684,14 +686,14 @@ static bool outliner_id_remap_find_tree_element(bContext *C,
static int outliner_id_remap_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
float fmval[2];
if (!RNA_property_is_set(op->ptr, RNA_struct_find_property(op->ptr, "id_type"))) {
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
- outliner_id_remap_find_tree_element(C, op, &soops->tree, fmval[1]);
+ outliner_id_remap_find_tree_element(C, op, &space_outliner->tree, fmval[1]);
}
return WM_operator_props_dialog_popup(C, op, 200);
@@ -754,7 +756,7 @@ void OUTLINER_OT_id_remap(wmOperatorType *ot)
RNA_def_property_flag(ot->prop, PROP_ENUM_NO_TRANSLATE);
}
-void id_remap_cb(bContext *C,
+void id_remap_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -783,7 +785,7 @@ void id_remap_cb(bContext *C,
/** \name ID Copy Operator
* \{ */
-static int outliner_id_copy_tag(SpaceOutliner *soops, ListBase *tree)
+static int outliner_id_copy_tag(SpaceOutliner *space_outliner, ListBase *tree)
{
TreeElement *te;
TreeStoreElem *tselem;
@@ -802,8 +804,8 @@ static int outliner_id_copy_tag(SpaceOutliner *soops, ListBase *tree)
}
/* go over sub-tree */
- if (TSELEM_OPEN(tselem, soops)) {
- num_ids += outliner_id_copy_tag(soops, &te->subtree);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ num_ids += outliner_id_copy_tag(space_outliner, &te->subtree);
}
}
@@ -813,12 +815,12 @@ static int outliner_id_copy_tag(SpaceOutliner *soops, ListBase *tree)
static int outliner_id_copy_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
char str[FILE_MAX];
BKE_copybuffer_begin(bmain);
- const int num_ids = outliner_id_copy_tag(soops, &soops->tree);
+ const int num_ids = outliner_id_copy_tag(space_outliner, &space_outliner->tree);
if (num_ids == 0) {
BKE_report(op->reports, RPT_INFO, "No selected data-blocks to copy");
return OPERATOR_CANCELLED;
@@ -968,15 +970,15 @@ static int outliner_lib_relocate_invoke_do(
static int outliner_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
TreeElement *te;
float fmval[2];
- BLI_assert(region && soops);
+ BLI_assert(region && space_outliner);
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
- for (te = soops->tree.first; te; te = te->next) {
+ for (te = space_outliner->tree.first; te; te = te->next) {
int ret;
if ((ret = outliner_lib_relocate_invoke_do(C, op->reports, te, fmval, false))) {
@@ -1003,7 +1005,7 @@ void OUTLINER_OT_lib_relocate(wmOperatorType *ot)
/* XXX This does not work with several items
* (it is only called once in the end, due to the 'deferred'
* filebrowser invocation through event system...). */
-void lib_relocate_cb(bContext *C,
+void lib_relocate_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *te,
@@ -1019,15 +1021,15 @@ void lib_relocate_cb(bContext *C,
static int outliner_lib_reload_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
TreeElement *te;
float fmval[2];
- BLI_assert(region && soops);
+ BLI_assert(region && space_outliner);
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
- for (te = soops->tree.first; te; te = te->next) {
+ for (te = space_outliner->tree.first; te; te = te->next) {
int ret;
if ((ret = outliner_lib_relocate_invoke_do(C, op->reports, te, fmval, true))) {
@@ -1057,7 +1059,7 @@ void OUTLINER_OT_lib_reload(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-void lib_reload_cb(bContext *C,
+void lib_reload_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *te,
@@ -1194,14 +1196,14 @@ int common_restrict_check(bContext *C, Object *ob)
static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op))
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
- if (outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1)) {
- outliner_flag_set(&soops->tree, TSE_CLOSED, 0);
+ if (outliner_flag_is_any_test(&space_outliner->tree, TSE_CLOSED, 1)) {
+ outliner_flag_set(&space_outliner->tree, TSE_CLOSED, 0);
}
else {
- outliner_flag_set(&soops->tree, TSE_CLOSED, 1);
+ outliner_flag_set(&space_outliner->tree, TSE_CLOSED, 1);
}
ED_region_tag_redraw(region);
@@ -1231,27 +1233,28 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot)
static int outliner_select_all_exec(bContext *C, wmOperator *op)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
int action = RNA_enum_get(op->ptr, "action");
if (action == SEL_TOGGLE) {
- action = outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1) ? SEL_DESELECT : SEL_SELECT;
+ action = outliner_flag_is_any_test(&space_outliner->tree, TSE_SELECTED, 1) ? SEL_DESELECT :
+ SEL_SELECT;
}
switch (action) {
case SEL_SELECT:
- outliner_flag_set(&soops->tree, TSE_SELECTED, 1);
+ outliner_flag_set(&space_outliner->tree, TSE_SELECTED, 1);
break;
case SEL_DESELECT:
- outliner_flag_set(&soops->tree, TSE_SELECTED, 0);
+ outliner_flag_set(&space_outliner->tree, TSE_SELECTED, 0);
break;
case SEL_INVERT:
- outliner_flag_flip(&soops->tree, TSE_SELECTED);
+ outliner_flag_flip(&space_outliner->tree, TSE_SELECTED);
break;
}
- ED_outliner_select_sync_from_outliner(C, soops);
+ ED_outliner_select_sync_from_outliner(C, space_outliner);
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
@@ -1283,7 +1286,7 @@ void OUTLINER_OT_select_all(wmOperatorType *ot)
/** \name View Show Active (Outliner) Operator
* \{ */
-static void outliner_set_coordinates_element_recursive(SpaceOutliner *soops,
+static void outliner_set_coordinates_element_recursive(SpaceOutliner *space_outliner,
TreeElement *te,
int startx,
int *starty)
@@ -1295,22 +1298,22 @@ static void outliner_set_coordinates_element_recursive(SpaceOutliner *soops,
te->ys = (float)(*starty);
*starty -= UI_UNIT_Y;
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
TreeElement *ten;
for (ten = te->subtree.first; ten; ten = ten->next) {
- outliner_set_coordinates_element_recursive(soops, ten, startx + UI_UNIT_X, starty);
+ outliner_set_coordinates_element_recursive(space_outliner, ten, startx + UI_UNIT_X, starty);
}
}
}
/* to retrieve coordinates with redrawing the entire tree */
-void outliner_set_coordinates(ARegion *region, SpaceOutliner *soops)
+void outliner_set_coordinates(ARegion *region, SpaceOutliner *space_outliner)
{
TreeElement *te;
int starty = (int)(region->v2d.tot.ymax) - UI_UNIT_Y;
- for (te = soops->tree.first; te; te = te->next) {
- outliner_set_coordinates_element_recursive(soops, te, 0, &starty);
+ for (te = space_outliner->tree.first; te; te = te->next) {
+ outliner_set_coordinates_element_recursive(space_outliner, te, 0, &starty);
}
}
@@ -1332,7 +1335,7 @@ static int outliner_open_back(TreeElement *te)
/* Return element representing the active base or bone in the outliner, or NULL if none exists */
static TreeElement *outliner_show_active_get_element(bContext *C,
- SpaceOutliner *so,
+ SpaceOutliner *space_outliner,
ViewLayer *view_layer)
{
TreeElement *te;
@@ -1343,7 +1346,7 @@ static TreeElement *outliner_show_active_get_element(bContext *C,
return NULL;
}
- te = outliner_find_id(so, &so->tree, &obact->id);
+ te = outliner_find_id(space_outliner, &space_outliner->tree, &obact->id);
if (te != NULL && obact->type == OB_ARMATURE) {
/* traverse down the bone hierarchy in case of armature */
@@ -1366,41 +1369,44 @@ static TreeElement *outliner_show_active_get_element(bContext *C,
return te;
}
-static void outliner_show_active(SpaceOutliner *so, ARegion *region, TreeElement *te, ID *id)
+static void outliner_show_active(SpaceOutliner *space_outliner,
+ ARegion *region,
+ TreeElement *te,
+ ID *id)
{
/* open up tree to active object/bone */
if (TREESTORE(te)->id == id) {
if (outliner_open_back(te)) {
- outliner_set_coordinates(region, so);
+ outliner_set_coordinates(region, space_outliner);
}
return;
}
LISTBASE_FOREACH (TreeElement *, ten, &te->subtree) {
- outliner_show_active(so, region, ten, id);
+ outliner_show_active(space_outliner, region, ten, id);
}
}
static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
{
- SpaceOutliner *so = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ARegion *region = CTX_wm_region(C);
View2D *v2d = &region->v2d;
- TreeElement *active_element = outliner_show_active_get_element(C, so, view_layer);
+ TreeElement *active_element = outliner_show_active_get_element(C, space_outliner, view_layer);
if (active_element) {
ID *id = TREESTORE(active_element)->id;
/* Expand all elements in the outliner with matching ID */
- LISTBASE_FOREACH (TreeElement *, te, &so->tree) {
- outliner_show_active(so, region, te, id);
+ LISTBASE_FOREACH (TreeElement *, te, &space_outliner->tree) {
+ outliner_show_active(space_outliner, region, te, id);
}
/* Also open back from the active_element (only done for the first found occurrence of ID
* though). */
- outliner_show_active(so, region, active_element, id);
+ outliner_show_active(space_outliner, region, active_element, id);
/* Center view on first element found */
int size_y = BLI_rcti_size_y(&v2d->mask) + 1;
@@ -1484,7 +1490,7 @@ void OUTLINER_OT_scroll_page(wmOperatorType *ot)
/* find next element that has this name */
static TreeElement *outliner_find_name(
- SpaceOutliner *soops, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound)
+ SpaceOutliner *space_outliner, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound)
{
TreeElement *te, *tes;
@@ -1506,7 +1512,7 @@ static TreeElement *outliner_find_name(
}
}
- tes = outliner_find_name(soops, &te->subtree, name, flags, prev, prevFound);
+ tes = outliner_find_name(space_outliner, &te->subtree, name, flags, prev, prevFound);
if (tes) {
return tes;
}
@@ -1517,37 +1523,37 @@ static TreeElement *outliner_find_name(
}
static void outliner_find_panel(
- Scene *UNUSED(scene), ARegion *region, SpaceOutliner *soops, int again, int flags)
+ Scene *UNUSED(scene), ARegion *region, SpaceOutliner *space_outliner, int again, int flags)
{
ReportList *reports = NULL; /* CTX_wm_reports(C); */
TreeElement *te = NULL;
TreeElement *last_find;
TreeStoreElem *tselem;
int ytop, xdelta, prevFound = 0;
- char name[sizeof(soops->search_string)];
+ char name[sizeof(space_outliner->search_string)];
/* get last found tree-element based on stored search_tse */
- last_find = outliner_find_tse(soops, &soops->search_tse);
+ last_find = outliner_find_tse(space_outliner, &space_outliner->search_tse);
/* determine which type of search to do */
if (again && last_find) {
/* no popup panel - previous + user wanted to search for next after previous */
- BLI_strncpy(name, soops->search_string, sizeof(name));
- flags = soops->search_flags;
+ BLI_strncpy(name, space_outliner->search_string, sizeof(name));
+ flags = space_outliner->search_flags;
/* try to find matching element */
- te = outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound);
+ te = outliner_find_name(space_outliner, &space_outliner->tree, name, flags, last_find, &prevFound);
if (te == NULL) {
/* no more matches after previous, start from beginning again */
prevFound = 1;
- te = outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound);
+ te = outliner_find_name(space_outliner, &space_outliner->tree, name, flags, last_find, &prevFound);
}
}
else {
/* pop up panel - no previous, or user didn't want search after previous */
name[0] = '\0';
/* XXX if (sbutton(name, 0, sizeof(name) - 1, "Find: ") && name[0]) { */
- /* te = outliner_find_name(soops, &soops->tree, name, flags, NULL, &prevFound); */
+ /* te = outliner_find_name(space_outliner, &space_outliner->tree, name, flags, NULL, &prevFound); */
/* } */
/* else return; XXX RETURN! XXX */
}
@@ -1557,12 +1563,12 @@ static void outliner_find_panel(
tselem = TREESTORE(te);
if (tselem) {
/* expand branches so that it will be visible, we need to get correct coordinates */
- if (outliner_open_back(soops, te)) {
- outliner_set_coordinates(region, soops);
+ if (outliner_open_back(space_outliner, te)) {
+ outliner_set_coordinates(region, space_outliner);
}
/* deselect all visible, and select found element */
- outliner_flag_set(soops, &soops->tree, TSE_SELECTED, 0);
+ outliner_flag_set(space_outliner, &space_outliner->tree, TSE_SELECTED, 0);
tselem->flag |= TSE_SELECTED;
/* make te->ys center of view */
@@ -1579,10 +1585,10 @@ static void outliner_find_panel(
region->v2d.cur.xmax += xdelta;
/* store selection */
- soops->search_tse = *tselem;
+ space_outliner->search_tse = *tselem;
- BLI_strncpy(soops->search_string, name, sizeof(soops->search_string));
- soops->search_flags = flags;
+ BLI_strncpy(space_outliner->search_string, name, sizeof(space_outliner->search_string));
+ space_outliner->search_flags = flags;
/* redraw */
ED_region_tag_redraw_no_rebuild(region);
@@ -1628,23 +1634,23 @@ static void outliner_openclose_level(ListBase *lb, int curlevel, int level, int
static int outliner_one_level_exec(bContext *C, wmOperator *op)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
const bool add = RNA_boolean_get(op->ptr, "open");
int level;
- level = outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1);
+ level = outliner_flag_is_any_test(&space_outliner->tree, TSE_CLOSED, 1);
if (add == 1) {
if (level) {
- outliner_openclose_level(&soops->tree, 1, level, 1);
+ outliner_openclose_level(&space_outliner->tree, 1, level, 1);
}
}
else {
if (level == 0) {
- level = outliner_count_levels(&soops->tree, 0);
+ level = outliner_count_levels(&space_outliner->tree, 0);
}
if (level) {
- outliner_openclose_level(&soops->tree, 1, level - 1, 0);
+ outliner_openclose_level(&space_outliner->tree, 1, level - 1, 0);
}
}
@@ -1699,7 +1705,7 @@ static int subtree_has_objects(ListBase *lb)
}
/* recursive helper function for Show Hierarchy operator */
-static void tree_element_show_hierarchy(Scene *scene, SpaceOutliner *soops, ListBase *lb)
+static void tree_element_show_hierarchy(Scene *scene, SpaceOutliner *space_outliner, ListBase *lb)
{
TreeElement *te;
TreeStoreElem *tselem;
@@ -1734,8 +1740,8 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOutliner *soops, List
tselem->flag |= TSE_CLOSED;
}
- if (TSELEM_OPEN(tselem, soops)) {
- tree_element_show_hierarchy(scene, soops, &te->subtree);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ tree_element_show_hierarchy(scene, space_outliner, &te->subtree);
}
}
}
@@ -1743,12 +1749,12 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOutliner *soops, List
/* show entire object level hierarchy */
static int outliner_show_hierarchy_exec(bContext *C, wmOperator *UNUSED(op))
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
/* recursively open/close levels */
- tree_element_show_hierarchy(scene, soops, &soops->tree);
+ tree_element_show_hierarchy(scene, space_outliner, &space_outliner->tree);
ED_region_tag_redraw(region);
@@ -1782,8 +1788,8 @@ static bool ed_operator_outliner_datablocks_active(bContext *C)
{
ScrArea *area = CTX_wm_area(C);
if ((area) && (area->spacetype == SPACE_OUTLINER)) {
- SpaceOutliner *so = CTX_wm_space_outliner(C);
- return (so->outlinevis == SO_DATA_API);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+ return (space_outliner->outlinevis == SO_DATA_API);
}
return 0;
}
@@ -1957,7 +1963,7 @@ enum {
} /*eDrivers_EditModes*/;
/* Recursively iterate over tree, finding and working on selected items */
-static void do_outliner_drivers_editop(SpaceOutliner *soops,
+static void do_outliner_drivers_editop(SpaceOutliner *space_outliner,
ListBase *tree,
ReportList *reports,
short mode)
@@ -2025,8 +2031,8 @@ static void do_outliner_drivers_editop(SpaceOutliner *soops,
}
/* go over sub-tree */
- if (TSELEM_OPEN(tselem, soops)) {
- do_outliner_drivers_editop(soops, &te->subtree, reports, mode);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ do_outliner_drivers_editop(space_outliner, &te->subtree, reports, mode);
}
}
}
@@ -2039,15 +2045,16 @@ static void do_outliner_drivers_editop(SpaceOutliner *soops,
static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op)
{
- SpaceOutliner *soutliner = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
/* check for invalid states */
- if (soutliner == NULL) {
+ if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
/* recursively go into tree, adding selected items */
- do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD);
+ do_outliner_drivers_editop(
+ space_outliner, &space_outliner->tree, op->reports, DRIVERS_EDITMODE_ADD);
/* send notifiers */
WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); /* XXX */
@@ -2078,15 +2085,16 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot)
static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op)
{
- SpaceOutliner *soutliner = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
/* check for invalid states */
- if (soutliner == NULL) {
+ if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
/* recursively go into tree, adding selected items */
- do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_REMOVE);
+ do_outliner_drivers_editop(
+ space_outliner, &space_outliner->tree, op->reports, DRIVERS_EDITMODE_REMOVE);
/* send notifiers */
WM_event_add_notifier(C, ND_KEYS, NULL); /* XXX */
@@ -2153,7 +2161,7 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add)
}
/* Recursively iterate over tree, finding and working on selected items */
-static void do_outliner_keyingset_editop(SpaceOutliner *soops,
+static void do_outliner_keyingset_editop(SpaceOutliner *space_outliner,
KeyingSet *ks,
ListBase *tree,
short mode)
@@ -2211,8 +2219,8 @@ static void do_outliner_keyingset_editop(SpaceOutliner *soops,
}
/* go over sub-tree */
- if (TSELEM_OPEN(tselem, soops)) {
- do_outliner_keyingset_editop(soops, ks, &te->subtree, mode);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ do_outliner_keyingset_editop(space_outliner, ks, &te->subtree, mode);
}
}
}
@@ -2225,7 +2233,7 @@ static void do_outliner_keyingset_editop(SpaceOutliner *soops,
static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op)
{
- SpaceOutliner *soutliner = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
Scene *scene = CTX_data_scene(C);
KeyingSet *ks = verify_active_keyingset(scene, 1);
@@ -2234,12 +2242,12 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Operation requires an active keying set");
return OPERATOR_CANCELLED;
}
- if (soutliner == NULL) {
+ if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
/* recursively go into tree, adding selected items */
- do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD);
+ do_outliner_keyingset_editop(space_outliner, ks, &space_outliner->tree, KEYINGSET_EDITMODE_ADD);
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
@@ -2270,17 +2278,18 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot)
static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(op))
{
- SpaceOutliner *soutliner = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
Scene *scene = CTX_data_scene(C);
KeyingSet *ks = verify_active_keyingset(scene, 1);
/* check for invalid states */
- if (soutliner == NULL) {
+ if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
/* recursively go into tree, adding selected items */
- do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE);
+ do_outliner_keyingset_editop(
+ space_outliner, ks, &space_outliner->tree, KEYINGSET_EDITMODE_REMOVE);
/* send notifiers */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
@@ -2313,8 +2322,8 @@ static bool ed_operator_outliner_id_orphans_active(bContext *C)
{
ScrArea *area = CTX_wm_area(C);
if (area != NULL && area->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *so = CTX_wm_space_outliner(C);
- return (so->outlinevis == SO_ID_ORPHANS);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+ return (space_outliner->outlinevis == SO_ID_ORPHANS);
}
return true;
}
@@ -2382,7 +2391,7 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
ScrArea *area = CTX_wm_area(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int num_tagged[INDEX_ID_MAX] = {0};
if ((num_tagged[INDEX_ID_NULL] = RNA_int_get(op->ptr, "num_deleted")) == 0) {
@@ -2409,7 +2418,7 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *op)
* handling notifiers/redraw which leads to deleting the same object twice.
* cleanup tree here to prevent such cases. */
if ((area != NULL) && (area->spacetype == SPACE_OUTLINER)) {
- outliner_cleanup_tree(soops);
+ outliner_cleanup_tree(space_outliner);
}
DEG_relations_tag_update(bmain);
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 186a66a95c0..33dbbb274c0 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -21,8 +21,7 @@
* \ingroup spoutliner
*/
-#ifndef __OUTLINER_INTERN_H__
-#define __OUTLINER_INTERN_H__
+#pragma once
#include "RNA_types.h"
@@ -171,7 +170,8 @@ typedef enum {
/* The outliner display modes that support the filter system.
* Note: keep it synced with space_outliner.py */
-#define SUPPORT_FILTER_OUTLINER(soops_) (ELEM((soops_)->outlinevis, SO_VIEW_LAYER))
+#define SUPPORT_FILTER_OUTLINER(space_outliner_) \
+ (ELEM((space_outliner_)->outlinevis, SO_VIEW_LAYER))
/* Outliner Searching --
*
@@ -228,13 +228,13 @@ typedef enum TreeItemSelectAction {
/* outliner_tree.c ----------------------------------------------- */
void outliner_free_tree(ListBase *tree);
-void outliner_cleanup_tree(struct SpaceOutliner *soops);
+void outliner_cleanup_tree(struct SpaceOutliner *space_outliner);
void outliner_free_tree_element(TreeElement *element, ListBase *parent_subtree);
void outliner_build_tree(struct Main *mainvar,
struct Scene *scene,
struct ViewLayer *view_layer,
- struct SpaceOutliner *soops,
+ struct SpaceOutliner *space_outliner,
struct ARegion *region);
bool outliner_element_needs_rebuild_on_open_change(const TreeStoreElem *tselem);
@@ -265,20 +265,20 @@ int tree_element_id_type_to_index(TreeElement *te);
/* outliner_select.c -------------------------------------------- */
eOLDrawState tree_element_type_active(struct bContext *C,
const TreeViewContext *tvc,
- struct SpaceOutliner *soops,
+ struct SpaceOutliner *space_outliner,
TreeElement *te,
TreeStoreElem *tselem,
const eOLSetState set,
bool recursive);
eOLDrawState tree_element_active(struct bContext *C,
const TreeViewContext *tvc,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
TreeElement *te,
const eOLSetState set,
const bool handle_all_types);
void outliner_item_select(struct bContext *C,
- struct SpaceOutliner *soops,
+ struct SpaceOutliner *space_outliner,
struct TreeElement *te,
const short select_flag);
@@ -291,7 +291,7 @@ bool outliner_item_is_co_over_name_icons(const TreeElement *te, float view_co_x)
bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x);
/* outliner_edit.c ---------------------------------------------- */
-typedef void (*outliner_operation_cb)(struct bContext *C,
+typedef void (*outliner_operation_fn)(struct bContext *C,
struct ReportList *,
struct Scene *scene,
struct TreeElement *,
@@ -302,17 +302,17 @@ typedef void (*outliner_operation_cb)(struct bContext *C,
void outliner_do_object_operation_ex(struct bContext *C,
struct ReportList *reports,
struct Scene *scene,
- struct SpaceOutliner *soops,
+ struct SpaceOutliner *space_outliner,
struct ListBase *lb,
- outliner_operation_cb operation_cb,
+ outliner_operation_fn operation_fn,
void *user_data,
bool recurse_selected);
void outliner_do_object_operation(struct bContext *C,
struct ReportList *reports,
struct Scene *scene,
- struct SpaceOutliner *soops,
+ struct SpaceOutliner *space_outliner,
struct ListBase *lb,
- outliner_operation_cb operation_cb);
+ outliner_operation_fn operation_fn);
int common_restrict_check(struct bContext *C, struct Object *ob);
@@ -320,21 +320,21 @@ int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel);
bool outliner_flag_set(ListBase *lb, short flag, short set);
bool outliner_flag_flip(ListBase *lb, short flag);
-void item_rename_cb(struct bContext *C,
+void item_rename_fn(struct bContext *C,
struct ReportList *reports,
struct Scene *scene,
TreeElement *te,
struct TreeStoreElem *tsep,
struct TreeStoreElem *tselem,
void *user_data);
-void lib_relocate_cb(struct bContext *C,
+void lib_relocate_fn(struct bContext *C,
struct ReportList *reports,
struct Scene *scene,
struct TreeElement *te,
struct TreeStoreElem *tsep,
struct TreeStoreElem *tselem,
void *user_data);
-void lib_reload_cb(struct bContext *C,
+void lib_reload_fn(struct bContext *C,
struct ReportList *reports,
struct Scene *scene,
struct TreeElement *te,
@@ -342,14 +342,14 @@ void lib_reload_cb(struct bContext *C,
struct TreeStoreElem *tselem,
void *user_data);
-void id_delete_cb(struct bContext *C,
+void id_delete_fn(struct bContext *C,
struct ReportList *reports,
struct Scene *scene,
struct TreeElement *te,
struct TreeStoreElem *tsep,
struct TreeStoreElem *tselem,
void *user_data);
-void id_remap_cb(struct bContext *C,
+void id_remap_fn(struct bContext *C,
struct ReportList *reports,
struct Scene *scene,
struct TreeElement *te,
@@ -357,14 +357,14 @@ void id_remap_cb(struct bContext *C,
struct TreeStoreElem *tselem,
void *user_data);
-void item_object_mode_enter_cb(struct bContext *C,
+void item_object_mode_enter_fn(struct bContext *C,
struct ReportList *reports,
struct Scene *scene,
TreeElement *te,
struct TreeStoreElem *tsep,
struct TreeStoreElem *tselem,
void *user_data);
-void item_object_mode_exit_cb(struct bContext *C,
+void item_object_mode_exit_fn(struct bContext *C,
struct ReportList *reports,
struct Scene *scene,
TreeElement *te,
@@ -372,7 +372,7 @@ void item_object_mode_exit_cb(struct bContext *C,
struct TreeStoreElem *tselem,
void *user_data);
-void outliner_set_coordinates(struct ARegion *region, struct SpaceOutliner *soops);
+void outliner_set_coordinates(struct ARegion *region, struct SpaceOutliner *space_outliner);
void outliner_item_openclose(TreeElement *te, bool open, bool toggle_all);
@@ -486,36 +486,36 @@ void OUTLINER_OT_unhide_all(struct wmOperatorType *ot);
void outliner_viewcontext_init(const struct bContext *C, TreeViewContext *tvc);
-TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops,
+TreeElement *outliner_find_item_at_y(const SpaceOutliner *space_outliner,
const ListBase *tree,
float view_co_y);
-TreeElement *outliner_find_item_at_x_in_row(const SpaceOutliner *soops,
+TreeElement *outliner_find_item_at_x_in_row(const SpaceOutliner *space_outliner,
const TreeElement *parent_te,
float view_co_x,
bool *multiple_objects);
-TreeElement *outliner_find_tse(struct SpaceOutliner *soops, const TreeStoreElem *tse);
+TreeElement *outliner_find_tse(struct SpaceOutliner *space_outliner, const TreeStoreElem *tse);
TreeElement *outliner_find_tree_element(ListBase *lb, const TreeStoreElem *store_elem);
TreeElement *outliner_find_parent_element(ListBase *lb,
TreeElement *parent_te,
const TreeElement *child_te);
-TreeElement *outliner_find_id(struct SpaceOutliner *soops, ListBase *lb, const struct ID *id);
+TreeElement *outliner_find_id(struct SpaceOutliner *space_outliner,
+ ListBase *lb,
+ const struct ID *id);
TreeElement *outliner_find_posechannel(ListBase *lb, const struct bPoseChannel *pchan);
TreeElement *outliner_find_editbone(ListBase *lb, const struct EditBone *ebone);
TreeElement *outliner_search_back_te(TreeElement *te, short idcode);
struct ID *outliner_search_back(TreeElement *te, short idcode);
-bool outliner_tree_traverse(const SpaceOutliner *soops,
+bool outliner_tree_traverse(const SpaceOutliner *space_outliner,
ListBase *tree,
int filter_te_flag,
int filter_tselem_flag,
TreeTraversalFunc func,
void *customdata);
-float outliner_restrict_columns_width(const struct SpaceOutliner *soops);
+float outliner_restrict_columns_width(const struct SpaceOutliner *space_outliner);
TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag);
bool outliner_is_element_visible(const TreeElement *te);
void outliner_scroll_view(struct ARegion *region, int delta_y);
/* outliner_sync.c ---------------------------------------------- */
-void outliner_sync_selection(const struct bContext *C, struct SpaceOutliner *soops);
-
-#endif /* __OUTLINER_INTERN_H__ */
+void outliner_sync_selection(const struct bContext *C, struct SpaceOutliner *space_outliner);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 8bf05c3018a..1ac1b46f0d1 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -334,7 +334,7 @@ static void do_outliner_ebone_select_recursive(bArmature *arm, EditBone *ebone_p
static eOLDrawState tree_element_set_active_object(bContext *C,
Scene *scene,
ViewLayer *view_layer,
- SpaceOutliner *UNUSED(soops),
+ SpaceOutliner *UNUSED(space_outliner),
TreeElement *te,
const eOLSetState set,
bool recursive)
@@ -526,7 +526,7 @@ static eOLDrawState tree_element_active_camera(bContext *C,
static eOLDrawState tree_element_active_world(bContext *C,
Scene *scene,
ViewLayer *UNUSED(sl),
- SpaceOutliner *UNUSED(soops),
+ SpaceOutliner *UNUSED(space_outliner),
TreeElement *te,
const eOLSetState set)
{
@@ -1033,7 +1033,7 @@ static eOLDrawState tree_element_active_layer_collection(bContext *C,
/* generic call for ID data check or make/check active in UI */
eOLDrawState tree_element_active(bContext *C,
const TreeViewContext *tvc,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
TreeElement *te,
const eOLSetState set,
const bool handle_all_types)
@@ -1045,13 +1045,13 @@ eOLDrawState tree_element_active(bContext *C,
case ID_OB:
if (handle_all_types) {
return tree_element_set_active_object(
- C, tvc->scene, tvc->view_layer, soops, te, set, false);
+ C, tvc->scene, tvc->view_layer, space_outliner, te, set, false);
}
break;
case ID_MA:
return tree_element_active_material(C, tvc->scene, tvc->view_layer, te, set);
case ID_WO:
- return tree_element_active_world(C, tvc->scene, tvc->view_layer, soops, te, set);
+ return tree_element_active_world(C, tvc->scene, tvc->view_layer, space_outliner, te, set);
case ID_CA:
return tree_element_active_camera(C, tvc->scene, tvc->view_layer, te, set);
}
@@ -1063,7 +1063,7 @@ eOLDrawState tree_element_active(bContext *C,
*/
eOLDrawState tree_element_type_active(bContext *C,
const TreeViewContext *tvc,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
TreeElement *te,
TreeStoreElem *tselem,
const eOLSetState set,
@@ -1080,7 +1080,8 @@ eOLDrawState tree_element_type_active(bContext *C,
return tree_element_active_modifier(C, tvc->scene, tvc->view_layer, te, tselem, set);
case TSE_LINKED_OB:
if (set != OL_SETSEL_NONE) {
- tree_element_set_active_object(C, tvc->scene, tvc->view_layer, soops, te, set, false);
+ tree_element_set_active_object(
+ C, tvc->scene, tvc->view_layer, space_outliner, te, set, false);
}
else if (tselem->id == (ID *)tvc->obact) {
return OL_DRAWSEL_NORMAL;
@@ -1126,7 +1127,7 @@ eOLDrawState tree_element_type_active(bContext *C,
*/
static void do_outliner_item_activate_tree_element(bContext *C,
const TreeViewContext *tvc,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
TreeElement *te,
TreeStoreElem *tselem,
const bool extend,
@@ -1153,7 +1154,7 @@ static void do_outliner_item_activate_tree_element(bContext *C,
tree_element_set_active_object(C,
tvc->scene,
tvc->view_layer,
- soops,
+ space_outliner,
te,
(extend && tselem->type == 0) ? OL_SETSEL_EXTEND :
OL_SETSEL_NORMAL,
@@ -1169,7 +1170,7 @@ static void do_outliner_item_activate_tree_element(bContext *C,
WM_window_set_active_scene(CTX_data_main(C), C, CTX_wm_window(C), (Scene *)tselem->id);
}
}
- else if ((te->idcode == ID_GR) && (soops->outlinevis != SO_VIEW_LAYER)) {
+ else if ((te->idcode == ID_GR) && (space_outliner->outlinevis != SO_VIEW_LAYER)) {
Collection *gr = (Collection *)tselem->id;
if (extend) {
@@ -1210,18 +1211,23 @@ static void do_outliner_item_activate_tree_element(bContext *C,
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, tvc->scene);
}
else { /* Rest of types. */
- tree_element_active(C, tvc, soops, te, OL_SETSEL_NORMAL, false);
+ tree_element_active(C, tvc, space_outliner, te, OL_SETSEL_NORMAL, false);
}
}
else if (do_activate_data) {
- tree_element_type_active(
- C, tvc, soops, te, tselem, extend ? OL_SETSEL_EXTEND : OL_SETSEL_NORMAL, recursive);
+ tree_element_type_active(C,
+ tvc,
+ space_outliner,
+ te,
+ tselem,
+ extend ? OL_SETSEL_EXTEND : OL_SETSEL_NORMAL,
+ recursive);
}
}
/* Select the item using the set flags */
void outliner_item_select(bContext *C,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
TreeElement *te,
const short select_flag)
{
@@ -1233,7 +1239,7 @@ void outliner_item_select(bContext *C,
/* Clear previous active when activating and clear selection when not extending selection */
const short clear_flag = (activate ? TSE_ACTIVE : 0) | (extend ? 0 : TSE_SELECTED);
if (clear_flag) {
- outliner_flag_set(&soops->tree, clear_flag, false);
+ outliner_flag_set(&space_outliner->tree, clear_flag, false);
}
if (select_flag & OL_ITEM_SELECT) {
@@ -1250,12 +1256,12 @@ void outliner_item_select(bContext *C,
tselem->flag |= TSE_ACTIVE;
do_outliner_item_activate_tree_element(C,
&tvc,
- soops,
+ space_outliner,
te,
tselem,
extend,
select_flag & OL_ITEM_RECURSIVE,
- activate_data || soops->flag & SO_SYNC_SELECT);
+ activate_data || space_outliner->flag & SO_SYNC_SELECT);
/* Mode toggle on data activate for now, but move later */
if (select_flag & OL_ITEM_TOGGLE_MODE) {
@@ -1296,15 +1302,15 @@ static bool do_outliner_range_select_recursive(ListBase *lb,
/* Select a range of items between cursor and active element */
static void do_outliner_range_select(bContext *C,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
TreeElement *cursor,
const bool extend)
{
- TreeElement *active = outliner_find_element_with_flag(&soops->tree, TSE_ACTIVE);
+ TreeElement *active = outliner_find_element_with_flag(&space_outliner->tree, TSE_ACTIVE);
/* If no active element exists, activate the element under the cursor */
if (!active) {
- outliner_item_select(C, soops, cursor, OL_ITEM_SELECT | OL_ITEM_ACTIVATE);
+ outliner_item_select(C, space_outliner, cursor, OL_ITEM_SELECT | OL_ITEM_ACTIVATE);
return;
}
@@ -1312,29 +1318,29 @@ static void do_outliner_range_select(bContext *C,
const bool active_selected = (tselem->flag & TSE_SELECTED);
if (!extend) {
- outliner_flag_set(&soops->tree, TSE_SELECTED, false);
+ outliner_flag_set(&space_outliner->tree, TSE_SELECTED, false);
}
/* Select active if under cursor */
if (active == cursor) {
- outliner_item_select(C, soops, cursor, OL_ITEM_SELECT);
+ outliner_item_select(C, space_outliner, cursor, OL_ITEM_SELECT);
return;
}
/* If active is not selected or visible, select and activate the element under the cursor */
if (!active_selected || !outliner_is_element_visible(active)) {
- outliner_item_select(C, soops, cursor, OL_ITEM_SELECT | OL_ITEM_ACTIVATE);
+ outliner_item_select(C, space_outliner, cursor, OL_ITEM_SELECT | OL_ITEM_ACTIVATE);
return;
}
- do_outliner_range_select_recursive(&soops->tree, active, cursor, false);
+ do_outliner_range_select_recursive(&space_outliner->tree, active, cursor, false);
}
-static bool outliner_is_co_within_restrict_columns(const SpaceOutliner *soops,
+static bool outliner_is_co_within_restrict_columns(const SpaceOutliner *space_outliner,
const ARegion *region,
float view_co_x)
{
- return (view_co_x > region->v2d.cur.xmax - outliner_restrict_columns_width(soops));
+ return (view_co_x > region->v2d.cur.xmax - outliner_restrict_columns_width(space_outliner));
}
/**
@@ -1349,20 +1355,20 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
const bool deselect_all)
{
ARegion *region = CTX_wm_region(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
TreeElement *te;
float view_mval[2];
bool changed = false, rebuild_tree = false;
UI_view2d_region_to_view(&region->v2d, mval[0], mval[1], &view_mval[0], &view_mval[1]);
- if (outliner_is_co_within_restrict_columns(soops, region, view_mval[0])) {
+ if (outliner_is_co_within_restrict_columns(space_outliner, region, view_mval[0])) {
return OPERATOR_CANCELLED;
}
- if (!(te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]))) {
+ if (!(te = outliner_find_item_at_y(space_outliner, &space_outliner->tree, view_mval[1]))) {
if (deselect_all) {
- outliner_flag_set(&soops->tree, TSE_SELECTED, false);
+ outliner_flag_set(&space_outliner->tree, TSE_SELECTED, false);
changed = true;
}
}
@@ -1375,7 +1381,7 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
/* The row may also contain children, if one is hovered we want this instead of current te. */
bool merged_elements = false;
TreeElement *activate_te = outliner_find_item_at_x_in_row(
- soops, te, view_mval[0], &merged_elements);
+ space_outliner, te, view_mval[0], &merged_elements);
/* If the selected icon was an aggregate of multiple elements, run the search popup */
if (merged_elements) {
@@ -1386,7 +1392,7 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
TreeStoreElem *activate_tselem = TREESTORE(activate_te);
if (use_range) {
- do_outliner_range_select(C, soops, activate_te, extend);
+ do_outliner_range_select(C, space_outliner, activate_te, extend);
}
else {
const bool is_over_name_icons = outliner_item_is_co_over_name_icons(activate_te,
@@ -1399,7 +1405,7 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
(is_over_name_icons ? OL_ITEM_SELECT_DATA : 0) |
(extend ? OL_ITEM_EXTEND : 0) | OL_ITEM_TOGGLE_MODE;
- outliner_item_select(C, soops, activate_te, select_flag);
+ outliner_item_select(C, space_outliner, activate_te, select_flag);
}
changed = true;
@@ -1413,7 +1419,7 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
ED_region_tag_redraw_no_rebuild(region);
}
- ED_outliner_select_sync_from_outliner(C, soops);
+ ED_outliner_select_sync_from_outliner(C, space_outliner);
}
return OPERATOR_FINISHED;
@@ -1457,20 +1463,24 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot)
/* ****************************************************** */
/* **************** Box Select Tool ****************** */
-static void outliner_item_box_select(
- bContext *C, SpaceOutliner *soops, Scene *scene, rctf *rectf, TreeElement *te, bool select)
+static void outliner_item_box_select(bContext *C,
+ SpaceOutliner *space_outliner,
+ Scene *scene,
+ rctf *rectf,
+ TreeElement *te,
+ bool select)
{
TreeStoreElem *tselem = TREESTORE(te);
if (te->ys <= rectf->ymax && te->ys + UI_UNIT_Y >= rectf->ymin) {
outliner_item_select(
- C, soops, te, (select ? OL_ITEM_SELECT : OL_ITEM_DESELECT) | OL_ITEM_EXTEND);
+ C, space_outliner, te, (select ? OL_ITEM_SELECT : OL_ITEM_DESELECT) | OL_ITEM_EXTEND);
}
/* Look at its children. */
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
for (te = te->subtree.first; te; te = te->next) {
- outliner_item_box_select(C, soops, scene, rectf, te, select);
+ outliner_item_box_select(C, space_outliner, scene, rectf, te, select);
}
}
}
@@ -1478,35 +1488,35 @@ static void outliner_item_box_select(
static int outliner_box_select_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
rctf rectf;
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const bool select = (sel_op != SEL_OP_SUB);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- outliner_flag_set(&soops->tree, TSE_SELECTED, 0);
+ outliner_flag_set(&space_outliner->tree, TSE_SELECTED, 0);
}
WM_operator_properties_border_to_rctf(op, &rectf);
UI_view2d_region_to_view_rctf(&region->v2d, &rectf, &rectf);
- LISTBASE_FOREACH (TreeElement *, te, &soops->tree) {
- outliner_item_box_select(C, soops, scene, &rectf, te, select);
+ LISTBASE_FOREACH (TreeElement *, te, &space_outliner->tree) {
+ outliner_item_box_select(C, space_outliner, scene, &rectf, te, select);
}
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
ED_region_tag_redraw(region);
- ED_outliner_select_sync_from_outliner(C, soops);
+ ED_outliner_select_sync_from_outliner(C, space_outliner);
return OPERATOR_FINISHED;
}
static int outliner_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
float view_mval[2];
const bool tweak = RNA_boolean_get(op->ptr, "tweak");
@@ -1515,7 +1525,7 @@ static int outliner_box_select_invoke(bContext *C, wmOperator *op, const wmEvent
&region->v2d, event->mval[0], event->mval[1], &view_mval[0], &view_mval[1]);
/* Find element clicked on */
- TreeElement *te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]);
+ TreeElement *te = outliner_find_item_at_y(space_outliner, &space_outliner->tree, view_mval[1]);
/* Pass through if click is over name or icons, or not tweak event */
if (te && tweak && outliner_item_is_co_over_name_icons(te, view_mval[0])) {
@@ -1559,10 +1569,11 @@ void OUTLINER_OT_select_box(wmOperatorType *ot)
/* **************** Walk Select Tool ****************** */
/* Given a tree element return the rightmost child that is visible in the outliner */
-static TreeElement *outliner_find_rightmost_visible_child(SpaceOutliner *soops, TreeElement *te)
+static TreeElement *outliner_find_rightmost_visible_child(SpaceOutliner *space_outliner,
+ TreeElement *te)
{
while (te->subtree.last) {
- if (TSELEM_OPEN(TREESTORE(te), soops)) {
+ if (TSELEM_OPEN(TREESTORE(te), space_outliner)) {
te = te->subtree.last;
}
else {
@@ -1573,10 +1584,10 @@ static TreeElement *outliner_find_rightmost_visible_child(SpaceOutliner *soops,
}
/* Find previous visible element in the tree */
-static TreeElement *outliner_find_previous_element(SpaceOutliner *soops, TreeElement *te)
+static TreeElement *outliner_find_previous_element(SpaceOutliner *space_outliner, TreeElement *te)
{
if (te->prev) {
- te = outliner_find_rightmost_visible_child(soops, te->prev);
+ te = outliner_find_rightmost_visible_child(space_outliner, te->prev);
}
else if (te->parent) {
/* Use parent if at beginning of list */
@@ -1602,11 +1613,11 @@ static TreeElement *outliner_element_find_successor_in_parents(TreeElement *te)
}
/* Find next visible element in the tree */
-static TreeElement *outliner_find_next_element(SpaceOutliner *soops, TreeElement *te)
+static TreeElement *outliner_find_next_element(SpaceOutliner *space_outliner, TreeElement *te)
{
TreeStoreElem *tselem = TREESTORE(te);
- if (TSELEM_OPEN(tselem, soops) && te->subtree.first) {
+ if (TSELEM_OPEN(tselem, space_outliner) && te->subtree.first) {
te = te->subtree.first;
}
else if (te->next) {
@@ -1619,7 +1630,7 @@ static TreeElement *outliner_find_next_element(SpaceOutliner *soops, TreeElement
return te;
}
-static TreeElement *do_outliner_select_walk(SpaceOutliner *soops,
+static TreeElement *do_outliner_select_walk(SpaceOutliner *space_outliner,
TreeElement *te,
const int direction,
const bool extend,
@@ -1629,10 +1640,10 @@ static TreeElement *do_outliner_select_walk(SpaceOutliner *soops,
switch (direction) {
case UI_SELECT_WALK_UP:
- te = outliner_find_previous_element(soops, te);
+ te = outliner_find_previous_element(space_outliner, te);
break;
case UI_SELECT_WALK_DOWN:
- te = outliner_find_next_element(soops, te);
+ te = outliner_find_next_element(space_outliner, te);
break;
case UI_SELECT_WALK_LEFT:
outliner_item_openclose(te, false, toggle_all);
@@ -1654,14 +1665,14 @@ static TreeElement *do_outliner_select_walk(SpaceOutliner *soops,
/* Find the active element to walk from, or set one if none exists.
* Changed is set to true if the active element is found, or false if it was set */
-static TreeElement *find_walk_select_start_element(SpaceOutliner *soops, bool *changed)
+static TreeElement *find_walk_select_start_element(SpaceOutliner *space_outliner, bool *changed)
{
- TreeElement *active_te = outliner_find_element_with_flag(&soops->tree, TSE_ACTIVE);
+ TreeElement *active_te = outliner_find_element_with_flag(&space_outliner->tree, TSE_ACTIVE);
*changed = false;
/* If no active element exists, use the first element in the tree */
if (!active_te) {
- active_te = soops->tree.first;
+ active_te = space_outliner->tree.first;
*changed = true;
}
@@ -1694,7 +1705,7 @@ static void outliner_walk_scroll(ARegion *region, TreeElement *te)
static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
ARegion *region = CTX_wm_region(C);
const short direction = RNA_enum_get(op->ptr, "direction");
@@ -1702,20 +1713,22 @@ static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEven
const bool toggle_all = RNA_boolean_get(op->ptr, "toggle_all");
bool changed;
- TreeElement *active_te = find_walk_select_start_element(soops, &changed);
+ TreeElement *active_te = find_walk_select_start_element(space_outliner, &changed);
/* If finding the active element did not modify the selection, proceed to walk */
if (!changed) {
- active_te = do_outliner_select_walk(soops, active_te, direction, extend, toggle_all);
+ active_te = do_outliner_select_walk(space_outliner, active_te, direction, extend, toggle_all);
}
- outliner_item_select(
- C, soops, active_te, OL_ITEM_SELECT | OL_ITEM_ACTIVATE | (extend ? OL_ITEM_EXTEND : 0));
+ outliner_item_select(C,
+ space_outliner,
+ active_te,
+ OL_ITEM_SELECT | OL_ITEM_ACTIVATE | (extend ? OL_ITEM_EXTEND : 0));
/* Scroll outliner to focus on walk element */
outliner_walk_scroll(region, active_te);
- ED_outliner_select_sync_from_outliner(C, soops);
+ ED_outliner_select_sync_from_outliner(C, space_outliner);
ED_region_tag_redraw(region);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c
index a4be4062746..3055d15725b 100644
--- a/source/blender/editors/space_outliner/outliner_sync.c
+++ b/source/blender/editors/space_outliner/outliner_sync.c
@@ -99,9 +99,9 @@ void ED_outliner_select_sync_flag_outliners(const bContext *C)
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOutliner *soutliner = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
- soutliner->sync_select_dirty |= wm->outliner_sync_select_dirty;
+ space_outliner->sync_select_dirty |= wm->outliner_sync_select_dirty;
}
}
}
@@ -128,13 +128,13 @@ typedef struct SyncSelectTypes {
* interaction mode and outliner display mode
*/
static void outliner_sync_select_from_outliner_set_types(bContext *C,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
SyncSelectTypes *sync_types)
{
TreeViewContext tvc;
outliner_viewcontext_init(C, &tvc);
- const bool sequence_view = soops->outlinevis == SO_SEQUENCE;
+ const bool sequence_view = space_outliner->outlinevis == SO_SEQUENCE;
sync_types->object = !sequence_view;
sync_types->edit_bone = !sequence_view && (tvc.ob_edit && tvc.ob_edit->type == OB_ARMATURE);
@@ -148,22 +148,24 @@ static void outliner_sync_select_from_outliner_set_types(bContext *C,
* Returns true if a sync is needed.
*/
static bool outliner_sync_select_to_outliner_set_types(const bContext *C,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
SyncSelectTypes *sync_types)
{
TreeViewContext tvc;
outliner_viewcontext_init(C, &tvc);
- const bool sequence_view = soops->outlinevis == SO_SEQUENCE;
+ const bool sequence_view = space_outliner->outlinevis == SO_SEQUENCE;
sync_types->object = !sequence_view &&
- (soops->sync_select_dirty & WM_OUTLINER_SYNC_SELECT_FROM_OBJECT);
+ (space_outliner->sync_select_dirty & WM_OUTLINER_SYNC_SELECT_FROM_OBJECT);
sync_types->edit_bone = !sequence_view && (tvc.ob_edit && tvc.ob_edit->type == OB_ARMATURE) &&
- (soops->sync_select_dirty & WM_OUTLINER_SYNC_SELECT_FROM_EDIT_BONE);
+ (space_outliner->sync_select_dirty &
+ WM_OUTLINER_SYNC_SELECT_FROM_EDIT_BONE);
sync_types->pose_bone = !sequence_view && (tvc.ob_pose && tvc.ob_pose->mode == OB_MODE_POSE) &&
- (soops->sync_select_dirty & WM_OUTLINER_SYNC_SELECT_FROM_POSE_BONE);
- sync_types->sequence = sequence_view &&
- (soops->sync_select_dirty & WM_OUTLINER_SYNC_SELECT_FROM_SEQUENCE);
+ (space_outliner->sync_select_dirty &
+ WM_OUTLINER_SYNC_SELECT_FROM_POSE_BONE);
+ sync_types->sequence = sequence_view && (space_outliner->sync_select_dirty &
+ WM_OUTLINER_SYNC_SELECT_FROM_SEQUENCE);
return sync_types->object || sync_types->edit_bone || sync_types->pose_bone ||
sync_types->sequence;
@@ -349,11 +351,11 @@ static void outliner_sync_selection_from_outliner(Scene *scene,
}
/* Set clean outliner and mark other outliners for syncing */
-void ED_outliner_select_sync_from_outliner(bContext *C, SpaceOutliner *soops)
+void ED_outliner_select_sync_from_outliner(bContext *C, SpaceOutliner *space_outliner)
{
/* Don't sync if not checked or in certain outliner display modes */
- if (!(soops->flag & SO_SYNC_SELECT) ||
- ELEM(soops->outlinevis, SO_LIBRARIES, SO_DATA_API, SO_ID_ORPHANS)) {
+ if (!(space_outliner->flag & SO_SYNC_SELECT) ||
+ ELEM(space_outliner->outlinevis, SO_LIBRARIES, SO_DATA_API, SO_ID_ORPHANS)) {
return;
}
@@ -361,7 +363,7 @@ void ED_outliner_select_sync_from_outliner(bContext *C, SpaceOutliner *soops)
ViewLayer *view_layer = CTX_data_view_layer(C);
SyncSelectTypes sync_types;
- outliner_sync_select_from_outliner_set_types(C, soops, &sync_types);
+ outliner_sync_select_from_outliner_set_types(C, space_outliner, &sync_types);
/* To store elements that have been selected to prevent linked object sync errors */
SelectedItems selected_items;
@@ -369,24 +371,24 @@ void ED_outliner_select_sync_from_outliner(bContext *C, SpaceOutliner *soops)
selected_items_init(&selected_items);
outliner_sync_selection_from_outliner(
- scene, view_layer, &soops->tree, &sync_types, &selected_items);
+ scene, view_layer, &space_outliner->tree, &sync_types, &selected_items);
selected_items_free(&selected_items);
/* Tag for updates and clear dirty flag toprevent a sync to the outliner on draw */
if (sync_types.object) {
- soops->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_OBJECT;
+ space_outliner->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_OBJECT;
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
else if (sync_types.edit_bone) {
- soops->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_EDIT_BONE;
+ space_outliner->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_EDIT_BONE;
}
else if (sync_types.pose_bone) {
- soops->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_POSE_BONE;
+ space_outliner->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_POSE_BONE;
}
if (sync_types.sequence) {
- soops->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_SEQUENCE;
+ space_outliner->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_SEQUENCE;
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
}
}
@@ -491,7 +493,7 @@ typedef struct SyncSelectActiveData {
/** Sync select and active flags from active view layer, bones, and sequences to the outliner. */
static void outliner_sync_selection_to_outliner(ViewLayer *view_layer,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
ListBase *tree,
SyncSelectActiveData *active_data,
const SyncSelectTypes *sync_types)
@@ -524,7 +526,8 @@ static void outliner_sync_selection_to_outliner(ViewLayer *view_layer,
}
/* Sync subtree elements */
- outliner_sync_selection_to_outliner(view_layer, soops, &te->subtree, active_data, sync_types);
+ outliner_sync_selection_to_outliner(
+ view_layer, space_outliner, &te->subtree, active_data, sync_types);
}
}
@@ -540,11 +543,12 @@ static void get_sync_select_active_data(const bContext *C, SyncSelectActiveData
}
/* If outliner is dirty sync selection from view layer and sequwncer */
-void outliner_sync_selection(const bContext *C, SpaceOutliner *soops)
+void outliner_sync_selection(const bContext *C, SpaceOutliner *space_outliner)
{
/* Set which types of data to sync from sync dirty flag and outliner display mode */
SyncSelectTypes sync_types;
- const bool sync_required = outliner_sync_select_to_outliner_set_types(C, soops, &sync_types);
+ const bool sync_required = outliner_sync_select_to_outliner_set_types(
+ C, space_outliner, &sync_types);
if (sync_required) {
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -554,20 +558,20 @@ void outliner_sync_selection(const bContext *C, SpaceOutliner *soops)
get_sync_select_active_data(C, &active_data);
outliner_sync_selection_to_outliner(
- view_layer, soops, &soops->tree, &active_data, &sync_types);
+ view_layer, space_outliner, &space_outliner->tree, &active_data, &sync_types);
/* Keep any unsynced data in the dirty flag */
if (sync_types.object) {
- soops->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_OBJECT;
+ space_outliner->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_OBJECT;
}
if (sync_types.edit_bone) {
- soops->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_EDIT_BONE;
+ space_outliner->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_EDIT_BONE;
}
if (sync_types.pose_bone) {
- soops->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_POSE_BONE;
+ space_outliner->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_POSE_BONE;
}
if (sync_types.sequence) {
- soops->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_SEQUENCE;
+ space_outliner->sync_select_dirty &= ~WM_OUTLINER_SYNC_SELECT_FROM_SEQUENCE;
}
}
}
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index dae2ba32f09..6532ff189b5 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -95,7 +95,7 @@
/** \name ID/Library/Data Set/Un-link Utilities
* \{ */
-static void set_operation_types(SpaceOutliner *soops,
+static void set_operation_types(SpaceOutliner *space_outliner,
ListBase *lb,
int *scenelevel,
int *objectlevel,
@@ -192,13 +192,14 @@ static void set_operation_types(SpaceOutliner *soops,
}
}
}
- if (TSELEM_OPEN(tselem, soops)) {
- set_operation_types(soops, &te->subtree, scenelevel, objectlevel, idlevel, datalevel);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ set_operation_types(
+ space_outliner, &te->subtree, scenelevel, objectlevel, idlevel, datalevel);
}
}
}
-static void unlink_action_cb(bContext *C,
+static void unlink_action_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -210,7 +211,7 @@ static void unlink_action_cb(bContext *C,
BKE_animdata_set_action(CTX_wm_reports(C), tsep->id, NULL);
}
-static void unlink_material_cb(bContext *UNUSED(C),
+static void unlink_material_fn(bContext *UNUSED(C),
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *te,
@@ -270,7 +271,7 @@ static void unlink_material_cb(bContext *UNUSED(C),
}
}
-static void unlink_texture_cb(bContext *UNUSED(C),
+static void unlink_texture_fn(bContext *UNUSED(C),
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *te,
@@ -299,7 +300,7 @@ static void unlink_texture_cb(bContext *UNUSED(C),
}
}
-static void unlink_collection_cb(bContext *C,
+static void unlink_collection_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -335,7 +336,7 @@ static void unlink_collection_cb(bContext *C,
}
}
-static void unlink_object_cb(bContext *C,
+static void unlink_object_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *te,
@@ -374,7 +375,7 @@ static void unlink_object_cb(bContext *C,
}
}
-static void unlink_world_cb(bContext *UNUSED(C),
+static void unlink_world_fn(bContext *UNUSED(C),
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -393,9 +394,9 @@ static void unlink_world_cb(bContext *UNUSED(C),
static void outliner_do_libdata_operation(bContext *C,
ReportList *reports,
Scene *scene,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
ListBase *lb,
- outliner_operation_cb operation_cb,
+ outliner_operation_fn operation_fn,
void *user_data)
{
TreeElement *te;
@@ -406,12 +407,12 @@ static void outliner_do_libdata_operation(bContext *C,
if (tselem->flag & TSE_SELECTED) {
if (ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) {
TreeStoreElem *tsep = te->parent ? TREESTORE(te->parent) : NULL;
- operation_cb(C, reports, scene, te, tsep, tselem, user_data);
+ operation_fn(C, reports, scene, te, tsep, tselem, user_data);
}
}
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
outliner_do_libdata_operation(
- C, reports, scene, soops, &te->subtree, operation_cb, user_data);
+ C, reports, scene, space_outliner, &te->subtree, operation_fn, user_data);
}
}
}
@@ -435,7 +436,7 @@ static bool outliner_do_scene_operation(
bContext *C,
eOutliner_PropSceneOps event,
ListBase *lb,
- bool (*operation_cb)(bContext *, eOutliner_PropSceneOps, TreeElement *, TreeStoreElem *))
+ bool (*operation_fn)(bContext *, eOutliner_PropSceneOps, TreeElement *, TreeStoreElem *))
{
TreeElement *te;
TreeStoreElem *tselem;
@@ -444,7 +445,7 @@ static bool outliner_do_scene_operation(
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
if (tselem->flag & TSE_SELECTED) {
- if (operation_cb(C, event, te, tselem)) {
+ if (operation_fn(C, event, te, tselem)) {
success = true;
}
}
@@ -453,7 +454,7 @@ static bool outliner_do_scene_operation(
return success;
}
-static bool scene_cb(bContext *C,
+static bool scene_fn(bContext *C,
eOutliner_PropSceneOps event,
TreeElement *UNUSED(te),
TreeStoreElem *tselem)
@@ -474,15 +475,15 @@ static bool scene_cb(bContext *C,
static int outliner_scene_operation_exec(bContext *C, wmOperator *op)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
const eOutliner_PropSceneOps event = RNA_enum_get(op->ptr, "type");
- if (outliner_do_scene_operation(C, event, &soops->tree, scene_cb) == false) {
+ if (outliner_do_scene_operation(C, event, &space_outliner->tree, scene_fn) == false) {
return OPERATOR_CANCELLED;
}
if (event == OL_SCENE_OP_DELETE) {
- outliner_cleanup_tree(soops);
+ outliner_cleanup_tree(space_outliner);
ED_undo_push(C, "Delete Scene(s)");
}
else {
@@ -526,7 +527,7 @@ typedef struct MergedSearchData {
TreeElement *select_element;
} MergedSearchData;
-static void merged_element_search_cb_recursive(
+static void merged_element_search_fn_recursive(
const ListBase *tree, short tselem_type, short type, const char *str, uiSearchItems *items)
{
char name[64];
@@ -550,7 +551,7 @@ static void merged_element_search_cb_recursive(
}
}
- merged_element_search_cb_recursive(&te->subtree, tselem_type, type, str, items);
+ merged_element_search_fn_recursive(&te->subtree, tselem_type, type, str, items);
}
}
@@ -566,18 +567,18 @@ static void merged_element_search_update_fn(const bContext *UNUSED(C),
int type = tree_element_id_type_to_index(te);
- merged_element_search_cb_recursive(&parent->subtree, TREESTORE(te)->type, type, str, items);
+ merged_element_search_fn_recursive(&parent->subtree, TREESTORE(te)->type, type, str, items);
}
/* Activate an element from the merged element search menu */
static void merged_element_search_exec_fn(struct bContext *C, void *UNUSED(arg1), void *element)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
TreeElement *te = (TreeElement *)element;
- outliner_item_select(C, soops, te, OL_ITEM_SELECT | OL_ITEM_ACTIVATE);
+ outliner_item_select(C, space_outliner, te, OL_ITEM_SELECT | OL_ITEM_ACTIVATE);
- ED_outliner_select_sync_from_outliner(C, soops);
+ ED_outliner_select_sync_from_outliner(C, space_outliner);
}
/**
@@ -637,7 +638,7 @@ void merged_element_search_menu_invoke(bContext *C,
UI_popup_block_invoke(C, merged_element_search_menu, select_data, MEM_freeN);
}
-static void object_select_cb(bContext *C,
+static void object_select_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -660,7 +661,7 @@ static void object_select_cb(bContext *C,
/** \name Callbacks (Selection, Users & Library) Utilities
* \{ */
-static void object_select_hierarchy_cb(bContext *C,
+static void object_select_hierarchy_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *te,
@@ -670,11 +671,12 @@ static void object_select_hierarchy_cb(bContext *C,
{
/* Don't extend because this toggles, which is nice for Ctrl-Click but not for a menu item.
* it's especially confusing when multiple items are selected since some toggle on/off. */
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
- outliner_item_select(C, soops, te, OL_ITEM_SELECT | OL_ITEM_ACTIVATE | OL_ITEM_RECURSIVE);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+ outliner_item_select(
+ C, space_outliner, te, OL_ITEM_SELECT | OL_ITEM_ACTIVATE | OL_ITEM_RECURSIVE);
}
-static void object_deselect_cb(bContext *C,
+static void object_deselect_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -719,7 +721,7 @@ static void outliner_object_delete_fn(bContext *C, ReportList *reports, Scene *s
}
}
-static void id_local_cb(bContext *C,
+static void id_local_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -744,7 +746,7 @@ typedef struct OutlinerLibOverrideData {
bool do_hierarchy;
} OutlinerLibOverrideData;
-static void id_override_library_create_cb(bContext *C,
+static void id_override_library_create_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *te,
@@ -797,7 +799,7 @@ static void id_override_library_create_cb(bContext *C,
}
}
-static void id_override_library_reset_cb(bContext *C,
+static void id_override_library_reset_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -825,7 +827,7 @@ static void id_override_library_reset_cb(bContext *C,
}
}
-static void id_fake_user_set_cb(bContext *UNUSED(C),
+static void id_fake_user_set_fn(bContext *UNUSED(C),
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -838,7 +840,7 @@ static void id_fake_user_set_cb(bContext *UNUSED(C),
id_fake_user_set(id);
}
-static void id_fake_user_clear_cb(bContext *UNUSED(C),
+static void id_fake_user_clear_fn(bContext *UNUSED(C),
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -851,7 +853,7 @@ static void id_fake_user_clear_cb(bContext *UNUSED(C),
id_fake_user_clear(id);
}
-static void id_select_linked_cb(bContext *C,
+static void id_select_linked_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -864,7 +866,7 @@ static void id_select_linked_cb(bContext *C,
ED_object_select_linked_by_id(C, id);
}
-static void singleuser_action_cb(bContext *C,
+static void singleuser_action_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *te,
@@ -892,7 +894,7 @@ static void singleuser_action_cb(bContext *C,
}
}
-static void singleuser_world_cb(bContext *C,
+static void singleuser_world_fn(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
@@ -922,9 +924,9 @@ static void singleuser_world_cb(bContext *C,
void outliner_do_object_operation_ex(bContext *C,
ReportList *reports,
Scene *scene_act,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
ListBase *lb,
- outliner_operation_cb operation_cb,
+ outliner_operation_fn operation_fn,
void *user_data,
bool select_recurse)
{
@@ -942,15 +944,21 @@ void outliner_do_object_operation_ex(bContext *C,
/* Important to use 'scene_owner' not scene_act else deleting objects can crash.
* only use 'scene_act' when 'scene_owner' is NULL, which can happen when the
* outliner isn't showing scenes: Visible Layer draw mode for eg. */
- operation_cb(
+ operation_fn(
C, reports, scene_owner ? scene_owner : scene_act, te, NULL, tselem, user_data);
select_handled = true;
}
}
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
if ((select_handled == false) || select_recurse) {
- outliner_do_object_operation_ex(
- C, reports, scene_act, soops, &te->subtree, operation_cb, NULL, select_recurse);
+ outliner_do_object_operation_ex(C,
+ reports,
+ scene_act,
+ space_outliner,
+ &te->subtree,
+ operation_fn,
+ NULL,
+ select_recurse);
}
}
}
@@ -959,11 +967,12 @@ void outliner_do_object_operation_ex(bContext *C,
void outliner_do_object_operation(bContext *C,
ReportList *reports,
Scene *scene_act,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
ListBase *lb,
- outliner_operation_cb operation_cb)
+ outliner_operation_fn operation_fn)
{
- outliner_do_object_operation_ex(C, reports, scene_act, soops, lb, operation_cb, NULL, true);
+ outliner_do_object_operation_ex(
+ C, reports, scene_act, space_outliner, lb, operation_fn, NULL, true);
}
/** \} */
@@ -972,7 +981,7 @@ void outliner_do_object_operation(bContext *C,
/** \name Internal Tagging Utilities
* \{ */
-static void clear_animdata_cb(int UNUSED(event),
+static void clear_animdata_fn(int UNUSED(event),
TreeElement *UNUSED(te),
TreeStoreElem *tselem,
void *UNUSED(arg))
@@ -981,7 +990,7 @@ static void clear_animdata_cb(int UNUSED(event),
DEG_id_tag_update(tselem->id, ID_RECALC_ANIMATION);
}
-static void unlinkact_animdata_cb(int UNUSED(event),
+static void unlinkact_animdata_fn(int UNUSED(event),
TreeElement *UNUSED(te),
TreeStoreElem *tselem,
void *UNUSED(arg))
@@ -991,7 +1000,7 @@ static void unlinkact_animdata_cb(int UNUSED(event),
DEG_id_tag_update(tselem->id, ID_RECALC_ANIMATION);
}
-static void cleardrivers_animdata_cb(int UNUSED(event),
+static void cleardrivers_animdata_fn(int UNUSED(event),
TreeElement *UNUSED(te),
TreeStoreElem *tselem,
void *UNUSED(arg))
@@ -1003,7 +1012,7 @@ static void cleardrivers_animdata_cb(int UNUSED(event),
DEG_id_tag_update(tselem->id, ID_RECALC_ANIMATION);
}
-static void refreshdrivers_animdata_cb(int UNUSED(event),
+static void refreshdrivers_animdata_fn(int UNUSED(event),
TreeElement *UNUSED(te),
TreeStoreElem *tselem,
void *UNUSED(arg))
@@ -1048,7 +1057,7 @@ typedef enum eOutliner_PropModifierOps {
OL_MODIFIER_OP_DELETE,
} eOutliner_PropModifierOps;
-static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
+static void pchan_fn(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
{
bPoseChannel *pchan = (bPoseChannel *)te->directdata;
@@ -1067,7 +1076,7 @@ static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem),
}
}
-static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
+static void bone_fn(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
{
Bone *bone = (Bone *)te->directdata;
@@ -1086,7 +1095,7 @@ static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), v
}
}
-static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
+static void ebone_fn(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
{
EditBone *ebone = (EditBone *)te->directdata;
@@ -1105,7 +1114,7 @@ static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem),
}
}
-static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem, void *scene_ptr)
+static void sequence_fn(int event, TreeElement *te, TreeStoreElem *tselem, void *scene_ptr)
{
Sequence *seq = (Sequence *)te->directdata;
if (event == OL_DOP_SELECT) {
@@ -1119,7 +1128,7 @@ static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem, void
(void)tselem;
}
-static void gpencil_layer_cb(int event,
+static void gpencil_layer_fn(int event,
TreeElement *te,
TreeStoreElem *UNUSED(tselem),
void *UNUSED(arg))
@@ -1140,7 +1149,7 @@ static void gpencil_layer_cb(int event,
}
}
-static void data_select_linked_cb(int event,
+static void data_select_linked_fn(int event,
TreeElement *te,
TreeStoreElem *UNUSED(tselem),
void *C_v)
@@ -1155,7 +1164,7 @@ static void data_select_linked_cb(int event,
}
}
-static void constraint_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *C_v)
+static void constraint_fn(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *C_v)
{
bContext *C = C_v;
Main *bmain = CTX_data_main(C);
@@ -1195,7 +1204,7 @@ static void constraint_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tsel
}
}
-static void modifier_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *Carg)
+static void modifier_fn(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *Carg)
{
bContext *C = (bContext *)Carg;
Main *bmain = CTX_data_main(C);
@@ -1221,11 +1230,11 @@ static void modifier_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem
}
static void outliner_do_data_operation(
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
int type,
int event,
ListBase *lb,
- void (*operation_cb)(int, TreeElement *, TreeStoreElem *, void *),
+ void (*operation_fn)(int, TreeElement *, TreeStoreElem *, void *),
void *arg)
{
TreeElement *te;
@@ -1235,11 +1244,11 @@ static void outliner_do_data_operation(
tselem = TREESTORE(te);
if (tselem->flag & TSE_SELECTED) {
if (tselem->type == type) {
- operation_cb(event, te, tselem, arg);
+ operation_fn(event, te, tselem, arg);
}
}
- if (TSELEM_OPEN(tselem, soops)) {
- outliner_do_data_operation(soops, type, event, &te->subtree, operation_cb, arg);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ outliner_do_data_operation(space_outliner, type, event, &te->subtree, operation_fn, arg);
}
}
}
@@ -1359,13 +1368,13 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
wmWindow *win = CTX_wm_window(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int event;
const char *str = NULL;
bool selection_changed = false;
/* check for invalid states */
- if (soops == NULL) {
+ if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
@@ -1373,7 +1382,8 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
if (event == OL_OP_SELECT) {
Scene *sce = scene; /* To be able to delete, scenes are set... */
- outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_select_cb);
+ outliner_do_object_operation(
+ C, op->reports, scene, space_outliner, &space_outliner->tree, object_select_fn);
if (scene != sce) {
WM_window_set_active_scene(bmain, C, win, sce);
}
@@ -1383,8 +1393,14 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
}
else if (event == OL_OP_SELECT_HIERARCHY) {
Scene *sce = scene; /* To be able to delete, scenes are set... */
- outliner_do_object_operation_ex(
- C, op->reports, scene, soops, &soops->tree, object_select_hierarchy_cb, NULL, false);
+ outliner_do_object_operation_ex(C,
+ op->reports,
+ scene,
+ space_outliner,
+ &space_outliner->tree,
+ object_select_hierarchy_fn,
+ NULL,
+ false);
if (scene != sce) {
WM_window_set_active_scene(bmain, C, win, sce);
}
@@ -1392,31 +1408,35 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
selection_changed = true;
}
else if (event == OL_OP_DESELECT) {
- outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_deselect_cb);
+ outliner_do_object_operation(
+ C, op->reports, scene, space_outliner, &space_outliner->tree, object_deselect_fn);
str = "Deselect Objects";
selection_changed = true;
}
else if (event == OL_OP_REMAP) {
- outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_remap_cb, NULL);
+ outliner_do_libdata_operation(
+ C, op->reports, scene, space_outliner, &space_outliner->tree, id_remap_fn, NULL);
/* No undo push here, operator does it itself (since it's a modal one, the op_undo_depth
* trick does not work here). */
}
else if (event == OL_OP_LOCALIZED) { /* disabled, see above enum (ton) */
- outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, id_local_cb);
+ outliner_do_object_operation(
+ C, op->reports, scene, space_outliner, &space_outliner->tree, id_local_fn);
str = "Localized Objects";
}
else if (event == OL_OP_RENAME) {
- outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, item_rename_cb);
+ outliner_do_object_operation(
+ C, op->reports, scene, space_outliner, &space_outliner->tree, item_rename_fn);
str = "Rename Object";
}
else if (event == OL_OP_OBJECT_MODE_ENTER) {
outliner_do_object_operation(
- C, op->reports, scene, soops, &soops->tree, item_object_mode_enter_cb);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, item_object_mode_enter_fn);
str = "Enter Current Mode";
}
else if (event == OL_OP_OBJECT_MODE_EXIT) {
outliner_do_object_operation(
- C, op->reports, scene, soops, &soops->tree, item_object_mode_exit_cb);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, item_object_mode_exit_fn);
str = "Exit Current Mode";
}
else {
@@ -1497,7 +1517,7 @@ static int outliner_delete_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
const Base *basact_prev = BASACT(view_layer);
@@ -1507,8 +1527,12 @@ static int outliner_delete_exec(bContext *C, wmOperator *op)
/* Get selected objects skipping duplicates to prevent deleting objects linked to multiple
* collections twice */
GSet *objects_to_delete = BLI_gset_ptr_new(__func__);
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, outliner_find_objects_to_delete, objects_to_delete);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
+ outliner_find_objects_to_delete,
+ objects_to_delete);
if (delete_hierarchy) {
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
@@ -1531,7 +1555,7 @@ static int outliner_delete_exec(bContext *C, wmOperator *op)
* outliner several mouse events can be handled in one cycle without
* handling notifiers/redraw which leads to deleting the same object twice.
* cleanup tree here to prevent such cases. */
- outliner_cleanup_tree(soops);
+ outliner_cleanup_tree(space_outliner);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
@@ -1650,7 +1674,7 @@ static bool outliner_id_operation_item_poll(bContext *C,
PropertyRNA *UNUSED(prop),
const int enum_value)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
switch (enum_value) {
case OUTLINER_IDOP_OVERRIDE_LIBRARY_CREATE:
@@ -1660,7 +1684,7 @@ static bool outliner_id_operation_item_poll(bContext *C,
case OUTLINER_IDOP_OVERRIDE_LIBRARY_RESET_HIERARCHY:
return true;
case OUTLINER_IDOP_SINGLE:
- if (!soops || ELEM(soops->outlinevis, SO_SCENES, SO_VIEW_LAYER)) {
+ if (!space_outliner || ELEM(space_outliner->outlinevis, SO_SCENES, SO_VIEW_LAYER)) {
return true;
}
/* TODO (dalai): enable in the few cases where this can be supported
@@ -1698,16 +1722,17 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
{
wmWindowManager *wm = CTX_wm_manager(C);
Scene *scene = CTX_data_scene(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
eOutlinerIdOpTypes event;
/* check for invalid states */
- if (soops == NULL) {
+ if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
- set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ set_operation_types(
+ space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
event = RNA_enum_get(op->ptr, "type");
@@ -1716,7 +1741,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
/* unlink datablock from its parent */
if (objectlevel) {
outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, unlink_object_cb, NULL);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, unlink_object_fn, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, NULL);
ED_undo_push(C, "Unlink Object");
@@ -1725,36 +1750,56 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
switch (idlevel) {
case ID_AC:
- outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, unlink_action_cb, NULL);
+ outliner_do_libdata_operation(C,
+ op->reports,
+ scene,
+ space_outliner,
+ &space_outliner->tree,
+ unlink_action_fn,
+ NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
ED_undo_push(C, "Unlink action");
break;
case ID_MA:
- outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, unlink_material_cb, NULL);
+ outliner_do_libdata_operation(C,
+ op->reports,
+ scene,
+ space_outliner,
+ &space_outliner->tree,
+ unlink_material_fn,
+ NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL);
ED_undo_push(C, "Unlink material");
break;
case ID_TE:
- outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, unlink_texture_cb, NULL);
+ outliner_do_libdata_operation(C,
+ op->reports,
+ scene,
+ space_outliner,
+ &space_outliner->tree,
+ unlink_texture_fn,
+ NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL);
ED_undo_push(C, "Unlink texture");
break;
case ID_WO:
outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, unlink_world_cb, NULL);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, unlink_world_fn, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL);
ED_undo_push(C, "Unlink world");
break;
case ID_GR:
- outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, unlink_collection_cb, NULL);
+ outliner_do_libdata_operation(C,
+ op->reports,
+ scene,
+ space_outliner,
+ &space_outliner->tree,
+ unlink_collection_fn,
+ NULL);
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, NULL);
ED_undo_push(C, "Unlink Collection");
@@ -1767,7 +1812,8 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
}
case OUTLINER_IDOP_LOCAL: {
/* make local */
- outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_local_cb, NULL);
+ outliner_do_libdata_operation(
+ C, op->reports, scene, space_outliner, &space_outliner->tree, id_local_fn, NULL);
ED_undo_push(C, "Localized Data");
break;
}
@@ -1776,9 +1822,9 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
outliner_do_libdata_operation(C,
op->reports,
scene,
- soops,
- &soops->tree,
- id_override_library_create_cb,
+ space_outliner,
+ &space_outliner->tree,
+ id_override_library_create_fn,
&(OutlinerLibOverrideData){.do_hierarchy = false});
ED_undo_push(C, "Overridden Data");
break;
@@ -1788,9 +1834,9 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
outliner_do_libdata_operation(C,
op->reports,
scene,
- soops,
- &soops->tree,
- id_override_library_create_cb,
+ space_outliner,
+ &space_outliner->tree,
+ id_override_library_create_fn,
&(OutlinerLibOverrideData){.do_hierarchy = true});
ED_undo_push(C, "Overridden Data Hierarchy");
break;
@@ -1800,9 +1846,9 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
outliner_do_libdata_operation(C,
op->reports,
scene,
- soops,
- &soops->tree,
- id_override_library_reset_cb,
+ space_outliner,
+ &space_outliner->tree,
+ id_override_library_reset_fn,
&(OutlinerLibOverrideData){.do_hierarchy = false});
ED_undo_push(C, "Reset Overridden Data");
break;
@@ -1812,9 +1858,9 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
outliner_do_libdata_operation(C,
op->reports,
scene,
- soops,
- &soops->tree,
- id_override_library_reset_cb,
+ space_outliner,
+ &space_outliner->tree,
+ id_override_library_reset_fn,
&(OutlinerLibOverrideData){.do_hierarchy = true});
ED_undo_push(C, "Reset Overridden Data Hierarchy");
break;
@@ -1823,16 +1869,26 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
/* make single user */
switch (idlevel) {
case ID_AC:
- outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, singleuser_action_cb, NULL);
+ outliner_do_libdata_operation(C,
+ op->reports,
+ scene,
+ space_outliner,
+ &space_outliner->tree,
+ singleuser_action_fn,
+ NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
ED_undo_push(C, "Single-User Action");
break;
case ID_WO:
- outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, singleuser_world_cb, NULL);
+ outliner_do_libdata_operation(C,
+ op->reports,
+ scene,
+ space_outliner,
+ &space_outliner->tree,
+ singleuser_world_fn,
+ NULL);
WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL);
ED_undo_push(C, "Single-User World");
@@ -1847,7 +1903,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
case OUTLINER_IDOP_DELETE: {
if (idlevel > 0) {
outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, id_delete_cb, NULL);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, id_delete_fn, NULL);
ED_undo_push(C, "Delete");
}
break;
@@ -1855,7 +1911,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
case OUTLINER_IDOP_REMAP: {
if (idlevel > 0) {
outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, id_remap_cb, NULL);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, id_remap_fn, NULL);
/* No undo push here, operator does it itself (since it's a modal one, the op_undo_depth
* trick does not work here). */
}
@@ -1879,7 +1935,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
case OUTLINER_IDOP_FAKE_ADD: {
/* set fake user */
outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, id_fake_user_set_cb, NULL);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, id_fake_user_set_fn, NULL);
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
ED_undo_push(C, "Add Fake User");
@@ -1887,8 +1943,13 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
}
case OUTLINER_IDOP_FAKE_CLEAR: {
/* clear fake user */
- outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, id_fake_user_clear_cb, NULL);
+ outliner_do_libdata_operation(C,
+ op->reports,
+ scene,
+ space_outliner,
+ &space_outliner->tree,
+ id_fake_user_clear_fn,
+ NULL);
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
ED_undo_push(C, "Clear Fake User");
@@ -1897,7 +1958,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
case OUTLINER_IDOP_RENAME: {
/* rename */
outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, item_rename_cb, NULL);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, item_rename_fn, NULL);
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
ED_undo_push(C, "Rename");
@@ -1905,7 +1966,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
}
case OUTLINER_IDOP_SELECT_LINKED:
outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, id_select_linked_cb, NULL);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, id_select_linked_fn, NULL);
ED_outliner_select_sync_from_all_tag(C);
ED_undo_push(C, "Select");
break;
@@ -1975,23 +2036,24 @@ static const EnumPropertyItem outliner_lib_op_type_items[] = {
static int outliner_lib_operation_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
eOutlinerLibOpTypes event;
/* check for invalid states */
- if (soops == NULL) {
+ if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
- set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ set_operation_types(
+ space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
event = RNA_enum_get(op->ptr, "type");
switch (event) {
case OL_LIB_RENAME: {
outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, item_rename_cb, NULL);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, item_rename_fn, NULL);
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
ED_undo_push(C, "Rename Library");
@@ -1999,20 +2061,20 @@ static int outliner_lib_operation_exec(bContext *C, wmOperator *op)
}
case OL_LIB_DELETE: {
outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, id_delete_cb, NULL);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, id_delete_fn, NULL);
ED_undo_push(C, "Delete Library");
break;
}
case OL_LIB_RELOCATE: {
outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, lib_relocate_cb, NULL);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, lib_relocate_fn, NULL);
/* No undo push here, operator does it itself (since it's a modal one, the op_undo_depth
* trick does not work here). */
break;
}
case OL_LIB_RELOAD: {
outliner_do_libdata_operation(
- C, op->reports, scene, soops, &soops->tree, lib_reload_cb, NULL);
+ C, op->reports, scene, space_outliner, &space_outliner->tree, lib_reload_fn, NULL);
/* No undo push here, operator does it itself (since it's a modal one, the op_undo_depth
* trick does not work here). */
break;
@@ -2053,11 +2115,11 @@ void OUTLINER_OT_lib_operation(wmOperatorType *ot)
* \{ */
static void outliner_do_id_set_operation(
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
int type,
ListBase *lb,
ID *newid,
- void (*operation_cb)(TreeElement *, TreeStoreElem *, TreeStoreElem *, ID *))
+ void (*operation_fn)(TreeElement *, TreeStoreElem *, TreeStoreElem *, ID *))
{
TreeElement *te;
TreeStoreElem *tselem;
@@ -2067,16 +2129,16 @@ static void outliner_do_id_set_operation(
if (tselem->flag & TSE_SELECTED) {
if (tselem->type == type) {
TreeStoreElem *tsep = te->parent ? TREESTORE(te->parent) : NULL;
- operation_cb(te, tselem, tsep, newid);
+ operation_fn(te, tselem, tsep, newid);
}
}
- if (TSELEM_OPEN(tselem, soops)) {
- outliner_do_id_set_operation(soops, type, &te->subtree, newid, operation_cb);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ outliner_do_id_set_operation(space_outliner, type, &te->subtree, newid, operation_fn);
}
}
}
-static void actionset_id_cb(TreeElement *UNUSED(te),
+static void actionset_id_fn(TreeElement *UNUSED(te),
TreeStoreElem *tselem,
TreeStoreElem *tsep,
ID *actId)
@@ -2100,16 +2162,17 @@ static void actionset_id_cb(TreeElement *UNUSED(te),
static int outliner_action_set_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
bAction *act;
/* check for invalid states */
- if (soops == NULL) {
+ if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
- set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ set_operation_types(
+ space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
/* get action to use */
act = BLI_findlink(&bmain->actions, RNA_enum_get(op->ptr, "action"));
@@ -2131,10 +2194,12 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
/* perform action if valid channel */
if (datalevel == TSE_ANIM_DATA) {
- outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID *)act, actionset_id_cb);
+ outliner_do_id_set_operation(
+ space_outliner, datalevel, &space_outliner->tree, (ID *)act, actionset_id_fn);
}
else if (idlevel == ID_AC) {
- outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID *)act, actionset_id_cb);
+ outliner_do_id_set_operation(
+ space_outliner, idlevel, &space_outliner->tree, (ID *)act, actionset_id_fn);
}
else {
return OPERATOR_CANCELLED;
@@ -2212,17 +2277,18 @@ static const EnumPropertyItem prop_animdata_op_types[] = {
static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
{
wmWindowManager *wm = CTX_wm_manager(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
eOutliner_AnimDataOps event;
/* check for invalid states */
- if (soops == NULL) {
+ if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
event = RNA_enum_get(op->ptr, "type");
- set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ set_operation_types(
+ space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
if (datalevel != TSE_ANIM_DATA) {
return OPERATOR_CANCELLED;
@@ -2232,7 +2298,8 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
switch (event) {
case OUTLINER_ANIMOP_CLEAR_ADT:
/* Remove Animation Data - this may remove the active action, in some cases... */
- outliner_do_data_operation(soops, datalevel, event, &soops->tree, clear_animdata_cb, NULL);
+ outliner_do_data_operation(
+ space_outliner, datalevel, event, &space_outliner->tree, clear_animdata_fn, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
ED_undo_push(C, "Clear Animation Data");
@@ -2249,15 +2316,19 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
case OUTLINER_ANIMOP_CLEAR_ACT:
/* clear active action - using standard rules */
outliner_do_data_operation(
- soops, datalevel, event, &soops->tree, unlinkact_animdata_cb, NULL);
+ space_outliner, datalevel, event, &space_outliner->tree, unlinkact_animdata_fn, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
ED_undo_push(C, "Unlink action");
break;
case OUTLINER_ANIMOP_REFRESH_DRV:
- outliner_do_data_operation(
- soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb, NULL);
+ outliner_do_data_operation(space_outliner,
+ datalevel,
+ event,
+ &space_outliner->tree,
+ refreshdrivers_animdata_fn,
+ NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL);
/* ED_undo_push(C, "Refresh Drivers"); No undo needed - shouldn't have any impact? */
@@ -2265,7 +2336,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
case OUTLINER_ANIMOP_CLEAR_DRV:
outliner_do_data_operation(
- soops, datalevel, event, &soops->tree, cleardrivers_animdata_cb, NULL);
+ space_outliner, datalevel, event, &space_outliner->tree, cleardrivers_animdata_fn, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL);
ED_undo_push(C, "Clear Drivers");
@@ -2312,17 +2383,19 @@ static const EnumPropertyItem prop_constraint_op_types[] = {
static int outliner_constraint_operation_exec(bContext *C, wmOperator *op)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
eOutliner_PropConstraintOps event;
event = RNA_enum_get(op->ptr, "type");
- set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ set_operation_types(
+ space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
- outliner_do_data_operation(soops, datalevel, event, &soops->tree, constraint_cb, C);
+ outliner_do_data_operation(
+ space_outliner, datalevel, event, &space_outliner->tree, constraint_fn, C);
if (event == OL_CONSTRAINTOP_DELETE) {
- outliner_cleanup_tree(soops);
+ outliner_cleanup_tree(space_outliner);
}
ED_undo_push(C, "Constraint operation");
@@ -2362,17 +2435,19 @@ static const EnumPropertyItem prop_modifier_op_types[] = {
static int outliner_modifier_operation_exec(bContext *C, wmOperator *op)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
eOutliner_PropModifierOps event;
event = RNA_enum_get(op->ptr, "type");
- set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ set_operation_types(
+ space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
- outliner_do_data_operation(soops, datalevel, event, &soops->tree, modifier_cb, C);
+ outliner_do_data_operation(
+ space_outliner, datalevel, event, &space_outliner->tree, modifier_fn, C);
if (event == OL_MODIFIER_OP_DELETE) {
- outliner_cleanup_tree(soops);
+ outliner_cleanup_tree(space_outliner);
}
ED_undo_push(C, "Modifier operation");
@@ -2414,35 +2489,39 @@ static const EnumPropertyItem prop_data_op_types[] = {
static int outliner_data_operation_exec(bContext *C, wmOperator *op)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
eOutliner_PropDataOps event;
/* check for invalid states */
- if (soops == NULL) {
+ if (space_outliner == NULL) {
return OPERATOR_CANCELLED;
}
event = RNA_enum_get(op->ptr, "type");
- set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ set_operation_types(
+ space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
switch (datalevel) {
case TSE_POSE_CHANNEL: {
- outliner_do_data_operation(soops, datalevel, event, &soops->tree, pchan_cb, NULL);
+ outliner_do_data_operation(
+ space_outliner, datalevel, event, &space_outliner->tree, pchan_fn, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
ED_undo_push(C, "PoseChannel operation");
break;
}
case TSE_BONE: {
- outliner_do_data_operation(soops, datalevel, event, &soops->tree, bone_cb, NULL);
+ outliner_do_data_operation(
+ space_outliner, datalevel, event, &space_outliner->tree, bone_fn, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
ED_undo_push(C, "Bone operation");
break;
}
case TSE_EBONE: {
- outliner_do_data_operation(soops, datalevel, event, &soops->tree, ebone_cb, NULL);
+ outliner_do_data_operation(
+ space_outliner, datalevel, event, &space_outliner->tree, ebone_fn, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
ED_undo_push(C, "EditBone operation");
@@ -2450,12 +2529,14 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op)
}
case TSE_SEQUENCE: {
Scene *scene = CTX_data_scene(C);
- outliner_do_data_operation(soops, datalevel, event, &soops->tree, sequence_cb, scene);
+ outliner_do_data_operation(
+ space_outliner, datalevel, event, &space_outliner->tree, sequence_fn, scene);
break;
}
case TSE_GP_LAYER: {
- outliner_do_data_operation(soops, datalevel, event, &soops->tree, gpencil_layer_cb, NULL);
+ outliner_do_data_operation(
+ space_outliner, datalevel, event, &space_outliner->tree, gpencil_layer_fn, NULL);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL);
ED_undo_push(C, "Grease Pencil Layer operation");
@@ -2464,7 +2545,7 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op)
case TSE_RNA_STRUCT:
if (event == OL_DOP_SELECT_LINKED) {
outliner_do_data_operation(
- soops, datalevel, event, &soops->tree, data_select_linked_cb, C);
+ space_outliner, datalevel, event, &space_outliner->tree, data_select_linked_fn, C);
}
break;
@@ -2518,8 +2599,11 @@ static int outliner_operator_menu(bContext *C, const char *opname)
return OPERATOR_INTERFACE;
}
-static int do_outliner_operation_event(
- bContext *C, ARegion *region, SpaceOutliner *soops, TreeElement *te, const float mval[2])
+static int do_outliner_operation_event(bContext *C,
+ ARegion *region,
+ SpaceOutliner *space_outliner,
+ TreeElement *te,
+ const float mval[2])
{
ReportList *reports = CTX_wm_reports(C); /* XXX... */
@@ -2530,8 +2614,8 @@ static int do_outliner_operation_event(
/* select object that's clicked on and popup context menu */
if (!(tselem->flag & TSE_SELECTED)) {
- if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1)) {
- outliner_flag_set(&soops->tree, TSE_SELECTED, 0);
+ if (outliner_flag_is_any_test(&space_outliner->tree, TSE_SELECTED, 1)) {
+ outliner_flag_set(&space_outliner->tree, TSE_SELECTED, 0);
}
tselem->flag |= TSE_SELECTED;
@@ -2539,10 +2623,11 @@ static int do_outliner_operation_event(
/* Only redraw, don't rebuild here because TreeElement pointers will
* become invalid and operations will crash. */
ED_region_tag_redraw_no_rebuild(region);
- ED_outliner_select_sync_from_outliner(C, soops);
+ ED_outliner_select_sync_from_outliner(C, space_outliner);
}
- set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+ set_operation_types(
+ space_outliner, &space_outliner->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
if (scenelevel) {
if (objectlevel || datalevel || idlevel) {
@@ -2611,7 +2696,7 @@ static int do_outliner_operation_event(
}
for (te = te->subtree.first; te; te = te->next) {
- int retval = do_outliner_operation_event(C, region, soops, te, mval);
+ int retval = do_outliner_operation_event(C, region, space_outliner, te, mval);
if (retval) {
return retval;
}
@@ -2623,7 +2708,7 @@ static int do_outliner_operation_event(
static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
uiBut *but = UI_context_active_but_get(C);
TreeElement *te;
float fmval[2];
@@ -2634,8 +2719,8 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
- for (te = soops->tree.first; te; te = te->next) {
- int retval = do_outliner_operation_event(C, region, soops, te, fmval);
+ for (te = space_outliner->tree.first; te; te = te->next) {
+ int retval = do_outliner_operation_event(C, region, space_outliner, te, fmval);
if (retval) {
return retval;
}
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 09dc1320c3a..60058c82283 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -88,7 +88,7 @@
#endif
/* prototypes */
-static TreeElement *outliner_add_collection_recursive(SpaceOutliner *soops,
+static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
Collection *collection,
TreeElement *ten);
static void outliner_make_object_parent_hierarchy(ListBase *lb);
@@ -96,9 +96,9 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb);
/* ********************************************************* */
/* Persistent Data */
-static void outliner_storage_cleanup(SpaceOutliner *soops)
+static void outliner_storage_cleanup(SpaceOutliner *space_outliner)
{
- BLI_mempool *ts = soops->treestore;
+ BLI_mempool *ts = space_outliner->treestore;
if (ts) {
TreeStoreElem *tselem;
@@ -114,8 +114,8 @@ static void outliner_storage_cleanup(SpaceOutliner *soops)
/* cleanup only after reading file or undo step, and always for
* RNA data-blocks view in order to save memory */
- if (soops->storeflag & SO_TREESTORE_CLEANUP) {
- soops->storeflag &= ~SO_TREESTORE_CLEANUP;
+ if (space_outliner->storeflag & SO_TREESTORE_CLEANUP) {
+ space_outliner->storeflag &= ~SO_TREESTORE_CLEANUP;
BLI_mempool_iternew(ts, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
@@ -127,10 +127,10 @@ static void outliner_storage_cleanup(SpaceOutliner *soops)
if (unused) {
if (BLI_mempool_len(ts) == unused) {
BLI_mempool_destroy(ts);
- soops->treestore = NULL;
- if (soops->treehash) {
- BKE_outliner_treehash_free(soops->treehash);
- soops->treehash = NULL;
+ space_outliner->treestore = NULL;
+ if (space_outliner->treehash) {
+ BKE_outliner_treehash_free(space_outliner->treehash);
+ space_outliner->treehash = NULL;
}
}
else {
@@ -145,35 +145,39 @@ static void outliner_storage_cleanup(SpaceOutliner *soops)
}
}
BLI_mempool_destroy(ts);
- soops->treestore = new_ts;
- if (soops->treehash) {
+ space_outliner->treestore = new_ts;
+ if (space_outliner->treehash) {
/* update hash table to fix broken pointers */
- BKE_outliner_treehash_rebuild_from_treestore(soops->treehash, soops->treestore);
+ BKE_outliner_treehash_rebuild_from_treestore(space_outliner->treehash,
+ space_outliner->treestore);
}
}
}
}
- else if (soops->treehash) {
- BKE_outliner_treehash_clear_used(soops->treehash);
+ else if (space_outliner->treehash) {
+ BKE_outliner_treehash_clear_used(space_outliner->treehash);
}
}
}
-static void check_persistent(SpaceOutliner *soops, TreeElement *te, ID *id, short type, short nr)
+static void check_persistent(
+ SpaceOutliner *space_outliner, TreeElement *te, ID *id, short type, short nr)
{
TreeStoreElem *tselem;
- if (soops->treestore == NULL) {
+ if (space_outliner->treestore == NULL) {
/* if treestore was not created in readfile.c, create it here */
- soops->treestore = BLI_mempool_create(sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
+ space_outliner->treestore = BLI_mempool_create(
+ sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
}
- if (soops->treehash == NULL) {
- soops->treehash = BKE_outliner_treehash_create_from_treestore(soops->treestore);
+ if (space_outliner->treehash == NULL) {
+ space_outliner->treehash = BKE_outliner_treehash_create_from_treestore(
+ space_outliner->treestore);
}
/* find any unused tree element in treestore and mark it as used
* (note that there may be multiple unused elements in case of linked objects) */
- tselem = BKE_outliner_treehash_lookup_unused(soops->treehash, type, nr, id);
+ tselem = BKE_outliner_treehash_lookup_unused(space_outliner->treehash, type, nr, id);
if (tselem) {
te->store_elem = tselem;
tselem->used = 1;
@@ -181,14 +185,14 @@ static void check_persistent(SpaceOutliner *soops, TreeElement *te, ID *id, shor
}
/* add 1 element to treestore */
- tselem = BLI_mempool_alloc(soops->treestore);
+ tselem = BLI_mempool_alloc(space_outliner->treestore);
tselem->type = type;
tselem->nr = type ? nr : 0;
tselem->id = id;
tselem->used = 0;
tselem->flag = TSE_CLOSED;
te->store_elem = tselem;
- BKE_outliner_treehash_add_element(soops->treehash, tselem);
+ BKE_outliner_treehash_add_element(space_outliner->treehash, tselem);
}
/* ********************************************************* */
@@ -202,10 +206,10 @@ void outliner_free_tree(ListBase *tree)
}
}
-void outliner_cleanup_tree(SpaceOutliner *soops)
+void outliner_cleanup_tree(SpaceOutliner *space_outliner)
{
- outliner_free_tree(&soops->tree);
- outliner_storage_cleanup(soops);
+ outliner_free_tree(&space_outliner->tree);
+ outliner_storage_cleanup(space_outliner);
}
/**
@@ -230,8 +234,12 @@ void outliner_free_tree_element(TreeElement *element, ListBase *parent_subtree)
/* ********************************************************* */
/* Prototype, see functions below */
-static TreeElement *outliner_add_element(
- SpaceOutliner *soops, ListBase *lb, void *idv, TreeElement *parent, short type, short index);
+static TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
+ ListBase *lb,
+ void *idv,
+ TreeElement *parent,
+ short type,
+ short index);
/* -------------------------------------------------------- */
@@ -247,17 +255,21 @@ bool outliner_element_needs_rebuild_on_open_change(const TreeStoreElem *tselem)
}
/* special handling of hierarchical non-lib data */
-static void outliner_add_bone(
- SpaceOutliner *soops, ListBase *lb, ID *id, Bone *curBone, TreeElement *parent, int *a)
+static void outliner_add_bone(SpaceOutliner *space_outliner,
+ ListBase *lb,
+ ID *id,
+ Bone *curBone,
+ TreeElement *parent,
+ int *a)
{
- TreeElement *te = outliner_add_element(soops, lb, id, parent, TSE_BONE, *a);
+ TreeElement *te = outliner_add_element(space_outliner, lb, id, parent, TSE_BONE, *a);
(*a)++;
te->name = curBone->name;
te->directdata = curBone;
for (curBone = curBone->childbase.first; curBone; curBone = curBone->next) {
- outliner_add_bone(soops, &te->subtree, id, curBone, te, a);
+ outliner_add_bone(space_outliner, &te->subtree, id, curBone, te, a);
}
}
@@ -270,7 +282,7 @@ static bool outliner_animdata_test(AnimData *adt)
}
#ifdef WITH_FREESTYLE
-static void outliner_add_line_styles(SpaceOutliner *soops,
+static void outliner_add_line_styles(SpaceOutliner *space_outliner,
ListBase *lb,
Scene *sce,
TreeElement *te)
@@ -294,75 +306,81 @@ static void outliner_add_line_styles(SpaceOutliner *soops,
continue;
}
linestyle->id.tag &= ~LIB_TAG_DOIT;
- outliner_add_element(soops, lb, linestyle, te, 0, 0);
+ outliner_add_element(space_outliner, lb, linestyle, te, 0, 0);
}
}
}
}
#endif
-static void outliner_add_scene_contents(SpaceOutliner *soops,
+static void outliner_add_scene_contents(SpaceOutliner *space_outliner,
ListBase *lb,
Scene *sce,
TreeElement *te)
{
/* View layers */
- TreeElement *ten = outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0);
+ TreeElement *ten = outliner_add_element(space_outliner, lb, sce, te, TSE_R_LAYER_BASE, 0);
ten->name = IFACE_("View Layers");
ViewLayer *view_layer;
for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
- TreeElement *tenlay = outliner_add_element(soops, &ten->subtree, sce, ten, TSE_R_LAYER, 0);
+ TreeElement *tenlay = outliner_add_element(
+ space_outliner, &ten->subtree, sce, ten, TSE_R_LAYER, 0);
tenlay->name = view_layer->name;
tenlay->directdata = view_layer;
}
/* World */
- outliner_add_element(soops, lb, sce->world, te, 0, 0);
+ outliner_add_element(space_outliner, lb, sce->world, te, 0, 0);
/* Collections */
- ten = outliner_add_element(soops, lb, &sce->id, te, TSE_SCENE_COLLECTION_BASE, 0);
+ ten = outliner_add_element(space_outliner, lb, &sce->id, te, TSE_SCENE_COLLECTION_BASE, 0);
ten->name = IFACE_("Scene Collection");
- outliner_add_collection_recursive(soops, sce->master_collection, ten);
+ outliner_add_collection_recursive(space_outliner, sce->master_collection, ten);
/* Objects */
- ten = outliner_add_element(soops, lb, sce, te, TSE_SCENE_OBJECTS_BASE, 0);
+ ten = outliner_add_element(space_outliner, lb, sce, te, TSE_SCENE_OBJECTS_BASE, 0);
ten->name = IFACE_("Objects");
FOREACH_SCENE_OBJECT_BEGIN (sce, ob) {
- outliner_add_element(soops, &ten->subtree, ob, ten, 0, 0);
+ outliner_add_element(space_outliner, &ten->subtree, ob, ten, 0, 0);
}
FOREACH_SCENE_OBJECT_END;
outliner_make_object_parent_hierarchy(&ten->subtree);
/* Animation Data */
if (outliner_animdata_test(sce->adt)) {
- outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, lb, sce, te, TSE_ANIM_DATA, 0);
}
}
/* Can be inlined if necessary. */
-static void outliner_add_object_contents(SpaceOutliner *soops,
+static void outliner_add_object_contents(SpaceOutliner *space_outliner,
TreeElement *te,
TreeStoreElem *tselem,
Object *ob)
{
if (outliner_animdata_test(ob->adt)) {
- outliner_add_element(soops, &te->subtree, ob, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, ob, te, TSE_ANIM_DATA, 0);
}
- outliner_add_element(
- soops, &te->subtree, ob->poselib, te, 0, 0); /* XXX FIXME.. add a special type for this. */
+ outliner_add_element(space_outliner,
+ &te->subtree,
+ ob->poselib,
+ te,
+ 0,
+ 0); /* XXX FIXME.. add a special type for this. */
if (ob->proxy && !ID_IS_LINKED(ob)) {
- outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0);
+ outliner_add_element(space_outliner, &te->subtree, ob->proxy, te, TSE_PROXY, 0);
}
- outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0);
+ outliner_add_element(space_outliner, &te->subtree, ob->data, te, 0, 0);
if (ob->pose) {
bArmature *arm = ob->data;
bPoseChannel *pchan;
- TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0);
+ TreeElement *tenla = outliner_add_element(
+ space_outliner, &te->subtree, ob, te, TSE_POSE_BASE, 0);
tenla->name = IFACE_("Pose");
@@ -372,7 +390,8 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
int a = 0, const_index = 1000; /* ensure unique id for bone constraints */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, a++) {
- ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a);
+ ten = outliner_add_element(
+ space_outliner, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a);
ten->name = pchan->name;
ten->directdata = pchan;
pchan->temp = (void *)ten;
@@ -382,13 +401,13 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
bConstraint *con;
TreeElement *ten1;
TreeElement *tenla1 = outliner_add_element(
- soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0);
+ space_outliner, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0);
/* char *str; */
tenla1->name = IFACE_("Constraints");
for (con = pchan->constraints.first; con; con = con->next, const_index++) {
ten1 = outliner_add_element(
- soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index);
+ space_outliner, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index);
#if 0 /* disabled as it needs to be reworked for recoded constraints system */
target = get_constraint_target(con, &str);
if (str && str[0]) {
@@ -429,13 +448,14 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
if (ob->pose->agroups.first) {
bActionGroup *agrp;
TreeElement *ten_bonegrp = outliner_add_element(
- soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0);
+ space_outliner, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0);
int a = 0;
ten_bonegrp->name = IFACE_("Bone Groups");
for (agrp = ob->pose->agroups.first; agrp; agrp = agrp->next, a++) {
TreeElement *ten;
- ten = outliner_add_element(soops, &ten_bonegrp->subtree, ob, ten_bonegrp, TSE_POSEGRP, a);
+ ten = outliner_add_element(
+ space_outliner, &ten_bonegrp->subtree, ob, ten_bonegrp, TSE_POSEGRP, a);
ten->name = agrp->name;
ten->directdata = agrp;
}
@@ -443,20 +463,21 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
}
for (int a = 0; a < ob->totcol; a++) {
- outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a);
+ outliner_add_element(space_outliner, &te->subtree, ob->mat[a], te, 0, a);
}
if (ob->constraints.first) {
/* Object *target; */
bConstraint *con;
TreeElement *ten;
- TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0);
+ TreeElement *tenla = outliner_add_element(
+ space_outliner, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0);
/* char *str; */
int a;
tenla->name = IFACE_("Constraints");
for (con = ob->constraints.first, a = 0; con; con = con->next, a++) {
- ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a);
+ ten = outliner_add_element(space_outliner, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a);
#if 0 /* disabled due to constraints system targets recode... code here needs review */
target = get_constraint_target(con, &str);
if (str && str[0]) {
@@ -477,37 +498,54 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
if (ob->modifiers.first) {
ModifierData *md;
- TreeElement *ten_mod = outliner_add_element(soops, &te->subtree, ob, te, TSE_MODIFIER_BASE, 0);
+ TreeElement *ten_mod = outliner_add_element(
+ space_outliner, &te->subtree, ob, te, TSE_MODIFIER_BASE, 0);
int index;
ten_mod->name = IFACE_("Modifiers");
for (index = 0, md = ob->modifiers.first; md; index++, md = md->next) {
TreeElement *ten = outliner_add_element(
- soops, &ten_mod->subtree, ob, ten_mod, TSE_MODIFIER, index);
+ space_outliner, &ten_mod->subtree, ob, ten_mod, TSE_MODIFIER, index);
ten->name = md->name;
ten->directdata = md;
if (md->type == eModifierType_Lattice) {
- outliner_add_element(
- soops, &ten->subtree, ((LatticeModifierData *)md)->object, ten, TSE_LINKED_OB, 0);
+ outliner_add_element(space_outliner,
+ &ten->subtree,
+ ((LatticeModifierData *)md)->object,
+ ten,
+ TSE_LINKED_OB,
+ 0);
}
else if (md->type == eModifierType_Curve) {
- outliner_add_element(
- soops, &ten->subtree, ((CurveModifierData *)md)->object, ten, TSE_LINKED_OB, 0);
+ outliner_add_element(space_outliner,
+ &ten->subtree,
+ ((CurveModifierData *)md)->object,
+ ten,
+ TSE_LINKED_OB,
+ 0);
}
else if (md->type == eModifierType_Armature) {
- outliner_add_element(
- soops, &ten->subtree, ((ArmatureModifierData *)md)->object, ten, TSE_LINKED_OB, 0);
+ outliner_add_element(space_outliner,
+ &ten->subtree,
+ ((ArmatureModifierData *)md)->object,
+ ten,
+ TSE_LINKED_OB,
+ 0);
}
else if (md->type == eModifierType_Hook) {
- outliner_add_element(
- soops, &ten->subtree, ((HookModifierData *)md)->object, ten, TSE_LINKED_OB, 0);
+ outliner_add_element(space_outliner,
+ &ten->subtree,
+ ((HookModifierData *)md)->object,
+ ten,
+ TSE_LINKED_OB,
+ 0);
}
else if (md->type == eModifierType_ParticleSystem) {
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
TreeElement *ten_psys;
- ten_psys = outliner_add_element(soops, &ten->subtree, ob, te, TSE_LINKED_PSYS, 0);
+ ten_psys = outliner_add_element(space_outliner, &ten->subtree, ob, te, TSE_LINKED_PSYS, 0);
ten_psys->directdata = psys;
ten_psys->name = psys->part->id.name + 2;
}
@@ -518,12 +556,13 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
if (ob->defbase.first) {
bDeformGroup *defgroup;
TreeElement *ten;
- TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0);
+ TreeElement *tenla = outliner_add_element(
+ space_outliner, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0);
int a;
tenla->name = IFACE_("Vertex Groups");
for (defgroup = ob->defbase.first, a = 0; defgroup; defgroup = defgroup->next, a++) {
- ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a);
+ ten = outliner_add_element(space_outliner, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a);
ten->name = defgroup->name;
ten->directdata = defgroup;
}
@@ -531,12 +570,12 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
/* duplicated group */
if (ob->instance_collection && (ob->transflag & OB_DUPLICOLLECTION)) {
- outliner_add_element(soops, &te->subtree, ob->instance_collection, te, 0, 0);
+ outliner_add_element(space_outliner, &te->subtree, ob->instance_collection, te, 0, 0);
}
}
/* Can be inlined if necessary. */
-static void outliner_add_id_contents(SpaceOutliner *soops,
+static void outliner_add_id_contents(SpaceOutliner *space_outliner,
TreeElement *te,
TreeStoreElem *tselem,
ID *id)
@@ -553,11 +592,11 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
break;
}
case ID_SCE: {
- outliner_add_scene_contents(soops, &te->subtree, (Scene *)id, te);
+ outliner_add_scene_contents(space_outliner, &te->subtree, (Scene *)id, te);
break;
}
case ID_OB: {
- outliner_add_object_contents(soops, te, tselem, (Object *)id);
+ outliner_add_object_contents(space_outliner, te, tselem, (Object *)id);
break;
}
case ID_ME: {
@@ -565,12 +604,12 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
int a;
if (outliner_animdata_test(me->adt)) {
- outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, me, te, TSE_ANIM_DATA, 0);
}
- outliner_add_element(soops, &te->subtree, me->key, te, 0, 0);
+ outliner_add_element(space_outliner, &te->subtree, me->key, te, 0, 0);
for (a = 0; a < me->totcol; a++) {
- outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a);
+ outliner_add_element(space_outliner, &te->subtree, me->mat[a], te, 0, a);
}
/* could do tfaces with image links, but the images are not grouped nicely.
* would require going over all tfaces, sort images in use. etc... */
@@ -581,11 +620,11 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
int a;
if (outliner_animdata_test(cu->adt)) {
- outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, cu, te, TSE_ANIM_DATA, 0);
}
for (a = 0; a < cu->totcol; a++) {
- outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a);
+ outliner_add_element(space_outliner, &te->subtree, cu->mat[a], te, 0, a);
}
break;
}
@@ -594,11 +633,11 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
int a;
if (outliner_animdata_test(mb->adt)) {
- outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, mb, te, TSE_ANIM_DATA, 0);
}
for (a = 0; a < mb->totcol; a++) {
- outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a);
+ outliner_add_element(space_outliner, &te->subtree, mb->mat[a], te, 0, a);
}
break;
}
@@ -606,7 +645,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
Material *ma = (Material *)id;
if (outliner_animdata_test(ma->adt)) {
- outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, ma, te, TSE_ANIM_DATA, 0);
}
break;
}
@@ -614,16 +653,16 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
Tex *tex = (Tex *)id;
if (outliner_animdata_test(tex->adt)) {
- outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, tex, te, TSE_ANIM_DATA, 0);
}
- outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0);
+ outliner_add_element(space_outliner, &te->subtree, tex->ima, te, 0, 0);
break;
}
case ID_CA: {
Camera *ca = (Camera *)id;
if (outliner_animdata_test(ca->adt)) {
- outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, ca, te, TSE_ANIM_DATA, 0);
}
break;
}
@@ -631,7 +670,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
CacheFile *cache_file = (CacheFile *)id;
if (outliner_animdata_test(cache_file->adt)) {
- outliner_add_element(soops, &te->subtree, cache_file, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, cache_file, te, TSE_ANIM_DATA, 0);
}
break;
@@ -640,7 +679,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
Light *la = (Light *)id;
if (outliner_animdata_test(la->adt)) {
- outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, la, te, TSE_ANIM_DATA, 0);
}
break;
}
@@ -648,7 +687,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
Speaker *spk = (Speaker *)id;
if (outliner_animdata_test(spk->adt)) {
- outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, spk, te, TSE_ANIM_DATA, 0);
}
break;
}
@@ -656,7 +695,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
LightProbe *prb = (LightProbe *)id;
if (outliner_animdata_test(prb->adt)) {
- outliner_add_element(soops, &te->subtree, prb, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, prb, te, TSE_ANIM_DATA, 0);
}
break;
}
@@ -664,7 +703,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
World *wrld = (World *)id;
if (outliner_animdata_test(wrld->adt)) {
- outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, wrld, te, TSE_ANIM_DATA, 0);
}
break;
}
@@ -672,7 +711,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
Key *key = (Key *)id;
if (outliner_animdata_test(key->adt)) {
- outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, key, te, TSE_ANIM_DATA, 0);
}
break;
}
@@ -686,7 +725,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
int a = 0;
if (outliner_animdata_test(arm->adt)) {
- outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, arm, te, TSE_ANIM_DATA, 0);
}
if (arm->edbo) {
@@ -694,7 +733,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
TreeElement *ten;
for (ebone = arm->edbo->first; ebone; ebone = ebone->next, a++) {
- ten = outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a);
+ ten = outliner_add_element(space_outliner, &te->subtree, id, te, TSE_EBONE, a);
ten->directdata = ebone;
ten->name = ebone->name;
ebone->temp.p = ten;
@@ -722,7 +761,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
else {
Bone *curBone;
for (curBone = arm->bonebase.first; curBone; curBone = curBone->next) {
- outliner_add_bone(soops, &te->subtree, id, curBone, te, &a);
+ outliner_add_bone(space_outliner, &te->subtree, id, curBone, te, &a);
}
}
}
@@ -733,12 +772,12 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
int a;
if (outliner_animdata_test(linestyle->adt)) {
- outliner_add_element(soops, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0);
}
for (a = 0; a < MAX_MTEX; a++) {
if (linestyle->mtex[a]) {
- outliner_add_element(soops, &te->subtree, linestyle->mtex[a]->tex, te, 0, a);
+ outliner_add_element(space_outliner, &te->subtree, linestyle->mtex[a]->tex, te, 0, a);
}
}
break;
@@ -749,12 +788,12 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
int a = 0;
if (outliner_animdata_test(gpd->adt)) {
- outliner_add_element(soops, &te->subtree, gpd, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, gpd, te, TSE_ANIM_DATA, 0);
}
/* TODO: base element for layers? */
for (gpl = gpd->layers.last; gpl; gpl = gpl->prev) {
- outliner_add_element(soops, &te->subtree, gpl, te, TSE_GP_LAYER, a);
+ outliner_add_element(space_outliner, &te->subtree, gpl, te, TSE_GP_LAYER, a);
a++;
}
break;
@@ -763,35 +802,35 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
/* Don't expand for instances, creates too many elements. */
if (!(te->parent && te->parent->idcode == ID_OB)) {
Collection *collection = (Collection *)id;
- outliner_add_collection_recursive(soops, collection, te);
+ outliner_add_collection_recursive(space_outliner, collection, te);
}
break;
}
case ID_HA: {
Hair *hair = (Hair *)id;
if (outliner_animdata_test(hair->adt)) {
- outliner_add_element(soops, &te->subtree, hair, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, hair, te, TSE_ANIM_DATA, 0);
}
break;
}
case ID_PT: {
PointCloud *pointcloud = (PointCloud *)id;
if (outliner_animdata_test(pointcloud->adt)) {
- outliner_add_element(soops, &te->subtree, pointcloud, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, pointcloud, te, TSE_ANIM_DATA, 0);
}
break;
}
case ID_VO: {
Volume *volume = (Volume *)id;
if (outliner_animdata_test(volume->adt)) {
- outliner_add_element(soops, &te->subtree, volume, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, volume, te, TSE_ANIM_DATA, 0);
}
break;
}
case ID_SIM: {
Simulation *simulation = (Simulation *)id;
if (outliner_animdata_test(simulation->adt)) {
- outliner_add_element(soops, &te->subtree, simulation, te, TSE_ANIM_DATA, 0);
+ outliner_add_element(space_outliner, &te->subtree, simulation, te, TSE_ANIM_DATA, 0);
}
break;
}
@@ -807,8 +846,12 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
* \note: If child items are only added to the tree if the item is open, the TSE_ type _must_ be
* added to #outliner_element_needs_rebuild_on_open_change().
*/
-static TreeElement *outliner_add_element(
- SpaceOutliner *soops, ListBase *lb, void *idv, TreeElement *parent, short type, short index)
+static TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
+ ListBase *lb,
+ void *idv,
+ TreeElement *parent,
+ short type,
+ short index)
{
TreeElement *te;
TreeStoreElem *tselem;
@@ -842,11 +885,11 @@ static TreeElement *outliner_add_element(
/* add to the visual tree */
BLI_addtail(lb, te);
/* add to the storage */
- check_persistent(soops, te, id, type, index);
+ check_persistent(space_outliner, te, id, type, index);
tselem = TREESTORE(te);
/* if we are searching for something expand to see child elements */
- if (SEARCHING_OUTLINER(soops)) {
+ if (SEARCHING_OUTLINER(space_outliner)) {
tselem->flag |= TSE_CHILDSEARCH;
}
@@ -885,8 +928,8 @@ static TreeElement *outliner_add_element(
TreeStoreElem *tsepar = parent ? TREESTORE(parent) : NULL;
/* ID data-block. */
- if (tsepar == NULL || tsepar->type != TSE_ID_BASE || soops->filter_id_type) {
- outliner_add_id_contents(soops, te, tselem, id);
+ if (tsepar == NULL || tsepar->type != TSE_ID_BASE || space_outliner->filter_id_type) {
+ outliner_add_id_contents(space_outliner, te, tselem, id);
}
}
else if (type == TSE_ANIM_DATA) {
@@ -898,11 +941,12 @@ static TreeElement *outliner_add_element(
te->directdata = adt;
/* Action */
- outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0);
+ outliner_add_element(space_outliner, &te->subtree, adt->action, te, 0, 0);
/* Drivers */
if (adt->drivers.first) {
- TreeElement *ted = outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0);
+ TreeElement *ted = outliner_add_element(
+ space_outliner, &te->subtree, adt, te, TSE_DRIVER_BASE, 0);
ID *lastadded = NULL;
FCurve *fcu;
@@ -918,7 +962,8 @@ static TreeElement *outliner_add_element(
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
if (lastadded != dtar->id) {
/* XXX this lastadded check is rather lame, and also fails quite badly... */
- outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0);
+ outliner_add_element(
+ space_outliner, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0);
lastadded = dtar->id;
}
}
@@ -930,7 +975,7 @@ static TreeElement *outliner_add_element(
/* NLA Data */
if (adt->nla_tracks.first) {
- TreeElement *tenla = outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0);
+ TreeElement *tenla = outliner_add_element(space_outliner, &te->subtree, adt, te, TSE_NLA, 0);
NlaTrack *nlt;
int a = 0;
@@ -938,7 +983,7 @@ static TreeElement *outliner_add_element(
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
TreeElement *tenlt = outliner_add_element(
- soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a);
+ space_outliner, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a);
NlaStrip *strip;
TreeElement *ten;
int b = 0;
@@ -946,7 +991,8 @@ static TreeElement *outliner_add_element(
tenlt->name = nlt->name;
for (strip = nlt->strips.first; strip; strip = strip->next, b++) {
- ten = outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b);
+ ten = outliner_add_element(
+ space_outliner, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b);
if (ten) {
ten->directdata = strip;
}
@@ -983,12 +1029,13 @@ static TreeElement *outliner_add_element(
if (seq->type == SEQ_TYPE_META) {
p = seq->seqbase.first;
while (p) {
- outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
+ outliner_add_element(space_outliner, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
p = p->next;
}
}
else {
- outliner_add_element(soops, &te->subtree, (void *)seq->strip, te, TSE_SEQ_STRIP, index);
+ outliner_add_element(
+ space_outliner, &te->subtree, (void *)seq->strip, te, TSE_SEQ_STRIP, index);
}
}
}
@@ -1039,7 +1086,7 @@ static TreeElement *outliner_add_element(
}
/* If searching don't expand RNA entries */
- if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) {
+ if (SEARCHING_OUTLINER(space_outliner) && BLI_strcasecmp("RNA", te->name) == 0) {
tselem->flag &= ~TSE_CHILDSEARCH;
}
@@ -1054,11 +1101,12 @@ static TreeElement *outliner_add_element(
}
}
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
for (a = 0; a < tot; a++) {
RNA_property_collection_lookup_int(ptr, iterprop, a, &propptr);
if (!(RNA_property_flag(propptr.data) & PROP_HIDDEN)) {
- outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_PROPERTY, a);
+ outliner_add_element(
+ space_outliner, &te->subtree, (void *)ptr, te, TSE_RNA_PROPERTY, a);
}
}
}
@@ -1081,7 +1129,7 @@ static TreeElement *outliner_add_element(
te->rnaptr = *ptr;
/* If searching don't expand RNA entries */
- if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) {
+ if (SEARCHING_OUTLINER(space_outliner) && BLI_strcasecmp("RNA", te->name) == 0) {
tselem->flag &= ~TSE_CHILDSEARCH;
}
@@ -1089,8 +1137,9 @@ static TreeElement *outliner_add_element(
pptr = RNA_property_pointer_get(ptr, prop);
if (pptr.data) {
- if (TSELEM_OPEN(tselem, soops)) {
- outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, -1);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ outliner_add_element(
+ space_outliner, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, -1);
}
else {
te->flag |= TE_LAZY_CLOSED;
@@ -1101,10 +1150,11 @@ static TreeElement *outliner_add_element(
tot = RNA_property_collection_length(ptr, prop);
CLAMP_MAX(tot, tot_limit);
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
for (a = 0; a < tot; a++) {
RNA_property_collection_lookup_int(ptr, prop, a, &pptr);
- outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, a);
+ outliner_add_element(
+ space_outliner, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, a);
}
}
else if (tot) {
@@ -1115,9 +1165,10 @@ static TreeElement *outliner_add_element(
tot = RNA_property_array_length(ptr, prop);
CLAMP_MAX(tot, tot_limit);
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
for (a = 0; a < tot; a++) {
- outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_ARRAY_ELEM, a);
+ outliner_add_element(
+ space_outliner, &te->subtree, (void *)ptr, te, TSE_RNA_ARRAY_ELEM, a);
}
}
else if (tot) {
@@ -1136,7 +1187,7 @@ static TreeElement *outliner_add_element(
c = RNA_property_array_item_char(prop, index);
- te->name = MEM_callocN(sizeof(char) * 20, "OutlinerRNAArrayName");
+ te->name = MEM_callocN(sizeof(char[20]), "OutlinerRNAArrayName");
if (c) {
sprintf((char *)te->name, " %c", c);
}
@@ -1154,7 +1205,7 @@ static TreeElement *outliner_add_element(
te->directdata = idv;
te->name = km->idname;
- if (TSELEM_OPEN(tselem, soops)) {
+ if (TSELEM_OPEN(tselem, space_outliner)) {
int a = 0;
for (kmi = km->items.first; kmi; kmi = kmi->next, a++) {
@@ -1172,7 +1223,7 @@ static TreeElement *outliner_add_element(
if (ot || kmi->propvalue) {
TreeElement *ten = outliner_add_element(
- soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a);
+ space_outliner, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a);
ten->directdata = kmi;
@@ -1237,10 +1288,13 @@ static int need_add_seq_dup(Sequence *seq)
}
p = p->next;
}
- return (1);
+ return 1;
}
-static void outliner_add_seq_dup(SpaceOutliner *soops, Sequence *seq, TreeElement *te, short index)
+static void outliner_add_seq_dup(SpaceOutliner *space_outliner,
+ Sequence *seq,
+ TreeElement *te,
+ short index)
{
/* TreeElement *ch; */ /* UNUSED */
Sequence *p;
@@ -1254,7 +1308,7 @@ static void outliner_add_seq_dup(SpaceOutliner *soops, Sequence *seq, TreeElemen
if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) {
/* ch = */ /* UNUSED */ outliner_add_element(
- soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
+ space_outliner, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
}
p = p->next;
}
@@ -1296,17 +1350,19 @@ static bool outliner_library_id_show(Library *lib, ID *id, short filter_id_type)
}
static TreeElement *outliner_add_library_contents(Main *mainvar,
- SpaceOutliner *soops,
+ SpaceOutliner *space_outliner,
ListBase *lb,
Library *lib)
{
TreeElement *ten, *tenlib = NULL;
ListBase *lbarray[MAX_LIBARRAY];
int a, tot;
- short filter_id_type = (soops->filter & SO_FILTER_ID_TYPE) ? soops->filter_id_type : 0;
+ short filter_id_type = (space_outliner->filter & SO_FILTER_ID_TYPE) ?
+ space_outliner->filter_id_type :
+ 0;
if (filter_id_type) {
- lbarray[0] = which_libbase(mainvar, soops->filter_id_type);
+ lbarray[0] = which_libbase(mainvar, space_outliner->filter_id_type);
tot = 1;
}
else {
@@ -1331,10 +1387,10 @@ static TreeElement *outliner_add_library_contents(Main *mainvar,
if (!tenlib) {
/* Create library tree element on demand, depending if there are any data-blocks. */
if (lib) {
- tenlib = outliner_add_element(soops, lb, lib, NULL, 0, 0);
+ tenlib = outliner_add_element(space_outliner, lb, lib, NULL, 0, 0);
}
else {
- tenlib = outliner_add_element(soops, lb, mainvar, NULL, TSE_ID_BASE, 0);
+ tenlib = outliner_add_element(space_outliner, lb, mainvar, NULL, TSE_ID_BASE, 0);
tenlib->name = IFACE_("Current File");
}
}
@@ -1345,14 +1401,15 @@ static TreeElement *outliner_add_library_contents(Main *mainvar,
ten = tenlib;
}
else {
- ten = outliner_add_element(soops, &tenlib->subtree, lbarray[a], NULL, TSE_ID_BASE, 0);
+ ten = outliner_add_element(
+ space_outliner, &tenlib->subtree, lbarray[a], NULL, TSE_ID_BASE, 0);
ten->directdata = lbarray[a];
ten->name = outliner_idcode_to_plural(GS(id->name));
}
for (id = lbarray[a]->first; id; id = id->next) {
if (outliner_library_id_show(lib, id, filter_id_type)) {
- outliner_add_element(soops, &ten->subtree, id, ten, 0, 0);
+ outliner_add_element(space_outliner, &ten->subtree, id, ten, 0, 0);
}
}
}
@@ -1363,15 +1420,17 @@ static TreeElement *outliner_add_library_contents(Main *mainvar,
return tenlib;
}
-static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops)
+static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *space_outliner)
{
TreeElement *ten;
ListBase *lbarray[MAX_LIBARRAY];
int a, tot;
- short filter_id_type = (soops->filter & SO_FILTER_ID_TYPE) ? soops->filter_id_type : 0;
+ short filter_id_type = (space_outliner->filter & SO_FILTER_ID_TYPE) ?
+ space_outliner->filter_id_type :
+ 0;
if (filter_id_type) {
- lbarray[0] = which_libbase(mainvar, soops->filter_id_type);
+ lbarray[0] = which_libbase(mainvar, space_outliner->filter_id_type);
tot = 1;
}
else {
@@ -1395,7 +1454,8 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops
ten = NULL;
}
else {
- ten = outliner_add_element(soops, &soops->tree, lbarray[a], NULL, TSE_ID_BASE, 0);
+ ten = outliner_add_element(
+ space_outliner, &space_outliner->tree, lbarray[a], NULL, TSE_ID_BASE, 0);
ten->directdata = lbarray[a];
ten->name = outliner_idcode_to_plural(GS(id->name));
}
@@ -1403,7 +1463,8 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops
/* add the orphaned data-blocks - these will not be added with any subtrees attached */
for (id = lbarray[a]->first; id; id = id->next) {
if (ID_REAL_USERS(id) <= 0) {
- outliner_add_element(soops, (ten) ? &ten->subtree : &soops->tree, id, ten, 0, 0);
+ outliner_add_element(
+ space_outliner, (ten) ? &ten->subtree : &space_outliner->tree, id, ten, 0, 0);
}
}
}
@@ -1411,12 +1472,15 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops
}
}
-static void outliner_add_layer_collection_objects(
- SpaceOutliner *soops, ListBase *tree, ViewLayer *layer, LayerCollection *lc, TreeElement *ten)
+static void outliner_add_layer_collection_objects(SpaceOutliner *space_outliner,
+ ListBase *tree,
+ ViewLayer *layer,
+ LayerCollection *lc,
+ TreeElement *ten)
{
LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) {
Base *base = BKE_view_layer_base_find(layer, cob->ob);
- TreeElement *te_object = outliner_add_element(soops, tree, base->object, ten, 0, 0);
+ TreeElement *te_object = outliner_add_element(space_outliner, tree, base->object, ten, 0, 0);
te_object->directdata = base;
if (!(base->flag & BASE_VISIBLE_DEPSGRAPH)) {
@@ -1425,7 +1489,7 @@ static void outliner_add_layer_collection_objects(
}
}
-static void outliner_add_layer_collections_recursive(SpaceOutliner *soops,
+static void outliner_add_layer_collections_recursive(SpaceOutliner *space_outliner,
ListBase *tree,
ViewLayer *layer,
ListBase *layer_collections,
@@ -1436,12 +1500,12 @@ static void outliner_add_layer_collections_recursive(SpaceOutliner *soops,
const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0;
TreeElement *ten;
- if (exclude && ((soops->show_restrict_flags & SO_RESTRICT_ENABLE) == 0)) {
+ if (exclude && ((space_outliner->show_restrict_flags & SO_RESTRICT_ENABLE) == 0)) {
ten = parent_ten;
}
else {
ID *id = &lc->collection->id;
- ten = outliner_add_element(soops, tree, id, parent_ten, TSE_LAYER_COLLECTION, 0);
+ ten = outliner_add_element(space_outliner, tree, id, parent_ten, TSE_LAYER_COLLECTION, 0);
ten->name = id->name + 2;
ten->directdata = lc;
@@ -1458,14 +1522,14 @@ static void outliner_add_layer_collections_recursive(SpaceOutliner *soops,
}
outliner_add_layer_collections_recursive(
- soops, &ten->subtree, layer, &lc->layer_collections, ten, show_objects);
+ space_outliner, &ten->subtree, layer, &lc->layer_collections, ten, show_objects);
if (!exclude && show_objects) {
- outliner_add_layer_collection_objects(soops, &ten->subtree, layer, lc, ten);
+ outliner_add_layer_collection_objects(space_outliner, &ten->subtree, layer, lc, ten);
}
}
}
-static void outliner_add_view_layer(SpaceOutliner *soops,
+static void outliner_add_view_layer(SpaceOutliner *space_outliner,
ListBase *tree,
TreeElement *parent,
ViewLayer *layer,
@@ -1478,9 +1542,9 @@ static void outliner_add_view_layer(SpaceOutliner *soops,
}
outliner_add_layer_collections_recursive(
- soops, tree, layer, &lc->layer_collections, parent, show_objects);
+ space_outliner, tree, layer, &lc->layer_collections, parent, show_objects);
if (show_objects) {
- outliner_add_layer_collection_objects(soops, tree, layer, lc, parent);
+ outliner_add_layer_collection_objects(space_outliner, tree, layer, lc, parent);
}
}
@@ -1490,28 +1554,28 @@ BLI_INLINE void outliner_add_collection_init(TreeElement *te, Collection *collec
te->directdata = collection;
}
-BLI_INLINE void outliner_add_collection_objects(SpaceOutliner *soops,
+BLI_INLINE void outliner_add_collection_objects(SpaceOutliner *space_outliner,
ListBase *tree,
Collection *collection,
TreeElement *parent)
{
LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
- outliner_add_element(soops, tree, cob->ob, parent, 0, 0);
+ outliner_add_element(space_outliner, tree, cob->ob, parent, 0, 0);
}
}
-static TreeElement *outliner_add_collection_recursive(SpaceOutliner *soops,
+static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
Collection *collection,
TreeElement *ten)
{
outliner_add_collection_init(ten, collection);
LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
- outliner_add_element(soops, &ten->subtree, &child->collection->id, ten, 0, 0);
+ outliner_add_element(space_outliner, &ten->subtree, &child->collection->id, ten, 0, 0);
}
- if (soops->outlinevis != SO_SCENES) {
- outliner_add_collection_objects(soops, &ten->subtree, collection, ten);
+ if (space_outliner->outlinevis != SO_SCENES) {
+ outliner_add_collection_objects(space_outliner, &ten->subtree, collection, ten);
}
return ten;
@@ -1552,7 +1616,7 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb)
* For all objects in the tree, lookup the parent in this map,
* and move or add tree elements as needed.
*/
-static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soops,
+static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *space_outliner,
GHash *object_tree_elements_hash)
{
GHashIterator gh_iter;
@@ -1600,7 +1664,7 @@ static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soo
/* We add the child in the tree even if it is not in the collection.
* We deliberately clear its sub-tree though, to make it less prominent. */
TreeElement *child_ob_tree_element = outliner_add_element(
- soops, &parent_ob_tree_element->subtree, child, parent_ob_tree_element, 0, 0);
+ space_outliner, &parent_ob_tree_element->subtree, child, parent_ob_tree_element, 0, 0);
outliner_free_tree(&child_ob_tree_element->subtree);
child_ob_tree_element->flag |= TE_CHILD_NOT_IN_COLLECTION;
BLI_addtail(child_ob_tree_elements, BLI_genericNodeN(child_ob_tree_element));
@@ -1889,16 +1953,16 @@ typedef struct OutlinerTreeElementFocus {
* Bring the outliner scrolling back to where it was in relation to the original focus element
* Caller is expected to handle redrawing of ARegion.
*/
-static void outliner_restore_scrolling_position(SpaceOutliner *soops,
+static void outliner_restore_scrolling_position(SpaceOutliner *space_outliner,
ARegion *region,
OutlinerTreeElementFocus *focus)
{
View2D *v2d = &region->v2d;
if (focus->tselem != NULL) {
- outliner_set_coordinates(region, soops);
+ outliner_set_coordinates(region, space_outliner);
- TreeElement *te_new = outliner_find_tree_element(&soops->tree, focus->tselem);
+ TreeElement *te_new = outliner_find_tree_element(&space_outliner->tree, focus->tselem);
if (te_new != NULL) {
int ys_new = te_new->ys;
@@ -1928,7 +1992,7 @@ static bool test_object_callback(TreeElement *te)
* See if TreeElement or any of its children pass the callback_test.
*/
static TreeElement *outliner_find_first_desired_element_at_y_recursive(
- const SpaceOutliner *soops,
+ const SpaceOutliner *space_outliner,
TreeElement *te,
const float limit,
bool (*callback_test)(TreeElement *))
@@ -1937,11 +2001,11 @@ static TreeElement *outliner_find_first_desired_element_at_y_recursive(
return te;
}
- if (TSELEM_OPEN(te->store_elem, soops)) {
+ if (TSELEM_OPEN(te->store_elem, space_outliner)) {
TreeElement *te_iter, *te_sub;
for (te_iter = te->subtree.first; te_iter; te_iter = te_iter->next) {
te_sub = outliner_find_first_desired_element_at_y_recursive(
- soops, te_iter, limit, callback_test);
+ space_outliner, te_iter, limit, callback_test);
if (te_sub != NULL) {
return te_sub;
}
@@ -1961,15 +2025,16 @@ static TreeElement *outliner_find_first_desired_element_at_y_recursive(
* what we are looking for. If we are past the visible range and we can't find a valid element
* we return NULL.
*/
-static TreeElement *outliner_find_first_desired_element_at_y(const SpaceOutliner *soops,
+static TreeElement *outliner_find_first_desired_element_at_y(const SpaceOutliner *space_outliner,
const float view_co,
const float view_co_limit)
{
TreeElement *te, *te_sub;
- te = outliner_find_item_at_y(soops, &soops->tree, view_co);
+ te = outliner_find_item_at_y(space_outliner, &space_outliner->tree, view_co);
bool (*callback_test)(TreeElement *);
- if ((soops->outlinevis == SO_VIEW_LAYER) && (soops->filter & SO_FILTER_NO_COLLECTION)) {
+ if ((space_outliner->outlinevis == SO_VIEW_LAYER) &&
+ (space_outliner->filter & SO_FILTER_NO_COLLECTION)) {
callback_test = test_object_callback;
}
else {
@@ -1978,7 +2043,7 @@ static TreeElement *outliner_find_first_desired_element_at_y(const SpaceOutliner
while (te != NULL) {
te_sub = outliner_find_first_desired_element_at_y_recursive(
- soops, te, view_co_limit, callback_test);
+ space_outliner, te, view_co_limit, callback_test);
if (te_sub != NULL) {
/* Skip the element if it was not visible to start with. */
if (te->ys + UI_UNIT_Y > view_co_limit) {
@@ -2015,16 +2080,16 @@ static TreeElement *outliner_find_first_desired_element_at_y(const SpaceOutliner
* #OutlinerTreeElementFocus struct to retrieve this element later to make sure it is in the same
* original position as before filtering.
*/
-static void outliner_store_scrolling_position(SpaceOutliner *soops,
+static void outliner_store_scrolling_position(SpaceOutliner *space_outliner,
ARegion *region,
OutlinerTreeElementFocus *focus)
{
TreeElement *te;
float limit = region->v2d.cur.ymin;
- outliner_set_coordinates(region, soops);
+ outliner_set_coordinates(region, space_outliner);
- te = outliner_find_first_desired_element_at_y(soops, region->v2d.cur.ymax, limit);
+ te = outliner_find_first_desired_element_at_y(space_outliner, region->v2d.cur.ymax, limit);
if (te != NULL) {
focus->tselem = TREESTORE(te);
@@ -2035,11 +2100,11 @@ static void outliner_store_scrolling_position(SpaceOutliner *soops,
}
}
-static int outliner_exclude_filter_get(SpaceOutliner *soops)
+static int outliner_exclude_filter_get(SpaceOutliner *space_outliner)
{
- int exclude_filter = soops->filter & ~SO_FILTER_OB_STATE;
+ int exclude_filter = space_outliner->filter & ~SO_FILTER_OB_STATE;
- if (soops->search_string[0] != 0) {
+ if (space_outliner->search_string[0] != 0) {
exclude_filter |= SO_FILTER_SEARCH;
}
else {
@@ -2047,15 +2112,15 @@ static int outliner_exclude_filter_get(SpaceOutliner *soops)
}
/* Let's have this for the collection options at first. */
- if (!SUPPORT_FILTER_OUTLINER(soops)) {
+ if (!SUPPORT_FILTER_OUTLINER(space_outliner)) {
return (exclude_filter & SO_FILTER_SEARCH);
}
- if (soops->filter & SO_FILTER_NO_OBJECT) {
+ if (space_outliner->filter & SO_FILTER_NO_OBJECT) {
exclude_filter |= SO_FILTER_OB_TYPE;
}
- switch (soops->filter_state) {
+ switch (space_outliner->filter_state) {
case SO_FILTER_OB_VISIBLE:
exclude_filter |= SO_FILTER_OB_STATE_VISIBLE;
break;
@@ -2192,7 +2257,9 @@ static bool outliner_element_is_collection_or_object(TreeElement *te)
if ((tselem->type == 0) && (te->idcode == ID_OB)) {
return true;
}
- if (outliner_is_collection_tree_element(te)) {
+
+ /* Collection instance datablocks should not be extracted. */
+ if (outliner_is_collection_tree_element(te) && !(te->parent && te->parent->idcode == ID_OB)) {
return true;
}
@@ -2224,7 +2291,7 @@ static TreeElement *outliner_extract_children_from_subtree(TreeElement *element,
return te_next;
}
-static int outliner_filter_subtree(SpaceOutliner *soops,
+static int outliner_filter_subtree(SpaceOutliner *space_outliner,
ViewLayer *view_layer,
ListBase *lb,
const char *search_string,
@@ -2238,17 +2305,19 @@ static int outliner_filter_subtree(SpaceOutliner *soops,
if ((outliner_element_visible_get(view_layer, te, exclude_filter) == false)) {
/* Don't free the tree, but extract the children from the parent and add to this tree. */
/* This also needs filtering the subtree prior (see T69246). */
- outliner_filter_subtree(soops, view_layer, &te->subtree, search_string, exclude_filter);
+ outliner_filter_subtree(
+ space_outliner, view_layer, &te->subtree, search_string, exclude_filter);
te_next = outliner_extract_children_from_subtree(te, lb);
continue;
}
if ((exclude_filter & SO_FILTER_SEARCH) == 0) {
/* Filter subtree too. */
- outliner_filter_subtree(soops, view_layer, &te->subtree, search_string, exclude_filter);
+ outliner_filter_subtree(
+ space_outliner, view_layer, &te->subtree, search_string, exclude_filter);
continue;
}
- if (!outliner_filter_has_name(te, search_string, soops->search_flags)) {
+ if (!outliner_filter_has_name(te, search_string, space_outliner->search_flags)) {
/* item isn't something we're looking for, but...
* - if the subtree is expanded, check if there are any matches that can be easily found
* so that searching for "cu" in the default scene will still match the Cube
@@ -2260,9 +2329,9 @@ static int outliner_filter_subtree(SpaceOutliner *soops,
/* flag as not a found item */
tselem->flag &= ~TSE_SEARCHMATCH;
- if ((!TSELEM_OPEN(tselem, soops)) ||
+ if ((!TSELEM_OPEN(tselem, space_outliner)) ||
outliner_filter_subtree(
- soops, view_layer, &te->subtree, search_string, exclude_filter) == 0) {
+ space_outliner, view_layer, &te->subtree, search_string, exclude_filter) == 0) {
outliner_free_tree_element(te, lb);
}
}
@@ -2273,7 +2342,8 @@ static int outliner_filter_subtree(SpaceOutliner *soops,
tselem->flag |= TSE_SEARCHMATCH;
/* filter subtree too */
- outliner_filter_subtree(soops, view_layer, &te->subtree, search_string, exclude_filter);
+ outliner_filter_subtree(
+ space_outliner, view_layer, &te->subtree, search_string, exclude_filter);
}
}
@@ -2281,27 +2351,28 @@ static int outliner_filter_subtree(SpaceOutliner *soops,
return (BLI_listbase_is_empty(lb) == false);
}
-static void outliner_filter_tree(SpaceOutliner *soops, ViewLayer *view_layer)
+static void outliner_filter_tree(SpaceOutliner *space_outliner, ViewLayer *view_layer)
{
char search_buff[sizeof(((struct SpaceOutliner *)NULL)->search_string) + 2];
char *search_string;
- const int exclude_filter = outliner_exclude_filter_get(soops);
+ const int exclude_filter = outliner_exclude_filter_get(space_outliner);
if (exclude_filter == 0) {
return;
}
- if (soops->search_flags & SO_FIND_COMPLETE) {
- search_string = soops->search_string;
+ if (space_outliner->search_flags & SO_FIND_COMPLETE) {
+ search_string = space_outliner->search_string;
}
else {
/* Implicitly add heading/trailing wildcards if needed. */
- BLI_strncpy_ensure_pad(search_buff, soops->search_string, '*', sizeof(search_buff));
+ BLI_strncpy_ensure_pad(search_buff, space_outliner->search_string, '*', sizeof(search_buff));
search_string = search_buff;
}
- outliner_filter_subtree(soops, view_layer, &soops->tree, search_string, exclude_filter);
+ outliner_filter_subtree(
+ space_outliner, view_layer, &space_outliner->tree, search_string, exclude_filter);
}
/* ======================================================= */
@@ -2309,27 +2380,32 @@ static void outliner_filter_tree(SpaceOutliner *soops, ViewLayer *view_layer)
/* Main entry point for building the tree data-structure that the outliner represents. */
/* TODO: split each mode into its own function? */
-void outliner_build_tree(
- Main *mainvar, Scene *scene, ViewLayer *view_layer, SpaceOutliner *soops, ARegion *region)
+void outliner_build_tree(Main *mainvar,
+ Scene *scene,
+ ViewLayer *view_layer,
+ SpaceOutliner *space_outliner,
+ ARegion *region)
{
TreeElement *te = NULL, *ten;
TreeStoreElem *tselem;
/* on first view, we open scenes */
- int show_opened = !soops->treestore || !BLI_mempool_len(soops->treestore);
+ int show_opened = !space_outliner->treestore || !BLI_mempool_len(space_outliner->treestore);
/* Are we looking for something - we want to tag parents to filter child matches
* - NOT in data-blocks view - searching all data-blocks takes way too long to be useful
* - this variable is only set once per tree build */
- if (soops->search_string[0] != 0 && soops->outlinevis != SO_DATA_API) {
- soops->search_flags |= SO_SEARCH_RECURSIVE;
+ if (space_outliner->search_string[0] != 0 && space_outliner->outlinevis != SO_DATA_API) {
+ space_outliner->search_flags |= SO_SEARCH_RECURSIVE;
}
else {
- soops->search_flags &= ~SO_SEARCH_RECURSIVE;
+ space_outliner->search_flags &= ~SO_SEARCH_RECURSIVE;
}
- if (soops->treehash && (soops->storeflag & SO_TREESTORE_REBUILD) && soops->treestore) {
- soops->storeflag &= ~SO_TREESTORE_REBUILD;
- BKE_outliner_treehash_rebuild_from_treestore(soops->treehash, soops->treestore);
+ if (space_outliner->treehash && (space_outliner->storeflag & SO_TREESTORE_REBUILD) &&
+ space_outliner->treestore) {
+ space_outliner->storeflag &= ~SO_TREESTORE_REBUILD;
+ BKE_outliner_treehash_rebuild_from_treestore(space_outliner->treehash,
+ space_outliner->treestore);
}
if (region->do_draw & RGN_DRAW_NO_REBUILD) {
@@ -2337,17 +2413,17 @@ void outliner_build_tree(
}
OutlinerTreeElementFocus focus;
- outliner_store_scrolling_position(soops, region, &focus);
+ outliner_store_scrolling_position(space_outliner, region, &focus);
- outliner_free_tree(&soops->tree);
- outliner_storage_cleanup(soops);
+ outliner_free_tree(&space_outliner->tree);
+ outliner_storage_cleanup(space_outliner);
/* options */
- if (soops->outlinevis == SO_LIBRARIES) {
+ if (space_outliner->outlinevis == SO_LIBRARIES) {
Library *lib;
/* current file first - mainvar provides tselem with unique pointer - not used */
- ten = outliner_add_library_contents(mainvar, soops, &soops->tree, NULL);
+ ten = outliner_add_library_contents(mainvar, space_outliner, &space_outliner->tree, NULL);
if (ten) {
tselem = TREESTORE(ten);
if (!tselem->used) {
@@ -2356,14 +2432,14 @@ void outliner_build_tree(
}
for (lib = mainvar->libraries.first; lib; lib = lib->id.next) {
- ten = outliner_add_library_contents(mainvar, soops, &soops->tree, lib);
+ ten = outliner_add_library_contents(mainvar, space_outliner, &space_outliner->tree, lib);
/* NULL-check matters, due to filtering there may not be a new element. */
if (ten) {
lib->id.newid = (ID *)ten;
}
}
/* make hierarchy */
- ten = soops->tree.first;
+ ten = space_outliner->tree.first;
if (ten != NULL) {
ten = ten->next; /* first one is main */
while (ten) {
@@ -2374,14 +2450,14 @@ void outliner_build_tree(
par = (TreeElement *)lib->parent->id.newid;
if (tselem->id->tag & LIB_TAG_INDIRECT) {
/* Only remove from 'first level' if lib is not also directly used. */
- BLI_remlink(&soops->tree, ten);
+ BLI_remlink(&space_outliner->tree, ten);
BLI_addtail(&par->subtree, ten);
ten->parent = par;
}
else {
/* Else, make a new copy of the libtree for our parent. */
TreeElement *dupten = outliner_add_library_contents(
- mainvar, soops, &par->subtree, lib);
+ mainvar, space_outliner, &par->subtree, lib);
if (dupten) {
dupten->parent = par;
}
@@ -2395,10 +2471,10 @@ void outliner_build_tree(
lib->id.newid = NULL;
}
}
- else if (soops->outlinevis == SO_SCENES) {
+ else if (space_outliner->outlinevis == SO_SCENES) {
Scene *sce;
for (sce = mainvar->scenes.first; sce; sce = sce->id.next) {
- te = outliner_add_element(soops, &soops->tree, sce, NULL, 0, 0);
+ te = outliner_add_element(space_outliner, &space_outliner->tree, sce, NULL, 0, 0);
tselem = TREESTORE(te);
/* New scene elements open by default */
@@ -2409,7 +2485,7 @@ void outliner_build_tree(
outliner_make_object_parent_hierarchy(&te->subtree);
}
}
- else if (soops->outlinevis == SO_SEQUENCE) {
+ else if (space_outliner->outlinevis == SO_SEQUENCE) {
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
int op;
@@ -2426,74 +2502,81 @@ void outliner_build_tree(
while (seq) {
op = need_add_seq_dup(seq);
if (op == 1) {
- /* ten = */ outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE, 0);
+ /* ten = */ outliner_add_element(
+ space_outliner, &space_outliner->tree, (void *)seq, NULL, TSE_SEQUENCE, 0);
}
else if (op == 0) {
- ten = outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE_DUP, 0);
- outliner_add_seq_dup(soops, seq, ten, 0);
+ ten = outliner_add_element(
+ space_outliner, &space_outliner->tree, (void *)seq, NULL, TSE_SEQUENCE_DUP, 0);
+ outliner_add_seq_dup(space_outliner, seq, ten, 0);
}
seq = seq->next;
}
}
- else if (soops->outlinevis == SO_DATA_API) {
+ else if (space_outliner->outlinevis == SO_DATA_API) {
PointerRNA mainptr;
RNA_main_pointer_create(mainvar, &mainptr);
- ten = outliner_add_element(soops, &soops->tree, (void *)&mainptr, NULL, TSE_RNA_STRUCT, -1);
+ ten = outliner_add_element(
+ space_outliner, &space_outliner->tree, (void *)&mainptr, NULL, TSE_RNA_STRUCT, -1);
if (show_opened) {
tselem = TREESTORE(ten);
tselem->flag &= ~TSE_CLOSED;
}
}
- else if (soops->outlinevis == SO_ID_ORPHANS) {
- outliner_add_orphaned_datablocks(mainvar, soops);
+ else if (space_outliner->outlinevis == SO_ID_ORPHANS) {
+ outliner_add_orphaned_datablocks(mainvar, space_outliner);
}
- else if (soops->outlinevis == SO_VIEW_LAYER) {
- if (soops->filter & SO_FILTER_NO_COLLECTION) {
+ else if (space_outliner->outlinevis == SO_VIEW_LAYER) {
+ if (space_outliner->filter & SO_FILTER_NO_COLLECTION) {
/* Show objects in the view layer. */
LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
TreeElement *te_object = outliner_add_element(
- soops, &soops->tree, base->object, NULL, 0, 0);
+ space_outliner, &space_outliner->tree, base->object, NULL, 0, 0);
te_object->directdata = base;
}
- outliner_make_object_parent_hierarchy(&soops->tree);
+ if ((space_outliner->filter & SO_FILTER_NO_CHILDREN) == 0) {
+ outliner_make_object_parent_hierarchy(&space_outliner->tree);
+ }
}
else {
/* Show collections in the view layer. */
- ten = outliner_add_element(soops, &soops->tree, scene, NULL, TSE_VIEW_COLLECTION_BASE, 0);
+ ten = outliner_add_element(
+ space_outliner, &space_outliner->tree, scene, NULL, TSE_VIEW_COLLECTION_BASE, 0);
ten->name = IFACE_("Scene Collection");
TREESTORE(ten)->flag &= ~TSE_CLOSED;
- bool show_objects = !(soops->filter & SO_FILTER_NO_OBJECT);
- outliner_add_view_layer(soops, &ten->subtree, ten, view_layer, show_objects);
+ bool show_objects = !(space_outliner->filter & SO_FILTER_NO_OBJECT);
+ outliner_add_view_layer(space_outliner, &ten->subtree, ten, view_layer, show_objects);
- if ((soops->filter & SO_FILTER_NO_CHILDREN) == 0) {
+ if ((space_outliner->filter & SO_FILTER_NO_CHILDREN) == 0) {
GHash *object_tree_elements_hash = BLI_ghash_new(
BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, ten);
- outliner_make_object_parent_hierarchy_collections(soops, object_tree_elements_hash);
+ outliner_make_object_parent_hierarchy_collections(space_outliner,
+ object_tree_elements_hash);
outliner_object_tree_elements_lookup_free(object_tree_elements_hash);
BLI_ghash_free(object_tree_elements_hash, NULL, NULL);
}
}
}
- if ((soops->flag & SO_SKIP_SORT_ALPHA) == 0) {
- outliner_sort(&soops->tree);
+ if ((space_outliner->flag & SO_SKIP_SORT_ALPHA) == 0) {
+ outliner_sort(&space_outliner->tree);
}
- else if ((soops->filter & SO_FILTER_NO_CHILDREN) == 0) {
+ else if ((space_outliner->filter & SO_FILTER_NO_CHILDREN) == 0) {
/* We group the children that are in the collection before the ones that are not.
* This way we can try to draw them in a different style altogether.
* We also have to respect the original order of the elements in case alphabetical
* sorting is not enabled. This keep object data and modifiers before its children. */
- outliner_collections_children_sort(&soops->tree);
+ outliner_collections_children_sort(&space_outliner->tree);
}
- outliner_filter_tree(soops, view_layer);
- outliner_restore_scrolling_position(soops, region, &focus);
+ outliner_filter_tree(space_outliner, view_layer);
+ outliner_restore_scrolling_position(space_outliner, region, &focus);
BKE_main_id_clear_newpoins(mainvar);
}
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index 9accf35784a..1da44b5e51e 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -74,7 +74,7 @@ void outliner_viewcontext_init(const bContext *C, TreeViewContext *tvc)
* Try to find an item under y-coordinate \a view_co_y (view-space).
* \note Recursive
*/
-TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops,
+TreeElement *outliner_find_item_at_y(const SpaceOutliner *space_outliner,
const ListBase *tree,
float view_co_y)
{
@@ -85,7 +85,8 @@ TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops,
return te_iter;
}
- if (BLI_listbase_is_empty(&te_iter->subtree) || !TSELEM_OPEN(TREESTORE(te_iter), soops)) {
+ if (BLI_listbase_is_empty(&te_iter->subtree) ||
+ !TSELEM_OPEN(TREESTORE(te_iter), space_outliner)) {
/* No need for recursion. */
continue;
}
@@ -99,7 +100,7 @@ TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops,
/* co_y is lower than current element (but not lower than the next one), possibly inside
* children */
- TreeElement *te_sub = outliner_find_item_at_y(soops, &te_iter->subtree, view_co_y);
+ TreeElement *te_sub = outliner_find_item_at_y(space_outliner, &te_iter->subtree, view_co_y);
if (te_sub) {
return te_sub;
}
@@ -147,13 +148,13 @@ static TreeElement *outliner_find_item_at_x_in_row_recursive(const TreeElement *
*
* \return a hovered child item or \a parent_te (if no hovered child found).
*/
-TreeElement *outliner_find_item_at_x_in_row(const SpaceOutliner *soops,
+TreeElement *outliner_find_item_at_x_in_row(const SpaceOutliner *space_outliner,
const TreeElement *parent_te,
float view_co_x,
bool *r_merged)
{
/* if parent_te is opened, it doesn't show children in row */
- if (!TSELEM_OPEN(TREESTORE(parent_te), soops)) {
+ if (!TSELEM_OPEN(TREESTORE(parent_te), space_outliner)) {
return outliner_find_item_at_x_in_row_recursive(parent_te, view_co_x, r_merged);
}
@@ -196,7 +197,7 @@ TreeElement *outliner_find_parent_element(ListBase *lb,
}
/* tse is not in the treestore, we use its contents to find a match */
-TreeElement *outliner_find_tse(SpaceOutliner *soops, const TreeStoreElem *tse)
+TreeElement *outliner_find_tse(SpaceOutliner *space_outliner, const TreeStoreElem *tse)
{
TreeStoreElem *tselem;
@@ -205,16 +206,16 @@ TreeElement *outliner_find_tse(SpaceOutliner *soops, const TreeStoreElem *tse)
}
/* check if 'tse' is in treestore */
- tselem = BKE_outliner_treehash_lookup_any(soops->treehash, tse->type, tse->nr, tse->id);
+ tselem = BKE_outliner_treehash_lookup_any(space_outliner->treehash, tse->type, tse->nr, tse->id);
if (tselem) {
- return outliner_find_tree_element(&soops->tree, tselem);
+ return outliner_find_tree_element(&space_outliner->tree, tselem);
}
return NULL;
}
/* Find treestore that refers to given ID */
-TreeElement *outliner_find_id(SpaceOutliner *soops, ListBase *lb, const ID *id)
+TreeElement *outliner_find_id(SpaceOutliner *space_outliner, ListBase *lb, const ID *id)
{
LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
@@ -224,7 +225,7 @@ TreeElement *outliner_find_id(SpaceOutliner *soops, ListBase *lb, const ID *id)
}
}
- TreeElement *tes = outliner_find_id(soops, &te->subtree, id);
+ TreeElement *tes = outliner_find_id(space_outliner, &te->subtree, id);
if (tes) {
return tes;
}
@@ -304,7 +305,7 @@ ID *outliner_search_back(TreeElement *te, short idcode)
* \param filter_tselem_flag: Same as \a filter_te_flag, but for the TreeStoreElem.
* \param func: Custom callback to execute for each visited item.
*/
-bool outliner_tree_traverse(const SpaceOutliner *soops,
+bool outliner_tree_traverse(const SpaceOutliner *space_outliner,
ListBase *tree,
int filter_te_flag,
int filter_tselem_flag,
@@ -337,7 +338,7 @@ bool outliner_tree_traverse(const SpaceOutliner *soops,
/* skip */
}
else if (!outliner_tree_traverse(
- soops, &subtree, filter_te_flag, filter_tselem_flag, func, customdata)) {
+ space_outliner, &subtree, filter_te_flag, filter_tselem_flag, func, customdata)) {
return false;
}
}
@@ -345,11 +346,11 @@ bool outliner_tree_traverse(const SpaceOutliner *soops,
return true;
}
-float outliner_restrict_columns_width(const SpaceOutliner *soops)
+float outliner_restrict_columns_width(const SpaceOutliner *space_outliner)
{
int num_columns = 0;
- switch (soops->outlinevis) {
+ switch (space_outliner->outlinevis) {
case SO_DATA_API:
case SO_SEQUENCE:
case SO_LIBRARIES:
@@ -358,24 +359,24 @@ float outliner_restrict_columns_width(const SpaceOutliner *soops)
num_columns = 3;
break;
case SO_VIEW_LAYER:
- if (soops->show_restrict_flags & SO_RESTRICT_HOLDOUT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_HOLDOUT) {
num_columns++;
}
- if (soops->show_restrict_flags & SO_RESTRICT_INDIRECT_ONLY) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_INDIRECT_ONLY) {
num_columns++;
}
ATTR_FALLTHROUGH;
case SO_SCENES:
- if (soops->show_restrict_flags & SO_RESTRICT_SELECT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_SELECT) {
num_columns++;
}
- if (soops->show_restrict_flags & SO_RESTRICT_HIDE) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_HIDE) {
num_columns++;
}
- if (soops->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
num_columns++;
}
- if (soops->show_restrict_flags & SO_RESTRICT_RENDER) {
+ if (space_outliner->show_restrict_flags & SO_RESTRICT_RENDER) {
num_columns++;
}
break;
@@ -459,14 +460,14 @@ Base *ED_outliner_give_base_under_cursor(bContext *C, const int mval[2])
{
ARegion *region = CTX_wm_region(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
TreeElement *te;
Base *base = NULL;
float view_mval[2];
UI_view2d_region_to_view(&region->v2d, mval[0], mval[1], &view_mval[0], &view_mval[1]);
- te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]);
+ te = outliner_find_item_at_y(space_outliner, &space_outliner->tree, view_mval[1]);
if (te) {
TreeStoreElem *tselem = TREESTORE(te);
if (tselem->type == 0) {
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index aa1663dff01..b14afed81dd 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -242,14 +242,14 @@ static void outliner_main_region_message_subscribe(const struct bContext *UNUSED
struct ARegion *region,
struct wmMsgBus *mbus)
{
- SpaceOutliner *soops = area->spacedata.first;
+ SpaceOutliner *space_outliner = area->spacedata.first;
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
.owner = region,
.user_data = region,
.notify = ED_region_do_msg_notify_tag_redraw,
};
- if (ELEM(soops->outlinevis, SO_VIEW_LAYER, SO_SCENES)) {
+ if (ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES)) {
WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_region_tag_redraw);
}
}
@@ -294,46 +294,46 @@ static void outliner_header_region_listener(wmWindow *UNUSED(win),
/* ******************** default callbacks for outliner space ***************** */
-static SpaceLink *outliner_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *outliner_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
- SpaceOutliner *soutliner;
+ SpaceOutliner *space_outliner;
- soutliner = MEM_callocN(sizeof(SpaceOutliner), "initoutliner");
- soutliner->spacetype = SPACE_OUTLINER;
- soutliner->filter_id_type = ID_GR;
- soutliner->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE;
- soutliner->outlinevis = SO_VIEW_LAYER;
- soutliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL;
- soutliner->flag |= SO_SYNC_SELECT;
+ space_outliner = MEM_callocN(sizeof(SpaceOutliner), "initoutliner");
+ space_outliner->spacetype = SPACE_OUTLINER;
+ space_outliner->filter_id_type = ID_GR;
+ space_outliner->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE;
+ space_outliner->outlinevis = SO_VIEW_LAYER;
+ space_outliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL;
+ space_outliner->flag |= SO_SYNC_SELECT;
/* header */
region = MEM_callocN(sizeof(ARegion), "header for outliner");
- BLI_addtail(&soutliner->regionbase, region);
+ BLI_addtail(&space_outliner->regionbase, region);
region->regiontype = RGN_TYPE_HEADER;
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
/* main region */
region = MEM_callocN(sizeof(ARegion), "main region for outliner");
- BLI_addtail(&soutliner->regionbase, region);
+ BLI_addtail(&space_outliner->regionbase, region);
region->regiontype = RGN_TYPE_WINDOW;
- return (SpaceLink *)soutliner;
+ return (SpaceLink *)space_outliner;
}
/* not spacelink itself */
static void outliner_free(SpaceLink *sl)
{
- SpaceOutliner *soutliner = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
- outliner_free_tree(&soutliner->tree);
- if (soutliner->treestore) {
- BLI_mempool_destroy(soutliner->treestore);
+ outliner_free_tree(&space_outliner->tree);
+ if (space_outliner->treestore) {
+ BLI_mempool_destroy(space_outliner->treestore);
}
- if (soutliner->treehash) {
- BKE_outliner_treehash_free(soutliner->treehash);
+ if (space_outliner->treehash) {
+ BKE_outliner_treehash_free(space_outliner->treehash);
}
}
@@ -344,48 +344,47 @@ static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
static SpaceLink *outliner_duplicate(SpaceLink *sl)
{
- SpaceOutliner *soutliner = (SpaceOutliner *)sl;
- SpaceOutliner *soutlinern = MEM_dupallocN(soutliner);
+ SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
+ SpaceOutliner *space_outliner_new = MEM_dupallocN(space_outliner);
- BLI_listbase_clear(&soutlinern->tree);
- soutlinern->treestore = NULL;
- soutlinern->treehash = NULL;
+ BLI_listbase_clear(&space_outliner_new->tree);
+ space_outliner_new->treestore = NULL;
+ space_outliner_new->treehash = NULL;
- soutlinern->flag |= (soutliner->flag & SO_SYNC_SELECT);
- soutlinern->sync_select_dirty = WM_OUTLINER_SYNC_SELECT_FROM_ALL;
+ space_outliner_new->sync_select_dirty = WM_OUTLINER_SYNC_SELECT_FROM_ALL;
- return (SpaceLink *)soutlinern;
+ return (SpaceLink *)space_outliner_new;
}
static void outliner_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
{
- SpaceOutliner *so = (SpaceOutliner *)slink;
+ SpaceOutliner *space_outliner = (SpaceOutliner *)slink;
/* Some early out checks. */
if (!TREESTORE_ID_TYPE(old_id)) {
return; /* ID type is not used by outilner... */
}
- if (so->search_tse.id == old_id) {
- so->search_tse.id = new_id;
+ if (space_outliner->search_tse.id == old_id) {
+ space_outliner->search_tse.id = new_id;
}
- if (so->treestore) {
+ if (space_outliner->treestore) {
TreeStoreElem *tselem;
BLI_mempool_iter iter;
bool changed = false;
- BLI_mempool_iternew(so->treestore, &iter);
+ BLI_mempool_iternew(space_outliner->treestore, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
if (tselem->id == old_id) {
tselem->id = new_id;
changed = true;
}
}
- if (so->treehash && changed) {
+ if (space_outliner->treehash && changed) {
/* rebuild hash table, because it depends on ids too */
/* postpone a full rebuild because this can be called many times on-free */
- so->storeflag |= SO_TREESTORE_REBUILD;
+ space_outliner->storeflag |= SO_TREESTORE_REBUILD;
}
}
}
@@ -393,8 +392,8 @@ static void outliner_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_i
static void outliner_deactivate(struct ScrArea *area)
{
/* Remove hover highlights */
- SpaceOutliner *soops = area->spacedata.first;
- outliner_flag_set(&soops->tree, TSE_HIGHLIGHTED, false);
+ SpaceOutliner *space_outliner = area->spacedata.first;
+ outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED, false);
ED_region_tag_redraw_no_rebuild(BKE_area_find_region_type(area, RGN_TYPE_WINDOW));
}
@@ -407,7 +406,7 @@ void ED_spacetype_outliner(void)
st->spaceid = SPACE_OUTLINER;
strncpy(st->name, "Outliner", BKE_ST_MAXNAME);
- st->new = outliner_new;
+ st->create = outliner_create;
st->free = outliner_free;
st->init = outliner_init;
st->duplicate = outliner_duplicate;
diff --git a/source/blender/editors/space_script/script_intern.h b/source/blender/editors/space_script/script_intern.h
index c6f72784b05..5d73bca350c 100644
--- a/source/blender/editors/space_script/script_intern.h
+++ b/source/blender/editors/space_script/script_intern.h
@@ -21,8 +21,7 @@
* \ingroup spscript
*/
-#ifndef __SCRIPT_INTERN_H__
-#define __SCRIPT_INTERN_H__
+#pragma once
/* internal exports only */
@@ -33,5 +32,3 @@ void script_keymap(struct wmKeyConfig *keyconf);
/* script_edit.c */
void SCRIPT_OT_reload(struct wmOperatorType *ot);
void SCRIPT_OT_python_file_run(struct wmOperatorType *ot);
-
-#endif /* __SCRIPT_INTERN_H__ */
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index 343f35421a4..4d0c2b658c6 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -51,7 +51,7 @@
/* ******************** default callbacks for script space ***************** */
-static SpaceLink *script_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *script_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceScript *sscript;
@@ -179,7 +179,7 @@ void ED_spacetype_script(void)
st->spaceid = SPACE_SCRIPT;
strncpy(st->name, "Script", BKE_ST_MAXNAME);
- st->new = script_new;
+ st->create = script_create;
st->free = script_free;
st->init = script_init;
st->duplicate = script_duplicate;
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 6202a3556a4..a35feb62c9d 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -151,7 +151,7 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type)
int proximity = INT_MAX;
if (!ed || !ed->seqbasep) {
- return 2;
+ return 1;
}
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
@@ -165,7 +165,7 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type)
if (tgt) {
return tgt->machine + 1;
}
- return 2;
+ return 1;
}
static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, int flag, int type)
@@ -581,10 +581,10 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
seq = seq_load_fn(C, ed->seqbasep, &seq_load);
if (seq) {
- sequencer_add_apply_overlap(C, op, seq);
if (seq_load.seq_sound) {
sequencer_add_apply_overlap(C, op, seq_load.seq_sound);
}
+ sequencer_add_apply_overlap(C, op, seq);
}
}
RNA_END;
@@ -594,10 +594,10 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
seq = seq_load_fn(C, ed->seqbasep, &seq_load);
if (seq) {
- sequencer_add_apply_overlap(C, op, seq);
if (seq_load.seq_sound) {
sequencer_add_apply_overlap(C, op, seq_load.seq_sound);
}
+ sequencer_add_apply_overlap(C, op, seq);
}
}
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 995e980aba0..0f4690c11d5 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1599,7 +1599,7 @@ static void sequencer_draw_display_buffer(const bContext *C,
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
}
- /* Format needs to be created prior to any immBindProgram call.
+ /* Format needs to be created prior to any immBindShader call.
* Do it here because OCIO binds it's own shader. */
eGPUTextureFormat format;
eGPUDataFormat data;
@@ -2169,7 +2169,7 @@ static void draw_cache_view(const bContext *C)
if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) {
stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HANDLE_HEIGHT);
stripe_top = stripe_bot + stripe_ht;
- float bg_color[4] = {1.0f, 0.4f, 0.2f, 0.1f};
+ const float bg_color[4] = {1.0f, 0.4f, 0.2f, 0.1f};
immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
immRectf(pos, scene->r.sfra, stripe_bot, scene->r.efra, stripe_top);
@@ -2188,7 +2188,7 @@ static void draw_cache_view(const bContext *C)
stripe_top = stripe_bot + stripe_ht;
if (scene->ed->cache_flag & SEQ_CACHE_VIEW_RAW) {
- float bg_color[4] = {1.0f, 0.1f, 0.02f, 0.1f};
+ const float bg_color[4] = {1.0f, 0.1f, 0.02f, 0.1f};
immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top);
}
@@ -2197,7 +2197,7 @@ static void draw_cache_view(const bContext *C)
stripe_top = stripe_bot + stripe_ht;
if (scene->ed->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) {
- float bg_color[4] = {0.1f, 0.1f, 0.75f, 0.1f};
+ const float bg_color[4] = {0.1f, 0.1f, 0.75f, 0.1f};
immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top);
}
@@ -2206,7 +2206,7 @@ static void draw_cache_view(const bContext *C)
stripe_bot = stripe_top - stripe_ht;
if (scene->ed->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) {
- float bg_color[4] = {1.0f, 0.6f, 0.0f, 0.1f};
+ const float bg_color[4] = {1.0f, 0.6f, 0.0f, 0.1f};
immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top);
}
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 604d2f2a108..99d4c2d9f1a 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -1000,6 +1000,7 @@ static bool sequence_offset_after_frame(Scene *scene, const int delta, const int
if (seq->startdisp >= cfra) {
BKE_sequence_translate(scene, seq, delta);
BKE_sequence_calc(scene, seq);
+ BKE_sequence_invalidate_cache_preprocessed(scene, seq);
done = true;
}
}
@@ -2150,7 +2151,7 @@ static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op)
if (BKE_sequencer_render_loop_check(seq1, last_seq) ||
BKE_sequencer_render_loop_check(seq2, last_seq) ||
BKE_sequencer_render_loop_check(seq3, last_seq)) {
- BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: recursion detected.");
+ BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: recursion detected");
return OPERATOR_CANCELLED;
}
@@ -2269,6 +2270,8 @@ static int sequencer_split_exec(bContext *C, wmOperator *op)
split_side = RNA_enum_get(op->ptr, "side");
ignore_selection = RNA_boolean_get(op->ptr, "ignore_selection");
+ BKE_sequencer_prefetch_stop(scene);
+
if (split_hard == SEQ_SPLIT_HARD) {
changed = split_seq_list(bmain,
scene,
@@ -2473,7 +2476,8 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
if (nseqbase.first) {
Sequence *seq = nseqbase.first;
- /* Rely on the nseqbase list being added at the end. */
+ /* Rely on the nseqbase list being added at the end.
+ * Their UUIDs has been re-generated by the BKE_sequence_base_dupli_recursive(), */
BLI_movelisttolist(ed->seqbasep, &nseqbase);
for (; seq; seq = seq->next) {
@@ -2515,6 +2519,8 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
+ BKE_sequencer_prefetch_stop(scene);
+
SEQP_BEGIN (scene->ed, seq) {
if (seq->flag & SELECT) {
BKE_sequencer_flag_for_removal(scene, ed->seqbasep, seq);
@@ -2843,6 +2849,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
if (seq != seqm && (seq->flag & SELECT)) {
BKE_sequence_invalidate_cache_composite(scene, seq);
channel_max = max_ii(seq->machine, channel_max);
+ /* Sequence is moved within the same edit, no need to re-generate the UUID. */
BLI_remlink(ed->seqbasep, seq);
BLI_addtail(&seqm->seqbase, seq);
}
@@ -2919,6 +2926,9 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
BKE_sequence_invalidate_cache_composite(scene, seq);
}
+ /* This moves strips from meta to parent, sating within same edit and no new strips are
+ * allocated. If the UUID was unique already (as it should) it will stay unique.
+ * No need to re-generate the UUIDs. */
BLI_movelisttolist(ed->seqbasep, &last_seq->seqbase);
BLI_listbase_clear(&last_seq->seqbase);
@@ -3258,8 +3268,15 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_sequence_base_dupli_recursive(
- scene, scene, &seqbase_clipboard, ed->seqbasep, 0, LIB_ID_CREATE_NO_USER_REFCOUNT);
+ /* NOTE: The UUID is re-generated on paste, so we can keep UUID in the clipboard since
+ * nobody can reach them anyway.
+ * This reduces chance or running out of UUIDs if a cat falls asleep on Ctrl-C. */
+ BKE_sequence_base_dupli_recursive(scene,
+ scene,
+ &seqbase_clipboard,
+ ed->seqbasep,
+ 0,
+ (LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_FREE_NO_MAIN));
seqbase_clipboard_frame = scene->r.cfra;
@@ -3317,6 +3334,8 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op))
iseq_first = nseqbase.first;
+ /* NOTE: BKE_sequence_base_dupli_recursive() takes care of generating new UUIDs for sequences
+ * in the new list. */
BLI_movelisttolist(ed->seqbasep, &nseqbase);
for (iseq = iseq_first; iseq; iseq = iseq->next) {
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index fee07e8941d..1d168866e7c 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -21,8 +21,7 @@
* \ingroup spseq
*/
-#ifndef __SEQUENCER_INTERN_H__
-#define __SEQUENCER_INTERN_H__
+#pragma once
#include "DNA_sequence_types.h"
#include "RNA_access.h"
@@ -208,5 +207,3 @@ int sequencer_image_seq_get_minmax_frame(struct wmOperator *op,
int *r_numdigits);
void sequencer_image_seq_reserve_frames(
struct wmOperator *op, struct StripElem *se, int len, int minframe, int numdigits);
-
-#endif /* __SEQUENCER_INTERN_H__ */
diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c
index 80b1c7a5194..ba573032350 100644
--- a/source/blender/editors/space_sequencer/sequencer_scopes.c
+++ b/source/blender/editors/space_sequencer/sequencer_scopes.c
@@ -730,7 +730,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf)
const float *src1 = src + 4 * (ibuf->x * y + x);
const char *p;
- memcpy(rgb, src1, 3 * sizeof(float));
+ memcpy(rgb, src1, sizeof(float[3]));
clamp_v3(rgb, 0.0f, 1.0f);
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 926752c6488..b8bb3e4d43b 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -86,7 +86,7 @@ static ARegion *sequencer_find_region(ScrArea *area, short type)
/* ******************** default callbacks for sequencer space ***************** */
-static SpaceLink *sequencer_new(const ScrArea *UNUSED(area), const Scene *scene)
+static SpaceLink *sequencer_create(const ScrArea *UNUSED(area), const Scene *scene)
{
ARegion *region;
SpaceSeq *sseq;
@@ -231,12 +231,12 @@ static void sequencer_refresh(const bContext *C, ScrArea *area)
case SEQ_VIEW_SEQUENCE:
if (region_main && (region_main->flag & RGN_FLAG_HIDDEN)) {
region_main->flag &= ~RGN_FLAG_HIDDEN;
- region_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_main->v2d.flag &= ~V2D_IS_INIT;
view_changed = true;
}
if (region_preview && !(region_preview->flag & RGN_FLAG_HIDDEN)) {
region_preview->flag |= RGN_FLAG_HIDDEN;
- region_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_preview->v2d.flag &= ~V2D_IS_INIT;
WM_event_remove_handlers((bContext *)C, &region_preview->handlers);
view_changed = true;
}
@@ -252,13 +252,13 @@ static void sequencer_refresh(const bContext *C, ScrArea *area)
case SEQ_VIEW_PREVIEW:
if (region_main && !(region_main->flag & RGN_FLAG_HIDDEN)) {
region_main->flag |= RGN_FLAG_HIDDEN;
- region_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_main->v2d.flag &= ~V2D_IS_INIT;
WM_event_remove_handlers((bContext *)C, &region_main->handlers);
view_changed = true;
}
if (region_preview && (region_preview->flag & RGN_FLAG_HIDDEN)) {
region_preview->flag &= ~RGN_FLAG_HIDDEN;
- region_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_preview->v2d.flag &= ~V2D_IS_INIT;
region_preview->v2d.cur = region_preview->v2d.tot;
view_changed = true;
}
@@ -281,13 +281,13 @@ static void sequencer_refresh(const bContext *C, ScrArea *area)
* 'full window' views before, though... Better than nothing. */
if (region_main->flag & RGN_FLAG_HIDDEN) {
region_main->flag &= ~RGN_FLAG_HIDDEN;
- region_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_main->v2d.flag &= ~V2D_IS_INIT;
region_preview->sizey = (int)(height - region_main->sizey);
view_changed = true;
}
if (region_preview->flag & RGN_FLAG_HIDDEN) {
region_preview->flag &= ~RGN_FLAG_HIDDEN;
- region_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ region_preview->v2d.flag &= ~V2D_IS_INIT;
region_preview->v2d.cur = region_preview->v2d.tot;
region_main->sizey = (int)(height - region_preview->sizey);
view_changed = true;
@@ -312,7 +312,7 @@ static void sequencer_refresh(const bContext *C, ScrArea *area)
}
if (view_changed) {
- ED_area_initialize(wm, window, area);
+ ED_area_init(wm, window, area);
ED_area_tag_redraw(area);
}
}
@@ -852,7 +852,7 @@ void ED_spacetype_sequencer(void)
st->spaceid = SPACE_SEQ;
strncpy(st->name, "Sequencer", BKE_ST_MAXNAME);
- st->new = sequencer_new;
+ st->create = sequencer_create;
st->free = sequencer_free;
st->init = sequencer_init;
st->duplicate = sequencer_duplicate;
diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c
index 34d7f8b0216..ae56b111360 100644
--- a/source/blender/editors/space_statusbar/space_statusbar.c
+++ b/source/blender/editors/space_statusbar/space_statusbar.c
@@ -42,7 +42,7 @@
/* ******************** default callbacks for statusbar space ******************** */
-static SpaceLink *statusbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *statusbar_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceStatusBar *sstatusbar;
@@ -158,7 +158,7 @@ void ED_spacetype_statusbar(void)
st->spaceid = SPACE_STATUSBAR;
strncpy(st->name, "Status Bar", BKE_ST_MAXNAME);
- st->new = statusbar_new;
+ st->create = statusbar_create;
st->free = statusbar_free;
st->init = statusbar_init;
st->duplicate = statusbar_duplicate;
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index a2af99ee9f9..f6d00ec94bf 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -53,7 +53,7 @@
/* ******************** default callbacks for text space ***************** */
-static SpaceLink *text_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *text_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceText *stext;
@@ -445,7 +445,7 @@ void ED_spacetype_text(void)
st->spaceid = SPACE_TEXT;
strncpy(st->name, "Text", BKE_ST_MAXNAME);
- st->new = text_new;
+ st->create = text_create;
st->free = text_free;
st->init = text_init;
st->duplicate = text_duplicate;
diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index 24c55e60513..74cf3c866d3 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -55,7 +55,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *region)
TextLine *tmp;
int l, x, y, w, h, i;
int tgti, *top;
- int mval[2] = {0, 0};
+ const int mval[2] = {0, 0};
if (!st || !st->text) {
return 0;
diff --git a/source/blender/editors/space_text/text_format.h b/source/blender/editors/space_text/text_format.h
index 07635e4227a..bb9574ee55e 100644
--- a/source/blender/editors/space_text/text_format.h
+++ b/source/blender/editors/space_text/text_format.h
@@ -21,8 +21,7 @@
* \ingroup sptext
*/
-#ifndef __TEXT_FORMAT_H__
-#define __TEXT_FORMAT_H__
+#pragma once
/* *** Flatten String *** */
typedef struct FlattenString {
@@ -110,5 +109,3 @@ void ED_text_format_register_pov_ini(void);
#define STR_LITERAL_STARTSWITH(str, str_literal, len_var) \
(strncmp(str, str_literal, len_var = (sizeof(str_literal) - 1)) == 0)
-
-#endif /* __TEXT_FORMAT_H__ */
diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h
index d6588dda797..abafad4c241 100644
--- a/source/blender/editors/space_text/text_intern.h
+++ b/source/blender/editors/space_text/text_intern.h
@@ -21,8 +21,7 @@
* \ingroup sptext
*/
-#ifndef __TEXT_INTERN_H__
-#define __TEXT_INTERN_H__
+#pragma once
/* internal exports only */
@@ -181,5 +180,3 @@ void TEXT_OT_autocomplete(struct wmOperatorType *ot);
/* space_text.c */
extern const char *text_context_dir[]; /* doc access */
-
-#endif /* __TEXT_INTERN_H__ */
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 6be436cffb5..201f9dae5d5 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -2587,7 +2587,7 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
{
SpaceText *st = CTX_wm_space_text(C);
TextScroll *tsc = op->customdata;
- int mval[2] = {event->x, event->y};
+ const int mval[2] = {event->x, event->y};
text_update_character_width(st);
diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c
index d06c567988d..dc357cdd355 100644
--- a/source/blender/editors/space_topbar/space_topbar.c
+++ b/source/blender/editors/space_topbar/space_topbar.c
@@ -52,7 +52,7 @@
/* ******************** default callbacks for topbar space ***************** */
-static SpaceLink *topbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+static SpaceLink *topbar_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceTopBar *stopbar;
@@ -250,7 +250,7 @@ void ED_spacetype_topbar(void)
st->spaceid = SPACE_TOPBAR;
strncpy(st->name, "Top Bar", BKE_ST_MAXNAME);
- st->new = topbar_new;
+ st->create = topbar_create;
st->free = topbar_free;
st->init = topbar_init;
st->duplicate = topbar_duplicate;
diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c
index 9eae722d5c8..0242bb4fe24 100644
--- a/source/blender/editors/space_userpref/space_userpref.c
+++ b/source/blender/editors/space_userpref/space_userpref.c
@@ -45,7 +45,7 @@
/* ******************** default callbacks for userpref space ***************** */
-static SpaceLink *userpref_new(const ScrArea *area, const Scene *UNUSED(scene))
+static SpaceLink *userpref_create(const ScrArea *area, const Scene *UNUSED(scene))
{
ARegion *region;
SpaceUserPref *spref;
@@ -115,7 +115,7 @@ static void userpref_main_region_init(wmWindowManager *wm, ARegion *region)
{
/* do not use here, the properties changed in userprefs do a system-wide refresh,
* then scroller jumps back */
- /* region->v2d.flag &= ~V2D_IS_INITIALISED; */
+ /* region->v2d.flag &= ~V2D_IS_INIT; */
region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
@@ -235,7 +235,7 @@ void ED_spacetype_userpref(void)
st->spaceid = SPACE_USERPREF;
strncpy(st->name, "Userpref", BKE_ST_MAXNAME);
- st->new = userpref_new;
+ st->create = userpref_create;
st->free = userpref_free;
st->init = userpref_init;
st->duplicate = userpref_duplicate;
diff --git a/source/blender/editors/space_userpref/userpref_intern.h b/source/blender/editors/space_userpref/userpref_intern.h
index 56930d3a231..506e93ae7ac 100644
--- a/source/blender/editors/space_userpref/userpref_intern.h
+++ b/source/blender/editors/space_userpref/userpref_intern.h
@@ -21,9 +21,6 @@
* \ingroup spuserpref
*/
-#ifndef __USERPREF_INTERN_H__
-#define __USERPREF_INTERN_H__
+#pragma once
/* internal exports only */
-
-#endif /* __USERPREF_INTERN_H__ */
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index f17d7ccd136..1ffa653372c 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -69,7 +69,7 @@ static const float cosval[CIRCLE_RESOL] = {
0.82076344, 0.91895781, 0.97952994, 1.00000000,
};
-static void circball_array_fill(float verts[CIRCLE_RESOL][3],
+static void circball_array_fill(const float verts[CIRCLE_RESOL][3],
const float cent[3],
float rad,
const float tmat[4][4])
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index c88303daa16..e5ba27cef07 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -260,7 +260,7 @@ void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *area)
/* ******************** default callbacks for view3d space ***************** */
-static SpaceLink *view3d_new(const ScrArea *UNUSED(area), const Scene *scene)
+static SpaceLink *view3d_create(const ScrArea *UNUSED(area), const Scene *scene)
{
ARegion *region;
View3D *v3d;
@@ -616,11 +616,12 @@ static void view3d_lightcache_update(bContext *C)
return;
}
- WM_operator_properties_create(&op_ptr, "SCENE_OT_light_cache_bake");
+ wmOperatorType *ot = WM_operatortype_find("SCENE_OT_light_cache_bake", true);
+ WM_operator_properties_create_ptr(&op_ptr, ot);
RNA_int_set(&op_ptr, "delay", 200);
RNA_enum_set_identifier(C, &op_ptr, "subset", "DIRTY");
- WM_operator_name_call(C, "SCENE_OT_light_cache_bake", WM_OP_INVOKE_DEFAULT, &op_ptr);
+ WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &op_ptr);
WM_operator_properties_free(&op_ptr);
}
@@ -1610,7 +1611,7 @@ void ED_spacetype_view3d(void)
st->spaceid = SPACE_VIEW3D;
strncpy(st->name, "View3D", BKE_ST_MAXNAME);
- st->new = view3d_new;
+ st->create = view3d_create;
st->free = view3d_free;
st->init = view3d_init;
st->listener = space_view3d_listener;
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index d78c58c0c64..38784a5c79e 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -1071,7 +1071,7 @@ static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d
const float lim = FLT_MAX;
for (int i = 0; i < 3; i++) {
uiBut *but;
- char text[3] = {'X' + i, ':', '\0'};
+ const char text[3] = {'X' + i, ':', '\0'};
but = uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_DIMS,
diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c
index 7e63d650409..1d5b33e7b90 100644
--- a/source/blender/editors/space_view3d/view3d_camera_control.c
+++ b/source/blender/editors/space_view3d/view3d_camera_control.c
@@ -198,6 +198,56 @@ struct View3DCameraControl *ED_view3d_cameracontrol_acquire(Depsgraph *depsgraph
}
/**
+ * A version of #BKE_object_apply_mat4 that respects #Object.protectflag,
+ * applying the locking back to the view to avoid the view.
+ * This is needed so the view doesn't get out of sync with the object,
+ * causing visible jittering when in fly/walk mode for e.g.
+ *
+ * \note This could be exposed as an API option, as we might not want the view
+ * to be constrained by the thing it's controlling.
+ */
+static bool object_apply_mat4_with_protect(Object *ob,
+ const float obmat[4][4],
+ const bool use_parent,
+ /* Only use when applying lock. */
+ RegionView3D *rv3d,
+ const float view_mat[4][4])
+{
+ const bool use_protect = (ob->protectflag != 0);
+ bool view_changed = false;
+
+ ObjectTfmProtectedChannels obtfm;
+ if (use_protect) {
+ BKE_object_tfm_protected_backup(ob, &obtfm);
+ }
+
+ BKE_object_apply_mat4(ob, obmat, true, use_parent);
+
+ if (use_protect) {
+ float obmat_noprotect[4][4], obmat_protect[4][4];
+
+ BKE_object_to_mat4(ob, obmat_noprotect);
+ BKE_object_tfm_protected_restore(ob, &obtfm, ob->protectflag);
+ BKE_object_to_mat4(ob, obmat_protect);
+
+ if (!equals_m4m4(obmat_noprotect, obmat_protect)) {
+ /* Apply the lock protection back to the view, without this the view
+ * keeps moving, ignoring the object locking, causing jittering in some cases. */
+ float diff_mat[4][4];
+ float view_mat_protect[4][4];
+ float obmat_noprotect_inv[4][4];
+ invert_m4_m4(obmat_noprotect_inv, obmat_noprotect);
+ mul_m4_m4m4(diff_mat, obmat_protect, obmat_noprotect_inv);
+
+ mul_m4_m4m4(view_mat_protect, diff_mat, view_mat);
+ ED_view3d_from_m4(view_mat_protect, rv3d->ofs, rv3d->viewquat, &rv3d->dist);
+ view_changed = true;
+ }
+ }
+ return view_changed;
+}
+
+/**
* Updates cameras from the ``rv3d`` values, optionally auto-keyframing.
*/
void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl,
@@ -216,21 +266,25 @@ void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl,
ID *id_key;
+ float view_mat[4][4];
+ ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
+
/* transform the parent or the camera? */
if (vctrl->root_parent) {
Object *ob_update;
- float view_mat[4][4];
float prev_view_imat[4][4];
float diff_mat[4][4];
float parent_mat[4][4];
invert_m4_m4(prev_view_imat, vctrl->view_mat_prev);
- ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
mul_m4_m4m4(diff_mat, view_mat, prev_view_imat);
mul_m4_m4m4(parent_mat, diff_mat, vctrl->root_parent->obmat);
- BKE_object_apply_mat4(vctrl->root_parent, parent_mat, true, false);
+ if (object_apply_mat4_with_protect(vctrl->root_parent, parent_mat, false, rv3d, view_mat)) {
+ /* Calculate again since the view locking changes the matrix. */
+ ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
+ }
ob_update = v3d->camera->parent;
while (ob_update) {
@@ -243,18 +297,16 @@ void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl,
id_key = &vctrl->root_parent->id;
}
else {
- float view_mat[4][4];
float scale_mat[4][4];
float scale_back[3];
/* even though we handle the scale matrix, this still changes over time */
copy_v3_v3(scale_back, v3d->camera->scale);
- ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
size_to_mat4(scale_mat, v3d->camera->scale);
mul_m4_m4m4(view_mat, view_mat, scale_mat);
- BKE_object_apply_mat4(v3d->camera, view_mat, true, true);
+ object_apply_mat4_with_protect(v3d->camera, view_mat, true, rv3d, view_mat);
DEG_id_tag_update(&v3d->camera->id, ID_RECALC_TRANSFORM);
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 84b3578e978..0442a0f35c9 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -36,6 +36,7 @@
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_global.h"
+#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_layer.h"
#include "BKE_main.h"
@@ -74,7 +75,6 @@
#include "GPU_batch.h"
#include "GPU_batch_presets.h"
-#include "GPU_draw.h"
#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
@@ -115,8 +115,8 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph,
const Scene *scene,
View3D *v3d,
ARegion *region,
- float viewmat[4][4],
- float winmat[4][4],
+ const float viewmat[4][4],
+ const float winmat[4][4],
const rcti *rect,
bool offscreen)
{
@@ -197,8 +197,8 @@ static void view3d_main_region_setup_view(Depsgraph *depsgraph,
Scene *scene,
View3D *v3d,
ARegion *region,
- float viewmat[4][4],
- float winmat[4][4],
+ const float viewmat[4][4],
+ const float winmat[4][4],
const rcti *rect)
{
RegionView3D *rv3d = region->regiondata;
@@ -214,8 +214,8 @@ static void view3d_main_region_setup_offscreen(Depsgraph *depsgraph,
const Scene *scene,
View3D *v3d,
ARegion *region,
- float viewmat[4][4],
- float winmat[4][4])
+ const float viewmat[4][4],
+ const float winmat[4][4])
{
RegionView3D *rv3d = region->regiondata;
ED_view3d_update_viewmat(depsgraph, scene, v3d, region, viewmat, winmat, NULL, true);
@@ -353,8 +353,8 @@ void ED_view3d_draw_setup_view(const wmWindowManager *wm,
Scene *scene,
ARegion *region,
View3D *v3d,
- float viewmat[4][4],
- float winmat[4][4],
+ const float viewmat[4][4],
+ const float winmat[4][4],
const rcti *rect)
{
RegionView3D *rv3d = region->regiondata;
@@ -668,7 +668,8 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region,
/* safety border */
if (ca) {
- immUniformThemeColorBlend(TH_VIEW_OVERLAY, TH_BACK, 0.25f);
+ GPU_blend(true);
+ immUniformThemeColorAlpha(TH_VIEW_OVERLAY, 0.75f);
if (ca->dtx & CAM_DTX_CENTER) {
float x3, y3;
@@ -778,6 +779,8 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region,
* 2.0f round corner effect was nearly not visible anyway... */
imm_draw_box_wire_2d(shdr_pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
}
+
+ GPU_blend(false);
}
immUnbindProgram();
@@ -1617,7 +1620,7 @@ void view3d_main_region_draw(const bContext *C, ARegion *region)
view3d_draw_view(C, region);
DRW_cache_free_old_batches(bmain);
- GPU_free_images_old(bmain);
+ BKE_image_free_old_gputextures(bmain);
GPU_pass_cache_garbage_collect();
/* XXX This is in order to draw UI batches with the DRW
@@ -1640,7 +1643,7 @@ static void view3d_stereo3d_setup_offscreen(Depsgraph *depsgraph,
const Scene *scene,
View3D *v3d,
ARegion *region,
- float winmat[4][4],
+ const float winmat[4][4],
const char *viewname)
{
/* update the viewport matrices with the new camera */
@@ -1667,8 +1670,8 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph,
ARegion *region,
int winx,
int winy,
- float viewmat[4][4],
- float winmat[4][4],
+ const float viewmat[4][4],
+ const float winmat[4][4],
bool is_image_render,
bool do_sky,
bool UNUSED(is_persp),
@@ -1707,7 +1710,7 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph,
{
/* free images which can have changed on frame-change
* warning! can be slow so only free animated images - campbell */
- GPU_free_images_anim(G.main); /* XXX :((( */
+ BKE_image_free_anim_gputextures(G.main); /* XXX :((( */
}
GPU_matrix_push_projection();
@@ -1759,8 +1762,8 @@ void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph,
int winx,
int winy,
uint draw_flags,
- float viewmat[4][4],
- float winmat[4][4],
+ const float viewmat[4][4],
+ const float winmat[4][4],
float clip_start,
float clip_end,
bool is_image_render,
@@ -2406,7 +2409,7 @@ struct RV3DMatrixStore *ED_view3d_mats_rv3d_backup(struct RegionView3D *rv3d)
copy_m4_m4(rv3dmat->viewinv, rv3d->viewinv);
copy_v4_v4(rv3dmat->viewcamtexcofac, rv3d->viewcamtexcofac);
rv3dmat->pixsize = rv3d->pixsize;
- return (void *)rv3dmat;
+ return rv3dmat;
}
void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat_pt)
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index bf02845058e..ac9d12cdd58 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -2500,7 +2500,10 @@ static bool viewdolly_offset_lock_check(bContext *C, wmOperator *op)
return false;
}
-static void view_dolly_to_vector_3d(ARegion *region, float orig_ofs[3], float dvec[3], float dfac)
+static void view_dolly_to_vector_3d(ARegion *region,
+ const float orig_ofs[3],
+ const float dvec[3],
+ float dfac)
{
RegionView3D *rv3d = region->regiondata;
madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, -(1.0f - dfac));
@@ -4868,7 +4871,9 @@ void VIEW3D_OT_background_image_remove(wmOperatorType *ot)
* Draw border or toggle off.
* \{ */
-static void calc_local_clipping(float clip_local[6][4], BoundBox *clipbb, float mat[4][4])
+static void calc_local_clipping(float clip_local[6][4],
+ const BoundBox *clipbb,
+ const float mat[4][4])
{
BoundBox clipbb_local;
float imat[4][4];
@@ -4883,7 +4888,7 @@ static void calc_local_clipping(float clip_local[6][4], BoundBox *clipbb, float
ED_view3d_clipping_calc_from_boundbox(clip_local, &clipbb_local, is_negative_m4(mat));
}
-void ED_view3d_clipping_local(RegionView3D *rv3d, float mat[4][4])
+void ED_view3d_clipping_local(RegionView3D *rv3d, const float mat[4][4])
{
if (rv3d->rflag & RV3D_CLIPPING) {
calc_local_clipping(rv3d->clip_local, rv3d->clipbb, mat);
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index cc19ecf35a8..556b5d51505 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -16,6 +16,10 @@
/** \file
* \ingroup spview3d
+ *
+ * Interactive fly navigation modal operator (flying around in space).
+ *
+ * \note Similar logic to `view3d_walk.c` changes here may apply there too.
*/
/* defines VIEW3D_OT_fly modal operator */
@@ -998,19 +1002,6 @@ static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm)
interp_v3_v3v3(
dvec, dvec_tmp, fly->dvec_prev, (1.0f / (1.0f + (time_redraw * FLY_SMOOTH_FAC))));
- if (rv3d->persp == RV3D_CAMOB) {
- Object *lock_ob = ED_view3d_cameracontrol_object_get(fly->v3d_camera_control);
- if (lock_ob->protectflag & OB_LOCK_LOCX) {
- dvec[0] = 0.0;
- }
- if (lock_ob->protectflag & OB_LOCK_LOCY) {
- dvec[1] = 0.0;
- }
- if (lock_ob->protectflag & OB_LOCK_LOCZ) {
- dvec[2] = 0.0;
- }
- }
-
add_v3_v3(rv3d->ofs, dvec);
if (rv3d->persp == RV3D_CAMOB) {
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 30212fcd9e5..e17993445df 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
@@ -156,7 +156,7 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int
if (eve_test) {
BMVert *vert = (BMVert *)eve_test;
float vert_p_co[3], vert_co[3];
- float mval_f[2] = {UNPACK2(vc.mval)};
+ const float mval_f[2] = {UNPACK2(vc.mval)};
mul_v3_m4v3(vert_co, gz_ele->bases[base_index_vert]->object->obmat, vert->co);
ED_view3d_project(vc.region, vert_co, vert_p_co);
float len = len_v2v2(vert_p_co, mval_f);
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index 59b2e378955..7799aba5c19 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -909,7 +909,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz)
static int gizmo_ruler_test_select(bContext *UNUSED(C), wmGizmo *gz, const int mval[2])
{
RulerItem *ruler_item_pick = (RulerItem *)gz;
- float mval_fl[2] = {UNPACK2(mval)};
+ const float mval_fl[2] = {UNPACK2(mval)};
int co_index;
/* select and drag */
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 50cd71d7edc..83707ca4383 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -21,8 +21,7 @@
* \ingroup spview3d
*/
-#ifndef __VIEW3D_INTERN_H__
-#define __VIEW3D_INTERN_H__
+#pragma once
#include "ED_view3d.h"
@@ -284,5 +283,3 @@ void VIEW3D_GGT_placement(struct wmGizmoGroupType *gzgt);
extern uchar view3d_camera_border_hack_col[3];
extern bool view3d_camera_border_hack_test;
#endif
-
-#endif /* __VIEW3D_INTERN_H__ */
diff --git a/source/blender/editors/space_view3d/view3d_placement.c b/source/blender/editors/space_view3d/view3d_placement.c
index b7219290654..a828dbc2ee0 100644
--- a/source/blender/editors/space_view3d/view3d_placement.c
+++ b/source/blender/editors/space_view3d/view3d_placement.c
@@ -246,7 +246,7 @@ static bool idp_poject_surface_normal(SnapObjectContext *snap_context,
/** \name Primitive Drawing (Cube, Cone, Cylinder...)
* \{ */
-static void draw_line_loop(float coords[][3], int coords_len, const float color[4])
+static void draw_line_loop(const float coords[][3], int coords_len, const float color[4])
{
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
@@ -279,7 +279,7 @@ static void draw_line_loop(float coords[][3], int coords_len, const float color[
GPU_blend(false);
}
-static void draw_line_pairs(float coords_a[][3],
+static void draw_line_pairs(const float coords_a[][3],
float coords_b[][3],
int coords_len,
const float color[4])
@@ -321,7 +321,7 @@ static void draw_line_bounds(const BoundBox *bounds, const float color[4])
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- int edges[12][2] = {
+ const int edges[12][2] = {
/* First side. */
{0, 1},
{1, 2},
@@ -507,7 +507,7 @@ static void draw_circle_in_quad(const float v1[2],
float theta = ((2.0f * M_PI) * ((float)i / (float)resolution)) + 0.01f;
float x = cosf(theta);
float y = sinf(theta);
- float pt[2] = {x, y};
+ const float pt[2] = {x, y};
float w[4];
barycentric_weights_v2_quad(UNPACK4(quad), pt, w);
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c
index f4ec9a22520..c790a8659ee 100644
--- a/source/blender/editors/space_view3d/view3d_project.c
+++ b/source/blender/editors/space_view3d/view3d_project.c
@@ -303,12 +303,12 @@ eV3DProjStatus ED_view3d_project_float_object(const ARegion *region,
float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
{
- return mul_project_m4_v3_zfac((float(*)[4])rv3d->persmat, co) * rv3d->pixsize * U.pixelsize;
+ return mul_project_m4_v3_zfac(rv3d->persmat, co) * rv3d->pixsize * U.pixelsize;
}
float ED_view3d_pixel_size_no_ui_scale(const RegionView3D *rv3d, const float co[3])
{
- return mul_project_m4_v3_zfac((float(*)[4])rv3d->persmat, co) * rv3d->pixsize;
+ return mul_project_m4_v3_zfac(rv3d->persmat, co) * rv3d->pixsize;
}
/**
@@ -316,7 +316,7 @@ float ED_view3d_pixel_size_no_ui_scale(const RegionView3D *rv3d, const float co[
*/
float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3], bool *r_flip)
{
- float zfac = mul_project_m4_v3_zfac((float(*)[4])rv3d->persmat, co);
+ float zfac = mul_project_m4_v3_zfac(rv3d->persmat, co);
if (r_flip) {
*r_flip = (zfac < 0.0f);
@@ -483,11 +483,11 @@ void ED_view3d_global_to_vector(const RegionView3D *rv3d, const float coord[3],
p1[3] = 1.0f;
copy_v3_v3(p2, p1);
p2[3] = 1.0f;
- mul_m4_v4((float(*)[4])rv3d->viewmat, p2);
+ mul_m4_v4(rv3d->viewmat, p2);
mul_v3_fl(p2, 2.0f);
- mul_m4_v4((float(*)[4])rv3d->viewinv, p2);
+ mul_m4_v4(rv3d->viewinv, p2);
sub_v3_v3v3(vec, p1, p2);
}
@@ -749,25 +749,26 @@ bool ED_view3d_win_to_segment_clipped(struct Depsgraph *depsgraph,
return true;
}
-/* Utility functions for projection
- * ******************************** */
+/* -------------------------------------------------------------------- */
+/** \name Utility functions for projection
+ * \{ */
-void ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, Object *ob, float pmat[4][4])
+void ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, Object *ob, float r_pmat[4][4])
{
float vmat[4][4];
- mul_m4_m4m4(vmat, (float(*)[4])rv3d->viewmat, ob->obmat);
- mul_m4_m4m4(pmat, (float(*)[4])rv3d->winmat, vmat);
+ mul_m4_m4m4(vmat, rv3d->viewmat, ob->obmat);
+ mul_m4_m4m4(r_pmat, rv3d->winmat, vmat);
}
void ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d,
- float obmat[4][4],
- float pmat[4][4])
+ const float obmat[4][4],
+ float r_pmat[4][4])
{
float vmat[4][4];
- mul_m4_m4m4(vmat, (float(*)[4])rv3d->viewmat, obmat);
- mul_m4_m4m4(pmat, (float(*)[4])rv3d->winmat, vmat);
+ mul_m4_m4m4(vmat, rv3d->viewmat, obmat);
+ mul_m4_m4m4(r_pmat, rv3d->winmat, vmat);
}
/**
@@ -777,7 +778,7 @@ void ED_view3d_project(const struct ARegion *region, const float world[3], float
{
// viewport is set up to make coordinates relative to the region, not window
RegionView3D *rv3d = region->regiondata;
- int viewport[4] = {0, 0, region->winx, region->winy};
+ const int viewport[4] = {0, 0, region->winx, region->winy};
GPU_matrix_project(world, rv3d->viewmat, rv3d->winmat, viewport, r_region_co);
}
@@ -786,8 +787,10 @@ bool ED_view3d_unproject(
const struct ARegion *region, float regionx, float regiony, float regionz, float world[3])
{
RegionView3D *rv3d = region->regiondata;
- int viewport[4] = {0, 0, region->winx, region->winy};
- float region_co[3] = {regionx, regiony, regionz};
+ const int viewport[4] = {0, 0, region->winx, region->winy};
+ const float region_co[3] = {regionx, regiony, regionz};
return GPU_matrix_unproject(region_co, rv3d->viewmat, rv3d->winmat, viewport, world);
}
+
+/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 2c8ea396a99..9490c807989 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -2112,7 +2112,7 @@ static bool ed_object_select_pick(bContext *C,
if (hits > 0) {
/* note: bundles are handling in the same way as bones */
- const bool has_bones = selectbuffer_has_bones(buffer, hits);
+ const bool has_bones = object ? false : selectbuffer_has_bones(buffer, hits);
/* note; shift+alt goes to group-flush-selecting */
if (enumerate) {
@@ -3335,12 +3335,7 @@ static int view3d_box_select_exec(bContext *C, wmOperator *op)
FOREACH_OBJECT_IN_MODE_END;
}
else { /* No edit-mode, unified for bones and objects. */
- if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) {
- /* XXX, this is not selection, could be it's own operator. */
- changed_multi = ED_sculpt_mask_box_select(
- C, &vc, &rect, sel_op == SEL_OP_ADD ? true : false);
- }
- else if (vc.obact && BKE_paint_select_face_test(vc.obact)) {
+ if (vc.obact && BKE_paint_select_face_test(vc.obact)) {
changed_multi = do_paintface_box_select(&vc, wm_userdata, &rect, sel_op);
}
else if (vc.obact && BKE_paint_select_vert_test(vc.obact)) {
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index bd2323f47f4..a264e1560c6 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -335,7 +335,7 @@ void ED_view3d_clipping_calc(
*
* \{ */
-static bool view3d_boundbox_clip_m4(const BoundBox *bb, float persmatob[4][4])
+static bool view3d_boundbox_clip_m4(const BoundBox *bb, const float persmatob[4][4])
{
int a, flag = -1, fl;
@@ -1243,7 +1243,9 @@ float ED_view3d_radius_to_dist(const View3D *v3d,
* \param fallback_dist: The distance to use if the object is too near or in front of \a ofs.
* \returns A newly calculated distance or the fallback.
*/
-float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float fallback_dist)
+float ED_view3d_offset_distance(const float mat[4][4],
+ const float ofs[3],
+ const float fallback_dist)
{
float pos[4] = {0.0f, 0.0f, 0.0f, 1.0f};
float dir[4] = {0.0f, 0.0f, 1.0f, 0.0f};
@@ -1374,11 +1376,11 @@ static float view3d_quat_axis[6][4][4] = {
};
-bool ED_view3d_quat_from_axis_view(const char view, const char view_axis_roll, float quat[4])
+bool ED_view3d_quat_from_axis_view(const char view, const char view_axis_roll, float r_quat[4])
{
BLI_assert(view_axis_roll <= RV3D_VIEW_AXIS_ROLL_270);
if (RV3D_VIEW_IS_AXIS(view)) {
- copy_qt_qt(quat, view3d_quat_axis[view - RV3D_VIEW_FRONT][view_axis_roll]);
+ copy_qt_qt(r_quat, view3d_quat_axis[view - RV3D_VIEW_FRONT][view_axis_roll]);
return true;
}
return false;
@@ -1497,7 +1499,7 @@ void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], const
*/
void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist)
{
- float iviewquat[4] = {-quat[0], quat[1], quat[2], quat[3]};
+ const float iviewquat[4] = {-quat[0], quat[1], quat[2], quat[3]};
float dvec[3] = {0.0f, 0.0f, dist};
quat_to_mat4(mat, iviewquat);
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 751e37f0235..2cc41097070 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -16,6 +16,11 @@
/** \file
* \ingroup spview3d
+ *
+ * Interactive walk navigation modal operator
+ * (similar to walking around in a first person game).
+ *
+ * \note Similar logic to `view3d_fly.c` changes here may apply there too.
*/
/* defines VIEW3D_OT_navigate - walk modal operator */
@@ -382,7 +387,7 @@ static bool walk_floor_distance_get(RegionView3D *rv3d,
const float dvec[3],
float *r_distance)
{
- float ray_normal[3] = {0, 0, -1}; /* down */
+ const float ray_normal[3] = {0, 0, -1}; /* down */
float ray_start[3];
float r_location[3];
float r_normal_dummy[3];
@@ -1295,19 +1300,6 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm)
sub_v3_v3v3(dvec, cur_loc, new_loc);
}
- if (rv3d->persp == RV3D_CAMOB) {
- Object *lock_ob = ED_view3d_cameracontrol_object_get(walk->v3d_camera_control);
- if (lock_ob->protectflag & OB_LOCK_LOCX) {
- dvec[0] = 0.0f;
- }
- if (lock_ob->protectflag & OB_LOCK_LOCY) {
- dvec[1] = 0.0f;
- }
- if (lock_ob->protectflag & OB_LOCK_LOCZ) {
- dvec[2] = 0.0f;
- }
- }
-
/* scale the movement to the scene size */
mul_v3_v3fl(dvec_tmp, dvec, walk->grid);
add_v3_v3(rv3d->ofs, dvec_tmp);
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index bbd18b4bdaf..1917d9463f4 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -21,8 +21,7 @@
* \ingroup edtransform
*/
-#ifndef __TRANSFORM_H__
-#define __TRANSFORM_H__
+#pragma once
#include "ED_numinput.h"
#include "ED_transform.h"
@@ -753,5 +752,3 @@ bool checkUseAxisMatrix(TransInfo *t);
*tc_end = (t)->data_container + (t)->data_container_len; \
th != tc_end; \
th++, i++)
-
-#endif
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 66b90eb159f..d0e37f22236 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -388,7 +388,7 @@ void transform_constraint_snap_axis_to_face(const TransInfo *t,
* Return true if the 2x axis are both aligned when projected into the view.
* In this case, we can't usefully project the cursor onto the plane.
*/
-static bool isPlaneProjectionViewAligned(const TransInfo *t, float plane[4])
+static bool isPlaneProjectionViewAligned(const TransInfo *t, const float plane[4])
{
const float eps = 0.001f;
float view_to_plane[3];
@@ -510,10 +510,12 @@ static void applyObjectConstraintVec(
else {
/* Specific TransData's space. */
copy_v3_v3(out, in);
- mul_m3_v3(t->spacemtx_inv, out);
- mul_m3_v3(td->axismtx, out);
- if (t->flag & T_EDIT) {
- mul_m3_v3(tc->mat3_unit, out);
+ if (t->con.mode & CON_APPLY) {
+ mul_m3_v3(t->spacemtx_inv, out);
+ mul_m3_v3(td->axismtx, out);
+ if (t->flag & T_EDIT) {
+ mul_m3_v3(tc->mat3_unit, out);
+ }
}
}
}
diff --git a/source/blender/editors/transform/transform_constraints.h b/source/blender/editors/transform/transform_constraints.h
index 282060af2c3..4c901842964 100644
--- a/source/blender/editors/transform/transform_constraints.h
+++ b/source/blender/editors/transform/transform_constraints.h
@@ -21,8 +21,7 @@
* \ingroup edtransform
*/
-#ifndef __TRANSFORM_CONSTRAINTS_H__
-#define __TRANSFORM_CONSTRAINTS_H__
+#pragma once
struct TransInfo;
@@ -49,5 +48,3 @@ int constraintModeToIndex(const TransInfo *t);
char constraintModeToChar(const TransInfo *t);
bool isLockConstraint(TransInfo *t);
int getConstraintSpaceDimension(TransInfo *t);
-
-#endif
diff --git a/source/blender/editors/transform/transform_convert.h b/source/blender/editors/transform/transform_convert.h
index 70017d5560b..b753572ea7b 100644
--- a/source/blender/editors/transform/transform_convert.h
+++ b/source/blender/editors/transform/transform_convert.h
@@ -22,8 +22,7 @@
* \brief conversion and adaptation of different datablocks to a common struct.
*/
-#ifndef __TRANSFORM_CONVERT_H__
-#define __TRANSFORM_CONVERT_H__
+#pragma once
struct BezTriple;
struct FCurve;
@@ -189,4 +188,3 @@ void special_aftertrans_update__sequencer(bContext *C, TransInfo *t);
void createTransTrackingData(bContext *C, TransInfo *t);
void recalcData_tracking(TransInfo *t);
void special_aftertrans_update__movieclip(bContext *C, TransInfo *t);
-#endif
diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil.c
index 0eb12aeabed..84885dd8c49 100644
--- a/source/blender/editors/transform/transform_convert_gpencil.c
+++ b/source/blender/editors/transform/transform_convert_gpencil.c
@@ -104,7 +104,7 @@ void createTransGPencil(bContext *C, TransInfo *t)
/* initialize falloff curve */
if (is_multiedit) {
- BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff);
+ BKE_curvemapping_init(ts->gp_sculpt.cur_falloff);
}
/* First Pass: Count the number of data-points required for the strokes,
diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c
index 451903f1857..573f4550fec 100644
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@ -472,7 +472,7 @@ static void editmesh_mirror_data_calc(BMEditMesh *em,
BMIter iter;
int i, flag, totvert = bm->totvert;
- vert_map = MEM_mallocN(totvert * sizeof(*vert_map), __func__);
+ vert_map = MEM_callocN(totvert * sizeof(*vert_map), __func__);
float select_sum[3] = {0};
BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
@@ -498,7 +498,8 @@ static void editmesh_mirror_data_calc(BMEditMesh *em,
uint mirror_elem_len = 0;
int *index[3] = {NULL, NULL, NULL};
- bool test_selected_only = use_select && (mirror_axis[0] + mirror_axis[1] + mirror_axis[2]) == 1;
+ bool is_single_mirror_axis = (mirror_axis[0] + mirror_axis[1] + mirror_axis[2]) == 1;
+ bool test_selected_only = use_select && is_single_mirror_axis;
for (int a = 0; a < 3; a++) {
if (!mirror_axis[a]) {
continue;
@@ -523,13 +524,23 @@ static void editmesh_mirror_data_calc(BMEditMesh *em,
if (!is_in_quadrant_v3(eve->co, quadrant, TRANSFORM_MAXDIST_MIRROR)) {
continue;
}
+ if (vert_map[i_mirr].flag != 0) {
+ /* One mirror per element.
+ * It can happen when vertices occupy the same position. */
+ continue;
+ }
vert_map[i_mirr] = (struct MirrorDataVert){i, flag};
mirror_elem_len++;
}
}
- if (mirror_elem_len) {
+ if (!mirror_elem_len) {
+ MEM_freeN(vert_map);
+ vert_map = NULL;
+ }
+ else if (!is_single_mirror_axis) {
+ /* Adjustment for elements that are mirrors of mirrored elements. */
for (int a = 0; a < 3; a++) {
if (!mirror_axis[a]) {
continue;
@@ -551,10 +562,6 @@ static void editmesh_mirror_data_calc(BMEditMesh *em,
}
}
}
- else {
- MEM_freeN(vert_map);
- vert_map = NULL;
- }
MEM_SAFE_FREE(index[0]);
MEM_SAFE_FREE(index[1]);
@@ -747,7 +754,8 @@ void createTransEditVerts(TransInfo *t)
if (tc->use_mirror_axis_any) {
bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
bool use_select = (t->flag & T_PROP_EDIT) == 0;
- bool mirror_axis[3] = {tc->use_mirror_axis_x, tc->use_mirror_axis_y, tc->use_mirror_axis_z};
+ const bool mirror_axis[3] = {
+ tc->use_mirror_axis_x, tc->use_mirror_axis_y, tc->use_mirror_axis_z};
editmesh_mirror_data_calc(em, use_select, use_topology, mirror_axis, &mirror_data);
if (mirror_data.vert_map) {
@@ -1026,8 +1034,10 @@ static void mesh_customdatacorrect_free_cb(struct TransInfo *UNUSED(t),
# define FACE_SUBSTITUTE_INDEX INT_MIN
-/* Search for a neighboring face with area and preferably without selected vertex.
- * Used to replace arealess faces in customdata correction. */
+/**
+ * Search for a neighboring face with area and preferably without selected vertex.
+ * Used to replace area-less faces in custom-data correction.
+ */
static BMFace *mesh_customdatacorrect_find_best_face_substitute(BMFace *f)
{
BMFace *best_face = NULL;
@@ -1094,10 +1104,11 @@ static BMFace *mesh_customdatacorrect_face_substitute_get(BMFace *f_copy)
#endif /* USE_FACE_SUBSTITUTE */
static void mesh_customdatacorrect_init_vert(struct TransCustomDataLayer *tcld,
- BMVert *v,
+ struct TransDataBasic *td,
const int index)
{
BMesh *bm = tcld->bm;
+ BMVert *v = td->extra;
BMIter liter;
int j, l_num;
float *loop_weights;
@@ -1149,7 +1160,7 @@ static void mesh_customdatacorrect_init_vert(struct TransCustomDataLayer *tcld,
merge_data->cd_loop_groups = NULL;
}
- BLI_ghash_insert(tcld->merge_group.origverts, v, merge_data);
+ BLI_ghash_insert(tcld->merge_group.origverts, v, td);
}
}
@@ -1243,14 +1254,12 @@ static void mesh_customdatacorrect_init_container(TransDataContainer *tc,
TransData *tob = tc->data;
for (int j = tc->data_len; j--; tob++, i++) {
- BMVert *v = tob->extra;
- mesh_customdatacorrect_init_vert(tcld, v, i);
+ mesh_customdatacorrect_init_vert(tcld, (TransDataBasic *)tob, i);
}
TransDataMirror *td_mirror = tc->data_mirror;
for (int j = tc->data_mirror_len; j--; td_mirror++, i++) {
- BMVert *v = td_mirror->extra;
- mesh_customdatacorrect_init_vert(tcld, v, i);
+ mesh_customdatacorrect_init_vert(tcld, (TransDataBasic *)td_mirror, i);
}
}
diff --git a/source/blender/editors/transform/transform_data.h b/source/blender/editors/transform/transform_data.h
index 48ed9ecf34b..bca6a99e35a 100644
--- a/source/blender/editors/transform/transform_data.h
+++ b/source/blender/editors/transform/transform_data.h
@@ -21,8 +21,7 @@
* \ingroup edtransform
*/
-#ifndef __TRANSFORM_DATA_H__
-#define __TRANSFORM_DATA_H__
+#pragma once
struct bConstraint;
struct Object;
@@ -193,5 +192,3 @@ enum {
/* Hard min/max for proportional size. */
#define T_PROP_SIZE_MIN 1e-6f
#define T_PROP_SIZE_MAX 1e12f
-
-#endif
diff --git a/source/blender/editors/transform/transform_draw_cursors.h b/source/blender/editors/transform/transform_draw_cursors.h
index e7696bad5a7..0f626c9039b 100644
--- a/source/blender/editors/transform/transform_draw_cursors.h
+++ b/source/blender/editors/transform/transform_draw_cursors.h
@@ -21,11 +21,8 @@
* \ingroup edtransform
*/
-#ifndef __TRANSFORM_DRAW_CURSORS_H__
-#define __TRANSFORM_DRAW_CURSORS_H__
+#pragma once
/* Callbacks for #WM_paint_cursor_activate */
bool transform_draw_cursor_poll(struct bContext *C);
void transform_draw_cursor_draw(struct bContext *C, int x, int y, void *customdata);
-
-#endif /* __TRANSFORM_DRAW_CURSORS_H__ */
diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c
index dacdb72806c..11cde6a9038 100644
--- a/source/blender/editors/transform/transform_gizmo_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -350,8 +350,8 @@ static void gizmo2d_xform_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup
ptr = WM_gizmo_operator_set(ggd->cage, 0, ot_translate, NULL);
RNA_boolean_set(ptr, "release_confirm", 1);
- bool constraint_x[3] = {1, 0, 0};
- bool constraint_y[3] = {0, 1, 0};
+ const bool constraint_x[3] = {1, 0, 0};
+ const bool constraint_y[3] = {0, 1, 0};
ptr = WM_gizmo_operator_set(ggd->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL);
PropertyRNA *prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm");
@@ -484,7 +484,7 @@ static void gizmo2d_xform_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
ARegion *region = CTX_wm_region(C);
GizmoGroup2D *ggd = gzgroup->customdata;
float origin[3] = {UNPACK2(ggd->origin), 0.0f};
- float origin_aa[3] = {UNPACK2(ggd->origin), 0.0f};
+ const float origin_aa[3] = {UNPACK2(ggd->origin), 0.0f};
gizmo2d_origin_to_region(region, origin);
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 3878103fa4e..6155042f555 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -2053,7 +2053,7 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmGizmoGroup
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
for (int z = 0; z < 3; z++) {
- bool constraint[3] = {x != 1, y != 1, z != 1};
+ const bool constraint[3] = {x != 1, y != 1, z != 1};
ptr = WM_gizmo_operator_set(gz, i, ot_resize, NULL);
if (prop_release_confirm == NULL) {
prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm");
diff --git a/source/blender/editors/transform/transform_gizmo_extrude_3d.c b/source/blender/editors/transform/transform_gizmo_extrude_3d.c
index 7f6f3e53bc3..ae7cda0bd03 100644
--- a/source/blender/editors/transform/transform_gizmo_extrude_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_extrude_3d.c
@@ -213,7 +213,7 @@ static void gizmo_mesh_extrude_setup(const bContext *C, wmGizmoGroup *gzgroup)
PointerRNA macroptr = RNA_pointer_get(ptr, "TRANSFORM_OT_translate");
RNA_boolean_set(&macroptr, "release_confirm", true);
- bool constraint[3] = {0, 0, 0};
+ const bool constraint[3] = {0, 0, 0};
RNA_boolean_set_array(&macroptr, "constraint_axis", constraint);
}
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 9c8d99d0d24..ce35a9f55ef 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -267,7 +267,7 @@ void setCustomPoints(TransInfo *UNUSED(t),
{
int *data;
- mi->data = MEM_reallocN(mi->data, sizeof(int) * 4);
+ mi->data = MEM_reallocN(mi->data, sizeof(int[4]));
data = mi->data;
diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c
index 38d49ab5efd..495c21bc755 100644
--- a/source/blender/editors/transform/transform_mode.c
+++ b/source/blender/editors/transform/transform_mode.c
@@ -178,7 +178,7 @@ static void protectedRotateBits(short protectflag, float eul[3], const float old
/* this function only does the delta rotation */
/* axis-angle is usually internally stored as quats... */
static void protectedAxisAngleBits(
- short protectflag, float axis[3], float *angle, float oldAxis[3], float oldAngle)
+ short protectflag, float axis[3], float *angle, const float oldAxis[3], float oldAngle)
{
/* check that protection flags are set */
if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) {
@@ -896,7 +896,7 @@ void headerResize(TransInfo *t, const float vec[3], char str[UI_MAX_DRAW_STR])
*
* \note this is a tricky area, before making changes see: T29633, T42444
*/
-static void TransMat3ToSize(float mat[3][3], float smat[3][3], float size[3])
+static void TransMat3ToSize(const float mat[3][3], const float smat[3][3], float size[3])
{
float rmat[3][3];
diff --git a/source/blender/editors/transform/transform_mode.h b/source/blender/editors/transform/transform_mode.h
index 5cda8e3063a..51aca7d551c 100644
--- a/source/blender/editors/transform/transform_mode.h
+++ b/source/blender/editors/transform/transform_mode.h
@@ -22,8 +22,7 @@
* \brief transform modes used by different operators.
*/
-#ifndef __TRANSFORM_MODE_H__
-#define __TRANSFORM_MODE_H__
+#pragma once
struct AnimData;
struct bContext;
@@ -156,4 +155,3 @@ void initTranslation(TransInfo *t);
void drawVertSlide(TransInfo *t);
void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp);
void initVertSlide(TransInfo *t);
-#endif
diff --git a/source/blender/editors/transform/transform_mode_bbone_resize.c b/source/blender/editors/transform/transform_mode_bbone_resize.c
index 2c2253630c0..80a5b307a91 100644
--- a/source/blender/editors/transform/transform_mode_bbone_resize.c
+++ b/source/blender/editors/transform/transform_mode_bbone_resize.c
@@ -87,7 +87,10 @@ static void headerBoneSize(TransInfo *t, const float vec[3], char str[UI_MAX_DRA
}
}
-static void ElementBoneSize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3])
+static void ElementBoneSize(TransInfo *t,
+ TransDataContainer *tc,
+ TransData *td,
+ const float mat[3][3])
{
float tmat[3][3], smat[3][3], oldy;
float sizemat[3][3];
diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c b/source/blender/editors/transform/transform_mode_edge_slide.c
index 4a648a77fe1..1886f95beae 100644
--- a/source/blender/editors/transform/transform_mode_edge_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_slide.c
@@ -534,7 +534,7 @@ static EdgeSlideData *createEdgeSlideVerts_double_side(TransInfo *t, TransDataCo
int sv_tot;
int *sv_table; /* BMVert -> sv_array index */
EdgeSlideData *sld = MEM_callocN(sizeof(*sld), "sld");
- float mval[2] = {(float)t->mval[0], (float)t->mval[1]};
+ const float mval[2] = {(float)t->mval[0], (float)t->mval[1]};
int numsel, i, loop_nr;
bool use_occlude_geometry = false;
View3D *v3d = NULL;
@@ -894,7 +894,7 @@ static EdgeSlideData *createEdgeSlideVerts_single_side(TransInfo *t, TransDataCo
int sv_tot;
int *sv_table; /* BMVert -> sv_array index */
EdgeSlideData *sld = MEM_callocN(sizeof(*sld), "sld");
- float mval[2] = {(float)t->mval[0], (float)t->mval[1]};
+ const float mval[2] = {(float)t->mval[0], (float)t->mval[1]};
int loop_nr;
bool use_occlude_geometry = false;
View3D *v3d = NULL;
diff --git a/source/blender/editors/transform/transform_mode_shear.c b/source/blender/editors/transform/transform_mode_shear.c
index fa33c1550e7..e508a1fa4c2 100644
--- a/source/blender/editors/transform/transform_mode_shear.c
+++ b/source/blender/editors/transform/transform_mode_shear.c
@@ -164,7 +164,7 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- const float *center, *co;
+ const float *center;
if (td->flag & TD_SKIP) {
continue;
}
@@ -178,19 +178,15 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
if (is_local_center) {
center = td->center;
- co = td->loc;
}
else {
center = tc->center_local;
- co = td->center;
}
- sub_v3_v3v3(vec, co, center);
-
+ sub_v3_v3v3(vec, td->iloc, center);
mul_m3_v3(tmat, vec);
-
add_v3_v3(vec, center);
- sub_v3_v3(vec, co);
+ sub_v3_v3(vec, td->iloc);
if (t->options & CTX_GPENCIL_STROKES) {
/* grease pencil multiframe falloff */
diff --git a/source/blender/editors/transform/transform_mode_vert_slide.c b/source/blender/editors/transform/transform_mode_vert_slide.c
index b396317ba7c..38537194af3 100644
--- a/source/blender/editors/transform/transform_mode_vert_slide.c
+++ b/source/blender/editors/transform/transform_mode_vert_slide.c
@@ -126,7 +126,7 @@ static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2])
{
/* Active object may have no selected vertices. */
VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
- float mval_fl[2] = {UNPACK2(mval)};
+ const float mval_fl[2] = {UNPACK2(mval)};
TransDataVertSlideVert *sv;
/* set the vertex to use as a reference for the mouse direction 'curr_sv_index' */
@@ -153,8 +153,8 @@ static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2])
static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2])
{
VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
- float imval_fl[2] = {UNPACK2(t->mouse.imval)};
- float mval_fl[2] = {UNPACK2(mval)};
+ const float imval_fl[2] = {UNPACK2(t->mouse.imval)};
+ const float mval_fl[2] = {UNPACK2(mval)};
float dir[3];
TransDataVertSlideVert *sv;
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 493b52495db..e805743e6bb 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -467,14 +467,14 @@ short ED_transform_calc_orientation_from_type_ex(const bContext *C,
return V3D_ORIENT_GLOBAL;
}
case V3D_ORIENT_GIMBAL: {
- if (gimbal_axis(ob, r_mat)) {
+ if (ob && gimbal_axis(ob, r_mat)) {
return V3D_ORIENT_GIMBAL;
}
/* if not gimbal, fall through to normal */
ATTR_FALLTHROUGH;
}
case V3D_ORIENT_NORMAL: {
- if (obedit || ob->mode & OB_MODE_POSE) {
+ if (obedit || (ob && ob->mode & OB_MODE_POSE)) {
ED_getTransformOrientationMatrix(C, r_mat, pivot_point);
return V3D_ORIENT_NORMAL;
}
diff --git a/source/blender/editors/transform/transform_snap.h b/source/blender/editors/transform/transform_snap.h
index 688661bc2cb..b97a9dc882c 100644
--- a/source/blender/editors/transform/transform_snap.h
+++ b/source/blender/editors/transform/transform_snap.h
@@ -18,8 +18,7 @@
* \ingroup editors
*/
-#ifndef __TRANSFORM_SNAP_H__
-#define __TRANSFORM_SNAP_H__
+#pragma once
#define SNAP_MIN_DISTANCE 30
@@ -88,5 +87,3 @@ eRedrawFlag updateSelectedSnapPoint(TransInfo *t);
void removeSnapPoint(TransInfo *t);
float transform_snap_distance_len_squared_fn(TransInfo *t, const float p1[3], const float p2[3]);
-
-#endif /* __TRANSFORM_SNAP_H__ */
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index eb14c5bec28..50b7c6d147b 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -1214,7 +1214,7 @@ static void cb_mlooptri_edges_get(const int index, int v_index[3], const BVHTree
const MLoopTri *lt = &data->looptri[index];
for (int j = 2, j_next = 0; j_next < 3; j = j_next++) {
const MEdge *ed = &medge[mloop[lt->tri[j]].e];
- uint tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v};
+ const uint tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v};
if (ELEM(ed->v1, tri_edge[0], tri_edge[1]) && ELEM(ed->v2, tri_edge[0], tri_edge[1])) {
// printf("real edge found\n");
v_index[j] = mloop[lt->tri[j]].e;
@@ -1302,11 +1302,11 @@ static bool test_projected_edge_dist(const struct DistProjectedAABBPrecalc *prec
* \{ */
typedef void (*Nearest2DGetVertCoCallback)(const int index, const float **co, void *data);
-typedef void (*Nearest2DGetEdgeVertsCallback)(const int index, int v_index[2], void *data);
-typedef void (*Nearest2DGetTriVertsCallback)(const int index, int v_index[3], void *data);
+typedef void (*Nearest2DGetEdgeVertsCallback)(const int index, const int v_index[2], void *data);
+typedef void (*Nearest2DGetTriVertsCallback)(const int index, const int v_index[3], void *data);
/* Equal the previous one */
-typedef void (*Nearest2DGetTriEdgesCallback)(const int index, int e_index[3], void *data);
-typedef void (*Nearest2DCopyVertNoCallback)(const int index, float r_no[3], void *data);
+typedef void (*Nearest2DGetTriEdgesCallback)(const int index, const int e_index[3], void *data);
+typedef void (*Nearest2DCopyVertNoCallback)(const int index, const float r_no[3], void *data);
typedef struct Nearest2dUserData {
void *userdata;
diff --git a/source/blender/editors/undo/undo_intern.h b/source/blender/editors/undo/undo_intern.h
index 8184e7bfbdc..660f1a5b57d 100644
--- a/source/blender/editors/undo/undo_intern.h
+++ b/source/blender/editors/undo/undo_intern.h
@@ -18,8 +18,7 @@
* \ingroup edundo
*/
-#ifndef __UNDO_INTERN_H__
-#define __UNDO_INTERN_H__
+#pragma once
/* internal exports only */
@@ -27,5 +26,3 @@ struct UndoType;
/* memfile_undo.c */
void ED_memfile_undosys_type(struct UndoType *ut);
-
-#endif /* __UNDO_INTERN_H__ */
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index f48ea610345..207606c2dcd 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -63,7 +63,6 @@ set(SRC
../include/ED_keyframes_edit.h
../include/ED_keyframing.h
../include/ED_lattice.h
- ../include/ED_logic.h
../include/ED_markers.h
../include/ED_mask.h
../include/ED_mball.h
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index dad0b96c5e2..93762e6500c 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -58,7 +58,6 @@
#include "DEG_depsgraph.h"
#include "ED_armature.h"
-#include "ED_buttons.h"
#include "ED_image.h"
#include "ED_mesh.h"
#include "ED_node.h"
diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h
index d4f284a1619..5a510aaf945 100644
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@ -21,8 +21,7 @@
* \ingroup eduv
*/
-#ifndef __UVEDIT_INTERN_H__
-#define __UVEDIT_INTERN_H__
+#pragma once
struct BMFace;
struct BMLoop;
@@ -34,7 +33,6 @@ struct wmOperatorType;
/* geometric utilities */
void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy, int len);
-void uv_poly_center(struct BMFace *f, float r_cent[2], const int cd_loop_uv_offset);
/* find nearest */
@@ -88,6 +86,15 @@ bool uv_find_nearest_face_multi(struct Scene *scene,
const float co[2],
struct UvNearestHit *hit_final);
+BMLoop *uv_find_nearest_loop_from_vert(struct Scene *scene,
+ struct Object *obedit,
+ struct BMVert *v,
+ const float co[2]);
+BMLoop *uv_find_nearest_loop_from_edge(struct Scene *scene,
+ struct Object *obedit,
+ struct BMEdge *e,
+ const float co[2]);
+
/* utility tool functions */
void uvedit_live_unwrap_update(struct SpaceImage *sima,
@@ -138,5 +145,3 @@ void UV_OT_select_circle(struct wmOperatorType *ot);
void UV_OT_select_more(struct wmOperatorType *ot);
void UV_OT_select_less(struct wmOperatorType *ot);
void UV_OT_select_overlap(struct wmOperatorType *ot);
-
-#endif /* __UVEDIT_INTERN_H__ */
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index ad98321c458..d3d8c58829b 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -227,22 +227,6 @@ void uvedit_live_unwrap_update(SpaceImage *sima, Scene *scene, Object *obedit)
/** \name Geometric Utilities
* \{ */
-void uv_poly_center(BMFace *f, float r_cent[2], const int cd_loop_uv_offset)
-{
- BMLoop *l;
- MLoopUV *luv;
- BMIter liter;
-
- zero_v2(r_cent);
-
- BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- add_v2_v2(r_cent, luv->uv);
- }
-
- mul_v2_fl(r_cent, 1.0f / (float)f->len);
-}
-
void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy, int len)
{
int i;
@@ -2109,7 +2093,7 @@ void ED_operatormacros_uvedit(void)
ot = WM_operatortype_append_macro("UV_OT_rip_move",
"UV Rip Move",
- "unstitch UV's and move the result",
+ "Unstitch UV's and move the result",
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "UV_OT_rip");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index a4ee9a294fe..dd422f2443a 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -497,7 +497,7 @@ static void p_chart_uv_translate(PChart *chart, const float trans[2])
}
}
-static void p_chart_uv_transform(PChart *chart, float mat[2][2])
+static void p_chart_uv_transform(PChart *chart, const float mat[2][2])
{
PVert *v;
@@ -1498,10 +1498,10 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent
float(*oldpoints)[2], (*newpoints)[2], *p1, *p2;
size = npoints * 3;
- oldpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonOldPoints");
- newpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonNewPoints");
+ oldpoints = MEM_mallocN(sizeof(float[2]) * size, "PPolygonOldPoints");
+ newpoints = MEM_mallocN(sizeof(float[2]) * size, "PPolygonNewPoints");
- memcpy(oldpoints, points, sizeof(float) * 2 * npoints);
+ memcpy(oldpoints, points, sizeof(float[2]) * npoints);
for (i = 0; i < npoints; i++) {
p1 = points[i];
@@ -1510,7 +1510,7 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent
if (nnewpoints == 0) {
/* degenerate case, use center of original polygon */
- memcpy(oldpoints, points, sizeof(float) * 2 * npoints);
+ memcpy(oldpoints, points, sizeof(float[2]) * npoints);
nnewpoints = npoints;
break;
}
@@ -1528,10 +1528,10 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent
if (nnewpoints * 2 > size) {
size *= 2;
MEM_freeN(oldpoints);
- oldpoints = MEM_mallocN(sizeof(float) * 2 * size, "oldpoints");
- memcpy(oldpoints, newpoints, sizeof(float) * 2 * nnewpoints);
+ oldpoints = MEM_mallocN(sizeof(float[2]) * size, "oldpoints");
+ memcpy(oldpoints, newpoints, sizeof(float[2]) * nnewpoints);
MEM_freeN(newpoints);
- newpoints = MEM_mallocN(sizeof(float) * 2 * size, "newpoints");
+ newpoints = MEM_mallocN(sizeof(float[2]) * size, "newpoints");
}
else {
float(*sw_points)[2] = oldpoints;
@@ -1687,7 +1687,7 @@ static void p_vert_harmonic_insert(PVert *v)
npoints++;
}
- points = MEM_mallocN(sizeof(float) * 2 * npoints, "PHarmonicPoints");
+ points = MEM_mallocN(sizeof(float[2]) * npoints, "PHarmonicPoints");
e = v->edge;
i = 0;
@@ -2427,7 +2427,7 @@ static void p_abf_setup_system(PAbfSystem *sys)
sys->bAlpha = (float *)MEM_mallocN(sizeof(float) * sys->nangles, "ABFbalpha");
sys->bTriangle = (float *)MEM_mallocN(sizeof(float) * sys->nfaces, "ABFbtriangle");
- sys->bInterior = (float *)MEM_mallocN(sizeof(float) * 2 * sys->ninterior, "ABFbinterior");
+ sys->bInterior = (float *)MEM_mallocN(sizeof(float[2]) * sys->ninterior, "ABFbinterior");
sys->lambdaTriangle = (float *)MEM_callocN(sizeof(float) * sys->nfaces, "ABFlambdatri");
sys->lambdaPlanar = (float *)MEM_callocN(sizeof(float) * sys->ninterior, "ABFlamdaplane");
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h
index 53188ea42bb..ee1eb4f63bf 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.h
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __UVEDIT_PARAMETRIZER_H__
-#define __UVEDIT_PARAMETRIZER_H__
+#pragma once
/** \file
* \ingroup eduv
@@ -109,5 +108,3 @@ void param_flush_restore(ParamHandle *handle);
#ifdef __cplusplus
}
#endif
-
-#endif /*__UVEDIT_PARAMETRIZER_H__*/
diff --git a/source/blender/editors/uvedit/uvedit_path.c b/source/blender/editors/uvedit/uvedit_path.c
index 1c7da7af0f4..546aad078aa 100644
--- a/source/blender/editors/uvedit/uvedit_path.c
+++ b/source/blender/editors/uvedit/uvedit_path.c
@@ -69,9 +69,6 @@
#include "bmesh_tools.h"
-/* TODO(campbell): region filling, matching mesh selection. */
-#define USE_FILL
-
/* -------------------------------------------------------------------- */
/** \name Local Utilities
* \{ */
@@ -84,8 +81,12 @@
*
* While the code below is a bit awkward, it's significantly less overhead than
* adding full edge selection which is nearly the same as vertex path in the case of UV's.
+ *
+ * \param use_nearest: When false use the post distant pair of loops,
+ * use when filling a region as we want both verts from each edge to be included in the region.
*/
-static void bm_loop_calc_vert_pair_from_edge_pair(const int cd_loop_uv_offset,
+static void bm_loop_calc_vert_pair_from_edge_pair(const bool use_nearest,
+ const int cd_loop_uv_offset,
const float aspect_y,
BMElem **ele_src_p,
BMElem **ele_dst_p,
@@ -116,8 +117,15 @@ static void bm_loop_calc_vert_pair_from_edge_pair(const int cd_loop_uv_offset,
};
int i_best = 0;
for (int i = 1; i < ARRAY_SIZE(tests); i++) {
- if (tests[i].len_sq < tests[i_best].len_sq) {
- i_best = i;
+ if (use_nearest) {
+ if (tests[i].len_sq < tests[i_best].len_sq) {
+ i_best = i;
+ }
+ }
+ else {
+ if (tests[i].len_sq > tests[i_best].len_sq) {
+ i_best = i;
+ }
}
}
@@ -139,14 +147,13 @@ struct PathSelectParams {
bool track_active;
bool use_topology_distance;
bool use_face_step;
-#ifdef USE_FILL
bool use_fill;
-#endif
struct CheckerIntervalParams interval_params;
};
struct UserData_UV {
Scene *scene;
+ BMEditMesh *em;
uint cd_loop_uv_offset;
};
@@ -162,13 +169,11 @@ static void path_select_properties(wmOperatorType *ot)
false,
"Topology Distance",
"Find the minimum number of steps, ignoring spatial distance");
-#ifdef USE_FILL
RNA_def_boolean(ot->srna,
"use_fill",
false,
"Fill Region",
"Select all paths between the source/destination elements");
-#endif
WM_operator_properties_checker_interval(ot, true);
}
@@ -177,9 +182,7 @@ static void path_select_params_from_op(wmOperator *op, struct PathSelectParams *
{
op_params->track_active = false;
op_params->use_face_step = RNA_boolean_get(op->ptr, "use_face_step");
-#ifdef USE_FILL
op_params->use_fill = RNA_boolean_get(op->ptr, "use_fill");
-#endif
op_params->use_topology_distance = RNA_boolean_get(op->ptr, "use_topology_distance");
WM_operator_properties_checker_interval_from_op(op, &op_params->interval_params);
}
@@ -200,6 +203,7 @@ static bool looptag_test_cb(BMLoop *l, void *user_data_v)
{
/* All connected loops are selected or we return false. */
struct UserData_UV *user_data = user_data_v;
+ const Scene *scene = user_data->scene;
const uint cd_loop_uv_offset = user_data->cd_loop_uv_offset;
const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
BMIter iter;
@@ -208,7 +212,7 @@ static bool looptag_test_cb(BMLoop *l, void *user_data_v)
if (looptag_filter_cb(l_iter, user_data)) {
const MLoopUV *luv_iter = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset);
if (equals_v2v2(luv->uv, luv_iter->uv)) {
- if ((luv_iter->flag & MLOOPUV_VERTSEL) == 0) {
+ if (!uvedit_uv_select_test(scene, l_iter, cd_loop_uv_offset)) {
return false;
}
}
@@ -219,6 +223,8 @@ static bool looptag_test_cb(BMLoop *l, void *user_data_v)
static void looptag_set_cb(BMLoop *l, bool val, void *user_data_v)
{
struct UserData_UV *user_data = user_data_v;
+ const Scene *scene = user_data->scene;
+ BMEditMesh *em = user_data->em;
const uint cd_loop_uv_offset = user_data->cd_loop_uv_offset;
const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
BMIter iter;
@@ -227,28 +233,56 @@ static void looptag_set_cb(BMLoop *l, bool val, void *user_data_v)
if (looptag_filter_cb(l_iter, user_data)) {
MLoopUV *luv_iter = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset);
if (equals_v2v2(luv->uv, luv_iter->uv)) {
- SET_FLAG_FROM_TEST(luv_iter->flag, val, MLOOPUV_VERTSEL);
+ uvedit_uv_select_set(scene, em, l_iter, val, false, cd_loop_uv_offset);
}
}
}
}
-static void mouse_mesh_uv_shortest_path_vert(Scene *scene,
- Object *obedit,
- const struct PathSelectParams *op_params,
- BMLoop *l_src,
- BMLoop *l_dst,
- BMLoop *l_dst_add_to_path,
- const float aspect_y,
- const int cd_loop_uv_offset)
+static int mouse_mesh_uv_shortest_path_vert(Scene *scene,
+ Object *obedit,
+ const struct PathSelectParams *op_params,
+ BMLoop *l_src,
+ BMLoop *l_dst,
+ const float aspect_y,
+ const int cd_loop_uv_offset)
{
- const ToolSettings *ts = scene->toolsettings;
- const bool use_fake_edge_select = (ts->uv_selectmode & UV_SELECT_EDGE);
+ const char uv_selectmode = ED_uvedit_select_mode_get(scene);
+ const bool use_fake_edge_select = (uv_selectmode & UV_SELECT_EDGE);
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMesh *bm = em->bm;
+ int flush = 0;
+
+ /* Variables to use when `use_fake_edge_select` is set. */
+ struct {
+ BMLoop *l_dst_activate;
+ BMLoop *l_dst_add_to_path;
+ } fake_edge_select = {NULL};
+
+ if (use_fake_edge_select) {
+ fake_edge_select.l_dst_activate = l_dst;
+
+ /* Use most distant when doing region selection.
+ * without this we get dangling edges outside the region. */
+ bool use_neaerst = (op_params->use_fill == false);
+ BMElem *ele_src = (BMElem *)l_src;
+ BMElem *ele_dst = (BMElem *)l_dst;
+ BMElem *ele_dst_final = NULL;
+ bm_loop_calc_vert_pair_from_edge_pair(
+ use_neaerst, cd_loop_uv_offset, aspect_y, &ele_src, &ele_dst, &ele_dst_final);
+
+ if (op_params->use_fill == false) {
+ /* Always activate the item under the cursor. */
+ fake_edge_select.l_dst_add_to_path = (BMLoop *)ele_dst_final;
+ }
+
+ l_src = (BMLoop *)ele_src;
+ l_dst = (BMLoop *)ele_dst;
+ }
struct UserData_UV user_data = {
.scene = scene,
+ .em = em,
.cd_loop_uv_offset = cd_loop_uv_offset,
};
@@ -280,11 +314,14 @@ static void mouse_mesh_uv_shortest_path_vert(Scene *scene,
BMLoop *l_dst_last = l_dst;
if (path) {
- if ((l_dst_add_to_path != NULL) && (BLI_linklist_index(path, l_dst_add_to_path) == -1)) {
- /* Append, this isn't optimal compared to #BLI_linklist_append, it's a one-off lookup. */
- LinkNode *path_last = BLI_linklist_find_last(path);
- BLI_linklist_insert_after(&path_last, l_dst_add_to_path);
- BLI_assert(BLI_linklist_find_last(path)->link == l_dst_add_to_path);
+ if (use_fake_edge_select) {
+ if ((fake_edge_select.l_dst_add_to_path != NULL) &&
+ (BLI_linklist_index(path, fake_edge_select.l_dst_add_to_path) == -1)) {
+ /* Append, this isn't optimal compared to #BLI_linklist_append, it's a one-off lookup. */
+ LinkNode *path_last = BLI_linklist_find_last(path);
+ BLI_linklist_insert_after(&path_last, fake_edge_select.l_dst_add_to_path);
+ BLI_assert(BLI_linklist_find_last(path)->link == fake_edge_select.l_dst_add_to_path);
+ }
}
/* toggle the flag */
@@ -310,6 +347,7 @@ static void mouse_mesh_uv_shortest_path_vert(Scene *scene,
} while ((void)depth++, (node = node->next));
BLI_linklist_free(path, NULL);
+ flush = all_set ? -1 : 1;
}
else {
const bool is_act = !looptag_test_cb(l_dst, &user_data);
@@ -319,12 +357,17 @@ static void mouse_mesh_uv_shortest_path_vert(Scene *scene,
if (op_params->track_active) {
/* Fake edge selection. */
if (use_fake_edge_select) {
- ED_uvedit_active_edge_loop_set(bm, l_dst_last);
+ BMLoop *l_dst_activate = fake_edge_select.l_dst_activate;
+ /* TODO(campbell): Search for an active loop attached to 'l_dst'.
+ * when `BLI_linklist_index(path, l_dst_activate) == -1`
+ * In practice this rarely happens though. */
+ ED_uvedit_active_edge_loop_set(bm, l_dst_activate);
}
else {
ED_uvedit_active_vert_loop_set(bm, l_dst_last);
}
}
+ return flush;
}
/** \} */
@@ -343,12 +386,12 @@ static bool facetag_test_cb(BMFace *f, void *user_data_v)
{
/* All connected loops are selected or we return false. */
struct UserData_UV *user_data = user_data_v;
+ const Scene *scene = user_data->scene;
const uint cd_loop_uv_offset = user_data->cd_loop_uv_offset;
BMIter iter;
BMLoop *l_iter;
BM_ITER_ELEM (l_iter, &iter, f, BM_LOOPS_OF_FACE) {
- const MLoopUV *luv_iter = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset);
- if ((luv_iter->flag & MLOOPUV_VERTSEL) == 0) {
+ if (!uvedit_uv_select_test(scene, l_iter, cd_loop_uv_offset)) {
return false;
}
}
@@ -357,28 +400,27 @@ static bool facetag_test_cb(BMFace *f, void *user_data_v)
static void facetag_set_cb(BMFace *f, bool val, void *user_data_v)
{
struct UserData_UV *user_data = user_data_v;
+ const Scene *scene = user_data->scene;
+ BMEditMesh *em = user_data->em;
const uint cd_loop_uv_offset = user_data->cd_loop_uv_offset;
- BMIter iter;
- BMLoop *l_iter;
- BM_ITER_ELEM (l_iter, &iter, f, BM_LOOPS_OF_FACE) {
- MLoopUV *luv_iter = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset);
- SET_FLAG_FROM_TEST(luv_iter->flag, val, MLOOPUV_VERTSEL);
- }
+ uvedit_face_select_set(scene, em, f, val, false, cd_loop_uv_offset);
}
-static void mouse_mesh_uv_shortest_path_face(Scene *scene,
- Object *obedit,
- const struct PathSelectParams *op_params,
- BMFace *f_src,
- BMFace *f_dst,
- const float aspect_y,
- const int cd_loop_uv_offset)
+static int mouse_mesh_uv_shortest_path_face(Scene *scene,
+ Object *obedit,
+ const struct PathSelectParams *op_params,
+ BMFace *f_src,
+ BMFace *f_dst,
+ const float aspect_y,
+ const int cd_loop_uv_offset)
{
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMesh *bm = em->bm;
+ int flush = 0;
struct UserData_UV user_data = {
.scene = scene,
+ .em = em,
.cd_loop_uv_offset = cd_loop_uv_offset,
};
@@ -433,6 +475,7 @@ static void mouse_mesh_uv_shortest_path_face(Scene *scene,
} while ((void)depth++, (node = node->next));
BLI_linklist_free(path, NULL);
+ flush = all_set ? -1 : 1;
}
else {
const bool is_act = !facetag_test_cb(f_dst, &user_data);
@@ -443,6 +486,7 @@ static void mouse_mesh_uv_shortest_path_face(Scene *scene,
/* Unlike other types, we can track active without it being selected. */
BM_mesh_active_face_set(bm, f_dst_last);
}
+ return flush;
}
/** \} */
@@ -462,44 +506,56 @@ static bool uv_shortest_path_pick_ex(Scene *scene,
const float aspect_y,
const int cd_loop_uv_offset)
{
+ const ToolSettings *ts = scene->toolsettings;
+ const char uv_selectmode = ED_uvedit_select_mode_get(scene);
bool ok = false;
+ int flush = 0;
if (ELEM(NULL, ele_src, ele_dst) || (ele_src->head.htype != ele_dst->head.htype)) {
/* pass */
}
else if (ele_src->head.htype == BM_FACE) {
- mouse_mesh_uv_shortest_path_face(scene,
- obedit,
- op_params,
- (BMFace *)ele_src,
- (BMFace *)ele_dst,
- aspect_y,
- cd_loop_uv_offset);
+ flush = mouse_mesh_uv_shortest_path_face(scene,
+ obedit,
+ op_params,
+ (BMFace *)ele_src,
+ (BMFace *)ele_dst,
+ aspect_y,
+ cd_loop_uv_offset);
ok = true;
}
else if (ele_src->head.htype == BM_LOOP) {
- const ToolSettings *ts = scene->toolsettings;
- BMElem *ele_dst_final = NULL;
- if (ts->uv_selectmode & UV_SELECT_EDGE) {
- if (op_params->use_fill == false) {
- bm_loop_calc_vert_pair_from_edge_pair(
- cd_loop_uv_offset, aspect_y, &ele_src, &ele_dst, &ele_dst_final);
- }
- }
- mouse_mesh_uv_shortest_path_vert(scene,
- obedit,
- op_params,
- (BMLoop *)ele_src,
- (BMLoop *)ele_dst,
- (BMLoop *)ele_dst_final,
- aspect_y,
- cd_loop_uv_offset);
+ flush = mouse_mesh_uv_shortest_path_vert(scene,
+ obedit,
+ op_params,
+ (BMLoop *)ele_src,
+ (BMLoop *)ele_dst,
+ aspect_y,
+ cd_loop_uv_offset);
ok = true;
}
if (ok) {
- Object *obedit_eval = DEG_get_evaluated_object(depsgraph, obedit);
- BKE_mesh_batch_cache_dirty_tag(obedit_eval->data, BKE_MESH_BATCH_DIRTY_UVEDIT_SELECT);
+ if (flush != 0) {
+ const bool select = (flush == 1);
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ if (uv_selectmode & UV_SELECT_EDGE) {
+ /* Special case as we don't use true edge selection,
+ * flush the selection from the vertices. */
+ BM_mesh_select_mode_flush_ex(em->bm, SCE_SELECT_VERTEX);
+ }
+ }
+ ED_uvedit_select_sync_flush(scene->toolsettings, em, select);
+ }
+
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
+ }
+ else {
+ Object *obedit_eval = DEG_get_evaluated_object(depsgraph, obedit);
+ BKE_mesh_batch_cache_dirty_tag(obedit_eval->data, BKE_MESH_BATCH_DIRTY_UVEDIT_SELECT);
+ }
/* Only for region redraw. */
WM_main_add_notifier(NC_GEOM | ND_SELECT, obedit->data);
}
@@ -511,13 +567,9 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve
{
Scene *scene = CTX_data_scene(C);
const ToolSettings *ts = scene->toolsettings;
+ const char uv_selectmode = ED_uvedit_select_mode_get(scene);
/* We could support this, it needs further testing. */
- if (ts->uv_flag & UV_SYNC_SELECTION) {
- BKE_report(op->reports, RPT_ERROR, "Sync selection doesn't support path select");
- return OPERATOR_CANCELLED;
- }
-
if (RNA_struct_property_is_set(op->ptr, "index")) {
return uv_shortest_path_pick_exec(C, op);
}
@@ -550,7 +602,7 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve
BMElem *ele_src = NULL, *ele_dst = NULL;
- if (ts->uv_selectmode & UV_SELECT_FACE) {
+ if (uv_selectmode == UV_SELECT_FACE) {
UvNearestHit hit = UV_NEAREST_HIT_INIT;
if (!uv_find_nearest_face(scene, obedit, co, &hit)) {
return OPERATOR_CANCELLED;
@@ -562,21 +614,30 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve
ele_src = (BMElem *)f_src;
ele_dst = (BMElem *)hit.efa;
}
- else if (ts->uv_selectmode & UV_SELECT_EDGE) {
+
+ else if (uv_selectmode & UV_SELECT_EDGE) {
UvNearestHit hit = UV_NEAREST_HIT_INIT;
if (!uv_find_nearest_edge(scene, obedit, co, &hit)) {
return OPERATOR_CANCELLED;
}
- BMLoop *l_src = ED_uvedit_active_edge_loop_get(bm);
- if (l_src != NULL) {
- const MLoopUV *luv_src_v1 = BM_ELEM_CD_GET_VOID_P(l_src, cd_loop_uv_offset);
- const MLoopUV *luv_src_v2 = BM_ELEM_CD_GET_VOID_P(l_src->next, cd_loop_uv_offset);
- if ((luv_src_v1->flag & MLOOPUV_VERTSEL) == 0 && (luv_src_v2->flag & MLOOPUV_VERTSEL) == 0) {
- l_src = NULL;
+ BMLoop *l_src = NULL;
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ BMEdge *e_src = BM_mesh_active_edge_get(bm);
+ if (e_src != NULL) {
+ l_src = uv_find_nearest_loop_from_edge(scene, obedit, e_src, co);
+ }
+ }
+ else {
+ l_src = ED_uvedit_active_edge_loop_get(bm);
+ if (l_src != NULL) {
+ if ((!uvedit_uv_select_test(scene, l_src, cd_loop_uv_offset)) &&
+ (!uvedit_uv_select_test(scene, l_src->next, cd_loop_uv_offset))) {
+ l_src = NULL;
+ }
+ ele_src = (BMElem *)l_src;
}
}
-
ele_src = (BMElem *)l_src;
ele_dst = (BMElem *)hit.l;
}
@@ -586,14 +647,21 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve
return OPERATOR_CANCELLED;
}
- BMLoop *l_src = ED_uvedit_active_vert_loop_get(bm);
- if (l_src != NULL) {
- const MLoopUV *luv_src = BM_ELEM_CD_GET_VOID_P(l_src, cd_loop_uv_offset);
- if ((luv_src->flag & MLOOPUV_VERTSEL) == 0) {
- l_src = NULL;
+ BMLoop *l_src = NULL;
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ BMVert *v_src = BM_mesh_active_vert_get(bm);
+ if (v_src != NULL) {
+ l_src = uv_find_nearest_loop_from_vert(scene, obedit, v_src, co);
+ }
+ }
+ else {
+ l_src = ED_uvedit_active_vert_loop_get(bm);
+ if (l_src != NULL) {
+ if (!uvedit_uv_select_test(scene, l_src, cd_loop_uv_offset)) {
+ l_src = NULL;
+ }
}
}
-
ele_src = (BMElem *)l_src;
ele_dst = (BMElem *)hit.l;
}
@@ -607,11 +675,11 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve
/* To support redo. */
int index;
- if (ts->uv_selectmode & UV_SELECT_FACE) {
+ if (uv_selectmode & UV_SELECT_FACE) {
BM_mesh_elem_index_ensure(bm, BM_FACE);
index = BM_elem_index_get(ele_dst);
}
- else if (ts->uv_selectmode & UV_SELECT_EDGE) {
+ else if (uv_selectmode & UV_SELECT_EDGE) {
BM_mesh_elem_index_ensure(bm, BM_LOOP);
index = BM_elem_index_get(ele_dst);
}
@@ -628,7 +696,7 @@ static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op)
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
- const ToolSettings *ts = scene->toolsettings;
+ const char uv_selectmode = ED_uvedit_select_mode_get(scene);
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMesh *bm = em->bm;
@@ -645,7 +713,7 @@ static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op)
BMElem *ele_src, *ele_dst;
- if (ts->uv_selectmode & UV_SELECT_FACE) {
+ if (uv_selectmode & UV_SELECT_FACE) {
if (index < 0 || index >= bm->totface) {
return OPERATOR_CANCELLED;
}
@@ -654,7 +722,7 @@ static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
}
- else if (ts->uv_selectmode & UV_SELECT_EDGE) {
+ else if (uv_selectmode & UV_SELECT_EDGE) {
if (index < 0 || index >= bm->totloop) {
return OPERATOR_CANCELLED;
}
@@ -720,7 +788,7 @@ static int uv_shortest_path_select_exec(bContext *C, wmOperator *op)
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
- const ToolSettings *ts = scene->toolsettings;
+ const char uv_selectmode = ED_uvedit_select_mode_get(scene);
bool found_valid_elements = false;
float aspect_y;
@@ -746,10 +814,10 @@ static int uv_shortest_path_select_exec(bContext *C, wmOperator *op)
{
BMElem **ele_array = NULL;
int ele_array_len = 0;
- if (ts->uv_selectmode & UV_SELECT_FACE) {
+ if (uv_selectmode & UV_SELECT_FACE) {
ele_array = (BMElem **)ED_uvedit_selected_faces(scene, bm, 3, &ele_array_len);
}
- else if (ts->uv_selectmode & UV_SELECT_EDGE) {
+ else if (uv_selectmode & UV_SELECT_EDGE) {
ele_array = (BMElem **)ED_uvedit_selected_edges(scene, bm, 3, &ele_array_len);
}
else {
diff --git a/source/blender/editors/uvedit/uvedit_rip.c b/source/blender/editors/uvedit/uvedit_rip.c
index 07bec2da1ae..421e58b1cb5 100644
--- a/source/blender/editors/uvedit/uvedit_rip.c
+++ b/source/blender/editors/uvedit/uvedit_rip.c
@@ -538,23 +538,22 @@ static bool uv_rip_pairs_loop_change_sides_test(BMLoop *l_switch,
if (count_a + count_b == 4) {
return count_a > count_b;
}
- else {
- const float angle_a_before = uv_rip_pairs_calc_uv_angle(
- l_switch, side_a, aspect_y, cd_loop_uv_offset);
- const float angle_b_before = uv_rip_pairs_calc_uv_angle(
- l_target, side_b, aspect_y, cd_loop_uv_offset);
- UL(l_switch)->side = side_b;
+ const float angle_a_before = uv_rip_pairs_calc_uv_angle(
+ l_switch, side_a, aspect_y, cd_loop_uv_offset);
+ const float angle_b_before = uv_rip_pairs_calc_uv_angle(
+ l_target, side_b, aspect_y, cd_loop_uv_offset);
- const float angle_a_after = uv_rip_pairs_calc_uv_angle(
- l_switch, side_a, aspect_y, cd_loop_uv_offset);
- const float angle_b_after = uv_rip_pairs_calc_uv_angle(
- l_target, side_b, aspect_y, cd_loop_uv_offset);
+ UL(l_switch)->side = side_b;
- UL(l_switch)->side = side_a;
+ const float angle_a_after = uv_rip_pairs_calc_uv_angle(
+ l_switch, side_a, aspect_y, cd_loop_uv_offset);
+ const float angle_b_after = uv_rip_pairs_calc_uv_angle(
+ l_target, side_b, aspect_y, cd_loop_uv_offset);
- return fabsf(angle_a_before - angle_b_before) > fabsf(angle_a_after - angle_b_after);
- }
+ UL(l_switch)->side = side_a;
+
+ return fabsf(angle_a_before - angle_b_before) > fabsf(angle_a_after - angle_b_after);
}
/**
diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c
index ece0158bc9b..149c5cf1f96 100644
--- a/source/blender/editors/uvedit/uvedit_select.c
+++ b/source/blender/editors/uvedit/uvedit_select.c
@@ -145,6 +145,59 @@ BMLoop *ED_uvedit_active_edge_loop_get(BMesh *bm)
* \{ */
/**
+ * Intentionally don't return #UV_SELECT_ISLAND as it's not an element type.
+ * In this case return #UV_SELECT_VERTEX as a fallback.
+ */
+char ED_uvedit_select_mode_get(const Scene *scene)
+{
+ const ToolSettings *ts = scene->toolsettings;
+ char uv_selectmode = UV_SELECT_VERTEX;
+
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->selectmode & SCE_SELECT_VERTEX) {
+ uv_selectmode = UV_SELECT_VERTEX;
+ }
+ else if (ts->selectmode & SCE_SELECT_EDGE) {
+ uv_selectmode = UV_SELECT_EDGE;
+ }
+ else if (ts->selectmode & SCE_SELECT_FACE) {
+ uv_selectmode = UV_SELECT_FACE;
+ }
+ }
+ else {
+ if (ts->uv_selectmode & UV_SELECT_VERTEX) {
+ uv_selectmode = UV_SELECT_VERTEX;
+ }
+ else if (ts->uv_selectmode & UV_SELECT_EDGE) {
+ uv_selectmode = UV_SELECT_EDGE;
+ }
+ else if (ts->uv_selectmode & UV_SELECT_FACE) {
+ uv_selectmode = UV_SELECT_FACE;
+ }
+ }
+ return uv_selectmode;
+}
+
+void ED_uvedit_select_sync_flush(const ToolSettings *ts, BMEditMesh *em, const bool select)
+{
+ /* bmesh API handles flushing but not on de-select */
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->selectmode != SCE_SELECT_FACE) {
+ if (select == false) {
+ EDBM_deselect_flush(em);
+ }
+ else {
+ EDBM_select_flush(em);
+ }
+ }
+
+ if (select == false) {
+ BM_select_history_validate(em->bm);
+ }
+ }
+}
+
+/**
* Apply a penalty to elements that are already selected
* so elements that aren't already selected are prioritized.
*
@@ -529,7 +582,7 @@ void uvedit_uv_select_enable(const Scene *scene,
}
if (do_history) {
- BM_select_history_remove(em->bm, (BMElem *)l->v);
+ BM_select_history_store(em->bm, (BMElem *)l->v);
}
}
else {
@@ -671,7 +724,7 @@ bool uv_find_nearest_face(Scene *scene, Object *obedit, const float co[2], UvNea
}
float cent[2];
- uv_poly_center(efa, cent, cd_loop_uv_offset);
+ BM_face_uv_calc_center_median(efa, cd_loop_uv_offset, cent);
const float dist_test_sq = len_squared_v2v2(co, cent);
@@ -857,6 +910,72 @@ bool ED_uvedit_nearest_uv_multi(const Scene *scene,
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Find Nearest to Element
+ *
+ * These functions are quite specialized, useful when sync select is enabled
+ * and we want to pick an active UV vertex/edge from the active element which may
+ * have multiple UV's split out.
+ * \{ */
+
+BMLoop *uv_find_nearest_loop_from_vert(struct Scene *scene,
+ struct Object *obedit,
+ struct BMVert *v,
+ const float co[2])
+{
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ const uint cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+
+ BMIter liter;
+ BMLoop *l;
+ BMLoop *l_found = NULL;
+ float dist_best_sq = FLT_MAX;
+
+ BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
+ if (!uvedit_face_visible_test(scene, l->f)) {
+ continue;
+ }
+
+ const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ const float dist_test_sq = len_squared_v2v2(co, luv->uv);
+ if (dist_test_sq < dist_best_sq) {
+ dist_best_sq = dist_test_sq;
+ l_found = l;
+ }
+ }
+ return l_found;
+}
+
+BMLoop *uv_find_nearest_loop_from_edge(struct Scene *scene,
+ struct Object *obedit,
+ struct BMEdge *e,
+ const float co[2])
+{
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ const uint cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+
+ BMIter eiter;
+ BMLoop *l;
+ BMLoop *l_found = NULL;
+ float dist_best_sq = FLT_MAX;
+
+ BM_ITER_ELEM (l, &eiter, e, BM_LOOPS_OF_EDGE) {
+ if (!uvedit_face_visible_test(scene, l->f)) {
+ continue;
+ }
+ const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ const MLoopUV *luv_next = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
+ const float dist_test_sq = dist_squared_to_line_segment_v2(co, luv->uv, luv_next->uv);
+ if (dist_test_sq < dist_best_sq) {
+ dist_best_sq = dist_test_sq;
+ l_found = l;
+ }
+ }
+ return l_found;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Edge Loop Select
* \{ */
@@ -1144,11 +1263,13 @@ static void uv_select_linked_multi(Scene *scene,
Object **objects,
const uint objects_len,
UvNearestHit *hit_final,
- bool extend,
+ const bool extend,
bool deselect,
- bool toggle,
- bool select_faces)
+ const bool toggle,
+ const bool select_faces)
{
+ const bool uv_sync_select = (scene->toolsettings->uv_flag & UV_SYNC_SELECTION);
+
/* loop over objects, or just use hit_final->ob */
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
if (hit_final && ob_index != 0) {
@@ -1159,7 +1280,6 @@ static void uv_select_linked_multi(Scene *scene,
BMFace *efa;
BMLoop *l;
BMIter iter, liter;
- MLoopUV *luv;
UvVertMap *vmap;
UvMapVert *vlist, *iterv, *startv;
int i, stacksize = 0, *stack;
@@ -1177,7 +1297,7 @@ static void uv_select_linked_multi(Scene *scene,
*
* Better solve this by having a delimit option for select-linked operator,
* keeping island-select working as is. */
- vmap = BM_uv_vert_map_create(em->bm, !select_faces, false);
+ vmap = BM_uv_vert_map_create(em->bm, !uv_sync_select, false);
if (vmap == NULL) {
continue;
@@ -1199,14 +1319,42 @@ static void uv_select_linked_multi(Scene *scene,
}
else {
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-
- if (luv->flag & MLOOPUV_VERTSEL) {
- stack[stacksize] = a;
- stacksize++;
- flag[a] = 1;
+ if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
+ bool add_to_stack = true;
+ if (uv_sync_select && !select_faces) {
+ /* Special case, vertex/edge & sync select being enabled.
+ *
+ * Without this, a second linked select will 'grow' each time as each new
+ * selection reaches the boundaries of islands that share vertices but not UV's.
+ *
+ * Rules applied here:
+ * - This loops face isn't selected.
+ * - The only other fully selected face is connected or,
+ * - There are no connected fully selected faces UV-connected to this loop.
+ */
+ if (uvedit_face_select_test(scene, l->f, cd_loop_uv_offset)) {
+ /* pass */
+ }
+ else {
+ BMIter liter_other;
+ BMLoop *l_other;
+ BM_ITER_ELEM (l_other, &liter_other, l->v, BM_LOOPS_OF_VERT) {
+ if ((l != l_other) &&
+ !BM_loop_uv_share_vert_check(l, l_other, cd_loop_uv_offset) &&
+ uvedit_face_select_test(scene, l_other->f, cd_loop_uv_offset)) {
+ add_to_stack = false;
+ break;
+ }
+ }
+ }
+ }
- break;
+ if (add_to_stack) {
+ stack[stacksize] = a;
+ stacksize++;
+ flag[a] = 1;
+ break;
+ }
}
}
}
@@ -1275,10 +1423,9 @@ static void uv_select_linked_multi(Scene *scene,
}
else {
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-
- if (luv->flag & MLOOPUV_VERTSEL) {
+ if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
found_selected = true;
+ break;
}
}
@@ -1295,10 +1442,7 @@ static void uv_select_linked_multi(Scene *scene,
BM_face_select_set(em->bm, efa, value); \
} \
else { \
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { \
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); \
- luv->flag = (value) ? (luv->flag | MLOOPUV_VERTSEL) : (luv->flag & ~MLOOPUV_VERTSEL); \
- } \
+ uvedit_face_select_set(scene, em, efa, value, false, cd_loop_uv_offset); \
} \
(void)0
@@ -1323,6 +1467,17 @@ static void uv_select_linked_multi(Scene *scene,
MEM_freeN(stack);
MEM_freeN(flag);
BM_uv_vert_map_free(vmap);
+
+ if (uv_sync_select) {
+ if (deselect) {
+ EDBM_deselect_flush(em);
+ }
+ else {
+ if (!select_faces) {
+ EDBM_selectmode_flush(em);
+ }
+ }
+ }
}
}
@@ -2144,13 +2299,6 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
UvNearestHit hit = UV_NEAREST_HIT_INIT;
- if ((ts->uv_flag & UV_SYNC_SELECTION) && !(ts->selectmode & SCE_SELECT_FACE)) {
- BKE_report(op->reports,
- RPT_ERROR,
- "Select linked only works in face select mode when sync selection is enabled");
- return OPERATOR_CANCELLED;
- }
-
if (pick) {
extend = RNA_boolean_get(op->ptr, "extend");
deselect = RNA_boolean_get(op->ptr, "deselect");
@@ -2181,7 +2329,7 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
}
}
- if (!extend) {
+ if (!extend && !deselect) {
uv_select_all_perform_multi(scene, objects, objects_len, SEL_DESELECT);
}
@@ -2383,25 +2531,6 @@ void UV_OT_select_split(wmOperatorType *ot)
ot->poll = ED_operator_uvedit; /* requires space image */
}
-static void uv_select_sync_flush(const ToolSettings *ts, BMEditMesh *em, const short select)
-{
- /* bmesh API handles flushing but not on de-select */
- if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode != SCE_SELECT_FACE) {
- if (select == false) {
- EDBM_deselect_flush(em);
- }
- else {
- EDBM_select_flush(em);
- }
- }
-
- if (select == false) {
- BM_select_history_validate(em->bm);
- }
- }
-}
-
static void uv_select_tag_update_for_object(Depsgraph *depsgraph,
const ToolSettings *ts,
Object *obedit)
@@ -2712,7 +2841,7 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
BM_elem_flag_disable(efa, BM_ELEM_TAG);
if (uvedit_face_visible_test(scene, efa)) {
- uv_poly_center(efa, cent, cd_loop_uv_offset);
+ BM_face_uv_calc_center_median(efa, cd_loop_uv_offset, cent);
if (BLI_rctf_isect_pt_v(&rectf, cent)) {
BM_elem_flag_enable(efa, BM_ELEM_TAG);
changed = true;
@@ -2806,7 +2935,7 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
if (changed || use_pre_deselect) {
changed_multi = true;
- uv_select_sync_flush(ts, em, select);
+ ED_uvedit_select_sync_flush(ts, em, select);
uv_select_tag_update_for_object(depsgraph, ts, obedit);
}
}
@@ -2943,7 +3072,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
/* assume not touched */
if (select != uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) {
float cent[2];
- uv_poly_center(efa, cent, cd_loop_uv_offset);
+ BM_face_uv_calc_center_median(efa, cd_loop_uv_offset, cent);
if (uv_circle_select_is_point_inside(cent, offset, ellipse)) {
BM_elem_flag_enable(efa, BM_ELEM_TAG);
changed = true;
@@ -3026,7 +3155,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
if (changed || use_pre_deselect) {
changed_multi = true;
- uv_select_sync_flush(ts, em, select);
+ ED_uvedit_select_sync_flush(ts, em, select);
uv_select_tag_update_for_object(depsgraph, ts, obedit);
}
}
@@ -3134,7 +3263,7 @@ static bool do_lasso_select_mesh_uv(bContext *C,
/* assume not touched */
if (select != uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) {
float cent[2];
- uv_poly_center(efa, cent, cd_loop_uv_offset);
+ BM_face_uv_calc_center_median(efa, cd_loop_uv_offset, cent);
if (do_lasso_select_mesh_uv_is_point_inside(region, &rect, mcoords, mcoords_len, cent)) {
BM_elem_flag_enable(efa, BM_ELEM_TAG);
changed = true;
@@ -3221,7 +3350,7 @@ static bool do_lasso_select_mesh_uv(bContext *C,
if (changed || use_pre_deselect) {
changed_multi = true;
- uv_select_sync_flush(ts, em, select);
+ ED_uvedit_select_sync_flush(ts, em, select);
uv_select_tag_update_for_object(depsgraph, ts, obedit);
}
}
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index f649ee528d4..6332a6ab48f 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -323,7 +323,10 @@ static int getNumOfIslandUvs(UvElementMap *elementMap, int island)
return elementMap->islandIndices[island + 1] - elementMap->islandIndices[island];
}
-static void stitch_uv_rotate(float mat[2][2], float medianPoint[2], float uv[2], float aspect)
+static void stitch_uv_rotate(const float mat[2][2],
+ const float medianPoint[2],
+ float uv[2],
+ float aspect)
{
float uv_rotation_result[2];
@@ -1222,14 +1225,14 @@ static int stitch_process_data(StitchStateContainer *ssc,
uint buffer_index = 0;
/* initialize the preview buffers */
- preview->preview_polys = MEM_mallocN(preview->preview_uvs * sizeof(float) * 2,
+ preview->preview_polys = MEM_mallocN(sizeof(float[2]) * preview->preview_uvs,
"tri_uv_stitch_prev");
- preview->uvs_per_polygon = MEM_mallocN(preview->num_polys * sizeof(*preview->uvs_per_polygon),
+ preview->uvs_per_polygon = MEM_mallocN(sizeof(*preview->uvs_per_polygon) * preview->num_polys,
"tri_uv_stitch_prev");
- preview->static_tris = MEM_mallocN(state->tris_per_island[ssc->static_island] * sizeof(float) *
- 6,
- "static_island_preview_tris");
+ preview->static_tris = MEM_mallocN(
+ (sizeof(float[6]) * state->tris_per_island[ssc->static_island]),
+ "static_island_preview_tris");
preview->num_static_tris = state->tris_per_island[ssc->static_island];
/* will cause cancel and freeing of all data structures so OK */
@@ -1268,9 +1271,9 @@ static int stitch_process_data(StitchStateContainer *ssc,
&bm->ldata, lnext->next->head.data, CD_MLOOPUV);
luv = CustomData_bmesh_get(&bm->ldata, lnext->head.data, CD_MLOOPUV);
- memcpy(preview->static_tris + buffer_index, fuv->uv, 2 * sizeof(float));
- memcpy(preview->static_tris + buffer_index + 2, luv->uv, 2 * sizeof(float));
- memcpy(preview->static_tris + buffer_index + 4, luvnext->uv, 2 * sizeof(float));
+ memcpy(preview->static_tris + buffer_index, fuv->uv, sizeof(float[2]));
+ memcpy(preview->static_tris + buffer_index + 2, luv->uv, sizeof(float[2]));
+ memcpy(preview->static_tris + buffer_index + 4, luvnext->uv, sizeof(float[2]));
buffer_index += 6;
}
else {
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 2f30ef1caa6..49f11cd6a74 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -1348,7 +1348,7 @@ static void uv_map_rotation_matrix(float result[4][4],
float sideangledeg,
float radius)
{
- float offset[4] = {0};
+ const float offset[4] = {0};
uv_map_rotation_matrix_ex(result, rv3d, ob, upangledeg, sideangledeg, radius, offset);
}
@@ -1885,12 +1885,10 @@ static int smart_uv_project_thickface_area_cmp_fn(const void *tf_a_p, const void
if (tf_a->area < tf_b->area) {
return 1;
}
- else if (tf_a->area > tf_b->area) {
+ if (tf_a->area > tf_b->area) {
return -1;
}
- else {
- return 0;
- }
+ return 0;
}
static uint smart_uv_project_calculate_project_normals(const ThickFace *thick_faces,
diff --git a/source/blender/freestyle/FRS_freestyle.h b/source/blender/freestyle/FRS_freestyle.h
index 876f40b211f..bc5e9d49bee 100644
--- a/source/blender/freestyle/FRS_freestyle.h
+++ b/source/blender/freestyle/FRS_freestyle.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FRS_FREESTYLE_H__
-#define __FRS_FREESTYLE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -43,7 +42,7 @@ struct FreestyleGlobals {
extern struct FreestyleGlobals g_freestyle;
/* Rendering */
-void FRS_initialize(void);
+void FRS_init(void);
void FRS_set_context(struct bContext *C);
int FRS_is_freestyle_enabled(struct ViewLayer *view_layer);
void FRS_init_stroke_renderer(struct Render *re);
@@ -69,5 +68,3 @@ struct Material *FRS_create_stroke_material(struct Main *bmain,
#ifdef __cplusplus
}
#endif
-
-#endif // __FRS_FREESTYLE_H__
diff --git a/source/blender/freestyle/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp
index 5681c65e5d2..d34be79cd66 100644
--- a/source/blender/freestyle/intern/application/AppCanvas.cpp
+++ b/source/blender/freestyle/intern/application/AppCanvas.cpp
@@ -122,7 +122,7 @@ void AppCanvas::Erase()
void AppCanvas::readColorPixels(int x, int y, int w, int h, RGBImage &oImage) const
{
float *rgb = new float[3 * w * h];
- memset(rgb, 0, sizeof(float) * 3 * w * h);
+ memset(rgb, 0, sizeof(float[3]) * w * h);
int xsch = width();
int ysch = height();
if (_pass_diffuse.buf) {
@@ -161,8 +161,7 @@ void AppCanvas::readColorPixels(int x, int y, int w, int h, RGBImage &oImage) co
if (ii < 0 || ii >= rectx) {
continue;
}
- memcpy(
- rgb + (w * j + i) * 3, _pass_diffuse.buf + (rectx * jj + ii) * 3, sizeof(float) * 3);
+ memcpy(rgb + (w * j + i) * 3, _pass_diffuse.buf + (rectx * jj + ii) * 3, sizeof(float[3]));
}
}
}
diff --git a/source/blender/freestyle/intern/application/AppCanvas.h b/source/blender/freestyle/intern/application/AppCanvas.h
index 9d1e2458564..1ff7e781ce6 100644
--- a/source/blender/freestyle/intern/application/AppCanvas.h
+++ b/source/blender/freestyle/intern/application/AppCanvas.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __APPCANVAS_H__
-#define __APPCANVAS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -93,5 +92,3 @@ class AppCanvas : public Canvas {
};
} /* namespace Freestyle */
-
-#endif // __APPCANVAS_H__
diff --git a/source/blender/freestyle/intern/application/AppConfig.h b/source/blender/freestyle/intern/application/AppConfig.h
index 34f5d220cfe..61beff33876 100644
--- a/source/blender/freestyle/intern/application/AppConfig.h
+++ b/source/blender/freestyle/intern/application/AppConfig.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __APP_CONFIG_H__
-#define __APP_CONFIG_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -123,5 +122,3 @@ static const real DEFAULT_DKR_EPSILON = 0.0;
} // namespace Config
} /* namespace Freestyle */
-
-#endif // __APP_CONFIG_H__
diff --git a/source/blender/freestyle/intern/application/AppView.h b/source/blender/freestyle/intern/application/AppView.h
index 6009f2b0e50..3f07d2794c4 100644
--- a/source/blender/freestyle/intern/application/AppView.h
+++ b/source/blender/freestyle/intern/application/AppView.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __APPVIEW_H__
-#define __APPVIEW_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -272,5 +271,3 @@ class AppView {
};
} /* namespace Freestyle */
-
-#endif // __APPVIEW_H__
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index f9edadb2d4a..dea09b7620f 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -316,10 +316,9 @@ int Controller::LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph
ClearRootNode();
return 0;
}
- else {
- delete _ViewMap;
- _ViewMap = NULL;
- }
+
+ delete _ViewMap;
+ _ViewMap = NULL;
}
_Chrono.start();
diff --git a/source/blender/freestyle/intern/application/Controller.h b/source/blender/freestyle/intern/application/Controller.h
index 613ea2cb45c..6c41733db36 100644
--- a/source/blender/freestyle/intern/application/Controller.h
+++ b/source/blender/freestyle/intern/application/Controller.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __CONTROLLER_H__
-#define __CONTROLLER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -278,5 +277,3 @@ class Controller {
extern Controller *g_pController;
} /* namespace Freestyle */
-
-#endif // __CONTROLLER_H__
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
index e1763514e08..a06218620ac 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
@@ -684,7 +684,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
if (v0 == v1 || v0 == v2 || v1 == v2) {
continue; // do nothing for now
}
- else if (GeomUtils::distPointSegment<Vec3r>(v0, v1, v2) < 1.0e-6) {
+ if (GeomUtils::distPointSegment<Vec3r>(v0, v1, v2) < 1.0e-6) {
detri.viP = vi0;
detri.viA = vi1;
detri.viB = vi2;
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
index 9d8b7e55fbb..50834db3c5c 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLENDER_FILE_LOADER_H__
-#define __BLENDER_FILE_LOADER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -168,5 +167,3 @@ class BlenderFileLoader {
};
} /* namespace Freestyle */
-
-#endif // __BLENDER_FILE_LOADER_H__
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
index 21505f47ae2..1b2e57529d6 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLENDER_STROKE_RENDERER_H__
-#define __BLENDER_STROKE_RENDERER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -102,5 +101,3 @@ class BlenderStrokeRenderer : public StrokeRenderer {
};
} /* namespace Freestyle */
-
-#endif // __BLENDER_STROKE_RENDERER_H__
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
index 95612a42722..e7636e2453a 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLENDERSTYLEMODULE_H__
-#define __BLENDERSTYLEMODULE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -87,5 +86,3 @@ class BlenderStyleModule : public StyleModule {
};
} /* namespace Freestyle */
-
-#endif // __BLENDERSTYLEMODULE_H__
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index 51ac281e330..388c2f35774 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -100,7 +100,7 @@ static bCallbackFuncStore load_post_callback_funcstore = {
// Initialization
//=======================================================
-void FRS_initialize()
+void FRS_init()
{
if (freestyle_is_initialized) {
return;
@@ -376,7 +376,7 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
{FREESTYLE_FE_EXTERNAL_CONTOUR, 0},
{FREESTYLE_FE_EDGE_MARK, 0},
};
- int num_edge_types = sizeof(conditions) / sizeof(struct edge_type_condition);
+ int num_edge_types = ARRAY_SIZE(conditions);
if (G.debug & G_DEBUG_FREESTYLE) {
cout << "Linesets:" << endl;
}
diff --git a/source/blender/freestyle/intern/geometry/BBox.h b/source/blender/freestyle/intern/geometry/BBox.h
index a8965e63451..d9a070faa55 100644
--- a/source/blender/freestyle/intern/geometry/BBox.h
+++ b/source/blender/freestyle/intern/geometry/BBox.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BBOX_H__
-#define __BBOX_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -156,5 +155,3 @@ template<class Point> BBox<Point> &operator+(const BBox<Point> &b1, const BBox<P
}
} /* namespace Freestyle */
-
-#endif // __BBOX_H__
diff --git a/source/blender/freestyle/intern/geometry/Bezier.h b/source/blender/freestyle/intern/geometry/Bezier.h
index adcd6e3a652..4c6b38935f9 100644
--- a/source/blender/freestyle/intern/geometry/Bezier.h
+++ b/source/blender/freestyle/intern/geometry/Bezier.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BEZIER_H__
-#define __BEZIER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -92,5 +91,3 @@ class BezierCurve {
};
} /* namespace Freestyle */
-
-#endif // __BEZIER_H__
diff --git a/source/blender/freestyle/intern/geometry/FastGrid.h b/source/blender/freestyle/intern/geometry/FastGrid.h
index 367c233d799..ec47f36d644 100644
--- a/source/blender/freestyle/intern/geometry/FastGrid.h
+++ b/source/blender/freestyle/intern/geometry/FastGrid.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FASTGRID_H__
-#define __FASTGRID_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -76,5 +75,3 @@ class FastGrid : public Grid {
};
} /* namespace Freestyle */
-
-#endif // __FASTGRID_H__
diff --git a/source/blender/freestyle/intern/geometry/FitCurve.cpp b/source/blender/freestyle/intern/geometry/FitCurve.cpp
index b60de93c4a1..aeb4902e5b0 100644
--- a/source/blender/freestyle/intern/geometry/FitCurve.cpp
+++ b/source/blender/freestyle/intern/geometry/FitCurve.cpp
@@ -202,7 +202,7 @@ static BezierCurve GenerateBezier(
bezCurve[3] = d[last];
V2Add(&bezCurve[0], V2Scale(&tHat1, alpha_l), &bezCurve[1]);
V2Add(&bezCurve[3], V2Scale(&tHat2, alpha_r), &bezCurve[2]);
- return (bezCurve);
+ return bezCurve;
}
/*
@@ -223,7 +223,7 @@ static double *Reparameterize(Vector2 *d, int first, int last, double *u, Bezier
for (i = first; i <= last; i++) {
uPrime[i - first] = NewtonRaphsonRootFind(bezCurve, d[i], u[i - first]);
}
- return (uPrime);
+ return uPrime;
}
/*
diff --git a/source/blender/freestyle/intern/geometry/FitCurve.h b/source/blender/freestyle/intern/geometry/FitCurve.h
index 92afd685d8f..c08dc52249e 100644
--- a/source/blender/freestyle/intern/geometry/FitCurve.h
+++ b/source/blender/freestyle/intern/geometry/FitCurve.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FITCURVE_H__
-#define __FITCURVE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -109,5 +108,3 @@ class FitCurveWrapper {
};
} /* namespace Freestyle */
-
-#endif // __FITCURVE_H__
diff --git a/source/blender/freestyle/intern/geometry/Geom.h b/source/blender/freestyle/intern/geometry/Geom.h
index 63785d56cab..53703c3497a 100644
--- a/source/blender/freestyle/intern/geometry/Geom.h
+++ b/source/blender/freestyle/intern/geometry/Geom.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __GEOM_H__
-#define __GEOM_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -69,5 +68,3 @@ typedef VecMat::SquareMatrix<real, 4> Matrix44r;
} // end of namespace Geometry
} /* namespace Freestyle */
-
-#endif // __GEOM_H__
diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.h b/source/blender/freestyle/intern/geometry/GeomCleaner.h
index aee8ed6963d..7abbf881548 100644
--- a/source/blender/freestyle/intern/geometry/GeomCleaner.h
+++ b/source/blender/freestyle/intern/geometry/GeomCleaner.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __GEOMCLEANER_H__
-#define __GEOMCLEANER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -257,5 +256,3 @@ bool operator<(const IndexedVertex &iv1, const IndexedVertex &iv2)
#endif
} /* namespace Freestyle */
-
-#endif // __GEOMCLEANER_H__
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp
index 4c4f12faaba..89a89d095ea 100644
--- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp
+++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp
@@ -77,7 +77,7 @@ intersection_test intersect2dSeg2dSeg(
// Check signs of r3 and r4. If both point 3 and point 4 lie on same side of line 1,
// the line segments do not intersect.
if (r3 != 0 && r4 != 0 && r3 * r4 > 0.0) {
- return (DONT_INTERSECT);
+ return DONT_INTERSECT;
}
// Compute a2, b2, c2
@@ -92,13 +92,13 @@ intersection_test intersect2dSeg2dSeg(
// Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line
// segment, the line segments do not intersect.
if (r1 != 0 && r2 != 0 && r1 * r2 > 0.0) {
- return (DONT_INTERSECT);
+ return DONT_INTERSECT;
}
// Line segments intersect: compute intersection point.
denom = a1 * b2 - a2 * b1;
if (fabs(denom) < M_EPSILON) {
- return (COLINEAR);
+ return COLINEAR;
}
num = b1 * c2 - b2 * c1;
@@ -107,7 +107,7 @@ intersection_test intersect2dSeg2dSeg(
num = a2 * c1 - a1 * c2;
res[1] = num / denom;
- return (DO_INTERSECT);
+ return DO_INTERSECT;
}
intersection_test intersect2dLine2dLine(
@@ -129,7 +129,7 @@ intersection_test intersect2dLine2dLine(
// Line segments intersect: compute intersection point.
denom = a1 * b2 - a2 * b1;
if (fabs(denom) < M_EPSILON) {
- return (COLINEAR);
+ return COLINEAR;
}
num = b1 * c2 - b2 * c1;
@@ -138,7 +138,7 @@ intersection_test intersect2dLine2dLine(
num = a2 * c1 - a1 * c2;
res[1] = num / denom;
- return (DO_INTERSECT);
+ return DO_INTERSECT;
}
intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
@@ -165,7 +165,7 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
// Check signs of r3 and r4. If both point 3 and point 4 lie on same side of line 1,
// the line segments do not intersect.
if (r3 != 0 && r4 != 0 && r3 * r4 > 0.0) {
- return (DONT_INTERSECT);
+ return DONT_INTERSECT;
}
// Compute a2, b2, c2
@@ -180,13 +180,13 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
// Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line
// segment, the line segments do not intersect.
if (r1 != 0 && r2 != 0 && r1 * r2 > 0.0) {
- return (DONT_INTERSECT);
+ return DONT_INTERSECT;
}
// Line segments intersect: compute intersection point.
denom = a1 * b2 - a2 * b1;
if (fabs(denom) < epsilon) {
- return (COLINEAR);
+ return COLINEAR;
}
real d1, e1;
@@ -200,7 +200,7 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
num = -b1 * d1 - a1 * e1;
u = num / denom;
- return (DO_INTERSECT);
+ return DO_INTERSECT;
}
// AABB-triangle overlap test code by Tomas Akenine-Möller
@@ -514,9 +514,8 @@ intersection_test intersectRayPlane(const Vec3r &orig,
if (fabs((norm * orig) + d) <= epsilon) {
return COINCIDENT; // plane and ray are coincident
}
- else {
- return COLINEAR;
- }
+
+ return COLINEAR;
}
t = -(d + (norm * orig)) / denom;
@@ -766,9 +765,8 @@ inline bool intersect2dSegPoly(Vec2r *seg, Vec2r *poly, unsigned n)
if (N < 0) {
return false;
}
- else {
- continue;
- }
+
+ continue;
}
t = N / D;
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.h b/source/blender/freestyle/intern/geometry/GeomUtils.h
index 635808aab4b..46cd307d9af 100644
--- a/source/blender/freestyle/intern/geometry/GeomUtils.h
+++ b/source/blender/freestyle/intern/geometry/GeomUtils.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __GEOMUTILS_H__
-#define __GEOMUTILS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -266,5 +265,3 @@ void fromCameraToWorld(const Vec3r &p, Vec3r &q, const real model_view_matrix[4]
} // end of namespace GeomUtils
} /* namespace Freestyle */
-
-#endif // __GEOMUTILS_H__
diff --git a/source/blender/freestyle/intern/geometry/Grid.h b/source/blender/freestyle/intern/geometry/Grid.h
index c1a8dcdb370..b66f04398af 100644
--- a/source/blender/freestyle/intern/geometry/Grid.h
+++ b/source/blender/freestyle/intern/geometry/Grid.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __GRID_H__
-#define __GRID_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -433,5 +432,3 @@ class VirtualOccludersSet {
};
} /* namespace Freestyle */
-
-#endif // __GRID_H__
diff --git a/source/blender/freestyle/intern/geometry/GridHelpers.h b/source/blender/freestyle/intern/geometry/GridHelpers.h
index 3f3c669cb57..077688164b4 100644
--- a/source/blender/freestyle/intern/geometry/GridHelpers.h
+++ b/source/blender/freestyle/intern/geometry/GridHelpers.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __GRIDHELPERS_H__
-#define __GRIDHELPERS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -212,5 +211,3 @@ inline void expandProscenium(real proscenium[4], const Vec3r &point)
}; // namespace GridHelpers
} /* namespace Freestyle */
-
-#endif // __GRIDHELPERS_H__
diff --git a/source/blender/freestyle/intern/geometry/HashGrid.h b/source/blender/freestyle/intern/geometry/HashGrid.h
index 4bb92859775..6fb7f2b9cbe 100644
--- a/source/blender/freestyle/intern/geometry/HashGrid.h
+++ b/source/blender/freestyle/intern/geometry/HashGrid.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __HASHGRID_H__
-#define __HASHGRID_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -104,5 +103,3 @@ class HashGrid : public Grid {
};
} /* namespace Freestyle */
-
-#endif // __HASHGRID_H__
diff --git a/source/blender/freestyle/intern/geometry/Noise.h b/source/blender/freestyle/intern/geometry/Noise.h
index 18992092b19..27a91ded9e2 100644
--- a/source/blender/freestyle/intern/geometry/Noise.h
+++ b/source/blender/freestyle/intern/geometry/Noise.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOISE_H__
-#define __NOISE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -81,5 +80,3 @@ class Noise {
};
} /* namespace Freestyle */
-
-#endif // __NOISE_H__
diff --git a/source/blender/freestyle/intern/geometry/Polygon.h b/source/blender/freestyle/intern/geometry/Polygon.h
index b3f47c8ca77..f6f827fd0f2 100644
--- a/source/blender/freestyle/intern/geometry/Polygon.h
+++ b/source/blender/freestyle/intern/geometry/Polygon.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __POLYGON_H__
-#define __POLYGON_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -230,5 +229,3 @@ class Polygon3r : public Polygon<Vec3r> {
} // end of namespace Geometry
} /* namespace Freestyle */
-
-#endif // __POLYGON_H__
diff --git a/source/blender/freestyle/intern/geometry/SweepLine.h b/source/blender/freestyle/intern/geometry/SweepLine.h
index b3555a4a160..d7d379d82f2 100644
--- a/source/blender/freestyle/intern/geometry/SweepLine.h
+++ b/source/blender/freestyle/intern/geometry/SweepLine.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __SWEEPLINE_H__
-#define __SWEEPLINE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -347,5 +346,3 @@ template<class T, class Point> class SweepLine {
};
} /* namespace Freestyle */
-
-#endif // __SWEEPLINE_H__
diff --git a/source/blender/freestyle/intern/geometry/VecMat.h b/source/blender/freestyle/intern/geometry/VecMat.h
index ee1cc42876c..64c3213560c 100644
--- a/source/blender/freestyle/intern/geometry/VecMat.h
+++ b/source/blender/freestyle/intern/geometry/VecMat.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __VECMAT_H__
-#define __VECMAT_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -1005,5 +1004,3 @@ inline std::ostream &operator<<(std::ostream &s, const Matrix<T, M, N> &m)
} // end of namespace VecMat
} /* namespace Freestyle */
-
-#endif // __VECMAT_H__
diff --git a/source/blender/freestyle/intern/geometry/matrix_util.h b/source/blender/freestyle/intern/geometry/matrix_util.h
index f42e043ca97..996ebc928a1 100644
--- a/source/blender/freestyle/intern/geometry/matrix_util.h
+++ b/source/blender/freestyle/intern/geometry/matrix_util.h
@@ -25,8 +25,7 @@
* FRANCE
*/
-#ifndef __MATRIX_UTIL__
-#define __MATRIX_UTIL__
+#pragma once
/** \file
* \ingroup freestyle
@@ -61,5 +60,3 @@ void semi_definite_symmetric_eigen(const double *mat, int n, double *eigen_vec,
} // namespace OGF
} /* namespace Freestyle */
-
-#endif // __MATRIX_UTIL__
diff --git a/source/blender/freestyle/intern/geometry/normal_cycle.h b/source/blender/freestyle/intern/geometry/normal_cycle.h
index a57bfdb953e..6ac9779e7c2 100644
--- a/source/blender/freestyle/intern/geometry/normal_cycle.h
+++ b/source/blender/freestyle/intern/geometry/normal_cycle.h
@@ -25,8 +25,7 @@
* FRANCE
*/
-#ifndef __MESH_TOOLS_MATH_NORMAL_CYCLE__
-#define __MESH_TOOLS_MATH_NORMAL_CYCLE__
+#pragma once
/** \file
* \ingroup freestyle
@@ -145,5 +144,3 @@ inline void NormalCycle::accumulate_dihedral_angle(const Vec3r &edge,
} // namespace OGF
} /* namespace Freestyle */
-
-#endif // __MESH_TOOLS_MATH_NORMAL_CYCLE__
diff --git a/source/blender/freestyle/intern/image/GaussianFilter.h b/source/blender/freestyle/intern/image/GaussianFilter.h
index 625e357eddf..ff765e619a8 100644
--- a/source/blender/freestyle/intern/image/GaussianFilter.h
+++ b/source/blender/freestyle/intern/image/GaussianFilter.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __GAUSSIANFILTER_H__
-#define __GAUSSIANFILTER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -151,5 +150,3 @@ template<class Map> float GaussianFilter::getSmoothedPixel(Map *map, int x, int
}
} /* namespace Freestyle */
-
-#endif // __GAUSSIANFILTER_H__
diff --git a/source/blender/freestyle/intern/image/Image.h b/source/blender/freestyle/intern/image/Image.h
index cf8b0e33c6b..385e243a1a2 100644
--- a/source/blender/freestyle/intern/image/Image.h
+++ b/source/blender/freestyle/intern/image/Image.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __IMAGE_H__
-#define __IMAGE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -430,5 +429,3 @@ class GrayImage : public FrsImage {
};
} /* namespace Freestyle */
-
-#endif // __IMAGE_H__
diff --git a/source/blender/freestyle/intern/image/ImagePyramid.h b/source/blender/freestyle/intern/image/ImagePyramid.h
index 8c6a8bcdff4..ee8bf69aa10 100644
--- a/source/blender/freestyle/intern/image/ImagePyramid.h
+++ b/source/blender/freestyle/intern/image/ImagePyramid.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __IMAGEPYRAMID_H__
-#define __IMAGEPYRAMID_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -113,5 +112,3 @@ class GaussianPyramid : public ImagePyramid {
};
} /* namespace Freestyle */
-
-#endif // __IMAGEPYRAMID_H__
diff --git a/source/blender/freestyle/intern/python/BPy_BBox.h b/source/blender/freestyle/intern/python/BPy_BBox.h
index 84542dc6d1c..a284deed10c 100644
--- a/source/blender/freestyle/intern/python/BPy_BBox.h
+++ b/source/blender/freestyle/intern/python/BPy_BBox.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_BBOX_H__
-#define __FREESTYLE_PYTHON_BBOX_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -55,5 +54,3 @@ int BBox_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_BBOX_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h
index 3d0575a676c..cdf81f3e4fc 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_BINARYPREDICATE0D_H__
-#define __FREESTYLE_PYTHON_BINARYPREDICATE0D_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -54,5 +53,3 @@ int BinaryPredicate0D_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_BINARYPREDICATE0D_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h
index b258f293694..b761f6f6ace 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_BINARYPREDICATE1D_H__
-#define __FREESTYLE_PYTHON_BINARYPREDICATE1D_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -54,5 +53,3 @@ int BinaryPredicate1D_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_BINARYPREDICATE1D_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.h b/source/blender/freestyle/intern/python/BPy_ContextFunctions.h
index 674023fa008..4cc04379f18 100644
--- a/source/blender/freestyle/intern/python/BPy_ContextFunctions.h
+++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CONTEXTFUNCTIONS_H__
-#define __FREESTYLE_PYTHON_CONTEXTFUNCTIONS_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -36,5 +35,3 @@ int ContextFunctions_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CONTEXTFUNCTIONS_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp
index 427e4198e5c..03f9760344b 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp
@@ -110,22 +110,22 @@ PyObject *Any_BPy_Interface0D_from_Interface0D(Interface0D &if0D)
if (typeid(if0D) == typeid(CurvePoint)) {
return BPy_CurvePoint_from_CurvePoint(dynamic_cast<CurvePoint &>(if0D));
}
- else if (typeid(if0D) == typeid(StrokeVertex)) {
+ if (typeid(if0D) == typeid(StrokeVertex)) {
return BPy_StrokeVertex_from_StrokeVertex(dynamic_cast<StrokeVertex &>(if0D));
}
- else if (typeid(if0D) == typeid(SVertex)) {
+ if (typeid(if0D) == typeid(SVertex)) {
return BPy_SVertex_from_SVertex(dynamic_cast<SVertex &>(if0D));
}
- else if (typeid(if0D) == typeid(ViewVertex)) {
+ if (typeid(if0D) == typeid(ViewVertex)) {
return BPy_ViewVertex_from_ViewVertex(dynamic_cast<ViewVertex &>(if0D));
}
- else if (typeid(if0D) == typeid(NonTVertex)) {
+ if (typeid(if0D) == typeid(NonTVertex)) {
return BPy_NonTVertex_from_NonTVertex(dynamic_cast<NonTVertex &>(if0D));
}
- else if (typeid(if0D) == typeid(TVertex)) {
+ if (typeid(if0D) == typeid(TVertex)) {
return BPy_TVertex_from_TVertex(dynamic_cast<TVertex &>(if0D));
}
- else if (typeid(if0D) == typeid(Interface0D)) {
+ if (typeid(if0D) == typeid(Interface0D)) {
return BPy_Interface0D_from_Interface0D(if0D);
}
string msg("unexpected type: " + if0D.getExactTypeName());
@@ -138,22 +138,22 @@ PyObject *Any_BPy_Interface1D_from_Interface1D(Interface1D &if1D)
if (typeid(if1D) == typeid(ViewEdge)) {
return BPy_ViewEdge_from_ViewEdge(dynamic_cast<ViewEdge &>(if1D));
}
- else if (typeid(if1D) == typeid(Chain)) {
+ if (typeid(if1D) == typeid(Chain)) {
return BPy_Chain_from_Chain(dynamic_cast<Chain &>(if1D));
}
- else if (typeid(if1D) == typeid(Stroke)) {
+ if (typeid(if1D) == typeid(Stroke)) {
return BPy_Stroke_from_Stroke(dynamic_cast<Stroke &>(if1D));
}
- else if (typeid(if1D) == typeid(FEdgeSharp)) {
+ if (typeid(if1D) == typeid(FEdgeSharp)) {
return BPy_FEdgeSharp_from_FEdgeSharp(dynamic_cast<FEdgeSharp &>(if1D));
}
- else if (typeid(if1D) == typeid(FEdgeSmooth)) {
+ if (typeid(if1D) == typeid(FEdgeSmooth)) {
return BPy_FEdgeSmooth_from_FEdgeSmooth(dynamic_cast<FEdgeSmooth &>(if1D));
}
- else if (typeid(if1D) == typeid(FEdge)) {
+ if (typeid(if1D) == typeid(FEdge)) {
return BPy_FEdge_from_FEdge(dynamic_cast<FEdge &>(if1D));
}
- else if (typeid(if1D) == typeid(Interface1D)) {
+ if (typeid(if1D) == typeid(Interface1D)) {
return BPy_Interface1D_from_Interface1D(if1D);
}
string msg("unexpected type: " + if1D.getExactTypeName());
@@ -166,10 +166,10 @@ PyObject *Any_BPy_FEdge_from_FEdge(FEdge &fe)
if (typeid(fe) == typeid(FEdgeSharp)) {
return BPy_FEdgeSharp_from_FEdgeSharp(dynamic_cast<FEdgeSharp &>(fe));
}
- else if (typeid(fe) == typeid(FEdgeSmooth)) {
+ if (typeid(fe) == typeid(FEdgeSmooth)) {
return BPy_FEdgeSmooth_from_FEdgeSmooth(dynamic_cast<FEdgeSmooth &>(fe));
}
- else if (typeid(fe) == typeid(FEdge)) {
+ if (typeid(fe) == typeid(FEdge)) {
return BPy_FEdge_from_FEdge(fe);
}
string msg("unexpected type: " + fe.getExactTypeName());
@@ -182,10 +182,10 @@ PyObject *Any_BPy_ViewVertex_from_ViewVertex(ViewVertex &vv)
if (typeid(vv) == typeid(NonTVertex)) {
return BPy_NonTVertex_from_NonTVertex(dynamic_cast<NonTVertex &>(vv));
}
- else if (typeid(vv) == typeid(TVertex)) {
+ if (typeid(vv) == typeid(TVertex)) {
return BPy_TVertex_from_TVertex(dynamic_cast<TVertex &>(vv));
}
- else if (typeid(vv) == typeid(ViewVertex)) {
+ if (typeid(vv) == typeid(ViewVertex)) {
return BPy_ViewVertex_from_ViewVertex(vv);
}
string msg("unexpected type: " + vv.getExactTypeName());
@@ -773,7 +773,7 @@ bool float_array_from_PyObject(PyObject *obj, float *v, int n)
}
return 1;
}
- else if (ColorObject_Check(obj) && n == 3) {
+ if (ColorObject_Check(obj) && n == 3) {
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
return 0;
}
@@ -782,10 +782,10 @@ bool float_array_from_PyObject(PyObject *obj, float *v, int n)
}
return 1;
}
- else if (PyList_Check(obj) && PyList_GET_SIZE(obj) == n) {
+ if (PyList_Check(obj) && PyList_GET_SIZE(obj) == n) {
return float_array_from_PyList(obj, v, n);
}
- else if (PyTuple_Check(obj) && PyTuple_GET_SIZE(obj) == n) {
+ if (PyTuple_Check(obj) && PyTuple_GET_SIZE(obj) == n) {
return float_array_from_PyTuple(obj, v, n);
}
return 0;
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h
index 19e0879beff..5a1c11ec086 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.h
+++ b/source/blender/freestyle/intern/python/BPy_Convert.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CONVERT_H__
-#define __FREESTYLE_PYTHON_CONVERT_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -177,5 +176,3 @@ int convert_v2(PyObject *obj, void *v);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CONVERT_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
index 33078e6ba6a..9796dcda964 100644
--- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
@@ -264,7 +264,7 @@ static PyObject *Freestyle_evaluateCurveMappingF(PyObject * /*self*/, PyObject *
return NULL;
}
cumap = (CurveMapping *)py_srna->ptr.data;
- BKE_curvemapping_initialize(cumap);
+ BKE_curvemapping_init(cumap);
/* disable extrapolation if enabled */
if ((cumap->flag & CUMA_EXTEND_EXTRAPOLATE)) {
cumap->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.h b/source/blender/freestyle/intern/python/BPy_Freestyle.h
index a3a482be9ee..f63eb0d8466 100644
--- a/source/blender/freestyle/intern/python/BPy_Freestyle.h
+++ b/source/blender/freestyle/intern/python/BPy_Freestyle.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_FREESTYLE_H__
-#define __FREESTYLE_PYTHON_FREESTYLE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -38,5 +37,3 @@ PyObject *Freestyle_Init(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_FREESTYLE_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
index 2c226e330d7..dbf1c12fb01 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
+++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
@@ -108,7 +108,7 @@ static int FrsMaterial_init(BPy_FrsMaterial *self, PyObject *args, PyObject *kwd
self->m = new FrsMaterial(*m);
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O&O&O&O&O&fi",
@@ -508,9 +508,8 @@ static PyObject *BPy_FrsMaterial_richcmpr(PyObject *objectA,
if (comparison_type == Py_NE) {
Py_RETURN_TRUE;
}
- else {
- Py_RETURN_FALSE;
- }
+
+ Py_RETURN_FALSE;
}
matA = (BPy_FrsMaterial *)objectA;
@@ -531,9 +530,8 @@ static PyObject *BPy_FrsMaterial_richcmpr(PyObject *objectA,
if (result == true) {
Py_RETURN_TRUE;
}
- else {
- Py_RETURN_FALSE;
- }
+
+ Py_RETURN_FALSE;
}
static Py_hash_t FrsMaterial_hash(PyObject *self)
diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
index 84a3ac2463f..13a116d7ef2 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
+++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_FRSMATERIAL_H__
-#define __FREESTYLE_PYTHON_FRSMATERIAL_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -55,5 +54,3 @@ void FrsMaterial_mathutils_register_callback();
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_FRSMATERIAL_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.h b/source/blender/freestyle/intern/python/BPy_FrsNoise.h
index 9dcf59779cf..09bcc82ae94 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsNoise.h
+++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_FRSNOISE_H__
-#define __FREESTYLE_PYTHON_FRSNOISE_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -55,5 +54,3 @@ int FrsNoise_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_FRSNOISE_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_Id.cpp b/source/blender/freestyle/intern/python/BPy_Id.cpp
index 4f61ba847f6..eb0eb661e3d 100644
--- a/source/blender/freestyle/intern/python/BPy_Id.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Id.cpp
@@ -75,7 +75,7 @@ static int Id_init(BPy_Id *self, PyObject *args, PyObject *kwds)
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_1, &Id_Type, &brother)) {
self->id = new Id(*(((BPy_Id *)brother)->id));
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args, kwds, "|ii", (char **)kwlist_2, &first, &second)) {
self->id = new Id(first, second);
}
diff --git a/source/blender/freestyle/intern/python/BPy_Id.h b/source/blender/freestyle/intern/python/BPy_Id.h
index 3544f751453..f5952297c66 100644
--- a/source/blender/freestyle/intern/python/BPy_Id.h
+++ b/source/blender/freestyle/intern/python/BPy_Id.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_ID_H__
-#define __FREESTYLE_PYTHON_ID_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -57,5 +56,3 @@ int Id_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_ID_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
index 98b0099bcad..9c155db913c 100644
--- a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
+++ b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
@@ -88,21 +88,20 @@ static PyObject *Integrator_integrate(PyObject * /*self*/, PyObject *args, PyObj
double res = integrate(*fun, it, it_end, t);
return PyFloat_FromDouble(res);
}
- else if (BPy_UnaryFunction0DFloat_Check(obj1)) {
+ if (BPy_UnaryFunction0DFloat_Check(obj1)) {
UnaryFunction0D<float> *fun = ((BPy_UnaryFunction0DFloat *)obj1)->uf0D_float;
float res = integrate(*fun, it, it_end, t);
return PyFloat_FromDouble(res);
}
- else if (BPy_UnaryFunction0DUnsigned_Check(obj1)) {
+ if (BPy_UnaryFunction0DUnsigned_Check(obj1)) {
UnaryFunction0D<unsigned int> *fun = ((BPy_UnaryFunction0DUnsigned *)obj1)->uf0D_unsigned;
unsigned int res = integrate(*fun, it, it_end, t);
return PyLong_FromLong(res);
}
- else {
- string class_name(Py_TYPE(obj1)->tp_name);
- PyErr_SetString(PyExc_TypeError, ("unsupported function type: " + class_name).c_str());
- return NULL;
- }
+
+ string class_name(Py_TYPE(obj1)->tp_name);
+ PyErr_SetString(PyExc_TypeError, ("unsupported function type: " + class_name).c_str());
+ return NULL;
}
/*-----------------------Integrator module docstring---------------------------------------*/
diff --git a/source/blender/freestyle/intern/python/BPy_IntegrationType.h b/source/blender/freestyle/intern/python/BPy_IntegrationType.h
index 525feb002e4..be815c6c95a 100644
--- a/source/blender/freestyle/intern/python/BPy_IntegrationType.h
+++ b/source/blender/freestyle/intern/python/BPy_IntegrationType.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_INTEGRATIONTYPE_H__
-#define __FREESTYLE_PYTHON_INTEGRATIONTYPE_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -49,5 +48,3 @@ int IntegrationType_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_INTEGRATIONTYPE_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.h b/source/blender/freestyle/intern/python/BPy_Interface0D.h
index 81fdd40ff04..7e41a8888e1 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface0D.h
+++ b/source/blender/freestyle/intern/python/BPy_Interface0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_INTERFACE0D_H__
-#define __FREESTYLE_PYTHON_INTERFACE0D_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -55,5 +54,3 @@ int Interface0D_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_INTERFACE0D_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.h b/source/blender/freestyle/intern/python/BPy_Interface1D.h
index db9bfa7f79c..20a4af0b4d0 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface1D.h
+++ b/source/blender/freestyle/intern/python/BPy_Interface1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_INTERFACE1D_H__
-#define __FREESTYLE_PYTHON_INTERFACE1D_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -55,5 +54,3 @@ int Interface1D_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_INTERFACE1D_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_Iterator.h b/source/blender/freestyle/intern/python/BPy_Iterator.h
index f9f80c5f1db..5d1e8422976 100644
--- a/source/blender/freestyle/intern/python/BPy_Iterator.h
+++ b/source/blender/freestyle/intern/python/BPy_Iterator.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_ITERATOR_H__
-#define __FREESTYLE_PYTHON_ITERATOR_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -53,5 +52,3 @@ int Iterator_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_ITERATOR_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_MediumType.h b/source/blender/freestyle/intern/python/BPy_MediumType.h
index 5c91890c249..854f826291e 100644
--- a/source/blender/freestyle/intern/python/BPy_MediumType.h
+++ b/source/blender/freestyle/intern/python/BPy_MediumType.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_MEDIUMTYPE_H__
-#define __FREESTYLE_PYTHON_MEDIUMTYPE_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -62,5 +61,3 @@ extern PyLongObject _BPy_MediumType_OPAQUE_MEDIUM;
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_MEDIUMTYPE_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_Nature.h b/source/blender/freestyle/intern/python/BPy_Nature.h
index 8eb33f02488..48d15c8e796 100644
--- a/source/blender/freestyle/intern/python/BPy_Nature.h
+++ b/source/blender/freestyle/intern/python/BPy_Nature.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_NATURE_H__
-#define __FREESTYLE_PYTHON_NATURE_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -53,5 +52,3 @@ int Nature_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_NATURE_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_Operators.cpp b/source/blender/freestyle/intern/python/BPy_Operators.cpp
index 510e823ba55..56f95b8ecbb 100644
--- a/source/blender/freestyle/intern/python/BPy_Operators.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Operators.cpp
@@ -365,8 +365,8 @@ static PyObject *Operators_sequential_split(BPy_Operators * /*self*/,
return NULL;
}
}
- else if (PyErr_Clear(),
- (f = 0.0f),
+ else if ((void)PyErr_Clear(),
+ (void)(f = 0.0f),
PyArg_ParseTupleAndKeywords(
args, kwds, "O!|f", (char **)kwlist_2, &UnaryPredicate0D_Type, &obj1, &f)) {
if (!((BPy_UnaryPredicate0D *)obj1)->up0D) {
@@ -484,8 +484,8 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/,
return NULL;
}
}
- else if (PyErr_Clear(),
- (f = 0.0f),
+ else if ((void)PyErr_Clear(),
+ (void)(f = 0.0f),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!O!O!|f",
diff --git a/source/blender/freestyle/intern/python/BPy_Operators.h b/source/blender/freestyle/intern/python/BPy_Operators.h
index 15797ca742e..3b060d63f3c 100644
--- a/source/blender/freestyle/intern/python/BPy_Operators.h
+++ b/source/blender/freestyle/intern/python/BPy_Operators.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_OPERATORS_H__
-#define __FREESTYLE_PYTHON_OPERATORS_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -53,5 +52,3 @@ int Operators_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_OPERATORS_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.h b/source/blender/freestyle/intern/python/BPy_SShape.h
index 55ef11b9a0b..9741a10f69e 100644
--- a/source/blender/freestyle/intern/python/BPy_SShape.h
+++ b/source/blender/freestyle/intern/python/BPy_SShape.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_SSHAPE_H__
-#define __FREESTYLE_PYTHON_SSHAPE_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -54,5 +53,3 @@ int SShape_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_SSHAPE_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
index 5f5407e82e3..214385f74ad 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
@@ -110,7 +110,7 @@ static int StrokeAttribute_init(BPy_StrokeAttribute *self, PyObject *args, PyObj
self->sa = new StrokeAttribute(*(((BPy_StrokeAttribute *)obj1)->sa));
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!O!f",
@@ -123,7 +123,7 @@ static int StrokeAttribute_init(BPy_StrokeAttribute *self, PyObject *args, PyObj
self->sa = new StrokeAttribute(
*(((BPy_StrokeAttribute *)obj1)->sa), *(((BPy_StrokeAttribute *)obj2)->sa), t);
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args,
kwds,
"ffffff",
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
index 9e14c292c0a..9068eb4c7a3 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_STROKEATTRIBUTE_H__
-#define __FREESTYLE_PYTHON_STROKEATTRIBUTE_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -56,5 +55,3 @@ void StrokeAttribute_mathutils_register_callback();
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_STROKEATTRIBUTE_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.h b/source/blender/freestyle/intern/python/BPy_StrokeShader.h
index 23b1196fdb9..04fff8e8052 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeShader.h
+++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_STROKESHADER_H__
-#define __FREESTYLE_PYTHON_STROKESHADER_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -58,5 +57,3 @@ int StrokeShader_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_STROKESHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
index c0834859dc8..1319cabe94a 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0D_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION0D_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -54,5 +53,3 @@ int UnaryFunction0D_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION0D_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
index dfd0e56beb6..331c3b4aaa1 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION1D_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION1D_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -54,5 +53,3 @@ int UnaryFunction1D_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION1D_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h
index d422b10f18e..2460b1f028b 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYPREDICATE0D_H__
-#define __FREESTYLE_PYTHON_UNARYPREDICATE0D_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -54,5 +53,3 @@ int UnaryPredicate0D_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYPREDICATE0D_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h
index 22358fab525..8fad7f94caf 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYPREDICATE1D_H__
-#define __FREESTYLE_PYTHON_UNARYPREDICATE1D_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -54,5 +53,3 @@ int UnaryPredicate1D_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYPREDICATE1D_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_ViewMap.h b/source/blender/freestyle/intern/python/BPy_ViewMap.h
index fe1cd39deb3..59738b6dce9 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewMap.h
+++ b/source/blender/freestyle/intern/python/BPy_ViewMap.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_VIEWMAP_H__
-#define __FREESTYLE_PYTHON_VIEWMAP_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -53,5 +52,3 @@ int ViewMap_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_VIEWMAP_H__ */
diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
index f59ae15ae01..2adcae13e6d 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
@@ -88,7 +88,7 @@ static int ViewShape_init(BPy_ViewShape *self, PyObject *args, PyObject *kwds)
self->py_ss = ((BPy_ViewShape *)obj)->py_ss;
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &SShape_Type, &obj)) {
BPy_SShape *py_ss = (BPy_SShape *)obj;
self->vs = new ViewShape(py_ss->ss);
diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.h b/source/blender/freestyle/intern/python/BPy_ViewShape.h
index 3158353136f..bd51fd0d5cb 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewShape.h
+++ b/source/blender/freestyle/intern/python/BPy_ViewShape.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_VIEWSHAPE_H__
-#define __FREESTYLE_PYTHON_VIEWSHAPE_H__
+#pragma once
extern "C" {
#include <Python.h>
@@ -57,5 +56,3 @@ int ViewShape_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_VIEWSHAPE_H__ */
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h
index abb9eca9b30..6d741400caa 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_FALSEBP1D_H__
-#define __FREESTYLE_PYTHON_FALSEBP1D_H__
+#pragma once
#include "../BPy_BinaryPredicate1D.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_FALSEBP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h
index 6ad2373c570..755da249855 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_LENGTH2DBP1D_H__
-#define __FREESTYLE_PYTHON_LENGTH2DBP1D_H__
+#pragma once
#include "../BPy_BinaryPredicate1D.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_LENGTH2DBP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h
index 75fc5eaa271..08326706a53 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_SAMESHAPEIDBP1D_H__
-#define __FREESTYLE_PYTHON_SAMESHAPEIDBP1D_H__
+#pragma once
#include "../BPy_BinaryPredicate1D.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_SAMESHAPEIDBP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h
index ed6a783fa47..76f3487d7db 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_TRUEBP1D_H__
-#define __FREESTYLE_PYTHON_TRUEBP1D_H__
+#pragma once
#include "../BPy_BinaryPredicate1D.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_TRUEBP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h
index 1a451a688fb..b9ce88773a8 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_VIEWMAPGRADIENTNORMBP1D_H__
-#define __FREESTYLE_PYTHON_VIEWMAPGRADIENTNORMBP1D_H__
+#pragma once
#include "../BPy_BinaryPredicate1D.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_VIEWMAPGRADIENTNORMBP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/Director.h b/source/blender/freestyle/intern/python/Director.h
index 5c087e411ff..468150524f1 100644
--- a/source/blender/freestyle/intern/python/Director.h
+++ b/source/blender/freestyle/intern/python/Director.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_DIRECTOR_H__
-#define __FREESTYLE_PYTHON_DIRECTOR_H__
+#pragma once
namespace Freestyle {
class UnaryPredicate0D;
@@ -63,5 +62,3 @@ int Director_BPy_StrokeShader_shade(StrokeShader *ss, Stroke &s);
// ChainingIterator: init, traverse
int Director_BPy_ChainingIterator_init(ChainingIterator *c_it);
int Director_BPy_ChainingIterator_traverse(ChainingIterator *c_it, AdjacencyIterator &a_it);
-
-#endif // __FREESTYLE_PYTHON_DIRECTOR_H__
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
index 6af80c4bfd9..81dd79ff270 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
@@ -95,7 +95,7 @@ static int CurvePoint_init(BPy_CurvePoint *self, PyObject *args, PyObject *kwds)
self->cp = new CurvePoint(*(((BPy_CurvePoint *)obj1)->cp));
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!O!f",
@@ -107,7 +107,7 @@ static int CurvePoint_init(BPy_CurvePoint *self, PyObject *args, PyObject *kwds)
&t2d)) {
self->cp = new CurvePoint(((BPy_SVertex *)obj1)->sv, ((BPy_SVertex *)obj2)->sv, t2d);
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!O!f",
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h
index d0f4087f8a6..6a550085817 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CURVEPOINT_H__
-#define __FREESTYLE_PYTHON_CURVEPOINT_H__
+#pragma once
#include "../BPy_Interface0D.h"
@@ -46,5 +45,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CURVEPOINT_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
index 71a87c2c01e..c01f1f17000 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
@@ -72,7 +72,7 @@ static int SVertex_init(BPy_SVertex *self, PyObject *args, PyObject *kwds)
self->sv = new SVertex(*(((BPy_SVertex *)obj)->sv));
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(
args, kwds, "O&O!", (char **)kwlist_2, convert_v3, v, &Id_Type, &obj)) {
Vec3r point_3d(v[0], v[1], v[2]);
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h
index 20a14f1422c..8d24576a98f 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_SVERTEX_H__
-#define __FREESTYLE_PYTHON_SVERTEX_H__
+#pragma once
#include "../BPy_Interface0D.h"
@@ -50,5 +49,3 @@ void SVertex_mathutils_register_callback();
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_SVERTEX_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h
index 6769efa4673..cb9815fb3d4 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_VIEWVERTEX_H__
-#define __FREESTYLE_PYTHON_VIEWVERTEX_H__
+#pragma once
#include "../BPy_Interface0D.h"
@@ -46,5 +45,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_VIEWVERTEX_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
index b4c08714af0..519bd72db3b 100644
--- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
@@ -107,7 +107,7 @@ static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *k
self->sv = new StrokeVertex(*(((BPy_StrokeVertex *)obj1)->sv));
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!O!f",
@@ -129,7 +129,7 @@ static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *k
}
self->sv = new StrokeVertex(sv1, sv2, t3d);
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist_3, &CurvePoint_Type, &obj1)) {
CurvePoint *cp = ((BPy_CurvePoint *)obj1)->cp;
@@ -139,8 +139,8 @@ static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *k
}
self->sv = new StrokeVertex(cp);
}
- else if (PyErr_Clear(),
- (obj2 = 0),
+ else if ((void)PyErr_Clear(),
+ (void)(obj2 = 0),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!|O!",
diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h
index e2eab6ab887..44da0ed212a 100644
--- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_STROKEVERTEX_H__
-#define __FREESTYLE_PYTHON_STROKEVERTEX_H__
+#pragma once
#include "../BPy_CurvePoint.h"
@@ -51,5 +50,3 @@ void StrokeVertex_mathutils_register_callback();
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_STROKEVERTEX_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h
index fdea985a125..43f2c2b4a5c 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_NONTVERTEX_H__
-#define __FREESTYLE_PYTHON_NONTVERTEX_H__
+#pragma once
#include "../BPy_ViewVertex.h"
@@ -46,5 +45,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_NONTVERTEX_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h
index 165ad976fdf..253934bb4e7 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_TVERTEX_H__
-#define __FREESTYLE_PYTHON_TVERTEX_H__
+#pragma once
#include "../BPy_ViewVertex.h"
@@ -46,5 +45,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_TVERTEX_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
index 8a09e7722ea..187ab94360a 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
@@ -81,7 +81,7 @@ static int FEdge_init(BPy_FEdge *self, PyObject *args, PyObject *kwds)
self->fe = new FEdge(*(((BPy_FEdge *)obj1)->fe));
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!O!",
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h
index 3ab8c5f8273..25b1bc99860 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_FEDGE_H__
-#define __FREESTYLE_PYTHON_FEDGE_H__
+#pragma once
#include "../BPy_Interface1D.h"
@@ -46,5 +45,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_FEDGE_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
index fd434f9c4ef..788dfa78992 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
@@ -72,7 +72,7 @@ static int FrsCurve_init(BPy_FrsCurve *self, PyObject *args, PyObject *kwds)
self->c = new Curve(*(((BPy_FrsCurve *)obj)->c));
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &Id_Type, &obj)) {
self->c = new Curve(*(((BPy_Id *)obj)->id));
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h
index aa4fb409076..9bdc3919a38 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_FRSCURVE_H__
-#define __FREESTYLE_PYTHON_FRSCURVE_H__
+#pragma once
#include "../BPy_Interface1D.h"
@@ -46,5 +45,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_FRSCURVE_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
index 3a25ddb0252..b31efe1f923 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
@@ -157,7 +157,8 @@ static PyObject *Stroke_resample(BPy_Stroke *self, PyObject *args, PyObject *kwd
return NULL;
}
}
- else if (PyErr_Clear(), PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist_2, &f)) {
+ else if ((void)PyErr_Clear(),
+ PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist_2, &f)) {
if (self->s->Resample(f) < 0) {
PyErr_SetString(PyExc_RuntimeError, "Stroke resampling (by vertex interval) failed");
return NULL;
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h
index a08905e6043..33c6aa70f91 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_STROKE_H__
-#define __FREESTYLE_PYTHON_STROKE_H__
+#pragma once
#include "../BPy_Interface1D.h"
@@ -46,5 +45,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_STROKE_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h
index c02d5d0f21b..519081cedbd 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_VIEWEDGE_H__
-#define __FREESTYLE_PYTHON_VIEWEDGE_H__
+#pragma once
#include "../BPy_Interface1D.h"
@@ -46,5 +45,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_VIEWEDGE_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
index 285100193d3..9cdc344081e 100644
--- a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
@@ -71,7 +71,7 @@ static int Chain_init(BPy_Chain *self, PyObject *args, PyObject *kwds)
self->c = new Chain(*(((BPy_Chain *)obj)->c));
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &Id_Type, &obj)) {
self->c = new Chain(*(((BPy_Id *)obj)->id));
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h
index a9392cd81bf..73da253688c 100644
--- a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h
+++ b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CHAIN_H__
-#define __FREESTYLE_PYTHON_CHAIN_H__
+#pragma once
#include "../BPy_FrsCurve.h"
@@ -46,5 +45,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CHAIN_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
index 725daa80b5e..5db75c84608 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
@@ -75,7 +75,7 @@ static int FEdgeSharp_init(BPy_FEdgeSharp *self, PyObject *args, PyObject *kwds)
self->fes = new FEdgeSharp(*(((BPy_FEdgeSharp *)obj1)->fes));
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!O!",
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h
index 450539acb16..2b8b09a5990 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_FEDGESHARP_H__
-#define __FREESTYLE_PYTHON_FEDGESHARP_H__
+#pragma once
#include "../BPy_FEdge.h"
@@ -50,5 +49,3 @@ void FEdgeSharp_mathutils_register_callback();
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_FEDGESHARP_H__ */
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
index 65d9dcbe01f..3fb739b18db 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
@@ -73,7 +73,7 @@ static int FEdgeSmooth_init(BPy_FEdgeSmooth *self, PyObject *args, PyObject *kwd
self->fes = new FEdgeSmooth(*(((BPy_FEdgeSmooth *)obj1)->fes));
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!O!",
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h
index 901741a76ff..97497281310 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_FEDGESMOOTH_H__
-#define __FREESTYLE_PYTHON_FEDGESMOOTH_H__
+#pragma once
#include "../BPy_FEdge.h"
@@ -51,5 +50,3 @@ void FEdgeSmooth_mathutils_register_callback();
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_FEDGESMOOTH_H__ */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
index 74ae7809284..90e751333b9 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
@@ -82,8 +82,8 @@ static int AdjacencyIterator_init(BPy_AdjacencyIterator *self, PyObject *args, P
self->at_start = ((BPy_AdjacencyIterator *)obj1)->at_start;
}
}
- else if (PyErr_Clear(),
- (obj2 = obj3 = 0),
+ else if ((void)PyErr_Clear(),
+ (void)(obj2 = obj3 = 0),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!|O!O!",
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h
index 9a360f23f0a..e5332e0d180 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_ADJACENCYITERATOR_H__
-#define __FREESTYLE_PYTHON_ADJACENCYITERATOR_H__
+#pragma once
#include "../BPy_Iterator.h"
@@ -48,5 +47,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_ADJACENCYITERATOR_H__ */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
index 164e1646934..1703fc2bddb 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
@@ -114,8 +114,8 @@ static int ChainPredicateIterator_init(BPy_ChainPredicateIterator *self,
Py_INCREF(self->upred);
Py_INCREF(self->bpred);
}
- else if (PyErr_Clear(),
- (obj3 = obj4 = obj5 = obj6 = 0),
+ else if ((void)PyErr_Clear(),
+ (void)(obj3 = obj4 = obj5 = obj6 = 0),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!O!|O!O!O&O!",
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h
index 645e6573257..ece8018d285 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CHAINPREDICATEITERATOR_H__
-#define __FREESTYLE_PYTHON_CHAINPREDICATEITERATOR_H__
+#pragma once
#include "BPy_ChainingIterator.h"
@@ -49,5 +48,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CHAINPREDICATEITERATOR_H__ */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
index 401959be0c0..d8ad82d667c 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
@@ -91,8 +91,8 @@ static int ChainSilhouetteIterator_init(BPy_ChainSilhouetteIterator *self,
args, kwds, "O!", (char **)kwlist_1, &ChainSilhouetteIterator_Type, &obj1)) {
self->cs_it = new ChainSilhouetteIterator(*(((BPy_ChainSilhouetteIterator *)obj1)->cs_it));
}
- else if (PyErr_Clear(),
- (obj1 = obj2 = obj3 = 0),
+ else if ((void)PyErr_Clear(),
+ (void)(obj1 = obj2 = obj3 = 0),
PyArg_ParseTupleAndKeywords(args,
kwds,
"|O!O&O!",
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h
index 72823832441..f91d0fb2585 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CHAINSILHOUETTEITERATOR_H__
-#define __FREESTYLE_PYTHON_CHAINSILHOUETTEITERATOR_H__
+#pragma once
#include "BPy_ChainingIterator.h"
@@ -47,5 +46,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CHAINSILHOUETTEITERATOR_H__ */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
index b6d841c5b64..dbd6e8dd09d 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
@@ -91,8 +91,8 @@ static int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args,
args, kwds, "O!", (char **)kwlist_1, &ChainingIterator_Type, &obj1)) {
self->c_it = new ChainingIterator(*(((BPy_ChainingIterator *)obj1)->c_it));
}
- else if (PyErr_Clear(),
- (obj1 = obj2 = obj3 = obj4 = 0),
+ else if ((void)PyErr_Clear(),
+ (void)(obj1 = obj2 = obj3 = obj4 = 0),
PyArg_ParseTupleAndKeywords(args,
kwds,
"|O!O!O&O!",
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h
index 7e3be0bc6cd..e950824764c 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CHAININGITERATOR_H__
-#define __FREESTYLE_PYTHON_CHAININGITERATOR_H__
+#pragma once
#include "BPy_ViewEdgeIterator.h"
@@ -47,5 +46,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CHAININGITERATOR_H__ */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
index 6ea61a060cb..6c496b0308b 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
@@ -75,7 +75,8 @@ static int CurvePointIterator_init(BPy_CurvePointIterator *self, PyObject *args,
*(((BPy_CurvePointIterator *)brother)->cp_it));
}
}
- else if (PyErr_Clear(), PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist_2, &step)) {
+ else if ((void)PyErr_Clear(),
+ PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist_2, &step)) {
self->cp_it = new CurveInternal::CurvePointIterator(step);
}
else {
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h
index aa84b1020ce..db36bf386ec 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CURVEPOINTITERATOR_H__
-#define __FREESTYLE_PYTHON_CURVEPOINTITERATOR_H__
+#pragma once
#include "../BPy_Iterator.h"
@@ -47,5 +46,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CURVEPOINTITERATOR_H__ */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
index 0dbef9f325c..734ed0117f4 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
@@ -81,14 +81,14 @@ static int Interface0DIterator_init(BPy_Interface0DIterator *self, PyObject *arg
self->at_start = true;
self->reversed = false;
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist_2, &Interface1D_Type, &inter)) {
self->if0D_it = new Interface0DIterator(((BPy_Interface1D *)inter)->if1D->verticesBegin());
self->at_start = true;
self->reversed = false;
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(
args, kwds, "O!", (char **)kwlist_3, &Interface0DIterator_Type, &brother)) {
self->if0D_it = new Interface0DIterator(*(((BPy_Interface0DIterator *)brother)->if0D_it));
@@ -124,7 +124,7 @@ static PyObject *Interface0DIterator_iternext(BPy_Interface0DIterator *self)
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
- else if (self->at_start) {
+ if (self->at_start) {
self->at_start = false;
}
else if (self->if0D_it->atLast()) {
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h
index 3695cda6c76..663193bedee 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_INTERFACE0DITERATOR_H__
-#define __FREESTYLE_PYTHON_INTERFACE0DITERATOR_H__
+#pragma once
#include "../BPy_Iterator.h"
@@ -49,5 +48,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_INTERFACE0DITERATOR_H__ */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
index dd738b97473..4a5927ff6eb 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
@@ -82,7 +82,7 @@ static int SVertexIterator_init(BPy_SVertexIterator *self, PyObject *args, PyObj
self->sv_it = new ViewEdgeInternal::SVertexIterator(*(((BPy_SVertexIterator *)obj1)->sv_it));
}
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args,
kwds,
"O!O!O!O!f",
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h
index 2a3bfa6baf9..a34dc7a63c5 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_SVERTEXITERATOR_H__
-#define __FREESTYLE_PYTHON_SVERTEXITERATOR_H__
+#pragma once
#include "../BPy_Iterator.h"
@@ -47,5 +46,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_SVERTEXITERATOR_H__ */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
index 84f57f1fe31..cda4031240b 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
@@ -74,7 +74,7 @@ static int StrokeVertexIterator_init(BPy_StrokeVertexIterator *self,
self->at_start = ((BPy_StrokeVertexIterator *)brother)->at_start;
}
- else if (PyErr_Clear(),
+ else if ((void)PyErr_Clear(),
PyArg_ParseTupleAndKeywords(
args, kwds, "|O!", (char **)kwlist_2, &Stroke_Type, &stroke)) {
if (!stroke) {
@@ -125,7 +125,7 @@ static PyObject *StrokeVertexIterator_iternext(BPy_StrokeVertexIterator *self)
}
/* If at the start of the iterator, only return the object
* and don't increment, to keep for-loops in sync */
- else if (self->at_start) {
+ if (self->at_start) {
self->at_start = false;
}
/* If sv_it.atLast() is true, the iterator is currently pointing to the final valid element.
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h
index 04bca16337d..629471a664c 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_STROKEVERTEXITERATOR_H__
-#define __FREESTYLE_PYTHON_STROKEVERTEXITERATOR_H__
+#pragma once
#include "../BPy_Iterator.h"
@@ -50,5 +49,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_STROKEVERTEXITERATOR_H__ */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
index c8a978784a4..3d0ed5d5a4d 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
@@ -78,8 +78,8 @@ static int ViewEdgeIterator_init(BPy_ViewEdgeIterator *self, PyObject *args, PyO
args, kwds, "O!", (char **)kwlist_1, &ViewEdgeIterator_Type, &obj1)) {
self->ve_it = new ViewEdgeInternal::ViewEdgeIterator(*(((BPy_ViewEdgeIterator *)obj1)->ve_it));
}
- else if (PyErr_Clear(),
- (obj1 = obj2 = 0),
+ else if ((void)PyErr_Clear(),
+ (void)(obj1 = obj2 = 0),
PyArg_ParseTupleAndKeywords(
args, kwds, "|O&O!", (char **)kwlist_2, check_begin, &obj1, &PyBool_Type, &obj2)) {
ViewEdge *begin = (!obj1 || obj1 == Py_None) ? NULL : ((BPy_ViewEdge *)obj1)->ve;
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h
index c9061d30e07..7169a13f328 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_VIEWEDGEITERATOR_H__
-#define __FREESTYLE_PYTHON_VIEWEDGEITERATOR_H__
+#pragma once
#include "../BPy_Iterator.h"
@@ -47,5 +46,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_VIEWEDGEITERATOR_H__ */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h
index 179e315b1be..7a13f6d2c72 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_ORIENTEDVIEWEDGEITERATOR_H__
-#define __FREESTYLE_PYTHON_ORIENTEDVIEWEDGEITERATOR_H__
+#pragma once
#include "../BPy_Iterator.h"
@@ -49,5 +48,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_ORIENTEDVIEWEDGEITERATOR_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h
index c37d330e4a7..bd63b2fb337 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_BACKBONESTRETCHERSHADER_H__
-#define __FREESTYLE_PYTHON_BACKBONESTRETCHERSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_BACKBONESTRETCHERSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h
index b38fcec838d..a0b80b401ba 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_BEZIERCURVESHADER_H__
-#define __FREESTYLE_PYTHON_BEZIERCURVESHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_BEZIERCURVESHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.h
index 35335ffc023..7147a542467 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_BLENDERTEXTURESHADER_H__
-#define __FREESTYLE_PYTHON_BLENDERTEXTURESHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -46,5 +45,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_BLENDERTEXTURESHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
index 35a94a1620d..b64e1b9376e 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CALLIGRAPHICSHADER_H__
-#define __FREESTYLE_PYTHON_CALLIGRAPHICSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CALLIGRAPHICSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h
index 054479d916d..ada3165eea9 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_COLORNOISESHADER_H__
-#define __FREESTYLE_PYTHON_COLORNOISESHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_COLORNOISESHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h
index 36b59e6493e..7f58ed53e96 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CONSTANTCOLORSHADER_H__
-#define __FREESTYLE_PYTHON_CONSTANTCOLORSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CONSTANTCOLORSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h
index 3a11ab9c9a0..9323e2b9143 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CONSTANTTHICKNESSSHADER_H__
-#define __FREESTYLE_PYTHON_CONSTANTTHICKNESSSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CONSTANTTHICKNESSSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
index 04912499c04..e3946c4bedb 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CONSTRAINEDINCREASINGTHICKNESSSHADER_H__
-#define __FREESTYLE_PYTHON_CONSTRAINEDINCREASINGTHICKNESSSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -45,5 +44,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CONSTRAINEDINCREASINGTHICKNESSSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h
index 217acbc4648..51fd37978d5 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GUIDINGLINESSHADER_H__
-#define __FREESTYLE_PYTHON_GUIDINGLINESSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GUIDINGLINESSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h
index d7d1d053efd..def647abcce 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_INCREASINGCOLORSHADER_H__
-#define __FREESTYLE_PYTHON_INCREASINGCOLORSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_INCREASINGCOLORSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h
index 28636263813..7ded1c81beb 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_INCREASINGTHICKNESSSHADER_H__
-#define __FREESTYLE_PYTHON_INCREASINGTHICKNESSSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_INCREASINGTHICKNESSSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h
index e44ca1caa51..c50b388965a 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_POLYGONALIZATIONSHADER_H__
-#define __FREESTYLE_PYTHON_POLYGONALIZATIONSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_POLYGONALIZATIONSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h
index 50dbae6916e..073c5e8df42 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_SAMPLINGSHADER_H__
-#define __FREESTYLE_PYTHON_SAMPLINGSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_SAMPLINGSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
index 51a0c670d75..9e2726061c3 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
@@ -35,9 +35,9 @@ static char SmoothingShader___doc__[] =
"\n"
"[Geometry shader]\n"
"\n"
- ".. method:: __init__(num_iterations=100, factor_point=0.1,\n"
- " factor_curvature=0.0, factor_curvature_difference=0.2,\n"
- " aniso_point=0.0, aniso_normal=0.0, aniso_curvature=0.0,\n"
+ ".. method:: __init__(num_iterations=100, factor_point=0.1, \\\n"
+ " factor_curvature=0.0, factor_curvature_difference=0.2, \\\n"
+ " aniso_point=0.0, aniso_normal=0.0, aniso_curvature=0.0, \\\n"
" carricature_factor=1.0)\n"
"\n"
" Builds a SmoothingShader object.\n"
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h
index 4b553d76770..fcd559b661d 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHONSMOOTHINGSHADER_H__
-#define __FREESTYLE_PYTHONSMOOTHINGSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHONSMOOTHINGSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h
index 7e5e644c46f..59e3e32d6cf 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_SPATIALNOISESHADER_H__
-#define __FREESTYLE_PYTHON_SPATIALNOISESHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_SPATIALNOISESHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.h
index d53ca139b2b..ef0ebfad883 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_STROKETEXTURESTEPSHADER_H__
-#define __FREESTYLE_PYTHON_STROKETEXTURESTEPSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -46,5 +45,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_STROKETEXTURESTEPSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h
index 1a42985b245..e18f60c033b 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_THICKNESSNOISESHADER_H__
-#define __FREESTYLE_PYTHON_THICKNESSNOISESHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_THICKNESSNOISESHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h
index a82be691c81..bc7c2a2f2f4 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_TIPREMOVERSHADER_H__
-#define __FREESTYLE_PYTHON_TIPREMOVERSHADER_H__
+#pragma once
#include "../BPy_StrokeShader.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_TIPREMOVERSHADER_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h
index 8abccd27591..60ebc646d74 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0DDOUBLE_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION0DDOUBLE_H__
+#pragma once
#include "../BPy_UnaryFunction0D.h"
@@ -48,5 +47,3 @@ int UnaryFunction0DDouble_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION0DDOUBLE_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h
index 5a92142c88a..9ce4b3bfd0b 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0DEDGENATURE_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION0DEDGENATURE_H__
+#pragma once
#include "../BPy_UnaryFunction0D.h"
@@ -50,5 +49,3 @@ int UnaryFunction0DEdgeNature_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION0DEDGENATURE_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h
index 53dc88d0e21..fd221201d99 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0DFLOAT_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION0DFLOAT_H__
+#pragma once
#include "../BPy_UnaryFunction0D.h"
@@ -48,5 +47,3 @@ int UnaryFunction0DFloat_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION0DFLOAT_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h
index a8887b081ce..14e5d48ce43 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0DID_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION0DID_H__
+#pragma once
#include "../BPy_UnaryFunction0D.h"
@@ -50,5 +49,3 @@ int UnaryFunction0DId_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION0DID_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h
index 558719032f8..bbd53c409eb 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0DMATERIAL_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION0DMATERIAL_H__
+#pragma once
#include "../BPy_UnaryFunction0D.h"
@@ -50,5 +49,3 @@ int UnaryFunction0DMaterial_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION0DMATERIAL_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h
index ac09b51eceb..1a466ffc673 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0DUNSIGNED_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION0DUNSIGNED_H__
+#pragma once
#include "../BPy_UnaryFunction0D.h"
@@ -48,5 +47,3 @@ int UnaryFunction0DUnsigned_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION0DUNSIGNED_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h
index 1639e1a5356..6c3d5fc85cc 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0DVEC2F_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION0DVEC2F_H__
+#pragma once
#include "../BPy_UnaryFunction0D.h"
@@ -51,5 +50,3 @@ int UnaryFunction0DVec2f_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION0DVEC2F_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h
index 0f3bcc51f2e..4be9b170311 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0DVEC3F_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION0DVEC3F_H__
+#pragma once
#include "../BPy_UnaryFunction0D.h"
@@ -51,5 +50,3 @@ int UnaryFunction0DVec3f_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION0DVEC3F_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
index 4f559a09ba9..2a36ae21002 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0DVECTORVIEWSHAPE_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION0DVECTORVIEWSHAPE_H__
+#pragma once
#include "../BPy_UnaryFunction0D.h"
@@ -53,5 +52,3 @@ int UnaryFunction0DVectorViewShape_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION0DVECTORVIEWSHAPE_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h
index af3661669bd..8a8dcdceb1f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION0DVIEWSHAPE_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION0DVIEWSHAPE_H__
+#pragma once
#include "../BPy_UnaryFunction0D.h"
@@ -50,5 +49,3 @@ int UnaryFunction0DViewShape_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION0DVIEWSHAPE_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h
index 1aea0736c9b..ce4b448df03 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_SHAPEIDF0D_H__
-#define __FREESTYLE_PYTHON_SHAPEIDF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DId.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_SHAPEIDF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h
index f1520fa63ee..b569b9e1e81 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_MATERIALF0D_H__
-#define __FREESTYLE_PYTHON_MATERIALF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DMaterial.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_MATERIALF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h
index f24e63d09f9..5e29845c6b9 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CURVENATUREF0D_H__
-#define __FREESTYLE_PYTHON_CURVENATUREF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DEdgeNature.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CURVENATUREF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h
index 45a4ec3124d..c9b10412f34 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_NORMAL2DF0D_H__
-#define __FREESTYLE_PYTHON_NORMAL2DF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DVec2f.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_NORMAL2DF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h
index 8e76c31ff27..036bc82b52a 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_VERTEXORIENTATION2DF0D_H__
-#define __FREESTYLE_PYTHON_VERTEXORIENTATION2DF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DVec2f.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_VERTEXORIENTATION2DF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h
index 391f7c9536b..c99c344d470 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_VERTEXORIENTATION3DF0D_H__
-#define __FREESTYLE_PYTHON_VERTEXORIENTATION3DF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DVec3f.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_VERTEXORIENTATION3DF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h
index 45c9524e185..20ca0499a1e 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETOCCLUDEEF0D_H__
-#define __FREESTYLE_PYTHON_GETOCCLUDEEF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DViewShape.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETOCCLUDEEF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h
index c1db8c1219a..4e6dd6b9f60 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETSHAPEF0D_H__
-#define __FREESTYLE_PYTHON_GETSHAPEF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DViewShape.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETSHAPEF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h
index b57119257b9..6fcafef8143 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CURVATURE2DANGLEF0D_H__
-#define __FREESTYLE_PYTHON_CURVATURE2DANGLEF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CURVATURE2DANGLEF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h
index 34bbd8331fb..8df2f67aff3 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_DENSITYF0D_H__
-#define __FREESTYLE_PYTHON_DENSITYF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DDouble.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_DENSITYF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h
index ddd500f617e..cf5adf216fc 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETPROJECTEDXF0D_H__
-#define __FREESTYLE_PYTHON_GETPROJECTEDXF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETPROJECTEDXF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h
index 8fccf14971f..6293f9daa24 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETPROJECTEDYF0D_H__
-#define __FREESTYLE_PYTHON_GETPROJECTEDYF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETPROJECTEDYF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h
index eecf69adb12..edae33e4c85 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETPROJECTEDZF0D_H__
-#define __FREESTYLE_PYTHON_GETPROJECTEDZF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETPROJECTEDZF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h
index 745bd5c628d..e0427fb1ccd 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETXF0D_H__
-#define __FREESTYLE_PYTHON_GETXF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DDouble.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETXF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h
index 437ec573585..3f4f3c85dc7 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETYF0D_H__
-#define __FREESTYLE_PYTHON_GETYF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DDouble.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETYF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h
index 840303fa59d..54a451e81f4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETZF0D_H__
-#define __FREESTYLE_PYTHON_GETZF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DDouble.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETZF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h
index f8072427d47..85626895d20 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF0D_H__
-#define __FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h
index d0aed95fc1a..fe2f333da37 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_ZDISCONTINUITYF0D_H__
-#define __FREESTYLE_PYTHON_ZDISCONTINUITYF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_ZDISCONTINUITYF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h
index 72238cfc255..8fffe3fd51d 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETCURVILINEARABSCISSAF0D_H__
-#define __FREESTYLE_PYTHON_GETCURVILINEARABSCISSAF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DFloat.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETCURVILINEARABSCISSAF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h
index 4fdb6419f21..3346b519e60 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETPARAMETERF0D_H__
-#define __FREESTYLE_PYTHON_GETPARAMETERF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DFloat.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETPARAMETERF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h
index 6ed42ee8019..de4930912f4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF0D_H__
-#define __FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DFloat.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
index 48d36543ca0..ceee0151771 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_READCOMPLETEVIEWMAPPIXELF0D_H__
-#define __FREESTYLE_PYTHON_READCOMPLETEVIEWMAPPIXELF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DFloat.h"
@@ -45,5 +44,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_READCOMPLETEVIEWMAPPIXELF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h
index 014a4aa2b8e..54c9ac984f9 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_READMAPPIXELF0D_H__
-#define __FREESTYLE_PYTHON_READMAPPIXELF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DFloat.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_READMAPPIXELF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
index 3cff99be633..f1fa1f1b7a2 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_READSTEERABLEVIEWMAPPIXELF0D_H__
-#define __FREESTYLE_PYTHON_READSTEERABLEVIEWMAPPIXELF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DFloat.h"
@@ -45,5 +44,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_READSTEERABLEVIEWMAPPIXELF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
index dd64fb40d85..510cc7ef146 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF0D_H__
-#define __FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DUnsigned.h"
@@ -45,5 +44,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h
index 82889b64aba..9e932ff9eff 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETOCCLUDERSF0D_H__
-#define __FREESTYLE_PYTHON_GETOCCLUDERSF0D_H__
+#pragma once
#include "../BPy_UnaryFunction0DVectorViewShape.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETOCCLUDERSF0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h
index cfd7f954b54..1fb42a18337 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION1DDOUBLE_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION1DDOUBLE_H__
+#pragma once
#include "../BPy_UnaryFunction1D.h"
@@ -48,5 +47,3 @@ int UnaryFunction1DDouble_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION1DDOUBLE_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h
index 1a7a5a2d7ee..886eb469d51 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION1DEDGENATURE_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION1DEDGENATURE_H__
+#pragma once
#include "../BPy_UnaryFunction1D.h"
@@ -50,5 +49,3 @@ int UnaryFunction1DEdgeNature_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION1DEDGENATURE_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h
index 8a5a329b0bf..8b977c9c96a 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION1DFLOAT_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION1DFLOAT_H__
+#pragma once
#include "../BPy_UnaryFunction1D.h"
@@ -48,5 +47,3 @@ int UnaryFunction1DFloat_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION1DFLOAT_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h
index b18bf34b27e..9149275b610 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION1DUNSIGNED_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION1DUNSIGNED_H__
+#pragma once
#include "../BPy_UnaryFunction1D.h"
@@ -48,5 +47,3 @@ int UnaryFunction1DUnsigned_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION1DUNSIGNED_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h
index f4cad92334f..b55f9af7c4d 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION1DVEC2F_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION1DVEC2F_H__
+#pragma once
#include "../BPy_UnaryFunction1D.h"
@@ -51,5 +50,3 @@ int UnaryFunction1DVec2f_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION1DVEC2F_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h
index 253a8d550e3..9e4342979e4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION1DVEC3F_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION1DVEC3F_H__
+#pragma once
#include "../BPy_UnaryFunction1D.h"
@@ -51,5 +50,3 @@ int UnaryFunction1DVec3f_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION1DVEC3F_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
index 80511e7c145..bfbcf5e451d 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION1DVECTORVIEWSHAPE_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION1DVECTORVIEWSHAPE_H__
+#pragma once
#include "../BPy_UnaryFunction1D.h"
@@ -53,5 +52,3 @@ int UnaryFunction1DVectorViewShape_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION1DVECTORVIEWSHAPE_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h
index 03d949f879d..3a821bc2083 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_UNARYFUNCTION1DVOID_H__
-#define __FREESTYLE_PYTHON_UNARYFUNCTION1DVOID_H__
+#pragma once
#include "../BPy_UnaryFunction1D.h"
@@ -48,5 +47,3 @@ int UnaryFunction1DVoid_Init(PyObject *module);
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_UNARYFUNCTION1DVOID_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h
index 15c381eb279..961c9729e6c 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CURVENATUREF1D_H__
-#define __FREESTYLE_PYTHON_CURVENATUREF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DEdgeNature.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CURVENATUREF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h
index 343c4379b4a..080f26aa753 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_NORMAL2DF1D_H__
-#define __FREESTYLE_PYTHON_NORMAL2DF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DVec2f.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_NORMAL2DF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h
index 5b453cbe714..013423003c6 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_ORIENTATION2DF1D_H__
-#define __FREESTYLE_PYTHON_ORIENTATION2DF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DVec2f.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_ORIENTATION2DF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h
index 26c6cd845db..2e79559bf43 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_ORIENTATION3DF1D_H__
-#define __FREESTYLE_PYTHON_ORIENTATION3DF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DVec3f.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_ORIENTATION3DF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h
index 7a3a3fcff4b..241c864fdad 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CURVATURE2DANGLEF1D_H__
-#define __FREESTYLE_PYTHON_CURVATURE2DANGLEF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CURVATURE2DANGLEF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h
index 71daa14069a..1b1040d66c4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_DENSITYF1D_H__
-#define __FREESTYLE_PYTHON_DENSITYF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_DENSITYF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
index dacfb33553e..1bbb4d46fc5 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETCOMPLETEVIEWMAPDENSITYF1D_H__
-#define __FREESTYLE_PYTHON_GETCOMPLETEVIEWMAPDENSITYF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -45,5 +44,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETCOMPLETEVIEWMAPDENSITYF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
index b039fadcdca..8e55fc7cc50 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETDIRECTIONALVIEWMAPDENSITYF1D_H__
-#define __FREESTYLE_PYTHON_GETDIRECTIONALVIEWMAPDENSITYF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -45,5 +44,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETDIRECTIONALVIEWMAPDENSITYF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h
index febb3265f97..66bd3983e45 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETPROJECTEDXF1D_H__
-#define __FREESTYLE_PYTHON_GETPROJECTEDXF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETPROJECTEDXF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h
index 5a0a5f42cb0..b1a1e90f83f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETPROJECTEDYF1D_H__
-#define __FREESTYLE_PYTHON_GETPROJECTEDYF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETPROJECTEDYF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h
index aeb42521d1f..73b01bbf999 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETPROJECTEDZF1D_H__
-#define __FREESTYLE_PYTHON_GETPROJECTEDZF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETPROJECTEDZF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
index 47f168af2a8..81167d36352 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETSTEERABLEVIEWMAPDENSITYF1D_H__
-#define __FREESTYLE_PYTHON_GETSTEERABLEVIEWMAPDENSITYF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETSTEERABLEVIEWMAPDENSITYF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h
index 4f19b4ac67f..0e4a67cf4df 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF1D_H__
-#define __FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -45,5 +44,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h
index 7db31882381..30218ccd5e5 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETXF1D_H__
-#define __FREESTYLE_PYTHON_GETXF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETXF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h
index 3f70d64e200..16afac368c1 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETYF1D_H__
-#define __FREESTYLE_PYTHON_GETYF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETYF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h
index b841bde2a5c..a204f3d6665 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETZF1D_H__
-#define __FREESTYLE_PYTHON_GETZF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETZF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h
index 258d028bfbd..d472489fb0c 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF1D_H__
-#define __FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h
index c336591842b..c1966472377 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_ZDISCONTINUITYF1D_H__
-#define __FREESTYLE_PYTHON_ZDISCONTINUITYF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DDouble.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_ZDISCONTINUITYF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
index 0d4d118995b..c76e5f821f2 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF1D_H__
-#define __FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DUnsigned.h"
@@ -45,5 +44,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h
index 5a14b5dc35d..2e414446e47 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETOCCLUDEEF1D_H__
-#define __FREESTYLE_PYTHON_GETOCCLUDEEF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DVectorViewShape.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETOCCLUDEEF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h
index 29899d443a6..52c78bd7f4c 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETOCCLUDERSF1D_H__
-#define __FREESTYLE_PYTHON_GETOCCLUDERSF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DVectorViewShape.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETOCCLUDERSF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h
index b90f3df5831..9c025e3b404 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_GETSHAPEF1D_H__
-#define __FREESTYLE_PYTHON_GETSHAPEF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DVectorViewShape.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_GETSHAPEF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h
index c6423ef434f..0a8650d6794 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CHAININGTIMESTAMPF1D_H__
-#define __FREESTYLE_PYTHON_CHAININGTIMESTAMPF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DVoid.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CHAININGTIMESTAMPF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
index 0d74b1f7756..e555788f4c9 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_INCREMENTCHAININGTIMESTAMPF1D_H__
-#define __FREESTYLE_PYTHON_INCREMENTCHAININGTIMESTAMPF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DVoid.h"
@@ -45,5 +44,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_INCREMENTCHAININGTIMESTAMPF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h
index 4787f35cfc5..117d724d179 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_TIMESTAMPF1D_H__
-#define __FREESTYLE_PYTHON_TIMESTAMPF1D_H__
+#pragma once
#include "../BPy_UnaryFunction1DVoid.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CHAININGTIMESTAMPF1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h
index b947ccf5b95..0c36e770b80 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_FALSEUP0D_H__
-#define __FREESTYLE_PYTHON_FALSEUP0D_H__
+#pragma once
#include "../BPy_UnaryPredicate0D.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_FALSEUP0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h
index 72acf363992..abdfb4e294d 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_TRUEUP0D_H__
-#define __FREESTYLE_PYTHON_TRUEUP0D_H__
+#pragma once
#include "../BPy_UnaryPredicate0D.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_TRUEUP0D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h
index de6c40fa8ac..be06a0fee33 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_CONTOURUP1D_H__
-#define __FREESTYLE_PYTHON_CONTOURUP1D_H__
+#pragma once
#include "../BPy_UnaryPredicate1D.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_CONTOURUP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h
index fb02b63fa3d..068c7727ec0 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_DENSITYLOWERTHANUP1D_H__
-#define __FREESTYLE_PYTHON_DENSITYLOWERTHANUP1D_H__
+#pragma once
#include "../BPy_UnaryPredicate1D.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_DENSITYLOWERTHANUP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
index e2ba8b7709b..d103c1356ab 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_EQUALTOCHAININGTIMESTAMPUP1D_H__
-#define __FREESTYLE_PYTHON_EQUALTOCHAININGTIMESTAMPUP1D_H__
+#pragma once
#include "../BPy_UnaryPredicate1D.h"
@@ -45,5 +44,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_EQUALTOCHAININGTIMESTAMPUP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h
index 13736242382..9e3d90ab760 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_EQUALTOTIMESTAMPUP1D_H__
-#define __FREESTYLE_PYTHON_EQUALTOTIMESTAMPUP1D_H__
+#pragma once
#include "../BPy_UnaryPredicate1D.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_EQUALTOTIMESTAMPUP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h
index 4d2a22731fa..0576b727f4a 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_EXTERNALCONTOURUP1D_H__
-#define __FREESTYLE_PYTHON_EXTERNALCONTOURUP1D_H__
+#pragma once
#include "../BPy_UnaryPredicate1D.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_EXTERNALCONTOURUP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h
index 57255c2333f..a74d2aba0a6 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_FALSEUP1D_H__
-#define __FREESTYLE_PYTHON_FALSEUP1D_H__
+#pragma once
#include "../BPy_UnaryPredicate1D.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_FALSEUP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
index bbb1dce5ed1..970ddd48273 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYUP1D_H__
-#define __FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYUP1D_H__
+#pragma once
#include "../BPy_UnaryPredicate1D.h"
@@ -45,5 +44,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYUP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h
index a48ed0aa0da..c60aa7aa9cf 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_SHAPEUP1D_H__
-#define __FREESTYLE_PYTHON_SHAPEUP1D_H__
+#pragma once
#include "../BPy_UnaryPredicate1D.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_SHAPEUP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h
index 49c3dcdacca..e036cfe95ed 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_TRUEUP1D_H__
-#define __FREESTYLE_PYTHON_TRUEUP1D_H__
+#pragma once
#include "../BPy_UnaryPredicate1D.h"
@@ -43,5 +42,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_TRUEUP1D_H__ */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.h
index 2481beee78e..1d08f7fb530 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.h
@@ -18,8 +18,7 @@
* \ingroup freestyle
*/
-#ifndef __FREESTYLE_PYTHON_WITHINIMAGEBOUNDARYUP1D_H__
-#define __FREESTYLE_PYTHON_WITHINIMAGEBOUNDARYUP1D_H__
+#pragma once
#include "../BPy_UnaryPredicate1D.h"
@@ -44,5 +43,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-
-#endif /* __FREESTYLE_PYTHON_WITHINIMAGEBOUNDARYUP1D_H__ */
diff --git a/source/blender/freestyle/intern/scene_graph/DrawingStyle.h b/source/blender/freestyle/intern/scene_graph/DrawingStyle.h
index 631f4b99adc..ca1e2351868 100644
--- a/source/blender/freestyle/intern/scene_graph/DrawingStyle.h
+++ b/source/blender/freestyle/intern/scene_graph/DrawingStyle.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_DRAWING_STYLE_H__
-#define __FREESTYLE_DRAWING_STYLE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -124,5 +123,3 @@ DrawingStyle &DrawingStyle::operator=(const DrawingStyle &ds)
}
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_DRAWING_STYLE_H__
diff --git a/source/blender/freestyle/intern/scene_graph/FrsMaterial.h b/source/blender/freestyle/intern/scene_graph/FrsMaterial.h
index 80cd783f164..18d3c8839dd 100644
--- a/source/blender/freestyle/intern/scene_graph/FrsMaterial.h
+++ b/source/blender/freestyle/intern/scene_graph/FrsMaterial.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_MATERIAL_H__
-#define __FREESTYLE_MATERIAL_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -479,5 +478,3 @@ bool FrsMaterial::operator==(const FrsMaterial &m) const
}
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_MATERIAL_H__
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
index f8dd25913c1..9d1fc009e37 100644
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_INDEXED_FACE_SET_H__
-#define __FREESTYLE_INDEXED_FACE_SET_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -311,5 +310,3 @@ class IndexedFaceSet : public Rep {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_INDEXED_FACE_SET_H__
diff --git a/source/blender/freestyle/intern/scene_graph/LineRep.h b/source/blender/freestyle/intern/scene_graph/LineRep.h
index e45a33d9fc4..43fd736570f 100644
--- a/source/blender/freestyle/intern/scene_graph/LineRep.h
+++ b/source/blender/freestyle/intern/scene_graph/LineRep.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_LINE_REP_H__
-#define __FREESTYLE_LINE_REP_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -149,5 +148,3 @@ class LineRep : public Rep {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_LINE_REP_H__
diff --git a/source/blender/freestyle/intern/scene_graph/Node.h b/source/blender/freestyle/intern/scene_graph/Node.h
index 96072993590..07bf186ea39 100644
--- a/source/blender/freestyle/intern/scene_graph/Node.h
+++ b/source/blender/freestyle/intern/scene_graph/Node.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_NODE_H__
-#define __FREESTYLE_NODE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -113,5 +112,3 @@ class Node : public BaseObject {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_NODE_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp b/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp
index ad2310d7875..052ae73da43 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp
@@ -52,8 +52,8 @@ NodeCamera::NodeCamera(CameraType camera_type) : camera_type_(camera_type)
#if 0 /* UNUSED, gives warning in gcc */
NodeCamera::NodeCamera(const NodeCamera &iBrother) : camera_type_(iBrother.camera_type_)
{
- memcpy(modelview_matrix_, iBrother.modelview_matrix_, 16 * sizeof(double));
- memcpy(projection_matrix_, iBrother.projection_matrix_, 16 * sizeof(double));
+ memcpy(modelview_matrix_, iBrother.modelview_matrix_, sizeof(double[16]));
+ memcpy(projection_matrix_, iBrother.projection_matrix_, sizeof(double[16]));
}
#endif
@@ -64,12 +64,12 @@ void NodeCamera::accept(SceneVisitor &v)
void NodeCamera::setModelViewMatrix(double modelview_matrix[16])
{
- memcpy(modelview_matrix_, modelview_matrix, 16 * sizeof(double));
+ memcpy(modelview_matrix_, modelview_matrix, sizeof(double[16]));
}
void NodeCamera::setProjectionMatrix(double projection_matrix[16])
{
- memcpy(projection_matrix_, projection_matrix, 16 * sizeof(double));
+ memcpy(projection_matrix_, projection_matrix, sizeof(double[16]));
}
NodeOrthographicCamera::NodeOrthographicCamera()
diff --git a/source/blender/freestyle/intern/scene_graph/NodeCamera.h b/source/blender/freestyle/intern/scene_graph/NodeCamera.h
index 2878e7a834e..cc7b1f7f67c 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeCamera.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeCamera.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_NODE_CAMERA_H__
-#define __FREESTYLE_NODE_CAMERA_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -217,5 +216,3 @@ class NodePerspectiveCamera : public NodeCamera {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_NODE_CAMERA_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
index f1dfad06250..8bbdaf30bad 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_NODE_DRAWING_STYLE_H__
-#define __FREESTYLE_NODE_DRAWING_STYLE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -106,5 +105,3 @@ class NodeDrawingStyle : public NodeGroup {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_NODE_DRAWING_STYLE_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.h b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
index 5ef16255e46..0558e22bed1 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeGroup.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_NODE_GROUP_H__
-#define __FREESTYLE_NODE_GROUP_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -80,5 +79,3 @@ class NodeGroup : public Node {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_NODE_GROUP_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeLight.h b/source/blender/freestyle/intern/scene_graph/NodeLight.h
index 046b61beaf4..bf8389441b6 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeLight.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeLight.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_NODE_LIGHT_H__
-#define __FREESTYLE_NODE_LIGHT_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -101,5 +100,3 @@ class NodeLight : public Node {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_NODE_LIGHT_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeShape.h b/source/blender/freestyle/intern/scene_graph/NodeShape.h
index 13ee265ec10..5f7a24b85d5 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeShape.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeShape.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_NODE_SHAPE_H__
-#define __FREESTYLE_NODE_SHAPE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -93,5 +92,3 @@ class NodeShape : public Node {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_NODE_SHAPE_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeTransform.h b/source/blender/freestyle/intern/scene_graph/NodeTransform.h
index 1118417657f..9d55046a515 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeTransform.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeTransform.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_NODE_TRANSFORM_H__
-#define __FREESTYLE_NODE_TRANSFORM_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -98,5 +97,3 @@ class NodeTransform : public NodeGroup {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_NODE_TRANSFORM_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeViewLayer.h b/source/blender/freestyle/intern/scene_graph/NodeViewLayer.h
index 2339abe9aed..d52155eb216 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeViewLayer.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeViewLayer.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_NODE_VIEW_LAYER_H__
-#define __FREESTYLE_NODE_VIEW_LAYER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -59,5 +58,3 @@ class NodeViewLayer : public Node {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_NODE_VIEW_LAYER_H__
diff --git a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp
index 9e83527acad..e8e21d37d00 100644
--- a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp
+++ b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp
@@ -27,7 +27,9 @@ namespace Freestyle {
void OrientedLineRep::accept(SceneVisitor &v)
{
- Rep::accept(v);
+ Rep::accept(v); // NOLINT(bugprone-parent-virtual-call), this seems to intentionally *not* call
+ // the parent class' accept() function, but rather the grandparent's. The
+ // v.visitLineRep(*this); call below is actually what the parent class would do.
if (!frs_material()) {
v.visitOrientedLineRep(*this);
}
diff --git a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h
index 2e39259077e..c33fd529c69 100644
--- a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h
+++ b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_ORIENTED_LINE_REP_H__
-#define __FREESTYLE_ORIENTED_LINE_REP_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -62,5 +61,3 @@ class OrientedLineRep : public LineRep {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_ORIENTED_LINE_REP_H__
diff --git a/source/blender/freestyle/intern/scene_graph/Rep.h b/source/blender/freestyle/intern/scene_graph/Rep.h
index 58553d257d9..dae5272beed 100644
--- a/source/blender/freestyle/intern/scene_graph/Rep.h
+++ b/source/blender/freestyle/intern/scene_graph/Rep.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_REP_H__
-#define __FREESTYLE_REP_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -181,5 +180,3 @@ class Rep : public BaseObject {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_REP_H__
diff --git a/source/blender/freestyle/intern/scene_graph/SceneHash.h b/source/blender/freestyle/intern/scene_graph/SceneHash.h
index 05c0880f806..605e2ddaa84 100644
--- a/source/blender/freestyle/intern/scene_graph/SceneHash.h
+++ b/source/blender/freestyle/intern/scene_graph/SceneHash.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_SCENE_HASH_H__
-#define __FREESTYLE_SCENE_HASH_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -78,5 +77,3 @@ class SceneHash : public SceneVisitor {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_SCENE_HASH_H__
diff --git a/source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.h b/source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.h
index f19233bba3b..9436bdccf57 100644
--- a/source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.h
+++ b/source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_SCENE_PRETTY_PRINTER_H__
-#define __FREESTYLE_SCENE_PRETTY_PRINTER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -96,5 +95,3 @@ class ScenePrettyPrinter : public SceneVisitor {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_SCENE_PRETTY_PRINTER_H__
diff --git a/source/blender/freestyle/intern/scene_graph/SceneVisitor.h b/source/blender/freestyle/intern/scene_graph/SceneVisitor.h
index 81a478e8cf3..72e0f4cbb28 100644
--- a/source/blender/freestyle/intern/scene_graph/SceneVisitor.h
+++ b/source/blender/freestyle/intern/scene_graph/SceneVisitor.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_SCENE_VISITOR_H__
-#define __FREESTYLE_SCENE_VISITOR_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -111,5 +110,3 @@ class SceneVisitor {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_SCENE_VISITOR_H__
diff --git a/source/blender/freestyle/intern/scene_graph/TriangleRep.h b/source/blender/freestyle/intern/scene_graph/TriangleRep.h
index e4190faae6f..4461b38d68b 100644
--- a/source/blender/freestyle/intern/scene_graph/TriangleRep.h
+++ b/source/blender/freestyle/intern/scene_graph/TriangleRep.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_TRIANGLE_REP_H__
-#define __FREESTYLE_TRIANGLE_REP_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -142,5 +141,3 @@ class TriangleRep : public Rep {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_TRIANGLE_REP_H__
diff --git a/source/blender/freestyle/intern/scene_graph/VertexRep.h b/source/blender/freestyle/intern/scene_graph/VertexRep.h
index 3831be3105a..278cfa694f7 100644
--- a/source/blender/freestyle/intern/scene_graph/VertexRep.h
+++ b/source/blender/freestyle/intern/scene_graph/VertexRep.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_VERTEX_REP_H__
-#define __FREESTYLE_VERTEX_REP_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -129,5 +128,3 @@ class VertexRep : public Rep {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_VERTEX_REP_H__
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
index dcab48fd12f..17e419bed54 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_ADVANCED_FUNCTIONS_0D_H__
-#define __FREESTYLE_ADVANCED_FUNCTIONS_0D_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -209,5 +208,3 @@ class GetViewMapGradientNormF0D : public UnaryFunction0D<float> {
} // end of namespace Functions0D
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_ADVANCED_FUNCTIONS_0D_H__
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
index d14a9836b95..349db393e17 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_ADVANCED_FUNCTIONS_1D_H__
-#define __FREESTYLE_ADVANCED_FUNCTIONS_1D_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -289,5 +288,3 @@ class GetViewMapGradientNormF1D : public UnaryFunction1D<double> {
} // end of namespace Functions1D
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_ADVANCED_FUNCTIONS_1D_H__
diff --git a/source/blender/freestyle/intern/stroke/AdvancedPredicates1D.h b/source/blender/freestyle/intern/stroke/AdvancedPredicates1D.h
index 05fcf7f356f..25a5efcce34 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedPredicates1D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedPredicates1D.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_ADVANCED_PREDICATES_1D_H__
-#define __FREESTYLE_ADVANCED_PREDICATES_1D_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -82,5 +81,3 @@ class DensityLowerThanUP1D : public UnaryPredicate1D {
} // end of namespace Predicates1D
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_ADVANCED_PREDICATES_1D_H__
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
index 544fdee519f..63c7d451599 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_ADVANCED_STROKE_SHADERS_H__
-#define __FREESTYLE_ADVANCED_STROKE_SHADERS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -232,5 +231,3 @@ class OmissionShader : public StrokeShader {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_ADVANCED_STROKE_SHADERS_H__
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
index 5a2d0cbe458..8663cfd42bf 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_BASIC_STROKE_SHADERS_H__
-#define __FREESTYLE_BASIC_STROKE_SHADERS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -660,5 +659,3 @@ class StrokeTextureStepShader : public StrokeShader {
} // end of namespace StrokeShaders
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_BASIC_STROKE_SHADERS_H__
diff --git a/source/blender/freestyle/intern/stroke/Canvas.h b/source/blender/freestyle/intern/stroke/Canvas.h
index 2a0ebbe17c5..2bbd9c2682f 100644
--- a/source/blender/freestyle/intern/stroke/Canvas.h
+++ b/source/blender/freestyle/intern/stroke/Canvas.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_CANVAS_H__
-#define __FREESTYLE_CANVAS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -252,5 +251,3 @@ class Canvas {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_CANVAS_H__
diff --git a/source/blender/freestyle/intern/stroke/Chain.h b/source/blender/freestyle/intern/stroke/Chain.h
index 7cd0c64cc16..d5dae5c35ba 100644
--- a/source/blender/freestyle/intern/stroke/Chain.h
+++ b/source/blender/freestyle/intern/stroke/Chain.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_CHAIN_H__
-#define __FREESTYLE_CHAIN_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -109,5 +108,3 @@ class Chain : public Curve {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_CHAIN_H__
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
index 271db48aabe..2b2ab0dc14a 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
@@ -169,7 +169,7 @@ int ChainSilhouetteIterator::traverse(const AdjacencyIterator &ait)
Nature::VALLEY,
Nature::RIDGE,
};
- int numNatures = sizeof(natures) / sizeof(Nature::EdgeNature);
+ int numNatures = ARRAY_SIZE(natures);
for (int i = 0; i < numNatures; ++i) {
if (getCurrentEdge()->getNature() & natures[i]) {
int n = 0;
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.h b/source/blender/freestyle/intern/stroke/ChainingIterators.h
index 36611a4a009..e3d49c167b5 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.h
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_CHAINING_ITERATORS_H__
-#define __FREESTYLE_CHAINING_ITERATORS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -415,5 +414,3 @@ class ChainPredicateIterator : public ChainingIterator {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_CHAINING_ITERATORS_H__
diff --git a/source/blender/freestyle/intern/stroke/ContextFunctions.h b/source/blender/freestyle/intern/stroke/ContextFunctions.h
index 6897e2b193d..334bdd657c1 100644
--- a/source/blender/freestyle/intern/stroke/ContextFunctions.h
+++ b/source/blender/freestyle/intern/stroke/ContextFunctions.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_CONTEXT_FUNCTIONS_H__
-#define __FREESTYLE_CONTEXT_FUNCTIONS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -106,5 +105,3 @@ FEdge *GetSelectedFEdgeCF();
} // end of namespace ContextFunctions
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_CONTEXT_FUNCTIONS_H__
diff --git a/source/blender/freestyle/intern/stroke/Curve.cpp b/source/blender/freestyle/intern/stroke/Curve.cpp
index 02a1d32953d..51c40c890a3 100644
--- a/source/blender/freestyle/intern/stroke/Curve.cpp
+++ b/source/blender/freestyle/intern/stroke/Curve.cpp
@@ -216,10 +216,10 @@ FEdge *CurvePoint::getFEdge(Interface0D &inter)
if (iVertexB->__B == 0) {
return __A->getFEdge(*(iVertexB->__A));
}
- else if (iVertexB->__A == __A) {
+ if (iVertexB->__A == __A) {
return __A->getFEdge(*(iVertexB->__B));
}
- else if (iVertexB->__B == __A) {
+ if (iVertexB->__B == __A) {
return __A->getFEdge(*(iVertexB->__A));
}
}
@@ -227,7 +227,7 @@ FEdge *CurvePoint::getFEdge(Interface0D &inter)
if (iVertexB->__A == __A) {
return __B->getFEdge(*(iVertexB->__A));
}
- else if (iVertexB->__A == __B) {
+ if (iVertexB->__A == __B) {
return __A->getFEdge(*(iVertexB->__A));
}
}
diff --git a/source/blender/freestyle/intern/stroke/Curve.h b/source/blender/freestyle/intern/stroke/Curve.h
index 8a233eef4ab..5f0d2a6aed7 100644
--- a/source/blender/freestyle/intern/stroke/Curve.h
+++ b/source/blender/freestyle/intern/stroke/Curve.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_CURVE_H__
-#define __FREESTYLE_CURVE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -604,5 +603,3 @@ class Curve : public Interface1D {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_CURVE_H__
diff --git a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
index 4ac4c04774e..1896a674477 100644
--- a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
+++ b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_CURVE_ADVANCED_ITERATORS_H__
-#define __FREESTYLE_CURVE_ADVANCED_ITERATORS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -388,5 +387,3 @@ class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Tr
} // end of namespace CurveInternal
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_CURVE_ADVANCED_ITERATORS_H__
diff --git a/source/blender/freestyle/intern/stroke/CurveIterators.h b/source/blender/freestyle/intern/stroke/CurveIterators.h
index 3ac7ede0954..9d1cf33ed80 100644
--- a/source/blender/freestyle/intern/stroke/CurveIterators.h
+++ b/source/blender/freestyle/intern/stroke/CurveIterators.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_CURVE_ITERATORS_H__
-#define __FREESTYLE_CURVE_ITERATORS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -303,5 +302,3 @@ class CurvePointIterator : public Interface0DIteratorNested {
} // end of namespace CurveInternal
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_CURVE_ITERATORS_H__
diff --git a/source/blender/freestyle/intern/stroke/Modifiers.h b/source/blender/freestyle/intern/stroke/Modifiers.h
index ecdfd25c499..0aac6f58658 100644
--- a/source/blender/freestyle/intern/stroke/Modifiers.h
+++ b/source/blender/freestyle/intern/stroke/Modifiers.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_MODIFIERS_H__
-#define __FREESTYLE_MODIFIERS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -71,5 +70,3 @@ template<class Edge> struct TimestampModifier : public EdgeModifier<Edge> {
};
} /* namespace Freestyle */
-
-#endif // MODIFIERS_H
diff --git a/source/blender/freestyle/intern/stroke/Module.h b/source/blender/freestyle/intern/stroke/Module.h
index 3e32361eb45..58c44751d91 100644
--- a/source/blender/freestyle/intern/stroke/Module.h
+++ b/source/blender/freestyle/intern/stroke/Module.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_MODULE_H__
-#define __FREESTYLE_MODULE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -76,5 +75,3 @@ class Module {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_MODULE_H__
diff --git a/source/blender/freestyle/intern/stroke/Operators.h b/source/blender/freestyle/intern/stroke/Operators.h
index 2da9d30f172..e721e9fb837 100644
--- a/source/blender/freestyle/intern/stroke/Operators.h
+++ b/source/blender/freestyle/intern/stroke/Operators.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_OPERATORS_H__
-#define __FREESTYLE_OPERATORS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -290,5 +289,3 @@ class Operators {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_OPERATORS_H__
diff --git a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h
index 7ddd3d3e4c0..78aa17d26b6 100644
--- a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h
+++ b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_PS_STROKE_RENDERER_H__
-#define __FREESTYLE_PS_STROKE_RENDERER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -55,5 +54,3 @@ class PSStrokeRenderer : public StrokeRenderer {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_PS_STROKE_RENDERER_H__
diff --git a/source/blender/freestyle/intern/stroke/Predicates0D.h b/source/blender/freestyle/intern/stroke/Predicates0D.h
index 90b6d99f2db..89dbaeb339d 100644
--- a/source/blender/freestyle/intern/stroke/Predicates0D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates0D.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_PREDICATES_0D_H__
-#define __FREESTYLE_PREDICATES_0D_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -178,5 +177,3 @@ class FalseUP0D : public UnaryPredicate0D {
} // end of namespace Predicates0D
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_PREDICATES_0D_H__
diff --git a/source/blender/freestyle/intern/stroke/Predicates1D.h b/source/blender/freestyle/intern/stroke/Predicates1D.h
index 0ad4c69f869..a3953950d86 100644
--- a/source/blender/freestyle/intern/stroke/Predicates1D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates1D.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_PREDICATES_1D_H__
-#define __FREESTYLE_PREDICATES_1D_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -580,5 +579,3 @@ class ViewMapGradientNormBP1D : public BinaryPredicate1D {
} // end of namespace Predicates1D
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_PREDICATES_1D_H__
diff --git a/source/blender/freestyle/intern/stroke/QInformationMap.h b/source/blender/freestyle/intern/stroke/QInformationMap.h
index d3a4218f9d7..0f651a656bf 100644
--- a/source/blender/freestyle/intern/stroke/QInformationMap.h
+++ b/source/blender/freestyle/intern/stroke/QInformationMap.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_Q_INFORMATION_MAP_H__
-#define __FREESTYLE_Q_INFORMATION_MAP_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -59,5 +58,3 @@ class QInformationMap : public InformationMap {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_Q_INFORMATION_MAP_H__
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index 7983e8cdde2..71753b25328 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STROKE_H__
-#define __FREESTYLE_STROKE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -894,5 +893,3 @@ Stroke::Stroke(InputVertexIterator iBegin, InputVertexIterator iEnd)
}
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STROKE_H__
diff --git a/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h b/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
index b8c96533a1c..4256cdebe86 100644
--- a/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
+++ b/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STROKE_ADVANCED_ITERATORS_H__
-#define __FREESTYLE_STROKE_ADVANCED_ITERATORS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -179,5 +178,3 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
} // end of namespace StrokeInternal
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STROKE_ADVANCED_ITERATORS_H__
diff --git a/source/blender/freestyle/intern/stroke/StrokeIO.h b/source/blender/freestyle/intern/stroke/StrokeIO.h
index ae38847f8cc..a0e59655eed 100644
--- a/source/blender/freestyle/intern/stroke/StrokeIO.h
+++ b/source/blender/freestyle/intern/stroke/StrokeIO.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STROKE_IO_H__
-#define __FREESTYLE_STROKE_IO_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -37,5 +36,3 @@ ostream &operator<<(ostream &out, const StrokeVertex &iStrokeVertex);
ostream &operator<<(ostream &out, const Stroke &iStroke);
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STROKE_IO_H__
diff --git a/source/blender/freestyle/intern/stroke/StrokeIterators.h b/source/blender/freestyle/intern/stroke/StrokeIterators.h
index 71932d8487a..d4cbffd535e 100644
--- a/source/blender/freestyle/intern/stroke/StrokeIterators.h
+++ b/source/blender/freestyle/intern/stroke/StrokeIterators.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STROKE_ITERATORS_H__
-#define __FREESTYLE_STROKE_ITERATORS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -232,5 +231,3 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
} // end of namespace StrokeInternal
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STROKE_ITERATORS_H__
diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.h b/source/blender/freestyle/intern/stroke/StrokeLayer.h
index ecb98025875..2101e7732ce 100644
--- a/source/blender/freestyle/intern/stroke/StrokeLayer.h
+++ b/source/blender/freestyle/intern/stroke/StrokeLayer.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STROKE_LAYER_H__
-#define __FREESTYLE_STROKE_LAYER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -102,5 +101,3 @@ class StrokeLayer {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STROKE_LAYER_H__
diff --git a/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp b/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
index a76579c7c96..a29d015b4c9 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRenderer.cpp
@@ -101,9 +101,8 @@ unsigned TextureManager::getBrushTextureIndex(string name, Stroke::MediumType lo
cerr << "brush file " << name << " not found" << endl;
return 0;
}
- else {
- return _brushesMap[bt];
- }
+
+ return _brushesMap[bt];
}
void TextureManager::Options::setPatternsPath(const string &path)
diff --git a/source/blender/freestyle/intern/stroke/StrokeRenderer.h b/source/blender/freestyle/intern/stroke/StrokeRenderer.h
index 67deb5eebf3..2fb08b880d9 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRenderer.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRenderer.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STROKE_RENDERER_H__
-#define __FREESTYLE_STROKE_RENDERER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -142,5 +141,3 @@ class StrokeRenderer {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STROKE_RENDERER_H__
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.h b/source/blender/freestyle/intern/stroke/StrokeRep.h
index d6ee1d01279..09048b8e147 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STROKE_REP_H__
-#define __FREESTYLE_STROKE_REP_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -278,5 +277,3 @@ class StrokeRep {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STROKE_REP_H__
diff --git a/source/blender/freestyle/intern/stroke/StrokeShader.h b/source/blender/freestyle/intern/stroke/StrokeShader.h
index 7b1f12a8c9d..f4984136747 100644
--- a/source/blender/freestyle/intern/stroke/StrokeShader.h
+++ b/source/blender/freestyle/intern/stroke/StrokeShader.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STROKE_SHADERS_H__
-#define __FREESTYLE_STROKE_SHADERS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -96,5 +95,3 @@ class StrokeShader {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STROKE_SHADERS_H__
diff --git a/source/blender/freestyle/intern/stroke/StrokeTesselator.h b/source/blender/freestyle/intern/stroke/StrokeTesselator.h
index 8cece705ed4..0c1efb873bc 100644
--- a/source/blender/freestyle/intern/stroke/StrokeTesselator.h
+++ b/source/blender/freestyle/intern/stroke/StrokeTesselator.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STROKE_TESSELATOR_H__
-#define __FREESTYLE_STROKE_TESSELATOR_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -73,5 +72,3 @@ class StrokeTesselator {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STROKE_TESSELATOR_H__
diff --git a/source/blender/freestyle/intern/stroke/StyleModule.h b/source/blender/freestyle/intern/stroke/StyleModule.h
index 6f03d903045..398e4c7ee77 100644
--- a/source/blender/freestyle/intern/stroke/StyleModule.h
+++ b/source/blender/freestyle/intern/stroke/StyleModule.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STYLE_MODULE_H__
-#define __FREESTYLE_STYLE_MODULE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -182,5 +181,3 @@ class StyleModule {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STYLE_MODULE_H__
diff --git a/source/blender/freestyle/intern/system/BaseIterator.h b/source/blender/freestyle/intern/system/BaseIterator.h
index 651f2bf4387..7792fded4cb 100644
--- a/source/blender/freestyle/intern/system/BaseIterator.h
+++ b/source/blender/freestyle/intern/system/BaseIterator.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_BASE_ITERATOR_H__
-#define __FREESTYLE_BASE_ITERATOR_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -103,5 +102,3 @@ template<class Traits, class IteratorTagTraits> class IteratorBase {
};
} /* namespace Freestyle */
-
-#endif // BASEITERATOR_H
diff --git a/source/blender/freestyle/intern/system/BaseObject.h b/source/blender/freestyle/intern/system/BaseObject.h
index 335221223dc..76d30aa74e2 100644
--- a/source/blender/freestyle/intern/system/BaseObject.h
+++ b/source/blender/freestyle/intern/system/BaseObject.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_BASE_OBJECT_H__
-#define __FREESTYLE_BASE_OBJECT_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -72,5 +71,3 @@ class BaseObject {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_BASE_OBJECT_H__
diff --git a/source/blender/freestyle/intern/system/Cast.h b/source/blender/freestyle/intern/system/Cast.h
index 44fd86a9b43..db0defbae22 100644
--- a/source/blender/freestyle/intern/system/Cast.h
+++ b/source/blender/freestyle/intern/system/Cast.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_CAST_H__
-#define __FREESTYLE_CAST_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -35,5 +34,3 @@ template<class T, class U> U *cast(T *in)
} // end of namespace Cast
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_CAST_H__
diff --git a/source/blender/freestyle/intern/system/Exception.h b/source/blender/freestyle/intern/system/Exception.h
index 0efd136af8f..618c2171fb9 100644
--- a/source/blender/freestyle/intern/system/Exception.h
+++ b/source/blender/freestyle/intern/system/Exception.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_EXCEPTION_H__
-#define __FREESTYLE_EXCEPTION_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -62,5 +61,3 @@ class Exception {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_EXCEPTION_H__
diff --git a/source/blender/freestyle/intern/system/FreestyleConfig.h b/source/blender/freestyle/intern/system/FreestyleConfig.h
index 34db7121eaf..032da864e6c 100644
--- a/source/blender/freestyle/intern/system/FreestyleConfig.h
+++ b/source/blender/freestyle/intern/system/FreestyleConfig.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_CONFIG_H__
-#define __FREESTYLE_CONFIG_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -43,5 +42,3 @@ static const string PATH_SEP(":");
} // end of namespace Config
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_CONFIG_H__
diff --git a/source/blender/freestyle/intern/system/Id.h b/source/blender/freestyle/intern/system/Id.h
index 549def6cabb..f94e044de29 100644
--- a/source/blender/freestyle/intern/system/Id.h
+++ b/source/blender/freestyle/intern/system/Id.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_ID_H__
-#define __FREESTYLE_ID_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -138,5 +137,3 @@ inline std::ostream &operator<<(std::ostream &s, const Id &id)
}
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_ID_H__
diff --git a/source/blender/freestyle/intern/system/Interpreter.h b/source/blender/freestyle/intern/system/Interpreter.h
index 911d03318e5..0a5c0302fe6 100644
--- a/source/blender/freestyle/intern/system/Interpreter.h
+++ b/source/blender/freestyle/intern/system/Interpreter.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_INTERPRETER_H__
-#define __FREESTYLE_INTERPRETER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -61,5 +60,3 @@ class Interpreter {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_INTERPRETER_H__
diff --git a/source/blender/freestyle/intern/system/Iterator.h b/source/blender/freestyle/intern/system/Iterator.h
index 75d49521f96..d2086f637d9 100644
--- a/source/blender/freestyle/intern/system/Iterator.h
+++ b/source/blender/freestyle/intern/system/Iterator.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_ITERATOR_H__
-#define __FREESTYLE_ITERATOR_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -73,5 +72,3 @@ class Iterator {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_ITERATOR_H__
diff --git a/source/blender/freestyle/intern/system/PointerSequence.h b/source/blender/freestyle/intern/system/PointerSequence.h
index d136632f060..c2301ee740d 100644
--- a/source/blender/freestyle/intern/system/PointerSequence.h
+++ b/source/blender/freestyle/intern/system/PointerSequence.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_POINTER_SEQUENCE_H__
-#define __FREESTYLE_POINTER_SEQUENCE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -91,5 +90,3 @@ template<typename C, typename T> class PointerSequence : public C {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_POINTER_SEQUENCE_H__
diff --git a/source/blender/freestyle/intern/system/Precision.h b/source/blender/freestyle/intern/system/Precision.h
index c6695f207cc..6a6435299ca 100644
--- a/source/blender/freestyle/intern/system/Precision.h
+++ b/source/blender/freestyle/intern/system/Precision.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_PRECISION_H__
-#define __FREESTYLE_PRECISION_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -31,5 +30,3 @@ static const real M_EPSILON = 0.00000001;
#endif // SWIG
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_PRECISION_H__
diff --git a/source/blender/freestyle/intern/system/ProgressBar.h b/source/blender/freestyle/intern/system/ProgressBar.h
index b3a1f98f15e..d7b02c48359 100644
--- a/source/blender/freestyle/intern/system/ProgressBar.h
+++ b/source/blender/freestyle/intern/system/ProgressBar.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_PROGRESS_BAR_H__
-#define __FREESTYLE_PROGRESS_BAR_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -92,5 +91,3 @@ class ProgressBar {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_PROGRESS_BAR_H__
diff --git a/source/blender/freestyle/intern/system/PseudoNoise.cpp b/source/blender/freestyle/intern/system/PseudoNoise.cpp
index 048be5d018c..c05c269c404 100644
--- a/source/blender/freestyle/intern/system/PseudoNoise.cpp
+++ b/source/blender/freestyle/intern/system/PseudoNoise.cpp
@@ -33,9 +33,8 @@ static int modf_to_index(Freestyle::real x, unsigned int range)
BLI_assert(i >= 0 && i < range);
return i;
}
- else {
- return 0;
- }
+
+ return 0;
}
namespace Freestyle {
diff --git a/source/blender/freestyle/intern/system/PseudoNoise.h b/source/blender/freestyle/intern/system/PseudoNoise.h
index 53fe54754c8..38270016675 100644
--- a/source/blender/freestyle/intern/system/PseudoNoise.h
+++ b/source/blender/freestyle/intern/system/PseudoNoise.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_PSEUDO_NOISE_H__
-#define __FREESTYLE_PSEUDO_NOISE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -56,5 +55,3 @@ class PseudoNoise {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_PSEUDO_NOISE_H__
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h
index 8099ed63199..bae69aa0a42 100644
--- a/source/blender/freestyle/intern/system/PythonInterpreter.h
+++ b/source/blender/freestyle/intern/system/PythonInterpreter.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_PYTHON_INTERPRETER_H__
-#define __FREESTYLE_PYTHON_INTERPRETER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -147,5 +146,3 @@ class PythonInterpreter : public Interpreter {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_PYTHON_INTERPRETER_H__
diff --git a/source/blender/freestyle/intern/system/RandGen.h b/source/blender/freestyle/intern/system/RandGen.h
index 43f36b0a2fd..e514f4cfc9f 100644
--- a/source/blender/freestyle/intern/system/RandGen.h
+++ b/source/blender/freestyle/intern/system/RandGen.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_RAND_GEN_H__
-#define __FREESTYLE_RAND_GEN_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -46,5 +45,3 @@ class RandGen {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_RAND_GEN_H__
diff --git a/source/blender/freestyle/intern/system/RenderMonitor.h b/source/blender/freestyle/intern/system/RenderMonitor.h
index eef4683328b..5d543f32dfb 100644
--- a/source/blender/freestyle/intern/system/RenderMonitor.h
+++ b/source/blender/freestyle/intern/system/RenderMonitor.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_RENDER_MONITOR_H__
-#define __FREESTYLE_RENDER_MONITOR_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -71,5 +70,3 @@ class RenderMonitor {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_RENDER_MONITOR_H__
diff --git a/source/blender/freestyle/intern/system/StringUtils.h b/source/blender/freestyle/intern/system/StringUtils.h
index fd97ca5b032..dc63f20f294 100644
--- a/source/blender/freestyle/intern/system/StringUtils.h
+++ b/source/blender/freestyle/intern/system/StringUtils.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STRING_UTILS_H__
-#define __FREESTYLE_STRING_UTILS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -50,5 +49,3 @@ struct ltstr {
} // end of namespace StringUtils
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STRING_UTILS_H__
diff --git a/source/blender/freestyle/intern/system/TimeStamp.h b/source/blender/freestyle/intern/system/TimeStamp.h
index 2fbf83d226d..5560bf8be8d 100644
--- a/source/blender/freestyle/intern/system/TimeStamp.h
+++ b/source/blender/freestyle/intern/system/TimeStamp.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_TIME_STAMP_H__
-#define __FREESTYLE_TIME_STAMP_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -70,5 +69,3 @@ class TimeStamp {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_TIME_STAMP_H__
diff --git a/source/blender/freestyle/intern/system/TimeUtils.h b/source/blender/freestyle/intern/system/TimeUtils.h
index 6d4c56ab15e..3c8a28e9e43 100644
--- a/source/blender/freestyle/intern/system/TimeUtils.h
+++ b/source/blender/freestyle/intern/system/TimeUtils.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_TIME_UTILS_H__
-#define __FREESTYLE_TIME_UTILS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -60,5 +59,3 @@ class Chronometer {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_TIME_UTILS_H__
diff --git a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h
index 97aae3d653c..c2d843742df 100644
--- a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h
+++ b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_ARBITRARY_GRID_DENSITY_PROVIDER_H__
-#define __FREESTYLE_ARBITRARY_GRID_DENSITY_PROVIDER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -66,5 +65,3 @@ class ArbitraryGridDensityProviderFactory : public GridDensityProviderFactory {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_ARBITRARY_GRID_DENSITY_PROVIDER_H__
diff --git a/source/blender/freestyle/intern/view_map/AutoPtrHelper.h b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
index fb2a9d73d13..94fd80bc0fb 100644
--- a/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
+++ b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_AUTOPTR_HELPER_H__
-#define __FREESTYLE_AUTOPTR_HELPER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -47,5 +46,3 @@ template<typename T> class AutoPtr : public std::unique_ptr<T> {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_AUTOPTR_HELPER_H__
diff --git a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h
index f530cf35569..5336cc1ff97 100644
--- a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h
+++ b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_AVERAGE_AREA_GRID_DENSITY_PROVIDER_H__
-#define __FREESTYLE_AVERAGE_AREA_GRID_DENSITY_PROVIDER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -63,5 +62,3 @@ class AverageAreaGridDensityProviderFactory : public GridDensityProviderFactory
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_AVERAGE_AREA_GRID_DENSITY_PROVIDER_H__
diff --git a/source/blender/freestyle/intern/view_map/BoxGrid.h b/source/blender/freestyle/intern/view_map/BoxGrid.h
index 35b5e4d6b55..581ee0a2340 100644
--- a/source/blender/freestyle/intern/view_map/BoxGrid.h
+++ b/source/blender/freestyle/intern/view_map/BoxGrid.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_BOX_GRID_H__
-#define __FREESTYLE_BOX_GRID_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -422,5 +421,3 @@ inline bool BoxGrid::insertOccluder(OccluderSource &source, OccluderData *&occlu
}
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_BOX_GRID_H__
diff --git a/source/blender/freestyle/intern/view_map/CulledOccluderSource.h b/source/blender/freestyle/intern/view_map/CulledOccluderSource.h
index 3457fb6ca10..2bb77bad0f7 100644
--- a/source/blender/freestyle/intern/view_map/CulledOccluderSource.h
+++ b/source/blender/freestyle/intern/view_map/CulledOccluderSource.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_CULLED_OCCLUDER_SOURCE_H__
-#define __FREESTYLE_CULLED_OCCLUDER_SOURCE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -57,5 +56,3 @@ class CulledOccluderSource : public OccluderSource {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_CULLED_OCCLUDER_SOURCE_H__
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
index 2bcf2d3bee8..c4115ee00c4 100644
--- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
+++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_FEDGE_X_DETECTOR_H__
-#define __FREESTYLE_FEDGE_X_DETECTOR_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -246,5 +245,3 @@ class FEdgeXDetector {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_FEDGE_X_DETECTOR_H__
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.h b/source/blender/freestyle/intern/view_map/Functions0D.h
index 7149c1909fd..0364069b631 100644
--- a/source/blender/freestyle/intern/view_map/Functions0D.h
+++ b/source/blender/freestyle/intern/view_map/Functions0D.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_FUNCTIONS_0D_H__
-#define __FREESTYLE_FUNCTIONS_0D_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -509,5 +508,3 @@ ViewShape *getOccludeeF0D(Interface0DIterator &it);
} // end of namespace Functions0D
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_FUNCTIONS_0D_H__
diff --git a/source/blender/freestyle/intern/view_map/Functions1D.h b/source/blender/freestyle/intern/view_map/Functions1D.h
index 20aa9f2a27f..9cf5527ee19 100644
--- a/source/blender/freestyle/intern/view_map/Functions1D.h
+++ b/source/blender/freestyle/intern/view_map/Functions1D.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_FUNCTIONS_1D_H__
-#define __FREESTYLE_FUNCTIONS_1D_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -638,5 +637,3 @@ void getShapeF1D(Interface1D &inter, set<ViewShape *> &oShapes);
} // end of namespace Functions1D
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_FUNCTIONS_1D_H__
diff --git a/source/blender/freestyle/intern/view_map/GridDensityProvider.h b/source/blender/freestyle/intern/view_map/GridDensityProvider.h
index 290d5b0cfba..e663f14d368 100644
--- a/source/blender/freestyle/intern/view_map/GridDensityProvider.h
+++ b/source/blender/freestyle/intern/view_map/GridDensityProvider.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_GRID_DENSITY_PROVIDER_H__
-#define __FREESTYLE_GRID_DENSITY_PROVIDER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -167,5 +166,3 @@ class GridDensityProviderFactory {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_GRID_DENSITY_PROVIDER_H__
diff --git a/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.cpp b/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.cpp
index 55bc02b8358..26a40ee587c 100644
--- a/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.cpp
+++ b/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.cpp
@@ -43,9 +43,8 @@ AutoPtr<GridDensityProvider> HeuristicGridDensityProviderFactory::newGridDensity
if (avg->cellSize() > p23->cellSize()) {
return (AutoPtr<GridDensityProvider>)p23;
}
- else {
- return (AutoPtr<GridDensityProvider>)avg;
- }
+
+ return (AutoPtr<GridDensityProvider>)avg;
}
AutoPtr<GridDensityProvider> HeuristicGridDensityProviderFactory::newGridDensityProvider(
@@ -58,9 +57,8 @@ AutoPtr<GridDensityProvider> HeuristicGridDensityProviderFactory::newGridDensity
if (avg->cellSize() > p23->cellSize()) {
return (AutoPtr<GridDensityProvider>)p23;
}
- else {
- return (AutoPtr<GridDensityProvider>)avg;
- }
+
+ return (AutoPtr<GridDensityProvider>)avg;
}
AutoPtr<GridDensityProvider> HeuristicGridDensityProviderFactory::newGridDensityProvider(
@@ -75,9 +73,8 @@ AutoPtr<GridDensityProvider> HeuristicGridDensityProviderFactory::newGridDensity
if (avg->cellSize() > p23->cellSize()) {
return (AutoPtr<GridDensityProvider>)p23;
}
- else {
- return (AutoPtr<GridDensityProvider>)avg;
- }
+
+ return (AutoPtr<GridDensityProvider>)avg;
}
} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.h b/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.h
index b32a284cb61..0ce62572092 100644
--- a/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.h
+++ b/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_HEURISTIC_GRID_DENSITY_PROVIDER_FACTORY_H__
-#define __FREESTYLE_HEURISTIC_GRID_DENSITY_PROVIDER_FACTORY_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -48,5 +47,3 @@ class HeuristicGridDensityProviderFactory : public GridDensityProviderFactory {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_HEURISTIC_GRID_DENSITY_PROVIDER_FACTORY_H__
diff --git a/source/blender/freestyle/intern/view_map/Interface0D.h b/source/blender/freestyle/intern/view_map/Interface0D.h
index 724a98f047f..6b4682cc862 100644
--- a/source/blender/freestyle/intern/view_map/Interface0D.h
+++ b/source/blender/freestyle/intern/view_map/Interface0D.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_INTERFACE_0D_H__
-#define __FREESTYLE_INTERFACE_0D_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -341,5 +340,3 @@ class Interface0DIterator : public Iterator {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_INTERFACE_0D_H__
diff --git a/source/blender/freestyle/intern/view_map/Interface1D.h b/source/blender/freestyle/intern/view_map/Interface1D.h
index ab489bff4c9..778deb20a60 100644
--- a/source/blender/freestyle/intern/view_map/Interface1D.h
+++ b/source/blender/freestyle/intern/view_map/Interface1D.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_INTERFACE_1D_H__
-#define __FREESTYLE_INTERFACE_1D_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -203,5 +202,3 @@ class Interface1D {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_INTERFACE_1D_H__
diff --git a/source/blender/freestyle/intern/view_map/OccluderSource.cpp b/source/blender/freestyle/intern/view_map/OccluderSource.cpp
index 7132e0172ae..e75856edc35 100644
--- a/source/blender/freestyle/intern/view_map/OccluderSource.cpp
+++ b/source/blender/freestyle/intern/view_map/OccluderSource.cpp
@@ -77,11 +77,10 @@ bool OccluderSource::next()
valid = false;
return false;
}
- else {
- vector<WFace *> &wFaces = (*currentShape)->GetFaceList();
- currentFace = wFaces.begin();
- facesEnd = wFaces.end();
- }
+
+ vector<WFace *> &wFaces = (*currentShape)->GetFaceList();
+ currentFace = wFaces.begin();
+ facesEnd = wFaces.end();
}
buildCachedPolygon();
return true;
diff --git a/source/blender/freestyle/intern/view_map/OccluderSource.h b/source/blender/freestyle/intern/view_map/OccluderSource.h
index 07df3b95347..befde3c1b1b 100644
--- a/source/blender/freestyle/intern/view_map/OccluderSource.h
+++ b/source/blender/freestyle/intern/view_map/OccluderSource.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_OCCLUDER_SOURCE_H__
-#define __FREESTYLE_OCCLUDER_SOURCE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -70,5 +69,3 @@ class OccluderSource {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_OCCLUDER_SOURCE_H__
diff --git a/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.h b/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.h
index 52d57e3030e..fec869e0665 100644
--- a/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.h
+++ b/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_POW_23_GRID_DENSITY_PROVIDER_H__
-#define __FREESTYLE_POW_23_GRID_DENSITY_PROVIDER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -64,5 +63,3 @@ class Pow23GridDensityProviderFactory : public GridDensityProviderFactory {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_POW_23_GRID_DENSITY_PROVIDER_H__
diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h
index 8503836e0ca..6463cd7eb3e 100644
--- a/source/blender/freestyle/intern/view_map/Silhouette.h
+++ b/source/blender/freestyle/intern/view_map/Silhouette.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_SILHOUETTE_H__
-#define __FREESTYLE_SILHOUETTE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -1958,5 +1957,3 @@ class SShape {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_SILHOUETTE_H__
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
index 46d4389ea83..2624c70c988 100644
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
@@ -124,7 +124,7 @@ void SilhouetteGeomEngine::setFrustum(real iZNear, real iZFar)
void SilhouetteGeomEngine::retrieveViewport(int viewport[4])
{
- memcpy(viewport, _viewport, 4 * sizeof(int));
+ memcpy(viewport, _viewport, sizeof(int[4]));
}
void SilhouetteGeomEngine::ProjectSilhouette(vector<SVertex *> &ioVertices)
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
index 79d863e81e7..124ef35e5b9 100644
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_SILHOUETTE_GEOM_ENGINE_H__
-#define __FREESTYLE_SILHOUETTE_GEOM_ENGINE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -135,5 +134,3 @@ class SilhouetteGeomEngine {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_SILHOUETTE_GEOM_ENGINE_H__
diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.h b/source/blender/freestyle/intern/view_map/SphericalGrid.h
index e9074580fb9..0ef68d073ae 100644
--- a/source/blender/freestyle/intern/view_map/SphericalGrid.h
+++ b/source/blender/freestyle/intern/view_map/SphericalGrid.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_SPHERICAL_GRID_H__
-#define __FREESTYLE_SPHERICAL_GRID_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -434,5 +433,3 @@ inline bool SphericalGrid::insertOccluder(OccluderSource &source, OccluderData *
}
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_SPHERICAL_GRID_H__
diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.h b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
index 537f07f44f4..65633fd85d4 100644
--- a/source/blender/freestyle/intern/view_map/SteerableViewMap.h
+++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_STEERABLE_VIEW_MAP_H__
-#define __FREESTYLE_STEERABLE_VIEW_MAP_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -156,5 +155,3 @@ class SteerableViewMap {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_STEERABLE_VIEW_MAP_H__
diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
index d024c360e3f..aecd37fa0de 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
@@ -344,9 +344,8 @@ OWXFaceLayer ViewEdgeXBuilder::FindNextFaceLayer(const OWXFaceLayer &iFaceLayer)
if (woeend == winner->getSmoothEdge()->woea()->twin()) {
return OWXFaceLayer(winner, true);
}
- else {
- return OWXFaceLayer(winner, false);
- }
+
+ return OWXFaceLayer(winner, false);
}
}
++f;
@@ -368,19 +367,17 @@ OWXFaceLayer ViewEdgeXBuilder::FindNextFaceLayer(const OWXFaceLayer &iFaceLayer)
if ((sameNatureLayers.empty()) || (sameNatureLayers.size() != 1)) {
return OWXFaceLayer(NULL, true);
}
- else {
- WXFaceLayer *winner = sameNatureLayers[0];
- // check face mark continuity
- if (winner->getFace()->GetMark() != iFaceLayer.fl->getFace()->GetMark()) {
- return OWXFaceLayer(NULL, true);
- }
- if (woeend == winner->getSmoothEdge()->woea()->twin()) {
- return OWXFaceLayer(winner, true);
- }
- else {
- return OWXFaceLayer(winner, false);
- }
+
+ WXFaceLayer *winner = sameNatureLayers[0];
+ // check face mark continuity
+ if (winner->getFace()->GetMark() != iFaceLayer.fl->getFace()->GetMark()) {
+ return OWXFaceLayer(NULL, true);
+ }
+ if (woeend == winner->getSmoothEdge()->woea()->twin()) {
+ return OWXFaceLayer(winner, true);
}
+
+ return OWXFaceLayer(winner, false);
}
return OWXFaceLayer(NULL, true);
}
@@ -429,9 +426,8 @@ OWXFaceLayer ViewEdgeXBuilder::FindPreviousFaceLayer(const OWXFaceLayer &iFaceLa
if (woebegin == winner->getSmoothEdge()->woeb()->twin()) {
return OWXFaceLayer(winner, true);
}
- else {
- return OWXFaceLayer(winner, false);
- }
+
+ return OWXFaceLayer(winner, false);
}
}
}
@@ -452,19 +448,17 @@ OWXFaceLayer ViewEdgeXBuilder::FindPreviousFaceLayer(const OWXFaceLayer &iFaceLa
if ((sameNatureLayers.empty()) || (sameNatureLayers.size() != 1)) {
return OWXFaceLayer(NULL, true);
}
- else {
- WXFaceLayer *winner = sameNatureLayers[0];
- // check face mark continuity
- if (winner->getFace()->GetMark() != iFaceLayer.fl->getFace()->GetMark()) {
- return OWXFaceLayer(NULL, true);
- }
- if (woebegin == winner->getSmoothEdge()->woeb()->twin()) {
- return OWXFaceLayer(winner, true);
- }
- else {
- return OWXFaceLayer(winner, false);
- }
+
+ WXFaceLayer *winner = sameNatureLayers[0];
+ // check face mark continuity
+ if (winner->getFace()->GetMark() != iFaceLayer.fl->getFace()->GetMark()) {
+ return OWXFaceLayer(NULL, true);
+ }
+ if (woebegin == winner->getSmoothEdge()->woeb()->twin()) {
+ return OWXFaceLayer(winner, true);
}
+
+ return OWXFaceLayer(winner, false);
}
return OWXFaceLayer(NULL, true);
}
@@ -631,11 +625,10 @@ OWXEdge ViewEdgeXBuilder::FindNextWEdge(const OWXEdge &iEdge)
// So the vertex order is OK.
return OWXEdge(wxe, true);
}
- else {
- // That means that the face necessarily lies on the edge left.
- // So the vertex order is OK.
- return OWXEdge(wxe, false);
- }
+
+ // That means that the face necessarily lies on the edge left.
+ // So the vertex order is OK.
+ return OWXEdge(wxe, false);
}
// we did not find:
return OWXEdge(NULL, true);
@@ -679,9 +672,8 @@ OWXEdge ViewEdgeXBuilder::FindPreviousWEdge(const OWXEdge &iEdge)
if (wxe->GetbVertex() == v) {
return OWXEdge(wxe, true);
}
- else {
- return OWXEdge(wxe, false);
- }
+
+ return OWXEdge(wxe, false);
}
// we did not find:
return OWXEdge(NULL, true);
diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
index b1934d08376..f6f54a2d87d 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_VIEW_EDGE_X_BUILDER_H__
-#define __FREESTYLE_VIEW_EDGE_X_BUILDER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -292,5 +291,3 @@ class ViewEdgeXBuilder {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_VIEW_EDGE_X_BUILDER_H__
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.cpp b/source/blender/freestyle/intern/view_map/ViewMap.cpp
index 47c6c3a1f6a..fa2f95dac72 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMap.cpp
@@ -323,18 +323,16 @@ static bool ViewEdgeComp(ViewVertex::directedViewEdge &dve1, ViewVertex::directe
if (v2.y() < 0) {
return true;
}
- else {
- return (v1.x() > v2.x());
- }
+
+ return (v1.x() > v2.x());
}
- else {
- if (v2.y() > 0) {
- return false;
- }
- else {
- return (v1.x() < v2.x());
- }
+
+ if (v2.y() > 0) {
+ return false;
}
+
+ return (v1.x() < v2.x());
+
return false;
}
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h
index 83c45be8c61..e5e49f17ca5 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.h
+++ b/source/blender/freestyle/intern/view_map/ViewMap.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_VIEW_MAP_H__
-#define __FREESTYLE_VIEW_MAP_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -1830,5 +1829,3 @@ inline real ViewEdge::curvature2d_as_angle(int iCombination) const
#endif
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_VIEW_MAP_H__
diff --git a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
index 2ff46e353f3..5cb52b6a0f3 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_VIEW_MAP_ADVANCED_ITERATORS_H__
-#define __FREESTYLE_VIEW_MAP_ADVANCED_ITERATORS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -499,7 +498,7 @@ class edge_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_
// dereferencing
virtual reference operator*() const
{
- return (_ViewEdge);
+ return _ViewEdge;
}
virtual pointer operator->() const
@@ -627,7 +626,7 @@ class fedge_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag
// dereferencing
virtual reference operator*() const
{
- return (_FEdge);
+ return _FEdge;
}
virtual pointer operator->() const
@@ -775,7 +774,7 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
// dereferencing
virtual reference operator*() const
{
- return (_SVertex);
+ return _SVertex;
}
virtual pointer operator->() const
@@ -816,5 +815,3 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
} // end of namespace ViewEdgeInternal
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_VIEW_MAP_ADVANCED_ITERATORS_H__
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
index 8ac272e92b5..a0989c52e4e 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
@@ -504,10 +504,10 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
(*ve)->setaShape(0);
continue;
}
- else {
- ++qiMajority;
- qiMajority >>= 1;
- }
+
+ ++qiMajority;
+ qiMajority >>= 1;
+
#if LOGGING
if (_global.debug & G_DEBUG_FREESTYLE) {
cout << "\tqiMajority: " << qiMajority << endl;
@@ -702,10 +702,10 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
(*ve)->setaShape(0);
continue;
}
- else {
- ++qiMajority;
- qiMajority >>= 1;
- }
+
+ ++qiMajority;
+ qiMajority >>= 1;
+
#if LOGGING
if (_global.debug & G_DEBUG_FREESTYLE) {
cout << "\tqiMajority: " << qiMajority << endl;
@@ -873,10 +873,9 @@ static void computeFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
(*ve)->setaShape(0);
continue;
}
- else {
- ++qiMajority;
- qiMajority >>= 1;
- }
+
+ ++qiMajority;
+ qiMajority >>= 1;
even_test = true;
maxIndex = 0;
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.h b/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
index a5d967af331..6d919f5561a 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_VIEW_MAP_BUILDER_H__
-#define __FREESTYLE_VIEW_MAP_BUILDER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -284,5 +283,3 @@ class ViewMapBuilder {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_VIEW_MAP_BUILDER_H__
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
index 4c4e5ce7fe9..3cbf42ed388 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
@@ -998,6 +998,7 @@ int load(istream &in, ViewMap *vm, ProgressBar *pb)
if (fe_s) {
bool b;
READ(b);
+ /* NOLINTNEXTLINE: bugprone-infinite-loop */
for (READ(fe_rle1), fe_rle2 = 0; fe_rle1 <= fe_s; fe_rle2 = fe_rle1, READ(fe_rle1)) {
if (b) {
for (unsigned int i = fe_rle2; i < fe_rle1; i++) {
@@ -1023,6 +1024,7 @@ int load(istream &in, ViewMap *vm, ProgressBar *pb)
if (vv_s) {
Nature::VertexNature nature;
READ(nature);
+ /* NOLINTNEXTLINE: bugprone-infinite-loop */
for (READ(vv_rle1), vv_rle2 = 0; vv_rle1 <= vv_s; vv_rle2 = vv_rle1, READ(vv_rle1)) {
if (nature & Nature::T_VERTEX) {
for (unsigned int i = vv_rle2; i < vv_rle1; i++) {
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIO.h b/source/blender/freestyle/intern/view_map/ViewMapIO.h
index 98d27852c8d..e4c42c094d0 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIO.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapIO.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_VIEW_MAP_IO_H__
-#define __FREESTYLE_VIEW_MAP_IO_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -102,5 +101,3 @@ template<> istream &read<0>(istream &in, char *)
} // End of namespace ViewMapIO
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_VIEW_MAP_IO_H__
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIterators.h b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
index 174e25896cc..9956d47469d 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_VIEW_MAP_ITERATORS_H__
-#define __FREESTYLE_VIEW_MAP_ITERATORS_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -590,5 +589,3 @@ class ViewEdgeIterator : public Iterator {
} // end of namespace ViewEdgeInternal
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_VIEW_MAP_ITERATORS_H__
diff --git a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
index b6bf51618d8..c6690b1d9dc 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_VIEW_MAP_TESSELATOR_H__
-#define __FREESTYLE_VIEW_MAP_TESSELATOR_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -225,5 +224,3 @@ NodeGroup *ViewMapTesselator::Tesselate(ViewEdgesIterator begin, ViewEdgesIterat
}
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_VIEW_MAP_TESSELATOR_H__
diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.h b/source/blender/freestyle/intern/winged_edge/Curvature.h
index 32e9ea8b5cf..9ecc92df2ac 100644
--- a/source/blender/freestyle/intern/winged_edge/Curvature.h
+++ b/source/blender/freestyle/intern/winged_edge/Curvature.h
@@ -27,8 +27,7 @@
* FRANCE
*/
-#ifndef __FREESTYLE_CURVATURE_H__
-#define __FREESTYLE_CURVATURE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -142,5 +141,3 @@ void compute_curvature_tensor_one_ring(WVertex *start, NormalCycle &nc);
} // namespace OGF
} /* namespace Freestyle */
-
-#endif /* __FREESTYLE_CURVATURE_H__ */
diff --git a/source/blender/freestyle/intern/winged_edge/Nature.h b/source/blender/freestyle/intern/winged_edge/Nature.h
index 91f9f63b412..68323d7122c 100644
--- a/source/blender/freestyle/intern/winged_edge/Nature.h
+++ b/source/blender/freestyle/intern/winged_edge/Nature.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_NATURE_H__
-#define __FREESTYLE_NATURE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -67,5 +66,3 @@ static const EdgeNature EDGE_MARK = (1 << 7); // 128
} // end of namespace Nature
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_NATURE_H__
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.cpp b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
index d624728250a..c8805c144e3 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
@@ -114,7 +114,7 @@ bool WVertex::isBoundary()
if (_Border == 1) {
return true;
}
- else if (_Border == 0) {
+ if (_Border == 0) {
return false;
}
@@ -412,9 +412,8 @@ bool WFace::getOppositeEdge(const WVertex *v, WOEdge *&e)
if (!e) {
return false;
}
- else {
- return true;
- }
+
+ return true;
}
float WFace::getArea()
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h
index 424cd76a6b7..42a8e62990f 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_W_EDGE_H__
-#define __FREESTYLE_W_EDGE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -1428,5 +1427,3 @@ inline void WOEdge::setVecAndAngle()
}
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_W_EDGE_H__
diff --git a/source/blender/freestyle/intern/winged_edge/WFillGrid.h b/source/blender/freestyle/intern/winged_edge/WFillGrid.h
index 918c1f154f3..095a58675c0 100644
--- a/source/blender/freestyle/intern/winged_edge/WFillGrid.h
+++ b/source/blender/freestyle/intern/winged_edge/WFillGrid.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_W_FILL_GRID_H__
-#define __FREESTYLE_W_FILL_GRID_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -85,5 +84,3 @@ class WFillGrid {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_W_FILL_GRID_H__
diff --git a/source/blender/freestyle/intern/winged_edge/WSFillGrid.h b/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
index e3deebcd6c2..5393f57d2cd 100644
--- a/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
+++ b/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_WS_FILL_GRID_H__
-#define __FREESTYLE_WS_FILL_GRID_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -81,5 +80,3 @@ class WSFillGrid {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_WS_FILL_GRID_H__
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.h b/source/blender/freestyle/intern/winged_edge/WXEdge.h
index 21418c44614..8fe99f9bb93 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_WX_EDGE_H__
-#define __FREESTYLE_WX_EDGE_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -845,5 +844,3 @@ bool WXVertex::isFeature()
}
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_WX_EDGE_H__
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
index d223cee5e0e..efba18eb084 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
+++ b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_WX_EDGE_BUILDER_H__
-#define __FREESTYLE_WX_EDGE_BUILDER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -48,5 +47,3 @@ class WXEdgeBuilder : public WingedEdgeBuilder {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_WX_EDGE_BUILDER_H__
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
index 5c728dea1d8..8cf86a421b7 100644
--- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
+++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FREESTYLE_WINGED_EDGE_BUILDER_H__
-#define __FREESTYLE_WINGED_EDGE_BUILDER_H__
+#pragma once
/** \file
* \ingroup freestyle
@@ -174,5 +173,3 @@ class WingedEdgeBuilder : public SceneVisitor {
};
} /* namespace Freestyle */
-
-#endif // __FREESTYLE_WINGED_EDGE_BUILDER_H__
diff --git a/source/blender/functions/FN_array_spans.hh b/source/blender/functions/FN_array_spans.hh
index 5f976711e06..976b9a44d3e 100644
--- a/source/blender/functions/FN_array_spans.hh
+++ b/source/blender/functions/FN_array_spans.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_ARRAY_SPANS_HH__
-#define __FN_ARRAY_SPANS_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -205,5 +204,3 @@ class GVArraySpan : public VArraySpanBase<void> {
};
} // namespace blender::fn
-
-#endif /* __FN_ARRAY_SPANS_HH__ */
diff --git a/source/blender/functions/FN_attributes_ref.hh b/source/blender/functions/FN_attributes_ref.hh
index c694f11b7a7..a9236f73549 100644
--- a/source/blender/functions/FN_attributes_ref.hh
+++ b/source/blender/functions/FN_attributes_ref.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_ATTRIBUTES_REF_HH__
-#define __FN_ATTRIBUTES_REF_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -52,7 +51,7 @@ class AttributesInfoBuilder : NonCopyable, NonMovable {
template<typename T> bool add(StringRef name, const T &default_value)
{
- return this->add(name, CPPType::get<T>(), (const void *)&default_value);
+ return this->add(name, CPPType::get<T>(), static_cast<const void *>(&default_value));
}
bool add(StringRef name, const CPPType &type, const void *default_value = nullptr);
@@ -108,7 +107,7 @@ class AttributesInfo : NonCopyable, NonMovable {
template<typename T> const T &default_of(int index) const
{
BLI_assert(type_by_index_[index]->is<T>());
- return *(T *)defaults_[index];
+ return *static_cast<T *>(defaults_[index]);
}
template<typename T> const T &default_of(StringRef name) const
@@ -204,7 +203,7 @@ class MutableAttributesRef {
template<typename T> MutableSpan<T> get(int index) const
{
BLI_assert(info_->type_of(index).is<T>());
- return MutableSpan<T>((T *)buffers_[index] + range_.start(), range_.size());
+ return MutableSpan<T>(static_cast<T *>(buffers_[index]) + range_.start(), range_.size());
}
template<typename T> MutableSpan<T> get(StringRef name) const
@@ -295,7 +294,7 @@ class AttributesRef {
template<typename T> Span<T> get(int index) const
{
BLI_assert(info_->type_of(index).is<T>());
- return Span<T>((T *)buffers_[index] + range_.start(), range_.size());
+ return Span<T>(static_cast<T *>(buffers_[index]) + range_.start(), range_.size());
}
template<typename T> Span<T> get(StringRef name) const
@@ -340,5 +339,3 @@ class AttributesRef {
};
} // namespace blender::fn
-
-#endif /* __FN_ATTRIBUTES_REF_HH__ */
diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh
index 531a9073784..5f3981826c5 100644
--- a/source/blender/functions/FN_cpp_type.hh
+++ b/source/blender/functions/FN_cpp_type.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_CPP_TYPE_HH__
-#define __FN_CPP_TYPE_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -585,35 +584,35 @@ template<typename T> void construct_default_cb(void *ptr)
}
template<typename T> void construct_default_n_cb(void *ptr, int64_t n)
{
- blender::default_construct_n((T *)ptr, n);
+ blender::default_construct_n(static_cast<T *>(ptr), n);
}
template<typename T> void construct_default_indices_cb(void *ptr, IndexMask mask)
{
- mask.foreach_index([&](int64_t i) { new ((T *)ptr + i) T; });
+ mask.foreach_index([&](int64_t i) { new (static_cast<T *>(ptr) + i) T; });
}
template<typename T> void destruct_cb(void *ptr)
{
- ((T *)ptr)->~T();
+ (static_cast<T *>(ptr))->~T();
}
template<typename T> void destruct_n_cb(void *ptr, int64_t n)
{
- blender::destruct_n((T *)ptr, n);
+ blender::destruct_n(static_cast<T *>(ptr), n);
}
template<typename T> void destruct_indices_cb(void *ptr, IndexMask mask)
{
- T *ptr_ = (T *)ptr;
+ T *ptr_ = static_cast<T *>(ptr);
mask.foreach_index([&](int64_t i) { ptr_[i].~T(); });
}
template<typename T> void copy_to_initialized_cb(const void *src, void *dst)
{
- *(T *)dst = *(T *)src;
+ *static_cast<T *>(dst) = *static_cast<const T *>(src);
}
template<typename T> void copy_to_initialized_n_cb(const void *src, void *dst, int64_t n)
{
- const T *src_ = (const T *)src;
- T *dst_ = (T *)dst;
+ const T *src_ = static_cast<const T *>(src);
+ T *dst_ = static_cast<T *>(dst);
for (int64_t i = 0; i < n; i++) {
dst_[i] = src_[i];
@@ -622,45 +621,45 @@ template<typename T> void copy_to_initialized_n_cb(const void *src, void *dst, i
template<typename T>
void copy_to_initialized_indices_cb(const void *src, void *dst, IndexMask mask)
{
- const T *src_ = (const T *)src;
- T *dst_ = (T *)dst;
+ const T *src_ = static_cast<const T *>(src);
+ T *dst_ = static_cast<T *>(dst);
mask.foreach_index([&](int64_t i) { dst_[i] = src_[i]; });
}
template<typename T> void copy_to_uninitialized_cb(const void *src, void *dst)
{
- blender::uninitialized_copy_n((T *)src, 1, (T *)dst);
+ blender::uninitialized_copy_n(static_cast<const T *>(src), 1, static_cast<T *>(dst));
}
template<typename T> void copy_to_uninitialized_n_cb(const void *src, void *dst, int64_t n)
{
- blender::uninitialized_copy_n((T *)src, n, (T *)dst);
+ blender::uninitialized_copy_n(static_cast<const T *>(src), n, static_cast<T *>(dst));
}
template<typename T>
void copy_to_uninitialized_indices_cb(const void *src, void *dst, IndexMask mask)
{
- const T *src_ = (const T *)src;
- T *dst_ = (T *)dst;
+ const T *src_ = static_cast<const T *>(src);
+ T *dst_ = static_cast<T *>(dst);
mask.foreach_index([&](int64_t i) { new (dst_ + i) T(src_[i]); });
}
template<typename T> void relocate_to_initialized_cb(void *src, void *dst)
{
- T *src_ = (T *)src;
- T *dst_ = (T *)dst;
+ T *src_ = static_cast<T *>(src);
+ T *dst_ = static_cast<T *>(dst);
*dst_ = std::move(*src_);
src_->~T();
}
template<typename T> void relocate_to_initialized_n_cb(void *src, void *dst, int64_t n)
{
- blender::initialized_relocate_n((T *)src, n, (T *)dst);
+ blender::initialized_relocate_n(static_cast<T *>(src), n, static_cast<T *>(dst));
}
template<typename T> void relocate_to_initialized_indices_cb(void *src, void *dst, IndexMask mask)
{
- T *src_ = (T *)src;
- T *dst_ = (T *)dst;
+ T *src_ = static_cast<T *>(src);
+ T *dst_ = static_cast<T *>(dst);
mask.foreach_index([&](int64_t i) {
dst_[i] = std::move(src_[i]);
@@ -670,21 +669,21 @@ template<typename T> void relocate_to_initialized_indices_cb(void *src, void *ds
template<typename T> void relocate_to_uninitialized_cb(void *src, void *dst)
{
- T *src_ = (T *)src;
- T *dst_ = (T *)dst;
+ T *src_ = static_cast<T *>(src);
+ T *dst_ = static_cast<T *>(dst);
new (dst_) T(std::move(*src_));
src_->~T();
}
template<typename T> void relocate_to_uninitialized_n_cb(void *src, void *dst, int64_t n)
{
- blender::uninitialized_relocate_n((T *)src, n, (T *)dst);
+ blender::uninitialized_relocate_n(static_cast<T *>(src), n, static_cast<T *>(dst));
}
template<typename T>
void relocate_to_uninitialized_indices_cb(void *src, void *dst, IndexMask mask)
{
- T *src_ = (T *)src;
- T *dst_ = (T *)dst;
+ T *src_ = static_cast<T *>(src);
+ T *dst_ = static_cast<T *>(dst);
mask.foreach_index([&](int64_t i) {
new (dst_ + i) T(std::move(src_[i]));
@@ -694,8 +693,8 @@ void relocate_to_uninitialized_indices_cb(void *src, void *dst, IndexMask mask)
template<typename T> void fill_initialized_cb(const void *value, void *dst, int64_t n)
{
- const T &value_ = *(const T *)value;
- T *dst_ = (T *)dst;
+ const T &value_ = *static_cast<const T *>(value);
+ T *dst_ = static_cast<T *>(dst);
for (int64_t i = 0; i < n; i++) {
dst_[i] = value_;
@@ -703,16 +702,16 @@ template<typename T> void fill_initialized_cb(const void *value, void *dst, int6
}
template<typename T> void fill_initialized_indices_cb(const void *value, void *dst, IndexMask mask)
{
- const T &value_ = *(const T *)value;
- T *dst_ = (T *)dst;
+ const T &value_ = *static_cast<const T *>(value);
+ T *dst_ = static_cast<T *>(dst);
mask.foreach_index([&](int64_t i) { dst_[i] = value_; });
}
template<typename T> void fill_uninitialized_cb(const void *value, void *dst, int64_t n)
{
- const T &value_ = *(const T *)value;
- T *dst_ = (T *)dst;
+ const T &value_ = *static_cast<const T *>(value);
+ T *dst_ = static_cast<T *>(dst);
for (int64_t i = 0; i < n; i++) {
new (dst_ + i) T(value_);
@@ -721,28 +720,28 @@ template<typename T> void fill_uninitialized_cb(const void *value, void *dst, in
template<typename T>
void fill_uninitialized_indices_cb(const void *value, void *dst, IndexMask mask)
{
- const T &value_ = *(const T *)value;
- T *dst_ = (T *)dst;
+ const T &value_ = *static_cast<const T *>(value);
+ T *dst_ = static_cast<T *>(dst);
mask.foreach_index([&](int64_t i) { new (dst_ + i) T(value_); });
}
template<typename T> void debug_print_cb(const void *value, std::stringstream &ss)
{
- const T &value_ = *(const T *)value;
+ const T &value_ = *static_cast<const T *>(value);
ss << value_;
}
template<typename T> bool is_equal_cb(const void *a, const void *b)
{
- const T &a_ = *(T *)a;
- const T &b_ = *(T *)b;
+ const T &a_ = *static_cast<const T *>(a);
+ const T &b_ = *static_cast<const T *>(b);
return a_ == b_;
}
template<typename T> uint64_t hash_cb(const void *value)
{
- const T &value_ = *(const T *)value;
+ const T &value_ = *static_cast<const T *>(value);
return DefaultHash<T>{}(value_);
}
@@ -781,7 +780,7 @@ inline std::unique_ptr<const CPPType> create_cpp_type(StringRef name, const T &d
debug_print_cb<T>,
is_equal_cb<T>,
hash_cb<T>,
- (const void *)&default_value);
+ static_cast<const void *>(&default_value));
return std::unique_ptr<const CPPType>(type);
}
@@ -795,5 +794,3 @@ inline std::unique_ptr<const CPPType> create_cpp_type(StringRef name, const T &d
STRINGIFY(IDENTIFIER), default_value); \
return *cpp_type; \
}
-
-#endif /* __FN_CPP_TYPE_HH__ */
diff --git a/source/blender/functions/FN_generic_vector_array.hh b/source/blender/functions/FN_generic_vector_array.hh
index ee67db000e5..dc5ad3c36ab 100644
--- a/source/blender/functions/FN_generic_vector_array.hh
+++ b/source/blender/functions/FN_generic_vector_array.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_GENERIC_VECTOR_ARRAY_HH__
-#define __FN_GENERIC_VECTOR_ARRAY_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -187,7 +186,8 @@ template<typename T> class GVectorArrayRef {
MutableSpan<T> operator[](int64_t index)
{
BLI_assert(index < vector_array_->starts_.size());
- return MutableSpan<T>((T *)vector_array_->starts_[index], vector_array_->lengths_[index]);
+ return MutableSpan<T>(static_cast<T *>(vector_array_->starts_[index]),
+ vector_array_->lengths_[index]);
}
int64_t size() const
@@ -202,5 +202,3 @@ template<typename T> class GVectorArrayRef {
};
} // namespace blender::fn
-
-#endif /* __FN_GENERIC_VECTOR_ARRAY_HH__ */
diff --git a/source/blender/functions/FN_multi_function.hh b/source/blender/functions/FN_multi_function.hh
index eaddcee7964..bf431984946 100644
--- a/source/blender/functions/FN_multi_function.hh
+++ b/source/blender/functions/FN_multi_function.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_MULTI_FUNCTION_HH__
-#define __FN_MULTI_FUNCTION_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -124,5 +123,3 @@ inline MFParamsBuilder::MFParamsBuilder(const class MultiFunction &fn, int64_t m
extern const MultiFunction &dummy_multi_function;
} // namespace blender::fn
-
-#endif /* __FN_MULTI_FUNCTION_HH__ */
diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh
index 95e216558e7..6d5ca7f64ad 100644
--- a/source/blender/functions/FN_multi_function_builder.hh
+++ b/source/blender/functions/FN_multi_function_builder.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_MULTI_FUNCTION_BUILDER_HH__
-#define __FN_MULTI_FUNCTION_BUILDER_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -59,7 +58,8 @@ template<typename In1, typename Out1> class CustomMF_SI_SO : public MultiFunctio
template<typename ElementFuncT> static FunctionT create_function(ElementFuncT element_fn)
{
return [=](IndexMask mask, VSpan<In1> in1, MutableSpan<Out1> out1) {
- mask.foreach_index([&](int i) { new ((void *)&out1[i]) Out1(element_fn(in1[i])); });
+ mask.foreach_index(
+ [&](int i) { new (static_cast<void *>(&out1[i])) Out1(element_fn(in1[i])); });
};
}
@@ -101,7 +101,8 @@ class CustomMF_SI_SI_SO : public MultiFunction {
template<typename ElementFuncT> static FunctionT create_function(ElementFuncT element_fn)
{
return [=](IndexMask mask, VSpan<In1> in1, VSpan<In2> in2, MutableSpan<Out1> out1) {
- mask.foreach_index([&](int i) { new ((void *)&out1[i]) Out1(element_fn(in1[i], in2[i])); });
+ mask.foreach_index(
+ [&](int i) { new (static_cast<void *>(&out1[i])) Out1(element_fn(in1[i], in2[i])); });
};
}
@@ -151,8 +152,9 @@ class CustomMF_SI_SI_SI_SO : public MultiFunction {
VSpan<In2> in2,
VSpan<In3> in3,
MutableSpan<Out1> out1) {
- mask.foreach_index(
- [&](int i) { new ((void *)&out1[i]) Out1(element_fn(in1[i], in2[i], in3[i])); });
+ mask.foreach_index([&](int i) {
+ new (static_cast<void *>(&out1[i])) Out1(element_fn(in1[i], in2[i], in3[i]));
+ });
};
}
@@ -221,7 +223,7 @@ template<typename From, typename To> class CustomMF_Convert : public MultiFuncti
MutableSpan<To> outputs = params.uninitialized_single_output<To>(1);
for (int64_t i : mask) {
- new ((void *)&outputs[i]) To(inputs[i]);
+ new (static_cast<void *>(&outputs[i])) To(inputs[i]);
}
}
};
@@ -295,7 +297,7 @@ template<typename T> class CustomMF_Constant : public MultiFunction {
if (other2 != nullptr) {
const CPPType &type = CPPType::get<T>();
if (type == other2->type_) {
- return type.is_equal((const void *)&value_, other2->value_);
+ return type.is_equal(static_cast<const void *>(&value_), other2->value_);
}
}
return false;
@@ -314,5 +316,3 @@ class CustomMF_DefaultOutput : public MultiFunction {
};
} // namespace blender::fn
-
-#endif /* __FN_MULTI_FUNCTION_BUILDER_HH__ */
diff --git a/source/blender/functions/FN_multi_function_context.hh b/source/blender/functions/FN_multi_function_context.hh
index 8492fd86742..1d3ed726c4a 100644
--- a/source/blender/functions/FN_multi_function_context.hh
+++ b/source/blender/functions/FN_multi_function_context.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_MULTI_FUNCTION_CONTEXT_HH__
-#define __FN_MULTI_FUNCTION_CONTEXT_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -44,7 +43,7 @@ class MFContextBuilder {
public:
template<typename T> void add_global_context(std::string name, const T *context)
{
- global_contexts_.add_new(std::move(name), (const void *)context);
+ global_contexts_.add_new(std::move(name), static_cast<const void *>(context));
}
};
@@ -61,10 +60,8 @@ class MFContext {
{
const void *context = builder_.global_contexts_.lookup_default_as(name, nullptr);
/* TODO: Implement type checking. */
- return (const T *)context;
+ return static_cast<const T *>(context);
}
};
} // namespace blender::fn
-
-#endif /* __FN_MULTI_FUNCTION_CONTEXT_HH__ */
diff --git a/source/blender/functions/FN_multi_function_data_type.hh b/source/blender/functions/FN_multi_function_data_type.hh
index 23a1c0e5680..713f73c2b5a 100644
--- a/source/blender/functions/FN_multi_function_data_type.hh
+++ b/source/blender/functions/FN_multi_function_data_type.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_MULTI_FUNCTION_DATA_TYPE_HH__
-#define __FN_MULTI_FUNCTION_DATA_TYPE_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -111,7 +110,7 @@ class MFDataType {
uint64_t hash() const
{
- return DefaultHash<CPPType>{}(*type_) + (uint64_t)category_;
+ return DefaultHash<CPPType>{}(*type_) + static_cast<uint64_t>(category_);
}
};
@@ -126,5 +125,3 @@ inline bool operator!=(const MFDataType &a, const MFDataType &b)
}
} // namespace blender::fn
-
-#endif /* __FN_MULTI_FUNCTION_DATA_TYPE_HH__ */
diff --git a/source/blender/functions/FN_multi_function_network.hh b/source/blender/functions/FN_multi_function_network.hh
index 20f8fb2ee43..b303589106a 100644
--- a/source/blender/functions/FN_multi_function_network.hh
+++ b/source/blender/functions/FN_multi_function_network.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_MULTI_FUNCTION_NETWORK_HH__
-#define __FN_MULTI_FUNCTION_NETWORK_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -119,7 +118,7 @@ class MFFunctionNode : public MFNode {
};
class MFDummyNode : public MFNode {
- private:
+ protected:
StringRefNull name_;
MutableSpan<StringRefNull> input_names_;
MutableSpan<StringRefNull> output_names_;
@@ -280,25 +279,25 @@ inline bool MFNode::is_function() const
inline MFDummyNode &MFNode::as_dummy()
{
BLI_assert(is_dummy_);
- return *(MFDummyNode *)this;
+ return static_cast<MFDummyNode &>(*this);
}
inline const MFDummyNode &MFNode::as_dummy() const
{
BLI_assert(is_dummy_);
- return *(const MFDummyNode *)this;
+ return static_cast<const MFDummyNode &>(*this);
}
inline MFFunctionNode &MFNode::as_function()
{
BLI_assert(!is_dummy_);
- return *(MFFunctionNode *)this;
+ return static_cast<MFFunctionNode &>(*this);
}
inline const MFFunctionNode &MFNode::as_function() const
{
BLI_assert(!is_dummy_);
- return *(const MFFunctionNode *)this;
+ return static_cast<const MFFunctionNode &>(*this);
}
inline MFInputSocket &MFNode::input(int index)
@@ -441,25 +440,25 @@ inline bool MFSocket::is_output() const
inline MFInputSocket &MFSocket::as_input()
{
BLI_assert(this->is_input());
- return *(MFInputSocket *)this;
+ return static_cast<MFInputSocket &>(*this);
}
inline const MFInputSocket &MFSocket::as_input() const
{
BLI_assert(this->is_input());
- return *(const MFInputSocket *)this;
+ return static_cast<const MFInputSocket &>(*this);
}
inline MFOutputSocket &MFSocket::as_output()
{
BLI_assert(this->is_output());
- return *(MFOutputSocket *)this;
+ return static_cast<MFOutputSocket &>(*this);
}
inline const MFOutputSocket &MFSocket::as_output() const
{
BLI_assert(this->is_output());
- return *(const MFOutputSocket *)this;
+ return static_cast<const MFOutputSocket &>(*this);
}
/* --------------------------------------------------------------------
@@ -535,5 +534,3 @@ inline int MFNetwork::node_id_amount() const
}
} // namespace blender::fn
-
-#endif /* __FN_MULTI_FUNCTION_NETWORK_HH__ */
diff --git a/source/blender/functions/FN_multi_function_network_evaluation.hh b/source/blender/functions/FN_multi_function_network_evaluation.hh
index 11606869ca2..2c0d94615b0 100644
--- a/source/blender/functions/FN_multi_function_network_evaluation.hh
+++ b/source/blender/functions/FN_multi_function_network_evaluation.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_MULTI_FUNCTION_NETWORK_EVALUATION_HH__
-#define __FN_MULTI_FUNCTION_NETWORK_EVALUATION_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -60,5 +59,3 @@ class MFNetworkEvaluator : public MultiFunction {
};
} // namespace blender::fn
-
-#endif /* __FN_MULTI_FUNCTION_NETWORK_EVALUATION_HH__ */
diff --git a/source/blender/functions/FN_multi_function_network_optimization.hh b/source/blender/functions/FN_multi_function_network_optimization.hh
index 3cbabd72c2a..6d0165643ce 100644
--- a/source/blender/functions/FN_multi_function_network_optimization.hh
+++ b/source/blender/functions/FN_multi_function_network_optimization.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_MULTI_FUNCTION_NETWORK_OPTIMIZATION_HH__
-#define __FN_MULTI_FUNCTION_NETWORK_OPTIMIZATION_HH__
+#pragma once
#include "FN_multi_function_network.hh"
@@ -28,5 +27,3 @@ void constant_folding(MFNetwork &network, ResourceCollector &resources);
void common_subnetwork_elimination(MFNetwork &network);
} // namespace blender::fn::mf_network_optimization
-
-#endif /* __FN_MULTI_FUNCTION_NETWORK_OPTIMIZATION_HH__ */
diff --git a/source/blender/functions/FN_multi_function_param_type.hh b/source/blender/functions/FN_multi_function_param_type.hh
index 7c16b8cdf10..5b35cbe365b 100644
--- a/source/blender/functions/FN_multi_function_param_type.hh
+++ b/source/blender/functions/FN_multi_function_param_type.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_MULTI_FUNCTION_PARAM_TYPE_HH__
-#define __FN_MULTI_FUNCTION_PARAM_TYPE_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -164,5 +163,3 @@ inline bool operator!=(const MFParamType &a, const MFParamType &b)
}
} // namespace blender::fn
-
-#endif /* __FN_MULTI_FUNCTION_PARAM_TYPE_HH__ */
diff --git a/source/blender/functions/FN_multi_function_params.hh b/source/blender/functions/FN_multi_function_params.hh
index ac4dca33cf0..ba2d1d0edd3 100644
--- a/source/blender/functions/FN_multi_function_params.hh
+++ b/source/blender/functions/FN_multi_function_params.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_MULTI_FUNCTION_PARAMS_HH__
-#define __FN_MULTI_FUNCTION_PARAMS_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -247,5 +246,3 @@ class MFParams {
};
} // namespace blender::fn
-
-#endif /* __FN_MULTI_FUNCTION_PARAMS_HH__ */
diff --git a/source/blender/functions/FN_multi_function_signature.hh b/source/blender/functions/FN_multi_function_signature.hh
index 3c09d1c961c..ef51ddbaf24 100644
--- a/source/blender/functions/FN_multi_function_signature.hh
+++ b/source/blender/functions/FN_multi_function_signature.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_MULTI_FUNCTION_SIGNATURE_HH__
-#define __FN_MULTI_FUNCTION_SIGNATURE_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -169,5 +168,3 @@ class MFSignatureBuilder {
};
} // namespace blender::fn
-
-#endif /* __FN_MULTI_FUNCTION_SIGNATURE_HH__ */
diff --git a/source/blender/functions/FN_spans.hh b/source/blender/functions/FN_spans.hh
index 62fa7c8ed4b..2c1257f9ad2 100644
--- a/source/blender/functions/FN_spans.hh
+++ b/source/blender/functions/FN_spans.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_SPANS_HH__
-#define __FN_SPANS_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -68,7 +67,8 @@ class GSpan {
}
template<typename T>
- GSpan(Span<T> array) : GSpan(CPPType::get<T>(), (const void *)array.data(), array.size())
+ GSpan(Span<T> array)
+ : GSpan(CPPType::get<T>(), static_cast<const void *>(array.data()), array.size())
{
}
@@ -101,7 +101,7 @@ class GSpan {
template<typename T> Span<T> typed() const
{
BLI_assert(type_->is<T>());
- return Span<T>((const T *)data_, size_);
+ return Span<T>(static_cast<const T *>(data_), size_);
}
};
@@ -130,7 +130,7 @@ class GMutableSpan {
template<typename T>
GMutableSpan(MutableSpan<T> array)
- : GMutableSpan(CPPType::get<T>(), (void *)array.begin(), array.size())
+ : GMutableSpan(CPPType::get<T>(), static_cast<void *>(array.begin()), array.size())
{
}
@@ -168,7 +168,7 @@ class GMutableSpan {
template<typename T> MutableSpan<T> typed()
{
BLI_assert(type_->is<T>());
- return MutableSpan<T>((T *)data_, size_);
+ return MutableSpan<T>(static_cast<T *>(data_), size_);
}
};
@@ -452,5 +452,3 @@ class GVSpan : public VSpanBase<void> {
};
} // namespace blender::fn
-
-#endif /* __FN_SPANS_HH__ */
diff --git a/source/blender/functions/intern/attributes_ref.cc b/source/blender/functions/intern/attributes_ref.cc
index 4686e217911..9f1e7fa65e5 100644
--- a/source/blender/functions/intern/attributes_ref.cc
+++ b/source/blender/functions/intern/attributes_ref.cc
@@ -27,6 +27,10 @@ AttributesInfoBuilder::~AttributesInfoBuilder()
bool AttributesInfoBuilder::add(StringRef name, const CPPType &type, const void *default_value)
{
+ if (name.size() == 0) {
+ std::cout << "Warning: Tried to add an attribute with empty name.\n";
+ return false;
+ }
if (names_.add_as(name)) {
types_.append(&type);
@@ -38,14 +42,13 @@ bool AttributesInfoBuilder::add(StringRef name, const CPPType &type, const void
defaults_.append(dst);
return true;
}
- else {
- const CPPType &stored_type = *types_[names_.index_of_as(name)];
- if (stored_type != type) {
- std::cout << "Warning: Tried to add an attribute twice with different types (" << name
- << ": " << stored_type.name() << ", " << type.name() << ").\n";
- }
- return false;
+
+ const CPPType &stored_type = *types_[names_.index_of_as(name)];
+ if (stored_type != type) {
+ std::cout << "Warning: Tried to add an attribute twice with different types (" << name << ": "
+ << stored_type.name() << ", " << type.name() << ").\n";
}
+ return false;
}
AttributesInfo::AttributesInfo(const AttributesInfoBuilder &builder)
diff --git a/source/blender/functions/intern/multi_function_network.cc b/source/blender/functions/intern/multi_function_network.cc
index cd3c38dd09f..77c8ba6373f 100644
--- a/source/blender/functions/intern/multi_function_network.cc
+++ b/source/blender/functions/intern/multi_function_network.cc
@@ -285,8 +285,8 @@ std::string MFNetwork::to_dot(Span<const MFNode *> marked_nodes) const
Map<const MFNode *, dot::NodeWithSocketsRef> dot_nodes;
Vector<const MFNode *> all_nodes;
- all_nodes.extend(function_nodes_.as_span());
- all_nodes.extend(dummy_nodes_.as_span());
+ all_nodes.extend(function_nodes_.as_span().cast<const MFNode *>());
+ all_nodes.extend(dummy_nodes_.as_span().cast<const MFNode *>());
for (const MFNode *node : all_nodes) {
dot::Node &dot_node = digraph.new_node("");
diff --git a/source/blender/functions/intern/multi_function_network_evaluation.cc b/source/blender/functions/intern/multi_function_network_evaluation.cc
index 25e983d2eeb..c543d86ad34 100644
--- a/source/blender/functions/intern/multi_function_network_evaluation.cc
+++ b/source/blender/functions/intern/multi_function_network_evaluation.cc
@@ -519,8 +519,8 @@ MFNetworkEvaluationStorage::~MFNetworkEvaluationStorage()
if (any_value == nullptr) {
continue;
}
- else if (any_value->type == ValueType::OwnSingle) {
- OwnSingleValue *value = (OwnSingleValue *)any_value;
+ if (any_value->type == ValueType::OwnSingle) {
+ OwnSingleValue *value = static_cast<OwnSingleValue *>(any_value);
GMutableSpan span = value->span;
const CPPType &type = span.type();
if (value->is_single_allocated) {
@@ -532,7 +532,7 @@ MFNetworkEvaluationStorage::~MFNetworkEvaluationStorage()
}
}
else if (any_value->type == ValueType::OwnVector) {
- OwnVectorValue *value = (OwnVectorValue *)any_value;
+ OwnVectorValue *value = static_cast<OwnVectorValue *>(any_value);
delete value->vector_array;
}
}
@@ -550,7 +550,7 @@ bool MFNetworkEvaluationStorage::socket_is_computed(const MFOutputSocket &socket
return false;
}
if (ELEM(any_value->type, ValueType::OutputSingle, ValueType::OutputVector)) {
- return ((OutputValue *)any_value)->is_computed;
+ return static_cast<OutputValue *>(any_value)->is_computed;
}
return true;
}
@@ -560,17 +560,17 @@ bool MFNetworkEvaluationStorage::is_same_value_for_every_index(const MFOutputSoc
Value *any_value = value_per_output_id_[socket.id()];
switch (any_value->type) {
case ValueType::OwnSingle:
- return ((OwnSingleValue *)any_value)->span.size() == 1;
+ return static_cast<OwnSingleValue *>(any_value)->span.size() == 1;
case ValueType::OwnVector:
- return ((OwnVectorValue *)any_value)->vector_array->size() == 1;
+ return static_cast<OwnVectorValue *>(any_value)->vector_array->size() == 1;
case ValueType::InputSingle:
- return ((InputSingleValue *)any_value)->virtual_span.is_single_element();
+ return static_cast<InputSingleValue *>(any_value)->virtual_span.is_single_element();
case ValueType::InputVector:
- return ((InputVectorValue *)any_value)->virtual_array_span.is_single_array();
+ return static_cast<InputVectorValue *>(any_value)->virtual_array_span.is_single_array();
case ValueType::OutputSingle:
- return ((OutputSingleValue *)any_value)->span.size() == 1;
+ return static_cast<OutputSingleValue *>(any_value)->span.size() == 1;
case ValueType::OutputVector:
- return ((OutputVectorValue *)any_value)->vector_array->size() == 1;
+ return static_cast<OutputVectorValue *>(any_value)->vector_array->size() == 1;
}
BLI_assert(false);
return false;
@@ -605,7 +605,7 @@ void MFNetworkEvaluationStorage::finish_output_socket(const MFOutputSocket &sock
}
if (ELEM(any_value->type, ValueType::OutputSingle, ValueType::OutputVector)) {
- ((OutputValue *)any_value)->is_computed = true;
+ static_cast<OutputValue *>(any_value)->is_computed = true;
}
}
@@ -627,7 +627,7 @@ void MFNetworkEvaluationStorage::finish_input_socket(const MFInputSocket &socket
break;
}
case ValueType::OwnSingle: {
- OwnSingleValue *value = (OwnSingleValue *)any_value;
+ OwnSingleValue *value = static_cast<OwnSingleValue *>(any_value);
BLI_assert(value->max_remaining_users >= 1);
value->max_remaining_users--;
if (value->max_remaining_users == 0) {
@@ -645,7 +645,7 @@ void MFNetworkEvaluationStorage::finish_input_socket(const MFInputSocket &socket
break;
}
case ValueType::OwnVector: {
- OwnVectorValue *value = (OwnVectorValue *)any_value;
+ OwnVectorValue *value = static_cast<OwnVectorValue *>(any_value);
BLI_assert(value->max_remaining_users >= 1);
value->max_remaining_users--;
if (value->max_remaining_users == 0) {
@@ -710,10 +710,9 @@ GMutableSpan MFNetworkEvaluationStorage::get_single_output__full(const MFOutputS
return span;
}
- else {
- BLI_assert(any_value->type == ValueType::OutputSingle);
- return ((OutputSingleValue *)any_value)->span;
- }
+
+ BLI_assert(any_value->type == ValueType::OutputSingle);
+ return static_cast<OutputSingleValue *>(any_value)->span;
}
GMutableSpan MFNetworkEvaluationStorage::get_single_output__single(const MFOutputSocket &socket)
@@ -729,12 +728,11 @@ GMutableSpan MFNetworkEvaluationStorage::get_single_output__single(const MFOutpu
return value->span;
}
- else {
- BLI_assert(any_value->type == ValueType::OutputSingle);
- GMutableSpan span = ((OutputSingleValue *)any_value)->span;
- BLI_assert(span.size() == 1);
- return span;
- }
+
+ BLI_assert(any_value->type == ValueType::OutputSingle);
+ GMutableSpan span = static_cast<OutputSingleValue *>(any_value)->span;
+ BLI_assert(span.size() == 1);
+ return span;
}
GVectorArray &MFNetworkEvaluationStorage::get_vector_output__full(const MFOutputSocket &socket)
@@ -749,10 +747,9 @@ GVectorArray &MFNetworkEvaluationStorage::get_vector_output__full(const MFOutput
return *value->vector_array;
}
- else {
- BLI_assert(any_value->type == ValueType::OutputVector);
- return *((OutputVectorValue *)any_value)->vector_array;
- }
+
+ BLI_assert(any_value->type == ValueType::OutputVector);
+ return *static_cast<OutputVectorValue *>(any_value)->vector_array;
}
GVectorArray &MFNetworkEvaluationStorage::get_vector_output__single(const MFOutputSocket &socket)
@@ -767,12 +764,11 @@ GVectorArray &MFNetworkEvaluationStorage::get_vector_output__single(const MFOutp
return *value->vector_array;
}
- else {
- BLI_assert(any_value->type == ValueType::OutputVector);
- GVectorArray &vector_array = *((OutputVectorValue *)any_value)->vector_array;
- BLI_assert(vector_array.size() == 1);
- return vector_array;
- }
+
+ BLI_assert(any_value->type == ValueType::OutputVector);
+ GVectorArray &vector_array = *static_cast<OutputVectorValue *>(any_value)->vector_array;
+ BLI_assert(vector_array.size() == 1);
+ return vector_array;
}
GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__full(const MFInputSocket &input,
@@ -789,14 +785,14 @@ GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__full(const MFInputS
if (to_any_value != nullptr) {
BLI_assert(to_any_value->type == ValueType::OutputSingle);
- GMutableSpan span = ((OutputSingleValue *)to_any_value)->span;
+ GMutableSpan span = static_cast<OutputSingleValue *>(to_any_value)->span;
GVSpan virtual_span = this->get_single_input__full(input);
virtual_span.materialize_to_uninitialized(mask_, span.data());
return span;
}
if (from_any_value->type == ValueType::OwnSingle) {
- OwnSingleValue *value = (OwnSingleValue *)from_any_value;
+ OwnSingleValue *value = static_cast<OwnSingleValue *>(from_any_value);
if (value->max_remaining_users == 1 && !value->is_single_allocated) {
value_per_output_id_[to.id()] = value;
value_per_output_id_[from.id()] = nullptr;
@@ -830,7 +826,7 @@ GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__single(const MFInpu
if (to_any_value != nullptr) {
BLI_assert(to_any_value->type == ValueType::OutputSingle);
- GMutableSpan span = ((OutputSingleValue *)to_any_value)->span;
+ GMutableSpan span = static_cast<OutputSingleValue *>(to_any_value)->span;
BLI_assert(span.size() == 1);
GVSpan virtual_span = this->get_single_input__single(input);
type.copy_to_uninitialized(virtual_span.as_single_element(), span[0]);
@@ -838,7 +834,7 @@ GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__single(const MFInpu
}
if (from_any_value->type == ValueType::OwnSingle) {
- OwnSingleValue *value = (OwnSingleValue *)from_any_value;
+ OwnSingleValue *value = static_cast<OwnSingleValue *>(from_any_value);
if (value->max_remaining_users == 1) {
value_per_output_id_[to.id()] = value;
value_per_output_id_[from.id()] = nullptr;
@@ -874,14 +870,14 @@ GVectorArray &MFNetworkEvaluationStorage::get_mutable_vector__full(const MFInput
if (to_any_value != nullptr) {
BLI_assert(to_any_value->type == ValueType::OutputVector);
- GVectorArray &vector_array = *((OutputVectorValue *)to_any_value)->vector_array;
+ GVectorArray &vector_array = *static_cast<OutputVectorValue *>(to_any_value)->vector_array;
GVArraySpan virtual_array_span = this->get_vector_input__full(input);
vector_array.extend(mask_, virtual_array_span);
return vector_array;
}
if (from_any_value->type == ValueType::OwnVector) {
- OwnVectorValue *value = (OwnVectorValue *)from_any_value;
+ OwnVectorValue *value = static_cast<OwnVectorValue *>(from_any_value);
if (value->max_remaining_users == 1) {
value_per_output_id_[to.id()] = value;
value_per_output_id_[from.id()] = nullptr;
@@ -916,7 +912,7 @@ GVectorArray &MFNetworkEvaluationStorage::get_mutable_vector__single(const MFInp
if (to_any_value != nullptr) {
BLI_assert(to_any_value->type == ValueType::OutputVector);
- GVectorArray &vector_array = *((OutputVectorValue *)to_any_value)->vector_array;
+ GVectorArray &vector_array = *static_cast<OutputVectorValue *>(to_any_value)->vector_array;
BLI_assert(vector_array.size() == 1);
GVArraySpan virtual_array_span = this->get_vector_input__single(input);
vector_array.extend(0, virtual_array_span[0]);
@@ -924,7 +920,7 @@ GVectorArray &MFNetworkEvaluationStorage::get_mutable_vector__single(const MFInp
}
if (from_any_value->type == ValueType::OwnVector) {
- OwnVectorValue *value = (OwnVectorValue *)from_any_value;
+ OwnVectorValue *value = static_cast<OwnVectorValue *>(from_any_value);
if (value->max_remaining_users == 1) {
value_per_output_id_[to.id()] = value;
value_per_output_id_[from.id()] = nullptr;
@@ -951,20 +947,19 @@ GVSpan MFNetworkEvaluationStorage::get_single_input__full(const MFInputSocket &s
BLI_assert(any_value != nullptr);
if (any_value->type == ValueType::OwnSingle) {
- OwnSingleValue *value = (OwnSingleValue *)any_value;
+ OwnSingleValue *value = static_cast<OwnSingleValue *>(any_value);
if (value->is_single_allocated) {
return GVSpan::FromSingle(value->span.type(), value->span.data(), min_array_size_);
}
- else {
- return value->span;
- }
+
+ return value->span;
}
- else if (any_value->type == ValueType::InputSingle) {
- InputSingleValue *value = (InputSingleValue *)any_value;
+ if (any_value->type == ValueType::InputSingle) {
+ InputSingleValue *value = static_cast<InputSingleValue *>(any_value);
return value->virtual_span;
}
- else if (any_value->type == ValueType::OutputSingle) {
- OutputSingleValue *value = (OutputSingleValue *)any_value;
+ if (any_value->type == ValueType::OutputSingle) {
+ OutputSingleValue *value = static_cast<OutputSingleValue *>(any_value);
BLI_assert(value->is_computed);
return value->span;
}
@@ -980,17 +975,17 @@ GVSpan MFNetworkEvaluationStorage::get_single_input__single(const MFInputSocket
BLI_assert(any_value != nullptr);
if (any_value->type == ValueType::OwnSingle) {
- OwnSingleValue *value = (OwnSingleValue *)any_value;
+ OwnSingleValue *value = static_cast<OwnSingleValue *>(any_value);
BLI_assert(value->span.size() == 1);
return value->span;
}
- else if (any_value->type == ValueType::InputSingle) {
- InputSingleValue *value = (InputSingleValue *)any_value;
+ if (any_value->type == ValueType::InputSingle) {
+ InputSingleValue *value = static_cast<InputSingleValue *>(any_value);
BLI_assert(value->virtual_span.is_single_element());
return value->virtual_span;
}
- else if (any_value->type == ValueType::OutputSingle) {
- OutputSingleValue *value = (OutputSingleValue *)any_value;
+ if (any_value->type == ValueType::OutputSingle) {
+ OutputSingleValue *value = static_cast<OutputSingleValue *>(any_value);
BLI_assert(value->is_computed);
BLI_assert(value->span.size() == 1);
return value->span;
@@ -1007,21 +1002,20 @@ GVArraySpan MFNetworkEvaluationStorage::get_vector_input__full(const MFInputSock
BLI_assert(any_value != nullptr);
if (any_value->type == ValueType::OwnVector) {
- OwnVectorValue *value = (OwnVectorValue *)any_value;
+ OwnVectorValue *value = static_cast<OwnVectorValue *>(any_value);
if (value->vector_array->size() == 1) {
GSpan span = (*value->vector_array)[0];
return GVArraySpan(span, min_array_size_);
}
- else {
- return *value->vector_array;
- }
+
+ return *value->vector_array;
}
- else if (any_value->type == ValueType::InputVector) {
- InputVectorValue *value = (InputVectorValue *)any_value;
+ if (any_value->type == ValueType::InputVector) {
+ InputVectorValue *value = static_cast<InputVectorValue *>(any_value);
return value->virtual_array_span;
}
- else if (any_value->type == ValueType::OutputVector) {
- OutputVectorValue *value = (OutputVectorValue *)any_value;
+ if (any_value->type == ValueType::OutputVector) {
+ OutputVectorValue *value = static_cast<OutputVectorValue *>(any_value);
return *value->vector_array;
}
@@ -1036,17 +1030,17 @@ GVArraySpan MFNetworkEvaluationStorage::get_vector_input__single(const MFInputSo
BLI_assert(any_value != nullptr);
if (any_value->type == ValueType::OwnVector) {
- OwnVectorValue *value = (OwnVectorValue *)any_value;
+ OwnVectorValue *value = static_cast<OwnVectorValue *>(any_value);
BLI_assert(value->vector_array->size() == 1);
return *value->vector_array;
}
- else if (any_value->type == ValueType::InputVector) {
- InputVectorValue *value = (InputVectorValue *)any_value;
+ if (any_value->type == ValueType::InputVector) {
+ InputVectorValue *value = static_cast<InputVectorValue *>(any_value);
BLI_assert(value->virtual_array_span.is_single_array());
return value->virtual_array_span;
}
- else if (any_value->type == ValueType::OutputVector) {
- OutputVectorValue *value = (OutputVectorValue *)any_value;
+ if (any_value->type == ValueType::OutputVector) {
+ OutputVectorValue *value = static_cast<OutputVectorValue *>(any_value);
BLI_assert(value->vector_array->size() == 1);
return *value->vector_array;
}
diff --git a/source/blender/functions/intern/multi_function_network_optimization.cc b/source/blender/functions/intern/multi_function_network_optimization.cc
index af1e77aa355..e24f157d4f9 100644
--- a/source/blender/functions/intern/multi_function_network_optimization.cc
+++ b/source/blender/functions/intern/multi_function_network_optimization.cc
@@ -45,9 +45,8 @@ static bool set_tag_and_check_if_modified(bool &tag, bool new_value)
tag = new_value;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
static Array<bool> mask_nodes_to_the_left(MFNetwork &network, Span<MFNode *> nodes)
@@ -131,7 +130,8 @@ static Vector<MFNode *> find_nodes_based_on_mask(MFNetwork &network,
*/
void dead_node_removal(MFNetwork &network)
{
- Array<bool> node_is_used_mask = mask_nodes_to_the_left(network, network.dummy_nodes());
+ Array<bool> node_is_used_mask = mask_nodes_to_the_left(network,
+ network.dummy_nodes().cast<MFNode *>());
Vector<MFNode *> nodes_to_remove = find_nodes_based_on_mask(network, node_is_used_mask, false);
network.remove(nodes_to_remove);
}
@@ -157,7 +157,7 @@ static bool function_node_can_be_constant(MFFunctionNode *node)
static Vector<MFNode *> find_non_constant_nodes(MFNetwork &network)
{
Vector<MFNode *> non_constant_nodes;
- non_constant_nodes.extend(network.dummy_nodes());
+ non_constant_nodes.extend(network.dummy_nodes().cast<MFNode *>());
for (MFFunctionNode *node : network.function_nodes()) {
if (!function_node_can_be_constant(node)) {
@@ -300,6 +300,10 @@ static Array<MFOutputSocket *> compute_constant_sockets_and_add_folded_nodes(
return add_constant_folded_sockets(network_fn, params, resources, network);
}
+class MyClass {
+ MFDummyNode node;
+};
+
/**
* Find function nodes that always output the same value and replace those with constant nodes.
*/
@@ -319,7 +323,7 @@ void constant_folding(MFNetwork &network, ResourceCollector &resources)
network.relink(original_socket, *folded_sockets[i]);
}
- network.remove(temporary_nodes);
+ network.remove(temporary_nodes.as_span().cast<MFNode *>());
}
/** \} */
diff --git a/source/blender/functions/tests/FN_multi_function_network_test.cc b/source/blender/functions/tests/FN_multi_function_network_test.cc
index 53290e9170c..f226e0eac2e 100644
--- a/source/blender/functions/tests/FN_multi_function_network_test.cc
+++ b/source/blender/functions/tests/FN_multi_function_network_test.cc
@@ -7,6 +7,7 @@
#include "FN_multi_function_network_evaluation.hh"
namespace blender::fn::tests {
+namespace {
TEST(multi_function_network, Test1)
{
@@ -250,4 +251,5 @@ TEST(multi_function_network, Test2)
}
}
+} // namespace
} // namespace blender::fn::tests
diff --git a/source/blender/functions/tests/FN_multi_function_test.cc b/source/blender/functions/tests/FN_multi_function_test.cc
index 6acb6e22b01..cc023bce597 100644
--- a/source/blender/functions/tests/FN_multi_function_test.cc
+++ b/source/blender/functions/tests/FN_multi_function_test.cc
@@ -6,6 +6,7 @@
#include "FN_multi_function_builder.hh"
namespace blender::fn::tests {
+namespace {
class AddFunction : public MultiFunction {
public:
@@ -125,7 +126,7 @@ TEST(multi_function, CreateRangeFunction)
{
CreateRangeFunction fn;
- GVectorArray ranges(CPPType::get<int32_t>(), 5);
+ GVectorArray ranges(CPPType::get<uint>(), 5);
GVectorArrayRef<uint> ranges_ref(ranges);
Array<uint> sizes = {3, 0, 6, 1, 4};
@@ -382,4 +383,5 @@ TEST(multi_function, CustomMF_Convert)
EXPECT_EQ(outputs[2], 9);
}
+} // namespace
} // namespace blender::fn::tests
diff --git a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
index a7a4333d82e..3f167ac6785 100644
--- a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
+++ b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
@@ -18,8 +18,7 @@
* \ingroup modifiers
*/
-#ifndef __MOD_GPENCIL_MODIFIERTYPES_H__
-#define __MOD_GPENCIL_MODIFIERTYPES_H__
+#pragma once
#include "BKE_gpencil_modifier.h"
@@ -47,5 +46,3 @@ extern GpencilModifierTypeInfo modifierType_Gpencil_Texture;
/* MOD_gpencil_util.c */
void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[]);
-
-#endif /* __MOD_GPENCIL_MODIFIERTYPES_H__ */
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h
index 9c6edb51d63..c85e939b13f 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h
@@ -18,8 +18,7 @@
* \ingroup modifiers
*/
-#ifndef __MOD_UI_COMMON__GPENCIL_H__
-#define __MOD_UI_COMMON__GPENCIL_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -62,5 +61,3 @@ struct PanelType *gpencil_modifier_subpanel_register(struct ARegionType *region_
#ifdef __cplusplus
}
#endif
-
-#endif /* __MOD_UI_COMMON__GPENCIL_H__ */
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index f7929b58650..077a454db73 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -180,9 +180,8 @@ float get_modifier_point_weight(MDeformVert *dvert, bool inverse, int def_nr)
if (inverse == 1) {
return 1.0f;
}
- else {
- return -1.0f;
- }
+
+ return -1.0f;
}
return weight;
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h
index 5cc3750639b..e5a6d9e6a8f 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h
@@ -21,8 +21,7 @@
* \ingroup modifiers
*/
-#ifndef __MOD_GPENCIL_UTIL_H__
-#define __MOD_GPENCIL_UTIL_H__
+#pragma once
struct GHash;
struct MDeformVert;
@@ -46,5 +45,3 @@ bool is_stroke_affected_by_modifier(struct Object *ob,
const bool inv4);
float get_modifier_point_weight(struct MDeformVert *dvert, bool inverse, int def_nr);
-
-#endif /* __MOD_GPENCIL_UTIL_H__ */
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
index d92721f887f..d645064475b 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
@@ -236,7 +236,7 @@ static void generate_geometry(GpencilModifierData *md,
float rand[3][3];
for (int j = 0; j < 3; j++) {
- uint primes[3] = {2, 3, 7};
+ const uint primes[3] = {2, 3, 7};
double offset[3] = {0.0, 0.0, 0.0};
double r[3];
/* To ensure a nice distribution, we use halton sequence and offset using the seed. */
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
index 56d94611b5d..bf6c47b2df5 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
@@ -484,7 +484,7 @@ static void generate_geometry(GpencilModifierData *md,
/* Early exit */
return;
}
- else if (ctime >= end_frame) {
+ if (ctime >= end_frame) {
/* Past End - Animation finished. Display final result. */
if (reverse) {
/* 1) Reverse = Start with all, end with nothing.
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
index 03137a5cf23..21a8962b131 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
@@ -69,7 +69,7 @@ static void initData(GpencilModifierData *md)
gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (gpmd->curve_intensity) {
CurveMapping *curve = gpmd->curve_intensity;
- BKE_curvemapping_initialize(curve);
+ BKE_curvemapping_init(curve);
}
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
index 4761dc878c0..30ac18c64ae 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
@@ -94,7 +94,7 @@ static void initData(GpencilModifierData *md)
gpmd->falloff_type = eGPHook_Falloff_Smooth;
gpmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (gpmd->curfalloff) {
- BKE_curvemapping_initialize(gpmd->curfalloff);
+ BKE_curvemapping_init(gpmd->curfalloff);
}
}
@@ -120,7 +120,7 @@ static float gpencil_hook_falloff(const struct GPHookData_cb *tData, const float
if (len_sq > tData->falloff_sq) {
return 0.0f;
}
- else if (len_sq > 0.0f) {
+ if (len_sq > 0.0f) {
float fac;
if (tData->falloff_type == eGPHook_Falloff_Const) {
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
index 619c37015e4..0f6daea50ef 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
@@ -147,9 +147,9 @@ static void duplicateStroke(Object *ob,
normalize_v3(stroke_normal);
}
- float *t1_array = MEM_callocN(sizeof(float) * 3 * gps->totpoints,
+ float *t1_array = MEM_callocN(sizeof(float[3]) * gps->totpoints,
"duplicate_temp_result_array_1");
- float *t2_array = MEM_callocN(sizeof(float) * 3 * gps->totpoints,
+ float *t2_array = MEM_callocN(sizeof(float[3]) * gps->totpoints,
"duplicate_temp_result_array_2");
pt = gps->points;
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
index 0d8a5f7914e..67c26bf2584 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
@@ -79,7 +79,7 @@ static void initData(GpencilModifierData *md)
if (gpmd->curve_intensity) {
CurveMapping *curve = gpmd->curve_intensity;
BKE_curvemap_reset(curve->cm, &curve->clipr, CURVE_PRESET_BELL, CURVEMAP_SLOPE_POSITIVE);
- BKE_curvemapping_initialize(curve);
+ BKE_curvemapping_init(curve);
}
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
index 34142709c18..efa58cc4ae0 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
@@ -70,7 +70,7 @@ static void initData(GpencilModifierData *md)
gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (gpmd->curve_intensity) {
CurveMapping *curve = gpmd->curve_intensity;
- BKE_curvemapping_initialize(curve);
+ BKE_curvemapping_init(curve);
}
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
index 175a6d81b1b..e3511d9645e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
@@ -66,7 +66,7 @@ static void initData(GpencilModifierData *md)
gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (gpmd->curve_intensity) {
CurveMapping *curve = gpmd->curve_intensity;
- BKE_curvemapping_initialize(curve);
+ BKE_curvemapping_init(curve);
}
}
@@ -195,7 +195,7 @@ static void panel_draw(const bContext *C, Panel *panel)
row = uiLayoutRow(layout, true);
uiItemR(row, &ptr, "use_edit_position", UI_ITEM_R_TOGGLE, IFACE_("Position"), ICON_NONE);
- uiItemR(row, &ptr, "use_edit_strength", UI_ITEM_R_TOGGLE, IFACE_("Stength"), ICON_NONE);
+ uiItemR(row, &ptr, "use_edit_strength", UI_ITEM_R_TOGGLE, IFACE_("Strength"), ICON_NONE);
uiItemR(row, &ptr, "use_edit_thickness", UI_ITEM_R_TOGGLE, IFACE_("Thickness"), ICON_NONE);
uiItemR(row, &ptr, "use_edit_uv", UI_ITEM_R_TOGGLE, IFACE_("UV"), ICON_NONE);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
index 4fa47a592ba..68547614776 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
@@ -65,7 +65,7 @@ static void initData(GpencilModifierData *md)
gpmd->material = NULL;
gpmd->curve_thickness = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (gpmd->curve_thickness) {
- BKE_curvemapping_initialize(gpmd->curve_thickness);
+ BKE_curvemapping_init(gpmd->curve_thickness);
}
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
index 49396f56d26..389f3ca1bd2 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
@@ -22,6 +22,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "BLI_utildefines.h"
@@ -168,7 +169,7 @@ static int remapTime(struct GpencilModifierData *md,
const int delta = abs(sfra - nfra);
return efra - delta + 1;
}
- else if (cfra + offset > efra) {
+ if (cfra + offset > efra) {
return nfra - efra + sfra - 1;
}
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
index da7d33839f1..9d10fcbe49b 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
@@ -96,7 +96,7 @@ static void initData(GpencilModifierData *md)
gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (gpmd->curve_intensity) {
CurveMapping *curve = gpmd->curve_intensity;
- BKE_curvemapping_initialize(curve);
+ BKE_curvemapping_init(curve);
}
}
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 3c7ff51ea24..80ea28aca3c 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -28,6 +28,8 @@ endif()
set(INC
.
+ intern
+ opengl
../blenkernel
../blenlib
../bmesh
@@ -42,6 +44,7 @@ set(INC
../nodes
../nodes/intern
+ ../../../intern/ghost
../../../intern/glew-mx
../../../intern/guardedalloc
../../../intern/mantaflow/extern
@@ -68,24 +71,25 @@ set(SRC
intern/gpu_init_exit.c
intern/gpu_material.c
intern/gpu_material_library.c
- intern/gpu_matrix.c
+ intern/gpu_matrix.cc
intern/gpu_node_graph.c
intern/gpu_platform.cc
intern/gpu_primitive.c
intern/gpu_select.c
intern/gpu_select_pick.c
intern/gpu_select_sample_query.c
- intern/gpu_shader.c
- intern/gpu_shader_interface.c
- intern/gpu_state.c
- intern/gpu_texture.c
- intern/gpu_texture_image.cc
- intern/gpu_texture_smoke.cc
- intern/gpu_uniformbuffer.c
- intern/gpu_vertex_buffer.c
- intern/gpu_vertex_format.c
+ intern/gpu_shader.cc
+ intern/gpu_shader_builtin.c
+ intern/gpu_shader_interface.cc
+ intern/gpu_state.cc
+ intern/gpu_texture.cc
+ intern/gpu_uniformbuffer.cc
+ intern/gpu_vertex_buffer.cc
+ intern/gpu_vertex_format.cc
intern/gpu_viewport.c
+ opengl/gl_context.cc
+
GPU_attr_binding.h
GPU_batch.h
GPU_batch_presets.h
@@ -94,7 +98,6 @@ set(SRC
GPU_common.h
GPU_context.h
GPU_debug.h
- GPU_draw.h
GPU_element.h
GPU_extensions.h
GPU_framebuffer.h
@@ -118,9 +121,10 @@ set(SRC
GPU_viewport.h
intern/gpu_attr_binding_private.h
+ intern/gpu_backend.hh
intern/gpu_batch_private.h
intern/gpu_codegen.h
- intern/gpu_context_private.h
+ intern/gpu_context_private.hh
intern/gpu_material_library.h
intern/gpu_matrix_private.h
intern/gpu_node_graph.h
@@ -129,6 +133,9 @@ set(SRC
intern/gpu_select_private.h
intern/gpu_shader_private.h
intern/gpu_vertex_format_private.h
+
+ opengl/gl_backend.hh
+ opengl/gl_context.hh
)
set(LIB
@@ -216,6 +223,8 @@ data_to_c_simple(shaders/gpu_shader_text_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_keyframe_diamond_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_keyframe_diamond_frag.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_codegen_lib.glsl SRC)
+
data_to_c_simple(shaders/gpu_shader_geometry.glsl SRC)
data_to_c_simple(shaders/material/gpu_shader_material_add_shader.glsl SRC)
diff --git a/source/blender/gpu/GPU_attr_binding.h b/source/blender/gpu/GPU_attr_binding.h
index 8093e02cab6..e7c3dcbce05 100644
--- a/source/blender/gpu/GPU_attr_binding.h
+++ b/source/blender/gpu/GPU_attr_binding.h
@@ -23,8 +23,7 @@
* GPU vertex attribute binding
*/
-#ifndef __GPU_ATTR_BINDING_H__
-#define __GPU_ATTR_BINDING_H__
+#pragma once
#include "GPU_common.h"
@@ -42,5 +41,3 @@ typedef struct GPUAttrBinding {
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_ATTR_BINDING_H__ */
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index 5f55b512695..855214c279c 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -24,8 +24,7 @@
* Contains VAOs + VBOs + Shader representing a drawable entity.
*/
-#ifndef __GPU_BATCH_H__
-#define __GPU_BATCH_H__
+#pragma once
#include "GPU_element.h"
#include "GPU_shader.h"
@@ -103,6 +102,7 @@ enum {
GPU_BATCH_OWNS_INDEX = (1u << 31u),
};
+GPUBatch *GPU_batch_calloc(uint count);
GPUBatch *GPU_batch_create_ex(GPUPrimType, GPUVertBuf *, GPUIndexBuf *, uint owns_flag);
void GPU_batch_init_ex(GPUBatch *, GPUPrimType, GPUVertBuf *, GPUIndexBuf *, uint owns_flag);
void GPU_batch_copy(GPUBatch *batch_dst, GPUBatch *batch_src);
@@ -127,9 +127,8 @@ int GPU_batch_vertbuf_add_ex(GPUBatch *, GPUVertBuf *, bool own_vbo);
#define GPU_batch_vertbuf_add(batch, verts) GPU_batch_vertbuf_add_ex(batch, verts, false)
-void GPU_batch_program_set_no_use(GPUBatch *, uint32_t program, const GPUShaderInterface *);
-void GPU_batch_program_set(GPUBatch *, uint32_t program, const GPUShaderInterface *);
-void GPU_batch_program_set_shader(GPUBatch *, GPUShader *shader);
+void GPU_batch_set_shader(GPUBatch *batch, GPUShader *shader);
+void GPU_batch_set_shader_no_bind(GPUBatch *batch, GPUShader *shader);
void GPU_batch_program_set_imm_shader(GPUBatch *batch);
void GPU_batch_program_set_builtin(GPUBatch *batch, eGPUBuiltinShader shader_id);
void GPU_batch_program_set_builtin_with_config(GPUBatch *batch,
@@ -248,5 +247,3 @@ void gpu_batch_exit(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_BATCH_H__ */
diff --git a/source/blender/gpu/GPU_batch_presets.h b/source/blender/gpu/GPU_batch_presets.h
index eb803333d98..1674cf776db 100644
--- a/source/blender/gpu/GPU_batch_presets.h
+++ b/source/blender/gpu/GPU_batch_presets.h
@@ -24,8 +24,7 @@
* This file contains any additions or modifications specific to Blender.
*/
-#ifndef __GPU_BATCH_PRESETS_H__
-#define __GPU_BATCH_PRESETS_H__
+#pragma once
#include "BLI_compiler_attrs.h"
#include "BLI_sys_types.h"
@@ -50,8 +49,8 @@ bool gpu_batch_presets_unregister(struct GPUBatch *preset_batch);
void gpu_batch_presets_reset(void);
void gpu_batch_presets_exit(void);
+void GPU_batch_presets_reset(void);
+
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_BATCH_PRESETS_H__ */
diff --git a/source/blender/gpu/GPU_batch_utils.h b/source/blender/gpu/GPU_batch_utils.h
index 8f85ac59aa5..37dccc4621c 100644
--- a/source/blender/gpu/GPU_batch_utils.h
+++ b/source/blender/gpu/GPU_batch_utils.h
@@ -18,8 +18,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_BATCH_UTILS_H__
-#define __GPU_BATCH_UTILS_H__
+#pragma once
#include "BLI_compiler_attrs.h"
#include "BLI_sys_types.h"
@@ -44,5 +43,3 @@ struct GPUBatch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RES
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_BATCH_UTILS_H__ */
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index c7e74040568..23349728f25 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_BUFFERS_H__
-#define __GPU_BUFFERS_H__
+#pragma once
#include <stddef.h>
@@ -121,5 +120,3 @@ bool GPU_pbvh_buffers_has_overlays(GPU_PBVH_Buffers *buffers);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/gpu/GPU_common.h b/source/blender/gpu/GPU_common.h
index dd580ebbdac..8fd1baba2f7 100644
--- a/source/blender/gpu/GPU_common.h
+++ b/source/blender/gpu/GPU_common.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_COMMON_H__
-#define __GPU_COMMON_H__
+#pragma once
#define PROGRAM_NO_OPTI 0
@@ -51,5 +50,3 @@
#else
# define GPU_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
#endif
-
-#endif /* __GPU_COMMON_H__ */
diff --git a/source/blender/gpu/GPU_context.h b/source/blender/gpu/GPU_context.h
index 9876aa6998c..e3d47cfe084 100644
--- a/source/blender/gpu/GPU_context.h
+++ b/source/blender/gpu/GPU_context.h
@@ -23,8 +23,7 @@
* This interface allow GPU to manage VAOs for multiple context and threads.
*/
-#ifndef __GPU_CONTEXT_H__
-#define __GPU_CONTEXT_H__
+#pragma once
#include "GPU_batch.h"
#include "GPU_common.h"
@@ -36,14 +35,28 @@ extern "C" {
typedef struct GPUContext GPUContext;
-GPUContext *GPU_context_create(GLuint default_framebuffer);
+typedef enum eGPUBackendType {
+ GPU_BACKEND_NONE = 0,
+ GPU_BACKEND_OPENGL,
+} eGPUBackendType;
+
+void GPU_backend_init(eGPUBackendType backend);
+void GPU_backend_exit(void);
+
+GPUContext *GPU_context_create(void *ghost_window);
void GPU_context_discard(GPUContext *);
void GPU_context_active_set(GPUContext *);
GPUContext *GPU_context_active_get(void);
+/* Legacy GPU (Intel HD4000 series) do not support sharing GPU objects between GPU
+ * contexts. EEVEE/Workbench can create different contexts for image/preview rendering, baking or
+ * compiling. When a legacy GPU is detected (`GPU_use_main_context_workaround()`) any worker
+ * threads should use the draw manager opengl context and make sure that they are the only one
+ * using it by locking the main context using these two functions. */
+void GPU_context_main_lock(void);
+void GPU_context_main_unlock(void);
+
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_CONTEXT_H__ */
diff --git a/source/blender/gpu/GPU_debug.h b/source/blender/gpu/GPU_debug.h
index fc6ca791664..be822056678 100644
--- a/source/blender/gpu/GPU_debug.h
+++ b/source/blender/gpu/GPU_debug.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_DEBUG_H__
-#define __GPU_DEBUG_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -37,5 +36,3 @@ void GPU_string_marker(const char *str);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_DEBUG_H__ */
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
deleted file mode 100644
index 01af654b52f..00000000000
--- a/source/blender/gpu/GPU_draw.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2005 Blender Foundation.
- * All rights reserved.
- */
-
-/** \file
- * \ingroup gpu
- */
-
-#ifndef __GPU_DRAW_H__
-#define __GPU_DRAW_H__
-
-#include "BLI_utildefines.h"
-#include "DNA_object_enums.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct FluidModifierData;
-struct ImBuf;
-struct Image;
-struct ImageUser;
-struct Main;
-
-/* OpenGL drawing functions related to shading. */
-
-/* Mipmap settings
- * - these will free textures on changes */
-
-void GPU_set_mipmap(struct Main *bmain, bool mipmap);
-bool GPU_get_mipmap(void);
-void GPU_set_linear_mipmap(bool linear);
-bool GPU_get_linear_mipmap(void);
-void GPU_paint_set_mipmap(struct Main *bmain, bool mipmap);
-
-/* Anisotropic filtering settings
- * - these will free textures on changes */
-void GPU_set_anisotropic(float value);
-float GPU_get_anisotropic(void);
-
-/* Image updates and free
- * - these deal with images bound as opengl textures */
-
-void GPU_paint_update_image(
- struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h);
-bool GPU_upload_dxt_texture(struct ImBuf *ibuf, bool use_srgb, uint *bindcode);
-void GPU_free_image(struct Image *ima);
-void GPU_free_images(struct Main *bmain);
-void GPU_free_images_anim(struct Main *bmain);
-void GPU_free_images_old(struct Main *bmain);
-
-/* gpu_draw_smoke.c */
-void GPU_free_smoke(struct FluidModifierData *fmd);
-void GPU_free_smoke_velocity(struct FluidModifierData *fmd);
-void GPU_create_smoke(struct FluidModifierData *fmd, int highres);
-void GPU_create_smoke_coba_field(struct FluidModifierData *fmd);
-void GPU_create_smoke_velocity(struct FluidModifierData *fmd);
-
-/* Delayed free of OpenGL buffers by main thread */
-void GPU_free_unused_buffers(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/source/blender/gpu/GPU_element.h b/source/blender/gpu/GPU_element.h
index 9aef8d6ed73..3d5195b12fc 100644
--- a/source/blender/gpu/GPU_element.h
+++ b/source/blender/gpu/GPU_element.h
@@ -23,8 +23,7 @@
* GPU element list (AKA index buffer)
*/
-#ifndef __GPU_ELEMENT_H__
-#define __GPU_ELEMENT_H__
+#pragma once
#include "GPU_primitive.h"
@@ -116,5 +115,3 @@ int GPU_indexbuf_primitive_len(GPUPrimType prim_type);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_ELEMENT_H__ */
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index 263deeaf28d..2ce6e458378 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_EXTENSIONS_H__
-#define __GPU_EXTENSIONS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -48,10 +47,12 @@ bool GPU_arb_texture_cube_map_array_is_supported(void);
bool GPU_mip_render_workaround(void);
bool GPU_depth_blitting_workaround(void);
bool GPU_unused_fb_slot_workaround(void);
-bool GPU_context_local_shaders_workaround(void);
+bool GPU_use_main_context_workaround(void);
bool GPU_texture_copy_workaround(void);
bool GPU_crappy_amd_driver(void);
+int GPU_texture_size_with_limit(int res);
+
bool GPU_mem_stats_supported(void);
void GPU_mem_stats_get(int *totalmem, int *freemem);
@@ -62,5 +63,3 @@ bool GPU_stereo_quadbuffer_support(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_EXTENSIONS_H__ */
diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h
index db531cdef9b..9dc07fefd4e 100644
--- a/source/blender/gpu/GPU_framebuffer.h
+++ b/source/blender/gpu/GPU_framebuffer.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_FRAMEBUFFER_H__
-#define __GPU_FRAMEBUFFER_H__
+#pragma once
#include "GPU_texture.h"
@@ -235,5 +234,3 @@ void GPU_backbuffer_bind(eGPUBackBuffer buffer);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_FRAMEBUFFER_H__ */
diff --git a/source/blender/gpu/GPU_glew.h b/source/blender/gpu/GPU_glew.h
index 744bce9713a..e87a7054e5f 100644
--- a/source/blender/gpu/GPU_glew.h
+++ b/source/blender/gpu/GPU_glew.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_GLEW_H__
-#define __GPU_GLEW_H__
+#pragma once
#if defined(WITH_OPENGL)
# include "glew-mx.h"
@@ -30,5 +29,3 @@
# include "GPU_legacy_stubs.h"
# endif
#endif
-
-#endif /* __GPU_GLEW_H__ */
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index 698c4585d20..41d4f5d28d3 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -23,8 +23,7 @@
* GPU immediate mode work-alike
*/
-#ifndef __GPU_IMMEDIATE_H__
-#define __GPU_IMMEDIATE_H__
+#pragma once
#include "GPU_batch.h"
#include "GPU_immediate_util.h"
@@ -42,7 +41,7 @@ extern "C" {
GPUVertFormat *immVertexFormat(void);
/** Every immBegin must have a program bound first. */
-void immBindProgram(uint32_t program, const GPUShaderInterface *);
+void immBindShader(GPUShader *shader);
/** Call after your last immEnd, or before binding another program. */
void immUnbindProgram(void);
@@ -134,13 +133,14 @@ void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char a);
void immUniformColor4ubv(const unsigned char rgba[4]);
/**
- * Extend #immBindProgram to use Blender’s library of built-in shader programs.
+ * Extend #immBindShader to use Blender’s library of built-in shader programs.
* Use #immUnbindProgram() when done.
*/
void immBindBuiltinProgram(eGPUBuiltinShader shader_id);
/* Extend immUniformColor to take Blender's themes */
void immUniformThemeColor(int color_id);
+void immUniformThemeColorAlpha(int color_id, float a);
void immUniformThemeColor3(int color_id);
void immUniformThemeColorShade(int color_id, int offset);
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset);
@@ -157,5 +157,3 @@ void immDestroy(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_IMMEDIATE_H__ */
diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h
index 47b44b59461..7786bcd2d06 100644
--- a/source/blender/gpu/GPU_immediate_util.h
+++ b/source/blender/gpu/GPU_immediate_util.h
@@ -20,8 +20,7 @@
* Utility drawing functions (rough equivalent to OpenGL's GLU)
*/
-#ifndef __GPU_IMMEDIATE_UTIL_H__
-#define __GPU_IMMEDIATE_UTIL_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -92,5 +91,3 @@ void imm_draw_cylinder_fill_3d(
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_IMMEDIATE_UTIL_H__ */
diff --git a/source/blender/gpu/GPU_init_exit.h b/source/blender/gpu/GPU_init_exit.h
index 3e30a1ddcf5..42c56940c4c 100644
--- a/source/blender/gpu/GPU_init_exit.h
+++ b/source/blender/gpu/GPU_init_exit.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_INIT_EXIT_H__
-#define __GPU_INIT_EXIT_H__
+#pragma once
#include "BLI_utildefines.h"
@@ -32,10 +31,8 @@ extern "C" {
void GPU_init(void);
void GPU_exit(void);
-bool GPU_is_initialized(void);
+bool GPU_is_init(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_INIT_EXIT_H__ */
diff --git a/source/blender/gpu/GPU_legacy_stubs.h b/source/blender/gpu/GPU_legacy_stubs.h
index c666ff73bc6..2e21b879907 100644
--- a/source/blender/gpu/GPU_legacy_stubs.h
+++ b/source/blender/gpu/GPU_legacy_stubs.h
@@ -26,8 +26,7 @@
* This file should be removed in the future
*/
-#ifndef __GPU_LEGACY_STUBS_H__
-#define __GPU_LEGACY_STUBS_H__
+#pragma once
#if defined(__GNUC__)
# pragma GCC diagnostic push
@@ -512,5 +511,3 @@ _GL_VOID DO_NOT_USE_glClientActiveTexture(GLenum texture) _GL_VOID_RET
#if defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
-
-#endif /* __GPU_LEGACY_STUBS_H__ */
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index c372bfaf218..b8957ff1819 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_MATERIAL_H__
-#define __GPU_MATERIAL_H__
+#pragma once
#include "DNA_customdata_types.h" /* for CustomDataType */
#include "DNA_listBase.h"
@@ -110,6 +109,7 @@ typedef enum eGPUMatFlag {
GPU_MATFLAG_GLOSSY = (1 << 1),
GPU_MATFLAG_REFRACT = (1 << 2),
GPU_MATFLAG_SSS = (1 << 3),
+ GPU_MATFLAG_BARYCENTRIC = (1 << 4),
} eGPUMatFlag;
typedef enum eGPUBlendMode {
@@ -137,6 +137,13 @@ typedef enum eGPUMaterialStatus {
GPU_MAT_SUCCESS,
} eGPUMaterialStatus;
+typedef void (*GPUMaterialEvalCallbackFn)(GPUMaterial *mat,
+ int options,
+ const char **vert_code,
+ const char **geom_code,
+ const char **frag_lib,
+ const char **defines);
+
GPUNodeLink *GPU_constant(const float *num);
GPUNodeLink *GPU_uniform(const float *num);
GPUNodeLink *GPU_attribute(GPUMaterial *mat, CustomDataType type, const char *name);
@@ -190,7 +197,8 @@ GPUMaterial *GPU_material_from_nodetree(struct Scene *scene,
const char *geom_code,
const char *frag_lib,
const char *defines,
- const char *name);
+ const char *name,
+ GPUMaterialEvalCallbackFn callback);
void GPU_material_compile(GPUMaterial *mat);
void GPU_material_free(struct ListBase *gpumaterial);
@@ -255,5 +263,3 @@ ListBase GPU_material_volume_grids(GPUMaterial *material);
#ifdef __cplusplus
}
#endif
-
-#endif /*__GPU_MATERIAL_H__*/
diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h
index eabfb5d2dc3..7b94a535a30 100644
--- a/source/blender/gpu/GPU_matrix.h
+++ b/source/blender/gpu/GPU_matrix.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_MATRIX_H__
-#define __GPU_MATRIX_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -236,5 +235,3 @@ int GPU_matrix_stack_level_get_projection(void);
* however we need to check these limits in code that calls into these API's. */
#define GPU_MATRIX_ORTHO_CLIP_NEAR_DEFAULT (-100)
#define GPU_MATRIX_ORTHO_CLIP_FAR_DEFAULT (100)
-
-#endif /* __GPU_MATRIX_H__ */
diff --git a/source/blender/gpu/GPU_platform.h b/source/blender/gpu/GPU_platform.h
index 104d5ef0ddc..a89298c0d01 100644
--- a/source/blender/gpu/GPU_platform.h
+++ b/source/blender/gpu/GPU_platform.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_PLATFORM_H__
-#define __GPU_PLATFORM_H__
+#pragma once
#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
@@ -74,5 +73,3 @@ const char *GPU_platform_gpu_name(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_PLATFORM_H__ */
diff --git a/source/blender/gpu/GPU_primitive.h b/source/blender/gpu/GPU_primitive.h
index 4cd6205c0d1..e910e81fac1 100644
--- a/source/blender/gpu/GPU_primitive.h
+++ b/source/blender/gpu/GPU_primitive.h
@@ -23,8 +23,7 @@
* GPU geometric primitives
*/
-#ifndef __GPU_PRIMITIVE_H__
-#define __GPU_PRIMITIVE_H__
+#pragma once
#include "GPU_common.h"
@@ -63,5 +62,3 @@ bool GPU_primtype_belongs_to_class(GPUPrimType, GPUPrimClass);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_PRIMITIVE_H__ */
diff --git a/source/blender/gpu/GPU_select.h b/source/blender/gpu/GPU_select.h
index d9a8e964a3d..d28363253b1 100644
--- a/source/blender/gpu/GPU_select.h
+++ b/source/blender/gpu/GPU_select.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_SELECT_H__
-#define __GPU_SELECT_H__
+#pragma once
#include "BLI_sys_types.h"
@@ -63,5 +62,3 @@ void GPU_select_buffer_stride_realign(const struct rcti *src, const struct rcti
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index a19ed2d84fd..f782742ae53 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_SHADER_H__
-#define __GPU_SHADER_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -87,8 +86,6 @@ void GPU_shader_transform_feedback_disable(GPUShader *shader);
int GPU_shader_get_program(GPUShader *shader);
-void *GPU_shader_get_interface(GPUShader *shader);
-
void GPU_shader_set_srgb_uniform(const struct GPUShaderInterface *interface);
int GPU_shader_get_uniform(GPUShader *shader, const char *name);
@@ -372,5 +369,3 @@ void GPU_shader_free_builtin_shaders(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_SHADER_H__ */
diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h
index 28ee162bdbd..8aba1236b65 100644
--- a/source/blender/gpu/GPU_shader_interface.h
+++ b/source/blender/gpu/GPU_shader_interface.h
@@ -23,8 +23,7 @@
* GPU shader interface (C --> GLSL)
*/
-#ifndef __GPU_SHADER_INTERFACE_H__
-#define __GPU_SHADER_INTERFACE_H__
+#pragma once
#include "GPU_common.h"
@@ -116,5 +115,3 @@ void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface *, struct GPUBatch
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_SHADER_INTERFACE_H__ */
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h
index 8d50330ac93..4a2c90e241b 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -18,8 +18,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_STATE_H__
-#define __GPU_STATE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -87,6 +86,7 @@ bool GPU_depth_mask_get(void);
void GPU_stencil_mask(uint stencil);
void GPU_unpack_row_length_set(uint len);
void GPU_clip_distances(int enabled_len);
+bool GPU_mipmap_enabled(void);
void GPU_flush(void);
void GPU_finish(void);
@@ -108,5 +108,3 @@ void gpuPopAttr(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_STATE_H__ */
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 0f159a3774f..7ee7f8fcdec 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -21,10 +21,10 @@
* \ingroup gpu
*/
-#ifndef __GPU_TEXTURE_H__
-#define __GPU_TEXTURE_H__
+#pragma once
#include "BLI_utildefines.h"
+
#include "GPU_state.h"
struct GPUVertBuf;
@@ -38,21 +38,11 @@ struct PreviewImage;
struct GPUFrameBuffer;
typedef struct GPUTexture GPUTexture;
-/* Used to get the correct gpu texture from an Image datablock. */
-typedef enum eGPUTextureTarget {
- TEXTARGET_2D = 0,
- TEXTARGET_CUBE_MAP,
- TEXTARGET_2D_ARRAY,
- TEXTARGET_TILE_MAPPING,
- TEXTARGET_COUNT,
-} eGPUTextureTarget;
-
/* GPU Samplers state
* - Specify the sampler state to bind a texture with.
* - Internally used by textures.
* - All states are created at startup to avoid runtime costs.
*/
-
typedef enum eGPUSamplerState {
GPU_SAMPLER_FILTER = (1 << 0),
GPU_SAMPLER_MIPMAP = (1 << 1),
@@ -66,6 +56,8 @@ typedef enum eGPUSamplerState {
GPU_SAMPLER_MAX = (1 << 8),
} eGPUSamplerState;
+ENUM_OPERATORS(eGPUSamplerState)
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -130,7 +122,6 @@ typedef enum eGPUTextureFormat {
#if 0
GPU_RGB10_A2,
GPU_RGB10_A2UI,
- GPU_SRGB8_A8,
#endif
GPU_R11F_G11F_B10F,
GPU_DEPTH32F_STENCIL8,
@@ -159,7 +150,13 @@ typedef enum eGPUTextureFormat {
GPU_R8_SNORM,
#endif
-/* Special formats texture only */
+ /* Special formats texture only */
+ GPU_SRGB8_A8_DXT1,
+ GPU_SRGB8_A8_DXT3,
+ GPU_SRGB8_A8_DXT5,
+ GPU_RGBA8_DXT1,
+ GPU_RGBA8_DXT3,
+ GPU_RGBA8_DXT5,
#if 0
GPU_SRGB8,
GPU_RGB9_E5,
@@ -232,17 +229,10 @@ GPUTexture *GPU_texture_create_cube_array(
GPUTexture *GPU_texture_create_from_vertbuf(struct GPUVertBuf *vert);
GPUTexture *GPU_texture_create_buffer(eGPUTextureFormat data_type, const uint buffer);
-GPUTexture *GPU_texture_from_bindcode(eGPUTextureTarget target, int bindcode);
-GPUTexture *GPU_texture_from_blender(struct Image *ima,
- struct ImageUser *iuser,
- struct ImBuf *ibuf,
- eGPUTextureTarget target);
+GPUTexture *GPU_texture_create_compressed(
+ int w, int h, int miplen, eGPUTextureFormat format, const void *data);
-/* movie clip drawing */
-GPUTexture *GPU_texture_from_movieclip(struct MovieClip *clip,
- struct MovieClipUser *cuser,
- eGPUTextureTarget target);
-void GPU_free_texture_movieclip(struct MovieClip *clip);
+GPUTexture *GPU_texture_create_error(int dimension, bool array);
void GPU_texture_add_mipmap(GPUTexture *tex,
eGPUDataFormat gpu_data_format,
@@ -278,6 +268,7 @@ void GPU_texture_unbind_all(void);
void GPU_texture_copy(GPUTexture *dst, GPUTexture *src);
void GPU_texture_generate_mipmap(GPUTexture *tex);
+void GPU_texture_anisotropic_filter(GPUTexture *tex, bool use_aniso);
void GPU_texture_compare_mode(GPUTexture *tex, bool use_compare);
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter);
void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter);
@@ -310,5 +301,3 @@ void GPU_sampler_icon_bind(int number);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_TEXTURE_H__ */
diff --git a/source/blender/gpu/GPU_uniformbuffer.h b/source/blender/gpu/GPU_uniformbuffer.h
index b221ae035d3..e2b2a757fb9 100644
--- a/source/blender/gpu/GPU_uniformbuffer.h
+++ b/source/blender/gpu/GPU_uniformbuffer.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_UNIFORMBUFFER_H__
-#define __GPU_UNIFORMBUFFER_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -42,8 +41,7 @@ void GPU_uniformbuffer_dynamic_update(GPUUniformBuffer *ubo_);
void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number);
void GPU_uniformbuffer_unbind(GPUUniformBuffer *ubo);
-
-int GPU_uniformbuffer_bindpoint(GPUUniformBuffer *ubo);
+void GPU_uniformbuffer_unbind_all(void);
bool GPU_uniformbuffer_is_empty(GPUUniformBuffer *ubo);
bool GPU_uniformbuffer_is_dirty(GPUUniformBuffer *ubo);
@@ -53,5 +51,3 @@ bool GPU_uniformbuffer_is_dirty(GPUUniformBuffer *ubo);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_UNIFORMBUFFER_H__ */
diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h
index f9bdf726930..757255496e0 100644
--- a/source/blender/gpu/GPU_vertex_buffer.h
+++ b/source/blender/gpu/GPU_vertex_buffer.h
@@ -23,8 +23,7 @@
* GPU vertex buffer
*/
-#ifndef __GPU_VERTEX_BUFFER_H__
-#define __GPU_VERTEX_BUFFER_H__
+#pragma once
#include "GPU_vertex_format.h"
@@ -59,10 +58,10 @@ typedef struct GPUVertBuf {
/** 0 indicates not yet allocated. */
uint32_t vbo_id;
/** Usage hint for GL optimisation. */
- uint usage : 2;
+ GPUUsageType usage;
/** Data has been touched and need to be reuploaded to GPU. */
- uint dirty : 1;
- unsigned char *data; /* NULL indicates data in VRAM (unmapped) */
+ bool dirty;
+ uchar *data; /* NULL indicates data in VRAM (unmapped) */
} GPUVertBuf;
GPUVertBuf *GPU_vertbuf_create(GPUUsageType);
@@ -147,5 +146,3 @@ uint GPU_vertbuf_get_memory_usage(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_VERTEX_BUFFER_H__ */
diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h
index 34bfbb27823..59af912ed3d 100644
--- a/source/blender/gpu/GPU_vertex_format.h
+++ b/source/blender/gpu/GPU_vertex_format.h
@@ -23,8 +23,7 @@
* GPU vertex format
*/
-#ifndef __GPU_VERTEX_FORMAT_H__
-#define __GPU_VERTEX_FORMAT_H__
+#pragma once
#include "BLI_assert.h"
#include "BLI_compiler_compat.h"
@@ -42,7 +41,7 @@ extern "C" {
#define GPU_MAX_SAFE_ATTR_NAME 12
typedef enum {
- GPU_COMP_I8,
+ GPU_COMP_I8 = 0,
GPU_COMP_U8,
GPU_COMP_I16,
GPU_COMP_U16,
@@ -52,17 +51,21 @@ typedef enum {
GPU_COMP_F32,
GPU_COMP_I10,
+ /* Warning! adjust GPUVertAttr if changing. */
} GPUVertCompType;
typedef enum {
- GPU_FETCH_FLOAT,
+ GPU_FETCH_FLOAT = 0,
GPU_FETCH_INT,
GPU_FETCH_INT_TO_FLOAT_UNIT, /* 127 (ubyte) -> 0.5 (and so on for other int types) */
GPU_FETCH_INT_TO_FLOAT, /* 127 (any int type) -> 127.0 */
+ /* Warning! adjust GPUVertAttr if changing. */
} GPUVertFetchMode;
typedef struct GPUVertAttr {
+ /* GPUVertFetchMode */
uint fetch_mode : 2;
+ /* GPUVertCompType */
uint comp_type : 3;
/* 1 to 4 or 8 or 12 or 16 */
uint comp_len : 5;
@@ -72,8 +75,6 @@ typedef struct GPUVertAttr {
uint offset : 11;
/* up to GPU_VERT_ATTR_MAX_NAMES */
uint name_len : 3;
- uint gl_comp_type;
- /* -- 8 Bytes -- */
uchar names[GPU_VERT_ATTR_MAX_NAMES];
} GPUVertAttr;
@@ -197,5 +198,3 @@ BLI_INLINE GPUPackedNormal GPU_normal_convert_i10_s3(const short data[3])
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_VERTEX_FORMAT_H__ */
diff --git a/source/blender/gpu/GPU_viewport.h b/source/blender/gpu/GPU_viewport.h
index 50d265feaad..60b78ecd59b 100644
--- a/source/blender/gpu/GPU_viewport.h
+++ b/source/blender/gpu/GPU_viewport.h
@@ -21,8 +21,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_VIEWPORT_H__
-#define __GPU_VIEWPORT_H__
+#pragma once
#include <stdbool.h>
@@ -41,6 +40,8 @@ extern "C" {
typedef struct GPUViewport GPUViewport;
+struct GPUFrameBuffer;
+
/* Contains memory pools information */
typedef struct ViewportMemoryPool {
struct BLI_memblock *commands;
@@ -151,8 +152,9 @@ GPUTexture *GPU_viewport_texture_pool_query(
bool GPU_viewport_engines_data_validate(GPUViewport *viewport, void **engine_handle_array);
void GPU_viewport_cache_release(GPUViewport *viewport);
+struct GPUFrameBuffer *GPU_viewport_framebuffer_default_get(GPUViewport *viewport);
+struct GPUFrameBuffer *GPU_viewport_framebuffer_overlay_get(GPUViewport *viewport);
+
#ifdef __cplusplus
}
#endif
-
-#endif // __GPU_VIEWPORT_H__
diff --git a/source/blender/gpu/intern/gpu_attr_binding_private.h b/source/blender/gpu/intern/gpu_attr_binding_private.h
index 7df403a3ea5..4d359343c38 100644
--- a/source/blender/gpu/intern/gpu_attr_binding_private.h
+++ b/source/blender/gpu/intern/gpu_attr_binding_private.h
@@ -23,8 +23,7 @@
* GPU vertex attribute binding
*/
-#ifndef __GPU_ATTR_BINDING_PRIVATE_H__
-#define __GPU_ATTR_BINDING_PRIVATE_H__
+#pragma once
#include "GPU_shader_interface.h"
#include "GPU_vertex_format.h"
@@ -44,5 +43,3 @@ uint read_attr_location(const GPUAttrBinding *binding, uint a_idx);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_ATTR_BINDING_PRIVATE_H__ */
diff --git a/source/blender/editors/include/ED_logic.h b/source/blender/gpu/intern/gpu_backend.hh
index ae2d5038321..24f592f214f 100644
--- a/source/blender/editors/include/ED_logic.h
+++ b/source/blender/gpu/intern/gpu_backend.hh
@@ -13,26 +13,25 @@
* 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.
+ * Copyright 2020, Blender Foundation.
* All rights reserved.
*/
/** \file
- * \ingroup editors
- */
+ * \ingroup gpu
+ *
+ * GPUBackend derived class contain allocators that do not need a context bound.
+ * The backend is init at startup and is accessible using GPU_backend_get() */
-#ifndef __ED_LOGIC_H__
-#define __ED_LOGIC_H__
+#pragma once
-#ifdef __cplusplus
-extern "C" {
-#endif
+struct GPUContext;
-/* logic_ops.c */
-void ED_operatortypes_logic(void);
+class GPUBackend {
+ public:
+ virtual ~GPUBackend(){};
-#ifdef __cplusplus
-}
-#endif
+ virtual GPUContext *context_alloc(void *ghost_window) = 0;
+};
-#endif /* __ED_LOGIC_H__ */
+GPUBackend *gpu_backend_get(void);
diff --git a/source/blender/gpu/intern/gpu_batch.cc b/source/blender/gpu/intern/gpu_batch.cc
index 43a8d000547..a6ba4d3d89a 100644
--- a/source/blender/gpu/intern/gpu_batch.cc
+++ b/source/blender/gpu/intern/gpu_batch.cc
@@ -34,9 +34,10 @@
#include "GPU_shader.h"
#include "gpu_batch_private.h"
-#include "gpu_context_private.h"
+#include "gpu_context_private.hh"
#include "gpu_primitive_private.h"
#include "gpu_shader_private.h"
+#include "gpu_vertex_format_private.h"
#include <limits.h>
#include <stdlib.h>
@@ -84,12 +85,17 @@ void GPU_batch_vao_cache_clear(GPUBatch *batch)
batch->context = NULL;
}
+GPUBatch *GPU_batch_calloc(uint count)
+{
+ return (GPUBatch *)MEM_callocN(sizeof(GPUBatch) * count, "GPUBatch");
+}
+
GPUBatch *GPU_batch_create_ex(GPUPrimType prim_type,
GPUVertBuf *verts,
GPUIndexBuf *elem,
uint owns_flag)
{
- GPUBatch *batch = (GPUBatch *)MEM_callocN(sizeof(GPUBatch), "GPUBatch");
+ GPUBatch *batch = GPU_batch_calloc(1);
GPU_batch_init_ex(batch, prim_type, verts, elem, owns_flag);
return batch;
}
@@ -370,22 +376,20 @@ static GLuint batch_vao_get(GPUBatch *batch)
return new_vao;
}
-void GPU_batch_program_set_no_use(GPUBatch *batch,
- uint32_t program,
- const GPUShaderInterface *shaderface)
+void GPU_batch_set_shader_no_bind(GPUBatch *batch, GPUShader *shader)
{
#if TRUST_NO_ONE
- assert(glIsProgram(program));
+ assert(glIsProgram(shader->program));
assert(batch->program_in_use == 0);
#endif
- batch->interface = shaderface;
- batch->program = program;
+ batch->interface = shader->interface;
+ batch->program = shader->program;
batch->vao_id = batch_vao_get(batch);
}
-void GPU_batch_program_set(GPUBatch *batch, uint32_t program, const GPUShaderInterface *shaderface)
+void GPU_batch_set_shader(GPUBatch *batch, GPUShader *shader)
{
- GPU_batch_program_set_no_use(batch, program, shaderface);
+ GPU_batch_set_shader_no_bind(batch, shader);
GPU_batch_program_use_begin(batch); /* hack! to make Batch_Uniform* simpler */
}
@@ -440,6 +444,7 @@ static void create_bindings(GPUVertBuf *verts,
}
const GLvoid *pointer = (const GLubyte *)0 + offset + v_first * stride;
+ const GLenum type = convert_comp_type_to_gl(static_cast<GPUVertCompType>(a->comp_type));
for (uint n_idx = 0; n_idx < a->name_len; n_idx++) {
const char *name = GPU_vertformat_attr_name_get(format, a, n_idx);
@@ -452,19 +457,13 @@ static void create_bindings(GPUVertBuf *verts,
*attr_mask &= ~(1 << input->location);
if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) {
-#if TRUST_NO_ONE
- assert(a->fetch_mode == GPU_FETCH_FLOAT);
- assert(a->gl_comp_type == GL_FLOAT);
-#endif
+ 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++) {
glEnableVertexAttribArray(input->location + i);
glVertexAttribDivisor(input->location + i, (use_instancing) ? 1 : 0);
- glVertexAttribPointer(input->location + i,
- 4,
- a->gl_comp_type,
- GL_FALSE,
- stride,
- (const GLubyte *)pointer + i * 16);
+ glVertexAttribPointer(
+ input->location + i, 4, type, GL_FALSE, stride, (const GLubyte *)pointer + i * 16);
}
}
else {
@@ -474,15 +473,13 @@ static void create_bindings(GPUVertBuf *verts,
switch (a->fetch_mode) {
case GPU_FETCH_FLOAT:
case GPU_FETCH_INT_TO_FLOAT:
- glVertexAttribPointer(
- input->location, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer);
+ glVertexAttribPointer(input->location, a->comp_len, type, GL_FALSE, stride, pointer);
break;
case GPU_FETCH_INT_TO_FLOAT_UNIT:
- glVertexAttribPointer(
- input->location, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer);
+ glVertexAttribPointer(input->location, a->comp_len, type, GL_TRUE, stride, pointer);
break;
case GPU_FETCH_INT:
- glVertexAttribIPointer(input->location, a->comp_len, a->gl_comp_type, stride, pointer);
+ glVertexAttribIPointer(input->location, a->comp_len, type, stride, pointer);
break;
}
}
@@ -989,17 +986,12 @@ void GPU_draw_list_submit(GPUDrawList *list)
/** \name Utilities
* \{ */
-void GPU_batch_program_set_shader(GPUBatch *batch, GPUShader *shader)
-{
- GPU_batch_program_set(batch, shader->program, shader->interface);
-}
-
void GPU_batch_program_set_builtin_with_config(GPUBatch *batch,
eGPUBuiltinShader shader_id,
eGPUShaderConfig sh_cfg)
{
GPUShader *shader = GPU_shader_get_builtin_shader_with_config(shader_id, sh_cfg);
- GPU_batch_program_set(batch, shader->program, shader->interface);
+ GPU_batch_set_shader(batch, shader);
}
void GPU_batch_program_set_builtin(GPUBatch *batch, eGPUBuiltinShader shader_id)
@@ -1012,10 +1004,7 @@ void GPU_batch_program_set_builtin(GPUBatch *batch, eGPUBuiltinShader shader_id)
* DO NOT DRAW WITH THE BATCH BEFORE CALLING immUnbindProgram. */
void GPU_batch_program_set_imm_shader(GPUBatch *batch)
{
- GLuint program;
- GPUShaderInterface *interface;
- immGetProgram(&program, &interface);
- GPU_batch_program_set(batch, program, interface);
+ GPU_batch_set_shader(batch, immGetShader());
}
/** \} */
@@ -1031,7 +1020,7 @@ void gpu_batch_init(void)
float default_attrib_data[4] = {0.0f, 0.0f, 0.0f, 1.0f};
glBindBuffer(GL_ARRAY_BUFFER, g_default_attr_vbo);
- glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4, default_attrib_data, GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(float[4]), default_attrib_data, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c
index d16edab5ac9..3d9b4326c7e 100644
--- a/source/blender/gpu/intern/gpu_batch_presets.c
+++ b/source/blender/gpu/intern/gpu_batch_presets.c
@@ -129,12 +129,11 @@ GPUBatch *GPU_batch_preset_sphere(int lod)
if (lod == 0) {
return g_presets_3d.batch.sphere_low;
}
- else if (lod == 1) {
+ if (lod == 1) {
return g_presets_3d.batch.sphere_med;
}
- else {
- return g_presets_3d.batch.sphere_high;
- }
+
+ return g_presets_3d.batch.sphere_high;
}
GPUBatch *GPU_batch_preset_sphere_wire(int lod)
@@ -145,9 +144,8 @@ GPUBatch *GPU_batch_preset_sphere_wire(int lod)
if (lod == 0) {
return g_presets_3d.batch.sphere_wire_low;
}
- else {
- return g_presets_3d.batch.sphere_wire_med;
- }
+
+ return g_presets_3d.batch.sphere_wire_med;
}
/** \} */
@@ -406,4 +404,17 @@ void gpu_batch_presets_exit(void)
BLI_mutex_end(&g_presets_3d.mutex);
}
+/**
+ * This function only needs to be accessed externally because
+ * we are drawing UI batches with the DRW old context.
+ *
+ * And now we use it for drawing the entire area.
+ *
+ * XXX (Clément) - to cleanup in the upcoming 2.91 refactor.
+ **/
+void GPU_batch_presets_reset()
+{
+ gpu_batch_presets_reset();
+}
+
/** \} */
diff --git a/source/blender/gpu/intern/gpu_batch_private.h b/source/blender/gpu/intern/gpu_batch_private.h
index 58d1810ac7a..93745b9ca9b 100644
--- a/source/blender/gpu/intern/gpu_batch_private.h
+++ b/source/blender/gpu/intern/gpu_batch_private.h
@@ -24,8 +24,7 @@
* Contains VAOs + VBOs + Shader representing a drawable entity.
*/
-#ifndef __GPU_BATCH_PRIVATE_H__
-#define __GPU_BATCH_PRIVATE_H__
+#pragma once
#include "GPU_batch.h"
#include "GPU_context.h"
@@ -40,5 +39,3 @@ void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *i
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_BATCH_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 10d5a860f6a..83d70b32b7b 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -337,7 +337,7 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
}
}
/* Face Sets. */
- memcpy(GPU_vertbuf_raw_step(&fset_step), face_set_color, sizeof(uchar) * 3);
+ memcpy(GPU_vertbuf_raw_step(&fset_step), face_set_color, sizeof(uchar[3]));
}
}
}
@@ -695,7 +695,7 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
}
if (show_vcol) {
- ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
+ const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, &vcol);
}
@@ -749,7 +749,7 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
empty_mask = empty_mask && (cmask == 0);
}
- ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
+ const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 0, &vcol);
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 1, &vcol);
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 2, &vcol);
@@ -832,12 +832,12 @@ static void gpu_bmesh_vert_to_buffer_copy(BMVert *v,
}
if (show_vcol) {
- ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
+ const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
GPU_vertbuf_attr_set(vert_buf, g_vbo_id.col, v_index, &vcol);
}
/* Add default face sets color to avoid artifacts. */
- uchar face_set[3] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
+ const uchar face_set[3] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
GPU_vertbuf_attr_set(vert_buf, g_vbo_id.fset, v_index, &face_set);
}
@@ -1083,9 +1083,8 @@ GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast, bool
if (wires) {
return (fast && buffers->lines_fast) ? buffers->lines_fast : buffers->lines;
}
- else {
- return (fast && buffers->triangles_fast) ? buffers->triangles_fast : buffers->triangles;
- }
+
+ return (fast && buffers->triangles_fast) ? buffers->triangles_fast : buffers->triangles;
}
bool GPU_pbvh_buffers_has_overlays(GPU_PBVH_Buffers *buffers)
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 65c9a27e1fe..b051d4fe59a 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -55,8 +55,8 @@
#include <stdarg.h>
#include <string.h>
+extern char datatoc_gpu_shader_codegen_lib_glsl[];
extern char datatoc_gpu_shader_common_obinfos_lib_glsl[];
-extern char datatoc_common_view_lib_glsl[];
/* -------------------- GPUPass Cache ------------------ */
/**
@@ -111,11 +111,11 @@ static GPUPass *gpu_pass_cache_resolve_collision(GPUPass *pass,
BLI_spin_lock(&pass_cache_spin);
/* Collision, need to strcmp the whole shader. */
for (; pass && (pass->hash == hash); pass = pass->next) {
- if ((defs != NULL) && (strcmp(pass->defines, defs) != 0)) { /* Pass */
+ if ((defs != NULL) && (!STREQ(pass->defines, defs))) { /* Pass */
}
- else if ((geom != NULL) && (strcmp(pass->geometrycode, geom) != 0)) { /* Pass */
+ else if ((geom != NULL) && (!STREQ(pass->geometrycode, geom))) { /* Pass */
}
- else if ((strcmp(pass->fragmentcode, frag) == 0) && (strcmp(pass->vertexcode, vert) == 0)) {
+ else if ((!STREQ(pass->fragmentcode, frag) == 0) && (STREQ(pass->vertexcode, vert))) {
BLI_spin_unlock(&pass_cache_spin);
return pass;
}
@@ -220,63 +220,61 @@ static const char *gpu_builtin_name(eGPUBuiltin builtin)
if (builtin == GPU_VIEW_MATRIX) {
return "unfviewmat";
}
- else if (builtin == GPU_OBJECT_MATRIX) {
+ if (builtin == GPU_OBJECT_MATRIX) {
return "unfobmat";
}
- else if (builtin == GPU_INVERSE_VIEW_MATRIX) {
+ if (builtin == GPU_INVERSE_VIEW_MATRIX) {
return "unfinvviewmat";
}
- else if (builtin == GPU_INVERSE_OBJECT_MATRIX) {
+ if (builtin == GPU_INVERSE_OBJECT_MATRIX) {
return "unfinvobmat";
}
- else if (builtin == GPU_LOC_TO_VIEW_MATRIX) {
+ if (builtin == GPU_LOC_TO_VIEW_MATRIX) {
return "unflocaltoviewmat";
}
- else if (builtin == GPU_INVERSE_LOC_TO_VIEW_MATRIX) {
+ if (builtin == GPU_INVERSE_LOC_TO_VIEW_MATRIX) {
return "unfinvlocaltoviewmat";
}
- else if (builtin == GPU_VIEW_POSITION) {
+ if (builtin == GPU_VIEW_POSITION) {
return "varposition";
}
- else if (builtin == GPU_WORLD_NORMAL) {
+ if (builtin == GPU_WORLD_NORMAL) {
return "varwnormal";
}
- else if (builtin == GPU_VIEW_NORMAL) {
+ if (builtin == GPU_VIEW_NORMAL) {
return "varnormal";
}
- else if (builtin == GPU_OBJECT_COLOR) {
+ if (builtin == GPU_OBJECT_COLOR) {
return "unfobjectcolor";
}
- else if (builtin == GPU_AUTO_BUMPSCALE) {
+ if (builtin == GPU_AUTO_BUMPSCALE) {
return "unfobautobumpscale";
}
- else if (builtin == GPU_CAMERA_TEXCO_FACTORS) {
+ if (builtin == GPU_CAMERA_TEXCO_FACTORS) {
return "unfcameratexfactors";
}
- else if (builtin == GPU_PARTICLE_SCALAR_PROPS) {
+ if (builtin == GPU_PARTICLE_SCALAR_PROPS) {
return "unfparticlescalarprops";
}
- else if (builtin == GPU_PARTICLE_LOCATION) {
+ if (builtin == GPU_PARTICLE_LOCATION) {
return "unfparticleco";
}
- else if (builtin == GPU_PARTICLE_VELOCITY) {
+ if (builtin == GPU_PARTICLE_VELOCITY) {
return "unfparticlevel";
}
- else if (builtin == GPU_PARTICLE_ANG_VELOCITY) {
+ if (builtin == GPU_PARTICLE_ANG_VELOCITY) {
return "unfparticleangvel";
}
- else if (builtin == GPU_OBJECT_INFO) {
+ if (builtin == GPU_OBJECT_INFO) {
return "unfobjectinfo";
}
- else if (builtin == GPU_BARYCENTRIC_TEXCO) {
+ if (builtin == GPU_BARYCENTRIC_TEXCO) {
return "unfbarycentrictex";
}
- else if (builtin == GPU_BARYCENTRIC_DIST) {
+ if (builtin == GPU_BARYCENTRIC_DIST) {
return "unfbarycentricdist";
}
- else {
- return "";
- }
+ return "";
}
static void codegen_set_unique_ids(GPUNodeGraph *graph)
@@ -307,11 +305,6 @@ static int codegen_process_uniforms_functions(GPUMaterial *material,
int builtins = 0;
ListBase ubo_inputs = {NULL, NULL};
- /* Attributes */
- LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
- BLI_dynstr_appendf(ds, "in %s var%d;\n", gpu_data_type_to_string(attr->gputype), attr->id);
- }
-
/* Textures */
LISTBASE_FOREACH (GPUMaterialTexture *, tex, &graph->textures) {
if (tex->colorband) {
@@ -378,7 +371,7 @@ static int codegen_process_uniforms_functions(GPUMaterial *material,
LISTBASE_FOREACH (LinkData *, link, &ubo_inputs) {
GPUInput *input = (GPUInput *)(link->data);
- BLI_dynstr_appendf(ds, "\t%s unf%d;\n", gpu_data_type_to_string(input->type), input->id);
+ BLI_dynstr_appendf(ds, " %s unf%d;\n", gpu_data_type_to_string(input->type), input->id);
}
BLI_dynstr_append(ds, "};\n");
BLI_freelistN(&ubo_inputs);
@@ -395,10 +388,10 @@ static void codegen_declare_tmps(DynStr *ds, GPUNodeGraph *graph)
/* declare temporary variables for node output storage */
LISTBASE_FOREACH (GPUOutput *, output, &node->outputs) {
if (output->type == GPU_CLOSURE) {
- BLI_dynstr_appendf(ds, "\tClosure tmp%d;\n", output->id);
+ BLI_dynstr_appendf(ds, " Closure tmp%d;\n", output->id);
}
else {
- BLI_dynstr_appendf(ds, "\t%s tmp%d;\n", gpu_data_type_to_string(output->type), output->id);
+ BLI_dynstr_appendf(ds, " %s tmp%d;\n", gpu_data_type_to_string(output->type), output->id);
}
}
}
@@ -408,7 +401,7 @@ static void codegen_declare_tmps(DynStr *ds, GPUNodeGraph *graph)
static void codegen_call_functions(DynStr *ds, GPUNodeGraph *graph, GPUOutput *finaloutput)
{
LISTBASE_FOREACH (GPUNode *, node, &graph->nodes) {
- BLI_dynstr_appendf(ds, "\t%s(", node->name);
+ BLI_dynstr_appendf(ds, " %s(", node->name);
LISTBASE_FOREACH (GPUInput *, input, &node->inputs) {
if (input->source == GPU_SOURCE_TEX) {
@@ -501,21 +494,24 @@ static void codegen_call_functions(DynStr *ds, GPUNodeGraph *graph, GPUOutput *f
BLI_dynstr_append(ds, ");\n");
}
- BLI_dynstr_appendf(ds, "\n\treturn tmp%d", finaloutput->id);
- BLI_dynstr_append(ds, ";\n");
+ BLI_dynstr_appendf(ds, "\n return tmp%d;\n", finaloutput->id);
}
-static char *code_generate_fragment(GPUMaterial *material, GPUNodeGraph *graph)
+static char *code_generate_fragment(GPUMaterial *material,
+ GPUNodeGraph *graph,
+ const char *interface_str)
{
DynStr *ds = BLI_dynstr_new();
char *code;
int builtins;
-#if 0
- BLI_dynstr_append(ds, FUNCTION_PROTOTYPES);
-#endif
-
codegen_set_unique_ids(graph);
+
+ /* Attributes, Shader stage interface. */
+ if (interface_str) {
+ BLI_dynstr_appendf(ds, "in codegenInterface {%s};\n\n", interface_str);
+ }
+
builtins = codegen_process_uniforms_functions(material, ds, graph);
if (builtins & (GPU_OBJECT_INFO | GPU_OBJECT_COLOR)) {
@@ -523,73 +519,61 @@ static char *code_generate_fragment(GPUMaterial *material, GPUNodeGraph *graph)
}
if (builtins & GPU_BARYCENTRIC_TEXCO) {
- BLI_dynstr_append(ds, "in vec2 barycentricTexCo;\n");
- }
-
- if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_append(ds, "flat in vec3 barycentricDist;\n");
+ BLI_dynstr_append(ds, datatoc_gpu_shader_codegen_lib_glsl);
}
BLI_dynstr_append(ds, "Closure nodetree_exec(void)\n{\n");
if (builtins & GPU_BARYCENTRIC_TEXCO) {
- BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
- BLI_dynstr_append(ds,
- "\tvec2 barytexco = vec2((fract(barycentricTexCo.y) != 0.0)\n"
- "\t ? barycentricTexCo.x\n"
- "\t : 1.0 - barycentricTexCo.x,\n"
- "\t 0.0);\n");
- BLI_dynstr_append(ds, "#else\n");
- BLI_dynstr_append(ds, "\tvec2 barytexco = barycentricTexCo;\n");
- BLI_dynstr_append(ds, "#endif\n");
+ BLI_dynstr_append(ds, " vec2 barytexco = barycentric_resolve(barycentricTexCo);\n");
}
/* TODO(fclem) get rid of that. */
if (builtins & GPU_VIEW_MATRIX) {
- BLI_dynstr_append(ds, "\t#define viewmat ViewMatrix\n");
+ BLI_dynstr_append(ds, " #define viewmat ViewMatrix\n");
}
if (builtins & GPU_CAMERA_TEXCO_FACTORS) {
- BLI_dynstr_append(ds, "\t#define camtexfac CameraTexCoFactors\n");
+ BLI_dynstr_append(ds, " #define camtexfac CameraTexCoFactors\n");
}
if (builtins & GPU_OBJECT_MATRIX) {
- BLI_dynstr_append(ds, "\t#define objmat ModelMatrix\n");
+ BLI_dynstr_append(ds, " #define objmat ModelMatrix\n");
}
if (builtins & GPU_INVERSE_OBJECT_MATRIX) {
- BLI_dynstr_append(ds, "\t#define objinv ModelMatrixInverse\n");
+ BLI_dynstr_append(ds, " #define objinv ModelMatrixInverse\n");
}
if (builtins & GPU_INVERSE_VIEW_MATRIX) {
- BLI_dynstr_append(ds, "\t#define viewinv ViewMatrixInverse\n");
+ BLI_dynstr_append(ds, " #define viewinv ViewMatrixInverse\n");
}
if (builtins & GPU_LOC_TO_VIEW_MATRIX) {
- BLI_dynstr_append(ds, "\t#define localtoviewmat (ViewMatrix * ModelMatrix)\n");
+ BLI_dynstr_append(ds, " #define localtoviewmat (ViewMatrix * ModelMatrix)\n");
}
if (builtins & GPU_INVERSE_LOC_TO_VIEW_MATRIX) {
BLI_dynstr_append(ds,
- "\t#define invlocaltoviewmat (ModelMatrixInverse * ViewMatrixInverse)\n");
+ " #define invlocaltoviewmat (ModelMatrixInverse * ViewMatrixInverse)\n");
}
if (builtins & GPU_VIEW_NORMAL) {
BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
- BLI_dynstr_append(ds, "\tvec3 n;\n");
- BLI_dynstr_append(ds, "\tworld_normals_get(n);\n");
- BLI_dynstr_append(ds, "\tvec3 facingnormal = transform_direction(ViewMatrix, n);\n");
+ BLI_dynstr_append(ds, " vec3 n;\n");
+ BLI_dynstr_append(ds, " world_normals_get(n);\n");
+ BLI_dynstr_append(ds, " vec3 facingnormal = transform_direction(ViewMatrix, n);\n");
BLI_dynstr_append(ds, "#else\n");
- BLI_dynstr_append(ds, "\tvec3 facingnormal = gl_FrontFacing ? viewNormal: -viewNormal;\n");
+ BLI_dynstr_append(ds, " vec3 facingnormal = gl_FrontFacing ? viewNormal: -viewNormal;\n");
BLI_dynstr_append(ds, "#endif\n");
}
if (builtins & GPU_WORLD_NORMAL) {
- BLI_dynstr_append(ds, "\tvec3 facingwnormal;\n");
+ BLI_dynstr_append(ds, " vec3 facingwnormal;\n");
if (builtins & GPU_VIEW_NORMAL) {
BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
- BLI_dynstr_append(ds, "\tfacingwnormal = n;\n");
+ BLI_dynstr_append(ds, " facingwnormal = n;\n");
BLI_dynstr_append(ds, "#else\n");
- BLI_dynstr_append(ds, "\tworld_normals_get(facingwnormal);\n");
+ BLI_dynstr_append(ds, " world_normals_get(facingwnormal);\n");
BLI_dynstr_append(ds, "#endif\n");
}
else {
- BLI_dynstr_append(ds, "\tworld_normals_get(facingwnormal);\n");
+ BLI_dynstr_append(ds, " world_normals_get(facingwnormal);\n");
}
}
if (builtins & GPU_VIEW_POSITION) {
- BLI_dynstr_append(ds, "\t#define viewposition viewPosition\n");
+ BLI_dynstr_append(ds, " #define viewposition viewPosition\n");
}
codegen_declare_tmps(ds, graph);
@@ -597,21 +581,6 @@ static char *code_generate_fragment(GPUMaterial *material, GPUNodeGraph *graph)
BLI_dynstr_append(ds, "}\n");
- /* XXX This cannot go into gpu_shader_material.glsl because main()
- * would be parsed and generate error */
- /* Old glsl mode compat. */
- /* TODO(fclem) This is only used by world shader now. get rid of it? */
- BLI_dynstr_append(ds, "#ifndef NODETREE_EXEC\n");
- BLI_dynstr_append(ds, "out vec4 fragColor;\n");
- BLI_dynstr_append(ds, "void main()\n");
- BLI_dynstr_append(ds, "{\n");
- BLI_dynstr_append(ds, "\tClosure cl = nodetree_exec();\n");
- BLI_dynstr_append(ds,
- "\tfragColor = vec4(cl.radiance, "
- "saturate(1.0 - avg(cl.transmittance)));\n");
- BLI_dynstr_append(ds, "}\n");
- BLI_dynstr_append(ds, "#endif\n\n");
-
/* create shader */
code = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
@@ -646,21 +615,48 @@ static const char *attr_prefix_get(CustomDataType type)
}
}
-static char *code_generate_vertex(GPUNodeGraph *graph, const char *vert_code, bool use_geom)
+/* We talk about shader stage interface, not to be mistaken with GPUShaderInterface. */
+static char *code_generate_interface(GPUNodeGraph *graph, int builtins)
{
+ if (BLI_listbase_is_empty(&graph->attributes) &&
+ (builtins & (GPU_BARYCENTRIC_DIST | GPU_BARYCENTRIC_TEXCO)) == 0) {
+ return NULL;
+ }
+
DynStr *ds = BLI_dynstr_new();
- char *code;
- int builtins = 0;
- /* Hairs uv and col attributes are passed by bufferTextures. */
- BLI_dynstr_append(ds,
- "#ifdef HAIR_SHADER\n"
- "#define DEFINE_ATTR(type, attr) uniform samplerBuffer attr\n"
- "#else\n"
- "#define DEFINE_ATTR(type, attr) in type attr\n"
- "#endif\n");
+ BLI_dynstr_append(ds, "\n");
+
+ LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
+ BLI_dynstr_appendf(ds, "%s var%d;\n", gpu_data_type_to_string(attr->gputype), attr->id);
+ }
+ if (builtins & GPU_BARYCENTRIC_TEXCO) {
+ BLI_dynstr_append(ds, "vec2 barycentricTexCo;\n");
+ }
+ if (builtins & GPU_BARYCENTRIC_DIST) {
+ BLI_dynstr_append(ds, "vec3 barycentricDist;\n");
+ }
+
+ char *code = BLI_dynstr_get_cstring(ds);
+
+ BLI_dynstr_free(ds);
+
+ return code;
+}
+
+static char *code_generate_vertex(GPUNodeGraph *graph,
+ const char *interface_str,
+ const char *vert_code,
+ int builtins)
+{
+ DynStr *ds = BLI_dynstr_new();
+ BLI_dynstr_append(ds, datatoc_gpu_shader_codegen_lib_glsl);
+
+ /* Inputs */
LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
+ const char *type_str = gpu_data_type_to_string(attr->gputype);
+ const char *prefix = attr_prefix_get(attr->type);
/* XXX FIXME : see notes in mesh_render_data_create() */
/* NOTE : Replicate changes to mesh_render_data_create() in draw_cache_impl_mesh.c */
if (attr->type == CD_ORCO) {
@@ -669,188 +665,58 @@ static char *code_generate_vertex(GPUNodeGraph *graph, const char *vert_code, bo
BLI_dynstr_append(ds, "DEFINE_ATTR(vec4, orco);\n");
}
else if (attr->name[0] == '\0') {
- BLI_dynstr_appendf(ds,
- "DEFINE_ATTR(%s, %s);\n",
- gpu_data_type_to_string(attr->gputype),
- attr_prefix_get(attr->type));
- BLI_dynstr_appendf(ds, "#define att%d %s\n", attr->id, attr_prefix_get(attr->type));
+ BLI_dynstr_appendf(ds, "DEFINE_ATTR(%s, %s);\n", type_str, prefix);
+ BLI_dynstr_appendf(ds, "#define att%d %s\n", attr->id, prefix);
}
else {
char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
GPU_vertformat_safe_attr_name(attr->name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
- BLI_dynstr_appendf(ds,
- "DEFINE_ATTR(%s, %s%s);\n",
- gpu_data_type_to_string(attr->gputype),
- attr_prefix_get(attr->type),
- attr_safe_name);
- BLI_dynstr_appendf(
- ds, "#define att%d %s%s\n", attr->id, attr_prefix_get(attr->type), attr_safe_name);
+ BLI_dynstr_appendf(ds, "DEFINE_ATTR(%s, %s%s);\n", type_str, prefix, attr_safe_name);
+ BLI_dynstr_appendf(ds, "#define att%d %s%s\n", attr->id, prefix, attr_safe_name);
}
- BLI_dynstr_appendf(ds,
- "out %s var%d%s;\n",
- gpu_data_type_to_string(attr->gputype),
- attr->id,
- use_geom ? "g" : "");
}
- LISTBASE_FOREACH (GPUNode *, node, &graph->nodes) {
- LISTBASE_FOREACH (GPUInput *, input, &node->inputs) {
- if (input->source == GPU_SOURCE_BUILTIN) {
- builtins |= input->builtin;
- }
- }
- }
-
- if (builtins & GPU_BARYCENTRIC_TEXCO) {
- BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
- BLI_dynstr_appendf(ds, "out vec2 barycentricTexCo%s;\n", use_geom ? "g" : "");
- BLI_dynstr_append(ds, "#endif\n");
- }
-
- if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_append(ds, "out vec3 barycentricPosg;\n");
+ /* Outputs interface */
+ if (interface_str) {
+ BLI_dynstr_appendf(ds, "out codegenInterface {%s};\n\n", interface_str);
}
- BLI_dynstr_append(ds, "\n#define USE_ATTR\n");
-
- /* Prototype, defined later (this is because of matrices definition). */
- BLI_dynstr_append(ds, "void pass_attr(in vec3 position);\n");
-
- BLI_dynstr_append(ds, "\n");
-
- if (use_geom) {
- /* XXX HACK: Eevee specific. */
- char *vert_new, *vert_new2;
- vert_new = BLI_str_replaceN(vert_code, "worldPosition", "worldPositiong");
- vert_new2 = vert_new;
- vert_new = BLI_str_replaceN(vert_new2, "viewPosition", "viewPositiong");
- MEM_freeN(vert_new2);
- vert_new2 = vert_new;
- vert_new = BLI_str_replaceN(vert_new2, "worldNormal", "worldNormalg");
- MEM_freeN(vert_new2);
- vert_new2 = vert_new;
- vert_new = BLI_str_replaceN(vert_new2, "viewNormal", "viewNormalg");
- MEM_freeN(vert_new2);
-
- BLI_dynstr_append(ds, vert_new);
-
- MEM_freeN(vert_new);
- }
- else {
- BLI_dynstr_append(ds, vert_code);
- }
+ /* Prototype. Needed for hair functions. */
+ BLI_dynstr_append(ds, "void pass_attr(vec3 position, mat3 normalmat, mat4 modelmatinv);\n");
+ BLI_dynstr_append(ds, "#define USE_ATTR\n\n");
+ BLI_dynstr_append(ds, vert_code);
BLI_dynstr_append(ds, "\n");
- BLI_dynstr_append(ds, use_geom ? "RESOURCE_ID_VARYING_GEOM\n" : "RESOURCE_ID_VARYING\n");
-
- /* Prototype because defined later. */
- BLI_dynstr_append(ds,
- "vec2 hair_get_customdata_vec2(const samplerBuffer);\n"
- "vec3 hair_get_customdata_vec3(const samplerBuffer);\n"
- "vec4 hair_get_customdata_vec4(const samplerBuffer);\n"
- "vec3 hair_get_strand_pos(void);\n"
- "int hair_get_base_id(void);\n"
- "\n");
-
- BLI_dynstr_append(ds, "void pass_attr(in vec3 position) {\n");
-
- BLI_dynstr_append(ds, use_geom ? "\tPASS_RESOURCE_ID_GEOM\n" : "\tPASS_RESOURCE_ID\n");
-
- BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
-
- if (builtins & GPU_BARYCENTRIC_TEXCO) {
- /* To match cycles without breaking into individual segment we encode if we need to invert
- * the first component into the second component. We invert if the barycentricTexCo.y
- * is NOT 0.0 or 1.0. */
- BLI_dynstr_append(ds, "\tint _base_id = hair_get_base_id();\n");
- BLI_dynstr_appendf(
- ds, "\tbarycentricTexCo%s.x = float((_base_id %% 2) == 1);\n", use_geom ? "g" : "");
- BLI_dynstr_appendf(
- ds, "\tbarycentricTexCo%s.y = float(((_base_id %% 4) %% 3) > 0);\n", use_geom ? "g" : "");
- }
-
- if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_append(ds, "\tbarycentricPosg = position;\n");
- }
-
- LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
- if (attr->type == CD_TANGENT) {
- /* Not supported by hairs */
- BLI_dynstr_appendf(ds, "\tvar%d%s = vec4(0.0);\n", attr->id, use_geom ? "g" : "");
- }
- else if (attr->type == CD_ORCO) {
- BLI_dynstr_appendf(ds,
- "\tvar%d%s = OrcoTexCoFactors[0].xyz + (ModelMatrixInverse * "
- "vec4(hair_get_strand_pos(), 1.0)).xyz * OrcoTexCoFactors[1].xyz;\n",
- attr->id,
- use_geom ? "g" : "");
- /* TODO: fix ORCO with modifiers. */
- }
- else {
- BLI_dynstr_appendf(ds,
- "\tvar%d%s = hair_get_customdata_%s(att%d);\n",
- attr->id,
- use_geom ? "g" : "",
- gpu_data_type_to_string(attr->gputype),
- attr->id);
- }
- }
-
- BLI_dynstr_append(ds, "#else /* MESH_SHADER */\n");
+ BLI_dynstr_append(ds, "void pass_attr(vec3 position, mat3 normalmat, mat4 modelmatinv) {\n");
/* GPU_BARYCENTRIC_TEXCO cannot be computed based on gl_VertexID
* for MESH_SHADER because of indexed drawing. In this case a
* geometry shader is needed. */
-
+ if (builtins & GPU_BARYCENTRIC_TEXCO) {
+ BLI_dynstr_appendf(ds, " barycentricTexCo = barycentric_get();\n");
+ }
if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_append(ds, "\tbarycentricPosg = (ModelMatrix * vec4(position, 1.0)).xyz;\n");
+ BLI_dynstr_appendf(ds, " barycentricDist = vec3(0);\n");
}
LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
if (attr->type == CD_TANGENT) { /* silly exception */
- BLI_dynstr_appendf(ds,
- "\tvar%d%s.xyz = transpose(mat3(ModelMatrixInverse)) * att%d.xyz;\n",
- attr->id,
- use_geom ? "g" : "",
- attr->id);
- BLI_dynstr_appendf(ds, "\tvar%d%s.w = att%d.w;\n", attr->id, use_geom ? "g" : "", attr->id);
- /* Normalize only if vector is not null. */
- BLI_dynstr_appendf(ds,
- "\tfloat lvar%d = dot(var%d%s.xyz, var%d%s.xyz);\n",
- attr->id,
- attr->id,
- use_geom ? "g" : "",
- attr->id,
- use_geom ? "g" : "");
- BLI_dynstr_appendf(ds,
- "\tvar%d%s.xyz *= (lvar%d > 0.0) ? inversesqrt(lvar%d) : 1.0;\n",
- attr->id,
- use_geom ? "g" : "",
- attr->id,
- attr->id);
+ BLI_dynstr_appendf(ds, " var%d = tangent_get(att%d, normalmat);\n", attr->id, attr->id);
}
else if (attr->type == CD_ORCO) {
- BLI_dynstr_appendf(ds,
- "\tvar%d%s = OrcoTexCoFactors[0].xyz + position *"
- " OrcoTexCoFactors[1].xyz;\n",
- attr->id,
- use_geom ? "g" : "");
- /* See mesh_create_loop_orco() for explanation. */
- BLI_dynstr_appendf(ds,
- "\tif (orco.w == 0.0) { var%d%s = orco.xyz * 0.5 + 0.5; }\n",
- attr->id,
- use_geom ? "g" : "");
+ BLI_dynstr_appendf(
+ ds, " var%d = orco_get(position, modelmatinv, OrcoTexCoFactors, orco);\n", attr->id);
}
else {
- BLI_dynstr_appendf(ds, "\tvar%d%s = att%d;\n", attr->id, use_geom ? "g" : "", attr->id);
+ const char *type_str = gpu_data_type_to_string(attr->gputype);
+ BLI_dynstr_appendf(ds, " var%d = GET_ATTR(%s, att%d);\n", attr->id, type_str, attr->id);
}
}
- BLI_dynstr_append(ds, "#endif /* HAIR_SHADER */\n");
BLI_dynstr_append(ds, "}\n");
- code = BLI_dynstr_get_cstring(ds);
+ char *code = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
@@ -864,144 +730,46 @@ static char *code_generate_vertex(GPUNodeGraph *graph, const char *vert_code, bo
}
static char *code_generate_geometry(GPUNodeGraph *graph,
+ const char *interface_str,
const char *geom_code,
- const char *defines)
+ int builtins)
{
- DynStr *ds = BLI_dynstr_new();
- char *code;
- int builtins = 0;
-
- /* XXX we should not make specific eevee cases here. */
- bool is_hair_shader = (strstr(defines, "HAIR_SHADER") != NULL);
-
- /* Create prototype because attributes cannot be declared before layout. */
- BLI_dynstr_append(ds, "void pass_attr(in int vert);\n");
- BLI_dynstr_append(ds, "void calc_barycentric_distances(vec3 pos0, vec3 pos1, vec3 pos2);\n");
- BLI_dynstr_append(ds, "#define USE_ATTR\n");
-
- LISTBASE_FOREACH (GPUNode *, node, &graph->nodes) {
- LISTBASE_FOREACH (GPUInput *, input, &node->inputs) {
- if (input->source == GPU_SOURCE_BUILTIN) {
- builtins |= input->builtin;
- }
- }
+ if (!geom_code) {
+ return NULL;
}
- /* Generate varying declarations. */
- LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
- BLI_dynstr_appendf(ds, "in %s var%dg[];\n", gpu_data_type_to_string(attr->gputype), attr->id);
- BLI_dynstr_appendf(ds, "out %s var%d;\n", gpu_data_type_to_string(attr->gputype), attr->id);
- }
-
- if (builtins & GPU_BARYCENTRIC_TEXCO) {
- BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
- BLI_dynstr_append(ds, "in vec2 barycentricTexCog[];\n");
- BLI_dynstr_append(ds, "#endif\n");
-
- BLI_dynstr_append(ds, "out vec2 barycentricTexCo;\n");
- }
+ DynStr *ds = BLI_dynstr_new();
- if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_append(ds, "in vec3 barycentricPosg[];\n");
- BLI_dynstr_append(ds, "flat out vec3 barycentricDist;\n");
+ /* Attributes, Shader interface; */
+ if (interface_str) {
+ BLI_dynstr_appendf(ds, "in codegenInterface {%s} dataAttrIn[];\n\n", interface_str);
+ BLI_dynstr_appendf(ds, "out codegenInterface {%s} dataAttrOut;\n\n", interface_str);
}
- if (geom_code == NULL) {
- /* Force geometry usage if GPU_BARYCENTRIC_DIST or GPU_BARYCENTRIC_TEXCO are used.
- * Note: GPU_BARYCENTRIC_TEXCO only requires it if the shader is not drawing hairs. */
- if ((builtins & (GPU_BARYCENTRIC_DIST | GPU_BARYCENTRIC_TEXCO)) == 0 || is_hair_shader) {
- /* Early out */
- BLI_dynstr_free(ds);
- return NULL;
- }
- else {
- /* Force geom shader usage */
- /* TODO put in external file. */
- BLI_dynstr_append(ds, "layout(triangles) in;\n");
- BLI_dynstr_append(ds, "layout(triangle_strip, max_vertices=3) out;\n");
-
- BLI_dynstr_append(ds, "in vec3 worldPositiong[];\n");
- BLI_dynstr_append(ds, "in vec3 viewPositiong[];\n");
- BLI_dynstr_append(ds, "in vec3 worldNormalg[];\n");
- BLI_dynstr_append(ds, "in vec3 viewNormalg[];\n");
-
- BLI_dynstr_append(ds, "out vec3 worldPosition;\n");
- BLI_dynstr_append(ds, "out vec3 viewPosition;\n");
- BLI_dynstr_append(ds, "out vec3 worldNormal;\n");
- BLI_dynstr_append(ds, "out vec3 viewNormal;\n");
-
- BLI_dynstr_append(ds, datatoc_common_view_lib_glsl);
-
- BLI_dynstr_append(ds, "void main(){\n");
-
- if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_append(ds,
- "\tcalc_barycentric_distances(barycentricPosg[0], barycentricPosg[1], "
- "barycentricPosg[2]);\n");
- }
-
- for (int i = 0; i < 3; i++) {
- BLI_dynstr_appendf(ds, "\tgl_Position = gl_in[%d].gl_Position;\n", i);
- BLI_dynstr_appendf(ds, "\tgl_ClipDistance[0] = gl_in[%d].gl_ClipDistance[0];\n", i);
- BLI_dynstr_appendf(ds, "\tpass_attr(%d);\n", i);
- BLI_dynstr_append(ds, "\tEmitVertex();\n");
- }
- BLI_dynstr_append(ds, "}\n");
- }
- }
- else {
- BLI_dynstr_append(ds, geom_code);
- }
+ BLI_dynstr_append(ds, datatoc_gpu_shader_codegen_lib_glsl);
if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_append(ds, "void calc_barycentric_distances(vec3 pos0, vec3 pos1, vec3 pos2) {\n");
- BLI_dynstr_append(ds, "\tvec3 edge21 = pos2 - pos1;\n");
- BLI_dynstr_append(ds, "\tvec3 edge10 = pos1 - pos0;\n");
- BLI_dynstr_append(ds, "\tvec3 edge02 = pos0 - pos2;\n");
- BLI_dynstr_append(ds, "\tvec3 d21 = normalize(edge21);\n");
- BLI_dynstr_append(ds, "\tvec3 d10 = normalize(edge10);\n");
- BLI_dynstr_append(ds, "\tvec3 d02 = normalize(edge02);\n");
-
- BLI_dynstr_append(ds, "\tfloat d = dot(d21, edge02);\n");
- BLI_dynstr_append(ds, "\tbarycentricDist.x = sqrt(dot(edge02, edge02) - d * d);\n");
- BLI_dynstr_append(ds, "\td = dot(d02, edge10);\n");
- BLI_dynstr_append(ds, "\tbarycentricDist.y = sqrt(dot(edge10, edge10) - d * d);\n");
- BLI_dynstr_append(ds, "\td = dot(d10, edge21);\n");
- BLI_dynstr_append(ds, "\tbarycentricDist.z = sqrt(dot(edge21, edge21) - d * d);\n");
- BLI_dynstr_append(ds, "}\n");
+ /* geom_code should do something with this, but may not. */
+ BLI_dynstr_append(ds, "#define DO_BARYCENTRIC_DISTANCES\n");
}
- BLI_dynstr_append(ds, "RESOURCE_ID_VARYING\n");
-
/* Generate varying assignments. */
- BLI_dynstr_append(ds, "void pass_attr(in int vert) {\n");
-
- BLI_dynstr_append(ds, "\tPASS_RESOURCE_ID(vert)\n");
-
- /* XXX HACK: Eevee specific. */
- if (geom_code == NULL) {
- BLI_dynstr_append(ds, "\tworldPosition = worldPositiong[vert];\n");
- BLI_dynstr_append(ds, "\tviewPosition = viewPositiong[vert];\n");
- BLI_dynstr_append(ds, "\tworldNormal = worldNormalg[vert];\n");
- BLI_dynstr_append(ds, "\tviewNormal = viewNormalg[vert];\n");
- }
+ BLI_dynstr_append(ds, "#define USE_ATTR\n");
+ BLI_dynstr_append(ds, "void pass_attr(const int vert) {\n");
if (builtins & GPU_BARYCENTRIC_TEXCO) {
- BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
- BLI_dynstr_append(ds, "\tbarycentricTexCo = barycentricTexCog[vert];\n");
- BLI_dynstr_append(ds, "#else\n");
- BLI_dynstr_append(ds, "\tbarycentricTexCo.x = float((vert % 3) == 0);\n");
- BLI_dynstr_append(ds, "\tbarycentricTexCo.y = float((vert % 3) == 1);\n");
- BLI_dynstr_append(ds, "#endif\n");
+ BLI_dynstr_append(ds, " dataAttrOut.barycentricTexCo = calc_barycentric_co(vert);\n");
}
LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
/* TODO let shader choose what to do depending on what the attribute is. */
- BLI_dynstr_appendf(ds, "\tvar%d = var%dg[vert];\n", attr->id, attr->id);
+ BLI_dynstr_appendf(ds, " dataAttrOut.var%d = dataAttrIn[vert].var%d;\n", attr->id, attr->id);
}
- BLI_dynstr_append(ds, "}\n");
+ BLI_dynstr_append(ds, "}\n\n");
- code = BLI_dynstr_get_cstring(ds);
+ BLI_dynstr_append(ds, geom_code);
+
+ char *code = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return code;
@@ -1031,8 +799,17 @@ GPUPass *GPU_generate_pass(GPUMaterial *material,
* generated VBOs are ready to accept the future shader. */
gpu_node_graph_prune_unused(graph);
+ int builtins = 0;
+ LISTBASE_FOREACH (GPUNode *, node, &graph->nodes) {
+ LISTBASE_FOREACH (GPUInput *, input, &node->inputs) {
+ if (input->source == GPU_SOURCE_BUILTIN) {
+ builtins |= input->builtin;
+ }
+ }
+ }
/* generate code */
- char *fragmentgen = code_generate_fragment(material, graph);
+ char *interface_str = code_generate_interface(graph, builtins);
+ char *fragmentgen = code_generate_fragment(material, graph, interface_str);
/* Cache lookup: Reuse shaders already compiled */
uint32_t hash = gpu_pass_hash(fragmentgen, defines, &graph->attributes);
@@ -1040,6 +817,7 @@ GPUPass *GPU_generate_pass(GPUMaterial *material,
if (pass_hash && (pass_hash->next == NULL || pass_hash->next->hash != hash)) {
/* No collision, just return the pass. */
+ MEM_SAFE_FREE(interface_str);
MEM_freeN(fragmentgen);
if (!gpu_pass_is_valid(pass_hash)) {
/* Shader has already been created but failed to compile. */
@@ -1054,10 +832,11 @@ GPUPass *GPU_generate_pass(GPUMaterial *material,
GSet *used_libraries = gpu_material_used_libraries(material);
char *tmp = gpu_material_library_generate_code(used_libraries, frag_lib);
- char *geometrycode = code_generate_geometry(graph, geom_code, defines);
- char *vertexcode = code_generate_vertex(graph, vert_code, (geometrycode != NULL));
+ char *geometrycode = code_generate_geometry(graph, interface_str, geom_code, builtins);
+ char *vertexcode = code_generate_vertex(graph, interface_str, vert_code, builtins);
char *fragmentcode = BLI_strdupcat(tmp, fragmentgen);
+ MEM_SAFE_FREE(interface_str);
MEM_freeN(fragmentgen);
MEM_freeN(tmp);
@@ -1211,21 +990,9 @@ bool GPU_pass_compile(GPUPass *pass, const char *shname)
shader = NULL;
}
}
- else if (!BLI_thread_is_main() && GPU_context_local_shaders_workaround()) {
- pass->binary.content = GPU_shader_get_binary(
- shader, &pass->binary.format, &pass->binary.len);
- GPU_shader_free(shader);
- shader = NULL;
- }
-
pass->shader = shader;
pass->compiled = true;
}
- else if (pass->binary.content && BLI_thread_is_main()) {
- pass->shader = GPU_shader_load_from_binary(
- pass->binary.content, pass->binary.format, pass->binary.len, shname);
- MEM_SAFE_FREE(pass->binary.content);
- }
return success;
}
@@ -1246,9 +1013,6 @@ static void gpu_pass_free(GPUPass *pass)
MEM_SAFE_FREE(pass->geometrycode);
MEM_SAFE_FREE(pass->vertexcode);
MEM_SAFE_FREE(pass->defines);
- if (pass->binary.content) {
- MEM_freeN(pass->binary.content);
- }
MEM_freeN(pass);
}
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index 18ff4c3241d..5d130d75d2c 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -23,8 +23,7 @@
* Generate shader code from the intermediate node graph.
*/
-#ifndef __GPU_CODEGEN_H__
-#define __GPU_CODEGEN_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -47,11 +46,6 @@ typedef struct GPUPass {
char *defines;
uint refcount; /* Orphaned GPUPasses gets freed by the garbage collector. */
uint32_t hash; /* Identity hash generated from all GLSL code. */
- struct {
- char *content;
- uint format;
- int len;
- } binary;
bool compiled; /* Did we already tried to compile the attached GPUShader. */
} GPUPass;
@@ -75,5 +69,3 @@ void gpu_codegen_exit(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_CODEGEN_H__ */
diff --git a/source/blender/gpu/intern/gpu_context.cc b/source/blender/gpu/intern/gpu_context.cc
index 0b9104e5349..283784aec20 100644
--- a/source/blender/gpu/intern/gpu_context.cc
+++ b/source/blender/gpu/intern/gpu_context.cc
@@ -28,122 +28,68 @@
* - free can be called from any thread
*/
+/* TODO Create cmake option. */
+#define WITH_OPENGL_BACKEND 1
+
#include "BLI_assert.h"
#include "BLI_utildefines.h"
#include "GPU_context.h"
#include "GPU_framebuffer.h"
+#include "GHOST_C-api.h"
+
+#include "gpu_backend.hh"
#include "gpu_batch_private.h"
-#include "gpu_context_private.h"
+#include "gpu_context_private.hh"
#include "gpu_matrix_private.h"
-#include <mutex>
-#include <pthread.h>
-#include <string.h>
-#include <unordered_set>
-#include <vector>
-
-#if TRUST_NO_ONE
-# if 0
-extern "C" {
-extern int BLI_thread_is_main(void); /* Blender-specific function */
-}
-
-static bool thread_is_main()
-{
- /* "main" here means the GL context's thread */
- return BLI_thread_is_main();
-}
-# endif
+#ifdef WITH_OPENGL_BACKEND
+# include "gl_backend.hh"
+# include "gl_context.hh"
#endif
-static std::vector<GLuint> orphaned_buffer_ids;
-static std::vector<GLuint> orphaned_texture_ids;
-
-static std::mutex orphans_mutex;
-
-struct GPUContext {
- GLuint default_vao;
- GLuint default_framebuffer;
- GPUFrameBuffer *current_fbo;
- std::unordered_set<GPUBatch *> batches; /* Batches that have VAOs from this context */
-#ifdef DEBUG
- std::unordered_set<GPUFrameBuffer *>
- framebuffers; /* Framebuffers that have FBO from this context */
-#endif
- struct GPUMatrixState *matrix_state;
- std::vector<GLuint> orphaned_vertarray_ids;
- std::vector<GLuint> orphaned_framebuffer_ids;
- std::mutex orphans_mutex; /* todo: try spinlock instead */
-#if TRUST_NO_ONE
- pthread_t thread; /* Thread on which this context is active. */
- bool thread_is_used;
-#endif
+#include <mutex>
+#include <vector>
- GPUContext()
- {
-#if TRUST_NO_ONE
- thread_is_used = false;
-#endif
- current_fbo = 0;
- }
-};
+using namespace blender::gpu;
static thread_local GPUContext *active_ctx = NULL;
-static void orphans_add(GPUContext *ctx, std::vector<GLuint> *orphan_list, GLuint id)
-{
- std::mutex *mutex = (ctx) ? &ctx->orphans_mutex : &orphans_mutex;
+/* -------------------------------------------------------------------- */
+/** \name GPUContext methods
+ * \{ */
- mutex->lock();
- orphan_list->emplace_back(id);
- mutex->unlock();
+GPUContext::GPUContext()
+{
+ thread_ = pthread_self();
+ is_active_ = false;
+ matrix_state = GPU_matrix_state_create();
}
-static void orphans_clear(GPUContext *ctx)
+GPUContext::~GPUContext()
{
- /* need at least an active context */
- BLI_assert(ctx);
+ GPU_matrix_state_discard(matrix_state);
+}
- /* context has been activated by another thread! */
- BLI_assert(pthread_equal(pthread_self(), ctx->thread));
+bool GPUContext::is_active_on_thread(void)
+{
+ return (this == active_ctx) && pthread_equal(pthread_self(), thread_);
+}
- ctx->orphans_mutex.lock();
- if (!ctx->orphaned_vertarray_ids.empty()) {
- uint orphan_len = (uint)ctx->orphaned_vertarray_ids.size();
- glDeleteVertexArrays(orphan_len, ctx->orphaned_vertarray_ids.data());
- ctx->orphaned_vertarray_ids.clear();
- }
- if (!ctx->orphaned_framebuffer_ids.empty()) {
- uint orphan_len = (uint)ctx->orphaned_framebuffer_ids.size();
- glDeleteFramebuffers(orphan_len, ctx->orphaned_framebuffer_ids.data());
- ctx->orphaned_framebuffer_ids.clear();
- }
+/** \} */
- ctx->orphans_mutex.unlock();
+/* -------------------------------------------------------------------- */
- orphans_mutex.lock();
- if (!orphaned_buffer_ids.empty()) {
- uint orphan_len = (uint)orphaned_buffer_ids.size();
- glDeleteBuffers(orphan_len, orphaned_buffer_ids.data());
- orphaned_buffer_ids.clear();
- }
- if (!orphaned_texture_ids.empty()) {
- uint orphan_len = (uint)orphaned_texture_ids.size();
- glDeleteTextures(orphan_len, orphaned_texture_ids.data());
- orphaned_texture_ids.clear();
+GPUContext *GPU_context_create(void *ghost_window)
+{
+ if (gpu_backend_get() == NULL) {
+ /* TODO move where it make sense. */
+ GPU_backend_init(GPU_BACKEND_OPENGL);
}
- orphans_mutex.unlock();
-}
-GPUContext *GPU_context_create(GLuint default_framebuffer)
-{
- /* BLI_assert(thread_is_main()); */
- GPUContext *ctx = new GPUContext;
- glGenVertexArrays(1, &ctx->default_vao);
- ctx->default_framebuffer = default_framebuffer;
- ctx->matrix_state = GPU_matrix_state_create();
+ GPUContext *ctx = gpu_backend_get()->context_alloc(ghost_window);
+
GPU_context_active_set(ctx);
return ctx;
}
@@ -151,21 +97,6 @@ GPUContext *GPU_context_create(GLuint default_framebuffer)
/* to be called after GPU_context_active_set(ctx_to_destroy) */
void GPU_context_discard(GPUContext *ctx)
{
- /* Make sure no other thread has locked it. */
- BLI_assert(ctx == active_ctx);
- BLI_assert(pthread_equal(pthread_self(), ctx->thread));
- BLI_assert(ctx->orphaned_vertarray_ids.empty());
-#ifdef DEBUG
- /* For now don't allow GPUFrameBuffers to be reuse in another ctx. */
- BLI_assert(ctx->framebuffers.empty());
-#endif
- /* delete remaining vaos */
- while (!ctx->batches.empty()) {
- /* this removes the array entry */
- GPU_batch_vao_cache_clear(*ctx->batches.begin());
- }
- GPU_matrix_state_discard(ctx->matrix_state);
- glDeleteVertexArrays(1, &ctx->default_vao);
delete ctx;
active_ctx = NULL;
}
@@ -173,22 +104,15 @@ void GPU_context_discard(GPUContext *ctx)
/* ctx can be NULL */
void GPU_context_active_set(GPUContext *ctx)
{
-#if TRUST_NO_ONE
if (active_ctx) {
- active_ctx->thread_is_used = false;
+ active_ctx->deactivate();
}
- /* Make sure no other context is already bound to this thread. */
- if (ctx) {
- /* Make sure no other thread has locked it. */
- assert(ctx->thread_is_used == false);
- ctx->thread = pthread_self();
- ctx->thread_is_used = true;
- }
-#endif
+
+ active_ctx = ctx;
+
if (ctx) {
- orphans_clear(ctx);
+ ctx->activate();
}
- active_ctx = ctx;
}
GPUContext *GPU_context_active_get(void)
@@ -199,23 +123,18 @@ GPUContext *GPU_context_active_get(void)
GLuint GPU_vao_default(void)
{
BLI_assert(active_ctx); /* need at least an active context */
- BLI_assert(pthread_equal(
- pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */
- return active_ctx->default_vao;
+ return static_cast<GLContext *>(active_ctx)->default_vao_;
}
GLuint GPU_framebuffer_default(void)
{
BLI_assert(active_ctx); /* need at least an active context */
- BLI_assert(pthread_equal(
- pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */
- return active_ctx->default_framebuffer;
+ return static_cast<GLContext *>(active_ctx)->default_framebuffer_;
}
GLuint GPU_vao_alloc(void)
{
GLuint new_vao_id = 0;
- orphans_clear(active_ctx);
glGenVertexArrays(1, &new_vao_id);
return new_vao_id;
}
@@ -223,7 +142,6 @@ GLuint GPU_vao_alloc(void)
GLuint GPU_fbo_alloc(void)
{
GLuint new_fbo_id = 0;
- orphans_clear(active_ctx);
glGenFramebuffers(1, &new_fbo_id);
return new_fbo_id;
}
@@ -231,7 +149,6 @@ GLuint GPU_fbo_alloc(void)
GLuint GPU_buf_alloc(void)
{
GLuint new_buffer_id = 0;
- orphans_clear(active_ctx);
glGenBuffers(1, &new_buffer_id);
return new_buffer_id;
}
@@ -239,51 +156,32 @@ GLuint GPU_buf_alloc(void)
GLuint GPU_tex_alloc(void)
{
GLuint new_texture_id = 0;
- orphans_clear(active_ctx);
glGenTextures(1, &new_texture_id);
return new_texture_id;
}
void GPU_vao_free(GLuint vao_id, GPUContext *ctx)
{
- BLI_assert(ctx);
- if (ctx == active_ctx) {
- glDeleteVertexArrays(1, &vao_id);
- }
- else {
- orphans_add(ctx, &ctx->orphaned_vertarray_ids, vao_id);
- }
+ static_cast<GLContext *>(ctx)->vao_free(vao_id);
}
void GPU_fbo_free(GLuint fbo_id, GPUContext *ctx)
{
- BLI_assert(ctx);
- if (ctx == active_ctx) {
- glDeleteFramebuffers(1, &fbo_id);
- }
- else {
- orphans_add(ctx, &ctx->orphaned_framebuffer_ids, fbo_id);
- }
+ static_cast<GLContext *>(ctx)->fbo_free(fbo_id);
}
void GPU_buf_free(GLuint buf_id)
{
- if (active_ctx) {
- glDeleteBuffers(1, &buf_id);
- }
- else {
- orphans_add(NULL, &orphaned_buffer_ids, buf_id);
- }
+ /* TODO avoid using backend */
+ GPUBackend *backend = gpu_backend_get();
+ static_cast<GLBackend *>(backend)->buf_free(buf_id);
}
void GPU_tex_free(GLuint tex_id)
{
- if (active_ctx) {
- glDeleteTextures(1, &tex_id);
- }
- else {
- orphans_add(NULL, &orphaned_texture_ids, tex_id);
- }
+ /* TODO avoid using backend */
+ GPUBackend *backend = gpu_backend_get();
+ static_cast<GLBackend *>(backend)->tex_free(tex_id);
}
/* GPUBatch & GPUFrameBuffer contains respectively VAO & FBO indices
@@ -293,26 +191,20 @@ void GPU_tex_free(GLuint tex_id)
void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch)
{
BLI_assert(ctx);
- ctx->orphans_mutex.lock();
- ctx->batches.emplace(batch);
- ctx->orphans_mutex.unlock();
+ static_cast<GLContext *>(ctx)->batch_register(batch);
}
void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch)
{
BLI_assert(ctx);
- ctx->orphans_mutex.lock();
- ctx->batches.erase(batch);
- ctx->orphans_mutex.unlock();
+ static_cast<GLContext *>(ctx)->batch_unregister(batch);
}
void gpu_context_add_framebuffer(GPUContext *ctx, GPUFrameBuffer *fb)
{
#ifdef DEBUG
BLI_assert(ctx);
- ctx->orphans_mutex.lock();
- ctx->framebuffers.emplace(fb);
- ctx->orphans_mutex.unlock();
+ static_cast<GLContext *>(ctx)->framebuffer_register(fb);
#else
UNUSED_VARS(ctx, fb);
#endif
@@ -322,9 +214,7 @@ void gpu_context_remove_framebuffer(GPUContext *ctx, GPUFrameBuffer *fb)
{
#ifdef DEBUG
BLI_assert(ctx);
- ctx->orphans_mutex.lock();
- ctx->framebuffers.erase(fb);
- ctx->orphans_mutex.unlock();
+ static_cast<GLContext *>(ctx)->framebuffer_unregister(fb);
#else
UNUSED_VARS(ctx, fb);
#endif
@@ -345,3 +235,59 @@ struct GPUMatrixState *gpu_context_active_matrix_state_get()
BLI_assert(active_ctx);
return active_ctx->matrix_state;
}
+
+/* -------------------------------------------------------------------- */
+/** \name Main context global mutex
+ *
+ * Used to avoid crash on some old drivers.
+ * \{ */
+
+static std::mutex main_context_mutex;
+
+void GPU_context_main_lock(void)
+{
+ main_context_mutex.lock();
+}
+
+void GPU_context_main_unlock(void)
+{
+ main_context_mutex.unlock();
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Backend selection
+ * \{ */
+
+static GPUBackend *g_backend;
+
+void GPU_backend_init(eGPUBackendType backend_type)
+{
+ BLI_assert(g_backend == NULL);
+
+ switch (backend_type) {
+#if WITH_OPENGL_BACKEND
+ case GPU_BACKEND_OPENGL:
+ g_backend = new GLBackend;
+ break;
+#endif
+ default:
+ BLI_assert(0);
+ break;
+ }
+}
+
+void GPU_backend_exit(void)
+{
+ /* TODO assert no resource left. Currently UI textures are still not freed in their context
+ * correctly. */
+ delete g_backend;
+}
+
+GPUBackend *gpu_backend_get(void)
+{
+ return g_backend;
+}
+
+/** \} */
diff --git a/source/blender/gpu/intern/gpu_context_private.h b/source/blender/gpu/intern/gpu_context_private.hh
index f64cdf439a1..d369dbe7402 100644
--- a/source/blender/gpu/intern/gpu_context_private.h
+++ b/source/blender/gpu/intern/gpu_context_private.hh
@@ -23,16 +23,43 @@
* This interface allow GPU to manage GL objects for multiple context and threads.
*/
-#ifndef __GPU_CONTEXT_PRIVATE_H__
-#define __GPU_CONTEXT_PRIVATE_H__
+#pragma once
+
+#include "MEM_guardedalloc.h"
#include "GPU_context.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <mutex>
+#include <pthread.h>
+#include <string.h>
+#include <unordered_set>
+#include <vector>
struct GPUFrameBuffer;
+struct GPUMatrixState;
+
+struct GPUContext {
+ public:
+ /** State managment */
+ GPUFrameBuffer *current_fbo = NULL;
+ GPUMatrixState *matrix_state = NULL;
+
+ protected:
+ /** Thread on which this context is active. */
+ pthread_t thread_;
+ bool is_active_;
+
+ public:
+ GPUContext();
+ virtual ~GPUContext();
+
+ virtual void activate(void) = 0;
+ virtual void deactivate(void) = 0;
+
+ bool is_active_on_thread(void);
+
+ MEM_CXX_CLASS_ALLOC_FUNCS("GPUContext")
+};
GLuint GPU_vao_default(void);
GLuint GPU_framebuffer_default(void);
@@ -60,9 +87,3 @@ void gpu_context_active_framebuffer_set(GPUContext *ctx, struct GPUFrameBuffer *
struct GPUFrameBuffer *gpu_context_active_framebuffer_get(GPUContext *ctx);
struct GPUMatrixState *gpu_context_active_matrix_state_get(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __GPU_CONTEXT_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_element.cc b/source/blender/gpu/intern/gpu_element.cc
index 9f104ab3fec..cf7cc1d214c 100644
--- a/source/blender/gpu/intern/gpu_element.cc
+++ b/source/blender/gpu/intern/gpu_element.cc
@@ -28,7 +28,7 @@
#include "GPU_element.h"
#include "GPU_glew.h"
-#include "gpu_context_private.h"
+#include "gpu_context_private.hh"
#include <stdlib.h>
@@ -280,7 +280,7 @@ static uint index_range(const uint values[], uint value_len, uint *min_out, uint
if (value == RESTART_INDEX) {
continue;
}
- else if (value < min_value) {
+ if (value < min_value) {
min_value = value;
}
else if (value > max_value) {
@@ -292,11 +292,10 @@ static uint index_range(const uint values[], uint value_len, uint *min_out, uint
*max_out = 0;
return 0;
}
- else {
- *min_out = min_value;
- *max_out = max_value;
- return max_value - min_value;
- }
+
+ *min_out = min_value;
+ *max_out = max_value;
+ return max_value - min_value;
}
static void squeeze_indices_short(GPUIndexBufBuilder *builder,
diff --git a/source/blender/gpu/intern/gpu_extensions.cc b/source/blender/gpu/intern/gpu_extensions.cc
index a9ab25cbb41..8074e4b64f0 100644
--- a/source/blender/gpu/intern/gpu_extensions.cc
+++ b/source/blender/gpu/intern/gpu_extensions.cc
@@ -31,6 +31,8 @@
#include "BKE_global.h"
#include "MEM_guardedalloc.h"
+#include "DNA_userdef_types.h"
+
#include "GPU_extensions.h"
#include "GPU_framebuffer.h"
#include "GPU_glew.h"
@@ -95,7 +97,7 @@ static struct GPUGlobal {
bool broken_amd_driver;
/* Some crappy Intel drivers don't work well with shaders created in different
* rendering contexts. */
- bool context_local_shaders_workaround;
+ bool use_main_context_workaround;
/* Intel drivers exhibit artifacts when using #glCopyImageSubData & workbench anti-aliasing.
* (see T76273) */
bool texture_copy_workaround;
@@ -104,8 +106,7 @@ static struct GPUGlobal {
static void gpu_detect_mip_render_workaround(void)
{
int cube_size = 2;
- float *source_pix = (float *)MEM_callocN(sizeof(float) * 4 * 6 * cube_size * cube_size,
- __func__);
+ float *source_pix = (float *)MEM_callocN(sizeof(float[4][6]) * cube_size * cube_size, __func__);
float clear_color[4] = {1.0f, 0.5f, 0.0f, 0.0f};
GPUTexture *tex = GPU_texture_create_cube(cube_size, GPU_RGBA16F, source_pix, NULL);
@@ -223,9 +224,9 @@ bool GPU_unused_fb_slot_workaround(void)
return GG.unused_fb_slot_workaround;
}
-bool GPU_context_local_shaders_workaround(void)
+bool GPU_use_main_context_workaround(void)
{
- return GG.context_local_shaders_workaround;
+ return GG.use_main_context_workaround;
}
bool GPU_texture_copy_workaround(void)
@@ -239,6 +240,13 @@ bool GPU_crappy_amd_driver(void)
return GG.broken_amd_driver;
}
+int GPU_texture_size_with_limit(int res)
+{
+ int size = GPU_max_texture_size();
+ int reslimit = (U.glreslimit != 0) ? min_ii(U.glreslimit, size) : size;
+ return min_ii(reslimit, res);
+}
+
void gpu_extensions_init(void)
{
/* during 2.8 development each platform has its own OpenGL minimum requirements
@@ -382,12 +390,12 @@ void gpu_extensions_init(void)
/* Maybe not all of these drivers have problems with `GLEW_ARB_base_instance`.
* But it's hard to test each case. */
GG.glew_arb_base_instance_is_supported = false;
- GG.context_local_shaders_workaround = true;
+ GG.use_main_context_workaround = true;
}
if (strstr(version, "Build 20.19.15.4285")) {
/* Somehow fixes armature display issues (see T69743). */
- GG.context_local_shaders_workaround = true;
+ GG.use_main_context_workaround = true;
}
}
else if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE) &&
diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc
index 3829573cde1..5f3089b2ffb 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.cc
+++ b/source/blender/gpu/intern/gpu_framebuffer.cc
@@ -28,13 +28,12 @@
#include "BLI_utildefines.h"
#include "GPU_batch.h"
-#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_framebuffer.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
-#include "gpu_context_private.h"
+#include "gpu_context_private.hh"
#include "gpu_private.h"
typedef enum {
@@ -128,9 +127,8 @@ static GPUTexture *framebuffer_get_depth_tex(GPUFrameBuffer *fb)
if (fb->attachments[GPU_FB_DEPTH_ATTACHMENT].tex) {
return fb->attachments[GPU_FB_DEPTH_ATTACHMENT].tex;
}
- else {
- return fb->attachments[GPU_FB_DEPTH_STENCIL_ATTACHMENT].tex;
- }
+
+ return fb->attachments[GPU_FB_DEPTH_STENCIL_ATTACHMENT].tex;
}
static GPUTexture *framebuffer_get_color_tex(GPUFrameBuffer *fb, int slot)
@@ -191,9 +189,8 @@ GPUFrameBuffer *GPU_framebuffer_active_get(void)
if (ctx) {
return gpu_context_active_framebuffer_get(ctx);
}
- else {
- return 0;
- }
+
+ return 0;
}
static void gpu_framebuffer_current_set(GPUFrameBuffer *fb)
@@ -262,7 +259,7 @@ static void gpu_framebuffer_texture_attach_ex(
if ((attachment->tex == tex) && (attachment->mip == mip) && (attachment->layer == layer)) {
return; /* Exact same texture already bound here. */
}
- else if (attachment->tex != NULL) {
+ if (attachment->tex != NULL) {
GPU_framebuffer_texture_detach(fb, attachment->tex);
}
@@ -415,7 +412,7 @@ static void gpu_framebuffer_update_attachments(GPUFrameBuffer *fb)
if (GPU_FB_ATTACHEMENT_IS_DIRTY(fb->dirty_flag, type) == false) {
continue;
}
- else if (fb->attachments[type].tex != NULL) {
+ if (fb->attachments[type].tex != NULL) {
gpu_framebuffer_attachment_attach(&fb->attachments[type], type);
fb->multisample = (GPU_texture_samples(fb->attachments[type].tex) > 0);
@@ -451,7 +448,7 @@ static void gpu_framebuffer_update_attachments_and_fill_empty_slots(GPUFrameBuff
BLI_assert(GPU_framebuffer_active_get() == fb);
/* Update attachments */
- for (int i_type = GPU_FB_MAX_ATTACHEMENT; i_type >= 0; --i_type) {
+ for (int i_type = GPU_FB_MAX_ATTACHEMENT - 1; i_type >= 0; --i_type) {
GPUAttachmentType type = static_cast<GPUAttachmentType>(i_type);
GPUTexture *tex = fb->attachments[type].tex;
@@ -1046,7 +1043,7 @@ void GPU_offscreen_read_pixels(GPUOffScreen *ofs, eGPUDataFormat type, void *pix
const int w = GPU_texture_width(ofs->color);
const int h = GPU_texture_height(ofs->color);
- BLI_assert(ELEM(type, GPU_DATA_UNSIGNED_BYTE, GL_FLOAT));
+ BLI_assert(ELEM(type, GPU_DATA_UNSIGNED_BYTE, GPU_DATA_FLOAT));
GLenum gl_type = (type == GPU_DATA_FLOAT) ? GL_FLOAT : GL_UNSIGNED_BYTE;
glReadPixels(0, 0, w, h, GL_RGBA, gl_type, pixels);
diff --git a/source/blender/gpu/intern/gpu_immediate.cc b/source/blender/gpu/intern/gpu_immediate.cc
index 4780b2dc7b3..9cededa54f7 100644
--- a/source/blender/gpu/intern/gpu_immediate.cc
+++ b/source/blender/gpu/intern/gpu_immediate.cc
@@ -33,7 +33,7 @@
#include "GPU_texture.h"
#include "gpu_attr_binding_private.h"
-#include "gpu_context_private.h"
+#include "gpu_context_private.hh"
#include "gpu_primitive_private.h"
#include "gpu_shader_private.h"
#include "gpu_vertex_format_private.h"
@@ -72,7 +72,7 @@ typedef struct {
GLuint vao_id;
- GLuint bound_program;
+ GPUShader *bound_program;
const GPUShaderInterface *shader_interface;
GPUAttrBinding attr_binding;
uint16_t prev_enabled_attr_bits; /* <-- only affects this VAO, so we're ok */
@@ -143,48 +143,47 @@ GPUVertFormat *immVertexFormat(void)
return &imm.vertex_format;
}
-void immBindProgram(GLuint program, const GPUShaderInterface *shaderface)
+void immBindShader(GPUShader *shader)
{
#if TRUST_NO_ONE
- assert(imm.bound_program == 0);
- assert(glIsProgram(program));
+ assert(imm.bound_program == NULL);
+ assert(glIsProgram(shader->program));
#endif
- imm.bound_program = program;
- imm.shader_interface = shaderface;
+ imm.bound_program = shader;
+ imm.shader_interface = shader->interface;
if (!imm.vertex_format.packed) {
VertexFormat_pack(&imm.vertex_format);
}
- glUseProgram(program);
- get_attr_locations(&imm.vertex_format, &imm.attr_binding, shaderface);
- GPU_matrix_bind(shaderface);
- GPU_shader_set_srgb_uniform(shaderface);
+ GPU_shader_bind(shader);
+ get_attr_locations(&imm.vertex_format, &imm.attr_binding, imm.shader_interface);
+ GPU_matrix_bind(imm.shader_interface);
+ GPU_shader_set_srgb_uniform(imm.shader_interface);
}
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
{
GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
- immBindProgram(shader->program, shader->interface);
+ immBindShader(shader);
}
void immUnbindProgram(void)
{
#if TRUST_NO_ONE
- assert(imm.bound_program != 0);
+ assert(imm.bound_program != NULL);
#endif
#if PROGRAM_NO_OPTI
glUseProgram(0);
#endif
- imm.bound_program = 0;
+ imm.bound_program = NULL;
}
/* XXX do not use it. Special hack to use OCIO with batch API. */
-void immGetProgram(GLuint *program, GPUShaderInterface **shaderface)
+GPUShader *immGetShader(void)
{
- *program = imm.bound_program;
- *shaderface = (GPUShaderInterface *)imm.shader_interface;
+ return imm.bound_program;
}
#if TRUST_NO_ONE
@@ -364,17 +363,18 @@ static void immDrawSetup(void)
const GLvoid *pointer = (const GLubyte *)0 + offset;
const uint loc = read_attr_location(&imm.attr_binding, a_idx);
+ const GLenum type = convert_comp_type_to_gl(static_cast<GPUVertCompType>(a->comp_type));
switch (a->fetch_mode) {
case GPU_FETCH_FLOAT:
case GPU_FETCH_INT_TO_FLOAT:
- glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer);
+ glVertexAttribPointer(loc, a->comp_len, type, GL_FALSE, stride, pointer);
break;
case GPU_FETCH_INT_TO_FLOAT_UNIT:
- glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer);
+ glVertexAttribPointer(loc, a->comp_len, type, GL_TRUE, stride, pointer);
break;
case GPU_FETCH_INT:
- glVertexAttribIPointer(loc, a->comp_len, a->gl_comp_type, stride, pointer);
+ glVertexAttribIPointer(loc, a->comp_len, type, stride, pointer);
}
}
@@ -422,7 +422,7 @@ void immEnd(void)
GPU_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_len);
/* TODO: resize only if vertex count is much smaller */
}
- GPU_batch_program_set(imm.batch, imm.bound_program, imm.shader_interface);
+ GPU_batch_set_shader(imm.batch, imm.bound_program);
imm.batch->phase = GPU_BATCH_READY_TO_DRAW;
imm.batch = NULL; /* don't free, batch belongs to caller */
}
@@ -931,6 +931,14 @@ void immUniformThemeColor(int color_id)
immUniformColor4fv(color);
}
+void immUniformThemeColorAlpha(int color_id, float a)
+{
+ float color[4];
+ UI_GetThemeColor3fv(color_id, color);
+ color[3] = a;
+ immUniformColor4fv(color);
+}
+
void immUniformThemeColor3(int color_id)
{
float color[3];
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index e834d6afccb..b8cd9fe356d 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -460,10 +460,10 @@ void imm_draw_cylinder_fill_normal_3d(
float h1 = height * ((float)j / (float)stacks);
float h2 = height * ((float)(j + 1) / (float)stacks);
- float v1[3] = {r1 * cos2, r1 * sin2, h1};
- float v2[3] = {r2 * cos2, r2 * sin2, h2};
- float v3[3] = {r2 * cos1, r2 * sin1, h2};
- float v4[3] = {r1 * cos1, r1 * sin1, h1};
+ const float v1[3] = {r1 * cos2, r1 * sin2, h1};
+ const float v2[3] = {r2 * cos2, r2 * sin2, h2};
+ const float v3[3] = {r2 * cos1, r2 * sin1, h2};
+ const float v4[3] = {r1 * cos1, r1 * sin1, h1};
float n1[3], n2[3];
/* calc normals */
@@ -516,10 +516,10 @@ void imm_draw_cylinder_wire_3d(
float h1 = height * ((float)j / (float)stacks);
float h2 = height * ((float)(j + 1) / (float)stacks);
- float v1[3] = {r1 * cos2, r1 * sin2, h1};
- float v2[3] = {r2 * cos2, r2 * sin2, h2};
- float v3[3] = {r2 * cos1, r2 * sin1, h2};
- float v4[3] = {r1 * cos1, r1 * sin1, h1};
+ const float v1[3] = {r1 * cos2, r1 * sin2, h1};
+ const float v2[3] = {r2 * cos2, r2 * sin2, h2};
+ const float v3[3] = {r2 * cos1, r2 * sin1, h2};
+ const float v4[3] = {r1 * cos1, r1 * sin1, h1};
immVertex3fv(pos, v1);
immVertex3fv(pos, v2);
@@ -554,10 +554,10 @@ void imm_draw_cylinder_fill_3d(
float h1 = height * ((float)j / (float)stacks);
float h2 = height * ((float)(j + 1) / (float)stacks);
- float v1[3] = {r1 * cos2, r1 * sin2, h1};
- float v2[3] = {r2 * cos2, r2 * sin2, h2};
- float v3[3] = {r2 * cos1, r2 * sin1, h2};
- float v4[3] = {r1 * cos1, r1 * sin1, h1};
+ const float v1[3] = {r1 * cos2, r1 * sin2, h1};
+ const float v2[3] = {r2 * cos2, r2 * sin2, h2};
+ const float v3[3] = {r2 * cos1, r2 * sin1, h2};
+ const float v4[3] = {r1 * cos1, r1 * sin1, h1};
/* first tri */
immVertex3fv(pos, v1);
diff --git a/source/blender/gpu/intern/gpu_init_exit.c b/source/blender/gpu/intern/gpu_init_exit.c
index 54ddb9351b9..ba0da95eb9d 100644
--- a/source/blender/gpu/intern/gpu_init_exit.c
+++ b/source/blender/gpu/intern/gpu_init_exit.c
@@ -26,6 +26,7 @@
#include "BLI_sys_types.h"
#include "GPU_batch.h"
#include "GPU_buffers.h"
+#include "GPU_context.h"
#include "GPU_immediate.h"
#include "intern/gpu_codegen.h"
@@ -95,7 +96,7 @@ void GPU_exit(void)
initialized = false;
}
-bool GPU_is_initialized(void)
+bool GPU_is_init(void)
{
return initialized;
}
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index c65c1046b8f..8df1f94238a 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -85,7 +85,7 @@ struct GPUMaterial {
bool has_surface_output;
/* Only used by Eevee to know which bsdf are used. */
- int flag;
+ eGPUMatFlag flag;
/* Used by 2.8 pipeline */
GPUUniformBuffer *ubo; /* UBOs for shader uniforms. */
@@ -311,12 +311,11 @@ static float eval_profile(float r, short falloff_type, float sharpness, float pa
if (falloff_type == SHD_SUBSURFACE_BURLEY || falloff_type == SHD_SUBSURFACE_RANDOM_WALK) {
return burley_profile(r, param) / BURLEY_TRUNCATE_CDF;
}
- else if (falloff_type == SHD_SUBSURFACE_CUBIC) {
+ if (falloff_type == SHD_SUBSURFACE_CUBIC) {
return cubic_profile(r, param, sharpness);
}
- else {
- return gaussian_profile(r, param);
- }
+
+ return gaussian_profile(r, param);
}
/* Resolution for each sample of the precomputed kernel profile */
@@ -440,7 +439,7 @@ static void compute_sss_translucence_kernel(const GPUSssKernelData *kd,
float **output)
{
float(*texels)[4];
- texels = MEM_callocN(sizeof(float) * 4 * resolution, "compute_sss_translucence_kernel");
+ texels = MEM_callocN(sizeof(float[4]) * resolution, "compute_sss_translucence_kernel");
*output = (float *)texels;
/* Last texel should be black, hence the - 1. */
@@ -659,7 +658,8 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene,
const char *geom_code,
const char *frag_lib,
const char *defines,
- const char *name)
+ const char *name,
+ GPUMaterialEvalCallbackFn callback)
{
LinkData *link;
bool has_volume_output, has_surface_output;
@@ -696,6 +696,9 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene,
mat->has_volume_output = has_volume_output;
if (mat->graph.outlink) {
+ if (callback) {
+ callback(mat, options, &vert_code, &geom_code, &frag_lib, &defines);
+ }
/* HACK: this is only for eevee. We add the define here after the nodetree evaluation. */
if (GPU_material_flag_get(mat, GPU_MATFLAG_SSS)) {
defines = BLI_string_joinN(defines,
diff --git a/source/blender/gpu/intern/gpu_material_library.c b/source/blender/gpu/intern/gpu_material_library.c
index 42cd9673ac2..e0165e1fa83 100644
--- a/source/blender/gpu/intern/gpu_material_library.c
+++ b/source/blender/gpu/intern/gpu_material_library.c
@@ -678,14 +678,13 @@ char *gpu_str_skip_token(char *str, char *token, int max)
if (ELEM(*str, ' ', '(', ')', ',', ';', '\t', '\n', '\r')) {
break;
}
- else {
- if (token && len < max - 1) {
- *token = *str;
- token++;
- len++;
- }
- str++;
+
+ if (token && len < max - 1) {
+ *token = *str;
+ token++;
+ len++;
}
+ str++;
}
if (token) {
diff --git a/source/blender/gpu/intern/gpu_material_library.h b/source/blender/gpu/intern/gpu_material_library.h
index f69c25b9490..da7b1636fa3 100644
--- a/source/blender/gpu/intern/gpu_material_library.h
+++ b/source/blender/gpu/intern/gpu_material_library.h
@@ -22,8 +22,7 @@
*
* Parsing of and code generation using GLSL shaders in gpu/shaders/material. */
-#ifndef __GPU_MATERIAL_LIBRARY_H__
-#define __GPU_MATERIAL_LIBRARY_H__
+#pragma once
#include "GPU_material.h"
@@ -65,5 +64,3 @@ char *gpu_material_library_generate_code(struct GSet *used_libraries, const char
char *gpu_str_skip_token(char *str, char *token, int max);
const char *gpu_data_type_to_string(const eGPUType type);
-
-#endif /* __ __GPU_MATERIAL_LIBRARY_H__ */
diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.cc
index 669bf56b726..5d8d77bbf1c 100644
--- a/source/blender/gpu/intern/gpu_matrix.c
+++ b/source/blender/gpu/intern/gpu_matrix.cc
@@ -23,7 +23,7 @@
#include "GPU_shader_interface.h"
-#include "gpu_context_private.h"
+#include "gpu_context_private.hh"
#include "gpu_matrix_private.h"
#define SUPPRESS_GENERIC_MATRIX_API
@@ -37,8 +37,6 @@
#include "MEM_guardedalloc.h"
-#define DEBUG_MATRIX_BIND 0
-
#define MATRIX_STACK_DEPTH 32
typedef float Mat4[4][4];
@@ -79,7 +77,7 @@ GPUMatrixState *GPU_matrix_state_create(void)
} \
}
- GPUMatrixState *state = MEM_mallocN(sizeof(*state), __func__);
+ GPUMatrixState *state = (GPUMatrixState *)MEM_mallocN(sizeof(*state), __func__);
const MatrixStack identity_stack = {{MATRIX_4X4_IDENTITY}, 0};
state->model_view_stack = state->projection_stack = identity_stack;
@@ -592,9 +590,8 @@ const float (*GPU_matrix_model_view_get(float m[4][4]))[4]
copy_m4_m4(m, ModelView);
return m;
}
- else {
- return ModelView;
- }
+
+ return ModelView;
}
const float (*GPU_matrix_projection_get(float m[4][4]))[4]
@@ -603,9 +600,8 @@ const float (*GPU_matrix_projection_get(float m[4][4]))[4]
copy_m4_m4(m, Projection);
return m;
}
- else {
- return Projection;
- }
+
+ return Projection;
}
const float (*GPU_matrix_model_view_projection_get(float m[4][4]))[4]
@@ -662,51 +658,32 @@ void GPU_matrix_bind(const GPUShaderInterface *shaderface)
int32_t MV_inv = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_MODELVIEW_INV);
int32_t P_inv = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_PROJECTION_INV);
+ /* XXX(fclem) this works but this assumes shader is unused inside GPU_shader_uniform_vector. */
+ GPUShader *sh = NULL;
if (MV != -1) {
-#if DEBUG_MATRIX_BIND
- puts("setting MV matrix");
-#endif
-
- glUniformMatrix4fv(MV, 1, GL_FALSE, (const float *)GPU_matrix_model_view_get(NULL));
+ GPU_shader_uniform_vector(sh, MV, 16, 1, (const float *)GPU_matrix_model_view_get(NULL));
}
-
if (P != -1) {
-#if DEBUG_MATRIX_BIND
- puts("setting P matrix");
-#endif
-
- glUniformMatrix4fv(P, 1, GL_FALSE, (const float *)GPU_matrix_projection_get(NULL));
+ GPU_shader_uniform_vector(sh, P, 16, 1, (const float *)GPU_matrix_projection_get(NULL));
}
-
if (MVP != -1) {
-#if DEBUG_MATRIX_BIND
- puts("setting MVP matrix");
-#endif
-
- glUniformMatrix4fv(
- MVP, 1, GL_FALSE, (const float *)GPU_matrix_model_view_projection_get(NULL));
+ GPU_shader_uniform_vector(
+ sh, MVP, 16, 1, (const float *)GPU_matrix_model_view_projection_get(NULL));
}
-
if (N != -1) {
-#if DEBUG_MATRIX_BIND
- puts("setting normal matrix");
-#endif
-
- glUniformMatrix3fv(N, 1, GL_FALSE, (const float *)GPU_matrix_normal_get(NULL));
+ GPU_shader_uniform_vector(sh, N, 9, 1, (const float *)GPU_matrix_normal_get(NULL));
}
-
if (MV_inv != -1) {
Mat4 m;
GPU_matrix_model_view_get(m);
invert_m4(m);
- glUniformMatrix4fv(MV_inv, 1, GL_FALSE, (const float *)m);
+ GPU_shader_uniform_vector(sh, MV_inv, 16, 1, (const float *)m);
}
-
if (P_inv != -1) {
Mat4 m;
GPU_matrix_projection_get(m);
invert_m4(m);
- glUniformMatrix4fv(P_inv, 1, GL_FALSE, (const float *)m);
+ GPU_shader_uniform_vector(sh, P_inv, 16, 1, (const float *)m);
}
gpu_matrix_state_active_set_dirty(false);
diff --git a/source/blender/gpu/intern/gpu_matrix_private.h b/source/blender/gpu/intern/gpu_matrix_private.h
index 862ef065481..3448b0a95aa 100644
--- a/source/blender/gpu/intern/gpu_matrix_private.h
+++ b/source/blender/gpu/intern/gpu_matrix_private.h
@@ -18,8 +18,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_MATRIX_PRIVATE_H__
-#define __GPU_MATRIX_PRIVATE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -31,5 +30,3 @@ void GPU_matrix_state_discard(struct GPUMatrixState *state);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_MATRIX_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c
index 17d97dc05e2..81cf2d69f4d 100644
--- a/source/blender/gpu/intern/gpu_node_graph.c
+++ b/source/blender/gpu/intern/gpu_node_graph.c
@@ -457,10 +457,10 @@ GPUNodeLink *GPU_volume_grid(GPUMaterial *mat, const char *name)
/* Two special cases, where we adjust the output values of smoke grids to
* bring the into standard range without having to modify the grid values. */
- if (strcmp(name, "color") == 0) {
+ if (STREQ(name, "color")) {
GPU_link(mat, "node_attribute_volume_color", link, transform_link, &link);
}
- else if (strcmp(name, "temperature") == 0) {
+ else if (STREQ(name, "temperature")) {
GPU_link(mat, "node_attribute_volume_temperature", link, transform_link, &link);
}
else {
diff --git a/source/blender/gpu/intern/gpu_node_graph.h b/source/blender/gpu/intern/gpu_node_graph.h
index a133dd1ccdc..7265abf4d65 100644
--- a/source/blender/gpu/intern/gpu_node_graph.h
+++ b/source/blender/gpu/intern/gpu_node_graph.h
@@ -23,8 +23,7 @@
* Intermediate node graph for generating GLSL shaders.
*/
-#ifndef __GPU_NODE_GRAPH_H__
-#define __GPU_NODE_GRAPH_H__
+#pragma once
#include "DNA_customdata_types.h"
#include "DNA_listBase.h"
@@ -164,5 +163,3 @@ struct GPUTexture **gpu_material_ramp_texture_row_set(struct GPUMaterial *mat,
float *row);
struct GSet *gpu_material_used_libraries(struct GPUMaterial *material);
-
-#endif /* __GPU_NODE_GRAPH_H__ */
diff --git a/source/blender/gpu/intern/gpu_primitive_private.h b/source/blender/gpu/intern/gpu_primitive_private.h
index b7d7b262128..e91eec18786 100644
--- a/source/blender/gpu/intern/gpu_primitive_private.h
+++ b/source/blender/gpu/intern/gpu_primitive_private.h
@@ -23,8 +23,7 @@
* GPU geometric primitives
*/
-#ifndef __GPU_PRIMITIVE_PRIVATE_H__
-#define __GPU_PRIMITIVE_PRIVATE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -36,5 +35,3 @@ GLenum convert_prim_type_to_gl(GPUPrimType);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_PRIMITIVE_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_private.h b/source/blender/gpu/intern/gpu_private.h
index ed729dd399c..ef96bedae4a 100644
--- a/source/blender/gpu/intern/gpu_private.h
+++ b/source/blender/gpu/intern/gpu_private.h
@@ -18,8 +18,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_PRIVATE_H__
-#define __GPU_PRIVATE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -48,5 +47,3 @@ void gpu_pbvh_exit(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index c6d8545527c..0f6f29fab40 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -27,7 +27,6 @@
#include <stdlib.h>
#include <string.h>
-#include "GPU_draw.h"
#include "GPU_glew.h"
#include "GPU_immediate.h"
#include "GPU_select.h"
@@ -205,12 +204,11 @@ static int depth_id_cmp(const void *v1, const void *v2)
if (d1->id < d2->id) {
return -1;
}
- else if (d1->id > d2->id) {
+ if (d1->id > d2->id) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
static int depth_cmp(const void *v1, const void *v2)
@@ -219,12 +217,11 @@ static int depth_cmp(const void *v1, const void *v2)
if (d1->depth < d2->depth) {
return -1;
}
- else if (d1->depth > d2->depth) {
+ if (d1->depth > d2->depth) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
/* depth sorting */
diff --git a/source/blender/gpu/intern/gpu_select_private.h b/source/blender/gpu/intern/gpu_select_private.h
index a0619bd4293..e364b78bff2 100644
--- a/source/blender/gpu/intern/gpu_select_private.h
+++ b/source/blender/gpu/intern/gpu_select_private.h
@@ -23,8 +23,7 @@
* Selection implementations.
*/
-#ifndef __GPU_SELECT_PRIVATE_H__
-#define __GPU_SELECT_PRIVATE_H__
+#pragma once
/* gpu_select_pick */
void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, char mode);
@@ -43,5 +42,3 @@ bool gpu_select_query_load_id(uint id);
uint gpu_select_query_end(void);
#define SELECT_ID_NONE ((uint)0xffffffff)
-
-#endif /* __GPU_SELECT_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_select_sample_query.c b/source/blender/gpu/intern/gpu_select_sample_query.c
index 70ad2f6759e..f67c9c36a6b 100644
--- a/source/blender/gpu/intern/gpu_select_sample_query.c
+++ b/source/blender/gpu/intern/gpu_select_sample_query.c
@@ -147,9 +147,8 @@ bool gpu_select_query_load_id(uint id)
g_query_state.index++;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
}
diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc
new file mode 100644
index 00000000000..03b7d5402f5
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_shader.cc
@@ -0,0 +1,839 @@
+/*
+ * 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) 2005 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup gpu
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math_base.h"
+#include "BLI_math_vector.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+#include "BLI_string_utils.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_appdir.h"
+#include "BKE_global.h"
+
+#include "DNA_space_types.h"
+
+#include "GPU_extensions.h"
+#include "GPU_matrix.h"
+#include "GPU_platform.h"
+#include "GPU_shader.h"
+#include "GPU_texture.h"
+#include "GPU_uniformbuffer.h"
+
+#include "gpu_shader_private.h"
+
+extern "C" char datatoc_gpu_shader_colorspace_lib_glsl[];
+
+/* Adjust these constants as needed. */
+#define MAX_DEFINE_LENGTH 256
+#define MAX_EXT_DEFINE_LENGTH 512
+
+#ifndef NDEBUG
+static uint g_shaderid = 0;
+#endif
+
+/* -------------------------------------------------------------------- */
+/** \name Convenience functions
+ * \{ */
+
+static void shader_print_errors(const char *task, const char *log, const char **code, int totcode)
+{
+ int line = 1;
+
+ fprintf(stderr, "GPUShader: %s error:\n", task);
+
+ for (int i = 0; i < totcode; i++) {
+ const char *c, *pos, *end = code[i] + strlen(code[i]);
+
+ if (G.debug & G_DEBUG) {
+ fprintf(stderr, "===== shader string %d ====\n", i + 1);
+
+ c = code[i];
+ while ((c < end) && (pos = strchr(c, '\n'))) {
+ fprintf(stderr, "%2d ", line);
+ fwrite(c, (pos + 1) - c, 1, stderr);
+ c = pos + 1;
+ line++;
+ }
+
+ fprintf(stderr, "%s", c);
+ }
+ }
+
+ fprintf(stderr, "%s\n", log);
+}
+
+static const char *gpu_shader_version(void)
+{
+ return "#version 330\n";
+}
+
+static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH])
+{
+ /* enable extensions for features that are not part of our base GLSL version
+ * don't use an extension for something already available!
+ */
+
+ if (GLEW_ARB_texture_gather) {
+ /* There is a bug on older Nvidia GPU where GL_ARB_texture_gather
+ * is reported to be supported but yield a compile error (see T55802). */
+ if (!GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY) || GLEW_VERSION_4_0) {
+ strcat(defines, "#extension GL_ARB_texture_gather: enable\n");
+
+ /* Some drivers don't agree on GLEW_ARB_texture_gather and the actual support in the
+ * shader so double check the preprocessor define (see T56544). */
+ if (!GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY) && !GLEW_VERSION_4_0) {
+ strcat(defines, "#ifdef GL_ARB_texture_gather\n");
+ strcat(defines, "# define GPU_ARB_texture_gather\n");
+ strcat(defines, "#endif\n");
+ }
+ else {
+ strcat(defines, "#define GPU_ARB_texture_gather\n");
+ }
+ }
+ }
+ if (GLEW_ARB_texture_query_lod) {
+ /* a #version 400 feature, but we use #version 330 maximum so use extension */
+ strcat(defines, "#extension GL_ARB_texture_query_lod: enable\n");
+ }
+ if (GLEW_ARB_shader_draw_parameters) {
+ strcat(defines, "#extension GL_ARB_shader_draw_parameters : enable\n");
+ strcat(defines, "#define GPU_ARB_shader_draw_parameters\n");
+ }
+ if (GPU_arb_texture_cube_map_array_is_supported()) {
+ strcat(defines, "#extension GL_ARB_texture_cube_map_array : enable\n");
+ strcat(defines, "#define GPU_ARB_texture_cube_map_array\n");
+ }
+}
+
+static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH])
+{
+ /* some useful defines to detect GPU type */
+ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) {
+ strcat(defines, "#define GPU_ATI\n");
+ if (GPU_crappy_amd_driver()) {
+ strcat(defines, "#define GPU_DEPRECATED_AMD_DRIVER\n");
+ }
+ }
+ else if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY)) {
+ strcat(defines, "#define GPU_NVIDIA\n");
+ }
+ else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) {
+ strcat(defines, "#define GPU_INTEL\n");
+ }
+
+ /* some useful defines to detect OS type */
+ if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_WIN, GPU_DRIVER_ANY)) {
+ strcat(defines, "#define OS_WIN\n");
+ }
+ else if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_MAC, GPU_DRIVER_ANY)) {
+ strcat(defines, "#define OS_MAC\n");
+ }
+ else if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_UNIX, GPU_DRIVER_ANY)) {
+ strcat(defines, "#define OS_UNIX\n");
+ }
+
+ float derivatives_factors[2];
+ GPU_get_dfdy_factors(derivatives_factors);
+ if (derivatives_factors[0] == 1.0f) {
+ strcat(defines, "#define DFDX_SIGN 1.0\n");
+ }
+ else {
+ strcat(defines, "#define DFDX_SIGN -1.0\n");
+ }
+
+ if (derivatives_factors[1] == 1.0f) {
+ strcat(defines, "#define DFDY_SIGN 1.0\n");
+ }
+ else {
+ strcat(defines, "#define DFDY_SIGN -1.0\n");
+ }
+}
+
+#define DEBUG_SHADER_NONE ""
+#define DEBUG_SHADER_VERTEX "vert"
+#define DEBUG_SHADER_FRAGMENT "frag"
+#define DEBUG_SHADER_GEOMETRY "geom"
+
+/**
+ * Dump GLSL shaders to disk
+ *
+ * This is used for profiling shader performance externally and debug if shader code is correct.
+ * If called with no code, it simply bumps the shader index, so different shaders for the same
+ * program share the same index.
+ */
+static void gpu_dump_shaders(const char **code, const int num_shaders, const char *extension)
+{
+ if ((G.debug & G_DEBUG_GPU_SHADERS) == 0) {
+ return;
+ }
+
+ /* We use the same shader index for shaders in the same program.
+ * So we call this function once before calling for the individual shaders. */
+ static int shader_index = 0;
+ if (code == NULL) {
+ shader_index++;
+ BLI_assert(STREQ(DEBUG_SHADER_NONE, extension));
+ return;
+ }
+
+ /* Determine the full path of the new shader. */
+ char shader_path[FILE_MAX];
+
+ char file_name[512] = {'\0'};
+ sprintf(file_name, "%04d.%s", shader_index, extension);
+
+ BLI_join_dirfile(shader_path, sizeof(shader_path), BKE_tempdir_session(), file_name);
+
+ /* Write shader to disk. */
+ FILE *f = fopen(shader_path, "w");
+ if (f == NULL) {
+ printf("Error writing to file: %s\n", shader_path);
+ }
+ for (int j = 0; j < num_shaders; j++) {
+ fprintf(f, "%s", code[j]);
+ }
+ fclose(f);
+ printf("Shader file written to disk: %s\n", shader_path);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Creation / Destruction
+ * \{ */
+
+GPUShader *GPU_shader_create(const char *vertexcode,
+ const char *fragcode,
+ const char *geocode,
+ const char *libcode,
+ const char *defines,
+ const char *shname)
+{
+ return GPU_shader_create_ex(
+ vertexcode, fragcode, geocode, libcode, defines, GPU_SHADER_TFB_NONE, NULL, 0, shname);
+}
+
+GPUShader *GPU_shader_create_from_python(const char *vertexcode,
+ const char *fragcode,
+ const char *geocode,
+ const char *libcode,
+ const char *defines)
+{
+ char *libcodecat = NULL;
+
+ if (libcode == NULL) {
+ libcode = datatoc_gpu_shader_colorspace_lib_glsl;
+ }
+ else {
+ libcode = libcodecat = BLI_strdupcat(libcode, datatoc_gpu_shader_colorspace_lib_glsl);
+ }
+
+ GPUShader *sh = GPU_shader_create_ex(
+ vertexcode, fragcode, geocode, libcode, defines, GPU_SHADER_TFB_NONE, NULL, 0, NULL);
+
+ MEM_SAFE_FREE(libcodecat);
+ return sh;
+}
+
+GPUShader *GPU_shader_load_from_binary(const char *binary,
+ const int binary_format,
+ const int binary_len,
+ const char *shname)
+{
+ BLI_assert(GL_ARB_get_program_binary);
+ int success;
+ int program = glCreateProgram();
+
+ glProgramBinary(program, binary_format, binary, binary_len);
+ glGetProgramiv(program, GL_LINK_STATUS, &success);
+
+ if (success) {
+ glUseProgram(program);
+
+ GPUShader *shader = (GPUShader *)MEM_callocN(sizeof(*shader), __func__);
+ shader->interface = GPU_shaderinterface_create(program);
+ shader->program = program;
+
+#ifndef NDEBUG
+ BLI_snprintf(shader->name, sizeof(shader->name), "%s_%u", shname, g_shaderid++);
+#else
+ UNUSED_VARS(shname);
+#endif
+
+ return shader;
+ }
+
+ glDeleteProgram(program);
+ return NULL;
+}
+
+GPUShader *GPU_shader_create_ex(const char *vertexcode,
+ const char *fragcode,
+ const char *geocode,
+ const char *libcode,
+ const char *defines,
+ const eGPUShaderTFBType tf_type,
+ const char **tf_names,
+ const int tf_count,
+ const char *shname)
+{
+ GLint status;
+ GLchar log[5000];
+ GLsizei length = 0;
+ GPUShader *shader;
+ char standard_defines[MAX_DEFINE_LENGTH] = "";
+ char standard_extensions[MAX_EXT_DEFINE_LENGTH] = "";
+
+ shader = (GPUShader *)MEM_callocN(sizeof(GPUShader), "GPUShader");
+ gpu_dump_shaders(NULL, 0, DEBUG_SHADER_NONE);
+
+#ifndef NDEBUG
+ BLI_snprintf(shader->name, sizeof(shader->name), "%s_%u", shname, g_shaderid++);
+#else
+ UNUSED_VARS(shname);
+#endif
+
+ /* At least a vertex shader and a fragment shader are required. */
+ BLI_assert((fragcode != NULL) && (vertexcode != NULL));
+
+ if (vertexcode) {
+ shader->vertex = glCreateShader(GL_VERTEX_SHADER);
+ }
+ if (fragcode) {
+ shader->fragment = glCreateShader(GL_FRAGMENT_SHADER);
+ }
+ if (geocode) {
+ shader->geometry = glCreateShader(GL_GEOMETRY_SHADER);
+ }
+
+ shader->program = glCreateProgram();
+
+ if (!shader->program || (vertexcode && !shader->vertex) || (fragcode && !shader->fragment) ||
+ (geocode && !shader->geometry)) {
+ fprintf(stderr, "GPUShader, object creation failed.\n");
+ GPU_shader_free(shader);
+ return NULL;
+ }
+
+ gpu_shader_standard_defines(standard_defines);
+ gpu_shader_standard_extensions(standard_extensions);
+
+ if (vertexcode) {
+ const char *source[7];
+ /* custom limit, may be too small, beware */
+ int num_source = 0;
+
+ source[num_source++] = gpu_shader_version();
+ source[num_source++] =
+ "#define GPU_VERTEX_SHADER\n"
+ "#define IN_OUT out\n";
+ source[num_source++] = standard_extensions;
+ source[num_source++] = standard_defines;
+
+ if (geocode) {
+ source[num_source++] = "#define USE_GEOMETRY_SHADER\n";
+ }
+ if (defines) {
+ source[num_source++] = defines;
+ }
+ source[num_source++] = vertexcode;
+
+ gpu_dump_shaders(source, num_source, DEBUG_SHADER_VERTEX);
+
+ glAttachShader(shader->program, shader->vertex);
+ glShaderSource(shader->vertex, num_source, source, NULL);
+
+ glCompileShader(shader->vertex);
+ glGetShaderiv(shader->vertex, GL_COMPILE_STATUS, &status);
+
+ if (!status) {
+ glGetShaderInfoLog(shader->vertex, sizeof(log), &length, log);
+ shader_print_errors("compile", log, source, num_source);
+
+ GPU_shader_free(shader);
+ return NULL;
+ }
+ }
+
+ if (fragcode) {
+ const char *source[8];
+ int num_source = 0;
+
+ source[num_source++] = gpu_shader_version();
+ source[num_source++] =
+ "#define GPU_FRAGMENT_SHADER\n"
+ "#define IN_OUT in\n";
+ source[num_source++] = standard_extensions;
+ source[num_source++] = standard_defines;
+
+ if (geocode) {
+ source[num_source++] = "#define USE_GEOMETRY_SHADER\n";
+ }
+ if (defines) {
+ source[num_source++] = defines;
+ }
+ if (libcode) {
+ source[num_source++] = libcode;
+ }
+ source[num_source++] = fragcode;
+
+ gpu_dump_shaders(source, num_source, DEBUG_SHADER_FRAGMENT);
+
+ glAttachShader(shader->program, shader->fragment);
+ glShaderSource(shader->fragment, num_source, source, NULL);
+
+ glCompileShader(shader->fragment);
+ glGetShaderiv(shader->fragment, GL_COMPILE_STATUS, &status);
+
+ if (!status) {
+ glGetShaderInfoLog(shader->fragment, sizeof(log), &length, log);
+ shader_print_errors("compile", log, source, num_source);
+
+ GPU_shader_free(shader);
+ return NULL;
+ }
+ }
+
+ if (geocode) {
+ const char *source[6];
+ int num_source = 0;
+
+ source[num_source++] = gpu_shader_version();
+ source[num_source++] = "#define GPU_GEOMETRY_SHADER\n";
+ source[num_source++] = standard_extensions;
+ source[num_source++] = standard_defines;
+
+ if (defines) {
+ source[num_source++] = defines;
+ }
+ source[num_source++] = geocode;
+
+ gpu_dump_shaders(source, num_source, DEBUG_SHADER_GEOMETRY);
+
+ glAttachShader(shader->program, shader->geometry);
+ glShaderSource(shader->geometry, num_source, source, NULL);
+
+ glCompileShader(shader->geometry);
+ glGetShaderiv(shader->geometry, GL_COMPILE_STATUS, &status);
+
+ if (!status) {
+ glGetShaderInfoLog(shader->geometry, sizeof(log), &length, log);
+ shader_print_errors("compile", log, source, num_source);
+
+ GPU_shader_free(shader);
+ return NULL;
+ }
+ }
+
+ if (tf_names != NULL) {
+ glTransformFeedbackVaryings(shader->program, tf_count, tf_names, GL_INTERLEAVED_ATTRIBS);
+ /* Primitive type must be setup */
+ BLI_assert(tf_type != GPU_SHADER_TFB_NONE);
+ shader->feedback_transform_type = tf_type;
+ }
+
+ glLinkProgram(shader->program);
+ glGetProgramiv(shader->program, GL_LINK_STATUS, &status);
+ if (!status) {
+ glGetProgramInfoLog(shader->program, sizeof(log), &length, log);
+ /* print attached shaders in pipeline order */
+ if (defines) {
+ shader_print_errors("linking", log, &defines, 1);
+ }
+ if (vertexcode) {
+ shader_print_errors("linking", log, &vertexcode, 1);
+ }
+ if (geocode) {
+ shader_print_errors("linking", log, &geocode, 1);
+ }
+ if (libcode) {
+ shader_print_errors("linking", log, &libcode, 1);
+ }
+ if (fragcode) {
+ shader_print_errors("linking", log, &fragcode, 1);
+ }
+
+ GPU_shader_free(shader);
+ return NULL;
+ }
+
+ glUseProgram(shader->program);
+ shader->interface = GPU_shaderinterface_create(shader->program);
+
+ return shader;
+}
+
+#undef DEBUG_SHADER_GEOMETRY
+#undef DEBUG_SHADER_FRAGMENT
+#undef DEBUG_SHADER_VERTEX
+#undef DEBUG_SHADER_NONE
+
+void GPU_shader_free(GPUShader *shader)
+{
+#if 0 /* Would be nice to have, but for now the Deferred compilation \
+ * does not have a GPUContext. */
+ BLI_assert(GPU_context_active_get() != NULL);
+#endif
+ BLI_assert(shader);
+
+ if (shader->vertex) {
+ glDeleteShader(shader->vertex);
+ }
+ if (shader->geometry) {
+ glDeleteShader(shader->geometry);
+ }
+ if (shader->fragment) {
+ glDeleteShader(shader->fragment);
+ }
+ if (shader->program) {
+ glDeleteProgram(shader->program);
+ }
+
+ if (shader->interface) {
+ GPU_shaderinterface_discard(shader->interface);
+ }
+
+ MEM_freeN(shader);
+}
+
+static const char *string_join_array_maybe_alloc(const char **str_arr, bool *r_is_alloc)
+{
+ bool is_alloc = false;
+ if (str_arr == NULL) {
+ *r_is_alloc = false;
+ return NULL;
+ }
+ /* Skip empty strings (avoid alloc if we can). */
+ while (str_arr[0] && str_arr[0][0] == '\0') {
+ str_arr++;
+ }
+ int i;
+ for (i = 0; str_arr[i]; i++) {
+ if (i != 0 && str_arr[i][0] != '\0') {
+ is_alloc = true;
+ }
+ }
+ *r_is_alloc = is_alloc;
+ if (is_alloc) {
+ return BLI_string_join_arrayN(str_arr, i);
+ }
+
+ return str_arr[0];
+}
+
+/**
+ * Use via #GPU_shader_create_from_arrays macro (avoids passing in param).
+ *
+ * Similar to #DRW_shader_create_with_lib with the ability to include libs for each type of shader.
+ *
+ * It has the advantage that each item can be conditionally included
+ * without having to build the string inline, then free it.
+ *
+ * \param params: NULL terminated arrays of strings.
+ *
+ * Example:
+ * \code{.c}
+ * sh = GPU_shader_create_from_arrays({
+ * .vert = (const char *[]){shader_lib_glsl, shader_vert_glsl, NULL},
+ * .geom = (const char *[]){shader_geom_glsl, NULL},
+ * .frag = (const char *[]){shader_frag_glsl, NULL},
+ * .defs = (const char *[]){"#define DEFINE\n", test ? "#define OTHER_DEFINE\n" : "", NULL},
+ * });
+ * \endcode
+ */
+struct GPUShader *GPU_shader_create_from_arrays_impl(
+ const struct GPU_ShaderCreateFromArray_Params *params)
+{
+ struct {
+ const char *str;
+ bool is_alloc;
+ } str_dst[4] = {{0}};
+ const char **str_src[4] = {params->vert, params->frag, params->geom, params->defs};
+
+ for (int i = 0; i < ARRAY_SIZE(str_src); i++) {
+ str_dst[i].str = string_join_array_maybe_alloc(str_src[i], &str_dst[i].is_alloc);
+ }
+
+ GPUShader *sh = GPU_shader_create(
+ str_dst[0].str, str_dst[1].str, str_dst[2].str, NULL, str_dst[3].str, __func__);
+
+ for (int i = 0; i < ARRAY_SIZE(str_dst); i++) {
+ if (str_dst[i].is_alloc) {
+ MEM_freeN((void *)str_dst[i].str);
+ }
+ }
+ return sh;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Binding
+ * \{ */
+
+void GPU_shader_bind(GPUShader *shader)
+{
+ BLI_assert(shader && shader->program);
+
+ glUseProgram(shader->program);
+ GPU_matrix_bind(shader->interface);
+ GPU_shader_set_srgb_uniform(shader->interface);
+}
+
+void GPU_shader_unbind(void)
+{
+ glUseProgram(0);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Transform feedback
+ * \{ */
+
+bool GPU_shader_transform_feedback_enable(GPUShader *shader, uint vbo_id)
+{
+ if (shader->feedback_transform_type == GPU_SHADER_TFB_NONE) {
+ return false;
+ }
+
+ glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, vbo_id);
+
+ switch (shader->feedback_transform_type) {
+ case GPU_SHADER_TFB_POINTS:
+ glBeginTransformFeedback(GL_POINTS);
+ return true;
+ case GPU_SHADER_TFB_LINES:
+ glBeginTransformFeedback(GL_LINES);
+ return true;
+ case GPU_SHADER_TFB_TRIANGLES:
+ glBeginTransformFeedback(GL_TRIANGLES);
+ return true;
+ default:
+ return false;
+ }
+}
+
+void GPU_shader_transform_feedback_disable(GPUShader *UNUSED(shader))
+{
+ glEndTransformFeedback();
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Uniforms / Resource location
+ * \{ */
+
+int GPU_shader_get_uniform(GPUShader *shader, const char *name)
+{
+ BLI_assert(shader && shader->program);
+ const GPUShaderInput *uniform = GPU_shaderinterface_uniform(shader->interface, name);
+ return uniform ? uniform->location : -1;
+}
+
+int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
+{
+ BLI_assert(shader && shader->program);
+ return GPU_shaderinterface_uniform_builtin(shader->interface,
+ static_cast<GPUUniformBuiltin>(builtin));
+}
+
+int GPU_shader_get_builtin_block(GPUShader *shader, int builtin)
+{
+ BLI_assert(shader && shader->program);
+ return GPU_shaderinterface_block_builtin(shader->interface,
+ static_cast<GPUUniformBlockBuiltin>(builtin));
+}
+
+int GPU_shader_get_uniform_block(GPUShader *shader, const char *name)
+{
+ BLI_assert(shader && shader->program);
+ const GPUShaderInput *ubo = GPU_shaderinterface_ubo(shader->interface, name);
+ return ubo ? ubo->location : -1;
+}
+
+int GPU_shader_get_uniform_block_binding(GPUShader *shader, const char *name)
+{
+ BLI_assert(shader && shader->program);
+ const GPUShaderInput *ubo = GPU_shaderinterface_ubo(shader->interface, name);
+ return ubo ? ubo->binding : -1;
+}
+
+int GPU_shader_get_texture_binding(GPUShader *shader, const char *name)
+{
+ BLI_assert(shader && shader->program);
+ const GPUShaderInput *tex = GPU_shaderinterface_uniform(shader->interface, name);
+ return tex ? tex->binding : -1;
+}
+
+int GPU_shader_get_attribute(GPUShader *shader, const char *name)
+{
+ BLI_assert(shader && shader->program);
+ const GPUShaderInput *attr = GPU_shaderinterface_attr(shader->interface, name);
+ return attr ? attr->location : -1;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Getters
+ * \{ */
+
+/* Clement : Temp */
+int GPU_shader_get_program(GPUShader *shader)
+{
+ return (int)shader->program;
+}
+
+char *GPU_shader_get_binary(GPUShader *shader, uint *r_binary_format, int *r_binary_len)
+{
+ BLI_assert(GLEW_ARB_get_program_binary);
+ char *r_binary;
+ int binary_len = 0;
+
+ glGetProgramiv(shader->program, GL_PROGRAM_BINARY_LENGTH, &binary_len);
+ r_binary = (char *)MEM_mallocN(binary_len, __func__);
+ glGetProgramBinary(shader->program, binary_len, NULL, r_binary_format, r_binary);
+
+ if (r_binary_len) {
+ *r_binary_len = binary_len;
+ }
+
+ return r_binary;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Uniforms setters
+ * \{ */
+
+void GPU_shader_uniform_float(GPUShader *UNUSED(shader), int location, float value)
+{
+ if (location == -1) {
+ return;
+ }
+
+ glUniform1f(location, value);
+}
+
+void GPU_shader_uniform_vector(
+ GPUShader *UNUSED(shader), int location, int length, int arraysize, const float *value)
+{
+ if (location == -1 || value == NULL) {
+ return;
+ }
+
+ switch (length) {
+ case 1:
+ glUniform1fv(location, arraysize, value);
+ break;
+ case 2:
+ glUniform2fv(location, arraysize, value);
+ break;
+ case 3:
+ glUniform3fv(location, arraysize, value);
+ break;
+ case 4:
+ glUniform4fv(location, arraysize, value);
+ break;
+ case 9:
+ glUniformMatrix3fv(location, arraysize, 0, value);
+ break;
+ case 16:
+ glUniformMatrix4fv(location, arraysize, 0, value);
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
+}
+
+void GPU_shader_uniform_int(GPUShader *UNUSED(shader), int location, int value)
+{
+ if (location == -1) {
+ return;
+ }
+
+ glUniform1i(location, value);
+}
+
+void GPU_shader_uniform_vector_int(
+ GPUShader *UNUSED(shader), int location, int length, int arraysize, const int *value)
+{
+ if (location == -1) {
+ return;
+ }
+
+ switch (length) {
+ case 1:
+ glUniform1iv(location, arraysize, value);
+ break;
+ case 2:
+ glUniform2iv(location, arraysize, value);
+ break;
+ case 3:
+ glUniform3iv(location, arraysize, value);
+ break;
+ case 4:
+ glUniform4iv(location, arraysize, value);
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name sRGB Rendering Workaround
+ *
+ * The viewport overlay frame-buffer is sRGB and will expect shaders to output display referred
+ * Linear colors. But other frame-buffers (i.e: the area frame-buffers) are not sRGB and require
+ * the shader output color to be in sRGB space
+ * (assumed display encoded color-space as the time of writing).
+ * For this reason we have a uniform to switch the transform on and off depending on the current
+ * frame-buffer color-space.
+ * \{ */
+
+static int g_shader_builtin_srgb_transform = 0;
+
+void GPU_shader_set_srgb_uniform(const GPUShaderInterface *interface)
+{
+ int32_t loc = GPU_shaderinterface_uniform_builtin(interface, GPU_UNIFORM_SRGB_TRANSFORM);
+ if (loc != -1) {
+ glUniform1i(loc, g_shader_builtin_srgb_transform);
+ }
+}
+
+void GPU_shader_set_framebuffer_srgb_target(int use_srgb_to_linear)
+{
+ g_shader_builtin_srgb_transform = use_srgb_to_linear;
+}
+
+/** \} */
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader_builtin.c
index 9ea798e5669..9c0692b76e2 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader_builtin.c
@@ -153,11 +153,6 @@ const struct GPUShaderConfigData GPU_shader_cfg_data[GPU_SHADER_CFG_LEN] = {
/* cache of built-in shaders (each is created on first use) */
static GPUShader *builtin_shaders[GPU_SHADER_CFG_LEN][GPU_SHADER_BUILTIN_LEN] = {{NULL}};
-static int g_shader_builtin_srgb_transform = 0;
-
-#ifndef NDEBUG
-static uint g_shaderid = 0;
-#endif
typedef struct {
const char *vert;
@@ -168,727 +163,6 @@ typedef struct {
const char *defs;
} GPUShaderStages;
-static void shader_print_errors(const char *task, const char *log, const char **code, int totcode)
-{
- int line = 1;
-
- fprintf(stderr, "GPUShader: %s error:\n", task);
-
- for (int i = 0; i < totcode; i++) {
- const char *c, *pos, *end = code[i] + strlen(code[i]);
-
- if (G.debug & G_DEBUG) {
- fprintf(stderr, "===== shader string %d ====\n", i + 1);
-
- c = code[i];
- while ((c < end) && (pos = strchr(c, '\n'))) {
- fprintf(stderr, "%2d ", line);
- fwrite(c, (pos + 1) - c, 1, stderr);
- c = pos + 1;
- line++;
- }
-
- fprintf(stderr, "%s", c);
- }
- }
-
- fprintf(stderr, "%s\n", log);
-}
-
-static const char *gpu_shader_version(void)
-{
- return "#version 330\n";
-}
-
-static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH])
-{
- /* enable extensions for features that are not part of our base GLSL version
- * don't use an extension for something already available!
- */
-
- if (GLEW_ARB_texture_gather) {
- /* There is a bug on older Nvidia GPU where GL_ARB_texture_gather
- * is reported to be supported but yield a compile error (see T55802). */
- if (!GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY) || GLEW_VERSION_4_0) {
- strcat(defines, "#extension GL_ARB_texture_gather: enable\n");
-
- /* Some drivers don't agree on GLEW_ARB_texture_gather and the actual support in the
- * shader so double check the preprocessor define (see T56544). */
- if (!GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY) && !GLEW_VERSION_4_0) {
- strcat(defines, "#ifdef GL_ARB_texture_gather\n");
- strcat(defines, "# define GPU_ARB_texture_gather\n");
- strcat(defines, "#endif\n");
- }
- else {
- strcat(defines, "#define GPU_ARB_texture_gather\n");
- }
- }
- }
- if (GLEW_ARB_texture_query_lod) {
- /* a #version 400 feature, but we use #version 330 maximum so use extension */
- strcat(defines, "#extension GL_ARB_texture_query_lod: enable\n");
- }
- if (GLEW_ARB_shader_draw_parameters) {
- strcat(defines, "#extension GL_ARB_shader_draw_parameters : enable\n");
- }
- if (GPU_arb_texture_cube_map_array_is_supported()) {
- strcat(defines, "#extension GL_ARB_texture_cube_map_array : enable\n");
- strcat(defines, "#define GPU_ARB_texture_cube_map_array\n");
- }
-}
-
-static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH])
-{
- /* some useful defines to detect GPU type */
- if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) {
- strcat(defines, "#define GPU_ATI\n");
- if (GPU_crappy_amd_driver()) {
- strcat(defines, "#define GPU_DEPRECATED_AMD_DRIVER\n");
- }
- }
- else if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY)) {
- strcat(defines, "#define GPU_NVIDIA\n");
- }
- else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) {
- strcat(defines, "#define GPU_INTEL\n");
- }
-
- /* some useful defines to detect OS type */
- if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_WIN, GPU_DRIVER_ANY)) {
- strcat(defines, "#define OS_WIN\n");
- }
- else if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_MAC, GPU_DRIVER_ANY)) {
- strcat(defines, "#define OS_MAC\n");
- }
- else if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_UNIX, GPU_DRIVER_ANY)) {
- strcat(defines, "#define OS_UNIX\n");
- }
-
- float derivatives_factors[2];
- GPU_get_dfdy_factors(derivatives_factors);
- if (derivatives_factors[0] == 1.0f) {
- strcat(defines, "#define DFDX_SIGN 1.0\n");
- }
- else {
- strcat(defines, "#define DFDX_SIGN -1.0\n");
- }
-
- if (derivatives_factors[1] == 1.0f) {
- strcat(defines, "#define DFDY_SIGN 1.0\n");
- }
- else {
- strcat(defines, "#define DFDY_SIGN -1.0\n");
- }
-}
-
-GPUShader *GPU_shader_create(const char *vertexcode,
- const char *fragcode,
- const char *geocode,
- const char *libcode,
- const char *defines,
- const char *shname)
-{
- return GPU_shader_create_ex(
- vertexcode, fragcode, geocode, libcode, defines, GPU_SHADER_TFB_NONE, NULL, 0, shname);
-}
-
-GPUShader *GPU_shader_create_from_python(const char *vertexcode,
- const char *fragcode,
- const char *geocode,
- const char *libcode,
- const char *defines)
-{
- char *libcodecat = NULL;
-
- if (libcode == NULL) {
- libcode = datatoc_gpu_shader_colorspace_lib_glsl;
- }
- else {
- libcode = libcodecat = BLI_strdupcat(libcode, datatoc_gpu_shader_colorspace_lib_glsl);
- }
-
- GPUShader *sh = GPU_shader_create_ex(
- vertexcode, fragcode, geocode, libcode, defines, GPU_SHADER_TFB_NONE, NULL, 0, NULL);
-
- MEM_SAFE_FREE(libcodecat);
- return sh;
-}
-
-GPUShader *GPU_shader_load_from_binary(const char *binary,
- const int binary_format,
- const int binary_len,
- const char *shname)
-{
- BLI_assert(GL_ARB_get_program_binary);
- int success;
- int program = glCreateProgram();
-
- glProgramBinary(program, binary_format, binary, binary_len);
- glGetProgramiv(program, GL_LINK_STATUS, &success);
-
- if (success) {
- glUseProgram(program);
-
- GPUShader *shader = MEM_callocN(sizeof(*shader), __func__);
- shader->interface = GPU_shaderinterface_create(program);
- shader->program = program;
-
-#ifndef NDEBUG
- BLI_snprintf(shader->name, sizeof(shader->name), "%s_%u", shname, g_shaderid++);
-#else
- UNUSED_VARS(shname);
-#endif
-
- return shader;
- }
-
- glDeleteProgram(program);
- return NULL;
-}
-
-#define DEBUG_SHADER_NONE ""
-#define DEBUG_SHADER_VERTEX "vert"
-#define DEBUG_SHADER_FRAGMENT "frag"
-#define DEBUG_SHADER_GEOMETRY "geom"
-
-/**
- * Dump GLSL shaders to disk
- *
- * This is used for profiling shader performance externally and debug if shader code is correct.
- * If called with no code, it simply bumps the shader index, so different shaders for the same
- * program share the same index.
- */
-static void gpu_dump_shaders(const char **code, const int num_shaders, const char *extension)
-{
- if ((G.debug & G_DEBUG_GPU_SHADERS) == 0) {
- return;
- }
-
- /* We use the same shader index for shaders in the same program.
- * So we call this function once before calling for the individual shaders. */
- static int shader_index = 0;
- if (code == NULL) {
- shader_index++;
- BLI_assert(STREQ(DEBUG_SHADER_NONE, extension));
- return;
- }
-
- /* Determine the full path of the new shader. */
- char shader_path[FILE_MAX];
-
- char file_name[512] = {'\0'};
- sprintf(file_name, "%04d.%s", shader_index, extension);
-
- BLI_join_dirfile(shader_path, sizeof(shader_path), BKE_tempdir_session(), file_name);
-
- /* Write shader to disk. */
- FILE *f = fopen(shader_path, "w");
- if (f == NULL) {
- printf("Error writing to file: %s\n", shader_path);
- }
- for (int j = 0; j < num_shaders; j++) {
- fprintf(f, "%s", code[j]);
- }
- fclose(f);
- printf("Shader file written to disk: %s\n", shader_path);
-}
-
-GPUShader *GPU_shader_create_ex(const char *vertexcode,
- const char *fragcode,
- const char *geocode,
- const char *libcode,
- const char *defines,
- const eGPUShaderTFBType tf_type,
- const char **tf_names,
- const int tf_count,
- const char *shname)
-{
- GLint status;
- GLchar log[5000];
- GLsizei length = 0;
- GPUShader *shader;
- char standard_defines[MAX_DEFINE_LENGTH] = "";
- char standard_extensions[MAX_EXT_DEFINE_LENGTH] = "";
-
- shader = MEM_callocN(sizeof(GPUShader), "GPUShader");
- gpu_dump_shaders(NULL, 0, DEBUG_SHADER_NONE);
-
-#ifndef NDEBUG
- BLI_snprintf(shader->name, sizeof(shader->name), "%s_%u", shname, g_shaderid++);
-#else
- UNUSED_VARS(shname);
-#endif
-
- /* At least a vertex shader and a fragment shader are required. */
- BLI_assert((fragcode != NULL) && (vertexcode != NULL));
-
- if (vertexcode) {
- shader->vertex = glCreateShader(GL_VERTEX_SHADER);
- }
- if (fragcode) {
- shader->fragment = glCreateShader(GL_FRAGMENT_SHADER);
- }
- if (geocode) {
- shader->geometry = glCreateShader(GL_GEOMETRY_SHADER);
- }
-
- shader->program = glCreateProgram();
-
- if (!shader->program || (vertexcode && !shader->vertex) || (fragcode && !shader->fragment) ||
- (geocode && !shader->geometry)) {
- fprintf(stderr, "GPUShader, object creation failed.\n");
- GPU_shader_free(shader);
- return NULL;
- }
-
- gpu_shader_standard_defines(standard_defines);
- gpu_shader_standard_extensions(standard_extensions);
-
- if (vertexcode) {
- const char *source[6];
- /* custom limit, may be too small, beware */
- int num_source = 0;
-
- source[num_source++] = gpu_shader_version();
- source[num_source++] =
- "#define GPU_VERTEX_SHADER\n"
- "#define IN_OUT out\n";
- source[num_source++] = standard_extensions;
- source[num_source++] = standard_defines;
-
- if (defines) {
- source[num_source++] = defines;
- }
- source[num_source++] = vertexcode;
-
- gpu_dump_shaders(source, num_source, DEBUG_SHADER_VERTEX);
-
- glAttachShader(shader->program, shader->vertex);
- glShaderSource(shader->vertex, num_source, source, NULL);
-
- glCompileShader(shader->vertex);
- glGetShaderiv(shader->vertex, GL_COMPILE_STATUS, &status);
-
- if (!status) {
- glGetShaderInfoLog(shader->vertex, sizeof(log), &length, log);
- shader_print_errors("compile", log, source, num_source);
-
- GPU_shader_free(shader);
- return NULL;
- }
- }
-
- if (fragcode) {
- const char *source[7];
- int num_source = 0;
-
- source[num_source++] = gpu_shader_version();
- source[num_source++] =
- "#define GPU_FRAGMENT_SHADER\n"
- "#define IN_OUT in\n";
- source[num_source++] = standard_extensions;
- source[num_source++] = standard_defines;
-
- if (defines) {
- source[num_source++] = defines;
- }
- if (libcode) {
- source[num_source++] = libcode;
- }
- source[num_source++] = fragcode;
-
- gpu_dump_shaders(source, num_source, DEBUG_SHADER_FRAGMENT);
-
- glAttachShader(shader->program, shader->fragment);
- glShaderSource(shader->fragment, num_source, source, NULL);
-
- glCompileShader(shader->fragment);
- glGetShaderiv(shader->fragment, GL_COMPILE_STATUS, &status);
-
- if (!status) {
- glGetShaderInfoLog(shader->fragment, sizeof(log), &length, log);
- shader_print_errors("compile", log, source, num_source);
-
- GPU_shader_free(shader);
- return NULL;
- }
- }
-
- if (geocode) {
- const char *source[6];
- int num_source = 0;
-
- source[num_source++] = gpu_shader_version();
- source[num_source++] = "#define GPU_GEOMETRY_SHADER\n";
- source[num_source++] = standard_extensions;
- source[num_source++] = standard_defines;
-
- if (defines) {
- source[num_source++] = defines;
- }
- source[num_source++] = geocode;
-
- gpu_dump_shaders(source, num_source, DEBUG_SHADER_GEOMETRY);
-
- glAttachShader(shader->program, shader->geometry);
- glShaderSource(shader->geometry, num_source, source, NULL);
-
- glCompileShader(shader->geometry);
- glGetShaderiv(shader->geometry, GL_COMPILE_STATUS, &status);
-
- if (!status) {
- glGetShaderInfoLog(shader->geometry, sizeof(log), &length, log);
- shader_print_errors("compile", log, source, num_source);
-
- GPU_shader_free(shader);
- return NULL;
- }
- }
-
- if (tf_names != NULL) {
- glTransformFeedbackVaryings(shader->program, tf_count, tf_names, GL_INTERLEAVED_ATTRIBS);
- /* Primitive type must be setup */
- BLI_assert(tf_type != GPU_SHADER_TFB_NONE);
- shader->feedback_transform_type = tf_type;
- }
-
- glLinkProgram(shader->program);
- glGetProgramiv(shader->program, GL_LINK_STATUS, &status);
- if (!status) {
- glGetProgramInfoLog(shader->program, sizeof(log), &length, log);
- /* print attached shaders in pipeline order */
- if (vertexcode) {
- shader_print_errors("linking", log, &vertexcode, 1);
- }
- if (geocode) {
- shader_print_errors("linking", log, &geocode, 1);
- }
- if (libcode) {
- shader_print_errors("linking", log, &libcode, 1);
- }
- if (fragcode) {
- shader_print_errors("linking", log, &fragcode, 1);
- }
-
- GPU_shader_free(shader);
- return NULL;
- }
-
- glUseProgram(shader->program);
- shader->interface = GPU_shaderinterface_create(shader->program);
-
- return shader;
-}
-
-#undef DEBUG_SHADER_GEOMETRY
-#undef DEBUG_SHADER_FRAGMENT
-#undef DEBUG_SHADER_VERTEX
-#undef DEBUG_SHADER_NONE
-
-static const char *string_join_array_maybe_alloc(const char **str_arr, bool *r_is_alloc)
-{
- bool is_alloc = false;
- if (str_arr == NULL) {
- *r_is_alloc = false;
- return NULL;
- }
- /* Skip empty strings (avoid alloc if we can). */
- while (str_arr[0] && str_arr[0][0] == '\0') {
- str_arr++;
- }
- int i;
- for (i = 0; str_arr[i]; i++) {
- if (i != 0 && str_arr[i][0] != '\0') {
- is_alloc = true;
- }
- }
- *r_is_alloc = is_alloc;
- if (is_alloc) {
- return BLI_string_join_arrayN(str_arr, i);
- }
- else {
- return str_arr[0];
- }
-}
-
-/**
- * Use via #GPU_shader_create_from_arrays macro (avoids passing in param).
- *
- * Similar to #DRW_shader_create_with_lib with the ability to include libs for each type of shader.
- *
- * It has the advantage that each item can be conditionally included
- * without having to build the string inline, then free it.
- *
- * \param params: NULL terminated arrays of strings.
- *
- * Example:
- * \code{.c}
- * sh = GPU_shader_create_from_arrays({
- * .vert = (const char *[]){shader_lib_glsl, shader_vert_glsl, NULL},
- * .geom = (const char *[]){shader_geom_glsl, NULL},
- * .frag = (const char *[]){shader_frag_glsl, NULL},
- * .defs = (const char *[]){"#define DEFINE\n", test ? "#define OTHER_DEFINE\n" : "", NULL},
- * });
- * \endcode
- */
-struct GPUShader *GPU_shader_create_from_arrays_impl(
- const struct GPU_ShaderCreateFromArray_Params *params)
-{
- struct {
- const char *str;
- bool is_alloc;
- } str_dst[4] = {{0}};
- const char **str_src[4] = {params->vert, params->frag, params->geom, params->defs};
-
- for (int i = 0; i < ARRAY_SIZE(str_src); i++) {
- str_dst[i].str = string_join_array_maybe_alloc(str_src[i], &str_dst[i].is_alloc);
- }
-
- GPUShader *sh = GPU_shader_create(
- str_dst[0].str, str_dst[1].str, str_dst[2].str, NULL, str_dst[3].str, __func__);
-
- for (int i = 0; i < ARRAY_SIZE(str_dst); i++) {
- if (str_dst[i].is_alloc) {
- MEM_freeN((void *)str_dst[i].str);
- }
- }
- return sh;
-}
-
-void GPU_shader_bind(GPUShader *shader)
-{
- BLI_assert(shader && shader->program);
-
- glUseProgram(shader->program);
- GPU_matrix_bind(shader->interface);
- GPU_shader_set_srgb_uniform(shader->interface);
-}
-
-void GPU_shader_unbind(void)
-{
- glUseProgram(0);
-}
-
-bool GPU_shader_transform_feedback_enable(GPUShader *shader, uint vbo_id)
-{
- if (shader->feedback_transform_type == GPU_SHADER_TFB_NONE) {
- return false;
- }
-
- glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, vbo_id);
-
- switch (shader->feedback_transform_type) {
- case GPU_SHADER_TFB_POINTS:
- glBeginTransformFeedback(GL_POINTS);
- return true;
- case GPU_SHADER_TFB_LINES:
- glBeginTransformFeedback(GL_LINES);
- return true;
- case GPU_SHADER_TFB_TRIANGLES:
- glBeginTransformFeedback(GL_TRIANGLES);
- return true;
- default:
- return false;
- }
-}
-
-void GPU_shader_transform_feedback_disable(GPUShader *UNUSED(shader))
-{
- glEndTransformFeedback();
-}
-
-void GPU_shader_free(GPUShader *shader)
-{
-#if 0 /* Would be nice to have, but for now the Deferred compilation \
- * does not have a GPUContext. */
- BLI_assert(GPU_context_active_get() != NULL);
-#endif
- BLI_assert(shader);
-
- if (shader->vertex) {
- glDeleteShader(shader->vertex);
- }
- if (shader->geometry) {
- glDeleteShader(shader->geometry);
- }
- if (shader->fragment) {
- glDeleteShader(shader->fragment);
- }
- if (shader->program) {
- glDeleteProgram(shader->program);
- }
-
- if (shader->interface) {
- GPU_shaderinterface_discard(shader->interface);
- }
-
- MEM_freeN(shader);
-}
-
-int GPU_shader_get_uniform(GPUShader *shader, const char *name)
-{
- BLI_assert(shader && shader->program);
- const GPUShaderInput *uniform = GPU_shaderinterface_uniform(shader->interface, name);
- return uniform ? uniform->location : -1;
-}
-
-int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
-{
- BLI_assert(shader && shader->program);
- return GPU_shaderinterface_uniform_builtin(shader->interface, builtin);
-}
-
-int GPU_shader_get_builtin_block(GPUShader *shader, int builtin)
-{
- BLI_assert(shader && shader->program);
- return GPU_shaderinterface_block_builtin(shader->interface, builtin);
-}
-
-int GPU_shader_get_uniform_block(GPUShader *shader, const char *name)
-{
- BLI_assert(shader && shader->program);
- const GPUShaderInput *ubo = GPU_shaderinterface_ubo(shader->interface, name);
- return ubo ? ubo->location : -1;
-}
-
-int GPU_shader_get_uniform_block_binding(GPUShader *shader, const char *name)
-{
- BLI_assert(shader && shader->program);
- const GPUShaderInput *ubo = GPU_shaderinterface_ubo(shader->interface, name);
- return ubo ? ubo->binding : -1;
-}
-
-int GPU_shader_get_texture_binding(GPUShader *shader, const char *name)
-{
- BLI_assert(shader && shader->program);
- const GPUShaderInput *tex = GPU_shaderinterface_uniform(shader->interface, name);
- return tex ? tex->binding : -1;
-}
-
-void *GPU_shader_get_interface(GPUShader *shader)
-{
- return shader->interface;
-}
-
-/* Clement : Temp */
-int GPU_shader_get_program(GPUShader *shader)
-{
- return (int)shader->program;
-}
-
-void GPU_shader_uniform_float(GPUShader *UNUSED(shader), int location, float value)
-{
- if (location == -1) {
- return;
- }
-
- glUniform1f(location, value);
-}
-
-void GPU_shader_uniform_vector(
- GPUShader *UNUSED(shader), int location, int length, int arraysize, const float *value)
-{
- if (location == -1 || value == NULL) {
- return;
- }
-
- switch (length) {
- case 1:
- glUniform1fv(location, arraysize, value);
- break;
- case 2:
- glUniform2fv(location, arraysize, value);
- break;
- case 3:
- glUniform3fv(location, arraysize, value);
- break;
- case 4:
- glUniform4fv(location, arraysize, value);
- break;
- case 9:
- glUniformMatrix3fv(location, arraysize, 0, value);
- break;
- case 16:
- glUniformMatrix4fv(location, arraysize, 0, value);
- break;
- default:
- BLI_assert(0);
- break;
- }
-}
-
-void GPU_shader_uniform_vector_int(
- GPUShader *UNUSED(shader), int location, int length, int arraysize, const int *value)
-{
- if (location == -1) {
- return;
- }
-
- switch (length) {
- case 1:
- glUniform1iv(location, arraysize, value);
- break;
- case 2:
- glUniform2iv(location, arraysize, value);
- break;
- case 3:
- glUniform3iv(location, arraysize, value);
- break;
- case 4:
- glUniform4iv(location, arraysize, value);
- break;
- default:
- BLI_assert(0);
- break;
- }
-}
-
-void GPU_shader_uniform_int(GPUShader *UNUSED(shader), int location, int value)
-{
- if (location == -1) {
- return;
- }
-
- glUniform1i(location, value);
-}
-
-void GPU_shader_set_srgb_uniform(const GPUShaderInterface *interface)
-{
- int32_t loc = GPU_shaderinterface_uniform_builtin(interface, GPU_UNIFORM_SRGB_TRANSFORM);
- if (loc != -1) {
- glUniform1i(loc, g_shader_builtin_srgb_transform);
- }
-}
-
-int GPU_shader_get_attribute(GPUShader *shader, const char *name)
-{
- BLI_assert(shader && shader->program);
- const GPUShaderInput *attr = GPU_shaderinterface_attr(shader->interface, name);
- return attr ? attr->location : -1;
-}
-
-char *GPU_shader_get_binary(GPUShader *shader, uint *r_binary_format, int *r_binary_len)
-{
- BLI_assert(GLEW_ARB_get_program_binary);
- char *r_binary;
- int binary_len = 0;
-
- glGetProgramiv(shader->program, GL_PROGRAM_BINARY_LENGTH, &binary_len);
- r_binary = MEM_mallocN(binary_len, __func__);
- glGetProgramBinary(shader->program, binary_len, NULL, r_binary_format, r_binary);
-
- if (r_binary_len) {
- *r_binary_len = binary_len;
- }
-
- return r_binary;
-}
-
-void GPU_shader_set_framebuffer_srgb_target(int use_srgb_to_linear)
-{
- g_shader_builtin_srgb_transform = use_srgb_to_linear;
-}
-
static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = {
[GPU_SHADER_TEXT] =
{
@@ -1242,6 +516,7 @@ GPUShader *GPU_shader_get_builtin_shader_with_config(eGPUBuiltinShader shader,
return *sh_p;
}
+
GPUShader *GPU_shader_get_builtin_shader(eGPUBuiltinShader shader)
{
return GPU_shader_get_builtin_shader_with_config(shader, GPU_SHADER_CFG_DEFAULT);
diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.cc
index 9d9f98c6bb0..4511d4a199d 100644
--- a/source/blender/gpu/intern/gpu_shader_interface.c
+++ b/source/blender/gpu/intern/gpu_shader_interface.cc
@@ -33,7 +33,7 @@
#include "GPU_shader_interface.h"
#include "gpu_batch_private.h"
-#include "gpu_context_private.h"
+#include "gpu_context_private.hh"
#include <stddef.h>
#include <stdlib.h>
@@ -47,52 +47,71 @@
static const char *BuiltinUniform_name(GPUUniformBuiltin u)
{
- static const char *names[] = {
- [GPU_UNIFORM_MODEL] = "ModelMatrix",
- [GPU_UNIFORM_VIEW] = "ViewMatrix",
- [GPU_UNIFORM_MODELVIEW] = "ModelViewMatrix",
- [GPU_UNIFORM_PROJECTION] = "ProjectionMatrix",
- [GPU_UNIFORM_VIEWPROJECTION] = "ViewProjectionMatrix",
- [GPU_UNIFORM_MVP] = "ModelViewProjectionMatrix",
-
- [GPU_UNIFORM_MODEL_INV] = "ModelMatrixInverse",
- [GPU_UNIFORM_VIEW_INV] = "ViewMatrixInverse",
- [GPU_UNIFORM_MODELVIEW_INV] = "ModelViewMatrixInverse",
- [GPU_UNIFORM_PROJECTION_INV] = "ProjectionMatrixInverse",
- [GPU_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse",
-
- [GPU_UNIFORM_NORMAL] = "NormalMatrix",
- [GPU_UNIFORM_ORCO] = "OrcoTexCoFactors",
- [GPU_UNIFORM_CLIPPLANES] = "WorldClipPlanes",
-
- [GPU_UNIFORM_COLOR] = "color",
- [GPU_UNIFORM_BASE_INSTANCE] = "baseInstance",
- [GPU_UNIFORM_RESOURCE_CHUNK] = "resourceChunk",
- [GPU_UNIFORM_RESOURCE_ID] = "resourceId",
- [GPU_UNIFORM_SRGB_TRANSFORM] = "srgbTarget",
-
- [GPU_NUM_UNIFORMS] = NULL,
- };
-
- return names[u];
+ switch (u) {
+ case GPU_UNIFORM_MODEL:
+ return "ModelMatrix";
+ case GPU_UNIFORM_VIEW:
+ return "ViewMatrix";
+ case GPU_UNIFORM_MODELVIEW:
+ return "ModelViewMatrix";
+ case GPU_UNIFORM_PROJECTION:
+ return "ProjectionMatrix";
+ case GPU_UNIFORM_VIEWPROJECTION:
+ return "ViewProjectionMatrix";
+ case GPU_UNIFORM_MVP:
+ return "ModelViewProjectionMatrix";
+
+ case GPU_UNIFORM_MODEL_INV:
+ return "ModelMatrixInverse";
+ case GPU_UNIFORM_VIEW_INV:
+ return "ViewMatrixInverse";
+ case GPU_UNIFORM_MODELVIEW_INV:
+ return "ModelViewMatrixInverse";
+ case GPU_UNIFORM_PROJECTION_INV:
+ return "ProjectionMatrixInverse";
+ case GPU_UNIFORM_VIEWPROJECTION_INV:
+ return "ViewProjectionMatrixInverse";
+
+ case GPU_UNIFORM_NORMAL:
+ return "NormalMatrix";
+ case GPU_UNIFORM_ORCO:
+ return "OrcoTexCoFactors";
+ case GPU_UNIFORM_CLIPPLANES:
+ return "WorldClipPlanes";
+
+ case GPU_UNIFORM_COLOR:
+ return "color";
+ case GPU_UNIFORM_BASE_INSTANCE:
+ return "baseInstance";
+ case GPU_UNIFORM_RESOURCE_CHUNK:
+ return "resourceChunk";
+ case GPU_UNIFORM_RESOURCE_ID:
+ return "resourceId";
+ case GPU_UNIFORM_SRGB_TRANSFORM:
+ return "srgbTarget";
+
+ default:
+ return NULL;
+ }
}
static const char *BuiltinUniformBlock_name(GPUUniformBlockBuiltin u)
{
- static const char *names[] = {
- [GPU_UNIFORM_BLOCK_VIEW] = "viewBlock",
- [GPU_UNIFORM_BLOCK_MODEL] = "modelBlock",
- [GPU_UNIFORM_BLOCK_INFO] = "infoBlock",
-
- [GPU_NUM_UNIFORM_BLOCKS] = NULL,
- };
-
- return names[u];
+ switch (u) {
+ case GPU_UNIFORM_BLOCK_VIEW:
+ return "viewBlock";
+ case GPU_UNIFORM_BLOCK_MODEL:
+ return "modelBlock";
+ case GPU_UNIFORM_BLOCK_INFO:
+ return "infoBlock";
+ default:
+ return NULL;
+ }
}
GPU_INLINE bool match(const char *a, const char *b)
{
- return strcmp(a, b) == 0;
+ return STREQ(a, b);
}
GPU_INLINE uint hash_string(const char *str)
@@ -138,13 +157,12 @@ GPU_INLINE const GPUShaderInput *input_lookup(const GPUShaderInterface *shaderfa
}
return NULL; /* not found */
}
- else {
- /* This is a bit dangerous since we could have a hash collision.
- * where the asked uniform that does not exist has the same hash
- * as a real uniform. */
- BLI_assert(match(name, shaderface->name_buffer + inputs[i].name_offset));
- return inputs + i;
- }
+
+ /* This is a bit dangerous since we could have a hash collision.
+ * where the asked uniform that does not exist has the same hash
+ * as a real uniform. */
+ BLI_assert(match(name, shaderface->name_buffer + inputs[i].name_offset));
+ return inputs + i;
}
}
return NULL; /* not found */
@@ -273,7 +291,7 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program)
/* Bit set to true if uniform comes from a uniform block. */
BLI_bitmap *uniforms_from_blocks = BLI_BITMAP_NEW(active_uniform_len, __func__);
/* Set uniforms from block for exclusion. */
- GLint *ubo_uni_ids = MEM_mallocN(sizeof(GLint) * max_ubo_uni_len, __func__);
+ GLint *ubo_uni_ids = (GLint *)MEM_mallocN(sizeof(GLint) * max_ubo_uni_len, __func__);
for (int i = 0; i < ubo_len; i++) {
GLint ubo_uni_len;
glGetActiveUniformBlockiv(program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &ubo_uni_len);
@@ -291,16 +309,18 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program)
int input_tot_len = attr_len + ubo_len + uniform_len;
size_t interface_size = sizeof(GPUShaderInterface) + sizeof(GPUShaderInput) * input_tot_len;
- GPUShaderInterface *shaderface = MEM_callocN(interface_size, "GPUShaderInterface");
+ GPUShaderInterface *shaderface = (GPUShaderInterface *)MEM_callocN(interface_size,
+ "GPUShaderInterface");
shaderface->attribute_len = attr_len;
shaderface->ubo_len = ubo_len;
shaderface->uniform_len = uniform_len;
- shaderface->name_buffer = MEM_mallocN(name_buffer_len, "name_buffer");
+ shaderface->name_buffer = (char *)MEM_mallocN(name_buffer_len, "name_buffer");
GPUShaderInput *inputs = shaderface->inputs;
/* Temp buffer. */
int input_tmp_len = max_iii(attr_len, ubo_len, uniform_len);
- GPUShaderInput *inputs_tmp = MEM_mallocN(sizeof(GPUShaderInput) * input_tmp_len, "name_buffer");
+ GPUShaderInput *inputs_tmp = (GPUShaderInput *)MEM_mallocN(
+ sizeof(GPUShaderInput) * input_tmp_len, "name_buffer");
/* Attributes */
shaderface->enabled_attr_mask = 0;
@@ -366,27 +386,29 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program)
sort_input_list(inputs, inputs_tmp, shaderface->uniform_len);
/* Builtin Uniforms */
- for (GPUUniformBuiltin u = 0; u < GPU_NUM_UNIFORMS; u++) {
+ for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORMS; u_int++) {
+ GPUUniformBuiltin u = static_cast<GPUUniformBuiltin>(u_int);
shaderface->builtins[u] = glGetUniformLocation(program, BuiltinUniform_name(u));
}
/* Builtin Uniforms Blocks */
- for (GPUUniformBlockBuiltin u = 0; u < GPU_NUM_UNIFORM_BLOCKS; u++) {
+ for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORM_BLOCKS; u_int++) {
+ GPUUniformBlockBuiltin u = static_cast<GPUUniformBlockBuiltin>(u_int);
const GPUShaderInput *block = GPU_shaderinterface_ubo(shaderface, BuiltinUniformBlock_name(u));
shaderface->builtin_blocks[u] = (block != NULL) ? block->binding : -1;
}
/* Batches ref buffer */
shaderface->batches_len = GPU_SHADERINTERFACE_REF_ALLOC_COUNT;
- shaderface->batches = MEM_callocN(shaderface->batches_len * sizeof(GPUBatch *),
- "GPUShaderInterface batches");
+ shaderface->batches = (GPUBatch **)MEM_callocN(shaderface->batches_len * sizeof(GPUBatch *),
+ "GPUShaderInterface batches");
MEM_freeN(uniforms_from_blocks);
MEM_freeN(inputs_tmp);
/* Resize name buffer to save some memory. */
if (name_buffer_offset < name_buffer_len) {
- shaderface->name_buffer = MEM_reallocN(shaderface->name_buffer, name_buffer_offset);
+ shaderface->name_buffer = (char *)MEM_reallocN(shaderface->name_buffer, name_buffer_offset);
}
#if DEBUG_SHADER_INTERFACE
@@ -501,8 +523,8 @@ void GPU_shaderinterface_add_batch_ref(GPUShaderInterface *shaderface, GPUBatch
/* Not enough place, realloc the array. */
i = shaderface->batches_len;
shaderface->batches_len += GPU_SHADERINTERFACE_REF_ALLOC_COUNT;
- shaderface->batches = MEM_recallocN(shaderface->batches,
- sizeof(GPUBatch *) * shaderface->batches_len);
+ shaderface->batches = (GPUBatch **)MEM_recallocN(shaderface->batches,
+ sizeof(GPUBatch *) * shaderface->batches_len);
}
shaderface->batches[i] = batch;
}
diff --git a/source/blender/gpu/intern/gpu_shader_private.h b/source/blender/gpu/intern/gpu_shader_private.h
index 5a9a74cdfcc..0f89fbda737 100644
--- a/source/blender/gpu/intern/gpu_shader_private.h
+++ b/source/blender/gpu/intern/gpu_shader_private.h
@@ -18,8 +18,7 @@
* \ingroup gpu
*/
-#ifndef __GPU_SHADER_PRIVATE_H__
-#define __GPU_SHADER_PRIVATE_H__
+#pragma once
#include "GPU_shader_interface.h"
@@ -48,10 +47,8 @@ struct GPUShader {
};
/* XXX do not use it. Special hack to use OCIO with batch API. */
-void immGetProgram(GLuint *program, GPUShaderInterface **shaderface);
+GPUShader *immGetShader(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_SHADER_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.cc
index bd7aff9772b..794c7a3eb97 100644
--- a/source/blender/gpu/intern/gpu_state.c
+++ b/source/blender/gpu/intern/gpu_state.cc
@@ -268,6 +268,12 @@ void GPU_clip_distances(int distances_new)
distances_enabled = distances_new;
}
+bool GPU_mipmap_enabled(void)
+{
+ /* TODO(fclem) this used to be a userdef option. */
+ return true;
+}
+
/** \name GPU Push/Pop State
* \{ */
@@ -276,33 +282,18 @@ void GPU_clip_distances(int distances_new)
typedef struct {
eGPUAttrMask mask;
- /* GL_ENABLE_BIT */
+ /* GL_BLEND_BIT */
uint is_blend : 1;
- uint is_cull_face : 1;
- uint is_depth_test : 1;
- /* uint is_lighting : 1; */ /* UNUSED */
- uint is_line_smooth : 1;
- uint is_color_logic_op : 1;
- uint is_multisample : 1;
- uint is_polygon_offset_line : 1;
- uint is_polygon_offset_fill : 1;
- uint is_polygon_smooth : 1;
- uint is_sample_alpha_to_coverage : 1;
- uint is_scissor_test : 1;
- uint is_stencil_test : 1;
- uint is_framebuffer_srgb : 1;
-
- bool is_clip_plane[6];
/* GL_DEPTH_BUFFER_BIT */
- /* uint is_depth_test : 1; */
+ uint is_depth_test : 1;
int depth_func;
double depth_clear_value;
bool depth_write_mask;
/* GL_SCISSOR_BIT */
int scissor_box[4];
- /* uint is_scissor_test : 1; */
+ uint is_scissor_test : 1;
/* GL_VIEWPORT_BIT */
int viewport[4];
@@ -315,7 +306,8 @@ typedef struct {
} GPUAttrStack;
static GPUAttrStack state = {
- .top = 0,
+ {},
+ 0,
};
#define AttrStack state
@@ -338,26 +330,6 @@ void gpuPushAttr(eGPUAttrMask mask)
glGetBooleanv(GL_DEPTH_WRITEMASK, (GLboolean *)&Attr.depth_write_mask);
}
- if ((mask & GPU_ENABLE_BIT) != 0) {
- Attr.is_blend = glIsEnabled(GL_BLEND);
-
- for (int i = 0; i < 6; i++) {
- Attr.is_clip_plane[i] = glIsEnabled(GL_CLIP_PLANE0 + i);
- }
-
- Attr.is_cull_face = glIsEnabled(GL_CULL_FACE);
- Attr.is_depth_test = glIsEnabled(GL_DEPTH_TEST);
- Attr.is_line_smooth = glIsEnabled(GL_LINE_SMOOTH);
- Attr.is_color_logic_op = glIsEnabled(GL_COLOR_LOGIC_OP);
- Attr.is_multisample = glIsEnabled(GL_MULTISAMPLE);
- Attr.is_polygon_offset_line = glIsEnabled(GL_POLYGON_OFFSET_LINE);
- Attr.is_polygon_offset_fill = glIsEnabled(GL_POLYGON_OFFSET_FILL);
- Attr.is_polygon_smooth = glIsEnabled(GL_POLYGON_SMOOTH);
- Attr.is_sample_alpha_to_coverage = glIsEnabled(GL_SAMPLE_ALPHA_TO_COVERAGE);
- Attr.is_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
- Attr.is_stencil_test = glIsEnabled(GL_STENCIL_TEST);
- }
-
if ((mask & GPU_SCISSOR_BIT) != 0) {
Attr.is_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
glGetIntegerv(GL_SCISSOR_BOX, (GLint *)&Attr.scissor_box);
@@ -366,7 +338,6 @@ void gpuPushAttr(eGPUAttrMask mask)
if ((mask & GPU_VIEWPORT_BIT) != 0) {
glGetDoublev(GL_DEPTH_RANGE, (GLdouble *)&Attr.near_far);
glGetIntegerv(GL_VIEWPORT, (GLint *)&Attr.viewport);
- Attr.is_framebuffer_srgb = glIsEnabled(GL_FRAMEBUFFER_SRGB);
}
if ((mask & GPU_BLEND_BIT) != 0) {
@@ -401,30 +372,9 @@ void gpuPopAttr(void)
glDepthMask(Attr.depth_write_mask);
}
- if ((mask & GPU_ENABLE_BIT) != 0) {
- restore_mask(GL_BLEND, Attr.is_blend);
-
- for (int i = 0; i < 6; i++) {
- restore_mask(GL_CLIP_PLANE0 + i, Attr.is_clip_plane[i]);
- }
-
- restore_mask(GL_CULL_FACE, Attr.is_cull_face);
- restore_mask(GL_DEPTH_TEST, Attr.is_depth_test);
- restore_mask(GL_LINE_SMOOTH, Attr.is_line_smooth);
- restore_mask(GL_COLOR_LOGIC_OP, Attr.is_color_logic_op);
- restore_mask(GL_MULTISAMPLE, Attr.is_multisample);
- restore_mask(GL_POLYGON_OFFSET_LINE, Attr.is_polygon_offset_line);
- restore_mask(GL_POLYGON_OFFSET_FILL, Attr.is_polygon_offset_fill);
- restore_mask(GL_POLYGON_SMOOTH, Attr.is_polygon_smooth);
- restore_mask(GL_SAMPLE_ALPHA_TO_COVERAGE, Attr.is_sample_alpha_to_coverage);
- restore_mask(GL_SCISSOR_TEST, Attr.is_scissor_test);
- restore_mask(GL_STENCIL_TEST, Attr.is_stencil_test);
- }
-
if ((mask & GPU_VIEWPORT_BIT) != 0) {
glViewport(Attr.viewport[0], Attr.viewport[1], Attr.viewport[2], Attr.viewport[3]);
glDepthRange(Attr.near_far[0], Attr.near_far[1]);
- restore_mask(GL_FRAMEBUFFER_SRGB, Attr.is_framebuffer_srgb);
}
if ((mask & GPU_SCISSOR_BIT) != 0) {
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.cc
index 88424cb4cec..a45bd222664 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.cc
@@ -26,6 +26,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_image_types.h"
+#include "DNA_userdef_types.h"
#include "BLI_blenlib.h"
#include "BLI_math_base.h"
@@ -36,14 +37,13 @@
#include "GPU_batch.h"
#include "GPU_context.h"
#include "GPU_debug.h"
-#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_framebuffer.h"
#include "GPU_glew.h"
#include "GPU_platform.h"
#include "GPU_texture.h"
-#include "gpu_context_private.h"
+#include "gpu_context_private.hh"
#define WARN_NOT_BOUND(_tex) \
{ \
@@ -81,6 +81,8 @@ typedef enum eGPUTextureFormatFlag {
GPU_FORMAT_ARRAY = (1 << 14),
} eGPUTextureFormatFlag;
+ENUM_OPERATORS(eGPUTextureFormatFlag)
+
/* GPUTexture */
struct GPUTexture {
int w, h, d; /* width/height/depth */
@@ -113,7 +115,7 @@ static void gpu_texture_framebuffer_ensure(GPUTexture *tex);
/* ------ Memory Management ------- */
/* Records every texture allocation / free
* to estimate the Texture Pool Memory consumption */
-static uint memory_usage;
+static uint memory_usage = 0;
static uint gpu_texture_memory_footprint_compute(GPUTexture *tex)
{
@@ -171,54 +173,58 @@ uint GPU_texture_memory_usage_get(void)
static const char *gl_enum_to_str(GLenum e)
{
-#define ENUM_TO_STRING(e) [GL_##e] = STRINGIFY_ARG(e)
- static const char *enum_strings[] = {
- ENUM_TO_STRING(TEXTURE_CUBE_MAP),
- ENUM_TO_STRING(TEXTURE_CUBE_MAP_ARRAY),
- ENUM_TO_STRING(TEXTURE_2D),
- ENUM_TO_STRING(TEXTURE_2D_ARRAY),
- ENUM_TO_STRING(TEXTURE_1D),
- ENUM_TO_STRING(TEXTURE_1D_ARRAY),
- ENUM_TO_STRING(TEXTURE_3D),
- ENUM_TO_STRING(TEXTURE_2D_MULTISAMPLE),
- ENUM_TO_STRING(RGBA32F),
- ENUM_TO_STRING(RGBA16F),
- ENUM_TO_STRING(RGBA16UI),
- ENUM_TO_STRING(RGBA16I),
- ENUM_TO_STRING(RGBA16),
- ENUM_TO_STRING(RGBA8UI),
- ENUM_TO_STRING(RGBA8I),
- ENUM_TO_STRING(RGBA8),
- ENUM_TO_STRING(RGB16F),
- ENUM_TO_STRING(RG32F),
- ENUM_TO_STRING(RG16F),
- ENUM_TO_STRING(RG16UI),
- ENUM_TO_STRING(RG16I),
- ENUM_TO_STRING(RG16),
- ENUM_TO_STRING(RG8UI),
- ENUM_TO_STRING(RG8I),
- ENUM_TO_STRING(RG8),
- ENUM_TO_STRING(R8UI),
- ENUM_TO_STRING(R8I),
- ENUM_TO_STRING(R8),
- ENUM_TO_STRING(R32F),
- ENUM_TO_STRING(R32UI),
- ENUM_TO_STRING(R32I),
- ENUM_TO_STRING(R16F),
- ENUM_TO_STRING(R16UI),
- ENUM_TO_STRING(R16I),
- ENUM_TO_STRING(R16),
- ENUM_TO_STRING(R11F_G11F_B10F),
- ENUM_TO_STRING(SRGB8_ALPHA8),
- ENUM_TO_STRING(DEPTH24_STENCIL8),
- ENUM_TO_STRING(DEPTH32F_STENCIL8),
- ENUM_TO_STRING(DEPTH_COMPONENT32F),
- ENUM_TO_STRING(DEPTH_COMPONENT24),
- ENUM_TO_STRING(DEPTH_COMPONENT16),
+#define ENUM_TO_STRING(e) \
+ case GL_##e: { \
+ return STRINGIFY_ARG(e); \
+ }
+
+ switch (e) {
+ ENUM_TO_STRING(TEXTURE_CUBE_MAP);
+ ENUM_TO_STRING(TEXTURE_CUBE_MAP_ARRAY);
+ ENUM_TO_STRING(TEXTURE_2D);
+ ENUM_TO_STRING(TEXTURE_2D_ARRAY);
+ ENUM_TO_STRING(TEXTURE_1D);
+ ENUM_TO_STRING(TEXTURE_1D_ARRAY);
+ ENUM_TO_STRING(TEXTURE_3D);
+ ENUM_TO_STRING(TEXTURE_2D_MULTISAMPLE);
+ ENUM_TO_STRING(RGBA32F);
+ ENUM_TO_STRING(RGBA16F);
+ ENUM_TO_STRING(RGBA16UI);
+ ENUM_TO_STRING(RGBA16I);
+ ENUM_TO_STRING(RGBA16);
+ ENUM_TO_STRING(RGBA8UI);
+ ENUM_TO_STRING(RGBA8I);
+ ENUM_TO_STRING(RGBA8);
+ ENUM_TO_STRING(RGB16F);
+ ENUM_TO_STRING(RG32F);
+ ENUM_TO_STRING(RG16F);
+ ENUM_TO_STRING(RG16UI);
+ ENUM_TO_STRING(RG16I);
+ ENUM_TO_STRING(RG16);
+ ENUM_TO_STRING(RG8UI);
+ ENUM_TO_STRING(RG8I);
+ ENUM_TO_STRING(RG8);
+ ENUM_TO_STRING(R8UI);
+ ENUM_TO_STRING(R8I);
+ ENUM_TO_STRING(R8);
+ ENUM_TO_STRING(R32F);
+ ENUM_TO_STRING(R32UI);
+ ENUM_TO_STRING(R32I);
+ ENUM_TO_STRING(R16F);
+ ENUM_TO_STRING(R16UI);
+ ENUM_TO_STRING(R16I);
+ ENUM_TO_STRING(R16);
+ ENUM_TO_STRING(R11F_G11F_B10F);
+ ENUM_TO_STRING(SRGB8_ALPHA8);
+ ENUM_TO_STRING(DEPTH24_STENCIL8);
+ ENUM_TO_STRING(DEPTH32F_STENCIL8);
+ ENUM_TO_STRING(DEPTH_COMPONENT32F);
+ ENUM_TO_STRING(DEPTH_COMPONENT24);
+ ENUM_TO_STRING(DEPTH_COMPONENT16);
+ default:
+ return "Unkown enum";
};
#undef ENUM_TO_STRING
-
- return enum_strings[e];
}
static int gpu_get_component_count(eGPUTextureFormat format)
@@ -306,31 +312,28 @@ static eGPUDataFormat gpu_get_data_format_from_tex_format(eGPUTextureFormat tex_
if (ELEM(tex_format, GPU_DEPTH_COMPONENT24, GPU_DEPTH_COMPONENT16, GPU_DEPTH_COMPONENT32F)) {
return GPU_DATA_FLOAT;
}
- else if (ELEM(tex_format, GPU_DEPTH24_STENCIL8, GPU_DEPTH32F_STENCIL8)) {
+ if (ELEM(tex_format, GPU_DEPTH24_STENCIL8, GPU_DEPTH32F_STENCIL8)) {
return GPU_DATA_UNSIGNED_INT_24_8;
}
- else {
- /* Integer formats */
- if (ELEM(tex_format, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R8UI, GPU_R16UI, GPU_R32UI)) {
- if (ELEM(tex_format, GPU_R8UI, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) {
- return GPU_DATA_UNSIGNED_INT;
- }
- else {
- return GPU_DATA_INT;
- }
- }
- /* Byte formats */
- else if (ELEM(tex_format, GPU_R8)) {
- return GPU_DATA_UNSIGNED_BYTE;
- }
- /* Special case */
- else if (ELEM(tex_format, GPU_R11F_G11F_B10F)) {
- return GPU_DATA_10_11_11_REV;
- }
- else {
- return GPU_DATA_FLOAT;
+
+ /* Integer formats */
+ if (ELEM(tex_format, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R8UI, GPU_R16UI, GPU_R32UI)) {
+ if (ELEM(tex_format, GPU_R8UI, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) {
+ return GPU_DATA_UNSIGNED_INT;
}
+
+ return GPU_DATA_INT;
+ }
+ /* Byte formats */
+ if (ELEM(tex_format, GPU_R8)) {
+ return GPU_DATA_UNSIGNED_BYTE;
}
+ /* Special case */
+ if (ELEM(tex_format, GPU_R11F_G11F_B10F)) {
+ return GPU_DATA_10_11_11_REV;
+ }
+
+ return GPU_DATA_FLOAT;
}
/* Definitely not complete, edit according to the gl specification. */
@@ -341,51 +344,50 @@ static GLenum gpu_get_gl_dataformat(eGPUTextureFormat data_type,
*format_flag |= GPU_FORMAT_DEPTH;
return GL_DEPTH_COMPONENT;
}
- else if (ELEM(data_type, GPU_DEPTH24_STENCIL8, GPU_DEPTH32F_STENCIL8)) {
+ if (ELEM(data_type, GPU_DEPTH24_STENCIL8, GPU_DEPTH32F_STENCIL8)) {
*format_flag |= GPU_FORMAT_DEPTH | GPU_FORMAT_STENCIL;
return GL_DEPTH_STENCIL;
}
- else {
- /* Integer formats */
- if (ELEM(data_type, GPU_R8UI, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) {
- *format_flag |= GPU_FORMAT_INTEGER;
- switch (gpu_get_component_count(data_type)) {
- case 1:
- return GL_RED_INTEGER;
- break;
- case 2:
- return GL_RG_INTEGER;
- break;
- case 3:
- return GL_RGB_INTEGER;
- break;
- case 4:
- return GL_RGBA_INTEGER;
- break;
- }
- }
- else if (ELEM(data_type, GPU_R8)) {
- *format_flag |= GPU_FORMAT_FLOAT;
- return GL_RED;
+ /* Integer formats */
+ if (ELEM(data_type, GPU_R8UI, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) {
+ *format_flag |= GPU_FORMAT_INTEGER;
+
+ switch (gpu_get_component_count(data_type)) {
+ case 1:
+ return GL_RED_INTEGER;
+ break;
+ case 2:
+ return GL_RG_INTEGER;
+ break;
+ case 3:
+ return GL_RGB_INTEGER;
+ break;
+ case 4:
+ return GL_RGBA_INTEGER;
+ break;
}
- else {
- *format_flag |= GPU_FORMAT_FLOAT;
+ }
+ else if (ELEM(data_type, GPU_R8)) {
+ *format_flag |= GPU_FORMAT_FLOAT;
+ return GL_RED;
+ }
+ else {
+ *format_flag |= GPU_FORMAT_FLOAT;
- switch (gpu_get_component_count(data_type)) {
- case 1:
- return GL_RED;
- break;
- case 2:
- return GL_RG;
- break;
- case 3:
- return GL_RGB;
- break;
- case 4:
- return GL_RGBA;
- break;
- }
+ switch (gpu_get_component_count(data_type)) {
+ case 1:
+ return GL_RED;
+ break;
+ case 2:
+ return GL_RG;
+ break;
+ case 3:
+ return GL_RGB;
+ break;
+ case 4:
+ return GL_RGBA;
+ break;
}
}
@@ -433,6 +435,13 @@ static uint gpu_get_bytesize(eGPUTextureFormat data_type)
case GPU_R8:
case GPU_R8UI:
return 1;
+ case GPU_SRGB8_A8_DXT1:
+ case GPU_SRGB8_A8_DXT3:
+ case GPU_SRGB8_A8_DXT5:
+ case GPU_RGBA8_DXT1:
+ case GPU_RGBA8_DXT3:
+ case GPU_RGBA8_DXT5:
+ return 1; /* Incorrect but actual size is fractional. */
default:
BLI_assert(!"Texture format incorrect or unsupported\n");
return 0;
@@ -518,7 +527,18 @@ static GLenum gpu_format_to_gl_internalformat(eGPUTextureFormat format)
case GPU_RGB16F:
return GL_RGB16F;
/* Special formats texture only */
- /* ** Add Format here */
+ case GPU_SRGB8_A8_DXT1:
+ return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
+ case GPU_SRGB8_A8_DXT3:
+ return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
+ case GPU_SRGB8_A8_DXT5:
+ return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
+ case GPU_RGBA8_DXT1:
+ return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
+ case GPU_RGBA8_DXT3:
+ return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
+ case GPU_RGBA8_DXT5:
+ return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
/* Depth Formats */
case GPU_DEPTH_COMPONENT32F:
return GL_DEPTH_COMPONENT32F;
@@ -532,99 +552,6 @@ static GLenum gpu_format_to_gl_internalformat(eGPUTextureFormat format)
}
}
-static eGPUTextureFormat gl_internalformat_to_gpu_format(const GLint glformat)
-{
- /* You can add any of the available type to this list
- * For available types see GPU_texture.h */
- switch (glformat) {
- /* Formats texture & renderbuffer */
- case GL_RGBA8UI:
- return GPU_RGBA8UI;
- case GL_RGBA8I:
- return GPU_RGBA8I;
- case GL_RGBA8:
- return GPU_RGBA8;
- case GL_RGBA32UI:
- return GPU_RGBA32UI;
- case GL_RGBA32I:
- return GPU_RGBA32I;
- case GL_RGBA32F:
- return GPU_RGBA32F;
- case GL_RGBA16UI:
- return GPU_RGBA16UI;
- case GL_RGBA16I:
- return GPU_RGBA16I;
- case GL_RGBA16F:
- return GPU_RGBA16F;
- case GL_RGBA16:
- return GPU_RGBA16;
- case GL_RG8UI:
- return GPU_RG8UI;
- case GL_RG8I:
- return GPU_RG8I;
- case GL_RG8:
- return GPU_RG8;
- case GL_RG32UI:
- return GPU_RG32UI;
- case GL_RG32I:
- return GPU_RG32I;
- case GL_RG32F:
- return GPU_RG32F;
- case GL_RG16UI:
- return GPU_RG16UI;
- case GL_RG16I:
- return GPU_RG16I;
- case GL_RG16F:
- return GPU_RGBA32F;
- case GL_RG16:
- return GPU_RG16;
- case GL_R8UI:
- return GPU_R8UI;
- case GL_R8I:
- return GPU_R8I;
- case GL_R8:
- return GPU_R8;
- case GL_R32UI:
- return GPU_R32UI;
- case GL_R32I:
- return GPU_R32I;
- case GL_R32F:
- return GPU_R32F;
- case GL_R16UI:
- return GPU_R16UI;
- case GL_R16I:
- return GPU_R16I;
- case GL_R16F:
- return GPU_R16F;
- case GL_R16:
- return GPU_R16;
- /* Special formats texture & renderbuffer */
- case GL_R11F_G11F_B10F:
- return GPU_R11F_G11F_B10F;
- case GL_DEPTH32F_STENCIL8:
- return GPU_DEPTH32F_STENCIL8;
- case GL_DEPTH24_STENCIL8:
- return GPU_DEPTH24_STENCIL8;
- case GL_SRGB8_ALPHA8:
- return GPU_SRGB8_A8;
- /* Texture only format */
- case GL_RGB16F:
- return GPU_RGB16F;
- /* Special formats texture only */
- /* ** Add Format here */
- /* Depth Formats */
- case GL_DEPTH_COMPONENT32F:
- return GPU_DEPTH_COMPONENT32F;
- case GL_DEPTH_COMPONENT24:
- return GPU_DEPTH_COMPONENT24;
- case GL_DEPTH_COMPONENT16:
- return GPU_DEPTH_COMPONENT16;
- default:
- BLI_assert(!"Internal format incorrect or unsupported\n");
- }
- return -1;
-}
-
static GLenum gpu_get_gl_datatype(eGPUDataFormat format)
{
switch (format) {
@@ -650,8 +577,8 @@ static float *GPU_texture_rescale_3d(
GPUTexture *tex, int w, int h, int d, int channels, const float *fpixels)
{
const uint xf = w / tex->w, yf = h / tex->h, zf = d / tex->d;
- float *nfpixels = MEM_mallocN(channels * sizeof(float) * tex->w * tex->h * tex->d,
- "GPUTexture Rescaled 3Dtex");
+ float *nfpixels = (float *)MEM_mallocN(channels * sizeof(float) * tex->w * tex->h * tex->d,
+ "GPUTexture Rescaled 3Dtex");
if (nfpixels) {
GPU_print_error_debug("You need to scale a 3D texture, feel the pain!");
@@ -687,6 +614,13 @@ static float *GPU_texture_rescale_3d(
static bool gpu_texture_check_capacity(
GPUTexture *tex, GLenum proxy, GLenum internalformat, GLenum data_format, GLenum data_type)
{
+ if (proxy == GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB &&
+ GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_MAC, GPU_DRIVER_ANY)) {
+ /* Special fix for T79703. */
+ /* Depth has already been checked. */
+ return tex->w <= GPU_max_cube_map_size();
+ }
+
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_WIN, GPU_DRIVER_ANY) ||
GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_OFFICIAL) ||
GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OFFICIAL)) {
@@ -736,26 +670,30 @@ static bool gpu_texture_check_capacity(
return true;
}
- else {
- switch (proxy) {
- case GL_PROXY_TEXTURE_1D:
- glTexImage1D(proxy, 0, internalformat, tex->w, 0, data_format, data_type, NULL);
- break;
- case GL_PROXY_TEXTURE_1D_ARRAY:
- case GL_PROXY_TEXTURE_2D:
- glTexImage2D(proxy, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, NULL);
- break;
- case GL_PROXY_TEXTURE_2D_ARRAY:
- case GL_PROXY_TEXTURE_3D:
- glTexImage3D(
- proxy, 0, internalformat, tex->w, tex->h, tex->d, 0, data_format, data_type, NULL);
- break;
- }
- int width = 0;
- glGetTexLevelParameteriv(proxy, 0, GL_TEXTURE_WIDTH, &width);
- return (width > 0);
+ switch (proxy) {
+ case GL_PROXY_TEXTURE_1D:
+ glTexImage1D(proxy, 0, internalformat, tex->w, 0, data_format, data_type, NULL);
+ break;
+ case GL_PROXY_TEXTURE_1D_ARRAY:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
+ glTexImage2D(proxy, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, NULL);
+ break;
+ case GL_PROXY_TEXTURE_2D_ARRAY:
+ case GL_PROXY_TEXTURE_3D:
+ glTexImage3D(
+ proxy, 0, internalformat, tex->w, tex->h, tex->d, 0, data_format, data_type, NULL);
+ break;
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB:
+ glTexImage3D(
+ proxy, 0, internalformat, tex->w, tex->h, tex->d * 6, 0, data_format, data_type, NULL);
+ break;
}
+ int width = 0;
+ glGetTexLevelParameteriv(proxy, 0, GL_TEXTURE_WIDTH, &width);
+
+ return (width > 0);
}
/* This tries to allocate video memory for a given texture
@@ -774,8 +712,11 @@ static bool gpu_texture_try_alloc(GPUTexture *tex,
ret = gpu_texture_check_capacity(tex, proxy, internalformat, data_format, data_type);
if (!ret && try_rescale) {
- BLI_assert(
- !ELEM(proxy, GL_PROXY_TEXTURE_1D_ARRAY, GL_PROXY_TEXTURE_2D_ARRAY)); // not implemented
+ BLI_assert(!ELEM(proxy,
+ GL_PROXY_TEXTURE_1D_ARRAY,
+ GL_PROXY_TEXTURE_2D_ARRAY,
+ GL_PROXY_TEXTURE_CUBE_MAP,
+ GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB)); // not implemented
const int w = tex->w, h = tex->h, d = tex->d;
@@ -838,7 +779,7 @@ GPUTexture *GPU_texture_create_nD(int w,
tex_format = GPU_DEPTH32F_STENCIL8;
}
- GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture");
+ GPUTexture *tex = (GPUTexture *)MEM_callocN(sizeof(GPUTexture), __func__);
tex->w = w;
tex->h = h;
tex->d = d;
@@ -847,7 +788,7 @@ GPUTexture *GPU_texture_create_nD(int w,
tex->format = tex_format;
tex->components = gpu_get_component_count(tex_format);
tex->mipmaps = 0;
- tex->format_flag = 0;
+ tex->format_flag = static_cast<eGPUTextureFormatFlag>(0);
tex->number = -1;
if (n == 2) {
@@ -931,18 +872,20 @@ GPUTexture *GPU_texture_create_nD(int w,
data_type,
tex->components,
can_rescale,
- pixels,
+ (float *)pixels,
&rescaled_pixels);
if (G.debug & G_DEBUG_GPU || !valid) {
- printf("GPUTexture: create : %s, %s, w : %d, h : %d, d : %d, comp : %d, size : %.2f MiB\n",
- gl_enum_to_str(tex->target),
- gl_enum_to_str(internalformat),
- w,
- h,
- d,
- tex->components,
- gpu_texture_memory_footprint_compute(tex) / 1048576.0f);
+ printf(
+ "GPUTexture: create : %s,\t w : %5d, h : %5d, d : %5d, comp : %4d, size : %.2f "
+ "MiB,\t %s\n",
+ gl_enum_to_str(tex->target),
+ w,
+ h,
+ d,
+ tex->components,
+ gpu_texture_memory_footprint_compute(tex) / 1048576.0f,
+ gl_enum_to_str(internalformat));
}
if (!valid) {
@@ -962,7 +905,7 @@ GPUTexture *GPU_texture_create_nD(int w,
gpu_texture_memory_footprint_add(tex);
/* Upload Texture */
- const float *pix = (rescaled_pixels) ? rescaled_pixels : pixels;
+ const void *pix = (rescaled_pixels) ? rescaled_pixels : pixels;
if (tex->target == GL_TEXTURE_2D || tex->target == GL_TEXTURE_2D_MULTISAMPLE ||
tex->target == GL_TEXTURE_1D_ARRAY) {
@@ -1012,7 +955,7 @@ GPUTexture *GPU_texture_cube_create(int w,
eGPUDataFormat gpu_data_format,
char err_out[256])
{
- GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture");
+ GPUTexture *tex = (GPUTexture *)MEM_callocN(sizeof(GPUTexture), __func__);
tex->w = w;
tex->h = w;
tex->d = d;
@@ -1024,10 +967,14 @@ GPUTexture *GPU_texture_cube_create(int w,
tex->format_flag = GPU_FORMAT_CUBE;
tex->number = -1;
+ GLenum proxy;
+
if (d == 0) {
+ proxy = GL_PROXY_TEXTURE_CUBE_MAP;
tex->target_base = tex->target = GL_TEXTURE_CUBE_MAP;
}
else {
+ proxy = GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB;
tex->target_base = tex->target = GL_TEXTURE_CUBE_MAP_ARRAY_ARB;
tex->format_flag |= GPU_FORMAT_ARRAY;
@@ -1063,15 +1010,36 @@ GPUTexture *GPU_texture_cube_create(int w,
return NULL;
}
- if (G.debug & G_DEBUG_GPU) {
- printf("GPUTexture: create : %s, %s, w : %d, h : %d, d : %d, comp : %d, size : %.2f MiB\n",
- gl_enum_to_str(tex->target),
- gl_enum_to_str(internalformat),
- w,
- w,
- d,
- tex->components,
- gpu_texture_memory_footprint_compute(tex) / 1048576.0f);
+ bool valid = gpu_texture_try_alloc(
+ tex, proxy, internalformat, data_format, data_type, tex->components, false, NULL, NULL);
+
+ if (G.debug & G_DEBUG_GPU || !valid) {
+ printf(
+ "GPUTexture: create : %s,\t w : %5d, h : %5d, d : %5d, comp : %4d, size : %.2f "
+ "MiB,\t %s\n",
+ gl_enum_to_str(tex->target),
+ w,
+ w,
+ d * 6,
+ tex->components,
+ gpu_texture_memory_footprint_compute(tex) / 1048576.0f,
+ gl_enum_to_str(internalformat));
+ }
+
+ if (!valid) {
+ if (err_out) {
+ BLI_strncpy(err_out, "GPUTexture: texture alloc failed\n", 256);
+ }
+ else {
+ fprintf(stderr,
+ "GPUTexture: texture alloc failed. Likely not enough Video Memory or the requested "
+ "size is not supported by the implementation.\n");
+ fprintf(stderr,
+ "Current texture memory usage : %.2f MiB.\n",
+ gpu_texture_memory_footprint_compute(tex) / 1048576.0f);
+ }
+ GPU_texture_free(tex);
+ return NULL;
}
gpu_texture_memory_footprint_add(tex);
@@ -1136,11 +1104,11 @@ GPUTexture *GPU_texture_cube_create(int w,
/* Special buffer textures. tex_format must be compatible with the buffer content. */
GPUTexture *GPU_texture_create_buffer(eGPUTextureFormat tex_format, const GLuint buffer)
{
- GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture");
+ GPUTexture *tex = (GPUTexture *)MEM_callocN(sizeof(GPUTexture), __func__);
tex->refcount = 1;
tex->format = tex_format;
tex->components = gpu_get_component_count(tex_format);
- tex->format_flag = 0;
+ tex->format_flag = static_cast<eGPUTextureFormatFlag>(0);
tex->target_base = tex->target = GL_TEXTURE_BUFFER;
tex->mipmaps = 0;
tex->number = -1;
@@ -1186,63 +1154,87 @@ GPUTexture *GPU_texture_create_buffer(eGPUTextureFormat tex_format, const GLuint
return tex;
}
-static GLenum convert_target_to_gl(eGPUTextureTarget target)
+static GLenum convert_target_to_gl(int dimension, bool is_array)
{
- switch (target) {
- case TEXTARGET_2D:
- return GL_TEXTURE_2D;
- case TEXTARGET_CUBE_MAP:
- return GL_TEXTURE_CUBE_MAP;
- case TEXTARGET_2D_ARRAY:
- return GL_TEXTURE_2D_ARRAY;
- case TEXTARGET_TILE_MAPPING:
- return GL_TEXTURE_1D_ARRAY;
+ switch (dimension) {
+ case 1:
+ return is_array ? GL_TEXTURE_1D : GL_TEXTURE_1D_ARRAY;
+ case 2:
+ return is_array ? GL_TEXTURE_2D : GL_TEXTURE_2D_ARRAY;
+ case 3:
+ return GL_TEXTURE_3D;
default:
BLI_assert(0);
return GL_TEXTURE_2D;
}
}
-GPUTexture *GPU_texture_from_bindcode(eGPUTextureTarget target, int bindcode)
+/* Create an error texture that will bind an invalid texture (pink) at draw time. */
+GPUTexture *GPU_texture_create_error(int dimension, bool is_array)
{
- GLenum textarget = convert_target_to_gl(target);
+ GLenum textarget = convert_target_to_gl(dimension, is_array);
- GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture");
- tex->bindcode = bindcode;
+ GPUTexture *tex = (GPUTexture *)MEM_callocN(sizeof(GPUTexture), __func__);
+ tex->bindcode = 0;
tex->refcount = 1;
tex->target = textarget;
tex->target_base = textarget;
tex->samples = 0;
- tex->sampler_state = GPU_SAMPLER_REPEAT | GPU_SAMPLER_ANISO;
- if (GPU_get_mipmap()) {
- tex->sampler_state |= (GPU_SAMPLER_MIPMAP | GPU_SAMPLER_FILTER);
- }
+ tex->sampler_state = GPU_SAMPLER_DEFAULT;
tex->number = -1;
- if (!glIsTexture(tex->bindcode)) {
- GPU_print_error_debug("Blender Texture Not Loaded");
+ GPU_print_error_debug("Blender Texture Not Loaded");
+ return tex;
+}
+
+/* DDS texture loading. Return NULL if support is not available. */
+GPUTexture *GPU_texture_create_compressed(
+ int w, int h, int miplen, eGPUTextureFormat tex_format, const void *data)
+{
+ if (!GLEW_EXT_texture_compression_s3tc) {
+ return NULL;
}
- else {
- GLint w, h, gl_format;
- GLenum gettarget;
- gettarget = (textarget == GL_TEXTURE_CUBE_MAP) ? GL_TEXTURE_CUBE_MAP_POSITIVE_X : textarget;
-
- glBindTexture(textarget, tex->bindcode);
- glGetTexLevelParameteriv(gettarget, 0, GL_TEXTURE_WIDTH, &w);
- glGetTexLevelParameteriv(gettarget, 0, GL_TEXTURE_HEIGHT, &h);
- glGetTexLevelParameteriv(gettarget, 0, GL_TEXTURE_INTERNAL_FORMAT, &gl_format);
- tex->w = w;
- tex->h = h;
- tex->format = gl_internalformat_to_gpu_format(gl_format);
- tex->components = gpu_get_component_count(tex->format);
- glBindTexture(textarget, 0);
-
- /* Depending on how this bindcode was obtained, the memory used here could
- * already have been computed.
- * But that is not the case currently. */
- gpu_texture_memory_footprint_add(tex);
+
+ GPUTexture *tex = (GPUTexture *)MEM_callocN(sizeof(GPUTexture), __func__);
+ tex->w = w;
+ tex->h = h;
+ tex->refcount = 1;
+ tex->target = tex->target_base = GL_TEXTURE_2D;
+ tex->format_flag = static_cast<eGPUTextureFormatFlag>(0);
+ tex->components = gpu_get_component_count(tex_format);
+ tex->mipmaps = miplen - 1;
+ tex->sampler_state = GPU_SAMPLER_DEFAULT;
+ tex->number = -1;
+
+ GLenum internalformat = gpu_format_to_gl_internalformat(tex_format);
+
+ glGenTextures(1, &tex->bindcode);
+ glBindTexture(tex->target, tex->bindcode);
+
+ /* Reset to opengl Defaults. (Untested, might not be needed) */
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+
+ int blocksize = (ELEM(tex_format, GPU_RGBA8_DXT1, GPU_SRGB8_A8_DXT1)) ? 8 : 16;
+
+ size_t ofs = 0;
+ for (int mip = 0; mip < miplen && (w || h); mip++, w >>= 1, h >>= 1) {
+ w = max_ii(1, w);
+ h = max_ii(1, h);
+ size_t size = ((w + 3) / 4) * ((h + 3) / 4) * blocksize;
+
+ glCompressedTexImage2D(tex->target, mip, internalformat, w, h, 0, size, (uchar *)data + ofs);
+
+ ofs += size;
}
+ /* Restore Blender default. */
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glTexParameteri(tex->target, GL_TEXTURE_MAX_LEVEL, tex->mipmaps);
+ glTexParameteri(tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ glBindTexture(tex->target, 0);
+
return tex;
}
@@ -1962,6 +1954,14 @@ void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter)
SET_FLAG_FROM_TEST(tex->sampler_state, use_filter, GPU_SAMPLER_FILTER);
}
+void GPU_texture_anisotropic_filter(GPUTexture *tex, bool use_aniso)
+{
+ /* Stencil and integer format does not support filtering. */
+ BLI_assert(!(use_aniso) || !(GPU_texture_stencil(tex) || GPU_texture_integer(tex)));
+
+ SET_FLAG_FROM_TEST(tex->sampler_state, use_aniso, GPU_SAMPLER_ANISO);
+}
+
void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat, bool use_clamp)
{
SET_FLAG_FROM_TEST(tex->sampler_state, use_repeat, GPU_SAMPLER_REPEAT);
@@ -2176,7 +2176,7 @@ void GPU_samplers_init(void)
{
glGenSamplers(GPU_SAMPLER_MAX, GG.samplers);
for (int i = 0; i < GPU_SAMPLER_MAX; i++) {
- eGPUSamplerState state = i;
+ eGPUSamplerState state = static_cast<eGPUSamplerState>(i);
GLenum clamp_type = (state & GPU_SAMPLER_CLAMP_BORDER) ? GL_CLAMP_TO_BORDER : GL_CLAMP_TO_EDGE;
GLenum wrap_s = (state & GPU_SAMPLER_REPEAT_S) ? GL_REPEAT : clamp_type;
GLenum wrap_t = (state & GPU_SAMPLER_REPEAT_T) ? GL_REPEAT : clamp_type;
@@ -2186,8 +2186,9 @@ void GPU_samplers_init(void)
((state & GPU_SAMPLER_MIPMAP) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR) :
((state & GPU_SAMPLER_MIPMAP) ? GL_NEAREST_MIPMAP_LINEAR : GL_NEAREST);
GLenum compare_mode = (state & GPU_SAMPLER_COMPARE) ? GL_COMPARE_REF_TO_TEXTURE : GL_NONE;
+ /* TODO(fclem) Anisotropic level should be a render engine parameter. */
float aniso_filter = ((state & GPU_SAMPLER_MIPMAP) && (state & GPU_SAMPLER_ANISO)) ?
- GPU_get_anisotropic() :
+ U.anisotropic_filter :
1.0f;
glSamplerParameteri(GG.samplers[i], GL_TEXTURE_WRAP_S, wrap_s);
@@ -2213,7 +2214,7 @@ void GPU_samplers_init(void)
glGenSamplers(1, &GG.icon_sampler);
glSamplerParameteri(GG.icon_sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glSamplerParameteri(GG.icon_sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glSamplerParameteri(GG.icon_sampler, GL_TEXTURE_LOD_BIAS, -0.5f);
+ glSamplerParameterf(GG.icon_sampler, GL_TEXTURE_LOD_BIAS, -0.5f);
}
void GPU_sampler_icon_bind(int unit)
diff --git a/source/blender/gpu/intern/gpu_texture_image.cc b/source/blender/gpu/intern/gpu_texture_image.cc
deleted file mode 100644
index 5b53ba0544b..00000000000
--- a/source/blender/gpu/intern/gpu_texture_image.cc
+++ /dev/null
@@ -1,1480 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2005 Blender Foundation.
- * All rights reserved.
- */
-
-/** \file
- * \ingroup gpu
- *
- * Utility functions for dealing with OpenGL texture & material context,
- * mipmap generation and light objects.
- *
- * These are some obscure rendering functions shared between the game engine (not anymore)
- * and the blender, in this module to avoid duplication
- * and abstract them away from the rest a bit.
- */
-
-#include <string.h>
-
-#include "BLI_blenlib.h"
-#include "BLI_boxpack_2d.h"
-#include "BLI_linklist.h"
-#include "BLI_math.h"
-#include "BLI_threads.h"
-#include "BLI_utildefines.h"
-
-#include "DNA_image_types.h"
-#include "DNA_movieclip_types.h"
-#include "DNA_userdef_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "IMB_colormanagement.h"
-#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
-
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_main.h"
-#include "BKE_movieclip.h"
-
-#include "GPU_draw.h"
-#include "GPU_extensions.h"
-#include "GPU_glew.h"
-#include "GPU_matrix.h"
-#include "GPU_platform.h"
-#include "GPU_texture.h"
-
-#include "PIL_time.h"
-
-static void gpu_free_image(Image *ima, const bool immediate);
-static void gpu_free_unused_buffers(void);
-static void gpu_create_gl_tex_compressed(unsigned int *bind,
- eGPUTextureTarget textarget,
- Image *ima,
- ImBuf *ibuf);
-static void gpu_create_gl_tex(uint *bind,
- uint *rect,
- float *frect,
- int rectw,
- int recth,
- eGPUTextureTarget textarget,
- bool mipmap,
- bool half_float,
- bool use_srgb,
- Image *ima);
-
-//* Checking powers of two for images since OpenGL ES requires it */
-#ifdef WITH_DDS
-static bool is_power_of_2_resolution(int w, int h)
-{
- return is_power_of_2_i(w) && is_power_of_2_i(h);
-}
-#endif
-
-static bool is_over_resolution_limit(GLenum textarget, int w, int h)
-{
- int size = (textarget == GL_TEXTURE_CUBE_MAP) ? GPU_max_cube_map_size() : GPU_max_texture_size();
- int reslimit = (U.glreslimit != 0) ? min_ii(U.glreslimit, size) : size;
-
- return (w > reslimit || h > reslimit);
-}
-
-static int smaller_power_of_2_limit(int num)
-{
- int reslimit = (U.glreslimit != 0) ? min_ii(U.glreslimit, GPU_max_texture_size()) :
- GPU_max_texture_size();
- /* take texture clamping into account */
- if (num > reslimit) {
- return reslimit;
- }
-
- return power_of_2_min_i(num);
-}
-
-/* Current OpenGL state caching for GPU_set_tpage */
-
-static struct GPUTextureState {
- /* also controls min/mag filtering */
- bool domipmap;
- /* only use when 'domipmap' is set */
- bool linearmipmap;
- /* store this so that new images created while texture painting won't be set to mipmapped */
- bool texpaint;
-
- float anisotropic;
-} GTS = {1, 0, 0, 1.0f};
-
-/* Mipmap settings */
-
-void GPU_set_mipmap(Main *bmain, bool mipmap)
-{
- if (GTS.domipmap != mipmap) {
- GPU_free_images(bmain);
- GTS.domipmap = mipmap;
- }
-}
-
-void GPU_set_linear_mipmap(bool linear)
-{
- if (GTS.linearmipmap != linear) {
- GTS.linearmipmap = linear;
- }
-}
-
-bool GPU_get_mipmap(void)
-{
- return GTS.domipmap && !GTS.texpaint;
-}
-
-bool GPU_get_linear_mipmap(void)
-{
- return GTS.linearmipmap;
-}
-
-static GLenum gpu_get_mipmap_filter(bool mag)
-{
- /* linearmipmap is off by default *when mipmapping is off,
- * use unfiltered display */
- if (mag) {
- if (GTS.domipmap) {
- return GL_LINEAR;
- }
- else {
- return GL_NEAREST;
- }
- }
- else {
- if (GTS.domipmap) {
- if (GTS.linearmipmap) {
- return GL_LINEAR_MIPMAP_LINEAR;
- }
- else {
- return GL_LINEAR_MIPMAP_NEAREST;
- }
- }
- else {
- return GL_NEAREST;
- }
- }
-}
-
-/* Anisotropic filtering settings */
-void GPU_set_anisotropic(float value)
-{
- if (GTS.anisotropic != value) {
- GPU_samplers_free();
-
- /* Clamp value to the maximum value the graphics card supports */
- const float max = GPU_max_texture_anisotropy();
- if (value > max) {
- value = max;
- }
-
- GTS.anisotropic = value;
-
- GPU_samplers_init();
- }
-}
-
-float GPU_get_anisotropic(void)
-{
- return GTS.anisotropic;
-}
-
-static GPUTexture **gpu_get_image_gputexture(Image *ima, int textarget, const int multiview_eye)
-{
- const bool in_range = (textarget >= 0) && (textarget < TEXTARGET_COUNT);
- BLI_assert(in_range);
-
- if (in_range) {
- return &(ima->gputexture[textarget][multiview_eye]);
- }
- return NULL;
-}
-
-static uint gpu_texture_create_tile_mapping(Image *ima, const int multiview_eye)
-{
- GPUTexture *tilearray = ima->gputexture[TEXTARGET_2D_ARRAY][multiview_eye];
-
- if (tilearray == NULL) {
- return 0;
- }
-
- float array_w = GPU_texture_width(tilearray);
- float array_h = GPU_texture_height(tilearray);
-
- ImageTile *last_tile = (ImageTile *)ima->tiles.last;
- /* Tiles are sorted by number. */
- int max_tile = last_tile->tile_number - 1001;
-
- /* create image */
- int bindcode;
- glGenTextures(1, (GLuint *)&bindcode);
- glBindTexture(GL_TEXTURE_1D_ARRAY, bindcode);
-
- int width = max_tile + 1;
- float *data = (float *)MEM_callocN(width * 8 * sizeof(float), __func__);
- for (int i = 0; i < width; i++) {
- data[4 * i] = -1.0f;
- }
- LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
- int i = tile->tile_number - 1001;
- data[4 * i] = tile->runtime.tilearray_layer;
-
- float *tile_info = &data[4 * width + 4 * i];
- tile_info[0] = tile->runtime.tilearray_offset[0] / array_w;
- tile_info[1] = tile->runtime.tilearray_offset[1] / array_h;
- tile_info[2] = tile->runtime.tilearray_size[0] / array_w;
- tile_info[3] = tile->runtime.tilearray_size[1] / array_h;
- }
-
- glTexImage2D(GL_TEXTURE_1D_ARRAY, 0, GL_RGBA32F, width, 2, 0, GL_RGBA, GL_FLOAT, data);
- MEM_freeN(data);
-
- glTexParameteri(GL_TEXTURE_1D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_1D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-
- glBindTexture(GL_TEXTURE_1D_ARRAY, 0);
-
- return bindcode;
-}
-
-typedef struct PackTile {
- FixedSizeBoxPack boxpack;
- ImageTile *tile;
- float pack_score;
-} PackTile;
-
-static int compare_packtile(const void *a, const void *b)
-{
- const PackTile *tile_a = (const PackTile *)a;
- const PackTile *tile_b = (const PackTile *)b;
-
- return tile_a->pack_score < tile_b->pack_score;
-}
-
-static uint gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
-{
- int arraywidth = 0, arrayheight = 0;
-
- ListBase boxes = {NULL};
-
- LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
- ImageUser iuser;
- BKE_imageuser_default(&iuser);
- iuser.tile = tile->tile_number;
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
-
- if (ibuf) {
- PackTile *packtile = (PackTile *)MEM_callocN(sizeof(PackTile), __func__);
- packtile->tile = tile;
- packtile->boxpack.w = ibuf->x;
- packtile->boxpack.h = ibuf->y;
-
- if (is_over_resolution_limit(
- GL_TEXTURE_2D_ARRAY, packtile->boxpack.w, packtile->boxpack.h)) {
- packtile->boxpack.w = smaller_power_of_2_limit(packtile->boxpack.w);
- packtile->boxpack.h = smaller_power_of_2_limit(packtile->boxpack.h);
- }
- arraywidth = max_ii(arraywidth, packtile->boxpack.w);
- arrayheight = max_ii(arrayheight, packtile->boxpack.h);
-
- /* We sort the tiles by decreasing size, with an additional penalty term
- * for high aspect ratios. This improves packing efficiency. */
- float w = packtile->boxpack.w, h = packtile->boxpack.h;
- packtile->pack_score = max_ff(w, h) / min_ff(w, h) * w * h;
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
- BLI_addtail(&boxes, packtile);
- }
- }
-
- BLI_assert(arraywidth > 0 && arrayheight > 0);
-
- BLI_listbase_sort(&boxes, compare_packtile);
- int arraylayers = 0;
- /* Keep adding layers until all tiles are packed. */
- while (boxes.first != NULL) {
- ListBase packed = {NULL};
- BLI_box_pack_2d_fixedarea(&boxes, arraywidth, arrayheight, &packed);
- BLI_assert(packed.first != NULL);
-
- LISTBASE_FOREACH (PackTile *, packtile, &packed) {
- ImageTile *tile = packtile->tile;
- int *tileoffset = tile->runtime.tilearray_offset;
- int *tilesize = tile->runtime.tilearray_size;
-
- tileoffset[0] = packtile->boxpack.x;
- tileoffset[1] = packtile->boxpack.y;
- tilesize[0] = packtile->boxpack.w;
- tilesize[1] = packtile->boxpack.h;
- tile->runtime.tilearray_layer = arraylayers;
- }
-
- BLI_freelistN(&packed);
- arraylayers++;
- }
-
- /* create image */
- int bindcode;
- glGenTextures(1, (GLuint *)&bindcode);
- glBindTexture(GL_TEXTURE_2D_ARRAY, bindcode);
-
- GLenum data_type, internal_format;
- if (main_ibuf->rect_float) {
- data_type = GL_FLOAT;
- internal_format = (!(main_ibuf->flags & IB_halffloat) && (ima->flag & IMA_HIGH_BITDEPTH)) ?
- GL_RGBA32F :
- GL_RGBA16F;
- }
- else {
- data_type = GL_UNSIGNED_BYTE;
- internal_format = GL_RGBA8;
- if (!IMB_colormanagement_space_is_data(main_ibuf->rect_colorspace) &&
- !IMB_colormanagement_space_is_scene_linear(main_ibuf->rect_colorspace)) {
- internal_format = GL_SRGB8_ALPHA8;
- }
- }
-
- glTexImage3D(GL_TEXTURE_2D_ARRAY,
- 0,
- internal_format,
- arraywidth,
- arrayheight,
- arraylayers,
- 0,
- GL_RGBA,
- data_type,
- NULL);
-
- LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
- int tilelayer = tile->runtime.tilearray_layer;
- int *tileoffset = tile->runtime.tilearray_offset;
- int *tilesize = tile->runtime.tilearray_size;
-
- if (tilesize[0] == 0 || tilesize[1] == 0) {
- continue;
- }
-
- ImageUser iuser;
- BKE_imageuser_default(&iuser);
- iuser.tile = tile->tile_number;
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
-
- if (ibuf) {
- bool needs_scale = (ibuf->x != tilesize[0] || ibuf->y != tilesize[1]);
-
- ImBuf *scale_ibuf = NULL;
- if (ibuf->rect_float) {
- float *rect_float = ibuf->rect_float;
-
- const bool store_premultiplied = ima->alpha_mode != IMA_ALPHA_STRAIGHT;
- if (ibuf->channels != 4 || !store_premultiplied) {
- rect_float = (float *)MEM_mallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, __func__);
- IMB_colormanagement_imbuf_to_float_texture(
- rect_float, 0, 0, ibuf->x, ibuf->y, ibuf, store_premultiplied);
- }
-
- float *pixeldata = rect_float;
- if (needs_scale) {
- scale_ibuf = IMB_allocFromBuffer(NULL, rect_float, ibuf->x, ibuf->y, 4);
- IMB_scaleImBuf(scale_ibuf, tilesize[0], tilesize[1]);
- pixeldata = scale_ibuf->rect_float;
- }
-
- glTexSubImage3D(GL_TEXTURE_2D_ARRAY,
- 0,
- tileoffset[0],
- tileoffset[1],
- tilelayer,
- tilesize[0],
- tilesize[1],
- 1,
- GL_RGBA,
- GL_FLOAT,
- pixeldata);
-
- if (rect_float != ibuf->rect_float) {
- MEM_freeN(rect_float);
- }
- }
- else {
- unsigned int *rect = ibuf->rect;
-
- if (!IMB_colormanagement_space_is_data(ibuf->rect_colorspace)) {
- rect = (uint *)MEM_mallocN(sizeof(uchar) * 4 * ibuf->x * ibuf->y, __func__);
- IMB_colormanagement_imbuf_to_byte_texture((uchar *)rect,
- 0,
- 0,
- ibuf->x,
- ibuf->y,
- ibuf,
- internal_format == GL_SRGB8_ALPHA8,
- ima->alpha_mode == IMA_ALPHA_PREMUL);
- }
-
- unsigned int *pixeldata = rect;
- if (needs_scale) {
- scale_ibuf = IMB_allocFromBuffer(rect, NULL, ibuf->x, ibuf->y, 4);
- IMB_scaleImBuf(scale_ibuf, tilesize[0], tilesize[1]);
- pixeldata = scale_ibuf->rect;
- }
- glTexSubImage3D(GL_TEXTURE_2D_ARRAY,
- 0,
- tileoffset[0],
- tileoffset[1],
- tilelayer,
- tilesize[0],
- tilesize[1],
- 1,
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- pixeldata);
-
- if (rect != ibuf->rect) {
- MEM_freeN(rect);
- }
- }
- if (scale_ibuf != NULL) {
- IMB_freeImBuf(scale_ibuf);
- }
- }
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
- }
-
- if (GPU_get_mipmap()) {
- glGenerateMipmap(GL_TEXTURE_2D_ARRAY);
- if (ima) {
- ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
- }
- }
-
- glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
-
- return bindcode;
-}
-
-static uint gpu_texture_create_from_ibuf(Image *ima, ImBuf *ibuf, eGPUTextureTarget textarget)
-{
- uint bindcode = 0;
- const bool mipmap = GPU_get_mipmap();
- const bool half_float = (ibuf->flags & IB_halffloat) != 0;
-
-#ifdef WITH_DDS
- if (ibuf->ftype == IMB_FTYPE_DDS) {
- /* DDS is loaded directly in compressed form. */
- gpu_create_gl_tex_compressed(&bindcode, textarget, ima, ibuf);
- return bindcode;
- }
-#else
- (void)gpu_create_gl_tex_compressed;
-#endif
-
- /* Regular uncompressed texture. */
- float *rect_float = ibuf->rect_float;
- uchar *rect = (uchar *)ibuf->rect;
- bool compress_as_srgb = false;
-
- if (rect_float == NULL) {
- /* Byte image is in original colorspace from the file. If the file is sRGB
- * scene linear, or non-color data no conversion is needed. Otherwise we
- * compress as scene linear + sRGB transfer function to avoid precision loss
- * in common cases.
- *
- * We must also convert to premultiplied for correct texture interpolation
- * and consistency with float images. */
- if (!IMB_colormanagement_space_is_data(ibuf->rect_colorspace)) {
- compress_as_srgb = !IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace);
-
- rect = (uchar *)MEM_mallocN(sizeof(uchar) * 4 * ibuf->x * ibuf->y, __func__);
- if (rect == NULL) {
- return bindcode;
- }
-
- /* Texture storage of images is defined by the alpha mode of the image. The
- * downside of this is that there can be artifacts near alpha edges. However,
- * this allows us to use sRGB texture formats and preserves color values in
- * zero alpha areas, and appears generally closer to what game engines that we
- * want to be compatible with do. */
- const bool store_premultiplied = ima ? (ima->alpha_mode == IMA_ALPHA_PREMUL) : true;
- IMB_colormanagement_imbuf_to_byte_texture(
- rect, 0, 0, ibuf->x, ibuf->y, ibuf, compress_as_srgb, store_premultiplied);
- }
- }
- else {
- /* Float image is already in scene linear colorspace or non-color data by
- * convention, no colorspace conversion needed. But we do require 4 channels
- * currently. */
- const bool store_premultiplied = ima ? (ima->alpha_mode != IMA_ALPHA_STRAIGHT) : false;
-
- if (ibuf->channels != 4 || !store_premultiplied) {
- rect_float = (float *)MEM_mallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, __func__);
- if (rect_float == NULL) {
- return bindcode;
- }
- IMB_colormanagement_imbuf_to_float_texture(
- rect_float, 0, 0, ibuf->x, ibuf->y, ibuf, store_premultiplied);
- }
- }
-
- /* Create OpenGL texture. */
- gpu_create_gl_tex(&bindcode,
- (uint *)rect,
- rect_float,
- ibuf->x,
- ibuf->y,
- textarget,
- mipmap,
- half_float,
- compress_as_srgb,
- ima);
-
- /* Free buffers if needed. */
- if (rect && rect != (uchar *)ibuf->rect) {
- MEM_freeN(rect);
- }
- if (rect_float && rect_float != ibuf->rect_float) {
- MEM_freeN(rect_float);
- }
-
- return bindcode;
-}
-
-static GPUTexture **gpu_get_movieclip_gputexture(MovieClip *clip,
- MovieClipUser *cuser,
- eGPUTextureTarget textarget)
-{
- LISTBASE_FOREACH (MovieClip_RuntimeGPUTexture *, tex, &clip->runtime.gputextures) {
- if (memcmp(&tex->user, cuser, sizeof(MovieClipUser)) == 0) {
- if (tex == NULL) {
- tex = (MovieClip_RuntimeGPUTexture *)MEM_mallocN(sizeof(MovieClip_RuntimeGPUTexture),
- __func__);
-
- for (int i = 0; i < TEXTARGET_COUNT; i++) {
- tex->gputexture[i] = NULL;
- }
-
- memcpy(&tex->user, cuser, sizeof(MovieClipUser));
- BLI_addtail(&clip->runtime.gputextures, tex);
- }
-
- return &tex->gputexture[textarget];
- }
- }
- return NULL;
-}
-
-static ImBuf *update_do_scale(uchar *rect,
- float *rect_float,
- int *x,
- int *y,
- int *w,
- int *h,
- int limit_w,
- int limit_h,
- int full_w,
- int full_h)
-{
- /* Partial update with scaling. */
- float xratio = limit_w / (float)full_w;
- float yratio = limit_h / (float)full_h;
-
- int part_w = *w, part_h = *h;
-
- /* Find sub coordinates in scaled image. Take ceiling because we will be
- * losing 1 pixel due to rounding errors in x,y. */
- *x *= xratio;
- *y *= yratio;
- *w = (int)ceil(xratio * (*w));
- *h = (int)ceil(yratio * (*h));
-
- /* ...but take back if we are over the limit! */
- if (*x + *w > limit_w) {
- (*w)--;
- }
- if (*y + *h > limit_h) {
- (*h)--;
- }
-
- /* Scale pixels. */
- ImBuf *ibuf = IMB_allocFromBuffer((uint *)rect, rect_float, part_w, part_h, 4);
- IMB_scaleImBuf(ibuf, *w, *h);
-
- return ibuf;
-}
-
-static void gpu_texture_update_scaled_array(uchar *rect,
- float *rect_float,
- int full_w,
- int full_h,
- int x,
- int y,
- int layer,
- const int *tile_offset,
- const int *tile_size,
- int w,
- int h)
-{
- ImBuf *ibuf = update_do_scale(
- rect, rect_float, &x, &y, &w, &h, tile_size[0], tile_size[1], full_w, full_h);
-
- /* Shift to account for tile packing. */
- x += tile_offset[0];
- y += tile_offset[1];
-
- if (ibuf->rect_float) {
- glTexSubImage3D(
- GL_TEXTURE_2D_ARRAY, 0, x, y, layer, w, h, 1, GL_RGBA, GL_FLOAT, ibuf->rect_float);
- }
- else {
- glTexSubImage3D(
- GL_TEXTURE_2D_ARRAY, 0, x, y, layer, w, h, 1, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
- }
-
- IMB_freeImBuf(ibuf);
-}
-
-static void gpu_texture_update_scaled(
- uchar *rect, float *rect_float, int full_w, int full_h, int x, int y, int w, int h)
-{
- /* Partial update with scaling. */
- int limit_w = smaller_power_of_2_limit(full_w);
- int limit_h = smaller_power_of_2_limit(full_h);
-
- ImBuf *ibuf = update_do_scale(
- rect, rect_float, &x, &y, &w, &h, limit_w, limit_h, full_w, full_h);
-
- if (ibuf->rect_float) {
- glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, GL_FLOAT, ibuf->rect_float);
- }
- else {
- glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
- }
-
- IMB_freeImBuf(ibuf);
-}
-
-static void gpu_texture_update_unscaled(uchar *rect,
- float *rect_float,
- int x,
- int y,
- int layer,
- int w,
- int h,
- GLint tex_stride,
- GLint tex_offset)
-{
- /* Partial update without scaling. Stride and offset are used to copy only a
- * subset of a possible larger buffer than what we are updating. */
- GPU_unpack_row_length_set(tex_stride);
-
- if (layer >= 0) {
- if (rect_float == NULL) {
- glTexSubImage3D(GL_TEXTURE_2D_ARRAY,
- 0,
- x,
- y,
- layer,
- w,
- h,
- 1,
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- rect + tex_offset);
- }
- else {
- glTexSubImage3D(GL_TEXTURE_2D_ARRAY,
- 0,
- x,
- y,
- layer,
- w,
- h,
- 1,
- GL_RGBA,
- GL_FLOAT,
- rect_float + tex_offset);
- }
- }
- else {
- if (rect_float == NULL) {
- glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, rect + tex_offset);
- }
- else {
- glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, GL_FLOAT, rect_float + tex_offset);
- }
- }
-
- /* Restore default. */
- GPU_unpack_row_length_set(0);
-}
-
-static void gpu_texture_update_from_ibuf(
- GPUTexture *tex, Image *ima, ImBuf *ibuf, ImageTile *tile, int x, int y, int w, int h)
-{
- /* Partial update of texture for texture painting. This is often much
- * quicker than fully updating the texture for high resolution images. */
- GPU_texture_bind(tex, 0);
-
- bool scaled;
- if (tile != NULL) {
- int *tilesize = tile->runtime.tilearray_size;
- scaled = (ibuf->x != tilesize[0]) || (ibuf->y != tilesize[1]);
- }
- else {
- scaled = is_over_resolution_limit(GL_TEXTURE_2D, ibuf->x, ibuf->y);
- }
-
- if (scaled) {
- /* Extra padding to account for bleed from neighboring pixels. */
- const int padding = 4;
- const int xmax = min_ii(x + w + padding, ibuf->x);
- const int ymax = min_ii(y + h + padding, ibuf->y);
- x = max_ii(x - padding, 0);
- y = max_ii(y - padding, 0);
- w = xmax - x;
- h = ymax - y;
- }
-
- /* Get texture data pointers. */
- float *rect_float = ibuf->rect_float;
- uchar *rect = (uchar *)ibuf->rect;
- GLint tex_stride = ibuf->x;
- GLint tex_offset = ibuf->channels * (y * ibuf->x + x);
-
- if (rect_float == NULL) {
- /* Byte pixels. */
- if (!IMB_colormanagement_space_is_data(ibuf->rect_colorspace)) {
- const bool compress_as_srgb = !IMB_colormanagement_space_is_scene_linear(
- ibuf->rect_colorspace);
-
- rect = (uchar *)MEM_mallocN(sizeof(uchar) * 4 * w * h, __func__);
- if (rect == NULL) {
- return;
- }
-
- tex_stride = w;
- tex_offset = 0;
-
- /* Convert to scene linear with sRGB compression, and premultiplied for
- * correct texture interpolation. */
- const bool store_premultiplied = (ima->alpha_mode == IMA_ALPHA_PREMUL);
- IMB_colormanagement_imbuf_to_byte_texture(
- rect, x, y, w, h, ibuf, compress_as_srgb, store_premultiplied);
- }
- }
- else {
- /* Float pixels. */
- const bool store_premultiplied = (ima->alpha_mode != IMA_ALPHA_STRAIGHT);
-
- if (ibuf->channels != 4 || scaled || !store_premultiplied) {
- rect_float = (float *)MEM_mallocN(sizeof(float) * 4 * w * h, __func__);
- if (rect_float == NULL) {
- return;
- }
-
- tex_stride = w;
- tex_offset = 0;
-
- IMB_colormanagement_imbuf_to_float_texture(
- rect_float, x, y, w, h, ibuf, store_premultiplied);
- }
- }
-
- if (scaled) {
- /* Slower update where we first have to scale the input pixels. */
- if (tile != NULL) {
- int *tileoffset = tile->runtime.tilearray_offset;
- int *tilesize = tile->runtime.tilearray_size;
- int tilelayer = tile->runtime.tilearray_layer;
- gpu_texture_update_scaled_array(
- rect, rect_float, ibuf->x, ibuf->y, x, y, tilelayer, tileoffset, tilesize, w, h);
- }
- else {
- gpu_texture_update_scaled(rect, rect_float, ibuf->x, ibuf->y, x, y, w, h);
- }
- }
- else {
- /* Fast update at same resolution. */
- if (tile != NULL) {
- int *tileoffset = tile->runtime.tilearray_offset;
- int tilelayer = tile->runtime.tilearray_layer;
- gpu_texture_update_unscaled(rect,
- rect_float,
- x + tileoffset[0],
- y + tileoffset[1],
- tilelayer,
- w,
- h,
- tex_stride,
- tex_offset);
- }
- else {
- gpu_texture_update_unscaled(rect, rect_float, x, y, -1, w, h, tex_stride, tex_offset);
- }
- }
-
- /* Free buffers if needed. */
- if (rect && rect != (uchar *)ibuf->rect) {
- MEM_freeN(rect);
- }
- if (rect_float && rect_float != ibuf->rect_float) {
- MEM_freeN(rect_float);
- }
-
- if (GPU_get_mipmap()) {
- glGenerateMipmap((tile != NULL) ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D);
- }
- else {
- ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
- }
-
- GPU_texture_unbind(tex);
-}
-
-/* Get the GPUTexture for a given `Image`.
- *
- * `iuser` and `ibuf` are mutual exclusive parameters. The caller can pass the `ibuf` when already
- * available. It is also required when requesting the GPUTexture for a render result. */
-GPUTexture *GPU_texture_from_blender(Image *ima,
- ImageUser *iuser,
- ImBuf *ibuf,
- eGPUTextureTarget textarget)
-{
-#ifndef GPU_STANDALONE
- if (ima == NULL) {
- return NULL;
- }
-
- /* Free any unused GPU textures, since we know we are in a thread with OpenGL
- * context and might as well ensure we have as much space free as possible. */
- gpu_free_unused_buffers();
-
- /* currently, gpu refresh tagging is used by ima sequences */
- if (ima->gpuflag & IMA_GPU_REFRESH) {
- gpu_free_image(ima, true);
- ima->gpuflag &= ~IMA_GPU_REFRESH;
- }
-
- /* Tag as in active use for garbage collector. */
- BKE_image_tag_time(ima);
-
- /* Test if we already have a texture. */
- GPUTexture **tex = gpu_get_image_gputexture(ima, textarget, iuser ? iuser->multiview_eye : 0);
- if (*tex) {
- return *tex;
- }
-
- /* Check if we have a valid image. If not, we return a dummy
- * texture with zero bindcode so we don't keep trying. */
- uint bindcode = 0;
- ImageTile *tile = BKE_image_get_tile(ima, 0);
- if (tile == NULL || tile->ok == 0) {
- *tex = GPU_texture_from_bindcode(textarget, bindcode);
- return *tex;
- }
-
- /* check if we have a valid image buffer */
- ImBuf *ibuf_intern = ibuf;
- if (ibuf_intern == NULL) {
- ibuf_intern = BKE_image_acquire_ibuf(ima, iuser, NULL);
- if (ibuf_intern == NULL) {
- *tex = GPU_texture_from_bindcode(textarget, bindcode);
- return *tex;
- }
- }
-
- if (textarget == TEXTARGET_2D_ARRAY) {
- bindcode = gpu_texture_create_tile_array(ima, ibuf_intern);
- }
- else if (textarget == TEXTARGET_TILE_MAPPING) {
- bindcode = gpu_texture_create_tile_mapping(ima, iuser ? iuser->multiview_eye : 0);
- }
- else {
- bindcode = gpu_texture_create_from_ibuf(ima, ibuf_intern, textarget);
- }
-
- /* if `ibuf` was given, we don't own the `ibuf_intern` */
- if (ibuf == NULL) {
- BKE_image_release_ibuf(ima, ibuf_intern, NULL);
- }
-
- *tex = GPU_texture_from_bindcode(textarget, bindcode);
-
- GPU_texture_orig_size_set(*tex, ibuf_intern->x, ibuf_intern->y);
-
- if (textarget == TEXTARGET_TILE_MAPPING) {
- /* Special for tile mapping. */
- GPU_texture_mipmap_mode(*tex, false, false);
- }
-
- return *tex;
-#endif
- return NULL;
-}
-
-GPUTexture *GPU_texture_from_movieclip(MovieClip *clip,
- MovieClipUser *cuser,
- eGPUTextureTarget textarget)
-{
-#ifndef GPU_STANDALONE
- if (clip == NULL) {
- return NULL;
- }
-
- GPUTexture **tex = gpu_get_movieclip_gputexture(clip, cuser, textarget);
- if (*tex) {
- return *tex;
- }
-
- /* check if we have a valid image buffer */
- uint bindcode = 0;
- ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, cuser);
- if (ibuf == NULL) {
- *tex = GPU_texture_from_bindcode(textarget, bindcode);
- return *tex;
- }
-
- bindcode = gpu_texture_create_from_ibuf(NULL, ibuf, textarget);
- IMB_freeImBuf(ibuf);
-
- *tex = GPU_texture_from_bindcode(textarget, bindcode);
- return *tex;
-#else
- return NULL;
-#endif
-}
-
-void GPU_free_texture_movieclip(struct MovieClip *clip)
-{
- /* number of gpu textures to keep around as cache
- * We don't want to keep too many GPU textures for
- * movie clips around, as they can be large.*/
- const int MOVIECLIP_NUM_GPUTEXTURES = 1;
-
- while (BLI_listbase_count(&clip->runtime.gputextures) > MOVIECLIP_NUM_GPUTEXTURES) {
- MovieClip_RuntimeGPUTexture *tex = (MovieClip_RuntimeGPUTexture *)BLI_pophead(
- &clip->runtime.gputextures);
- for (int i = 0; i < TEXTARGET_COUNT; i++) {
- /* free glsl image binding */
- if (tex->gputexture[i]) {
- GPU_texture_free(tex->gputexture[i]);
- tex->gputexture[i] = NULL;
- }
- }
- MEM_freeN(tex);
- }
-}
-
-static void **gpu_gen_cube_map(uint *rect, float *frect, int rectw, int recth)
-{
- size_t block_size = frect ? sizeof(float[4]) : sizeof(uchar[4]);
- void **sides = NULL;
- int h = recth / 2;
- int w = rectw / 3;
-
- if (w != h) {
- return sides;
- }
-
- /* PosX, NegX, PosY, NegY, PosZ, NegZ */
- sides = (void **)MEM_mallocN(sizeof(void *) * 6, "");
- for (int i = 0; i < 6; i++) {
- sides[i] = MEM_mallocN(block_size * w * h, "");
- }
-
- /* divide image into six parts */
- /* ______________________
- * | | | |
- * | NegX | NegY | PosX |
- * |______|______|______|
- * | | | |
- * | NegZ | PosZ | PosY |
- * |______|______|______|
- */
- if (frect) {
- float(*frectb)[4] = (float(*)[4])frect;
- float(**fsides)[4] = (float(**)[4])sides;
-
- for (int y = 0; y < h; y++) {
- for (int x = 0; x < w; x++) {
- memcpy(&fsides[0][x * h + y], &frectb[(recth - y - 1) * rectw + 2 * w + x], block_size);
- memcpy(&fsides[1][x * h + y], &frectb[(y + h) * rectw + w - 1 - x], block_size);
- memcpy(
- &fsides[3][y * w + x], &frectb[(recth - y - 1) * rectw + 2 * w - 1 - x], block_size);
- memcpy(&fsides[5][y * w + x], &frectb[(h - y - 1) * rectw + w - 1 - x], block_size);
- }
- memcpy(&fsides[2][y * w], frectb[y * rectw + 2 * w], block_size * w);
- memcpy(&fsides[4][y * w], frectb[y * rectw + w], block_size * w);
- }
- }
- else {
- uint **isides = (uint **)sides;
-
- for (int y = 0; y < h; y++) {
- for (int x = 0; x < w; x++) {
- isides[0][x * h + y] = rect[(recth - y - 1) * rectw + 2 * w + x];
- isides[1][x * h + y] = rect[(y + h) * rectw + w - 1 - x];
- isides[3][y * w + x] = rect[(recth - y - 1) * rectw + 2 * w - 1 - x];
- isides[5][y * w + x] = rect[(h - y - 1) * rectw + w - 1 - x];
- }
- memcpy(&isides[2][y * w], &rect[y * rectw + 2 * w], block_size * w);
- memcpy(&isides[4][y * w], &rect[y * rectw + w], block_size * w);
- }
- }
-
- return sides;
-}
-
-static void gpu_del_cube_map(void **cube_map)
-{
- int i;
- if (cube_map == NULL) {
- return;
- }
- for (i = 0; i < 6; i++) {
- MEM_freeN(cube_map[i]);
- }
- MEM_freeN(cube_map);
-}
-
-/* Image *ima can be NULL */
-static void gpu_create_gl_tex(uint *bind,
- uint *rect,
- float *frect,
- int rectw,
- int recth,
- eGPUTextureTarget target,
- bool mipmap,
- bool half_float,
- bool use_srgb,
- Image *ima)
-{
- GLenum textarget = (target == TEXTARGET_2D) ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP;
-
- ImBuf *ibuf = NULL;
-
- if (textarget == GL_TEXTURE_2D && is_over_resolution_limit(textarget, rectw, recth)) {
- int tpx = rectw;
- int tpy = recth;
- rectw = smaller_power_of_2_limit(rectw);
- recth = smaller_power_of_2_limit(recth);
-
- if (frect) {
- ibuf = IMB_allocFromBuffer(NULL, frect, tpx, tpy, 4);
- IMB_scaleImBuf(ibuf, rectw, recth);
-
- frect = ibuf->rect_float;
- }
- else {
- ibuf = IMB_allocFromBuffer(rect, NULL, tpx, tpy, 4);
- IMB_scaleImBuf(ibuf, rectw, recth);
-
- rect = ibuf->rect;
- }
- }
-
- /* create image */
- glGenTextures(1, (GLuint *)bind);
- glBindTexture(textarget, *bind);
-
- GLenum float_format = (!half_float && (ima && (ima->flag & IMA_HIGH_BITDEPTH))) ? GL_RGBA32F :
- GL_RGBA16F;
- GLenum internal_format = (frect) ? float_format : (use_srgb) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
-
- if (textarget == GL_TEXTURE_2D) {
- if (frect) {
- glTexImage2D(GL_TEXTURE_2D, 0, internal_format, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
- }
- else {
- glTexImage2D(
- GL_TEXTURE_2D, 0, internal_format, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
- }
-
- if (GPU_get_mipmap() && mipmap) {
- glGenerateMipmap(GL_TEXTURE_2D);
- if (ima) {
- ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
- }
- }
- }
- else if (textarget == GL_TEXTURE_CUBE_MAP) {
- int w = rectw / 3, h = recth / 2;
-
- if (h == w && is_power_of_2_i(h) && !is_over_resolution_limit(textarget, h, w)) {
- void **cube_map = gpu_gen_cube_map(rect, frect, rectw, recth);
- GLenum type = frect ? GL_FLOAT : GL_UNSIGNED_BYTE;
-
- if (cube_map) {
- for (int i = 0; i < 6; i++) {
- glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
- 0,
- internal_format,
- w,
- h,
- 0,
- GL_RGBA,
- type,
- cube_map[i]);
- }
- }
-
- if (GPU_get_mipmap() && mipmap) {
- glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
-
- if (ima) {
- ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
- }
- }
-
- gpu_del_cube_map(cube_map);
- }
- else {
- printf("Incorrect envmap size\n");
- }
- }
-
- glBindTexture(textarget, 0);
-
- if (ibuf) {
- IMB_freeImBuf(ibuf);
- }
-}
-
-/**
- * Returns false if the provided ImBuf doesn't have a supported DXT compression format
- */
-bool GPU_upload_dxt_texture(ImBuf *ibuf, bool use_srgb, uint *bindcode)
-{
-#ifdef WITH_DDS
- glGenTextures(1, (GLuint *)bindcode);
- glBindTexture(GL_TEXTURE_2D, *bindcode);
-
- GLint format = 0;
- int blocksize, height, width, i, size, offset = 0;
-
- width = ibuf->x;
- height = ibuf->y;
-
- if (GLEW_EXT_texture_compression_s3tc) {
- if (ibuf->dds_data.fourcc == FOURCC_DXT1) {
- format = (use_srgb) ? GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT :
- GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- }
- else if (ibuf->dds_data.fourcc == FOURCC_DXT3) {
- format = (use_srgb) ? GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT :
- GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
- }
- else if (ibuf->dds_data.fourcc == FOURCC_DXT5) {
- format = (use_srgb) ? GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT :
- GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
- }
- }
-
- if (format == 0) {
- fprintf(stderr, "Unable to find a suitable DXT compression, falling back to uncompressed\n");
- glDeleteTextures(1, (GLuint *)bindcode);
- return false;
- }
-
- if (!is_power_of_2_resolution(width, height)) {
- fprintf(
- stderr,
- "Unable to load non-power-of-two DXT image resolution, falling back to uncompressed\n");
- glDeleteTextures(1, (GLuint *)bindcode);
- return false;
- }
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
-
- /* Reset to opengl Defaults. (Untested, might not be needed) */
- glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
-
- blocksize = (ibuf->dds_data.fourcc == FOURCC_DXT1) ? 8 : 16;
- for (i = 0; i < ibuf->dds_data.nummipmaps && (width || height); i++) {
- if (width == 0) {
- width = 1;
- }
- if (height == 0) {
- height = 1;
- }
-
- size = ((width + 3) / 4) * ((height + 3) / 4) * blocksize;
-
- glCompressedTexImage2D(
- GL_TEXTURE_2D, i, format, width, height, 0, size, ibuf->dds_data.data + offset);
-
- offset += size;
- width >>= 1;
- height >>= 1;
- }
- /* Restore Blender default. */
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- /* set number of mipmap levels we have, needed in case they don't go down to 1x1 */
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, i - 1);
-
- glBindTexture(GL_TEXTURE_2D, 0);
- return true;
-#else
- UNUSED_VARS(ibuf, use_srgb, bindcode);
- return false;
-#endif
-}
-
-static void gpu_create_gl_tex_compressed(unsigned int *bind,
- eGPUTextureTarget textarget,
- Image *ima,
- ImBuf *ibuf)
-{
- /* For DDS we only support data, scene linear and sRGB. Converting to
- * different colorspace would break the compression. */
- const bool use_srgb = !(IMB_colormanagement_space_is_data(ibuf->rect_colorspace) ||
- IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace));
- const bool mipmap = GPU_get_mipmap();
- const bool half_float = (ibuf->flags & IB_halffloat) != 0;
-
-#ifndef WITH_DDS
- (void)ibuf;
- /* Fall back to uncompressed if DDS isn't enabled */
- gpu_create_gl_tex(
- bind, ibuf->rect, NULL, ibuf->x, ibuf->y, textarget, mipmap, half_float, use_srgb, ima);
-#else
-
- if (textarget == TEXTARGET_2D) {
- if (GPU_upload_dxt_texture(ibuf, use_srgb, bind)) {
- /* All went fine! */
- return;
- }
- }
- /* Fallback. */
- gpu_create_gl_tex(
- bind, ibuf->rect, NULL, ibuf->x, ibuf->y, textarget, mipmap, half_float, use_srgb, ima);
-#endif
-}
-
-/* these two functions are called on entering and exiting texture paint mode,
- * temporary disabling/enabling mipmapping on all images for quick texture
- * updates with glTexSubImage2D. images that didn't change don't have to be
- * re-uploaded to OpenGL */
-void GPU_paint_set_mipmap(Main *bmain, bool mipmap)
-{
-#ifndef GPU_STANDALONE
- if (!GTS.domipmap) {
- return;
- }
-
- GTS.texpaint = !mipmap;
-
- if (mipmap) {
-
- LISTBASE_FOREACH (Image *, ima, &bmain->images) {
- if (BKE_image_has_opengl_texture(ima)) {
- if (ima->gpuflag & IMA_GPU_MIPMAP_COMPLETE) {
- for (int eye = 0; eye < 2; eye++) {
- for (int a = 0; a < TEXTARGET_COUNT; a++) {
- if (ELEM(a, TEXTARGET_2D, TEXTARGET_2D_ARRAY)) {
- GPUTexture *tex = ima->gputexture[a][eye];
- if (tex != NULL) {
- GPU_texture_bind(tex, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
- GPU_texture_unbind(tex);
- }
- }
- }
- }
- }
- else {
- GPU_free_image(ima);
- }
- }
- else {
- ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
- }
- }
- }
- else {
- LISTBASE_FOREACH (Image *, ima, &bmain->images) {
- if (BKE_image_has_opengl_texture(ima)) {
- for (int eye = 0; eye < 2; eye++) {
- for (int a = 0; a < TEXTARGET_COUNT; a++) {
- if (ELEM(a, TEXTARGET_2D, TEXTARGET_2D_ARRAY)) {
- GPUTexture *tex = ima->gputexture[a][eye];
- if (tex != NULL) {
- GPU_texture_bind(tex, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
- GPU_texture_unbind(tex);
- }
- }
- }
- }
- }
- else {
- ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
- }
- }
- }
-#endif /* GPU_STANDALONE */
-}
-
-void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, int h)
-{
-#ifndef GPU_STANDALONE
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
- ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
-
- if ((ibuf == NULL) || (w == 0) || (h == 0)) {
- /* Full reload of texture. */
- GPU_free_image(ima);
- }
-
- GPUTexture *tex = ima->gputexture[TEXTARGET_2D][0];
- /* Check if we need to update the main gputexture. */
- if (tex != NULL && tile == ima->tiles.first) {
- gpu_texture_update_from_ibuf(tex, ima, ibuf, NULL, x, y, w, h);
- }
-
- /* Check if we need to update the array gputexture. */
- tex = ima->gputexture[TEXTARGET_2D_ARRAY][0];
- if (tex != NULL) {
- gpu_texture_update_from_ibuf(tex, ima, ibuf, tile, x, y, w, h);
- }
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
-#endif
-}
-
-/* Delayed GPU texture free. Image datablocks can be deleted by any thread,
- * but there may not be any active OpenGL context. In that case we push them
- * into a queue and free the buffers later. */
-static LinkNode *gpu_texture_free_queue = NULL;
-static ThreadMutex gpu_texture_queue_mutex = BLI_MUTEX_INITIALIZER;
-
-static void gpu_free_unused_buffers()
-{
- if (gpu_texture_free_queue == NULL) {
- return;
- }
-
- BLI_mutex_lock(&gpu_texture_queue_mutex);
-
- if (gpu_texture_free_queue != NULL) {
- GPUTexture *tex;
- while ((tex = (GPUTexture *)BLI_linklist_pop(&gpu_texture_free_queue))) {
- GPU_texture_free(tex);
- }
- gpu_texture_free_queue = NULL;
- }
-
- BLI_mutex_unlock(&gpu_texture_queue_mutex);
-}
-
-static void gpu_free_image(Image *ima, const bool immediate)
-{
- for (int eye = 0; eye < 2; eye++) {
- for (int i = 0; i < TEXTARGET_COUNT; i++) {
- if (ima->gputexture[i][eye] != NULL) {
- if (immediate) {
- GPU_texture_free(ima->gputexture[i][eye]);
- }
- else {
- BLI_mutex_lock(&gpu_texture_queue_mutex);
- BLI_linklist_prepend(&gpu_texture_free_queue, ima->gputexture[i][eye]);
- BLI_mutex_unlock(&gpu_texture_queue_mutex);
- }
-
- ima->gputexture[i][eye] = NULL;
- }
- }
- }
-
- ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
-}
-
-void GPU_free_unused_buffers()
-{
- if (BLI_thread_is_main()) {
- gpu_free_unused_buffers();
- }
-}
-
-void GPU_free_image(Image *ima)
-{
- gpu_free_image(ima, BLI_thread_is_main());
-}
-
-void GPU_free_images(Main *bmain)
-{
- if (bmain) {
- LISTBASE_FOREACH (Image *, ima, &bmain->images) {
- GPU_free_image(ima);
- }
- }
-}
-
-/* same as above but only free animated images */
-void GPU_free_images_anim(Main *bmain)
-{
- if (bmain) {
- LISTBASE_FOREACH (Image *, ima, &bmain->images) {
- if (BKE_image_is_animated(ima)) {
- GPU_free_image(ima);
- }
- }
- }
-}
-
-void GPU_free_images_old(Main *bmain)
-{
- static int lasttime = 0;
- int ctime = (int)PIL_check_seconds_timer();
-
- /*
- * Run garbage collector once for every collecting period of time
- * if textimeout is 0, that's the option to NOT run the collector
- */
- if (U.textimeout == 0 || ctime % U.texcollectrate || ctime == lasttime) {
- return;
- }
-
- /* of course not! */
- if (G.is_rendering) {
- return;
- }
-
- lasttime = ctime;
-
- LISTBASE_FOREACH (Image *, ima, &bmain->images) {
- if ((ima->flag & IMA_NOCOLLECT) == 0 && ctime - ima->lastused > U.textimeout) {
- /* If it's in GL memory, deallocate and set time tag to current time
- * This gives textures a "second chance" to be used before dying. */
- if (BKE_image_has_opengl_texture(ima)) {
- GPU_free_image(ima);
- ima->lastused = ctime;
- }
- /* Otherwise, just kill the buffers */
- else {
- BKE_image_free_buffers(ima);
- }
- }
- }
-}
diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.cc
index 130e8fe7da1..e203ffd848f 100644
--- a/source/blender/gpu/intern/gpu_uniformbuffer.c
+++ b/source/blender/gpu/intern/gpu_uniformbuffer.cc
@@ -25,8 +25,9 @@
#include <string.h>
#include "BLI_blenlib.h"
+#include "BLI_math_base.h"
-#include "gpu_context_private.h"
+#include "gpu_context_private.hh"
#include "gpu_node_graph.h"
#include "GPU_extensions.h"
@@ -34,217 +35,63 @@
#include "GPU_material.h"
#include "GPU_uniformbuffer.h"
-typedef enum eGPUUniformBufferFlag {
- GPU_UBO_FLAG_INITIALIZED = (1 << 0),
- GPU_UBO_FLAG_DIRTY = (1 << 1),
-} eGPUUniformBufferFlag;
-
-typedef enum eGPUUniformBufferType {
- GPU_UBO_STATIC = 0,
- GPU_UBO_DYNAMIC = 1,
-} eGPUUniformBufferType;
-
-struct GPUUniformBuffer {
- int size; /* in bytes */
- GLuint bindcode; /* opengl identifier for UBO */
- int bindpoint; /* current binding point */
- eGPUUniformBufferType type;
-};
-
-#define GPUUniformBufferStatic GPUUniformBuffer
-
-typedef struct GPUUniformBufferDynamic {
- GPUUniformBuffer buffer;
- void *data; /* Continuous memory block to copy to GPU. */
- char flag;
-} GPUUniformBufferDynamic;
-
-/* Prototypes */
-static eGPUType get_padded_gpu_type(struct LinkData *link);
-static void gpu_uniformbuffer_inputs_sort(struct ListBase *inputs);
-
-/* Only support up to this type, if you want to extend it, make sure the
- * padding logic is correct for the new types. */
-#define MAX_UBO_GPU_TYPE GPU_MAT4
-
-static void gpu_uniformbuffer_initialize(GPUUniformBuffer *ubo, const void *data)
-{
- glBindBuffer(GL_UNIFORM_BUFFER, ubo->bindcode);
- glBufferData(GL_UNIFORM_BUFFER, ubo->size, data, GL_DYNAMIC_DRAW);
- glBindBuffer(GL_UNIFORM_BUFFER, 0);
-}
+typedef struct GPUUniformBuffer {
+ /** Data size in bytes. */
+ int size;
+ /** GL handle for UBO. */
+ GLuint bindcode;
+ /** Current binding point. */
+ int bindpoint;
+ /** Continuous memory block to copy to GPU. Is own by the GPUUniformBuffer. */
+ void *data;
+} GPUUniformBuffer;
GPUUniformBuffer *GPU_uniformbuffer_create(int size, const void *data, char err_out[256])
{
/* Make sure that UBO is padded to size of vec4 */
BLI_assert((size % 16) == 0);
- GPUUniformBuffer *ubo = MEM_callocN(sizeof(GPUUniformBufferStatic), "GPUUniformBufferStatic");
- ubo->size = size;
- ubo->bindpoint = -1;
-
- /* Generate Buffer object */
- ubo->bindcode = GPU_buf_alloc();
-
- if (!ubo->bindcode) {
- if (err_out) {
- BLI_strncpy(err_out, "GPUUniformBuffer: UBO create failed", 256);
- }
- GPU_uniformbuffer_free(ubo);
- return NULL;
- }
-
- if (ubo->size > GPU_max_ubo_size()) {
+ if (size > GPU_max_ubo_size()) {
if (err_out) {
BLI_strncpy(err_out, "GPUUniformBuffer: UBO too big", 256);
}
- GPU_uniformbuffer_free(ubo);
- return NULL;
- }
-
- gpu_uniformbuffer_initialize(ubo, data);
- return ubo;
-}
-
-/**
- * Create dynamic UBO from parameters
- * Return NULL if failed to create or if \param inputs: is empty.
- *
- * \param inputs: ListBase of #BLI_genericNodeN(#GPUInput).
- */
-GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_out[256])
-{
- /* There is no point on creating an UBO if there is no arguments. */
- if (BLI_listbase_is_empty(inputs)) {
return NULL;
}
- GPUUniformBufferDynamic *ubo = MEM_callocN(sizeof(GPUUniformBufferDynamic),
- "GPUUniformBufferDynamic");
- ubo->buffer.type = GPU_UBO_DYNAMIC;
- ubo->buffer.bindpoint = -1;
- ubo->flag = GPU_UBO_FLAG_DIRTY;
-
- /* Generate Buffer object. */
- ubo->buffer.bindcode = GPU_buf_alloc();
-
- if (!ubo->buffer.bindcode) {
- if (err_out) {
- BLI_strncpy(err_out, "GPUUniformBuffer: UBO create failed", 256);
- }
- GPU_uniformbuffer_free(&ubo->buffer);
- return NULL;
- }
-
- if (ubo->buffer.size > GPU_max_ubo_size()) {
- if (err_out) {
- BLI_strncpy(err_out, "GPUUniformBuffer: UBO too big", 256);
- }
- GPU_uniformbuffer_free(&ubo->buffer);
- return NULL;
- }
-
- /* Make sure we comply to the ubo alignment requirements. */
- gpu_uniformbuffer_inputs_sort(inputs);
-
- LISTBASE_FOREACH (LinkData *, link, inputs) {
- const eGPUType gputype = get_padded_gpu_type(link);
- ubo->buffer.size += gputype * sizeof(float);
- }
-
- /* Round up to size of vec4 */
- ubo->buffer.size = ((ubo->buffer.size + 15) / 16) * 16;
-
- /* Allocate the data. */
- ubo->data = MEM_mallocN(ubo->buffer.size, __func__);
+ GPUUniformBuffer *ubo = (GPUUniformBuffer *)MEM_mallocN(sizeof(GPUUniformBuffer), __func__);
+ ubo->size = size;
+ ubo->data = NULL;
+ ubo->bindcode = 0;
+ ubo->bindpoint = -1;
- /* Now that we know the total ubo size we can start populating it. */
- float *offset = ubo->data;
- LISTBASE_FOREACH (LinkData *, link, inputs) {
- GPUInput *input = link->data;
- memcpy(offset, input->vec, input->type * sizeof(float));
- offset += get_padded_gpu_type(link);
+ /* Direct init. */
+ if (data != NULL) {
+ GPU_uniformbuffer_update(ubo, data);
}
- /* Note since we may create the UBOs in the CPU in a different thread than the main drawing one,
- * we don't create the UBO in the GPU here. This will happen when we first bind the UBO.
- */
-
- return &ubo->buffer;
-}
-
-/**
- * Free the data
- */
-static void gpu_uniformbuffer_dynamic_free(GPUUniformBuffer *ubo_)
-{
- BLI_assert(ubo_->type == GPU_UBO_DYNAMIC);
- GPUUniformBufferDynamic *ubo = (GPUUniformBufferDynamic *)ubo_;
-
- ubo->buffer.size = 0;
- if (ubo->data) {
- MEM_freeN(ubo->data);
- }
+ return ubo;
}
void GPU_uniformbuffer_free(GPUUniformBuffer *ubo)
{
- if (ubo->type == GPU_UBO_DYNAMIC) {
- gpu_uniformbuffer_dynamic_free(ubo);
- }
-
+ MEM_SAFE_FREE(ubo->data);
GPU_buf_free(ubo->bindcode);
MEM_freeN(ubo);
}
-static void gpu_uniformbuffer_update(GPUUniformBuffer *ubo, const void *data)
-{
- glBindBuffer(GL_UNIFORM_BUFFER, ubo->bindcode);
- glBufferSubData(GL_UNIFORM_BUFFER, 0, ubo->size, data);
- glBindBuffer(GL_UNIFORM_BUFFER, 0);
-}
-
-void GPU_uniformbuffer_update(GPUUniformBuffer *ubo, const void *data)
-{
- BLI_assert(ubo->type == GPU_UBO_STATIC);
- gpu_uniformbuffer_update(ubo, data);
-}
-
-/**
- * We need to recalculate the internal data, and re-generate it
- * from its populated items.
- */
-void GPU_uniformbuffer_dynamic_update(GPUUniformBuffer *ubo_)
-{
- BLI_assert(ubo_->type == GPU_UBO_DYNAMIC);
- GPUUniformBufferDynamic *ubo = (GPUUniformBufferDynamic *)ubo_;
-
- if (ubo->flag & GPU_UBO_FLAG_INITIALIZED) {
- gpu_uniformbuffer_update(ubo_, ubo->data);
- }
- else {
- ubo->flag |= GPU_UBO_FLAG_INITIALIZED;
- gpu_uniformbuffer_initialize(ubo_, ubo->data);
- }
-
- ubo->flag &= ~GPU_UBO_FLAG_DIRTY;
-}
-
/**
* We need to pad some data types (vec3) on the C side
* To match the GPU expected memory block alignment.
*/
static eGPUType get_padded_gpu_type(LinkData *link)
{
- GPUInput *input = link->data;
+ GPUInput *input = (GPUInput *)link->data;
eGPUType gputype = input->type;
-
/* Unless the vec3 is followed by a float we need to treat it as a vec4. */
if (gputype == GPU_VEC3 && (link->next != NULL) &&
(((GPUInput *)link->next->data)->type != GPU_FLOAT)) {
gputype = GPU_VEC4;
}
-
return gputype;
}
@@ -254,8 +101,9 @@ static eGPUType get_padded_gpu_type(LinkData *link)
*/
static int inputs_cmp(const void *a, const void *b)
{
- const LinkData *link_a = a, *link_b = b;
- const GPUInput *input_a = link_a->data, *input_b = link_b->data;
+ const LinkData *link_a = (const LinkData *)a, *link_b = (const LinkData *)b;
+ const GPUInput *input_a = (const GPUInput *)link_a->data;
+ const GPUInput *input_b = (const GPUInput *)link_b->data;
return input_a->type < input_b->type ? 1 : 0;
}
@@ -265,22 +113,26 @@ static int inputs_cmp(const void *a, const void *b)
*/
static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
{
+/* Only support up to this type, if you want to extend it, make sure the
+ * padding logic is correct for the new types. */
+#define MAX_UBO_GPU_TYPE GPU_MAT4
+
/* Order them as mat4, vec4, vec3, vec2, float. */
BLI_listbase_sort(inputs, inputs_cmp);
/* Creates a lookup table for the different types; */
LinkData *inputs_lookup[MAX_UBO_GPU_TYPE + 1] = {NULL};
- eGPUType cur_type = MAX_UBO_GPU_TYPE + 1;
+ eGPUType cur_type = static_cast<eGPUType>(MAX_UBO_GPU_TYPE + 1);
LISTBASE_FOREACH (LinkData *, link, inputs) {
- GPUInput *input = link->data;
+ GPUInput *input = (GPUInput *)link->data;
if (input->type == GPU_MAT3) {
/* Alignment for mat3 is not handled currently, so not supported */
BLI_assert(!"mat3 not supported in UBO");
continue;
}
- else if (input->type > MAX_UBO_GPU_TYPE) {
+ if (input->type > MAX_UBO_GPU_TYPE) {
BLI_assert(!"GPU type not supported in UBO");
continue;
}
@@ -288,10 +140,9 @@ static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
if (input->type == cur_type) {
continue;
}
- else {
- inputs_lookup[input->type] = link;
- cur_type = input->type;
- }
+
+ inputs_lookup[input->type] = link;
+ cur_type = input->type;
}
/* If there is no GPU_VEC3 there is no need for alignment. */
@@ -319,6 +170,74 @@ static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
link = link_next;
}
+#undef MAX_UBO_GPU_TYPE
+}
+
+/**
+ * Create dynamic UBO from parameters
+ * Return NULL if failed to create or if \param inputs: is empty.
+ *
+ * \param inputs: ListBase of #BLI_genericNodeN(#GPUInput).
+ */
+GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_out[256])
+{
+ /* There is no point on creating an UBO if there is no arguments. */
+ if (BLI_listbase_is_empty(inputs)) {
+ return NULL;
+ }
+ /* Make sure we comply to the ubo alignment requirements. */
+ gpu_uniformbuffer_inputs_sort(inputs);
+
+ size_t buffer_size = 0;
+
+ LISTBASE_FOREACH (LinkData *, link, inputs) {
+ const eGPUType gputype = get_padded_gpu_type(link);
+ buffer_size += gputype * sizeof(float);
+ }
+ /* Round up to size of vec4. (Opengl Requirement) */
+ size_t alignment = sizeof(float[4]);
+ buffer_size = divide_ceil_u(buffer_size, alignment) * alignment;
+ void *data = MEM_mallocN(buffer_size, __func__);
+
+ /* Now that we know the total ubo size we can start populating it. */
+ float *offset = (float *)data;
+ LISTBASE_FOREACH (LinkData *, link, inputs) {
+ GPUInput *input = (GPUInput *)link->data;
+ memcpy(offset, input->vec, input->type * sizeof(float));
+ offset += get_padded_gpu_type(link);
+ }
+
+ /* Pass data as NULL for late init. */
+ GPUUniformBuffer *ubo = GPU_uniformbuffer_create(buffer_size, NULL, err_out);
+ /* Data will be update just before binding. */
+ ubo->data = data;
+ return ubo;
+}
+
+static void gpu_uniformbuffer_init(GPUUniformBuffer *ubo)
+{
+ BLI_assert(ubo->bindcode == 0);
+ ubo->bindcode = GPU_buf_alloc();
+
+ if (ubo->bindcode == 0) {
+ fprintf(stderr, "GPUUniformBuffer: UBO create failed");
+ BLI_assert(0);
+ return;
+ }
+
+ glBindBuffer(GL_UNIFORM_BUFFER, ubo->bindcode);
+ glBufferData(GL_UNIFORM_BUFFER, ubo->size, NULL, GL_DYNAMIC_DRAW);
+}
+
+void GPU_uniformbuffer_update(GPUUniformBuffer *ubo, const void *data)
+{
+ if (ubo->bindcode == 0) {
+ gpu_uniformbuffer_init(ubo);
+ }
+
+ glBindBuffer(GL_UNIFORM_BUFFER, ubo->bindcode);
+ glBufferSubData(GL_UNIFORM_BUFFER, 0, ubo->size, data);
+ glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number)
@@ -328,28 +247,30 @@ void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number)
return;
}
- if (ubo->type == GPU_UBO_DYNAMIC) {
- GPUUniformBufferDynamic *ubo_dynamic = (GPUUniformBufferDynamic *)ubo;
- if (ubo_dynamic->flag & GPU_UBO_FLAG_DIRTY) {
- GPU_uniformbuffer_dynamic_update(ubo);
- }
+ if (ubo->bindcode == 0) {
+ gpu_uniformbuffer_init(ubo);
}
- if (ubo->bindcode != 0) {
- glBindBufferBase(GL_UNIFORM_BUFFER, number, ubo->bindcode);
+ if (ubo->data != NULL) {
+ GPU_uniformbuffer_update(ubo, ubo->data);
+ MEM_SAFE_FREE(ubo->data);
}
+ glBindBufferBase(GL_UNIFORM_BUFFER, number, ubo->bindcode);
ubo->bindpoint = number;
}
void GPU_uniformbuffer_unbind(GPUUniformBuffer *ubo)
{
- ubo->bindpoint = -1;
+#ifndef NDEBUG
+ glBindBufferBase(GL_UNIFORM_BUFFER, ubo->bindpoint, 0);
+#endif
+ ubo->bindpoint = 0;
}
-int GPU_uniformbuffer_bindpoint(GPUUniformBuffer *ubo)
+void GPU_uniformbuffer_unbind_all(void)
{
- return ubo->bindpoint;
+ for (int i = 0; i < GPU_max_ubo_binds(); i++) {
+ glBindBufferBase(GL_UNIFORM_BUFFER, i, 0);
+ }
}
-
-#undef MAX_UBO_GPU_TYPE
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.cc
index 3b4d469542c..67ad8835b6a 100644
--- a/source/blender/gpu/intern/gpu_vertex_buffer.c
+++ b/source/blender/gpu/intern/gpu_vertex_buffer.cc
@@ -27,7 +27,7 @@
#include "GPU_vertex_buffer.h"
-#include "gpu_context_private.h"
+#include "gpu_context_private.hh"
#include "gpu_vertex_format_private.h"
#include <stdlib.h>
@@ -39,17 +39,22 @@ static uint vbo_memory_usage;
static GLenum convert_usage_type_to_gl(GPUUsageType type)
{
- static const GLenum table[] = {
- [GPU_USAGE_STREAM] = GL_STREAM_DRAW,
- [GPU_USAGE_STATIC] = GL_STATIC_DRAW,
- [GPU_USAGE_DYNAMIC] = GL_DYNAMIC_DRAW,
- };
- return table[type];
+ switch (type) {
+ case GPU_USAGE_STREAM:
+ return GL_STREAM_DRAW;
+ case GPU_USAGE_DYNAMIC:
+ return GL_DYNAMIC_DRAW;
+ case GPU_USAGE_STATIC:
+ return GL_STATIC_DRAW;
+ default:
+ BLI_assert(0);
+ return GL_STATIC_DRAW;
+ }
}
GPUVertBuf *GPU_vertbuf_create(GPUUsageType usage)
{
- GPUVertBuf *verts = MEM_mallocN(sizeof(GPUVertBuf), "GPUVertBuf");
+ GPUVertBuf *verts = (GPUVertBuf *)MEM_mallocN(sizeof(GPUVertBuf), "GPUVertBuf");
GPU_vertbuf_init(verts, usage);
return verts;
}
@@ -109,7 +114,7 @@ GPUVertBuf *GPU_vertbuf_duplicate(GPUVertBuf *verts)
}
if (verts->data) {
- verts_dst->data = MEM_dupallocN(verts->data);
+ verts_dst->data = (uchar *)MEM_dupallocN(verts->data);
}
return verts_dst;
}
@@ -161,7 +166,7 @@ void GPU_vertbuf_data_alloc(GPUVertBuf *verts, uint v_len)
#endif
verts->dirty = true;
verts->vertex_len = verts->vertex_alloc = v_len;
- verts->data = MEM_mallocN(sizeof(GLubyte) * GPU_vertbuf_size_get(verts), "GPUVertBuf data");
+ verts->data = (uchar *)MEM_mallocN(sizeof(GLubyte) * GPU_vertbuf_size_get(verts), __func__);
}
/* resize buffer keeping existing data */
@@ -178,7 +183,7 @@ void GPU_vertbuf_data_resize(GPUVertBuf *verts, uint v_len)
#endif
verts->dirty = true;
verts->vertex_len = verts->vertex_alloc = v_len;
- verts->data = MEM_reallocN(verts->data, sizeof(GLubyte) * GPU_vertbuf_size_get(verts));
+ verts->data = (uchar *)MEM_reallocN(verts->data, sizeof(GLubyte) * GPU_vertbuf_size_get(verts));
}
/* Set vertex count but does not change allocation.
diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.cc
index 585a22277b2..2e8017660d0 100644
--- a/source/blender/gpu/intern/gpu_vertex_format.c
+++ b/source/blender/gpu/intern/gpu_vertex_format.cc
@@ -63,21 +63,29 @@ void GPU_vertformat_copy(GPUVertFormat *dest, const GPUVertFormat *src)
memcpy(dest, src, sizeof(GPUVertFormat));
}
-static GLenum convert_comp_type_to_gl(GPUVertCompType type)
+GLenum convert_comp_type_to_gl(GPUVertCompType type)
{
- static const GLenum table[] = {
- [GPU_COMP_I8] = GL_BYTE,
- [GPU_COMP_U8] = GL_UNSIGNED_BYTE,
- [GPU_COMP_I16] = GL_SHORT,
- [GPU_COMP_U16] = GL_UNSIGNED_SHORT,
- [GPU_COMP_I32] = GL_INT,
- [GPU_COMP_U32] = GL_UNSIGNED_INT,
-
- [GPU_COMP_F32] = GL_FLOAT,
-
- [GPU_COMP_I10] = GL_INT_2_10_10_10_REV,
- };
- return table[type];
+ switch (type) {
+ case GPU_COMP_I8:
+ return GL_BYTE;
+ case GPU_COMP_U8:
+ return GL_UNSIGNED_BYTE;
+ case GPU_COMP_I16:
+ return GL_SHORT;
+ case GPU_COMP_U16:
+ return GL_UNSIGNED_SHORT;
+ case GPU_COMP_I32:
+ return GL_INT;
+ case GPU_COMP_U32:
+ return GL_UNSIGNED_INT;
+ case GPU_COMP_F32:
+ return GL_FLOAT;
+ case GPU_COMP_I10:
+ return GL_INT_2_10_10_10_REV;
+ default:
+ BLI_assert(0);
+ return GL_FLOAT;
+ }
}
static uint comp_sz(GPUVertCompType type)
@@ -94,7 +102,7 @@ static uint attr_sz(const GPUVertAttr *a)
if (a->comp_type == GPU_COMP_I10) {
return 4; /* always packed as 10_10_10_2 */
}
- return a->comp_len * comp_sz(a->comp_type);
+ return a->comp_len * comp_sz(static_cast<GPUVertCompType>(a->comp_type));
}
static uint attr_align(const GPUVertAttr *a)
@@ -102,13 +110,12 @@ static uint attr_align(const GPUVertAttr *a)
if (a->comp_type == GPU_COMP_I10) {
return 4; /* always packed as 10_10_10_2 */
}
- uint c = comp_sz(a->comp_type);
+ uint c = comp_sz(static_cast<GPUVertCompType>(a->comp_type));
if (a->comp_len == 3 && c <= 2) {
return 4 * c; /* AMD HW can't fetch these well, so pad it out (other vendors too?) */
}
- else {
- return c; /* most fetches are ok if components are naturally aligned */
- }
+
+ return c; /* most fetches are ok if components are naturally aligned */
}
uint vertex_buffer_size(const GPUVertFormat *format, uint vertex_len)
@@ -185,7 +192,6 @@ uint GPU_vertformat_attr_add(GPUVertFormat *format,
attr->names[attr->name_len++] = copy_attr_name(format, name);
attr->comp_type = comp_type;
- attr->gl_comp_type = convert_comp_type_to_gl(comp_type);
attr->comp_len = (comp_type == GPU_COMP_I10) ?
4 :
comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */
@@ -279,7 +285,7 @@ void GPU_vertformat_attr_rename(GPUVertFormat *format, int attr_id, const char *
/* Encode 8 original bytes into 11 safe bytes. */
static void safe_bytes(char out[11], const char data[8])
{
- char safe_chars[63] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
+ char safe_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
uint64_t in = *(uint64_t *)data;
for (int i = 0; i < 11; i++) {
@@ -368,14 +374,6 @@ static void show_pack(uint a_idx, uint sz, uint pad)
void VertexFormat_pack(GPUVertFormat *format)
{
- /* For now, attributes are packed in the order they were added,
- * making sure each attribute is naturally aligned (add padding where necessary)
- * Later we can implement more efficient packing w/ reordering
- * (keep attribute ID order, adjust their offsets to reorder in buffer). */
-
- /* TODO: realloc just enough to hold the final combo string. And just enough to
- * hold used attributes, not all 16. */
-
GPUVertAttr *a0 = &format->attrs[0];
a0->offset = 0;
uint offset = a0->sz;
@@ -512,7 +510,6 @@ void GPU_vertformat_from_shader(GPUVertFormat *format, const GPUShader *shader)
attr->sz = attr->comp_len * 4;
attr->fetch_mode = fetch_mode;
attr->comp_type = comp_type;
- attr->gl_comp_type = convert_comp_type_to_gl(comp_type);
attr += 1;
}
}
diff --git a/source/blender/gpu/intern/gpu_vertex_format_private.h b/source/blender/gpu/intern/gpu_vertex_format_private.h
index 22373a6394a..45523c0e956 100644
--- a/source/blender/gpu/intern/gpu_vertex_format_private.h
+++ b/source/blender/gpu/intern/gpu_vertex_format_private.h
@@ -23,8 +23,7 @@
* GPU vertex format
*/
-#ifndef __GPU_VERTEX_FORMAT_PRIVATE_H__
-#define __GPU_VERTEX_FORMAT_PRIVATE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -33,9 +32,8 @@ extern "C" {
void VertexFormat_pack(GPUVertFormat *format);
uint padding(uint offset, uint alignment);
uint vertex_buffer_size(const GPUVertFormat *format, uint vertex_len);
+GLenum convert_comp_type_to_gl(GPUVertCompType type);
#ifdef __cplusplus
}
#endif
-
-#endif /* __GPU_VERTEX_FORMAT_PRIVATE_H__ */
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index ed5297f0a4a..ba938349761 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -912,9 +912,8 @@ GPUTexture *GPU_viewport_color_texture(GPUViewport *viewport, int view)
if (viewport->active_view == view) {
return dtxl->color;
}
- else {
- return dtxl->color_stereo;
- }
+
+ return dtxl->color_stereo;
}
return NULL;
@@ -1035,3 +1034,15 @@ void GPU_viewport_free(GPUViewport *viewport)
MEM_freeN(viewport);
}
+
+GPUFrameBuffer *GPU_viewport_framebuffer_default_get(GPUViewport *viewport)
+{
+ DefaultFramebufferList *fbl = GPU_viewport_framebuffer_list_get(viewport);
+ return fbl->default_fb;
+}
+
+GPUFrameBuffer *GPU_viewport_framebuffer_overlay_get(GPUViewport *viewport)
+{
+ DefaultFramebufferList *fbl = GPU_viewport_framebuffer_list_get(viewport);
+ return fbl->overlay_fb;
+}
diff --git a/source/blender/gpu/opengl/gl_backend.hh b/source/blender/gpu/opengl/gl_backend.hh
new file mode 100644
index 00000000000..f7c01b2f184
--- /dev/null
+++ b/source/blender/gpu/opengl/gl_backend.hh
@@ -0,0 +1,57 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright 2020, Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup gpu
+ */
+
+#pragma once
+
+#include "gpu_backend.hh"
+
+#include "BLI_vector.hh"
+
+#include "gl_context.hh"
+
+namespace blender {
+namespace gpu {
+
+class GLBackend : public GPUBackend {
+ private:
+ GLSharedOrphanLists shared_orphan_list_;
+
+ public:
+ GPUContext *context_alloc(void *ghost_window)
+ {
+ return new GLContext(ghost_window, shared_orphan_list_);
+ };
+
+ /* TODO remove */
+ void buf_free(GLuint buf_id);
+ void tex_free(GLuint tex_id);
+ void orphans_add(Vector<GLuint> &orphan_list, std::mutex &list_mutex, unsigned int id)
+ {
+ list_mutex.lock();
+ orphan_list.append(id);
+ list_mutex.unlock();
+ }
+};
+
+} // namespace gpu
+} // namespace blender
diff --git a/source/blender/gpu/opengl/gl_context.cc b/source/blender/gpu/opengl/gl_context.cc
new file mode 100644
index 00000000000..37c84abaa7f
--- /dev/null
+++ b/source/blender/gpu/opengl/gl_context.cc
@@ -0,0 +1,239 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright 2020, Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup gpu
+ */
+
+#include "BLI_assert.h"
+#include "BLI_utildefines.h"
+
+#include "GPU_framebuffer.h"
+
+#include "GHOST_C-api.h"
+
+#include "gpu_context_private.hh"
+
+#include "gl_backend.hh" /* TODO remove */
+#include "gl_context.hh"
+
+using namespace blender;
+using namespace blender::gpu;
+
+/* -------------------------------------------------------------------- */
+/** \name Constructor / Destructor
+ * \{ */
+
+GLContext::GLContext(void *ghost_window, GLSharedOrphanLists &shared_orphan_list)
+ : shared_orphan_list_(shared_orphan_list)
+{
+ default_framebuffer_ = ghost_window ?
+ GHOST_GetDefaultOpenGLFramebuffer((GHOST_WindowHandle)ghost_window) :
+ 0;
+
+ glGenVertexArrays(1, &default_vao_);
+
+ float data[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+ glGenBuffers(1, &default_attr_vbo_);
+ glBindBuffer(GL_ARRAY_BUFFER, default_attr_vbo_);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+}
+
+GLContext::~GLContext()
+{
+ BLI_assert(orphaned_framebuffers_.is_empty());
+ BLI_assert(orphaned_vertarrays_.is_empty());
+ /* For now don't allow GPUFrameBuffers to be reuse in another context. */
+ BLI_assert(framebuffers_.is_empty());
+ /* Delete vaos so the batch can be reused in another context. */
+ for (GPUBatch *batch : batches_) {
+ GPU_batch_vao_cache_clear(batch);
+ }
+ glDeleteVertexArrays(1, &default_vao_);
+ glDeleteBuffers(1, &default_attr_vbo_);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Activate / Deactivate context
+ * \{ */
+
+void GLContext::activate(void)
+{
+ /* Make sure no other context is already bound to this thread. */
+ BLI_assert(is_active_ == false);
+
+ is_active_ = true;
+ thread_ = pthread_self();
+
+ /* Clear accumulated orphans. */
+ orphans_clear();
+}
+
+void GLContext::deactivate(void)
+{
+ is_active_ = false;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Safe object deletion
+ *
+ * GPU objects can be freed when the context is not bound.
+ * In this case we delay the deletion until the context is bound again.
+ * \{ */
+
+void GLSharedOrphanLists::orphans_clear(void)
+{
+ /* Check if any context is active on this thread! */
+ BLI_assert(GPU_context_active_get());
+
+ lists_mutex.lock();
+ if (!buffers.is_empty()) {
+ glDeleteBuffers((uint)buffers.size(), buffers.data());
+ buffers.clear();
+ }
+ if (!textures.is_empty()) {
+ glDeleteTextures((uint)textures.size(), textures.data());
+ textures.clear();
+ }
+ lists_mutex.unlock();
+};
+
+void GLContext::orphans_clear(void)
+{
+ /* Check if context has been activated by another thread! */
+ BLI_assert(this->is_active_on_thread());
+
+ lists_mutex_.lock();
+ if (!orphaned_vertarrays_.is_empty()) {
+ glDeleteVertexArrays((uint)orphaned_vertarrays_.size(), orphaned_vertarrays_.data());
+ orphaned_vertarrays_.clear();
+ }
+ if (!orphaned_framebuffers_.is_empty()) {
+ glDeleteFramebuffers((uint)orphaned_framebuffers_.size(), orphaned_framebuffers_.data());
+ orphaned_framebuffers_.clear();
+ }
+ lists_mutex_.unlock();
+
+ shared_orphan_list_.orphans_clear();
+};
+
+void GLContext::orphans_add(Vector<GLuint> &orphan_list, std::mutex &list_mutex, GLuint id)
+{
+ list_mutex.lock();
+ orphan_list.append(id);
+ list_mutex.unlock();
+}
+
+void GLContext::vao_free(GLuint vao_id)
+{
+ if (this == GPU_context_active_get()) {
+ glDeleteVertexArrays(1, &vao_id);
+ }
+ else {
+ orphans_add(orphaned_vertarrays_, lists_mutex_, vao_id);
+ }
+}
+
+void GLContext::fbo_free(GLuint fbo_id)
+{
+ if (this == GPU_context_active_get()) {
+ glDeleteFramebuffers(1, &fbo_id);
+ }
+ else {
+ orphans_add(orphaned_framebuffers_, lists_mutex_, fbo_id);
+ }
+}
+
+void GLBackend::buf_free(GLuint buf_id)
+{
+ /* Any context can free. */
+ if (GPU_context_active_get()) {
+ glDeleteBuffers(1, &buf_id);
+ }
+ else {
+ orphans_add(shared_orphan_list_.buffers, shared_orphan_list_.lists_mutex, buf_id);
+ }
+}
+
+void GLBackend::tex_free(GLuint tex_id)
+{
+ /* Any context can free. */
+ if (GPU_context_active_get()) {
+ glDeleteTextures(1, &tex_id);
+ }
+ else {
+ orphans_add(shared_orphan_list_.textures, shared_orphan_list_.lists_mutex, tex_id);
+ }
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Linked object deletion
+ *
+ * These objects contain data that are stored per context. We
+ * need to do some cleanup if they are used accross context or if context
+ * is discarded.
+ * \{ */
+
+void GLContext::batch_register(struct GPUBatch *batch)
+{
+ lists_mutex_.lock();
+ batches_.add(batch);
+ lists_mutex_.unlock();
+}
+
+void GLContext::batch_unregister(struct GPUBatch *batch)
+{
+ /* vao_cache_clear() can acquire lists_mutex_ so avoid deadlock. */
+ // reinterpret_cast<GLBatch *>(batch)->vao_cache_clear();
+
+ lists_mutex_.lock();
+ batches_.remove(batch);
+ lists_mutex_.unlock();
+}
+
+void GLContext::framebuffer_register(struct GPUFrameBuffer *fb)
+{
+#ifdef DEBUG
+ lists_mutex_.lock();
+ framebuffers_.add(fb);
+ lists_mutex_.unlock();
+#else
+ UNUSED_VARS(fb);
+#endif
+}
+
+void GLContext::framebuffer_unregister(struct GPUFrameBuffer *fb)
+{
+#ifdef DEBUG
+ lists_mutex_.lock();
+ framebuffers_.remove(fb);
+ lists_mutex_.unlock();
+#else
+ UNUSED_VARS(fb);
+#endif
+}
+
+/** \} */
diff --git a/source/blender/gpu/opengl/gl_context.hh b/source/blender/gpu/opengl/gl_context.hh
new file mode 100644
index 00000000000..3b55965b9d1
--- /dev/null
+++ b/source/blender/gpu/opengl/gl_context.hh
@@ -0,0 +1,97 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright 2020, Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup gpu
+ */
+
+#pragma once
+
+#include "gpu_context_private.hh"
+
+#include "BLI_set.hh"
+#include "BLI_vector.hh"
+
+#include "glew-mx.h"
+
+#include <iostream>
+#include <mutex>
+#include <unordered_set>
+#include <vector>
+
+namespace blender {
+namespace gpu {
+
+class GLSharedOrphanLists {
+ public:
+ /** Mutex for the bellow structures. */
+ std::mutex lists_mutex;
+ /** Buffers and textures are shared across context. Any context can free them. */
+ Vector<GLuint> textures;
+ Vector<GLuint> buffers;
+
+ public:
+ void orphans_clear(void);
+};
+
+class GLContext : public GPUContext {
+ /* TODO(fclem) these needs to become private. */
+ public:
+ /** Default VAO for procedural draw calls. */
+ GLuint default_vao_;
+ /** Default framebuffer object for some GL implementation. */
+ GLuint default_framebuffer_;
+ /** VBO for missing vertex attrib binding. Avoid undefined behavior on some implementation. */
+ GLuint default_attr_vbo_;
+ /**
+ * GPUBatch & GPUFramebuffer have references to the context they are from, in the case the
+ * context is destroyed, we need to remove any reference to it.
+ */
+ Set<GPUBatch *> batches_;
+ Set<GPUFrameBuffer *> framebuffers_;
+ /** Mutex for the bellow structures. */
+ std::mutex lists_mutex_;
+ /** VertexArrays and framebuffers are not shared across context. */
+ Vector<GLuint> orphaned_vertarrays_;
+ Vector<GLuint> orphaned_framebuffers_;
+ /** GLBackend onws this data. */
+ GLSharedOrphanLists &shared_orphan_list_;
+
+ public:
+ GLContext(void *ghost_window, GLSharedOrphanLists &shared_orphan_list);
+ ~GLContext();
+
+ void activate(void) override;
+ void deactivate(void) override;
+
+ /* TODO(fclem) these needs to become private. */
+ public:
+ void orphans_add(Vector<GLuint> &orphan_list, std::mutex &list_mutex, GLuint id);
+ void orphans_clear(void);
+
+ void vao_free(GLuint vao_id);
+ void fbo_free(GLuint fbo_id);
+ void batch_register(struct GPUBatch *batch);
+ void batch_unregister(struct GPUBatch *batch);
+ void framebuffer_register(struct GPUFrameBuffer *fb);
+ void framebuffer_unregister(struct GPUFrameBuffer *fb);
+};
+
+} // namespace gpu
+} // namespace blender
diff --git a/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl
new file mode 100644
index 00000000000..f7bf3d33361
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl
@@ -0,0 +1,87 @@
+
+vec3 calc_barycentric_distances(vec3 pos0, vec3 pos1, vec3 pos2)
+{
+ vec3 edge21 = pos2 - pos1;
+ vec3 edge10 = pos1 - pos0;
+ vec3 edge02 = pos0 - pos2;
+ vec3 d21 = normalize(edge21);
+ vec3 d10 = normalize(edge10);
+ vec3 d02 = normalize(edge02);
+
+ vec3 dists;
+ float d = dot(d21, edge02);
+ dists.x = sqrt(dot(edge02, edge02) - d * d);
+ d = dot(d02, edge10);
+ dists.y = sqrt(dot(edge10, edge10) - d * d);
+ d = dot(d10, edge21);
+ dists.z = sqrt(dot(edge21, edge21) - d * d);
+ return dists;
+}
+
+vec2 calc_barycentric_co(int vertid)
+{
+ vec2 bary;
+ bary.x = float((vertid % 3) == 0);
+ bary.y = float((vertid % 3) == 1);
+ return bary;
+}
+
+#ifdef HAIR_SHADER
+
+/* Hairs uv and col attributes are passed by bufferTextures. */
+# define DEFINE_ATTR(type, attr) uniform samplerBuffer attr
+# define GET_ATTR(type, attr) hair_get_customdata_##type(attr)
+
+# define barycentric_get() hair_get_barycentric()
+# define barycentric_resolve(bary) hair_resolve_barycentric(bary)
+
+vec3 orco_get(vec3 local_pos, mat4 modelmatinv, vec4 orco_madd[2], const samplerBuffer orco_samp)
+{
+ /* TODO: fix ORCO with modifiers. */
+ vec3 orco = (modelmatinv * vec4(local_pos, 1.0)).xyz;
+ return orco_madd[0].xyz + orco * orco_madd[1].xyz;
+}
+
+vec4 tangent_get(const samplerBuffer attr, mat3 normalmat)
+{
+ /* Unsupported */
+ return vec4(0.0);
+}
+
+#else /* MESH_SHADER */
+
+# define DEFINE_ATTR(type, attr) in type attr
+# define GET_ATTR(type, attr) attr
+
+/* Calculated in geom shader later with calc_barycentric_co. */
+# define barycentric_get() vec2(0)
+# define barycentric_resolve(bary) bary
+
+vec3 orco_get(vec3 local_pos, mat4 modelmatinv, vec4 orco_madd[2], vec4 orco)
+{
+ /* If the object does not have any deformation, the orco layer calculation is done on the fly
+ * using the orco_madd factors.
+ * We know when there is no orco layer when orco.w is 1.0 because it uses the generic vertex
+ * attrib (which is [0,0,0,1]). */
+ if (orco.w == 0.0) {
+ return orco.xyz * 0.5 + 0.5;
+ }
+ else {
+ return orco_madd[0].xyz + local_pos * orco_madd[1].xyz;
+ }
+}
+
+vec4 tangent_get(vec4 attr, mat3 normalmat)
+{
+ vec4 tangent;
+ tangent.xyz = normalmat * attr.xyz;
+ tangent.w = attr.w;
+ float len_sqr = dot(tangent.xyz, tangent.xyz);
+ /* Normalize only if vector is not null. */
+ if (len_sqr > 0.0) {
+ tangent.xyz *= inversesqrt(len_sqr);
+ }
+ return tangent;
+}
+
+#endif
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl
index d6d6fbab971..eea8d19efce 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl
@@ -3,7 +3,7 @@ void node_ambient_occlusion(
vec4 color, float distance, vec3 normal, out vec4 result_color, out float result_ao)
{
vec3 bent_normal;
- vec4 rand = texelFetch(utilTex, ivec3(ivec2(gl_FragCoord.xy) % LUT_SIZE, 2.0), 0);
+ vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy);
result_ao = occlusion_compute(normalize(normal), viewPosition, 1.0, rand, bent_normal);
result_color = result_ao * color;
}
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl
index 3b23ac976ae..6330daa4391 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl
@@ -1,3 +1,15 @@
+
+float wang_hash_noise(uint s)
+{
+ s = (s ^ 61u) ^ (s >> 16u);
+ s *= 9u;
+ s = s ^ (s >> 4u);
+ s *= 0x27d4eb2du;
+ s = s ^ (s >> 15u);
+
+ return fract(float(s) / 4294967296.0);
+}
+
void node_hair_info(out float is_strand,
out float intercept,
out float thickness,
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl
index f9691beee6f..d33465fa846 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl
@@ -6,7 +6,7 @@ void world_normals_get(out vec3 N)
vec3 B = normalize(cross(worldNormal, hairTangent));
float cos_theta;
if (hairThicknessRes == 1) {
- vec4 rand = texelFetch(utilTex, ivec3(ivec2(gl_FragCoord.xy) % LUT_SIZE, 2.0), 0);
+ vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy);
/* Random cosine normal distribution on the hair surface. */
cos_theta = rand.x * 2.0 - 1.0;
}
diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h
index 2c2053b47a6..674b384adf2 100644
--- a/source/blender/ikplugin/BIK_api.h
+++ b/source/blender/ikplugin/BIK_api.h
@@ -22,8 +22,7 @@
* \ingroup ikplugin
*/
-#ifndef __BIK_API_H__
-#define __BIK_API_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -36,10 +35,10 @@ struct bConstraint;
struct bPose;
struct bPoseChannel;
-void BIK_initialize_tree(struct Depsgraph *depsgraph,
- struct Scene *scene,
- struct Object *ob,
- float ctime);
+void BIK_init_tree(struct Depsgraph *depsgraph,
+ struct Scene *scene,
+ struct Object *ob,
+ float ctime);
void BIK_execute_tree(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob,
@@ -54,5 +53,3 @@ void BIK_test_constraint(struct Object *ob, struct bConstraint *cons);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BIK_API_H__ */
diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c
index 5e683d36408..233150a77aa 100644
--- a/source/blender/ikplugin/intern/ikplugin_api.c
+++ b/source/blender/ikplugin/intern/ikplugin_api.c
@@ -80,7 +80,7 @@ static IKPlugin *get_plugin(bPose *pose)
/*----------------------------------------*/
/* Plugin API */
-void BIK_initialize_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
+void BIK_init_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
{
IKPlugin *plugin = get_plugin(ob->pose);
diff --git a/source/blender/ikplugin/intern/ikplugin_api.h b/source/blender/ikplugin/intern/ikplugin_api.h
index faf21cecacd..f61ba7e3a63 100644
--- a/source/blender/ikplugin/intern/ikplugin_api.h
+++ b/source/blender/ikplugin/intern/ikplugin_api.h
@@ -22,8 +22,7 @@
* \ingroup ikplugin
*/
-#ifndef __IKPLUGIN_API_H__
-#define __IKPLUGIN_API_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -56,5 +55,3 @@ typedef struct IKPlugin IKPlugin;
#ifdef __cplusplus
}
#endif
-
-#endif /* __IKPLUGIN_API_H__ */
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index 3646686e81f..ba096653e0f 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -452,21 +452,20 @@ static void execute_posetree(struct Depsgraph *depsgraph,
/* don't solve IK when we are setting the pole angle */
break;
}
- else {
- mul_m4_m4m4(goal, goalinv, rootmat);
- copy_v3_v3(polepos, goal[3]);
- poleconstrain = 1;
-
- /* for pole targets, we blend the result of the ik solver
- * instead of the target position, otherwise we can't get
- * a smooth transition */
- resultblend = 1;
- resultinf = target->con->enforce;
-
- if (data->flag & CONSTRAINT_IK_GETANGLE) {
- poleangledata = data;
- data->flag &= ~CONSTRAINT_IK_GETANGLE;
- }
+
+ mul_m4_m4m4(goal, goalinv, rootmat);
+ copy_v3_v3(polepos, goal[3]);
+ poleconstrain = 1;
+
+ /* for pole targets, we blend the result of the ik solver
+ * instead of the target position, otherwise we can't get
+ * a smooth transition */
+ resultblend = 1;
+ resultinf = target->con->enforce;
+
+ if (data->flag & CONSTRAINT_IK_GETANGLE) {
+ poleangledata = data;
+ data->flag &= ~CONSTRAINT_IK_GETANGLE;
}
}
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.h b/source/blender/ikplugin/intern/iksolver_plugin.h
index 20a9e78cc47..28356b4fc9c 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.h
+++ b/source/blender/ikplugin/intern/iksolver_plugin.h
@@ -22,8 +22,7 @@
* \ingroup ikplugin
*/
-#ifndef __IKSOLVER_PLUGIN_H__
-#define __IKSOLVER_PLUGIN_H__
+#pragma once
#include "ikplugin_api.h"
@@ -46,5 +45,3 @@ void iksolver_clear_data(struct bPose *pose);
#ifdef __cplusplus
}
#endif
-
-#endif /* __IKSOLVER_PLUGIN_H__ */
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index 8f84d04f602..a5fdb9ef491 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -446,24 +446,21 @@ static double EulerAngleFromMatrix(const KDL::Rotation &R, int axis)
if (axis == 0) {
return -KDL::atan2(R(1, 2), R(2, 2));
}
- else if (axis == 1) {
+ if (axis == 1) {
return KDL::atan2(-R(0, 2), t);
}
- else {
- return -KDL::atan2(R(0, 1), R(0, 0));
- }
+
+ return -KDL::atan2(R(0, 1), R(0, 0));
}
- else {
- if (axis == 0) {
- return -KDL::atan2(-R(2, 1), R(1, 1));
- }
- else if (axis == 1) {
- return KDL::atan2(-R(0, 2), t);
- }
- else {
- return 0.0f;
- }
+
+ if (axis == 0) {
+ return -KDL::atan2(-R(2, 1), R(1, 1));
+ }
+ if (axis == 1) {
+ return KDL::atan2(-R(0, 2), t);
}
+
+ return 0.0f;
}
static double ComputeTwist(const KDL::Rotation &R)
diff --git a/source/blender/ikplugin/intern/itasc_plugin.h b/source/blender/ikplugin/intern/itasc_plugin.h
index e7a319809b7..89342295b35 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.h
+++ b/source/blender/ikplugin/intern/itasc_plugin.h
@@ -22,8 +22,7 @@
* \ingroup ikplugin
*/
-#ifndef __ITASC_PLUGIN_H__
-#define __ITASC_PLUGIN_H__
+#pragma once
#include "ikplugin_api.h"
@@ -49,5 +48,3 @@ void itasc_test_constraint(struct Object *ob, struct bConstraint *cons);
#ifdef __cplusplus
}
#endif
-
-#endif /* __ITASC_PLUGIN_H__ */
diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt
index cad0be659ec..cf637a06405 100644
--- a/source/blender/imbuf/CMakeLists.txt
+++ b/source/blender/imbuf/CMakeLists.txt
@@ -23,6 +23,7 @@ set(INC
../blenkernel
../blenlib
../blenloader
+ ../gpu
../makesdna
../makesrna
../../../intern/guardedalloc
@@ -63,6 +64,7 @@ set(SRC
intern/thumbs_blend.c
intern/thumbs_font.c
intern/util.c
+ intern/util_gpu.c
intern/writeimage.c
IMB_colormanagement.h
diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h
index 4530f6c9fc0..54f126684ae 100644
--- a/source/blender/imbuf/IMB_colormanagement.h
+++ b/source/blender/imbuf/IMB_colormanagement.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __IMB_COLORMANAGEMENT_H__
-#define __IMB_COLORMANAGEMENT_H__
+#pragma once
/** \file
* \ingroup imbuf
@@ -374,5 +373,3 @@ enum {
#endif
#include "intern/colormanagement_inline.c"
-
-#endif /* __IMB_COLORMANAGEMENT_H__ */
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 478297e61b2..37046521dd8 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -53,8 +53,7 @@
* posix-compliant.
*/
-#ifndef __IMB_IMBUF_H__
-#define __IMB_IMBUF_H__
+#pragma once
/* for bool */
#include "../blenlib/BLI_sys_types.h"
@@ -90,6 +89,12 @@ struct Stereo3dFormat;
/**
*
+ * \attention defined in GPU_texture.h
+ */
+struct GPUTexture;
+
+/**
+ *
* \attention Defined in allocimbuf.c
*/
void IMB_init(void);
@@ -729,6 +734,25 @@ const char *IMB_ffmpeg_last_error(void);
/**
*
+ * \attention defined in util_gpu.c
+ */
+struct GPUTexture *IMB_create_gpu_texture(struct ImBuf *ibuf,
+ bool use_high_bitdepth,
+ bool use_premult);
+struct GPUTexture *IMB_touch_gpu_texture(
+ struct ImBuf *ibuf, int w, int h, int layers, bool use_high_bitdepth);
+void IMB_update_gpu_texture_sub(struct GPUTexture *tex,
+ struct ImBuf *ibuf,
+ int x,
+ int y,
+ int z,
+ int w,
+ int h,
+ bool use_high_bitdepth,
+ bool use_premult);
+
+/**
+ *
* \attention defined in stereoimbuf.c
*/
void IMB_stereo3d_write_dimensions(const char mode,
@@ -766,5 +790,3 @@ void IMB_ImBufFromStereo3d(struct Stereo3dFormat *s3d,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index ddc8394264a..98e9c34a4ff 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __IMB_IMBUF_TYPES_H__
-#define __IMB_IMBUF_TYPES_H__
+#pragma once
#include "DNA_vec_types.h" /* for rcti */
@@ -353,5 +352,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __IMB_IMBUF_TYPES_H__ */
diff --git a/source/blender/imbuf/IMB_metadata.h b/source/blender/imbuf/IMB_metadata.h
index edbdd7be482..501bf9dfba1 100644
--- a/source/blender/imbuf/IMB_metadata.h
+++ b/source/blender/imbuf/IMB_metadata.h
@@ -21,8 +21,7 @@
* \ingroup imbuf
*/
-#ifndef __IMB_METADATA_H__
-#define __IMB_METADATA_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -84,5 +83,3 @@ void IMB_metadata_foreach(struct ImBuf *ibuf, IMBMetadataForeachCb callback, voi
#ifdef __cplusplus
}
#endif
-
-#endif /* __IMB_METADATA_H__ */
diff --git a/source/blender/imbuf/IMB_moviecache.h b/source/blender/imbuf/IMB_moviecache.h
index 5fb158f0d8b..8e5f15a64a0 100644
--- a/source/blender/imbuf/IMB_moviecache.h
+++ b/source/blender/imbuf/IMB_moviecache.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __IMB_MOVIECACHE_H__
-#define __IMB_MOVIECACHE_H__
+#pragma once
/** \file
* \ingroup imbuf
@@ -85,5 +84,3 @@ void *IMB_moviecacheIter_getUserKey(struct MovieCacheIter *iter);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/imbuf/IMB_thumbs.h b/source/blender/imbuf/IMB_thumbs.h
index 00e9a810ef3..e8c244aaba7 100644
--- a/source/blender/imbuf/IMB_thumbs.h
+++ b/source/blender/imbuf/IMB_thumbs.h
@@ -21,8 +21,7 @@
* \ingroup imbuf
*/
-#ifndef __IMB_THUMBS_H__
-#define __IMB_THUMBS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -98,5 +97,3 @@ void IMB_thumb_path_unlock(const char *path);
#ifdef __cplusplus
}
#endif /* __cplusplus */
-
-#endif /* __IMB_THUMBS_H__ */
diff --git a/source/blender/imbuf/intern/IMB_allocimbuf.h b/source/blender/imbuf/intern/IMB_allocimbuf.h
index 9f89969cf1c..08aa1936a6f 100644
--- a/source/blender/imbuf/intern/IMB_allocimbuf.h
+++ b/source/blender/imbuf/intern/IMB_allocimbuf.h
@@ -21,8 +21,7 @@
* \ingroup imbuf
* \brief Header file for allocimbuf.c
*/
-#ifndef __IMB_ALLOCIMBUF_H__
-#define __IMB_ALLOCIMBUF_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -51,5 +50,3 @@ bool imb_enlargeencodedbufferImBuf(struct ImBuf *ibuf);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h
index 3d1d99963c7..babff5c34cd 100644
--- a/source/blender/imbuf/intern/IMB_anim.h
+++ b/source/blender/imbuf/intern/IMB_anim.h
@@ -21,8 +21,7 @@
* \ingroup imbuf
*/
-#ifndef __IMB_ANIM_H__
-#define __IMB_ANIM_H__
+#pragma once
#ifdef _WIN32
# define INC_OLE2
@@ -152,5 +151,3 @@ struct anim {
struct IDProperty *metadata;
};
-
-#endif
diff --git a/source/blender/imbuf/intern/IMB_colormanagement_intern.h b/source/blender/imbuf/intern/IMB_colormanagement_intern.h
index 79abe8472b9..6b505a7171a 100644
--- a/source/blender/imbuf/intern/IMB_colormanagement_intern.h
+++ b/source/blender/imbuf/intern/IMB_colormanagement_intern.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __IMB_COLORMANAGEMENT_INTERN_H__
-#define __IMB_COLORMANAGEMENT_INTERN_H__
+#pragma once
/** \file
* \ingroup imbuf
@@ -130,5 +129,3 @@ void colormanage_imbuf_make_linear(struct ImBuf *ibuf, const char *from_colorspa
#ifdef __cplusplus
}
#endif
-
-#endif /* __IMB_COLORMANAGEMENT_INTERN_H__ */
diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h
index ce731a3a86d..2b00b87d3d2 100644
--- a/source/blender/imbuf/intern/IMB_filetype.h
+++ b/source/blender/imbuf/intern/IMB_filetype.h
@@ -18,8 +18,7 @@
* \ingroup imbuf
*/
-#ifndef __IMB_FILETYPE_H__
-#define __IMB_FILETYPE_H__
+#pragma once
#include "IMB_imbuf.h"
@@ -151,5 +150,3 @@ struct ImBuf *imb_loadtiff(const unsigned char *mem,
void imb_loadtiletiff(
struct ImBuf *ibuf, const unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect);
int imb_savetiff(struct ImBuf *ibuf, const char *name, int flags);
-
-#endif /* __IMB_FILETYPE_H__ */
diff --git a/source/blender/imbuf/intern/IMB_filter.h b/source/blender/imbuf/intern/IMB_filter.h
index 2cd785e6889..556362d78c1 100644
--- a/source/blender/imbuf/intern/IMB_filter.h
+++ b/source/blender/imbuf/intern/IMB_filter.h
@@ -22,8 +22,7 @@
* \brief Function declarations for filter.c
*/
-#ifndef __IMB_FILTER_H__
-#define __IMB_FILTER_H__
+#pragma once
struct ImBuf;
@@ -36,5 +35,3 @@ void IMB_unpremultiply_rect(unsigned int *rect, char planes, int w, int h);
void IMB_unpremultiply_rect_float(float *rect_float, int channels, int w, int h);
void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1);
-
-#endif
diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h
index 446aaa0655e..7cd11e137c2 100644
--- a/source/blender/imbuf/intern/IMB_indexer.h
+++ b/source/blender/imbuf/intern/IMB_indexer.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __IMB_INDEXER_H__
-#define __IMB_INDEXER_H__
+#pragma once
/** \file
* \ingroup imbuf
@@ -113,5 +112,3 @@ struct anim_index *IMB_anim_open_index(struct anim *anim, IMB_Timecode_Type tc);
int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size);
int IMB_timecode_to_array_index(IMB_Timecode_Type tc);
-
-#endif
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 4b3858e6d5a..8dfb3ada7d6 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -423,9 +423,8 @@ bool imb_addrectImBuf(ImBuf *ibuf)
if (ibuf->planes > 32) {
return (addzbufImBuf(ibuf));
}
- else {
- return true;
- }
+
+ return true;
}
return false;
@@ -489,7 +488,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int
}
}
- return (ibuf);
+ return ibuf;
}
bool IMB_initImBuf(
@@ -624,7 +623,7 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
*ibuf2 = tbuf;
- return (ibuf2);
+ return ibuf2;
}
size_t IMB_get_size_in_memory(ImBuf *ibuf)
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 9fab450cc76..f5ae602946e 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -301,7 +301,7 @@ struct anim *IMB_open_anim(const char *name,
anim->ib_flags = ib_flags;
anim->streamindex = streamindex;
}
- return (anim);
+ return anim;
}
bool IMB_anim_can_produce_frames(const struct anim *anim)
@@ -743,7 +743,7 @@ static int startffmpeg(struct anim *anim)
}
# endif
- return (0);
+ return 0;
}
/* postprocess the image in anim->pFrame and do color conversion
@@ -803,7 +803,7 @@ static void ffmpeg_postprocess(struct anim *anim)
if (ENDIAN_ORDER == B_ENDIAN) {
int *dstStride = anim->pFrameRGB->linesize;
uint8_t **dst = anim->pFrameRGB->data;
- int dstStride2[4] = {dstStride[0], 0, 0, 0};
+ const int dstStride2[4] = {dstStride[0], 0, 0, 0};
uint8_t *dst2[4] = {dst[0], 0, 0, 0};
int x, y, h, w;
unsigned char *bottom;
@@ -849,7 +849,7 @@ static void ffmpeg_postprocess(struct anim *anim)
else {
int *dstStride = anim->pFrameRGB->linesize;
uint8_t **dst = anim->pFrameRGB->data;
- int dstStride2[4] = {-dstStride[0], 0, 0, 0};
+ const int dstStride2[4] = {-dstStride[0], 0, 0, 0};
uint8_t *dst2[4] = {dst[0] + (anim->y - 1) * dstStride[0], 0, 0, 0};
sws_scale(anim->img_convert_ctx,
@@ -1060,7 +1060,7 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ
int old_frame_index = 0; /* To quiet gcc barking... */
if (anim == NULL) {
- return (0);
+ return 0;
}
av_log(anim->pFormatCtx, AV_LOG_DEBUG, "FETCH: pos=%d\n", position);
@@ -1291,7 +1291,7 @@ static ImBuf *anim_getnew(struct anim *anim)
struct ImBuf *ibuf = NULL;
if (anim == NULL) {
- return (NULL);
+ return NULL;
}
free_anim_movie(anim);
@@ -1305,7 +1305,7 @@ static ImBuf *anim_getnew(struct anim *anim)
#endif
if (anim->curtype != 0) {
- return (NULL);
+ return NULL;
}
anim->curtype = imb_get_anim_type(anim->name);
@@ -1319,7 +1319,7 @@ static ImBuf *anim_getnew(struct anim *anim)
break;
case ANIM_MOVIE:
if (startmovie(anim)) {
- return (NULL);
+ return NULL;
}
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0); /* fake */
break;
@@ -1327,7 +1327,7 @@ static ImBuf *anim_getnew(struct anim *anim)
case ANIM_AVI:
if (startavi(anim)) {
printf("couldn't start avi\n");
- return (NULL);
+ return NULL;
}
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
break;
@@ -1335,13 +1335,13 @@ static ImBuf *anim_getnew(struct anim *anim)
#ifdef WITH_FFMPEG
case ANIM_FFMPEG:
if (startffmpeg(anim)) {
- return (0);
+ return 0;
}
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
break;
#endif
}
- return (ibuf);
+ return ibuf;
}
struct ImBuf *IMB_anim_previewframe(struct anim *anim)
@@ -1369,7 +1369,7 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim,
int pic;
int filter_y;
if (anim == NULL) {
- return (NULL);
+ return NULL;
}
filter_y = (anim->ib_flags & IB_animdeinterlace);
@@ -1378,7 +1378,7 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim,
if (anim->curtype == 0) {
ibuf = anim_getnew(anim);
if (ibuf == NULL) {
- return (NULL);
+ return NULL;
}
IMB_freeImBuf(ibuf); /* ???? */
@@ -1386,10 +1386,10 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim,
}
if (position < 0) {
- return (NULL);
+ return NULL;
}
if (position >= anim->duration_in_frames) {
- return (NULL);
+ return NULL;
}
}
else {
@@ -1444,7 +1444,7 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim,
}
BLI_snprintf(ibuf->name, sizeof(ibuf->name), "%s.%04d", anim->name, anim->curposition + 1);
}
- return (ibuf);
+ return ibuf;
}
/***/
diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c
index 3cac0be7935..31f8b651eff 100644
--- a/source/blender/imbuf/intern/bmp.c
+++ b/source/blender/imbuf/intern/bmp.c
@@ -101,7 +101,7 @@ static int checkbmp(const uchar *mem)
}
}
- return (ret_val);
+ return ret_val;
}
int imb_is_a_bmp(const uchar *buf)
@@ -123,7 +123,7 @@ ImBuf *imb_bmp_decode(const uchar *mem, size_t size, int flags, char colorspace[
(void)size; /* unused */
if (checkbmp(mem) == 0) {
- return (NULL);
+ return NULL;
}
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
@@ -272,7 +272,7 @@ ImBuf *imb_bmp_decode(const uchar *mem, size_t size, int flags, char colorspace[
ibuf->ftype = IMB_FTYPE_BMP;
}
- return (ibuf);
+ return ibuf;
}
#undef CHECK_HEADER_FIELD_BMP
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c
index 18942c9abb8..50785d7a857 100644
--- a/source/blender/imbuf/intern/cineon/cineon_dpx.c
+++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c
@@ -139,7 +139,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
/* don't use the float buffer to save 8 bpp picture to prevent color banding
* (there's no dithering algorithm behind the logImageSetDataRGBA function) */
- fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float),
+ fbuf = (float *)MEM_mallocN(sizeof(float[4]) * ibuf->x * ibuf->y,
"fbuf in imb_save_dpx_cineon");
for (y = 0; y < ibuf->y; y++) {
@@ -158,7 +158,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
IMB_rect_from_float(ibuf);
}
- fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float),
+ fbuf = (float *)MEM_mallocN(sizeof(float[4]) * ibuf->x * ibuf->y,
"fbuf in imb_save_dpx_cineon");
if (fbuf == NULL) {
printf("DPX/Cineon: error allocating memory.\n");
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.h b/source/blender/imbuf/intern/cineon/cineonlib.h
index 040435e44ee..d1225027b4c 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.h
+++ b/source/blender/imbuf/intern/cineon/cineonlib.h
@@ -23,8 +23,7 @@
* Also handles DPX files (almost)
*/
-#ifndef __CINEONLIB_H__
-#define __CINEONLIB_H__
+#pragma once
#include "logImageCore.h"
@@ -135,5 +134,3 @@ LogImageFile *cineonCreate(
#ifdef __cplusplus
}
#endif
-
-#endif /* __CINEONLIB_H__ */
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index 8acfc23439f..73003265d8d 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -207,7 +207,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
dpx->srcFormat = format_DPX;
dpx->numElements = swap_ushort(header.imageHeader.elements_per_image, dpx->isMSB);
- size_t max_elements = sizeof(header.imageHeader.element) / sizeof(header.imageHeader.element[0]);
+ size_t max_elements = ARRAY_SIZE(header.imageHeader.element);
if (dpx->numElements == 0 || dpx->numElements >= max_elements) {
if (verbose) {
printf("DPX: Wrong number of elements: %d\n", dpx->numElements);
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.h b/source/blender/imbuf/intern/cineon/dpxlib.h
index 3a7ebe9dddf..6b729dba59a 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.h
+++ b/source/blender/imbuf/intern/cineon/dpxlib.h
@@ -22,8 +22,7 @@
* DPX image file format library definitions.
*/
-#ifndef __DPXLIB_H__
-#define __DPXLIB_H__
+#pragma once
#include "logImageCore.h"
@@ -160,5 +159,3 @@ LogImageFile *dpxCreate(const char *filename,
#ifdef __cplusplus
}
#endif
-
-#endif /* __DPXLIB_H__ */
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c
index e9030496498..6a81abd96e3 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.c
+++ b/source/blender/imbuf/intern/cineon/logImageCore.c
@@ -119,7 +119,7 @@ LogImageFile *logImageOpenFromFile(const char *filename, int cineon)
if (logImageIsDpx(&magicNum)) {
return dpxOpen((const unsigned char *)filename, 0, 0);
}
- else if (logImageIsCineon(&magicNum)) {
+ if (logImageIsCineon(&magicNum)) {
return cineonOpen((const unsigned char *)filename, 0, 0);
}
@@ -131,7 +131,7 @@ LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int s
if (logImageIsDpx(buffer)) {
return dpxOpen(buffer, 1, size);
}
- else if (logImageIsCineon(buffer)) {
+ if (logImageIsCineon(buffer)) {
return cineonOpen(buffer, 1, size);
}
@@ -154,18 +154,17 @@ LogImageFile *logImageCreate(const char *filename,
if (cineon) {
return cineonCreate(filename, width, height, bitsPerSample, creator);
}
- else {
- return dpxCreate(filename,
- width,
- height,
- bitsPerSample,
- isLogarithmic,
- hasAlpha,
- referenceWhite,
- referenceBlack,
- gamma,
- creator);
- }
+
+ return dpxCreate(filename,
+ width,
+ height,
+ bitsPerSample,
+ isLogarithmic,
+ hasAlpha,
+ referenceWhite,
+ referenceBlack,
+ gamma,
+ creator);
return NULL;
}
@@ -484,7 +483,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
memcpy(&mergedElement, &logImage->element[0], sizeof(LogImageElement));
mergedElement.descriptor = -1;
mergedElement.depth = logImage->depth;
- memset(&sortedElementData, -1, 8 * sizeof(int));
+ memset(&sortedElementData, -1, sizeof(int[8]));
/* Try to know how to assemble the elements */
for (i = 0; i < logImage->numElements; i++) {
@@ -1677,7 +1676,7 @@ static int convertLogElementToRGBA(
if (rvalue == 1) {
return 1;
}
- else if (dstIsLinearRGB) {
+ if (dstIsLinearRGB) {
/* convert data from sRGB to Linear RGB via lut */
float *lut = getSrgbToLinLut(logElement);
src_ptr = dst; // no error here
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.h b/source/blender/imbuf/intern/cineon/logImageCore.h
index 3d49da7eb42..a2d50f21a98 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.h
+++ b/source/blender/imbuf/intern/cineon/logImageCore.h
@@ -27,8 +27,7 @@
* Hmm. I thought the two formats would have more in common!
*/
-#ifndef __LOGIMAGECORE_H__
-#define __LOGIMAGECORE_H__
+#pragma once
#include <stdio.h>
@@ -295,5 +294,3 @@ BLI_INLINE unsigned int float_uint(float value, unsigned int max)
#ifdef __cplusplus
}
#endif
-
-#endif /* __LOGIMAGECORE_H__ */
diff --git a/source/blender/imbuf/intern/cineon/logmemfile.c b/source/blender/imbuf/intern/cineon/logmemfile.c
index 91351d309de..aca84df91ca 100644
--- a/source/blender/imbuf/intern/cineon/logmemfile.c
+++ b/source/blender/imbuf/intern/cineon/logmemfile.c
@@ -64,10 +64,9 @@ int logimage_fwrite(void *buffer, size_t size, unsigned int count, LogImageFile
if (logFile->file) {
return fwrite(buffer, size, count, logFile->file);
}
- else { /* we're writing to memory */
- /* do nothing as this isn't supported yet */
- return count;
- }
+ /* we're writing to memory */
+ /* do nothing as this isn't supported yet */
+ return count;
}
int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *logFile)
@@ -75,23 +74,22 @@ int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *
if (logFile->file) {
return fread(buffer, size, count, logFile->file);
}
- else { /* we're reading from memory */
- unsigned char *buf = (unsigned char *)buffer;
- uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
- size_t total_size = size * count;
- if (pos + total_size > logFile->memBufferSize) {
- /* how many elements can we read without overflow ? */
- count = (logFile->memBufferSize - pos) / size;
- /* recompute the size */
- total_size = size * count;
- }
-
- if (total_size != 0) {
- memcpy(buf, logFile->memCursor, total_size);
- }
+ /* we're reading from memory */
+ unsigned char *buf = (unsigned char *)buffer;
+ uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
+ size_t total_size = size * count;
+ if (pos + total_size > logFile->memBufferSize) {
+ /* how many elements can we read without overflow ? */
+ count = (logFile->memBufferSize - pos) / size;
+ /* recompute the size */
+ total_size = size * count;
+ }
- return count;
+ if (total_size != 0) {
+ memcpy(buf, logFile->memCursor, total_size);
}
+
+ return count;
}
int logimage_read_uchar(unsigned char *x, LogImageFile *logFile)
diff --git a/source/blender/imbuf/intern/cineon/logmemfile.h b/source/blender/imbuf/intern/cineon/logmemfile.h
index d0ca03193e5..fd67011ef30 100644
--- a/source/blender/imbuf/intern/cineon/logmemfile.h
+++ b/source/blender/imbuf/intern/cineon/logmemfile.h
@@ -22,8 +22,7 @@
* Cineon image file format library routines.
*/
-#ifndef __LOGMEMFILE_H__
-#define __LOGMEMFILE_H__
+#pragma once
#include "logImageCore.h"
@@ -35,5 +34,3 @@ int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *
int logimage_read_uchar(unsigned char *x, LogImageFile *logFile);
int logimage_read_ushort(unsigned short *x, LogImageFile *logFile);
int logimage_read_uint(unsigned int *x, LogImageFile *logFile);
-
-#endif /* __LOGMEMFILE_H__ */
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index c9b3db39976..2c42d59a2d9 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -1399,9 +1399,8 @@ const char *IMB_colormanagement_get_float_colorspace(ImBuf *ibuf)
if (ibuf->float_colorspace) {
return ibuf->float_colorspace->name;
}
- else {
- return IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
- }
+
+ return IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
}
const char *IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
@@ -1409,9 +1408,8 @@ const char *IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
if (ibuf->rect_colorspace) {
return ibuf->rect_colorspace->name;
}
- else {
- return IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE);
- }
+
+ return IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE);
}
bool IMB_colormanagement_space_is_data(ColorSpace *colorspace)
@@ -2344,7 +2342,7 @@ void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer,
}
}
else {
- memcpy(out, in, sizeof(float) * 4 * width);
+ memcpy(out, in, sizeof(float[4]) * width);
}
}
}
@@ -3513,7 +3511,7 @@ static void partial_buffer_update_rect(ImBuf *ibuf,
size_t display_offset = ((size_t)display_stride * i + xmin) * 4;
memcpy(
- display_buffer + display_offset, byte_buffer + byte_offset, 4 * sizeof(char) * width);
+ display_buffer + display_offset, byte_buffer + byte_offset, sizeof(char[4]) * width);
}
}
}
@@ -3958,7 +3956,7 @@ static void curve_mapping_to_ocio_settings(CurveMapping *curve_mapping,
{
int i;
- BKE_curvemapping_initialize(curve_mapping);
+ BKE_curvemapping_init(curve_mapping);
BKE_curvemapping_premultiply(curve_mapping, false);
BKE_curvemapping_table_RGBA(
curve_mapping, &curve_mapping_settings->lut, &curve_mapping_settings->lut_size);
diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp
index 9fd6d71e091..1fbe7b46963 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.cpp
+++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp
@@ -97,21 +97,20 @@ uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
return 4;
}
- else {
- // Three-color block: derive the other color.
- color_array[2].r = (color_array[0].r + color_array[1].r) / 2;
- color_array[2].g = (color_array[0].g + color_array[1].g) / 2;
- color_array[2].b = (color_array[0].b + color_array[1].b) / 2;
- color_array[2].a = 0xFF;
- // Set all components to 0 to match DXT specs.
- color_array[3].r = 0x00; // color_array[2].r;
- color_array[3].g = 0x00; // color_array[2].g;
- color_array[3].b = 0x00; // color_array[2].b;
- color_array[3].a = 0x00;
+ // Three-color block: derive the other color.
+ color_array[2].r = (color_array[0].r + color_array[1].r) / 2;
+ color_array[2].g = (color_array[0].g + color_array[1].g) / 2;
+ color_array[2].b = (color_array[0].b + color_array[1].b) / 2;
+ color_array[2].a = 0xFF;
- return 3;
- }
+ // Set all components to 0 to match DXT specs.
+ color_array[3].r = 0x00; // color_array[2].r;
+ color_array[3].g = 0x00; // color_array[2].g;
+ color_array[3].b = 0x00; // color_array[2].b;
+ color_array[3].a = 0x00;
+
+ return 3;
}
uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
@@ -143,21 +142,20 @@ uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
return 4;
}
- else {
- // Three-color block: derive the other color.
- color_array[2].r = ((col0.r + col1.r) * 33) / 8;
- color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 128) / 256;
- color_array[2].b = ((col0.b + col1.b) * 33) / 8;
- color_array[2].a = 0xFF;
- // Set all components to 0 to match DXT specs.
- color_array[3].r = 0x00; // color_array[2].r;
- color_array[3].g = 0x00; // color_array[2].g;
- color_array[3].b = 0x00; // color_array[2].b;
- color_array[3].a = 0x00;
+ // Three-color block: derive the other color.
+ color_array[2].r = ((col0.r + col1.r) * 33) / 8;
+ color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 128) / 256;
+ color_array[2].b = ((col0.b + col1.b) * 33) / 8;
+ color_array[2].a = 0xFF;
- return 3;
- }
+ // Set all components to 0 to match DXT specs.
+ color_array[3].r = 0x00; // color_array[2].r;
+ color_array[3].g = 0x00; // color_array[2].g;
+ color_array[3].b = 0x00; // color_array[2].b;
+ color_array[3].a = 0x00;
+
+ return 3;
}
// Evaluate palette assuming 3 color block.
diff --git a/source/blender/imbuf/intern/dds/BlockDXT.h b/source/blender/imbuf/intern/dds/BlockDXT.h
index 57430dbaea2..70ec8808c61 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.h
+++ b/source/blender/imbuf/intern/dds/BlockDXT.h
@@ -48,8 +48,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
-#ifndef __BLOCKDXT_H__
-#define __BLOCKDXT_H__
+#pragma once
#include <Color.h>
#include <ColorBlock.h>
@@ -305,5 +304,3 @@ void mem_read(Stream &mem, BlockDXT5 &block);
void mem_read(Stream &mem, BlockATI1 &block);
void mem_read(Stream &mem, BlockATI2 &block);
void mem_read(Stream &mem, BlockCTX1 &block);
-
-#endif /* __BLOCKDXT_H__ */
diff --git a/source/blender/imbuf/intern/dds/Color.h b/source/blender/imbuf/intern/dds/Color.h
index 36e2615759b..d0b67d4638c 100644
--- a/source/blender/imbuf/intern/dds/Color.h
+++ b/source/blender/imbuf/intern/dds/Color.h
@@ -27,8 +27,7 @@
// This code is in the public domain -- castanyo@yahoo.es
-#ifndef __COLOR_H__
-#define __COLOR_H__
+#pragma once
/// 32 bit color stored as BGRA.
class Color32 {
@@ -116,5 +115,3 @@ class Color16 {
unsigned short u;
};
};
-
-#endif /* __COLOR_H__ */
diff --git a/source/blender/imbuf/intern/dds/ColorBlock.h b/source/blender/imbuf/intern/dds/ColorBlock.h
index 2e8a6bbda7f..dd63286e230 100644
--- a/source/blender/imbuf/intern/dds/ColorBlock.h
+++ b/source/blender/imbuf/intern/dds/ColorBlock.h
@@ -27,8 +27,7 @@
// This code is in the public domain -- castanyo@yahoo.es
-#ifndef __COLORBLOCK_H__
-#define __COLORBLOCK_H__
+#pragma once
#include <Color.h>
#include <Image.h>
@@ -91,5 +90,3 @@ inline Color32 &ColorBlock::color(uint x, uint y)
{
return m_color[y * 4 + x];
}
-
-#endif /* __COLORBLOCK_H__ */
diff --git a/source/blender/imbuf/intern/dds/Common.h b/source/blender/imbuf/intern/dds/Common.h
index 56f5d54cf42..90ec347a9ad 100644
--- a/source/blender/imbuf/intern/dds/Common.h
+++ b/source/blender/imbuf/intern/dds/Common.h
@@ -18,8 +18,7 @@
* \ingroup imbdds
*/
-#ifndef __COMMON_H__
-#define __COMMON_H__
+#pragma once
#ifndef MIN
# define MIN(a, b) ((a) <= (b) ? (a) : (b))
@@ -49,5 +48,3 @@ inline uint computePitch(uint w, uint bitsize, uint alignment)
{
return ((w * bitsize + 8 * alignment - 1) / (8 * alignment)) * alignment;
}
-
-#endif
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index 9730153819e..7ec059607c5 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -864,9 +864,8 @@ uint DDSHeader::d3d9Format() const
if (pf.flags & DDPF_FOURCC) {
return pf.fourcc;
}
- else {
- return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask);
- }
+
+ return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask);
}
DirectDrawSurface::DirectDrawSurface(unsigned char *mem, uint size) : stream(mem, size), header()
@@ -923,33 +922,32 @@ bool DirectDrawSurface::isSupported() const
return false;
}
- else {
- if (header.pf.flags & DDPF_FOURCC) {
- if (header.pf.fourcc != FOURCC_DXT1 && header.pf.fourcc != FOURCC_DXT2 &&
- header.pf.fourcc != FOURCC_DXT3 && header.pf.fourcc != FOURCC_DXT4 &&
- header.pf.fourcc != FOURCC_DXT5 && header.pf.fourcc != FOURCC_RXGB &&
- header.pf.fourcc != FOURCC_ATI1 && header.pf.fourcc != FOURCC_ATI2) {
- // Unknown fourcc code.
- return false;
- }
- }
- else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE)) {
- // All RGB and luminance formats are supported now.
- }
- else {
- return false;
- }
- if (isTextureCube() &&
- (header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) != DDSCAPS2_CUBEMAP_ALL_FACES) {
- // Cubemaps must contain all faces.
+ if (header.pf.flags & DDPF_FOURCC) {
+ if (header.pf.fourcc != FOURCC_DXT1 && header.pf.fourcc != FOURCC_DXT2 &&
+ header.pf.fourcc != FOURCC_DXT3 && header.pf.fourcc != FOURCC_DXT4 &&
+ header.pf.fourcc != FOURCC_DXT5 && header.pf.fourcc != FOURCC_RXGB &&
+ header.pf.fourcc != FOURCC_ATI1 && header.pf.fourcc != FOURCC_ATI2) {
+ // Unknown fourcc code.
return false;
}
+ }
+ else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE)) {
+ // All RGB and luminance formats are supported now.
+ }
+ else {
+ return false;
+ }
- if (isTexture3D()) {
- // @@ 3D textures not supported yet.
- return false;
- }
+ if (isTextureCube() &&
+ (header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) != DDSCAPS2_CUBEMAP_ALL_FACES) {
+ // Cubemaps must contain all faces.
+ return false;
+ }
+
+ if (isTexture3D()) {
+ // @@ 3D textures not supported yet.
+ return false;
}
return true;
@@ -963,23 +961,21 @@ bool DirectDrawSurface::hasAlpha() const
header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM ||
header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM;
}
- else {
- if (header.pf.flags & DDPF_RGB) {
- return header.pf.amask != 0;
- }
- else if (header.pf.flags & DDPF_FOURCC) {
- if (header.pf.fourcc == FOURCC_RXGB || header.pf.fourcc == FOURCC_ATI1 ||
- header.pf.fourcc == FOURCC_ATI2 || header.pf.flags & DDPF_NORMAL) {
- return false;
- }
- else {
- // @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it. (except us?)
- return true;
- }
+
+ if (header.pf.flags & DDPF_RGB) {
+ return header.pf.amask != 0;
+ }
+ if (header.pf.flags & DDPF_FOURCC) {
+ if (header.pf.fourcc == FOURCC_RXGB || header.pf.fourcc == FOURCC_ATI1 ||
+ header.pf.fourcc == FOURCC_ATI2 || header.pf.flags & DDPF_NORMAL) {
+ return false;
}
- return false;
+ // @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it. (except us?)
+ return true;
}
+
+ return false;
}
uint DirectDrawSurface::mipmapCount() const
@@ -987,9 +983,8 @@ uint DirectDrawSurface::mipmapCount() const
if (header.flags & DDSD_MIPMAPCOUNT) {
return header.mipmapcount;
}
- else {
- return 1;
- }
+
+ return 1;
}
uint DirectDrawSurface::fourCC() const
@@ -1002,9 +997,8 @@ uint DirectDrawSurface::width() const
if (header.flags & DDSD_WIDTH) {
return header.width;
}
- else {
- return 1;
- }
+
+ return 1;
}
uint DirectDrawSurface::height() const
@@ -1012,9 +1006,8 @@ uint DirectDrawSurface::height() const
if (header.flags & DDSD_HEIGHT) {
return header.height;
}
- else {
- return 1;
- }
+
+ return 1;
}
uint DirectDrawSurface::depth() const
@@ -1022,9 +1015,8 @@ uint DirectDrawSurface::depth() const
if (header.flags & DDSD_DEPTH) {
return header.depth;
}
- else {
- return 1;
- }
+
+ return 1;
}
bool DirectDrawSurface::isTexture1D() const
@@ -1040,9 +1032,8 @@ bool DirectDrawSurface::isTexture2D() const
if (header.hasDX10Header()) {
return header.header10.resourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE2D;
}
- else {
- return !isTexture3D() && !isTextureCube();
- }
+
+ return !isTexture3D() && !isTextureCube();
}
bool DirectDrawSurface::isTexture3D() const
@@ -1050,9 +1041,8 @@ bool DirectDrawSurface::isTexture3D() const
if (header.hasDX10Header()) {
return header.header10.resourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE3D;
}
- else {
- return (header.caps.caps2 & DDSCAPS2_VOLUME) != 0;
- }
+
+ return (header.caps.caps2 & DDSCAPS2_VOLUME) != 0;
}
bool DirectDrawSurface::isTextureCube() const
@@ -1355,16 +1345,15 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
h = (h + 3) / 4;
return blockSize() * w * h;
}
- else if (header.pf.flags & DDPF_RGB || (header.pf.flags & DDPF_LUMINANCE)) {
+ if (header.pf.flags & DDPF_RGB || (header.pf.flags & DDPF_LUMINANCE)) {
uint pitch = computePitch(
w, header.pf.bitcount, 8); // Assuming 8 bit alignment, which is the same D3DX expects.
return pitch * h * d;
}
- else {
- printf("DDS: mipmap format not supported\n");
- return (0);
- }
+
+ printf("DDS: mipmap format not supported\n");
+ return 0;
}
uint DirectDrawSurface::faceSize() const
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.h b/source/blender/imbuf/intern/dds/DirectDrawSurface.h
index f12c45d11df..ac7f893fddd 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.h
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.h
@@ -48,8 +48,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
-#ifndef __DIRECTDRAWSURFACE_H__
-#define __DIRECTDRAWSURFACE_H__
+#pragma once
#include <ColorBlock.h>
#include <Common.h>
@@ -184,5 +183,3 @@ void mem_read(Stream &mem, DDSPixelFormat &pf);
void mem_read(Stream &mem, DDSCaps &caps);
void mem_read(Stream &mem, DDSHeader &header);
void mem_read(Stream &mem, DDSHeader10 &header);
-
-#endif /* __DIRECTDRAWSURFACE_H__ */
diff --git a/source/blender/imbuf/intern/dds/FlipDXT.cpp b/source/blender/imbuf/intern/dds/FlipDXT.cpp
index f5c937654b3..f46f50eb2b9 100644
--- a/source/blender/imbuf/intern/dds/FlipDXT.cpp
+++ b/source/blender/imbuf/intern/dds/FlipDXT.cpp
@@ -217,7 +217,7 @@ int FlipDXTCImage(
// no flip to do, and we're done.
break;
}
- else if (mip_height == 2) {
+ if (mip_height == 2) {
// flip the first 2 lines in each block.
for (unsigned int i = 0; i < blocks_per_row; i++) {
half_block_function(data + i * block_bytes);
diff --git a/source/blender/imbuf/intern/dds/FlipDXT.h b/source/blender/imbuf/intern/dds/FlipDXT.h
index b7056742430..d35157251bd 100644
--- a/source/blender/imbuf/intern/dds/FlipDXT.h
+++ b/source/blender/imbuf/intern/dds/FlipDXT.h
@@ -14,13 +14,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FLIPDXT_H__
-#define __FLIPDXT_H__
+#pragma once
#include "BLI_sys_types.h"
/* flip compressed DXT image vertically to fit OpenGL convention */
int FlipDXTCImage(
unsigned int width, unsigned int height, unsigned int levels, int fourcc, uint8_t *data);
-
-#endif
diff --git a/source/blender/imbuf/intern/dds/Image.h b/source/blender/imbuf/intern/dds/Image.h
index 2922d5cfda3..4ccfec99445 100644
--- a/source/blender/imbuf/intern/dds/Image.h
+++ b/source/blender/imbuf/intern/dds/Image.h
@@ -27,8 +27,7 @@
// This code is in the public domain -- castanyo@yahoo.es
-#ifndef __IMAGE_H__
-#define __IMAGE_H__
+#pragma once
#include "Color.h"
#include "Common.h"
@@ -89,5 +88,3 @@ inline Color32 &Image::pixel(uint x, uint y)
{
return pixel(y * width() + x);
}
-
-#endif /* __IMAGE_H__ */
diff --git a/source/blender/imbuf/intern/dds/PixelFormat.h b/source/blender/imbuf/intern/dds/PixelFormat.h
index 47585147dfb..a9125c64121 100644
--- a/source/blender/imbuf/intern/dds/PixelFormat.h
+++ b/source/blender/imbuf/intern/dds/PixelFormat.h
@@ -48,8 +48,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
-#ifndef __PIXELFORMAT_H__
-#define __PIXELFORMAT_H__
+#pragma once
#include "Common.h"
@@ -126,5 +125,3 @@ inline float quantizeFloor(float f, int bits)
#endif
} // namespace PixelFormat
-
-#endif /* __PIXELFORMAT_H__ */
diff --git a/source/blender/imbuf/intern/dds/Stream.cpp b/source/blender/imbuf/intern/dds/Stream.cpp
index 271717f165c..e1c5eb1d505 100644
--- a/source/blender/imbuf/intern/dds/Stream.cpp
+++ b/source/blender/imbuf/intern/dds/Stream.cpp
@@ -42,55 +42,55 @@ unsigned int mem_read(Stream &mem, unsigned long long &i)
{
if (mem.pos + 8 > mem.size) {
mem.set_failed(msg_error_seek);
- return (0);
+ return 0;
}
memcpy(&i, mem.mem + mem.pos, 8); // @@ todo: make sure little endian
mem.pos += 8;
- return (8);
+ return 8;
}
unsigned int mem_read(Stream &mem, unsigned int &i)
{
if (mem.pos + 4 > mem.size) {
mem.set_failed(msg_error_read);
- return (0);
+ return 0;
}
memcpy(&i, mem.mem + mem.pos, 4); // @@ todo: make sure little endian
mem.pos += 4;
- return (4);
+ return 4;
}
unsigned int mem_read(Stream &mem, unsigned short &i)
{
if (mem.pos + 2 > mem.size) {
mem.set_failed(msg_error_read);
- return (0);
+ return 0;
}
memcpy(&i, mem.mem + mem.pos, 2); // @@ todo: make sure little endian
mem.pos += 2;
- return (2);
+ return 2;
}
unsigned int mem_read(Stream &mem, unsigned char &i)
{
if (mem.pos + 1 > mem.size) {
mem.set_failed(msg_error_read);
- return (0);
+ return 0;
}
i = (mem.mem + mem.pos)[0];
mem.pos += 1;
- return (1);
+ return 1;
}
unsigned int mem_read(Stream &mem, unsigned char *i, unsigned int cnt)
{
if (mem.pos + cnt > mem.size) {
mem.set_failed(msg_error_read);
- return (0);
+ return 0;
}
memcpy(i, mem.mem + mem.pos, cnt);
mem.pos += cnt;
- return (cnt);
+ return cnt;
}
void Stream::set_failed(const char *msg)
diff --git a/source/blender/imbuf/intern/dds/Stream.h b/source/blender/imbuf/intern/dds/Stream.h
index 43cd6b56fb9..ad6b9165801 100644
--- a/source/blender/imbuf/intern/dds/Stream.h
+++ b/source/blender/imbuf/intern/dds/Stream.h
@@ -20,8 +20,7 @@
/* simple memory stream functions with buffer overflow check */
-#ifndef __STREAM_H__
-#define __STREAM_H__
+#pragma once
struct Stream {
unsigned char *mem; // location in memory
@@ -40,5 +39,3 @@ unsigned int mem_read(Stream &mem, unsigned int &i);
unsigned int mem_read(Stream &mem, unsigned short &i);
unsigned int mem_read(Stream &mem, unsigned char &i);
unsigned int mem_read(Stream &mem, unsigned char *i, unsigned int cnt);
-
-#endif /* __STREAM_H__ */
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index 83d304203a0..309b5d6410f 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -44,14 +44,14 @@ extern "C" {
int imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
{
- return (0); /* todo: finish this function */
+ return 0; /* todo: finish this function */
/* check image buffer */
if (ibuf == 0) {
- return (0);
+ return 0;
}
if (ibuf->rect == 0) {
- return (0);
+ return 0;
}
/* open file for writing */
@@ -69,7 +69,7 @@ int imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
fildes << "DDS ";
fildes.close();
- return (1);
+ return 1;
}
int imb_is_a_dds(const unsigned char *mem) // note: use at most first 32 bytes
@@ -77,13 +77,13 @@ int imb_is_a_dds(const unsigned char *mem) // note: use at most first 32 bytes
/* heuristic check to see if mem contains a DDS file */
/* header.fourcc == FOURCC_DDS */
if ((mem[0] != 'D') || (mem[1] != 'D') || (mem[2] != 'S') || (mem[3] != ' ')) {
- return (0);
+ return 0;
}
/* header.size == 124 */
if ((mem[4] != 124) || mem[5] || mem[6] || mem[7]) {
- return (0);
+ return 0;
}
- return (1);
+ return 1;
}
struct ImBuf *imb_load_dds(const unsigned char *mem,
@@ -109,27 +109,27 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
if (!imb_is_a_dds(mem)) {
- return (0);
+ return 0;
}
/* check if DDS is valid and supported */
if (!dds.isValid()) {
/* no need to print error here, just testing if it is a DDS */
if (flags & IB_test) {
- return (0);
+ return 0;
}
printf("DDS: not valid; header follows\n");
dds.printInfo();
- return (0);
+ return 0;
}
if (!dds.isSupported()) {
printf("DDS: format not supported\n");
- return (0);
+ return 0;
}
if ((dds.width() > 65535) || (dds.height() > 65535)) {
printf("DDS: dimensions too large\n");
- return (0);
+ return 0;
}
/* convert DDS into ImBuf */
@@ -149,7 +149,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
}
ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, 0);
if (ibuf == 0) {
- return (0); /* memory allocation failed */
+ return 0; /* memory allocation failed */
}
ibuf->ftype = IMB_FTYPE_DDS;
@@ -158,10 +158,10 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
if ((flags & IB_test) == 0) {
if (!imb_addrectImBuf(ibuf)) {
- return (ibuf);
+ return ibuf;
}
if (ibuf->rect == 0) {
- return (ibuf);
+ return ibuf;
}
rect = ibuf->rect;
@@ -196,7 +196,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
IMB_flipy(ibuf);
}
- return (ibuf);
+ return ibuf;
}
} // extern "C"
diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h
index e6782e217fc..930205c9efb 100644
--- a/source/blender/imbuf/intern/dds/dds_api.h
+++ b/source/blender/imbuf/intern/dds/dds_api.h
@@ -18,8 +18,7 @@
* \ingroup imbdds
*/
-#ifndef __DDS_API_H__
-#define __DDS_API_H__
+#pragma once
#include "../../IMB_imbuf.h"
@@ -37,5 +36,3 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
#ifdef __cplusplus
}
#endif
-
-#endif /* __DDS_API_H */
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index bcc8488089d..798849f2dd4 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -666,7 +666,7 @@ void IMB_buffer_byte_from_byte(uchar *rect_to,
if (profile_to == profile_from) {
/* same profile, copy */
- memcpy(to, from, sizeof(uchar) * 4 * width);
+ memcpy(to, from, sizeof(uchar[4]) * width);
}
else if (profile_to == IB_PROFILE_LINEAR_RGB) {
/* convert to sRGB to linear */
@@ -785,7 +785,7 @@ void IMB_float_from_rect(ImBuf *ibuf)
size_t size;
size = ((size_t)ibuf->x) * ibuf->y;
- size = size * 4 * sizeof(float);
+ size = sizeof(float[4]) * size;
ibuf->channels = 4;
rect_float = MEM_callocN(size, "IMB_float_from_rect");
diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c
index 29430036182..5aa588da36d 100644
--- a/source/blender/imbuf/intern/filetype.c
+++ b/source/blender/imbuf/intern/filetype.c
@@ -224,8 +224,7 @@ const ImFileType IMB_FILE_TYPES[] = {
{NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0},
};
-const ImFileType *IMB_FILE_TYPES_LAST =
- &IMB_FILE_TYPES[sizeof(IMB_FILE_TYPES) / sizeof(ImFileType) - 1];
+const ImFileType *IMB_FILE_TYPES_LAST = &IMB_FILE_TYPES[ARRAY_SIZE(IMB_FILE_TYPES) - 1];
void imb_filetypes_init(void)
{
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c
index d8a5096af71..12f90f27309 100644
--- a/source/blender/imbuf/intern/filter.c
+++ b/source/blender/imbuf/intern/filter.c
@@ -394,9 +394,8 @@ static int filter_make_index(const int x, const int y, const int w, const int h)
if (x < 0 || x >= w || y < 0 || y >= h) {
return -1; /* return bad index */
}
- else {
- return y * w + x;
- }
+
+ return y * w + x;
}
static int check_pixel_assigned(
diff --git a/source/blender/imbuf/intern/imbuf.h b/source/blender/imbuf/intern/imbuf.h
index 912c25f2616..309a911e9ca 100644
--- a/source/blender/imbuf/intern/imbuf.h
+++ b/source/blender/imbuf/intern/imbuf.h
@@ -21,8 +21,7 @@
* \ingroup imbuf
*/
-#ifndef __IMBUF_H__
-#define __IMBUF_H__
+#pragma once
#include <stdio.h>
#include <stdlib.h>
@@ -61,5 +60,3 @@
#endif
#define IMB_DPI_DEFAULT 72.0f
-
-#endif /* __IMBUF_H__ */
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index 7cc31b99077..76717bef537 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -268,9 +268,8 @@ int IMB_indexer_get_frame_index(struct anim_index *idx, int frameno)
if (first == idx->num_entries) {
return idx->num_entries - 1;
}
- else {
- return first;
- }
+
+ return first;
}
unsigned long long IMB_indexer_get_pts(struct anim_index *idx, int frame_index)
@@ -473,10 +472,6 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg(
char fname[FILE_MAX];
int ffmpeg_quality;
- /* JPEG requires this */
- width = round_up(width, 8);
- height = round_up(height, 8);
-
rv->proxy_size = proxy_size;
rv->anim = anim;
@@ -633,9 +628,8 @@ static int add_to_proxy_output_ffmpeg(struct proxy_output_ctx *ctx, AVFrame *fra
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
static void free_proxy_output_ffmpeg(struct proxy_output_ctx *ctx, int rollback)
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index 2516df22151..2d8f1510d7b 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -281,18 +281,18 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors
readheader(inf, &image);
if (image.imagic != IMAGIC) {
fprintf(stderr, "longimagedata: bad magic number in image file\n");
- return (NULL);
+ return NULL;
}
rle = ISRLE(image.type);
bpp = BPP(image.type);
if (bpp != 1 && bpp != 2) {
fprintf(stderr, "longimagedata: image must have 1 or 2 byte per pix chan\n");
- return (NULL);
+ return NULL;
}
if ((uint)image.zsize > 8) {
fprintf(stderr, "longimagedata: channels over 8 not supported\n");
- return (NULL);
+ return NULL;
}
const int xsize = image.xsize;
@@ -304,7 +304,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors
if (ibuf) {
ibuf->ftype = IMB_FTYPE_IMAGIC;
}
- return (ibuf);
+ return ibuf;
}
if (rle) {
@@ -598,7 +598,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors
IMB_convert_rgba_to_abgr(ibuf);
}
- return (ibuf);
+ return ibuf;
}
/* static utility functions for longimagedata */
@@ -892,10 +892,9 @@ static int output_iris(uint *lptr, int xsize, int ysize, int zsize, const char *
if (goodwrite) {
return 1;
}
- else {
- fprintf(stderr, "output_iris: not enough space for image!!\n");
- return 0;
- }
+
+ fprintf(stderr, "output_iris: not enough space for image!!\n");
+ return 0;
}
/* static utility functions for output_iris */
@@ -989,5 +988,5 @@ int imb_saveiris(struct ImBuf *ibuf, const char *name, int flags)
IMB_convert_rgba_to_abgr(ibuf);
test_endian_zbuf(ibuf);
- return (ret);
+ return ret;
}
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index 5154f50c7e8..2244a9c3051 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -73,12 +73,11 @@ static OPJ_CODEC_FORMAT format_from_header(const unsigned char mem[JP2_FILEHEADE
if (check_jp2(mem)) {
return OPJ_CODEC_JP2;
}
- else if (check_j2k(mem)) {
+ if (check_j2k(mem)) {
return OPJ_CODEC_J2K;
}
- else {
- return OPJ_CODEC_UNKNOWN;
- }
+
+ return OPJ_CODEC_UNKNOWN;
}
int imb_is_a_jp2(const unsigned char *buf)
@@ -339,16 +338,14 @@ ImBuf *imb_load_jp2_filepath(const char *filepath, int flags, char colorspace[IM
if (stream) {
return NULL;
}
- else {
- if (fread(mem, sizeof(mem), 1, p_file) != sizeof(mem)) {
- opj_stream_destroy(stream);
- return NULL;
- }
- else {
- fseek(p_file, 0, SEEK_SET);
- }
+
+ if (fread(mem, sizeof(mem), 1, p_file) != sizeof(mem)) {
+ opj_stream_destroy(stream);
+ return NULL;
}
+ fseek(p_file, 0, SEEK_SET);
+
const OPJ_CODEC_FORMAT format = format_from_header(mem);
ImBuf *ibuf = imb_load_jp2_stream(stream, format, flags, colorspace);
opj_stream_destroy(stream);
@@ -651,7 +648,7 @@ BLI_INLINE int DOWNSAMPLE_FLOAT_TO_16BIT(const float _val)
#define COMP_24_CS 1041666 /*Maximum size per color component for 2K & 4K @ 24fps*/
#define COMP_48_CS 520833 /*Maximum size per color component for 2K @ 48fps*/
-static int initialise_4K_poc(opj_poc_t *POC, int numres)
+static int init_4K_poc(opj_poc_t *POC, int numres)
{
POC[0].tile = 1;
POC[0].resno0 = 0;
@@ -750,7 +747,7 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters,
else {
parameters->cp_rsiz = DCP_CINEMA2K;
}
- parameters->numpocs = initialise_4K_poc(parameters->POC, parameters->numresolution);
+ parameters->numpocs = init_4K_poc(parameters->POC, parameters->numresolution);
break;
case OPJ_OFF:
/* do nothing */
@@ -899,7 +896,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
h = ibuf->y;
/* initialize image components */
- memset(&cmptparm, 0, 4 * sizeof(opj_image_cmptparm_t));
+ memset(&cmptparm, 0, sizeof(opj_image_cmptparm_t[4]));
for (i = 0; i < numcomps; i++) {
cmptparm[i].prec = prec;
cmptparm[i].bpp = prec;
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index fe74d9bc23f..3346f1c0964 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -417,7 +417,7 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla
}
}
- return (ibuf);
+ return ibuf;
}
ImBuf *imb_load_jpeg(const unsigned char *buffer,
@@ -452,7 +452,7 @@ ImBuf *imb_load_jpeg(const unsigned char *buffer,
ibuf = ibJpegImageFromCinfo(cinfo, flags);
- return (ibuf);
+ return ibuf;
}
static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf)
@@ -479,7 +479,7 @@ static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf)
for (prop = ibuf->metadata->data.group.first; prop; prop = prop->next) {
if (prop->type == IDP_STRING) {
int text_len;
- if (!strcmp(prop->name, "None")) {
+ if (STREQ(prop->name, "None")) {
jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *)IDP_String(prop), prop->len + 1);
}
@@ -605,7 +605,7 @@ static int init_jpeg(FILE *outfile, struct jpeg_compress_struct *cinfo, struct I
cinfo->dct_method = JDCT_FLOAT;
jpeg_set_quality(cinfo, quality, true);
- return (0);
+ return 0;
}
static int save_stdjpeg(const char *name, struct ImBuf *ibuf)
diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c
index 96ecbdce9cc..e395222a214 100644
--- a/source/blender/imbuf/intern/moviecache.c
+++ b/source/blender/imbuf/intern/moviecache.c
@@ -192,9 +192,8 @@ static size_t get_size_in_memory(ImBuf *ibuf)
if (ibuf->userflags & IB_PERSISTENT) {
return 0;
}
- else {
- return IMB_get_size_in_memory(ibuf);
- }
+
+ return IMB_get_size_in_memory(ibuf);
}
static size_t get_item_size(void *p)
{
@@ -537,7 +536,7 @@ void IMB_moviecache_get_cache_segments(
if (totseg) {
int b, *points;
- points = MEM_callocN(2 * sizeof(int) * totseg, "movieclip cache segments");
+ points = MEM_callocN(sizeof(int[2]) * totseg, "movieclip cache segments");
/* fill */
for (a = 0, b = 0; a < totframe; a++) {
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
index df51aada5f0..86bb5934db6 100644
--- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
@@ -182,10 +182,10 @@ int imb_save_photoshop(struct ImBuf *ibuf, const char * /*name*/, int flags)
<< " currently not supported" << std::endl;
imb_addencodedbufferImBuf(ibuf);
ibuf->encodedsize = 0;
- return (0);
+ return 0;
}
- return (0);
+ return 0;
}
struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspace[IM_MAX_SPACE])
@@ -199,7 +199,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
/* load image from file through OIIO */
if (imb_is_a_photoshop(filename) == 0) {
- return (NULL);
+ return NULL;
}
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.h b/source/blender/imbuf/intern/oiio/openimageio_api.h
index 3dd089d65cb..3f5f234099c 100644
--- a/source/blender/imbuf/intern/oiio/openimageio_api.h
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.h
@@ -21,8 +21,7 @@
* \ingroup openimageio
*/
-#ifndef __OPENIMAGEIO_API_H__
-#define __OPENIMAGEIO_API_H__
+#pragma once
#include <stdio.h>
@@ -44,5 +43,3 @@ int OIIO_getVersionHex(void);
}
#endif
-
-#endif /* __OPENIMAGEIO_API_H__ */
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 9b614eab0dc..67bb3677834 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -131,9 +131,8 @@ class IMemStream : public Imf::IStream {
_exrpos += n;
return true;
}
- else {
- return false;
- }
+
+ return false;
}
virtual Int64 tellg()
@@ -597,15 +596,13 @@ int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
if (ibuf->foptions.flag & OPENEXR_HALF) {
return (int)imb_save_openexr_half(ibuf, name, flags);
}
- else {
- /* when no float rect, we save as half (16 bits is sufficient) */
- if (ibuf->rect_float == NULL) {
- return (int)imb_save_openexr_half(ibuf, name, flags);
- }
- else {
- return (int)imb_save_openexr_float(ibuf, name, flags);
- }
+
+ /* when no float rect, we save as half (16 bits is sufficient) */
+ if (ibuf->rect_float == NULL) {
+ return (int)imb_save_openexr_half(ibuf, name, flags);
}
+
+ return (int)imb_save_openexr_float(ibuf, name, flags);
}
/* ******* Nicer API, MultiLayer and with Tile file support ************************************ */
@@ -719,9 +716,8 @@ static int imb_exr_get_multiView_id(StringVector &views, const std::string &name
if (name == *i) {
return count;
}
- else {
- count++;
- }
+
+ count++;
}
/* no views or wrong name */
@@ -741,7 +737,7 @@ static void imb_exr_get_views(MultiPartInputFile &file, StringVector &views)
else {
for (int p = 0; p < file.parts(); p++) {
- std::string view = "";
+ std::string view;
if (file.header(p).hasView()) {
view = file.header(p).view();
}
@@ -1173,7 +1169,7 @@ void IMB_exrtile_write_channels(
/* eventually we can make the parts' channels to include
* only the current view TODO */
- if (strcmp(viewname, echan->m->view.c_str()) != 0) {
+ if (!STREQ(viewname, echan->m->view.c_str())) {
continue;
}
@@ -1421,7 +1417,7 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa
printf("multilayer read: bad channel name: %s\n", name);
return 0;
}
- else if (len == 1) {
+ if (len == 1) {
echan->chan_id = token[0];
}
else if (len > 1) {
@@ -1904,7 +1900,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
MultiPartInputFile *file = NULL;
if (imb_is_a_openexr(mem) == 0) {
- return (NULL);
+ return NULL;
}
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);
@@ -1980,7 +1976,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
const bool has_luma = exr_has_luma(*file);
FrameBuffer frameBuffer;
float *first;
- int xstride = sizeof(float) * 4;
+ int xstride = sizeof(float[4]);
int ystride = -xstride * width;
imb_addrectfloatImBuf(ibuf);
@@ -2077,7 +2073,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
ibuf->flags |= IB_alphamode_premul;
}
}
- return (ibuf);
+ return ibuf;
}
catch (const std::exception &exc) {
std::cerr << exc.what() << std::endl;
@@ -2087,7 +2083,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
delete file;
delete membuf;
- return (0);
+ return 0;
}
}
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h
index b0835e5082e..73db146849b 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.h
+++ b/source/blender/imbuf/intern/openexr/openexr_api.h
@@ -21,8 +21,7 @@
* \ingroup openexr
*/
-#ifndef __OPENEXR_API_H__
-#define __OPENEXR_API_H__
+#pragma once
#include <stdio.h>
@@ -42,5 +41,3 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem, size_t size, int flags,
#ifdef __cplusplus
}
#endif
-
-#endif /* __OPENEXR_API_H */
diff --git a/source/blender/imbuf/intern/openexr/openexr_multi.h b/source/blender/imbuf/intern/openexr/openexr_multi.h
index 58f103aeba0..7008447313d 100644
--- a/source/blender/imbuf/intern/openexr/openexr_multi.h
+++ b/source/blender/imbuf/intern/openexr/openexr_multi.h
@@ -21,8 +21,7 @@
* \ingroup openexr
*/
-#ifndef __OPENEXR_MULTI_H__
-#define __OPENEXR_MULTI_H__
+#pragma once
/* experiment with more advanced exr api */
@@ -99,5 +98,3 @@ bool IMB_exr_has_multilayer(void *handle);
#ifdef __cplusplus
} // extern "C"
#endif
-
-#endif /* __OPENEXR_MULTI_H */
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 9e600f363c5..2eb1b216572 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -71,7 +71,7 @@ int imb_is_a_png(const unsigned char *mem)
ret_val = !png_sig_cmp(mem, 0, 8);
#endif
}
- return (ret_val);
+ return ret_val;
}
static void Flush(png_structp png_ptr)
@@ -161,7 +161,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
bytesperpixel = (ibuf->planes + 7) >> 3;
if ((bytesperpixel > 4) || (bytesperpixel == 2)) {
printf("imb_savepng: Unsupported bytes per pixel: %d for file: '%s'\n", bytesperpixel, name);
- return (0);
+ return 0;
}
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
@@ -511,7 +511,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
fclose(fp);
}
- return (1);
+ return 1;
}
static void imb_png_warning(png_structp UNUSED(png_ptr), png_const_charp message)
@@ -549,7 +549,7 @@ ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colors
unsigned int channels;
if (imb_is_a_png(mem) == 0) {
- return (NULL);
+ return NULL;
}
/* both 8 and 16 bit PNGs are default to standard byte colorspace */
@@ -819,5 +819,5 @@ ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colors
}
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
- return (ibuf);
+ return ibuf;
}
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c
index 91787d64525..8b4f33bb306 100644
--- a/source/blender/imbuf/intern/rectop.c
+++ b/source/blender/imbuf/intern/rectop.c
@@ -610,7 +610,7 @@ void IMB_rectblend(ImBuf *dbuf,
}
if (do_float) {
- memcpy(drectf, srectf, width * sizeof(float) * 4);
+ memcpy(drectf, srectf, sizeof(float[4]) * width);
drectf += destskip * 4;
srectf += srcskip * 4;
}
diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c
index 17b485b5171..c2fc2190ce5 100644
--- a/source/blender/imbuf/intern/rotate.c
+++ b/source/blender/imbuf/intern/rotate.c
@@ -108,11 +108,11 @@ void IMB_flipx(struct ImBuf *ibuf)
if (ibuf->rect_float) {
for (yi = y - 1; yi >= 0; yi--) {
for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) {
- memcpy(&px_f, &ibuf->rect_float[((x * yi) + xr) * 4], 4 * sizeof(float));
+ memcpy(&px_f, &ibuf->rect_float[((x * yi) + xr) * 4], sizeof(float[4]));
memcpy(&ibuf->rect_float[((x * yi) + xr) * 4],
&ibuf->rect_float[((x * yi) + xl) * 4],
- 4 * sizeof(float));
- memcpy(&ibuf->rect_float[((x * yi) + xl) * 4], &px_f, 4 * sizeof(float));
+ sizeof(float[4]));
+ memcpy(&ibuf->rect_float[((x * yi) + xl) * 4], &px_f, sizeof(float[4]));
}
}
}
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index 95f720a9d16..1fd9bba68f3 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -99,10 +99,10 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1)
struct ImBuf *ibuf2;
if (ibuf1 == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf1->x <= 1) {
@@ -111,12 +111,12 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1)
ibuf2 = IMB_allocImBuf((ibuf1->x) / 2, ibuf1->y, ibuf1->planes, ibuf1->flags);
if (ibuf2 == NULL) {
- return (NULL);
+ return NULL;
}
imb_half_x_no_alloc(ibuf2, ibuf1);
- return (ibuf2);
+ return ibuf2;
}
struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1)
@@ -126,10 +126,10 @@ struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1)
float *p1f, *destf;
if (ibuf1 == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
- return (NULL);
+ return NULL;
}
do_rect = (ibuf1->rect != NULL);
@@ -137,7 +137,7 @@ struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1)
ibuf2 = IMB_allocImBuf(2 * ibuf1->x, ibuf1->y, ibuf1->planes, ibuf1->flags);
if (ibuf2 == NULL) {
- return (NULL);
+ return NULL;
}
p1 = (int *)ibuf1->rect;
@@ -161,7 +161,7 @@ struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1)
}
}
- return (ibuf2);
+ return ibuf2;
}
struct ImBuf *IMB_double_x(struct ImBuf *ibuf1)
@@ -169,16 +169,16 @@ struct ImBuf *IMB_double_x(struct ImBuf *ibuf1)
struct ImBuf *ibuf2;
if (ibuf1 == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
- return (NULL);
+ return NULL;
}
ibuf2 = IMB_double_fast_x(ibuf1);
imb_filterx(ibuf2);
- return (ibuf2);
+ return ibuf2;
}
static void imb_half_y_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
@@ -253,10 +253,10 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1)
struct ImBuf *ibuf2;
if (ibuf1 == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf1->y <= 1) {
@@ -265,12 +265,12 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1)
ibuf2 = IMB_allocImBuf(ibuf1->x, (ibuf1->y) / 2, ibuf1->planes, ibuf1->flags);
if (ibuf2 == NULL) {
- return (NULL);
+ return NULL;
}
imb_half_y_no_alloc(ibuf2, ibuf1);
- return (ibuf2);
+ return ibuf2;
}
struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1)
@@ -282,10 +282,10 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1)
int do_rect, do_float;
if (ibuf1 == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
- return (NULL);
+ return NULL;
}
do_rect = (ibuf1->rect != NULL);
@@ -293,7 +293,7 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1)
ibuf2 = IMB_allocImBuf(ibuf1->x, 2 * ibuf1->y, ibuf1->planes, ibuf1->flags);
if (ibuf2 == NULL) {
- return (NULL);
+ return NULL;
}
p1 = (int *)ibuf1->rect;
@@ -318,7 +318,7 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1)
}
}
- return (ibuf2);
+ return ibuf2;
}
struct ImBuf *IMB_double_y(struct ImBuf *ibuf1)
@@ -326,16 +326,16 @@ struct ImBuf *IMB_double_y(struct ImBuf *ibuf1)
struct ImBuf *ibuf2;
if (ibuf1 == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf1->rect == NULL) {
- return (NULL);
+ return NULL;
}
ibuf2 = IMB_double_fast_y(ibuf1);
IMB_filtery(ibuf2);
- return (ibuf2);
+ return ibuf2;
}
/* pretty much specific functions which converts uchar <-> ushort but assumes
@@ -453,10 +453,10 @@ ImBuf *IMB_onehalf(struct ImBuf *ibuf1)
struct ImBuf *ibuf2;
if (ibuf1 == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf1->x <= 1) {
@@ -468,12 +468,12 @@ ImBuf *IMB_onehalf(struct ImBuf *ibuf1)
ibuf2 = IMB_allocImBuf((ibuf1->x) / 2, (ibuf1->y) / 2, ibuf1->planes, ibuf1->flags);
if (ibuf2 == NULL) {
- return (NULL);
+ return NULL;
}
imb_onehalf_no_alloc(ibuf2, ibuf1);
- return (ibuf2);
+ return ibuf2;
}
/* q_scale_linear_interpolation helper functions */
@@ -886,7 +886,7 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy)
}
if (ibuf->rect) {
- unsigned char *newrect = MEM_mallocN(newx * newy * sizeof(int), "q_scale rect");
+ unsigned char *newrect = MEM_mallocN(sizeof(int) * newx * newy, "q_scale rect");
q_scale_byte((unsigned char *)ibuf->rect, newrect, ibuf->x, ibuf->y, newx, newy);
imb_freerectImBuf(ibuf);
@@ -894,7 +894,7 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy)
ibuf->rect = (unsigned int *)newrect;
}
if (ibuf->rect_float) {
- float *newrect = MEM_mallocN(newx * newy * 4 * sizeof(float), "q_scale rectfloat");
+ float *newrect = MEM_mallocN(sizeof(float[4]) * newx * newy, "q_scale rectfloat");
q_scale_float(ibuf->rect_float, newrect, ibuf->x, ibuf->y, newx, newy);
imb_freerectfloatImBuf(ibuf);
ibuf->mall |= IB_rectfloat;
@@ -923,22 +923,22 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f;
if (!do_rect && !do_float) {
- return (ibuf);
+ return ibuf;
}
if (do_rect) {
- _newrect = MEM_mallocN(newx * ibuf->y * sizeof(uchar) * 4, "scaledownx");
+ _newrect = MEM_mallocN(sizeof(uchar[4]) * newx * ibuf->y, "scaledownx");
if (_newrect == NULL) {
- return (ibuf);
+ return ibuf;
}
}
if (do_float) {
- _newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaledownxf");
+ _newrectf = MEM_mallocN(sizeof(float[4]) * newx * ibuf->y, "scaledownxf");
if (_newrectf == NULL) {
if (_newrect) {
MEM_freeN(_newrect);
}
- return (ibuf);
+ return ibuf;
}
}
@@ -1044,7 +1044,7 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
(void)rect_size; /* UNUSED in release builds */
ibuf->x = newx;
- return (ibuf);
+ return ibuf;
}
static ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
@@ -1064,22 +1064,22 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f;
if (!do_rect && !do_float) {
- return (ibuf);
+ return ibuf;
}
if (do_rect) {
- _newrect = MEM_mallocN(newy * ibuf->x * sizeof(uchar) * 4, "scaledowny");
+ _newrect = MEM_mallocN(sizeof(uchar[4]) * newy * ibuf->x, "scaledowny");
if (_newrect == NULL) {
- return (ibuf);
+ return ibuf;
}
}
if (do_float) {
- _newrectf = MEM_mallocN(newy * ibuf->x * sizeof(float) * 4, "scaledownyf");
+ _newrectf = MEM_mallocN(sizeof(float[4]) * newy * ibuf->x, "scaledownyf");
if (_newrectf == NULL) {
if (_newrect) {
MEM_freeN(_newrect);
}
- return (ibuf);
+ return ibuf;
}
}
@@ -1186,7 +1186,7 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
(void)rect_size; /* UNUSED in release builds */
ibuf->y = newy;
- return (ibuf);
+ return ibuf;
}
static ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
@@ -1210,27 +1210,27 @@ static ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
val_af = nval_af = diff_af = val_bf = nval_bf = diff_bf = 0;
val_gf = nval_gf = diff_gf = val_rf = nval_rf = diff_rf = 0;
if (ibuf == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
- return (ibuf);
+ return ibuf;
}
if (ibuf->rect) {
do_rect = true;
_newrect = MEM_mallocN(newx * ibuf->y * sizeof(int), "scaleupx");
if (_newrect == NULL) {
- return (ibuf);
+ return ibuf;
}
}
if (ibuf->rect_float) {
do_float = true;
- _newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaleupxf");
+ _newrectf = MEM_mallocN(sizeof(float[4]) * newx * ibuf->y, "scaleupxf");
if (_newrectf == NULL) {
if (_newrect) {
MEM_freeN(_newrect);
}
- return (ibuf);
+ return ibuf;
}
}
@@ -1362,7 +1362,7 @@ static ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
}
ibuf->x = newx;
- return (ibuf);
+ return ibuf;
}
static ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
@@ -1386,27 +1386,27 @@ static ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
val_af = nval_af = diff_af = val_bf = nval_bf = diff_bf = 0;
val_gf = nval_gf = diff_gf = val_rf = nval_rf = diff_rf = 0;
if (ibuf == NULL) {
- return (NULL);
+ return NULL;
}
if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
- return (ibuf);
+ return ibuf;
}
if (ibuf->rect) {
do_rect = true;
_newrect = MEM_mallocN(ibuf->x * newy * sizeof(int), "scaleupy");
if (_newrect == NULL) {
- return (ibuf);
+ return ibuf;
}
}
if (ibuf->rect_float) {
do_float = true;
- _newrectf = MEM_mallocN(ibuf->x * newy * sizeof(float) * 4, "scaleupyf");
+ _newrectf = MEM_mallocN(sizeof(float[4]) * ibuf->x * newy, "scaleupyf");
if (_newrectf == NULL) {
if (_newrect) {
MEM_freeN(_newrect);
}
- return (ibuf);
+ return ibuf;
}
}
@@ -1545,7 +1545,7 @@ static ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
}
ibuf->y = newy;
- return (ibuf);
+ return ibuf;
}
static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
@@ -1703,7 +1703,7 @@ bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy
}
if (do_float) {
- _newrectf = MEM_mallocN(newx * newy * sizeof(float) * 4, "scalefastimbuf f");
+ _newrectf = MEM_mallocN(sizeof(float[4]) * newx * newy, "scalefastimbuf f");
if (_newrectf == NULL) {
if (_newrect) {
MEM_freeN(_newrect);
diff --git a/source/blender/imbuf/intern/stereoimbuf.c b/source/blender/imbuf/intern/stereoimbuf.c
index 5569e119b95..247122065de 100644
--- a/source/blender/imbuf/intern/stereoimbuf.c
+++ b/source/blender/imbuf/intern/stereoimbuf.c
@@ -669,17 +669,17 @@ static void imb_stereo3d_squeeze_rect(
/*************************** preparing to call the write functions **************************/
-static void imb_stereo3d_data_initialize(Stereo3DData *s3d_data,
- const bool is_float,
- const size_t x,
- const size_t y,
- const size_t channels,
- int *rect_left,
- int *rect_right,
- int *rect_stereo,
- float *rectf_left,
- float *rectf_right,
- float *rectf_stereo)
+static void imb_stereo3d_data_init(Stereo3DData *s3d_data,
+ const bool is_float,
+ const size_t x,
+ const size_t y,
+ const size_t channels,
+ int *rect_left,
+ int *rect_right,
+ int *rect_stereo,
+ float *rectf_left,
+ float *rectf_right,
+ float *rectf_stereo)
{
s3d_data->is_float = is_float;
s3d_data->x = x;
@@ -709,7 +709,7 @@ int *IMB_stereo3d_from_rect(ImageFormatData *im_format,
im_format->stereo3d_format.display_mode, false, x, y, &width, &height);
r_rect = MEM_mallocN(channels * sizeof(int) * width * height, __func__);
- imb_stereo3d_data_initialize(
+ imb_stereo3d_data_init(
&s3d_data, is_float, x, y, channels, rect_left, rect_right, r_rect, NULL, NULL, NULL);
imb_stereo3d_write_doit(&s3d_data, &im_format->stereo3d_format);
imb_stereo3d_squeeze_rect(r_rect, &im_format->stereo3d_format, x, y, channels);
@@ -733,7 +733,7 @@ float *IMB_stereo3d_from_rectf(ImageFormatData *im_format,
im_format->stereo3d_format.display_mode, false, x, y, &width, &height);
r_rectf = MEM_mallocN(channels * sizeof(float) * width * height, __func__);
- imb_stereo3d_data_initialize(
+ imb_stereo3d_data_init(
&s3d_data, is_float, x, y, channels, NULL, NULL, NULL, rectf_left, rectf_right, r_rectf);
imb_stereo3d_write_doit(&s3d_data, &im_format->stereo3d_format);
imb_stereo3d_squeeze_rectf(r_rectf, &im_format->stereo3d_format, x, y, channels);
@@ -759,17 +759,17 @@ ImBuf *IMB_stereo3d_ImBuf(ImageFormatData *im_format, ImBuf *ibuf_left, ImBuf *i
ibuf_stereo->flags = ibuf_left->flags;
- imb_stereo3d_data_initialize(&s3d_data,
- is_float,
- ibuf_left->x,
- ibuf_left->y,
- 4,
- (int *)ibuf_left->rect,
- (int *)ibuf_right->rect,
- (int *)ibuf_stereo->rect,
- ibuf_left->rect_float,
- ibuf_right->rect_float,
- ibuf_stereo->rect_float);
+ imb_stereo3d_data_init(&s3d_data,
+ is_float,
+ ibuf_left->x,
+ ibuf_left->y,
+ 4,
+ (int *)ibuf_left->rect,
+ (int *)ibuf_right->rect,
+ (int *)ibuf_stereo->rect,
+ ibuf_left->rect_float,
+ ibuf_right->rect_float,
+ ibuf_stereo->rect_float);
imb_stereo3d_write_doit(&s3d_data, &im_format->stereo3d_format);
imb_stereo3d_squeeze_ImBuf(ibuf_stereo, &im_format->stereo3d_format, ibuf_left->x, ibuf_left->y);
@@ -1286,17 +1286,17 @@ void IMB_ImBufFromStereo3d(Stereo3dFormat *s3d,
&height);
imb_stereo3d_unsqueeze_ImBuf(ibuf_stereo3d, s3d, width, height);
- imb_stereo3d_data_initialize(&s3d_data,
- is_float,
- ibuf_left->x,
- ibuf_left->y,
- 4,
- (int *)ibuf_left->rect,
- (int *)ibuf_right->rect,
- (int *)ibuf_stereo3d->rect,
- ibuf_left->rect_float,
- ibuf_right->rect_float,
- ibuf_stereo3d->rect_float);
+ imb_stereo3d_data_init(&s3d_data,
+ is_float,
+ ibuf_left->x,
+ ibuf_left->y,
+ 4,
+ (int *)ibuf_left->rect,
+ (int *)ibuf_right->rect,
+ (int *)ibuf_stereo3d->rect,
+ ibuf_left->rect_float,
+ ibuf_right->rect_float,
+ ibuf_stereo3d->rect_float);
imb_stereo3d_read_doit(&s3d_data, s3d);
@@ -1310,17 +1310,17 @@ void IMB_ImBufFromStereo3d(Stereo3dFormat *s3d,
addzbufImBuf(ibuf_right);
}
- imb_stereo3d_data_initialize(&s3d_data,
- is_float,
- ibuf_left->x,
- ibuf_left->y,
- 1,
- (int *)ibuf_left->zbuf,
- (int *)ibuf_right->zbuf,
- (int *)ibuf_stereo3d->zbuf,
- ibuf_left->zbuf_float,
- ibuf_right->zbuf_float,
- ibuf_stereo3d->zbuf_float);
+ imb_stereo3d_data_init(&s3d_data,
+ is_float,
+ ibuf_left->x,
+ ibuf_left->y,
+ 1,
+ (int *)ibuf_left->zbuf,
+ (int *)ibuf_right->zbuf,
+ (int *)ibuf_stereo3d->zbuf,
+ ibuf_left->zbuf_float,
+ ibuf_right->zbuf_float,
+ ibuf_stereo3d->zbuf_float);
imb_stereo3d_read_doit(&s3d_data, s3d);
}
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c
index 715f2aaf621..c95476fa628 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -104,7 +104,7 @@ static int imb_tiff_DummyMapProc(
(void)pbase;
(void)psize;
- return (0);
+ return 0;
}
/**
@@ -145,7 +145,7 @@ static tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n)
/* on EOF, return immediately and read (copy) nothing */
if (nCopy <= 0) {
- return (0);
+ return 0;
}
/* all set -> do the read (copy) */
@@ -238,7 +238,7 @@ static int imb_tiff_CloseProc(thandle_t handle)
mfile = IMB_TIFF_GET_MEMFILE(handle);
if (!mfile || !mfile->mem) {
fprintf(stderr, "imb_tiff_CloseProc: !mfile || !mfile->mem!\n");
- return (0);
+ return 0;
}
/* virtually close the file */
@@ -246,7 +246,7 @@ static int imb_tiff_CloseProc(thandle_t handle)
mfile->offset = 0;
mfile->size = 0;
- return (0);
+ return 0;
}
/**
@@ -262,7 +262,7 @@ static toff_t imb_tiff_SizeProc(thandle_t handle)
mfile = IMB_TIFF_GET_MEMFILE(handle);
if (!mfile || !mfile->mem) {
fprintf(stderr, "imb_tiff_SizeProc: !mfile || !mfile->mem!\n");
- return (0);
+ return 0;
}
/* return the size */
@@ -306,8 +306,8 @@ static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, const unsigned char *
#define IMB_TIFF_NCB 4 /* number of comparison bytes used */
int imb_is_a_tiff(const unsigned char *mem)
{
- char big_endian[IMB_TIFF_NCB] = {0x4d, 0x4d, 0x00, 0x2a};
- char lil_endian[IMB_TIFF_NCB] = {0x49, 0x49, 0x2a, 0x00};
+ const char big_endian[IMB_TIFF_NCB] = {0x4d, 0x4d, 0x00, 0x2a};
+ const char lil_endian[IMB_TIFF_NCB] = {0x49, 0x49, 0x2a, 0x00};
return ((memcmp(big_endian, mem, IMB_TIFF_NCB) == 0) ||
(memcmp(lil_endian, mem, IMB_TIFF_NCB) == 0));
@@ -764,7 +764,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
"imb_savetiff: unsupported number of bytes per "
"pixel: %d\n",
samplesperpixel);
- return (0);
+ return 0;
}
if ((ibuf->foptions.flag & TIF_16BIT) && ibuf->rect_float) {
@@ -790,21 +790,21 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
fprintf(stderr,
"imb_savetiff: creation of in-memory TIFF files is "
"not yet supported.\n");
- return (0);
+ return 0;
}
- else {
- /* create image as a file */
+
+ /* create image as a file */
#ifdef WIN32
- wchar_t *wname = alloc_utf16_from_8(name, 0);
- image = TIFFOpenW(wname, "w");
- free(wname);
+ wchar_t *wname = alloc_utf16_from_8(name, 0);
+ image = TIFFOpenW(wname, "w");
+ free(wname);
#else
- image = TIFFOpen(name, "w");
+ image = TIFFOpen(name, "w");
#endif
- }
+
if (image == NULL) {
fprintf(stderr, "imb_savetiff: could not open TIFF for writing.\n");
- return (0);
+ return 0;
}
/* allocate array for pixel data */
@@ -819,7 +819,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
if (pixels == NULL && pixels16 == NULL) {
fprintf(stderr, "imb_savetiff: could not allocate pixels array.\n");
TIFFClose(image);
- return (0);
+ return 0;
}
/* setup pointers */
@@ -945,7 +945,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
if (pixels16) {
_TIFFfree(pixels16);
}
- return (1);
+ return 1;
}
/* close the TIFF file */
@@ -956,5 +956,5 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
if (pixels16) {
_TIFFfree(pixels16);
}
- return (1);
+ return 1;
}
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index 3c420f3f297..64b03f332a8 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -339,42 +339,42 @@ int imb_get_anim_type(const char *name)
# ifdef WITH_FFMPEG
/* stat test below fails on large files > 4GB */
if (isffmpeg(name)) {
- return (ANIM_FFMPEG);
+ return ANIM_FFMPEG;
}
# endif
if (BLI_stat(name, &st) == -1) {
- return (0);
+ return 0;
}
if (((st.st_mode) & S_IFMT) != S_IFREG) {
- return (0);
+ return 0;
}
if (isavi(name)) {
- return (ANIM_AVI);
+ return ANIM_AVI;
}
if (ismovie(name)) {
- return (ANIM_MOVIE);
+ return ANIM_MOVIE;
}
#else
if (BLI_stat(name, &st) == -1) {
- return (0);
+ return 0;
}
if (((st.st_mode) & S_IFMT) != S_IFREG) {
- return (0);
+ return 0;
}
if (ismovie(name)) {
- return (ANIM_MOVIE);
+ return ANIM_MOVIE;
}
# ifdef WITH_FFMPEG
if (isffmpeg(name)) {
- return (ANIM_FFMPEG);
+ return ANIM_FFMPEG;
}
# endif
if (isavi(name)) {
- return (ANIM_AVI);
+ return ANIM_AVI;
}
#endif
type = IMB_ispic(name);
diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c
new file mode 100644
index 00000000000..58ff8473a85
--- /dev/null
+++ b/source/blender/imbuf/intern/util_gpu.c
@@ -0,0 +1,260 @@
+/*
+ * 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.
+ * util.c
+ */
+
+/** \file
+ * \ingroup imbuf
+ */
+
+#include "imbuf.h"
+
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+#include "MEM_guardedalloc.h"
+
+#include "BKE_global.h"
+
+#include "GPU_extensions.h"
+#include "GPU_texture.h"
+
+#include "IMB_colormanagement.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
+/* gpu ibuf utils */
+
+static void imb_gpu_get_format(const ImBuf *ibuf,
+ bool high_bitdepth,
+ eGPUDataFormat *r_data_format,
+ eGPUTextureFormat *r_texture_format)
+{
+ const bool float_rect = (ibuf->rect_float != NULL);
+ const bool use_srgb = (!IMB_colormanagement_space_is_data(ibuf->rect_colorspace) &&
+ !IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace));
+ high_bitdepth = (!(ibuf->flags & IB_halffloat) && high_bitdepth);
+
+ *r_data_format = (float_rect) ? GPU_DATA_FLOAT : GPU_DATA_UNSIGNED_BYTE;
+
+ if (float_rect) {
+ *r_texture_format = high_bitdepth ? GPU_RGBA32F : GPU_RGBA16F;
+ }
+ else {
+ *r_texture_format = use_srgb ? GPU_SRGB8_A8 : GPU_RGBA8;
+ }
+}
+
+/* Return false if no suitable format was found. */
+#ifdef WITH_DDS
+static bool IMB_gpu_get_compressed_format(const ImBuf *ibuf, eGPUTextureFormat *r_texture_format)
+{
+ /* For DDS we only support data, scene linear and sRGB. Converting to
+ * different colorspace would break the compression. */
+ const bool use_srgb = (!IMB_colormanagement_space_is_data(ibuf->rect_colorspace) &&
+ !IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace));
+
+ if (ibuf->dds_data.fourcc == FOURCC_DXT1) {
+ *r_texture_format = (use_srgb) ? GPU_SRGB8_A8_DXT1 : GPU_RGBA8_DXT1;
+ }
+ else if (ibuf->dds_data.fourcc == FOURCC_DXT3) {
+ *r_texture_format = (use_srgb) ? GPU_SRGB8_A8_DXT3 : GPU_RGBA8_DXT3;
+ }
+ else if (ibuf->dds_data.fourcc == FOURCC_DXT5) {
+ *r_texture_format = (use_srgb) ? GPU_SRGB8_A8_DXT5 : GPU_RGBA8_DXT5;
+ }
+ else {
+ return false;
+ }
+ return true;
+}
+#endif
+
+/**
+ * Apply colormanagement and scale buffer if needed.
+ * *r_freedata is set to true if the returned buffer need to be manually freed.
+ **/
+static void *imb_gpu_get_data(const ImBuf *ibuf,
+ const bool do_rescale,
+ const int rescale_size[2],
+ const bool compress_as_srgb,
+ const bool store_premultiplied,
+ bool *r_freedata)
+{
+ const bool is_float_rect = (ibuf->rect_float != NULL);
+ void *data_rect = (is_float_rect) ? (void *)ibuf->rect_float : (void *)ibuf->rect;
+
+ if (is_float_rect) {
+ /* Float image is already in scene linear colorspace or non-color data by
+ * convention, no colorspace conversion needed. But we do require 4 channels
+ * currently. */
+ if (ibuf->channels != 4 || !store_premultiplied) {
+ data_rect = MEM_mallocN(sizeof(float[4]) * ibuf->x * ibuf->y, __func__);
+ *r_freedata = true;
+
+ if (data_rect == NULL) {
+ return NULL;
+ }
+
+ IMB_colormanagement_imbuf_to_float_texture(
+ (float *)data_rect, 0, 0, ibuf->x, ibuf->y, ibuf, store_premultiplied);
+ }
+ }
+ else {
+ /* Byte image is in original colorspace from the file. If the file is sRGB
+ * scene linear, or non-color data no conversion is needed. Otherwise we
+ * compress as scene linear + sRGB transfer function to avoid precision loss
+ * in common cases.
+ *
+ * We must also convert to premultiplied for correct texture interpolation
+ * and consistency with float images. */
+ if (!IMB_colormanagement_space_is_data(ibuf->rect_colorspace)) {
+ data_rect = MEM_mallocN(sizeof(uchar[4]) * ibuf->x * ibuf->y, __func__);
+ *r_freedata = true;
+
+ if (data_rect == NULL) {
+ return NULL;
+ }
+
+ /* Texture storage of images is defined by the alpha mode of the image. The
+ * downside of this is that there can be artifacts near alpha edges. However,
+ * this allows us to use sRGB texture formats and preserves color values in
+ * zero alpha areas, and appears generally closer to what game engines that we
+ * want to be compatible with do. */
+ IMB_colormanagement_imbuf_to_byte_texture(
+ (uchar *)data_rect, 0, 0, ibuf->x, ibuf->y, ibuf, compress_as_srgb, store_premultiplied);
+ }
+ }
+
+ if (do_rescale) {
+ uint *rect = (is_float_rect) ? NULL : (uint *)data_rect;
+ float *rect_float = (is_float_rect) ? (float *)data_rect : NULL;
+
+ ImBuf *scale_ibuf = IMB_allocFromBuffer(rect, rect_float, ibuf->x, ibuf->y, 4);
+ IMB_scaleImBuf(scale_ibuf, UNPACK2(rescale_size));
+
+ data_rect = (is_float_rect) ? (void *)scale_ibuf->rect_float : (void *)scale_ibuf->rect;
+ *r_freedata = true;
+ /* Steal the rescaled buffer to avoid double free. */
+ scale_ibuf->rect_float = NULL;
+ scale_ibuf->rect = NULL;
+ IMB_freeImBuf(scale_ibuf);
+ }
+ return data_rect;
+}
+
+/* The ibuf is only here to detect the storage type. The produced texture will have undefined
+ * content. It will need to be populated by using IMB_update_gpu_texture_sub(). */
+GPUTexture *IMB_touch_gpu_texture(ImBuf *ibuf, int w, int h, int layers, bool use_high_bitdepth)
+{
+ eGPUDataFormat data_format;
+ eGPUTextureFormat tex_format;
+ imb_gpu_get_format(ibuf, use_high_bitdepth, &data_format, &tex_format);
+
+ GPUTexture *tex = GPU_texture_create_nD(
+ w, h, layers, 2, NULL, tex_format, data_format, 0, false, NULL);
+
+ GPU_texture_anisotropic_filter(tex, true);
+ return tex;
+}
+
+/* Will update a GPUTexture using the content of the ImBuf. Only one layer will be updated.
+ * Will resize the ibuf if needed.
+ * z is the layer to update. Unused if the texture is 2D. */
+void IMB_update_gpu_texture_sub(GPUTexture *tex,
+ ImBuf *ibuf,
+ int x,
+ int y,
+ int z,
+ int w,
+ int h,
+ bool use_high_bitdepth,
+ bool use_premult)
+{
+ const bool do_rescale = (ibuf->x != w || ibuf->y != h);
+ const int size[2] = {w, h};
+
+ eGPUDataFormat data_format;
+ eGPUTextureFormat tex_format;
+ imb_gpu_get_format(ibuf, use_high_bitdepth, &data_format, &tex_format);
+
+ const bool compress_as_srgb = (tex_format == GPU_SRGB8_A8);
+ bool freebuf = false;
+
+ void *data = imb_gpu_get_data(ibuf, do_rescale, size, compress_as_srgb, use_premult, &freebuf);
+
+ /* Update Texture. */
+ GPU_texture_update_sub(tex, data_format, data, x, y, z, w, h, 1);
+
+ if (freebuf) {
+ MEM_freeN(data);
+ }
+}
+
+GPUTexture *IMB_create_gpu_texture(ImBuf *ibuf, bool use_high_bitdepth, bool use_premult)
+{
+ GPUTexture *tex = NULL;
+ const int size[2] = {GPU_texture_size_with_limit(ibuf->x), GPU_texture_size_with_limit(ibuf->y)};
+ bool do_rescale = (ibuf->x != size[0]) || (ibuf->y != size[1]);
+
+#ifdef WITH_DDS
+ if (ibuf->ftype == IMB_FTYPE_DDS) {
+ eGPUTextureFormat compressed_format;
+ if (!IMB_gpu_get_compressed_format(ibuf, &compressed_format)) {
+ fprintf(stderr, "Unable to find a suitable DXT compression,");
+ }
+ else if (do_rescale) {
+ fprintf(stderr, "Unable to load DXT image resolution,");
+ }
+ else if (!is_power_of_2_i(ibuf->x) || !is_power_of_2_i(ibuf->y)) {
+ fprintf(stderr, "Unable to load non-power-of-two DXT image resolution,");
+ }
+ else {
+ tex = GPU_texture_create_compressed(
+ ibuf->x, ibuf->y, ibuf->dds_data.nummipmaps, compressed_format, ibuf->dds_data.data);
+
+ if (tex != NULL) {
+ return tex;
+ }
+
+ fprintf(stderr, "ST3C support not found,");
+ }
+ /* Fallback to uncompressed texture. */
+ fprintf(stderr, " falling back to uncompressed.\n");
+ }
+#endif
+
+ eGPUDataFormat data_format;
+ eGPUTextureFormat tex_format;
+ imb_gpu_get_format(ibuf, use_high_bitdepth, &data_format, &tex_format);
+
+ const bool compress_as_srgb = (tex_format == GPU_SRGB8_A8);
+ bool freebuf = false;
+
+ void *data = imb_gpu_get_data(ibuf, do_rescale, size, compress_as_srgb, use_premult, &freebuf);
+
+ /* Create Texture. */
+ tex = GPU_texture_create_nD(UNPACK2(size), 0, 2, data, tex_format, data_format, 0, false, NULL);
+
+ GPU_texture_anisotropic_filter(tex, true);
+
+ if (freebuf) {
+ MEM_freeN(data);
+ }
+
+ return tex;
+}
diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c
index 9cb0436cb98..1d77233a7e2 100644
--- a/source/blender/imbuf/intern/writeimage.c
+++ b/source/blender/imbuf/intern/writeimage.c
@@ -50,7 +50,7 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags)
BLI_assert(!BLI_path_is_rel(name));
if (ibuf == NULL) {
- return (false);
+ return false;
}
ibuf->flags = flags;
diff --git a/source/blender/io/alembic/ABC_alembic.h b/source/blender/io/alembic/ABC_alembic.h
index ddf75aa3258..67f8aeb0a67 100644
--- a/source/blender/io/alembic/ABC_alembic.h
+++ b/source/blender/io/alembic/ABC_alembic.h
@@ -128,6 +128,16 @@ struct CacheReader *CacheReader_open_alembic_object(struct AbcArchiveHandle *han
struct Object *object,
const char *object_path);
+bool ABC_has_vec3_array_property_named(struct CacheReader *reader, const char *name);
+
+/* r_vertex_velocities should point to a preallocated array of num_vertices floats */
+int ABC_read_velocity_cache(struct CacheReader *reader,
+ const char *velocity_name,
+ float time,
+ float fps,
+ int num_vertices,
+ float *r_vertex_velocities);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/io/alembic/CMakeLists.txt b/source/blender/io/alembic/CMakeLists.txt
index 681d6d04acd..de99a2c9d65 100644
--- a/source/blender/io/alembic/CMakeLists.txt
+++ b/source/blender/io/alembic/CMakeLists.txt
@@ -110,3 +110,17 @@ list(APPEND LIB
)
blender_add_lib(bf_alembic "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+
+if(WITH_GTESTS)
+ set(TEST_SRC
+ tests/abc_export_test.cc
+ tests/abc_matrix_test.cc
+ )
+ set(TEST_INC
+ )
+ set(TEST_LIB
+ bf_alembic
+ )
+ include(GTestTesting)
+ blender_add_test_lib(bf_io_alembic_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
+endif()
diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc
index 98c551c635c..8c5f3d89870 100644
--- a/source/blender/io/alembic/exporter/abc_export_capi.cc
+++ b/source/blender/io/alembic/exporter/abc_export_capi.cc
@@ -48,6 +48,7 @@
static CLG_LogRef LOG = {"io.alembic"};
#include <algorithm>
+#include <memory>
struct ExportJobData {
Main *bmain;
@@ -103,17 +104,41 @@ static void export_startjob(void *customdata,
const bool export_animation = (data->params.frame_start != data->params.frame_end);
// Create the Alembic archive.
- ABCArchive abc_archive(data->bmain, scene, data->params, std::string(data->filename));
+ std::unique_ptr<ABCArchive> abc_archive;
+ try {
+ abc_archive = std::make_unique<ABCArchive>(
+ data->bmain, scene, data->params, std::string(data->filename));
+ }
+ catch (const std::exception &ex) {
+ std::stringstream error_message_stream;
+ error_message_stream << "Error writing to " << data->filename;
+ const std::string &error_message = error_message_stream.str();
+
+ // The exception message can be very cryptic (just "iostream error" on Linux, for example), so
+ // better not to include it in the report.
+ CLOG_ERROR(&LOG, "%s: %s", error_message.c_str(), ex.what());
+ WM_report(RPT_ERROR, error_message.c_str());
+ data->export_ok = false;
+ return;
+ }
+ catch (...) {
+ // Unknown exception class, so we cannot include its message.
+ std::stringstream error_message_stream;
+ error_message_stream << "Unknown error writing to " << data->filename;
+ WM_report(RPT_ERROR, error_message_stream.str().c_str());
+ data->export_ok = false;
+ return;
+ }
- ABCHierarchyIterator iter(data->depsgraph, &abc_archive, data->params);
+ ABCHierarchyIterator iter(data->depsgraph, abc_archive.get(), data->params);
if (export_animation) {
CLOG_INFO(&LOG, 2, "Exporting animation");
// Writing the animated frames is not 100% of the work, but it's our best guess.
- const float progress_per_frame = 1.0f / std::max(size_t(1), abc_archive.total_frame_count());
- ABCArchive::Frames::const_iterator frame_it = abc_archive.frames_begin();
- const ABCArchive::Frames::const_iterator frames_end = abc_archive.frames_end();
+ const float progress_per_frame = 1.0f / std::max(size_t(1), abc_archive->total_frame_count());
+ ABCArchive::Frames::const_iterator frame_it = abc_archive->frames_begin();
+ const ABCArchive::Frames::const_iterator frames_end = abc_archive->frames_end();
for (; frame_it != frames_end; frame_it++) {
double frame = *frame_it;
@@ -128,7 +153,7 @@ static void export_startjob(void *customdata,
BKE_scene_graph_update_for_newframe(data->depsgraph, data->bmain);
CLOG_INFO(&LOG, 2, "Exporting frame %.2f", frame);
- ExportSubset export_subset = abc_archive.export_subset_for_frame(frame);
+ ExportSubset export_subset = abc_archive->export_subset_for_frame(frame);
iter.set_export_subset(export_subset);
iter.iterate_and_write();
diff --git a/source/blender/io/alembic/intern/abc_axis_conversion.cc b/source/blender/io/alembic/intern/abc_axis_conversion.cc
index cebab1f2e41..396c8fdb28b 100644
--- a/source/blender/io/alembic/intern/abc_axis_conversion.cc
+++ b/source/blender/io/alembic/intern/abc_axis_conversion.cc
@@ -170,4 +170,4 @@ void create_transform_matrix(Object *obj,
} // namespace alembic
} // namespace io
-} // namespace blender \ No newline at end of file
+} // namespace blender
diff --git a/source/blender/io/alembic/intern/abc_axis_conversion.h b/source/blender/io/alembic/intern/abc_axis_conversion.h
index 9a19e9116be..645d9fc783b 100644
--- a/source/blender/io/alembic/intern/abc_axis_conversion.h
+++ b/source/blender/io/alembic/intern/abc_axis_conversion.h
@@ -100,4 +100,4 @@ void create_transform_matrix(Object *obj,
} // namespace alembic
} // namespace io
-} // namespace blender \ No newline at end of file
+} // namespace blender
diff --git a/source/blender/io/alembic/intern/abc_customdata.cc b/source/blender/io/alembic/intern/abc_customdata.cc
index f3e2342e844..408894a8de2 100644
--- a/source/blender/io/alembic/intern/abc_customdata.cc
+++ b/source/blender/io/alembic/intern/abc_customdata.cc
@@ -330,7 +330,7 @@ static void read_custom_data_mcols(const std::string &iobject_full_name,
if (IC3fGeomParam::matches(prop_header)) {
IC3fGeomParam color_param(arbGeomParams, prop_header.getName());
IC3fGeomParam::Sample sample;
- BLI_assert(!strcmp("rgb", color_param.getInterpretation()));
+ BLI_assert(STREQ("rgb", color_param.getInterpretation()));
color_param.getIndexed(sample, iss);
is_facevarying = sample.getScope() == kFacevaryingScope &&
@@ -343,7 +343,7 @@ static void read_custom_data_mcols(const std::string &iobject_full_name,
else if (IC4fGeomParam::matches(prop_header)) {
IC4fGeomParam color_param(arbGeomParams, prop_header.getName());
IC4fGeomParam::Sample sample;
- BLI_assert(!strcmp("rgba", color_param.getInterpretation()));
+ BLI_assert(STREQ("rgba", color_param.getInterpretation()));
color_param.getIndexed(sample, iss);
is_facevarying = sample.getScope() == kFacevaryingScope &&
diff --git a/source/blender/io/alembic/intern/abc_reader_archive.cc b/source/blender/io/alembic/intern/abc_reader_archive.cc
index d7f1095f0fd..776b8955d47 100644
--- a/source/blender/io/alembic/intern/abc_reader_archive.cc
+++ b/source/blender/io/alembic/intern/abc_reader_archive.cc
@@ -63,7 +63,7 @@ static IArchive open_archive(const std::string &filename,
else if (!the_file.read(header, sizeof(header))) {
std::cerr << "Unable to read from " << filename << std::endl;
}
- else if (strncmp(header + 1, "HDF", 3)) {
+ else if (strncmp(header + 1, "HDF", 3) != 0) {
std::cerr << filename << " has an unknown file format, unable to read." << std::endl;
}
else {
diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc
index 7cde2d4fe73..eba7f64db02 100644
--- a/source/blender/io/alembic/intern/alembic_capi.cc
+++ b/source/blender/io/alembic/intern/alembic_capi.cc
@@ -22,6 +22,7 @@
#include <Alembic/AbcMaterial/IMaterial.h>
+#include "abc_axis_conversion.h"
#include "abc_reader_archive.h"
#include "abc_reader_camera.h"
#include "abc_reader_curves.h"
@@ -47,18 +48,13 @@
#include "BKE_lib_id.h"
#include "BKE_object.h"
#include "BKE_scene.h"
+#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "ED_undo.h"
-/* SpaceType struct has a member called 'new' which obviously conflicts with C++
- * so temporarily redefining the new keyword to make it compile. */
-#define new extern_new
-#include "BKE_screen.h"
-#undef new
-
#include "BLI_compiler_compat.h"
#include "BLI_fileops.h"
#include "BLI_ghash.h"
@@ -70,7 +66,10 @@
#include "WM_api.h"
#include "WM_types.h"
+using Alembic::Abc::IV3fArrayProperty;
using Alembic::Abc::ObjectHeader;
+using Alembic::Abc::PropertyHeader;
+using Alembic::Abc::V3fArraySamplePtr;
using Alembic::AbcGeom::ICamera;
using Alembic::AbcGeom::ICurves;
using Alembic::AbcGeom::IFaceSet;
@@ -79,9 +78,11 @@ using Alembic::AbcGeom::INuPatch;
using Alembic::AbcGeom::IObject;
using Alembic::AbcGeom::IPoints;
using Alembic::AbcGeom::IPolyMesh;
+using Alembic::AbcGeom::IPolyMeshSchema;
using Alembic::AbcGeom::ISampleSelector;
using Alembic::AbcGeom::ISubD;
using Alembic::AbcGeom::IXform;
+using Alembic::AbcGeom::kWrapExisting;
using Alembic::AbcGeom::MetaData;
using Alembic::AbcMaterial::IMaterial;
@@ -859,3 +860,136 @@ CacheReader *CacheReader_open_alembic_object(AbcArchiveHandle *handle,
return reinterpret_cast<CacheReader *>(abc_reader);
}
+
+/* ************************************************************************** */
+
+static const PropertyHeader *get_property_header(const IPolyMeshSchema &schema, const char *name)
+{
+ const PropertyHeader *prop_header = schema.getPropertyHeader(name);
+
+ if (prop_header) {
+ return prop_header;
+ }
+
+ ICompoundProperty prop = schema.getArbGeomParams();
+
+ if (!has_property(prop, name)) {
+ return nullptr;
+ }
+
+ return prop.getPropertyHeader(name);
+}
+
+bool ABC_has_vec3_array_property_named(struct CacheReader *reader, const char *name)
+{
+ AbcObjectReader *abc_reader = reinterpret_cast<AbcObjectReader *>(reader);
+
+ if (!abc_reader) {
+ return false;
+ }
+
+ IObject iobject = abc_reader->iobject();
+
+ if (!iobject.valid()) {
+ return false;
+ }
+
+ const ObjectHeader &header = iobject.getHeader();
+
+ if (!IPolyMesh::matches(header)) {
+ return false;
+ }
+
+ IPolyMesh mesh(iobject, kWrapExisting);
+ IPolyMeshSchema schema = mesh.getSchema();
+
+ const PropertyHeader *prop_header = get_property_header(schema, name);
+
+ if (!prop_header) {
+ return false;
+ }
+
+ return IV3fArrayProperty::matches(prop_header->getMetaData());
+}
+
+static V3fArraySamplePtr get_velocity_prop(const IPolyMeshSchema &schema,
+ const ISampleSelector &iss,
+ const std::string &name)
+{
+ const PropertyHeader *prop_header = schema.getPropertyHeader(name);
+
+ if (prop_header) {
+ const IV3fArrayProperty &velocity_prop = IV3fArrayProperty(schema, name, 0);
+ return velocity_prop.getValue(iss);
+ }
+
+ ICompoundProperty prop = schema.getArbGeomParams();
+
+ if (!has_property(prop, name)) {
+ return V3fArraySamplePtr();
+ }
+
+ const IV3fArrayProperty &velocity_prop = IV3fArrayProperty(prop, name, 0);
+
+ if (velocity_prop) {
+ return velocity_prop.getValue(iss);
+ }
+
+ return V3fArraySamplePtr();
+}
+
+int ABC_read_velocity_cache(CacheReader *reader,
+ const char *velocity_name,
+ const float time,
+ float velocity_scale,
+ int num_vertices,
+ float *r_vertex_velocities)
+{
+ AbcObjectReader *abc_reader = reinterpret_cast<AbcObjectReader *>(reader);
+
+ if (!abc_reader) {
+ return -1;
+ }
+
+ IObject iobject = abc_reader->iobject();
+
+ if (!iobject.valid()) {
+ return -1;
+ }
+
+ const ObjectHeader &header = iobject.getHeader();
+
+ if (!IPolyMesh::matches(header)) {
+ return -1;
+ }
+
+ IPolyMesh mesh(iobject, kWrapExisting);
+ IPolyMeshSchema schema = mesh.getSchema();
+ ISampleSelector sample_sel(time);
+ const IPolyMeshSchema::Sample sample = schema.getValue(sample_sel);
+
+ V3fArraySamplePtr velocities = get_velocity_prop(schema, sample_sel, velocity_name);
+
+ if (!velocities) {
+ return -1;
+ }
+
+ float vel[3];
+
+ int num_velocity_vectors = static_cast<int>(velocities->size());
+
+ if (num_velocity_vectors != num_vertices) {
+ return -1;
+ }
+
+ for (size_t i = 0; i < velocities->size(); ++i) {
+ const Imath::V3f &vel_in = (*velocities)[i];
+ copy_zup_from_yup(vel, vel_in.getValue());
+
+ mul_v3_fl(vel, velocity_scale);
+
+ copy_v3_v3(r_vertex_velocities + i * 3, vel);
+ }
+
+ return num_vertices;
+}
diff --git a/tests/gtests/alembic/abc_export_test.cc b/source/blender/io/alembic/tests/abc_export_test.cc
index 5c2b505958e..5c2b505958e 100644
--- a/tests/gtests/alembic/abc_export_test.cc
+++ b/source/blender/io/alembic/tests/abc_export_test.cc
diff --git a/tests/gtests/alembic/abc_matrix_test.cc b/source/blender/io/alembic/tests/abc_matrix_test.cc
index b58e989b1a1..b58e989b1a1 100644
--- a/tests/gtests/alembic/abc_matrix_test.cc
+++ b/source/blender/io/alembic/tests/abc_matrix_test.cc
diff --git a/source/blender/io/avi/AVI_avi.h b/source/blender/io/avi/AVI_avi.h
index 4f3aa720da3..ba1ef9261a0 100644
--- a/source/blender/io/avi/AVI_avi.h
+++ b/source/blender/io/avi/AVI_avi.h
@@ -39,8 +39,7 @@
* code. So we keep it like this.
*/
-#ifndef __AVI_AVI_H__
-#define __AVI_AVI_H__
+#pragma once
#include "BLI_sys_types.h"
#include <stdio.h> /* for FILE */
@@ -295,5 +294,3 @@ AviError AVI_write_frame(AviMovie *movie, int frame_num, ...);
* Unused but still external
*/
AviError AVI_print_error(AviError error);
-
-#endif /* __AVI_AVI_H__ */
diff --git a/source/blender/io/avi/intern/avi.c b/source/blender/io/avi/intern/avi.c
index e829a15deba..0ab51b7a084 100644
--- a/source/blender/io/avi/intern/avi.c
+++ b/source/blender/io/avi/intern/avi.c
@@ -116,9 +116,8 @@ int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num)
if (stream_num == 0) {
return cur_stream;
}
- else {
- stream_num--;
- }
+
+ stream_num--;
}
}
@@ -572,9 +571,8 @@ AviError AVI_open_movie(const char *name, AviMovie *movie)
if (GET_FCC(movie->fp) == FCC("movi")) {
break;
}
- else {
- BLI_fseek(movie->fp, size - 4, SEEK_CUR);
- }
+
+ BLI_fseek(movie->fp, size - 4, SEEK_CUR);
}
else {
BLI_fseek(movie->fp, size, SEEK_CUR);
diff --git a/source/blender/io/avi/intern/avi_endian.h b/source/blender/io/avi/intern/avi_endian.h
index d1253f488e7..88c13d17950 100644
--- a/source/blender/io/avi/intern/avi_endian.h
+++ b/source/blender/io/avi/intern/avi_endian.h
@@ -23,8 +23,7 @@
* This is external code.
*/
-#ifndef __AVI_ENDIAN_H__
-#define __AVI_ENDIAN_H__
+#pragma once
#define AVI_RAW 0
#define AVI_CHUNK 1
@@ -36,5 +35,3 @@
#define AVI_MJPEGU 7
void awrite(AviMovie *movie, void *datain, int block, int size, FILE *fp, int type);
-
-#endif /* __AVI_ENDIAN_H__ */
diff --git a/source/blender/io/avi/intern/avi_intern.h b/source/blender/io/avi/intern/avi_intern.h
index 6ce91ce7f70..28ab999f6e3 100644
--- a/source/blender/io/avi/intern/avi_intern.h
+++ b/source/blender/io/avi/intern/avi_intern.h
@@ -21,8 +21,7 @@
* \ingroup avi
*/
-#ifndef __AVI_INTERN_H__
-#define __AVI_INTERN_H__
+#pragma once
#include <stdio.h> /* for FILE */
@@ -61,5 +60,3 @@ int avi_get_data_id(AviFormat format, int stream);
int avi_get_format_type(AviFormat format);
int avi_get_format_fcc(AviFormat format);
int avi_get_format_compression(AviFormat format);
-
-#endif
diff --git a/source/blender/io/avi/intern/avi_mjpeg.h b/source/blender/io/avi/intern/avi_mjpeg.h
index 13153fa41f0..3ee1b611f70 100644
--- a/source/blender/io/avi/intern/avi_mjpeg.h
+++ b/source/blender/io/avi/intern/avi_mjpeg.h
@@ -21,13 +21,10 @@
* \ingroup avi
*/
-#ifndef __AVI_MJPEG_H__
-#define __AVI_MJPEG_H__
+#pragma once
void *avi_converter_from_mjpeg(AviMovie *movie,
int stream,
unsigned char *buffer,
const size_t *size);
void *avi_converter_to_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, size_t *size);
-
-#endif /* __AVI_MJPEG_H__ */
diff --git a/source/blender/io/avi/intern/avi_rgb.c b/source/blender/io/avi/intern/avi_rgb.c
index 44542af96ae..8af728f0737 100644
--- a/source/blender/io/avi/intern/avi_rgb.c
+++ b/source/blender/io/avi/intern/avi_rgb.c
@@ -96,35 +96,34 @@ void *avi_converter_from_avi_rgb(AviMovie *movie,
return buf;
}
- else {
- buf = imb_alloc_pixels(
- movie->header->Height, movie->header->Width, 3, sizeof(unsigned char), "fromavirgbbuf");
-
- if (buf) {
- size_t rowstride = movie->header->Width * 3;
- BLI_assert(bits != 16);
- if (movie->header->Width % 2) {
- rowstride++;
- }
- for (size_t y = 0; y < movie->header->Height; y++) {
- memcpy(&buf[y * movie->header->Width * 3],
- &buffer[((movie->header->Height - 1) - y) * rowstride],
- movie->header->Width * 3);
- }
+ buf = imb_alloc_pixels(
+ movie->header->Height, movie->header->Width, 3, sizeof(unsigned char), "fromavirgbbuf");
- for (size_t y = 0; y < (size_t)movie->header->Height * (size_t)movie->header->Width * 3;
- y += 3) {
- int i = buf[y];
- buf[y] = buf[y + 2];
- buf[y + 2] = i;
- }
+ if (buf) {
+ size_t rowstride = movie->header->Width * 3;
+ BLI_assert(bits != 16);
+ if (movie->header->Width % 2) {
+ rowstride++;
}
- MEM_freeN(buffer);
+ for (size_t y = 0; y < movie->header->Height; y++) {
+ memcpy(&buf[y * movie->header->Width * 3],
+ &buffer[((movie->header->Height - 1) - y) * rowstride],
+ movie->header->Width * 3);
+ }
- return buf;
+ for (size_t y = 0; y < (size_t)movie->header->Height * (size_t)movie->header->Width * 3;
+ y += 3) {
+ int i = buf[y];
+ buf[y] = buf[y + 2];
+ buf[y + 2] = i;
+ }
}
+
+ MEM_freeN(buffer);
+
+ return buf;
}
void *avi_converter_to_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, size_t *size)
diff --git a/source/blender/io/avi/intern/avi_rgb.h b/source/blender/io/avi/intern/avi_rgb.h
index 3a37fad94e1..aac8a2dffbf 100644
--- a/source/blender/io/avi/intern/avi_rgb.h
+++ b/source/blender/io/avi/intern/avi_rgb.h
@@ -21,13 +21,10 @@
* \ingroup avi
*/
-#ifndef __AVI_RGB_H__
-#define __AVI_RGB_H__
+#pragma once
void *avi_converter_from_avi_rgb(AviMovie *movie,
int stream,
unsigned char *buffer,
const size_t *size);
void *avi_converter_to_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, size_t *size);
-
-#endif /* __AVI_RGB_H__ */
diff --git a/source/blender/io/avi/intern/avi_rgb32.h b/source/blender/io/avi/intern/avi_rgb32.h
index eb4b9ca4e21..675b1ced41e 100644
--- a/source/blender/io/avi/intern/avi_rgb32.h
+++ b/source/blender/io/avi/intern/avi_rgb32.h
@@ -21,10 +21,7 @@
* \ingroup avi
*/
-#ifndef __AVI_RGB32_H__
-#define __AVI_RGB32_H__
+#pragma once
void *avi_converter_from_rgb32(AviMovie *movie, int stream, unsigned char *buffer, size_t *size);
void *avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer, size_t *size);
-
-#endif /* __AVI_RGB32_H__ */
diff --git a/source/blender/io/collada/AnimationClipExporter.h b/source/blender/io/collada/AnimationClipExporter.h
index 9d782eac094..a19fcb4d372 100644
--- a/source/blender/io/collada/AnimationClipExporter.h
+++ b/source/blender/io/collada/AnimationClipExporter.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __ANIMATIONCLIPEXPORTER_H__
-#define __ANIMATIONCLIPEXPORTER_H__
+#pragma once
#include <math.h>
#include <stdio.h>
@@ -49,5 +48,3 @@ class AnimationClipExporter : COLLADASW::LibraryAnimationClips {
void exportAnimationClips(Scene *sce);
};
-
-#endif /* __ANIMATIONCLIPEXPORTER_H__ */
diff --git a/source/blender/io/collada/AnimationExporter.cpp b/source/blender/io/collada/AnimationExporter.cpp
index c25b4ea543b..a4302a680a3 100644
--- a/source/blender/io/collada/AnimationExporter.cpp
+++ b/source/blender/io/collada/AnimationExporter.cpp
@@ -230,7 +230,7 @@ void AnimationExporter::export_matrix_animation(Object *ob, BCAnimationSampler &
std::string name = encode_xml(id_name(ob));
std::string action_name = (action == NULL) ? name + "-action" : id_name(action);
std::string channel_type = "transform";
- std::string axis = "";
+ std::string axis;
std::string id = bc_get_action_id(action_name, name, channel_type, axis);
std::string target = translate_id(name) + '/' + channel_type;
@@ -395,15 +395,15 @@ bool AnimationExporter::is_bone_deform_group(Bone *bone)
return true;
}
/* Check child bones */
- else {
- for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
- /* loop through all the children until deform bone is found, and then return */
- is_def = is_bone_deform_group(child);
- if (is_def) {
- return true;
- }
+
+ for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
+ /* loop through all the children until deform bone is found, and then return */
+ is_def = is_bone_deform_group(child);
+ if (is_def) {
+ return true;
}
}
+
/* no deform bone found in children also */
return false;
}
@@ -840,12 +840,11 @@ std::string AnimationExporter::get_collada_sid(const BCAnimationCurve &curve,
if (is_angle) {
return tm_name + std::string(axis_name) + ".ANGLE";
}
- else if (!axis_name.empty()) {
+ if (!axis_name.empty()) {
return tm_name + "." + std::string(axis_name);
}
- else {
- return tm_name;
- }
+
+ return tm_name;
}
return tm_name;
diff --git a/source/blender/io/collada/AnimationExporter.h b/source/blender/io/collada/AnimationExporter.h
index b4564eb7b2d..48279b0c867 100644
--- a/source/blender/io/collada/AnimationExporter.h
+++ b/source/blender/io/collada/AnimationExporter.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __ANIMATIONEXPORTER_H__
-#define __ANIMATIONEXPORTER_H__
+#pragma once
#include <math.h>
#include <stdio.h>
@@ -258,5 +257,3 @@ class AnimationExporter : COLLADASW::LibraryAnimations {
void export_morph_animation(Object *ob, BCAnimationSampler &sampler);
#endif
};
-
-#endif /* __ANIMATIONEXPORTER_H__ */
diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp
index b53aa95a11f..1dada68293e 100644
--- a/source/blender/io/collada/AnimationImporter.cpp
+++ b/source/blender/io/collada/AnimationImporter.cpp
@@ -717,37 +717,36 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi
if (animlist_map.find(listid) == animlist_map.end()) {
return;
}
- else {
- /* anim_type has animations */
- const COLLADAFW::AnimationList *animlist = animlist_map[listid];
- const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
- /* all the curves belonging to the current binding */
- std::vector<FCurve *> animcurves;
- for (unsigned int j = 0; j < bindings.getCount(); j++) {
- animcurves = curve_map[bindings[j].animation];
-
- BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
- modify_fcurve(&animcurves, rna_path, 0);
- std::vector<FCurve *>::iterator iter;
- /* Add the curves of the current animation to the object */
- for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
- FCurve *fcu = *iter;
- /* All anim_types whose values are to be converted from Degree to Radians can be ORed here
+
+ /* anim_type has animations */
+ const COLLADAFW::AnimationList *animlist = animlist_map[listid];
+ const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
+ /* all the curves belonging to the current binding */
+ std::vector<FCurve *> animcurves;
+ for (unsigned int j = 0; j < bindings.getCount(); j++) {
+ animcurves = curve_map[bindings[j].animation];
+
+ BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
+ modify_fcurve(&animcurves, rna_path, 0);
+ std::vector<FCurve *>::iterator iter;
+ /* Add the curves of the current animation to the object */
+ for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
+ FCurve *fcu = *iter;
+ /* All anim_types whose values are to be converted from Degree to Radians can be ORed here
+ */
+ if (STREQ("spot_size", anim_type)) {
+ /* NOTE: Do NOT convert if imported file was made by blender <= 2.69.10
+ * Reason: old blender versions stored spot_size in radians (was a bug)
*/
- if (STREQ("spot_size", anim_type)) {
- /* NOTE: Do NOT convert if imported file was made by blender <= 2.69.10
- * Reason: old blender versions stored spot_size in radians (was a bug)
- */
- if (this->import_from_version.empty() ||
- BLI_strcasecmp_natural(this->import_from_version.c_str(), "2.69.10") != -1) {
- fcurve_deg_to_rad(fcu);
- }
+ if (this->import_from_version.empty() ||
+ BLI_strcasecmp_natural(this->import_from_version.c_str(), "2.69.10") != -1) {
+ fcurve_deg_to_rad(fcu);
}
- /** XXX What About animtype "rotation" ? */
-
- BLI_addtail(AnimCurves, fcu);
- fcurve_is_used(fcu);
}
+ /** XXX What About animtype "rotation" ? */
+
+ BLI_addtail(AnimCurves, fcu);
+ fcurve_is_used(fcu);
}
}
}
@@ -780,35 +779,34 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId &listid
if (animlist_map.find(listid) == animlist_map.end()) {
return;
}
- else {
- /* anim_type has animations */
- const COLLADAFW::AnimationList *animlist = animlist_map[listid];
- const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
- /* all the curves belonging to the current binding */
- std::vector<FCurve *> animcurves;
- for (unsigned int j = 0; j < bindings.getCount(); j++) {
- animcurves = curve_map[bindings[j].animation];
- BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
+ /* anim_type has animations */
+ const COLLADAFW::AnimationList *animlist = animlist_map[listid];
+ const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
+ /* all the curves belonging to the current binding */
+ std::vector<FCurve *> animcurves;
+ for (unsigned int j = 0; j < bindings.getCount(); j++) {
+ animcurves = curve_map[bindings[j].animation];
- modify_fcurve(&animcurves, rna_path, 0);
- std::vector<FCurve *>::iterator iter;
- /* Add the curves of the current animation to the object */
- for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
- FCurve *fcu = *iter;
+ BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
- for (unsigned int i = 0; i < fcu->totvert; i++) {
- fcu->bezt[i].vec[0][1] = convert_to_focal_length(
- fcu->bezt[i].vec[0][1], fov_type, aspect, cam->sensor_x);
- fcu->bezt[i].vec[1][1] = convert_to_focal_length(
- fcu->bezt[i].vec[1][1], fov_type, aspect, cam->sensor_x);
- fcu->bezt[i].vec[2][1] = convert_to_focal_length(
- fcu->bezt[i].vec[2][1], fov_type, aspect, cam->sensor_x);
- }
+ modify_fcurve(&animcurves, rna_path, 0);
+ std::vector<FCurve *>::iterator iter;
+ /* Add the curves of the current animation to the object */
+ for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
+ FCurve *fcu = *iter;
- BLI_addtail(AnimCurves, fcu);
- fcurve_is_used(fcu);
+ for (unsigned int i = 0; i < fcu->totvert; i++) {
+ fcu->bezt[i].vec[0][1] = convert_to_focal_length(
+ fcu->bezt[i].vec[0][1], fov_type, aspect, cam->sensor_x);
+ fcu->bezt[i].vec[1][1] = convert_to_focal_length(
+ fcu->bezt[i].vec[1][1], fov_type, aspect, cam->sensor_x);
+ fcu->bezt[i].vec[2][1] = convert_to_focal_length(
+ fcu->bezt[i].vec[2][1], fov_type, aspect, cam->sensor_x);
}
+
+ BLI_addtail(AnimCurves, fcu);
+ fcurve_is_used(fcu);
}
}
}
@@ -1077,35 +1075,34 @@ void AnimationImporter::translate_Animations(
if (animlist_map.find(listid) == animlist_map.end()) {
continue;
}
- else {
- /* transformation has animations */
- const COLLADAFW::AnimationList *animlist = animlist_map[listid];
- const COLLADAFW::AnimationList::AnimationBindings &bindings =
- animlist->getAnimationBindings();
- /* all the curves belonging to the current binding */
- std::vector<FCurve *> animcurves;
- for (unsigned int j = 0; j < bindings.getCount(); j++) {
- animcurves = curve_map[bindings[j].animation];
- if (is_matrix) {
- apply_matrix_curves(ob, animcurves, root, node, transform);
- }
- else {
- /* calculate rnapaths and array index of fcurves according to transformation and
- * animation class */
- Assign_transform_animations(
- transform, &bindings[j], &animcurves, is_joint, joint_path);
-
- std::vector<FCurve *>::iterator iter;
- /* Add the curves of the current animation to the object */
- for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
- FCurve *fcu = *iter;
-
- BLI_addtail(AnimCurves, fcu);
- fcurve_is_used(fcu);
- }
+
+ /* transformation has animations */
+ const COLLADAFW::AnimationList *animlist = animlist_map[listid];
+ const COLLADAFW::AnimationList::AnimationBindings &bindings =
+ animlist->getAnimationBindings();
+ /* all the curves belonging to the current binding */
+ std::vector<FCurve *> animcurves;
+ for (unsigned int j = 0; j < bindings.getCount(); j++) {
+ animcurves = curve_map[bindings[j].animation];
+ if (is_matrix) {
+ apply_matrix_curves(ob, animcurves, root, node, transform);
+ }
+ else {
+ /* calculate rnapaths and array index of fcurves according to transformation and
+ * animation class */
+ Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path);
+
+ std::vector<FCurve *>::iterator iter;
+ /* Add the curves of the current animation to the object */
+ for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
+ FCurve *fcu = *iter;
+
+ BLI_addtail(AnimCurves, fcu);
+ fcurve_is_used(fcu);
}
}
}
+
if (is_rotation && !(is_joint || is_matrix)) {
ob->rotmode = ROT_MODE_EUL;
}
@@ -1423,10 +1420,9 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
if (animlist_map.find(listid) == animlist_map.end()) {
continue;
}
- else {
- types->transform = types->transform | BC_NODE_TRANSFORM;
- break;
- }
+
+ types->transform = types->transform | BC_NODE_TRANSFORM;
+ break;
}
const COLLADAFW::InstanceLightPointerArray &nodeLights = node->getInstanceLights();
@@ -1995,7 +1991,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
return true;
}
- else if (is_scale || is_translate) {
+ if (is_scale || is_translate) {
bool is_xyz = animclass == COLLADAFW::AnimationList::POSITION_XYZ;
if ((!is_xyz && curves.size() != 1) || (is_xyz && curves.size() != 3)) {
diff --git a/source/blender/io/collada/AnimationImporter.h b/source/blender/io/collada/AnimationImporter.h
index 51041c6ee3e..5c6f9400286 100644
--- a/source/blender/io/collada/AnimationImporter.h
+++ b/source/blender/io/collada/AnimationImporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __ANIMATIONIMPORTER_H__
-#define __ANIMATIONIMPORTER_H__
+#pragma once
#include <map>
#include <vector>
@@ -250,5 +249,3 @@ class AnimationImporter : private TransformReader, public AnimationImporterBase
void extra_data_importer(std::string elementName);
};
-
-#endif
diff --git a/source/blender/io/collada/ArmatureExporter.h b/source/blender/io/collada/ArmatureExporter.h
index 3bc9dfe2639..193dc9cde3a 100644
--- a/source/blender/io/collada/ArmatureExporter.h
+++ b/source/blender/io/collada/ArmatureExporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __ARMATUREEXPORTER_H__
-#define __ARMATUREEXPORTER_H__
+#pragma once
#include <list>
#include <string>
@@ -103,5 +102,3 @@ class ArmatureExporter : public COLLADASW::LibraryControllers,
void write_bone_URLs(COLLADASW::InstanceController &ins, Object *ob_arm, Bone *bone);
};
-
-#endif
diff --git a/source/blender/io/collada/ArmatureImporter.h b/source/blender/io/collada/ArmatureImporter.h
index 7393b882f4b..a1c4a25b80f 100644
--- a/source/blender/io/collada/ArmatureImporter.h
+++ b/source/blender/io/collada/ArmatureImporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __ARMATUREIMPORTER_H__
-#define __ARMATUREIMPORTER_H__
+#pragma once
#include "COLLADAFWMorphController.h"
#include "COLLADAFWNode.h"
@@ -181,5 +180,3 @@ class ArmatureImporter : private TransformReader {
void set_tags_map(TagsMap &tags_map);
};
-
-#endif
diff --git a/source/blender/io/collada/BCAnimationCurve.cpp b/source/blender/io/collada/BCAnimationCurve.cpp
index 61dded368b5..5fdbb65fb6e 100644
--- a/source/blender/io/collada/BCAnimationCurve.cpp
+++ b/source/blender/io/collada/BCAnimationCurve.cpp
@@ -559,9 +559,8 @@ inline bool operator<(const BCAnimationCurve &lhs, const BCAnimationCurve &rhs)
const int rha = rhs.get_channel_index();
return lha < rha;
}
- else {
- return lhtgt < rhtgt;
- }
+
+ return lhtgt < rhtgt;
}
BCCurveKey::BCCurveKey()
diff --git a/source/blender/io/collada/BCAnimationCurve.h b/source/blender/io/collada/BCAnimationCurve.h
index e0216ee6849..779678bca1d 100644
--- a/source/blender/io/collada/BCAnimationCurve.h
+++ b/source/blender/io/collada/BCAnimationCurve.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BCANIMATIONCURVE_H__
-#define __BCANIMATIONCURVE_H__
+#pragma once
#include "BCSampleData.h"
#include "collada_utils.h"
@@ -147,5 +146,3 @@ class BCAnimationCurve {
};
typedef std::map<BCCurveKey, BCAnimationCurve *> BCAnimationCurveMap;
-
-#endif /* __BCANIMATIONCURVE_H__ */
diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp
index f44e3e8385d..6f363aa76c2 100644
--- a/source/blender/io/collada/BCAnimationSampler.cpp
+++ b/source/blender/io/collada/BCAnimationSampler.cpp
@@ -558,7 +558,7 @@ const bool BCSampleFrame::has_sample_for(Object *ob) const
const bool BCSampleFrame::has_sample_for(Object *ob, Bone *bone) const
{
const BCMatrix *bc_bone = get_sample_matrix(ob, bone);
- return (bc_bone);
+ return bc_bone;
}
/* ==================================================================== */
diff --git a/source/blender/io/collada/BCAnimationSampler.h b/source/blender/io/collada/BCAnimationSampler.h
index 3273ac8e0a0..5ab4be3722c 100644
--- a/source/blender/io/collada/BCAnimationSampler.h
+++ b/source/blender/io/collada/BCAnimationSampler.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BCANIMATIONSAMPLER_H__
-#define __BCANIMATIONSAMPLER_H__
+#pragma once
#include "BCAnimationCurve.h"
#include "BCSampleData.h"
@@ -190,5 +189,3 @@ class BCAnimationSampler {
ListBase *conlist,
std::set<Object *> &animated_objects);
};
-
-#endif /* __BCANIMATIONSAMPLER_H__ */
diff --git a/source/blender/io/collada/BCMath.h b/source/blender/io/collada/BCMath.h
index 38158751740..79a0ea941cd 100644
--- a/source/blender/io/collada/BCMath.h
+++ b/source/blender/io/collada/BCMath.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __BCMATH_H__
-#define __BCMATH_H__
+#pragma once
#include "BlenderTypes.h"
@@ -105,5 +104,3 @@ class BCMatrix {
static void sanitize(DMatrix &matrix, int precision);
static void transpose(Matrix &matrix);
};
-
-#endif /* __BCMATH_H__ */
diff --git a/source/blender/io/collada/BCSampleData.h b/source/blender/io/collada/BCSampleData.h
index 6f3ca9135b3..39e34355b72 100644
--- a/source/blender/io/collada/BCSampleData.h
+++ b/source/blender/io/collada/BCSampleData.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __BCSAMPLEDATA_H__
-#define __BCSAMPLEDATA_H__
+#pragma once
#include <algorithm>
#include <map>
@@ -62,5 +61,3 @@ class BCSample {
typedef std::map<Object *, BCSample *> BCSampleMap;
typedef std::map<int, const BCSample *> BCFrameSampleMap;
typedef std::map<int, const BCMatrix *> BCMatrixSampleMap;
-
-#endif /* __BCSAMPLEDATA_H__ */
diff --git a/source/blender/io/collada/BlenderContext.h b/source/blender/io/collada/BlenderContext.h
index bf6fde134fa..9163b30c86f 100644
--- a/source/blender/io/collada/BlenderContext.h
+++ b/source/blender/io/collada/BlenderContext.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __BLENDERCONTEXT_H__
-#define __BLENDERCONTEXT_H__
+#pragma once
#include "BKE_context.h"
#include "BKE_main.h"
@@ -68,5 +67,3 @@ class BlenderContext {
Main *get_main();
};
#endif
-
-#endif
diff --git a/source/blender/io/collada/BlenderTypes.h b/source/blender/io/collada/BlenderTypes.h
index 0e024be2374..63b0471ef6f 100644
--- a/source/blender/io/collada/BlenderTypes.h
+++ b/source/blender/io/collada/BlenderTypes.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __BLENDERTYPES_H__
-#define __BLENDERTYPES_H__
+#pragma once
typedef float(Vector)[3];
typedef float(Quat)[4];
@@ -44,5 +43,3 @@ typedef enum BC_global_up_axis {
BC_GLOBAL_UP_MINUS_Y = 4,
BC_GLOBAL_UP_MINUS_Z = 5
} BC_global_up_axis;
-
-#endif
diff --git a/source/blender/io/collada/CameraExporter.h b/source/blender/io/collada/CameraExporter.h
index 0dda6392d03..cc4f7aee165 100644
--- a/source/blender/io/collada/CameraExporter.h
+++ b/source/blender/io/collada/CameraExporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __CAMERAEXPORTER_H__
-#define __CAMERAEXPORTER_H__
+#pragma once
#include "COLLADASWLibraryCameras.h"
#include "COLLADASWStreamWriter.h"
@@ -40,5 +39,3 @@ class CamerasExporter : COLLADASW::LibraryCameras {
bool exportBlenderProfile(COLLADASW::Camera &cla, Camera *cam);
BCExportSettings &export_settings;
};
-
-#endif
diff --git a/source/blender/io/collada/ControllerExporter.h b/source/blender/io/collada/ControllerExporter.h
index fb84af6ebc9..753538d8e98 100644
--- a/source/blender/io/collada/ControllerExporter.h
+++ b/source/blender/io/collada/ControllerExporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __CONTROLLEREXPORTER_H__
-#define __CONTROLLEREXPORTER_H__
+#pragma once
#include <list>
#include <string>
@@ -133,5 +132,3 @@ class ControllerExporter : public COLLADASW::LibraryControllers,
void write_bone_URLs(COLLADASW::InstanceController &ins, Object *ob_arm, Bone *bone);
};
-
-#endif
diff --git a/source/blender/io/collada/DocumentExporter.h b/source/blender/io/collada/DocumentExporter.h
index 1fe52420534..850eb4fbbb2 100644
--- a/source/blender/io/collada/DocumentExporter.h
+++ b/source/blender/io/collada/DocumentExporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __DOCUMENTEXPORTER_H__
-#define __DOCUMENTEXPORTER_H__
+#pragma once
#include "BlenderContext.h"
#include "collada.h"
@@ -38,5 +37,3 @@ class DocumentExporter {
BCExportSettings export_settings;
KeyImageMap key_image_map;
};
-
-#endif
diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp
index 0f84db79c28..83c8a805076 100644
--- a/source/blender/io/collada/DocumentImporter.cpp
+++ b/source/blender/io/collada/DocumentImporter.cpp
@@ -1254,9 +1254,6 @@ bool DocumentImporter::is_armature(COLLADAFW::Node *node)
if (child_nodes[i]->getType() == COLLADAFW::Node::JOINT) {
return true;
}
- else {
- continue;
- }
}
/* no child is JOINT */
diff --git a/source/blender/io/collada/DocumentImporter.h b/source/blender/io/collada/DocumentImporter.h
index d9be4880b35..e382a44c3c2 100644
--- a/source/blender/io/collada/DocumentImporter.h
+++ b/source/blender/io/collada/DocumentImporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __DOCUMENTIMPORTER_H__
-#define __DOCUMENTIMPORTER_H__
+#pragma once
#include "COLLADAFWColor.h"
#include "COLLADAFWController.h"
@@ -168,5 +167,3 @@ class DocumentImporter : COLLADAFW::IWriter {
void report_unknown_reference(const COLLADAFW::Node &node, const std::string object_type);
};
-
-#endif
diff --git a/source/blender/io/collada/EffectExporter.h b/source/blender/io/collada/EffectExporter.h
index 36d02bb1c8f..c844d93b040 100644
--- a/source/blender/io/collada/EffectExporter.h
+++ b/source/blender/io/collada/EffectExporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __EFFECTEXPORTER_H__
-#define __EFFECTEXPORTER_H__
+#pragma once
#include <string>
#include <vector>
@@ -85,5 +84,3 @@ class EffectsExporter : COLLADASW::LibraryEffects {
Scene *scene;
bContext *mContext;
};
-
-#endif
diff --git a/source/blender/io/collada/ErrorHandler.h b/source/blender/io/collada/ErrorHandler.h
index 0c082a3b9dd..60253a08cda 100644
--- a/source/blender/io/collada/ErrorHandler.h
+++ b/source/blender/io/collada/ErrorHandler.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __ERRORHANDLER_H__
-#define __ERRORHANDLER_H__
+#pragma once
#include <algorithm> // sort()
#include <map>
@@ -53,5 +52,3 @@ class ErrorHandler : public COLLADASaxFWL::IErrorHandler {
/** Hold error status. */
bool mError;
};
-
-#endif /* __ERRORHANDLER_H__ */
diff --git a/source/blender/io/collada/ExportSettings.h b/source/blender/io/collada/ExportSettings.h
index 477f0b8b678..2f647cefa8b 100644
--- a/source/blender/io/collada/ExportSettings.h
+++ b/source/blender/io/collada/ExportSettings.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __EXPORTSETTINGS_H__
-#define __EXPORTSETTINGS_H__
+#pragma once
#include "BLI_linklist.h"
#include "BlenderContext.h"
@@ -291,5 +290,3 @@ class BCExportSettings {
};
#endif
-
-#endif
diff --git a/source/blender/io/collada/ExtraHandler.h b/source/blender/io/collada/ExtraHandler.h
index 04ac963b530..8f98e1dec1b 100644
--- a/source/blender/io/collada/ExtraHandler.h
+++ b/source/blender/io/collada/ExtraHandler.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __EXTRAHANDLER_H__
-#define __EXTRAHANDLER_H__
+#pragma once
#include <algorithm> // sort()
#include <map>
@@ -79,5 +78,3 @@ class ExtraHandler : public COLLADASaxFWL::IExtraDataCallbackHandler {
ExtraTags *currentExtraTags;
std::string currentElement;
};
-
-#endif /* __EXTRAHANDLER_H__ */
diff --git a/source/blender/io/collada/ExtraTags.h b/source/blender/io/collada/ExtraTags.h
index c806b8fa904..a72cdeb32a8 100644
--- a/source/blender/io/collada/ExtraTags.h
+++ b/source/blender/io/collada/ExtraTags.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __EXTRATAGS_H__
-#define __EXTRATAGS_H__
+#pragma once
#include <map>
#include <string>
@@ -73,5 +72,3 @@ class ExtraTags {
/** Get text data for tag as a string. */
std::string asString(std::string tag, bool *ok);
};
-
-#endif /* __EXTRATAGS_H__ */
diff --git a/source/blender/io/collada/GeometryExporter.h b/source/blender/io/collada/GeometryExporter.h
index 5090158177f..d91f3d1ec5a 100644
--- a/source/blender/io/collada/GeometryExporter.h
+++ b/source/blender/io/collada/GeometryExporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __GEOMETRYEXPORTER_H__
-#define __GEOMETRYEXPORTER_H__
+#pragma once
#include <set>
#include <string>
@@ -136,5 +135,3 @@ struct GeometryFunctor {
}
}
};
-
-#endif
diff --git a/source/blender/io/collada/ImageExporter.h b/source/blender/io/collada/ImageExporter.h
index 20f9b95a512..e1fdcc12272 100644
--- a/source/blender/io/collada/ImageExporter.h
+++ b/source/blender/io/collada/ImageExporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __IMAGEEXPORTER_H__
-#define __IMAGEEXPORTER_H__
+#pragma once
#include <string>
#include <vector>
@@ -47,5 +46,3 @@ class ImagesExporter : COLLADASW::LibraryImages {
KeyImageMap &key_image_map;
void export_UV_Image(Image *image, bool use_texture_copies);
};
-
-#endif
diff --git a/source/blender/io/collada/ImportSettings.h b/source/blender/io/collada/ImportSettings.h
index 608d8bff882..e8a5bf8ce81 100644
--- a/source/blender/io/collada/ImportSettings.h
+++ b/source/blender/io/collada/ImportSettings.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __IMPORTSETTINGS_H__
-#define __IMPORTSETTINGS_H__
+#pragma once
typedef struct ImportSettings {
bool import_units;
@@ -30,5 +29,3 @@ typedef struct ImportSettings {
char *filepath;
bool keep_bind_info;
} ImportSettings;
-
-#endif
diff --git a/source/blender/io/collada/InstanceWriter.h b/source/blender/io/collada/InstanceWriter.h
index cfec1cf7006..c79d6691842 100644
--- a/source/blender/io/collada/InstanceWriter.h
+++ b/source/blender/io/collada/InstanceWriter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __INSTANCEWRITER_H__
-#define __INSTANCEWRITER_H__
+#pragma once
#include "COLLADASWBindMaterial.h"
@@ -31,5 +30,3 @@ class InstanceWriter {
Object *ob,
bool active_uv_only);
};
-
-#endif
diff --git a/source/blender/io/collada/LightExporter.h b/source/blender/io/collada/LightExporter.h
index a5c7f5c6dee..90256691c06 100644
--- a/source/blender/io/collada/LightExporter.h
+++ b/source/blender/io/collada/LightExporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __LIGHTEXPORTER_H__
-#define __LIGHTEXPORTER_H__
+#pragma once
#include "COLLADASWLibraryLights.h"
#include "COLLADASWStreamWriter.h"
@@ -40,5 +39,3 @@ class LightsExporter : COLLADASW::LibraryLights {
bool exportBlenderProfile(COLLADASW::Light &cla, Light *la);
BCExportSettings &export_settings;
};
-
-#endif
diff --git a/source/blender/io/collada/MaterialExporter.h b/source/blender/io/collada/MaterialExporter.h
index babb113567f..7d40347097c 100644
--- a/source/blender/io/collada/MaterialExporter.h
+++ b/source/blender/io/collada/MaterialExporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __MATERIALEXPORTER_H__
-#define __MATERIALEXPORTER_H__
+#pragma once
#include <string>
#include <vector>
@@ -93,5 +92,3 @@ struct MaterialFunctor {
gf.forEachMeshObjectInExportSet<ForEachMaterialFunctor<Functor>>(sce, matfunc, export_set);
}
};
-
-#endif
diff --git a/source/blender/io/collada/Materials.h b/source/blender/io/collada/Materials.h
index e1d12246a2b..f671a00758d 100644
--- a/source/blender/io/collada/Materials.h
+++ b/source/blender/io/collada/Materials.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __MATERIALS_H__
-#define __MATERIALS_H__
+#pragma once
#include <map>
#include <string>
@@ -70,5 +69,3 @@ class MaterialNode {
COLLADAFW::ColorOrTexture &cot,
COLLADAFW::FloatOrParam &val);
};
-
-#endif /* __MATERIALS_H__ */
diff --git a/source/blender/io/collada/MeshImporter.h b/source/blender/io/collada/MeshImporter.h
index 18e56e8f9df..a63cb0da987 100644
--- a/source/blender/io/collada/MeshImporter.h
+++ b/source/blender/io/collada/MeshImporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __MESHIMPORTER_H__
-#define __MESHIMPORTER_H__
+#pragma once
#include <map>
#include <vector>
@@ -177,5 +176,3 @@ class MeshImporter : public MeshImporterBase {
bool write_geometry(const COLLADAFW::Geometry *geom);
std::string *get_geometry_name(const std::string &mesh_name);
};
-
-#endif
diff --git a/source/blender/io/collada/SceneExporter.h b/source/blender/io/collada/SceneExporter.h
index 3ea6a9fac8e..5b8ec37152f 100644
--- a/source/blender/io/collada/SceneExporter.h
+++ b/source/blender/io/collada/SceneExporter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __SCENEEXPORTER_H__
-#define __SCENEEXPORTER_H__
+#pragma once
#include <math.h>
#include <stdio.h>
@@ -110,5 +109,3 @@ class SceneExporter : COLLADASW::LibraryVisualScenes,
void writeNodeList(std::vector<Object *> &child_objects, Object *parent);
void writeNode(Object *ob);
};
-
-#endif
diff --git a/source/blender/io/collada/SkinInfo.h b/source/blender/io/collada/SkinInfo.h
index e8b13f86e9c..3b94e403b6d 100644
--- a/source/blender/io/collada/SkinInfo.h
+++ b/source/blender/io/collada/SkinInfo.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __SKININFO_H__
-#define __SKININFO_H__
+#pragma once
#include <map>
#include <vector>
@@ -126,5 +125,3 @@ class SkinInfo {
bool find_node_in_tree(COLLADAFW::Node *node, COLLADAFW::Node *tree_root);
};
-
-#endif
diff --git a/source/blender/io/collada/TransformReader.h b/source/blender/io/collada/TransformReader.h
index 5a778e6aba5..f8a73ce3912 100644
--- a/source/blender/io/collada/TransformReader.h
+++ b/source/blender/io/collada/TransformReader.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __TRANSFORMREADER_H__
-#define __TRANSFORMREADER_H__
+#pragma once
#include "COLLADAFWMatrix.h"
#include "COLLADAFWNode.h"
@@ -68,5 +67,3 @@ class TransformReader {
void dae_scale_to_v3(COLLADAFW::Transformation *tm, float v[3]);
void dae_vector3_to_v3(const COLLADABU::Math::Vector3 &v3, float v[3]);
};
-
-#endif
diff --git a/source/blender/io/collada/TransformWriter.h b/source/blender/io/collada/TransformWriter.h
index db8ef3f5ee2..200f641b064 100644
--- a/source/blender/io/collada/TransformWriter.h
+++ b/source/blender/io/collada/TransformWriter.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __TRANSFORMWRITER_H__
-#define __TRANSFORMWRITER_H__
+#pragma once
#include "COLLADASWNode.h"
@@ -47,5 +46,3 @@ class TransformWriter {
const float rot[3],
const float scale[3]);
};
-
-#endif
diff --git a/source/blender/io/collada/collada.h b/source/blender/io/collada/collada.h
index d8e498ef4b2..2668be6153b 100644
--- a/source/blender/io/collada/collada.h
+++ b/source/blender/io/collada/collada.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __COLLADA_H__
-#define __COLLADA_H__
+#pragma once
#include <stdlib.h>
@@ -46,5 +45,3 @@ int collada_export(struct bContext *C, ExportSettings *export_settings);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/io/collada/collada_internal.cpp b/source/blender/io/collada/collada_internal.cpp
index f123e8ea31f..b3fa9ba1251 100644
--- a/source/blender/io/collada/collada_internal.cpp
+++ b/source/blender/io/collada/collada_internal.cpp
@@ -277,7 +277,7 @@ std::string encode_xml(std::string xml)
{'<', "&lt;"}, {'>', "&gt;"}, {'"', "&quot;"}, {'\'', "&apos;"}, {'&', "&amp;"}};
std::map<char, std::string>::const_iterator it;
- std::string encoded_xml = "";
+ std::string encoded_xml;
for (unsigned int i = 0; i < xml.size(); i++) {
char c = xml.at(i);
diff --git a/source/blender/io/collada/collada_internal.h b/source/blender/io/collada/collada_internal.h
index d9fe0ba0b58..de4e1d7e0d4 100644
--- a/source/blender/io/collada/collada_internal.h
+++ b/source/blender/io/collada/collada_internal.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __COLLADA_INTERNAL_H__
-#define __COLLADA_INTERNAL_H__
+#pragma once
#include <map>
#include <string>
@@ -94,5 +93,3 @@ extern std::string get_morph_id(Object *ob);
extern std::string get_effect_id(Material *mat);
extern std::string get_material_id(Material *mat);
-
-#endif /* __COLLADA_INTERNAL_H__ */
diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp
index 2c54a49198a..2493b3a386b 100644
--- a/source/blender/io/collada/collada_utils.cpp
+++ b/source/blender/io/collada/collada_utils.cpp
@@ -88,9 +88,8 @@ float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray &array, unsigned in
if (array.getType() == COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT) {
return array.getFloatValues()->getData()[index];
}
- else {
- return array.getDoubleValues()->getData()[index];
- }
+
+ return array.getDoubleValues()->getData()[index];
}
/* copied from /editors/object/object_relations.c */
@@ -330,9 +329,8 @@ bool bc_is_root_bone(Bone *aBone, bool deform_bones_only)
}
return (aBone == root);
}
- else {
- return !(aBone->parent);
- }
+
+ return !(aBone->parent);
}
int bc_get_active_UVLayer(Object *ob)
@@ -672,8 +670,7 @@ void BoneExtended::set_bone_layers(std::string layerString, std::vector<std::str
std::string BoneExtended::get_bone_layers(int bitfield)
{
- std::string result = "";
- std::string sep = "";
+ std::string sep;
int bit = 1u;
std::ostringstream ss;
@@ -1323,9 +1320,8 @@ COLLADASW::ColorOrTexture bc_get_base_color(Material *ma)
if (ma->use_nodes && shader) {
return bc_get_cot_from_shader(shader, "Base Color", default_color, false);
}
- else {
- return bc_get_cot(default_color);
- }
+
+ return bc_get_cot(default_color);
}
COLLADASW::ColorOrTexture bc_get_emission(Material *ma)
@@ -1335,9 +1331,8 @@ COLLADASW::ColorOrTexture bc_get_emission(Material *ma)
if (ma->use_nodes && shader) {
return bc_get_cot_from_shader(shader, "Emission", default_color);
}
- else {
- return bc_get_cot(default_color); /* default black */
- }
+
+ return bc_get_cot(default_color); /* default black */
}
COLLADASW::ColorOrTexture bc_get_ambient(Material *ma)
@@ -1420,9 +1415,8 @@ COLLADASW::ColorOrTexture bc_get_cot_from_shader(bNode *shader,
float *col = dcol->value;
return bc_get_cot(col, with_alpha);
}
- else {
- return bc_get_cot(default_color, with_alpha);
- }
+
+ return bc_get_cot(default_color, with_alpha);
}
bNode *bc_get_master_shader(Material *ma)
diff --git a/source/blender/io/collada/collada_utils.h b/source/blender/io/collada/collada_utils.h
index 11a9376294b..38050556b47 100644
--- a/source/blender/io/collada/collada_utils.h
+++ b/source/blender/io/collada/collada_utils.h
@@ -18,8 +18,7 @@
* \ingroup collada
*/
-#ifndef __COLLADA_UTILS_H__
-#define __COLLADA_UTILS_H__
+#pragma once
#include "COLLADAFWColorOrTexture.h"
#include "COLLADAFWFloatOrDoubleArray.h"
@@ -155,7 +154,7 @@ inline std::string bc_string_after(const std::string &s, const std::string probe
if (i != std::string::npos) {
return (s.substr(i + probe.length(), s.length() - i));
}
- return (s);
+ return s;
}
inline std::string bc_string_before(const std::string &s, const std::string probe)
@@ -164,7 +163,7 @@ inline std::string bc_string_before(const std::string &s, const std::string prob
if (i != std::string::npos) {
return s.substr(0, i);
}
- return (s);
+ return s;
}
inline bool bc_startswith(std::string const &value, std::string const &starting)
@@ -393,5 +392,3 @@ COLLADASW::ColorOrTexture bc_get_cot_from_shader(bNode *shader,
COLLADASW::ColorOrTexture bc_get_cot(float r, float g, float b, float a);
COLLADASW::ColorOrTexture bc_get_cot(Color col, bool with_alpha = true);
-
-#endif
diff --git a/source/blender/io/common/CMakeLists.txt b/source/blender/io/common/CMakeLists.txt
index d3341767f8b..7e39af32f11 100644
--- a/source/blender/io/common/CMakeLists.txt
+++ b/source/blender/io/common/CMakeLists.txt
@@ -55,8 +55,11 @@ if(WITH_GTESTS)
intern/hierarchy_context_order_test.cc
intern/object_identifier_test.cc
)
+ set(TEST_INC
+ ../../blenloader
+ )
set(TEST_LIB
- bf_blenloader_test
+ bf_blenloader_tests
bf_io_common
)
include(GTestTesting)
diff --git a/source/blender/io/common/IO_abstract_hierarchy_iterator.h b/source/blender/io/common/IO_abstract_hierarchy_iterator.h
index d289d86b397..d0d9d72b880 100644
--- a/source/blender/io/common/IO_abstract_hierarchy_iterator.h
+++ b/source/blender/io/common/IO_abstract_hierarchy_iterator.h
@@ -33,8 +33,7 @@
* Selections like "selected only" or "no hair systems" are left to concrete subclasses.
*/
-#ifndef __ABSTRACT_HIERARCHY_ITERATOR_H__
-#define __ABSTRACT_HIERARCHY_ITERATOR_H__
+#pragma once
#include "IO_dupli_persistent_id.hh"
@@ -355,5 +354,3 @@ class AbstractHierarchyIterator {
} // namespace io
} // namespace blender
-
-#endif /* __ABSTRACT_HIERARCHY_ITERATOR_H__ */
diff --git a/source/blender/io/common/IO_dupli_persistent_id.hh b/source/blender/io/common/IO_dupli_persistent_id.hh
index 5dc54164684..6fabafd9d51 100644
--- a/source/blender/io/common/IO_dupli_persistent_id.hh
+++ b/source/blender/io/common/IO_dupli_persistent_id.hh
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2020 Blender Foundation.
* All rights reserved.
*/
-#ifndef __IO_COMMON_DUPLI_PERSISTENT_ID_H__
-#define __IO_COMMON_DUPLI_PERSISTENT_ID_H__
+#pragma once
#include "BKE_duplilist.h"
@@ -64,5 +63,3 @@ class PersistentID {
};
} // namespace blender::io
-
-#endif // __IO_COMMON_DUPLI_PARENT_FINDER_H__
diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
index 2bc7560e177..cbb2e63a99f 100644
--- a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
+++ b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
@@ -17,7 +17,8 @@
* All rights reserved.
*/
#include "IO_abstract_hierarchy_iterator.h"
-#include "blenloader/blendfile_loading_base_test.h"
+
+#include "tests/blendfile_loading_base_test.h"
#include "BLI_math.h"
#include "DEG_depsgraph.h"
diff --git a/source/blender/io/common/intern/dupli_parent_finder.hh b/source/blender/io/common/intern/dupli_parent_finder.hh
index e7e628665ee..3dcf037bb5e 100644
--- a/source/blender/io/common/intern/dupli_parent_finder.hh
+++ b/source/blender/io/common/intern/dupli_parent_finder.hh
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2020 Blender Foundation.
* All rights reserved.
*/
-#ifndef __IO_COMMON_DUPLI_PARENT_FINDER_H__
-#define __IO_COMMON_DUPLI_PARENT_FINDER_H__
+#pragma once
#include "IO_dupli_persistent_id.hh"
@@ -58,5 +57,3 @@ class DupliParentFinder final {
};
} // namespace blender::io
-
-#endif \ No newline at end of file
diff --git a/source/blender/io/usd/intern/usd_exporter_context.h b/source/blender/io/usd/intern/usd_exporter_context.h
index 07a9d0fc0c5..5513768b527 100644
--- a/source/blender/io/usd/intern/usd_exporter_context.h
+++ b/source/blender/io/usd/intern/usd_exporter_context.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_EXPORTER_CONTEXT_H__
-#define __USD_EXPORTER_CONTEXT_H__
+#pragma once
#include "usd.h"
@@ -44,5 +43,3 @@ struct USDExporterContext {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_EXPORTER_CONTEXT_H__ */
diff --git a/source/blender/io/usd/intern/usd_hierarchy_iterator.h b/source/blender/io/usd/intern/usd_hierarchy_iterator.h
index 2836ff0b17f..03e80ce735a 100644
--- a/source/blender/io/usd/intern/usd_hierarchy_iterator.h
+++ b/source/blender/io/usd/intern/usd_hierarchy_iterator.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_HIERARCHY_ITERATOR_H__
-#define __USD_HIERARCHY_ITERATOR_H__
+#pragma once
#include "IO_abstract_hierarchy_iterator.h"
#include "usd.h"
@@ -75,5 +74,3 @@ class USDHierarchyIterator : public AbstractHierarchyIterator {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_HIERARCHY_ITERATOR_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_abstract.h b/source/blender/io/usd/intern/usd_writer_abstract.h
index f81cf5197af..a689deaf0d8 100644
--- a/source/blender/io/usd/intern/usd_writer_abstract.h
+++ b/source/blender/io/usd/intern/usd_writer_abstract.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_ABSTRACT_H__
-#define __USD_WRITER_ABSTRACT_H__
+#pragma once
#include "IO_abstract_hierarchy_iterator.h"
#include "usd_exporter_context.h"
@@ -78,5 +77,3 @@ class USDAbstractWriter : public AbstractHierarchyWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_ABSTRACT_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_camera.h b/source/blender/io/usd/intern/usd_writer_camera.h
index 8b5795d7d9f..1c613d7879b 100644
--- a/source/blender/io/usd/intern/usd_writer_camera.h
+++ b/source/blender/io/usd/intern/usd_writer_camera.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_CAMERA_H__
-#define __USD_WRITER_CAMERA_H__
+#pragma once
#include "usd_writer_abstract.h"
@@ -38,5 +37,3 @@ class USDCameraWriter : public USDAbstractWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_CAMERA_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_hair.h b/source/blender/io/usd/intern/usd_writer_hair.h
index cecacd0a355..b9a28013875 100644
--- a/source/blender/io/usd/intern/usd_writer_hair.h
+++ b/source/blender/io/usd/intern/usd_writer_hair.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_HAIR_H__
-#define __USD_WRITER_HAIR_H__
+#pragma once
#include "usd_writer_abstract.h"
@@ -38,5 +37,3 @@ class USDHairWriter : public USDAbstractWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_HAIR_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_light.h b/source/blender/io/usd/intern/usd_writer_light.h
index 73666622af1..082050ad071 100644
--- a/source/blender/io/usd/intern/usd_writer_light.h
+++ b/source/blender/io/usd/intern/usd_writer_light.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_LIGHT_H__
-#define __USD_WRITER_LIGHT_H__
+#pragma once
#include "usd_writer_abstract.h"
@@ -37,5 +36,3 @@ class USDLightWriter : public USDAbstractWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_LIGHT_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_mesh.h b/source/blender/io/usd/intern/usd_writer_mesh.h
index a14ceecfa53..078daa05501 100644
--- a/source/blender/io/usd/intern/usd_writer_mesh.h
+++ b/source/blender/io/usd/intern/usd_writer_mesh.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_MESH_H__
-#define __USD_WRITER_MESH_H__
+#pragma once
#include "usd_writer_abstract.h"
@@ -66,5 +65,3 @@ class USDMeshWriter : public USDGenericMeshWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_MESH_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_metaball.h b/source/blender/io/usd/intern/usd_writer_metaball.h
index 9f51a3314a5..216f5a2638f 100644
--- a/source/blender/io/usd/intern/usd_writer_metaball.h
+++ b/source/blender/io/usd/intern/usd_writer_metaball.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2020 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_METABALL_H__
-#define __USD_WRITER_METABALL_H__
+#pragma once
#include "usd_writer_mesh.h"
@@ -42,5 +41,3 @@ class USDMetaballWriter : public USDGenericMeshWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_METABALL_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_transform.h b/source/blender/io/usd/intern/usd_writer_transform.h
index 8b4741f1177..39a1f20e7e8 100644
--- a/source/blender/io/usd/intern/usd_writer_transform.h
+++ b/source/blender/io/usd/intern/usd_writer_transform.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_TRANSFORM_H__
-#define __USD_WRITER_TRANSFORM_H__
+#pragma once
#include "usd_writer_abstract.h"
@@ -42,5 +41,3 @@ class USDTransformWriter : public USDAbstractWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_TRANSFORM_H__ */
diff --git a/source/blender/io/usd/usd.h b/source/blender/io/usd/usd.h
index eee98521289..f2826cd1d7c 100644
--- a/source/blender/io/usd/usd.h
+++ b/source/blender/io/usd/usd.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __USD_H__
-#define __USD_H__
+#pragma once
#include "DEG_depsgraph.h"
@@ -59,5 +58,3 @@ int USD_get_version(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __USD_H__ */
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 4ec622574cc..feda4ba43eb 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -22,8 +22,7 @@
* \brief ID and Library types, which are fundamental for sdna.
*/
-#ifndef __DNA_ID_H__
-#define __DNA_ID_H__
+#pragma once
#include "DNA_defs.h"
#include "DNA_listBase.h"
@@ -820,5 +819,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 98e858dbf41..6e590001aff 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -25,11 +25,11 @@
* or sequenced in the non-linear-editor (NLA).
*/
-#ifndef __DNA_ACTION_TYPES_H__
-#define __DNA_ACTION_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_listBase.h"
+#include "DNA_session_uuid_types.h"
#include "DNA_userdef_types.h" /* ThemeWireColor */
#include "DNA_vec_types.h"
#include "DNA_view2d_types.h"
@@ -188,6 +188,8 @@ struct DualQuat;
struct Mat4;
typedef struct bPoseChannel_Runtime {
+ SessionUUID session_uuid;
+
/* Cached dual quaternion for deformation. */
struct DualQuat deform_dual_quat;
@@ -953,5 +955,3 @@ typedef struct bActionChannel {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_ACTION_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 6a024ec9e7e..858daaac47c 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_ANIM_TYPES_H__
-#define __DNA_ANIM_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_action_types.h"
@@ -1141,5 +1140,3 @@ typedef struct IdAdtTemplate {
#ifdef __cplusplus
};
#endif
-
-#endif /* __DNA_ANIM_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index 635c155dec6..2e029d041ec 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_ARMATURE_TYPES_H__
-#define __DNA_ARMATURE_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -281,5 +280,3 @@ typedef enum eBone_BBoneHandleType {
} eBone_BBoneHandleType;
#define MAXBONENAME 64
-
-#endif
diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h
index de93c734bb4..88b2c1e31b8 100644
--- a/source/blender/makesdna/DNA_boid_types.h
+++ b/source/blender/makesdna/DNA_boid_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_BOID_TYPES_H__
-#define __DNA_BOID_TYPES_H__
+#pragma once
#include "DNA_listBase.h"
@@ -223,5 +222,3 @@ typedef struct BoidSettings {
//#define BOID_RULE_LAND (1 << 3) /* goal */
//#define BOID_RULE_WITH_BOIDS (1 << 4) /* avoid collision */
//#define BOID_RULE_WITH_DEFLECTORS (1 << 5) /* avoid collision */
-
-#endif
diff --git a/source/blender/makesdna/DNA_brush_defaults.h b/source/blender/makesdna/DNA_brush_defaults.h
index 2ec4f4ee991..b0a35ac783e 100644
--- a/source/blender/makesdna/DNA_brush_defaults.h
+++ b/source/blender/makesdna/DNA_brush_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_BRUSH_DEFAULTS_H__
-#define __DNA_BRUSH_DEFAULTS_H__
+#pragma once
#include "DNA_texture_defaults.h"
@@ -116,5 +115,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_BRUSH_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index e2102abb285..503dba776a7 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_BRUSH_TYPES_H__
-#define __DNA_BRUSH_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_curve_types.h"
@@ -67,7 +66,9 @@ typedef struct BrushGpencilSettings {
short draw_smoothlvl;
/** Number of times to subdivide new strokes. */
short draw_subdivide;
- char _pad[4];
+ /** Layers used for fill. */
+ short fill_layer_mode;
+ short fill_direction;
/** Factor for transparency. */
float fill_threshold;
@@ -118,7 +119,8 @@ typedef struct BrushGpencilSettings {
int sculpt_mode_flag;
/** Preset type (used to reset brushes - internal). */
short preset_type;
- char _pad3[2];
+ /** Brush preselected mode (Active/Material/Vertexcolor). */
+ short brush_draw_mode;
/** Randomness for Hue. */
float random_hue;
@@ -190,7 +192,7 @@ typedef enum eGPDbrush_Flag {
/* brush use pressure */
GP_BRUSH_USE_PRESSURE = (1 << 0),
/* brush use pressure for alpha factor */
- GP_BRUSH_USE_STENGTH_PRESSURE = (1 << 1),
+ GP_BRUSH_USE_STRENGTH_PRESSURE = (1 << 1),
/* brush use pressure for alpha factor */
GP_BRUSH_USE_JITTER_PRESSURE = (1 << 2),
/* fill hide transparent */
@@ -251,6 +253,16 @@ typedef enum eGP_FillDrawModes {
GP_FILL_DMODE_CONTROL = 2,
} eGP_FillDrawModes;
+/* BrushGpencilSettings->fill_layer_mode */
+typedef enum eGP_FillLayerModes {
+ GP_FILL_GPLMODE_VISIBLE = 0,
+ GP_FILL_GPLMODE_ACTIVE = 1,
+ GP_FILL_GPLMODE_ALL_ABOVE = 2,
+ GP_FILL_GPLMODE_ALL_BELOW = 3,
+ GP_FILL_GPLMODE_ABOVE = 4,
+ GP_FILL_GPLMODE_BELOW = 5,
+} eGP_FillLayerModes;
+
/* BrushGpencilSettings->gp_eraser_mode */
typedef enum eGP_BrushEraserMode {
GP_BRUSH_ERASER_SOFT = 0,
@@ -258,6 +270,13 @@ typedef enum eGP_BrushEraserMode {
GP_BRUSH_ERASER_STROKE = 2,
} eGP_BrushEraserMode;
+/* BrushGpencilSettings->brush_draw_mode */
+typedef enum eGP_BrushMode {
+ GP_BRUSH_MODE_ACTIVE = 0,
+ GP_BRUSH_MODE_MATERIAL = 1,
+ GP_BRUSH_MODE_VERTEXCOLOR = 2,
+} eGP_BrushMode;
+
/* BrushGpencilSettings default brush icons */
typedef enum eGP_BrushIcons {
GP_BRUSH_ICON_PENCIL = 1,
@@ -331,6 +350,11 @@ typedef enum eBrushClothForceFalloffType {
BRUSH_CLOTH_FORCE_FALLOFF_PLANE = 1,
} eBrushClothForceFalloffType;
+typedef enum eBrushClothSimulationAreaType {
+ BRUSH_CLOTH_SIMULATION_AREA_LOCAL = 0,
+ BRUSH_CLOTH_SIMULATION_AREA_GLOBAL = 1,
+} eBrushClothSimulationAreaType;
+
typedef enum eBrushPoseDeformType {
BRUSH_POSE_DEFORM_ROTATE_TWIST = 0,
BRUSH_POSE_DEFORM_SCALE_TRASLATE = 1,
@@ -355,6 +379,14 @@ typedef enum eBrushSlideDeformType {
BRUSH_SLIDE_DEFORM_EXPAND = 2,
} eBrushSlideDeformType;
+typedef enum eBrushBoundaryDeformType {
+ BRUSH_BOUNDARY_DEFORM_BEND = 0,
+ BRUSH_BOUNDARY_DEFORM_EXPAND = 1,
+ BRUSH_BOUNDARY_DEFORM_INFLATE = 2,
+ BRUSH_BOUNDARY_DEFORM_GRAB = 3,
+ BRUSH_BOUNDARY_DEFORM_TWIST = 4,
+} eBrushBushBoundaryDeformType;
+
/* Gpencilsettings.Vertex_mode */
typedef enum eGp_Vertex_Mode {
/* Affect to Stroke only. */
@@ -526,7 +558,7 @@ typedef struct Brush {
char gpencil_sculpt_tool;
/** Active grease pencil weight tool. */
char gpencil_weight_tool;
- char _pad1[6];
+ char _pad1[2];
float autosmooth_factor;
@@ -562,9 +594,13 @@ typedef struct Brush {
int pose_ik_segments;
int pose_origin_type;
+ /* boundary */
+ int boundary_deform_type;
+
/* cloth */
int cloth_deform_type;
int cloth_force_falloff_type;
+ int cloth_simulation_area_type;
float cloth_mass;
float cloth_damping;
@@ -572,6 +608,8 @@ typedef struct Brush {
float cloth_sim_limit;
float cloth_sim_falloff;
+ float cloth_constraint_softbody_strength;
+
/* smooth */
int smooth_deform_type;
float surface_smooth_shape_preservation;
@@ -716,6 +754,9 @@ typedef enum eBrushFlags2 {
BRUSH_MULTIPLANE_SCRAPE_PLANES_PREVIEW = (1 << 1),
BRUSH_POSE_IK_ANCHORED = (1 << 2),
BRUSH_USE_CONNECTED_ONLY = (1 << 3),
+ BRUSH_CLOTH_PIN_SIMULATION_BOUNDARY = (1 << 4),
+ BRUSH_POSE_USE_LOCK_ROTATION = (1 << 5),
+ BRUSH_CLOTH_USE_COLLISION = (1 << 6),
} eBrushFlags2;
typedef enum {
@@ -768,6 +809,7 @@ typedef enum eBrushSculptTool {
SCULPT_TOOL_DRAW_FACE_SETS = 27,
SCULPT_TOOL_PAINT = 28,
SCULPT_TOOL_SMEAR = 29,
+ SCULPT_TOOL_BOUNDARY = 30,
} eBrushSculptTool;
/* Brush.uv_sculpt_tool */
@@ -915,5 +957,3 @@ enum {
#define MAX_BRUSH_PIXEL_RADIUS 500
#define GP_MAX_BRUSH_PIXEL_RADIUS 1000
-
-#endif /* __DNA_BRUSH_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_cachefile_defaults.h b/source/blender/makesdna/DNA_cachefile_defaults.h
index 4c4ff53ed90..d37994bb488 100644
--- a/source/blender/makesdna/DNA_cachefile_defaults.h
+++ b/source/blender/makesdna/DNA_cachefile_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_CACHEFILE_DEFAULTS_H__
-#define __DNA_CACHEFILE_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -45,5 +44,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_CACHEFILE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_cachefile_types.h b/source/blender/makesdna/DNA_cachefile_types.h
index 1175c7f0dc0..04c99c6c4b1 100644
--- a/source/blender/makesdna/DNA_cachefile_types.h
+++ b/source/blender/makesdna/DNA_cachefile_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_CACHEFILE_TYPES_H__
-#define __DNA_CACHEFILE_TYPES_H__
+#pragma once
#include "DNA_ID.h"
@@ -53,6 +52,13 @@ typedef struct AlembicObjectPath {
char path[4096];
} AlembicObjectPath;
+/* CacheFile::velocity_unit
+ * Determines what temporal unit is used to interpret velocity vectors for motion blur effects. */
+enum {
+ CACHEFILE_VELOCITY_UNIT_FRAME,
+ CACHEFILE_VELOCITY_UNIT_SECOND,
+};
+
typedef struct CacheFile {
ID id;
struct AnimData *adt;
@@ -78,7 +84,11 @@ typedef struct CacheFile {
short flag;
short draw_flag; /* UNUSED */
- char _pad[4];
+ char _pad[3];
+
+ char velocity_unit;
+ /* Name of the velocity property in the Alembic file. */
+ char velocity_name[64];
/* Runtime */
struct AbcArchiveHandle *handle;
@@ -89,5 +99,3 @@ typedef struct CacheFile {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_CACHEFILE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_camera_defaults.h b/source/blender/makesdna/DNA_camera_defaults.h
index 7a28f673ee4..55fbb59a161 100644
--- a/source/blender/makesdna/DNA_camera_defaults.h
+++ b/source/blender/makesdna/DNA_camera_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_CAMERA_DEFAULTS_H__
-#define __DNA_CAMERA_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -63,5 +62,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_CAMERA_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h
index b12d25d74e0..73a55edf05f 100644
--- a/source/blender/makesdna/DNA_camera_types.h
+++ b/source/blender/makesdna/DNA_camera_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_CAMERA_TYPES_H__
-#define __DNA_CAMERA_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -226,5 +225,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index 9d9ee711339..bc6991b3249 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_CLOTH_TYPES_H__
-#define __DNA_CLOTH_TYPES_H__
+#pragma once
#include "DNA_defs.h"
@@ -210,5 +209,3 @@ typedef struct ClothCollSettings {
/** Impulse clamp for self collisions. */
float self_clamp;
} ClothCollSettings;
-
-#endif
diff --git a/source/blender/makesdna/DNA_collection_types.h b/source/blender/makesdna/DNA_collection_types.h
index 13eb8a762d9..6cf02137fa6 100644
--- a/source/blender/makesdna/DNA_collection_types.h
+++ b/source/blender/makesdna/DNA_collection_types.h
@@ -23,8 +23,7 @@
* \brief Object groups, one object can be in many groups at once.
*/
-#ifndef __DNA_COLLECTION_TYPES_H__
-#define __DNA_COLLECTION_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -93,5 +92,3 @@ enum {
* Using a generic tag like LIB_TAG_DOIT for this is just impossible, we need our very own. */
COLLECTION_TAG_RELATION_REBUILD = (1 << 0),
};
-
-#endif /* __DNA_COLLECTION_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h
index 66adc547cf2..5577a17c0df 100644
--- a/source/blender/makesdna/DNA_color_types.h
+++ b/source/blender/makesdna/DNA_color_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_COLOR_TYPES_H__
-#define __DNA_COLOR_TYPES_H__
+#pragma once
#include "DNA_defs.h"
#include "DNA_vec_types.h"
@@ -215,5 +214,3 @@ typedef struct ColorManagedColorspaceSettings {
enum {
COLORMANAGE_VIEW_USE_CURVES = (1 << 0),
};
-
-#endif
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index 85d9a04a902..cddc78d7640 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -22,8 +22,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_CONSTRAINT_TYPES_H__
-#define __DNA_CONSTRAINT_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -1168,5 +1167,3 @@ typedef enum eStretchTo_Flags {
#define CONSTRAINT_RB_CONETWIST 4
#define CONSTRAINT_RB_VEHICLE 11
#define CONSTRAINT_RB_GENERIC6DOF 12
-
-#endif
diff --git a/source/blender/makesdna/DNA_curve_defaults.h b/source/blender/makesdna/DNA_curve_defaults.h
index 0fdfd5713e9..0cb3960dbd7 100644
--- a/source/blender/makesdna/DNA_curve_defaults.h
+++ b/source/blender/makesdna/DNA_curve_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_CURVE_DEFAULTS_H__
-#define __DNA_CURVE_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -55,5 +54,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_CURVE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 9f724973b6c..2ae9ba13177 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_CURVE_TYPES_H__
-#define __DNA_CURVE_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -547,5 +546,3 @@ enum {
/* indicates point has been seen during surface duplication */
#define SURF_SEEN 4
-
-#endif
diff --git a/source/blender/makesdna/DNA_curveprofile_types.h b/source/blender/makesdna/DNA_curveprofile_types.h
index ca00f783905..5b425741df2 100644
--- a/source/blender/makesdna/DNA_curveprofile_types.h
+++ b/source/blender/makesdna/DNA_curveprofile_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_CURVEPROFILE_TYPES_H__
-#define __DNA_CURVEPROFILE_TYPES_H__
+#pragma once
#include "DNA_vec_types.h"
@@ -31,7 +30,7 @@
/** Number of table points per control point. */
#define PROF_RESOL 16
/** Dynamic size of widget's high resolution table. Input should be profile->totpoint. */
-#define PROF_N_TABLE(n_pts) min_ii(PROF_TABLE_MAX, (((n_pts - 1)) * PROF_RESOL) + 1)
+#define PROF_TABLE_LEN(n_pts) min_ii(PROF_TABLE_MAX, (((n_pts - 1)) * PROF_RESOL) + 1)
/**
* Each control point that makes up the profile.
@@ -99,5 +98,3 @@ typedef enum eCurveProfilePresets {
PROF_PRESET_CROWN = 3, /* Second molding example. */
PROF_PRESET_STEPS = 4, /* Dynamic number of steps defined by segments_len. */
} eCurveProfilePresets;
-
-#endif /* __DNA_CURVEPROFILE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h
index 7a9744ed1c7..2990fa85c27 100644
--- a/source/blender/makesdna/DNA_customdata_types.h
+++ b/source/blender/makesdna/DNA_customdata_types.h
@@ -23,8 +23,7 @@
* Used for custom mesh data types (stored per vert/edge/loop/face)
*/
-#ifndef __DNA_CUSTOMDATA_TYPES_H__
-#define __DNA_CUSTOMDATA_TYPES_H__
+#pragma once
#include "DNA_defs.h"
@@ -254,5 +253,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_CUSTOMDATA_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_defaults.h b/source/blender/makesdna/DNA_defaults.h
index ca5ac649e33..1549e33b267 100644
--- a/source/blender/makesdna/DNA_defaults.h
+++ b/source/blender/makesdna/DNA_defaults.h
@@ -24,8 +24,7 @@
* \see dna_defaults.c for details on how to use this system.
*/
-#ifndef __DNA_DEFAULTS_H__
-#define __DNA_DEFAULTS_H__
+#pragma once
#include "BLI_utildefines.h"
@@ -52,5 +51,3 @@ char *_DNA_struct_default_alloc_impl(const char *data_src, size_t size, const ch
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_defs.h b/source/blender/makesdna/DNA_defs.h
index 092dd9d3bcc..01ee954d0d2 100644
--- a/source/blender/makesdna/DNA_defs.h
+++ b/source/blender/makesdna/DNA_defs.h
@@ -20,8 +20,7 @@
* Group generic defines for all DNA headers may use in this file.
*/
-#ifndef __DNA_DEFS_H__
-#define __DNA_DEFS_H__
+#pragma once
/* makesdna ignores */
#ifdef DNA_DEPRECATED_ALLOW
@@ -61,5 +60,3 @@
/* non-id name variables should use this length */
#define MAX_NAME 64
-
-#endif /* __DNA_DEFS_H__ */
diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h
index c97e68a6a6b..94f54a0d200 100644
--- a/source/blender/makesdna/DNA_dynamicpaint_types.h
+++ b/source/blender/makesdna/DNA_dynamicpaint_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_DYNAMICPAINT_TYPES_H__
-#define __DNA_DYNAMICPAINT_TYPES_H__
+#pragma once
#include "DNA_listBase.h"
struct PaintSurfaceData;
@@ -262,5 +261,3 @@ typedef struct DynamicPaintBrushSettings {
float wave_factor, wave_clamp;
float max_velocity, smudge_strength;
} DynamicPaintBrushSettings;
-
-#endif
diff --git a/source/blender/makesdna/DNA_effect_types.h b/source/blender/makesdna/DNA_effect_types.h
index c34b146064e..c25e9d0dded 100644
--- a/source/blender/makesdna/DNA_effect_types.h
+++ b/source/blender/makesdna/DNA_effect_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_EFFECT_TYPES_H__
-#define __DNA_EFFECT_TYPES_H__
+#pragma once
/* don't forget, new effects also in writefile.c for dna!!! */
@@ -130,5 +129,3 @@ typedef struct WaveEff {
float timeoffs, lifetime;
} WaveEff;
-
-#endif
diff --git a/source/blender/makesdna/DNA_fileglobal_types.h b/source/blender/makesdna/DNA_fileglobal_types.h
index 66f185282a9..bb660fb8eaa 100644
--- a/source/blender/makesdna/DNA_fileglobal_types.h
+++ b/source/blender/makesdna/DNA_fileglobal_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_FILEGLOBAL_TYPES_H__
-#define __DNA_FILEGLOBAL_TYPES_H__
+#pragma once
/**
* FileGlobal stores a part of the current user-interface settings at
@@ -54,5 +53,3 @@ typedef struct FileGlobal {
/* example: if in 2.43 the meshes lose mesh data, minversion is 2.43 then too */
/* or: in 2.42, subversion 1, same as above, minversion then is 2.42, min subversion 1 */
/* (defines for version are in the BKE_blender_version.h file, for historic reasons) */
-
-#endif
diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h
index 90440d9af8a..6035c43ad57 100644
--- a/source/blender/makesdna/DNA_fluid_types.h
+++ b/source/blender/makesdna/DNA_fluid_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_FLUID_TYPES_H__
-#define __DNA_FLUID_TYPES_H__
+#pragma once
#include "DNA_listBase.h"
@@ -226,8 +225,9 @@ enum {
#define FLUID_NAME_GUIDING "fluid_guiding"
/* Fluid object names.*/
-#define FLUID_NAME_FLAGS "flags" /* == OpenVDB grid attribute name. */
-#define FLUID_NAME_VELOCITY "velocity" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_FLAGS "flags" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_VELOCITY "velocity" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_VEL "vel"
#define FLUID_NAME_VELOCITYTMP "velocity_previous" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_VELOCITYX "x_vel"
#define FLUID_NAME_VELOCITYY "y_vel"
@@ -368,7 +368,8 @@ enum {
#define FLUID_NAME_GUIDEVEL_X "x_guidevel"
#define FLUID_NAME_GUIDEVEL_Y "y_guidevel"
#define FLUID_NAME_GUIDEVEL_Z "z_guidevel"
-#define FLUID_NAME_GUIDEVEL "velocity_guide"
+#define FLUID_NAME_GUIDEVEL "guidevel"
+#define FLUID_NAME_VELOCITY_GUIDE "velocity_guide"
/* Cache file extensions. */
#define FLUID_DOMAIN_EXTENSION_UNI ".uni"
@@ -784,5 +785,3 @@ typedef struct FluidEffectorSettings {
short guide_mode;
char _pad2[2];
} FluidEffectorSettings;
-
-#endif
diff --git a/source/blender/makesdna/DNA_freestyle_types.h b/source/blender/makesdna/DNA_freestyle_types.h
index 8b3d8090c89..884e11f3a8e 100644
--- a/source/blender/makesdna/DNA_freestyle_types.h
+++ b/source/blender/makesdna/DNA_freestyle_types.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __DNA_FREESTYLE_TYPES_H__
-#define __DNA_FREESTYLE_TYPES_H__
+#pragma once
/** \file
* \ingroup DNA
@@ -155,5 +154,3 @@ typedef struct FreestyleConfig {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_FREESTYLE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h
index 6366412f0cf..1cdaba81ffa 100644
--- a/source/blender/makesdna/DNA_genfile.h
+++ b/source/blender/makesdna/DNA_genfile.h
@@ -22,8 +22,7 @@
* \brief blenloader genfile private function prototypes
*/
-#ifndef __DNA_GENFILE_H__
-#define __DNA_GENFILE_H__
+#pragma once
#include "intern/dna_utils.h"
@@ -141,5 +140,3 @@ void DNA_sdna_alias_data_ensure_structs_map(struct SDNA *sdna);
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_GENFILE_H__ */
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index 5d35db1a960..3049c0f8bab 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_GPENCIL_MODIFIER_TYPES_H__
-#define __DNA_GPENCIL_MODIFIER_TYPES_H__
+#pragma once
#include "DNA_defs.h"
#include "DNA_listBase.h"
@@ -800,5 +799,3 @@ typedef enum eTextureGpencil_Mode {
FILL = 1,
STROKE_AND_FILL = 2,
} eTextureGpencil_Mode;
-
-#endif /* __DNA_GPENCIL_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index b6e2910a1b0..222b716a502 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_GPENCIL_TYPES_H__
-#define __DNA_GPENCIL_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_brush_types.h"
@@ -756,5 +755,3 @@ typedef enum eGP_DrawMode {
#define GPENCIL_ANY_VERTEX_MASK(flag) \
((flag & (GP_VERTEX_MASK_SELECTMODE_POINT | GP_VERTEX_MASK_SELECTMODE_STROKE | \
GP_VERTEX_MASK_SELECTMODE_SEGMENT)))
-
-#endif /* __DNA_GPENCIL_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_gpu_types.h b/source/blender/makesdna/DNA_gpu_types.h
index 7d56baf86a4..b1ace1bda49 100644
--- a/source/blender/makesdna/DNA_gpu_types.h
+++ b/source/blender/makesdna/DNA_gpu_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_GPU_TYPES_H__
-#define __DNA_GPU_TYPES_H__
+#pragma once
/* Keep for 'Camera' versioning. */
/** Properties for dof effect. */
@@ -37,5 +36,3 @@ typedef struct GPUDOFSettings {
int num_blades;
int high_quality;
} GPUDOFSettings;
-
-#endif /* __DNA_GPU_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_hair_defaults.h b/source/blender/makesdna/DNA_hair_defaults.h
index de7a830885d..095e4fdf583 100644
--- a/source/blender/makesdna/DNA_hair_defaults.h
+++ b/source/blender/makesdna/DNA_hair_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_HAIR_DEFAULTS_H__
-#define __DNA_HAIR_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -36,5 +35,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_HAIR_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_hair_types.h b/source/blender/makesdna/DNA_hair_types.h
index 98fae91dbe1..d120e61cfef 100644
--- a/source/blender/makesdna/DNA_hair_types.h
+++ b/source/blender/makesdna/DNA_hair_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_HAIR_TYPES_H__
-#define __DNA_HAIR_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_customdata_types.h"
@@ -74,5 +73,3 @@ enum {
/* Only one material supported currently. */
#define HAIR_MATERIAL_NR 1
-
-#endif /* __DNA_HAIR_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_image_defaults.h b/source/blender/makesdna/DNA_image_defaults.h
index e115f9e2b16..ce1296d681f 100644
--- a/source/blender/makesdna/DNA_image_defaults.h
+++ b/source/blender/makesdna/DNA_image_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_IMAGE_DEFAULTS_H__
-#define __DNA_IMAGE_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -42,5 +41,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_IMAGE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h
index 20357fc1099..749bc55fcb9 100644
--- a/source/blender/makesdna/DNA_image_types.h
+++ b/source/blender/makesdna/DNA_image_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_IMAGE_TYPES_H__
-#define __DNA_IMAGE_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_color_types.h" /* for color management */
@@ -117,6 +116,14 @@ typedef struct ImageTile {
#define IMA_NEED_FRAME_RECALC (1 << 3)
#define IMA_SHOW_STEREO (1 << 4)
+/* Used to get the correct gpu texture from an Image datablock. */
+typedef enum eGPUTextureTarget {
+ TEXTARGET_2D = 0,
+ TEXTARGET_2D_ARRAY,
+ TEXTARGET_TILE_MAPPING,
+ TEXTARGET_COUNT,
+} eGPUTextureTarget;
+
typedef struct Image {
ID id;
@@ -125,8 +132,8 @@ typedef struct Image {
/** Not written in file. */
struct MovieCache *cache;
- /** Not written in file 4 = TEXTARGET_COUNT, 2 = stereo eyes. */
- struct GPUTexture *gputexture[4][2];
+ /** Not written in file 3 = TEXTARGET_COUNT, 2 = stereo eyes. */
+ struct GPUTexture *gputexture[3][2];
/* sources from: */
ListBase anims;
@@ -257,5 +264,3 @@ enum {
IMA_ALPHA_CHANNEL_PACKED = 2,
IMA_ALPHA_IGNORE = 3,
};
-
-#endif
diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h
index 0f1028f5770..dfd06702b72 100644
--- a/source/blender/makesdna/DNA_ipo_types.h
+++ b/source/blender/makesdna/DNA_ipo_types.h
@@ -26,8 +26,7 @@
* All defines, etc. are only still maintained to provide backwards compatibility for old files.
*/
-#ifndef __DNA_IPO_TYPES_H__
-#define __DNA_IPO_TYPES_H__
+#pragma once
#include "DNA_curve_types.h"
#include "DNA_listBase.h"
@@ -517,5 +516,3 @@ typedef struct Ipo {
/* driver->flag */
/* invalid flag: currently only used for buggy pydriver expressions */
#define IPO_DRIVER_FLAG_INVALID (1 << 0)
-
-#endif
diff --git a/source/blender/makesdna/DNA_key_types.h b/source/blender/makesdna/DNA_key_types.h
index a1cc6f89314..56a164e4f2c 100644
--- a/source/blender/makesdna/DNA_key_types.h
+++ b/source/blender/makesdna/DNA_key_types.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
-#ifndef __DNA_KEY_TYPES_H__
-#define __DNA_KEY_TYPES_H__
+#pragma once
/** \file
* \ingroup DNA
@@ -159,5 +158,3 @@ enum {
#define KEYELEM_ELEM_LEN_BEZTRIPLE 4
#define KEYELEM_FLOAT_LEN_BEZTRIPLE (KEYELEM_ELEM_LEN_BEZTRIPLE * KEYELEM_ELEM_SIZE_CURVE)
-
-#endif /* __DNA_KEY_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_lattice_defaults.h b/source/blender/makesdna/DNA_lattice_defaults.h
index 052aaba51d7..505b853b0ee 100644
--- a/source/blender/makesdna/DNA_lattice_defaults.h
+++ b/source/blender/makesdna/DNA_lattice_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_LATTICE_DEFAULTS_H__
-#define __DNA_LATTICE_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -40,5 +39,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_LATTICE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_lattice_types.h b/source/blender/makesdna/DNA_lattice_types.h
index 336726fb28d..797df3bd738 100644
--- a/source/blender/makesdna/DNA_lattice_types.h
+++ b/source/blender/makesdna/DNA_lattice_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_LATTICE_TYPES_H__
-#define __DNA_LATTICE_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -83,5 +82,3 @@ typedef struct Lattice {
#define LT_DS_EXPAND 4
#define LT_ACTBP_NONE -1
-
-#endif
diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h
index cb604fd6681..3c2d479bea4 100644
--- a/source/blender/makesdna/DNA_layer_types.h
+++ b/source/blender/makesdna/DNA_layer_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_LAYER_TYPES_H__
-#define __DNA_LAYER_TYPES_H__
+#pragma once
#include "DNA_freestyle_types.h"
#include "DNA_listBase.h"
@@ -216,5 +215,3 @@ typedef struct SceneCollection {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_LAYER_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_light_defaults.h b/source/blender/makesdna/DNA_light_defaults.h
index dceaaf7c278..6ac52c1b356 100644
--- a/source/blender/makesdna/DNA_light_defaults.h
+++ b/source/blender/makesdna/DNA_light_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_LIGHT_DEFAULTS_H__
-#define __DNA_LIGHT_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -72,5 +71,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_LIGHT_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_light_types.h b/source/blender/makesdna/DNA_light_types.h
index 7a7b5d923e3..1616cf949bd 100644
--- a/source/blender/makesdna/DNA_light_types.h
+++ b/source/blender/makesdna/DNA_light_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_LIGHT_TYPES_H__
-#define __DNA_LIGHT_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -155,5 +154,3 @@ typedef struct Light {
/* #define LA_AREA_BOX 3 */ /* UNUSED */
#define LA_AREA_DISK 4
#define LA_AREA_ELLIPSE 5
-
-#endif /* __DNA_LIGHT_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_lightprobe_defaults.h b/source/blender/makesdna/DNA_lightprobe_defaults.h
index 7c7732d17e4..4de94b81b97 100644
--- a/source/blender/makesdna/DNA_lightprobe_defaults.h
+++ b/source/blender/makesdna/DNA_lightprobe_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_LIGHTPROBE_DEFAULTS_H__
-#define __DNA_LIGHTPROBE_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -47,5 +46,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_LIGHTPROBE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_lightprobe_types.h b/source/blender/makesdna/DNA_lightprobe_types.h
index 5ddfedfed2d..3830919bfd3 100644
--- a/source/blender/makesdna/DNA_lightprobe_types.h
+++ b/source/blender/makesdna/DNA_lightprobe_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_LIGHTPROBE_TYPES_H__
-#define __DNA_LIGHTPROBE_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -150,7 +149,7 @@ BLI_STATIC_ASSERT_ALIGN(LightGridCache, 16)
typedef struct LightCacheTexture {
struct GPUTexture *tex;
- /* Copy of GPU datas to create GPUTextures on file read. */
+ /** Copy of GPU datas to create GPUTextures on file read. */
char *data;
int tex_size[3];
char data_type;
@@ -204,6 +203,10 @@ enum {
LIGHTCACHE_UPDATE_GRID = (1 << 5),
LIGHTCACHE_UPDATE_WORLD = (1 << 6),
LIGHTCACHE_UPDATE_AUTO = (1 << 7),
+ /** Invalid means we tried to alloc it but failed. */
+ LIGHTCACHE_INVALID = (1 << 8),
+ /** The data present in the cache is valid but unusable on this GPU. */
+ LIGHTCACHE_NOT_USABLE = (1 << 9),
};
/* EEVEE_LightCacheTexture->data_type */
@@ -216,5 +219,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_LIGHTPROBE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_linestyle_defaults.h b/source/blender/makesdna/DNA_linestyle_defaults.h
index 2f9203050d1..47405b4a15f 100644
--- a/source/blender/makesdna/DNA_linestyle_defaults.h
+++ b/source/blender/makesdna/DNA_linestyle_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_LINESTYLE_DEFAULTS_H__
-#define __DNA_LINESTYLE_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -57,5 +56,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_LINESTYLE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_linestyle_types.h b/source/blender/makesdna/DNA_linestyle_types.h
index eca5ab5e8ec..867f0995ae9 100644
--- a/source/blender/makesdna/DNA_linestyle_types.h
+++ b/source/blender/makesdna/DNA_linestyle_types.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __DNA_LINESTYLE_TYPES_H__
-#define __DNA_LINESTYLE_TYPES_H__
+#pragma once
/** \file
* \ingroup DNA
@@ -576,5 +575,3 @@ typedef struct FreestyleLineStyle {
ListBase thickness_modifiers;
ListBase geometry_modifiers;
} FreestyleLineStyle;
-
-#endif
diff --git a/source/blender/makesdna/DNA_listBase.h b/source/blender/makesdna/DNA_listBase.h
index 7d247c99387..0c4054004ea 100644
--- a/source/blender/makesdna/DNA_listBase.h
+++ b/source/blender/makesdna/DNA_listBase.h
@@ -25,8 +25,7 @@
* with Link.
*/
-#ifndef __DNA_LISTBASE_H__
-#define __DNA_LISTBASE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -53,5 +52,3 @@ typedef struct ListBase {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h
index 9617b3fdf27..5f232036f2a 100644
--- a/source/blender/makesdna/DNA_mask_types.h
+++ b/source/blender/makesdna/DNA_mask_types.h
@@ -24,8 +24,7 @@
* for image masking in the compositor and sequencer.
*/
-#ifndef __DNA_MASK_TYPES_H__
-#define __DNA_MASK_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_curve_types.h"
@@ -264,5 +263,3 @@ enum {
enum {
MASK_ANIMF_EXPAND = (1 << 4),
};
-
-#endif /* __DNA_MASK_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_material_defaults.h b/source/blender/makesdna/DNA_material_defaults.h
index cdcb1dd45f7..3f4496ce735 100644
--- a/source/blender/makesdna/DNA_material_defaults.h
+++ b/source/blender/makesdna/DNA_material_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_MATERIAL_DEFAULTS_H__
-#define __DNA_MATERIAL_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -51,5 +50,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_MATERIAL_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 6a4ec65318b..3d050805f12 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_MATERIAL_TYPES_H__
-#define __DNA_MATERIAL_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -355,4 +354,3 @@ enum {
GP_MATERIAL_FOLLOW_OBJ = 1,
GP_MATERIAL_FOLLOW_FIXED = 2,
};
-#endif
diff --git a/source/blender/makesdna/DNA_mesh_defaults.h b/source/blender/makesdna/DNA_mesh_defaults.h
index abcdf8bf57b..8326db66049 100644
--- a/source/blender/makesdna/DNA_mesh_defaults.h
+++ b/source/blender/makesdna/DNA_mesh_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_MESH_DEFAULTS_H__
-#define __DNA_MESH_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -43,5 +42,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_MESH_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index 9435cb3bd78..a6aef5b08ad 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_MESH_TYPES_H__
-#define __DNA_MESH_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_customdata_types.h"
@@ -110,9 +109,12 @@ typedef struct Mesh_Runtime {
/** Set by modifier stack if only deformed from original. */
char deformed_only;
/**
- * Copied from edit-mesh (hint, draw with editmesh data).
- * In the future we may leave the mesh-data empty
- * since its not needed if we can use edit-mesh data. */
+ * Copied from edit-mesh (hint, draw with edit-mesh data when true).
+ *
+ * Modifiers that edit the mesh data in-place must set this to false
+ * (most #eModifierTypeType_NonGeometrical modifiers). Otherwise the edit-mesh
+ * data will be used for drawing, missing changes from modifiers. See T79517.
+ */
char is_original;
/** #eMeshWrapperType and others. */
@@ -320,5 +322,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index cc2ba3fb999..57750b15dea 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_MESHDATA_TYPES_H__
-#define __DNA_MESHDATA_TYPES_H__
+#pragma once
#include "DNA_customdata_types.h"
#include "DNA_listBase.h"
@@ -570,5 +569,3 @@ typedef struct Multires {
/* End multi-res structs. */
/** \} */
-
-#endif /* __DNA_MESHDATA_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_meta_defaults.h b/source/blender/makesdna/DNA_meta_defaults.h
index 723f178ed58..1bf2caf556d 100644
--- a/source/blender/makesdna/DNA_meta_defaults.h
+++ b/source/blender/makesdna/DNA_meta_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_META_DEFAULTS_H__
-#define __DNA_META_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -40,5 +39,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_META_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h
index df4558dac77..de7427bc4dd 100644
--- a/source/blender/makesdna/DNA_meta_types.h
+++ b/source/blender/makesdna/DNA_meta_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_META_TYPES_H__
-#define __DNA_META_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -139,5 +138,3 @@ typedef struct MetaBall {
#define MB_NEGATIVE 2
#define MB_HIDE 8
#define MB_SCALE_RAD 16
-
-#endif
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 8c564bda3d0..fc50261eb03 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -18,11 +18,11 @@
* \ingroup DNA
*/
-#ifndef __DNA_MODIFIER_TYPES_H__
-#define __DNA_MODIFIER_TYPES_H__
+#pragma once
#include "DNA_defs.h"
#include "DNA_listBase.h"
+#include "DNA_session_uuid_types.h"
#ifdef __cplusplus
extern "C" {
@@ -125,6 +125,11 @@ typedef struct ModifierData {
/* Pointer to a ModifierData in the original domain. */
struct ModifierData *orig_modifier_data;
+
+ /* Runtime field which contains unique identifier of the modifier. */
+ SessionUUID session_uuid;
+
+ /* Runtime field which contains runtime data which is specific to a modifier type. */
void *runtime;
} ModifierData;
@@ -1277,7 +1282,11 @@ typedef struct OceanModifierData {
struct Ocean *ocean;
struct OceanCache *oceancache;
+ /** Render resolution. */
int resolution;
+ /** Viewport resolution for the non-render case. */
+ int viewport_resolution;
+
int spatial_size;
float wind_velocity;
@@ -1294,8 +1303,6 @@ typedef struct OceanModifierData {
float foam_coverage;
float time;
- char _pad1[4];
-
/* Spectrum being used. */
int spectrum;
@@ -2052,6 +2059,10 @@ enum {
MOD_NORMALEDIT_MIX_MUL = 3,
};
+typedef struct MeshCacheVertexVelocity {
+ float vel[3];
+} MeshCacheVertexVelocity;
+
typedef struct MeshSeqCacheModifierData {
ModifierData modifier;
@@ -2060,11 +2071,31 @@ typedef struct MeshSeqCacheModifierData {
char object_path[1024];
char read_flag;
- char _pad[7];
+ char _pad[3];
+
+ float velocity_scale;
/* Runtime. */
struct CacheReader *reader;
char reader_object_path[1024];
+
+ /* Vertex velocities read from the cache. The velocities are not automatically read during
+ * modifier execution, and therefore have to manually be read when needed. This is only used
+ * through the RNA for now. */
+ struct MeshCacheVertexVelocity *vertex_velocities;
+
+ /* The number of vertices of the Alembic mesh, set when the modifier is executed. */
+ int num_vertices;
+
+ /* Time (in frames or seconds) between two velocity samples. Automatically computed to
+ * scale the velocity vectors at render time for generating proper motion blur data. */
+ float velocity_delta;
+
+ /* Caches the scene time (in seconds) used to lookup data in the Alembic archive when the
+ * modifier was last executed. Used to access Alembic samples through the RNA. */
+ float last_lookup_time;
+
+ int _pad1;
} MeshSeqCacheModifierData;
/* MeshSeqCacheModifierData.read_flag */
@@ -2164,5 +2195,3 @@ typedef struct SimulationModifierData {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h
index d750a7f3148..2b1fd546450 100644
--- a/source/blender/makesdna/DNA_movieclip_types.h
+++ b/source/blender/makesdna/DNA_movieclip_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_MOVIECLIP_TYPES_H__
-#define __DNA_MOVIECLIP_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_color_types.h" /* for color management */
@@ -64,8 +63,8 @@ typedef struct MovieClipProxy {
typedef struct MovieClip_RuntimeGPUTexture {
void *next, *prev;
MovieClipUser user;
- /** Not written in file 4 = TEXTARGET_COUNT. */
- struct GPUTexture *gputexture[4];
+ /** Not written in file 3 = TEXTARGET_COUNT. */
+ struct GPUTexture *gputexture[3];
} MovieClip_RuntimeGPUTexture;
typedef struct MovieClip_Runtime {
@@ -208,5 +207,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/makesdna/DNA_nla_types.h b/source/blender/makesdna/DNA_nla_types.h
index 6bf4a92514e..1cf93464f6a 100644
--- a/source/blender/makesdna/DNA_nla_types.h
+++ b/source/blender/makesdna/DNA_nla_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_NLA_TYPES_H__
-#define __DNA_NLA_TYPES_H__
+#pragma once
#include "DNA_listBase.h"
@@ -106,5 +105,3 @@ typedef enum eActStrip_Flag {
ACTSTRIP_REVERSE = (1 << 7),
ACTSTRIP_AUTO_BLENDS = (1 << 11),
} eActStrip_Flag;
-
-#endif
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 42ccbc657d8..1d76ebdff2c 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_NODE_TYPES_H__
-#define __DNA_NODE_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_listBase.h"
@@ -1439,5 +1438,3 @@ typedef enum NodeSimInputTimeType {
NODE_SIM_INPUT_SIMULATION_TIME = 0,
NODE_SIM_INPUT_SCENE_TIME = 1,
} NodeSimInputTimeType;
-
-#endif
diff --git a/source/blender/makesdna/DNA_object_defaults.h b/source/blender/makesdna/DNA_object_defaults.h
index 554d68f2d4a..1bca572b963 100644
--- a/source/blender/makesdna/DNA_object_defaults.h
+++ b/source/blender/makesdna/DNA_object_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_OBJECT_DEFAULTS_H__
-#define __DNA_OBJECT_DEFAULTS_H__
+#pragma once
#include "DNA_vec_defaults.h"
@@ -72,5 +71,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_OBJECT_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_object_enums.h b/source/blender/makesdna/DNA_object_enums.h
index f3e69161c85..dbbd72c2075 100644
--- a/source/blender/makesdna/DNA_object_enums.h
+++ b/source/blender/makesdna/DNA_object_enums.h
@@ -20,8 +20,7 @@
* Enums typedef's for use in public headers.
*/
-#ifndef __DNA_OBJECT_ENUMS_H__
-#define __DNA_OBJECT_ENUMS_H__
+#pragma once
/** #Object.mode */
typedef enum eObjectMode {
@@ -69,5 +68,3 @@ typedef enum eDrawType {
(OB_MODE_EDIT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_SCULPT | OB_MODE_POSE | \
OB_MODE_PAINT_GPENCIL | OB_MODE_EDIT_GPENCIL | OB_MODE_SCULPT_GPENCIL | \
OB_MODE_WEIGHT_GPENCIL | OB_MODE_VERTEX_GPENCIL)
-
-#endif /* __DNA_OBJECT_ENUMS_H__ */
diff --git a/source/blender/makesdna/DNA_object_fluidsim_types.h b/source/blender/makesdna/DNA_object_fluidsim_types.h
index 1140a837e23..b8848ccc458 100644
--- a/source/blender/makesdna/DNA_object_fluidsim_types.h
+++ b/source/blender/makesdna/DNA_object_fluidsim_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_OBJECT_FLUIDSIM_TYPES_H__
-#define __DNA_OBJECT_FLUIDSIM_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -179,5 +178,3 @@ typedef struct FluidsimSettings {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_OBJECT_FLUIDSIM_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_object_force_types.h b/source/blender/makesdna/DNA_object_force_types.h
index 78f645deaa2..3b0640544ae 100644
--- a/source/blender/makesdna/DNA_object_force_types.h
+++ b/source/blender/makesdna/DNA_object_force_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_OBJECT_FORCE_TYPES_H__
-#define __DNA_OBJECT_FORCE_TYPES_H__
+#pragma once
#include "DNA_defs.h"
#include "DNA_listBase.h"
@@ -409,5 +408,3 @@ typedef struct SoftBody {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_OBJECT_FORCE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 9424100e1c8..6568281a8d4 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -22,8 +22,7 @@
* \brief Object is a sort of wrapper for general info.
*/
-#ifndef __DNA_OBJECT_TYPES_H__
-#define __DNA_OBJECT_TYPES_H__
+#pragma once
#include "DNA_object_enums.h"
@@ -495,19 +494,19 @@ enum {
ID_VO))
#define OB_DATA_SUPPORT_ID_CASE \
-ID_ME: \
-case ID_CU: \
-case ID_MB: \
-case ID_LA: \
-case ID_SPK: \
-case ID_LP: \
-case ID_CA: \
-case ID_LT: \
-case ID_GD: \
-case ID_AR: \
-case ID_HA: \
-case ID_PT: \
-case ID_VO
+ ID_ME: \
+ case ID_CU: \
+ case ID_MB: \
+ case ID_LA: \
+ case ID_SPK: \
+ case ID_LP: \
+ case ID_CA: \
+ case ID_LT: \
+ case ID_GD: \
+ case ID_AR: \
+ case ID_HA: \
+ case ID_PT: \
+ case ID_VO
/* partype: first 4 bits: type */
enum {
@@ -715,5 +714,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/makesdna/DNA_outliner_types.h b/source/blender/makesdna/DNA_outliner_types.h
index d8a7599e4cb..46c8b1570e3 100644
--- a/source/blender/makesdna/DNA_outliner_types.h
+++ b/source/blender/makesdna/DNA_outliner_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_OUTLINER_TYPES_H__
-#define __DNA_OUTLINER_TYPES_H__
+#pragma once
#include "DNA_defs.h"
@@ -127,5 +126,3 @@ enum {
TSE_KEYMAP_ITEM, \
TSE_ID_BASE, \
TSE_GP_LAYER))
-
-#endif
diff --git a/source/blender/makesdna/DNA_packedFile_types.h b/source/blender/makesdna/DNA_packedFile_types.h
index 8196e3098eb..b74368f767b 100644
--- a/source/blender/makesdna/DNA_packedFile_types.h
+++ b/source/blender/makesdna/DNA_packedFile_types.h
@@ -21,13 +21,10 @@
* \ingroup DNA
*/
-#ifndef __DNA_PACKEDFILE_TYPES_H__
-#define __DNA_PACKEDFILE_TYPES_H__
+#pragma once
typedef struct PackedFile {
int size;
int seek;
void *data;
} PackedFile;
-
-#endif /* PACKEDFILE_TYPES_H */
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 5bd11ab85a5..00f888dde5b 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_PARTICLE_TYPES_H__
-#define __DNA_PARTICLE_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_boid_types.h"
@@ -691,5 +690,3 @@ typedef enum eParticleTextureInfluence {
PAMAP_CHILD = (PAMAP_CLUMP | PAMAP_KINK_FREQ | PAMAP_KINK_AMP | PAMAP_ROUGH | PAMAP_LENGTH |
PAMAP_TWIST),
} eParticleTextureInfluence;
-
-#endif
diff --git a/source/blender/makesdna/DNA_pointcache_types.h b/source/blender/makesdna/DNA_pointcache_types.h
index 3c7fc9031de..678be7d8297 100644
--- a/source/blender/makesdna/DNA_pointcache_types.h
+++ b/source/blender/makesdna/DNA_pointcache_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_POINTCACHE_TYPES_H__
-#define __DNA_POINTCACHE_TYPES_H__
+#pragma once
#include "DNA_listBase.h"
@@ -167,5 +166,3 @@ typedef struct PointCache {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_POINTCACHE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_pointcloud_defaults.h b/source/blender/makesdna/DNA_pointcloud_defaults.h
index 89df2d3c4be..b5c9396b1dd 100644
--- a/source/blender/makesdna/DNA_pointcloud_defaults.h
+++ b/source/blender/makesdna/DNA_pointcloud_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_POINTCLOUD_DEFAULTS_H__
-#define __DNA_POINTCLOUD_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -36,5 +35,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_POINTCLOUD_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_pointcloud_types.h b/source/blender/makesdna/DNA_pointcloud_types.h
index 7f42b75fdd1..d3b687c2c68 100644
--- a/source/blender/makesdna/DNA_pointcloud_types.h
+++ b/source/blender/makesdna/DNA_pointcloud_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_POINTCLOUD_TYPES_H__
-#define __DNA_POINTCLOUD_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_customdata_types.h"
@@ -56,5 +55,3 @@ enum {
/* Only one material supported currently. */
#define POINTCLOUD_MATERIAL_NR 1
-
-#endif /* __DNA_POINTCLOUD_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index 7ad50dc04de..02a4a158d8c 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -22,8 +22,7 @@
* \brief Types and defines for representing Rigid Body entities
*/
-#ifndef __DNA_RIGIDBODY_TYPES_H__
-#define __DNA_RIGIDBODY_TYPES_H__
+#pragma once
#include "DNA_listBase.h"
#include "DNA_object_force_types.h"
@@ -214,7 +213,7 @@ typedef enum eRigidBody_Shape {
RB_SHAPE_TRIMESH = 6,
/* concave mesh approximated using primitives */
- // RB_SHAPE_COMPOUND,
+ RB_SHAPE_COMPOUND = 7,
} eRigidBody_Shape;
typedef enum eRigidBody_MeshSource {
@@ -369,5 +368,3 @@ typedef enum eRigidBodyCon_Flag {
} eRigidBodyCon_Flag;
/* ******************************** */
-
-#endif /* __DNA_RIGIDBODY_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_scene_defaults.h b/source/blender/makesdna/DNA_scene_defaults.h
index 7f01e58f2af..ec64eea0aae 100644
--- a/source/blender/makesdna/DNA_scene_defaults.h
+++ b/source/blender/makesdna/DNA_scene_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_SCENE_DEFAULTS_H__
-#define __DNA_SCENE_DEFAULTS_H__
+#pragma once
#include "DNA_view3d_defaults.h"
@@ -366,4 +365,3 @@
/* clang-format off */
-#endif /* __DNA_SCENE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index a3f5a95f231..93e690d0aba 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_SCENE_TYPES_H__
-#define __DNA_SCENE_TYPES_H__
+#pragma once
#include "DNA_defs.h"
@@ -2414,5 +2413,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_SCENE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index bf5c097322f..d5b828c898d 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_SCREEN_TYPES_H__
-#define __DNA_SCREEN_TYPES_H__
+#pragma once
#include "DNA_defs.h"
#include "DNA_listBase.h"
@@ -705,5 +704,3 @@ enum {
/* Only editor overlays (currently gizmos only!) should be redrawn. */
RGN_DRAW_EDITOR_OVERLAYS = 32,
};
-
-#endif /* __DNA_SCREEN_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_sdna_types.h b/source/blender/makesdna/DNA_sdna_types.h
index efa7a308f88..cfb65860b8e 100644
--- a/source/blender/makesdna/DNA_sdna_types.h
+++ b/source/blender/makesdna/DNA_sdna_types.h
@@ -20,8 +20,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_SDNA_TYPES_H__
-#define __DNA_SDNA_TYPES_H__
+#pragma once
struct MemArena;
@@ -101,5 +100,3 @@ typedef struct BHead8 {
int64_t old;
int SDNAnr, nr;
} BHead8;
-
-#endif
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 9fee839f979..850b906af39 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -28,12 +28,12 @@
* - Meta Strip (SEQ_TYPE_META): Support for nesting Sequences.
*/
-#ifndef __DNA_SEQUENCE_TYPES_H__
-#define __DNA_SEQUENCE_TYPES_H__
+#pragma once
#include "DNA_color_types.h"
#include "DNA_defs.h"
#include "DNA_listBase.h"
+#include "DNA_session_uuid_types.h"
#include "DNA_vec_types.h"
#include "DNA_vfont_types.h"
@@ -119,6 +119,10 @@ typedef struct Strip {
ColorManagedColorspaceSettings colorspace_settings;
} Strip;
+typedef struct SequenceRuntime {
+ SessionUUID session_uuid;
+} SequenceRuntime;
+
/**
* The sequence structure is the basic struct used by any strip.
* each of the strips uses a different sequence structure.
@@ -237,8 +241,7 @@ typedef struct Sequence {
int cache_flag;
int _pad2[3];
- struct Sequence *orig_sequence;
- void *_pad3;
+ SequenceRuntime runtime;
} Sequence;
typedef struct MetaStack {
@@ -692,5 +695,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __DNA_SEQUENCE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_session_uuid_types.h b/source/blender/makesdna/DNA_session_uuid_types.h
new file mode 100644
index 00000000000..eaaae101277
--- /dev/null
+++ b/source/blender/makesdna/DNA_session_uuid_types.h
@@ -0,0 +1,43 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#pragma once
+
+#include "BLI_sys_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Is a structure because of the following considerations:
+ *
+ * - It is not possible to use custom types in DNA members: makesdna does not recognize them.
+ * - It allows to add more bits, more than standard fixed-size types can store. For example, if
+ * we ever need to go 128 bits, it is as simple as adding extra 64bit field.
+ */
+typedef struct SessionUUID {
+ /* Never access directly, as it might cause a headache when more bits are needed: if the field
+ * is used directly it will not be easy to find all places where partial access is used. */
+ uint64_t uuid_;
+} SessionUUID;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/makesdna/DNA_shader_fx_types.h b/source/blender/makesdna/DNA_shader_fx_types.h
index f19181bf07d..56caac51b94 100644
--- a/source/blender/makesdna/DNA_shader_fx_types.h
+++ b/source/blender/makesdna/DNA_shader_fx_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_SHADER_FX_TYPES_H__
-#define __DNA_SHADER_FX_TYPES_H__
+#pragma once
#include "DNA_defs.h"
#include "DNA_listBase.h"
@@ -250,4 +249,3 @@ typedef struct WaveShaderFxData {
char _pad[4];
ShaderFxData_Runtime runtime;
} WaveShaderFxData;
-#endif /* __DNA_SHADER_FX_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_simulation_defaults.h b/source/blender/makesdna/DNA_simulation_defaults.h
index b4cecd861a9..48d35d5e81f 100644
--- a/source/blender/makesdna/DNA_simulation_defaults.h
+++ b/source/blender/makesdna/DNA_simulation_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_SIMULATION_DEFAULTS_H__
-#define __DNA_SIMULATION_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -36,5 +35,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_SIMULATION_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_simulation_types.h b/source/blender/makesdna/DNA_simulation_types.h
index afc59b422c5..8cc2db99332 100644
--- a/source/blender/makesdna/DNA_simulation_types.h
+++ b/source/blender/makesdna/DNA_simulation_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_SIMULATION_TYPES_H__
-#define __DNA_SIMULATION_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_customdata_types.h"
@@ -94,5 +93,3 @@ enum {
#define SIM_TYPE_NAME_PARTICLE_SIMULATION "Particle Simulation"
#define SIM_TYPE_NAME_PARTICLE_MESH_EMITTER "Particle Mesh Emitter"
-
-#endif /* __DNA_SIMULATION_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h
index 35ff3a658ba..1d24e655f45 100644
--- a/source/blender/makesdna/DNA_sound_types.h
+++ b/source/blender/makesdna/DNA_sound_types.h
@@ -20,8 +20,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_SOUND_TYPES_H__
-#define __DNA_SOUND_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -117,5 +116,3 @@ enum {
SOUND_TAGS_WAVEFORM_NO_RELOAD = 1 << 0,
SOUND_TAGS_WAVEFORM_LOADING = (1 << 6),
};
-
-#endif /* __DNA_SOUND_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 565844f0f27..2cc24327178 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -22,8 +22,7 @@
* Structs for each of space type in the user interface.
*/
-#ifndef __DNA_SPACE_TYPES_H__
-#define __DNA_SPACE_TYPES_H__
+#pragma once
#include "DNA_color_types.h" /* for Histogram */
#include "DNA_defs.h"
@@ -1741,5 +1740,3 @@ typedef enum eSpace_Type {
#define IMG_SIZE_FALLBACK 256
/** \} */
-
-#endif /* __DNA_SPACE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_speaker_defaults.h b/source/blender/makesdna/DNA_speaker_defaults.h
index d252a447701..a14e4d687d3 100644
--- a/source/blender/makesdna/DNA_speaker_defaults.h
+++ b/source/blender/makesdna/DNA_speaker_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_SPEAKER_DEFAULTS_H__
-#define __DNA_SPEAKER_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -47,5 +46,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_SPEAKER_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_speaker_types.h b/source/blender/makesdna/DNA_speaker_types.h
index 9100b37d85e..82693689d68 100644
--- a/source/blender/makesdna/DNA_speaker_types.h
+++ b/source/blender/makesdna/DNA_speaker_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_SPEAKER_TYPES_H__
-#define __DNA_SPEAKER_TYPES_H__
+#pragma once
#include "DNA_ID.h"
@@ -58,5 +57,3 @@ typedef struct Speaker {
#define SPK_DS_EXPAND (1 << 0)
#define SPK_MUTED (1 << 1)
// #define SPK_RELATIVE (1 << 2) /* UNUSED */
-
-#endif /* __DNA_SPEAKER_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_text_types.h b/source/blender/makesdna/DNA_text_types.h
index 27663ffcbdd..2dcb19d19b8 100644
--- a/source/blender/makesdna/DNA_text_types.h
+++ b/source/blender/makesdna/DNA_text_types.h
@@ -23,8 +23,7 @@
* and arbitrary text data to store in blend files.
*/
-#ifndef __DNA_TEXT_TYPES_H__
-#define __DNA_TEXT_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_listBase.h"
@@ -85,5 +84,3 @@ enum {
/** Use space instead of tabs. */
TXT_TABSTOSPACES = 1 << 10,
};
-
-#endif /* __DNA_TEXT_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_texture_defaults.h b/source/blender/makesdna/DNA_texture_defaults.h
index d5097c5ea21..1e790709fd1 100644
--- a/source/blender/makesdna/DNA_texture_defaults.h
+++ b/source/blender/makesdna/DNA_texture_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_TEXTURE_DEFAULTS_H__
-#define __DNA_TEXTURE_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -151,5 +150,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_TEXTURE_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index 907fe29263f..63e5f134c19 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_TEXTURE_TYPES_H__
-#define __DNA_TEXTURE_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -529,5 +528,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index 32a00cc25d1..4cd9034a83b 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -23,8 +23,7 @@
* Structs used for camera tracking and the movie-clip editor.
*/
-#ifndef __DNA_TRACKING_TYPES_H__
-#define __DNA_TRACKING_TYPES_H__
+#pragma once
#include "DNA_defs.h"
#include "DNA_listBase.h"
@@ -617,5 +616,3 @@ enum {
PLANE_TRACK_LOCKED = (1 << 2),
PLANE_TRACK_AUTOKEY = (1 << 3),
};
-
-#endif /* __DNA_TRACKING_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index d50c0055499..c2ed6c97d3d 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_USERDEF_TYPES_H__
-#define __DNA_USERDEF_TYPES_H__
+#pragma once
#include "DNA_listBase.h"
#include "DNA_texture_types.h" /* ColorBand */
@@ -1339,5 +1338,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/makesdna/DNA_vec_defaults.h b/source/blender/makesdna/DNA_vec_defaults.h
index 7242f5ab114..3b980db7838 100644
--- a/source/blender/makesdna/DNA_vec_defaults.h
+++ b/source/blender/makesdna/DNA_vec_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_VEC_DEFAULTS_H__
-#define __DNA_VEC_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -51,5 +50,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_VEC_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_vec_types.h b/source/blender/makesdna/DNA_vec_types.h
index 72a6056e239..b8cbf85b683 100644
--- a/source/blender/makesdna/DNA_vec_types.h
+++ b/source/blender/makesdna/DNA_vec_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_VEC_TYPES_H__
-#define __DNA_VEC_TYPES_H__
+#pragma once
/* types */
@@ -91,5 +90,3 @@ typedef struct DualQuat {
float scale[4][4];
float scale_weight;
} DualQuat;
-
-#endif
diff --git a/source/blender/makesdna/DNA_vfont_types.h b/source/blender/makesdna/DNA_vfont_types.h
index 086fb2bc905..4e2a6eba1f5 100644
--- a/source/blender/makesdna/DNA_vfont_types.h
+++ b/source/blender/makesdna/DNA_vfont_types.h
@@ -24,8 +24,7 @@
* (unrelated to text used to render the GUI).
*/
-#ifndef __DNA_VFONT_TYPES_H__
-#define __DNA_VFONT_TYPES_H__
+#pragma once
#include "DNA_ID.h"
@@ -60,5 +59,3 @@ typedef struct VFont {
#define FO_CURS_IS_MOTION(mode) (ELEM(mode, FO_CURSUP, FO_CURSDOWN, FO_PAGEUP, FO_PAGEDOWN))
#define FO_BUILTIN_NAME "<builtin>"
-
-#endif /* __DNA_VFONT_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h
index 8734a73c07a..63038b6be2d 100644
--- a/source/blender/makesdna/DNA_view2d_types.h
+++ b/source/blender/makesdna/DNA_view2d_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_VIEW2D_TYPES_H__
-#define __DNA_VIEW2D_TYPES_H__
+#pragma once
#include "DNA_vec_types.h"
@@ -137,7 +136,7 @@ enum {
/* apply pixel offsets on y-axis when setting view matrices */
V2D_PIXELOFS_Y = (1 << 3),
/* view settings need to be set still... */
- V2D_IS_INITIALISED = (1 << 10),
+ V2D_IS_INIT = (1 << 10),
};
/* scroller flags for View2D (v2d->scroll) */
@@ -181,5 +180,3 @@ enum {
V2D_ALIGN_NO_POS_Y = (1 << 2),
V2D_ALIGN_NO_NEG_Y = (1 << 3),
};
-
-#endif
diff --git a/source/blender/makesdna/DNA_view3d_defaults.h b/source/blender/makesdna/DNA_view3d_defaults.h
index 10eadf368ef..62e3d14bd0c 100644
--- a/source/blender/makesdna/DNA_view3d_defaults.h
+++ b/source/blender/makesdna/DNA_view3d_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_VIEW3D_DEFAULTS_H__
-#define __DNA_VIEW3D_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -114,5 +113,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_VIEW3D_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_view3d_enums.h b/source/blender/makesdna/DNA_view3d_enums.h
index f8c772422bb..fdeebf20808 100644
--- a/source/blender/makesdna/DNA_view3d_enums.h
+++ b/source/blender/makesdna/DNA_view3d_enums.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_VIEW3D_ENUMS_H__
-#define __DNA_VIEW3D_ENUMS_H__
+#pragma once
/** Settings for offscreen rendering */
typedef enum eV3DOffscreenDrawFlag {
@@ -52,5 +51,3 @@ typedef enum eV3DShadingBackgroundType {
V3D_SHADING_BACKGROUND_WORLD = 1,
V3D_SHADING_BACKGROUND_VIEWPORT = 2,
} eV3DShadingBackgroundType;
-
-#endif
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 4bb32fedd1d..7bfdc14d25c 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_VIEW3D_TYPES_H__
-#define __DNA_VIEW3D_TYPES_H__
+#pragma once
struct BoundBox;
struct Object;
@@ -630,5 +629,3 @@ enum {
/** #BKE_screen_view3d_zoom_to_fac() values above */
#define RV3D_CAMZOOM_MIN_FACTOR 0.1657359312880714853f
#define RV3D_CAMZOOM_MAX_FACTOR 44.9852813742385702928f
-
-#endif
diff --git a/source/blender/makesdna/DNA_volume_defaults.h b/source/blender/makesdna/DNA_volume_defaults.h
index 3a0373851da..8239f263c6c 100644
--- a/source/blender/makesdna/DNA_volume_defaults.h
+++ b/source/blender/makesdna/DNA_volume_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_VOLUME_DEFAULTS_H__
-#define __DNA_VOLUME_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -55,5 +54,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_VOLUME_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_volume_types.h b/source/blender/makesdna/DNA_volume_types.h
index b3615e87a50..30ac67281e2 100644
--- a/source/blender/makesdna/DNA_volume_types.h
+++ b/source/blender/makesdna/DNA_volume_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_VOLUME_TYPES_H__
-#define __DNA_VOLUME_TYPES_H__
+#pragma once
#include "DNA_ID.h"
@@ -122,5 +121,3 @@ typedef enum VolumeRenderSpace {
/* Only one material supported currently. */
#define VOLUME_MATERIAL_NR 1
-
-#endif /* __DNA_VOLUME_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index a07b8f81d96..dd11fed021d 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_WINDOWMANAGER_TYPES_H__
-#define __DNA_WINDOWMANAGER_TYPES_H__
+#pragma once
#include "DNA_listBase.h"
#include "DNA_screen_types.h"
@@ -198,8 +197,8 @@ typedef struct wmWindowManager {
/* wmWindowManager.initialized */
enum {
- WM_WINDOW_IS_INITIALIZED = (1 << 0),
- WM_KEYCONFIG_IS_INITIALIZED = (1 << 1),
+ WM_WINDOW_IS_INIT = (1 << 0),
+ WM_KEYCONFIG_IS_INIT = (1 << 1),
};
/* wmWindowManager.outliner_sync_select_dirty */
@@ -557,5 +556,3 @@ enum {
* (the regiontype is maintained to prevent errors) */
OP_IS_MODAL_CURSOR_REGION = (1 << 3),
};
-
-#endif /* __DNA_WINDOWMANAGER_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index d2461657480..170366881c6 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -20,8 +20,7 @@
* Use API in BKE_workspace.h to edit these.
*/
-#ifndef __DNA_WORKSPACE_TYPES_H__
-#define __DNA_WORKSPACE_TYPES_H__
+#pragma once
#include "DNA_scene_types.h"
@@ -184,5 +183,3 @@ typedef struct WorkSpaceInstanceHook {
typedef enum eWorkSpaceFlags {
WORKSPACE_USE_FILTER_BY_ORIGIN = (1 << 1),
} eWorkSpaceFlags;
-
-#endif /* __DNA_WORKSPACE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_world_defaults.h b/source/blender/makesdna/DNA_world_defaults.h
index c4d934381b4..52c9551a63e 100644
--- a/source/blender/makesdna/DNA_world_defaults.h
+++ b/source/blender/makesdna/DNA_world_defaults.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_WORLD_DEFAULTS_H__
-#define __DNA_WORLD_DEFAULTS_H__
+#pragma once
/* Struct members on own line. */
/* clang-format off */
@@ -45,5 +44,3 @@
/** \} */
/* clang-format on */
-
-#endif /* __DNA_WORLD_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index dff07f515b1..b1ecf4abf85 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -21,8 +21,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_WORLD_TYPES_H__
-#define __DNA_WORLD_TYPES_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_defs.h"
@@ -111,5 +110,3 @@ enum {
* otherwise anim-editors will not read correctly
*/
#define WO_DS_SHOW_TEXS (1 << 2)
-
-#endif
diff --git a/source/blender/makesdna/DNA_xr_types.h b/source/blender/makesdna/DNA_xr_types.h
index a026f7554cb..caa5232788a 100644
--- a/source/blender/makesdna/DNA_xr_types.h
+++ b/source/blender/makesdna/DNA_xr_types.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_XR_TYPES_H__
-#define __DNA_XR_TYPES_H__
+#pragma once
#include "DNA_view3d_types.h"
@@ -54,5 +53,3 @@ typedef enum eXRSessionBasePoseType {
XR_BASE_POSE_OBJECT = 1,
XR_BASE_POSE_CUSTOM = 2,
} eXRSessionBasePoseType;
-
-#endif /* __DNA_XR_TYPES_H__ */
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index 737ea9a7e12..9808740e030 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -35,6 +35,7 @@ blender_include_dirs(
set(SRC
dna_utils.c
makesdna.c
+ ../../blenlib/intern/BLI_assert.c
../../blenlib/intern/BLI_ghash.c
../../blenlib/intern/BLI_ghash_utils.c
../../blenlib/intern/BLI_memarena.c
@@ -126,6 +127,7 @@ set(INC_SYS
)
set(SRC
+ ../../blenlib/intern/BLI_assert.c
../../blenlib/intern/BLI_ghash.c
../../blenlib/intern/BLI_ghash_utils.c
../../blenlib/intern/BLI_linklist.c
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 3d95eba4aed..8ad0271f355 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -356,141 +356,140 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error
*r_error_message = "SDNA error in SDNA file";
return false;
}
- else {
- const char *cp;
- data++;
- /* Names array ('NAME') */
- if (*data == MAKE_ID('N', 'A', 'M', 'E')) {
- data++;
+ const char *cp;
- sdna->names_len = *data;
- if (do_endian_swap) {
- BLI_endian_switch_int32(&sdna->names_len);
- }
- sdna->names_len_alloc = sdna->names_len;
+ data++;
+ /* Names array ('NAME') */
+ if (*data == MAKE_ID('N', 'A', 'M', 'E')) {
+ data++;
- data++;
- sdna->names = MEM_callocN(sizeof(void *) * sdna->names_len, "sdnanames");
- }
- else {
- *r_error_message = "NAME error in SDNA file";
- return false;
+ sdna->names_len = *data;
+ if (do_endian_swap) {
+ BLI_endian_switch_int32(&sdna->names_len);
}
+ sdna->names_len_alloc = sdna->names_len;
- cp = (char *)data;
- for (int nr = 0; nr < sdna->names_len; nr++) {
- sdna->names[nr] = cp;
-
- /* "float gravity [3]" was parsed wrong giving both "gravity" and
- * "[3]" members. we rename "[3]", and later set the type of
- * "gravity" to "void" so the offsets work out correct */
- if (*cp == '[' && strcmp(cp, "[3]") == 0) {
- if (nr && strcmp(sdna->names[nr - 1], "Cvi") == 0) {
- sdna->names[nr] = "gravity[3]";
- gravity_fix = nr;
- }
- }
- while (*cp) {
- cp++;
+ data++;
+ sdna->names = MEM_callocN(sizeof(void *) * sdna->names_len, "sdnanames");
+ }
+ else {
+ *r_error_message = "NAME error in SDNA file";
+ return false;
+ }
+
+ cp = (char *)data;
+ for (int nr = 0; nr < sdna->names_len; nr++) {
+ sdna->names[nr] = cp;
+
+ /* "float gravity [3]" was parsed wrong giving both "gravity" and
+ * "[3]" members. we rename "[3]", and later set the type of
+ * "gravity" to "void" so the offsets work out correct */
+ if (*cp == '[' && STREQ(cp, "[3]")) {
+ if (nr && STREQ(sdna->names[nr - 1], "Cvi")) {
+ sdna->names[nr] = "gravity[3]";
+ gravity_fix = nr;
}
+ }
+ while (*cp) {
cp++;
}
+ cp++;
+ }
- cp = pad_up_4(cp);
-
- /* Type names array ('TYPE') */
- data = (int *)cp;
- if (*data == MAKE_ID('T', 'Y', 'P', 'E')) {
- data++;
+ cp = pad_up_4(cp);
- sdna->types_len = *data;
- if (do_endian_swap) {
- BLI_endian_switch_int32(&sdna->types_len);
- }
+ /* Type names array ('TYPE') */
+ data = (int *)cp;
+ if (*data == MAKE_ID('T', 'Y', 'P', 'E')) {
+ data++;
- data++;
- sdna->types = MEM_callocN(sizeof(void *) * sdna->types_len, "sdnatypes");
- }
- else {
- *r_error_message = "TYPE error in SDNA file";
- return false;
+ sdna->types_len = *data;
+ if (do_endian_swap) {
+ BLI_endian_switch_int32(&sdna->types_len);
}
- cp = (char *)data;
- for (int nr = 0; nr < sdna->types_len; nr++) {
- /* WARNING! See: DNA_struct_rename_legacy_hack_static_from_alias docs. */
- sdna->types[nr] = DNA_struct_rename_legacy_hack_static_from_alias(cp);
- while (*cp) {
- cp++;
- }
+ data++;
+ sdna->types = MEM_callocN(sizeof(void *) * sdna->types_len, "sdnatypes");
+ }
+ else {
+ *r_error_message = "TYPE error in SDNA file";
+ return false;
+ }
+
+ cp = (char *)data;
+ for (int nr = 0; nr < sdna->types_len; nr++) {
+ /* WARNING! See: DNA_struct_rename_legacy_hack_static_from_alias docs. */
+ sdna->types[nr] = DNA_struct_rename_legacy_hack_static_from_alias(cp);
+ while (*cp) {
cp++;
}
+ cp++;
+ }
- cp = pad_up_4(cp);
-
- /* Type lengths array ('TLEN') */
- data = (int *)cp;
- if (*data == MAKE_ID('T', 'L', 'E', 'N')) {
- data++;
- sp = (short *)data;
- sdna->types_size = sp;
+ cp = pad_up_4(cp);
- if (do_endian_swap) {
- BLI_endian_switch_int16_array(sp, sdna->types_len);
- }
+ /* Type lengths array ('TLEN') */
+ data = (int *)cp;
+ if (*data == MAKE_ID('T', 'L', 'E', 'N')) {
+ data++;
+ sp = (short *)data;
+ sdna->types_size = sp;
- sp += sdna->types_len;
- }
- else {
- *r_error_message = "TLEN error in SDNA file";
- return false;
- }
- /* prevent BUS error */
- if (sdna->types_len & 1) {
- sp++;
+ if (do_endian_swap) {
+ BLI_endian_switch_int16_array(sp, sdna->types_len);
}
- /* Struct array ('STRC') */
- data = (int *)sp;
- if (*data == MAKE_ID('S', 'T', 'R', 'C')) {
- data++;
+ sp += sdna->types_len;
+ }
+ else {
+ *r_error_message = "TLEN error in SDNA file";
+ return false;
+ }
+ /* prevent BUS error */
+ if (sdna->types_len & 1) {
+ sp++;
+ }
- sdna->structs_len = *data;
- if (do_endian_swap) {
- BLI_endian_switch_int32(&sdna->structs_len);
- }
+ /* Struct array ('STRC') */
+ data = (int *)sp;
+ if (*data == MAKE_ID('S', 'T', 'R', 'C')) {
+ data++;
- data++;
- sdna->structs = MEM_callocN(sizeof(void *) * sdna->structs_len, "sdnastrcs");
- }
- else {
- *r_error_message = "STRC error in SDNA file";
- return false;
+ sdna->structs_len = *data;
+ if (do_endian_swap) {
+ BLI_endian_switch_int32(&sdna->structs_len);
}
- sp = (short *)data;
- for (int nr = 0; nr < sdna->structs_len; nr++) {
- sdna->structs[nr] = sp;
+ data++;
+ sdna->structs = MEM_callocN(sizeof(void *) * sdna->structs_len, "sdnastrcs");
+ }
+ else {
+ *r_error_message = "STRC error in SDNA file";
+ return false;
+ }
+
+ sp = (short *)data;
+ for (int nr = 0; nr < sdna->structs_len; nr++) {
+ sdna->structs[nr] = sp;
- if (do_endian_swap) {
- short a;
+ if (do_endian_swap) {
+ short a;
+ BLI_endian_switch_int16(&sp[0]);
+ BLI_endian_switch_int16(&sp[1]);
+
+ a = sp[1];
+ sp += 2;
+ while (a--) {
BLI_endian_switch_int16(&sp[0]);
BLI_endian_switch_int16(&sp[1]);
-
- a = sp[1];
sp += 2;
- while (a--) {
- BLI_endian_switch_int16(&sp[0]);
- BLI_endian_switch_int16(&sp[1]);
- sp += 2;
- }
- }
- else {
- sp += 2 * sp[1] + 2;
}
}
+ else {
+ sp += 2 * sp[1] + 2;
+ }
}
{
@@ -498,7 +497,7 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error
if (gravity_fix > -1) {
for (int nr = 0; nr < sdna->structs_len; nr++) {
sp = sdna->structs[nr];
- if (strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0) {
+ if (STREQ(sdna->types[sp[0]], "ClothSimSettings")) {
sp[10] = SDNA_TYPE_VOID;
}
}
@@ -578,16 +577,15 @@ SDNA *DNA_sdna_from_data(const void *data,
if (init_structDNA(sdna, do_endian_swap, &error_message)) {
return sdna;
}
+
+ if (r_error_message == NULL) {
+ fprintf(stderr, "Error decoding blend file SDNA: %s\n", error_message);
+ }
else {
- if (r_error_message == NULL) {
- fprintf(stderr, "Error decoding blend file SDNA: %s\n", error_message);
- }
- else {
- *r_error_message = error_message;
- }
- DNA_sdna_free(sdna);
- return NULL;
+ *r_error_message = error_message;
}
+ DNA_sdna_free(sdna);
+ return NULL;
}
/**
@@ -700,13 +698,13 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna
while (b > 0) {
str1 = newsdna->types[sp_new[0]];
str2 = oldsdna->types[sp_old[0]];
- if (strcmp(str1, str2) != 0) {
+ if (!STREQ(str1, str2)) {
break;
}
str1 = newsdna->names[sp_new[1]];
str2 = oldsdna->names[sp_old[1]];
- if (strcmp(str1, str2) != 0) {
+ if (!STREQ(str1, str2)) {
break;
}
@@ -764,34 +762,33 @@ static eSDNA_Type sdna_type_nr(const char *dna_type)
if (STR_ELEM(dna_type, "char", "const char")) {
return SDNA_TYPE_CHAR;
}
- else if (STR_ELEM(dna_type, "uchar", "unsigned char")) {
+ if (STR_ELEM(dna_type, "uchar", "unsigned char")) {
return SDNA_TYPE_UCHAR;
}
- else if (STR_ELEM(dna_type, "short")) {
+ if (STR_ELEM(dna_type, "short")) {
return SDNA_TYPE_SHORT;
}
- else if (STR_ELEM(dna_type, "ushort", "unsigned short")) {
+ if (STR_ELEM(dna_type, "ushort", "unsigned short")) {
return SDNA_TYPE_USHORT;
}
- else if (STR_ELEM(dna_type, "int")) {
+ if (STR_ELEM(dna_type, "int")) {
return SDNA_TYPE_INT;
}
- else if (STR_ELEM(dna_type, "float")) {
+ if (STR_ELEM(dna_type, "float")) {
return SDNA_TYPE_FLOAT;
}
- else if (STR_ELEM(dna_type, "double")) {
+ if (STR_ELEM(dna_type, "double")) {
return SDNA_TYPE_DOUBLE;
}
- else if (STR_ELEM(dna_type, "int64_t")) {
+ if (STR_ELEM(dna_type, "int64_t")) {
return SDNA_TYPE_INT64;
}
- else if (STR_ELEM(dna_type, "uint64_t")) {
+ if (STR_ELEM(dna_type, "uint64_t")) {
return SDNA_TYPE_UINT64;
}
/* invalid! */
- else {
- return -1;
- }
+
+ return -1;
}
/**
@@ -940,13 +937,13 @@ static void cast_pointer(
/**
* Equality test on name and oname excluding any array-size suffix.
*/
-static int elem_strcmp(const char *name, const char *oname)
+static bool elem_streq(const char *name, const char *oname)
{
int a = 0;
while (1) {
if (name[a] != oname[a]) {
- return 1;
+ return false;
}
if (name[a] == '[' || oname[a] == '[') {
break;
@@ -956,7 +953,7 @@ static int elem_strcmp(const char *name, const char *oname)
}
a++;
}
- return 0;
+ return true;
}
/**
@@ -987,8 +984,8 @@ static bool elem_exists_impl(
otype = types[old[0]];
oname = names[old[1]];
- if (elem_strcmp(name, oname) == 0) { /* name equal */
- return strcmp(type, otype) == 0; /* type equal */
+ if (elem_streq(name, oname)) { /* name equal */
+ return STREQ(type, otype); /* type equal */
}
}
return false;
@@ -1063,8 +1060,8 @@ static const char *find_elem(const SDNA *sdna,
len = DNA_elem_size_nr(sdna, old[0], old[1]);
- if (elem_strcmp(name, oname) == 0) { /* name equal */
- if (strcmp(type, otype) == 0) { /* type equal */
+ if (elem_streq(name, oname)) { /* name equal */
+ if (STREQ(type, otype)) { /* type equal */
if (sppo) {
*sppo = old;
}
@@ -1132,7 +1129,7 @@ static void reconstruct_elem(const SDNA *newsdna,
oname = oldsdna->names[old[1]];
len = DNA_elem_size_nr(oldsdna, old[0], old[1]);
- if (strcmp(name, oname) == 0) { /* name equal */
+ if (STREQ(name, oname)) { /* name equal */
if (ispointer(name)) { /* pointer of functionpointer afhandelen */
cast_pointer(newsdna->pointer_size,
@@ -1141,7 +1138,7 @@ static void reconstruct_elem(const SDNA *newsdna,
curdata,
olddata);
}
- else if (strcmp(type, otype) == 0) { /* type equal */
+ else if (STREQ(type, otype)) { /* type equal */
memcpy(curdata, olddata, len);
}
else {
@@ -1150,7 +1147,7 @@ static void reconstruct_elem(const SDNA *newsdna,
return;
}
- else if (countpos != 0) { /* name is an array */
+ if (countpos != 0) { /* name is an array */
if (oname[countpos] == '[' && strncmp(name, oname, countpos) == 0) { /* basis equal */
const int new_name_array_len = newsdna->names_array_len[new_name_nr];
@@ -1161,7 +1158,7 @@ static void reconstruct_elem(const SDNA *newsdna,
cast_pointer(
newsdna->pointer_size, oldsdna->pointer_size, min_name_array_len, curdata, olddata);
}
- else if (strcmp(type, otype) == 0) { /* type equal */
+ else if (STREQ(type, otype)) { /* type equal */
/* size of single old array element */
mul = len / old_name_array_len;
/* smaller of sizes of old and new arrays */
@@ -1169,7 +1166,7 @@ static void reconstruct_elem(const SDNA *newsdna,
memcpy(curdata, olddata, mul);
- if (old_name_array_len > new_name_array_len && strcmp(type, "char") == 0) {
+ if (old_name_array_len > new_name_array_len && STREQ(type, "char")) {
/* string had to be truncated, ensure it's still null-terminated */
curdata[mul - 1] = '\0';
}
@@ -1368,7 +1365,7 @@ void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data)
/* exception: variable called blocktype: derived from ID_ */
bool skip = false;
if (name[0] == 'b' && name[1] == 'l') {
- if (strcmp(name, "blocktype") == 0) {
+ if (STREQ(name, "blocktype")) {
skip = true;
}
}
diff --git a/source/blender/makesdna/intern/dna_utils.h b/source/blender/makesdna/intern/dna_utils.h
index 123dd30a2b9..264310ef0fb 100644
--- a/source/blender/makesdna/intern/dna_utils.h
+++ b/source/blender/makesdna/intern/dna_utils.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_UTILS_H__
-#define __DNA_UTILS_H__
+#pragma once
struct GHash;
struct MemArena;
@@ -54,5 +53,3 @@ void DNA_alias_maps(enum eDNA_RenameDir version_dir,
const char *DNA_struct_rename_legacy_hack_alias_from_static(const char *name);
const char *DNA_struct_rename_legacy_hack_static_from_alias(const char *name);
-
-#endif /* __DNA_UTILS_H__ */
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 48258f39604..7aaedbff1ce 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -54,6 +54,7 @@
#include "BLI_ghash.h"
#include "BLI_memarena.h"
#include "BLI_sys_types.h" /* for intptr_t support */
+#include "BLI_system.h" /* for 'BLI_system_backtrace' stub. */
#include "BLI_utildefines.h"
#include "dna_utils.h"
@@ -98,6 +99,7 @@ static const char *includefiles[] = {
"DNA_sdna_types.h",
"DNA_fileglobal_types.h",
"DNA_sequence_types.h",
+ "DNA_session_uuid_types.h",
"DNA_effect_types.h",
"DNA_outliner_types.h",
"DNA_sound_types.h",
@@ -358,7 +360,7 @@ static int add_type(const char *str, int size)
if (str[0] == 0) {
return -1;
}
- else if (strchr(str, '*')) {
+ if (strchr(str, '*')) {
/* note: this is valid C syntax but we can't parse, complain!
* `struct SomeStruct* some_var;` <-- correct but we cant handle right now. */
return -1;
@@ -368,7 +370,7 @@ static int add_type(const char *str, int size)
/* search through type array */
for (int index = 0; index < types_len; index++) {
- if (strcmp(str, types[index]) == 0) {
+ if (STREQ(str, types[index])) {
if (size) {
types_size_native[index] = size;
types_size_32[index] = size;
@@ -521,7 +523,7 @@ static int add_name(const char *str)
/* search name array */
for (nr = 0; nr < names_len; nr++) {
- if (strcmp(name, names[nr]) == 0) {
+ if (STREQ(name, names[nr])) {
return nr;
}
}
@@ -1601,6 +1603,7 @@ int main(int argc, char **argv)
#include "DNA_screen_types.h"
#include "DNA_sdna_types.h"
#include "DNA_sequence_types.h"
+#include "DNA_session_uuid_types.h"
#include "DNA_shader_fx_types.h"
#include "DNA_simulation_types.h"
#include "DNA_sound_types.h"
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 1bcf7f434f2..ee1a3fdd539 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __RNA_DEFINE_H__
-#define __RNA_DEFINE_H__
+#pragma once
/** \file
* \ingroup RNA
@@ -531,5 +530,3 @@ extern const float rna_default_scale_3d[3];
#ifdef __cplusplus
}
#endif
-
-#endif /* __RNA_DEFINE_H__ */
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 0c462ba6766..fb9b62e729a 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __RNA_ENUM_TYPES_H__
-#define __RNA_ENUM_TYPES_H__
+#pragma once
/** \file
* \ingroup RNA
@@ -323,5 +322,3 @@ const EnumPropertyItem *RNA_enum_node_tree_types_itemf_impl(struct bContext *C,
#ifdef __cplusplus
}
#endif
-
-#endif /* __RNA_ENUM_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 045d098bf6a..779e4363be0 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_system.h" /* for 'BLI_system_backtrace' stub. */
#include "BLI_utildefines.h"
#include "RNA_define.h"
@@ -174,7 +175,7 @@ static int replace_if_different(const char *tmpfile, const char *dep_files[])
if (dep_files) {
int pass;
for (pass = 0; dep_files[pass]; pass++) {
- char from_path[4096] = __FILE__;
+ const char from_path[4096] = __FILE__;
char *p1, *p2;
/* dir only */
@@ -3589,7 +3590,7 @@ static void rna_generate_struct_prototypes(FILE *f)
if (found == 0) {
fprintf(f, "struct %s;\n", struct_name);
- if (all_structures >= sizeof(structures) / sizeof(structures[0])) {
+ if (all_structures >= ARRAY_SIZE(structures)) {
printf("Array size to store all structures names is too small\n");
exit(1);
}
@@ -5146,7 +5147,7 @@ int main(int argc, char **argv)
{
int return_status = 0;
- MEM_initialize_memleak_detection();
+ MEM_init_memleak_detection();
MEM_set_error_callback(mem_error_cb);
CLG_init();
diff --git a/source/blender/makesrna/intern/rna_access_internal.h b/source/blender/makesrna/intern/rna_access_internal.h
index a5b554ec7a6..73407123863 100644
--- a/source/blender/makesrna/intern/rna_access_internal.h
+++ b/source/blender/makesrna/intern/rna_access_internal.h
@@ -18,8 +18,7 @@
* \ingroup RNA
*/
-#ifndef __RNA_ACCESS_INTERNAL_H__
-#define __RNA_ACCESS_INTERNAL_H__
+#pragma once
#include "BLI_utildefines.h"
@@ -34,5 +33,3 @@ void rna_property_rna_or_id_get(PropertyRNA *prop,
void rna_idproperty_touch(struct IDProperty *idprop);
struct IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name);
-
-#endif /* __ACCESS_RNA_INTERNAL_H__ */
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 71922eb86b5..852ddf32607 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -95,6 +95,7 @@ const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = {
{SCULPT_TOOL_NUDGE, "NUDGE", ICON_BRUSH_NUDGE, "Nudge", ""},
{SCULPT_TOOL_ROTATE, "ROTATE", ICON_BRUSH_ROTATE, "Rotate", ""},
{SCULPT_TOOL_SLIDE_RELAX, "TOPOLOGY", ICON_BRUSH_GRAB, "Slide Relax", ""},
+ {SCULPT_TOOL_BOUNDARY, "BOUNDARY", ICON_BRUSH_GRAB, "Boundary", ""},
{0, "", 0, NULL, NULL},
{SCULPT_TOOL_CLOTH, "CLOTH", ICON_BRUSH_SCULPT_DRAW, "Cloth", ""},
{SCULPT_TOOL_SIMPLIFY, "SIMPLIFY", ICON_BRUSH_DATA, "Simplify", ""},
@@ -237,12 +238,33 @@ static EnumPropertyItem rna_enum_gpencil_fill_draw_modes_items[] = {
{GP_FILL_DMODE_BOTH,
"BOTH",
0,
- "Default",
+ "All",
"Use both visible strokes and edit lines as fill boundary limits"},
{GP_FILL_DMODE_STROKE, "STROKE", 0, "Strokes", "Use visible strokes as fill boundary limits"},
{GP_FILL_DMODE_CONTROL, "CONTROL", 0, "Edit Lines", "Use edit lines as fill boundary limits"},
{0, NULL, 0, NULL, NULL}};
+static EnumPropertyItem rna_enum_gpencil_fill_layers_modes_items[] = {
+ {GP_FILL_GPLMODE_VISIBLE, "VISIBLE", 0, "Visible", "Visible layers"},
+ {GP_FILL_GPLMODE_ACTIVE, "ACTIVE", 0, "Active", "Only active layer"},
+ {GP_FILL_GPLMODE_ABOVE, "ABOVE", 0, "Layer Above", "Layer above active"},
+ {GP_FILL_GPLMODE_BELOW, "BELOW", 0, "Layer Below", "Layer below active"},
+ {GP_FILL_GPLMODE_ALL_ABOVE, "ALL_ABOVE", 0, "All Above", "All layers above active"},
+ {GP_FILL_GPLMODE_ALL_BELOW, "ALL_BELOW", 0, "All Below", "All layers below active"},
+ {0, NULL, 0, NULL, NULL}};
+
+static EnumPropertyItem rna_enum_gpencil_fill_direction_items[] = {
+ {0, "NORMAL", ICON_ADD, "Normal", "Fill internal area"},
+ {BRUSH_DIR_IN, "INVERT", ICON_REMOVE, "Inverted", "Fill inverted area"},
+ {0, NULL, 0, NULL, NULL},
+};
+
+static EnumPropertyItem rna_enum_gpencil_brush_modes_items[] = {
+ {GP_BRUSH_MODE_ACTIVE, "ACTIVE", 0, "Active", "Use current mode"},
+ {GP_BRUSH_MODE_MATERIAL, "MATERIAL", 0, "Material", "Use always material mode"},
+ {GP_BRUSH_MODE_VERTEXCOLOR, "VERTEXCOLOR", 0, "Vertex Color", "Use always Vertex Color mode"},
+ {0, NULL, 0, NULL, NULL}};
+
static EnumPropertyItem rna_enum_gpencil_brush_paint_icons_items[] = {
{GP_BRUSH_ICON_PENCIL, "PENCIL", ICON_GPBRUSH_PENCIL, "Pencil", ""},
{GP_BRUSH_ICON_PEN, "PEN", ICON_GPBRUSH_PEN, "Pen", ""},
@@ -359,7 +381,7 @@ static bool rna_BrushCapabilities_has_overlay_get(PointerRNA *ptr)
static bool rna_BrushCapabilitiesSculpt_has_persistence_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
- return br->sculpt_tool == SCULPT_TOOL_LAYER;
+ return ELEM(br->sculpt_tool, SCULPT_TOOL_LAYER, SCULPT_TOOL_CLOTH);
}
static bool rna_BrushCapabilitiesSculpt_has_pinch_factor_get(PointerRNA *ptr)
@@ -1519,7 +1541,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "use_strength_pressure", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_STENGTH_PRESSURE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_STRENGTH_PRESSURE);
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
RNA_def_property_ui_text(
prop, "Use Pressure Strength", "Use tablet pressure for color strength");
@@ -1640,6 +1662,24 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Mode", "Mode to draw boundary limits");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ prop = RNA_def_property(srna, "fill_layer_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "fill_layer_mode");
+ RNA_def_property_enum_items(prop, rna_enum_gpencil_fill_layers_modes_items);
+ RNA_def_property_ui_text(prop, "Layer Mode", "Layers used as boundaries");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
+ prop = RNA_def_property(srna, "fill_direction", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "fill_direction");
+ RNA_def_property_enum_items(prop, rna_enum_gpencil_fill_direction_items);
+ RNA_def_property_ui_text(prop, "Direction", "Direction of the fill");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
+ prop = RNA_def_property(srna, "brush_draw_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "brush_draw_mode");
+ RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_modes_items);
+ RNA_def_property_ui_text(prop, "Mode", "Preselected mode when using this brush");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
prop = RNA_def_property(srna, "trim", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_TRIM_STROKE);
RNA_def_property_boolean_default(prop, false);
@@ -1956,6 +1996,16 @@ static void rna_def_brush(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
+ static const EnumPropertyItem brush_cloth_simulation_area_type_items[] = {
+ {BRUSH_CLOTH_SIMULATION_AREA_LOCAL,
+ "LOCAL",
+ 0,
+ "Local",
+ "Simulates only a specific area arround the brush limited by a fixed radius"},
+ {BRUSH_CLOTH_SIMULATION_AREA_GLOBAL, "GLOBAL", 0, "Global", "Simulates the entire mesh"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
static const EnumPropertyItem brush_smooth_deform_type_items[] = {
{BRUSH_SMOOTH_DEFORM_LAPLACIAN,
"LAPLACIAN",
@@ -1973,7 +2023,7 @@ static void rna_def_brush(BlenderRNA *brna)
static const EnumPropertyItem brush_pose_deform_type_items[] = {
{BRUSH_POSE_DEFORM_ROTATE_TWIST, "ROTATE_TWIST", 0, "Rotate/Twist", ""},
{BRUSH_POSE_DEFORM_SCALE_TRASLATE, "SCALE_TRANSLATE", 0, "Scale/Translate", ""},
- {BRUSH_POSE_DEFORM_SQUASH_STRETCH, "SQUASH_STRETCH", 0, "Squash/Stretch", ""},
+ {BRUSH_POSE_DEFORM_SQUASH_STRETCH, "SQUASH_STRETCH", 0, "Squash & Stretch", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -2011,6 +2061,15 @@ static void rna_def_brush(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
+ static const EnumPropertyItem brush_boundary_deform_type_items[] = {
+ {BRUSH_BOUNDARY_DEFORM_BEND, "BEND", 0, "Bend", ""},
+ {BRUSH_BOUNDARY_DEFORM_EXPAND, "EXPAND", 0, "Expand", ""},
+ {BRUSH_BOUNDARY_DEFORM_INFLATE, "INFLATE", 0, "Inflate", ""},
+ {BRUSH_BOUNDARY_DEFORM_GRAB, "GRAB", 0, "Grab", ""},
+ {BRUSH_BOUNDARY_DEFORM_TWIST, "TWIST", 0, "Twist", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
srna = RNA_def_struct(brna, "Brush", "ID");
RNA_def_struct_ui_text(
srna, "Brush", "Brush data-block for storing brush settings for painting and sculpting");
@@ -2126,6 +2185,14 @@ static void rna_def_brush(BlenderRNA *brna)
prop, "Force Falloff", "Shape used in the brush to apply force to the cloth");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "cloth_simulation_area_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, brush_cloth_simulation_area_type_items);
+ RNA_def_property_ui_text(
+ prop,
+ "Simulation Area",
+ "Part of the mesh that is going to be simulated when the stroke is active");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "smooth_deform_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, brush_smooth_deform_type_items);
RNA_def_property_ui_text(prop, "Deformation", "Deformation type that is used in the brush");
@@ -2141,6 +2208,11 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Deformation", "Deformation type that is used in the brush");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "boundary_deform_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, brush_boundary_deform_type_items);
+ RNA_def_property_ui_text(prop, "Deformation", "Deformation type that is used in the brush");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "pose_deform_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, brush_pose_deform_type_items);
RNA_def_property_ui_text(prop, "Deformation", "Deformation type that is used in the brush");
@@ -2277,7 +2349,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(
prop,
"Wet Persistence",
- "Amount of wet paint that stays in the brush after applyig paint to the surface");
+ "Amount of wet paint that stays in the brush after applying paint to the surface");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_FACTOR);
@@ -2556,6 +2628,15 @@ static void rna_def_brush(BlenderRNA *brna)
"Area to apply deformation falloff to the effects of the simulation");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "cloth_constraint_softbody_strength", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "cloth_constraint_softbody_strength");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(
+ prop,
+ "Soft Body Influence",
+ "How much the simulation preserves the original shape, acting as a soft body");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "hardness", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "hardness");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -2767,11 +2848,32 @@ static void rna_def_brush(BlenderRNA *brna)
prop, "Keep Anchor Point", "Keep the position of the last segment in the IK chain fixed");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "use_pose_lock_rotation", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", BRUSH_POSE_USE_LOCK_ROTATION);
+ RNA_def_property_ui_text(prop,
+ "Lock Rotation When Scaling",
+ "Do not rotate the segment when using the scale deform mode");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "use_connected_only", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", BRUSH_USE_CONNECTED_ONLY);
RNA_def_property_ui_text(prop, "Connected Only", "Affect only topologically connected elements");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "use_cloth_pin_simulation_boundary", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", BRUSH_CLOTH_PIN_SIMULATION_BOUNDARY);
+ RNA_def_property_ui_text(
+ prop,
+ "Pin Simulation Boundary",
+ "Lock the position of the vertices in the simulation falloff area to avoid artifacts and "
+ "create a softer transitionwith with unnafected areas");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
+ prop = RNA_def_property(srna, "use_cloth_collision", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", BRUSH_CLOTH_USE_COLLISION);
+ RNA_def_property_ui_text(prop, "Enable Collision", "Collide with objects during the simulation");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "invert_to_scrape_fill", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_INVERT_TO_SCRAPE_FILL);
RNA_def_property_ui_text(prop,
diff --git a/source/blender/makesrna/intern/rna_cachefile.c b/source/blender/makesrna/intern/rna_cachefile.c
index f9275ef1993..c25cea1b4b3 100644
--- a/source/blender/makesrna/intern/rna_cachefile.c
+++ b/source/blender/makesrna/intern/rna_cachefile.c
@@ -174,6 +174,32 @@ static void rna_def_cachefile(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Object Paths", "Paths of the objects inside the Alembic archive");
+ /* ----------------- Alembic Velocity Attribute ----------------- */
+
+ prop = RNA_def_property(srna, "velocity_name", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop,
+ "Velocity Attribute",
+ "Name of the Alembic attribute used for generating motion blur data");
+ RNA_def_property_update(prop, 0, "rna_CacheFile_update");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
+ static const EnumPropertyItem velocity_unit_items[] = {
+ {CACHEFILE_VELOCITY_UNIT_SECOND, "SECOND", 0, "Second", ""},
+ {CACHEFILE_VELOCITY_UNIT_FRAME, "FRAME", 0, "Frame", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ prop = RNA_def_property(srna, "velocity_unit", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "velocity_unit");
+ RNA_def_property_enum_items(prop, velocity_unit_items);
+ RNA_def_property_ui_text(
+ prop,
+ "Velocity Unit",
+ "Define how the velocity vectors are interpreted with regard to time, 'frame' means "
+ "the delta time is 1 frame, 'second' means the delta time is 1 / FPS");
+ RNA_def_property_update(prop, 0, "rna_CacheFile_update");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
RNA_define_lib_overridable(false);
rna_def_cachefile_object_paths(brna, prop);
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 56ad8e2677b..60b6cc40792 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -702,7 +702,7 @@ static float rna_CurveMapping_evaluateF(struct CurveMapping *cumap,
static void rna_CurveMap_initialize(struct CurveMapping *cumap)
{
- BKE_curvemapping_initialize(cumap);
+ BKE_curvemapping_init(cumap);
}
#else
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c
index c8abf774561..e6dceb5af72 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -41,7 +41,7 @@ const EnumPropertyItem rna_enum_context_mode_items[] = {
{CTX_MODE_EDIT_ARMATURE, "EDIT_ARMATURE", 0, "Armature Edit", ""},
{CTX_MODE_EDIT_METABALL, "EDIT_METABALL", 0, "Metaball Edit", ""},
{CTX_MODE_EDIT_LATTICE, "EDIT_LATTICE", 0, "Lattice Edit", ""},
- {CTX_MODE_POSE, "POSE", 0, "Pose ", ""},
+ {CTX_MODE_POSE, "POSE", 0, "Pose", ""},
{CTX_MODE_SCULPT, "SCULPT", 0, "Sculpt", ""},
{CTX_MODE_PAINT_WEIGHT, "PAINT_WEIGHT", 0, "Weight Paint", ""},
{CTX_MODE_PAINT_VERTEX, "PAINT_VERTEX", 0, "Vertex Paint", ""},
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 8a3186ea7fe..1768d79fe8f 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -1191,9 +1191,9 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
RNA_def_property_ui_text(
prop,
"Object Font",
- "Use Objects as font characters (give font objects a common name "
+ "Use objects as font characters (give font objects a common name "
"followed by the character they represent, eg. 'family-a', 'family-b', etc, "
- "set this setting to 'family-', and turn on Vertex Duplication)");
+ "set this setting to 'family-', and turn on Vertex Instancing)");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop = RNA_def_property(srna, "body", PROP_STRING, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_curve_api.c b/source/blender/makesrna/intern/rna_curve_api.c
index 1207f19b95f..94fdb130026 100644
--- a/source/blender/makesrna/intern/rna_curve_api.c
+++ b/source/blender/makesrna/intern/rna_curve_api.c
@@ -37,7 +37,7 @@
#ifdef RNA_RUNTIME
static void rna_Curve_transform(Curve *cu, float *mat, bool shape_keys)
{
- BKE_curve_transform(cu, (float(*)[4])mat, shape_keys, true);
+ BKE_curve_transform(cu, (const float(*)[4])mat, shape_keys, true);
DEG_id_tag_update(&cu->id, 0);
}
diff --git a/source/blender/makesrna/intern/rna_curveprofile.c b/source/blender/makesrna/intern/rna_curveprofile.c
index ce91fc79085..ee1c659fcd5 100644
--- a/source/blender/makesrna/intern/rna_curveprofile.c
+++ b/source/blender/makesrna/intern/rna_curveprofile.c
@@ -146,7 +146,7 @@ static void rna_CurveProfile_evaluate(struct CurveProfile *profile,
static void rna_CurveProfile_initialize(struct CurveProfile *profile, int segments_len)
{
- BKE_curveprofile_initialize(profile, (short)segments_len);
+ BKE_curveprofile_init(profile, (short)segments_len);
}
static void rna_CurveProfile_update(struct CurveProfile *profile)
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index bb791dd6e2d..e94dad59176 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -4384,7 +4384,7 @@ void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropert
int tot = *totitem;
if (tot == 0) {
- *items = MEM_callocN(sizeof(EnumPropertyItem) * 8, __func__);
+ *items = MEM_callocN(sizeof(EnumPropertyItem[8]), __func__);
}
else if (tot >= 8 && (tot & (tot - 1)) == 0) {
/* power of two > 8 */
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 3ae16f8577a..d5449a69cf6 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -1635,7 +1635,7 @@ static void rna_def_fmodifier(BlenderRNA *brna)
/* TODO: setting this to true must ensure that all others in stack are turned off too... */
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_ACTIVE);
- RNA_def_property_ui_text(prop, "Active", "F-Curve Modifier is the one being edited ");
+ RNA_def_property_ui_text(prop, "Active", "F-Curve Modifier is the one being edited");
RNA_def_property_boolean_funcs(prop, NULL, "rna_FModifier_active_set");
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_active_update");
RNA_def_property_ui_icon(prop, ICON_RADIOBUT_OFF, 1);
diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c
index ab8f97ae3c2..0a58f8af593 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -1024,14 +1024,18 @@ static void rna_Fluid_flowtype_set(struct PointerRNA *ptr, int value)
FluidFlowSettings *settings = (FluidFlowSettings *)ptr->data;
if (value != settings->type) {
+ short prev_value = settings->type;
settings->type = value;
- /* Force flow source to mesh */
+ /* Force flow source to mesh for liquids.
+ * Also use different surface emission. Liquids should by default not emit around surface. */
if (value == FLUID_FLOW_TYPE_LIQUID) {
rna_Fluid_flowsource_set(ptr, FLUID_FLOW_SOURCE_MESH);
settings->surface_distance = 0.0f;
}
- else {
+ /* Use some surface emission when switching to a gas emitter. Gases should by default emit a
+ * bit around surface. */
+ if (prev_value == FLUID_FLOW_TYPE_LIQUID) {
settings->surface_distance = 1.5f;
}
}
@@ -1677,7 +1681,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.001, 1.0);
RNA_def_property_ui_range(prop, 0.01, 1.0, 0.05, -1);
RNA_def_property_ui_text(prop,
- "Obstacle-Fluid Threshold ",
+ "Obstacle-Fluid Threshold",
"Determines how much fluid is allowed in an obstacle cell "
"(higher values will tag a boundary cell as an obstacle easier "
"and reduce the boundary smoothening effect)");
@@ -2048,6 +2052,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
prop,
"Start",
"Frame on which the simulation starts. This is the first frame that will be baked");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "cache_frame_end", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "cache_frame_end");
@@ -2057,6 +2062,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
prop,
"End",
"Frame on which the simulation stops. This is the last frame that will be baked");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "cache_frame_offset", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "cache_frame_offset");
@@ -2066,6 +2072,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
"Offset",
"Frame offset that is used when loading the simulation from the cache. It is not considered "
"when baking the simulation, only when loading it");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "cache_frame_pause_data", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "cache_frame_pause_data");
@@ -2089,6 +2096,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
prop, NULL, "rna_Fluid_cachetype_mesh_set", "rna_Fluid_cachetype_mesh_itemf");
RNA_def_property_ui_text(
prop, "File Format", "Select the file format to be used for caching surface data");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset");
prop = RNA_def_property(srna, "cache_data_format", PROP_ENUM, PROP_NONE);
@@ -2098,6 +2106,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
prop, NULL, "rna_Fluid_cachetype_data_set", "rna_Fluid_cachetype_volume_itemf");
RNA_def_property_ui_text(
prop, "File Format", "Select the file format to be used for caching volumetric data");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
prop = RNA_def_property(srna, "cache_particle_format", PROP_ENUM, PROP_NONE);
@@ -2107,6 +2116,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
prop, NULL, "rna_Fluid_cachetype_particle_set", "rna_Fluid_cachetype_particle_itemf");
RNA_def_property_ui_text(
prop, "File Format", "Select the file format to be used for caching particle data");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
prop = RNA_def_property(srna, "cache_noise_format", PROP_ENUM, PROP_NONE);
@@ -2116,6 +2126,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
prop, NULL, "rna_Fluid_cachetype_noise_set", "rna_Fluid_cachetype_volume_itemf");
RNA_def_property_ui_text(
prop, "File Format", "Select the file format to be used for caching noise data");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_noisecache_reset");
prop = RNA_def_property(srna, "cache_type", PROP_ENUM, PROP_NONE);
@@ -2123,6 +2134,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
RNA_def_property_enum_items(prop, cache_types);
RNA_def_property_enum_funcs(prop, NULL, "rna_Fluid_cachetype_set", NULL);
RNA_def_property_ui_text(prop, "Type", "Change the cache type of the simulation");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_domain_data_reset");
prop = RNA_def_property(srna, "cache_resumable", PROP_BOOLEAN, PROP_NONE);
@@ -2133,6 +2145,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
"Additional data will be saved so that the bake jobs can be resumed after pausing. Because "
"more data will be written to disk it is recommended to avoid enabling this option when "
"baking at high resolutions");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
prop = RNA_def_property(srna, "cache_directory", PROP_STRING, PROP_DIRPATH);
@@ -2385,7 +2398,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "openvdb_cache_compress_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "openvdb_compression");
RNA_def_property_enum_items(prop, prop_compression_items);
- RNA_def_property_ui_text(prop, "Compression", "facession method to be used");
+ RNA_def_property_ui_text(prop, "Compression", "Compression method to be used");
prop = RNA_def_property(srna, "openvdb_data_depth", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "openvdb_data_depth");
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index e0bcdc504fb..1c43815d3a2 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -67,7 +67,6 @@ static const EnumPropertyItem image_source_items[] = {
# include "BKE_global.h"
-# include "GPU_draw.h"
# include "GPU_texture.h"
# include "IMB_imbuf.h"
@@ -200,7 +199,7 @@ static void rna_Image_gpu_texture_update(Main *UNUSED(bmain),
Image *ima = (Image *)ptr->owner_id;
if (!G.background) {
- GPU_free_image(ima);
+ BKE_image_free_gputextures(ima);
}
WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
@@ -516,7 +515,7 @@ static void rna_Image_pixels_set(PointerRNA *ptr, const float *values)
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID | IB_MIPMAP_INVALID;
BKE_image_mark_dirty(ima, ibuf);
if (!G.background) {
- GPU_free_image(ima);
+ BKE_image_free_gputextures(ima);
}
WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
}
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index 1dcb10ed466..6f876923e52 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -220,7 +220,7 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame)
BKE_imageuser_default(&iuser);
iuser.framenr = frame;
- GPUTexture *tex = GPU_texture_from_blender(image, &iuser, NULL, TEXTARGET_2D);
+ GPUTexture *tex = BKE_image_get_gpu_texture(image, &iuser, NULL);
if (tex == NULL) {
BKE_reportf(reports, RPT_ERROR, "Failed to load image texture '%s'", image->id.name + 2);
@@ -237,7 +237,7 @@ static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame)
BKE_image_tag_time(image);
- if (image->gputexture[TEXTARGET_2D] == NULL) {
+ if (image->gputexture[TEXTARGET_2D][0] == NULL) {
error = rna_Image_gl_load(image, reports, frame);
}
@@ -246,7 +246,7 @@ static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame)
static void rna_Image_gl_free(Image *image)
{
- GPU_free_image(image);
+ BKE_image_free_gputextures(image);
/* remove the nocollect flag, image is available for garbage collection again */
image->flag &= ~IMA_NOCOLLECT;
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index a8085c00cb3..8045279eef2 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -18,8 +18,7 @@
* \ingroup RNA
*/
-#ifndef __RNA_INTERNAL_H__
-#define __RNA_INTERNAL_H__
+#pragma once
#include "BLI_utildefines.h"
@@ -644,5 +643,3 @@ void rna_RenderPass_rect_set(PointerRNA *ptr, const float *values);
: -FLT_MAX, double \
: -DBL_MAX)
#endif
-
-#endif /* __RNA_INTERNAL_H__ */
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index 20c8743f768..01c406104d7 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -18,8 +18,7 @@
* \ingroup RNA
*/
-#ifndef __RNA_INTERNAL_TYPES_H__
-#define __RNA_INTERNAL_TYPES_H__
+#pragma once
#include "DNA_listBase.h"
@@ -569,5 +568,3 @@ struct BlenderRNA {
};
#define CONTAINER_RNA_ID(cont) (*(const char **)(((ContainerRNA *)(cont)) + 1))
-
-#endif /* __RNA_INTERNAL_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_mesh_utils.h b/source/blender/makesrna/intern/rna_mesh_utils.h
index 9c5b4f9d5b3..5e11be382ec 100644
--- a/source/blender/makesrna/intern/rna_mesh_utils.h
+++ b/source/blender/makesrna/intern/rna_mesh_utils.h
@@ -18,8 +18,7 @@
* \ingroup RNA
*/
-#ifndef __RNA_MESH_UTILS_H__
-#define __RNA_MESH_UTILS_H__
+#pragma once
/* Macros to help reduce code clutter in rna_mesh.c */
@@ -123,5 +122,3 @@
BKE_mesh_update_customdata_pointers(me, true); \
} \
}
-
-#endif /* __RNA_MESH_UTILS_H__ */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 86f05c350f3..05e11ffc919 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -302,7 +302,7 @@ const EnumPropertyItem rna_enum_modifier_triangulate_quad_method_items[] = {
{MOD_TRIANGULATE_QUAD_BEAUTY,
"BEAUTY",
0,
- "Beauty ",
+ "Beauty",
"Split the quads in nice triangles, slower method"},
{MOD_TRIANGULATE_QUAD_FIXED,
"FIXED",
@@ -1163,7 +1163,7 @@ static void rna_BevelModifier_update_segments(Main *bmain, Scene *scene, Pointer
BevelModifierData *bmd = (BevelModifierData *)ptr->data;
if (RNA_enum_get(ptr, "profile_type") == MOD_BEVEL_PROFILE_CUSTOM) {
short segments = (short)RNA_int_get(ptr, "segments");
- BKE_curveprofile_initialize(bmd->custom_profile, segments);
+ BKE_curveprofile_init(bmd->custom_profile, segments);
}
rna_Modifier_update(bmain, scene, ptr);
}
@@ -1699,6 +1699,51 @@ static bool rna_Modifier_show_expanded_get(PointerRNA *ptr)
return md->ui_expand_flag & (1 << 0);
}
+static int rna_MeshSequenceCacheModifier_has_velocity_get(PointerRNA *ptr)
+{
+# ifdef WITH_ALEMBIC
+ MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)ptr->data;
+ return ABC_has_vec3_array_property_named(mcmd->reader, mcmd->cache_file->velocity_name);
+# else
+ return false;
+ UNUSED_VARS(ptr);
+# endif
+}
+
+static int rna_MeshSequenceCacheModifier_read_velocity_get(PointerRNA *ptr)
+{
+# ifdef WITH_ALEMBIC
+ MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)ptr->data;
+
+ if (mcmd->num_vertices == 0) {
+ return 0;
+ }
+
+ if (mcmd->vertex_velocities) {
+ MEM_freeN(mcmd->vertex_velocities);
+ }
+
+ mcmd->vertex_velocities = MEM_mallocN(sizeof(MeshCacheVertexVelocity) * mcmd->num_vertices,
+ "Mesh Cache Velocities");
+
+ int num_read = ABC_read_velocity_cache(mcmd->reader,
+ mcmd->cache_file->velocity_name,
+ mcmd->last_lookup_time,
+ mcmd->velocity_scale * mcmd->velocity_delta,
+ mcmd->num_vertices,
+ (float *)mcmd->vertex_velocities);
+
+ if (num_read == -1 || num_read != mcmd->num_vertices) {
+ return false;
+ }
+
+ return true;
+# else
+ return false;
+ UNUSED_VARS(ptr);
+# endif
+}
+
#else
/* NOTE: *MUST* return subdivision_type property. */
@@ -5667,7 +5712,17 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 1, 1024);
RNA_def_property_ui_range(prop, 1, 32, 1, -1);
- RNA_def_property_ui_text(prop, "Resolution", "Resolution of the generated surface");
+ RNA_def_property_ui_text(
+ prop, "Render Resolution", "Resolution of the generated surface for rendering and baking");
+ RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
+
+ prop = RNA_def_property(srna, "viewport_resolution", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "viewport_resolution");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_range(prop, 1, 1024);
+ RNA_def_property_ui_range(prop, 1, 32, 1, -1);
+ RNA_def_property_ui_text(
+ prop, "Viewport Resolution", "Viewport resolution of the generated surface");
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
prop = RNA_def_property(srna, "spatial_size", PROP_INT, PROP_NONE);
@@ -5905,7 +5960,7 @@ static void rna_def_modifier_triangulate(BlenderRNA *brna)
static void rna_def_modifier_meshcache(BlenderRNA *brna)
{
static const EnumPropertyItem prop_format_type_items[] = {
- {MOD_MESHCACHE_TYPE_MDD, "MDD", 0, "MDD ", ""},
+ {MOD_MESHCACHE_TYPE_MDD, "MDD", 0, "MDD", ""},
{MOD_MESHCACHE_TYPE_PC2, "PC2", 0, "PC2", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -5926,7 +5981,7 @@ static void rna_def_modifier_meshcache(BlenderRNA *brna)
};
static const EnumPropertyItem prop_interpolation_type_items[] = {
- {MOD_MESHCACHE_INTERP_NONE, "NONE", 0, "None ", ""},
+ {MOD_MESHCACHE_INTERP_NONE, "NONE", 0, "None", ""},
{MOD_MESHCACHE_INTERP_LINEAR, "LINEAR", 0, "Linear", ""},
/* for cardinal we'd need to read 4x cache's */
// {MOD_MESHCACHE_INTERP_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
@@ -6066,6 +6121,22 @@ static void rna_def_modifier_meshcache(BlenderRNA *brna)
RNA_define_lib_overridable(false);
}
+static void rna_def_mesh_cache_velocities(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "MeshCacheVertexVelocity", NULL);
+ RNA_def_struct_ui_text(srna, "Mesh Cache Velocity", "Velocity attribute of an Alembic mesh");
+ RNA_def_struct_ui_icon(srna, ICON_VERTEXSEL);
+
+ prop = RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_float_sdna(prop, NULL, "vel");
+ RNA_def_property_ui_text(prop, "Velocity", "");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+}
+
static void rna_def_modifier_meshseqcache(BlenderRNA *brna)
{
StructRNA *srna;
@@ -6108,6 +6179,35 @@ static void rna_def_modifier_meshseqcache(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "velocity_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "velocity_scale");
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_text(
+ prop,
+ "Velocity Scale",
+ "Multiplier used to control the magnitude of the velocity vectors for time effects");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ /* -------------------------- Velocity Vectors -------------------------- */
+
+ prop = RNA_def_property(srna, "vertex_velocities", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "vertex_velocities", "num_vertices");
+ RNA_def_property_struct_type(prop, "MeshCacheVertexVelocity");
+ RNA_def_property_ui_text(
+ prop, "Fluid Mesh Vertices", "Vertices of the fluid mesh generated by simulation");
+
+ rna_def_mesh_cache_velocities(brna);
+
+ prop = RNA_def_property(srna, "has_velocity", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Has Velocity Cache", "");
+ RNA_def_property_boolean_funcs(prop, "rna_MeshSequenceCacheModifier_has_velocity_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop = RNA_def_property(srna, "read_velocity", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Read Velocity Cache", "");
+ RNA_def_property_boolean_funcs(prop, "rna_MeshSequenceCacheModifier_read_velocity_get", NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
RNA_define_lib_overridable(false);
}
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 0359b2ed959..af07185ab4a 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -6504,7 +6504,7 @@ static void def_cmp_channel_matte(StructRNA *srna)
static const EnumPropertyItem algorithm_items[] = {
{0, "SINGLE", 0, "Single", "Limit by single channel"},
- {1, "MAX", 0, "Max", "Limit by max of other channels "},
+ {1, "MAX", 0, "Max", "Limit by max of other channels"},
{0, NULL, 0, NULL, NULL},
};
@@ -8475,6 +8475,12 @@ static void rna_def_node_socket_interface(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Output", "True if the socket is an output, otherwise input");
+ prop = RNA_def_property(srna, "hide_value", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SOCK_HIDE_VALUE);
+ RNA_def_property_ui_text(
+ prop, "Hide Value", "Hide the socket input value even when the socket is not connected");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
+
/* registration */
prop = RNA_def_property(srna, "bl_socket_idname", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "typeinfo->idname");
@@ -9921,7 +9927,7 @@ static void rna_def_composite_nodetree(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_viewer_border", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NTREE_VIEWER_BORDER);
RNA_def_property_ui_text(
- prop, "Viewer Border", "Use boundaries for viewer nodes and composite backdrop");
+ prop, "Viewer Region", "Use boundaries for viewer nodes and composite backdrop");
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, "rna_NodeTree_update");
}
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 84b83bee089..08ca3f16b6d 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -193,6 +193,12 @@ static EnumPropertyItem instance_items_nogroup[] = {
INSTANCE_ITEMS_SHARED,
{0, NULL, 0, NULL, NULL},
};
+
+static EnumPropertyItem instance_items_pointcloud[] = {
+ {0, "NONE", 0, "None", ""},
+ {OB_DUPLIVERTS, "POINTS", 0, "Points", "Instantiate child objects on all points"},
+ {0, NULL, 0, NULL, NULL},
+};
#endif
#undef INSTANCE_ITEMS_SHARED
#undef INSTANCE_ITEM_COLLECTION
@@ -707,6 +713,9 @@ static const EnumPropertyItem *rna_Object_instance_type_itemf(bContext *UNUSED(C
if (ob->type == OB_EMPTY) {
item = instance_items;
}
+ else if (ob->type == OB_POINTCLOUD) {
+ item = instance_items_pointcloud;
+ }
else {
item = instance_items_nogroup;
}
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index af1f1847fc6..3067a5a9453 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -2887,7 +2887,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "userjit");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0, 1000);
- RNA_def_property_ui_text(prop, "P/F", "Emission locations / face (0 = automatic)");
+ RNA_def_property_ui_text(prop, "Particles/Face", "Emission locations per face (0 = automatic)");
RNA_def_property_update(prop, 0, "rna_Particle_reset");
prop = RNA_def_property(srna, "grid_resolution", PROP_INT, PROP_UNSIGNED);
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index 325c4e3caa9..fb550b38b31 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -35,6 +35,8 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "DEG_depsgraph_build.h"
+
#include "WM_types.h"
/* roles of objects in RigidBody Sims */
@@ -75,6 +77,11 @@ const EnumPropertyItem rna_enum_rigidbody_object_shape_items[] = {
"Mesh",
"Mesh consisting of triangles only, allowing for more detailed interactions than convex "
"hulls"},
+ {RB_SHAPE_COMPOUND,
+ "COMPOUND",
+ ICON_MESH_DATA,
+ "Compound Parent",
+ "Combines all of its direct rigid body children into one rigid object."},
{0, NULL, 0, NULL, NULL},
};
@@ -218,6 +225,7 @@ static void rna_RigidBodyOb_shape_update(Main *bmain, Scene *scene, PointerRNA *
Object *ob = (Object *)ptr->owner_id;
rna_RigidBodyOb_reset(bmain, scene, ptr);
+ DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
@@ -233,6 +241,16 @@ static void rna_RigidBodyOb_shape_reset(Main *UNUSED(bmain), Scene *scene, Point
}
}
+static void rna_RigidBodyOb_mesh_source_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ Object *ob = (Object *)ptr->owner_id;
+
+ rna_RigidBodyOb_reset(bmain, scene, ptr);
+ DEG_relations_tag_update(bmain);
+
+ WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
+}
+
static char *rna_RigidBodyOb_path(PointerRNA *UNUSED(ptr))
{
/* NOTE: this hardcoded path should work as long as only Objects have this */
@@ -1026,7 +1044,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Mesh Source", "Source of the mesh used to create collision shape");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
+ RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_mesh_source_update");
/* booleans */
prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 66698d60423..262c9f87b66 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2862,7 +2862,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
"3D Cursor",
"Draw stroke at 3D cursor location"},
/* Weird, GP_PROJECT_VIEWALIGN is inverted. */
- {0, "VIEW", ICON_RESTRICT_VIEW_ON, "View", "Stick stroke to the view "},
+ {0, "VIEW", ICON_RESTRICT_VIEW_ON, "View", "Stick stroke to the view"},
{GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_VIEW,
"SURFACE",
ICON_FACESEL,
@@ -3589,7 +3589,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna)
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, brush_size_unit_items);
RNA_def_property_ui_text(
- prop, "Radius Unit", "Measure brush size relative to the view or the scene ");
+ prop, "Radius Unit", "Measure brush size relative to the view or the scene");
}
static void rna_def_curve_paint_settings(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index a66e20258d2..06c73fbb19c 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -138,8 +138,7 @@ static void rna_SceneRender_get_frame_path(
}
static void rna_Scene_ray_cast(Scene *scene,
- Main *bmain,
- ViewLayer *view_layer,
+ Depsgraph *depsgraph,
float origin[3],
float direction[3],
float ray_dist,
@@ -151,8 +150,6 @@ static void rna_Scene_ray_cast(Scene *scene,
float r_obmat[16])
{
normalize_v3(direction);
-
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
SnapObjectContext *sctx = ED_transform_snap_object_context_create(scene, 0);
bool ret = ED_transform_snap_object_project_ray_ex(sctx,
@@ -292,9 +289,9 @@ void RNA_api_scene(StructRNA *srna)
/* Ray Cast */
func = RNA_def_function(srna, "ray_cast", "rna_Scene_ray_cast");
- RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Cast a ray onto in object space");
- parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Scene Layer");
+
+ parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", "The current dependency graph");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
/* ray start and end */
parm = RNA_def_float_vector(func, "origin", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 24c4818694f..fb2a60db0fd 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -231,7 +231,7 @@ static int rna_Area_ui_type_get(PointerRNA *ptr)
* the area type is changing.
* So manually do the lookup in those cases, but do not actually change area->type
* since that prevents a proper exit when the area type is changing.
- * Logic copied from `ED_area_initialize()`.*/
+ * Logic copied from `ED_area_init()`.*/
SpaceType *type = area->type;
if (type == NULL || area_changing) {
type = BKE_spacetype_from_id(area_type);
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index d360e37588c..0cfc6fd569c 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -872,7 +872,7 @@ static void rna_Sequence_input_set(PointerRNA *ptr,
Sequence *input = ptr_value.data;
if (BKE_sequencer_render_loop_check(input, seq)) {
- BKE_report(reports, RPT_ERROR, "Cannot reassign inputs: recursion detected.");
+ BKE_report(reports, RPT_ERROR, "Cannot reassign inputs: recursion detected");
return;
}
diff --git a/source/blender/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c
index e1970a57a91..7b039b91188 100644
--- a/source/blender/makesrna/intern/rna_shader_fx.c
+++ b/source/blender/makesrna/intern/rna_shader_fx.c
@@ -338,7 +338,7 @@ static void rna_def_shader_fx_pixel(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FX_PIXEL_FILTER_NEAREST);
- RNA_def_property_ui_text(prop, "Antialiasing", "Antialiase pixels");
+ RNA_def_property_ui_text(prop, "Antialiasing", "Antialias pixels");
RNA_def_property_update(prop, NC_OBJECT | ND_SHADERFX, "rna_ShaderFx_update");
}
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 27297a4d19a..b8500264e12 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -815,7 +815,7 @@ static void rna_trackingCameras_matrix_from_frame(ID *id,
MovieTrackingObject *object = find_object_for_reconstruction(tracking, reconstruction);
BKE_tracking_camera_get_reconstructed_interpolate(tracking, object, framenr, mat);
- memcpy(matrix, mat, sizeof(float) * 16);
+ memcpy(matrix, mat, sizeof(float[4][4]));
}
#else
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index bfc020afb41..90873fa73f4 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -179,6 +179,7 @@ static const EnumPropertyItem rna_enum_userdef_viewport_aa_items[] = {
# include "BKE_blender.h"
# include "BKE_global.h"
# include "BKE_idprop.h"
+# include "BKE_image.h"
# include "BKE_main.h"
# include "BKE_mesh_runtime.h"
# include "BKE_paint.h"
@@ -187,9 +188,9 @@ static const EnumPropertyItem rna_enum_userdef_viewport_aa_items[] = {
# include "DEG_depsgraph.h"
-# include "GPU_draw.h"
# include "GPU_extensions.h"
# include "GPU_select.h"
+# include "GPU_texture.h"
# include "BLF_api.h"
@@ -363,13 +364,14 @@ static void rna_userdef_load_ui_update(Main *UNUSED(bmain), Scene *UNUSED(scene)
static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
- GPU_set_anisotropic(U.anisotropic_filter);
+ GPU_samplers_free();
+ GPU_samplers_init();
rna_userdef_update(bmain, scene, ptr);
}
static void rna_userdef_gl_texture_limit_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
- GPU_free_images(bmain);
+ BKE_image_free_all_gputextures(bmain);
rna_userdef_update(bmain, scene, ptr);
}
@@ -1086,7 +1088,7 @@ int rna_show_statusbar_vram_editable(struct PointerRNA *UNUSED(ptr), const char
static size_t max_memory_in_megabytes(void)
{
/* Maximum addressable bytes on this platform. */
- const size_t limit_bytes = (((size_t)1) << ((sizeof(size_t) * 8) - 1));
+ const size_t limit_bytes = (((size_t)1) << ((sizeof(size_t[8])) - 1));
/* Convert it to megabytes and return. */
return (limit_bytes >> 20);
}
@@ -4593,7 +4595,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
"no matter opening direction");
static const EnumPropertyItem header_align_items[] = {
- {0, "NONE", 0, "Default", "Keep existing header alignment"},
+ {0, "NONE", 0, "Keep Existing", "Keep existing header alignment"},
{USER_HEADER_FROM_PREF, "TOP", 0, "Top", "Top aligned on load"},
{USER_HEADER_FROM_PREF | USER_HEADER_BOTTOM,
"BOTTOM",
diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h
index ba676bbe459..b011abf336d 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -18,8 +18,7 @@
* \ingroup modifiers
*/
-#ifndef __MOD_MODIFIERTYPES_H__
-#define __MOD_MODIFIERTYPES_H__
+#pragma once
#include "BKE_modifier.h"
@@ -94,5 +93,3 @@ void modifier_type_init(ModifierTypeInfo *types[]);
#ifdef __cplusplus
}
#endif
-
-#endif /* __MOD_MODIFIERTYPES_H__ */
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index b62c03d1b03..e7f47a09d95 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -165,10 +165,15 @@ static void deformVerts(ModifierData *md,
static void deformVertsEM(ModifierData *md,
const ModifierEvalContext *ctx,
struct BMEditMesh *em,
- Mesh *UNUSED(mesh),
+ Mesh *mesh,
float (*vertexCos)[3],
int numVerts)
{
+ if (mesh != NULL) {
+ deformVerts(md, ctx, mesh, vertexCos, numVerts);
+ return;
+ }
+
ArmatureModifierData *amd = (ArmatureModifierData *)md;
MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 48d69f8e02c..1c98cec915e 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -139,12 +139,11 @@ static int svert_sum_cmp(const void *e1, const void *e2)
if (sv1->sum_co > sv2->sum_co) {
return 1;
}
- else if (sv1->sum_co < sv2->sum_co) {
+ if (sv1->sum_co < sv2->sum_co) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
static void svert_from_mvert(SortVertsElem *sv,
@@ -826,10 +825,10 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
if (amd->curve_ob && amd->curve_ob->type != OB_CURVE) {
return true;
}
- else if (amd->start_cap && amd->start_cap->type != OB_MESH) {
+ if (amd->start_cap && amd->start_cap->type != OB_MESH) {
return true;
}
- else if (amd->end_cap && amd->end_cap->type != OB_MESH) {
+ if (amd->end_cap && amd->end_cap->type != OB_MESH) {
return true;
}
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 1d39aa786a5..08fd7fb229d 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -44,6 +44,7 @@
#include "BKE_lib_query.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_wrapper.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
@@ -180,6 +181,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
if (mesh_other) {
Object *object = ctx->object;
+ /* XXX This is utterly non-optimal, we may go from a bmesh to a mesh back to a bmesh!
+ * But for 2.90 better not try to be smart here. */
+ BKE_mesh_wrapper_ensure_mdata(mesh_other);
+
/* when one of objects is empty (has got no faces) we could speed up
* calculation a bit returning one of objects' derived meshes (or empty one)
* Returning mesh is depended on modifiers operation (sergey) */
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index f3ee14e0206..0cd3430f009 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -121,7 +121,7 @@ static void deformVerts(ModifierData *md,
&mesh_src->vdata, CD_CLOTH_ORCO, CD_CALLOC, NULL, mesh_src->totvert);
}
- memcpy(layerorco, kb->data, sizeof(float) * 3 * numVerts);
+ memcpy(layerorco, kb->data, sizeof(float[3]) * numVerts);
}
}
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index 760e4717b6d..42adf305ee9 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -150,10 +150,15 @@ static void deformVerts(ModifierData *md,
static void deformVertsEM(ModifierData *md,
const ModifierEvalContext *ctx,
BMEditMesh *em,
- Mesh *UNUSED(mesh),
+ Mesh *mesh,
float (*vertexCos)[3],
int numVerts)
{
+ if (mesh != NULL) {
+ deformVerts(md, ctx, mesh, vertexCos, numVerts);
+ return;
+ }
+
CurveModifierData *cmd = (CurveModifierData *)md;
bool use_dverts = false;
int defgrp_index = -1;
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index 0b205ec4fc5..c8f49694a2f 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -204,32 +204,36 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
BKE_reports_init(&reports, RPT_STORE);
/* Note: no islands precision for now here. */
- BKE_object_data_transfer_ex(ctx->depsgraph,
- scene,
- ob_source,
- ctx->object,
- result,
- dtmd->data_types,
- false,
- dtmd->vmap_mode,
- dtmd->emap_mode,
- dtmd->lmap_mode,
- dtmd->pmap_mode,
- space_transform,
- false,
- max_dist,
- dtmd->map_ray_radius,
- 0.0f,
- dtmd->layers_select_src,
- dtmd->layers_select_dst,
- dtmd->mix_mode,
- dtmd->mix_factor,
- dtmd->defgrp_name,
- invert_vgroup,
- &reports);
+ if (BKE_object_data_transfer_ex(ctx->depsgraph,
+ scene,
+ ob_source,
+ ctx->object,
+ result,
+ dtmd->data_types,
+ false,
+ dtmd->vmap_mode,
+ dtmd->emap_mode,
+ dtmd->lmap_mode,
+ dtmd->pmap_mode,
+ space_transform,
+ false,
+ max_dist,
+ dtmd->map_ray_radius,
+ 0.0f,
+ dtmd->layers_select_src,
+ dtmd->layers_select_dst,
+ dtmd->mix_mode,
+ dtmd->mix_factor,
+ dtmd->defgrp_name,
+ invert_vgroup,
+ &reports)) {
+ result->runtime.is_original = false;
+ }
if (BKE_reports_contain(&reports, RPT_ERROR)) {
- BKE_modifier_set_error(md, "%s", BKE_reports_string(&reports, RPT_ERROR));
+ const char *report_str = BKE_reports_string(&reports, RPT_ERROR);
+ BKE_modifier_set_error(md, "%s", report_str);
+ MEM_freeN((void *)report_str);
}
else if ((dtmd->data_types & DT_TYPE_LNOR) && !(me->flag & ME_AUTOSMOOTH)) {
BKE_modifier_set_error((ModifierData *)dtmd, "Enable 'Auto Smooth' in Object Data Properties");
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 9b9dd0a079c..191623112bb 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -103,9 +103,8 @@ static bool dependsOnTime(ModifierData *md)
if (dmd->texture) {
return BKE_texture_dependsOnTime(dmd->texture);
}
- else {
- return false;
- }
+
+ return false;
}
static bool dependsOnNormals(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index 4e46e135b72..d520cccf0a2 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -1180,9 +1180,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
BKE_id_free(NULL, split_m);
return explode;
}
- else {
- return explodeMesh(emd, psmd, ctx, scene, mesh);
- }
+
+ return explodeMesh(emd, psmd, ctx, scene, mesh);
}
return mesh;
}
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index c8cfc07562f..86592245368 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -23,6 +23,7 @@
#include "BLI_utildefines.h"
+#include "BLI_bitmap.h"
#include "BLI_math.h"
#include "BLT_translation.h"
@@ -40,6 +41,7 @@
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_wrapper.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
@@ -139,7 +141,10 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
struct HookData_cb {
float (*vertexCos)[3];
- MDeformVert *dvert;
+ /**
+ * When anything other than -1, use deform groups.
+ * This is not the same as checking `dvert` for NULL when we have edit-meshes.
+ */
int defgrp_index;
struct CurveMapping *curfalloff;
@@ -160,13 +165,27 @@ struct HookData_cb {
bool invert_vgroup;
};
+static BLI_bitmap *hook_index_array_to_bitmap(HookModifierData *hmd, const int numVerts)
+{
+ BLI_bitmap *indexar_used = BLI_BITMAP_NEW(numVerts, __func__);
+ int i;
+ int *index_pt;
+ for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) {
+ const int j = *index_pt;
+ if (j < numVerts) {
+ BLI_BITMAP_ENABLE(indexar_used, i);
+ }
+ }
+ return indexar_used;
+}
+
static float hook_falloff(const struct HookData_cb *hd, const float len_sq)
{
BLI_assert(hd->falloff_sq);
if (len_sq > hd->falloff_sq) {
return 0.0f;
}
- else if (len_sq > 0.0f) {
+ if (len_sq > 0.0f) {
float fac;
if (hd->falloff_type == eHook_Falloff_Const) {
@@ -226,7 +245,7 @@ static float hook_falloff(const struct HookData_cb *hd, const float len_sq)
}
}
-static void hook_co_apply(struct HookData_cb *hd, const int j)
+static void hook_co_apply(struct HookData_cb *hd, int j, const MDeformVert *dv)
{
float *co = hd->vertexCos[j];
float fac;
@@ -250,9 +269,9 @@ static void hook_co_apply(struct HookData_cb *hd, const int j)
}
if (fac) {
- if (hd->dvert) {
- fac *= hd->invert_vgroup ? 1.0f - BKE_defvert_find_weight(&hd->dvert[j], hd->defgrp_index) :
- BKE_defvert_find_weight(&hd->dvert[j], hd->defgrp_index);
+ if (dv != NULL) {
+ fac *= hd->invert_vgroup ? 1.0f - BKE_defvert_find_weight(dv, hd->defgrp_index) :
+ BKE_defvert_find_weight(dv, hd->defgrp_index);
}
if (fac) {
@@ -267,6 +286,7 @@ static void deformVerts_do(HookModifierData *hmd,
const ModifierEvalContext *UNUSED(ctx),
Object *ob,
Mesh *mesh,
+ BMEditMesh *em,
float (*vertexCos)[3],
int numVerts)
{
@@ -274,6 +294,7 @@ static void deformVerts_do(HookModifierData *hmd,
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_target->pose, hmd->subtarget);
float dmat[4][4];
int i, *index_pt;
+ MDeformVert *dvert;
struct HookData_cb hd;
const bool invert_vgroup = (hmd->flag & MOD_HOOK_INVERT_VGROUP) != 0;
@@ -283,12 +304,21 @@ static void deformVerts_do(HookModifierData *hmd,
}
if (hmd->curfalloff) {
- BKE_curvemapping_initialize(hmd->curfalloff);
+ BKE_curvemapping_init(hmd->curfalloff);
}
/* Generic data needed for applying per-vertex calculations (initialize all members) */
hd.vertexCos = vertexCos;
- MOD_get_vgroup(ob, mesh, hmd->name, &hd.dvert, &hd.defgrp_index);
+
+ MOD_get_vgroup(ob, mesh, hmd->name, &dvert, &hd.defgrp_index);
+ int cd_dvert_offset = -1;
+
+ if ((em != NULL) && (hd.defgrp_index != -1)) {
+ cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
+ if (cd_dvert_offset == -1) {
+ hd.defgrp_index = -1;
+ }
+ }
hd.curfalloff = hmd->curfalloff;
@@ -337,32 +367,62 @@ static void deformVerts_do(HookModifierData *hmd,
}
else if (hmd->indexar) { /* vertex indices? */
const int *origindex_ar;
-
/* if mesh is present and has original index data, use it */
if (mesh && (origindex_ar = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX))) {
- for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) {
- if (*index_pt < numVerts) {
- int j;
-
- for (j = 0; j < numVerts; j++) {
- if (origindex_ar[j] == *index_pt) {
- hook_co_apply(&hd, j);
- }
- }
+ int numVerts_orig = numVerts;
+ if (ob->type == OB_MESH) {
+ const Mesh *me_orig = ob->data;
+ numVerts_orig = me_orig->totvert;
+ }
+ BLI_bitmap *indexar_used = hook_index_array_to_bitmap(hmd, numVerts_orig);
+ for (i = 0; i < numVerts; i++) {
+ int i_orig = origindex_ar[i];
+ BLI_assert(i_orig < numVerts_orig);
+ if (BLI_BITMAP_TEST(indexar_used, i_orig)) {
+ hook_co_apply(&hd, i, dvert ? &dvert[i] : NULL);
}
}
+ MEM_freeN(indexar_used);
}
else { /* missing mesh or ORIGINDEX */
- for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) {
- if (*index_pt < numVerts) {
- hook_co_apply(&hd, *index_pt);
+ if ((em != NULL) && (hd.defgrp_index != -1)) {
+ BLI_assert(em->bm->totvert == numVerts);
+ BLI_bitmap *indexar_used = hook_index_array_to_bitmap(hmd, numVerts);
+ BMIter iter;
+ BMVert *v;
+ BM_ITER_MESH_INDEX (v, &iter, em->bm, BM_VERTS_OF_MESH, i) {
+ if (BLI_BITMAP_TEST(indexar_used, i)) {
+ const MDeformVert *dv = BM_ELEM_CD_GET_VOID_P(v, cd_dvert_offset);
+ hook_co_apply(&hd, i, dv);
+ }
+ }
+ MEM_freeN(indexar_used);
+ }
+ else {
+ for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) {
+ const int j = *index_pt;
+ if (j < numVerts) {
+ hook_co_apply(&hd, j, dvert ? &dvert[j] : NULL);
+ }
}
}
}
}
- else if (hd.dvert) { /* vertex group hook */
- for (i = 0; i < numVerts; i++) {
- hook_co_apply(&hd, i);
+ else if (hd.defgrp_index != -1) { /* vertex group hook */
+ if (em != NULL) {
+ BLI_assert(em->bm->totvert == numVerts);
+ BMIter iter;
+ BMVert *v;
+ BM_ITER_MESH_INDEX (v, &iter, em->bm, BM_VERTS_OF_MESH, i) {
+ const MDeformVert *dv = BM_ELEM_CD_GET_VOID_P(v, cd_dvert_offset);
+ hook_co_apply(&hd, i, dv);
+ }
+ }
+ else {
+ BLI_assert(dvert != NULL);
+ for (i = 0; i < numVerts; i++) {
+ hook_co_apply(&hd, i, &dvert[i]);
+ }
}
}
}
@@ -376,7 +436,7 @@ static void deformVerts(struct ModifierData *md,
HookModifierData *hmd = (HookModifierData *)md;
Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
- deformVerts_do(hmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
+ deformVerts_do(hmd, ctx, ctx->object, mesh_src, NULL, vertexCos, numVerts);
if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
@@ -391,14 +451,8 @@ static void deformVertsEM(struct ModifierData *md,
int numVerts)
{
HookModifierData *hmd = (HookModifierData *)md;
- Mesh *mesh_src = MOD_deform_mesh_eval_get(
- ctx->object, editData, mesh, NULL, numVerts, false, false);
-
- deformVerts_do(hmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
- if (!ELEM(mesh_src, NULL, mesh)) {
- BKE_id_free(NULL, mesh_src);
- }
+ deformVerts_do(hmd, ctx, ctx->object, mesh, mesh ? NULL : editData, vertexCos, numVerts);
}
static void panel_draw(const bContext *C, Panel *panel)
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index b1a9258ec51..bf891c4938b 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -130,10 +130,15 @@ static void deformVerts(ModifierData *md,
static void deformVertsEM(ModifierData *md,
const ModifierEvalContext *ctx,
struct BMEditMesh *em,
- struct Mesh *UNUSED(mesh),
+ struct Mesh *mesh,
float (*vertexCos)[3],
int numVerts)
{
+ if (mesh != NULL) {
+ deformVerts(md, ctx, mesh, vertexCos, numVerts);
+ return;
+ }
+
LatticeModifierData *lmd = (LatticeModifierData *)md;
MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */
diff --git a/source/blender/modifiers/intern/MOD_mask.cc b/source/blender/modifiers/intern/MOD_mask.cc
index 93fb7749392..c173ab52ce8 100644
--- a/source/blender/modifiers/intern/MOD_mask.cc
+++ b/source/blender/modifiers/intern/MOD_mask.cc
@@ -44,12 +44,7 @@
#include "BKE_lib_query.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
-
-/* SpaceType struct has a member called 'new' which obviously conflicts with C++
- * so temporarily redefining the new keyword to make it compile. */
-#define new extern_new
#include "BKE_screen.h"
-#undef new
#include "UI_interface.h"
#include "UI_resources.h"
@@ -82,13 +77,13 @@ static void requiredDataMask(Object *UNUSED(ob),
static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, void *userData)
{
- MaskModifierData *mmd = (MaskModifierData *)md;
+ MaskModifierData *mmd = reinterpret_cast<MaskModifierData *>(md);
walk(userData, ob, &mmd->ob_arm, IDWALK_CB_NOP);
}
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
{
- MaskModifierData *mmd = (MaskModifierData *)md;
+ MaskModifierData *mmd = reinterpret_cast<MaskModifierData *>(md);
if (mmd->ob_arm) {
bArmature *arm = (bArmature *)mmd->ob_arm->data;
/* Tag relationship in depsgraph, but also on the armature. */
@@ -311,7 +306,7 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
*/
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
{
- MaskModifierData *mmd = (MaskModifierData *)md;
+ MaskModifierData *mmd = reinterpret_cast<MaskModifierData *>(md);
Object *ob = ctx->object;
const bool invert_mask = mmd->flag & MOD_MASK_INV;
@@ -393,7 +388,7 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
ModifierData *md,
bool UNUSED(useRenderParams))
{
- MaskModifierData *mmd = (MaskModifierData *)md;
+ MaskModifierData *mmd = reinterpret_cast<MaskModifierData *>(md);
/* The object type check is only needed here in case we have a placeholder
* object assigned (because the library containing the armature is missing).
diff --git a/source/blender/modifiers/intern/MOD_meshcache_mdd.c b/source/blender/modifiers/intern/MOD_meshcache_mdd.c
index 60376f61708..cb150976ff5 100644
--- a/source/blender/modifiers/intern/MOD_meshcache_mdd.c
+++ b/source/blender/modifiers/intern/MOD_meshcache_mdd.c
@@ -160,7 +160,7 @@ bool MOD_meshcache_read_mdd_index(FILE *fp,
return false;
}
- if (BLI_fseek(fp, sizeof(float) * 3 * index * mdd_head.verts_tot, SEEK_CUR) != 0) {
+ if (BLI_fseek(fp, sizeof(float[3]) * index * mdd_head.verts_tot, SEEK_CUR) != 0) {
*err_str = "Failed to seek frame";
return false;
}
@@ -170,7 +170,7 @@ bool MOD_meshcache_read_mdd_index(FILE *fp,
float *vco = *vertexCos;
uint i;
for (i = mdd_head.verts_tot; i != 0; i--, vco += 3) {
- fread(vco, sizeof(float) * 3, 1, fp);
+ fread(vco, sizeof(float[3]), 1, fp);
# ifdef __LITTLE_ENDIAN__
BLI_endian_switch_float(vco + 0);
@@ -180,7 +180,7 @@ bool MOD_meshcache_read_mdd_index(FILE *fp,
}
#else
/* no blending */
- if (!fread(vertexCos, sizeof(float) * 3, mdd_head.verts_tot, f)) {
+ if (!fread(vertexCos, sizeof(float[3]), mdd_head.verts_tot, f)) {
*err_str = errno ? strerror(errno) : "Failed to read frame";
return false;
}
@@ -195,7 +195,7 @@ bool MOD_meshcache_read_mdd_index(FILE *fp,
uint i;
for (i = mdd_head.verts_tot; i != 0; i--, vco += 3) {
float tvec[3];
- fread(tvec, sizeof(float) * 3, 1, fp);
+ fread(tvec, sizeof(float[3]), 1, fp);
#ifdef __LITTLE_ENDIAN__
BLI_endian_switch_float(tvec + 0);
@@ -238,22 +238,19 @@ bool MOD_meshcache_read_mdd_frame(FILE *fp,
MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str)) {
return true;
}
- else {
- return false;
- }
+
+ return false;
}
- else {
- /* read both and interpolate */
- if ((BLI_fseek(fp, 0, SEEK_SET) == 0) &&
- MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str) &&
- (BLI_fseek(fp, 0, SEEK_SET) == 0) &&
- MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) {
- return true;
- }
- else {
- return false;
- }
+
+ /* read both and interpolate */
+ if ((BLI_fseek(fp, 0, SEEK_SET) == 0) &&
+ MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str) &&
+ (BLI_fseek(fp, 0, SEEK_SET) == 0) &&
+ MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) {
+ return true;
}
+
+ return false;
}
bool MOD_meshcache_read_mdd_times(const char *filepath,
diff --git a/source/blender/modifiers/intern/MOD_meshcache_pc2.c b/source/blender/modifiers/intern/MOD_meshcache_pc2.c
index 60011458c67..120d1d6d71a 100644
--- a/source/blender/modifiers/intern/MOD_meshcache_pc2.c
+++ b/source/blender/modifiers/intern/MOD_meshcache_pc2.c
@@ -146,7 +146,7 @@ bool MOD_meshcache_read_pc2_index(FILE *fp,
return false;
}
- if (BLI_fseek(fp, sizeof(float) * 3 * index * pc2_head.verts_tot, SEEK_CUR) != 0) {
+ if (BLI_fseek(fp, sizeof(float[3]) * index * pc2_head.verts_tot, SEEK_CUR) != 0) {
*err_str = "Failed to seek frame";
return false;
}
@@ -155,7 +155,7 @@ bool MOD_meshcache_read_pc2_index(FILE *fp,
float *vco = *vertexCos;
uint i;
for (i = pc2_head.verts_tot; i != 0; i--, vco += 3) {
- fread(vco, sizeof(float) * 3, 1, fp);
+ fread(vco, sizeof(float[3]), 1, fp);
#ifdef __BIG_ENDIAN__
BLI_endian_switch_float(vco + 0);
@@ -170,7 +170,7 @@ bool MOD_meshcache_read_pc2_index(FILE *fp,
uint i;
for (i = pc2_head.verts_tot; i != 0; i--, vco += 3) {
float tvec[3];
- fread(tvec, sizeof(float) * 3, 1, fp);
+ fread(tvec, sizeof(float[3]), 1, fp);
#ifdef __BIG_ENDIAN__
BLI_endian_switch_float(tvec + 0);
@@ -213,22 +213,19 @@ bool MOD_meshcache_read_pc2_frame(FILE *fp,
MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str)) {
return true;
}
- else {
- return false;
- }
+
+ return false;
}
- else {
- /* read both and interpolate */
- if ((BLI_fseek(fp, 0, SEEK_SET) == 0) &&
- MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str) &&
- (BLI_fseek(fp, 0, SEEK_SET) == 0) &&
- MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) {
- return true;
- }
- else {
- return false;
- }
+
+ /* read both and interpolate */
+ if ((BLI_fseek(fp, 0, SEEK_SET) == 0) &&
+ MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str) &&
+ (BLI_fseek(fp, 0, SEEK_SET) == 0) &&
+ MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) {
+ return true;
}
+
+ return false;
}
bool MOD_meshcache_read_pc2_times(const char *filepath,
diff --git a/source/blender/modifiers/intern/MOD_meshcache_util.h b/source/blender/modifiers/intern/MOD_meshcache_util.h
index 0a6c0e73632..74131099e3c 100644
--- a/source/blender/modifiers/intern/MOD_meshcache_util.h
+++ b/source/blender/modifiers/intern/MOD_meshcache_util.h
@@ -18,8 +18,7 @@
* \ingroup modifiers
*/
-#ifndef __MOD_MESHCACHE_UTIL_H__
-#define __MOD_MESHCACHE_UTIL_H__
+#pragma once
/* MOD_meshcache_mdd.c */
bool MOD_meshcache_read_mdd_index(FILE *fp,
@@ -73,5 +72,3 @@ void MOD_meshcache_calc_range(const float frame,
float *r_factor);
#define FRAME_SNAP_EPS 0.0001f
-
-#endif /* __MOD_MESHCACHE_UTIL_H__ */
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index 8f6676dd0b2..5513e6b4971 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -33,6 +33,8 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
+#include "MEM_guardedalloc.h"
+
#include "BKE_cachefile.h"
#include "BKE_context.h"
#include "BKE_lib_query.h"
@@ -65,6 +67,9 @@ static void initData(ModifierData *md)
mcmd->cache_file = NULL;
mcmd->object_path[0] = '\0';
mcmd->read_flag = MOD_MESHSEQ_READ_ALL;
+ mcmd->velocity_scale = 1.0f;
+ mcmd->vertex_velocities = NULL;
+ mcmd->num_vertices = 0;
mcmd->reader = NULL;
mcmd->reader_object_path[0] = '\0';
@@ -91,6 +96,10 @@ static void freeData(ModifierData *md)
mcmd->reader_object_path[0] = '\0';
BKE_cachefile_reader_free(mcmd->cache_file, &mcmd->reader);
}
+
+ if (mcmd->vertex_velocities) {
+ MEM_freeN(mcmd->vertex_velocities);
+ }
}
static bool isDisabled(const struct Scene *UNUSED(scene),
@@ -154,6 +163,17 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
Mesh *result = ABC_read_mesh(mcmd->reader, ctx->object, mesh, time, &err_str, mcmd->read_flag);
+ mcmd->velocity_delta = 1.0f;
+ if (mcmd->cache_file->velocity_unit == CACHEFILE_VELOCITY_UNIT_SECOND) {
+ mcmd->velocity_delta /= FPS;
+ }
+
+ mcmd->last_lookup_time = time;
+
+ if (result != NULL) {
+ mcmd->num_vertices = result->totvert;
+ }
+
if (err_str) {
BKE_modifier_set_error(md, "%s", err_str);
}
@@ -221,6 +241,8 @@ static void panel_draw(const bContext *C, Panel *panel)
uiItemR(layout, &ptr, "read_data", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
}
+ uiItemR(layout, &ptr, "velocity_scale", 0, NULL, ICON_NONE);
+
modifier_panel_end(layout, &ptr);
}
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 7039b24cfc6..f22ece11726 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -472,7 +472,7 @@ static bool is_valid_target(NormalEditModifierData *enmd)
if (enmd->mode == MOD_NORMALEDIT_MODE_RADIAL) {
return true;
}
- else if ((enmd->mode == MOD_NORMALEDIT_MODE_DIRECTIONAL) && enmd->target) {
+ if ((enmd->mode == MOD_NORMALEDIT_MODE_DIRECTIONAL) && enmd->target) {
return true;
}
BKE_modifier_set_error((ModifierData *)enmd, "Invalid target settings");
@@ -637,6 +637,8 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
CustomData_free_layers(pdata, CD_NORMAL, num_polys);
MEM_SAFE_FREE(loopnors);
+ result->runtime.is_original = false;
+
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 6374f081581..7b31886a220 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -59,7 +59,7 @@
#include "MOD_ui_common.h"
#ifdef WITH_OCEANSIM
-static void init_cache_data(Object *ob, struct OceanModifierData *omd)
+static void init_cache_data(Object *ob, struct OceanModifierData *omd, const int resolution)
{
const char *relbase = BKE_modifier_path_relbase_from_global(ob);
@@ -71,7 +71,7 @@ static void init_cache_data(Object *ob, struct OceanModifierData *omd)
omd->chop_amount,
omd->foam_coverage,
omd->foam_fade,
- omd->resolution);
+ resolution);
}
static void simulate_ocean_modifier(struct OceanModifierData *omd)
@@ -87,7 +87,11 @@ static void initData(ModifierData *md)
#ifdef WITH_OCEANSIM
OceanModifierData *omd = (OceanModifierData *)md;
+ /* Render resolution */
omd->resolution = 7;
+ /* Display resolution for the non-render case */
+ omd->viewport_resolution = 7;
+
omd->spatial_size = 50;
omd->wave_alignment = 0.0;
@@ -126,7 +130,7 @@ static void initData(ModifierData *md)
omd->spraylayername[0] = '\0'; /* layer name empty by default */
omd->ocean = BKE_ocean_add();
- BKE_ocean_init_from_modifier(omd->ocean, omd);
+ BKE_ocean_init_from_modifier(omd->ocean, omd, omd->viewport_resolution);
simulate_ocean_modifier(omd);
#else /* WITH_OCEANSIM */
/* unused */
@@ -164,7 +168,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
tomd->oceancache = NULL;
tomd->ocean = BKE_ocean_add();
- BKE_ocean_init_from_modifier(tomd->ocean, tomd);
+ BKE_ocean_init_from_modifier(tomd->ocean, tomd, tomd->viewport_resolution);
simulate_ocean_modifier(tomd);
#else /* WITH_OCEANSIM */
/* unused */
@@ -288,7 +292,7 @@ static void generate_ocean_geometry_uvs(void *__restrict userdata,
}
}
-static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig)
+static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, const int resolution)
{
Mesh *result;
@@ -297,10 +301,10 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig)
int num_verts;
int num_polys;
- const bool use_threading = omd->resolution > 4;
+ const bool use_threading = resolution > 4;
- gogd.rx = omd->resolution * omd->resolution;
- gogd.ry = omd->resolution * omd->resolution;
+ gogd.rx = resolution * resolution;
+ gogd.ry = resolution * resolution;
gogd.res_x = gogd.rx * omd->repeat_x;
gogd.res_y = gogd.ry * omd->repeat_y;
@@ -362,6 +366,9 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
Mesh *result = NULL;
OceanResult ocr;
+ const int resolution = (ctx->flag & MOD_APPLY_RENDER) ? omd->resolution :
+ omd->viewport_resolution;
+
MVert *mverts;
int cfra_for_cache;
@@ -383,7 +390,7 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
/* do ocean simulation */
if (omd->cached == true) {
if (!omd->oceancache) {
- init_cache_data(ob, omd);
+ init_cache_data(ob, omd, resolution);
}
BKE_ocean_simulate_cache(omd->oceancache, cfra_scene);
}
@@ -393,12 +400,12 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
* This function is only called on an original object when applying the modifier
* using the 'Apply Modifier' button, and thus it is not called frequently for
* simulation. */
- allocated_ocean |= BKE_ocean_ensure(omd);
+ allocated_ocean |= BKE_ocean_ensure(omd, resolution);
simulate_ocean_modifier(omd);
}
if (omd->geometry_mode == MOD_OCEAN_GEOM_GENERATE) {
- result = generate_ocean_geometry(omd, mesh);
+ result = generate_ocean_geometry(omd, mesh, resolution);
BKE_mesh_ensure_normals(result);
}
else if (omd->geometry_mode == MOD_OCEAN_GEOM_DISPLACE) {
@@ -558,7 +565,10 @@ static void panel_draw(const bContext *C, Panel *panel)
uiItemR(sub, &ptr, "repeat_x", 0, IFACE_("Repeat X"), ICON_NONE);
uiItemR(sub, &ptr, "repeat_y", 0, IFACE_("Y"), ICON_NONE);
}
- uiItemR(col, &ptr, "resolution", 0, NULL, ICON_NONE);
+
+ sub = uiLayoutColumn(col, true);
+ uiItemR(sub, &ptr, "viewport_resolution", 0, IFACE_("Resolution Viewport"), ICON_NONE);
+ uiItemR(sub, &ptr, "resolution", 0, IFACE_("Render"), ICON_NONE);
uiItemR(col, &ptr, "time", 0, NULL, ICON_NONE);
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index dd881f1ac74..d3d2f891929 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -198,12 +198,11 @@ static bool particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *ps
if (maxp > minp) {
return randp < minp || randp >= maxp;
}
- else if (maxp < minp) {
+ if (maxp < minp) {
return randp < minp && randp >= maxp;
}
- else {
- return true;
- }
+
+ return true;
return false;
}
@@ -443,7 +442,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
float angle = 2.0f * M_PI *
(pimd->rotation +
pimd->random_rotation * (psys_frand(psys, 19957323 + p) - 0.5f));
- float eul[3] = {0.0f, 0.0f, angle};
+ const float eul[3] = {0.0f, 0.0f, angle};
float rot[4];
eul_to_quat(rot, eul);
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index b9bb7add811..3bb7ecd43f4 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -301,7 +301,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
float totlen = len_v3(mtx_tx[3]);
if (totlen != 0.0f) {
- float zero[3] = {0.0f, 0.0f, 0.0f};
+ const float zero[3] = {0.0f, 0.0f, 0.0f};
float cp[3];
screw_ofs = closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec);
}
@@ -412,7 +412,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, (int)totvert);
if (mloopuv_layers_tot) {
- float zero_co[3] = {0};
+ const float zero_co[3] = {0};
plane_from_point_normal_v3(uv_axis_plane, zero_co, axis_vec);
}
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index a5f6be04a08..c40fbffc506 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -96,7 +96,7 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
if (!smd->target || smd->target->type != OB_MESH) {
return true;
}
- else if (smd->auxTarget && smd->auxTarget->type != OB_MESH) {
+ if (smd->auxTarget && smd->auxTarget->type != OB_MESH) {
return true;
}
return false;
diff --git a/source/blender/modifiers/intern/MOD_simulation.cc b/source/blender/modifiers/intern/MOD_simulation.cc
index 85d9b47a861..99cd582f37d 100644
--- a/source/blender/modifiers/intern/MOD_simulation.cc
+++ b/source/blender/modifiers/intern/MOD_simulation.cc
@@ -46,16 +46,11 @@
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_pointcloud.h"
+#include "BKE_screen.h"
#include "BKE_simulation.h"
#include "BLO_read_write.h"
-/* SpaceType struct has a member called 'new' which obviously conflicts with C++
- * so temporarily redefining the new keyword to make it compile. */
-#define new extern_new
-#include "BKE_screen.h"
-#undef new
-
#include "UI_interface.h"
#include "UI_resources.h"
@@ -71,7 +66,7 @@ using blender::float3;
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
{
- SimulationModifierData *smd = (SimulationModifierData *)md;
+ SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
if (smd->simulation) {
DEG_add_simulation_relation(ctx->node, smd->simulation, "Accessed Simulation");
}
@@ -79,7 +74,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
{
- SimulationModifierData *smd = (SimulationModifierData *)md;
+ SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
walk(userData, ob, (ID **)&smd->simulation, IDWALK_CB_USER);
}
@@ -87,21 +82,22 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
ModifierData *md,
bool UNUSED(useRenderParams))
{
- SimulationModifierData *smd = (SimulationModifierData *)md;
+ SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
return smd->simulation == nullptr;
}
static const ParticleSimulationState *find_particle_state(SimulationModifierData *smd)
{
- return (const ParticleSimulationState *)BKE_simulation_state_try_find_by_name_and_type(
- smd->simulation, smd->data_path, SIM_TYPE_NAME_PARTICLE_SIMULATION);
+ return reinterpret_cast<const ParticleSimulationState *>(
+ BKE_simulation_state_try_find_by_name_and_type(
+ smd->simulation, smd->data_path, SIM_TYPE_NAME_PARTICLE_SIMULATION));
}
static PointCloud *modifyPointCloud(ModifierData *md,
const ModifierEvalContext *UNUSED(ctx),
PointCloud *input_pointcloud)
{
- SimulationModifierData *smd = (SimulationModifierData *)md;
+ SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
const ParticleSimulationState *state = find_particle_state(smd);
if (state == nullptr) {
return input_pointcloud;
@@ -112,12 +108,14 @@ static PointCloud *modifyPointCloud(ModifierData *md,
return pointcloud;
}
- const float3 *positions = (const float3 *)CustomData_get_layer_named(
- &state->attributes, CD_PROP_FLOAT3, "Position");
+ const float3 *positions = static_cast<const float3 *>(
+ CustomData_get_layer_named(&state->attributes, CD_PROP_FLOAT3, "Position"));
+ const float *radii = static_cast<const float *>(
+ CustomData_get_layer_named(&state->attributes, CD_PROP_FLOAT, "Radius"));
memcpy(pointcloud->co, positions, sizeof(float3) * state->tot_particles);
for (int i = 0; i < state->tot_particles; i++) {
- pointcloud->radius[i] = 0.03f;
+ pointcloud->radius[i] = radii[i];
}
return pointcloud;
@@ -147,20 +145,20 @@ static void panelRegister(ARegionType *region_type)
static void blendWrite(BlendWriter *writer, const ModifierData *md)
{
- const SimulationModifierData *smd = (const SimulationModifierData *)md;
+ const SimulationModifierData *smd = reinterpret_cast<const SimulationModifierData *>(md);
BLO_write_string(writer, smd->data_path);
}
static void blendRead(BlendDataReader *reader, ModifierData *md)
{
- SimulationModifierData *smd = (SimulationModifierData *)md;
+ SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
BLO_read_data_address(reader, &smd->data_path);
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
- const SimulationModifierData *smd = (const SimulationModifierData *)md;
- SimulationModifierData *tsmd = (SimulationModifierData *)target;
+ const SimulationModifierData *smd = reinterpret_cast<const SimulationModifierData *>(md);
+ SimulationModifierData *tsmd = reinterpret_cast<SimulationModifierData *>(target);
BKE_modifier_copydata_generic(md, target, flag);
if (smd->data_path != nullptr) {
@@ -170,7 +168,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
static void freeData(ModifierData *md)
{
- SimulationModifierData *smd = (SimulationModifierData *)md;
+ SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
if (smd->data_path) {
MEM_freeN(smd->data_path);
}
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 8f0174fe6d9..797d9e9e251 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -222,9 +222,8 @@ static bool skin_frame_find_contained_faces(const Frame *frame, BMFace *fill_fac
if (diag) {
return BM_edge_face_pair(diag, &fill_faces[0], &fill_faces[1]);
}
- else {
- return false;
- }
+
+ return false;
}
/* Returns true if hull is successfully built, false otherwise */
@@ -460,7 +459,7 @@ static void node_frames_init(SkinNode *nf, int totframe)
}
static void create_frame(
- Frame *frame, const float co[3], const float radius[2], float mat[3][3], float offset)
+ Frame *frame, const float co[3], const float radius[2], const float mat[3][3], float offset)
{
float rx[3], ry[3], rz[3];
int i;
@@ -773,6 +772,11 @@ static EMat *build_edge_mats(const MVertSkin *vs,
*has_valid_root = true;
}
+ else if (totedge == 0) {
+ /* Vertex-only mesh is valid, mark valid root as well (will display error otherwise). */
+ *has_valid_root = true;
+ break;
+ }
}
}
@@ -814,9 +818,8 @@ static int calc_edge_subdivisions(const MVert *mvert,
if (v1_branch && v2_branch) {
return 2;
}
- else {
- return 0;
- }
+
+ return 0;
}
avg_radius = half_v2(evs[0]->radius) + half_v2(evs[1]->radius);
@@ -1278,7 +1281,7 @@ static void skin_choose_quad_bridge_order(BMVert *a[4], BMVert *b[4], int best_o
if (len < shortest_len) {
shortest_len = len;
- memcpy(best_order, orders[i], sizeof(int) * 4);
+ memcpy(best_order, orders[i], sizeof(int[4]));
}
}
}
diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index 7e5e4ecd9d3..818327e120b 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -182,7 +182,7 @@ static void mesh_calc_hq_normal(Mesh *mesh, float (*poly_nors)[3], float (*r_ver
/* -------------------------------------------------------------------- */
/** \name Main Solidify Function
* \{ */
-
+/* NOLINTNEXTLINE: readability-function-size */
Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
{
Mesh *result;
@@ -355,7 +355,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
}
if (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) {
- vert_nors = MEM_calloc_arrayN(numVerts, 3 * sizeof(float), "mod_solid_vno_hq");
+ vert_nors = MEM_calloc_arrayN(numVerts, sizeof(float[3]), "mod_solid_vno_hq");
mesh_calc_hq_normal(mesh, poly_nors, vert_nors);
}
@@ -726,13 +726,13 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
#endif
/* same as EM_solidify() in editmesh_lib.c */
float *vert_angles = MEM_calloc_arrayN(
- numVerts, 2 * sizeof(float), "mod_solid_pair"); /* 2 in 1 */
+ numVerts, sizeof(float[2]), "mod_solid_pair"); /* 2 in 1 */
float *vert_accum = vert_angles + numVerts;
uint vidx;
uint i;
if (vert_nors == NULL) {
- vert_nors = MEM_malloc_arrayN(numVerts, 3 * sizeof(float), "mod_solid_vno");
+ vert_nors = MEM_malloc_arrayN(numVerts, sizeof(float[3]), "mod_solid_vno");
for (i = 0, mv = mvert; i < numVerts; i++, mv++) {
normal_short_to_float_v3(vert_nors[i], mv->no);
}
@@ -1044,7 +1044,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
const bool do_side_normals = !(result->runtime.cd_dirty_vert & CD_MASK_NORMAL);
/* annoying to allocate these since we only need the edge verts, */
float(*edge_vert_nos)[3] = do_side_normals ?
- MEM_calloc_arrayN(numVerts, 3 * sizeof(float), __func__) :
+ MEM_calloc_arrayN(numVerts, sizeof(float[3]), __func__) :
NULL;
float nor[3];
#endif
diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 423a6b4458a..1e0269617ec 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -132,6 +132,7 @@ static int comp_float_int_pair(const void *a, const void *b)
return (int)(x->angle > y->angle) - (int)(x->angle < y->angle);
}
+/* NOLINTNEXTLINE: readability-function-size */
Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
const ModifierEvalContext *ctx,
Mesh *mesh)
@@ -479,12 +480,12 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
old_edge_vert_ref->edges_len++;
break;
}
- else if (vm[orig_medge[edge].v1] == vs[1 - j]) {
+ if (vm[orig_medge[edge].v1] == vs[1 - j]) {
invalid_edge_index = edge + 1;
invalid_edge_reversed = (j == 0);
break;
}
- else if (vm[orig_medge[edge].v2] == vs[1 - j]) {
+ if (vm[orig_medge[edge].v2] == vs[1 - j]) {
invalid_edge_index = edge + 1;
invalid_edge_reversed = (j == 1);
break;
@@ -936,7 +937,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
}
break;
}
- else if (edge->faces[0] == eg_track_faces[0]) {
+ if (edge->faces[0] == eg_track_faces[0]) {
insert_at_start = true;
eg_track_faces[0] = edge->faces[1];
found_edge = edge;
@@ -945,14 +946,14 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
}
break;
}
- else if (edge->faces[1] != NULL) {
+ if (edge->faces[1] != NULL) {
if (edge->faces[1] == eg_track_faces[1]) {
insert_at_start = false;
eg_track_faces[1] = edge->faces[0];
found_edge = edge;
break;
}
- else if (edge->faces[1] == eg_track_faces[0]) {
+ if (edge->faces[1] == eg_track_faces[0]) {
insert_at_start = true;
eg_track_faces[0] = edge->faces[0];
found_edge = edge;
diff --git a/source/blender/modifiers/intern/MOD_solidify_util.h b/source/blender/modifiers/intern/MOD_solidify_util.h
index 6ab4734c451..e9f0709f7ea 100644
--- a/source/blender/modifiers/intern/MOD_solidify_util.h
+++ b/source/blender/modifiers/intern/MOD_solidify_util.h
@@ -18,8 +18,7 @@
* \ingroup modifiers
*/
-#ifndef __MOD_SOLIDIFY_UTIL_H__
-#define __MOD_SOLIDIFY_UTIL_H__
+#pragma once
/* MOD_solidify_extrude.c */
Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md,
@@ -30,5 +29,3 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md,
Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
const ModifierEvalContext *ctx,
Mesh *mesh);
-
-#endif /* __MOD_SOLIDIFY_UTIL_H__ */
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 6a0e82a686b..962e93be215 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -372,9 +372,8 @@ BLI_INLINE uint nearestVert(SDefBindCalcData *const data, const float point_co[3
len_squared_v3v3(point_co, data->targetCos[edge->v2])) {
return edge->v1;
}
- else {
- return edge->v2;
- }
+
+ return edge->v2;
}
BLI_INLINE int isPolyValid(const float coords[][2], const uint nr)
@@ -450,7 +449,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
SDefBindWeightData *bwdata;
SDefBindPoly *bpoly;
- float world[3] = {0.0f, 0.0f, 1.0f};
+ const float world[3] = {0.0f, 0.0f, 1.0f};
float avg_point_dist = 0.0f;
float tot_weight = 0.0f;
int inf_weight_flags = 0;
@@ -1283,7 +1282,7 @@ static void surfacedeformModifier_do(ModifierData *md,
BKE_modifier_set_error(md, "Vertices changed from %u to %u", smd->numverts, numverts);
return;
}
- else if (smd->numpoly != tnumpoly) {
+ if (smd->numpoly != tnumpoly) {
BKE_modifier_set_error(md, "Target polygons changed from %u to %u", smd->numpoly, tnumpoly);
return;
}
diff --git a/source/blender/modifiers/intern/MOD_ui_common.c b/source/blender/modifiers/intern/MOD_ui_common.c
index 01b9e972086..8de4b042eb3 100644
--- a/source/blender/modifiers/intern/MOD_ui_common.c
+++ b/source/blender/modifiers/intern/MOD_ui_common.c
@@ -179,12 +179,11 @@ static int modifier_is_simulation(ModifierData *md)
return 1;
}
/* Particle Tab */
- else if (md->type == eModifierType_ParticleSystem) {
+ if (md->type == eModifierType_ParticleSystem) {
return 2;
}
- else {
- return 0;
- }
+
+ return 0;
}
static bool modifier_can_delete(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_ui_common.h b/source/blender/modifiers/intern/MOD_ui_common.h
index 59c0fe1c413..cac8806a2bf 100644
--- a/source/blender/modifiers/intern/MOD_ui_common.h
+++ b/source/blender/modifiers/intern/MOD_ui_common.h
@@ -18,8 +18,7 @@
* \ingroup modifiers
*/
-#ifndef __MOD_UI_COMMON_H__
-#define __MOD_UI_COMMON_H__
+#pragma once
/* so modifier types match their defines */
#include "MOD_modifiertypes.h"
@@ -66,5 +65,3 @@ struct PanelType *modifier_subpanel_register(struct ARegionType *region_type,
#ifdef __cplusplus
}
#endif
-
-#endif /* __MOD_UI_COMMON_H__ */
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index c6dff375109..179996d5acf 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -143,10 +143,9 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd,
MEM_freeN(done);
return;
}
- else {
- /* if there are no UVs, default to local */
- texmapping = MOD_DISP_MAP_LOCAL;
- }
+
+ /* if there are no UVs, default to local */
+ texmapping = MOD_DISP_MAP_LOCAL;
}
MVert *mv = mesh->mvert;
diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h
index a05e25d204c..05a24b92242 100644
--- a/source/blender/modifiers/intern/MOD_util.h
+++ b/source/blender/modifiers/intern/MOD_util.h
@@ -18,8 +18,7 @@
* \ingroup modifiers
*/
-#ifndef __MOD_UTIL_H__
-#define __MOD_UTIL_H__
+#pragma once
/* so modifier types match their defines */
#include "MOD_modifiertypes.h"
@@ -60,4 +59,3 @@ void MOD_depsgraph_update_object_bone_relation(struct DepsNodeHandle *node,
struct Object *object,
const char *bonename,
const char *description);
-#endif /* __MOD_UTIL_H__ */
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 6f261f9f67a..361c778bb95 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -308,6 +308,8 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
}
}
+ mesh->runtime.is_original = false;
+
/* Mark tessellated CD layers as dirty. */
mesh->runtime.cd_dirty_vert |= CD_MASK_TESSLOOPNORMAL;
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index 4aca3c28ed8..05224e1ffaa 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -49,7 +49,9 @@
#include "MOD_ui_common.h"
#include "MOD_util.h"
-static void uv_warp_from_mat4_pair(float uv_dst[2], const float uv_src[2], float warp_mat[4][4])
+static void uv_warp_from_mat4_pair(float uv_dst[2],
+ const float uv_src[2],
+ const float warp_mat[4][4])
{
float tuv[3] = {0.0f};
@@ -185,7 +187,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
mul_m4_m4m4(warp_mat, mat_cent, warp_mat);
}
- int shuf_indices[4] = {axis_u, axis_v, -1, 3};
+ const int shuf_indices[4] = {axis_u, axis_v, -1, 3};
shuffle_m4(shuf_mat, shuf_indices);
mul_m4_m4m4(warp_mat, shuf_mat, warp_mat);
transpose_m4(shuf_mat);
@@ -233,6 +235,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* XXX TODO is this still needed? */
// me_eval->dirty |= DM_DIRTY_TESS_CDLAYERS;
+ mesh->runtime.is_original = false;
+
return mesh;
}
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index cbe774e91da..45252fed031 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -123,9 +123,8 @@ static bool dependsOnTime(ModifierData *md)
if (wmd->texture) {
return BKE_texture_dependsOnTime(wmd->texture);
}
- else {
- return false;
- }
+
+ return false;
}
static void freeData(ModifierData *md)
@@ -236,7 +235,7 @@ static void warpModifier_do(WarpModifierData *wmd,
}
if (wmd->curfalloff) {
- BKE_curvemapping_initialize(wmd->curfalloff);
+ BKE_curvemapping_init(wmd->curfalloff);
}
invert_m4_m4(obinv, ob->obmat);
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index f174b6d5aa4..744bab02c56 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -677,6 +677,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* Currently Modifier stack assumes there is no poly normal data passed around... */
CustomData_free_layers(pdata, CD_NORMAL, numPolys);
+
+ result->runtime.is_original = false;
+
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index 54d3aa46344..4ee1f9f669a 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -83,7 +83,7 @@ void weightvg_do_map(
}
if (cmap && falloff_type == MOD_WVG_MAPPING_CURVE) {
- BKE_curvemapping_initialize(cmap);
+ BKE_curvemapping_init(cmap);
}
/* Map each weight (vertex) to its new value, accordingly to the chosen mode. */
@@ -382,4 +382,4 @@ void weightvg_ui_common(const bContext *C, PointerRNA *ob_ptr, PointerRNA *ptr,
}
}
}
-} \ No newline at end of file
+}
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h
index 725574dc0a5..c00acd27d38 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.h
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.h
@@ -21,8 +21,7 @@
* \ingroup modifiers
*/
-#ifndef __MOD_WEIGHTVG_UTIL_H__
-#define __MOD_WEIGHTVG_UTIL_H__
+#pragma once
struct CurveMapping;
struct MDeformVert;
@@ -92,4 +91,3 @@ void weightvg_update_vg(struct MDeformVert *dvert,
const bool do_normalize);
void weightvg_ui_common(const bContext *C, PointerRNA *ob_ptr, PointerRNA *ptr, uiLayout *layout);
-#endif /* __MOD_WEIGHTVG_UTIL_H__ */
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 8039856172a..4f67fd88d4e 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -72,7 +72,7 @@ static void initData(ModifierData *md)
wmd->default_weight = 0.0f;
wmd->cmap_curve = BKE_curvemapping_add(1, 0.0, 0.0, 1.0, 1.0);
- BKE_curvemapping_initialize(wmd->cmap_curve);
+ BKE_curvemapping_init(wmd->cmap_curve);
wmd->rem_threshold = 0.01f;
wmd->add_threshold = 0.01f;
@@ -312,6 +312,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
MEM_freeN(new_w);
MEM_freeN(dw);
+ mesh->runtime.is_original = false;
+
/* Return the vgroup-modified mesh. */
return mesh;
}
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index d1c618df68b..649481a7023 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -95,16 +95,16 @@ static float mix_weight(float weight, float weight2, char mix_mode)
if (mix_mode == MOD_WVG_MIX_SET) {
return weight2;
}
- else if (mix_mode == MOD_WVG_MIX_ADD) {
+ if (mix_mode == MOD_WVG_MIX_ADD) {
return (weight + weight2);
}
- else if (mix_mode == MOD_WVG_MIX_SUB) {
+ if (mix_mode == MOD_WVG_MIX_SUB) {
return (weight - weight2);
}
- else if (mix_mode == MOD_WVG_MIX_MUL) {
+ if (mix_mode == MOD_WVG_MIX_MUL) {
return (weight * weight2);
}
- else if (mix_mode == MOD_WVG_MIX_DIV) {
+ if (mix_mode == MOD_WVG_MIX_DIV) {
/* Avoid dividing by zero (or really small values). */
if (weight2 < 0.0f && weight2 > -MOD_WVG_ZEROFLOOR) {
weight2 = -MOD_WVG_ZEROFLOOR;
@@ -114,15 +114,14 @@ static float mix_weight(float weight, float weight2, char mix_mode)
}
return (weight / weight2);
}
- else if (mix_mode == MOD_WVG_MIX_DIF) {
+ if (mix_mode == MOD_WVG_MIX_DIF) {
return (weight < weight2 ? weight2 - weight : weight - weight2);
}
- else if (mix_mode == MOD_WVG_MIX_AVG) {
+ if (mix_mode == MOD_WVG_MIX_AVG) {
return (weight + weight2) * 0.5f;
}
- else {
- return weight2;
- }
+
+ return weight2;
}
/**************************************
@@ -456,6 +455,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
MEM_freeN(dw2);
MEM_SAFE_FREE(indices);
+ mesh->runtime.is_original = false;
+
/* Return the vgroup-modified mesh. */
return mesh;
}
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 0668a7a086f..b23eb997f61 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -637,6 +637,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
TIMEIT_END(perf);
#endif
+ mesh->runtime.is_original = false;
+
/* Return the vgroup-modified mesh. */
return mesh;
}
diff --git a/source/blender/modifiers/intern/MOD_weld.c b/source/blender/modifiers/intern/MOD_weld.c
index cf92da1b0e6..a89209f5dbb 100644
--- a/source/blender/modifiers/intern/MOD_weld.c
+++ b/source/blender/modifiers/intern/MOD_weld.c
@@ -1850,23 +1850,22 @@ static Mesh *weldModifier_doWeld(WeldModifierData *wmd, const ModifierEvalContex
&iter, wp, weld_mesh.wloop, mloop, weld_mesh.loop_map, group_buffer)) {
continue;
}
- else {
- if (wp->poly_dst != OUT_OF_CONTEXT) {
- continue;
- }
- while (weld_iter_loop_of_poly_next(&iter)) {
- customdata_weld(&mesh->ldata, &result->ldata, group_buffer, iter.group_len, loop_cur);
- uint v = vert_final[iter.v];
- uint e = edge_final[iter.e];
- r_ml->v = v;
- r_ml->e = e;
- r_ml++;
- loop_cur++;
- if (iter.type) {
- result->medge[e].flag &= ~ME_LOOSEEDGE;
- }
- BLI_assert((result->medge[e].flag & ME_LOOSEEDGE) == 0);
+
+ if (wp->poly_dst != OUT_OF_CONTEXT) {
+ continue;
+ }
+ while (weld_iter_loop_of_poly_next(&iter)) {
+ customdata_weld(&mesh->ldata, &result->ldata, group_buffer, iter.group_len, loop_cur);
+ uint v = vert_final[iter.v];
+ uint e = edge_final[iter.e];
+ r_ml->v = v;
+ r_ml->e = e;
+ r_ml++;
+ loop_cur++;
+ if (iter.type) {
+ result->medge[e].flag &= ~ME_LOOSEEDGE;
}
+ BLI_assert((result->medge[e].flag & ME_LOOSEEDGE) == 0);
}
}
@@ -1885,24 +1884,24 @@ static Mesh *weldModifier_doWeld(WeldModifierData *wmd, const ModifierEvalContex
&iter, wp, weld_mesh.wloop, mloop, weld_mesh.loop_map, group_buffer)) {
continue;
}
- else {
- if (wp->poly_dst != OUT_OF_CONTEXT) {
- continue;
- }
- while (weld_iter_loop_of_poly_next(&iter)) {
- customdata_weld(&mesh->ldata, &result->ldata, group_buffer, iter.group_len, loop_cur);
- uint v = vert_final[iter.v];
- uint e = edge_final[iter.e];
- r_ml->v = v;
- r_ml->e = e;
- r_ml++;
- loop_cur++;
- if (iter.type) {
- result->medge[e].flag &= ~ME_LOOSEEDGE;
- }
- BLI_assert((result->medge[e].flag & ME_LOOSEEDGE) == 0);
+
+ if (wp->poly_dst != OUT_OF_CONTEXT) {
+ continue;
+ }
+ while (weld_iter_loop_of_poly_next(&iter)) {
+ customdata_weld(&mesh->ldata, &result->ldata, group_buffer, iter.group_len, loop_cur);
+ uint v = vert_final[iter.v];
+ uint e = edge_final[iter.e];
+ r_ml->v = v;
+ r_ml->e = e;
+ r_ml++;
+ loop_cur++;
+ if (iter.type) {
+ result->medge[e].flag &= ~ME_LOOSEEDGE;
}
+ BLI_assert((result->medge[e].flag & ME_LOOSEEDGE) == 0);
}
+
r_mp->loopstart = loop_start;
r_mp->totloop = loop_cur - loop_start;
r_mp++;
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index c53e01ac80f..33b95d50cc0 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -136,6 +136,7 @@ set(SRC
function/nodes/node_fn_float_compare.cc
function/nodes/node_fn_group_instance_id.cc
function/nodes/node_fn_object_transforms.cc
+ function/nodes/node_fn_random_float.cc
function/nodes/node_fn_switch.cc
function/node_function_util.cc
@@ -232,10 +233,12 @@ set(SRC
shader/node_shader_tree.c
shader/node_shader_util.c
+ simulation/nodes/node_sim_age_reached_event.cc
simulation/nodes/node_sim_common.cc
simulation/nodes/node_sim_emit_particles.cc
simulation/nodes/node_sim_execute_condition.cc
simulation/nodes/node_sim_force.cc
+ simulation/nodes/node_sim_kill_particle.cc
simulation/nodes/node_sim_multi_execute.cc
simulation/nodes/node_sim_particle_attribute.cc
simulation/nodes/node_sim_particle_birth_event.cc
diff --git a/source/blender/nodes/NOD_common.h b/source/blender/nodes/NOD_common.h
index dcc4f4d0b76..50ed992dcb6 100644
--- a/source/blender/nodes/NOD_common.h
+++ b/source/blender/nodes/NOD_common.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NOD_COMMON_H__
-#define __NOD_COMMON_H__
+#pragma once
#include "BKE_node.h"
@@ -49,5 +48,3 @@ void node_group_output_update(struct bNodeTree *ntree, struct bNode *node);
#ifdef __cplusplus
}
#endif
-
-#endif /* __NOD_COMMON_H__ */
diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h
index 6b1dd239294..99bcb849ebd 100644
--- a/source/blender/nodes/NOD_composite.h
+++ b/source/blender/nodes/NOD_composite.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NOD_COMPOSITE_H__
-#define __NOD_COMPOSITE_H__
+#pragma once
#include "BKE_node.h"
@@ -150,5 +149,3 @@ void register_node_type_cmp_custom_group(bNodeType *ntype);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh
index b39c9fd1a23..9c71ae79cf2 100644
--- a/source/blender/nodes/NOD_derived_node_tree.hh
+++ b/source/blender/nodes/NOD_derived_node_tree.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_DERIVED_NODE_TREE_HH__
-#define __NOD_DERIVED_NODE_TREE_HH__
+#pragma once
/** \file
* \ingroup nodes
@@ -172,7 +171,6 @@ using NodeTreeRefMap = Map<bNodeTree *, std::unique_ptr<const NodeTreeRef>>;
class DerivedNodeTree : NonCopyable, NonMovable {
private:
LinearAllocator<> allocator_;
- bNodeTree *btree_;
Vector<DNode *> nodes_by_id_;
Vector<DGroupInput *> group_inputs_;
Vector<DParentNode *> parent_nodes_;
@@ -267,12 +265,12 @@ inline const DSocket &DSocket::as_base() const
inline const DInputSocket &DSocket::as_input() const
{
- return *(DInputSocket *)this;
+ return static_cast<const DInputSocket &>(*this);
}
inline const DOutputSocket &DSocket::as_output() const
{
- return *(DOutputSocket *)this;
+ return static_cast<const DOutputSocket &>(*this);
}
inline PointerRNA *DSocket::rna() const
@@ -507,5 +505,3 @@ inline Span<const DGroupInput *> DerivedNodeTree::group_inputs() const
}
} // namespace blender::nodes
-
-#endif /* __NOD_DERIVED_NODE_TREE_HH__ */
diff --git a/source/blender/nodes/NOD_function.h b/source/blender/nodes/NOD_function.h
index 4c05da694f7..58a968151ac 100644
--- a/source/blender/nodes/NOD_function.h
+++ b/source/blender/nodes/NOD_function.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_FUNCTION_H__
-#define __NOD_FUNCTION_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -27,9 +26,8 @@ void register_node_type_fn_switch(void);
void register_node_type_fn_group_instance_id(void);
void register_node_type_fn_combine_strings(void);
void register_node_type_fn_object_transforms(void);
+void register_node_type_fn_random_float(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __NOD_FUNCTION_H__ */
diff --git a/source/blender/nodes/NOD_node_tree_dependencies.hh b/source/blender/nodes/NOD_node_tree_dependencies.hh
index ca7059caa5f..13bb2bde2f3 100644
--- a/source/blender/nodes/NOD_node_tree_dependencies.hh
+++ b/source/blender/nodes/NOD_node_tree_dependencies.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_NODE_TREE_DEPENDENCIES_H__
-#define __NOD_NODE_TREE_DEPENDENCIES_H__
+#pragma once
#include "BLI_vector_set.hh"
@@ -75,5 +74,3 @@ class NodeTreeDependencies {
NodeTreeDependencies find_node_tree_dependencies(bNodeTree &ntree);
} // namespace blender::nodes
-
-#endif /* __NOD_NODE_TREE_DEPENDENCIES_H__ */
diff --git a/source/blender/nodes/NOD_node_tree_multi_function.hh b/source/blender/nodes/NOD_node_tree_multi_function.hh
index 81b467eca3a..25787231afa 100644
--- a/source/blender/nodes/NOD_node_tree_multi_function.hh
+++ b/source/blender/nodes/NOD_node_tree_multi_function.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_NODE_TREE_FUNCTION_HH__
-#define __NOD_NODE_TREE_FUNCTION_HH__
+#pragma once
/** \file
* \ingroup nodes
@@ -127,8 +126,20 @@ class MFNetworkTreeMap {
void add_try_match(const DNode &dnode, fn::MFNode &node)
{
- this->add_try_match(dnode.inputs(), node.inputs());
- this->add_try_match(dnode.outputs(), node.outputs());
+ this->add_try_match(dnode.inputs().cast<const DSocket *>(),
+ node.inputs().cast<fn::MFSocket *>());
+ this->add_try_match(dnode.outputs().cast<const DSocket *>(),
+ node.outputs().cast<fn::MFSocket *>());
+ }
+
+ void add_try_match(Span<const DInputSocket *> dsockets, Span<fn::MFInputSocket *> sockets)
+ {
+ this->add_try_match(dsockets.cast<const DSocket *>(), sockets.cast<fn::MFSocket *>());
+ }
+
+ void add_try_match(Span<const DOutputSocket *> dsockets, Span<fn::MFOutputSocket *> sockets)
+ {
+ this->add_try_match(dsockets.cast<const DSocket *>(), sockets.cast<fn::MFSocket *>());
}
void add_try_match(Span<const DSocket *> dsockets, Span<fn::MFSocket *> sockets)
@@ -251,19 +262,17 @@ class MFNetworkBuilderBase {
*/
class SocketMFNetworkBuilder : public MFNetworkBuilderBase {
private:
- const DSocket *dsocket_ = nullptr;
- const DGroupInput *group_input_ = nullptr;
bNodeSocket *bsocket_;
fn::MFOutputSocket *built_socket_ = nullptr;
public:
SocketMFNetworkBuilder(CommonMFNetworkBuilderData &common, const DSocket &dsocket)
- : MFNetworkBuilderBase(common), dsocket_(&dsocket), bsocket_(dsocket.bsocket())
+ : MFNetworkBuilderBase(common), bsocket_(dsocket.bsocket())
{
}
SocketMFNetworkBuilder(CommonMFNetworkBuilderData &common, const DGroupInput &group_input)
- : MFNetworkBuilderBase(common), group_input_(&group_input), bsocket_(group_input.bsocket())
+ : MFNetworkBuilderBase(common), bsocket_(group_input.bsocket())
{
}
@@ -280,7 +289,7 @@ class SocketMFNetworkBuilder : public MFNetworkBuilderBase {
*/
template<typename T> T *socket_default_value()
{
- return (T *)bsocket_->default_value;
+ return static_cast<T *>(bsocket_->default_value);
}
/**
@@ -389,5 +398,3 @@ MFNetworkTreeMap insert_node_tree_into_mf_network(fn::MFNetwork &network,
ResourceCollector &resources);
} // namespace blender::nodes
-
-#endif /* __NOD_NODE_TREE_FUNCTION_HH__ */
diff --git a/source/blender/nodes/NOD_node_tree_ref.hh b/source/blender/nodes/NOD_node_tree_ref.hh
index 13656c2e940..3b085248a39 100644
--- a/source/blender/nodes/NOD_node_tree_ref.hh
+++ b/source/blender/nodes/NOD_node_tree_ref.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_NODE_TREE_REF_HH__
-#define __NOD_NODE_TREE_REF_HH__
+#pragma once
/** \file
* \ingroup nodes
@@ -249,13 +248,13 @@ inline const SocketRef &SocketRef::as_base() const
inline const InputSocketRef &SocketRef::as_input() const
{
BLI_assert(this->is_input());
- return *(const InputSocketRef *)this;
+ return static_cast<const InputSocketRef &>(*this);
}
inline const OutputSocketRef &SocketRef::as_output() const
{
BLI_assert(this->is_output());
- return *(const OutputSocketRef *)this;
+ return static_cast<const OutputSocketRef &>(*this);
}
inline PointerRNA *SocketRef::rna() const
@@ -436,5 +435,3 @@ inline bNodeTree *NodeTreeRef::btree() const
}
} // namespace blender::nodes
-
-#endif /* __NOD_NODE_TREE_REF_HH__ */
diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h
index bf548aea5f4..2911e0fbea6 100644
--- a/source/blender/nodes/NOD_shader.h
+++ b/source/blender/nodes/NOD_shader.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NOD_SHADER_H__
-#define __NOD_SHADER_H__
+#pragma once
#include "BKE_node.h"
@@ -146,5 +145,3 @@ void register_node_type_sh_custom_group(bNodeType *ntype);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/NOD_simulation.h b/source/blender/nodes/NOD_simulation.h
index 2947d38fe83..266ded997c6 100644
--- a/source/blender/nodes/NOD_simulation.h
+++ b/source/blender/nodes/NOD_simulation.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_SIMULATION_H__
-#define __NOD_SIMULATION_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -39,9 +38,9 @@ void register_node_type_sim_particle_mesh_collision_event(void);
void register_node_type_sim_emit_particles(void);
void register_node_type_sim_time(void);
void register_node_type_sim_particle_attribute(void);
+void register_node_type_sim_age_reached_event(void);
+void register_node_type_sim_kill_particle(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __NOD_SIMULATION_H__ */
diff --git a/source/blender/nodes/NOD_socket.h b/source/blender/nodes/NOD_socket.h
index ce6f0da4aee..3344a25bdea 100644
--- a/source/blender/nodes/NOD_socket.h
+++ b/source/blender/nodes/NOD_socket.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NOD_SOCKET_H__
-#define __NOD_SOCKET_H__
+#pragma once
#include "DNA_listBase.h"
@@ -48,10 +47,13 @@ void node_verify_socket_templates(struct bNodeTree *ntree, struct bNode *node);
void node_socket_init_default_value(struct bNodeSocket *sock);
void node_socket_copy_default_value(struct bNodeSocket *to, const struct bNodeSocket *from);
+void node_socket_skip_reroutes(struct ListBase *links,
+ struct bNode *node,
+ struct bNodeSocket *socket,
+ struct bNode **r_node,
+ struct bNodeSocket **r_socket);
void register_standard_node_socket_types(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __NOD_SOCKET_H__ */
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index 31ce3f81450..7922a73902c 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -270,6 +270,8 @@ DefNode(SimulationNode, SIM_NODE_PARTICLE_MESH_COLLISION_EVENT, 0, "PARTIC
DefNode(SimulationNode, SIM_NODE_EMIT_PARTICLES, 0, "EMIT_PARTICLES", EmitParticles, "Emit Particles", "")
DefNode(SimulationNode, SIM_NODE_TIME, def_sim_time, "TIME", Time, "Time", "")
DefNode(SimulationNode, SIM_NODE_PARTICLE_ATTRIBUTE, def_sim_particle_attribute, "PARTICLE_ATTRIBUTE", ParticleAttribute, "Particle Attribute", "")
+DefNode(SimulationNode, SIM_NODE_AGE_REACHED_EVENT, 0, "AGE_REACHED_EVENT", AgeReachedEvent, "Age Reached Event", "")
+DefNode(SimulationNode, SIM_NODE_KILL_PARTICLE, 0, "KILL_PARTICLE", KillParticle, "Kill Particle", "")
DefNode(FunctionNode, FN_NODE_BOOLEAN_MATH, def_boolean_math, "BOOLEAN_MATH", BooleanMath, "Boolean Math", "")
DefNode(FunctionNode, FN_NODE_FLOAT_COMPARE, def_float_compare, "FLOAT_COMPARE", FloatCompare, "Float Compare", "")
@@ -277,7 +279,7 @@ DefNode(FunctionNode, FN_NODE_SWITCH, def_fn_switch, "SWITCH",
DefNode(FunctionNode, FN_NODE_GROUP_INSTANCE_ID, 0, "GROUP_INSTANCE_ID", GroupInstanceID, "Group Instance ID", "")
DefNode(FunctionNode, FN_NODE_COMBINE_STRINGS, 0, "COMBINE_STRINGS", CombineStrings, "Combine Strings", "")
DefNode(FunctionNode, FN_NODE_OBJECT_TRANSFORMS, 0, "OBJECT_TRANSFORMS", ObjectTransforms, "Object Transforms", "")
-
+DefNode(FunctionNode, FN_NODE_RANDOM_FLOAT, 0, "RANDOM_FLOAT", RandomFloat, "Random Float", "")
/* undefine macros */
diff --git a/source/blender/nodes/NOD_texture.h b/source/blender/nodes/NOD_texture.h
index 07a05f01bc5..af59fefd925 100644
--- a/source/blender/nodes/NOD_texture.h
+++ b/source/blender/nodes/NOD_texture.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NOD_TEXTURE_H__
-#define __NOD_TEXTURE_H__
+#pragma once
#include "BKE_node.h"
@@ -78,5 +77,3 @@ void register_node_type_tex_proc_distnoise(void);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/composite/node_composite_util.h b/source/blender/nodes/composite/node_composite_util.h
index 0edc864e98f..8810b760e8c 100644
--- a/source/blender/nodes/composite/node_composite_util.h
+++ b/source/blender/nodes/composite/node_composite_util.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_COMPOSITE_UTIL_H__
-#define __NODE_COMPOSITE_UTIL_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_movieclip_types.h"
@@ -63,5 +62,3 @@ void cmp_node_type_base(
#ifdef __cplusplus
}
#endif
-
-#endif /* __NODE_COMPOSITE_UTIL_H__ */
diff --git a/source/blender/nodes/function/node_function_util.hh b/source/blender/nodes/function/node_function_util.hh
index 8e09ab0f24f..d57d1383019 100644
--- a/source/blender/nodes/function/node_function_util.hh
+++ b/source/blender/nodes/function/node_function_util.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NODE_FUNCTION_UTIL_H__
-#define __NODE_FUNCTION_UTIL_H__
+#pragma once
#include <string.h>
@@ -40,5 +39,3 @@
void fn_node_type_base(
struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
bool fn_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
-
-#endif /* __NODE_FUNCTION_UTIL_H__ */
diff --git a/source/blender/nodes/function/nodes/node_fn_random_float.cc b/source/blender/nodes/function/nodes/node_fn_random_float.cc
new file mode 100644
index 00000000000..584c544946e
--- /dev/null
+++ b/source/blender/nodes/function/nodes/node_fn_random_float.cc
@@ -0,0 +1,89 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_function_util.hh"
+
+#include "BLI_hash.h"
+
+static bNodeSocketTemplate fn_node_random_float_in[] = {
+ {SOCK_FLOAT, N_("Min"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE},
+ {SOCK_FLOAT, N_("Max"), 1.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE},
+ {SOCK_INT, N_("Seed")},
+ {-1, ""},
+};
+
+static bNodeSocketTemplate fn_node_random_float_out[] = {
+ {SOCK_FLOAT, N_("Value")},
+ {-1, ""},
+};
+
+class RandomFloatFunction : public blender::fn::MultiFunction {
+ private:
+ uint32_t function_seed_;
+
+ public:
+ RandomFloatFunction(uint32_t function_seed) : function_seed_(function_seed)
+ {
+ blender::fn::MFSignatureBuilder signature = this->get_builder("Random float");
+ signature.single_input<float>("Min");
+ signature.single_input<float>("Max");
+ signature.single_input<int>("Seed");
+ signature.single_output<float>("Value");
+ }
+
+ void call(blender::IndexMask mask,
+ blender::fn::MFParams params,
+ blender::fn::MFContext UNUSED(context)) const override
+ {
+ blender::fn::VSpan<float> min_values = params.readonly_single_input<float>(0, "Min");
+ blender::fn::VSpan<float> max_values = params.readonly_single_input<float>(1, "Max");
+ blender::fn::VSpan<int> seeds = params.readonly_single_input<int>(2, "Seed");
+ blender::MutableSpan<float> values = params.uninitialized_single_output<float>(3, "Value");
+
+ for (int64_t i : mask) {
+ const float min_value = min_values[i];
+ const float max_value = max_values[i];
+ const int seed = seeds[i];
+ const float value = BLI_hash_int_01(static_cast<uint32_t>(seed) ^ function_seed_);
+ values[i] = value * (max_value - min_value) + min_value;
+ }
+ }
+};
+
+static void fn_node_random_float_expand_in_mf_network(
+ blender::nodes::NodeMFNetworkBuilder &builder)
+{
+ uint32_t function_seed = 1746872341u;
+ const blender::nodes::DNode &node = builder.dnode();
+ const blender::DefaultHash<blender::StringRefNull> hasher;
+ function_seed = 33 * function_seed + hasher(node.name());
+ for (const blender::nodes::DParentNode *parent = node.parent(); parent != nullptr;
+ parent = parent->parent()) {
+ function_seed = 33 * function_seed + hasher(parent->node_ref().name());
+ }
+
+ builder.construct_and_set_matching_fn<RandomFloatFunction>(function_seed);
+}
+
+void register_node_type_fn_random_float()
+{
+ static bNodeType ntype;
+
+ fn_node_type_base(&ntype, FN_NODE_RANDOM_FLOAT, "Random Float", 0, 0);
+ node_type_socket_templates(&ntype, fn_node_random_float_in, fn_node_random_float_out);
+ ntype.expand_in_mf_network = fn_node_random_float_expand_in_mf_network;
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/intern/derived_node_tree.cc b/source/blender/nodes/intern/derived_node_tree.cc
index 5414ea9208a..4612a479ebc 100644
--- a/source/blender/nodes/intern/derived_node_tree.cc
+++ b/source/blender/nodes/intern/derived_node_tree.cc
@@ -28,7 +28,7 @@ static const NodeTreeRef &get_tree_ref(NodeTreeRefMap &node_tree_refs, bNodeTree
[&]() { return std::make_unique<NodeTreeRef>(btree); });
}
-DerivedNodeTree::DerivedNodeTree(bNodeTree *btree, NodeTreeRefMap &node_tree_refs) : btree_(btree)
+DerivedNodeTree::DerivedNodeTree(bNodeTree *btree, NodeTreeRefMap &node_tree_refs)
{
const NodeTreeRef &main_tree_ref = get_tree_ref(node_tree_refs, btree);
@@ -59,9 +59,10 @@ BLI_NOINLINE void DerivedNodeTree::insert_nodes_and_links_in_id_order(const Node
/* Insert links. */
for (const NodeRef *node_ref : tree_ref.nodes()) {
for (const InputSocketRef *to_socket_ref : node_ref->inputs()) {
- DInputSocket *to_socket = (DInputSocket *)sockets_map[to_socket_ref->id()];
+ DInputSocket *to_socket = static_cast<DInputSocket *>(sockets_map[to_socket_ref->id()]);
for (const OutputSocketRef *from_socket_ref : to_socket_ref->linked_sockets()) {
- DOutputSocket *from_socket = (DOutputSocket *)sockets_map[from_socket_ref->id()];
+ DOutputSocket *from_socket = static_cast<DOutputSocket *>(
+ sockets_map[from_socket_ref->id()]);
to_socket->linked_sockets_.append(from_socket);
from_socket->linked_sockets_.append(to_socket);
}
@@ -130,7 +131,7 @@ BLI_NOINLINE void DerivedNodeTree::expand_group_node(DNode &group_node,
const NodeRef &group_node_ref = *group_node.node_ref_;
BLI_assert(group_node_ref.is_group_node());
- bNodeTree *btree = (bNodeTree *)group_node_ref.bnode()->id;
+ bNodeTree *btree = reinterpret_cast<bNodeTree *>(group_node_ref.bnode()->id);
if (btree == nullptr) {
return;
}
@@ -366,7 +367,7 @@ static dot::Cluster *get_cluster_for_parent(dot::DirectedGraph &graph,
}
return clusters.lookup_or_add_cb(parent, [&]() {
dot::Cluster *parent_cluster = get_cluster_for_parent(graph, clusters, parent->parent());
- bNodeTree *btree = (bNodeTree *)parent->node_ref().bnode()->id;
+ bNodeTree *btree = reinterpret_cast<bNodeTree *>(parent->node_ref().bnode()->id);
dot::Cluster *new_cluster = &graph.new_cluster(parent->node_ref().name() + " / " +
StringRef(btree->id.name + 2));
new_cluster->set_parent_cluster(parent_cluster);
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index 996fb93eb76..aa1f23163a0 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -84,13 +84,11 @@ bool node_group_poll_instance(bNode *node, bNodeTree *nodetree)
if (grouptree) {
return nodeGroupPoll(nodetree, grouptree);
}
- else {
- return true; /* without a linked node tree, group node is always ok */
- }
- }
- else {
- return false;
+
+ return true; /* without a linked node tree, group node is always ok */
}
+
+ return false;
}
int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree)
@@ -132,6 +130,9 @@ static bNodeSocket *group_verify_socket(
if (sock) {
strcpy(sock->name, iosock->name);
+ const int mask = SOCK_HIDE_VALUE;
+ sock->flag = (sock->flag & ~mask) | (iosock->flag & mask);
+
if (iosock->typeinfo->interface_verify_socket) {
iosock->typeinfo->interface_verify_socket(ntree, iosock, gnode, sock, "interface");
}
diff --git a/source/blender/nodes/intern/node_common.h b/source/blender/nodes/intern/node_common.h
index 7810e9f1f14..7aad6782640 100644
--- a/source/blender/nodes/intern/node_common.h
+++ b/source/blender/nodes/intern/node_common.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_COMMON_H__
-#define __NODE_COMMON_H__
+#pragma once
#include "DNA_listBase.h"
@@ -40,5 +39,3 @@ void ntree_update_reroute_nodes(struct bNodeTree *ntree);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/intern/node_exec.h b/source/blender/nodes/intern/node_exec.h
index 87a61f0a490..806dd10d9bf 100644
--- a/source/blender/nodes/intern/node_exec.h
+++ b/source/blender/nodes/intern/node_exec.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_EXEC_H__
-#define __NODE_EXEC_H__
+#pragma once
#include "DNA_listBase.h"
@@ -105,5 +104,3 @@ void ntreeTexEndExecTree_internal(struct bNodeTreeExec *exec);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc
index 57c8d51975e..0dfae7424cb 100644
--- a/source/blender/nodes/intern/node_socket.cc
+++ b/source/blender/nodes/intern/node_socket.cc
@@ -356,6 +356,54 @@ void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from)
to->flag |= (from->flag & SOCK_HIDE_VALUE);
}
+void node_socket_skip_reroutes(
+ ListBase *links, bNode *node, bNodeSocket *socket, bNode **r_node, bNodeSocket **r_socket)
+{
+ const int loop_limit = 100; /* Limit in case there is a connection cycle. */
+
+ if (socket->in_out == SOCK_IN) {
+ bNodeLink *first_link = (bNodeLink *)links->first;
+
+ for (int i = 0; node->type == NODE_REROUTE && i < loop_limit; i++) {
+ bNodeLink *link = first_link;
+
+ for (; link; link = link->next) {
+ if (link->fromnode == node && link->tonode != node) {
+ break;
+ }
+ }
+
+ if (link) {
+ node = link->tonode;
+ socket = link->tosock;
+ }
+ else {
+ break;
+ }
+ }
+ }
+ else {
+ for (int i = 0; node->type == NODE_REROUTE && i < loop_limit; i++) {
+ bNodeSocket *input = (bNodeSocket *)node->inputs.first;
+
+ if (input && input->link) {
+ node = input->link->fromnode;
+ socket = input->link->fromsock;
+ }
+ else {
+ break;
+ }
+ }
+ }
+
+ if (r_node) {
+ *r_node = node;
+ }
+ if (r_socket) {
+ *r_socket = socket;
+ }
+}
+
static void standard_node_socket_interface_init_socket(bNodeTree *UNUSED(ntree),
bNodeSocket *stemp,
bNode *UNUSED(node),
diff --git a/source/blender/nodes/intern/node_tree_dependencies.cc b/source/blender/nodes/intern/node_tree_dependencies.cc
index efe75a10f7e..9d279dd4d75 100644
--- a/source/blender/nodes/intern/node_tree_dependencies.cc
+++ b/source/blender/nodes/intern/node_tree_dependencies.cc
@@ -28,7 +28,7 @@ static void add_dependencies_of_node_tree(bNodeTree &ntree, NodeTreeDependencies
LISTBASE_FOREACH (bNode *, node, &ntree.nodes) {
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
if (socket->type == SOCK_OBJECT) {
- Object *object = ((bNodeSocketValueObject *)socket->default_value)->value;
+ Object *object = reinterpret_cast<bNodeSocketValueObject *>(socket->default_value)->value;
if (object != nullptr) {
r_dependencies.add_transform_dependency(object);
if (object->type == OB_MESH) {
@@ -39,7 +39,7 @@ static void add_dependencies_of_node_tree(bNodeTree &ntree, NodeTreeDependencies
}
if (node->type == NODE_GROUP) {
- bNodeTree *group = (bNodeTree *)node->id;
+ bNodeTree *group = reinterpret_cast<bNodeTree *>(node->id);
if (group != nullptr) {
add_dependencies_of_node_tree(*group, r_dependencies);
}
diff --git a/source/blender/nodes/intern/node_tree_multi_function.cc b/source/blender/nodes/intern/node_tree_multi_function.cc
index 82842c4ef32..09a80fd23f4 100644
--- a/source/blender/nodes/intern/node_tree_multi_function.cc
+++ b/source/blender/nodes/intern/node_tree_multi_function.cc
@@ -176,13 +176,12 @@ static fn::MFOutputSocket *try_find_origin(CommonMFNetworkBuilderData &common,
}
return nullptr;
}
- else {
- const DGroupInput &from_group_input = *from_group_inputs[0];
- if (is_multi_function_data_socket(from_group_input.bsocket())) {
- return &common.network_map.lookup(from_group_input);
- }
- return nullptr;
+
+ const DGroupInput &from_group_input = *from_group_inputs[0];
+ if (is_multi_function_data_socket(from_group_input.bsocket())) {
+ return &common.network_map.lookup(from_group_input);
}
+ return nullptr;
}
using ImplicitConversionsMap =
diff --git a/source/blender/nodes/intern/node_tree_ref.cc b/source/blender/nodes/intern/node_tree_ref.cc
index 47669bc5ca2..96ad1e0280e 100644
--- a/source/blender/nodes/intern/node_tree_ref.cc
+++ b/source/blender/nodes/intern/node_tree_ref.cc
@@ -101,9 +101,9 @@ InputSocketRef &NodeTreeRef::find_input_socket(Map<bNode *, NodeRef *> &node_map
bNodeSocket *bsocket)
{
NodeRef *node = node_mapping.lookup(bnode);
- for (SocketRef *socket : node->inputs_) {
+ for (InputSocketRef *socket : node->inputs_) {
if (socket->bsocket_ == bsocket) {
- return *(InputSocketRef *)socket;
+ return *socket;
}
}
BLI_assert(false);
@@ -115,9 +115,9 @@ OutputSocketRef &NodeTreeRef::find_output_socket(Map<bNode *, NodeRef *> &node_m
bNodeSocket *bsocket)
{
NodeRef *node = node_mapping.lookup(bnode);
- for (SocketRef *socket : node->outputs_) {
+ for (OutputSocketRef *socket : node->outputs_) {
if (socket->bsocket_ == bsocket) {
- return *(OutputSocketRef *)socket;
+ return *socket;
}
}
BLI_assert(false);
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index 9efbdc079e6..b2309abe32e 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -73,7 +73,7 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context),
bNode *node,
bNodeInstanceKey UNUSED(key))
{
- BKE_curvemapping_initialize(node->storage);
+ BKE_curvemapping_init(node->storage);
return NULL; /* unused return */
}
diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h
index 61f8fe6809d..1b542a9420a 100644
--- a/source/blender/nodes/intern/node_util.h
+++ b/source/blender/nodes/intern/node_util.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_UTIL_H__
-#define __NODE_UTIL_H__
+#pragma once
#include "DNA_listBase.h"
@@ -110,5 +109,3 @@ void node_socket_set_vector(struct bNodeTree *ntree,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index 179a92ec7bd..758f7edfe49 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -344,15 +344,23 @@ static void ntree_shader_unlink_hidden_value_sockets(bNode *group_node, bNodeSoc
bool removed_link = false;
for (node = group_ntree->nodes.first; node; node = node->next) {
+ const bool is_group = ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && (node->id != NULL);
+
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
- if ((sock->flag & SOCK_HIDE_VALUE) == 0) {
+ if (!is_group && (sock->flag & SOCK_HIDE_VALUE) == 0) {
continue;
}
/* If socket is linked to a group input node and sockets id match. */
if (sock && sock->link && sock->link->fromnode->type == NODE_GROUP_INPUT) {
if (STREQ(isock->identifier, sock->link->fromsock->identifier)) {
- nodeRemLink(group_ntree, sock->link);
- removed_link = true;
+ if (is_group) {
+ /* Recursively unlink sockets within the nested group. */
+ ntree_shader_unlink_hidden_value_sockets(node, sock);
+ }
+ else {
+ nodeRemLink(group_ntree, sock->link);
+ removed_link = true;
+ }
}
}
}
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index b0ba1ea194f..de192f51a5f 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_SHADER_UTIL_H__
-#define __NODE_SHADER_UTIL_H__
+#pragma once
#include <float.h>
#include <math.h>
@@ -116,5 +115,3 @@ void ntreeExecGPUNodes(struct bNodeTreeExec *exec,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c
index 6b5d46e250b..116bc181997 100644
--- a/source/blender/nodes/shader/nodes/node_shader_attribute.c
+++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c
@@ -55,17 +55,16 @@ static int node_shader_gpu_attribute(GPUMaterial *mat,
return 1;
}
- else {
- GPUNodeLink *cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name);
- GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr);
- /* for each output. */
- for (int i = 0; sh_node_attribute_out[i].type != -1; i++) {
- node_shader_gpu_bump_tex_coord(mat, node, &out[i].link);
- }
+ GPUNodeLink *cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name);
+ GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr);
- return 1;
+ /* for each output. */
+ for (int i = 0; sh_node_attribute_out[i].type != -1; i++) {
+ node_shader_gpu_bump_tex_coord(mat, node, &out[i].link);
}
+
+ return 1;
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_clamp.cc b/source/blender/nodes/shader/nodes/node_shader_clamp.cc
index 1077f616a62..d3a893e1d76 100644
--- a/source/blender/nodes/shader/nodes/node_shader_clamp.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_clamp.cc
@@ -60,9 +60,8 @@ static void sh_node_clamp_expand_in_mf_network(blender::nodes::NodeMFNetworkBuil
if (a < b) {
return clamp_f(value, a, b);
}
- else {
- return clamp_f(value, b, a);
- }
+
+ return clamp_f(value, b, a);
}};
int clamp_type = builder.bnode().custom1;
diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c
index 68f252cb092..42299a193e2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_curves.c
+++ b/source/blender/nodes/shader/nodes/node_shader_curves.c
@@ -168,7 +168,7 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat,
CurveMapping *cumap = node->storage;
- BKE_curvemapping_initialize(cumap);
+ BKE_curvemapping_init(cumap);
BKE_curvemapping_table_RGBA(cumap, &array, &size);
GPUNodeLink *tex = GPU_color_band(mat, size, array, &layer);
@@ -215,20 +215,19 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat,
GPU_uniform(range_rgba),
GPU_uniform(ext_rgba[3]));
}
- else {
- return GPU_stack_link(mat,
- node,
- "curves_rgb",
- in,
- out,
- tex,
- GPU_constant(&layer),
- GPU_uniform(range_rgba),
- GPU_uniform(ext_rgba[0]),
- GPU_uniform(ext_rgba[1]),
- GPU_uniform(ext_rgba[2]),
- GPU_uniform(ext_rgba[3]));
- }
+
+ return GPU_stack_link(mat,
+ node,
+ "curves_rgb",
+ in,
+ out,
+ tex,
+ GPU_constant(&layer),
+ GPU_uniform(range_rgba),
+ GPU_uniform(ext_rgba[0]),
+ GPU_uniform(ext_rgba[1]),
+ GPU_uniform(ext_rgba[2]),
+ GPU_uniform(ext_rgba[3]));
}
void register_node_type_sh_curve_rgb(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_displacement.c b/source/blender/nodes/shader/nodes/node_shader_displacement.c
index 22fbe4e4da6..649aad370c0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_displacement.c
+++ b/source/blender/nodes/shader/nodes/node_shader_displacement.c
@@ -64,10 +64,9 @@ static int gpu_shader_displacement(GPUMaterial *mat,
return GPU_stack_link(
mat, node, "node_displacement_object", in, out, GPU_builtin(GPU_OBJECT_MATRIX));
}
- else {
- return GPU_stack_link(
- mat, node, "node_displacement_world", in, out, GPU_builtin(GPU_OBJECT_MATRIX));
- }
+
+ return GPU_stack_link(
+ mat, node, "node_displacement_world", in, out, GPU_builtin(GPU_OBJECT_MATRIX));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c
index deb0ee9037c..f66633e64c8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_geometry.c
+++ b/source/blender/nodes/shader/nodes/node_shader_geometry.c
@@ -42,9 +42,12 @@ static int node_shader_gpu_geometry(GPUMaterial *mat,
{
/* HACK: Don't request GPU_BARYCENTRIC_TEXCO if not used because it will
* trigger the use of geometry shader (and the performance penalty it implies). */
- float val[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float val[4] = {0.0f, 0.0f, 0.0f, 0.0f};
GPUNodeLink *bary_link = (!out[5].hasoutput) ? GPU_constant(val) :
GPU_builtin(GPU_BARYCENTRIC_TEXCO);
+ if (out[5].hasoutput) {
+ GPU_material_flag_set(mat, GPU_MATFLAG_BARYCENTRIC);
+ }
/* Opti: don't request orco if not needed. */
GPUNodeLink *orco_link = (!out[2].hasoutput) ? GPU_constant(val) :
GPU_attribute(mat, CD_ORCO, "");
diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c
index 6750acf5ee1..774e7fed029 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mapping.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c
@@ -53,9 +53,8 @@ static int gpu_shader_mapping(GPUMaterial *mat,
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
return GPU_stack_link(mat, node, names[node->custom1], in, out);
}
- else {
- return 0;
- }
+
+ return 0;
}
static void node_shader_update_mapping(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc
index c7035da8c70..e7bbadfbcb0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_math.cc
@@ -141,9 +141,8 @@ static int gpu_shader_math(GPUMaterial *mat,
}
return ret;
}
- else {
- return 0;
- }
+
+ return 0;
}
static const blender::fn::MultiFunction &get_base_multi_function(
diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
index 93e88664d1a..8725122b12c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
@@ -91,16 +91,15 @@ static int gpu_shader_mix_rgb(GPUMaterial *mat,
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
int ret = GPU_stack_link(mat, node, names[node->custom1], in, out);
if (ret && node->custom2 & SHD_MIXRGB_CLAMP) {
- float min[3] = {0.0f, 0.0f, 0.0f};
- float max[3] = {1.0f, 1.0f, 1.0f};
+ const float min[3] = {0.0f, 0.0f, 0.0f};
+ const float max[3] = {1.0f, 1.0f, 1.0f};
GPU_link(
mat, "clamp_color", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link);
}
return ret;
}
- else {
- return 0;
- }
+
+ return 0;
}
void register_node_type_sh_mix_rgb(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c
index e8bedde0a62..2c12bf9bc01 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tangent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c
@@ -45,28 +45,27 @@ static int node_shader_gpu_tangent(GPUMaterial *mat,
return GPU_stack_link(
mat, node, "node_tangentmap", in, out, GPU_attribute(mat, CD_TANGENT, attr->uv_map));
}
- else {
- GPUNodeLink *orco = GPU_attribute(mat, CD_ORCO, "");
- if (attr->axis == SHD_TANGENT_AXIS_X) {
- GPU_link(mat, "tangent_orco_x", orco, &orco);
- }
- else if (attr->axis == SHD_TANGENT_AXIS_Y) {
- GPU_link(mat, "tangent_orco_y", orco, &orco);
- }
- else {
- GPU_link(mat, "tangent_orco_z", orco, &orco);
- }
+ GPUNodeLink *orco = GPU_attribute(mat, CD_ORCO, "");
- return GPU_stack_link(mat,
- node,
- "node_tangent",
- in,
- out,
- GPU_builtin(GPU_WORLD_NORMAL),
- orco,
- GPU_builtin(GPU_OBJECT_MATRIX));
+ if (attr->axis == SHD_TANGENT_AXIS_X) {
+ GPU_link(mat, "tangent_orco_x", orco, &orco);
+ }
+ else if (attr->axis == SHD_TANGENT_AXIS_Y) {
+ GPU_link(mat, "tangent_orco_y", orco, &orco);
}
+ else {
+ GPU_link(mat, "tangent_orco_z", orco, &orco);
+ }
+
+ return GPU_stack_link(mat,
+ node,
+ "node_tangent",
+ in,
+ out,
+ GPU_builtin(GPU_WORLD_NORMAL),
+ orco,
+ GPU_builtin(GPU_OBJECT_MATRIX));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
index 0cf4b51f307..38e79ebe94d 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
@@ -19,8 +19,6 @@
#include "../node_shader_util.h"
-#include "GPU_draw.h"
-
/* **************** OUTPUT ******************** */
static bNodeSocketTemplate sh_node_tex_environment_in[] = {
@@ -59,7 +57,8 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat,
NodeTexImage *tex_original = node_original->storage;
ImageUser *iuser = &tex_original->iuser;
eGPUSamplerState sampler = GPU_SAMPLER_REPEAT | GPU_SAMPLER_ANISO | GPU_SAMPLER_FILTER;
- if (GPU_get_mipmap()) {
+ /* TODO(fclem) For now assume mipmap is always enabled. */
+ if (true) {
sampler |= GPU_SAMPLER_MIPMAP;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
index cbda72cd228..1a78d2f5bf2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -19,8 +19,6 @@
#include "../node_shader_util.h"
-#include "GPU_draw.h"
-
/* **************** OUTPUT ******************** */
static bNodeSocketTemplate sh_node_tex_image_in[] = {
@@ -95,7 +93,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
if (tex->interpolation != SHD_INTERP_CLOSEST) {
sampler_state |= GPU_SAMPLER_ANISO | GPU_SAMPLER_FILTER;
- sampler_state |= GPU_get_mipmap() ? GPU_SAMPLER_MIPMAP : 0;
+ /* TODO(fclem) For now assume mipmap is always enabled. */
+ sampler_state |= true ? GPU_SAMPLER_MIPMAP : 0;
}
const bool use_cubic = ELEM(tex->interpolation, SHD_INTERP_CUBIC, SHD_INTERP_SMART);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
index 94ffbbe0c55..9ef05d781bd 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
@@ -170,7 +170,7 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat,
GPU_uniform(xyz_to_rgb.g),
GPU_uniform(xyz_to_rgb.b));
}
- else if (tex->sky_model == 1) {
+ if (tex->sky_model == 1) {
/* Hosek / Wilkie */
sun_angles[0] = fmin(M_PI_2, sun_angles[0]); /* clamp to horizon */
SKY_ArHosekSkyModelState *sky_state = SKY_arhosek_xyz_skymodelstate_alloc_init(
@@ -210,9 +210,8 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat,
GPU_uniform(xyz_to_rgb.g),
GPU_uniform(xyz_to_rgb.b));
}
- else {
- return GPU_stack_link(mat, node, "node_tex_sky_nishita", in, out);
- }
+
+ return GPU_stack_link(mat, node, "node_tex_sky_nishita", in, out);
}
static void node_shader_update_sky(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c
index 817ccdc8b6a..56ecb6d4476 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c
@@ -54,9 +54,8 @@ static int gpu_shader_tex_white_noise(GPUMaterial *mat,
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
return GPU_stack_link(mat, node, names[node->custom1], in, out);
}
- else {
- return 0;
- }
+
+ return 0;
}
static void node_shader_update_tex_white_noise(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
index 7f712b0db40..7b4e568e923 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
@@ -121,9 +121,8 @@ static int gpu_shader_valtorgb(GPUMaterial *mat,
if (coba->ipotype == COLBAND_INTERP_CONSTANT) {
return GPU_stack_link(mat, node, "valtorgb_nearest", in, out, tex, GPU_constant(&layer));
}
- else {
- return GPU_stack_link(mat, node, "valtorgb", in, out, tex, GPU_constant(&layer));
- }
+
+ return GPU_stack_link(mat, node, "valtorgb", in, out, tex, GPU_constant(&layer));
}
class ColorBandFunction : public blender::fn::MultiFunction {
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
index c9f79293328..0e82f346529 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
@@ -55,13 +55,12 @@ static int gpu_shader_vector_displacement(GPUMaterial *mat,
GPU_builtin(GPU_OBJECT_MATRIX),
GPU_builtin(GPU_VIEW_MATRIX));
}
- else if (node->custom1 == SHD_SPACE_OBJECT) {
+ if (node->custom1 == SHD_SPACE_OBJECT) {
return GPU_stack_link(
mat, node, "node_vector_displacement_object", in, out, GPU_builtin(GPU_OBJECT_MATRIX));
}
- else {
- return GPU_stack_link(mat, node, "node_vector_displacement_world", in, out);
- }
+
+ return GPU_stack_link(mat, node, "node_vector_displacement_world", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
index c18ad8bb244..e8396c7cfc1 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
@@ -103,9 +103,8 @@ static int gpu_shader_vector_math(GPUMaterial *mat,
if (name != nullptr) {
return GPU_stack_link(mat, node, name, in, out);
}
- else {
- return 0;
- }
+
+ return 0;
}
static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c
index 46a6ff1f353..b2132c59cde 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c
@@ -53,9 +53,8 @@ static int gpu_shader_vector_rotate(GPUMaterial *mat,
float invert = (node->custom2) ? -1.0 : 1.0;
return GPU_stack_link(mat, node, names[node->custom1], in, out, GPU_constant(&invert));
}
- else {
- return 0;
- }
+
+ return 0;
}
static void node_shader_update_vector_rotate(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_wireframe.c b/source/blender/nodes/shader/nodes/node_shader_wireframe.c
index e1da1cd34e4..37e60ddb205 100644
--- a/source/blender/nodes/shader/nodes/node_shader_wireframe.c
+++ b/source/blender/nodes/shader/nodes/node_shader_wireframe.c
@@ -36,20 +36,20 @@ static int node_shader_gpu_wireframe(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
+ GPU_material_flag_set(mat, GPU_MATFLAG_BARYCENTRIC);
/* node->custom1 is use_pixel_size */
if (node->custom1) {
return GPU_stack_link(
mat, node, "node_wireframe_screenspace", in, out, GPU_builtin(GPU_BARYCENTRIC_TEXCO));
}
- else {
- return GPU_stack_link(mat,
- node,
- "node_wireframe",
- in,
- out,
- GPU_builtin(GPU_BARYCENTRIC_TEXCO),
- GPU_builtin(GPU_BARYCENTRIC_DIST));
- }
+
+ return GPU_stack_link(mat,
+ node,
+ "node_wireframe",
+ in,
+ out,
+ GPU_builtin(GPU_BARYCENTRIC_TEXCO),
+ GPU_builtin(GPU_BARYCENTRIC_DIST));
}
/* node type definition */
diff --git a/source/blender/nodes/simulation/node_simulation_tree.cc b/source/blender/nodes/simulation/node_simulation_tree.cc
index 3f0e70259d6..eb3257d7e66 100644
--- a/source/blender/nodes/simulation/node_simulation_tree.cc
+++ b/source/blender/nodes/simulation/node_simulation_tree.cc
@@ -32,8 +32,8 @@ bNodeTreeType *ntreeType_Simulation;
void register_node_tree_type_sim(void)
{
- bNodeTreeType *tt = ntreeType_Simulation = (bNodeTreeType *)MEM_callocN(
- sizeof(bNodeTreeType), "simulation node tree type");
+ bNodeTreeType *tt = ntreeType_Simulation = static_cast<bNodeTreeType *>(
+ MEM_callocN(sizeof(bNodeTreeType), "simulation node tree type"));
tt->type = NTREE_SIMULATION;
strcpy(tt->idname, "SimulationNodeTree");
strcpy(tt->ui_name, N_("Simulation Editor"));
diff --git a/source/blender/nodes/simulation/node_simulation_util.h b/source/blender/nodes/simulation/node_simulation_util.h
index adbe2ad5e8f..76a10715cff 100644
--- a/source/blender/nodes/simulation/node_simulation_util.h
+++ b/source/blender/nodes/simulation/node_simulation_util.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NODE_SIM_UTIL_H__
-#define __NODE_SIM_UTIL_H__
+#pragma once
#include <string.h>
@@ -36,5 +35,3 @@
void sim_node_type_base(
struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
bool sim_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
-
-#endif /* __NODE_SIM_UTIL_H__ */
diff --git a/source/blender/nodes/simulation/nodes/node_sim_age_reached_event.cc b/source/blender/nodes/simulation/nodes/node_sim_age_reached_event.cc
new file mode 100644
index 00000000000..add8c4eba4d
--- /dev/null
+++ b/source/blender/nodes/simulation/nodes/node_sim_age_reached_event.cc
@@ -0,0 +1,38 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_age_reached_event_in[] = {
+ {SOCK_FLOAT, N_("Age"), 3, 0, 0, 0, 0, 10000000},
+ {SOCK_CONTROL_FLOW, N_("Execute")},
+ {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_age_reached_event_out[] = {
+ {SOCK_EVENTS, N_("Event")},
+ {-1, ""},
+};
+
+void register_node_type_sim_age_reached_event()
+{
+ static bNodeType ntype;
+
+ sim_node_type_base(&ntype, SIM_NODE_AGE_REACHED_EVENT, "Age Reached Event", 0, 0);
+ node_type_socket_templates(
+ &ntype, sim_node_age_reached_event_in, sim_node_age_reached_event_out);
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_kill_particle.cc b/source/blender/nodes/simulation/nodes/node_sim_kill_particle.cc
new file mode 100644
index 00000000000..793b40d9365
--- /dev/null
+++ b/source/blender/nodes/simulation/nodes/node_sim_kill_particle.cc
@@ -0,0 +1,36 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_kill_particle_in[] = {
+ {SOCK_CONTROL_FLOW, N_("Execute")},
+ {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_kill_particle_out[] = {
+ {SOCK_CONTROL_FLOW, N_("Execute")},
+ {-1, ""},
+};
+
+void register_node_type_sim_kill_particle()
+{
+ static bNodeType ntype;
+
+ sim_node_type_base(&ntype, SIM_NODE_KILL_PARTICLE, "Kill Particle", 0, 0);
+ node_type_socket_templates(&ntype, sim_node_kill_particle_in, sim_node_kill_particle_out);
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc b/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc
index 859ad81656b..5e1a6c35d52 100644
--- a/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc
+++ b/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc
@@ -21,6 +21,7 @@
static bNodeSocketTemplate sim_node_particle_mesh_emitter_in[] = {
{SOCK_OBJECT, N_("Object")},
{SOCK_FLOAT, N_("Rate"), 100.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX},
+ {SOCK_CONTROL_FLOW, N_("Execute")},
{-1, ""},
};
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c
index 1d7641753e0..981fc4e308a 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -145,14 +145,13 @@ void tex_output(bNode *node,
/* do not add a delegate if the node is muted */
return;
}
+
+ if (!out->data) {
+ /* Freed in tex_end_exec (node.c) */
+ dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate");
+ }
else {
- if (!out->data) {
- /* Freed in tex_end_exec (node.c) */
- dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate");
- }
- else {
- dg = out->data;
- }
+ dg = out->data;
}
dg->cdata = cdata;
diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h
index 7b8581c1f89..17a88ddaf5b 100644
--- a/source/blender/nodes/texture/node_texture_util.h
+++ b/source/blender/nodes/texture/node_texture_util.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_TEXTURE_UTIL_H__
-#define __NODE_TEXTURE_UTIL_H__
+#pragma once
#include <math.h>
#include <string.h>
@@ -131,5 +130,3 @@ void params_from_cdata(TexParams *out, TexCallData *in);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c
index d42985ba041..70f7e731720 100644
--- a/source/blender/nodes/texture/nodes/node_texture_curves.c
+++ b/source/blender/nodes/texture/nodes/node_texture_curves.c
@@ -39,7 +39,7 @@ static void time_colorfn(
fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1);
}
- BKE_curvemapping_initialize(node->storage);
+ BKE_curvemapping_init(node->storage);
fac = BKE_curvemapping_evaluateF(node->storage, 0, fac);
out[0] = CLAMPIS(fac, 0.0f, 1.0f);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.c b/source/blender/nodes/texture/nodes/node_texture_rotate.c
index 825f9d56147..06eb632378c 100644
--- a/source/blender/nodes/texture/nodes/node_texture_rotate.c
+++ b/source/blender/nodes/texture/nodes/node_texture_rotate.c
@@ -38,7 +38,7 @@ static bNodeSocketTemplate outputs[] = {
{-1, ""},
};
-static void rotate(float new_co[3], float a, float ax[3], const float co[3])
+static void rotate(float new_co[3], float a, const float ax[3], const float co[3])
{
float para[3];
float perp[3];
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index 049b919b4a4..7bcf96116b9 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -18,8 +18,7 @@
* \ingroup python
*/
-#ifndef __BPY_EXTERN_H__
-#define __BPY_EXTERN_H__
+#pragma once
struct AnimationEvalContext;
struct ChannelDriver; /* DNA_anim_types.h */
@@ -55,6 +54,7 @@ void BPY_python_start(int argc, const char **argv);
void BPY_python_end(void);
void BPY_python_reset(struct bContext *C);
void BPY_python_use_system_env(void);
+void BPY_python_backtrace(/* FILE */ void *file);
/* global interpreter lock */
@@ -140,5 +140,3 @@ const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *ms
#ifdef __cplusplus
} /* extern "C" */
#endif
-
-#endif /* __BPY_EXTERN_H__ */
diff --git a/source/blender/python/BPY_extern_clog.h b/source/blender/python/BPY_extern_clog.h
index d610dc1c7ba..14b57b4cc5c 100644
--- a/source/blender/python/BPY_extern_clog.h
+++ b/source/blender/python/BPY_extern_clog.h
@@ -20,11 +20,8 @@
* Logging defines.
*/
-#ifndef __BPY_EXTERN_CLOG_H__
-#define __BPY_EXTERN_CLOG_H__
+#pragma once
/* bpy_interface.c */
extern struct CLG_LogRef *BPY_LOG_RNA;
extern struct CLG_LogRef *BPY_LOG_CONTEXT;
-
-#endif /* __BPY_EXTERN_CLOG_H__ */
diff --git a/source/blender/python/bmesh/bmesh_py_api.h b/source/blender/python/bmesh/bmesh_py_api.h
index 9f227b21440..357f416f266 100644
--- a/source/blender/python/bmesh/bmesh_py_api.h
+++ b/source/blender/python/bmesh/bmesh_py_api.h
@@ -21,9 +21,6 @@
* \ingroup pybmesh
*/
-#ifndef __BMESH_PY_API_H__
-#define __BMESH_PY_API_H__
+#pragma once
PyObject *BPyInit_bmesh(void);
-
-#endif /* __BMESH_PY_API_H__ */
diff --git a/source/blender/python/bmesh/bmesh_py_geometry.h b/source/blender/python/bmesh/bmesh_py_geometry.h
index 98d336828dc..dcb8c59f68b 100644
--- a/source/blender/python/bmesh/bmesh_py_geometry.h
+++ b/source/blender/python/bmesh/bmesh_py_geometry.h
@@ -21,9 +21,6 @@
* \ingroup pybmesh
*/
-#ifndef __BMESH_PY_GEOMETRY_H__
-#define __BMESH_PY_GEOMETRY_H__
+#pragma once
PyObject *BPyInit_bmesh_geometry(void);
-
-#endif /* __BMESH_PY_GEOMETRY_H__ */
diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c
index 1eccfe06d15..cdbd4832159 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.c
+++ b/source/blender/python/bmesh/bmesh_py_ops.c
@@ -250,11 +250,9 @@ static PyObject *bpy_bmesh_ops_fakemod_getattro(PyObject *UNUSED(self), PyObject
if (BMO_opcode_from_opname(opname) != -1) {
return bpy_bmesh_op_CreatePyObject(opname);
}
- else {
- PyErr_Format(
- PyExc_AttributeError, "BMeshOpsModule: operator \"%.200s\" doesn't exist", opname);
- return NULL;
- }
+
+ PyErr_Format(PyExc_AttributeError, "BMeshOpsModule: operator \"%.200s\" doesn't exist", opname);
+ return NULL;
}
static PyObject *bpy_bmesh_ops_fakemod_dir(PyObject *UNUSED(self))
diff --git a/source/blender/python/bmesh/bmesh_py_ops.h b/source/blender/python/bmesh/bmesh_py_ops.h
index a4a12bbef61..442af51fd17 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.h
+++ b/source/blender/python/bmesh/bmesh_py_ops.h
@@ -21,9 +21,6 @@
* \ingroup pybmesh
*/
-#ifndef __BMESH_PY_OPS_H__
-#define __BMESH_PY_OPS_H__
+#pragma once
PyObject *BPyInit_bmesh_ops(void);
-
-#endif /* __BMESH_PY_OPS_H__ */
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c
index b1e5c1c761b..a387ba31c84 100644
--- a/source/blender/python/bmesh/bmesh_py_ops_call.c
+++ b/source/blender/python/bmesh/bmesh_py_ops_call.c
@@ -82,7 +82,7 @@ static int bpy_slot_from_py_elem_check(BPy_BMElem *value,
Py_TYPE(value)->tp_name);
return -1;
}
- else if (value->bm == NULL) {
+ if (value->bm == NULL) {
PyErr_Format(PyExc_TypeError,
"%.200s: keyword \"%.200s\" %.200s invalidated element",
opname,
@@ -90,7 +90,7 @@ static int bpy_slot_from_py_elem_check(BPy_BMElem *value,
descr);
return -1;
}
- else if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
+ if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
PyErr_Format(PyExc_TypeError,
"%.200s: keyword \"%.200s\" %.200s invalidated element",
opname,
@@ -127,7 +127,7 @@ static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value,
descr);
return -1;
}
- else if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
+ if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
PyErr_Format(PyExc_TypeError,
"%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
opname,
@@ -135,7 +135,7 @@ static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value,
descr);
return -1;
}
- else if ((htype_py & htype_bmo) == 0) {
+ if ((htype_py & htype_bmo) == 0) {
char str_bmo[32];
char str_py[32];
PyErr_Format(PyExc_TypeError,
@@ -175,9 +175,8 @@ static int bpy_slot_from_py(BMesh *bm,
Py_TYPE(value)->tp_name);
return -1;
}
- else {
- BMO_SLOT_AS_BOOL(slot) = param;
- }
+
+ BMO_SLOT_AS_BOOL(slot) = param;
break;
}
@@ -223,9 +222,8 @@ static int bpy_slot_from_py(BMesh *bm,
Py_TYPE(value)->tp_name);
return -1;
}
- else {
- BMO_SLOT_AS_INT(slot) = param;
- }
+
+ BMO_SLOT_AS_INT(slot) = param;
}
break;
}
@@ -239,9 +237,9 @@ static int bpy_slot_from_py(BMesh *bm,
Py_TYPE(value)->tp_name);
return -1;
}
- else {
- BMO_SLOT_AS_FLOAT(slot) = param;
- }
+
+ BMO_SLOT_AS_FLOAT(slot) = param;
+
break;
}
case BMO_OP_SLOT_MAT: {
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.h b/source/blender/python/bmesh/bmesh_py_ops_call.h
index 7b6611cd61d..6d9ceec73f6 100644
--- a/source/blender/python/bmesh/bmesh_py_ops_call.h
+++ b/source/blender/python/bmesh/bmesh_py_ops_call.h
@@ -21,8 +21,7 @@
* \ingroup pybmesh
*/
-#ifndef __BMESH_PY_OPS_CALL_H__
-#define __BMESH_PY_OPS_CALL_H__
+#pragma once
typedef struct {
PyObject_HEAD /* required python macro */
@@ -30,5 +29,3 @@ typedef struct {
} BPy_BMeshOpFunc;
PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw);
-
-#endif /* __BMESH_PY_OPS_CALL_H__ */
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index fccdfe7fbdc..e39b5faf3c4 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -292,14 +292,13 @@ static int bpy_bmesh_select_mode_set(BPy_BMesh *self, PyObject *value)
-1) {
return -1;
}
- else if (flag == 0) {
+ if (flag == 0) {
PyErr_SetString(PyExc_TypeError, "bm.select_mode: cant assignt an empty value");
return -1;
}
- else {
- self->bm->selectmode = flag;
- return 0;
- }
+
+ self->bm->selectmode = flag;
+ return 0;
}
PyDoc_STRVAR(bpy_bmesh_select_history_doc,
@@ -338,9 +337,8 @@ static int bpy_bmvert_co_set(BPy_BMVert *self, PyObject *value)
if (mathutils_array_parse(self->v->co, 3, 3, value, "BMVert.co") != -1) {
return 0;
}
- else {
- return -1;
- }
+
+ return -1;
}
PyDoc_STRVAR(
@@ -359,9 +357,8 @@ static int bpy_bmvert_normal_set(BPy_BMVert *self, PyObject *value)
if (mathutils_array_parse(self->v->no, 3, 3, value, "BMVert.normal") != -1) {
return 0;
}
- else {
- return -1;
- }
+
+ return -1;
}
PyDoc_STRVAR(bpy_bmvert_is_manifold_doc,
@@ -453,9 +450,8 @@ static int bpy_bmface_normal_set(BPy_BMFace *self, PyObject *value)
if (mathutils_array_parse(self->f->no, 3, 3, value, "BMFace.normal") != -1) {
return 0;
}
- else {
- return -1;
- }
+
+ return -1;
}
PyDoc_STRVAR(bpy_bmface_material_index_doc, "The face's material index.\n\n:type: int");
@@ -481,10 +477,9 @@ static int bpy_bmface_material_index_set(BPy_BMFace *self, PyObject *value)
PyErr_SetString(PyExc_ValueError, "material index outside of usable range (0 - 32766)");
return -1;
}
- else {
- self->f->mat_nr = (short)param;
- return 0;
- }
+
+ self->f->mat_nr = (short)param;
+ return 0;
}
/* Loop
@@ -586,9 +581,8 @@ static PyObject *bpy_bmfaceseq_active_get(BPy_BMElemSeq *self, void *UNUSED(clos
if (bm->act_face) {
return BPy_BMElem_CreatePyObject(bm, (BMHeader *)bm->act_face);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
static int bpy_bmfaceseq_active_set(BPy_BMElem *self, PyObject *value, void *UNUSED(closure))
@@ -598,18 +592,17 @@ static int bpy_bmfaceseq_active_set(BPy_BMElem *self, PyObject *value, void *UNU
bm->act_face = NULL;
return 0;
}
- else if (BPy_BMFace_Check(value)) {
+ if (BPy_BMFace_Check(value)) {
BPY_BM_CHECK_SOURCE_INT(bm, "faces.active = f", value);
bm->act_face = ((BPy_BMFace *)value)->f;
return 0;
}
- else {
- PyErr_Format(PyExc_TypeError,
- "faces.active = f: expected BMFace or None, not %.200s",
- Py_TYPE(value)->tp_name);
- return -1;
- }
+
+ PyErr_Format(PyExc_TypeError,
+ "faces.active = f: expected BMFace or None, not %.200s",
+ Py_TYPE(value)->tp_name);
+ return -1;
}
static PyGetSetDef bpy_bmesh_getseters[] = {
@@ -971,10 +964,9 @@ static PyObject *bpy_bmesh_copy(BPy_BMesh *self)
if (bm_copy) {
return BPy_BMesh_CreatePyObject(bm_copy, BPY_BMFLAG_NOP);
}
- else {
- PyErr_SetString(PyExc_SystemError, "Unable to copy BMesh, internal error");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_SystemError, "Unable to copy BMesh, internal error");
+ return NULL;
}
PyDoc_STRVAR(bpy_bmesh_clear_doc,
@@ -1141,9 +1133,8 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
"evaluation mode is RENDER");
return NULL;
}
- else {
- me_eval = mesh_create_eval_final_render(depsgraph, scene_eval, ob_eval, &data_masks);
- }
+
+ me_eval = mesh_create_eval_final_render(depsgraph, scene_eval, ob_eval, &data_masks);
}
else {
if (use_cage) {
@@ -1161,7 +1152,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
"from_object(...): cage arg is unsupported when deform=False");
return NULL;
}
- else if (use_render) {
+ if (use_render) {
me_eval = mesh_create_eval_no_deform_render(depsgraph, scene_eval, ob, &data_masks);
}
else {
@@ -1329,38 +1320,36 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject
&filter)) {
return NULL;
}
- else {
- BMVert *eve;
- BMIter iter;
- void *mat_ptr;
- if (BaseMath_ReadCallback(mat) == -1) {
- return NULL;
- }
- else if (mat->num_col != 4 || mat->num_row != 4) {
- PyErr_SetString(PyExc_ValueError, "expected a 4x4 matrix");
- return NULL;
- }
+ BMVert *eve;
+ BMIter iter;
+ void *mat_ptr;
- if (filter != NULL &&
- PyC_FlagSet_ToBitfield(bpy_bm_hflag_all_flags, filter, &filter_flags, "bm.transform") ==
- -1) {
- return NULL;
- }
+ if (BaseMath_ReadCallback(mat) == -1) {
+ return NULL;
+ }
+ if (mat->num_col != 4 || mat->num_row != 4) {
+ PyErr_SetString(PyExc_ValueError, "expected a 4x4 matrix");
+ return NULL;
+ }
- mat_ptr = mat->matrix;
+ if (filter != NULL && PyC_FlagSet_ToBitfield(
+ bpy_bm_hflag_all_flags, filter, &filter_flags, "bm.transform") == -1) {
+ return NULL;
+ }
- if (!filter_flags) {
- BM_ITER_MESH (eve, &iter, self->bm, BM_VERTS_OF_MESH) {
- mul_m4_v3((float(*)[4])mat_ptr, eve->co);
- }
+ mat_ptr = mat->matrix;
+
+ if (!filter_flags) {
+ BM_ITER_MESH (eve, &iter, self->bm, BM_VERTS_OF_MESH) {
+ mul_m4_v3((float(*)[4])mat_ptr, eve->co);
}
- else {
- char filter_flags_ch = (char)filter_flags;
- BM_ITER_MESH (eve, &iter, self->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(eve, filter_flags_ch)) {
- mul_m4_v3((float(*)[4])mat_ptr, eve->co);
- }
+ }
+ else {
+ char filter_flags_ch = (char)filter_flags;
+ BM_ITER_MESH (eve, &iter, self->bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(eve, filter_flags_ch)) {
+ mul_m4_v3((float(*)[4])mat_ptr, eve->co);
}
}
}
@@ -1388,9 +1377,8 @@ static PyObject *bpy_bmesh_calc_volume(BPy_BMElem *self, PyObject *args, PyObjec
args, kw, "|O!:calc_volume", (char **)kwlist, &PyBool_Type, &is_signed)) {
return NULL;
}
- else {
- return PyFloat_FromDouble(BM_mesh_calc_volume(self->bm, is_signed != Py_False));
- }
+
+ return PyFloat_FromDouble(BM_mesh_calc_volume(self->bm, is_signed != Py_False));
}
PyDoc_STRVAR(bpy_bmesh_calc_loop_triangles_doc,
@@ -1531,30 +1519,29 @@ static PyObject *bpy_bmvert_copy_from_vert_interp(BPy_BMVert *self, PyObject *ar
if (!PyArg_ParseTuple(args, "Of:BMVert.copy_from_vert_interp", &vert_seq, &fac)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- BMVert **vert_array = NULL;
- Py_ssize_t vert_seq_len; /* always 2 */
-
- vert_array = BPy_BMElem_PySeq_As_Array(&bm,
- vert_seq,
- 2,
- 2,
- &vert_seq_len,
- BM_VERT,
- true,
- true,
- "BMVert.copy_from_vert_interp(...)");
-
- if (vert_array == NULL) {
- return NULL;
- }
-
- BM_data_interp_from_verts(bm, vert_array[0], vert_array[1], self->v, clamp_f(fac, 0.0f, 1.0f));
- PyMem_FREE(vert_array);
- Py_RETURN_NONE;
+ BMesh *bm = self->bm;
+ BMVert **vert_array = NULL;
+ Py_ssize_t vert_seq_len; /* always 2 */
+
+ vert_array = BPy_BMElem_PySeq_As_Array(&bm,
+ vert_seq,
+ 2,
+ 2,
+ &vert_seq_len,
+ BM_VERT,
+ true,
+ true,
+ "BMVert.copy_from_vert_interp(...)");
+
+ if (vert_array == NULL) {
+ return NULL;
}
+
+ BM_data_interp_from_verts(bm, vert_array[0], vert_array[1], self->v, clamp_f(fac, 0.0f, 1.0f));
+
+ PyMem_FREE(vert_array);
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(bpy_bmvert_copy_from_face_interp_doc,
@@ -1574,15 +1561,14 @@ static PyObject *bpy_bmvert_copy_from_face_interp(BPy_BMVert *self, PyObject *ar
if (!PyArg_ParseTuple(args, "O!:BMVert.copy_from_face_interp", &BPy_BMFace_Type, &py_face)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- BPY_BM_CHECK_SOURCE_OBJ(bm, "copy_from_face_interp()", py_face);
+ BMesh *bm = self->bm;
- BM_vert_interp_from_face(bm, self->v, py_face->f);
+ BPY_BM_CHECK_SOURCE_OBJ(bm, "copy_from_face_interp()", py_face);
- Py_RETURN_NONE;
- }
+ BM_vert_interp_from_face(bm, self->v, py_face->f);
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(bpy_bmvert_calc_edge_angle_doc,
@@ -1615,12 +1601,11 @@ static PyObject *bpy_bmvert_calc_edge_angle(BPy_BMVert *self, PyObject *args)
Py_INCREF(fallback);
return fallback;
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "BMVert.calc_edge_angle(): "
- "vert must connect to exactly 2 edges");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError,
+ "BMVert.calc_edge_angle(): "
+ "vert must connect to exactly 2 edges");
+ return NULL;
}
return PyFloat_FromDouble(angle);
@@ -1697,12 +1682,11 @@ static PyObject *bpy_bmedge_calc_face_angle(BPy_BMEdge *self, PyObject *args)
Py_INCREF(fallback);
return fallback;
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "BMEdge.calc_face_angle(): "
- "edge doesn't use 2 faces");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError,
+ "BMEdge.calc_face_angle(): "
+ "edge doesn't use 2 faces");
+ return NULL;
}
return PyFloat_FromDouble(angle);
@@ -1737,12 +1721,11 @@ static PyObject *bpy_bmedge_calc_face_angle_signed(BPy_BMEdge *self, PyObject *a
Py_INCREF(fallback);
return fallback;
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "BMEdge.calc_face_angle_signed(): "
- "edge doesn't use 2 faces");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError,
+ "BMEdge.calc_face_angle_signed(): "
+ "edge doesn't use 2 faces");
+ return NULL;
}
return PyFloat_FromDouble(angle);
@@ -1767,13 +1750,12 @@ static PyObject *bpy_bmedge_calc_tangent(BPy_BMEdge *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O!:BMEdge.calc_face_tangent", &BPy_BMLoop_Type, &py_loop)) {
return NULL;
}
- else {
- float vec[3];
- BPY_BM_CHECK_OBJ(py_loop);
- /* no need to check if they are from the same mesh or even connected */
- BM_edge_calc_face_tangent(self->e, py_loop->l, vec);
- return Vector_CreatePyObject(vec, 3, NULL);
- }
+
+ float vec[3];
+ BPY_BM_CHECK_OBJ(py_loop);
+ /* no need to check if they are from the same mesh or even connected */
+ BM_edge_calc_face_tangent(self->e, py_loop->l, vec);
+ return Vector_CreatePyObject(vec, 3, NULL);
}
PyDoc_STRVAR(
@@ -1805,10 +1787,9 @@ static PyObject *bpy_bmedge_other_vert(BPy_BMEdge *self, BPy_BMVert *value)
if (other) {
return BPy_BMVert_CreatePyObject(self->bm, other);
}
- else {
- /* could raise an exception here */
- Py_RETURN_NONE;
- }
+
+ /* could raise an exception here */
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(bpy_bmedge_normal_update_doc,
@@ -1852,15 +1833,14 @@ static PyObject *bpy_bmface_copy_from_face_interp(BPy_BMFace *self, PyObject *ar
&do_vertex)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- BPY_BM_CHECK_SOURCE_OBJ(bm, "BMFace.copy_from_face_interp(face)", py_face);
+ BMesh *bm = self->bm;
- BM_face_interp_from_face(bm, self->f, py_face->f, do_vertex);
+ BPY_BM_CHECK_SOURCE_OBJ(bm, "BMFace.copy_from_face_interp(face)", py_face);
- Py_RETURN_NONE;
- }
+ BM_face_interp_from_face(bm, self->f, py_face->f, do_vertex);
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(bpy_bmface_copy_doc,
@@ -1901,11 +1881,9 @@ static PyObject *bpy_bmface_copy(BPy_BMFace *self, PyObject *args, PyObject *kw)
if (f_cpy) {
return BPy_BMFace_CreatePyObject(bm, f_cpy);
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "BMFace.copy(): couldn't create the new face, internal error");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError, "BMFace.copy(): couldn't create the new face, internal error");
+ return NULL;
}
PyDoc_STRVAR(bpy_bmface_calc_area_doc,
@@ -2109,15 +2087,14 @@ static PyObject *bpy_bmloop_copy_from_face_interp(BPy_BMLoop *self, PyObject *ar
&do_multires)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- BPY_BM_CHECK_SOURCE_OBJ(bm, "BMLoop.copy_from_face_interp(face)", py_face);
+ BMesh *bm = self->bm;
- BM_loop_interp_from_face(bm, self->l, py_face->f, do_vertex, do_multires);
+ BPY_BM_CHECK_SOURCE_OBJ(bm, "BMLoop.copy_from_face_interp(face)", py_face);
- Py_RETURN_NONE;
- }
+ BM_loop_interp_from_face(bm, self->l, py_face->f, do_vertex, do_multires);
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(bpy_bmloop_calc_angle_doc,
@@ -2190,33 +2167,32 @@ static PyObject *bpy_bmvertseq_new(BPy_BMElemSeq *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|OO!:verts.new", &py_co, &BPy_BMVert_Type, &py_vert_example)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- BMVert *v;
- float co[3] = {0.0f, 0.0f, 0.0f};
- if (py_vert_example) {
- BPY_BM_CHECK_OBJ(py_vert_example);
- }
+ BMesh *bm = self->bm;
+ BMVert *v;
+ float co[3] = {0.0f, 0.0f, 0.0f};
- if (py_co && mathutils_array_parse(co, 3, 3, py_co, "verts.new(co)") == -1) {
- return NULL;
- }
+ if (py_vert_example) {
+ BPY_BM_CHECK_OBJ(py_vert_example);
+ }
- v = BM_vert_create(bm, co, NULL, BM_CREATE_NOP);
+ if (py_co && mathutils_array_parse(co, 3, 3, py_co, "verts.new(co)") == -1) {
+ return NULL;
+ }
- if (v == NULL) {
- PyErr_SetString(PyExc_ValueError,
- "faces.new(verts): couldn't create the new face, internal error");
- return NULL;
- }
+ v = BM_vert_create(bm, co, NULL, BM_CREATE_NOP);
- if (py_vert_example) {
- BM_elem_attrs_copy(py_vert_example->bm, bm, py_vert_example->v, v);
- }
+ if (v == NULL) {
+ PyErr_SetString(PyExc_ValueError,
+ "faces.new(verts): couldn't create the new face, internal error");
+ return NULL;
+ }
- return BPy_BMVert_CreatePyObject(bm, v);
+ if (py_vert_example) {
+ BM_elem_attrs_copy(py_vert_example->bm, bm, py_vert_example->v, v);
}
+
+ return BPy_BMVert_CreatePyObject(bm, v);
}
/* Edge Seq
@@ -2242,49 +2218,48 @@ static PyObject *bpy_bmedgeseq_new(BPy_BMElemSeq *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O|O!:edges.new", &vert_seq, &BPy_BMEdge_Type, &py_edge_example)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- BMEdge *e;
- BMVert **vert_array = NULL;
- Py_ssize_t vert_seq_len; /* always 2 */
- PyObject *ret = NULL;
- if (py_edge_example) {
- BPY_BM_CHECK_OBJ(py_edge_example);
- }
+ BMesh *bm = self->bm;
+ BMEdge *e;
+ BMVert **vert_array = NULL;
+ Py_ssize_t vert_seq_len; /* always 2 */
+ PyObject *ret = NULL;
- vert_array = BPy_BMElem_PySeq_As_Array(
- &bm, vert_seq, 2, 2, &vert_seq_len, BM_VERT, true, true, "edges.new(...)");
+ if (py_edge_example) {
+ BPY_BM_CHECK_OBJ(py_edge_example);
+ }
- if (vert_array == NULL) {
- return NULL;
- }
+ vert_array = BPy_BMElem_PySeq_As_Array(
+ &bm, vert_seq, 2, 2, &vert_seq_len, BM_VERT, true, true, "edges.new(...)");
- if (BM_edge_exists(vert_array[0], vert_array[1])) {
- PyErr_SetString(PyExc_ValueError, "edges.new(): this edge exists");
- goto cleanup;
- }
+ if (vert_array == NULL) {
+ return NULL;
+ }
- e = BM_edge_create(bm, vert_array[0], vert_array[1], NULL, BM_CREATE_NOP);
+ if (BM_edge_exists(vert_array[0], vert_array[1])) {
+ PyErr_SetString(PyExc_ValueError, "edges.new(): this edge exists");
+ goto cleanup;
+ }
- if (e == NULL) {
- PyErr_SetString(PyExc_ValueError,
- "faces.new(verts): couldn't create the new face, internal error");
- goto cleanup;
- }
+ e = BM_edge_create(bm, vert_array[0], vert_array[1], NULL, BM_CREATE_NOP);
- if (py_edge_example) {
- BM_elem_attrs_copy(py_edge_example->bm, bm, py_edge_example->e, e);
- }
+ if (e == NULL) {
+ PyErr_SetString(PyExc_ValueError,
+ "faces.new(verts): couldn't create the new face, internal error");
+ goto cleanup;
+ }
- ret = BPy_BMEdge_CreatePyObject(bm, e);
+ if (py_edge_example) {
+ BM_elem_attrs_copy(py_edge_example->bm, bm, py_edge_example->e, e);
+ }
- cleanup:
- if (vert_array) {
- PyMem_FREE(vert_array);
- }
- return ret;
+ ret = BPy_BMEdge_CreatePyObject(bm, e);
+
+cleanup:
+ if (vert_array) {
+ PyMem_FREE(vert_array);
}
+ return ret;
}
/* Face Seq
@@ -2310,58 +2285,57 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O|O!:faces.new", &vert_seq, &BPy_BMFace_Type, &py_face_example)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- Py_ssize_t vert_seq_len;
- BMVert **vert_array = NULL;
+ BMesh *bm = self->bm;
+ Py_ssize_t vert_seq_len;
- PyObject *ret = NULL;
+ BMVert **vert_array = NULL;
- BMFace *f_new;
+ PyObject *ret = NULL;
- if (py_face_example) {
- BPY_BM_CHECK_OBJ(py_face_example);
- }
+ BMFace *f_new;
- vert_array = BPy_BMElem_PySeq_As_Array(
- &bm, vert_seq, 3, PY_SSIZE_T_MAX, &vert_seq_len, BM_VERT, true, true, "faces.new(...)");
+ if (py_face_example) {
+ BPY_BM_CHECK_OBJ(py_face_example);
+ }
- if (vert_array == NULL) {
- return NULL;
- }
+ vert_array = BPy_BMElem_PySeq_As_Array(
+ &bm, vert_seq, 3, PY_SSIZE_T_MAX, &vert_seq_len, BM_VERT, true, true, "faces.new(...)");
- /* check if the face exists */
- if (BM_face_exists(vert_array, vert_seq_len) != NULL) {
- PyErr_SetString(PyExc_ValueError, "faces.new(verts): face already exists");
- goto cleanup;
- }
+ if (vert_array == NULL) {
+ return NULL;
+ }
- /* Go ahead and make the face!
- * --------------------------- */
+ /* check if the face exists */
+ if (BM_face_exists(vert_array, vert_seq_len) != NULL) {
+ PyErr_SetString(PyExc_ValueError, "faces.new(verts): face already exists");
+ goto cleanup;
+ }
- f_new = BM_face_create_verts(bm,
- vert_array,
- vert_seq_len,
- py_face_example ? py_face_example->f : NULL,
- BM_CREATE_NOP,
- true);
+ /* Go ahead and make the face!
+ * --------------------------- */
- if (UNLIKELY(f_new == NULL)) {
- PyErr_SetString(PyExc_ValueError,
- "faces.new(verts): couldn't create the new face, internal error");
- goto cleanup;
- }
+ f_new = BM_face_create_verts(bm,
+ vert_array,
+ vert_seq_len,
+ py_face_example ? py_face_example->f : NULL,
+ BM_CREATE_NOP,
+ true);
- ret = BPy_BMFace_CreatePyObject(bm, f_new);
+ if (UNLIKELY(f_new == NULL)) {
+ PyErr_SetString(PyExc_ValueError,
+ "faces.new(verts): couldn't create the new face, internal error");
+ goto cleanup;
+ }
- /* pass through */
- cleanup:
- if (vert_array) {
- PyMem_FREE(vert_array);
- }
- return ret;
+ ret = BPy_BMFace_CreatePyObject(bm, f_new);
+
+ /* pass through */
+cleanup:
+ if (vert_array) {
+ PyMem_FREE(vert_array);
}
+ return ret;
}
/* Elem Seq
@@ -2378,16 +2352,15 @@ static PyObject *bpy_bmvertseq_remove(BPy_BMElemSeq *self, BPy_BMVert *value)
if (!BPy_BMVert_Check(value)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- BPY_BM_CHECK_SOURCE_OBJ(bm, "verts.remove(vert)", value);
+ BMesh *bm = self->bm;
- BM_vert_kill(bm, value->v);
- bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
+ BPY_BM_CHECK_SOURCE_OBJ(bm, "verts.remove(vert)", value);
- Py_RETURN_NONE;
- }
+ BM_vert_kill(bm, value->v);
+ bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(bpy_bmedgeseq_remove_doc,
@@ -2401,16 +2374,15 @@ static PyObject *bpy_bmedgeseq_remove(BPy_BMElemSeq *self, BPy_BMEdge *value)
if (!BPy_BMEdge_Check(value)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- BPY_BM_CHECK_SOURCE_OBJ(bm, "edges.remove(edges)", value);
+ BMesh *bm = self->bm;
- BM_edge_kill(bm, value->e);
- bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
+ BPY_BM_CHECK_SOURCE_OBJ(bm, "edges.remove(edges)", value);
- Py_RETURN_NONE;
- }
+ BM_edge_kill(bm, value->e);
+ bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(bpy_bmfaceseq_remove_doc,
@@ -2424,16 +2396,15 @@ static PyObject *bpy_bmfaceseq_remove(BPy_BMElemSeq *self, BPy_BMFace *value)
if (!BPy_BMFace_Check(value)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- BPY_BM_CHECK_SOURCE_OBJ(bm, "faces.remove(face)", value);
+ BMesh *bm = self->bm;
- BM_face_kill(bm, value->f);
- bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
+ BPY_BM_CHECK_SOURCE_OBJ(bm, "faces.remove(face)", value);
- Py_RETURN_NONE;
- }
+ BM_face_kill(bm, value->f);
+ bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(bpy_bmedgeseq_get__method_doc,
@@ -2456,31 +2427,30 @@ static PyObject *bpy_bmedgeseq_get__method(BPy_BMElemSeq *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O|O:edges.get", &vert_seq, &fallback)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- BMEdge *e;
- BMVert **vert_array = NULL;
- Py_ssize_t vert_seq_len; /* always 2 */
- PyObject *ret = NULL;
- vert_array = BPy_BMElem_PySeq_As_Array(
- &bm, vert_seq, 2, 2, &vert_seq_len, BM_VERT, true, true, "edges.get(...)");
+ BMesh *bm = self->bm;
+ BMEdge *e;
+ BMVert **vert_array = NULL;
+ Py_ssize_t vert_seq_len; /* always 2 */
+ PyObject *ret = NULL;
- if (vert_array == NULL) {
- return NULL;
- }
+ vert_array = BPy_BMElem_PySeq_As_Array(
+ &bm, vert_seq, 2, 2, &vert_seq_len, BM_VERT, true, true, "edges.get(...)");
- if ((e = BM_edge_exists(vert_array[0], vert_array[1]))) {
- ret = BPy_BMEdge_CreatePyObject(bm, e);
- }
- else {
- ret = fallback;
- Py_INCREF(ret);
- }
+ if (vert_array == NULL) {
+ return NULL;
+ }
- PyMem_FREE(vert_array);
- return ret;
+ if ((e = BM_edge_exists(vert_array[0], vert_array[1]))) {
+ ret = BPy_BMEdge_CreatePyObject(bm, e);
+ }
+ else {
+ ret = fallback;
+ Py_INCREF(ret);
}
+
+ PyMem_FREE(vert_array);
+ return ret;
}
PyDoc_STRVAR(bpy_bmfaceseq_get__method_doc,
@@ -2503,32 +2473,31 @@ static PyObject *bpy_bmfaceseq_get__method(BPy_BMElemSeq *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O|O:faces.get", &vert_seq, &fallback)) {
return NULL;
}
- else {
- BMesh *bm = self->bm;
- BMFace *f = NULL;
- BMVert **vert_array = NULL;
- Py_ssize_t vert_seq_len;
- PyObject *ret = NULL;
- vert_array = BPy_BMElem_PySeq_As_Array(
- &bm, vert_seq, 1, PY_SSIZE_T_MAX, &vert_seq_len, BM_VERT, true, true, "faces.get(...)");
+ BMesh *bm = self->bm;
+ BMFace *f = NULL;
+ BMVert **vert_array = NULL;
+ Py_ssize_t vert_seq_len;
+ PyObject *ret = NULL;
- if (vert_array == NULL) {
- return NULL;
- }
+ vert_array = BPy_BMElem_PySeq_As_Array(
+ &bm, vert_seq, 1, PY_SSIZE_T_MAX, &vert_seq_len, BM_VERT, true, true, "faces.get(...)");
- f = BM_face_exists(vert_array, vert_seq_len);
- if (f != NULL) {
- ret = BPy_BMFace_CreatePyObject(bm, f);
- }
- else {
- ret = fallback;
- Py_INCREF(ret);
- }
+ if (vert_array == NULL) {
+ return NULL;
+ }
- PyMem_FREE(vert_array);
- return ret;
+ f = BM_face_exists(vert_array, vert_seq_len);
+ if (f != NULL) {
+ ret = BPy_BMFace_CreatePyObject(bm, f);
}
+ else {
+ ret = fallback;
+ Py_INCREF(ret);
+ }
+
+ PyMem_FREE(vert_array);
+ return ret;
}
PyDoc_STRVAR(
@@ -2651,12 +2620,11 @@ static int bpy_bmelemseq_sort_cmp_by_keys_ascending(const void *index1_v,
if (keys[*index1] < keys[*index2]) {
return -1;
}
- else if (keys[*index1] > keys[*index2]) {
+ if (keys[*index1] > keys[*index2]) {
return 1;
}
- else {
- return 0;
- }
+
+ return 0;
}
static int bpy_bmelemseq_sort_cmp_by_keys_descending(const void *index1_v,
@@ -3260,54 +3228,51 @@ static PyObject *bpy_bmelemseq_subscript(BPy_BMElemSeq *self, PyObject *key)
}
return bpy_bmelemseq_subscript_int(self, i);
}
- else if (PySlice_Check(key)) {
+ if (PySlice_Check(key)) {
PySliceObject *key_slice = (PySliceObject *)key;
Py_ssize_t step = 1;
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
return NULL;
}
- else if (step != 1) {
+ if (step != 1) {
PyErr_SetString(PyExc_TypeError, "BMElemSeq[slice]: slice steps not supported");
return NULL;
}
- else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
+ if (key_slice->start == Py_None && key_slice->stop == Py_None) {
return bpy_bmelemseq_subscript_slice(self, 0, PY_SSIZE_T_MAX);
}
- else {
- Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- /* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
- if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
- return NULL;
- }
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
- return NULL;
- }
+ Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- if (start < 0 || stop < 0) {
- /* only get the length for negative values */
- Py_ssize_t len = bpy_bmelemseq_length(self);
- if (start < 0) {
- start += len;
- }
- if (stop < 0) {
- stop += len;
- }
- }
+ /* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
+ if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
+ return NULL;
+ }
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
+ return NULL;
+ }
- if (stop - start <= 0) {
- return PyList_New(0);
+ if (start < 0 || stop < 0) {
+ /* only get the length for negative values */
+ Py_ssize_t len = bpy_bmelemseq_length(self);
+ if (start < 0) {
+ start += len;
}
- else {
- return bpy_bmelemseq_subscript_slice(self, start, stop);
+ if (stop < 0) {
+ stop += len;
}
}
+
+ if (stop - start <= 0) {
+ return PyList_New(0);
+ }
+
+ return bpy_bmelemseq_subscript_slice(self, start, stop);
}
- else {
- PyErr_SetString(PyExc_AttributeError, "BMElemSeq[key]: invalid key, key must be an int");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_AttributeError, "BMElemSeq[key]: invalid key, key must be an int");
+ return NULL;
}
static int bpy_bmelemseq_contains(BPy_BMElemSeq *self, PyObject *value)
@@ -3395,9 +3360,8 @@ static PyObject *bpy_bmiter_next(BPy_BMIter *self)
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
- else {
- return (PyObject *)BPy_BMElem_CreatePyObject(self->bm, ele);
- }
+
+ return (PyObject *)BPy_BMElem_CreatePyObject(self->bm, ele);
}
/* Dealloc Functions
@@ -3532,9 +3496,8 @@ static PyObject *bpy_bmesh_repr(BPy_BMesh *self)
bm->totface,
bm->totloop);
}
- else {
- return PyUnicode_FromFormat("<BMesh dead at %p>", self);
- }
+
+ return PyUnicode_FromFormat("<BMesh dead at %p>", self);
}
static PyObject *bpy_bmvert_repr(BPy_BMVert *self)
@@ -3545,9 +3508,8 @@ static PyObject *bpy_bmvert_repr(BPy_BMVert *self)
BMVert *v = self->v;
return PyUnicode_FromFormat("<BMVert(%p), index=%d>", v, BM_elem_index_get(v));
}
- else {
- return PyUnicode_FromFormat("<BMVert dead at %p>", self);
- }
+
+ return PyUnicode_FromFormat("<BMVert dead at %p>", self);
}
static PyObject *bpy_bmedge_repr(BPy_BMEdge *self)
@@ -3564,9 +3526,8 @@ static PyObject *bpy_bmedge_repr(BPy_BMEdge *self)
e->v2,
BM_elem_index_get(e->v2));
}
- else {
- return PyUnicode_FromFormat("<BMEdge dead at %p>", self);
- }
+
+ return PyUnicode_FromFormat("<BMEdge dead at %p>", self);
}
static PyObject *bpy_bmface_repr(BPy_BMFace *self)
@@ -3578,9 +3539,8 @@ static PyObject *bpy_bmface_repr(BPy_BMFace *self)
return PyUnicode_FromFormat(
"<BMFace(%p), index=%d, totverts=%d>", f, BM_elem_index_get(f), f->len);
}
- else {
- return PyUnicode_FromFormat("<BMFace dead at %p>", self);
- }
+
+ return PyUnicode_FromFormat("<BMFace dead at %p>", self);
}
static PyObject *bpy_bmloop_repr(BPy_BMLoop *self)
@@ -3599,9 +3559,8 @@ static PyObject *bpy_bmloop_repr(BPy_BMLoop *self)
l->f,
BM_elem_index_get(l->f));
}
- else {
- return PyUnicode_FromFormat("<BMLoop dead at %p>", self);
- }
+
+ return PyUnicode_FromFormat("<BMLoop dead at %p>", self);
}
/* Types
@@ -4054,12 +4013,10 @@ int bpy_bm_generic_valid_check(BPy_BMGeneric *self)
return 0;
}
- else {
- PyErr_Format(PyExc_ReferenceError,
- "BMesh data of type %.200s has been removed",
- Py_TYPE(self)->tp_name);
- return -1;
- }
+
+ PyErr_Format(
+ PyExc_ReferenceError, "BMesh data of type %.200s has been removed", Py_TYPE(self)->tp_name);
+ return -1;
}
int bpy_bm_generic_valid_check_source(BMesh *bm_source,
@@ -4079,16 +4036,15 @@ int bpy_bm_generic_valid_check_source(BMesh *bm_source,
if (UNLIKELY(ret == -1)) {
break;
}
- else {
- if (UNLIKELY(py_bm_elem->bm != bm_source)) {
- /* could give more info here */
- PyErr_Format(PyExc_ValueError,
- "%.200s: BMesh data of type %.200s is from another mesh",
- error_prefix,
- Py_TYPE(py_bm_elem)->tp_name);
- ret = -1;
- break;
- }
+
+ if (UNLIKELY(py_bm_elem->bm != bm_source)) {
+ /* could give more info here */
+ PyErr_Format(PyExc_ValueError,
+ "%.200s: BMesh data of type %.200s is from another mesh",
+ error_prefix,
+ Py_TYPE(py_bm_elem)->tp_name);
+ ret = -1;
+ break;
}
}
}
diff --git a/source/blender/python/bmesh/bmesh_py_types.h b/source/blender/python/bmesh/bmesh_py_types.h
index 74bfbcec3c7..7ac3c4bf3cc 100644
--- a/source/blender/python/bmesh/bmesh_py_types.h
+++ b/source/blender/python/bmesh/bmesh_py_types.h
@@ -21,8 +21,7 @@
* \ingroup pybmesh
*/
-#ifndef __BMESH_PY_TYPES_H__
-#define __BMESH_PY_TYPES_H__
+#pragma once
extern PyTypeObject BPy_BMesh_Type;
extern PyTypeObject BPy_BMVert_Type;
@@ -228,5 +227,3 @@ extern struct PyC_FlagSet bpy_bm_htype_vert_edge_face_flags[];
extern struct PyC_FlagSet bpy_bm_htype_all_flags[];
extern struct PyC_FlagSet bpy_bm_hflag_all_flags[];
#endif
-
-#endif /* __BMESH_PY_TYPES_H__ */
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index 8615da653ae..51616030d30 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -67,10 +67,9 @@ static CustomDataLayer *bpy_bmlayeritem_get(BPy_BMLayerItem *self)
if (index_absolute != -1) {
return &data->layers[index_absolute];
}
- else {
- PyErr_SetString(PyExc_RuntimeError, "layer has become invalid");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_RuntimeError, "layer has become invalid");
+ return NULL;
}
/* py-type definitions
@@ -142,9 +141,8 @@ static PyObject *bpy_bmlayercollection_active_get(BPy_BMLayerItem *self, void *U
if (index != -1) {
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(
@@ -169,9 +167,8 @@ static PyObject *bpy_bmlayeritem_name_get(BPy_BMLayerItem *self, void *UNUSED(fl
if (layer) {
return PyUnicode_FromString(layer->name);
}
- else {
- return NULL;
- }
+
+ return NULL;
}
static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = {
@@ -617,16 +614,15 @@ static PyObject *bpy_bmlayercollection_get(BPy_BMLayerCollection *self, PyObject
if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) {
return NULL;
}
- else {
- CustomData *data;
- int index;
- data = bpy_bm_customdata_get(self->bm, self->htype);
- index = CustomData_get_named_layer(data, self->type, key); /* type relative */
+ CustomData *data;
+ int index;
- if (index != -1) {
- return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
- }
+ data = bpy_bm_customdata_get(self->bm, self->htype);
+ index = CustomData_get_named_layer(data, self->type, key); /* type relative */
+
+ if (index != -1) {
+ return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
}
return Py_INCREF_RET(def);
@@ -689,10 +685,9 @@ static PyObject *bpy_bmlayercollection_subscript_str(BPy_BMLayerCollection *self
if (index != -1) {
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, index);
}
- else {
- PyErr_Format(PyExc_KeyError, "BMLayerCollection[key]: key \"%.200s\" not found", keyname);
- return NULL;
- }
+
+ PyErr_Format(PyExc_KeyError, "BMLayerCollection[key]: key \"%.200s\" not found", keyname);
+ return NULL;
}
static PyObject *bpy_bmlayercollection_subscript_int(BPy_BMLayerCollection *self, int keynum)
@@ -750,62 +745,58 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
if (PyUnicode_Check(key)) {
return bpy_bmlayercollection_subscript_str(self, _PyUnicode_AsString(key));
}
- else if (PyIndex_Check(key)) {
+ if (PyIndex_Check(key)) {
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
if (i == -1 && PyErr_Occurred()) {
return NULL;
}
return bpy_bmlayercollection_subscript_int(self, i);
}
- else if (PySlice_Check(key)) {
+ if (PySlice_Check(key)) {
PySliceObject *key_slice = (PySliceObject *)key;
Py_ssize_t step = 1;
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
return NULL;
}
- else if (step != 1) {
+ if (step != 1) {
PyErr_SetString(PyExc_TypeError, "BMLayerCollection[slice]: slice steps not supported");
return NULL;
}
- else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
+ if (key_slice->start == Py_None && key_slice->stop == Py_None) {
return bpy_bmlayercollection_subscript_slice(self, 0, PY_SSIZE_T_MAX);
}
- else {
- Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- /* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
- if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
- return NULL;
- }
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
- return NULL;
- }
+ Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- if (start < 0 || stop < 0) {
- /* only get the length for negative values */
- Py_ssize_t len = bpy_bmlayercollection_length(self);
- if (start < 0) {
- start += len;
- }
- if (stop < 0) {
- stop += len;
- }
- }
+ /* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
+ if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
+ return NULL;
+ }
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
+ return NULL;
+ }
- if (stop - start <= 0) {
- return PyTuple_New(0);
+ if (start < 0 || stop < 0) {
+ /* only get the length for negative values */
+ Py_ssize_t len = bpy_bmlayercollection_length(self);
+ if (start < 0) {
+ start += len;
}
- else {
- return bpy_bmlayercollection_subscript_slice(self, start, stop);
+ if (stop < 0) {
+ stop += len;
}
}
+
+ if (stop - start <= 0) {
+ return PyTuple_New(0);
+ }
+
+ return bpy_bmlayercollection_subscript_slice(self, start, stop);
}
- else {
- PyErr_SetString(PyExc_AttributeError,
- "BMLayerCollection[key]: invalid key, key must be an int");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_AttributeError, "BMLayerCollection[key]: invalid key, key must be an int");
+ return NULL;
}
static int bpy_bmlayercollection_contains(BPy_BMLayerCollection *self, PyObject *value)
@@ -1024,11 +1015,11 @@ static void *bpy_bmlayeritem_ptr_get(BPy_BMElem *py_ele, BPy_BMLayerItem *py_lay
PyErr_SetString(PyExc_AttributeError, "BMElem[key]: invalid key, must be a BMLayerItem");
return NULL;
}
- else if (UNLIKELY(py_ele->bm != py_layer->bm)) {
+ if (UNLIKELY(py_ele->bm != py_layer->bm)) {
PyErr_SetString(PyExc_ValueError, "BMElem[layer]: layer is from another mesh");
return NULL;
}
- else if (UNLIKELY(ele->head.htype != py_layer->htype)) {
+ if (UNLIKELY(ele->head.htype != py_layer->htype)) {
char namestr_1[32], namestr_2[32];
PyErr_Format(PyExc_ValueError,
"Layer/Element type mismatch, expected %.200s got layer type %.200s",
@@ -1046,9 +1037,8 @@ static void *bpy_bmlayeritem_ptr_get(BPy_BMElem *py_ele, BPy_BMLayerItem *py_lay
PyErr_SetString(PyExc_KeyError, "BMElem[key]: layer not found");
return NULL;
}
- else {
- return value;
- }
+
+ return value;
}
/**
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.h b/source/blender/python/bmesh/bmesh_py_types_customdata.h
index 95836707e3d..3173813a912 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.h
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.h
@@ -21,8 +21,7 @@
* \ingroup pybmesh
*/
-#ifndef __BMESH_PY_TYPES_CUSTOMDATA_H__
-#define __BMESH_PY_TYPES_CUSTOMDATA_H__
+#pragma once
/* all use BPy_BMLayerAccess struct */
extern PyTypeObject BPy_BMLayerAccessVert_Type;
@@ -67,5 +66,3 @@ void BPy_BM_init_types_customdata(void);
/* __getitem__ / __setitem__ */
PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer);
int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObject *value);
-
-#endif /* __BMESH_PY_TYPES_CUSTOMDATA_H__ */
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
index 82b6cf5c3d5..f42348975c9 100644
--- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
@@ -65,9 +65,8 @@ static int bpy_bmloopuv_uv_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED
copy_v2_v2(self->data->uv, tvec);
return 0;
}
- else {
- return -1;
- }
+
+ return -1;
}
PyDoc_STRVAR(bpy_bmloopuv_flag__pin_uv_doc, "UV pin state.\n\n:type: boolean");
@@ -136,10 +135,9 @@ int BPy_BMLoopUV_AssignPyObject(struct MLoopUV *mloopuv, PyObject *value)
PyErr_Format(PyExc_TypeError, "expected BMLoopUV, not a %.200s", Py_TYPE(value)->tp_name);
return -1;
}
- else {
- *((MLoopUV *)mloopuv) = *(((BPy_BMLoopUV *)value)->data);
- return 0;
- }
+
+ *((MLoopUV *)mloopuv) = *(((BPy_BMLoopUV *)value)->data);
+ return 0;
}
PyObject *BPy_BMLoopUV_CreatePyObject(struct MLoopUV *mloopuv)
@@ -174,9 +172,8 @@ static int bpy_bmvertskin_radius_set(BPy_BMVertSkin *self, PyObject *value, void
copy_v2_v2(self->data->radius, tvec);
return 0;
}
- else {
- return -1;
- }
+
+ return -1;
}
PyDoc_STRVAR(bpy_bmvertskin_flag__use_root_doc,
@@ -251,10 +248,9 @@ int BPy_BMVertSkin_AssignPyObject(struct MVertSkin *mvertskin, PyObject *value)
PyErr_Format(PyExc_TypeError, "expected BMVertSkin, not a %.200s", Py_TYPE(value)->tp_name);
return -1;
}
- else {
- *((MVertSkin *)mvertskin) = *(((BPy_BMVertSkin *)value)->data);
- return 0;
- }
+
+ *((MVertSkin *)mvertskin) = *(((BPy_BMVertSkin *)value)->data);
+ return 0;
}
PyObject *BPy_BMVertSkin_CreatePyObject(struct MVertSkin *mvertskin)
@@ -351,9 +347,8 @@ int BPy_BMLoopColor_AssignPyObject(struct MLoopCol *mloopcol, PyObject *value)
mloopcol_from_float(mloopcol, tvec);
return 0;
}
- else {
- return -1;
- }
+
+ return -1;
}
PyObject *BPy_BMLoopColor_CreatePyObject(struct MLoopCol *data)
@@ -416,25 +411,22 @@ static PyObject *bpy_bmdeformvert_subscript(BPy_BMDeformVert *self, PyObject *ke
if (i == -1 && PyErr_Occurred()) {
return NULL;
}
- else {
- MDeformWeight *dw = BKE_defvert_find_index(self->data, i);
- if (dw == NULL) {
- PyErr_SetString(PyExc_KeyError,
- "BMDeformVert[key] = x: "
- "key not found");
- return NULL;
- }
- else {
- return PyFloat_FromDouble(dw->weight);
- }
+ MDeformWeight *dw = BKE_defvert_find_index(self->data, i);
+
+ if (dw == NULL) {
+ PyErr_SetString(PyExc_KeyError,
+ "BMDeformVert[key] = x: "
+ "key not found");
+ return NULL;
}
+
+ return PyFloat_FromDouble(dw->weight);
}
- else {
- PyErr_Format(
- PyExc_TypeError, "BMDeformVert keys must be integers, not %.200s", Py_TYPE(key)->tp_name);
- return NULL;
- }
+
+ PyErr_Format(
+ PyExc_TypeError, "BMDeformVert keys must be integers, not %.200s", Py_TYPE(key)->tp_name);
+ return NULL;
}
static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key, PyObject *value)
@@ -455,18 +447,17 @@ static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key,
"weight keys can't be negative");
return -1;
}
- else {
- MDeformWeight *dw = BKE_defvert_ensure_index(self->data, i);
- const float f = PyFloat_AsDouble(value);
- if (f == -1 && PyErr_Occurred()) { // parsed key not a number
- PyErr_SetString(PyExc_TypeError,
- "BMDeformVert[key] = x: "
- "assigned value not a number");
- return -1;
- }
-
- dw->weight = clamp_f(f, 0.0f, 1.0f);
+
+ MDeformWeight *dw = BKE_defvert_ensure_index(self->data, i);
+ const float f = PyFloat_AsDouble(value);
+ if (f == -1 && PyErr_Occurred()) { // parsed key not a number
+ PyErr_SetString(PyExc_TypeError,
+ "BMDeformVert[key] = x: "
+ "assigned value not a number");
+ return -1;
}
+
+ dw->weight = clamp_f(f, 0.0f, 1.0f);
}
else {
/* del dvert[group_index] */
@@ -482,11 +473,10 @@ static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key,
return 0;
}
- else {
- PyErr_Format(
- PyExc_TypeError, "BMDeformVert keys must be integers, not %.200s", Py_TYPE(key)->tp_name);
- return -1;
- }
+
+ PyErr_Format(
+ PyExc_TypeError, "BMDeformVert keys must be integers, not %.200s", Py_TYPE(key)->tp_name);
+ return -1;
}
static int bpy_bmdeformvert_contains(BPy_BMDeformVert *self, PyObject *value)
@@ -616,16 +606,14 @@ static PyObject *bpy_bmdeformvert_get(BPy_BMDeformVert *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i|O:get", &key, &def)) {
return NULL;
}
- else {
- MDeformWeight *dw = BKE_defvert_find_index(self->data, key);
- if (dw) {
- return PyFloat_FromDouble(dw->weight);
- }
- else {
- return Py_INCREF_RET(def);
- }
+ MDeformWeight *dw = BKE_defvert_find_index(self->data, key);
+
+ if (dw) {
+ return PyFloat_FromDouble(dw->weight);
}
+
+ return Py_INCREF_RET(def);
}
PyDoc_STRVAR(bpy_bmdeformvert_clear_doc,
@@ -675,13 +663,12 @@ int BPy_BMDeformVert_AssignPyObject(struct MDeformVert *dvert, PyObject *value)
PyErr_Format(PyExc_TypeError, "expected BMDeformVert, not a %.200s", Py_TYPE(value)->tp_name);
return -1;
}
- else {
- MDeformVert *dvert_src = ((BPy_BMDeformVert *)value)->data;
- if (LIKELY(dvert != dvert_src)) {
- BKE_defvert_copy(dvert, dvert_src);
- }
- return 0;
+
+ MDeformVert *dvert_src = ((BPy_BMDeformVert *)value)->data;
+ if (LIKELY(dvert != dvert_src)) {
+ BKE_defvert_copy(dvert, dvert_src);
}
+ return 0;
}
PyObject *BPy_BMDeformVert_CreatePyObject(struct MDeformVert *dvert)
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.h b/source/blender/python/bmesh/bmesh_py_types_meshdata.h
index 5211c30ec7e..58f31a9807e 100644
--- a/source/blender/python/bmesh/bmesh_py_types_meshdata.h
+++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.h
@@ -21,8 +21,7 @@
* \ingroup pybmesh
*/
-#ifndef __BMESH_PY_TYPES_MESHDATA_H__
-#define __BMESH_PY_TYPES_MESHDATA_H__
+#pragma once
extern PyTypeObject BPy_BMLoopUV_Type;
extern PyTypeObject BPy_BMDeformVert_Type;
@@ -51,5 +50,3 @@ int BPy_BMDeformVert_AssignPyObject(struct MDeformVert *dvert, PyObject *value);
PyObject *BPy_BMDeformVert_CreatePyObject(struct MDeformVert *dvert);
void BPy_BM_init_types_meshdata(void);
-
-#endif /* __BMESH_PY_TYPES_MESHDATA_H__ */
diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c
index 5e064453a04..d69668341ff 100644
--- a/source/blender/python/bmesh/bmesh_py_types_select.c
+++ b/source/blender/python/bmesh/bmesh_py_types_select.c
@@ -51,9 +51,8 @@ static PyObject *bpy_bmeditselseq_active_get(BPy_BMEditSelSeq *self, void *UNUSE
if ((ese = self->bm->selected.last)) {
return BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
static PyGetSetDef bpy_bmeditselseq_getseters[] = {
@@ -196,10 +195,9 @@ static PyObject *bpy_bmeditselseq_subscript_int(BPy_BMEditSelSeq *self, int keyn
if (ese) {
return BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head);
}
- else {
- PyErr_Format(PyExc_IndexError, "BMElemSeq[index]: index %d out of range", keynum);
- return NULL;
- }
+
+ PyErr_Format(PyExc_IndexError, "BMElemSeq[index]: index %d out of range", keynum);
+ return NULL;
}
static PyObject *bpy_bmeditselseq_subscript_slice(BPy_BMEditSelSeq *self,
@@ -254,54 +252,51 @@ static PyObject *bpy_bmeditselseq_subscript(BPy_BMEditSelSeq *self, PyObject *ke
}
return bpy_bmeditselseq_subscript_int(self, i);
}
- else if (PySlice_Check(key)) {
+ if (PySlice_Check(key)) {
PySliceObject *key_slice = (PySliceObject *)key;
Py_ssize_t step = 1;
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
return NULL;
}
- else if (step != 1) {
+ if (step != 1) {
PyErr_SetString(PyExc_TypeError, "BMElemSeq[slice]: slice steps not supported");
return NULL;
}
- else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
+ if (key_slice->start == Py_None && key_slice->stop == Py_None) {
return bpy_bmeditselseq_subscript_slice(self, 0, PY_SSIZE_T_MAX);
}
- else {
- Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- /* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
- if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
- return NULL;
- }
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
- return NULL;
- }
+ Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- if (start < 0 || stop < 0) {
- /* only get the length for negative values */
- Py_ssize_t len = bpy_bmeditselseq_length(self);
- if (start < 0) {
- start += len;
- }
- if (stop < 0) {
- stop += len;
- }
- }
+ /* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
+ if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
+ return NULL;
+ }
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
+ return NULL;
+ }
- if (stop - start <= 0) {
- return PyList_New(0);
+ if (start < 0 || stop < 0) {
+ /* only get the length for negative values */
+ Py_ssize_t len = bpy_bmeditselseq_length(self);
+ if (start < 0) {
+ start += len;
}
- else {
- return bpy_bmeditselseq_subscript_slice(self, start, stop);
+ if (stop < 0) {
+ stop += len;
}
}
+
+ if (stop - start <= 0) {
+ return PyList_New(0);
+ }
+
+ return bpy_bmeditselseq_subscript_slice(self, start, stop);
}
- else {
- PyErr_SetString(PyExc_AttributeError, "BMElemSeq[key]: invalid key, key must be an int");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_AttributeError, "BMElemSeq[key]: invalid key, key must be an int");
+ return NULL;
}
static int bpy_bmeditselseq_contains(BPy_BMEditSelSeq *self, PyObject *value)
@@ -358,10 +353,9 @@ static PyObject *bpy_bmeditseliter_next(BPy_BMEditSelIter *self)
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
- else {
- self->ese = ese->next;
- return (PyObject *)BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head);
- }
+
+ self->ese = ese->next;
+ return (PyObject *)BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head);
}
PyTypeObject BPy_BMEditSelSeq_Type;
diff --git a/source/blender/python/bmesh/bmesh_py_types_select.h b/source/blender/python/bmesh/bmesh_py_types_select.h
index 593857a5083..c33aa3675c5 100644
--- a/source/blender/python/bmesh/bmesh_py_types_select.h
+++ b/source/blender/python/bmesh/bmesh_py_types_select.h
@@ -21,8 +21,7 @@
* \ingroup pybmesh
*/
-#ifndef __BMESH_PY_TYPES_SELECT_H__
-#define __BMESH_PY_TYPES_SELECT_H__
+#pragma once
struct BPy_BMesh;
@@ -46,5 +45,3 @@ void BPy_BM_init_types_select(void);
PyObject *BPy_BMEditSel_CreatePyObject(BMesh *bm);
PyObject *BPy_BMEditSelIter_CreatePyObject(BMesh *bm);
int BPy_BMEditSel_Assign(struct BPy_BMesh *self, PyObject *value);
-
-#endif /* __BMESH_PY_SELECT_H__ */
diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c
index 9b207693e37..eab9ab226e4 100644
--- a/source/blender/python/bmesh/bmesh_py_utils.c
+++ b/source/blender/python/bmesh/bmesh_py_utils.c
@@ -91,11 +91,10 @@ static PyObject *bpy_bm_utils_vert_collapse_edge(PyObject *UNUSED(self), PyObjec
if (e_new) {
return BPy_BMEdge_CreatePyObject(bm, e_new);
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "vert_collapse_edge(vert, edge): no new edge created, internal error");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError,
+ "vert_collapse_edge(vert, edge): no new edge created, internal error");
+ return NULL;
}
PyDoc_STRVAR(bpy_bm_utils_vert_collapse_faces_doc,
@@ -158,11 +157,10 @@ static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObje
if (e_new) {
return BPy_BMEdge_CreatePyObject(bm, e_new);
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "vert_collapse_faces(vert, edge): no new edge created, internal error");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError,
+ "vert_collapse_faces(vert, edge): no new edge created, internal error");
+ return NULL;
}
PyDoc_STRVAR(bpy_bm_utils_vert_dissolve_doc,
@@ -360,11 +358,10 @@ static PyObject *bpy_bm_utils_edge_split(PyObject *UNUSED(self), PyObject *args)
ret, BPy_BMEdge_CreatePyObject(bm, e_new), BPy_BMVert_CreatePyObject(bm, v_new));
return ret;
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "edge_split(edge, vert): couldn't split the edge, internal error");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError,
+ "edge_split(edge, vert): couldn't split the edge, internal error");
+ return NULL;
}
PyDoc_STRVAR(bpy_bm_utils_edge_rotate_doc,
@@ -401,9 +398,8 @@ static PyObject *bpy_bm_utils_edge_rotate(PyObject *UNUSED(self), PyObject *args
if (e_new) {
return BPy_BMEdge_CreatePyObject(bm, e_new);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(
@@ -534,10 +530,9 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args,
ret, BPy_BMFace_CreatePyObject(bm, f_new), BPy_BMLoop_CreatePyObject(bm, l_new));
return ret;
}
- else {
- PyErr_SetString(PyExc_ValueError, "face_split(...): couldn't split the face, internal error");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError, "face_split(...): couldn't split the face, internal error");
+ return NULL;
}
PyDoc_STRVAR(bpy_bm_utils_face_split_edgenet_doc,
@@ -617,11 +612,10 @@ static PyObject *bpy_bm_utils_face_split_edgenet(PyObject *UNUSED(self),
}
return ret;
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "face_split_edgenet(...): couldn't split the face, internal error");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError,
+ "face_split_edgenet(...): couldn't split the face, internal error");
+ return NULL;
}
PyDoc_STRVAR(bpy_bm_utils_face_join_doc,
@@ -664,9 +658,8 @@ static PyObject *bpy_bm_utils_face_join(PyObject *UNUSED(self), PyObject *args)
if (f_new) {
return BPy_BMFace_CreatePyObject(bm, f_new);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(
@@ -721,9 +714,8 @@ static PyObject *bpy_bm_utils_face_vert_separate(PyObject *UNUSED(self), PyObjec
if (v_new != v_old) {
return BPy_BMVert_CreatePyObject(bm, v_new);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(bpy_bm_utils_face_flip_doc,
@@ -782,9 +774,8 @@ static PyObject *bpy_bm_utils_loop_separate(PyObject *UNUSED(self), BPy_BMLoop *
if (v_new != v_old) {
return BPy_BMVert_CreatePyObject(bm, v_new);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
static struct PyMethodDef BPy_BM_utils_methods[] = {
diff --git a/source/blender/python/bmesh/bmesh_py_utils.h b/source/blender/python/bmesh/bmesh_py_utils.h
index a6f4f22bf8b..27eccca4535 100644
--- a/source/blender/python/bmesh/bmesh_py_utils.h
+++ b/source/blender/python/bmesh/bmesh_py_utils.h
@@ -21,9 +21,6 @@
* \ingroup pybmesh
*/
-#ifndef __BMESH_PY_UTILS_H__
-#define __BMESH_PY_UTILS_H__
+#pragma once
PyObject *BPyInit_bmesh_utils(void);
-
-#endif /* __BMESH_PY_UTILS_H__ */
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 2ad2794c76f..405541554c9 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -415,10 +415,9 @@ typedef struct BufferOrOffset {
if (ret_str) { \
return PyUnicode_FromString((const char *)ret_str); \
} \
- else { \
- PyErr_SetString(PyExc_AttributeError, "could not get opengl string"); \
- return NULL; \
- }
+\
+ PyErr_SetString(PyExc_AttributeError, "could not get opengl string"); \
+ return NULL;
/** \} */
@@ -705,7 +704,7 @@ static int BGL_BufferOrOffsetConverter(PyObject *object, BufferOrOffset *buffer)
buffer->offset = NULL;
return 1;
}
- else if (PyNumber_Check(object)) {
+ if (PyNumber_Check(object)) {
Py_ssize_t offset = PyNumber_AsSsize_t(object, PyExc_IndexError);
if (offset == -1 && PyErr_Occurred()) {
return 0;
@@ -715,15 +714,14 @@ static int BGL_BufferOrOffsetConverter(PyObject *object, BufferOrOffset *buffer)
buffer->offset = (void *)offset;
return 1;
}
- else if (PyObject_TypeCheck(object, &BGL_bufferType)) {
+ if (PyObject_TypeCheck(object, &BGL_bufferType)) {
buffer->buffer = (Buffer *)object;
buffer->offset = NULL;
return 1;
}
- else {
- PyErr_SetString(PyExc_TypeError, "expected a bgl.Buffer or None");
- return 0;
- }
+
+ PyErr_SetString(PyExc_TypeError, "expected a bgl.Buffer or None");
+ return 0;
}
#define MAX_DIMENSIONS 256
@@ -766,7 +764,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
"too many dimensions, max is " STRINGIFY(MAX_DIMENSIONS));
return NULL;
}
- else if (ndimensions < 1) {
+ if (ndimensions < 1) {
PyErr_SetString(PyExc_AttributeError, "sequence must have at least one dimension");
return NULL;
}
@@ -913,9 +911,8 @@ static int Buffer_ass_item(Buffer *self, int i, PyObject *v)
Py_DECREF(row);
return ret;
}
- else {
- return -1;
- }
+
+ return -1;
}
switch (self->type) {
@@ -996,7 +993,7 @@ static PyObject *Buffer_subscript(Buffer *self, PyObject *item)
}
return Buffer_item(self, i);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0) {
@@ -1006,19 +1003,17 @@ static PyObject *Buffer_subscript(Buffer *self, PyObject *item)
if (slicelength <= 0) {
return PyTuple_New(0);
}
- else if (step == 1) {
+ if (step == 1) {
return Buffer_slice(self, start, stop);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
- return NULL;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "buffer indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
return NULL;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "buffer indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return NULL;
}
static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value)
@@ -1033,7 +1028,7 @@ static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value)
}
return Buffer_ass_item(self, i, value);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0) {
@@ -1043,16 +1038,14 @@ static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value)
if (step == 1) {
return Buffer_ass_slice(self, start, stop, value);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
- return -1;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "buffer indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
return -1;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "buffer indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return -1;
}
static void Buffer_dealloc(Buffer *self)
@@ -1442,24 +1435,10 @@ static void py_module_dict_add_method(PyObject *submodule,
}
}
-PyObject *BPyInit_bgl(void)
-{
- PyObject *submodule, *dict;
- submodule = PyModule_Create(&BGL_module_def);
- dict = PyModule_GetDict(submodule);
-
- if (PyType_Ready(&BGL_bufferType) < 0) {
- return NULL; /* should never happen */
- }
-
- PyModule_AddObject(submodule, "Buffer", (PyObject *)&BGL_bufferType);
- Py_INCREF((PyObject *)&BGL_bufferType);
-
/* needed since some function pointers won't be NULL */
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Waddress"
#endif
-
#define PY_MOD_ADD_METHOD(func) \
{ \
static PyMethodDef method_def = {"gl" #func, Method_##func, METH_VARARGS}; \
@@ -1467,788 +1446,790 @@ PyObject *BPyInit_bgl(void)
} \
((void)0)
+static void init_bgl_version_1_0_methods(PyObject *submodule, PyObject *dict)
+{
/* GL_VERSION_1_0 */
- {
- PY_MOD_ADD_METHOD(BlendFunc);
- PY_MOD_ADD_METHOD(Clear);
- PY_MOD_ADD_METHOD(ClearColor);
- PY_MOD_ADD_METHOD(ClearDepth);
- PY_MOD_ADD_METHOD(ClearStencil);
- PY_MOD_ADD_METHOD(ColorMask);
- PY_MOD_ADD_METHOD(CullFace);
- PY_MOD_ADD_METHOD(DepthFunc);
- PY_MOD_ADD_METHOD(DepthMask);
- PY_MOD_ADD_METHOD(DepthRange);
- PY_MOD_ADD_METHOD(Disable);
- PY_MOD_ADD_METHOD(DrawBuffer);
- PY_MOD_ADD_METHOD(Enable);
- PY_MOD_ADD_METHOD(Finish);
- PY_MOD_ADD_METHOD(Flush);
- PY_MOD_ADD_METHOD(FrontFace);
- PY_MOD_ADD_METHOD(GetBooleanv);
- PY_MOD_ADD_METHOD(GetDoublev);
- PY_MOD_ADD_METHOD(GetError);
- PY_MOD_ADD_METHOD(GetFloatv);
- PY_MOD_ADD_METHOD(GetIntegerv);
- PY_MOD_ADD_METHOD(GetString);
- PY_MOD_ADD_METHOD(GetTexImage);
- PY_MOD_ADD_METHOD(GetTexLevelParameterfv);
- PY_MOD_ADD_METHOD(GetTexLevelParameteriv);
- PY_MOD_ADD_METHOD(GetTexParameterfv);
- PY_MOD_ADD_METHOD(GetTexParameteriv);
- PY_MOD_ADD_METHOD(Hint);
- PY_MOD_ADD_METHOD(IsEnabled);
- PY_MOD_ADD_METHOD(LineWidth);
- PY_MOD_ADD_METHOD(LogicOp);
- PY_MOD_ADD_METHOD(PixelStoref);
- PY_MOD_ADD_METHOD(PixelStorei);
- PY_MOD_ADD_METHOD(PointSize);
- PY_MOD_ADD_METHOD(PolygonMode);
- PY_MOD_ADD_METHOD(ReadBuffer);
- PY_MOD_ADD_METHOD(ReadPixels);
- PY_MOD_ADD_METHOD(Scissor);
- PY_MOD_ADD_METHOD(StencilFunc);
- PY_MOD_ADD_METHOD(StencilMask);
- PY_MOD_ADD_METHOD(StencilOp);
- PY_MOD_ADD_METHOD(TexImage1D);
- PY_MOD_ADD_METHOD(TexImage2D);
- PY_MOD_ADD_METHOD(TexParameterf);
- PY_MOD_ADD_METHOD(TexParameterfv);
- PY_MOD_ADD_METHOD(TexParameteri);
- PY_MOD_ADD_METHOD(TexParameteriv);
- PY_MOD_ADD_METHOD(Viewport);
- }
-
+ PY_MOD_ADD_METHOD(BlendFunc);
+ PY_MOD_ADD_METHOD(Clear);
+ PY_MOD_ADD_METHOD(ClearColor);
+ PY_MOD_ADD_METHOD(ClearDepth);
+ PY_MOD_ADD_METHOD(ClearStencil);
+ PY_MOD_ADD_METHOD(ColorMask);
+ PY_MOD_ADD_METHOD(CullFace);
+ PY_MOD_ADD_METHOD(DepthFunc);
+ PY_MOD_ADD_METHOD(DepthMask);
+ PY_MOD_ADD_METHOD(DepthRange);
+ PY_MOD_ADD_METHOD(Disable);
+ PY_MOD_ADD_METHOD(DrawBuffer);
+ PY_MOD_ADD_METHOD(Enable);
+ PY_MOD_ADD_METHOD(Finish);
+ PY_MOD_ADD_METHOD(Flush);
+ PY_MOD_ADD_METHOD(FrontFace);
+ PY_MOD_ADD_METHOD(GetBooleanv);
+ PY_MOD_ADD_METHOD(GetDoublev);
+ PY_MOD_ADD_METHOD(GetError);
+ PY_MOD_ADD_METHOD(GetFloatv);
+ PY_MOD_ADD_METHOD(GetIntegerv);
+ PY_MOD_ADD_METHOD(GetString);
+ PY_MOD_ADD_METHOD(GetTexImage);
+ PY_MOD_ADD_METHOD(GetTexLevelParameterfv);
+ PY_MOD_ADD_METHOD(GetTexLevelParameteriv);
+ PY_MOD_ADD_METHOD(GetTexParameterfv);
+ PY_MOD_ADD_METHOD(GetTexParameteriv);
+ PY_MOD_ADD_METHOD(Hint);
+ PY_MOD_ADD_METHOD(IsEnabled);
+ PY_MOD_ADD_METHOD(LineWidth);
+ PY_MOD_ADD_METHOD(LogicOp);
+ PY_MOD_ADD_METHOD(PixelStoref);
+ PY_MOD_ADD_METHOD(PixelStorei);
+ PY_MOD_ADD_METHOD(PointSize);
+ PY_MOD_ADD_METHOD(PolygonMode);
+ PY_MOD_ADD_METHOD(ReadBuffer);
+ PY_MOD_ADD_METHOD(ReadPixels);
+ PY_MOD_ADD_METHOD(Scissor);
+ PY_MOD_ADD_METHOD(StencilFunc);
+ PY_MOD_ADD_METHOD(StencilMask);
+ PY_MOD_ADD_METHOD(StencilOp);
+ PY_MOD_ADD_METHOD(TexImage1D);
+ PY_MOD_ADD_METHOD(TexImage2D);
+ PY_MOD_ADD_METHOD(TexParameterf);
+ PY_MOD_ADD_METHOD(TexParameterfv);
+ PY_MOD_ADD_METHOD(TexParameteri);
+ PY_MOD_ADD_METHOD(TexParameteriv);
+ PY_MOD_ADD_METHOD(Viewport);
+}
+static void init_bgl_version_1_1_methods(PyObject *submodule, PyObject *dict)
+{
/* GL_VERSION_1_1 */
- {
- PY_MOD_ADD_METHOD(BindTexture);
- PY_MOD_ADD_METHOD(CopyTexImage1D);
- PY_MOD_ADD_METHOD(CopyTexImage2D);
- PY_MOD_ADD_METHOD(CopyTexSubImage1D);
- PY_MOD_ADD_METHOD(CopyTexSubImage2D);
- PY_MOD_ADD_METHOD(DeleteTextures);
- PY_MOD_ADD_METHOD(DrawArrays);
- PY_MOD_ADD_METHOD(DrawElements);
- PY_MOD_ADD_METHOD(GenTextures);
- PY_MOD_ADD_METHOD(IsTexture);
- PY_MOD_ADD_METHOD(PolygonOffset);
- PY_MOD_ADD_METHOD(TexSubImage1D);
- PY_MOD_ADD_METHOD(TexSubImage2D);
- }
-
+ PY_MOD_ADD_METHOD(BindTexture);
+ PY_MOD_ADD_METHOD(CopyTexImage1D);
+ PY_MOD_ADD_METHOD(CopyTexImage2D);
+ PY_MOD_ADD_METHOD(CopyTexSubImage1D);
+ PY_MOD_ADD_METHOD(CopyTexSubImage2D);
+ PY_MOD_ADD_METHOD(DeleteTextures);
+ PY_MOD_ADD_METHOD(DrawArrays);
+ PY_MOD_ADD_METHOD(DrawElements);
+ PY_MOD_ADD_METHOD(GenTextures);
+ PY_MOD_ADD_METHOD(IsTexture);
+ PY_MOD_ADD_METHOD(PolygonOffset);
+ PY_MOD_ADD_METHOD(TexSubImage1D);
+ PY_MOD_ADD_METHOD(TexSubImage2D);
+}
+static void init_bgl_version_1_2_methods(PyObject *submodule, PyObject *dict)
+{
/* GL_VERSION_1_2 */
- {
- PY_MOD_ADD_METHOD(CopyTexSubImage3D);
- PY_MOD_ADD_METHOD(DrawRangeElements);
- PY_MOD_ADD_METHOD(TexImage3D);
- PY_MOD_ADD_METHOD(TexSubImage3D);
- }
-
+ PY_MOD_ADD_METHOD(CopyTexSubImage3D);
+ PY_MOD_ADD_METHOD(DrawRangeElements);
+ PY_MOD_ADD_METHOD(TexImage3D);
+ PY_MOD_ADD_METHOD(TexSubImage3D);
+}
+static void init_bgl_version_1_3_methods(PyObject *submodule, PyObject *dict)
+{
/* GL_VERSION_1_3 */
- {
- PY_MOD_ADD_METHOD(ActiveTexture);
- PY_MOD_ADD_METHOD(CompressedTexImage1D);
- PY_MOD_ADD_METHOD(CompressedTexImage2D);
- PY_MOD_ADD_METHOD(CompressedTexImage3D);
- PY_MOD_ADD_METHOD(CompressedTexSubImage1D);
- PY_MOD_ADD_METHOD(CompressedTexSubImage2D);
- PY_MOD_ADD_METHOD(CompressedTexSubImage3D);
- PY_MOD_ADD_METHOD(GetCompressedTexImage);
- PY_MOD_ADD_METHOD(SampleCoverage);
- }
-
+ PY_MOD_ADD_METHOD(ActiveTexture);
+ PY_MOD_ADD_METHOD(CompressedTexImage1D);
+ PY_MOD_ADD_METHOD(CompressedTexImage2D);
+ PY_MOD_ADD_METHOD(CompressedTexImage3D);
+ PY_MOD_ADD_METHOD(CompressedTexSubImage1D);
+ PY_MOD_ADD_METHOD(CompressedTexSubImage2D);
+ PY_MOD_ADD_METHOD(CompressedTexSubImage3D);
+ PY_MOD_ADD_METHOD(GetCompressedTexImage);
+ PY_MOD_ADD_METHOD(SampleCoverage);
+}
+static void init_bgl_version_1_4_methods(PyObject *submodule, PyObject *dict)
+{
/* GL_VERSION_1_4 */
- {
- PY_MOD_ADD_METHOD(BlendColor);
- PY_MOD_ADD_METHOD(BlendEquation);
- }
-
- /* GL_VERSION_1_5 */
- {
- PY_MOD_ADD_METHOD(BeginQuery);
- PY_MOD_ADD_METHOD(BindBuffer);
- PY_MOD_ADD_METHOD(BufferData);
- PY_MOD_ADD_METHOD(BufferSubData);
- PY_MOD_ADD_METHOD(DeleteBuffers);
- PY_MOD_ADD_METHOD(DeleteQueries);
- PY_MOD_ADD_METHOD(EndQuery);
- PY_MOD_ADD_METHOD(GenBuffers);
- PY_MOD_ADD_METHOD(GenQueries);
- PY_MOD_ADD_METHOD(GetBufferParameteriv);
- PY_MOD_ADD_METHOD(GetBufferPointerv);
- PY_MOD_ADD_METHOD(GetBufferSubData);
- PY_MOD_ADD_METHOD(GetQueryObjectiv);
- PY_MOD_ADD_METHOD(GetQueryObjectuiv);
- PY_MOD_ADD_METHOD(GetQueryiv);
- PY_MOD_ADD_METHOD(IsBuffer);
- PY_MOD_ADD_METHOD(IsQuery);
- PY_MOD_ADD_METHOD(MapBuffer);
- PY_MOD_ADD_METHOD(UnmapBuffer);
- }
-
+ PY_MOD_ADD_METHOD(BlendColor);
+ PY_MOD_ADD_METHOD(BlendEquation);
+}
+static void init_bgl_version_1_5_methods(PyObject *submodule, PyObject *dict)
+/* GL_VERSION_1_5 */
+{
+ PY_MOD_ADD_METHOD(BeginQuery);
+ PY_MOD_ADD_METHOD(BindBuffer);
+ PY_MOD_ADD_METHOD(BufferData);
+ PY_MOD_ADD_METHOD(BufferSubData);
+ PY_MOD_ADD_METHOD(DeleteBuffers);
+ PY_MOD_ADD_METHOD(DeleteQueries);
+ PY_MOD_ADD_METHOD(EndQuery);
+ PY_MOD_ADD_METHOD(GenBuffers);
+ PY_MOD_ADD_METHOD(GenQueries);
+ PY_MOD_ADD_METHOD(GetBufferParameteriv);
+ PY_MOD_ADD_METHOD(GetBufferPointerv);
+ PY_MOD_ADD_METHOD(GetBufferSubData);
+ PY_MOD_ADD_METHOD(GetQueryObjectiv);
+ PY_MOD_ADD_METHOD(GetQueryObjectuiv);
+ PY_MOD_ADD_METHOD(GetQueryiv);
+ PY_MOD_ADD_METHOD(IsBuffer);
+ PY_MOD_ADD_METHOD(IsQuery);
+ PY_MOD_ADD_METHOD(MapBuffer);
+ PY_MOD_ADD_METHOD(UnmapBuffer);
+}
+static void init_bgl_version_2_0_methods(PyObject *submodule, PyObject *dict)
+{
/* GL_VERSION_2_0 */
- {
- PY_MOD_ADD_METHOD(AttachShader);
- PY_MOD_ADD_METHOD(BindAttribLocation);
- PY_MOD_ADD_METHOD(BlendEquationSeparate);
- PY_MOD_ADD_METHOD(CompileShader);
- PY_MOD_ADD_METHOD(CreateProgram);
- PY_MOD_ADD_METHOD(CreateShader);
- PY_MOD_ADD_METHOD(DeleteProgram);
- PY_MOD_ADD_METHOD(DeleteShader);
- PY_MOD_ADD_METHOD(DetachShader);
- PY_MOD_ADD_METHOD(DisableVertexAttribArray);
- PY_MOD_ADD_METHOD(DrawBuffers);
- PY_MOD_ADD_METHOD(EnableVertexAttribArray);
- PY_MOD_ADD_METHOD(GetActiveAttrib);
- PY_MOD_ADD_METHOD(GetActiveUniform);
- PY_MOD_ADD_METHOD(GetAttachedShaders);
- PY_MOD_ADD_METHOD(GetAttribLocation);
- PY_MOD_ADD_METHOD(GetProgramInfoLog);
- PY_MOD_ADD_METHOD(GetProgramiv);
- PY_MOD_ADD_METHOD(GetShaderInfoLog);
- PY_MOD_ADD_METHOD(GetShaderSource);
- PY_MOD_ADD_METHOD(GetShaderiv);
- PY_MOD_ADD_METHOD(GetUniformLocation);
- PY_MOD_ADD_METHOD(GetUniformfv);
- PY_MOD_ADD_METHOD(GetUniformiv);
- PY_MOD_ADD_METHOD(GetVertexAttribPointerv);
- PY_MOD_ADD_METHOD(GetVertexAttribdv);
- PY_MOD_ADD_METHOD(GetVertexAttribfv);
- PY_MOD_ADD_METHOD(GetVertexAttribiv);
- PY_MOD_ADD_METHOD(IsProgram);
- PY_MOD_ADD_METHOD(IsShader);
- PY_MOD_ADD_METHOD(LinkProgram);
- PY_MOD_ADD_METHOD(ShaderSource);
- PY_MOD_ADD_METHOD(StencilFuncSeparate);
- PY_MOD_ADD_METHOD(StencilMaskSeparate);
- PY_MOD_ADD_METHOD(StencilOpSeparate);
- PY_MOD_ADD_METHOD(Uniform1f);
- PY_MOD_ADD_METHOD(Uniform1fv);
- PY_MOD_ADD_METHOD(Uniform1i);
- PY_MOD_ADD_METHOD(Uniform1iv);
- PY_MOD_ADD_METHOD(Uniform2f);
- PY_MOD_ADD_METHOD(Uniform2fv);
- PY_MOD_ADD_METHOD(Uniform2i);
- PY_MOD_ADD_METHOD(Uniform2iv);
- PY_MOD_ADD_METHOD(Uniform3f);
- PY_MOD_ADD_METHOD(Uniform3fv);
- PY_MOD_ADD_METHOD(Uniform3i);
- PY_MOD_ADD_METHOD(Uniform3iv);
- PY_MOD_ADD_METHOD(Uniform4f);
- PY_MOD_ADD_METHOD(Uniform4fv);
- PY_MOD_ADD_METHOD(Uniform4i);
- PY_MOD_ADD_METHOD(Uniform4iv);
- PY_MOD_ADD_METHOD(UniformMatrix2fv);
- PY_MOD_ADD_METHOD(UniformMatrix3fv);
- PY_MOD_ADD_METHOD(UniformMatrix4fv);
- PY_MOD_ADD_METHOD(UseProgram);
- PY_MOD_ADD_METHOD(ValidateProgram);
- PY_MOD_ADD_METHOD(VertexAttrib1d);
- PY_MOD_ADD_METHOD(VertexAttrib1dv);
- PY_MOD_ADD_METHOD(VertexAttrib1f);
- PY_MOD_ADD_METHOD(VertexAttrib1fv);
- PY_MOD_ADD_METHOD(VertexAttrib1s);
- PY_MOD_ADD_METHOD(VertexAttrib1sv);
- PY_MOD_ADD_METHOD(VertexAttrib2d);
- PY_MOD_ADD_METHOD(VertexAttrib2dv);
- PY_MOD_ADD_METHOD(VertexAttrib2f);
- PY_MOD_ADD_METHOD(VertexAttrib2fv);
- PY_MOD_ADD_METHOD(VertexAttrib2s);
- PY_MOD_ADD_METHOD(VertexAttrib2sv);
- PY_MOD_ADD_METHOD(VertexAttrib3d);
- PY_MOD_ADD_METHOD(VertexAttrib3dv);
- PY_MOD_ADD_METHOD(VertexAttrib3f);
- PY_MOD_ADD_METHOD(VertexAttrib3fv);
- PY_MOD_ADD_METHOD(VertexAttrib3s);
- PY_MOD_ADD_METHOD(VertexAttrib3sv);
- PY_MOD_ADD_METHOD(VertexAttrib4Nbv);
- PY_MOD_ADD_METHOD(VertexAttrib4Niv);
- PY_MOD_ADD_METHOD(VertexAttrib4Nsv);
- PY_MOD_ADD_METHOD(VertexAttrib4Nub);
- PY_MOD_ADD_METHOD(VertexAttrib4Nubv);
- PY_MOD_ADD_METHOD(VertexAttrib4Nuiv);
- PY_MOD_ADD_METHOD(VertexAttrib4Nusv);
- PY_MOD_ADD_METHOD(VertexAttrib4bv);
- PY_MOD_ADD_METHOD(VertexAttrib4d);
- PY_MOD_ADD_METHOD(VertexAttrib4dv);
- PY_MOD_ADD_METHOD(VertexAttrib4f);
- PY_MOD_ADD_METHOD(VertexAttrib4fv);
- PY_MOD_ADD_METHOD(VertexAttrib4iv);
- PY_MOD_ADD_METHOD(VertexAttrib4s);
- PY_MOD_ADD_METHOD(VertexAttrib4sv);
- PY_MOD_ADD_METHOD(VertexAttrib4ubv);
- PY_MOD_ADD_METHOD(VertexAttrib4uiv);
- PY_MOD_ADD_METHOD(VertexAttrib4usv);
- PY_MOD_ADD_METHOD(VertexAttribPointer);
- }
-
+ PY_MOD_ADD_METHOD(AttachShader);
+ PY_MOD_ADD_METHOD(BindAttribLocation);
+ PY_MOD_ADD_METHOD(BlendEquationSeparate);
+ PY_MOD_ADD_METHOD(CompileShader);
+ PY_MOD_ADD_METHOD(CreateProgram);
+ PY_MOD_ADD_METHOD(CreateShader);
+ PY_MOD_ADD_METHOD(DeleteProgram);
+ PY_MOD_ADD_METHOD(DeleteShader);
+ PY_MOD_ADD_METHOD(DetachShader);
+ PY_MOD_ADD_METHOD(DisableVertexAttribArray);
+ PY_MOD_ADD_METHOD(DrawBuffers);
+ PY_MOD_ADD_METHOD(EnableVertexAttribArray);
+ PY_MOD_ADD_METHOD(GetActiveAttrib);
+ PY_MOD_ADD_METHOD(GetActiveUniform);
+ PY_MOD_ADD_METHOD(GetAttachedShaders);
+ PY_MOD_ADD_METHOD(GetAttribLocation);
+ PY_MOD_ADD_METHOD(GetProgramInfoLog);
+ PY_MOD_ADD_METHOD(GetProgramiv);
+ PY_MOD_ADD_METHOD(GetShaderInfoLog);
+ PY_MOD_ADD_METHOD(GetShaderSource);
+ PY_MOD_ADD_METHOD(GetShaderiv);
+ PY_MOD_ADD_METHOD(GetUniformLocation);
+ PY_MOD_ADD_METHOD(GetUniformfv);
+ PY_MOD_ADD_METHOD(GetUniformiv);
+ PY_MOD_ADD_METHOD(GetVertexAttribPointerv);
+ PY_MOD_ADD_METHOD(GetVertexAttribdv);
+ PY_MOD_ADD_METHOD(GetVertexAttribfv);
+ PY_MOD_ADD_METHOD(GetVertexAttribiv);
+ PY_MOD_ADD_METHOD(IsProgram);
+ PY_MOD_ADD_METHOD(IsShader);
+ PY_MOD_ADD_METHOD(LinkProgram);
+ PY_MOD_ADD_METHOD(ShaderSource);
+ PY_MOD_ADD_METHOD(StencilFuncSeparate);
+ PY_MOD_ADD_METHOD(StencilMaskSeparate);
+ PY_MOD_ADD_METHOD(StencilOpSeparate);
+ PY_MOD_ADD_METHOD(Uniform1f);
+ PY_MOD_ADD_METHOD(Uniform1fv);
+ PY_MOD_ADD_METHOD(Uniform1i);
+ PY_MOD_ADD_METHOD(Uniform1iv);
+ PY_MOD_ADD_METHOD(Uniform2f);
+ PY_MOD_ADD_METHOD(Uniform2fv);
+ PY_MOD_ADD_METHOD(Uniform2i);
+ PY_MOD_ADD_METHOD(Uniform2iv);
+ PY_MOD_ADD_METHOD(Uniform3f);
+ PY_MOD_ADD_METHOD(Uniform3fv);
+ PY_MOD_ADD_METHOD(Uniform3i);
+ PY_MOD_ADD_METHOD(Uniform3iv);
+ PY_MOD_ADD_METHOD(Uniform4f);
+ PY_MOD_ADD_METHOD(Uniform4fv);
+ PY_MOD_ADD_METHOD(Uniform4i);
+ PY_MOD_ADD_METHOD(Uniform4iv);
+ PY_MOD_ADD_METHOD(UniformMatrix2fv);
+ PY_MOD_ADD_METHOD(UniformMatrix3fv);
+ PY_MOD_ADD_METHOD(UniformMatrix4fv);
+ PY_MOD_ADD_METHOD(UseProgram);
+ PY_MOD_ADD_METHOD(ValidateProgram);
+ PY_MOD_ADD_METHOD(VertexAttrib1d);
+ PY_MOD_ADD_METHOD(VertexAttrib1dv);
+ PY_MOD_ADD_METHOD(VertexAttrib1f);
+ PY_MOD_ADD_METHOD(VertexAttrib1fv);
+ PY_MOD_ADD_METHOD(VertexAttrib1s);
+ PY_MOD_ADD_METHOD(VertexAttrib1sv);
+ PY_MOD_ADD_METHOD(VertexAttrib2d);
+ PY_MOD_ADD_METHOD(VertexAttrib2dv);
+ PY_MOD_ADD_METHOD(VertexAttrib2f);
+ PY_MOD_ADD_METHOD(VertexAttrib2fv);
+ PY_MOD_ADD_METHOD(VertexAttrib2s);
+ PY_MOD_ADD_METHOD(VertexAttrib2sv);
+ PY_MOD_ADD_METHOD(VertexAttrib3d);
+ PY_MOD_ADD_METHOD(VertexAttrib3dv);
+ PY_MOD_ADD_METHOD(VertexAttrib3f);
+ PY_MOD_ADD_METHOD(VertexAttrib3fv);
+ PY_MOD_ADD_METHOD(VertexAttrib3s);
+ PY_MOD_ADD_METHOD(VertexAttrib3sv);
+ PY_MOD_ADD_METHOD(VertexAttrib4Nbv);
+ PY_MOD_ADD_METHOD(VertexAttrib4Niv);
+ PY_MOD_ADD_METHOD(VertexAttrib4Nsv);
+ PY_MOD_ADD_METHOD(VertexAttrib4Nub);
+ PY_MOD_ADD_METHOD(VertexAttrib4Nubv);
+ PY_MOD_ADD_METHOD(VertexAttrib4Nuiv);
+ PY_MOD_ADD_METHOD(VertexAttrib4Nusv);
+ PY_MOD_ADD_METHOD(VertexAttrib4bv);
+ PY_MOD_ADD_METHOD(VertexAttrib4d);
+ PY_MOD_ADD_METHOD(VertexAttrib4dv);
+ PY_MOD_ADD_METHOD(VertexAttrib4f);
+ PY_MOD_ADD_METHOD(VertexAttrib4fv);
+ PY_MOD_ADD_METHOD(VertexAttrib4iv);
+ PY_MOD_ADD_METHOD(VertexAttrib4s);
+ PY_MOD_ADD_METHOD(VertexAttrib4sv);
+ PY_MOD_ADD_METHOD(VertexAttrib4ubv);
+ PY_MOD_ADD_METHOD(VertexAttrib4uiv);
+ PY_MOD_ADD_METHOD(VertexAttrib4usv);
+ PY_MOD_ADD_METHOD(VertexAttribPointer);
+}
+static void init_bgl_version_2_1_methods(PyObject *submodule, PyObject *dict)
+{
/* GL_VERSION_2_1 */
- {
- PY_MOD_ADD_METHOD(UniformMatrix2x3fv);
- PY_MOD_ADD_METHOD(UniformMatrix2x4fv);
- PY_MOD_ADD_METHOD(UniformMatrix3x2fv);
- PY_MOD_ADD_METHOD(UniformMatrix3x4fv);
- PY_MOD_ADD_METHOD(UniformMatrix4x2fv);
- PY_MOD_ADD_METHOD(UniformMatrix4x3fv);
- }
-
+ PY_MOD_ADD_METHOD(UniformMatrix2x3fv);
+ PY_MOD_ADD_METHOD(UniformMatrix2x4fv);
+ PY_MOD_ADD_METHOD(UniformMatrix3x2fv);
+ PY_MOD_ADD_METHOD(UniformMatrix3x4fv);
+ PY_MOD_ADD_METHOD(UniformMatrix4x2fv);
+ PY_MOD_ADD_METHOD(UniformMatrix4x3fv);
+}
+static void init_bgl_version_3_0_methods(PyObject *submodule, PyObject *dict)
+{
/* GL_VERSION_3_0 */
- {
- PY_MOD_ADD_METHOD(BindFramebuffer);
- PY_MOD_ADD_METHOD(BindRenderbuffer);
- PY_MOD_ADD_METHOD(BindVertexArray);
- PY_MOD_ADD_METHOD(BlitFramebuffer);
- PY_MOD_ADD_METHOD(CheckFramebufferStatus);
- PY_MOD_ADD_METHOD(DeleteFramebuffers);
- PY_MOD_ADD_METHOD(DeleteRenderbuffers);
- PY_MOD_ADD_METHOD(DeleteVertexArrays);
- PY_MOD_ADD_METHOD(FramebufferRenderbuffer);
- PY_MOD_ADD_METHOD(GenFramebuffers);
- PY_MOD_ADD_METHOD(GenRenderbuffers);
- PY_MOD_ADD_METHOD(GenVertexArrays);
- PY_MOD_ADD_METHOD(GetStringi);
- PY_MOD_ADD_METHOD(IsVertexArray);
- PY_MOD_ADD_METHOD(RenderbufferStorage);
- PY_MOD_ADD_METHOD(VertexAttribIPointer);
- }
-
+ PY_MOD_ADD_METHOD(BindFramebuffer);
+ PY_MOD_ADD_METHOD(BindRenderbuffer);
+ PY_MOD_ADD_METHOD(BindVertexArray);
+ PY_MOD_ADD_METHOD(BlitFramebuffer);
+ PY_MOD_ADD_METHOD(CheckFramebufferStatus);
+ PY_MOD_ADD_METHOD(DeleteFramebuffers);
+ PY_MOD_ADD_METHOD(DeleteRenderbuffers);
+ PY_MOD_ADD_METHOD(DeleteVertexArrays);
+ PY_MOD_ADD_METHOD(FramebufferRenderbuffer);
+ PY_MOD_ADD_METHOD(GenFramebuffers);
+ PY_MOD_ADD_METHOD(GenRenderbuffers);
+ PY_MOD_ADD_METHOD(GenVertexArrays);
+ PY_MOD_ADD_METHOD(GetStringi);
+ PY_MOD_ADD_METHOD(IsVertexArray);
+ PY_MOD_ADD_METHOD(RenderbufferStorage);
+ PY_MOD_ADD_METHOD(VertexAttribIPointer);
+}
+static void init_bgl_version_3_1_methods(PyObject *submodule, PyObject *dict)
+{
/* GL_VERSION_3_1 */
- {
- PY_MOD_ADD_METHOD(BindBufferBase);
- PY_MOD_ADD_METHOD(BindBufferRange);
- PY_MOD_ADD_METHOD(GetActiveUniformBlockName);
- PY_MOD_ADD_METHOD(GetActiveUniformBlockiv);
- PY_MOD_ADD_METHOD(GetActiveUniformName);
- PY_MOD_ADD_METHOD(GetActiveUniformsiv);
- PY_MOD_ADD_METHOD(GetIntegeri_v);
- PY_MOD_ADD_METHOD(GetUniformBlockIndex);
- PY_MOD_ADD_METHOD(GetUniformIndices);
- PY_MOD_ADD_METHOD(UniformBlockBinding);
- }
-
+ PY_MOD_ADD_METHOD(BindBufferBase);
+ PY_MOD_ADD_METHOD(BindBufferRange);
+ PY_MOD_ADD_METHOD(GetActiveUniformBlockName);
+ PY_MOD_ADD_METHOD(GetActiveUniformBlockiv);
+ PY_MOD_ADD_METHOD(GetActiveUniformName);
+ PY_MOD_ADD_METHOD(GetActiveUniformsiv);
+ PY_MOD_ADD_METHOD(GetIntegeri_v);
+ PY_MOD_ADD_METHOD(GetUniformBlockIndex);
+ PY_MOD_ADD_METHOD(GetUniformIndices);
+ PY_MOD_ADD_METHOD(UniformBlockBinding);
+}
+static void init_bgl_version_3_2_methods(PyObject *submodule, PyObject *dict)
+{
/* GL_VERSION_3_2 */
- {
- PY_MOD_ADD_METHOD(FramebufferTexture);
- PY_MOD_ADD_METHOD(GetBufferParameteri64v);
- PY_MOD_ADD_METHOD(GetInteger64i_v);
- PY_MOD_ADD_METHOD(GetMultisamplefv);
- PY_MOD_ADD_METHOD(SampleMaski);
- PY_MOD_ADD_METHOD(TexImage2DMultisample);
- PY_MOD_ADD_METHOD(TexImage3DMultisample);
- }
-
+ PY_MOD_ADD_METHOD(FramebufferTexture);
+ PY_MOD_ADD_METHOD(GetBufferParameteri64v);
+ PY_MOD_ADD_METHOD(GetInteger64i_v);
+ PY_MOD_ADD_METHOD(GetMultisamplefv);
+ PY_MOD_ADD_METHOD(SampleMaski);
+ PY_MOD_ADD_METHOD(TexImage2DMultisample);
+ PY_MOD_ADD_METHOD(TexImage3DMultisample);
+}
+static void init_bgl_version_3_3_methods(PyObject *UNUSED(submodule), PyObject *UNUSED(dict))
+{
/* GL_VERSION_3_3 */
- {
- }
+}
#define PY_DICT_ADD_INT(x) py_module_dict_add_int(dict, #x, x)
#define PY_DICT_ADD_INT64(x) py_module_dict_add_int64(dict, #x, x)
+static void init_bgl_version_1_1_constants(PyObject *dict)
+{
/* GL_VERSION_1_1 */
- {
- PY_DICT_ADD_INT(GL_ALPHA);
- PY_DICT_ADD_INT(GL_ALWAYS);
- PY_DICT_ADD_INT(GL_AND);
- PY_DICT_ADD_INT(GL_AND_INVERTED);
- PY_DICT_ADD_INT(GL_AND_REVERSE);
- PY_DICT_ADD_INT(GL_BACK);
- PY_DICT_ADD_INT(GL_BACK_LEFT);
- PY_DICT_ADD_INT(GL_BACK_RIGHT);
- PY_DICT_ADD_INT(GL_BLEND);
- PY_DICT_ADD_INT(GL_BLEND_DST);
- PY_DICT_ADD_INT(GL_BLEND_SRC);
- PY_DICT_ADD_INT(GL_BLUE);
- PY_DICT_ADD_INT(GL_BYTE);
- PY_DICT_ADD_INT(GL_CCW);
- PY_DICT_ADD_INT(GL_CLEAR);
- PY_DICT_ADD_INT(GL_COLOR);
- PY_DICT_ADD_INT(GL_COLOR_BUFFER_BIT);
- PY_DICT_ADD_INT(GL_COLOR_CLEAR_VALUE);
- PY_DICT_ADD_INT(GL_COLOR_LOGIC_OP);
- PY_DICT_ADD_INT(GL_COLOR_WRITEMASK);
- PY_DICT_ADD_INT(GL_COPY);
- PY_DICT_ADD_INT(GL_COPY_INVERTED);
- PY_DICT_ADD_INT(GL_CULL_FACE);
- PY_DICT_ADD_INT(GL_CULL_FACE_MODE);
- PY_DICT_ADD_INT(GL_CW);
- PY_DICT_ADD_INT(GL_DECR);
- PY_DICT_ADD_INT(GL_DEPTH);
- PY_DICT_ADD_INT(GL_DEPTH_BUFFER_BIT);
- PY_DICT_ADD_INT(GL_DEPTH_CLEAR_VALUE);
- PY_DICT_ADD_INT(GL_DEPTH_COMPONENT);
- PY_DICT_ADD_INT(GL_DEPTH_FUNC);
- PY_DICT_ADD_INT(GL_DEPTH_RANGE);
- PY_DICT_ADD_INT(GL_DEPTH_TEST);
- PY_DICT_ADD_INT(GL_DEPTH_WRITEMASK);
- PY_DICT_ADD_INT(GL_DITHER);
- PY_DICT_ADD_INT(GL_DONT_CARE);
- PY_DICT_ADD_INT(GL_DOUBLE);
- PY_DICT_ADD_INT(GL_DOUBLEBUFFER);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER);
- PY_DICT_ADD_INT(GL_DST_ALPHA);
- PY_DICT_ADD_INT(GL_DST_COLOR);
- PY_DICT_ADD_INT(GL_EQUAL);
- PY_DICT_ADD_INT(GL_EQUIV);
- PY_DICT_ADD_INT(GL_EXTENSIONS);
- PY_DICT_ADD_INT(GL_FALSE);
- PY_DICT_ADD_INT(GL_FASTEST);
- PY_DICT_ADD_INT(GL_FILL);
- PY_DICT_ADD_INT(GL_FLOAT);
- PY_DICT_ADD_INT(GL_FRONT);
- PY_DICT_ADD_INT(GL_FRONT_AND_BACK);
- PY_DICT_ADD_INT(GL_FRONT_FACE);
- PY_DICT_ADD_INT(GL_FRONT_LEFT);
- PY_DICT_ADD_INT(GL_FRONT_RIGHT);
- PY_DICT_ADD_INT(GL_GEQUAL);
- PY_DICT_ADD_INT(GL_GREATER);
- PY_DICT_ADD_INT(GL_GREEN);
- PY_DICT_ADD_INT(GL_INCR);
- PY_DICT_ADD_INT(GL_INT);
- PY_DICT_ADD_INT(GL_INVALID_ENUM);
- PY_DICT_ADD_INT(GL_INVALID_OPERATION);
- PY_DICT_ADD_INT(GL_INVALID_VALUE);
- PY_DICT_ADD_INT(GL_INVERT);
- PY_DICT_ADD_INT(GL_KEEP);
- PY_DICT_ADD_INT(GL_LEFT);
- PY_DICT_ADD_INT(GL_LEQUAL);
- PY_DICT_ADD_INT(GL_LESS);
- PY_DICT_ADD_INT(GL_LINE);
- PY_DICT_ADD_INT(GL_LINEAR);
- PY_DICT_ADD_INT(GL_LINEAR_MIPMAP_LINEAR);
- PY_DICT_ADD_INT(GL_LINEAR_MIPMAP_NEAREST);
- PY_DICT_ADD_INT(GL_LINES);
- PY_DICT_ADD_INT(GL_LINE_LOOP);
- PY_DICT_ADD_INT(GL_LINE_SMOOTH);
- PY_DICT_ADD_INT(GL_LINE_SMOOTH_HINT);
- PY_DICT_ADD_INT(GL_LINE_STRIP);
- PY_DICT_ADD_INT(GL_LINE_WIDTH);
- PY_DICT_ADD_INT(GL_LINE_WIDTH_GRANULARITY);
- PY_DICT_ADD_INT(GL_LINE_WIDTH_RANGE);
- PY_DICT_ADD_INT(GL_LOGIC_OP_MODE);
- PY_DICT_ADD_INT(GL_MAX_TEXTURE_SIZE);
- PY_DICT_ADD_INT(GL_MAX_VIEWPORT_DIMS);
- PY_DICT_ADD_INT(GL_NAND);
- PY_DICT_ADD_INT(GL_NEAREST);
- PY_DICT_ADD_INT(GL_NEAREST_MIPMAP_LINEAR);
- PY_DICT_ADD_INT(GL_NEAREST_MIPMAP_NEAREST);
- PY_DICT_ADD_INT(GL_NEVER);
- PY_DICT_ADD_INT(GL_NICEST);
- PY_DICT_ADD_INT(GL_NONE);
- PY_DICT_ADD_INT(GL_NOOP);
- PY_DICT_ADD_INT(GL_NOR);
- PY_DICT_ADD_INT(GL_NOTEQUAL);
- PY_DICT_ADD_INT(GL_NO_ERROR);
- PY_DICT_ADD_INT(GL_ONE);
- PY_DICT_ADD_INT(GL_ONE_MINUS_DST_ALPHA);
- PY_DICT_ADD_INT(GL_ONE_MINUS_DST_COLOR);
- PY_DICT_ADD_INT(GL_ONE_MINUS_SRC_ALPHA);
- PY_DICT_ADD_INT(GL_ONE_MINUS_SRC_COLOR);
- PY_DICT_ADD_INT(GL_OR);
- PY_DICT_ADD_INT(GL_OR_INVERTED);
- PY_DICT_ADD_INT(GL_OR_REVERSE);
- PY_DICT_ADD_INT(GL_OUT_OF_MEMORY);
- PY_DICT_ADD_INT(GL_PACK_ALIGNMENT);
- PY_DICT_ADD_INT(GL_PACK_LSB_FIRST);
- PY_DICT_ADD_INT(GL_PACK_ROW_LENGTH);
- PY_DICT_ADD_INT(GL_PACK_SKIP_PIXELS);
- PY_DICT_ADD_INT(GL_PACK_SKIP_ROWS);
- PY_DICT_ADD_INT(GL_PACK_SWAP_BYTES);
- PY_DICT_ADD_INT(GL_POINT);
- PY_DICT_ADD_INT(GL_POINTS);
- PY_DICT_ADD_INT(GL_POINT_SIZE);
- PY_DICT_ADD_INT(GL_POLYGON_MODE);
- PY_DICT_ADD_INT(GL_POLYGON_OFFSET_FACTOR);
- PY_DICT_ADD_INT(GL_POLYGON_OFFSET_FILL);
- PY_DICT_ADD_INT(GL_POLYGON_OFFSET_LINE);
- PY_DICT_ADD_INT(GL_POLYGON_OFFSET_POINT);
- PY_DICT_ADD_INT(GL_POLYGON_OFFSET_UNITS);
- PY_DICT_ADD_INT(GL_POLYGON_SMOOTH);
- PY_DICT_ADD_INT(GL_POLYGON_SMOOTH_HINT);
- PY_DICT_ADD_INT(GL_PROXY_TEXTURE_1D);
- PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D);
- PY_DICT_ADD_INT(GL_R3_G3_B2);
- PY_DICT_ADD_INT(GL_READ_BUFFER);
- PY_DICT_ADD_INT(GL_RED);
- PY_DICT_ADD_INT(GL_RENDERER);
- PY_DICT_ADD_INT(GL_REPEAT);
- PY_DICT_ADD_INT(GL_REPLACE);
- PY_DICT_ADD_INT(GL_RGB);
- PY_DICT_ADD_INT(GL_RGB10);
- PY_DICT_ADD_INT(GL_RGB10_A2);
- PY_DICT_ADD_INT(GL_RGB12);
- PY_DICT_ADD_INT(GL_RGB16);
- PY_DICT_ADD_INT(GL_RGB4);
- PY_DICT_ADD_INT(GL_RGB5);
- PY_DICT_ADD_INT(GL_RGB5_A1);
- PY_DICT_ADD_INT(GL_RGB8);
- PY_DICT_ADD_INT(GL_RGBA);
- PY_DICT_ADD_INT(GL_RGBA12);
- PY_DICT_ADD_INT(GL_RGBA16);
- PY_DICT_ADD_INT(GL_RGBA2);
- PY_DICT_ADD_INT(GL_RGBA4);
- PY_DICT_ADD_INT(GL_RGBA8);
- PY_DICT_ADD_INT(GL_RIGHT);
- PY_DICT_ADD_INT(GL_SCISSOR_BOX);
- PY_DICT_ADD_INT(GL_SCISSOR_TEST);
- PY_DICT_ADD_INT(GL_SET);
- PY_DICT_ADD_INT(GL_SHORT);
- PY_DICT_ADD_INT(GL_SRC_ALPHA);
- PY_DICT_ADD_INT(GL_SRC_ALPHA_SATURATE);
- PY_DICT_ADD_INT(GL_SRC_COLOR);
- PY_DICT_ADD_INT(GL_STENCIL);
- PY_DICT_ADD_INT(GL_STENCIL_BUFFER_BIT);
- PY_DICT_ADD_INT(GL_STENCIL_CLEAR_VALUE);
- PY_DICT_ADD_INT(GL_STENCIL_FAIL);
- PY_DICT_ADD_INT(GL_STENCIL_FUNC);
- PY_DICT_ADD_INT(GL_STENCIL_INDEX);
- PY_DICT_ADD_INT(GL_STENCIL_PASS_DEPTH_FAIL);
- PY_DICT_ADD_INT(GL_STENCIL_PASS_DEPTH_PASS);
- PY_DICT_ADD_INT(GL_STENCIL_REF);
- PY_DICT_ADD_INT(GL_STENCIL_TEST);
- PY_DICT_ADD_INT(GL_STENCIL_VALUE_MASK);
- PY_DICT_ADD_INT(GL_STENCIL_WRITEMASK);
- PY_DICT_ADD_INT(GL_STEREO);
- PY_DICT_ADD_INT(GL_SUBPIXEL_BITS);
- PY_DICT_ADD_INT(GL_TEXTURE);
- PY_DICT_ADD_INT(GL_TEXTURE_1D);
- PY_DICT_ADD_INT(GL_TEXTURE_2D);
- PY_DICT_ADD_INT(GL_TEXTURE_ALPHA_SIZE);
- PY_DICT_ADD_INT(GL_TEXTURE_BINDING_1D);
- PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D);
- PY_DICT_ADD_INT(GL_TEXTURE_BLUE_SIZE);
- PY_DICT_ADD_INT(GL_TEXTURE_BORDER_COLOR);
- PY_DICT_ADD_INT(GL_TEXTURE_GREEN_SIZE);
- PY_DICT_ADD_INT(GL_TEXTURE_HEIGHT);
- PY_DICT_ADD_INT(GL_TEXTURE_INTERNAL_FORMAT);
- PY_DICT_ADD_INT(GL_TEXTURE_MAG_FILTER);
- PY_DICT_ADD_INT(GL_TEXTURE_MIN_FILTER);
- PY_DICT_ADD_INT(GL_TEXTURE_RED_SIZE);
- PY_DICT_ADD_INT(GL_TEXTURE_WIDTH);
- PY_DICT_ADD_INT(GL_TEXTURE_WRAP_S);
- PY_DICT_ADD_INT(GL_TEXTURE_WRAP_T);
- PY_DICT_ADD_INT(GL_TRIANGLES);
- PY_DICT_ADD_INT(GL_TRIANGLE_FAN);
- PY_DICT_ADD_INT(GL_TRIANGLE_STRIP);
- PY_DICT_ADD_INT(GL_TRUE);
- PY_DICT_ADD_INT(GL_UNPACK_ALIGNMENT);
- PY_DICT_ADD_INT(GL_UNPACK_LSB_FIRST);
- PY_DICT_ADD_INT(GL_UNPACK_ROW_LENGTH);
- PY_DICT_ADD_INT(GL_UNPACK_SKIP_PIXELS);
- PY_DICT_ADD_INT(GL_UNPACK_SKIP_ROWS);
- PY_DICT_ADD_INT(GL_UNPACK_SWAP_BYTES);
- PY_DICT_ADD_INT(GL_UNSIGNED_BYTE);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT);
- PY_DICT_ADD_INT(GL_UNSIGNED_SHORT);
- PY_DICT_ADD_INT(GL_VENDOR);
- PY_DICT_ADD_INT(GL_VERSION);
- PY_DICT_ADD_INT(GL_VIEWPORT);
- PY_DICT_ADD_INT(GL_XOR);
- PY_DICT_ADD_INT(GL_ZERO);
- }
-
+ PY_DICT_ADD_INT(GL_ALPHA);
+ PY_DICT_ADD_INT(GL_ALWAYS);
+ PY_DICT_ADD_INT(GL_AND);
+ PY_DICT_ADD_INT(GL_AND_INVERTED);
+ PY_DICT_ADD_INT(GL_AND_REVERSE);
+ PY_DICT_ADD_INT(GL_BACK);
+ PY_DICT_ADD_INT(GL_BACK_LEFT);
+ PY_DICT_ADD_INT(GL_BACK_RIGHT);
+ PY_DICT_ADD_INT(GL_BLEND);
+ PY_DICT_ADD_INT(GL_BLEND_DST);
+ PY_DICT_ADD_INT(GL_BLEND_SRC);
+ PY_DICT_ADD_INT(GL_BLUE);
+ PY_DICT_ADD_INT(GL_BYTE);
+ PY_DICT_ADD_INT(GL_CCW);
+ PY_DICT_ADD_INT(GL_CLEAR);
+ PY_DICT_ADD_INT(GL_COLOR);
+ PY_DICT_ADD_INT(GL_COLOR_BUFFER_BIT);
+ PY_DICT_ADD_INT(GL_COLOR_CLEAR_VALUE);
+ PY_DICT_ADD_INT(GL_COLOR_LOGIC_OP);
+ PY_DICT_ADD_INT(GL_COLOR_WRITEMASK);
+ PY_DICT_ADD_INT(GL_COPY);
+ PY_DICT_ADD_INT(GL_COPY_INVERTED);
+ PY_DICT_ADD_INT(GL_CULL_FACE);
+ PY_DICT_ADD_INT(GL_CULL_FACE_MODE);
+ PY_DICT_ADD_INT(GL_CW);
+ PY_DICT_ADD_INT(GL_DECR);
+ PY_DICT_ADD_INT(GL_DEPTH);
+ PY_DICT_ADD_INT(GL_DEPTH_BUFFER_BIT);
+ PY_DICT_ADD_INT(GL_DEPTH_CLEAR_VALUE);
+ PY_DICT_ADD_INT(GL_DEPTH_COMPONENT);
+ PY_DICT_ADD_INT(GL_DEPTH_FUNC);
+ PY_DICT_ADD_INT(GL_DEPTH_RANGE);
+ PY_DICT_ADD_INT(GL_DEPTH_TEST);
+ PY_DICT_ADD_INT(GL_DEPTH_WRITEMASK);
+ PY_DICT_ADD_INT(GL_DITHER);
+ PY_DICT_ADD_INT(GL_DONT_CARE);
+ PY_DICT_ADD_INT(GL_DOUBLE);
+ PY_DICT_ADD_INT(GL_DOUBLEBUFFER);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER);
+ PY_DICT_ADD_INT(GL_DST_ALPHA);
+ PY_DICT_ADD_INT(GL_DST_COLOR);
+ PY_DICT_ADD_INT(GL_EQUAL);
+ PY_DICT_ADD_INT(GL_EQUIV);
+ PY_DICT_ADD_INT(GL_EXTENSIONS);
+ PY_DICT_ADD_INT(GL_FALSE);
+ PY_DICT_ADD_INT(GL_FASTEST);
+ PY_DICT_ADD_INT(GL_FILL);
+ PY_DICT_ADD_INT(GL_FLOAT);
+ PY_DICT_ADD_INT(GL_FRONT);
+ PY_DICT_ADD_INT(GL_FRONT_AND_BACK);
+ PY_DICT_ADD_INT(GL_FRONT_FACE);
+ PY_DICT_ADD_INT(GL_FRONT_LEFT);
+ PY_DICT_ADD_INT(GL_FRONT_RIGHT);
+ PY_DICT_ADD_INT(GL_GEQUAL);
+ PY_DICT_ADD_INT(GL_GREATER);
+ PY_DICT_ADD_INT(GL_GREEN);
+ PY_DICT_ADD_INT(GL_INCR);
+ PY_DICT_ADD_INT(GL_INT);
+ PY_DICT_ADD_INT(GL_INVALID_ENUM);
+ PY_DICT_ADD_INT(GL_INVALID_OPERATION);
+ PY_DICT_ADD_INT(GL_INVALID_VALUE);
+ PY_DICT_ADD_INT(GL_INVERT);
+ PY_DICT_ADD_INT(GL_KEEP);
+ PY_DICT_ADD_INT(GL_LEFT);
+ PY_DICT_ADD_INT(GL_LEQUAL);
+ PY_DICT_ADD_INT(GL_LESS);
+ PY_DICT_ADD_INT(GL_LINE);
+ PY_DICT_ADD_INT(GL_LINEAR);
+ PY_DICT_ADD_INT(GL_LINEAR_MIPMAP_LINEAR);
+ PY_DICT_ADD_INT(GL_LINEAR_MIPMAP_NEAREST);
+ PY_DICT_ADD_INT(GL_LINES);
+ PY_DICT_ADD_INT(GL_LINE_LOOP);
+ PY_DICT_ADD_INT(GL_LINE_SMOOTH);
+ PY_DICT_ADD_INT(GL_LINE_SMOOTH_HINT);
+ PY_DICT_ADD_INT(GL_LINE_STRIP);
+ PY_DICT_ADD_INT(GL_LINE_WIDTH);
+ PY_DICT_ADD_INT(GL_LINE_WIDTH_GRANULARITY);
+ PY_DICT_ADD_INT(GL_LINE_WIDTH_RANGE);
+ PY_DICT_ADD_INT(GL_LOGIC_OP_MODE);
+ PY_DICT_ADD_INT(GL_MAX_TEXTURE_SIZE);
+ PY_DICT_ADD_INT(GL_MAX_VIEWPORT_DIMS);
+ PY_DICT_ADD_INT(GL_NAND);
+ PY_DICT_ADD_INT(GL_NEAREST);
+ PY_DICT_ADD_INT(GL_NEAREST_MIPMAP_LINEAR);
+ PY_DICT_ADD_INT(GL_NEAREST_MIPMAP_NEAREST);
+ PY_DICT_ADD_INT(GL_NEVER);
+ PY_DICT_ADD_INT(GL_NICEST);
+ PY_DICT_ADD_INT(GL_NONE);
+ PY_DICT_ADD_INT(GL_NOOP);
+ PY_DICT_ADD_INT(GL_NOR);
+ PY_DICT_ADD_INT(GL_NOTEQUAL);
+ PY_DICT_ADD_INT(GL_NO_ERROR);
+ PY_DICT_ADD_INT(GL_ONE);
+ PY_DICT_ADD_INT(GL_ONE_MINUS_DST_ALPHA);
+ PY_DICT_ADD_INT(GL_ONE_MINUS_DST_COLOR);
+ PY_DICT_ADD_INT(GL_ONE_MINUS_SRC_ALPHA);
+ PY_DICT_ADD_INT(GL_ONE_MINUS_SRC_COLOR);
+ PY_DICT_ADD_INT(GL_OR);
+ PY_DICT_ADD_INT(GL_OR_INVERTED);
+ PY_DICT_ADD_INT(GL_OR_REVERSE);
+ PY_DICT_ADD_INT(GL_OUT_OF_MEMORY);
+ PY_DICT_ADD_INT(GL_PACK_ALIGNMENT);
+ PY_DICT_ADD_INT(GL_PACK_LSB_FIRST);
+ PY_DICT_ADD_INT(GL_PACK_ROW_LENGTH);
+ PY_DICT_ADD_INT(GL_PACK_SKIP_PIXELS);
+ PY_DICT_ADD_INT(GL_PACK_SKIP_ROWS);
+ PY_DICT_ADD_INT(GL_PACK_SWAP_BYTES);
+ PY_DICT_ADD_INT(GL_POINT);
+ PY_DICT_ADD_INT(GL_POINTS);
+ PY_DICT_ADD_INT(GL_POINT_SIZE);
+ PY_DICT_ADD_INT(GL_POLYGON_MODE);
+ PY_DICT_ADD_INT(GL_POLYGON_OFFSET_FACTOR);
+ PY_DICT_ADD_INT(GL_POLYGON_OFFSET_FILL);
+ PY_DICT_ADD_INT(GL_POLYGON_OFFSET_LINE);
+ PY_DICT_ADD_INT(GL_POLYGON_OFFSET_POINT);
+ PY_DICT_ADD_INT(GL_POLYGON_OFFSET_UNITS);
+ PY_DICT_ADD_INT(GL_POLYGON_SMOOTH);
+ PY_DICT_ADD_INT(GL_POLYGON_SMOOTH_HINT);
+ PY_DICT_ADD_INT(GL_PROXY_TEXTURE_1D);
+ PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D);
+ PY_DICT_ADD_INT(GL_R3_G3_B2);
+ PY_DICT_ADD_INT(GL_READ_BUFFER);
+ PY_DICT_ADD_INT(GL_RED);
+ PY_DICT_ADD_INT(GL_RENDERER);
+ PY_DICT_ADD_INT(GL_REPEAT);
+ PY_DICT_ADD_INT(GL_REPLACE);
+ PY_DICT_ADD_INT(GL_RGB);
+ PY_DICT_ADD_INT(GL_RGB10);
+ PY_DICT_ADD_INT(GL_RGB10_A2);
+ PY_DICT_ADD_INT(GL_RGB12);
+ PY_DICT_ADD_INT(GL_RGB16);
+ PY_DICT_ADD_INT(GL_RGB4);
+ PY_DICT_ADD_INT(GL_RGB5);
+ PY_DICT_ADD_INT(GL_RGB5_A1);
+ PY_DICT_ADD_INT(GL_RGB8);
+ PY_DICT_ADD_INT(GL_RGBA);
+ PY_DICT_ADD_INT(GL_RGBA12);
+ PY_DICT_ADD_INT(GL_RGBA16);
+ PY_DICT_ADD_INT(GL_RGBA2);
+ PY_DICT_ADD_INT(GL_RGBA4);
+ PY_DICT_ADD_INT(GL_RGBA8);
+ PY_DICT_ADD_INT(GL_RIGHT);
+ PY_DICT_ADD_INT(GL_SCISSOR_BOX);
+ PY_DICT_ADD_INT(GL_SCISSOR_TEST);
+ PY_DICT_ADD_INT(GL_SET);
+ PY_DICT_ADD_INT(GL_SHORT);
+ PY_DICT_ADD_INT(GL_SRC_ALPHA);
+ PY_DICT_ADD_INT(GL_SRC_ALPHA_SATURATE);
+ PY_DICT_ADD_INT(GL_SRC_COLOR);
+ PY_DICT_ADD_INT(GL_STENCIL);
+ PY_DICT_ADD_INT(GL_STENCIL_BUFFER_BIT);
+ PY_DICT_ADD_INT(GL_STENCIL_CLEAR_VALUE);
+ PY_DICT_ADD_INT(GL_STENCIL_FAIL);
+ PY_DICT_ADD_INT(GL_STENCIL_FUNC);
+ PY_DICT_ADD_INT(GL_STENCIL_INDEX);
+ PY_DICT_ADD_INT(GL_STENCIL_PASS_DEPTH_FAIL);
+ PY_DICT_ADD_INT(GL_STENCIL_PASS_DEPTH_PASS);
+ PY_DICT_ADD_INT(GL_STENCIL_REF);
+ PY_DICT_ADD_INT(GL_STENCIL_TEST);
+ PY_DICT_ADD_INT(GL_STENCIL_VALUE_MASK);
+ PY_DICT_ADD_INT(GL_STENCIL_WRITEMASK);
+ PY_DICT_ADD_INT(GL_STEREO);
+ PY_DICT_ADD_INT(GL_SUBPIXEL_BITS);
+ PY_DICT_ADD_INT(GL_TEXTURE);
+ PY_DICT_ADD_INT(GL_TEXTURE_1D);
+ PY_DICT_ADD_INT(GL_TEXTURE_2D);
+ PY_DICT_ADD_INT(GL_TEXTURE_ALPHA_SIZE);
+ PY_DICT_ADD_INT(GL_TEXTURE_BINDING_1D);
+ PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D);
+ PY_DICT_ADD_INT(GL_TEXTURE_BLUE_SIZE);
+ PY_DICT_ADD_INT(GL_TEXTURE_BORDER_COLOR);
+ PY_DICT_ADD_INT(GL_TEXTURE_GREEN_SIZE);
+ PY_DICT_ADD_INT(GL_TEXTURE_HEIGHT);
+ PY_DICT_ADD_INT(GL_TEXTURE_INTERNAL_FORMAT);
+ PY_DICT_ADD_INT(GL_TEXTURE_MAG_FILTER);
+ PY_DICT_ADD_INT(GL_TEXTURE_MIN_FILTER);
+ PY_DICT_ADD_INT(GL_TEXTURE_RED_SIZE);
+ PY_DICT_ADD_INT(GL_TEXTURE_WIDTH);
+ PY_DICT_ADD_INT(GL_TEXTURE_WRAP_S);
+ PY_DICT_ADD_INT(GL_TEXTURE_WRAP_T);
+ PY_DICT_ADD_INT(GL_TRIANGLES);
+ PY_DICT_ADD_INT(GL_TRIANGLE_FAN);
+ PY_DICT_ADD_INT(GL_TRIANGLE_STRIP);
+ PY_DICT_ADD_INT(GL_TRUE);
+ PY_DICT_ADD_INT(GL_UNPACK_ALIGNMENT);
+ PY_DICT_ADD_INT(GL_UNPACK_LSB_FIRST);
+ PY_DICT_ADD_INT(GL_UNPACK_ROW_LENGTH);
+ PY_DICT_ADD_INT(GL_UNPACK_SKIP_PIXELS);
+ PY_DICT_ADD_INT(GL_UNPACK_SKIP_ROWS);
+ PY_DICT_ADD_INT(GL_UNPACK_SWAP_BYTES);
+ PY_DICT_ADD_INT(GL_UNSIGNED_BYTE);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT);
+ PY_DICT_ADD_INT(GL_UNSIGNED_SHORT);
+ PY_DICT_ADD_INT(GL_VENDOR);
+ PY_DICT_ADD_INT(GL_VERSION);
+ PY_DICT_ADD_INT(GL_VIEWPORT);
+ PY_DICT_ADD_INT(GL_XOR);
+ PY_DICT_ADD_INT(GL_ZERO);
+}
+static void init_bgl_version_1_2_constants(PyObject *dict)
+{
/* GL_VERSION_1_2 */
- {
- PY_DICT_ADD_INT(GL_ALIASED_LINE_WIDTH_RANGE);
- PY_DICT_ADD_INT(GL_BGR);
- PY_DICT_ADD_INT(GL_BGRA);
- PY_DICT_ADD_INT(GL_CLAMP_TO_EDGE);
- PY_DICT_ADD_INT(GL_MAX_3D_TEXTURE_SIZE);
- PY_DICT_ADD_INT(GL_MAX_ELEMENTS_INDICES);
- PY_DICT_ADD_INT(GL_MAX_ELEMENTS_VERTICES);
- PY_DICT_ADD_INT(GL_PACK_IMAGE_HEIGHT);
- PY_DICT_ADD_INT(GL_PACK_SKIP_IMAGES);
- PY_DICT_ADD_INT(GL_PROXY_TEXTURE_3D);
- PY_DICT_ADD_INT(GL_SMOOTH_LINE_WIDTH_GRANULARITY);
- PY_DICT_ADD_INT(GL_SMOOTH_LINE_WIDTH_RANGE);
- PY_DICT_ADD_INT(GL_SMOOTH_POINT_SIZE_GRANULARITY);
- PY_DICT_ADD_INT(GL_SMOOTH_POINT_SIZE_RANGE);
- PY_DICT_ADD_INT(GL_TEXTURE_3D);
- PY_DICT_ADD_INT(GL_TEXTURE_BASE_LEVEL);
- PY_DICT_ADD_INT(GL_TEXTURE_BINDING_3D);
- PY_DICT_ADD_INT(GL_TEXTURE_DEPTH);
- PY_DICT_ADD_INT(GL_TEXTURE_MAX_LEVEL);
- PY_DICT_ADD_INT(GL_TEXTURE_MAX_LOD);
- PY_DICT_ADD_INT(GL_TEXTURE_MIN_LOD);
- PY_DICT_ADD_INT(GL_TEXTURE_WRAP_R);
- PY_DICT_ADD_INT(GL_UNPACK_IMAGE_HEIGHT);
- PY_DICT_ADD_INT(GL_UNPACK_SKIP_IMAGES);
- PY_DICT_ADD_INT(GL_UNSIGNED_BYTE_2_3_3_REV);
- PY_DICT_ADD_INT(GL_UNSIGNED_BYTE_3_3_2);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_10_10_10_2);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_2_10_10_10_REV);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_8_8_8_8);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_8_8_8_8_REV);
- PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_1_5_5_5_REV);
- PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_4_4_4_4);
- PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_4_4_4_4_REV);
- PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_5_5_5_1);
- PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_5_6_5);
- PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_5_6_5_REV);
- }
-
+ PY_DICT_ADD_INT(GL_ALIASED_LINE_WIDTH_RANGE);
+ PY_DICT_ADD_INT(GL_BGR);
+ PY_DICT_ADD_INT(GL_BGRA);
+ PY_DICT_ADD_INT(GL_CLAMP_TO_EDGE);
+ PY_DICT_ADD_INT(GL_MAX_3D_TEXTURE_SIZE);
+ PY_DICT_ADD_INT(GL_MAX_ELEMENTS_INDICES);
+ PY_DICT_ADD_INT(GL_MAX_ELEMENTS_VERTICES);
+ PY_DICT_ADD_INT(GL_PACK_IMAGE_HEIGHT);
+ PY_DICT_ADD_INT(GL_PACK_SKIP_IMAGES);
+ PY_DICT_ADD_INT(GL_PROXY_TEXTURE_3D);
+ PY_DICT_ADD_INT(GL_SMOOTH_LINE_WIDTH_GRANULARITY);
+ PY_DICT_ADD_INT(GL_SMOOTH_LINE_WIDTH_RANGE);
+ PY_DICT_ADD_INT(GL_SMOOTH_POINT_SIZE_GRANULARITY);
+ PY_DICT_ADD_INT(GL_SMOOTH_POINT_SIZE_RANGE);
+ PY_DICT_ADD_INT(GL_TEXTURE_3D);
+ PY_DICT_ADD_INT(GL_TEXTURE_BASE_LEVEL);
+ PY_DICT_ADD_INT(GL_TEXTURE_BINDING_3D);
+ PY_DICT_ADD_INT(GL_TEXTURE_DEPTH);
+ PY_DICT_ADD_INT(GL_TEXTURE_MAX_LEVEL);
+ PY_DICT_ADD_INT(GL_TEXTURE_MAX_LOD);
+ PY_DICT_ADD_INT(GL_TEXTURE_MIN_LOD);
+ PY_DICT_ADD_INT(GL_TEXTURE_WRAP_R);
+ PY_DICT_ADD_INT(GL_UNPACK_IMAGE_HEIGHT);
+ PY_DICT_ADD_INT(GL_UNPACK_SKIP_IMAGES);
+ PY_DICT_ADD_INT(GL_UNSIGNED_BYTE_2_3_3_REV);
+ PY_DICT_ADD_INT(GL_UNSIGNED_BYTE_3_3_2);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_10_10_10_2);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_2_10_10_10_REV);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_8_8_8_8);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_8_8_8_8_REV);
+ PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_1_5_5_5_REV);
+ PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_4_4_4_4);
+ PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_4_4_4_4_REV);
+ PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_5_5_5_1);
+ PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_5_6_5);
+ PY_DICT_ADD_INT(GL_UNSIGNED_SHORT_5_6_5_REV);
+}
+static void init_bgl_version_1_3_constants(PyObject *dict)
+{
/* GL_VERSION_1_3 */
- {
- PY_DICT_ADD_INT(GL_ACTIVE_TEXTURE);
- PY_DICT_ADD_INT(GL_CLAMP_TO_BORDER);
- PY_DICT_ADD_INT(GL_COMPRESSED_RGB);
- PY_DICT_ADD_INT(GL_COMPRESSED_RGBA);
- PY_DICT_ADD_INT(GL_COMPRESSED_TEXTURE_FORMATS);
- PY_DICT_ADD_INT(GL_MAX_CUBE_MAP_TEXTURE_SIZE);
- PY_DICT_ADD_INT(GL_MULTISAMPLE);
- PY_DICT_ADD_INT(GL_NUM_COMPRESSED_TEXTURE_FORMATS);
- PY_DICT_ADD_INT(GL_PROXY_TEXTURE_CUBE_MAP);
- PY_DICT_ADD_INT(GL_SAMPLES);
- PY_DICT_ADD_INT(GL_SAMPLE_ALPHA_TO_COVERAGE);
- PY_DICT_ADD_INT(GL_SAMPLE_ALPHA_TO_ONE);
- PY_DICT_ADD_INT(GL_SAMPLE_BUFFERS);
- PY_DICT_ADD_INT(GL_SAMPLE_COVERAGE);
- PY_DICT_ADD_INT(GL_SAMPLE_COVERAGE_INVERT);
- PY_DICT_ADD_INT(GL_SAMPLE_COVERAGE_VALUE);
- PY_DICT_ADD_INT(GL_TEXTURE0);
- PY_DICT_ADD_INT(GL_TEXTURE1);
- PY_DICT_ADD_INT(GL_TEXTURE10);
- PY_DICT_ADD_INT(GL_TEXTURE11);
- PY_DICT_ADD_INT(GL_TEXTURE12);
- PY_DICT_ADD_INT(GL_TEXTURE13);
- PY_DICT_ADD_INT(GL_TEXTURE14);
- PY_DICT_ADD_INT(GL_TEXTURE15);
- PY_DICT_ADD_INT(GL_TEXTURE16);
- PY_DICT_ADD_INT(GL_TEXTURE17);
- PY_DICT_ADD_INT(GL_TEXTURE18);
- PY_DICT_ADD_INT(GL_TEXTURE19);
- PY_DICT_ADD_INT(GL_TEXTURE2);
- PY_DICT_ADD_INT(GL_TEXTURE20);
- PY_DICT_ADD_INT(GL_TEXTURE21);
- PY_DICT_ADD_INT(GL_TEXTURE22);
- PY_DICT_ADD_INT(GL_TEXTURE23);
- PY_DICT_ADD_INT(GL_TEXTURE24);
- PY_DICT_ADD_INT(GL_TEXTURE25);
- PY_DICT_ADD_INT(GL_TEXTURE26);
- PY_DICT_ADD_INT(GL_TEXTURE27);
- PY_DICT_ADD_INT(GL_TEXTURE28);
- PY_DICT_ADD_INT(GL_TEXTURE29);
- PY_DICT_ADD_INT(GL_TEXTURE3);
- PY_DICT_ADD_INT(GL_TEXTURE30);
- PY_DICT_ADD_INT(GL_TEXTURE31);
- PY_DICT_ADD_INT(GL_TEXTURE4);
- PY_DICT_ADD_INT(GL_TEXTURE5);
- PY_DICT_ADD_INT(GL_TEXTURE6);
- PY_DICT_ADD_INT(GL_TEXTURE7);
- PY_DICT_ADD_INT(GL_TEXTURE8);
- PY_DICT_ADD_INT(GL_TEXTURE9);
- PY_DICT_ADD_INT(GL_TEXTURE_BINDING_CUBE_MAP);
- PY_DICT_ADD_INT(GL_TEXTURE_COMPRESSED);
- PY_DICT_ADD_INT(GL_TEXTURE_COMPRESSED_IMAGE_SIZE);
- PY_DICT_ADD_INT(GL_TEXTURE_COMPRESSION_HINT);
- PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP);
- PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X);
- PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y);
- PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
- PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_POSITIVE_X);
- PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_POSITIVE_Y);
- PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_POSITIVE_Z);
- }
-
+ PY_DICT_ADD_INT(GL_ACTIVE_TEXTURE);
+ PY_DICT_ADD_INT(GL_CLAMP_TO_BORDER);
+ PY_DICT_ADD_INT(GL_COMPRESSED_RGB);
+ PY_DICT_ADD_INT(GL_COMPRESSED_RGBA);
+ PY_DICT_ADD_INT(GL_COMPRESSED_TEXTURE_FORMATS);
+ PY_DICT_ADD_INT(GL_MAX_CUBE_MAP_TEXTURE_SIZE);
+ PY_DICT_ADD_INT(GL_MULTISAMPLE);
+ PY_DICT_ADD_INT(GL_NUM_COMPRESSED_TEXTURE_FORMATS);
+ PY_DICT_ADD_INT(GL_PROXY_TEXTURE_CUBE_MAP);
+ PY_DICT_ADD_INT(GL_SAMPLES);
+ PY_DICT_ADD_INT(GL_SAMPLE_ALPHA_TO_COVERAGE);
+ PY_DICT_ADD_INT(GL_SAMPLE_ALPHA_TO_ONE);
+ PY_DICT_ADD_INT(GL_SAMPLE_BUFFERS);
+ PY_DICT_ADD_INT(GL_SAMPLE_COVERAGE);
+ PY_DICT_ADD_INT(GL_SAMPLE_COVERAGE_INVERT);
+ PY_DICT_ADD_INT(GL_SAMPLE_COVERAGE_VALUE);
+ PY_DICT_ADD_INT(GL_TEXTURE0);
+ PY_DICT_ADD_INT(GL_TEXTURE1);
+ PY_DICT_ADD_INT(GL_TEXTURE10);
+ PY_DICT_ADD_INT(GL_TEXTURE11);
+ PY_DICT_ADD_INT(GL_TEXTURE12);
+ PY_DICT_ADD_INT(GL_TEXTURE13);
+ PY_DICT_ADD_INT(GL_TEXTURE14);
+ PY_DICT_ADD_INT(GL_TEXTURE15);
+ PY_DICT_ADD_INT(GL_TEXTURE16);
+ PY_DICT_ADD_INT(GL_TEXTURE17);
+ PY_DICT_ADD_INT(GL_TEXTURE18);
+ PY_DICT_ADD_INT(GL_TEXTURE19);
+ PY_DICT_ADD_INT(GL_TEXTURE2);
+ PY_DICT_ADD_INT(GL_TEXTURE20);
+ PY_DICT_ADD_INT(GL_TEXTURE21);
+ PY_DICT_ADD_INT(GL_TEXTURE22);
+ PY_DICT_ADD_INT(GL_TEXTURE23);
+ PY_DICT_ADD_INT(GL_TEXTURE24);
+ PY_DICT_ADD_INT(GL_TEXTURE25);
+ PY_DICT_ADD_INT(GL_TEXTURE26);
+ PY_DICT_ADD_INT(GL_TEXTURE27);
+ PY_DICT_ADD_INT(GL_TEXTURE28);
+ PY_DICT_ADD_INT(GL_TEXTURE29);
+ PY_DICT_ADD_INT(GL_TEXTURE3);
+ PY_DICT_ADD_INT(GL_TEXTURE30);
+ PY_DICT_ADD_INT(GL_TEXTURE31);
+ PY_DICT_ADD_INT(GL_TEXTURE4);
+ PY_DICT_ADD_INT(GL_TEXTURE5);
+ PY_DICT_ADD_INT(GL_TEXTURE6);
+ PY_DICT_ADD_INT(GL_TEXTURE7);
+ PY_DICT_ADD_INT(GL_TEXTURE8);
+ PY_DICT_ADD_INT(GL_TEXTURE9);
+ PY_DICT_ADD_INT(GL_TEXTURE_BINDING_CUBE_MAP);
+ PY_DICT_ADD_INT(GL_TEXTURE_COMPRESSED);
+ PY_DICT_ADD_INT(GL_TEXTURE_COMPRESSED_IMAGE_SIZE);
+ PY_DICT_ADD_INT(GL_TEXTURE_COMPRESSION_HINT);
+ PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP);
+ PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X);
+ PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y);
+ PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
+ PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_POSITIVE_X);
+ PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_POSITIVE_Y);
+ PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_POSITIVE_Z);
+}
+static void init_bgl_version_1_4_constants(PyObject *dict)
+{
/* GL_VERSION_1_4 */
- {
- PY_DICT_ADD_INT(GL_BLEND_DST_ALPHA);
- PY_DICT_ADD_INT(GL_BLEND_DST_RGB);
- PY_DICT_ADD_INT(GL_BLEND_SRC_ALPHA);
- PY_DICT_ADD_INT(GL_BLEND_SRC_RGB);
- PY_DICT_ADD_INT(GL_CONSTANT_ALPHA);
- PY_DICT_ADD_INT(GL_CONSTANT_COLOR);
- PY_DICT_ADD_INT(GL_DECR_WRAP);
- PY_DICT_ADD_INT(GL_DEPTH_COMPONENT16);
- PY_DICT_ADD_INT(GL_DEPTH_COMPONENT24);
- PY_DICT_ADD_INT(GL_DEPTH_COMPONENT32);
- PY_DICT_ADD_INT(GL_FUNC_ADD);
- PY_DICT_ADD_INT(GL_FUNC_REVERSE_SUBTRACT);
- PY_DICT_ADD_INT(GL_FUNC_SUBTRACT);
- PY_DICT_ADD_INT(GL_INCR_WRAP);
- PY_DICT_ADD_INT(GL_MAX);
- PY_DICT_ADD_INT(GL_MAX_TEXTURE_LOD_BIAS);
- PY_DICT_ADD_INT(GL_MIN);
- PY_DICT_ADD_INT(GL_MIRRORED_REPEAT);
- PY_DICT_ADD_INT(GL_ONE_MINUS_CONSTANT_ALPHA);
- PY_DICT_ADD_INT(GL_ONE_MINUS_CONSTANT_COLOR);
- PY_DICT_ADD_INT(GL_POINT_FADE_THRESHOLD_SIZE);
- PY_DICT_ADD_INT(GL_TEXTURE_COMPARE_FUNC);
- PY_DICT_ADD_INT(GL_TEXTURE_COMPARE_MODE);
- PY_DICT_ADD_INT(GL_TEXTURE_DEPTH_SIZE);
- PY_DICT_ADD_INT(GL_TEXTURE_LOD_BIAS);
- }
-
+ PY_DICT_ADD_INT(GL_BLEND_DST_ALPHA);
+ PY_DICT_ADD_INT(GL_BLEND_DST_RGB);
+ PY_DICT_ADD_INT(GL_BLEND_SRC_ALPHA);
+ PY_DICT_ADD_INT(GL_BLEND_SRC_RGB);
+ PY_DICT_ADD_INT(GL_CONSTANT_ALPHA);
+ PY_DICT_ADD_INT(GL_CONSTANT_COLOR);
+ PY_DICT_ADD_INT(GL_DECR_WRAP);
+ PY_DICT_ADD_INT(GL_DEPTH_COMPONENT16);
+ PY_DICT_ADD_INT(GL_DEPTH_COMPONENT24);
+ PY_DICT_ADD_INT(GL_DEPTH_COMPONENT32);
+ PY_DICT_ADD_INT(GL_FUNC_ADD);
+ PY_DICT_ADD_INT(GL_FUNC_REVERSE_SUBTRACT);
+ PY_DICT_ADD_INT(GL_FUNC_SUBTRACT);
+ PY_DICT_ADD_INT(GL_INCR_WRAP);
+ PY_DICT_ADD_INT(GL_MAX);
+ PY_DICT_ADD_INT(GL_MAX_TEXTURE_LOD_BIAS);
+ PY_DICT_ADD_INT(GL_MIN);
+ PY_DICT_ADD_INT(GL_MIRRORED_REPEAT);
+ PY_DICT_ADD_INT(GL_ONE_MINUS_CONSTANT_ALPHA);
+ PY_DICT_ADD_INT(GL_ONE_MINUS_CONSTANT_COLOR);
+ PY_DICT_ADD_INT(GL_POINT_FADE_THRESHOLD_SIZE);
+ PY_DICT_ADD_INT(GL_TEXTURE_COMPARE_FUNC);
+ PY_DICT_ADD_INT(GL_TEXTURE_COMPARE_MODE);
+ PY_DICT_ADD_INT(GL_TEXTURE_DEPTH_SIZE);
+ PY_DICT_ADD_INT(GL_TEXTURE_LOD_BIAS);
+}
+static void init_bgl_version_1_5_constants(PyObject *dict)
+{
/* GL_VERSION_1_5 */
- {
- PY_DICT_ADD_INT(GL_ARRAY_BUFFER);
- PY_DICT_ADD_INT(GL_ARRAY_BUFFER_BINDING);
- PY_DICT_ADD_INT(GL_BUFFER_ACCESS);
- PY_DICT_ADD_INT(GL_BUFFER_MAPPED);
- PY_DICT_ADD_INT(GL_BUFFER_MAP_POINTER);
- PY_DICT_ADD_INT(GL_BUFFER_SIZE);
- PY_DICT_ADD_INT(GL_BUFFER_USAGE);
- PY_DICT_ADD_INT(GL_CURRENT_QUERY);
- PY_DICT_ADD_INT(GL_DYNAMIC_COPY);
- PY_DICT_ADD_INT(GL_DYNAMIC_DRAW);
- PY_DICT_ADD_INT(GL_DYNAMIC_READ);
- PY_DICT_ADD_INT(GL_ELEMENT_ARRAY_BUFFER);
- PY_DICT_ADD_INT(GL_ELEMENT_ARRAY_BUFFER_BINDING);
- PY_DICT_ADD_INT(GL_QUERY_COUNTER_BITS);
- PY_DICT_ADD_INT(GL_QUERY_RESULT);
- PY_DICT_ADD_INT(GL_QUERY_RESULT_AVAILABLE);
- PY_DICT_ADD_INT(GL_READ_ONLY);
- PY_DICT_ADD_INT(GL_READ_WRITE);
- PY_DICT_ADD_INT(GL_SAMPLES_PASSED);
- PY_DICT_ADD_INT(GL_STATIC_COPY);
- PY_DICT_ADD_INT(GL_STATIC_DRAW);
- PY_DICT_ADD_INT(GL_STATIC_READ);
- PY_DICT_ADD_INT(GL_STREAM_COPY);
- PY_DICT_ADD_INT(GL_STREAM_DRAW);
- PY_DICT_ADD_INT(GL_STREAM_READ);
- PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
- PY_DICT_ADD_INT(GL_WRITE_ONLY);
- }
-
+ PY_DICT_ADD_INT(GL_ARRAY_BUFFER);
+ PY_DICT_ADD_INT(GL_ARRAY_BUFFER_BINDING);
+ PY_DICT_ADD_INT(GL_BUFFER_ACCESS);
+ PY_DICT_ADD_INT(GL_BUFFER_MAPPED);
+ PY_DICT_ADD_INT(GL_BUFFER_MAP_POINTER);
+ PY_DICT_ADD_INT(GL_BUFFER_SIZE);
+ PY_DICT_ADD_INT(GL_BUFFER_USAGE);
+ PY_DICT_ADD_INT(GL_CURRENT_QUERY);
+ PY_DICT_ADD_INT(GL_DYNAMIC_COPY);
+ PY_DICT_ADD_INT(GL_DYNAMIC_DRAW);
+ PY_DICT_ADD_INT(GL_DYNAMIC_READ);
+ PY_DICT_ADD_INT(GL_ELEMENT_ARRAY_BUFFER);
+ PY_DICT_ADD_INT(GL_ELEMENT_ARRAY_BUFFER_BINDING);
+ PY_DICT_ADD_INT(GL_QUERY_COUNTER_BITS);
+ PY_DICT_ADD_INT(GL_QUERY_RESULT);
+ PY_DICT_ADD_INT(GL_QUERY_RESULT_AVAILABLE);
+ PY_DICT_ADD_INT(GL_READ_ONLY);
+ PY_DICT_ADD_INT(GL_READ_WRITE);
+ PY_DICT_ADD_INT(GL_SAMPLES_PASSED);
+ PY_DICT_ADD_INT(GL_STATIC_COPY);
+ PY_DICT_ADD_INT(GL_STATIC_DRAW);
+ PY_DICT_ADD_INT(GL_STATIC_READ);
+ PY_DICT_ADD_INT(GL_STREAM_COPY);
+ PY_DICT_ADD_INT(GL_STREAM_DRAW);
+ PY_DICT_ADD_INT(GL_STREAM_READ);
+ PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
+ PY_DICT_ADD_INT(GL_WRITE_ONLY);
+}
+static void init_bgl_version_2_0_constants(PyObject *dict)
+{
/* GL_VERSION_2_0 */
- {
- PY_DICT_ADD_INT(GL_ACTIVE_ATTRIBUTES);
- PY_DICT_ADD_INT(GL_ACTIVE_ATTRIBUTE_MAX_LENGTH);
- PY_DICT_ADD_INT(GL_ACTIVE_UNIFORMS);
- PY_DICT_ADD_INT(GL_ACTIVE_UNIFORM_MAX_LENGTH);
- PY_DICT_ADD_INT(GL_ATTACHED_SHADERS);
- PY_DICT_ADD_INT(GL_BLEND_EQUATION_ALPHA);
- PY_DICT_ADD_INT(GL_BLEND_EQUATION_RGB);
- PY_DICT_ADD_INT(GL_BOOL);
- PY_DICT_ADD_INT(GL_BOOL_VEC2);
- PY_DICT_ADD_INT(GL_BOOL_VEC3);
- PY_DICT_ADD_INT(GL_BOOL_VEC4);
- PY_DICT_ADD_INT(GL_COMPILE_STATUS);
- PY_DICT_ADD_INT(GL_CURRENT_PROGRAM);
- PY_DICT_ADD_INT(GL_CURRENT_VERTEX_ATTRIB);
- PY_DICT_ADD_INT(GL_DELETE_STATUS);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER0);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER1);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER10);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER11);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER12);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER13);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER14);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER15);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER2);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER3);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER4);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER5);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER6);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER7);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER8);
- PY_DICT_ADD_INT(GL_DRAW_BUFFER9);
- PY_DICT_ADD_INT(GL_FLOAT_MAT2);
- PY_DICT_ADD_INT(GL_FLOAT_MAT3);
- PY_DICT_ADD_INT(GL_FLOAT_MAT4);
- PY_DICT_ADD_INT(GL_FLOAT_VEC2);
- PY_DICT_ADD_INT(GL_FLOAT_VEC3);
- PY_DICT_ADD_INT(GL_FLOAT_VEC4);
- PY_DICT_ADD_INT(GL_FRAGMENT_SHADER);
- PY_DICT_ADD_INT(GL_FRAGMENT_SHADER_DERIVATIVE_HINT);
- PY_DICT_ADD_INT(GL_INFO_LOG_LENGTH);
- PY_DICT_ADD_INT(GL_INT_VEC2);
- PY_DICT_ADD_INT(GL_INT_VEC3);
- PY_DICT_ADD_INT(GL_INT_VEC4);
- PY_DICT_ADD_INT(GL_LINK_STATUS);
- PY_DICT_ADD_INT(GL_LOWER_LEFT);
- PY_DICT_ADD_INT(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
- PY_DICT_ADD_INT(GL_MAX_DRAW_BUFFERS);
- PY_DICT_ADD_INT(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS);
- PY_DICT_ADD_INT(GL_MAX_TEXTURE_IMAGE_UNITS);
- PY_DICT_ADD_INT(GL_MAX_VARYING_FLOATS);
- PY_DICT_ADD_INT(GL_MAX_VERTEX_ATTRIBS);
- PY_DICT_ADD_INT(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
- PY_DICT_ADD_INT(GL_MAX_VERTEX_UNIFORM_COMPONENTS);
- PY_DICT_ADD_INT(GL_POINT_SPRITE_COORD_ORIGIN);
- PY_DICT_ADD_INT(GL_SAMPLER_1D);
- PY_DICT_ADD_INT(GL_SAMPLER_1D_SHADOW);
- PY_DICT_ADD_INT(GL_SAMPLER_2D);
- PY_DICT_ADD_INT(GL_SAMPLER_2D_SHADOW);
- PY_DICT_ADD_INT(GL_SAMPLER_3D);
- PY_DICT_ADD_INT(GL_SAMPLER_CUBE);
- PY_DICT_ADD_INT(GL_SHADER_SOURCE_LENGTH);
- PY_DICT_ADD_INT(GL_SHADER_TYPE);
- PY_DICT_ADD_INT(GL_SHADING_LANGUAGE_VERSION);
- PY_DICT_ADD_INT(GL_STENCIL_BACK_FAIL);
- PY_DICT_ADD_INT(GL_STENCIL_BACK_FUNC);
- PY_DICT_ADD_INT(GL_STENCIL_BACK_PASS_DEPTH_FAIL);
- PY_DICT_ADD_INT(GL_STENCIL_BACK_PASS_DEPTH_PASS);
- PY_DICT_ADD_INT(GL_STENCIL_BACK_REF);
- PY_DICT_ADD_INT(GL_STENCIL_BACK_VALUE_MASK);
- PY_DICT_ADD_INT(GL_STENCIL_BACK_WRITEMASK);
- PY_DICT_ADD_INT(GL_UPPER_LEFT);
- PY_DICT_ADD_INT(GL_VALIDATE_STATUS);
- PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_ENABLED);
- PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_NORMALIZED);
- PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_POINTER);
- PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_SIZE);
- PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_STRIDE);
- PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_TYPE);
- PY_DICT_ADD_INT(GL_VERTEX_PROGRAM_POINT_SIZE);
- PY_DICT_ADD_INT(GL_VERTEX_SHADER);
- }
-
+ PY_DICT_ADD_INT(GL_ACTIVE_ATTRIBUTES);
+ PY_DICT_ADD_INT(GL_ACTIVE_ATTRIBUTE_MAX_LENGTH);
+ PY_DICT_ADD_INT(GL_ACTIVE_UNIFORMS);
+ PY_DICT_ADD_INT(GL_ACTIVE_UNIFORM_MAX_LENGTH);
+ PY_DICT_ADD_INT(GL_ATTACHED_SHADERS);
+ PY_DICT_ADD_INT(GL_BLEND_EQUATION_ALPHA);
+ PY_DICT_ADD_INT(GL_BLEND_EQUATION_RGB);
+ PY_DICT_ADD_INT(GL_BOOL);
+ PY_DICT_ADD_INT(GL_BOOL_VEC2);
+ PY_DICT_ADD_INT(GL_BOOL_VEC3);
+ PY_DICT_ADD_INT(GL_BOOL_VEC4);
+ PY_DICT_ADD_INT(GL_COMPILE_STATUS);
+ PY_DICT_ADD_INT(GL_CURRENT_PROGRAM);
+ PY_DICT_ADD_INT(GL_CURRENT_VERTEX_ATTRIB);
+ PY_DICT_ADD_INT(GL_DELETE_STATUS);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER0);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER1);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER10);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER11);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER12);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER13);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER14);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER15);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER2);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER3);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER4);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER5);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER6);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER7);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER8);
+ PY_DICT_ADD_INT(GL_DRAW_BUFFER9);
+ PY_DICT_ADD_INT(GL_FLOAT_MAT2);
+ PY_DICT_ADD_INT(GL_FLOAT_MAT3);
+ PY_DICT_ADD_INT(GL_FLOAT_MAT4);
+ PY_DICT_ADD_INT(GL_FLOAT_VEC2);
+ PY_DICT_ADD_INT(GL_FLOAT_VEC3);
+ PY_DICT_ADD_INT(GL_FLOAT_VEC4);
+ PY_DICT_ADD_INT(GL_FRAGMENT_SHADER);
+ PY_DICT_ADD_INT(GL_FRAGMENT_SHADER_DERIVATIVE_HINT);
+ PY_DICT_ADD_INT(GL_INFO_LOG_LENGTH);
+ PY_DICT_ADD_INT(GL_INT_VEC2);
+ PY_DICT_ADD_INT(GL_INT_VEC3);
+ PY_DICT_ADD_INT(GL_INT_VEC4);
+ PY_DICT_ADD_INT(GL_LINK_STATUS);
+ PY_DICT_ADD_INT(GL_LOWER_LEFT);
+ PY_DICT_ADD_INT(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+ PY_DICT_ADD_INT(GL_MAX_DRAW_BUFFERS);
+ PY_DICT_ADD_INT(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MAX_TEXTURE_IMAGE_UNITS);
+ PY_DICT_ADD_INT(GL_MAX_VARYING_FLOATS);
+ PY_DICT_ADD_INT(GL_MAX_VERTEX_ATTRIBS);
+ PY_DICT_ADD_INT(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
+ PY_DICT_ADD_INT(GL_MAX_VERTEX_UNIFORM_COMPONENTS);
+ PY_DICT_ADD_INT(GL_POINT_SPRITE_COORD_ORIGIN);
+ PY_DICT_ADD_INT(GL_SAMPLER_1D);
+ PY_DICT_ADD_INT(GL_SAMPLER_1D_SHADOW);
+ PY_DICT_ADD_INT(GL_SAMPLER_2D);
+ PY_DICT_ADD_INT(GL_SAMPLER_2D_SHADOW);
+ PY_DICT_ADD_INT(GL_SAMPLER_3D);
+ PY_DICT_ADD_INT(GL_SAMPLER_CUBE);
+ PY_DICT_ADD_INT(GL_SHADER_SOURCE_LENGTH);
+ PY_DICT_ADD_INT(GL_SHADER_TYPE);
+ PY_DICT_ADD_INT(GL_SHADING_LANGUAGE_VERSION);
+ PY_DICT_ADD_INT(GL_STENCIL_BACK_FAIL);
+ PY_DICT_ADD_INT(GL_STENCIL_BACK_FUNC);
+ PY_DICT_ADD_INT(GL_STENCIL_BACK_PASS_DEPTH_FAIL);
+ PY_DICT_ADD_INT(GL_STENCIL_BACK_PASS_DEPTH_PASS);
+ PY_DICT_ADD_INT(GL_STENCIL_BACK_REF);
+ PY_DICT_ADD_INT(GL_STENCIL_BACK_VALUE_MASK);
+ PY_DICT_ADD_INT(GL_STENCIL_BACK_WRITEMASK);
+ PY_DICT_ADD_INT(GL_UPPER_LEFT);
+ PY_DICT_ADD_INT(GL_VALIDATE_STATUS);
+ PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_ENABLED);
+ PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_NORMALIZED);
+ PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_POINTER);
+ PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_SIZE);
+ PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_STRIDE);
+ PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_TYPE);
+ PY_DICT_ADD_INT(GL_VERTEX_PROGRAM_POINT_SIZE);
+ PY_DICT_ADD_INT(GL_VERTEX_SHADER);
+}
+static void init_bgl_version_2_1_constants(PyObject *dict)
+{
/* GL_VERSION_2_1 */
- {
- PY_DICT_ADD_INT(GL_COMPRESSED_SRGB);
- PY_DICT_ADD_INT(GL_COMPRESSED_SRGB_ALPHA);
- PY_DICT_ADD_INT(GL_FLOAT_MAT2x3);
- PY_DICT_ADD_INT(GL_FLOAT_MAT2x4);
- PY_DICT_ADD_INT(GL_FLOAT_MAT3x2);
- PY_DICT_ADD_INT(GL_FLOAT_MAT3x4);
- PY_DICT_ADD_INT(GL_FLOAT_MAT4x2);
- PY_DICT_ADD_INT(GL_FLOAT_MAT4x3);
- PY_DICT_ADD_INT(GL_PIXEL_PACK_BUFFER);
- PY_DICT_ADD_INT(GL_PIXEL_PACK_BUFFER_BINDING);
- PY_DICT_ADD_INT(GL_PIXEL_UNPACK_BUFFER);
- PY_DICT_ADD_INT(GL_PIXEL_UNPACK_BUFFER_BINDING);
- PY_DICT_ADD_INT(GL_SRGB);
- PY_DICT_ADD_INT(GL_SRGB8);
- PY_DICT_ADD_INT(GL_SRGB8_ALPHA8);
- PY_DICT_ADD_INT(GL_SRGB_ALPHA);
- }
-
+ PY_DICT_ADD_INT(GL_COMPRESSED_SRGB);
+ PY_DICT_ADD_INT(GL_COMPRESSED_SRGB_ALPHA);
+ PY_DICT_ADD_INT(GL_FLOAT_MAT2x3);
+ PY_DICT_ADD_INT(GL_FLOAT_MAT2x4);
+ PY_DICT_ADD_INT(GL_FLOAT_MAT3x2);
+ PY_DICT_ADD_INT(GL_FLOAT_MAT3x4);
+ PY_DICT_ADD_INT(GL_FLOAT_MAT4x2);
+ PY_DICT_ADD_INT(GL_FLOAT_MAT4x3);
+ PY_DICT_ADD_INT(GL_PIXEL_PACK_BUFFER);
+ PY_DICT_ADD_INT(GL_PIXEL_PACK_BUFFER_BINDING);
+ PY_DICT_ADD_INT(GL_PIXEL_UNPACK_BUFFER);
+ PY_DICT_ADD_INT(GL_PIXEL_UNPACK_BUFFER_BINDING);
+ PY_DICT_ADD_INT(GL_SRGB);
+ PY_DICT_ADD_INT(GL_SRGB8);
+ PY_DICT_ADD_INT(GL_SRGB8_ALPHA8);
+ PY_DICT_ADD_INT(GL_SRGB_ALPHA);
+}
+static void init_bgl_version_3_0_constants(PyObject *dict)
+{
/* GL_VERSION_3_0 */
- {
- PY_DICT_ADD_INT(GL_BGRA_INTEGER);
- PY_DICT_ADD_INT(GL_BGR_INTEGER);
- PY_DICT_ADD_INT(GL_BLUE_INTEGER);
- PY_DICT_ADD_INT(GL_BUFFER_ACCESS_FLAGS);
- PY_DICT_ADD_INT(GL_BUFFER_MAP_LENGTH);
- PY_DICT_ADD_INT(GL_BUFFER_MAP_OFFSET);
- PY_DICT_ADD_INT(GL_CLAMP_READ_COLOR);
- PY_DICT_ADD_INT(GL_CLIP_DISTANCE0);
- PY_DICT_ADD_INT(GL_CLIP_DISTANCE1);
- PY_DICT_ADD_INT(GL_CLIP_DISTANCE2);
- PY_DICT_ADD_INT(GL_CLIP_DISTANCE3);
- PY_DICT_ADD_INT(GL_CLIP_DISTANCE4);
- PY_DICT_ADD_INT(GL_CLIP_DISTANCE5);
+ PY_DICT_ADD_INT(GL_BGRA_INTEGER);
+ PY_DICT_ADD_INT(GL_BGR_INTEGER);
+ PY_DICT_ADD_INT(GL_BLUE_INTEGER);
+ PY_DICT_ADD_INT(GL_BUFFER_ACCESS_FLAGS);
+ PY_DICT_ADD_INT(GL_BUFFER_MAP_LENGTH);
+ PY_DICT_ADD_INT(GL_BUFFER_MAP_OFFSET);
+ PY_DICT_ADD_INT(GL_CLAMP_READ_COLOR);
+ PY_DICT_ADD_INT(GL_CLIP_DISTANCE0);
+ PY_DICT_ADD_INT(GL_CLIP_DISTANCE1);
+ PY_DICT_ADD_INT(GL_CLIP_DISTANCE2);
+ PY_DICT_ADD_INT(GL_CLIP_DISTANCE3);
+ PY_DICT_ADD_INT(GL_CLIP_DISTANCE4);
+ PY_DICT_ADD_INT(GL_CLIP_DISTANCE5);
#if 0
PY_DICT_ADD_INT(GL_CLIP_DISTANCE6);
PY_DICT_ADD_INT(GL_CLIP_DISTANCE7);
#endif
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT0);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT1);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT2);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT3);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT4);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT5);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT6);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT7);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT8);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT9);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT10);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT11);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT12);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT13);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT14);
- PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT15);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT0);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT1);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT2);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT3);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT4);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT5);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT6);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT7);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT8);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT9);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT10);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT11);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT12);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT13);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT14);
+ PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT15);
#if 0
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT16);
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT17);
@@ -2267,346 +2248,384 @@ PyObject *BPyInit_bgl(void)
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT30);
PY_DICT_ADD_INT(GL_COLOR_ATTACHMENT31);
#endif
- PY_DICT_ADD_INT(GL_COMPARE_REF_TO_TEXTURE);
- PY_DICT_ADD_INT(GL_COMPRESSED_RED);
- PY_DICT_ADD_INT(GL_COMPRESSED_RED_RGTC1);
- PY_DICT_ADD_INT(GL_COMPRESSED_RG);
- PY_DICT_ADD_INT(GL_COMPRESSED_RG_RGTC2);
- PY_DICT_ADD_INT(GL_COMPRESSED_SIGNED_RED_RGTC1);
- PY_DICT_ADD_INT(GL_COMPRESSED_SIGNED_RG_RGTC2);
- PY_DICT_ADD_INT(GL_CONTEXT_FLAGS);
- PY_DICT_ADD_INT(GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT);
- PY_DICT_ADD_INT(GL_DEPTH24_STENCIL8);
- PY_DICT_ADD_INT(GL_DEPTH32F_STENCIL8);
- PY_DICT_ADD_INT(GL_DEPTH_ATTACHMENT);
- PY_DICT_ADD_INT(GL_DEPTH_COMPONENT32F);
- PY_DICT_ADD_INT(GL_DEPTH_STENCIL);
- PY_DICT_ADD_INT(GL_DEPTH_STENCIL_ATTACHMENT);
- PY_DICT_ADD_INT(GL_DRAW_FRAMEBUFFER);
- PY_DICT_ADD_INT(GL_DRAW_FRAMEBUFFER_BINDING);
- PY_DICT_ADD_INT(GL_FIXED_ONLY);
- PY_DICT_ADD_INT(GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_BINDING);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_COMPLETE);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_DEFAULT);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_SRGB);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_UNDEFINED);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_UNSUPPORTED);
- PY_DICT_ADD_INT(GL_GREEN_INTEGER);
- PY_DICT_ADD_INT(GL_HALF_FLOAT);
- PY_DICT_ADD_INT(GL_INDEX);
- PY_DICT_ADD_INT(GL_INTERLEAVED_ATTRIBS);
- PY_DICT_ADD_INT(GL_INT_SAMPLER_1D);
- PY_DICT_ADD_INT(GL_INT_SAMPLER_1D_ARRAY);
- PY_DICT_ADD_INT(GL_INT_SAMPLER_2D);
- PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_ARRAY);
- PY_DICT_ADD_INT(GL_INT_SAMPLER_3D);
- PY_DICT_ADD_INT(GL_INT_SAMPLER_CUBE);
- PY_DICT_ADD_INT(GL_INVALID_FRAMEBUFFER_OPERATION);
- PY_DICT_ADD_INT(GL_MAJOR_VERSION);
- PY_DICT_ADD_INT(GL_MAP_FLUSH_EXPLICIT_BIT);
- PY_DICT_ADD_INT(GL_MAP_INVALIDATE_BUFFER_BIT);
- PY_DICT_ADD_INT(GL_MAP_INVALIDATE_RANGE_BIT);
- PY_DICT_ADD_INT(GL_MAP_READ_BIT);
- PY_DICT_ADD_INT(GL_MAP_UNSYNCHRONIZED_BIT);
- PY_DICT_ADD_INT(GL_MAP_WRITE_BIT);
- PY_DICT_ADD_INT(GL_MAX_ARRAY_TEXTURE_LAYERS);
- PY_DICT_ADD_INT(GL_MAX_CLIP_DISTANCES);
- PY_DICT_ADD_INT(GL_MAX_COLOR_ATTACHMENTS);
- PY_DICT_ADD_INT(GL_MAX_PROGRAM_TEXEL_OFFSET);
- PY_DICT_ADD_INT(GL_MAX_RENDERBUFFER_SIZE);
- PY_DICT_ADD_INT(GL_MAX_SAMPLES);
- PY_DICT_ADD_INT(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS);
- PY_DICT_ADD_INT(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS);
- PY_DICT_ADD_INT(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS);
- PY_DICT_ADD_INT(GL_MAX_VARYING_COMPONENTS);
- PY_DICT_ADD_INT(GL_MINOR_VERSION);
- PY_DICT_ADD_INT(GL_MIN_PROGRAM_TEXEL_OFFSET);
- PY_DICT_ADD_INT(GL_NUM_EXTENSIONS);
- PY_DICT_ADD_INT(GL_PRIMITIVES_GENERATED);
- PY_DICT_ADD_INT(GL_PROXY_TEXTURE_1D_ARRAY);
- PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D_ARRAY);
- PY_DICT_ADD_INT(GL_QUERY_BY_REGION_NO_WAIT);
- PY_DICT_ADD_INT(GL_QUERY_BY_REGION_WAIT);
- PY_DICT_ADD_INT(GL_QUERY_NO_WAIT);
- PY_DICT_ADD_INT(GL_QUERY_WAIT);
- PY_DICT_ADD_INT(GL_R11F_G11F_B10F);
- PY_DICT_ADD_INT(GL_R16);
- PY_DICT_ADD_INT(GL_R16F);
- PY_DICT_ADD_INT(GL_R16I);
- PY_DICT_ADD_INT(GL_R16UI);
- PY_DICT_ADD_INT(GL_R32F);
- PY_DICT_ADD_INT(GL_R32I);
- PY_DICT_ADD_INT(GL_R32UI);
- PY_DICT_ADD_INT(GL_R8);
- PY_DICT_ADD_INT(GL_R8I);
- PY_DICT_ADD_INT(GL_R8UI);
- PY_DICT_ADD_INT(GL_RASTERIZER_DISCARD);
- PY_DICT_ADD_INT(GL_READ_FRAMEBUFFER);
- PY_DICT_ADD_INT(GL_READ_FRAMEBUFFER_BINDING);
- PY_DICT_ADD_INT(GL_RED_INTEGER);
- PY_DICT_ADD_INT(GL_RENDERBUFFER);
- PY_DICT_ADD_INT(GL_RENDERBUFFER_ALPHA_SIZE);
- PY_DICT_ADD_INT(GL_RENDERBUFFER_BINDING);
- PY_DICT_ADD_INT(GL_RENDERBUFFER_BLUE_SIZE);
- PY_DICT_ADD_INT(GL_RENDERBUFFER_DEPTH_SIZE);
- PY_DICT_ADD_INT(GL_RENDERBUFFER_GREEN_SIZE);
- PY_DICT_ADD_INT(GL_RENDERBUFFER_HEIGHT);
- PY_DICT_ADD_INT(GL_RENDERBUFFER_INTERNAL_FORMAT);
- PY_DICT_ADD_INT(GL_RENDERBUFFER_RED_SIZE);
- PY_DICT_ADD_INT(GL_RENDERBUFFER_SAMPLES);
- PY_DICT_ADD_INT(GL_RENDERBUFFER_STENCIL_SIZE);
- PY_DICT_ADD_INT(GL_RENDERBUFFER_WIDTH);
- PY_DICT_ADD_INT(GL_RG);
- PY_DICT_ADD_INT(GL_RG16);
- PY_DICT_ADD_INT(GL_RG16F);
- PY_DICT_ADD_INT(GL_RG16I);
- PY_DICT_ADD_INT(GL_RG16UI);
- PY_DICT_ADD_INT(GL_RG32F);
- PY_DICT_ADD_INT(GL_RG32I);
- PY_DICT_ADD_INT(GL_RG32UI);
- PY_DICT_ADD_INT(GL_RG8);
- PY_DICT_ADD_INT(GL_RG8I);
- PY_DICT_ADD_INT(GL_RG8UI);
- PY_DICT_ADD_INT(GL_RGB16F);
- PY_DICT_ADD_INT(GL_RGB16I);
- PY_DICT_ADD_INT(GL_RGB16UI);
- PY_DICT_ADD_INT(GL_RGB32F);
- PY_DICT_ADD_INT(GL_RGB32I);
- PY_DICT_ADD_INT(GL_RGB32UI);
- PY_DICT_ADD_INT(GL_RGB8I);
- PY_DICT_ADD_INT(GL_RGB8UI);
- PY_DICT_ADD_INT(GL_RGB9_E5);
- PY_DICT_ADD_INT(GL_RGBA16F);
- PY_DICT_ADD_INT(GL_RGBA16I);
- PY_DICT_ADD_INT(GL_RGBA16UI);
- PY_DICT_ADD_INT(GL_RGBA32F);
- PY_DICT_ADD_INT(GL_RGBA32I);
- PY_DICT_ADD_INT(GL_RGBA32UI);
- PY_DICT_ADD_INT(GL_RGBA8I);
- PY_DICT_ADD_INT(GL_RGBA8UI);
- PY_DICT_ADD_INT(GL_RGBA_INTEGER);
- PY_DICT_ADD_INT(GL_RGB_INTEGER);
- PY_DICT_ADD_INT(GL_RG_INTEGER);
- PY_DICT_ADD_INT(GL_SAMPLER_1D_ARRAY);
- PY_DICT_ADD_INT(GL_SAMPLER_1D_ARRAY_SHADOW);
- PY_DICT_ADD_INT(GL_SAMPLER_2D_ARRAY);
- PY_DICT_ADD_INT(GL_SAMPLER_2D_ARRAY_SHADOW);
- PY_DICT_ADD_INT(GL_SAMPLER_CUBE_SHADOW);
- PY_DICT_ADD_INT(GL_SEPARATE_ATTRIBS);
- PY_DICT_ADD_INT(GL_STENCIL_ATTACHMENT);
- PY_DICT_ADD_INT(GL_STENCIL_INDEX1);
- PY_DICT_ADD_INT(GL_STENCIL_INDEX16);
- PY_DICT_ADD_INT(GL_STENCIL_INDEX4);
- PY_DICT_ADD_INT(GL_STENCIL_INDEX8);
- PY_DICT_ADD_INT(GL_TEXTURE_1D_ARRAY);
- PY_DICT_ADD_INT(GL_TEXTURE_2D_ARRAY);
- PY_DICT_ADD_INT(GL_TEXTURE_ALPHA_TYPE);
- PY_DICT_ADD_INT(GL_TEXTURE_BINDING_1D_ARRAY);
- PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D_ARRAY);
- PY_DICT_ADD_INT(GL_TEXTURE_BLUE_TYPE);
- PY_DICT_ADD_INT(GL_TEXTURE_DEPTH_TYPE);
- PY_DICT_ADD_INT(GL_TEXTURE_GREEN_TYPE);
- PY_DICT_ADD_INT(GL_TEXTURE_RED_TYPE);
- PY_DICT_ADD_INT(GL_TEXTURE_SHARED_SIZE);
- PY_DICT_ADD_INT(GL_TEXTURE_STENCIL_SIZE);
- PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER);
- PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING);
- PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_MODE);
- PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_SIZE);
- PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_START);
- PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
- PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_VARYINGS);
- PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_10F_11F_11F_REV);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_24_8);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_5_9_9_9_REV);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_1D);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_3D);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_CUBE);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_VEC2);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_VEC3);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_VEC4);
- PY_DICT_ADD_INT(GL_UNSIGNED_NORMALIZED);
- PY_DICT_ADD_INT(GL_VERTEX_ARRAY_BINDING);
- PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_INTEGER);
- }
-
+ PY_DICT_ADD_INT(GL_COMPARE_REF_TO_TEXTURE);
+ PY_DICT_ADD_INT(GL_COMPRESSED_RED);
+ PY_DICT_ADD_INT(GL_COMPRESSED_RED_RGTC1);
+ PY_DICT_ADD_INT(GL_COMPRESSED_RG);
+ PY_DICT_ADD_INT(GL_COMPRESSED_RG_RGTC2);
+ PY_DICT_ADD_INT(GL_COMPRESSED_SIGNED_RED_RGTC1);
+ PY_DICT_ADD_INT(GL_COMPRESSED_SIGNED_RG_RGTC2);
+ PY_DICT_ADD_INT(GL_CONTEXT_FLAGS);
+ PY_DICT_ADD_INT(GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT);
+ PY_DICT_ADD_INT(GL_DEPTH24_STENCIL8);
+ PY_DICT_ADD_INT(GL_DEPTH32F_STENCIL8);
+ PY_DICT_ADD_INT(GL_DEPTH_ATTACHMENT);
+ PY_DICT_ADD_INT(GL_DEPTH_COMPONENT32F);
+ PY_DICT_ADD_INT(GL_DEPTH_STENCIL);
+ PY_DICT_ADD_INT(GL_DEPTH_STENCIL_ATTACHMENT);
+ PY_DICT_ADD_INT(GL_DRAW_FRAMEBUFFER);
+ PY_DICT_ADD_INT(GL_DRAW_FRAMEBUFFER_BINDING);
+ PY_DICT_ADD_INT(GL_FIXED_ONLY);
+ PY_DICT_ADD_INT(GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_BINDING);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_COMPLETE);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_DEFAULT);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_SRGB);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_UNDEFINED);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_UNSUPPORTED);
+ PY_DICT_ADD_INT(GL_GREEN_INTEGER);
+ PY_DICT_ADD_INT(GL_HALF_FLOAT);
+ PY_DICT_ADD_INT(GL_INDEX);
+ PY_DICT_ADD_INT(GL_INTERLEAVED_ATTRIBS);
+ PY_DICT_ADD_INT(GL_INT_SAMPLER_1D);
+ PY_DICT_ADD_INT(GL_INT_SAMPLER_1D_ARRAY);
+ PY_DICT_ADD_INT(GL_INT_SAMPLER_2D);
+ PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_ARRAY);
+ PY_DICT_ADD_INT(GL_INT_SAMPLER_3D);
+ PY_DICT_ADD_INT(GL_INT_SAMPLER_CUBE);
+ PY_DICT_ADD_INT(GL_INVALID_FRAMEBUFFER_OPERATION);
+ PY_DICT_ADD_INT(GL_MAJOR_VERSION);
+ PY_DICT_ADD_INT(GL_MAP_FLUSH_EXPLICIT_BIT);
+ PY_DICT_ADD_INT(GL_MAP_INVALIDATE_BUFFER_BIT);
+ PY_DICT_ADD_INT(GL_MAP_INVALIDATE_RANGE_BIT);
+ PY_DICT_ADD_INT(GL_MAP_READ_BIT);
+ PY_DICT_ADD_INT(GL_MAP_UNSYNCHRONIZED_BIT);
+ PY_DICT_ADD_INT(GL_MAP_WRITE_BIT);
+ PY_DICT_ADD_INT(GL_MAX_ARRAY_TEXTURE_LAYERS);
+ PY_DICT_ADD_INT(GL_MAX_CLIP_DISTANCES);
+ PY_DICT_ADD_INT(GL_MAX_COLOR_ATTACHMENTS);
+ PY_DICT_ADD_INT(GL_MAX_PROGRAM_TEXEL_OFFSET);
+ PY_DICT_ADD_INT(GL_MAX_RENDERBUFFER_SIZE);
+ PY_DICT_ADD_INT(GL_MAX_SAMPLES);
+ PY_DICT_ADD_INT(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS);
+ PY_DICT_ADD_INT(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MAX_VARYING_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MINOR_VERSION);
+ PY_DICT_ADD_INT(GL_MIN_PROGRAM_TEXEL_OFFSET);
+ PY_DICT_ADD_INT(GL_NUM_EXTENSIONS);
+ PY_DICT_ADD_INT(GL_PRIMITIVES_GENERATED);
+ PY_DICT_ADD_INT(GL_PROXY_TEXTURE_1D_ARRAY);
+ PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D_ARRAY);
+ PY_DICT_ADD_INT(GL_QUERY_BY_REGION_NO_WAIT);
+ PY_DICT_ADD_INT(GL_QUERY_BY_REGION_WAIT);
+ PY_DICT_ADD_INT(GL_QUERY_NO_WAIT);
+ PY_DICT_ADD_INT(GL_QUERY_WAIT);
+ PY_DICT_ADD_INT(GL_R11F_G11F_B10F);
+ PY_DICT_ADD_INT(GL_R16);
+ PY_DICT_ADD_INT(GL_R16F);
+ PY_DICT_ADD_INT(GL_R16I);
+ PY_DICT_ADD_INT(GL_R16UI);
+ PY_DICT_ADD_INT(GL_R32F);
+ PY_DICT_ADD_INT(GL_R32I);
+ PY_DICT_ADD_INT(GL_R32UI);
+ PY_DICT_ADD_INT(GL_R8);
+ PY_DICT_ADD_INT(GL_R8I);
+ PY_DICT_ADD_INT(GL_R8UI);
+ PY_DICT_ADD_INT(GL_RASTERIZER_DISCARD);
+ PY_DICT_ADD_INT(GL_READ_FRAMEBUFFER);
+ PY_DICT_ADD_INT(GL_READ_FRAMEBUFFER_BINDING);
+ PY_DICT_ADD_INT(GL_RED_INTEGER);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER_ALPHA_SIZE);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER_BINDING);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER_BLUE_SIZE);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER_DEPTH_SIZE);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER_GREEN_SIZE);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER_HEIGHT);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER_INTERNAL_FORMAT);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER_RED_SIZE);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER_SAMPLES);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER_STENCIL_SIZE);
+ PY_DICT_ADD_INT(GL_RENDERBUFFER_WIDTH);
+ PY_DICT_ADD_INT(GL_RG);
+ PY_DICT_ADD_INT(GL_RG16);
+ PY_DICT_ADD_INT(GL_RG16F);
+ PY_DICT_ADD_INT(GL_RG16I);
+ PY_DICT_ADD_INT(GL_RG16UI);
+ PY_DICT_ADD_INT(GL_RG32F);
+ PY_DICT_ADD_INT(GL_RG32I);
+ PY_DICT_ADD_INT(GL_RG32UI);
+ PY_DICT_ADD_INT(GL_RG8);
+ PY_DICT_ADD_INT(GL_RG8I);
+ PY_DICT_ADD_INT(GL_RG8UI);
+ PY_DICT_ADD_INT(GL_RGB16F);
+ PY_DICT_ADD_INT(GL_RGB16I);
+ PY_DICT_ADD_INT(GL_RGB16UI);
+ PY_DICT_ADD_INT(GL_RGB32F);
+ PY_DICT_ADD_INT(GL_RGB32I);
+ PY_DICT_ADD_INT(GL_RGB32UI);
+ PY_DICT_ADD_INT(GL_RGB8I);
+ PY_DICT_ADD_INT(GL_RGB8UI);
+ PY_DICT_ADD_INT(GL_RGB9_E5);
+ PY_DICT_ADD_INT(GL_RGBA16F);
+ PY_DICT_ADD_INT(GL_RGBA16I);
+ PY_DICT_ADD_INT(GL_RGBA16UI);
+ PY_DICT_ADD_INT(GL_RGBA32F);
+ PY_DICT_ADD_INT(GL_RGBA32I);
+ PY_DICT_ADD_INT(GL_RGBA32UI);
+ PY_DICT_ADD_INT(GL_RGBA8I);
+ PY_DICT_ADD_INT(GL_RGBA8UI);
+ PY_DICT_ADD_INT(GL_RGBA_INTEGER);
+ PY_DICT_ADD_INT(GL_RGB_INTEGER);
+ PY_DICT_ADD_INT(GL_RG_INTEGER);
+ PY_DICT_ADD_INT(GL_SAMPLER_1D_ARRAY);
+ PY_DICT_ADD_INT(GL_SAMPLER_1D_ARRAY_SHADOW);
+ PY_DICT_ADD_INT(GL_SAMPLER_2D_ARRAY);
+ PY_DICT_ADD_INT(GL_SAMPLER_2D_ARRAY_SHADOW);
+ PY_DICT_ADD_INT(GL_SAMPLER_CUBE_SHADOW);
+ PY_DICT_ADD_INT(GL_SEPARATE_ATTRIBS);
+ PY_DICT_ADD_INT(GL_STENCIL_ATTACHMENT);
+ PY_DICT_ADD_INT(GL_STENCIL_INDEX1);
+ PY_DICT_ADD_INT(GL_STENCIL_INDEX16);
+ PY_DICT_ADD_INT(GL_STENCIL_INDEX4);
+ PY_DICT_ADD_INT(GL_STENCIL_INDEX8);
+ PY_DICT_ADD_INT(GL_TEXTURE_1D_ARRAY);
+ PY_DICT_ADD_INT(GL_TEXTURE_2D_ARRAY);
+ PY_DICT_ADD_INT(GL_TEXTURE_ALPHA_TYPE);
+ PY_DICT_ADD_INT(GL_TEXTURE_BINDING_1D_ARRAY);
+ PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D_ARRAY);
+ PY_DICT_ADD_INT(GL_TEXTURE_BLUE_TYPE);
+ PY_DICT_ADD_INT(GL_TEXTURE_DEPTH_TYPE);
+ PY_DICT_ADD_INT(GL_TEXTURE_GREEN_TYPE);
+ PY_DICT_ADD_INT(GL_TEXTURE_RED_TYPE);
+ PY_DICT_ADD_INT(GL_TEXTURE_SHARED_SIZE);
+ PY_DICT_ADD_INT(GL_TEXTURE_STENCIL_SIZE);
+ PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER);
+ PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING);
+ PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_MODE);
+ PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_SIZE);
+ PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_BUFFER_START);
+ PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
+ PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_VARYINGS);
+ PY_DICT_ADD_INT(GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_10F_11F_11F_REV);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_24_8);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_5_9_9_9_REV);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_1D);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_3D);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_CUBE);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_VEC2);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_VEC3);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_VEC4);
+ PY_DICT_ADD_INT(GL_UNSIGNED_NORMALIZED);
+ PY_DICT_ADD_INT(GL_VERTEX_ARRAY_BINDING);
+ PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_INTEGER);
+}
+static void init_bgl_version_3_1_constants(PyObject *dict)
+{
/* GL_VERSION_3_1 */
- {
- PY_DICT_ADD_INT(GL_ACTIVE_UNIFORM_BLOCKS);
- PY_DICT_ADD_INT(GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH);
- PY_DICT_ADD_INT(GL_COPY_READ_BUFFER);
- PY_DICT_ADD_INT(GL_COPY_WRITE_BUFFER);
- PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_RECT);
- PY_DICT_ADD_INT(GL_INT_SAMPLER_BUFFER);
- PY_DICT_ADD_INT(GL_INVALID_INDEX);
- PY_DICT_ADD_INT(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS);
- PY_DICT_ADD_INT(GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS);
- PY_DICT_ADD_INT(GL_MAX_COMBINED_UNIFORM_BLOCKS);
- PY_DICT_ADD_INT(GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS);
- PY_DICT_ADD_INT(GL_MAX_FRAGMENT_UNIFORM_BLOCKS);
- PY_DICT_ADD_INT(GL_MAX_GEOMETRY_UNIFORM_BLOCKS);
- PY_DICT_ADD_INT(GL_MAX_RECTANGLE_TEXTURE_SIZE);
- PY_DICT_ADD_INT(GL_MAX_TEXTURE_BUFFER_SIZE);
- PY_DICT_ADD_INT(GL_MAX_UNIFORM_BLOCK_SIZE);
- PY_DICT_ADD_INT(GL_MAX_UNIFORM_BUFFER_BINDINGS);
- PY_DICT_ADD_INT(GL_MAX_VERTEX_UNIFORM_BLOCKS);
- PY_DICT_ADD_INT(GL_PRIMITIVE_RESTART);
- PY_DICT_ADD_INT(GL_PRIMITIVE_RESTART_INDEX);
- PY_DICT_ADD_INT(GL_PROXY_TEXTURE_RECTANGLE);
- PY_DICT_ADD_INT(GL_R16_SNORM);
- PY_DICT_ADD_INT(GL_R8_SNORM);
- PY_DICT_ADD_INT(GL_RG16_SNORM);
- PY_DICT_ADD_INT(GL_RG8_SNORM);
- PY_DICT_ADD_INT(GL_RGB16_SNORM);
- PY_DICT_ADD_INT(GL_RGB8_SNORM);
- PY_DICT_ADD_INT(GL_RGBA16_SNORM);
- PY_DICT_ADD_INT(GL_RGBA8_SNORM);
- PY_DICT_ADD_INT(GL_SAMPLER_2D_RECT);
- PY_DICT_ADD_INT(GL_SAMPLER_2D_RECT_SHADOW);
- PY_DICT_ADD_INT(GL_SAMPLER_BUFFER);
- PY_DICT_ADD_INT(GL_SIGNED_NORMALIZED);
- PY_DICT_ADD_INT(GL_TEXTURE_BINDING_BUFFER);
- PY_DICT_ADD_INT(GL_TEXTURE_BINDING_RECTANGLE);
- PY_DICT_ADD_INT(GL_TEXTURE_BUFFER);
- PY_DICT_ADD_INT(GL_TEXTURE_BUFFER_DATA_STORE_BINDING);
- PY_DICT_ADD_INT(GL_TEXTURE_RECTANGLE);
- PY_DICT_ADD_INT(GL_UNIFORM_ARRAY_STRIDE);
- PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS);
- PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES);
- PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_BINDING);
- PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_DATA_SIZE);
- PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_INDEX);
- PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_NAME_LENGTH);
- PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER);
- PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER);
- PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER);
- PY_DICT_ADD_INT(GL_UNIFORM_BUFFER);
- PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_BINDING);
- PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT);
- PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_SIZE);
- PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_START);
- PY_DICT_ADD_INT(GL_UNIFORM_IS_ROW_MAJOR);
- PY_DICT_ADD_INT(GL_UNIFORM_MATRIX_STRIDE);
- PY_DICT_ADD_INT(GL_UNIFORM_NAME_LENGTH);
- PY_DICT_ADD_INT(GL_UNIFORM_OFFSET);
- PY_DICT_ADD_INT(GL_UNIFORM_SIZE);
- PY_DICT_ADD_INT(GL_UNIFORM_TYPE);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_RECT);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_BUFFER);
- }
+ PY_DICT_ADD_INT(GL_ACTIVE_UNIFORM_BLOCKS);
+ PY_DICT_ADD_INT(GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH);
+ PY_DICT_ADD_INT(GL_COPY_READ_BUFFER);
+ PY_DICT_ADD_INT(GL_COPY_WRITE_BUFFER);
+ PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_RECT);
+ PY_DICT_ADD_INT(GL_INT_SAMPLER_BUFFER);
+ PY_DICT_ADD_INT(GL_INVALID_INDEX);
+ PY_DICT_ADD_INT(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MAX_COMBINED_UNIFORM_BLOCKS);
+ PY_DICT_ADD_INT(GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MAX_FRAGMENT_UNIFORM_BLOCKS);
+ PY_DICT_ADD_INT(GL_MAX_GEOMETRY_UNIFORM_BLOCKS);
+ PY_DICT_ADD_INT(GL_MAX_RECTANGLE_TEXTURE_SIZE);
+ PY_DICT_ADD_INT(GL_MAX_TEXTURE_BUFFER_SIZE);
+ PY_DICT_ADD_INT(GL_MAX_UNIFORM_BLOCK_SIZE);
+ PY_DICT_ADD_INT(GL_MAX_UNIFORM_BUFFER_BINDINGS);
+ PY_DICT_ADD_INT(GL_MAX_VERTEX_UNIFORM_BLOCKS);
+ PY_DICT_ADD_INT(GL_PRIMITIVE_RESTART);
+ PY_DICT_ADD_INT(GL_PRIMITIVE_RESTART_INDEX);
+ PY_DICT_ADD_INT(GL_PROXY_TEXTURE_RECTANGLE);
+ PY_DICT_ADD_INT(GL_R16_SNORM);
+ PY_DICT_ADD_INT(GL_R8_SNORM);
+ PY_DICT_ADD_INT(GL_RG16_SNORM);
+ PY_DICT_ADD_INT(GL_RG8_SNORM);
+ PY_DICT_ADD_INT(GL_RGB16_SNORM);
+ PY_DICT_ADD_INT(GL_RGB8_SNORM);
+ PY_DICT_ADD_INT(GL_RGBA16_SNORM);
+ PY_DICT_ADD_INT(GL_RGBA8_SNORM);
+ PY_DICT_ADD_INT(GL_SAMPLER_2D_RECT);
+ PY_DICT_ADD_INT(GL_SAMPLER_2D_RECT_SHADOW);
+ PY_DICT_ADD_INT(GL_SAMPLER_BUFFER);
+ PY_DICT_ADD_INT(GL_SIGNED_NORMALIZED);
+ PY_DICT_ADD_INT(GL_TEXTURE_BINDING_BUFFER);
+ PY_DICT_ADD_INT(GL_TEXTURE_BINDING_RECTANGLE);
+ PY_DICT_ADD_INT(GL_TEXTURE_BUFFER);
+ PY_DICT_ADD_INT(GL_TEXTURE_BUFFER_DATA_STORE_BINDING);
+ PY_DICT_ADD_INT(GL_TEXTURE_RECTANGLE);
+ PY_DICT_ADD_INT(GL_UNIFORM_ARRAY_STRIDE);
+ PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS);
+ PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES);
+ PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_BINDING);
+ PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_DATA_SIZE);
+ PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_INDEX);
+ PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_NAME_LENGTH);
+ PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER);
+ PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER);
+ PY_DICT_ADD_INT(GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER);
+ PY_DICT_ADD_INT(GL_UNIFORM_BUFFER);
+ PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_BINDING);
+ PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT);
+ PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_SIZE);
+ PY_DICT_ADD_INT(GL_UNIFORM_BUFFER_START);
+ PY_DICT_ADD_INT(GL_UNIFORM_IS_ROW_MAJOR);
+ PY_DICT_ADD_INT(GL_UNIFORM_MATRIX_STRIDE);
+ PY_DICT_ADD_INT(GL_UNIFORM_NAME_LENGTH);
+ PY_DICT_ADD_INT(GL_UNIFORM_OFFSET);
+ PY_DICT_ADD_INT(GL_UNIFORM_SIZE);
+ PY_DICT_ADD_INT(GL_UNIFORM_TYPE);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_RECT);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_BUFFER);
+}
+static void init_bgl_version_3_2_constants(PyObject *dict)
+/* GL_VERSION_3_2 */
+{
+ PY_DICT_ADD_INT(GL_ALREADY_SIGNALED);
+ PY_DICT_ADD_INT(GL_CONDITION_SATISFIED);
+ PY_DICT_ADD_INT(GL_CONTEXT_COMPATIBILITY_PROFILE_BIT);
+ PY_DICT_ADD_INT(GL_CONTEXT_CORE_PROFILE_BIT);
+ PY_DICT_ADD_INT(GL_CONTEXT_PROFILE_MASK);
+ PY_DICT_ADD_INT(GL_DEPTH_CLAMP);
+ PY_DICT_ADD_INT(GL_FIRST_VERTEX_CONVENTION);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_LAYERED);
+ PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS);
+ PY_DICT_ADD_INT(GL_GEOMETRY_INPUT_TYPE);
+ PY_DICT_ADD_INT(GL_GEOMETRY_OUTPUT_TYPE);
+ PY_DICT_ADD_INT(GL_GEOMETRY_SHADER);
+ PY_DICT_ADD_INT(GL_GEOMETRY_VERTICES_OUT);
+ PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_MULTISAMPLE);
+ PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY);
+ PY_DICT_ADD_INT(GL_LAST_VERTEX_CONVENTION);
+ PY_DICT_ADD_INT(GL_LINES_ADJACENCY);
+ PY_DICT_ADD_INT(GL_LINE_STRIP_ADJACENCY);
+ PY_DICT_ADD_INT(GL_MAX_COLOR_TEXTURE_SAMPLES);
+ PY_DICT_ADD_INT(GL_MAX_DEPTH_TEXTURE_SAMPLES);
+ PY_DICT_ADD_INT(GL_MAX_FRAGMENT_INPUT_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MAX_GEOMETRY_INPUT_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MAX_GEOMETRY_OUTPUT_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MAX_GEOMETRY_OUTPUT_VERTICES);
+ PY_DICT_ADD_INT(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS);
+ PY_DICT_ADD_INT(GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MAX_GEOMETRY_UNIFORM_COMPONENTS);
+ PY_DICT_ADD_INT(GL_MAX_INTEGER_SAMPLES);
+ PY_DICT_ADD_INT(GL_MAX_SAMPLE_MASK_WORDS);
+ PY_DICT_ADD_INT(GL_MAX_SERVER_WAIT_TIMEOUT);
+ PY_DICT_ADD_INT(GL_MAX_VERTEX_OUTPUT_COMPONENTS);
+ PY_DICT_ADD_INT(GL_OBJECT_TYPE);
+ PY_DICT_ADD_INT(GL_PROGRAM_POINT_SIZE);
+ PY_DICT_ADD_INT(GL_PROVOKING_VERTEX);
+ PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D_MULTISAMPLE);
+ PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY);
+ PY_DICT_ADD_INT(GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION);
+ PY_DICT_ADD_INT(GL_SAMPLER_2D_MULTISAMPLE);
+ PY_DICT_ADD_INT(GL_SAMPLER_2D_MULTISAMPLE_ARRAY);
+ PY_DICT_ADD_INT(GL_SAMPLE_MASK);
+ PY_DICT_ADD_INT(GL_SAMPLE_MASK_VALUE);
+ PY_DICT_ADD_INT(GL_SAMPLE_POSITION);
+ PY_DICT_ADD_INT(GL_SIGNALED);
+ PY_DICT_ADD_INT(GL_SYNC_CONDITION);
+ PY_DICT_ADD_INT(GL_SYNC_FENCE);
+ PY_DICT_ADD_INT(GL_SYNC_FLAGS);
+ PY_DICT_ADD_INT(GL_SYNC_FLUSH_COMMANDS_BIT);
+ PY_DICT_ADD_INT(GL_SYNC_GPU_COMMANDS_COMPLETE);
+ PY_DICT_ADD_INT(GL_SYNC_STATUS);
+ PY_DICT_ADD_INT(GL_TEXTURE_2D_MULTISAMPLE);
+ PY_DICT_ADD_INT(GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
+ PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D_MULTISAMPLE);
+ PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY);
+ PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_SEAMLESS);
+ PY_DICT_ADD_INT(GL_TEXTURE_FIXED_SAMPLE_LOCATIONS);
+ PY_DICT_ADD_INT(GL_TEXTURE_SAMPLES);
+ PY_DICT_ADD_INT(GL_TIMEOUT_EXPIRED);
+ PY_DICT_ADD_INT64(GL_TIMEOUT_IGNORED);
+ PY_DICT_ADD_INT(GL_TRIANGLES_ADJACENCY);
+ PY_DICT_ADD_INT(GL_TRIANGLE_STRIP_ADJACENCY);
+ PY_DICT_ADD_INT(GL_UNSIGNALED);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE);
+ PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY);
+ PY_DICT_ADD_INT(GL_WAIT_FAILED);
+}
+static void init_bgl_version_3_3_constants(PyObject *dict)
+{
+ /* GL_VERSION_3_3 */
+ PY_DICT_ADD_INT(GL_ANY_SAMPLES_PASSED);
+ PY_DICT_ADD_INT(GL_INT_2_10_10_10_REV);
+ PY_DICT_ADD_INT(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS);
+ PY_DICT_ADD_INT(GL_ONE_MINUS_SRC1_ALPHA);
+ PY_DICT_ADD_INT(GL_ONE_MINUS_SRC1_COLOR);
+ PY_DICT_ADD_INT(GL_RGB10_A2UI);
+ PY_DICT_ADD_INT(GL_SAMPLER_BINDING);
+ PY_DICT_ADD_INT(GL_SRC1_COLOR);
+ PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_A);
+ PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_B);
+ PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_G);
+ PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_R);
+ PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_RGBA);
+ PY_DICT_ADD_INT(GL_TIMESTAMP);
+ PY_DICT_ADD_INT(GL_TIME_ELAPSED);
+ PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR);
+}
- /* GL_VERSION_3_2 */
- {
- PY_DICT_ADD_INT(GL_ALREADY_SIGNALED);
- PY_DICT_ADD_INT(GL_CONDITION_SATISFIED);
- PY_DICT_ADD_INT(GL_CONTEXT_COMPATIBILITY_PROFILE_BIT);
- PY_DICT_ADD_INT(GL_CONTEXT_CORE_PROFILE_BIT);
- PY_DICT_ADD_INT(GL_CONTEXT_PROFILE_MASK);
- PY_DICT_ADD_INT(GL_DEPTH_CLAMP);
- PY_DICT_ADD_INT(GL_FIRST_VERTEX_CONVENTION);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_ATTACHMENT_LAYERED);
- PY_DICT_ADD_INT(GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS);
- PY_DICT_ADD_INT(GL_GEOMETRY_INPUT_TYPE);
- PY_DICT_ADD_INT(GL_GEOMETRY_OUTPUT_TYPE);
- PY_DICT_ADD_INT(GL_GEOMETRY_SHADER);
- PY_DICT_ADD_INT(GL_GEOMETRY_VERTICES_OUT);
- PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_MULTISAMPLE);
- PY_DICT_ADD_INT(GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY);
- PY_DICT_ADD_INT(GL_LAST_VERTEX_CONVENTION);
- PY_DICT_ADD_INT(GL_LINES_ADJACENCY);
- PY_DICT_ADD_INT(GL_LINE_STRIP_ADJACENCY);
- PY_DICT_ADD_INT(GL_MAX_COLOR_TEXTURE_SAMPLES);
- PY_DICT_ADD_INT(GL_MAX_DEPTH_TEXTURE_SAMPLES);
- PY_DICT_ADD_INT(GL_MAX_FRAGMENT_INPUT_COMPONENTS);
- PY_DICT_ADD_INT(GL_MAX_GEOMETRY_INPUT_COMPONENTS);
- PY_DICT_ADD_INT(GL_MAX_GEOMETRY_OUTPUT_COMPONENTS);
- PY_DICT_ADD_INT(GL_MAX_GEOMETRY_OUTPUT_VERTICES);
- PY_DICT_ADD_INT(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS);
- PY_DICT_ADD_INT(GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS);
- PY_DICT_ADD_INT(GL_MAX_GEOMETRY_UNIFORM_COMPONENTS);
- PY_DICT_ADD_INT(GL_MAX_INTEGER_SAMPLES);
- PY_DICT_ADD_INT(GL_MAX_SAMPLE_MASK_WORDS);
- PY_DICT_ADD_INT(GL_MAX_SERVER_WAIT_TIMEOUT);
- PY_DICT_ADD_INT(GL_MAX_VERTEX_OUTPUT_COMPONENTS);
- PY_DICT_ADD_INT(GL_OBJECT_TYPE);
- PY_DICT_ADD_INT(GL_PROGRAM_POINT_SIZE);
- PY_DICT_ADD_INT(GL_PROVOKING_VERTEX);
- PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D_MULTISAMPLE);
- PY_DICT_ADD_INT(GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY);
- PY_DICT_ADD_INT(GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION);
- PY_DICT_ADD_INT(GL_SAMPLER_2D_MULTISAMPLE);
- PY_DICT_ADD_INT(GL_SAMPLER_2D_MULTISAMPLE_ARRAY);
- PY_DICT_ADD_INT(GL_SAMPLE_MASK);
- PY_DICT_ADD_INT(GL_SAMPLE_MASK_VALUE);
- PY_DICT_ADD_INT(GL_SAMPLE_POSITION);
- PY_DICT_ADD_INT(GL_SIGNALED);
- PY_DICT_ADD_INT(GL_SYNC_CONDITION);
- PY_DICT_ADD_INT(GL_SYNC_FENCE);
- PY_DICT_ADD_INT(GL_SYNC_FLAGS);
- PY_DICT_ADD_INT(GL_SYNC_FLUSH_COMMANDS_BIT);
- PY_DICT_ADD_INT(GL_SYNC_GPU_COMMANDS_COMPLETE);
- PY_DICT_ADD_INT(GL_SYNC_STATUS);
- PY_DICT_ADD_INT(GL_TEXTURE_2D_MULTISAMPLE);
- PY_DICT_ADD_INT(GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
- PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D_MULTISAMPLE);
- PY_DICT_ADD_INT(GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY);
- PY_DICT_ADD_INT(GL_TEXTURE_CUBE_MAP_SEAMLESS);
- PY_DICT_ADD_INT(GL_TEXTURE_FIXED_SAMPLE_LOCATIONS);
- PY_DICT_ADD_INT(GL_TEXTURE_SAMPLES);
- PY_DICT_ADD_INT(GL_TIMEOUT_EXPIRED);
- PY_DICT_ADD_INT64(GL_TIMEOUT_IGNORED);
- PY_DICT_ADD_INT(GL_TRIANGLES_ADJACENCY);
- PY_DICT_ADD_INT(GL_TRIANGLE_STRIP_ADJACENCY);
- PY_DICT_ADD_INT(GL_UNSIGNALED);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE);
- PY_DICT_ADD_INT(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY);
- PY_DICT_ADD_INT(GL_WAIT_FAILED);
- }
+PyObject *BPyInit_bgl(void)
+{
+ PyObject *submodule, *dict;
+ submodule = PyModule_Create(&BGL_module_def);
+ dict = PyModule_GetDict(submodule);
- /* GL_VERSION_3_3 */
- {
- PY_DICT_ADD_INT(GL_ANY_SAMPLES_PASSED);
- PY_DICT_ADD_INT(GL_INT_2_10_10_10_REV);
- PY_DICT_ADD_INT(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS);
- PY_DICT_ADD_INT(GL_ONE_MINUS_SRC1_ALPHA);
- PY_DICT_ADD_INT(GL_ONE_MINUS_SRC1_COLOR);
- PY_DICT_ADD_INT(GL_RGB10_A2UI);
- PY_DICT_ADD_INT(GL_SAMPLER_BINDING);
- PY_DICT_ADD_INT(GL_SRC1_COLOR);
- PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_A);
- PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_B);
- PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_G);
- PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_R);
- PY_DICT_ADD_INT(GL_TEXTURE_SWIZZLE_RGBA);
- PY_DICT_ADD_INT(GL_TIMESTAMP);
- PY_DICT_ADD_INT(GL_TIME_ELAPSED);
- PY_DICT_ADD_INT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR);
+ if (PyType_Ready(&BGL_bufferType) < 0) {
+ return NULL; /* should never happen */
}
+ PyModule_AddObject(submodule, "Buffer", (PyObject *)&BGL_bufferType);
+ Py_INCREF((PyObject *)&BGL_bufferType);
+
+ init_bgl_version_1_0_methods(submodule, dict);
+ init_bgl_version_1_1_methods(submodule, dict);
+ init_bgl_version_1_2_methods(submodule, dict);
+ init_bgl_version_1_3_methods(submodule, dict);
+ init_bgl_version_1_4_methods(submodule, dict);
+ init_bgl_version_1_5_methods(submodule, dict);
+ init_bgl_version_2_0_methods(submodule, dict);
+ init_bgl_version_2_1_methods(submodule, dict);
+ init_bgl_version_3_0_methods(submodule, dict);
+ init_bgl_version_3_1_methods(submodule, dict);
+ init_bgl_version_3_2_methods(submodule, dict);
+ init_bgl_version_3_3_methods(submodule, dict);
+
+ init_bgl_version_1_1_constants(dict);
+ init_bgl_version_1_2_constants(dict);
+ init_bgl_version_1_3_constants(dict);
+ init_bgl_version_1_4_constants(dict);
+ init_bgl_version_1_5_constants(dict);
+ init_bgl_version_2_0_constants(dict);
+ init_bgl_version_2_1_constants(dict);
+ init_bgl_version_3_0_constants(dict);
+ init_bgl_version_3_1_constants(dict);
+ init_bgl_version_3_2_constants(dict);
+ init_bgl_version_3_3_constants(dict);
+
return submodule;
}
diff --git a/source/blender/python/generic/bgl.h b/source/blender/python/generic/bgl.h
index 8c81dc48340..ee8c293945a 100644
--- a/source/blender/python/generic/bgl.h
+++ b/source/blender/python/generic/bgl.h
@@ -18,8 +18,7 @@
* \ingroup pygen
*/
-#ifndef __BGL_H__
-#define __BGL_H__
+#pragma once
PyObject *BPyInit_bgl(void);
@@ -52,5 +51,3 @@ typedef struct _Buffer {
/** The type object */
extern PyTypeObject BGL_bufferType;
-
-#endif /* __BGL_H__ */
diff --git a/source/blender/python/generic/bl_math_py_api.h b/source/blender/python/generic/bl_math_py_api.h
index 9183573abfc..484304948f3 100644
--- a/source/blender/python/generic/bl_math_py_api.h
+++ b/source/blender/python/generic/bl_math_py_api.h
@@ -19,9 +19,6 @@
* \ingroup pygen
*/
-#ifndef __BL_MATH_PY_API_H__
-#define __BL_MATH_PY_API_H__
+#pragma once
PyMODINIT_FUNC BPyInit_bl_math(void);
-
-#endif /* __BL_MATH_PY_API_H__ */
diff --git a/source/blender/python/generic/blf_py_api.h b/source/blender/python/generic/blf_py_api.h
index 919272df942..c47edd1eaab 100644
--- a/source/blender/python/generic/blf_py_api.h
+++ b/source/blender/python/generic/blf_py_api.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLF_PY_API_H__
-#define __BLF_PY_API_H__
+#pragma once
/** \file
* \ingroup pygen
@@ -24,5 +23,3 @@
#include <Python.h>
PyObject *BPyInit_blf(void);
-
-#endif /* __BLF_PY_API_H__ */
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index cabeeba18b9..615ce514a3e 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -51,13 +51,12 @@ static PyObject *idprop_py_from_idp_string(const IDProperty *prop)
if (prop->subtype == IDP_STRING_SUB_BYTE) {
return PyBytes_FromStringAndSize(IDP_String(prop), prop->len);
}
- else {
+
#ifdef USE_STRING_COERCE
- return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len - 1);
+ return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len - 1);
#else
- return PyUnicode_FromStringAndSize(IDP_String(prop), prop->len - 1);
+ return PyUnicode_FromStringAndSize(IDP_String(prop), prop->len - 1);
#endif
- }
}
static PyObject *idprop_py_from_idp_int(const IDProperty *prop)
@@ -479,10 +478,10 @@ static IDProperty *idp_from_PySequence_Buffer(const char *name, Py_buffer *buffe
/* should never happen as the type has been checked before */
return NULL;
}
- else {
- val.array.type = id_type;
- val.array.len = buffer->len / buffer->itemsize;
- }
+
+ val.array.type = id_type;
+ val.array.len = buffer->len / buffer->itemsize;
+
prop = IDP_New(IDP_ARRAY, &val, name);
memcpy(IDP_Array(prop), buffer->buf, buffer->len);
return prop;
@@ -576,17 +575,15 @@ static IDProperty *idp_from_PySequence(const char *name, PyObject *ob)
PyBuffer_Release(&buffer);
return prop;
}
- else {
- PyObject *ob_seq_fast = PySequence_Fast(ob, "py -> idprop");
- if (ob_seq_fast != NULL) {
- IDProperty *prop = idp_from_PySequence_Fast(name, ob_seq_fast);
- Py_DECREF(ob_seq_fast);
- return prop;
- }
- else {
- return NULL;
- }
+
+ PyObject *ob_seq_fast = PySequence_Fast(ob, "py -> idprop");
+ if (ob_seq_fast != NULL) {
+ IDProperty *prop = idp_from_PySequence_Fast(name, ob_seq_fast);
+ Py_DECREF(ob_seq_fast);
+ return prop;
}
+
+ return NULL;
}
static IDProperty *idp_from_PyMapping(const char *name, PyObject *ob)
@@ -641,29 +638,28 @@ static IDProperty *idp_from_PyObject(PyObject *name_obj, PyObject *ob)
if (PyFloat_Check(ob)) {
return idp_from_PyFloat(name, ob);
}
- else if (PyLong_Check(ob)) {
+ if (PyLong_Check(ob)) {
return idp_from_PyLong(name, ob);
}
- else if (PyUnicode_Check(ob)) {
+ if (PyUnicode_Check(ob)) {
return idp_from_PyUnicode(name, ob);
}
- else if (PyBytes_Check(ob)) {
+ if (PyBytes_Check(ob)) {
return idp_from_PyBytes(name, ob);
}
- else if (PySequence_Check(ob)) {
+ if (PySequence_Check(ob)) {
return idp_from_PySequence(name, ob);
}
- else if (ob == Py_None || pyrna_id_CheckPyObject(ob)) {
+ if (ob == Py_None || pyrna_id_CheckPyObject(ob)) {
return idp_from_DatablockPointer(name, ob);
}
- else if (PyMapping_Check(ob)) {
+ if (PyMapping_Check(ob)) {
return idp_from_PyMapping(name, ob);
}
- else {
- PyErr_Format(
- PyExc_TypeError, "invalid id-property type %.200s not supported", Py_TYPE(ob)->tp_name);
- return NULL;
- }
+
+ PyErr_Format(
+ PyExc_TypeError, "invalid id-property type %.200s not supported", Py_TYPE(ob)->tp_name);
+ return NULL;
}
/** \} */
@@ -736,21 +732,19 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val)
IDP_FreeFromGroup(prop, pkey);
return 0;
}
- else {
- PyErr_SetString(PyExc_KeyError, "property not found in group");
- return -1;
- }
+
+ PyErr_SetString(PyExc_KeyError, "property not found in group");
+ return -1;
}
- else {
- bool ok;
- ok = BPy_IDProperty_Map_ValidateAndCreate(key, prop, val);
- if (ok == false) {
- return -1;
- }
+ bool ok;
- return 0;
+ ok = BPy_IDProperty_Map_ValidateAndCreate(key, prop, val);
+ if (ok == false) {
+ return -1;
}
+
+ return 0;
}
static int BPy_IDGroup_Map_SetItem(BPy_IDProperty *self, PyObject *key, PyObject *val)
@@ -1485,7 +1479,7 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray *self, PyObject *item)
}
return BPy_IDArray_GetItem(self, i);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0) {
@@ -1495,21 +1489,19 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray *self, PyObject *item)
if (slicelength <= 0) {
return PyTuple_New(0);
}
- else if (step == 1) {
+ if (step == 1) {
return BPy_IDArray_slice(self, start, stop);
}
- else {
- PyErr_SetString(PyExc_TypeError, "slice steps not supported with vectors");
- return NULL;
- }
- }
- else {
- PyErr_Format(PyExc_TypeError,
- "vector indices must be integers, not %.200s",
- __func__,
- Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_TypeError, "slice steps not supported with vectors");
return NULL;
}
+
+ PyErr_Format(PyExc_TypeError,
+ "vector indices must be integers, not %.200s",
+ __func__,
+ Py_TYPE(item)->tp_name);
+ return NULL;
}
static int BPy_IDArray_ass_subscript(BPy_IDArray *self, PyObject *item, PyObject *value)
@@ -1524,7 +1516,7 @@ static int BPy_IDArray_ass_subscript(BPy_IDArray *self, PyObject *item, PyObject
}
return BPy_IDArray_SetItem(self, i, value);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0) {
@@ -1534,16 +1526,14 @@ static int BPy_IDArray_ass_subscript(BPy_IDArray *self, PyObject *item, PyObject
if (step == 1) {
return BPy_IDArray_ass_slice(self, start, stop, value);
}
- else {
- PyErr_SetString(PyExc_TypeError, "slice steps not supported with vectors");
- return -1;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_TypeError, "slice steps not supported with vectors");
return -1;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return -1;
}
static PyMappingMethods BPy_IDArray_AsMapping = {
@@ -1709,14 +1699,12 @@ static PyObject *BPy_Group_Iter_Next(BPy_IDGroup_Iter *self)
BPy_IDGroup_WrapData(self->group->id, cur, self->group->prop));
return ret;
}
- else {
- return PyUnicode_FromString(cur->name);
- }
- }
- else {
- PyErr_SetNone(PyExc_StopIteration);
- return NULL;
+
+ return PyUnicode_FromString(cur->name);
}
+
+ PyErr_SetNone(PyExc_StopIteration);
+ return NULL;
}
PyTypeObject BPy_IDGroup_Iter_Type = {
diff --git a/source/blender/python/generic/idprop_py_api.h b/source/blender/python/generic/idprop_py_api.h
index 49094f95ecb..478dc99f73d 100644
--- a/source/blender/python/generic/idprop_py_api.h
+++ b/source/blender/python/generic/idprop_py_api.h
@@ -18,8 +18,7 @@
* \ingroup pygen
*/
-#ifndef __IDPROP_PY_API_H__
-#define __IDPROP_PY_API_H__
+#pragma once
struct BPy_IDGroup_Iter;
struct ID;
@@ -68,5 +67,3 @@ PyObject *BPyInit_idprop(void);
#define IDPROP_ITER_KEYS 0
#define IDPROP_ITER_ITEMS 1
-
-#endif /* __IDPROP_PY_API_H__ */
diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c
index 8a02638786d..3536236754e 100644
--- a/source/blender/python/generic/imbuf_py_api.c
+++ b/source/blender/python/generic/imbuf_py_api.c
@@ -57,11 +57,10 @@ static int py_imbuf_valid_check(Py_ImBuf *self)
if (LIKELY(self->ibuf)) {
return 0;
}
- else {
- PyErr_Format(
- PyExc_ReferenceError, "ImBuf data of type %.200s has been freed", Py_TYPE(self)->tp_name);
- return -1;
- }
+
+ PyErr_Format(
+ PyExc_ReferenceError, "ImBuf data of type %.200s has been freed", Py_TYPE(self)->tp_name);
+ return -1;
}
#define PY_IMBUF_CHECK_OBJ(obj) \
@@ -324,9 +323,8 @@ static PyObject *py_imbuf_repr(Py_ImBuf *self)
return PyUnicode_FromFormat(
"<imbuf: address=%p, filepath='%s', size=(%d, %d)>", ibuf, ibuf->name, ibuf->x, ibuf->y);
}
- else {
- return PyUnicode_FromString("<imbuf: address=0x0>");
- }
+
+ return PyUnicode_FromString("<imbuf: address=0x0>");
}
static Py_hash_t py_imbuf_hash(Py_ImBuf *self)
diff --git a/source/blender/python/generic/imbuf_py_api.h b/source/blender/python/generic/imbuf_py_api.h
index 2dea925a9f2..897423415b3 100644
--- a/source/blender/python/generic/imbuf_py_api.h
+++ b/source/blender/python/generic/imbuf_py_api.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __IMBUF_PY_API_H__
-#define __IMBUF_PY_API_H__
+#pragma once
/** \file
* \ingroup pygen
@@ -24,5 +23,3 @@
PyObject *BPyInit_imbuf(void);
extern PyTypeObject Py_ImBuf_Type;
-
-#endif /* __IMBUF_PY_API_H__ */
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 406dbdafe22..caae5c4e122 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -51,6 +51,10 @@
# include "BLI_math_base.h" /* isfinite() */
#endif
+/* -------------------------------------------------------------------- */
+/** \name Fast Python to C Array Conversion for Primitive Types
+ * \{ */
+
/* array utility function */
int PyC_AsArray_FAST(void *array,
PyObject *value_fast,
@@ -137,11 +141,12 @@ int PyC_AsArray(void *array,
return ret;
}
+/** \} */
+
/* -------------------------------------------------------------------- */
/** \name Typed Tuple Packing
*
* \note See #PyC_Tuple_Pack_* macros that take multiple arguments.
- *
* \{ */
/* array utility function */
@@ -192,6 +197,10 @@ PyObject *PyC_Tuple_PackArray_Bool(const bool *array, uint len)
/** \} */
+/* -------------------------------------------------------------------- */
+/** \name Tuple/List Filling
+ * \{ */
+
/**
* Caller needs to ensure tuple is uninitialized.
* Handy for filling a tuple with None for eg.
@@ -218,6 +227,12 @@ void PyC_List_Fill(PyObject *list, PyObject *value)
}
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Bool/Enum Argument Parsing
+ * \{ */
+
/**
* Use with PyArg_ParseTuple's "O&" formatting.
*
@@ -274,8 +289,16 @@ int PyC_CheckArgs_DeepCopy(PyObject *args)
return PyArg_ParseTuple(args, "|O!:__deepcopy__", &PyDict_Type, &dummy_pydict) != 0;
}
+/** \} */
+
#ifndef MATH_STANDALONE
+/* -------------------------------------------------------------------- */
+/** \name Simple Printing (for debugging)
+ *
+ * These are useful to run directly from a debugger to be able to inspect the state.
+ * \{ */
+
/* for debugging */
void PyC_ObSpit(const char *name, PyObject *var)
{
@@ -352,14 +375,33 @@ void PyC_StackSpit(void)
fprintf(stderr, "python line lookup failed, interpreter inactive\n");
return;
}
- else {
- /* lame but handy */
- PyGILState_STATE gilstate = PyGILState_Ensure();
- PyRun_SimpleString("__import__('traceback').print_stack()");
- PyGILState_Release(gilstate);
+
+ /* lame but handy */
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+ PyRun_SimpleString("__import__('traceback').print_stack()");
+ PyGILState_Release(gilstate);
+}
+
+void PyC_StackPrint(/* FILE */ void *fp)
+{
+ PyThreadState *tstate = PyGILState_GetThisThreadState();
+ if (tstate != NULL && tstate->frame != NULL) {
+ PyFrameObject *frame = tstate->frame;
+ do {
+ const int line = PyCode_Addr2Line(frame->f_code, frame->f_lasti);
+ const char *filename = _PyUnicode_AsString(frame->f_code->co_filename);
+ const char *funcname = _PyUnicode_AsString(frame->f_code->co_name);
+ fprintf(fp, " File \"%s\", line %d in %s\n", filename, line, funcname);
+ } while ((frame = frame->f_back));
}
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Access Current Frame File Name & Line Number
+ * \{ */
+
void PyC_FileAndNum(const char **r_filename, int *r_lineno)
{
PyFrameObject *frame;
@@ -419,6 +461,12 @@ void PyC_FileAndNum_Safe(const char **r_filename, int *r_lineno)
PyC_FileAndNum(r_filename, r_lineno);
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Object Access Utilities
+ * \{ */
+
/* Would be nice if python had this built in */
PyObject *PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...)
{
@@ -447,6 +495,12 @@ PyObject *PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...)
return item;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Frozen Set Creation
+ * \{ */
+
PyObject *PyC_FrozenSetFromStrings(const char **strings)
{
const char **str;
@@ -463,6 +517,12 @@ PyObject *PyC_FrozenSetFromStrings(const char **strings)
return ret;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Exception Utilities
+ * \{ */
+
/**
* Similar to #PyErr_Format(),
*
@@ -528,6 +588,12 @@ void PyC_Err_PrintWithFunc(PyObject *py_func)
_PyUnicode_AsString(((PyFunctionObject *)py_func)->func_name));
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Exception Buffer Access
+ * \{ */
+
/* returns the exception string as a new PyUnicode object, depends on external traceback module */
# if 0
@@ -673,6 +739,14 @@ PyObject *PyC_ExceptionBuffer_Simple(void)
return string_io_buf;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Unicode Conversion
+ *
+ * In some cases we need to coerce strings, avoid doing this inline.
+ * \{ */
+
/* string conversion, escape non-unicode chars, coerce must be set to NULL */
const char *PyC_UnicodeAsByteAndSize(PyObject *py_str, Py_ssize_t *size, PyObject **coerce)
{
@@ -685,22 +759,20 @@ const char *PyC_UnicodeAsByteAndSize(PyObject *py_str, Py_ssize_t *size, PyObjec
* chars since blender doesn't limit this */
return result;
}
- else {
- PyErr_Clear();
- if (PyBytes_Check(py_str)) {
- *size = PyBytes_GET_SIZE(py_str);
- return PyBytes_AS_STRING(py_str);
- }
- else if ((*coerce = PyUnicode_EncodeFSDefault(py_str))) {
- *size = PyBytes_GET_SIZE(*coerce);
- return PyBytes_AS_STRING(*coerce);
- }
- else {
- /* leave error raised from EncodeFS */
- return NULL;
- }
+ PyErr_Clear();
+
+ if (PyBytes_Check(py_str)) {
+ *size = PyBytes_GET_SIZE(py_str);
+ return PyBytes_AS_STRING(py_str);
+ }
+ if ((*coerce = PyUnicode_EncodeFSDefault(py_str))) {
+ *size = PyBytes_GET_SIZE(*coerce);
+ return PyBytes_AS_STRING(*coerce);
}
+
+ /* leave error raised from EncodeFS */
+ return NULL;
}
const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
@@ -714,20 +786,18 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
* chars since blender doesn't limit this. */
return result;
}
- else {
- PyErr_Clear();
- if (PyBytes_Check(py_str)) {
- return PyBytes_AS_STRING(py_str);
- }
- else if ((*coerce = PyUnicode_EncodeFSDefault(py_str))) {
- return PyBytes_AS_STRING(*coerce);
- }
- else {
- /* leave error raised from EncodeFS */
- return NULL;
- }
+ PyErr_Clear();
+
+ if (PyBytes_Check(py_str)) {
+ return PyBytes_AS_STRING(py_str);
}
+ if ((*coerce = PyUnicode_EncodeFSDefault(py_str))) {
+ return PyBytes_AS_STRING(*coerce);
+ }
+
+ /* leave error raised from EncodeFS */
+ return NULL;
}
PyObject *PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size)
@@ -738,12 +808,11 @@ PyObject *PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size)
* chars since blender doesn't limit this */
return result;
}
- else {
- PyErr_Clear();
- /* this means paths will always be accessible once converted, on all OS's */
- result = PyUnicode_DecodeFSDefaultAndSize(str, size);
- return result;
- }
+
+ PyErr_Clear();
+ /* this means paths will always be accessible once converted, on all OS's */
+ result = PyUnicode_DecodeFSDefaultAndSize(str, size);
+ return result;
}
PyObject *PyC_UnicodeFromByte(const char *str)
@@ -751,6 +820,12 @@ PyObject *PyC_UnicodeFromByte(const char *str)
return PyC_UnicodeFromByteAndSize(str, strlen(str));
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Name Space Creation/Manipulation
+ * \{ */
+
/*****************************************************************************
* Description: This function creates a new Python dictionary object.
* note: dict is owned by sys.modules["__main__"] module, reference is borrowed
@@ -816,6 +891,12 @@ void PyC_MainModule_Restore(PyObject *main_mod)
Py_XDECREF(main_mod);
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name #Py_SetPythonHome Wrapper
+ * \{ */
+
/**
* - Must be called before #Py_Initialize.
* - Expects output of `BKE_appdir_folder_id(BLENDER_PYTHON, NULL)`.
@@ -867,6 +948,12 @@ bool PyC_IsInterpreterActive(void)
return (PyThreadState_GetDict() != NULL);
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name #Py_SetPythonHome Wrapper
+ * \{ */
+
/* Would be nice if python had this built in
* See: https://wiki.blender.org/wiki/Tools/Debugging/PyFromC
*/
@@ -1043,15 +1130,22 @@ void *PyC_RNA_AsPointer(PyObject *value, const char *type_name)
return result;
}
- else {
- PyErr_Format(PyExc_TypeError,
- "expected '%.200s' type found '%.200s' instead",
- type_name,
- Py_TYPE(value)->tp_name);
- return NULL;
- }
+
+ PyErr_Format(PyExc_TypeError,
+ "expected '%.200s' type found '%.200s' instead",
+ type_name,
+ Py_TYPE(value)->tp_name);
+ return NULL;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Flag Set Utilities (#PyC_FlagSet)
+ *
+ * Convert to/from Python set of strings to an int flag.
+ * \{ */
+
PyObject *PyC_FlagSet_AsString(PyC_FlagSet *item)
{
PyObject *py_items = PyList_New(0);
@@ -1152,6 +1246,12 @@ PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag)
return ret;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Run String (Evaluate to Primitive Types)
+ * \{ */
+
/**
* \return success
*
@@ -1315,6 +1415,8 @@ bool PyC_RunString_AsString(const char *imports[],
return PyC_RunString_AsStringAndSize(imports, expr, filename, r_value, &value_size);
}
+/** \} */
+
#endif /* #ifndef MATH_STANDALONE */
/* -------------------------------------------------------------------- */
@@ -1402,6 +1504,12 @@ uint32_t PyC_Long_AsU32(PyObject *value)
* PyC_Long_AsU64
*/
+#ifdef __GNUC__
+# pragma warning(pop)
+#endif
+
+/** \} */
+
/* -------------------------------------------------------------------- */
/** \name Py_buffer Utils
*
@@ -1478,9 +1586,3 @@ bool PyC_StructFmt_type_is_bool(char format)
}
/** \} */
-
-#ifdef __GNUC__
-# pragma warning(pop)
-#endif
-
-/** \} */
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index e8b2e8ff502..dde450012d0 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -28,6 +28,7 @@ void PyC_ObSpit(const char *name, PyObject *var);
void PyC_ObSpitStr(char *result, size_t result_len, PyObject *var);
void PyC_LineSpit(void);
void PyC_StackSpit(void);
+void PyC_StackPrint(/* FILE */ void *fp);
PyObject *PyC_ExceptionBuffer(void);
PyObject *PyC_ExceptionBuffer_Simple(void);
PyObject *PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...);
diff --git a/source/blender/python/generic/python_utildefines.h b/source/blender/python/generic/python_utildefines.h
index 653122c9c33..1f093e633e4 100644
--- a/source/blender/python/generic/python_utildefines.h
+++ b/source/blender/python/generic/python_utildefines.h
@@ -20,8 +20,7 @@
* \note light addition to Python.h, use py_capi_utils.h for larger features.
*/
-#ifndef __PYTHON_UTILDEFINES_H__
-#define __PYTHON_UTILDEFINES_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -57,5 +56,3 @@ Py_LOCAL_INLINE(int) PyList_APPEND(PyObject *op, PyObject *v)
#ifdef __cplusplus
}
#endif
-
-#endif /* __PYTHON_UTILDEFINES_H__ */
diff --git a/source/blender/python/gpu/gpu_py_api.c b/source/blender/python/gpu/gpu_py_api.c
index 1379c0e557a..da7674eb7f9 100644
--- a/source/blender/python/gpu/gpu_py_api.c
+++ b/source/blender/python/gpu/gpu_py_api.c
@@ -43,9 +43,9 @@
/** \name Utils to invalidate functions
* \{ */
-bool bpygpu_is_initialized_or_error(void)
+bool bpygpu_is_init_or_error(void)
{
- if (!GPU_is_initialized()) {
+ if (!GPU_is_init()) {
PyErr_SetString(PyExc_SystemError,
"GPU functions for drawing are not available in background mode");
diff --git a/source/blender/python/gpu/gpu_py_api.h b/source/blender/python/gpu/gpu_py_api.h
index e278bb63a49..b8f0cde129f 100644
--- a/source/blender/python/gpu/gpu_py_api.h
+++ b/source/blender/python/gpu/gpu_py_api.h
@@ -18,23 +18,20 @@
* \ingroup bpygpu
*/
-#ifndef __GPU_PY_API_H__
-#define __GPU_PY_API_H__
+#pragma once
int bpygpu_ParsePrimType(PyObject *o, void *p);
PyObject *BPyInit_gpu(void);
-bool bpygpu_is_initialized_or_error(void);
+bool bpygpu_is_init_or_error(void);
#define BPYGPU_IS_INIT_OR_ERROR_OBJ \
- if (UNLIKELY(!bpygpu_is_initialized_or_error())) { \
+ if (UNLIKELY(!bpygpu_is_init_or_error())) { \
return NULL; \
} \
((void)0)
#define BPYGPU_IS_INIT_OR_ERROR_INT \
- if (UNLIKELY(!bpygpu_is_initialized_or_error())) { \
+ if (UNLIKELY(!bpygpu_is_init_or_error())) { \
return -1; \
} \
((void)0)
-
-#endif /* __GPU_PY_API_H__ */
diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c
index b3df991cf12..01bccc57c7a 100644
--- a/source/blender/python/gpu/gpu_py_batch.c
+++ b/source/blender/python/gpu/gpu_py_batch.c
@@ -184,8 +184,7 @@ static PyObject *bpygpu_Batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_sh
}
GPUShader *shader = py_shader->shader;
- GPU_batch_program_set(
- self->batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader));
+ GPU_batch_set_shader(self->batch, shader);
#ifdef USE_GPU_PY_REFERENCES
/* Remove existing user (if any), hold new user. */
@@ -223,15 +222,13 @@ static PyObject *bpygpu_Batch_draw(BPyGPUBatch *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|O!:GPUBatch.draw", &BPyGPUShader_Type, &py_program)) {
return NULL;
}
- else if (py_program == NULL) {
+ if (py_program == NULL) {
if (!bpygpu_batch_is_program_or_error(self)) {
return NULL;
}
}
else if (self->batch->program != GPU_shader_get_program(py_program->shader)) {
- GPU_batch_program_set(self->batch,
- GPU_shader_get_program(py_program->shader),
- GPU_shader_get_interface(py_program->shader));
+ GPU_batch_set_shader(self->batch, py_program->shader);
}
GPU_batch_draw(self->batch);
diff --git a/source/blender/python/gpu/gpu_py_batch.h b/source/blender/python/gpu/gpu_py_batch.h
index 1e916afcc2e..7c882eab8fc 100644
--- a/source/blender/python/gpu/gpu_py_batch.h
+++ b/source/blender/python/gpu/gpu_py_batch.h
@@ -18,8 +18,7 @@
* \ingroup bpygpu
*/
-#ifndef __GPU_PY_BATCH_H__
-#define __GPU_PY_BATCH_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -40,5 +39,3 @@ typedef struct BPyGPUBatch {
} BPyGPUBatch;
PyObject *BPyGPUBatch_CreatePyObject(struct GPUBatch *batch) ATTR_NONNULL(1);
-
-#endif /* __GPU_PY_BATCH_H__ */
diff --git a/source/blender/python/gpu/gpu_py_element.h b/source/blender/python/gpu/gpu_py_element.h
index 055c9d54ecf..a8e22aae15a 100644
--- a/source/blender/python/gpu/gpu_py_element.h
+++ b/source/blender/python/gpu/gpu_py_element.h
@@ -18,8 +18,7 @@
* \ingroup bpygpu
*/
-#ifndef __GPU_PY_ELEMENT_H__
-#define __GPU_PY_ELEMENT_H__
+#pragma once
extern PyTypeObject BPyGPUIndexBuf_Type;
@@ -30,5 +29,3 @@ typedef struct BPyGPUIndexBuf {
} BPyGPUIndexBuf;
PyObject *BPyGPUIndexBuf_CreatePyObject(struct GPUIndexBuf *elem);
-
-#endif /* __GPU_PY_ELEMENT_H__ */
diff --git a/source/blender/python/gpu/gpu_py_matrix.h b/source/blender/python/gpu/gpu_py_matrix.h
index cf187dee002..38a7f398b30 100644
--- a/source/blender/python/gpu/gpu_py_matrix.h
+++ b/source/blender/python/gpu/gpu_py_matrix.h
@@ -18,9 +18,6 @@
* \ingroup bpygpu
*/
-#ifndef __GPU_PY_MATRIX_H__
-#define __GPU_PY_MATRIX_H__
+#pragma once
PyObject *BPyInit_gpu_matrix(void);
-
-#endif /* __GPU_PY_MATRIX_H__ */
diff --git a/source/blender/python/gpu/gpu_py_offscreen.h b/source/blender/python/gpu/gpu_py_offscreen.h
index 61d7bd82abc..efe5b57b22e 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.h
+++ b/source/blender/python/gpu/gpu_py_offscreen.h
@@ -18,8 +18,7 @@
* \ingroup bpygpu
*/
-#ifndef __GPU_PY_OFFSCREEN_H__
-#define __GPU_PY_OFFSCREEN_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -33,5 +32,3 @@ typedef struct BPyGPUOffScreen {
} BPyGPUOffScreen;
PyObject *BPyGPUOffScreen_CreatePyObject(struct GPUOffScreen *ofs) ATTR_NONNULL(1);
-
-#endif /* __GPU_PY_OFFSCREEN_H__ */
diff --git a/source/blender/python/gpu/gpu_py_select.h b/source/blender/python/gpu/gpu_py_select.h
index 814b6028da1..857cd7bb7f8 100644
--- a/source/blender/python/gpu/gpu_py_select.h
+++ b/source/blender/python/gpu/gpu_py_select.h
@@ -18,9 +18,6 @@
* \ingroup bpygpu
*/
-#ifndef __GPU_PY_SELECT_H__
-#define __GPU_PY_SELECT_H__
+#pragma once
PyObject *BPyInit_gpu_select(void);
-
-#endif /* __GPU_PY_SELECT_H__ */
diff --git a/source/blender/python/gpu/gpu_py_shader.h b/source/blender/python/gpu/gpu_py_shader.h
index 92873753039..ee26c26acd4 100644
--- a/source/blender/python/gpu/gpu_py_shader.h
+++ b/source/blender/python/gpu/gpu_py_shader.h
@@ -18,8 +18,7 @@
* \ingroup bpygpu
*/
-#ifndef __GPU_PY_SHADER_H__
-#define __GPU_PY_SHADER_H__
+#pragma once
extern PyTypeObject BPyGPUShader_Type;
@@ -32,5 +31,3 @@ typedef struct BPyGPUShader {
PyObject *BPyGPUShader_CreatePyObject(struct GPUShader *shader, bool is_builtin);
PyObject *BPyInit_gpu_shader(void);
-
-#endif /* __GPU_PY_SHADER_H__ */
diff --git a/source/blender/python/gpu/gpu_py_types.h b/source/blender/python/gpu/gpu_py_types.h
index d8048225604..56f73b8a504 100644
--- a/source/blender/python/gpu/gpu_py_types.h
+++ b/source/blender/python/gpu/gpu_py_types.h
@@ -18,8 +18,7 @@
* \ingroup bpygpu
*/
-#ifndef __GPU_PY_TYPES_H__
-#define __GPU_PY_TYPES_H__
+#pragma once
#include "gpu_py_batch.h"
#include "gpu_py_element.h"
@@ -29,5 +28,3 @@
#include "gpu_py_vertex_format.h"
PyObject *BPyInit_gpu_types(void);
-
-#endif /* __GPU_PY_TYPES_H__ */
diff --git a/source/blender/python/gpu/gpu_py_vertex_buffer.h b/source/blender/python/gpu/gpu_py_vertex_buffer.h
index b7124d245a9..41791a35e6e 100644
--- a/source/blender/python/gpu/gpu_py_vertex_buffer.h
+++ b/source/blender/python/gpu/gpu_py_vertex_buffer.h
@@ -18,8 +18,7 @@
* \ingroup bpygpu
*/
-#ifndef __GPU_PY_VERTEX_BUFFER_H__
-#define __GPU_PY_VERTEX_BUFFER_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -34,5 +33,3 @@ typedef struct BPyGPUVertBuf {
} BPyGPUVertBuf;
PyObject *BPyGPUVertBuf_CreatePyObject(struct GPUVertBuf *vbo) ATTR_NONNULL(1);
-
-#endif /* __GPU_PY_VERTEX_BUFFER_H__ */
diff --git a/source/blender/python/gpu/gpu_py_vertex_format.h b/source/blender/python/gpu/gpu_py_vertex_format.h
index 8ef466aa918..54d090e2923 100644
--- a/source/blender/python/gpu/gpu_py_vertex_format.h
+++ b/source/blender/python/gpu/gpu_py_vertex_format.h
@@ -18,8 +18,7 @@
* \ingroup bpygpu
*/
-#ifndef __GPU_PY_VERTEX_FORMAT_H__
-#define __GPU_PY_VERTEX_FORMAT_H__
+#pragma once
#include "GPU_vertex_format.h"
@@ -32,5 +31,3 @@ typedef struct BPyGPUVertFormat {
} BPyGPUVertFormat;
PyObject *BPyGPUVertFormat_CreatePyObject(struct GPUVertFormat *fmt);
-
-#endif /* __GPU_PY_VERTEX_FORMAT_H__ */
diff --git a/source/blender/python/intern/bpy.h b/source/blender/python/intern/bpy.h
index 8f91c4e1208..744bf903443 100644
--- a/source/blender/python/intern/bpy.h
+++ b/source/blender/python/intern/bpy.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_H__
-#define __BPY_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -38,5 +37,3 @@ extern struct CLG_LogRef *BPY_LOG_RNA;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_H__ */
diff --git a/source/blender/python/intern/bpy_app.h b/source/blender/python/intern/bpy_app.h
index 880686f3536..0e5b6747543 100644
--- a/source/blender/python/intern/bpy_app.h
+++ b/source/blender/python/intern/bpy_app.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_H__
-#define __BPY_APP_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_H__ */
diff --git a/source/blender/python/intern/bpy_app_alembic.h b/source/blender/python/intern/bpy_app_alembic.h
index fcd93fb2b13..4288b556172 100644
--- a/source/blender/python/intern/bpy_app_alembic.h
+++ b/source/blender/python/intern/bpy_app_alembic.h
@@ -21,8 +21,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_ALEMBIC_H__
-#define __BPY_APP_ALEMBIC_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -33,5 +32,3 @@ PyObject *BPY_app_alembic_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_ALEMBIC_H__ */
diff --git a/source/blender/python/intern/bpy_app_build_options.h b/source/blender/python/intern/bpy_app_build_options.h
index a10f42d53be..390e3409fb8 100644
--- a/source/blender/python/intern/bpy_app_build_options.h
+++ b/source/blender/python/intern/bpy_app_build_options.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_BUILD_OPTIONS_H__
-#define __BPY_APP_BUILD_OPTIONS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_build_options_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_BUILD_OPTIONS_H__ */
diff --git a/source/blender/python/intern/bpy_app_ffmpeg.h b/source/blender/python/intern/bpy_app_ffmpeg.h
index 4809288662b..b189592e03e 100644
--- a/source/blender/python/intern/bpy_app_ffmpeg.h
+++ b/source/blender/python/intern/bpy_app_ffmpeg.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_FFMPEG_H__
-#define __BPY_APP_FFMPEG_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_ffmpeg_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_FFMPEG_H__ */
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index dde1d13477f..cdbd3bc0b9c 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -118,22 +118,20 @@ static PyObject *bpy_app_handlers_persistent_new(PyTypeObject *UNUSED(type),
"get the dictionary from the function passed");
return NULL;
}
- else {
- /* set id */
- if (*dict_ptr == NULL) {
- *dict_ptr = PyDict_New();
- }
- PyDict_SetItemString(*dict_ptr, PERMINENT_CB_ID, Py_None);
+ /* set id */
+ if (*dict_ptr == NULL) {
+ *dict_ptr = PyDict_New();
}
+ PyDict_SetItemString(*dict_ptr, PERMINENT_CB_ID, Py_None);
+
Py_INCREF(value);
return value;
}
- else {
- PyErr_SetString(PyExc_ValueError, "bpy.app.handlers.persistent expected a function");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError, "bpy.app.handlers.persistent expected a function");
+ return NULL;
}
/* dummy type because decorators can't be PyCFunctions */
diff --git a/source/blender/python/intern/bpy_app_handlers.h b/source/blender/python/intern/bpy_app_handlers.h
index 9c9dd75dd18..eb8e85fc96e 100644
--- a/source/blender/python/intern/bpy_app_handlers.h
+++ b/source/blender/python/intern/bpy_app_handlers.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_HANDLERS_H__
-#define __BPY_APP_HANDLERS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_handlers_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_HANDLERS_H__ */
diff --git a/source/blender/python/intern/bpy_app_icons.h b/source/blender/python/intern/bpy_app_icons.h
index 2904dc06136..b0dcbe4b0ea 100644
--- a/source/blender/python/intern/bpy_app_icons.h
+++ b/source/blender/python/intern/bpy_app_icons.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_ICONS_H__
-#define __BPY_APP_ICONS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_icons_module(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_ICONS_H__ */
diff --git a/source/blender/python/intern/bpy_app_ocio.h b/source/blender/python/intern/bpy_app_ocio.h
index 145cea1a9be..bc4529a962c 100644
--- a/source/blender/python/intern/bpy_app_ocio.h
+++ b/source/blender/python/intern/bpy_app_ocio.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_OCIO_H__
-#define __BPY_APP_OCIO_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_ocio_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_OCIO_H__ */
diff --git a/source/blender/python/intern/bpy_app_oiio.h b/source/blender/python/intern/bpy_app_oiio.h
index e106a9a055a..47092899eec 100644
--- a/source/blender/python/intern/bpy_app_oiio.h
+++ b/source/blender/python/intern/bpy_app_oiio.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_OIIO_H__
-#define __BPY_APP_OIIO_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_oiio_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_OIIO_H__ */
diff --git a/source/blender/python/intern/bpy_app_opensubdiv.h b/source/blender/python/intern/bpy_app_opensubdiv.h
index f659e58c071..e18c827e6d8 100644
--- a/source/blender/python/intern/bpy_app_opensubdiv.h
+++ b/source/blender/python/intern/bpy_app_opensubdiv.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_OPENSUBDIV_H__
-#define __BPY_APP_OPENSUBDIV_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_opensubdiv_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_OPENSUBDIV_H__ */
diff --git a/source/blender/python/intern/bpy_app_openvdb.h b/source/blender/python/intern/bpy_app_openvdb.h
index 60c2bbaa922..ab73d561412 100644
--- a/source/blender/python/intern/bpy_app_openvdb.h
+++ b/source/blender/python/intern/bpy_app_openvdb.h
@@ -21,8 +21,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_OPENVDB_H__
-#define __BPY_APP_OPENVDB_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -33,5 +32,3 @@ PyObject *BPY_app_openvdb_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_OPENVDB_H__ */
diff --git a/source/blender/python/intern/bpy_app_sdl.h b/source/blender/python/intern/bpy_app_sdl.h
index dd21ece89c7..b1d349c2a59 100644
--- a/source/blender/python/intern/bpy_app_sdl.h
+++ b/source/blender/python/intern/bpy_app_sdl.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_SDL_H__
-#define __BPY_APP_SDL_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_sdl_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_SDL_H__ */
diff --git a/source/blender/python/intern/bpy_app_timers.h b/source/blender/python/intern/bpy_app_timers.h
index 6da92eb8b31..9e62541c83a 100644
--- a/source/blender/python/intern/bpy_app_timers.h
+++ b/source/blender/python/intern/bpy_app_timers.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_TIMERS_H__
-#define __BPY_APP_TIMERS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_app_timers_module(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_TIMERS_H__ */
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c
index 190d4eb1855..c152c920453 100644
--- a/source/blender/python/intern/bpy_app_translations.c
+++ b/source/blender/python/intern/bpy_app_translations.c
@@ -566,7 +566,7 @@ static PyObject *_py_pgettext(PyObject *args,
PyDoc_STRVAR(
app_translations_pgettext_doc,
- ".. method:: pgettext(msgid, msgctxt)\n"
+ ".. method:: pgettext(msgid, msgctxt=None)\n"
"\n"
" Try to translate the given msgid (with optional msgctxt).\n"
"\n"
@@ -600,7 +600,7 @@ static PyObject *app_translations_pgettext(BlenderAppTranslations *UNUSED(self),
}
PyDoc_STRVAR(app_translations_pgettext_iface_doc,
- ".. method:: pgettext_iface(msgid, msgctxt)\n"
+ ".. method:: pgettext_iface(msgid, msgctxt=None)\n"
"\n"
" Try to translate the given msgid (with optional msgctxt), if labels' translation "
"is enabled.\n"
@@ -622,7 +622,7 @@ static PyObject *app_translations_pgettext_iface(BlenderAppTranslations *UNUSED(
}
PyDoc_STRVAR(app_translations_pgettext_tip_doc,
- ".. method:: pgettext_tip(msgid, msgctxt)\n"
+ ".. method:: pgettext_tip(msgid, msgctxt=None)\n"
"\n"
" Try to translate the given msgid (with optional msgctxt), if tooltips' "
"translation is enabled.\n"
@@ -644,7 +644,7 @@ static PyObject *app_translations_pgettext_tip(BlenderAppTranslations *UNUSED(se
}
PyDoc_STRVAR(app_translations_pgettext_data_doc,
- ".. method:: pgettext_data(msgid, msgctxt)\n"
+ ".. method:: pgettext_data(msgid, msgctxt=None)\n"
"\n"
" Try to translate the given msgid (with optional msgctxt), if new data name's "
"translation is enabled.\n"
diff --git a/source/blender/python/intern/bpy_app_translations.h b/source/blender/python/intern/bpy_app_translations.h
index 1e98c7d9aaa..090cab5917c 100644
--- a/source/blender/python/intern/bpy_app_translations.h
+++ b/source/blender/python/intern/bpy_app_translations.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_TRANSLATIONS_H__
-#define __BPY_APP_TRANSLATIONS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -31,5 +30,3 @@ void BPY_app_translations_end(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_TRANSLATIONS_H__ */
diff --git a/source/blender/python/intern/bpy_app_usd.h b/source/blender/python/intern/bpy_app_usd.h
index 0482b10974d..2801408c2aa 100644
--- a/source/blender/python/intern/bpy_app_usd.h
+++ b/source/blender/python/intern/bpy_app_usd.h
@@ -21,8 +21,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_APP_USD_H__
-#define __BPY_APP_USD_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -33,5 +32,3 @@ PyObject *BPY_app_usd_struct(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_APP_USD_H__ */
diff --git a/source/blender/python/intern/bpy_capi_utils.h b/source/blender/python/intern/bpy_capi_utils.h
index 11409397028..861b23190a2 100644
--- a/source/blender/python/intern/bpy_capi_utils.h
+++ b/source/blender/python/intern/bpy_capi_utils.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_CAPI_UTILS_H__
-#define __BPY_CAPI_UTILS_H__
+#pragma once
#if PY_VERSION_HEX < 0x03070000
# error "Python 3.7 or greater is required, you'll need to update your Python."
@@ -59,5 +58,3 @@ extern void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilsta
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_CAPI_UTILS_H__ */
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index d48ad2b197c..7fb4b0c469c 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -83,9 +83,8 @@ int bpy_pydriver_create_dict(void)
if (d == NULL) {
return -1;
}
- else {
- bpy_pydriver_Dict = d;
- }
+
+ bpy_pydriver_Dict = d;
/* import some modules: builtins, bpy, math, (Blender.noise)*/
PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins());
@@ -680,11 +679,8 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
if (isfinite(result)) {
return (float)result;
}
- else {
- fprintf(stderr,
- "\tBPY_driver_eval() - driver '%s' evaluates to '%f'\n",
- driver->expression,
- result);
- return 0.0f;
- }
+
+ fprintf(
+ stderr, "\tBPY_driver_eval() - driver '%s' evaluates to '%f'\n", driver->expression, result);
+ return 0.0f;
}
diff --git a/source/blender/python/intern/bpy_driver.h b/source/blender/python/intern/bpy_driver.h
index 84f3cbdbbb3..d5064d9fa56 100644
--- a/source/blender/python/intern/bpy_driver.h
+++ b/source/blender/python/intern/bpy_driver.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_DRIVER_H__
-#define __BPY_DRIVER_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -31,5 +30,3 @@ extern PyObject *bpy_pydriver_Dict;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_DRIVER_H__ */
diff --git a/source/blender/python/intern/bpy_gizmo_wrap.h b/source/blender/python/intern/bpy_gizmo_wrap.h
index 3a46dd5d78b..86b56ab2bd9 100644
--- a/source/blender/python/intern/bpy_gizmo_wrap.h
+++ b/source/blender/python/intern/bpy_gizmo_wrap.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_GIZMO_WRAP_H__
-#define __BPY_GIZMO_WRAP_H__
+#pragma once
struct wmGizmoGroupType;
struct wmGizmoType;
@@ -35,5 +34,3 @@ void BPY_RNA_gizmogroup_wrapper(struct wmGizmoGroupType *gzgt, void *userdata);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_GIZMO_WRAP_H__ */
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index f91afa414ce..c311041e4cb 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -438,6 +438,12 @@ static void python_script_error_jump_text(struct Text *text)
}
}
+void BPY_python_backtrace(/* FILE */ void *fp)
+{
+ fputs("\n# Python backtrace\n", fp);
+ PyC_StackPrint(fp);
+}
+
/* super annoying, undo _PyModule_Clear(), bug [#23871] */
#define PYMODULE_CLEAR_WORKAROUND
@@ -921,8 +927,11 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
/* TODO, reloading the module isn't functional at the moment. */
static void bpy_module_free(void *mod);
+
+/* Defined in 'creator.c' when building as a Python module. */
extern int main_python_enter(int argc, const char **argv);
extern void main_python_exit(void);
+
static struct PyModuleDef bpy_proxy_def = {
PyModuleDef_HEAD_INIT,
"bpy", /* m_name */
diff --git a/source/blender/python/intern/bpy_intern_string.h b/source/blender/python/intern/bpy_intern_string.h
index f87a43e6bf6..0c75b723fb8 100644
--- a/source/blender/python/intern/bpy_intern_string.h
+++ b/source/blender/python/intern/bpy_intern_string.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BPY_INTERN_STRING_H__
-#define __BPY_INTERN_STRING_H__
+#pragma once
/** \file
* \ingroup pythonintern
@@ -48,5 +47,3 @@ extern PyObject *bpy_intern_str_unregister;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_INTERN_STRING_H__ */
diff --git a/source/blender/python/intern/bpy_library.h b/source/blender/python/intern/bpy_library.h
index aca4ae94d6e..fbcf111e37d 100644
--- a/source/blender/python/intern/bpy_library.h
+++ b/source/blender/python/intern/bpy_library.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_LIBRARY_H__
-#define __BPY_LIBRARY_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -33,5 +32,3 @@ extern PyMethodDef BPY_library_write_method_def;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_LIBRARY_H__ */
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index 05cbc9af601..bcf13b1d88f 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -244,21 +244,20 @@ static PyObject *bpy_lib_enter(BPy_Library *self)
}
return NULL;
}
- else {
- int i = 0, code;
- while ((code = BKE_idtype_idcode_iter_step(&i))) {
- if (BKE_idtype_idcode_is_linkable(code)) {
- const char *name_plural = BKE_idtype_idcode_to_name_plural(code);
- PyObject *str = PyUnicode_FromString(name_plural);
- PyObject *item;
-
- PyDict_SetItem(self->dict, str, item = PyList_New(0));
- Py_DECREF(item);
- PyDict_SetItem(from_dict, str, item = _bpy_names(self, code));
- Py_DECREF(item);
-
- Py_DECREF(str);
- }
+
+ int i = 0, code;
+ while ((code = BKE_idtype_idcode_iter_step(&i))) {
+ if (BKE_idtype_idcode_is_linkable(code)) {
+ const char *name_plural = BKE_idtype_idcode_to_name_plural(code);
+ PyObject *str = PyUnicode_FromString(name_plural);
+ PyObject *item;
+
+ PyDict_SetItem(self->dict, str, item = PyList_New(0));
+ Py_DECREF(item);
+ PyDict_SetItem(from_dict, str, item = _bpy_names(self, code));
+ Py_DECREF(item);
+
+ Py_DECREF(str);
}
}
@@ -393,65 +392,64 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false);
return NULL;
}
- else {
- Library *lib = mainl->curlib; /* newly added lib, assign before append end */
- BLO_library_link_end(mainl, &(self->blo_handle), self->flag, NULL, NULL, NULL, NULL);
- BLO_blendhandle_close(self->blo_handle);
- self->blo_handle = NULL;
- GHash *old_to_new_ids = BLI_ghash_ptr_new(__func__);
+ Library *lib = mainl->curlib; /* newly added lib, assign before append end */
+ BLO_library_link_end(mainl, &(self->blo_handle), self->flag, NULL, NULL, NULL, NULL);
+ BLO_blendhandle_close(self->blo_handle);
+ self->blo_handle = NULL;
- /* copied from wm_operator.c */
- {
- /* mark all library linked objects to be updated */
- BKE_main_lib_objects_recalc_all(bmain);
+ GHash *old_to_new_ids = BLI_ghash_ptr_new(__func__);
- /* append, rather than linking */
- if (do_append) {
- BKE_library_make_local(bmain, lib, old_to_new_ids, true, false);
- }
+ /* copied from wm_operator.c */
+ {
+ /* mark all library linked objects to be updated */
+ BKE_main_lib_objects_recalc_all(bmain);
+
+ /* append, rather than linking */
+ if (do_append) {
+ BKE_library_make_local(bmain, lib, old_to_new_ids, true, false);
}
+ }
- BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false);
+ BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false);
- /* finally swap the capsules for real bpy objects
- * important since BLO_library_append_end initializes NodeTree types used by srna->refine */
+ /* finally swap the capsules for real bpy objects
+ * important since BLO_library_append_end initializes NodeTree types used by srna->refine */
#ifdef USE_RNA_DATABLOCKS
- {
- int idcode_step = 0, idcode;
- while ((idcode = BKE_idtype_idcode_iter_step(&idcode_step))) {
- if (BKE_idtype_idcode_is_linkable(idcode) && (idcode != ID_WS || do_append)) {
- const char *name_plural = BKE_idtype_idcode_to_name_plural(idcode);
- PyObject *ls = PyDict_GetItemString(self->dict, name_plural);
- if (ls && PyList_Check(ls)) {
- Py_ssize_t size = PyList_GET_SIZE(ls);
- Py_ssize_t i;
- PyObject *item;
-
- for (i = 0; i < size; i++) {
- item = PyList_GET_ITEM(ls, i);
- if (PyCapsule_CheckExact(item)) {
- PointerRNA id_ptr;
- ID *id;
-
- id = PyCapsule_GetPointer(item, NULL);
- id = BLI_ghash_lookup_default(old_to_new_ids, id, id);
- Py_DECREF(item);
-
- RNA_id_pointer_create(id, &id_ptr);
- item = pyrna_struct_CreatePyObject(&id_ptr);
- PyList_SET_ITEM(ls, i, item);
- }
+ {
+ int idcode_step = 0, idcode;
+ while ((idcode = BKE_idtype_idcode_iter_step(&idcode_step))) {
+ if (BKE_idtype_idcode_is_linkable(idcode) && (idcode != ID_WS || do_append)) {
+ const char *name_plural = BKE_idtype_idcode_to_name_plural(idcode);
+ PyObject *ls = PyDict_GetItemString(self->dict, name_plural);
+ if (ls && PyList_Check(ls)) {
+ Py_ssize_t size = PyList_GET_SIZE(ls);
+ Py_ssize_t i;
+ PyObject *item;
+
+ for (i = 0; i < size; i++) {
+ item = PyList_GET_ITEM(ls, i);
+ if (PyCapsule_CheckExact(item)) {
+ PointerRNA id_ptr;
+ ID *id;
+
+ id = PyCapsule_GetPointer(item, NULL);
+ id = BLI_ghash_lookup_default(old_to_new_ids, id, id);
+ Py_DECREF(item);
+
+ RNA_id_pointer_create(id, &id_ptr);
+ item = pyrna_struct_CreatePyObject(&id_ptr);
+ PyList_SET_ITEM(ls, i, item);
}
}
}
}
}
+ }
#endif /* USE_RNA_DATABLOCKS */
- BLI_ghash_free(old_to_new_ids, NULL, NULL);
- Py_RETURN_NONE;
- }
+ BLI_ghash_free(old_to_new_ids, NULL, NULL);
+ Py_RETURN_NONE;
}
static PyObject *bpy_lib_dir(BPy_Library *self)
diff --git a/source/blender/python/intern/bpy_msgbus.h b/source/blender/python/intern/bpy_msgbus.h
index 9a797218832..8d4846fd707 100644
--- a/source/blender/python/intern/bpy_msgbus.h
+++ b/source/blender/python/intern/bpy_msgbus.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_MSGBUS_H__
-#define __BPY_MSGBUS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_msgbus_module(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_MSGBUS_H__ */
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 4b2b5f129a7..274c1934e9e 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -227,7 +227,14 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
context_dict_back = CTX_py_dict_get(C);
- CTX_py_dict_set(C, (void *)context_dict);
+ /**
+ * It might be that there is already a Python context override. We don't want to remove that
+ * except when this operator call sets a new override explicitly. This is necessary so that
+ * called operator runs in the same context as the calling code by default.
+ */
+ if (context_dict != NULL) {
+ CTX_py_dict_set(C, (void *)context_dict);
+ }
Py_XINCREF(context_dict); /* so we done loose it */
if (WM_operator_poll_context((bContext *)C, ot, context) == false) {
diff --git a/source/blender/python/intern/bpy_operator.h b/source/blender/python/intern/bpy_operator.h
index 37a6acfe822..3cb335d5d9a 100644
--- a/source/blender/python/intern/bpy_operator.h
+++ b/source/blender/python/intern/bpy_operator.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_OPERATOR_H__
-#define __BPY_OPERATOR_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -38,5 +37,3 @@ PyObject *BPY_operator_module(void);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/python/intern/bpy_operator_wrap.h b/source/blender/python/intern/bpy_operator_wrap.h
index 942f9dbea39..9e496cd8d26 100644
--- a/source/blender/python/intern/bpy_operator_wrap.h
+++ b/source/blender/python/intern/bpy_operator_wrap.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_OPERATOR_WRAP_H__
-#define __BPY_OPERATOR_WRAP_H__
+#pragma once
struct wmOperatorType;
@@ -37,5 +36,3 @@ void BPY_RNA_operator_macro_wrapper(struct wmOperatorType *ot, void *userdata);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/python/intern/bpy_path.h b/source/blender/python/intern/bpy_path.h
index 0da9e610b53..3e25cb26288 100644
--- a/source/blender/python/intern/bpy_path.h
+++ b/source/blender/python/intern/bpy_path.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_PATH_H__
-#define __BPY_PATH_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPyInit__bpy_path(void);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index a1f9d4afc51..66c67ca061c 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -1408,9 +1408,8 @@ static bool py_long_as_int(PyObject *py_long, int *r_int)
*r_int = (int)PyLong_AS_LONG(py_long);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
#if 0
@@ -1716,16 +1715,15 @@ static int bpy_prop_callback_check(PyObject *py_func, const char *keyword, int a
Py_TYPE(py_func)->tp_name);
return -1;
}
- else {
- PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(py_func);
- if (f_code->co_argcount != argcount) {
- PyErr_Format(PyExc_TypeError,
- "%s keyword: expected a function taking %d arguments, not %d",
- keyword,
- argcount,
- f_code->co_argcount);
- return -1;
- }
+
+ PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(py_func);
+ if (f_code->co_argcount != argcount) {
+ PyErr_Format(PyExc_TypeError,
+ "%s keyword: expected a function taking %d arguments, not %d",
+ keyword,
+ argcount,
+ f_code->co_argcount);
+ return -1;
}
}
@@ -1981,7 +1979,7 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop,
Py_DECREF(args); \
return ret; \
} \
- else if (PyTuple_GET_SIZE(args) > 1) { \
+ if (PyTuple_GET_SIZE(args) > 1) { \
PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \
return NULL; \
} \
@@ -2961,7 +2959,7 @@ PyDoc_STRVAR(BPy_StringProperty_doc,
"default=\"\", "
"maxlen=0, "
"options={'ANIMATABLE'}, "
- "options=set(), "
+ "override=set(), "
"tags=set(), "
"subtype='NONE', "
"update=None, "
@@ -3537,7 +3535,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
Py_DECREF(args);
return ret;
}
- else if (PyTuple_GET_SIZE(args) > 1) {
+ if (PyTuple_GET_SIZE(args) > 1) {
PyErr_SetString(PyExc_ValueError, "expected one positional arg, one keyword arg");
return NULL;
}
@@ -3546,27 +3544,27 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
if (srna == NULL && PyErr_Occurred()) {
return NULL; /* self's type was compatible but error getting the srna */
}
- else if (srna == NULL) {
+ if (srna == NULL) {
PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type");
return NULL;
}
- else {
- const char *id = NULL;
- static const char *_keywords[] = {
- "attr",
- NULL,
- };
- static _PyArg_Parser _parser = {"s:RemoveProperty", _keywords, 0};
- if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &id)) {
- return NULL;
- }
+ const char *id = NULL;
- if (RNA_def_property_free_identifier(srna, id) != 1) {
- PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id);
- return NULL;
- }
+ static const char *_keywords[] = {
+ "attr",
+ NULL,
+ };
+ static _PyArg_Parser _parser = {"s:RemoveProperty", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &id)) {
+ return NULL;
+ }
+
+ if (RNA_def_property_free_identifier(srna, id) != 1) {
+ PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id);
+ return NULL;
}
+
Py_RETURN_NONE;
}
diff --git a/source/blender/python/intern/bpy_props.h b/source/blender/python/intern/bpy_props.h
index 9bcfe8e263a..3d7860dcdd8 100644
--- a/source/blender/python/intern/bpy_props.h
+++ b/source/blender/python/intern/bpy_props.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_PROPS_H__
-#define __BPY_PROPS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -36,5 +35,3 @@ StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 893832b61b6..955a24bc880 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -987,24 +987,23 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
PyErr_SetString(PyExc_RuntimeError, "could not use property type, internal error");
return NULL;
}
- else {
- /* This should never fail. */
- int len = -1;
- char *c = type_fmt;
- while ((*c++ = tolower(*type_id++))) {
- }
+ /* This should never fail. */
+ int len = -1;
+ char *c = type_fmt;
- if (type == PROP_COLLECTION) {
- len = pyrna_prop_collection_length(self);
- }
- else if (RNA_property_array_check(self->prop)) {
- len = pyrna_prop_array_length((BPy_PropertyArrayRNA *)self);
- }
+ while ((*c++ = tolower(*type_id++))) {
+ }
- if (len != -1) {
- sprintf(--c, "[%d]", len);
- }
+ if (type == PROP_COLLECTION) {
+ len = pyrna_prop_collection_length(self);
+ }
+ else if (RNA_property_array_check(self->prop)) {
+ len = pyrna_prop_array_length((BPy_PropertyArrayRNA *)self);
+ }
+
+ if (len != -1) {
+ sprintf(--c, "[%d]", len);
}
/* If a pointer, try to print name of pointer target too. */
@@ -1246,17 +1245,16 @@ static int pyrna_string_to_enum(
Py_TYPE(item)->tp_name);
return -1;
}
- else {
- if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, r_value)) {
- const char *enum_str = pyrna_enum_as_string(ptr, prop);
- PyErr_Format(PyExc_TypeError,
- "%.200s enum \"%.200s\" not found in (%s)",
- error_prefix,
- param,
- enum_str);
- MEM_freeN((void *)enum_str);
- return -1;
- }
+
+ if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, r_value)) {
+ const char *enum_str = pyrna_enum_as_string(ptr, prop);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s enum \"%.200s\" not found in (%s)",
+ error_prefix,
+ param,
+ enum_str);
+ MEM_freeN((void *)enum_str);
+ return -1;
}
return 0;
@@ -1715,14 +1713,14 @@ static int pyrna_py_to_prop(
Py_TYPE(value)->tp_name);
return -1;
}
+
+ if (data) {
+ *((bool *)data) = param;
+ }
else {
- if (data) {
- *((bool *)data) = param;
- }
- else {
- RNA_property_boolean_set(ptr, prop, param);
- }
+ RNA_property_boolean_set(ptr, prop, param);
}
+
break;
}
case PROP_INT: {
@@ -1737,7 +1735,7 @@ static int pyrna_py_to_prop(
RNA_property_identifier(prop));
return -1;
}
- else if (param == -1 && PyErr_Occurred()) {
+ if (param == -1 && PyErr_Occurred()) {
PyErr_Format(PyExc_TypeError,
"%.200s %.200s.%.200s expected an int type, not %.200s",
error_prefix,
@@ -1746,16 +1744,16 @@ static int pyrna_py_to_prop(
Py_TYPE(value)->tp_name);
return -1;
}
+
+ int param_i = (int)param;
+ if (data) {
+ RNA_property_int_clamp(ptr, prop, &param_i);
+ *((int *)data) = param_i;
+ }
else {
- int param_i = (int)param;
- if (data) {
- RNA_property_int_clamp(ptr, prop, &param_i);
- *((int *)data) = param_i;
- }
- else {
- RNA_property_int_set(ptr, prop, param_i);
- }
+ RNA_property_int_set(ptr, prop, param_i);
}
+
break;
}
case PROP_FLOAT: {
@@ -1769,15 +1767,15 @@ static int pyrna_py_to_prop(
Py_TYPE(value)->tp_name);
return -1;
}
+
+ if (data) {
+ RNA_property_float_clamp(ptr, prop, (float *)&param);
+ *((float *)data) = param;
+ }
else {
- if (data) {
- RNA_property_float_clamp(ptr, prop, (float *)&param);
- *((float *)data) = param;
- }
- else {
- RNA_property_float_set(ptr, prop, param);
- }
+ RNA_property_float_set(ptr, prop, param);
}
+
break;
}
case PROP_STRING: {
@@ -1835,19 +1833,18 @@ static int pyrna_py_to_prop(
return -1;
}
- else {
- if (data) {
- if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
- BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop));
- }
- else {
- *((char **)data) = (char *)param;
- }
+
+ if (data) {
+ if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
+ BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop));
}
else {
- RNA_property_string_set_bytes(ptr, prop, param, PyBytes_Size(value));
+ *((char **)data) = (char *)param;
}
}
+ else {
+ RNA_property_string_set_bytes(ptr, prop, param, PyBytes_Size(value));
+ }
}
else {
/* Unicode String. */
@@ -1886,22 +1883,22 @@ static int pyrna_py_to_prop(
return -1;
}
- else {
- /* Same as bytes. */
- /* XXX, this is suspect, but needed for function calls,
- * need to see if there's a better way. */
- if (data) {
- if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
- BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop));
- }
- else {
- *((char **)data) = (char *)param;
- }
+
+ /* Same as bytes. */
+ /* XXX, this is suspect, but needed for function calls,
+ * need to see if there's a better way. */
+ if (data) {
+ if (RNA_property_flag(prop) & PROP_THICK_WRAP) {
+ BLI_strncpy((char *)data, (char *)param, RNA_property_string_maxlength(prop));
}
else {
- RNA_property_string_set(ptr, prop, param);
+ *((char **)data) = (char *)param;
}
}
+ else {
+ RNA_property_string_set(ptr, prop, param);
+ }
+
#ifdef USE_STRING_COERCE
Py_XDECREF(value_coerce);
#endif /* USE_STRING_COERCE */
@@ -1971,7 +1968,7 @@ static int pyrna_py_to_prop(
PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
return pyrna_pydict_to_props(&opptr, value, false, error_prefix);
}
- else if (base_type == &RNA_GizmoProperties) {
+ if (base_type == &RNA_GizmoProperties) {
PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
return pyrna_pydict_to_props(&opptr, value, false, error_prefix);
}
@@ -2008,7 +2005,7 @@ static int pyrna_py_to_prop(
Py_XDECREF(value_new);
return -1;
}
- else if ((flag & PROP_NEVER_NULL) && value == Py_None) {
+ if ((flag & PROP_NEVER_NULL) && value == Py_None) {
PyErr_Format(PyExc_TypeError,
"%.200s %.200s.%.200s does not support a 'None' assignment %.200s type",
error_prefix,
@@ -2018,8 +2015,8 @@ static int pyrna_py_to_prop(
Py_XDECREF(value_new);
return -1;
}
- else if ((value != Py_None) && ((flag & PROP_ID_SELF_CHECK) &&
- ptr->owner_id == ((BPy_StructRNA *)value)->ptr.owner_id)) {
+ if ((value != Py_None) && ((flag & PROP_ID_SELF_CHECK) &&
+ ptr->owner_id == ((BPy_StructRNA *)value)->ptr.owner_id)) {
PyErr_Format(PyExc_TypeError,
"%.200s %.200s.%.200s ID type does not support assignment to itself",
error_prefix,
@@ -2028,85 +2025,84 @@ static int pyrna_py_to_prop(
Py_XDECREF(value_new);
return -1;
}
- else {
- BPy_StructRNA *param = (BPy_StructRNA *)value;
- bool raise_error = false;
- if (data) {
- if (flag_parameter & PARM_RNAPTR) {
- if (flag & PROP_THICK_WRAP) {
- if (value == Py_None) {
- memset(data, 0, sizeof(PointerRNA));
- }
- else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
- *((PointerRNA *)data) = param->ptr;
- }
- else {
- raise_error = true;
- }
+ BPy_StructRNA *param = (BPy_StructRNA *)value;
+ bool raise_error = false;
+ if (data) {
+
+ if (flag_parameter & PARM_RNAPTR) {
+ if (flag & PROP_THICK_WRAP) {
+ if (value == Py_None) {
+ memset(data, 0, sizeof(PointerRNA));
+ }
+ else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
+ *((PointerRNA *)data) = param->ptr;
}
else {
- /* For function calls, we sometimes want to pass the 'ptr' directly,
- * but watch out that it remains valid!
- * We could possibly support this later if needed. */
- BLI_assert(value_new == NULL);
- if (value == Py_None) {
- *((void **)data) = NULL;
- }
- else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
- *((PointerRNA **)data) = &param->ptr;
- }
- else {
- raise_error = true;
- }
+ raise_error = true;
}
}
- else if (value == Py_None) {
- *((void **)data) = NULL;
- }
- else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
- *((void **)data) = param->ptr.data;
- }
else {
- raise_error = true;
+ /* For function calls, we sometimes want to pass the 'ptr' directly,
+ * but watch out that it remains valid!
+ * We could possibly support this later if needed. */
+ BLI_assert(value_new == NULL);
+ if (value == Py_None) {
+ *((void **)data) = NULL;
+ }
+ else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
+ *((PointerRNA **)data) = &param->ptr;
+ }
+ else {
+ raise_error = true;
+ }
}
}
+ else if (value == Py_None) {
+ *((void **)data) = NULL;
+ }
+ else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
+ *((void **)data) = param->ptr.data;
+ }
else {
- /* Data == NULL, assign to RNA. */
- if (value == Py_None || RNA_struct_is_a(param->ptr.type, ptr_type)) {
- ReportList reports;
- BKE_reports_init(&reports, RPT_STORE);
- RNA_property_pointer_set(
- ptr, prop, value == Py_None ? PointerRNA_NULL : param->ptr, &reports);
- int err = (BPy_reports_to_error(&reports, PyExc_RuntimeError, true));
- if (err == -1) {
- Py_XDECREF(value_new);
- return -1;
- }
- }
- else {
- raise_error = true;
+ raise_error = true;
+ }
+ }
+ else {
+ /* Data == NULL, assign to RNA. */
+ if (value == Py_None || RNA_struct_is_a(param->ptr.type, ptr_type)) {
+ ReportList reports;
+ BKE_reports_init(&reports, RPT_STORE);
+ RNA_property_pointer_set(
+ ptr, prop, value == Py_None ? PointerRNA_NULL : param->ptr, &reports);
+ int err = (BPy_reports_to_error(&reports, PyExc_RuntimeError, true));
+ if (err == -1) {
+ Py_XDECREF(value_new);
+ return -1;
}
}
+ else {
+ raise_error = true;
+ }
+ }
- if (raise_error) {
- if (pyrna_struct_validity_check(param) == -1) {
- /* Error set. */
- }
- else {
- PointerRNA tmp;
- RNA_pointer_create(NULL, ptr_type, NULL, &tmp);
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
- error_prefix,
- RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop),
- RNA_struct_identifier(tmp.type),
- RNA_struct_identifier(param->ptr.type));
- }
- Py_XDECREF(value_new);
- return -1;
+ if (raise_error) {
+ if (pyrna_struct_validity_check(param) == -1) {
+ /* Error set. */
}
+ else {
+ PointerRNA tmp;
+ RNA_pointer_create(NULL, ptr_type, NULL, &tmp);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
+ error_prefix,
+ RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop),
+ RNA_struct_identifier(tmp.type),
+ RNA_struct_identifier(param->ptr.type));
+ }
+ Py_XDECREF(value_new);
+ return -1;
}
Py_XDECREF(value_new);
@@ -2295,9 +2291,8 @@ static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self)
if (RNA_property_array_dimension(&self->ptr, self->prop, NULL) > 1) {
return RNA_property_multi_array_length(&self->ptr, self->prop, self->arraydim);
}
- else {
- return RNA_property_array_length(&self->ptr, self->prop);
- }
+
+ return RNA_property_array_length(&self->ptr, self->prop);
}
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self)
@@ -2356,25 +2351,24 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s
if (RNA_property_collection_lookup_int(&self->ptr, self->prop, keynum_abs, &newptr)) {
return pyrna_struct_CreatePyObject(&newptr);
}
- else {
- const int len = RNA_property_collection_length(&self->ptr, self->prop);
- if (keynum_abs >= len) {
- PyErr_Format(PyExc_IndexError,
- "bpy_prop_collection[index]: "
- "index %d out of range, size %d",
- keynum,
- len);
- }
- else {
- PyErr_Format(PyExc_RuntimeError,
- "bpy_prop_collection[index]: internal error, "
- "valid index %d given in %d sized collection, but value not found",
- keynum_abs,
- len);
- }
- return NULL;
+ const int len = RNA_property_collection_length(&self->ptr, self->prop);
+ if (keynum_abs >= len) {
+ PyErr_Format(PyExc_IndexError,
+ "bpy_prop_collection[index]: "
+ "index %d out of range, size %d",
+ keynum,
+ len);
+ }
+ else {
+ PyErr_Format(PyExc_RuntimeError,
+ "bpy_prop_collection[index]: internal error, "
+ "valid index %d given in %d sized collection, but value not found",
+ keynum_abs,
+ len);
}
+
+ return NULL;
}
/* Values type must have been already checked. */
@@ -2473,79 +2467,76 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel
PyTuple_GET_SIZE(key));
return -1;
}
- else if (self->ptr.type != &RNA_BlendData) {
+ if (self->ptr.type != &RNA_BlendData) {
PyErr_Format(PyExc_KeyError,
"%s: is only valid for bpy.data collections, not %.200s",
err_prefix,
RNA_struct_identifier(self->ptr.type));
return -1;
}
- else if ((keyname = _PyUnicode_AsString(PyTuple_GET_ITEM(key, 0))) == NULL) {
+ if ((keyname = _PyUnicode_AsString(PyTuple_GET_ITEM(key, 0))) == NULL) {
PyErr_Format(PyExc_KeyError,
"%s: id must be a string, not %.200s",
err_prefix,
Py_TYPE(PyTuple_GET_ITEM(key, 0))->tp_name);
return -1;
}
- else {
- PyObject *keylib = PyTuple_GET_ITEM(key, 1);
- Library *lib;
- bool found = false;
-
- if (keylib == Py_None) {
- lib = NULL;
- }
- else if (PyUnicode_Check(keylib)) {
- Main *bmain = self->ptr.data;
- const char *keylib_str = _PyUnicode_AsString(keylib);
- lib = BLI_findstring(&bmain->libraries, keylib_str, offsetof(Library, filepath));
- if (lib == NULL) {
- if (err_not_found) {
- PyErr_Format(PyExc_KeyError,
- "%s: lib name '%.240s' "
- "does not reference a valid library",
- err_prefix,
- keylib_str);
- return -1;
- }
- else {
- return 0;
- }
+
+ PyObject *keylib = PyTuple_GET_ITEM(key, 1);
+ Library *lib;
+ bool found = false;
+
+ if (keylib == Py_None) {
+ lib = NULL;
+ }
+ else if (PyUnicode_Check(keylib)) {
+ Main *bmain = self->ptr.data;
+ const char *keylib_str = _PyUnicode_AsString(keylib);
+ lib = BLI_findstring(&bmain->libraries, keylib_str, offsetof(Library, filepath));
+ if (lib == NULL) {
+ if (err_not_found) {
+ PyErr_Format(PyExc_KeyError,
+ "%s: lib name '%.240s' "
+ "does not reference a valid library",
+ err_prefix,
+ keylib_str);
+ return -1;
}
+
+ return 0;
}
- else {
- PyErr_Format(PyExc_KeyError,
- "%s: lib must be a string or None, not %.200s",
- err_prefix,
- Py_TYPE(keylib)->tp_name);
- return -1;
- }
+ }
+ else {
+ PyErr_Format(PyExc_KeyError,
+ "%s: lib must be a string or None, not %.200s",
+ err_prefix,
+ Py_TYPE(keylib)->tp_name);
+ return -1;
+ }
- /* lib is either a valid pointer or NULL,
- * either way can do direct comparison with id.lib */
+ /* lib is either a valid pointer or NULL,
+ * either way can do direct comparison with id.lib */
- RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
- ID *id = itemptr.data; /* Always an ID. */
- if (id->lib == lib && (STREQLEN(keyname, id->name + 2, sizeof(id->name) - 2))) {
- found = true;
- if (r_ptr) {
- *r_ptr = itemptr;
- }
- break;
+ RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
+ ID *id = itemptr.data; /* Always an ID. */
+ if (id->lib == lib && (STREQLEN(keyname, id->name + 2, sizeof(id->name) - 2))) {
+ found = true;
+ if (r_ptr) {
+ *r_ptr = itemptr;
}
+ break;
}
- RNA_PROP_END;
+ }
+ RNA_PROP_END;
- /* We may want to fail silently as with collection.get(). */
- if ((found == false) && err_not_found) {
- /* Only runs for getitem access so use fixed string. */
- PyErr_SetString(PyExc_KeyError, "bpy_prop_collection[key, lib]: not found");
- return -1;
- }
- else {
- return found; /* 1 / 0, no exception. */
- }
+ /* We may want to fail silently as with collection.get(). */
+ if ((found == false) && err_not_found) {
+ /* Only runs for getitem access so use fixed string. */
+ PyErr_SetString(PyExc_KeyError, "bpy_prop_collection[key, lib]: not found");
+ return -1;
}
+
+ return found; /* 1 / 0, no exception. */
}
static PyObject *pyrna_prop_collection_subscript_str_lib_pair(BPy_PropertyRNA *self,
@@ -2560,9 +2551,8 @@ static PyObject *pyrna_prop_collection_subscript_str_lib_pair(BPy_PropertyRNA *s
if (contains == 1) {
return pyrna_struct_CreatePyObject(&ptr);
}
- else {
- return NULL;
- }
+
+ return NULL;
}
static PyObject *pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self,
@@ -2707,7 +2697,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
if (PyUnicode_Check(key)) {
return pyrna_prop_collection_subscript_str(self, _PyUnicode_AsString(key));
}
- else if (PyIndex_Check(key)) {
+ if (PyIndex_Check(key)) {
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
if (i == -1 && PyErr_Occurred()) {
return NULL;
@@ -2715,62 +2705,59 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
return pyrna_prop_collection_subscript_int(self, i);
}
- else if (PySlice_Check(key)) {
+ if (PySlice_Check(key)) {
PySliceObject *key_slice = (PySliceObject *)key;
Py_ssize_t step = 1;
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
return NULL;
}
- else if (step != 1) {
+ if (step != 1) {
PyErr_SetString(PyExc_TypeError, "bpy_prop_collection[slice]: slice steps not supported");
return NULL;
}
- else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
+ if (key_slice->start == Py_None && key_slice->stop == Py_None) {
return pyrna_prop_collection_subscript_slice(self, 0, PY_SSIZE_T_MAX);
}
- else {
- Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- /* Avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
- if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
- return NULL;
- }
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
- return NULL;
- }
+ Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- if (start < 0 || stop < 0) {
- /* Only get the length for negative values. */
- Py_ssize_t len = (Py_ssize_t)RNA_property_collection_length(&self->ptr, self->prop);
- if (start < 0) {
- start += len;
- }
- if (stop < 0) {
- stop += len;
- }
- }
+ /* Avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
+ if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
+ return NULL;
+ }
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
+ return NULL;
+ }
- if (stop - start <= 0) {
- return PyList_New(0);
+ if (start < 0 || stop < 0) {
+ /* Only get the length for negative values. */
+ Py_ssize_t len = (Py_ssize_t)RNA_property_collection_length(&self->ptr, self->prop);
+ if (start < 0) {
+ start += len;
}
- else {
- return pyrna_prop_collection_subscript_slice(self, start, stop);
+ if (stop < 0) {
+ stop += len;
}
}
+
+ if (stop - start <= 0) {
+ return PyList_New(0);
+ }
+
+ return pyrna_prop_collection_subscript_slice(self, start, stop);
}
- else if (PyTuple_Check(key)) {
+ if (PyTuple_Check(key)) {
/* Special case, for ID datablocks we. */
return pyrna_prop_collection_subscript_str_lib_pair(
self, key, "bpy_prop_collection[id, lib]", true);
}
- else {
- PyErr_Format(PyExc_TypeError,
- "bpy_prop_collection[key]: invalid key, "
- "must be a string or an int, not %.200s",
- Py_TYPE(key)->tp_name);
- return NULL;
- }
+
+ PyErr_Format(PyExc_TypeError,
+ "bpy_prop_collection[key]: invalid key, "
+ "must be a string or an int, not %.200s",
+ Py_TYPE(key)->tp_name);
+ return NULL;
}
/* generic check to see if a PyObject is compatible with a collection
@@ -2786,18 +2773,17 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
"this collection doesn't support None assignment");
return -1;
}
- else {
- return 0; /* None is OK. */
- }
+
+ return 0; /* None is OK. */
}
- else if (BPy_StructRNA_Check(value) == 0) {
+ if (BPy_StructRNA_Check(value) == 0) {
PyErr_Format(PyExc_TypeError,
"bpy_prop_collection[key] = value: invalid, "
"expected a StructRNA type or None, not a %.200s",
Py_TYPE(value)->tp_name);
return -1;
}
- else if ((prop_srna = RNA_property_pointer_type(&self->ptr, self->prop))) {
+ if ((prop_srna = RNA_property_pointer_type(&self->ptr, self->prop))) {
StructRNA *value_srna = ((BPy_StructRNA *)value)->ptr.type;
if (RNA_struct_is_a(value_srna, prop_srna) == 0) {
PyErr_Format(PyExc_TypeError,
@@ -2807,9 +2793,8 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
RNA_struct_identifier(value_srna));
return -1;
}
- else {
- return 0; /* OK, this is the correct type! */
- }
+
+ return 0; /* OK, this is the correct type! */
}
PyErr_Format(PyExc_TypeError,
@@ -2831,7 +2816,7 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self,
PyErr_SetString(PyExc_TypeError, "del bpy_prop_collection[key]: not supported");
return -1;
}
- else if (pyrna_prop_collection_type_check(self, value) == -1) {
+ if (pyrna_prop_collection_type_check(self, value) == -1) {
return -1; /* Exception is set. */
}
@@ -2895,13 +2880,12 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self,
}
}
#endif
- else {
- PyErr_Format(PyExc_TypeError,
- "bpy_prop_collection[key]: invalid key, "
- "must be a string or an int, not %.200s",
- Py_TYPE(key)->tp_name);
- return -1;
- }
+
+ PyErr_Format(PyExc_TypeError,
+ "bpy_prop_collection[key]: invalid key, "
+ "must be a string or an int, not %.200s",
+ Py_TYPE(key)->tp_name);
+ return -1;
}
static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject *key)
@@ -2921,43 +2905,40 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
}
return pyrna_prop_array_subscript_int(self, i);
}
- else if (PySlice_Check(key)) {
+ if (PySlice_Check(key)) {
Py_ssize_t step = 1;
PySliceObject *key_slice = (PySliceObject *)key;
if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) {
return NULL;
}
- else if (step != 1) {
+ if (step != 1) {
PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice]: slice steps not supported");
return NULL;
}
- else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
+ if (key_slice->start == Py_None && key_slice->stop == Py_None) {
/* Note: no significant advantage with optimizing [:] slice as with collections,
* but include here for consistency with collection slice func */
Py_ssize_t len = (Py_ssize_t)pyrna_prop_array_length(self);
return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, 0, len, len);
}
- else {
- int len = pyrna_prop_array_length(self);
- Py_ssize_t start, stop, slicelength;
- if (PySlice_GetIndicesEx(key, len, &start, &stop, &step, &slicelength) < 0) {
- return NULL;
- }
+ int len = pyrna_prop_array_length(self);
+ Py_ssize_t start, stop, slicelength;
- if (slicelength <= 0) {
- return PyTuple_New(0);
- }
- else {
- return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, start, stop, len);
- }
+ if (PySlice_GetIndicesEx(key, len, &start, &stop, &step, &slicelength) < 0) {
+ return NULL;
}
+
+ if (slicelength <= 0) {
+ return PyTuple_New(0);
+ }
+
+ return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, start, stop, len);
}
- else {
- PyErr_SetString(PyExc_AttributeError, "bpy_prop_array[key]: invalid key, key must be an int");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_AttributeError, "bpy_prop_array[key]: invalid key, key must be an int");
+ return NULL;
}
/**
@@ -2972,7 +2953,7 @@ static PyObject *prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, in
"element in assignment is not a sequence type"))) {
return NULL;
}
- else if (PySequence_Fast_GET_SIZE(value_fast) != length) {
+ if (PySequence_Fast_GET_SIZE(value_fast) != length) {
Py_DECREF(value_fast);
PyErr_SetString(PyExc_ValueError,
"bpy_prop_array[slice] = value: "
@@ -2980,9 +2961,8 @@ static PyObject *prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, in
return NULL;
}
- else {
- return value_fast;
- }
+
+ return value_fast;
}
static int prop_subscript_ass_array_slice__float_recursive(
@@ -3005,17 +2985,16 @@ static int prop_subscript_ass_array_slice__float_recursive(
}
return index;
}
- else {
- BLI_assert(totdim == 1);
- const float min = range[0], max = range[1];
- int i;
- for (i = 0; i != length; i++) {
- float v = PyFloat_AsDouble(value_items[i]);
- CLAMP(v, min, max);
- value[i] = v;
- }
- return i;
+
+ BLI_assert(totdim == 1);
+ const float min = range[0], max = range[1];
+ int i;
+ for (i = 0; i != length; i++) {
+ float v = PyFloat_AsDouble(value_items[i]);
+ CLAMP(v, min, max);
+ value[i] = v;
}
+ return i;
}
static int prop_subscript_ass_array_slice__int_recursive(
@@ -3038,17 +3017,16 @@ static int prop_subscript_ass_array_slice__int_recursive(
}
return index;
}
- else {
- BLI_assert(totdim == 1);
- const int min = range[0], max = range[1];
- int i;
- for (i = 0; i != length; i++) {
- int v = PyLong_AsLong(value_items[i]);
- CLAMP(v, min, max);
- value[i] = v;
- }
- return i;
+
+ BLI_assert(totdim == 1);
+ const int min = range[0], max = range[1];
+ int i;
+ for (i = 0; i != length; i++) {
+ int v = PyLong_AsLong(value_items[i]);
+ CLAMP(v, min, max);
+ value[i] = v;
}
+ return i;
}
static int prop_subscript_ass_array_slice__bool_recursive(PyObject **value_items,
@@ -3073,15 +3051,14 @@ static int prop_subscript_ass_array_slice__bool_recursive(PyObject **value_items
}
return index;
}
- else {
- BLI_assert(totdim == 1);
- int i;
- for (i = 0; i != length; i++) {
- int v = PyLong_AsLong(value_items[i]);
- value[i] = v;
- }
- return i;
+
+ BLI_assert(totdim == 1);
+ int i;
+ for (i = 0; i != length; i++) {
+ int v = PyLong_AsLong(value_items[i]);
+ value[i] = v;
}
+ return i;
}
/* Could call `pyrna_py_to_prop_array_index(self, i, value)` in a loop, but it is slow. */
@@ -3364,23 +3341,21 @@ static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key)
return pyrna_prop_collection_subscript_str_lib_pair_ptr(
self, key, "(id, lib) in bpy_prop_collection", false, NULL);
}
- else {
-
- /* Key in dict style check. */
- const char *keyname = _PyUnicode_AsString(key);
- if (keyname == NULL) {
- PyErr_SetString(PyExc_TypeError,
- "bpy_prop_collection.__contains__: expected a string or a tuple of strings");
- return -1;
- }
+ /* Key in dict style check. */
+ const char *keyname = _PyUnicode_AsString(key);
- if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr)) {
- return 1;
- }
+ if (keyname == NULL) {
+ PyErr_SetString(PyExc_TypeError,
+ "bpy_prop_collection.__contains__: expected a string or a tuple of strings");
+ return -1;
+ }
- return 0;
+ if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr)) {
+ return 1;
}
+
+ return 0;
}
static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value)
@@ -3821,30 +3796,25 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
path);
return NULL;
}
- else {
- return pyrna_array_index(&r_ptr, r_prop, index);
- }
+
+ return pyrna_array_index(&r_ptr, r_prop, index);
}
- else {
- if (coerce == Py_False) {
- return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
- }
- else {
- return pyrna_prop_to_py(&r_ptr, r_prop);
- }
+
+ if (coerce == Py_False) {
+ return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
}
+
+ return pyrna_prop_to_py(&r_ptr, r_prop);
}
- else {
- return pyrna_struct_CreatePyObject(&r_ptr);
- }
- }
- else {
- PyErr_Format(PyExc_ValueError,
- "%.200s.path_resolve(\"%.200s\") could not be resolved",
- RNA_struct_identifier(self->ptr.type),
- path);
- return NULL;
+
+ return pyrna_struct_CreatePyObject(&r_ptr);
}
+
+ PyErr_Format(PyExc_ValueError,
+ "%.200s.path_resolve(\"%.200s\") could not be resolved",
+ RNA_struct_identifier(self->ptr.type),
+ path);
+ return NULL;
}
PyDoc_STRVAR(pyrna_struct_path_from_id_doc,
@@ -3954,22 +3924,21 @@ static PyObject *pyrna_prop_as_bytes(BPy_PropertyRNA *self)
RNA_property_identifier(self->prop));
return NULL;
}
- else {
- PyObject *ret;
- char buf_fixed[256], *buf;
- int buf_len;
- buf = RNA_property_string_get_alloc(
- &self->ptr, self->prop, buf_fixed, sizeof(buf_fixed), &buf_len);
+ PyObject *ret;
+ char buf_fixed[256], *buf;
+ int buf_len;
- ret = PyBytes_FromStringAndSize(buf, buf_len);
+ buf = RNA_property_string_get_alloc(
+ &self->ptr, self->prop, buf_fixed, sizeof(buf_fixed), &buf_len);
- if (buf_fixed != buf) {
- MEM_freeN(buf);
- }
+ ret = PyBytes_FromStringAndSize(buf, buf_len);
- return ret;
+ if (buf_fixed != buf) {
+ MEM_freeN(buf);
}
+
+ return ret;
}
PyDoc_STRVAR(pyrna_prop_update_doc,
@@ -4478,7 +4447,7 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
PyErr_SetString(PyExc_AttributeError, "bpy_struct: __setattr__ must be a string");
return -1;
}
- else if (name[0] != '_' && (prop = RNA_struct_find_property(&self->ptr, name))) {
+ if (name[0] != '_' && (prop = RNA_struct_find_property(&self->ptr, name))) {
if (!RNA_property_editable_flag(&self->ptr, prop)) {
PyErr_Format(PyExc_AttributeError,
"bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only",
@@ -4497,22 +4466,21 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
name);
return -1;
}
- else {
- PointerRNA newptr;
- ListBase newlb;
- short newtype;
- int done = CTX_data_get(C, name, &newptr, &newlb, &newtype);
+ PointerRNA newptr;
+ ListBase newlb;
+ short newtype;
- if (done == 1) {
- PyErr_Format(
- PyExc_AttributeError, "bpy_struct: Context property \"%.200s\" is read-only", name);
- BLI_freelistN(&newlb);
- return -1;
- }
+ int done = CTX_data_get(C, name, &newptr, &newlb, &newtype);
+ if (done == 1) {
+ PyErr_Format(
+ PyExc_AttributeError, "bpy_struct: Context property \"%.200s\" is read-only", name);
BLI_freelistN(&newlb);
+ return -1;
}
+
+ BLI_freelistN(&newlb);
}
/* pyrna_py_to_prop sets its own exceptions */
@@ -4523,9 +4491,8 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
}
return pyrna_py_to_prop(&self->ptr, prop, NULL, value, "bpy_struct: item.attr = val:");
}
- else {
- return PyObject_GenericSetAttr((PyObject *)self, pyname, value);
- }
+
+ return PyObject_GenericSetAttr((PyObject *)self, pyname, value);
}
static PyObject *pyrna_prop_dir(BPy_PropertyRNA *self)
@@ -4563,7 +4530,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
PyErr_SetString(PyExc_AttributeError, "bpy_prop_collection: __getattr__ must be a string");
return NULL;
}
- else if (name[0] != '_') {
+ if (name[0] != '_') {
PyObject *ret;
PropertyRNA *prop;
FunctionRNA *func;
@@ -4575,7 +4542,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
return ret;
}
- else if ((func = RNA_struct_find_function(r_ptr.type, name))) {
+ if ((func = RNA_struct_find_function(r_ptr.type, name))) {
PyObject *self_collection = pyrna_struct_CreatePyObject(&r_ptr);
ret = pyrna_func_to_py(&((BPy_DummyPointerRNA *)self_collection)->ptr, func);
Py_DECREF(self_collection);
@@ -4639,11 +4606,11 @@ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pynam
PyErr_SetString(PyExc_AttributeError, "bpy_prop: __setattr__ must be a string");
return -1;
}
- else if (value == NULL) {
+ if (value == NULL) {
PyErr_SetString(PyExc_AttributeError, "bpy_prop: del not supported");
return -1;
}
- else if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
+ if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
if ((prop = RNA_struct_find_property(&r_ptr, name))) {
/* pyrna_py_to_prop sets its own exceptions. */
return pyrna_py_to_prop(&r_ptr, prop, NULL, value, "BPy_PropertyRNA - Attribute (setattr):");
@@ -4673,9 +4640,8 @@ static PyObject *pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self)
"bpy_prop_collection.add(): not supported for this collection");
return NULL;
}
- else {
- return pyrna_struct_CreatePyObject(&r_ptr);
- }
+
+ return pyrna_struct_CreatePyObject(&r_ptr);
}
static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyObject *value)
@@ -5798,7 +5764,7 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *
Py_INCREF(base);
return (PyObject *)base;
}
- else if (PyType_IsSubtype(Py_TYPE(base), &pyrna_struct_Type)) {
+ if (PyType_IsSubtype(Py_TYPE(base), &pyrna_struct_Type)) {
/* this almost never runs, only when using user defined subclasses of built-in object.
* this isn't common since it's NOT related to registerable subclasses. eg:
*
@@ -5826,10 +5792,9 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *
type->tp_name);
return NULL;
}
- else {
- PyErr_Format(PyExc_TypeError, "bpy_struct.__new__(type): expected a single argument");
- return NULL;
- }
+
+ PyErr_Format(PyExc_TypeError, "bpy_struct.__new__(type): expected a single argument");
+ return NULL;
}
/* only needed for subtyping, so a new class gets a valid BPy_StructRNA
@@ -5845,18 +5810,17 @@ static PyObject *pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *UN
if (type == Py_TYPE(base)) {
return Py_INCREF_RET((PyObject *)base);
}
- else if (PyType_IsSubtype(type, &pyrna_prop_Type)) {
+ if (PyType_IsSubtype(type, &pyrna_prop_Type)) {
BPy_PropertyRNA *ret = (BPy_PropertyRNA *)type->tp_alloc(type, 0);
ret->ptr = base->ptr;
ret->prop = base->prop;
return (PyObject *)ret;
}
- else {
- PyErr_Format(PyExc_TypeError,
- "bpy_prop.__new__(type): type '%.200s' is not a subtype of bpy_prop",
- type->tp_name);
- return NULL;
- }
+
+ PyErr_Format(PyExc_TypeError,
+ "bpy_prop.__new__(type): type '%.200s' is not a subtype of bpy_prop",
+ type->tp_name);
+ return NULL;
}
static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
@@ -6192,9 +6156,8 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
err = -1;
break;
}
- else { /* PyDict_GetItemString wont raise an error. */
- continue;
- }
+ /* PyDict_GetItemString wont raise an error. */
+ continue;
}
#ifdef DEBUG_STRING_FREE
@@ -7131,25 +7094,24 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
- else {
- BPy_StructRNA *pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&self->iter.ptr);
+
+ BPy_StructRNA *pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&self->iter.ptr);
# ifdef USE_PYRNA_STRUCT_REFERENCE
- if (pyrna) { /* Unlikely, but may fail. */
- if ((PyObject *)pyrna != Py_None) {
- /* hold a reference to the iterator since it may have
- * allocated memory 'pyrna' needs. eg: introspecting dynamic enum's */
- /* TODO, we could have an api call to know if this is
- * needed since most collections don't */
- pyrna_struct_reference_set(pyrna, (PyObject *)self);
- }
+ if (pyrna) { /* Unlikely, but may fail. */
+ if ((PyObject *)pyrna != Py_None) {
+ /* hold a reference to the iterator since it may have
+ * allocated memory 'pyrna' needs. eg: introspecting dynamic enum's */
+ /* TODO, we could have an api call to know if this is
+ * needed since most collections don't */
+ pyrna_struct_reference_set(pyrna, (PyObject *)self);
}
+ }
# endif /* !USE_PYRNA_STRUCT_REFERENCE */
- RNA_property_collection_next(&self->iter);
+ RNA_property_collection_next(&self->iter);
- return (PyObject *)pyrna;
- }
+ return (PyObject *)pyrna;
}
static void pyrna_prop_collection_iter_dealloc(BPy_PropertyCollectionIterRNA *self)
@@ -7413,9 +7375,8 @@ static StructRNA *srna_from_ptr(PointerRNA *ptr)
if (ptr->type == &RNA_Struct) {
return ptr->data;
}
- else {
- return ptr->type;
- }
+
+ return ptr->type;
}
/* Always returns a new ref, be sure to decref when done. */
@@ -7445,15 +7406,14 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
Py_INCREF(pyrna);
return (PyObject *)pyrna;
}
- else {
- /* Existing users will need to use 'type_recast' method. */
- Py_DECREF(pyrna);
- *instance = NULL;
- /* Continue as if no instance was made. */
+
+ /* Existing users will need to use 'type_recast' method. */
+ Py_DECREF(pyrna);
+ *instance = NULL;
+ /* Continue as if no instance was made. */
#if 0 /* No need to assign, will be written to next... */
pyrna = NULL;
#endif
- }
}
{
@@ -7560,9 +7520,8 @@ PyObject *pyrna_id_CreatePyObject(ID *id)
RNA_id_pointer_create(id, &ptr);
return pyrna_struct_CreatePyObject(&ptr);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
@@ -7571,10 +7530,9 @@ bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
*id = ((BPy_StructRNA *)obj)->ptr.owner_id;
return true;
}
- else {
- *id = NULL;
- return false;
- }
+
+ *id = NULL;
+ return false;
}
bool pyrna_id_CheckPyObject(PyObject *obj)
@@ -7869,30 +7827,29 @@ StructRNA *srna_from_self(PyObject *self, const char *error_prefix)
if (self == NULL) {
return NULL;
}
- else if (PyCapsule_CheckExact(self)) {
+ if (PyCapsule_CheckExact(self)) {
return PyCapsule_GetPointer(self, NULL);
}
- else if (PyType_Check(self) == 0) {
+ if (PyType_Check(self) == 0) {
return NULL;
}
- else {
- /* These cases above not errors, they just mean the type was not compatible
- * After this any errors will be raised in the script */
- PyObject *error_type, *error_value, *error_traceback;
- StructRNA *srna;
+ /* These cases above not errors, they just mean the type was not compatible
+ * After this any errors will be raised in the script */
- PyErr_Fetch(&error_type, &error_value, &error_traceback);
- PyErr_Clear();
+ PyObject *error_type, *error_value, *error_traceback;
+ StructRNA *srna;
- srna = pyrna_struct_as_srna(self, false, error_prefix);
+ PyErr_Fetch(&error_type, &error_value, &error_traceback);
+ PyErr_Clear();
- if (!PyErr_Occurred()) {
- PyErr_Restore(error_type, error_value, error_traceback);
- }
+ srna = pyrna_struct_as_srna(self, false, error_prefix);
- return srna;
+ if (!PyErr_Occurred()) {
+ PyErr_Restore(error_type, error_value, error_traceback);
}
+
+ return srna;
}
static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item)
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index fadda9a8002..a2c2171d151 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_RNA_H__
-#define __BPY_RNA_H__
+#pragma once
/* --- bpy build options --- */
#ifdef WITH_PYTHON_SAFETY
@@ -272,5 +271,3 @@ extern BPy_StructRNA *bpy_context_module;
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index 8aba2ae8598..ae19f89c348 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -181,24 +181,24 @@ static int pyrna_struct_anim_args_parse_no_resolve(PointerRNA *ptr,
*r_path_full = path;
return 0;
}
- else {
- char *path_prefix = RNA_path_from_ID_to_struct(ptr);
- if (path_prefix == NULL) {
- PyErr_Format(PyExc_TypeError,
- "%.200s could not make path for type %s",
- error_prefix,
- RNA_struct_identifier(ptr->type));
- return -1;
- }
- if (*path == '[') {
- *r_path_full = BLI_string_joinN(path_prefix, path);
- }
- else {
- *r_path_full = BLI_string_join_by_sep_charN('.', path_prefix, path);
- }
- MEM_freeN(path_prefix);
+ char *path_prefix = RNA_path_from_ID_to_struct(ptr);
+ if (path_prefix == NULL) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s could not make path for type %s",
+ error_prefix,
+ RNA_struct_identifier(ptr->type));
+ return -1;
+ }
+
+ if (*path == '[') {
+ *r_path_full = BLI_string_joinN(path_prefix, path);
}
+ else {
+ *r_path_full = BLI_string_join_by_sep_charN('.', path_prefix, path);
+ }
+ MEM_freeN(path_prefix);
+
return 0;
}
@@ -383,33 +383,32 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
return PyBool_FromLong(result);
}
- else {
- ID *id = self->ptr.owner_id;
- ReportList reports;
- bool result;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- BLI_assert(BKE_id_is_in_global_main(id));
- result = (insert_keyframe(G_MAIN,
- &reports,
- id,
- NULL,
- group_name,
- path_full,
- index,
- &anim_eval_context,
- keytype,
- NULL,
- options) != 0);
- MEM_freeN((void *)path_full);
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
- return NULL;
- }
-
- return PyBool_FromLong(result);
+ ID *id = self->ptr.owner_id;
+ ReportList reports;
+ bool result;
+
+ BKE_reports_init(&reports, RPT_STORE);
+
+ BLI_assert(BKE_id_is_in_global_main(id));
+ result = (insert_keyframe(G_MAIN,
+ &reports,
+ id,
+ NULL,
+ group_name,
+ path_full,
+ index,
+ &anim_eval_context,
+ keytype,
+ NULL,
+ options) != 0);
+ MEM_freeN((void *)path_full);
+
+ if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
+ return NULL;
}
+
+ return PyBool_FromLong(result);
}
char pyrna_struct_keyframe_delete_doc[] =
@@ -453,7 +452,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
NULL) == -1) {
return NULL;
}
- else if (self->ptr.type == &RNA_NlaStrip) {
+ if (self->ptr.type == &RNA_NlaStrip) {
/* Handle special properties for NLA Strips, whose F-Curves are stored on the
* strips themselves. These are stored separately or else the properties will
* not have any effect.
@@ -518,22 +517,21 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
return PyBool_FromLong(result);
}
- else {
- bool result;
- ReportList reports;
- BKE_reports_init(&reports, RPT_STORE);
+ bool result;
+ ReportList reports;
- result = (delete_keyframe(
- G.main, &reports, self->ptr.owner_id, NULL, path_full, index, cfra) != 0);
- MEM_freeN((void *)path_full);
+ BKE_reports_init(&reports, RPT_STORE);
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
- return NULL;
- }
+ result = (delete_keyframe(G.main, &reports, self->ptr.owner_id, NULL, path_full, index, cfra) !=
+ 0);
+ MEM_freeN((void *)path_full);
- return PyBool_FromLong(result);
+ if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
+ return NULL;
}
+
+ return PyBool_FromLong(result);
}
char pyrna_struct_driver_add_doc[] =
@@ -563,60 +561,59 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) == -1) {
return NULL;
}
- else {
- PyObject *ret = NULL;
- ReportList reports;
- int result;
- BKE_reports_init(&reports, RPT_STORE);
+ PyObject *ret = NULL;
+ ReportList reports;
+ int result;
- result = ANIM_add_driver(&reports,
- (ID *)self->ptr.owner_id,
- path_full,
- index,
- CREATEDRIVER_WITH_FMODIFIER,
- DRIVER_TYPE_PYTHON);
+ BKE_reports_init(&reports, RPT_STORE);
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
- return NULL;
- }
+ result = ANIM_add_driver(&reports,
+ (ID *)self->ptr.owner_id,
+ path_full,
+ index,
+ CREATEDRIVER_WITH_FMODIFIER,
+ DRIVER_TYPE_PYTHON);
- if (result) {
- ID *id = self->ptr.owner_id;
- AnimData *adt = BKE_animdata_from_id(id);
- FCurve *fcu;
+ if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
+ return NULL;
+ }
- PointerRNA tptr;
+ if (result) {
+ ID *id = self->ptr.owner_id;
+ AnimData *adt = BKE_animdata_from_id(id);
+ FCurve *fcu;
- if (index == -1) { /* all, use a list */
- int i = 0;
- ret = PyList_New(0);
- while ((fcu = BKE_fcurve_find(&adt->drivers, path_full, i++))) {
- RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
- PyList_APPEND(ret, pyrna_struct_CreatePyObject(&tptr));
- }
- }
- else {
- fcu = BKE_fcurve_find(&adt->drivers, path_full, index);
+ PointerRNA tptr;
+
+ if (index == -1) { /* all, use a list */
+ int i = 0;
+ ret = PyList_New(0);
+ while ((fcu = BKE_fcurve_find(&adt->drivers, path_full, i++))) {
RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
- ret = pyrna_struct_CreatePyObject(&tptr);
+ PyList_APPEND(ret, pyrna_struct_CreatePyObject(&tptr));
}
-
- bContext *context = BPy_GetContext();
- WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
- DEG_relations_tag_update(CTX_data_main(context));
}
else {
- /* XXX, should be handled by reports, */
- PyErr_SetString(PyExc_TypeError,
- "bpy_struct.driver_add(): failed because of an internal error");
- return NULL;
+ fcu = BKE_fcurve_find(&adt->drivers, path_full, index);
+ RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
+ ret = pyrna_struct_CreatePyObject(&tptr);
}
- MEM_freeN((void *)path_full);
-
- return ret;
+ bContext *context = BPy_GetContext();
+ WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
+ DEG_relations_tag_update(CTX_data_main(context));
}
+ else {
+ /* XXX, should be handled by reports, */
+ PyErr_SetString(PyExc_TypeError,
+ "bpy_struct.driver_add(): failed because of an internal error");
+ return NULL;
+ }
+
+ MEM_freeN((void *)path_full);
+
+ return ret;
}
char pyrna_struct_driver_remove_doc[] =
@@ -646,26 +643,25 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) == -1) {
return NULL;
}
- else {
- short result;
- ReportList reports;
- BKE_reports_init(&reports, RPT_STORE);
+ short result;
+ ReportList reports;
- result = ANIM_remove_driver(&reports, (ID *)self->ptr.owner_id, path_full, index, 0);
+ BKE_reports_init(&reports, RPT_STORE);
- if (path != path_full) {
- MEM_freeN((void *)path_full);
- }
+ result = ANIM_remove_driver(&reports, (ID *)self->ptr.owner_id, path_full, index, 0);
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
- return NULL;
- }
-
- bContext *context = BPy_GetContext();
- WM_event_add_notifier(context, NC_ANIMATION | ND_FCURVES_ORDER, NULL);
- DEG_relations_tag_update(CTX_data_main(context));
+ if (path != path_full) {
+ MEM_freeN((void *)path_full);
+ }
- return PyBool_FromLong(result);
+ if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
+ return NULL;
}
+
+ bContext *context = BPy_GetContext();
+ WM_event_add_notifier(context, NC_ANIMATION | ND_FCURVES_ORDER, NULL);
+ DEG_relations_tag_update(CTX_data_main(context));
+
+ return PyBool_FromLong(result);
}
diff --git a/source/blender/python/intern/bpy_rna_anim.h b/source/blender/python/intern/bpy_rna_anim.h
index 88537778dde..7c840e616b1 100644
--- a/source/blender/python/intern/bpy_rna_anim.h
+++ b/source/blender/python/intern/bpy_rna_anim.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BPY_RNA_ANIM_H__
-#define __BPY_RNA_ANIM_H__
+#pragma once
/** \file
* \ingroup pythonintern
@@ -38,5 +37,3 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_ANIM_H__ */
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index 1e5b53b819e..66e07d556a6 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -180,7 +180,7 @@ static int validate_array_type(PyObject *seq,
Py_TYPE(seq)->tp_name);
return -1;
}
- else if ((seq_size != dimsize[dim]) && (is_dynamic == false)) {
+ if ((seq_size != dimsize[dim]) && (is_dynamic == false)) {
PyErr_Format(PyExc_ValueError,
"%s sequences of dimension %d should contain %d items, not %d",
error_prefix,
@@ -201,7 +201,7 @@ static int validate_array_type(PyObject *seq,
i);
return -1;
}
- else if (!check_item_type(item)) {
+ if (!check_item_type(item)) {
Py_DECREF(item);
#if 0
@@ -279,7 +279,7 @@ static int validate_array_length(PyObject *rvalue,
RNA_property_identifier(prop));
return -1;
}
- else if ((RNA_property_flag(prop) & PROP_DYNAMIC) && lvalue_dim == 0) {
+ if ((RNA_property_flag(prop) & PROP_DYNAMIC) && lvalue_dim == 0) {
if (RNA_property_array_length(ptr, prop) != tot) {
#if 0
/* length is flexible */
@@ -382,7 +382,7 @@ static int validate_array(PyObject *rvalue,
RNA_property_identifier(prop));
return -1;
}
- else if (totdim != 2) {
+ if (totdim != 2) {
PyErr_Format(PyExc_ValueError,
"%s %.200s.%.200s, matrix assign array with %d dimensions",
error_prefix,
@@ -391,7 +391,7 @@ static int validate_array(PyObject *rvalue,
totdim);
return -1;
}
- else if (pymat->num_col != dimsize[0] || pymat->num_row != dimsize[1]) {
+ if (pymat->num_col != dimsize[0] || pymat->num_row != dimsize[1]) {
PyErr_Format(PyExc_ValueError,
"%s %.200s.%.200s, matrix assign dimension size mismatch, "
"is %dx%d, expected be %dx%d",
@@ -404,10 +404,9 @@ static int validate_array(PyObject *rvalue,
dimsize[1]);
return -1;
}
- else {
- *r_totitem = dimsize[0] * dimsize[1];
- return 0;
- }
+
+ *r_totitem = dimsize[0] * dimsize[1];
+ return 0;
}
}
#endif /* USE_MATHUTILS */
@@ -1017,31 +1016,31 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
PyErr_Clear();
return 0;
}
- else {
- float tmp[32];
- float *tmp_arr;
- if (len * sizeof(float) > sizeof(tmp)) {
- tmp_arr = PyMem_MALLOC(len * sizeof(float));
- }
- else {
- tmp_arr = tmp;
- }
+ float tmp[32];
+ float *tmp_arr;
- RNA_property_float_get_array(ptr, prop, tmp_arr);
+ if (len * sizeof(float) > sizeof(tmp)) {
+ tmp_arr = PyMem_MALLOC(len * sizeof(float));
+ }
+ else {
+ tmp_arr = tmp;
+ }
- for (i = 0; i < len; i++) {
- if (tmp_arr[i] == value_f) {
- break;
- }
- }
+ RNA_property_float_get_array(ptr, prop, tmp_arr);
- if (tmp_arr != tmp) {
- PyMem_FREE(tmp_arr);
+ for (i = 0; i < len; i++) {
+ if (tmp_arr[i] == value_f) {
+ break;
}
+ }
- return i < len ? 1 : 0;
+ if (tmp_arr != tmp) {
+ PyMem_FREE(tmp_arr);
}
+
+ return i < len ? 1 : 0;
+
break;
}
case PROP_INT: {
@@ -1050,31 +1049,31 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
PyErr_Clear();
return 0;
}
- else {
- int tmp[32];
- int *tmp_arr;
- if (len * sizeof(int) > sizeof(tmp)) {
- tmp_arr = PyMem_MALLOC(len * sizeof(int));
- }
- else {
- tmp_arr = tmp;
- }
+ int tmp[32];
+ int *tmp_arr;
- RNA_property_int_get_array(ptr, prop, tmp_arr);
+ if (len * sizeof(int) > sizeof(tmp)) {
+ tmp_arr = PyMem_MALLOC(len * sizeof(int));
+ }
+ else {
+ tmp_arr = tmp;
+ }
- for (i = 0; i < len; i++) {
- if (tmp_arr[i] == value_i) {
- break;
- }
- }
+ RNA_property_int_get_array(ptr, prop, tmp_arr);
- if (tmp_arr != tmp) {
- PyMem_FREE(tmp_arr);
+ for (i = 0; i < len; i++) {
+ if (tmp_arr[i] == value_i) {
+ break;
}
+ }
- return i < len ? 1 : 0;
+ if (tmp_arr != tmp) {
+ PyMem_FREE(tmp_arr);
}
+
+ return i < len ? 1 : 0;
+
break;
}
case PROP_BOOLEAN: {
@@ -1083,31 +1082,31 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
PyErr_Clear();
return 0;
}
- else {
- bool tmp[32];
- bool *tmp_arr;
- if (len * sizeof(bool) > sizeof(tmp)) {
- tmp_arr = PyMem_MALLOC(len * sizeof(bool));
- }
- else {
- tmp_arr = tmp;
- }
+ bool tmp[32];
+ bool *tmp_arr;
- RNA_property_boolean_get_array(ptr, prop, tmp_arr);
+ if (len * sizeof(bool) > sizeof(tmp)) {
+ tmp_arr = PyMem_MALLOC(len * sizeof(bool));
+ }
+ else {
+ tmp_arr = tmp;
+ }
- for (i = 0; i < len; i++) {
- if (tmp_arr[i] == value_i) {
- break;
- }
- }
+ RNA_property_boolean_get_array(ptr, prop, tmp_arr);
- if (tmp_arr != tmp) {
- PyMem_FREE(tmp_arr);
+ for (i = 0; i < len; i++) {
+ if (tmp_arr[i] == value_i) {
+ break;
}
+ }
- return i < len ? 1 : 0;
+ if (tmp_arr != tmp) {
+ PyMem_FREE(tmp_arr);
}
+
+ return i < len ? 1 : 0;
+
break;
}
}
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index f9bcb8943f4..976b8a65ac7 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -317,10 +317,10 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
error_prefix) == -1) {
return NULL;
}
- else if (params.region_type_str && pyrna_enum_value_from_id(rna_enum_region_type_items,
- params.region_type_str,
- &params.region_type,
- error_prefix) == -1) {
+ if (params.region_type_str && pyrna_enum_value_from_id(rna_enum_region_type_items,
+ params.region_type_str,
+ &params.region_type,
+ error_prefix) == -1) {
return NULL;
}
@@ -352,29 +352,26 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
region_draw_mode_items, params.event_str, &params.event, error_prefix) == -1) {
return NULL;
}
- else if (pyrna_enum_value_from_id(rna_enum_region_type_items,
- params.region_type_str,
- &params.region_type,
- error_prefix) == -1) {
+ if (pyrna_enum_value_from_id(rna_enum_region_type_items,
+ params.region_type_str,
+ &params.region_type,
+ error_prefix) == -1) {
return NULL;
}
- else {
- const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
- if (spaceid == SPACE_EMPTY) {
- PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
- return NULL;
- }
- else {
- SpaceType *st = BKE_spacetype_from_id(spaceid);
- ARegionType *art = BKE_regiontype_from_id(st, params.region_type);
- if (art == NULL) {
- PyErr_Format(
- PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
- return NULL;
- }
- handle = ED_region_draw_cb_activate(art, cb_region_draw, (void *)args, params.event);
- }
+
+ const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
+ if (spaceid == SPACE_EMPTY) {
+ PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
+ return NULL;
}
+
+ SpaceType *st = BKE_spacetype_from_id(spaceid);
+ ARegionType *art = BKE_regiontype_from_id(st, params.region_type);
+ if (art == NULL) {
+ PyErr_Format(PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
+ return NULL;
+ }
+ handle = ED_region_draw_cb_activate(art, cb_region_draw, (void *)args, params.event);
}
else {
PyErr_SetString(PyExc_TypeError, "callback_add(): type does not support callbacks");
@@ -448,24 +445,21 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
error_prefix) == -1) {
return NULL;
}
- else {
- const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
- if (spaceid == SPACE_EMPTY) {
- PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
- return NULL;
- }
- else {
- SpaceType *st = BKE_spacetype_from_id(spaceid);
- ARegionType *art = BKE_regiontype_from_id(st, params.region_type);
- if (art == NULL) {
- PyErr_Format(
- PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
- return NULL;
- }
- ED_region_draw_cb_exit(art, handle);
- capsule_clear = true;
- }
+
+ const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
+ if (spaceid == SPACE_EMPTY) {
+ PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
+ return NULL;
}
+
+ SpaceType *st = BKE_spacetype_from_id(spaceid);
+ ARegionType *art = BKE_regiontype_from_id(st, params.region_type);
+ if (art == NULL) {
+ PyErr_Format(PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
+ return NULL;
+ }
+ ED_region_draw_cb_exit(art, handle);
+ capsule_clear = true;
}
else {
PyErr_SetString(PyExc_TypeError, "callback_remove(): type does not support callbacks");
diff --git a/source/blender/python/intern/bpy_rna_callback.h b/source/blender/python/intern/bpy_rna_callback.h
index 67392b60995..ae42c4cb1a4 100644
--- a/source/blender/python/intern/bpy_rna_callback.h
+++ b/source/blender/python/intern/bpy_rna_callback.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BPY_RNA_CALLBACK_H__
-#define __BPY_RNA_CALLBACK_H__
+#pragma once
/** \file
* \ingroup pythonintern
@@ -39,5 +38,3 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *cls, PyObject *args);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_CALLBACK_H__ */
diff --git a/source/blender/python/intern/bpy_rna_driver.h b/source/blender/python/intern/bpy_rna_driver.h
index a534f770732..cc2c4550870 100644
--- a/source/blender/python/intern/bpy_rna_driver.h
+++ b/source/blender/python/intern/bpy_rna_driver.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BPY_RNA_DRIVER_H__
-#define __BPY_RNA_DRIVER_H__
+#pragma once
/** \file
* \ingroup pythonintern
@@ -38,5 +37,3 @@ bool pyrna_driver_is_equal_anim_rna(const struct PathResolvedRNA *anim_rna,
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_DRIVER_H__ */
diff --git a/source/blender/python/intern/bpy_rna_gizmo.c b/source/blender/python/intern/bpy_rna_gizmo.c
index aff81c68358..4ef718ef023 100644
--- a/source/blender/python/intern/bpy_rna_gizmo.c
+++ b/source/blender/python/intern/bpy_rna_gizmo.c
@@ -367,10 +367,10 @@ static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *ar
WM_gizmo_target_property_float_get_array(gz, gz_prop, value);
return PyC_Tuple_PackArray_F32(value, array_len);
}
- else {
- float value = WM_gizmo_target_property_float_get(gz, gz_prop);
- return PyFloat_FromDouble(value);
- }
+
+ float value = WM_gizmo_target_property_float_get(gz, gz_prop);
+ return PyFloat_FromDouble(value);
+
break;
}
default: {
diff --git a/source/blender/python/intern/bpy_rna_gizmo.h b/source/blender/python/intern/bpy_rna_gizmo.h
index b209dbf4a26..307b694338c 100644
--- a/source/blender/python/intern/bpy_rna_gizmo.h
+++ b/source/blender/python/intern/bpy_rna_gizmo.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_RNA_GIZMO_H__
-#define __BPY_RNA_GIZMO_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ int BPY_rna_gizmo_module(PyObject *);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_GIZMO_H__ */
diff --git a/source/blender/python/intern/bpy_rna_id_collection.h b/source/blender/python/intern/bpy_rna_id_collection.h
index 223ae126323..320a9e66ff8 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.h
+++ b/source/blender/python/intern/bpy_rna_id_collection.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_RNA_ID_COLLECTION_H__
-#define __BPY_RNA_ID_COLLECTION_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -32,5 +31,3 @@ extern PyMethodDef BPY_rna_id_collection_orphans_purge_method_def;
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_ID_COLLECTION_H__ */
diff --git a/source/blender/python/intern/bpy_rna_types_capi.h b/source/blender/python/intern/bpy_rna_types_capi.h
index 402dc2c7936..eb8dd14d888 100644
--- a/source/blender/python/intern/bpy_rna_types_capi.h
+++ b/source/blender/python/intern/bpy_rna_types_capi.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_RNA_TYPES_CAPI_H__
-#define __BPY_RNA_TYPES_CAPI_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ void BPY_rna_types_extend_capi(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_RNA_TYPES_CAPI_H__ */
diff --git a/source/blender/python/intern/bpy_traceback.h b/source/blender/python/intern/bpy_traceback.h
index cb23dd23c9b..26f6a574439 100644
--- a/source/blender/python/intern/bpy_traceback.h
+++ b/source/blender/python/intern/bpy_traceback.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_TRACEBACK_H__
-#define __BPY_TRACEBACK_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_TRACEBACK_H__ */
diff --git a/source/blender/python/intern/bpy_utils_previews.h b/source/blender/python/intern/bpy_utils_previews.h
index 23fd0216668..dbe74f619a9 100644
--- a/source/blender/python/intern/bpy_utils_previews.h
+++ b/source/blender/python/intern/bpy_utils_previews.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_UTILS_PREVIEWS_H__
-#define __BPY_UTILS_PREVIEWS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_utils_previews_module(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_UTILS_PREVIEWS_H__ */
diff --git a/source/blender/python/intern/bpy_utils_units.h b/source/blender/python/intern/bpy_utils_units.h
index add766d0d93..7a135bc6163 100644
--- a/source/blender/python/intern/bpy_utils_units.h
+++ b/source/blender/python/intern/bpy_utils_units.h
@@ -18,8 +18,7 @@
* \ingroup pythonintern
*/
-#ifndef __BPY_UTILS_UNITS_H__
-#define __BPY_UTILS_UNITS_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -30,5 +29,3 @@ PyObject *BPY_utils_units(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __BPY_UTILS_UNITS_H__ */
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 5764db4e70c..308d2ef9618 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -249,42 +249,41 @@ int mathutils_array_parse_alloc(float **array,
memcpy(*array, ((BaseMathObject *)value)->data, size * sizeof(float));
return size;
}
- else
-#endif
- {
- PyObject *value_fast = NULL;
- // *array = NULL;
- int ret;
- /* non list/tuple cases */
- if (!(value_fast = PySequence_Fast(value, error_prefix))) {
- /* PySequence_Fast sets the error */
- return -1;
- }
+#endif
- size = PySequence_Fast_GET_SIZE(value_fast);
+ PyObject *value_fast = NULL;
+ // *array = NULL;
+ int ret;
- if (size < array_min) {
- Py_DECREF(value_fast);
- PyErr_Format(PyExc_ValueError,
- "%.200s: sequence size is %d, expected > %d",
- error_prefix,
- size,
- array_min);
- return -1;
- }
+ /* non list/tuple cases */
+ if (!(value_fast = PySequence_Fast(value, error_prefix))) {
+ /* PySequence_Fast sets the error */
+ return -1;
+ }
- *array = PyMem_Malloc(size * sizeof(float));
+ size = PySequence_Fast_GET_SIZE(value_fast);
- ret = mathutils_array_parse_fast(*array, size, value_fast, error_prefix);
+ if (size < array_min) {
Py_DECREF(value_fast);
+ PyErr_Format(PyExc_ValueError,
+ "%.200s: sequence size is %d, expected > %d",
+ error_prefix,
+ size,
+ array_min);
+ return -1;
+ }
- if (ret == -1) {
- PyMem_Free(*array);
- }
+ *array = PyMem_Malloc(size * sizeof(float));
+
+ ret = mathutils_array_parse_fast(*array, size, value_fast, error_prefix);
+ Py_DECREF(value_fast);
- return ret;
+ if (ret == -1) {
+ PyMem_Free(*array);
}
+
+ return ret;
}
/* parse an array of vectors */
@@ -482,45 +481,41 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
}
- else {
- eulO_to_mat3(rmat, ((EulerObject *)value)->eul, ((EulerObject *)value)->order);
- return 0;
- }
+
+ eulO_to_mat3(rmat, ((EulerObject *)value)->eul, ((EulerObject *)value)->order);
+ return 0;
}
- else if (QuaternionObject_Check(value)) {
+ if (QuaternionObject_Check(value)) {
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
}
- else {
- float tquat[4];
- normalize_qt_qt(tquat, ((QuaternionObject *)value)->quat);
- quat_to_mat3(rmat, tquat);
- return 0;
- }
+
+ float tquat[4];
+ normalize_qt_qt(tquat, ((QuaternionObject *)value)->quat);
+ quat_to_mat3(rmat, tquat);
+ return 0;
}
- else if (MatrixObject_Check(value)) {
+ if (MatrixObject_Check(value)) {
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
}
- else if (((MatrixObject *)value)->num_row < 3 || ((MatrixObject *)value)->num_col < 3) {
+ if (((MatrixObject *)value)->num_row < 3 || ((MatrixObject *)value)->num_col < 3) {
PyErr_Format(
PyExc_ValueError, "%.200s: matrix must have minimum 3x3 dimensions", error_prefix);
return -1;
}
- else {
- matrix_as_3x3(rmat, (MatrixObject *)value);
- normalize_m3(rmat);
- return 0;
- }
- }
- else {
- PyErr_Format(PyExc_TypeError,
- "%.200s: expected a Euler, Quaternion or Matrix type, "
- "found %.200s",
- error_prefix,
- Py_TYPE(value)->tp_name);
- return -1;
+
+ matrix_as_3x3(rmat, (MatrixObject *)value);
+ normalize_m3(rmat);
+ return 0;
}
+
+ PyErr_Format(PyExc_TypeError,
+ "%.200s: expected a Euler, Quaternion or Matrix type, "
+ "found %.200s",
+ error_prefix,
+ Py_TYPE(value)->tp_name);
+ return -1;
}
/* ----------------------------------MATRIX FUNCTIONS-------------------- */
diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h
index c59fa75b651..d8d390cfad0 100644
--- a/source/blender/python/mathutils/mathutils.h
+++ b/source/blender/python/mathutils/mathutils.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __MATHUTILS_H__
-#define __MATHUTILS_H__
+#pragma once
/** \file
* \ingroup pymathutils
@@ -195,5 +194,3 @@ int column_vector_multiplication(float rvec[4], VectorObject *vec, MatrixObject
/* dynstr as python string utility functions */
PyObject *mathutils_dynstr_to_py(struct DynStr *ds);
#endif
-
-#endif /* __MATHUTILS_H__ */
diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c
index 08dede8ff78..6bffff467cd 100644
--- a/source/blender/python/mathutils/mathutils_Color.c
+++ b/source/blender/python/mathutils/mathutils_Color.c
@@ -347,7 +347,7 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item)
}
return Color_item(self, i);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) {
@@ -357,19 +357,17 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item)
if (slicelength <= 0) {
return PyTuple_New(0);
}
- else if (step == 1) {
+ if (step == 1) {
return Color_slice(self, start, stop);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with color");
- return NULL;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "color indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with color");
return NULL;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "color indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return NULL;
}
static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *value)
@@ -384,7 +382,7 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
}
return Color_ass_item(self, i, value);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) {
@@ -394,16 +392,14 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
if (step == 1) {
return Color_ass_slice(self, start, stop, value);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with color");
- return -1;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "color indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with color");
return -1;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "color indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return -1;
}
/* -----------------PROTCOL DECLARATIONS-------------------------- */
diff --git a/source/blender/python/mathutils/mathutils_Color.h b/source/blender/python/mathutils/mathutils_Color.h
index 51e1746ae74..c966bf1e3b2 100644
--- a/source/blender/python/mathutils/mathutils_Color.h
+++ b/source/blender/python/mathutils/mathutils_Color.h
@@ -18,8 +18,7 @@
* \ingroup pymathutils
*/
-#ifndef __MATHUTILS_COLOR_H__
-#define __MATHUTILS_COLOR_H__
+#pragma once
extern PyTypeObject color_Type;
#define ColorObject_Check(v) PyObject_TypeCheck((v), &color_Type)
@@ -42,5 +41,3 @@ PyObject *Color_CreatePyObject_wrap(float col[3], PyTypeObject *base_type) ATTR_
PyObject *Color_CreatePyObject_cb(PyObject *cb_user,
unsigned char cb_type,
unsigned char cb_subtype) ATTR_WARN_UNUSED_RESULT;
-
-#endif /* __MATHUTILS_COLOR_H__ */
diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c
index 7ece587e38f..ebc71706bef 100644
--- a/source/blender/python/mathutils/mathutils_Euler.c
+++ b/source/blender/python/mathutils/mathutils_Euler.c
@@ -558,7 +558,7 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item)
}
return Euler_item(self, i);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) {
@@ -568,19 +568,17 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item)
if (slicelength <= 0) {
return PyTuple_New(0);
}
- else if (step == 1) {
+ if (step == 1) {
return Euler_slice(self, start, stop);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with eulers");
- return NULL;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "euler indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with eulers");
return NULL;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "euler indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return NULL;
}
static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *value)
@@ -595,7 +593,7 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
}
return Euler_ass_item(self, i, value);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) {
@@ -605,16 +603,14 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
if (step == 1) {
return Euler_ass_slice(self, start, stop, value);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with euler");
- return -1;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "euler indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with euler");
return -1;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "euler indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return -1;
}
/* -----------------PROTCOL DECLARATIONS-------------------------- */
diff --git a/source/blender/python/mathutils/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h
index c56962395e5..0deef3cfdf3 100644
--- a/source/blender/python/mathutils/mathutils_Euler.h
+++ b/source/blender/python/mathutils/mathutils_Euler.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __MATHUTILS_EULER_H__
-#define __MATHUTILS_EULER_H__
+#pragma once
/** \file
* \ingroup pymathutils
@@ -50,5 +49,3 @@ PyObject *Euler_CreatePyObject_cb(PyObject *cb_user,
unsigned char cb_subtype) ATTR_WARN_UNUSED_RESULT;
short euler_order_from_string(const char *str, const char *error_prefix);
-
-#endif /* __MATHUTILS_EULER_H__ */
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 3e30c81c8c6..236bb1de29d 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -54,9 +54,8 @@ static int matrix_row_vector_check(MatrixObject *mat, VectorObject *vec, int row
"owner matrix has been resized since this row vector was created");
return 0;
}
- else {
- return 1;
- }
+
+ return 1;
}
static int matrix_col_vector_check(MatrixObject *mat, VectorObject *vec, int col)
@@ -67,9 +66,8 @@ static int matrix_col_vector_check(MatrixObject *mat, VectorObject *vec, int col
"owner matrix has been resized since this column vector was created");
return 0;
}
- else {
- return 1;
- }
+
+ return 1;
}
/* ----------------------------------------------------------------------------
@@ -380,9 +378,8 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (Matrix_ass_slice((MatrixObject *)matrix, 0, INT_MAX, arg) == 0) {
return matrix;
}
- else { /* matrix ok, slice assignment not */
- Py_DECREF(matrix);
- }
+ /* matrix ok, slice assignment not */
+ Py_DECREF(matrix);
}
}
break;
@@ -406,15 +403,13 @@ static PyObject *matrix__apply_to_copy(PyObject *(*matrix_func)(MatrixObject *),
Py_DECREF(ret_dummy);
return ret;
}
- else { /* error */
- Py_DECREF(ret);
- return NULL;
- }
- }
- else {
- /* copy may fail if the read callback errors out */
+ /* error */
+ Py_DECREF(ret);
return NULL;
}
+
+ /* copy may fail if the read callback errors out */
+ return NULL;
}
/* when a matrix is 4x4 size but initialized as a 3x3, re-assign values for 4x4 */
@@ -512,10 +507,9 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
"or a string in 'X', 'Y', 'Z'");
return NULL;
}
- else {
- /* use the string */
- vec = NULL;
- }
+
+ /* use the string */
+ vec = NULL;
}
angle = angle_wrap_rad(angle);
@@ -1023,7 +1017,7 @@ static float matrix_determinant_internal(const MatrixObject *self)
MATRIX_ITEM(self, 1, 0),
MATRIX_ITEM(self, 1, 1));
}
- else if (self->num_col == 3) {
+ if (self->num_col == 3) {
return determinant_m3(MATRIX_ITEM(self, 0, 0),
MATRIX_ITEM(self, 0, 1),
MATRIX_ITEM(self, 0, 2),
@@ -1034,9 +1028,8 @@ static float matrix_determinant_internal(const MatrixObject *self)
MATRIX_ITEM(self, 2, 1),
MATRIX_ITEM(self, 2, 2));
}
- else {
- return determinant_m4((float(*)[4])self->matrix);
- }
+
+ return determinant_m4((float(*)[4])self->matrix);
}
static void adjoint_matrix_n(float *mat_dst, const float *mat_src, const ushort dim)
@@ -1094,9 +1087,8 @@ static bool matrix_invert_internal(const MatrixObject *self, float *r_mat)
matrix_invert_with_det_n_internal(r_mat, self->matrix, det, self->num_col);
return true;
}
- else {
- return false;
- }
+
+ return false;
}
/**
@@ -1475,9 +1467,8 @@ static bool matrix_invert_is_compat(const MatrixObject *self)
"only square matrices are supported");
return false;
}
- else {
- return true;
- }
+
+ return true;
}
static bool matrix_invert_args_check(const MatrixObject *self, PyObject *args, bool check_type)
@@ -1605,10 +1596,9 @@ static PyObject *Matrix_inverted(MatrixObject *self, PyObject *args)
Py_INCREF(fallback);
return fallback;
}
- else {
- matrix_invert_raise_degenerate();
- return NULL;
- }
+
+ matrix_invert_raise_degenerate();
+ return NULL;
}
return Matrix_copy_notest(self, mat);
@@ -2386,48 +2376,47 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va
/* PySequence_Fast sets the error */
return -1;
}
- else {
- PyObject **value_fast_items = PySequence_Fast_ITEMS(value_fast);
- const int size = end - begin;
- int row, col;
- float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
- float vec[4];
- if (PySequence_Fast_GET_SIZE(value_fast) != size) {
- Py_DECREF(value_fast);
- PyErr_SetString(PyExc_ValueError,
- "matrix[begin:end] = []: "
- "size mismatch in slice assignment");
- return -1;
- }
+ PyObject **value_fast_items = PySequence_Fast_ITEMS(value_fast);
+ const int size = end - begin;
+ int row, col;
+ float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
+ float vec[4];
+
+ if (PySequence_Fast_GET_SIZE(value_fast) != size) {
+ Py_DECREF(value_fast);
+ PyErr_SetString(PyExc_ValueError,
+ "matrix[begin:end] = []: "
+ "size mismatch in slice assignment");
+ return -1;
+ }
- memcpy(mat, self->matrix, self->num_col * self->num_row * sizeof(float));
+ memcpy(mat, self->matrix, self->num_col * self->num_row * sizeof(float));
- /* parse sub items */
- for (row = begin; row < end; row++) {
- /* parse each sub sequence */
- PyObject *item = value_fast_items[row - begin];
+ /* parse sub items */
+ for (row = begin; row < end; row++) {
+ /* parse each sub sequence */
+ PyObject *item = value_fast_items[row - begin];
- if (mathutils_array_parse(
- vec, self->num_col, self->num_col, item, "matrix[begin:end] = value assignment") ==
- -1) {
- Py_DECREF(value_fast);
- return -1;
- }
+ if (mathutils_array_parse(
+ vec, self->num_col, self->num_col, item, "matrix[begin:end] = value assignment") ==
+ -1) {
+ Py_DECREF(value_fast);
+ return -1;
+ }
- for (col = 0; col < self->num_col; col++) {
- mat[col * self->num_row + row] = vec[col];
- }
+ for (col = 0; col < self->num_col; col++) {
+ mat[col * self->num_row + row] = vec[col];
}
+ }
- Py_DECREF(value_fast);
+ Py_DECREF(value_fast);
- /*parsed well - now set in matrix*/
- memcpy(self->matrix, mat, self->num_col * self->num_row * sizeof(float));
+ /*parsed well - now set in matrix*/
+ memcpy(self->matrix, mat, self->num_col * self->num_row * sizeof(float));
- (void)BaseMath_WriteCallback(self);
- return 0;
- }
+ (void)BaseMath_WriteCallback(self);
+ return 0;
}
/*------------------------NUMERIC PROTOCOLS----------------------
*------------------------obj + obj------------------------------*/
@@ -2540,7 +2529,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
return Matrix_CreatePyObject(mat, mat2->num_col, mat1->num_row, Py_TYPE(mat1));
}
- else if (mat2) {
+ if (mat2) {
/*FLOAT/INT * MATRIX */
if (((scalar = PyFloat_AsDouble(m1)) == -1.0f && PyErr_Occurred()) == 0) {
return matrix_mul_float(mat2, scalar);
@@ -2655,7 +2644,7 @@ static PyObject *Matrix_matmul(PyObject *m1, PyObject *m2)
return Matrix_CreatePyObject(mat, mat2->num_col, mat1->num_row, Py_TYPE(mat1));
}
- else if (mat1) {
+ if (mat1) {
/* MATRIX @ VECTOR */
if (VectorObject_Check(m2)) {
VectorObject *vec2 = (VectorObject *)m2;
@@ -2772,7 +2761,7 @@ static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item)
}
return Matrix_item_row(self, i);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, self->num_row, &start, &stop, &step, &slicelength) < 0) {
@@ -2782,19 +2771,17 @@ static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item)
if (slicelength <= 0) {
return PyTuple_New(0);
}
- else if (step == 1) {
+ if (step == 1) {
return Matrix_slice(self, start, stop);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with matrices");
- return NULL;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with matrices");
return NULL;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return NULL;
}
static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *value)
@@ -2809,7 +2796,7 @@ static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *va
}
return Matrix_ass_item_row(self, i, value);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, self->num_row, &start, &stop, &step, &slicelength) < 0) {
@@ -2819,16 +2806,14 @@ static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *va
if (step == 1) {
return Matrix_ass_slice(self, start, stop, value);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with matrices");
- return -1;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with matrices");
return -1;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return -1;
}
static PyMappingMethods Matrix_AsMapping = {
@@ -2977,15 +2962,14 @@ static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure
if (self->num_row == 4 && self->num_col == 4) {
return PyBool_FromLong(is_negative_m4((float(*)[4])self->matrix));
}
- else if (self->num_row == 3 && self->num_col == 3) {
+ if (self->num_row == 3 && self->num_col == 3) {
return PyBool_FromLong(is_negative_m3((float(*)[3])self->matrix));
}
- else {
- PyErr_SetString(PyExc_AttributeError,
- "Matrix.is_negative: "
- "inappropriate matrix size - expects 3x3 or 4x4 matrix");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_AttributeError,
+ "Matrix.is_negative: "
+ "inappropriate matrix size - expects 3x3 or 4x4 matrix");
+ return NULL;
}
PyDoc_STRVAR(Matrix_is_orthogonal_doc,
@@ -3000,15 +2984,14 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu
if (self->num_row == 4 && self->num_col == 4) {
return PyBool_FromLong(is_orthonormal_m4((float(*)[4])self->matrix));
}
- else if (self->num_row == 3 && self->num_col == 3) {
+ if (self->num_row == 3 && self->num_col == 3) {
return PyBool_FromLong(is_orthonormal_m3((float(*)[3])self->matrix));
}
- else {
- PyErr_SetString(PyExc_AttributeError,
- "Matrix.is_orthogonal: "
- "inappropriate matrix size - expects 3x3 or 4x4 matrix");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_AttributeError,
+ "Matrix.is_orthogonal: "
+ "inappropriate matrix size - expects 3x3 or 4x4 matrix");
+ return NULL;
}
PyDoc_STRVAR(Matrix_is_orthogonal_axis_vectors_doc,
@@ -3024,15 +3007,14 @@ static PyObject *Matrix_is_orthogonal_axis_vectors_get(MatrixObject *self, void
if (self->num_row == 4 && self->num_col == 4) {
return PyBool_FromLong(is_orthogonal_m4((float(*)[4])self->matrix));
}
- else if (self->num_row == 3 && self->num_col == 3) {
+ if (self->num_row == 3 && self->num_col == 3) {
return PyBool_FromLong(is_orthogonal_m3((float(*)[3])self->matrix));
}
- else {
- PyErr_SetString(PyExc_AttributeError,
- "Matrix.is_orthogonal_axis_vectors: "
- "inappropriate matrix size - expects 3x3 or 4x4 matrix");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_AttributeError,
+ "Matrix.is_orthogonal_axis_vectors: "
+ "inappropriate matrix size - expects 3x3 or 4x4 matrix");
+ return NULL;
}
/*****************************************************************************/
@@ -3478,14 +3460,13 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item
}
return Matrix_item_row(matrix_user, i);
}
- else { /* MAT_ACCESS_ROW */
- if (i < 0) {
- i += matrix_user->num_col;
- }
- return Matrix_item_col(matrix_user, i);
+ /* MAT_ACCESS_ROW */
+ if (i < 0) {
+ i += matrix_user->num_col;
}
+ return Matrix_item_col(matrix_user, i);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, MatrixAccess_len(self), &start, &stop, &step, &slicelength) <
@@ -3496,19 +3477,17 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item
if (slicelength <= 0) {
return PyTuple_New(0);
}
- else if (step == 1) {
+ if (step == 1) {
return MatrixAccess_slice(self, start, stop);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with matrix accessors");
- return NULL;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with matrix accessors");
return NULL;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return NULL;
}
static int MatrixAccess_ass_subscript(MatrixAccessObject *self, PyObject *item, PyObject *value)
@@ -3527,19 +3506,17 @@ static int MatrixAccess_ass_subscript(MatrixAccessObject *self, PyObject *item,
}
return Matrix_ass_item_row(matrix_user, i, value);
}
- else { /* MAT_ACCESS_ROW */
- if (i < 0) {
- i += matrix_user->num_col;
- }
- return Matrix_ass_item_col(matrix_user, i, value);
+ /* MAT_ACCESS_ROW */
+ if (i < 0) {
+ i += matrix_user->num_col;
}
+ return Matrix_ass_item_col(matrix_user, i, value);
}
/* TODO, slice */
- else {
- PyErr_Format(
- PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
- return -1;
- }
+
+ PyErr_Format(
+ PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return -1;
}
static PyObject *MatrixAccess_iter(MatrixAccessObject *self)
diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h
index a0e2256b1ce..588c0b94891 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.h
+++ b/source/blender/python/mathutils/mathutils_Matrix.h
@@ -18,8 +18,7 @@
* \ingroup pymathutils
*/
-#ifndef __MATHUTILS_MATRIX_H__
-#define __MATHUTILS_MATRIX_H__
+#pragma once
extern PyTypeObject matrix_Type;
extern PyTypeObject matrix_access_Type;
@@ -96,5 +95,3 @@ extern struct Mathutils_Callback mathutils_matrix_col_cb;
extern struct Mathutils_Callback mathutils_matrix_translation_cb;
void matrix_as_3x3(float mat[3][3], MatrixObject *self);
-
-#endif /* __MATHUTILS_MATRIX_H__ */
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index 2b7761b7678..b0e6b330968 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -815,7 +815,7 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item)
}
return Quaternion_item(self, i);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) {
@@ -825,20 +825,17 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item)
if (slicelength <= 0) {
return PyTuple_New(0);
}
- else if (step == 1) {
+ if (step == 1) {
return Quaternion_slice(self, start, stop);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with quaternions");
- return NULL;
- }
- }
- else {
- PyErr_Format(PyExc_TypeError,
- "quaternion indices must be integers, not %.200s",
- Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with quaternions");
return NULL;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "quaternion indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return NULL;
}
static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyObject *value)
@@ -853,7 +850,7 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb
}
return Quaternion_ass_item(self, i, value);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) {
@@ -863,17 +860,14 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb
if (step == 1) {
return Quaternion_ass_slice(self, start, stop, value);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with quaternion");
- return -1;
- }
- }
- else {
- PyErr_Format(PyExc_TypeError,
- "quaternion indices must be integers, not %.200s",
- Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with quaternion");
return -1;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "quaternion indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return -1;
}
/* ------------------------NUMERIC PROTOCOLS---------------------- */
@@ -967,7 +961,7 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
return Quaternion_CreatePyObject(quat, Py_TYPE(q1));
}
/* the only case this can happen (for a supported type is "FLOAT * QUAT") */
- else if (quat2) { /* FLOAT * QUAT */
+ if (quat2) { /* FLOAT * QUAT */
if (((scalar = PyFloat_AsDouble(q1)) == -1.0f && PyErr_Occurred()) == 0) {
return quat_mul_float(quat2, scalar);
}
@@ -1049,7 +1043,7 @@ static PyObject *Quaternion_matmul(PyObject *q1, PyObject *q2)
mul_qt_qtqt(quat, quat1->quat, quat2->quat);
return Quaternion_CreatePyObject(quat, Py_TYPE(q1));
}
- else if (quat1) {
+ if (quat1) {
/* QUAT @ VEC */
if (VectorObject_Check(q2)) {
VectorObject *vec2 = (VectorObject *)q2;
@@ -1384,10 +1378,9 @@ static PyObject *quat__apply_to_copy(PyObject *(*quat_func)(QuaternionObject *),
Py_DECREF(ret_dummy);
return ret;
}
- else { /* error */
- Py_DECREF(ret);
- return NULL;
- }
+ /* error */
+ Py_DECREF(ret);
+ return NULL;
}
/* axis vector suffers from precision errors, use this function to ensure */
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.h b/source/blender/python/mathutils/mathutils_Quaternion.h
index bc6bd307ece..7d20558939e 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.h
+++ b/source/blender/python/mathutils/mathutils_Quaternion.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __MATHUTILS_QUATERNION_H__
-#define __MATHUTILS_QUATERNION_H__
+#pragma once
/** \file
* \ingroup pymathutils
@@ -44,5 +43,3 @@ PyObject *Quaternion_CreatePyObject_wrap(float quat[4],
PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user,
unsigned char cb_type,
unsigned char cb_subtype) ATTR_WARN_UNUSED_RESULT;
-
-#endif /* __MATHUTILS_QUATERNION_H__ */
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 4b47440a530..3ee6e766413 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -104,10 +104,9 @@ static PyObject *vec__apply_to_copy(PyObject *(*vec_func)(VectorObject *), Vecto
Py_DECREF(ret_dummy);
return (PyObject *)ret;
}
- else { /* error */
- Py_DECREF(ret);
- return NULL;
- }
+ /* error */
+ Py_DECREF(ret);
+ return NULL;
}
/*-----------------------CLASS-METHODS----------------------------*/
@@ -484,7 +483,7 @@ static PyObject *Vector_resize_2d(VectorObject *self)
return NULL;
}
- self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2));
+ self->vec = PyMem_Realloc(self->vec, sizeof(float[2]));
if (self->vec == NULL) {
PyErr_SetString(PyExc_MemoryError,
"Vector.resize_2d(): "
@@ -515,7 +514,7 @@ static PyObject *Vector_resize_3d(VectorObject *self)
return NULL;
}
- self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3));
+ self->vec = PyMem_Realloc(self->vec, sizeof(float[3]));
if (self->vec == NULL) {
PyErr_SetString(PyExc_MemoryError,
"Vector.resize_3d(): "
@@ -550,7 +549,7 @@ static PyObject *Vector_resize_4d(VectorObject *self)
return NULL;
}
- self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4));
+ self->vec = PyMem_Realloc(self->vec, sizeof(float[4]));
if (self->vec == NULL) {
PyErr_SetString(PyExc_MemoryError,
"Vector.resize_4d(): "
@@ -1004,12 +1003,11 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
Py_INCREF(fallback);
return fallback;
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "Vector.angle(other): "
- "zero length vectors have no valid angle");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError,
+ "Vector.angle(other): "
+ "zero length vectors have no valid angle");
+ return NULL;
}
return PyFloat_FromDouble(saacos(dot / (sqrt(dot_self) * sqrt(dot_other))));
@@ -1059,12 +1057,11 @@ static PyObject *Vector_angle_signed(VectorObject *self, PyObject *args)
Py_INCREF(fallback);
return fallback;
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "Vector.angle_signed(other): "
- "zero length vectors have no valid angle");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError,
+ "Vector.angle_signed(other): "
+ "zero length vectors have no valid angle");
+ return NULL;
}
return PyFloat_FromDouble(angle_signed_v2v2(self->vec, tvec));
@@ -1238,12 +1235,11 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args)
Py_INCREF(fallback);
return fallback;
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "Vector.slerp(): "
- "zero length vectors unsupported");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError,
+ "Vector.slerp(): "
+ "zero length vectors unsupported");
+ return NULL;
}
/* We have sane state, execute slerp */
@@ -1256,12 +1252,11 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args)
Py_INCREF(fallback);
return fallback;
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "Vector.slerp(): "
- "opposite vectors unsupported");
- return NULL;
- }
+
+ PyErr_SetString(PyExc_ValueError,
+ "Vector.slerp(): "
+ "opposite vectors unsupported");
+ return NULL;
}
interp_dot_slerp(fac, cosom, w);
@@ -1785,7 +1780,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
/* element-wise product */
return vector_mul_vec(vec1, vec2);
}
- else if (vec1) {
+ if (vec1) {
if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* VEC * FLOAT */
return vector_mul_float(vec1, scalar);
}
@@ -1890,7 +1885,7 @@ static PyObject *Vector_matmul(PyObject *v1, PyObject *v2)
/*dot product*/
return PyFloat_FromDouble(dot_vn_vn(vec1->vec, vec2->vec, vec1->size));
}
- else if (vec1) {
+ if (vec1) {
if (MatrixObject_Check(v2)) {
/* VEC @ MATRIX */
float tvec[MAX_DIMENSIONS];
@@ -2039,9 +2034,8 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
if (comparison_type == Py_NE) {
Py_RETURN_TRUE;
}
- else {
- Py_RETURN_FALSE;
- }
+
+ Py_RETURN_FALSE;
}
vecA = (VectorObject *)objectA;
vecB = (VectorObject *)objectB;
@@ -2054,9 +2048,8 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
if (comparison_type == Py_NE) {
Py_RETURN_TRUE;
}
- else {
- Py_RETURN_FALSE;
- }
+
+ Py_RETURN_FALSE;
}
switch (comparison_type) {
@@ -2107,9 +2100,8 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
if (result == 1) {
Py_RETURN_TRUE;
}
- else {
- Py_RETURN_FALSE;
- }
+
+ Py_RETURN_FALSE;
}
static Py_hash_t Vector_hash(VectorObject *self)
@@ -2152,7 +2144,7 @@ static PyObject *Vector_subscript(VectorObject *self, PyObject *item)
}
return Vector_item(self, i);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0) {
@@ -2162,19 +2154,17 @@ static PyObject *Vector_subscript(VectorObject *self, PyObject *item)
if (slicelength <= 0) {
return PyTuple_New(0);
}
- else if (step == 1) {
+ if (step == 1) {
return Vector_slice(self, start, stop);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
- return NULL;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
return NULL;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return NULL;
}
static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *value)
@@ -2189,7 +2179,7 @@ static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *va
}
return Vector_ass_item(self, i, value);
}
- else if (PySlice_Check(item)) {
+ if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0) {
@@ -2199,16 +2189,14 @@ static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *va
if (step == 1) {
return Vector_ass_slice(self, start, stop, value);
}
- else {
- PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
- return -1;
- }
- }
- else {
- PyErr_Format(
- PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+
+ PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors");
return -1;
}
+
+ PyErr_Format(
+ PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
+ return -1;
}
static PyMappingMethods Vector_AsMapping = {
@@ -2523,9 +2511,8 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure
if (BaseMath_WriteCallback(self) == -1) {
return -1;
}
- else {
- return 0;
- }
+
+ return 0;
}
#define _SWIZZLE1(a) ((a) | SWIZZLE_VALID_AXIS)
diff --git a/source/blender/python/mathutils/mathutils_Vector.h b/source/blender/python/mathutils/mathutils_Vector.h
index f75702bc54c..09fc429f9cc 100644
--- a/source/blender/python/mathutils/mathutils_Vector.h
+++ b/source/blender/python/mathutils/mathutils_Vector.h
@@ -18,8 +18,7 @@
* \ingroup pymathutils
*/
-#ifndef __MATHUTILS_VECTOR_H__
-#define __MATHUTILS_VECTOR_H__
+#pragma once
extern PyTypeObject vector_Type;
@@ -48,5 +47,3 @@ PyObject *Vector_CreatePyObject_alloc(float *vec,
const int size,
PyTypeObject *base_type) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1);
-
-#endif /* __MATHUTILS_VECTOR_H__ */
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c
index 5a0dc7d6a5e..0c53639c67d 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -549,8 +549,8 @@ static bool py_bvhtree_overlap_cb(void *userdata, int index_a, int index_b, int
}
}
- return (isect_tri_tri_epsilon_v3(
- UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1], data->epsilon) &&
+ return (isect_tri_tri_v3(
+ UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1]) &&
((verts_shared == 0) || (len_squared_v3v3(ix_pair[0], ix_pair[1]) > data->epsilon)));
}
@@ -914,16 +914,15 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
return bvhtree_CreatePyObject(
tree, epsilon, coords, coords_len, tris, tris_len, orig_index, orig_normal);
}
- else {
- if (coords) {
- MEM_freeN(coords);
- }
- if (tris) {
- MEM_freeN(tris);
- }
- return NULL;
+ if (coords) {
+ MEM_freeN(coords);
+ }
+ if (tris) {
+ MEM_freeN(tris);
}
+
+ return NULL;
}
#ifndef MATH_STANDALONE
@@ -1053,55 +1052,48 @@ static Mesh *bvh_get_mesh(const char *funcname,
funcname);
return NULL;
}
- else {
- *r_free_mesh = true;
- return mesh_create_eval_final_render(depsgraph, scene, ob, &data_masks);
- }
+
+ *r_free_mesh = true;
+ return mesh_create_eval_final_render(depsgraph, scene, ob, &data_masks);
}
- else if (ob_eval != NULL) {
+ if (ob_eval != NULL) {
if (use_cage) {
return mesh_get_eval_deform(depsgraph, scene, ob_eval, &data_masks);
}
- else {
- return mesh_get_eval_final(depsgraph, scene, ob_eval, &data_masks);
- }
+
+ return mesh_get_eval_final(depsgraph, scene, ob_eval, &data_masks);
}
- else {
- PyErr_Format(PyExc_ValueError,
- "%s(...): Cannot get evaluated data from given dependency graph / object pair",
- funcname);
+
+ PyErr_Format(PyExc_ValueError,
+ "%s(...): Cannot get evaluated data from given dependency graph / object pair",
+ funcname);
+ return NULL;
+ }
+
+ /* !use_deform */
+ if (use_render) {
+ if (use_cage) {
+ PyErr_Format(
+ PyExc_ValueError,
+ "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
+ funcname);
return NULL;
}
+
+ *r_free_mesh = true;
+ return mesh_create_eval_no_deform_render(depsgraph, scene, ob, &data_masks);
}
- else {
- /* !use_deform */
- if (use_render) {
- if (use_cage) {
- PyErr_Format(
- PyExc_ValueError,
- "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER",
- funcname);
- return NULL;
- }
- else {
- *r_free_mesh = true;
- return mesh_create_eval_no_deform_render(depsgraph, scene, ob, &data_masks);
- }
- }
- else {
- if (use_cage) {
- PyErr_Format(PyExc_ValueError,
- "%s(...): cage arg is unsupported when deform=False and dependency graph "
- "evaluation mode is not RENDER",
- funcname);
- return NULL;
- }
- else {
- *r_free_mesh = true;
- return mesh_create_eval_no_deform(depsgraph, scene, ob, &data_masks);
- }
- }
+
+ if (use_cage) {
+ PyErr_Format(PyExc_ValueError,
+ "%s(...): cage arg is unsupported when deform=False and dependency graph "
+ "evaluation mode is not RENDER",
+ funcname);
+ return NULL;
}
+
+ *r_free_mesh = true;
+ return mesh_create_eval_no_deform(depsgraph, scene, ob, &data_masks);
}
PyDoc_STRVAR(C_BVHTree_FromObject_doc,
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.h b/source/blender/python/mathutils/mathutils_bvhtree.h
index 2991982f3a2..82b09f11e5e 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.h
+++ b/source/blender/python/mathutils/mathutils_bvhtree.h
@@ -18,8 +18,7 @@
* \ingroup mathutils
*/
-#ifndef __MATHUTILS_BVHTREE_H__
-#define __MATHUTILS_BVHTREE_H__
+#pragma once
PyMODINIT_FUNC PyInit_mathutils_bvhtree(void);
@@ -27,5 +26,3 @@ extern PyTypeObject PyBVHTree_Type;
#define PyBVHTree_Check(v) PyObject_TypeCheck((v), &PyBVHTree_Type)
#define PyBVHTree_CheckExact(v) (Py_TYPE(v) == &PyBVHTree_Type)
-
-#endif /* __MATHUTILS_BVHTREE_H__ */
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 93dbac32c19..37997e9f912 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -204,12 +204,11 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject
/* collinear */
Py_RETURN_NONE;
}
- else {
- tuple = PyTuple_New(2);
- PyTuple_SET_ITEMS(
- tuple, Vector_CreatePyObject(i1, len, NULL), Vector_CreatePyObject(i2, len, NULL));
- return tuple;
- }
+
+ tuple = PyTuple_New(2);
+ PyTuple_SET_ITEMS(
+ tuple, Vector_CreatePyObject(i1, len, NULL), Vector_CreatePyObject(i2, len, NULL));
+ return tuple;
}
/* Line-Line intersection using algorithm from mathworld.wolfram.com */
@@ -466,9 +465,8 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj
if (isect_seg_seg_v2_point(UNPACK4(lines), vi) == 1) {
return Vector_CreatePyObject(vi, 2, NULL);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(
@@ -519,9 +517,8 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec
if (isect_line_plane_v3(isect, line_a, line_b, plane_co, plane_no) == 1) {
return Vector_CreatePyObject(isect, 3, NULL);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(
@@ -637,43 +634,42 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
-1)) == 0) {
return NULL;
}
- else {
- bool use_a = true;
- bool use_b = true;
- float lambda;
- PyObject *ret = PyTuple_New(2);
+ bool use_a = true;
+ bool use_b = true;
+ float lambda;
- switch (isect_line_sphere_v3(line_a, line_b, sphere_co, sphere_radius, isect_a, isect_b)) {
- case 1:
- if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a, line_b)) >= 0.0f) &&
- (lambda <= 1.0f)))) {
- use_a = false;
- }
- use_b = false;
- break;
- case 2:
- if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a, line_b)) >= 0.0f) &&
- (lambda <= 1.0f)))) {
- use_a = false;
- }
- if (!(!clip || (((lambda = line_point_factor_v3(isect_b, line_a, line_b)) >= 0.0f) &&
- (lambda <= 1.0f)))) {
- use_b = false;
- }
- break;
- default:
+ PyObject *ret = PyTuple_New(2);
+
+ switch (isect_line_sphere_v3(line_a, line_b, sphere_co, sphere_radius, isect_a, isect_b)) {
+ case 1:
+ if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a, line_b)) >= 0.0f) &&
+ (lambda <= 1.0f)))) {
+ use_a = false;
+ }
+ use_b = false;
+ break;
+ case 2:
+ if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a, line_b)) >= 0.0f) &&
+ (lambda <= 1.0f)))) {
use_a = false;
+ }
+ if (!(!clip || (((lambda = line_point_factor_v3(isect_b, line_a, line_b)) >= 0.0f) &&
+ (lambda <= 1.0f)))) {
use_b = false;
- break;
- }
+ }
+ break;
+ default:
+ use_a = false;
+ use_b = false;
+ break;
+ }
- PyTuple_SET_ITEMS(ret,
- use_a ? Vector_CreatePyObject(isect_a, 3, NULL) : Py_INCREF_RET(Py_None),
- use_b ? Vector_CreatePyObject(isect_b, 3, NULL) : Py_INCREF_RET(Py_None));
+ PyTuple_SET_ITEMS(ret,
+ use_a ? Vector_CreatePyObject(isect_a, 3, NULL) : Py_INCREF_RET(Py_None),
+ use_b ? Vector_CreatePyObject(isect_b, 3, NULL) : Py_INCREF_RET(Py_None));
- return ret;
- }
+ return ret;
}
/* keep in sync with M_Geometry_intersect_line_sphere */
@@ -723,43 +719,42 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
-1)) == 0) {
return NULL;
}
- else {
- bool use_a = true;
- bool use_b = true;
- float lambda;
- PyObject *ret = PyTuple_New(2);
+ bool use_a = true;
+ bool use_b = true;
+ float lambda;
- switch (isect_line_sphere_v2(line_a, line_b, sphere_co, sphere_radius, isect_a, isect_b)) {
- case 1:
- if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a, line_b)) >= 0.0f) &&
- (lambda <= 1.0f)))) {
- use_a = false;
- }
- use_b = false;
- break;
- case 2:
- if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a, line_b)) >= 0.0f) &&
- (lambda <= 1.0f)))) {
- use_a = false;
- }
- if (!(!clip || (((lambda = line_point_factor_v2(isect_b, line_a, line_b)) >= 0.0f) &&
- (lambda <= 1.0f)))) {
- use_b = false;
- }
- break;
- default:
+ PyObject *ret = PyTuple_New(2);
+
+ switch (isect_line_sphere_v2(line_a, line_b, sphere_co, sphere_radius, isect_a, isect_b)) {
+ case 1:
+ if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a, line_b)) >= 0.0f) &&
+ (lambda <= 1.0f)))) {
+ use_a = false;
+ }
+ use_b = false;
+ break;
+ case 2:
+ if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a, line_b)) >= 0.0f) &&
+ (lambda <= 1.0f)))) {
use_a = false;
+ }
+ if (!(!clip || (((lambda = line_point_factor_v2(isect_b, line_a, line_b)) >= 0.0f) &&
+ (lambda <= 1.0f)))) {
use_b = false;
- break;
- }
+ }
+ break;
+ default:
+ use_a = false;
+ use_b = false;
+ break;
+ }
- PyTuple_SET_ITEMS(ret,
- use_a ? Vector_CreatePyObject(isect_a, 2, NULL) : Py_INCREF_RET(Py_None),
- use_b ? Vector_CreatePyObject(isect_b, 2, NULL) : Py_INCREF_RET(Py_None));
+ PyTuple_SET_ITEMS(ret,
+ use_a ? Vector_CreatePyObject(isect_a, 2, NULL) : Py_INCREF_RET(Py_None),
+ use_b ? Vector_CreatePyObject(isect_b, 2, NULL) : Py_INCREF_RET(Py_None));
- return ret;
- }
+ return ret;
}
PyDoc_STRVAR(
@@ -849,9 +844,8 @@ static PyObject *M_Geometry_intersect_point_tri(PyObject *UNUSED(self), PyObject
if (isect_point_tri_v3(pt, UNPACK3(tri), vi)) {
return Vector_CreatePyObject(vi, 3, NULL);
}
- else {
- Py_RETURN_NONE;
- }
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(M_Geometry_closest_point_on_tri_doc,
@@ -1094,88 +1088,84 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a
(float **)&planes, 4, py_planes, "points_in_planes")) == -1) {
return NULL;
}
- else {
- /* note, this could be refactored into plain C easy - py bits are noted */
- const float eps = 0.0001f;
- const uint len = (uint)planes_len;
- uint i, j, k, l;
-
- float n1n2[3], n2n3[3], n3n1[3];
- float potentialVertex[3];
- char *planes_used = PyMem_Malloc(sizeof(char) * len);
-
- /* python */
- PyObject *py_verts = PyList_New(0);
- PyObject *py_plane_index = PyList_New(0);
-
- memset(planes_used, 0, sizeof(char) * len);
-
- for (i = 0; i < len; i++) {
- const float *N1 = planes[i];
- for (j = i + 1; j < len; j++) {
- const float *N2 = planes[j];
- cross_v3_v3v3(n1n2, N1, N2);
- if (len_squared_v3(n1n2) > eps) {
- for (k = j + 1; k < len; k++) {
- const float *N3 = planes[k];
- cross_v3_v3v3(n2n3, N2, N3);
- if (len_squared_v3(n2n3) > eps) {
- cross_v3_v3v3(n3n1, N3, N1);
- if (len_squared_v3(n3n1) > eps) {
- const float quotient = dot_v3v3(N1, n2n3);
- if (fabsf(quotient) > eps) {
- /**
- * <pre>
- * potentialVertex = (
- * (n2n3 * N1[3] + n3n1 * N2[3] + n1n2 * N3[3]) *
- * (-1.0 / quotient));
- * </pre>
- */
- const float quotient_ninv = -1.0f / quotient;
- potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) +
- (n1n2[0] * N3[3])) *
- quotient_ninv;
- potentialVertex[1] = ((n2n3[1] * N1[3]) + (n3n1[1] * N2[3]) +
- (n1n2[1] * N3[3])) *
- quotient_ninv;
- potentialVertex[2] = ((n2n3[2] * N1[3]) + (n3n1[2] * N2[3]) +
- (n1n2[2] * N3[3])) *
- quotient_ninv;
- for (l = 0; l < len; l++) {
- const float *NP = planes[l];
- if ((dot_v3v3(NP, potentialVertex) + NP[3]) > 0.000001f) {
- break;
- }
- }
- if (l == len) { /* ok */
- /* python */
- PyList_APPEND(py_verts, Vector_CreatePyObject(potentialVertex, 3, NULL));
- planes_used[i] = planes_used[j] = planes_used[k] = true;
+ /* note, this could be refactored into plain C easy - py bits are noted */
+ const float eps = 0.0001f;
+ const uint len = (uint)planes_len;
+ uint i, j, k, l;
+
+ float n1n2[3], n2n3[3], n3n1[3];
+ float potentialVertex[3];
+ char *planes_used = PyMem_Malloc(sizeof(char) * len);
+
+ /* python */
+ PyObject *py_verts = PyList_New(0);
+ PyObject *py_plane_index = PyList_New(0);
+
+ memset(planes_used, 0, sizeof(char) * len);
+
+ for (i = 0; i < len; i++) {
+ const float *N1 = planes[i];
+ for (j = i + 1; j < len; j++) {
+ const float *N2 = planes[j];
+ cross_v3_v3v3(n1n2, N1, N2);
+ if (len_squared_v3(n1n2) > eps) {
+ for (k = j + 1; k < len; k++) {
+ const float *N3 = planes[k];
+ cross_v3_v3v3(n2n3, N2, N3);
+ if (len_squared_v3(n2n3) > eps) {
+ cross_v3_v3v3(n3n1, N3, N1);
+ if (len_squared_v3(n3n1) > eps) {
+ const float quotient = dot_v3v3(N1, n2n3);
+ if (fabsf(quotient) > eps) {
+ /**
+ * <pre>
+ * potentialVertex = (
+ * (n2n3 * N1[3] + n3n1 * N2[3] + n1n2 * N3[3]) *
+ * (-1.0 / quotient));
+ * </pre>
+ */
+ const float quotient_ninv = -1.0f / quotient;
+ potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) + (n1n2[0] * N3[3])) *
+ quotient_ninv;
+ potentialVertex[1] = ((n2n3[1] * N1[3]) + (n3n1[1] * N2[3]) + (n1n2[1] * N3[3])) *
+ quotient_ninv;
+ potentialVertex[2] = ((n2n3[2] * N1[3]) + (n3n1[2] * N2[3]) + (n1n2[2] * N3[3])) *
+ quotient_ninv;
+ for (l = 0; l < len; l++) {
+ const float *NP = planes[l];
+ if ((dot_v3v3(NP, potentialVertex) + NP[3]) > 0.000001f) {
+ break;
}
}
+
+ if (l == len) { /* ok */
+ /* python */
+ PyList_APPEND(py_verts, Vector_CreatePyObject(potentialVertex, 3, NULL));
+ planes_used[i] = planes_used[j] = planes_used[k] = true;
+ }
}
}
}
}
}
}
+ }
- PyMem_Free(planes);
+ PyMem_Free(planes);
- /* now make a list of used planes */
- for (i = 0; i < len; i++) {
- if (planes_used[i]) {
- PyList_APPEND(py_plane_index, PyLong_FromLong(i));
- }
+ /* now make a list of used planes */
+ for (i = 0; i < len; i++) {
+ if (planes_used[i]) {
+ PyList_APPEND(py_plane_index, PyLong_FromLong(i));
}
- PyMem_Free(planes_used);
+ }
+ PyMem_Free(planes_used);
- {
- PyObject *ret = PyTuple_New(2);
- PyTuple_SET_ITEMS(ret, py_verts, py_plane_index);
- return ret;
- }
+ {
+ PyObject *ret = PyTuple_New(2);
+ PyTuple_SET_ITEMS(ret, py_verts, py_plane_index);
+ return ret;
}
}
@@ -1321,7 +1311,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject
BKE_displist_free(&dispbase); /* possible some dl was allocated */
return NULL;
}
- else if (totpoints) {
+ if (totpoints) {
/* now make the list to return */
BKE_displist_fill(&dispbase, &dispbase, is_2d ? ((const float[3]){0, 0, -1}) : NULL, false);
diff --git a/source/blender/python/mathutils/mathutils_geometry.h b/source/blender/python/mathutils/mathutils_geometry.h
index 5a1198b4a26..4a200ec98ca 100644
--- a/source/blender/python/mathutils/mathutils_geometry.h
+++ b/source/blender/python/mathutils/mathutils_geometry.h
@@ -14,13 +14,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __MATHUTILS_GEOMETRY_H__
-#define __MATHUTILS_GEOMETRY_H__
+#pragma once
/** \file
* \ingroup pymathutils
*/
PyMODINIT_FUNC PyInit_mathutils_geometry(void);
-
-#endif /* __MATHUTILS_GEOMETRY_H__ */
diff --git a/source/blender/python/mathutils/mathutils_interpolate.h b/source/blender/python/mathutils/mathutils_interpolate.h
index 50dee1ee8de..c51d2b6905b 100644
--- a/source/blender/python/mathutils/mathutils_interpolate.h
+++ b/source/blender/python/mathutils/mathutils_interpolate.h
@@ -14,13 +14,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __MATHUTILS_INTERPOLATE_H__
-#define __MATHUTILS_INTERPOLATE_H__
+#pragma once
/** \file
* \ingroup pymathutils
*/
PyMODINIT_FUNC PyInit_mathutils_interpolate(void);
-
-#endif /* __MATHUTILS_INTERPOLATE_H__ */
diff --git a/source/blender/python/mathutils/mathutils_kdtree.h b/source/blender/python/mathutils/mathutils_kdtree.h
index 99411997282..3df3fc8d382 100644
--- a/source/blender/python/mathutils/mathutils_kdtree.h
+++ b/source/blender/python/mathutils/mathutils_kdtree.h
@@ -18,11 +18,8 @@
* \ingroup mathutils
*/
-#ifndef __MATHUTILS_KDTREE_H__
-#define __MATHUTILS_KDTREE_H__
+#pragma once
PyMODINIT_FUNC PyInit_mathutils_kdtree(void);
extern PyTypeObject PyKDTree_Type;
-
-#endif /* __MATHUTILS_KDTREE_H__ */
diff --git a/source/blender/python/mathutils/mathutils_noise.h b/source/blender/python/mathutils/mathutils_noise.h
index 8204c084947..da5e1a99a03 100644
--- a/source/blender/python/mathutils/mathutils_noise.h
+++ b/source/blender/python/mathutils/mathutils_noise.h
@@ -18,9 +18,6 @@
* \ingroup mathutils
*/
-#ifndef __MATHUTILS_NOISE_H__
-#define __MATHUTILS_NOISE_H__
+#pragma once
PyMODINIT_FUNC PyInit_mathutils_noise(void);
-
-#endif /* __MATHUTILS_NOISE_H__ */
diff --git a/source/blender/render/extern/include/RE_bake.h b/source/blender/render/extern/include/RE_bake.h
index 6bb241b83ed..3ed41ede006 100644
--- a/source/blender/render/extern/include/RE_bake.h
+++ b/source/blender/render/extern/include/RE_bake.h
@@ -21,8 +21,7 @@
* \ingroup render
*/
-#ifndef __RE_BAKE_H__
-#define __RE_BAKE_H__
+#pragma once
struct Depsgraph;
struct ImBuf;
@@ -127,5 +126,3 @@ void RE_bake_ibuf_clear(struct Image *image, const bool is_tangent);
#ifdef __cplusplus
}
#endif
-
-#endif /* __RE_BAKE_H__ */
diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h
index 49d312923e7..41f65fbda5c 100644
--- a/source/blender/render/extern/include/RE_engine.h
+++ b/source/blender/render/extern/include/RE_engine.h
@@ -21,8 +21,7 @@
* \ingroup render
*/
-#ifndef __RE_ENGINE_H__
-#define __RE_ENGINE_H__
+#pragma once
#include "DNA_listBase.h"
#include "DNA_node_types.h"
@@ -244,5 +243,3 @@ void RE_engine_free_blender_memory(struct RenderEngine *engine);
#ifdef __cplusplus
}
#endif
-
-#endif /* __RE_ENGINE_H__ */
diff --git a/source/blender/render/extern/include/RE_multires_bake.h b/source/blender/render/extern/include/RE_multires_bake.h
index 7698ff7d59c..c48ce7bfd6e 100644
--- a/source/blender/render/extern/include/RE_multires_bake.h
+++ b/source/blender/render/extern/include/RE_multires_bake.h
@@ -21,8 +21,7 @@
* \ingroup render
*/
-#ifndef __RE_MULTIRES_BAKE_H__
-#define __RE_MULTIRES_BAKE_H__
+#pragma once
struct MultiresBakeRender;
struct Scene;
@@ -70,5 +69,3 @@ void RE_multires_bake_images(struct MultiresBakeRender *bkr);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index f9d2e915fad..c8cb537af39 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -21,8 +21,7 @@
* \ingroup render
*/
-#ifndef __RE_PIPELINE_H__
-#define __RE_PIPELINE_H__
+#pragma once
#include "DEG_depsgraph.h"
#include "DNA_listBase.h"
@@ -367,8 +366,8 @@ struct RenderPass *RE_pass_find_by_type(volatile struct RenderLayer *rl,
#define RE_BAKE_AO 2
void RE_GetCameraWindow(struct Render *re, struct Object *camera, float mat[4][4]);
-void RE_GetCameraWindowWithOverscan(struct Render *re, float mat[4][4], float overscan);
-void RE_GetCameraModelMatrix(struct Render *re, struct Object *camera, float r_mat[4][4]);
+void RE_GetCameraWindowWithOverscan(struct Render *re, float overscan, float r_winmat[4][4]);
+void RE_GetCameraModelMatrix(struct Render *re, struct Object *camera, float r_modelmat[4][4]);
struct Scene *RE_GetScene(struct Render *re);
void RE_SetScene(struct Render *re, struct Scene *sce);
@@ -392,5 +391,3 @@ RenderResult *RE_DuplicateRenderResult(RenderResult *rr);
#ifdef __cplusplus
}
#endif
-
-#endif /* __RE_PIPELINE_H__ */
diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h
index 7dfba8f668f..76812840c91 100644
--- a/source/blender/render/extern/include/RE_render_ext.h
+++ b/source/blender/render/extern/include/RE_render_ext.h
@@ -20,8 +20,7 @@
* \ingroup render
*/
-#ifndef __RE_RENDER_EXT_H__
-#define __RE_RENDER_EXT_H__
+#pragma once
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* this include is for non-render pipeline exports (still old cruft here) */
@@ -79,5 +78,3 @@ void RE_point_density_fix_linking(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __RE_RENDER_EXT_H__ */
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index f69ae4dfd5c..dc41afee938 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -20,8 +20,7 @@
* \ingroup render
*/
-#ifndef __RE_SHADER_EXT_H__
-#define __RE_SHADER_EXT_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -82,5 +81,3 @@ int multitex_nodes(struct Tex *tex,
#ifdef __cplusplus
}
#endif
-
-#endif /* __RE_SHADER_EXT_H__ */
diff --git a/source/blender/render/intern/include/initrender.h b/source/blender/render/intern/include/initrender.h
index ae78ac1dc1b..f5ac352752f 100644
--- a/source/blender/render/intern/include/initrender.h
+++ b/source/blender/render/intern/include/initrender.h
@@ -21,8 +21,7 @@
* \ingroup render
*/
-#ifndef __INITRENDER_H__
-#define __INITRENDER_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -37,5 +36,3 @@ void RE_parts_clamp(Render *re);
#ifdef __cplusplus
}
#endif
-
-#endif /* __INITRENDER_H__ */
diff --git a/source/blender/render/intern/include/render_result.h b/source/blender/render/intern/include/render_result.h
index 70b358ec5b4..187685cd464 100644
--- a/source/blender/render/intern/include/render_result.h
+++ b/source/blender/render/intern/include/render_result.h
@@ -21,8 +21,7 @@
* \ingroup render
*/
-#ifndef __RENDER_RESULT_H__
-#define __RENDER_RESULT_H__
+#pragma once
#define PASS_VECTOR_MAX 10000.0f
@@ -155,5 +154,3 @@ bool render_result_has_views(struct RenderResult *rr);
#ifdef __cplusplus
}
#endif
-
-#endif /* __RENDER_RESULT_H__ */
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index 14893c9bd1a..6be5fb4792c 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -21,8 +21,7 @@
* \ingroup render
*/
-#ifndef __RENDER_TYPES_H__
-#define __RENDER_TYPES_H__
+#pragma once
/* ------------------------------------------------------------------------- */
/* exposed internal in render module only! */
@@ -167,5 +166,3 @@ struct Render {
#ifdef __cplusplus
}
#endif
-
-#endif /* __RENDER_TYPES_H__ */
diff --git a/source/blender/render/intern/include/renderpipeline.h b/source/blender/render/intern/include/renderpipeline.h
index 3e8864fe56d..062df59bfd3 100644
--- a/source/blender/render/intern/include/renderpipeline.h
+++ b/source/blender/render/intern/include/renderpipeline.h
@@ -21,8 +21,7 @@
* \ingroup render
*/
-#ifndef __RENDERPIPELINE_H__
-#define __RENDERPIPELINE_H__
+#pragma once
struct ListBase;
struct Render;
@@ -43,5 +42,3 @@ void render_copy_renderdata(struct RenderData *to, struct RenderData *from);
#ifdef __cplusplus
}
#endif
-
-#endif /* __RENDERPIPELINE_H__ */
diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h
index 1c66cb3f04d..22023baab95 100644
--- a/source/blender/render/intern/include/texture.h
+++ b/source/blender/render/intern/include/texture.h
@@ -21,8 +21,7 @@
* \ingroup render
*/
-#ifndef __TEXTURE_H__
-#define __TEXTURE_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -102,5 +101,3 @@ void image_sample(struct Image *ima,
#ifdef __cplusplus
}
#endif
-
-#endif /* __TEXTURE_H__ */
diff --git a/source/blender/render/intern/include/zbuf.h b/source/blender/render/intern/include/zbuf.h
index d03f997c8f2..b898ff89ae4 100644
--- a/source/blender/render/intern/include/zbuf.h
+++ b/source/blender/render/intern/include/zbuf.h
@@ -18,8 +18,7 @@
* \ingroup render
*/
-#ifndef __ZBUF_H__
-#define __ZBUF_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -47,5 +46,3 @@ void zspan_scanconvert(struct ZSpan *zpan,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c
index 633b9324d9f..075202e8a79 100644
--- a/source/blender/render/intern/source/external_engine.c
+++ b/source/blender/render/intern/source/external_engine.c
@@ -174,7 +174,8 @@ static RenderResult *render_result_from_bake(RenderEngine *engine, int x, int y,
BLI_addtail(&rr->layers, rl);
/* Add render passes. */
- render_layer_add_pass(rr, rl, engine->bake.depth, RE_PASSNAME_COMBINED, "", "RGBA");
+ RenderPass *result_pass = render_layer_add_pass(
+ rr, rl, engine->bake.depth, RE_PASSNAME_COMBINED, "", "RGBA");
RenderPass *primitive_pass = render_layer_add_pass(rr, rl, 4, "BakePrimitive", "", "RGBA");
RenderPass *differential_pass = render_layer_add_pass(rr, rl, 4, "BakeDifferential", "", "RGBA");
@@ -210,6 +211,15 @@ static RenderResult *render_result_from_bake(RenderEngine *engine, int x, int y,
}
}
+ /* Initialize tile render result from full image bake result. */
+ for (int ty = 0; ty < h; ty++) {
+ size_t offset = ty * w * engine->bake.depth;
+ size_t bake_offset = ((y + ty) * engine->bake.width + x) * engine->bake.depth;
+ size_t size = w * engine->bake.depth * sizeof(float);
+
+ memcpy(result_pass->rect + offset, engine->bake.result + bake_offset, size);
+ }
+
return rr;
}
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index 7b28728cfe7..188bdab316c 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -491,7 +491,7 @@ static float clipx_rctf(rctf *rf, float x1, float x2)
rf->xmin = rf->xmax;
return 0.0;
}
- else if (size != 0.0f) {
+ if (size != 0.0f) {
return BLI_rctf_size_x(rf) / size;
}
return 1.0;
@@ -514,7 +514,7 @@ static float clipy_rctf(rctf *rf, float y1, float y2)
rf->ymin = rf->ymax;
return 0.0;
}
- else if (size != 0.0f) {
+ if (size != 0.0f) {
return BLI_rctf_size_y(rf) / size;
}
return 1.0;
@@ -888,7 +888,7 @@ static void ewa_read_pixel_cb(void *userdata, int x, int y, float result[4])
static void ewa_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD)
{
ReadEWAData data;
- float uv[2] = {fx, fy};
+ const float uv[2] = {fx, fy};
data.ibuf = ibuf;
data.AFD = AFD;
BLI_ewa_filter(ibuf->x,
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 2e9f30397db..d631dd1a2ff 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -211,14 +211,14 @@ void RE_SetCamera(Render *re, Object *cam_ob)
re_camera_params_get(re, &params);
}
-void RE_GetCameraWindow(struct Render *re, struct Object *camera, float mat[4][4])
+void RE_GetCameraWindow(struct Render *re, struct Object *camera, float r_winmat[4][4])
{
RE_SetCamera(re, camera);
- copy_m4_m4(mat, re->winmat);
+ copy_m4_m4(r_winmat, re->winmat);
}
/* Must be called after RE_GetCameraWindow(), does not change re->winmat. */
-void RE_GetCameraWindowWithOverscan(struct Render *re, float mat[4][4], float overscan)
+void RE_GetCameraWindowWithOverscan(struct Render *re, float overscan, float r_winmat[4][4])
{
CameraParams params;
params.is_ortho = re->winmat[3][3] != 0.0f;
@@ -233,12 +233,12 @@ void RE_GetCameraWindowWithOverscan(struct Render *re, float mat[4][4], float ov
params.viewplane.ymin -= overscan;
params.viewplane.ymax += overscan;
BKE_camera_params_compute_matrix(&params);
- copy_m4_m4(mat, params.winmat);
+ copy_m4_m4(r_winmat, params.winmat);
}
-void RE_GetCameraModelMatrix(Render *re, struct Object *camera, float r_mat[4][4])
+void RE_GetCameraModelMatrix(Render *re, struct Object *camera, float r_modelmat[4][4])
{
- BKE_camera_multiview_model_matrix(&re->r, camera, re->viewname, r_mat);
+ BKE_camera_multiview_model_matrix(&re->r, camera, re->viewname, r_modelmat);
}
/* ~~~~~~~~~~~~~~~~ part (tile) calculus ~~~~~~~~~~~~~~~~~~~~~~ */
diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c
index b30821a1b73..f12b425ee8b 100644
--- a/source/blender/render/intern/source/multires_bake.c
+++ b/source/blender/render/intern/source/multires_bake.c
@@ -157,7 +157,7 @@ static void init_bake_rast(MBakeRast *bake_rast,
static void flush_pixel(const MResolvePixelData *data, const int x, const int y)
{
- float st[2] = {(x + 0.5f) / data->w, (y + 0.5f) / data->h};
+ const float st[2] = {(x + 0.5f) / data->w, (y + 0.5f) / data->h};
const float *st0, *st1, *st2;
const float *tang0, *tang1, *tang2;
float no0[3], no1[3], no2[3];
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index ade80898131..3236026c69f 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -281,9 +281,8 @@ RenderLayer *RE_GetRenderLayer(RenderResult *rr, const char *name)
if (rr == NULL) {
return NULL;
}
- else {
- return BLI_findstring(&rr->layers, name, offsetof(RenderLayer, name));
- }
+
+ return BLI_findstring(&rr->layers, name, offsetof(RenderLayer, name));
}
bool RE_HasSingleLayer(Render *re)
@@ -1655,9 +1654,8 @@ static bool check_valid_compositing_camera(Scene *scene, Object *camera_override
return true;
}
- else {
- return (camera_override != NULL || scene->camera != NULL);
- }
+
+ return (camera_override != NULL || scene->camera != NULL);
}
static bool check_valid_camera_multiview(Scene *scene, Object *camera, ReportList *reports)
@@ -1755,7 +1753,7 @@ static bool node_tree_has_composite_output(bNodeTree *ntree)
if (ELEM(node->type, CMP_NODE_COMPOSITE, CMP_NODE_OUTPUT_FILE)) {
return true;
}
- else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
+ if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
if (node->id) {
if (node_tree_has_composite_output((bNodeTree *)node->id)) {
return true;
@@ -1879,14 +1877,14 @@ const char *RE_GetActiveRenderView(Render *re)
}
/* evaluating scene options for general Blender render */
-static int render_initialize_from_main(Render *re,
- const RenderData *rd,
- Main *bmain,
- Scene *scene,
- ViewLayer *single_layer,
- Object *camera_override,
- int anim,
- int anim_init)
+static int render_init_from_main(Render *re,
+ const RenderData *rd,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *single_layer,
+ Object *camera_override,
+ int anim,
+ int anim_init)
{
int winx, winy;
rcti disprect;
@@ -2004,8 +2002,7 @@ void RE_RenderFrame(Render *re,
scene->r.cfra = frame;
- if (render_initialize_from_main(
- re, &scene->r, bmain, scene, single_layer, camera_override, 0, 0)) {
+ if (render_init_from_main(re, &scene->r, bmain, scene, single_layer, camera_override, 0, 0)) {
const RenderData rd = scene->r;
MEM_reset_peak_memory();
@@ -2058,7 +2055,7 @@ void RE_RenderFrame(Render *re,
void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene, int render)
{
re->result_ok = 0;
- if (render_initialize_from_main(re, &scene->r, bmain, scene, NULL, NULL, 0, 0)) {
+ if (render_init_from_main(re, &scene->r, bmain, scene, NULL, NULL, 0, 0)) {
if (render) {
do_render_3d(re);
}
@@ -2422,7 +2419,7 @@ void RE_RenderAnim(Render *re,
(rd.im_format.views_format == R_IMF_VIEWS_INDIVIDUAL));
/* do not fully call for each frame, it initializes & pops output window */
- if (!render_initialize_from_main(re, &rd, bmain, scene, single_layer, camera_override, 0, 1)) {
+ if (!render_init_from_main(re, &rd, bmain, scene, single_layer, camera_override, 0, 1)) {
return;
}
@@ -2501,15 +2498,14 @@ void RE_RenderAnim(Render *re,
render_update_depsgraph(re);
/* only border now, todo: camera lens. (ton) */
- render_initialize_from_main(re, &rd, bmain, scene, single_layer, camera_override, 1, 0);
+ render_init_from_main(re, &rd, bmain, scene, single_layer, camera_override, 1, 0);
if (nfra != scene->r.cfra) {
/* Skip this frame, but could update for physics and particles system. */
continue;
}
- else {
- nfra += tfra;
- }
+
+ nfra += tfra;
/* Touch/NoOverwrite options are only valid for image's */
if (is_movie == false) {
@@ -2783,7 +2779,7 @@ void RE_layer_load_from_file(
IMB_float_from_rect(ibuf);
}
- memcpy(rpass->rect, ibuf->rect_float, sizeof(float) * 4 * layer->rectx * layer->recty);
+ memcpy(rpass->rect, ibuf->rect_float, sizeof(float[4]) * layer->rectx * layer->recty);
}
else {
if ((ibuf->x - x >= layer->rectx) && (ibuf->y - y >= layer->recty)) {
@@ -2798,7 +2794,7 @@ void RE_layer_load_from_file(
IMB_rectcpy(ibuf_clip, ibuf, 0, 0, x, y, layer->rectx, layer->recty);
memcpy(
- rpass->rect, ibuf_clip->rect_float, sizeof(float) * 4 * layer->rectx * layer->recty);
+ rpass->rect, ibuf_clip->rect_float, sizeof(float[4]) * layer->rectx * layer->recty);
IMB_freeImBuf(ibuf_clip);
}
else {
@@ -2864,7 +2860,7 @@ RenderPass *RE_pass_find_by_name(volatile RenderLayer *rl, const char *name, con
if (viewname == NULL || viewname[0] == '\0') {
break;
}
- else if (STREQ(rp->view, viewname)) {
+ if (STREQ(rp->view, viewname)) {
break;
}
}
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index 8daad33b477..12b80da9f59 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -557,7 +557,7 @@ static float density_falloff(PointDensityRangeData *pdr, int index, float square
}
if (pdr->density_curve && dist != 0.0f) {
- BKE_curvemapping_initialize(pdr->density_curve);
+ BKE_curvemapping_init(pdr->density_curve);
density = BKE_curvemapping_evaluateF(pdr->density_curve, 0, density / dist) * dist;
}
@@ -770,7 +770,7 @@ static void pointdensity_color(
static void sample_dummy_point_density(int resolution, float *values)
{
- memset(values, 0, sizeof(float) * 4 * resolution * resolution * resolution);
+ memset(values, 0, sizeof(float[4]) * resolution * resolution * resolution);
}
static void particle_system_minmax(Depsgraph *depsgraph,
@@ -868,7 +868,7 @@ void RE_point_density_minmax(struct Depsgraph *depsgraph,
particle_system_minmax(depsgraph, scene, object, psys, pd->radius, r_min, r_max);
}
else {
- float radius[3] = {pd->radius, pd->radius, pd->radius};
+ const float radius[3] = {pd->radius, pd->radius, pd->radius};
BoundBox *bb = BKE_object_boundbox_get(object);
if (bb != NULL) {
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index 4b74bfb3e5c..ef44c896a25 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -475,7 +475,7 @@ RenderResult *render_result_new(Render *re,
const char *view = rv->name;
if (viewname && viewname[0]) {
- if (strcmp(view, viewname) != 0) {
+ if (!STREQ(view, viewname)) {
continue;
}
}
@@ -709,7 +709,7 @@ static int order_render_passes(const void *a, const void *b)
if (passtype_a > passtype_b) {
return 1;
}
- else if (passtype_a < passtype_b) {
+ if (passtype_a < passtype_b) {
return 0;
}
}
@@ -728,7 +728,7 @@ static int order_render_passes(const void *a, const void *b)
if (STREQ(rpa->view, STEREO_LEFT_NAME)) {
return 0;
}
- else if (STREQ(rpb->view, STEREO_LEFT_NAME)) {
+ if (STREQ(rpb->view, STEREO_LEFT_NAME)) {
return 1;
}
@@ -736,7 +736,7 @@ static int order_render_passes(const void *a, const void *b)
if (STREQ(rpa->view, STEREO_RIGHT_NAME)) {
return 0;
}
- else if (STREQ(rpb->view, STEREO_RIGHT_NAME)) {
+ if (STREQ(rpb->view, STEREO_RIGHT_NAME)) {
return 1;
}
@@ -877,7 +877,7 @@ void render_result_merge(RenderResult *rr, RenderResult *rrpart)
continue;
}
/* Renderresult have all passes, renderpart only the active view's passes. */
- if (strcmp(rpassp->fullname, rpass->fullname) != 0) {
+ if (!STREQ(rpassp->fullname, rpass->fullname)) {
continue;
}
@@ -930,9 +930,8 @@ bool RE_WriteRenderResult(ReportList *reports,
if (!STREQ(view, viewname)) {
continue;
}
- else {
- viewname = "";
- }
+
+ viewname = "";
}
/* Skip compositing if only a single other layer is requested. */
@@ -993,9 +992,8 @@ bool RE_WriteRenderResult(ReportList *reports,
if (!STREQ(view, viewname)) {
continue;
}
- else {
- viewname = "";
- }
+
+ viewname = "";
}
/* We only store RGBA passes as half float, for
@@ -1509,10 +1507,10 @@ void RE_render_result_rect_from_ibuf(RenderResult *rr,
rr->have_combined = true;
if (!rv->rectf) {
- rv->rectf = MEM_mallocN(4 * sizeof(float) * rr->rectx * rr->recty, "render_seq rectf");
+ rv->rectf = MEM_mallocN(sizeof(float[4]) * rr->rectx * rr->recty, "render_seq rectf");
}
- memcpy(rv->rectf, ibuf->rect_float, 4 * sizeof(float) * rr->rectx * rr->recty);
+ memcpy(rv->rectf, ibuf->rect_float, sizeof(float[4]) * rr->rectx * rr->recty);
/* TSK! Since sequence render doesn't free the *rr render result, the old rect32
* can hang around when sequence render has rendered a 32 bits one before */
@@ -1537,7 +1535,7 @@ void render_result_rect_fill_zero(RenderResult *rr, const int view_id)
RenderView *rv = RE_RenderViewGetById(rr, view_id);
if (rv->rectf) {
- memset(rv->rectf, 0, 4 * sizeof(float) * rr->rectx * rr->recty);
+ memset(rv->rectf, 0, sizeof(float[4]) * rr->rectx * rr->recty);
}
else if (rv->rect32) {
memset(rv->rect32, 0, 4 * rr->rectx * rr->recty);
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index b37eeed3681..e5c62dbd784 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -1381,20 +1381,19 @@ static int multitex_nodes_intern(Tex *tex,
return rgbnor;
}
- else {
- return multitex(tex,
- texvec,
- dxt,
- dyt,
- osatex,
- texres,
- thread,
- which_output,
- pool,
- skip_load_image,
- texnode_preview,
- use_nodes);
- }
+
+ return multitex(tex,
+ texvec,
+ dxt,
+ dyt,
+ osatex,
+ texres,
+ thread,
+ which_output,
+ pool,
+ skip_load_image,
+ texnode_preview,
+ use_nodes);
}
/* this is called from the shader and texture nodes
diff --git a/source/blender/shader_fx/FX_shader_types.h b/source/blender/shader_fx/FX_shader_types.h
index f338f9bcc2a..54d3f98bdd4 100644
--- a/source/blender/shader_fx/FX_shader_types.h
+++ b/source/blender/shader_fx/FX_shader_types.h
@@ -18,8 +18,7 @@
* \ingroup shader_fx
*/
-#ifndef __FX_SHADER_TYPES_H__
-#define __FX_SHADER_TYPES_H__
+#pragma once
#include "BKE_shader_fx.h"
@@ -38,5 +37,3 @@ extern ShaderFxTypeInfo shaderfx_Type_Wave;
/* FX_shaderfx_util.c */
void shaderfx_type_init(ShaderFxTypeInfo *types[]);
-
-#endif /* __FX_SHADER_TYPES_H__ */
diff --git a/source/blender/shader_fx/intern/FX_shader_util.h b/source/blender/shader_fx/intern/FX_shader_util.h
index 8ff5a6c0d0e..9617cfd2ee0 100644
--- a/source/blender/shader_fx/intern/FX_shader_util.h
+++ b/source/blender/shader_fx/intern/FX_shader_util.h
@@ -21,7 +21,4 @@
* \ingroup shader_fx
*/
-#ifndef __FX_SHADER_UTIL_H__
-#define __FX_SHADER_UTIL_H__
-
-#endif /* __FX_SHADER_UTIL_H__ */
+#pragma once
diff --git a/source/blender/shader_fx/intern/FX_ui_common.h b/source/blender/shader_fx/intern/FX_ui_common.h
index 877855b98e4..ce3038776ba 100644
--- a/source/blender/shader_fx/intern/FX_ui_common.h
+++ b/source/blender/shader_fx/intern/FX_ui_common.h
@@ -18,8 +18,7 @@
* \ingroup modifiers
*/
-#ifndef __FX_UI_COMMON_H__
-#define __FX_UI_COMMON_H__
+#pragma once
#include "FX_shader_types.h"
@@ -52,5 +51,3 @@ struct PanelType *shaderfx_subpanel_register(struct ARegionType *region_type,
#ifdef __cplusplus
}
#endif
-
-#endif /* __FX_UI_COMMON_H__ */
diff --git a/source/blender/simulation/SIM_mass_spring.h b/source/blender/simulation/SIM_mass_spring.h
index d30a7160fd8..219ead477c2 100644
--- a/source/blender/simulation/SIM_mass_spring.h
+++ b/source/blender/simulation/SIM_mass_spring.h
@@ -21,8 +21,7 @@
* \ingroup bph
*/
-#ifndef __SIM_MASS_SPRING_H__
-#define __SIM_MASS_SPRING_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -58,5 +57,3 @@ void SIM_cloth_solver_set_volume(ClothModifierData *clmd);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/simulation/SIM_simulation_update.hh b/source/blender/simulation/SIM_simulation_update.hh
index efdfde8a4de..7c2726f038e 100644
--- a/source/blender/simulation/SIM_simulation_update.hh
+++ b/source/blender/simulation/SIM_simulation_update.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __SIM_SIMULATION_UPDATE_HH__
-#define __SIM_SIMULATION_UPDATE_HH__
+#pragma once
struct Depsgraph;
struct Scene;
@@ -30,5 +29,3 @@ void update_simulation_in_depsgraph(Depsgraph *depsgraph,
bool update_simulation_dependencies(Simulation *simulation);
} // namespace blender::sim
-
-#endif /* __SIM_SIMULATION_UPDATE_HH__ */
diff --git a/source/blender/simulation/intern/ConstrainedConjugateGradient.h b/source/blender/simulation/intern/ConstrainedConjugateGradient.h
index c924490f97d..b0f2bb037d2 100644
--- a/source/blender/simulation/intern/ConstrainedConjugateGradient.h
+++ b/source/blender/simulation/intern/ConstrainedConjugateGradient.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __CONSTRAINEDCONJUGATEGRADIENT_H__
-#define __CONSTRAINEDCONJUGATEGRADIENT_H__
+#pragma once
#include <Eigen/Core>
@@ -331,5 +330,3 @@ struct solve_retval<ConstrainedConjugateGradient<_MatrixType, _UpLo, _Filter, _P
} // end namespace internal
} // end namespace Eigen
-
-#endif // __CONSTRAINEDCONJUGATEGRADIENT_H__
diff --git a/source/blender/simulation/intern/eigen_utils.h b/source/blender/simulation/intern/eigen_utils.h
index c186cf567df..897ba8b2a67 100644
--- a/source/blender/simulation/intern/eigen_utils.h
+++ b/source/blender/simulation/intern/eigen_utils.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __EIGEN_UTILS_H__
-#define __EIGEN_UTILS_H__
+#pragma once
/** \file
* \ingroup bph
@@ -232,5 +231,3 @@ BLI_INLINE void print_lmatrix(const lMatrix &m)
printf("\n");
}
}
-
-#endif
diff --git a/source/blender/simulation/intern/hair_volume.cpp b/source/blender/simulation/intern/hair_volume.cpp
index c80ae69ce73..c24b7154d13 100644
--- a/source/blender/simulation/intern/hair_volume.cpp
+++ b/source/blender/simulation/intern/hair_volume.cpp
@@ -710,9 +710,8 @@ BLI_INLINE float hair_volume_density_divergence(float density,
if (density > density_threshold && density > target_density) {
return strength * logf(target_density / density);
}
- else {
- return 0.0f;
- }
+
+ return 0.0f;
}
bool SIM_hair_volume_solve_divergence(HairGrid *grid,
@@ -1030,14 +1029,13 @@ bool SIM_hair_volume_solve_divergence(HairGrid *grid,
return true;
}
- else {
- /* Clear result in case of error */
- for (i = 0, vert = grid->verts; i < num_cells; i++, vert++) {
- zero_v3(vert->velocity_smooth);
- }
- return false;
+ /* Clear result in case of error */
+ for (i = 0, vert = grid->verts; i < num_cells; i++, vert++) {
+ zero_v3(vert->velocity_smooth);
}
+
+ return false;
}
#if 0 /* XXX weighting is incorrect, disabled for now */
diff --git a/source/blender/simulation/intern/implicit.h b/source/blender/simulation/intern/implicit.h
index 17dfb8b88b9..a3c8e5f34c4 100644
--- a/source/blender/simulation/intern/implicit.h
+++ b/source/blender/simulation/intern/implicit.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __IMPLICIT_H__
-#define __IMPLICIT_H__
+#pragma once
/** \file
* \ingroup bph
@@ -268,5 +267,3 @@ void SIM_hair_volume_vertex_grid_forces(struct HairGrid *grid,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/simulation/intern/implicit_blender.c b/source/blender/simulation/intern/implicit_blender.c
index 856572aa3f5..b4912492678 100644
--- a/source/blender/simulation/intern/implicit_blender.c
+++ b/source/blender/simulation/intern/implicit_blender.c
@@ -98,7 +98,7 @@ DO_INLINE void mul_fvector_S(float to[3], const float from[3], float scalar)
}
/* simple v^T * v product ("outer product") */
/* STATUS: HAS TO BE verified (*should* work) */
-DO_INLINE void mul_fvectorT_fvector(float to[3][3], float vectorA[3], float vectorB[3])
+DO_INLINE void mul_fvectorT_fvector(float to[3][3], const float vectorA[3], const float vectorB[3])
{
mul_fvector_S(to[0], vectorB, vectorA[0]);
mul_fvector_S(to[1], vectorB, vectorA[1]);
@@ -156,7 +156,7 @@ DO_INLINE void cp_lfvector(float (*to)[3], float (*from)[3], unsigned int verts)
memcpy(to, from, verts * sizeof(lfVector));
}
/* init long vector with float[3] */
-DO_INLINE void init_lfvector(float (*fLongVector)[3], float vector[3], unsigned int verts)
+DO_INLINE void init_lfvector(float (*fLongVector)[3], const float vector[3], unsigned int verts)
{
unsigned int i = 0;
for (i = 0; i < verts; i++) {
@@ -360,9 +360,9 @@ static void print_bfmatrix(fmatrix3x3 *m)
# endif
/* copy 3x3 matrix */
-DO_INLINE void cp_fmatrix(float to[3][3], float from[3][3])
+DO_INLINE void cp_fmatrix(float to[3][3], const float from[3][3])
{
- // memcpy(to, from, sizeof (float) * 9);
+ // memcpy(to, from, sizeof(float[3][3]));
copy_v3_v3(to[0], from[0]);
copy_v3_v3(to[1], from[1]);
copy_v3_v3(to[2], from[2]);
@@ -429,7 +429,7 @@ DO_INLINE void mul_fmatrix_S(float matrix[3][3], float scalar)
/* a vector multiplied by a 3x3 matrix */
/* STATUS: verified */
-DO_INLINE void mul_fvector_fmatrix(float *to, const float *from, float matrix[3][3])
+DO_INLINE void mul_fvector_fmatrix(float *to, const float *from, const float matrix[3][3])
{
to[0] = matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2];
to[1] = matrix[0][1] * from[0] + matrix[1][1] * from[1] + matrix[2][1] * from[2];
@@ -438,14 +438,16 @@ DO_INLINE void mul_fvector_fmatrix(float *to, const float *from, float matrix[3]
/* 3x3 matrix multiplied by a vector */
/* STATUS: verified */
-DO_INLINE void mul_fmatrix_fvector(float *to, float matrix[3][3], float from[3])
+DO_INLINE void mul_fmatrix_fvector(float *to, const float matrix[3][3], const float from[3])
{
to[0] = dot_v3v3(matrix[0], from);
to[1] = dot_v3v3(matrix[1], from);
to[2] = dot_v3v3(matrix[2], from);
}
/* 3x3 matrix addition with 3x3 matrix */
-DO_INLINE void add_fmatrix_fmatrix(float to[3][3], float matrixA[3][3], float matrixB[3][3])
+DO_INLINE void add_fmatrix_fmatrix(float to[3][3],
+ const float matrixA[3][3],
+ const float matrixB[3][3])
{
add_v3_v3v3(to[0], matrixA[0], matrixB[0]);
add_v3_v3v3(to[1], matrixA[1], matrixB[1]);
@@ -453,14 +455,16 @@ DO_INLINE void add_fmatrix_fmatrix(float to[3][3], float matrixA[3][3], float ma
}
/* A -= B*x + C*y (3x3 matrix sub-addition with 3x3 matrix) */
DO_INLINE void subadd_fmatrixS_fmatrixS(
- float to[3][3], float matrixA[3][3], float aS, float matrixB[3][3], float bS)
+ float to[3][3], const float matrixA[3][3], float aS, const float matrixB[3][3], float bS)
{
VECSUBADDSS(to[0], matrixA[0], aS, matrixB[0], bS);
VECSUBADDSS(to[1], matrixA[1], aS, matrixB[1], bS);
VECSUBADDSS(to[2], matrixA[2], aS, matrixB[2], bS);
}
/* A = B - C (3x3 matrix subtraction with 3x3 matrix) */
-DO_INLINE void sub_fmatrix_fmatrix(float to[3][3], float matrixA[3][3], float matrixB[3][3])
+DO_INLINE void sub_fmatrix_fmatrix(float to[3][3],
+ const float matrixA[3][3],
+ const float matrixB[3][3])
{
sub_v3_v3v3(to[0], matrixA[0], matrixB[0]);
sub_v3_v3v3(to[1], matrixA[1], matrixB[1]);
@@ -471,14 +475,14 @@ DO_INLINE void sub_fmatrix_fmatrix(float to[3][3], float matrixA[3][3], float ma
/////////////////////////////////////////////////////////////////
/* 3x3 matrix multiplied+added by a vector */
/* STATUS: verified */
-DO_INLINE void muladd_fmatrix_fvector(float to[3], float matrix[3][3], float from[3])
+DO_INLINE void muladd_fmatrix_fvector(float to[3], const float matrix[3][3], const float from[3])
{
to[0] += dot_v3v3(matrix[0], from);
to[1] += dot_v3v3(matrix[1], from);
to[2] += dot_v3v3(matrix[2], from);
}
-DO_INLINE void muladd_fmatrixT_fvector(float to[3], float matrix[3][3], const float from[3])
+DO_INLINE void muladd_fmatrixT_fvector(float to[3], const float matrix[3][3], const float from[3])
{
to[0] += matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2];
to[1] += matrix[0][1] * from[0] + matrix[1][1] * from[1] + matrix[2][1] * from[2];
@@ -492,7 +496,7 @@ BLI_INLINE void outerproduct(float r[3][3], const float a[3], const float b[3])
mul_v3_v3fl(r[2], a, b[2]);
}
-BLI_INLINE void cross_m3_v3m3(float r[3][3], const float v[3], float m[3][3])
+BLI_INLINE void cross_m3_v3m3(float r[3][3], const float v[3], const float m[3][3])
{
cross_v3_v3v3(r[0], v, m[0]);
cross_v3_v3v3(r[1], v, m[1]);
@@ -512,7 +516,7 @@ BLI_INLINE void cross_v3_identity(float r[3][3], const float v[3])
r[2][2] = 0.0f;
}
-BLI_INLINE void madd_m3_m3fl(float r[3][3], float m[3][3], float f)
+BLI_INLINE void madd_m3_m3fl(float r[3][3], const float m[3][3], float f)
{
r[0][0] += m[0][0] * f;
r[0][1] += m[0][1] * f;
@@ -744,7 +748,10 @@ BLI_INLINE void root_to_world_v3(Implicit_Data *data, int index, float r[3], con
mul_v3_m3v3(r, data->tfm[index].m, v);
}
-BLI_INLINE void world_to_root_m3(Implicit_Data *data, int index, float r[3][3], float m[3][3])
+BLI_INLINE void world_to_root_m3(Implicit_Data *data,
+ int index,
+ float r[3][3],
+ const float m[3][3])
{
float trot[3][3];
copy_m3_m3(trot, data->tfm[index].m);
@@ -752,7 +759,10 @@ BLI_INLINE void world_to_root_m3(Implicit_Data *data, int index, float r[3][3],
mul_m3_m3m3(r, trot, m);
}
-BLI_INLINE void root_to_world_m3(Implicit_Data *data, int index, float r[3][3], float m[3][3])
+BLI_INLINE void root_to_world_m3(Implicit_Data *data,
+ int index,
+ float r[3][3],
+ const float m[3][3])
{
mul_m3_m3m3(r, data->tfm[index].m, m);
}
@@ -1469,7 +1479,7 @@ void SIM_mass_spring_force_face_wind(
Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3])
{
const float effector_scale = 0.02f;
- int vs[3] = {v1, v2, v3};
+ const int vs[3] = {v1, v2, v3};
float win[3], nor[3], area;
float factor, base_force;
float force[3];
@@ -1509,7 +1519,7 @@ void SIM_mass_spring_force_face_extern(
Implicit_Data *data, int v1, int v2, int v3, const float (*forcevec)[3])
{
const float effector_scale = 0.02f;
- int vs[3] = {v1, v2, v3};
+ const int vs[3] = {v1, v2, v3};
float nor[3], area;
float factor, base_force[3];
float force[3][3];
@@ -1711,9 +1721,8 @@ BLI_INLINE float fbstar(float length, float L, float kb, float cb)
if (tempfb_fl < fbstar_fl) {
return fbstar_fl;
}
- else {
- return tempfb_fl;
- }
+
+ return tempfb_fl;
}
// function to calculae bending spring force (taken from Choi & Co)
@@ -1725,9 +1734,8 @@ BLI_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
if (tempfb_fl < fbstar_fl) {
return -cb;
}
- else {
- return -kb * fbderiv(length, L);
- }
+
+ return -kb * fbderiv(length, L);
}
/* calculate elonglation */
@@ -1763,8 +1771,12 @@ BLI_INLINE bool spring_length(Implicit_Data *data,
return true;
}
-BLI_INLINE void apply_spring(
- Implicit_Data *data, int i, int j, const float f[3], float dfdx[3][3], float dfdv[3][3])
+BLI_INLINE void apply_spring(Implicit_Data *data,
+ int i,
+ int j,
+ const float f[3],
+ const float dfdx[3][3],
+ const float dfdv[3][3])
{
int block_ij = SIM_mass_spring_add_block(data, i, j);
@@ -1864,9 +1876,8 @@ bool SIM_mass_spring_force_spring_bending(
return true;
}
- else {
- return false;
- }
+
+ return false;
}
BLI_INLINE void poly_avg(lfVector *data, const int *inds, int len, float r_avg[3])
@@ -1902,7 +1913,7 @@ BLI_INLINE void edge_norm(lfVector *data, int i, int j, float r_dir[3])
normalize_v3(r_dir);
}
-BLI_INLINE float bend_angle(float dir_a[3], float dir_b[3], float dir_e[3])
+BLI_INLINE float bend_angle(const float dir_a[3], const float dir_b[3], const float dir_e[3])
{
float cos, sin;
float tmp[3];
@@ -2352,9 +2363,8 @@ bool SIM_mass_spring_force_spring_goal(Implicit_Data *data,
return true;
}
- else {
- return false;
- }
+
+ return false;
}
#endif /* IMPLICIT_SOLVER_BLENDER */
diff --git a/source/blender/simulation/intern/particle_allocator.cc b/source/blender/simulation/intern/particle_allocator.cc
index e47a6354d81..91ca667a239 100644
--- a/source/blender/simulation/intern/particle_allocator.cc
+++ b/source/blender/simulation/intern/particle_allocator.cc
@@ -71,9 +71,9 @@ fn::MutableAttributesRef ParticleAllocator::allocate(int size)
}
else if (name == "Hash") {
MutableSpan<int> hashes = attributes.get<int>("Hash");
- RandomNumberGenerator rng(hash_seed_ ^ (uint32_t)next_id_);
+ RandomNumberGenerator rng(hash_seed_ ^ static_cast<uint32_t>(next_id_));
for (int pindex : IndexRange(size)) {
- hashes[pindex] = (int)rng.get_uint32();
+ hashes[pindex] = static_cast<int>(rng.get_uint32());
}
}
else {
diff --git a/source/blender/simulation/intern/particle_allocator.hh b/source/blender/simulation/intern/particle_allocator.hh
index 1c412508fe6..c0bbdb845d9 100644
--- a/source/blender/simulation/intern/particle_allocator.hh
+++ b/source/blender/simulation/intern/particle_allocator.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __SIM_PARTICLE_ALLOCATOR_HH__
-#define __SIM_PARTICLE_ALLOCATOR_HH__
+#pragma once
#include "BLI_array.hh"
#include "BLI_vector.hh"
@@ -97,5 +96,3 @@ class ParticleAllocator : NonCopyable, NonMovable {
};
} // namespace blender::sim
-
-#endif /* __SIM_PARTICLE_ALLOCATOR_HH__ */
diff --git a/source/blender/simulation/intern/particle_function.cc b/source/blender/simulation/intern/particle_function.cc
index 035e6d50e21..69977eb2054 100644
--- a/source/blender/simulation/intern/particle_function.cc
+++ b/source/blender/simulation/intern/particle_function.cc
@@ -102,9 +102,8 @@ fn::GVSpan ParticleFunctionEvaluator::get(int output_index, StringRef expected_n
if (particle_fn_.output_is_global_[output_index]) {
return fn::GVSpan::FromSingleWithMaxSize(type, buffer);
}
- else {
- return fn::GVSpan(fn::GSpan(type, buffer, mask_.min_array_size()));
- }
+
+ return fn::GVSpan(fn::GSpan(type, buffer, mask_.min_array_size()));
}
void ParticleFunctionEvaluator::compute_globals()
diff --git a/source/blender/simulation/intern/particle_function.hh b/source/blender/simulation/intern/particle_function.hh
index c9b35640b47..ead4e6f3c31 100644
--- a/source/blender/simulation/intern/particle_function.hh
+++ b/source/blender/simulation/intern/particle_function.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __SIM_PARTICLE_FUNCTION_HH__
-#define __SIM_PARTICLE_FUNCTION_HH__
+#pragma once
#include "FN_attributes_ref.hh"
#include "FN_multi_function.hh"
@@ -93,5 +92,3 @@ class ParticleFunctionEvaluator {
};
} // namespace blender::sim
-
-#endif /* __SIM_PARTICLE_FUNCTION_HH__ */
diff --git a/source/blender/simulation/intern/particle_mesh_emitter.cc b/source/blender/simulation/intern/particle_mesh_emitter.cc
index c1482a29cb7..3d43d4d8001 100644
--- a/source/blender/simulation/intern/particle_mesh_emitter.cc
+++ b/source/blender/simulation/intern/particle_mesh_emitter.cc
@@ -233,14 +233,14 @@ static BLI_NOINLINE bool compute_new_particle_attributes(ParticleEmitterContext
if (settings.object->type != OB_MESH) {
return false;
}
- Mesh &mesh = *(Mesh *)settings.object->data;
+ Mesh &mesh = *static_cast<Mesh *>(settings.object->data);
if (mesh.totvert == 0) {
return false;
}
const float start_time = context.emit_interval.start();
const uint32_t seed = DefaultHash<StringRef>{}(state.head.name);
- RandomNumberGenerator rng{(*(uint32_t *)&start_time) ^ seed};
+ RandomNumberGenerator rng{*reinterpret_cast<const uint32_t *>(&start_time) ^ seed};
compute_birth_times(settings.rate, context.emit_interval, state, r_birth_times);
const int particle_amount = r_birth_times.size();
@@ -346,6 +346,16 @@ void ParticleMeshEmitter::emit(ParticleEmitterContext &context) const
attributes.get<float3>("Position").copy_from(new_positions);
attributes.get<float3>("Velocity").copy_from(new_velocities);
attributes.get<float>("Birth Time").copy_from(new_birth_times);
+
+ if (action_ != nullptr) {
+ ParticleChunkContext particles{
+ *context.solve_context.state_map.lookup<ParticleSimulationState>(name),
+ IndexRange(amount),
+ attributes,
+ nullptr};
+ ParticleActionContext action_context{context.solve_context, particles};
+ action_->execute(action_context);
+ }
}
}
diff --git a/source/blender/simulation/intern/particle_mesh_emitter.hh b/source/blender/simulation/intern/particle_mesh_emitter.hh
index 601697c9986..cdcf2a34e16 100644
--- a/source/blender/simulation/intern/particle_mesh_emitter.hh
+++ b/source/blender/simulation/intern/particle_mesh_emitter.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __SIM_PARTICLE_MESH_EMITTER_HH__
-#define __SIM_PARTICLE_MESH_EMITTER_HH__
+#pragma once
#include "simulation_solver_influences.hh"
@@ -28,14 +27,17 @@ class ParticleMeshEmitter final : public ParticleEmitter {
std::string own_state_name_;
Array<std::string> particle_names_;
const fn::MultiFunction &inputs_fn_;
+ const ParticleAction *action_;
public:
ParticleMeshEmitter(std::string own_state_name,
Array<std::string> particle_names,
- const fn::MultiFunction &inputs_fn)
+ const fn::MultiFunction &inputs_fn,
+ const ParticleAction *action)
: own_state_name_(std::move(own_state_name)),
particle_names_(particle_names),
- inputs_fn_(inputs_fn)
+ inputs_fn_(inputs_fn),
+ action_(action)
{
}
@@ -45,5 +47,3 @@ class ParticleMeshEmitter final : public ParticleEmitter {
};
} // namespace blender::sim
-
-#endif /* __SIM_PARTICLE_MESH_EMITTER_HH__ */
diff --git a/source/blender/simulation/intern/simulation_collect_influences.cc b/source/blender/simulation/intern/simulation_collect_influences.cc
index 4d339f9e323..818415e5d88 100644
--- a/source/blender/simulation/intern/simulation_collect_influences.cc
+++ b/source/blender/simulation/intern/simulation_collect_influences.cc
@@ -367,6 +367,17 @@ static const ParticleFunction *create_particle_function_for_inputs(
return &particle_fn;
}
+static const ParticleFunction *create_particle_function_for_inputs(
+ CollectContext &context, Span<const DInputSocket *> dsockets_to_compute)
+{
+ Vector<const MFInputSocket *> sockets_to_compute;
+ for (const DInputSocket *dsocket : dsockets_to_compute) {
+ const MFInputSocket &socket = context.network_map.lookup_dummy(*dsocket);
+ sockets_to_compute.append(&socket);
+ }
+ return create_particle_function_for_inputs(context, sockets_to_compute);
+}
+
class ParticleFunctionForce : public ParticleForce {
private:
const ParticleFunction &particle_fn_;
@@ -401,11 +412,8 @@ static void create_forces_for_particle_simulation(CollectContext &context,
continue;
}
- const MFInputSocket &force_socket = context.network_map.lookup_dummy(
- origin_node.input(0, "Force"));
-
- const ParticleFunction *particle_fn = create_particle_function_for_inputs(context,
- {&force_socket});
+ const ParticleFunction *particle_fn = create_particle_function_for_inputs(
+ context, {&origin_node.input(0, "Force")});
if (particle_fn == nullptr) {
continue;
@@ -434,7 +442,7 @@ static ParticleEmitter *create_particle_emitter(CollectContext &context, const D
return nullptr;
}
- Array<const MFInputSocket *> input_sockets{dnode.inputs().size()};
+ Array<const MFInputSocket *> input_sockets{2};
for (int i : input_sockets.index_range()) {
input_sockets[i] = &context.network_map.lookup_dummy(dnode.input(i));
}
@@ -446,10 +454,13 @@ static ParticleEmitter *create_particle_emitter(CollectContext &context, const D
MultiFunction &inputs_fn = context.resources.construct<MFNetworkEvaluator>(
AT, Span<const MFOutputSocket *>(), input_sockets.as_span());
+ const ParticleAction *birth_action = create_particle_action(
+ context, dnode.input(2, "Execute"), names);
+
StringRefNull own_state_name = get_identifier(context, dnode);
context.required_states.add(own_state_name, SIM_TYPE_NAME_PARTICLE_MESH_EMITTER);
ParticleEmitter &emitter = context.resources.construct<ParticleMeshEmitter>(
- AT, own_state_name, names.as_span(), inputs_fn);
+ AT, own_state_name, names.as_span(), inputs_fn, birth_action);
return &emitter;
}
@@ -490,15 +501,10 @@ static void collect_time_step_events(CollectContext &context)
{
for (const DNode *event_dnode : nodes_by_type(context, "SimulationNodeParticleTimeStepEvent")) {
const DInputSocket &execute_input = event_dnode->input(0);
- if (execute_input.linked_sockets().size() != 1) {
- continue;
- }
-
Array<StringRefNull> particle_names = find_linked_particle_simulations(context,
event_dnode->output(0));
- const DOutputSocket &execute_source = *execute_input.linked_sockets()[0];
- const ParticleAction *action = create_particle_action(context, execute_source, particle_names);
+ const ParticleAction *action = create_particle_action(context, execute_input, particle_names);
if (action == nullptr) {
continue;
}
@@ -570,6 +576,10 @@ class SetParticleAttributeAction : public ParticleAction {
cpp_type_.copy_to_initialized_indices(
value_array.data(), attribute_array->data(), context.particles.index_mask);
}
+
+ if (attribute_name_ == "Velocity") {
+ context.particles.update_diffs_after_velocity_change();
+ }
}
};
@@ -595,21 +605,28 @@ static const ParticleAction *create_set_particle_attribute_action(
CollectContext &context, const DOutputSocket &dsocket, Span<StringRefNull> particle_names)
{
const DNode &dnode = dsocket.node();
+
+ const ParticleAction *previous_action = create_particle_action(
+ context, dnode.input(0), particle_names);
+
MFInputSocket &name_socket = context.network_map.lookup_dummy(dnode.input(1));
MFInputSocket &value_socket = name_socket.node().input(1);
std::optional<Array<std::string>> names = compute_global_string_inputs(context.network_map,
{&name_socket});
if (!names.has_value()) {
- return nullptr;
+ return previous_action;
}
std::string attribute_name = (*names)[0];
+ if (attribute_name.empty()) {
+ return previous_action;
+ }
const CPPType &attribute_type = value_socket.data_type().single_type();
const ParticleFunction *inputs_fn = create_particle_function_for_inputs(context,
{&value_socket});
if (inputs_fn == nullptr) {
- return nullptr;
+ return previous_action;
}
for (StringRef particle_name : particle_names) {
@@ -620,9 +637,6 @@ static const ParticleAction *create_set_particle_attribute_action(
ParticleAction &this_action = context.resources.construct<SetParticleAttributeAction>(
AT, attribute_name, attribute_type, *inputs_fn);
- const ParticleAction *previous_action = create_particle_action(
- context, dnode.input(0), particle_names);
-
return concatenate_actions(context, {previous_action, &this_action});
}
@@ -674,12 +688,18 @@ class ParticleConditionAction : public ParticleAction {
}
if (action_true_ != nullptr) {
- ParticleChunkContext chunk_context{true_indices.as_span(), context.particles.attributes};
+ ParticleChunkContext chunk_context{context.particles.state,
+ true_indices.as_span(),
+ context.particles.attributes,
+ context.particles.integration};
ParticleActionContext action_context{context.solve_context, chunk_context};
action_true_->execute(action_context);
}
if (action_false_ != nullptr) {
- ParticleChunkContext chunk_context{false_indices.as_span(), context.particles.attributes};
+ ParticleChunkContext chunk_context{context.particles.state,
+ false_indices.as_span(),
+ context.particles.attributes,
+ context.particles.integration};
ParticleActionContext action_context{context.solve_context, chunk_context};
action_false_->execute(action_context);
}
@@ -692,10 +712,9 @@ static const ParticleAction *create_particle_condition_action(CollectContext &co
Span<StringRefNull> particle_names)
{
const DNode &dnode = dsocket.node();
- MFInputSocket &condition_socket = context.network_map.lookup_dummy(dnode.input(0));
- const ParticleFunction *inputs_fn = create_particle_function_for_inputs(context,
- {&condition_socket});
+ const ParticleFunction *inputs_fn = create_particle_function_for_inputs(
+ context, {&dnode.input(0, "Condition")});
if (inputs_fn == nullptr) {
return nullptr;
}
@@ -712,17 +731,32 @@ static const ParticleAction *create_particle_condition_action(CollectContext &co
AT, *inputs_fn, true_action, false_action);
}
+class KillParticleAction : public ParticleAction {
+ public:
+ void execute(ParticleActionContext &context) const override
+ {
+ MutableSpan<int> dead_states = context.particles.attributes.get<int>("Dead");
+ for (int i : context.particles.index_mask) {
+ dead_states[i] = true;
+ }
+ }
+};
+
static const ParticleAction *create_particle_action(CollectContext &context,
const DOutputSocket &dsocket,
Span<StringRefNull> particle_names)
{
const DNode &dnode = dsocket.node();
- if (dnode.idname() == "SimulationNodeSetParticleAttribute") {
+ StringRef idname = dnode.idname();
+ if (idname == "SimulationNodeSetParticleAttribute") {
return create_set_particle_attribute_action(context, dsocket, particle_names);
}
- if (dnode.idname() == "SimulationNodeExecuteCondition") {
+ if (idname == "SimulationNodeExecuteCondition") {
return create_particle_condition_action(context, dsocket, particle_names);
}
+ if (idname == "SimulationNodeKillParticle") {
+ return &context.resources.construct<KillParticleAction>(AT);
+ }
return nullptr;
}
@@ -740,6 +774,7 @@ static void initialize_particle_attribute_builders(CollectContext &context)
/* TODO: Use uint32_t, but we don't have a corresponding custom property type. */
attributes_builder.add<int>("Hash", 0);
attributes_builder.add<float>("Birth Time", 0.0f);
+ attributes_builder.add<float>("Radius", 0.02f);
context.influences.particle_attributes_builder.add_new(name, &attributes_builder);
}
}
@@ -752,6 +787,93 @@ static void optimize_function_network(CollectContext &context)
// WM_clipboard_text_set(network.to_dot().c_str(), false);
}
+class AgeReachedEvent : public ParticleEvent {
+ private:
+ std::string attribute_name_;
+ const ParticleFunction &inputs_fn_;
+ const ParticleAction &action_;
+
+ public:
+ AgeReachedEvent(std::string attribute_name,
+ const ParticleFunction &inputs_fn,
+ const ParticleAction &action)
+ : attribute_name_(std::move(attribute_name)), inputs_fn_(inputs_fn), action_(action)
+ {
+ }
+
+ void filter(ParticleEventFilterContext &context) const override
+ {
+ Span<float> birth_times = context.particles.attributes.get<float>("Birth Time");
+ std::optional<Span<int>> has_been_triggered = context.particles.attributes.try_get<int>(
+ attribute_name_);
+ if (!has_been_triggered.has_value()) {
+ return;
+ }
+
+ ParticleFunctionEvaluator evaluator{inputs_fn_, context.solve_context, context.particles};
+ evaluator.compute();
+ VSpan<float> trigger_ages = evaluator.get<float>(0, "Age");
+
+ const float end_time = context.particles.integration->end_time;
+ for (int i : context.particles.index_mask) {
+ if ((*has_been_triggered)[i]) {
+ continue;
+ }
+ const float trigger_age = trigger_ages[i];
+ const float birth_time = birth_times[i];
+ const float trigger_time = birth_time + trigger_age;
+ if (trigger_time > end_time) {
+ continue;
+ }
+
+ const float duration = context.particles.integration->durations[i];
+ TimeInterval interval(end_time - duration, duration);
+ const float time_factor = interval.safe_factor_at_time(trigger_time);
+
+ context.factor_dst[i] = std::max<float>(0.0f, time_factor);
+ }
+ }
+
+ void execute(ParticleActionContext &context) const override
+ {
+ MutableSpan<int> has_been_triggered = context.particles.attributes.get<int>(attribute_name_);
+ for (int i : context.particles.index_mask) {
+ has_been_triggered[i] = 1;
+ }
+ action_.execute(context);
+ }
+};
+
+static void collect_age_reached_events(CollectContext &context)
+{
+ for (const DNode *dnode : nodes_by_type(context, "SimulationNodeAgeReachedEvent")) {
+ const DInputSocket &age_input = dnode->input(0, "Age");
+ const DInputSocket &execute_input = dnode->input(1, "Execute");
+ Array<StringRefNull> particle_names = find_linked_particle_simulations(context,
+ dnode->output(0));
+ const ParticleAction *action = create_particle_action(context, execute_input, particle_names);
+ if (action == nullptr) {
+ continue;
+ }
+ const ParticleFunction *inputs_fn = create_particle_function_for_inputs(context, {&age_input});
+ if (inputs_fn == nullptr) {
+ continue;
+ }
+
+ std::string attribute_name = get_identifier(context, *dnode);
+ const ParticleEvent &event = context.resources.construct<AgeReachedEvent>(
+ AT, attribute_name, *inputs_fn, *action);
+ for (StringRefNull particle_name : particle_names) {
+ const bool added_attribute = context.influences.particle_attributes_builder
+ .lookup_as(particle_name)
+ ->add<int>(attribute_name, 0);
+ if (added_attribute) {
+ context.influences.particle_events.add_as(particle_name, &event);
+ }
+ }
+ }
+}
+
void collect_simulation_influences(Simulation &simulation,
ResourceCollector &resources,
SimulationInfluences &r_influences,
@@ -773,6 +895,7 @@ void collect_simulation_influences(Simulation &simulation,
collect_emitters(context);
collect_birth_events(context);
collect_time_step_events(context);
+ collect_age_reached_events(context);
optimize_function_network(context);
diff --git a/source/blender/simulation/intern/simulation_collect_influences.hh b/source/blender/simulation/intern/simulation_collect_influences.hh
index caf5a8c4ffa..8673a308b04 100644
--- a/source/blender/simulation/intern/simulation_collect_influences.hh
+++ b/source/blender/simulation/intern/simulation_collect_influences.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __SIM_SIMULATION_COLLECT_INFLUENCES_HH__
-#define __SIM_SIMULATION_COLLECT_INFLUENCES_HH__
+#pragma once
#include "NOD_derived_node_tree.hh"
@@ -64,5 +63,3 @@ void collect_simulation_influences(Simulation &simulation,
RequiredStates &r_required_states);
} // namespace blender::sim
-
-#endif /* __SIM_SIMULATION_COLLECT_INFLUENCES_HH__ */
diff --git a/source/blender/simulation/intern/simulation_solver.cc b/source/blender/simulation/intern/simulation_solver.cc
index 3c159eb1c58..d53ccd2bd49 100644
--- a/source/blender/simulation/intern/simulation_solver.cc
+++ b/source/blender/simulation/intern/simulation_solver.cc
@@ -121,6 +121,171 @@ static void ensure_attributes_exist(ParticleSimulationState *state, const Attrib
}
}
+BLI_NOINLINE static void apply_remaining_diffs(ParticleChunkContext &context)
+{
+ BLI_assert(context.integration != nullptr);
+ MutableSpan<float3> positions = context.attributes.get<float3>("Position");
+ MutableSpan<float3> velocities = context.attributes.get<float3>("Velocity");
+
+ for (int i : context.index_mask) {
+ positions[i] += context.integration->position_diffs[i];
+ velocities[i] += context.integration->velocity_diffs[i];
+ }
+}
+
+BLI_NOINLINE static void find_next_event_per_particle(
+ SimulationSolveContext &solve_context,
+ ParticleChunkContext &particles,
+ Span<const ParticleEvent *> events,
+ MutableSpan<int> r_next_event_indices,
+ MutableSpan<float> r_time_factors_to_next_event)
+{
+ r_next_event_indices.fill_indices(particles.index_mask, -1);
+ r_time_factors_to_next_event.fill_indices(particles.index_mask, 1.0f);
+
+ Array<float> time_factors(particles.index_mask.min_array_size());
+ for (int event_index : events.index_range()) {
+ time_factors.fill(-1.0f);
+ ParticleEventFilterContext event_context{solve_context, particles, time_factors};
+ const ParticleEvent &event = *events[event_index];
+ event.filter(event_context);
+
+ for (int i : particles.index_mask) {
+ const float time_factor = time_factors[i];
+ const float previously_smallest_time_factor = r_time_factors_to_next_event[i];
+ if (time_factor >= 0.0f && time_factor <= previously_smallest_time_factor) {
+ r_time_factors_to_next_event[i] = time_factor;
+ r_next_event_indices[i] = event_index;
+ }
+ }
+ }
+}
+
+BLI_NOINLINE static void forward_particles_to_next_event_or_end(
+ ParticleChunkContext &particles, Span<float> time_factors_to_next_event)
+{
+ MutableSpan<float3> positions = particles.attributes.get<float3>("Position");
+ MutableSpan<float3> velocities = particles.attributes.get<float3>("Velocity");
+
+ MutableSpan<float3> position_diffs = particles.integration->position_diffs;
+ MutableSpan<float3> velocity_diffs = particles.integration->velocity_diffs;
+ MutableSpan<float> durations = particles.integration->durations;
+
+ for (int i : particles.index_mask) {
+ const float time_factor = time_factors_to_next_event[i];
+ positions[i] += position_diffs[i] * time_factor;
+ velocities[i] += velocity_diffs[i] * time_factor;
+
+ const float remaining_time_factor = 1.0f - time_factor;
+ position_diffs[i] *= remaining_time_factor;
+ velocity_diffs[i] *= remaining_time_factor;
+ durations[i] *= remaining_time_factor;
+ }
+}
+
+BLI_NOINLINE static void group_particles_by_event(
+ IndexMask mask,
+ Span<int> next_event_indices,
+ MutableSpan<Vector<int64_t>> r_particles_per_event)
+{
+ for (int i : mask) {
+ int event_index = next_event_indices[i];
+ if (event_index >= 0) {
+ r_particles_per_event[event_index].append(i);
+ }
+ }
+}
+
+BLI_NOINLINE static void execute_events(SimulationSolveContext &solve_context,
+ ParticleChunkContext &all_particles,
+ Span<const ParticleEvent *> events,
+ Span<Vector<int64_t>> particles_per_event)
+{
+ for (int event_index : events.index_range()) {
+ Span<int64_t> pindices = particles_per_event[event_index];
+ if (pindices.is_empty()) {
+ continue;
+ }
+
+ const ParticleEvent &event = *events[event_index];
+ ParticleChunkContext particles{
+ all_particles.state, pindices, all_particles.attributes, all_particles.integration};
+ ParticleActionContext action_context{solve_context, particles};
+ event.execute(action_context);
+ }
+}
+
+BLI_NOINLINE static void find_unfinished_particles(IndexMask index_mask,
+ Span<float> time_factors_to_next_event,
+ Vector<int64_t> &r_unfinished_pindices)
+{
+ for (int i : index_mask) {
+ float time_factor = time_factors_to_next_event[i];
+ if (time_factor < 1.0f) {
+ r_unfinished_pindices.append(i);
+ }
+ }
+}
+
+BLI_NOINLINE static void simulate_to_next_event(SimulationSolveContext &solve_context,
+ ParticleChunkContext &particles,
+ Span<const ParticleEvent *> events,
+ Vector<int64_t> &r_unfinished_pindices)
+{
+ int array_size = particles.index_mask.min_array_size();
+ Array<int> next_event_indices(array_size);
+ Array<float> time_factors_to_next_event(array_size);
+
+ find_next_event_per_particle(
+ solve_context, particles, events, next_event_indices, time_factors_to_next_event);
+
+ forward_particles_to_next_event_or_end(particles, time_factors_to_next_event);
+
+ Array<Vector<int64_t>> particles_per_event(events.size());
+ group_particles_by_event(particles.index_mask, next_event_indices, particles_per_event);
+
+ execute_events(solve_context, particles, events, particles_per_event);
+ find_unfinished_particles(
+ particles.index_mask, time_factors_to_next_event, r_unfinished_pindices);
+}
+
+BLI_NOINLINE static void simulate_with_max_n_events(SimulationSolveContext &solve_context,
+ ParticleSimulationState &state,
+ ParticleChunkContext &particles,
+ int max_events)
+{
+ Span<const ParticleEvent *> events = solve_context.influences.particle_events.lookup_as(
+ state.head.name);
+ if (events.size() == 0) {
+ apply_remaining_diffs(particles);
+ return;
+ }
+
+ Vector<int64_t> unfininished_pindices = particles.index_mask.indices();
+ for (int iteration : IndexRange(max_events)) {
+ UNUSED_VARS(iteration);
+ if (unfininished_pindices.is_empty()) {
+ break;
+ }
+
+ Vector<int64_t> new_unfinished_pindices;
+ ParticleChunkContext remaining_particles{particles.state,
+ unfininished_pindices.as_span(),
+ particles.attributes,
+ particles.integration};
+ simulate_to_next_event(solve_context, remaining_particles, events, new_unfinished_pindices);
+ unfininished_pindices = std::move(new_unfinished_pindices);
+ }
+
+ if (!unfininished_pindices.is_empty()) {
+ ParticleChunkContext remaining_particles{particles.state,
+ unfininished_pindices.as_span(),
+ particles.attributes,
+ particles.integration};
+ apply_remaining_diffs(remaining_particles);
+ }
+}
+
BLI_NOINLINE static void simulate_particle_chunk(SimulationSolveContext &solve_context,
ParticleSimulationState &state,
MutableAttributesRef attributes,
@@ -132,7 +297,7 @@ BLI_NOINLINE static void simulate_particle_chunk(SimulationSolveContext &solve_c
Span<const ParticleAction *> begin_actions =
solve_context.influences.particle_time_step_begin_actions.lookup_as(state.head.name);
for (const ParticleAction *action : begin_actions) {
- ParticleChunkContext particles{IndexMask(particle_amount), attributes};
+ ParticleChunkContext particles{state, IndexMask(particle_amount), attributes};
ParticleActionContext action_context{solve_context, particles};
action->execute(action_context);
}
@@ -141,30 +306,32 @@ BLI_NOINLINE static void simulate_particle_chunk(SimulationSolveContext &solve_c
Span<const ParticleForce *> forces = solve_context.influences.particle_forces.lookup_as(
state.head.name);
for (const ParticleForce *force : forces) {
- ParticleChunkContext particles{IndexMask(particle_amount), attributes};
+ ParticleChunkContext particles{state, IndexMask(particle_amount), attributes};
ParticleForceContext particle_force_context{solve_context, particles, force_vectors};
force->add_force(particle_force_context);
}
- MutableSpan<float3> positions = attributes.get<float3>("Position");
MutableSpan<float3> velocities = attributes.get<float3>("Velocity");
- MutableSpan<float> birth_times = attributes.get<float>("Birth Time");
- MutableSpan<int> dead_states = attributes.get<int>("Dead");
+ Array<float3> position_diffs(particle_amount);
+ Array<float3> velocity_diffs(particle_amount);
for (int i : IndexRange(particle_amount)) {
const float time_step = remaining_durations[i];
- velocities[i] += force_vectors[i] * time_step;
- positions[i] += velocities[i] * time_step;
-
- if (end_time - birth_times[i] > 2) {
- dead_states[i] = true;
- }
+ velocity_diffs[i] = force_vectors[i] * time_step;
+ position_diffs[i] = (velocities[i] + velocity_diffs[i] / 2.0f) * time_step;
}
+ ParticleChunkIntegrationContext integration_context = {
+ position_diffs, velocity_diffs, remaining_durations, end_time};
+ ParticleChunkContext particle_chunk_context{
+ state, IndexMask(particle_amount), attributes, &integration_context};
+
+ simulate_with_max_n_events(solve_context, state, particle_chunk_context, 10);
+
Span<const ParticleAction *> end_actions =
solve_context.influences.particle_time_step_end_actions.lookup_as(state.head.name);
for (const ParticleAction *action : end_actions) {
- ParticleChunkContext particles{IndexMask(particle_amount), attributes};
+ ParticleChunkContext particles{state, IndexMask(particle_amount), attributes};
ParticleActionContext action_context{solve_context, particles};
action->execute(action_context);
}
@@ -326,7 +493,7 @@ void solve_simulation_time_step(Simulation &simulation,
Span<const ParticleAction *> actions = influences.particle_birth_actions.lookup_as(
state->head.name);
for (const ParticleAction *action : actions) {
- ParticleChunkContext chunk_context{IndexRange(attributes.size()), attributes};
+ ParticleChunkContext chunk_context{*state, IndexRange(attributes.size()), attributes};
ParticleActionContext action_context{solve_context, chunk_context};
action->execute(action_context);
}
diff --git a/source/blender/simulation/intern/simulation_solver.hh b/source/blender/simulation/intern/simulation_solver.hh
index 9d30ea87731..2cf8eb2aa27 100644
--- a/source/blender/simulation/intern/simulation_solver.hh
+++ b/source/blender/simulation/intern/simulation_solver.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __SIM_SIMULATION_SOLVER_HH__
-#define __SIM_SIMULATION_SOLVER_HH__
+#pragma once
#include "simulation_collect_influences.hh"
@@ -36,5 +35,3 @@ void solve_simulation_time_step(Simulation &simulation,
float time_step);
} // namespace blender::sim
-
-#endif /* __SIM_SIMULATION_SOLVER_HH__ */
diff --git a/source/blender/simulation/intern/simulation_solver_influences.cc b/source/blender/simulation/intern/simulation_solver_influences.cc
index 75c2c820651..3485d7c7bfb 100644
--- a/source/blender/simulation/intern/simulation_solver_influences.cc
+++ b/source/blender/simulation/intern/simulation_solver_influences.cc
@@ -32,6 +32,10 @@ ParticleAction::~ParticleAction()
{
}
+ParticleEvent::~ParticleEvent()
+{
+}
+
DependencyAnimations::~DependencyAnimations()
{
}
diff --git a/source/blender/simulation/intern/simulation_solver_influences.hh b/source/blender/simulation/intern/simulation_solver_influences.hh
index d3c515bb6a0..7dc0b3b8c8d 100644
--- a/source/blender/simulation/intern/simulation_solver_influences.hh
+++ b/source/blender/simulation/intern/simulation_solver_influences.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __SIM_SIMULATION_SOLVER_INFLUENCES_HH__
-#define __SIM_SIMULATION_SOLVER_INFLUENCES_HH__
+#pragma once
#include "BLI_float3.hh"
#include "BLI_float4x4.hh"
@@ -45,6 +44,7 @@ using fn::MutableAttributesRef;
struct ParticleEmitterContext;
struct ParticleForceContext;
struct ParticleActionContext;
+struct ParticleEventFilterContext;
class ParticleEmitter {
public:
@@ -64,11 +64,19 @@ class ParticleAction {
virtual void execute(ParticleActionContext &context) const = 0;
};
+class ParticleEvent {
+ public:
+ virtual ~ParticleEvent();
+ virtual void filter(ParticleEventFilterContext &context) const = 0;
+ virtual void execute(ParticleActionContext &context) const = 0;
+};
+
struct SimulationInfluences {
MultiValueMap<std::string, const ParticleForce *> particle_forces;
MultiValueMap<std::string, const ParticleAction *> particle_birth_actions;
MultiValueMap<std::string, const ParticleAction *> particle_time_step_begin_actions;
MultiValueMap<std::string, const ParticleAction *> particle_time_step_end_actions;
+ MultiValueMap<std::string, const ParticleEvent *> particle_events;
Map<std::string, AttributesInfoBuilder *> particle_attributes_builder;
Vector<const ParticleEmitter *> particle_emitters;
};
@@ -88,7 +96,7 @@ class SimulationStateMap {
template<typename StateType> StateType *lookup(StringRef name) const
{
const char *type = BKE_simulation_get_state_type_name<StateType>();
- return (StateType *)this->lookup_name_type(name, type);
+ return reinterpret_cast<StateType *>(this->lookup_name_type(name, type));
}
template<typename StateType> Span<StateType *> lookup() const
@@ -157,9 +165,37 @@ class ParticleAllocators {
}
};
+struct ParticleChunkIntegrationContext {
+ MutableSpan<float3> position_diffs;
+ MutableSpan<float3> velocity_diffs;
+ MutableSpan<float> durations;
+ float end_time;
+};
+
struct ParticleChunkContext {
+ ParticleSimulationState &state;
IndexMask index_mask;
MutableAttributesRef attributes;
+ ParticleChunkIntegrationContext *integration = nullptr;
+
+ void update_diffs_after_velocity_change()
+ {
+ if (integration == nullptr) {
+ return;
+ }
+
+ Span<float> remaining_durations = integration->durations;
+ MutableSpan<float3> position_diffs = integration->position_diffs;
+ Span<float3> velocities = attributes.get<float3>("Velocity");
+
+ for (int i : index_mask) {
+ const float duration = remaining_durations[i];
+ /* This is certainly not a perfect way to "re-integrate" the velocity, but it should be good
+ * enough for most use cases. Changing the velocity in an instant is not physically correct
+ * anyway. */
+ position_diffs[i] = velocities[i] * duration;
+ }
+ }
};
struct ParticleEmitterContext {
@@ -189,6 +225,10 @@ struct ParticleActionContext {
ParticleChunkContext &particles;
};
-} // namespace blender::sim
+struct ParticleEventFilterContext {
+ SimulationSolveContext &solve_context;
+ ParticleChunkContext &particles;
+ MutableSpan<float> factor_dst;
+};
-#endif /* __SIM_SIMULATION_SOLVER_INFLUENCES_HH__ */
+} // namespace blender::sim
diff --git a/source/blender/simulation/intern/simulation_update.cc b/source/blender/simulation/intern/simulation_update.cc
index 32b582977d0..452b222bb08 100644
--- a/source/blender/simulation/intern/simulation_update.cc
+++ b/source/blender/simulation/intern/simulation_update.cc
@@ -143,7 +143,7 @@ class SampledDependencyAnimations : public DependencyAnimations {
const float factor = simulation_time_interval_.factor_at_time(simulation_time);
BLI_assert(factor > 0.0f && factor < 1.0f);
const float scaled_factor = factor * (cached_transforms.size() - 1);
- const int lower_sample = (int)scaled_factor;
+ const int lower_sample = static_cast<int>(scaled_factor);
const int upper_sample = lower_sample + 1;
const float mix_factor = scaled_factor - lower_sample;
r_transforms[i] = float4x4::interpolate(
@@ -205,7 +205,7 @@ static void prepare_dependency_animations(Depsgraph &depsgraph,
if (GS(id_cow->name) != ID_OB) {
continue;
}
- Object &object_cow = *(Object *)id_cow;
+ Object &object_cow = *reinterpret_cast<Object *>(id_cow);
constexpr int sample_count = 10;
Array<float4x4, sample_count> transforms(sample_count);
sample_object_transforms(object_cow, depsgraph, scene, scene_frame_interval, transforms);
@@ -233,7 +233,8 @@ void update_simulation_in_depsgraph(Depsgraph *depsgraph,
return;
}
- Simulation *simulation_orig = (Simulation *)DEG_get_original_id(&simulation_cow->id);
+ Simulation *simulation_orig = reinterpret_cast<Simulation *>(
+ DEG_get_original_id(&simulation_cow->id));
ResourceCollector resources;
SimulationInfluences influences;
@@ -317,8 +318,8 @@ bool update_simulation_dependencies(Simulation *simulation)
}
used_handles.add_new(next_handle);
- SimulationDependency *dependency = (SimulationDependency *)MEM_callocN(sizeof(*dependency),
- AT);
+ SimulationDependency *dependency = static_cast<SimulationDependency *>(
+ MEM_callocN(sizeof(*dependency), AT));
id_us_plus(id);
dependency->id = id;
dependency->handle = next_handle;
diff --git a/source/blender/simulation/intern/time_interval.hh b/source/blender/simulation/intern/time_interval.hh
index 5996dc5d25b..034628fa9be 100644
--- a/source/blender/simulation/intern/time_interval.hh
+++ b/source/blender/simulation/intern/time_interval.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __SIM_TIME_INTERVAL_HH__
-#define __SIM_TIME_INTERVAL_HH__
+#pragma once
#include "BLI_utildefines.h"
@@ -89,5 +88,3 @@ class TimeInterval {
};
} // namespace blender::sim
-
-#endif /* __SIM_TIME_INTERVAL_HH__ */
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 3d4c84805f9..07746af4b60 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*/
-#ifndef __WM_API_H__
-#define __WM_API_H__
+#pragma once
/** \file
* \ingroup wm
@@ -99,7 +98,7 @@ void WM_main(struct bContext *C) ATTR_NORETURN;
void WM_init_splash(struct bContext *C);
-void WM_init_opengl(struct Main *bmain);
+void WM_init_opengl(void);
void WM_check(struct bContext *C);
void WM_reinit_gizmomap_all(struct Main *bmain);
@@ -904,5 +903,3 @@ bool WM_xr_session_state_viewer_pose_matrix_info_get(const wmXrData *xr,
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_API_H__ */
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index 53a3fd5ebda..15be21bdbc4 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __WM_KEYMAP_H__
-#define __WM_KEYMAP_H__
+#pragma once
/** \file
* \ingroup wm
@@ -194,5 +193,3 @@ const char *WM_bool_as_string(bool test);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_KEYMAP_H__ */
diff --git a/source/blender/windowmanager/WM_message.h b/source/blender/windowmanager/WM_message.h
index 1527d514e9b..25d5bae392b 100644
--- a/source/blender/windowmanager/WM_message.h
+++ b/source/blender/windowmanager/WM_message.h
@@ -18,9 +18,6 @@
* \ingroup wm
*/
-#ifndef __WM_MESSAGE_H__
-#define __WM_MESSAGE_H__
+#pragma once
#include "message_bus/wm_message_bus.h"
-
-#endif /* __WM_MESSAGE_H__ */
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h
index 163f37be974..13d1666dc95 100644
--- a/source/blender/windowmanager/WM_toolsystem.h
+++ b/source/blender/windowmanager/WM_toolsystem.h
@@ -13,8 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __WM_TOOLSYSTEM_H__
-#define __WM_TOOLSYSTEM_H__
+#pragma once
/** \file
* \ingroup wm
@@ -140,5 +139,3 @@ void WM_toolsystem_refresh_screen_all(struct Main *bmain);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_TOOLSYSTEM_API_H__ */
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index b4b3d0957af..efe600a846a 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -106,8 +106,7 @@
* \endcode
*/
-#ifndef __WM_TYPES_H__
-#define __WM_TYPES_H__
+#pragma once
struct ID;
struct ImBuf;
@@ -928,5 +927,3 @@ extern struct CLG_LogRef *WM_LOG_MSGBUS_SUB;
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_TYPES_H__ */
diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h
index 1066f009214..a4412ecce5c 100644
--- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h
+++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h
@@ -26,8 +26,7 @@
* Only included in WM_api.h
*/
-#ifndef __WM_GIZMO_API_H__
-#define __WM_GIZMO_API_H__
+#pragma once
struct ARegion;
struct GHashIterator;
@@ -403,5 +402,3 @@ void WM_gizmo_group_refresh(const struct bContext *C, struct wmGizmoGroup *gzgro
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_GIZMO_API_H__ */
diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h
index 5def7f8d2f9..bddf54b846f 100644
--- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h
+++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h
@@ -26,8 +26,7 @@
* Only included in WM_types.h and lower level files.
*/
-#ifndef __WM_GIZMO_TYPES_H__
-#define __WM_GIZMO_TYPES_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -513,5 +512,3 @@ typedef enum eWM_GizmoFlagMapDrawStep {
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_GIZMO_TYPES_H__ */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
index 90d9ba45637..87cb4d5f584 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
@@ -452,9 +452,7 @@ bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *gzmap, wmGizmo *gz)
wm_gizmomap_highlight_set(gzmap, C, gz, gz->highlight_part);
return true;
}
- else {
- return false;
- }
+ return false;
}
/**
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
index 67f30f0d7ee..b64d544962d 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -166,12 +166,10 @@ int WM_gizmo_cmp_temp_fl(const void *gz_a_ptr, const void *gz_b_ptr)
if (gz_a->temp.f < gz_b->temp.f) {
return -1;
}
- else if (gz_a->temp.f > gz_b->temp.f) {
+ if (gz_a->temp.f > gz_b->temp.f) {
return 1;
}
- else {
- return 0;
- }
+ return 0;
}
int WM_gizmo_cmp_temp_fl_reverse(const void *gz_a_ptr, const void *gz_b_ptr)
@@ -181,12 +179,10 @@ int WM_gizmo_cmp_temp_fl_reverse(const void *gz_a_ptr, const void *gz_b_ptr)
if (gz_a->temp.f < gz_b->temp.f) {
return 1;
}
- else if (gz_a->temp.f > gz_b->temp.f) {
+ if (gz_a->temp.f > gz_b->temp.f) {
return -1;
}
- else {
- return 0;
- }
+ return 0;
}
static bool wm_gizmo_keymap_uses_event_modifier(wmWindowManager *wm,
@@ -396,10 +392,9 @@ static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
return OPERATOR_FINISHED;
}
- else {
- BLI_assert(0);
- return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
- }
+
+ BLI_assert(0);
+ return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
}
void GIZMOGROUP_OT_gizmo_select(wmOperatorType *ot)
@@ -476,9 +471,7 @@ static bool gizmo_tweak_start_and_finish(
}
return true;
}
- else {
- return false;
- }
+ return false;
}
static void gizmo_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal)
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
index 00df6edef22..953722f28e9 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h
@@ -18,8 +18,7 @@
* \ingroup wm
*/
-#ifndef __WM_GIZMO_INTERN_H__
-#define __WM_GIZMO_INTERN_H__
+#pragma once
struct BLI_Buffer;
struct wmGizmoMap;
@@ -142,5 +141,3 @@ bool wm_gizmomap_deselect_all(struct wmGizmoMap *gzmap);
void wm_gizmomap_select_array_shrink(struct wmGizmoMap *gzmap, int len_subtract);
void wm_gizmomap_select_array_push_back(struct wmGizmoMap *gzmap, wmGizmo *gz);
void wm_gizmomap_select_array_remove(struct wmGizmoMap *gzmap, wmGizmo *gz);
-
-#endif
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index 2038a82c9fd..cecd324ff28 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -263,11 +263,10 @@ bool WM_gizmomap_minmax(const wmGizmoMap *gzmap,
}
return i != 0;
}
- else {
- bool ok = false;
- BLI_assert(!"TODO");
- return ok;
- }
+
+ bool ok = false;
+ BLI_assert(!"TODO");
+ return ok;
}
/**
@@ -647,10 +646,9 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos,
}
return hit_found;
}
- else {
- const uint *hit_near = GPU_select_buffer_near(buffer, hits);
- return hit_near ? hit_near[3] : -1;
- }
+
+ const uint *hit_near = GPU_select_buffer_near(buffer, hits);
+ return hit_near ? hit_near[3] : -1;
}
/**
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
index 2dc03d1419c..b056ed40943 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
@@ -70,9 +70,7 @@ wmGizmoProperty *WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
if (index != -1) {
return WM_gizmo_target_property_at_index(gz, index);
}
- else {
- return NULL;
- }
+ return NULL;
}
void WM_gizmo_target_property_def_rna_ptr(wmGizmo *gz,
@@ -195,9 +193,7 @@ float WM_gizmo_target_property_float_get(const wmGizmo *gz, wmGizmoProperty *gz_
if (gz_prop->index == -1) {
return RNA_property_float_get(&gz_prop->ptr, gz_prop->prop);
}
- else {
- return RNA_property_float_get_index(&gz_prop->ptr, gz_prop->prop, gz_prop->index);
- }
+ return RNA_property_float_get_index(&gz_prop->ptr, gz_prop->prop, gz_prop->index);
}
void WM_gizmo_target_property_float_set(bContext *C,
@@ -255,9 +251,7 @@ bool WM_gizmo_target_property_float_range_get(const wmGizmo *gz,
gz_prop->custom_func.range_get_fn(gz, gz_prop, range);
return true;
}
- else {
- return false;
- }
+ return false;
}
float step, precision;
diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h
index 00a3f476bac..418e848e35b 100644
--- a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h
+++ b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h
@@ -20,8 +20,7 @@
* Callback function definitions, needed for both Types & API headers.
*/
-#ifndef __WM_GIZMO_FN_H__
-#define __WM_GIZMO_FN_H__
+#pragma once
#include "BLI_compiler_attrs.h"
@@ -92,5 +91,3 @@ typedef struct wmGizmoPropertyFnParams {
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_GIZMO_FN_H__ */
diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h
index edded4c7620..18b3f40aba6 100644
--- a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h
+++ b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h
@@ -28,8 +28,7 @@
* Only included in wm.h and lower level files.
*/
-#ifndef __WM_GIZMO_WMAPI_H__
-#define __WM_GIZMO_WMAPI_H__
+#pragma once
struct wmEventHandler_Gizmo;
struct wmEventHandler_Op;
@@ -99,5 +98,3 @@ void wm_gizmomaptypes_free(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_GIZMO_WMAPI_H__ */
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 2112477e62a..43c08a2b980 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -293,7 +293,7 @@ void WM_keyconfig_init(bContext *C)
/* initialize only after python init is done, for keymaps that
* use python operators */
- if (CTX_py_init_get(C) && (wm->initialized & WM_KEYCONFIG_IS_INITIALIZED) == 0) {
+ if (CTX_py_init_get(C) && (wm->initialized & WM_KEYCONFIG_IS_INIT) == 0) {
/* create default key config, only initialize once,
* it's persistent across sessions */
if (!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) {
@@ -308,7 +308,7 @@ void WM_keyconfig_init(bContext *C)
WM_keyconfig_update_tag(NULL, NULL);
WM_keyconfig_update(wm);
- wm->initialized |= WM_KEYCONFIG_IS_INITIALIZED;
+ wm->initialized |= WM_KEYCONFIG_IS_INIT;
}
}
@@ -334,7 +334,7 @@ void WM_check(bContext *C)
if (!G.background) {
/* case: fileread */
- if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) {
+ if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) {
WM_keyconfig_init(C);
WM_autosave_init(wm);
}
@@ -345,9 +345,9 @@ void WM_check(bContext *C)
/* case: fileread */
/* note: this runs in bg mode to set the screen context cb */
- if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) {
- ED_screens_initialize(bmain, wm);
- wm->initialized |= WM_WINDOW_IS_INITIALIZED;
+ if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) {
+ ED_screens_init(bmain, wm);
+ wm->initialized |= WM_WINDOW_IS_INIT;
}
}
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 2af68956923..8e89c08a831 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -121,7 +121,7 @@ static GHOST_TStandardCursor convert_to_ghost_standard_cursor(WMCursorType curs)
}
static void window_set_custom_cursor(
- wmWindow *win, const uchar mask[16][2], uchar bitmap[16][2], int hotx, int hoty)
+ wmWindow *win, const uchar mask[16][2], const uchar bitmap[16][2], int hotx, int hoty)
{
GHOST_SetCustomCursorShape(
win->ghostwin, (GHOST_TUns8 *)bitmap, (GHOST_TUns8 *)mask, 16, 16, hotx, hoty, true);
@@ -319,15 +319,15 @@ bool wm_cursor_arrow_move(wmWindow *win, const wmEvent *event)
wm_cursor_warp_relative(win, 0, fac);
return 1;
}
- else if (event->type == EVT_DOWNARROWKEY) {
+ if (event->type == EVT_DOWNARROWKEY) {
wm_cursor_warp_relative(win, 0, -fac);
return 1;
}
- else if (event->type == EVT_LEFTARROWKEY) {
+ if (event->type == EVT_LEFTARROWKEY) {
wm_cursor_warp_relative(win, -fac, 0);
return 1;
}
- else if (event->type == EVT_RIGHTARROWKEY) {
+ if (event->type == EVT_RIGHTARROWKEY) {
wm_cursor_warp_relative(win, fac, 0);
return 1;
}
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index 5f13adcb971..ec18a401fa4 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -296,7 +296,7 @@ void WM_drag_add_ID(wmDrag *drag, ID *id, ID *from_parent)
}
return;
}
- else if (GS(drag_id->id->name) != GS(id->name)) {
+ if (GS(drag_id->id->name) != GS(id->name)) {
BLI_assert(!"All dragged IDs must have the same type");
return;
}
@@ -355,7 +355,7 @@ static const char *wm_drag_name(wmDrag *drag)
if (single) {
return id->name + 2;
}
- else if (id) {
+ if (id) {
return BKE_idtype_idcode_to_name_plural(GS(id->name));
}
break;
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 16454e473cc..b8cb5432a49 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -51,7 +51,7 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "GPU_draw.h"
+#include "GPU_context.h"
#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_state.h"
@@ -207,7 +207,7 @@ static bool wm_draw_region_stereo_set(Main *bmain,
if (region->regiontype == RGN_TYPE_PREVIEW) {
return true;
}
- else if (region->regiontype == RGN_TYPE_WINDOW) {
+ if (region->regiontype == RGN_TYPE_WINDOW) {
return (sseq->draw_flag & SEQ_DRAW_BACKDROP) != 0;
}
}
@@ -520,9 +520,7 @@ GPUTexture *wm_draw_region_texture(ARegion *region, int view)
if (viewport) {
return GPU_viewport_color_texture(viewport, view);
}
- else {
- return GPU_offscreen_color_texture(region->draw_buffer->offscreen);
- }
+ return GPU_offscreen_color_texture(region->draw_buffer->offscreen);
}
void wm_draw_region_blend(ARegion *region, int view, bool blend)
@@ -572,8 +570,8 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend)
}
/* Not the same layout as rectf/recti. */
- float rectt[4] = {rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax};
- float rectg[4] = {rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax};
+ const float rectt[4] = {rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax};
+ const float rectg[4] = {rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax};
if (blend) {
/* GL_ONE because regions drawn offscreen have premultiplied alpha. */
@@ -999,7 +997,8 @@ void wm_draw_update(bContext *C)
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win;
- GPU_free_unused_buffers();
+ GPU_context_main_lock();
+ BKE_image_free_unused_gpu_textures();
for (win = wm->windows.first; win; win = win->next) {
#ifdef WIN32
@@ -1036,6 +1035,8 @@ void wm_draw_update(bContext *C)
/* Draw non-windows (surfaces) */
wm_surfaces_iter(C, wm_draw_surface);
+
+ GPU_context_main_unlock();
}
void wm_draw_region_clear(wmWindow *win, ARegion *UNUSED(region))
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 05ef4bfac30..bea4faa779a 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -387,6 +387,18 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
CTX_wm_window_set(C, NULL);
}
+static void wm_event_execute_timers(bContext *C)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+
+ /* Set the first window as context, so that there is some minimal context. This avoids crashes
+ * when calling code that assumes that there is always a window in the context (which many
+ * operators do). */
+ CTX_wm_window_set(C, wm->windows.first);
+ BLI_timer_execute();
+ CTX_wm_window_set(C, NULL);
+}
+
/* called in mainloop */
void wm_event_do_notifiers(bContext *C)
{
@@ -398,7 +410,7 @@ void wm_event_do_notifiers(bContext *C)
return;
}
- BLI_timer_execute();
+ wm_event_execute_timers(C);
/* disable? - keep for now since its used for window level notifiers. */
#if 1
@@ -597,7 +609,7 @@ static int wm_handler_ui_call(bContext *C,
if (is_wheel) {
return WM_HANDLER_CONTINUE;
}
- else if (wm_event_always_pass(event) == 0) {
+ if (wm_event_always_pass(event) == 0) {
do_wheel_ui = true;
}
}
@@ -783,7 +795,7 @@ bool WM_operator_poll(bContext *C, wmOperatorType *ot)
if (ot->pyop_poll) {
return ot->pyop_poll(C, ot);
}
- else if (ot->poll) {
+ if (ot->poll) {
return ot->poll(C);
}
@@ -1095,7 +1107,7 @@ bool WM_operator_repeat_check(const bContext *UNUSED(C), wmOperator *op)
if (op->type->exec != NULL) {
return true;
}
- else if (op->opm) {
+ if (op->opm) {
/* for macros, check all have exec() we can call */
wmOperatorTypeMacro *otmacro;
for (otmacro = op->opm->type->macro.first; otmacro; otmacro = otmacro->next) {
@@ -1816,10 +1828,10 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi)
/* tablet events can occur on hover + keypress */
return false;
}
- else if ((kmitype == TABLET_STYLUS) && (wmtab->active != EVT_TABLET_STYLUS)) {
+ if ((kmitype == TABLET_STYLUS) && (wmtab->active != EVT_TABLET_STYLUS)) {
return false;
}
- else if ((kmitype == TABLET_ERASER) && (wmtab->active != EVT_TABLET_ERASER)) {
+ if ((kmitype == TABLET_ERASER) && (wmtab->active != EVT_TABLET_ERASER)) {
return false;
}
}
@@ -2434,13 +2446,11 @@ static int wm_handlers_do_keymap_with_keymap_handler(
}
break;
}
+ if (action & WM_HANDLER_HANDLED) {
+ CLOG_INFO(WM_LOG_HANDLERS, 2, "handled - and pass on! '%s'", kmi->idname);
+ }
else {
- if (action & WM_HANDLER_HANDLED) {
- CLOG_INFO(WM_LOG_HANDLERS, 2, "handled - and pass on! '%s'", kmi->idname);
- }
- else {
- CLOG_INFO(WM_LOG_HANDLERS, 2, "un-handled '%s'", kmi->idname);
- }
+ CLOG_INFO(WM_LOG_HANDLERS, 2, "un-handled '%s'", kmi->idname);
}
}
}
@@ -2492,16 +2502,14 @@ static int wm_handlers_do_keymap_with_gizmo_handler(
}
break;
}
- else {
- if (action & WM_HANDLER_HANDLED) {
- if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS)) {
- printf("%s: handled - and pass on! '%s'\n", __func__, kmi->idname);
- }
- }
- else {
- PRINT("%s: un-handled '%s'\n", __func__, kmi->idname);
+ if (action & WM_HANDLER_HANDLED) {
+ if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS)) {
+ printf("%s: handled - and pass on! '%s'\n", __func__, kmi->idname);
}
}
+ else {
+ PRINT("%s: un-handled '%s'\n", __func__, kmi->idname);
+ }
}
}
}
@@ -3126,13 +3134,9 @@ static bool wm_event_pie_filter(wmWindow *win, const wmEvent *event)
win->lock_pie_event = EVENT_NONE;
return false;
}
- else {
- return true;
- }
- }
- else {
- return false;
+ return true;
}
+ return false;
}
/**
@@ -3692,10 +3696,8 @@ wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(wmWindowManager *wm,
handler->keymap_tool = area->runtime.tool;
return km;
}
- else {
- printf(
- "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname);
- }
+ printf(
+ "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname);
}
}
return NULL;
@@ -3716,10 +3718,8 @@ wmKeyMap *WM_event_get_keymap_from_toolsystem(wmWindowManager *wm, wmEventHandle
handler->keymap_tool = area->runtime.tool;
return km;
}
- else {
- printf(
- "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname);
- }
+ printf(
+ "Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, area->runtime.tool->idname);
}
}
return NULL;
@@ -3775,12 +3775,10 @@ static bool event_or_prev_in_rect(const wmEvent *event, const rcti *rect)
if (BLI_rcti_isect_pt(rect, event->x, event->y)) {
return true;
}
- else if (event->type == MOUSEMOVE && BLI_rcti_isect_pt(rect, event->prevx, event->prevy)) {
+ if (event->type == MOUSEMOVE && BLI_rcti_isect_pt(rect, event->prevx, event->prevy)) {
return true;
}
- else {
- return false;
- }
+ return false;
}
static bool handler_region_v2d_mask_test(const ARegion *region, const wmEvent *event)
@@ -3966,138 +3964,137 @@ static int convert_key(GHOST_TKey key)
if (key >= GHOST_kKeyA && key <= GHOST_kKeyZ) {
return (EVT_AKEY + ((int)key - GHOST_kKeyA));
}
- else if (key >= GHOST_kKey0 && key <= GHOST_kKey9) {
+ if (key >= GHOST_kKey0 && key <= GHOST_kKey9) {
return (EVT_ZEROKEY + ((int)key - GHOST_kKey0));
}
- else if (key >= GHOST_kKeyNumpad0 && key <= GHOST_kKeyNumpad9) {
+ if (key >= GHOST_kKeyNumpad0 && key <= GHOST_kKeyNumpad9) {
return (EVT_PAD0 + ((int)key - GHOST_kKeyNumpad0));
}
- else if (key >= GHOST_kKeyF1 && key <= GHOST_kKeyF24) {
+ if (key >= GHOST_kKeyF1 && key <= GHOST_kKeyF24) {
return (EVT_F1KEY + ((int)key - GHOST_kKeyF1));
}
- else {
- switch (key) {
- case GHOST_kKeyBackSpace:
- return EVT_BACKSPACEKEY;
- case GHOST_kKeyTab:
- return EVT_TABKEY;
- case GHOST_kKeyLinefeed:
- return EVT_LINEFEEDKEY;
- case GHOST_kKeyClear:
- return 0;
- case GHOST_kKeyEnter:
- return EVT_RETKEY;
-
- case GHOST_kKeyEsc:
- return EVT_ESCKEY;
- case GHOST_kKeySpace:
- return EVT_SPACEKEY;
- case GHOST_kKeyQuote:
- return EVT_QUOTEKEY;
- case GHOST_kKeyComma:
- return EVT_COMMAKEY;
- case GHOST_kKeyMinus:
- return EVT_MINUSKEY;
- case GHOST_kKeyPlus:
- return EVT_PLUSKEY;
- case GHOST_kKeyPeriod:
- return EVT_PERIODKEY;
- case GHOST_kKeySlash:
- return EVT_SLASHKEY;
-
- case GHOST_kKeySemicolon:
- return EVT_SEMICOLONKEY;
- case GHOST_kKeyEqual:
- return EVT_EQUALKEY;
-
- case GHOST_kKeyLeftBracket:
- return EVT_LEFTBRACKETKEY;
- case GHOST_kKeyRightBracket:
- return EVT_RIGHTBRACKETKEY;
- case GHOST_kKeyBackslash:
- return EVT_BACKSLASHKEY;
- case GHOST_kKeyAccentGrave:
- return EVT_ACCENTGRAVEKEY;
-
- case GHOST_kKeyLeftShift:
- return EVT_LEFTSHIFTKEY;
- case GHOST_kKeyRightShift:
- return EVT_RIGHTSHIFTKEY;
- case GHOST_kKeyLeftControl:
- return EVT_LEFTCTRLKEY;
- case GHOST_kKeyRightControl:
- return EVT_RIGHTCTRLKEY;
- case GHOST_kKeyOS:
- return EVT_OSKEY;
- case GHOST_kKeyLeftAlt:
- return EVT_LEFTALTKEY;
- case GHOST_kKeyRightAlt:
- return EVT_RIGHTALTKEY;
- case GHOST_kKeyApp:
- return EVT_APPKEY;
-
- case GHOST_kKeyCapsLock:
- return EVT_CAPSLOCKKEY;
- case GHOST_kKeyNumLock:
- return 0;
- case GHOST_kKeyScrollLock:
- return 0;
-
- case GHOST_kKeyLeftArrow:
- return EVT_LEFTARROWKEY;
- case GHOST_kKeyRightArrow:
- return EVT_RIGHTARROWKEY;
- case GHOST_kKeyUpArrow:
- return EVT_UPARROWKEY;
- case GHOST_kKeyDownArrow:
- return EVT_DOWNARROWKEY;
-
- case GHOST_kKeyPrintScreen:
- return 0;
- case GHOST_kKeyPause:
- return EVT_PAUSEKEY;
-
- case GHOST_kKeyInsert:
- return EVT_INSERTKEY;
- case GHOST_kKeyDelete:
- return EVT_DELKEY;
- case GHOST_kKeyHome:
- return EVT_HOMEKEY;
- case GHOST_kKeyEnd:
- return EVT_ENDKEY;
- case GHOST_kKeyUpPage:
- return EVT_PAGEUPKEY;
- case GHOST_kKeyDownPage:
- return EVT_PAGEDOWNKEY;
-
- case GHOST_kKeyNumpadPeriod:
- return EVT_PADPERIOD;
- case GHOST_kKeyNumpadEnter:
- return EVT_PADENTER;
- case GHOST_kKeyNumpadPlus:
- return EVT_PADPLUSKEY;
- case GHOST_kKeyNumpadMinus:
- return EVT_PADMINUS;
- case GHOST_kKeyNumpadAsterisk:
- return EVT_PADASTERKEY;
- case GHOST_kKeyNumpadSlash:
- return EVT_PADSLASHKEY;
-
- case GHOST_kKeyGrLess:
- return EVT_GRLESSKEY;
-
- case GHOST_kKeyMediaPlay:
- return EVT_MEDIAPLAY;
- case GHOST_kKeyMediaStop:
- return EVT_MEDIASTOP;
- case GHOST_kKeyMediaFirst:
- return EVT_MEDIAFIRST;
- case GHOST_kKeyMediaLast:
- return EVT_MEDIALAST;
-
- default:
- return EVT_UNKNOWNKEY; /* GHOST_kKeyUnknown */
- }
+
+ switch (key) {
+ case GHOST_kKeyBackSpace:
+ return EVT_BACKSPACEKEY;
+ case GHOST_kKeyTab:
+ return EVT_TABKEY;
+ case GHOST_kKeyLinefeed:
+ return EVT_LINEFEEDKEY;
+ case GHOST_kKeyClear:
+ return 0;
+ case GHOST_kKeyEnter:
+ return EVT_RETKEY;
+
+ case GHOST_kKeyEsc:
+ return EVT_ESCKEY;
+ case GHOST_kKeySpace:
+ return EVT_SPACEKEY;
+ case GHOST_kKeyQuote:
+ return EVT_QUOTEKEY;
+ case GHOST_kKeyComma:
+ return EVT_COMMAKEY;
+ case GHOST_kKeyMinus:
+ return EVT_MINUSKEY;
+ case GHOST_kKeyPlus:
+ return EVT_PLUSKEY;
+ case GHOST_kKeyPeriod:
+ return EVT_PERIODKEY;
+ case GHOST_kKeySlash:
+ return EVT_SLASHKEY;
+
+ case GHOST_kKeySemicolon:
+ return EVT_SEMICOLONKEY;
+ case GHOST_kKeyEqual:
+ return EVT_EQUALKEY;
+
+ case GHOST_kKeyLeftBracket:
+ return EVT_LEFTBRACKETKEY;
+ case GHOST_kKeyRightBracket:
+ return EVT_RIGHTBRACKETKEY;
+ case GHOST_kKeyBackslash:
+ return EVT_BACKSLASHKEY;
+ case GHOST_kKeyAccentGrave:
+ return EVT_ACCENTGRAVEKEY;
+
+ case GHOST_kKeyLeftShift:
+ return EVT_LEFTSHIFTKEY;
+ case GHOST_kKeyRightShift:
+ return EVT_RIGHTSHIFTKEY;
+ case GHOST_kKeyLeftControl:
+ return EVT_LEFTCTRLKEY;
+ case GHOST_kKeyRightControl:
+ return EVT_RIGHTCTRLKEY;
+ case GHOST_kKeyOS:
+ return EVT_OSKEY;
+ case GHOST_kKeyLeftAlt:
+ return EVT_LEFTALTKEY;
+ case GHOST_kKeyRightAlt:
+ return EVT_RIGHTALTKEY;
+ case GHOST_kKeyApp:
+ return EVT_APPKEY;
+
+ case GHOST_kKeyCapsLock:
+ return EVT_CAPSLOCKKEY;
+ case GHOST_kKeyNumLock:
+ return 0;
+ case GHOST_kKeyScrollLock:
+ return 0;
+
+ case GHOST_kKeyLeftArrow:
+ return EVT_LEFTARROWKEY;
+ case GHOST_kKeyRightArrow:
+ return EVT_RIGHTARROWKEY;
+ case GHOST_kKeyUpArrow:
+ return EVT_UPARROWKEY;
+ case GHOST_kKeyDownArrow:
+ return EVT_DOWNARROWKEY;
+
+ case GHOST_kKeyPrintScreen:
+ return 0;
+ case GHOST_kKeyPause:
+ return EVT_PAUSEKEY;
+
+ case GHOST_kKeyInsert:
+ return EVT_INSERTKEY;
+ case GHOST_kKeyDelete:
+ return EVT_DELKEY;
+ case GHOST_kKeyHome:
+ return EVT_HOMEKEY;
+ case GHOST_kKeyEnd:
+ return EVT_ENDKEY;
+ case GHOST_kKeyUpPage:
+ return EVT_PAGEUPKEY;
+ case GHOST_kKeyDownPage:
+ return EVT_PAGEDOWNKEY;
+
+ case GHOST_kKeyNumpadPeriod:
+ return EVT_PADPERIOD;
+ case GHOST_kKeyNumpadEnter:
+ return EVT_PADENTER;
+ case GHOST_kKeyNumpadPlus:
+ return EVT_PADPLUSKEY;
+ case GHOST_kKeyNumpadMinus:
+ return EVT_PADMINUS;
+ case GHOST_kKeyNumpadAsterisk:
+ return EVT_PADASTERKEY;
+ case GHOST_kKeyNumpadSlash:
+ return EVT_PADSLASHKEY;
+
+ case GHOST_kKeyGrLess:
+ return EVT_GRLESSKEY;
+
+ case GHOST_kKeyMediaPlay:
+ return EVT_MEDIAPLAY;
+ case GHOST_kKeyMediaStop:
+ return EVT_MEDIASTOP;
+ case GHOST_kKeyMediaFirst:
+ return EVT_MEDIAFIRST;
+ case GHOST_kKeyMediaLast:
+ return EVT_MEDIALAST;
+
+ default:
+ return EVT_UNKNOWNKEY; /* GHOST_kKeyUnknown */
}
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index f431a6f431b..ef4f2b4a62a 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -258,7 +258,7 @@ static void wm_window_match_keep_current_wm(const bContext *C,
bScreen *screen = NULL;
/* match oldwm to new dbase, only old files */
- wm->initialized &= ~WM_WINDOW_IS_INITIALIZED;
+ wm->initialized &= ~WM_WINDOW_IS_INIT;
/* when loading without UI, no matching needed */
if (load_ui && (screen = CTX_wm_screen(C))) {
@@ -1404,10 +1404,8 @@ bool write_crash_blend(void)
printf("written: %s\n", path);
return 1;
}
- else {
- printf("failed: %s\n", path);
- return 0;
- }
+ printf("failed: %s\n", path);
+ return 0;
}
/**
@@ -2091,9 +2089,7 @@ static int wm_homefile_read_invoke(bContext *C, wmOperator *op, const wmEvent *U
wm_close_file_dialog(C, callback);
return OPERATOR_INTERFACE;
}
- else {
- return wm_homefile_read_exec(C, op);
- }
+ return wm_homefile_read_exec(C, op);
}
static void read_homefile_props(wmOperatorType *ot)
@@ -2255,9 +2251,7 @@ static int wm_open_mainfile__discard_changes(bContext *C, wmOperator *op)
wm_close_file_dialog(C, callback);
return OPERATOR_INTERFACE;
}
- else {
- return wm_open_mainfile_dispatch(C, op);
- }
+ return wm_open_mainfile_dispatch(C, op);
}
static int wm_open_mainfile__select_file_path(bContext *C, wmOperator *op)
@@ -2328,9 +2322,7 @@ static int wm_open_mainfile__open(bContext *C, wmOperator *op)
ED_view3d_local_collections_reset(C, (G.fileflags & G_FILE_NO_UI) != 0);
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static OperatorDispatchTarget wm_open_mainfile_dispatch_targets[] = {
@@ -2475,9 +2467,7 @@ static int wm_revert_mainfile_exec(bContext *C, wmOperator *op)
if (success) {
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static bool wm_revert_mainfile_poll(bContext *UNUSED(C))
@@ -2572,9 +2562,7 @@ static int wm_recover_auto_save_exec(bContext *C, wmOperator *op)
if (success) {
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static int wm_recover_auto_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 31d36603505..6ccc5d79962 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -357,11 +357,11 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports, RPT_ERROR, "'%s': not a library", path);
return OPERATOR_CANCELLED;
}
- else if (!group) {
+ if (!group) {
BKE_reportf(op->reports, RPT_ERROR, "'%s': nothing indicated", path);
return OPERATOR_CANCELLED;
}
- else if (BLI_path_cmp(BKE_main_blendfile_path(bmain), libname) == 0) {
+ if (BLI_path_cmp(BKE_main_blendfile_path(bmain), libname) == 0) {
BKE_reportf(op->reports, RPT_ERROR, "'%s': cannot use current file as library", path);
return OPERATOR_CANCELLED;
}
@@ -755,7 +755,7 @@ static void lib_relocate_do_remap(Main *bmain,
if (c == '.') {
break;
}
- else if (c < '0' || c > '9') {
+ if (c < '0' || c > '9') {
has_num = false;
break;
}
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 5a66cbd10eb..55233168ab2 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -324,7 +324,7 @@ static void draw_filled_lasso(wmGesture *gt)
int(*mcoords)[2] = MEM_mallocN(sizeof(*mcoords) * (mcoords_len + 1), __func__);
int i;
rcti rect;
- float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
+ const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
for (i = 0; i < mcoords_len; i++, lasso += 2) {
mcoords[i][0] = lasso[0];
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 945d5fd42e4..03e84f098c0 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -59,6 +59,7 @@
#include "BKE_font.h"
#include "BKE_global.h"
#include "BKE_icons.h"
+#include "BKE_image.h"
#include "BKE_keyconfig.h"
#include "BKE_lib_remap.h"
#include "BKE_main.h"
@@ -120,7 +121,7 @@
#include "UI_interface.h"
#include "UI_resources.h"
-#include "GPU_draw.h"
+#include "GPU_context.h"
#include "GPU_init_exit.h"
#include "GPU_material.h"
@@ -171,7 +172,7 @@ void WM_init_state_start_with_console_set(bool value)
*/
static bool opengl_is_init = false;
-void WM_init_opengl(Main *bmain)
+void WM_init_opengl(void)
{
/* must be called only once */
BLI_assert(opengl_is_init == false);
@@ -185,9 +186,6 @@ void WM_init_opengl(Main *bmain)
DRW_opengl_context_create();
GPU_init();
- GPU_set_mipmap(bmain, true);
- GPU_set_linear_mipmap(true);
- GPU_set_anisotropic(U.anisotropic_filter);
GPU_pass_cache_init();
@@ -315,7 +313,7 @@ void WM_init(bContext *C, int argc, const char **argv)
/* sets 3D mouse deadzone */
WM_ndof_deadzone_set(U.ndof_deadzone);
#endif
- WM_init_opengl(G_MAIN);
+ WM_init_opengl();
if (!WM_platform_support_perform_checks()) {
exit(-1);
@@ -578,7 +576,7 @@ void WM_exit_ex(bContext *C, const bool do_python)
BKE_subdiv_exit();
if (opengl_is_init) {
- GPU_free_unused_buffers();
+ BKE_image_free_unused_gpu_textures();
}
BKE_blender_free(); /* blender.c, does entire library and spacetypes */
@@ -637,6 +635,8 @@ void WM_exit_ex(bContext *C, const bool do_python)
RNA_exit(); /* should be after BPY_python_end so struct python slots are cleared */
+ GPU_backend_exit();
+
wm_ghost_exit();
CTX_free(C);
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 87a19d832c9..c9b125901e7 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -344,9 +344,7 @@ void *WM_jobs_customdata_get(wmJob *wm_job)
if (!wm_job->customdata) {
return wm_job->run_customdata;
}
- else {
- return wm_job->customdata;
- }
+ return wm_job->customdata;
}
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void (*free)(void *))
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index d7102a1e8af..d7ff2689a86 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -321,9 +321,7 @@ bool WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
return true;
}
- else {
- return false;
- }
+ return false;
}
void WM_keyconfig_clear(wmKeyConfig *keyconf)
@@ -363,7 +361,7 @@ void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname)
WM_keyconfig_update(wm);
BLI_strncpy(U.keyconfigstr, idname, sizeof(U.keyconfigstr));
- if (wm->initialized & WM_KEYCONFIG_IS_INITIALIZED) {
+ if (wm->initialized & WM_KEYCONFIG_IS_INIT) {
U.runtime.is_dirty = true;
}
@@ -448,9 +446,7 @@ bool WM_keymap_remove(wmKeyConfig *keyconf, wmKeyMap *keymap)
return true;
}
- else {
- return false;
- }
+ return false;
}
bool WM_keymap_poll(bContext *C, wmKeyMap *keymap)
@@ -551,9 +547,7 @@ bool WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
WM_keyconfig_update_tag(keymap, NULL);
return true;
}
- else {
- return false;
- }
+ return false;
}
/** \} */
@@ -1122,7 +1116,7 @@ const char *WM_key_event_string(const short type, const bool compact)
if (platform == MACOS) {
return key_event_glyph_or_text(font_id, IFACE_("Cmd"), "\xe2\x8c\x98");
}
- else if (platform == MSWIN) {
+ if (platform == MSWIN) {
return key_event_glyph_or_text(font_id, IFACE_("Win"), "\xe2\x9d\x96");
}
return IFACE_("OS");
diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c
index 5ab36b15666..953fb9fed79 100644
--- a/source/blender/windowmanager/intern/wm_keymap_utils.c
+++ b/source/blender/windowmanager/intern/wm_keymap_utils.c
@@ -217,7 +217,6 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
* FLUID_OT
* TEXTURE_OT
* UI_OT
- * VIEW2D_OT
* WORLD_OT
*/
@@ -344,6 +343,10 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
break;
}
}
+ /* General 2D View, not bound to a specific spacetype. */
+ else if (STRPREFIX(opname, "VIEW2D_OT")) {
+ km = WM_keymap_find_all(wm, "View2D", 0, 0);
+ }
/* Image Editor */
else if (STRPREFIX(opname, "IMAGE_OT")) {
km = WM_keymap_find_all(wm, "Image", sl->spacetype, 0);
@@ -379,7 +382,25 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
}
/* Animation Generic - after channels */
else if (STRPREFIX(opname, "ANIM_OT")) {
- km = WM_keymap_find_all(wm, "Animation", 0, 0);
+ if (sl->spacetype == SPACE_VIEW3D) {
+ switch (CTX_data_mode_enum(C)) {
+ case CTX_MODE_OBJECT:
+ km = WM_keymap_find_all(wm, "Object Mode", 0, 0);
+ break;
+ case CTX_MODE_POSE:
+ km = WM_keymap_find_all(wm, "Pose", 0, 0);
+ break;
+ default:
+ break;
+ }
+ if (km && !WM_keymap_poll((bContext *)C, km)) {
+ km = NULL;
+ }
+ }
+
+ if (!km) {
+ km = WM_keymap_find_all(wm, "Animation", 0, 0);
+ }
}
/* Graph Editor */
else if (STRPREFIX(opname, "GRAPH_OT")) {
diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c
index 650d5bbe015..457cd0f16be 100644
--- a/source/blender/windowmanager/intern/wm_operator_type.c
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@ -606,9 +606,7 @@ char *WM_operatortype_description(struct bContext *C,
if (description[0]) {
return description;
}
- else {
- MEM_freeN(description);
- }
+ MEM_freeN(description);
}
}
@@ -621,9 +619,7 @@ char *WM_operatortype_description(struct bContext *C,
if (info && info[0]) {
return BLI_strdup(info);
}
- else {
- return NULL;
- }
+ return NULL;
}
/** \} */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index d1f65b6271b..1964813fff9 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -864,19 +864,17 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
return ret_value | OPERATOR_PASS_THROUGH;
}
- else {
- /* If we are in init phase, and cannot validate init of modal operations,
- * just fall back to basic exec.
- */
- RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false);
+ /* If we are in init phase, and cannot validate init of modal operations,
+ * just fall back to basic exec.
+ */
+ RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false);
- ret_value = op->type->exec(C, op);
- OPERATOR_RETVAL_CHECK(ret_value);
+ ret_value = op->type->exec(C, op);
+ OPERATOR_RETVAL_CHECK(ret_value);
- return ret_value | OPERATOR_PASS_THROUGH;
- }
+ return ret_value | OPERATOR_PASS_THROUGH;
}
- else if (event->type == init_event_type && event->val == KM_RELEASE) {
+ if (event->type == init_event_type && event->val == KM_RELEASE) {
RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false);
ret_value = op->type->exec(C, op);
@@ -884,7 +882,7 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
return ret_value | OPERATOR_PASS_THROUGH;
}
- else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
+ if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
const int drag_delta[2] = {
mval[0] - event->mval[0],
mval[1] - event->mval[1],
@@ -895,11 +893,9 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (WM_event_drag_test_with_delta(event, drag_delta)) {
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
}
- else {
- /* Important not to return anything other than PASS_THROUGH here,
- * otherwise it prevents underlying tweak detection code to work properly. */
- return OPERATOR_PASS_THROUGH;
- }
+ /* Important not to return anything other than PASS_THROUGH here,
+ * otherwise it prevents underlying tweak detection code to work properly. */
+ return OPERATOR_PASS_THROUGH;
}
return OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH;
@@ -1151,9 +1147,7 @@ int WM_operator_confirm_or_exec(bContext *C, wmOperator *op, const wmEvent *UNUS
if (confirm) {
return WM_operator_confirm_message(C, op, NULL);
}
- else {
- return op->type->exec(C, op);
- }
+ return op->type->exec(C, op);
}
/* op->invoke, opens fileselect if path property not set, otherwise executes */
@@ -1162,10 +1156,8 @@ int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *UNUSED(event
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return WM_operator_call_notest(C, op); /* call exec direct */
}
- else {
- WM_event_add_fileselect(C, op);
- return OPERATOR_RUNNING_MODAL;
- }
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
}
bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFormatData *im_format)
@@ -2322,7 +2314,7 @@ static void radial_control_paint_curve(uint pos, Brush *br, float radius, int li
GPU_line_width(2.0f);
immUniformColor4f(0.8f, 0.8f, 0.8f, 0.85f);
float step = (radius * 2.0f) / (float)line_segments;
- BKE_curvemapping_initialize(br->curve);
+ BKE_curvemapping_init(br->curve);
immBegin(GPU_PRIM_LINES, line_segments * 2);
for (int i = 0; i < line_segments; i++) {
float h1 = BKE_brush_curve_strength_clamped(br, fabsf((i * step) - radius), radius);
@@ -2453,7 +2445,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, r2, 80);
if (rmin > 0.0f) {
/* Inner fill circle to increase the contrast of the value */
- float black[3] = {0.0f};
+ const float black[3] = {0.0f};
immUniformColor3fvAlpha(black, 0.2f);
imm_draw_circle_fill_2d(pos, 0.0, 0.0f, rmin, 80);
@@ -2536,10 +2528,8 @@ static int radial_control_get_path(PointerRNA *ctx_ptr,
if (flags & RC_PROP_ALLOW_MISSING) {
return 1;
}
- else {
- BKE_reportf(op->reports, RPT_ERROR, "Could not resolve path '%s'", name);
- return 0;
- }
+ BKE_reportf(op->reports, RPT_ERROR, "Could not resolve path '%s'", name);
+ return 0;
}
/* check property type */
@@ -2591,13 +2581,12 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
(RC_PROP_ALLOW_MISSING | RC_PROP_REQUIRE_BOOL))) {
return 0;
}
+
+ if (use_secondary_prop && RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop)) {
+ data_path = "data_path_secondary";
+ }
else {
- if (use_secondary_prop && RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop)) {
- data_path = "data_path_secondary";
- }
- else {
- data_path = "data_path_primary";
- }
+ data_path = "data_path_primary";
}
if (!radial_control_get_path(&ctx_ptr, op, data_path, &rc->ptr, &rc->prop, 0, 0)) {
@@ -2664,7 +2653,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
if (!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0)) {
return 0;
}
- else if (rc->image_id_ptr.data) {
+ if (rc->image_id_ptr.data) {
/* extra check, pointer must be to an ID */
if (!RNA_struct_is_ID(rc->image_id_ptr.type)) {
BKE_report(op->reports, RPT_ERROR, "Pointer from path image_id is not an ID");
@@ -2841,171 +2830,169 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
radial_control_update_header(op, C);
return OPERATOR_RUNNING_MODAL;
}
- else {
- handled = false;
- switch (event->type) {
- case EVT_ESCKEY:
- case RIGHTMOUSE:
- /* canceled; restore original value */
- radial_control_set_value(rc, rc->initial_value);
- ret = OPERATOR_CANCELLED;
- break;
-
- case LEFTMOUSE:
- case EVT_PADENTER:
- case EVT_RETKEY:
- /* done; value already set */
- RNA_property_update(C, &rc->ptr, rc->prop);
- ret = OPERATOR_FINISHED;
- break;
-
- case MOUSEMOVE:
- if (!has_numInput) {
- if (rc->slow_mode) {
- if (rc->subtype == PROP_ANGLE) {
- float position[2] = {event->x, event->y};
-
- /* calculate the initial angle here first */
- delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
- delta[1] = rc->initial_mouse[1] - rc->slow_mouse[1];
-
- /* precision angle gets calculated from dial and gets added later */
- angle_precision = -0.1f * BLI_dial_angle(rc->dial, position);
- }
- else {
- delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
- delta[1] = 0.0f;
- if (rc->zoom_prop) {
- RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
- delta[0] /= zoom[0];
- }
+ handled = false;
+ switch (event->type) {
+ case EVT_ESCKEY:
+ case RIGHTMOUSE:
+ /* canceled; restore original value */
+ radial_control_set_value(rc, rc->initial_value);
+ ret = OPERATOR_CANCELLED;
+ break;
- dist = len_v2(delta);
+ case LEFTMOUSE:
+ case EVT_PADENTER:
+ case EVT_RETKEY:
+ /* done; value already set */
+ RNA_property_update(C, &rc->ptr, rc->prop);
+ ret = OPERATOR_FINISHED;
+ break;
- delta[0] = event->x - rc->slow_mouse[0];
+ case MOUSEMOVE:
+ if (!has_numInput) {
+ if (rc->slow_mode) {
+ if (rc->subtype == PROP_ANGLE) {
+ const float position[2] = {event->x, event->y};
- if (rc->zoom_prop) {
- delta[0] /= zoom[0];
- }
+ /* calculate the initial angle here first */
+ delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
+ delta[1] = rc->initial_mouse[1] - rc->slow_mouse[1];
- dist = dist + 0.1f * (delta[0]);
- }
+ /* precision angle gets calculated from dial and gets added later */
+ angle_precision = -0.1f * BLI_dial_angle(rc->dial, position);
}
else {
- delta[0] = rc->initial_mouse[0] - event->x;
- delta[1] = rc->initial_mouse[1] - event->y;
+ delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
+ delta[1] = 0.0f;
+
if (rc->zoom_prop) {
RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
delta[0] /= zoom[0];
- delta[1] /= zoom[1];
}
- if (rc->subtype == PROP_ANGLE) {
- dist = len_v2(delta);
- }
- else {
- dist = clamp_f(-delta[0], 0.0f, FLT_MAX);
+
+ dist = len_v2(delta);
+
+ delta[0] = event->x - rc->slow_mouse[0];
+
+ if (rc->zoom_prop) {
+ delta[0] /= zoom[0];
}
- }
- /* calculate new value and apply snapping */
- switch (rc->subtype) {
- case PROP_NONE:
- case PROP_DISTANCE:
- case PROP_PIXEL:
- new_value = dist;
- if (snap) {
- new_value = ((int)new_value + 5) / 10 * 10;
- }
- break;
- case PROP_PERCENTAGE:
- new_value = ((dist - WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE) /
- WM_RADIAL_CONTROL_DISPLAY_WIDTH) *
- 100.0f;
- if (snap) {
- new_value = ((int)(new_value + 2.5f)) / 5 * 5;
- }
- break;
- 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;
- }
- /* Invert new value to increase the factor moving the mouse to the right */
- new_value = 1 - new_value;
- break;
- case PROP_ANGLE:
- new_value = atan2f(delta[1], delta[0]) + (float)M_PI + angle_precision;
- new_value = fmod(new_value, 2.0f * (float)M_PI);
- if (new_value < 0.0f) {
- new_value += 2.0f * (float)M_PI;
- }
- if (snap) {
- new_value = DEG2RADF(((int)RAD2DEGF(new_value) + 5) / 10 * 10);
- }
- break;
- default:
- new_value = dist; /* dummy value, should this ever happen? - campbell */
- break;
+ dist = dist + 0.1f * (delta[0]);
}
-
- /* clamp and update */
- CLAMP(new_value, rc->min_value, rc->max_value);
- radial_control_set_value(rc, new_value);
- rc->current_value = new_value;
- handled = true;
- break;
}
- break;
-
- case EVT_LEFTSHIFTKEY:
- case EVT_RIGHTSHIFTKEY: {
- if (event->val == KM_PRESS) {
- rc->slow_mouse[0] = event->x;
- rc->slow_mouse[1] = event->y;
- rc->slow_mode = true;
+ else {
+ delta[0] = rc->initial_mouse[0] - event->x;
+ delta[1] = rc->initial_mouse[1] - event->y;
+ if (rc->zoom_prop) {
+ RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
+ delta[0] /= zoom[0];
+ delta[1] /= zoom[1];
+ }
if (rc->subtype == PROP_ANGLE) {
- float initial_position[2] = {UNPACK2(rc->initial_mouse)};
- float current_position[2] = {UNPACK2(rc->slow_mouse)};
- rc->dial = BLI_dial_initialize(initial_position, 0.0f);
- /* immediately set the position to get a an initial direction */
- BLI_dial_angle(rc->dial, current_position);
+ dist = len_v2(delta);
}
- handled = true;
- }
- if (event->val == KM_RELEASE) {
- rc->slow_mode = false;
- handled = true;
- if (rc->dial) {
- MEM_freeN(rc->dial);
- rc->dial = NULL;
+ else {
+ dist = clamp_f(-delta[0], 0.0f, FLT_MAX);
}
}
+
+ /* calculate new value and apply snapping */
+ switch (rc->subtype) {
+ case PROP_NONE:
+ case PROP_DISTANCE:
+ case PROP_PIXEL:
+ new_value = dist;
+ if (snap) {
+ new_value = ((int)new_value + 5) / 10 * 10;
+ }
+ break;
+ case PROP_PERCENTAGE:
+ new_value = ((dist - WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE) /
+ WM_RADIAL_CONTROL_DISPLAY_WIDTH) *
+ 100.0f;
+ if (snap) {
+ new_value = ((int)(new_value + 2.5f)) / 5 * 5;
+ }
+ break;
+ 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;
+ }
+ /* Invert new value to increase the factor moving the mouse to the right */
+ new_value = 1 - new_value;
+ break;
+ case PROP_ANGLE:
+ new_value = atan2f(delta[1], delta[0]) + (float)M_PI + angle_precision;
+ new_value = fmod(new_value, 2.0f * (float)M_PI);
+ if (new_value < 0.0f) {
+ new_value += 2.0f * (float)M_PI;
+ }
+ if (snap) {
+ new_value = DEG2RADF(((int)RAD2DEGF(new_value) + 5) / 10 * 10);
+ }
+ break;
+ default:
+ new_value = dist; /* dummy value, should this ever happen? - campbell */
+ break;
+ }
+
+ /* clamp and update */
+ CLAMP(new_value, rc->min_value, rc->max_value);
+ radial_control_set_value(rc, new_value);
+ rc->current_value = new_value;
+ handled = true;
break;
}
+ break;
+
+ case EVT_LEFTSHIFTKEY:
+ case EVT_RIGHTSHIFTKEY: {
+ if (event->val == KM_PRESS) {
+ rc->slow_mouse[0] = event->x;
+ rc->slow_mouse[1] = event->y;
+ rc->slow_mode = true;
+ if (rc->subtype == PROP_ANGLE) {
+ const float initial_position[2] = {UNPACK2(rc->initial_mouse)};
+ const float current_position[2] = {UNPACK2(rc->slow_mouse)};
+ rc->dial = BLI_dial_init(initial_position, 0.0f);
+ /* immediately set the position to get a an initial direction */
+ BLI_dial_angle(rc->dial, current_position);
+ }
+ handled = true;
+ }
+ if (event->val == KM_RELEASE) {
+ rc->slow_mode = false;
+ handled = true;
+ if (rc->dial) {
+ MEM_freeN(rc->dial);
+ rc->dial = NULL;
+ }
+ }
+ break;
}
+ }
- /* Modal numinput inactive, try to handle numeric inputs last... */
- if (!handled && event->val == KM_PRESS && handleNumInput(C, &rc->num_input, event)) {
- applyNumInput(&rc->num_input, &numValue);
+ /* Modal numinput inactive, try to handle numeric inputs last... */
+ if (!handled && event->val == KM_PRESS && handleNumInput(C, &rc->num_input, event)) {
+ applyNumInput(&rc->num_input, &numValue);
- if (rc->subtype == PROP_ANGLE) {
- numValue = fmod(numValue, 2.0f * (float)M_PI);
- if (numValue < 0.0f) {
- numValue += 2.0f * (float)M_PI;
- }
+ if (rc->subtype == PROP_ANGLE) {
+ numValue = fmod(numValue, 2.0f * (float)M_PI);
+ if (numValue < 0.0f) {
+ numValue += 2.0f * (float)M_PI;
}
+ }
- CLAMP(numValue, rc->min_value, rc->max_value);
- new_value = numValue;
+ CLAMP(numValue, rc->min_value, rc->max_value);
+ new_value = numValue;
- radial_control_set_value(rc, new_value);
+ radial_control_set_value(rc, new_value);
- rc->current_value = new_value;
- radial_control_update_header(op, C);
- return OPERATOR_RUNNING_MODAL;
- }
+ rc->current_value = new_value;
+ radial_control_update_header(op, C);
+ return OPERATOR_RUNNING_MODAL;
}
ED_region_tag_redraw(CTX_wm_region(C));
@@ -3722,6 +3709,7 @@ static int wm_xr_session_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C);
/* Lazy-create xr context - tries to dynlink to the runtime, reading active_runtime.json. */
@@ -3730,7 +3718,7 @@ static int wm_xr_session_toggle_exec(bContext *C, wmOperator *UNUSED(op))
}
v3d->runtime.flag |= V3D_RUNTIME_XR_SESSION_ROOT;
- wm_xr_session_toggle(wm, wm_xr_session_update_screen_on_exit_cb);
+ wm_xr_session_toggle(wm, win, wm_xr_session_update_screen_on_exit_cb);
wm_xr_session_update_screen(bmain, &wm->xr);
WM_event_add_notifier(C, NC_WM | ND_XR_DATA_CHANGED, NULL);
@@ -3917,6 +3905,7 @@ static void gesture_box_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "CLIP_OT_select_box");
WM_modalkeymap_assign(keymap, "CLIP_OT_graph_select_box");
WM_modalkeymap_assign(keymap, "MASK_OT_select_box");
+ WM_modalkeymap_assign(keymap, "PAINT_OT_mask_box_gesture");
WM_modalkeymap_assign(keymap, "VIEW2D_OT_zoom_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_render_border");
diff --git a/source/blender/windowmanager/intern/wm_platform_support.h b/source/blender/windowmanager/intern/wm_platform_support.h
index a8e20f6bcdf..6346f517343 100644
--- a/source/blender/windowmanager/intern/wm_platform_support.h
+++ b/source/blender/windowmanager/intern/wm_platform_support.h
@@ -20,11 +20,8 @@
/** \file
* \ingroup wm
*/
-#ifndef __WM_PLATFORM_SUPPORT_H__
-#define __WM_PLATFORM_SUPPORT_H__
+#pragma once
#include "BLI_sys_types.h"
bool WM_platform_support_perform_checks(void);
-
-#endif
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index d0a70596957..a0a21fadbbb 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -1293,8 +1293,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
// GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
/* initialize OpenGL immediate mode */
- GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(g_WS.ghost_window);
- g_WS.gpu_context = GPU_context_create(default_fb);
+ g_WS.gpu_context = GPU_context_create(g_WS.ghost_window);
GPU_init();
immActivate();
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index 245560d3795..9667ed5b631 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -353,12 +353,11 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_WINDOW, NULL);
return OPERATOR_FINISHED;
}
- else {
- /* without this, the popup won't be freed freed properly T44688 */
- CTX_wm_window_set(C, win_src);
- win_src->stereo3d_format->display_mode = prev_display_mode;
- return OPERATOR_CANCELLED;
- }
+
+ /* without this, the popup won't be freed freed properly T44688 */
+ CTX_wm_window_set(C, win_src);
+ win_src->stereo3d_format->display_mode = prev_display_mode;
+ return OPERATOR_CANCELLED;
}
int wm_stereo3d_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
@@ -368,9 +367,7 @@ int wm_stereo3d_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
if (wm_stereo3d_set_properties(C, op)) {
return wm_stereo3d_set_exec(C, op);
}
- else {
- return WM_operator_props_dialog_popup(C, op, 250);
- }
+ return WM_operator_props_dialog_popup(C, op, 250);
}
void wm_stereo3d_set_draw(bContext *UNUSED(C), wmOperator *op)
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index e444c5b2109..47afa343394 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -355,10 +355,8 @@ wmWindow *wm_window_copy_test(bContext *C,
WM_event_add_notifier_ex(wm, CTX_wm_window(C), NC_WINDOW | NA_ADDED, NULL);
return win_dst;
}
- else {
- wm_window_close(C, wm, win_dst);
- return NULL;
- }
+ wm_window_close(C, wm, win_dst);
+ return NULL;
}
/** \} */
@@ -617,8 +615,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
if (ghostwin) {
GHOST_RectangleHandle bounds;
- GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(ghostwin);
- win->gpuctx = GPU_context_create(default_fb);
+ win->gpuctx = GPU_context_create(ghostwin);
/* needed so we can detect the graphics card below */
GPU_init();
@@ -813,9 +810,7 @@ static bool wm_window_update_size_position(wmWindow *win)
win->posy = posy;
return true;
}
- else {
- return false;
- }
+ return false;
}
/**
@@ -840,11 +835,10 @@ wmWindow *WM_window_open(bContext *C, const rcti *rect)
if (win->ghostwin) {
return win;
}
- else {
- wm_window_close(C, wm, win);
- CTX_wm_window_set(C, win_prev);
- return NULL;
- }
+
+ wm_window_close(C, wm, win);
+ CTX_wm_window_set(C, win_prev);
+ return NULL;
}
/**
@@ -969,13 +963,12 @@ wmWindow *WM_window_open_temp(bContext *C,
GHOST_SetTitle(win->ghostwin, title);
return win;
}
- else {
- /* very unlikely! but opening a new window can fail */
- wm_window_close(C, wm, win);
- CTX_wm_window_set(C, win_prev);
- return NULL;
- }
+ /* very unlikely! but opening a new window can fail */
+ wm_window_close(C, wm, win);
+ CTX_wm_window_set(C, win_prev);
+
+ return NULL;
}
/* ****************** Operators ****************** */
@@ -1206,7 +1199,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
/* Ghost now can call this function for life resizes,
* but it should return if WM didn't initialize yet.
* Can happen on file read (especially full size window). */
- if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) {
+ if ((wm->initialized & WM_WINDOW_IS_INIT) == 0) {
return 1;
}
if (!ghostwin) {
@@ -1215,15 +1208,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
puts("<!> event has no window");
return 1;
}
- else if (!GHOST_ValidWindow(g_system, ghostwin)) {
+ if (!GHOST_ValidWindow(g_system, ghostwin)) {
/* XXX - should be checked, why are we getting an event here, and */
/* what is it? */
puts("<!> event has invalid window");
return 1;
}
- else {
- win = GHOST_GetWindowUserData(ghostwin);
- }
+ win = GHOST_GetWindowUserData(ghostwin);
switch (type) {
case GHOST_kEventWindowDeactivate:
diff --git a/source/blender/windowmanager/intern/wm_window_private.h b/source/blender/windowmanager/intern/wm_window_private.h
index 115539861d7..c208d07ee37 100644
--- a/source/blender/windowmanager/intern/wm_window_private.h
+++ b/source/blender/windowmanager/intern/wm_window_private.h
@@ -20,8 +20,7 @@
/** \file
* \ingroup wm
*/
-#ifndef __WM_WINDOW_PRIVATE_H__
-#define __WM_WINDOW_PRIVATE_H__
+#pragma once
#include "BLI_sys_types.h"
#include "GHOST_Types.h"
@@ -38,5 +37,3 @@ void WM_ghost_show_message_box(const char *title,
const char *continue_label,
const char *link,
GHOST_DialogOptions dialog_options);
-
-#endif
diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h b/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h
index ccf7034e3e0..24c0192fe14 100644
--- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h
+++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h
@@ -18,8 +18,7 @@
* \ingroup wm
*/
-#ifndef __WM_MESSAGE_BUS_INTERN_H__
-#define __WM_MESSAGE_BUS_INTERN_H__
+#pragma once
#include "../wm_message_bus.h"
@@ -47,5 +46,3 @@ BLI_INLINE wmMsg *wm_msg_subscribe_value_msg_cast_mut(wmMsgSubscribeKey *key)
{
return &((wmMsgSubscribeKey_Generic *)key)->msg;
}
-
-#endif /* __WM_MESSAGE_BUS_INTERN_H__ */
diff --git a/source/blender/windowmanager/message_bus/wm_message_bus.h b/source/blender/windowmanager/message_bus/wm_message_bus.h
index 74472386a39..23a53eace52 100644
--- a/source/blender/windowmanager/message_bus/wm_message_bus.h
+++ b/source/blender/windowmanager/message_bus/wm_message_bus.h
@@ -18,8 +18,7 @@
* \ingroup wm
*/
-#ifndef __WM_MESSAGE_BUS_H__
-#define __WM_MESSAGE_BUS_H__
+#pragma once
#include "RNA_types.h"
#include <stdio.h>
@@ -294,5 +293,3 @@ void WM_msg_publish_ID(struct wmMsgBus *mbus, struct ID *id);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_MESSAGE_BUS_H__ */
diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h
index 2b59e047f23..baa47098bd3 100644
--- a/source/blender/windowmanager/wm.h
+++ b/source/blender/windowmanager/wm.h
@@ -21,8 +21,7 @@
* \ingroup wm
*/
-#ifndef __WM_H__
-#define __WM_H__
+#pragma once
struct ARegion;
struct ReportList;
@@ -104,5 +103,3 @@ void wm_open_init_use_scripts(wmOperator *op, bool use_prefs);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/windowmanager/wm_cursors.h b/source/blender/windowmanager/wm_cursors.h
index cdd6b325063..b85616deda5 100644
--- a/source/blender/windowmanager/wm_cursors.h
+++ b/source/blender/windowmanager/wm_cursors.h
@@ -21,8 +21,7 @@
* \ingroup wm
*/
-#ifndef __WM_CURSORS_H__
-#define __WM_CURSORS_H__
+#pragma once
struct wmEvent;
struct wmWindow;
@@ -84,5 +83,3 @@ bool wm_cursor_arrow_move(struct wmWindow *win, const struct wmEvent *event);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_CURSORS_H__ */
diff --git a/source/blender/windowmanager/wm_draw.h b/source/blender/windowmanager/wm_draw.h
index 9b6bd66c0e5..4997361b485 100644
--- a/source/blender/windowmanager/wm_draw.h
+++ b/source/blender/windowmanager/wm_draw.h
@@ -21,8 +21,7 @@
* \ingroup wm
*/
-#ifndef __WM_DRAW_H__
-#define __WM_DRAW_H__
+#pragma once
struct GPUOffScreen;
struct GPUTexture;
@@ -55,5 +54,3 @@ struct GPUTexture *wm_draw_region_texture(struct ARegion *region, int view);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_DRAW_H__ */
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index c61ba61f55d..787c840de8a 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -21,8 +21,7 @@
* \ingroup wm
*/
-#ifndef __WM_EVENT_SYSTEM_H__
-#define __WM_EVENT_SYSTEM_H__
+#pragma once
/* return value of handler-operator call */
#define WM_HANDLER_CONTINUE 0
@@ -172,5 +171,3 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_EVENT_SYSTEM_H__ */
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index 16b872c3c9c..ed8f39fea48 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -23,8 +23,7 @@
* Blender copied the conventions quite some, and expanded it with internal new defines (ton)
*/
-#ifndef __WM_EVENT_TYPES_H__
-#define __WM_EVENT_TYPES_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -496,5 +495,3 @@ enum {
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_EVENT_TYPES_H__ */
diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h
index d7f8c3fc583..d54090a6025 100644
--- a/source/blender/windowmanager/wm_files.h
+++ b/source/blender/windowmanager/wm_files.h
@@ -21,8 +21,7 @@
* \ingroup wm
*/
-#ifndef __WM_FILES_H__
-#define __WM_FILES_H__
+#pragma once
struct Main;
struct wmGenericCallback;
@@ -75,5 +74,3 @@ void WM_OT_lib_reload(struct wmOperatorType *ot);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_FILES_H__ */
diff --git a/source/blender/windowmanager/wm_surface.h b/source/blender/windowmanager/wm_surface.h
index 8ab6301e8c9..06c29231361 100644
--- a/source/blender/windowmanager/wm_surface.h
+++ b/source/blender/windowmanager/wm_surface.h
@@ -22,8 +22,7 @@
* Container to manage painting in an offscreen context.
*/
-#ifndef __WM_SURFACE_H__
-#define __WM_SURFACE_H__
+#pragma once
struct bContext;
@@ -66,5 +65,3 @@ void wm_surface_reset_drawable(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_SURFACE_H__ */
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index e3e8abae531..336db7edb50 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -21,8 +21,7 @@
* \ingroup wm
*/
-#ifndef __WM_WINDOW_H__
-#define __WM_WINDOW_H__
+#pragma once
struct wmOperator;
@@ -92,5 +91,3 @@ void wm_test_autorun_warning(bContext *C);
#ifdef __cplusplus
}
#endif
-
-#endif /* __WM_WINDOW_H__ */
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_draw.c b/source/blender/windowmanager/xr/intern/wm_xr_draw.c
index 684e59eb8b2..6f96d2ea6a0 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_draw.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_draw.c
@@ -55,7 +55,7 @@ static void wm_xr_draw_matrices_create(const wmXrDrawData *draw_data,
copy_qt_qt(eye_pose.orientation_quat, draw_view->eye_pose.orientation_quat);
copy_v3_v3(eye_pose.position, draw_view->eye_pose.position);
- add_v3_v3(eye_pose.position, draw_data->eye_position_ofs);
+ sub_v3_v3(eye_pose.position, draw_data->eye_position_ofs);
if ((session_settings->flag & XR_SESSION_USE_POSITION_TRACKING) == 0) {
sub_v3_v3(eye_pose.position, draw_view->local_pose.position);
}
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_intern.h b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
index 9b7e9a15948..25e3da3ffb4 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_intern.h
+++ b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
@@ -18,8 +18,7 @@
* \ingroup wm
*/
-#ifndef __WM_XR_INTERN_H__
-#define __WM_XR_INTERN_H__
+#pragma once
#include "CLG_log.h"
@@ -50,7 +49,11 @@ typedef struct wmXrSessionState {
typedef struct wmXrRuntimeData {
GHOST_XrContextHandle context;
- /* Although this struct is internal, RNA gets a handle to this for state information queries. */
+ /** The window the session was started in. Stored to be able to follow its view-layer. This may
+ * be an invalid reference, i.e. the window may have been closed. */
+ wmWindow *session_root_win;
+
+ /** Although this struct is internal, RNA gets a handle to this for state information queries. */
wmXrSessionState session_state;
wmXrSessionExitFn exit_fn;
} wmXrRuntimeData;
@@ -71,6 +74,8 @@ typedef struct wmXrDrawData {
* space). With positional tracking enabled, it should be the same as the base pose, when
* disabled it also contains a location delta from the moment the option was toggled. */
GHOST_XrPose base_pose;
+ /** Offset to _substract_ from the OpenXR eye and viewer pose to get the wanted effective pose
+ * (e.g. a pose exactly at the landmark position). */
float eye_position_ofs[3]; /* Local/view space. */
} wmXrDrawData;
@@ -92,5 +97,3 @@ void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle context);
void wm_xr_pose_to_viewmat(const GHOST_XrPose *pose, float r_viewmat[4][4]);
void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata);
-
-#endif
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c b/source/blender/windowmanager/xr/intern/wm_xr_session.c
index 8e7101ddcd5..f3ce7be993f 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_session.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c
@@ -19,7 +19,10 @@
*/
#include "BKE_context.h"
+#include "BKE_main.h"
+#include "BKE_scene.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "DEG_depsgraph.h"
@@ -41,8 +44,8 @@
#include "wm_window.h"
#include "wm_xr_intern.h"
-wmSurface *g_xr_surface = NULL;
-CLG_LogRef LOG = {"wm.xr"};
+static wmSurface *g_xr_surface = NULL;
+static CLG_LogRef LOG = {"wm.xr"};
/* -------------------------------------------------------------------- */
@@ -68,7 +71,9 @@ static void wm_xr_session_begin_info_create(wmXrData *xr_data,
r_begin_info->exit_customdata = xr_data;
}
-void wm_xr_session_toggle(wmWindowManager *wm, wmXrSessionExitFn session_exit_fn)
+void wm_xr_session_toggle(wmWindowManager *wm,
+ wmWindow *session_root_win,
+ wmXrSessionExitFn session_exit_fn)
{
wmXrData *xr_data = &wm->xr;
@@ -78,6 +83,7 @@ void wm_xr_session_toggle(wmWindowManager *wm, wmXrSessionExitFn session_exit_fn
else {
GHOST_XrSessionBeginInfo begin_info;
+ xr_data->runtime->session_root_win = session_root_win;
xr_data->runtime->session_state.is_started = true;
xr_data->runtime->exit_fn = session_exit_fn;
@@ -159,6 +165,43 @@ static void wm_xr_session_draw_data_populate(wmXrData *xr_data,
wm_xr_session_base_pose_calc(r_draw_data->scene, settings, &r_draw_data->base_pose);
}
+static wmWindow *wm_xr_session_root_window_or_fallback_get(const wmWindowManager *wm,
+ const wmXrRuntimeData *runtime_data)
+{
+ if (runtime_data->session_root_win &&
+ BLI_findindex(&wm->windows, runtime_data->session_root_win) != -1) {
+ /* Root window is still valid, use it. */
+ return runtime_data->session_root_win;
+ }
+ /* Otherwise, fallback. */
+ return wm->windows.first;
+}
+
+/**
+ * Get the scene and depsgraph shown in the VR session's root window (the window the session was
+ * started from) if still available. If it's not available, use some fallback window.
+ *
+ * It's important that the VR session follows some existing window, otherwise it would need to have
+ * an own depsgraph, which is an expense we should avoid.
+ */
+static void wm_xr_session_scene_and_evaluated_depsgraph_get(Main *bmain,
+ const wmWindowManager *wm,
+ Scene **r_scene,
+ Depsgraph **r_depsgraph)
+{
+ const wmWindow *root_win = wm_xr_session_root_window_or_fallback_get(wm, wm->xr.runtime);
+
+ /* Follow the scene & view layer shown in the root 3D View. */
+ Scene *scene = WM_window_get_active_scene(root_win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(root_win);
+
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, false);
+ BLI_assert(scene && view_layer && depsgraph);
+ BKE_scene_graph_evaluated_ensure(depsgraph, bmain);
+ *r_scene = scene;
+ *r_depsgraph = depsgraph;
+}
+
typedef enum wmXrSessionStateEvent {
SESSION_STATE_EVENT_NONE = 0,
SESSION_STATE_EVENT_START,
@@ -183,16 +226,15 @@ static wmXrSessionStateEvent wm_xr_session_state_to_event(const wmXrSessionState
if (!state->is_view_data_set) {
return SESSION_STATE_EVENT_START;
}
- else if (wm_xr_session_draw_data_needs_reset_to_base_pose(state, settings)) {
+ if (wm_xr_session_draw_data_needs_reset_to_base_pose(state, settings)) {
return SESSION_STATE_EVENT_RESET_TO_BASE_POSE;
}
- else {
- const bool position_tracking_toggled = ((state->prev_settings_flag &
- XR_SESSION_USE_POSITION_TRACKING) !=
- (settings->flag & XR_SESSION_USE_POSITION_TRACKING));
- if (position_tracking_toggled) {
- return SESSION_STATE_EVENT_POSITON_TRACKING_TOGGLE;
- }
+
+ const bool position_tracking_toggled = ((state->prev_settings_flag &
+ XR_SESSION_USE_POSITION_TRACKING) !=
+ (settings->flag & XR_SESSION_USE_POSITION_TRACKING));
+ if (position_tracking_toggled) {
+ return SESSION_STATE_EVENT_POSITON_TRACKING_TOGGLE;
}
return SESSION_STATE_EVENT_NONE;
@@ -208,8 +250,9 @@ void wm_xr_session_draw_data_update(const wmXrSessionState *state,
switch (event) {
case SESSION_STATE_EVENT_START:
- /* Always use the exact base pose with no offset when starting the session. */
- copy_v3_fl(draw_data->eye_position_ofs, 0.0f);
+ /* We want to start the session exactly at landmark position.
+ * Run-times may have a non-[0,0,0] starting position that we have to subtract for that. */
+ copy_v3_v3(draw_data->eye_position_ofs, draw_view->local_pose.position);
break;
/* This should be triggered by the VR add-on if a landmark changes. */
case SESSION_STATE_EVENT_RESET_TO_BASE_POSE:
@@ -256,9 +299,9 @@ void wm_xr_session_state_update(const XrSessionSettings *settings,
copy_v3_v3(viewer_pose.position, draw_data->base_pose.position);
/* The local pose and the eye pose (which is copied from an earlier local pose) both are view
* space, so Y-up. In this case we need them in regular Z-up. */
- viewer_pose.position[0] += draw_data->eye_position_ofs[0];
- viewer_pose.position[1] -= draw_data->eye_position_ofs[2];
- viewer_pose.position[2] += draw_data->eye_position_ofs[1];
+ viewer_pose.position[0] -= draw_data->eye_position_ofs[0];
+ viewer_pose.position[1] += draw_data->eye_position_ofs[2];
+ viewer_pose.position[2] -= draw_data->eye_position_ofs[1];
if (use_position_tracking) {
viewer_pose.position[0] += draw_view->local_pose.position[0];
viewer_pose.position[1] -= draw_view->local_pose.position[2];
@@ -344,13 +387,17 @@ static void wm_xr_session_surface_draw(bContext *C)
{
wmXrSurfaceData *surface_data = g_xr_surface->customdata;
wmWindowManager *wm = CTX_wm_manager(C);
+ Main *bmain = CTX_data_main(C);
wmXrDrawData draw_data;
if (!GHOST_XrSessionIsRunning(wm->xr.runtime->context)) {
return;
}
- wm_xr_session_draw_data_populate(
- &wm->xr, CTX_data_scene(C), CTX_data_ensure_evaluated_depsgraph(C), &draw_data);
+
+ Scene *scene;
+ Depsgraph *depsgraph;
+ wm_xr_session_scene_and_evaluated_depsgraph_get(bmain, wm, &scene, &depsgraph);
+ wm_xr_session_draw_data_populate(&wm->xr, scene, depsgraph, &draw_data);
GHOST_XrSessionDrawViews(wm->xr.runtime->context, &draw_data);
diff --git a/source/blender/windowmanager/xr/wm_xr.h b/source/blender/windowmanager/xr/wm_xr.h
index 33f79bc75b2..0f0fbe8bc00 100644
--- a/source/blender/windowmanager/xr/wm_xr.h
+++ b/source/blender/windowmanager/xr/wm_xr.h
@@ -18,8 +18,7 @@
* \ingroup wm
*/
-#ifndef __WM_XR_H__
-#define __WM_XR_H__
+#pragma once
struct wmWindowManager;
struct wmXrData;
@@ -29,7 +28,5 @@ typedef void (*wmXrSessionExitFn)(const wmXrData *xr_data);
/* wm_xr.c */
bool wm_xr_init(wmWindowManager *wm);
void wm_xr_exit(wmWindowManager *wm);
-void wm_xr_session_toggle(wmWindowManager *wm, wmXrSessionExitFn session_exit_fn);
+void wm_xr_session_toggle(wmWindowManager *wm, wmWindow *win, wmXrSessionExitFn session_exit_fn);
bool wm_xr_events_handle(wmWindowManager *wm);
-
-#endif
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index aed2a9350bb..8784d9f1744 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -694,6 +694,23 @@ elseif(WIN32)
)
endif()
+ if(WITH_GMP)
+ install(
+ FILES ${LIBDIR}/gmp/lib/libgmp-10.dll
+ DESTINATION "."
+ )
+ install(
+ FILES ${LIBDIR}/gmp/lib/libgmpxx.dll
+ DESTINATION "."
+ CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
+ )
+ install(
+ FILES ${LIBDIR}/gmp/lib/libgmpxx_d.dll
+ DESTINATION "."
+ CONFIGURATIONS Debug
+ )
+ endif()
+
if(WITH_WINDOWS_PDB)
if(WITH_WINDOWS_STRIPPED_PDB)
# Icky hack for older cmake from https://stackoverflow.com/a/21198501
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 9268ed15923..3d76d832d9f 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -110,25 +110,10 @@
#include "creator_intern.h" /* own include */
/* Local Function prototypes. */
-#ifdef WITH_PYTHON_MODULE
-int main_python_enter(int argc, const char **argv);
-void main_python_exit(void);
-#endif
-#ifdef WITH_USD
-/**
- * Workaround to make it possible to pass a path at runtime to USD.
- *
- * USD requires some JSON files, and it uses a static constructor to determine the possible
- * file-system paths to find those files. This made it impossible for Blender to pass a path to the
- * USD library at runtime, as the constructor would run before Blender's main() function. We have
- * patched USD (see usd.diff) to avoid that particular static constructor, and have an
- * initialization function instead.
- *
- * This function is implemented in the USD source code, `pxr/base/lib/plug/initConfig.cpp`.
- */
-void usd_initialise_plugin_path(const char *datafiles_usd_path);
-#endif
+/* -------------------------------------------------------------------- */
+/** \name Local Application State
+ * \{ */
/* written to by 'creator_args.c' */
struct ApplicationState app_state = {
@@ -143,6 +128,8 @@ struct ApplicationState app_state = {
},
};
+/** \} */
+
/* -------------------------------------------------------------------- */
/** \name Application Level Callbacks
*
@@ -199,11 +186,19 @@ static void callback_clg_fatal(void *fp)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Main Function
+/** \name Blender as a Stand-Alone Python Module (bpy)
+ *
+ * While not officially supported, this can be useful for Python developers.
+ * See: https://wiki.blender.org/wiki/Building_Blender/Other/BlenderAsPyModule
* \{ */
#ifdef WITH_PYTHON_MODULE
-/* allow python module to call main */
+
+/* Called in `bpy_interface.c` when building as a Python module. */
+int main_python_enter(int argc, const char **argv);
+void main_python_exit(void);
+
+/* Rename the 'main' function, allowing Python initialization to call it. */
# define main main_python_enter
static void *evil_C = NULL;
@@ -211,8 +206,15 @@ static void *evil_C = NULL;
/* Environment is not available in macOS shared libraries. */
# include <crt_externs.h>
char **environ = NULL;
-# endif
-#endif
+# endif /* __APPLE__ */
+
+#endif /* WITH_PYTHON_MODULE */
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Main Function
+ * \{ */
/**
* Blender's main function responsibilities are:
@@ -295,7 +297,7 @@ int main(int argc,
break;
}
}
- MEM_initialize_memleak_detection();
+ MEM_init_memleak_detection();
}
#ifdef BUILD_DATE
@@ -441,10 +443,21 @@ int main(int argc,
BKE_materials_init();
#ifdef WITH_USD
+ /* Workaround to make it possible to pass a path at runtime to USD.
+ *
+ * USD requires some JSON files, and it uses a static constructor to determine the possible
+ * file-system paths to find those files. This made it impossible for Blender to pass a path to
+ * the USD library at runtime, as the constructor would run before Blender's main() function.
+ * We have patched USD (see usd.diff) to avoid that particular static constructor, and have an
+ * initialization function instead.
+ *
+ * This function is implemented in the USD source code, `pxr/base/lib/plug/initConfig.cpp`. */
+ extern void usd_initialise_plugin_path(const char *datafiles_usd_path);
+
/* Tell USD which directory to search for its JSON files. If 'datafiles/usd'
* does not exist, the USD library will not be able to read or write any files. */
usd_initialise_plugin_path(BKE_appdir_folder_id(BLENDER_DATAFILES, "usd"));
-#endif
+#endif /* WITH_USD */
if (G.background == 0) {
#ifndef WITH_PYTHON_MODULE
@@ -488,7 +501,7 @@ int main(int argc,
#ifdef WITH_FREESTYLE
/* Initialize Freestyle. */
- FRS_initialize();
+ FRS_init();
FRS_set_context(C);
#endif
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 20a75ebe3b9..b8e99899821 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -2192,6 +2192,12 @@ void main_args_setup(bContext *C, bArgs *ba)
BLI_argsAdd(ba,
1,
NULL,
+ "--debug-depsgraph-uuid",
+ CB_EX(arg_handle_debug_mode_generic_set, depsgraph_build),
+ (void *)G_DEBUG_DEPSGRAPH_UUID);
+ BLI_argsAdd(ba,
+ 1,
+ NULL,
"--debug-gpumem",
CB_EX(arg_handle_debug_mode_generic_set, gpumem),
(void *)G_DEBUG_GPU_MEM);
diff --git a/source/creator/creator_intern.h b/source/creator/creator_intern.h
index 9c7d3d95498..7ff3247e17e 100644
--- a/source/creator/creator_intern.h
+++ b/source/creator/creator_intern.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __CREATOR_INTERN_H__
-#define __CREATOR_INTERN_H__
+#pragma once
/** \file
* \ingroup creator
@@ -82,5 +81,3 @@ extern char build_cxxflags[];
extern char build_linkflags[];
extern char build_system[];
#endif
-
-#endif /* __CREATOR_INTERN_H__ */
diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c
index dbf947a86fd..ad0b7b2547d 100644
--- a/source/creator/creator_signals.c
+++ b/source/creator/creator_signals.c
@@ -59,6 +59,10 @@
# include <signal.h>
+# ifdef WITH_PYTHON
+# include "BPY_extern.h" /* BPY_python_backtrace */
+# endif
+
# include "creator_intern.h" /* own include */
// #define USE_WRITE_CRASH_BLEND
@@ -174,6 +178,11 @@ static void sig_handle_crash(int signum)
sig_handle_crash_backtrace(fp);
+# ifdef WITH_PYTHON
+ /* Generate python back-trace if Python is currently active. */
+ BPY_python_backtrace(fp);
+# endif
+
fclose(fp);
}
diff --git a/tests/gtests/CMakeLists.txt b/tests/gtests/CMakeLists.txt
index 9a7509f81f3..2a89aaa4aea 100644
--- a/tests/gtests/CMakeLists.txt
+++ b/tests/gtests/CMakeLists.txt
@@ -3,19 +3,9 @@ if(WITH_GTESTS)
# Otherwise we get warnings here that we cant fix in external projects
remove_strict_flags()
- # Build common test runner
+ # Build common test executable used by most tests
add_subdirectory(runner)
- # Build tests not yet ported to the common runner
+ # Build utility library used by test executables
add_subdirectory(testing)
- add_subdirectory(blenlib)
- add_subdirectory(blenloader)
- add_subdirectory(guardedalloc)
- add_subdirectory(bmesh)
- if(WITH_CODEC_FFMPEG)
- add_subdirectory(ffmpeg)
- endif()
- if(WITH_ALEMBIC)
- add_subdirectory(alembic)
- endif()
endif()
diff --git a/tests/gtests/alembic/CMakeLists.txt b/tests/gtests/alembic/CMakeLists.txt
deleted file mode 100644
index 90f1829fc77..00000000000
--- a/tests/gtests/alembic/CMakeLists.txt
+++ /dev/null
@@ -1,63 +0,0 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# 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) 2014, Blender Foundation
-# All rights reserved.
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ..
- ../../../source/blender/blenlib
- ../../../source/blender/blenkernel
- ../../../source/blender/io/alembic
- ../../../source/blender/io/common
- ../../../source/blender/io/usd/intern
- ../../../source/blender/makesdna
- ../../../source/blender/depsgraph
- ${ALEMBIC_INCLUDE_DIRS}
- ${BOOST_INCLUDE_DIR}
- ${HDF5_INCLUDE_DIRS}
- ${OPENEXR_INCLUDE_DIRS}
-)
-
-set(LIB
- bf_blenloader # Should not be needed but gives linking error without it.
- bf_intern_opencolorio # Should not be needed but gives windows linker errors if the ocio libs are linked before this
- bf_gpu # Should not be needed but gives windows linker errors if the ocio libs are linked before this
- bf_alembic
-
- ${OPENEXR_LIBRARIES}
- ${BOOST_LIBRARIES}
-)
-
-include_directories(${INC})
-
-setup_libdirs()
-get_property(BLENDER_SORTED_LIBS GLOBAL PROPERTY BLENDER_SORTED_LIBS_PROP)
-
-if(WITH_BUILDINFO)
- set(_buildinfo_src "$<TARGET_OBJECTS:buildinfoobj>")
-else()
- set(_buildinfo_src "")
-endif()
-
-# For motivation on doubling BLENDER_SORTED_LIBS, see ../bmesh/CMakeLists.txt
-BLENDER_SRC_GTEST(alembic "abc_matrix_test.cc;abc_export_test.cc;${_buildinfo_src}" "${LIB}")
-
-unset(_buildinfo_src)
-
-setup_liblinks(alembic_test)
diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt
deleted file mode 100644
index 0727d317eaa..00000000000
--- a/tests/gtests/blenlib/CMakeLists.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# 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) 2014, Blender Foundation
-# All rights reserved.
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ..
- ../../../source/blender/blenlib
- ../../../source/blender/makesdna
- ../../../intern/guardedalloc
- ../../../intern/atomic
-)
-
-setup_libdirs()
-include_directories(${INC})
-
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
-set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
-
-if(WIN32)
- set(BLI_path_util_extra_libs "bf_blenlib;bf_intern_utfconv;extern_wcwidth;${ZLIB_LIBRARIES}")
-else()
- set(BLI_path_util_extra_libs "bf_blenlib;extern_wcwidth;${ZLIB_LIBRARIES}")
-endif()
-
-BLENDER_TEST(BLI_array_store "bf_blenlib")
-BLENDER_TEST(BLI_array_utils "bf_blenlib")
-BLENDER_TEST(BLI_delaunay_2d "bf_blenlib")
-BLENDER_TEST(BLI_expr_pylike_eval "bf_blenlib")
-BLENDER_TEST(BLI_ghash "bf_blenlib")
-BLENDER_TEST(BLI_hash_mm2a "bf_blenlib")
-BLENDER_TEST(BLI_heap "bf_blenlib")
-BLENDER_TEST(BLI_heap_simple "bf_blenlib")
-BLENDER_TEST(BLI_kdopbvh "bf_blenlib;bf_intern_numaapi")
-BLENDER_TEST(BLI_linklist_lockfree "bf_blenlib;bf_intern_numaapi")
-BLENDER_TEST(BLI_listbase "bf_blenlib")
-BLENDER_TEST(BLI_math_base "bf_blenlib")
-BLENDER_TEST(BLI_math_bits "bf_blenlib")
-BLENDER_TEST(BLI_math_color "bf_blenlib")
-BLENDER_TEST(BLI_math_geom "bf_blenlib")
-BLENDER_TEST(BLI_math_matrix "bf_blenlib")
-BLENDER_TEST(BLI_math_vector "bf_blenlib")
-BLENDER_TEST(BLI_memiter "bf_blenlib")
-BLENDER_TEST(BLI_path_util "${BLI_path_util_extra_libs}")
-BLENDER_TEST(BLI_polyfill_2d "bf_blenlib")
-BLENDER_TEST(BLI_stack "bf_blenlib")
-BLENDER_TEST(BLI_string "bf_blenlib")
-BLENDER_TEST(BLI_string_utf8 "bf_blenlib")
-BLENDER_TEST(BLI_task "bf_blenlib;bf_intern_numaapi")
-BLENDER_TEST(BLI_task_graph "bf_blenlib;bf_intern_numaapi")
-
-BLENDER_TEST_PERFORMANCE(BLI_ghash_performance "bf_blenlib")
-BLENDER_TEST_PERFORMANCE(BLI_task_performance "bf_blenlib")
-
-unset(BLI_path_util_extra_libs)
diff --git a/tests/gtests/blenlib/stubs/bf_intern_eigen_stubs.h b/tests/gtests/blenlib/stubs/bf_intern_eigen_stubs.h
deleted file mode 100644
index dec2631fc63..00000000000
--- a/tests/gtests/blenlib/stubs/bf_intern_eigen_stubs.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Apache License, Version 2.0 */
-
-extern "C" {
-
-void EIG_svd_square_matrix(
- const int size, const float *matrix, float *r_U, float *r_S, float *r_V);
-bool EIG_self_adjoint_eigen_solve(const int size,
- const float *matrix,
- float *r_eigen_values,
- float *r_eigen_vectors);
-
-bool EIG_self_adjoint_eigen_solve(const int size,
- const float *matrix,
- float *r_eigen_values,
- float *r_eigen_vectors)
-{
- BLI_assert(0);
- UNUSED_VARS(size, matrix, r_eigen_values, r_eigen_vectors);
- return false;
-}
-
-void EIG_svd_square_matrix(const int size, const float *matrix, float *r_U, float *r_S, float *r_V)
-{
- BLI_assert(0);
- UNUSED_VARS(size, matrix, r_U, r_S, r_V);
-}
-}
diff --git a/tests/gtests/blenloader/CMakeLists.txt b/tests/gtests/blenloader/CMakeLists.txt
deleted file mode 100644
index 5c071c614c6..00000000000
--- a/tests/gtests/blenloader/CMakeLists.txt
+++ /dev/null
@@ -1,92 +0,0 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# 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) 2019 by Blender Foundation.
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ..
- ../../../source/blender/blenkernel
- ../../../source/blender/blenlib
- ../../../source/blender/blenloader
- ../../../source/blender/depsgraph
- ../../../source/blender/imbuf
- ../../../source/blender/makesdna
- ../../../source/blender/makesrna
- ../../../source/blender/windowmanager
- ../../../intern/guardedalloc
- ${GLOG_INCLUDE_DIRS}
- ${GFLAGS_INCLUDE_DIRS}
- ../../../extern/gtest/include
-)
-
-set(SRC
- blendfile_loading_base_test.cc
- blendfile_loading_base_test.h
-)
-
-set(LIB
-)
-
-blender_add_lib(bf_blenloader_test "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
-
-
-set(INC
- .
- ..
- ../../../source/blender/blenlib
- ../../../source/blender/blenloader
- ../../../source/blender/blenkernel
- ../../../source/blender/makesdna
- ../../../source/blender/makesrna
- ../../../source/blender/depsgraph
- ../../../intern/guardedalloc
-)
-
-set(LIB
- bf_blenloader_test
- bf_blenloader
-
- # Should not be needed but gives windows linker errors if the ocio libs are linked before this:
- bf_intern_opencolorio
- bf_gpu
-)
-
-include_directories(${INC})
-
-setup_libdirs()
-get_property(BLENDER_SORTED_LIBS GLOBAL PROPERTY BLENDER_SORTED_LIBS_PROP)
-
-
-set(SRC
- blendfile_load_test.cc
-)
-if(WITH_BUILDINFO)
- list(APPEND SRC
- "$<TARGET_OBJECTS:buildinfoobj>"
- )
-endif()
-
-BLENDER_SRC_GTEST_EX(
- NAME blenloader
- SRC "${SRC}"
- EXTRA_LIBS "${LIB}"
- COMMAND_ARGS --test-assets-dir "${CMAKE_SOURCE_DIR}/../lib/tests")
-
-unset(_buildinfo_src)
-
-setup_liblinks(blenloader_test)
diff --git a/tests/gtests/bmesh/CMakeLists.txt b/tests/gtests/bmesh/CMakeLists.txt
deleted file mode 100644
index f9e1c97c405..00000000000
--- a/tests/gtests/bmesh/CMakeLists.txt
+++ /dev/null
@@ -1,49 +0,0 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# 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) 2014, Blender Foundation
-# All rights reserved.
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC
- .
- ..
- ../../../source/blender/blenlib
- ../../../source/blender/makesdna
- ../../../source/blender/bmesh
- ../../../intern/guardedalloc
-)
-
-set(LIB
- bf_blenloader # Should not be needed but gives linking error without it.
- bf_intern_opencolorio # Should not be needed but gives windows linker errors if the ocio libs are linked before this
- bf_gpu # Should not be needed but gives windows linker errors if the ocio libs are linked before this
- bf_bmesh
-)
-
-include_directories(${INC})
-
-setup_libdirs()
-
-if(WITH_BUILDINFO)
- set(_buildinfo_src "$<TARGET_OBJECTS:buildinfoobj>")
-else()
- set(_buildinfo_src "")
-endif()
-BLENDER_SRC_GTEST(bmesh_core "bmesh_core_test.cc;${_buildinfo_src}" "${LIB}")
-unset(_buildinfo_src)
-
-setup_liblinks(bmesh_core_test)
diff --git a/tests/gtests/runner/BlenderAddTests.cmake b/tests/gtests/runner/BlenderAddTests.cmake
deleted file mode 100644
index c4f5c8aba8a..00000000000
--- a/tests/gtests/runner/BlenderAddTests.cmake
+++ /dev/null
@@ -1,3 +0,0 @@
-# Disable ASAN leak detection when trying to discover tests.
-set(ENV{ASAN_OPTIONS} "detect_leaks=0")
-include(GoogleTestAddTests)
diff --git a/tests/gtests/runner/CMakeLists.txt b/tests/gtests/runner/CMakeLists.txt
index 59537aab571..8b3390e7aec 100644
--- a/tests/gtests/runner/CMakeLists.txt
+++ b/tests/gtests/runner/CMakeLists.txt
@@ -35,10 +35,8 @@ endif()
# Test libraries need to be linked "whole archive", because they're not
# directly referenced from other code.
get_property(_test_libs GLOBAL PROPERTY BLENDER_TEST_LIBS)
-if(WIN32)
- # Win32 is set using target_link_options after target creation.
-elseif(APPLE)
- list(APPEND TEST_LIBS "-Wl,-force_load" ${_test_libs})
+if(WIN32 OR APPLE)
+ # Windows and macOS set target_link_options after target creation.
elseif(UNIX)
list(APPEND TEST_LIBS "-Wl,--whole-archive" ${_test_libs} "-Wl,--no-whole-archive")
else()
@@ -63,6 +61,13 @@ if(WIN32)
target_link_libraries(blender_test ${_lib})
target_link_options(blender_test PRIVATE /wholearchive:$<TARGET_FILE:${_lib}>)
endforeach()
+elseif(APPLE)
+ foreach(_lib ${_test_libs})
+ # We need -force_load for every test library and target_link_libraries will
+ # deduplicate it. So explicitly set as linker option for every test lib.
+ target_link_libraries(blender_test ${_lib})
+ target_link_options(blender_test PRIVATE "LINKER:-force_load,$<TARGET_FILE:${_lib}>")
+ endforeach()
endif()
unset(_test_libs)
@@ -70,17 +75,28 @@ unset(_test_libs)
# This runs the blender_test executable with `--gtest_list_tests`, then
# exposes those tests individually to the ctest runner.
# See https://cmake.org/cmake/help/v3.18/module/GoogleTest.html
-include(GoogleTest)
+#
+# We have our own modified copy of this CMake module.
+include(GTest)
set(_GOOGLETEST_DISCOVER_TESTS_SCRIPT
- ${CMAKE_CURRENT_LIST_DIR}/BlenderAddTests.cmake
+ ${CMAKE_SOURCE_DIR}/build_files/cmake/Modules/GTestAddTests.cmake
)
+if(APPLE)
+ set(_test_release_dir ${TEST_INSTALL_DIR}/Blender.app/Contents/Resources/${BLENDER_VERSION})
+else()
+ set(_test_release_dir ${TEST_INSTALL_DIR}/${BLENDER_VERSION})
+endif()
+
gtest_discover_tests(blender_test
-# So that the binary can find its shared libs on window.
- WORKING_DIRECTORY "$<TARGET_FILE_DIR:blender>"
+ WORKING_DIRECTORY "${TEST_INSTALL_DIR}"
+# So that it will run after the install phase that will copy the required libraries
+ DISCOVERY_MODE PRE_TEST
# So that unit tests know where to find files:
EXTRA_ARGS
--test-assets-dir "${CMAKE_SOURCE_DIR}/../lib/tests"
- --test-release-dir "${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}"
+ --test-release-dir "${_test_release_dir}"
)
+
+unset(_test_release_dir)
diff --git a/tests/gtests/testing/testing_main.cc b/tests/gtests/testing/testing_main.cc
index 9816e71526b..36d39a1b3b9 100644
--- a/tests/gtests/testing/testing_main.cc
+++ b/tests/gtests/testing/testing_main.cc
@@ -48,7 +48,7 @@ const std::string &flags_test_release_dir()
int main(int argc, char **argv)
{
- MEM_initialize_memleak_detection();
+ MEM_init_memleak_detection();
testing::InitGoogleTest(&argc, argv);
BLENDER_GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
google::InitGoogleLogging(argv[0]);
diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt
index a3df01fdbe2..1b78a938a04 100644
--- a/tests/python/CMakeLists.txt
+++ b/tests/python/CMakeLists.txt
@@ -337,7 +337,7 @@ add_blender_test(
--python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py --
--run={'FINISHED'}&bpy.ops.export_mesh.ply\(filepath='${TEST_OUT_DIR}/io_tests/export_ply_vertices.ply'\)
--md5_source=${TEST_OUT_DIR}/io_tests/export_ply_vertices.ply
- --md5=37faba0aa2014451b27f951afa92f870 --md5_method=FILE
+ --md5=ee6ce2e69c1d9a7418ff0548f6338f70 --md5_method=FILE
)
diff --git a/tests/python/cycles_render_tests.py b/tests/python/cycles_render_tests.py
index 79ba11fdd44..bdf4283eb3e 100644
--- a/tests/python/cycles_render_tests.py
+++ b/tests/python/cycles_render_tests.py
@@ -7,6 +7,7 @@ import shlex
import shutil
import subprocess
import sys
+from pathlib import Path
def get_arguments(filepath, output_filepath):
@@ -63,6 +64,12 @@ def main():
report.set_pixelated(True)
report.set_reference_dir("cycles_renders")
report.set_compare_engines('cycles', 'eevee')
+
+ # Increase threshold for motion blur, see T78777.
+ test_dir_name = Path(test_dir).name
+ if test_dir_name == 'motion_blur':
+ report.set_fail_threshold(0.032)
+
ok = report.run(test_dir, blender, get_arguments, batch=True)
sys.exit(not ok)
diff --git a/tests/python/modules/render_report.py b/tests/python/modules/render_report.py
index 0cce1791a88..506c1a1518a 100755
--- a/tests/python/modules/render_report.py
+++ b/tests/python/modules/render_report.py
@@ -104,6 +104,8 @@ class Report:
'reference_dir',
'idiff',
'pixelated',
+ 'fail_threshold',
+ 'fail_percent',
'verbose',
'update',
'failed_tests',
@@ -118,6 +120,8 @@ class Report:
self.reference_dir = 'reference_renders'
self.idiff = idiff
self.compare_engines = None
+ self.fail_threshold = 0.016
+ self.fail_percent = 1
self.pixelated = False
self.verbose = os.environ.get("BLENDER_VERBOSE") is not None
@@ -136,6 +140,9 @@ class Report:
def set_pixelated(self, pixelated):
self.pixelated = pixelated
+ def set_fail_threshold(self, threshold):
+ self.fail_threshold = threshold
+
def set_reference_dir(self, reference_dir):
self.reference_dir = reference_dir
@@ -366,8 +373,8 @@ class Report:
# Diff images test with threshold.
command = (
self.idiff,
- "-fail", "0.016",
- "-failpercent", "1",
+ "-fail", str(self.fail_threshold),
+ "-failpercent", str(self.fail_percent),
ref_img,
tmp_filepath,
)