Commit Graph

364 Commits

Author SHA1 Message Date
Campbell Barton 686605a6dd Cleanup: declare arrays as const where possible 2024-03-28 22:57:57 +11:00
Hans Goudey efee753e8f Cleanup: Move BKE_idprop.h to C++ 2024-03-26 13:07:04 -04:00
Jesse Yurkovich 5ad9f9dc90 Cleanup: unused includes in source/blender/io
Reduce dependence on Blender headers as much as possible and move closer
to an include-what-you-use setup.

- Removes unnecessary includes
- Replaces some includes with more appropriate, narrower, substitutes

Pull Request: https://projects.blender.org/blender/blender/pulls/119234
2024-03-10 04:28:00 +01:00
Campbell Barton f3e0e39df5 Cleanup: use const pointers where camera data isn't modified 2024-03-08 17:15:08 +11:00
Jesse Yurkovich 833791772c Merge branch 'blender-v4.1-release' 2024-03-01 13:15:42 -08:00
Jesse Yurkovich 1597e9386f Fix #118602: Build depsgraph on main thread for Alembic
Building the depsgraph from a worker thread is unsafe currently, as it
may trigger some deferred processing on the Main data itself.

Mimic what was already done for USD (from `5cf3654d9d`) and build the
graph before launching `export_startjob`.

Pull Request: https://projects.blender.org/blender/blender/pulls/118974
2024-03-01 22:14:12 +01:00
Jesse Yurkovich 2353fd8f91 Alembic: Alleviate long loading times in large files
Sort the incoming Alembic objects by name before processing them. This
mirrors what is already done in USD to partially side-step Blender's
quadratic behavior when checking object names.

The file contained in issue #118839 contains over 365000 individual
objects. This change allows loading to be ~4x faster; from 2.2 hours
down to 28 minutes.

Additionally, change the progress bar to report in finer-grained steps
to better indicate that progress is still being made.

Pull Request: https://projects.blender.org/blender/blender/pulls/118869
2024-02-29 18:30:24 +01:00
Hans Goudey 5c5089d651 Fix: Small changes to USD and Alembic curves import
Make both importers work the same way: first building an array
of the new offsets, then comparing the offsets to check if the
topology changed. Previously the USD importer incorrectly
compared curve offsets to USD point counts.

Also:
- Don't unnecessarily set the resolution to the incorrect default.
  The default for the curves system is 12. But it's unnecessary to
  fill the attribute to the default value anyway.
- Use some helper methods to iterate over all curves.
- Use float literal instead of integer.
- Use cast and `copy_from` for positions copy
- Pass Span by value

Pull Request: https://projects.blender.org/blender/blender/pulls/118829
2024-02-28 05:05:53 +01:00
Hans Goudey 5ed9c8c9dd Cleanup: Standardize CurvesGeometry naming in Alembic and USD
- Curves data-block is called "curves_id"
- CurvesGeometry is called "curves"
2024-02-27 21:32:40 -05:00
Hans Goudey c409b14797 Cleanup: Resolve missing declaration warning in Alembic mesh reader 2024-02-27 21:27:13 -05:00
Kévin Dietrich ea256346a8 Alembic/USD: Use GeometrySets to import data
This rewrites the Alembic and USD data importers to work with and
output GeometrySets instead of Meshes.

The main motivation for this change is to be able to import properly
point clouds, which are currently imported as Meshes, and curves
data, which suffer from a lot of issues due to limitations of
legacy curves structures (fixed by the new curves data-block) and are
also converted to Meshes. Further, for Curves, it will allow importing
arbitrary attributes.

This patch was primarily meant for Alembic, but changes to USD import
were necessary as they share the same modifier.

For Alembic:
There should be no behavioral changes for Meshes
Curves are imported as the new Curves object type
Points are imported as PointClouds

For USD:
There should be no behavioral changes for Meshes
Curves are imported as the new Curves object type
Note that the current USD importer does not support loading PointClouds,
so this patch does not add support for it.

