Commit Graph

27 Commits

Author SHA1 Message Date
Campbell Barton
b3dfde88f3 Cleanup: spelling in comments (check_spelling_* target)
Also uppercase acronyms: API, UTF & ASCII.
2025-05-17 10:17:37 +10:00
Campbell Barton
3bf92a6e83 Cleanup: rename nullptr to null for null-characters 2025-04-11 23:55:00 +00:00
Brecht Van Lommel
478426c937 Cleanup: Various clang-tidy warnings in blenkernel
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Campbell Barton
7e8dcf77db Cleanup: pass UnitSettings as a const reference 2025-01-08 21:22:45 +11:00
Campbell Barton
e949ff7334 Fix unit scale use when when units were disabled
UnitSettings::scale_length was used to scale reported
values for operators (translate, shrink-fatten, voxel-size).

This isn't expected as the value isn't editable when the unit-system
is set to None.

Add BKE_unit_value_as_string_scaled utility function for clarity &
to ensure scaling is only applied when it should be.
2025-01-08 21:07:23 +11:00
Campbell Barton
361e98b09e Cleanup: move BKE_scene_unit_scale to BKE_unit_value_scale
This doesn't use any scene types, move to BKE_unit.hh
2025-01-08 21:03:50 +11:00
Lleu Yang
166c921a44 UI: Add Frequency unit
This adds the unit of frequency Hertz (Hz) and Kilohertz (kHz) for
expressing pitch of a sound.

This will be used for the ongoing Sample Sound node in #122228.

Pull Request: https://projects.blender.org/blender/blender/pulls/125915
2024-08-22 17:05:48 +02:00
Lukas Stockner
25d4d645cd UI: Add Color Temperature unit
The current temperature unit adjusts to Celsius or Fahrenheit based on
unit system, but specifically for color temperatures the convention is
to display them in Kelvin, and it'd be strange to e.g. see 11240°F when
opening the white balance panel.

Therefore, this adds a dedicated Color Temperature unit, and uses it
for the two existing blackbody temperature inputs in shader nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/123337
2024-06-17 23:50:05 +02:00
Lukas Stockner
cc541f2c07 UI: Add Wavelength unit for scene-independent nanometer-scale inputs
Currently this is only used for the Wavelength node, but it will also be relevant for the Thin Film Interference support in the Principled BSDF.

Pull Request: https://projects.blender.org/blender/blender/pulls/120900
2024-04-22 13:10:16 +02:00
Campbell Barton
c31b4b810c Cleanup: pass by const reference instead of value 2024-04-14 23:09:35 +10:00
Campbell Barton
c527056f0c Fix #117783: Allow Multiple Negatives in Numerical Inputs with Units
Support multiple unary operators before a number where only a single
negative value worked in the past.

Ref !117827.
2024-02-06 09:28:30 +11:00
Damien Picard
299e112d1a UI: improve unit names
This commit tweaks some unit names:

- Remove `name_alt` for square mile "sq m" and cubic mile "cu m" as
  they could easily be confused with meters.
- Correct plural forms for the ton units: rename "ton" to "tonne" for
  the metric ton, and "tonnes" to "tons" for the imperial (short) ton.
  Identifiers are unchanged.
- Swap `name_short` and `name_alt` for metric ton, hour, and second,
  as `name_short` is used for UI display and should use the official
  symbol. Keep the other form as `name_alt` for input.
- Use "t" and "tn" respectively as short names for the metric and
  imperial (short) ton.
- Rename radian's short name "r" to "rad", keep it as alt name.
- Introduce alt names for km/h (kph), arcminutes (amin),
  arcseconds (asec), for convenience.

References:
- https://en.wikipedia.org/wiki/Ton
- https://en.wikipedia.org/wiki/Tonne

Ref: !116762
2024-01-15 18:04:38 +11:00
Damien Picard
faefaa4447 I18n: extract and disambiguate a few messages
Extract:
- Compositor error messages.
- `bUnitDef`s were broken after cleanup commit 2b77cd726d. Since each
  unit's "display name" is now preceded by a consistent "name_display"
  comment, the regex which extracts the unit is greatly simplified.
  It now relies on the presence of the comment instead of the struct
  order.
- "Preset" menu and "Apply Preset" button from the curveprofile
  template.
- Operator labels from the catalog context menu.

Disambiguate:
- "Bake Data": can mean "Which data to bake" (verb), or "The data that
  were baked" (noun).
- "Cache" in the Simulation Nodes panel is a verb, not a noun.
- "Mix" in the snapping menu is a noun, not a verb.
- "Top" and "Bottom" can mean the upper part of an object or the
  highest point or element of something like a menu or list.

Pull Request: https://projects.blender.org/blender/blender/pulls/115963
2023-12-19 18:41:09 +01:00
Hans Goudey
7e3ba529ea Cleanup: Move four blenkernel headers to C++ 2023-11-28 16:05:12 -05:00
Campbell Barton
611930e5a8 Cleanup: use std::min/max instead of MIN2/MAX2 macros 2023-11-07 16:33:19 +11:00
Campbell Barton
137f8dd7bc Cleanup: spelling in comments 2023-10-10 09:44:57 +11:00
Campbell Barton
bd66e2e662 Cleanup: use defines for superscript numbers in unit.cc 2023-10-06 14:12:26 +11:00
Campbell Barton
2b77cd726d Cleanup: wrap definitions across multiple lines, add struct identifiers
When units were initially defined having each on their own line was
compact, since them more fields have been added, making the lines
overly long and the difference between each field non-obvious.

Further, the conversion from C to C++ [0], wrapped definitions onto the
same line (for some reason), resulting in lines over 700 wide.

Use clang-format & add struct ID's for clarity.

[0]: 129f78eee7
2023-10-06 13:57:52 +11:00
Campbell Barton
5e2b8c43e4 Fix invalid collection length for dummy unit collection
While this didn't show up as a bug, if this length was used it could
result in an out of bounds read.
2023-10-06 13:23:42 +11:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Campbell Barton
d3353eb34b Cleanup: use const variables, reduce right-shift in unti.cc
Also assert the 3D view fixed size buffer is large enough.
2023-08-11 18:12:45 +10:00
Aras Pranckevicius
d973355b3a Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).

However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.

This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.

Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
  to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).

Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.

Pull Request #110944
2023-08-10 14:51:40 +03:00
Campbell Barton
23cd37de25 Cleanup: redundant checks 2023-08-10 17:11:24 +10:00
Campbell Barton
e68302d49e Cleanup: use block-comments for multi-line comments 2023-08-09 11:17:04 +10:00
Campbell Barton
81ee130063 Cleanup: use C++ system headers
Apply clang-tidy modernize-deprecated-headers to source/
2023-07-22 11:27:25 +10:00
Campbell Barton
17563e9a91 Cleanup: use C++ function style casts, NULL -> nullptr 2023-07-18 14:18:07 +10:00
Jacques Lucke
129f78eee7 Blenkernel: move to C++
Also see #103343.

Couldn't move two files yet:
* `softbody.c`: The corresponding regression test fails. It seems like the
  conversion to C++ changes floating point accuracy, but it's not clear where that happens exactly.
* `writeffmpeg.c`: Is a bit more complex to convert because of the static array in `av_err2str`.

Pull Request: https://projects.blender.org/blender/blender/pulls/110182
2023-07-17 10:46:26 +02:00