Move all header file into namespace.
Unnecessary namespaces was removed from implementations file.
Part of forward declarations in header was moved in the top part
of file just to do not have a lot of separate namespaces.
Pull Request: https://projects.blender.org/blender/blender/pulls/121637
If a curve was not using U parameter range of 0..1, the importer
did not properly detect whether the "U endpoint" flag should
be set on it. Fixed that, along with test coverage for the case.
When moving importers from Python to C++ validation was removed
(from PLY) & disabled by default (STL & OBJ) which re-introduces
crashes reported by users such as #31835.
Enable validation by default because crashes caused by imported data
should be avoided, especially since the crashes may happen later when
users enter edit-mode or run certain editing operations.
This does slow down importing, from testing a 236MB .OBJ it takes around
twice as long to import (~1.5 to ~3 seconds). Although validation can
be optimized to reduce the overhead ad well as run in parallel for
importers that load multiple objects.
The defaults for USD and Alembic remain unchanged since this was never
enabled by default, although we could consider enabling these as well.
When using Collection export skip drawing certain operator properties
which shouldn't apply for this style of export.
These suppressed properties were mentioned a few times while gathering
feedback for the feature and they are ignored internally when using
collection export anyhow.
This implements the ability to have file exporters added and configured on Collections.
Exporting is reachable from several locations:
- Individually on each exporter configuration: The `Export` button in each panel header
- For all exporters on the collection: The `Export All` button in the main panel interface
- For all exporters on all collections in the scene: The `File`->`Export All Collections` button
Visibility of which collections currently have exporters configured is done by ways of an icon added to the Collection row in the Outliner.
Adding multiple exporters for the same file type is permitted. The user is free to setup several exports of the same format but with different file locations or settings etc.
Notes:
Only USD and Wavefront OBJ are enabled for the initial commit. Additional formats, including those implemented in Python will be added as separate commits after this.
Ref #115690
Pull Request: https://projects.blender.org/blender/blender/pulls/116646
The MTLWriter was using a BLI_assert to check user-provided data, which
is incorrect and would only work in Debug builds. Release builds would
end up using too small of a buffer and would needlessly fail to append
the `.mtl` extension in some cases.
Instead, we now allow the path manipulation code to just use the full
max size available to it.
Pull Request: https://projects.blender.org/blender/blender/pulls/120275
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
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
- Pass null instead of an empty string to BKE_tempdir_init
because the string isn't meant to be used.
- Never pass null to BLI_temp_directory_path_copy_if_valid
(the caller must check).
- Additional comments for which checks are performed & why
from discussion about #95411.
Properly handle exceptions from STL and PLY code to prevent crashes on
invalid file paths.
This will now also Report errors/warnings to the callers of these
formats as well. For the UI this means a Report banner and Info editor
entry. For Python scripts this means an exception instead of silently
continuing.
Related to #117881
Pull Request: https://projects.blender.org/blender/blender/pulls/118731
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
Span is preferrable since it's agnostic of the source container,
makes it clearer that there is no ownership, is 8 bytes smaller,
and can be passed by value.
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
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
- Only calculate the necessary normals based on smooth/flat/mixed shading
- Use cached face normals instead of computing them
- Use a `VectorSet` for deduplication instead of a `Map`
- Deduplicate vertex normals and store indices in separate loops
- Avoid unnecessary duplication of face normal indices
- Inline simple function for slicing index span
Export time (ms) of 1.8m vertex mesh:
| Normals Domain | Before | After |
| --------------- | ------ | ----- |
| Face (flat) | 559 | 469 |
| Vertex (smooth) | 659 | 466 |
| Corner (mixed) | 656 | 640 |
The change of using normals from different domains and using a
VectorSet for de-duplication change the order of normals in the OBJ
files. Other than that, the results should be unchanged.
Fixes#117510
Pull Request: https://projects.blender.org/blender/blender/pulls/117522
Remove the need for the `calc_vertex_coords` function by combining
the scale into the existing transform needed to export vertex positions
in global space. This simplifies code and may slightly improve performance
(I only observed a few percent difference in the positions export, which is
not a slower part of the export).
- Use Span where ownership is unnecessary
- Use Array when dynamic growth is unnecessary
- Use Vector in all other cases
Also remove unnecessary namespace specification.
`BKE_object_get_pre_modified_mesh` returns curve object data, later
accessing non-existing edge/face data triggered the crash.
`apply_modifiers` seems valid for mesh data only.
Pull Request: https://projects.blender.org/blender/blender/pulls/117471