More bounding boxes
This commit is contained in:
@@ -122,7 +122,7 @@ Tuple Cone::localNormalAt(Tuple point)
|
||||
return Vector(point.x, y, point.z);
|
||||
}
|
||||
|
||||
BoundingBox Cone::getBounds()
|
||||
BoundingBox Cone::getLocalBounds()
|
||||
{
|
||||
BoundingBox ret;
|
||||
|
||||
@@ -130,11 +130,8 @@ BoundingBox Cone::getBounds()
|
||||
double b = fabs(this->maxCap);
|
||||
double limit = (a > b)?a:b;
|
||||
|
||||
ret.min = this->objectToWorld(Point(-limit, this->minCap, -limit));
|
||||
ret.max = this->objectToWorld(Point(limit, this->maxCap, limit));
|
||||
|
||||
ret.min.fixPoint();
|
||||
ret.max.fixPoint();
|
||||
ret | Point(-limit, this->minCap, -limit);
|
||||
ret | Point(limit, this->maxCap, limit);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -108,15 +108,12 @@ Tuple Cylinder::localNormalAt(Tuple point)
|
||||
return Vector(point.x, 0, point.z);
|
||||
}
|
||||
|
||||
BoundingBox Cylinder::getBounds()
|
||||
BoundingBox Cylinder::getLocalBounds()
|
||||
{
|
||||
BoundingBox ret;
|
||||
|
||||
ret.min = this->objectToWorld(Point(-1, this->minCap, -1));
|
||||
ret.max = this->objectToWorld(Point(1, this->maxCap, 1));
|
||||
|
||||
ret.min.fixPoint();
|
||||
ret.max.fixPoint();
|
||||
ret | Point(-1, this->minCap, -1);
|
||||
ret | Point(1, this->maxCap, 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,11 @@ bool Group::isEmpty()
|
||||
return (this->objectCount == 0) && (this->unboxableObjectCount == 0);
|
||||
}
|
||||
|
||||
BoundingBox Group::getLocalBounds()
|
||||
{
|
||||
return this->bounds;
|
||||
}
|
||||
|
||||
BoundingBox Group::getBounds()
|
||||
{
|
||||
if (this->bounds.isEmpty()) { this->updateBoundingBox(); }
|
||||
|
||||
@@ -35,15 +35,12 @@ Tuple Plane::localNormalAt(Tuple point)
|
||||
return Vector(0, 1, 0);
|
||||
}
|
||||
|
||||
BoundingBox Plane::getBounds()
|
||||
BoundingBox Plane::getLocalBounds()
|
||||
{
|
||||
BoundingBox ret;
|
||||
|
||||
ret.min = this->objectToWorld(Point(-INFINITY, 0-getEpsilon(), -INFINITY));
|
||||
ret.max = this->objectToWorld(Point(INFINITY, 0+getEpsilon(), INFINITY));
|
||||
|
||||
ret.min.fixPoint();
|
||||
ret.max.fixPoint();
|
||||
ret | Point(-INFINITY, 0-getEpsilon(), -INFINITY);
|
||||
ret | Point(INFINITY, 0+getEpsilon(), INFINITY);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -66,12 +66,25 @@ void Shape::setTransform(Matrix transform)
|
||||
this->updateTransform();
|
||||
}
|
||||
|
||||
BoundingBox Shape::getLocalBounds()
|
||||
{
|
||||
return BoundingBox(Point(-1, -1, -1), Point(1,1,1));
|
||||
}
|
||||
|
||||
BoundingBox Shape::getBounds()
|
||||
{
|
||||
BoundingBox ret;
|
||||
BoundingBox me = this->getLocalBounds();
|
||||
|
||||
ret | this->objectToWorld(Point(me.min.x, me.min.y, me.min.z));
|
||||
ret | this->objectToWorld(Point(me.min.x, me.min.y, me.max.z));
|
||||
ret | this->objectToWorld(Point(me.min.x, me.max.y, me.min.z));
|
||||
ret | this->objectToWorld(Point(me.max.x, me.min.y, me.min.z));
|
||||
ret | this->objectToWorld(Point(me.max.x, me.max.y, me.min.z));
|
||||
ret | this->objectToWorld(Point(me.max.x, me.min.y, me.max.z));
|
||||
ret | this->objectToWorld(Point(me.min.x, me.max.y, me.max.z));
|
||||
ret | this->objectToWorld(Point(me.max.x, me.max.y, me.max.z));
|
||||
|
||||
ret.min = this->objectToWorld(Point(-1, -1, -1));
|
||||
ret.max = this->objectToWorld(Point(1, 1, 1));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,16 +59,13 @@ Tuple Triangle::localNormalAt(Tuple point)
|
||||
return this->normal;
|
||||
}
|
||||
|
||||
BoundingBox Triangle::getBounds()
|
||||
BoundingBox Triangle::getLocalBounds()
|
||||
{
|
||||
BoundingBox ret;
|
||||
|
||||
ret | p1;
|
||||
ret | p2;
|
||||
ret | p3;
|
||||
|
||||
ret.min = this->objectToWorld(ret.min);
|
||||
ret.max = this->objectToWorld(ret.max);
|
||||
ret | this->objectToWorld(p1);
|
||||
ret | this->objectToWorld(p2);
|
||||
ret | this->objectToWorld(p3);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user