Commit Graph

99156 Commits

Author SHA1 Message Date
Harley Acheson
d1219b727c Fix #97530: Overlapping Content Causing Region Scrolling
Selecting filter in NLA/Graph Editor causes scrolling in the region
below it. This PR makes `UI_but_ensure_in_view` not occur if the block
has UI_BLOCK_CLIP_EVENTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/107404
2023-04-28 19:06:30 +02:00
Jacques Lucke
7d38cef6d1 Geometry Nodes: use new BitGroupVector to find attribute propagation sets
A `BitGroupVector` is a compact data structure that allows storing multiple
bits per element, for example 5 bits per vertex. The implementation is
mostly just a wrapper around `BitVector`. There is some additional logic
to make sure that the bit span of every element is bounded (according
to the `is_bounded_span` function). This makes it more efficient to operate
on groups as a whole (e.g. `or` one group into another). In some sense,
this data structure can also be interpreted as a 2D bit array. Functions
like `append` can be added when they become necessary.

The new data structure is used to replace some `MultiValueMap` in
geometry nodes. This simplifies the code.
2023-04-28 16:54:43 +02:00
Hans Goudey
d6c61ccadc Cleanup: Extract function to make extend node declaration 2023-04-28 10:24:32 -04:00
Hans Goudey
098e58ea24 Attributes: Allow attribute API to create non-deleteable attributes
This can be useful to allow creating these core attributes with shared
arrays. Otherwise CustomData has to be used directly, which is nice
to avoid. This was done in e45ed69349, but not everywhere.
2023-04-28 10:24:32 -04:00
Jacques Lucke
fee9a3796c Cleanup: Add not equal operator to compute constext hash 2023-04-28 10:24:32 -04:00
Jacques Lucke
ac1827edda BLI: Add utility method to check if CPPType matches multiple types 2023-04-28 10:24:32 -04:00
Hans Goudey
67700ced54 BLI: Add "take front" and "take back" methods to bit spans
This is consistent with `Span`, and also allows returning a bounded
bit span when taking the front of an existing bounded span, which
can simplify using optimized bit processing.

Pull Request: https://projects.blender.org/blender/blender/pulls/107441
2023-04-28 16:14:03 +02:00
Germano Cavalcante
6beaf1dc7d Fix error in recent navigation refactor
Error in 67203c0ec8

The modal zoom operation was always being activated.
2023-04-28 11:11:13 -03:00
Hans Goudey
5a1013f6a8 Fix #106289: Copy optimal display edges in mirror, array modifiers
These aren't propagated as attributes since interpolating them with the
generic rules often gives strange results, and they're intended to as
an optimization. Though theoretically it would be nice if this
copying became more generic in the future.
2023-04-28 10:05:57 -04:00
Hans Goudey
b87ccedd75 BLI: Add bit span operations and bounded bit spans
Most of this patch is by Jacques Lucke, from the simulation branch.

This commit adds generic expression evaluation for bit spans, helping
to generalize the optimizations that avoid processing a single bit
at a time. Operations like "for each 1 index", "or", and "and" are
already implemented in this pull request. Bits in full integers are
processed 64 at a time, then remaining bits are processed all at once.
The operations allow implementing a `copy_from` method for bit spans.

Currently this optimized evaluation is only implemented for simpler
bounded bit spans. Bounded bit spans have constraints on their bit
ranges that make them more efficient to process. Large spans must start
at the beginning of the first int, and small spans must start and end
within the first int.

Knowing these constraints at compile time reduces the number of edge
cases in the operations, but mainly allows skipping alignment between
multiple spans with different offsets.

Pull Request: https://projects.blender.org/blender/blender/pulls/107408
2023-04-28 15:43:34 +02:00
Germano Cavalcante
d74f3895e7 Overlay: do not draw grids with undefined units
The `ED_view3d_grid_steps` function creates steps of units other than
those defined in `unit.c`.

This seems to be used for grid drawing in order to draw a unit after
the miles (in this case it would be something like 10 miles).

But that doesn't seem right as it's an undefined unit.

Therefore, the solution is not to create these different unit values.

The change in the overlay is that the softer grid that used to
correspond to 10 miles now corresponds to mile.

Pull Request: https://projects.blender.org/blender/blender/pulls/107405
2023-04-28 14:38:38 +02:00
Germano Cavalcante
67203c0ec8 3D View: Refactor navigation operators
No functional changes.

