Commit Graph

152599 Commits

Author SHA1 Message Date
Sybren A. Stüvel
3ca28acbb3 Introduce Python code generator for OpenAPI spec to dataclasses
Add a [Python code generator][1] that takes an OpenAPI definition and
outputs the corresponding data model as [dataclasses][2]

This is intended to be used in the Remote Asset Library project, to
create, download, parse, and validate information of a remote asset
library.

[1]: https://koxudaxi.github.io/datamodel-code-generator/
[2]: https://docs.python.org/3/library/dataclasses.html

## Running the Generator

The generator is a Python script, which creates its own Python
virtualenv, installs the dependencies it needs, and then runs the
generator within that virtualenv.

The script is intended to run via the `generate_datamodels` CMake
target. For example, `ninja generate_datamodels` in the build
directory.

## Details

The virtualenv is created in Blender's build directory, and is not
cleaned up after running. This means that subsequent runs will just
use it directly, instead of reinstalling dependencies on every run.

## Generated Code & Interaction with Build System

It is my intention that the code generation _only_ happens when the
OpenAPI specification changes. This means that the generated code will
be committed to Git like any hand-written code. Building Blender will
therefore _not_ require the code generator to run. Only people working
on the area that uses the generated code will have to deal with this.

Pull Request: https://projects.blender.org/blender/blender/pulls/139495
2025-08-01 16:33:56 +02:00
Brecht Van Lommel
24a7c42766 Cleanup: Remove unused and outdated render test files
Pull Request: https://projects.blender.org/blender/blender/pulls/143438
2025-08-01 16:02:48 +02:00
Nika Kutsniashvili
7158e02aed Modeling: Set shape key default value to 1.0
When adding a shape key, set its blend value to 1.0 / 100%.

There is no practical use case where user wants to add shape key but
not work on it. New shape keys at value 0 have no purpose. Adding
shape key should be interpreted by Blender as user wanting to
sculpt/model on it. Also, being at 1.0 initially doesn't change
anything visually, because key isn't edited yet and it doesn't deform
mesh.

The default value of the shape key is also set to 1.0. When using
right-click to reset values, user most often wants to return to 1
(which is "correct" state of deformation without multiplication)
rather than 0 (which is no deformation at all).

Co-authored-by: Sybren A. Stüvel <sybren@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/133399
2025-08-01 15:43:31 +02:00
Philipp Oeser
8678766c5a Fix #143648: Cannot add collection instances to light linking
Since c6c127bfd3, objects for which `OB_TYPE_IS_GEOMETRY` fails (e.g.
Empties) were skipped.
However, empties instancing collections works well with light linking if
they contain geometry so we should be supporting these.

In order to do this use an existing function from preview rendering
(`collection_preview_contains_geometry_recursive`), move that to BKE and
use that from light linking operators.

Pull Request: https://projects.blender.org/blender/blender/pulls/143776
2025-08-01 15:43:00 +02:00
Miguel Pozo
34db9bd087 Fix: OpenGL: Invalid GL info on GPUSecondaryContexts
When creating `GPUSecondaryContext`s, `epoxy_gl_version` returns 0 and
`epoxy_has_gl_extension` always returns false.
This is caused by `GPU_context_create` being called without the ghost
context being activated.

