Commit Graph

4614 Commits

Author SHA1 Message Date
Campbell Barton
5fc3303a35 Fix assert drawing the knife tool points with the Vulkan backend
Using the knife tool with Vulkan failed because using
GPU_PRIM_POINTS isn't supported with the GPU_SHADER_3D_UNIFORM_COLOR
shader.

Resolve using a shader intended for drawing points.

Ref !136109
2025-03-18 22:36:13 +11:00
Campbell Barton
ff8baa6791 Cleanup: pass BMUVOffsets by const reference 2025-03-13 17:06:32 +11:00
Campbell Barton
78c3f6a1ee Cleanup: adjust order of terms for BMesh UV map function calls
Order more generic terms first for better ordering, more useful
completion.
2025-03-13 15:23:46 +11:00
Campbell Barton
6ef7dae8ef Cleanup: spelling in comments (make check_spelling_*) 2025-03-13 13:41:17 +11:00
Germano Cavalcante
6aeda6edaa Merge remote-tracking branch 'origin/blender-v4.4-release' 2025-03-08 10:19:49 -03:00
Germano Cavalcante
bd9dce74c0 Fix #135564: 'Cycle edges' on the Knife tool not working
Due to recent code changes, `knife_calculate_snap_ref_edges` relied on
the (not yet computed) `kcd->curr.mval` to compute the raycast ray.

The solution is to pass the computed ray right before.

Also `knife_snap_update_from_mval` is now called on the modal to update
the edge as soon as the button is pressed.

Pull Request: https://projects.blender.org/blender/blender/pulls/135649
2025-03-08 14:16:34 +01:00
Campbell Barton
9259ebbc0f Merge branch 'blender-v4.4-release' 2025-03-06 12:50:04 +11:00
Campbell Barton
f6f53551ff Fix invalid tessellation after vertex smooth with mirror enabled
Smoothing vertices with symmetry wasn't recalculating normals
before re-tessellating, meaning the faces would use an incorrect
2D projection for tessellation.

The error was exposed by an assert.
2025-03-06 12:48:39 +11:00
Campbell Barton
d951428422 Cleanup: spelling in comments
Address warnings from check_spelling.py
2025-03-06 10:49:51 +11:00
Bastien Montagne
dd168a35c5 Refactor: Replace MEM_cnew with a type-aware template version of MEM_callocN.
The general idea is to keep the 'old', C-style MEM_callocN signature, and slowly
replace most of its usages with the new, C++-style type-safer template version.

* `MEM_cnew<T>` allocation version is renamed to `MEM_callocN<T>`.
* `MEM_cnew_array<T>` allocation version is renamed to `MEM_calloc_arrayN<T>`.
* `MEM_cnew<T>` duplicate version is renamed to `MEM_dupallocN<T>`.

Similar templates type-safe version of `MEM_mallocN` will be added soon
as well.

Following discussions in !134452.

NOTE: For now static type checking in `MEM_callocN` and related are slightly
different for Windows MSVC. This compiler seems to consider structs using the
`DNA_DEFINE_CXX_METHODS` macro as non-trivial (likely because their default
copy constructors are deleted). So using checks on trivially
constructible/destructible instead on this compiler/system.

Pull Request: https://projects.blender.org/blender/blender/pulls/134771
2025-03-05 16:35:09 +01:00
Clément Foucault
1b902e305c Refactor: Select: Use IndexRange for the element selection
This cleanup naming convention and code clarity. There
is no functional change.

- `elem_ranges` is changed to a `Map` to avoid relying on
`sel_data->drawn_index`.
- `select_draw_utils.cc` is merged with `select_engine.cc`
- `index_drawn_len` is renamed to `max_index_drawn_len`
- Remove the usage of `DrawData`

Rel #134690

Pull Request: https://projects.blender.org/blender/blender/pulls/134940
2025-02-25 14:40:04 +01:00
Hans Goudey
322b4624d5 Fix: Use matching attribute name for multi-object "Set Attribute"
Currently these operators work on the active attribute for each
selected mesh or curves data-block. That doesn't really make
sense because you can only see the active attribute for the
active data-block. It's better to try to affect the attribute with
the same name for every geometry, regardless of which is active.

Pull Request: https://projects.blender.org/blender/blender/pulls/135067
2025-02-25 01:36:35 +01:00
Hans Goudey
d0a6189b50 Refactor: DRW: Centralize and clean up packed normals conversion
Move the code dealing with converting float3 to GPU normals
out of the vertex format header into a separate header. Use a
proper C++ namespace and remove duplication by only using
the more recently added C++ templated conversions.

