Exemplo n.º 1
0
	bool bounding_box::contains(const sphere & sphere) const
	{
		const math::box & box = bounding_box::get_box();
		const math::point & min = box.get_min();
		const math::point & max = box.get_max();
		float sq_dist = 0.f;

		int matches = 0;

		for (int i = 0; i < 3; i++)
		{
			float v = sphere.get_origin()[i];

			if (v < min[i])
			{
				sq_dist += std::pow(min[i] - v, 2);
			}
			else if (v > max[i])
			{
				sq_dist += std::pow(v - max[i], 2);
			}
			else if (v >= min[i] + sphere.get_radius()
				&& v <= max[i] - sphere.get_radius())
			{
				matches++;
			}
		}

		return matches == 3;
	}
Exemplo n.º 2
0
	bounding_sphere::bounding_sphere(const sphere & sphere)
		: bounding_volume(sphere.get_origin(), sphere.get_radius(), type::sphere)
	{}