Commit Graph

139575 Commits

Author SHA1 Message Date
Bastien Montagne
63016ad965 MEM management: Add data storage only destructed after memleak detection.
Add a new API to store data that is guaranteed to not be freed
before the memleak detector has run.

This will be used in next commit by the readfile code to improve
reporting on leaks from blendfile readingi process.

This is done by a two-layer approach:

A new templated `MEM_construct_leak_detection_data` allows to
create any type of data. Its ownership and lifetime are handled
internally, and guaranteed to not be destroyed before the memleak
detector has run.

Add a new template-based 'allocation string storage' system to
`intern/memutil`. This uses the new `Guardedalloc Persistent Storage`
system to store all 'complex' allocation messages, that cannot be
defined as literals.

Internally, the storage is done through an owning reference (a
`shared_ptr`) of the created data into a mutex-protected static
vector.

`MEM_init_memleak_detection` code ensures that this static storage
is created before the memleak detection data, so that it is destructed
after the memleak detector has ran.

The main container (`AllocStringStorageContainer`) is wrapping a
map of `{string -> AllocStringStorage<key_type, hash_type>}`.
The key is a storage identifier.

Each storage is also a map wrapped into a simple templated API
class (`AllocStringStorage`), where the values are the alloc strings,
and the keys type is defined by the user code.

Pull Request: https://projects.blender.org/blender/blender/pulls/125320
2024-07-29 11:47:04 +02:00
Falk David
a1630792cf Python: Attributes: Add domain_size function
This function returns the number of elements of a given domain.

Example:
```py
>>> attributes.domain_size('POINT')
500
```

Pull Request: https://projects.blender.org/blender/blender/pulls/125519
2024-07-29 11:14:50 +02:00
Falk David
cd577f02b9 Python: Trigger property update in foreach_get/set
Calling `foreach_get/set` on a collection property did not trigger
a property update. In the attribute API, this lead to missing
updates after e.g. setting the values of an attribute.

This adds a call to `RNA_property_update` for the getter/setter
bpy rna function and adds a property update callback to all the
different attribute collection properties.

Pull Request: https://projects.blender.org/blender/blender/pulls/125518
2024-07-29 11:14:20 +02:00
Falk David
0f42f277b7 Grease Pencil: Remove legacy modifiers
This removes the legacy Grease Pencil modifiers from the code.
These should have already been inaccessible from the UI and hidden from
the user. The modifiers have been reimplemented for the new GPv3
data structure.

On top of the modifier code, some other related things have been
removed as well:
 * Operators related to the legacy modifiers.
 * Keymaps for the legacy modifier operators.
 * Some bits of code that used modifier functions.

Some code has to be kept, because it is still used:
 * The core line art code, which is used by the new line art modifier. It's
    moved to `modifiers/lineart`.
 * The DNA structs for the legacy modifiers. They are still needed for
    conversion.
 * A few kernel functions for the modifiers are kept (also for conversion).

Co-authored-by: Lukas Tönne <lukas@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/125102
2024-07-29 10:37:29 +02:00
Campbell Barton
4afb3aff35 Cleanup: pass const arguments, use r_ prefixed return arg 2024-07-29 13:01:12 +10:00
Campbell Barton
004c247670 Cleanup: different declaration names, use r_ prefix for return args 2024-07-29 13:01:10 +10:00
Jacques Lucke
9e88ff1b4b Cleanup: use correct index when building group node lazy function
This shouldn't make any difference right now, because the main inputs
and outputs of a group always come first. But it's better to not rely on that
here if it can be avoided.
2024-07-28 14:21:56 +02:00
Jacques Lucke
1f026f7ac2 Cleanup: improve method names
These methods don't build separate nodes anymore, just the sockets.
2024-07-28 14:20:18 +02:00
Philipp Oeser
8b3beeee82 Fix #124836: Triangulate modifier changed behavior with custom normals
This reverts commit f3c32a36bc and the two followups.

The commit caused issues with both the operator and the modifier.

