Changeset 4121 in orxonox.OLD for orxonox/branches/physics/src/util/physics/i_physics.cc
- Timestamp:
- May 9, 2005, 3:01:57 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/util/physics/i_physics.cc
r3961 r4121 19 19 20 20 #include "i_physics.h" 21 21 #include "list.h" 22 #include "string.h" 22 23 #include "stdincl.h" 23 24 … … 31 32 { 32 33 this->setClassName ("IPhysics"); 34 this->mass = 0; 35 this->massChildren = 0; 33 36 } 34 37 … … 42 45 // delete what has to be deleted here 43 46 } 47 48 49 50 void IPhysics::setMass( float mass ) 51 { 52 this->mass = mass; 53 } 54 55 float IPhysics::getMass( void ) const 56 { 57 return this->mass; 58 } 59 60 float IPhysics::getTotalMass( void ) const 61 { 62 return (this->mass + this->massChildren); 63 } 64 65 void IPhysics::recalcMass() 66 { 67 float massSum = 0; 68 69 tIterator<PNode>* iterator = this->children->getIterator(); 70 PNode* pn = iterator->nextElement(); 71 while( pn != NULL) 72 { 73 // todo: find out if children are IPhysics in an efficient way 74 if (strcmp( pn->getClassName(), "IPhysics")) { 75 massSum += ((IPhysics*)pn)->getTotalMass(); 76 } 77 pn = iterator->nextElement(); 78 } 79 delete iterator; 80 81 if (massSum != this->massChildren ) { 82 this->massChildren = massSum; 83 if (strcmp( parent->getClassName(), "IPhysics")) 84 ((IPhysics*)parent)->recalcMass(); 85 } else { 86 this->massChildren = massSum; 87 } 88 } 89 90
Note: See TracChangeset
for help on using the changeset viewer.