Commit Graph

6916 Commits

Author SHA1 Message Date
Campbell Barton
4cd827870d Cleanup: quiet check_spelling_* targets
Also correct outdated references to `ghash`.
2025-02-02 13:58:34 +11:00
Brecht Van Lommel
27accea53e Cleanup: Various clang-tidy warnings in python
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:18 +01:00
Brecht Van Lommel
c7502b092d Cleanup: Various clang-tidy warnings in gpu
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:18 +01:00
Hans Goudey
e79859ab14 Refactor: Use Map instead of GHash for Python translations cache
This makes the code simpler, aligns it with the builtin translations in
messages.cc, and should improve performance as well. My motivation
for the change is to allow returning StringRef/StringRefNull from the
translation functions instead of char pointers.

To test the change I used the Sun Position addon which includes
translations and toggled different languages in the preferences.

Pull Request: https://projects.blender.org/blender/blender/pulls/133827
2025-01-31 14:10:14 +01:00
Hans Goudey
ce5bdecf89 Refactor: Use VectorSet for panels, menus, gizmos, lists, operators
Previously, the global storage of these types either used a GHash or a
blender::Map. VectorSet is preferrable to GHash because it's type safe,
clearer, and faster. It's preferrable to Map because the key doesn't
have to be duplicated and because iteration is faster.

This PR moves these registered types to VectorSet, just like the
node, node socket, and node tree types. Note that none of these types
use RAII for allocation, so freeing is still done manually.

Testing was manually interacting with each of these systems, including
with addons that register their own types.

Pull Request: https://projects.blender.org/blender/blender/pulls/133778
2025-01-30 15:35:00 +01:00
Jonathan Plasse
2459b3a049 PyDoc: add bpy.types.AddonPreferences to registration doc-strings
Ref: !133484
2025-01-28 17:35:42 +11:00
Bastien Montagne
9c237af041 Refactor: RNA: add discrete suffix to RNA_pointer_create.
This is a noisy preliminary step to the 'RNA ancestors' change. The
rename helps clearly tell what each `pointer_create` function does.

Pull Request: https://projects.blender.org/blender/blender/pulls/133475
2025-01-24 16:45:32 +01:00
Campbell Barton
18783c5699 Cleanup: correct RST syntax, spelling & adjust quotes 2025-01-21 16:51:40 +11:00
Hans Goudey
8cb4d6aaab Cleanup: Unused variable with asserts off 2025-01-20 12:37:25 -05:00
Bastien Montagne
2d7068a0d3 Add file_path_map function to bpy.data.
Similar to `bpy.data.user_map`, it returns a mapping of IDs to all the
filepaths they use.

Fairly basic still, may need to be refined with more options to
control which filepaths are included etc.

Mainly intended to make handling of a production blendfile dependencies
more easy.

Also adds some basic testing of the new feature.

Pull Request: https://projects.blender.org/blender/blender/pulls/127252
2025-01-20 17:39:25 +01:00
Campbell Barton
ad7a6495ac PyDoc: use "note" directive for bpy.props
Also minor rewording & adjust indentation.
2025-01-20 16:34:47 +11:00
Campbell Barton
4507c9fcc2 PyDoc: add bpy.types.PropertyGroup to registration doc-strings
Ref !133233

Co-authored-by: Jonathan Plasse <jonathan.plasse@eilbek-research.de>
2025-01-20 16:12:11 +11:00
Campbell Barton
ddae7cd966 PyAPI: expose bpy.types.bpy_prop_collection_idprop
Expose the IDProperty sub-class of `bpy.types.bpy_prop_collection`,
needed for API doc generation but should have been exposed for
completeness.
2025-01-20 15:47:08 +11:00
Brecht Van Lommel
a6b293daac Python Module: Bundle VFX library python bindings
When calling bpy.utils.expose_bundled_modules(), these modules are
added to sys.path.

