Commit Graph

120282 Commits

Author SHA1 Message Date
Campbell Barton
628f1e08d0 Fix edge dissolve leaving visible edges connected to hidden vertices
Visible edges should always have both vertices visible.
When dissolving, hide any edges which become connected to hidden
vertices.
2025-06-05 05:33:51 +00:00
Jason C. Wenger
e418f7b1f1 Modeling: add an angle threshold that affects vertex dissolve
When dissolving an edge merges faces, use an angle threshold before
dissolving vertices from the face which have become chains as reult
of the merge (connected to 2 edges).

Also fix edge-flag handling when dissolving multiple edges
from a chain into a single edge, previously flags from the
resulting edge was effectively random.
Now flags from all edges are merged.

Resolves #100184.

Ref !134017
2025-06-05 05:33:49 +00:00
Campbell Barton
2d86699209 PyDoc: improve BMesh operator docs
- Place doc-strings before arguments (avoid over long lines).
- Enable clang-format for BMesh operator definitions.
- Remove invalid comments (likely left in from copy-paste).
- Use double back-ticks for RST.
- Use full sentences.

No functional changes.
2025-06-05 15:31:36 +10:00
Harley Acheson
ccb0dc50fb Fix #139780: Always Enforce Minimum Area Heights on File Load
We attempt to enforce a minimum area height so that they cannot be made
smaller than header height. This works correctly as we drag resize
areas but not when loading blend files. We skip doing so if resizing
from smaller to a bigger vertical size. This PR just makes it so we
enforce minimum size always.

Pull Request: https://projects.blender.org/blender/blender/pulls/139804
2025-06-05 03:31:56 +02:00
Sean Kim
6a03e8249d Paint: Add forward compatibility code for brush size
In 5.0, we plan to change the brush size from representing radius to
diameter. This means that for 5.0 files loaded in 4.5, we need to
scale the stored value when reading the relevant brush fields.

Related to #134204

Pull Request: https://projects.blender.org/blender/blender/pulls/139561
2025-06-05 00:44:43 +02:00
Sean Kim
e906fe2738 Fix: UV Editor doesn't show UVs in non-edit modes
Introduced in 440c6c8b6f

Pull Request: https://projects.blender.org/blender/blender/pulls/139857
2025-06-05 00:02:03 +02:00
Hans Goudey
c9bb7f0b23 Fix: Texture paint color jitter dereference of uninitialized optional
The value isn't created unless jitter is enabled, but it was always
retrieved for a function argument. The uninitialized memory wasn't read,
but it caused a crash in debug builds.

Pull Request: https://projects.blender.org/blender/blender/pulls/139854
2025-06-04 21:27:16 +02:00
Laurynas Duburas
46bc894570 Fix: Curves: Custom knots in Curves and GP operators
Current strategy to deal with operators not supporting custom NURBS
knots is to fall back to calculated knots for curves of the custom mode
but with no `CurvesGeometry::custom_knots` allocated. Such curves are
the result of operators that copy only `Point` and `Curve` domains. This
way the problem is only postponed. It is not possible to add new custom
knot curves to such `CurvesGeometry` as custom knot offsets are
calculated all together and there is no way to distinguish between old
curves with lost knots and new ones. This is more a future problem.

The actual problem in `main` can be shown with an attached blend file
(see PR) by applying `Subdivide` to some points and then adding new
`Bezier` curve to the same object. This particular problem could be
addressed somewhere in `realize_instances.cc` but the actual problem
would persist.

This PR handles custom knots in all places where `BKE_defgroup_copy_list`
is iused, and where `bke::curves::copy_only_curve_domain` is called.
Here the assumption is made that only these places can copy custom knots
modes without copying custom knots. Depending on operator logic knots are
handled most often in one of two ways:
 - `bke::curves::nurbs::copy_custom_knots`:
   copies custom knots for all curves excluding `selection`. Knot modes
   for excluded curves are altered from the custom mode to calculated.
   This way only curves modified by the operator will loose custom knots.
 - `bke::curves::nurbs::update_custom_knot_modes;`
   alters all curves to calculated mode.

In some places (e.g. `reorder.cc`) it is possible to deal with knots
without side effects.

PR also adds `BLI_assert` in `load_curve_knots` function to check if
`CurvesGeometry::custom_knots` exists for custom mode curves. Thus
versioning code is needed addressing the issue in files in case such
already exists.
Pull Request: https://projects.blender.org/blender/blender/pulls/139554
2025-06-04 20:43:15 +02:00
Hans Goudey
e346c6d7a0 Fix #139816: Corrupt wireframe with antialiasing off and subdivision
Caused by 1e1ac2bb9b.

