Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5382 in orxonox.OLD for trunk/src/lib/coord


Ignore:
Timestamp:
Oct 15, 2005, 8:22:30 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: fixed a reparenting bug
made the naming more compliant

Location:
trunk/src/lib/coord
Files:
2 edited

Legend:

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

    r5372 r5382  
    235235}
    236236
     237
    237238/**
    238239 * @param absCoord set absolute coordinate
     
    266267}
    267268
     269
    268270/**
    269271 * @param x x-coordinate.
     
    287289   someNode->shiftCoor(objectMovement);
    288290
    289    elsewhere you would have to:
     291   otherwise you would have to:
    290292   PNode* someNode = ...;
    291293   Vector objectMovement = calculateShift();
     
    293295   Vector newCoor = currentCoor + objectMovement;
    294296   someNode->setRelCoor(newCoor);
    295 
    296    yea right... shorter...
    297297 *
    298 */
     298 */
    299299void PNode::shiftCoor (const Vector& shift)
    300300{
     
    405405 *  adds a child and makes this node to a parent
    406406 * @param child child reference
    407  * @param parentMode on which changes the child should also change ist state
    408  *
    409407 * use this to add a child to this node.
    410408*/
    411 void PNode::addChild (PNode* child, int parentMode)
     409void PNode::addChild (PNode* child)
    412410{
    413411  if( likely(child->parent != NULL))
     
    416414      child->parent->children->remove(child);
    417415    }
    418   child->parentMode = parentMode;
    419416  child->parent = this;
    420417  this->children->add(child);
     
    461458  while( pn != NULL)
    462459    {
    463       NullParent::getInstance()->addChild(pn, pn->getParentMode());
     460      NullParent::getInstance()->addChild(pn);
    464461      pn = iterator->nextElement();
    465462    }
     
    494491 * @param bias the speed to iterate to this new Positions
    495492 */
    496 void PNode::softReparent(PNode* parentNode, float bias)
    497 {
     493void PNode::setParentSoft(PNode* parentNode, float bias)
     494{
     495  // return if the new parent and the old one match
    498496  if (this->parent == parentNode)
    499497    return;
    500498
     499  // store the Valures to iterate to.
    501500  if (likely(this->toCoordinate == NULL))
    502501  {
     
    517516  parentNode->addChild(this);
    518517
    519  if (this->parentMode & PNODE_ROTATE_MOVEMENT)
    520    this->setRelCoor(this->parent->getAbsDir().inverse().apply(tmpV - this->parent->getAbsCoor()));
     518 if (this->parentMode & PNODE_ROTATE_MOVEMENT && this->parent != NULL)
     519   this->relCoordinate = this->parent->getAbsDir().inverse().apply(tmpV - this->parent->getAbsCoor());
    521520 else
    522    this->setRelCoor(tmpV - parentNode->getAbsCoor());
    523 
    524   this->setRelDir(tmpQ / parentNode->getAbsDir());
     521   this->relCoordinate = tmpV - parentNode->getAbsCoor();
     522
     523 this->relDirection = tmpQ / parentNode->getAbsDir();
    525524}
    526525
     
    530529 * @param bias the speed to iterate to this new Positions
    531530 */
    532 void PNode::softReparent(const char* parentName, float bias)
     531void PNode::setParentSoft(const char* parentName, float bias)
    533532{
    534533  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
    535534  if (parentNode != NULL)
    536     this->softReparent(parentNode, bias);
     535    this->setParentSoft(parentNode, bias);
    537536}
    538537
     
    561560      if (unlikely(this->toCoordinate != NULL))
    562561      {
    563         Vector moveVect = (*this->toCoordinate - this->getRelCoor()) *fabsf(dt)*bias;
    564 
     562        Vector moveVect = (*this->toCoordinate - this->relCoordinate) *fabsf(dt)*bias;
    565563        if (likely(moveVect.len() >= PNODE_ITERATION_DELTA))
    566564        {
     
    701699   displays the PNode at its position with its rotation as a cube.
    702700*/
    703 void PNode::debugDraw(unsigned int depth, float size, Vector color) const
     701void PNode::debugDraw(unsigned int depth, float size, const Vector& color) const
    704702{
    705703  glMatrixMode(GL_MODELVIEW);
  • trunk/src/lib/coord/p_node.h

    r5356 r5382  
    9696
    9797
    98   void addChild (PNode* child, int parentingMode = PNODE_PARENT_MODE_DEFAULT);
     98  void addChild (PNode* child);
    9999  void addChild (const char* childName);
    100100  void removeChild (PNode* child);
     
    106106  PNode* getParent () const { return this->parent; };
    107107
    108   void softReparent(PNode* parentNode, float bias = 1.0);
    109   void softReparent(const char* parentName, float bias = 1.0);
     108  void setParentSoft(PNode* parentNode, float bias = 1.0);
     109  void setParentSoft(const char* parentName, float bias = 1.0);
    110110
    111111  /** @param parentMode sets the parentingMode of this Node */
     
    118118
    119119  void debug (unsigned int depth = 1, unsigned int level = 0) const;
    120   void debugDraw(unsigned int depth = 1, float size = 1.0, Vector color = Vector(1,1,1)) const;
     120  void debugDraw(unsigned int depth = 1, float size = 1.0, const Vector& color = Vector(1,1,1)) const;
    121121
    122122
     
    150150  Vector          velocity;           //!< Saves the velocity.
    151151
    152   Vector*         toCoordinate;       //!< a position to which to iterate. (This is used in conjunction with softReparent.and set*CoorSoft)
    153   Quaternion*     toDirection;        //!< a direction to which to iterate. (This is used in conjunction with softReparent and set*DirSoft)
     152  Vector*         toCoordinate;       //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft)
     153  Quaternion*     toDirection;        //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft)
    154154  float           bias;               //!< how fast to iterate to the given position (default is 1)
    155155
Note: See TracChangeset for help on using the changeset viewer.