Commit Graph

2979 Commits

Author SHA1 Message Date
Jacques Lucke 2ffd08e952 Geometry Nodes: deterministic anonymous attribute lifetimes
Previously, the lifetimes of anonymous attributes were determined by
reference counts which were non-deterministic when multiple threads
are used. Now the lifetimes of anonymous attributes are handled
more explicitly and deterministically. This is a prerequisite for any kind
of caching, because caching the output of nodes that do things
non-deterministically and have "invisible inputs" (reference counts)
doesn't really work.

For more details for how deterministic lifetimes are achieved, see D16858.

No functional changes are expected. Small performance changes are expected
as well (within few percent, anything larger regressions should be reported as
bugs).

Differential Revision: https://developer.blender.org/D16858
2023-01-05 14:05:30 +01:00
Hans Goudey c26616b2c1 Curves: Support boolean attribute selection type, simplifications
Use the same `".selection"` attribute for both curve and point domains,
instead of a different name for each. The attribute can now have
either boolean or float type. Some tools create boolean selections.
Other tools create float selections. Some tools "upgrade" the attribute
from boolean to float.

Edit mode tools that create selections from scratch can create boolean
selections, but edit mode should generally be able to handle both
selection types. Sculpt mode should be able to read boolean selections,
but can also and write float values between zero and one.

Theoretically we could just always use floats to store selections,
but the type-agnosticism doesn't cost too much complexity given the
existing APIs for dealing with it, and being able to use booleans is
clearer in edit mode, and may allow future optimizations like more
efficient ways to store boolean attributes.

The attribute API is usually used directly for accessing the selection
attribute. We rely on implicit type conversion and domain interpolation
to simplify the rest of the code.

Differential Revision: https://developer.blender.org/D16057
2023-01-03 23:05:29 -05:00
Pratik Borhade e438e8e04e Fix T102993: Incorrect icon displaying of Weighted Normal modifier in the outliner
Mistake in {rBd15e8bdaa3343cf97a74f918b2570e66fb7abfa0}

Reviewed by: JacquesLucke

Differential Revision: https://developer.blender.org/D16890
2023-01-03 14:56:11 +05:30
Campbell Barton e39ca9d1e3 Cleanup: use function style casts for integer types in C++
Also remove redundant parenthesis.
2023-01-03 11:12:51 +11:00
Jacques Lucke 4d39b6b3f4 Geometry Nodes: skip logging socket values for invisible trees
Geometry nodes used to log all socket values during evaluation.
This allowed the user to hover over any socket (that was evaluated)
to see its last value. The problem is that in large (nested) node trees,
the number of sockets becomes huge, causing a lot of performance
and memory overhead (in extreme cases, more than 70% of the
total execution time).

This patch changes it so, that only socket values are logged that the
user is likely to investigate. The simple heuristic is that socket values
of the currently visible node tree are logged.

The downside is that when the user changes the visible node tree, it
won't have any logged values until it is reevaluated. I updated the
tooltip message for that case to be a bit more precise.
If user feedback suggests that this new behavior is too annoying, we
can always add a UI option to log all socket values again. That shouldn't
be done without an actual need though because it takes up UI space.

Differential Revision: https://developer.blender.org/D16884
2022-12-29 19:36:36 +01:00
Hans Goudey 2652029f3b Cleanup: Clang tidy
Addressed almost all warnings except for replacing defines
with enums and variable assignment in if statements.
2022-12-29 12:01:32 -05:00
Chris Blackbourn 8c194e1ba6 Cleanup: format 2022-12-29 20:49:08 +13:00
Hans Goudey b492dc3579 Cleanup: Remove unused modifier and BMesh includes 2022-12-21 13:10:51 -06:00
Germano Cavalcante fb7f12dc40 Cleanup: hide 'UNUSED' macro definition for C++
This may allow the `C4100` warning to be re-enabled in the MSVC for C++.

Differential Revision: https://developer.blender.org/D16828
2022-12-20 19:16:33 -03:00
Germano Cavalcante cc13934442 Cleanup: convert 'MOD_mirror.c' to C++
It will be useful to use the merge verts API in C++.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D16823
2022-12-20 15:53:10 -03:00
Hans Goudey 4ae0da1bbc Geometry Nodes: Avoid mesh copy in some cases
Accessing a mesh with write access can be costly if it is used
elsewhere at the same time because of copy-on-write. When always did
that at the end of the modifier calculation, but it's trivial to only
do that when we might need actually use the mesh to add original
index layers.
2022-12-19 14:24:49 -06:00
Jacques Lucke 28511ac6cf Fix T103294: bring back modifyMesh function for geometry nodes modifier
This was removed inrBb1494bcea7b6bb608 under the assumption that
it is not needed anymore. Apparently it is, so this commit brings it back.
2022-12-17 14:46:15 +01:00
Campbell Barton 067fe443d8 Cleanup: consistent naming for normals
Use consistent naming for {vert/poly/loop/face}_normals.
2022-12-17 13:06:43 +11:00
Hans Goudey b1494bcea7 Geometry Nodes: Add error message when applying modifier with no mesh
If the resulting geometry from applying a geometry nodes modifier
contains no mesh, give an error message. This gives people something to
search and makes the behavior more purposeful.

Also remove the `modifyMesh` implementation from the geometry nodes
modifier, since it isn't necessary anymore. And remove the existing
"Modifier returned error, skipping apply" message which was cryptic
and redundant if applying returns an actual error message.

Resolves T103229

Differential Revision: https://developer.blender.org/D16782
2022-12-15 14:21:35 -06:00
Jacques Lucke ea7570989d Cleanup: add utility method to get group input nodes 2022-12-13 17:25:51 +01:00
Hans Goudey ab1c36ad3f Cleanup: Move two modifier files to C++ 2022-12-12 18:19:32 -06:00
Hans Goudey b000fc308b Cleanup: Resolve unused variable warnings in modifier 2022-12-09 14:26:15 -06:00
Kévin Dietrich 9b57a2ac6a Cleanup: helper function for MeshSequenceCache ORCO evaluation
This splits the logic to detect if the MeshSequenceCache modifier
evaluation is for the ORCO mesh into its own function. This will allow
reusing the logic for when GeometrySet support is added to the modifier
(D11592).

No functionnal changes.

Differential Revision: https://developer.blender.org/D16611
2022-12-09 04:25:29 +01:00
Campbell Barton a0dc062816 Cleanup: use function style casts for integer types in C++ 2022-12-08 13:47:55 +11:00
Jacques Lucke 3d5a4fbcc2 Cleanup: move some files that use normals to C++
Doing this to help with T102858.
2022-12-02 12:34:26 +01:00
Hans Goudey 90ea1b7643 Nodes: Use persistent integer to identify to nodes
This patch adds an integer identifier to nodes that doesn't change when
the node name changes. This identifier can be used by different systems
to reference a node. This may be important to store caches and simulation
states per node, because otherwise those would always be invalidated
when a node name changes.

Additionally, this kind of identifier could make some things more efficient,
because with it an integer is enough to identify a node and one does not
have to store the node name.

I observed a 10% improvement in evaluation time in a file with an extreme
number of simple math nodes, due to reduced logging overhead-- from
0.226s to 0.205s.

Differential Revision: https://developer.blender.org/D15775
2022-12-01 15:08:12 -06:00
Hans Goudey 7540842ca7 Fix T99592: Exact Boolean: Skip empty materials, add index-based option
**Empty Slot Fix**
Currently the boolean modifier transfers the default material from
meshes with no materials and empty material slots to the faces on the
base mesh. I added this in a2d59b2dac9e for the sake of consistency,
but the behavior is actually not useful at all. The default empty
material isn't chosen by users, it just signifies "nothing," so when
it replaces a material chosen by users, it feels like a bug.

This commit corrects that behavior by only transferring materials from
non-empty material slots. The implementation is now consistent between
exact mode of the boolean modifier and the geometry node.

**Index-Based Option**

"Index-based" is the new default material method for the boolean
modifier, to access the old behavior from before the breaking commit.

a2d59b2dac9e actually broke some Boolean workflows fundamentally, since
it was important to set up matching slot indices on each operand. That
isn't the cleanest workflow, and it breaks when materials change
procedurally, but historically that hasn't been a problem. The
"transfer" behavior transfers all materials except for empty slots,
but the fundamental problem is that there isn't a good way to specify
the result materials besides using the slot indices.

Even then, the transfer option is a bit more intuitive and useful for
some simpler situations, and it allows accessing the behavior that has
been in 3.2 and 3.3 for a long time, so it's also left in as an option.
The geometry node doesn't get this new option, in the hope that we'll
find a better solution in the future.

Differential Revision: https://developer.blender.org/D16187
2022-11-28 21:03:07 +01:00
Hans Goudey 70041ced14 Cleanup: Remove unused mesh array variables and arguments 2022-11-28 08:19:33 -06:00
Hans Goudey 2cb6b0b4eb Merge branch 'blender-v3.4-release' 2022-11-22 15:52:33 -06:00
Hans Goudey 41ae2c6438 Fix T102700: Viewer node missing check for empty geometry component
`GeometrySet::has()` can return an empty component. It's more convenient
if it doesn't, since other code rarely wants to access an empty component.

