Commit Graph

7109 Commits

Author SHA1 Message Date
Clément Foucault
1611dc2fb3 GPU: Rever mass renaming removing GPUTexture type from python
This was accidentaly commited in 32d64d35bb
2025-07-24 18:19:59 +02:00
Hans Goudey
9c9695b103 Refactor: Move ReportList definition from DNA to blenkernel
Ever since [0], ReportList is not actually used in any DNA structs.
That makes sense, since reports are conceptually only necessary
at runtime. Move the definition of the struct to BKE_report.hh, and
fix a bunch of include errors where types were previously available
transitively. Besides adding some clarity, theoretically this change
could reduce compile times because of less header parsing.

[0]: 1bf6d8b0b9

Pull Request: https://projects.blender.org/blender/blender/pulls/138872
2025-07-24 15:59:52 +02:00
Brecht Van Lommel
7f0f8d4e94 PyDoc: Document all app handler arguments
Previously this was only done for a couple handlers.

Ref #142330

Pull Request: https://projects.blender.org/blender/blender/pulls/142873
2025-07-23 14:23:21 +02:00
Campbell Barton
5e3db5fbb0 Cleanup: consistent use of back-ticks in code-comments 2025-07-23 20:59:16 +10:00
Campbell Barton
d3fd04c816 Fix #142909: SystemError when collections contain non UTF8 names
The Python API wasn't accounting for structs name properties using
path sub-types, which allow non UTF8 byte sequences.

This meant accessing the SpaceFileBrowser.recent_folders collection
could cause unhandled exceptions because
FileBrowserFSMenuEntry.name uses the PROP_FILENAME sub-type.

Resolve by adding a wrapper around the RNA struct name lookup
that handles path properties properly.
2025-07-23 12:38:23 +10:00
Clément Foucault
32d64d35bb Refactor: GPU: Texture: Replace eGPUTextureFormat by TextureFormat
This offers better semantic and safety of the API.

Part of #130632

Pull Request: https://projects.blender.org/blender/blender/pulls/142818
2025-07-22 14:58:54 +02:00
Clément Foucault
f0254c2dcf Refactor: GPU: Remove unnecessary C wrappers for textures
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/142732
2025-07-22 09:48:10 +02:00
Campbell Barton
53136a0b53 Cleanup: format 2025-07-22 16:00:11 +10:00
Campbell Barton
5f6a07240f Cleanup: avoid redundant string formatting 2025-07-22 15:53:14 +10:00
Jesse Yurkovich
a27384e389 Fix: Typo in documentation for new POINT_UNIFORM_COLOR gpu shader
Typo introduced with initial commit c56a855b9f
2025-07-18 20:52:10 +02:00
Campbell Barton
fc07a4d45e Cleanup: quiet ignored qualifier & unused warnings 2025-07-17 12:30:39 +10:00
Campbell Barton
c034c928fe Cleanup: correct spelling, typos & remove outdated comment 2025-07-17 12:30:37 +10:00
Hans Goudey
b20ecee555 Mesh: Move freestyle tags to generic attributes
This commit moves the freestyle edge and face mark tags to become
generic attributes, similar to other changes over the past years. The
attributes are called "freestyle_edge" and "freestyle_face", and they're
now propagated like regular boolean attributes.

Compatibility wise, forward and backward blend file compatibility are
maintained (for forward compatibility this is implemented a bit
differently than in the past because of the ongoing `AttributeStorage`
transition). In the Python API, `use_freestyle_mark` has been removed;
the attribute API should be used instead (just like bevel weights).
The BMesh (`freestyle`) accessors are removed too.

The conversions benefit from the fact that bit-wise, the old structs are
the same as `bool`, so we can convert to the old and new formats without
reallocating arrays.

Pull Request: https://projects.blender.org/blender/blender/pulls/141996
2025-07-16 18:26:26 +02:00
Campbell Barton
ec62b843da PyAPI: warn when PropertyGroup sub-classes don't define __slots__
Warn since this allows for confusing assignments, see #141948.
2025-07-16 17:44:06 +10:00
Guillermo Venegas
1a247fbaa8 Refactor: WM: Make OperatorCallContext an enum class, move to namespace
This allows forward declaring `OpCallContext`, avoiding the
transitive include `WM_Types.hh` in `UI_interface_layout.hh`

