Commit Graph

135 Commits

Author SHA1 Message Date
Jesse Yurkovich
3b2bbad609 USD: Add support for Text objects during export
Similar to the existing meta-ball export, and the other exporters,
convert Text objects to meshes for export.

Ref #138883

Pull Request: https://projects.blender.org/blender/blender/pulls/138903
2025-05-16 22:12:48 +02:00
Jacques Lucke
e8d1491e62 Refactor: Depsgraph: simplify query API further
* Remove `DEG_get_evaluated_object` in favor of `DEG_get_evaluated`.
* Remove `DEG_is_original_object` in favor of `DEG_is_original`.
* Remove `DEG_is_evaluated_object` in favor of `DEG_is_evaluated`.

Pull Request: https://projects.blender.org/blender/blender/pulls/138317
2025-05-02 15:08:29 +02:00
Jesse Yurkovich
01ddb320dd Fix #124263: Generate unique names during Alembic and USD export
While object names in Blender are already unique, the names themselves
may be "unsafe" for use in the various file formats. During processing
we make the names "safe". However, we did not guarantee that these new
safe names were themselves unique wrt each other. Consider object names
"Test 1" and "Test-1" which both become "Test_1" after being made safe.
These will collide during export; only 1 object would be exported and
it's undefined which object's data would "win".

To rectify this we add another name map to the hierarchy iterator which
is then used to handle collisions as they happen. The map is per-
hierarchy meaning that a name can appear more than once as long as its
under a different hierarchy. E.g.
- `/root/A/X` and another `/root/B/X` is OK
- `/root/A/X` and another `/root/A/X` is NOT OK

Pull Request: https://projects.blender.org/blender/blender/pulls/135418
2025-03-21 21:29:08 +01:00
Campbell Barton
6ef7dae8ef Cleanup: spelling in comments (make check_spelling_*) 2025-03-13 13:41:17 +11:00
Campbell Barton
d951428422 Cleanup: spelling in comments
Address warnings from check_spelling.py
2025-03-06 10:49:51 +11:00
Jesse Yurkovich
ae1a5aa2a1 Fix: USD: Incorrect call to Map::add_new during dupli-vert export
Mistake in 6704647c66. Test coverage being added for another bug fix
uncovered this one.

Problem occurs when exporting an object that is duplicating at least two
other objects with the dupli vert system.

Pull Request: https://projects.blender.org/blender/blender/pulls/135369
2025-03-02 22:51:23 +01:00
Jesse Yurkovich
6704647c66 Cleanup: IO: Use blender containers for AbstractHierarchyIterator
Use Blender Containers in the AbstractHierarchyIterator system. A future
bug fix in the area is looking like it will require another map so it
seems like a good time to replace the old containers before that lands.

The conversion is complicated due to how the prior code leveraged
`operator[]` to both add and update entries; it was never clear which
operation was being performed. This leads to a somewhat confusing mix
of `add_new`, `add`, and `lookup_or_add` calls. The calls in place now
are what was required based on our existing tests.

Additionally, pointer stability guarantees were a little bit different,
affecting the usage of the `graph_children` function the most.

Pull Request: https://projects.blender.org/blender/blender/pulls/134698
2025-02-28 05:58:46 +01:00
Campbell Barton
5087246f39 Cleanup: strip trailing space, sort file lists 2025-02-16 20:42:16 +11:00
Devashish Lal
1a62fdc82a Geometry Nodes: CSV import node
This commit implements a node to import CSV files as a point cloud.
The interface is minimal, with just a file path input. The type of each
column is chosen by whether the first value is an integer or a float
(those are currently the only supported types).

The goal of the node is to make it easier to get arbitrary data into
geometry nodes for visualization purposes, for example.

https://devtalk.blender.org/t/gsoc-2024-geometry-nodes-file-import-nodes/34482

Pull Request: https://projects.blender.org/blender/blender/pulls/126308
2025-02-10 16:56:52 +01:00
Brecht Van Lommel
941f186e88 Cleanup: Various clang-tidy warnings in io
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:18 +01:00
Michael Kowalski
e021cf0491 Fix: USD export: missing prototype proxies
The scene graph instancing export code contains logic for
determining which instances need to be converted to prototypes
because the original prototypes are not included in the export
(e.g., because they are not visible).

