Code Quality Day
https://wiki.blender.org/wiki/Style_Guide/Code_Quality_Day
Bigger impact changes
Projects which might go somewhat deeper but which have big impact on Blender code quality.
Extensible Architecture Refactoring
Task: T75724: Extensible Architecture Refactoring
Write a script to automatically rename DNA fields
Make it super easy to rename fields in DNA, avoiding manual work to through files and
Suggestion: look into clang-rename tool
Alternative: maybe there is IDE which has good enough refactoring functionality
Once that's done we will improve naming of all ambiguous/confusing DNA names.
Compositor
Design task: T74491
- Remove GPU code
Working on: @Aaron Carlisle (Blendify)
Patch: D7028
Current GPU support is very limited, causes duplication of node implementation, not friendly for data transfer, does not give measurable speedup in production setups.
Removing the code makes it easier to refactor the system to be faster and more responsive on CPU.
GPU integration might get re-introduced later with an upgraded design.
- Switch operations from pixel values to relative values
Makes it very easy to adopt compositing for the display resolution. For example, there is no need to composite full 8K image just to have a preview on a FullHD monitor.
Dependency graph
- Consolidate relations and node builders
- Move dependency building from depsgraph to ID type
There are multiple possible solutions, but goal is: consolidate nodes/relations building on per-ID basis.
Refactor multilayer storage
Make it more clear and easier to follow design, which will not be dependent on Render.
Note: Needs clear design first.
Physics
- Move all physics solvers to simulation/
Render module
Refactor/cleanup in render/:
- Baking is split half-way between editors/object and render/. Consolidate in either of them.
- Multires baking is likely broken, and can be implemented more accurately with OSD. Check on this and possibly remove.
- Refactor shading/texturing (at least make it more clear API names)
- Move RenderResult from pipeline.h/.c
Move headers files from render/extern/ to render/rBe15076b22f4f
User Interface
Automated Testing
Clang-Tidy integration
Code linter, which diagnoses typical programming errors.
More details and coordination in T78535
Smaller isolated changes
"Papercut" type of projects, which might not have that much of a difference on a local scale, but which adds up and make overall experience better.
Split big translation units
Applies to big files, big functions, big if and case statements.
While is not end of a world, makes it hard to jump into area and grasp a bigger picture.
- Split f-curves, f-curve modifiers, NLA, drivers, evaluation to more descriptive files than anim.c and anim_sys.c. (being worked on by @Sybren A. Stüvel (sybren)).
- Split big if, switch stataments in Draw Manager.
- Split BKE_boundbox API out of BKE_object (possibly rename BKE_object_boundbox).
Refactor directory structure
- Move subdiv and multires out of BKE, into a top-level module.
- Consolidate tracking from BKE with Libmv’s C-API in a top level module.
- Move sequencer to the top level module (including sequencer, effects, cache).
- Use "utils" instead of "util" (Currently both are used 34 util, 60 utils. Example: ED_util.h, path_util.c, MOD_util.c).
Motion tracking
- Move Libmv C-API and BKE_tracking to a top-level tracking module.
- Move more logic from operators to tracking module.
Finish moving away from DerivedMesh
- Rename DerivedMesh.c to something more meaningful in nowadays world.
- Remove GPU side of OpenSubdiv in BKE.
- Remove uses of the term 'derived' when it doesn't apply to derived-mesh, eg: BKE_object_free_derived_caches BKE_editmesh_free_derivedmesh.
After multires is fully ported to Subdiv:
- Remove CCGDerivedMesh and SubdivCCG
Code modernize/readability
- Replace list iteration with LISTBASE_FOREACH in C code (e.g., D7320)
DNA: Replace manual offset calculation with offsetof()
- Simplifies code
- Makes it work on all platforms and memory models
- Avoids almost all needs in padding (unless it’s something special like float3 which needs to be padded to float4)
GHOST: Naming
- getAllDisplayDimensions currently returns dimensions of the main monitor, should be renamed or made to work as named.
Improve names of BLI_path_util API
Without reading docstrings the purposes of the following functions is unclear.
- BLI_make_exist
- BLI_make_existing_file
- 'BLI_make_file_string'
Propose to use BLI_path_ prefix. See T74506 for proposed new names.
Working on this: @Sybren A. Stüvel (sybren)
Split out operating system wrappers (BLI_path_util, BLI_storage) own API
T75516: Day of Clean Code: Split wrappers for C API functions into own files
Working on this: @Campbell Barton (campbellbarton)
Improve naming of BKE_library/BKE_main
See T72604: Proposal: BKE_library and BKE_main API naming: prefixes conventions
T71219: Refactor out BKE ID copy functions
Refactor GPU attributes
gpuPushAttr/gpuPopAttr: Make this part of GPU_state since it's pushing attributes associated with state, use snake-case naming convention.
Disambiguate term "Line" in BLI_math.h
Currently it's sometimes used for a line-segment (clamped start/end points), other uses extend infinitely in both directions. eg:
closest_to_line_v2 clamps between the two points, where line_point_factor_v3_ex doesn't.
Propose for all clamping versions to use line_segment, or seg in cases where we need to include multiple in a name, eg: isect_seg_seg_v2_point_ex.
Use _fn as a suffix for callbacks instead of f, cb func
- FileList.checkdirf -> check_dir_fn.
- PointerPropertyRNA.typef type_fn
- PointerPropertyRNA.itemf item_fn
- RenderEngine.update_render_passes_cb -> update_render_passes_fn
- bNodeType.freeexecfunc -> free_exec_fn
Use shorter commonly used naming
Use shorter terms for function names where there is no ambiguity (which are already used in the API).
- synchronize -> sync
- initialize -> init
- attrib -> attr
Terminology
- ibuf_arr → ibufs_arr (or the other way around, but we have both in the same file often, e.g., sequencer.c)
See T74427: Code Quality: Terminology
- FFmpeg API update **
We are using some fields and functions which are declared as deprecated in FFmpeg. Is better to update code to avoid use deprecated fields, as it will minimize frustration when deprecated symbols are actually removed.
The easiest way to see code which needs to be updated is to compile with strict)er) warnings with GCC or CLang. Not sure yet how to see such warnings when using MSVC.
Review task: D10338
Modernize OpenColorIO C-API
It can benefit from using C++11/C++17 features like string_view. Also, can do more proper virtual/override semantic.
Documentation
- Document how to add a new property on a high level (DNA, RNA, default values, versioning, preferences, ...).
- T73275: Wiki: Migrating and Integrating Design Documentation
- T70016: Document performance profiling Blender
- T55361: Blender development todo list (Parent task)