Commit Graph

114099 Commits

Author SHA1 Message Date
Jacques Lucke
917f7e648c Fix #130180: non-screen space dial gizmo scale does not take geometry scale into account
We can't scale the dial gizmo non-uniformly. Therefore, the average of the x/y/z scale
is used to determine the scale of the gizmo.

Pull Request: https://projects.blender.org/blender/blender/pulls/130183
2024-11-12 22:45:51 +01:00
Bastien Montagne
0565f16f18 Fix (unreported) rare assert when loading blendfile using libraries.
There is actually a valid (rare) case where a Library ID can have a `0`
versionfile value during blendfile loading: if that library only
contains 'indirect weak' linked data.

These IDs are only actually read in the library blendfile if they are
also used by some other data, otherwise they are purposedly dropped and
removed, and the library blendfile can end up never being read at all.

This would lead to a completely empty library on blendfile loading,
which can then be removed from the data-base.

NOTE: this _does not_ affect cases where the whole library is missing,
or some linked IDs from that library are not found anymore.
2024-11-12 19:59:32 +01:00
Julian Eisel
a0b2704202 Fix #128138: No paint curves selectable for brush strokes
The data-block selector filters out local data-blocks when trying to
assign to linked data. A lot of data-block management relies on this.

Since these data-blocks are created for the use with brushes only,
create them under the same library that the brush is from, as indirect
data. The UI allows selecting these data-blocks then. We do the same for
textures attached to a brush, and some other data-block types.

Also add paint-curves to the editable data-block types, so they can be
edited despite being considered linked data.

Pull Request: https://projects.blender.org/blender/blender/pulls/130184
2024-11-12 19:13:24 +01:00
Pratik Borhade
9a4ce4a0f7 Fix #128749: GPv3: Dopesheet Move channel to top reverses layer order
The operator to move a channel to the top revered the layer order
by iterating from the top to the bottom and moving selected channels
to the top. Iterate from the bottom to the top instead to keep the right
layer ordering.

Pull Request: https://projects.blender.org/blender/blender/pulls/128793
2024-11-12 18:56:12 +01:00
YimingWu
2e82f95237 Fix: LineArt: Cache mechanism fixes
The cache mechanism for line art is changed during migration to GPv3,
however the code path failed to handle following cases which could lead
to a few problems:

- Line art cache isn't deleted after last line art modifier because it
  coule be hidden, causing memory leaks.
- A modifier inside a multiple line art modifier sequence that doesn't
  use cache would prematurely delete line art cache, causing subsequent
  line art modifier to give empty result.
- When the first line art modifier is hidden (in viewport/render), the
  cache is not created correctly, leading to crashes.

Now the new code logic addresses these problems properly by:

- Making sure the last visible line art modifier deletes cache.
- Giving a fresh cache pointer for modifiers that doesn't use global
  cache.
- Line art cache is correctly ensured when there are modifiers that
  are hidden

Pull Request: https://projects.blender.org/blender/blender/pulls/129953
2024-11-12 18:51:45 +01:00
Julian Eisel
f66b3eeae9 Fix #128774: Setting brush from Properties doesn't change active tool
We need to be careful about not just looking up active tool data from
context, because this code path may also be run from the Properties,
which use the tools of the 3D view. So make sure related code falls back
to the 3D view, like it's already done in some other places.
2024-11-12 18:03:17 +01:00
Richard Antalik
ebe209b8ec Fix #126461: Scene sound does not play
Caused by removing scene sound from "main scene" when other strip using
the same scene is not rendering sequencer strips.

Only remove sound when all strips using particular scene are not
rendering sequencer strips.

Pull Request: https://projects.blender.org/blender/blender/pulls/129768
2024-11-12 17:28:20 +01:00
Falk David
5ecec47280 Fix #130176: GPv3: Fill tool doesn't write to fill_opacity.
The fill tool didn't write to the `fill_opacity` attribute leading
to non-filled strokes in some cases.

This makes sure that the attribute is created with full opacities.

Pull Request: https://projects.blender.org/blender/blender/pulls/130177
2024-11-12 17:26:47 +01:00
Casey Bianco-Davis
155c21d774 Fix: GPv3: Primitive Tool: Control point misalignments when object or layer is moved.
The problem was that the control point positions where not accounting
for the grease pencil objects transform nor the layer transformation.

