Commit Graph

104971 Commits

Author SHA1 Message Date
Campbell Barton
94de4087e6 Cleanup: assign values for enums that may be stored in blend files 2023-12-01 11:04:47 +11:00
Campbell Barton
afa9a6904d Fix missing null check from !115247 & simplify
- CTX_wm_region(C) must be NULL checked as it's not checked in the
  poll function.
- Add back the removed flag, note it's dirty.
- Replace ternary operators with min/max.
2023-12-01 10:47:21 +11:00
Campbell Barton
8aff65daf2 Cleanup: naming for GPUSelectResult
Prefer the name 'hit_result' since 'result' was sometimes used for
a vector of GPUSelectResult and is often used a functions return value.

Use hit_results for the span/vector and hit_result for a single hit.

Also assign struct members for new GPUSelectResult as it reads better
and avoids depending on struct order.
2023-12-01 09:45:02 +11:00
Hans Goudey
ac6e854335 Cleanup: Small tweaks to C++ style in lib remap code
- Pass Span by value. It is a small struct, and passed by reference
  it acts as a pointer to a pointer.
- Remove unnecessary `= {}`. Vector has a default constructor.
- Use initializer list Span constructor to avoid temporary array.

Pull Request: https://projects.blender.org/blender/blender/pulls/115635
2023-11-30 23:03:39 +01:00
Hans Goudey
8b28bb9882 Cleanup: Remove redundant subdiv pointers from PBVH
These are just duplicates of the pointers in `SubdivCCG`, which are
already quickly accessible. Keeping track of the state is too complex
and bloats the responsibilities of the PBVH too much.
2023-11-30 16:40:09 -05:00
Bastien Montagne
050d48edfc BLI_fileops: Harmonize 'rename' behaviors accross platforms.
This commit aim at making the behaviors of `BLI_rename` and
`BLI_rename_overwrite` more consistent and coherent across all
supported platforms.

* `BLI_rename` now only succeeds in case the target `to` path does not
  exists (similar to Windows `rename` behavior).
* `BLI_rename_overwrite` allows to replace an existing target `to` file
  or (empty) directory (similar to Unix `rename` behavior).

NOTE: In case the target is open by some process on the system, trying
to overwrite it will still fail on Windows, while it should succeed on
Unix-like systems.

The main change for Windows is the usage of `MoveFileExW`
instead of `_wrename`, which allows for 'native support' of file
overwrite (using the `MOVEFILE_REPLACE_EXISTING` flag). Directories
still need to be explicitly removed though.

The main change for *nix systems is the use of `renamex_np` (OSX) or
`renameat2` (most Linux systems) to allow forbidding renaming to an
already existing target in an 'atomic' way.

NOTE: While this commit aims at avoiding the TOC/TOU problem as
much as possible by using available system's primitives for most
common cases, there are some situations where race conditions
(filesystem changes between checks on FS state, and actual rename
operation) remain possible.

Pull Request: https://projects.blender.org/blender/blender/pulls/115096
2023-11-30 22:35:00 +01:00
Bastien Montagne
dfe1a7d039 BKE_lib_remap: Refactor: Replace LinkNode by blender::Span. 2023-11-30 22:21:45 +01:00
Harley Acheson
5d330ddb1f BLF: Support All Render and Bitmap Formats
Add support for all of FreeType's various render formats and output
bitmap formats.

Pull Request: https://projects.blender.org/blender/blender/pulls/115452
2023-11-30 22:17:30 +01:00
Jesse Yurkovich
abf59eb23a Selection: Remove limit on number of items which can be selected at once
This removes the long-standing static limit for the selection buffer in
favor of a dynamic approach.

It replaces the static array with our Vector type where the inline
buffer provides parity with existing code while also providing the
ability to grow as necessary.

Fixes #102487, #109178, #112350, #112493, and https://projects.blender.org/blender/blender-manual/issues/102485

See PR for further notes and links to the different limits remaining.
Pull Request: https://projects.blender.org/blender/blender/pulls/112491
2023-11-30 21:27:15 +01:00
Miguel Pozo
2e27791df3 Fix: EEVEE-Next: Alpha hashed transparency doesn't converge
Use sub-pixel alpha hash scale when the camera is not moving.
This provides cleaner results, while maintaining temporal coherence on
camera movement.

