Commit Graph

3768 Commits

Author SHA1 Message Date
Jacques Lucke
fdfd1de9a8 Fix: Geometry Nodes: empty expanded menu entries in modifier
Work around an issue with expanded menus that exists for a long time
already. I briefly tried fixing it, but does not seem straight forward unfortunately
without breaking stuff.

Also see the comment in `ui_item_enum_expand_exec`.
2025-05-14 14:04:15 +02:00
Guillermo Venegas
3b1e123361 Refactor: UI: Replace uiItemS and uiItemS_ex with uiLayout::separator
This merges the public `uiItemS` and `uiItemS_ex` functions into an
object oriented API (`uiLayout::separator`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code
(or vice-versa), making it almost seamless.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138826
2025-05-13 17:54:26 +02:00
Jacques Lucke
55a831d134 Cleanup: Modifiers: rename function to draw modifier error message
The old name `modifier_panel_end` was not great because:
* There is no corresponding `*_begin`.
* It sounds more magical then it really is (it just draws the error message).
* It doesn't even have to be at the end as is sometimes the case when there are subpanels.

Pull Request: https://projects.blender.org/blender/blender/pulls/138797
2025-05-13 17:27:30 +02:00
Jacques Lucke
1e071603a2 Cleanup: Geometry Nodes: simplify property name escaping 2025-05-13 05:31:01 +02:00
Guillermo Venegas
a017a6cc54 Refactor: UI: Replace uiItemO with class method uiLayout::op
This converts the public `uiItemO` function to an object oriented
API (`uiLayout::op`).
Also this rearranges `idname` paramether, since this the only one
required, and to make format similar to `uiItemFullO`

Note: One of the benefits of moving from a public function to class
method is to reduce API usage difference between C++ and Python. In
Python this method is called `UILayout::operator`, however `operator`
is a reserved keyword in C++.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138776
2025-05-12 22:14:38 +02:00
Guillermo Venegas
858abf43c3 Refactor: UI: Replace uiItemFullR with class method uiLayout::prop
This converts the public `uiItemFullR` function to an object oriented
API (an overload of `uiLayout::prop`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138683
2025-05-10 03:39:31 +02:00
Jesse Yurkovich
eb82c4edf1 Format: use fmt::format correctly with runtime format strings
Starting with C++20, `fmt::format` will process the format string at
compile time by default. We need to opt out in the cases where this is
not possible by using `fmt::runtime(...)`, like, for example, when using
our various translation utilities.

This mirrors prior commit e62aa986b2 and
fixes 2 cases that have slipped back in.

Pull Request: https://projects.blender.org/blender/blender/pulls/138640
2025-05-09 06:43:48 +02:00
Guillermo Venegas
dafdced6ab Refactor: UI: Replace uiItemR with class method uiLayout::prop
This converts the public `uiItemR` function to an object oriented
API (`uiLayout::prop`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138617
2025-05-08 20:45:37 +02:00
Guillermo Venegas
e5dcd0de99 Refactor: UI: Replace uiItemL with class method uiLayout::label
This converts the public `uiItemL` function to an object oriented
API (`uiLayout::label`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138608
2025-05-08 17:21:08 +02:00
Jacques Lucke
8a42e2b59a Nodes: support expanded menus in node group interface
Previously, menu sockets were always drawn as dropdown. This patch adds the
ability to draw them expanded instead.

As before, in the node editor, only the expanded menu is drawn, without the
label. There is simply not enough space for both. However, in the modifier and
operator settings the label is drawn currently. We'll probably need to add a
separate `Hide Label` option (similar to `Hide Value`) for group inputs that
support it. That would also help a lot with e.g. object sockets.

Pull Request: https://projects.blender.org/blender/blender/pulls/138387
2025-05-08 04:31:09 +02:00
Hans Goudey
f90e448c6a Cleanup: Use blender::Mutex for various static mutexes
Change almost all `static ThreadMutex` to `static blender::Mutex`.
See b7a1325c3c.

Pull Request: https://projects.blender.org/blender/blender/pulls/138556
2025-05-07 19:32:00 +02:00
Jacques Lucke
b7a1325c3c BLI: use blender::Mutex by default which wraps tbb::mutex
This patch adds a new `BLI_mutex.hh` header which adds `blender::Mutex` as alias
for either `tbb::mutex` or `std::mutex` depending on whether TBB is enabled.

Description copied from the patch:
```
/**
 * blender::Mutex should be used as the default mutex in Blender. It implements a subset of the API
 * of std::mutex but has overall better guaranteed properties. It can be used with RAII helpers
 * like std::lock_guard. However, it is not compatible with e.g. std::condition_variable. So one
 * still has to use std::mutex for that case.
 *
 * The mutex provided by TBB has these properties:
 * - It's as fast as a spin-lock in the non-contended case, i.e. when no other thread is trying to
 *   lock the mutex at the same time.
 * - In the contended case, it spins a couple of times but then blocks to avoid draining system
 *   resources by spinning for a long time.
 * - It's only 1 byte large, compared to e.g. 40 bytes when using the std::mutex of GCC. This makes
 *   it more feasible to have many smaller mutexes which can improve scalability of algorithms
 *   compared to using fewer larger mutexes. Also it just reduces "memory slop" across Blender.
 * - It is *not* a fair mutex, i.e. it's not guaranteed that a thread will ever be able to lock the
 *   mutex when there are always more than one threads that try to lock it. In the majority of
 *   cases, using a fair mutex just causes extra overhead without any benefit. std::mutex is not
 *   guaranteed to be fair either.
 */
 ```

The performance benchmark suggests that the impact is negilible in almost
all cases. The only benchmarks that show interesting behavior are the once
testing foreach zones in Geometry Nodes. These tests are explicitly testing
overhead, which I still have to reduce over time. So it's not unexpected that
changing the mutex has an impact there. What's interesting is that on macos the
performance improves a lot while on linux it gets worse. Since that overhead
should eventually be removed almost entirely, I don't really consider that
blocking.

Links:
* Documentation of different mutex flavors in TBB:
  https://www.intel.com/content/www/us/en/docs/onetbb/developer-guide-api-reference/2021-12/mutex-flavors.html
* Older implementation of a similar mutex by me:
  https://archive.blender.org/developer/differential/0016/0016711/index.html
* Interesting read regarding how a mutex can be this small:
  https://webkit.org/blog/6161/locking-in-webkit/

Pull Request: https://projects.blender.org/blender/blender/pulls/138370
2025-05-07 04:53:16 +02:00
Guillermo Venegas
b83fe22703 Refactor: UI: Replace uiLayoutPanelPropWithBoolHeader with class method
This converts the public uiLayoutPanelPropWithBoolHeader function to an
object oriented API (`uiLayout::panel_prop_with_bool_header`), following
similar changes to the uiLayout API.

Pull Request: https://projects.blender.org/blender/blender/pulls/138523
2025-05-07 02:55:25 +02:00
Guillermo Venegas
c55b3fef02 Refactor: UI: Replace uiLayoutPanelProp with class method uiLayout::panel_prop
This converts the public `uiLayoutPanelProp` function to an object oriented
API (`uiLayout::panel_prop`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

Pull Request: https://projects.blender.org/blender/blender/pulls/138501
2025-05-06 17:13:30 +02:00
Jacques Lucke
e09ccc9b35 Core: add templated version of BKE_id_new_nomain to reduce explicit casting
This adds a version of `BKE_id_new_nomain` that takes the ID type parameter as
template argument. This allows the function the return the newly created ID with
the correct type, removing the need to use `static_cast` on the call-site.

To make this work, I added a static `id_type` member to every ID struct. This
can also be used to create a similar API for other id management functions in
future patches.

```cpp
// Old
Mesh *mesh = static_cast<Mesh *>(BKE_id_new_nomain(ID_ME, "Mesh"));

// New
Mesh *mesh = BKE_id_new_nomain<Mesh>("Mesh");
```

Pull Request: https://projects.blender.org/blender/blender/pulls/138383
2025-05-05 18:41:03 +02:00
Guillermo Venegas
9e5151d294 Refactor: UI: Replace uiLayoutSplit with class method uiLayout::split
This converts the public `uiLayoutSplit` function to an object oriented
API (`uiLayout::split`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

`uiLayout::split` now returns an `uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Pull Request: https://projects.blender.org/blender/blender/pulls/138361
2025-05-03 20:51:42 +02:00
Jacques Lucke
e8d1491e62 Refactor: Depsgraph: simplify query API further
* Remove `DEG_get_evaluated_object` in favor of `DEG_get_evaluated`.
* Remove `DEG_is_original_object` in favor of `DEG_is_original`.
* Remove `DEG_is_evaluated_object` in favor of `DEG_is_evaluated`.

Pull Request: https://projects.blender.org/blender/blender/pulls/138317
2025-05-02 15:08:29 +02:00
Campbell Barton
43af16a4c1 Cleanup: spelling in comments, correct comment block formatting
Also use doxygen comments more consistently.
2025-05-01 11:44:33 +10:00
Guillermo Venegas
8e499caded Refactor: UI: Replace uiLayoutColumnWithHeading with class method uiLayout::column
This converts the public `uiLayoutColumnWithHeading` function to an
object oriented API (an `uiLayout::column` overloaded version), matching
the python API.

Like the original `uiLayout::column`, this overloaded version now also
returns an `uiLayout` reference instead of a pointer. New calls to this
method should use references too.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138056
2025-04-27 17:09:52 +02:00
Guillermo Venegas
2d896877d1 Refactor: UI: Replace uiLayoutColumn with class method uiLayout::column
This converts the public `uiLayoutColumn` function to an object oriented
API (`uiLayout::column`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

`uiLayout::column` now returns an `uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Pull Request: https://projects.blender.org/blender/blender/pulls/138034
2025-04-26 21:07:34 +02:00
Guillermo Venegas
f0f0361254 Refactor: UI: Replace uiLayoutRowWithHeading with class method uiLayout::row
This converts the public `uiLayoutRowWithHeading` function to an object oriented
API (an `uiLayout::row` overloaded version), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

Same as the original `uiLayout::row`, this overloaded version also now returns an
`uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138014
2025-04-26 02:17:31 +02:00
Guillermo Venegas
90644b30b2 Refactor: UI: Replace uiLayoutRow with class method uiLayout::row
This converts the public `uiLayoutRow` function to an object oriented
API (`uiLayout::row`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

`uiLayout::row` now returns an `uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/137979
2025-04-25 19:45:25 +02:00
Lukas Stockner
bf412ed9dd Cycles: Support for custom OSL cameras
This allows users to implement arbitrary camera models using OSL by writing
shaders that take an image position as input and compute ray origin and
direction.

The obvious applications for this are e.g. panorama modes, lens distortion
models and realistic lens simulation, but the possibilities are endless.

Currently, this is only supported on devices with OSL support, so CPU and
OptiX. However, it is independent from the shading model used, so custom
cameras can be used without getting the performance hit of OSL shading.

A few samples are provided as Text Editor templates.

One notable current limitation (in addition to the limited device support)
is that inverse mapping is not supported, so Window texture coordinates and
the Vector pass will not work with custom cameras.

Pull Request: https://projects.blender.org/blender/blender/pulls/129495
2025-04-25 19:27:30 +02:00
Hans Goudey
8db322f1f5 Fix #137902: Manifold boolean modifier solver doubles object transform
The object to world transform was applied to the result (which was
meant to be in world space), rather than the inverse. However, the
processing of transforms is more complicated than necessary. Instead
of passing around a separate "target transform" that's meant to be used
inverted after the boolean operation, just make the input transforms
transform the input meshes into the desired transform space of the
output (object-local space for the modifier).

Pull Request: https://projects.blender.org/blender/blender/pulls/137919
2025-04-23 20:37:53 +02:00
Howard Trickey
dd559259d8 Modeling: Add a new boolean solver based on the Manifold library.
Adds the 'manifold' solver option to the Boolean geo node and to
the Boolean modifier. This solver is about as fast, or faster,
than the current float solver, and is robust against floating
point issues like the Exact solver. But currently it only
works on mesh arguments that are strictly manifold.

See https://projects.blender.org/blender/blender/issues/120182
for many more details.
2025-04-22 21:23:37 -04:00
Brecht Van Lommel
d061b00455 Refactor: Eliminate various unsafe memcpy and memset
Some of these already have warnings with clang-tidy, others are more
safe in case these structs get (copy) constructors in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/137404
2025-04-21 17:59:41 +02:00
Brecht Van Lommel
388a21e260 Refactor: Eliminate various void pointers passed to MEM_freeN
It's safer to pass a type so that it can be checked if delete should be
used instead. Also changes a few void pointer casts to const_cast so that
if the data becomes typed it's an error.

Pull Request: https://projects.blender.org/blender/blender/pulls/137404
2025-04-21 17:59:41 +02:00
Brecht Van Lommel
637c6497e9 Refactor: Use more typed MEM_calloc<>, avoid unnecessary size_t cast
Handle some cases that were missed in previous refactor. And eliminate
unnecessary size_t casts as these could hide issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/137404
2025-04-21 17:59:41 +02:00
Falk David
69a722cee5 Geometry Nodes: Add Grease Pencil layer name search
This makes it possible to search layer names in the
`Named Layer Selection` node as well as boolean
modifier inputs that are marked as a `Layer Selection`.

The layer selection UI is slightly updated:
* Use a slightly larger default width for the
   `Named Layer Selection` node.
* Use the layer icon in the field that search for layer names.
* Use `Layer` placeholder string

Pull Request: https://projects.blender.org/blender/blender/pulls/137273
2025-04-18 12:35:49 +02:00
Jacques Lucke
f442c86197 Depsgraph: improve type safety when getting evaluated or original ID
The goal here is to avoid having to cast to and from `ID` when getting the
evaluated or original ID using the depsgraph API, which is often verbose and not
type safe. To solve this, there are now `DEG_get_original` and
`DEG_get_evaluated` methods which are templated on the type and use a new
`is_ID_v` static type check to make sure it's only used with valid types.

This allows removing quite some verbosity on all the call sites. I also removed
`DEG_get_original_object`, because that does not have to be a special case
anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/137629
2025-04-17 13:09:20 +02:00
Jacques Lucke
a0444a5a2d Geometry Nodes: support viewers in closures
This adds support for having viewer nodes in closures. The code attempt to
detect where the closure is evaluated and shows the data from there.

If the closure is evaluated in multiple Evaluate Closure nodes, currently it
just picks the first one it finds. Support for more user control in this case
may be added a bit later. If the Evaluate Closure node is in e.g. the repeat or
foreach zone, it will automatically use the inspection index of that zone to
determine what evaluation to look at specifically.

Overall, not too much had to change conceptually to support viewers in closures.
Just some code like converting between viewer paths and compute contexts had to
be generalized a little bit.

Pull Request: https://projects.blender.org/blender/blender/pulls/137625
2025-04-16 23:35:59 +02:00
Jacques Lucke
411d4204f6 Refactor: Geometry Nodes: simplify getting compute context for edittree
This adds a simple `compute_context_for_edittree` function that returns the
"active" compute context for the given node editor. This is used in various
places, but previously one had to construct the compute context in multiple
steps (first find the root context (modifier/operator), then handle the tree
path). Since the edittree already has a specific active context, there should be
an easy way to retrieve that.

This also adds a few extra check that avoid redundant work that was done before.

Pull Request: https://projects.blender.org/blender/blender/pulls/137525
2025-04-15 15:24:29 +02:00
Jacques Lucke
be266a1c0c Refactor: Geometry Nodes: replace ComputeContextBuilder with ComputeContextCache
While `ComputeContextBuilder` worked well for building simple linear compute
contexts, it was fairly limiting for all the slightly more complex cases where
an entire tree of compute contexts is built. Using `ComputeContextCache` that is
easier to do more explicitly. There were only very few cases where using
`ComputeContextBuilder` would have still helped a bit, but it's not really worth
keeping that abstraction around just for those few cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/137370
2025-04-14 17:47:56 +02:00
Jacques Lucke
3ae20bf166 Cleanup: remove foreach macro from .clang-format
The usage of that macro was removed in 60bec183cb,
but it was still in our .clang-format file. This lead to worse formatting when other code
used methods named `foreach`.

Pull Request: https://projects.blender.org/blender/blender/pulls/137468
2025-04-14 16:17:00 +02:00
YimingWu
47c7000392 Cleanup: Grease Pencil: Remove unused variables.
Previously the change in f5c0c81b7ee6f127f44543179f17fd475f115842 left
an unused variable and is removed by this fix.
2025-04-14 21:21:52 +08:00
Pratik Borhade
062c5ab225 Fix #137385: Grease Pencil: Thickness modifier doesn't work with vgroup filter
Use `get_influence_vertex_weights` for thickness modifier. This returns
array of values 0 when group is empty (see `lookup_or_default`).
Function also controls the invert state for vertex group.

Pull Request: https://projects.blender.org/blender/blender/pulls/137455
2025-04-14 10:20:49 +02:00
YimingWu
b0e4c31bb0 Fix #134494: Grease Pencil: Tint modifier fix on gradient material
When a stroke has a gradient fill material that starts with a color with
zero alpha, the tint modifier would behave as if it's not effective at
all, this is caused by referencing source material color only with the
starting color in this case, and since the alpha is zero, the tint is
applied wrongly. Now use average color of start and end color of the
gradient to mix with the tint modifier color.

Note that this isn't technically correct still, since material gradient
is computed in the shader, and tint modifier isn't able to get the
acutal fill color at a given vertex (especially for the radial gradient
case) however the result of this patch looks visually good enough, and
users can always set all alpha to 1 when they feel the color is off.

Pull Request: https://projects.blender.org/blender/blender/pulls/134549
2025-04-11 11:34:58 +02:00
Jacques Lucke
dcc8d28859 Refactor: Geometry Nodes: store tree identifier in tree logger
The main goal here is to add `GeoTreeLogger.tree_orig_session_uid`. Previously,
it was always possible to derive this information in `ensure_node_warnings`.
However, with closures that's not possible in general anymore, because the
Evaluate Closure node does not know statically which node tree the closure zone
is from that it evaluates. Therefore, this information has to be logged as well.

This patch initializes `tree_orig_session_uid` the same way it initializes
`parent_node_id`, by scanning the compute context when creating the tree logger.
To make this work properly, some extra contextual data had to be stored in some
compute contexts.

This is just a refactor with no expected functional changes. Node warnings for
closures are still not properly logged, because that requires storing
source-location data in closures, which will be implemented separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/137208
2025-04-10 08:56:02 +02:00
David Murmann
73efe738e4 Fix #135696: Alembic: Interpolate curve control points
Reading curves from alembic files did not interpolate the curves between
frames, leading to incorrect motion blur. This uses the existing
`use_vertex_interpolation` flag on the MeshSequenceCache to enable the
subframe interpolation.

Pull Request: https://projects.blender.org/blender/blender/pulls/135698
2025-04-09 06:50:25 +02:00
Jacques Lucke
bf5339df14 Fix #137114: crash due to bad mesh ownership handling
When releasing a mesh from a `GeometrySet` one has to take manual control over
owner-management. In some cases, the geometry set was not the owner of the mesh,
but was just referencing it. This is generally fine in a limited set of
circumstances and can avoid copies. However, when taking ownership of the mesh
in the geometry set, one has to be sure that the geometry set actually has
ownership.

This is similar to what is done in e.g. `modifier_modify_mesh_and_geometry_set`.

Pull Request: https://projects.blender.org/blender/blender/pulls/137150
2025-04-08 16:11:52 +02:00
Hans Goudey
cf6ee877a0 Modifiers: Simplify displace modifier custom normals access
`BKE_mesh_normals_loop_to_vertex` is redundant with `Mesh::vert_normals()`.
Also fix the use of "true normals" vs. "normals".
2025-04-07 10:42:10 -04:00
Jesse Yurkovich
f60c528c48 Cleanup: Fix one-definition-rule violations for various structs
This fixes most "One Definition Rule" violations inside blender proper
resulting from duplicate structures of the same name. The fixes were
made similar to that of !135491. See also #120444 for how this has come
up in the past.

These were found by using the following compile options:
-flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

Note: There are still various ODR issues remaining that require
more / different fixes than what was done here.

Pull Request: https://projects.blender.org/blender/blender/pulls/136371
2025-04-04 21:05:16 +02:00
Hans Goudey
d3f84449ad Mesh: Add "free" custom normals
Add a "dumb vector" storage option for custom normals, with the
"custom_normal" attribute. Adjust the mesh normals caching to
provide this attribute if it's available, and add a geometry node to
store custom normals.

## Free Normals
They're called "free" in the sense that they're just direction vectors
in the object's local space, rather than the existing "smooth corner
fan space" storage. They're also "free" in that they make further
normals calculation very inexpensive, since we just use the custom
normals instead. That's a big improvement from the existing custom
normals storage, which usually significantly decreases
viewport performance. For example, in a simple test file just storing
the vertex normals on a UV sphere, using free normals gives 25 times
better playback performance and 10% lower memory usage.

Free normals are adjusted when applying a transformation to the entire
mesh or when realizing instances, but in general they're not updated for
vertex deformations.

## Set Mesh Normal Node
The new geometry node allows storing free custom normals as well as
the existing corner fan space normals. When free normals are chosen,
free normals can be stored on vertices, faces, or face corners. Using
the face corner domain is necessary to bake existing mixed sharp and
smooth edges into the custom normal vectors.

The node also has a mode for storing edge and mesh sharpness, meant
as a "soft" replacement to the "Set Shade Smooth" node that's a bit
more convenient.

## Normal Input Node
The normal node outputs free custom normals mixed to whatever domain is
requested. A "true normal" output that ignores custom normals and
sharpness is added as well.

Across Blender, custom normals are generally accessed via face and
vertex normals, when "true normals" are not requested explicitly.
In many cases that means they are mixed from the face corner domain.

## Future Work
1. There are many places where propagation of free normals could be
   improved. They should probably be normalized after mixing, and it
   may be useful to not just use 0 vectors for new elements. To keep
   the scope of this change smaller, that sort of thing generally isn't
   handled here. Searching `CD_NORMAL` gives a hint of where better
   propagation could be useful.
2. Free normals are displayed properly in edit mode, but the existing
   custom normal editing operators don't work with free normals yet.
   This will hopefully be fairly straightforward since custom normals
   are usually converted to `float3` for editing anyway. Edit mode
   changes aren't included here because they're unnecessary for the
   procedural custom normals use cases.
3. Most importers can probably switch to using free normals instead,
   or at least provide an option for it. That will give a significant
   import performance improvement, and an improvement of Blender's
   FPS for imported scenes too.

Pull Request: https://projects.blender.org/blender/blender/pulls/132583
2025-04-04 19:16:51 +02:00
YimingWu
b54d629401 Fix: Line Art: Prevent loading empty meshes
In `lineart_geometry_check_visible` it could recieve a valid mesh
without any vertices, this causes `bounds` below to be invalid.
Now return early if encountered such situation.

Pull Request: https://projects.blender.org/blender/blender/pulls/136819
2025-04-04 12:04:20 +02:00
Jacques Lucke
8ec9c62d3e Geometry Nodes: add Closures and Bundles behind experimental feature flag
This implements bundles and closures which are described in more detail in this
blog post: https://code.blender.org/2024/11/geometry-nodes-workshop-october-2024/

tl;dr:
* Bundles are containers that allow storing multiple socket values in a single
  value. Each value in the bundle is identified by a name. Bundles can be
  nested.
* Closures are functions that are created with the Closure Zone and can be
  evaluated with the Evaluate Closure node.

To use the patch, the `Bundle and Closure Nodes` experimental feature has to be
enabled. This is necessary, because these features are not fully done yet and
still need iterations to improve the workflow before they can be officially
released. These iterations are easier to do in `main` than in a separate branch
though. That's because this patch is quite large and somewhat prone to merge
conflicts. Also other work we want to do, depends on this.

This adds the following new nodes:
* Combine Bundle: can pack multiple values into one.
* Separate Bundle: extracts values from a bundle.
* Closure Zone: outputs a closure zone for use in the `Evaluate Closure` node.
* Evaluate Closure: evaluates the passed in closure.

Things that will be added soon after this lands:
* Fields in bundles and closures. The way this is done changes with #134811, so
  I rather implement this once both are in `main`.
* UI features for keeping sockets in sync (right now there are warnings only).

One bigger issue is the limited support for lazyness. For example, all inputs of
a Combine Bundle node will be evaluated, even if they are not all needed. The
same is true for all captured values of a closure. This is a deeper limitation
that needs to be resolved at some point. This will likely be done after an
initial version of this patch is done.

Pull Request: https://projects.blender.org/blender/blender/pulls/128340
2025-04-03 15:44:06 +02:00
YimingWu
3522e2bd26 Fix #136868: Line Art: Wrong index when transferring vertex weight
This was an issue previously not noticed. There were two bugs:

- When an out of range index was somehow detected, line art discards the
  entire stroke after the point, which causes remaining point positions
  to be invalid. In fact the index should never go out of range unless
  total points in the scene exceeds `size_t`.
- Line art point index is global, not local to objects, previously the
  "object starting index" was not subtracted from the final point index
  when transferring weights, this will lead to incorrect weight being
  transferred/discarded.

Now both problems have been properly taken care of.

Pull Request: https://projects.blender.org/blender/blender/pulls/136869
2025-04-02 10:58:49 +02:00
Guillermo Venegas
6397a4fb9a Refactor: UI: Use typed enum class for eUIEmbossType enum
Part of incoming refactors in interface layout c++ code, this enables
forward declaring this enum type. Enum is renamed as `EmbossType` and
moved to `blender::ui` namespace. No user visible changes expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/136725
2025-03-31 00:36:46 +02:00
Sean Kim
c5cda9474e Fix #136637: Voxel remesh crashes with small input
Caused by 6c05859b12

OpenVDB does not handle transformations with determinants smaller than
3e-15 and throws an `ArithmeticError` when a `Transform` is created
with invalid values.

To avoid abrupt crashes on the user side, this commit catches the error
and displays a warning message.

Pull Request: https://projects.blender.org/blender/blender/pulls/136690
2025-03-29 02:52:00 +01:00
Cartesian Caramel
ade8576bf7 Geometry Nodes: new Camera Info Node
This adds a new Camera Info node to Geometry Nodes. It provides information
about the passed in camera like its projection matrix and focus distance.

This can be used for camera culling which was must more complex before.
It also allows building other view-dependent effects.

Pull Request: https://projects.blender.org/blender/blender/pulls/135311
2025-03-28 22:54:13 +01:00
Hans Goudey
448d3d04d9 Cleanup: Unify and clean up mesh transform & translation functions
Use C++ types, move to C++ header, use them consistently in the
geometry transform function.
2025-03-28 11:36:39 -04:00