Commit Graph

7015 Commits

Author SHA1 Message Date
Jason C. Wenger
702efd6846 BMesh: add a BM_faces_join() to return a duplicate face (if found)
Every call to BM_faces_join and BM_faces_join_pair has been adjusted to
provide the new face pointer, and a BLI_assert_msg has been added so
that doubles are now consistently identified and flagged as a problem.
BM_faces_join is now also capable of automatically reusing a double
when it is found. This new behavior is currently unused at this point.
Future patch-sets will begin to use it, allowing simplification of
calling functions.

Ref: !137406
2025-04-15 11:03:15 +00:00
Campbell Barton
c49e6a7dd4 Cleanup: reference operators as symbols, spelling in comments 2025-04-15 15:22:53 +10:00
Andrej730
035c0c8606 Fix: PyDocs: document bpy_prop_collection.values() possible None values
Document `bpy_prop_collection.values()` possibility of having
`None` values, unlike `.items()` that seems returns only bpy structs as it's values.

Example snippet with `None` values:
```python
>>> C.object.data.materials
bpy.data.meshes['Cube'].materials
>>> type(C.object.data.materials)
<class 'bpy_prop_collection'>
>>> C.object.data.materials.append(None)
>>> C.object.data.materials.append(None)
>>> C.object.data.materials.append(None)
>>> C.object.data.materials.values()
[bpy.data.materials['Material'], None, None, None]
>>> C.object.data.materials.items()
[('Material', bpy.data.materials['Material'])]
```

Pull Request: https://projects.blender.org/blender/blender/pulls/137302
2025-04-14 11:26:04 +02:00
Campbell Barton
5affe5fc6d Cleanup: spelling in comments (make check_spelling_*) 2025-04-12 19:31:29 +10:00
Campbell Barton
10e1aaf02c PyAPI: add imbuf.load_from_buffer to support loading images from memory
Add a Python wrapper for IMB_load_image_from_memory.
2025-04-12 18:56:12 +10:00
Campbell Barton
3bf92a6e83 Cleanup: rename nullptr to null for null-characters 2025-04-11 23:55:00 +00:00
Clément Foucault
9990273d04 GPU: Change Type enum to use lower case values
This is to help for future resource declaration
using macros.

Rel #137261

Pull Request: https://projects.blender.org/blender/blender/pulls/137367
2025-04-11 22:39:01 +02:00
RedMser
ba04393fde Cleanup: Remove deprecated Python and Rigid Body Joint constraints
Remove long-deprecated constraints that will likely never be
implemented in this form.

- Rigid Body Joint Constraint was removed in 2.80, but some references
  remained in the code. Versioning code was written that tried to
  remove them on load, but since constraint initialization code sets
  the type to CONSTRAINT_TYPE_NULL before versioning gets a chance,
  the versioning code ended up never running. This has all been
  removed.
- Python/Script Constraint never worked since 2.50 and showed an error
  message in the UI panel.

These constraints now load as 'null' constraint, as seems to be
(looking at the code) the way that Blender currently deals with
removed constraint types. These still show up in the outliner and
python API, but have no UI panel. Removing such constraints completely
will be left for another time, as it is beyond the scope of removing
these two specific constraint types.

Pull Request: https://projects.blender.org/blender/blender/pulls/136672
2025-04-11 11:38:29 +02:00
Campbell Barton
ab20edf469 RNA: support flagging properties as support blend file relative prefix
Some paths in Blender support the `//` prefix for blend-file relative
paths however this is not communicated anywhere.

Support declaring this with a new flag which can be applied to filepath
& dirpath typed properties.

This is used to:

- Show red-alert when "//" are used in paths which don't support a relative prefix.
- Show a warning in the tooltip that the relative suffix is used when unsupported.
- Python warns if this prefix is ever used in an assignment or
  function argument.

Resolves #133456.

Ref !137060
2025-04-10 23:27:21 +00:00
Sean Kim
5a5db5ea88 WM: Pass tablet tilt data to paint cursor draw callback
Part of #82877

When drawing specialized cursors for the different paint modes via the
`wmPaintCursor` draw callback, tablet tilt direction is unavailable to
use to customize the drawing for the user.

To enable this functionality, this commit adds the `x_tilt` and `y_tilt`
data read while processing MOUSEMOVE events to the `eventstate` variable
so it can be used by consuming functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/137189
2025-04-09 23:07:03 +02:00
Campbell Barton
12f0164eb0 CMake: match defines & CMake variable names
Avoid mistakes with these variables getting mixed up
(see: bf03a2684b).

