Commit Graph

102532 Commits

Author SHA1 Message Date
Hans Goudey
4e97def8a3 Geometry Nodes: Expose sharp edge status with builtin nodes
Change the existing "Is Shade Smooth" node to be named "Is Face Smooth"
and add a new "Is Edge Smooth" node. Also give the "Set Shade Smooth"
node the ability to set face or edge smoothness.

The fact that the nodes process "smooth" data reversed from the builtin
"sharp" attributes can be reversed with versioning in a separate commit.

While it's tempting to abstract the sharpness status into a single node,
face and edge smoothness are accessed separately in edit mode, and the
subtlety of interacting with data on different domains would make that
confusing. Instead, a separate "Is Shade Smooth" node group asset will
give all the sharp elements taking into account both builtin attributes.

The fact that sharpness is stored separately on two domains makes the
best design for simple operations non-obvious. For example, you should be
able to remove all sharpness or make everything flat with a single node.
The behavior depends on whether the two attributes exist and the
combination of values between the domains.

---

![image](/attachments/c3f053c4-2b0f-44ac-9227-62071065fe56)

![image](/attachments/fd489fb3-314b-42ff-a5a9-e79578cbdfe7)

Pull Request: https://projects.blender.org/blender/blender/pulls/112029
2023-09-06 17:12:27 +02:00
Julian Eisel
1ee584c137 Cleanup: Add comments to thumbnail creation function
The function is quite confusing, this should clarify things a bit.
2023-09-06 16:58:07 +02:00
Julian Eisel
6659579abc Cleanup: Move variable declarations close to usage in thumbnail function
This function is rather big and it's not clear what state variables are
in without a bunch of scrolling around. Plus, having the declarations
close to the function calls that set them makes it more clear that these
functions use the variables as output parameters. So this change should
help understanding the function flow.
2023-09-06 16:56:30 +02:00
Philipp Oeser
5b6e1c0cf6 Fix #111898: Custom normals data transfer modifier does not work
Mistake/typo in 5e9ea9243b (mixing up very similarly named variables -
leading to heap buffer overflow).

Pull Request: https://projects.blender.org/blender/blender/pulls/112037
2023-09-06 16:54:46 +02:00
Bastien Montagne
00a36cbf24 Fix #111970: Regression: Crash with assertion after delete scene when some 3D Views have Local Collection enabled
This is a nasty gathering of several issues, main one being that 'local
collections' of 3DViews are still updated immediately instead of the
deferred update used for all other viewlayer cases.

The change in a16bcb6576 led to internal references to the Scene's
master collection to become invalid, which is the expected behavior.
But this turns the Scene's view_layers into invalid state too.

Ideally, there should never be resync of viewlayers of a scene being
deleted anyways.

For now, take the (hopefully!) safe approach of explicitely forbidding
any viewlayer update during ID deletion process, and deferring it at the
end of the process.

Note that this change may also give some marginal gerformance
improvements in some rare edge cases (like deleting a very heavy scene
with many collections and 'local collection' 3DViews ?).
2023-09-06 16:21:55 +02:00
Miguel Pozo
e850df06ee Workbench: Remove next postfix
Pull Request: https://projects.blender.org/blender/blender/pulls/111993
2023-09-06 15:54:50 +02:00
Miguel Pozo
2aa7961e6f Workbench: Remove old implementation 2023-09-06 15:54:48 +02:00
Clément Foucault
209bbf8274 GPU: Rename ROG to SubpassInput, add tests and documentation
This is in order to follow the vulkan terminology
like the rest of the module.

Other implementations (GL, VK) are not supposed to work yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/112026
2023-09-06 14:39:38 +02:00
Miguel Pozo
fc08f220bf EEVEE Next: Volumes: Lighting integration improvements
Add the features missing from #107176

* Irradiance integration.
* Self-shadows.
* Receive shadows from shadow maps.

Shadow tagging works by iterating all the froxels in a
compute shader and tagging the exact same position
that will be sampled by the volume scatter shader.
Froxels that are fully transmissive, have no scattering,
or are behind opaque geometry, are skipped.

