Commit Graph

112277 Commits

Author SHA1 Message Date
Hans Goudey
ae8ecd6e4e Cleanup: Remove unused variables 2024-08-15 00:00:44 -04:00
Hans Goudey
0c0a9d7714 Cleanup: Remove unused variables 2024-08-14 23:58:07 -04:00
Hans Goudey
9a776830a6 Refactor: Sculpt: Reduce usage of BVH tree positions array
In preparation for removing the positions array from the BVH tree
and just retrieving the evaluated or original positions as necessary.
2024-08-14 23:27:20 -04:00
Hans Goudey
bd19212fb8 Refactor: Sculpt: Avoid BVH tree geometry pointers in normals update
Part of #118145.
There is some complexity in this area because the normals need to be
updated on the original geometry only when there is no deformation
or multires modifier. The simplest way to encapsulate that usage of
the original geometry for now was adding a separate function that
contains the lookup with a comment justifying it.
2024-08-14 23:19:39 -04:00
Hans Goudey
0abf1b32b2 Refactor: Sculpt: Specialize face set fair selection filtering
Part of #118145.
2024-08-14 23:19:39 -04:00
Hans Goudey
561d035da4 Cleanup: Follow class layout style guide for SculptSession 2024-08-14 23:19:39 -04:00
Sean Kim
a0e6e16da5 Refactor: Various changes to SCULPT_OT_mask_by_color
* Removes usage of `PBVHVertRef` in favor of `int` since the operator
  only works on Mesh
* Removes calls to Multires and BMesh code that have no effect
* Inline floodfill algorithm

Pull Request: https://projects.blender.org/blender/blender/pulls/126258
2024-08-15 04:52:12 +02:00
Sean Kim
712d322335 Refactor: Sculpt: Add automask factor raw pointer overload
The automask cache is not guaranteed to exist for a given tool type,
instead of forcing developers to remember to guard the dereference with
a null check, this commit adds an inline overload that performs the
check for the user on a raw pointer. The API takes in pointers instead
of smart pointers as this method is not intended to take ownership of
the pointer into consideration.

Pull Request: https://projects.blender.org/blender/blender/pulls/126346
2024-08-15 04:47:24 +02:00
Hans Goudey
73e1fa181e Cleanup: Formatting 2024-08-14 21:10:04 -04:00
Hans Goudey
6703927a05 Refactor: Sculpt: Retrieve positions instead of using BVH tree reference
Part of #118145.
2024-08-14 21:10:04 -04:00
Sean Kim
a3a0a848a8 Fix #126330: Crash when using Color Filter
Pull Request: https://projects.blender.org/blender/blender/pulls/126332
2024-08-15 01:33:48 +02:00
Richard Antalik
717b8c08f3 Fix #125401: Crash when enabling prefetching
Prefetching thread attempted to render scene strip inside of meta strip,
because `channels` argument was incorrectly set to top-level channels.

Pull Request: https://projects.blender.org/blender/blender/pulls/126092
2024-08-14 22:36:11 +02:00
Hans Goudey
27bc773c0b Cleanup: Formatting 2024-08-14 14:20:43 -04:00
Hans Goudey
e04707bf2a Cleanup: Sculpt: Remove last usage of PBVHVertRef visibility function
Pat of #118145.
2024-08-14 14:10:32 -04:00
Hans Goudey
70a24258c6 Sculpt: Remove unused positions array copy with some deform modifiers
Last usage was removed in 0250596f5b.
2024-08-14 14:10:32 -04:00
Sean Kim
e7787f24aa Refactor: Simplify boundary::preview_data_init parameters
* Since displaying this information will only ever happen based on the
  active vert, remove the parameter and fetch it inside the function
* Remove the `PBVHVertRef` usage in favor of `ActiveVert`

Pull Request: https://projects.blender.org/blender/blender/pulls/126256
2024-08-14 19:35:03 +02:00
Hans Goudey
93054f9a0e Refactor: Sculpt: Move original position restore to brush deform step
Instead of running a separate loop before processing the brush
deformation, undo the translations from the previous brush steps
when applying the translation. Avoiding this separate loop over
all geometry should improve performance.
2024-08-14 11:53:16 -04:00
Hans Goudey
658b32093a Refactor: Sculpt: Replace sculpt attribute system for dynamic topology data
Part of #118145.
Use the BMesh functions instead of the sculpt attribute API which we
intend to remove.
2024-08-14 10:25:52 -04:00
Hans Goudey
d065d54972 Fix: Missing sculpt overlays for dynamic topology
Caused by 9eb7e8bfd1.
2024-08-14 10:24:16 -04:00
Hans Goudey
e612260f5c Refactor: Sculpt: Replace sculpt attribute system for persistent base data
Part of #118145.
Use the mesh attribute API instead of the sculpt attribute API which we
intend to remove.
2024-08-14 10:13:37 -04:00
Aras Pranckevicius
df00c30fcd Fix #126201: Video artifacts when rendering into ffmpeg with PNG codec
Started happening with 422dd9404f that introduced multi-threaded
conversions of src->dst (usually RGBA->YUV) format before encoding
the frame with ffmpeg. But the issue itself is not related to
multi-threading, but rather with the fact that AVFrame objects
started to be backed by an AVBuffer object (as that is needed for
threaded swscale to work).

