Commit Graph

111692 Commits

Author SHA1 Message Date
Sean Kim
06aa1ce7b2 Refactor: Switch vector of PBVHVertRef in SculptBoundary for int
Part of #118145

Both int indices and PBVVertRef objects are used in multiple places
throughout the sculpt_boundary.cc code. This commit removes the
external-facing PBVHVertRef in favor of the int index to make further
refactoring of the methods that use this data easier.

Pull Request: https://projects.blender.org/blender/blender/pulls/125274
2024-07-23 23:19:41 +02:00
Harley Acheson
f6ae3bf8f3 UI: Docking Split Order Areas As Previous
Prior behavior for interactive area split would create the new area
immediately. If pulled from the top the new area would be above, while
if pulled from the bottom the new area would always be below. With
docking the split does not occur until the end, which would reverse
the area orders if the split was larger than 50%. This PR creates with
the old expected order, based on the starting position.

Pull Request: https://projects.blender.org/blender/blender/pulls/125338
2024-07-23 23:13:22 +02:00
Sean Kim
b518172ae5 Refactor: Remove SculptBoundary initial_vert field
Pull Request: https://projects.blender.org/blender/blender/pulls/125273
2024-07-23 23:05:03 +02:00
Sean Kim
6181569a21 Refactor: Replace sparse mesh-sized array with map
Currently, the SculptBounary struct initializes and stores an array of
distances from the original boundary vert. However, this data is only
actually stored and calculated for boundary vertices, every other vertex
is initialized to 0.0f.

Pull Request: https://projects.blender.org/blender/blender/pulls/125278
2024-07-23 23:03:57 +02:00
Sean Kim
338140f1e6 Fix #125157: Sculpt multires crashes on box mask and duplicated stroke
Introduced in d527e3a6bd.

The change to update PBVH normals before destroying the PBVH to fix
shading on duplicate meshes issues had the unfortunate side effect of
causing crashes for multires due to a race condition. This commit
simply avoids performing this flushing for multires to allow for
further iteration in the future instead of reverting the offending
commit entirely.

Pull Request: https://projects.blender.org/blender/blender/pulls/125268
2024-07-23 22:56:26 +02:00
Hans Goudey
7daefd730b Refactor: Sculpt: Change PBVH and PBVHNode to public classes
Part of #118145.

These days we aren't really benefiting from making PBVH an opaque type.
As we remove its responsibilities to focus it on being a BVH tree and look
to improve performance with data-oriented design, that will only become
more true.

There are some other future developments the current header structure
makes difficult:
- Storing selections of nodes with `IndexMask` for simpler iteration, etc.
- Specialization of node type for each PBVH type
- Reducing overhead of access to node data as nodes get smaller
- General C++ cleanliness and consistency

This PR moves `PBVH` to `blender::bke::pbvh::Tree` and moves `PBVHNode`
to `blender::bke::pbvh::Node`. Both are classes visible to elsewhere in Blender
but with private data fields.

The difficult part about the change is that we're in the middle of a transition
removing data from PBVH. Rather than making some data truly private I
chose to just give it the `_` suffix, since it will ideally be removed later.
Other things should be class methods or implemented as part of friend
classes. But the "fake" private status is much simpler for now and avoids
increasing the scope of this PR too much. Though that's a bit ugly, there's a
straightforward way to resolve these issues-- it just looks like the sort of
inconsistency you'd expect in the middle of a large refactor.

Pull Request: https://projects.blender.org/blender/blender/pulls/124919
2024-07-23 22:31:27 +02:00
Harley Acheson
73e519ded2 UI: When Docking Use Movement Threshold for Dupli & Swap
When docking is enabled it is currently skipping the movement threshold
when holding down shift (dupli) or ctrl (swap). This PR adds that back
by not immediately applying unless no modifiers are held.

Pull Request: https://projects.blender.org/blender/blender/pulls/125329
2024-07-23 20:06:05 +02:00
Bastien Montagne
12f3aec3eb BLO readfile: report error when reading invalid 'data' chunks.
Blendfile format expects all `BLO_CODE_DATA` bheads belonging to a same
ID 'space' to have unique identifiers (their old addresses).