For both Alembic and USD, knots arrays are not read anymore, as the new
Curves object does not expose the ability to set them. Improvements can
be made in the future if and when example assets are provided.

This fixes at least the following:
#58704: Animated Alembic curves don't update on render
#112308: Curves have offset animations (alembic / USD)
#118261: wrong motion blur from usd in cycles and reverting to the first
frame when disabeling motion blur

Co-authored-by: Jesse Yurkovich <jesse.y@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/115623
2024-02-28 03:02:38 +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
Hans Goudey 81a63153d0 Despgraph: Rename "copy-on-write" to "copy-on-evaluation"
The depsgraph CoW mechanism is a bit of a misnomer. It creates an
evaluated copy for data-blocks regardless of whether the copy will
actually be written to. The point is to have physical separation between
original and evaluated data. This is in contrast to the commonly used
performance improvement of keeping a user count and copying data
implicitly when it needs to be changed. In Blender code we call this
"implicit sharing" instead. Importantly, the dependency graph has no
idea about the _actual_ CoW behavior in Blender.

Renaming this functionality in the despgraph removes some of the
confusion that comes up when talking about this, and will hopefully
make the depsgraph less confusing to understand initially too. Wording
like "the evaluated copy" (as opposed to the original data-block) has
also become common anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/118338
2024-02-19 15:54:08 +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
Bastien Montagne 5aaadebbe4 Cleanup: Make `BKE_scene.h` a full Cpp header. 2024-02-10 19:16:25 +01:00
Bastien Montagne 54618dbae3 Cleanup: Make `BKE_global.h` a Cpp header. 2024-02-10 18:25:14 +01:00
Bastien Montagne deab8c085a Cleanup: Move `BKE_callbacks.h` and `BKE_cachefile.h` to CPP headers. 2024-02-09 19:29:34 +01:00
Bastien Montagne 45e7827898 Clenup: Move BLT headers to Cpp.
Noisy but fairly straight forward.
2024-02-09 18:59:42 +01:00
Jacques Lucke 1497005054 Modifiers: add unique modifier identifiers
This adds a new `ModifierData.persistent_uid` integer property with the following properties:
* It's unique within the object.
* Match between the original and evaluated object.
* Stable across Blender sessions.
* Stable across renames and reorderings of modifiers.

Potential use-cases:
* Everywhere where we currently use the name as identifier. For example,
  `ModifierComputeContext` and `ModifierViewerPathElem`.
* Can be used as part of a key in `IDCacheKey` to support caches that stay
  in-tact across undo steps.
* Can be stored in the `SpaceNode` to identify the modifier whose geometry node
  tree is currently pinned (this could use the name currently, but that hasn't been
  implemented yet).

This new identifier has some overlap with `ModifierData.session_uid`, but there
are some differences:
* `session_uid` is unique within the entire Blender session (except for duplicates
  between the original and evaluated data blocks).
* `session_uid` is not stable across Blender sessions.

Especially due to the first difference, it's not immediately obvious that the new
`persistent_uid` can fulfill all use-cases of the existing `session_uid`. Nevertheless,
this seems likely and will be cleaned up separately.

Unfortunately, there is not a single place where modifiers are added to objects currently.
Therefore, there are quite a few places that need to ensure valid identifiers. I tried to catch
all the places, but it's hard to be sure. Therefore, I added an assert in `object_copy_data`
that checks if all identifiers are valid. This way, we should be notified relatively quickly if
issues are caused by invalid identifiers.

Pull Request: https://projects.blender.org/blender/blender/pulls/117347
2024-02-06 17:10:40 +01:00
Hans Goudey 19e2b13cec Cleanup: Move BKE_key.h to C++ 2024-01-30 14:42:13 -05:00
Hans Goudey 500f09b88a Cleanup: Move metaball BKE headers to C++ 2024-01-24 11:46:39 -05:00
Hans Goudey 02582213de Cleanup: Move BKE_layer.hh to C++ 2024-01-24 10:55:16 -05: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
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
Philipp Oeser 5412bd48a9 Alembic: export render resolution on cameras
Blender's cameras don't have specific resolution configured to them,
instead they use the scene's resolution.
This is a problem when exporting a camera using Alembic. Other software
(like Houdini) expects the resolution parameters on the camera itself.