It also adds a LoD bias parameter for shadow tagging,
driven by the volumetric tile size.
This works for punctual shadows, but directional lights
would need a way to support re-direction between levels
at sampling time, which is out of the scope of this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/110809
2023-09-06 14:35:57 +02:00
Weizhen Huang
077022e45f Fix #112003: Principled Huang Hair renders black on horizontal particle hair
Curve normal is not available in legacy particle hair system. Construct
a local coordinate system instead of using a fixed normal direction [1,
0, 0] to avoid black appearance.
2023-09-06 14:18:29 +02:00
Clément Foucault
c1e11df732 GPU: Remove uneeded and incorrect os version check
Theses added checks are not working correctly and
are never true even on supported hardware with correct
target version.
2023-09-06 14:14:37 +02:00
Campbell Barton
ddf881ad9b Tools: add addr2line_backtrace to extract back-trace info on Unix/Linux
Since hiding symbols on Linux, in many cases only addresses are printed.
This utility can run run on the back-trace to replace addresses
with line & function information.

See: ./tools/utils/addr2line_backtrace.py --help for usage information.

Note that some examples online run addr2line directly and use the output
in the stack-trace, while convenient and acceptable in some cases, in my
tests addr2line can take over 20 seconds to complete for a single
address. Implement this as a post-process instead. Multi-processing to
prevent this taking too long (around ~23 seconds on my system).

Ref !111416.
2023-09-06 22:07:07 +10:00
Campbell Barton
90864d3fb8 Curve: operate on handles when the knot is selected
Change the behavior of transform and set-handle-type to operate on both
handles when the knot is selected.

This was an oversight in [0] which changed selection to select the knot
without the handles.

This makes curve bezier handles picking & transform match the Graph
Editor & grease pencil bezier curves.

This fixes issues transforming a bezier knot:

- Auto handles would be converted to "Aligned".
- Vector handles would be converted to "Free"
  with the vector handles being left in-place.

Resolves #111840.

Details:

