GOBJ_SPHERE,
GOBJ_AABOX,
GOBJ_BOX,
- GOBJ_PLANE
+ GOBJ_PLANE,
+ GOBJ_DISC
};
class GeomObject;
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;
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;
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;
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;
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;
//! 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.