While looking at someone's code i was struck by a way of representing data which, in a C context, seemed strange to me :
This person needed to represent different kind of geometries for a raytracer, each geometries while being different had similarities in their structures. So this person decided to represent the geometries through more or less abstract structs linked together through pointers.
s_entities -> s_scene_object -> s_sphere
s_entities -> s_scene_object -> s_plane
s_entities -> s_pointlight
i was wondering why one would decompose its data in C through abstraction layers instead of having an all-encompassing struct for each kind of data.
One explanation would be to reduce overhead if you have functions that operate on a certain layer of abstration of your data. right ?
it seems to me like remnants of OOP habits.