{
mOrderedComponents.Resize(mComponentCount);
+ unsigned int sceneId = 0;
+
TransformId parentId;
for(TransformId i = 0; i < mComponentCount; ++i)
{
mOrderedComponents[i].level = 0u;
parentId = mParent[i];
+ if(parentId == INVALID_TRANSFORM_ID)
+ {
+ mOrderedComponents[i].sceneId = sceneId++;
+ }
+
while(parentId != INVALID_TRANSFORM_ID)
{
mOrderedComponents[i].level++;
- parentId = mParent[mIds[parentId]];
+ parentId = mParent[mIds[parentId]];
+ mOrderedComponents[i].sceneId = mOrderedComponents[mIds[mParent[i]]].sceneId;
}
}
{
bool operator<(const SOrderItem& item) const
{
- return level < item.level;
+ if(sceneId != item.sceneId)
+ {
+ return sceneId < item.sceneId;
+ }
+ else
+ {
+ return level < item.level;
+ }
}
TransformId id;
- uint32_t level;
+ uint16_t sceneId;
+ uint16_t level;
};
/**
/**
* Reorders components in hierarchical order so update can iterate sequentially
- * updating the world transforms
+ * updating the world transforms. The components are sorted in the breadth first
+ * order for each scene and grouped per scene.
*/
void ReorderComponents();