Previous removal of < 4 byte aligned GPU vertex buffer formats was
incomplete. The edge factor buffer still used a single-byte format.

Pull Request: https://projects.blender.org/blender/blender/pulls/139839
2025-06-04 17:47:13 +02:00
Bastien Montagne
e66ebc5a5b Cleanup/Fix: BLO: Include missing header.
The `adjust_fcurve_key_frame_values` template uses enums from RNA
header, so directly include the relevant header.
2025-06-04 15:31:26 +02:00
Thomas Dinges
ea5b1f7527 Release: Update 4.5 branch to beta
Splash by Blender Studio
2025-06-04 14:10:17 +02:00
Bastien Montagne
456a07c5e6 Improve Blender resilience to blendfile DNA data corruption.
This commit improves DNA parsing resilience to data corruption in two ways:
* Detect and abort on failure to allocate requested amount of memory.
* Detect multiple usages of the same `type_index` by different struct
  definitions.

The second part fixes the `dna_genfile.cc:1918:40.blend` case reported
in #137870.

Pull Request: https://projects.blender.org/blender/blender/pulls/139803
2025-06-04 12:53:27 +02:00
Omar Emara
6bf52d11f1 Fix #139327: Movie distortion result is cropped
The Movie distortion node crops its data if the movie size differs from
the input size. That's because boundary extensions do not take
calibration size into account. To fix this, we use the same coordinates
range as the distortion grid computation, which computes the distortion
in the space of the calibration size.

Pull Request: https://projects.blender.org/blender/blender/pulls/139822
2025-06-04 12:24:33 +02:00
Falk David
889751b0c5 Grease Pencil: Add Convert Curve Type operator
Adds a new operator in Grease Pencil edit mode to convert between curve
types. This acts as a replacment for the `Set Curve Type` operator as
the new operator better aligns with previous workflows and artist
expectations. Specifically using a threshold to adjust how well the
resulting curves fit to the original.

It can be found in the `Stroke` > `Convert Type` menu.

This operator aims at keeping visual fidelity between the curves. When
converting to a non-poly curve type, there's a `threshold` parameter
that dictates how closley the shapes will match (a value of zero meaning
an almost perfect match, and higher values will result in less accuracy
but lower control point count).

The conversion to `Catmull-Rom` does not do an actual curve fitting.
For now, this will resample the curves and then do an adaptive
simplification of the line (using the threshold parameter)
to simulate a curve fitting.

The `Set Curve Type` operator is no longer exposed in the
`Stroke` menu.

This also adds a new `geometry::fit_curves` function.

The function will fit a selection of curves to bézier curves. The
selected curves are treated as if they were poly curves.

The `thresholds` virtual array is the error threshold distance
 for each curve that the fit should be within. The size of the virtual
 array is assumed to have the same size as the total number of
 input curves.

The `corners` virtual array allows specific input points to be treated
as sharp corners. The resulting bezier curve will have this point and
the handles will be set to "free".

There are two fitting methods:
* **Split**: Uses a least squares solver to find the control
                     points (faster, but less accurate).
* **Refit**: Iteratively removes knots with the least error starting
                     with a dense curve (slower, more accurate fit).