Pull Request: https://projects.blender.org/blender/blender/pulls/130005
2024-11-12 17:19:43 +01:00
Bastien Montagne
0b3a7cbe69 Cleanup: Move BKE_image.h and related headers to C++.
NOTE: This also required some changes to Cycles code itself, who is now
directly including `BKE_image.hh` instead of declaring a few prototypes
of these functions in its `blender/utils.h` header (due to C++ functions
names mangling, this was not working anymore).

Pull Request: https://projects.blender.org/blender/blender/pulls/130174
2024-11-12 16:53:54 +01:00
Laurynas Duburas
f9d89a0dfb Fix: Prevent bezier handle attribute creation on transform
Prevents Bezier handle attribute creation on transform for
`CurvesGeometry` instances without Bezier curves.

Pull Request: https://projects.blender.org/blender/blender/pulls/130165
2024-11-12 16:51:54 +01:00
Falk David
0a27b3d6ba Fix: GPv3: Fill tool doesn't have a paint cursor
Reverts part of 0872e898bc.
In 4.2, the fill tool had a small paint cursor that could
be turned off using the "Display Cursor" setting.

This makes it so that the cursor for the fill tool behaves
the same as in 4.2.
2024-11-12 16:16:42 +01:00
Clément Foucault
e3a960ef2e Fix #129889: EEVEE: Lightprobe Volume bake is non-deterministic
Turns out the sampling module was not initialized when
computing lighting which resulted in undefined shadow location.
In some cases even producing NaN position which would make the
shadow disappear.

Basically, anything returned by `sampling_rng_nD_get` was returning
garbage, and on some occasion, it could be a negative number and
produce NaN if passed into `sample_disk` or any `sqrt`.

ASAN did not catch it because the uninitialized data load
was done on the GPU.

I ran the render tests and, minor difference aside, they all match.

#### Follow Up:
This raises the concern that we have no assertion for correctly
using some modules. At the very least, we should have some
mechanism to catch uninitialized buffer. Investigating this
was a pain au chocolat.

Pull Request: https://projects.blender.org/blender/blender/pulls/130150
2024-11-12 15:29:17 +01:00
Falk David
43fde8c39c Fix: #130045: Crash in length modifier with 2 point curves
The length modifier was not handling 2 point curves correctly.

This change does two things:
1) Fix the crash by copying the original indices for 2 point curves into `dst_to_src_point`.
2) Fallback to `extend_curves_straight` for extending 2 point curves.

Pull Request: https://projects.blender.org/blender/blender/pulls/130122
2024-11-12 15:11:59 +01:00
Pratik Borhade
22d94df4cf Fix: GPv3: "Only In Multiframe" overlay not working
There were some issues in the code that sets up the draw calls.
The `only_lines` option needs to consider multi frame editing.

Resolves #129873.

Pull Request: https://projects.blender.org/blender/blender/pulls/129944
2024-11-12 14:44:31 +01:00
Omar Emara
a0cfb0b142 Fix #130134: Double Edge Mask uses too much memory
The Double Edge Mask node uses too much memory when it is not connected
to anything in the Full-Frame compositor. That's because it tries to
allocate a buffer of size 131072x131072, which is due to the cumulation
of multiple issues.

1. The Full-Frame compositor evaluates nodes that are not connected to
   the output.
2. The constant folder assigns a bounds of +-65536 to its output memory
   buffers as a maximum possible value.
3. Then the MemoryBuffer::inflate method doesn't know about the constant
   folder special value, so it tries to allocate a buffer of that size.

The safest fix for now is to clear the output and return early if all
inputs are single value.

The problem is that this issue might happen for other nodes that also
satisfy the 3 issues above, that is, uses inflate and can be constant
folded. I manually checked for such nodes and there are no nodes that
satisfy all three, so hopefully this is isolated to the Double Edge Mask
node.

Pull Request: https://projects.blender.org/blender/blender/pulls/130163
2024-11-12 12:53:23 +01:00
Pratik Borhade
4e907829d3 Fix #128099: Outliner isolate collection tweaks linked data
Mistake in e494a44024
Even though collection/object PointerRNA argument is same in most cases,
use `layer_or_collection_prop` in if() before assigning value to
collection property (`base_or_object_prop`argument value is  null in function
call from `_isolate_flag()`).

Pull Request: https://projects.blender.org/blender/blender/pulls/129250
2024-11-12 12:07:59 +01:00
Falk David
32c76ee768 Fix: GPv3: Unused parameter in remove_from_vertex_group
Caused by 5585d29d30.
Forgot to remove the parameter.
2024-11-12 11:56:59 +01:00
Pratik Borhade
5585d29d30 Fix: GPv3: Vertex group functions edit all keyframes
Instead of looping through all drawings in the vertex group kernel
function, loop through all/visible drawings in the operators and
pass a single drawing to `remove_from_vertex_group`.

