00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef BOUNDINGVOLUME_H
00020 #define BOUNDINGVOLUME_H
00021
00022 #include "pandabase.h"
00023
00024 #include "typedObject.h"
00025 #include "typedReferenceCount.h"
00026
00027 class BoundingSphere;
00028 class BoundingHexahedron;
00029 class BoundingLine;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 class EXPCL_PANDA BoundingVolume : public TypedReferenceCount {
00043 PUBLISHED:
00044 INLINE_MATHUTIL BoundingVolume();
00045 virtual BoundingVolume *make_copy() const=0;
00046
00047 INLINE_MATHUTIL bool is_empty() const;
00048 INLINE_MATHUTIL bool is_infinite() const;
00049
00050 INLINE_MATHUTIL void set_infinite();
00051
00052 INLINE_MATHUTIL bool extend_by(const BoundingVolume *vol);
00053
00054
00055
00056
00057 bool around(const BoundingVolume **first,
00058 const BoundingVolume **last);
00059
00060
00061
00062 enum IntersectionFlags {
00063
00064 IF_no_intersection = 0,
00065
00066
00067 IF_possible = 0x01,
00068
00069
00070
00071 IF_some = 0x02,
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 IF_all = 0x04,
00086
00087
00088
00089 IF_dont_understand = 0x08
00090 };
00091
00092 INLINE_MATHUTIL int contains(const BoundingVolume *vol) const;
00093
00094 virtual void output(ostream &out) const=0;
00095 virtual void write(ostream &out, int indent_level = 0) const;
00096
00097 protected:
00098 enum Flags {
00099 F_empty = 0x01,
00100 F_infinite = 0x02
00101 };
00102 int _flags;
00103
00104 protected:
00105
00106
00107
00108
00109
00110 virtual bool extend_other(BoundingVolume *other) const=0;
00111 virtual bool around_other(BoundingVolume *other,
00112 const BoundingVolume **first,
00113 const BoundingVolume **last) const=0;
00114 virtual int contains_other(const BoundingVolume *other) const=0;
00115
00116
00117
00118 virtual bool extend_by_sphere(const BoundingSphere *sphere);
00119 virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron);
00120 virtual bool extend_by_line(const BoundingLine *line);
00121
00122 virtual bool around_spheres(const BoundingVolume **first,
00123 const BoundingVolume **last);
00124 virtual bool around_hexahedrons(const BoundingVolume **first,
00125 const BoundingVolume **last);
00126 virtual bool around_lines(const BoundingVolume **first,
00127 const BoundingVolume **last);
00128
00129 virtual int contains_sphere(const BoundingSphere *sphere) const;
00130 virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const;
00131 virtual int contains_line(const BoundingLine *line) const;
00132
00133
00134 public:
00135 static TypeHandle get_class_type() {
00136 return _type_handle;
00137 }
00138 static void init_type() {
00139 TypedReferenceCount::init_type();
00140 register_type(_type_handle, "BoundingVolume",
00141 TypedReferenceCount::get_class_type());
00142 }
00143 virtual TypeHandle get_type() const {
00144 return get_class_type();
00145 }
00146 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00147
00148 private:
00149 static TypeHandle _type_handle;
00150
00151 friend class BoundingSphere;
00152 friend class BoundingHexahedron;
00153 friend class BoundingLine;
00154 };
00155
00156 INLINE_MATHUTIL ostream &operator << (ostream &out, const BoundingVolume &bound);
00157
00158 #include "boundingVolume.I"
00159
00160 #endif