Most of the diff comes from the removal of the indirect includes
from GPU_vertex_format.hh. A lot of files ended up mistakenly
depending on that.

Pull Request: https://projects.blender.org/blender/blender/pulls/134873
2025-02-24 16:08:30 +01:00
Campbell Barton
a7924c3b65 Cleanup: quiet unused variable warning in release builds 2025-02-18 13:28:36 +11:00
Jason C. Wenger
59d72a8f7d Mesh: grid-fill now supports replacing existing faces
The existing behavior of the grid fill operator requires a loop of
boundary or wire edges to be selected. This algorithm tries to fit a
grid of quads into the edge loop. It also works if you select two of the
four 'rails' of an edge loop.

This new behavior allows running grid fill after selecting faces.
If the algorithm sees that a set of faces are selected, it separates
all the faces, and then attempts to grid from their exterior boundary
using the exact same logic it normally uses for interior boundaries.
This all assumes the user has selected a set of faces with an outside
border that works with grid fill. (has one clear exterior loop with an
even number of edges) If not, grid fill will halt, and notify the user
of the error, exactly the way that it already did before.
Once the grid fill is complete and successful,
the existing faces which were replaced get deleted.

UVs (including at UV island boundaries) are interpolated properly,
as are custom-data on verts, edges, faces, and face corners.
At the edges of the selection, the edges/faces/face corners that are
selected contribute, but the custom-data outside the selection does not.

This also resolves non-deterministic behavior.
The previous behavior of `edbm_grid_fill_prepare` found the vertex with
the largest angle, then walked the edge loop until it found one out of
the three best remaining corners. This established one edge of the grid
area, and the second edge was found by symmetry.
However, the direction that the algorithm walked the loop
(and therefore which second corner was found) was essentially arbitrary.

The new behavior first finds the vert with the largest angle,
then finds the vert with the second largest angle,
(after excluding the diagonally opposite corner from the first vert),
and selects the edge between those two verts.

Ref !129318.
2025-02-18 12:40:00 +11:00
Hans Goudey
b4c9b3e87f Cleanup: Move transform editors module to C++ namespace
Pull Request: https://projects.blender.org/blender/blender/pulls/134701
2025-02-18 01:27:04 +01:00
Hans Goudey
947658d1b2 Refactor: Simplify CustomData functions by requiring ImplicitSharingInfo
Previously we generally expected CustomData layers to have implicit
sharing info, but we didn't require it. This PR clarifies that we do
require layers with non-null data to have implicit sharing info. This
generally makes code simpler because we don't have to have a separate
code path for non-shared layers. For example, it makes the "totelem"
arguments for layer freeing functions unnecessary, since shared data
knows how to free itself. Those arguments are removed in this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/134578
2025-02-17 19:44:54 +01:00
Hans Goudey
2e22be10f8 Cleanup: Missing custom data implicit sharing info in edit mesh undo
The missing sharing info shouldn't cause crashes currently, but since this
is the one place that CustomData is built "manually" it's better to do the
standard thing and create it.
2025-02-14 13:45:44 -05:00
Campbell Barton
640e70b6e8 Cleanup: various non-functional changes for C++ 2025-02-13 13:33:09 +11: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
Bastien Montagne
87a4c0d3a8 Refactor: Make Library.runtime an allocated pointer.
Move `Library.runtime` to be a pointer, move the related
`LibraryRuntime` struct to `BKE_library.hh`. Similar to e.g.
Mesh.runtime, that pointer is expected to always be valid, and is
allocated at readtime or when creating a new Library ID.

Related smaller changes:
* Write code now uses standard ID writing codepath for Library IDs too.
  * Runtime pointer is reset to nullptr before writing.
* Looking up a library by its absolute path is now handled through a
  dedicated utils, `search_filepath_abs`, instead of using
  `BLI_findstring`.

Pull Request: https://projects.blender.org/blender/blender/pulls/134188
2025-02-07 17:47:16 +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
Philipp Oeser
eecf5787c1 Fix #119932: Weight paint loop selection fails when bones are rotated
Previous approach was using non-evaluated meshes to find the closest edge from a face index retrieved from the selection buffer.
This can fail though if the mesh is deformed or even altered to not have the same indices anymore (e.g. generating/masking modifiers).

