本文整理汇总了C++中Portal::setTargetPortal方法的典型用法代码示例。如果您正苦于以下问题:C++ Portal::setTargetPortal方法的具体用法?C++ Portal::setTargetPortal怎么用?C++ Portal::setTargetPortal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portal
的用法示例。
在下文中一共展示了Portal::setTargetPortal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: destroyPortal
// delete a portal instance by pointer
void PCZSceneManager::destroyPortal(Portal * p)
{
// remove the portal from it's target portal
Portal * targetPortal = p->getTargetPortal();
if (targetPortal)
{
targetPortal->setTargetPortal(0); // the targetPortal will still have targetZone value, but targetPortal will be invalid
}
// remove the Portal from it's home zone
PCZone * homeZone = p->getCurrentHomeZone();
if (homeZone)
{
// inform zone of portal change. Do here since PCZone is abstract
homeZone->setPortalsUpdated(true);
homeZone->_removePortal(p);
}
// remove the portal from the master portal list
PortalList::iterator it = std::find( mPortals.begin(), mPortals.end(), p );
if (it != mPortals.end())
{
mPortals.erase(it);
}
// delete the portal instance
OGRE_DELETE p;
}
示例2: connectPortalsToTargetZonesByLocation
/* Attempt to automatically connect unconnected portals to proper target zones
* by looking for matching portals in other zones which are at the same location
*/
void PCZSceneManager::connectPortalsToTargetZonesByLocation(void)
{
// go through every zone to find portals
ZoneMap::iterator i, iend;
PCZone* zone;
iend = mZones.end();
bool foundMatch;
for (i = mZones.begin(); i != iend; i++)
{
zone = i->second;
// go through all the portals in the zone
Portal* portal;
PortalList::iterator pi, piend;
piend = zone->mPortals.end();
for (pi = zone->mPortals.begin(); pi != piend; pi++)
{
portal = *pi;
//portal->updateDerivedValues();
if (portal->getTargetZone() == 0)
{
// this is a portal without a connected zone - look for
// a matching portal in another zone
PCZone* zone2;
ZoneMap::iterator j= mZones.begin();
foundMatch = false;
while (!foundMatch && j != mZones.end())
{
zone2 = j->second;
if (zone2 != zone) // make sure we don't look in the same zone
{
Portal * portal2 = zone2->findMatchingPortal(portal);
if (portal2)
{
// found a match!
Ogre::LogManager::getSingletonPtr()->logMessage("Connecting portal "+portal->getName()+" to portal "+portal2->getName());
foundMatch = true;
portal->setTargetZone(zone2);
portal->setTargetPortal(portal2);
portal2->setTargetZone(zone);
portal2->setTargetPortal(portal);
}
}
j++;
}
if (foundMatch == false)
{
// error, didn't find a matching portal!
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
"Could not find matching portal for portal " + portal->getName(),
"PCZSceneManager::connectPortalsToTargetZonesByLocation");
}
}
}
}
}