OPC_PlanesCollider.h
Go to the documentation of this file.
00001 
00002 /*
00003  *      OPCODE - Optimized Collision Detection
00004  *      Copyright (C) 2001 Pierre Terdiman
00005  *      Homepage: http://www.codercorner.com/Opcode.htm
00006  */
00008 
00010 
00016 
00017 
00019 // Include Guard
00020 #ifndef __OPC_PLANESCOLLIDER_H__
00021 #define __OPC_PLANESCOLLIDER_H__
00022 
00023         struct OPCODE_API PlanesCache : VolumeCache
00024         {
00025                                         PlanesCache()
00026                                         {
00027                                         }
00028         };
00029 
00030         class OPCODE_API PlanesCollider : public VolumeCollider
00031         {
00032                 public:
00033                 // Constructor / Destructor
00034                                                                                         PlanesCollider();
00035                 virtual                                                         ~PlanesCollider();
00036 
00037                 inline void setCollisionPairInserter(hrp::CollisionPairInserterBase* collisionPairInserter) {
00038                     this->collisionPairInserter = collisionPairInserter;
00039                 }
00041 
00055 
00056                                                         bool                    Collide(PlanesCache& cache, const Plane* planes, udword nb_planes, const Model& model, const Matrix4x4* worldm=null);
00057 
00058                 // Mutant box-with-planes collision queries
00059                 inline_                         bool                    Collide(PlanesCache& cache, const OBB& box, const Model& model, const Matrix4x4* worldb=null, const Matrix4x4* worldm=null)
00060                                                                                         {
00061                                                                                                 Plane PL[6];
00062 
00063                                                                                                 if(worldb)
00064                                                                                                 {
00065                                                                                                         // Create a new OBB in world space
00066                                                                                                         OBB WorldBox;
00067                                                                                                         box.Rotate(*worldb, WorldBox);
00068                                                                                                         // Compute planes from the sides of the box
00069                                                                                                         WorldBox.ComputePlanes(PL);
00070                                                                                                 }
00071                                                                                                 else
00072                                                                                                 {
00073                                                                                                         // Compute planes from the sides of the box
00074                                                                                                         box.ComputePlanes(PL);
00075                                                                                                 }
00076 
00077                                                                                                 // Collide with box planes
00078                                                                                                 return Collide(cache, PL, 6, model, worldm);
00079                                                                                         }
00080                 // Settings
00081 
00083 
00087 
00088                 override(Collider)      const char*             ValidateSettings();
00089 
00090                 protected:
00091                                                         hrp::CollisionPairInserterBase* collisionPairInserter;
00092                 // Planes in model space
00093                                                         udword                  mNbPlanes;
00094                                                         Plane*                  mPlanes;
00095                 // Leaf description
00096                                                         VertexPointers  mVP;
00097                 // Internal methods
00098                                                         void                    _Collide(const AABBCollisionNode* node, udword clip_mask);
00099                                                         void                    _Collide(const AABBNoLeafNode* node, udword clip_mask);
00100                                                         void                    _Collide(const AABBQuantizedNode* node, udword clip_mask);
00101                                                         void                    _Collide(const AABBQuantizedNoLeafNode* node, udword clip_mask);
00102                                                         void                    _CollideNoPrimitiveTest(const AABBCollisionNode* node, udword clip_mask);
00103                                                         void                    _CollideNoPrimitiveTest(const AABBNoLeafNode* node, udword clip_mask);
00104                                                         void                    _CollideNoPrimitiveTest(const AABBQuantizedNode* node, udword clip_mask);
00105                                                         void                    _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node, udword clip_mask);
00106                         // Overlap tests
00107                 inline_                         BOOL                    PlanesAABBOverlap(const Point& center, const Point& extents, udword& out_clip_mask, udword in_clip_mask);
00108                 inline_                         BOOL                    PlanesTriOverlap(udword in_clip_mask);
00109                         // Init methods
00110                                                         BOOL                    InitQuery(PlanesCache& cache, const Plane* planes, udword nb_planes, const Matrix4x4* worldm=null);
00111         };
00112 
00113         class OPCODE_API HybridPlanesCollider : public PlanesCollider
00114         {
00115                 public:
00116                 // Constructor / Destructor
00117                                                                                         HybridPlanesCollider();
00118                 virtual                                                         ~HybridPlanesCollider();
00119 
00120                                                         bool                    Collide(PlanesCache& cache, const Plane* planes, udword nb_planes, const HybridModel& model, const Matrix4x4* worldm=null);
00121                 protected:
00122                                                         Container               mTouchedBoxes;
00123         };
00124 
00125 #endif // __OPC_PLANESCOLLIDER_H__


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:55