3 ms·
I'm the last one to shill specific styles or languages, but: class b2Island { b2Body** bodies; b2Contact** contacts; b2Joint**
by lionkor 3y ago
I'm the last one to shill specific styles or languages, but:
class b2Island
{
b2Body** bodies;
b2Contact** contacts;
b2Joint** joints;
int bodyCount;
int contactCount;
int jointCount;
};
I understand that this is a physics engine and performance is paramount.
There is absolutely no real reason to use raw double pointers here, in my opinion there is likely a zero Overhead datastructure one could come up with to do exaftly the same thing, but unit-testable.
Further, why `int`? This isn't java, and this will cause any size comparisons to become unsigned-vs-signed comparisons, which likely will also be of different sizes. I'm saying those could and should be size_t, unless I'm missing something(?). Why would a count be negative? Why only allow a count up to int max, whatever that is on a given platform?
It just baffels me that people write serious business code in this style, still.
Edit: If the pointers are non-owning, there are references for that... Not that they're safer, but at least more idiomatic
- nightowl_games 3y agoHow would you write the struct?