Commit Graph

25005 Commits

Author SHA1 Message Date
Julian Eisel 401340fade MSVC: Attempt to fix build error because C++ type in C-linkage block 2023-08-30 18:59:38 +02:00
Julian Eisel eefee47a8a UI: Refactor deferred preview image storage
Previously we'd just allocate extra space for additional data for the
deferred loading, and then do pointer arithmetic to access that data.
This is cryptic and not type safe.

Instead, use an internal type deriving from `PreviewImage`, and manage
that internally. This ensures type safety, while keeping this as
implementation detail (not visible outside of the preview image API) and
keeping internals easy to understand.

Some code did shallow copies of preview images, making ownership
unclear. That made things a bit tricky, but I've made support for
shallow copies explicit now and noted this in comments.
2023-08-30 17:50:48 +02:00
Hans Goudey e56b1fc164 Cleanup: Make SubdivCCG a non-trivial struct
Allocate with `MEM_new`, free with `MEM_delete`, and provide
explicit defaults to guarantee values after initialization.
2023-08-30 11:36:36 -04:00
Hans Goudey fdd6065c21 Cleanup: Add missing struct forward declaration 2023-08-30 11:26:20 -04:00
Jacques Lucke 152f5dc897 Fix #111633: crash with cyclic node tree zones
The problem was that there was a cyclic nesting dependency that was not detected
correctly, which led to problems further down the line. See the PR for details.

Right now, the zones just disappear when there is an error. This has to be improved
at some point, but it outside of the scope of this patch.

A regression test that covers this case is added as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/111689
2023-08-30 14:50:53 +02:00
Lukas Tönne e071288ab2 Nodes: Panels integration with blend files and UI
Part 3/3 of #109135, #110272

Switch to new node group interfaces and deprecate old DNA and API.
This completes support for panels in node drawing and in node group
interface declarations in particular.