This commit fixes an error in this logic, which incorrectly
assumed that if the root of the original prototype is included
in the export, then the entire original hierarchy beneath the
root is included as well.

To fix this, the logic in AbstractHierarchyIterator::
determine_duplication_references was updated so that if any
descendants of an instance are converted to prototypes, the
parent instance is converted to a prototype as well.

This addresses the bug noted by Brecht in
https://projects.blender.org/blender/blender/pulls/131707#issuecomment-1403309

Pull Request: https://projects.blender.org/blender/blender/pulls/133750
2025-01-29 14:05:52 +01:00
Michael Kowalski
319c64205d USD: Scene graph instancing export
Refactored USD instancing export to support instanceable references.

With this change, it's now possible to instance object hierarchies and
geometry types other than meshes (e.g., curves, point clouds, etc.).

No longer marking mesh prims as instances in
USDGenericMeshWriter::write_mesh().

USDTransformWriter::do_write() now marks the Xform as instanceable
with a reference to the prototype's Xform when the Blender object is
an instance.

In USDAbstractWriter::mark_as_instance() the target prim is now marked
as instanceable.

Added AbstractHierarchyIterator virtual functions include_data_writers()
and include_child_writers() to allow pruning children of instanceable Xforms
in AbstractHierarchyIterator::make_writers(). These functions return true
in the base class implementation, so that the iterator behavior for Alembic
exports is unaffected.  In the USDHierarchyIterator subclass, these functions
are overridden to return false if instancing is enabled and the objects are
instances.

Added virtual function AbstractHierarchyIterator::should_determine_duplication_references()
which returns true if duplication references should be resolved for children
of a given context.  This function is overridden in USDHierarchyIterator to
skip processing children of instances, which is more efficient for USD export,
since children of instances are pruned during traversal for writing.  For nested
instances where the original prototype is not included in the export, this also
avoids designating a duplicated object parented to an instance as "the original",
which would cause USD errors since defining a prim under an instance
proxy is not allowed.

Extended logic in `AbstractHierarchyIterator::determine_duplication_references()`
to identify prototypes.

Added new function `HierarchyContext::is_prototype()`.

Disallowing merging with parent for instances and prototypes, since
the Xforms cannot be discarded in those cases.

