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_SIMULATION_SUBSPACE_H 00024 #define SHEEP_SIMULATION_SUBSPACE_H 00025 00026 #include "common/math/de.h" 00027 #include "common/math/real.h" 00028 #include "engine/dynamics/contact.h" 00029 #include "engine/dynamics/contacthandler.h" 00030 #include "engine/dynamics/joints.h" 00031 #include "engine/dynamics/rigidbody.h" 00032 #include "engine/geometry/swiftcollisiondetector.h" 00033 00034 #include <cassert> 00035 #include <list> 00036 00037 namespace sheep { 00038 00039 class RigidObject; 00040 class World; 00041 00042 class Subspace { 00043 public: 00044 inline void Insert(RigidObject *object, bool collide); //!\todo 'collide' is a buggy quick hack! 00045 inline void Remove(RigidObject *object); 00046 00047 inline void Insert(Joint *joint); 00048 inline void Remove(Joint *joint); 00049 00050 inline void Setup(); 00051 00052 inline void AttachTo(World *world); 00053 00054 void Step(Real start_time, Real end_time); 00055 00056 private: 00057 DE1RK4Solver<RigidBody::StateVector> m_solver; 00058 // DE1EulerSolver<RigidBody::StateVector> m_solver; 00059 00060 SWIFTCollisionDetector m_cd; 00061 ContactHandler m_ch; 00062 JointManager m_jm; 00063 00064 typedef std::list<RigidObject *> rigidobject_list; 00065 00066 rigidobject_list m_objects; 00067 00068 World *m_world; 00069 00070 struct state_snapshot { 00071 RigidBody::StateVector *m_states; 00072 }; 00073 00074 void save_state(state_snapshot *s); 00075 void restore_state(const state_snapshot &s); 00076 00077 void find_contacts(); 00078 Real compute_step_end(Real start_time, Real end_time); 00079 void step_bodies(Real time, Real step); 00080 }; 00081 00082 #include "subspace.inl" 00083 00084 } 00085 00086 #endif // !SHEEP_SIMULATION_SUBSPACE_H
1.3.6