Commit Graph

110 Commits

Author SHA1 Message Date
Hans Goudey 7c01355cad Cleanup: Use forward declaration headers in a few places 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
Hans Goudey c61ecf1f40 Cleanup: Move Mesh edit_mesh pointer to runtime data
The edit mesh is never saved to files, so it should be in the runtime struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/119766
2024-03-21 23:18:49 +01:00
Brecht Van Lommel f20d9fe5a5 Merge branch 'blender-v4.1-release' 2024-03-19 18:05:33 +01:00
Brecht Van Lommel f771a8563b Fix #110751: Crash baking grease pencil line art
Ensure depsgraph tag happens when strokes are cleared, otherwise the
next depsgraph evaluation tries to use freed stroke data.

Pull Request: https://projects.blender.org/blender/blender/pulls/119662
2024-03-19 17:59:19 +01:00
Brecht Van Lommel 7a395e2e7f Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was f57e4c5b98.

After this one more fix was committed, this one is preserved as well:
67bd678887.
2024-03-18 15:04:12 +01:00
Campbell Barton f3e0e39df5 Cleanup: use const pointers where camera data isn't modified 2024-03-08 17:15:08 +11:00
YimingWu 3dc483982c GPv2: LineArt: Conversion code
Adds conversion code for the lineart modifier for Grease Pencil 3.

Pull Request: https://projects.blender.org/blender/blender/pulls/118791
2024-02-29 16:02:44 +01:00
Campbell Barton 6c78f79740 Cleanup: pass matrices by reference instead of value 2024-02-28 17:16:18 +11:00
YimingWu 9e143968d3 LineArt: Fix back transformation issue for v3
Line art v3 strokes should not move along with the grease pencil object
to keep the same behaviour as the old line art. Now fixed.
2024-02-27 13:07:47 +08:00
YimingWu 3d1cdfe2ca GPv3: Line Art Modifier
This is a migration of the current Line Art modifier to GPv3.

Note:
- The modifier is using the exact same DNA structure as the old one, it's re-defined in a different name. At the moment all the variable names and placement after the `ModifierData` part should stay exactly the same until we do proper versioning of the modifier data and completely remove the GPv2 support.
- Vertex weight transfer feature no longer supports name initial matching ("group" used to match "group1","group2" etc). Now it will only transfer vertex weight from source vertex groups that has the exact same name as specified.

Pull Request: https://projects.blender.org/blender/blender/pulls/117028
2024-02-26 15:28:15 +01:00
Jeroen Bakker 582be5e315 Cleanup: Make format 2024-02-26 14:44:56 +01:00
Miguel Pozo 1446b05ca4 Merge branch 'blender-v4.1-release' 2024-02-26 12:51:59 +01:00
YimingWu e938b516a9 Fix #118425: LineArt: ensure long edges are shown
Line art used to not calculate edges where both ends are outside image
frame, this will lead to missing edges in some cases where the model is
scaled up pretty big. Now it ensures those edges are still preserved.

Pull Request: https://projects.blender.org/blender/blender/pulls/118448
2024-02-26 04:50:48 +01:00
YimingWu 0a339231ec Fix #118547: LineArt: Handle shadow segments with 0 length
Line art shadow projection will cut lines indefinitely when it
encounters a edge segment with 0 length. In the case of #118547, it was
caused by the combination bevel modifier and the view angle. This fix
ensures that no such edge is worked on further.

Pull Request: https://projects.blender.org/blender/blender/pulls/118613
2024-02-26 03:53:21 +01:00
Brecht Van Lommel 0f2064bc3b Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was 4bf6a2e564.
2024-02-19 15:59:59 +01:00
Campbell Barton 5c87dfd269 Cleanup: use BLI_time_ prefix for time functions
Also use the term "now" instead of "check" for clarity.
2024-02-15 13:15:56 +11:00
Hans Goudey 1c0f374ec3 Object: Move transform matrices to runtime struct
The `object_to_world` and `world_to_object` matrices are set during
depsgraph evaluation, calculated from the object's animated location,
rotation, scale, parenting, and constraints. It's confusing and
unnecessary to store them with the original data in DNA.

This commit moves them to `ObjectRuntime` and moves the matrices to
use the C++ `float4x4` type, giving the potential for simplified code
using the C++ abstractions. The matrices are accessible with functions
on `Object` directly since they are used so commonly. Though for write
access, directly using the runtime struct is necessary.

The inverse `world_to_object` matrix is often calculated before it's
used, even though it's calculated as part of depsgraph evaluation.
Long term we might not want to store this in `ObjectRuntime` at all,
and just calculate it on demand. Or at least we should remove the
redundant calculations. That should be done separately though.

