aboutsummaryrefslogtreecommitdiff
path: root/src/scene/node_impl.h
blob: c79f25275781bb3a1c8050af75d46e7d383661a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once

#include <gfx/scene/node.h>

#include "types.h"

#include <cstring.h>
#include <math/mat4.h>

/// Scene node.
///
/// The SceneNode owns its cameras, objects, lights and child nodes. These
/// together form a strict tree hierarchy and not a more general DAG.
typedef struct SceneNode {
  NodeType type;
  union {
    anima_idx  anima;
    camera_idx camera;
    light_idx  light;
    model_idx  model;
    object_idx object;
  };
  mat4     transform; // Transformation for this node and its children.
  node_idx parent;    // Parent SceneNode.
  node_idx child;     // First child SceneNode.
  node_idx next;      // Next sibling SceneNode.
  node_idx prev;      // Previous sibling SceneNode.
} SceneNode;

/// Recursively destroy a node given its index but without destroying the node
/// resources.
///
/// The node and its children are removed from the scene graph.
///
/// This function is for the library's internal use only.
void gfx_del_node(node_idx);

/// Return a shallow clone of the scene rooted at the given node.
/// The given node must have no siblings (must be a root node).
SceneNode* gfx_clone_scene_shallow(const SceneNode*);