1

I have a List of Entities I want to update and than render. For updating:

Variable:

std::vector<Entity> entityList;

function:

void EntityController::update(){
    for(Entity e : entityList){        
        e.update();
    }
}

and the update function for the entity

void Entity::update(){

glm::mat4 trans = glm::mat4();
trans = glm::translate(trans, glm::vec3(50.0f,0.0f,50.0f));
trans = glm::scale(trans, glm::vec3(21.0,21.0,21.0));

modelMatrix = trans;
}

My problem here is, that the model matrix actually works. I can find all my information when I take a look at it (Debugging mode XCode), as long as I am in the class entity.

But When I am out of that class, the information in the model matrix is the identity matrix again. somehow he does not save, or update the information :S

DomiDiDongo
  • 133
  • 10
  • 1
    The most likely cause is that you are modifying a copy, not the original object. – R Sahu Nov 23 '15 at 18:32
  • That's my guess. It will be better if you can post a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – R Sahu Nov 23 '15 at 18:36
  • I added a little bit in the code. somehow I forgot the for each loop. But I don't know what information more could be necessary. – DomiDiDongo Nov 23 '15 at 18:47

1 Answers1

2

You're update()ing Entity copies with your current range for:

for(Entity e : entityList)
          ^ huh?

You probably wanted references:

for(Entity& e : entityList)
          ^ important
genpfault
  • 51,148
  • 11
  • 85
  • 139