00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef COLLISIONENTRY_H
00020 #define COLLISIONENTRY_H
00021
00022 #include "pandabase.h"
00023
00024 #include "collisionTraverser.h"
00025 #include "collisionSolid.h"
00026 #include "collisionNode.h"
00027 #include "collisionRecorder.h"
00028
00029 #include "typedReferenceCount.h"
00030 #include "luse.h"
00031 #include "pointerTo.h"
00032 #include "pandaNode.h"
00033 #include "nodePath.h"
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 class EXPCL_PANDA CollisionEntry : public TypedReferenceCount {
00049 public:
00050 INLINE CollisionEntry();
00051 CollisionEntry(const CollisionEntry ©);
00052 void operator = (const CollisionEntry ©);
00053
00054 PUBLISHED:
00055 INLINE const CollisionSolid *get_from() const;
00056 INLINE bool has_into() const;
00057 INLINE const CollisionSolid *get_into() const;
00058
00059 INLINE CollisionNode *get_from_node() const;
00060 INLINE PandaNode *get_into_node() const;
00061 INLINE const NodePath &get_into_node_path() const;
00062
00063 INLINE const LMatrix4f &get_from_space() const;
00064 INLINE const LMatrix4f &get_into_space() const;
00065 INLINE const LMatrix4f &get_wrt_space() const;
00066 INLINE const LMatrix4f &get_inv_wrt_space() const;
00067
00068 INLINE void set_from_velocity(const LVector3f &vel);
00069 INLINE bool has_from_velocity() const;
00070 INLINE const LVector3f &get_from_velocity() const;
00071
00072 INLINE void set_into_intersection_point(const LPoint3f &point);
00073 INLINE bool has_into_intersection_point() const;
00074 INLINE const LPoint3f &get_into_intersection_point() const;
00075
00076 INLINE bool has_from_intersection_point() const;
00077 INLINE LPoint3f get_from_intersection_point() const;
00078
00079 INLINE void set_into_surface_normal(const LVector3f &normal);
00080 INLINE bool has_into_surface_normal() const;
00081 INLINE const LVector3f &get_into_surface_normal() const;
00082
00083 INLINE void set_from_surface_normal(const LVector3f &normal);
00084 INLINE bool has_from_surface_normal() const;
00085 INLINE const LVector3f &get_from_surface_normal() const;
00086
00087 INLINE void set_into_depth(float depth);
00088 INLINE bool has_into_depth() const;
00089 INLINE float get_into_depth() const;
00090
00091 INLINE void set_from_depth(float depth);
00092 INLINE bool has_from_depth() const;
00093 INLINE float get_from_depth() const;
00094
00095 private:
00096 INLINE void test_intersection(CollisionHandler *record,
00097 const CollisionTraverser *trav) const;
00098 void compute_from_surface_normal();
00099
00100 CPT(CollisionSolid) _from;
00101 CPT(CollisionSolid) _into;
00102
00103 PT(CollisionNode) _from_node;
00104 PT(PandaNode) _into_node;
00105 NodePath _into_node_path;
00106 LMatrix4f _from_space;
00107 LMatrix4f _into_space;
00108 LMatrix4f _wrt_space;
00109 LMatrix4f _inv_wrt_space;
00110
00111 enum Flags {
00112 F_has_into_intersection_point = 0x0001,
00113 F_has_into_surface_normal = 0x0002,
00114 F_has_from_surface_normal = 0x0004,
00115 F_has_into_depth = 0x0008,
00116 F_has_from_depth = 0x0010,
00117 F_has_from_velocity = 0x0020,
00118 };
00119
00120 int _flags;
00121
00122 LVector3f _from_velocity;
00123 LPoint3f _into_intersection_point;
00124 LVector3f _into_surface_normal;
00125 LVector3f _from_surface_normal;
00126 float _into_depth;
00127 float _from_depth;
00128
00129 public:
00130 static TypeHandle get_class_type() {
00131 return _type_handle;
00132 }
00133 static void init_type() {
00134 TypedReferenceCount::init_type();
00135 register_type(_type_handle, "CollisionEntry",
00136 TypedReferenceCount::get_class_type());
00137 }
00138 virtual TypeHandle get_type() const {
00139 return get_class_type();
00140 }
00141 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00142
00143 private:
00144 static TypeHandle _type_handle;
00145
00146 friend class CollisionTraverser;
00147 };
00148
00149 #include "collisionEntry.I"
00150
00151 #endif
00152
00153
00154