本文整理汇总了C++中CThreadFastMutex类的典型用法代码示例。如果您正苦于以下问题:C++ CThreadFastMutex类的具体用法?C++ CThreadFastMutex怎么用?C++ CThreadFastMutex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CThreadFastMutex类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLightingAtPoint
//-----------------------------------------------------------------------------
// Inherited from IParticleSystemQuery
//-----------------------------------------------------------------------------
void CParticleSystemQuery::GetLightingAtPoint( const Vector& vecOrigin, Color &cTint )
{
#ifdef GAME_DLL
// FIXME: Go through to the engine from the server to get these values
cTint.SetColor( 255, 255, 255, 255 );
#else
if ( engine->IsInGame() )
{
s_LightMutex.Lock();
// Compute our lighting at our position
Vector totalColor = engine->GetLightForPoint( vecOrigin, true );
s_LightMutex.Unlock();
// Get our lighting information
cTint.SetColor( totalColor.x*255, totalColor.y*255, totalColor.z*255, 0 );
}
else
{
// FIXME: Go through to the engine from the server to get these values
cTint.SetColor( 255, 255, 255, 255 );
}
#endif
}
示例2: OnPreQuery
//-----------------------------------------------------------------------------
// Makes sure all entries in the KD tree are in the correct position
//-----------------------------------------------------------------------------
void CDirtySpatialPartitionEntityList::OnPreQuery( SpatialPartitionListMask_t listMask )
{
#ifdef CLIENT_DLL
if ( !( listMask & PARTITION_CLIENT_GAME_EDICTS ) )
return;
// FIXME: This should really be an assertion... feh!
if ( !C_BaseEntity::IsAbsRecomputationsEnabled() )
{
m_mutex.Lock();
return;
}
#else
if ( !( listMask & PARTITION_SERVER_GAME_EDICTS ) )
return;
#endif
m_mutex.Lock();
CUtlVector< CBaseHandle > vecStillDirty;
int nDirtyEntityCount = m_DirtyEntities.Count();
while ( nDirtyEntityCount > 0 )
{
CBaseHandle handle;
handle = m_DirtyEntities[nDirtyEntityCount-1];
#ifndef CLIENT_DLL
CBaseEntity *pEntity = gEntList.GetBaseEntity( handle );
#else
CBaseEntity *pEntity = cl_entitylist->GetBaseEntityFromHandle( handle );
#endif
m_DirtyEntities.FastRemove( nDirtyEntityCount-1 );
if ( pEntity )
{
// If an entity is in the middle of bone setup, don't call UpdatePartition
// which can cause it to redo bone setup on the same frame causing a recursive
// call to bone setup.
if ( !pEntity->IsEFlagSet( EFL_SETTING_UP_BONES ) )
{
pEntity->CollisionProp()->UpdatePartition();
}
else
{
vecStillDirty.AddToTail( handle );
}
}
nDirtyEntityCount = m_DirtyEntities.Count();
}
if ( vecStillDirty.Count() > 0 )
{
m_DirtyEntities = vecStillDirty;
}
}
示例3: SetUpLightingEnvironment
void CParticleSystemQuery::SetUpLightingEnvironment( const Vector& pos )
{
#ifndef GAME_DLL
if ( !engine->IsInGame() )
return;
s_LightMutex.Lock();
modelrender->SetupLighting( pos );
s_LightMutex.Unlock();
#endif
}
示例4: OnPostQuery
//-----------------------------------------------------------------------------
// Makes sure all entries in the KD tree are in the correct position
//-----------------------------------------------------------------------------
void CDirtySpatialPartitionEntityList::OnPostQuery( SpatialPartitionListMask_t listMask )
{
#ifdef CLIENT_DLL
if ( !( listMask & PARTITION_CLIENT_GAME_EDICTS ) )
return;
#else
if ( !( listMask & PARTITION_SERVER_GAME_EDICTS ) )
return;
#endif
m_mutex.Unlock();
}
示例5: IsPointInControllingObjectHitBox
bool CParticleSystemQuery::IsPointInControllingObjectHitBox(
CParticleCollection *pParticles,
int nControlPointNumber, Vector vecPos, bool bBBoxOnly )
{
bool bSuccess = false;
#ifndef GAME_DLL
EHANDLE *phMoveParent = reinterpret_cast<EHANDLE *> ( pParticles->m_ControlPoints[nControlPointNumber].m_pObject );
CBaseEntity *pMoveParent = NULL;
if ( phMoveParent )
{
pMoveParent = *( phMoveParent );
}
if ( pMoveParent )
{
s_BoneMutex.Lock();
C_BaseAnimating *pAnimating = pMoveParent->GetBaseAnimating();
bool bInBBox = false;
Vector vecBBoxMin;
Vector vecBBoxMax;
Vector vecOrigin;
vecBBoxMin = pMoveParent->CollisionProp()->OBBMins();
vecBBoxMax = pMoveParent->CollisionProp()->OBBMaxs();
matrix3x4_t matOrientation;
matOrientation = pMoveParent->EntityToWorldTransform();
Vector vecLocalPos;
VectorITransform( vecPos, matOrientation, vecLocalPos );
if ( IsPointInBox( vecLocalPos, vecBBoxMin, vecBBoxMax ) )
bInBBox = true;
if ( bInBBox && bBBoxOnly )
bSuccess = true;
else if ( pAnimating && bInBBox )
{
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
if ( pAnimating->HitboxToWorldTransforms( hitboxbones ) )
{
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if ( pStudioHdr )
{
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( set )
{
// do a point in solid test
Ray_t ray;
trace_t tr;
ray.Init( vecPos, vecPos );
enginetrace->ClipRayToEntity( ray, MASK_ALL, pMoveParent, &tr );
if ( tr.startsolid )
bSuccess = true;
}
}
}
}
else if ( pMoveParent->IsBrushModel() && bInBBox )
{
// do a point in solid test
Ray_t ray;
trace_t tr;
ray.Init( vecPos, vecPos );
enginetrace->ClipRayToEntity( ray, MASK_ALL, pMoveParent, &tr );
if ( tr.startsolid )
bSuccess = true;
}
s_BoneMutex.Unlock();
}
#endif
return bSuccess;
}
示例6: GetControllingObjectHitBoxInfo
int CParticleSystemQuery::GetControllingObjectHitBoxInfo(
CParticleCollection *pParticles,
int nControlPointNumber,
int nBufSize, // # of output slots available
ModelHitBoxInfo_t *pHitBoxOutputBuffer )
{
int nRet = 0;
#ifndef GAME_DLL
s_BoneMutex.Lock();
EHANDLE *phMoveParent = reinterpret_cast<EHANDLE *> ( pParticles->m_ControlPoints[nControlPointNumber].m_pObject );
CBaseEntity *pMoveParent = NULL;
if ( phMoveParent )
{
pMoveParent = *( phMoveParent );
}
if ( pMoveParent )
{
C_BaseAnimating *pAnimating = pMoveParent->GetBaseAnimating();
if ( pAnimating )
{
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
if ( pAnimating->HitboxToWorldTransforms( hitboxbones ) )
{
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if ( pStudioHdr )
{
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( set )
{
nRet = min( nBufSize, set->numhitboxes );
for( int i=0 ; i < nRet; i++ )
{
mstudiobbox_t *pBox = set->pHitbox( i );
pHitBoxOutputBuffer[i].m_vecBoxMins.x = pBox->bbmin.x;
pHitBoxOutputBuffer[i].m_vecBoxMins.y = pBox->bbmin.y;
pHitBoxOutputBuffer[i].m_vecBoxMins.z = pBox->bbmin.z;
pHitBoxOutputBuffer[i].m_vecBoxMaxes.x = pBox->bbmax.x;
pHitBoxOutputBuffer[i].m_vecBoxMaxes.y = pBox->bbmax.y;
pHitBoxOutputBuffer[i].m_vecBoxMaxes.z = pBox->bbmax.z;
pHitBoxOutputBuffer[i].m_Transform = *hitboxbones[pBox->bone];
}
}
}
}
}
if ( pMoveParent->IsBrushModel() )
{
Vector vecMin;
Vector vecMax;
matrix3x4_t matOrientation;
pMoveParent->GetRenderBounds( vecMin, vecMax );
matOrientation = pMoveParent->EntityToWorldTransform();
pHitBoxOutputBuffer[0].m_vecBoxMins = vecMin;
pHitBoxOutputBuffer[0].m_vecBoxMaxes = vecMax;
pHitBoxOutputBuffer[0].m_Transform = matOrientation;
nRet = 1;
}
}
s_BoneMutex.Unlock();
#endif
return nRet;
}
示例7: GetRandomPointsOnControllingObjectHitBox
void CParticleSystemQuery::GetRandomPointsOnControllingObjectHitBox(
CParticleCollection *pParticles,
int nControlPointNumber,
int nNumPtsOut,
float flBBoxScale,
int nNumTrysToGetAPointInsideTheModel,
Vector *pPntsOut,
Vector vecDirectionalBias,
Vector *pHitBoxRelativeCoordOut,
int *pHitBoxIndexOut
)
{
bool bSucesss = false;
#ifndef GAME_DLL
EHANDLE *phMoveParent = reinterpret_cast<EHANDLE *> ( pParticles->m_ControlPoints[nControlPointNumber].m_pObject );
CBaseEntity *pMoveParent = NULL;
if ( phMoveParent )
{
pMoveParent = *( phMoveParent );
}
if ( pMoveParent )
{
float flRandMax = flBBoxScale;
float flRandMin = 1.0 - flBBoxScale;
Vector vecBasePos;
pParticles->GetControlPointAtTime( nControlPointNumber, pParticles->m_flCurTime, &vecBasePos );
s_BoneMutex.Lock();
C_BaseAnimating *pAnimating = pMoveParent->GetBaseAnimating();
if ( pAnimating )
{
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
if ( pAnimating->HitboxToWorldTransforms( hitboxbones ) )
{
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if ( pStudioHdr )
{
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( set )
{
bSucesss = true;
Vector vecWorldPosition;
float u = 0, v = 0, w = 0;
int nHitbox = 0;
int nNumIters = nNumTrysToGetAPointInsideTheModel;
if (! vecDirectionalBias.IsZero( 0.0001 ) )
nNumIters = max( nNumIters, 5 );
for( int i=0 ; i < nNumPtsOut; i++)
{
int nTryCnt = nNumIters;
float flBestPointGoodness = -1.0e20;
do
{
int nTryHitbox = pParticles->RandomInt( 0, set->numhitboxes - 1 );
mstudiobbox_t *pBox = set->pHitbox(nTryHitbox);
float flTryU = pParticles->RandomFloat( flRandMin, flRandMax );
float flTryV = pParticles->RandomFloat( flRandMin, flRandMax );
float flTryW = pParticles->RandomFloat( flRandMin, flRandMax );
Vector vecLocalPosition;
vecLocalPosition.x = GetSurfaceCoord( flTryU, pBox->bbmin.x, pBox->bbmax.x );
vecLocalPosition.y = GetSurfaceCoord( flTryV, pBox->bbmin.y, pBox->bbmax.y );
vecLocalPosition.z = GetSurfaceCoord( flTryW, pBox->bbmin.z, pBox->bbmax.z );
Vector vecTryWorldPosition;
VectorTransform( vecLocalPosition, *hitboxbones[pBox->bone], vecTryWorldPosition );
float flPointGoodness = pParticles->RandomFloat( 0, 72 )
+ DotProduct( vecTryWorldPosition - vecBasePos,
vecDirectionalBias );
if ( nNumTrysToGetAPointInsideTheModel )
{
// do a point in solid test
Ray_t ray;
trace_t tr;
ray.Init( vecTryWorldPosition, vecTryWorldPosition );
enginetrace->ClipRayToEntity( ray, MASK_ALL, pMoveParent, &tr );
if ( tr.startsolid )
flPointGoodness += 1000.; // got a point inside!
}
if ( flPointGoodness > flBestPointGoodness )
{
u = flTryU;
v = flTryV;
w = flTryW;
//.........这里部分代码省略.........
示例8: GetControllingObjectHitBoxInfo
int CParticleSystemQuery::GetControllingObjectHitBoxInfo(
CParticleCollection *pParticles,
int nControlPointNumber,
int nBufSize, // # of output slots available
ModelHitBoxInfo_t *pHitBoxOutputBuffer )
{
int nRet = 0;
#ifndef GAME_DLL
s_BoneMutex.Lock();
EHANDLE *phMoveParent = reinterpret_cast<EHANDLE *> ( pParticles->ControlPoint( nControlPointNumber ).m_pObject );
CBaseEntity *pMoveParent = NULL;
if ( phMoveParent )
{
pMoveParent = *( phMoveParent );
}
if ( pMoveParent )
{
C_BaseAnimating *pAnimating = pMoveParent->GetBaseAnimating();
if ( pAnimating )
{
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
if ( pAnimating->HitboxToWorldTransforms( hitboxbones ) )
{
studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if ( pStudioHdr )
{
// Try to get the "effects" set first, otherwise use their current set
int nEffectsHitboxSet = FindHitboxSetByName( pAnimating->GetModelPtr(), "effects" );
mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( nEffectsHitboxSet != -1 ? nEffectsHitboxSet : pAnimating->GetHitboxSet() );
if ( set )
{
for( int i=0 ; i < set->numhitboxes; i++ )
{
mstudiobbox_t *pBox = set->pHitbox( i );
// E3 HACK - check for hitboxes at the origin and ignore those
if ( fabs( (*hitboxbones[pBox->bone])[0][3] ) < POINT_AT_ORIGIN_EPSILON && fabs( (*hitboxbones[pBox->bone])[1][3] ) < POINT_AT_ORIGIN_EPSILON && fabs( (*hitboxbones[pBox->bone])[2][3] ) < POINT_AT_ORIGIN_EPSILON )
{
continue;
}
pHitBoxOutputBuffer[nRet].m_vecBoxMins.x = pBox->bbmin.x;
pHitBoxOutputBuffer[nRet].m_vecBoxMins.y = pBox->bbmin.y;
pHitBoxOutputBuffer[nRet].m_vecBoxMins.z = pBox->bbmin.z;
pHitBoxOutputBuffer[nRet].m_vecBoxMaxes.x = pBox->bbmax.x;
pHitBoxOutputBuffer[nRet].m_vecBoxMaxes.y = pBox->bbmax.y;
pHitBoxOutputBuffer[nRet].m_vecBoxMaxes.z = pBox->bbmax.z;
pHitBoxOutputBuffer[nRet].m_Transform = *hitboxbones[pBox->bone];
nRet++;
if ( nRet >= nBufSize )
{
break;
}
}
}
}
}
}
if ( pMoveParent->IsBrushModel() )
{
Vector vecMin;
Vector vecMax;
matrix3x4_t matOrientation;
pMoveParent->GetRenderBounds( vecMin, vecMax );
matOrientation = pMoveParent->EntityToWorldTransform();
pHitBoxOutputBuffer[0].m_vecBoxMins = vecMin;
pHitBoxOutputBuffer[0].m_vecBoxMaxes = vecMax;
pHitBoxOutputBuffer[0].m_Transform = matOrientation;
nRet = 1;
}
}
s_BoneMutex.Unlock();
#endif
return nRet;
}