Commit Graph

25376 Commits

Author SHA1 Message Date
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
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
Damien Picard
5e38f7faf0 I18n: translate new text object body
After VFont has been updated to use the BLF API in 604ee2d036, it can
use the fallback font stack and display text in many scripts.

This change means the default text for font objects can now be
translated, instead of always being the English word 'Text'.
Translation will only occur if the user has enabled translation of new
data in the preferences.
2023-11-27 20:44:48 +01:00
Hans Goudey
721de99571 Cleanup: Add missing return 2023-11-27 13:36:20 -05:00
Hans Goudey
367423a31c Cleanup: Make format 2023-11-27 13:36:20 -05:00
Bastien Montagne
dad1eea511 Move BKE_main_idmap and BKE_main_namemap to be fully cpp headers.
NOTE: `BKE_main.h` is currently used by `writeffmpeg.c`, so not trivial
to make it a full CPP header file for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/115485
2023-11-27 18:09:27 +01:00
Hans Goudey
14e3523ac2 Refactor: Further improvements to geometry bounds
Implement the next phases of bounds improvement design #96968.
Mainly the following changes:

Don't use `Object.runtime.bb` for performance caching volume bounds.
This is redundant with the cache in most geometry data-block types.
Instead, this becomes `Object.runtime.bounds_eval`, and is only used
where it's actually needed: syncing the bounds from the evaluated
geometry in the active depsgraph to the original object.

Remove all redundant functions to access geometry bounds with an
Object argument. These make the whole design confusing, since they
access geometry bounds at an object level.

Use `std::optional<Bounds<float3>>` to pass and store bounds instead
of an allocated `BoundBox` struct. This uses less space, avoids
small heap allocations, and generally simplifies code, since we
usually only want the min and max anyway.

After this, to avoid performance regressions, we should also cache
bounds in volumes, and maybe the legacy curve and GP data types
(though it might not be worth the effort for those legacy types).

Pull Request: https://projects.blender.org/blender/blender/pulls/114933
2023-11-27 16:14:49 +01:00
Wannes Malfait
b162281caf Mesh: add index-independent test for mesh equality
This adds a new function, `compare_meshes`,
as a replacement for `BKE_mesh_cmp`.

The main benefits of the new version are the following:
- The code is written in c++, and makes use of the new attributes API.
- It adds an additional check, to see if the meshes only differ by
  their indices. This is useful to verify correctness of new algorithmic
  changes in mesh code, which might produce mesh elements in a different
  order than the original algorithm. The tests will still fail, but the
  error will show that the indices changed.

Some downsides:
- The code is more complex, due to having to be index-independent.
- The code is probably slower due to having to do comparisons "index-
  independently". I have not tested this, as correctness was my priority
  for this patch. A future update could look to improve the speed,
  if that is desired.
- This is technically a breaking API change, since it changes the
  returned values of `rna_Mesh_unit_test_compare`. I don't think that
  there are many people (if any) using this, besides our own unit tests.

All tests that pass with `BKE_mesh_cmp` still pass with the new version.

**NOTE:**
Currently, mesh edge indices are allowed to be different in the
comparison, because `BKE_mesh_cmp` also allowed this. There are some
tests which would fail otherwise. These tests should be updated, and
then the corresponding code as well.

I wrote up a more detailed explanation of the algorithm here:
https://hackmd.io/@bo-JY945TOmvepQ1tAWy6w/SyuaFtay6

Pull Request: https://projects.blender.org/blender/blender/pulls/112794
2023-11-27 16:10:43 +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
Hans Goudey
eb399678f5 Fix #115366: Missing task isolation subdividing loose edges
Nowadays we have the loose edge cache which can tell us if there will be
any loose edges to subdivide. This means the topology map creation that
included multi-threading doesn't need to be behind a lock anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/115480
2023-11-27 15:19:44 +01:00
Falk David
3a743018b1 Fix: GPv3: Wrong location in paint_init_pivot
The `paint_init_pivot` calculates the `location` based
on the midpoint of the bounds of the object. For grease pencil
the bounds depend on the current frame (for original data).

This fixes the issue by making the `bounds_min_max` function
dependent on the `frame` and by introducing a `bounds_min_max_eval`
for evaluated data.
2023-11-27 15:06:38 +01:00
Falk David
8dc9a9a0e3 Fix: GPv3: Uninitialized runtime variable
The `eval_frame` was not initialized to a default value,
causing a crash in some situations on windows.
This at least avoids a crash even if the outcome of
whatever uses the `eval_frame` might not be correct.
2023-11-27 15:06:38 +01:00
Miguel Pozo
78de9138e5 Core: Add ObjectRuntime::last_update transform, geometry and shading
Track the last time an object or its dependencies were evaluated by the
dependency graph.
These values can be compared against DEG_get_update_count().
Implemented following the design from #114112

Pull Request: https://projects.blender.org/blender/blender/pulls/115196
2023-11-27 12:03:17 +01:00
Hans Goudey
d1a3108fa2 Fix #115291: Object dimension setting ignores modifiers
The factor needs to be calculated against the evaluated bounds rather
than the bounds of the original geometry. Error in 1cbd0f5a85.
2023-11-26 23:09:29 -05:00
Campbell Barton
1eff48a838 Cleanup: spelling in code 2023-11-27 10:55:39 +11:00