| 957 | } |
| 958 | |
| 959 | void SceneGraph::Refresh(uint32_t frameIndex) |
| 960 | { |
| 961 | struct StackItem |
| 962 | { |
| 963 | bool supergraphTransformUpdated = false; |
| 964 | bool supergraphContentUpdate = false; |
| 965 | }; |
| 966 | |
| 967 | bool structureDirty = HasPendingStructureChanges(); |
| 968 | |
| 969 | StackItem context; |
| 970 | std::vector<StackItem> stack; |
| 971 | |
| 972 | SceneGraphWalker walker(m_Root.get()); |
| 973 | while (walker) |
| 974 | { |
| 975 | auto current = walker.Get(); |
| 976 | auto parent = current->m_Parent; |
| 977 | |
| 978 | // save the current local/global transforms as previous |
| 979 | current->m_PrevLocalTransform = current->m_LocalTransform; |
| 980 | current->m_PrevGlobalTransform = current->m_GlobalTransform; |
| 981 | current->m_PrevGlobalTransformFloat = current->m_GlobalTransformFloat; |
| 982 | |
| 983 | bool currentTransformUpdated = (current->m_Dirty & SceneGraphNode::DirtyFlags::LocalTransform) != 0; |
| 984 | bool currentContentUpdated = (current->m_Dirty & SceneGraphNode::DirtyFlags::SubgraphContentUpdate) != 0; |
| 985 | |
| 986 | if (currentTransformUpdated) |
| 987 | { |
| 988 | current->UpdateLocalTransform(); |
| 989 | } |
| 990 | |
| 991 | // update the global transform of the current node |
| 992 | if (parent) |
| 993 | { |
| 994 | current->m_GlobalTransform = current->m_HasLocalTransform |
| 995 | ? current->m_LocalTransform * parent->m_GlobalTransform |
| 996 | : parent->m_GlobalTransform; |
| 997 | } |
| 998 | else |
| 999 | { |
| 1000 | current->m_GlobalTransform = current->m_LocalTransform; |
| 1001 | } |
| 1002 | current->m_GlobalTransformFloat = dm::affine3(current->m_GlobalTransform); |
| 1003 | |
| 1004 | // initialize the global bbox of the current node, start with the leaf (or an empty box if there is no leaf) |
| 1005 | if ((current->m_Dirty & (SceneGraphNode::DirtyFlags::SubgraphStructure | SceneGraphNode::DirtyFlags::SubgraphTransforms)) != 0 || context.supergraphTransformUpdated) |
| 1006 | { |
| 1007 | current->m_GlobalBoundingBox = dm::box3::empty(); |
| 1008 | if (current->m_Leaf) |
| 1009 | { |
| 1010 | dm::box3 localBoundingBox = current->m_Leaf->GetLocalBoundingBox(); |
| 1011 | if (!localBoundingBox.isempty()) |
| 1012 | current->m_GlobalBoundingBox = localBoundingBox * current->m_GlobalTransformFloat; |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | // initialize the content flags of the current node |
nothing calls this directly
no test coverage detected