Commit Graph

547 Commits

Author SHA1 Message Date
Hans Goudey
21a2390f4c BLI: Add utility to reverse index mask
This utility was already duplicated in two places and planned to be used
more. While we should usually avoid creating arrays the size of the
indexed array (rather than the size of the mask), sometimes it does seem
to be the best option, and we're helped by the fact that most memory
stays unintialized for a small mask (allocating but not writing to memory
pages at all generally isn't too expensive).

Pull Request: https://projects.blender.org/blender/blender/pulls/115491
2023-11-28 17:32:17 +01:00
Ray molenkamp
dbb2844ed9 Cleanup: CMake: Modernize bf_functions dependencies
Pretty straightforward

- Remove any bf_functions paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115427
2023-11-28 01:14:15 +01:00
Lukas Tönne
227a4eae77 Make ImplicitSharingPtr constructor from data pointer explicit
The ImplicitSharingPtr has an implicit constructor for raw pointers.
This has unintended effects when comparing an ImplicitSharingPtr to a
raw pointer: The raw pointer is implicitly converted to the shared
pointer (without change in refcount) and when going out of scope will
decrement user count, eventually freeing the data.

Conversion from raw pointer to shared pointer should not happen
implicitly. The constructor is made explicit now. This requires a little
more boilerplate when constructing a sharing pointer. A special
constructor for the nullptr is added so comparison with nullptr can
still happen without writing out a constructor.

Pull Request: https://projects.blender.org/blender/blender/pulls/115476
2023-11-27 15:53:29 +01: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
b022457bfe Cleanup: Use attribute propagation utility function in fillet curves
Using a shared type-agnostic attribute propagation function gives a 32
KB reduction in binary size with no observable performance difference.
2023-11-26 20:51:47 -05:00
Campbell Barton
27c660707d Cleanup: spelling in comments, variables 2023-11-27 09:54:36 +11:00
Campbell Barton
e084553e88 Cleanup: add missing include 2023-11-27 09:31:37 +11:00
Campbell Barton
343b48663b Cleanup: format 2023-11-27 09:30:52 +11:00
Iliya Katueshenock
361174b588 Refactor: GEO: Mesh selection header file
Share code of geometry processing of mesh selection.
For now, `mesh_copy_selection` is only user of this code,
but in #115142 this will also be used.

Pull Request: https://projects.blender.org/blender/blender/pulls/115376
2023-11-25 13:41:17 +01:00
Brecht Van Lommel
0da822e471 Refactor: improve (still unused) UV unwrap simplify code
Use vector instead of malloc, make cost function a callback, tweak names
and comments for clarity.
2023-11-24 19:13:51 +01:00
Brecht Van Lommel
c1f931a399 Cleanup: default initialize members of ParamHandle 2023-11-24 19:13:51 +01:00
Hans Goudey
62b4555d01 Cleanup: Return Bounds type directly in mesh to volume code 2023-11-19 16:57:13 -05: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
Hans Goudey
9785f2631e Mesh: Add flag to store presence of overlapping topology
For improving performance in the triangulate node (#112264), it's
helpful to know whether the mesh has edges or faces that overlap
each other. If that is known to be false, the node can skip edge de-
duplication.This might apply to the future "Replace Faces" node too.

This information is stored as a flag on the mesh and set in various
places that create "clean" new meshes. It isn't calculated lazily unlike
other other areas, because the point is to improve performance, and
the calculation probably isn't faster than the duplication check it's
meant to replace.

Pull Request: https://projects.blender.org/blender/blender/pulls/113205
2023-11-15 14:02:48 +01:00
Hans Goudey
583bd9662e Cleanup: Remove C header from C++ math header
Remove some redundancy between headers, more fully
separate the C++ headers from the older C headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/114705
2023-11-11 21:09:54 +01:00
Hans Goudey
9a458314f2 Cleanup: Use proper case for "uv_phi" class name 2023-10-19 10:37:04 +02:00
Hans Goudey
aa34e2f2aa Cleanup: Remove unnecessary namespace specification 2023-10-19 10:37:04 +02:00
Hans Goudey
a5eaf6698a Geometry Nodes: Optimize joining of instances
Restore lost performance from removing `reserve` in ff4d5b6f04
in a better way. First build offsets so we know where in the result the
source data should go, then copy the data in parallel.

Joining geometries containing 1 million instances each took 194 ms
before the change and only 15.6 ms afterwards.

Pull Request: https://projects.blender.org/blender/blender/pulls/113886
2023-10-19 10:23:59 +02:00
Jacques Lucke
ff4d5b6f04 Geometry Nodes: don't use CustomDataAttributes in Instances
This was the last use of `CustomDataAttributes`. It's not very useful
nowadays because we have a lower level (`CustomData`) and higher level
(`AttributeAccessor`) API.

As part of this I removed the ability to `reserve` instances which was
useful when adding instances one by one. Generally, such code should
eventually be rewritten to handle more instances at once, instead of
handling them one by one. This will lead to better performance and
is more in line with how other geometry types (like mesh) are handled.

This also adds the ability to move and assign `Instances` just like we can
move and assign `CurvesGeometry`.
2023-10-16 18:41:32 +02: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
Jacques Lucke
d0342b1782 Cleanup: don't use CustomDataAttributes when realizing instances
`CustomDataAttributes` does not serve much of a purpose nowadays,
since we usually use either the lower level `CustomData` or the higher
level `AttributeAccessor` interface.
2023-10-16 16:27:33 +02:00
Dalai Felinto
3f13471d65 GPv3: Resample Curve node
Reviewed as part of !113581.
2023-10-12 12:25:39 +02:00
Hans Goudey
7507251071 Cleanup: Extract attribute function to copy values from group to group
Use the typical combination of an "array utils" function used by an
attribute interpolation function. This helps moves us towards having
a more centralized implementaiton of attribute propagation that can
be changed and optimized more easily.
2023-10-09 15:23:48 +02:00
Jacques Lucke
63b39c5aeb Merge branch 'blender-v4.0-release' 2023-10-09 11:46:45 +02:00
Iliya Katueshenock
26346464e0 Fix #110666: Copy built-in attributes for masked curves type conversion
Curve type conversion can cause changing of some curves size.
Also, changing of curve type can cause deletion of unnecessary
built-in attributes and creating new ones. All of this make sense
only for converted curves. Others, unselected, should simply make
copy all old attributes, both built-in and not. This fix simply replaces
the last copy from incorrect only non-built-in, to a correct one,
for all attributes.

Pull Request: https://projects.blender.org/blender/blender/pulls/110683
2023-10-09 10:44:35 +02:00
Iliya Katueshenock
ceb8d34319 Cleanup: reduce template usage in join geometries code
Pull Request: https://projects.blender.org/blender/blender/pulls/110436
2023-10-08 19:10:14 +02:00
Jacques Lucke
144a5aa512 Cleanup: replace use of std::iota with more specific function
`iota` is name that has no meaning, it's not an acronym or initialism.
It's usually very cryptic when I come across it. Replacing it with a
specialized function makes the code more readible.
2023-10-06 23:01:16 +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
Hans Goudey
36f7d33121 Fix: False positive geometry randomization in split edges node
See cc7da09c1b.

Splitting edges only potentially affects the order of edges and
vertices. Face corner vertex and edge indices are affected, but their
order isn't affected, and faces aren't affected at all. This didn't
cause problems, but correcting it shows users they can rely on
these consistencies after this operation.
2023-10-06 16:46:49 -04:00
Jacques Lucke
57e914fc8a Cleanup: move join geometry functionality to separate file
This allows us to reuse the functionality more easily.
2023-10-06 18:31:44 +02:00
Hans Goudey
b5b0a296b6 Cleanup: Else after return in curves trim 2023-10-06 10:11:16 +02: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
bafc952f97 Cleanup: Geometry Nodes: pass selection by varray instead of field 2023-09-30 16:27:25 +02:00
Jacques Lucke
08aa71bfc9 Merge branch 'blender-v4.0-release' 2023-09-30 12:40:25 +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
Iliya Katueshenock
6c14764f32 Fix #112933: Fix codegen issue on MSVC 17.7
MSVC 17.7 generates bad code in some lambda's, this has been reported
upstream [1], and a workaround has been suggested by MS in the form of
turning the inliner off. In consultation with the geo nodes people this
was deemed a passable solution, there was only a single call to this
method so performance wasn't a concern, so no special care had to be
taken to single out just the problematic MSVC versions.

If this bug pops up in other parts of our code where performance IS a
concern a more delicate approach may be required.

[1] https://developercommunity.visualstudio.com/t/10448291

Pull Request: https://projects.blender.org/blender/blender/pulls/112616
2023-09-29 16:57:02 +02:00
Germano Cavalcante
48204b630c Fix #112909, #112922: Weld modifier crashes in some situations
The weld modifier was experiencing crashes due to the `switch_to`
variable occasionally pointing to a collapsed corner.

The encumbrance of the code implementation utilizing `switch_to` was
proving to be problematic as it was escalating the complexity of
maintenance. 

To resolve the issue, a code rewrite was conducted.

The new implementation uses a `loop_next` in place of `switch_to` for
skipping corners.

This modification streamlined the code and improved its stability.

However, this solution does come with minor drawbacks. There is a small
increase in memory consumption and the corner group detection process
is now slightly more computational intensive.

Also the test files need to be updated.
2023-09-27 13:00:06 -03:00
Campbell Barton
e38ff7c06d Cleanup: use C++ comments for disabled code 2023-09-25 17:06:04 +10:00
Campbell Barton
5fbcb4c27e Cleanup: remove spaces from commented arguments
Also use local enums for `MA_BM_*` in versioning code.
2023-09-22 12:21:18 +10:00
Brecht Van Lommel
89b3249c14 UV: when finding the best packing method, use area as tie breaker
When multiple packing methods results in effectively the same bounds,
prefer the packer that uses the smallest area. When all islands can
easily fit this is usually the box packer instead of alpaca. The zigzag
method of the latter has a tendendcy to take up more area and rotate
islands.

Fix #110724: smart UV project unnecessarily rotates islands

Pull Request: https://projects.blender.org/blender/blender/pulls/112295
2023-09-14 18:57:26 +02:00
Brecht Van Lommel
d4cc0d02cb UV: disable best fit rotation of all islands at end of UV packing
This has a tendency to place islands diagonally in the image which is
not usually wanted, even if it's maximimizing the number of pixels for
the island.

Fix #109906: UV unwrap packs island diagonally instead of straight

Pull Request: https://projects.blender.org/blender/blender/pulls/112295
2023-09-14 18:57:26 +02:00
Campbell Barton
b7f3e0d84e Cleanup: spelling & punctuation in comments
Also remove some unhelpful/redundant comments.
2023-09-14 13:25:24 +10:00
Hans Goudey
dd9f196c2e Mesh: Pre-fill loose verts and bounds cache of line primitive
On a Ryzen 7950x, saves about 30 ms of work every frame where a 10
million vertex line is rebuild from scratch.
2023-09-11 16:52:45 -04:00
Hans Goudey
7344c7875a Geometry: Move mesh primitives from nodes to geometry module
This makes the code reusable in a few more places,
particularly by tests for a new boolean implementation
also defined in the geometry module.

It also makes the way some primitives are reused among
different nodes a bit clearer.

Pull Request: https://projects.blender.org/blender/blender/pulls/112255
2023-09-11 22:49:41 +02:00
Hans Goudey
67aad1f72d Cleanup: Remove unused includes in cuboid primitive 2023-09-11 16:13:39 -04:00
Campbell Barton
d897fd34cb UV: restore internal solver state variable
Removed in [0] however I think it helps track the state,
so restore the state and assertions.

[0]: 8ace65e3c6
2023-09-08 23:09:51 +10:00
Campbell Barton
a4aa5adf44 Fix #110729: Unwrap angle based fails with seams
Regression [0] which merged index assignment into an earlier loop.
This caused the indices to be overwritten by p_chart_abf_solve
causing unwrap to fail.

[0]: 8ace65e3c6
2023-09-08 22:30:14 +10:00
Hans Goudey
2cc3a63216 Cleanup: Remove mesh validation assert in mesh code
These asserts are helpful for development, but are too expensive and
strict to live permanently in debug builds.

Resolves #112035
2023-09-06 15:37:35 -04:00
Hans Goudey
fa34992def Cleanup: Remove unnecessary includes from C++ data structure headers
The hash tables and vector blenlib headers were pulling many more
headers than they actually need, including the C base math header,
our C string API header, and the StringRef header. All of this
potentially slows down compilation and polutes autocomplete
with unrelated information.

Also remove the `ListBase` constructor for `Vector`. It wasn't used
much, and making it easy to use `ListBase` isn't worth it for the
same reasons mentioned above.

It turns out a lot of files depended on indirect includes of
`BLI_string.h` and `BLI_listbase.h`, so those are fixed here.

Pull Request: https://projects.blender.org/blender/blender/pulls/111801
2023-09-01 21:37:11 +02:00