Panda3D
 All Classes Functions Variables Enumerations
physicsManager.I
00001 // Filename: physicsManager.I
00002 // Created by:  charles (14Jun00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 ////////////////////////////////////////////////////////////////////
00016 //    Function : attach_physical
00017 //      Access : Public
00018 // Description : Registers a Physical class with the manager
00019 ////////////////////////////////////////////////////////////////////
00020 INLINE void PhysicsManager::
00021 attach_physical(Physical *p) {
00022   nassertv(p && p->_physics_manager == NULL);
00023   p->_physics_manager = this;
00024   PhysicalsVector::iterator found;
00025   found = find(_physicals.begin(), _physicals.end(), p);
00026   if (found == _physicals.end()) {
00027     _physicals.push_back(p);
00028   }
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //    Function : attach_linear_force
00033 //      Access : Public
00034 // Description : Adds a global linear force to the physics manager
00035 ////////////////////////////////////////////////////////////////////
00036 INLINE void PhysicsManager::
00037 add_linear_force(LinearForce *f) {
00038   nassertv(f);
00039   LinearForceVector::iterator found;
00040   PT(LinearForce) ptlf = f;
00041   found = find(_linear_forces.begin(), _linear_forces.end(), ptlf);
00042   if (found == _linear_forces.end()) {
00043     _linear_forces.push_back(f);
00044   }
00045 }
00046 
00047 ////////////////////////////////////////////////////////////////////
00048 //    Function : attach_physicalnode
00049 //      Access : Public
00050 // Description : Please call attach_physical_node instead.
00051 ////////////////////////////////////////////////////////////////////
00052 INLINE void PhysicsManager::
00053 attach_physicalnode(PhysicalNode *p) {
00054   cerr<<"attach_physicalnode (aka attachPhysicalnode) has been"
00055     <<"replaced with attach_physical_node (aka attachPhysicalNode)."
00056     <<"  Please change the spelling of the function in your code."
00057     <<endl;
00058   attach_physical_node(p);
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //    Function : attach_physical_node
00063 //      Access : Public
00064 // Description : Registers a physicalnode with the manager
00065 ////////////////////////////////////////////////////////////////////
00066 INLINE void PhysicsManager::
00067 attach_physical_node(PhysicalNode *p) {
00068   nassertv(p);
00069   for (int i = 0; i < p->get_num_physicals(); ++i) {
00070     attach_physical(p->get_physical(i));
00071   }
00072 }
00073 
00074 ////////////////////////////////////////////////////////////////////
00075 //    Function : clear_linear_forces
00076 //      Access : Public
00077 // Description : Resets the physics manager force vector
00078 ////////////////////////////////////////////////////////////////////
00079 INLINE void PhysicsManager::
00080 clear_linear_forces() {
00081   _linear_forces.erase(_linear_forces.begin(), _linear_forces.end());
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //    Function : attach_angular_force
00086 //      Access : Public
00087 // Description : Adds a global angular force to the physics manager
00088 ////////////////////////////////////////////////////////////////////
00089 INLINE void PhysicsManager::
00090 add_angular_force(AngularForce *f) {
00091   nassertv(f);
00092   AngularForceVector::iterator found;
00093   PT(AngularForce) ptaf = f;
00094   found = find(_angular_forces.begin(), _angular_forces.end(), ptaf);
00095   if (found == _angular_forces.end())
00096     _angular_forces.push_back(f);
00097 }
00098 
00099 ////////////////////////////////////////////////////////////////////
00100 //    Function : clear_angular_forces
00101 //      Access : Public
00102 // Description : Resets the physics manager force vector
00103 ////////////////////////////////////////////////////////////////////
00104 INLINE void PhysicsManager::
00105 clear_angular_forces() {
00106   _angular_forces.erase(_angular_forces.begin(), _angular_forces.end());
00107 }
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //    Function : clear_physicals
00111 //      Access : Public
00112 // Description : Resets the physics manager objects vector
00113 ////////////////////////////////////////////////////////////////////
00114 INLINE void PhysicsManager::
00115 clear_physicals() {
00116   _physicals.erase(_physicals.begin(), _physicals.end());
00117 }
00118 
00119 ////////////////////////////////////////////////////////////////////
00120 //    Function : set_viscosity
00121 //      Access : Public
00122 // Description : Set the global viscosity.
00123 ////////////////////////////////////////////////////////////////////
00124 INLINE void PhysicsManager::
00125 set_viscosity(PN_stdfloat viscosity) {
00126   _viscosity=viscosity;
00127 }
00128 
00129 ////////////////////////////////////////////////////////////////////
00130 //    Function : get_viscosity
00131 //      Access : Public
00132 // Description : Get the global viscosity.
00133 ////////////////////////////////////////////////////////////////////
00134 INLINE PN_stdfloat PhysicsManager::
00135 get_viscosity() const {
00136   return _viscosity;
00137 }
00138 
00139 ////////////////////////////////////////////////////////////////////
00140 //    Function : attach_linear_integrator
00141 //      Access : Public
00142 // Description : Hooks a linear integrator into the manager
00143 ////////////////////////////////////////////////////////////////////
00144 INLINE void PhysicsManager::
00145 attach_linear_integrator(LinearIntegrator *i) {
00146   nassertv(i);
00147   _linear_integrator = i;
00148 }
00149 
00150 ////////////////////////////////////////////////////////////////////
00151 //    Function : attach_angular_integrator
00152 //      Access : Public
00153 // Description : Hooks an angular integrator into the manager
00154 ////////////////////////////////////////////////////////////////////
00155 INLINE void PhysicsManager::
00156 attach_angular_integrator(AngularIntegrator *i) {
00157   nassertv(i);
00158   _angular_integrator = i;
00159 }
 All Classes Functions Variables Enumerations