Commit Graph

7162 Commits

Author SHA1 Message Date
Jeroen Bakker
56784c2681 Fix: Python: incorrect assert when reading back framebuffers
Detected when looking into #144887

Pull Request: https://projects.blender.org/blender/blender/pulls/145165
2025-08-28 09:19:29 +02:00
Campbell Barton
4b35760354 Fix: incorrect doc-strings for bpy.props type argument 2025-08-26 02:14:31 +00:00
Campbell Barton
753b6c031b PyDoc: include keyword only parameter in doc-strings 2025-08-26 02:14:30 +00:00
Sybren A. Stüvel
494b041585 Python: Improve bpy.data.user_map() argument documentation
Update the call signature in the docstring so that it is clear that the
arguments to `bpy.data.user_map()` are all optional:

```
.. method:: user_map(*, subset=None, key_types=None, value_types=None)
```

This is important for Python stubs that are generated from the
docstrings; see https://github.com/michaelgold/buildbpy/issues/3.

This change feels a bit weird, as the function behaves differently
depending on whether the arguments are there or not. For example,
`subset=None` is not actually valid, as it should be a dictionary and
the function will raise a `TypeError`. But documenting `subset=dict()`
is also incorrect, because explicitly passing that will make the
function behave differently: it reports an empty dictionary, instead of
reporting everything. The same goes for the other parameters.

A better approach (IMO) would be to either add "empty dict/set means
'everything'" logic, or to allow `None` values for these parameters so
that the documented call can actually be made.

Note that this is the case for other calls as well, such as
`bpy.data.file_path_map()`. As such, I don't want to address this in
this commit; this is just for making the docstring reflect the optional
nature of the parameters.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/144933
2025-08-25 11:53:23 +02:00
Campbell Barton
e964f078b5 PyDoc: correct use of back ticks for literal text 2025-08-22 15:10:29 +10:00
Campbell Barton
78c9d16919 PyDoc: correct types, consistent formatting for doc-strings in C++
Correct some types, ensure multi-line docs end with a newline,
sentences end with a full stop.
2025-08-22 14:05:28 +10:00
Andrej730
e41fdebf3a PyDoc: UILayout.introspect(), add missing return value type
Ref !143353
2025-08-22 03:42:34 +00:00
Brecht Van Lommel
235fdc6356 Color Management: Fix wrong use of display color space
* PROP_COLOR_GAMMA is sRGB, not display space
* Hex colors are always sRGB
* Image byte buffers are in byte_buffer.colorspace

Fixes for sequencer text, image painting, render stamp and tooltips.
The default display space is sRGB, so this change will not be noticed
in most files.

Ref #144911

Pull Request: https://projects.blender.org/blender/blender/pulls/144565
2025-08-21 15:24:40 +02:00
Sybren A. Stüvel
f5ba4dbfe6 Python: Fix parameter name in error message from bpy.data.file_path_map()
When `bpy.data.file_path_map(subset=X)` is called, where `X` has the
wrong type, it now correctly shows `subset` as the erroneous parameter.

Pull Request: https://projects.blender.org/blender/blender/pulls/144914
2025-08-21 14:11:26 +02:00
Jeroen Bakker
5767da3b49 Fix #144758: Python: Inversed unicode comparison in GPUFramebuffer
Regression introduced by d9f38fca5f

