Commit Graph

40016 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
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
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
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
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
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
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
Campbell Barton
3b5031f1cb Cleanup: use 'r_' prefix for output arguments, order last
Also clarify some naming.
2023-11-30 10:42:18 +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
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
Hans Goudey
1a36feb7e5 Cleanup: Use references instead of pointers in subdiv_ccg.cc 2023-11-29 11:40:10 -05:00
Germano Cavalcante
db3d59d94d Fix #115570: Crash when using snap to volume and clipping region
`ED_view3d_win_to_ray_clipped_ex` requires `ray_end` when
`do_clip_planes` is true.

Since the snap code uses `ray_depth` instead of `ray_end`, the solution
is to always calculate the `ray_end` and convert to `ray_depth` when
necessary.
2023-11-29 12:33:08 -03:00
Jacques Lucke
7a7b7196f9 Geometry Nodes: extract global data passed to a geometry nodes invocation to separate struct
This avoids some duplication between the modifier and operator evaluation
contexts and also makes it easier to make independent from a specific
evaluation context (so e.g. the simulation nodes code shouldn't care whether
it's used from a modifier or operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/115512
2023-11-29 13:22:20 +01:00
Campbell Barton
807993d2b7 Cleanup: use single underscore prefixes
Double underscores are reserved for implementation macros.
2023-11-29 18:09:01 +11:00
Campbell Barton
a144fcfa50 Cleanup: declare values for enums that may be written into blend files 2023-11-29 17:37:04 +11:00
Campbell Barton
c7593cc99f Cleanup: replace MAX2 with std::max 2023-11-29 17:11:09 +11:00
Campbell Barton
3a01ba9a39 Cleanup: avoid STR_ELEM expanding into multiple function calls
Also add note since hard coded property name checks are generally
worth avoiding.
2023-11-29 16:33:01 +11:00
Campbell Barton
a385a98e8e Cleanup: spelling in comments 2023-11-29 15:56:17 +11:00
Campbell Barton
44d6995b4c Cleanup: make hash sizes static, remove references to smallhash
Remove BLI_ghash_hash_sizes declaration it's only user (smallhash)
has been removed.
2023-11-29 15:13:05 +11:00
Hans Goudey
aca27e5462 Cleanup: Store BVH and shrinkwrap data with C++ types 2023-11-28 16:40:43 -05:00
Hans Goudey
7e3ba529ea Cleanup: Move four blenkernel headers to C++ 2023-11-28 16:05:12 -05:00
Hans Goudey
991486c37f Cleanup: Remove/replace SmallHash data structure
Use blender::Set which is similar but offsers better type safety
and likely better performance as well. The only remaining user
was the mesh edit mode knife tool, and replacing that usage
with `Set` and `Map` was straightforward.
2023-11-28 14:03:53 -05:00
Habib Gahbiche
ff083c1595 Compositor: UI: better node visibility for default node tree
Create default compositor node tree centred around x-axis, and with lower y-offset for better visibility

Pull Request: https://projects.blender.org/blender/blender/pulls/115439
2023-11-28 18:45:37 +01:00
Hans Goudey
81abaaad6b Fix #115521: Voxel remesh resets smooth with attribute propagation off
Add a special case for the sharp_face attribute to use the sharpness
of the first face, the same as before ba1c8fe6a5
2023-11-28 12:45:14 -05:00
Hans Goudey
f2467f75b3 Cleanup: Remove mesh "vert coords" functions
Inlining the functions is simpler nowadays, since there are utility
functions to copy spans and tag the mesh caches dirty. Also use an
array instead of a raw pointer for multires.
Resolves #103789
2023-11-28 12:26:51 -05:00
Nathan Vegdahl
c9093332e0 Fix #115434: custom bone colors invisible in stick mode
The issue was that bone colors are only specified with 3 channels (RGB),
but they're stored as 4 channels for some reason.  So the fourth bogus
channel gets initialized to zero by default, which was then being
interpreted as zero alpha in some drawing modes.

This fixes the issue by ensuring that the fourth unused channel always
gets initialized to 255, and therefore can be validly interpreted as an
alpha channel.

Pull Request: https://projects.blender.org/blender/blender/pulls/115477
2023-11-28 18:04:11 +01:00
Hans Goudey
ed23989e2e Geometry Nodes: Remove drag & drop requirement of geometry input
Generator node groups don't need to have a geometry input, and the error
will be displayed in the modifier after it's added if it really matters.
2023-11-28 11:06:54 -05:00
Antonio Vazquez
b9fba005bd GPv3: Lock unselect materials operator
Conversion of GPv2 operator

Pull Request: https://projects.blender.org/blender/blender/pulls/115278
2023-11-28 16:38:59 +01:00
Julian Eisel
0156169a9c Fix #115431: Crash on right click on string button inside menu
Problem is the `UI_context_active_but_get()` lookup doesn't respect menu
regions, unlike the earier call to `UI_context_active_but_prop_get()`
(which is also used to validate the existence of an active button).

Using `UI_context_active_but_get_respect_menu()` instead would work, but
in fact the earlier lookup returns the active button if any, we just
didn't use that.
2023-11-28 16:03:01 +01:00
Philipp Oeser
ed556113ce Fix #114557: UI scrollbar "focus bubble" interaction wrong in cases
Some Editors like the Filebrowser or Spreadsheet set up custom masks for
scrollbars (they dont cover the whole region width or height, some rows
or colums are excluded here -- e.g. the "index" column in the
Spreadsheet), this was working fine for drawing, but mouse interaction
was ignoring these custom masks.

Symptoms were that clicking on the "focus bubble" of the scrollbar and
dragging would not result in smooth scrolling [because internally code
would assume the mouse was clicking outside], instead scroll by 1 'page'
was happening [was perceived as a massive lag]. Especially noticable
with many rows/columns (where the "focus bubble" gets small).

So for drawing (`UI_view2d_scrollers_draw`) this wasnt a problem, masks
were passed in for `view2d_scrollers_calc`.
But for interaction (`scroller_activate_init`) `view2d_scrollers_calc`
is called again and a NULL mask was passed.

The already set up rects need to be considered though, otherwise coords
for `mouse_in_scroller_handle` later are not compatible.
To fix this, use existing `View2D` rects fors scrollbars, and pass a
union of those as `mask_custom` to `view2d_scrollers_calc`.

NOTE: this can temporarily extend the `View2D` scrollbar rect by a
pixel, the next draw call will correct this again though.

Pull Request: https://projects.blender.org/blender/blender/pulls/114631
2023-11-28 12:12:18 +01:00
Philipp Oeser
a4b8d214c6 Fix #115140: Crash undoing painting on linked image from 3DView
Related commit: 82aa300e1c / 5596f79821

82aa300e1c made it so that if only linked images are used, painting
would be prohibited. But since painting in Material mode actualy paints
across all materials it could happen that one particular image is linked
whereas another image isnt. In this case, painting on the linked image
would not be prohibited.

Two issues:

- [1] logic in above commit(s) seems slightly wrong, we could still pass
the check for linked images (also no image here should also not result
in a positive check I think).

- [2] code in `project_paint_prepare_all_faces` would still work with
linked images in slots, so
-- `ProjPaintState` -> `image_tot` was incremented
-- `ProjPaintImage` was created
-- this then ends up in the undo push - and crashes on undo

So now [1] is rectified and for [2] we skip faces with associated linked
images.

In addition, slots with linked images are now also greyed out in the UI
(`VIEW3D_PT_slots_projectpaint`) to give some sort of hint. For the
future it would probably also be good to dissallow selection of such
paint slots, but that is for another commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/115263
2023-11-28 12:05:07 +01:00
Philipp Oeser
09be0915c3 Fix #115363: Scrollbars for template_lists in popups update issue
Scrollbars in popups need UI layout refresh to update the right items to
show correctly.

Pull Request: https://projects.blender.org/blender/blender/pulls/115364
2023-11-28 09:14:28 +01:00
Campbell Barton
9dda667fd4 Cleanup: spelling in comments 2023-11-28 15:19:20 +11:00
Ray molenkamp
dbb2844ed9 Cleanup: CMake: Modernize bf_functions dependencies
Pretty straightforward

- Remove any bf_functions paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115427
2023-11-28 01:14:15 +01:00