Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4558 in orxonox.OLD for orxonox/trunk/src/lib/physics


Ignore:
Timestamp:
Jun 8, 2005, 9:02:12 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: PhysicsEngine looks better (it speeds up things… but i do not exactly know if it works

Location:
orxonox/trunk/src/lib/physics
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/physics/physics_engine.cc

    r4519 r4558  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2828   \brief standard constructor
    2929*/
    30 PhysicsEngine::PhysicsEngine() 
     30PhysicsEngine::PhysicsEngine()
    3131{
    3232   this->setClassName ("PhysicsEngine");
     
    4646
    4747*/
    48 PhysicsEngine::~PhysicsEngine () 
     48PhysicsEngine::~PhysicsEngine ()
    4949{
    5050  PhysicsEngine::singletonRef = NULL;
     
    7171void PhysicsEngine::removePhysicsInterface(PhysicsInterface* physicsInterface)
    7272{
    73   this->interfaces->remove(physicsInterface); 
     73  this->interfaces->remove(physicsInterface);
    7474}
    7575
     
    9999   \brief adds A Physical Connection to the List of Connections
    100100   \param connection the Connection to add
    101    
     101
    102102   Usually this is done through the constructor of PhysicshConnections
    103103*/
     
    110110   \brief removes A Physical Connection from the List of Connections
    111111   \param connection the Connection to remove
    112    
     112
    113113   Usually this is done through the destructor of PhysicsConnections
    114114*/
     
    130130void PhysicsEngine::tick(float dt)
    131131{
     132  /* go through all the PhysicsInterface(s) and tick them,
     133  meaning let the fields work */
    132134  tIterator<PhysicsConnection>* itPC = this->connections->getIterator();
    133135  PhysicsConnection* enumPC = itPC->nextElement();
     
    135137    {
    136138      enumPC->apply();
     139
    137140      enumPC = itPC->nextElement();
    138141    }
    139142  delete itPC;
    140143
    141 
     144  /* actually tick all the PhysicsInterfaces. Move the objects around */
    142145  tIterator<PhysicsInterface>* itPI = this->interfaces->getIterator();
    143146  PhysicsInterface* enumPI = itPI->nextElement();
     
    145148    {
    146149      enumPI->tickPhys(dt);
     150
    147151      enumPI = itPI->nextElement();
    148152    }
  • orxonox/trunk/src/lib/physics/physics_engine.h

    r4519 r4558  
    1 /*! 
     1/*!
    22    \file physics_engine.h
    3     \brief Definition of the ... singleton Class
    4    
     3    \brief Definition of the PhysicsEngine-singleton Class
     4
    55*/
    66
     
    1818
    1919
    20 //! A default singleton class.
     20//! A class, that brings things into motion through Physics.
    2121class PhysicsEngine : public BaseObject {
    2222
     
    4141 private:
    4242  PhysicsEngine(void);
    43   static PhysicsEngine* singletonRef;      //!< the singleton reference of the PhysicsEngine
    4443
    45   tList<PhysicsInterface>* interfaces;     //!< a list of physically based objects
    46   tList<Field>* fields;                    //!< a list of physicsl fields.
    47   tList<PhysicsConnection>* connections;   //!< a list of physical connections
     44 private:
     45  static PhysicsEngine*         singletonRef;         //!< the singleton reference of the PhysicsEngine
     46
     47  tList<PhysicsInterface>*      interfaces;           //!< a list of physically based objects
     48  tList<Field>*                 fields;               //!< a list of physicsl fields.
     49  tList<PhysicsConnection>*     connections;          //!< a list of physical connections
    4850};
    4951
  • orxonox/trunk/src/lib/physics/physics_interface.cc

    r4555 r4558  
    4444   this->massChildren = 0;
    4545   this->forceSum = Vector(0, 0, 0);
     46   this->bForceApplied = false;
    4647
    4748   PhysicsEngine::getInstance()->addPhysicsInterface(this);
     
    9798  PNode* tmp = (PNode*) objectPointer;
    9899  this->forceSum += field->calcForce(tmp->getAbsCoor());
     100  this->bForceApplied = true;
    99101}
    100102
     
    107109  //  Vector acc = this->forceSum / ( this->massChildren + this->mass );
    108110  PNode* coorTick =  (PNode*)(this->objectPointer);
    109   if (coorTick)
    110     coorTick->setRelCoor(coorTick->getRelCoor() + this->forceSum/this->mass * dt);
     111  if (this->bForceApplied && coorTick)
     112  {
     113    coorTick->shiftCoor((coorTick->getVelocity()+ this->forceSum/this->mass * dt)*dt);
     114
     115    this->bForceApplied = false;
     116  }
    111117  this->forceSum = Vector(0,0,0);
    112   // todo: introduce kinematics
    113118}
  • orxonox/trunk/src/lib/physics/physics_interface.h

    r4555 r4558  
    4848 private:
    4949  void*          objectPointer;         //!< A Pointer to the object we handel (actually should be this)
     50
     51
    5052  float          mass;                  //!< Mass of this object
    5153  float          massChildren;          //!< Sum of the masses of the children nodes
     54
    5255  Vector         forceSum;              //!< Total central force for this tick
    5356  Quaternion     momentumSum;           //!< Total momentum in this tick
     57  bool           bForceApplied;         //!< If a force was applied to this object.
    5458};
    5559
Note: See TracChangeset for help on using the changeset viewer.