Merge the modal callbacks of the `VIEW3D_OT_move`, `VIEW3D_OT_rotate`
and `VIEW3D_OT_zoom` operators into a single simplified
`view3d_navigate_modal_fn` callback.

Deduplicate code for initialization, also the code for finalization and
the code to get the `event_code`.

Improve support for operation switching by the existing (but unused)
modal keymap items `VIEWROT_MODAL_SWITCH_ZOOM`,
`VIEWROT_MODAL_SWITCH_MOVE` and
`VIEWROT_MODAL_SWITCH_ROTATE`.

Pull Request: https://projects.blender.org/blender/blender/pulls/106279
2023-04-28 14:11:00 +02:00
Campbell Barton
ff0cf45bc2 Fix potential buffer overflows from invalid string size arguments
- FILENAME_MAX was used when the output was later limited by FILE_MAX.
- Some were passing in incorrect/dummy sizes in a couple of places.
2023-04-28 21:49:05 +10:00
Campbell Barton
ba978e1b68 Fix potential buffer overflow in internal pointcache logic
Buffer lengths in internal point-cache logic offent didn't match
the actual buffer size.
2023-04-28 21:45:19 +10:00
Campbell Barton
e462e20e21 Fix buffer overflow in BKE_image_ensure_tile_token use
BKE_image_ensure_tile_token took only the file name component but used
FILE_MAX to limit the input buffer.

Split this function in two, one that takes the full path as this is the
most common usage and another which takes only the filename.
Both now take a string size argument.
2023-04-28 21:40:04 +10:00
Campbell Barton
6701d24084 BLI_path: add string size arguments to sequence encode/decode functions 2023-04-28 21:33:38 +10:00
Jacques Lucke
bfcc2b1c4c BLI: add utility methods for serialization
This simplifies the code that works with the `BLI_serialize.hh` header.
The various `lookup` methods do a linear search. If there are only a
few elements that can even be faster than building the map first.
In the future it might be nice to transparently build and cache the
map internally if necessary.
2023-04-28 13:30:26 +02:00
Campbell Barton
5c184525ed Fix 3D text selection & cursor mismatch with text-on-curve enabled
The cursor & selection were shifted down in local (object) space,
ignoring character rotation.
2023-04-28 21:15:38 +10:00
Campbell Barton
6586c4c73f Fix negative index in text cursor drawing
Recent changes to cursor drawing read an index of -1 when there was no
text.
2023-04-28 21:14:07 +10:00
Jacques Lucke
b4d914b676 BLI: support weak users and version in implicit sharing info
The main goal of these changes is to support checking if some data has
been changed over time. This is used by the WIP simulation nodes during
baking to detect which attributes have to be stored in every frame because
they have changed.

By using a combination of a weak user count and a version counter, it is
possible to detect that an attribute (or any data controlled by implicit
sharing) has not been changed with O(1) memory and time. It's still
possible that the data has been changed multiple times and is the same
in the end and beginning of course. That wouldn't be detected using this
mechanism.

The `ImplicitSharingInfo` struct has a new weak user count. A weak
reference is one that does not keep the referenced data alive, but makes sure
that the `ImplicitSharingInfo` itself is not deleted. If some piece of
data has one strong and multiple weak users, it is still mutable. If the
strong user count goes down to zero, the referenced data is freed.
Remaining weak users can check for this condition using `is_expired`.

This is a bit similar to `std::weak_ptr` but there is an important difference:
a weak user can not become a strong user while one can create a `shared_ptr`
from a `weak_ptr`. This restriction is necessary, because some code might
be changing the referenced data assuming that it is the only owner. If
another thread suddenly adds a new owner, the data would be shared again
and the first thread would not have been allowed to modify the data in
the first place.

