Use `blender::Stack` instead of `BLI_Stack`. Theoretically this can
improve performance because it makes use of inlining to remove function
call overhead and give the compiler more information. I observed a build
time improvement of about 4%, from 1156 to 1113 ms with 30k cube objects.
Notably, now `deg_graph_flush_visibility_flags` doesn't call any
non-inlined functions.
Pull Request: https://projects.blender.org/blender/blender/pulls/137355
This commit renames the `types.hh` file to `brushes.hh` as an attempt to
make brush implementations more independent and begin to unwind and
remove much of the logic in `sculpt.cc`.
As a first step, this moves the node mask calculation exposed for the
plane brush into `plane.cc` and exposes the function header into
`types.hh`.
Pull Request: https://projects.blender.org/blender/blender/pulls/137020
They are actually already some literals with the `f` suffix
that are in our shader codebase and we never had problem in
the past 5 years (or even 8 years).
So I think it is safe to do and improves convergence of codestyles.
Pull Request: https://projects.blender.org/blender/blender/pulls/137352
The goal is to log information about which closures are evaluated where. This
information is not exposed in the UI yet, but will be needed to be able to debug
the evaluation and inspect socket values within closures.
Pull Request: https://projects.blender.org/blender/blender/pulls/137351
I observed allocation becoming a bottleneck when building the depsgraph
with scenes with many simple data-blocks. One of the main culprits was
the struct that encodes relations between nodes in the graph.
Instead of allocating each `Relation` with a separate allocation call,
combine them into a `LinearAllocator`. That is must faster because it
allocates in large chunks and just bumps an offset on each allocation.
In a test file with 30 thousand cube objects, I observe a 1.18x
improvement in depsgraph evaluation time, from 1370 to 1163 ms.
The depsgraph isn't completely re-allocated when it's rebuilt, so the
allocator added in this PR has to be cleared manually. In the future,
it can be used for other structs or potentially strings.
Pull Request: https://projects.blender.org/blender/blender/pulls/137303
A couple of memory leak fixes for the vulkan backend.
We increment the submission_id on render_graphs upon reset. This
triggers cleanup of anything tracked as a VKResourceTracker. Notably
uniform buffers created for push constant fallbacks. This fixes a memory
leak that was accumulating VKUniformBuffers every frame without cleaning
them up.
Reset resource pools when a swapchain image is presented. This ends up
calling vkResetDescriptorPool, freeing up descriptor set resources. This
fixes a memory leak that was accumulate descriptor sets and pools over
time without freeing them.
Pull Request: https://projects.blender.org/blender/blender/pulls/137305
On certain platforms the 3d cursor wasn't visible. The reason was that
the shader read garbage in `gpu_attr_1_fetch_unorm8` and interpreted the
data to be packed, resulting in loading incorrect colors.
Pull Request: https://projects.blender.org/blender/blender/pulls/137336
Point count is missing in object and sculpt mode for Curves object.
Added an extra if block that handles this case. Added a new variable
`totcurvepoints` to track curve points count. Otherwise it is aggregated with
other points count (eg. mesh) which result in wrong number in status bar.
Pull Request: https://projects.blender.org/blender/blender/pulls/137199
As mentioned in #132028, search box is intentionally skipped for lib
override hierarchy view mode of outliner. But search filtering from
previous mode still builds the tree with searched elements. Added a new
function that checks the outliner view mode. If it's lib
override-hierarchy, skip search filtering.
See images attached in PR description.
Pull Request: https://projects.blender.org/blender/blender/pulls/137086
Remove long-deprecated constraints that will likely never be
implemented in this form.
- Rigid Body Joint Constraint was removed in 2.80, but some references
remained in the code. Versioning code was written that tried to
remove them on load, but since constraint initialization code sets
the type to CONSTRAINT_TYPE_NULL before versioning gets a chance,
the versioning code ended up never running. This has all been
removed.
- Python/Script Constraint never worked since 2.50 and showed an error
message in the UI panel.
These constraints now load as 'null' constraint, as seems to be
(looking at the code) the way that Blender currently deals with
removed constraint types. These still show up in the outliner and
python API, but have no UI panel. Removing such constraints completely
will be left for another time, as it is beyond the scope of removing
these two specific constraint types.
Pull Request: https://projects.blender.org/blender/blender/pulls/136672
When a stroke has a gradient fill material that starts with a color with
zero alpha, the tint modifier would behave as if it's not effective at
all, this is caused by referencing source material color only with the
starting color in this case, and since the alpha is zero, the tint is
applied wrongly. Now use average color of start and end color of the
gradient to mix with the tint modifier color.
Note that this isn't technically correct still, since material gradient
is computed in the shader, and tint modifier isn't able to get the
acutal fill color at a given vertex (especially for the radial gradient
case) however the result of this patch looks visually good enough, and
users can always set all alpha to 1 when they feel the color is off.
Pull Request: https://projects.blender.org/blender/blender/pulls/134549
Implement ellipse gizmo for the ellipse mask node. Behavior and implementation are similar to the box node with the exception that corners are always visible.
Pull Request: https://projects.blender.org/blender/blender/pulls/137115
Only geometry nodes is allowed to have no active output (the group output node acts as an explicit node tree output). The previous fix only considered geometry nodes and compositor cases, which was not enough.
Pull Request: https://projects.blender.org/blender/blender/pulls/137288
WebP images can be at most 16383x16383,
however saving sizes which overflowed an integer would crash.
- Early exit with an error when the image is too large.
- Replace integer offsets with size_t.
The internal logic for this operator has become broken over time.
- Relative paths could expand using, then be made relative
using the blend file - but only for directories (not files).
- A trailing slash was added for directories (noted as important),
but then ignored when the relative option was disabled.
Simplify the logic here:
- Use the same relative path logic for all paths.
- Add the trailing slash for the directory based on the RNA type
instead of checking if the underlying path is a directory.
- Remove the logic that stripped the file-name off non-directories
since the file selector doesn't allow a filename to be set
when selecting a directory.
Correct invalid mixing of different flag types,
this happened not to cause any problems but it's error prone.
There is no need to set the "required" flag for return values.
Based on it's usage it wasn't clear if this supported a relative prefix.
Enable the flag & add comments clarifying the file-selector
will expand the relative prefix.
Don't add directories with the relative prefix to the FSMenu.
While mostly harmless, causes unnecessary checks on startup
and asserts with debug builds.
Prior to this commit, the set of brushes that ignore the gravity brush
effect and the set of brushes that dim the display of the related
options were mismatched.
Pull Request: https://projects.blender.org/blender/blender/pulls/137309
The update function expanded a relative paths and ensured a slash.
Making "safe" could even change the blend file path,
causing the expanded path not to match the blend file path.
There is no need to treat this path as a special case
which is handled differently from other preferences.
Some paths in Blender support the `//` prefix for blend-file relative
paths however this is not communicated anywhere.
Support declaring this with a new flag which can be applied to filepath
& dirpath typed properties.
This is used to:
- Show red-alert when "//" are used in paths which don't support a relative prefix.
- Show a warning in the tooltip that the relative suffix is used when unsupported.
- Python warns if this prefix is ever used in an assignment or
function argument.
Resolves#133456.
Ref !137060
Depending on internal details of how Blender is run, attempting to load
elements from the asset library may either execute as synchronous &
blocking or asynchronously.
When executing a script in background mode, prior to this commit,
operators that are dependent on the asset system will not execute
correctly due to the loading not being complete.
Busy-waiting for this by repeatedly calling the operator over and over
again in python does not resolve. To match behavior of other operators
when called from python scripts such as the quadriflow remesh, this
commit changes the `brush.asset_activate` operator and dependent code to
force a blocking call instead of optionally using the wmJob background
abstraction system.
Related to #117399
Pull Request: https://projects.blender.org/blender/blender/pulls/134203
Prior to this commit, whether or not a brush was capable of using
certain options in Sculpt mode and whether or not these properties would
be shown to the user was spread across a number of files and
inconsistently applied.
This commit moves most of these checks to the bke::brush namespace so
that we have a single source of truth for these checks.
In total this commit:
* Changes all BrushCapabilitiesSculpt methods to use the equivalent
bke::brush function
* Removes brush type macros
* Renames BKE_brush_supports_secondary_color to fit the new pattern
* Refactors inverted logic for the `direction` property
Pull Request: https://projects.blender.org/blender/blender/pulls/137249
Simplifies implementation of curve tangent calculation for polylines
and evaluated curves. Loop now re-uses results from previous
iteration and adjusts for 0-length segments in the same loop,
removing need for a conditional extra loop.
Performance gain comes from removing a normalization and difference per
iteration. Curves with 0-length segments can benefit further.
For a single curve containing 860K points containing 0-length segments
measured improvement was 1.43x (from 33ms to 23ms).
Test does not utilize threading since it's threaded for curves, adding
threading to single/large curves might be better but would require
the current dependency to previous iterations to be removed.
Pull Request: https://projects.blender.org/blender/blender/pulls/137182
Only consider buttons with matching types as matching, when comparing
them between redraws to preserve active button state.
We could have avoided a bunch of issues in the past with this. They are
becoming quite common since we use more spacers and invisible elements
to enable certain behavior. Especially with nodes this caused some issues
recently.
Further code in `ui_but_update_old_active_from_new()` assumed matching
button types resulting in undefined behavior.
Fixes heap-buffer-overflow ASAN crash since 8ec9c62d3e.
Steps to reproduce were:
- Open [emitter-closures.blend](/attachments/e7689016-064c-4390-9f02-c2665b2a6a6b)
- Ctrl+Shift+Click on the header of the "Evaluate Closure" node
Pull Request: https://projects.blender.org/blender/blender/pulls/136943
Gizmos that contain 3D parts, like the rounded lines of the "Rotate"
gizmo, have a fairly small hit size that make it hard to grab with a
tablet pen. This PR just increases the radius around the pointer
position while using a pen.
Pull Request: https://projects.blender.org/blender/blender/pulls/136847
This is helpful for #133123 where we want to use std::unique_ptr for
a struct with a definition that's ideally unavailable in sculpt_intern.hh.
Just adding the constructor changes the initialization of the struct,
so I added explicit defaults for the struct's fields.
Pull Request: https://projects.blender.org/blender/blender/pulls/137233
With commit bf18e8f814 the Properties editor can filter categories.
There is versioning code to ensure that any existing areas show all by
default. But newly-created Properties areas start without any. For
example, start with Factory Settings and then change the 3D Viewport to
a Properties editor and it will be blank. I'm assuming this is not
intended behavior so this PR makes new editors start with all tabs
shown.
Pull Request: https://projects.blender.org/blender/blender/pulls/137237
Some OpenXR platforms do not support OpenGL or Vulkan. To support these
platforms we use a bridge. Blender still renders in OpenGL/Vulkan, but
will copy the render result into a D3D11 swapchain.
OpenGL doesn this by importing the D3D11 swapchain into the OpenGL
context and perfor OpenGL calls to update the swapchain. However for
vulkan that could lead to construct 3 context for OpenXR
- Blender GPU Context
- OpenXR D3D Context
- New context that imports the Blender render result and the OpenXR
Swapchain image and copies them.
Due to Direct3D limitations importing into a vulkan context has known
issues (driver + extensions). Secondly we are not sure if we are running
on the same device as the OpenXR swapchain. The solution provided with
this PR is to only support CPU data transfers.
**SteamVR using d3d bridge**
SteamVR normally would use the Vulkan binding. But by changing the binding
priority in code you can make it select the D3D bridge.
<img width="1518" alt="Screenshot 2025-04-10 114534.png" src="attachments/f856bb2b-9ad5-4bb2-9cfd-a1412da9edd1">
It has been tested and validated to work using Mixed reality portal as well.
Pull Request: https://projects.blender.org/blender/blender/pulls/137264
The `GeoTreeLog::ensure_evaluated_gizmo_nodes()` reran the iteration
over the tree loggers to add the node ids for the evaluated gizmo.
This wasn't an issue because `GeoTreeLog::evaluated_gizmo_nodes` is
a set, so nothing changed when trying to re-add the same ids.
This sets `reduced_evaluated_gizmo_nodes_` to `true` (probably an
oversight when this got added) so that the function returns early when
called again.
The `Group ID` input on every node is a hidden value except for the
Accumulate Field node. This patch just hides that value to bring it
inline with the other nodes, as different single values are meaningless.
Pull Request: https://projects.blender.org/blender/blender/pulls/137160