本文整理汇总了C++中BoundingSphere::Intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingSphere::Intersects方法的具体用法?C++ BoundingSphere::Intersects怎么用?C++ BoundingSphere::Intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingSphere
的用法示例。
在下文中一共展示了BoundingSphere::Intersects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(BoundingSphere, Intersects_BoundingSphere)
{
BoundingSphere sphere;
sphere.Center = Vector3::Zero;
sphere.Radius = 42.0f;
EXPECT_TRUE(sphere.Intersects(sphere));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3::Zero, 43.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3::Zero, 41.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{40.f, 0.f, 0.f}, 1.9f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, 40.f, 0.f}, 1.9f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, 0.f, 40.f}, 1.9f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{-40.f, 0.f, 0.f}, 1.9f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, -40.f, 0.f}, 1.9f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, 0.f, -40.f}, 1.9f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{42.f, 0.f, 0.f}, 1.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, 42.f, 0.f}, 1.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, 0.f, 42.f}, 1.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{-42.f, 0.f, 0.f}, 1.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, -42.f, 0.f}, 1.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, 0.f, -42.f}, 1.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{43.f, 0.f, 0.f}, 2.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, 43.f, 0.f}, 2.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, 0.f, 43.f}, 2.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{-43.f, 0.f, 0.f}, 2.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, -43.f, 0.f}, 2.0f}));
EXPECT_TRUE(sphere.Intersects(BoundingSphere{Vector3{0.f, 0.f, -43.f}, 2.0f}));
EXPECT_FALSE(sphere.Intersects(BoundingSphere{Vector3{43.f, 0.f, 0.f}, 0.5f}));
EXPECT_FALSE(sphere.Intersects(BoundingSphere{Vector3{0.f, 43.f, 0.f}, 0.5f}));
EXPECT_FALSE(sphere.Intersects(BoundingSphere{Vector3{0.f, 0.f, 43.f}, 0.5f}));
EXPECT_FALSE(sphere.Intersects(BoundingSphere{Vector3{-43.f, 0.f, 0.f}, 0.5f}));
EXPECT_FALSE(sphere.Intersects(BoundingSphere{Vector3{0.f, -43.f, 0.f}, 0.5f}));
EXPECT_FALSE(sphere.Intersects(BoundingSphere{Vector3{0.f, 0.f, -43.f}, 0.5f}));
}
示例2:
std::unique_ptr<float> Ray::Intersects(const BoundingSphere& bs)
{
return bs.Intersects(*this);
}
示例3: LineSphereHitTest
bool GameBase::LineSphereHitTest(Mesh* mesh, const XMFLOAT3* p0, const XMFLOAT3* dir, float& outT)
{
XMFLOAT3 center(mesh->Extents().CenterX, mesh->Extents().CenterY, mesh->Extents().CenterZ);
BoundingSphere* sphere = new BoundingSphere(center, mesh->Extents().Radius);
return sphere->Intersects(XMLoadFloat3(p0), XMLoadFloat3(dir), outT);
}