| 1715 | } |
| 1716 | |
| 1717 | void RenderScene(HScene scene, const RenderSceneParams& params, void* context) |
| 1718 | { |
| 1719 | Context* c = scene->m_Context; |
| 1720 | |
| 1721 | c->m_RenderNodes.SetSize(0); |
| 1722 | c->m_RenderTransforms.SetSize(0); |
| 1723 | c->m_RenderOpacities.SetSize(0); |
| 1724 | c->m_StencilClippingNodes.SetSize(0); |
| 1725 | c->m_StencilScopes.SetSize(0); |
| 1726 | c->m_StencilScopeIndices.SetSize(0); |
| 1727 | uint32_t capacity = scene->m_NodePool.Size() * 2; |
| 1728 | if (capacity > c->m_RenderNodes.Capacity()) |
| 1729 | { |
| 1730 | c->m_RenderNodes.SetCapacity(capacity); |
| 1731 | c->m_RenderTransforms.SetCapacity(capacity); |
| 1732 | c->m_RenderOpacities.SetCapacity(capacity); |
| 1733 | c->m_SceneTraversalCache.m_Data.SetCapacity(capacity); |
| 1734 | c->m_SceneTraversalCache.m_Data.SetSize(capacity); |
| 1735 | c->m_StencilClippingNodes.SetCapacity(capacity); |
| 1736 | c->m_StencilScopes.SetCapacity(capacity); |
| 1737 | c->m_StencilScopeIndices.SetCapacity(capacity); |
| 1738 | } |
| 1739 | |
| 1740 | c->m_SceneTraversalCache.m_NodeIndex = 0; |
| 1741 | if(++c->m_SceneTraversalCache.m_Version == INVALID_INDEX) |
| 1742 | { |
| 1743 | c->m_SceneTraversalCache.m_Version = 0; |
| 1744 | } |
| 1745 | |
| 1746 | CollectNodes(scene, c->m_StencilClippingNodes, c->m_RenderNodes); |
| 1747 | uint32_t node_count = c->m_RenderNodes.Size(); |
| 1748 | std::sort(c->m_RenderNodes.Begin(), c->m_RenderNodes.End(), RenderEntrySortPred()); |
| 1749 | Matrix4 transform; |
| 1750 | |
| 1751 | if (c->m_RenderNodes.Capacity() > c->m_RenderTransforms.Capacity()) |
| 1752 | { |
| 1753 | uint32_t new_capacity = c->m_RenderNodes.Capacity(); |
| 1754 | c->m_RenderTransforms.SetCapacity(new_capacity); |
| 1755 | c->m_RenderOpacities.SetCapacity(new_capacity); |
| 1756 | c->m_SceneTraversalCache.m_Data.SetCapacity(new_capacity); |
| 1757 | c->m_SceneTraversalCache.m_Data.SetSize(new_capacity); |
| 1758 | c->m_StencilClippingNodes.SetCapacity(new_capacity); |
| 1759 | c->m_StencilScopes.SetCapacity(new_capacity); |
| 1760 | c->m_StencilScopeIndices.SetCapacity(new_capacity); |
| 1761 | } |
| 1762 | |
| 1763 | uint32_t num_pruned = 0; |
| 1764 | for (uint32_t i = 0; i < node_count; ++i) |
| 1765 | { |
| 1766 | RenderEntry& entry = c->m_RenderNodes[i]; |
| 1767 | uint16_t index = entry.m_Node & 0xffff; |
| 1768 | InternalNode* n = &scene->m_Nodes[index]; |
| 1769 | float opacity = 1.0f; |
| 1770 | |
| 1771 | // Ideally, we'd like to be able to do this in an Update step, |
| 1772 | // but since the gui script is updated _after_ the gui component, we need to accomodate |
| 1773 | // for any late scripting changes |
| 1774 | // Note: We need this update step for bones as well, since they update their transform |