Commit Graph

99737 Commits

Author SHA1 Message Date
Bastien Montagne
a1e5d57b59 Cleanup/fix: Add file subversion bump to 3.6 for 'unversioned' versioning.
`blo_do_versions_300` still had some 'no version number' versioning code
at its end, should have been handled when 3.6 branch was created.
2023-06-07 17:01:33 +02:00
Germano Cavalcante
981dd12394 Fix #108665: Project 3D cursor on Geometry not working in X-ray
Caused by 98bfa8d458

Occlusion must consider several factors:
- The `Viewport Display` > `Display As` setting  of the object.
- The X-Ray mode of the scene.
- Whether only Snap to Face is being used.
- Whether Snap is set to Cage (always transparent) in edit mode.
- Whether the object is hidden.

In the case of Cage, the final geometry should be utilized for occlusion.
However, to prevent excessive and risky modifications, it was followed
the same approach as before and verified the `Display As` setting of
the object.
2023-06-07 11:56:53 -03:00
Philipp Oeser
7b8bbabece Fix #106155 : Hair dynamics not working well when converted from curves
In particular, the root was not sticking to mesh with hair dynamics.
Reason for this is missing HairKey weight upon conversion (everything
had zero weight). This then can not be corrected (since weight tool does
not allow to paint on roots).

So now, give the hair a default 1.0 to 0.0 weight gradient upon
conversion [which is in line with the default weight distribution for a
hair particle system].

Pull Request: https://projects.blender.org/blender/blender/pulls/108651
2023-06-07 14:49:20 +02:00
Bastien Montagne
7ceb33e06e I18N: Revert part of d95486af95 removing check for main thread.
Part of the checks to see if translating a UI string is allowed or not
is that current thread is the main one. This was a requirement years ago
of the Boost backend for translations.

Not sure whether this can be removed or not now, but it needs to be
carefully checked, done it as its own commit, and not in a beta release
branch. ;)

Sorry for the noise, totally missed this during the patch review
yesterday.
2023-06-07 11:31:34 +02:00
Philipp Oeser
c51467cd4c Fix #108096: UI: copy-paste buttons can change source properties
Pasting numerical array buttons happens with `Ctrl + Alt + V`.
Holding `Alt` also triggers uiSelectContext, so having other nodes/
objects etc. selected while doing this would try to copy the pasted
values back to other objects (possibly to the ones you pasted from) and
that happens relative to the original value, so the value actually
changes.

NOTE: the `Ctrl + Alt + V` shortcut can also be used on non-array buttons, so was an issue for them as well.

To prevent the "copy-to-selected" behavior, refine the `IS_ALLSELECT_EVENT` macro to be more specific.

Pull Request: https://projects.blender.org/blender/blender/pulls/108270
2023-06-07 11:19:05 +02:00
Campbell Barton
c0bfb81e04 Fix material paste setting the nodetree's owner_id to null
Resolves assert in debug builds when changing the material color
after pasting.
2023-06-07 13:32:27 +10:00
Campbell Barton
64ead920a1 Fix #108495: Pasting a material crashes
References to data-blocks in a material were stored in-memory and could
crash if the data-blocks referenced by the material no longer existed
when pasting.

Resolve by using a blend-file for material copy/paste, matching how the
clipboard works in the 3D view-port.

Currently there is no support for including indirectly linked
data-blocks when pasting the material. Instead, data-blocks are restored
by name, by inspecting the current file.

This also fixes a crash where the `SpaceNode::nodetree` could point to
freed memory when pasting a material.

Ref !108496.

Includes contributions by @mont29.

---

Fix back-ported to main [0], including fix [1].

[0]: 5177e2f20b
[1]: 64aa96d421
2023-06-07 13:22:07 +10:00
Chao Li
a56df90931 Fix #108198: Particle hair crash when using Hair Dynamics
`hair_out_mesh` and `hair_in_mesh` implicitly share edges.
In `hair_create_input_mesh()`, edge data of `hair_in_mesh` needs to be
updated and therefore are copied to a new location. In the subsequent
frames, `psys->clmd->clothObject->edges` won't be updated and point to
freed memory block. Therefore, Blender crashes.
By freeing `hair_out_mesh` first,
1. in `hair_create_input_mesh(),` at least edge data copying is avoided
2. `psys->clmd->clothObject->edges` always points to correct memory

