Currently we calculate neighbors for vertices in batches. The idea is
to access topology data all at once, storing the result in a local node-
sized vector that can fit in CPU caches. Currently we use
`Vector<Vector<int>>` for storing the neighbors, and that works well
enough when the number of neighbors fits into the inline buffer, but
whenever it doesn't it causes many vector reallocations and scatters
the neighbor storage in arbitrary memory locations.
This commit changes to using a `GroupedSpan` to store the neighbors, in
other words contiguous storage split into groups by an array of offset
integers. This reduces local per-vertex memory usage by 20 bytes and
makes memory access more predictable.
I observed a 1.39x performance improvement for the mesh smooth filter
on a large triangulated mesh, and a 1.14x improvement for a mesh of
mostly quads. In the brush benchmark on a quad mesh the difference I
observed is a small slowdown. I'm not sure why that happens but I trust
the results from the filter a bit more.
Resolves#130797.
Pull Request: https://projects.blender.org/blender/blender/pulls/130941
For me on Mac picking "Video Editing" template in startup dialog
now consistently crashes, due to bToolRef being null.
Looks like other code places check for tool being null before trying
to use it; `sequencer_main_cursor` however was not.
Pull Request: https://projects.blender.org/blender/blender/pulls/131358
The BLI bicubic interpolation function with border boundary is wrong
around edges. It returns zero, where interpolated values should exist.
This is due to a wrong early exit condition, where only a 2x2 window is
assumed instead of the 4x4 window considered by bicubic interpolation.
To fix this, assume a 2 pixel region in the early exit condition for
both directions.
Pull Request: https://projects.blender.org/blender/blender/pulls/131320
Avoid rebuilding BVH trees when meshes are copied.
Similar to the other uses of the shared cache system,
this can arbitrarily improve performance when meshes
are copied but not deformed and BVH building is the
main bottleneck. In a simple test file I got a 6x speedup.
The amount of code is also reduced and the system is
much simpler overall-- built out of common threading
patterns like `SharedCache` with its double-checked lock.
RAII is used in a few places to simplify memory management
too.
The downside is storing more `SharedCache` items in the
mesh runtime struct. That has a slight cost when copying
a small mesh many times, but we have ideas to improve that
in the future anyway (#104327).
Pull Request: https://projects.blender.org/blender/blender/pulls/130865
The issue is that the conversion to quaternions seems to need normalized matrices
and even then is not always safe. It's simplest to use the existing `*_safe` method here for now.
Related to reports #129445 and #129485.
Related to PR #131296.
Pull Request: https://projects.blender.org/blender/blender/pulls/131297
The call to `sculpt_apply_texture` is not thread safe and as such is a
major bottleneck in brush stroke processing. In previous versions, we
avoided calculating this if the vertex position was outside of the brush
radius.
To fix this, we add a check for the factor already being 0 and prevent
further texture calculations.
Pull Request: https://projects.blender.org/blender/blender/pulls/131256
Splitting the write-loop into stages makes it easier to understand, debug and time.
All the complex filtering in `gather_local_ids_to_write` is the same as before.
With this and some previous refactors, it's also much easier to have a clean `write_id`
function that should also work for embedded IDs later on.
Pull Request: https://projects.blender.org/blender/blender/pulls/130983
Previously area & region types were not set when in background mode,
with 172e9c5b83 that changed. Apparently this causes a bunch of logic to
run that shouldn't run in background mode. So make sure we don't set the
types in background mode. Also don't run region polling in background
mode, since that would cause another crash if region types are not set
(as done in background mode).
Some non-functional changes:
* Use the C++ variant of `BLI_uniquename_cb`.
* Use `StringRef` when passing strings as parameters.
* Don't pass default name as parameter. Expect name in
`unique_node_name` to not be empty.
The region type isn't set yet when polling regions just after file read. As a
result, the polling state cannot be evaluated correctly, and `init()` may end
up being called without the previous required call to `on_poll_success()`.
Ensure the region type is set earlier, right at the beginning of screen
initialization after file read. This way all further area/region
referesh/re-init (confusingly called "init") logic can assume it's set.
Pull Request: https://projects.blender.org/blender/blender/pulls/131050
When "sound scrubbing" was turned on, it would stop audio playback if
you managed to start the timeline before the "sound scrubbing" audio
preview had finished.
This was trying to smooth out the playback but could instead lead to
worse frame pacing. It was also masking some bugs in the PulseAudio
backend that has been fixed.
Previously changing audio devices or settings while Blender was playing
back could lead to crashes or the playback state between Blender and
Audaspace de-syncing.
The order of curves in a Grease Pencil drawing defines the
order in wich they are rendered, so it's important to be
able to change the order. Currently, there is not easy way
to do this from python.
This adds a new `reorder_curves` and `reorder_strokes`
function to reorder the curves in the curves geometry.
The function takes in an array of indices that are the
new indices for the curves (e.g. an index map).
`reorder_curves(new_indices=[...])`
Pull Request: https://projects.blender.org/blender/blender/pulls/130331
The `Action::last_slot_handle` field is set to a high-ish value, to
disambiguate slot handles from array indices.
Slot handles are opaque integers, and are just used to find a slot
with that particular handle. Its exact value is irrelevant; Blender
only ensures that slot handles are never reused within the same
Action.
This particular value was obtained by taking the 31 most significant
bits of the TentHash value (Nathan's hash function) for the string
"Quercus&Laksa" (Sybren's cats).
Pull Request: https://projects.blender.org/blender/blender/pulls/131310
There seems to be an issue inside Intel OpenGL driver of legacy
platforms that fails to link `gpu_shader_sequencer_strips`.
Uniform locations are used to fix an specialization constants issue.
This PR only adds the uniform location when the shader can be
specialized. It is unclear what is actually failing inside the driver
but there are other issues with the driver.
Pull Request: https://projects.blender.org/blender/blender/pulls/131293
The BLI wrapmode variant of nearest interpolation for border boundary is
wrong for coordinates between [-1, 0]. That's because the negative
comparison in wrap_coord is done on the integer rounded coordinates,
which will be zero in this case, so the condition will not fail. To fix
this, do the comparison on the original coordinates instead.
Pull Request: https://projects.blender.org/blender/blender/pulls/131306
I'm not quite sure what was wrong about the old implementation, but it was confusing
because it also depended on the user counts of drawings and other more high level
functions like `duplicate_layer`.
This fix just reimplements the functionality using the grease pencil API that we use in
more places in geometry nodes.
Pull Request: https://projects.blender.org/blender/blender/pulls/131291
Adds support of NURBS weights or "rat bspline" in OBJ terms.
Tries to guess Blender knot mode better:
- Detects and closes loops. This decision is based on geometry only. No metadata is provided in OBJ for this, so importer has checkbox to disable this feature.
- Bezier knot mode allows to import circles and circular arcs.
Pull Request: https://projects.blender.org/blender/blender/pulls/131169
When copying from/to depth stencil images the aspect of the image was
set incorrectly. It pointed to only one aspect of the full image when
building resource links, which could lead to incorrect decisions in the
driver.
Found when researching #131269
Pull Request: https://projects.blender.org/blender/blender/pulls/131298
This applies the fix from 98334b8f7d to the c++ implementation.
Two notes:
* We need to work towards unifying these implementations which would have avoided this bug.
* In the C++ implementation, one can't use `math::dot` and `math::normalize` for quaternions
where this function is implemented, because of include dependency order.
Both these things should be resolved, but right now correctness has priority for me.
Pull Request: https://projects.blender.org/blender/blender/pulls/131296