Ref !137183
2025-04-09 08:44:36 +00:00
Campbell Barton
e94068e8d2 PyAPI: add "image_webp" build option
Match other image_* format booleans.
2025-04-09 10:26:55 +10:00
Campbell Barton
bf03a2684b Fix: error with CMake checking the wrong WEBP variable 2025-04-09 10:21:37 +10:00
Jacques Lucke
3a7dc6ed7f Cleanup: improve comment 2025-04-08 12:29:02 +02:00
Jacques Lucke
53072e7a67 Cleanup: remove unnecessary null check
The null check is not necessary, because the function does not fail
because `PyUnicode_Check` is used on the value already.
2025-04-08 12:29:02 +02:00
Jacques Lucke
82aa6a3b71 Cleanup: improve comment for GeometrySet.name 2025-04-08 12:29:01 +02:00
Jacques Lucke
9c89e9c6fd Fix: raise exception when passing arguments to GeometrySet constructor 2025-04-08 12:29:01 +02:00
Jacques Lucke
d8a959f34a Cleanup: avoid error-prone function cast 2025-04-08 09:54:39 +02:00
Jacques Lucke
6f022e0530 Fix #137127: missing null check when accessing GeometrySet.mesh 2025-04-08 09:50:10 +02:00
Campbell Barton
256d964879 Cleanup: avoid function casts for BlenderAppTranslationsType 2025-04-08 14:57:14 +10:00
Clément Foucault
9d06508837 Fix #137052: GPU: Crash on startup caused by legacy pyGPU API
The removed legacy API was still in used by the pyGPU API.
Add a deprecation warning instead.

This partially reverts commit 3179cb0069.
2025-04-07 12:27:48 +02:00
Campbell Barton
1c702f9c94 Cleanup: assign the property flag to a variable 2025-04-06 10:48:36 +00:00
Campbell Barton
e85c18eb92 Cleanup: remove redundant casts 2025-04-06 20:39:39 +10:00
Campbell Barton
b43159088c Fix: use of non UTF8 string copy for thick wrapped strings in Python
Avoid potential incomplete UTF8 sequences in the Python RNA API.
2025-04-06 19:40:29 +10:00
Clément Foucault
3562433ae7 pyGPU: Deprecate Shader.program getter
This is getting in the way of making the
GPUShader API more threadsafe.

This getter already doesn't work for vulkan
and Metal, and has very limited usage.

Keeping the python function to avoid errors
and display a deprecation warning.

Pull Request: https://projects.blender.org/blender/blender/pulls/136983
2025-04-04 14:23:09 +02:00
Campbell Barton
4139d4a8f0 Cleanup: spelling in comments (make check_spelling_*) 2025-04-04 12:48:04 +11:00
nutti
eb3fb565bd PyDoc: correct formatting for GPUShaderCreateInfo.depth_write
Ref !136846
2025-04-04 10:18:34 +11:00
Campbell Barton
cf7d119e94 PyDoc: clarify the "capsule" return type 2025-04-02 03:02:04 +00:00
Campbell Barton
e58574e1aa Cleanup: minor corrections to code-comments 2025-04-02 03:02:03 +00:00
Campbell Barton
90fd070c28 Cleanup: spelling in comments (make check_spelling_*) 2025-04-02 03:02:01 +00:00
Jacques Lucke
46fc5cb2cf Python: flush stdout and stderr after running Python script
When debugging with gdb in vscode, the stuff I print when executing a script in
the text editor does not show up in the terminal. It does work when I flush
explicitly though using `print(..., flush=True)`. This is quite annoying.

The solution is to always flush `stdout` and `stderr` automatically when running
a script. This is done using the CPython API, as just using
`fflush(stdout/stderr)` did not solve the issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/136632
2025-04-01 12:41:38 +02:00
Campbell Barton
3e496a5dfe Cleanup: add missing doxygen file headers 2025-04-01 12:35:01 +11:00
Campbell Barton
7ae020ecd1 Cleanup: use our utility function to create a PyUnicode from a std:str 2025-04-01 12:33:56 +11: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
ccbf8c0544 Cleanup: resolve unknown pragma warning for CLANG 2025-04-01 12:05:25 +11:00
Jeroen Bakker
5a5471b622 Python: Add GPUShaderCreateInfo.depth_write method
Setting depth_write option of ShaderCreateInfo isn't available in
python GPU module. This PR adds support of it.

References #136732

Pull Request: https://projects.blender.org/blender/blender/pulls/136752
2025-03-31 12:37:56 +02:00
Jacques Lucke
29fddf4710 Python: Geometry: create GeometrySet wrapper for Python
In Geometry Nodes a geometry is represented by a `GeometrySet`. This is a
container that can contain one geometry of each of the supported types (mesh,
curves, volume, grease pencil, pointcloud, instances). It's possible for a
`GeometrySet` to contain e.g. a mesh and a point cloud.

