Reputation: 0 Apprentice
- New Members
- Active Posts:
- 1 (0 per day)
- 07-July 10
- Profile Views:
- Last Active:
- Jan 04 2012 03:36 PM
- Dream Kudos:
Posts I've Made
Posted 4 Jan 2012The destructor isn't virtual, but the GetMesh() is..
Which means it's meant to be derived from... I see a possible memory leak if the destructor deallocates memory.
It already has a vtable because GetMesh has the virtual keyword.
You can replace the Quaternion with 3 Euler angles. This can be converted into a Quaternion if necessary at runtime.
Of course it may be easier to keep it as a Quaternion (for interpolation and gimble lock avoidance, etc.)
Someone already mentioned the bit flags. Good idea.
Correct me if I'm wrong, I don't know much about padding, but I believe the compiler will auto-pad the class if the variables aren't aligned to some bytes...
I don't know though..
Design-wise: You could start off by stating that this code is complete crap. I'm sure this would get them interested.
The cohesion is very low. Notice that the class groups "health" and "orientation" together in the same class...
They don't have anything to do with one another.
You could, oh I don't know..... factor out position, velocity, and orientation into say, some sort of component... Like a physics component...
Or, for runtime optimization: It looks like you could use Data Oriented Design...
This class is a perfect example of cache poisoning.. Or cache pollution... If we have an array of game objects, for example, we have, not only the good stuff in the cache lines, we have the useless crap too... We only want good stuff... When the integrator loops through each game object, it has useless crap it doesn't need in there, such as health... So where does it have to fetch the next position/velocity/etc. from? Main memory because the cache is all full of useless crap.
Create an array of velocities, an array of positions, an array of orientations... So when the integrator loops through these arrays and updates them all,
the next position (or whatever) will will be in the cache already.. It's locality of reference will be good.
Data oriented design will, not only be faster, it'll decrease the footprint of all the game objects in the game because less padding will be used per game object... right?
I dunno, I'm not 100% sure about the padding.
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
aragonsr hasn't added any friends yet.