The new node group interface DNA and RNA code has been added in parts
1 and 2 (#110885, #110952) but has not be enabled yet. This commit
completes the integration by
* enabling the new RNA API
* using the new API in UI
* read/write new interfaces from blend files
* add versioning for backward compatibility
* add forward-compatible writing code to reconstruct old interfaces

All places accessing node group interface declarations should now be
using the new API. A runtime cache has been added that allows simple
linear access to socket inputs and outputs even when a panel hierarchy
is used.

Old DNA has been deprecated and should only be accessed for versioning
(inputs/outputs renamed to inputs_legacy/outputs_legacy to catch
errors). Versioning code ensures both backward and forward
compatibility of existing files.

The API for old interfaces is removed. The new API is very similar but
is defined on the `ntree.interface` instead of the `ntree` directly.
Breaking change notifications and detailed instructions for migrating
will be added.

A python test has been added for the node group API functions. This
includes new functionality such as creating panels and moving items
between different levels.

This patch does not yet contain panel representations in the modifier
UI. This has been tested in a separate branch and will be added with a
later PR (#108565).

Pull Request: https://projects.blender.org/blender/blender/pulls/111348
2023-08-30 12:37:21 +02:00
Campbell Barton 3d607be572 Cleanup: spelling in comments 2023-08-30 10:57:12 +10:00
Hans Goudey 7563b96945 Geometry Nodes: Avoid attribute copy in simple case of points to curves
When the final curve point indices are in the same order as the input
points, and there are many curves, avoid copying point domain
attributes, by generalizing the existing check from the mesh
to curve conversion node.

Pull Request: https://projects.blender.org/blender/blender/pulls/111662
2023-08-29 20:12:47 +02:00
Philipp Oeser a3c045d49d Fix: Customdata merging does not check layer limit on destination
`LayerTypeInfo` can define a `layers_max()` function which determines the
maximum allowed number of layers.

Upon merging, this limit was respected from the source, but not on the
destination, so it was possible to exceed the max (if there were layers
on the destination already).

NOTE: `layers_max()` is currently only defined for legacy CD_MTFACE, but
we might want to enforce this for UVs / CD_PROP_FLOAT2 again.

This came up in #111608.

Pull Request: https://projects.blender.org/blender/blender/pulls/111609
2023-08-29 18:02:36 +02:00
Hans Goudey 69c498084a Cleanup: Remove unnecessary Mesh C API functions 2023-08-29 11:47:29 -04:00
Hans Goudey b339e3937d Fix: Crash in sculpt mode with shared normals caches
Since the normals are stored in a shared cache, tagging them dirty
recreated the cache from scratch when it was shared. Instead,
add a function that updates the cache in the same call as tagging
it dirty. This keeps the old state of the cache around even if it was
shared, and reflects the way that it's really the PBVH and sculpt
mode managing the dirty status of normals while sculpt mode
is active.

One consequence is that the BVH cache and the triangulation
cache need to be tagged dirty manually. I'd like to avoid abstracting
this more than necessary, because I'm hoping in the long term
different caching abstractions like a more global cache that takes
implicit sharing versions into account will make this complexity
unnecessary.

Fixes #111628, #111563

Pull Request: https://projects.blender.org/blender/blender/pulls/111641
2023-08-29 17:07:42 +02:00
Hans Goudey 425b871607 Mesh: Replace EdgeHash and EdgeSet with C++ classes
The `EdgeHash` and `EdgeSet` data structures are designed specifically
as a hash of an order agnostic pair of integers. This specialization can
be achieved much more easily with the templated C++ data structures,
which gives improved performance, readability, and type safety.

This PR removes the older data structures and replaces their use with
`Map`, `Set`, or `VectorSet` depending on the situation. The changes
are mostly straightforward, but there are a few places where the old
API made the goals of the code confusing.

The last time these removed data structures were significantly changed,
they were already moving closer to the implementation of the newer
C++ data structures (aa63a87d37).

Pull Request: https://projects.blender.org/blender/blender/pulls/111391
2023-08-29 17:00:33 +02:00
Iliya Katueshenock 48b08199d5 Geometry Nodes: Points to Curves node
New node to converts groups of points to curves. Groups
of points defined as `Curve Group ID` attribute. `Weight` in curve
is used for sort points in each group. Points of result curves
propagate attributes from original points. Implicit conversion
of other geometry types is not supported currently.

Pull Request: https://projects.blender.org/blender/blender/pulls/109610
2023-08-29 16:52:20 +02:00
Damien Picard ea974b6681 UI: fix and improve a few messages
- Multiple issues in the Data Transfer modifier error messages:
  - "None" -> "none", this word in the middle of a sentence, no need
    for upper case.
  - "amount of <element>" -> "number", more appropriate for discrete
    counts.
  - "doesn't" -> "does not", to respect Blender's style guide.
- "The grease pencil object need an Armature modifier" -> "needs",
  grammar.
- "Armature modifier is not valid or wrong defined" -> "is invalid".
  Unclear what "wrong defined" means.
- The "Recent Reports" text block has not been used since 2.81.
- "Not valid subdivisions found to rebuild lower levels" -> "No
  valid...", typo.
- "extensions repository" -> "extension repository": typo.
- "... , but loose correct blending..." -> "lose": typo.
- "True when multiple enums ": trailing whitespace.
- "Number of ray per pixel" -> "rays": typo.
- "Curve Parameter node" -> "Spline ...": this is the actual name of
  the node after its rename in 1cd9fcd98d.

Pull Request: https://projects.blender.org/blender/blender/pulls/111145
2023-08-29 14:49:02 +02:00
Nathan Vegdahl a1f081c212 Fix: uninitialized memory in bone collection unit tests
This caused the tests to fail in debug with address sanitizer.
2023-08-29 14:31:18 +02:00
Nathan Vegdahl 172a6d65a6 Fix: update BKE bone layer visibility checks to use bone collections 2023-08-29 14:31:18 +02:00
Nathan Vegdahl 9eee076a29 Anim: add custom property support for Bone Collections
Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-29 14:31:18 +02:00
Sybren A. Stüvel 998136f7a7 Anim: replace Bone Groups & Armature Layers with Bone Collections
Armature layers (the 32 little dots) and bone groups are replaced with
Bone Collections:

- Bone collections are stored on the armature, and have a name that is
  unique within that armature.
- An armature can have an arbitrary number of bone collections (instead
  of the fixed 32 layers).
- Bones can be assigned to zero or more bone collections.
- Bone collections have a visibility setting, just like objects in scene
  collections.
- When a bone is in at least one collection, and all its collections in
  are hidden, the bone is hidden. In other cases (in any visible
  collection, or in no collection at all), the bone visibility is
  determined by its own 'hidden' flag.
- For now, bone collections cannot be nested; they are a flat list just
  like bone groups were. Nestability of bone collections is intended to
  be implemented in a later 4.x release.
- Since bone collections are defined on the armature, they can be used
  from both pose mode and edit mode.

Versioning converts bone groups and armature layers to new bone
collections. Layers that do not contain any bones are skipped. The old
data structures remain in DNA and are unaltered, for limited forward
compatibility. That way at least a save with Blender 4.0 will not
immediately erase the bone group and armature layers and their bone
assignments.

Shortcuts:

- M/Shift+M in pose/edit mode: move to collection (M) and add to
  collection (shift+M). This works similar to the M/Shift+M menus for
  objects & scene collections.
- Ctrl+G in pose mode shows a port of the old 'bone groups' menu. This
  is likely to be removed in the near future, as the functionality
  overlaps with the M/Shift+M menus.

This is the first commit of a series; the bone collections feature will
be improved before the Blender 4.0 release. See #108941 for more info.

Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-29 14:31:18 +02:00
Sybren A. Stüvel 042c5347f4 Anim: move bone colors from bone groups to individual bones
Move control over the color of bones from bone groups to the bones
themselves. Instead of using bone groups (which are defined on the pose,
and thus owned by the object), the color is stored on:

- the bone (`struct Bone`, or RNA `armature.bones['bone_name'].color`)
- a possible override on the pose bone (`struct bPoseChannel`, or RNA
  `ob.pose.bones['bone_name'].color`).

When the pose bone is set to its default color, the color is determined
by the armature bone. In armature edit mode, the armature bone colors
are always used, as then the pose data is unavailable.

Versioning code converts bone group colors to bone colors. If the
Armature has a single user, the group color is stored on the bones
directly. If it has multiple users, the group colors will be stored on
the pose bones instead.

The bone group color is not removed from DNA for forward compatibility,
that is, to avoid immediate dataloss when saving a 3.6 file with 4.0.

This is part of the replacement of bone groups & armature layers with
bone collections. See the design task at #108941.

Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-29 14:31:18 +02:00
Hans Goudey c9621a002d Cleanup: Sculpt: Remove duplicate visibility update function
`node_update_visibility_redraw` and `BKE_pbvh_update_visibility`
do the same thing, and the latter is better specialized for the three
PBVH types, so remove the first.

The two update methods were added in:
- f4411b58ad
- 38d6533f21

Pull Request: https://projects.blender.org/blender/blender/pulls/110709
2023-08-29 14:23:04 +02:00
Julian Eisel 7fb58a33f0 Fix #111332: 4.0 files cannot be opened in 3.6, invalid region types
4.0 files now include asset shelf regions in 3D views. This region type is not
known to older Blender versions. So far, in such cases we would just change
the region type to be the first known region type and keep the region storage
otherwise. This was arbitrary, and in fact unsafe: the reused settings may
violate invariants/assumptions for a region type and worse, the
`ARegion.regiondata` can only be interpreted and correctly written to files
if the region type is known.

Make sure all invalid regions (regions where the type cannot be restored) are
removed on file read.

Committed to 3.6 release branch as e2d4403497.

Pull Request: https://projects.blender.org/blender/blender/pulls/111483
2023-08-29 14:10:43 +02:00
Julian Eisel 567e3b9b19 Assets: Always use guarded allocator for weak references
Although I don't like the idea of using owning raw pointers in new APIs
like this (violates fundamental C++ good practises), this type is mostly
meant for writing to files via DNA. So we have to use Blender's memory
management via the guarded allocator here.

Considered making this an alternative function, but then we'd have to
duplicate logif or duplicate memory or so. Not worth it to me.
2023-08-29 13:49:58 +02:00
Rawalanche 411cd827b7 Nodes: Move Auto-Offset toggle to User Preferences
Move Auto-Offset toggle from Node Editor View menu
into the Editing > Node Editor section of User Preferences,
to reflect its use as a workflow option not configured
per editor or per file.

Pull Request: https://projects.blender.org/blender/blender/pulls/111589
2023-08-29 01:18:33 +02:00
Iliya Katueshenock 226359ec48 Mesh: Parallelize vertex and edge to corner topology map creation
Change the algorithm to make better use of multiple CPU cores. First
offsets are created by counting the number of elements using each
vertex. Those offsets are used during the next phase that adds indices
to each group in parallel. Atomic increments are used to add elements
to each group. Since the order in each group is non-deterministic,
they are sorted in parallel afterwards.

The performance improvement depends on the number of cores, CPU caches,
memory bandwidth, single threaded performance, and mesh topology. In
our tests, performance improved by 3-4.5x for large grid-like meshes.

See [1] for investigation of this algorithm and potential alternatives.

1. https://hackmd.io/@s0TMIS4lTAGwHVO20ECwpw/build_edge_to_loop_map_tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/110707
2023-08-28 22:32:31 +02:00
Bastien Montagne 5ba692898e I18N/UI messages fixes. 2023-08-28 18:02:31 +02:00
Hans Goudey 3db523ab3e Cleanup: Move BLO headers to C++
Except for BLO_readfile.h, which is still included by C files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111610
2023-08-28 15:01:05 +02:00
Hans Goudey 383a145a19 Mesh: Share normals caches by splitting vertex and face calculation
Since vertex and face normals can be calculated separately, it simplifies
things to further separate the two caches. This makes it easier to use
`SharedCache` to avoid recalculating normals when copying meshes.

Sharing vertex normal caches with meshes with the same positions and
topology allows completely skipping recomputation as meshes are
copied. The effects are similar to e8f4010611, but normals are much
more expensive, so the benefit is larger.

In a simple test changing a large grid's generic attribute with geometry
nodes, I observed a performance improvement from 12 to 17 FPS.
Most real world situations will have smaller changes though.

Completely splitting face and vertex calculation is slightly slower
when face normals aren't already calculated, so I kept the option
to recalculate them together as well.

This simplifies investigating the changes in #105920 which resolve
non-determinism in the vertex normal calculation. If we can make the
topology map creation fast enough, that might allow simplifying this
code more in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/110479
2023-08-25 23:06:06 +02:00
Bastien Montagne a186f5e48a Cleanup: unused variable in release builds. 2023-08-25 12:24:21 +02:00
Campbell Barton b150b47720 UI: add a preference for the number of samples used for FPS playback
This was hard coded to 8, which can still result in a number that
jitters making the overall FPS difficult to measure.

The default is still 8, but this is now a preference that can be
increased for values that don't jitter as much.
2023-08-25 19:33:48 +10:00
Pratik Borhade faff3d1d15 Cleanup: Comment style
Pull Request: https://projects.blender.org/blender/blender/pulls/111509
2023-08-25 11:14:19 +02:00
Campbell Barton 7074c210cc Cleanup: format 2023-08-25 09:40:42 +10:00
Campbell Barton 3de8900ed6 Cleanup: spelling in comments 2023-08-25 09:40:42 +10:00
Hans Goudey f5b7813f3c Cleanup: Remove unnecessary mesh C API function 2023-08-24 13:10:41 -04:00
Hans Goudey 119fbba47d Cleanup: Simplify PBVH update of mesh pointers
- User higher level access to mesh normals
- Avoid duplicating the retrieval of visibility layers
2023-08-24 12:41:28 -04:00
Bastien Montagne 7e7edc4d8e Readfile: Fix existing memleak in case an Armature Object loses its armature ObData.
The situation at this stage of readfile process is now sane enough, that
the regular Pose freeing code can be called, avoiding potential
memleaks.

Note that this whole 'non-Empty object with NULL obdata' case should now
be very hypothetical, since in case a linked obdata goes missing,
Blender will generate and empty place-holder for it at read time.

Tested by artificially setting all Armature objects' obdata pointer to
null in read_data code, and loading some complex production files from
Pets Project.
2023-08-24 17:30:12 +02:00
Hans Goudey 111e586424 Cleanup: Sculpt: Avoid unnecessarily changing vertex normals
Keeping a mutable reference to vertex normals for the entire lifetime
of the PBVH structure makes caching the normals and sharing the cache
harder than it should be. Generally code is safer when we reduce the
number of mutable references to data.

Currently the normals are modified in two places. First is the sculpt
mesh normal recalculation. There we can just retrieve the normals from
the mesh each time. Second is the restore from an undo step. That is
unnecessary because the normals are marked for recalculation anyway.
It doesn't even make much sense to store the normals in an undo step
when we can easily recalculate them based on new positions.

This change helps with #110479. These were also the last place that
kept a mutable reference to normals. I tested undo and redo after
sculpting, and it works well for each PBVH type.

Pull Request: https://projects.blender.org/blender/blender/pulls/111470
2023-08-24 16:47:55 +02:00
Bastien Montagne b53c7a804a Readfile: Replace the 'lib_link' specific code by generic usage of foreach_id.
The `lib_link` callback cannot always be fully replaced/removed, as in
some case it is also doing some validation checks, or data editing based
on the result of lib_linking internal ID pointers.

The callback has been renamed for that purpose, from `read_lib` to
`read_after_liblink`. It is now called after all ID pointers have been
fully lib-linked for the current ID, but still before the call to
`do_versions_after_linking`.

This change should not have any behavioral effect. Although in theory
the side-effect of this commit (to split lib linking itself, and the
validation/further processing code) into two completely separated steps
could have some effects, in practice none are expected, and tests did
not show any changes in behavior either..

Part of implementing #105134: Removal of readfile's lib_link & expand code.
2023-08-24 16:33:31 +02:00
Hans Goudey 45d8a8b0c3 Geometry Nodes: Initial basic rotation socket nodes
This PR adds an initial set of nodes using the new rotation socket.
6 nodes build rotations or convert them to other formats, a 7th rotates
a vector with a rotation, and the last inverts rotations.

The design task #109965 describes the choice to use separate nodes
for the rotation construction and separation operations. In the future,
a "Switch Node" operator (#111438) will help to make working with
these separated nodes faster.

- **Axis Angle to Rotation**
- **Rotation to Axis Angle**
- **Combine Quaternion**
- **Separate Quaternion**
- **Euler to Rotation**
- **Rotation to Euler**
- **Rotate Vector**
- **Invert Rotation**

See #92967

Pull Request: https://projects.blender.org/blender/blender/pulls/109030
2023-08-24 14:58:55 +02:00
Hans Goudey d8757236e0 Cleanup: Remove unused sculpt function declaration
The function is static, it doesn't need to be declared in the header.
2023-08-24 08:21:10 -04:00
Hans Goudey 4d82e1a7ee Cleanup: Simplify, parallelize multires to mesh visibility propagation
After undoing a visibility change, the visibility is propagated from
multires grids to mesh faces and vertices. This progress was completely
single threaded and more complicated than necessary. Simplify it
using newer C++ data structures and APIs.
2023-08-24 07:37:07 -04:00
Campbell Barton a13823057c Cleanup: format 2023-08-24 11:37:29 +10:00
Campbell Barton 8d1ffe14b2 Cleanup: use a bool for BKE_mesh_orco_verts_transform invert argument 2023-08-24 10:45:34 +10:00
Bastien Montagne 8bb5916183 Readfile: Replace the 'expand' specific code by generic usage of foreach_id.
The `expand` callback is 'trivial' to replace, since it is only iterating
over ID pointers and calling a callback.

The only change in behavior here is that some pointers that were not
processed previously will now be.

In practice this is not expected to have any real effect (usually
the IDs used by these pointers would have been expanded through other
usages anyway). But it may solve a few corner cases, undocumented issues
though.

Part of implementing #105134: Removal of readfile's lib_link & expand code.
2023-08-23 16:44:56 +02:00
Bastien Montagne c79642fa98 Core: foreach_id: Do not mutually exclude 'no origpointer access' and 'readonly' flags anymore.
There are actually cases where you do not want to access the original
ID pointers, even though the callback will not modify them. One example
is the incoming generic 'expand' readfile callback, which will replace the
dedicated one for all ID types.

Related to #105134: Removal of readfile's lib_link & expand code.
2023-08-23 16:44:56 +02:00
Hans Goudey e7abe1fd76 Cleanup: Remove unused node function 2023-08-23 10:37:09 -04:00
Lukas Tönne 26e2f07dad Fix #111381: Crash when inserting a node onto a link inside a frame
`discover_tree_zones` requires the node topology cache, make sure it is available before calling.

Pull Request: https://projects.blender.org/blender/blender/pulls/111383
2023-08-23 08:51:05 +02:00
Campbell Barton 3aa0715d65 Cleanup: remove calls to snprintf
Use BLI_snprintf/SNPRINTF to ensure the strings are null terminated.
2023-08-23 15:04:12 +10:00
Campbell Barton 24ef5e097a Cleanup: balance doxy sections 2023-08-23 14:54:46 +10:00
Campbell Barton f66fa32ada Cleanup: spelling in comments 2023-08-23 13:30:55 +10:00
Bastien Montagne 709ec52c7d Core: foreach_id: Add a new callback flag to skip processing at readfile time.
In readfile context, some ID pointers have to be ignored: typically the
'owner_id' pointers of embedded data.

Currently unused, but required for replacing `blend_read_lib`/
`blend_read_expand` by `foreach_id` (#105666).
2023-08-22 22:17:04 +02:00
Hans Goudey 1857df8d5b Cleanup: Use FunctionRef for PBVH filtering callback
Call functions directly in lambdas rather than passing their
arguments in a separate void * argument. This can be changed
more in the future to move callback arguments out of smaller
structs.
2023-08-22 15:06:42 -04:00
Hans Goudey 42bf06a57d Fix #111255: Sculpt mode crash for mesh with no faces 2023-08-22 12:29:36 -04:00
Bastien Montagne 7a0a406ff8 Core: foreach_id: add optional support for deprecated ID pointers.
This commit adds a new option flag to the lib_query foreach_id code,
which will make deprecated ID pointers to be processed as well.

NOTE: Currently there is no report to the callbakcs about the fact that
it is processing a deprecated ID. This can be easily added later if it
becomes necessary.

Part of implementing #105134: Removal of readfile's lib_link & expand code.
2023-08-22 17:47:57 +02:00
Clément Foucault acd6dd96b7 Camera: Move panoramic projection settings to DNA
This is in prevision of EEVEE panoramic projection support.

EEVEE-Next is planned to add support for these parameters.
Not having these parameters in Blender DNA will make Cycles
and EEVEE not share the same parameters and will be confusing
for the user.

We handle forward compatibility by still writing the parameters
as ID properties as previous cycles versions expect.

Since this change will break the API compatibility it is crucial
to make it for the 4.0 release.

Related Task #109639

Pull Request: https://projects.blender.org/blender/blender/pulls/111310
2023-08-22 15:49:34 +02:00
Hans Goudey fccab83bc8 Cleanup: Small cleanups to BKE_cloth.hh header
- Use C++ math vector type
- Remove struct and typedef keywords
2023-08-22 07:48:53 -04:00
Hans Goudey 55d6d5b335 Cleanup: Move BKE_cloth.h to C++ 2023-08-22 07:48:53 -04:00
Jesse Yurkovich f30ac938de Cleanup: Reduce unnecessary mesh position copying
Continuation of #103789 to remove/reduce the copying of mesh position
data.

Pull Request: https://projects.blender.org/blender/blender/pulls/111313
2023-08-22 03:51:53 +02:00
Harley Acheson d45f47a809 Cleanup: Make format
Formatting changes resulting from "make format"
2023-08-21 15:52:36 -07:00
Jesse Yurkovich baa8f663a2 Fix (unreported) nullptr access in BKE_fcurve_handles_recalc_ex
Don't access fields of the potentially null `FCurve` struct before it's
been validated.

Pull Request: https://projects.blender.org/blender/blender/pulls/111315
2023-08-21 20:15:22 +02:00
Amelie Fondevilla 3dc93d6e38 GPv3: Display layer groups in grease pencil dopesheet
This patch adds a new type of channel for grease pencil layer groups, which works as an expandable summary channel of layers inside the group.

Pull Request: https://projects.blender.org/blender/blender/pulls/111015
2023-08-21 10:51:00 +02:00
Campbell Barton 33a05725be Cleanup: spelling in comments 2023-08-21 10:05:45 +10:00
Hans Goudey 39a40d6f84 Cleanup: Subdiv: Replace "stack or buffer" storage with C++ classes
Blender's C++ data structures have configurable inline buffers used to
avoid allocation when the needed size is small. Use them in multires
code instead of an uglier C solution.

Pull Request: https://projects.blender.org/blender/blender/pulls/111070
2023-08-20 00:25:45 +02:00
Campbell Barton 5a8cb665e0 Cleanup: various non-functional C++ changes 2023-08-19 23:52:47 +10:00
Campbell Barton faa3ef6ad5 Cleanup: format 2023-08-19 23:52:47 +10:00
Bastien Montagne 99e78f1c7a Cleanup: Move Object' FluidModifier internal data handling from 'lib_link' into 'read_data' code.
The only acceptable case to handle internal data in 'lib_link' code is
when it depends on other IDs info. Otherwise, it should be done in
'read_data' code (and versioning if relevant).
2023-08-18 17:31:06 +02:00
Falk David 24082ceecc Cleanup: GPv3: Constructors and destructors
The `TreeNode`, `Layer` and `LayerGroup` constructors and destructors
had some inconsistencies. Now the code is a bit more clean and shared.
2023-08-18 15:06:18 +02:00
Bastien Montagne f954329376 Cleanup: Move FCurve's internal data hanlding from 'lib_lkink' to 'read_data' code.
Deciding to forcefully set an ID pointer to null is not ID lib_linking
process, but internal data management.
2023-08-18 14:58:44 +02:00
Bastien Montagne 77eb7898e9 Cleanup: Comment in liboverride hierarchy handling code. 2023-08-18 14:23:41 +02:00
Bastien Montagne dfb002bac6 Cleanup: Move Workspace's internal data handling from 'lib_link' to 'read_data' code.
Decision to clear the pinned scene ID in case of linked data _is_
internal data handling, and not related to updating relationships to
other IDs.
2023-08-18 14:23:18 +02:00
RedMser baeeff9a84 Fix: crash in liboverride hierarchy ensure
Add null checks to logging and fix typo in if-check.

Pull Request: https://projects.blender.org/blender/blender/pulls/111055
2023-08-18 14:20:34 +02:00
Weizhen Huang 6f8011edf7 Cycles: new Principled Hair BSDF variant with elliptical cross-section support
Implements the paper [A Microfacet-based Hair Scattering
Model](https://onlinelibrary.wiley.com/doi/full/10.1111/cgf.14588) by
Weizhen Huang, Matthias B. Hullin and Johannes Hanika.

### Features:
- This is a far-field model, as opposed to the previous near-field
Principled Hair BSDF model. The hair is expected to be less noisy, but
lower roughness values takes longer to render due to numerical
integration along the hair width. The hair also appears to be flat when
viewed up-close.
- The longitudinal width of the scattering lobe differs along the
azimuth, providing a higher contrast compared to the evenly spread
scattering in the near-field Principled Hair BSDF model. For a more
detailed comparison, please refer to the original paper.
- Supports elliptical cross-sections, adding more realism as human hairs
are usually elliptical. The orientation of the cross-section is aligned
with the curve normal, which can be adjusted using geometry nodes.
Default is minimal twist. During sampling, light rays that hit outside
the hair width will continue propogating as if the material is
transparent.
- There is non-physical modulation factors for the first three
lobes (Reflection, Transmission, Secondary Reflection).

### Missing:
- A good default for cross-section orientation. There was an
attempt (9039f76928) to default the orientation to align with the curve
normal in the mathematical sense, but the stability (when animated) is
unclear and it would be a hassle to generalise to all curve types. After
the model is in main, we could experiment with the geometry nodes team
to see what works the best as a default.

Co-authored-by: Lukas Stockner <lukas.stockner@freenet.de>
Pull Request: https://projects.blender.org/blender/blender/pulls/105600
2023-08-18 12:46:13 +02:00
Falk David d06a6105a7 Fix: GPv3: `TreeNode::is_locked()` function
The function returned `true` for the root node, which it shouldn't.
2023-08-18 12:44:11 +02:00
Falk David 725f1dbf2d Revert: GPv3: DNA rename of `name`
Partially reverts b14a0ee57e.

Instead of renaming the DNA field, use namespaces in C++ to resolve
name collisions (which is the reason this change was done
in the first place).
2023-08-18 12:44:11 +02:00
Bastien Montagne 591c778b33 Fix (unreported) memleak in Particle lib_link code.
The potential data already read in `instance_weights` listbase needs to
be freed, instead of just clearing the listbase.

Also move some (very old!) versioning code out of Particle's 'lib_link'
code into proper versioning code.
2023-08-18 11:22:50 +02:00
Campbell Barton bc1ffdce5b Cleanup: spelling in comments 2023-08-18 08:56:12 +10:00
Bastien Montagne 1b25849ea6 Fix (unreported) missing handling of plane tracks' image ID pointer in MovieClip foreach_id code. 2023-08-17 19:58:07 +02:00
Bastien Montagne 75eb7ace73 Cleanup: move internal data handling from Mesh 'lib_link' to 'read_data' code.
No behavioral change expected from this commit.
2023-08-17 19:45:09 +02:00
Bastien Montagne 7d6e47a2b0 Fix (unreported) missing handling of Maks' spline parent ID pointer in foreach_id code. 2023-08-17 19:26:01 +02:00
Bastien Montagne 3822d8e3fc Fix (unreported) LineStyle foreach_id callback skipping some NULL ID pointers.
Not sure how bad that was in practice, was likely harmless. But
foreach_id logic should never decide to not process an ID pointer
because its value is NULL. Callback code is expected to handle NULL
pointers appropriately.
2023-08-17 19:19:05 +02:00
Bastien Montagne a083e1cd0f Cleanup: Remove unused `image` Image pointer from LigthPrope data.
This pointer was fully unused, no point in keeping it around.
2023-08-17 18:57:54 +02:00
Bastien Montagne eb582b9441 Cleanup: move internal data handling from ScreenArea 'lib_link' to 'read_data' code.
No behavioral change expected from this commit.
2023-08-17 16:33:47 +02:00
Bastien Montagne 6033edd6b2 Cleanup: move internal data handling from Screen 'lib_link' to 'read_data' code.
No behavioral change expected from this commit.
2023-08-17 16:24:38 +02:00
Bastien Montagne d7d487e13a Refactor: Move Editors' 'foreach_id' code into a new SpaceType callback.
Was a known pending TODO for quite some time already.

This commit should have no behavior change at all.
2023-08-17 16:08:05 +02:00
Falk David 5aacbf6c81 Fix: GPv3: Crash because of missing null check
There was a missing null check in the `TreeNode::name()`
function.
2023-08-17 14:41:26 +02:00
Bastien Montagne f1e64781a8 Core: foreach_id: Tweak handling of scene collection in LayerCollection.
Unfortunately, relying only on the 'embedded' flag of the collection ID
pointer to detect the LayerCollection of a Scene embedded collection is
not enough, since this info may not always be available.

So add an extra explicit 'is_master' to the recursive code processing
all LayerCollections ID pointerrs, and double-check with an assert that
this info is coherent with the Collection's embedded flag, when
possible.
2023-08-16 18:23:15 +02:00
Bastien Montagne 28305c2c73 Refactor: Properly formalize special versioning done after most of readfile code.
In a few cases (IPO conversion, Proxy conversion, ...), versioning
implies creating or removing IDs, and/or needs access to the whole Main
data-base.

So far this was done ad-hoc by adding some code at the end of
`setup_app_data`.

This commit formalizes this process by adding a BLO call
(`BLO_read_do_version_after_setup`) that will encapsulate all such
complex versioning code.

NOTE: This commit does not address the existing issue that this
versioning code is never performmed when linking new data (outside of
the 'opening a blendfile' context). This topic would require its own
design task.

NOTE: This commit does not fix the few current evil cases of ID creation in
regular versioning code. This will be addressed separately.

Although this commit does modifies slightly some logic in this specific
versioning process, no behavioral changes are expected here.

Pull Request: https://projects.blender.org/blender/blender/pulls/111147
2023-08-16 16:21:59 +02:00
Falk David b14a0ee57e Cleanup: GPv3: Refactor usage of `TreeNode`
Some functionality of `Layer`s and `LayerGroup`s can be shared. This is why the `TreeNode` class exists. It encapsulates all the common methods both `Layer`s and `LayerGroup`s should have.

Up until now, the usage of `TreeNode` was not consistent and often the layers would just access the base c-struct directly.

This refactor makes it so that all of the functions affecting only the `TreeNode` are moved to the `TreeNode` class and only implemented there.

For example, renaming a layer is really just renaming the node. Therefor there shouldn't even be a `rename_layer` and `rename_layer_group` function. These were combined into a `rename_node` function.

Pull Request: https://projects.blender.org/blender/blender/pulls/111177
2023-08-16 16:18:26 +02:00
Bastien Montagne dd647677b6 Fix (unreported) Scene foreach_id callback skipping some NULL ID pointers.
Not sure how bad that was in practice, was likely harmless. But
foreach_id logic should never decide to not process an ID pointer
because its value is NULL. Callback code is expected to handle NULL
pointers appropriately.
2023-08-16 15:04:33 +02:00
Aras Pranckevicius 2f060706a4 Cleanup: fewer BLI_color.hh et al includes
Include counts of some headers while making full blender build:
- BLI_color.hh 1771 -> 1718
- BLI_math_color.h 1828 -> 1783
- BLI_math_vector.hh 496 -> 405
- BLI_index_mask.hh 1341 -> 1267
- BLI_task.hh 958 -> 903
- BLI_generic_virtual_array.hh 509 -> 435
- IMB_colormanagement.h 437 -> 130
- GPU_texture.h 806 -> 780
- FN_multi_function.hh 331 -> 257

Note: DNA_node_tree_interface_types.h needs color include only
for the currently unused (but soon to be used) socket_color function.
Future step is to figure out how to include
DNA_node_tree_interface_types.h less.

Pull Request: #111113
2023-08-16 14:48:53 +03:00
Campbell Barton 92c4756d02 Fix replacement of "Blender Foundation" in recent header change
The recent change to header copyrights [0] unintentionally changed
"Blender Foundation" to "Blender Authors" for the WIN32 file path
which blender is installed into.

Revert lines changed that aren't related to copyright text.

[0]: e955c94ed3
2023-08-16 21:21:55 +10:00
Aras Pranckevicius acbd952abf Cleanup: fewer iostreams related includes from BLI/BKE headers
Including <iostream> or similar headers is quite expensive, since it
also pulls in things like <locale> and so on. In many BLI headers,
iostreams are only used to implement some sort of "debug print",
or an operator<< for ostream.

Change some of the commonly used places to instead include <iosfwd>,
which is the standard way of forward-declaring iostreams related
classes, and move the actual debug-print / operator<< implementations
into .cc files.

This is not done for templated classes though (it would be possible
to provide explicit operator<< instantiations somewhere in the
source file, but that would lead to hard-to-figure-out linker error
whenever someone would add a different template type). There, where
possible, I changed from full <iostream> include to only the needed
<ostream> part.

For Span<T>, I just removed print_as_lines since it's not used by
anything. It could be moved into a .cc file using a similar approach
as above if needed.

Doing full blender build changes include counts this way:
- <iostream> 1986 -> 978
- <sstream> 2880 -> 925

It does not affect the total build time much though, mostly because
towards the end of it there's just several CPU cores finishing
compiling OpenVDB related source files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111046
2023-08-16 09:51:37 +02:00
Iliya Katueshenock f50da4040f Fix #111142: bl_static_type is empty for node groups and custom nodes
Caused by f18c45eb69.
Functions `node_type_base` and `node_type_base_custom`
are the same, but last one have been missed in the cleanup.

Pull Request: https://projects.blender.org/blender/blender/pulls/111154
2023-08-16 09:29:46 +02:00
Hoshinova 0702c24a36 Nodes: Add Lacunarity and Normalize inputs to Noise node
This PR adds the Lacunarity and Normalize inputs to the Noise node
similar to the Voronoi node.

The Lacunarity input controls the scale factor by which each
successive Perlin noise octave is scaled. Which was previously hard
coded to a factor of 2.

The Noise node normalizes its output to the [0, 1] range by default.
The Normalize option makes it possible for the user to disable that.
To keep the behavior consistent with past versions it is enabled by
default.

To make the aforementioned normalization control easer to implement,
the fractal noise code now accumulates signed noise and remaps the
final sum, as opposed to accumulating positive [0, 1] noise.

Pull Request: https://projects.blender.org/blender/blender/pulls/110839
2023-08-15 17:38:45 +02:00
Falk David 969de5135a GPv3: Re-evaluate on frame change
This makes it so the `GreasePencil` geometry gets updated on a time
change.
The frame at which the object gets evaluated is stored in runtime as
`eval_frame`. This is for example used to calculate the bounding box
of the geometry as well as invalidating the batch cache for different
frames.

Pull Request: https://projects.blender.org/blender/blender/pulls/111137
2023-08-15 17:31:11 +02:00
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Bastien Montagne 257f21d494 Cleanup: Move Compositor versioning code from Scene's 'lib_link' to actual versioning code.
Not sure when that versioning was added, but nowadays there are the
'after_linking` versioning handlers for that kind of case.
2023-08-15 15:54:21 +02:00
Bastien Montagne 4b98c0aa24 Cleanup: Remove 'read_data' code from Scene's paint 'link_lib' code.
Changes to internal private data of an ID has _nothing_ to do into its
'lib_link' reading code (unless in the extremely rare case where it
would have hard dependency on its ID having valid ID pointers).

In that case, `BKE_paint_runtime_init` was already called in
`BKE_paint_blend_read_data` anyway, so the only actual change was
setting `p->paint_cursor`... *sigh*
2023-08-15 12:02:37 +02:00
Bastien Montagne e2a5846d56 Fix (unreported) improper handling of camera's baground image IDs in foreach_id callback.
`foreach_id` callbacks should not decide whether a given ID pointers
should be processed or not (unless maybe some extremely specific cases).

Even if an ID pointer is not currently 'used', it still needs to
increment its ID user count, be remapped to a new pointer, etc. etc.
2023-08-14 18:17:13 +02:00
Falk David 2661747138 Cleanup: GPv3: Move inline `Drawing` methods
Moves the `blender::bke::greasepencil::Drawing` methods into the
`namespace blender::bke::greasepencil`.
2023-08-14 17:47:12 +02:00
Bastien Montagne 7ddea7e90a Cleanup/Fix: Move 'security' check on constraints 'data' into 'read_data' code.
Having this check is likely no more meaningful (it seems to have been
added ages ago), but keeping it around does not hurt either. And it
could avoid crashes in some file corruption cases e.g.

However, having it in 'lib_link' code of constraints is useless for
sure, since that data pointer may have already been accessed in the
'read_data' one. And of course, logically it belongs to 'read_data'
anyway, since it's related (and only affects) private local data, not
pointers to other IDs...

No behavioral change expected here.
2023-08-14 17:28:08 +02:00
Bastien Montagne 695995d7cb Refactor: Move 'local data' liboverride flag clearing from 'lib_link' to 'read_data' code.
There is no reason to do that in the 'lib_link' stage of blendfile
reading, whether the owner ID is linked or local is already known info
at the 'read_data' stage of the process. And it is more logical to do
that in code affecting internal private data of an ID, rather than in
code handling updates of it ID pointers.

Note that the camera's baground image case was already handled in the
'read_data' stage.

No behavioral change expected here.
2023-08-14 16:45:18 +02:00
Bastien Montagne 6a79a6a24a Cleanup/Refactor: Move animdata read/write code into generic ID handling.
There is no reason at all for each ID read/write callbacks to have to
deal with this generic, common data explicitely. Generic ID read/write
code is the place to handle such data (just like asset, liboverride,
etc. data are handled already).

Note behavioral change expected here.
2023-08-14 16:30:53 +02:00
Bastien Montagne 29930ef589 readfile: Move Object proxy validation code from lib_link to do_version.
This is now deprecated data, no reason to keep such logic in the main
lib-linking code of Object ID.
2023-08-13 13:43:54 +02:00
Bastien Montagne 6cd7eda1c6 Fix (unreported) wrong handling of depreacted non-Empty instantiating objects in readfile code.
Fixing this is do-version work. Having that kind of logic in lib-linking
code is... beyond despicable.
2023-08-13 13:10:27 +02:00
Hans Goudey 9804b2244a Cleanup: Make sculpt face visibility test inline
This simple function just performed a null check and an array lookup.
Just writing it in the few places its used works fine too, and avoiding
the function call per triangle can improve and make the check clearer.

Also, avoiding the abstraction makes the "node fully visible" check
when building the PBVH more obvious; that has been refactored here.

Pull Request: https://projects.blender.org/blender/blender/pulls/111072
2023-08-12 23:58:26 +02:00
Hans Goudey b04a72866d Revert "Multires: Simplify grids normals update and grid to face map"
This reverts commit c97178fa2e.

This was committed to main by mistake, it was meant for a local branch.
2023-08-12 16:38:39 -04:00
Hans Goudey c97178fa2e Multires: Simplify grids normals update and grid to face map
The goal is to move to more data oriented design, reducing memory
usage and simplifying code by clarifying data access, avoiding
unnecessary levels of abstraction, and reusing code.

- Simplify threading with the C++ threading API
- Pass the faces to update with an IndexMask instead of a pointer array
  - IndexMask uses less memory and simplifies masking and iteration
- Store the grid to face map with indices instead of pointers
  - Now this is exactly the same as `build_loop_to_face_map`
2023-08-12 12:20:10 -04:00
Hans Goudey 3d6a8ab54f Cleanup: Remove unused argument to PBVH draw 2023-08-12 12:17:25 -04:00
Campbell Barton 311fa9768d Cleanup: spelling in comments 2023-08-12 16:29:51 +10:00
Pratik Borhade d87db8d569 Fix #111024: Crash when adding attribute to curve object
After 12ef20990b, attributes and vertex group names were checked
simultaneously to fix the name collision. But this results in crash when
new attribute is added to curve object (it searches for vertex group
list). To avoid the crash, check for supported id types in new function
`BKE_id_supports_vertex_groups`.

Pull Request: https://projects.blender.org/blender/blender/pulls/111036
2023-08-12 07:37:37 +02:00
Hans Goudey efacffebfc Cleanup: Add comment for mesh triangulation faces cache 2023-08-11 22:03:25 -07:00
Bastien Montagne 4facf670a8 Fix (unreported) foreach_id missing handling of ID pointers from RNA strips modifiers.
Also factorized fcurve modifiers foreach_id processing into their own
new function, `BKE_fmodifiers_foreach_id`.
2023-08-11 16:57:22 +02:00
Campbell Barton d3353eb34b Cleanup: use const variables, reduce right-shift in unti.cc
Also assert the 3D view fixed size buffer is large enough.
2023-08-11 18:12:45 +10:00
Campbell Barton 8ce5a24b77 PyAPI: add preferences.filepaths.extension_repos.new/remove methods
Provide convenient access to adding/removing repositories,
useful for testing.
2023-08-11 17:37:12 +10:00
Jacques Lucke cc4d5c432c RNA: move headers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/111022
2023-08-10 22:40:27 +02:00
Falk David 4f66031714 GPv3: Fix TreeNode::parent_group() for root group
For the root group, the parent is `nullptr` so calling `parent_group()`
would fail. This fixes the issue by adding a null check and returning
`nullptr` otherwise.
2023-08-10 16:05:21 +02:00
Amelie Fondevilla f1e4cd3f1f Fix: missing include in volume.cc
Pull Request: https://projects.blender.org/blender/blender/pulls/111005
2023-08-10 14:21:22 +02:00
Amelie Fondevilla 7f6196ccae GPv3: Display layer properties in animation channels
This patch adds layer widgets in the grease pencil layer channels of the grease pencil dopesheet.
It adds RNA + getter function for the `use_onion_skinning` at layer level.
It also sets the offset of the channel, and the color of grease pencil data-block channels.

Pull Request: https://projects.blender.org/blender/blender/pulls/110991
2023-08-10 13:55:14 +02:00
Aras Pranckevicius d973355b3a Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).

However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.

This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.

Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
  to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).

Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.

Pull Request #110944
2023-08-10 14:51:40 +03:00
Amelie Fondevilla 09d2108bf5 GPv3 : Transform action for grease pencil frames.
Implementation of the transform action for grease pencil frames, which enables translating and scaling grease pencil frames in the dopesheet.

This patch adds the following in the grease pencil API :
 - `move_frames`  to move a set of frames given a map of key transformations (with overwrite), and
 -  the structure `LayerTransformData` that stores in the layer runtime some useful data for the frames transformation.

Co-authored-by: Falk David <falk@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/110743
2023-08-10 12:57:32 +02:00
Bastien Montagne 6a86dd5f34 LibOverride: Add ID pointer to operations over ID pointers.
In RNA collections storing ID references, the name of the collection
item may not always be unique, when several IDs from different libraries
are present.

While rare, this situation can become deadly to liboverride, by causing
random but exponential liboverride hierarchies corruptions.

This has already been alleviated by using preferably both name and index
in items lookup (a05419f18b) and by reducing the risk of name collision
in general between liboverrides and their linked reference (b9becc47de).

This commit goes further, by ensuring that references to items of RNA
collections of IDs stored in liboverride operations become completely
unambiguous. This is achieved by storing an extra pointer to the item's
ID itself, when relevant.

Lookup then requires a complete match `name + ID` to be successful,
which is guaranteed to match at most a single item in the whole RNA
collection (since RNA collection of IDs do not allow duplicates, and
the ID pointer is always unique).

Note that this ID pointer is implemented as an `std::optional` one
(either directly in C++ code, or using an new liboverride operation `flag`
in DNA). This allows to smoothly transition from existing data to the
added ID pointer info (when needed), without needing any dedicated
versioning. This solution also preserves forward compatibility as much
as possible.

It may also provide marginal performances improvements in some cases, as
looking up for ID items in RNA collections will first check for the
ID pointer, which should be faster than a string comparision.

Implements #110421.

Pull Request: https://projects.blender.org/blender/blender/pulls/110773
2023-08-10 12:41:20 +02:00
Campbell Barton 23cd37de25 Cleanup: redundant checks 2023-08-10 17:11:24 +10:00
Falk David 9e172b9e2e Cleanup: GPv3: Use `int64_t` for indices
Instead of `int` use `int64_t`.
2023-08-09 16:47:25 +02:00
Falk David 827a71fe7e GPv3: Refactor: replace `remove_frame_at` function
Instead of removing frames one by one, the `GreasePencil::remove_frames`
function now expects a span of frame numbers, replacing the
`GreasePencil::remove_frame_at` function.
Now, when drawings need to be deleted, we shrink the array only once.

Pull Request: https://projects.blender.org/blender/blender/pulls/110957
2023-08-09 16:12:45 +02:00
Lukas Tönne 63115218d8 Nodes: Fixed accidental typo. 2023-08-09 16:04:59 +02:00
Lukas Tönne 063294932a Nodes: fix for silenced variable, used the wrong name. 2023-08-09 16:00:30 +02:00
Lukas Tönne f1ec9f7190 Silence unused variable warning, from an intermediate PR.
The first part of the node panels PR has an unused API call that will be
reenabled with the next stages (#110885).
2023-08-09 15:58:23 +02:00
Campbell Barton f940eb7739 Cleanup: quiet compiler warnings, also correct typo & pep8 formatting 2023-08-09 20:24:24 +10:00
Campbell Barton 31cb31d736 PyAPI: add-on name-spacing for extension repositories
Support name-spaced add-ons, exposed via user configurable extension
repositories.

Directories for add-ons can be added at run-time and are name-spaced to
avoid name-collisions with Python modules or add-ons from other
repositories.

This is exposed as an experimental feature "Extension Repositories".

Details:

- A `bUserExtensionRepo` type which represents a repository which is
  listed in the add-ons repository.

- `JunctionModuleHandle` class to manage a package with sub-modules
  which can point to arbitrary locations.

- `bpy.app.handlers._extension_repos_update_{pre/post}` internal
  callbacks run before/after changes to extension repositories,
  callbacks are used to sync the changes to the Python package that
  exposes these to add-ons.

- The size of an add-on name has been increased so a user-defined package
  prefix can be included without enforcing shorter add-on names.

- Functionality relating to package management has been left out of this
  change and will be developed separately.

Further work:

- While a repository can be renamed, enabled add-ons aren't renamed.
  Eventually we might want to support this although we could also
  disallow renaming repositories with add-ons enabled as the name isn't
  all that significant.

- Removing a repository should remove all the add-ons located in this
  repository.

- Sub-module names are currently restricted to `[A-Za-z]+[A-Za-z0-9_]*`
  we might want to relax this to allow unicode characters (we might
  still want to disallow `-` or any characters that would prevent
  attribute access in code).

Ref !110869.

Reviewed By: brecht
2023-08-09 20:24:24 +10:00
Bastien Montagne 23835a393c Remove compatibility code for blendfiles from early 2.80 development era.
Remove the 'SceneCollection' structure definition from DNA, and the
compatibility code converting it to the 'modern' viewlayer system.

'SceneCollection' was part at some point of the new collection system
during 2.80 development, but was never in any published Blender release.
So this code was only ensuring compatibility with a few potential
Blender files saved from in-development builds over four years ago.

Implements #110918.

Pull Request: https://projects.blender.org/blender/blender/pulls/110926
2023-08-09 11:15:27 +02:00
Sergey Sharybin db4f926c92 Cleanup: LIST_SWAP re-definition warning
Happens on Apple M2 platform. Caused by indirectly included queue.h
via tbb, which has its own LIST_SWAP.

Rename our macro to `LISTBASE_SWAP` to avoid conflicts.

Pull Request: https://projects.blender.org/blender/blender/pulls/110943
2023-08-09 10:23:08 +02:00
Lukas Tönne 090f365cbd Node panels: New DNA and C++ API for node group interfaces
Part 1/3 of #109135, #110272

Adds a new DNA structure for defining node group interfaces without
using `bNodeSocket` and with additional node UI item types.

Node group interfaces are organized as a hierarchy of "items", which
can be sockets or panels. Panels can contain both sockets and other
panels (although nested panels beyond the root panel may be disabled to
avoid complexity on the user level).

Sockets can be added to the interface in any order, not just the
conventional outputs..inputs order. Sockets can be marked as both input
and output, generating 2 sockets on node instances.

The C++ API in the DNA struct allows manipulating the interface
declaration by adding and removing items, moving them inside the
interface or into a different panel.

Pull Request: https://projects.blender.org/blender/blender/pulls/110885
2023-08-09 10:06:31 +02:00
Campbell Barton bff7962c80 Cleanup: remove redundant struct/void in C++, function style casts 2023-08-09 13:37:37 +10:00
Campbell Barton 8d0268b09c Cleanup: spelling in comments 2023-08-09 11:20:59 +10:00
Campbell Barton e68302d49e Cleanup: use block-comments for multi-line comments 2023-08-09 11:17:04 +10:00
Campbell Barton 1a675d0c47 Cleanup: format disabled code 2023-08-09 10:49:53 +10:00
Colin Marmond b8eb7d18e9 Nodes: experimental node previews in the shader editor
First implementation of node previews in the shader node editor. Using
the same user interface as compositor node previews, most shader nodes
can now be previewed (except group in/output and material output).

This is currently still an experimental feature, as polishing of the
user experience and performance improvements are planned. These will
be easier to do as incremental changes on this implementation.

See #110353 for details on the work that remains to be done and known
limitations.

Implementation notes:

We take advantage of the `RenderResult` available as `ImBuf` images to
store a `Render` for every viewed nested node tree present in a
`SpaceNode`. The computation is initiated at the moment of drawing nodes
overlays.

One render is started for the current nodetree, having a `ViewLayer`
associated with each previewed node. We separate the previewed nodes in
two categories: the shader ones and the non-shader ones.
- For non-shader nodes, we use AOVs which highly speed up the rendering
  process by rendering every non-shader nodes at the same time. They are
  rendered in the first `ViewLayer`.
- For shader nodes, we render them each in a different `ViewLayer`, by
  rerouting the node to the output of the material in the preview scene.

The preview scene takes the same aspect as the Material preview scene,
and the same preview object is used.

At the moment of drawing the node overlay, we take the `Render` of the
viewed node tree and extract the `ImBuf` of the wanted viewlayer/pass
for each previewed node.

Pull Request: https://projects.blender.org/blender/blender/pulls/110065
2023-08-08 17:36:06 +02:00
Bastien Montagne e1b1b2a8b4 Fix (unreported) collection 'readfile' expand incorrect assertion.
Naming is bad and confusing, but the 'expander' code path from readfile
can also be used outside of the reading context (see e.g.
`BKE_blendfile_write_partial` code). So code cannot assume that it is
exclusively working on data freshly read from file.

This should be renamed - but should also be probably replaced by
proper usage of the more generic 'foreach_id' code anyway, see #105134.

Found while investigating #109588.
2023-08-08 15:55:17 +02:00
Bastien Montagne 5dfd3e3c28 Fix (unreported) missing handling of ViewLayer IDProperties in foreach_id code.
Yet another 'obviously' missing bit in foreach_id processing found and fixed.
2023-08-08 15:24:20 +02:00
Pratik Borhade 6e66125f34 GPv3: New is_layer_active function
New Grease Pencil function to determine whether the layer
is active.

Pull Request: https://projects.blender.org/blender/blender/pulls/110890
2023-08-08 11:26:22 +02:00
Philipp Oeser 12ef20990b Fix #103410: name collisions between vertex groups and attributes
These name collisions should be avoided with attributes, all sorts of
issues can arise from those. We already warned in the attributes
(but not the vertex groups) list if those were found.

Previously, creating a vertex group with the same name as an already
existing attribute would allow this (and give said warning), and creating
an attribute with the same name as an already existing vertex group
would silently fail (as in: not return a layer) -- and then due to an oversight
in 101d04f41f (which assumed a valid layer would always be returned
by `BKE_id_attribute_new`) would even crash.

Now name collisions between vertex groups and attributes are avoided,
unique names will be found across attributes and vertex groups if either
`BKE_id_attribute_calc_unique_name` or `BKE_object_defgroup_unique_name`
is called.

This is done by unifying the checks and callbacks for both into a single.

Pull Request: https://projects.blender.org/blender/blender/pulls/109910
2023-08-08 10:11:10 +02:00
Bastien Montagne d9ec3985a3 LibOverride: Remove an override property when it has no operations.
Update #BKE_lib_override_library_id_unused_cleanup to also clear the
property when all its operations have been removed, even if the
property itself was not tagged as unused.
2023-08-07 18:41:19 +02:00
Lukas Tönne 14bc097015 Nodes: Remove the experimental "node panels" feature
This feature is going to be replaced with a more thorough refactoring
of the node group interface UI, which has actual node drawing support
and a new API for integration of panels into nodes.

Design task: #109135
Implementation: #110272

Pull Request: https://projects.blender.org/blender/blender/pulls/110803
2023-08-07 10:40:29 +02:00
Clément Foucault cc34a0ae2e EEVEE-Next: Irradiance Volume: Allow object copy
This copies the baked lighting data during object
duplication. This allows library overrides to
work as expected on irradiance volumes.
2023-08-06 21:30:30 +02:00
Campbell Barton 845a5146e7 Cleanup: avoid term '_len' for buffer size 2023-08-06 16:09:04 +10:00
Campbell Barton 9e3dc02bed Cleanup: naming consistency for find functions
- find_from_name -> find_by_name.
- find_from_index -> find_index.

This matches naming used elsewhere in Blender API's.
2023-08-06 15:57:24 +10:00
Campbell Barton 0701c65d93 Cleanup: use DNA_struct_default_alloc utility function, doxy section 2023-08-06 15:47:50 +10:00
Campbell Barton b879a4f2d8 Cleanup: replace MEM_callocN with MEM_mallocN when overwritten afterward
Also pair allocation with memcpy calls.
2023-08-05 20:06:42 +10:00
Jacques Lucke b41c6489bc Cleanup: set node struct ui names at run-time
The goal is to get to closer to removing `NOD_static_types.h` and to define all/most
aspects of a node in the node file itself instead. Data defined in node files is not
available when rna structs are created currently, because that happens in a preprocessing
step. This patch moves part of what was defined in `rna_nodetree.cc` to `node.cc` which
makes it easier to replace when `NOD_static_types.h` is removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/110824
2023-08-05 09:12:27 +02:00
Campbell Barton 7f34ad736a Cleanup: spelling in comments 2023-08-05 13:54:25 +10:00
Hans Goudey 07019e7ef5 Cleanup: Remove more struct keywords from C++ headers 2023-08-04 22:47:29 -04:00
Hans Goudey ffe4fbe832 Cleanup: Move editors headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110820
2023-08-05 02:57:52 +02:00
Hans Goudey c15d391e86 Cleanup: Various cleanups in newly C++ headers
Mostly remove unnecessary struct and typedef keywords.
Move a few more small wm headers to C++ as well.
2023-08-04 17:55:14 -04:00
Jacques Lucke f18c45eb69 Cleanup: avoid using NOD_static_types.h for creating the node.type enum
The overall goal is to get rid of `NOD_static_types.h`. This patch removes
one usage of it to generate the `node.type` rna enum. Not all of the data
was available on `bNodeType` already, so I had to add the missing data there.

Pull Request: https://projects.blender.org/blender/blender/pulls/110810
2023-08-04 21:43:54 +02:00
Hans Goudey e3e6fb8ecf Geometry Nodes: Initial tool-specific nodes
Add three new nodes for operations and inputs specific to
node group operators.
- **Selection** Whether elements are selected in the viewport
- **Set Selection** Sets the edit/sculpt selection, on the point,
  face, or curve domains
- **3D Cursor** Gives the location and rotation of the 3D cursor,
  in the local space of the modified object.
- **Face Set** The face set value from mesh sculpt mode,
  and whether the attribute exists.
- **Set Face Set** Set sculpt face set values.

In the add menu and search, the nodes are only visible in the
"Tool" context of the geometry node editor. They also give
errors when executed by a modifier.

Pull Request: https://projects.blender.org/blender/blender/pulls/109517
2023-08-04 20:59:04 +02:00
Alexander Gavrilov 9921c3532c Custom Data: make get_layer_index_n always safely handle n overrun.
This function is used to retrieve the index of the n'th layer of
the specified type, if it exists. Currently the way it handles
an n value that is too big is inconsistent: if there are more
layers of different types following the ones of the correct type,
and n isn't too big, it will safely detect that the corresponding
layer is of a different type and return -1. However, if the value
results in a buffer overrun, it causes an assertion or crash.

This means that safe code should currently ensure n is always
correct, making the type check in this function pointless.
Moreover, checking the range in the caller may incur more
overhead than making this code safe.

This changes the assert into a check to ensure consistent behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/110812
2023-08-04 20:40:05 +02:00
Hans Goudey 39c3a86d8e Cleanup: Make object material count function take a const pointer 2023-08-04 13:42:51 -04:00
Hans Goudey f97a51350d Cleanup: Make mesh normal calculation function const
Since this outputs to a separate array and not a custom data layer,
it actually doesn't change the mesh (after 580833165c anyway).
2023-08-04 13:42:51 -04:00
Hans Goudey fd9d22ba57 Geometry Nodes: Operators: Support more object types and modes
Add support in the UI for the edit mode of curves, mesh, and point
cloud objects. It's possible to control for which mode sand object
types the asset is available with a dropdown in the node header.
To make this per-mode filtering possible, the static asset tree
cache is now unique per context mode.

See #101778

Pull Request: https://projects.blender.org/blender/blender/pulls/109526
2023-08-04 18:22:45 +02:00
Campbell Barton adf58a77ff Cleanup: use LISTBASE_FOREACH & LISTBASE_FOREACH_BACKWARD macros 2023-08-04 08:51:13 +10:00
Hans Goudey bc393c4033 Geometry Nodes: Draw node operator inputs in redo panel
Show node group inputs in the redo panel, including the
"use attribute" toggle. There are a few limitations that will
be solved separately:
- The redo panel is _always_ drawn, there is no way to show it conditionally yet
- There is no way to add the operator name to the redo panel title yet
- Attribute search is still missing for attribute inputs

Pull Request: https://projects.blender.org/blender/blender/pulls/109975
2023-08-03 18:04:36 +02:00
Hans Goudey dc7979a056 Cleanup: Make geometry set naming more consistent
Remove the "_for_read" suffix from methods to get geometry and geometry
components. That should be considered the default, so the suffix just
adds unnecessary text. This is consistent with the attribute API and
various implicit sharing data access methods.

Use "from_mesh" instead of "create_with_mesh". This is consistent with
the recently used naming for the `IndexMask` API.

Pull Request: https://projects.blender.org/blender/blender/pulls/110738
2023-08-03 17:09:18 +02:00
Julian Eisel 268d322e7c BKE: Bump subversion for versioning in previous commit 2023-08-03 17:07:22 +02:00
Julian Eisel 98142f5e35 UI: Asset Shelf Support (Experimental Feature)
No user visible changes expected, except of new experimental feature
option.

------------------------------------------------------------------------------

This introduces asset shelves as a new standard UI element for accessing
assets. Based on the current context (like the active mode and/or tool), they
can provide assets for specific workflows/tasks. As such they are more limited
in functionality than the asset browser, but a lot more efficient for certain
tasks.

The asset shelf is developed as part of the brush assets project (see #101895),
but is also meant to replace the current pose library UI.

Support for asset shelves can quite easily be added to different editor types,
the following commit will add support for the 3D View. If an editor type
supports asset shelves, add-ons can chose to register an asset shelf type for
an editor with just a few lines of Python.

It should be possible to entirely remove `UILayout.asset_view_template()` once
asset shelves are non-experimental.

Some changes are to be expected still, see #107881.

Task: #102879
Brush asset workflow blog post: https://code.blender.org/2022/12/brush-assets-workflow/
Initial technical documentation: https://developer.blender.org/docs/asset_system/user_interface/asset_shelf/

Pull Request: #104831
2023-08-03 16:54:39 +02:00
Ray Molenkamp 4718c084e6 Cleanup: CMake: Modernize bf_extern_curve_fit_nd dependencies
Pretty straightforward

- Remove any curve_fit_nd 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/110762
2023-08-03 16:50:25 +02:00
Clément Foucault 0dc3318ffd EEVEE-Next: Irradiance Bake: Virtual Offset
Implement capture point bias. This offsets the capture
points to reduce the amount bad capture locations (i.e.:
inside objects, near walls etc...).

Two new parameters are added:
- Capture Surface Bias: Ensure a minimum distance between
capture points and surrounding geometry. This is expressed as the
relative distance between two capture point. Requires re-bake
to take effect.
- Capture Escape Bias: Moves capture points enclosed inside
objects above the nearest surface. This bias defines how far a
capture point can be moved for escaping the object. This is
expressed as the relative distance between two capture point.
Requires re-bake to take effect.

This is called virtual offset in the reference material.

A quick prepass runs before the baking to offset the samples away
from any surface that could potentially make bad samples.

In order to speedup the process, we create cluster list of surfels
near each irradiance grid point. This allow access to neighboring
surfels that can contribute to the virtual offset which should
never be more than half a cell wide.

Pull Request: https://projects.blender.org/blender/blender/pulls/110355
2023-08-03 16:47:05 +02:00
Hans Goudey eabff37483 Mesh: Add API functions to assign vertex normals
A few places already calculated vertex normals with better contextual
information to improve performance. To allow changing the storage of
vertex normals more (mostly for improved caching), change some code
from "get normals, set values, clear dirty flag" to "make vertex
normals data, give to mesh". This makes the API less awkward too,
since previously the "get for write" and "clear dirty" calls always
had to be separated.

Pull Request: https://projects.blender.org/blender/blender/pulls/110754
2023-08-03 16:13:04 +02:00
Clément Foucault 8e33b20de9 EEVEE-Next: Irradiance Bake: Add validity based dilation
Implement invalid sample points filling. Improves invalid regions
but introduce light leak.

Grid sample points are considered invalid if they have a ratio of
front-face ray hit under the given threshold. This is a post-processing
pass on the baked lighting that fills dark regions produced by
invalid sample location (e.g.: inside walls) with valid neighbor
samples data.

Two new parameters are added:

- Dilation Threshold: Validity threshold under which grid samples are
considered invalid. Invalid samples will gather valid lighting data
from valid neighbors inside the dilation radius.
- Dilation Radius: Radius of the dilation process. Expressed in grid
sample distance.

The validity of each point is progressively refined just like the
lighting data during the baking process.

The dilation process is implemented as a post-processing pass during
the loading of the grid data into the irradiance atlas. This allows
live tweaking the dilation parameters.

Pull Request: https://projects.blender.org/blender/blender/pulls/110386
2023-08-03 15:48:33 +02:00
Alexander Gavrilov 36c6bcca1a Python API: expose the math mapping vertex positions to B-Bone segments.
Recently a user expressed interest in exporting baked animation
with B-Bone segments. Currently the python API already exposes
segment matrices via a PoseBone method, but there is no access
to the mapping of vertices to the segments.

Although currently the math is simple and easy to re-implement,
forcing Python add-ons to do that would cause a maintenance issue
if the mapping is ever changed later (it's quite dumb, ignoring
the rest pose curve, and there definitely is room for improvement).

This patch extracts the relevant math into a BKE function, and
exposes it in the python API as a new PoseBone method.

Pull Request: https://projects.blender.org/blender/blender/pulls/105419
2023-08-03 14:44:39 +02:00
Guillermo 5b3398a673 Fix #110161: Crash on dragging a Speaker NLA strip
`NLASTRIP_TYPE_TRANSITION` was being used incorrectly as a flag, having
`NLASTRIP_TYPE_TRANSITION=1` and `NLASTRIP_TYPE_SOUND=3` in the enum
`eNlaStrip_Type`, when evaluating `NLASTRIP_TYPE_SOUND &
NLASTRIP_TYPE_TRANSITION` gives a invalid truish value.

Also `strips` that can't be placed were freed, but no removed from the
`strips list`, this will cause a error if the `strip` is at begin
or end of the list.

Pull Request: https://projects.blender.org/blender/blender/pulls/110605
2023-08-03 14:19:49 +02:00
Jacques Lucke 9b54e7cc7f Fix: free nullptr in grease pencil 2023-08-03 13:22:41 +02:00
Campbell Barton 0af370a62d Cleanup: use C++ style sizeof(struct::member) instead of casting nullptr 2023-08-03 20:23:01 +10:00
Amelie Fondevilla 655b2b6c2c GPv3: Delete grease pencil frames
Implementation of the delete frame operator for grease pencil channels.
Changes in the GreasePencil::remove_frame_at function so that it returns a boolean.

Pull Request: https://projects.blender.org/blender/blender/pulls/110746
2023-08-03 11:49:14 +02:00
Campbell Barton de391cf811 Cleanup: use nullptr instead of zero 2023-08-03 19:17:43 +10:00
Campbell Barton c6f3f19648 Cleanup: reduce variable scope when removing in a while loop 2023-08-03 19:17:43 +10:00
Falk David 110ea98ea2 GPv3: Fix missing tag in frames map
In `Layer::remove_frame` there is a case where the frame is not removed,
but overridden by a null-frame. In this case, the frames map was not
tagged, when it should have been.
2023-08-03 11:13:44 +02:00
Falk David 270a229728 Fix: GPv3: Crash on undo when changing frames map
Changing the frames map would lead to a crash later in undo.
This was because the `frames_storage` was not written to file corectly.

When the `frames_storage` was tagged dirty, it recreated the
`frames_storage.num` as well as the `keys` and `values` pointers.
The `keys` and `values` pointers were written after the update, but
since the `num` is just an `int` in the embeded struct, it was written
before being updated. This lead to an out-of-sync state and later
to the crash.

The fix makes sure we write the struct *after* updating it.
2023-08-03 11:13:44 +02:00
Campbell Barton 8c8ff6b85b Cleanup: spelling in comments, use C-style comments 2023-08-03 09:44:28 +10:00
Hans Goudey 8bb8cfb54e Cleanup: Remove unnecessary struct keyword from C++ headers
Pull Request: https://projects.blender.org/blender/blender/pulls/110734
2023-08-03 01:11:28 +02:00
Hans Goudey 731d296f35 Cleanup: Move mesh related blenkernel headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110730
2023-08-02 22:14:18 +02:00
Bastien Montagne 4f673f18af Move `BKE_lib_override.h` header to be fully C++.
This implies using the `.hh` extension, and removing the `extern "C"`
blocks from it.

Pull Request: https://projects.blender.org/blender/blender/pulls/110718
2023-08-02 17:44:37 +02:00
Falk David 873453005d Fix: GPv3 not rendering when origin is out of view
This was because the `ob->runtime.geometry_set_eval` was populated
with the new `GreasePencilComponent` but
`GeometrySet::compute_boundbox_without_instances()` did not compute
the bounding box of the grease pencil geometry.
Thus the bounding box was not correctly set and the object not
correctly rendered.
2023-08-02 17:36:38 +02:00
Falk David 331969159e Fix: Unreported memory leak
Whenever `grow_array` in
`blender/source/blender/blenkernel/intern/grease_pencil.cc` was called,
it would not free the original array after relocating the data to the
newly allocated memory. This fixes the memory leak.
2023-08-02 15:52:21 +02:00
Amelie Fondevilla fd75695bed GPv3: Insert grease pencil keyframe from the dopesheet
Adaptation of the operator `ACTION_OT_keyframe_insert` to take into account grease pencil channels.
Grease pencil keyframes can now be inserted in blank mode, or in additive mode (duplicate the current frame in the new keyframe).

Two API functions were added :
 * `add_duplicate_drawings` which copies the data of a drawing to creates a duplicate, and
 * `insert_duplicate_frame` which creates a duplicate frame of an existing one either by copy or instance.

The additive mode option is also added to the UI.

The Layer method `frame_key_at` previously private was set to public.

Pull Request: https://projects.blender.org/blender/blender/pulls/110649
2023-08-02 14:56:18 +02:00
Hans Goudey 4309c32be6 Mesh: Replace older flip faces utilities
Replace `BKE_mesh_face_flip_ex()` with `bke::mesh_flip_faces()`.
This gives better performance since it avoids custom data name
lookups for every face index, and processes data in a more cache
friendly way. Also remove the `CustomData_swap` API function
as mentioned in 09b6eac5c4.

Flipping 16 million faces, I observed a 3.25x speedup, from 760 to 230 ms.

Pull Request: https://projects.blender.org/blender/blender/pulls/110702
2023-08-02 14:15:27 +02:00
Falk David b2f61b5c8a GPv3: Replace `int` with `FramesMapKey`
This adds the `FramesMapKey` alias to the `blender::bke::greasepencil` namespace.

Pull Request: https://projects.blender.org/blender/blender/pulls/110714
2023-08-02 14:02:23 +02:00
Hans Goudey 29a338811c Fix #110411: Mesh loop cut preview uses final instead of cage positions
Caused by 91b27ab637, which caused the final position
arrays to be returned in more situations (in this case, when the final
result is a non-wrapper mesh). Instead, use the cage mesh, which
is more correct anyway-- it just wasn't always available before.
2023-08-01 21:36:26 -04:00
Hans Goudey 620a5ebe4a Mesh: Parallelize edit selection and visibility interpolation
Each of the four algorithms is different, and not all of them will
parallelize linearly, but for large meshes these "flushing" operations
begin to become noticeable compared to other multithreaded code.
For example, flushing visibility to vertices and edges after a change
to faces became 3.75x faster, from 90 to 24 ms.

Also avoid duplicating selection interpolation logic, use the attribute
API instead.
2023-08-01 20:51:11 -04:00
Hans Goudey b54bca9f08 Cleanup: Reduce indentation in pbvh clipping 2023-08-01 18:19:13 -04:00
Hans Goudey 8104d6e95c Cleanup: Simplify some parallel iteration over PBVH nodes
Use `parallel_for` instead of the older task API. A lot of sculpt code
still uses `SculptThreadedTaskData`, so this is just a start.
2023-08-01 18:14:43 -04:00
Hans Goudey 02e0d7717b Cleanup: Remove unused variable in pbvh draw code 2023-08-01 17:30:10 -04:00
Hans Goudey 40de15d521 Mesh: Move flip faces function to blenkernel
The aim is to replace the `BKE_mesh_faces_flip` functions with
this newer C++ function using the attribute API. But that is must
be called by RNA, so move this to blenkernel to avoid a circular
dependency between the geometry module and RNA.
2023-08-01 13:08:59 -04:00
Falk David 162fc23887 GPv3: Use `add_new` and `remove_contained` in core
Instead of the default `add` and `remove` functions for the frames map,
use `add_new` and `remove_contained` for when it is known that a value
is or isn't in the map already. This should be slightly more efficient
(and just better practice overall).
2023-08-01 17:56:20 +02:00
Falk David de8ce4e34b GPv3: Add user count to drawings
Adds a user count to drawings to track how many frames use the drawing.
If the user count hits `0` the drawing should be deleted.

Also adds a function to delete a frame in a layer. This will
decrement the user count of the drawing and delete it if there are no
users left. This is consistent with the way GPv2 worked.

Pull Request: https://projects.blender.org/blender/blender/pulls/110579
2023-08-01 17:04:39 +02:00
Ray Molenkamp b4e4030bd6 Cleanup: Format 2023-08-01 08:46:26 -06:00
Sergey Sharybin fddcbf2d40 Fix missing subversion bump in the previous commit
Pull Request: https://projects.blender.org/blender/blender/pulls/110687
2023-08-01 15:02:27 +02:00
Sergey Sharybin 0a964cf0e1 Color management: Improve non-color managed versioning
Support configurations where there is no dedicated None display
and try to use Raw view of the default display.

This allows to preserve compatibility with old files and the new
upcoming AgX configuration.

Ref #110685

Pull Request: https://projects.blender.org/blender/blender/pulls/110581
2023-08-01 14:58:19 +02:00
Sergey Sharybin 63e2832057 Color management: Remove old name-based exceptions
Historically, the OCIO based color management implementation in Blender
had exceptions to treat specific configurations differently. It was a
compatibility with the legacy "No color management" option.

With time and more development in the area there are better ways of
achieving this goal, if needed.

This commit removes the named-based exception, which also solves confusion
about why certain similar configurations (from OCIO stand point) give
different results. As well as allows to create a cleaner plate for an
upcoming additions in the OCIO configuration such as AgX.

Quite simple and technical change which constant-folds the check for
whether the scene color management enabled or not with "true" value.

Ref #110685

Pull Request: https://projects.blender.org/blender/blender/pulls/110580
2023-08-01 14:39:29 +02:00
Jacques Lucke 09b6eac5c4 Fix #110471: Normal Edit modifier screws up UVs
The issue was that `CustomData_swap` modifies all layers, but does not ensure
that the layers are actually mutable. This resulted in it modifying shared layers.
Now it ensures that the layers are mutable first (which copies the layers if they
are shared).

Longer term, it would be good to remove `CustomData_swap` since it's not a
good API performance wise, but that is outside of the scope of this patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/110678
2023-08-01 14:27:16 +02:00
Falk David 8df5968603 GPv3: Add `remove_frame` function to layers
This core function removes a frame at a specific `start_frame_number`.
It also handles both implicit holds and fixed duration frames.

Pull Request: https://projects.blender.org/blender/blender/pulls/110679
2023-08-01 14:09:12 +02:00