コード例 #1
0
TEST( CollisionTests, RayVsSphere_WithinTowards )
{
	Ray ray;
	ray.Position	= vec3( 0.0f, 0.0f, 0.5f );
	ray.Direction	= glm::normalize( vec3( 0.0f, 0.0f, -1.0f ) );

	Sphere sphere;
	sphere.Position	= vec3( 0.0f, 0.0f, 0.0f );
	sphere.Radius	= 3.0f;

	IntersectionTestLookupTable testLookup;
	IntersectionTestFunction intersectionTestFunction = testLookup.Fetch( ray.GetVolumeType(), sphere.GetVolumeType() );

	EXPECT_TRUE( (*intersectionTestFunction)( &ray, &sphere, nullptr ) );
}
コード例 #2
0
TEST( CollisionTests, RayVsSphere_ParallelNearMiss )
{
	Ray ray;
	ray.Position	= vec3( 6.01f, 4.0f, 0.0f );
	ray.Direction	= glm::normalize( vec3( 0.0f, -1.0f, 0.0f ) );

	Sphere sphere;
	sphere.Position	= vec3( 0.0f, 0.0f, 0.0f );
	sphere.Radius	= 6.0f;

	IntersectionTestLookupTable testLookup;
	IntersectionTestFunction intersectionTestFunction = testLookup.Fetch( ray.GetVolumeType(), sphere.GetVolumeType() );

	EXPECT_FALSE( (*intersectionTestFunction)( &ray, &sphere, nullptr ) );
}