684 Commits

Author SHA1 Message Date
Campbell Barton
224bd118eb Build: resolve error with Python 3.14
Include local version of _PyArg_CheckPositional which is private
for CPython as of Python 3.14.

Ref !147783
2025-10-10 17:53:35 +11:00
Hans Goudey
a68d39e9d9 Cleanup: Formatting
Run `make format` after the library update in the previous commit.
2025-10-02 12:55:42 -04:00
Oxicid
44d04ad857 PyAPI: add mathutils.geometry.intersect_point_line_segment function
Add a *_line_segment equivalent of the *_line function,
which clamps to the end-points.

Ref !146490
2025-10-02 11:53:02 +10:00
Oxicid
9f45b479fd PyAPI: use METH_FASTCALL to improve performance for intersect_point_line
Use METH_FASTCALL to improve performance by about 1.3x,
useful as this function may be used on large datasets.

Ref !146490
2025-10-02 11:52:24 +10:00
Campbell Barton
38e5c875c5 PyDoc: correct doc-string for intersect_point_line & minor cleanup
Apply some minor changes from !146490.
2025-10-02 11:48:19 +10:00
Campbell Barton
96d7c5c4cd Cleanup: use braces in mathutils switch statements
Also move error checking before variable declarations.
2025-09-16 14:53:58 +10:00
Oxicid
b2176bfdd7 PyAPI: use the vectorcall protocol for mathutils types
The Vectorcall protocol avoids creating a tuple, and also provides the
number of arguments in advance, providing a ~1.6x speedup for creation
of mathutils types.

Ref !146237
2025-09-16 04:50:38 +00:00
Brecht Van Lommel
ea0fab21d4 Color Management: Builtin support for ACEScg and Rec.2020 linear spaces
With new functions to convert to/from scene linear in the Python API. ACEScg
in particular is common in USD and MaterialX files.

Pull Request: https://projects.blender.org/blender/blender/pulls/145755
2025-09-05 11:11:32 +02:00
Campbell Barton
6c7513b9ac Cleanup: spelling (make check_spelling_*) 2025-08-29 11:27:33 +10:00
Campbell Barton
753b6c031b PyDoc: include keyword only parameter in doc-strings 2025-08-26 02:14:30 +00: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
Campbell Barton
b8ce7d419e Cleanup: use PyErr_SetString when formatting isn't needed 2025-08-20 16:10:54 +10: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
nutti
d901c95502 Fix: typo in mathutils.Vector doc-string
Ref !143771
2025-08-12 22:41:59 +00: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
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
Campbell Barton
9f056204e5 Cleanup: use UTF8 string functions in source/blender/python
Use UTF8 aware functions unless raw bytes are expected.
2025-07-27 12:49:02 +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
Bastien Montagne
bc80ef136e Big Endian Support Removal.
This commit implements #125759.

It removes:
* Blender does not build on big endian systems anymore.
* Support for opening blendfiles written from a big endian system is
  removed.

It keeps:
* Support to generate thumbnails from big endian blendfiles.
* BE support in `extern` or `intern` libraries, including Cycles.
* Support to open big endian versions of third party file formats:
  - PLY files.
  - Some image files (cineon, ...).

Pull Request: https://projects.blender.org/blender/blender/pulls/140138
2025-06-12 10:37:47 +02:00
Hans Goudey
14a42c0928 Cleanup: Use C++ vector types for convex hull API
Pull Request: https://projects.blender.org/blender/blender/pulls/140233
2025-06-11 22:46:27 +02:00
Jacques Lucke
e8d1491e62 Refactor: Depsgraph: simplify query API further
* Remove `DEG_get_evaluated_object` in favor of `DEG_get_evaluated`.
* Remove `DEG_is_original_object` in favor of `DEG_is_original`.
* Remove `DEG_is_evaluated_object` in favor of `DEG_is_evaluated`.

Pull Request: https://projects.blender.org/blender/blender/pulls/138317
2025-05-02 15:08:29 +02:00
Campbell Barton
e3d6051181 Cleanup: suppress cast-function-type warnings for CLANG
Extend the existing GCC pragma's and add the warning suppression
for Cycles & Freestyle.
2025-04-01 12:06:03 +11:00
Campbell Barton
6ef7dae8ef Cleanup: spelling in comments (make check_spelling_*) 2025-03-13 13:41:17 +11:00
Bastien Montagne
bb89c89e7f Cleanup: python: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/135852
2025-03-12 11:21:53 +01:00
Philipp Oeser
51f0758f61 Merge branch 'blender-v4.4-release' 2025-02-26 14:14:36 +01:00
Philipp Oeser
d2ecf66492 Fix #120697: better error for BVHTree.FromObject()
When called on an object that you cannot get a mesh from (e.g. Empties),
you would run into an unhelpful "SystemError: <built-in method
FromObject of type object at ...> returned NULL without setting an
exception"

Now be more specific in the error message.

Pull Request: https://projects.blender.org/blender/blender/pulls/135162
2025-02-26 14:14:14 +01:00
Jacques Lucke
cb96dc34fa Merge branch 'blender-v4.4-release' 2025-02-17 12:38:50 +01:00
Andrej730
b9bbf48841 Fix: PyDocs typing issue with lists
Fixed use of lists using multiple arguments - `list` only
support a single argument.

Noticed working with fake-bpy-module - providing multiple
arguments to `list` resulted in typing error (e.g. "Too many type
arguments provided for "list"; expected 1 but received 2").

Pull Request: https://projects.blender.org/blender/blender/pulls/134663
2025-02-17 10:58:11 +01:00
Hans Goudey
93ab2813a7 Cleanup: Remove unnecessary "using" statements 2025-02-05 18:27:43 -05: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
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
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
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
Hans Goudey
bcfe4c34da Cleanup: Move BVH utils to C++ namespace 2024-12-19 18:22:29 +01:00
Hans Goudey
31964ef5ca Cleanup: Move BLI_kdopbvh to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/132031
2024-12-17 21:04:55 +01:00
Andrej730
6d555ac2a7 PyDoc: typing fix for Vector.to_tuple
Ref: !131855
2024-12-14 15:36:29 +11:00
Campbell Barton
3bcfb151c1 PyDoc: use Python's type annotation syntax for doc-strings
Replace plain-text type information with the type syntax used
for Python's type annotations as it's more concise, especially for
callbacks which often didn't include useful type information.

Note that this change only applies to inline doc-strings,
generated doc-strings from RNA need to be updated separately.

Details:

- Many minor corrections were made when "list" was incorrectly used
  instead of "sequence".
- Some type information wasn't defined in the doc-strings and has been
  added.
- Verbose type info would benefit from support for type aliases.
2024-11-03 15:44:35 +11:00
Campbell Barton
a05345e139 PyDoc: various corrections to function doc-strings
Add missing arguments, corrections & remove unchecked type info.
2024-11-02 17:48:21 +11:00
Campbell Barton
99387c0749 Cleanup: spelling in comments, docs & error 2024-11-02 15:43:27 +11:00
Campbell Barton
e7e6bf1dfe Fix memory leak in mathutils.geometry.box_pack_2d
The set macro doesn't handle the reference count for existing values.
2024-11-02 15:08:42 +11:00
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
933fb1978f PyAPI: correct types in doc-strings
Ref !116245
2024-10-09 15:45:23 +11:00
Bastien Montagne
6c0c53161e Refactor: Move BPY bmesh headers to proper C++ ones. 2024-09-25 18:04:27 +02:00