Commit Graph

123697 Commits

Author SHA1 Message Date
Sergey Sharybin
86a14faf69 Fix CUDA/OptiX compilation error in Cycles
Apparently, it does not seem to support hex notation for
floating point values.

Pull Request: https://projects.blender.org/blender/blender/pulls/107424
2023-04-28 10:51:03 +02:00
Campbell Barton
2bb4abdc27 Cleanup: assign variables & use 'match' to avoid redundant lookups
Also use more verbose names for RNA subtype enum variables.
2023-04-28 16:56:34 +10: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
Campbell Barton
7b8ba7f101 Fix #107314: OS key stuck when switching windows with GNOME/Wayland
Tapping the OS key to switch windows could cause the OS key to stick.

On window deactivation the OS key was considered held, activating the
window later read the XKB modifier state before the keyboard_enter &
keyboard_modifier callbacks had run.

When they ran later, the mis-match between XKB and GHOST was not taken
into account, causing the OS key to stick.
2023-04-28 16:06:37 +10:00
Colin Basnett
6e2721da30 Core: Add sub-types for float-type custom properties
This adds the ability for users to assign sub-types to `Float` type custom properties (e.g., distance, angle, time, power etc.)

Pull Request: https://projects.blender.org/blender/blender/pulls/106700
2023-04-28 05:44:50 +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
Hans Goudey
032e69527d Cleanup: Fix spelling in subdiv function name 2023-04-26 12:42:48 -04:00
Hans Goudey
d8f4387ac9 Geometry Nodes: Index of Nearest: Use grain size based on tree sizes
Use a grain size for the final tree creation/balancing/lookup that
depends on the average size of each tree. When the trees are larger,
fewer trees are processed on each thread and vice versa. I didn't notice
a difference when there are hundreds of thousands of groups, but
when there are few (i.e. around the number of cores), I noticed a 6x
performance improvement, from over 1 second to around 0.2 s.

Note that generally the performance is better with many small groups,
because the creation and balancing of trees is single threaded.
2023-04-26 12:34:48 -04:00
Hans Goudey
4346314351 Geometry Nodes: Index of Nearest: Use span for non-single ids
If the Group ID input isn't a single value, it's likely to be a span,
so making sure that's true should generally be free, at least in
most cases. This brought a test with 1 million points from 37
to 34 ms, roughtly an 8% improvement.
2023-04-26 12:26:38 -04:00
Hans Goudey
45cecb101c Nodes: Support adding multiple nodes from search menu
Needed for the simulation zone addition to the add menu search.
Link-drag search isn't supported yet, but a similar change should be
possible there.

Now the search item exposed through the public nodes namespace returns
several items directly, and the "after add function" is just handled as
a sub-case of that for convenience.
2023-04-26 11:40:54 -04:00
Campbell Barton
f6931a9ead CMake: only generate & install the man-page when it may be outdated
Check if the man-page is missing or older than files that generate it
before re-running the generator.

Previously the install target would re-run the man-page generator
every time, even when no other changes to the build were detected.
2023-04-26 23:01:02 +10:00
Hans Goudey
bdaf8e3715 Cleanup: Avoid storing redundant information in corner normals task data
Though alignment means the size of the struct doesn't change
if the data is split up a bit more it could give further improvement.
2023-04-26 08:50:31 -04:00
Hans Goudey
803f03ae32 Cleanup: Remove redundant namespaces in mesh normals code
Also use int instead of uint.
2023-04-26 08:46:11 -04:00
Hans Goudey
93f99859bc Cleanup: Standardize mesh corner normals code
Use consistent variable names: for example "vert" instead of "mv" and
"edge" instead of "me", etc. Also use helper functions like "edge other
vert" to make the code easier to read.
2023-04-26 08:46:11 -04:00
Hans Goudey
b54398c16c Geometry Nodes: Use implicit sharing in store/capture attribute nodes
Some fields reference attributes directly. When the referenced attribute
has the requested type and domain, the captured/stored attribute can
share its array, avoiding the cost of duplication and reducing memory
usage, at least temporarily until either attribute is modified.

This only works when the attribute doesn't need validation and when
the selection input isn't used, since those potentially need to change
values in the arrays.

I saw this save 200MB and 11 ms of copying for a simple grid with
16 million points (creating the grid takes about 60ms).

Pull Request: https://projects.blender.org/blender/blender/pulls/107357
2023-04-26 14:38:56 +02:00
Sergey Sharybin
02b5c04b2b Fix intersection distance offset in Cycles
The intersection distance offset in Cycles could have returned
a denormal floating point value for the input values of 0 (and
for the denormal input value).

This could lead to a situation when ray is unable to be advanced
when it hits an edge between two triangles: the intersection will
keep bouncing between two adjacent triangles. This is because the
ray->tmin is compared inclusively, and 0 >= <denormal zero>.

The solution is to return the smallest possible normalized floating
point value from the intersection_t_offset if the input is zero
or a denormal value (which is covered by the same t == 0 check).

This fix is hard to measure on the user level. The old code did
not cause any infinite traversal loop because of the way how the
integration is organized (some kernels offset ray.P, others check
for the number of bounces). It is possible that this fixes some
corner cases of noise: i.e. if some shadow rays falsefully were
considered occluded due to reached maximum number of bounces.

The actual problematic case was discovered during working on a
prototype which had an in-lined intersection loop with the ray
tmin offset.

Pull Request: https://projects.blender.org/blender/blender/pulls/107364
2023-04-26 11:36:37 +02:00
Campbell Barton
029ce2b656 Cleanup: remove redundant casts 2023-04-26 19:03:21 +10:00
Campbell Barton
0a3a6cd154 Cleanup: use ptrdiff_t in assertion to prevent overflow 2023-04-26 19:02:24 +10:00
Jacques Lucke
bf58af2d65 Cleanup: fix build errors/warnings 2023-04-26 10:55:45 +02:00
Jacques Lucke
8ebabac003 Cleanup: store less data per node that is already stored together 2023-04-26 10:42:46 +02:00
Joseph Eagar
c1d4b6f339 Core: Add ASAN support to BLI_mempool
This patch adds address sanitizer support to memory pools.

when ASAN is enabled the following happens:
* 32 byte red zones are inserted between pool elements.
* The BLI_mempool struct itself is marked as a red zone.
* Access to the pool goes through a thread mutex (except when compiling makesdna).

This is very useful for finding bugs in code that uses BMesh.

Pull Request: #104668
2023-04-26 01:32:41 -07:00
Jacques Lucke
536144983b Fix: group node inputs always requested unnecessarily
This triggered an assert during evaluation, because the group inputs
were first requested and later the set unused, which is not allowed.

The issue was likely introduced in 258678916f.
2023-04-26 10:10:22 +02:00
Campbell Barton
5a5c0e879c Cleanup: correct exception message & remove unused iterator variable 2023-04-26 17:51:50 +10:00