Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10618 in orxonox.OLD for trunk/src/lib/graphics/importer/bsp


Ignore:
Timestamp:
Apr 4, 2007, 12:13:53 PM (18 years ago)
Author:
bknecht
Message:

merged cleanup into trunk (only improvements)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1616OrxonoxPlayability.kdevses
        1717OrxonoxPlayability.kdevelop.pcs
         18orxonox.backtrace
         19orxonox.kdevses
         20orxonox.kdevelop.pcs
  • trunk/src/lib/graphics/importer/bsp/bsp_manager.cc

    r10519 r10618  
    3030#include "debug.h"
    3131#include "material.h"
    32 #include "camera.h"
     32#include "tools/camera.h"
    3333#include "vertex_array_model.h"
    3434#include "world_entities/player.h"
     
    982982  float endDistance = end->dot(node->plane) - node->d;
    983983  float startDistance = start->dot(node->plane) - node->d;
    984 
    985 
     984 
    986985  if( node->isLeaf) {
    987986    leaf& curLeaf = this->bspFile->leaves[node->leafIndex];
     
    999998  }
    1000999
    1001 
     1000  //TODO valgrind complains about uninitialised value here
    10021001  if (startDistance >= 0 && endDistance >= 0)     // A
    10031002  {   // both points are in front of the plane
     
    11021101  this->outputFraction = 1.0f;
    11031102
    1104 
    11051103  this->checkCollisionX(worldEntity);
    1106   this->checkCollisionY(worldEntity);
    11071104  this->checkCollisionZ(worldEntity);
     1105
     1106  if(!(this->checkCollisionY(worldEntity)))
     1107  this->checkCollisionWay(worldEntity);
    11081108
    11091109
     
    12881288 * check the collision in the x direction (forward, backward)
    12891289 */
    1290 void BspManager::checkCollisionX(WorldEntity* entity)
     1290bool BspManager::checkCollisionX(WorldEntity* entity)
    12911291{
    12921292  // Retrieve Bounding box
     
    13981398                              SolidFlag);
    13991399  }
     1400
     1401 return (xCollisionBackward || xCollisionForward);
    14001402}
    14011403
     
    14041406 * check the collision in the z direction (up, down)
    14051407 */
    1406 void BspManager::checkCollisionY(WorldEntity* entity)
     1408bool BspManager::checkCollisionY(WorldEntity* entity)
    14071409{
    14081410
     
    15461548                              collPos, SolidFlag);
    15471549  }
     1550
     1551 return (yCollisionUp || yCollisionDown);
    15481552}
    15491553
     
    15541558 * check the collision in the z direction (left, right)
    15551559 */
    1556 void BspManager::checkCollisionZ(WorldEntity* entity)
     1560bool BspManager::checkCollisionZ(WorldEntity* entity)
    15571561{
    15581562  // Retrieve Bounding box
     
    16641668                               collPos , SolidFlag);
    16651669  }
     1670
     1671 return (zCollisionLeft || zCollisionRight);
     1672
     1673}
     1674
     1675
     1676
     1677
     1678/**
     1679 * check wether a collision occured on the way from the last position to the current position
     1680 */
     1681bool BspManager::checkCollisionWay(WorldEntity* entity)
     1682{
     1683
     1684
     1685 
     1686  plane*            testPlane          = NULL;  //!< the collision test plane
     1687  Vector            to;
     1688  Vector            collPos;                    //!< the collision position
     1689
     1690  bool              yCollisionUp       = false; //!< flag true if right collision
     1691  bool              SolidFlag          = false; //!< flag set true if solid
     1692
     1693  Vector            from;                   //!< current position of the entity
     1694  Vector            dirY;                       //!< direction x
     1695
     1696  from = entity->getLastAbsCoor();
     1697  to    = entity->getAbsCoor();
     1698  collPos = from;
     1699  dirY =  Vector(0.0, 1.0, 0.0);
     1700
     1701
     1702
     1703
     1704  /*   Y Ray up */
     1705  // init some member variables before collision check
     1706  this->inputStart = from;
     1707  this->inputEnd   = to;
     1708  this->checkCollisionRayN(this->root,0.0f,1.0f, &from, &to );
     1709
     1710  if( !this->outputStartsOut )
     1711  {
     1712    this->collPlane = new plane;
     1713    this->collPlane->x = 0.0f;
     1714    this->collPlane->y = 0.0f;
     1715    this->collPlane->z = 0.0f;
     1716    yCollisionUp = true;
     1717  }
     1718  else
     1719  {
     1720    if( this->outputFraction == 1.0f)
     1721    {
     1722      if( this->outputAllSolid )
     1723      {
     1724        this->collPlane = new plane;
     1725        this->collPlane->x = 0.0f;
     1726        this->collPlane->y = 0.0f;
     1727        this->collPlane->z = 0.0f;
     1728        yCollisionUp = true;
     1729        SolidFlag = true;
     1730      }
     1731      else
     1732      {
     1733        yCollisionUp = false;
     1734        collPos = to;
     1735      }
     1736    }
     1737    else
     1738    {
     1739      yCollisionUp = true;
     1740      collPos = from + (to - from) * this->outputFraction;
     1741      this->out = collPos;        // why this????
     1742    }
     1743  }
     1744  testPlane = this->collPlane;
     1745
     1746  // collision registration
     1747  if( yCollisionUp)
     1748  {
     1749    CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_WAY,
     1750                              entity, this->parent,
     1751                              Vector(testPlane->x, testPlane->y, testPlane->z),
     1752                              collPos, SolidFlag);
     1753  }
     1754
     1755 return yCollisionUp;
    16661756
    16671757}
  • trunk/src/lib/graphics/importer/bsp/bsp_manager.h

    r10519 r10618  
    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.