How to modify struct array inside struct? c++
Hi, I tried to post this as a thread in the forums but apparently it didn't get through for some reason.
I'll try to keep it short. I am making a hex tile grid procedural generation. I use Instanced Static Mesh components to generate the tiles given X,Y coordinates and position the transform of every instance. I was previously using actors but because of performance problems im switching to ISM's. Since I cant store any data in the ISM instances themselves I am trying to keep everything indexed using my own Ftile_indexer struct. After I place the tile instance I create a struct of this type and I store it in an array. This works fine with the data sent as initialization on its constructor.
Problem is, I have a second struct array inside Ftile_indexer. It is an array that stores structs of another struct called Fneighbour. I am doing this so I can keep track of the graph that is being generated when I spawn the tiles. Whenever I find out that a tile should be neighbor to another tile I send a Fneighbour struct to the tile and save the information of its neighbor in its neighbors array. For some reason, when I add the neighbor, the array is getting modified (I checked with a debug message) as its size is increasing. Nevertheless, when I try to get the neighbor array from an Ftile_indexer struct the array is empty. Am i losing the references somewhere? I'm not really sure what I'm doing wrong.
This is my header for the map_controller and this is the .cpp. generate_hex_grid() : function where i spawn the tiles through instancing from a random ISM. generate_graph(): is where i am setting the neighbors.
If Anyone can come up with some helpful advice or a different solution for an indexing system that works with tiles and neighbors I would really appreciate it. Thanks in advance. Cheers!
asked Oct 12 '16 at 06:30 PM in C++ Programming
Follow this question
Once you sign in you will be able to subscribe for any updates here