当前位置: 首页>>代码示例>>C++>>正文


C++ BoundingSphere::Intersects方法代码示例

本文整理汇总了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}));
}
开发者ID:colajam93,项目名称:pomdog,代码行数:38,代码来源:BoundingSphereTest.cpp

示例2:

	std::unique_ptr<float> Ray::Intersects(const BoundingSphere& bs)
	{
		return bs.Intersects(*this);
	}
开发者ID:Swillis57,项目名称:YAX,代码行数:4,代码来源:Ray.cpp

示例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);
}
开发者ID:RioDream,项目名称:Learning-D3D,代码行数:6,代码来源:GameBase.cpp


注:本文中的BoundingSphere::Intersects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。