Commit Graph

105083 Commits

Author SHA1 Message Date
Hans Goudey
874f83c42e Cleanup: Use FunctionRef for PBVH batch drawing
Also use const arguments, move a null check from the callback to the
PBVH function, and reorganice the PBVH code to be in a consistent
place in the file and to simplify the logic.
2023-12-05 09:36:13 -05:00
Sybren A. Stüvel
0cc58e40af Cleanup: Anim, remove accidentally committed declaration
Remove a function declaration that belongs in a future commit.

No functional changes.
2023-12-05 15:12:16 +01:00
Sybren A. Stüvel
42083c8357 Refactor: move ANIM_bone_collections.h into the .hh file
Move the contents of `ANIM_bone_collections.h` into its C++
`ANIM_bone_collections.hh` sibling. Blender is C++ by now that we can do
without the C header.

No functional changes.
2023-12-05 15:10:27 +01:00
Iliya Katueshenock
5429e006c8 Geometry Nodes: Face Group Boundaries node speedup
The multithreaded algorithm works by atomically assigning each face's
group ID to the surrounding edges. If the ID for the edge is different
than one set previously, the edge becomes a boundary.

Using the edge to face topology map was also tested, but it wasn't
faster, and given the large memory usage of the map, the increased
complexity of this algorithm was considered worthwhile.

Speed improvement for attached example file is listed in table:
| Cube resolution | Main | PR |
| -- | -- | -- |
| 20x20x20 | `71920 ns` | `97400 ns` |
| 100x100x100 | `1.27 ms` | `1.17 ms` |
| 500x500x500 | `79.37 ms` | `23.16 ms` |
| 1000x1000x1000 | `520.31 ms` | `142.21 ms` |

Pull Request: https://projects.blender.org/blender/blender/pulls/115138
2023-12-05 14:45:03 +01:00
Sebastian Parborg
4c527b095a Make the preference option "remap relative" apply for all save operations
Before it would only apply for the "Save" but not "Save As" and "Save
Copy" operators.

Pull Request: https://projects.blender.org/blender/blender/pulls/115791
2023-12-05 14:11:15 +01:00
Philipp Oeser
c5538b6851 Fix #115657 : Bone's tail is still selected after invert selection
The whole logic of selecting a parent bone's tip when selecting a bone
should only happen when they are actually **connected**
(BONE_CONNECTED), same as when picking a bone in the UI
(`ED_armature_edit_select_pick_bone`).

Pull Request: https://projects.blender.org/blender/blender/pulls/115663
2023-12-05 14:08:07 +01:00
Jacques Lucke
822cb1afd7 Fix: ensure function does not create geometry instances in all cases
This caused a crash further down the line where the code expected geometry
instances after calling `ensure_geometry_instances`, which seems reasonable
to assume.
2023-12-05 13:28:29 +01:00
Christoph Lendenfeld
1149bb216d Fix #115678: Padding not applied correctly when framing keyframes
When framing a single keyframe in the Graph Editor
the padding to the y axis wasn't applied correctly.
This meant that the viewport would zoom in too far
making it hard to zoom out again.

Pull Request: https://projects.blender.org/blender/blender/pulls/115792
2023-12-05 12:01:45 +01:00
Christoph Lendenfeld
f489b84316 Fix #115683: Crash with IK constraint
The issue was that the IK constraint wasn't set up correctly,
in such a way that the bone that had the constraint had no parents.
(refer to the file in the bugreport)

This lead to a crash when trying to get the tip of the chain because
`pchan_tip->parent` was a `nullptr`.

Fix it by only getting the parent if it's not a `nullptr`.
This has the side effect of not being able to move the bone in the test file.

Caused by: 0c2afa7c17

Pull Request: https://projects.blender.org/blender/blender/pulls/115788
2023-12-05 12:00:37 +01:00
Nathan Vegdahl
05ac25dfba Cleanup: use existing bone iterator function 2023-12-05 11:54:16 +01:00
Bastien Montagne
fa25a286d8 Refactor: BKE: Move BKE_library header to full CPP. 2023-12-05 11:53:55 +01:00
Christoph Lendenfeld
b549260aa4 Fix #114828: Don't rebuild outliner tree when frame scrubbing
Before this PR, whenever the frame changed during scrubbing,
the whole outliner tree would be rebuilt.
This rebuilding did not happen when playing back.
This was a major bottleneck, especially on scenes with many objects.