Activating it fixes the issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/142715
2025-08-01 15:32:50 +02:00
Ian Yoo
562020e0f0 Tests: Fix keying screen test
This PR adds more markers and re-tracks them correctly on the cube clip
The output should be a gradient color, which was tested with another
setup and should mask the clip if used in conjunction with the keying
node (this PR doesn't include that setup, just the keying screen fix).

Coverage remains the same.

Pull Request: https://projects.blender.org/blender/blender/pulls/142534
2025-08-01 15:27:34 +02:00
Weizhen Huang
1667d69d3b Cleanup: Cycles: use constexpr in kernel
instead of lambda and macro guard. Should be possible after ce0ae95ed3

Pull Request: https://projects.blender.org/blender/blender/pulls/143723
2025-08-01 14:06:13 +02:00
Bastien Montagne
f4ae983dfb RNA: Improve handling of ID refcounting by Pointer properties.
This commit works on two related issues:
1. It is too easy to forget to handle ID refcounting in custom RNA setters.
2. It is not possible to fully force RNA refcounting ON or OFF for some
   properties.

Issue 1. has bit us several times recently (e.g. in animation or
compositor areas, see latest fix blender/blender!143577).

This commit addresses it by adding some debug-only checks around the
call to `PointerPropertyRNA::set()` in `RNA_property_pointer_set()`,
that validates that usercount of both previously and newly assigned IDs
matches expected (changes of) values.

While not ideal, this should make it way easier for developers to catch
that issue in the future.

The second issue was discovered while working on the first, leading to
e.g. questionable work-arounds like the `rna_DriverTarget_id_set`
setter, only defined to by-pass the automatically assigned
`PROP_ID_USERCOUNT` flag (and related automatic refcounting of the
default setter code).

It is addressed by adding an internal `PROP_INTERN_PTR_ID_REFCOUNT_FORCED`
flag, which keeps track of calls to
`RNA_def_property_flag`/`RNA_def_property_clear_flag` which explicitely
sets or clears the `PROP_ID_USERCOUNT` flag, and prevents automatic
setting of that flag in that case.

Pull Request: https://projects.blender.org/blender/blender/pulls/143660
2025-08-01 14:01:24 +02:00
Campbell Barton
2c27d2be54 Cleanup: grammar corrections, minor improvements to wording 2025-08-01 21:41:24 +10:00
Habib Gahbiche
53380ed8b2 Cleanup: redundant check for shader type
Pull Request: https://projects.blender.org/blender/blender/pulls/143784
2025-08-01 13:38:54 +02:00
Falk David
4a36f5b2dc Fix: Rigify: Wrong type in create_object_data for Grease Pencil
The code was using the legacy Grease Pencil data type
in `create_object_data`. For the object type `GREASEPENCIL` we should
be using `bpy.data.grease_pencils_v3`.

Pull Request: https://projects.blender.org/blender/blender/pulls/142335
2025-08-01 13:35:10 +02:00
Hugh Delaney
930a942dd0 Refactor: Cycles: Move block sizes into common header
This change puts all the block size macros in the same common header, so
they can be included in host side code without needing to also include
the kernels that are defined in the device headers that contained these
values.

This change also removes a magic number used to enqueue a kernel, which
happened to agree with the GPU_PARALLEL_SORT_BLOCK_SIZE macro.

Pull Request: https://projects.blender.org/blender/blender/pulls/143646
2025-08-01 13:26:02 +02:00
Jacques Lucke
3905cdd89a Fix #143455: crash in Grease Pencil Shrinkwrap modifier when there is a dependency cycle
The case when no mesh can be retrieved from the shrinkwrap target object can be
retrieved was not handled. It was handled by `ensure_shrinkwrap_cache_data` but
the calling function didn't check if the cache was actually created.
`BKE_modifier_get_evaluated_mesh_from_evaluated_object` can return null for an
object that would usually have a mesh but the object has not been evaluated yet,
as can be the case when there is a depsgraph cycle.

From my current understanding, the issue existed without 83325d1fd. Changing the
hash just made the depsgraph do different scheduling decisions so that now the
shrinkwrap was evaluated before the target object. The order in which these two
things are evaluated is arbitrary when there is a depsgraph cycle.

Pull Request: https://projects.blender.org/blender/blender/pulls/143757
2025-08-01 12:58:31 +02:00
Sybren A. Stüvel
bd7b8bbeaf Shape Keys: expand tooltip of Make Basis Key operator
Expand the tooltip of the "Make Shape Key the Basis Key" to clarify that
the chosen shape key will be applied at 100%, and not at the current
blend value.

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

Pull Request: https://projects.blender.org/blender/blender/pulls/143466
2025-08-01 12:54:50 +02:00
Sybren A. Stüvel
abb0c49870 Shape Keys: let Make Basis Key also update the "relative to" fields
When a shape key is made the new basis key, also update the "Relative
To" setting on the old & new basis keys. Both are made relative to the
new basis shape key.

Without this, the old basis key would still be relative to itself, which
effectively disables it. By making it relative to the new basis key, you
can increase its blend value to invert the effect of the new basis key.

Pull Request: https://projects.blender.org/blender/blender/pulls/143466
2025-08-01 12:54:46 +02:00
Sybren A. Stüvel
3d40246e94 Python: add HTTP file downloader
Add a new package `scripts/modules/_bpy_internal/http`, containing
classes to download files via HTTP.

The code is intentionally put into the `_bpy_internal` package, as I
don't intend it to be the end-all-be-all of downloaders for general
use in add-ons. It's been written to support the Remote Asset Library
project (#134495), where it will be used to download JSON files (to
get the list of assets on the server) as well as the asset files
themselves.

The module consists of several parts. The main ones are:

`class ConditionalDownloader`
: File downloader, which downloads a URL to a file on disk.

  It supports conditional requests via `ETag`/`If-None-Match` and
  `Last-Modified`/`If-Modified-Since` HTTP headers (RFC 7273, section 3.
  Precondition Header Fields). A `304 Not Modified` response is
  treated as a succesful download.

  Metadata of the request (the response length in bytes, and the above
  headers) are stored on disk, in a location that is determined by the
  user of the class. Probably in the future it would be nice to have a
  single sqlite database for this (there's a TODO in the code about
  this).

  The downloader uses the Requests library, and manages its own HTTP
  session object. This way it can handle TCP/IP connection reuse,
  automatically retry failing connections, and in the future
  HTTP-level authentication.

`class BackgroundDownloader`
: Wrapper for a `ConditionalDownloader` that manages a background
  process for the actual downloading.

  It runs the downloader in a background process, while ensuring that
  its reporters (see below) get called on the main process. This way
  it's possible to do background downloading, while still receiving
  progress reports in a modal operator, which in turn can directly
  call Blender's Python API. Care was taken to [not use Python
  threads][1]