However, since it's possible that similar situation will happen again
by adding another strong user to the same `CustomData` in the future,
it is safer to update `psys->clmd->clothObject->edges` for every frame.

Pull Request: https://projects.blender.org/blender/blender/pulls/108480
2023-06-06 18:46:35 +02:00
Hans Goudey
d9dfa782eb Fix: Remove non-threadsafe BMesh assertions in Mesh conversion
Currently this macro modifies faces. It needs to take a const pointer
to the element so it can be run on the same face from multiple threads.
2023-06-06 12:12:26 -04:00
Damien Picard
f07a4c1eed I18n: disambiguate "Fill"
The "Fill" message can be either a noun or a verb. This commit
disambiguates the verb usages for translation through various
translation contexts.

The more involved change is in the generation of keymaps from paint
modes. By default, the enums defining brush names are in the default
context, but this commit changes the ones including a "Fill" item to
"Brush". In order to get the same contexts in the keymap, we introduce
a specific function in `paint.cc` to return the appropriate context
depending on the tool.

Issue reported by Gabriel Gazzán (@GabrielGazzan) in #43295.

Pull Request: https://projects.blender.org/blender/blender/pulls/108561
2023-06-06 16:29:22 +02:00
Damien Picard
d95486af95 18n: Use fmt::format() to replace string concatenation in nodes
The UI code for nodes uses `stringstream`s a few times to format
strings. In some cases it is fine, but in others it makes localization
hard or impossible to do properly, as explained in #92758.