So now store the scene's resolution on each camera that is exported.
Since this is not part of the concept of a camera in alembic itself,
export these as `userProperties` in a way other software can read this.

Fixes #116375

Pull Request: https://projects.blender.org/blender/blender/pulls/116782
2024-01-04 17:49:28 +01:00
Philipp Oeser 472cf44166 Alembic: read velocities on Points
This is reusing the generic system from 128eb6cbe9 which at that time
was only done for the mesh reader and is now done for the point reader
as well.

This allows for rendering with proper motion blur for alembic points
(which of course are still imported as meshes - were just lacking the
velocity attribute) when directly rendering as points in Cycles.

Came up in #109185 (where instancing is used - which is still not
supported, this patch is just for direct point rendering in Cycles).

Unsure about the status of https://archive.blender.org/developer/D11591
but until that lands, having velocities for points sounds useful enough
to support this now.

Fixes #95945

Pull Request: https://projects.blender.org/blender/blender/pulls/116749
2024-01-04 09:25:24 +01:00
Brecht Van Lommel 364beee159 Tests: add option to build one binary per GTest file
Bundling many tests in a single binary reduces build time and disk space
usage, but is less convenient for running individual tests command line
as filter flags need to be used.

This adds WITH_TESTS_SINGLE_BINARY to generate one executable file per
source file. Note that enabling this option requires a significant amount
of disk space.

Due to refactoring, the resulting ctest names are a bit different than
before. The number of tests is also a bit different depending if this
option is used, as one uses gtests discovery and the other is organized
purely by filename, which isn't always 1:1.

Co-authored-by: Sergey Sharybin <sergey@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/114604
2024-01-03 18:35:50 +01:00
Brecht Van Lommel f63accd3b6 Cleanup: move CMake test utility functions into testing.cmake
Combining functions from macros.cmake and Modules/GTestTesting.cmake.
It was unusual to have Blender specific code in the Modules folder.

Pull Request: https://projects.blender.org/blender/blender/pulls/116719
2024-01-03 14:49:11 +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
Brecht Van Lommel 4ce14a639f Revert "Cleanup: move CMake test utility functions into testing.cmake"
This breaks execution of some Windows tests.

This reverts commit 4190a61020.
2024-01-02 19:06:39 +01:00
Brecht Van Lommel 4190a61020 Cleanup: move CMake test utility functions into testing.cmake
Combining functions from macros.cmake and Modules/GTestTesting.cmake.
It was unusual to have Blender specific code in the Modules folder.
2024-01-02 15:34:52 +01:00
Hans Goudey 06eda2a484 Cleanup: Remove most indirect includes of BKE_customdata.hh
Some common headers were including this. Separating the includes
will ideally lead to better conceptual separation between CustomData
and the attribute API too. Mostly the change is adding the file to
places where it was included indirectly before. But some code is
shuffled around to hopefully better places as well.
2023-12-26 23:59:44 -05: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 2c43a9eed9 Cleanup: Move BKE_mesh_calc_edges to bke namespace
Also use reference for mesh argument, and move edges calculation
from legacy faces to "legacy" file.
2023-12-20 20:47:10 -05:00
Hans Goudey 19b46e0816 Cleanup: Make format 2023-12-20 14:54:50 -05:00
Hans Goudey edf8a776ac Cleanup: Use forward declarations to replace includes of BKE_attribute.hh
Remove most includes of this header inside other headers, to remove unnecessary
indirect includes which can have a impact on compile times. In the future we may
want more dedicated "_fwd.hh" headers, but until then, this sticks with the
solution in existing code.

Unfortunately it isn't yet possible to remove the include from `BKE_geometry_set.hh`.
2023-12-20 13:25:28 -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 8dd8f932e2 Cleanup: Rename Mesh loop_data to corner_data
Related to #110434, efbee2d606, 7c69c8827b
2023-12-19 20:39:05 -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
Michael B Johnson 5edda6cbcc USD: optionally author subdivision schema on export
USD: optionally author subdivision schema on export

This PR adds support for exporting USD assets which have the subdivision
schema applied. Current behavior prior to this PR is that the effects of
Subdivision Surface modifiers are always applied to their mesh prior to
export, such that it is not possible to recover the original base mesh.

In this PR we provide three options for the subdiv schema type:

Ignore - Export base mesh without subdivision with USD Scheme = None
Tessellate - Export subdivided mesh with USD Scheme = None
Best Match (default) - Export base mesh with USD Scheme = Catmull-Clark

"Best Match" here means that Blender will set a subdiv scheme type in
the exported USD asset when it is possible to closely match the
subdivision surface type that was authored in Blender. At this time
Blender provides two subdivision types: Catmull-Clark and Simple.

Because Simple does not have a corresponding subdivision type in USD, we
do not attempt to convert or represent it, and instead the Simple subdiv
modifier will be evaluated and applied to the mesh during export.

Whenever a Catmull-Clark Subdivision Surface modifier is applied to an
object, and is the last modifier in the stack, it is possible to set the
subdiv scheme to Catmull-Clark for the respective prim in the exported
USD file.

Authored by Apple: Matt McLin

Co-authored-by: Matt McLin <mmclin@apple.com>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/113267
2023-12-15 21:11:41 +01:00
Hans Goudey 1d0179adbb Cleanup: Move mesh update tags to DNA struct
This is similar to other update tags and update tags for other geometry types.
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
Jeroen Bakker 65e58fe574 CMake: Fix Compiling Shader Builder on macOS
Due to changes in the build environment shader_builder wasn't able to
compile on macOs. This patch reverts several recent changes to CMake files.

* dbb2844ed9
* 94817f64b9
* 1b6cd937ff

The idea is that in the near future shader_builder will run on the buildbot as
part of any regular build to ensure that changes to the CMake doesn't break
shader_builder and we only detect it after a few days.

Pull Request: https://projects.blender.org/blender/blender/pulls/115929
2023-12-08 15:47:14 +01:00
Jesse Yurkovich 2f0633f5fa Fix: Send more appropriate notification at end of USD/Alembic import
A recent change[1] caused the `NC_SCENE | ND_FRAME` combination to no
longer perform a full Outliner rebuild. However, both Alembic and USD
importers were using this combination. The end result was that the
outliner would not show any of the newly imported objects/collections
until a rebuild was forced some other way (like going into Edit mode on
an object).

Change to use a more appropriate notification that corresponds to the
concept of new IDs being added to the scene instead: `NC_ID | NA_ADDED`

Also, remove the notification being sent from the startjob callback when
creating a new collection. It's unneeded in this situation and it could
be problematic being called from the callback.

[1] b549260aa4

Pull Request: https://projects.blender.org/blender/blender/pulls/115883
2023-12-07 10:45:58 +01:00
Hans Goudey 7a96c4672c Cleanup: Move BMesh headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/115817
2023-12-05 23:01:12 +01: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 15db0cb446 Cleanup: use style for doxygen comment blocks 2023-11-30 14:15:11 +11:00
Ray molenkamp 94817f64b9 Cleanup: CMake: Modernize bf_intern_utfconv dependencies
- Remove any bf_intern_utfconv paths from INC
- Add a dependency though LIB when missing
- an empty target is created for non windows builds, so we don't have to
if(WIN32) this all over the place

context: https://devtalk.blender.org/t/cmake-cleanup/30260
Pull Request: https://projects.blender.org/blender/blender/pulls/115373
2023-11-28 01:11:15 +01:00