Pull Request: https://projects.blender.org/blender/blender/pulls/118210
2024-02-14 16:14:49 +01:00
Campbell Barton 0e4f9104bc Cleanup: unused includes in source/blender/gpencil_modifiers_legacy
Remove 159 includes.
2024-02-13 19:59:14 +11:00
Bastien Montagne 5aaadebbe4 Cleanup: Make `BKE_scene.h` a full Cpp header. 2024-02-10 19:16:25 +01:00
Bastien Montagne 29fe777445 Cleanup: Make `BKE_report.h` a full Cpp header. 2024-02-10 18:34:29 +01:00
Bastien Montagne 54618dbae3 Cleanup: Make `BKE_global.h` a Cpp header. 2024-02-10 18:25:14 +01:00
Bastien Montagne e71ae3b16c Cleanup: Move `BKE_collection.h` to CPP header. 2024-02-09 19:42:38 +01:00
Bastien Montagne 45e7827898 Clenup: Move BLT headers to Cpp.
Noisy but fairly straight forward.
2024-02-09 18:59:42 +01:00
Hans Goudey c87e51790d Cleanup: Make format 2024-01-31 22:01:30 -05:00
Hans Goudey fac27b1b6b Cleanup: Replace most used of SWAP macro with std::swap
Also remove / replace use of the math vector double swapping functions.
2024-01-31 21:12:16 -05:00
Hans Goudey 961783c444 Cleanup: Move BKE_deform.h to C++ 2024-01-29 19:04:13 -05:00
YimingWu f2d08d2cbe Fix #104982: Ensure view layer when baking line art.
This is more like a hack, which ensures view layer depsgraph evaluation
when baking line art. It should fix the problem where the camera marker
switch would cause `view_layer->object_bases_array == null`.

Pull Request: https://projects.blender.org/blender/blender/pulls/117227
2024-01-25 04:33:37 +01:00
Hans Goudey 0618de49ad Cleanup: Replace MIN/MAX macros with C++ functions
Use `std::min` and `std::max` instead. Though keep MIN2 and MAX2
just for C code that hasn't been moved to C++ yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/117384
2024-01-22 15:58:18 +01:00
Jacques Lucke 4b47b46f9c Cleanup: rename PIL to BLI
The term `PIL` stands for "platform independent library." It exists since the `Initial Revision`
commit from 2002. Nowadays, we generally just use the `BLI` (blenlib) prefix for such code
and the `PIL` prefix feels more confusing then useful. Therefore, this patch renames the
`PIL` to `BLI`.

Pull Request: https://projects.blender.org/blender/blender/pulls/117325
2024-01-19 14:32:28 +01:00
Bastien Montagne 03c1cc4310 Cleanup: Move `BKE_lib_query` header to Cpp era. 2024-01-18 12:21:19 +01:00
Hans Goudey 3e76a1a6c2 Cleanup: Move BKE_lib_id.h to C++ 2024-01-15 12:44:14 -05:00
Damien Picard 3bd41cf9bc I18n: Go over TIP_ and IFACE_ usages, change to RPT_ when relevant
The previous commit introduced a new `RPT_()` macro to translate
strings which are not tooltips or regular interface elements, but
longer reports or statuses.

This commit uses the new macro to translate many strings all over the
UI.

Most of it is a simple replace from `TIP_()` or `IFACE_()` to
`RPT_()`, but there are some additional changes:
- A few translations inside `BKE_report()` are removed altogether
  because they are already handled by the translation system.
- Messages inside `UI_but_disable()` are no longer translated
  manually, but they are handled by a new regex in the translation
  system.

Pull Request: https://projects.blender.org/blender/blender/pulls/116804

Pull Request: https://projects.blender.org/blender/blender/pulls/116804
2024-01-12 13:37:32 +01:00
Brecht Van Lommel d377ef2543 Clang Format: bump to version 17
Along with the 4.1 libraries upgrade, we are bumping the clang-format
version from 8-12 to 17. This affects quite a few files.

If not already the case, you may consider pointing your IDE to the
clang-format binary bundled with the Blender precompiled libraries.
2024-01-03 13:38:14 +01:00
Aras Pranckevicius fec8461365 Cleanup: move BKE_colorband.h and BKE_colorcools.h to .hh
Also remove includes of those where not needed

