Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

swiftcollisiondetector.h

Go to the documentation of this file.
00001 /*
00002     Sheep - A Rigid Body Dynamics Engine
00003     Copyright (C) 2001-2004 Francois Beaune
00004     Contact: http://toxicengine.sourceforge.net/
00005 
00006     This file is part of Sheep.
00007 
00008     Sheep is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     Sheep is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with Sheep; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef SHEEP_GEOMETRY_SWIFTCOLLISIONDETECTOR_H
00024 #define SHEEP_GEOMETRY_SWIFTCOLLISIONDETECTOR_H
00025 
00026 #include "engine/dynamics/contact.h"
00027 #include "icollisiondetector.h"
00028 
00029 #include "SWIFT.h"
00030 
00031 #include <map>
00032 
00033 namespace sheep {
00034 
00035     class RigidObject;
00036     class RigidModel;
00037 
00038     class SWIFTCollisionDetector : public ICollisionDetector {
00039     public:
00040         SWIFTCollisionDetector();
00041         virtual ~SWIFTCollisionDetector();
00042 
00043         virtual void Insert(RigidObject *object);
00044         virtual void Remove(RigidObject *object);
00045 
00046         //! This method must be called (before proceeding to any query)
00047         //! every time bodies transformation have changed or every time
00048         //! bodies have been inserted to or removed from the system.
00049         virtual void RefreshTransformations();
00050 
00051         virtual bool AreObjectsDisjoint() const;
00052         virtual bool AreObjectHullsDisjoint() const;
00053 
00054         virtual void FindContacts(ContactList *contacts);
00055 
00056     private:
00057         SWIFT_Scene *m_scene;
00058 
00059         //!\todo Consider using a hash_map container for faster lookup.
00060         typedef std::map<int, RigidObject *> id_to_object_map;
00061         typedef std::map<RigidObject *, int> object_to_id_map;
00062         typedef std::map<RigidModel *, int> model_to_id_map;
00063 
00064         id_to_object_map m_id_to_object;
00065         object_to_id_map m_object_to_id;
00066         model_to_id_map m_model_to_id;
00067 
00068         bool m_are_disjoint;    //!< Are objects disjoints?
00069         int m_num_pairs;
00070         int *m_oids;            //!< Colliding pairs.
00071         int *m_pids;
00072         int *m_feature_types;
00073         int *m_feature_ids;
00074         SWIFT_Real *m_distances;
00075     };
00076 
00077 #include "swiftcollisiondetector.inl"
00078 
00079 }
00080 
00081 #endif  // !SHEEP_GEOMETRY_SWIFTCOLLISIONDETECTOR_H

Generated on Tue May 11 01:31:52 2004 for toxic by doxygen 1.3.6