MCPcopy Create free account
hub / github.com/DiligentGraphics/DiligentFX / Sync

Method Sync

Hydrogent/src/HnCamera.cpp:56–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void HnCamera::Sync(pxr::HdSceneDelegate* SceneDelegate,
57 pxr::HdRenderParam* RenderParam,
58 pxr::HdDirtyBits* DirtyBits)
59{
60 pxr::HdDirtyBits OrigDirtyBits = *DirtyBits;
61 pxr::HdCamera::Sync(SceneDelegate, RenderParam, DirtyBits);
62
63 if (OrigDirtyBits & pxr::HdCamera::DirtyTransform)
64 {
65 m_WorldMatrix = ToFloat4x4(_transform);
66 m_ViewMatrix = m_WorldMatrix.Inverse();
67 }
68
69 if (OrigDirtyBits & pxr::HdCamera::DirtyParams)
70 {
71 const float MetersPerUnit = RenderParam ? static_cast<const HnRenderParam*>(RenderParam)->GetMetersPerUnit() : 0.01f;
72 const float HorzAperture = GetHorizontalAperture();
73 const float VertAperture = GetVerticalAperture();
74 const float FocalLength = GetFocalLength();
75 const pxr::GfRange1f ClippingRange = GetClippingRange();
76
77 m_ProjectionMatrix._11 = FocalLength / (0.5f * HorzAperture);
78 m_ProjectionMatrix._22 = FocalLength / (0.5f * VertAperture);
79
80 const HnRenderDelegate* pRenderDelegate = static_cast<const HnRenderDelegate*>(SceneDelegate->GetRenderIndex().GetRenderDelegate());
81 const IRenderDevice* pDevice = pRenderDelegate->GetDevice();
82 const RenderDeviceInfo& DeviceInfo = pDevice->GetDeviceInfo();
83 // USD camera attributes are in scene units, while Diligent expects them in world units
84 m_ProjectionMatrix.SetNearFarClipPlanes(ClippingRange.GetMin() * MetersPerUnit, ClippingRange.GetMax() * MetersPerUnit, DeviceInfo.GetNDCAttribs().MinZ == -1);
85 }
86}
87
88} // namespace USD
89

Callers

nothing calls this directly

Calls 3

ToFloat4x4Function · 0.85
GetMetersPerUnitMethod · 0.80
GetDeviceMethod · 0.45

Tested by

no test coverage detected