In order to make this work, added `ED_mesh_pick_edge` which switches the selection context to edges directly
and picks from those. No need to map anything back and forth between original and evaluated, the selection buffer contains the original indices already.

Further logic (following the face loop) is untouched (and happens on the original geometry which is fine)

Should go into 4.2 LTS as well

Pull Request: https://projects.blender.org/blender/blender/pulls/132803
2025-02-05 15:13:48 +01:00
Hans Goudey
b5e5d4b335 Fix #134108: Set attribute operator crash with multiple objects
Caused by 0089a90625.
2025-02-05 08:19:01 -05:00
Hans Goudey
fc1fe4e78c Cleanup: Rename object materials "test" functions
"test" wasn't descriptive. Rename that part to "sync_length".
Also expose documentation from the function implementation
to describe what the functions do.

Pull Request: https://projects.blender.org/blender/blender/pulls/134058
2025-02-04 17:46:08 +01:00
Campbell Barton
007d46ef6d Cleanup: rename "opengl" to "gpu" for 3D viewport utilities 2025-02-04 21:19:28 +11:00
Germano Cavalcante
1a362429e8 Knife: Improve precision at knife line intersections 2025-02-03 20:16:55 -03:00
Germano Cavalcante
1aaf16641a Refactor: Knife - Pass 'mval' and related as params instead in the struct 2025-02-03 20:16:54 -03:00
Germano Cavalcante
60c7c5483f Refactor: Knife - Remove redundant redraw calls
And avoid excessive calls to `knife_update_mval`, as this function is
computationally expensive
2025-02-03 20:16:54 -03:00
Harley Acheson
f631607df4 UI: Status Bar Confirm Then Cancel
When displaying keymaps on the Status Bar we prefer to show Confirm and
then Cancel.  We have a few places where these are reversed
accidentally. This just makes these consistent with the rest.

Pull Request: https://projects.blender.org/blender/blender/pulls/133947
2025-02-03 01:17:12 +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
Germano Cavalcante
40298880b5 Fix #113685: Knife precision penalized by long-distance constraints
Precision in knife operations is greatly impacted when projecting a 3D
coordinate to 2D in screen space.

This happened for example when performing constraint operations, where
only the mval of the constrained position was used for snapping.

To solve this problem, the constrained position is now used to
calculate the ray_orig and ray_dir used in snap operations.

Now, a ray_orig and ray_dir are calculated whenever an mval is
set and can be adjusted later when setting a constraint.

Ref !131764
2025-01-28 18:24:58 +11:00
Jason C. Wenger
7070c781b9 Fix select shortest path failing to set the active faces material
Now the active material stays in sync with the active face,
so it's consistent with other kinds of selection picking.

Ref: !133593
2025-01-28 17:26:37 +11:00
Alaska
3e11cfb1d0 Fix #133591: Bevel profile shape name did not match between redo and status bar
Update the name of the Profile shape variable for the bevel tool
in edit mode to be `Profile Shape` in both the redo panel and
status bar.

Pull Request: https://projects.blender.org/blender/blender/pulls/133598
2025-01-26 04:29:30 +01:00
Bastien Montagne
9c237af041 Refactor: RNA: add discrete suffix to RNA_pointer_create.
This is a noisy preliminary step to the 'RNA ancestors' change. The
rename helps clearly tell what each `pointer_create` function does.

Pull Request: https://projects.blender.org/blender/blender/pulls/133475
2025-01-24 16:45:32 +01:00
Philipp Oeser
c0e881cebf Sculpt: avoid adding ".sculpt_mask" attributes in certain cases
Mask layers were added (unnecessarily) in these cases:
- calling `Mask Slice` without having a mask even (now return
`OPERATOR_CANCELLED` early)
- calling `Mask Extract` without having a mask even (now return
`OPERATOR_CANCELLED` early)
- `Extract Face Set` was also adding a mask layer (only because both
extracts used `geometry_extract_apply`), moved mask specific stuff into
`paint_mask_extract_exec` (see above also)

Came up in !123888

Pull Request: https://projects.blender.org/blender/blender/pulls/133435
2025-01-22 15:25:25 +01:00
Nika Kutsniashvili
9d5a4756ca UI: Use gizmo theme colors for knife tool overlay
Knife Tool overlays were using NURBS theme colors,
make it use gizmo colors instead.

More details and screenshots in the PR.

Fixes #126867

