2015-08-29 04:49:19 +00:00
|
|
|
#ifndef CSPHERE_HPP
|
|
|
|
#define CSPHERE_HPP
|
|
|
|
|
|
|
|
#include "CVector3f.hpp"
|
|
|
|
|
2015-10-08 00:21:38 +00:00
|
|
|
namespace Zeus
|
|
|
|
{
|
2015-10-25 19:31:41 +00:00
|
|
|
class alignas(16) CSphere
|
2015-08-29 04:49:19 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
ZE_DECLARE_ALIGNED_ALLOCATOR();
|
|
|
|
|
2015-11-02 18:44:46 +00:00
|
|
|
CSphere(const CVector3f& position, float radius)
|
|
|
|
: position(position), radius(radius) { }
|
2015-08-29 04:49:19 +00:00
|
|
|
|
2015-11-02 18:44:46 +00:00
|
|
|
inline CVector3f getSurfaceNormal(const CVector3f& coord)
|
|
|
|
{ return (position - coord).normalized(); }
|
|
|
|
|
|
|
|
inline bool intersects(const CSphere& other)
|
2015-08-29 04:49:19 +00:00
|
|
|
{
|
2015-11-02 18:44:46 +00:00
|
|
|
float dist = (position - other.position).magnitude();
|
|
|
|
return dist < (radius + other.radius);
|
|
|
|
}
|
|
|
|
|
|
|
|
CVector3f position;
|
|
|
|
float radius;
|
2015-08-29 04:49:19 +00:00
|
|
|
};
|
2015-10-08 00:21:38 +00:00
|
|
|
}
|
2015-08-29 04:49:19 +00:00
|
|
|
|
|
|
|
#endif
|