I am trying to recursively construct an octree in C# as part of implementing Dual Contouring (https://www.cse.wustl.edu/~taoju/research/dualContour.pdf). The algorithm suggests using three types of octree nodes as some data is only relevant to a particular node. The three node types share several properties, such as a position, size and vertex buffer index, however they each also need to store some unique data. An example of one of the node types is shown below, along with the unique fields belonging to it.
Class HeterogeneousNode : OctreeNode
-int bitfield
-float qefResult
-Vector3[] points
-Vector3[] normals
I plan to have a base class OctreeNode and an OctreeNode array which I will store all the nodes in. However, I can't access the unique properties of HeterogeneousNode this way unless I downcast it to an OctreeNode, which I believe to be bad design.
I have also tried having just the OctreeNode class and placing the unique data in a struct. This seems wrong as it would mean leaving the struct fields at their default values for nodes that donn't need to store the extra data.
Is there a better way of approaching this problem? Thanks