Commit Graph

18 Commits

Author SHA1 Message Date
Hans Goudey
947658d1b2 Refactor: Simplify CustomData functions by requiring ImplicitSharingInfo
Previously we generally expected CustomData layers to have implicit
sharing info, but we didn't require it. This PR clarifies that we do
require layers with non-null data to have implicit sharing info. This
generally makes code simpler because we don't have to have a separate
code path for non-shared layers. For example, it makes the "totelem"
arguments for layer freeing functions unnecessary, since shared data
knows how to free itself. Those arguments are removed in this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/134578
2025-02-17 19:44:54 +01:00
Hans Goudey
5e3951541e Cleanup: A few clang tidy fixes for geometry module
Mostly removing unused includes.

Pull Request: https://projects.blender.org/blender/blender/pulls/133078
2025-01-15 02:56:59 +01:00
Bastien Montagne
bb24677a76 Cleanup: Rename CustomData_copy to CustomData_initi_from.
And same for the `copy_layout` function. These functions do not free any
potentially existing data in destination, but expect it to be uninitialized.
Hopefully these new names will make it more clear and avoid bugs like #122160.
2024-08-26 19:11:02 +02:00
Hans Goudey
6099252dd4 Instances: Move transforms to attribute
Similar to 2e6223d90f, but potentially 16 times more effective.
The new attribute is named "instance_transform". It isn't displayed in the
spreadsheet since that wouldn't really be useful. This simplifies a lot of
code since it doesn't have to handle transforms specially anymore. But
complexity is added in the store named attribute node and attribute input
node to keep the old "position" attribute working for compatibility.

Pull Request: https://projects.blender.org/blender/blender/pulls/118531
2024-02-22 17:57:09 +01:00
Campbell Barton
0933e21750 Cleanup: unused includes in source/blender/geometry
Remove 13 includes.
2024-02-13 19:21:03 +11:00
Bastien Montagne
54618dbae3 Cleanup: Make BKE_global.h a Cpp header. 2024-02-10 18:25:14 +01:00
Hans Goudey
2e6223d90f Geometry Nodes: Move instance reference indices to a builtin attribute
This means the array can be shared between geometries when unchanged,
reducing memory usage and increasing performance. It also means that
handling the data can be done more generically using the attribute
system. In the future the transforms can become attributes too.

Two other changes are related here:
- The "almost unique ids" are cached with a shared cache so they
  are shared too.
- The reference indices are baked as an attribute now, making the process
  more generic and potentially easier to optimize in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/117951
2024-02-08 20:55:34 +01:00
Hans Goudey
b9b47088bc Cleanup: Remove unnecessary DNA_meshdata_types.h includes
Except for vertex groups and a few older color types, these
are generally replaced by newer generic attribute types.
Also remove some includes of DNA_mesh_types.h, since it's
included indirectly by BKE_mesh.hh currently.
2023-12-20 20:58:38 -05:00
Hans Goudey
8dd8f932e2 Cleanup: Rename Mesh loop_data to corner_data
Related to #110434, efbee2d606, 7c69c8827b
2023-12-19 20:39:05 -05:00
Hans Goudey
efbee2d606 Mesh: Rename totvert, totedge, and totloop fields
Use the standard "elements_num" naming, and use the "corner" name rather
than the old "loop" name: `verts_num`, `edges_num`, and `corners_num`.
This matches the existing `faces_num` field which was already renamed.

Pull Request: https://projects.blender.org/blender/blender/pulls/116350
2023-12-20 02:21:48 +01:00
Hans Goudey
1d0179adbb Cleanup: Move mesh update tags to DNA struct
This is similar to other update tags and update tags for other geometry types.
2023-12-12 18:23:59 -05:00
Jacques Lucke
cf9987d548 Cleanup: remove line accidentally added in previous commit 2023-11-27 15:24:23 +01:00
Jacques Lucke
d46770703a Fix: assert when randomizing mesh with zero faces 2023-11-27 15:20:53 +01:00
Hans Goudey
3d57bc4397 Cleanup: Move several blenkernel headers to C++
Mostly focus on areas where we're already using C++ features,
where combining C and C++ APIs is getting in the way.

Pull Request: https://projects.blender.org/blender/blender/pulls/114972
2023-11-16 11:41:55 +01:00
Jacques Lucke
5f80242bc2 Cleanup: use CustomDataAttributes from Instances interface
It's still used internally currently. `CustomDataAttributes` will be removed
soon because there are better alternatives (`AttributeAccessor`).
2023-10-16 16:39:39 +02:00
Hans Goudey
4cbcaf51cb Cleanup: Use "vert" term consistently in mesh randomization debug code
In this area the contraction is usally used. It's nice to be consistent.
2023-10-06 16:50:52 -04:00
Jacques Lucke
63e1d06233 Geometry Nodes: add utility for debug randomization of instances
Also see cc7da09c1b.
2023-09-30 16:29:08 +02:00
Jacques Lucke
cc7da09c1b Geometry: add utility to check for bad geometry element index dependence
Sometimes .blend files have compatibility issues between Blender versions,
because .blend files depended on the specific order of geometry elements
generated by some nodes/modifiers (#112746, #113018). While we make
guarantees about the order in some places, that is relatively rare, because it
makes future improvements much harder. The functionality in this patch
makes it easier for users to notice when they depend on things that are not
expected to be stable between Blender builds.

This is achieved by adding a new global flag which indicates whether some
algorithms should randomize their output. The functionality can be toggled
on or off by searching for `Set Geometry Randomization`. If there are no
differences (or acceptable minor ones) when the flag is on or off, one can
be reasonably sure that one does not on unspecified behavior (can't be 100%
sure though, because randomization might be missing in some places). If
there are big differences, one should consider fixing the file before it comes
to an actual breakage in the next Blender version.

Currently, the setting is only available when `Developer Extras` is turned on,
because the setting is in no menu.

With this patch, if we get bug reports with compatibility issues caused by
depending on indices, one of the following three cases should always apply:
* We actually accidentally broke something, which requires a fix commit.
* Turning on geometry randomization shows that the .blend file depends on
  things it shouldn't depend on. In this case the user has to fix the file.
* We are missing geometry randomization somewhere, which requires a fix
  commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/113030
2023-09-29 21:44:36 +02:00