Pull Request: https://projects.blender.org/blender/blender/pulls/115620
2023-11-30 20:18:08 +01:00
Hans Goudey
4e66769ec0 Sculpt: Improve "Hide/Show" operator performance for mesh
Parallelize the implementation and move constant checks out of hot
loops. Only push undo steps for PBVH nodes that actually have changed
hide status. Optimize the "show all" case to remove the hide attributes.
For timings, I recorded some information on a 16 million vertex mesh:
- Hide masked (1/4 of mesh): 171 ms to 33 ms
- Hide small box: 13 ms to 14 ms
- Show all with small box hidden: 226 ms to 10 ms
- Show with all visible: 173 ms to 0.36 ms

There are a few other visbility operators that aren't affected:
- SCULPT_OT_face_set_invert_visibility
- SCULPT_OT_reveal_all
- SCULPT_OT_face_set_change_visibility
In separate steps, they should be moved to use the same structure, or
maybe even removed in the case of "reveal all".

I expect the "gather, change hidden verts, scatter" steps for each node
could be made a bit more efficient, they do some redundant work.
But it was also a simple way to share a reasonable amount of code.
2023-11-30 14:14:02 -05:00
Hans Goudey
7eb8c4cdda Cleanup: use const variables and arguments 2023-11-30 14:14:02 -05:00
Hans Goudey
841864406f Cleanup: Use enum class int paint hide operator 2023-11-30 14:14:02 -05:00
Hans Goudey
11b4e9311f Cleanup: Move paint hide file to namespace 2023-11-30 14:14:02 -05:00
Hans Goudey
68baa04eeb Cleanup: Move enum definition out of header 2023-11-30 14:14:02 -05:00
Hans Goudey
3adcc1378c Cleanup: Avoid using keyword in sculpt header
This approach doesn't scale well, and the right solution is to move
this code to the proper namespace anyway.
2023-11-30 14:14:02 -05:00
Hans Goudey
759d2634fd Cleanup: Pass all nodes to paint hiding functions
Allows specializing the operation more for each PBVH type.
2023-11-30 14:14:02 -05:00
Bastien Montagne
fe3cb11ae4 BKE_lib: Convert BKE_lib_remap and lib_intern headers to be fully C++. 2023-11-30 19:51:22 +01:00
Harley Acheson
1317c951fb Cleanup: Make format
Formatting changes resulting from Make Format
2023-11-30 09:29:35 -08:00
Guillermo Venegas
cf08b088ba Text Editor: Use active text selection as search query
If text is selected, use that as the search query.

Pull Request: https://projects.blender.org/blender/blender/pulls/115247
2023-11-30 18:26:53 +01:00
Aras Pranckevicius
93ca2788ff VSE: speedup Luma Waveform display output mode
Use multithreading, plus make the non-float / non-separate luma
calculations faster by avoiding byte->float->byte conversions
back and forth.

On a 4K resolution sequencer display, time taken to calculate the
waveform (Windows, Ryzen 5950X):

- regular images: 127.0ms -> 6.4ms
- regular images, separate colors: 160.3ms -> 13.1ms
- float images: 86.2ms -> 11.1ms
- float images, separate colors: 162.9ms -> 17.4ms

This also fixes curious "one black pixel row" in the middle of the
waveform, which was caused by the code spreading 256 possible luma
values over "off by one" vertical range:

Pull Request: https://projects.blender.org/blender/blender/pulls/115579
2023-11-30 18:19:40 +01:00
Clément Busschaert
671f428ead GPv3: "Set Active Layer" operator and menu
Resolves #113915 .

Ports the `layer_active` operator to set the active layer from an index.
Adds the menu to set the active layer from a list.

Pull Request: https://projects.blender.org/blender/blender/pulls/115606
2023-11-30 16:10:06 +01:00
Philipp Oeser
6023a6a423 Fix #115526: missing normals on first chunk of array modifier
Exposed by 383a145a19.

Think the issue actually started in cfa53e0fbe, since then the new
destination normals were only filled from the first array copy onwards
(probably hidden by some recalculation of normals somewhere?).

In any case, starting the destination normals array with what we have
from the input mesh normals and then resizing the array (instead of
reinitializing it from scratch) fixes this.

