Commit Graph

3288 Commits

Author SHA1 Message Date
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
37b95783fa Cleanup: Various clang-tidy warnings in bmesh
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Campbell Barton
c86d3b429e Cleanup: spelling in comments 2025-01-30 14:18:40 +11:00
Howard Trickey
b2998848c5 Fix #109765 - Prevent Dissolve Edges from dissolving verts...
that are unrelated to the selected edge,
See https://projects.blender.org/blender/blender/issues/109765 .
This comes from PR https://projects.blender.org/blender/blender/pulls/131645
by jcwenger.
2025-01-29 16:26:46 -05:00
Campbell Barton
8d97330482 Cleanup: clarify naming for BMesh tangent calculation functions
The newly added "tangent_pair" calculation functions meant the names
didn't read well in some cases, use this style of naming for clarity:

- BM_face_calc_tangent_from_*
- BM_face_calc_tangent_pair_from_*
2025-01-17 15:28:32 +11:00
Campbell Barton
c7104f5392 Fix #96535: Incorrect extrude direction with two faces of a cube
It was possible two quads at right-angles to each other would accumulate
a "tangent" that was co-linear with the it's normal.

Resolve this by calculating two tangents for each face, then using the
accumulated tangent that's least co-linear with the accumulated normal.
2025-01-17 15:17:06 +11:00
Campbell Barton
a586b537af Cleanup: various non-functional changes in C++ 2025-01-17 11:54:43 +11:00
Campbell Barton
bb92a6fbef Fix BMesh quad tangent calculation failure to normalize
This impacted the Python method BMFace.calc_tangent_edge_pair()
2025-01-17 11:31:28 +11:00
Campbell Barton
4e683c4bd6 Cleanup: doxygen formatting for param 2025-01-16 13:04:17 +11:00
Campbell Barton
372ecb847f Fix #108658: Geometry with non-finite coordinates crashes bevel 2025-01-10 16:30:52 +11:00
Brecht Van Lommel
920e709069 Refactor: Make header files more clangd and clang-tidy friendly
When using clangd or running clang-tidy on headers there are
currently many errors. These are noisy in IDEs, make auto fixes
impossible, and break features like code completion, refactoring
and navigation.

This makes source/blender headers work by themselves, which is
generally the goal anyway. But #includes and forward declarations
were often incomplete.

* Add #includes and forward declarations
* Add IWYU pragma: export in a few places
* Remove some unused #includes (but there are many more)
* Tweak ShaderCreateInfo macros to work better with clangd

Some types of headers still have errors, these could be fixed or
worked around with more investigation. Mostly preprocessor
template headers like NOD_static_types.h.

Note that that disabling WITH_UNITY_BUILD is required for clangd to
work properly, otherwise compile_commands.json does not contain
the information for the relevant source files.

For more details see the developer docs:
https://developer.blender.org/docs/handbook/tooling/clangd/

Pull Request: https://projects.blender.org/blender/blender/pulls/132608
2025-01-07 12:39:13 +01:00
Campbell Barton
5003253aca Cleanup: spelling & repeated terms 2025-01-07 13:20:19 +11:00
Campbell Barton
d2d754be3f Cleanup: spelling in comments (make check_spelling*)
- Back-tick quote math expressions so differentiate them
  from English.
- Use doxygen code blocks for TEX expressions.
2025-01-04 16:26:39 +11:00
Campbell Barton
dca0996777 Cleanup: various non-functional changes for C++ 2025-01-02 15:11:20 +11:00
Ray Molenkamp
c331c6b50e Cleanup: CMake: Modernize bf_blentranslation dependencies
Pretty straightforward

- Remove any bf_blentranslation 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/132311
2024-12-25 17:40:25 +01:00
Ray Molenkamp
a7c39896c6 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any bf_blenkernel 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/132282
2024-12-23 20:08:37 +01:00
Ray Molenkamp
2992c63bc3 Cleanup: CMake: Modernize bf_bmesh dependencies
Pretty straightforward

- Remove any bf_bmesh 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/132203
2024-12-23 17:47:25 +01:00
Hans Goudey
3d0988a719 Cleanup: Move some math C-API usage to C++ API
Mostly part of an attempt to remove some of the lesser-used
parts of the C math API.
2024-12-20 21:46:59 +01:00
Hans Goudey
c5ba8bd7c2 Fix #125098: uv_seam attribute not accessible procedurally
When moving UV seams from special custom data types to attributes,
I considered them similar to mesh selection or visibility which are
"internal" attributes that aren't accessible procedurally and are
hidden from the UI. In retrospect that was the wrong decision; users
expect UV seams to behave more like bevel weights, and that makes sense.