Extended `USDWriterAbstract::ensure_usd_material()` with special logic
to ensure materials for prototype prims are defined in the subtree of the
prototype.  This helps ensure the hierarchical encapsulation requirement
for prototypes and is required by certain renderers (e.g., Houdini's Karma)
for instance materials to render.

Added a new `process_scene_graph_instances()` function to ensure
prototypes are exported as abstract prims.

Added python tests test_export_native_instancing_true and
test_export_native_instancing_false.

Pull Request: https://projects.blender.org/blender/blender/pulls/131707
2025-01-28 15:51:56 +01:00
Ray Molenkamp
5783950ac5 Revert: 0dc484f9cc bf_rna modernisation
This caused build errors on the docs builder, I can't seem to reproduce
locally, so revert for now and have another look at some point in the
future.

Sadly as these changes usually go, this took 5c515e26bb and
2f0fc7fc9f with it as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/132559
2025-01-02 19:56:24 +01:00
Campbell Barton
dfef060ea4 Cleanup: spelling in comments (make check_spelling_*)
Also use doxy-code blocks for inlined TEX to avoid
them being interpreted as English.
2025-01-02 15:11:17 +11:00
Ray Molenkamp
0dc484f9cc Cleanup: CMake: Modernize bf_rna dependencies
Pretty straightforward

- Remove any bf_rna 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/132413
2024-12-31 18:23: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
Jesse Yurkovich
afe0ebeb74 Fix: properly export metaballs to USD
While adding tests I found that metaball export has been broken since
Blender 3.4. It would export each metaball geometry twice.

This looks to have been a side effect of a change to `object_dupli.cc`
which no longer sets the `no_draw` flag for metaballs[1]. With the flag
unset we would end up visiting this particular object twice.

Use a direct check for Metaballs now and add test coverage for the
scenario in general.

[1] eaa87101cd

Pull Request: https://projects.blender.org/blender/blender/pulls/131984
2024-12-16 22:11:07 +01:00
Jesse Yurkovich
aef11435b9 Cleanup: Move MAX_DUPLI_RECUR define from DNA to BKE
Moving MAX_DUPLI_RECUR from `DNA_object_types` to `BKE_duplilist` is
more correct organizationally and it allows some downstream consumers to
remove the inclusion of a large and unnecessary DNA header.

Archaeology reference: https://archive.blender.org/developer/D8222

Pull Request: https://projects.blender.org/blender/blender/pulls/131274
2024-12-07 03:14:49 +01:00
Jesse Yurkovich
d0eff5f665 Cleanup: IO Common: Use clog and fmtlib instead of streams
Use CLOG for warnings and fmtlib for developer output and string
formatting rather than the heavy `<stringstream>` machinery.

Pull Request: https://projects.blender.org/blender/blender/pulls/131126
2024-12-03 00:24:01 +01:00
Jesse Yurkovich
1868ae9366 Fix: IO: wrong ObjectIdentifier used when trying to determine parent status
The wrong ObjectIdentifier was used when trying to see if the object is
a parent to something else in the export graph. This lead to accessing
an invalid iterator which will assert with MSVC in Debug configurations.

Accidentally regressed during the review of 428ab699dc.

Pull Request: https://projects.blender.org/blender/blender/pulls/131174
2024-11-30 04:14:19 +01:00
Charles Flèche
428ab699dc USD: Add option to merge transform and shape on export
Adds the option `merge_parent_xform` to the USD export operator and
panels so the transform and shapes are merged into a single USD Prim.

Without the option (existing default), a top-level mesh would be
exported as a top-level `Xform` that has a `Mesh` child:
```
def Xform "MyBlenderMeshObject"
{
  matrix4d xformOp:transform = ...

  def Mesh "MyBlenderMeshData"
  {
  }
}
```

This matches the Blender data model, where a transformable object
contains a geometric shape (like a mesh). This structure is also very
valid in USD, where we don't want to directly instantiate geometric
primitives[1]

However, "since number of prims on a stage is one of the primary factors
that governs how USD scale"[2], to reduce the number of prims in a
stage, geometric primitives *are transformable* themselves (see the
inheritence diagram[3]).

As such, the new export option allows to export geometric primitives
without the parent transform:
```
def Mesh "MyBlenderMeshObject"
{
  matrix4d xformOp:transform = ...
}
```

This MR adds a the `is_object_data_context` flag to the
`HierarchyContext` context structure. The point of this change is to
make unambiguous in `USDHierarchyIterator::create_usd_export_context`
the fact that an `object` or a `data` is currently being exported: the
new `merge_parent_xform` option is meaningless for `object`. Only `data`
can be exported with a parent `Xform` or as a child of said `Xform`.

Ideally this flag would not be needed at all: the final USD prim path
*could* be computed in an override of the virtual
`AbstractHierarchyIterator::get_object_data_path` method. However, this
would mean that an `object` and a `data` would have the same export path.
This does not currently play well with
`AbstractHierarchyIterator::ensure_writer`, where `writers` are cached
*by their export path*: it would cache a transform writer, but will skip
the subsequent data writer.

Additionally, another new `is_parent` flag is added to handle the case
where merging the Xform is invalid: objects that are parents to other
objects should remain unmerged as otherwise that would yield invalid USD
files.

[1] https://openusd.org/release/glossary.html#usdglossary-gprim
[2] https://openusd.org/release/glossary.html#usdglossary-instancing
[3] https://openusd.org/release/api/class_usd_geom_xformable.html

Co-authored-by: Odréanne Breton <odreanne.breton@ubisoft.com>
Co-authored-by: Sttevan Carnali Joga <sttevan.carnali-joga@ubisoft.com>
Co-authored-by: Charles Flèche <charles.fleche@ubisoft.com>
2024-11-19 19:18:53 +01:00
Campbell Barton
4df285ccd5 Cleanup: move function comments into headers or implementation notes
For C/C++ doc-strings should be located in headers,
move function comments into the headers, in some cases merging
with existing doc-strings, in other cases, moving implementation
notes into the function body.
2024-11-02 17:27:09 +11:00
Campbell Barton
381898b6dc Refactor: move BLI_path_util header to C++, rename to BLI_path_utils
Move to a C++ header to allow C++ features to be used there,
use the "utils" suffix as it's preferred for new files.

Ref !128147
2024-09-26 21:13:39 +10:00
Campbell Barton
b03332a055 Cleanup: use BLI_assert_msg instead of checking string literals 2024-04-03 14:27:54 +11: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
Bastien Montagne
de5451b112 Cleanup: Move BKE_anim_data header to be fully C++. 2024-02-28 11:51:03 +01:00
Hans Goudey
a52323d711 Cleanup: Move BKE_duplilist.hh to C++ 2024-02-14 10:51:46 -05: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
Hans Goudey
91e54fdd83 Cleanup: Move BLO_readfile.h to C++
I added a new BLO_userdef_default.h header to contain declarations of
two global variables that are still defined in C files. Use of designated
initializers for large structs make those files harder to change.
Arguably this is a better header for them anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/118015
2024-02-09 13:41:30 +01:00
Hans Goudey
19e2b13cec Cleanup: Move BKE_key.h to C++ 2024-01-30 14:42:13 -05:00
Hans Goudey
02582213de Cleanup: Move BKE_layer.hh to C++ 2024-01-24 10:55:16 -05:00
Hans Goudey
09063a3632 Cleanup: Remove some indirect includes in common headers
The idea is to avoid mistakenly depending on indirect includes,
and avoid compile time overhead from unnecessary header parsing.

Pull Request: https://projects.blender.org/blender/blender/pulls/116664
2024-01-06 01:47:39 +01:00
Hans Goudey
d6cfd7d1f4 Cleanup: Remove unnecessary keywords from C++ headers
- Remove unnecessary `struct`
- Use `using` instead of `typedef`
- Remove `void` from `(void)` as function arguments
2024-01-04 15:07:48 -05: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
Campbell Barton
482ba7806d Cleanup: spelling correction: "adjacent" & spelling in comments 2023-12-19 09:54:53 +11: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
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
Ray Molenkamp
6b70c04724 Cleanup: CMake: Modernize bf_depsgraph dependencies
Pretty straightforward

- Remove any bf_depsgraph 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/115422
2023-11-25 22:51:59 +01: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
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
Hans Goudey
fa34992def Cleanup: Remove unnecessary includes from C++ data structure headers
The hash tables and vector blenlib headers were pulling many more
headers than they actually need, including the C base math header,
our C string API header, and the StringRef header. All of this
potentially slows down compilation and polutes autocomplete
with unrelated information.

Also remove the `ListBase` constructor for `Vector`. It wasn't used
much, and making it easy to use `ListBase` isn't worth it for the
same reasons mentioned above.

It turns out a lot of files depended on indirect includes of
`BLI_string.h` and `BLI_listbase.h`, so those are fixed here.

Pull Request: https://projects.blender.org/blender/blender/pulls/111801
2023-09-01 21:37:11 +02:00
Campbell Barton
8032ee9df2 Revert "Cleanup: Replace IO orientation enum with blenlib type"
This reverts commit 074dbf08cd.

This change caused PLY and OBJ tests not to compile,
even with the identifiers updated some OBJ tests fails
with different rotation values.
2023-09-01 10:35:14 +10:00
Hans Goudey
074dbf08cd Cleanup: Replace IO orientation enum with blenlib type
This helps to document standard behavior, improves type
safety, reduces code duplication, and gets us closer to being
able to remove some of the older C math API.
2023-08-31 13:29:52 -04:00
Hans Goudey
78dd7d91c4 Cleanup: Move IO headers to C++
See #103343
2023-08-31 12:52:04 -04:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00