What kind of coding standard do you prefer

Started by
82 comments, last by JoeJ 1 year, 4 months ago

Juliean said:
That was something that I was suggesting before, so I'm not sure why you are asking me :D I would absolutely see it as a possibility to solve that “problem” by just measuring the max-peak of a what a cell can have, and then reserve to that.

Wastes more precious cache and memory than anything. I'd guess it's slower than pointer chasing as well on worlds larger than a screen.
Would you proudly show such code? Would you argue this way on some job interview, and still expect to get the job? I doubt you would. It's just for the sake of argue, yes?

Juliean said:
Since they were (i belive) talking about GPU-resources on that slide, I think they did mean actual fixed memory by design. They also did mention the part about making sure by asserting and testing regularily that the game doesn't blow up.

Was it to bin lights to a screen grid? Something like that? In such scenario, you do not know your object count, as it depends on camera. Thus the approach is eventually justified, although a single work group could handle proper compaction in no time.
But in our case the object count is always known. At least we know how many objects are allowed in the whole game, and we use that to use fixed sized memory for the whole system, so it never allocates anything, ideally.
Contrary, if you have to set a max count per grid cell (not per whole game), that's always bad. It causes design limitations, and still wastes memory. For absolutely no reason.
It's inferior, bad, and you can't talk it good, no matter how often you repeat the same bad arguments.

Juliean said:
Yeah, but if you store its own vector, the code would not be as simple anymore, to declare it the “simplest solution”

Imo it dos not increase complexity at all. Same algorithm, same data.

Juliean said:
Using this for other features could be done, but I'm not sure that a range-query would work. Without knowing the first object in the “list”

You do know the pointer to the first object. It's in the grid, your spatial acceleration structure. Which, likely, you keep around, in case you want spatial queries.
I mean, that's literally what a broad phase is doing: Spatial range queries.

Well, maybe that's a good keyword, to get to some other perspective you maybe prefer…

So, in my applet, i have called the objects Object, to keep it simple. But that's not what i personally associate with that data. It's not a game object, a sprite, or whatever.
It is a bounding volume (or area in 2D). In my case a bounding sphere, but could also be a bounding box (or rectangle).

And the collision system as shown is just the broad phase, not knowing about sprites or skeletons, or even the orientation of a rigid body.
It does not know about shapes, only their bounds. And it computes potentially colliding pairs, in other words: pairs of overlapping bounds.

A second, narrow phase collision detection system would then, knowing about actual shapes, calculate precise intersections from those pairs.
E.g. bit mask overlap tests for transparent sprites, or GJK algorithm to see if convex polyhedras intersect, etc.

Maybe you don't need such accuracy for your game and circles or rectangles are good enough, but the concept still makes sense.
And if you use ECS, you could add a collision component to your game objects, which then holds the bounding volume, the pointer, plus some index or ID for the pair mask, if needed.

The broad phase system could then also implement range queries, to find collision components inside a given rectangle range.

Btw, with all that argue we overlooked the true advantage of the vector approach:
If objects go to multiple cells, you can suppurt objects that are larger than a cell.
If objects go only into one cell, this does not work, and you'd need a multi level grid.
Multi level grid is faster anyway, but worth it only if many objects are large.
If you want small cells, and only few objects are larger than a cell, the vector approach becomes indeed more attractive.

Advertisement

Juliean said:
The main difference I see is that your example does not provide the ability to add new elements.

It does. I add a new element each time i insert an object into a grid cell.

Juliean said:
but you cannot add an entirely new “object”, unless there already exists an object of type “Object” somewhere.

Not true. Initially the cell is empty, and still i can add a object. No special case arises from this, and it just works.

Juliean said:
Its really not a data-structure at all at this points, its an optimization that effectively removes the need for an data-structure in the first place.

I think you associate with 'data-structure' an actual implementation, where all related functionality is implemented behind a complete and abstract interface, basically a C++ class with OOP design.
But i disagree with such assumption, because we have had data structures long before those things came up. E.g. with C, you could not add the interfaces to some class, nor could you bundle the implementation in some class.
All you could do is to write data structure (struct) and implementation (functions with global scope) in the same h and c files.
But it's still the same data structure and functionality. Where your implementation is, if it's written in place or in a function or method, does not change the fact we all use that same data structure the same ways.

So, if you would add your expectations on software design to the definition, this would only add unrelated bloat. Thus i don't believe it's part if the definition, simply because it's not needed to make it work, or to explain how it works.
But ofc. you need to provide code examples, which likely look like you expect. But may look a bit different in some older C book, for example.

JoeJ said:
Would you proudly show such code? Would you argue this way on some job interview, and still expect to get the job? I doubt you would. It's just for the sake of argue, yes?

No, its absolutely not for sake of arguments. But I'm afrait that if we are going there, I do have to stop this conversation, because this is where I feel things get might get personal/uncivil. I'm a bit on edge, but in combination with:

JoeJ said:
Contrary, if you have to set a max count per grid cell (not per whole game), that's always bad. It causes design limitations, and still wastes memory. For absolutely no reason. It's inferior, bad, and you can't talk it good, no matter how often you repeat the same bad arguments.

If you have to fall back to start calling arguments “bad” to make a point, then I feel thats the end of the line. There's no more nuanced discussion to be had from this point, and it would pretty much just turn into a flame war. Been there, done that. A shame, this went farther then I expected. But in the end, everything that has been said has been said, and whoever stumbles upon this thread and doesn't get bored on the first page can make up their own mind based on whats been presented.

So I'll just pretend that this goddamn forum had an “unfollow thead” option… wait, it has? Dayum. Now thats some nice thing to come from this!
Anyway, still no hard feelings on my side. So I'll end with a sincere Marry Christmas, or Happy Holiday, whether you prefer. I'll probably not be checking out the forums for the next days anyway ?

Juliean said:
If you have to fall back to start calling arguments “bad” to make a point, then I feel thats the end of the line.

I have to, because you refuse to accept / admit i'm right. It's just facts, and there is no point to argue once you accept those facts to be the facts they are.
Your arguments to turn issues into minor issues are irrelevant, because all those issues do not exist with the better solution.

I think you should just say: ‘I accept the issues, because they won't matter for me, and i just like the vectors approach better’. Which would be fine and is your personal choice anyway. I would not complain.
But you don't. Instead you repeat the same arguments, ignoring my proofs of the alternative being superior, and so i have to correct those arguments with my same counter arguments again and again as well.
The correction is needed, because you claim the inferior method would be on par or even better.

At some point i start to question if maybe you do not understand that all those memory issues are not necessary, or maybe you're just kidding me, and then you feel insulted in a sudden.
That's not my intent, i feel sorry for being harsh, and i did not mean it personal.

Good new year. Or good evening, in case you come back earlier than planned.

This topic is closed to new replies.

Advertisement