Commit Graph

25417 Commits

Author SHA1 Message Date
Brecht Van Lommel
56cc47ee2e Cleanup: compiler warning 2023-12-04 20:37:11 +01:00
Hans Goudey
cc3c5e2329 Fix: Debug build error after recent PBVH bounds change 2023-12-04 14:10:38 -05:00
Hans Goudey
8a705ffd11 PBVH: Use C++ Bounds type for node bounds
This is just a bit more ergonomic and works a bit better with our C++
math vector types. Also, during PBVH build, don't store the center of
each triangle/grid. That's redundant and can always be recalculated
from the bounds.
2023-12-04 12:45:23 -05:00
Sybren A. Stüvel
562e9b9f4c Refactor: remove unused argument to BKE_constraint_remove_ex()
Remove the `bool clear_dep` argument of `BKE_constraint_remove_ex()`, as
it was always `true` on every call anyway.

No functional changes.
2023-12-04 17:13:47 +01:00
Hans Goudey
e9f4f8b52a PBVH: Specialize node bounds update, expose functions
Similar to previous commits (7332a1eb90), use three separate
functions for updating the bounds of different PBVH types. This avoids
the use of the vertex iteration macro. Also make the functions reusable,
so they can be called directly after a brush update in the future.
2023-12-04 08:36:02 -05:00
Hans Goudey
869ea79da0 Cleanup: Return PBVH vertex data arrays as spans 2023-12-04 07:55:47 -05:00
Hans Goudey
3b1d5d14f2 Cleanup: Remove unused DMFlagMat struct
Arrays were allocated and filled with data, but never read.
2023-12-04 07:55:47 -05:00
Hans Goudey
8171f719fe Subdiv: Remove unnecessary CCG derived flag structs
The copied the material index and its smoothness to every grid,
resulting in 4 bytes of memory per base mesh face corner. That's
wasteful, since it's trivial to loop up the original data from the base
mesh attributes as necessary. This way we can also avoid the
dereference.
2023-12-04 07:55:47 -05:00
Hans Goudey
5cd6a05f5e Cleanup: Store SubdivCCG in unique_ptr
Automatic memory management and clearer ownership! Requires
removing `MEM_CXX_CLASS_ALLOC_FUNCS` from `MeshRuntime`,
but that's used very inconsistently anyway, and `MeshRuntime` isn't
that large.
2023-12-04 07:55:47 -05:00
Hans Goudey
d73868d5a1 Subdiv: Inline grid to face map lookup function
I've seen this appear in profiles sometimes, which it really shouldn't,
since it's just a single array access. I didn't detect an observable
difference, but we don't have to think about that anymore anyway.
2023-12-04 07:55:47 -05:00
Hans Goudey
0b9ae3df4c Subdiv: Use base mesh faces and topology map for SubdivCCG
Instead of storing a redundant array of faces, use the base mesh faces
and corner_to_face map. This saves 8 bytes per base mesh face with
multires sculpting, and avoids recalculating the topology map whenever
reevaluating the object. There is a lot of other duplicate data between
base meshes and faces, particularly in `MeshTopology`. This is just
a first step of untangling that.
2023-12-04 07:55:47 -05:00
Hans Goudey
881ec8b1ed Cleanup: Return multires grid key by value 2023-12-04 07:55:47 -05:00
Hans Goudey
a9f847f94c Fix: Various issues with multires visibility undo
Push the undo step before changing any grid hide data, fix a missing
allocation in the undo step, and workaround some issue with temporary
BitVector<> construction that I couldn't quite figure out. Also fix a
crash when there is vertex mask attribute but no multires hiding.
2023-12-04 07:55:47 -05:00
Hans Goudey
7332a1eb90 PBVH: Refactor hide and mask update to be data oriented and reusable
Specialize the mask update for each PBVH type, simplifying hot loops,
reducing reliance on complex shared state and clarifying which data is
used. Expose functions to update the visibility and masks tags for a
specific node. It can be helpful to call these after modifying the data
to update the flags while the data is more likely to be in CPU caches.
2023-12-04 07:55:46 -05:00
Hans Goudey
f3bfbd9d84 Cleanup: Use const arguments to PBVH functions 2023-12-04 07:55:46 -05:00
Hans Goudey
b74862127d Cleanup: Remove unused arguments to sculpt update function 2023-12-04 07:55:46 -05:00
Campbell Barton
92e8b7e850 Cleanup: match logic & naming between bmesh & mesh crazyspace functions 2023-12-04 12:28:44 +11:00
Habib Gahbiche
153f14be2b Compositor: Make split viewer a regular split node
Changes:
- Renamed Split Viewer Node to Split Node
- Split Node is now under `Utilities` (similar to Switch node)
- Versioning: split viewer from 4.0 and before is replaced with the new split node connected to a new viewer node.