`class DownloadReporter`
: Protocol class. Objects adhering to the protocol can be given to a
  `ConditionalDownloader` or `BackgroundDownloader`. The protocol has
  functions like `download_starts(…)`, `download_progress(…)`,
  `download_error(…)`, which will be called by the downloader to
  report on what it's doing.

  I chose to make this a protocol, rather than an abstract superclass,
  because then it's possible to make an Operator a DownloadReporter
  without requiring multi-classing.

[1]: https://docs.blender.org/api/main/info_gotchas_threading.html

Pull Request: https://projects.blender.org/blender/blender/pulls/138327
2025-08-01 12:27:56 +02:00
Benjamin Beilharz
53832755ae Compositor: Adds extension modes to map UV node
This commit introduces the extension modes for the map UV node. The
drop-down for the extension modes is only shown if the interpolation
mode is not set to anisotropic. This is due to extension modes currently
not being supported for the anisotropic filtering.

Pull Request: https://projects.blender.org/blender/blender/pulls/143415
2025-08-01 11:00:24 +02:00
Christoph Neuhauser
f03392a09a Fix #141436: Dilate node Feather mode has artifacts
The Dilate node Feather mode has artifacts on Intel Windows GPUs. This
is due to a wrong shader image format. So this patch fixes that by using
the correct single channel format.

Pull Request: https://projects.blender.org/blender/blender/pulls/143748
2025-08-01 10:52:33 +02:00
Habib Gahbiche
d04ae09aff Compositor: remove scene.node_tree from Python API
Since we are removing `scene.use_nodes` in #143578, most developers
will have to update their python script by replacing `scene.node_tree`
by `scene.compositing_node_group` in order to create a new compositing
 node tree anyways. So we remove `scene.node_tree`.

Note: `scene->nodetree` in `scene_blend_write()` is still being written
to the blend file, so forward compatibility is not affected by this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/143619
2025-08-01 10:30:11 +02:00
Bastien Montagne
d415890708 RNA: Improve handling of bitflags enum properties.
* Remove the 'set default from all bitflags items' behavior of
  `RNA_def_property_enum_bitflag_sdna`.
* Add some minimal sanity check regarding bitflag enums that also define
  an `items` runtime callback.
  It currently assumes that if a valid set of items is also statically
  defined, the items callback will return a subset of these.

Implements #143538.

Pull Request: https://projects.blender.org/blender/blender/pulls/143733
2025-08-01 10:25:41 +02:00
tariqsulley
b9958fa4da Modeling: mirror support for the hide operator
Use EditMeshSymmetryHelper so hiding operates on mirrored geometry.

Ref !142698
2025-08-01 05:02:08 +00:00
tariqsulley
0720f90606 Edit Mesh: add EditMeshSymmetryHelper utility class
This class simplifies supporting mirror functionality for edit-mesh
operators.

No functional changes.

Ref !142698
2025-08-01 15:00:13 +10:00
Mattias Fredriksson
e191d3d243 IO: OBJ improvements for NURBS curves
* Bezier (NURBS) import, supporting both Blender and external variants.
* Cleaner Bezier export, with better results importing in Rhino.
* Internal support for exporting the new Curves type.
* Tests covering a broad number of related cases.

The current NURBS exporter writes curve data directly, without accounting
for internal padding or how knots are generated from modes. This adjusts the
export behavior to omit data that does not influence the geometry of the
curve. The result is a simplified output that is easier to parse during import,
both for the importer and when importing to other platforms (Rhino).
Visual explanation to the adjustment can be found in #139174.

Importer is also adjusted to support variations in knot patterns. Extending
it to support the data generated by the exporter and by other platforms (Rhino).
This should resolve some issues in relation to #138732.

