本文整理汇总了C++中AABB::Intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ AABB::Intersects方法的具体用法?C++ AABB::Intersects怎么用?C++ AABB::Intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABB
的用法示例。
在下文中一共展示了AABB::Intersects方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Query_Region
void Octree::Query_Region(const AABB ®ion, std::vector<OctreeOccupant*> &result) const
{
// Query outside root elements
for(std::unordered_set<OctreeOccupant*>::iterator it = m_outsideRoot.begin(); it != m_outsideRoot.end(); it++)
{
OctreeOccupant* pOc = *it;
if(region.Intersects(pOc->m_aabb))
{
// Intersects, add to list
result.push_back(pOc);
}
}
std::list<OctreeNode*> open;
open.push_back(m_pRootNode.get());
while(!open.empty())
{
// Depth-first (results in less memory usage), remove objects from open list
OctreeNode* pCurrent = open.back();
open.pop_back();
if(region.Intersects(pCurrent->m_region))
{
for(std::unordered_set<OctreeOccupant*>::iterator it = pCurrent->m_pOccupants.begin(); it != pCurrent->m_pOccupants.end(); it++)
{
OctreeOccupant* pOc = *it;
if(region.Intersects(pOc->m_aabb))
{
// Visible, add to list
result.push_back(pOc);
}
}
// Add children to open list if they intersect the region
if(pCurrent->m_hasChildren)
{
for(int x = 0; x < 2; x++)
for(int y = 0; y < 2; y++)
for(int z = 0; z < 2; z++)
{
if((*pCurrent->m_children)[x][y][z].GetNumOccupantsBelow() != 0)
open.push_back(&(*pCurrent->m_children)[x][y][z]);
}
}
}
}
}
示例2: SweepAgainst
bool Ellipsoid::SweepAgainst(const CollisionTriangle& t, const Vector& v,
const AABB& SweepAABB,
CollisionInfo* const pInfo) const {
if (SweepAABB.Intersects(t.m_AABB)) // Broad phase: test sweep bounds against
// precomputed triangle bounds
{
const Vector InvExtents = 1.0f / m_Extents;
const Triangle ESpaceTri(t.m_Triangle.m_Vec1 * InvExtents,
t.m_Triangle.m_Vec2 * InvExtents,
t.m_Triangle.m_Vec3 * InvExtents);
const Sphere UnitSphere(m_Center * InvExtents, 1.0f);
const Vector ESpaceOffset = v * InvExtents;
if (UnitSphere.SweepAgainst(ESpaceTri, ESpaceOffset, pInfo)) {
if (pInfo) {
pInfo->m_Intersection *= m_Extents;
pInfo->m_Plane =
Plane((pInfo->m_Plane.m_Normal * InvExtents).GetNormalized(),
pInfo->m_Intersection);
}
return true;
}
}
return false;
}
示例3: Query
_Use_decl_annotations_
void BIH::Query(const AABB& test, uint32_t* numTriangles)
{
*numTriangles = 0;
if (!test.Intersects(_bounds))
{
return;
}
Query(test, _root, numTriangles);
}
示例4: RandomFrustumContainingPoint
MATH_IGNORE_UNUSED_VARS_WARNING
RANDOMIZED_TEST(AABBPBVolumeIntersect)
{
vec pt = vec::RandomBox(rng, POINT_VEC_SCALAR(-SCALE), POINT_VEC_SCALAR(SCALE));
Frustum b = RandomFrustumContainingPoint(pt);
AABB a = RandomAABBContainingPoint(pt, 10.f);
assert(a.Intersects(b));
assert(b.Intersects(a));
bool contained = b.Contains(a);
vec centerPoint = b.CenterPoint();
assert(b.Contains(b.CenterPoint()));
PBVolume<6> pbVolume = ToPBVolume(b);
assert(pbVolume.Contains(b.CenterPoint()));
CullTestResult r = pbVolume.InsideOrIntersects(a);
assert(r == TestInside || r == TestNotContained);
if (contained)
assert(r == TestInside);
}
示例5: Intersects
inline bool Intersects(PhysicsObject Other) {
if (Other._id == _parentID || Other._parentID == _id)
return false;
return _aabb.Intersects(Other._aabb);
}
示例6: Intersects
bool Polygon::Intersects(const AABB &aabb) const
{
return aabb.Intersects(*this);
}
示例7: Intersects
bool Sphere::Intersects(const AABB &aabb, vec *closestPointOnAABB) const
{
return aabb.Intersects(*this, closestPointOnAABB);
}
示例8: Intersects
bool Ray::Intersects(const AABB &aabb, float *dNear, float *dFar) const
{
return aabb.Intersects(*this, dNear, dFar);
}
示例9: Intersects
bool Ray::Intersects(const AABB &aabb) const
{
return aabb.Intersects(*this);
}
示例10: GetEntity
/*virtual*/ void WBCompEldIcicles::Tick( float DeltaTime )
{
XTRACE_FUNCTION;
PROFILE_FUNCTION;
Unused( DeltaTime );
WBEntity* const pEntity = GetEntity();
ASSERT( pEntity );
WBCompEldAnchor* const pAnchor = GET_WBCOMP( pEntity, EldAnchor );
ASSERT( pAnchor );
if( !pAnchor->IsAnchored() )
{
return;
}
WBEntity* const pPlayer = EldritchGame::GetPlayer();
if( !pPlayer )
{
return;
}
WBCompStatMod* const pPlayerStatMod = GET_WBCOMP( pPlayer, StatMod );
ASSERT( pPlayerStatMod );
WB_MODIFY_FLOAT( IgnoreIcicles, 0.0f, pPlayerStatMod );
const bool IgnoreIcicles = ( WB_MODDED( IgnoreIcicles ) != 0.0f );
if( IgnoreIcicles )
{
return;
}
EldritchWorld* const pWorld = GetWorld();
ASSERT( pWorld );
WBCompEldTransform* const pTransform = pEntity->GetTransformComponent<WBCompEldTransform>();
ASSERT( pTransform );
WBCompEldCollision* const pCollision = GET_WBCOMP( pEntity, EldCollision );
ASSERT( pCollision );
WBCompEldTransform* const pPlayerTransform = pPlayer->GetTransformComponent<WBCompEldTransform>();
ASSERT( pPlayerTransform );
WBCompEldCollision* const pPlayerCollision = GET_WBCOMP( pPlayer, EldCollision );
ASSERT( pPlayerCollision );
const Vector CheckOffset = Vector( 0.0f, 0.0f, -m_CheckDistance );
const Vector TraceStart = pTransform->GetLocation();
Vector TraceEnd = TraceStart + CheckOffset;
// Early out if player doesn't intersect the trace bounds.
Vector EntityExtents = pCollision->GetExtents();
EntityExtents.z = 0.0f;
const AABB TraceBox = AABB( TraceEnd - EntityExtents, TraceStart + EntityExtents );
const AABB PlayerBox = pPlayerCollision->GetBounds();
if( !TraceBox.Intersects( PlayerBox ) )
{
return;
}
// Move trace up to the top of player so we don't check occlusion beyond player.
const float PlayerTopZ = PlayerBox.m_Max.z;
TraceEnd.z = PlayerTopZ;
// Do an occlusion test to make sure there's nothing blocking the trace.
CollisionInfo Info;
Info.m_CollideWorld = true;
Info.m_CollideEntities = true;
Info.m_CollidingEntity = pEntity;
Info.m_UserFlags = EECF_Occlusion;
Info.m_StopAtAnyCollision = true;
const bool Occluded = pWorld->LineCheck( TraceStart, TraceEnd, Info );
if( Occluded )
{
return;
}
// All checks passed. Unanchor to initiate falling sequence
WB_MAKE_EVENT( Unanchor, pEntity );
WB_DISPATCH_EVENT( GetEventManager(), Unanchor, pEntity );
}
示例11: Intersects
bool Line::Intersects(const AABB &aabb, float &dNear, float &dFar) const
{
return aabb.Intersects(*this, dNear, dFar);
}