Commit Graph

26196 Commits

Author SHA1 Message Date
Falk David 8512a608a4 GPv3: Onion Skinning
Implements the GPv2 onion skinning functionality.

There are no functional changes exept for the `use_ghosts_always`
option, which has been removed. This was used to show onion
skinning in the final render.

Pull Request: https://projects.blender.org/blender/blender/pulls/119792
2024-04-03 15:34:40 +02:00
Hans Goudey 4bdf5bf2e2 Mesh: Remove unnecessary wrapper_type_finalize logic
After some discussions and investigation over the last couple months,
it's not clear what the "wrapper type finalize" logic is necessary for.
For edit meshes and regular meshes, normals are calculated lazily when
building the draw cache.

Apart from the unnecessary complication for mesh GPU draw data
extraction, this code also causes normals to always be calculated
when turning an edit mesh wrapper into a regular mesh. However, those
normals are immediately discarded since the edit deform cache is deleted
in the next line.

Beyond the obvious simplification, the motivation for this change is to
avoid requesting write access on the evaluated mesh and cage mesh. This
works better with implicit sharing, allowing other improvements.

Pull Request: https://projects.blender.org/blender/blender/pulls/120066
2024-04-03 14:15:31 +02:00
Hans Goudey e7339bdd5f Geometry: Use implicit sharing for deformed positions
Avoid copying the positions array into the evaluated edit hints array
that's used to support editing with deformed positions when there is
a topology-changing procedural operation. In a simple test in sculpt
mode with 706k curve points, memory usage went from 78 to 70 MB.

