0

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

  • It is really hard to answer the questions in the last sentence as the rest of the question doesn't say much about memory use and OO best practices. Please try to make this question as specific as possible. – Emond Feb 26 '19 at 19:54
  • @ErnodeWeerd Thanks for the feedback. I'll try to clarify the question. – MasterReDWinD Feb 27 '19 at 04:38
  • @Erno I tried to make the question more precise and also reworded it as a new question (https://stackoverflow.com/questions/54947438/how-to-store-data-in-an-octree). Can you spot anything else that I should be doing to increase my chances of getting a response? Many thanks. – MasterReDWinD Mar 03 '19 at 19:53

0 Answers0