Selecting only the knot vertex was done because the tweak tool no longer
de-selects when picking an already selected vertex to allow tweak to be
used to transform the selection (instead of always de-selecting all
before tweaking). Without this change, dragging a single handle required
manually de-selecting the knot and the opposite handle (3 clicks to
select a handle before dragging). Selecting only the knot solves this
but means transform needs to support tweaking a vertex (& it's handles)
without it's handles selected.

See design #96544.

[0]: 618f39fca2
2023-09-06 22:03:16 +10:00
Campbell Barton
3cfa61291b Fix curve set handle type not respecting hidden handles
The handle selection should be ignored when hidden.
Now set handle type considers all handles selected when handles
are hidden and the knot is selected.
2023-09-06 22:03:16 +10:00
Campbell Barton
8c85fd90cb Fix transforming a gpencil bezier vertex changing it's handle type
Selecting a gpencil bezier vertex and move it would change the handle
type when set to "Auto".

This happened because of a mismatch between transform flag use
and BKE_nurb_bezt_handle_test which would change the handle type
when only the vertex (knot) was selected.

Resolve by treating both handles as selected when the knot is selected.
2023-09-06 22:03:16 +10:00
Campbell Barton
78b6ed19f3 Curve: extend BKE_nurb_bezt_handle_test & BKE_nurb_handles_test
Replace use_handles with an enum that optionally uses handles
except when the vertex (knot) is selected in which case it behaves
as if both handles are selected.

Needed for nurb curves not to change handle type when only the
center point is selected (as is done in the graph editor).

No functional changes.
2023-09-06 22:03:16 +10:00
Campbell Barton
ccaafa318d Cleanup: negate handles_visible & name hide_handles
Match naming of curve transform conversion to avoid confusion.
2023-09-06 22:03:16 +10:00
Philipp Oeser
e924f316a7 Fix #112021: Crash dragging node groups into an empty node editor
Mistake in 30e3caaf82 (which wasnt checking if an `edittree` actually
existed).

Pull Request: https://projects.blender.org/blender/blender/pulls/112023
2023-09-06 13:51:18 +02:00
Philipp Oeser
0d5a094532 Fix #111983 : Context Path in the node editors is broken
Mistake in fa34992def (reversed conditional).

Pull Request: https://projects.blender.org/blender/blender/pulls/112020
2023-09-06 13:50:44 +02:00
Hans Goudey
f47de98def Fix: Node link drag search attachment to existing group input broken
Mistake in e071288ab2
2023-09-06 07:42:03 -04:00
Lukas Tönne
ad0a6fa4cb Fix #112016: Sockets in closed node panels still draggable.
Include the `SOCK_PANEL_COLLAPSED` flag in the general `is_visible`
function used to determine if operators can see the socket.

Pull Request: https://projects.blender.org/blender/blender/pulls/112019
2023-09-06 13:34:22 +02:00
Lukas Tönne
fb9916b305 Fix #111786: Node panels header blocks resizing the node border
The invisible button for the header covers the entire node width,
causing conflicts with the resize operator. Added a small margin to
ensure the button does not overlap with the node border.

Pull Request: https://projects.blender.org/blender/blender/pulls/112017
2023-09-06 13:30:48 +02:00
Lukas Tönne
8cb6f78e74 Fix #111966: Node group panels too small when using "both" type sockets
Node group sockets can be set to "both" for input/output, generating
two socket declarations in the same panel. Panel size was calculated
using only the items count, which is <= the actual declarations count.

This patch calculates actual declarations count as the panel size.
Panel size variable renamed to `num_child_decls` to distinguish from
`num_items`.

Pull Request: https://projects.blender.org/blender/blender/pulls/112013
2023-09-06 13:29:47 +02:00
Weizhen Huang
db4a2de620 Fix: EEVEE: Principled BSDF not matching Cycles near IOR == 1
Schlick's approaximation used by EEVEE is not accurate near `IOR == 1`,
especially when IOR is exactly one, there is no specular reflection and
the material should appear diffuse.
Cycles bypass the issue by lerping between the f0 and f90 color using
the factor derived from real Fresnel curve. In EEVEE we can use the same
trick as in Glass BSDF to smooth the transition at `IOR == 1`.
Note that at `IOR < 1` there is still mismatch, because f0 is prebaked
in the BTDF look up table. In the future if we color f0 using
`specular_tint`, we can split the table and use the BTDF LUT for the
specular component too.
2023-09-06 12:47:30 +02:00
Lukas Tönne
ba8d165d3b Fix #111804: Remove padding between node sockets when hidden
Node drawing was adding some extra padding for each socket even when it
isn't visible. This patch makes the padding conditional on whether the
socket is visible and only when there is preceding items that require a
spacer.

![Screenshot_20230905_162302](/attachments/da52983a-a053-44c8-9d5c-859f89a652a1)

Pull Request: https://projects.blender.org/blender/blender/pulls/111981
2023-09-06 10:34:18 +02:00
Philipp Oeser
2b5f97b8c4 Fix #111955: Animation player no longer responds to mouse input
Caused by C++ conversion in f07a112cb5.

Above commit was casting directly from event (instead of the event
data).

Pull Request: https://projects.blender.org/blender/blender/pulls/112010
2023-09-06 10:24:00 +02:00
Lukas Tönne
7e316b57d0 Fix #111936: Nodes forward compatibility data is not freed
Node group interfaces for 4.0 are written to blend files as legacy data
to enable forward compatibility. This data is meaningless in 4.0, so if
a blend file contains it, the data should be freed right away. The
code for freeing legacy data was incomplete.

Pull Request: https://projects.blender.org/blender/blender/pulls/111989
2023-09-06 10:23:51 +02:00
Jacques Lucke
8c43cc3f83 Cleanup: use menu type flag
Another flag is added in #110855.
2023-09-06 10:04:01 +02:00
Campbell Barton
48394561d7 Fix keyconfigs.remove(..) leaving dangling pointers
Removing key-configs that also had direct pointer access
left them pointing to freed memory.
2023-09-06 14:23:04 +10:00
Campbell Barton
1f01a64403 Cleanup: spelling in comments 2023-09-06 14:23:01 +10:00
Richard Antalik
b1526dd2c6 Fix #107726: Viewport animation render ignores start frame
This issue specifically happend if sound playback is synchronized by
Audaspace. In this case render engine can't override current frame.
`BKE_sound_sync_scene()` should return NaN as when rendering is in
progress, however viewport render operator doesn't set `G.is_rendering`.

Pull Request: https://projects.blender.org/blender/blender/pulls/111946
2023-09-06 04:40:39 +02:00
Campbell Barton
1f285a5ec8 Cleanup: early return to reduce right shift 2023-09-06 12:05:19 +10:00
Jacques Lucke
b5c89822ac RNA: return PointerRNA from rna create functions
There are a couple of functions that create rna pointers. For example
`RNA_main_pointer_create` and `RNA_pointer_create`. Currently, those
take an output parameter `r_ptr` as last argument. This patch changes
it so that the functions actually return a` PointerRNA` instead of using
the output parameters.

This has a few benefits:
* Output parameters should only be used when there is an actual benefit.
  Otherwise, one should default to returning the value.
* It's simpler to use the API in the large majority of cases (note that this
  patch reduces the number of lines of code).
