- Edited
Question for the cracks: pointers or handles ?
unsigned int m_x;
unsigned int m_z;
unsigned int m_level;
unsigned int m_size;
omath::vec2 m_min_max_height;
node *m_tl{nullptr};
node *m_tr{nullptr};
node *m_bl{nullptr};
node *m_br{nullptr};
So this is the current node struct I use to build the quad tree for my terrain renderer. X, z and level are vital, size, min and max values are there for sanity checks, will be eliminated.
So that leaves me with 44 bytes for a node. Not much, but with a huge terrain can still be unwieldy, possibly gigabytes of memory for the quad tree of a continent sized terrain (example 1.4 Gb for a terrain of size 1048576 by 1048576, leaf node size 256*256, 7 lod levels, nodes have 60 bytes with size and min/max values).
Biggest block are the four pointers, would I reduce them to 32 bit int values, that would reduce the structure size (and thus improve performance) considerably and I may end up with "just" 650mb for the same structure.
I stumbled upon this:
https://floooh.github.io/2018/06/17/handles-vs-pointers.html
and several discussions around the topic.
My question asks for an opinion (inadequate for stackexchange), has someone actually realized a project with handles, like written a class "handle" based on 32 bit integers that replicate the behaviour of classic raw pointers, and did it have the hoped-for impact on performance ?