The UsdTransform2d shader was previously ignored, and the material
read would stop when it found these nodes. This resulted in many
surfaces having their textures mapped incorrectly when imported
into Blender, and worse, resulted in the loss of that data when
round-tripping back out of Blender.
This patch adds support for the Transform 2D node and also ensures
that the wrap modes are similarly written correctly.
Co-authored-by: Charles Wardlaw <kattkieru@users.noreply.github.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/114821
Implement the next phases of bounds improvement design #96968.
Mainly the following changes:
Don't use `Object.runtime.bb` for performance caching volume bounds.
This is redundant with the cache in most geometry data-block types.
Instead, this becomes `Object.runtime.bounds_eval`, and is only used
where it's actually needed: syncing the bounds from the evaluated
geometry in the active depsgraph to the original object.
Remove all redundant functions to access geometry bounds with an
Object argument. These make the whole design confusing, since they
access geometry bounds at an object level.
Use `std::optional<Bounds<float3>>` to pass and store bounds instead
of an allocated `BoundBox` struct. This uses less space, avoids
small heap allocations, and generally simplifies code, since we
usually only want the min and max anyway.
After this, to avoid performance regressions, we should also cache
bounds in volumes, and maybe the legacy curve and GP data types
(though it might not be worth the effort for those legacy types).
Pull Request: https://projects.blender.org/blender/blender/pulls/114933
- Only calculate normals on the necessary domain
- Functions for exporting generic data
- Parallelize export of multiple submeshes
- Parallelize export within a single submesh
- Resize vectors to correct size to avoid reallocation
- Simplify hot loops to improve performance
- Optimize single material case to avoid index remapping
`write_submeshes` timing information (average of many runs)
| Test | Before | After |
| ------------------------------ | --------- | --------- |
| 6 million vert mesh | 791.99 ms | 130.75 ms |
| 1.5 million vert 100 materials | crash | 48.27 ms |
| Mr. Elephant test file | 778.95 ms | 277.06 ms |
Pull Request: https://projects.blender.org/blender/blender/pulls/113412
Avoid the need to call the separate `BKE_mesh_wrapper_minmax` function
that dealt with the edit mesh wrapper. This makes the API inconsistent,
since other mesh functions don't implicitly deal with the wrapper.
But the bounds are a bit of a special case anyway in regard
to the GPU subdivision wrapper already, and this is much more
convenient in the rest of the refactors for #96968.
There was a C++ STL importer since Blender 3.3, but no corresponding C++ STL exporter. This PR is adding said exporter: taking https://projects.blender.org/blender/blender/pulls/105598 and finishing it (agreed with original author).
Exporting Suzanne with 6 level subdivision (4 million triangles), on Apple M1 Max:
- Binary: python exporter 7.8 sec -> C++ exporter 0.9 sec.
- Ascii: python exporter 13.1 sec -> C++ exporter 4.5 sec.
Co-authored-by: Iyad Ahmed <iyadahmed430@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/114862
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
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
This fixes a bug where the rgb UsdUVTexture shader output
attributes were created with incorrect type color3f when
connected to UsdPreviewSurface diffuseColor and emissiveColor
inputs. The UsdPreviewSurface specification requires the
UsdUVTexture rgb output to be of type float3.
This was happening because the UsdUVTexture outputs were created
implicitly by the call to UsdShadeInput::ConnectToSource(). I.e.,
because the diffuseColor and emissiveColor inputs are of type
color3f, this was the type assigned by default to the rgb source
attributes as well.
Now explicitly creating the UsdUVTexture shader output attributes
with the correct types.
Pull Request: https://projects.blender.org/blender/blender/pulls/114728
Ensure that the view layer is properly synced before trying to get the
active collection.
Without the sync, imported objects typically get placed in the global
Scene Collection rather than the new collection that was just created
for the import.
Pull Request: https://projects.blender.org/blender/blender/pulls/114650
No functional changes.
Move the functions
`insert_vert_fcurve` and
`insert_bezt_fcurve`
from `ED_keyframing.hh` / `keyframing.cc`
to `ANIM_fcurve.hh` / `fcurve.cc`
in animrig
Pull Request: https://projects.blender.org/blender/blender/pulls/114570
This progress report was utterly broken and useless when not exporting
animations, and not great either with animation export. This commit
fixes:
* Not generating any progress report when exporting a single frame.
* Assuming actual data export covers 100% of progress.
That last point is the biggest change, now actual export (be it
animated or still) only covers 75% of the whole range. The rest is used
to cover depsgraph building and updates (which can be noticiably slow
with big scenes), stage writing, etc.
Progression is still far from linear in time, but at least it gives
better feedback on actual progress of the whole export.
Pull Request: https://projects.blender.org/blender/blender/pulls/114416
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).
USDZ conversion currently requires to change the 'current working
directory', due to internal USD library limitations.
This can only be done from main thread (and is highly discouraged in
general). This implies that USDZ conversion cannot happen from the Job
worker thread.
This commit moves it to the `endjob` callback of the USD export job
instead, as it is guaranteed to be executed from caller thread, i.e.
main thread in this case.
Pull Request: https://projects.blender.org/blender/blender/pulls/114420
The file that reproduces this had some faces of a mesh with vertex
normals, while some other faces were without vertex normals.
The parsing code assigns INT32_MAX as a fallback of "I could not parse
the normal index as a number" case, but later on code was not
catching this "normal index might be invalid" case. Fixes#114304
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.
The file that reproduces this had some faces of a mesh with vertex
normals, while some other faces were without vertex normals.
The parsing code assigns INT32_MAX as a fallback of "I could not parse
the normal index as a number" case, but later on code was not
catching this "normal index might be invalid" case. Fixes#114304
This usage of the whole USD `USDStageReader` as 'cache handle' feels a
bit... uncomfortable to me. It implicitely assumes that all data in this
owned by the reader (or has a lifetime that contains the whole handle
lifetime). IMHO, if such struct is expected to have a long lifetime, it
should be documented, and probably needs better design for sub-data
handling then. Am curious to know if there is a good reason why the
handle itself is not a simple trivial class, able to re-generate an
actual complete USD reader on demand?
Or maybe we need to find a better place to store the `wmJobWorkerStatus`
data?
Anyway, for now this PR addresses the issue by ensuring that the
`worker_status` stored in the `USDImportParams` is not `nullptr` before
trying to access it for the reports.
This is more of a short-term solution though, imho there should be a way
to pass a reportlist to this codepath, and ensure the `wmJobWorkerStatus`
is always valid?
Pull Request: https://projects.blender.org/blender/blender/pulls/114337
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
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.