When this is not the case, the blendfile is considered as corrupted.
Consequences can vary, from mere memory leaks, to catastrophic
unrecoverable crashes.

NOTE: This is what happens in file from #125001.
2024-07-23 19:42:01 +02:00
Weizhen Huang
5cbc540a64 Fix #125219: Transmissive BSDF different in Blended and Dithered mode
for transmissive closures the color is squared, but Blended square
BEFORE the weight is applied, and Dithered square AFTER the weight is
applied, causing difference in the final color.

This fix aligns the behaviour of Blended with Dithered.

NOTE that this is a partial fix, because Dithered is also behaving
incorrectly. A more proper fix would be !125233.

Pull Request: https://projects.blender.org/blender/blender/pulls/125299
2024-07-23 19:40:14 +02:00
Julian Eisel
a5970b8248 Fix #124167: Crash opening file after asset browser is closed
Switching to an asset browser, then back to a different editor would
cause a crash when loading a new file.

Basically the file/asset browser tried to free dangling asset and asset
library pointers when trying to free itself. That's because the asset
system gets destructed with a `AS_asset_libraries_exit()` call before
the screen and with that the asset browser were freed.

Pull Request: https://projects.blender.org/blender/blender/pulls/125084
2024-07-23 18:29:50 +02:00
Bastien Montagne
f69f920164 Cleanup: BKE Blendfile: Improve PartialWriteContext documentation. 2024-07-23 18:28:51 +02:00
Falk David
d5a55935ea GPv3: Python API: Add missing functions to BlendDataGreasePencilsV3
This adds the `tag`, `new`, and `remove` functions for `GreasePencil` IDs.

Pull Request: https://projects.blender.org/blender/blender/pulls/125060
2024-07-23 18:26:38 +02:00
Bastien Montagne
03652c851c Fix #122961: Get out of 3D local views when they get empty.
This commit covers the case where all objects get removed from local
view, and an undo or blendfile read leads to such empty local views.

It also adds code to remapping/foreachID View3D callbacks to tag
potential local views as 'maybe empty', and use the View3D refresh
callback to actually check and potentially exit the local empty view.

Pull Request: https://projects.blender.org/blender/blender/pulls/123128
2024-07-23 18:23:02 +02:00
Bastien Montagne
f9eaf43ae0 Refactor: Make Pose Copy code use new PartialWriteContext.
See #122061  for details about the change from deprecated `BKE_partial_write` API to the new `PartialWriteContext` one.

Pull Request: https://projects.blender.org/blender/blender/pulls/124909
2024-07-23 18:04:37 +02:00
Falk David
ccc5922ece GPv3: Add "Set Curve Resolution" operator
Set the resolution of the selected curves.

Pull Request: https://projects.blender.org/blender/blender/pulls/125235
2024-07-23 15:23:35 +02:00
Falk David
752fad886a Fix #125312: Drawings not cleared after last layer is removed
In the case where the last layer is removed and all the drawings
have zero users, in the `remove_drawings_with_no_users` function
the `find_next_swap_index` lambda would return `false` on the
first call. Both `first_unused_drawing` and `last_used_drawing`
are `0` in this case. This meant that the `drawings_to_remove`
index mask would exclude the first drawing (because
`last_used_drawing` is the index of the first drawing) and not
remove it as it should.

To fix this, we check if `first_unused_drawing` is greater than zero.
If it is not, then we know all the drawings have to be removed.
Otherwise we only remove the drawings after
`last_used_drawing + 1`.

Pull Request: https://projects.blender.org/blender/blender/pulls/125318
2024-07-23 15:22:14 +02:00
Falk David
7d54e428e4 Fix: GPv3: Crash when changing the active layer
Caused by 0a64785067.
2024-07-23 14:48:03 +02:00
Falk David
56bd0c7e4a Fix #124995: Crashes in rendering code due to invalid material indices
The issue was that some `material_index` were `-1`. This meant that
the rendering code was accessing out-of-bounds memory to read
from the material pool.

