From b0ae54f14a23740a5103d8078b2e50c0a1b017c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 25 Sep 2017 20:18:19 -0700 Subject: [PATCH] Cleanup. --- examples/common/bounds.cpp | 13 ++++++++++++- examples/common/bounds.h | 12 +++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/examples/common/bounds.cpp b/examples/common/bounds.cpp index c6edfd1fb..d73b247c6 100644 --- a/examples/common/bounds.cpp +++ b/examples/common/bounds.cpp @@ -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]; diff --git a/examples/common/bounds.h b/examples/common/bounds.h index a0d6d47bf..59556b428 100644 --- a/examples/common/bounds.h +++ b/examples/common/bounds.h @@ -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);