Pull Request: https://projects.blender.org/blender/blender/pulls/114245
2023-12-03 23:20:44 +01:00
Harley Acheson
da7128c533 Cleanup: Make format
Formatting changes resulting from Make Format
2023-12-02 11:07:25 -08:00
Hans Goudey
ccab01f97f Subdiv: Store multires sculpt grid visibility in BitGroupVector
Instead of allocating a separate bitmap per grid for the hide status, store
all the bits in a recently added C++ data structure that stores all bits in one
contiguous memory chunk. When nothing is hidden, nothing is allocated
(that saves 32 MB for a 16 million vertex multires sculpt). Intuitively it
could have better performance because of the cache benefits of
contiguous memory, but this is hard to measure. It also has a nicer
API than `BLI_bitmap`.

I discussed this with Sergey in person recently. Most of the changes are
just straightforward refactors. The part that isn't is a change to the "show/hide"
operator to structure it similarly to the mesh handling in 4e66769ec0.

Pull Request: https://projects.blender.org/blender/blender/pulls/115687
2023-12-02 20:05:29 +01:00
Bastien Montagne
5736f88e31 BKE main: Add 'merge' utils to merge one Main content into another.
This merge does not rename any ID. In case a conflict happens (an ID of
the same name and library already exists in destination Main), its
counterpart in source Main is not moved, and its usages by other
moved-from-source IDs are remapped accordingly.

Libraries are also properly de-duplicated, and remapped as necessary.

Source Main is always freed by this function, since it is either empty,
or contains left-over IDs very likely to have invalid relationships
after the merge.

NOTE: This commit also enables `main_test.cc` unittests, which was
comitted by mistake in fe3cb11ae4, sorry about that.

Pull Request: https://projects.blender.org/blender/blender/pulls/115671
2023-12-02 16:25:02 +01:00
Bastien Montagne
2064af64e5 BKE lib remap: Add option to allow remapping of ID.lib pointers.
Usually Library pointers should not be affected by remapping, but this
can be needed in some cases.