Turns out, if a frame is backed by AVBuffer object, said buffer
might become "non writable" because it got shared (non-1 refcount).
And that happens with some ffmpeg video codecs, particularly PNG one.

Make sure to make the AVFrame objects writable inside
generate_video_frame. This follows official ffmpeg example
(doc/examples/encode_video.c) that explains why that is needed:

"the codec may have kept a reference to the frame in its internal
structures, that makes the frame unwritable. av_frame_make_writable()
checks that and allocates a new buffer for the frame only if necessary"

Pull Request: https://projects.blender.org/blender/blender/pulls/126317
2024-08-14 16:07:11 +02:00
Hans Goudey
7d08d6be6a Fix #126013: Geometry nodes PLY import node skips attributes
Just turn on the option for geometry nodes where attributes are
generally expected to be used. We could expose this and other
options at some point too but that requires a bit more thought.
2024-08-14 08:43:06 -04:00
Omar Emara
075bdbcd63 Nodes: Improve isotropic Gabor noise UI controls
This patch improves the isotropic Gabor noise UI controls such that
variations happen in both directions of the base orientation, as opposed
to being biased in the positive direction only.

Thanks to Charlie Jolly for suggesting this improvement.
2024-08-14 15:26:03 +03:00
Omar Emara
ce89d7949c Nodes: Optimize Gabor noise variance estimation
This patch optimizes the Gabor noise standard deviation estimation by
computing the upper limit of the integral as the frequency approaches
infinity, since the integral is mostly constant for the relevant
frequency range. The limits are 0.25 for the 2D case and 1 / 4 * sqrt2
for the 3D case.

This also improves normalization for low frequencies, possibly due to
the effect of windowing.

Thanks to Charlie Jolly for spotting the optimization.
2024-08-14 14:27:23 +03:00
Sergey Sharybin
1fc6a5b9bd Fix #126108: Crash when EXR image is loaded in image list
Technically the regression was caused by #124472 which made it so
duplicating ImBuf allocates the exact amount of memory needed to
hold the pixels, while before IMB_dupImBuf() would leave the float
buffer over-allocated for images that are less than 4 channels per
pixel.

At the same time IMB_scalefastImBuf() was hard-coded to use 4
channels per pixels, for both byte and float buffers. It did not
crash in Blender 4.1 as it was accessing memory that is over-allocated,
but it also did not generate proper preview.

This fix makes the IMB_scalefastImBuf() to operate on an arbitrary
number of channels in the float buffer.

Pull Request: https://projects.blender.org/blender/blender/pulls/126234
2024-08-14 11:34:29 +02:00
Omar Emara
847a3a7ea3 Nodes: Optimize Gabor noise with early exit
Optimize the Gabor noise texture code with an early exit for points that
are further away from the kernel center. This was already done for the
kernel, but is now being done earlier before computing the weight, so
its computation is now skipped.

Thanks to Charlie Jolly for the suggestion.
2024-08-14 12:12:34 +03:00
Pratik Borhade
8ccf6036e6 Fix: Declaration warning after 7bfdc6dfea 2024-08-14 14:34:55 +05:30
Pratik Borhade
7bfdc6dfea GPv3: Invert weight operator
Port gp legacy "invert weight" operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/126275
2024-08-14 08:55:24 +02:00
Omar Emara
94d3b764e7 Geometry Nodes: Implement Gabor noise node
This patch ports the Gabor noise shader texture node into Geometry
Nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/125718
2024-08-14 08:48:17 +02:00
Omar Emara
8504ab2070 Fix: Compile error when FFTW is disabled 2024-08-14 09:22:33 +03:00
YimingWu
fec8591464 Fix #126278: Missing finish() call joining .sculpt_face_set
In `mesh_join_offset_face_sets_ID()`, `.sculpt_face_set` is
modified but the `finish()` call wasn't present on the
`SpanAttributeWriter`, leading to warnings and potentially broken
data. This is now fixed.
2024-08-14 11:34:19 +08:00
Sean Kim
63bc8997a0 Fix #126199: Various brushes deform base mesh on non-basis shape key
When restoring the orig_position values for certain brushes, we need to
apply similar logic and avoid updating the base mesh if we are sculpting
on a non-basis shape key.

