00001 // Filename: intersectionBoundingVolume.h 00002 // Created by: drose (08Feb12) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef INTERSECTIONBOUNDINGVOLUME_H 00016 #define INTERSECTIONBOUNDINGVOLUME_H 00017 00018 #include "pandabase.h" 00019 00020 #include "geometricBoundingVolume.h" 00021 #include "pvector.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : IntersectionBoundingVolume 00025 // Description : This special bounding volume is the intersection of all of 00026 // its constituent bounding volumes. 00027 // 00028 // A point is defined to be within an 00029 // IntersectionBoundingVolume if it is within all of its 00030 // component bounding volumes. 00031 //////////////////////////////////////////////////////////////////// 00032 class EXPCL_PANDA_MATHUTIL IntersectionBoundingVolume : public GeometricBoundingVolume { 00033 PUBLISHED: 00034 INLINE_MATHUTIL IntersectionBoundingVolume(); 00035 ALLOC_DELETED_CHAIN(IntersectionBoundingVolume); 00036 00037 public: 00038 IntersectionBoundingVolume(const IntersectionBoundingVolume ©); 00039 00040 public: 00041 virtual BoundingVolume *make_copy() const; 00042 00043 virtual LPoint3 get_approx_center() const; 00044 virtual void xform(const LMatrix4 &mat); 00045 00046 virtual void output(ostream &out) const; 00047 virtual void write(ostream &out, int indent_level) const; 00048 00049 PUBLISHED: 00050 INLINE_MATHUTIL int get_num_components() const; 00051 INLINE_MATHUTIL const GeometricBoundingVolume *get_component(int n) const; 00052 MAKE_SEQ(get_components, get_num_components, get_component); 00053 00054 void clear_components(); 00055 void add_component(const GeometricBoundingVolume *component); 00056 00057 protected: 00058 virtual bool extend_other(BoundingVolume *other) const; 00059 virtual bool around_other(BoundingVolume *other, 00060 const BoundingVolume **first, 00061 const BoundingVolume **last) const; 00062 virtual int contains_other(const BoundingVolume *other) const; 00063 00064 virtual int contains_point(const LPoint3 &point) const; 00065 virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const; 00066 virtual int contains_sphere(const BoundingSphere *sphere) const; 00067 virtual int contains_box(const BoundingBox *box) const; 00068 virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const; 00069 virtual int contains_line(const BoundingLine *line) const; 00070 virtual int contains_plane(const BoundingPlane *plane) const; 00071 virtual int contains_union(const UnionBoundingVolume *unionv) const; 00072 virtual int contains_intersection(const IntersectionBoundingVolume *intersection) const; 00073 virtual int contains_finite(const FiniteBoundingVolume *volume) const; 00074 virtual int contains_geometric(const GeometricBoundingVolume *volume) const; 00075 int other_contains_intersection(const BoundingVolume *other) const; 00076 00077 private: 00078 typedef pvector<CPT(GeometricBoundingVolume) > Components; 00079 Components _components; 00080 00081 public: 00082 static TypeHandle get_class_type() { 00083 return _type_handle; 00084 } 00085 static void init_type() { 00086 GeometricBoundingVolume::init_type(); 00087 register_type(_type_handle, "IntersectionBoundingVolume", 00088 GeometricBoundingVolume::get_class_type()); 00089 } 00090 virtual TypeHandle get_type() const { 00091 return get_class_type(); 00092 } 00093 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00094 00095 private: 00096 static TypeHandle _type_handle; 00097 00098 friend class BoundingVolume; 00099 }; 00100 00101 #include "intersectionBoundingVolume.I" 00102 00103 #endif 00104