Commit Graph

114 Commits

Author SHA1 Message Date
Jaume Bellet a8aba3f8f4 Ok 2023-11-22 22:50:16 +01: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 4bcdc57fc8 Refactor: Move object runtime data to separate allocation
Move object runtime data to a separate header and allocate it separately
as `blender::bke::ObjectRuntime`. This is how node, mesh, curves, and
point cloud runtime data is stored.

Benefits:
- Allow using C++ types in object runtime data
- Reduce space required for Object struct in files
- Increase conceptual separation between DNA and runtime data
- Remove the need to add manual padding in runtime data
- Include runtime struct definition only in files that require it

Pull Request: https://projects.blender.org/blender/blender/pulls/113957
2023-11-15 18:46:07 +01:00
Campbell Barton 6bba008325 Cleanup: format 2023-11-09 09:34:49 +11:00
Martijn Versteegh 596aab27bd Merge branch 'blender-v4.0-release' 2023-11-08 21:32:30 +01:00
Falk David f6655ab06c Fix #114453: Grease Pencil shows up as "Grease Pencil (legacy)" in some places
In Blender 4.0 Grease Pencil was showing up as "Grease Pencil (legacy)" in the UI in some places.
Since the current Grease Pencil is not replaced yet, it shouldn't be named this way in 4.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/114531
2023-11-08 14:59:22 +01:00
Brecht Van Lommel 39107b3133 Revert changes from main commits that were merged into blender-v4.0-release
The last good commit was 8474716abb.

After this commits from main were pushed to blender-v4.0-release. These are
being reverted.

Commits a4880576dc from to b26f176d1a that happend afterwards were meant for
4.0, and their contents is preserved.
2023-10-30 21:40:35 +01:00
Campbell Barton e7e4e63313 Cleanup: spelling in comments, white-space in comments 2023-10-19 18:53:16 +11:00
Miguel Pozo 1ba16edaf0 EEVEE-Next: Rename light probes
Update to the new naming convention for `Light Probes`:

`Reflection Cubemap` -> `Sphere`
`Reflection Plane` -> `Plane`
`Irradiance Grid` -> `Volume`

Note that this breaks the Python API (`bpy.types.LightProbe.type`).

Pull Request: https://projects.blender.org/blender/blender/pulls/113452
2023-10-11 19:38:42 +02:00
Hans Goudey 976eaae02f Cleanup: Move BKE_object.hh to C++
Simplifies the fix to #111120, where the object bounds functions
may return a C++ type instead of `BoundBox`.

Pull Request: https://projects.blender.org/blender/blender/pulls/113462
2023-10-09 23:41:53 +02:00
Campbell Barton e38ff7c06d Cleanup: use C++ comments for disabled code 2023-09-25 17:06:04 +10:00
Hans Goudey 867f99c2af Cleanup: Move depsgraph headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/110816
2023-09-22 03:18:17 +02:00
Sybren A. Stüvel f0c89afb76 Anim: move creation of default bone collection to the Shift+A operator
Instead of adding the default "Bones" bone collection to every Armature
data-block, only add it for Armatures that are added in the 3D View with
Shift+A > Armature.

This simplifies things like importers, which otherwise would have needed
to remove that default collection before creating the imported ones.

Additionally, this also ensures that the one bone you get by default is
actually assigned to the default bone collection.
2023-09-21 17:09:25 +02:00
ChengduLittleA 44e245f4f0 Fix #112218: Do not require screen in `object_join_poll`
OBJECT_OT_object_join does not seem to use any screen/window during its
execution. Removing the relevant poll code so it makes it easier to run
this operator in the background.

Pull Request: https://projects.blender.org/blender/blender/pulls/112244
2023-09-11 15:54:23 +02:00
Campbell Barton 09f61f6881 Cleanup: enforce documented convention for RNA enum naming
This was noted in code comments and checked in Python documentation
generation but not at build time.

Since these enums are identifiers that end up included in various places
enforce the `rna_enum_*_items` convention which was noted as
the convention but not followed strictly.

Partially reverts [0], avoids having to deal with multiple prefix types.

[0]: 3ea7117ed1
2023-08-25 13:35:58 +10:00
Jacques Lucke cc4d5c432c RNA: move headers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/111022
2023-08-10 22:40:27 +02:00
Aras Pranckevicius d973355b3a Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).

However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.

This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.

Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
  to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).

Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.

Pull Request #110944
2023-08-10 14:51:40 +03:00
Jacques Lucke 08a8825827 Cleanup: use actual function type instead of void* in declaration
This updates the signature of `RNA_def_property_update_runtime`
which previously just has a `const void *` input. This made it difficult
to know what function signature is expected and also does not result
in compile errors when a wrong function is provided.

There is one case which required a different signature, so now there
is a separat function for that case.
2023-08-09 22:40:39 +02:00
Hans Goudey ffe4fbe832 Cleanup: Move editors headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110820
2023-08-05 02:57:52 +02:00
Hans Goudey bc8c892c65 Cleanup: Move WM headers to C++
Also move a few more headers that included WM headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/110815
2023-08-04 23:11:22 +02:00
Hans Goudey dc7979a056 Cleanup: Make geometry set naming more consistent
Remove the "_for_read" suffix from methods to get geometry and geometry
components. That should be considered the default, so the suffix just
adds unnecessary text. This is consistent with the attribute API and
various implicit sharing data access methods.

Use "from_mesh" instead of "create_with_mesh". This is consistent with
the recently used naming for the `IndexMask` API.

Pull Request: https://projects.blender.org/blender/blender/pulls/110738
2023-08-03 17:09:18 +02:00
Hans Goudey 731d296f35 Cleanup: Move mesh related blenkernel headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110730
2023-08-02 22:14:18 +02:00
Bastien Montagne 4f673f18af Move `BKE_lib_override.h` header to be fully C++.
This implies using the `.hh` extension, and removing the `extern "C"`
blocks from it.

Pull Request: https://projects.blender.org/blender/blender/pulls/110718
2023-08-02 17:44:37 +02:00
Campbell Barton cfffd813c1 Cleanup: use typed enum for UI_ITEM_* flags
Using an int lead to confusion with other flags often used with buttons.
For e.g. these flags could be easily confused with uiItem::flag.
2023-07-29 15:32:45 +10:00
Hans Goudey 95edff7495 Cleanup: Rename mesh custom data fields
Implements the rest of #101689, after 5e9ea9243b.

- `vdata` -> `vert_data`
- `edata` -> `edge_data`
- `pdata` -> `face_data`
- `ldata` -> `loop_data`

A deeper rename of `loop` to `corner` will be proposed as a next
step, and renaming `totvert` and `totedge` can be done separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/110432
2023-07-25 21:15:52 +02:00
Hans Goudey 5a86705d4c Cleanup: Move ED_curves.h to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110115
2023-07-15 03:44:58 +02:00
Campbell Barton 785bd13b9a Cleanup: spelling in comments 2023-07-05 14:09:33 +10:00
Jacques Lucke 3ece6876af RNA: move most rna files to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/109585
2023-07-01 16:38:46 +02:00
Campbell Barton cf29e011be Cleanup: remove all strcpy calls in source/blender/editors/
Replace with STRNCPY or BLI_strncpy, while many cases were safe,
translated source strings could cause buffer overflows, see: #108917.
2023-06-19 11:58:33 +10:00
Hans Goudey f4124ee02d Cleanup: Move GeometrySet and components to proper namespace
Move `GeometrySet` and `GeometryComponent` and subclasses
to the `blender::bke` namespace. This wasn't done earlier since
these were one of the first C++ classes used throughout Blender,
but now it is common.

Also remove the now-unnecessary C-header, since all users of
the geometry set header are now in C++.

