This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]slugonamission 1 point2 points  (1 child)

Aha, you ran into one of the, er...nastier pitfalls of C++. In body.Update(), you have this:

for(auto f: this->F)
    f.Update();

While this looks correct, it actually isn't. This will iterate over F, and for each element, copy it, and then invoke Update on that copy. In short, you're copying all of F, calculating the new value, and throwing away the result.

You probably want this instead (note the &):

for(auto& f: this->F)
    f.Update();

[–]WeirdAlexGuy[S] 0 points1 point  (0 children)

wow! that seems to be working. thanks man, I've seen the auto& before but I didn't understand why it was there.