Commit Graph

6803 Commits

Author SHA1 Message Date
Campbell Barton
094f7235bb Cleanup: replace own Py_INCREF_RET with CPython's Py_NewRef
These are both simple functions that serve the same purpose.
Py_NewRef didn't exist when Py_INCREF_RET was added to Blender.
2024-10-12 00:20:55 +11:00
nutti
1d07ec7bc9 PyAPI: add specific BMLayerCollection element type to doc-strings
Ref: !125851
2024-10-09 22:58:17 +11:00
nutti
933fb1978f PyAPI: correct types in doc-strings
Ref !116245
2024-10-09 15:45:23 +11:00
Bastien Montagne
76e7770bc9 Python API: Add link/append pre/post handlers.
The `pre` handler is called after blender internal code is done populating
the link/append context with data to be processed, and before this data
starts being linked from library files.

The `post` handler is called after blender is done linking, and
potentailly appending and/or instantiating, the requested data and all
of their dependencies.

Both handlers are called with a single argument, the link/append
context.

An new RNA sets of wrappers have been added to expose relevant info from
these internal C++ structures.

NOTE: !113658 is very similar (but tied to asset drag & drop), whereas
this PR is more general (these could probably live hand-in-hand / side-
by-side).

Implements #122357

Pull Request: https://projects.blender.org/blender/blender/pulls/128279

-----------------

Some quick py example  code:

```python
import bpy

def my_handler_pre(lapp_context):
    print("About to {}:\n\t".format("link" if "LINK" in lapp_context.options else "append"),
          "\n\t".join("{} '{}', from libs ['{}']".format(item.id_type, item.name,
                                                         "', '".join([l.filepath for l in item.source_libraries]))
                      for item in lapp_context.import_items))

def my_handler_post(lapp_context):
    print("{}:\n\t".format("Linked" if "LINK" in lapp_context.options else "Appended"),
          "\n\t".join("{} '{}', from lib '{}'".format(item.id.id_type, item.id.name, item.source_library.filepath)
                      for item in lapp_context.import_items))

bpy.app.handlers.link_append_pre.append(my_handler_pre)
bpy.app.handlers.link_append_post.append(my_handler_post)
```
2024-10-02 16:44:38 +02:00
Campbell Barton
c6fd26a3f5 Cleanup: spelling in comments 2024-10-01 09:59:33 +10:00
Campbell Barton
381898b6dc Refactor: move BLI_path_util header to C++, rename to BLI_path_utils
Move to a C++ header to allow C++ features to be used there,
use the "utils" suffix as it's preferred for new files.

Ref !128147
2024-09-26 21:13:39 +10:00
Campbell Barton
32c6f9bbd0 Cleanup: use PyModule_AddObjectRef where appropriate 2024-09-26 17:08:34 +10:00
Bastien Montagne
22477956e2 Refactor: Move BPY main/public extern headers to proper C++ ones.
Pull Request: https://projects.blender.org/blender/blender/pulls/128081
2024-09-25 18:04:33 +02:00
Bastien Montagne
6c0c53161e Refactor: Move BPY bmesh headers to proper C++ ones. 2024-09-25 18:04:27 +02:00
Bastien Montagne
c3247aa4f0 Refactor: Move BPY generic headers to proper C++ ones.
NOTE: `bgl.h` was left unchanged, as it is deprecated code anyway, and
its conversion to C++ does not seem immediately trivial.
2024-09-25 18:04:27 +02:00
Bastien Montagne
4fac7828e4 Refactor: Move BPY mathutils headers to proper C++ ones.
This module actually was confusing, since only a few headers were
effectively still C ones (using the `extern "C"` blocks)...
2024-09-25 18:04:27 +02:00
Bastien Montagne
4dd11465bc Refactor: Move BPY intern remaining headers to proper C++ ones. 2024-09-25 18:04:27 +02:00
Bastien Montagne
198a1ec7a9 Refactor: Move BPY intern bpy_app headers to proper C++ ones. 2024-09-25 18:04:27 +02:00
Bastien Montagne
91e4bcd204 Refactor: Move BPY intern bpy_rna headers to proper C++ ones. 2024-09-25 18:04:27 +02:00
Campbell Barton
01825a85cb Cleanup: quiet compiler warnings 2024-09-25 20:14:06 +10:00
Campbell Barton
72b6ffd508 Fix IDPropertyUIManager.as_dict() non-array default for arrays
When a non-array default was set for an array,
the returned default would be empty.
2024-09-23 16:25:13 +10:00
Campbell Barton
57eae31ce9 Fix #127952: Crash on load after id_properties_ui type change
Resolve regression in [0] which keeps UI data when ID property types
change.

[0]: 91466f71f1
2024-09-23 16:18:39 +10:00
Jesse Yurkovich
1dbf75ff52 Cleanup: Remove BLI_array macros in bmesh edgenet
This replaces the older dynamic c array macros with blender::Vector in
bmesh_polygon_edgenet. This is the only remaining use of the old array
machinery and removal of `BLI_array.h / .c` can happen immediately
afterwards.

See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/119975
2024-09-21 23:59:14 +02:00
Campbell Barton
0fc27c8d81 Cleanup: spelling in comments 2024-09-20 13:14:57 +10:00
Campbell Barton
9e68066a4d Logging: suppress "Info" prints when calling bpy.ops.* in quiet mode 2024-09-19 14:49:05 +10:00
Jeroen Bakker
0311d8082b Fix #127636: Inconsistent GPU module doc
Documentation of the `gpu.state.active_framebuffer_get` is inconsistent.
It mentions `framebuffer_active_get`. I believe the cause is that the
C methods in the Python wrapper are named inconsistently.

This PR fixes this by making the wrapper + documentation consistent
with the top level API.

Pull Request: https://projects.blender.org/blender/blender/pulls/127677
2024-09-16 09:51:04 +02:00
Campbell Barton
9b39b4c91c Cleanup: use const pointers/references 2024-09-15 23:14:09 +10:00
Campbell Barton
6a1bd2ff40 Cleanup: use C++ comments for disabled code 2024-09-14 12:35:00 +10:00
Campbell Barton
c6afb0e270 Core: remove sdlew/WITH_SDL_DYNLOAD & disable SDL by default
Disable dynamic SDL loading as well as disable SDL for release builds.

This was only used for audio output which can already use OpenAL
if there are back-ends not natively supported by Blender.

- Remove extern/sdlew/
- Remove the WITH_SDL_DYNLOAD build option.
- Remove `bpy.app.sdl.available`.

Ref !127554
2024-09-13 22:44:35 +10:00
Campbell Barton
11187aa9dc CMake: don't link sdlew when WITH_SDL=OFF
This caused a build error building Blender as a Python module
with !125556 applied.
2024-09-06 21:01:36 +10:00
Campbell Barton
43f7b50df3 Fix #127127: bpy.types sometimes reference their parent's "bl_rna"
Accessing `bl_rna` for type defined in `scripts/modules/bpy_types.py`
could return their parent-classes RNA when accessed via their parent
types __subclasses__() method.
2024-09-06 14:57:26 +10:00
Campbell Barton
1235404cfe Fix #127165: crash accessing cls.bl_rna after unregistering 2024-09-05 17:56:56 +10:00
Philipp Oeser
e5e5d5fe73 Fix BMFace/BMLoop.copy_from_face_interp() functions
Resolve incorrect use of `METH_O`.

Ref !127076
2024-09-03 19:53:15 +10:00
Campbell Barton
d19c13eb82 Cleanup: spelling & punctuation in comments 2024-09-03 12:59:37 +10:00
Campbell Barton
21b820cd33 Fix the type value of 'bpy.types.*.bl_rna'
The type of an RNA types "bl_rna" should be `bpy.types.Struct`,
it was being set to the type it represented so:
`type(bpy.types.Object.bl_rna) == bpy.types.Object`
which wasn't correct.

Ref !126877

