{
}
+Box::Box(const AABox &aabox, const Mat4 &xform)
+ : xform(xform)
+{
+ min = aabox.min;
+ max = aabox.max;
+}
+
Box::Box(const Vec3 &min, const Vec3 &max)
: AABox(min, max)
{
}
+Box::Box(const Vec3 &min, const Vec3 &max, const Mat4 &xform)
+ : AABox(min, max), xform(xform)
+{
+}
+
// XXX all this shit is completely untested
Box::Box(const Vec3 &pos, const Vec3 &vi, const Vec3 &vj, const Vec3 &vk)
{
return true;
}
+bool calc_bounding_box(Box *box, const GeomObject *obj)
+{
+ switch(obj->type) {
+ case GOBJ_BOX:
+ *box = *(Box*)obj;
+ break;
+
+ case GOBJ_AABOX:
+ box->min = BOX(obj)->min;
+ box->max = BOX(obj)->max;
+ box->xform = Mat4::identity;
+ break;
+
+ case GOBJ_SPHERE:
+ {
+ float r = SPHERE(obj)->radius;
+ box->min = SPHERE(obj)->center - Vec3(r, r, r);
+ box->max = SPHERE(obj)->center + Vec3(r, r, r);
+ box->xform = Mat4::identity;
+ }
+ break;
+
+ case GOBJ_PLANE:
+ default:
+ return false;
+ }
+ return true;
+}
+
bool intersect_sphere_sphere(Disc *result, const Sphere &a, const Sphere &b)
{
Vec3 dir = b.center - a.center;