Replace per UV map selection with a single UV selection for all UV's.
This uses the same data as UV sync select, meaning that it's no longer
possible to keep a different selection when sync-select is disabled.
There is a minor improvement to functionality - previously not possible
to de-select a single face surrounding by selected faces.
Now this is possible because true face selection is supported.
The selection from the active UV-map is converted to use the shared
selection data.
Ref !147523
Co-authored-by: Hans Goudey <hans@blender.org>
Merges the existing `bpy.context` logging with the new `context` logging
added in [0]. In most cases `bpy.context` & `context` log the same thing.
Where the new `context` logging produces more accurate results.
Ref !146407
[0]: 439fe8a1a0
Support sync selection in the UV editor, with face-corner selection,
so it's possible to select individual UV vertices/edges in the UV editor
without UV's attached to the same underlying edge also becoming selected.
There is limited support for maintaining the UV selection when selecting
from the 3D viewport, common operations such as picking &
box/circle/lasso select support this, however other selection operations
such as "Select Random" or "Select Similar" will clear this data,
causing all UV's connected to selected mesh elements to become selected.
We may add support for additional operators as needed.
Details:
- UV Sync Selection is now enabled by default.
- In edit-mode the UV selection is stored in BMLoop/BMFace which are
written to custom-data layers when converted to a Mesh.
- To avoid unnecessary overhead - this data is created on demand.
Operators may clear this data - selecting all or none do so,
as there is no reason to store this data for a uniform selection.
- The Python API includes functions to synchronize the selection to/from
UV's as well as flushing based on the mode.
- Python scripts that manipulate the selection will either need to clear
this synchronized state or maintain it.
See:
- Design task: #78393.
- Implementation task: #131642.
Ref !138197
Add a function `bpy.data.file_path_foreach()` with a callback function
`visit_path_fn`:
```py
def visit_path_fn(
owner_id: bpy.types.ID,
file_path: str,
_meta: typing.Any,
) -> str | None:
return file_path.replace('xxx', 'yyy') or None
bpy.data.file_path_foreach(
visit_path_fn,
*,
subset=None,
visit_types=None,
flags={},
)
```
When the function returns `None`, nothing happens. When it returns a
string, the reported file path is replaced with the returned string.
`subset` and `visit_types` have the same meaning as `subset` resp.
`key_types` in `bpy.data.file_path_map()`. Since the latter parameter
doesn't affect keys in a map, but rather the visited ID types, I named
it `visit_types` instead.
`flags` wraps most of `eBPathForeachFlag` as `set[str]`, with their
prefixes removed. `BKE_BPATH_FOREACH_PATH_RESOLVE_TOKEN` becomes
`RESOLVE_TOKEN`, etc. `BKE_BPATH_FOREACH_PATH_ABSOLUTE` is excluded,
as it only affects a field in the C++ callback structure that is not
passed to Python at all. If it turns out to be useful at some point,
we can always add it.
`_meta` is for future use, and is intended to give metadata of the
path (like whether it's an input or an output path, a single file or
the first file in a sequence, supports variables, etc.). By adding
this to the API now, we avoid a breaking change when this feature is
actually implemented.
Design task: #145734
Pull Request: https://projects.blender.org/blender/blender/pulls/146261
The `INSERTKEY_XYZ_TO_RGB` flag on `datablock.keyframe_insert()` in
Blender's Python API was changed to do nothing in #115297 and #119625,
in favor of determining fcurve coloring exclusively from user preferences.
This PR removes that now-useless `INSERTKEY_XYZ_TO_RGB` flag entirely.
Pull Request: https://projects.blender.org/blender/blender/pulls/147262
Based on the Python API for UV selection (!138197),
some methods that set the selection need a flush down argument too,
name the argument more clearly so the same name can be used by
all selection functions.
Support optionally flushing down:
- faces -> edges & verts.
- edges -> verts.
For C++ selection logic flushing down is avoided as it's an extra step
and instead, selection logic must take care to de-select edges/faces
before selection, so any shared vertices or edges are selected.
Flushing down means scripts can set the selection on faces or edges,
then flush this to all other elements without being concerned with
the order they have been set.
Ref !147351
The BMesh::selectmode is expected to be set when performing any
selection operations on the BMesh. While it wasn't possible to set
the select_mode to zero from Python, this meant assigning the attribute
from one BMesh to another could fail with an exception.
Aside from this, selection logic wouldn't work as expected.
Ref !147278
This is to make it easy to get the bpy paths to bpy.context.property for
example. Before this change, the easiest way was to use the clipboard
bpy.ops function. However this would make the python scripts using this
fragile as it we do not have full control of what is stored in the
system clipboard.
Pull Request: https://projects.blender.org/blender/blender/pulls/147116
Each name has to be unique within a group, so when renaming an idproperty, one
has to make sure that the parent group does not contain duplicates afterwards.
This patch raises a `NameError` when setting the name to one that exists
already. Alternatively, one could delete the already-existing property, but that
seems unexpected and the user should rather do that explicitly.
This also adds a new unit test for this case.
Pull Request: https://projects.blender.org/blender/blender/pulls/146892
Python API functions would both report an error through CLOG and throw an
exception. However this is a problem when --debug-exit-on-error is used,
as tests and other scripts will not have the opportunity to catch the exception
before Blender exits.
Now don't print such reports through CLOG. Note that these usages of
BKE_reports_init have their print level set to error, so were already not
printing info and warning reports (which is not something we generally
want Python API calls to do, they should be silent).
Ref #146256
Pull Request: https://projects.blender.org/blender/blender/pulls/146801
This adds support for packed linked data. This is a key part of an improved
asset workflow in Blender.
Packed IDs remain considered as linked data (i.e. they cannot be edited),
but they are stored in the current blendfile. This means that they:
* Are not lost in case the library data becomes unavailable.
* Are not changed in case the library data is updated.
These packed IDs are de-duplicated across blend-files, so e.g. if a shot
file and several of its dependencies all use the same util geometry node,
there will be a single copy of that geometry node in the shot file.
In case there are several versions of a same ID (e.g. linked at different
moments from a same library, which has been modified in-between), there
will be several packed IDs.
Name collisions are averted by storing these packed IDs into a new type of
'archive' libraries (and their namespaces). These libraries:
* Only contain packed IDs.
* Are owned and managed by their 'real' library data-block, called an
'archive parent'.
For more in-depth, technical design: #132167
UI/UX design: #140870
Co-authored-by: Bastien Montagne <bastien@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/133801
The naming was confusing as only some selection flushing functions
were intended to be used when elements had been selected or de-selected.
Replace these with a single function that takes a "select" argument.
Adds comprehensive logging system for temp_override context manager to
help developers debug "context is incorrect" operator poll failures.
The logging tracks all context member access during temp_override
sessions and provides detailed summaries to identify context
availability issues.
Features:
- Command-line logging: `./blender --log-level trace --log "context" `
- Python programmatic control: `temp_override_handle.logging_set(True)`
- C-level API: CTX_temp_override_logging_set/get() functions
- Tracks individual member access
- Uses CLOG logging infrastructure
The logging helps identify which context members are accessed during
temp_override sessions and whether they return valid data, making it
easier to debug operator poll functions that fail with context errors.
Ref !144810
Currently, when a python error is encountered when rendering the UI, the
corresponding message is printed to stdout / stderr via `PyErr_Print`,
this patch modifies behavior so that a cursory message is also printed
with CLOG
This has the benefit of allowing for testing via
`--debug-exit-on-error`, which aborts Blender when an error message is
printed.
Pull Request: https://projects.blender.org/blender/blender/pulls/146296
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
This makes the shader node inlining from #141936 available to external renderers
which use the Python API. Existing external renderer add-ons need to be updated
to get the inlined node tree from a material like below instead of using the
original node tree of the material directly.
The main contribution are these three methods: `Material.inline_shader_nodes()`,
`Light.inline_shader_nodes()` and `World.inline_shader_nodes()`.
In theory, there could be an inlining API for node trees more generally, but
some aspects of the inlining are specific to shader nodes currently. For example
the detection of output nodes and implicit input handling. Furthermore, having
the method on e.g. `Material` instead of on the node tree might be more future
proof for the case when we want to store input properties of the material on the
`Material` which are then passed into the shader node tree.
Example from API docs:
```python
import bpy
# The materials should be retrieved from the evaluated object to make sure that
# e.g. edits of Geometry Nodes are applied.
depsgraph = bpy.context.view_layer.depsgraph
ob = bpy.context.active_object
ob_eval = depsgraph.id_eval_get(ob)
material_eval = ob_eval.material_slots[0].material
# Compute the inlined shader nodes.
# Important: Do not loose the reference to this object while accessing the inlined
# node tree. Otherwise there will be a crash due to a dangling pointer.
inline_shader_nodes = material_eval.inline_shader_nodes()
# Get the actual inlined `bpy.types.NodeTree`.
tree = inline_shader_nodes.node_tree
for node in tree.nodes:
print(node.name)
```
Pull Request: https://projects.blender.org/blender/blender/pulls/145811
Stored undo step data for position changes in sculpt mode are now
automatically compressed. Compression is run in background threads,
reducing memory consumption during sculpting sessions while adding
little performance overhead.
For testing and benchmarks, memory usage is now available through
`bpy.app.undo_memory_info()`. Undo memory usage is now tracked by the
existing automated benchmark tests. Some changes to the web benchmark
visualization present the data a bit better.
ZSTD compression is run asynchronously in a backround task pool.
Compression is only blocking if the data is requested immediately for
undo/redo.
Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/141310