This commit replaces some `stringstreams` by `fmt::format()`, a
library that is already used in other parts of Blender and was
suggested by Hans Goudey (@hooglyboogly) in
[D15996](https://archive.blender.org/developer/differential/0015/0015996/#inline-138440).

Pull Request: https://projects.blender.org/blender/blender/pulls/107260
2023-06-06 16:27:49 +02:00
Philipp Oeser
014825dd26 Fix: UI: cannot copy-paste many array buttons in nodes
This came up in #108096

Reason this fails is the `ui_but_has_array_value` check [which depends
on a property subtype that supports arrays]. The default `VectorBuilder`
has a `PropertySubType` of `PROP_NONE` though, so one possibility
would be to change this to `PROP_XYZ`.

However, RNA should know much better which RNA property buttons
have arrays than the UI code, so use RNA_property_array_check now
(instead of checking particular UI property subtypes).

Pull Request: https://projects.blender.org/blender/blender/pulls/108349
2023-06-06 14:24:45 +02:00
Philipp Oeser
32a349d3a3 Fix #108492 : Compo Track Position node wrong Y for Relative Start/Frame
This seems to be a simple copy/paste error from e0c5ff87b7

Thx @Chris-Thomas spotting this!

Pull Request: https://projects.blender.org/blender/blender/pulls/108504
2023-06-06 13:50:34 +02:00
Nathan Vegdahl
997ad50b49 Fix #106801: loading file with overriden NLA in tweak mode loses action
The root issue was that the `tmpact` field of an object's animation
data wasn't exposed to RNA, and thus wasn't getting overridden.

Pull Request: https://projects.blender.org/blender/blender/pulls/108548
2023-06-06 11:10:58 +02:00
YimingWu
8a0a9ec0c3 Fix #108591: Handle null material adding paint slot
When adding a texture paint slot to an object, the object could have no
material, this patch handles that by checking the material first in
`default_paint_slot_color_get`, if material is null, then it will return a
fallback default color so the operator can proceed normally.

Pull Request: https://projects.blender.org/blender/blender/pulls/108592
2023-06-06 04:13:01 +02:00
Hans Goudey
41d994c9ac Fix #108571: OBJ vertex group import crash
`tot_loop_idx` was increased before it was used to set the set
the vertex group value of the current face corner's vertex.
2023-06-05 20:20:03 -04:00
Campbell Barton
7e7c14ad4c Fix paste flipped creating invalid RNA data paths
- Paste flipped created invalid paths when the size of the name changed
  left -> right: lost the 't' in right.
  right -> left: lost the entire end of the RNA path.

- Correct the fixed buffer size as it may include escaped characters.
2023-06-06 09:35:21 +10:00
Campbell Barton
dd1fe31a74 Cleanup: quiet compiler warnings 2023-06-06 09:34:50 +10:00
Leon Schittek
e6a8c45fd9 Fix #108578: Crash when unlinking input sockets
Fix a mistake in commit 2ce5fc4a3e that caused a crash when detaching
node links from input sockets.

When a link is detached from an input socket, `nodeRemLink` nulls the
`link` pointer of the socket.
So before the next update inputs are linked but don't have a valid `link`
pointer causing the crash, when trying to access the link in
`std_node_socket_draw`.

The introduced check avoids the crash and is more correct since it
doesn't just check one link for multi-input sockets.

Pull Request: https://projects.blender.org/blender/blender/pulls/108623
2023-06-05 20:21:07 +02:00
Damien Picard
745baa788d I18n: extract a few messages
- "Invalid" in transformation messages.
- For three messages, translation occured after a string
- concatenation, so the full message was not found.
  Instead, translate a format pattern and format it afterwards.
- Alembic errors when there is an import type mismatch.

Pull Request: https://projects.blender.org/blender/blender/pulls/108212
2023-06-05 18:10:11 +02:00
Bastien Montagne
855d8d3fa4 Fix #88010: Undo system did not respect memory limit.
Code was plainfully buggy, early-out check in
`BKE_undosys_stack_limit_steps_and_memory` was plainfully wrong.

Also added some more logging for memory limiting code.
2023-06-05 15:23:31 +02:00
Chris Blackbourn
de4fb0e570 UV: Add optimal uv packings using precomputed layouts
Produce optimal layouts for `n` squares, where n == 11, 18, 19 and 26.

With thanks:
* Walter Trump
* Pertti Hamalainen
* Robert Wainwright
* Erich Friedman
2023-06-05 12:06:30 +12:00
Leon Schittek
2ce5fc4a3e Fix #108336: Treat node sockets with muted links as linked
Prevent make links operator from creating links to sockets that are
already linked to a muted link.

The `SOCK_IS_LINKED` flag is used to check if there already is a link
connecting to the socket but when the link is muted, the flag wasn't set
leading to issues in parts of the code that used the flag to check
for any type of connected link.
This commit now also sets `SOCK_IS_LINKED` when links are muted and
adds an additional check in places where different behavior is expected
for muted links.

Pull Request: https://projects.blender.org/blender/blender/pulls/108375
2023-06-03 12:34:58 +02:00
Leon Schittek
cc9c720aae Fix #103068: Link insert offset not working when rotating/scaling nodes
Fix node link insertion during transform not working properly for
rotation and scale.
Inserting nodes by rotating or scaling...
* ...didn't offset the attached nodes.
* ...could lead to unfreed memory.

This commit fixes that by always calling the `NODE_OT_insert_offset`
operator at the end of the node transform operator rather than having
to explicitly append it into a macro operator for each transform
operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/107460
2023-06-03 12:29:57 +02:00
Hans Goudey
214da4b6b4 Fix #108039: Incorrect results when setting custom normals
The solution using `reverse_index_array` didn't work because it lost the
order that the corners were processed in (the order around the vertex).
This is important when setting custom normals because the process
sets sharp edges when the normal of the current and previous corner
is too different.
2023-06-02 21:18:12 -04:00
Julian Eisel
4832114d60 Fix #107870: Movie Clip Editor hangs in "Clip" view
Because of how the Clip Editor managed region state for different view
modes before region polls were introduced (fa0f295b53), regions could be
written to files in a state that's not valid for displaying them. State
for clip editors written to files is corrected with versioning now.
2023-06-02 18:19:23 +02:00
Nathan Vegdahl
f63c56e05c Fix: action's actual users and recorded user count could diverge
The user count decrement and unassigning the action were split
between two different conditionals, which weren't guaranteed
to both execute/not-execute together.
2023-06-02 16:03:26 +02:00
Bastien Montagne
d847851000 Fix #108285: Crash in Outliner when using RNA ID remapping API call.
RNA API call was not updated UI in anyway.
2023-06-02 15:26:04 +02:00
Bastien Montagne
5ce0f80ed6 Fix #108285: Remap Users operator doesn't work on Objects.
Objects were excluded from the ID operation, as originally they had
their own entry in their own menu. Joys of nightmare tools handling in
the Outliner...
2023-06-02 15:26:04 +02:00
Sietse Brouwer
a784a65dbe Fix #108473: unreliable auto-normalize results when weight painting in GPencil
Painting weights in Grease Pencil with the auto-normalize option enabled,
gave unpredictable results when vertex groups with a weight of zero
were involved.
This patch resolves the issue. Vertex weights of zero are excluded from
auto-normalization. Which is a better fit for the Grease Pencil workflow,
where weights are mostly painted from scratch since the 'parent to
armature with automatic weights' operator doesn't give good results.

Pull Request: https://projects.blender.org/blender/blender/pulls/108524
2023-06-02 15:04:19 +02:00
Sietse Brouwer
25952b865d Fix #108475: no helpful tooltips for Vertex Paint tools in Grease Pencil
The tools in Vertex Paint mode in Grease Pencil were missing clear
descriptions. This patch adds them, based on the descriptions in
the manual.

Pull Request: https://projects.blender.org/blender/blender/pulls/108522
2023-06-02 15:02:39 +02:00
Julian Eisel
a6e1caa1b2 Fix file/asset browser document type icons using wrong theme color
Steps to reproduce were:
- Open File Browser, set it to Thumbnails display mode, disable filters
- Navigate to a directory with documents that have no preview
- Change Preferences > Themes > User Interface > Icon Colors > File
  Folders to light and dark colors
- See how the type icons on top of the white document icon image get
  changed unexpectedly. Only type icons drawn on top of folder icon
  images should change.

When drawing the document type icons on top of the folder or document
image in the center of thumbnails, they would always use the folder icon
color (Preferences > Themes > User Interface > Icon Colors > File
Folders) to determine if they should be drawn with a light or a dark
color. It should only use that when drawing on top of a folder icon
image, and the color for document icon images otherwise.
2023-06-02 12:27:45 +02:00
Dalai Felinto
9d00d13767 Fix #108501: Image Editor glitch after texture painting undo
When doing the second undo, the image wasn't properly marked for full
update.

There reason was that in some cases the partial_updater was
totally reconstructed: `first_changeset_id` and `last_changeset_id` were both 0.

While the `user_imp->last_changeset_id` was still its last value (e.g., 3).

The fix is to have the partial updater validator to check for the
last change set as well (it was only checking for the first change set).

This way we cover both scenarios when user_imp->last_changeset_id is out
of the range of the partial update history.

Pull Request: https://projects.blender.org/blender/blender/pulls/108533
2023-06-02 11:09:38 +02:00
Campbell Barton
12240499ac Fix/workaround crash pasting MTex
Pasting MTex referenced Texture & Object data-blocks without any
check for their validity.

This isn't ideal as it doesn't handle re-allocated ID's,
it just prevents a crash referencing freed data-blocks.
2023-06-02 13:37:58 +10:00
Jason Fielder
3788f70647 Fix #107704: Release infrequently used memory in Metal buffer pools
Excessive memory pool bloating could occur for certain workloads in
Metal. Particularly those which continuously allocate increasingly
large buffers with minimal re-use of existing buffers.

New logic added to the memory pool flushes old buffers if they
have not been used for a set period of time. Timing is calibrated
against system resources and overall memory pressure.

Metal memory pressure will run higher than OpenGL, however,
this is an active decision to provide significant performance
improvements for scenarios which allocate lots of memory and
for keeping frames queued in flight without stalling on pending
GPU work.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/108083
2023-06-01 15:48:30 +02:00
Jason Fielder
361b42d526 Fix #107766: Resolve Metal texutre usage issue for GreasePencil fill
Certain textures require explicit HOST READ support for reading
data back to CPU. Given the compute based texture read path may
be used for this, if format conversion is required, this flag should
also imply general texture read support.

This resolves a bug with GreasePencil fill which relies on this.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/108463
2023-06-01 15:44:18 +02:00
Jason Fielder
c3f7b723b2 Fix #108500: Resolve Metal line loop emulation for armature limits
Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/108512
2023-06-01 15:41:25 +02:00
Jacques Lucke
cf959c1a90 Fix: remove materials from simulation state in all cases
This was somewhat inconsistent before where materials sometimes worked
and sometimes did not (#108178). There is a design task for supporting materials
properly: #108410.

Pull Request: https://projects.blender.org/blender/blender/pulls/108411
2023-06-01 12:11:10 +02:00
Campbell Barton
db1344530f Cleanup: unused argument warning 2023-06-01 16:33:10 +10:00
Chris Blackbourn
f87f119c2f UV: Update ui for the uv pack islands operator
Reorder options and improve naming for UV Pack Islands

Update names of constants to match names in the UI.

Pull Request: https://projects.blender.org/blender/blender/pulls/108253
2023-06-01 01:45:07 +02:00
Chris Blackbourn
f78d1fd114 Fix memory leak during uv packing
Regression from [0].

[0]: 91020ccde1
2023-06-01 11:29:06 +12:00
Bastien Montagne
9f1a4a2e3f Fix (studio-reported) LibOverride from Outliner not working well.
In case a part of an override hierarchy would still be linked data, and
there would be other liboverride hierarchies sharing usage of that same
linked data, trying to create a partial override of that linked data
into a hierarchy would create very unreliable results.

This commit now only process each ID at most once, to ensure that the
liboverride will only be put in one liboverride hierarchy.

This is only a partial fix, results now should at least always be
valid. However, due to inheritently broken Outliner code when it comes
to same data in more than one path of the tree, the place where
(hierarchy in which) the new liboverride will be created is currently
'random' and unpredictable from user perspective.

This commit contains some code to try to alliviate that (by enforcing
processing of the active elements first), but unfortunately this does
not work either.
2023-05-31 15:31:45 +02:00
Bastien Montagne
12a52c03c8 Fix (unreported) liboverride creation glitches:
- Do not remap local liboverrides from other hierarchies when a
   liboverride hierarchy root is provided (such that in case a linked
   data is overridden as part of one hierarchy, the new liboverride does
   not get assigned to other liboverride hierarchies of the same reference
   data).
 - Do not attempt to instanstiate newly overridden collections or objects
   when they are part of a hierarchy and not the root of that hierarchy
   (as they can be sondiered as already handled through that hierarchy
    processing). Avoids attempts to instantiate them when doing partial
   liboverride into an already existing hierarchy.
2023-05-31 15:27:14 +02:00
Bastien Montagne
688e63f950 Fix (unreported) BKE add_collection allowed to add to liboverride.
Probably typo, should check if collection is a liboverride, not if its
liboverridable.
2023-05-31 15:12:03 +02:00
Philipp Oeser
eb4ea0b51d Fix #108266: sculpt auto created color attribute not set as render color
When entering sculpt mode on an object without any color attributes and
starting to paint, the newly created color attribute was set active, but
not default (camera icon).

Now set it default as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/108271
2023-05-31 15:00:39 +02:00
Aras Pranckevicius
e097415c2c Fix #107299: new PLY importer does not skip unknown custom data elements
Properly skip any unknown/unrecognized custom data elements,
fixes #107299.
2023-05-31 09:43:56 +03:00
Campbell Barton
5242f442a5 Fix crashes accessing freed memory from the material clipboard
Follow up to [0], some material data wasn't accounted for.

- The embedded node-tree's owner_id wasn't set.
- Animation data (both the material & it's embedded node-tree).
- Updating depsgraph relations is needed when animation data is freed
  as part of paste too.

Also report when paste fails.

[0]: 5b5a1e3581
2023-05-31 13:51:10 +10:00
Campbell Barton
f5ad77adbf Fix material copy-buffer memory leak on exit
Commented [0] (2.5x refactor that disabled many free functions),
for some reason this call was never re-enabled.
Add back the free call along with other clipboard buffers.

---

Cherry picked [1] from main as other fixes material clipboard
are difficult to validate when memory is leaking.

[0]: a1c8543f2a
[1]: cb0c4f04d4
2023-05-31 13:22:50 +10:00
Campbell Barton
12e5241876 BKE_main: simplify & update debugging block for tracking freed ID's
Use a macro to make the ID-free switch more compact & use ID indices
for better readability. Also typedef the enum so missing types in the
switch will report compiler warnings.
2023-05-31 13:22:48 +10:00
Campbell Barton
19cd473518 Fix failure to cleanup temporary files with '--python-exit-code'
Note that handlers for the `ARG_PASS_FINAL` pass must always use WM_exit
instead of calling exit directly.
2023-05-31 12:35:22 +10:00