WARNING: Use with caution, this is potentially a dangerous operation for
Main data integrity/validity.
2023-12-02 16:10:41 +01:00
Hans Goudey
a7afc5b1e8 Cleanup: Pass PBVH node grid indices as Span 2023-12-01 14:40:14 -05:00
Bastien Montagne
3acb64e7ac BKE_main: move header to be a fully CPP one.
Pull Request: https://projects.blender.org/blender/blender/pulls/115681
2023-12-01 20:38:54 +01:00
Harley Acheson
1d7ddcc46e Cleanup: Make format
Formatting changes resulting from Make Format
2023-12-01 10:29:59 -08:00
Hans Goudey
f2ed2b82ce Cleanup: Use const arguments for some paint functions 2023-12-01 12:41:09 -05:00
Jacques Lucke
5de86fc4f8 Cleanup: make name more specific for simulations
This is necessary for the bake node (#115466).
2023-12-01 17:13:31 +01:00
Hans Goudey
a86122606c Fix: Crash building sculpt PBVH
Caused by 49f676e6c2. The SubdivCCG pointer was
dereferenced while doing normal face sculpting. Solve by splitting
the function for each PBVH type.
2023-12-01 10:03:05 -05:00
Hans Goudey
f69beb4829 Fix: Sculpt drawing ignores hide status
Caused by retrieving the hide status from the wrong mesh.
2023-12-01 10:03:05 -05:00
Jacques Lucke
cefdb67db7 Cleanup: return managed pointer when copying geometry component 2023-12-01 11:23:00 +01:00
Jacques Lucke
7730ca2b9d BLI: improve const handling in ImplicitSharingPtr
The constness of the `ImplicitSharingPtr` does not imply the constness of the
referenced data, because that is determined by the user count. Therefore,
`ImplicitSharingPtr` should never give a non-const pointer to the underlying data.
Instead, one always has to check the user count, before one can do a `const_cast`.

Pull Request: https://projects.blender.org/blender/blender/pulls/115652
2023-12-01 11:19:39 +01:00
Hans Goudey
91c936e01c Fix #115108: Object dimensions infinite for armatures
The initialization of min and max was reversed. Switch to C++
numeric limits, which I'm a bit more used to ad this point.
2023-11-30 23:40:34 -05:00
Hans Goudey
8c8ea2ec47 Refactor: Sculpt: Clarify PBVH attribute requests
Avoid reusing the custom data type enum with additional values. Instead
use std::variant and type names to properly distinguish between custom
and generic attribute requests. Use a Vector to hold the requests.

Also attempt to simplify the string key building process for requests
and groups of requests in batches. Previously for every PBVH node it
would rebuild the key 3 times, now it only does it once. It's hard to
measure, but that process did show up in profiles, so performance is
probably slightly improved when many nodes are handled at once.
2023-11-30 23:24:11 -05:00
Hans Goudey
2864f3ad3f Cleanup: Remove unused argument to PBVH draw functions
The attributes weren't used by BKE_pbvh_draw_cb.
2023-11-30 23:24:11 -05:00
Hans Goudey
e83b1b8ae0 Cleanup: Use object arguments in many drawing related functions 2023-11-30 23:24:11 -05:00
Hans Goudey
ed7b914bd8 Cleanup: Move draw_pbvh to a C++ namespace 2023-11-30 23:24:11 -05:00
Hans Goudey
666a99da8d Cleanup: use references, const arguments for PBVH draw args function 2023-11-30 23:24:11 -05:00
Hans Goudey
4a1c6b28ae Cleanup: Move PBVH draw args function to where it's used
Somehow this function was in the middle of the section of the
file where the code building the PBVH lives.
2023-11-30 23:24:11 -05:00
Hans Goudey
49f676e6c2 Cleanup: Reduce usage of mesh data pointers in PBVH
Pointers to hide status layers and custom data are removed,
since they can be accessed from the mesh as necessary.
Usage of other arrays has been reduced, so the pointers
can eventually be removed.

The reasoning is the same as some other commits in this area:
the goal is less duplication of state, and a more focused design
of the responsibilities of the PBVH class.

Some of the changes are fairly noisy, since we need to add
arguments to functions in a few places. On the nicer side of
things, some functions for syncing the state can be removed.

Not retrieving hide layers with write access also has performance
implications in some cases, since it means the original arrays can
be reused without a copy when they're shared.
2023-11-30 23:24:11 -05:00
Hans Goudey
a5e17dc607 Cleanup: PBVH: Process multiple nodes at once in visibility update
This improves the early out in the mesh case so that it isn't
repeated for every node. Also simplifies using more local
variables that are specific to a certain PBVH type (in this
case, switching to the C++ attribute API and retrieving the
vertex visibility status that way).
2023-11-30 23:24:11 -05:00
Campbell Barton
731a443354 Cleanup: pass const vectors BKE_lnor_space_define
Pass const references to lnor_space_define(..), one argument wasn't
const because of a local assignment, declare a new variable instead.
2023-12-01 11:05:29 +11:00
Hans Goudey
ac6e854335 Cleanup: Small tweaks to C++ style in lib remap code
- Pass Span by value. It is a small struct, and passed by reference
  it acts as a pointer to a pointer.
- Remove unnecessary `= {}`. Vector has a default constructor.
- Use initializer list Span constructor to avoid temporary array.

Pull Request: https://projects.blender.org/blender/blender/pulls/115635
2023-11-30 23:03:39 +01:00
Hans Goudey
8b28bb9882 Cleanup: Remove redundant subdiv pointers from PBVH
These are just duplicates of the pointers in `SubdivCCG`, which are
already quickly accessible. Keeping track of the state is too complex
and bloats the responsibilities of the PBVH too much.
2023-11-30 16:40:09 -05:00
Bastien Montagne
dfe1a7d039 BKE_lib_remap: Refactor: Replace LinkNode by blender::Span. 2023-11-30 22:21:45 +01:00
Bastien Montagne
fe3cb11ae4 BKE_lib: Convert BKE_lib_remap and lib_intern headers to be fully C++. 2023-11-30 19:51:22 +01:00
Campbell Barton
6b22572967 Cleanup: various non-functional changes for C++ 2023-11-30 16:42:39 +11:00
Aras Pranckevicius
3f7ab7069e Cleanup: move writeffmpeg to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/115585
2023-11-30 06:03:18 +01:00
Campbell Barton
15db0cb446 Cleanup: use style for doxygen comment blocks 2023-11-30 14:15:11 +11:00
Hans Goudey
34ec46934c Fix: Incorrect subdiv IndexMask construction
The indices have to be sorted. A different method of interpolating
the face selection to vertices would probably be better in the future.
2023-11-29 18:52:58 -05:00
Campbell Barton
3b5031f1cb Cleanup: use 'r_' prefix for output arguments, order last
Also clarify some naming.
2023-11-30 10:42:18 +11:00