This adds more duplication would be ideal, mainly because retrieving
the data with write access and making implicit sharing info for arbitrary
arrays aren't abstracted by implicit sharing utilities. It may be possible
to improve both of those aspects, either now or in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/120146
2024-04-03 14:14:34 +02:00
Falk David 50f5128be0 Fix: GPv3: Crash converting vertex groups
A grease pencil test file
(can be found here: https://cloud.blender.org/p/gallery/5d9c6ee20f9018baaca071c3)
was crashing when converting to GPv3.
The index of a deform weight group was out of bounds.
We will have to investgate how this can happen, but
in the conversion code it seems best to ignore and skip over
invalid indices.

Pull Request: https://projects.blender.org/blender/blender/pulls/120170
2024-04-03 11:40:10 +02:00
Jacques Lucke e2d170f685 Libraries: integrate xxHash library for fast hashing
`xxHash` is a fast non-cryptographic hashing library. It significantly outperforms
md5 which we use in some places currently while also having great collision
resistance if not attacked explicitly.

The library is added to `extern` because that was the easiest way to do it and has
the least impact on others. I expect this library to become a required dependency
instead of an optional one. It's licence is `BSD 2-Clause` which seems to be the
first of its kind in Blender (there is `BSD 3-Clause` a couple of times).

For now, I used the library only for data deduplication when baking geometry nodes
where the same geometry is generated for each frame. The bake time in my test
goes down from >6s to <1s (note that this includes more than just the hashing time).

Pull Request: https://projects.blender.org/blender/blender/pulls/120139
2024-04-03 10:22:53 +02:00
alxdsptr eca8e5d4b3 Fix: Video alignment issue caused by fix for #120077
after alignment, the rgb_frame's linesize is not equal to the actual
data length, so when copying the data generated from render to the
rgb_frame, they should use different linesize, one after alignment
and one before alignment.

Pull Request: https://projects.blender.org/blender/blender/pulls/120184
2024-04-03 05:56:56 +02:00
Campbell Barton b03332a055 Cleanup: use BLI_assert_msg instead of checking string literals 2024-04-03 14:27:54 +11:00
Campbell Barton cbd6266162 Cleanup: simplify init_meta logic
- Remove redundant loop on meta-elements.
- Use continue to reduce nested blocks.
- Move zero-axis matrix check into a function.
2024-04-03 14:07:04 +11:00
Hans Goudey 820865bacf Cleanup: Improve EditMeshData comments 2024-04-02 21:11:34 -04:00
Sean Kim 06f04a2c19 Refactor: Use blender::Array for SubdivCCGNeighbors
To avoid requiring callers to remember to free the allocated data.

Pull Request: https://projects.blender.org/blender/blender/pulls/120194
2024-04-03 02:37:45 +02:00
Campbell Barton d5d1025e94 Cleanup: use const pointer arguments 2024-04-03 10:22:05 +11:00
Hans Goudey 5b9ed4258b Cleanup: Access edit mesh caches with span return values
Instead of accessing the data directly from the cache struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/120191
2024-04-03 00:36:29 +02:00
Hans Goudey e29d582137 Cleanup: Use C++ Span, float3 in legacy instancing code 2024-04-02 18:03:49 -04:00
Hans Goudey a4b4f0116c Cleanup: Use C++ Span, float3 for BMesh normals API 2024-04-02 18:03:49 -04:00
Hans Goudey d001302200 Fix #117709: Crash with single point NURBS curve
The root of the issue seems to be calling `BLI_snprintf` with the
wrong number of arguments in the `MorePointsForBezierRequired`
case. The fix arguably makes things simpler anyway: just use a
separate call in each case of the switch.
2024-04-02 17:44:49 -04:00
Hans Goudey bf2b684913 Cleanup: Remove unused variable after recent cleanup 2024-04-02 17:41:27 -04:00
Iliya Katueshenock 3f3df16ba2 Cleanup: Mesh calculate edges file cleanup
Trivial changes of code:
1. Const correctness.
2. Arguments order.
3. Use regular constructor instead of aggregate one.
4. Replace stateful iterators of corners by `bke::mesh` functions.
5. Offset Indices instead of manual prefix sum.
6. Slight changes of iterator names which is affected by cleanup.
7. Cpp allocator.
8. Explicit template parameter.

Pull Request: https://projects.blender.org/blender/blender/pulls/120189
2024-04-02 22:48:58 +02:00
Hans Goudey 89d38cf008 Cleanup: Use ImplicitSharingInfo type instead of C handle 2024-04-02 16:40:33 -04:00
Falk David 45a0b6cc1a Cleanup: GPv3: Use `const` in a few places 2024-04-02 16:40:00 +02:00
Jacques Lucke 7400927ada Fix #120084: custom group node remains undefined after registering node type 2024-04-02 16:07:48 +02:00
Aras Pranckevicius 19ce05971d Fix #120077: Video output artifacts due to threaded YUV conversion
ffmpeg AVFrame objects should use correct alignment between image
rows, or otherwise bad things might happen. In this particular
case, multi-threaded libswscale RGB->YUV conversion was trampling
over 4 bytes of V plane, for each thread boundary.

Pull Request: https://projects.blender.org/blender/blender/pulls/120168
2024-04-02 13:03:05 +02:00
Campbell Barton 16a1c2e33f Fix error copying a grease pencil strokes fill opacity
The destination value was set to itself.
2024-04-02 17:44:30 +11:00
Hans Goudey 32fc3c0c1c Fix: Resolve over-allocation for mesh tangents
For some reason, the custom data type was set as `float[4][4]`
for tangents, but they are written as `float[4]`. The overallocation
might not have been a problem, since it looks like the extra memory
was never written to. But it's still confusing and potentially bad for
performance.
2024-04-01 13:38:06 -04:00
Hans Goudey f0d7a05fc4 Fix #120065: Mesh tangent draw extraction crash
Since the code was added, it used the active indices of the input and
output custom data layers incorrectly. 82b88f130a exposed that
by actually modifying the active indices of the ouput custom data
correctly, but it didn't update a couple other places to take that into
account.
2024-04-01 10:48:43 -04:00
Campbell Barton 7e5a712e58 Cleanup: remove redundant null pointer checks
Based on the surrounding context these checks aren't needed.
2024-04-01 22:20:09 +11:00
Campbell Barton ace64dbf50 Fix potential null pointer de-reference
Refactoring &
2024-04-01 22:20:09 +11:00
Campbell Barton 04b6fe78e7 Fix integer truncation when calculating int64_t values
Large int64_t values were calculated and assigned int however the
calculation was performed on integer types which would truncate the
result before casting to an in64_t.
2024-04-01 22:19:36 +11:00
Campbell Barton 2be407fc82 Cleanup: spelling in comments 2024-04-01 16:47:57 +11:00
Lukas Tönne d7c718dfd4 GPv3: Texture offset modifier
Port of the GPv2 texture modifier for transforming UVs of stroke points.

Pull Request: https://projects.blender.org/blender/blender/pulls/119050
2024-03-29 21:42:30 +01:00
Hans Goudey 8dbee79844 Fix: Debug build error after recent commit 2024-03-29 10:51:54 -04:00
Hans Goudey a78d4f31be Cleanup: Add detail to sculpt mesh variable name
Generally sculpt uses a combination of data from the original,
deformed, and final evaluated meshes. Keeping track of all that
is confusing and using a more specific variable name helps a bit.
2024-03-29 10:05:05 -04:00
Sergey Sharybin d174959759 Fix #120051: Crash when using shrinkwrap with Target Normal Project
The issue was introduced by b35831ad6c.

Since that commit `tree->boundary` will always be non-nullptr, even
when the target mesh had no boundaries. Some code was still relying
on the fact that `tree->boundary != nullptr` means the mesh has
boundary.

Update shrinkwrap code for this fact, avoiding access past array
boundaries.

Pull Request: https://projects.blender.org/blender/blender/pulls/120054
2024-03-29 11:43:15 +01:00
Campbell Barton 3d2593b229 Cleanup: replace "derived mesh" with "evaluated mesh" in code comments
References to the evaluated mesh were referring to "derived mesh"
when DerivedMesh wasn't used.
2024-03-29 13:29:30 +11:00
Hans Goudey ce9970c76b Cleanup: Remove duplicate function for copying edit mesh positions 2024-03-28 21:43:32 -04:00
Campbell Barton 01dceb6b89 Cleanup: remove redundant checks for known states 2024-03-29 10:30:42 +11:00
Hans Goudey 82b88f130a Cleanup: Use const for evaluated cage meshes and related data
Also access the evaluated deform mesh with a function rather than
directly from object runtime data. The goal is to make it easier to use
implicit sharing for these meshes and to improve overall const
correctness.
2024-03-28 18:57:57 -04:00
Hans Goudey 931206d3dc Cleanup: Rename mesh face deformed edit position variables
Use standard naming similar to their `Mesh` counterparts.
2024-03-28 18:28:35 -04:00
Hans Goudey 72347f11fe Cleanup: Use float3, Span, Array for vertex positions 2024-03-28 18:28:35 -04:00
Hans Goudey 684dbba6a1 Fix #119969: Crash rendering in sculpt mode with multires active
SubdvigCCG is null for the evaluated mesh in the render depsgraph
because of the `!for_render` check in `MOD_multires.cc`. But the PBVH
type is still `PBVH_GRIDS`. That's a weird inconsistency that ideally
wouldn't happen, but probably isn't simple to change. The simplest and
most obviously harmless fix is to just check whether the list of PBVH
nodes to update is empty.
2024-03-28 15:11:02 -04:00
Hans Goudey 0b80d5e755 Cleanup: Access sharp_face attribute with attribute API 2024-03-28 14:45:56 -04:00
Hans Goudey a5c5cf473e Fix #119992: Object transform ignored for shrinkwrap and flat shading
the transform was always ignored for face normals since b4b224dc08.
2024-03-28 13:43:20 -04:00
Falk David 8b7d5f8587 GPv3: Simplify Modifier
Implements the GPv2 simplify modifier.

Pull Request: https://projects.blender.org/blender/blender/pulls/120018
2024-03-28 18:16:14 +01:00
Christoph Lendenfeld 6276dd2f64 Fix #119946: NLA stack decomposition doesn't work with bones
The issue was that the `PointerRNA` passed to `BKE_animsys_get_nla_keyframing_context`
needs to point to an `ID` which wasn't the case when keying bones.
That is because internally the `FCurve` path is used to resolve the property.
This can only work from the `ID` because the `FCurve` path is always stored relative to that.
While the function doesn't fail when the property can't resolve the path, it won't actually do
the remapping when passing it to `BKE_animsys_nla_remap_keyframe_values` later.

Pull Request: https://projects.blender.org/blender/blender/pulls/120008
2024-03-28 15:14:01 +01:00
Bastien Montagne 71fd693d22 GPv3: Conversion: Add some support for GPData animation itself
Handling animation of GPv3 in itself is relatively straightforward, it's
mainly a matter of duplicating animdata into the new GreasePencil ID.

In case some propoerties need to be remapped, this will be done in a
similar way as e.g. GP object's modifiers animation for Object-level
animation.

The complex and ugly part of this PR is in the need to move animation
from GPdata to Object level for some properties. This PR tackles the
'layer adjustments to modifiers' aspect (i.e. adjustments on tint and
thickness).

Known limitations currently with these GPData to Object animation:
* NLA is not supported (i.e. if an NLA in legacy GP data controls these
  adjustments animations, it won't be converted to Object-level NLA to
  control matching modifiers settings).
* Drivers targets are not handled either, i.e. in case a driver is using
  data from legacy GPdata as input, these will be left as-is (this is
  true for all anim handling currently).
* There is no adjustments of values for animation (e.g. the thickness
  adjustment values would need to be devided by 2000).

Most of these limitations can be addressed at some point, depending on
how critical they are to support. This would have a cost (in time and
code complexity) though.

Pull Request: https://projects.blender.org/blender/blender/pulls/119214
2024-03-28 13:52:21 +01:00
Campbell Barton 686605a6dd Cleanup: declare arrays as const where possible 2024-03-28 22:57:57 +11:00
Campbell Barton b2e00d1285 Cleanup: use const pointer arguments 2024-03-28 20:57:50 +11:00
Campbell Barton 5685481fcb Cleanup: rename "name" to "filepath" for full paths 2024-03-28 20:57:50 +11:00
Philipp Oeser 7da9521c7c Fix #119925: Mask property keyframes missing when reload the file
Caused by 6a79a6a24a

`Mask` `AnimData` is read by `BKE_animdata_blend_read_data` since above
commit, so `BLO_read_data_address` on `AnimData` is already done there.
However, `mask_blend_read_data` does it again
Similar calls to `BLO_read_data_address` in `blend_read_data` callbacks
were usually removed in 6a79a6a24a, Masks being an exception.

Accoding to @mont29 the reason while a double remapping will fail is
because there can only be one remapping from old addresses to new ones.
Once the new address has been read, this new address cannot be used as
'key' again (it will likely map to nothing, or worse, remap to something
completely unrelated!)

Pull Request: https://projects.blender.org/blender/blender/pulls/119961
2024-03-28 10:50:14 +01:00
Bastien Montagne 4e650294e2 Fix #119184: Crash due to extremely broken liboverrides.
The validation code (`BKE_lib_override_library_main_validate` & co)
would not properly handle some extreme cases of data corruptions well.
2024-03-28 13:39:51 +09:00
Harley Acheson 27c95da888 Refactor: Remove BLF _ex functions using default arguments
Remove all BLF "_ex" versions of functions by using default arguments.
These functions only differ by having an optional argument that can
return extra details about the result of the operation. This PR just
make these part of the main function as optional arguments with default
values - all nullptr.

Pull Request: https://projects.blender.org/blender/blender/pulls/119994
2024-03-28 04:02:13 +01:00