Sorry, perhaps I ought to have been more specific/clear, by 3D, I mean I have a three dimensional grid of vector locations that I want to add to an array; I read that you can do a struct in a struct in a struct to get an easily readable set of data, like a bog standard multi-dimensional array in C++ but that seems a bit hacky and slow.
I suppose if I were a mathematician I could think of a mathematical way to get all the correct values in to the array but I don’t know a formula to iterate all potential values in a cube grid and also not sure if that would be performant enough anyway.
Other option is 3 layer index segmentation over 1D array to create virtual 3d index, let say we have continues 32x32x32 3D data and so we can calculate index for 3d potion like this:
So for more universal size solution let say S is size on all dimentions
It;s a lot easier to operate this as by going thru index you will read data from other dimensions and you can go thru entire cube with single for each.
You can also try using map,
but map stores index same as data , so it not really optimal way , but if you have non-continues data (have lot of zero/null data) and just single positions in you can all store them in map and store only pieces of cube that is impotent. Only issue with Vector as key of map is that vector is a float and may have precision issues
Yes I was thinking of making a struct that is just a trio of ints that I treat as a vector. I’m not totally clear on the method but I will try and follow it and see if I get it. Eventually, I will want to be able to remove chunks from the vector map when they become used so it will get irregular over time. I think I need to do more research on how to handle this kind of data.
Sorry for the late replies, I posted them much earlier but they were being moderated. In UE4 Blueprint they show up as a bunch of floats I suppose because people are doing gameplay stuff like raycasting with it? I suppose if you were doing this in C++ you might not use the Blueprint version.
I’ve looked this up elsewhere and some people include this big solver in their projects which gathers all the possible points in a grid but I think that level of complexity is unnecessary for me.
No it is struct of floats, you can see it it’s API refrence:
It probably wont harm if you use integers only, but there always possibility CPU might butcher they key during processing by adding some odd fraction making value hard to access without looping
There different type which has vector made of integers called FIntVector, but not sure if you can use it in Blueprints, you can try to find it, but oyu can definitely make more stable map with it in C++:
It would be hard to do graphical related stuff in vector of integers.
I also notice there being new template implemented TVector allowing you to create any vector type with as much of dimensions you desire
I generally find that when using these different ways of trying to represent ideas ( whether is be by segmenting index or using structures etc ), some parts of the code become very elegant, but other parts can end up being much worse…