Pull Request: https://projects.blender.org/blender/blender/pulls/115612
2023-11-30 15:49:52 +01:00
Philipp Oeser
864b07011a Fix #115037: Crash deleting tool node group from outliner
Prevent heap-use-after-free of SpaceNode `geometry_nodes_tool_tree`,
remapping it in `node_id_remap_cb` (so it get null when deleted).

Pull Request: https://projects.blender.org/blender/blender/pulls/115047
2023-11-30 15:48:42 +01:00
Falk David
0185609a26 Fix: GPv3: Smoothing even with factor of 0
The grease pencil draw tool would still do a lot of smoothing
even if the active smoothing factor was set to 0.0.

This was because the screen space coordinates were always pre-blurred
before being passed to the curve fitting. Even if the curve fitting
outputs a line that fits the input exactly, it would still use the pre
smoothed coordinates.

The fix makes sure to use the smoothing factor in the influence
of the pre-blur. This way, no pre-blur is used when the factor is 0
and the lines will be smoothed much less.

Note that we always do some smoothing to avoid artifacts such
as pixel-grid-aligned lines etc.
2023-11-30 14:48:28 +01:00
Christoph Lendenfeld
83287624bc Anim: Change how Only Insert Needed works
When keyframing with the `Only Insert Needed` flag enabled,
the code was able to delete keyframes in certain cases.
This behavior is removed and replaced with the following rules.

* If there is a key on the current frame, and it has the same value, skip it.
* If there is no key, but the FCurve evaluates to the same value, skip it.
* Add a key in all other cases.

Remove that functionality for consistency and simplify the code around it.

Pull Request: https://projects.blender.org/blender/blender/pulls/115360
2023-11-30 14:45:47 +01:00
Brecht Van Lommel
f47b1b41c2 Cleanup: compiler warning in release build 2023-11-30 14:32:54 +01:00
Brecht Van Lommel
9ffd6dabf0 Fix build error in freestyle when not using precompiled headers 2023-11-30 14:31:29 +01:00
Omar Emara
b8f4c45638 Realtime Compositor: Add utilities to handle texture formats
This patch adds a number of utilities to handle texture formats and
their relation to result types and precisions. This is needed for future
work, and also unifies the places one needs to update when adding a new
result type.
2023-11-30 15:21:56 +02:00
Nathan Vegdahl
908ce0dd1a Fix: allow overshoot numerical input in the Pose Breakdowner operator
You could already do overshoot via the mouse, but it was arbitrarily
disallowed when entering values numerically.  This simply lifts that
restriction so that numerical input is capable of the same things as
dragging the mouse.

Importantly, the operator slider code already appropriately clamps
both mouse and numerical input when needed.  So the checks and clamping
removed in this commit simply aren't needed, and removing them just
makes numerical input get constrained exactly the same as mouse input.

Pull Request: https://projects.blender.org/blender/blender/pulls/115534
2023-11-30 10:25:16 +01:00
Omar Emara
07e051d7cd Realtime Compositor: Implement zero cost external images
This patch implements a new mechanism for compositor results to wrap
external images, such as those cached in the static cache manager.
Thereby enabling zero cost use of those resources, which previously
needed a copy at each evaluation.

Pull Request: https://projects.blender.org/blender/blender/pulls/115574
2023-11-30 09:10:41 +01:00
Campbell Barton
dfbda79cbd Cleanup: declare pointers const where possible 2023-11-30 16:42:40 +11:00
Campbell Barton
6b22572967 Cleanup: various non-functional changes for C++ 2023-11-30 16:42:39 +11:00
Aras Pranckevicius
3f7ab7069e Cleanup: move writeffmpeg to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/115585
2023-11-30 06:03:18 +01:00
Campbell Barton
7f8efbe593 Cleanup: quiet CLANG conversion warnings 2023-11-30 15:01:58 +11:00
Campbell Barton
15db0cb446 Cleanup: use style for doxygen comment blocks 2023-11-30 14:15:11 +11:00
Campbell Barton
b0746f4be2 Refactor: reduce complexity of object mode selection, minor optimization
Selection logic in ed_object_select_pick mixed operations for
object mode & other modes, making it difficult to reason about.

Refactor so object mode selection is isolated to it's own block,
following conventions for SelectPick_Params used by all other selection
picking operators.

