Commit Graph

3710 Commits

Author SHA1 Message Date
Jacques Lucke
b36bf15e28 Geometry Nodes: improve detecting data-block dependencies
Previously, the data-block dependencies were always detected in
`update_depsgraph` in `MOD_nodes.cc`. This would only be called when something
called `DEG_relations_tag_update` before. We don't want to trigger a depsgraph
rebuild after each operation in the node editor, as that would be expensive.
However, that also meant that we often had to add data-block dependencies that
are not actually used, but might be used if the user changed e.g. a link. A
typical example for that is a object socket that has a default value, but the
socket is also linked.

Now, the dependencies referenced by the node tree are collected by the node tree
update code which runs after all changes. This way we can detect whether the
dependencies have changed. Only if they have changed, a depsgraph rebuild is
triggered. This now allows also taking into account the mute status of nodes and
whether an input is linked.

There are still more things that could be taken into account. Most obviously
whether a node is connected to an output. This can be done later. The most
tricky aspect here is probably that we also have to consider all viewer nodes as
output, because at the time the node runs, it's not known which viewer will
actually be used (which depends on other editors).

This also cleans up some special cases we had for e.g. the scene time node where
we always had to trigger a depsgraph rebuild when it was added/removed because
of its time dependence. This is now part of a more general system.

This fixes #109219.

Pull Request: https://projects.blender.org/blender/blender/pulls/131446
2024-12-05 18:02:14 +01:00
Jacques Lucke
5926654756 Fix: Geometry Nodes: crash when accessing runtime data while baking
Some editors are not redrawn while baking, but the properties editor currently
is and therefore needs this special check.

Eventually, we should rename or split the `is_rendering` flag to make it
more obvious that it also means baking.
2024-12-04 20:00:37 +01:00
Hans Goudey
22c13cfd28 Cleanup: Avoid reformatting geometry nodes property names, use fmt 2024-12-04 12:38:00 -05:00
Hans Goudey
af79b4e7b5 Cleanup: Use constexpr for geometry nodes string, avoid .c_str() 2024-12-04 12:38:00 -05:00
Hans Goudey
f9b627d29c Mesh: Move custom normals to a generic attribute
Move `CD_CUSTOMLOOPNORMAL` to the newly added
`CD_PROP_INT16_2D` generic attribute type. This is similar to
previous commits moving specific custom data types.

The attribute name is `custom_normal`. When the attribute with
that name is on the face corner domain, the code will interpret it
as stored in the existing deformation-invariant spherical coordinate
space.

The API remains the same, with the additional opportunity to edit
custom normal data as an attribute directly (which admittedly is fairly
unintuitive currently).

See #130484.

Pull Request: https://projects.blender.org/blender/blender/pulls/130689
2024-12-04 16:06:36 +01:00
Hans Goudey
024d7d12e2 Mesh: Move BVH storage to shared cache system
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
2024-12-04 00:17:17 +01:00
Pratik Borhade
74f212fae2 Fix #130922: GN: Hide empty panel in modifier UI
`interace_panel_has_socket` should return true when panel has
at least a socket of type input or hidden in modifier. That way, panel
drawing code won't be executed.

Pull Request: https://projects.blender.org/blender/blender/pulls/130958
2024-12-01 07:37:06 +01:00
YimingWu
73b7e8e256 Fix #131049: Line Art: Prevent stroke generation in locked target layer
Line art will not be able to insert any drawings into a locked target
layer, this fix prevent such situation from crashing Blender.

Pull Request: https://projects.blender.org/blender/blender/pulls/131073
2024-11-29 06:08:19 +01:00
Hans Goudey
953c4f1599 Cleanup: Remove references to legacy Grease Pencil object
These are converted on startup to the new type. There are still
some references left, mostly where it looked like there still needs
to be changes to properly deal with the new object type.
2024-11-27 09:17:16 -05:00
YimingWu
00f61f0913 Fix #130904: Grease Pencil: Build modifier additive mode issues
Grease pencil build modifier additive mode has two problems that is
causing crashes and wrong build result when drawing in additive mode:

