I'm trying to figure out a way to make my scene graph in an efficient manner but I'm kind of stuck..
Basically the thing is that my engine basically lets users create hex tile maps in an editor where they can select a bunch of them and move them around as they please - the map can potentially contain as many hex tiles as the user wants to add - the pic illustrates
my question is - how the heck should I organize my scene graph so that in the editor I can have collision detection and such - right now they are each in a grid space that uses modulo division from their center point position to determine which grid space to put them in.. each grid space has a list of object references that currently occupy that space -
so basically I have one base grass hex tile object which has a RenderComponent that contains the mesh data and a vector of matrix transforms for each instance that is in the scene, The render manager then calls draw on just the one grass hex tile passing in the instance data...
The hard part is building the instance data - when there are a lot of tiles on the screen, updating this vector of matrices can be expensive if I do it every frame, right now I only rebuild the vector if a tile is added or deleted - if one is moved I modify the transform directly with the reference (each ObjectReference has a reference to its transform contained in the base object's RenderComponent transform vector.. sounds complicated I know) ...
This all seems like some kind of hack or workaround, It seems like there has got to be a better way to organize these hex tiles - collisions, for example, go through each object with a collision component and check to see if the grid spaces immediately surrounding that object contain objects that also have a collision component - if they do collision is checked... This seems clunky to me and unorganized - but I can't think of a better way to do this
If anyone has some idea on how I should organize my scene - please let me know - I am okay with completely trashing the structure I have now and rebuilding it