Pull Request: https://projects.blender.org/blender/blender/pulls/141804
2025-07-15 03:08:04 +02:00
Bastien Montagne
159ea313f3 BPY: Add basic blendfile version info in data returned by bpy.data.libraries.load()
Only major and minor versions are available at that point, not the
blendfile subversion.

Version info is available in both `bpy_library` items returned by the
context handler, as a `version` property that is a tuple of two numbers.

Co-authored-by: Campbell Barton <campbell@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/141462
2025-07-14 14:43:08 +02:00
Campbell Barton
ec8751f826 Cleanup: white-space around C-style comment blocks
Also use C++ style comments for disabling code.
2025-07-13 21:58:53 +10:00
Brecht Van Lommel
4653b65f7c Logging: Add DEBUG, TRACE severity, replace numeric levels
The numeric levels have no obvious meaning. This removes the distinction
between severity and levels, instead there is a single list of named levels
with defined meaning.

Debug means information that's mainly useful for developers, and trace is for
very verbose code execution tracing.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Campbell Barton
5f4478f2e4 Merge branch 'blender-v4.5-release' 2025-07-08 22:02:07 +10:00
Andrej730
8246ea913f Fix: wrong argument name in doc-string
Correct regression from !141334.

Ref !141592
2025-07-08 12:00:32 +00:00
Campbell Barton
5781276ecb Cleanup: remove capabilities from the PyAPI that aren't used 2025-07-08 16:41:46 +10:00
Campbell Barton
439253eab5 Cleanup: use consistent terms in capability flags
Consistently use terms "cursor" & "clipboard" as a prefix
so they auto-complete more usefully.

Previously both ordering was used.
2025-07-08 16:35:42 +10:00
Campbell Barton
a950d0b2b1 Build: correct error in 2a414eea0c 2025-07-04 13:20:39 +10:00
Campbell Barton
2a414eea0c PyAPI: Refactor attribute access to avoid creating & clearing exceptions
- Add PyObject_GetOptionalAttrString (only available in Python 3.13).
- When registering RNA classes use optional attribute access to avoid
  raising and clearing exceptions.
- Refactor macro that handles substituting Python's built-ins
  with a `for` loop for better readability.
2025-07-04 12:09:16 +10:00
Campbell Barton
dad8bddd78 Cleanup: remove redundant calls to PyErr_Clear after PyErr_Print
I was under the impression both were needed however
PyErr_Print always clears the error too.
2025-07-04 11:10:54 +10:00
Campbell Barton
b99e4e1de1 PyAPI: treat "None" fallback properties as missing in class registration
If `__name__` or `__doc__` were None, the property would be detected as
being set when checking if the property is set (for required properties).

This is more of a technical correction as its unlikely developers would
run into this in practice since `__name__` should never be None and
the description is not a required property.
2025-07-04 11:02:24 +10:00
Thomas Dinges
b5c0f2dc32 Merge branch 'blender-v4.5-release' 2025-07-03 11:16:04 +02:00
Thomas Dinges
c94d5340b6 Cleanup: Make format 2025-07-03 11:14:58 +02:00
Campbell Barton
f0df1f5f38 Merge branch 'blender-v4.5-release' 2025-07-03 18:39:27 +10:00
Andrej730
1a9e90e965 PyDoc: bpy_struct, add missing types and more explicit signatures
- `bpy_struct.id_data` - provide a type.
- `bpy_struct` - add missing return types to
  `bpy_struct.get`, `bpy_struct.pop`, `bpy_struct.path_resolve`.
- `bpy_struct` - add missing argument types to some methods.
- `bpy_struct` - provide explicit `/` and `*` in signatures to make it
  clear which arguments are positional / keyword-only.

