本文整理汇总了C++中IPhysicsObject::GetGameData方法的典型用法代码示例。如果您正苦于以下问题:C++ IPhysicsObject::GetGameData方法的具体用法?C++ IPhysicsObject::GetGameData怎么用?C++ IPhysicsObject::GetGameData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPhysicsObject
的用法示例。
在下文中一共展示了IPhysicsObject::GetGameData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSpringObjectConnections
void CPhysicsSpring::GetSpringObjectConnections( string_t nameStart, string_t nameEnd, IPhysicsObject **pStart, IPhysicsObject **pEnd )
{
IPhysicsObject *pStartObject = FindPhysicsObject( STRING(nameStart) );
IPhysicsObject *pEndObject = FindPhysicsObject( STRING(nameEnd) );
// Assume the world for missing objects
if ( !pStartObject )
{
pStartObject = g_PhysWorldObject;
}
else if ( !pEndObject )
{
// try to sort so that the world is always the start object
pEndObject = pStartObject;
pStartObject = g_PhysWorldObject;
}
else
{
CBaseEntity *pEntity0 = (CBaseEntity *) (pStartObject->GetGameData());
g_pNotify->AddEntity( this, pEntity0 );
CBaseEntity *pEntity1 = (CBaseEntity *) pEndObject->GetGameData();
g_pNotify->AddEntity( this, pEntity1 );
}
*pStart = pStartObject;
*pEnd = pEndObject;
}
示例2: do_raycasts_gameside
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPhysics_Airboat::do_raycasts_gameside( int nRaycastCount, IVP_Ray_Solver_Template *pRays,
IVP_Raycast_Airboat_Impact *pImpacts )
{
Assert( nRaycastCount >= 0 );
Assert( nRaycastCount <= IVP_RAYCAST_AIRBOAT_MAX_WHEELS );
Ray_t gameRays[IVP_RAYCAST_AIRBOAT_MAX_WHEELS];
pre_raycasts_gameside( nRaycastCount, pRays, gameRays, pImpacts );
// Do the raycasts and set impact data.
trace_t trace;
for ( int iRaycast = 0; iRaycast < nRaycastCount; ++iRaycast )
{
// Trace.
if ( pImpacts[iRaycast].bInWater )
{
IPhysicsObject *pPhysAirboat = static_cast<IPhysicsObject*>( m_pAirboatBody->client_data );
m_pGameTrace->VehicleTraceRay( gameRays[iRaycast], pPhysAirboat->GetGameData(), &trace );
}
else
{
IPhysicsObject *pPhysAirboat = static_cast<IPhysicsObject*>( m_pAirboatBody->client_data );
m_pGameTrace->VehicleTraceRayWithWater( gameRays[iRaycast], pPhysAirboat->GetGameData(), &trace );
}
// Set impact data.
if ( trace.fraction == 1.0f )
{
pImpacts[iRaycast].bImpact = IVP_FALSE;
}
else
{
pImpacts[iRaycast].bImpact = IVP_TRUE;
// Set water surface flag.
pImpacts[iRaycast].bImpactWater = IVP_FALSE;
if ( trace.contents & MASK_WATER )
{
pImpacts[iRaycast].bImpactWater = IVP_TRUE;
}
// Save impact surface data.
ConvertPositionToIVP( trace.endpos, pImpacts[iRaycast].vecImpactPointWS );
ConvertDirectionToIVP( trace.plane.normal, pImpacts[iRaycast].vecImpactNormalWS );
// Save surface properties.
surfacedata_t *pSurfaceData = physprops->GetSurfaceData( trace.surface.surfaceProps );
pImpacts[iRaycast].flDampening = pSurfaceData->dampening;
pImpacts[iRaycast].flFriction = pSurfaceData->friction;
}
}
}
示例3:
static CBaseEntity *FindPhysicsBlocker( IPhysicsObject *pPhysics )
{
IPhysicsFrictionSnapshot *pSnapshot = pPhysics->CreateFrictionSnapshot();
CBaseEntity *pBlocker = NULL;
float maxVel = 10.0f;
while ( pSnapshot->IsValid() )
{
IPhysicsObject *pOther = pSnapshot->GetObject(1);
if ( pOther->IsMoveable() )
{
CBaseEntity *pOtherEntity = static_cast<CBaseEntity *>(pOther->GetGameData());
// dot with this if you have a direction
//Vector normal;
//pSnapshot->GetSurfaceNormal(normal);
float force = pSnapshot->GetNormalForce();
float vel = force * pOther->GetInvMass();
if ( vel > maxVel )
{
pBlocker = pOtherEntity;
maxVel = vel;
}
}
pSnapshot->NextFrictionData();
}
pPhysics->DestroyFrictionSnapshot( pSnapshot );
return pBlocker;
}
示例4: IsTouchingPortal
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTriggerPortal::IsTouchingPortal( CBaseEntity *pEntity )
{
// First, check the touchlinks. This will find non-vphysics entities touching us
touchlink_t *root = ( touchlink_t * )GetDataObject( TOUCHLINK );
if ( root )
{
for ( touchlink_t *link = root->nextLink; link != root; link = link->nextLink )
{
CBaseEntity *pTouch = link->entityTouched;
if ( pTouch == pEntity )
return true;
}
}
// Then check the friction snapshot. This will find vphysics objects touching us.
IPhysicsObject *pPhysics = VPhysicsGetObject();
if ( !pPhysics )
return false;
IPhysicsFrictionSnapshot *pSnapshot = pPhysics->CreateFrictionSnapshot();
bool bFound = false;
while ( pSnapshot->IsValid() )
{
IPhysicsObject *pOther = pSnapshot->GetObject( 1 );
if ( ((CBaseEntity *)pOther->GetGameData()) == pEntity )
{
bFound = true;
break;
}
pSnapshot->NextFrictionData();
}
pPhysics->DestroyFrictionSnapshot( pSnapshot );
return bFound;
}
示例5: ObjectSound
void CCollisionEvent::ObjectSound( int index, vcollisionevent_t *pEvent )
{
IPhysicsObject *pObject = pEvent->pObjects[index];
if ( !pObject || pObject->IsStatic() )
return;
float speed = pEvent->collisionSpeed * pEvent->collisionSpeed;
int surfaceProps = pEvent->surfaceProps[index];
void *pGameData = pObject->GetGameData();
if ( pGameData )
{
float volume = speed * (1.0f/(320.0f*320.0f)); // max volume at 320 in/s
if ( volume > 1.0f )
volume = 1.0f;
if ( surfaceProps >= 0 )
{
g_PhysicsSystem.AddImpactSound( pGameData, pObject, surfaceProps, pEvent->surfaceProps[!index], volume, speed );
}
}
}
示例6: PhysHasContactWithOtherInDirection
bool PhysHasContactWithOtherInDirection( IPhysicsObject *pPhysics, const Vector &dir )
{
bool hit = false;
void *pGameData = pPhysics->GetGameData();
IPhysicsFrictionSnapshot *pSnapshot = pPhysics->CreateFrictionSnapshot();
while ( pSnapshot->IsValid() )
{
IPhysicsObject *pOther = pSnapshot->GetObject( 1 );
if ( pOther->GetGameData() != pGameData )
{
Vector normal;
pSnapshot->GetSurfaceNormal( normal );
if ( DotProduct(normal,dir) > 0 )
{
hit = true;
break;
}
}
pSnapshot->NextFrictionData();
}
pPhysics->DestroyFrictionSnapshot( pSnapshot );
return hit;
}
示例7: CalculateObjectStress
float CalculateObjectStress( IPhysicsObject *pObject, CBaseEntity *pInputOwnerEntity, vphysics_objectstress_t *pOutput )
{
CUtlVector< CBaseEntity * > pObjectList;
CUtlVector< Vector > objectForce;
bool hasLargeObject = false;
// add a slot for static objects
pObjectList.AddToTail( NULL );
objectForce.AddToTail( vec3_origin );
// add a slot for friendly objects
pObjectList.AddToTail( NULL );
objectForce.AddToTail( vec3_origin );
CBaseCombatCharacter *pBCC = pInputOwnerEntity->MyCombatCharacterPointer();
IPhysicsFrictionSnapshot *pSnapshot = pObject->CreateFrictionSnapshot();
float objMass = pObject->GetMass();
while ( pSnapshot->IsValid() )
{
float force = pSnapshot->GetNormalForce();
if ( force > 0.0f )
{
IPhysicsObject *pOther = pSnapshot->GetObject(1);
CBaseEntity *pOtherEntity = static_cast<CBaseEntity *>(pOther->GetGameData());
if ( !pOtherEntity )
{
// object was just deleted, but we still have a contact point this frame...
// just assume it came from the world.
pOtherEntity = GetWorldEntity();
}
CBaseEntity *pOtherOwner = pOtherEntity;
if ( pOtherEntity->GetOwnerEntity() )
{
pOtherOwner = pOtherEntity->GetOwnerEntity();
}
int outIndex = 0;
if ( !pOther->IsMoveable() )
{
outIndex = 0;
}
// NavIgnored objects are often being pushed by a friendly
else if ( pBCC && (pBCC->IRelationType( pOtherOwner ) == D_LI || pOtherEntity->IsNavIgnored()) )
{
outIndex = 1;
}
// player held objects do no stress
else if ( pOther->GetGameFlags() & FVPHYSICS_PLAYER_HELD )
{
outIndex = 1;
}
else
{
if ( pOther->GetMass() >= VPHYSICS_LARGE_OBJECT_MASS )
{
if ( pInputOwnerEntity->GetGroundEntity() != pOtherEntity)
{
hasLargeObject = true;
}
}
// moveable, non-friendly
// aggregate contacts over each object to avoid greater stress in multiple contact cases
// NOTE: Contacts should be in order, so this shouldn't ever search, but just in case
outIndex = pObjectList.Count();
for ( int i = pObjectList.Count()-1; i >= 2; --i )
{
if ( pObjectList[i] == pOtherOwner )
{
outIndex = i;
break;
}
}
if ( outIndex == pObjectList.Count() )
{
pObjectList.AddToTail( pOtherOwner );
objectForce.AddToTail( vec3_origin );
}
}
if ( outIndex != 0 && pInputOwnerEntity->GetMoveType() != MOVETYPE_VPHYSICS && !IsPhysicallyControlled(pOtherEntity, pOther) )
{
// UNDONE: Test this! This is to remove any shadow/shadow stress. The game should handle this with blocked/damage
force = 0.0f;
}
Vector normal;
pSnapshot->GetSurfaceNormal( normal );
objectForce[outIndex] += normal * force;
}
pSnapshot->NextFrictionData();
}
pObject->DestroyFrictionSnapshot( pSnapshot );
pSnapshot = NULL;
// clear out all friendly force
objectForce[1].Init();
float sum = 0;
Vector negativeForce = vec3_origin;
//.........这里部分代码省略.........