int CBaseCombatWeapon::GetAvailableWeaponsInBox( CBaseCombatWeapon **pList, int listMax, const Vector &mins, const Vector &maxs ) { // linear search all weapons int count = 0; int index = g_WeaponList.m_list.Head(); while ( index != g_WeaponList.m_list.InvalidIndex() ) { CBaseCombatWeapon *pWeapon = g_WeaponList.m_list[index]; // skip any held weapon if ( !pWeapon->GetOwner() ) { // restrict to mins/maxs if ( IsPointInBox( pWeapon->GetAbsOrigin(), mins, maxs ) ) { if ( count < listMax ) { pList[count] = pWeapon; count++; } } } index = g_WeaponList.m_list.Next( index ); } return count; }
CBool COctree::AttachGeometriesToNode() { for( CUInt i = 0 ; i < g_scene.size(); i++ ) { g_render.SetScene( g_scene[i]); if( !g_render.GetScene()->m_isTrigger ) { for( CUInt j = 0; j < g_scene[i]->m_instanceGeometries.size(); j++ ) { if( !( g_scene[i]->m_instanceGeometries[j]->m_hasPhysX && g_scene[i]->m_instanceGeometries[j]->m_physXDensity > 0 ) ) { CGeometry* m_abstractGeometry = g_scene[i]->m_instanceGeometries[j]->m_abstractGeometry; if( !m_abstractGeometry->m_hasAnimation ) { for( CUInt k = 0; k < 8/*m_abstractGeometry->m_vertexcount*/; k++ ) { CVec3f p/*,pt*/; p = /*m_abstractGeometry->m_points[k];*/g_scene[i]->m_instanceGeometries[j]->m_localToWorldVertex[k]; //CMatrixTransform( g_scene[i]->m_instanceGeometries[j]->m_localToWorldMatrix, p, pt ); CBool foundTarget = CFalse; if( IsPointInBox( &p/*pt*/ ) ) { g_scene[i]->m_instanceGeometries[j]->m_parentTree.push_back( this ); foundTarget = CTrue; m_geoCount++; break; } if( foundTarget ) break; } } } } } } if( m_geoCount > g_sceneManagerObjectsPerSplit ) { SplitNode8( this ); m_leaf = CTrue; } return CTrue; }
/* --------------------------------------------------------------------------- * checks if a point is on a pin */ bool IsPointOnPin (Coord X, Coord Y, Coord Radius, PinTypePtr pin) { Coord t = PIN_SIZE (pin) / 2; if (TEST_FLAG (SQUAREFLAG, pin)) { BoxType b; b.X1 = pin->X - t; b.X2 = pin->X + t; b.Y1 = pin->Y - t; b.Y2 = pin->Y + t; if (IsPointInBox (X, Y, &b, Radius)) return true; } else if (Distance (pin->X, pin->Y, X, Y) <= Radius + t) return true; return false; }
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; }