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


C++ WaypointList::push_front方法代码示例

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


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

示例1: RETAILMSG


//.........这里部分代码省略.........
                
                DEBUGMSG(ZONE_PATHFINDER | ZONE_VERBOSE, "+Open List: %d -> %d (cost=%f) (costSoFar=%f) (estimatedCostToGoal=%f)\n", 
                    pVisibleConnection->parentNodeID,
                    pVisibleConnection->destinationNodeID,
                    pVisibleConnection->fCost,
                    pVisibleConnection->fCostSoFar,
                    pVisibleConnection->fEstimatedCostToGoal);

                // TEST TEST: validate that the list is sorted!
                //if (!IsListSorted( &m_OpenList ) )
                //{
                //    RETAILMSG(ZONE_ERROR, "ERROR: m_OpenList is not sorted!\n");
                //}
            }
        } // END considering each connection from current node


        // Done sorting all connections from current node into open (viable) and closed (too expensive)
        // remove m_pCurrentConnection from open list
        m_OpenList.erase( m_pCurrentConnection );
        DEBUGMSG(ZONE_PATHFINDER | ZONE_VERBOSE, "-Open List:   %d -> %d (cost=%f) (costSoFar=%f) (estimatedCostToGoal=%f)\n", 
            m_pCurrentConnection->parentNodeID,
            m_pCurrentConnection->destinationNodeID,
            m_pCurrentConnection->fCost,
            m_pCurrentConnection->fCostSoFar,
            m_pCurrentConnection->fEstimatedCostToGoal);

        // put m_pCurrentConnection on closed list
        m_ClosedList.insert( m_pCurrentConnection );
        DEBUGMSG(ZONE_PATHFINDER | ZONE_VERBOSE, "+Closed List: %d -> %d (cost=%f) (costSoFar=%f) (estimatedCostToGoal=%f)\n", 
            m_pCurrentConnection->parentNodeID,
            m_pCurrentConnection->destinationNodeID,
            m_pCurrentConnection->fCost,
            m_pCurrentConnection->fCostSoFar,
            m_pCurrentConnection->fEstimatedCostToGoal);


        // If we've run too long, abort the search
        // Will resume where we left off on the next call to PathFindAStar().
        if (++numCells >= maxCells)
            break;
    } // END while( open list )

Exit:
    //
    // Display the Open and Closed lists for debugging
    //
    if (m_bShowPathFinding && m_pDisplayCallback)
    {
        ClosedListType::iterator ppClosedConnection;
        for (ppClosedConnection = m_ClosedList.begin(); ppClosedConnection != m_ClosedList.end(); ++ppClosedConnection)
        {
            Connection* pConnection = *ppClosedConnection;
            m_pDisplayCallback( NodeIDToWorldPosition( pConnection->destinationNodeID ), PATH_NODE_CLOSED );
        }

        OpenListType::iterator ppOpenConnection;
        for (ppOpenConnection = m_OpenList.begin(); ppOpenConnection != m_OpenList.end(); ++ppOpenConnection)
        {
            Connection* pConnection = *ppOpenConnection;
            m_pDisplayCallback( NodeIDToWorldPosition( pConnection->destinationNodeID ), PATH_NODE_OPEN );
        }

    }

    // If we got here, the open list is empty, or we ran out of time for this frame
//    if (m_pCurrentConnection->destinationNodeID != goalID)
    if (!bFoundGoal && m_OpenList.empty() )
    {
        if ( !m_OpenList.empty() )
        {
            DEBUGMSG(ZONE_PATHFINDER | ZONE_VERBOSE, "Halting search until next frame.\n");
        }
        else
        {
            DEBUGMSG(ZONE_PATHFINDER, "Found NO path to goalID!\n");
            CleanUp();
        }
    }
    else
    {
        DEBUGMSG(ZONE_PATHFINDER, "Found path to goalID.\n");


        // Walk back the connection list
        // Convert each connection into a Waypoint
        pWaypointList = new WaypointList();
//        while( m_pCurrentConnection )
        while( m_pCurrentConnection && m_pCurrentConnection->fCost > 0.0f )
        {
            pWaypointList->push_front( NodeIDToWorldPosition( m_pCurrentConnection->destinationNodeID ) );
            
            m_pCurrentConnection = m_pCurrentConnection->pParentConnection;
        }

        CleanUp();
    }

    return pWaypointList;
}
开发者ID:kabinud,项目名称:HappyGame,代码行数:101,代码来源:PathFind.cpp


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