The fix adds an assert to the `gpencil_material_resources_get` and
clamps the `material_index` to >= 0 to ensure that the material is
valid. It also changes the default read value for the material indices
in `create_curves_outline` and `retrieve_visible_strokes` to be 0
instead of -1.

Pull Request: https://projects.blender.org/blender/blender/pulls/125309
2024-07-23 14:35:25 +02:00
Sybren A. Stüvel
990134af26 Anim: fix a crash showing the dopesheet with multi-slot Actions
The code to create 'key lists' (for example to go to the next/previous
key) do so by creating fake data-structures (`bDopeSheet` and
`bAnimContext`). These are zero-initialised, very few fields are set,
and then passed to the generic animation filtering function. Because of
this, `bAnimContext::bmain` was `nullptr`, which caused the crash.

Instead of fixing the real issue (major design problems in the animation
channel/filtering code), I've made the use of `bmain` optional. The
pointer is necessary to find the animated data-blocks, in order to
resolve the RNA path of F-Curves to the animated properties, which in
turn is necessary to determine the F-Curve display name. If that name is
irrelevant (for example when finding the next/previous key) the `bmain`
is not necessary. This is now handled more or less properly, at least to
the extent that the crash is prevented.

Pull Request: https://projects.blender.org/blender/blender/pulls/125300
2024-07-23 13:21:11 +02:00
Omar Emara
c7fdd46e01 Cleanup: Missing BKE compositor include 2024-07-23 14:05:41 +03:00
Pratik Borhade
ec220c17f5 GPv3: Rename active_group to active
Follow the changes in 0a64785067
and e373625e73.

Pull Request: https://projects.blender.org/blender/blender/pulls/125297
2024-07-23 12:10:53 +02:00
Jacques Lucke
cb79ef2efc Cleanup: remove unused data member 2024-07-23 11:50:50 +02:00
Jacques Lucke
8755745a84 Cleanup: add missing override keyword 2024-07-23 11:50:50 +02:00
Falk David
1e5df156f7 Fix: GPv3: Uninitialized placement_plane_ in DrawingPlacement
When using the `DrawingPlacementDepth::Stroke` or
`DrawingPlacementDepth::Surface` the placement plane was
not initialized. This leads to wrong projection values for tools
that don't support either of these depth placements.

This fixes the issue by initializing the placement plane in all
cases except for `DrawingPlacementPlane::View` which will
use the view plane.

Pull Request: https://projects.blender.org/blender/blender/pulls/125284
2024-07-23 11:50:07 +02:00
Falk David
0a64785067 GPv3: Rename active_layer to active
This is consistent with the naming in GPv2.
It also makes more sense when writing it out
in python: `grease_pencil.layers.active`.
2024-07-23 10:59:53 +02:00
Omar Emara
cf032d6893 Fix #119313: Render layers in startup file are missing
The outputs of the Render Layers node in the compositor in the startup
file are missing. That's because add-ons are disabled when loading the
startup file, so Cycles will not be registered by the time the node tree
of the compositor is loaded, and its passes will not exist.

To fix this, we mark the compositor node tree as needing an update after
loading the startup file.

Pull Request: https://projects.blender.org/blender/blender/pulls/125053
2024-07-23 10:42:17 +02:00
Omar Emara
57ff2969b8 Compositor: Support multi-pass compositing for EEVEE
This patch adds support for multi-pass compositing for EEVEE. This is
done by copying the passes used by the compositor node tree to the DRW
view data, which can then be accessed by the viewport compositor.

The viewport compositor will fallback to the viewport texture or an
invalid output of the passes were not initialized, this is currently the
case for any render engine that is not EEVEE.

A future optimization that we can do is eliminate the film pass copy
shaders and only copy the data that EEVEE rendered, which can be a
subset of the viewport for border rendering. This is not done at the
moment because not all engines support passes at the moment, so the
compositor expects full viewport passes.