* It allows the `PointerRNA` to be const on the call-site, if that is desired.

No performance regression has been measured in production files.
If one of these functions happened to be called in a hot loop where
there is a regression, the solution should be to use an inline function
there which allows the compiler to optimize it even better.

Pull Request: https://projects.blender.org/blender/blender/pulls/111976
2023-09-06 00:48:50 +02:00
Harley Acheson
8a3766e241 Fix #111017: Improvements to the drawing of Color Ramps
Color Ramp widget with themed outline, handling of line width changes,
padding fixes, scaling fixes, etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/111903
2023-09-06 00:00:40 +02:00
Habib Gahbiche
f0acbd151d Fix: Build error with Audaspace turned on
To reproduce build error, set `WITH_AUDASPACE` to `ON` in `blender_lite.cmake` and build using `make lite`.

The problem is that the function `AUD_Sound_equalize` is declared in `blender/extern/audaspace/bindings/C/AUD_Sound.h` within `WITH_CONVOLUTION` and not `WITH_AUDASPACE`.

Pull Request: https://projects.blender.org/blender/blender/pulls/111994
2023-09-05 21:19:02 +02:00
Miguel Pozo
fdda220a64 FIx: Workbench: Texture-less materials in texture mode
Fallback to material color if there's no texture.
2023-09-05 19:47:28 +02:00
Nathan Vegdahl
d5b9127e1b Fix: free BoneCollection ID props when the collection is freed 2023-09-05 17:32:01 +02:00
Colin Basnett
c73bdce8f8 Fix: Crash when trying to poll the status of non-existent icons
This fixes a specific crash that would happen to me sometimes when changing
between files (the files may have been saved in older versions of the Blender).
The fix is just to null-check the icon lookup.

Pull Request: https://projects.blender.org/blender/blender/pulls/111670
2023-09-05 16:05:12 +02:00
Miguel Pozo
22e4e94d57 Fix #111699: Remove deleted interface from the VAO cache
Newer interfaces can share the same address as the old one,
causing a deleted VAO to be bound.

Pull Request: https://projects.blender.org/blender/blender/pulls/111929
2023-09-05 15:34:12 +02:00
Sybren A. Stüvel
bcd0198a46 Anim: versioning, also bone create collections for empty bone groups
Change the versioning code so that all bone groups are converted to bone
collections, so also the ones that did not have any bones assigned.

As Demeter[1] put it: While bone groups with 0 bones assigned are
usually unintended, versioning should still preserve them I feel like,
just to be on the safe side. If there was an update to the vertex group
system, I would also expect empty vertex groups to survive, even though
they are strictly speaking pretty much pointless.

[1]: https://projects.blender.org/blender/blender/issues/111711#issuecomment-1013159
2023-09-05 15:12:36 +02:00
Sybren A. Stüvel
5250ae156e Refactor: move default bone collection name to constant
No functional changes.
2023-09-05 14:57:01 +02:00
Hans Goudey
6da4b87661 Geometry Nodes: Extend add modifier menu with node group assets
Implements part of #111538.

Change the modifier add button to create a menu with submenus.
Extend the submenus dynamically with geometry node group assets.
This makes it much simpler to share and use custom modifiers.

Node groups get a new "Is Modifier" property, which is controllable
in a popover in the node editor header when the group is an asset.

The built in modifier can be rearranged in different categories in
a next step. For now the existing organization is used, except for
the geometry nodes modifier, which is called "Empty Modifier" and
put in the root menu.

The changes in !110855 and !110828 will be important to improve
interaction speed with the new UI. Those are planned for 4.0 as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/111717
2023-09-05 14:47:18 +02:00
Christoph Lendenfeld
b7a84c49ea Animation: Keep icons aligned when curves are baked
When curves were baked, the lock icon wasn't drawn, which resulted in
a misalignment of the other icons.
With this patch, the icons are kept in alignment.

Also removes the comments that are no longer valid.

