Commit Graph

4735 Commits

Author SHA1 Message Date
Jacques Lucke
3a2f5fb9db Editors: move transform code to C++
Also see #103343.

Co-authored-by: Germano Cavalcante <germano.costa@ig.com.br>
Pull Request: https://projects.blender.org/blender/blender/pulls/110049
2023-07-13 17:59:52 +02:00
Christoph Lendenfeld
7acd6e61ab Animation: Butterworth Smoothing filter
Implements the Butterworth Filter
(https://en.wikipedia.org/wiki/Butterworth_filter) for smoothing FCurves.

This filter is ideal for smoothing dense data, like motion capture recordings.
It has the advantage of keeping the shape of the curve
intact while reducing minimal fluctuations.
The disadvantage is the impulse response has a twang,
meaning extreme spikes cause fluctuations to either side.

The implementation is based on the GPL code found here:
https://exstrom.com/journal/sigproc/dsigproc.html

In order to avoid phase shifting, the filter is run forward and backward,
effectively doubling the filter order.

The Redo panel offers the following options

* Frequency Cutoff: 0-n value, where 0 means it cuts everything
so the curve will become straight, the max value is the Nyquist frequency
and depends on the frame rate and the "Samples per Frame" option

* Filter Order: Higher values mean the frequency cutoff is steeper

* Samples per Frame: Before the filter is applied, the curve is resampled
at this interval to avoid errors when there are uneven spaces between frames.
If the keys are on subframes, e.g. a 60fps file in a 30fps scene, increase this value to 2

* Blend: 0-1 value to blend between the original curve and the filter result

* Blend In/Out: The number of frames at the start and end for which
to blend between the filtered and unfiltered curve.
This can help reduce any resulting jumps in the animation at the selection border

The operator can be called from the Key menu. (Key->Smooth->Butterworth Smooth)

Pull Request: https://projects.blender.org/blender/blender/pulls/106952
2023-07-13 09:10:42 +02:00
Campbell Barton
18b8b66952 Cleanup: correct doxy-comments, use doxy sections 2023-07-13 10:22:13 +10:00
Campbell Barton
e6609ecfda Cleanup: use a const ImBuf for UI image references 2023-07-13 10:10:44 +10:00
Campbell Barton
4e7ea8bf70 Cleanup: use const rect argument for immDrawPixelsTex functions 2023-07-13 10:09:16 +10:00
Jacques Lucke
75322803df Cleanup: move more editors folders to c++
This moves `space_script`, `space_statusbar`, `space_topbar`,
`space_userpref`, `space_view3d` and `util`.

Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110015
2023-07-12 18:02:56 +02:00
Colin Marmond
1ebdd2d9cf Nodes: Move preview images to an overlay
Move the node previews to the overlay region, atop each node.
It allows nodes to keep the same size when the preview is toggled,
which is more convenient for large nodes and large nodetrees.

The preview has to be drawn from `node_draw_extra_info_panel`
because there could be overlapping between info text and the preview.
When the node is out of the view, it also has to make sure that the
preview is also out of the view before exiting the draw function.

Pull Request: https://projects.blender.org/blender/blender/pulls/108001
2023-07-12 16:14:12 +02:00
Jacques Lucke
19d4cafb12 Cleanup: move more editors code to c++
This moves the remaining `.c` files in the following `editors` folders to C++:
`physics`, `screen`, `sound`, `space_buttons`, `space_file`, `space_graph` and `space_image`.

One exception is `fsmenu.c` which has platform specific issues on macos and
windows. E.g. the `Carbon/Carbon.h` include also declares a `Collection` type that collides
with ours.

Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/109918
2023-07-12 13:43:00 +02:00
Falk David
09f8f4d049 GPv3: Add initial dopesheet support
This PR adds basic support for viewing layers and keyframes in the grease pencil dopsheet for the new grease pencil data-type.
Resolves #108508.

Co-authored-by: Amelie Fondevilla <amelie.fondevilla@les-fees-speciales.coop>
Pull Request: https://projects.blender.org/blender/blender/pulls/108807
2023-07-12 10:32:09 +02:00
Harley Acheson
c6adafd8ef UI: add progress indicator variations & RNA API
Add pie and ring styles of progress indicators. Exposes progress bar to
the Python API and adds a "type" property to allow style variation.

This can be used for scripts & add-ons to show progress in the UI.

Ref !109882.

Co-authored-by: Campbell Barton <campbell@blender.org>
2023-07-12 14:00:39 +10:00
Campbell Barton
e63a77eeb8 Cleanup: rename uiButProgressbar to uiButProgress
Prepare for other types of progress to be added.
2023-07-12 13:31:46 +10:00
Jacques Lucke
3d73b71a97 Geometry Nodes: new Repeat Zone
This adds support for running a set of nodes repeatedly. The number
of iterations can be controlled dynamically as an input of the repeat
zone. The repeat zone can be added in via the search or from the
Add > Utilities menu.

The main use case is to replace long repetitive node chains with a more
flexible alternative. Technically, repeat zones can also be used for
many other use cases. However, due to their serial nature, performance
is very  sub-optimal when they are used to solve problems that could
be processed in parallel. Better solutions for such use cases will
be worked on separately.

Repeat zones are similar to simulation zones. The major difference is
that they have no concept of time and are always evaluated entirely in
the current frame, while in simulations only a single iteration is
evaluated per frame.

Stopping the repetition early using a dynamic condition is not yet
supported. "Break" functionality can be implemented manually using
Switch nodes in the  loop for now. It's likely that this functionality
will be built into the repeat zone in the future.
For now, things are kept more simple.

Remaining Todos after this first version:
* Improve socket inspection and viewer node support. Currently, only
  the first iteration is taken into account for socket inspection
  and the viewer.
* Make loop evaluation more lazy. Currently, the evaluation is eager,
  meaning that it evaluates some nodes even though their output may not
  be required.

Pull Request: https://projects.blender.org/blender/blender/pulls/109164
2023-07-11 22:36:10 +02:00
Hans Goudey
be09e94f05 Cleanup: Remove unused animation channel type
Unused after f3f05daf11
2023-07-11 14:50:29 -04:00
Hans Goudey
f3f05daf11 Cleanup: Remove unused "Simulation" data-block
This data-block was originally added in eb4e3bbe68.
However, that original plan wasn't fully implemented, with simulations
now integrated with geometry nodes and modifiers instead of a separate
data-block. We kept the data-block around anyway since we have the
loose plan of using a similar data-block to make global simulations
connected between multiple objects. But it may be a while before we
implement that, and in the meantime having this just causes confusion.
2023-07-11 10:53:15 -04:00
Julian Eisel
efbca8d660 Cleanup: Remove unnecessary tree view function override, add comment
`AbstractTreeViewItem::supports_collapsing()` returns true in the
default implementation, so no need to override that to do the same.
Notes the default behavior in a comment now.
2023-07-11 15:33:26 +02:00
Julian Eisel
4525527852 UI: Basic tree-view drag & drop reordering and inserting support
No user visible changes expected, these are just the internal API preparations.

Modifies the Drop API for views so that tree-views can choose to insert items
before, after and into other items.

Note: While there is support for drag-tooltips that can explain how an item
will be inserted, there is no drawing yet like in the Outliner, that indicates
if an item is inserted before, after or into. There is some work on that but
that can be done separately.

Changes:
- Removes `AbstractViewDropTarget` that was shared between tree- and
  grid-views, and adds `AbstractTreeViewDropTarget` and
  `AbstractGridViewDropTarget`. The tree-view needs specialized handling now,
  and although they could share some code still, it's not worth having another
  level of inheritance.
- Modifies the drop-target API to use `DragInfo` which contains more info about
  the dragging operation than just the `wmDrag`.
- Adds `determine_drop_location()` to the `DropTargetInterface` which drop
  targets can use to determine when dropping means inserting before, after or
  into.
- Store the block and region in the view. This is needed unfortunately but
  shouldn't be an issue since the tree view is recreated on redraws, together
  with the block.
- Various smaller tweaks and additions to views as needed.

TODO (outside scope of this change): Increase row height so there is no gap
between tree view items, but keep things visually the same otherwise. This
reduces flickering while dragging.

Pull Request: https://projects.blender.org/blender/blender/pulls/109825
2023-07-11 14:30:26 +02:00
bonj
d3315422ae Fix #109662: Overlay: Always use 0 for retopo min offset when disabled
Using 0.0015f as minimum value on Apple makes sense when the retopology
overlay is enabled.
When disabled however, this will cause the shader to think the overlay
is enabled when it's not, affecting the color of faces.
Therefore the offset when disabled should always be zero.
I've removed the unnecessary define and shortened the name of the other
one.

Pull Request: https://projects.blender.org/blender/blender/pulls/109658
2023-07-11 12:05:51 +02:00
Campbell Barton
09f1844d75 Cleanup: correct doxy-groups 2023-07-09 21:40:17 +10:00
Christoph Lendenfeld
79b2e8f211 Animation: Allow setting the slider unit and mode
Split off from [#106952: Animation: Butterworth Smoothing filter](https://projects.blender.org/blender/blender/pulls/106952)

This patch allows the slider to take a different string than just "%",
the use case is on #106952 where we want to display "Hz" instead.

Additionally the slider got the ability to set modes, which determine
how the factor number is displayed.
`SLIDER_MODE_PERCENT` means it will multiply by 100 and display as whole numbers
`SLIDER_MODE_FLOAT` means it will display just floats with one digit after the comma

Additionally to that, because the slider range is now arbitrary and potentially deals with
large numbers, the mouse distance needed to travel from min to max has been normalized
to the range.

Pull Request: https://projects.blender.org/blender/blender/pulls/109768
2023-07-07 15:08:40 +02:00
Julian Eisel
71273df2d5 UI: Draw hierarchy lines for tree-views
Hierarchy lines (like we also have in the Outliner) make it easier to
visually parse the hierarchy, and avoid confusion about nesting level.
Especially when some items have icons and/or collapse chevrons and some
not (thus different levels of visual indentation).
They were planned for #93582 and #107881, also see
https://code.blender.org/2023/05/the-next-big-step-grease-pencil-3-0/#layer-groups.

The drawing is implemented as a general tree-view feature, so all
tree-views with collapsable items (which excludes the spreadsheet
data-set tree view) will get them without further setup.
2023-07-06 17:09:32 +02:00
Falk David
4d3574a4a5 Curves: Reimplement random selection with mask
Instead of manipulating the selection attribute directly, we get an `IndexMask` of the random elements, and then apply the changes to the selection attribute in the operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/109366
2023-07-05 13:48:22 +02:00
Falk David
44ee5b38ac GPv3: Add operator to insert blank frames
This adds a new operator to insert blank keyframes for the new
grease pencil data type.

This uses the newly added `insert_frame` API.
2023-07-04 18:04:05 +02:00
Sergey Sharybin
e1b60fdb91 Remove Z Buffer from ImBuf
It was only used by OpenEXR and Iris images, and saving the Z Buffer
in those formats was disabled by default. This option comes from the
times prior to the addition of the Multilayer EXR.

It also worth noting that it was not possible to save Iris with Depth
pass from Blender as internally it is called IRIZ format and it was
not exposed. But even after exposing this format option something still
was missing as saving and loading ITIZ did not show up the Depth pass.

The reason of removal is to make it a more clear match of the ImBuf
with a render pass, and use it instead of a custom type in the render
result and render pass API. This will simplify the API and also avoid
stealing buffers and making shallow copies when showing the render
result.

For the cases when Depth is needed a Multilayer EXR is to be used,
as most likely more than just the Depth will be needed.

On a user level this change:

- Removes the "Z Buffer" option from the interface.

- It preserves existing sockets in compositor nodes, but it will
  output black image. Also changing the image data-block will
  remove the socket unless a Multilayer EXR with Depth pass image
  is selected.

- Removes "Depth" socket of the Viewer and Composite nodes.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/109687
2023-07-04 17:03:02 +02:00
Germano Cavalcante
c0d230e0b8 Revert "Transform: Allow navigation by default"
This reverts commit d53862351d.

After conducting tests with artists at the studio, it was observed that
altering the Transform Modal Maps caused significant disruption due to
the heavy reliance on the "Proportional Editing" and "Automatic
Constraint" features.

Considering this, it is now deemed more beneficial to provide users
with the choice of adapting their muscle memory to the new changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/109660
2023-07-04 14:53:39 +02:00
Hans Goudey
1b4b90f5f7 Cleanup: Remove unnecessary C API for asset representation
Now that almost all code is in C++, this is unnecessary and
just confuses things with multiple entry points to the same code.

Pull Request: https://projects.blender.org/blender/blender/pulls/109661
2023-07-04 14:46:19 +02:00
Falk David
3d99d05f00 GPv3: Add separate paint mode
This patch adds a separate paint mode for Grease Pencil 3.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/109453
2023-07-03 16:34:30 +02:00
Julian Eisel
0d1f3f445a UI: Support page based scrolling in View2D
No user visible changes expected. The feature is not exposed yet.

For the asset shelf (#102879), design is to use a paginated scrolling
style. That means, that any scrolling will always snap to a multiple of
the page size (the size used when pressing the Page Up/Down keys).
Together with strict region size snapping (implemented in the asset
shelf patch, #104831), this gives a clean scrolling experience where
partially visible rows are avoided (impossible even).

Introduces:
- `View2D.flag` value `V2D_SNAP_TO_PAGESIZE_Y`, which will cause any
  scrolling to only use multiples of the page size.
- A custom page size via `View2D.page_size_y` for when the full region
  size is not the appropriate page size value.
- API function `UI_view2d_offset_y_snap_to_closest_page()` to enforce
  the snapping from outside View2D. The asset shelf uses this to keep
  strict scrolling over DPI changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/109154
2023-07-03 15:15:18 +02:00
Campbell Barton
4be274a703 Cleanup: pass a const ibuf to ED_draw_imbuf_method 2023-07-02 19:54:27 +10:00
Hans Goudey
e4cc91a611 Geometry Nodes: Node group operators initial phase
This PR adds a new operator to run a node group on object geometry.
Only curves sculpt mode is supported for now, to simplify the design.

A new geometry node editor context to edit operator groups is also
added. This allows changing any node group, rather than only node
groups that are part of the active modifier context.

3D viewport menus are added with any geometry node group
asset in a catalog that contains the `Operator` tag. Currently Blender
must be restarted to refresh the list of available operators.

This is only the first phase of the node group operator feature.
Many more features will be added in next steps.

See #101778

Pull Request: https://projects.blender.org/blender/blender/pulls/108947
2023-06-29 13:57:54 +02:00
Campbell Barton
93b0be468f Cleanup: use r_ prefix for return arguments in ED_anim_api callbacks 2023-06-28 12:17:06 +10:00
Germano Cavalcante
d53862351d Transform: Allow navigation by default
As suggested in #108669, the "Navigate during Transform" option has
been removed and this feature works by default.

Now if you press `G`, `R` or `S` to move, rotate or scale an object you
can also navigate in the viewport.

Note that this update modifies the default keymap.
Now pressing `Alt` is required for the following modals:
- `PROPORTIONAL_SIZE_UP`,
- `PROPORTIONAL_SIZE_DOWN`,
- `PROPORTIONAL_SIZE`,
- `AUTOIK_CHAIN_LEN_UP`,
- `AUTOIK_CHAIN_LEN_DOWN`,
- `AUTOCONSTRAIN`,
- `AUTOCONSTRAINPLANE`.

Pull Request: https://projects.blender.org/blender/blender/pulls/109388
2023-06-27 20:29:05 +02:00
Germano Cavalcante
fcb2b99f2b Cleanup: Rename variables used in snap code
Many variables have been renamed to make their usage clearer in the
snap code.

- `color_line` -> `source_color`;
- `color_point` -> `target_color`;
- `loc_prev` -> `source_loc`;
- `loc_curr` -> `target_loc`;
- `normal` -> `target_normal`;
- `snap_elem_type` -> `target_type`;
- `snapElem` -> `target_type`;
- `Nearest2dUserData` -> `SnapData`;
- `SCE_SNAP_TO_VERTEX` -> `SCE_SNAP_TO_POINT` or `SCE_SNAP_TO_EDGE_ENDPOINT`;
- `SnapData_EditMesh` -> `SnapCache_EditMesh`;
- `sod` -> `em_cache`;

Also: make-format
2023-06-26 13:47:06 -03:00
Julian Eisel
0b19ab2cde UI: Add type-safe C++ button apply function object
No user visible changes expected.

Rather than relying on a C-style function pointer with void pointer
arguments, allow storing a `std::function` object, which can hold
arbitrary data in a type safe way. This can be conveniently used with
lambdas for example.

This is not used yet, but will be with #104831 merged. Replacing the
existing C-style callback uses with this can be done separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/109016
2023-06-26 16:39:51 +02:00
Falk David
497f9a6941 GPv3: Add operator to reorder the active layer
This operator will reorder the active layer (if there is one) to be above or below the target layer (specified by name).

Pull Request: https://projects.blender.org/blender/blender/pulls/109369
2023-06-26 14:03:28 +02:00
Falk David
c5a8a74f9e Refactor: Convert several animation editor files to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/109251
2023-06-26 11:27:25 +02:00
Falk David
32be07845f Curves: Mask function for end points
This essentially replaces the `ed::curves::select_ends` function by using a new masking function (`ed::curves::end_points`) and manipulating the selection attribute directly in the operators.

Pull Request: https://projects.blender.org/blender/blender/pulls/109293
2023-06-26 11:21:16 +02:00
Harley Acheson
4a80d0b6d5 Refactor: UTF-8 Character Defines
Use defined UTF-8 Universal character names in place of byte escape
sequences and literals.

Pull Request: https://projects.blender.org/blender/blender/pulls/109163
2023-06-26 06:05:18 +02:00
Campbell Barton
82d9eb09db Cleanup: use term SIZE instead of LEN for defines for buffer sizes
Reserve "LEN" for lengths that don't include the null byte.
2023-06-26 10:09:57 +10:00
lolloz98
fdc0402a50 GPv3: Select Alternate
Adds a "Select Alternate" operator for the new Grease Pencil data type.
This replaces the previous `gpencil.select_alternate`.

Resolves #109204.

Pull Request: https://projects.blender.org/blender/blender/pulls/109240
2023-06-23 11:34:00 +02:00
Falk David
b3f3b41d09 GPv3: Initial Layer Tree UI
Adds a new UI template to view the current layer tree of the active Grease Pencil object.

This UI tree view implements the following features (for now):
 - Displaying all the layers with their names and highlighting the active layer.
 - Changing the active layer by clicking on an item.
 - Adding new layers (using a new operator).
 - Removing the active layer (using a new operator).
 - Renaming a layer.

Pull Request: https://projects.blender.org/blender/blender/pulls/109197
2023-06-22 10:51:43 +02:00
Hans Goudey
cb07162c74 Cleanup: Remove unnecessary C wrappers from Mesh RNA 2023-06-21 15:35:22 -04:00
Germano Cavalcante
af63f05d17 Transform: Add utility for debug snapping time 2023-06-21 02:08:52 -03:00
Jacques Lucke
98d675ac6c Geometry Nodes: make evaluation and logging system aware of zones
This refactors how a geometry nodes node tree is converted to a lazy-function
graph. Previously, all nodes were inserted into a single graph. This was fine
because every node was evaluated at most once per node group evaluation.
However, loops (#108896) break this assumption since now nodes may be
evaluated multiple times and thus a single flat graph does not work anymore.

Now, a separate lazy-function is build for every zone which gives us much
more flexibility for what can happen in a zone. Right now, the change only
applies to simulation zones since that's the only kind of zone we have.
Technically, those zones could be inlined, but turning them into a separate
lazy-function also does not hurt and makes it possible to test this refactor
without implementing loops first. Also, having them as separate functions
might help in the future if we integrate a substep loop directly into the
simulation zone.

The most tricky part here is to just link everything up correctly, especially
with respect to deterministic anonymous attribute lifetimes. Fortunately,
correctness can be checked visually by looking at the generated graphs.

The logging/viewer system also had to be refactored a bit, because now there
can be multiple different `ComputeContext` in a single node tree. Each zone
is in a separate `ComputeContext`. To make it work, the `ViewerPath` system
now explicitly supports zones and drawing code will look up the right logger
for showing inspection data.

No functional changes are expected, except that the spreadsheet now shows
"Simulation Zone" in the context path if the viewer is in a simulation.
2023-06-20 10:08:57 +02:00
Germano Cavalcante
7764c87528 Cleanup: Transform Snap Object Code
Transform: remove unused members from 'SnapObjectHitDepth'

Also move the `short face_nearest_steps` member before the bit field.

And move 'void SnapData_EditMesh::clear()' definition to the source.

Pull Request: https://projects.blender.org/blender/blender/pulls/109132
2023-06-19 19:03:08 +02:00
Falk David
8c0b81da5b Cleanup: Separate GP operators and functions
Moved selection operators and related functions to their own file
`grease_pencil_select.cc`.
Moved editing related functions to `grease_pencil_edit.cc`.
Added a `ED_operatortypes_grease_pencil` function that calls all the
`ED_operatortypes_grease_pencil_*` functions.
2023-06-19 17:45:21 +02:00
Falk David
171de8b5a7 Cleanup: Remove ED_grease_pencil_draw.h
This is no longer needed. The function can be moved to
`ED_grease_pencil.h`
2023-06-19 17:38:58 +02:00
Julian Eisel
9b246fc438 Merge branch 'blender-v3.6-release' 2023-06-19 16:40:10 +02:00
Julian Eisel
232e065a17 Fix #109053: File Append with recursions leads to crash
In this specific code path (recursive reading inside .blend files
containing assets), reading datablocks marked as asset would move
ownership over the asset metadata without indicating that in the source
that owned it previously. This would cause a double free attempt.
2023-06-19 16:39:37 +02:00
Falk David
a6503f1dc9 Cleanup: Moving selection domain getter for GP
It was a bit odd having `ED_view3d_grease_pencil_selection_domain_get`
in the `ED_view3d.h` header.
Moving it to `ED_grease_pencil.h` makes more sense.
2023-06-19 16:22:48 +02:00
Sietse Brouwer
3432fc0b87 GPv3: Domain support for selection operators
This patch adds support for two of the three selection domains in the Edit Mode tool settings: point and stroke.

Affected selection operators: select all, lasso select, select pick, box select.

Pull Request: https://projects.blender.org/blender/blender/pulls/108970
2023-06-19 16:12:11 +02:00