There is also a new integer version counter in `ImplicitSharingInfo`.
It is incremented whenever some code wants to modify the referenced data.
Obviously, this can only be done when the data is not shared because then
it would be immutable. By comparing an old and new version number of the
same sharing info, one can check if the data has been modified. One has
to keep a weak reference to the sharing info together with the old version
number to ensure that the new sharing info is still the same as the old one.
Without this, it can happen that the sharing info was freed and a new
one was allocated at the same pointer address. Using a strong reference
for this purpose does not work, because then the data would never be
modified because it's shared.
2023-04-28 12:05:00 +02:00
Philipp Oeser
19aaf980d5 Cleanup: format 2023-04-28 11:46:25 +02:00
Omar Emara
5fa8f7746c Realtime Compositor: Prioritize Viewer output node
This patch changes the priority for choosing the active output to
prioritize viewer nodes as opposed to composite nodes. This is done to
better work with the workflow of using the Connect To Viewer operator
and better match the expected behavior from users.
2023-04-28 08:47:44 +02:00
Hans Goudey
1777f40c27 Cleanup: Remove global mesh threading size macro
The grain size depends on the algorithm, it doesn't make sense to use
the same value for multiple areas just because they relate to `Mesh`.
The comment mentions OpenMP which isn't used anymore.

Also remove an unused forward declaration.
2023-04-27 22:46:07 -04:00
Campbell Barton
a1e472615f BKE_unit: assert index access is in range 2023-04-28 12:23:29 +10:00
Campbell Barton
0c27c6f876 Cleanup: spelling in comments
Also remove redundant comment.
2023-04-28 12:23:29 +10:00
Campbell Barton
3ad82ec5a4 Refactor: path normalize now collapses multiple '..' directories at once
- Avoid a separate memmove call for each `..`.
- Avoid ambiguous path stepping, where separator literals
  needed to be checked to avoid fence post errors.
- Correct & update the doc-string.
2023-04-28 12:23:29 +10:00
Jesse Yurkovich
d36af92e5f USD: Release ImBuf objects during export
ImBuf objects need to be released after they are acquired.

Would cause a memory leak otherwise.

Pull Request: https://projects.blender.org/blender/blender/pulls/107361
2023-04-27 22:35:28 +02:00
Hong Shin
38ad653d77 Cleanup: prefer nullptr inside extract_mesh.hh
Replaced NULL with nullptr [std::nullptr_t].

Pull Request: https://projects.blender.org/blender/blender/pulls/107413
2023-04-27 22:07:43 +02:00
Harley Acheson
1d2eab9ab3 VFont: Corrections to Cursor When on Curve
Corrections to transformation and placement of the text cursor when the
text is being deformed by a curve.

Pull Request: https://projects.blender.org/blender/blender/pulls/107307
2023-04-27 22:07:03 +02:00
Omar Emara
59b6e8900f Fix #106965: HSV/HSL conversion differ from CPU compositor
The CPU compositor sanitizes the colors after HSV/HSL conversion by
clamping negative values to zero. The realtime compositor did no such
sanitization. This patch fixes that by introducing similar sanitization.
2023-04-27 19:21:55 +02:00
Omar Emara
a32dbb892f Realtime Compositor: Optimize image textures
This patch optimizes the evaluation of image textures by using and
prefetching a unified texture pool for the evaluation.
2023-04-27 17:09:27 +02:00
Hans Goudey
9292e094e7 Mesh: Reduce memory usage calculating custom normals
Reduces the size of the struct storing normal space from 72 to 64.
2023-04-27 10:31:34 -04:00
Jacques Lucke
18f4fd6b85 Attributes: Add function to rename attribute
This is implemented by removing the attribute and adding it again with
a different name. In the expected case though, implicit sharing is used
to avoid copying the array.

For now this doesn't rename UV sublayers or replace active/default color
attribute names. It's not clear where that should happen, but for now
things are clearer if those stay at a higher level.
2023-04-27 10:31:34 -04:00
Campbell Barton
3c0b15b7eb Fix #107274: Crash zooming out with imperial unit-system 2023-04-27 23:45:27 +10:00
Hans Goudey
d086249f4d Fix: Compile error in debug build in normals code 2023-04-27 09:39:59 -04:00
Hans Goudey
3c43632651 Mesh: Allocate custom normal spaces in array
Avoid many small allocations and just allocate all the structs in one
array, which is 4 times faster. In a test with an armature modifier and
custom normals, corner normal calculation went from 2.7 to 2.3 ms.
2023-04-27 08:50:41 -04:00
Hans Goudey
f8eebd3b25 Cleanup: Use simpler C++ types in mesh corner normals code
The various stacks are just filled and then emptied. We also expect
them to be fairly small. A vector can handle these cases fairly well.
Also store indices rather than pointers. I didn't notice any performance
changes from these changes.
2023-04-27 08:50:41 -04:00
Hans Goudey
a6baf7beae BLI: Allow different integer types when filling span indices 2023-04-27 08:50:41 -04:00
Hans Goudey
9fcfba4aae Mesh: Reduce memory corner normals memory usage and simplify threading
Instead of storing a 24 byte struct for every face corner we must do
calculations for, just gather the face corner index in the first single
threaded loop. And don't fill them in chunks and use the task pool API.
Instead just fill vectors and use standard "parallel_for" threading.
The check that avoided threading for tiny meshes becomes redundant this
way too, which simplifies the code more. Overall this removes over
100 lines of code.

