Well, I just peeked at your code, and I opened Controls.h, and the 1st thing I see is a function called "GetDirection()" but it doesn't seem to "Get" anything. There isn't a return value, nor any out variables. Typically, having a function named "GetBlah()" would return Blah in some way.
I'm sorry I didn't look at the rest, but I thought I would point that out.
Yeah, that's why I specifically mentioned not to look at the Controls file in my original post : It's the one file I hadn't really cleaned up or optimized in any way, shape or form. It's there in all of it's ugly, horrible glory It's also the one file that's probably seen the most changes.
But you have a good point. I think I had originally named it that as, while it doesn't return anything, it changes the quaternion angle and axis. So in my head, i was "getting" them by running that function and was unaware that that standard is to only use it when returning values. Thanks for the heads up!
(once you "const up" one function you pretty much have to make your entire codebase const-correct, and casting away const is often a slippery slope, so it can be a pain if you don't start upfront),
Out of curiosity, what do I need to look out for when using const? I ask because, there are lots of variables, that while they're fixed now, they won't necessarily be down the line. With the example of objType above, it stays the same now, but later I plan on that being changed (let you terraform the planets). I guess I ask because since this is my first time writing a program of this size, all the code goes through some pretty heavy and repeated revisions. I know that the correct answer is probably that I should have everything planned out from the beginning, but alas, this is more of a learn-as-I-go project and I'm pretty much implementing new features wily-nily as I learn how to do things. But, will I just be making my life miserable if I need to change a const back to a variable or vice-versa down the line, or is it relatively straight forward?
Newing objects without appropriate deletes. (and you should probably be using smart pointers of some kind here to avoid this issue as well, along with handling the following issue)
This question will probably come across as terribly dumb, but my first attempts at implementing smart pointers didn't work out for me. I initially ran into the problem of, when I try to create a vector of unique_ptrs to planets and push back new planets into them, they all got deleted at the end of the function (it works great until the function is done) I then tried to make the vector at the beginning of the Run() function, so they wouldn't be deleted until the program closed, but this didn't work either(I forget the exact error). Am I thinking about this entirely wrong? Should I just create a "Planet Manger" class that creates smart pointers to new planets as a function? I've gone over a few tutorials, but I'm missing something fundamental here about how smart pointers work I think. How does one go about being able to reference the object after more than one iteration if the pointer is deleted at the end of the function it's created in? I understand (partially, at least, i think) how the "move" syntax works to pass in ownership to a new function (but it's then deleted on that functions completion).
In a nutshell, I'm failing to create a vector of smart pointers to an object (well, I can create it, but that's about it), and use that vector until the program is closed. I'll keep reading over tutorials and cppreference.com, but if anyone feels like pointing me in the right direction I would appreciate it(terrible pun only half intended )
nevermind, I think I have that sorted out. Creating the vector of unique_ptrs to planets/stars at the beginning of the Run() function works, I was just doing it wrong If there is a more intelligent way to handle this, I'm still all ears, but I think I have it functional at least
after this thread, It's been pointed out that I totally don't need to use pointers at all for the vector of objects. So, I'll update that tomorrow. Though, I'm glad I'm now aware of smart pointers, so thanks everyone still for pointing that out.
Edited by Misantes, 18 July 2014 - 01:17 AM.