Integrated tests are added to broadly validate the common cases generated
by the exporter, including variations of different modes and NURBS order.

Regression tests are added to validate that the NURBS generated in Rhino
are imported as expected.

More details in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/139174
2025-08-01 06:37:28 +02:00
Campbell Barton
2b97043379 Cleanup: use doxygen comments for BLF headers 2025-08-01 04:08:30 +00:00
Campbell Barton
62dc34621a Cleanup: quiet warning in GCC 2025-08-01 14:02:26 +10:00
Campbell Barton
c04310d69f Fix memory leak when loading libraries fails from Python 2025-08-01 13:40:56 +10:00
Sean Kim
531d3d0a9c Cleanup: Rename sculpt_undo.cc NodeGeometry variables
Pull Request: https://projects.blender.org/blender/blender/pulls/143760
2025-08-01 00:24:21 +02:00
Sean Kim
e7378f1efd Fix: Avoid CLG_Level warning when -1 is used as CLI parameter
This commit prevents the UBSAN `-fsanitize=enum` warning from being
printed when `--log-level -1` is used on the command line.

Pull Request: https://projects.blender.org/blender/blender/pulls/143755
2025-07-31 22:23:16 +02:00
Jacques Lucke
c91a21d42b Fix: Geometry Nodes: crash when linking closure/bundle to group in/output extent socket
The issue was that the parent node group was not necessarily updated already
when the tracing code ran. So use socket identifiers instead of indices to try
to find corresponding sockets between group nodes and their corresponding
node groups.
2025-07-31 22:06:30 +02:00
Jacques Lucke
890ab23e0d Refactor: Nodes: return pointer instead of reference from in/output_by_identifier
This makes it possible to use these methods in cases where it's not guaranteed
that the identifier exists on a node.
2025-07-31 21:58:58 +02:00
Jacques Lucke
90b0e06fc7 Fix: Geometry Nodes: handle linking bundle/closure node to incompatible socket 2025-07-31 21:46:00 +02:00
Harley Acheson
6ac9b974ea Fix #98089: Improved Alignment of Playhead and Keyframes
This PR improves alignment between playhead and keyframe indicators,
especially noticeable at small UI scale sizes where we are currently
always out by one pixel. This is because keyframe icons are all odd
widths while the playhead line is an even width. This PR mostly makes
that line an odd width, with other small adjustments.

Pull Request: https://projects.blender.org/blender/blender/pulls/142904
2025-07-31 21:36:07 +02:00
Jacques Lucke
f73f9ad477 Geometry Nodes: move closure and bundle nodes to their own menu
This is still only visible if the experimental feature is enabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/143749
2025-07-31 21:08:47 +02:00
Jacques Lucke
9788f9f62a Geometry Nodes: sync bundle/closure nodes on first link
When using link-drag-search to create bundle or closure nodes, the newly created
nodes are already synced automatically. Now this automatic syncing also happens
when an empty node is first linked. If there are any sockets already, the
automatic syncing does not happen as it can be unintentional. In this case the
user can just click the sync icon in the node header to update the sockets.

Pull Request: https://projects.blender.org/blender/blender/pulls/143744
2025-07-31 20:49:28 +02:00
Jean-Silas
95422b95ee Fix: UI: Fuzzy Search: incorrect max acceptable edit distance for deletions in short words
This fixes an edge case in how the max acceptable edit distance is calculated
for deletions in fuzzy search, wherein the padding added to the max error count
could be negative when the query was longer than the matched term, producing a
max distance of zero.

This came up in chat a while back, where someone noted that, in the compositor,
searching for "bluir" wouldn't return the blur nodes; "blu" worked, "blui"
worked,  but "bluir" returned no results, despite all three having equal edit
distances (1 insertion, 1 substitution, and 1 deletion, respectively). The edit
distance metrics themselves are calculated correctly; the issue was just with
how the distance threshold was set.

Pull Request: https://projects.blender.org/blender/blender/pulls/143741
2025-07-31 20:47:06 +02:00
Jacques Lucke
f03259b0d1 Geometry Nodes: improve info/error messages for mismatching data types
Mention "bundle" or "closure" in the error message to that it is more
obvious what's wrong when seeing the error message at a higher level.
2025-07-31 20:41:32 +02:00
Jacques Lucke
4c3724180b Refactor: Geometry Nodes: extract value tracing to separate file
This moves code used for tracing bundles and closures to a separate file. This
code is used to e.g. detect which Separate Bundle node a Combine Bundle node is
linked to. This allows providing automatic socket update operators for these
nodes. Similarly for closures.