As far as I can tell there is no need to do that,
since there is no function that changes the
scene structure when the frame is changed.
The only way to do that is to add a python handler
for `post_frame_change`, but that also fires when playing back.

The performance gains can be quite significant.
I've made a scene with 32.000 cubes
and the `wm_draw_update` function goes from
~60ms
to
~30ms

Pull Request: https://projects.blender.org/blender/blender/pulls/114845
2023-12-05 11:04:24 +01:00
Falk David
5fea1eda36 GPv3: Drawing Placements
This PR adds the drawing placement modes from GPv2.

The drawing placement defines the depth (origin, view, surface, etc.) and a plane (view, cursor, xz, etc.).

This introduces a new helper class `DrawingPlacement` that does all of the internals to find the correct projection and just exposes a simple function to project from screen space to the drawing plane/surface.

Note: Drawing on other strokes currently doesn't work, because GPv3 can't be rendered to image yet. We use the depth buffer of the grease pencil render result to find the right depth.

Pull Request: https://projects.blender.org/blender/blender/pulls/115602
2023-12-05 11:01:42 +01:00
Nathan Vegdahl
9e7a70d6c6 Anim: store BoneCollections in a flat array
This is in preparation for eventual hierarchical bone collections.

The motivation here is that this will allow us to efficiently specify
children as an index range, which would be inefficient with a listbase
due to the list traversal overhead incurred for index-based look ups.

We're still saving to blend files as a list base for forwards compatibility
with Blender 4.0, but storing as an array at runtime for efficient indexing.

This should not result in any user-visible changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/115354
2023-12-05 10:39:45 +01:00
Omar Emara
689040db2f Fix #107465: Compositor Texture node produces artifacts
The compositor texture node produces artifacts in its Color output.
This was due to uninitialized alpha channel. Set the alpha channel to
1.0 if it was not written to fix the issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/115768
2023-12-05 09:17:08 +01:00
Jeroen Bakker
138ac87445 Cleanup: Make format 2023-12-05 08:18:16 +01:00
Z-Map
c9dd5ce4cc Fix #115715: Boolean behaves as if the object is on it's origin
Resolve regression in [0] which replaced a null check with an
identity comparison. This wasn't correct as the null check indicated
that transform was applied or not, where situations that require a
transform could have an identity matrix.

Resolve by checking if the matrix that would transform vertices is an
identity which is a reliable way to know if any transformation is needed.

Ref: !115736

[0]: e24c7f1954
2023-12-05 18:03:13 +11:00
Campbell Barton
20fd012adb Valgrind: suppress warnings with MemPool & MEM_* trailing padding
Suppress false positive Valgrind warnings which flooded the output.

- BLI_mempool alloc/free & iteration.
- Set alignment padding bytes at the end of MEM_* allocations
  as "defined" since this causes many false positive warnings
  in blend file writing and MEMFILE comparisons.
- Set MEM_* allocations as undefined when `--debug-memory`
  is passed in to account for debug initialization.
- Initialize pad bytes in TextLine allocations.
2023-12-05 17:12:32 +11:00
Campbell Barton
d48b9d32c6 Fix (unlikely) integer overflow error in writedata(..)
The range check was applied before padding up, in the unlikely case
sizes (INT_MAX - 2) or (INT_MAX - 1) were passed in,
the value overflow into a negative integer.
2023-12-05 17:11:03 +11:00
Campbell Barton
86f1fd5d8b BLI_idprop: simplify string creation logic, support unterminated strings
- Support passing in unterminated C-strings when clamped by the size
  argument.
- Pair string and it's size arguments together in IDP_NewStringMaxSize.
- Remove redundant size check which made it seem as if the string
  might not be null terminated.
- Replace clamping the result of strlen(..) with BLI_strnlen,
  to avoid calculating the length past the size checked.