On a Ryzen 7950x, face corner ("split"/"loop") normal calculation in a
small armature modifier setup with custom normals went from 4.1 ms to
2.8 ms. Calculation for a 12 million face mesh generated with curve to
mesh with end caps went from 776 ms to 568 ms.

Similar commits:
- 9e9ebcdd72
- 9338ab1d62
2023-04-27 08:50:41 -04:00
Philipp Oeser
61849d3b5b Revert "Fix: Knife tool does not interpolate vertex customdata in
interior cuts"

This reverts commit 129f79debe.

That commit changed the behavior of how booleans handled vertex weights
as well and made the CubeMaskFirst test modifier test fail.

Not entirely clear to me what the desired behavior would be (current
situation is "wrong" in certain situations as well I think), but until
this is further discussed with the #modeling-module , I think reverting
is the better choice.
2023-04-27 11:57:07 +02:00
Christoph Lendenfeld
107536f359 Refactor: Deduplicate code in graph_slider_ops.c
In most of the operators the code that loops through the FCurve segments and draws the status header were pretty much identical.

To combat that, create abstract helper functions that can be used.

They are not useful in all cases, e.g. the blend to default operator needs a bit of special code.

Pull Request: https://projects.blender.org/blender/blender/pulls/107170
2023-04-27 11:17:59 +02:00
Philipp Oeser
129f79debe Fix: Knife tool does not interpolate vertex customdata in interior cuts
Using the Knife tool, making cuts that split an edge exactly interpolate
fine for vertex customdata (weights or attributes on the vertex domain)
due to `BM_edge_split` taking care of data layers from the edge and
vertex domain (also mdisps -- which unfortunately dont seem to work
well, but that is for another patch...).

However, making cuts _inside_ a face though dont interpolate at all
(giving default values on new vertices).

With this patch, also interpolate vertex customdata in
`BM_face_split_edgenet`.

Pull Request: https://projects.blender.org/blender/blender/pulls/107367
2023-04-27 09:24:04 +02:00
Campbell Barton
c104b135c9 Cleanup: use term "space" in blend file read/write callbacks
Otherwise some function names are the same as data-block IO,
which is inconvenient for inserting break-points.
2023-04-27 16:06:27 +10:00
Omar Emara
fa2dbceadd Realtime Compositor: Implement Corner Pin node
This patch implements the Corner Pin node for the realtime compositor.
This is different from the existing compositor in that single value
inputs produce single value outputs, instead of assuming the size of the
render.

Pull Request: https://projects.blender.org/blender/blender/pulls/107363
2023-04-27 07:18:19 +02:00
Hans Goudey
e0a3212176 Curves: Avoid retrieving arrays many times
Avoids a string lookup for positions at every curve index
in the sculpt add brush when interpolation is used.
2023-04-26 23:50:57 -04:00
Hans Goudey
4daa7ae649 BLI: Add methods to generic spans to retrieve size in bytes 2023-04-26 23:50:57 -04:00
Hans Goudey
4b96af6cdd Cleanup: Remove timer in node, improve comment 2023-04-26 23:50:57 -04:00
Richard Antalik
be53da087d Fix #107390: Image transformation in VSE is very slow
71d7c919c0 introduced usage of `threading::parallel_for()`, but
`WITH_TBB` was not defined for imbuf module.
2023-04-27 04:35:34 +02:00
Chris Blackbourn
5c6f254a66 UV: Simplify storage and logic for UV Packing 2023-04-27 11:52:40 +12:00
Chris Blackbourn
249f677a1f Cleanup: format 2023-04-27 10:36:43 +12:00