1 /******************************************************************************* 2 * Copyright 2011 See AUTHORS file. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17 #ifdef _MSC_VER 18 #pragma once 19 #endif 20 21 #ifndef ContactCache_H 22 #define ContactCache_H 23 24 #include "ContactListener.h" 25 #include "../../../bullet/LinearMath/btAlignedObjectArray.h" 26 27 #ifndef SWIG 28 struct ContactPair; 29 #endif //SWIG 30 31 /** @author Xoppa */ 32 class ContactCache { 33 protected: 34 #ifndef SWIG 35 bool filter; 36 int events; 37 btAlignedObjectArray<ContactPair> cache; 38 //std::map<ContactPair, float> cache; 39 #endif 40 public: 41 float cacheTime; 42 43 ContactCache(bool dummy); 44 virtual ~ContactCache(); 45 46 #ifndef SWIG 47 void setEvents(const int &events); 48 #endif //SWIG 49 50 void enable(); 51 void disable(); 52 bool isEnabled(); 53 54 //virtual void onContactStarted(btPersistentManifold* manifold) = 0; 55 //virtual void onContactStarted(const btCollisionObject* colObj0, const btCollisionObject* colObj1) = 0; 56 //virtual void onContactStarted(const int &userValue0, const int &userValue1) = 0; 57 58 virtual void onContactStarted(btPersistentManifold* manifold, const bool &match0, const bool &match1) = 0; 59 //virtual void onContactStarted(const btCollisionObject* colObj0, const bool &match0, const btCollisionObject* colObj1, const bool &match1) = 0; 60 //virtual void onContactStarted(const int &userValue0, const bool &match0, const int &userValue1, const bool &match1) = 0; 61 62 //virtual void onContactEnded(btPersistentManifold* manifold) = 0; 63 //virtual void onContactEnded(const btCollisionObject* colObj0, const btCollisionObject* colObj1) = 0; 64 //virtual void onContactEnded(const int &userValue0, const int &userValue1) = 0; 65 66 //virtual void onContactEnded(btPersistentManifold* manifold, const bool &match0, const bool &match1) = 0; 67 virtual void onContactEnded(const btCollisionObject* colObj0, const bool &match0, const btCollisionObject* colObj1, const bool &match1) = 0; 68 //virtual void onContactEnded(const int &userValue0, const bool &match0, const int &userValue1, const bool &match1) = 0; 69 70 void clear(); 71 72 void update(float delta); 73 74 #ifndef SWIG 75 int indexOf(const btCollisionObject* const &obj0, const btCollisionObject* const &obj1); 76 77 void contactStarted(btPersistentManifold* manifold); 78 79 void contactEnded(btPersistentManifold* manifold); 80 #endif //SWIG 81 }; 82 83 #endif //ContactCache_H 84