Commit Graph

25390 Commits

Author SHA1 Message Date
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
Campbell Barton
2c2bd7d1e3 Cleanup: pass const arguments to BKE_mesh_fair functions 2023-11-30 10:42:16 +11:00
Hans Goudey
5366ccd625 Fix: Debug and lite build errors after recent cleanup
Our `EnumerableThreadSpecific` wrapper doesn't accept an
example argument, only an initialization function. And some
removed variables were still used in asserts.
2023-11-29 13:23:03 -05:00
Hans Goudey
13c145ac02 Cleanup: Grammar in a few comments 2023-11-29 12:39:33 -05:00
Hans Goudey
8c59532106 Cleanup: Use C++ arrays to store subdiv ccg data
Decrease the amount of manual memory management
and pointer arithmetic.
2023-11-29 12:39:33 -05:00
Philipp Oeser
d3ff658b66 Fix #115572: shape_key_remove operator leaves shared normals
Caused by 383a145a19

Since above commit, normals were in a SharedCache, they need to be tagged dirty
for recalculation.

Instead of tagging the normals caches dirty explicitly, simply use
`BKE_mesh_tag_positions_changed` [which includes all this and also tags
positions dirty - which sounds also needed for updating other things]

Pull Request: https://projects.blender.org/blender/blender/pulls/115580
2023-11-29 18:17:30 +01:00
Hans Goudey
c2571cd259 Cleanup: Use const SubdivCCGFace variables 2023-11-29 11:47:00 -05:00
Hans Goudey
1a36feb7e5 Cleanup: Use references instead of pointers in subdiv_ccg.cc 2023-11-29 11:40:10 -05:00
Hans Goudey
63af8dbfca Multires: Use IndexMask for Subdiv CCG face updates
These updates are used to recalculate normals and average values between
grid boundaries during multires sculpting. In main the affected faces
are passed as an array of pointers. Using an `IndexMask` instead reduces
memory usage by 4x per affected face (8 byte pointer to 2 byte integer),
simplifies iteration and threading, and can also improve performance.
Finding which faces are affected is now multithreaded, with its runtime
changing from 0.63 ms to 0.12 ms in a simple test sculpting on a portion
of a 1 million face grid.

Also switch to VectorSet instead of GHash for finding affected adjacent
elements. That's a friendlier data structure that probably has better
performance as well.
2023-11-29 11:10:08 -05:00
Hans Goudey
dfc6b1deb6 Cleanup: Use C++ threading API in subdiv_ccg.cc
Allows removing various structs for passing around arguments,
and simplifies the use of thread-local storage.
2023-11-29 10:35:21 -05:00
Lukas Tönne
5bc82b5b7c Geometry Nodes: Remove experimental volume nodes
The new grid socket (#115270) will make these nodes obsolete and
provide more elegant ways of implementing the features. Removing
these nodes now to clean up and make future changes simpler.

Pull Request: https://projects.blender.org/blender/blender/pulls/115567
2023-11-29 16:02:06 +01:00
Hans Goudey
aa2cdf283a Cleanup: Use proper type for subdiv CCG faces 2023-11-29 08:47:58 -05:00
Iliya Katueshenock
2ce4c4e8d2 Fix #115548: Missed sort after multithreaded algorithm
To make sure result is deterministic, sorting is used.
This was missed in one of last speedup.

Pull Request: https://projects.blender.org/blender/blender/pulls/115568
2023-11-29 14:16:37 +01:00
Campbell Barton
a144fcfa50 Cleanup: declare values for enums that may be written into blend files 2023-11-29 17:37:04 +11:00
Campbell Barton
a385a98e8e Cleanup: spelling in comments 2023-11-29 15:56:17 +11:00
Campbell Barton
b12edbcb9c Cleanup: format 2023-11-29 15:47:19 +11:00
Hans Goudey
09caf59690 Fix #115298: Sculpt mask removed with undo involving mode change
Because reading memfile undo steps doesn't send the mesh through the
versioning code that converts legacy layers back to the new generic
format, we can't write the old format in undo steps. This same check
existed during the mesh struct of array refactor.
2023-11-28 16:58:45 -05:00
Hans Goudey
c083b3b8d2 Cleanup: Remove outdated normals comment for mesh validation
The validation function doesn't handle normals anymore,
since they are calculated lazily at runtime.
2023-11-28 16:50:52 -05:00
Hans Goudey
19b9b8d431 Cleanup: Move mesh looptri real edges function 2023-11-28 16:49:55 -05:00
Hans Goudey
aca27e5462 Cleanup: Store BVH and shrinkwrap data with C++ types 2023-11-28 16:40:43 -05:00
Hans Goudey
9271949f7b Cleanup: Remove unnecessary keywords from newly C++ headers 2023-11-28 16:13:09 -05:00
Hans Goudey
7e3ba529ea Cleanup: Move four blenkernel headers to C++ 2023-11-28 16:05:12 -05:00
Hans Goudey
321c1af26e Cleanup: Remove unnecessary mesh C-API functions 2023-11-28 12:26:51 -05:00
Hans Goudey
f2467f75b3 Cleanup: Remove mesh "vert coords" functions
Inlining the functions is simpler nowadays, since there are utility
functions to copy spans and tag the mesh caches dirty. Also use an
array instead of a raw pointer for multires.
Resolves #103789
2023-11-28 12:26:51 -05:00
Nathan Vegdahl
c9093332e0 Fix #115434: custom bone colors invisible in stick mode
The issue was that bone colors are only specified with 3 channels (RGB),
but they're stored as 4 channels for some reason.  So the fourth bogus
channel gets initialized to zero by default, which was then being
interpreted as zero alpha in some drawing modes.

This fixes the issue by ensuring that the fourth unused channel always
gets initialized to 255, and therefore can be validly interpreted as an
alpha channel.

Pull Request: https://projects.blender.org/blender/blender/pulls/115477
2023-11-28 18:04:11 +01:00
Philipp Oeser
451a765ab3 Fix #115471: Crash opening files with particle boid goal objects
Exposed/caused by b53c7a804a

`particle_settings_foreach_id` only processed object IDs for `avoid`
(but not `goal`) -- `BoidRuleGoalAvoid` is used for both though.

Pull Request: https://projects.blender.org/blender/blender/pulls/115482
2023-11-28 09:11:11 +01:00
Campbell Barton
9dda667fd4 Cleanup: spelling in comments 2023-11-28 15:19:20 +11:00
Campbell Barton
1e84a028b3 Fix shadowing error causing a value to be assigned to it's self 2023-11-28 12:35:36 +11:00