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.
Regression caused by [0]. Passing "Span" by value caused io_ply test to
fail. References were used so changes would be applied to arguments
passed in.
Revert these changes for "ply_import.cc".
[0]: d338261c55
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
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
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.
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`.
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.
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
Now instead of trying to potentially handle unlimited amount of
newlines (which might be actual data in a binary file), only
explicitly handle either LF or CRLF line endings. Fixes#116022.
Will add test coverage in a followup commit, for easier backporting
of just the fix if needed.
When parsing PLY files it was possible that the buffer would contain
leading newline characters which were not being accounted for.
Ensure we skip past them each time we refill the buffer. Also properly
return an error string when handling such lines in the future.
Pull Request: https://projects.blender.org/blender/blender/pulls/114878
It is not clear why shallow copy needs to be created to access
some fields which are copied from the input object. Just use that
object directly.
Shallow copying is a weird and legacy concept, it should not be
used without huge disclaimer why it is unavoidable in the new
code.
Pull Request: https://projects.blender.org/blender/blender/pulls/114791
Several improvements how PLY files containing vertex normals are imported:
- When they are present on a regular mesh, the code no longer sets
all faces as "flat" (since that makes custom normals be ignored).
- When they are present on a pure point cloud (i.e. no faces),
custom vertex normals are added as a float3 point domain attribute
(ref #114371).
Similar to e98cc412e, exporting PLY essentially merges all meshes into
one. And if any of them has vertex colors to export, they all
should get a fake/dummy vertex color entry.
Custom attribute export (#114320) code did not realize that
PLY exports everything as one single "mesh" with the same vertex
data for everything. So if exporting several input meshes and they
have different vertex attributes, the result needs to have a union
of all present attributes, with fake/zero data for the ones
that were not actually present. Fixes#114346.
Implements #108948 - support for custom point domain attributes for PLY
import and export. Notes:
- Custom attributes are always represented as scalar floats. PLY itself
has some data types that blender can't fully represent, e.g. double or
uint32, or some that fit into a float just fine but blender does not have
them as separate types (e.g. int16).
- When importing, any PLY vertex attribute that is not one of "standard"
names (position, normal, etc.) gets turned into a custom attribute.
- For exporting, more complex custom attributes (e.g. 2D/3D floats,
quaternions, colors) get turned into several PLY attributes, with "_x"
like suffix.
Custom attribute import/export is on by default in the UI.
Pull Request: https://projects.blender.org/blender/blender/pulls/114320
Reviewed By: Hans Goudey
MPoly -> offset indices refactor (7966cd16d6) did not realize
that due to forced triangulation the mesh changes, so we need
to re-fetch the faces array after triangulating. Fixes#112011