本文整理汇总了C++中Portal::intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ Portal::intersects方法的具体用法?C++ Portal::intersects怎么用?C++ Portal::intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portal
的用法示例。
在下文中一共展示了Portal::intersects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _checkNodeAgainstPortals
void DefaultZone::_checkNodeAgainstPortals(PCZSceneNode * pczsn, Portal * ignorePortal)
{
if (pczsn == mEnclosureNode ||
pczsn->allowedToVisit() == false)
{
// don't do any checking of enclosure node versus portals
return;
}
PCZone * connectedZone;
for ( PortalList::iterator it = mPortals.begin(); it != mPortals.end(); ++it )
{
Portal * p = *it;
//Check if the portal intersects the node
if (p != ignorePortal &&
p->intersects(pczsn) != Portal::NO_INTERSECT)
{
// node is touching this portal
connectedZone = p->getTargetZone();
// add zone to the nodes visiting zone list unless it is the home zone of the node
if (connectedZone != pczsn->getHomeZone() &&
!pczsn->isVisitingZone(connectedZone))
{
pczsn->addZoneToVisitingZonesMap(connectedZone);
// tell the connected zone that the node is visiting it
connectedZone->_addNode(pczsn);
//recurse into the connected zone
connectedZone->_checkNodeAgainstPortals(pczsn, p->getTargetPortal());
}
}
}
}
示例2: updateNodeHomeZone
/* The following function checks if a node has left it's current home zone.
* This is done by checking each portal in the zone. If the node has crossed
* the portal, then the current zone is no longer the home zone of the node. The
* function then recurses into the connected zones. Once a zone is found where
* the node does NOT cross out through a portal, that zone is the new home zone.
NOTE: For this function to work, the node must start out in the proper zone to
begin with!
*/
PCZone* DefaultZone::updateNodeHomeZone( PCZSceneNode * pczsn, bool allowBackTouches )
{
// default to newHomeZone being the current home zone
PCZone * newHomeZone = pczsn->getHomeZone();
// Check all portals of the start zone for crossings!
Portal* portal;
PortalList::iterator pi, piend;
piend = mPortals.end();
for (pi = mPortals.begin(); pi != piend; pi++)
{
portal = *pi;
Portal::PortalIntersectResult pir = portal->intersects(pczsn);
switch (pir)
{
default:
case Portal::NO_INTERSECT: // node does not intersect portal - do nothing
case Portal::INTERSECT_NO_CROSS:// node intersects but does not cross portal - do nothing
break;
case Portal::INTERSECT_BACK_NO_CROSS:// node intersects but on the back of the portal
if (allowBackTouches)
{
// node is on wrong side of the portal - fix if we're allowing backside touches
if (portal->getTargetZone() != this &&
portal->getTargetZone() != pczsn->getHomeZone())
{
// set the home zone of the node to the target zone of the portal
pczsn->setHomeZone(portal->getTargetZone());
// continue checking for portal crossings in the new zone
newHomeZone = portal->getTargetZone()->updateNodeHomeZone(pczsn, false);
}
}
break;
case Portal::INTERSECT_CROSS:
// node intersects and crosses the portal - recurse into that zone as new home zone
if (portal->getTargetZone() != this &&
portal->getTargetZone() != pczsn->getHomeZone())
{
// set the home zone of the node to the target zone of the portal
pczsn->setHomeZone(portal->getTargetZone());
// continue checking for portal crossings in the new zone
newHomeZone = portal->getTargetZone()->updateNodeHomeZone(pczsn, true);
}
break;
}
}
// return the new home zone
return newHomeZone;
}
示例3: _findNodes
void DefaultZone::_findNodes( const Ray &t,
PCZSceneNodeList &list,
PortalList &visitedPortals,
bool includeVisitors,
bool recurseThruPortals,
PCZSceneNode *exclude )
{
// if this zone has an enclosure, check against the enclosure AABB first
if (mEnclosureNode)
{
std::pair<bool, Real> nsect = t.intersects(mEnclosureNode->_getWorldAABB());
if (!nsect.first)
{
// AABB of zone does not intersect t, just return.
return;
}
}
// check nodes at home in this zone
PCZSceneNodeList::iterator it = mHomeNodeList.begin();
while ( it != mHomeNodeList.end() )
{
PCZSceneNode * pczsn = *it;
if ( pczsn != exclude )
{
// make sure node is not already in the list (might have been added in another
// zone it was visiting)
PCZSceneNodeList::iterator it2 = list.find(pczsn);
if (it2 == list.end())
{
std::pair<bool, Real> nsect = t.intersects( pczsn -> _getWorldAABB() );
if ( nsect.first )
{
list.insert( pczsn );
}
}
}
++it;
}
if (includeVisitors)
{
// check visitor nodes
PCZSceneNodeList::iterator iter = mVisitorNodeList.begin();
while ( iter != mVisitorNodeList.end() )
{
PCZSceneNode * pczsn = *iter;
if ( pczsn != exclude )
{
// make sure node is not already in the list (might have been added in another
// zone it was visiting)
PCZSceneNodeList::iterator it2 = list.find(pczsn);
if (it2 == list.end())
{
std::pair<bool, Real> nsect = t.intersects( pczsn -> _getWorldAABB() );
if ( nsect.first )
{
list.insert( pczsn );
}
}
}
++iter;
}
}
// if asked to, recurse through portals
if (recurseThruPortals)
{
PortalList::iterator pit = mPortals.begin();
while ( pit != mPortals.end() )
{
Portal * portal = *pit;
// check portal versus bounding box
if (portal->intersects(t))
{
// make sure portal hasn't already been recursed through
PortalList::iterator pit2 = std::find(visitedPortals.begin(), visitedPortals.end(), portal);
if (pit2 == visitedPortals.end())
{
// save portal to the visitedPortals list
visitedPortals.push_front(portal);
// recurse into the connected zone
portal->getTargetZone()->_findNodes(t,
list,
visitedPortals,
includeVisitors,
recurseThruPortals,
exclude);
}
}
pit++;
}
}
}