- Not assigning `dst_to_src_curve` for previously built curves.
- The way `previous_drawing` was acquired was wrong, this gives a zero
  stroke count for additive build mode, which prevented the crash while
  not in drawing mode (not on key frame), but is in fact incorrect for
  the algorithm.

This PR handles these problems and additive mode now works correctly
and without crashes while drawing new frames.

Pull Request: https://projects.blender.org/blender/blender/pulls/130952
2024-11-26 11:00:48 +01:00
Bastien Montagne
4bf5a2f5cb Cleanup: PointerRNA: Remove 'C-style' zero-initializations.
These are useless now that PointerRNA has explicit default values, and
become a problem when real constructors are added to this struct. Simply
use the default empty value initialization instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/130927
2024-11-25 19:09:56 +01:00
YimingWu
5628c4f587 Fix: Grease Pencil: Ensure no bezier curves for offset modifier
Ensure no bezier curves for offset modifier, this makes it consistent
with the rest of the grease pencil modifiers for now and we will make
bezier support for the rest of the modifiers later.

Pull Request: https://projects.blender.org/blender/blender/pulls/130901
2024-11-25 13:31:04 +01:00
YimingWu
a3bdd0ce70 Fix #130691: Grease Pencil offset modifier missing position change tag
A `drawing.tag_positions_changed();` is needed after deforming strokes,
otherwise viewport will use outdated drawing batches.

Pull Request: https://projects.blender.org/blender/blender/pulls/130900
2024-11-25 12:37:11 +01:00
Campbell Barton
0de8ae8046 Cleanup: spelling in comments 2024-11-25 13:24:46 +11:00
YimingWu
d37a855973 Fix #130569: Grease Pencil tint modifier should use gradient alpha
Grease pencil tint modifier in gradient mode did not do alpha mix with
the original stroke color, making original color completely black even
when gradient color has alpha. Now fixed.

Pull Request: https://projects.blender.org/blender/blender/pulls/130575
2024-11-21 13:42:02 +01:00
Jacques Lucke
e62aa986b2 Format: use fmt::format correctly with runtime format strings
The `fmt::format` can process the format string at compile time. Currently, we
don't seem to be using that as we don't use `FMT_STRING`. Starting with C++20,
that will be the default though, and one has to explicitly opt out in places
where the string is not known at compile time using `fmt::runtime(...)`.
Currently, our code does not compile as C++20 because of that. Unfortunately, we
have many places with runtime format strings, because of i18n.

Pull Request: https://projects.blender.org/blender/blender/pulls/130392
2024-11-20 10:41:29 +01:00
ernst-ellert
73a3ebea56 Fix #129389: Lineart modifier updates when camera changes
The bug occurred when the user changed the camera of the scene.
The lineart modifier was not updating when changing the camera, but only
when changing other elements in the scene or moving the camera.

This is resolved by adding a depsgraph update for scene parameters, such
as when changing the camera.

Testing:
Add two cameras, add a Grease Pencil Collection Line Art, go into camera
perspective view and then switch to the other camera.
The Grease Pencil Line Art now updates automatically.

Co-authored-by: YimingWu <chengdulittlea@noreply.localhost>
Pull Request: https://projects.blender.org/blender/blender/pulls/129935
2024-11-20 04:47:05 +01:00
Iliya Katueshenock
ae0ab14716 Cleanup: BLI: Binary search first_if and last_if utils
Cleanup to simplify code by using common terms like _first_ and _last_ in context
of predicate applying in a range just like we do for spans and range containers.

Pull Request: https://projects.blender.org/blender/blender/pulls/130380
2024-11-19 11:05:57 +01:00
YimingWu
911ccac5f8 Fix #130198: GPv3 build modifier timing for nature drawing speed
GPv3 build modifier in "Nature Drawing Speed" mode didn't finish
building a frame when the time it took to draw those strokes by hand is
greater than the frame duration. Previous fix #129894 is only effective
for "Number of Frames" build mode. This fix moved the timing scaling
into `get_build_factor` and `get_factor_from_draw_speed` for more
granulated control in different modes.

