Initial USD Import open sourcing.
Cherry-picked commit of Tangent Animation's
USD importer from branch ta-usd-import inhttps://github.com/tangent-opensource/blender.git
Fixed compile errors. Registering USD plugins.
USD importer stage traversal options.
Added new stage traversal options to filter prim import
based on purpose (guide, proxy and render) and whether
to traverse instances with instance proxies. Also modified
the stage traversal logic to avoid a small memory leak due to
creating a reader for the pseudo root which is never used or
USD importer: custom normals shading bug.
Removed call to BKE_mesh_calc_edges() after setting
UVs, as this function is already called after setting
polys. Moreover, the second, redundant call was causing
incorrect viewport shading of previously set custom
normals. Now also setting the ME_AUTOSMOOTH mesh flag
to enable shading with custom normals.
USD importer: vertex normals render black.
Setting point normals by invoking normal_float_to_short_v3(),
instead of directly assigning components as floats.
USD import: Handle empty vertex-varying normals.
If point normals are empty, now invoking BKE_mesh_calc_normals()
to avoid black renders. Since BKE_mesh_calc_normals() requires
edges to be defined, moving point normal calculation to follow
USD import: handle primvars:normals if specified.
Per Pixar UsdGeomPointBased documentation: If 'normals' and
'primvars:normals' are both specified, the latter has precedence.
USD import: orientation bug.
Uninitialized USDMeshReader::m_isLeftHanded flag was
causing the vertex winding orientation to randomly flip,
causing incorrect shading and other issues.
Apply orientation when importing USD normals.
Also added check to ensure normal and loop counts match.
USD Import: Visible Prims Only flag.
Added new option to prune primitives by visibility.
If this option is enabled, invisible prims will
be excluded from the traversal. This only applies
to prims with a non-animating visibility attribute.
Prims with animating visibility will always be imported.
USD import: xform cache constraint parenting bug.
USD_get_transform() was not taking the object's parent
transform into account. Now following the same logic
as in the corresponding Alembic implementation,
ABC_get_transform(), to fix this.
USD import: convert UsdGeomImageables only.
Currently, the importer converts every node in the USD
to a Blender Empty object by default, including nodes
that aren't of UsdGeomImageable type, such as materials
and shaders. This can unnecessarily bloat the Blender
scene with nodes that are not immediately useful. I've
added logic to restrict conversion to nodes that are
UsdGeomImageables, and this can have a dramatic effect
in some cases. For exmaple, the number of nodes imported
in the Attic scene is reduced from 1,025 to 238 with
USD import: uniform interpolation normals.
Added logic to import USD normals with uniform interpolation
(i.e., per-face normals) as Blender loop normals.
USD Importer: dependency graph update crash.
Fixed occasional random crash due to simultaneous update
to the dependency graph from multiple threads. A typical
collision might happen when the USD import job thread
is creating a material while the window manager in the
main thread is processing event notifiers. The current
fix is to remove the ND_FRAME flag from the call to
WM_jobs_timer(), which prevents ED_update_for_newframe()
from being called from wm_event_do_notifiers().
USD Import: support instance collections.
Added an experimental Instancing option to support
importing USD scenegraph instances as Blender
USD Import: Minor instancing fixes.
Small edit to the Instancing import option parameter
description. Now allowing setting null instance collection
on USDInstanceReader objects.
USD Import: UV fixes.
Made the following updates to fix UV import errors:
Added logic to read UVs with Vertex interpolation and
indexed UVs. Fixed incorrect UV winding order for
USD Import: USDPrimReader uninitialized members.
Fixed bug where several USDPrimReader class member variables
were not being intialized in the constructor. One of the
previously uninitialized variables stores the reference count,
which was causing memory leaks in some cases.
USD Import: USD Preview conversion.
Added experimental Import USD Preview option to convert
UsdPreviewSurface shaders to Principled BSD shader networks,
for an approximate preview. Added new USDMaterialReader
class, which implements this feature. Also added a
Set Material Blend option to automatically set the material
blend method based on the UsdPreviewSurface shader's opacity
and opacityThreshold inputs. Finally, updated the logic so that
no materials will be imported if the Materials option is
USD Import: made USDPrimReader destructor virtual.
USD Import format fixes.
USD Import: Scale option fixes.
Updated the code to apply the global scale option, which
was previously ignored. Fixed application of global scale
in the xform reader matrix calculation to only apply the
scale to root objects. Also fixed bug in setting the
is_constant flag and simplified some of the code.
USD Import: Convert to Z Up option.
Added a Convert to Z Up import option and logic to rotate
imported root objects 90 degrees about the X-axis if this
option is checked and the USD stage up-axis is Y.
USD Import: Formatting fixes.
USD Import: simplify xform matrix computation.
Updated the USDXformReader matrix computation function to use the
standard UsdGeomXformable API for querying the prim's local
transform and to determine whether the matrix is time-varying,
rather than explicitly iterating over the UsdGeomXformOps.
USD Import: fixed compiler warning.
USD Import: Light Intensity Scale option.
Added new float import option to scale intensity of imported
USD Import: fixed compiler warnings.
USD Import: subdiv option default to off.
The Import Subdiv Option can sometimes behave unexpectedly,
losing all sharp edges. Turning this option off by default
until the behavior can be fine tuned.
USD Import: crash on reading no polys.
Fixed a crash where polys were not being read for new meshes when
the MOD_MESHSEQ_READ_POLY flag isn't set. Crash occurs because
downstream code expects polys to exist. Modified the logic to
always read verts and polys for new meshes, regardless of the
value of the read flag.
USD Import: removed printf call.
USD Import: read attributes null data guard.
Checking for null pointer to avoid crash when custom data
USD Import: import display colors.
Added support for reading the display color primvars. This
option is off by default in the mesh read flags.
USD Import: removed WM_reportf() trace calls.
USD Import: removed commented out code.
USD Import: use pragma once in headers.
Replaced include guards with pragma once directives,
to conform to the conventions used in the existing USD
USD Import: removed unneeded include guards.
USD Import: added blender::io::usd namespace.
Added blender::io::usd namespace where it was missing, to
conform to the convention used in the USD exporter code.
USD Import: snake case for function names.
As part of code cleanup, now using snake case consistently
for class member function names, to match the convention
used in the USD exporter code.
USD Import: naming convention fix.
To be consistent with the convention used in the USD exporter,
updated class member variables to consistently use snake case
and trailing underscores instead of the m_ prefix.
USD Import: UsdPrimReader interface cleanup.
Removed empty add_cache_modifier() function and made
USD Import: remove UsdPrimReader stage member.
The UsdPrimReader class doesn't need a stage pointer as a
member because the stage can implicitly be accessed
through the prim itself, as long as the prim is valid.
I removed the UsdPrimReader::stage_ member and updated the
relevant constructors and function calls. Also, updated
the various readers to construct schemas directly from
the contained prim, e.g., pxr::UsdLuxRectLight rect_light(prim_)
USD Import: stage reader validation and cleanup.
Added USDStageReader validation and guard against null
stage in the USDStageReader destructor.
USD Import: remove usd_util files.
Moved the two create_reader() implementations from usd_util.(h|cc)
to static functions in UsdStageReader and removed the usd_util
files from the project.
USD Import: fix reader refcount error.
Currently, USDPrimReader reference counts aren't correctly
maintained because the readers are stored in two separate
arrays, in the USDStageReader instance and also in the
import job data, but the reference counts for the readers
is incremented only once. I changed the logic to store
the readers only in the USDStageReader. Now also deleting
the stage reader instance, fixing a small memory leak. Also,
simplified the syntax for for looping over readers, to make
the code more readable.
USD Import: enforcing const correctness.
USD Import: removed unneeded includes.
USD Import: remove unsupported geometry flags.
For now, removing support for reading velocities and
attributes, because the data allocation for these layers
no longer works in the current version of Blender. We will
revisit implementing these features in the future.
USD Import: removed unneeded code.
USD Import: check bound materials on all subsets.
Changed material import logic to check bound materials
on all subsets, not just on the 'materialBind' subsets,
as this is necessary for geometry currently exported
USD Import: schema initialization and validation.
Now initializing schemas in the constuctor initialization
lists of reader classes. Checking schemas to validate
readers. Additional, minor cleanup.
Differential Revision: https://developer.blender.org/D10700