No, using OOP features does not add any significant overhead when done properly. If you are saying that things are effectively too slow, then I believe your problem is mostly that your algorithms are inefficient (ie: using O(n^2) algorithms for collision detection), ineffective frustum culling, lack of an LOD for your ships, etc...
En passant, si tu programme en C++, c'est mieux de tout faire en anglais que dans un horrible melange de francais et d'anglais... C'est simplement plus claire et plus habituel... Et tu trouvera de l'aide plus facilement.
Do excessive OOP in game can cause lag?
Quote:Original post by Arild FinesQuote:Original post by smr
As far as the switch statement goes, when using polymorphism the compiler is going to put some code in that selects the appropriate version of a method to call based on the class of the object. That logic is probably implemented as a switch statement too.
Eh, no.
A virtual call is implemented as an indirection through a vtable. In C it would look like this: <code>obj->vtable->VirtualMethod();</code>.
No switch.
Eh, ya got me.
Quote:Original post by Max_Payne
En passant, si tu programme en C++, c'est mieux de tout faire en anglais que dans un horrible melange de francais et d'anglais... C'est simplement plus claire et plus habituel... Et tu trouvera de l'aide plus facilement.
Ya know. I normaly code in english. This was the first time I made it in french just to see what it can be, and... It look messy lol
Whatever only the name of these classes are in french, my engine is in english of course. And ya, mix like entiteBehavior looks ugly.
Thanks anyway ;)
Definitely, mixing French and English in the code is a bad thing. Not only it doesn't look good, but you also have to remember what you used in French, what you used in English and what you mixed up. There's a kind of on-the-moment inspiration that probably won't come back when you'll be re-reading your source in a month.
Just for laughs (like the festival! :), I could send you my first sizeable Python program. You'll see what I mean. ;-)
And for the original question, no. I know of some young, brilliant programmer that really likes to work with objects, and he wouldn't use them in his engine if they were slowing things down. (Hi Max! ;-)
Seriously, classes are data structures with code associated to them. Nothing really fancy or hogging memory. To add to the discussion, inlining some functions that you use often will give your bigger objects, but faster execution. Well, a little bit anyway. :)
Just for laughs (like the festival! :), I could send you my first sizeable Python program. You'll see what I mean. ;-)
And for the original question, no. I know of some young, brilliant programmer that really likes to work with objects, and he wouldn't use them in his engine if they were slowing things down. (Hi Max! ;-)
Seriously, classes are data structures with code associated to them. Nothing really fancy or hogging memory. To add to the discussion, inlining some functions that you use often will give your bigger objects, but faster execution. Well, a little bit anyway. :)
The compiler I use, Free Pascal, has documented that it causes approx. 2 percent slow down. I an accept that! By the way I don't code 100 % oop, I want to be free in my game buildup. Don't want to give all things out of hand.
Cheers.
Cheers.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement