I hava a class (PathMapping) with static const references, so need to init them in its constructor.
I nest it into another class (LOD), and add the necessary logic to its constructor as well.
This works as expected for a sinple object like so:
LOD test (templateMesh, templateConn, templateEdgeLengths);
But for multiple objects in a vector it does not:
std::vector<LOD> lods;
lods.resize(10, LOD (templateMesh, templateConn, templateEdgeLengths));
In this case the const references from pathMapping end up wrong. The remesh in nested pathMapping is not the same as in its enclosing LOD object.
I guess instead it uses the data contained in the single temporary LOD variable created while initializing the vector.
I could work around this by using a vector of pointer instead objects, but i wonder if this could be fixed properly somehow?
struct LOD
{
HEMesh remesh;
PathMapping pathMapping;
LOD ( const HEMesh &templateMesh,
const MeshConnectivity &templateConn,
const std::vector<float> &templateEdgeLengths)
: pathMapping (
remesh, templateMesh, templateConn, templateEdgeLengths,
remeshVertexToTemplate) {};
};