This makes it possible to remove a call to de-select all objects
which was redundant in most cases.
2023-11-30 12:43:29 +11:00
Campbell Barton
09bd046975 Fix #115181: RMB Select sometimes to enter pose mode when selected
Pass-through selection allows select-drag not to activate an already
selected object - so an existing selection can be dragged without
changing the active/selection (see #96544) & [0],

This caused entering pose-mode to fail when selecting an armature
with "Lock Object Modes" disabled.

There is a logical conflict where pass-through is intended to keep the
current selection & active, which doesn't make sense when selecting the
armature should enter pose-mode (details in code-comments).

Resolve by disabling pass-through when the select action changes
the objects mode.

[0]: 618f39fca2
2023-11-30 11:15:09 +11:00
Clément Foucault
92bec9af0c Fix EEVEE: Compilation on Metal 2023-11-30 01:10:27 +01:00
Hans Goudey
34ec46934c Fix: Incorrect subdiv IndexMask construction
The indices have to be sorted. A different method of interpolating
the face selection to vertices would probably be better in the future.
2023-11-29 18:52:58 -05:00
Campbell Barton
8c473df8c3 Cleanup: suppress CLANG warnings, remove unused variables 2023-11-30 10:48:33 +11:00
Campbell Barton
3b5031f1cb Cleanup: use 'r_' prefix for output arguments, order last
Also clarify some naming.
2023-11-30 10:42:18 +11:00
Campbell Barton
2c2bd7d1e3 Cleanup: pass const arguments to BKE_mesh_fair functions 2023-11-30 10:42:16 +11:00
Aras Pranckevicius
df16f4931e VSE: speedup timeline drawing, and improve waveform display
Sequencer timeline UI repainting is 3x-4x faster now, for complex
timelines. On Sprite Fright Edit data set, with whole timeline visible
(2702 strips), repainting the timeline UI with all overlay options
(waveforms, offsets, thumbnails etc.):

- Windows (Ryzen 5950X, RTX 3080Ti, OpenGL): 62ms -> 18.6ms (16FPS -> 54FPS)
- Mac (M1 Max, Metal): 39.8ms -> 11.5ms (25FPS -> 86FPS)

This is achieved by:

- Avoiding tiny GPU draw calls (i.e. drawing one quad a time), instead
  batch all the quads / lines needed by the timeline display into
  series of about-1000 quads per draw.
- For retiming keys display, batch their keyframe point drawing too.
- For audio waveform overlay display, change it to draw batched quads
  instead of alternating between line strips and triangle strips. This
  actually changes how the waveform looks like (implements #115274)
  and fixes some visual issues with waveforms too.
- For fcurve overlays, also draw them as batched quads.

While at it, this also fixes an issue where while dragging strips over
other strips, their text labels would look as if they are behind the
background strips.

Pull Request: https://projects.blender.org/blender/blender/pulls/115311
2023-11-29 20:25:21 +01:00
Hans Goudey
5366ccd625 Fix: Debug and lite build errors after recent cleanup
Our `EnumerableThreadSpecific` wrapper doesn't accept an
example argument, only an initialization function. And some
removed variables were still used in asserts.
2023-11-29 13:23:03 -05:00
Hans Goudey
13c145ac02 Cleanup: Grammar in a few comments 2023-11-29 12:39:33 -05:00
Hans Goudey
8c59532106 Cleanup: Use C++ arrays to store subdiv ccg data
Decrease the amount of manual memory management
and pointer arithmetic.
2023-11-29 12:39:33 -05:00
Philipp Oeser
d3ff658b66 Fix #115572: shape_key_remove operator leaves shared normals
Caused by 383a145a19

Since above commit, normals were in a SharedCache, they need to be tagged dirty
for recalculation.

Instead of tagging the normals caches dirty explicitly, simply use
`BKE_mesh_tag_positions_changed` [which includes all this and also tags
positions dirty - which sounds also needed for updating other things]

Pull Request: https://projects.blender.org/blender/blender/pulls/115580
2023-11-29 18:17:30 +01:00
Hans Goudey
c2571cd259 Cleanup: Use const SubdivCCGFace variables 2023-11-29 11:47:00 -05:00
Hans Goudey
1a36feb7e5 Cleanup: Use references instead of pointers in subdiv_ccg.cc 2023-11-29 11:40:10 -05:00