Since the code only does anything if both substrings are found, implement
an early-out if either of them isn't found.
This seems like a micro-optimization at first, but since the current node
socket versioning requires looping over all AnimData in the file, this adds
up to e.g. 1.9sec saved when loading the Spring benchmark file.
Unlike most versioning helper functions, version_mesh_crease_generic
takes care of all meshes in the blend file. However, the versioning
code was looping over all meshes and calling it for each one anyways.
This doesn't do anything after the first iteration, but it results
in quadratic time complexity w.r.t. number of meshes and manages to
waste e.g. 600ms when loading the Spring benchmark file.
Centralized method to obtain ScrArea icons. Areas can add an optional
space_icon_get callback to provide an icon that differs by subtype. If
not defined then ED_area_icon will return RNA UI icon, which is correct
in cases without area subtypes.
Pull Request: https://projects.blender.org/blender/blender/pulls/124556
Part of #118145.
For each of the PBVH types, the refactored Relax Face Set brush
performs the following steps:
* Calculate all relevant element factors like other refactored brushes
* Calculate the displacement by performing the following steps, using a
displacement of 0 if certain conditions are unfulfilled (e.g. factor
will have no effect, no relevant neighbor vertices, etc)
* Find all neighbors for each element
* Filter the neighbors based on if the current vert is or is not a
boundary vert, looking at the face sets of each neighbor
* From the relevant neighbors, calculate a smoothed average position.
* For boundary verts, calculate the normal based on the summed
direction towards each neighbor vertex
* For non-boundary verts, retrieve the current vertex normal.
* Use the current position and the retrieved normal to create a
plane.
* Find the closest point on the plane to the smoothed position, use
this as the final displacement
* Apply all of these displacements to the relevant elements
Q: Why do we perform three different parallel loops for each method
instead of a single one like other brushes?
Because much of the processing time for these functions is spent in the
neighbor calculation, we opt to process factors in an earlier loop to
short-circuit neighbor calculation if we know it cannot possibly have
an effect (i.e `factor[i] == 0.0f`)
Q: Why are lambdas used in `filtered_neighbors` ?
Simply put, reducing the overall amount of code duplication,
otherwise this function would require 6 different methods to do the
necessary filtering (boundary vs non boundary vertices for each of the
three pbvh types)
### Potential Areas of Improvement
* Unique face set calculation requires iterating over the
`vert_to_face` map and happens multiple times per brush stroke (each
stroke performs the vertex tasks 4 times in succession). Some form of
cache or precomputed map similar to the `boundary_verts` `BitSpan`
may improve performance.
Pull Request: https://projects.blender.org/blender/blender/pulls/124135
Centralized method to obtain ScrArea names. Areas can add an optional
space_name_get callback to provide a name that differs by subtype. If
not defined then ED_area_name will return RNA UI name, which is correct
in cases without area subtypes. This eliminates the current use of
RNA_property_enum_name_gettexted using a temporary context, which
results in the reported (hard to duplicate) error.
Pull Request: https://projects.blender.org/blender/blender/pulls/124488
When this was originally implemented, the `mval` attribute `wmGesture`
didn't exist. This commit switches the current mouse position from being
stored in the last element of the point array to `mval`.
Pull Request: https://projects.blender.org/blender/blender/pulls/124489
VSE icon drawing is larger than previous after #123700, and has an
incorrect check if there is enough space to show them. This PR restores
uses of MISSING_ICON_SIZE and fixes the minimum size check.
Pull Request: https://projects.blender.org/blender/blender/pulls/124378
This mostly reverts d6e9438e60 and applies a different fix. Consuming
events here would break firing operators on these events, which is what
the pose library does. Added a comment to note this, because this is not
the first time that I want to change this return value to consume
events.
This replaces two members of `BlendfileLinkAppendContext`:
* `LinkNodePair libraries` -> `Vector<BlendfileLinkAppendContextLibrary *>`
* `LinkNodePair items` -> `std::list<BlendfileLinkAppendContextItem *>`
This simplifies the code quite a bit.
Making `libraries` a `Vector` works because afaik we never iterate over the
libraries while also adding new ones (which would invalidate iterators). It's
also nice, necause we use random access in some cases.
`items` can't become a vector, because afaik more items may be added while
iterating over it. So it's still a linked list now, but with a better type that reduces
boilerplate a lot.
Pull Request: https://projects.blender.org/blender/blender/pulls/124524
While investigating #124217 it was noticed that sometimes a >4 channel
ImBuf might be passed through to this api.
This would cause memory to be overwritten because the destination ImBuf
was created with only 4 channels of memory. Now we create it with the
proper number of channels.
Pull Request: https://projects.blender.org/blender/blender/pulls/124472
Properly guard the conditionals inside ImageNode::convert_to_operations
against null operations.
I've duplicated the null check in order to not add another layer of
nesting in an already very deep set of conditionals.
Pull Request: https://projects.blender.org/blender/blender/pulls/124473
Collection Export and File->Export were inadvertently sharing the
"last used" operator properties.
This would cause settings that were used during File->Export to
interfere, silently, when exporting the collections. Or vice versa.
Pull Request: https://projects.blender.org/blender/blender/pulls/124481
Previously, this code would crash when there are vertex groups which are
not stored as simple arrays. This happened e.g. in #124416.
All non-array attributes are converted to array-attributes with this change
for now, which is better than crashing.
Issue was that the left mouse press event was handled to activate the
dragging state, but not "consumed". So general view item handling would
attempt to force-activate it again, exiting the dragging state
immediately again.
Consume the event now, plus handle properly any similar unexpected cases
(with failing assert), where modal state would be exited because of an
unconsumed event.
Alternative solution to #124529, thanks to Pratik Borhade for finding
the root of the issue.
The Sun beams node produces sharp results when the background has an
alpha channel. That's because the sun beams samples were weights by the
alpha channel, and when the image is mostly transparent, no smooth
falloff can exist.
This is a regression in the Sun Beams redesign that took place in v3.6.
I was mislead by the fact that the alpha was multiplied to the weight.
But the original code actually multiplied the alpha of the border color,
not the sample color. So this fix essentially restores the old behavior.
Pull Request: https://projects.blender.org/blender/blender/pulls/124532
The vector pass and potentially other vectors that store 4 values are
stored wrongly, in particular, the last channel is ignored. To fix this
we identify if a vector pass is 4D and store the information in the
result meta data, then use this information to either save a 3D or a 4D
pass in the File Output node.
This is a partial fix for the GPU compositor only. The complete fix for
the CPU compositor will be submitted separately as it is not
straightforward and will likely require a refactor.
Pull Request: https://projects.blender.org/blender/blender/pulls/124522
The swapping code incorrectly expected the link to have a start and end.
However, this was not necessarily the case when attempting to create
a link from a node to itself. This case has special handling in
`node_link_find_socket`.
This changes the type of `new_id_to_item` from `GHash` to
`Map<ID *, BlendfileLinkAppendContextItem *>` which simplifies code. For this to work
nicely, `BlendfileLinkAppendContext` had to become a non-trivial type. Since it
was allocated with `calloc` before, I gave all members
zero-default-initializers.
This also changes `BKE_blendfile_link_append_context_new` so that it uses
`MEM_new` instead of allocating the `BlendfileLinkAppendContext` as part of the
memory arena, because that's the more common way to do it, and it does not seem
like saving this one allocation here makes a difference considering how this is
used.
Pull Request: https://projects.blender.org/blender/blender/pulls/124516
Previously, grease pencil was just ignored by the Join Geometry and Realize
Instances code. Now they work by concatenating the layers of all grease pencil
geometries together. So if e.g. there are two inputs with each 3 layers, then
the output will have 6 layers. Layer attributes are kept intact.
Some important things to keep in mind:
* Grease pencil layers are expected to have unique names. Ensuring uniqueness
requires O(n^2) currently.
* The material indices on the curves in each layer have to be remapped.
Just like with all other geometry types, the first input in the Join Geometry
node will come first in the output geometry. Since grease pencil layers are
drawn starting at index zero, that means that the first input will be drawn
first (i.e. it's at the bottom).
Pull Request: https://projects.blender.org/blender/blender/pulls/124361
The Cryptomatte layers in the compositor are saved compressed and saved
in half precision in the File Output node. That's because the EXR writer
makes decision about compression and half float based on channel names.
And Cryptomatte are currently saved using RGBA channel names like other
color images.
To fix this, we follow the Cycles convention of using lowercase rgba for
Cryptomatte images, allowing them to be saved without compression and
always in full precision since they are otherwise useless.
Fixes#124208, #87988.
Pull Request: https://projects.blender.org/blender/blender/pulls/124508
The call to `GHOST_DisposeSystemPaths` was done in `WM_exit_ex` and
_some_ of the tests' 'teardown'. But some more where missing. Issue was
only reproducible when defining `WITH_CXX_GUARDEDALLOC` cmake option.
There are several layers of issues here, this commit addresses the
first, simplest one: since `BKE_appdir` API will indirectly create the
GHOST SystemPaths data, it is simpler and more logical to move the
deletion of this SystemPaths data in `BKE_appdir_exit()`. This avoids
exposing a fairly low-level implementation detail all over our codebase.
Further more, `WM_init` also does not need to explicitely call
`GHOST_CreateSystemPaths`, since it will be created automatically when
required.
Since 4a9e8087a7, preview-tile buttons are non-interactive by default,
so tooltip handling is not triggered. Instead, attach the tooltip to the
underlying view-item button.
This commit creates an operator to convert a `legacy Action` into a `layered Action`.
No data is destroyed, the operator creates a new datablock.
The conversion to the `layered Action` is lossless.
Pull Request: https://projects.blender.org/blender/blender/pulls/122043