I am generating a collection of values each frame and I would like to add those values to a larger collection of values at a specific index.
This is a typical example of a collection I am generating
std::vector<glm::vec3> corners;
corners.reserve(8);
//glm::vec3 corners[8];
//std::list<glm::vec3> corners;
corners[i++] = position - hX + hY + hZ;
corners[i++] = position + hX + hY + hZ;
corners[i++] = position + hX - hY + hZ;
corners[i++] = position - hX - hY + hZ;
corners[i++] = position - hX + hY - hZ;
corners[i++] = position + hX + hY - hZ;
corners[i++] = position + hX - hY - hZ;
corners[i++] = position - hX - hY - hZ;
I then have a larger collection of glm::vec3 values that I would like to copy the values above to at a particular index.
std::vector<glm::vec3> vertices;
vertices.assign(maxVertices, 0);
The C# equivalent would be
corners.CopyTo(vertices, index);
What class type can I use to efficiently generate and copy the smaller collection across to the larger one without too much overhead of generating it each frame?
I could get away with assigning each newly generated smaller collection to the end of the larger collection so the index value could be ignored.
In your code you should
corners.resize(8), notcorners.reserve(8).Besides, if i understand you correctly, it seems you have always 8 corners?
Use array then:
Then filling can be done with initialization:
Copying can be done with standard copy:
If you need to insert instead of copy then use vertices.insert()