Pull Request: https://projects.blender.org/blender/blender/pulls/116416
2023-12-21 10:10:53 +01:00
Hans Goudey b9b47088bc Cleanup: Remove unnecessary DNA_meshdata_types.h includes
Except for vertex groups and a few older color types, these
are generally replaced by newer generic attribute types.
Also remove some includes of DNA_mesh_types.h, since it's
included indirectly by BKE_mesh.hh currently.
2023-12-20 20:58:38 -05:00
Hans Goudey 19001c9e6c Cleanup: Move attribute domain enum to C++ header, use enum class
Each value is now out of the global namespace, so they can be shorter
and easier to read. Most of this commit just adds the necessary casting
and namespace specification. `enum class` can be forward declared since
it has a specified size. We will make use of that in the next commit.
2023-12-20 13:25:28 -05:00
Hans Goudey efbee2d606 Mesh: Rename totvert, totedge, and totloop fields
Use the standard "elements_num" naming, and use the "corner" name rather
than the old "loop" name: `verts_num`, `edges_num`, and `corners_num`.
This matches the existing `faces_num` field which was already renamed.

Pull Request: https://projects.blender.org/blender/blender/pulls/116350
2023-12-20 02:21:48 +01:00
Hans Goudey 7c69c8827b Mesh: Rename MLoopTri variable names, and functions
Make the naming consistent with the recent change from "loop" to
"corner". Avoid the need for a special type for these triangles by
conveying the semantics in the naming instead.

- `looptris` -> `corner_tris`
- `lt` -> `tri` (or `corner_tri` when there is less context)
- `looptri_index` -> `tri_index` (or `corner_tri_index`)
- `lt->tri[0]` -> `tri[0]`
- `Span<MLoopTri>` -> `Span<int3>`
- `looptri_faces` -> `tri_faces` (or `corner_tri_faces`)

If we followed the naming pattern of "corner_verts" and "edge_verts"
exactly, we'd probably use "tri_corners" instead. But that sounds much
worse and less intuitive to me.

I've found that by using standard vector types for this sort of data,
the commonalities with other areas become much clearer, and code ends
up being naturally more data oriented. Besides that, the consistency
is nice, and we get to mostly remove use of `DNA_meshdata_types.h`.

Pull Request: https://projects.blender.org/blender/blender/pulls/116238
2023-12-19 14:57:49 +01:00
Campbell Barton 944e0483a6 Cleanup: clarify naming for MLoopTri
The term `looptri` was used ambiguously for both single & arrays.
The term `tri` was also used, causing `tri->tri`.

Use terms:

- `looptris` for an array or when dealing with multiple items.
- `looptri` is used when dealing with a single item.
- `lt` for a single MLoopTri variables & arguments.

This was already a convention but not followed closely.
2023-12-14 12:32:11 +11:00
Hans Goudey b52a071e7a Cleanup: Remove unnecessary Mesh C-API functions
Like mentioned in the docstrings, use the C++ API or access methods
in C++ code.
2023-12-13 08:40:21 -05:00
Hans Goudey c53e220aef Cleanup: Use C++ attribute API instead of CustomData API
This gives better asserts in debug builds through use of Span, more
safety when name convention attributes happen to have different types
or domains, and simpler code in some cases. But the main reasoning is to
avoid relying on the specifics of CustomData more to allow us to replace
it in the future.
2023-12-12 18:23:59 -05:00
Hans Goudey 854cdd1180 Cleanup: Use consistent "mesh" variable name (replace "me")
"mesh" reads much better than "me" since "me" is a different word.
There's no reason to avoid using two more characters here. Replacing
all of these at once is better than encountering it repeatedly and
doing the same change bit by bit.
2023-12-08 16:40:06 -05:00
Bastien Montagne 3acb64e7ac BKE_main: move header to be a fully CPP one.
Pull Request: https://projects.blender.org/blender/blender/pulls/115681
2023-12-01 20:38:54 +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
Hans Goudey 19b9b8d431 Cleanup: Move mesh looptri real edges function 2023-11-28 16:49:55 -05:00
Hans Goudey 7e3ba529ea Cleanup: Move four blenkernel headers to C++ 2023-11-28 16:05:12 -05:00
Hans Goudey 3d57bc4397 Cleanup: Move several blenkernel headers to C++
Mostly focus on areas where we're already using C++ features,
where combining C and C++ APIs is getting in the way.

Pull Request: https://projects.blender.org/blender/blender/pulls/114972
2023-11-16 11:41:55 +01:00
Hans Goudey 7b51d32dd9 Cleanup: Move BKE_modifier.h to C++ 2023-11-14 09:30:40 +01:00
Pratik Borhade 270fc860cf Fix #114685: GP time offset modifier doesn't work if the animation is 1 frame long
This is due to the early return of current frame when start and end of
custom range is same
2023-11-10 16:07:05 +05:30