19 TypeHandle IntersectionBoundingVolume::_type_handle;
27 _components(copy._components)
42 LPoint3 IntersectionBoundingVolume::
43 get_approx_center()
const {
44 nassertr(!
is_empty(), LPoint3::zero());
47 LPoint3 center = LPoint3::zero();
48 for (Components::const_iterator ci = _components.begin();
49 ci != _components.end();
51 center += (*ci)->get_approx_center();
54 return center / (PN_stdfloat)_components.size();
60 void IntersectionBoundingVolume::
61 xform(
const LMatrix4 &mat) {
62 nassertv(!mat.is_nan());
64 for (Components::iterator ci = _components.begin();
65 ci != _components.end();
76 void IntersectionBoundingVolume::
77 output(std::ostream &out)
const {
79 out <<
"intersection, empty";
81 out <<
"intersection, infinite";
83 out <<
"intersection [";
84 for (Components::const_iterator ci = _components.begin();
85 ci != _components.end();
96 void IntersectionBoundingVolume::
97 write(std::ostream &out,
int indent_level)
const {
99 indent(out, indent_level) <<
"intersection, empty\n";
101 indent(out, indent_level) <<
"intersection, infinite\n";
103 indent(out, indent_level) <<
"intersection {\n";
104 for (Components::const_iterator ci = _components.begin();
105 ci != _components.end();
107 (*ci)->write(out, indent_level + 2);
109 indent(out, indent_level) <<
"}\n";
133 if (component->
is_exact_type(UnionBoundingVolume::get_class_type())) {
139 unionv->filter_intersection(
this);
144 if (unionv->get_num_components() == 1) {
146 gbv = unionv->get_component(0);
159 }
else if (component->
is_exact_type(IntersectionBoundingVolume::get_class_type())) {
162 for (Components::const_iterator ci = other->_components.begin();
163 ci != other->_components.end();
171 while (i < _components.size()) {
175 int result = component->
contains(existing);
176 if ((result & IF_all) != 0) {
181 }
else if (result == 0) {
188 result = existing->
contains(component);
189 if ((result & IF_all) != 0) {
193 _components.erase(_components.begin() + i);
195 }
else if (result == 0) {
203 _flags &= ~F_infinite;
204 _components.push_back(component);
211 bool IntersectionBoundingVolume::
213 return other->extend_by_intersection(
this);
219 bool IntersectionBoundingVolume::
223 return other->around_intersections(first, last);
229 int IntersectionBoundingVolume::
231 return other->contains_intersection(
this);
237 int IntersectionBoundingVolume::
238 contains_point(
const LPoint3 &point)
const {
239 nassertr(!point.is_nan(), IF_no_intersection);
241 int result = IF_possible | IF_some | IF_all;
242 for (Components::const_iterator ci = _components.begin();
243 ci != _components.end();
245 int this_result = (*ci)->contains(point);
246 if ((this_result & IF_dont_understand) != 0) {
247 result |= IF_dont_understand;
250 result &= this_result;
251 if ((result & IF_possible) == 0) {
263 int IntersectionBoundingVolume::
264 contains_lineseg(
const LPoint3 &a,
const LPoint3 &b)
const {
265 nassertr(!a.is_nan() && !b.is_nan(), IF_no_intersection);
267 int result = IF_possible | IF_some | IF_all;
268 for (Components::const_iterator ci = _components.begin();
269 ci != _components.end();
271 int this_result = (*ci)->contains(a, b);
272 if ((this_result & IF_dont_understand) != 0) {
273 result |= IF_dont_understand;
276 result &= this_result;
277 if ((result & IF_possible) == 0) {
290 int IntersectionBoundingVolume::
292 int result = IF_possible | IF_some | IF_all;
293 for (Components::const_iterator ci = _components.begin();
294 ci != _components.end();
296 int this_result = (*ci)->contains_sphere(sphere);
297 if ((this_result & IF_dont_understand) != 0) {
298 result |= IF_dont_understand;
301 result &= this_result;
302 if ((result & IF_possible) == 0) {
315 int IntersectionBoundingVolume::
317 int result = IF_possible | IF_some | IF_all;
318 for (Components::const_iterator ci = _components.begin();
319 ci != _components.end();
321 int this_result = (*ci)->contains_box(box);
322 if ((this_result & IF_dont_understand) != 0) {
323 result |= IF_dont_understand;
326 result &= this_result;
327 if ((result & IF_possible) == 0) {
340 int IntersectionBoundingVolume::
342 int result = IF_possible | IF_some | IF_all;
343 for (Components::const_iterator ci = _components.begin();
344 ci != _components.end();
346 int this_result = (*ci)->contains_hexahedron(hexahedron);
347 if ((this_result & IF_dont_understand) != 0) {
348 result |= IF_dont_understand;
351 result &= this_result;
352 if ((result & IF_possible) == 0) {
365 int IntersectionBoundingVolume::
367 int result = IF_possible | IF_some | IF_all;
368 for (Components::const_iterator ci = _components.begin();
369 ci != _components.end();
371 int this_result = (*ci)->contains_line(line);
372 if ((this_result & IF_dont_understand) != 0) {
373 result |= IF_dont_understand;
376 result &= this_result;
377 if ((result & IF_possible) == 0) {
390 int IntersectionBoundingVolume::
392 int result = IF_possible | IF_some | IF_all;
393 for (Components::const_iterator ci = _components.begin();
394 ci != _components.end();
396 int this_result = (*ci)->contains_plane(plane);
397 if ((this_result & IF_dont_understand) != 0) {
398 result |= IF_dont_understand;
401 result &= this_result;
402 if ((result & IF_possible) == 0) {
415 int IntersectionBoundingVolume::
417 int result = IF_possible | IF_some | IF_all;
418 for (Components::const_iterator ci = _components.begin();
419 ci != _components.end();
421 int this_result = (*ci)->contains_union(unionv);
422 if ((this_result & IF_dont_understand) != 0) {
423 result |= IF_dont_understand;
426 result &= this_result;
427 if ((result & IF_possible) == 0) {
440 int IntersectionBoundingVolume::
442 int result = IF_possible | IF_some | IF_all;
443 for (Components::const_iterator ci = _components.begin();
444 ci != _components.end();
446 int this_result = (*ci)->contains_intersection(intersection);
447 if ((this_result & IF_dont_understand) != 0) {
448 result |= IF_dont_understand;
451 result &= this_result;
452 if ((result & IF_possible) == 0) {
464 int IntersectionBoundingVolume::
466 int result = IF_possible | IF_some | IF_all;
467 for (Components::const_iterator ci = _components.begin();
468 ci != _components.end();
470 int this_result = (*ci)->contains_finite(volume);
471 if ((this_result & IF_dont_understand) != 0) {
472 result |= IF_dont_understand;
475 result &= this_result;
476 if ((result & IF_possible) == 0) {
488 int IntersectionBoundingVolume::
490 int result = IF_possible | IF_some | IF_all;
491 for (Components::const_iterator ci = _components.begin();
492 ci != _components.end();
494 int this_result = (*ci)->contains_geometric(volume);
495 if ((this_result & IF_dont_understand) != 0) {
496 result |= IF_dont_understand;
499 result &= this_result;
500 if ((result & IF_possible) == 0) {
515 int IntersectionBoundingVolume::
517 int result = IF_possible | IF_some | IF_all;
518 for (Components::const_iterator ci = _components.begin();
519 ci != _components.end();
521 int this_result = volume->
contains(*ci);
522 if ((this_result & IF_dont_understand) != 0) {
523 result |= IF_dont_understand;
526 result &= this_result;
527 if ((result & IF_possible) == 0) {
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
bool is_exact_type(TypeHandle handle) const
Returns true if the current object is the indicated type exactly.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int contains(const BoundingVolume *vol) const
Returns the appropriate set of IntersectionFlags to indicate the amount of intersection with the indi...
int contains(const GeometricBoundingVolume *vol) const
Returns the appropriate set of IntersectionFlags to indicate the amount of intersection with the indi...
bool is_empty() const
Any kind of volume might be empty.
This defines a bounding sphere, consisting of a center and a radius.
bool is_infinite() const
The other side of the empty coin is an infinite volume.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
void clear_components()
Removes all components from the volume.
A special kind of GeometricBoundingVolume that is known to be finite.
TypeHandle is the identifier used to differentiate C++ class types.
This defines a bounding convex hexahedron.
void add_component(const GeometricBoundingVolume *component)
Adds a new component to the volume.
This funny bounding volume is an infinite line with no thickness and extending to infinity in both di...
IntersectionBoundingVolume()
Constructs an empty intersection.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.