Continuing !129789.

Co-authored-by: Falk David <falk@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/129890
2024-11-12 10:44:59 +01:00
Sybren A. Stüvel
ae5717905b Fix #130090: Grease Pencil object in NLA cause Blender to crash
Add some missing `nullptr` and `ale->type` checks to ensure the
assmptions the rest of the code makes holds.

The direct cause of this issue is likely
822907a68d. The root cause is the hard to
predict behaviour of the animation filtering system combined with a lot
of pointer casts without testing whether the data is actually of the
expected type.

Pull Request: https://projects.blender.org/blender/blender/pulls/130148
2024-11-12 10:19:27 +01:00
Pratik Borhade
1d14390f99 Fix #129297: Gizmo missing for unlocked layer when autolock inactive is on
`set_active_node` call from `grease_pencil_copy_data` resets inactive
layer again as locked before executing the drawing code. Since property
is only operated on layers, it is possible to remove the code from
`set_active_node()` and only have it in `set_active_layer()`.

Pull Request: https://projects.blender.org/blender/blender/pulls/129465
2024-11-12 09:09:28 +05:30
Sean Kim
009fb327ee Fix #130101: Boundary brush radius uses incorrect initial value
Introduced in 99c55bdbfb

Pull Request: https://projects.blender.org/blender/blender/pulls/130154
2024-11-11 20:02:36 +01:00
Lukas Tönne
1158130995 Fix #129324: Merge Down operator always appends merged layers at the end
The Merge-Down operator for layers was inserting existing layers first,
then appending the 2 merged layers at the end (top of stack).

Now merged layers are inserted at the position of the layer below the
active, so the layer order remains unchanged.

Note that merging a layer group has a similar issue, with the new
layers getting appended at the top. This is a bit more difficult because
looping only over layers drops the relative ordering of groups and
layers. A separate fix is needed for that.

Pull Request: https://projects.blender.org/blender/blender/pulls/130146
2024-11-11 18:42:10 +01:00
Jacques Lucke
0d6d54d565 Fix: don't show Geometry Nodes modifier gizmos for unselected objects
It's unexpected that the gizmos show for unselected objects.

Pull Request: https://projects.blender.org/blender/blender/pulls/130144
2024-11-11 18:20:46 +01:00
Falk David
0d1d3d12ba Fix: GPv3: Inconsistent behavior when adding a layer group
When a layer group was active, new groups would be created at
the top of the layer tree which is inconsistent with how layers are
added.

This fixes the behavior. When a group is active, newly added groups
are moved into that group.
2024-11-11 18:18:47 +01:00
Falk David
753e6952b9 Fix: GPv3: Inconsistent behavior when updating the active node after removal
The code that was updating the active node after removing a layer/group
was not handling all cases correctly.

The fix updates the logic for setting the active node:
1. If the node is a non-empty group and we're keeping the children, then set
the active node to the top node in the group.
2. Otherwise, if the node has a node below it (in the same group), set it to be the active one.
3. Otherwise, if the node has a node above it (in the same group), set it to be the active one.
4. Otherwise, if the parent is not the root group, set the parent to be the active node.
5. Otherwise, clear the active node.

This behaves the same as in Krita.

Pull Request: https://projects.blender.org/blender/blender/pulls/130126
2024-11-11 18:18:24 +01:00
Pratik Borhade
9a59372f07 Fix #130034: GPv3: Deleting root layer group leads to crash
The code was relying on the layer cache through `groups_for_write`/`layers_for_write`.
The `group->runtime->layer_group_cache_` stores all the child groups instead
of groups on first level. This leads to crash when recursively deleting
group i.e. group at third level has been deleted but `layer_group_cache_`
of first level group will still point to address of freed memory.

The fix removes the use of the cache and iterates over the direct
children in `group.children` and deletes them recursively.

Pull Request: https://projects.blender.org/blender/blender/pulls/130082
2024-11-11 17:54:59 +01:00
Germano Cavalcante
61f503a197 Fix: error in previous commit 2024-11-11 13:41:58 -03:00
Germano Cavalcante
fe37ede725 Fix: warning due to b4154c
No parentheses around comparison in operand of ‘==’ [-Wparentheses]
2024-11-11 13:34:59 -03:00
Hans Goudey
dd651ef5d6 Fix #130086: Weight/vertex paint non-deform modifiers wrong positions
The PBVH vertex positions accessor functions have to match the logic in
`sculpt_update_object`. When there were topology changing modifiers
before deform modifiers it didn't. `BKE_crazyspace_build_sculpt` just
skips the topology changing modifiers, and the resulting positions
are stored in `ss.deform_cos`, which we need to access here.

