X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fgeom.h;h=5db1996d09c5743d4a4fa59debaa7db5dc18ee7c;hp=24a0b864bb3692f168dd275bc9a20f029e33facd;hb=03085a16aa2fef785083fa3921be83015e08b290;hpb=ca5d732eb2b76da1e01428193effeb205ae951e9 diff --git a/src/geom.h b/src/geom.h index 24a0b86..5db1996 100644 --- a/src/geom.h +++ b/src/geom.h @@ -12,7 +12,8 @@ enum GeomObjectType { GOBJ_SPHERE, GOBJ_AABOX, GOBJ_BOX, - GOBJ_PLANE + GOBJ_PLANE, + GOBJ_DISC }; class GeomObject; @@ -33,6 +34,9 @@ public: GeomObject(); virtual ~GeomObject(); + virtual bool valid() const; + virtual void invalidate(); + virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const = 0; virtual bool contains(const Vec3 &pt) const = 0; @@ -48,6 +52,9 @@ public: Sphere(); Sphere(const Vec3 ¢er, float radius); + virtual bool valid() const; + virtual void invalidate(); + virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const; virtual bool contains(const Vec3 &pt) const; @@ -62,6 +69,9 @@ public: AABox(); AABox(const Vec3 &min, const Vec3 &max); + virtual bool valid() const; + virtual void invalidate(); + virtual Vec3 get_corner(int idx) const; virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const; @@ -76,10 +86,14 @@ public: Mat4 xform; Box(); + Box(const AABox &aabox, const Mat4 &xform); Box(const Vec3 &min, const Vec3 &max); + Box(const Vec3 &min, const Vec3 &max, const Mat4 &xform); Box(const Vec3 &pos, const Vec3 &vi, const Vec3 &vj, const Vec3 &vk); Box(const Vec3 *varr, int vcount); + virtual void invalidate(); + virtual Vec3 get_corner(int idx) const; virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const; @@ -114,6 +128,9 @@ public: Disc(const Vec3 &pt, const Vec3 &normal, float rad); Disc(const Vec3 &normal, float dist, float rad); + virtual bool valid() const; + virtual void invalidate(); + virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const; //! true if the projection of pt to the plane is contained within the disc radius virtual bool contains(const Vec3 &pt) const; @@ -143,6 +160,9 @@ bool calc_bounding_aabox(AABox *box, const GeomObject **objv, int num); //! calculate the bounding axis-aligned box of multiple points, optionally transformed by `xform` bool calc_bounding_aabox(AABox *box, const Vec3 *v, int num, const Mat4 &xform = Mat4::identity); +//! calculate the bounding box of any object +bool calc_bounding_box(Box *box, const GeomObject *obj); + //! calculate the intersection plane of two spheres. false if there is no plane or infinite planes. bool intersect_sphere_sphere(Plane *result, const Sphere &a, const Sphere &b); //! calculate the intersection line of two planes. returns false if planes are exactly parallel.