Commit Graph

120256 Commits

Author SHA1 Message Date
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
Christoph Lendenfeld
93675ac740 Cleanup: Comment code style
No functional changes
Just adding dots at the end
2025-06-03 14:42:06 +02:00
Christoph Lendenfeld
ace1d81242 Fix: Crash when starting asset preview screenshot in the header
The issue was that when the first point was in the header,
`ED_area_find_under_cursor` would return a `nullptr` leading to
a crash in that if statement.

Pull Request: https://projects.blender.org/blender/blender/pulls/139778
2025-06-03 14:39:43 +02:00
Pratik Borhade
6fe4496f4c Fix #125944: Outliner: Child objects missing when linked to other collection
Objects inside `lc.collection->gobject / te_parent->subtree` are not
order according to ob-parent heirarchy. Due to this, some child
object tree elements are iterated before the parent inside
`make_object_parent_hierarchy_collections` while building the hierarchy.
This ignores the case for objects when they are in the different
collection (lets say "Collection2"), see `if(!found)`. To fix this,
store ordered list of object hierarchy in a Vector `ordered_objects`.
This way, the parent element is first added to collection2.
Then while iterating its child, `parent_ob_tree_elements` has more than
one elements (i.e. possible to add child object inside Collection2)

Also resolves #100393
Steps to Reproduce: Just open the .blend from above report

Alternative for !136872

Pull Request: https://projects.blender.org/blender/blender/pulls/136971
2025-06-03 14:11:05 +02:00
Dhiraputta Pathama Tengara
cf34e9e75f Fix #139648: Crash when capturing screenshot preview with selection over window edges
Previously, dragging the screenshot selection area beyond Blender's
window borders would cause a crash. This PR addresses that issue by:
- Clamping the selection area to valid window bounds
- Displaying an "Invalid screenshot area" error when the selection is invalid

Pull Request: https://projects.blender.org/blender/blender/pulls/139680
2025-06-03 13:37:37 +02:00
Omar Emara
fb03217c5d Fix: Cryptomatte pick layer is wrongly displayed sometime
The Cryptomatte pick layer in the compositor is wrongly displayed due to
color management getting applied even though it is non color data. This
is because the non color meta-data member of viewer images was not set
if it was newels created. To fix this, we make sure it gets set in all
code paths for the viewer.
2025-06-03 13:32:43 +03:00
Omar Emara
7ccdee4d15 Fix #138533: Cryptomatte node fails for animated images
The Cryptomatte node fails to work for some animated images in certain
cases. That's because the auto refresh frame mechanism is not reliable.
To fix this, we use the context's frame to get Cryptomatte layers.
2025-06-03 13:30:30 +03:00
Marc Hamamji
9c33e27394 Fix #139449: Show gizmos in viewport when selecting gizmo nodes
When selecting gizmo nodes using box selection, circle selection, or
lasso selection, the gizmos don't show in the viewport.

This is fixed by notifying that the gizmo nodes have been updated to
redraw the gizmos using `WM_event_add_notifier`.

Pull Request: https://projects.blender.org/blender/blender/pulls/139728
2025-06-03 12:00:45 +02:00
Jeroen Bakker
e91e8eef41 Refactor: Vulkan: Use VKDevice& in finalize_pipeline_layout
!139630 requires the VKDevice to access the device function pointers.
2025-06-03 10:49:14 +02:00
Jeroen Bakker
3a875b2910 Vulkan: Don't run tests on unsupported platforms 2025-06-03 10:43:36 +02:00
Jeroen Bakker
9bbcbd06e8 Vulkan: Allow NVIDIA layers
Fixes a typo, NVIDIA layers use an abbreviation nowadays.
2025-06-03 10:07:19 +02:00
Jeroen Bakker
b416152cb9 Vulkan: Only load layers that we trust
This PR changes loading of implicit vulkan layers. See #139543 where we
detected that there are vulkan layers installed on systems that try to
impersonate other software, but crashes when used in Blender.
2025-06-03 08:37:48 +02:00
Campbell Barton
4aa6d778c9 Fix crash de-selecting UV edge loops in edge-selection mode
Error in [0] which missed checking edges have a loop.

[0]: 509b39f90e
2025-06-03 05:32:30 +00:00
Hans Goudey
2fa969e8f1 EEVEE: Use simpler hash for ObjectKey
Use the C++ "get_default_hash" instead of the C GHash functions. These
are inlined and also simpler, which is typically good for our open-
addessing hash tables. In a few scenes with many objects/instances,
I observed a 2% improvement in playback FPS.

Also the less than operator was unused. I figured this was probably
used in a `std::map` or another container that required the operator
at some point.