Depends on: #123685, #123817, #123815.

Pull Request: https://projects.blender.org/blender/blender/pulls/123378
2024-07-23 10:15:13 +02:00
Jacques Lucke
9ec3e0d681 Spreadsheet: undo accidental icon change
This was changed as part of 4e958617a9.
While we likely want to use a different icon in the future,
it still has to be choosen or designed.
2024-07-23 10:09:10 +02:00
Sybren A. Stüvel
9155f2336b Anim: rebuild depsgraph relations when creating a new F-Curve
When a new F-Curve is created on a layered Action, tag the dependency
graph for rebuilding its relationships. This is necessary as the F-Curve
may be animating a depsgraph component that was previously not animated,
and thus that relation needs to be constructed.

This was already in place for legacy Actions, and simply overlooked for
the new layered ones.

Pull Request: https://projects.blender.org/blender/blender/pulls/125236
2024-07-23 08:10:19 +02:00
Campbell Barton
7639ec9dfd Cleanup: remove redundant theme color lookup, avoid shadowing 2024-07-23 15:58:21 +10:00
Campbell Barton
f1febee83f Cleanup: use "num" as a variable suffix 2024-07-23 15:50:05 +10:00
Jesse Yurkovich
c46679c108 Fix #125112: UI notification for exporting all collections is confusing
If a user has multiple collections for which exporters are defined, then
during File->Export All Collections, multiple UI notifications will
occur, one for each collection. This is confusing because these
notifications contain a count of how many files were exported and only
the "last" notification is shown to the user. The others are still
present in the Info editor (and terminal) but users rarely look there.

The fix changes where we post the notification report. We tally up the
number of files and collections we process and only report them as a
final step in the appropriate Operator exec functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/125206
2024-07-23 07:37:13 +02:00
Harley Acheson
2c4a611be1 Fix: Incorrect Join/Docking Possible at Min Distance
If you start an action zone drag close to the edge it is possible to
leave the source area yet be under the minimum distance. If you release
at this particular pixel distance it is possible to have an invalid
or unwanted join. This PR just assumes you have dragged enough if you
manage to leave the source area.

Pull Request: https://projects.blender.org/blender/blender/pulls/125266
2024-07-23 02:30:05 +02:00
Pratik Borhade
0fe0c04d2a Fix #125074: MEM_new/MEM_freeN mismatch in selection pick code
This is due to the pointer free mismatch.

Pull Request: https://projects.blender.org/blender/blender/pulls/125163
2024-07-23 00:16:57 +02:00
Omar Emara
9f61ef74e7 EEVEE: Move Cryptomatte normalization to film shader
This patch moves the Cryptomatte weights normalization from The
Cryptomatte sorting shader to the film shader.

This is needed to support multi-pass viewport compositing because up
until now, Cryptomatte passes were only sorted and normalized for final
rendering after all samples were accumulated. So it assumed no further
accumulation of samples would take place. But for compositing, we need
to sort and normalize them for every sample, and applying normalization
multiple times will produce wrong results.

Needed by #123378.

Pull Request: https://projects.blender.org/blender/blender/pulls/123685
2024-07-22 21:14:03 +02:00
Omar Emara
aca7670569 Fix #125069: Texture properties missing
The Texture Properties tab is missing even if it is used in the
compositor. To fix this, we add a texture space user for texture nodes
in the compositor node tree.

Pull Request: https://projects.blender.org/blender/blender/pulls/125081
2024-07-22 20:23:50 +02:00
Jacques Lucke
4e958617a9 Spreadsheet: store original object pointer to access selection
This originally comes from #124186 and is necessary when the spreadsheet
can show data from instances.
2024-07-22 20:13:57 +02:00
Jacques Lucke
b69e6535d0 Spreadsheet: use fallback name when geometry has no name
We had this before, but it was accidentally removed.
2024-07-22 20:10:19 +02:00
Miguel Pozo
6d302ca7ca Fix #125134 #124971: EEVEE: Overlapping samplers in World shader 2024-07-22 18:31:43 +02:00
Jacques Lucke
9974ee71bd Spreadsheet: refactor data set drawing
This separates a single `GeometryDataSetTreeViewItem` into separate tree view
items for the individual parts of the tree view. While requiring a bit more boilerplate
overall, this simplifies the code quite a bit and makes it more extensible.

