Commit Graph

174 Commits

Author SHA1 Message Date
Pablo Vazquez
537e264b70 UI: Add icons to Set Handle Type menu
Some checks failed
Close GitHub Pull Requests / Close Pull Requests (push) Has been cancelled
Add icons to curves "Set Handle Type" menu, (both legacy Curve and new
Curves). Matching those in the Curve widgets.

Graph Editor already uses icons for that menu.

See PR for details and screenshots.

Pull Request: https://projects.blender.org/blender/blender/pulls/148322
2025-10-18 18:45:44 +02:00
Hans Goudey
1d372bdc8b Refactor: Split CustomData attribute and newer attribute headers
Avoid including DNA_customdata_types.h everywhere we include the
attributes header. Over time the older attribute header should be
used less and less.

Part of #122398

Pull Request: https://projects.blender.org/blender/blender/pulls/147980
2025-10-13 15:38:26 +02:00
Casey Bianco-Davis
cbdf12d2a9 Curves: Pen Tool
This PR adds the `Pen Tool` to `Curves` objects.
The logic and keybinds are shared with the Grease Pencil `Pen Tool`

Unlike the legacy pen tool, this version can works with multiple objects.

Note: Some changes have been made from the legacy curve object's pen tool.
A list of changes can be found at #142646

Pull Request: https://projects.blender.org/blender/blender/pulls/144833
2025-09-07 16:29:07 +02:00
Alaska
e86bff3621 Fix: UI: Correct spelling of Bézier in Curves add menu
Pull Request: https://projects.blender.org/blender/blender/pulls/145338
2025-08-29 20:00:05 +02:00
Casey Bianco-Davis
f248f3a5a2 Curves: Add Toggle Free/Align to Set Handle Type operators
This adds `Toggle Free/Align` from legacy Curve objects to
Grease Pencil and Curves objects.

This also reorders the items to match the legacy system.

Resolves: #140350.

Pull Request: https://projects.blender.org/blender/blender/pulls/144883
2025-08-27 11:57:51 +02:00
Casey Bianco-Davis
6271ae5758 Curves: Delete and Dissolve operator not work with selected handles
This makes it so that the `Delete` and `Dissolve` operators will remove any
points that have handles selected.

Part of #121574.

Pull Request: https://projects.blender.org/blender/blender/pulls/144893
2025-08-25 15:41:43 +02:00
Jacques Lucke
55e2fd2929 Cleanup: unify naming for named constructors
Previously, we used an inconsistent naming scheme for such "named constructors".
Now it always uses `from_*`.

Pull Request: https://projects.blender.org/blender/blender/pulls/142175
2025-07-17 09:09:16 +02:00
Hans Goudey
1f92fd7577 Refactor: Use AttrType instead of CustomData type in attribute API
Change `eCustomDataType` to `bke::AttrType` for uses of the attribute
API (the `AttributeAccessor` one anyway). I didn't touch any values that
might be saved in files; those should be handled on a case by case basis.

Part of #122398

Pull Request: https://projects.blender.org/blender/blender/pulls/141301
2025-07-01 22:14:26 +02:00
Guillermo Venegas
e300d44e69 Refactor: UI: Add uiLayout use_property_decorate methods
This replaces uiLayout use_property_decorate API with uiLayout
methods, following uiLayout refactors and the Python API naming.

Pull Request: https://projects.blender.org/blender/blender/pulls/140887
2025-06-24 03:52:17 +02:00
Guillermo Venegas
d600b1002a Refactor: UI: Add uiLayout use_property_split methods
This replaces uiLayout use_property_split API with uiLayout methods,
following uiLayout refactors and the Python API naming.

Pull Request: https://projects.blender.org/blender/blender/pulls/140874
2025-06-23 19:07:09 +02:00
Guillermo Venegas
091db9d52b Cleanup: UI: Use UI_interface_layout.hh instead of UI_interface.hh
This removes the include `UI_interface_layout.hh` from
`UI_interface_c.hh`, and in many places this swaps the include
from `UI_interface.hh` to `UI_interface_layout.hh`.

Also, cleanups some `UI_interface.hh` includes with
`UI_interface_icons.hh` or `UI_interface_types.hh`
2025-06-20 18:07:47 +02:00
Hans Goudey
550094b018 Refactor: Attributes: Access active attribute with name
This function to get the active attribute currently returns a custom
data layer pointer. This doesn't work when we transition to the new
`AttributeStorage` system. Returning an optional string is a simple
alternative that also aligns with the idea of changing the source of
truth from an index to a string stored on the geometry.