Pull Request: https://projects.blender.org/blender/blender/pulls/130139
2024-11-11 17:24:13 +01:00
Lukas Tönne
9fb185d31d Fix #130066: Crash after joining Grease Pencil objects
The Join operator for Grease Pencil was making a shallow copy of the drawings
array, with the assumption that the source object would no longer be needed.
This is not the case, the source object is still in the blend data and still
shares the same drawings pointer as the target object. This is invalid, the
drawings should owned by one object.

To fix this the patch makes a deep copy of the drawings so the source and target
have their own sets of drawings. Data is still shared at the CustomData level,
so these copies are not very expensive.

Pull Request: https://projects.blender.org/blender/blender/pulls/130140
2024-11-11 17:10:26 +01:00
Hans Goudey
e88ac07046 Fix #130098: Sculpt sample detail operator crash on failure
Check the error status from the function that updates the active vertex.
Also add `PROP_HIDDEN` to the operator's properties so the redo panel
doesn't show; that seemed extra weird to display on failure.

Pull Request: https://projects.blender.org/blender/blender/pulls/130142
2024-11-11 17:06:22 +01:00
YimingWu
37ec4b5430 Fix #129883: GPv3: Build modifier frame timing is not correct
When the duration of a frame is shorter than the build time specified in
the modifier, build modifier should shorten the build time to allow the
frame to be fully built within the frame duration. This fix made the
timing behaviour the same as GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/129894
2024-11-11 16:53:39 +01:00
Bastien Montagne
69a7948575 Doc: Py API: Add more info about UNDO operator option.
Essentially, any operator modifying Blender data should enable this
`UNDO` option, else bad things (corruption, crashes...) are likely to
happen.

* Added a new Operator example to explain this topic.
* Updated some existing Operator examples that were not correct anymore.
* Added a new small section in the gotchas page linking to it.
* Added also short reminder about this in the `UNDO` 'tooltip'
  description itself.

Related to #77557.
2024-11-11 16:13:37 +01:00
Bastien Montagne
ac75e37c8e Fix #130113: Copying Object ID never copies its preview.
This was added 7 years ago as 'safe' preservation of previous behavior,
when ID copying was refactored and more control was added over its
behavior.

However, it was never removed since then, even though `NO_PREVIEW` flag
has been part of the `LOCALIZE` copying behavior since many years.

So time to remove this enforced bahevior and use the API as designed. If
this causes new issues, they will have to be fixed in code calling the
ID copy API (most likely by simply adding the `NO_PREVIEW` flag to the
copy options).
2024-11-11 16:13:37 +01:00
Hans Goudey
7f75690127 Fix #130102: Boundary brushes ignore masking with Multires
Also fixes #130100.

Mistake in 1618448abd.
2024-11-11 09:13:45 -05:00
Germano Cavalcante
b4154c6a0e Fix #130078: Snap to Grid ignored if occluded in Add Object Tool
The snap cursor internally snaps to the Face to define the occlusion of
the Grid or to calculate the "Surface" orientation set by the tool.

Even though this is not the snap point enabled by the user, this
internal Snap to Face takes precedence over the Snap to Grid that is
enabled by the user.

To solve this, the solution is to do a second snap test but now only to
Grid and using the hit point as a reference for the closest grid.

Also fixes Absolute Increment Snap not being detected as Grid by the
tool.

Pull Request: https://projects.blender.org/blender/blender/pulls/130092
2024-11-11 14:26:52 +01:00
Lukas Tönne
72fd267024 Fix #130110: Fill tool crashes when extension lines are enabled
This was caused by ba28469e, which subtracted the start of the
offsets array, so it can't be used for "max array size" any more.
Use the "last()" entry directly to correctly size the view
positions array.

Pull Request: https://projects.blender.org/blender/blender/pulls/130127
2024-11-11 14:25:08 +01:00
Falk David
4ba7950c2c Fix: GPv3: Memory leak with empty drawings array
The `BKE_grease_pencil_duplicate_drawing_array` function
would allocate memory for an empty array. This can be avoided.
2024-11-11 14:12:07 +01:00
Pratik Borhade
68ddaa2f0a Fix #128930: Cancel resize area with Right mouse
Add RMB switch case in modal fn() to cancel area resize operation.