Pull Request: https://projects.blender.org/blender/blender/pulls/143734
2025-07-31 20:35:09 +02:00
Jacques Lucke
b7194ad693 Geometry Nodes: move sync out of subpanel for bundle/closure nodes
This was mentioned in #140967.
2025-07-31 20:23:50 +02:00
Nika Kutsniashvili
39c066ee53 UI: Add common theme properties panel; make preview range common
First part of design defined in #140360

Images in PR

This PR does two things:
- Creates new panel in theme preferences called "Common" that
doesn't belong to any editor
- Moves "Preview Range" property in common, and removes it
from animation editors.

Now, there is a single theme property for preview range, rather
than 5 for each animation editor.

Co-authored-by: Pablo Vazquez <pablo@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/140686
2025-07-31 20:19:00 +02:00
Miguel Pozo
0730d3f256 Fix: Python API: bpy.app.is_job_running('SHADER_COMPILATION')
Shader compilation no longer uses the `WM_job` API.
Add a `GPU_shader_batch_is_compiling` function to query if there's any
shader compilation happening, and update `bpy_app_is_job_running` to
handle this as a special case.

Pull Request: https://projects.blender.org/blender/blender/pulls/143559
2025-07-31 20:06:27 +02:00
Harley Acheson
972c0b9463 UI: BLF Use Custom NotDef Not Last Resort
This PR removes the "Last Resort" font from the stack. Instead uses a
custom "not def" glyph, defined as an SVG file. This glyph is shown
when requesting a character not found for text inputs, text editor, and
for Sequencer text strips.

Pull Request: https://projects.blender.org/blender/blender/pulls/132032
2025-07-31 19:53:29 +02:00
илья _
b4a355b30d Fix: Ensure world nodes have topology cache for Hydra
Methods like directly_linked_links require a tree topology cache to be there.

Pull Request: https://projects.blender.org/blender/blender/pulls/143670
2025-07-31 19:49:15 +02:00
Brecht Van Lommel
cedd7edd29 Cleanup: Cycles: Use gtest header instead of Blender test header
To avoid conflicts with glog logging macros, and because there is just no
need to have this dependency.

Pull Request: https://projects.blender.org/blender/blender/pulls/143719
2025-07-31 19:46:54 +02:00
Jacques Lucke
97b5618911 Refactor: Nodes: pass params as struct to bNodeType::insert_link
This simplifies potentially adding a `bContext` argument which allows for more advanced behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/143732
2025-07-31 19:22:11 +02:00
Aras Pranckevicius
77eec34973 Cleanup: BLF FontFlags enum type safety, move enums to separate header
- BLF font flags were an untyped enum; change to actual enum and
  update usages from int to that.
- Move all BLF API enums to their own header, so that if something
  needs just the enums they don't have to include whole BLF_api.hh

Pull Request: https://projects.blender.org/blender/blender/pulls/143692
2025-07-31 18:47:19 +02:00
Jacques Lucke
c67040771e Refactor: Geometry Nodes: generalize stop condition when tracing bundles/closures
Previously, the code assumed that closures are always created with the closure
zone and end up in the Evaluate Closure node. Similarly with bundles. While true
right now, this won't be true anymore with e.g. #141264 where unlinked input
sockets can also have a closure.

Pull Request: https://projects.blender.org/blender/blender/pulls/143725
2025-07-31 18:35:54 +02:00
Falk David
cd7b933cb6 Fix #143715: Grease Pencil: Replace uses of legacy BlendData type
There were some more uses of the legacy Grease Pencil type
in `BlendData`.

Pull Request: https://projects.blender.org/blender/blender/pulls/143716
2025-07-31 18:14:44 +02:00
Jacques Lucke
6ec5ee713b Cleanup: Geometry Nodes: add comment 2025-07-31 17:18:59 +02:00
Miguel Pozo
b43616513a OpenGL: Remove gl_debug_layer
It's broken and it's not needed anymore, since we require OpenGL 4.3.

Fix #142620

Note: Debug callbacks still won't work for compilation threads,
but that's relatively harmless and should cause no issues for the user.
This will be fixed in 5.0 with #142715.

(4.5 backport candidate)

Pull Request: https://projects.blender.org/blender/blender/pulls/142716
2025-07-31 16:36:08 +02:00
Damien Picard
f6771d8e21 UI: Improve running jobs labels
Use the form "Processing something..." (gerund, sentence case,
ellipsis) for running jobs progress label, according to Blender's
Human Interface Guidelines.

Pull Request: https://projects.blender.org/blender/blender/pulls/141573
2025-07-31 16:32:41 +02:00