Pull Request: https://projects.blender.org/blender/blender/pulls/109020
2023-06-15 22:18:28 +02:00
Campbell Barton 74dd0ed09e Cleanup: remove redundant struct qualifiers 2023-06-03 08:54:37 +10:00
YimingWu 95f1d8289c GPv3: "Add Suzanne" option in Add operator
This patch moves the "Add Suzanne" option to the new data structure.

Pull Request: https://projects.blender.org/blender/blender/pulls/108503
2023-06-01 16:39:47 +02:00
Falk David b14cdb440a GPv3: Add operator to create new grease pencil object
This adds the operator `OBJECT_OT_grease_pencil_add` to create a new grease pencil object.

Currently it supports the `EMPTY` and `STROKE` type.
This also replaces the add menu for the legacy grease pencil type in the Shift+A menu when the experimental option is enabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/108462
2023-05-31 18:00:26 +02:00
Sergey Sharybin c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Hans Goudey e64b3c8212 Refactor: Remove pre-2.8 function to reevaluate a single object
This function replaced the evaluated mesh with a new one with the given
custom data type mask. That doesn't work in general anymore for a few
reasons: the increased dependence on named attributes (a opposed to
custom data types), and the "all or nothing" approach to reevaluating
the depsgraph. Other objects might depend on the object's evaluated
geometry, so it shouldn't just be replaced. Pushed a bit further, this could
give nice simplifications to mesh modifier evaluation.

There are two breaking changes, `bmesh_from_object` and BVH tree
`FromObject` require the source object to have a proper evaluated
mesh now.

If this causes a regression, it's likely that the object is missing
an update tag when a mode is entered that requires extra evaluated data.

Pull Request: https://projects.blender.org/blender/blender/pulls/106186
2023-05-30 22:25:06 +02:00
Falk David d21f4efc8e Cleanup: formatting 2023-05-30 11:18:35 +02:00
Falk David 3aaacd6e30 GPencil 3.0: Initial commit
Adds the initial stage for the grease pencil 3.0 project.

This patch includes:
* New ID and new object type.
* New DNA structures.
* New drawing engine for grease pencil (gpencil-next).
* Tests for the new grease pencil data-type.
* A few operators for conversion, switching modes and (simple) drawing.

Exposed to the user:
* An experimental option to switch to the new grease pencil.
   * This will switch the grease pencil render engine to gpencil-next which can only render the new object type.
     Current grease pencil objects will no longer render.
   * Changing this option currently requires a restart of blender (for the keymap to update).
* A conversion setting in the `Object` > `Convert To` operator.
* A drawing operator in `Draw Mode`.

Pull Request: https://projects.blender.org/blender/blender/pulls/106848
2023-05-30 11:14:16 +02:00
Iliya Katueshenock f7388e3be5 Cleanup: Move BKE_node.h to C++
See: https://projects.blender.org/blender/blender/issues/103343

Changes:
1. Added `BKE_node.hh` file. New file includes old one.
2. Functions moved to new file. Redundant `(void)`, `struct` are removed.
3. All cpp includes replaced from `.h` on `.hh`.
4. Everything in `BKE_node.hh` is on `blender::bke` namespace.
5. All implementation functions moved in namespace.
6. Function names (`BKE_node_*`) changed to `blender::bke::node_*`.
7. `eNodeSizePreset` now is a class, with renamed items.

Pull Request: https://projects.blender.org/blender/blender/pulls/107790
2023-05-15 15:14:22 +02:00
Campbell Barton 169dd2a2b4 Use UTF8 copy function to ensure valid UTF8 output 2023-05-13 17:38:48 +10:00
Campbell Barton 3958ae7241 Cleanup: use STRNCPY, SNPRINTF macros 2023-05-09 14:08:19 +10:00
Campbell Barton 6859bb6e67 Cleanup: format (with BraceWrapping::AfterControlStatement "MultiLine") 2023-05-02 09:37:49 +10:00
Campbell Barton 358ce4f52b Fix more crashes attempting to run operators in unexpected contexts
Add missing NULL checks for:

