Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well first of all, your method getComponent is using operator [] which not only retrieves instance with given key, but if not present, inserts an element.</p> <p><a href="http://www.cplusplus.com/reference/map/map/operator%5B%5D/" rel="nofollow">http://www.cplusplus.com/reference/map/map/operator%5B%5D/</a></p> <p>In given implementation you limit yourself to one component of each type in an entity which might not be the best option. For example you might want to have a few renderable component for one entity doing various things like particles, mesh rendering etc. </p> <p>Map does not guarantee that object are laid in memory sequentially which might cause a cache miss when processed one by one. It would be more efficient to use std::vector for example, and keep the COMPONENT_INFO in the component object itself. </p> <p>Another solution would be to add methods to your system class that would create particular types of components and while doing so, doing some bookeping about each component instance. System could then keep vectors of each component type and do batch processing on those.</p> <p>Hope this will help a bit.</p> <p>Edit:</p> <p>The idea is that when you add/create new Collision component the component itself registers in the system providing type and pointer to itself. The same for renderables etc. You can have map of vectors for each component type in your system. When you need to resolve collsion you just retrieve all your collidables (reference to a vector). You make one lookup which is log(n) and then iterate over all collidables (the pointers due to being in vector are layed out sequentially in memory making it more cache friendly).</p> <p>Also do you test performance in release build?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload