本文整理汇总了C++中CBitVec::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ CBitVec::Get方法的具体用法?C++ CBitVec::Get怎么用?C++ CBitVec::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBitVec
的用法示例。
在下文中一共展示了CBitVec::Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FinishLagCompensation
void CLagCompensationManager::FinishLagCompensation( CBasePlayer *player )
{
VPROF_BUDGET_FLAGS( "FinishLagCompensation", VPROF_BUDGETGROUP_OTHER_NETWORKING, BUDGETFLAG_CLIENT|BUDGETFLAG_SERVER );
m_pCurrentPlayer = NULL;
if ( !m_bNeedToRestore )
return; // no player was changed at all
// Iterate all active players
for ( int i = 1; i <= gpGlobals->maxClients; i++ )
{
int pl_index = i - 1;
if ( !m_RestorePlayer.Get( pl_index ) )
{
// player wasn't changed by lag compensation
continue;
}
CBasePlayer *pPlayer = UTIL_PlayerByIndex( i );
if ( !pPlayer )
{
continue;
}
LagRecord *restore = &m_RestoreData[ pl_index ];
LagRecord *change = &m_ChangeData[ pl_index ];
bool restoreSimulationTime = false;
if ( restore->m_fFlags & LC_SIZE_CHANGED )
{
restoreSimulationTime = true;
// see if simulation made any changes, if no, then do the restore, otherwise,
// leave new values in
if ( pPlayer->CollisionProp()->OBBMinsPreScaled() == change->m_vecMinsPreScaled &&
pPlayer->CollisionProp()->OBBMaxsPreScaled() == change->m_vecMaxsPreScaled )
{
// Restore it
pPlayer->SetSize( restore->m_vecMinsPreScaled, restore->m_vecMaxsPreScaled );
}
else
{
Warning( "Should we really not restore the size?\n" );
}
}
if ( restore->m_fFlags & LC_ANGLES_CHANGED )
{
restoreSimulationTime = true;
if ( pPlayer->GetLocalAngles() == change->m_vecAngles )
{
pPlayer->SetLocalAngles( restore->m_vecAngles );
}
}
if ( restore->m_fFlags & LC_ORIGIN_CHANGED )
{
restoreSimulationTime = true;
// Okay, let's see if we can do something reasonable with the change
Vector delta = pPlayer->GetLocalOrigin() - change->m_vecOrigin;
// If it moved really far, just leave the player in the new spot!!!
if ( delta.Length2DSqr() < m_flTeleportDistanceSqr )
{
RestorePlayerTo( pPlayer, restore->m_vecOrigin + delta );
}
}
if( restore->m_fFlags & LC_ANIMATION_CHANGED )
{
restoreSimulationTime = true;
pPlayer->SetSequence(restore->m_masterSequence);
pPlayer->SetCycle(restore->m_masterCycle);
int layerCount = pPlayer->GetNumAnimOverlays();
for( int layerIndex = 0; layerIndex < layerCount; ++layerIndex )
{
CAnimationLayer *currentLayer = pPlayer->GetAnimOverlay(layerIndex);
if( currentLayer )
{
currentLayer->m_flCycle = restore->m_layerRecords[layerIndex].m_cycle;
currentLayer->m_nOrder = restore->m_layerRecords[layerIndex].m_order;
currentLayer->m_nSequence = restore->m_layerRecords[layerIndex].m_sequence;
currentLayer->m_flWeight = restore->m_layerRecords[layerIndex].m_weight;
}
}
}
if ( restoreSimulationTime )
{
pPlayer->SetSimulationTime( restore->m_flSimulationTime );
}
}
//.........这里部分代码省略.........
示例2: BacktrackEntity
void CLagCompensationManager::BacktrackEntity( CAI_BaseNPC *pEntity, float flTargetTime )
{
Vector org, mins, maxs;
QAngle ang;
VPROF_BUDGET( "BacktrackEntity", "CLagCompensationManager" );
// get track history of this entity
int index = pEntity->GetAIIndex();
CUtlFixedLinkedList< LagRecord > *track = &m_EntityTrack[ index ];
// check if we have at leat one entry
if ( track->Count() <= 0 )
return;
int curr = track->Head();
LagRecord *prevRecord = NULL;
LagRecord *record = NULL;
Vector prevOrg = pEntity->GetLocalOrigin();
// Walk context looking for any invalidating event
while( track->IsValidIndex(curr) )
{
// remember last record
prevRecord = record;
// get next record
record = &track->Element( curr );
if ( !(record->m_fFlags & LC_ALIVE) )
{
// entity must be alive, lost track
return;
}
Vector delta = record->m_vecOrigin - prevOrg;
if ( delta.LengthSqr() > LAG_COMPENSATION_TELEPORTED_DISTANCE_SQR )
{
// lost track, moved too far (may have teleported)
return;
}
// did we find a context smaller than target time ?
if ( record->m_flSimulationTime <= flTargetTime )
break; // hurra, stop
prevOrg = record->m_vecOrigin;
// go one step back in time
curr = track->Next( curr );
}
Assert( record );
if ( !record )
{
if ( sv_unlag_debug.GetBool() )
{
DevMsg( "No valid positions in history for BacktrackEntity ( %s )\n", pEntity->GetClassname() );
}
return; // that should never happen
}
float frac = 0.0f;
if ( prevRecord &&
(record->m_flSimulationTime < flTargetTime) &&
(record->m_flSimulationTime < prevRecord->m_flSimulationTime) )
{
// we didn't find the exact time but have a valid previous record
// so interpolate between these two records;
Assert( prevRecord->m_flSimulationTime > record->m_flSimulationTime );
Assert( flTargetTime < prevRecord->m_flSimulationTime );
// calc fraction between both records
frac = ( flTargetTime - record->m_flSimulationTime ) /
( prevRecord->m_flSimulationTime - record->m_flSimulationTime );
Assert( frac > 0 && frac < 1 ); // should never extrapolate
ang = Lerp( frac, record->m_vecAngles, prevRecord->m_vecAngles );
org = Lerp( frac, record->m_vecOrigin, prevRecord->m_vecOrigin );
mins = Lerp( frac, record->m_vecMins, prevRecord->m_vecMins );
maxs = Lerp( frac, record->m_vecMaxs, prevRecord->m_vecMaxs );
}
else
{
// we found the exact record or no other record to interpolate with
// just copy these values since they are the best we have
ang = record->m_vecAngles;
org = record->m_vecOrigin;
mins = record->m_vecMins;
maxs = record->m_vecMaxs;
}
// See if this is still a valid position for us to teleport to
if ( sv_unlag_fixstuck.GetBool() )
//.........这里部分代码省略.........
示例3: SetParameters
void CGroundLine::SetParameters(
const Vector &vStart,
const Vector &vEnd,
const Vector &vStartColor, // Color values 0-1
const Vector &vEndColor,
float alpha,
float lineWidth
)
{
m_vStart = vStart;
m_vEnd = vEnd;
m_vStartColor = vStartColor;
m_vEndColor = vEndColor;
m_Alpha = alpha;
m_LineWidth = lineWidth;
Vector vTo( vEnd.x - vStart.x, vEnd.y - vStart.y, 0 );
float flXYLen = vTo.Length();
// Recalculate our segment list.
unsigned int nSteps = (int)flXYLen / XY_PER_SEGMENT;
nSteps = clamp( nSteps, 8, MAX_GROUNDLINE_SEGMENTS ) & ~1;
unsigned int nMaxSteps = nSteps / 2;
// First generate the sequence. We generate every other point here so it can insert fixup points to prevent
// it from crossing world geometry.
Vector pt[MAX_GROUNDLINE_SEGMENTS];
Vector vStep = (Vector(m_vEnd[0], m_vEnd[1], 0) - Vector(m_vStart[0], m_vStart[1], 0)) / (nMaxSteps-1);
pt[0] = FindBestSurfacePoint(m_vStart);
unsigned int i;
for(i=1; i < nMaxSteps; i++)
pt[i<<1] = FindBestSurfacePoint(pt[(i-1)<<1] + vStep);
CBitVec<MAX_GROUNDLINE_SEGMENTS> pointsUsed;
pointsUsed.ClearAll();
// Now try to make sure they don't intersect the geometry.
for(i=0; i < nMaxSteps-1; i++)
{
Vector &a = pt[i<<1];
Vector &b = pt[(i+1)<<1];
trace_t trace;
UTIL_TraceLine(a, b, MASK_SOLID_BRUSHONLY, NULL, COLLISION_GROUP_NONE, &trace);
if(trace.fraction < 1)
{
int cIndex = (i<<1)+1;
Vector &c = pt[cIndex];
// Ok, this line segment intersects the world. Do a binary search to try to find the
// point of intersection.
Vector hi, lo;
if(a.z < b.z)
{
hi = b;
lo = a;
}
else
{
hi = a;
lo = b;
}
if(BinSearchSegments(lo, hi, Vector(lo[0],lo[1],hi[2]), 15, &c))
{
pointsUsed.Set( cIndex );
}
else if(BinSearchSegments(lo, hi, Vector(hi[0],hi[1],hi[2]+500), 15, &c))
{
pointsUsed.Set( cIndex );
}
}
}
// Export the points.
m_nPoints = 0;
for(i=0; i < nSteps; i++)
{
// Every other point is always active.
if( pointsUsed.Get( i ) || !(i & 1) )
{
m_Points[m_nPoints] = pt[i];
++m_nPoints;
}
}
}