This commit is contained in:
Branimir Karadžić 2017-09-25 20:18:19 -07:00
parent 88e00edf4d
commit b0ae54f14a
2 changed files with 23 additions and 2 deletions

View File

@ -531,7 +531,7 @@ bool intersect(const Ray& _ray, const Disk& _disk, Intersection* _intersection)
return false;
}
bool intersect(const Ray& _ray, const Cylinder& _cylinder, bool _capsule, Intersection* _intersection)
static bool intersect(const Ray& _ray, const Cylinder& _cylinder, bool _capsule, Intersection* _intersection)
{
float axis[3];
bx::vec3Sub(axis, _cylinder.m_end, _cylinder.m_pos);
@ -652,6 +652,17 @@ bool intersect(const Ray& _ray, const Cylinder& _cylinder, bool _capsule, Inters
return false;
}
bool intersect(const Ray& _ray, const Cylinder& _cylinder, Intersection* _intersection)
{
return intersect(_ray, _cylinder, false, _intersection);
}
bool intersect(const Ray& _ray, const Capsule& _capsule, Intersection* _intersection)
{
BX_STATIC_ASSERT(sizeof(Capsule) == sizeof(Cylinder) );
return intersect(_ray, *( (const Cylinder*)&_capsule), true, _intersection);
}
bool intersect(const Ray& _ray, const Cone& _cone, Intersection* _intersection)
{
float axis[3];

View File

@ -19,6 +19,13 @@ struct Cylinder
float m_radius;
};
struct Capsule
{
float m_pos[3];
float m_end[3];
float m_radius;
};
struct Cone
{
float m_pos[3];
@ -123,7 +130,10 @@ Ray makeRay(float _x, float _y, const float* _invVp);
bool intersect(const Ray& _ray, const Aabb& _aabb, Intersection* _intersection = NULL);
/// Intersect ray / cylinder.
bool intersect(const Ray& _ray, const Cylinder& _cylinder, bool _capsule, Intersection* _intersection = NULL);
bool intersect(const Ray& _ray, const Cylinder& _cylinder, Intersection* _intersection = NULL);
/// Intersect ray / capsule.
bool intersect(const Ray& _ray, const Capsule& _capsule, Intersection* _intersection = NULL);
/// Intersect ray / cone.
bool intersect(const Ray& _ray, const Cone& _cone, Intersection* _intersection = NULL);