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 CPU implementation of the same mechanism in the GPU compositor
implemented in 57a6832b17. The CPU implementation is a bit more complex
because the CPU compositors stores 4D vectors in color images internally
which can lead to information loss in case of implicit conversion when
the File Output has vector sockets. So what we do is force all vector
inputs to the File Output operation to be color, then save that as 3D or
4D depending on the meta data as well as the original UI socket type.
Pull Request: https://projects.blender.org/blender/blender/pulls/124580
The array-length of a texture view isn't stored at the same location as
the array-base and was forgotten that it was a feature what had to be
supported.
Detected when testing `monster.blend` where the SSS object id wasn't
set and lead to missing materials.
**Before**

**After**

Pull Request: https://projects.blender.org/blender/blender/pulls/124590
When using a python expression, its execution is disabled by
default unless specified differently in the user preferences.
Previously this only produced the error
"Error: Invalid Python expression". However that isn't really the correct error.
Now the error reads "Python restricted for security".
I've added a new flag to the driver `DRIVER_FLAG_PYTHON_BLOCKED` that is set
if the driver can't run because python is blocked
Co-authored by Phillip Oeser
Pull Request: https://projects.blender.org/blender/blender/pulls/124587
When quickly running the "frame step" and "insert key" operators it was possible to
run the key insertion when the depsgraph hasn't yet been updated.
Because the key insertion code took the frame from the scene, but the channel values
from the depsgraph, the inserted keys were appearing to be duplicated from a different frame.
The fix is to ensure an evaluated depsgraph is used, so the correct values are placed
at the correct time.
Pull Request: https://projects.blender.org/blender/blender/pulls/124583
Add the concept of 'active slot' within an Action. This allows
clicking on a slot in the Action editor, to select it and mark it as
'active'.
Note that this does _not_ add support for action slots in
`ANIM_set_active_channel()`, as that function doesn't get enough info
to do that, and refactoring it is not on my wishlist.
RNA property `action.slots.active` can be used to access and set the
active slot in Python. `slot.active` can be used to query the slot's
active state, and is read-only (so that there is one way to set the
active slot).
A panel in the Action editor shows info about the active slot. This
panel is just a minimal UI that shows the name and an icon
representing the idtype of the active slot.
Pull Request: https://projects.blender.org/blender/blender/pulls/124422
This implements the _automerge_ feature which finds nearby end points
during stroke draw and merges the new curve with existing strokes.
New utility functions are added in `geometry` for slightly generalized
functionality. The `curves_merge_endpoints` takes an index map that
describes how to connect curves by index. It performs a topological sort
and reorders connected curves into contiguous ranges. This can be used
with an arbitrary number of connected curves. The tool feature itself
only uses a single curve, based on 2D end point positions.
Unit tests have been added for the curve merge utility function.
Pull Request: https://projects.blender.org/blender/blender/pulls/124459
The (GPv2) fill tool has an "extension" mode to assist with filling
small gaps where strokes don't fully meet.
- Overlay: Draws various helpers during modal fill tool operation, using
the same functions as the render-to-image used for applying the fill
tool.
- Extension lines: Scrolling or page up/down extends the tips of strokes
and draws extra boundary lines to limit filling.
- Extension circles: Press S to toggle the mode. This draws circles
around stroke tips.
- Stroke overlay: This can be enabled in the brush settings
(_Advanced > Visual Aids_) to draw strokes in a simple color on top of
the viewport.
- Extension line collision: Tests for intersections of extension lines
with other lines and with strokes, and cuts them short. Enable in
brush settings (_Advanced > Strokes Collision_).
- Better defaults for extension increments: The values are in Blender
units, and quite arbitrary. Using lower values makes it feel more like
GPv2 in the 2D animation template.
- Draw functions in the `ed::greasepencil::image_render` namespace now
consistently expect coordinates in view space (avoids confusion and
works better for 2D elements).
- Some internal renaming and cleanup (many variable names come from GPv2
and were not very clear).
Pull Request: https://projects.blender.org/blender/blender/pulls/122771
Both the Follow Curve constraint and parenting with the follow curve option
require a property on the Curve ID to be animated if the user wants the
follower object to animate along the curve. However, the fcurve for this
was always getting created as a legacy action fcurve, regardless of whether
the action was actually legacy or not. If the action was layered, this
resulted in the follower object not animating along the path.
The underlying issue was that the code that created the fcurve was using
`action_fcurve_ensure()`, which hadn't yet been updated to work correctly with
layered actions, and thus the fcurve was created as if the action was legacy.
This commit fixes that by updating `action_fcurve_ensure()` to work with
Baklava phase-1 layered actions in limited circumstances, and also
ensuring that the follow curve code passes an appropriate ID RNA pointer
(required to find/create an appropriate Slot).
Pull Request: https://projects.blender.org/blender/blender/pulls/124353
The `resolution` and `nurbs_order` attributes of curves are expected to be `>=
1`. Due to a bug, it was possible that they are initialized to zero: #124534.
This fix adds versioning code to fix the curves that have been written
incorrectly.
Pull Request: https://projects.blender.org/blender/blender/pulls/124539
Previously, it was fairly easy to create built-in attributes which have invalid
values, because attributes were generally zero-initialized. This was especially
problematic for attributes that had certain invariants that Blender relies on
and that should never be zero. For example, the curve resolution should always
be at least 1.
To reproduce the issue, add the `resolution` attribute from the attributes panel
to curves. They had a value of 0 by default. I found this while investigating
#124416.
Pull Request: https://projects.blender.org/blender/blender/pulls/124534
Shortcut and quick favorite operators wouldn't show up in the regular asset
shelf. In the popup the shortcut operators would but they crashed with use
after frees.
Basic issue is that activating view-items by applying the button didn't work
well. That messes with button storage, but also the operator data (like
`uiBut.optype`) is unset after applying, in this case before the context menu
was built.
Instead, activate the view-item directly, and call the activate operator in its
`on_activate()` callback. The button shouldn't call this operator again, so
added a way to attach operators to buttons without calling them.
Seems generally useful to be able to attach an operator to buttons for
tooltips, "Assign Shortcut" and the like, without it being called on button
apply.
Pull Request: https://projects.blender.org/blender/blender/pulls/124466
When Blender started with an extension enabled from a repository that
referenced a directory that didn't exist - creating the directory
and extensions would fail to import the extension.
This happened because the missing state of the module was cached.
Resolve by clearing Python's path cache for the repository after
running install actions which may have created the directory.
Also run importlib.invalidate_caches() when manually refreshing local
extensions to ensure modules cached as missing can be imported if
they have become available.
This change simplifies access to this state by prefetching code.
Previously it had to iterate over screens from `bMain` in code local to
prefetching. Now this state is available to other code in VSE.
In preparation for the topology relax brush which shares much of this
code, this commit renames the file and distinguishes between methods
that will and will not be shared between the topology relax and face set
relax brushes.
Pull Request: https://projects.blender.org/blender/blender/pulls/124563
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
`UnifiedPaintPanel.get_brush_mode()` may return `None` when the current
tool doesn't use brushes. In the specific case of primitive tools
("Line", "Polyline", "Arc", etc) in grease pencil draw mode, the tools
actually should use brushes, but this isn't implemented properly yet
with brush assets. Still handle this case cleanly.
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