Pull Request: https://projects.blender.org/blender/blender/pulls/125239
2024-07-22 18:30:00 +02:00
Falk David
fc49a5928b Fix: GPv3: Duplicate previous key using auto key
When erasing, sculpting or tinting, the previous key was not being
duplicated.

The `ed::greasepencil::ensure_active_keyframe` didn't have a good
mechanism to make this work. This adds a parameter to the
`ensure_active_keyframe` function so that the caller can decide
what should be done.

For the sculpting tools, eraser, and tint tool, this will now duplicate
the previous key, when auto-key is on.

Resolves #124082.

Pull Request: https://projects.blender.org/blender/blender/pulls/125224
2024-07-22 18:09:17 +02:00
Falk David
d0ff8d89c9 Fix: GPv3: Use correct temporary eraser size
When holding CTRL using the draw tool to erase, the size of the cursor
was using the size of the eraser brush. This is not the expected behavior
when using the eraser from the draw tool. It should respect the size
of the brush used by the draw tool instead.

This fixes the issue by computing the right size when the eraser operation
is invoked. The size is then stored in a runtime field, so that the cursor
rendering callback can use the cached size.

Pull Request: https://projects.blender.org/blender/blender/pulls/125225
2024-07-22 18:08:51 +02:00
Julian Eisel
a1ac565315 Cleanup: Improve comments for UI related property flags
Previous comments were rather vague and misleading even. For example it
is often expected that `PROP_HIDDEN` would hide properties in the keymap
editor, which it wouldn't. The term "ghost" value was not defined thus
useless as documentation. Explained the behavior instead.

Also the "Inherits #PROP_SKIP_PRESET" note added in 0d7282e69b was
confusing, what does it mean to inherit a property? Clarified that too.

Lastly the API description of `WM_operator_properties_reset()` was not
updated for 1058006e03. Fixed now.
2024-07-22 17:53:25 +02:00
Julian Eisel
f5b46a66d1 Cleanup: Fix typo in comment 2024-07-22 17:49:56 +02:00
Philipp Oeser
b25e67189c Fix #125228: Image Editor Memory leaks showing image tooltip thumbnail
Looks like a simple oversight in 8937c0bcab

To resolve, just free the `ImBuf` (same as done in other places that use
`uiTooltipImage`)

Pull Request: https://projects.blender.org/blender/blender/pulls/125231
2024-07-22 17:37:43 +02:00
Miguel Pozo
f2c728468c Cleanup: Fix warnings 2024-07-22 16:55:25 +02:00
Sean Kim
07c613b485 Cleanup: Adjust GSpan and GArray asserts
Previously, 4e9e44ad made changes to allow GSpan and GMutableSpan to not
have a type when they are empty. This mirrors the same change in the
conversion from GArray to both span types and when converting to an
actual typed Span<> or MutableSpan<> via typed().

Fixes #125013

Pull Request: https://projects.blender.org/blender/blender/pulls/125018
2024-07-22 16:35:36 +02:00
Falk David
27c877f684 Fix: GPv3: Use of legacy object type in shaderfx_add 2024-07-22 16:29:19 +02:00
Falk David
ead43b6693 Fix: GPv3: Copy ShaderFX/Materials to selected
The operator was checking for the legacy object type.
2024-07-22 16:29:19 +02:00
Sebastian Parborg
b61d308d76 Fix: The position of the redo panel was inconsistent
If the redo panel wasn't initalized from scratch, it would not get the
scrollbar offset. Now always apply this runtime offset.

Pull Request: https://projects.blender.org/blender/blender/pulls/125092
2024-07-22 16:09:44 +02:00