The operator could be fixed, for the modifier this needs deeper
investigation (see #124836 for a bit more info on this).

Until a better solution is found it is just better to go back to
previous behavior.

Reintroduces  #103562 for now

Pull Request: https://projects.blender.org/blender/blender/pulls/125499
2024-07-28 10:27:29 +02:00
Jacques Lucke
26b7ae888b Fix: deduplicate shared data when writing to file
If a data-block referenced the same shared data more than once, it used to be
written multiple times. This worked out so far, because the written data is
always the same. So when reading the file, it doesn't matter which written
buffer Blender decides to read on. However, this makes the .blend file look
corrupt and leads to memory leaks on load (#125001).

Pull Request: https://projects.blender.org/blender/blender/pulls/125489
2024-07-27 23:07:21 +02:00
YimingWu
79862c8cfa LineArt: bake should return CANCELLED when not applicable
Previously the operator always returned OPERATOR_FINISHED, which is
incorrect when it did not actually run.
2024-07-27 20:52:27 +08:00
Falk David
95139263de Cleanup: Python: Remove unnecessary array length definition in curves API 2024-07-27 11:30:04 +02:00
Sean Kim
2f15347f7c Fix: Empty span check for vert_all_faces_visible_get
Pull Request: https://projects.blender.org/blender/blender/pulls/125524
2024-07-27 06:16:15 +02:00
Sean Kim
e8c7fe8ab9 Fix: Out of bounds errors with FillDataMesh
* Missed empty span check
* Wrong iterator direction

Pull Request: https://projects.blender.org/blender/blender/pulls/125523
2024-07-27 06:15:34 +02:00
Campbell Barton
e974ee05dc Cleanup: clarify ED_markers_make_cfra_list only selected argument
The argument read as if it might be a flag (callers passed in SELECT),
but it was in fact used as a boolean.
2024-07-27 13:32:52 +10:00
Campbell Barton
80f135e7d2 Cleanup: avoid shadowing 2024-07-27 13:32:52 +10:00
Campbell Barton
111a40239a Cleanup: match argument names for function & declarations
Match function and declaration names, picking names based on
consistency with related code & clarity.

Also changes for old conventions, missed in previous cleanups:

- name -> filepath
- tname -> newname
- maxlen -> maxncpy
2024-07-27 13:32:51 +10:00
Sean Kim
edb73325c1 Cleanup: Fix Span drop_back docstring
Pull Request: https://projects.blender.org/blender/blender/pulls/125512
2024-07-27 05:27:54 +02:00
Harley Acheson
9bdd511a27 UI: Always Use Mono Font for Python in Tooltips
When including Python on the tooltips they are meant to be shown using
a monospaced font. This is the case in two of the four places that
python is shown, but not in the other two which include Tool tooltips.
This PR makes them all consistent.

Pull Request: https://projects.blender.org/blender/blender/pulls/125521
2024-07-27 01:51:41 +02:00
Sean Kim
f217dad8de Cleanup: Rename SubdivCCGNeighbors duplicate() to duplicates()
Avoid implying that the method duplicates the underlying data.

Pull Request: https://projects.blender.org/blender/blender/pulls/125520
2024-07-27 00:51:22 +02:00
Alaska
d610ae2764 Fix broken EEVEE material shadow mode versioning
Fixes an issue where the original material of the node tree wasn't
connected to the right sockets in most situations after applying
EEVEE-Next shadow mode versioning.

Pull Request: https://projects.blender.org/blender/blender/pulls/125438
2024-07-27 00:42:24 +02:00
Falk David
52a1be9396 Cleanup: Formatting 2024-07-27 00:04:56 +02:00
Falk David
f256b9daf7 GPv3: Python: Add curve_offsets API
This adds the `curve_offsets` collection property.
The curve offsets can be used to get the points that belong
to a curve. They are the offset indices of the first point of
each curve. The first offset is always zero and the last offset
is the total number of points in the drawing.
2024-07-27 00:02:55 +02:00
Falk David
edcc438f5f GPv3: Python: Add drawing API functions
This adds `add_curves`, `remove_curves`, and `resize_curves`
functions to the drawing API.

This should replace the old GPv2 API functions:

* `strokes.new`
* `strokes.remove`
* `points.add`
* `points.pop`
* `points.update`

Pull Request: https://projects.blender.org/blender/blender/pulls/125502

Pull Request: https://projects.blender.org/blender/blender/pulls/125502
2024-07-26 22:51:28 +02:00
Falk David
6fac4707d5 Curves: Add Python API to remove and resize curves
This adds two new python functions:
* `curves.remove_curves(indices=None)`
* `curves.resize_curves(sizes, indices=None)`

By default, `remove_curves` will remove all curves. If `indices`
are provided, only the curves with the given indices are removed.
The indices have to be in ascending order and mustn't repeat.

The `resize_curves`function  will change the number of points
for each curve. If no indices are provided, there must be as
many elements in `sizes` as the number of curves there is.
Otherwise, there must be one element in `sizes` per element
in `indices`. The `sizes` are the new size for a given curve.
If the new size for a curve is smaller, then the curve is
trimmed from the end. If the new size for a curve is greater,
then the end values will be default initialized.

Pull Request: https://projects.blender.org/blender/blender/pulls/125502
2024-07-26 22:51:27 +02:00
Sean Kim
ac344aae1f Subdiv: Add neighbor slicing helper methods
Pull Request: https://projects.blender.org/blender/blender/pulls/125513
2024-07-26 21:42:09 +02:00
Sean Kim
eda872b6eb Cleanup: SubdivCCG: Add SubdivCCGCoord constructor from key and index
* Adds test for this usecase.
* Reduces existing duplicated code.

Pull Request: https://projects.blender.org/blender/blender/pulls/125511
2024-07-26 21:16:37 +02:00
Hans Goudey
a5374d8e30 Cleanup: Sculpt: Use C++ vector type in pose brush code 2024-07-26 12:57:51 -04:00
Hans Goudey
0e5858e226 Sculpt: Data oriented refactor for pose brush deformation
Part of #118145.
There are some things to address with the "fake neighbor" system before
the rest of the brush can be refactored.
2024-07-26 12:57:51 -04:00
Hans Goudey
c2ac890f6b Cleanup: Fix name of function argument 2024-07-26 12:57:51 -04:00
Hans Goudey
78c73eacd2 Cleanup: Use Array for pose brush mask data 2024-07-26 12:57:51 -04:00
Harley Acheson
f2f408bebf UI: Tooltip Final Period and Other Typography
This removes the terminal periods automatically added to the end of
tooltip items. The current desire is to only end in period if there
are multiple sentences - so if there is one in the middle of the
description. This also converts our uses of lists to use space and
bullet, rather than just bullet or asterisks.

Pull Request: https://projects.blender.org/blender/blender/pulls/125460
2024-07-26 18:29:50 +02:00
Omar Emara
406a2d3ff0 Fix #125380: Viewport compositor slows complex scenes
The viewport compositor slows down complex scenes even if it has very
simple setups. That's because it internally computes previews which
involves a fair bit of CPU computation, however, those previews are
actually never written to the original tree, so previewers weren't
really visible so it is effectively redundantly computations.

To fix this, we double down on disabling previews for the viewport
compositor and avoid any redundant computations in that case.
2024-07-26 19:08:58 +03:00
Sean Kim
8a812e334d Fix #125375: Sculpt undo with duplicate object causes crash
Introduced with d527e3a6bd.

Cached values are tagged as dirty during the update step, this can cause
conflicts where we attempt to then flush then changes into the PBVH but
have not yet updated the mesh pointers and reinitialized them.

This commit forcibly initializes the underlying data to prevent such
cases from happening when flushing to the PBVH.

Pull Request: https://projects.blender.org/blender/blender/pulls/125396
2024-07-26 18:01:11 +02:00
Harley Acheson
13795b5df1 UI: Custom VSE Handle Cursors for Mac
Mac Platform-specific PDF cursors for VSE handle types.

Pull Request: https://projects.blender.org/blender/blender/pulls/125471
2024-07-26 17:31:25 +02:00
Falk David
6f050fecfb GPv3: Python API for frame, drawing and drawing attributes
This is a PR that is built on top of #122094 (thanks to @SietseB
for the initial work).

Adds the following properties and functions:
* `layer.frames`,
* `layer.frames.new(frame_number)`
* `layer.frames.remove(frame_number)`
* `layer.frames.copy(from, to)`
* `frame = layer.get_frame_at(frame_number)`
* `frame.drawing`
* `frame.frame_number`
* `frame.select`: the selection state of the keyframe in the dope sheet
* `frame.keyframe_type`
* `drawing = frame.drawing`
* `drawing.type` (`DRAWING`/`REFERENCE`)
* `drawing.user_count`: The number of keyframes that use this drawing
* `drawing.attributes`: attribute read/write access to the drawing data

To be able to access attributes on drawings, a new
`AttributeOwnerType::GreasePencilDrawing` is added.
The API in `BKE_attributes.h` is updated to handle this type.

In `rna_attributes.cc`, there is a new
`rna_def_attribute_group_grease_pencil_drawing` that defines the
attribute group. For this to work, it also defines its own rna
callback functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/124787
2024-07-26 16:29:59 +02:00
Julian Eisel
5aa0695d12 Refactor: Use std::variant instead of union for asset data
Rather than a manually managed union, use `std::variant` which is
generally safer. E.g. an invalid access will now throw an exception
instead of causing undefined behavior (which may or may not crash, or
cause a data corruption). Code is also simplified this way.

Pull Request: https://projects.blender.org/blender/blender/pulls/125494
2024-07-26 15:55:03 +02:00
YimingWu
f9810ce99c GPv3: LineArt: Baking operators
This patch implements all baking operators for LineArt for GPv3.
The old baking operators are renamed with `_legacy_` to
distinguishing both when calling the operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/125079
2024-07-26 15:48:52 +02:00
Pratik Borhade
1da83ab046 GPv3: Duplicate active keys operator
Port legacy `frame_duplicate()` operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/125369
2024-07-26 15:39:42 +02:00
Falk David
cc28ad8dcf Grease Pencil: Remove legacy python API
While the python API for the legacy Grease Pencil object can be fully
deprecated, annotations still make use of the `bGPdata` DNA and
therefore need their own python API.

This removes `RNA_def_gpencil` entirely, but replaces parts of it
in `RNA_def_annotations` to make sure that annotations keep
working as before. Note that this is only a very small subset of the
legacy Grease Pencil API.

Technically, this "removes" python API functionality from annotations
because they are full Grease Pencil IDs, but the idea is to make them
simpler and encourage users to use Grease Pencil objects instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/125097
2024-07-26 15:39:02 +02:00
Julian Eisel
ea254f64e3 Cleanup: Improve name of asset storage type
Use "asset storage" instead of just "storage", because there are other
members acting as storage (e.g. holding all catalog data), while this is
asset specific.
2024-07-26 15:30:38 +02:00
Bastien Montagne
cd07327584 BLO write: Avoid double lookup in already added blocks addresses. 2024-07-26 15:29:00 +02:00
Julian Eisel
489a5e92b8 Cleanup: Remove now unused asset identifier files
Missed this in 693e590d9f.
2024-07-26 15:12:51 +02:00
Julian Eisel
693e590d9f Refactor: Assets: Remove unnecessary asset identifier class
This was just rather useless level of abstraction. I heard from other
devs that these helper classes caused confusion, so better to avoid
this.

Now the asset representation has all the needed bits to create its full
path, blend-file path and asset library relative path. In fact only the
asset library relative path needs to be stored to make all this
available, since the asset representation already stores a reference to
the asset library owning it, so the paths can be recreated easily.
2024-07-26 15:03:06 +02:00
Germano Cavalcante
0dad3bdfa7 Fix #123179: can't select multiple snap target elements in UV Editor
Missed after 'Set Snap Base' commit.

Just like in 3D View, UV editing can also benefit from selecting
multiple snap target elements.

The C++ code was already done, it was only necessary to edit the
interface.

Pull Request: https://projects.blender.org/blender/blender/pulls/124986
2024-07-26 14:59:13 +02:00
Christoph Lendenfeld
2c46b022a5 Fix: Compiler warning after recent refactor
`rna_path` was passed to `BKE_reportf`, while it should be `rna_path.path.c_str()`
2024-07-26 14:50:38 +02:00
Hans Goudey
99594f7281 Sculpt: Use Vector::resize instead of reinitialize
Though it amounts to the same thing for trivially destructible types,
conceptually `reinitialize` destructs old values before resizing. This
isn't necessary, and in the cases where it was used for a vector of
vectors (like vertex neighbor index storage), it could be slower.
I measured a few percent performance improvement for the smooth brush.

Also change some dynamically resized Arrays to vectors to make
use of amortized growth.
2024-07-26 08:44:29 -04:00
Jacques Lucke
f600d5681b Fix #125346: wrong transparency for dashed node links
This changed accidentally in 3410d0bf3f.
2024-07-26 14:40:03 +02:00
Sybren A. Stüvel
7346ef03f4 Anim: hide slot selector in Action editor behind experimental flag
Hide the Action Slot selector in the Action editor behind the experimental
flag. Not only shouldn't it be shown, but also it uses an API that's only
available in experimental builds.
2024-07-26 14:34:20 +02:00
Christoph Lendenfeld
e540325f3e Refactor: clear_keyframe function arguments
No functional changes intended.

The function `clear_keyframe` had more arguments than needed:
* The `bAction *` was always a nullptr
* the unused parameter `eInsertKeyFlags` was removed
* the rna path and the array index were merged with the `RNAPath` struct

Pull Request: https://projects.blender.org/blender/blender/pulls/125487
2024-07-26 14:08:45 +02:00