- Add doc-string for unclamped string creation.
2023-12-05 17:11:03 +11:00
Campbell Barton
6f08d76ca8 Cleanup: quiet warning 2023-12-05 16:31:52 +11:00
Hans Goudey
ce81bdc284 Fix #115775: Curve object to mesh conversion crash
Caused by 4bcdc57fc8.
These objects are "half evaluated" in a very ugly way and have
no runtime data.
2023-12-04 19:14:50 -05:00
Hans Goudey
c293c75975 Cleanup: Avoid passing context to shrinkwrap blenkernel function
Such lower level functions generally shouldn't know about Blender's
overall context. If that spreads everywhere, things get hard to reason
about.
2023-12-04 15:29:40 -05:00
Hans Goudey
695e626d3f Cleanup: Store more mesh runtime data with unique_ptr
Convert shrinkwrap data arrays to use C++ arrays and BitVector,
use references in "EditMeshData" code, and store both structs
with `std::unique_ptr` instead of a raw allocation.
2023-12-04 15:23:24 -05:00
Hans Goudey
0318d49995 Cleanup: Improve comments in BKE mesh types header 2023-12-04 15:23:18 -05:00
Hans Goudey
c4446d7924 Mesh: Avoid calculating corner normals for drawing flat-shaded meshes
If I remember correctly, this was needed during development of
89e3ba4e25, but not anymore. Now the face normals are used
if faces are sharp. And if there is a mixture of sharp and smooth faces,
then normals_domain will be Corner anyway.

In a basic test with a 16 million face grid, this saved 30ms every draw
extraction. It also saves about 12 bytes per corner which was cached on
the mesh before.

There's a chance I'm missing something and this will require changes
elsewhere, but it's working well in my testing.
2023-12-04 15:22:26 -05:00
Brecht Van Lommel
a1804f35f7 Shaders: change default IOR from 1.45 to 1.5
To match OpenPBR and Standard Surface. Most IOR real values are in a range
of 1.3 to 1.6, might as well use the more round and common number.

Pull Request: https://projects.blender.org/blender/blender/pulls/115770
2023-12-04 21:12:29 +01:00
Brecht Van Lommel
56cc47ee2e Cleanup: compiler warning 2023-12-04 20:37:11 +01:00
Hans Goudey
cc3c5e2329 Fix: Debug build error after recent PBVH bounds change 2023-12-04 14:10:38 -05:00
Miguel Pozo
35cf616169 FIx: Draw: Volume coordinates regression
Caused by #114933
2023-12-04 19:33:58 +01:00
Hans Goudey
a9b94d6150 Cleanup: Remove unused BoundBox flag 2023-12-04 12:45:23 -05:00
Hans Goudey
8a705ffd11 PBVH: Use C++ Bounds type for node bounds
This is just a bit more ergonomic and works a bit better with our C++
math vector types. Also, during PBVH build, don't store the center of
each triangle/grid. That's redundant and can always be recalculated
from the bounds.
2023-12-04 12:45:23 -05:00
Jason Fielder
34c6e31332 GPU: Add flag when using explicit framebuffer loadstore state
Flag enables backends to differentiate between a framebuffer
bind with a custom loadstore state and a standard bind.
For Metal, this resolves an ambiguous complexity about loading
or clearing attachments by only flagging the first bind call as
explicit.

This means if a framebuffer is re-bound by a secondary code-path,
the re-started render-pass will not perform a secondary load. This
now allows explicit clear state to be specified on any attachment
type. Previously only memoryless attachments supported this.

To avoid further complexity, usage of`GPU_framebuffer_clear_* `
calls in conjunction with `GPU_framebuffer_bind_ex` will now
trigger an assertion failure.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/115734
2023-12-04 17:32:28 +01:00
Sybren A. Stüvel
562e9b9f4c Refactor: remove unused argument to BKE_constraint_remove_ex()
Remove the `bool clear_dep` argument of `BKE_constraint_remove_ex()`, as
it was always `true` on every call anyway.

No functional changes.
2023-12-04 17:13:47 +01:00
Miguel Pozo
56be404b0f EEVEE-Next: Scene sync fixes and improvements
Rely on the depsgraph to detect scene updates,
using the `view_update` callback.
Remove `SceneHandle` and `scene_sync`.
Remove `reset_recalc_flag`.
Remove most `sampling.reset()` calls and their related logic,
and move the remaining ones to `Instance`.
Re-sync lights on `light_threshold` changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/115758
2023-12-04 15:57:51 +01:00
Philipp Oeser
8bfc412490 Fix #115667: Sculpt face sets draw wrong with subdivision modifier
Copy-paste mistake in 301731692e

Above commit was getting ".sculpt_mask" instead of ".sculpt_face_set"
attribute.

