The issues was that the `get_item_transform_flags` iterated over the `curves`
list of the action, ignoring the new structure.
Fixed by using the `action_foreach_fcurve` and modifying that to work on legacy actions as well.
Pull Request: https://projects.blender.org/blender/blender/pulls/126357
We often have the situation where it would be good if we could easily estimate
the memory usage of some value (e.g. a mesh, or volume). Examples of where we
ran into this in the past:
* Undo step size.
* Caching of volume grids.
* Caching of loaded geometries for import geometry nodes.
Generally, most caching systems would benefit from the ability to know how much
memory they currently use to make better decisions about which data to free and
when. The goal of this patch is to introduce a simple general API to count the
memory usage that is independent of any specific caching system. I'm doing this
to "fix" the chicken and egg problem that caches need to know the memory usage,
but we don't really need to count the memory usage without using it for caches.
Implementing caching and memory counting at the same time make both harder than
implementing them one after another.
The main difficulty with counting memory usage is that some memory may be shared
using implicit sharing. We want to avoid double counting such memory. How
exactly shared memory is treated depends a bit on the use case, so no specific
assumptions are made about that in the API. The gathered memory usage is not
expected to be exact. It's expected to be a decent approximation. It's neither a
lower nor an upper bound unless specified by some specific type. Cache systems
generally build on top of heuristics to decide when to free what anyway.
There are two sides to this API:
1. Get the amount of memory used by one or more values. This side is used by
caching systems and/or systems that want to present the used memory to the
user.
2. Tell the caller how much memory is used. This side is used by all kinds of
types that can report their memory usage such as meshes.
```cpp
/* Get how much memory is used by two meshes together. */
MemoryCounter memory;
mesh_a->count_memory(memory);
mesh_b->count_memory(memory);
int64_t bytes_used = memory.counted_bytes();
/* Tell the caller how much memory is used. */
void Mesh::count_memory(blender::MemoryCounter &memory) const
{
memory.add_shared(this->runtime->face_offsets_sharing_info,
this->face_offsets().size_in_bytes());
/* Forward memory counting to lower level types. This should be fairly common. */
CustomData_count_memory(this->vert_data, this->verts_num, memory);
}
void CustomData_count_memory(const CustomData &data,
const int totelem,
blender::MemoryCounter &memory)
{
for (const CustomDataLayer &layer : Span{data.layers, data.totlayer}) {
memory.add_shared(layer.sharing_info, [&](blender::MemoryCounter &shared_memory) {
/* Not quite correct for all types, but this is only a rough approximation anyway. */
const int64_t elem_size = CustomData_get_elem_size(&layer);
shared_memory.add(totelem * elem_size);
});
}
}
```
Pull Request: https://projects.blender.org/blender/blender/pulls/126295
No functional changes expected.
This PR refactors the code by:
* passing things by reference if they cannot be a `nullptr`
* Managing indentation by returning early or continuing.
* Cleaning up comments
* Indicating ListBase element types in the declaration
This is in service of #126125 for which the `get_item_transform_flags`
needs to be passed a slot handle as well.
Pull Request: https://projects.blender.org/blender/blender/pulls/126291
There were a couple of regressions when using the environment render
pass.
- Not working when film transparency was enabled
- Deferred geometry didn't occlude the background
This PR splits the world background shader (eevee_surf_world) into two
shaders. One clears background and render passes and a second one that renders
the background and the environment render pass.
The second shader is moved after the deferred pipeline and an early
depth test is used to occlude the background and environment pass.
NOTE: render test reference images needs to be updated.
Pull Request: https://projects.blender.org/blender/blender/pulls/126274
Regression in [0] which displays the filename for the active
theme but still used the label internally.
This meant actions such as removing the theme would not always apply
to the name being displayed.
- Adding a new theme was not setting it active.
- Detecting if a theme was built-in used the run-time label as a lookup.
- Theme removal first require it to be re-selected.
[0]: 0bb6317035
Part of #118145.
Similar in concept to recent commits removing the usage of
this mesh pointer in favor of fetching the data as necessary.
Also see recent discussion in a recent fix for this area:
https://projects.blender.org/blender/blender/pulls/122850.
And also note the comment for `Tree::mesh_` was incorrect.
The mesh was the original mesh, not the evaluated mesh.
Part of #118145.
There is some complexity in this area because the normals need to be
updated on the original geometry only when there is no deformation
or multires modifier. The simplest way to encapsulate that usage of
the original geometry for now was adding a separate function that
contains the lookup with a comment justifying it.
* Removes usage of `PBVHVertRef` in favor of `int` since the operator
only works on Mesh
* Removes calls to Multires and BMesh code that have no effect
* Inline floodfill algorithm
Pull Request: https://projects.blender.org/blender/blender/pulls/126258
The automask cache is not guaranteed to exist for a given tool type,
instead of forcing developers to remember to guard the dereference with
a null check, this commit adds an inline overload that performs the
check for the user on a raw pointer. The API takes in pointers instead
of smart pointers as this method is not intended to take ownership of
the pointer into consideration.
Pull Request: https://projects.blender.org/blender/blender/pulls/126346
* Since displaying this information will only ever happen based on the
active vert, remove the parameter and fetch it inside the function
* Remove the `PBVHVertRef` usage in favor of `ActiveVert`
Pull Request: https://projects.blender.org/blender/blender/pulls/126256
Instead of running a separate loop before processing the brush
deformation, undo the translations from the previous brush steps
when applying the translation. Avoiding this separate loop over
all geometry should improve performance.
Started happening with 422dd9404f that introduced multi-threaded
conversions of src->dst (usually RGBA->YUV) format before encoding
the frame with ffmpeg. But the issue itself is not related to
multi-threading, but rather with the fact that AVFrame objects
started to be backed by an AVBuffer object (as that is needed for
threaded swscale to work).
Turns out, if a frame is backed by AVBuffer object, said buffer
might become "non writable" because it got shared (non-1 refcount).
And that happens with some ffmpeg video codecs, particularly PNG one.
Make sure to make the AVFrame objects writable inside
generate_video_frame. This follows official ffmpeg example
(doc/examples/encode_video.c) that explains why that is needed:
"the codec may have kept a reference to the frame in its internal
structures, that makes the frame unwritable. av_frame_make_writable()
checks that and allocates a new buffer for the frame only if necessary"
Pull Request: https://projects.blender.org/blender/blender/pulls/126317
Just turn on the option for geometry nodes where attributes are
generally expected to be used. We could expose this and other
options at some point too but that requires a bit more thought.
This patch improves the isotropic Gabor noise UI controls such that
variations happen in both directions of the base orientation, as opposed
to being biased in the positive direction only.
Thanks to Charlie Jolly for suggesting this improvement.
This patch optimizes the Gabor noise standard deviation estimation by
computing the upper limit of the integral as the frequency approaches
infinity, since the integral is mostly constant for the relevant
frequency range. The limits are 0.25 for the 2D case and 1 / 4 * sqrt2
for the 3D case.
This also improves normalization for low frequencies, possibly due to
the effect of windowing.
Thanks to Charlie Jolly for spotting the optimization.
Technically the regression was caused by #124472 which made it so
duplicating ImBuf allocates the exact amount of memory needed to
hold the pixels, while before IMB_dupImBuf() would leave the float
buffer over-allocated for images that are less than 4 channels per
pixel.
At the same time IMB_scalefastImBuf() was hard-coded to use 4
channels per pixels, for both byte and float buffers. It did not
crash in Blender 4.1 as it was accessing memory that is over-allocated,
but it also did not generate proper preview.
This fix makes the IMB_scalefastImBuf() to operate on an arbitrary
number of channels in the float buffer.
Pull Request: https://projects.blender.org/blender/blender/pulls/126234
Optimize the Gabor noise texture code with an early exit for points that
are further away from the kernel center. This was already done for the
kernel, but is now being done earlier before computing the weight, so
its computation is now skipped.
Thanks to Charlie Jolly for the suggestion.
In `mesh_join_offset_face_sets_ID()`, `.sculpt_face_set` is
modified but the `finish()` call wasn't present on the
`SpanAttributeWriter`, leading to warnings and potentially broken
data. This is now fixed.
When restoring the orig_position values for certain brushes, we need to
apply similar logic and avoid updating the base mesh if we are sculpting
on a non-basis shape key.
Pull Request: https://projects.blender.org/blender/blender/pulls/126305
This simplifies the feedback shown while using the "Interactive Editor
Docking" experimental feature. It removes the "X" icon shown on areas
that are removed. It does not show an icon for the areas that are left
over and altered. It only shows an icon for the active target area, and
does so without the outline of the icon. The result is a calmer
experience and it is easier to see exactly where the area is going.
Pull Request: https://projects.blender.org/blender/blender/pulls/126304
Introduced in 45d9bfa734
We currently do not invalidate the `active_vert` variable when changing
between different mesh implementations. Therefore, it is incorrect to
assume the value can be turned into a valid concrete reference simply
based on the PBVH type.
Pull Request: https://projects.blender.org/blender/blender/pulls/126299
When the operator was introduced, the program specified the immediate
mode program GPU_SHADER_3D_UNIFORM_COLOR but did not bind a particular
value. This leads to the color used for this circle changing depending
on the last color bound when drawing.
This change makes the color of the circle white, as initially intended,
and adds a darker outline to improve readability.
Pull Request: https://projects.blender.org/blender/blender/pulls/126259