This patch creates a Python  wrapper for the built-in `GeometrySet`. For now,
it's main purpose is to consume the complete evaluated geometry of an object
without having to go through complex hoops via `depsgraph.object_instances`. It
also also allows retrieving instances that have been created with legacy
instancing systems such as dupli-verts or particles.

In the future, the `GeometrySet` API could also be used for more kinds of
geometry processing from Python, similar to how we use `GeometrySet` internally
as generic geometry storage.

Since we can't really have constness guarantees in Python currently, it's
enforced that the `GeometrySet` wrapper always has its own copy of each geometry
type (so e.g. it does not share a `Mesh` data-block pointer with any other place
in Blender). Without the copy, changes to the mesh in the geometry set would
also affect the evaluated geometry that Blender sees. The copy has a small cost,
but typically the overhead should be low, because attributes and other run-time
data can still be shared. This should be entirely thread-safe, assuming that no
code modifies implicitly shared data, which is forbidden. For historic reasons
there are still cases like #132423 where this assumption does not hold in all
cases. Those cases should be fixed. To my knowledge, this patch does not
introduce any new such issues or makes existing issues worse.

Pull Request: https://projects.blender.org/blender/blender/pulls/135318
2025-03-28 22:40:01 +01:00
Campbell Barton
38d9d971e5 WM: add a "Hyper" capability flag
Avoids the need to check against ghost backends.
2025-03-28 13:46:39 +11:00
Campbell Barton
12e17e2477 Cleanup: use const arguments, variables 2025-03-28 00:59:11 +00:00
Brecht Van Lommel
a02e0fa147 Refactor: Improve image buffer save/load function names and arguments 2025-03-27 22:07:51 +01:00
Andrej730
224b8bb116 PyDoc: add node classes to register_class doc-string
Ref: !136375
2025-03-26 16:33:34 +11:00
Campbell Barton
6960d05df8 Fix: exception showing touch-pad preferences
Regression in [0] returned null without an exception set.

[0]: d9f38fca5f
2025-03-26 15:34:07 +11:00
Bastien Montagne
14913a447c Fix #136294: Blender 4.4 is discarding exceptions occurred in operator's constructor
While using constructors in Operator classes is _really_ not
recommended, BPY code was a bit too eager to overwrite existing errors
with its own generic messages.

Now only generate these exceptions if there is no other exception
already set.
2025-03-21 11:29:59 +01:00
Campbell Barton
e1f91c2dba Cleanup: replace int with wmOperatorStatus, consistent naming
- Manually check over all direct calls to operator callbacks
  ensuring the result isn't assigned to an int.
- OPERATOR_RETVAL_CHECK() now fails unless a wmOperatorStatus is used.
- Check the return values of direct calls to callbacks.
- Remove invalid check for the return value of rna_operator_check_cb.
- Use the variable name `retval` as it's most widely used.
- Move the assignment of `retval` out of the `if` statement in
  sculpt/paint operators because it prevents assigning the result
  `const` variable.
2025-03-21 00:13:30 +00:00
Campbell Barton
2659ec12f5 Cleanup: replace int with wmOperatorStatus
Follow up to adding wmOperatorStatus, these cases were missed as they
didn't cause compiler warnings.
2025-03-21 08:34:21 +11:00
Brecht Van Lommel
9526fe9993 Refactor: Add BKE_mesh_new_from_object argument to ignore subdivision
Pull Request: https://projects.blender.org/blender/blender/pulls/135895
2025-03-19 14:08:37 +01:00
Campbell Barton
c3e5a35ecd PyAPI: add blf.bind_imbuf(..) context manager
Add support for using BLF to draw into an ImBuf image buffer.
Once the imbuf context has been set, draw calls for that font_id will draw into the image.

This works by binding an imbuf to BLF which is then used as the target when drawing.
```
with blf.bind_imbuf(font_id, imbuf):
    blf.draw_buffer(font_id, text)
```
See the example in the Python API documentation for reference.

The following BLF API's have been added to support a Python context manager.

- `BLF_buffer_state_push`.
- `BLF_buffer_state_pop`
- `BLF_buffer_state_free`

Ref !135772
2025-03-15 11:00:51 +11:00
Campbell Barton
78c3f6a1ee Cleanup: adjust order of terms for BMesh UV map function calls
Order more generic terms first for better ordering, more useful
completion.
2025-03-13 15:23:46 +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