Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4992 in orxonox.OLD for orxonox/trunk/src/lib


Ignore:
Timestamp:
Aug 13, 2005, 10:02:40 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: optimizations

Location:
orxonox/trunk/src/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/coord/p_node.cc

    r4991 r4992  
    114114  this->toPosition = NULL;
    115115  this->toDirection = NULL;
     116  this->bias = 1.0;
    116117}
    117118
     
    182183}
    183184
    184 void PNode::setRelCoorSoft(const Vector& relCoordSoft)
     185/**
     186 * sets a new relative position smoothely
     187 * @param relCoordSoft the new Position to iterate to
     188 * @param bias how fast to iterate to this position
     189 */
     190void PNode::setRelCoorSoft(const Vector& relCoordSoft, float bias)
    185191{
    186192  if (likely(this->toPosition == NULL))
     
    188194
    189195  *this->toPosition = relCoordSoft;
    190 }
    191 
    192 
    193 /**
    194  *  set relative coordinates
     196  this->bias = bias;
     197}
     198
     199
     200/**
     201 *  set relative coordinates smoothely
    195202 * @param x x-relative coordinates to its parent
    196203 * @param y y-relative coordinates to its parent
    197204 * @param z z-relative coordinates to its parent
    198    \see  void PNode::setRelCoor (const Vector& relCoord)
    199  */
    200 void PNode::setRelCoorSoft (float x, float y, float z)
    201 {
    202   this->setRelCoorSoft(Vector(x, y, z));
     205   \see  void PNode::setRelCoorSoft (const Vector&, float)
     206 */
     207void PNode::setRelCoorSoft (float x, float y, float z, float bias)
     208{
     209  this->setRelCoorSoft(Vector(x, y, z), bias);
    203210}
    204211
     
    295302 * sets the Relative Direction of this node to its parent in a Smoothed way
    296303 * @param relDirSoft the direction to iterate to smoothely.
    297  */
    298 void PNode::setRelDirSoft(const Quaternion& relDirSoft)
     304 * @param bias how fast to iterate to the new Direction
     305 */
     306void PNode::setRelDirSoft(const Quaternion& relDirSoft, float bias)
    299307{
    300308  if (likely(this->toDirection == NULL))
     
    302310
    303311  *this->toDirection = relDirSoft;
     312  this->bias = bias;
    304313}
    305314
     
    312321 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
    313322 */
    314 void PNode::setRelDirSoft(float x, float y, float z)
    315 {
    316   this->setRelDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)));
     323void PNode::setRelDirSoft(float x, float y, float z, float bias)
     324{
     325  this->setRelDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)), bias);
    317326}
    318327
     
    383392  if( likely(pNode->parent != NULL))
    384393    {
    385       PRINTF(3)("PNode::addChild() - reparenting node: removing it and adding it again\n");
     394      PRINTF(4)("PNode::addChild() - reparenting node: removing it and adding it again\n");
    386395      pNode->parent->children->remove(pNode);
    387396    }
     
    463472 * @param parentNode the new Node to connect this node to.
    464473 */
    465 void PNode::softReparent(PNode* parentNode)
    466 {
     474void PNode::softReparent(PNode* parentNode, float bias)
     475{
     476  if (this->parent == parentNode)
     477    return;
     478
    467479  //this->setRelCoorSoft(this->getRelCoor());
    468480  if (likely(this->toPosition == NULL))
     
    476488    *this->toDirection = this->getRelDir();
    477489  }
     490  this->bias = bias;
    478491
    479492
     
    491504}
    492505
    493 void PNode::softReparent(const char* parentName)
     506void PNode::softReparent(const char* parentName, float bias)
    494507{
    495508  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
    496509  if (parentNode != NULL)
    497     this->softReparent(parentNode);
     510    this->softReparent(parentNode, bias);
    498511}
    499512
     
    555568      if (unlikely(this->toPosition != NULL))
    556569      {
    557         Vector moveVect = (*this->toPosition - this->getRelCoor()) *dt;
     570        Vector moveVect = (*this->toPosition - this->getRelCoor()) *dt*bias;
    558571
    559572        if (likely(moveVect.len() >= .001))
     
    570583      if (unlikely(this->toDirection != NULL))
    571584      {
    572         Quaternion rotQuat = (*this->toDirection - this->getRelDir()) *dt;
     585        Quaternion rotQuat = (*this->toDirection - this->getRelDir()) *dt*bias;
    573586
    574587//        if (likely(rotQuat.len() >= .001))
  • orxonox/trunk/src/lib/coord/p_node.h

    r4991 r4992  
    6262  void setRelCoor (const Vector& relCoord);
    6363  void setRelCoor (float x, float y, float z);
    64   void setRelCoorSoft(const Vector& relCoordSoft);
    65   void setRelCoorSoft(float x, float y, float z);
     64  void setRelCoorSoft(const Vector& relCoordSoft, float bias = 1.0);
     65  void setRelCoorSoft(float x, float y, float z, float bias = 1.0);
    6666  /** @returns the relative position */
    6767  inline const Vector& getRelCoor () const { return this->relCoordinate; };
     
    7474  void setRelDir (const Quaternion& relDir);
    7575  void setRelDir (float x, float y, float z);
    76   void setRelDirSoft(const Quaternion& relDirSoft);
    77   void setRelDirSoft(float x, float y, float z);
     76  void setRelDirSoft(const Quaternion& relDirSoft, float bias = 1.0);
     77  void setRelDirSoft(float x, float y, float z, float bias = 1.0);
    7878  /** @returns the relative Direction */
    7979  inline const Quaternion& getRelDir () const { return this->relDirection; };
     
    104104  PNode* getParent () const { return this->parent; };
    105105
    106   void softReparent(PNode* parentNode);
    107   void softReparent(const char* parentName);
     106  void softReparent(PNode* parentNode, float bias = 1.0);
     107  void softReparent(const char* parentName, float bias = 1.0);
    108108
    109109  void setParentMode (PARENT_MODE parentMode);
     
    144144  Vector*         toPosition;         //!< a position to which to iterate. (This is used in conjunction with softReparent.and set*CoorSoft)
    145145  Quaternion*     toDirection;        //!< a direction to which to iterate. (This is used in conjunction with softReparent and set*DirSoft)
     146  float           bias;               //!< how fast to iterate to the given position (default is 1)
    146147
    147148  PNode*          parent;             //!< a pointer to the parent node
  • orxonox/trunk/src/lib/math/vector.h

    r4966 r4992  
    2929  /** @param index The index of the "array" @returns the x/y/z coordinate */
    3030  inline float operator[] (float index) const {if( index == 0) return this->x; if( index == 1) return this->y; if( index == 2) return this->z; }
    31   /*** @param v The vector to add @returns the addition between two vectors (this + v) */
     31  /** @param v The vector to add @returns the addition between two vectors (this + v) */
    3232  inline Vector operator+ (const Vector& v) const { return Vector(x + v.x, y + v.y, z + v.z); };
    33   /*** @param v The vector to add @returns the addition between two vectors (this + v) */
     33  /** @param v The vector to add @returns the addition between two vectors (this + v) */
    3434  inline Vector operator+ (const sVec3D& v) const { return Vector(x + v[0], y + v[1], z + v[2]); };
    3535  /** @param v The vector to add  @returns the addition between two vectors (this += v) */
     
    5757  /** @param f a factor to divide the vector with @returns the vector divided by f (this /= f) */
    5858  inline const Vector& operator/= (float f) {if (unlikely(f == 0.0)) {this->x=0;this->y=0;this->z=0;} else {this->x /= f; this->y /= f; this->z /= f;} return *this; };
    59   /** \brief copy constructor @todo (i do not know it this is faster) @param v the vector to assign to this vector. @returns the vector v */
     59  /** copy constructor @todo (i do not know it this is faster) @param v the vector to assign to this vector. @returns the vector v */
    6060  inline const Vector& operator= (const Vector& v) { this->x = v.x; this->y = v.y; this->z = v.z; return *this; };
    61   /** \brief copy constructor* @param v the sVec3D to assign to this vector. @returns the vector v */
     61  /** copy constructor* @param v the sVec3D to assign to this vector. @returns the vector v */
    6262  inline const Vector& operator= (const sVec3D& v) { this->x = v[0]; this->y = v[1]; this->z = v[2]; }
    6363  /** @param v: the other vector \return the dot product of the vectors */
     
    6565  /** @param v: the corss-product partner @returns the cross-product between this and v (this (x) v) */
    6666  inline Vector cross (const Vector& v) const { return Vector(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); }
    67   /** \brief scales the this vector with v* @param v the vector to scale this with */
     67  /** scales the this vector with v* @param v the vector to scale this with */
    6868  void scale(const Vector& v) {   x *= v.x;  y *= v.y; z *= v.z; };
    6969  /** @returns the length of the vector */
    7070  inline float len() const { return sqrt (x*x+y*y+z*z); }
    71   /** \brief normalizes the vector */
     71  /** normalizes the vector */
    7272  inline void normalize() {
    7373                      float l = len();
Note: See TracChangeset for help on using the changeset viewer.