Ref !141334
2025-07-03 18:25:09 +10:00
Campbell Barton
3b538a01d9 Cleanup: quiet deprecation warning building with Python 3.14
Replace use of `_PyDict_Pop` with `PyDict_Pop` when available.
2025-06-30 15:55:19 +10:00
Campbell Barton
e9f675f40b PyAPI: add missing options to bpy.data.library.load(..)
Support options which were available from the operator:
set_fake, recursive, reuse_local_id & clear_asset_data.
2025-06-30 15:47:16 +10:00
Campbell Barton
b2ec149652 Merge branch 'blender-v4.5-release' 2025-06-30 14:31:56 +10:00
Andrej730
b025874666 Fix: Pydocs: EnumProperty items is also allowing iterables
Ref !141134
2025-06-30 14:31:15 +10:00
Campbell Barton
6253a33aa3 Cleanup: use nodiscard attribute for functions in the Python API
In most (cases functions returning a PyObject pointer
requires it to be used by the caller, declare functions in the Python
API with the `nodiscard` attribute.
2025-06-28 10:15:27 +10:00
Campbell Barton
83ee7a3122 Merge branch 'blender-v4.5-release' 2025-06-27 18:58:40 +10:00
Andrej730
6dc0c85de6 Fix: PyDocs: GPUShader, use ref for better navigation
Also note removal version.

Ref !140846
2025-06-27 18:52:53 +10:00
Campbell Barton
048fa8a327 Merge branch 'blender-v4.5-release' 2025-06-26 19:15:20 +10:00
Campbell Barton
c3d5e429ac Fix crash assigning non UTF8 path to imbuf.filepath 2025-06-26 19:10:54 +10:00
Campbell Barton
7bc5347d91 Merge branch 'blender-v4.5-release' 2025-06-26 18:39:03 +10:00
Campbell Barton
2355a32017 Fix crash calling bpy.data.file_path_map with non UTF8 paths 2025-06-26 18:35:37 +10:00
Campbell Barton
c71b314565 Cleanup: return a boolean from BPY_context_member_get, check it's result 2025-06-26 14:28:40 +10:00
Campbell Barton
e7fe0932e6 Merge branch 'blender-v4.5-release' 2025-06-25 23:38:40 +10:00
Campbell Barton
5b06823f99 Fix #140929: Crash attempting to link from the current file from Python
Add an error check that the path being linked doesn't match the current
blend file.

Also resolve reference leak in the case of library override errors.
2025-06-25 13:37:52 +00:00
Bastien Montagne
7276b2009a Core: Add new 'system IDprops' storage for runtime-generated RNA properties.
This commit cleanly splits IDProperties storage for its two very different
usages:
* "User-defined" data, also known as "custom properties". Mostly exposed
  in UI and as 'dictionary' in Python scripting, these are unique to each data
  (each object can have its own set of custom properties).
* "System-defined" data, mainly as backend-storage for runtime RNA
  structures and properties. While these are not necessarily present in the
  storage, they are registered for a data type, and therefore always available
  to all data of that type through RNA access.

See #123232 for rationales, designs and alternative investigated solutions.

## User-facing Changes

When using Blender, the only noticeable change is that python-defined RNA
data are not listed anymore in the Custom Properties panels (e.g. Cycles
data).

From a Python API perspective, the main changes are:
* Runtime RNA structs defined by sub-classing `PropertyGroup` and
  registering them are no more accessible through the 'dict' syntax.
  * They remain accessible through a dedicated 'bl_system_properties_get()`
    callback, but its usages are only expected to be for testing and
    debugging.
  * The result of this call will be `None` by default when there has been
    nothing written into it yet, unless its optional `do_create` parameter
    is set to `True`.
* Some types (like `Node`, `UIList`, etc.) cannot store raw IDProperties
  anymore (using the 'dict' syntax).

## Technical Details

* Adds System idprops to some data types (IDs, ViewLayer...).
* Moves some other containers (e.g operator properties, or some UI types like
  UILists) to only have system-defined properties.
* For a few specific types (like `PropertyGroup`), the same storage is used,
  but exposed in RNA as both user and system properties.
* Adds RNA API accessor callback to system idprops.
* Adds a function `bl_system_properties_get()`, which wraps system-defined
  idprops and gives 'dict-like' access to them. Currently mainly used by some
  unittests.
* System IDProps are always ignored by RNA diffing code (and therefore
  liboverride processing), as their value is already exposed through RNA
  properties, and should always be processed through these RNA properties.
* Modifies bpy rna binding to use these new system idprops for property
  accesses, and keeps using user-defined idprops for 'dict-type' accesses.
* Handles versioning by copying 'user idprops' (existing ones) into new
  'system idprops'.

### IDProperties Split

These types keep their historic IDProperty storage for user properties,
and get a new `system_id_properties` storage for system properties:

`ID`, `ViewLayers`, `Bone`, `EditBone`, `BoneCollection`, `PoseBone`, `Strip`

These types can both be extended with registrable RNA properties, and
expose Custom Properties in the UI.

### IDProperties become System Ones

These types keep a single IDProperties storage (their DNA struct does not
change), but it is now exclusively used for system-defined properties.

`OperatorProperty`, `View3DShading`, `UIList`, `AddonPreferences`,
`KeyConfigPreferences`, `GizmoProperties`, `GizmoGroupProperties`,
`Node`, `NodeSocket`, `NodeTreeInterfaceSocket`, `TimelineMarker`,
`AssetMetaData``

Since user properties were never available in the UI for them, they lose
their 'dict-like' IDProperties access in the Python API.

### Single Storage, Exposed as Both in API

These types still use a single IDProperty storage, but expose it both as
user properties and as system ones through RNA API.

* `PropertyGroup`: They need both access APIs since they are both
  used for raw IDProperty groups (the 'dict-like' access), and
  internally to access data of runtime-defined RNA structs.
* `IDPropertyWrapPtr`: Done mainly to follow `PropertyGroup`.
* `NodesModifier`: cannot become purely system idprops currently, as
  there is no other access than the 'raw ID properties' paths to their
  values. This can be changed once #132129 is finally implemented.

Pull Request: https://projects.blender.org/blender/blender/pulls/135807
2025-06-23 18:25:24 +02:00
Guillermo Venegas
091db9d52b Cleanup: UI: Use UI_interface_layout.hh instead of UI_interface.hh
This removes the include `UI_interface_layout.hh` from
`UI_interface_c.hh`, and in many places this swaps the include
from `UI_interface.hh` to `UI_interface_layout.hh`.

Also, cleanups some `UI_interface.hh` includes with
`UI_interface_icons.hh` or `UI_interface_types.hh`
2025-06-20 18:07:47 +02:00
Jeroen Bakker
03caffe540 GPU: Deprecate GPU_DATA_UINT_24_8
GPU_DATA_UINT_24_8 isn't used anymore. We cannot phase out the data type
as it can still be used by add-ons. This PR will deprecate
`GPU_DATA_UINT_24_8`. When used in an add-on a deprecation message will
be shown.

Pull Request: https://projects.blender.org/blender/blender/pulls/140715
2025-06-20 12:17:20 +02:00
Campbell Barton
2e3d19ca4f Merge branch 'blender-v4.5-release' 2025-06-20 19:55:35 +10:00
Campbell Barton
bfb6b184f5 Fix #140332: Crash with Python/RNA class registration
Resolve reference counting error in the RNA API which mixed up ownership
between ExtensionRNA::data & StructRNA::py_data.

In practice this generally worked as RNA_struct_free_extension behaved
as if ExtensionRNA owned the reference instead of StructRNA, so as long
as only one reference was removed, there wasn't any difference.

When re-registering Python classes with RNA, ownership wasn't handled
properly which could result in negative reference counts,
crashing in some cases.
2025-06-20 09:54:13 +00:00
Campbell Barton
715a8268fa Build: resolve errors & deprecation warnings with Python 3.14 beta
Python 3.14 has moved some functionality into the public API,
use the updated names even with older Python versions.

Also resolve an error caused by variable reuse with delayed annotation
evaluation for TextureProperties_MixIn on startup.

Resolve #140695.
2025-06-20 14:34:25 +10:00