Fix: USD Export: Calculate extents property for lights
Lights without calculated extents are not considered correct USD. This is now possible with the APIs provided by recent USD versions. Pull Request: https://projects.blender.org/blender/blender/pulls/113910
This commit is contained in:
committed by
Michael Kowalski
parent
ef3897f6a4
commit
e6ff1348cb
@@ -26,6 +26,18 @@ bool USDLightWriter::is_supported(const HierarchyContext * /*context*/) const
|
||||
return true;
|
||||
}
|
||||
|
||||
static void set_light_extents(const pxr::UsdPrim &prim, const pxr::UsdTimeCode time)
|
||||
{
|
||||
if (auto boundable = pxr::UsdGeomBoundable(prim)) {
|
||||
pxr::VtArray<pxr::GfVec3f> extent;
|
||||
pxr::UsdGeomBoundable::ComputeExtentFromPlugins(boundable, time, &extent);
|
||||
boundable.CreateExtentAttr().Set(extent, time);
|
||||
}
|
||||
|
||||
/* We're intentionally not erroring on non-boundable lights,
|
||||
* because the error spam can be annoying. */
|
||||
}
|
||||
|
||||
void USDLightWriter::do_write(HierarchyContext &context)
|
||||
{
|
||||
pxr::UsdStageRefPtr stage = usd_export_context_.stage;
|
||||
@@ -115,6 +127,8 @@ void USDLightWriter::do_write(HierarchyContext &context)
|
||||
usd_light_api.CreateDiffuseAttr().Set(light->diff_fac, timecode);
|
||||
usd_light_api.CreateSpecularAttr().Set(light->spec_fac, timecode);
|
||||
usd_light_api.CreateNormalizeAttr().Set(true, timecode);
|
||||
|
||||
set_light_extents(usd_light_api.GetPrim(), timecode);
|
||||
}
|
||||
|
||||
} // namespace blender::io::usd
|
||||
|
||||
Reference in New Issue
Block a user