Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Pointers and defragmentation

$
0
0
I wanted to store more entities and components by value instead of unique pointers in contiguous memory. Every entity has a pointer to each of its components and to each of its child entities. Every component has a pointer to its owning entity. When I delete entities and components, wholes appear and fragmentation occurs. After n frames, I want to move the content of my arrays which is still alive, to close the gaps. This of course breaks all relations since data is moved around in memory. Each entity and component has a GUID, so I can technically use these instead of pointers. Unfortunately, this requires a search operation for every GUID that needs to resolved. Irrespective of some clever search algorithm, possibly combined with sorting the entities and components, this approach will always be too expensive. This especially becomes a bottleneck for transform components. Alternatively, it is possible to use the GUID to restore the pointers during defragmentation. But this manual labour does not sound very clever. So is it possible to use some alternative handle instead of a plain pointer that can be automatically and globally updated during defragmentation?

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>