Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10599 in orxonox.OLD for branches/cleanup/src/lib


Ignore:
Timestamp:
Feb 24, 2007, 12:25:48 PM (18 years ago)
Author:
bottac
Message:

1st part of the collision bug fix.

BTW, if shouldn't have amarok (what a pity), try to
suspend/'wake up' orxonox (CTRL-Z / fg). ;-)

Location:
branches/cleanup/src/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/src/lib/collision_reaction/cr_engine.h

    r10013 r10599  
    6262      CR_COLLISION_TYPE_AXIS_Z,            //!< collision on z axis
    6363      CR_COLLISION_TYPE_AXIS_Z_NEG,        //!< collision on negative z axis
     64      CR_COLLISION_TYPE_WAY,               //!< collision on the way from last to current position
    6465      CR_COLLISION_TYPE_OBB,               //!< object aligned bounding box collide
    6566
  • branches/cleanup/src/lib/collision_reaction/cr_physics_full_walk.cc

    r10013 r10599  
    163163
    164164
     165 case CoRe::CREngine::CR_COLLISION_TYPE_WAY:
     166          // calulate the height above ground
     167          height = collPos.len() - box->halfLength[1];
     168
     169
     170          // object is beneath the plane (ground)
     171          //         if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing
     172          if( height < 0.0f  )
     173          {
     174            entity->shiftCoor(Vector(0.0f, -height + 0.5f, 0.0f));
     175            entity->setOnGround(true);
     176          }
     177          // object is already in the wall
     178          else if( ce->isInWall())
     179          {
     180            entity->setAbsCoor(entity->getLastAbsCoor());
     181            PRINTF(0)("ground collision: reset pos\n");
     182          }
     183          else
     184          {
     185            // entity is not on ground
     186            entity->setOnGround(false);
     187          }
     188          break;
     189
     190
    165191          /* collision in the Z-AXIS */
    166192        case CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Z:
  • branches/cleanup/src/lib/graphics/importer/bsp/bsp_manager.cc

    r10591 r10599  
    11021102  this->outputFraction = 1.0f;
    11031103
    1104 
    11051104  this->checkCollisionX(worldEntity);
    1106   this->checkCollisionY(worldEntity);
    11071105  this->checkCollisionZ(worldEntity);
     1106
     1107  if(!(this->checkCollisionY(worldEntity)))
     1108  this->checkCollisionWay(worldEntity);
    11081109
    11091110
     
    12881289 * check the collision in the x direction (forward, backward)
    12891290 */
    1290 void BspManager::checkCollisionX(WorldEntity* entity)
     1291bool BspManager::checkCollisionX(WorldEntity* entity)
    12911292{
    12921293  // Retrieve Bounding box
     
    13981399                              SolidFlag);
    13991400  }
     1401
     1402 return (xCollisionBackward || xCollisionForward);
    14001403}
    14011404
     
    14041407 * check the collision in the z direction (up, down)
    14051408 */
    1406 void BspManager::checkCollisionY(WorldEntity* entity)
     1409bool BspManager::checkCollisionY(WorldEntity* entity)
    14071410{
    14081411
     
    15461549                              collPos, SolidFlag);
    15471550  }
     1551
     1552 return (yCollisionUp || yCollisionDown);
    15481553}
    15491554
     
    15541559 * check the collision in the z direction (left, right)
    15551560 */
    1556 void BspManager::checkCollisionZ(WorldEntity* entity)
     1561bool BspManager::checkCollisionZ(WorldEntity* entity)
    15571562{
    15581563  // Retrieve Bounding box
     
    16641669                               collPos , SolidFlag);
    16651670  }
     1671
     1672 return (zCollisionLeft || zCollisionRight);
     1673
     1674}
     1675
     1676
     1677
     1678
     1679/**
     1680 * check wether a collision occured on the way from the last position to the current position
     1681 */
     1682bool BspManager::checkCollisionWay(WorldEntity* entity)
     1683{
     1684
     1685
     1686 
     1687  plane*            testPlane          = NULL;  //!< the collision test plane
     1688  Vector            to;
     1689  Vector            collPos;                    //!< the collision position
     1690
     1691  bool              yCollisionUp       = false; //!< flag true if right collision
     1692  bool              SolidFlag          = false; //!< flag set true if solid
     1693
     1694  Vector            from;                   //!< current position of the entity
     1695  Vector            dirY;                       //!< direction x
     1696
     1697  from = entity->getLastAbsCoor();
     1698  to    = entity->getAbsCoor();
     1699  collPos = from;
     1700  dirY =  Vector(0.0, 1.0, 0.0);
     1701
     1702
     1703
     1704
     1705  /*   Y Ray up */
     1706  // init some member variables before collision check
     1707  this->inputStart = from;
     1708  this->inputEnd   = to;
     1709  this->checkCollisionRayN(this->root,0.0f,1.0f, &from, &to );
     1710
     1711  if( !this->outputStartsOut )
     1712  {
     1713    this->collPlane = new plane;
     1714    this->collPlane->x = 0.0f;
     1715    this->collPlane->y = 0.0f;
     1716    this->collPlane->z = 0.0f;
     1717    yCollisionUp = true;
     1718  }
     1719  else
     1720  {
     1721    if( this->outputFraction == 1.0f)
     1722    {
     1723      if( this->outputAllSolid )
     1724      {
     1725        this->collPlane = new plane;
     1726        this->collPlane->x = 0.0f;
     1727        this->collPlane->y = 0.0f;
     1728        this->collPlane->z = 0.0f;
     1729        yCollisionUp = true;
     1730        SolidFlag = true;
     1731      }
     1732      else
     1733      {
     1734        yCollisionUp = false;
     1735        collPos = to;
     1736      }
     1737    }
     1738    else
     1739    {
     1740      yCollisionUp = true;
     1741      collPos = from + (to - from) * this->outputFraction;
     1742      this->out = collPos;        // why this????
     1743    }
     1744  }
     1745  testPlane = this->collPlane;
     1746
     1747  // collision registration
     1748  if( yCollisionUp)
     1749  {
     1750    CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_WAY,
     1751                              entity, this->parent,
     1752                              Vector(testPlane->x, testPlane->y, testPlane->z),
     1753                              collPos, SolidFlag);
     1754  }
     1755
     1756 return yCollisionUp;
    16661757
    16671758}
  • branches/cleanup/src/lib/graphics/importer/bsp/bsp_manager.h

    r10519 r10599  
    8888  void  checkCollisionRayN(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
    8989
    90   void checkCollisionX(WorldEntity* entity);
    91   void checkCollisionY(WorldEntity* entity);
    92   void checkCollisionZ(WorldEntity* entity);
     90  bool checkCollisionX(WorldEntity* entity);
     91  bool checkCollisionY(WorldEntity* entity);
     92  bool checkCollisionZ(WorldEntity* entity);
     93  bool checkCollisionWay(WorldEntity* entity);
    9394
    9495  void  checkCollisionBox(void);
Note: See TracChangeset for help on using the changeset viewer.