Pull Request: https://projects.blender.org/blender/blender/pulls/129100
2024-11-11 12:48:13 +01:00
YimingWu
b8eb80c1fd Fix #130110: GPv3: Fill tool respect legacy radius factor
After applying fill tool, the `LEGACY_RADIUS_CONVERSION_FACTOR` was not
multiplied back so the value in the brush settings panel will become
smaller and smaller for each execution of the tool. Now fixed.

Pull Request: https://projects.blender.org/blender/blender/pulls/130120
2024-11-11 12:43:36 +01:00
Alaska
442498d53c Fix #130076: Make Grease Pencil Select Similar a callable menu
Use `WM_menu_invoke` callback to invoke menu for
"select similar" operator shortcut

Pull Request: https://projects.blender.org/blender/blender/pulls/130081
2024-11-11 12:41:55 +01:00
Falk David
7f983ae5e2 Fix #130089: GPv3: Don't use default mouse cursor if paint cursor is disabled.
The default mouse cursor would show if the user disabled the paint cursor.
This is not ideal, because the default cursor is pretty big and gets in the way,
especially for tablet users.

The fix sets the cursor to `DOT` (which is very small) when the
"Show Paint Cursor" option is disabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/130118
2024-11-11 12:17:50 +01:00
Pratik Borhade
83396c86fc Fix #130084: GPv3: Disable overlay does not work in sculpt mode
The cache population call was missing the "hide overlay" check.

Pull Request: https://projects.blender.org/blender/blender/pulls/130109
2024-11-11 12:08:13 +01:00
Bastien Montagne
5caa74ebf3 Fix (unreported) mistake in code, leading to invalid memory access. 2024-11-11 11:43:47 +01:00
Clément Foucault
dafa3fb88f Fix #129019: Crash when switching from EEVEE to Cycles while rendering animation
When changing render engine, we discard the persistent data
that could be saved for all the current render instance that
exists. This is to save memory for the new renderer.

When doing so while rendering for F12, `engine_depsgraph_free`
is called after waiting for the render to finish. But this
can be called before the renderer destruction and on the main
thread.

Doing so on the main thread means that the `gpu_context` used
by the renderer cannot be bound for the sake of just receiving
the orphan buffers that the depsgraph holds. This is because
only the worker thread can make the gpu context active.

Binding the draw gpu context in this situation avoid all
possible conflict.

This is basically doing exactly what the
`DRW_render_context_enable/disable` function is doing internally
if the render engine gpu context is null.

Pull Request: https://projects.blender.org/blender/blender/pulls/129982
2024-11-11 11:29:54 +01:00
Falk David
01db47b82c Fix #129766: GPv3: Fallback to "frames" mode in build modifier for natural drawing speed
The issue was that if the `delta_time` attribute didn't exist, the drawing
would appear immediatley.
In case we don't have any drawing speed information, the fix
makes it so that we fallback to use the number of frames
to build the strokes.

Pull Request: https://projects.blender.org/blender/blender/pulls/130035
2024-11-11 10:39:23 +01:00
Lukasz Czyz
9b3108462f Fix #129925: SLIM UV unwrap with holes
Assignments to UnwrapOptions overwrote the values set by
unwrap_options_get().

Ref: !130041
2024-11-10 14:45:18 +11:00
Jesse Yurkovich
f0e2d7e5ca Fix #107696: Use correct API when importing USD mesh vertex normals
This seems like a long-standing misuse of the custom vert normal APIs.
It broke, obviously so, in 3.1 but 3.0 was also rather fragile as was
noted in the original bug report.

The `BKE_mesh_set_custom_normals_from_verts` should be the correct API
to use when loading in vert normals from external files. The current
code would yield faceted mesh shading, as-if there were no custom
normals at all.

Pull Request: https://projects.blender.org/blender/blender/pulls/130069
2024-11-09 22:18:31 +01:00
John Kiril Swenson
8bbe0bc838 Fix #129947: VSE: B to box-select on strips
d2a802d3c6 got overzealous by removing the "tweak" property which was
actually necessary to differentiate box select on click-drag vs. box
select on B. Fix by restoring the tweak property for everything but
preview keymap items (where it doesn't actually do anything).

Main reason this happened is because the original description was a bit
too cryptic, so update it to be clearer.

Pull Request: https://projects.blender.org/blender/blender/pulls/130015
2024-11-08 21:29:53 +01:00