This PR makes UV seams accessible in modifiers (geometry nodes) by
removing the leading period from the attribute name that indicated their
internal status.

The change of the attribute name is a breaking change of the API to some
extent, even though it's technically only mesh data. To mitigate that
issue, the `mesh.attributes["name"]` lookup function is modified to
support both the old and new names. Versioning code renames the
attribute to the new name when loading older files, and renames the
new name to the old name when saving files. That handling will be
removed as a breaking change in 5.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/129803
2024-12-20 16:47:15 +01:00
Hans Goudey
31964ef5ca Cleanup: Move BLI_kdopbvh to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/132031
2024-12-17 21:04:55 +01:00
Hans Goudey
f9b627d29c Mesh: Move custom normals to a generic attribute
Move `CD_CUSTOMLOOPNORMAL` to the newly added
`CD_PROP_INT16_2D` generic attribute type. This is similar to
previous commits moving specific custom data types.

The attribute name is `custom_normal`. When the attribute with
that name is on the face corner domain, the code will interpret it
as stored in the existing deformation-invariant spherical coordinate
space.

The API remains the same, with the additional opportunity to edit
custom normal data as an attribute directly (which admittedly is fairly
unintuitive currently).

See #130484.

Pull Request: https://projects.blender.org/blender/blender/pulls/130689
2024-12-04 16:06:36 +01:00
Campbell Barton
b9f055459a Cleanup: ensure trailing space around comment blocks 2024-11-27 19:01:00 +11:00
Campbell Barton
0de8ae8046 Cleanup: spelling in comments 2024-11-25 13:24:46 +11:00
Hans Goudey
c497d5c3fa Refactor: Move quad triangulation function to blenlib
Make this available for a Mesh-based triangulation implementation
implemented elsewhere. Part of #112264.
2024-11-21 08:30:28 -05:00
Campbell Barton
c5272e7857 Cleanup: various non functional changes 2024-11-07 18:21:07 +11:00
Campbell Barton
38a2bb48fb Merge branch 'blender-v4.3-release' 2024-10-31 21:56:52 +11:00
Campbell Barton
2a2ad0c662 Fix error in recent fix for Rotate Edges
k
Commit [0] accidentally removed a check for edges not to rotate.

[0]: a0491899f0
2024-10-31 21:53:18 +11:00
Campbell Barton
fce0e43140 Merge branch 'blender-v4.3-release' 2024-10-31 18:52:17 +11:00
Campbell Barton
a0491899f0 Fix "Rotate Edges" iterating over freed edges
Rotating an edge deletes the edge and creates a new edge
however these edges were being iterated over and had their indices
checked.

In practice this wasn't causing use-after-free errors because the
edges are part of a BLI_mempool, nevertheless using freed elements of a
memory-pool should be avoided.
2024-10-31 18:45:45 +11:00
Rob-Blair
dd334faa58 Fix #125024: Bevel offset - eliminate divide by 0.
From Rob Blair's PR https://projects.blender.org/blender/blender/pulls/126309 .
In the code that clamps the bevel amount, the existing code could get
a denominator of 0 (from a tangent of a certain angle).
This code uses a different calculation (diagram in the PR) that clamps
when the projections of four specific edges onto another edge consumes
the whole length of that edge.
2024-10-30 08:21:51 -04:00
Campbell Barton
160e76cd9d Cleanup: remove unused function BM_mesh_active_elem_index_get
Getting the active index without knowing the element type
doesn't seem to have any practical use.
2024-10-30 15:47:43 +11:00
Campbell Barton
6fae671aa4 Merge branch 'blender-v4.3-release' 2024-10-29 22:48:37 +11:00
Campbell Barton
3f6707efd0 Fix #129401: BMesh.clear() causes crash on garbage collection 2024-10-29 22:47:35 +11:00
Howard Trickey
eba2aff295 Revert "Rob-Blair-ready" - committed before tests ready.
This reverts commit 8b94e21976.
2024-10-22 14:57:56 +02:00
Howard Trickey
8b94e21976 Rob-Blair-ready
Copying PR 126309 from Rob-Blair so that I can try to make the tests pass.

