00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 #ifndef _PHYSICS_COLLISIONSTATE_
00026 #define _PHYSICS_COLLISIONSTATE_
00027 
00028 #include <physics/physics>
00029 #include <physics/Collidable>
00030 #include <base/ReferencedObject>
00031 #include <base/Point3>
00032 #include <vector>
00033 
00034 
00035 namespace physics {
00036 
00037 class Solid;
00038 
00039 class CollisionState : public base::ReferencedObject
00040 {
00041 public:
00042   CollisionState(ref<const Collidable> collidable1, ref<const Collidable> collidable2)
00043     : collidable1(collidable1), collidable2(collidable2) {}
00044   CollisionState(const CollisionState& cs)
00045     : collidable1(cs.collidable1), collidable2(cs.collidable2), contacts(cs.contacts) {}
00046   virtual ~CollisionState() {}
00047 
00048   virtual String className() const { return String("CollisionState"); }
00049   virtual base::Object& clone() const { return *NewNamedObj(className()) CollisionState(*this); }
00050 
00051   
00052   ref<const Collidable> collidable1;
00053   ref<const Collidable> collidable2;
00054 
00055   class Contact {
00056   public:
00057     Contact(const Point3& p1, const Point3& p2, const Vector3& n1, Real depth=0)
00058       : p1(p1), p2(p2), n1(n1), depth(depth) {}
00059     Point3  p1,p2;  
00060     Vector3 n1;     
00061     Real depth;     
00062   };
00063 
00064 
00065   
00066   
00067   
00068   typedef std::vector<Contact> Contacts;
00069   Contacts contacts;
00070 };
00071 
00072 
00073 } 
00074 
00075 #endif