Changeset 10618 in orxonox.OLD for trunk/src/lib/graphics/importer/bsp
- Timestamp:
- Apr 4, 2007, 12:13:53 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 16 16 OrxonoxPlayability.kdevses 17 17 OrxonoxPlayability.kdevelop.pcs 18 orxonox.backtrace 19 orxonox.kdevses 20 orxonox.kdevelop.pcs
-
- Property svn:ignore
-
trunk/src/lib/graphics/importer/bsp/bsp_manager.cc
r10519 r10618 30 30 #include "debug.h" 31 31 #include "material.h" 32 #include " camera.h"32 #include "tools/camera.h" 33 33 #include "vertex_array_model.h" 34 34 #include "world_entities/player.h" … … 982 982 float endDistance = end->dot(node->plane) - node->d; 983 983 float startDistance = start->dot(node->plane) - node->d; 984 985 984 986 985 if( node->isLeaf) { 987 986 leaf& curLeaf = this->bspFile->leaves[node->leafIndex]; … … 999 998 } 1000 999 1001 1000 //TODO valgrind complains about uninitialised value here 1002 1001 if (startDistance >= 0 && endDistance >= 0) // A 1003 1002 { // both points are in front of the plane … … 1102 1101 this->outputFraction = 1.0f; 1103 1102 1104 1105 1103 this->checkCollisionX(worldEntity); 1106 this->checkCollisionY(worldEntity);1107 1104 this->checkCollisionZ(worldEntity); 1105 1106 if(!(this->checkCollisionY(worldEntity))) 1107 this->checkCollisionWay(worldEntity); 1108 1108 1109 1109 … … 1288 1288 * check the collision in the x direction (forward, backward) 1289 1289 */ 1290 voidBspManager::checkCollisionX(WorldEntity* entity)1290 bool BspManager::checkCollisionX(WorldEntity* entity) 1291 1291 { 1292 1292 // Retrieve Bounding box … … 1398 1398 SolidFlag); 1399 1399 } 1400 1401 return (xCollisionBackward || xCollisionForward); 1400 1402 } 1401 1403 … … 1404 1406 * check the collision in the z direction (up, down) 1405 1407 */ 1406 voidBspManager::checkCollisionY(WorldEntity* entity)1408 bool BspManager::checkCollisionY(WorldEntity* entity) 1407 1409 { 1408 1410 … … 1546 1548 collPos, SolidFlag); 1547 1549 } 1550 1551 return (yCollisionUp || yCollisionDown); 1548 1552 } 1549 1553 … … 1554 1558 * check the collision in the z direction (left, right) 1555 1559 */ 1556 voidBspManager::checkCollisionZ(WorldEntity* entity)1560 bool BspManager::checkCollisionZ(WorldEntity* entity) 1557 1561 { 1558 1562 // Retrieve Bounding box … … 1664 1668 collPos , SolidFlag); 1665 1669 } 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 */ 1681 bool 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; 1666 1756 1667 1757 } -
trunk/src/lib/graphics/importer/bsp/bsp_manager.h
r10519 r10618 88 88 void checkCollisionRayN(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end); 89 89 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); 93 94 94 95 void checkCollisionBox(void);
Note: See TracChangeset
for help on using the changeset viewer.