- OBJECT_OT_transform_to_mouse
- GPENCIL_OT_time_segment_remove
2023-04-30 15:23:43 +10:00
Campbell Barton 44d13c787d Fix various crashes attempting to run operators in unexpected contexts
Use bl_run_operators to detect cases when operators would crash
when run in an expected context for the following operators:

- GIZMOGROUP_OT_gizmo_select
- GIZMOGROUP_OT_gizmo_tweak
- GPENCIL_OT_time_segment_move
- OBJECT_OT_add_named
- OBJECT_OT_data_instance_add
- OBJECT_OT_drop_named_material
- SCULPT_OT_mask_by_color
- SEQUENCER_OT_delete
- SEQUENCER_OT_rename_channel
- SEQUENCER_OT_retiming_handle_move
- SPREADSHEET_OT_change_spreadsheet_data_source
- UI_OT_drop_color

Note that some of these situations users were unlikely to encounter,
however there were cases script authors could run into such as deleting
sequence strips without a region or masking by color without a 3D view.
2023-04-30 15:08:27 +10:00
Hans Goudey 7535ab412a Cleanup: Remove redundant "reference" argument to geometry copy
Implicit sharing means attribute ownership is shared between geometry
data-blocks, and the sharing happens automatically. So it's unnecessary
to choose whether to enable it when copying a mesh.
2023-04-19 15:52:56 -04:00
Hans Goudey a1cc15f239 Fix: Assert when converting curves object to mesh object
`BKE_mesh_nomain_to_mesh` expects the object's data to be the mesh.
Also, the curve to mesh conversion can return a null pointer, so use
an empty mesh in that case. Thanks to Falk David for finding these.
2023-04-14 08:51:00 -04:00
Falk David 10f20bf5d5 Refactor: Rename more grease pencil files to legacy
This renames more files and folders to indicate that it is grease pencil legacy code.

Pull Request: https://projects.blender.org/blender/blender/pulls/106862
2023-04-14 13:35:08 +02:00
Sergey Sharybin d32d787f5f Clang-Format: Allow empty functions to be single-line
For example

```
OIIOOutputDriver::~OIIOOutputDriver()
{
}
```

becomes

```
OIIOOutputDriver::~OIIOOutputDriver() {}
```

Saves quite some vertical space, which is especially handy for
constructors.

Pull Request: https://projects.blender.org/blender/blender/pulls/105594
2023-03-29 16:50:54 +02:00
Campbell Barton 1ddbe7cadd Cleanup: move doc-strings into headers, remove duplicates
In some cases move implementation details into the function body.
2023-03-29 14:37:34 +11:00
Falk David df0c2693b6 Refactor: Rename grease pencil files to legacy
This renames the `BKE_gpencil_*` as well as the `DNA_gpencil_types.h`
files to indicate that it's the legacy grease pencil.

Pull Request: https://projects.blender.org/blender/blender/pulls/105597
2023-03-13 10:42:51 +01:00
Hans Goudey 1dc57a89e9 Mesh: Move functions to C++ header
Refactoring mesh code, it has become clear that local cleanups and
simplifications are limited by the need to keep a C public API for
mesh functions. This change makes code more obvious and makes further
refactoring much easier.

- Add a new `BKE_mesh.hh` header for a C++ only mesh API
- Introduce a new `blender::bke::mesh` namespace, documented here:
  https://wiki.blender.org/wiki/Source/Objects/Mesh#Namespaces
- Move some functions to the new namespace, cleaning up their arguments
- Move code to `Array` and `float3` where necessary to use the new API
- Define existing inline mesh data access functions to the new header
- Keep some C API functions where necessary because of RNA
- Move all C++ files to use the new header, which includes the old one

In the future it may make sense to split up `BKE_mesh.hh` more, but for
now keeping the same name as the existing header keeps things simple.

Pull Request: https://projects.blender.org/blender/blender/pulls/105416
2023-03-12 22:29:15 +01:00