Fix: USD Export: Calculate extents properly for lights #113910
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue