本文整理汇总了C++中idBlockAlloc::GetAllocCount方法的典型用法代码示例。如果您正苦于以下问题:C++ idBlockAlloc::GetAllocCount方法的具体用法?C++ idBlockAlloc::GetAllocCount怎么用?C++ idBlockAlloc::GetAllocCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idBlockAlloc
的用法示例。
在下文中一共展示了idBlockAlloc::GetAllocCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: offsetof
/*
============
BuildPathTree
============
*/
pathNode_t *BuildPathTree( const obstacle_t *obstacles, int numObstacles, const idBounds &clipBounds, const idVec2 &startPos, const idVec2 &seekPos, obstaclePath_t &path ) {
int blockingEdgeNum, blockingObstacle, obstaclePoints, bestNumNodes = MAX_OBSTACLE_PATH;
float blockingScale;
pathNode_t *root, *node, *child;
// gcc 4.0
idQueueTemplate<pathNode_t, offsetof( pathNode_t, next ) > pathNodeQueue, treeQueue;
root = pathNodeAllocator.Alloc();
root->Init();
root->pos = startPos;
root->delta = seekPos - root->pos;
root->numNodes = 0;
pathNodeQueue.Add( root );
for ( node = pathNodeQueue.Get(); node && pathNodeAllocator.GetAllocCount() < MAX_PATH_NODES; node = pathNodeQueue.Get() ) {
treeQueue.Add( node );
// if this path has more than twice the number of nodes than the best path so far
if ( node->numNodes > bestNumNodes * 2 ) {
continue;
}
// don't move outside of the clip bounds
idVec2 endPos = node->pos + node->delta;
if ( endPos.x - CLIP_BOUNDS_EPSILON < clipBounds[0].x || endPos.x + CLIP_BOUNDS_EPSILON > clipBounds[1].x ||
endPos.y - CLIP_BOUNDS_EPSILON < clipBounds[0].y || endPos.y + CLIP_BOUNDS_EPSILON > clipBounds[1].y ) {
continue;
}
// if an obstacle is blocking the path
if ( GetFirstBlockingObstacle( obstacles, numObstacles, node->obstacle, node->pos, node->delta, blockingScale, blockingObstacle, blockingEdgeNum ) ) {
if ( path.firstObstacle == NULL ) {
path.firstObstacle = obstacles[blockingObstacle].entity;
}
node->delta *= blockingScale;
if ( node->edgeNum == -1 ) {
node->children[0] = pathNodeAllocator.Alloc();
node->children[0]->Init();
node->children[1] = pathNodeAllocator.Alloc();
node->children[1]->Init();
node->children[0]->dir = 0;
node->children[1]->dir = 1;
node->children[0]->parent = node->children[1]->parent = node;
node->children[0]->pos = node->children[1]->pos = node->pos + node->delta;
node->children[0]->obstacle = node->children[1]->obstacle = blockingObstacle;
node->children[0]->edgeNum = node->children[1]->edgeNum = blockingEdgeNum;
node->children[0]->numNodes = node->children[1]->numNodes = node->numNodes + 1;
if ( GetPathNodeDelta( node->children[0], obstacles, seekPos, true ) ) {
pathNodeQueue.Add( node->children[0] );
}
if ( GetPathNodeDelta( node->children[1], obstacles, seekPos, true ) ) {
pathNodeQueue.Add( node->children[1] );
}
} else {
node->children[node->dir] = child = pathNodeAllocator.Alloc();
child->Init();
child->dir = node->dir;
child->parent = node;
child->pos = node->pos + node->delta;
child->obstacle = blockingObstacle;
child->edgeNum = blockingEdgeNum;
child->numNodes = node->numNodes + 1;
if ( GetPathNodeDelta( child, obstacles, seekPos, true ) ) {
pathNodeQueue.Add( child );
}
}
} else {
node->children[node->dir] = child = pathNodeAllocator.Alloc();
child->Init();
child->dir = node->dir;
child->parent = node;
child->pos = node->pos + node->delta;
child->numNodes = node->numNodes + 1;
// there is a free path towards goal
if ( node->edgeNum == -1 ) {
if ( node->numNodes < bestNumNodes ) {
bestNumNodes = node->numNodes;
}
continue;
}
child->obstacle = node->obstacle;
obstaclePoints = obstacles[node->obstacle].winding.GetNumPoints();
child->edgeNum = ( node->edgeNum + obstaclePoints + ( 2 * node->dir - 1 ) ) % obstaclePoints;
if ( GetPathNodeDelta( child, obstacles, seekPos, false ) ) {
pathNodeQueue.Add( child );
}
}
}
//.........这里部分代码省略.........