SceneNode bounds calculation
[laserbrain_demo] / src / snode.h
index 21cf16d..94ccb6a 100644 (file)
@@ -3,8 +3,11 @@
 
 #include <vector>
 #include "object.h"
+#include "geom.h"
 #include "gmath/gmath.h"
 
+class Scene;
+
 class SceneNode {
 private:
        char *name;
@@ -21,7 +24,13 @@ private:
        Mat4 xform;
        Mat4 inv_xform;
 
+       mutable bool local_bvol_valid;
+       mutable AABox local_bvol;
+
 public:
+       Scene *scene;   // scene to which this node belongs
+       Mat4 dbg_xform;
+
        SceneNode();
        explicit SceneNode(Object *obj);
        ~SceneNode();
@@ -61,7 +70,18 @@ public:
        void update_node(float dt = 0.0f);
        void update(float dt = 0.0f);
 
+       void apply_xform();
+
        bool intersect(const Ray &ray, HitPoint *hit) const;
+
+       // cached local bounding box (all objects in this node in model space)
+       const AABox &calc_local_bounds();
+       const AABox &get_local_bounds() const;
+
+       // world bounding box of the node
+       AABox get_node_bounds() const;
+       // world bounding box of the node and it's subtree
+       AABox get_bounds() const;
 };
 
 #endif // SNODE_H_