Originally Posted by
King Mir
Your discription is a little unclear. Please elaborate so we can give more specific advice
The following should help to clarify. it's not actual code, but it shows what I'm trying to figure out.
Code:
struct Entity{
3DModel *model;
}
std::vector<3DModel> models;
void load_model(Model &m){
models.push_back(m);
}
void load_entity(Entity *e, const char *modelName){
e->model = find_model(&models, modelName);
}
void draw_entity(Entity *e){
draw_model(e->model);
}
void function_a(){
3DModel mA;
Entity a;
load_model(mA);
load_entity(&a, mA.name);
draw_entity(&a);
}
void function_b(){
3DModel mB1, mB2;
Entity b;
load_model(mB1);
load_entity(&b, mB1.name);
load_model(mB2); //makes b.model invalid if reallocation occurs
draw_entity(&b);
}
I am looking for a way to keep something like b.model valid, even if I add more members to the models vector.