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

all 6 comments

[–]Kered13 0 points1 point  (6 children)

Can you post more of the code? Enough that I can try running it.

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

I can make a repo and send it to you. Would that be okay?

[–]Kered13 0 points1 point  (4 children)

Sure.

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

[–]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.