本文整理汇总了C++中BinaryHeap::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryHeap::Add方法的具体用法?C++ BinaryHeap::Add怎么用?C++ BinaryHeap::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryHeap
的用法示例。
在下文中一共展示了BinaryHeap::Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindBestScore
float FindBestScore ( int iCountdown, float fCurrentScore, float fInputBestSoFar,
//WORD *pwIndices,
ScoreTri **ppstCurTris, // Pointer to a list of pointers to ScoreTris
int iNumTris, WORD *pwResult )
{
int iLookahead = iCountdown;
if ( iLookahead > LOOKAHEAD )
{
iLookahead = LOOKAHEAD;
}
//VERIFY ( fCurrentScore < 1e9 );
// At the start, limit the lookahead, or it takes ages.
if ( ( iNumTris > 100 ) && ( fCurrentScore < 50.0f ) && ( iLookahead > 2 ) )
{
iLookahead = 2;
}
float fBestSoFar = fInputBestSoFar;
// Given the BestSoFar score, what is the average cost of each lookahead tri?
float fAverageCost = ( fBestSoFar - fCurrentScore ) / (int)iLookahead;
// And now allow tris that are a bit worse.
float fExpensiveCutoff = fAverageCost * fExpensiveFactor;
VERIFY ( iCountdown > 0 );
VERIFY ( iNumTris > 0 );
int j;
if ( iNumTris == 1 )
{
// Well, that's an easy decision then.
// Find score after removal.
//float fTriScore = CacheAddTri ( pwIndices[0], pwIndices[1], pwIndices[2], TRUE );
ScoreTri *pstCur = ppstCurTris[0];
float fTriScore = CacheAddTri ( pstCur->wIndex[0], pstCur->wIndex[1], pstCur->wIndex[2], TRUE );
for ( j = 0; j < 3; j++ )
{
// Use the valence score after the tri has been removed.
//int iValence = (*(iValenceCounts.item(pwIndices[j]))) - 1;
int iValence = (svVertex.item(pstCur->wIndex[j])->iCurrentValence) - 1;
VERIFY ( iValence >= 0 );
if ( iValence < c_iMaxValenceBoost )
{
fTriScore += fValenceBoost[iValence];
}
else
{
fTriScore += fValenceBoost[c_iMaxValenceBoost-1];
}
}
fTriScore += fCurrentScore;
//pwResult[0] = pwIndices[0];
//pwResult[1] = pwIndices[1];
//pwResult[2] = pwIndices[2];
pwResult[0] = pstCur->wIndex[0];
pwResult[1] = pstCur->wIndex[1];
pwResult[2] = pstCur->wIndex[2];
if ( fTriScore > fBestSoFar )
{
// Oh well.
// (actually, not sure this ever happens).
return fInputBestSoFar;
}
else
{
return fTriScore;
}
}
#ifdef _DEBUG
for ( int k = 0; k < iNumTris; k++ )
{
VERIFY ( !ppstCurTris[k]->bAllowed );
VERIFY ( !ppstCurTris[k]->bUsed );
}
#endif
// Should we limit ourselves to tris that share at least one vert with the previous one?
//.........这里部分代码省略.........