Pull Request: https://projects.blender.org/blender/blender/pulls/144908
2025-08-21 11:52:24 +02:00
Clément Foucault
5681d41ca5 Fix: GPU: Wrong default size for compute local group size
The doc string was updated by 16430b10f1
but the default were not changed.
2025-08-21 11:32:43 +02:00
Bastien Montagne
27a613d9ea Fix: BPY props: broken custom set function for strings.
Another dummy mistake in BPY accessors refactor from yesterday (134d66201a)...
We critically need more unittests in this area!
2025-08-20 12:48:47 +02:00
Campbell Barton
b8ce7d419e Cleanup: use PyErr_SetString when formatting isn't needed 2025-08-20 16:10:54 +10:00
Bastien Montagne
59201ddc28 BPY props: Fix own mistake in recent refactor.
New code from 134d66201a was using uninitialized variable. Not sure how
I missed the compiler warning... :(
2025-08-19 17:49:46 +02:00
Bastien Montagne
134d66201a Cleanup: BPY prop: Move get/set... py callbacks into own scope.
Moving the python call itself into a dedicated sub-scope allows to
ensure local variables (arguments) do not risk leaking into the
rest of the code after being released.

Also use helper macro `PyTuple_SET_ITEMS`.

Pull Request: https://projects.blender.org/blender/blender/pulls/144798
2025-08-19 17:16:31 +02:00
nutti
99aa76035d Fix: typo in mathutils.Vector doc-string
Ref !144731
2025-08-19 02:36:42 +00:00
Oxicid
b856b6010e PyAPI: buffer protocol support for mathutils types
Adding buffer protocol support increases the speed of copying a Vector
(3D) array into a `numpy.array` by up to x3.8.

Ref !144401
2025-08-16 06:14:19 +00:00
Campbell Barton
248a9653f6 Fix: exception types in last commit
Missed changing exception types & messages in
25c69382fc.
2025-08-14 13:10:30 +10:00
Campbell Barton
25c69382fc Fix: frozen mathutils Vector & Matrix types could be resized
It's important that frozen types are immutable, add a generic
check that mathutils types can be resized and check the frozen flag.

Also correct the exception types when Vector's cant be resized,
using a ValueError instead of a TypeError as the type is correct.
2025-08-14 12:56:48 +10:00
clankill3r
72bda4eaee PyDoc: added missing screen parameter
Ref !144452
2025-08-12 22:42:03 +00:00
nutti
d901c95502 Fix: typo in mathutils.Vector doc-string
Ref !143771
2025-08-12 22:41:59 +00:00
Jesse Yurkovich
0240a1f32f Cleanup: CMake: Modernize bf_intern_openvdb dependencies
This follows the other CMake "modernization" commits, this time for
`bf_intern_openvdb` and the OpenVDB dependency itself.

The difference with this one is that `intern/openvdb` becomes an
"optional" dependency itself. This is because downstream consumers often
want to include this dependency rather than openvdb directly, so this
target must also be optional. Optional, in this case, means the target
always exists but may be entirely empty.

Summary
- If you are using BKE APIs to access openvdb features, then use the
  `bf::blenkernel` target
- If you are only using `intern/openvdb` APIs then use the
  `bf::intern::optional::openvdb` target (rare)
- For all other cases, use the `bf::dependencies::optional::openvdb`
  target (rare)

context: https://devtalk.blender.org/t/cmake-cleanup/30260
Pull Request: https://projects.blender.org/blender/blender/pulls/137071
2025-08-12 21:26:38 +02:00
Damien Picard
a166db31a9 Fix #144306: I18n: Wrong values in bpy.app.translations.locales
Commit 798f85a710 changed the way the languages menu is generated in
order to improve the items' descriptions. This revealed that items in
`bpy.app.translations.locales` used this description instead of the
identifier, resulting in them looking like:

  'Locale code: ca_AD. Translation progress: 100%'

instead of:

  'ca_AD'

To use the language code, this commit uses the menu item's identifier
instead of description.

-----

This should be backported to 4.5.

Pull Request: https://projects.blender.org/blender/blender/pulls/144366
2025-08-12 15:02:47 +02:00
Campbell Barton
f96a73961a Cleanup: avoid "nullptr" in Python strings & error messages
This is a C++ term not expected in exceptions and messages.
2025-08-12 13:32:41 +10:00
Campbell Barton
570eb9c60a PyAPI: minor clarification to error 2025-08-12 13:32:01 +10:00
Brecht Van Lommel
1ebefb8252 Refactor: Logging: Use CLOG for video and ffmpeg
The --debug-ffmpeg flag now is the same as --log video, and only exists for
backwards compatibility. The ffmpeg verbosity can now be controlled with
--log-level.

Pull Request: https://projects.blender.org/blender/blender/pulls/143447
2025-08-11 14:07:45 +02:00
Clément Foucault
9fbf7e9ec2 GPU: Remove wrapper type for gpu::UniformBuf
This is the first step into merging `DRW_gpu_wrapper.hh` into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/144328
2025-08-11 09:46:45 +02:00
Clément Foucault
1388a70914 GPU: Remove wrapper type for gpu::Shader
This is the first step into merging DRW_gpu_wrapper.hh into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/144229
2025-08-11 09:34:28 +02:00
Campbell Barton
ce3998ffea Refactor: simplify "_bpy_types" initialization internals
- Store the `_bpy_types` dictionary on startup instead of
  importing and setting on demand.

- Remove duplicate `_bpy_types` import.
2025-08-10 03:48:48 +00:00
Campbell Barton
eb2cc80cd0 PyAPI: move bpy_types.py to a private module
Use an underscore prefix as this module should not be accessed directly.
2025-08-10 13:45:40 +10:00
Campbell Barton
062fcd00d1 Cleanup: improve confusing/incomplete code-comments 2025-08-08 16:41:38 +10:00
Campbell Barton
28e9e87786 PyDoc: add missing arguments to bpy.app.handlers 2025-08-08 08:47:41 +10:00
Campbell Barton
53cae68ee8 Cleanup: hyphenate the term data-blocks in strings/doc-strings 2025-08-08 08:47:13 +10:00
Clément Foucault
16430b10f1 EEVEE: World Sun Shadow no longer works in 4.5
On some drivers, the GLSL compiler doesn't reflect the omitted
`local_size_*` of a compute shader inside `gl_WorkGroupSize`.

This lead to the 2D size computation of 1D workgroups to become
0 which was bypassing the parallel reduction algorithms.

Ensuring `local_size_*` are always set fixes the issue.

For clarity, also fix the 1D shaders to not use `gl_WorkGroupSize.y`.
This also fix a copy paste error in the Metal backend.

This issue affected AMD drivers on Windows.

Rel #142046

Candidate for backporting to 4.5 LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/144056
2025-08-07 09:40:57 +02:00
Campbell Barton
08cf60c66e PyDoc: generate a list of types that support custom properties
Methods for `bpy_struct` such as `get()` & `items()` noted that only
some types support custom-properties.

Since these docs were written many more types support custom properties.
Replace the inline list with a link to a generated list since there are
now too many to include inline.

Resolves #141450.
2025-08-07 14:37:38 +10:00
Campbell Barton
558d1c4774 Cleanup: use the suffix "_maxncpy" instead of "_len" for string sizes
The term "_len" is too easily confused with the strlen(),
excluding the nil byte.
2025-08-07 06:18:21 +10:00
Damien Picard
5998795aa6 UI: Replace contractions with long-form text
Avoid using contractions for can't, aren't, doesn't, and shouldn't.
Following the writing style guide in the Human Interface Guidelines.

Pull Request: https://projects.blender.org/blender/blender/pulls/143852
2025-08-05 11:16:22 +02:00
Campbell Barton
9d449ffcba Build: unbreak WITH_PYTHON_MODULE=ON
Caused by 9f056204e5.
2025-08-05 12:08:24 +10:00
youle31
2aae3c4ec7 Fix #143490: Missing uniform for POLYLINE_UNIFORM_COLOR gpu python API
Add vec4 color as uniform in PYDOC_BUILTIN_SHADER_DESCRIPTION for POLYLINE_UNIFORM_COLOR
builtin shader in accordance with gpu_shader_3D_polyline_info.hh.

Pull Request: https://projects.blender.org/blender/blender/pulls/143703
2025-08-04 08:52:02 +02:00
Campbell Barton
6d899a6726 Cleanup: naming & reduce declaration scope in the PyAPI for lib loading
Use terms source/destination instead of from/to.
2025-08-02 02:10:59 +00:00
Campbell Barton
58c7bb3fc7 Cleanup: minor corrections to library loading logic, improve docs
- Share the initialization size for library dictionaries &
  assert this size is up to date.
- Improve doc strings.
2025-08-02 12:05:13 +10:00
Campbell Barton
c04310d69f Fix memory leak when loading libraries fails from Python 2025-08-01 13:40:56 +10:00
Miguel Pozo
0730d3f256 Fix: Python API: bpy.app.is_job_running('SHADER_COMPILATION')
Shader compilation no longer uses the `WM_job` API.
Add a `GPU_shader_batch_is_compiling` function to query if there's any
shader compilation happening, and update `bpy_app_is_job_running` to
handle this as a special case.

Pull Request: https://projects.blender.org/blender/blender/pulls/143559
2025-07-31 20:06:27 +02:00
Aras Pranckevicius
77eec34973 Cleanup: BLF FontFlags enum type safety, move enums to separate header
- BLF font flags were an untyped enum; change to actual enum and
  update usages from int to that.
- Move all BLF API enums to their own header, so that if something
  needs just the enums they don't have to include whole BLF_api.hh

Pull Request: https://projects.blender.org/blender/blender/pulls/143692
2025-07-31 18:47:19 +02:00
Campbell Barton
f281f5a500 Cleanup: header grouping
Group includes, this is mostly being done already but had become mixed
up in some areas.
2025-07-30 14:22:06 +10:00
Campbell Barton
3de916ca25 RNA: support for marking properties as deprecated
Deprecation meta-data support for RNA properties.

- Properties may have a deprecated note and version.
- Warnings shown when these are accessed from Python.
- A note is included in the generated documentation.

Support for marking functions as deprecated can be added in the future.

Ref !139487
2025-07-29 22:09:59 +10:00
Campbell Barton
c4ba04428c PyAPI: show Python warnings by default when debugging
Show warnings for debug builds or when `--debug-python` is passed in.

Without this, only scripts running in the `__main__` namespace
show warnings - hiding warnings for almost all scripts & add-ons.

This is also needed so deprecation warnings can be shown, see !139487.
2025-07-29 22:09:59 +10:00
Brecht Van Lommel
fa007002b1 Refactor: Logging: Move G.quiet to CLOG, replace some printfs
* Replace G.quiet by CLG_quiet_set/get
* CLOG_INFO_NOCHECK prints are now suppressed when quiet, these were
  typically inside a if (!G.quiet) conditional already.
* Change some prints for blend files, color management and rendering to
  use CLOG, that were previously using if (!G.quiet) printf().

Pull Request: https://projects.blender.org/blender/blender/pulls/143138
2025-07-28 13:36:13 +02:00
Andrej730
ddeddaecd6 PyDoc: improve mathutils python signatures and doc-strings
- Adding `/` to signatures to indicate that arguments are accepted only
  as positional.
- Document default values and optional arguments in consistent way with
  other docs.
- Use `Literal` for strings to indicate set of allowed string values
  (later it can also be used in typing stubs).
- Document some undocumented arguments.

Ref !143278
2025-07-27 20:23:44 +10:00
Andrej730
0d2b44e309 Fix: Vector.to_tuple didn't accept precision of -1
The to_tuple method defaulted to -1 but didn't accept -1 as an argument
(as documented).

Ref !143278
2025-07-27 13:47:13 +10:00