Co-authored-by: Bastien Montagne <bastien@blender.org>
2024-08-28 19:07:14 +10:00
Campbell Barton
83ffadb248 Cleanup: reduce right-shift 2024-08-28 16:30:57 +10:00
Campbell Barton
b30bbcb17d Cleanup: remove duplicate function call & null check 2024-08-28 15:42:13 +10: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
Bastien Montagne
de47fee2e1 Fix #126156: Do not allow to assign embedded IDs to IDProperties.
This is just not supported, and typically not doable from Blender UI
(since embedded IDs won't be listed in ID template list).

Add asserts to IDProp code itself, and checks & error reports in
relevant BPY and RNA setters.
2024-08-21 18:19:06 +02:00
Bastien Montagne
2853a4c4db Refactor: Blendfile Link/Append: make callback of foreach item a function ref. 2024-08-20 12:51:47 +02:00
Lukas Tönne
400c738db9 GPv3: Import and export for SVG and PDF
Implements the SVG import/export and PDF export operators for GPv3.

Pull Request: https://projects.blender.org/blender/blender/pulls/123996
2024-08-20 11:41:37 +02:00
Iliya Katueshenock
1b67be14c6 Cleanup: BKE: Nodes: Functions renaming
Use snake style naming for all the kernel nodes functions.
Omit kernel prefix in the names since of the using namespace.
Use full forms of the terms
('iter' -> 'iterator', 'ntree' -> 'node_tree', 'rem' -> 'remove', ...).

Pull Request: https://projects.blender.org/blender/blender/pulls/126416
2024-08-19 20:27:37 +02:00
Aras Pranckevicius
6d93bf6b44 IMB: Speedups, fixes and cleanups to various image scaling functions
API: merged IMB_scalefastImBuf, IMB_scaleImBuf, IMB_scaleImBuf_threaded
into one function IMB_scale with enum IMBScaleFilter {Nearest, Bilinear, Box}
and bool "threaded" param.

Performance:
- Box filtering (nee IMB_scaleImBuf) can be multi-threaded now.
- Nearest filtering (nee IMB_scalefastImBuf) can be multi-threaded now.
  Also fix performance regression on float images caused by fix in #126234
- Bilinear filtering (nee IMB_scaleImBuf_threaded) is several times faster now.

Correctness:
- Nearest and Box filtering: no longer loses half of edge pixels when scaling
  up.
- Box: fixed garbage results (and possible out of bounds reads) for non-4
  channel float images.
- Bilinear: no longer shifts image when scaling up.
- Bilinear: properly filters when scaling down by 2x2.

Test coverage:
- Add gtest coverage for various IMB_scale modes.
- Add a IMB_performance_test performance test, ran manually.

More details, images and performance numbers in PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/126390
2024-08-19 16:50:05 +02:00
Campbell Barton
976062c771 Cleanup: use prefix comments before struct members 2024-08-19 11:37:20 +10:00
Campbell Barton
b5e0b59736 Cleanup: remove space around identifiers in C-style comments 2024-08-15 20:46:00 +10:00
Jacques Lucke
5861b078f7 Core: rename ID.flag and ID.tag values
Previously, values for `ID.flag` and `ID.tag` used the prefixes `LIB_` and
`LIB_TAG` respectively. This was somewhat confusing because it's not really
related to libraries in general. This patch changes the prefix to `ID_FLAG_` and
`ID_TAG_`. This makes it more obvious what they correspond to, simplifying code.

Pull Request: https://projects.blender.org/blender/blender/pulls/125811
2024-08-07 12:12:17 +02:00
nutti
1c3a2d1f5f Fix: temp_override doc not to take the positional arguments
Add positional argument to `temp_override` pyapi docs

Pull Request: https://projects.blender.org/blender/blender/pulls/125132
2024-08-05 13:28:25 +02:00
Campbell Barton
14b03fca3c PyAPI: add bpy.app.python_args, use when calling Python from Blender
Expose arguments to use when creating a Python sub-process.

Python could fail to start when loaded in a customized environment,
with PYTHONPATH set for e.g. Blender ignores these and loads but a
Python sub-process attempts to use these environment variables which
may point to incompatible Python versions.

Resolve the root cause of #124731.
2024-07-31 11:59:23 +10:00
Falk David
cd577f02b9 Python: Trigger property update in foreach_get/set
Calling `foreach_get/set` on a collection property did not trigger
a property update. In the attribute API, this lead to missing
updates after e.g. setting the values of an attribute.

This adds a call to `RNA_property_update` for the getter/setter
bpy rna function and adds a property update callback to all the
different attribute collection properties.

Pull Request: https://projects.blender.org/blender/blender/pulls/125518
2024-07-29 11:14:20 +02:00
Campbell Barton
111a40239a Cleanup: match argument names for function & declarations
Match function and declaration names, picking names based on
consistency with related code & clarity.

Also changes for old conventions, missed in previous cleanups:

- name -> filepath
- tname -> newname
- maxlen -> maxncpy
2024-07-27 13:32:51 +10:00
Christoph Lendenfeld
ebd123c90b Refactor: delete_keyframe function arguments
No functional changes intended.

This simplifies the arguments for the `delete_keyframe` function.
The `bAction *` was always a `nullptr` so I just removed it.
The rna path char array and the array index were merged into the `RNAPath` struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/125479
2024-07-26 13:29:25 +02:00
Campbell Barton
c589634f73 Cleanup: use colon after parameters 2024-07-25 10:17:45 +10:00
Campbell Barton
e2bc41598d Fix drivers showing "Python restricted for security" when they weren't
Regression from [0], drivers were tagged as being disabled with a flag
that was never cleared. Causing the label to be displayed for files
where the expressions were enabled and in use.

Resolve by clearing this flag on file load and when re-compiling
expressions - since an expressions block flag may be cleared if it
becomes a simple expression.

[0]: 1a8053939b
2024-07-22 10:39:50 +10:00
Andrej730
627bd7e51c Fix: API docs: bpy.app.timers function argument types
Fixed the "function" argument types of `is_registered` and `unregistered`
to be consistent with the correct typing from `bpy.app.timers.register`

Pull Request: https://projects.blender.org/blender/blender/pulls/125052
2024-07-20 14:52:37 +02:00
Bastien Montagne
c607ead4b7 Refactor: Makesrna: move generated code further in C++.
This commit moves generated `RNA_blender.h`, `RNA_prototype.h` and
`RNA_blender_cpp.h` headers to become C++ header files.

It also removes the now useless `RNA_EXTERN_C` defines, and just
directly use the `extern` keyword. We do not need anymore `extern "C"`
declarations here.

Pull Request: https://projects.blender.org/blender/blender/pulls/124469
2024-07-15 16:39:45 +02:00