00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef COLLISIONENTRY_H
00016 #define COLLISIONENTRY_H
00017
00018 #include "pandabase.h"
00019
00020 #include "collisionTraverser.h"
00021 #include "collisionSolid.h"
00022 #include "collisionNode.h"
00023 #include "collisionRecorder.h"
00024
00025 #include "transformState.h"
00026 #include "typedWritableReferenceCount.h"
00027 #include "luse.h"
00028 #include "pointerTo.h"
00029 #include "pandaNode.h"
00030 #include "nodePath.h"
00031 #include "clipPlaneAttrib.h"
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 class EXPCL_PANDA_COLLIDE CollisionEntry : public TypedWritableReferenceCount {
00047 public:
00048 INLINE CollisionEntry();
00049 CollisionEntry(const CollisionEntry ©);
00050 void operator = (const CollisionEntry ©);
00051
00052 PUBLISHED:
00053 INLINE const CollisionSolid *get_from() const;
00054 INLINE bool has_into() const;
00055 INLINE const CollisionSolid *get_into() const;
00056
00057 INLINE CollisionNode *get_from_node() const;
00058 INLINE PandaNode *get_into_node() const;
00059 INLINE NodePath get_from_node_path() const;
00060 INLINE NodePath get_into_node_path() const;
00061
00062 INLINE void set_t(PN_stdfloat t);
00063 INLINE PN_stdfloat get_t() const;
00064 INLINE bool collided() const;
00065 INLINE void reset_collided();
00066
00067 INLINE bool get_respect_prev_transform() const;
00068
00069 INLINE void set_surface_point(const LPoint3 &point);
00070 INLINE void set_surface_normal(const LVector3 &normal);
00071 INLINE void set_interior_point(const LPoint3 &point);
00072
00073 INLINE bool has_surface_point() const;
00074 INLINE bool has_surface_normal() const;
00075 INLINE bool has_interior_point() const;
00076
00077 INLINE void set_contact_pos(const LPoint3 &pos);
00078 INLINE void set_contact_normal(const LVector3 &normal);
00079
00080 INLINE bool has_contact_pos() const;
00081 INLINE bool has_contact_normal() const;
00082
00083 LPoint3 get_surface_point(const NodePath &space) const;
00084 LVector3 get_surface_normal(const NodePath &space) const;
00085 LPoint3 get_interior_point(const NodePath &space) const;
00086 bool get_all(const NodePath &space,
00087 LPoint3 &surface_point,
00088 LVector3 &surface_normal,
00089 LPoint3 &interior_point) const;
00090
00091 LPoint3 get_contact_pos(const NodePath &space) const;
00092 LVector3 get_contact_normal(const NodePath &space) const;
00093 bool get_all_contact_info(const NodePath &space,
00094 LPoint3 &contact_pos,
00095 LVector3 &contact_normal) const;
00096
00097 void output(ostream &out) const;
00098 void write(ostream &out, int indent_level = 0) const;
00099
00100 public:
00101 INLINE CPT(TransformState) get_wrt_space() const;
00102 INLINE CPT(TransformState) get_inv_wrt_space() const;
00103 INLINE CPT(TransformState) get_wrt_prev_space() const;
00104
00105 INLINE const LMatrix4 &get_wrt_mat() const;
00106 INLINE const LMatrix4 &get_inv_wrt_mat() const;
00107 INLINE const LMatrix4 &get_wrt_prev_mat() const;
00108
00109 INLINE const ClipPlaneAttrib *get_into_clip_planes() const;
00110
00111 private:
00112 INLINE void test_intersection(CollisionHandler *record,
00113 const CollisionTraverser *trav) const;
00114 void check_clip_planes();
00115
00116 CPT(CollisionSolid) _from;
00117 CPT(CollisionSolid) _into;
00118
00119 PT(CollisionNode) _from_node;
00120 PT(PandaNode) _into_node;
00121 NodePath _from_node_path;
00122 NodePath _into_node_path;
00123 CPT(ClipPlaneAttrib) _into_clip_planes;
00124 PN_stdfloat _t;
00125
00126 enum Flags {
00127 F_has_surface_point = 0x0001,
00128 F_has_surface_normal = 0x0002,
00129 F_has_interior_point = 0x0004,
00130 F_respect_prev_transform = 0x0008,
00131 F_checked_clip_planes = 0x0010,
00132 F_has_contact_pos = 0x0020,
00133 F_has_contact_normal = 0x0040,
00134 };
00135
00136 int _flags;
00137
00138 LPoint3 _surface_point;
00139 LVector3 _surface_normal;
00140 LPoint3 _interior_point;
00141
00142 LPoint3 _contact_pos;
00143 LVector3 _contact_normal;
00144
00145 public:
00146 static TypeHandle get_class_type() {
00147 return _type_handle;
00148 }
00149 static void init_type() {
00150 TypedWritableReferenceCount::init_type();
00151 register_type(_type_handle, "CollisionEntry",
00152 TypedWritableReferenceCount::get_class_type());
00153 }
00154 virtual TypeHandle get_type() const {
00155 return get_class_type();
00156 }
00157 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00158
00159 private:
00160 static TypeHandle _type_handle;
00161
00162 friend class CollisionTraverser;
00163 friend class CollisionHandlerFluidPusher;
00164 };
00165
00166 INLINE ostream &operator << (ostream &out, const CollisionEntry &entry);
00167
00168 #include "collisionEntry.I"
00169
00170 #endif
00171
00172
00173