diff --git a/examples/29-debugdraw/debugdraw.cpp b/examples/29-debugdraw/debugdraw.cpp index ce7126242..6ae1077a7 100644 --- a/examples/29-debugdraw/debugdraw.cpp +++ b/examples/29-debugdraw/debugdraw.cpp @@ -94,6 +94,32 @@ public: return 0; } + template + bool intersect(const Ray& _ray, const Ty& _shape) + { + Hit hit; + if (::intersect(_ray, _shape, &hit) ) + { + ddPush(); + + ddSetColor(0xff0000ff); + + float tmp[3]; + bx::vec3Mul(tmp, hit.m_normal, 0.7f); + + float end[3]; + bx::vec3Add(end, hit.m_pos, tmp); + + ddDrawCone(hit.m_pos, end, 0.1f); + + ddPop(); + + return true; + } + + return false; + } + bool update() override { if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) ) diff --git a/examples/common/bounds.cpp b/examples/common/bounds.cpp index a333b019d..b8cfc5416 100644 --- a/examples/common/bounds.cpp +++ b/examples/common/bounds.cpp @@ -729,14 +729,14 @@ bool intersect(const Ray& _ray, const Capsule& _capsule, Hit* _hit) bool intersect(const Ray& _ray, const Cone& _cone, Hit* _hit) { float axis[3]; - bx::vec3Sub(axis, _cone.m_end, _cone.m_pos); + bx::vec3Sub(axis, _cone.m_pos, _cone.m_end); float normal[3]; const float len = bx::vec3Norm(normal, axis); Disk disk; bx::vec3Move(disk.m_center, _cone.m_pos); - bx::vec3Neg(disk.m_normal, normal); + bx::vec3Move(disk.m_normal, normal); disk.m_radius = _cone.m_radius; Hit tmpInt; @@ -783,7 +783,7 @@ bool intersect(const Ray& _ray, const Cone& _cone, Hit* _hit) getPointAt(hitPos, _ray, tt); float point[3]; - bx::vec3Sub(point, hitPos, _cone.m_pos); + bx::vec3Sub(point, hitPos, _cone.m_end); const float hh = bx::vec3Dot(normal, point);