Commit Graph

26208 Commits

Author SHA1 Message Date
Hans Goudey 7ba8fc1768 Fix: Duplicate auto smooth modifier added by versioning in one case
When an object uses linked mesh data and the object and the modifier
node group are made local after versioning runs for the first time,
a new modifier is added every time the file is opened. An obvious
fix is to check whether there is already a modifier with the versioning
node group. In that case we can skip the object.

This doesn't fully fix the scenario from #120030; it requires that
the node group is made local so it doesn't leave a reference to
a non-existent library data-block.
2024-04-04 11:57:27 -04:00
YimingWu 11556bb994 Fix #120152: Clear mesh runtime after validation
The cache for triangles and other runtime caches could
be out of date after `mesh.validate()` is called.

Pull Request: https://projects.blender.org/blender/blender/pulls/120159
2024-04-04 17:21:21 +02:00
Christoph Lendenfeld ed2408400d Fix #117927: Limit rotation constraint flipping
The issue from the bug report mentions that the `Limit Rotation` constraint snaps
back to 0 when reaching 180 degrees with a min and max of 0 / 180.

The root cause of this goes a bit deeper though. Because the following also snaps back to 0.
* min max of 0 / 360
* angle of 185

The reason for this is that the clamping logic in the constraint was very simple.
It just took the matrix, decomposed it to euler and clamped the values directly.
However in that process, the euler angles are bound to a range of -180 / 180,
which means that any angle >= 180 would snap back to the min.

Pull Request: https://projects.blender.org/blender/blender/pulls/118502
2024-04-04 16:30:51 +02:00
YimingWu 022e46a7e2 Fix #120213: GPv3: Tint modifier not working correctly
The GPv3 tint modifier will give incorrect result in fill tint due to
two reasons: 1) The material index being wrong; 2) The default value
for `fill_color` attribute needs to be explicitly assigned as
`ColorGeometry4f(float4(0.0f))` to ensure correct color mixing and
switching between fill/material color in the tint modifier.

Pull Request: https://projects.blender.org/blender/blender/pulls/120249
2024-04-04 15:08:10 +02:00
Omar Emara b0bebd6265 Fix #119911: Compositor saved in 4.2 does not work in 4.1
Blend files with compositor node trees saves in 4.2 do not work in older
version. This is because 4.2 removed the chunk size property of the node
tree, so it is set to zero, which is invalid in older versions. To fix
this, we add it again as a deprecated DNA member, and set it to default
value upon write.

Pull Request: https://projects.blender.org/blender/blender/pulls/120246
2024-04-04 13:14:10 +02:00
Campbell Barton 7e9f7320e4 Cleanup: spelling in comments & comment blocks 2024-04-04 11:26:28 +11:00
Campbell Barton 61bd22e99b Cleanup: avoid duplicating UVBorder on iteration
Iterating over UVBorder duplicated it's allocated vector each iteration.
Use a const reference instead.
2024-04-04 10:55:22 +11:00
Campbell Barton cc4b5facb8 Cleanup: order index range checks before using them to index arrays
While these particular cases didn't cause out-of-bounds array access,
it's reads like it could be an oversight.
2024-04-04 10:55:16 +11:00
Campbell Barton a7439dd7ef Cleanup: clear a pointer to stack memory in what_does_obaction
Don't leave `workob->adt` set to a stack memory,
avoid the same error occurring which !118847 addressed.
2024-04-04 10:55:14 +11:00
Campbell Barton fdaaebce54 Cleanup: remove unnecessary checks & unused assignments 2024-04-04 10:55:13 +11:00
Campbell Barton 52ce8d408f Cleanup: use const arguments & variables 2024-04-04 10:55:10 +11:00
Falk David 85ce2a34e3 Fix #120212: GPv3: Hide masks flag wrongly set
This was caused by ab84f9eaf0.

The issue is that setting the flag in the `TreeNode`
constructor means that the root group will always
hide masks when its created. This effectively disables
masks in the entire object.

Instead, leave the default flag to be `0` (masks enabled)
and explicitly set the `HIDE_MASKS` flag when
creating a new layer/layer group.

Pull Request: https://projects.blender.org/blender/blender/pulls/120218
2024-04-03 17:59:30 +02:00
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