The alternative would be adding an `is_empty()` check in the lazy function
for the viewer node, that would work fine too, for this case.

Differential Revision: https://developer.blender.org/D16584
2022-11-22 15:40:42 -06:00
Hans Goudey 1ea169d90e Mesh: Move loose edge flag to a separate cache
As part of T95966, this patch moves loose edge information out of the
flag on each edge and into a new lazily calculated cache in mesh
runtime data. The number of loose edges is also cached, so further
processing can be skipped completely when there are no loose edges.

Previously the `ME_LOOSEEDGE` flag was updated on a "best effort"
basis. In order to be sure that it was correct, you had to be sure
to call `BKE_mesh_calc_edges_loose` first. Now the loose edge tag
is always correct. It also doesn't have to be calculated eagerly
in various places like the screw modifier where the complexity
wasn't worth the theoretical performance benefit.

The patch also adds a function to eagerly set the number of loose
edges to zero to avoid building the cache. This is used by various
primitive nodes, with the goal of improving drawing performance.
This results in a few ms shaved off extracting draw data for some
large meshes in my tests.

In the Python API, `MeshEdge.is_loose` is no longer editable.
No built-in addons set the value anyway. The upside is that
addons can be sure the data is correct based on the mesh.

**Tests**
There is one test failure in the Python OBJ exporter: `export_obj_cube`
that happens because of existing incorrect versioning. Opening the
file in master, all the edges were set to "loose", which is fixed
by this patch.

Differential Revision: https://developer.blender.org/D16504
2022-11-18 16:05:06 -06:00
Jacques Lucke a6c822733a BLI: improve CPPType system
* Support bidirectional type lookups. E.g. finding the base type of a
  field was supported, but not the other way around. This also removes
  the todo in `get_vector_type`. To achieve this, types have to be
  registered up-front.
* Separate `CPPType` from other "type traits". For example, previously
  `ValueOrFieldCPPType` adds additional behavior on top of `CPPType`.
  Previously, it was a subclass, now it just contains a reference to the
  `CPPType` it corresponds to. This follows the composition-over-inheritance
  idea. This makes it easier to have self-contained "type traits" without
  having to put everything into `CPPType`.

Differential Revision: https://developer.blender.org/D16479
2022-11-12 18:33:31 +01:00
Hans Goudey 1a8516163f Cleanup: Simplify handling of loop to poly map in normal calculation
A Loop to poly map was passed as an optional output to the loop normal
calculation. That meant it was often recalculated more than necessary.
Instead, treat it as an optional argument. This also helps relieve
unnecessary responsibilities from the already-complicated loop normal
calculation code.
2022-11-11 23:27:36 -06:00
Brecht Van Lommel 501036faae Merge branch 'blender-v3.4-release' 2022-11-09 20:42:19 +01:00
Brecht Van Lommel 7f6521f8dc Fix T100883: crash with particle instancing and clumping
Properly initialize clump curve mapping tables for duplis and other cases
where this was missed by making a generic init/free function instead of
duplicating the same logic in multiple places. Also fold lattice deform
init into this.
2022-11-09 20:37:55 +01:00
Leon Schittek 8eab23bc66 Geometry Nodes: Fix alignment of exposed properties in the modifier
The spacing and alignment of the properties in the geometry nodes
modifier could vary depending on the type of the socket or
whether the input can accept attributes.
Wrapping each property in its own `row` layout allows us to make
the spacing and alignment between them consistent.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16417
2022-11-08 19:14:29 +01:00
Leon Schittek fd35216025 Geometry Nodes: Fix alignment of exposed properties in the modifier
The spacing and alignment of the properties in the geometry nodes
modifier could vary depending on the type of the socket or
whether the input can accept attributes.
Wrapping each property in its own `row` layout allows us to make
the spacing and alignment between them consistent.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16417
2022-11-08 19:09:28 +01:00
Campbell Barton 8b151982fe Merge branch 'blender-v3.4-release' 2022-11-08 17:00:46 +11:00
Campbell Barton 642ff82f74 Cleanup: format, remove commented code & unused variable 2022-11-08 16:58:37 +11:00
Philipp Oeser 888fb0b395 Merge branch 'blender-v3.4-release' 2022-11-07 12:32:36 +01:00
Philipp Oeser ffc0db1994 Fix Curves Smooth modifier appears to be able to act on control points
This is not the case though, the modifier act explicitly on mesh edges,
if no tesselated mesh is provided, it would simpy early out and do
nothing.

Now always disable the "Apply on Spline" option with a tip that this
modifier can only smooth the tesselated curve (not the underlying curve
control points). Similar to rB1a6b51e17502.

