Avokadoen / TDT4195_code

A primitive openGL renderer made for an NTNU course
0 stars 0 forks source link

alternative scene graph implementation idea #11

Open Avokadoen opened 3 years ago

Avokadoen commented 3 years ago

The scene graph consist of nodes Each node holds an Vec of child nodes, transform, max_depth (longest distance to a leaf node) and an unique ID. The ID should describe the location of the node in the "tree". An example of such Id could be 0-0-1 or vec[0, 0, 1] (or array for that matter with a max depth)

Updating a node goes like:

  1. start at root node and locate target node using id
  2. apply change add to an delta batch for updating buffer
  3. iterate children and update transform according to parent node
  4. from here we can multithread using a thread pool depending on the child's children max depth
  5. Repeate step 2 until all children are updated and prepared to be sent to gpu
  6. Send delta batch to gpu

This could be designed around to create a simple API i.e

let tree_1_id = scene_graph.create_instance(&tree_mesh): scene_graph.translate(tree_1_id, 10, 0, 0) // TODO: describe creating nodes and adding them to the tree

TODO: Redefine return ID as a struct consisting of ids so that API user can create a "virtual tree" to interface with

Avokadoen commented 3 years ago

Related: #9