Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 4, 2006, 2:26:34 AM (18 years ago)
Author:
patrick
Message:

cr z axis half check

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/presentation/src/lib/graphics/importer/bsp_manager.cc

    r9088 r9089  
    11821182  this->inputStart =  position;
    11831183  this->inputEnd =   forward;
    1184   this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &forward );
     1184  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &forward );
    11851185
    11861186  // collision occured
     
    12201220  this->inputStart =  position;
    12211221  this->inputEnd =   backward;
    1222   this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &backward );
     1222  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &backward );
    12231223
    12241224  // collision occured
     
    12561256void BspManager::checkCollisionY(WorldEntity* entity)
    12571257{
     1258  // Retrieve Bounding box
     1259  AABB* box = entity->getModelAABB();
     1260
     1261
     1262  plane*            testPlane          = NULL;  //!< the collision test plane
     1263
     1264  Vector            right;                      //!< right collision ray
     1265  Vector            left;                       //!< left collision ray
     1266  Vector            collPos;                    //!< the collision position
     1267
     1268  bool              zCollisionRight    = false; //!< flag true if right collision
     1269  bool              zCollisionLeft     = false; //!< flag true if left collision
     1270  bool              SolidFlag          = false; //!< flag set true if solid
     1271
     1272  Vector            position;                   //!< current position of the entity
     1273  Vector            dirZ;                       //!< direction x
     1274
     1275  position = entity->getAbsCoor();
     1276  dirZ =  entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
     1277
     1278  // calculate the rays
     1279  if( box != NULL)
     1280  {
     1281    right = entity->getAbsCoor() +  box->center + dirZ * (box->halfLength[2]  + BSP_Z_OFFSET);
     1282    left  = entity->getAbsCoor() -  box->center + dirZ * (box->halfLength[2]  + BSP_Z_OFFSET);
     1283  }
     1284  else
     1285  {
     1286    right = position + dirZ * 4.0f;
     1287    left  = position + Vector(0.0, 1.0, 0.0) + dirZ * 4.0;
     1288  }
     1289
     1290
     1291  /*   Z Ray right */
     1292  // init some member variables before collision check
     1293  this->outputStartsOut = true;
     1294  this->outputAllSolid = false;
     1295  this->outputFraction = 1.0f;
     1296  this->inputStart =  position;
     1297  this->inputEnd =   right;
     1298  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &right );
     1299
     1300
     1301  // collision occured
     1302  if( this->outputFraction < 1.0f )
     1303  {
     1304    collPos = position + (right - position) * this->outputFraction;
     1305    zCollisionRight = true;
     1306    testPlane = this->collPlane;
     1307  }
     1308  if(this->outputAllSolid )
     1309  {
     1310    this->collPlane = new plane;
     1311    this->collPlane->x = 0.0f;
     1312    this->collPlane->y = 0.0f;
     1313    this->collPlane->z = 0.0f;
     1314    testPlane = this->collPlane;
     1315
     1316    SolidFlag = true;
     1317    zCollisionRight = true;
     1318  }
     1319
     1320
     1321  if( zCollisionRight) {
     1322    entity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent,
     1323                                   entity,
     1324                                   Vector(testPlane->x, testPlane->y, testPlane->z),
     1325                                   collPos , SolidFlag);
     1326  }
     1327
    12581328
    12591329}
Note: See TracChangeset for help on using the changeset viewer.