当前位置: 首页>>代码示例>>C++>>正文


C++ Transition::connectStates方法代码示例

本文整理汇总了C++中Transition::connectStates方法的典型用法代码示例。如果您正苦于以下问题:C++ Transition::connectStates方法的具体用法?C++ Transition::connectStates怎么用?C++ Transition::connectStates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transition的用法示例。


在下文中一共展示了Transition::connectStates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: buildFSM


//.........这里部分代码省略.........
					}
					State * src = fsm->getNode( stateNameMap[ gs->_stateName ] );
					if ( dynamic_cast< SharedGoalSelector * >( src->getGoalSelector() ) ) {
						logger << Logger::ERR_MSG << "Shared goal selector defined on line " << gs->_lineNo << " references a state with a shared goal.  The source state must have a full goal selector definition.";
						delete fsm;
						return 0x0;
					}
					state->clearGoalSelector();
					GoalSelector * srcGS = src->getGoalSelector();
					srcGS->setPersistence( true );
					state->setGoalSelector( srcGS );
				}
			}

			if ( VERBOSE ) logger << Logger::INFO_MSG << "There are " << fsmDescrip._transitions.size() << " transitions\n";

			//	2. Create transitions
			std::map< std::string, std::list< Transition * > >::iterator stItr = fsmDescrip._transitions.begin();
			for ( ; stItr != fsmDescrip._transitions.end(); ++stItr ) {
				const std::string fromName = stItr->first;
				std::list< Transition * > & tList = stItr->second;

				// Determine if the origin state is valid
				if ( fsmDescrip._stateNameMap.find( fromName ) == fsmDescrip._stateNameMap.end() ) {
					logger << Logger::ERR_MSG << "Transition with invalid from node name: " << fromName << ".";
					delete fsm;
					return 0x0;
				}

				// Try to connect the transitions to the destination(s)
				std::list< Transition * >::iterator tItr = tList.begin();
				for ( ; tItr != tList.end(); ++tItr ) {
					Transition * t = *tItr;
					if ( ! t->connectStates( fsmDescrip._stateNameMap ) ) {
						delete fsm;
						return 0x0;
					}
					fsm->addTransition( stateNameMap[ fromName ], t );
				}
				tList.clear();
			}
			fsmDescrip._transitions.clear();

			//////////////

			// copy over the velocity modifiers
			vItr = fsmDescrip._velModifiers.begin();
			for ( ; vItr != fsmDescrip._velModifiers.end(); ++vItr ) {   //TODO: replace global vel mod initalizer
				fsm->addVelModifier( *vItr );  

			}
			fsmDescrip._velModifiers.clear();

			// 3. Query simulator and fsm for possible reasons to have a task
			fsm->collectTasks();
			for ( std::list< Task * >::iterator itr = fsmDescrip._tasks.begin();
				itr != fsmDescrip._tasks.end();
				++itr ) {
				fsm->addTask( (*itr) );
			}
			fsmDescrip._tasks.clear();

			// spatial query and elevation tasks
			fsm->addTask( SPATIAL_QUERY->getTask() );
			if ( sim->getElevationInstance() ) {
				// NOTE: The elevation instance is null because none were specified.
开发者ID:argenos,项目名称:Menge,代码行数:67,代码来源:buildFSM.cpp


注:本文中的Transition::connectStates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。