Pull Request: https://projects.blender.org/blender/blender/pulls/139115
2025-05-19 21:29:57 +02:00
Guillermo Venegas
dafdced6ab Refactor: UI: Replace uiItemR with class method uiLayout::prop
This converts the public `uiItemR` function to an object oriented
API (`uiLayout::prop`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138617
2025-05-08 20:45:37 +02:00
Jacques Lucke
e8d1491e62 Refactor: Depsgraph: simplify query API further
* Remove `DEG_get_evaluated_object` in favor of `DEG_get_evaluated`.
* Remove `DEG_is_original_object` in favor of `DEG_is_original`.
* Remove `DEG_is_evaluated_object` in favor of `DEG_is_evaluated`.

Pull Request: https://projects.blender.org/blender/blender/pulls/138317
2025-05-02 15:08:29 +02:00
Guillermo Venegas
2d896877d1 Refactor: UI: Replace uiLayoutColumn with class method uiLayout::column
This converts the public `uiLayoutColumn` function to an object oriented
API (`uiLayout::column`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

`uiLayout::column` now returns an `uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Pull Request: https://projects.blender.org/blender/blender/pulls/138034
2025-04-26 21:07:34 +02:00
Brecht Van Lommel
fb2ba20b67 Refactor: Use more typed MEM_calloc<> and MEM_malloc<>
Pull Request: https://projects.blender.org/blender/blender/pulls/137822
2025-04-22 11:22:18 +02:00
Jacques Lucke
7f1a99e862 Refactor: BLI: Make some CPPType properties public instead of using methods
This makes accessing these properties more convenient. Since we only ever have
const references to `CPPType`, there isn't really a benefit to using methods to
avoid mutation.

Pull Request: https://projects.blender.org/blender/blender/pulls/137482
2025-04-14 17:48:17 +02:00
Campbell Barton
10233e95dd Cleanup: use a typed enum for operator & gizmo callbacks
Callbacks: exec invoke & modal now use a typed enum wmOperatorStatus.

This helps avoid mistakes returning incompatible booleans or other
values which don't make sense for operators to return.

It also makes it more obvious functions in the WM API are intended
to be used to calculate return values for operator callbacks.

Operator enums have been moved into DNA_windowmanager_enums.h
so this can be used in other headers without loading other includes
indirectly.

No functional changes expected.

Ref !136227
2025-03-20 21:11:06 +00:00
Laurynas Duburas
2c42294557 Curves: add Split operator
Adds Split operator to curves. It should have the same behavior as the
corresponding operator for legacy curves.

Pull Request: https://projects.blender.org/blender/blender/pulls/131788
2025-02-24 11:32:59 +01:00
Dalai Felinto
9d06f32761 Point Cloud: Select Random
Move the mask_random function to BLI_index_mask.hh, so it can be shared between curves, grease pencil and point cloud.

Copied/inspired by the curves select code.

Pull Request: https://projects.blender.org/blender/blender/pulls/134624
2025-02-19 17:23:37 +01:00
Hans Goudey
a99f9496a0 Curves: Separate to object operator
Use the existing "remove_points_and_split" utility added
for grease pencil to implement the operator for the curves
object type. The whole structure is similar to the recently
added point cloud separate operator (4cd3540579).

Pull Request: https://projects.blender.org/blender/blender/pulls/134763
2025-02-18 19:31:30 +01:00
Hans Goudey
45094542ff Point Cloud: Implement duplicate operator 2025-02-17 12:11:07 -05:00
Brecht Van Lommel
c7a33a62a2 Cleanup: Directly include DNA_userdef_types.h and BLI_listbase.h
Instead of relying on them being included indirectly.

Pull Request: https://projects.blender.org/blender/blender/pulls/134406
2025-02-12 23:01:08 +01:00
Hans Goudey
54dc692d7b Refactor: Use StringRef for attribute API and BMesh CustomData functions
Replace `const char *` with `StringRef` for the API in `BKE_attribute.h`.
The benefits are slightly simpler code and possibly slightly improved
performance through avoiding the need to measure string length.

Pull Request: https://projects.blender.org/blender/blender/pulls/134183
2025-02-06 21:38:19 +01:00
Brecht Van Lommel
3725fad82f Cleanup: Various clang-tidy warnings in editors
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Laurynas Duburas
8e0c050fa1 Cleanup: Curves: Correct incorrect function name 2025-01-15 11:37:07 -05:00
Hans Goudey
73ff099405 Cleanup: Remove unnecessary casts for PropertyFlag enum type 2025-01-10 15:18:40 -05:00
Hans Goudey
bcfe4c34da Cleanup: Move BVH utils to C++ namespace 2024-12-19 18:22:29 +01:00
Hans Goudey
21aef81714 Cleanup: Use StringRef and std::optional for UI string arguments
- Gives O(1) access to string length in more cases
- Convenient string manipulation functions
- Clarify difference between "no string" and "empty string"
- Avoid the need for raw pointers in the API
- Shows which API string arguments are optional

Pull Request: https://projects.blender.org/blender/blender/pulls/131473
2024-12-06 14:08:10 +01:00
Hans Goudey
024d7d12e2 Mesh: Move BVH storage to shared cache system
Avoid rebuilding BVH trees when meshes are copied.
Similar to the other uses of the shared cache system,
this can arbitrarily improve performance when meshes
are copied but not deformed and BVH building is the
main bottleneck. In a simple test file I got a 6x speedup.

The amount of code is also reduced and the system is
much simpler overall-- built out of common threading
patterns like `SharedCache` with its double-checked lock.
RAII is used in a few places to simplify memory management
too.

The downside is storing more `SharedCache` items in the
mesh runtime struct. That has a slight cost when copying
a small mesh many times, but we have ideas to improve that
in the future anyway (#104327).

Pull Request: https://projects.blender.org/blender/blender/pulls/130865
2024-12-04 00:17:17 +01:00
Sybren A. Stüvel
eaf596c49c Refactor: BLI: Add MutableSpan::contains() function
Add `bool MutableSpan<T>::contains(const T &value)` function, which is an
exact copy of the function from the `Span<T>` class. This makes it possible
to call `.contains()` directly on the `MutableSpan`, instead of having to
call `.as_span()` first.

Note that the `contains_ptr()` function was already copied from `Span` to
`MutableSpan` before.

No functional changes to the affected code, just the removal of the now
no longer necessary `.to_span()` call.

Pull Request: https://projects.blender.org/blender/blender/pulls/131149
2024-11-29 16:28:56 +01:00
Falk David
c8211b23c7 Refactor: Add CurvesGeometry::is_empty() function
Previously, some places used `curves.points_num() == 0` some other
places `curves.curves_num() == 0` to check if the geometry is empty.

Rather than having these two ways, add an `is_empty()` function
that replaces all these different checks.

Also update the curves geometry tests to use this function.

Pull Request: https://projects.blender.org/blender/blender/pulls/130168
2024-11-12 14:46:24 +01:00
Hans Goudey
c7cebf5f6d Curves: Select linked pick operator
This implements the "Select Linked Pick" operator, by default exposed
in the keymap with `L` and `Shift-L`. This mirrors the existing operator
in legacy-curve edit mode and mesh edit mode.

The implementation is pretty simple, we just find the curve closest to
the mouse and change the selection of the points in that curve.

Pull Request: https://projects.blender.org/blender/blender/pulls/129885
2024-11-06 21:25:43 +01:00
Bastien Montagne
c607ead4b7 Refactor: Makesrna: move generated code further in C++.
This commit moves generated `RNA_blender.h`, `RNA_prototype.h` and
`RNA_blender_cpp.h` headers to become C++ header files.

It also removes the now useless `RNA_EXTERN_C` defines, and just
directly use the `extern` keyword. We do not need anymore `extern "C"`
declarations here.

Pull Request: https://projects.blender.org/blender/blender/pulls/124469
2024-07-15 16:39:45 +02:00
Bastien Montagne
f6358f6e71 Merge branch 'blender-v4.2-release' 2024-06-26 19:28:22 +02:00
Damien Picard
26cdf7e340 I18n: Extract many custom labels defined in uiItem*
Those labels needed a manual translation with IFACE_() or RPT_():
  - "Add Item",
  - "Blend",
  - "Cached from the first line art modifier.",
  - "Custom Curve",
  - "Custom Path",
  - "Custom Range",
  - "End",
  - "Enter a Unicode codepoint hex value",
  - "Forward Axis",
  - "Insert Unicode Character",
  - "Mid Level",
  - "Min",
  - "Mode",
  - "No Items",
  - "Object",
  - "Path",
  - "Probability",
  - "Sample Radius",
  - "Sharp edges or custom normals detected, disabling GPU subdivision",
  - "Start",
  - "Texture Mapping",
  - "Up Axis",
  - "Using both CPU and GPU subdivision",
2024-06-26 19:25:20 +02:00
Falk David
0089a90625 Refactor: Attribute API: Remove ID owner dependency
The attribute API defined in `attribute.cc` was dependent on
the assumption that `ID`s are always the "direct" owners of attributes.

For Grease Pencil drawings, this is not the case. The Grease Pencil ID
stores the attributes for layers, and the attributes for drawings are stored
in `CurvesGeometry` on the drawings themselves.

In order to make use of  `rna_attribute.cc`, we need that API to handle
other types of attribute owners.

This adds an `AttributeOwner` which is basically just a type and a
pointer. We replace the `ID` pointers and pass `AttributeOwner`s instead.

For cases where we have to do a switch based on the type, all the
types are handled and the `default` statment is left out. This ensures
that we get a compiler warning when a new `AttributeOwnerType`
is added.

No functional changes expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/122765
2024-06-07 16:42:41 +02:00
Laurynas Duburas
d7b72b4979 Fix: Missing topology update setting curves handle type
If both segment handles are `Vector`, changing their type only changes
handle behavior, but doesn't add curvature to the segment. For `Vector`
segments only one step is designated in the evaluated offsets cache,
so  `all_bezier_offsets` has to be recalculated. As an optimization,
it would be possible to track if there was any `Vector` handle and
rebuild topology only when it is needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/121292
2024-05-01 14:48:52 +02:00
Jacques Lucke
3f2c4db951 Curves: support more curve type conversion options in edit mode
This adds a new `Handles` checkbox to the conversion operator that
affects how the conversion works in the following cases:
`Bezier -> Catmull Rom / Poly / Nurbs` and `Catmull Rom -> Nurbs`.
If enabled, three control points are added for each original control
point, otherwise only one.

-----

The images show the effect of the toggle. The top result is always the one with handles and the bottom one without.
* `Bezier -> Poly`
  ![image](/attachments/c4833568-fb8a-415e-b4fc-a8af2002ded8)
* `Bezier -> Catmull Rom`
  ![image](/attachments/df62e4c0-1a88-4f04-aa82-506bc40765a2)
* `Bezier -> Nurbs`
  ![image](/attachments/3b78d49d-c840-4c15-a342-050fb1f5c3f5)
* `Catmull Rom -> Nurbs`
  ![image](/attachments/de9a4c08-d442-4f97-a0e0-6393b0f0e6de)

Pull Request: https://projects.blender.org/blender/blender/pulls/120423
2024-04-25 10:56:43 +02:00
Jacques Lucke
549d02637a Curves: add menu to add some primitive curves in edit mode
This adds operators to add a bezier and circle primitive in curves
edit mode. The operators support the same settings as in the
legacy curve edit mode. The `shift+A` shortcut is added as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/120513
2024-04-11 15:11:02 +02:00
Jacques Lucke
183ac7d2a2 Fix: update auto bezier handles after toggling cyclic 2024-04-11 11:50:35 +02:00
Jacques Lucke
01ee34ebd1 Curves: add operator to set bezier handle types
This adds an operator to set the handle types of bezier curves. It also
adds the same shortcut that is available in the legacy curve edit mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/120426
2024-04-10 13:08:50 +02:00
Jacques Lucke
619ab92c77 Cleanup: quiet warning 2024-04-05 15:38:49 +02:00
Jacques Lucke
548df007a5 Curves: add subdivide curves edit mode operator 2024-04-05 13:50:09 +02:00
Jacques Lucke
6c25c66194 Curves: add switch direction edit mode operator 2024-04-05 13:23:22 +02:00
Jacques Lucke
23265a2b6d Curves: add edit mode operator to convert curve types
This operator shares the underlying code with the corresponding node.

Pull Request: https://projects.blender.org/blender/blender/pulls/120269
2024-04-04 21:04:51 +02:00
Jacques Lucke
d315a6a793 Curves: add toggle cyclic edit mode operator
This operator also exists in legacy edit mode and allows changing
whether the curve is cyclic. If all curves are non-cyclic, the attribute
is removed because it does not contain any useful information.

Pull Request: https://projects.blender.org/blender/blender/pulls/120266
2024-04-04 19:39:14 +02:00
Laurynas Duburas
4889aed8ac Curves: Bezier handle selection support
Adds ".selection_handle_left" and ".selection_handle_right" attributes to
`CurvesGeometry` and their support in curve's select all, pick, box, circle
and lasso select tools.

Pull Request: https://projects.blender.org/blender/blender/pulls/119712
2024-04-03 16:40:36 +02:00
Hans Goudey
5d09b0d373 Cleanup: Move remaining curves editors functions to C++ namespace 2024-03-27 22:25:08 -04:00
Hans Goudey
c28db1f0a0 Cleanup: Use C++ namespace for object editors module
Move the public functions from the editors/object (`ED_object.hh`)
header to the `blender::ed::object` namespace, and move all of the
implementation files to the namespace too. This provides better code
completion, makes it easier to use other C++ code, removes unnecessary
redundancy and verbosity from local uses of public functions, and more
cleanly separates different modules.

See the diff in `ED_object.hh` for the main renaming changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/119947
2024-03-28 01:30:38 +01:00