This provides a solution/workaround to two problems:
* Using bpy together with packages like usd-core is problematic. Besides
  crashing due to C++ symbol conflicts, it's just impossible to import
  different versions of the same module, or to have distinct environment
  variables for both. (#127132)
* Blender add-ons using these VFX modules do not currently work with
  the bpy module.

This adds about 15MB to the bpy package.

Pull Request: https://projects.blender.org/blender/blender/pulls/133082
2025-01-17 10:13:31 +01:00
Campbell Barton
8d97330482 Cleanup: clarify naming for BMesh tangent calculation functions
The newly added "tangent_pair" calculation functions meant the names
didn't read well in some cases, use this style of naming for clarity:

- BM_face_calc_tangent_from_*
- BM_face_calc_tangent_pair_from_*
2025-01-17 15:28:32 +11:00
Campbell Barton
481a8b67d4 PyAPI: add bpy.app.portable, derived from WITH_INSTALL_PORTABLE
Support differentiating between portable & system installations,
useful to properly locate relative paths which would not work
on system installations.

Ref !133143
2025-01-16 21:07:29 +11:00
Sybren A. Stüvel
59585cf978 Cleanup: document difference between bpy.app.version and .version_file
Clarify the meaning `bpy.app.version_file`, by being more explicit in the
description of `bpy.app.version` and their differences.

### Old:

`bpy.app.version`
: The Blender version as a tuple of 3 numbers. eg. (2, 83, 1)

`bpy.app.version_file`
: The Blender version, as a tuple, last used to save a .blend file, compatible with ``bpy.data.version``. This value should be used for handling compatibility changes between Blender versions

### New:

`bpy.app.version`
: The Blender version as a tuple of 3 numbers (major, minor, micro). eg. (4, 3, 1)

`bpy.app.version_file`
: The Blender File version, as a tuple of 3 numbers (major, minor, file sub-version), that will be used to save a .blend file. The last item in this tuple indicates the file sub-version, which is different from the release micro version (the last item of the `bpy.app.version` tuple). The file sub-version can be incremented multiple times while a Blender version is under development. This value is, and should be, used for handling compatibility changes between Blender versions

Pull Request: https://projects.blender.org/blender/blender/pulls/133142
2025-01-16 11:06:59 +01:00
Bastien Montagne
484fa519fb Fix some issues with bpy.data.user_map implementation.
* In case a subset of IDs is given, it was not checked that all items
  are ID data.
* In case of error while processing the subset, there could be some
  python data 'leak' (the `user_map` would not be unreferenced).
* Improve performances in case there are many duplicates in given subset
  iterable of IDs, by not processing the duplicates.

Discovered in !127252 review.
2025-01-15 11:35:11 +01:00
Bastien Montagne
be936025ea Cleanup: Replace some asserts by static asserts. 2025-01-08 15:50:52 +01:00
Brecht Van Lommel
920e709069 Refactor: Make header files more clangd and clang-tidy friendly
When using clangd or running clang-tidy on headers there are
currently many errors. These are noisy in IDEs, make auto fixes
impossible, and break features like code completion, refactoring
and navigation.

This makes source/blender headers work by themselves, which is
generally the goal anyway. But #includes and forward declarations
were often incomplete.

* Add #includes and forward declarations
* Add IWYU pragma: export in a few places
* Remove some unused #includes (but there are many more)
* Tweak ShaderCreateInfo macros to work better with clangd

Some types of headers still have errors, these could be fixed or
worked around with more investigation. Mostly preprocessor
template headers like NOD_static_types.h.

Note that that disabling WITH_UNITY_BUILD is required for clangd to
work properly, otherwise compile_commands.json does not contain
the information for the relevant source files.

For more details see the developer docs:
https://developer.blender.org/docs/handbook/tooling/clangd/

Pull Request: https://projects.blender.org/blender/blender/pulls/132608
2025-01-07 12:39:13 +01:00
nutti
d42a9ae406 PyDoc: use argument "type" to list valid types for class registration
Ref: !132482
2025-01-07 20:09:35 +11:00
Campbell Barton
292ba724ab Cleanup: use a define to make it explicit the BGL API shouldn't be used
Now bgl.hh only exposes the module initialization function
since other functions aren't used elsewhere and probably shouldn't be
used in the future.
2025-01-07 11:39:24 +11:00
Campbell Barton
a404f521a3 Cleanup: remove typedef struct & function(void) in Python declarations 2025-01-07 11:27:20 +11:00
Campbell Barton
724e4fe937 Cleanup: move bgl header to C++ 2025-01-07 11:16:14 +11:00
Campbell Barton
6ae599c588 Fix gpu.shader.from_builtin exception without returning null
Returning an object instead of null meant to exception would
not be raised as intended.

Oversight in !132686
2025-01-07 10:18:59 +11:00
Bastien Montagne
1b82ef37be Refactor: Use ENUM_OPERATORS macro for PartialWriteContext operations enum.
Reduces slightly verbosity.

Pull Request: https://projects.blender.org/blender/blender/pulls/132710
2025-01-06 18:19:18 +01:00
Jeroen Bakker
588087f88e Fix #131943: GPU: Vertex formats for polyline shaders
PR #129315 refactored polylines. The shaders now attaches the vertex
attributes as SSBOs. Adding a workaround for polyline shaders to
extract the correct vertex formats when called via Python.

Pull Request: https://projects.blender.org/blender/blender/pulls/132689
2025-01-06 16:05:50 +01:00
Jeroen Bakker
c2b8186b07 Fix #132590: Python/GPU: Builtin clipped shaders messages
Confusing error messages are printed when requesting a clipped builtin
shader via Python that does not exist.

This PR will remove the confusion of the messaging:
- Replaced BLI_assert_unreachable with an assert as it is reachable
  code.
- Adding clipped configuration for POLYLINE_UNIFORM_COLOR

Pull Request: https://projects.blender.org/blender/blender/pulls/132686
2025-01-06 15:42:07 +01:00
nutti
313f3ecf98 PyDoc: correct CollectionProperty & PointerProperty type in Python docs
Ref: !132420
2025-01-06 20:29:29 +11:00
nutti
10e3e3b4a0 PyDoc: add bpy_prop_collection_idprop class document
Ref: !132587
2025-01-06 20:29:29 +11:00
Campbell Barton
5f640457d8 Cleanup: suppress various pylint warnings 2025-01-04 21:17:29 +11:00
Campbell Barton
4c852d5566 Fix #131195: Crash with PyDrivers after canceling extensions update
Rendering a scene with py-drivers would crash after dropping an
extension onto Blender's window then canceling before the update
completed.

This was caused by context.temp_override pushing arguments into the
context but failing to pop them in the case of an error - which would
happen when the popup was closed while the update ran.
2025-01-04 19:09:54 +11:00
Campbell Barton
9363ad59b0 Fix #132615: Memory leak calling context.temp_override()
ContextTempOverride objects were not freeing the reference to their
arguments when the context managers __exit__ didn't run.

This would happen if __enter__ failed with an unsupported configuration
or if object was created and not used.

Resolve by making ContextTempOverride a container type with GC support.

This also allows the ContextTempOverride to be reused since it's
arguments are now cleared when it's deallocated instead of __exit__.
2025-01-04 19:09:53 +11:00
Campbell Barton
535b26d436 Cleanup: remove "__tp" from function names in bpy_rna_context
This convention seems strange and doesn't help with readability/clarity.
2025-01-04 16:32:04 +11:00
Campbell Barton
d2d754be3f Cleanup: spelling in comments (make check_spelling*)
- Back-tick quote math expressions so differentiate them
  from English.
- Use doxygen code blocks for TEX expressions.
2025-01-04 16:26:39 +11:00
Ray Molenkamp
5783950ac5 Revert: 0dc484f9cc bf_rna modernisation
This caused build errors on the docs builder, I can't seem to reproduce
locally, so revert for now and have another look at some point in the
future.

Sadly as these changes usually go, this took 5c515e26bb and
2f0fc7fc9f with it as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/132559
2025-01-02 19:56:24 +01:00
Campbell Barton
5c515e26bb Cleanup: remove trailing space, ensure a newline at EOF 2025-01-02 15:11:18 +11:00
Ray Molenkamp
0dc484f9cc Cleanup: CMake: Modernize bf_rna dependencies
Pretty straightforward

- Remove any bf_rna paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132413
2024-12-31 18:23:25 +01:00
Ray Molenkamp
a0d9826b3c Cleanup: CMake: Modernize bf_imbuf dependencies
Pretty straightforward

- Remove any bf_imbuf paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132336
2024-12-25 23:32:15 +01:00
Ray Molenkamp
a23aab3ddc Cleanup: CMake: Modernize bf_blenloader dependencies
Pretty straightforward

- Remove any bf_blenloader paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132334
2024-12-25 18:40:41 +01:00
Ray Molenkamp
c331c6b50e Cleanup: CMake: Modernize bf_blentranslation dependencies
Pretty straightforward

- Remove any bf_blentranslation paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132311
2024-12-25 17:40:25 +01:00
Ray Molenkamp
54604efdfd Cleanup: CMake: Modernize bf_windowmanager dependencies
Pretty straightforward

- Remove any bf_windowmanager paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132310
2024-12-24 22:40:38 +01:00
Ray Molenkamp
b7407aabb5 Cleanup: CMake: Modernize bf_gpu dependencies
Pretty straightforward

- Remove any bf_gpu paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132286
2024-12-23 21:38:19 +01:00
Ray Molenkamp
a7c39896c6 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any bf_blenkernel paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132282
2024-12-23 20:08:37 +01:00
Ray Molenkamp
2992c63bc3 Cleanup: CMake: Modernize bf_bmesh dependencies
Pretty straightforward

- Remove any bf_bmesh paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132203
2024-12-23 17:47:25 +01:00
Andrej730
406fe689fd PyDocs: Fix Vector.angle_signed signature
From the current signature it appears as `fallback` argument is not
optional. Changed it to have a default `None` value, similar to
`angle(other, fallback=None)`.

Noticed this issue working with fake-bpy-module that generates typing
based on Blender docs - https://github.com/nutti/fake-bpy-module/issues/326.

Pull Request: https://projects.blender.org/blender/blender/pulls/132052
2024-12-23 02:57:06 +01:00
Sean Kim
d05a359946 Cleanup: make format
Missed in 5d0dfd6f5a.
2024-12-22 15:02:02 -05:00
Andrej730
5d0dfd6f5a Doc: Add info about IDProperty Pointers not supporting Embedded IDs.
This was lacking in API documentation so far, and was source of confusion, see e.g. #129393.

Pull Request: https://projects.blender.org/blender/blender/pulls/132218
2024-12-22 18:17:12 +01:00
Hans Goudey
bcfe4c34da Cleanup: Move BVH utils to C++ namespace 2024-12-19 18:22:29 +01:00
Andrej730
149ab6a7c4 PyDoc: bpy.props typing fixes and clarification note to PointerProperty.poll
1) Typing fixes for vector properties (similar to !131855)
2) More specific type for PointerProperty.poll since it's only called if type is ID.
3) Added a note to PointerProperty.poll that it's only checked when property is assigned from the UI.

Pull Request: https://projects.blender.org/blender/blender/pulls/131925
2024-12-18 10:38:29 +01:00