Pull Request: https://projects.blender.org/blender/blender/pulls/108518
2023-09-05 14:27:09 +02:00
Christoph Lendenfeld
9d4edd3565 Cleanup: Make format 2023-09-05 14:23:54 +02:00
Christoph Lendenfeld
d7e3961a82 Animation: Graph Editor - Don't draw curve points if they are too close to each other
When viewing a curve with a lot of keys totally zoomed out,
the keys might be closer to each other than a pixel.
The code would still draw a line between them,
costing time in the draw code.

This PR skips any keys that are too close to each other in screen space.

## Performance

The setup: 62 bones with 6000f of animation keyed on every frame.
No keys displayed, just the curves.

| - | before | after |
| - | - | - |
| zoomed in | 11μs | 17μs |
| zoomed out |  55μs | 30μs |

So a small performance penalty when zoomed in in exchange for a big gain when zoomed out.

There is a small change in visuals when zoomed out a lot.
Because this change averages keys that are too close together,
it results in a small loss of high frequency detail.

## The logic
If `prevbezt` and `bezt` are too close it will not draw,
but extend a bounding box with `prevbezt` and `bezt` including handles if needed.
Eventually the keys will be far enough apart to draw.
At this point, draw the center of the bounding box and reset it.
Now because there could be the case where `bezt` in the
current loop is super far out (e.g 5 keys with 1f spacing and the 6th key is at f1000)
we need to recalculate the bounding box again.
In case the keys are far away, just draw normally.
If it is close still, the same  process repeats.

Pull Request: https://projects.blender.org/blender/blender/pulls/110788
2023-09-05 14:18:34 +02:00
Christoph Lendenfeld
93bf17f333 Fix: Warnings in transform_convert_nla.cc
No functional changes
The recent refactor patch introduced warnings on flag checks
2023-09-05 14:16:10 +02:00
Lukas Tönne
b2b1657721 Fix #111963: Copying sockets was not creating unique identifiers
Items in the node group interface need to have unique identifiers.
Copying an item (socket or panel) was not doing this, so the node groups
end up having sockets with the same identifier. Linking sockets was
broken because copies could not be distinguished.

Pull Request: https://projects.blender.org/blender/blender/pulls/111972
2023-09-05 13:31:58 +02:00
Christoph Lendenfeld
4033f3bcc3 Refactor: Code indentation in transform_convert_nla.cc
No functional changes

`transform_convert_nla.cc` had a few `if`s within
for loops that could be inverted to remove the indentation.

In addition to that I extracted the snapping functionality
so the `if`s there can also be inverted and return.

Pull Request: https://projects.blender.org/blender/blender/pulls/111968
2023-09-05 13:01:51 +02:00
nutti
1494929f94 Python API: Fix docstring from method to classmethod
`draw_handler_add` and `draw_handler_remove` method of bpy.types.SpaceXXX
should be class method not method. However, Python API document does not show
the classmethod.

This PR fixes the Python API document of them.

Pull Request: https://projects.blender.org/blender/blender/pulls/111107
2023-09-05 12:56:41 +02:00
Lukas Tönne
ed1f9d4fdd Nodes: Fix versioning 2.6 groups, causing dangling link pointers
In 2.6 the old method of using bNodeSocket lists in bNodeTree directly
as group sockets was replaced with new group input/output nodes. This
required versioning to create those input/output nodes and then redirect
links to the new node sockets. Because creating nodes relies heavily on
node typeinfo this versioning was done in the `_after_linking` section
of the 2.6 versioning code, running after _all other versioning_
(including for much newer versions!) has already happended.

While typinfo is available at that point, doing such late versioning
causes severe problems when the data structure changes, as is the case
with the recent node panels patch (#111348). The new node group
interface also has versioning code for 4.0, but this runs _before_ the
`_after_linking` code for 2.6! Versioning for node panels expects
sockets in bNodeTree to not have any links pointing at them, but this is
not true for old 2.6 files which have not yet been fully versioned at
that point, because of the late versioning stage. Subsequently 2.6
`_after_linking` code crashes when trying to modify node links with
dangling pointers.

The solution here is to move the old versioning code out of the
`after_linking` stage to restore the expected versioning chain. This
requires creating nodes and node sockets without any typeinfo, but
luckily we only need to create simple known group input/output nodes
which don't have much complicated behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/111704
2023-09-05 12:37:05 +02:00