Pull Request: https://projects.blender.org/blender/blender/pulls/133395
2025-01-22 12:57:46 +01:00
Philipp Oeser
517aa5bfe2 Fix #113760: Knife Tool: wrong red point after undo
After confirming a cut, the tool goes into `MODE_IDLE`.
In `knifetool_undo`, the `KnifePosData` `prev` (drawn as the "red point"
in question in `knifetool_draw`) was only set to the `KnifeUndoFrame`
pos when we are in `MODE_DRAGGING` though -- this is now changed to also
be done for `MODE_IDLE`.

NOTE: it might be questionable to even draw this bigger red dot once a
cut is confirmed (will attach another small diff to the PR that does
this)

Pull Request: https://projects.blender.org/blender/blender/pulls/133430
2025-01-22 12:14:51 +01:00
Harley Acheson
8953cc5045 UI: Improved Initial Message for Mesh Bisect
When first starting the Mesh Bisect operator, the Status Bar shows
"LMB: Click and drag to draw cut line". This PR just changes that to
show the message with an icon instead. And adds "Cancel".

Pull Request: https://projects.blender.org/blender/blender/pulls/133244
2025-01-19 00:49:52 +01:00
Pratik Borhade
5726a998a0 Fix #133151: Display "Depth" in status bar for inset operator keymap
Depth property of inset operator had wrong text displayed in status
bar. Should be "Depth" instead of "Tweak". Was changed in error in
commit 42a8947eb1.

Pull Request: https://projects.blender.org/blender/blender/pulls/133230
2025-01-18 19:35:44 +01:00
Pablo Vazquez
9081674e8c Fix: UI: Use title case for items in status bar
Missed these in the recent pull request review.
2025-01-17 12:10:46 +01:00
Harley Acheson
8ad3653112 UI: Improve Status Bar Display for Mesh Point Normals
Mesh Edit Mode / Mesh Menu / Normals / Point to Target... operator
shows keymap entries on the area header and in the status bar. This PR
removes the area header drawing and improves the Status bar using the
current pattern, including showing statuses with reversed items.

Pull Request: https://projects.blender.org/blender/blender/pulls/131586
2025-01-17 00:31:37 +01:00
Hans Goudey
c6f5c44350 Cleanup: Remove unused includes in editors modules
Pull Request: https://projects.blender.org/blender/blender/pulls/133166
2025-01-16 23:17:51 +01:00
Campbell Barton
81c26130dc Fix #43998: toggling edit-mode can destroy mesh shape-key
Regression in [0] that clamped the shape-key index when exiting
edit-mode but not when entering, causing the "Basis" shape not to
be treated as active when entering edit-mode, then treated as active
when exiting - overwriting it's values from the mesh.

Resolve by clamping on edit-mode enter & exit.

[0]: 225e3460d0
2025-01-16 16:36:50 +11:00
Damien Picard
f67911cb47 I18n: Disambiguate "Fill"
- In the context of mesh extrusion, "Fill" means "Fill the rim of an
  extruded edge loop" (verb).
- In the context of the file browser, it means select every file
  between beginning and end.
- In the context of an image, fill the tile with  generated image.

Issue reported by Hoang Duy Tran.
2025-01-13 12:40:45 +01:00
Falk David
d413b0064f Cleanup: Move BKE_material.h to C++
The `BKE_material.h` is only renamed to `.hh` to preserve
the history of the file. Changes to the file are done in
the following commit.
2025-01-09 18:11:46 +01:00
Campbell Barton
8ab4e8c7ad Fix crash in weight paint's loop selection
Finding the closest edge could use an uninitialized value.

Part of #119932.

Co-authored-by: Philipp Oeser <philipp@blender.org>
2025-01-09 10:36:06 +11:00
Campbell Barton
7e8dcf77db Cleanup: pass UnitSettings as a const reference 2025-01-08 21:22:45 +11:00
Campbell Barton
e949ff7334 Fix unit scale use when when units were disabled
UnitSettings::scale_length was used to scale reported
values for operators (translate, shrink-fatten, voxel-size).

This isn't expected as the value isn't editable when the unit-system
is set to None.

Add BKE_unit_value_as_string_scaled utility function for clarity &
to ensure scaling is only applied when it should be.
2025-01-08 21:07:23 +11:00
Campbell Barton
fc6702ccc7 Edit Mesh: increase the hard-max for select similar
For large scenes, a much larger threshold is sometimes needed.

Ref #81542.
2025-01-08 18:25:38 +11:00