This commit prevents writing to the mesh when sculpting on a non-basis
shape key. Prior to this, we incorrectly were applying changes to the
base mesh, even though those changes were not visible with the shape
keys still active, causing new shape keys to have a copy of the deformed
mesh data.
Pull Request: https://projects.blender.org/blender/blender/pulls/126107
- Use `Vector::remove_if` rather than custom "filter" functions copying
data to new vectors.
- Pass `float3` by const reference.
- Reorder arguments to pass constant/operation-global arguments first,
also using consistent order for mesh data arrays.
- Use const for some `Object` arguments.
- Initialize zero `float3` in a simpler way.
- Simplify neighbor averaging by checking for empty vectors first.
- Use more standard grids index variable names
- Remove `BLI_NOINLINE` from functions called for every element, more
consistent usage in general.
Pull Request: https://projects.blender.org/blender/blender/pulls/126145
The grid geometry creation incorrectly tagged the mesh with no loose edges
or vertices, breaking invariants of the caches that are relied on elsewhere.
The common code which writes out attribute data was seemingly not
performing the right sequence of calls for the UsdUtilsSparseValueWriter
to actually write sparse data.
See PR for a test file and .usda files produced with 4.1 and now with
this change applied.
Pull Request: https://projects.blender.org/blender/blender/pulls/126113
This includes the port of the edit edge shader to the new
primitive expansion API, removing split codepath and
code duplication.
Some of the shader code is duplicated for keeping the
legacy engine untouched.
Rel #102179
Pull Request: https://projects.blender.org/blender/blender/pulls/125921
Because the previous fix stopped creating these VBOs when they
would be empty we need more null checks. Alternatively still
creating them but not binding them might be a better solution
but just adding null checks seems like the simpler approach
right now.
Pull Request: https://projects.blender.org/blender/blender/pulls/126073
Assert in debug build, allocated vertex buffer has garbage data when
total points in the drawing are zero, Nothing is copied to vertex buffers
from `copy_transformed_positions()`. To fix the crash, exit early when
the number of points is zero and execute `DRW_shgroup_call_no_cull`
macro when batch is non-null.
Pull Request: https://projects.blender.org/blender/blender/pulls/126134
The primitive tool uses the `CurvesGeometry::resize` function which
leaves the end of the range uninitialized. The
`fill_attribute_range_default` function must be used to ensure all
existing attributes are initialized for the new points.
Pull Request: https://projects.blender.org/blender/blender/pulls/126127
Lift certain incorrect assumptions about the order of vertices in
an OBJ file when processing vertex colors, which could lead to
missing or randomly permuted colors.
Replaces the list-of-blocks representation, attuned to assumptions
that the verts in an object form a contiguous subrange, with a
flat array better suited for random-access.
Co-authored-by: scurest <scurest@users.noreply.github.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/126065
Part of #118145.
As noted in a comment, this algorithm has O(n^2) runtime which is quite
bad. Ideally we would be able to look into a better solution at some point,
but I just refactored the existing algorithm here.
If velocity attributes are the only thing being animated, we would fail
to add the cache modifier. This prevents velocity attribute data from
being updated as the timeline changes.
This is a rather rare case. Typically if velocity is changing that would
imply the positions of the mesh are also changing, and the positions
will add the modifier correctly in that case.
Pull Request: https://projects.blender.org/blender/blender/pulls/126105
We now deform the active shape key and other original data while deforming
the evaluated/deformed positions, rather than before, when we delayed that to
afterwards and affected the entire mesh no matter the area sculpted. This is all
handled by `write_translations` now.
When a curve instance did not have a "opacity" attribute, the default would be 0.
This meant that when creating Grease Pencil layers from scratch, the user
would need to manually write a "opacity" attribute.
Now the default value is 1, so that this step is no longer necessary.
This fixes two things:
* Pass the evaluated object into `BKE_object_as_kdtree` instead of the original
one. `BKE_object_as_kdtree` uses functions on the object which are only
expected to be executed on evaluated objects, such as
`BKE_object_get_mesh_deform_eval`. Note that this is the only place where
`BKE_object_as_kdtree` is used.
* Tag depsgraph at the end of setting parent. This way,
`BKE_object_get_evaluated_mesh` will return the correct mesh instead of null.
It was returning null because it the object is not in a fully evaluated state
if it just has been tagged as requiring an update.
Pull Request: https://projects.blender.org/blender/blender/pulls/126086
Part of #118145.
Structure the sampling code more like the brush code, processing the
distances for all vertices in a node at the same time. However, because
this is such a common code path, I compromised a bit on the code's
simplicity to improve performance, mostly by avoiding the use of more
local arrays like we often do for brushes, and also by skipping loop
iterations when the factor is zero. Avoiding the square root for filtered
vertices had a large performance impact of about 5-10% for example.
This is the last use of the sculpt brush test functions and structs which
allows removing them, completing a large part of the overall refactor.
The newly added `_sq` versions of the distance functions are deduplicated
from the non-square versions by separating the square roots to a separate
loop at the end. In my testing that had a ~1% performance cost, though
with variable timing results. I hope that smaller nodes will remove
that cost in the future.
Some rough numbers with the brush benchmark file:
Before: 0.471->0.476s
Without the filtered sqrt: ~0.5-0.53s
After: ~0.473-0.475s
Pull Request: https://projects.blender.org/blender/blender/pulls/126058
This patch introduces a new experimental option for the new CPU
compositor under development. This is to make development easier such
that it happens directly in main, but the compositor is not expected to
work and will probably crash.
Pull Request: https://projects.blender.org/blender/blender/pulls/125960
Curves selection didn't take cyclic into account, so when using box/
circle/lasso selections they won't trigger if only the "closing" segment
on a cyclic curve is touched. Now the code properly handles those
situations.
Pull Request: https://projects.blender.org/blender/blender/pulls/125900
Blender crashes when adding any Color compositor node when both the
viewport and the interactive compositors are active at the same time.
This is caused by a threading issue where both threads try to compile
the same GPU material at the same time.
To fix this, we protects GPU material pass compilation using a mutex.
Pull Request: https://projects.blender.org/blender/blender/pulls/126084
Both the operator and the brush have an "invert" setting for the fill
tool. The operator property is toggled by both editor keymap and modal
keymap, while the brush setting is toggled from UI. Both settings are
combined (i.e. inverting both works like regular fill again).
Pull Request: https://projects.blender.org/blender/blender/pulls/126042
This issue occurred only on Mac which has to circumvent
geometry shaders lacking support for them.
This patch reverts the vertex shader for Mac devices to
how it was before f9ea64b0ba. (and uses the frag shader from before that commit)
In order to communicate that to the user I added a label
in the GUI when the platform is Mac.
Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/125967
These functions used the term `curves` when we try to use the
term `strokes` at the user level. Renaming the functions and
the descriptions to be more consistent.
This changes the behavior when deleting the last key of an FCurve on layered actions.
Previously the FCurve would continue to exist, whereas now it is deleted.
This makes it consistent with legacy actions.
I modified the "Clear Keyframes" operator in this PR as well to make it work with layered actions.
Pull Request: https://projects.blender.org/blender/blender/pulls/125327
Support merging by distanced for UV's with shared underlying geometry.
This can be useful for welding seams & cleaning up holes without
merging nearby UV's from disconnected vertices.
Ref !124221
The preview is only supported with deform modifiers which are
only supported for Mesh sculpting, so just write that implementation.
Also remove SculptSession::vert_positions which is now unnecessary.