Pull Request: https://projects.blender.org/blender/blender/pulls/126305
2024-08-14 02:53:47 +02:00
Hans Goudey
2af62ba0f6 Refactor: Sculpt: Reduce usage of BVH tree geometry back pointers
Similar to 9eb7e8bfd1
Pass the object instead of retrieving geometry data from the BVH tree.
2024-08-13 19:01:15 -04:00
Hans Goudey
1661f0728f Cleanup: Remove usage of BKE_pbvh_get_mesh
Part of #118145.
This acts as a back pointer, allowing code that looks like it just deals with
the sculpt BVH tree to do basically anything.
2024-08-13 19:01:15 -04:00
Hans Goudey
c1bb5c03fe Cleanup: Sculpt: Remove now unused parts of automasking API
Part of #118145.
2024-08-13 19:01:15 -04:00
Harley Acheson
8f996f1786 UI: Simplified Feedback for Docking
This simplifies the feedback shown while using the "Interactive Editor
Docking" experimental feature.  It removes the "X" icon shown on areas
that are removed. It does not show an icon for the areas that are left
over and altered. It only shows an icon for the active target area, and
does so without the outline of the icon. The result is a calmer
experience and it is easier to see exactly where the area is going.

Pull Request: https://projects.blender.org/blender/blender/pulls/126304
2024-08-14 00:21:39 +02:00
Sean Kim
58e55ef023 Fix #126293: Crash when moving mouse after enabling Dyntopo
Introduced in 45d9bfa734

We currently do not invalidate the `active_vert` variable when changing
between different mesh implementations. Therefore, it is incorrect to
assume the value can be turned into a valid concrete reference simply
based on the PBVH type.

Pull Request: https://projects.blender.org/blender/blender/pulls/126299
2024-08-13 21:38:13 +02:00
Sean Kim
f7d94d3e73 Fix #126252: Polyline target circle changes color randomly
When the operator was introduced, the program specified the immediate
mode program GPU_SHADER_3D_UNIFORM_COLOR but did not bind a particular
value. This leads to the color used for this circle changing depending
on the last color bound when drawing.

This change makes the color of the circle white, as initially intended,
and adds a darker outline to improve readability.

Pull Request: https://projects.blender.org/blender/blender/pulls/126259
2024-08-13 21:24:27 +02:00
Iliya Katueshenock
4839a86984 Cleanup: BLI: Merge files
Deduplicate IndexRange implementation files.

Pull Request: https://projects.blender.org/blender/blender/pulls/126169
2024-08-13 20:26:55 +02:00
Iliya Katueshenock
593e70dc53 Fix: Geometry Nodes: typo in node description
Pull Request: https://projects.blender.org/blender/blender/pulls/126165
2024-08-13 19:56:20 +02:00
Jacques Lucke
4f491aca80 Fix #126286: crash when opening blend file with point cache 2024-08-13 19:53:46 +02:00
bartus
7207015a58 Fix #125070: Handle "Unit Scale" correctly in the STL and PLY importers
When importing an STL file with the "Scene Unit" option enabled, we
should divide by the Unit Scale instead of multiply (which was already
done when Exporting with "Unit Scale" enabled)

The PLY importer had the same issue.

The prior "legacy" implementation did this correctly:
b42d686277/io_mesh_stl/__init__.py (L110)

Co-authored-by: Jesse Yurkovich <jesse.y@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/124718
2024-08-13 19:22:58 +02:00
Hans Goudey
5b75c5b89d Refactor: Sculpt: Specialize expand operator boundary calculation
Part of #118145.
2024-08-13 13:07:28 -04:00
Hans Goudey
90460878b3 Cleanup: Sculpt: Remove unused hide_poly argument
Even if/when we take visibility into account for multires calculations,
the per-grid-face visibility is stored in SubdivCCG::grid_hidden, not
the base mesh's face visibility.
2024-08-13 12:49:20 -04:00
Hans Goudey
6229f10e93 Cleanup: Sculpt: Pass position argument instead of PBVHVertRef 2024-08-13 12:35:30 -04:00
Hans Goudey
e12c568a69 Cleanup: Sculpt: Remove unused function 2024-08-13 12:35:11 -04:00
Hans Goudey
2449b12e67 Fix #125929: Add curves creates 1-segment too short curves
Caused by 5e96934ef6.
2024-08-13 12:11:58 -04:00
Hans Goudey
a716685f2f Fix #126149: Flat face wireframe edges hidden on some platforms
d1049f6082 translated the logic from the `int8` to `float`
conversion incorrectly. Previously the data was extracted to an integer
array (multiplied by 254) first then translated to a float VBO (and
divided by 255). I think conceptually the special `1.0/255` value isn't
necessary because the "optimal display edges" area already taken into
account for the creation of the index buffer. But as a quick fix, just
fix the factor to be the same as before.

Pull Request: https://projects.blender.org/blender/blender/pulls/126290
2024-08-13 18:09:23 +02:00
Jacques Lucke
e1422530d6 Fix: crash when attempting to unload volume tree twice 2024-08-13 17:47:52 +02:00
Hans Goudey
9eb7e8bfd1 Refactor: Sculpt: Reduce reliance on BVH tree geometry back pointers
Retrieve the relevant data directly from the original object's mesh
(or the evaluated SubdivCCG in that case) rather than using the
BVH tree's geometry points which we'd like to remove.

Pull Request: https://projects.blender.org/blender/blender/pulls/126284
2024-08-13 17:38:09 +02:00