X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fsnode.h;h=00e1798de4ea616a2582df1029cfeb17f600fbe6;hp=21cf16db0bc92691895fed17192472c310bc4ab9;hb=6ef619c6d92c698728576a4ec1c798a0f716d9a4;hpb=b7c92831285013b2a0783bccaf3d900545ebb5ba diff --git a/src/snode.h b/src/snode.h index 21cf16d..00e1798 100644 --- a/src/snode.h +++ b/src/snode.h @@ -3,8 +3,11 @@ #include #include "object.h" +#include "geom.h" #include "gmath/gmath.h" +class Scene; + class SceneNode { private: char *name; @@ -21,7 +24,14 @@ 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; + bool visible; // if true, objects of this node are supposed to be visible + SceneNode(); explicit SceneNode(Object *obj); ~SceneNode(); @@ -37,6 +47,8 @@ public: SceneNode *get_parent() const; + SceneNode *find_object_node() const; + void add_object(Object *obj); bool remove_object(Object *obj); @@ -61,7 +73,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_