Pull Request: https://projects.blender.org/blender/blender/pulls/130199
2024-11-19 05:16:16 +01:00
Sean Kim
c88c2bfda9 Cleanup: Convert BKE_multires.hh enum to enum class
Pull Request: https://projects.blender.org/blender/blender/pulls/130363
2024-11-16 23:16:37 +01:00
Hans Goudey
0684639e1b Cleanup: Grease Pencil: Remove indirect includes from headers
To avoid unnecessary header parsing during compilation.

Pull Request: https://projects.blender.org/blender/blender/pulls/130285
2024-11-14 22:07:19 +01:00
Falk David
9dfcc506fc Merge branch 'blender-v4.3-release' 2024-11-12 18:56:59 +01:00
YimingWu
2e82f95237 Fix: LineArt: Cache mechanism fixes
The cache mechanism for line art is changed during migration to GPv3,
however the code path failed to handle following cases which could lead
to a few problems:

- Line art cache isn't deleted after last line art modifier because it
  coule be hidden, causing memory leaks.
- A modifier inside a multiple line art modifier sequence that doesn't
  use cache would prematurely delete line art cache, causing subsequent
  line art modifier to give empty result.
- When the first line art modifier is hidden (in viewport/render), the
  cache is not created correctly, leading to crashes.

Now the new code logic addresses these problems properly by:

- Making sure the last visible line art modifier deletes cache.
- Giving a fresh cache pointer for modifiers that doesn't use global
  cache.
- Line art cache is correctly ensured when there are modifiers that
  are hidden

Pull Request: https://projects.blender.org/blender/blender/pulls/129953
2024-11-12 18:51:45 +01:00
Bastien Montagne
b325142d17 Merge branch 'blender-v4.3-release' 2024-11-12 16:55:40 +01:00
Bastien Montagne
0b3a7cbe69 Cleanup: Move BKE_image.h and related headers to C++.
NOTE: This also required some changes to Cycles code itself, who is now
directly including `BKE_image.hh` instead of declaring a few prototypes
of these functions in its `blender/utils.h` header (due to C++ functions
names mangling, this was not working anymore).

Pull Request: https://projects.blender.org/blender/blender/pulls/130174
2024-11-12 16:53:54 +01:00
Falk David
c8211b23c7 Refactor: Add CurvesGeometry::is_empty() function
Previously, some places used `curves.points_num() == 0` some other
places `curves.curves_num() == 0` to check if the geometry is empty.

Rather than having these two ways, add an `is_empty()` function
that replaces all these different checks.

Also update the curves geometry tests to use this function.

Pull Request: https://projects.blender.org/blender/blender/pulls/130168
2024-11-12 14:46:24 +01:00
Lukas Tönne
dbbacbffaf Merge branch 'blender-v4.3-release' 2024-11-11 17:12:17 +01:00
YimingWu
37ec4b5430 Fix #129883: GPv3: Build modifier frame timing is not correct
When the duration of a frame is shorter than the build time specified in
the modifier, build modifier should shorten the build time to allow the
frame to be fully built within the frame duration. This fix made the
timing behaviour the same as GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/129894
2024-11-11 16:53:39 +01:00
Falk David
2a129f8762 Merge branch 'blender-v4.3-release' 2024-11-11 11:02:35 +01:00
Falk David
01db47b82c Fix #129766: GPv3: Fallback to "frames" mode in build modifier for natural drawing speed
The issue was that if the `delta_time` attribute didn't exist, the drawing
would appear immediatley.
In case we don't have any drawing speed information, the fix
makes it so that we fallback to use the number of frames
to build the strokes.