Pull Request: https://projects.blender.org/blender/blender/pulls/139744
2025-06-03 04:01:16 +02:00
Campbell Barton
a8593a7132 Cleanup: remove redundant checks for UV data layers 2025-06-03 10:43:49 +10:00
Campbell Barton
a4bc35f175 UV: select similar faces now skips meshes without a selection
Apply optimizeation from vertex/edge modes to face mode.
Also note why this is done.
2025-06-03 10:18:02 +10:00
Campbell Barton
87fb14fc42 Cleanup: spelling in comments (make check_spelling_*)
Also use doxgen doc-strings.
2025-06-03 10:01:38 +10:00
Sean Kim
440c6c8b6f Fix #138662: Image Editor View and Mask modes show UVs
With 24d08e0bae, the ability to view UVs
in the Image Editor was introduced in all modes, not just Texture Paint
and Edit Mode. This introduced a new flag that was enabled by default,
causing UVs to be displayed in any of the Image Editor modes.

While this is helpful for some workflows, it is unnecessarily
distracting for many usecases when using the Image and Mask modes of the
Image Editor. To remedy this, this PR adds various polls to ensure
that these are only shown in the Paint Mode of the Image Editor and the
UV Editor. Further thought should be put into the potential separation
between the different usecases of this editor, but that is out of scope
for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/139563
2025-06-02 23:42:01 +02:00
Hans Goudey
77b14f2dcb Cleanup: Grammar: Fallback vs. fall back
The former is a noun or adjective, the latter is a verb.
2025-06-02 17:13:56 -04:00
Hans Goudey
166bfb3811 Fix #138175: EEVEE crash with multiple materials in sculpt mode multires
`BKE_id_material_used_with_fallback_eval` doesn't account for the case
the evaluated mesh is empty and `SubdivCCG` is used for drawing instead,
which only happens for workbench/EEVEE in sculpt mode. Instead of
further complicating the logic, change the multires modifier to produce
a copy of the input mesh with the SubdivCCG attached, rather than that
mesh being empty. This makes things like detecting the max material
index work "for free."

Pull Request: https://projects.blender.org/blender/blender/pulls/139742
2025-06-02 22:32:34 +02:00
Jacques Lucke
383b3fd678 Fix #139391: take dynamically added vertex groups into account in armature modifier
Previously, the armature modifier retrieved the list of available vertex group
names from the original mesh. However, that list may contain different vertex
groups then are actually on the mesh that is being deformed. This patch makes it
so that the vertex group list (`defbase`) is taken directly from the
mesh-to-deform if possible.

Pull Request: https://projects.blender.org/blender/blender/pulls/139734
2025-06-02 19:30:21 +02:00
илья _
2add72df04 Fix: Geometry Nodes: Duplicate Elements node propagates instance handles incorrectly
The old code did not take the case into account when there is a non-full selection
is passed in.

Pull Request: https://projects.blender.org/blender/blender/pulls/139556
2025-06-02 18:47:44 +02:00
Brecht Van Lommel
bb6a88b95d Shaders: Reduce default distance/scale for bump/displacement nodes
The default was too high for most scenes, now it's 1mm for bump and
1cm for displacement by default.

Pull Request: https://projects.blender.org/blender/blender/pulls/139502
2025-06-02 18:44:44 +02:00
Jacques Lucke
8fe7e62656 Refactor: Nodes: extract socket items accessor defaults
This simplifies adding more functionality to socket items accessors without
having to change all the existing accessors.

Pull Request: https://projects.blender.org/blender/blender/pulls/139714
2025-06-02 18:41:10 +02:00
Habib Gahbiche
c956145530 Compositor: implement toggle for backdrop gizmos
The new gizmo toggle controls backdrop gizmo visibility for the
compositor node editor.

The implementation is consistent with the image editor, where the gizmo
toggle has a menu with a single entry, instead of having no drop down
menu at all.

The new toggle will be set inactive when there is no node tree in a
follow up PR: https://projects.blender.org/blender/blender/pulls/139526

Pull Request: https://projects.blender.org/blender/blender/pulls/139525
2025-06-02 17:48:19 +02:00
YimingWu
48f49deaa8 Fix #139572: Grease Pencil: Support pasting strokes into multiple frames
When multi-frame editing is enabled, users would expect to be able to
paste strokes into multiple selected frames. This PR supports this by
using `retrieve_editable_drawings` instead of `get_editable_drawing_at`
to achieve such feature.

Pull Request: https://projects.blender.org/blender/blender/pulls/139573
2025-06-02 16:44:25 +02:00
Aras Pranckevicius
71897ebf95 Fix #139580: Movie proxies can be missing the last frame
Commit 611940805e changed movie proxies to use MP4 container format
instead of AVI (to support video rotation metadata), however MP4
container needs more care compared to AVI. Several parts of proxy
generation were subtly wrong before:

- AVStream.avg_frame_rate was not set, this can make the mp4 muxer
  incorrectly determine the video duration for the "moov" atom.
- AV_CODEC_FLAG_GLOBAL_HEADER (needed by mp4 more than by avi) was not
  set since the code was checking the flags on the wrong structure.
- avcodec_parameters_from_context were called at the wrong place
  (need to be called after avcodec_open2, not before it)
- avcodec_flush_buffers call before av_write_trailer was incorrect;
  the codec state should not be reset there!
- avcodec_free_context should be called after fully finishing with the
  file (i.e. after avio_close)

Pull Request: https://projects.blender.org/blender/blender/pulls/139731
2025-06-02 16:24:41 +02:00