Pull Request: https://projects.blender.org/blender/blender/pulls/115744
2023-12-04 14:43:32 +01:00
Hans Goudey
e9f4f8b52a PBVH: Specialize node bounds update, expose functions
Similar to previous commits (7332a1eb90), use three separate
functions for updating the bounds of different PBVH types. This avoids
the use of the vertex iteration macro. Also make the functions reusable,
so they can be called directly after a brush update in the future.
2023-12-04 08:36:02 -05:00
Hans Goudey
869ea79da0 Cleanup: Return PBVH vertex data arrays as spans 2023-12-04 07:55:47 -05:00
Hans Goudey
3b1d5d14f2 Cleanup: Remove unused DMFlagMat struct
Arrays were allocated and filled with data, but never read.
2023-12-04 07:55:47 -05:00
Hans Goudey
8171f719fe Subdiv: Remove unnecessary CCG derived flag structs
The copied the material index and its smoothness to every grid,
resulting in 4 bytes of memory per base mesh face corner. That's
wasteful, since it's trivial to loop up the original data from the base
mesh attributes as necessary. This way we can also avoid the
dereference.
2023-12-04 07:55:47 -05:00
Hans Goudey
5cd6a05f5e Cleanup: Store SubdivCCG in unique_ptr
Automatic memory management and clearer ownership! Requires
removing `MEM_CXX_CLASS_ALLOC_FUNCS` from `MeshRuntime`,
but that's used very inconsistently anyway, and `MeshRuntime` isn't
that large.
2023-12-04 07:55:47 -05:00
Hans Goudey
d73868d5a1 Subdiv: Inline grid to face map lookup function
I've seen this appear in profiles sometimes, which it really shouldn't,
since it's just a single array access. I didn't detect an observable
difference, but we don't have to think about that anymore anyway.
2023-12-04 07:55:47 -05:00
Hans Goudey
0b9ae3df4c Subdiv: Use base mesh faces and topology map for SubdivCCG
Instead of storing a redundant array of faces, use the base mesh faces
and corner_to_face map. This saves 8 bytes per base mesh face with
multires sculpting, and avoids recalculating the topology map whenever
reevaluating the object. There is a lot of other duplicate data between
base meshes and faces, particularly in `MeshTopology`. This is just
a first step of untangling that.
2023-12-04 07:55:47 -05:00
Hans Goudey
881ec8b1ed Cleanup: Return multires grid key by value 2023-12-04 07:55:47 -05:00
Hans Goudey
a9f847f94c Fix: Various issues with multires visibility undo
Push the undo step before changing any grid hide data, fix a missing
allocation in the undo step, and workaround some issue with temporary
BitVector<> construction that I couldn't quite figure out. Also fix a
crash when there is vertex mask attribute but no multires hiding.
2023-12-04 07:55:47 -05:00
Hans Goudey
beda9e4656 Sculpt: Specialize mask fill/invert operator per PBVH type
Two main user-facing benefits: only nodes with actually changed
values have undo steps pushed, meaning reduced memory usage
and undo runtime, and the mask attribute is removed when cleared,
reducing memory usage and theoretically improving performance
afterwards.

On the code side, the changes consist conceptually of expanding the
PBVH vertex iter macro for each PBVH type and simplifying the resulting
logic. This results in significantly more code; the idea is that in the
future abstractions to reduce duplication  will become clearer. We just
want abstractions that relate closely to the actual data processing,
which is much simpler than the existing macro makes it look.
2023-12-04 07:55:47 -05:00
Hans Goudey
7332a1eb90 PBVH: Refactor hide and mask update to be data oriented and reusable
Specialize the mask update for each PBVH type, simplifying hot loops,
reducing reliance on complex shared state and clarifying which data is
used. Expose functions to update the visibility and masks tags for a
specific node. It can be helpful to call these after modifying the data
to update the flags while the data is more likely to be in CPU caches.
2023-12-04 07:55:46 -05:00
Hans Goudey
e1c4e7b4c6 Fix: Missing versioning for generic sculpt mask conversion
Since we're always writing the mask with the old format, this versioning
will have to run until a larger breaking release such as 5.0. Luckily it
is cheap, it's just rearranging the pointers to larger arrays.
2023-12-04 07:55:46 -05:00
Hans Goudey
f3bfbd9d84 Cleanup: Use const arguments to PBVH functions 2023-12-04 07:55:46 -05:00
Hans Goudey
785c49cf44 Cleanup: Move paint_mask functions to proper namespace
Some of these operators aren't really related to masking
and should be moved elsewhere in the future.
2023-12-04 07:55:46 -05:00