Fixes T102060.

Maniphest Tasks: T102060

Differential Revision: https://developer.blender.org/D16386
2022-11-07 12:25:20 +01:00
Jacques Lucke 37ca6e4fd1 Merge branch 'blender-v3.4-release' 2022-11-06 15:45:45 +01:00
Jacques Lucke 25c6444bad Fix T102153: crash when muting node group with active viewer 2022-11-06 15:39:57 +01:00
Hans Goudey 10131a6f62 Cleanup: Mesh: Remove redundant edge render flag
Currently there are both "EDGERENDER" and "EDGEDRAW" flags, which are
almost always used together. Both are runtime data and not exposed to
RNA, used to skip drawing some edges after the subdivision surface
modifier. The render flag is a relic of the Blender internal renderer.
This commit removes the render flag and replaces its uses with the
draw flag.
2022-11-04 20:19:52 +01:00
Sergey Sharybin 38c7fd36ff Refactor: Rename Object->imat to Object->world_to_object
The goal is to improve clarity and readability, without
introducing big design changes.

Follows the recent obmat to object_to_world refactor: the
similar naming is used, and it is a run-time only rename,
meaning, there is no affect on .blend files.

This patch does not touch the redundant inversions. Those
can be removed in almost (if not all) cases, but it would
be the best to do it as a separate change.

Differential Revision: https://developer.blender.org/D16367
2022-11-02 15:42:23 +01:00
Sergey Sharybin f17fbf8065 Refactor: Rename Object->obmat to Object->object_to_world
Motivation is to disambiguate on the naming level what the matrix
actually means. It is very easy to understand the meaning backwards,
especially since in Python the name goes the opposite way (it is
called `world_matrix` in the Python API).

It is important to disambiguate the naming without making developers
to look into the comment in the header file (which is also not super
clear either). Additionally, more clear naming facilitates the unit
verification (or, in this case, space validation) when reading an
expression.

This patch calls the matrix `object_to_world` which makes it clear
from the local code what is it exactly going on. This is only done
on DNA level, and a lot of local variables still follow the old
naming.

A DNA rename is setup in a way that there is no change on the file
level, so there should be no regressions at all.

The possibility is to add `_matrix` or `_mat` suffix to the name
to make it explicit that it is a matrix. Although, not sure if it
really helps the readability, or is it something redundant.

Differential Revision: https://developer.blender.org/D16328
2022-11-01 10:48:18 +01:00
Hans Goudey c34c6d3e25 Mesh: Move runtime data out of DNA
This commit replaces the `Mesh_Runtime` struct embedded in `Mesh`
with `blender::bke::MeshRuntime`. This has quite a few benefits:
- It's possible to use C++ types like `std::mutex`, `Array`,
  `BitVector`, etc. more easily
- Meshes saved in files are slightly smaller
- Copying and writing meshes is a bit more obvious without
  clearing of runtime data, etc.

The first is by far the most important. It will allows us to avoid a
bunch of manual memory management boilerplate that is error-prone and
annoying. It should also simplify future CoW improvements for runtime
data.

This patch doesn't change anything besides changing `mesh.runtime.data`
to `mesh.runtime->data`. The cleanups above will happen separately.

Differential Revision: https://developer.blender.org/D16180
2022-10-12 20:55:57 -05:00
Campbell Barton 984b279ef1 Cleanup: use commented arguments for unused args in C++ 2022-10-12 10:39:12 +11:00
Campbell Barton 331f850056 Cleanup: redundant parenthesis 2022-10-07 22:55:03 +11:00
Campbell Barton 11abeae99f Cleanup: use function style casts for C++ 2022-10-07 22:55:03 +11:00
Campbell Barton ecc404ea1a Cleanup: spelling in comments 2022-10-07 10:42:56 +11:00
Hans Goudey 406a98aff8 Cleanup: Move eight modifier files to C++
In preparation for moving mesh runtime data to C++.
2022-10-06 16:08:07 -05:00
Brecht Van Lommel bfeb64d620 Cleanup: make format 2022-10-05 21:40:58 +02:00
Hans Goudey 548a2cbe06 Cleanup: Clang tidy
Also remove unnecessary struct keywords in C++ files.
2022-10-05 13:48:01 -05:00
Damien Picard f5d67f3fdf I18n: disambiguate a few messages
- Active Track (NLA vs movie clip)
- New (file)
- Object Index (loop cut)
- Object Index (render pass)
- Proxy Storage (sequence)
- Rim (Solidify modifier)
- Roughness (particle children)
- Spaces (text whitespace)
- Out (sequencer wipe transition)

Also make new asset tag name translatable.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D16067
2022-10-05 17:53:37 +02:00