Co-authored-by: Casey Bianco-Davis <caseycasey739@gmail.com>
Co-authored-by: Hans Goudey <hans@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/137808
2025-06-04 11:48:15 +02:00
Pratik Borhade
0764217fb9 Fix #125974: Theme: TreeView list items use wrong theme settings
Set `UI_BLOCK_LIST_ITEM` flag for the block this will assign
`UI_BUT_LIST_ITEM` flag for tree view label buttons, see: `uiItemL_()`
That way `wcol_list_item` is being used for tree view.
(see: `widget_state()` / `widget_state_label()`

Pull Request: https://projects.blender.org/blender/blender/pulls/126026
2025-06-04 11:26:36 +02:00
Clément Foucault
2257ee7e56 GPU: OpenGL: Add support for non-blocking specialization
This avoid having to compile specializations JIT and
use the same API as subprocess compilation.

This bridges the gap between subprocess and threaded
compilation.

Pull Request: https://projects.blender.org/blender/blender/pulls/139702
2025-06-04 11:24:20 +02:00
Philipp Oeser
457cccd964 Fix #139782: USD MeshSequenceCache modifier using the wrong frame
It would run into using the same frame twice, looking like "freeze
frames"

Apparently we had a similar issue before, see 3f8ec963e3

Just a PoC to show that this looks like a precision/rounding issue when
getting a "working" `UsdTimeCode`.
In the modifier code, we are doing a roundtrip going from frame >> time
(in seconds -- via `BKE_cachefile_time_offset`) and then back to frame
before we store that in `USDMeshReadParams`.

To avoid the precision loss, this PR introduces
`BKE_cachefile_frame_offset` to stay in the "frame" domain and
circumvent going through FPS alltogether.

There might be better ways to let USD handle the "sightly off"
`UsdTimeCode` better though.

Pull Request: https://projects.blender.org/blender/blender/pulls/139793
2025-06-04 11:04:37 +02:00
Pratik Borhade
e24f46b12b Outliner: Support duplicating selected collections
Duplicating collection doesn't work when multiple collections are
selected, instead first selected collection is just duplicated. Now fixed
by iterating over list of selected collections returned by
`outliner_collect_selected_parent_collections` after traversing. In that
function, child collections are skipped if parent collection is already
selected, this avoids extra copies from being generated (i.e creates one
copy of nested collections).

Resolves #139651

Pull Request: https://projects.blender.org/blender/blender/pulls/139719
2025-06-04 11:00:44 +02:00
Jacques Lucke
36efa8d7a6 Fix: use getter function for Library.parent in RNA
Previously, this accessor didn't really work, because the `RNAPointer` would contain
the wrong pointer. I found that in #138485.

Pull Request: https://projects.blender.org/blender/blender/pulls/139817
2025-06-04 10:48:06 +02:00
Jacques Lucke
fc8695d6c5 Fix: assert in auto smooth operator
The check for whether the node group is valid requires the
interface cache.
2025-06-04 10:21:26 +02:00
Campbell Barton
8fd17c4368 Fix edit-mode check when removing materials
Comparing the object with "edit_object" isn't correct as
multiple objects may be in edit-mode across multiple scenes.

Check the object for edit-mode data instead.
2025-06-04 16:25:17 +10:00
Marc Hamamji
2b951355e3 Fix #133533: Inverted scroll direction in render pass menu
Ref !139777
2025-06-04 16:13:24 +10:00
Jacques Lucke
1e1e1333a6 Fix: wrong pointer passed to RNA_pointer_create_discrete
Found this using #138485.
2025-06-04 07:59:33 +02:00
Andrej730
f7ce58cefc Fix: PyDocs: Annotations for callables with variable number of arguments
Annotation `Callable[[Any, ...], str | None]` is not supported by Python
typing system and ... will be misinterpreted as unknown type instead of
option to provide variable number of arguments.

Ref !138804
2025-06-04 15:23:38 +10:00
Campbell Barton
534044ccef Fix #139681: Cursor appears in walk navigation after hovering over gizmo
Regression in [0] which would re-highlight gizmos when they had been
tagged for highlighting.

This caused highlighting to be recalculated unexpectedly while
blocking modal operators run that used a timer.

The timer events would be passed though to the gizmo handler which
then re-evaluated the highlighted gizmo based on the cursor position.

Resolve by skipping pass-through for gizmos.

[0]: f839847d3b4849425c3b06a52aae4361d384fea4
2025-06-04 13:54:32 +10:00
Campbell Barton
b20b2688ad Cleanup: add missing braces in walk/fly mode
Also use the region stored in the operator data when tagging to redraw.
2025-06-04 12:17:25 +10:00
Campbell Barton
6a1fa176ef Cleanup: spelling in comments & duplicate terms (check_spelling.py)
Also minor clarification in doc-string.
2025-06-04 01:51:29 +00:00
Campbell Barton
6fab30a767 Fix crash picking geometry with out of range material indices
Object::actcol assignments from edit-mode data wasn't clamping
the index to the valid range. This caused an out of bounds read when
accessing Object::matbits.

While material indexes should typically be within the material bounds,
this isn't guaranteed. Selecting a face for example with a material
outside the range was crashing.

Add a utility function that sets the active material index to replace
existing inline checks.

Follow up to the fix for #139369.
2025-06-04 01:25:12 +00:00
Campbell Barton
8173974925 Fix #139369: Crash pasting 3D text from a curve with more materials
Pasting text wasn't clamping the material range,
causing Object::actcol to exceed Object:totcol.
2025-06-04 10:32:26 +10:00
Guillermo Venegas
19741a6751 UI: Tooltip for dragging multiple files
This changes how tooltips for dragging multiple files are shown. this
shows an `Documents` icon and a counter of how many files are dragged.
When multiple files are dragged from Blender internal file browser,
this avoids showing the thumbnail of the file selected to start
dragging, if selection is unique this thumbnail will be visible.

Pull Request: https://projects.blender.org/blender/blender/pulls/136276
2025-06-04 00:15:36 +02:00
Sean Kim
463e543bc1 Cleanup: Rename and move BKE_sculpt_check_cavity_curves
* Move to paint.cc instead of scene.cc to be more specific
* Reword to `BKE_sculpt_cavity_curves_ensure` to better align with
  existing naming

Pull Request: https://projects.blender.org/blender/blender/pulls/139795
2025-06-03 20:38:37 +02:00
Jesse Yurkovich
04bc3f155e Fix #137662: Auto-validate meshes during USD import if we detect bad faces
A small number of USD files in the wild contain invalid face index data
for some of their meshes. This leads to asserts in debug builds and
crashes for users in retail builds(sometimes). There is already an
import option to Validate Meshes but it turns out that we, and most
other importers, perform validation too late. We crash before getting to
that validate option (see notes).

This PR implements a cheap detection mechanism and will auto-fix if we
detect broken data. The detection may not find all types of bad data but
it will detect what is known to fail today for duplicate vertex indices.

We immediately validate/fix before loading in the rest of the data. The
downside is that this will mean no additional data will be loaded.
Normals, edge creases, velocities, UVs, and all other attributes will be
lost because the incoming data arrays will no longer align.

It should be noted also that Alembic has also chosen this approach. It's
check is significantly weaker though and can be improved separately if
needed.

If auto-fix is triggered, it will typically appear as one trace on the
terminal.
```
WARN (io.usd): <path...>\io\usd\intern\usd_reader_mesh.cc:684
read_mesh_sample: Invalid face data detected for mesh
'/degenerate/m_degenerate'. Automatic correction will be used.
```

A more general downside of these fixes is that this applies to each
frame of animated mesh data. The mesh will be fixed, and re-fixed, on
every frame update when the frame in question contains bad data.

For well-behaved USD scenes, the penalty for this check is between 2-4%.
For broken USD scenes, it depends on how many meshes need the fixup. In
the case of the Intel 4004 Moore Lane scene, the penalty is a 2.7x
slowdown in import time (4.5 s to 12.5 s).

Pull Request: https://projects.blender.org/blender/blender/pulls/138633
2025-06-03 19:26:34 +02:00
Bastien Montagne
354ec7f642 Fix (unreported) 'too new' libraries not always correctly detected.
The checks and related warnings detecting usage of blendfiles generated
by newer versions of Blender were not fully behaving as expected for
libraries. In particular, opening an older main blendfile linking
against newer library ones would not always detect and report the
`has_forward_compatibility_issues` status properly.

Found out while working on 'longer ID names' compatibility PR for 4.5
(!139336).
2025-06-03 18:51:28 +02:00
Sean Kim
d4fb8c86c3 Cleanup: Move eUnifiedPaintSettingsFlags to DNA_scene_enums.h
Pull Request: https://projects.blender.org/blender/blender/pulls/139759
2025-06-03 18:05:22 +02:00
Clément Foucault
32c50e35c4 GPU: Add profiling groups for subprocess compilation 2025-06-03 17:57:16 +02:00
Clément Foucault
60f7ca21c3 GPU: Shader: Also move the compilation handle in static shaders
Small oversight.
2025-06-03 17:39:33 +02:00
Clément Foucault
e69762b8dd GPU: Add compilation constants
Compilation constants are constants defined in the create info.
They cannot be changed after the shader is created.
It is a replacement to macros with added type safety.

Reuse most of the logic from Specialization constants.

Pull Request: https://projects.blender.org/blender/blender/pulls/139703
2025-06-03 17:34:04 +02:00
Hans Goudey
c0ec3ff044 Fix: Crash with frame nodes after recent fix 2025-06-03 11:28:30 -04:00
Sean Kim
b1eef8bdac Cleanup: Remove unnecessary struct prefix in BKE_brush.hh
Pull Request: https://projects.blender.org/blender/blender/pulls/139771
2025-06-03 17:27:41 +02:00
Julian Eisel
06205ae977 Fix #139043: Asset shelf previews not updating when preview is changed
The "All Libraries" library didn't free its assets correctly on refresh,
so the asset previews didn't refresh correctly either. That's because it
didn't forward the removal request to the asset library that actually
owns the asset. It only freed assets from its own storage, which is
always empty.

This might make refreshing the all library feel a little slower, since
previews are now refreshed too. But in general this is fairly fast still
and there's an optimization to only load visible previews too.
2025-06-03 16:57:56 +02:00
Clément Foucault
1d638c0f5e EEVEE: Add deferred texture loading
This adds a new function to query GPUtexture from an
Image datablock without actually creating them.

This allows to keep track of all the texture that
needs to be loaded and defer their loading in
end_sync. The texture are then only used in the
next sync. This is because we do not want to stage
the texture for drawing as it would require a
valid texture.

Multithreading is used to load the texture from disk
as soon as possible in a threaded way. It is still
blocking, but it is much faster (depending on
hardware).

Before (5.7s):
After (2.5s):

On Linux workstation: 2.28x speedup in texture loading
On M1 Backbook pro: 2.72x speedup in texture loading

This includes redraw overhead but it is not super significant.

Having a vector of all the textures to be loaded
will eventually be helpful in making the
texture uploading multi-threaded. Currently, it is
a bit difficult given the need of a valid GPUContext
per thread.

- [x] Bypass deffered loading on animated textures
- [x] Add throttling to only load a few textures per frame
- [x] Do not delay for viewport render

Pull Request: https://projects.blender.org/blender/blender/pulls/139644
2025-06-03 16:57:27 +02:00
YimingWu
57d94f5902 Fix #139019: Grease Pencil: Support converting materials from Curve
Legacy curves can carry material information, and the fill material is
especially useful for grease pencil. This patch converts base color of
materials from legacy curves when converting to grease pencil.

Limitations:
- This patch does not take nodes material into account.
- Neither legacy curves nor grease pencil supports per-stroke fill
  attribute yet, thus the converted grease pencil will be shown as
  either all fills or all strokes, depends on the configuration in the
  original legacy curve object.

Pull Request: https://projects.blender.org/blender/blender/pulls/139212
2025-06-03 16:34:32 +02:00
YimingWu
f436f67663 Fix #139773: Grease Pencil: Copy vgroup names when converting from mesh
Apparently the vertex group list were missing when converting meshes to
grease pencil while all the attributes seems to be transferring just
fine. This is because of a missing `BKE_defgroup_copy_list` call. Now
all vertex group names show up correctly in the list after conversion.

Pull Request: https://projects.blender.org/blender/blender/pulls/139786
2025-06-03 16:34:14 +02:00
YimingWu
308292b5d7 Fix #139550: Modeling: Add error message for invalid mesh data transfer
"Transfer Mesh Data" operator only works on meshes, however it's `poll`
call doesn't do complete checks for all selected objects because that
would be too slow. Now we add an error message when invalid objects are
encountered during data transfer (e.g. target object type is not mesh)
it will give a report to notify users that some errors have occured. So
there will be less confusion.

Pull Request: https://projects.blender.org/blender/blender/pulls/139568
2025-06-03 16:33:58 +02:00
YimingWu
0f1ccdd167 Fix #139274: Grease Pencil: Update vertex color overlay value
In Geometry Nodes workspace, the viewport has a default value of 0.0
for `gpencil_vertex_paint_opacity`, this causes material preview to not
show proper vertex color even when strokes have color. Considering this
property is a bit obscure, setting a default value of 1.0 here makes
sense and it's also consistent with the rest of the viewport editors in
other workspaces.

Pull Request: https://projects.blender.org/blender/blender/pulls/139356
2025-06-03 16:33:06 +02:00
Hans Goudey
72d48c53bf Cleanup: Move more draw cache functions to C++ namespace 2025-06-03 10:15:23 -04:00
Hans Goudey
c62b5929a7 Fix #139750: Crash in structure type inferencing with missing data-block
Socket declarations can be null in this case.
2025-06-03 10:08:22 -04:00
YimingWu
0ed1429fd3 Fix #139776: Grease Pencil: Prevent fillet on empty curves
`blender::geometry::fillet_curves` should check for situations where empty
curves are passed in (this could happen in geometry nodes) and in those
cases it should not run.

Pull Request: https://projects.blender.org/blender/blender/pulls/139787
2025-06-03 16:08:03 +02:00
Miguel Pozo
8907567a00 Fix: OpenGL: Hang when subprocess crashes
If the compilation subprocess crashes due to an internal driver error,
the end semaphore is never signaled and leaves Blender hanging.

This replaces the `decrement` calls with `try_decrement` and checks
every second if the subprocess is lost.

Additionally, if the issue comes from a broken binary, the crashes will
happen every time a Blender session tries to load it.
So now we store the shader hash in the shared memory before trying to
load the binary. If the subprocess is lost mid compilation, the main
process will delete the broken cached binary.

Pull Request: https://projects.blender.org/blender/blender/pulls/139747
2025-06-03 15:37:21 +02:00
Falk David
73dc112a94 Cleanup: Use CurvesGeometry::is_empty()
Instead of testing the number of points/curves against 0,
use the `is_empty()` function.
2025-06-03 15:00:23 +02:00