Co-authored-by: Rob-Blair <Rob.Blair@Verizon.net>
Pull Request: https://projects.blender.org/blender/blender/pulls/129313
2024-10-22 14:52:30 +02:00
Campbell Barton
0625756644 Cleanup: remove unused includes 2024-10-17 16:45:39 +11:00
Jason C. Wenger
da689835e8 Fix #129110: Join triangles can assert when topology influence is used
Also add test.

Ref: !129121
2024-10-17 16:21:49 +11:00
Campbell Barton
85e29c4ac4 Refactor: simplify join triangles to quads heap-node lookups
- Replace blender::Map with an array to lookup heap-nodes by edge index.
- Only create the array when the topology influence is used.

These gives ~5-9% overall speedup to operator function.
2024-10-11 23:48:30 +11:00
Bastien Montagne
d70477ad4e Silence compiler warning about struct initialization.
In C++, in most cases empty braces (aka value initilization) are
the best way to initialize to 0/null (or the default values if
specified in the class/struct declaration).
2024-10-10 11:15:26 +02:00
Campbell Barton
c9b7f22e98 Cleanup: use a structure to store edge neighbor for join triangles
Replace 3x arguments and a return value with a structure
that stores the neighboring edges & loops.

Also call add_without_duplicates from a loop instead of inlining.
2024-10-10 18:33:36 +11:00
Jason C. Wenger
dc57693b0c Modeling: add support for merging triangles with reference to topology
A new parameter, topology influence, is added that causes the
join_triangles operator to prioritize edge joins that create quads with
sensible geometry relative to existing quads, instead of selecting the
'flattest' and 'squarest' next pair and then leaving leftover triangles
with no partners to merge with.

This produces its best results with the face and shape thresholds set to
180 degrees (no hard limits as a restriction against merging) and
topology influence somewhere between 100-130%, depending on the mesh.
Too low and many parallelograms and triangles are left, too high and the
algorithm tries too hard and starts making errors.

Note that both quads already present in the selection, as well as the
quads that are generated during the operator, will influence the
topology around them. This allows the modeler to manually merge a few
quads in key areas of the mesh, as a hint to the algorithm, indicating
what result they way they want to see, and the algorithm will then take
those quads into account and try to build around them according to the
modeler's guidance.

A new checkbox to leave only the remaining triangles selected has also
been added. This helps users visualize what remains to be fixed.

Ref !128610
2024-10-10 17:28:59 +11:00
Jason C. Wenger
262d32b694 Cleanup: improve comments & add error checking asserts
Ref !128610
2024-10-07 12:52:34 +11:00
Jason C. Wenger
a9e9c56151 Cleanup: extract delimit data creation into a function for join tris
Part of !128224.
2024-10-03 18:03:38 +10:00
Campbell Barton
414e8984e5 Cleanup: replace goto with return values 2024-10-03 17:12:37 +10:00
Campbell Barton
569683aa90 Cleanup: don't use float return type for boolean checks 2024-10-03 17:10:31 +10:00
Jesse Yurkovich
1dbf75ff52 Cleanup: Remove BLI_array macros in bmesh edgenet
This replaces the older dynamic c array macros with blender::Vector in
bmesh_polygon_edgenet. This is the only remaining use of the old array
machinery and removal of `BLI_array.h / .c` can happen immediately
afterwards.

See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/119975
2024-09-21 23:59:14 +02:00
Campbell Barton
0fc27c8d81 Cleanup: spelling in comments 2024-09-20 13:14:57 +10:00
Hans Goudey
22cf74d23b Cleanup: Use C++ Array for dependent shape key data
Avoids manual memory management and potentially avoids
an allocation with the inline buffer.
2024-09-16 12:46:54 -04:00
Mike93
cc5ed48cd3 Modifiers: Add custom attribute weight support to bevel modifier
As of 2a56403cb0, bevel weight data is stored as a generic
attribute. The bevel modifier is currently hard-coded to use the
`bevel_weight_edge` attribute as the data source for the weights.
This commit adds a string textbox where the user can specify alternate
attributes for the bevel's edge weights.

The string name field is added as a search button which provides a list
of all attributes in the original mesh. This is meant to work similarly
to geometry nodes, so mismatched attribute data types and domains are
automatically converted/interpolated as necessary. Attributes created
by previous modifiers can also be used, but they won't appear in the
search menu.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/117366
2024-09-05 17:15:34 +02:00