示例#1
0
文件: sphere.hpp 项目: mojocorp/gtl
        //! Extend the boundaries of the sphere by the given sphere.
        void extendBy(const sphere<Type>& sphere)
        {
            if (intersect(sphere))
                return;

            const vec3<Type> dir = (m_center - sphere.getCenter()).normalized();
            const vec3<Type> p1 = m_center + m_radius * dir;
            const vec3<Type> p2 = sphere.getCenter() - sphere.getRadius() * dir;

            setPoles(p1, p2);
        }
示例#2
0
文件: sphere.hpp 项目: mojocorp/gtl
        //! Intersect with a sphere, returning true if there is an intersection.
        bool intersect(const sphere<Type>& s) const
        {
            const Type d1 = (s.getCenter() - m_center).sqrLength();
            const Type d2 = m_radius + s.getRadius();

            return (d1 < d2 * d2);
        }
示例#3
0
文件: sphere.cpp 项目: EddyGun/Vulkan
sphere sphere::operator +(const sphere& other) const
{
	glm::vec4 center = (c + other.getCenter()) * 0.5f;

	float radius = glm::distance(c, center) + glm::max(r, other.getRadius());

	return sphere(center, radius);
}
示例#4
0
VkBool32 frustum::isVisible(const sphere& sphereWorld) const
{
	float distance;

	for (auto& currentSide : sidesWorld)
	{
		distance = currentSide.distance(sphereWorld.getCenter());

		if (distance + sphereWorld.getRadius() < 0.0f)
		{
			return VK_FALSE;
		}
	}

	return VK_TRUE;
}
示例#5
0
文件: sphere.cpp 项目: EddyGun/Vulkan
float sphere::distance(const sphere& sphere) const
{
	return glm::abs(glm::distance(c, sphere.getCenter())) - r - sphere.getRadius();
}
示例#6
0
文件: sphere.cpp 项目: EddyGun/Vulkan
sphere operator *(const glm::mat4& transform, const sphere& s)
{
	return sphere(transform * s.getCenter(), s.getRadius());
}