Pull Request: https://projects.blender.org/blender/blender/pulls/130035
2024-11-11 10:39:23 +01:00
Jacques Lucke
8464d95c4c Merge branch 'blender-v4.3-release' 2024-11-07 14:26:33 +01:00
Jacques Lucke
5cdaa7b0f0 Fix #129642: material lost after first frame in uncached simulation zone
The issue was that some checks didn't handle the no-cache case correctly.

Pull Request: https://projects.blender.org/blender/blender/pulls/129959
2024-11-07 14:25:57 +01:00
Clément Foucault
f4f94fb055 Merge branch 'blender-v4.3-release' 2024-11-05 16:40:52 +01:00
YimingWu
46b89b2aa4 Fix: GPv3: Some modifiers not working with non-poly curves
Some modifiers expect the curves to be of type `POLY`.
For such modifiers we need to resample the curves to the
evaluated points so that the modifiers work as expected.

Resolves #129859.

Pull Request: https://projects.blender.org/blender/blender/pulls/129860
2024-11-05 16:35:16 +01:00
Omar Emara
dc4155e133 Merge branch 'blender-v4.3-release' 2024-11-04 17:12:39 +02:00
YimingWu
ecba71ae91 Fix #129738: GPv3: Build modifier use key frame
Build modifier should start building strokes at a key frame, not always
assume a starting frame of 0.

Frame restriction works the same way as GPv2, which uses absolute
frame number.

Pull Request: https://projects.blender.org/blender/blender/pulls/129774
2024-11-04 15:33:11 +01:00
Xavier Hallade
57a7a940e1 Merge branch 'blender-v4.3-release' 2024-11-04 11:34:05 +01:00
Damien Picard
edcc5e0e87 I18n: Translate and disambiguate a few messages
Translate
- Extract Grease Pencil modifier subpanel header messages.

Disambiguate
- Integer Math node operation (same as other existing math nodes).

Pull Request: https://projects.blender.org/blender/blender/pulls/128715
2024-11-04 11:15:48 +01:00
Campbell Barton
0ae9ae736e Merge branch 'blender-v4.3-release' 2024-10-22 15:58:37 +11:00
Campbell Barton
f69fbb41c1 Fix #129225: Crash in modifiers & constraints with invalid enum values
Even though this is generally avoided, drivers don't prevent
invalid values being set. Further files from branches or files
written in the future may contain enum values not yet known.

Resolve by range checking enum values which are used to index arrays.
2024-10-22 15:56:58 +11:00
Jacques Lucke
8588e196c4 Merge branch 'blender-v4.3-release' 2024-10-21 15:48:06 +02:00
Jacques Lucke
7c7b8e1f28 Fix #129087: don't show empty panels in geometry nodes modifier
If a panel is detected to be empty, it is hidden automatically now.
This is the same behavior as in group nodes.
2024-10-21 15:47:16 +02:00
Campbell Barton
cbe6a3eb23 Merge branch 'blender-v4.3-release' 2024-10-21 21:41:16 +11:00
Lukas Tönne
41655fcb3d Fix #129255: Color modifier uses wrong material slot index
This worked in simple cases because the material slot index gets clamped
so negative slot indices become slot 0.

Pull Request: https://projects.blender.org/blender/blender/pulls/129287
2024-10-21 12:26:57 +02:00
Jacques Lucke
c428765b28 Merge branch 'blender-v4.3-release' 2024-10-18 12:38:34 +02:00
Jacques Lucke
30c3d17bb6 Fix #129190: invalid runtime data in lineart modifier after load 2024-10-18 12:38:00 +02:00
Campbell Barton
3290e33d34 Cleanup: spelling in comments 2024-10-17 11:53:47 +11:00
Campbell Barton
2d832240a3 Merge branch 'blender-v4.3-release' 2024-10-17 09:51:18 +11:00
Campbell Barton
21aa149568 Cleanup: spelling in comments 2024-10-17 09:48:37 +11:00
Sergey Sharybin
06c0bd6699 Merge branch 'blender-v4.3-release' 2024-10-16 16:29:24 +02:00