15 #include "boundingVolume.h"
16 #include "finiteBoundingVolume.h"
17 #include "unionBoundingVolume.h"
18 #include "intersectionBoundingVolume.h"
19 #include "boundingBox.h"
20 #include "boundingLine.h"
21 #include "boundingPlane.h"
22 #include "boundingSphere.h"
23 #include "boundingHexahedron.h"
24 #include "config_mathutil.h"
44 while (first != last && (*first)->
is_empty()) {
45 if ((*first)->is_infinite()) {
58 for (bvi = first; bvi != last; ++bvi) {
59 if ((*bvi)->is_infinite()) {
69 if (!(*first)->around_other(
this, first, last)) {
83 write(ostream &out,
int indent_level)
const {
84 indent(out, indent_level) << *
this <<
"\n";
179 if (strcmp(str.c_str(),
"default") == 0) {
182 }
else if (strcmp(str.c_str(),
"best") == 0) {
185 }
else if (strcmp(str.c_str(),
"fastest") == 0) {
188 }
else if (strcmp(str.c_str(),
"sphere") == 0) {
191 }
else if (strcmp(str.c_str(),
"box") == 0) {
205 bool BoundingVolume::
207 return extend_by_finite(sphere);
217 bool BoundingVolume::
219 return extend_by_finite(box);
229 bool BoundingVolume::
231 return extend_by_finite(hexahedron);
241 bool BoundingVolume::
243 return extend_by_geometric(line);
253 bool BoundingVolume::
255 return extend_by_geometric(plane);
265 bool BoundingVolume::
267 return extend_by_geometric(unionv);
277 bool BoundingVolume::
279 return extend_by_geometric(intersection);
287 bool BoundingVolume::
289 return extend_by_geometric(volume);
297 bool BoundingVolume::
299 mathutil_cat.warning()
300 << get_type() <<
"::extend_by_geometric() called with " << volume->get_type() <<
"\n";
312 bool BoundingVolume::
314 return around_finite(first, last);
324 bool BoundingVolume::
326 return around_finite(first, last);
336 bool BoundingVolume::
338 return around_finite(first, last);
348 bool BoundingVolume::
350 return around_geometric(first, last);
360 bool BoundingVolume::
362 return around_geometric(first, last);
372 bool BoundingVolume::
374 return around_geometric(first, last);
384 bool BoundingVolume::
386 return around_geometric(first, last);
394 bool BoundingVolume::
396 return around_geometric(first, last);
404 bool BoundingVolume::
406 mathutil_cat.warning()
407 << get_type() <<
"::extend_by_geometric() called with " << first[0]->get_type() <<
"\n";
421 return contains_finite(sphere);
433 return contains_finite(box);
445 return contains_finite(hexahedron);
457 return contains_geometric(line);
469 return contains_geometric(plane);
481 return unionv->other_contains_union(
this);
493 return intersection->other_contains_intersection(
this);
503 return contains_geometric(volume);
513 mathutil_cat.warning()
514 << get_type() <<
"::contains_geometric() called with " << volume->get_type() <<
"\n";
515 return IF_dont_understand;
519 operator << (ostream &out, BoundingVolume::BoundsType type) {
521 case BoundingVolume::BT_default:
522 return out <<
"default";
524 case BoundingVolume::BT_best:
525 return out <<
"best";
527 case BoundingVolume::BT_fastest:
528 return out <<
"fastest";
530 case BoundingVolume::BT_sphere:
531 return out <<
"sphere";
533 case BoundingVolume::BT_box:
538 <<
"Invalid BoundingVolume::BoundsType value: " << (int)type <<
"\n";
539 nassertr(
false, out);
544 operator >> (istream &in, BoundingVolume::BoundsType &type) {
548 if (type == BoundingVolume::BT_default) {
549 mathutil_cat->error()
550 <<
"Invalid BoundingVolume::BoundsType string: " << word <<
"\n";
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
virtual const BoundingSphere * as_bounding_sphere() const
Virtual downcast method.
virtual const BoundingBox * as_bounding_box() const
Virtual downcast method.
virtual const BoundingPlane * as_bounding_plane() const
Virtual downcast method.
This defines a bounding sphere, consisting of a center and a radius.
This funny bounding volume is an infinite plane that divides space into two regions: the part behind ...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
This special bounding volume is the intersection of all of its constituent bounding volumes...
This special bounding volume is the union of all of its constituent bounding volumes.
virtual const GeometricBoundingVolume * as_geometric_bounding_volume() const
Virtual downcast method.
virtual const BoundingHexahedron * as_bounding_hexahedron() const
Virtual downcast method.
static BoundsType string_bounds_type(const string &str)
Returns the BoundsType corresponding to the indicated string.
A special kind of GeometricBoundingVolume that is known to be finite.
bool around(const BoundingVolume **first, const BoundingVolume **last)
Resets the volume to enclose only the volumes indicated.
virtual const BoundingLine * as_bounding_line() const
Virtual downcast method.
bool is_empty() const
Any kind of volume might be empty.
TypeHandle is the identifier used to differentiate C++ class types.
virtual const FiniteBoundingVolume * as_finite_bounding_volume() const
Virtual downcast method.
This defines a bounding convex hexahedron.
This funny bounding volume is an infinite line with no thickness and extending to infinity in both di...